| View previous topic :: View next topic |
| Author |
Message |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Nov 09, 2008 8:43 pm Post subject: I suck. SetWindowsHookEx DLL injection. |
|
|
GetProcAddress fails with ERROR_PROC_NOT_FOUND.
What am I overlooking within the DLL?
Inject
| Code: | void Injector::Inject(void){
if(CheckProcess()){
HMODULE dll = LoadLibrary(dll_name);
FARPROC proc = GetProcAddress(dll, "GetMsgProc");
HHOOK hh = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)proc, dll, te.th32ThreadID);
UnhookWindowsHookEx(hh);
}
} |
DLL
| Code: | #include <Windows.h>
extern "C" __declspec(dllexport)LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam){
return CallNextHookEx(0, nCode, wParam, lParam);
}
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved){
UNREFERENCED_PARAMETER(hinstDLL);
UNREFERENCED_PARAMETER(fdwReason);
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
MessageBox(0, "Hi", "Sup", MB_OK);
return TRUE;
case DLL_PROCESS_DETACH:
return TRUE;
}
return ERROR_SUCCESS;
} |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Nov 09, 2008 8:56 pm Post subject: |
|
|
| Quote: | SetWindowsHookEx
lpfn
[in] Pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a DLL. Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
hMod
[in] Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process. |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun Nov 09, 2008 9:02 pm Post subject: |
|
|
| slovach wrote: | | Quote: | SetWindowsHookEx
lpfn
[in] Pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a DLL. Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
hMod
[in] Handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process. |
|
oh duh. didnt read all the code. sorry.
_________________
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Nov 09, 2008 10:22 pm Post subject: |
|
|
Try using ordinals, and see what happens then?
Edit: This is assuming that you've verified your dll has loaded correctly.
_________________
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Sun Nov 09, 2008 11:01 pm Post subject: |
|
|
| Yeah I think that could be the problem, check what the function name is exported as. I gave the code a try and the dll works fine using "_GetMsgProc@12" or "GetMsgProc" /w def file.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Nov 09, 2008 11:04 pm Post subject: |
|
|
Damn, I should have thought of that.
Yeah, that's it.
|
|
| Back to top |
|
 |
|