system\deployment\isolationinterop.cs (49)
22Marshal.FreeCoTaskMem(BlobData);
1221Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationStageComponent));
1261Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationStageComponentFile));
1292Size = (UInt32)Marshal.SizeOf(typeof(StoreApplicationReference));
1302IntPtr Reference = Marshal.AllocCoTaskMem(Marshal.SizeOf(this));
1303Marshal.StructureToPtr(this, Reference, false);
1312Marshal.DestroyStructure(ip, typeof(StoreApplicationReference));
1313Marshal.FreeCoTaskMem(ip);
1344Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationPinDeployment));
1390Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationUnpinDeployment));
1434Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationInstallDeployment));
1478Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationUninstallDeployment));
1545Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationSetDeploymentMetadata));
1604ulong iSlotSize = (ulong)Marshal.SizeOf(typeof(StoreOperationMetadataProperty));
1608Marshal.DestroyStructure(
1613Marshal.FreeCoTaskMem(rgItems);
1623int iSlotSize = Marshal.SizeOf(typeof(StoreOperationMetadataProperty));
1624IntPtr retval = Marshal.AllocCoTaskMem(iSlotSize * Props.Length);
1628Marshal.StructureToPtr(
1655Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationSetCanonicalizationContext));
1687Size = (UInt32)Marshal.SizeOf(typeof(StoreOperationScavenge));
2154Marshal.Copy(b.BlobData, retval, 0, (int)b.Size);
2451Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationStageComponent));
2454Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationStageComponentFile));
2457Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationPinDeployment));
2460Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationUninstallDeployment));
2463Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationUnpinDeployment));
2466Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationInstallDeployment));
2469Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationSetCanonicalizationContext));
2472Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationSetDeploymentMetadata));
2475Marshal.DestroyStructure(op.Data.DataPtr, typeof(StoreOperationScavenge));
2482Marshal.FreeCoTaskMem(op.Data.DataPtr);
2513txnList[i].Data.DataPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(o));
2514Marshal.StructureToPtr(o, txnList[i].Data.DataPtr, false);
2743IntPtr p = Marshal.AllocCoTaskMem(Marshal.SizeOf(this));
2744Marshal.StructureToPtr(this, p, false);
2751Marshal.DestroyStructure(p, typeof(CreateActContextParametersSource));
2752Marshal.FreeCoTaskMem(p);
2789IntPtr p = Marshal.AllocCoTaskMem(Marshal.SizeOf(this));
2790Marshal.StructureToPtr(this, p, false);
2797Marshal.DestroyStructure(p, typeof(CreateActContextParametersSourceDefinitionAppid));
2798Marshal.FreeCoTaskMem(p);
2809Parameters.Size = (UInt32)Marshal.SizeOf(typeof(CreateActContextParameters));
2817SourceInfo.Size = (UInt32)Marshal.SizeOf(typeof(CreateActContextParametersSource));
2822DefAppIdSource.Size = (UInt32)Marshal.SizeOf(typeof(CreateActContextParametersSourceDefinitionAppid));
system\security\principal\windowsidentity.cs (33)
175uint dwLength = (uint) Marshal.SizeOf(typeof(uint));
178if (Marshal.GetLastWin32Error() == Win32Native.ERROR_INVALID_HANDLE)
188throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error()));
317pLogonSessionData.Initialize((uint)Marshal.SizeOf(typeof(Win32Native.SECURITY_LOGON_SESSION_DATA)));
320return Marshal.PtrToStringUni(logonSessionData.AuthenticationPackage.Buffer);
415throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error()));
423throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error()));
574pGroups.ReadArray((uint)Marshal.OffsetOf(typeof(Win32Native.TOKEN_GROUPS), "Groups").ToInt32(),
868hr = GetHRForWin32Error(Marshal.GetLastWin32Error());
889Contract.Assert(information.ByteLength >= (ulong)Marshal.SizeOf(typeof(T)),
940uint dwLength = (uint) Marshal.SizeOf(typeof(uint));
946int dwErrorCode = Marshal.GetLastWin32Error();
965throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error()));
1054throw new SecurityException(Win32Native.GetMessage(Marshal.GetLastWin32Error()));
1072Contract.Assert(Marshal.SizeOf(typeof(Win32Native.KERB_S4U_LOGON)) % IntPtr.Size == 0, "Potential allignment issue setting up S4U logon buffer");
1073uint logonInfoSize = (uint) (Marshal.SizeOf(typeof(Win32Native.KERB_S4U_LOGON)) + upnBytes.Length);
1082ulong upnOffset = (ulong)Marshal.SizeOf(typeof(Win32Native.KERB_S4U_LOGON));
1333int count = Marshal.ReadInt32(safeAllocHandle.DangerousGetHandle());
1334IntPtr pSidAndAttributes = new IntPtr((long)safeAllocHandle.DangerousGetHandle() + (long)Marshal.OffsetOf(typeof(Win32Native.TOKEN_GROUPS), "Groups"));
1339Win32Native.SID_AND_ATTRIBUTES group = (Win32Native.SID_AND_ATTRIBUTES)Marshal.PtrToStructure(pSidAndAttributes, typeof(Win32Native.SID_AND_ATTRIBUTES));
1383Win32Native.TOKEN_PRIMARY_GROUP primaryGroup = (Win32Native.TOKEN_PRIMARY_GROUP)Marshal.PtrToStructure(safeAllocHandlePrimaryGroup.DangerousGetHandle(), typeof(Win32Native.TOKEN_PRIMARY_GROUP));
1391int count = Marshal.ReadInt32(safeAllocHandle.DangerousGetHandle());
1392IntPtr pSidAndAttributes = new IntPtr((long)safeAllocHandle.DangerousGetHandle() + (long)Marshal.OffsetOf(typeof(Win32Native.TOKEN_GROUPS), "Groups"));
1395Win32Native.SID_AND_ATTRIBUTES group = (Win32Native.SID_AND_ATTRIBUTES)Marshal.PtrToStructure(pSidAndAttributes, typeof(Win32Native.SID_AND_ATTRIBUTES));
1445Win32Native.SID_AND_ATTRIBUTES user = (Win32Native.SID_AND_ATTRIBUTES)Marshal.PtrToStructure(safeAllocHandle.DangerousGetHandle(), typeof(Win32Native.SID_AND_ATTRIBUTES));
1479Win32Native.CLAIM_SECURITY_ATTRIBUTES_INFORMATION claimAttributes = (Win32Native.CLAIM_SECURITY_ATTRIBUTES_INFORMATION)Marshal.PtrToStructure(safeAllocHandle.DangerousGetHandle(), typeof(Win32Native.CLAIM_SECURITY_ATTRIBUTES_INFORMATION));
1489Win32Native.CLAIM_SECURITY_ATTRIBUTE_V1 windowsClaim = (Win32Native.CLAIM_SECURITY_ATTRIBUTE_V1)Marshal.PtrToStructure(pAttribute, typeof(Win32Native.CLAIM_SECURITY_ATTRIBUTE_V1));
1496Marshal.Copy(windowsClaim.Values.ppString, stringPointers, 0, (int)windowsClaim.ValueCount);
1500instanceClaims.Add( new Claim(windowsClaim.Name, Marshal.PtrToStringAuto(stringPointers[item]), ClaimValueTypes.String, m_issuerName, m_issuerName, this, propertyValue, string.Empty));
1506Marshal.Copy(windowsClaim.Values.pInt64, intValues, 0, (int)windowsClaim.ValueCount);
1517Marshal.Copy(windowsClaim.Values.pUint64, uintValues, 0, (int)windowsClaim.ValueCount);
1527Marshal.Copy(windowsClaim.Values.pUint64, boolValues, 0, (int)windowsClaim.ValueCount);
1556offset += Marshal.SizeOf(windowsClaim);
system\stubhelpers.cs (25)
30byte[] buffer = new byte[(str.Length + 1) * Marshal.SystemMaxDBCSCharSize];
41int cbAllocLength = (1 + 1) * Marshal.SystemMaxDBCSCharSize;
74if (pbNativeBuffer != null || Marshal.SystemMaxDBCSCharSize == 1)
80nb = (strManaged.Length + 1) * Marshal.SystemMaxDBCSCharSize;
87pbNativeBuffer = (byte*)Marshal.AllocCoTaskMem(nb + 1);
102pbNativeBuffer = (byte*)Marshal.AllocCoTaskMem(nb + 2);
163pbNativeBuffer = (byte*)Marshal.AllocCoTaskMem(nb + 1);
381int nbytes = sizeof(uint) + ((cch + 1) * Marshal.SystemMaxDBCSCharSize);
383pNative = (byte*)Marshal.AllocCoTaskMem(nbytes);
556Marshal.ThrowExceptionForHR(hrCreate, new IntPtr(-1));
581Marshal.ThrowExceptionForHR(hrCreate, new IntPtr(-1));
706newItemsIP = Marshal.GetComInterfaceForObject(newItems, typeof(IBindableVector));
708oldItemsIP = Marshal.GetComInterfaceForObject(oldItems, typeof(IBindableVector));
715Marshal.Release(oldItemsIP);
717Marshal.Release(newItemsIP);
1117pNativeHome = Marshal.AllocCoTaskMem(allocSize);
1150int allocSize = (pManagedHome.Capacity * Marshal.SystemMaxDBCSCharSize) + 4;
1151pNativeHome = Marshal.AllocCoTaskMem(allocSize);
1187pNativeHome = Marshal.AllocCoTaskMem(allocSize);
1218int allocSize = Marshal.SizeOfHelper(pManagedHome.GetType(), false);
1219IntPtr pNativeHome = Marshal.AllocCoTaskMem(allocSize);
1329Marshal.DestroyStructure(pNativeHome, layoutType);
1347return Marshal.GetComInterfaceForObject(impl, typeof(IReference<T>));
1447Marshal.ThrowExceptionForHR(hrCreate, new IntPtr(-1));
1539return Marshal.GetComInterfaceForObject(impl, typeof(IKeyValuePair<K, V>));
Core\CSharp\System\Windows\DataObject.cs (32)
726Marshal.ThrowExceptionForHR(NativeMethods.E_NOTIMPL);
845medium.unionmember = Marshal.GetComInterfaceForObject(istream, typeof(IStream));
846Marshal.ReleaseComObject(istream);
852Marshal.Release(medium.unionmember);
873Marshal.ThrowExceptionForHR(hr);
893Marshal.ThrowExceptionForHR(DV_E_TYMED);
899Marshal.ThrowExceptionForHR(hr);
962Marshal.ThrowExceptionForHR(NativeMethods.E_NOTIMPL);
1174int win32Error = Marshal.GetLastWin32Error();
1195Marshal.ThrowExceptionForHR(hr);
1211int win32Error = Marshal.GetLastWin32Error();
1228int win32Error = Marshal.GetLastWin32Error();
1247int win32Error = Marshal.GetLastWin32Error();
1266int win32Error = Marshal.GetLastWin32Error();
1284int win32Error = Marshal.GetLastWin32Error();
1407int win32Error = Marshal.GetLastWin32Error();
1695int win32Error = Marshal.GetLastWin32Error(); // Dance around FxCop
1875IStream istream = (IStream)( Marshal.GetObjectForIUnknown(medium.unionmember) );
1905Marshal.ReleaseComObject(istream);
2050Marshal.Copy(bytes, 0, ptr, NativeMethods.IntPtrToInt32(size));
2143if (Marshal.SystemDefaultCharSize == 1)
2179Marshal.Copy(structData, 0, currentPtr, structData.Length);
2195Marshal.Copy(new char[] { '\0' }, 0, currentPtr, 1);
2204Marshal.Copy(new char[] { '\0' }, 0, currentPtr, 1);
2260Marshal.Copy(new char[] { '\0' }, 0, (IntPtr)((ulong)ptr + (ulong)chars.Length * 2), 1);
2310Marshal.Copy(new byte[] { 0 }, 0, (IntPtr)((long)ptr + pinvokeSize), 1);
2370Marshal.Copy(new byte[] { 0 }, 0, (IntPtr)((long)pointerUtf8 + utf8ByteCount), 1);
2885Marshal.FreeCoTaskMem(formatetc[formatetcIndex].ptd);
3092pStream = (UnsafeNativeMethods.IStream)Marshal.GetObjectForIUnknown(medium.unionmember);
3390Marshal.Copy(ptr, bytes, 0, size);
3596byte endByte = Marshal.ReadByte((IntPtr)((long)pointerUtf8 + utf8ByteCount));
3610Marshal.Copy(pointerUtf8, bytes, 0, utf8ByteCount);
Core\CSharp\System\Windows\Media\Imaging\PropVariant.cs (40)
170long size = Marshal.SizeOf(type) * length;
177destPtr = Marshal.AllocCoTaskMem((int) size);
198Marshal.FreeCoTaskMem(destPtr);
233destPtr = Marshal.AllocCoTaskMem((int)size);
239pString = Marshal.StringToCoTaskMemAnsi(value[index]);
243pString = Marshal.StringToCoTaskMemUni(value[index]);
245Marshal.WriteIntPtr(destPtr, (int)index*sizeIntPtr, pString);
258IntPtr pString = Marshal.ReadIntPtr(destPtr, i*sizeIntPtr);
259Marshal.FreeCoTaskMem(pString);
262Marshal.FreeCoTaskMem(destPtr);
294pszVal = Marshal.StringToCoTaskMemAnsi(new String(value as char[]));
373pwszVal = Marshal.StringToCoTaskMemUni(value as String);
393pszVal = Marshal.StringToCoTaskMemAnsi(new String(new char[] { (char)value }));
439pclsidVal = Marshal.AllocCoTaskMem(guid.Length);
440Marshal.Copy(guid, 0, pclsidVal, guid.Length);
506UnsafeNativeMethods.MILUnknown.Release(Marshal.ReadIntPtr(punkPtr, (int) (i*sizeIntPtr)));
520Marshal.FreeCoTaskMem(Marshal.ReadIntPtr(strPtr, (int) (i*sizeIntPtr)));
524Marshal.FreeCoTaskMem(ca.pElems);
531Marshal.FreeCoTaskMem(pwszVal);
562array[i] = (sbyte) Marshal.ReadByte(ca.pElems, i);
569Marshal.Copy(ca.pElems, array, 0, (int)ca.cElems);
576Marshal.Copy(ca.pElems, array, 0, (int)ca.cElems);
584array[i] = (ushort) Marshal.ReadInt16(ca.pElems, i*sizeof(ushort));
591Marshal.Copy(ca.pElems, array, 0, (int)ca.cElems);
599array[i] = (uint) Marshal.ReadInt32(ca.pElems, i*sizeof(uint));
606Marshal.Copy(ca.pElems, array, 0, (int)ca.cElems);
614array[i] = (UInt64) Marshal.ReadInt64(ca.pElems, i*sizeof(UInt64));
621Marshal.Copy(ca.pElems, array, 0, (int)ca.cElems);
628Marshal.Copy(ca.pElems, array, 0, (int)ca.cElems);
636array[i] = (bool) (Marshal.ReadInt16(ca.pElems, i*sizeof(ushort)) != 0);
646Marshal.Copy(ca.pElems, guid, i*16, 16);
663IntPtr ptr = Marshal.ReadIntPtr(ca.pElems, i*sizeIntPtr);
664array[i] = Marshal.PtrToStringAnsi(ptr);
680IntPtr ptr = Marshal.ReadIntPtr(ca.pElems, i*sizeIntPtr);
681array[i] = Marshal.PtrToStringUni(ptr);
736Marshal.Copy(pclsidVal, guid, 0, 16);
740return Marshal.PtrToStringAnsi(pszVal);
743return Marshal.PtrToStringUni(pwszVal);
748Marshal.Copy(ca.pElems, blob, 0, (int)ca.cElems);
src\Framework\MS\Internal\Printing\PrintDlgExMarshaler.cs (38)
276NativeMethods.PRINTDLGEX32 pdex = (NativeMethods.PRINTDLGEX32)Marshal.PtrToStructure(
286NativeMethods.PRINTDLGEX64 pdex = (NativeMethods.PRINTDLGEX64)Marshal.PtrToStructure(
302NativeMethods.PRINTPAGERANGE pageRangeStruct = (NativeMethods.PRINTPAGERANGE)Marshal.PtrToStructure(
323NativeMethods.DEVNAMES devNames = (NativeMethods.DEVNAMES)Marshal.PtrToStructure(
326int devNamesOffset = checked(devNames.wDeviceOffset * Marshal.SystemDefaultCharSize);
327printerName = Marshal.PtrToStringAuto(pDevNames + devNamesOffset);
440NativeMethods.DEVMODE devMode = (NativeMethods.DEVMODE)Marshal.PtrToStructure(
444Marshal.Copy(pDevMode, devModeData, 0, devModeData.Length);
500NativeMethods.PRINTDLGEX32 pdex = (NativeMethods.PRINTDLGEX32)Marshal.PtrToStructure(
507NativeMethods.PRINTDLGEX64 pdex = (NativeMethods.PRINTDLGEX64)Marshal.PtrToStructure(
582pdex.lpPageRanges = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NativeMethods.PRINTPAGERANGE)));
588Marshal.StructureToPtr(range, pdex.lpPageRanges, false);
621int cbBufferSize = Marshal.SizeOf(typeof(NativeMethods.PRINTDLGEX32));
622unmanagedBuffer = Marshal.AllocHGlobal(cbBufferSize);
623Marshal.StructureToPtr(pdex, unmanagedBuffer, false);
659pdex.lpPageRanges = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NativeMethods.PRINTPAGERANGE)));
665Marshal.StructureToPtr(range, pdex.lpPageRanges, false);
698int cbBufferSize = Marshal.SizeOf(typeof(NativeMethods.PRINTDLGEX64));
699unmanagedBuffer = Marshal.AllocHGlobal(cbBufferSize);
700Marshal.StructureToPtr(pdex, unmanagedBuffer, false);
749NativeMethods.PRINTDLGEX32 pdex = (NativeMethods.PRINTDLGEX32)Marshal.PtrToStructure(
758NativeMethods.PRINTDLGEX64 pdex = (NativeMethods.PRINTDLGEX64)Marshal.PtrToStructure(
781Marshal.FreeHGlobal(unmanagedBuffer);
798return Marshal.SizeOf(temp) == 8;
830int cbDevNames = checked(((printer.Length + 3) * Marshal.SystemDefaultCharSize) +
831Marshal.SizeOf(typeof(NativeMethods.DEVNAMES)));
832hDevNames = Marshal.AllocHGlobal(cbDevNames);
834ushort baseOffset = (ushort)Marshal.SizeOf(typeof(NativeMethods.DEVNAMES));
844devNames.wDeviceOffset = (ushort)(baseOffset / Marshal.SystemDefaultCharSize);
848Marshal.StructureToPtr(devNames, hDevNames, false);
858checked((IntPtr)((long)offsetName + (printer.Length * Marshal.SystemDefaultCharSize)));
868byte[] nulls = new byte[3 * Marshal.SystemDefaultCharSize];
870Marshal.Copy(
875Marshal.Copy(
938IntPtr hDevMode = Marshal.AllocHGlobal(devModeData.Length);
939Marshal.Copy(devModeData, 0, hDevMode, devModeData.Length);