Skip to content

Commit 685a1ef

Browse files
authored
Update windows-bindgen dependency (#1347)
1 parent 251bd49 commit 685a1ef

File tree

4 files changed

+80
-80
lines changed

4 files changed

+80
-80
lines changed

dev-tools/gen-windows-sys-binding/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ edition = "2018"
55
publish = false
66

77
[dependencies]
8-
windows-bindgen = "0.58"
8+
windows-bindgen = "0.59"
99
tempfile = "3"
1010
regex = "1"

dev-tools/gen-windows-sys-binding/src/main.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,23 @@ const PRELUDE: &str = r#"// This file is autogenerated.
2020

2121
fn main() {
2222
let manifest_dir = env!("CARGO_MANIFEST_DIR");
23+
let filter = format!("{manifest_dir}/windows_sys.list");
2324
let temp_file = tempfile::Builder::new()
2425
.suffix(".rs")
2526
.tempfile()
2627
.expect("failed to create temp file");
2728

28-
// Common args to windows_bindgen.
29-
let mut args = vec![
30-
"--config",
31-
"flatten",
32-
"sys",
33-
"minimal",
29+
// Generate bindings.
30+
windows_bindgen::bindgen([
31+
"--flat",
32+
"--sys",
33+
"--no-core",
3434
"--out",
3535
temp_file.path().to_str().unwrap(),
3636
"--filter",
37-
];
38-
39-
// Append the list of APIs
40-
let buffer = fs::read_to_string(format!("{manifest_dir}/windows_sys.list"))
41-
.expect("failed to read list");
42-
args.extend(buffer.lines().filter_map(|line| {
43-
let line = line.trim();
44-
if line.is_empty() || line.starts_with("//") {
45-
None
46-
} else {
47-
Some(line)
48-
}
49-
}));
50-
51-
// Generate bindings.
52-
windows_bindgen::bindgen(&args).expect("running bindgen failed");
37+
"--etc",
38+
&filter,
39+
]);
5340

5441
let bindings =
5542
fs::read_to_string(temp_file.path()).expect("failed to read temp windows_sys.rs");
Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
Windows.Win32.Foundation.FILETIME
2-
Windows.Win32.Foundation.ERROR_NO_MORE_ITEMS
3-
Windows.Win32.Foundation.ERROR_SUCCESS
4-
Windows.Win32.Foundation.SysFreeString
5-
Windows.Win32.Foundation.SysStringLen
6-
Windows.Win32.Foundation.S_FALSE
7-
Windows.Win32.Foundation.S_OK
8-
Windows.Win32.Foundation.FALSE
9-
Windows.Win32.Foundation.HANDLE
10-
Windows.Win32.Foundation.WAIT_OBJECT_0
11-
Windows.Win32.Foundation.WAIT_TIMEOUT
12-
Windows.Win32.Foundation.WAIT_FAILED
13-
Windows.Win32.Foundation.WAIT_ABANDONED
14-
Windows.Win32.Foundation.FreeLibrary
15-
16-
Windows.Win32.System.Com.SAFEARRAY
17-
Windows.Win32.System.Com.SAFEARRAYBOUND
18-
Windows.Win32.System.Com.CLSCTX_ALL
19-
Windows.Win32.System.Com.COINIT_MULTITHREADED
20-
Windows.Win32.System.Com.CoCreateInstance
21-
Windows.Win32.System.Com.CoInitializeEx
22-
23-
Windows.Win32.System.LibraryLoader.GetProcAddress
24-
Windows.Win32.System.LibraryLoader.LoadLibraryA
25-
26-
Windows.Win32.System.Pipes.PeekNamedPipe
27-
28-
Windows.Win32.System.Registry.RegCloseKey
29-
Windows.Win32.System.Registry.RegEnumKeyExW
30-
Windows.Win32.System.Registry.RegOpenKeyExW
31-
Windows.Win32.System.Registry.RegQueryValueExW
32-
Windows.Win32.System.Registry.HKEY
33-
Windows.Win32.System.Registry.HKEY_LOCAL_MACHINE
34-
Windows.Win32.System.Registry.KEY_READ
35-
Windows.Win32.System.Registry.KEY_WOW64_32KEY
36-
Windows.Win32.System.Registry.REG_SZ
37-
38-
Windows.Win32.System.SystemInformation.IMAGE_FILE_MACHINE_AMD64
39-
40-
Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_TEMPORARY
41-
42-
Windows.Win32.System.Threading.GetMachineTypeAttributes
43-
Windows.Win32.System.Threading.ReleaseSemaphore
44-
Windows.Win32.System.Threading.WaitForSingleObject
45-
Windows.Win32.System.Threading.SEMAPHORE_MODIFY_STATE
46-
Windows.Win32.System.Threading.THREAD_SYNCHRONIZE
47-
Windows.Win32.System.Threading.UserEnabled
48-
49-
Windows.Win32.System.WindowsProgramming.OpenSemaphoreA
1+
FILETIME
2+
ERROR_NO_MORE_ITEMS
3+
ERROR_SUCCESS
4+
SysFreeString
5+
SysStringLen
6+
S_FALSE
7+
S_OK
8+
FALSE
9+
HANDLE
10+
WAIT_OBJECT_0
11+
WAIT_TIMEOUT
12+
WAIT_FAILED
13+
WAIT_ABANDONED
14+
FreeLibrary
15+
16+
SAFEARRAY
17+
SAFEARRAYBOUND
18+
CLSCTX_ALL
19+
COINIT_MULTITHREADED
20+
CoCreateInstance
21+
CoInitializeEx
22+
23+
GetProcAddress
24+
LoadLibraryA
25+
26+
PeekNamedPipe
27+
28+
RegCloseKey
29+
RegEnumKeyExW
30+
RegOpenKeyExW
31+
RegQueryValueExW
32+
HKEY
33+
HKEY_LOCAL_MACHINE
34+
KEY_READ
35+
KEY_WOW64_32KEY
36+
REG_SZ
37+
38+
IMAGE_FILE_MACHINE_AMD64
39+
40+
FILE_ATTRIBUTE_TEMPORARY
41+
42+
GetMachineTypeAttributes
43+
ReleaseSemaphore
44+
WaitForSingleObject
45+
SEMAPHORE_MODIFY_STATE
46+
THREAD_SYNCHRONIZE
47+
UserEnabled
48+
49+
OpenSemaphoreA

src/windows/windows_sys.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// cd generate-windows-sys/
77
// cargo run
88
// ```
9-
// Bindings generated by `windows-bindgen` 0.58.0
9+
// Bindings generated by `windows-bindgen` 0.59.0
1010

1111
#![allow(
1212
non_snake_case,
@@ -15,22 +15,23 @@
1515
dead_code,
1616
clippy::all
1717
)]
18-
windows_targets::link!("advapi32.dll" "system" fn RegCloseKey(hkey : HKEY) -> WIN32_ERROR);
19-
windows_targets::link!("advapi32.dll" "system" fn RegEnumKeyExW(hkey : HKEY, dwindex : u32, lpname : PWSTR, lpcchname : *mut u32, lpreserved : *const u32, lpclass : PWSTR, lpcchclass : *mut u32, lpftlastwritetime : *mut FILETIME) -> WIN32_ERROR);
20-
windows_targets::link!("advapi32.dll" "system" fn RegOpenKeyExW(hkey : HKEY, lpsubkey : PCWSTR, uloptions : u32, samdesired : REG_SAM_FLAGS, phkresult : *mut HKEY) -> WIN32_ERROR);
21-
windows_targets::link!("advapi32.dll" "system" fn RegQueryValueExW(hkey : HKEY, lpvaluename : PCWSTR, lpreserved : *const u32, lptype : *mut REG_VALUE_TYPE, lpdata : *mut u8, lpcbdata : *mut u32) -> WIN32_ERROR);
18+
19+
windows_targets::link!("ole32.dll" "system" fn CoCreateInstance(rclsid : *const GUID, punkouter : * mut core::ffi::c_void, dwclscontext : CLSCTX, riid : *const GUID, ppv : *mut *mut core::ffi::c_void) -> HRESULT);
20+
windows_targets::link!("ole32.dll" "system" fn CoInitializeEx(pvreserved : *const core::ffi::c_void, dwcoinit : u32) -> HRESULT);
2221
windows_targets::link!("kernel32.dll" "system" fn FreeLibrary(hlibmodule : HMODULE) -> BOOL);
2322
windows_targets::link!("kernel32.dll" "system" fn GetMachineTypeAttributes(machine : u16, machinetypeattributes : *mut MACHINE_ATTRIBUTES) -> HRESULT);
2423
windows_targets::link!("kernel32.dll" "system" fn GetProcAddress(hmodule : HMODULE, lpprocname : PCSTR) -> FARPROC);
2524
windows_targets::link!("kernel32.dll" "system" fn LoadLibraryA(lplibfilename : PCSTR) -> HMODULE);
2625
windows_targets::link!("kernel32.dll" "system" fn OpenSemaphoreA(dwdesiredaccess : u32, binherithandle : BOOL, lpname : PCSTR) -> HANDLE);
2726
windows_targets::link!("kernel32.dll" "system" fn PeekNamedPipe(hnamedpipe : HANDLE, lpbuffer : *mut core::ffi::c_void, nbuffersize : u32, lpbytesread : *mut u32, lptotalbytesavail : *mut u32, lpbytesleftthismessage : *mut u32) -> BOOL);
27+
windows_targets::link!("advapi32.dll" "system" fn RegCloseKey(hkey : HKEY) -> WIN32_ERROR);
28+
windows_targets::link!("advapi32.dll" "system" fn RegEnumKeyExW(hkey : HKEY, dwindex : u32, lpname : PWSTR, lpcchname : *mut u32, lpreserved : *const u32, lpclass : PWSTR, lpcchclass : *mut u32, lpftlastwritetime : *mut FILETIME) -> WIN32_ERROR);
29+
windows_targets::link!("advapi32.dll" "system" fn RegOpenKeyExW(hkey : HKEY, lpsubkey : PCWSTR, uloptions : u32, samdesired : REG_SAM_FLAGS, phkresult : *mut HKEY) -> WIN32_ERROR);
30+
windows_targets::link!("advapi32.dll" "system" fn RegQueryValueExW(hkey : HKEY, lpvaluename : PCWSTR, lpreserved : *const u32, lptype : *mut REG_VALUE_TYPE, lpdata : *mut u8, lpcbdata : *mut u32) -> WIN32_ERROR);
2831
windows_targets::link!("kernel32.dll" "system" fn ReleaseSemaphore(hsemaphore : HANDLE, lreleasecount : i32, lppreviouscount : *mut i32) -> BOOL);
29-
windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT);
30-
windows_targets::link!("ole32.dll" "system" fn CoCreateInstance(rclsid : *const GUID, punkouter : * mut core::ffi::c_void, dwclscontext : CLSCTX, riid : *const GUID, ppv : *mut *mut core::ffi::c_void) -> HRESULT);
31-
windows_targets::link!("ole32.dll" "system" fn CoInitializeEx(pvreserved : *const core::ffi::c_void, dwcoinit : u32) -> HRESULT);
3232
windows_targets::link!("oleaut32.dll" "system" fn SysFreeString(bstrstring : BSTR));
3333
windows_targets::link!("oleaut32.dll" "system" fn SysStringLen(pbstr : BSTR) -> u32);
34+
windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT);
3435
pub type ADVANCED_FEATURE_FLAGS = u16;
3536
pub type BOOL = i32;
3637
pub type BSTR = *const u16;
@@ -69,12 +70,24 @@ impl GUID {
6970
}
7071
}
7172
pub type HANDLE = *mut core::ffi::c_void;
73+
pub type HINSTANCE = *mut core::ffi::c_void;
7274
pub type HKEY = *mut core::ffi::c_void;
7375
pub const HKEY_LOCAL_MACHINE: HKEY = -2147483646i32 as _;
7476
pub type HMODULE = *mut core::ffi::c_void;
7577
pub type HRESULT = i32;
7678
pub type IMAGE_FILE_MACHINE = u16;
7779
pub const IMAGE_FILE_MACHINE_AMD64: IMAGE_FILE_MACHINE = 34404u16;
80+
pub const IID_IUnknown: GUID = GUID::from_u128(0x00000000_0000_0000_c000_000000000046);
81+
#[repr(C)]
82+
pub struct IUnknown_Vtbl {
83+
pub QueryInterface: unsafe extern "system" fn(
84+
this: *mut core::ffi::c_void,
85+
iid: *const GUID,
86+
interface: *mut *mut core::ffi::c_void,
87+
) -> HRESULT,
88+
pub AddRef: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32,
89+
pub Release: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32,
90+
}
7891
pub const KEY_READ: REG_SAM_FLAGS = 131097u32;
7992
pub const KEY_WOW64_32KEY: REG_SAM_FLAGS = 512u32;
8093
pub type MACHINE_ATTRIBUTES = i32;

0 commit comments

Comments
 (0)