Skip to content

Commit 0b22a2c

Browse files
fix: use #else instead of #endif for x86 guards in msr(), kvm_interception(), and breakpoint()
The previous pattern (#if (!x86) return false; #endif) inserts an early return but the compiler still compiles the code below. MSVC on ARM64 fails because x86-specific intrinsics (__readmsr, __stosb, __movsb) and x86 debug registers (Dr0, Dr7) don't exist on that platform. Changed all three functions to use #if (!x86) return false; #else ... #endif so the x86-specific code is completely excluded from compilation on non-x86 targets.
1 parent 97f75ae commit 0b22a2c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/vmaware.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11797,7 +11797,7 @@ struct VM {
1179711797
[[nodiscard]] static bool msr() {
1179811798
#if (!x86)
1179911799
return false;
11800-
#endif
11800+
#else
1180111801
constexpr u32 random_msr = 0xDEADBEEFu;
1180211802

1180311803
auto try_read = [](u32 msr_index) -> bool {
@@ -11849,6 +11849,7 @@ struct VM {
1184911849
}
1185011850

1185111851
return false;
11852+
#endif
1185211853
}
1185311854

1185411855

@@ -11861,7 +11862,7 @@ struct VM {
1186111862
[[nodiscard]] static bool kvm_interception() {
1186211863
#if (!x86)
1186311864
return false;
11864-
#endif
11865+
#else
1186511866
using nt_allocate_virtual_memory_t = NTSTATUS(__stdcall*)(HANDLE, PVOID*, ULONG_PTR, PSIZE_T, ULONG, ULONG);
1186611867
using nt_protect_virtual_memory_t = NTSTATUS(__stdcall*)(HANDLE, PVOID*, PSIZE_T, ULONG, PULONG);
1186711868
using nt_free_virtual_memory_t = NTSTATUS(__stdcall*)(HANDLE, PVOID*, PSIZE_T, ULONG);
@@ -11947,6 +11948,7 @@ struct VM {
1194711948
}
1194811949

1194911950
return false;
11951+
#endif
1195011952
}
1195111953

1195211954

@@ -11958,7 +11960,7 @@ struct VM {
1195811960
[[nodiscard]] static bool breakpoint() {
1195911961
#if (!x86)
1196011962
return false;
11961-
#endif
11963+
#else
1196211964
const HMODULE ntdll = util::get_ntdll();
1196311965
if (!ntdll) return false;
1196411966

@@ -12072,6 +12074,7 @@ struct VM {
1207212074
nt_free_virtual_memory(current_process, &dst_page, &free_size, MEM_RELEASE);
1207312075

1207412076
return !ermsb_trap_detected;
12077+
#endif
1207512078
}
1207612079
// ADD NEW TECHNIQUE FUNCTION HERE
1207712080
#endif

0 commit comments

Comments
 (0)