Skip to content

Commit 16f408c

Browse files
authored
Clean up ClrFacade.cs - remove ClrFacade.StructureToPtr (PowerShell#4380)
1 parent 21f7f36 commit 16f408c

4 files changed

Lines changed: 6 additions & 17 deletions

File tree

src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Sam.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ private void SetUserData(IntPtr userHandle,
22482248
info.UserAccountControl = uac;
22492249

22502250
buffer = Marshal.AllocHGlobal(ClrFacade.SizeOf<USER_ALL_INFORMATION>());
2251-
ClrFacade.StructureToPtr<USER_ALL_INFORMATION>(info, buffer, false);
2251+
Marshal.StructureToPtr<USER_ALL_INFORMATION>(info, buffer, false);
22522252

22532253
status = SamApi.SamSetInformationUser(userHandle,
22542254
USER_INFORMATION_CLASS.UserAllInformation,
@@ -2393,7 +2393,7 @@ private void SetSamDacl(IntPtr objectHandle, RawAcl rawAcl)
23932393

23942394
if (rawAcl != null && rawAcl.BinaryLength > 0)
23952395
{
2396-
ClrFacade.StructureToPtr<SECURITY_DESCRIPTOR>(sd, ipsd, false);
2396+
Marshal.StructureToPtr<SECURITY_DESCRIPTOR>(sd, ipsd, false);
23972397

23982398
// put the DACL into unmanaged memory
23992399
var length = rawAcl.BinaryLength;
@@ -2601,7 +2601,7 @@ private void SetUserPassword(IntPtr userHandle,
26012601
info.PasswordExpired = setPwExpire;
26022602

26032603
buffer = Marshal.AllocHGlobal(Marshal.SizeOf(info));
2604-
ClrFacade.StructureToPtr<USER_SET_PASSWORD_INFORMATION>(info, buffer, false);
2604+
Marshal.StructureToPtr<USER_SET_PASSWORD_INFORMATION>(info, buffer, false);
26052605

26062606
var status = SamApi.SamSetInformationUser(userHandle,
26072607
USER_INFORMATION_CLASS.UserSetPasswordInformation,

src/System.Management.Automation/engine/remoting/fanin/WSManPluginFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ public static int InitPlugin(
468468
// If there are any non-critical exceptions (e.g. we are running on CLR prior to 4.6.2), we won't be able to use long paths
469469
}
470470
#endif
471-
ClrFacade.StructureToPtr<WSManPluginEntryDelegates.WSManPluginEntryDelegatesInternal>(workerPtrs.UnmanagedStruct, wkrPtrs, false);
471+
Marshal.StructureToPtr<WSManPluginEntryDelegates.WSManPluginEntryDelegatesInternal>(workerPtrs.UnmanagedStruct, wkrPtrs, false);
472472
return WSManPluginConstants.ExitCodeSuccess;
473473
}
474474

src/System.Management.Automation/namespaces/FileSystemProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8561,7 +8561,7 @@ internal static bool DeleteJunction(string junctionPath)
85618561
// Using the wrong one results in mismatched-tag error.
85628562

85638563
REPARSE_GUID_DATA_BUFFER junctionData = new REPARSE_GUID_DATA_BUFFER();
8564-
ClrFacade.StructureToPtr<REPARSE_GUID_DATA_BUFFER>(junctionData, outBuffer, false);
8564+
Marshal.StructureToPtr<REPARSE_GUID_DATA_BUFFER>(junctionData, outBuffer, false);
85658565

85668566
result = DeviceIoControl(dangerousHandle, FSCTL_GET_REPARSE_POINT, IntPtr.Zero, 0,
85678567
outBuffer, inOutBufferSize, out bytesReturned, IntPtr.Zero);
@@ -8575,7 +8575,7 @@ internal static bool DeleteJunction(string junctionPath)
85758575
junctionData.ReparseDataLength = 0;
85768576
junctionData.DataBuffer = new char[MAX_REPARSE_SIZE];
85778577

8578-
ClrFacade.StructureToPtr<REPARSE_GUID_DATA_BUFFER>(junctionData, inBuffer, false);
8578+
Marshal.StructureToPtr<REPARSE_GUID_DATA_BUFFER>(junctionData, inBuffer, false);
85798579

85808580
// To delete a reparse point:
85818581
// ReparseDataLength must be 0

src/System.Management.Automation/utils/ClrFacade.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,6 @@ internal static T PtrToStructure<T>(IntPtr ptr)
9696
return Marshal.PtrToStructure<T>(ptr);
9797
}
9898

99-
/// <summary>
100-
/// Wraps Marshal.StructureToPtr to hide differences between the CLRs.
101-
/// </summary>
102-
internal static void StructureToPtr<T>(
103-
T structure,
104-
IntPtr ptr,
105-
bool deleteOld)
106-
{
107-
Marshal.StructureToPtr<T>(structure, ptr, deleteOld);
108-
}
109-
11099
#endregion Marshal
111100

112101
#region Assembly

0 commit comments

Comments
 (0)