Note that there are some explanatory texts on larger screens.

plurals
  1. POHooking GetTickCount with C++
    primarykey
    data
    text
    <p>I'm not great at C++, more of a C# and PHP guy. I've been assigned a project that requires me to use <code>GetTickCount</code> and hooking into an application. I need some help as for some reason it's not working as planned... Here is the code for hooking, I know it works because i've used it in projects before. The only thing i'm not so sure about is the <code>GetTickCount</code> part of it. I tried <code>GetTickCount64</code> thinking that was a fix to my problem (It didn't crash what i was injecting it into) but found out that instead it just wasn't working at all so it didn't crash it.</p> <pre><code>bool APIENTRY DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) { switch(dwReason) { case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(hDll); CreateThread(0,0, (LPTHREAD_START_ROUTINE)KeyHooks, 0, 0, 0); GetTickCount_orig = (DWORD (__stdcall *)(void))DetourFunction((PBYTE)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetTickCount"), (PBYTE)GetTickCount_hooked); case DLL_PROCESS_DETACH: DetourRemove((PBYTE)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetTickCount"), (PBYTE)GetTickCount_hooked); break; } return true; } </code></pre> <p>Here is the rest of the code that is used for <code>GetTickCount</code></p> <pre><code>DWORD oldtick=0; DWORD (WINAPI *GetTickCount_orig)(void); DWORD WINAPI GetTickCount_hooked(void) { if(oldtick==0) { oldtick=(*GetTickCount_orig)(); return oldtick; } DWORD factor; DWORD ret; ret = (*GetTickCount_orig)(); factor = 3.0; DWORD newret; newret = ret+((oldtick-ret)*(factor-1)); oldtick=ret; return newret; } </code></pre> <p>Can you see something that is incorrect or that should be changed? Any help is appreciated. Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload