|
Q&A
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). Comments
| ||||||