Developed monitoring application window, the message hook the DLL.

I am using VB.net to develop an application, but there needs to be applied to the dll technology.

So come here to seek help.

First I will describe the features I need this dll

I want to monitor an application's window to get in on a PSD_ENVSTAMPRECT the lParam value.

Here I use SPY + + to monitor the application's window to get that information.

<00031> 00020E46 S WM_PSD_ENVSTAMPRECT wParam: 00000001 lParam: 00000001 <<<1
<00032> 00020E46 R WM_PSD_ENVSTAMPRECT lResult: 00000000
<00033> 00020E46 S WM_PSD_PAGESETUPDLG wParam: 00000000 lParam: 00000000
<00034> 00020E46 R WM_PSD_PAGESETUPDLG lResult: 00000001
<00035> 00020E46 S WM_PSD_ENVSTAMPRECT wParam: 00000001 lParam: 00000002 <<<2
<00036> 00020E46 R WM_PSD_ENVSTAMPRECT lResult: 00000000
<00037> 00020E46 S WM_PSD_PAGESETUPDLG wParam: 00000000 lParam: 00000000
<00038> 00020E46 R WM_PSD_PAGESETUPDLG lResult: 00000002
<00039> 00020E46 S WM_PSD_ENVSTAMPRECT wParam: 00000001 lParam: 00000003 <<<3 of lParam value for WM_PSD_ENVSTAMPRECT
<00040> 00020E46 R WM_PSD_ENVSTAMPRECT lResult: 00000000
<00041> 00020E46 S WM_PSD_PAGESETUPDLG wParam: 00000000 lParam: 00000000


This window WM_PSD_ENVSTAMPRECT function of the value of lParam will update immediately.

I would like to create a globle hook by to monitor the application window WM_PSD_ENVSTAMPRECT in the lParam of the message.

I spent a lot of time to study a lot with the HOOK on the C + + code.

But this problem is too difficult for me.

Difficult to understand.

Please do not give me references.
I've searched a lot of reference material.
I know of are:
1 have to install a hook
2 Select the type of hook
3 defines the structure
4 shared memory should also consider
5 off hook

Install a hook type hook with SetWindowEx do not know what was right.
Define the structure do not know what to consider?

I want to direct this project for me to give me what to write code directly into the help

Thank you.

The following is my code:
-----------------------------------------------

// hookps.cpp : Custom DLL's exported function application.
//
#include <windows.h>
#include "stdafx.h"



 HWND g_hWnd;
 HHOOK hThisHook; //Save the hook handle.
 static LRESULT CALLBACK HookedShellProc(int nCode, WPARAM wParam, LPARAM lParam);
 //Define common data structures
typedef struct
{
 HHOOK hThisHook; //Currently in use HOOK
 //... Increase the sharing of other information here.
};

LRESULT HookProc (
  int code,       // hook code
  WPARAM wParam,  // virtual-key code
  LPARAM lParam   // keystroke-message information
);

HINSTANCE hDll;
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
)
{
hDll = (HINSTANCE) hModule;
    return TRUE;
};

int GetWindowTextRemote(HWND hwnd,LPSTR lpString)
{
    g_hWnd=hwnd;
    hThisHook=SetWindowsHookEx(WH_SHELL,(HOOKPROC)HookProc,hDll,GetWindowThreadProcessId(hwnd,NULL) );

};

#define RELEASEHOOK(hThisHook)                                                              //  <<<<Off the hook.
{                                  //<<<  I do not know why the smoke has IntelliSense: must be declared.
 if(hThisHook)
  {
   UnhookWindowsHookEx(hThisHook);
   hThisHook = NULL;
  }
};

enum
{
HM_SHELL = 0x0100,
};


--------------------------

# define RELEASEHOOK (hThisHook) / / <<<<<< off the hook
{//<<<
Here do not know why the above has been cropped IntelliSense: The error message must be declared.

This is one of the problems.

Then I now need to add anything in the code or what is wrong or which side of the extra code.

Or where the code is useless at this type of hook in the wrong.

Please give these questions for me to help me.
Last edited on
Topic archived. No new replies allowed.