I'm writing a hooking program through Microsoft's Detours. I've hooked the WINAPI call CreateFile and am calling my own function before redirecting the information to kernel32.CreateFile. Here's what mine looks like:
__declspec(dllexport) HANDLE WINAPI MyCreateFile(
LPCTSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
myfile << lpFileName;
return CreateFile(lpFileName,dwDesiredAccess,dwShareMode, lpSecurityAttributes,dwCreationDisposition,dwFlags AndAttributes,hTemplateFile);
}
it works, but the problem is that myfile (a pre-opened .txt) is filled with hex gibberish, like:
"0012F1D87FFDFC007FFDFC007FFDFC007FFDFC007FFDF C"
I'm assuming it's actually printing the address pointed to by lpFileName. I've tried dereferencing like so:
myfile << *lpFileName;
and the new output is numerical gibberish:
"6868686868686868686868686868686868686"
any ideas?