Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LH incorrectly hooks DLLs that transition into ARM64 #8

Open
VXACDev opened this issue Jul 26, 2024 · 5 comments
Open

LH incorrectly hooks DLLs that transition into ARM64 #8

VXACDev opened this issue Jul 26, 2024 · 5 comments

Comments

@VXACDev
Copy link

VXACDev commented Jul 26, 2024

Use case: Running WinARM (from MAC using Parallels for example, or a native MSFT ARM based notebook)

Module = KERNELBASE.sys
Function = CreateFileW

pseudo code: HMODULE mod=(HMODULE)LoadLibraryA("kernelbase.sys")
void * origPtr = GetProcAddress("CreateFileW")

... use LH to "hook" and make a call to anything that gets to CreateFileW (fopen is fine, or use CreateFileW)

calling the ORIGINAL hook will crash/fault... along the lines of:

typedef HANDLE (*pfnCFW)( ...the..args...to...CFW);

HANDLE myCreateFileW( ..args ..)
{
pfnCFW orig = (pfwCFW)LH.trampoline;
return orig( .. args ..); <-- CRASH
}

@SamuelTulach
Copy link
Owner

a.) KernelBase.sys does not exist, KernelBase.dll does. That's a usermode module.
b.) I have no idea how x86 emulation for ARM (Prism?) works on Windows. My best bet is that it does some "AOT" recompilation by lifting parts of the executable to LLVM IR, running some optimization pass and then recompiling it (I am just guessing based on the fact that I have seen a video where unoptimized debug build was faster using x86 emulation when the unoptimized native ARM build). If that's the case, then you cannot use this library at all and most likely any other library for x86 as well. You should find something for ARM instead. For API hooking though, why not to hook IAT?

@VXACDev
Copy link
Author

VXACDev commented Jul 26, 2024 via email

@SamuelTulach
Copy link
Owner

If minhook works, then there could be some issue with figuring out the correct instruction length. If that's the case, please dump the function start bytes before and after hook is installed.

@VXACDev
Copy link
Author

VXACDev commented Jul 27, 2024 via email

@VXACDev
Copy link
Author

VXACDev commented Jul 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants