|
-
August 21st, 2006, 08:49 PM
#11
Re: Another Hook question
Couple of things to point:
1. Sample shows how to hook certain process (thread) and uses Notepad as an example.
2. If you want hook to be injected to all running processes set thread ID in SetWindowsHookEx to NULL and pass only DLL’s instance.
3. All variables that are used in a hook procedure must be global in shared, writable and readable memory. Moreover, they must be initialized. If not they are process bound.
4. You have to tell linker to use memory that was marked shared by either using def fiel and setting SECTIONS (def statement) and marking .WhateverSegmentName to SWR.
You can also use project settings and enter /SECTION specifying name of the segment and attribute.
The mos popular is using #pragma comment(linker, "/SECTION:. WhateverSegmentName)
Dot is optional and used by convention.
The reason for using shared memory id that each process is running in different address space and if variables are not shared, they will point into a lala land in other than DLL loading processes. By placing variables in shared chunk of memory, you assure that each process will map variables properly in own address space.
Since initializing custom data (arrays, structures and so on) is not simple, using custom data would not be possible, hence you must use simple types.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|