I am having a problem with creating a remote thread. I create the remote thread to load a library. It does so succesfully. In the remote thread i then have it get the address of a function, thats where it fails.. Code of the remote thread below.
I did not include the code to prepare the remote thread, i'm pretty sure my problem isn't there
Code:
typedef FARPROC (__stdcall *PGetProcAddress)(HMODULE, LPCSTR);
struct RemoteThreadBlock
{
// Variable that will return the module handle and function address
HMODULE hModule;
FARPROC fFunctionAddress;
// Function that loads the library and gets the function address
PLoadLibraryW fnLoadLibrary;
PGetProcAddress fnGetProcAddress;
// The path to the library we will be loading and the function
wchar_t lpModulePath[_MAX_PATH];
LPCSTR lpFunctionName;
};
DWORD __stdcall RemoteThread (RemoteThreadBlock*);
BOOL TestFunction ();
BOOL TestFunction ()
{
return 0;
}
DWORD __stdcall RemoteThread (RemoteThreadBlock* ExecuteBlock)
{
HMODULE hModule;
// Load our library and return the module handle
hModule = (*ExecuteBlock->fnLoadLibrary)(ExecuteBlock->lpModulePath);
ExecuteBlock->fFunctionAddress = (*ExecuteBlock->fnGetProcAddress)(hModule, "TestFunction");
return 0;
}
I've been fighting with this thing for 3 weeks not, rewriting every piece of code. Any ideas?