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 @@ -821,7 +821,7 @@ private static string RetrieveProcessUserName(Process process)
}
}

var tokenUser = ClrFacade.PtrToStructure<Win32Native.TOKEN_USER>(tokenUserInfo);
var tokenUser = Marshal.PtrToStructure<Win32Native.TOKEN_USER>(tokenUserInfo);

// Set the default length to be 256, so it will be sufficient for most cases
int userNameLength = 256, domainNameLength = 256;
Expand Down
20 changes: 10 additions & 10 deletions src/Microsoft.PowerShell.LocalAccounts/LocalAccounts/Sam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ private void OpenHandles()

lsaHandle = IntPtr.Zero;

domainInfo = ClrFacade.PtrToStructure<POLICY_PRIMARY_DOMAIN_INFO>(pInfo);
domainInfo = Marshal.PtrToStructure<POLICY_PRIMARY_DOMAIN_INFO>(pInfo);

status = SamApi.SamConnect(ref systemName, out samHandle, SamApi.SAM_SERVER_LOOKUP_DOMAIN, ref oa);
ThrowOnFailure(status);
Expand Down Expand Up @@ -1173,7 +1173,7 @@ private static IEnumerable<SamRidEnumeration> EnumerateUsersInDomain(IntPtr doma
{
SAM_RID_ENUMERATION sre;

sre = ClrFacade.PtrToStructure<SAM_RID_ENUMERATION>(buffer);
sre = Marshal.PtrToStructure<SAM_RID_ENUMERATION>(buffer);

SamApi.SamFreeMemory(buffer);
buffer = IntPtr.Zero;
Expand Down Expand Up @@ -1605,7 +1605,7 @@ private LocalUser MakeLocalUserObject(SamRidEnumeration sre, IntPtr userHandle)
USER_INFORMATION_CLASS.UserAllInformation,
out buffer);
ThrowOnFailure(status);
allInfo = ClrFacade.PtrToStructure<USER_ALL_INFORMATION>(buffer);
allInfo = Marshal.PtrToStructure<USER_ALL_INFORMATION>(buffer);

var userSid = RidToSid(sre.domainHandle, sre.RelativeId);
LocalUser user = new LocalUser()
Expand Down Expand Up @@ -1676,7 +1676,7 @@ private void EnableUser(SecurityIdentifier sid, Enabling enable)
USER_INFORMATION_CLASS.UserAllInformation,
out buffer);
ThrowOnFailure(status);
info = ClrFacade.PtrToStructure<USER_ALL_INFORMATION>(buffer);
info = Marshal.PtrToStructure<USER_ALL_INFORMATION>(buffer);
status = SamApi.SamFreeMemory(buffer);
buffer = IntPtr.Zero;

Expand Down Expand Up @@ -1836,7 +1836,7 @@ private static IEnumerable<SamRidEnumeration> EnumerateGroupsInDomain(IntPtr dom
{
SAM_RID_ENUMERATION sre;

sre = ClrFacade.PtrToStructure<SAM_RID_ENUMERATION>(buffer);
sre = Marshal.PtrToStructure<SAM_RID_ENUMERATION>(buffer);

SamApi.SamFreeMemory(buffer);
buffer = IntPtr.Zero;
Expand Down Expand Up @@ -2061,7 +2061,7 @@ private LocalGroup MakeLocalGroupObject(SamRidEnumeration sre, IntPtr aliasHandl
ALIAS_INFORMATION_CLASS.AliasGeneralInformation,
out buffer);
ThrowOnFailure(status);
generalInfo = ClrFacade.PtrToStructure<ALIAS_GENERAL_INFORMATION>(buffer);
generalInfo = Marshal.PtrToStructure<ALIAS_GENERAL_INFORMATION>(buffer);

LocalGroup group = new LocalGroup()
{
Expand Down Expand Up @@ -2296,7 +2296,7 @@ private UInt32 GetUserAccountControl(IntPtr userHandle)
USER_INFORMATION_CLASS.UserLogonInformation,
out buffer);
ThrowOnFailure(status);
info = ClrFacade.PtrToStructure<USER_LOGON_INFORMATION>(buffer);
info = Marshal.PtrToStructure<USER_LOGON_INFORMATION>(buffer);
status = SamApi.SamFreeMemory(buffer);
buffer = IntPtr.Zero;

Expand Down Expand Up @@ -2330,7 +2330,7 @@ private RawAcl GetSamDacl(IntPtr objectHandle)
status = SamApi.SamQuerySecurityObject(objectHandle, Win32.DACL_SECURITY_INFORMATION, out securityObject);
ThrowOnFailure(status);

SECURITY_DESCRIPTOR sd = ClrFacade.PtrToStructure<SECURITY_DESCRIPTOR>(securityObject);
SECURITY_DESCRIPTOR sd = Marshal.PtrToStructure<SECURITY_DESCRIPTOR>(securityObject);

bool daclPresent;
bool daclDefaulted;
Expand All @@ -2348,7 +2348,7 @@ private RawAcl GetSamDacl(IntPtr objectHandle)

if (daclPresent)
{
ACL acl = ClrFacade.PtrToStructure<ACL>(dacl);
ACL acl = Marshal.PtrToStructure<ACL>(dacl);

if (acl.AclSize != 0)
{
Expand Down Expand Up @@ -2544,7 +2544,7 @@ private bool IsPasswordExpired(IntPtr userHandle)
USER_INFORMATION_CLASS.UserAllInformation,
out buffer);
ThrowOnFailure(status);
info = ClrFacade.PtrToStructure<USER_ALL_INFORMATION>(buffer);
info = Marshal.PtrToStructure<USER_ALL_INFORMATION>(buffer);
status = SamApi.SamFreeMemory(buffer);
buffer = IntPtr.Zero;

Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.PowerShell.Security/security/AclCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public static SecurityIdentifier GetCentralAccessPolicyId(PSObject instance)
return null;
}
NativeMethods.ACL sacl = new NativeMethods.ACL();
sacl = ClrFacade.PtrToStructure<NativeMethods.ACL>(pSacl);
sacl = Marshal.PtrToStructure<NativeMethods.ACL>(pSacl);
if (sacl.AceCount == 0)
{
return null;
Expand All @@ -399,7 +399,7 @@ public static SecurityIdentifier GetCentralAccessPolicyId(PSObject instance)
for (uint aceIdx = 0; aceIdx < sacl.AceCount; aceIdx++)
{
NativeMethods.ACE_HEADER ace = new NativeMethods.ACE_HEADER();
ace = ClrFacade.PtrToStructure<NativeMethods.ACE_HEADER>(pAce);
ace = Marshal.PtrToStructure<NativeMethods.ACE_HEADER>(pAce);
Dbg.Diagnostics.Assert(ace.AceType ==
NativeMethods.SYSTEM_SCOPED_POLICY_ID_ACE_TYPE,
"Unexpected ACE type: " + ace.AceType.ToString(CultureInfo.CurrentCulture));
Expand Down Expand Up @@ -474,7 +474,7 @@ public static string GetCentralAccessPolicyName(PSObject instance)

// Get the CAP name.
NativeMethods.CENTRAL_ACCESS_POLICY cap = new NativeMethods.CENTRAL_ACCESS_POLICY();
cap = ClrFacade.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(caps);
cap = Marshal.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(caps);
// LSA_UNICODE_STRING is composed of WCHARs, but its length is given in bytes.
return Marshal.PtrToStringUni(cap.Name.Buffer, cap.Name.Length / 2);
}
Expand Down Expand Up @@ -532,7 +532,7 @@ public static string[] GetAllCentralAccessPolicies(PSObject instance)
// Retrieve CAP name.
Dbg.Diagnostics.Assert(capPtr != IntPtr.Zero,
"Invalid central access policies array");
cap = ClrFacade.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(capPtr);
cap = Marshal.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(capPtr);
// LSA_UNICODE_STRING is composed of WCHARs, but its length is given in bytes.
policies[capIdx] = "\"" + Marshal.PtrToStringUni(
cap.Name.Buffer,
Expand Down Expand Up @@ -1145,7 +1145,7 @@ private IntPtr GetSaclWithCapId(string capStr)
{
Dbg.Diagnostics.Assert(capPtr != IntPtr.Zero,
"Invalid central access policies array");
cap = ClrFacade.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(capPtr);
cap = Marshal.PtrToStructure<NativeMethods.CENTRAL_ACCESS_POLICY>(capPtr);
// LSA_UNICODE_STRING is composed of WCHARs, but its length is given in bytes.
string capName = Marshal.PtrToStringUni(
cap.Name.Buffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ private void DoDeleteKey(IntPtr pProvInfo)
{
IntPtr hProv = IntPtr.Zero;
Security.NativeMethods.CRYPT_KEY_PROV_INFO keyProvInfo =
ClrFacade.PtrToStructure<Security.NativeMethods.CRYPT_KEY_PROV_INFO>(pProvInfo);
Marshal.PtrToStructure<Security.NativeMethods.CRYPT_KEY_PROV_INFO>(pProvInfo);

IntPtr hWnd = DetectUIHelper.GetOwnerWindow(Host);

Expand Down Expand Up @@ -1896,7 +1896,7 @@ private void DoRemove(X509Certificate2 cert, bool fDeleteKey, bool fMachine, str
if (sourcePath.Contains("UserDS"))
{
Security.NativeMethods.CERT_CONTEXT context =
ClrFacade.PtrToStructure<Security.NativeMethods.CERT_CONTEXT>(cert.Handle);
Marshal.PtrToStructure<Security.NativeMethods.CERT_CONTEXT>(cert.Handle);

CommitUserDS(context.hCertStore);
}
Expand Down Expand Up @@ -1990,7 +1990,7 @@ private void DoMove(string destination, X509Certificate2 cert, X509NativeStore s

if (sourcePath.Contains("UserDS"))
{
Security.NativeMethods.CERT_CONTEXT context = ClrFacade.PtrToStructure<Security.NativeMethods.CERT_CONTEXT>(cert.Handle);
Security.NativeMethods.CERT_CONTEXT context = Marshal.PtrToStructure<Security.NativeMethods.CERT_CONTEXT>(cert.Handle);

CommitUserDS(context.hCertStore);
}
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/COM/ComMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal Collection<String> MethodDefinitions()
IntPtr pFuncDesc;

_typeInfo.GetFuncDesc(index, out pFuncDesc);
COM.FUNCDESC funcdesc = ClrFacade.PtrToStructure<COM.FUNCDESC>(pFuncDesc);
COM.FUNCDESC funcdesc = Marshal.PtrToStructure<COM.FUNCDESC>(pFuncDesc);

string signature = ComUtil.GetMethodSignatureFromFuncDesc(_typeInfo, funcdesc, false);
result.Add(signature);
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/COM/ComProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal Type Type
try
{
_typeInfo.GetFuncDesc(GetFuncDescIndex(), out pFuncDesc);
COM.FUNCDESC funcdesc = ClrFacade.PtrToStructure<COM.FUNCDESC>(pFuncDesc);
COM.FUNCDESC funcdesc = Marshal.PtrToStructure<COM.FUNCDESC>(pFuncDesc);

if (IsGettable)
{
Expand Down Expand Up @@ -347,7 +347,7 @@ internal string GetDefinition()
try
{
_typeInfo.GetFuncDesc(GetFuncDescIndex(), out pFuncDesc);
COM.FUNCDESC funcdesc = ClrFacade.PtrToStructure<COM.FUNCDESC>(pFuncDesc);
COM.FUNCDESC funcdesc = Marshal.PtrToStructure<COM.FUNCDESC>(pFuncDesc);

return ComUtil.GetMethodSignatureFromFuncDesc(_typeInfo, funcdesc, !IsGettable);
}
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/COM/ComTypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ internal static COM.TYPEATTR GetTypeAttr(COM.ITypeInfo typeinfo)
{
IntPtr pTypeAttr;
typeinfo.GetTypeAttr(out pTypeAttr);
COM.TYPEATTR typeattr = ClrFacade.PtrToStructure<COM.TYPEATTR>(pTypeAttr);
COM.TYPEATTR typeattr = Marshal.PtrToStructure<COM.TYPEATTR>(pTypeAttr);
typeinfo.ReleaseTypeAttr(pTypeAttr);
return typeattr;
}
Expand All @@ -215,7 +215,7 @@ internal static COM.FUNCDESC GetFuncDesc(COM.ITypeInfo typeinfo, int index)
{
IntPtr pFuncDesc;
typeinfo.GetFuncDesc(index, out pFuncDesc);
COM.FUNCDESC funcdesc = ClrFacade.PtrToStructure<COM.FUNCDESC>(pFuncDesc);
COM.FUNCDESC funcdesc = Marshal.PtrToStructure<COM.FUNCDESC>(pFuncDesc);
typeinfo.ReleaseFuncDesc(pFuncDesc);
return funcdesc;
}
Expand Down
10 changes: 5 additions & 5 deletions src/System.Management.Automation/engine/COM/ComUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internal static string GetMethodSignatureFromFuncDesc(COM.ITypeInfo typeinfo, CO
}
#pragma warning restore 56515

ElementDescription = ClrFacade.PtrToStructure<COM.ELEMDESC>(ElementDescriptionPointer);
ElementDescription = Marshal.PtrToStructure<COM.ELEMDESC>(ElementDescriptionPointer);

string paramstring = GetStringFromTypeDesc(typeinfo, ElementDescription.tdesc);

Expand Down Expand Up @@ -149,13 +149,13 @@ private static string GetStringFromTypeDesc(COM.ITypeInfo typeinfo, COM.TYPEDESC
{
if ((VarEnum)typedesc.vt == VarEnum.VT_PTR)
{
COM.TYPEDESC refdesc = ClrFacade.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
COM.TYPEDESC refdesc = Marshal.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
return GetStringFromTypeDesc(typeinfo, refdesc);
}

if ((VarEnum)typedesc.vt == VarEnum.VT_SAFEARRAY)
{
COM.TYPEDESC refdesc = ClrFacade.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
COM.TYPEDESC refdesc = Marshal.PtrToStructure<COM.TYPEDESC>(typedesc.lpValue);
return "SAFEARRAY(" + GetStringFromTypeDesc(typeinfo, refdesc) + ")";
}

Expand Down Expand Up @@ -314,7 +314,7 @@ internal static ParameterInformation[] GetParameterInformation(COM.FUNCDESC func

#pragma warning enable 56515

ElementDescription = ClrFacade.PtrToStructure<COM.ELEMDESC>(ElementDescriptionPointer);
ElementDescription = Marshal.PtrToStructure<COM.ELEMDESC>(ElementDescriptionPointer);

//get the type of parameter
Type type = ComUtil.GetTypeFromTypeDesc(ElementDescription.tdesc);
Expand Down Expand Up @@ -348,7 +348,7 @@ internal static ComMethodInformation[] GetMethodInformationArray(COM.ITypeInfo t
{
IntPtr pFuncDesc;
typeInfo.GetFuncDesc(index, out pFuncDesc);
COM.FUNCDESC funcdesc = ClrFacade.PtrToStructure<COM.FUNCDESC>(pFuncDesc);
COM.FUNCDESC funcdesc = Marshal.PtrToStructure<COM.FUNCDESC>(pFuncDesc);
returnValue[count++] = ComUtil.GetMethodInformation(funcdesc, skipLastParameters);
typeInfo.ReleaseFuncDesc(pFuncDesc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4469,8 +4469,7 @@ internal static List<string> GetFileShares(string machine, bool ignoreHidden)
for (int i = 0; i < numEntries; ++i)
{
IntPtr curInfoPtr = (IntPtr)((long)shBuf + (Marshal.SizeOf<SHARE_INFO_1>() * i));
SHARE_INFO_1 shareInfo = ClrFacade.PtrToStructure<SHARE_INFO_1>(curInfoPtr);

SHARE_INFO_1 shareInfo = Marshal.PtrToStructure<SHARE_INFO_1>(curInfoPtr);

if ((shareInfo.type & STYPE_MASK) != STYPE_DISKTREE)
continue;
Expand Down
Loading