Flag: Tornado! Hurricane!

Blogs >> AlexIonescu's Blog

Created: Sunday, August 13 2006 18:54.51 CDT  
Printer Friendly ...
Q&A
Author: AlexIonescu # Views: 2656

Q:
<<
In your blog entry titled "Debugging/Reversing NT System Binaries" you mention:

"Version1 14 of MSC (in the WDK or MSVC 2005) has many intrinsics that are portable when recompiled, including stuff like getting the return address, reading eflags, setting/reading/writng fs/gs/dr*/cr*, etc."

How can you get the return address and what are the other intrinsics that you talk about? Where are they documented?
>>

A: _AddressOfReturnAddress() is the intrinsic to get the return address. __getcallerseflags() is the one to get EFLAGS. http://msdn2.microsoft.com/en-us/library/w5405h95.aspx has the documentation and listing of the other ones. Have fun, and please use them! Help support the removal of unportable/ugly ASM code!

Q: Regarding your latest blog entry. I agree with you, however there is in my opinion one legitimate use of hooking and that is for registry operations because historically there hasn't been any legal and documented way of monitoring registry access.

A: No, there really isn't. Developers that hook are developers that can't RTFM (the DDK/WDK docs). I'm not accusing you of this, since it's possible to have skipped over the right documentation, especially as it's only really been of high quality since about last year. In either case, CmRegisterCallback and CmUnregisterCallback are documented, exported routines which allow you to hook the following:

RegNtDeleteKey
RegNtPreDeleteKey
RegNtPostDeleteKey
RegNtSetValueKey
RegNtPreSetValueKey
RegNtPostSetValueKey
RegNtDeleteValueKey
RegNtPreDeleteValueKey
RegNtPostDeleteValueKey
RegNtSetInformationKey
RegNtPreSetInformationKey
RegNtPostSetInformationKey
RegNtRenameKey
RegNtPreRenameKey
RegNtPostRenameKey
RegNtEnumerateKey
RegNtPreEnumerateKey
RegNtPostEnumerateKey
RegNtEnumerateValueKey
RegNtPreEnumerateValueKey
RegNtPostEnumerateValueKey
RegNtQueryKey
RegNtPreQueryKey
RegNtPostQueryKey
RegNtQueryValueKey
RegNtPreQueryValueKey
RegNtPostQueryValueKey
RegNtQueryMultipleValueKey
RegNtPreQueryMultipleValueKey
RegNtPostQueryMultipleValueKey
RegNtPreCreateKey
RegNtPreCreateKeyEx
RegNtPostCreateKey
RegNtPostCreateKeyEx
RegNtPreOpenKey
RegNtPreOpenKeyEx
RegNtPostOpenKey
RegNtPostOpenKeyEx
RegNtKeyHandleClose
RegNtPreKeyHandleClose
RegNtPostKeyHandleClose

Not only do you get PRE/ACTUAL/POST notifications for every single API out there, you also get them for actual HANDLE commands, which cannot be hooked through the system call table (you'd have to hook the CmpKeyObject type callbacks).




Add New Comment
Comment:









There are 31,314 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
hi!
Jul/01
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit