plugin hooking... one step to void the /NOUNLOAD
HINSTANCE hInst;
HMODULE hMod;
int i;
HHOOK hHook;
HOOKPROC hHookProc;
#define Function(name) extern "C" void __declspec(dllexport) name(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
Function(suma)
{
EXDLL_INIT();
setuservariable(0, int2str(++i));
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
hInst = hinstDLL;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
i = 0;
hMod = LoadLibrary("nsDLL");
hHookProc = (HOOKPROC)GetProcAddress(hMod, "suma");
hHook = SetWindowsHookEx(WH_CBT, hHookProc, hMod, 0);
return TRUE;
}
case DLL_PROCESS_DETACH:
{
UnhookWindowsHookEx(hHook);
FreeLibrary(hMod);
return TRUE;
}
}
return TRUE;
}
Example:
Section
nsDLL::suma ; $0 1
nsDLL::suma; $0 2
nsDLL::suma ; $0 1
nsDLL::suma ; $0 2
DetailPrint $0 ; $0 2
SectionEnd
at the end, $0 returns 2, when it suppose to be 4.... what I'm missing? :igor: