EDN Admin
Well-known member
(newbie alert)
I would like to inject my own messages to be logged by the ProcMon utility. The function below was copy&pasted from the ProcMon help file but it wont compile. There is an undefined variable "i", for starters.
TIA!
-CR
--------------------------
#include "stdafx.h"
#include <WinIoCtl.h><br/>
<br/>
<br/>
<br/>
#define FILE_DEVICE_PROCMON_LOG 0x00009535<br/>
#define IOCTL_EXTERNAL_LOG_DEBUGOUT (ULONG) CTL_CODE( FILE_DEVICE_PROCMON_LOG, 0x81, METHOD_BUFFERED, FILE_WRITE_ACCESS )<br/>
<br/>
void<br/>
ProcessMonitorInject( int argc, char * argv[] )<br/>
{<br/>
<br/>
HANDLE hDevice = CreateFile( (LPCSTR) L"\\.\Global\ProcmonDebugLogger", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );<br/>
<br/>
if ( hDevice != INVALID_HANDLE_VALUE ) {<br/>
<br/>
WCHAR text[] = L"Debug out";<br/>
<br/>
DWORD textlen = (wcslen(text)+1) *sizeof(WCHAR);<br/>
DWORD nb = 0;<br/>
<br/>
BOOL ok = DeviceIoControl( hDevice, IOCTL_EXTERNAL_LOG_DEBUGOUT, text, textlen, NULL, 0, &nb, NULL );<br/>
<br/>
if ( ok ) {<br/>
printf( "wrote %dn", i );<br/>
} else {<br/>
printf( "error 0x%xn", GetLastError() );<br/>
}<br/>
<br/>
} else {<br/>
printf( "error %d opening Process Monitorn", GetLastError() );<br/>
}<br/>
}<br/>
<br/>
<br/>
View the full article
I would like to inject my own messages to be logged by the ProcMon utility. The function below was copy&pasted from the ProcMon help file but it wont compile. There is an undefined variable "i", for starters.
TIA!
-CR
--------------------------
#include "stdafx.h"
#include <WinIoCtl.h><br/>
<br/>
<br/>
<br/>
#define FILE_DEVICE_PROCMON_LOG 0x00009535<br/>
#define IOCTL_EXTERNAL_LOG_DEBUGOUT (ULONG) CTL_CODE( FILE_DEVICE_PROCMON_LOG, 0x81, METHOD_BUFFERED, FILE_WRITE_ACCESS )<br/>
<br/>
void<br/>
ProcessMonitorInject( int argc, char * argv[] )<br/>
{<br/>
<br/>
HANDLE hDevice = CreateFile( (LPCSTR) L"\\.\Global\ProcmonDebugLogger", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );<br/>
<br/>
if ( hDevice != INVALID_HANDLE_VALUE ) {<br/>
<br/>
WCHAR text[] = L"Debug out";<br/>
<br/>
DWORD textlen = (wcslen(text)+1) *sizeof(WCHAR);<br/>
DWORD nb = 0;<br/>
<br/>
BOOL ok = DeviceIoControl( hDevice, IOCTL_EXTERNAL_LOG_DEBUGOUT, text, textlen, NULL, 0, &nb, NULL );<br/>
<br/>
if ( ok ) {<br/>
printf( "wrote %dn", i );<br/>
} else {<br/>
printf( "error 0x%xn", GetLastError() );<br/>
}<br/>
<br/>
} else {<br/>
printf( "error %d opening Process Monitorn", GetLastError() );<br/>
}<br/>
}<br/>
<br/>
<br/>
View the full article