With my current code (see below) the hook(detour) works the first time(just like before) and then the process seems to continue but if I try to close the process it stops responding.
I ran the program with IDA pro injected the dll and then went through the steps to make that hook run when it did IDA said it caused an unknown exception.
Current code(basically the same thing but for a different address point):
Code:
#include <windows.h>
#include "detours.h"
#include <iostream>
#include <fstream>
using namespace std;
int (__stdcall* DemoBugFixPoint)(void);
int __stdcall DemoBugFixPoint(void)
{
ofstream myfile;
myfile.open ("legends.log");
myfile << "SetRights(demo bug fix) applied to new logon.\n";
myfile.close();
return DemoBugFixPointHook();
}
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
DemoBugFixPointHook = (int (__stdcall*)(void))DetourFunction((PBYTE)0x004B8ABF, (PBYTE)DemoBugFixPoint);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
DetourRemove((PBYTE)0x004B8ABF, (PBYTE)DemoBugFixPointHook); //Remove hook
break;
}
return TRUE;
}
btw the assembly of "0x004B8ABF" is just NOP im not sure if that is an issue if it is can someone explain an easier way to run my function when the program reaches that address point?