Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/os_is64bit.c')
-rwxr-xr-xsrc/host/os_is64bit.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/host/os_is64bit.c b/src/host/os_is64bit.c
index 3134751..a296981 100755
--- a/src/host/os_is64bit.c
+++ b/src/host/os_is64bit.c
@@ -6,21 +6,35 @@
#include "premake.h"
+#if PLATFORM_WINDOWS
+typedef BOOL(WINAPI* WowFuncSig)(HANDLE, PBOOL);
+#endif
+
int os_is64bit(lua_State* L)
{
+#if PLATFORM_WINDOWS
+ HMODULE hKrnl32 = GetModuleHandle(TEXT("kernel32"));
+#endif
+ if (sizeof(void*) == 8) // our premake build is 64-bit, so the runtime environment must be also (at least) 64-bit ...
+ {
+ lua_pushboolean(L, 1);
+ return 1;
+ }
// If this code returns true, then the platform is 64-bit. If it
// returns false, the platform might still be 64-bit, but more
// checking will need to be done on the Lua side of things.
#if PLATFORM_WINDOWS
- typedef BOOL (WINAPI* WowFuncSig)(HANDLE, PBOOL);
- WowFuncSig func = (WowFuncSig)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
- if (func)
+ if (hKrnl32)
{
- BOOL isWow = FALSE;
- if (func(GetCurrentProcess(), &isWow))
+ WowFuncSig func = (WowFuncSig)GetProcAddress(hKrnl32, "IsWow64Process");
+ if (func)
{
- lua_pushboolean(L, isWow);
- return 1;
+ BOOL isWow = FALSE;
+ if (func(GetCurrentProcess(), &isWow))
+ {
+ lua_pushboolean(L, isWow);
+ return 1;
+ }
}
}
#endif