I'm trying to Hook the WritePrinter function present in winspool.drv using Easyhook RhInstallLibrary.
Injector.cpp
NTSTATUS nt = RhInjectLibrary(
processId, // The process to inject into
0, // ThreadId to wake up upon injection
EASYHOOK_INJECT_DEFAULT,
NULL, // 32-bit
dllToInject, // hook.dll
NULL, // data to send to injected DLL entry point
0// size of data to send
);
In hook.ddl, following function is created to hook printer function
BOOL MyWritePrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf, LPDWORD pcWritten)
{
//Some Code
return WritePrinter(hPrinter, pBuf, cbBuf, pcWritten);//
}
Data stream passed to printer is present in pBuf. But I'm not able to get that data. How can I read data from pBuf
WritePrinter Function Reference : https://msdn.microsoft.com/en-us/library/windows/desktop/dd145226(v=vs.85).aspx