EDN Admin
Well-known member
I recently order to monitor third-party software program written in VB.NET to call their own,
write a hook dll.
But its not clear how to hook the hook reference to the information coming.
Here is my hook file link:
<a title="HOOK https://skydrive.live.com/?cid=105b2868cb2df559&id=105B2868CB2DF559%21190
My purpose is to monitor third-party programs WM_PSD_ENVSTAMPRECT the lParam value.
I made reference to this article:
<a title="DU http://msdn.microsoft.com/en-us/library/ms172890%28VS.90%29.aspx
This article describes information call DLL file, but I still do not understand.
I wrote the following statement:
Declare Function getlparmvalue Lib "hookps.dll" ( ) As Integer
But what things I should be in the () in the fill it?
Here I use C + + code written in this hook;
<div style="color:black; background-color:white
<pre>---------------------------------------------------------------------------
<span style="color:green // hookps.cpp : Custom DLLs exported function application.
<span style="color:green //
#include <windows.h>
#include <span style="color:#a31515 "stdafx.h"
<span style="color:green //------------------------------------
#define WINAPI_stdcall
#define WM_PSD_ENVSTAMPRECT (WM_USER+5)
#define WM_USER 0x0400
<span style="color:green //----------------------------------------
<span style="color:green // Shared variable
# pragma data_seg (<span style="color:#a31515 "SharedDataName")
HWND g_hWnd;
HHOOK hThisHook; <span style="color:green // save the hook handle
<span style="color:blue static UINT_PTR CALLBACK PaintHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
<span style="color:blue int GetWindowTextRemote(HWND hwnd,LPSTR lpString);
<span style="color:blue int ReleaseHook();
# pragma data_seg ()
# pragma comment (linker, <span style="color:#a31515 "/section:.SharedDataName,RWS")
<span style="color:green //--------------------------------------------------------------------------------
<span style="color:blue static UINT_PTR CALLBACK PaintHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) <span style="color:green // Message callback function
{
<span style="color:blue char <span style="color:blue value=0; <span style="color:green //lParam is 16bit
<span style="color:blue switch (uMsg)
{
<span style="color:blue case WM_PSD_ENVSTAMPRECT:
<span style="color:green // uRet = PreDrawPage(WORD(wParam), WORD(wParam), (LPPAGESETUPDLG)lParam);
<span style="color:green //value= lParam;
<span style="color:blue return DefWindowProc(hwnd, uMsg, wParam, lParam);
<span style="color:blue break;
<span style="color:blue return TRUE;
<span style="color:blue default:
<span style="color:blue return FALSE;
};
<span style="color:blue return TRUE;
};
<span style="color:green //----------------------------------
HINSTANCE hDll;
<span style="color:green // Set the mount hook
<span style="color:blue int GetWindowTextRemote(HWND hwnd,LPSTR lpString)
{
g_hWnd=hwnd;
hThisHook=SetWindowsHookEx(WH_CALLWNDPROC,(HOOKPROC) PaintHookProc,hDll,GetWindowThreadProcessId(hwnd,NULL) );
<span style="color:blue return 0;
};
<span style="color:green //
<span style="color:blue int ReleaseHook() <span style="color:green // <<<<<<Off the hook
{
<span style="color:blue if(hThisHook)
{
UnhookWindowsHookEx(hThisHook);
hThisHook = NULL;
}
<span style="color:blue return TRUE;
};
<span style="color:green //enum
<span style="color:green //{
<span style="color:green //HM_CALLWNDPROC = 0x0001,
<span style="color:green //};
-------------------------------------------------------------------------------------
My initial thought is <span style="color:blue this is not the part I declare shared variables to be included <span style="color:blue in the brackets go?
This section:
<span style="color:green //----------------------------------------
<span style="color:green // Shared variable
# pragma data_seg (<span style="color:#a31515 "SharedDataName")
HWND g_hWnd;
HHOOK hThisHook; <span style="color:green // save the hook handle
<span style="color:blue static UINT_PTR CALLBACK PaintHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
<span style="color:blue int GetWindowTextRemote(HWND hwnd,LPSTR lpString);
<span style="color:blue int ReleaseHook();
# pragma data_seg ()
# pragma comment (linker, <span style="color:#a31515 "/section:.SharedDataName,RWS")
<span style="color:green //--------------------------------------------------------------------------------
[/code]
<br/>
How to set this part of it?
Grateful!
<br/>
View the full article
write a hook dll.
But its not clear how to hook the hook reference to the information coming.
Here is my hook file link:
<a title="HOOK https://skydrive.live.com/?cid=105b2868cb2df559&id=105B2868CB2DF559%21190
My purpose is to monitor third-party programs WM_PSD_ENVSTAMPRECT the lParam value.
I made reference to this article:
<a title="DU http://msdn.microsoft.com/en-us/library/ms172890%28VS.90%29.aspx
This article describes information call DLL file, but I still do not understand.
I wrote the following statement:
Declare Function getlparmvalue Lib "hookps.dll" ( ) As Integer
But what things I should be in the () in the fill it?
Here I use C + + code written in this hook;
<div style="color:black; background-color:white
<pre>---------------------------------------------------------------------------
<span style="color:green // hookps.cpp : Custom DLLs exported function application.
<span style="color:green //
#include <windows.h>
#include <span style="color:#a31515 "stdafx.h"
<span style="color:green //------------------------------------
#define WINAPI_stdcall
#define WM_PSD_ENVSTAMPRECT (WM_USER+5)
#define WM_USER 0x0400
<span style="color:green //----------------------------------------
<span style="color:green // Shared variable
# pragma data_seg (<span style="color:#a31515 "SharedDataName")
HWND g_hWnd;
HHOOK hThisHook; <span style="color:green // save the hook handle
<span style="color:blue static UINT_PTR CALLBACK PaintHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
<span style="color:blue int GetWindowTextRemote(HWND hwnd,LPSTR lpString);
<span style="color:blue int ReleaseHook();
# pragma data_seg ()
# pragma comment (linker, <span style="color:#a31515 "/section:.SharedDataName,RWS")
<span style="color:green //--------------------------------------------------------------------------------
<span style="color:blue static UINT_PTR CALLBACK PaintHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) <span style="color:green // Message callback function
{
<span style="color:blue char <span style="color:blue value=0; <span style="color:green //lParam is 16bit
<span style="color:blue switch (uMsg)
{
<span style="color:blue case WM_PSD_ENVSTAMPRECT:
<span style="color:green // uRet = PreDrawPage(WORD(wParam), WORD(wParam), (LPPAGESETUPDLG)lParam);
<span style="color:green //value= lParam;
<span style="color:blue return DefWindowProc(hwnd, uMsg, wParam, lParam);
<span style="color:blue break;
<span style="color:blue return TRUE;
<span style="color:blue default:
<span style="color:blue return FALSE;
};
<span style="color:blue return TRUE;
};
<span style="color:green //----------------------------------
HINSTANCE hDll;
<span style="color:green // Set the mount hook
<span style="color:blue int GetWindowTextRemote(HWND hwnd,LPSTR lpString)
{
g_hWnd=hwnd;
hThisHook=SetWindowsHookEx(WH_CALLWNDPROC,(HOOKPROC) PaintHookProc,hDll,GetWindowThreadProcessId(hwnd,NULL) );
<span style="color:blue return 0;
};
<span style="color:green //
<span style="color:blue int ReleaseHook() <span style="color:green // <<<<<<Off the hook
{
<span style="color:blue if(hThisHook)
{
UnhookWindowsHookEx(hThisHook);
hThisHook = NULL;
}
<span style="color:blue return TRUE;
};
<span style="color:green //enum
<span style="color:green //{
<span style="color:green //HM_CALLWNDPROC = 0x0001,
<span style="color:green //};
-------------------------------------------------------------------------------------
My initial thought is <span style="color:blue this is not the part I declare shared variables to be included <span style="color:blue in the brackets go?
This section:
<span style="color:green //----------------------------------------
<span style="color:green // Shared variable
# pragma data_seg (<span style="color:#a31515 "SharedDataName")
HWND g_hWnd;
HHOOK hThisHook; <span style="color:green // save the hook handle
<span style="color:blue static UINT_PTR CALLBACK PaintHookProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
<span style="color:blue int GetWindowTextRemote(HWND hwnd,LPSTR lpString);
<span style="color:blue int ReleaseHook();
# pragma data_seg ()
# pragma comment (linker, <span style="color:#a31515 "/section:.SharedDataName,RWS")
<span style="color:green //--------------------------------------------------------------------------------
[/code]
<br/>
How to set this part of it?
Grateful!
<br/>
View the full article