Well, to make this a fuck of a lot easier you can do the exact same thing without all that fucking messy ass code. I wrote one up just now, this should do exactly as you needed.
Code:
// pbclLogger2.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <fstream>
#include "detours.h"
typedef int (__stdcall *pbHook)(int iEAX, size_t Count, char *Dest);
pbHook pbHook2;
using namespace std;
ofstream Fileio;
int _pbHook2(int iEAX, size_t count, char *Dest)
{
Beep(9000,20);
int ireturn = pbHook2(iEAX,count,Dest);
Fileio <<"\n\n\nIEAX :"<<iEAX<<"nnn count :"<<count<<"\n\n\n DEST :"<<Dest<<"-----------------------n";
return ireturn;
}
void Main()
{
Fileio <<"\n[Started Logging]\n";
DWORD pbclBase = (DWORD) GetModuleHandle("pbcl.dll");
if(!pbclBase)
Fileio << "\n [ERROR :: UNABLE TO HOOK FUNCTION,PBCDLBASE IS NULL] \n";
else
Fileio << "\n [SUCESS:: LOCATED PBCL, NOW HOOKING] \n";
pbHook2 = (pbHook)DetourFunction((BYTE*)(pbclBase + 0x55FC5), (BYTE*)_pbHook2);
while(true)
Sleep(10);
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(hModule);
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Main,NULL,0,NULL);
Fileio.open("C:\WRKLG.txt");
break;
}
case DLL_PROCESS_DETACH:
{
Fileio << "\n\n Detaching"<<endl;
Fileio.close();
break;
}
}
return TRUE;
}
The \'s don't show up I assume because of some forum bb code issue or whatever, so if you see an abnormal n located, its probably \n
I told you to change the data-type from HANDLE to HMODULE, if it didn't prevent it from crashing, it at least made it easier to read. You also have a million unrequired headers in there.
* Spam Removed, If You Have No Idea What The Hell Where Talking About, Please Don't Post It. *
BTW : If the DLL is injected before Pbcl.dll is loaded, then it can't locate pbcl.dll, thus it will throw an exception, and crash. So load this
after pbcl.dll is loaded.