Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Inline Function Hooks - Clarification Needed

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
qpp
How do I cheat?
Reputation: 0

Joined: 05 Dec 2009
Posts: 2

PostPosted: Sat Dec 05, 2009 1:37 pm    Post subject: Inline Function Hooks - Clarification Needed Reply with quote

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
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sat Dec 05, 2009 2:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 474

Joined: 09 May 2003
Posts: 25953
Location: The netherlands

PostPosted: Sun Dec 06, 2009 12:45 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites