Fixed #903.
This commit is contained in:
Родитель
b8b270e3d2
Коммит
8387ddf166
|
@ -1,3 +1,5 @@
|
|||
--exclude
|
||||
DiInstallDevice
|
||||
--traverse
|
||||
<IncludeRoot>/shared/cfg.h
|
||||
<IncludeRoot>/shared/devguid.h
|
||||
|
|
|
@ -72,4 +72,17 @@ namespace Windows.Win32.Devices.DeviceAndDriverInstallation
|
|||
CR_INVALID_STRUCTURE_SIZE = (0x0000003B),
|
||||
NUM_CR_RESULTS = (0x0000003C)
|
||||
}
|
||||
|
||||
public static unsafe partial class Apis
|
||||
{
|
||||
[DllImport("newdev.dll", EntryPoint = "DiInstallDevice", CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
|
||||
[return: NativeTypeName("BOOL")]
|
||||
[SupportedOSPlatform("windows6.0.6000")]
|
||||
public static extern int DiInstallDeviceA([NativeTypeName("HWND")] [CppAttributeList("Name=SAL_name; p1=\"_In_opt_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__maybe^Name=SAL_pre^Name=SAL_valid^Name=SAL_name; p1=\"_Deref_pre_readonly_\"; p2=\"\"; p3=\"1.1\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end^Name=SAL_end")] IntPtr hwndParent, [NativeTypeName("HDEVINFO")] [CppAttributeList("Name=SAL_name; p1=\"_In_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__no^Name=SAL_pre^Name=SAL_valid^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end")] void* DeviceInfoSet, [NativeTypeName("PSP_DEVINFO_DATA")] [CppAttributeList("Name=SAL_name; p1=\"_In_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__no^Name=SAL_pre^Name=SAL_valid^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end")] SP_DEVINFO_DATA* DeviceInfoData, [NativeTypeName("PSP_DRVINFO_DATA")] [CppAttributeList("Name=SAL_name; p1=\"_In_opt_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__maybe^Name=SAL_pre^Name=SAL_valid^Name=SAL_name; p1=\"_Deref_pre_readonly_\"; p2=\"\"; p3=\"1.1\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end^Name=SAL_end")] SP_DRVINFO_DATA_V2_A* DriverInfoData, [NativeTypeName("DWORD")] [CppAttributeList("Name=SAL_name; p1=\"_In_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__no^Name=SAL_pre^Name=SAL_valid^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end")] uint Flags, [NativeTypeName("PBOOL")] [CppAttributeList("Name=SAL_name; p1=\"_Out_opt_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__maybe^Name=SAL_pre^Name=SAL_notref^Name=SAL_writableTo; p1=elementCount(1)^Name=SAL_post^Name=SAL_valid^Name=SAL_end")] BOOL* NeedReboot);
|
||||
|
||||
[DllImport("newdev.dll", EntryPoint = "DiInstallDevice", CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
|
||||
[return: NativeTypeName("BOOL")]
|
||||
[SupportedOSPlatform("windows6.0.6000")]
|
||||
public static extern int DiInstallDeviceW([NativeTypeName("HWND")] [CppAttributeList("Name=SAL_name; p1=\"_In_opt_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__maybe^Name=SAL_pre^Name=SAL_valid^Name=SAL_name; p1=\"_Deref_pre_readonly_\"; p2=\"\"; p3=\"1.1\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end^Name=SAL_end")] IntPtr hwndParent, [NativeTypeName("HDEVINFO")] [CppAttributeList("Name=SAL_name; p1=\"_In_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__no^Name=SAL_pre^Name=SAL_valid^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end")] void* DeviceInfoSet, [NativeTypeName("PSP_DEVINFO_DATA")] [CppAttributeList("Name=SAL_name; p1=\"_In_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__no^Name=SAL_pre^Name=SAL_valid^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end")] SP_DEVINFO_DATA* DeviceInfoData, [NativeTypeName("PSP_DRVINFO_DATA")] [CppAttributeList("Name=SAL_name; p1=\"_In_opt_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__maybe^Name=SAL_pre^Name=SAL_valid^Name=SAL_name; p1=\"_Deref_pre_readonly_\"; p2=\"\"; p3=\"1.1\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end^Name=SAL_end")] SP_DRVINFO_DATA_V2_W* DriverInfoData, [NativeTypeName("DWORD")] [CppAttributeList("Name=SAL_name; p1=\"_In_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__no^Name=SAL_pre^Name=SAL_valid^Name=SAL_pre^Name=SAL_notref^Name=SAL_deref^Name=SAL_notref^Name=SAL_access; p1=0x1^Name=SAL_end")] uint Flags, [NativeTypeName("PBOOL")] [CppAttributeList("Name=SAL_name; p1=\"_Out_opt_\"; p2=\"\"; p3=\"2\"^Name=SAL_begin^Name=SAL_pre^Name=SAL_notref^Name=SAL_null; p1=__maybe^Name=SAL_pre^Name=SAL_notref^Name=SAL_writableTo; p1=elementCount(1)^Name=SAL_post^Name=SAL_valid^Name=SAL_end")] BOOL* NeedReboot);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,3 +43,7 @@ winmd1: Windows.Win32.UI.Controls.Apis.TD_ERROR_ICON = -2, winmd2 = 65534
|
|||
winmd1: Windows.Win32.UI.Controls.Apis.TD_INFORMATION_ICON = -3, winmd2 = 65533
|
||||
winmd1: Windows.Win32.UI.Controls.Apis.TD_SHIELD_ICON = -4, winmd2 = 65532
|
||||
winmd1: Windows.Win32.UI.Controls.Apis.TD_WARNING_ICON = -1, winmd2 = 65535
|
||||
# Fixed #903.
|
||||
Windows.Win32.Devices.DeviceAndDriverInstallation.Apis.DiInstallDevice removed
|
||||
Windows.Win32.Devices.DeviceAndDriverInstallation.Apis.DiInstallDeviceA added
|
||||
Windows.Win32.Devices.DeviceAndDriverInstallation.Apis.DiInstallDeviceW added
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<icon>images\windows.png</icon>
|
||||
<repository type="git" url="https://github.com/microsoft/win32metadata.git" />
|
||||
<dependencies>
|
||||
<dependency id="Microsoft.Windows.SDK.Win32Metadata" version="47.0.25-preview" />
|
||||
<dependency id="Microsoft.Windows.SDK.Win32Metadata" version="48.0.6-preview" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
|
||||
|
|
|
@ -47,9 +47,10 @@ namespace WinmdUtilsProgram
|
|||
var showDuplicateImports = new Command("showDuplicateImports", "Show duplicate imports in a single winmd files.")
|
||||
{
|
||||
new Option<FileInfo>("--winmd", "The winmd to inspect.") { IsRequired = true }.ExistingOnly(),
|
||||
new Option<string>("--allowItem", "Item to allow and not flag as an error.", ArgumentArity.OneOrMore)
|
||||
};
|
||||
|
||||
showDuplicateImports.Handler = CommandHandler.Create<FileInfo, IConsole>(ShowDuplicateImports);
|
||||
showDuplicateImports.Handler = CommandHandler.Create<FileInfo, string[], IConsole>(ShowDuplicateImports);
|
||||
|
||||
var showDuplicateTypes = new Command("showDuplicateTypes", "Show duplicate types in a single winmd files.")
|
||||
{
|
||||
|
@ -1012,12 +1013,13 @@ namespace WinmdUtilsProgram
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static int ShowDuplicateImports(FileInfo winmd, IConsole console)
|
||||
public static int ShowDuplicateImports(FileInfo winmd, string[] allowItem, IConsole console)
|
||||
{
|
||||
DecompilerSettings settings = new DecompilerSettings() { ThrowOnAssemblyResolveErrors = false };
|
||||
DecompilerTypeSystem winmd1 = DecompilerTypeSystemUtils.CreateTypeSystemFromFile(winmd.FullName);
|
||||
|
||||
Dictionary<string, List<string>> dllImportsToClassNames = new Dictionary<string, List<string>>();
|
||||
HashSet<string> allowTable = new HashSet<string>(allowItem);
|
||||
|
||||
foreach (var type1 in winmd1.GetTopLevelTypeDefinitions())
|
||||
{
|
||||
|
@ -1075,6 +1077,11 @@ namespace WinmdUtilsProgram
|
|||
bool dupsFound = false;
|
||||
foreach (var pair in dllImportsToClassNames)
|
||||
{
|
||||
if (allowTable.Contains(pair.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pair.Value.Count > 1)
|
||||
{
|
||||
if (dupsFound == false)
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace Windows.Win32.Tests
|
|||
[Fact]
|
||||
public void NoDuplicateImports()
|
||||
{
|
||||
string args = $"showDuplicateImports --winmd \"{TestUtils.Win32WinmdPath}\"";
|
||||
string allowedDuplicateImportsFileName = TestUtils.GetAssetFile("duplicateImportsAllowList.rsp");
|
||||
string args = $"showDuplicateImports --winmd \"{TestUtils.Win32WinmdPath}\" \"@{allowedDuplicateImportsFileName}\"";
|
||||
this.ExecWinmdUtils(args);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
<None Update="assets\duplicateConstantsAllowList.rsp">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="assets\duplicateImportsAllowList.rsp">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="InterfacesToVerify.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
--allowItem
|
||||
NEWDEV.DLL:DIINSTALLDEVICE
|
Загрузка…
Ссылка в новой задаче