Skip to content

Commit

Permalink
LoadResource generates an unexpected GlobalFreeSafeHandle Fixed #1622.
Browse files Browse the repository at this point in the history
Reverted #792.
  • Loading branch information
mikebattista committed Jul 19, 2023
1 parent 660bc14 commit 3598cb5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions docs/projections.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

This comment has been minimized.

Copy link
@sharwell

sharwell Jul 19, 2023

Member

💡 Might be good to include wording about unowned for future readers. For example, the following added sentence:

This includes return values which are unowned ([#792](https://github.com/microsoft/win32metadata/issues/792)).

This comment has been minimized.

Copy link
@mikebattista

mikebattista Jul 19, 2023

Author Contributor

That text is already included.

* 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))
Expand Down
5 changes: 3 additions & 2 deletions generation/WinSDK/emitter.settings.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1681,4 +1681,5 @@ RmRemoveFilter::return=WIN32_ERROR
RmRestart::return=WIN32_ERROR
RmShutdown::return=WIN32_ERROR
RmStartSession::return=WIN32_ERROR
IServiceProvider::QueryService::ppvObject=[ComOutPtr]
IServiceProvider::QueryService::ppvObject=[ComOutPtr]
LoadResource::return=[DoNotRelease]
7 changes: 0 additions & 7 deletions generation/WinSDK/manual/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,6 @@ public ReservedAttribute()
}
}

public class ReturnsUnownedHandle : Attribute
{
public ReturnsUnownedHandle()
{
}
}

[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public class RetValAttribute : Attribute
{
Expand Down
4 changes: 4 additions & 0 deletions scripts/ChangesSinceLastRelease.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit 3598cb5

Please sign in to comment.