Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Win32 and WDK metadata #2573

Merged
merged 15 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions crates/libs/core/src/imp/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
::windows_targets::link!("kernel32.dll" "system" fn FreeLibrary(hlibmodule : HMODULE) -> BOOL);
::windows_targets::link!("kernel32.dll" "system" fn GetLastError() -> WIN32_ERROR);
::windows_targets::link!("kernel32.dll" "system" fn GetProcAddress(hmodule : HMODULE, lpprocname : PCSTR) -> FARPROC);
::windows_targets::link!("kernel32.dll" "system" fn GetProcessHeap() -> HeapHandle);
::windows_targets::link!("kernel32.dll" "system" fn HeapAlloc(hheap : HeapHandle, dwflags : HEAP_FLAGS, dwbytes : usize) -> *mut ::core::ffi::c_void);
::windows_targets::link!("kernel32.dll" "system" fn HeapFree(hheap : HeapHandle, dwflags : HEAP_FLAGS, lpmem : *const ::core::ffi::c_void) -> BOOL);
::windows_targets::link!("kernel32.dll" "system" fn GetProcessHeap() -> HANDLE);
::windows_targets::link!("kernel32.dll" "system" fn HeapAlloc(hheap : HANDLE, dwflags : HEAP_FLAGS, dwbytes : usize) -> *mut ::core::ffi::c_void);
::windows_targets::link!("kernel32.dll" "system" fn HeapFree(hheap : HANDLE, dwflags : HEAP_FLAGS, lpmem : *const ::core::ffi::c_void) -> BOOL);
::windows_targets::link!("kernel32.dll" "system" fn LoadLibraryExA(lplibfilename : PCSTR, hfile : HANDLE, dwflags : LOAD_LIBRARY_FLAGS) -> HMODULE);
::windows_targets::link!("kernel32.dll" "system" fn SetEvent(hevent : HANDLE) -> BOOL);
::windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WIN32_ERROR);
::windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT);
::windows_targets::link!("ole32.dll" "system" fn CoTaskMemAlloc(cb : usize) -> *mut ::core::ffi::c_void);
::windows_targets::link!("ole32.dll" "system" fn CoTaskMemFree(pv : *const ::core::ffi::c_void) -> ());
::windows_targets::link!("oleaut32.dll" "system" fn SysAllocStringLen(strin : PCWSTR, ui : u32) -> BSTR);
Expand All @@ -30,7 +30,6 @@ pub type FORMAT_MESSAGE_OPTIONS = u32;
pub type HANDLE = isize;
pub type HEAP_FLAGS = u32;
pub type HMODULE = isize;
pub type HeapHandle = isize;
pub type LOAD_LIBRARY_FLAGS = u32;
pub const LOAD_LIBRARY_SEARCH_DEFAULT_DIRS: LOAD_LIBRARY_FLAGS = 4096u32;
pub type PCSTR = *const u8;
Expand All @@ -48,4 +47,5 @@ impl ::core::clone::Clone for SECURITY_ATTRIBUTES {
*self
}
}
pub type WAIT_EVENT = u32;
pub type WIN32_ERROR = u32;
Binary file modified crates/libs/metadata/default/Windows.Wdk.winmd
Binary file not shown.
Binary file modified crates/libs/metadata/default/Windows.Win32.winmd
Binary file not shown.
4 changes: 2 additions & 2 deletions crates/libs/metadata/default/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ like [ILSpy](https://github.com/icsharpcode/ILSpy).

## Windows.Win32.winmd
- Source: https://www.nuget.org/packages/Microsoft.Windows.SDK.Win32Metadata/
- Version: 49.0.21
- Version: 53.0.14

## Windows.Wdk.winmd
- Source: https://www.nuget.org/packages/Microsoft.Windows.WDK.Win32Metadata/
- Version: 0.4.2
- Version: 0.7.3

## Windows.winmd
- Source: https://www.nuget.org/packages/Microsoft.Windows.SDK.Contracts
Expand Down
56 changes: 28 additions & 28 deletions crates/libs/metadata/src/imp/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// Bindings generated by `riddle` 0.0.1

#![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)]
pub type CorElementType = i32;
pub const ELEMENT_TYPE_ARRAY: CorElementType = 20i32;
pub const ELEMENT_TYPE_BOOLEAN: CorElementType = 2i32;
pub const ELEMENT_TYPE_BYREF: CorElementType = 16i32;
pub const ELEMENT_TYPE_CHAR: CorElementType = 3i32;
pub const ELEMENT_TYPE_CLASS: CorElementType = 18i32;
pub const ELEMENT_TYPE_CMOD_OPT: CorElementType = 32i32;
pub const ELEMENT_TYPE_CMOD_REQD: CorElementType = 31i32;
pub const ELEMENT_TYPE_GENERICINST: CorElementType = 21i32;
pub const ELEMENT_TYPE_I: CorElementType = 24i32;
pub const ELEMENT_TYPE_I1: CorElementType = 4i32;
pub const ELEMENT_TYPE_I2: CorElementType = 6i32;
pub const ELEMENT_TYPE_I4: CorElementType = 8i32;
pub const ELEMENT_TYPE_I8: CorElementType = 10i32;
pub const ELEMENT_TYPE_OBJECT: CorElementType = 28i32;
pub const ELEMENT_TYPE_PTR: CorElementType = 15i32;
pub const ELEMENT_TYPE_R4: CorElementType = 12i32;
pub const ELEMENT_TYPE_R8: CorElementType = 13i32;
pub const ELEMENT_TYPE_STRING: CorElementType = 14i32;
pub const ELEMENT_TYPE_SZARRAY: CorElementType = 29i32;
pub const ELEMENT_TYPE_U: CorElementType = 25i32;
pub const ELEMENT_TYPE_U1: CorElementType = 5i32;
pub const ELEMENT_TYPE_U2: CorElementType = 7i32;
pub const ELEMENT_TYPE_U4: CorElementType = 9i32;
pub const ELEMENT_TYPE_U8: CorElementType = 11i32;
pub const ELEMENT_TYPE_VALUETYPE: CorElementType = 17i32;
pub const ELEMENT_TYPE_VAR: CorElementType = 19i32;
pub const ELEMENT_TYPE_VOID: CorElementType = 1i32;
pub type CorElementType = u8;
pub const ELEMENT_TYPE_ARRAY: CorElementType = 20u8;
pub const ELEMENT_TYPE_BOOLEAN: CorElementType = 2u8;
pub const ELEMENT_TYPE_BYREF: CorElementType = 16u8;
pub const ELEMENT_TYPE_CHAR: CorElementType = 3u8;
pub const ELEMENT_TYPE_CLASS: CorElementType = 18u8;
pub const ELEMENT_TYPE_CMOD_OPT: CorElementType = 32u8;
pub const ELEMENT_TYPE_CMOD_REQD: CorElementType = 31u8;
pub const ELEMENT_TYPE_GENERICINST: CorElementType = 21u8;
pub const ELEMENT_TYPE_I: CorElementType = 24u8;
pub const ELEMENT_TYPE_I1: CorElementType = 4u8;
pub const ELEMENT_TYPE_I2: CorElementType = 6u8;
pub const ELEMENT_TYPE_I4: CorElementType = 8u8;
pub const ELEMENT_TYPE_I8: CorElementType = 10u8;
pub const ELEMENT_TYPE_OBJECT: CorElementType = 28u8;
pub const ELEMENT_TYPE_PTR: CorElementType = 15u8;
pub const ELEMENT_TYPE_R4: CorElementType = 12u8;
pub const ELEMENT_TYPE_R8: CorElementType = 13u8;
pub const ELEMENT_TYPE_STRING: CorElementType = 14u8;
pub const ELEMENT_TYPE_SZARRAY: CorElementType = 29u8;
pub const ELEMENT_TYPE_U: CorElementType = 25u8;
pub const ELEMENT_TYPE_U1: CorElementType = 5u8;
pub const ELEMENT_TYPE_U2: CorElementType = 7u8;
pub const ELEMENT_TYPE_U4: CorElementType = 9u8;
pub const ELEMENT_TYPE_U8: CorElementType = 11u8;
pub const ELEMENT_TYPE_VALUETYPE: CorElementType = 17u8;
pub const ELEMENT_TYPE_VAR: CorElementType = 19u8;
pub const ELEMENT_TYPE_VOID: CorElementType = 1u8;
#[repr(C)]
pub struct IMAGE_COR20_HEADER {
pub cb: u32,
Expand Down
36 changes: 29 additions & 7 deletions crates/libs/metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ impl<'a> Reader<'a> {
false
}
}
pub fn method_def_signature(&self, row: MethodDef, generics: &[Type]) -> Signature {
pub fn method_def_signature(&self, namespace: &str, row: MethodDef, generics: &[Type]) -> Signature {
let mut blob = self.row_blob(row.0, 4);
let call_flags = MethodCallAttributes(blob.read_usize() as _);
let _param_count = blob.read_usize();
Expand All @@ -624,6 +624,12 @@ impl<'a> Reader<'a> {
} else {
let is_output = self.param_flags(param).contains(ParamAttributes::Out);
let mut ty = self.type_from_blob(&mut blob, None, generics);

if let Some(name) = self.param_or_enum(param) {
let alt = self.get(TypeName::new(namespace, &name)).next().expect("Enum not found");
ty = Type::PrimitiveOrEnum(Box::new(ty), Box::new(Type::TypeDef(alt, Vec::new())));
}

if self.param_is_const(param) || !is_output {
ty = ty.to_const_type();
}
Expand Down Expand Up @@ -723,8 +729,8 @@ impl<'a> Reader<'a> {
unimplemented!()
}
}
pub fn method_def_size(&self, method: MethodDef) -> usize {
let signature = self.method_def_signature(method, &[]);
pub fn method_def_size(&self, namespace: &str, method: MethodDef) -> usize {
let signature = self.method_def_signature(namespace, method, &[]);
signature.params.iter().fold(0, |sum, param| sum + std::cmp::max(4, self.type_size(&param.ty)))
}
pub fn type_def_size(&self, def: TypeDef) -> usize {
Expand Down Expand Up @@ -755,6 +761,7 @@ impl<'a> Reader<'a> {
Type::GUID => 16,
Type::TypeDef(def, _) => self.type_def_size(*def),
Type::Win32Array(ty, len) => self.type_size(ty) * len,
Type::PrimitiveOrEnum(ty, _) => self.type_size(ty),
_ => 4,
}
}
Expand Down Expand Up @@ -846,6 +853,18 @@ impl<'a> Reader<'a> {
}
None
}
pub fn param_or_enum(&self, row: Param) -> Option<String> {
for attribute in self.param_attributes(row) {
if self.attribute_name(attribute) == "AssociatedEnumAttribute" {
for (_, arg) in self.attribute_args(attribute) {
if let Value::String(name) = arg {
return Some(name);
}
}
}
}
None
}
pub fn param_is_const(&self, row: Param) -> bool {
self.param_attributes(row).any(|attribute| self.attribute_name(attribute) == "ConstAttribute")
}
Expand Down Expand Up @@ -1243,7 +1262,7 @@ impl<'a> Reader<'a> {
reader.type_def_cfg_combine(def, generics, cfg);

for method in reader.type_def_methods(def) {
reader.signature_cfg_combine(&reader.method_def_signature(method, generics), cfg);
reader.signature_cfg_combine(&reader.method_def_signature(reader.type_def_namespace(def), method, generics), cfg);
}
}

Expand Down Expand Up @@ -1299,7 +1318,7 @@ impl<'a> Reader<'a> {
}
}
}
TypeKind::Delegate => self.signature_cfg_combine(&self.method_def_signature(self.type_def_invoke_method(row), generics), cfg),
TypeKind::Delegate => self.signature_cfg_combine(&self.method_def_signature(type_name.namespace, self.type_def_invoke_method(row), generics), cfg),
_ => {}
}
}
Expand Down Expand Up @@ -1494,7 +1513,10 @@ impl<'a> Reader<'a> {
return;
}

let Type::TypeDef(def, generics) = &ty else { return; };
let Type::TypeDef(def, generics) = &ty else {
return;
};

let def = *def;

// Ensure that we collect all the typedefs of the same name. We need to
Expand Down Expand Up @@ -1530,7 +1552,7 @@ impl<'a> Reader<'a> {
if self.method_def_name(method) == ".ctor" {
continue;
}
let signature = self.method_def_signature(method, generics);
let signature = self.method_def_signature(self.type_def_namespace(def), method, generics);
self.type_collect_standalone(&signature.return_type, set);
signature.params.iter().for_each(|param| self.type_collect_standalone(&param.ty, set));
}
Expand Down
1 change: 1 addition & 0 deletions crates/libs/metadata/src/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub enum Type {
WinrtArray(Box<Self>),
WinrtArrayRef(Box<Self>),
ConstRef(Box<Self>),
PrimitiveOrEnum(Box<Self>, Box<Self>),
}

impl Type {
Expand Down
6 changes: 6 additions & 0 deletions crates/libs/sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ Wdk_Graphics = ["Wdk"]
Wdk_Graphics_Direct3D = ["Wdk_Graphics"]
Wdk_Storage = ["Wdk"]
Wdk_Storage_FileSystem = ["Wdk_Storage"]
Wdk_Storage_FileSystem_Minifilters = ["Wdk_Storage_FileSystem"]
Wdk_System = ["Wdk"]
Wdk_System_IO = ["Wdk_System"]
Wdk_System_OfflineRegistry = ["Wdk_System"]
Wdk_System_Registry = ["Wdk_System"]
Wdk_System_SystemInformation = ["Wdk_System"]
Wdk_System_SystemServices = ["Wdk_System"]
Wdk_System_Threading = ["Wdk_System"]
Win32 = []
Win32_Data = ["Win32"]
Win32_Data_HtmlHelp = ["Win32_Data"]
Expand Down Expand Up @@ -222,6 +227,7 @@ Win32_System_Threading = ["Win32_System"]
Win32_System_Time = ["Win32_System"]
Win32_System_TpmBaseServices = ["Win32_System"]
Win32_System_UserAccessLogging = ["Win32_System"]
Win32_System_Variant = ["Win32_System"]
Win32_System_VirtualDosMachines = ["Win32_System"]
Win32_System_WindowsProgramming = ["Win32_System"]
Win32_System_Wmi = ["Win32_System"]
Expand Down
Loading