i have the following Problem: i have a old DetourFunction these are working fine.. Now a want to use the new DetourAttach but my Hook is not working anymore... Maybe anyone has an Idea what i'am doing wrong.
(我有以下问题:我有一个旧的DetourFunction,它们工作正常。.现在想使用新的DetourAttach,但我的挂钩不再工作了……也许有人知道我在做什么错。)
OLD ONE:
(老一:)
#include <windows.h>
#include <detours.h>
DWORD score_adr = 0x01013C89;
typedef DWORD *(__stdcall *score)(DWORD *a1, int a2);
score o_score;
DWORD *__stdcall h_score(DWORD *a1, int a2)
{
static int new_score;
new_score += 1;
a1[1] = 1;
return o_score(a1, new_score);
}
BOOL __stdcall DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpcReserved)
{
switch (fdwReason){
case DLL_PROCESS_ATTACH:
o_score = (score)DetourFunction((PBYTE)score_adr, (PBYTE)&h_score);
break;}
return TRUE;
}
NEW One:
(新的一个:)
#include <windows.h>
#include <detours.h>
DWORD score_adr = 0x01013C89;
typedef DWORD* (__stdcall* o_score)(DWORD* a1, int a2);
o_score score;
DWORD* __stdcall h_score(DWORD* a1, int a2)
{
static int new_score;
new_score += 1;
a1[1] = 1;
return score(a1, new_score);
}
BOOL __stdcall DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpcReserved)
{
switch (fdwReason){
case DLL_PROCESS_ATTACH:
score = (o_score)(score_adr);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread);
DetourAttach((PVOID*)(&score), (PVOID)h_score);
DetourTransactionCommit();
}
return TRUE;
}
ask by Joscha Kern translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…