From bcea80d1016e5eb636ff7e12911459918d9ffa70 Mon Sep 17 00:00:00 2001 From: Adam Rehn Date: Thu, 11 Jan 2024 16:42:29 +1000 Subject: [PATCH 1/3] Include nested types when identifying namespace dependencies --- sources/MetadataUtils/NamespaceDependencyUtil.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sources/MetadataUtils/NamespaceDependencyUtil.cs b/sources/MetadataUtils/NamespaceDependencyUtil.cs index f9b26442f..686b72e5d 100644 --- a/sources/MetadataUtils/NamespaceDependencyUtil.cs +++ b/sources/MetadataUtils/NamespaceDependencyUtil.cs @@ -45,8 +45,11 @@ public IEnumerable GetNamespaceDependencies(string winm { DecompilerTypeSystem winmd1 = DecompilerTypeSystemUtils.CreateTypeSystemFromFile(winmdFileName); - foreach (var type1 in winmd1.GetTopLevelTypeDefinitions()) + var types = new Queue(winmd1.GetTopLevelTypeDefinitions()); + while (types.Any()) { + var type1 = types.Dequeue(); + if (type1.FullName == "") { continue; @@ -71,6 +74,14 @@ public IEnumerable GetNamespaceDependencies(string winm string broughtInBy = $"{type1.Name}.{field.Name}"; this.AddTypeDependency(type1, depends, broughtInBy, field.Type); } + + foreach (var nested in type1.GetNestedTypes()) + { + var def = nested.GetDefinition(); + if (def != null) { + types.Enqueue(def); + } + } } else if (type1.Kind == TypeKind.Class && type1.Name == "Apis") { From 70104511cd2ead2fe9a495e5a888b03f787a53c4 Mon Sep 17 00:00:00 2001 From: Mike Battista <13860912+mikebattista@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:08:05 -0800 Subject: [PATCH 2/3] Untangled some dependencies. --- generation/WinSDK/autoTypes.json | 2 +- generation/WinSDK/requiredNamespacesForNames.rsp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/generation/WinSDK/autoTypes.json b/generation/WinSDK/autoTypes.json index 56d2e6a74..8563f0241 100644 --- a/generation/WinSDK/autoTypes.json +++ b/generation/WinSDK/autoTypes.json @@ -250,7 +250,7 @@ "NativeTypedef": true }, { - "Namespace": "Windows.Win32.Media", + "Namespace": "Windows.Win32.Foundation", "Name": "HTASK", "ValueType": "DECLARE_HANDLE", "InvalidHandleValues": [ -1, 0 ], diff --git a/generation/WinSDK/requiredNamespacesForNames.rsp b/generation/WinSDK/requiredNamespacesForNames.rsp index 0716b2232..230173e42 100644 --- a/generation/WinSDK/requiredNamespacesForNames.rsp +++ b/generation/WinSDK/requiredNamespacesForNames.rsp @@ -285,6 +285,7 @@ DEPRECATED_CLR_API_MESG=Windows.Win32.System.ClrHosting # endregion mscoree.h # region mssip.h MS_ADDINFO_CATALOGMEMBER=Windows.Win32.Security.Cryptography.Catalog +SIP_INDIRECT_DATA=Windows.Win32.Security.Cryptography # endregion mssip.h # region ntifs.h RtlConvertSidToUnicodeString=Windows.Win32.Security @@ -433,7 +434,6 @@ ILayoutStorage=Windows.Win32.System.Com.StructuredStorage ILockBytes=Windows.Win32.System.Com.StructuredStorage IRootStorage=Windows.Win32.System.Com.StructuredStorage #ISequentialStream=Windows.Win32.System.Com.StructuredStorage -IStorage=Windows.Win32.System.Com.StructuredStorage #IStream=Windows.Win32.System.Com.StructuredStorage #IPersistStream=Windows.Win32.System.Com.StructuredStorage IPersistStorage=Windows.Win32.System.Com.StructuredStorage @@ -714,6 +714,9 @@ GetSystemCpuSetInformation=Windows.Win32.System.SystemInformation # region tvout.h VIDEOPARAMETERS=Windows.Win32.Devices.Display # endregion tvout.h +# region unknwn.h +IUnknown=Windows.Win32.Foundation +# endregion unknwnbase.h # region unknwnbase.h IUnknown_AddRef_Proxy=Windows.Win32.System.Rpc IUnknown_QueryInterface_Proxy=Windows.Win32.System.Rpc From 3123b3dea52272b0a015deab3992a1b5fa30d0c5 Mon Sep 17 00:00:00 2001 From: Mike Battista <13860912+mikebattista@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:09:23 -0800 Subject: [PATCH 3/3] Reverted IUnknown remap. --- generation/WinSDK/requiredNamespacesForNames.rsp | 3 --- 1 file changed, 3 deletions(-) diff --git a/generation/WinSDK/requiredNamespacesForNames.rsp b/generation/WinSDK/requiredNamespacesForNames.rsp index 230173e42..f20c7020e 100644 --- a/generation/WinSDK/requiredNamespacesForNames.rsp +++ b/generation/WinSDK/requiredNamespacesForNames.rsp @@ -714,9 +714,6 @@ GetSystemCpuSetInformation=Windows.Win32.System.SystemInformation # region tvout.h VIDEOPARAMETERS=Windows.Win32.Devices.Display # endregion tvout.h -# region unknwn.h -IUnknown=Windows.Win32.Foundation -# endregion unknwnbase.h # region unknwnbase.h IUnknown_AddRef_Proxy=Windows.Win32.System.Rpc IUnknown_QueryInterface_Proxy=Windows.Win32.System.Rpc