mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-10-05 07:39:27 +00:00
Merge commit 'dabc40cb19
' as 'ext/detours'
This commit is contained in:
commit
77523940b3
178 changed files with 102613 additions and 0 deletions
74
ext/detours/samples/opengl/ogldet.cpp
Normal file
74
ext/detours/samples/opengl/ogldet.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Module: ogldet.dll
|
||||
//
|
||||
// This DLL is based on the sample simple.dll. A detour is inserted for
|
||||
// the OpenGL glFinish function.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include "detours.h"
|
||||
|
||||
static void (WINAPI * trueGlFinish)(void) = glFinish;
|
||||
|
||||
void WINAPI hookedGlFinish(void)
|
||||
{
|
||||
printf("ogldet" DETOURS_STRINGIFY(DETOURS_BITS) ".dll:"
|
||||
" hookedGlFinish Starting.\n");
|
||||
fflush(stdout);
|
||||
|
||||
trueGlFinish();
|
||||
|
||||
printf("ogldet" DETOURS_STRINGIFY(DETOURS_BITS) ".dll:"
|
||||
" hookedGlFinish done.\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
|
||||
{
|
||||
LONG error;
|
||||
(void)hinst;
|
||||
(void)reserved;
|
||||
|
||||
if (DetourIsHelperProcess()) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH) {
|
||||
DetourRestoreAfterWith();
|
||||
|
||||
printf("ogldet" DETOURS_STRINGIFY(DETOURS_BITS) ".dll:"
|
||||
" Starting.\n");
|
||||
fflush(stdout);
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(&(PVOID&)trueGlFinish, hookedGlFinish);
|
||||
error = DetourTransactionCommit();
|
||||
|
||||
if (error == NO_ERROR) {
|
||||
printf("ogldet" DETOURS_STRINGIFY(DETOURS_BITS) ".dll:"
|
||||
" Detoured glFinish().\n");
|
||||
}
|
||||
else {
|
||||
printf("ogldet" DETOURS_STRINGIFY(DETOURS_BITS) ".dll:"
|
||||
" Error detouring glFinish(): %d\n", error);
|
||||
}
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH) {
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach(&(PVOID&)trueGlFinish, hookedGlFinish);
|
||||
error = DetourTransactionCommit();
|
||||
|
||||
printf("ogldet" DETOURS_STRINGIFY(DETOURS_BITS) ".dll:"
|
||||
" Removed detour glFinish() (result=%d)\n", error);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
///////////////////////////////////////////////////////////////// End of File.
|
Loading…
Add table
Add a link
Reference in a new issue