int GetOSVersion(void)
{
    ZeroMemory(&osInfo, sizeof(osInfo));
    osInfo.dwOSVersionInfoSize = sizeof(osInfo);
    GetVersionEx(&osInfo);

	//64-bit OS test, when running as 32-bit under WoW
	BOOL bIs64BitOS= FALSE;
	typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
	LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process");
	if (NULL != fnIsWow64Process)
		fnIsWow64Process(GetCurrentProcess(), &bIs64BitOS);
	/*usingx64 = bIs64BitOS;
	//64-bit OS test, if compiled as native 64-bit. In case we ever need it.
	if (!usingx64)
		usingx64=(sizeof(int)!=sizeof(void*));*/

    using_NT         = osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT;

    if (using_NT)
		return ((osInfo.dwMajorVersion * 10) + osInfo.dwMinorVersion + (bIs64BitOS ? 5 : 0)); // NT 40; Win2kXP 50; Vista 60; etc.


	if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
    {
        if (osInfo.dwMinorVersion >= 90)
            return 30; // Windows ME
        if (osInfo.dwMinorVersion >= 10)
            return 20; // Windows 98
    }
	return 10; // Windows 95
}
Exemple #2
0
void setWow64Flag() {
	LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
			GetModuleHandle(TEXT("kernel32")), "IsWow64Process");

	if (fnIsWow64Process != NULL) {
		fnIsWow64Process(GetCurrentProcess(), &wow64);
	}
	debug("WOW64:\t\t%s\n", wow64 ? "yes" : "no");
}
Exemple #3
0
void setWow64Flag()
{
	LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
			GetModuleHandle(TEXT("kernel32")), "IsWow64Process");

	if (fnIsWow64Process != NULL) {
		fnIsWow64Process(GetCurrentProcess(), &wow64);
	}
}
Exemple #4
0
VOID GetSystemCPU(WCHAR *szBuffer)
{
    SYSTEM_INFO archInfo;
    ISWOW64PROC fnIsWow64Process;
    BOOL isWow64 = FALSE;

    /* Find out if the program is running through WOW64 or not. Apparently,
    IsWow64Process() is not available on all versions of Windows, so the function
    has to be imported at runtime. If the function cannot be found, then assume
    the program is not running in WOW64. */
    fnIsWow64Process = (ISWOW64PROC)GetProcAddress(
        GetModuleHandleW(L"kernel32"), "IsWow64Process");
    
    if (fnIsWow64Process != NULL)
        fnIsWow64Process(GetCurrentProcess(), &isWow64);

    /* If the program is compiled as 32-bit, but is running in WOW64, it will
    automatically report as 32-bit regardless of the actual system architecture.
    It detects whether or not the program is using WOW64 or not, and then
    uses GetNativeSystemInfo(). If it is, it will properly report the actual
    system architecture to the user. */
    if (isWow64)
        GetNativeSystemInfo(&archInfo);
    else
        GetSystemInfo(&archInfo);

    /* Now check to see what the system architecture is */
    if(archInfo.wProcessorArchitecture != PROCESSOR_ARCHITECTURE_UNKNOWN)
    {
        switch(archInfo.wProcessorArchitecture)
        {
        case PROCESSOR_ARCHITECTURE_INTEL:
        {
            wsprintfW(szBuffer, L"32-bit");
            break;
        }
        case PROCESSOR_ARCHITECTURE_AMD64:
        {
            wsprintfW(szBuffer, L"64-bit");
            break;
        }
        case PROCESSOR_ARCHITECTURE_IA64:
        {
            wsprintfW(szBuffer, L"Itanium");
            break;
        }
        case PROCESSOR_ARCHITECTURE_ARM:
        {
            wsprintfW(szBuffer, L"ARM");
            break;
        }
        default:break;
        }
    }
}
Exemple #5
0
char* uname_m(void) {
#if defined(_WIN64)
  return q("x86-64");
#endif
#ifdef __CYGWIN__
  return q("x86");
#endif
#ifndef HAVE_WINDOWS_H
  char *p=system_("uname -m");
  char *p2;
  p2=remove_char("\r\n",p);
  s(p);
  if(strcmp(p2,"i686")==0) {
    s(p2);
    return q("x86");
  }
  if(strcmp(p2,"amd64")==0) {
    s(p2);
    return q("x86-64");
  }
  if(strcmp(p2,"armv6l")==0 ||
     strcmp(p2,"armv7l")==0) {
    char* result=system_("readelf -A /proc/self/exe |grep Tag_ABI_VFP_args|wc -l");
    char* result2=remove_char("\r\n",result);
    s(result);
    if(strcmp(result2,"0")!=0) {
      s(result2);
      return q("armel");
    }else {
      s(result2);
      return q("armhf");
    }
  }
  return substitute_char('-','_',p2);
#else
#if _WIN64
  return q("x86-64");
#elif _WIN32
  BOOL isWow64 = FALSE;
  LPFN_ISWOW64PROCESS fnIsWow64Process  = (LPFN_ISWOW64PROCESS)
    GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
  if(fnIsWow64Process) {
    if (!fnIsWow64Process(GetCurrentProcess(), &isWow64))
      return q("x86");
    if(isWow64)
      return q("x86-64");
    else
      return q("x86");
  }
  else
    return q("x86");
#endif
#endif
}
Exemple #6
0
static void Set_Wow64()
{
  g_Is_Wow64 = false;
  Func_IsWow64Process fnIsWow64Process = (Func_IsWow64Process)GetProcAddress(
      GetModuleHandleA("kernel32.dll"), "IsWow64Process");
  if (fnIsWow64Process)
  {
    BOOL isWow;
    if (fnIsWow64Process(GetCurrentProcess(), &isWow))
      g_Is_Wow64 = (isWow != FALSE);
  }
}
Exemple #7
0
 BOOL IsWow64System()
 {
     typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
     LPFN_ISWOW64PROCESS fnIsWow64Process;
     BOOL bIsWow64 = FALSE;
     fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(_T("kernel32")), "IsWow64Process");
     if (NULL != fnIsWow64Process)
     {
         fnIsWow64Process(GetCurrentProcess(), &bIsWow64);
     }
     return bIsWow64;
 }
Exemple #8
0
	BOOL DuiSystem::IsWow64()
	{
		HMODULE hModule = GetModuleHandle(_T("kernel32"));
		if (!hModule) return FALSE;
		typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
		LPFN_ISWOW64PROCESS fnIsWow64Process;
		BOOL bIsWow64 = FALSE;
		fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(hModule, "IsWow64Process");
		if (NULL != fnIsWow64Process)
		{
			fnIsWow64Process(GetCurrentProcess(), &bIsWow64);
		}
		return bIsWow64;
	}
Exemple #9
0
// Detect whether the operating system is a 64-bit.
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms684139%28v=vs.85%29.aspx
BOOL IsWow64() {
  BOOL bIsWow64 = FALSE;

  fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
      GetModuleHandle(TEXT("kernel32")),
      "IsWow64Process");

  if (NULL != fnIsWow64Process) {
    if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
      // handle error
    }
  }
  return bIsWow64;
}
Exemple #10
0
JNIEXPORT jboolean JNICALL Java_org_netbeans_installer_utils_system_windows_WindowsRegistry_IsWow64Process0(JNIEnv *jEnv, jobject jObject) {
    typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
    LPFN_ISWOW64PROCESS fnIsWow64Process;
    BOOL IsWow64 = FALSE;

    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");
  
    if (NULL != fnIsWow64Process)
    {
        if (!fnIsWow64Process(GetCurrentProcess(),&IsWow64))
        {
        }
    }
    return IsWow64;
}
Exemple #11
0
static BOOL IsWow64()
{
    BOOL bIsWow64 = FALSE;
    LPFN_ISWOW64PROCESS fnIsWow64Process = ( LPFN_ISWOW64PROCESS ) GetProcAddress(
            GetModuleHandle( TEXT( "kernel32" ) ), "IsWow64Process" );
    if ( NULL != fnIsWow64Process )
    {
        if ( !fnIsWow64Process( GetCurrentProcess(), &bIsWow64 ) )
        {
            // handle error
            //AfxMessageBox(_T("IsWow64 error!"));
        }
    }
    return bIsWow64;
}
Exemple #12
0
bool SelfTest::IsWow64()
{
	int bIsWow64 = false;
	LPFN_ISWOW64PROCESS fnIsWow64Process;
	fnIsWow64Process = reinterpret_cast<LPFN_ISWOW64PROCESS>(GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process"));
	if (NULL != fnIsWow64Process)
	{
		if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
		{
			return false;
		}
	}

	return bIsWow64 != 0;
}
Exemple #13
0
inline BOOL IsWow64()
{
    BOOL bIsWow64 = FALSE;

    LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
            GetModuleHandle("kernel32"),"IsWow64Process");

    if (fnIsWow64Process != NULL)
    {
        if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
        {
            // handle error?
        }
    }
    return bIsWow64!=FALSE;
}
Exemple #14
0
gboolean
wing_is_wow_64 (void)
{
  typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
  LPFN_ISWOW64PROCESS fnIsWow64Process;
  BOOL is_wow_64 = FALSE;

  fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress (GetModuleHandle (TEXT ("kernel32")), "IsWow64Process");
  if (fnIsWow64Process != NULL)
    {
      if (!fnIsWow64Process (GetCurrentProcess (), &is_wow_64))
        return FALSE;
    }

  return is_wow_64;
}
Exemple #15
0
/*-----------------------------------------------------------------------------------*/
BOOL IsWow64(void)
{
    BOOL bIsWow64 = FALSE;
    LPFN_ISWOW64PROCESS fnIsWow64Process;

    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");

    if (NULL != fnIsWow64Process)
    {
        if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
        {

        }
    }
    return bIsWow64;
}
Exemple #16
0
BOOL IsWOW64() {
  typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
  BOOL wow64;
  LPFN_ISWOW64PROCESS fnIsWow64Process;

  fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
    GetModuleHandle("kernel32"), "IsWow64Process");

  if (fnIsWow64Process != NULL) {
    if (fnIsWow64Process(GetCurrentProcess(), &wow64)) {
      return wow64;
    }
  }

  return FALSE;
}
static int IsWow64(void)
{
    int bIsWow64 = 0;
    typedef BOOL (APIENTRY *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
    LPFN_ISWOW64PROCESS fnIsWow64Process;
    HMODULE module = GetModuleHandle(TEXT("kernel32"));
    const char funcName[] = "IsWow64Process";

    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(module, funcName);

    if (NULL != fnIsWow64Process) {
        fnIsWow64Process(GetCurrentProcess(), &bIsWow64);
    }

    return bIsWow64;
}
Exemple #18
0
bool IsWow64()
{
	BOOL bIsWow64 = FALSE;
	
	typedef BOOL (APIENTRY *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
	
	LPFN_ISWOW64PROCESS fnIsWow64Process;
	
	HMODULE module = GetModuleHandle("kernel32");
	const char funcName[] = "IsWow64Process";
	fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(module, funcName);
	
	if(fnIsWow64Process && !fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
		return false;

	return bIsWow64;
}
static BOOL IsWow64(void)
{
    BOOL bIsWow64 = FALSE;
    typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
    LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");
    if (fnIsWow64Process != NULL)
    {
        if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
        {
            fwprintf(stderr, L"ERROR: Could not determine process type!\n");

            /* Error in retrieving process type - assume that we're running on 32bit. */
            bIsWow64 = FALSE;
        }
    }
    return bIsWow64;
}
Exemple #20
0
BOOL Check64::IsWow64()
{
    BOOL bIsWow64 = FALSE;

    //IsWow64Process is not available on all supported versions of Windows.
    //Use GetModuleHandle to get a handle to the DLL that contains the function
    //and GetProcAddress to get a pointer to the function if available.

    fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
        GetModuleHandle(TEXT("kernel32")),"IsWow64Process");

    if(NULL != fnIsWow64Process) {
        if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) {
            // handle error
        }
    }
    return bIsWow64;
}
Exemple #21
0
bool System::is64() {
    BOOL res = FALSE;
    LPFN_ISWOW64PROCESS fnIsWow64Process;

    //IsWow64Process is not available on all supported versions of Windows.
    //Use GetModuleHandle to get a handle to the DLL that contains the function
    //and GetProcAddress to get a pointer to the function if available.

    fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");
    if(fnIsWow64Process) {
        if (!fnIsWow64Process(GetCurrentProcess(), &res)) {
            log_error(L"Failed to determine machine architecture: %u", GetLastError());
            return false;
        }
    }

    return (res == TRUE);
}
BOOL Is64BitOs ()
{
    static BOOL isWow64 = FALSE;
	static BOOL valid = FALSE;
	typedef BOOL (__stdcall *LPFN_ISWOW64PROCESS ) (HANDLE hProcess,PBOOL Wow64Process);
	LPFN_ISWOW64PROCESS fnIsWow64Process;

	if (valid)
		return isWow64;

	fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process");

    if (fnIsWow64Process != NULL)
        if (!fnIsWow64Process (GetCurrentProcess(), &isWow64))
			isWow64 = FALSE;

	valid = TRUE;
    return isWow64;
}
BOOL IsWow64()
{
    BOOL bIsWow64 = FALSE;
#if VERSIONWIN
    typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
    LPFN_ISWOW64PROCESS fnIsWow64Process;
    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
        GetModuleHandle(TEXT("kernel32")), "IsWow64Process");

    if (NULL != fnIsWow64Process)
    {
        if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
        {
            bIsWow64 = TRUE;
        }
    }
#endif
    return bIsWow64;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Returns TRUE if the specified PID belongs to a WOW64 process.
//
BOOL	IsProcessWow64(ULONG Pid)
{
	BOOL Ret =  FALSE;
	LPFN_ISWOW64PROCESS fnIsWow64Process = NULL;

	fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandleA(szKernel32),"IsWow64Process");
	if (fnIsWow64Process)
	{
		HANDLE	hProcess;
		if (hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, Pid))
		{
			if (!fnIsWow64Process(hProcess, &Ret))
				// An error occured: unable to get OS architecture type. Assume we are on x86 and process is not WOW64 process.
				Ret = FALSE;
			CloseHandle(hProcess);
		}
	}	// if (fnIsWow64Process)
	return(Ret);
}
Exemple #25
0
BOOL CKLL::Is64BitWindows()
{
#if defined(_WIN64)
	return TRUE;  // 64-bit programs run only on Win64
#elif defined(_WIN32)
	// 32-bit programs run on both 32-bit and 64-bit Windows
	// so must sniff
	BOOL f64 = FALSE;
	LPFN_ISWOW64PROCESS fnIsWow64Process;

	fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandleA("kernel32"),"IsWow64Process");
	if(NULL != fnIsWow64Process)
	{
		return fnIsWow64Process(GetCurrentProcess(),&f64) && f64;
	}
	return FALSE;
#else
	return FALSE; // Win64 does not support Win16
#endif
}
Exemple #26
0
BOOL IsWow64()
{
	BOOL bIsWow64 = FALSE;

	typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
	LPFN_ISWOW64PROCESS fnIsWow64Process;

	fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
		GetModuleHandle(TEXT("kernel32")),"IsWow64Process");

	if (NULL != fnIsWow64Process)
	{
		if (! fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
		{
			errorLogE(_T("IsWow64Process failed."));
		}
	}

	return bIsWow64;
}
Exemple #27
0
BOOL IsWow64()
{
    static int isWoW64 = -1;
    if (-1 == isWoW64)
    {
        BOOL bIsWow64 = FALSE;
        //IsWow64Process is not available on all supported versions of Windows.
        //Use GetModuleHandle to get a handle to the DLL that contains the function
        //and GetProcAddress to get a pointer to the function if available.
        LPFN_ISWOW64PROCESS fnIsWow64Process;
        fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
            GetModuleHandle(TEXT("kernel32")), "IsWow64Process");

        if(NULL != fnIsWow64Process)
            fnIsWow64Process(GetCurrentProcess(), &bIsWow64);

        isWoW64 = bIsWow64;
    }
    return isWoW64 == 1 ? TRUE : FALSE;
}
QString DiagnosticsDialog::getBits() const
{
	QString bits = "32";
	typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
	//check if kernel32 supports this function
	QLibrary lib( "kernel32" );
	BOOL bIsWow64 = false;
	if( LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)lib.resolve( "IsWow64Process" ) )
	{
		if( fnIsWow64Process( GetCurrentProcess(), &bIsWow64 ) && bIsWow64 )
			bits = "64";
	}
	else
	{
		SYSTEM_INFO sysInfo;
		GetSystemInfo( &sysInfo );
		if ( sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 )
			bits = "64";
	}
	return bits;
}
Exemple #29
0
bool
CArchSystemWindows::isWOW64() const
{
#if WINVER >= _WIN32_WINNT_WINXP
	typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
	HMODULE hModule = GetModuleHandle(TEXT("kernel32"));
	if (!hModule) return FALSE;

	LPFN_ISWOW64PROCESS fnIsWow64Process =
		(LPFN_ISWOW64PROCESS) GetProcAddress(hModule, "IsWow64Process");

	BOOL bIsWow64 = FALSE;
	if(NULL != fnIsWow64Process &&
		fnIsWow64Process(GetCurrentProcess(), &bIsWow64) &&
		bIsWow64)
	{
		return true;
	}
#endif
	return false;
}
Exemple #30
0
bool is_wow64()
{
    LPFN_ISWOW64PROCESS fnIsWow64Process;
    BOOL bIsWow64 = false;

    //IsWow64Process is not available on all supported versions of Windows.
    //Use GetModuleHandle to get a handle to the DLL that contains the function
    //and GetProcAddress to get a pointer to the function if available.

    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandleA("kernel32"), "IsWow64Process");
    if (fnIsWow64Process == NULL) {
        return false;
    }
    if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
        return false;
    }
    if (bIsWow64 == TRUE) {
        return  true; //64 bit
    }
    return false; //32 bit
}