-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from 21pages/master
- Loading branch information
Showing
4 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use cc::Build; | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-changed=src"); | ||
#[cfg(target_os = "windows")] | ||
{ | ||
println!("cargo:rustc-link-lib=Kernel32"); | ||
Build::new().file("src/win.cpp").compile("machine-uid"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <windows.h> | ||
#include <tchar.h> | ||
|
||
// https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process | ||
|
||
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); | ||
|
||
static LPFN_ISWOW64PROCESS fnIsWow64Process; | ||
|
||
extern "C" BOOL MachineUidIsWow64() | ||
{ | ||
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; | ||
} |