Skip to content

Commit a2eac45

Browse files
author
jiyongdong
committed
refact: Dynamically load the IsNativeVhdBoot function to ensure compatibility with older systems
1 parent 1ff1897 commit a2eac45

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/vmaware.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9664,7 +9664,23 @@ struct VM {
96649664
#else
96659665
BOOL isNativeVhdBoot = 0;
96669666

9667-
if (IsNativeVhdBoot(&isNativeVhdBoot)) {
9667+
const HMODULE hModule = GetModuleHandleA("Kernel32.dll");
9668+
if (!hModule)
9669+
return false;
9670+
9671+
const char* functionNames[] = { "IsNativeVhdBoot" };
9672+
void* functionPointers[1] = { nullptr };
9673+
9674+
util::GetFunctionAddresses(hModule, functionNames, functionPointers, 1);
9675+
9676+
typedef BOOL (WINAPI *IsNativeVhdBoot)(PBOOL NativeVhdBoot);
9677+
9678+
IsNativeVhdBoot pIsNativeVhdBoot = nullptr;
9679+
pIsNativeVhdBoot = reinterpret_cast<IsNativeVhdBoot>(functionPointers[0]);
9680+
if (!pIsNativeVhdBoot)
9681+
return false;
9682+
9683+
if ( pIsNativeVhdBoot(&isNativeVhdBoot)) {
96689684
return isNativeVhdBoot == 1;
96699685
}
96709686

0 commit comments

Comments
 (0)