| 1952 | |
| 1953 | |
| 1954 | BOOL IsProcess64Bit(HANDLE aHandle) |
| 1955 | { |
| 1956 | BOOL is32on64; |
| 1957 | #ifdef _WIN64 |
| 1958 | // No need to load the function dynamically in this case since it should exist on all OSes |
| 1959 | // which are able to load 64-bit executables (such as ours): |
| 1960 | if (IsWow64Process(aHandle, &is32on64)) |
| 1961 | return !is32on64; // 64-bit if not running under WOW64. |
| 1962 | // Since above didn't return, an error occurred. MSDN isn't clear about what conditions can |
| 1963 | // cause this, so for simplicity just assume the target process is 64-bit (like this one). |
| 1964 | return TRUE; |
| 1965 | #else |
| 1966 | if (IsWow64Process(GetCurrentProcess(), &is32on64)) |
| 1967 | { |
| 1968 | if (is32on64) |
| 1969 | { |
| 1970 | // We're running under WOW64. Since WOW64 only exists on 64-bit systems and on such systems |
| 1971 | // 32-bit processes can run ONLY under WOW64, if the target process is also running under |
| 1972 | // WOW64 it must be 32-bit; otherwise it must be 64-bit. |
| 1973 | if (IsWow64Process(aHandle, &is32on64)) |
| 1974 | return !is32on64; |
| 1975 | } |
| 1976 | } |
| 1977 | // Since above didn't return, one of the following is true: |
| 1978 | // a) IsWow64Process failed on the first or second call. MSDN isn't clear about what conditions |
| 1979 | // can cause this, so for simplicity just assume the target process is 32-bit (like this one). |
| 1980 | // b) The current process is not running under WOW64. Since we know it is 32-bit (due to our use |
| 1981 | // of conditional compilation), the OS and all running processes must be 32-bit. |
| 1982 | return FALSE; |
| 1983 | #endif |
| 1984 | } |
| 1985 | |
| 1986 | BOOL IsOS64Bit() |
| 1987 | { |
no outgoing calls
no test coverage detected