この問題をデバッグして数時間修正しようとした後、このプロジェクトをあきらめる前にもう一度解決しようとしています。
次のコードを使用して、スコアを操作する目的でソリティアに DLL を挿入しようとしましたが、機能しません。最後の操作でアプリがクラッシュします。
void SetGameTime(int time)
{
MessageBox(NULL, "Func just begins here - ", "Func start", MB_OK | MB_ICONHAND);
DWORD baseAddress = (DWORD) GetModuleHandle(0);
baseAddress = *(DWORD *) (baseAddress + BASE_OFS_DEF);
DWORD temp = *(DWORD *)(baseAddress + SCORE_OFS1_DEF);
DWORD temp2 = *(DWORD *)(temp + SCORE_OFS2_DEF);
*(DWORD*) temp2 = 500; // solitaire crashes right here
}
それで、私は何を間違っていますか?関数全体が原因で「eax」が0になるデバッガーを使用しているときに、間違ったロジックを取得しようとしました。
デバッガーの出力:
SetGameTime(500);
703E1284 push 10h
703E1286 push 703E3170h
703E128B push 703E317Ch
703E1290 push 0
703E1292 call dword ptr ds:[703E30ACh] // GetModuleHandle operation (?)
703E1298 push 0
703E129A call dword ptr ds:[703E3000h] // base Address operation (?)
703E12A0 mov eax,dword ptr [eax+97074h] // eax keeps zero so the wrong function has to be GetModuleHandle?
703E12A6 mov eax,dword ptr [eax+2Ch] // first offset of score
703E12A9 mov eax,dword ptr [eax+10h] // and the second one...
703E12AC mov dword ptr [eax],1F4h // unhandled exception, no access to write at pos 0x00000000
return 0;