View previous topic :: View next topic |
Author |
Message |
decheatengine Cheater
Reputation: 0
Joined: 10 Jun 2007 Posts: 25
|
Posted: Tue Mar 18, 2008 10:04 pm Post subject: How to call a function inside a injected DLL? |
|
|
How to call a function inside a injected DLL from a GUI? I tried the below code but it didnt work.
Code: |
//inject the dll to the process
HMODULE dll = InjectDll("notepad.exe", "Trainer.dll");
//blah blah blah
//blah blah blah
//blah blah blah
//here try to invoke a functionn from GUI
HMODULE hDummy = LoadLibrary("Trainer.dll");
PVOID func = GetProcAddress(hDummy, "_Hello");
DWORD offset = (DWORD)func - (DWORD)hDummy;
DWORD realfunc = (DWORD)dll + offset;
HANDLE hThread = CreateRemoteThread(0, 0, 0, (LPTHREAD_START_ROUTINE)realfunc, 0, 0,0);
DWORD error = GetLastError();
if (hThread != 0)
{
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
FreeLibrary(hDummy);
}
|
The value in realfunc is correct after i checked it using moon LightEngine's "Enumerate DLL and Symbols". But CreateRemoteThread returned NULL and error = 6.
Help please. |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25785 Location: The netherlands
|
Posted: Tue Mar 18, 2008 10:58 pm Post subject: |
|
|
CreateRemoteThread needs the processhandle of the process you've injected the dll in.
If you're doing the current process, use -1, not 0. Else Give it the processhandle.
Also, you could run the function from the dllmain _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
decheatengine Cheater
Reputation: 0
Joined: 10 Jun 2007 Posts: 25
|
Posted: Sun Mar 23, 2008 6:23 am Post subject: |
|
|
DarkByte thanks for the answer. I'm now able to invoke a function in Notepad.exe but everytime the program crashes in FreeLibrary(hDummy). Shouldn't I need to free the library? |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25785 Location: The netherlands
|
Posted: Sun Mar 23, 2008 6:33 am Post subject: |
|
|
try FreeLibraryAndExitThread if you call the freelibrary from inside the dll _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
|