ok, so i essentially have a .c file from anubis' process injection code, that i need converted to c++, which is the format of the rest of my product.
on compiling, i am getting one annoying error error (when i compile as a .cpp file):
1>.\inject.cpp(27) : error C2440: '=' : cannot convert from 'LPVOID' to 'HMODULE'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
the problem code
BOOL InjectExecutable(DWORD dwPid, LPTHREAD_START_ROUTINE lpStartProc, LPVOID lpParam)
{
HMODULE hModule, hNewModule;
DWORD dwSize;
HANDLE hProcess;
IMAGE_DOS_HEADER ImageDosHeader;
IMAGE_OPTIONAL_HEADER32 ImageOptionalHeader;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPid);
if (hProcess == NULL)
{
return FALSE;
}
hModule = GetModuleHandle(NULL);
CopyMemory(&ImageDosHeader, hModule, sizeof(ImageDosHeader));
CopyMemory(&ImageOptionalHeader, ((BYTE *)hModule + sizeof(DWORD) + ImageDosHeader.e_lfanew + sizeof(IMAGE_FILE_HEADER)), sizeof(ImageOptionalHeader));
dwSize = ImageOptionalHeader.SizeOfImage;
hNewModule = VirtualAllocEx(hProcess, hModule, dwSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (hNewModule == NULL)
{
return FALSE;
}
WriteProcessMemory(hProcess, hNewModule, hModule, dwSize, NULL);
CreateRemoteThread(hProcess, 0, 0, lpStartProc, lpParam, 0, NULL);
return TRUE;
}
help?