Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void Dispose()
{
if (objectName != IntPtr.Zero)
{
ClrFacade.DestroyStructure<UNICODE_STRING>(objectName);
Marshal.DestroyStructure<UNICODE_STRING>(objectName);
Marshal.FreeHGlobal(objectName);
objectName = IntPtr.Zero;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Sam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ private LocalUser CreateUser(LocalUser userInfo, System.Security.SecureString pa
out userHandle,
out grantedAccess,
out relativeId);
ClrFacade.DestroyStructure<UNICODE_STRING>(buffer);
Marshal.DestroyStructure<UNICODE_STRING>(buffer);
Marshal.FreeHGlobal(buffer);
buffer = IntPtr.Zero;
ThrowOnFailure(status);
Expand Down Expand Up @@ -1371,7 +1371,7 @@ private void RenameGroup(SecurityIdentifier sid, string newName)
{
if (buffer != IntPtr.Zero)
{
ClrFacade.DestroyStructure<ALIAS_NAME_INFORMATION>(buffer);
Marshal.DestroyStructure<ALIAS_NAME_INFORMATION>(buffer);
Marshal.FreeHGlobal(buffer);
}
if (aliasHandle != IntPtr.Zero)
Expand Down Expand Up @@ -1700,7 +1700,7 @@ private void EnableUser(SecurityIdentifier sid, Enabling enable)
status = SamApi.SamSetInformationUser(userHandle,
USER_INFORMATION_CLASS.UserAllInformation,
buffer);
ClrFacade.DestroyStructure<USER_ALL_INFORMATION>(buffer);
Marshal.DestroyStructure<USER_ALL_INFORMATION>(buffer);
Marshal.FreeHGlobal(buffer);
buffer = IntPtr.Zero;
ThrowOnFailure(status);
Expand Down Expand Up @@ -1760,7 +1760,7 @@ private void RenameUser(SecurityIdentifier sid, string newName)
{
if (buffer != IntPtr.Zero)
{
ClrFacade.DestroyStructure<USER_ACCOUNT_NAME_INFORMATION>(buffer);
Marshal.DestroyStructure<USER_ACCOUNT_NAME_INFORMATION>(buffer);
Marshal.FreeHGlobal(buffer);
}
if (userHandle != IntPtr.Zero)
Expand Down Expand Up @@ -1903,7 +1903,7 @@ private LocalGroup CreateGroup(LocalGroup groupInfo, IntPtr domainHandle)
Win32.MAXIMUM_ALLOWED,
out aliasHandle,
out relativeId);
ClrFacade.DestroyStructure<UNICODE_STRING>(buffer);
Marshal.DestroyStructure<UNICODE_STRING>(buffer);
Marshal.FreeHGlobal(buffer);
buffer = IntPtr.Zero;
ThrowOnFailure(status);
Expand All @@ -1920,7 +1920,7 @@ private LocalGroup CreateGroup(LocalGroup groupInfo, IntPtr domainHandle)
ALIAS_INFORMATION_CLASS.AliasAdminCommentInformation,
buffer);

ClrFacade.DestroyStructure<ALIAS_ADM_COMMENT_INFORMATION>(buffer);
Marshal.DestroyStructure<ALIAS_ADM_COMMENT_INFORMATION>(buffer);
Marshal.FreeHGlobal(buffer);
buffer = IntPtr.Zero;
ThrowOnFailure(status);
Expand Down Expand Up @@ -1995,7 +1995,7 @@ private void UpdateGroup(LocalGroup group, LocalGroup changed)
{
if (buffer != IntPtr.Zero)
{
ClrFacade.DestroyStructure<ALIAS_ADM_COMMENT_INFORMATION>(buffer);
Marshal.DestroyStructure<ALIAS_ADM_COMMENT_INFORMATION>(buffer);
Marshal.FreeHGlobal(buffer);
}
if (aliasHandle != IntPtr.Zero)
Expand Down Expand Up @@ -2268,7 +2268,7 @@ private void SetUserData(IntPtr userHandle,
{
if (buffer != IntPtr.Zero)
{
ClrFacade.DestroyStructure<USER_ALL_INFORMATION>(buffer);
Marshal.DestroyStructure<USER_ALL_INFORMATION>(buffer);
Marshal.FreeHGlobal(buffer);
}
}
Expand Down Expand Up @@ -2612,7 +2612,7 @@ private void SetUserPassword(IntPtr userHandle,
{
if (buffer != IntPtr.Zero)
{
ClrFacade.DestroyStructure<USER_SET_PASSWORD_INFORMATION>(buffer);
Marshal.DestroyStructure<USER_SET_PASSWORD_INFORMATION>(buffer);
Marshal.FreeHGlobal(buffer);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/System.Management.Automation/security/Authenticode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ internal static Signature SignFile(SigningOption option,

if (si.pSignExtInfo != null)
{
ClrFacade.DestroyStructure<NativeMethods.CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO>(si.pSignExtInfo);
Marshal.DestroyStructure<NativeMethods.CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO>(si.pSignExtInfo);
Marshal.FreeCoTaskMem(si.pSignExtInfo);
}

Expand Down Expand Up @@ -268,7 +268,7 @@ internal static Signature SignFile(SigningOption option,
}
finally
{
ClrFacade.DestroyStructure<NativeMethods.CRYPTUI_WIZ_DIGITAL_SIGN_INFO>(pSignInfo);
Marshal.DestroyStructure<NativeMethods.CRYPTUI_WIZ_DIGITAL_SIGN_INFO>(pSignInfo);
Marshal.FreeCoTaskMem(pSignInfo);
}

Expand Down Expand Up @@ -552,9 +552,9 @@ private static DWORD GetWinTrustData(string fileName, string fileContent,
}
finally
{
ClrFacade.DestroyStructure<Guid>(WINTRUST_ACTION_GENERIC_VERIFY_V2);
Marshal.DestroyStructure<Guid>(WINTRUST_ACTION_GENERIC_VERIFY_V2);
Marshal.FreeCoTaskMem(WINTRUST_ACTION_GENERIC_VERIFY_V2);
ClrFacade.DestroyStructure<NativeMethods.WINTRUST_DATA>(wtdBuffer);
Marshal.DestroyStructure<NativeMethods.WINTRUST_DATA>(wtdBuffer);
Marshal.FreeCoTaskMem(wtdBuffer);
}
return dwResult;
Expand Down
12 changes: 6 additions & 6 deletions src/System.Management.Automation/security/nativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,9 @@ internal static DWORD DestroyWintrustDataStruct(WINTRUST_DATA wtd)
}
finally
{
ClrFacade.DestroyStructure<WINTRUST_DATA>(wtdBuffer);
Marshal.DestroyStructure<WINTRUST_DATA>(wtdBuffer);
Marshal.FreeCoTaskMem(wtdBuffer);
ClrFacade.DestroyStructure<Guid>(WINTRUST_ACTION_GENERIC_VERIFY_V2);
Marshal.DestroyStructure<Guid>(WINTRUST_ACTION_GENERIC_VERIFY_V2);
Marshal.FreeCoTaskMem(WINTRUST_ACTION_GENERIC_VERIFY_V2);
}

Expand All @@ -1051,12 +1051,12 @@ internal static DWORD DestroyWintrustDataStruct(WINTRUST_DATA wtd)
(WINTRUST_BLOB_INFO)ClrFacade.PtrToStructure<WINTRUST_BLOB_INFO>(wtd.Choice.pBlob);
Marshal.FreeCoTaskMem(originalBlob.pbMemObject);

ClrFacade.DestroyStructure<WINTRUST_BLOB_INFO>(wtd.Choice.pBlob);
Marshal.DestroyStructure<WINTRUST_BLOB_INFO>(wtd.Choice.pBlob);
Marshal.FreeCoTaskMem(wtd.Choice.pBlob);
}
else
{
ClrFacade.DestroyStructure<WINTRUST_FILE_INFO>(wtd.Choice.pFile);
Marshal.DestroyStructure<WINTRUST_FILE_INFO>(wtd.Choice.pFile);
Marshal.FreeCoTaskMem(wtd.Choice.pFile);
}

Expand Down Expand Up @@ -1170,9 +1170,9 @@ internal static void FreeWVTStateData(System.IntPtr phWVTStateData)
}
finally
{
ClrFacade.DestroyStructure<WINTRUST_DATA>(wtdBuffer);
Marshal.DestroyStructure<WINTRUST_DATA>(wtdBuffer);
Marshal.FreeCoTaskMem(wtdBuffer);
ClrFacade.DestroyStructure<Guid>(WINTRUST_ACTION_GENERIC_VERIFY_V2);
Marshal.DestroyStructure<Guid>(WINTRUST_ACTION_GENERIC_VERIFY_V2);
Marshal.FreeCoTaskMem(WINTRUST_ACTION_GENERIC_VERIFY_V2);
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/System.Management.Automation/utils/ClrFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ internal static int SizeOf<T>()
return Marshal.SizeOf<T>();
}

/// <summary>
/// Facade for Marshal.DestroyStructure
/// </summary>
internal static void DestroyStructure<T>(IntPtr ptr)
{
// Marshal.DestroyStructure(IntPtr, Type) is obsolete in CoreCLR
Marshal.DestroyStructure<T>(ptr);
}

/// <summary>
/// Facade for Marshal.PtrToStructure
/// </summary>
Expand Down