Download Source Code

CHookStdio Class Reference

Hooks the specified standard stream. More...

#include <HookStdio.h>

List of all members.

Public Member Functions

DWORD Write (LPVOID pBuf, DWORD dwSize)
 Writes data to the stream.
DWORD Read (LPVOID pBuf, DWORD dwSize)
 Reads data from the stream.
void Stop ()
 Unhooks any stream.
BOOL Start (DWORD dwStreamId, DWORD dwBufferSize=64 *1024)
 Hooks the specified stream.
 CHookStdio (DWORD dwStreamId=0, DWORD dwBufferSize=0)
 Constructor.
virtual ~CHookStdio ()
 Destructor.
HANDLE GetReadHandle ()
 Returns the read handle.
HANDLE GetWriteHandle ()
 Returns the read handle.


Detailed Description

Hooks the specified standard stream.

Use this to hook the standard i/o streams

Example:

    CHookStdio hs( STD_OUTPUT_HANDLE );

    printf( "Hello World!" );

    char buf[ 256 ];
    buf[ hs.Read( buf, sizeof( buf ) - 1 ) ] = 0;

    TRACE( buf );


Constructor & Destructor Documentation

CHookStdio::CHookStdio DWORD  dwStreamId = 0,
DWORD  dwBufferSize = 0
 

Constructor.

Parameters:
[in] dwStreamId - Standard stream ID
  • STD_INPUT_HANDLE = Standard input handle
  • STD_OUTPUT_HANDLE = Standard output handle
  • STD_ERROR_HANDLE = Standard error handle
[in] dwBufferSize - The size buffer to use.
The default argument of zero, will not hook any stream

See also:
Start(), Stop


Member Function Documentation

DWORD CHookStdio::Read LPVOID  pBuf,
DWORD  dwSize
 

Reads data from the stream.

Parameters:
[in] pBuf - Buffer that receives the data
[in] dwSize - Size of buffer in pBuf
Returns:
Number of bytes actually read
See also:

BOOL CHookStdio::Start DWORD  dwStreamId,
DWORD  dwBufferSize = 64 *1024
 

Hooks the specified stream.

Parameters:
[in] dwStreamId - Standard stream ID
  • STD_INPUT_HANDLE = Standard input handle
  • STD_OUTPUT_HANDLE = Standard output handle
  • STD_ERROR_HANDLE = Standard error handle
[in] dwBufferSize - The size buffer to use.
Returns:
Non-zero if success
See also:
CHookStdio(), Stop()

DWORD CHookStdio::Write LPVOID  pBuf,
DWORD  dwSize
 

Writes data to the stream.

Parameters:
[in] pBuf - Buffer containing data to write
[in] dwSize - Number of bytes to write
Returns:
Number of bytes actuall written or zero if error.
See also:


The documentation for this class was generated from the following files:
  • inc/HookStdio.h
  • HookStdio.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL