From 3598cb561116ec13ea19a5b774a8728020d12b13 Mon Sep 17 00:00:00 2001 From: Mike Battista <13860912+mikebattista@users.noreply.github.com> Date: Wed, 19 Jul 2023 11:20:15 -0700 Subject: [PATCH] LoadResource generates an unexpected GlobalFreeSafeHandle Fixed #1622. Reverted #792. --- docs/projections.md | 3 +-- generation/WinSDK/emitter.settings.rsp | 5 +++-- generation/WinSDK/manual/Metadata.cs | 7 ------- scripts/ChangesSinceLastRelease.txt | 4 ++++ 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/projections.md b/docs/projections.md index d1a3994bf..d302d460a 100644 --- a/docs/projections.md +++ b/docs/projections.md @@ -58,8 +58,7 @@ DISCLAIMER: This list is a work in progress and is not yet comprehensive. * Pointer parameters whose byte size must be specified in another parameter are decorated with the `[MemorySize]` attribute that will contain the 0-based index of the parameter that can be automatically populated with the size of the provided pointer parameter (`BytesParamIndex`) ([#284](https://github.com/microsoft/win32metadata/issues/284)) * Parameters that accept values from an enum but have conflicting types are decorated with the `[AssociatedEnum]` attribute indicating the enum that may be used with the parameter. The enum must exist in the same namespace as the API. This enables the metadata to preserve the original API definition while allowing projections to improve usability of the API with the enum if they choose. ([#1502](https://github.com/microsoft/win32metadata/issues/1502)) * Output parameters that must be closed with a specific function are decorated with the `[FreeWith]` attribute -* Handle parameters that should not be closed are decorated with the `[DoNotRelease]` attribute -* Handle parameters or return values decorated with `[ReturnsUnownedHandle]` are unowned ([#792](https://github.com/microsoft/win32metadata/issues/792)) +* Handle parameters or return values that are unowned and should not be closed are decorated with the `[DoNotRelease]` attribute ([#1622](https://github.com/microsoft/win32metadata/issues/1622)) * Handle parameters decorated with `[IgnoreIfReturn]` are undefined in failure scenarios and should be ignored if the value specified by the attribute is returned. Multiple return values are represented by multiple attributes. ([#1312](https://github.com/microsoft/win32metadata/issues/1312)) * Return value parameters marked with the `_retval_` SAL annotation are decorated with the `[RetVal]` attribute * Functions that return multiple success values or return errors as success are decorated with `[CanReturnMultipleSuccessValues]` and `[CanReturnErrorsAsSuccess]` ([#1315](https://github.com/microsoft/win32metadata/issues/1315)) diff --git a/generation/WinSDK/emitter.settings.rsp b/generation/WinSDK/emitter.settings.rsp index 735afd29c..47b024038 100644 --- a/generation/WinSDK/emitter.settings.rsp +++ b/generation/WinSDK/emitter.settings.rsp @@ -1141,7 +1141,7 @@ PrivateExtractIconsA::piconid=[-NativeArrayInfo] PrivateExtractIconsW::piconid=[-NativeArrayInfo] CfConnectSyncRoot::CallbackTable=[NativeArrayInfo] CERT_INFO::rgExtension=[NativeArrayInfo(CountFieldName="cExtension")] -GetClipboardData::return=[ReturnsUnownedHandle] +GetClipboardData::return=[DoNotRelease] GetCommandLineA::return=[Const] GetCommandLineW::return=[Const] EXTENSION_CONTROL_BLOCK::GetServerVariable=PFN_IIS_GETSERVERVARIABLE @@ -1681,4 +1681,5 @@ RmRemoveFilter::return=WIN32_ERROR RmRestart::return=WIN32_ERROR RmShutdown::return=WIN32_ERROR RmStartSession::return=WIN32_ERROR -IServiceProvider::QueryService::ppvObject=[ComOutPtr] \ No newline at end of file +IServiceProvider::QueryService::ppvObject=[ComOutPtr] +LoadResource::return=[DoNotRelease] \ No newline at end of file diff --git a/generation/WinSDK/manual/Metadata.cs b/generation/WinSDK/manual/Metadata.cs index 50d52f5bf..44ac726f9 100644 --- a/generation/WinSDK/manual/Metadata.cs +++ b/generation/WinSDK/manual/Metadata.cs @@ -251,13 +251,6 @@ public ReservedAttribute() } } -public class ReturnsUnownedHandle : Attribute -{ - public ReturnsUnownedHandle() - { - } -} - [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] public class RetValAttribute : Attribute { diff --git a/scripts/ChangesSinceLastRelease.txt b/scripts/ChangesSinceLastRelease.txt index 266168116..c416c8d8e 100644 --- a/scripts/ChangesSinceLastRelease.txt +++ b/scripts/ChangesSinceLastRelease.txt @@ -61790,3 +61790,7 @@ Windows.Win32.System.RestartManager.Apis.RmShutdown : return...UInt32 => WIN32_E Windows.Win32.System.RestartManager.Apis.RmStartSession : return...UInt32 => WIN32_ERROR # Fixed #1625. Windows.Win32.System.Com.IServiceProvider.QueryService : ppvObject : [Out] => [ComOutPtr,Out] +# Fixed #1622. +Windows.Win32.Foundation.Metadata.ReturnsUnownedHandle removed +Windows.Win32.System.DataExchange.Apis.GetClipboardData : return : [ReturnsUnownedHandle] => [DoNotRelease] +Windows.Win32.System.LibraryLoader.Apis.LoadResource : return : => [DoNotRelease]