I just updated distorm to the latest version, and I thought it might be a good idea to try it out on a few different OSes first to see if I didn't break hooking anywhere. Well, the good news is, I don't think I did.
The bad news is that the x86 version of Windows 10 doesn't seem to like ScyllaHide (no matter the distorm version): if I enable any hook at all I am presented with
followed by
...followed by the first error again times the number of hooks enabled.
We already have some hacks for Windows 10 in place in RemoteHook.cpp
, but those are for Wow64, where the syscalls go through a shared gate like this:
mov eax, 0Dh ; syscall number
mov edx, offset Wow64SystemServiceCall ; shared stub to do native syscall
call edx
retn 10h
On native x86 however, the syscall functions each have their own leaf function directly after the exported function (sometimes with nop/int 3 padding, usually not.) E.g.:
mov eax, 0Dh
call leaf_stub ; E8 03 00 00 00 (eip+8)
retn 10h
; optional padding
@leaf_stub:
mov edx, esp
sysenter
retn
This is clearly confusing DetourCreateRemoteNative32
which is looking for the old-style mov edx, KiFastSystemCall
+ call [edx]
way of doing things. But what's really strange is that while the Wow64 syscalls have indeed changed with Windows 10, the native x86 ones have worked like this since Windows 8. Does really no one use x86 OSes anymore, or am I the only one having this issue?
Fixing the issue was not really a problem, I just worked around it by making HOOK_NATIVE
work the same way on native x86 as on x64:
void * DetourCreateRemoteNative32(void * hProcess, void * lpFuncOrig, void * lpFuncDetour, bool createTramp, unsigned long * backupSize)
{
if (scl::GetWindowsVersion() >= scl::OS_WIN_10 && !scl::IsWow64Process(hProcess))
return DetourCreateRemote(hProcess, lpFuncOrig, lpFuncDetour, createTramp, backupSize);
// otherwise continue as normal
}
But I'd kind of llike to know why I shouldn't just do this for any OS >= Win 8, as the exported syscall functions are literally byte for byte the same between them. Though I haven't tried SH on Windows 8 x86 yet. And can anyone reproduce this? I know there must be like, at least 3 people out there who use an x86 OS.