Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #define Naked __declspec(naked)
- #define stdcall __stdcall
- void SuperSleep(LONGLONG microseconds){
- LARGE_INTEGER Time1, Time2, Frequency, DeltaTime;
- DeltaTime.QuadPart = 0;
- QueryPerformanceFrequency(&Frequency);
- QueryPerformanceCounter(&Time1);
- while (DeltaTime.QuadPart < microseconds){
- QueryPerformanceCounter(&Time2);
- DeltaTime.QuadPart = Time2.QuadPart - Time1.QuadPart;
- DeltaTime.QuadPart *= 1000000;
- DeltaTime.QuadPart /= Frequency.QuadPart;
- }
- }
- void PlaceJmp(HANDLE hwnd,PVOID JumpFrom, DWORD JumpTo){
- DWORD old;
- DWORD bkup;
- DWORD JmpOffset = (DWORD)JumpTo - (DWORD)JumpFrom - 5;
- VirtualProtectEx(hwnd, JumpFrom, 5, PAGE_EXECUTE_READWRITE, &old);
- WriteProcessMemory(hwnd, JumpFrom, "\xE9", 1, NULL);
- WriteProcessMemory(hwnd, (PVOID)((DWORD)JumpFrom + 1),&JmpOffset,4,NULL);
- VirtualProtectEx(hwnd, JumpFrom, 5, old, &bkup);
- }
- PVOID GetHookedAddress(PVOID address){
- if (*(unsigned char*)address == 0xE9){
- return (PVOID)(*(DWORD*)((DWORD)address + 1) + (DWORD)address + 5);
- }
- else return (PVOID)0;
- }
- Naked void OpenGLHook(){
- SuperSleep(5555);
- __asm {
- ret
- }
- }
- PVOID HookSetup(PVOID HookAddr, PVOID CallThis); //Not Open Source
- void LockDLL(HMODULE DllHandle); //Not Open Source
- BOOL WINAPI DllMain(
- _In_ HINSTANCE hinstDLL,
- _In_ DWORD fdwReason,
- _In_ LPVOID lpvReserved
- ){
- if (fdwReason == DLL_PROCESS_ATTACH){
- PVOID ToHook = (PVOID)GetProcAddress(GetModuleHandleA("OPENGL32.dll"), "wglSwapBuffers");
- PVOID AllocatedHook = HookSetup(ToHook, (PVOID)OpenGLHook);
- PlaceJmp((HANDLE)-1, ToHook, (DWORD)AllocatedHook);
- LockDLL(hinstDLL);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement