| View previous topic :: View next topic |
| Author |
Message |
qpp How do I cheat?
Reputation: 0
Joined: 05 Dec 2009 Posts: 2
|
Posted: Sat Dec 05, 2009 1:37 pm Post subject: Inline Function Hooks - Clarification Needed |
|
|
Hello,
Could somebody clarify me the concept of inline function hooks. I am having hard time understanding how application specific function hooks work (for example the ones created by madCodeHook).
My understanding is that the code section is shared, so how can the ntdll!ZwOpenProcess be different for two applications that both load ntdll.dll (in my understanding a change to the code section of ntdll.dll loaded into memory should be reflected to all apps that load ntddll [IAT hooking is not used])? Or in other words, I have an application that uses ZwOpenProcess: once a hooking DLL is loaded into the program space, debugger shows an inline jmp when disassembling ntdll!ZwOpenprocess. Once the hooking DLL is unloaded (the detach includes the hook cleanup code) the ZwOpenProcess no longer contains the inline jmp. |
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sat Dec 05, 2009 2:35 pm Post subject: |
|
|
System DLLs do share the same space in physical memory, but due to the wonders of virtual addressing it can be treated as copy-on-write memory. i.e. you make a change in your address space, and the changed page is first copied, an then written over. The OS does this to save space, while still allowing changes to only affect the local address space. Another thing I should point out: Changing an application in memory does not change the application on disk.
Of course, this doesn't apply to applications that reside in kernel-land. There is no copy-on-write there, and a change there will affect every single process. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 474
Joined: 09 May 2003 Posts: 25953 Location: The netherlands
|
Posted: Sun Dec 06, 2009 12:45 pm Post subject: |
|
|
It does affect kernel-land application, but if you suppress the read-only attribute of the copy-on-write pages the copy-on-write routine never gets called.
By default the read only flag is respected in kernelmode though, unless someones driver is so stupid to reset the RW bit in CR0 and doesn't turn it back on _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
|