// ***Public methods*** public PhysFSFileStream(string FileName, PhysFSFileMode FileMode, ulong BufferSize) { // Open the specified file with the appropriate file access switch(FileMode) { case PhysFSFileMode.Read: pHandle = PhysFS_DLL.PHYSFS_openRead(FileName); break; case PhysFSFileMode.Write: pHandle = PhysFS_DLL.PHYSFS_openWrite(FileName); break; case PhysFSFileMode.Append: pHandle = PhysFS_DLL.PHYSFS_openAppend(FileName); break; default: throw new PhysFSException("Invalid FileMode specified"); } // If handle is null, an error occured, so raise an exception //!!! Does object get created if exception is thrown? if(pHandle == null) throw new PhysFSException(); // Set buffer size, raise an exception if an error occured if(PhysFS_DLL.PHYSFS_setBuffer(pHandle, BufferSize) == 0) throw new PhysFSException(); }
public void* GetPointer() { if (ptr == null) ptr = AllocateMemory(capacity); return ptr; }
public bool Close() { bool r = StormDll.SFileCloseArchive(handle); if (r) handle = null; return r; }
public void Factorization(SparseMatrix A) { TripletArraryData data = ConvertToTripletArrayData(A); int rowCount = A.Rows.Count; int columnCount = A.Columns.Count; int nnz = data.nnz; fixed (int* ri = data.rowIndex, ci = data.colIndex) fixed (double* val = data.values) { switch (SolverType) { case EnumSolver.UmfpackLU: solver = CreateSolverLUUMFPACK(rowCount, nnz, ri, ci, val); break; case EnumSolver.SuperLULU: solver = CreateSolverLUSuperLU(rowCount, rowCount, nnz, ri, ci, val); break; case EnumSolver.CholmodCholesky: solver = CreateSolverCholeskyCHOLMOD(rowCount, rowCount, nnz, nnz, ri, ci, val); break; case EnumSolver.SPQRLeastNormal: solver = CreateSolverQRSuiteSparseQR(rowCount, columnCount, nnz, nnz, ri, ci, val); break; case EnumSolver.SPQRLeastSqure: solver = CreateSolverQRSuiteSparseQR(rowCount, columnCount, nnz, nnz, ri, ci, val); break; } } if (solver == null) throw new Exception("Create Solver Fail"); }
public void OpenPipes() { DWORD selection = 0; myOutPipe = _MPUSBOpen(selection, vid_pid_norm, out_pipe, 0, 0); myInPipe = _MPUSBOpen(selection, vid_pid_norm, in_pipe, 1, 0); }
private void Alloc(int length) { #if WIN32 && PINVOKE void* memoryPointer; if (length < 0) throw new ArgumentOutOfRangeException("length"); memoryPointer = NativeMethods.HeapAlloc(hHeap, NativeMethods.HEAP_GENERATE_EXCEPTIONS, (UIntPtr)length); if (memoryPointer == (void*)NativeMethods.STATUS_NO_MEMORY) throw new OutOfMemoryException(); else if (memoryPointer == (void*)NativeMethods.STATUS_ACCESS_VIOLATION) throw new AccessViolationException(); else { this.memoryPointer = memoryPointer; this.length = length; } #elif GCHANDLE // This seems like a viable alternative method this.buffer = new byte[length]; GC.Collect(); // Force a GC Collection, hoping it will pack the newly-allocated array together with other data in memory. this.gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned); // Once pinned, the buffer will never move. this.memoryPointer = gcHandle.AddrOfPinnedObject().ToPointer(); this.length = length; #else this.memoryPointer = (void*)Marshal.AllocHGlobal(length); this.length = length; #endif }
internal ImageImportDll(MappedImage mappedImage, ImageImportDescriptor* descriptor) { _mappedImage = mappedImage; _descriptor = descriptor; if (_descriptor->OriginalFirstThunk != 0) _lookupTable = _mappedImage.RvaToVa(_descriptor->OriginalFirstThunk); else _lookupTable = _mappedImage.RvaToVa(_descriptor->FirstThunk); if (_lookupTable != null) { int i = 0; if (_mappedImage.Magic == Win32.Pe32Magic) { while (((int*)_lookupTable)[i] != 0) i++; } else if (_mappedImage.Magic == Win32.Pe32PlusMagic) { while (((long*)_lookupTable)[i] != 0) i++; } _count = i; } }
public UnsafeWin32MemoryMap(IntPtr hFile, IntPtr hMapping, void* pData, uint size) { m_fileHandle = hFile.AssumeNotNull(); m_mapHandle = hMapping.AssumeNotNull(); m_pData = FluentAsserts.AssumeNotNull(pData); m_size = size.AssumeGT(0U); }
public void Clear() { FreeMemory(ptr); ptr = null; count = 0; capacity = initialCapacity; }
[System.Security.SecuritySafeCritical] // auto-generated public unsafe UIntPtr(ulong value) { #if WIN32 m_value = (void*)checked((uint)value); #else m_value = (void *)value; #endif }
public void Dispose() { if (_filter != null) { NativeApi.PhRemoveProcessTreeFilter(_filter); _filter = null; } }
private bool Open(string file, uint Prio, uint Flags) { void* h; void** hp = &h; bool r = StormDll.SFileOpenArchive(file, Prio, Flags, hp); handle = h; return r; }
public void Dispose() { if (m_pMemory != null) { Syscall.munmap((IntPtr)m_pMemory,m_size); } m_pMemory = null; GC.SuppressFinalize(this); }
public unsafe IntPtr(int value) { #if BIT64 _value = (void*)(long)value; #else _value = (void*)value; #endif }
public unsafe UIntPtr(ulong value) { #if BIT64 _value = (void*)value; #else _value = (void*)checked((uint)value); #endif }
public unsafe IntPtr(int value) { #if WIN32 m_value = (void *)value; #else m_value = (void *)(long)value; #endif }
public WinFileIO(Array Buffer) { if (gchBuf.IsAllocated) gchBuf.Free(); gchBuf = GCHandle.Alloc(Buffer, GCHandleType.Pinned); IntPtr pAddr = Marshal.UnsafeAddrOfPinnedArrayElement(Buffer, 0); pBuffer = (void*)pAddr.ToPointer(); pHandle = IntPtr.Zero; }
public unsafe IntPtr(long value) { #if BIT64 m_value = (void *)value; #else // !BIT64 (32) m_value = (void *)checked((int)value); #endif }
public unsafe IntPtr(int value) { #if BIT64 m_value = (void *)(long)value; #else // !BIT64 (32) m_value = (void *)value; #endif }
private unsafe UnsafeBuffer(Array buffer, int realLength, bool aligned) { this._buffer = buffer; this._handle = GCHandle.Alloc((object) this._buffer, GCHandleType.Pinned); this._ptr = (void*) this._handle.AddrOfPinnedObject(); if (aligned) this._ptr = (void*) ((ulong) this._ptr + 15UL & 18446744073709551600UL); this._length = realLength; }
[System.Security.SecurityCritical] // auto-generated private unsafe UIntPtr(SerializationInfo info, StreamingContext context) { ulong l = info.GetUInt64("value"); if (Size==4 && l>UInt32.MaxValue) { throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue")); } m_value = (void *)l; }
public unsafe void TestArrayOfPointersToPrimitives() { Bar bar = new Bar(); void*[] array = new void*[1]; int i = 5; array[0] = &i; bar.ArrayOfPrimitivePointers = array; Assert.That(i, Is.EqualTo(*(int*) bar.ArrayOfPrimitivePointers[0])); }
public void CloseProcess() { bool done = CloseHandle(_processPtr); if (!done) { throw new Exception("CloseProcess failed"); } _processPtr = null; }
private IntPtr(SerializationInfo info, StreamingContext context) { long @int = info.GetInt64("value"); if (IntPtr.Size == 4 && (@int > 2147483647L || @int < -2147483648L)) { throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue")); } this.m_value = @int; }
public UIntPtr (ulong value) { if ((value > UInt32.MaxValue) && (UIntPtr.Size < 8)) { throw new OverflowException ( Locale.GetText ("This isn't a 64bits machine.")); } _pointer = (void*) value; }
public CDataStore(byte* buffer, int size) { this.vTable = null; this.Buffer = buffer; this.mBase = 0; this.alloc = -1; this.size = size; this.read = 0; }
private UIntPtr(SerializationInfo info, StreamingContext context) { ulong uInt = info.GetUInt64("value"); if (UIntPtr.Size == 4 && uInt > (ulong)-1) { throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue")); } this.m_value = uInt; }
private unsafe IntPtr(SerializationInfo info, StreamingContext context) { long num = info.GetInt64("value"); if ((Size == 4) && ((num > 0x7fffffffL) || (num < -2147483648L))) { throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue")); } this.m_value = (void*) num; }
unsafe public UIntPtr(ulong value) { if(Size == 4 && value > ((ulong)(UInt32.MaxValue))) { throw new OverflowException(_("Overflow_Pointer")); } value_ = (void *)value; }
public CDataStore(byte* buffer, int size, int read = 0) { vTable = null; Buffer = buffer; mBase = 0; alloc = -1; this.size = size; this.read = read; }
int IMetadataImport.EnumCustomAttributes(ref void *enumHandle, int parent, int attributeType, int *customAttributes, int bufferLength, int *count) => throw new NotImplementedException();
/// <summary> /// Constructor. /// </summary> /// <param name="ptr">Pointer to counter data.</param> public UnsafeAtomicCounter64(void* ptr) { Counter = (long*)ptr; }
int IMetadataImport.CountEnum(void *enumHandle, out int count) => throw new NotImplementedException();
internal static extern void il2cpp_format_stack_trace(IntPtr ex, void *output, int output_size);
int IMetadataImport.EnumInterfaceImpls(ref void *enumHandle, int typeDef, int *interfaceImpls, int bufferLength, int *count) => throw new NotImplementedException();
int IMetadataImport.EnumSignatures(ref void *enumHandle, int *signatureTokens, int bufferLength, int *count) => throw new NotImplementedException();
int IMetadataImport.EnumMembers(ref void *enumHandle, int typeDef, int *memberDefs, int bufferLength, int *count) => throw new NotImplementedException();
int IMetadataImport.EnumTypeRefs(ref void *enumHandle, int *typeRefs, int bufferLength, int *count) => throw new NotImplementedException();
internal static extern unsafe int HeapSize(IntPtr hHeap, int flags, void *block);
internal static extern unsafe bool HeapFree(IntPtr hHeap, int flags, void *block);
int IMetadataImport.EnumUnresolvedMethods(ref void *enumHandle, int *methodDefs, int bufferLength, int *count) => throw new NotImplementedException();
int IMetadataImport.ResetEnum(void *enumHandle, int position) => throw new NotImplementedException();
internal static extern unsafe void *HeapReAlloc(IntPtr hHeap, int flags, void *block, int size);
int IMetadataImport.EnumMethodSemantics(ref void *enumHandle, int methodDef, int *eventsAndProperties, int bufferLength, int *count) => throw new NotImplementedException();
internal static extern void SendResponse(void *pContext);
public unsafe void BindArrayData(void *pData) { _pVertexData = new IntPtr(pData); }
internal static extern void il2cpp_format_exception(IntPtr ex, void *message, int message_size);
void IMetadataImport.CloseEnum(void *enumHandle) => throw new NotImplementedException();
internal static extern void AwaitRequest(out void *pContext);
int IMetadataImport.EnumProperties(ref void *enumHandle, int typeDef, int *properties, int bufferLength, int *count) => throw new NotImplementedException();
/// <summary> /// Constructor. /// </summary> /// <param name="ptr">Pointer to counter data.</param> public UnsafeAtomicCounter32(void* ptr) { Counter = (int*)ptr; }
private void ValidateResult(Vector64 <Int32> op1, Vector64 <Int32> op2, Vector64 <Int32> op3, void *result, [CallerMemberName] string method = "") { Int32[] inArray1 = new Int32[Op1ElementCount]; Int32[] inArray2 = new Int32[Op2ElementCount]; Int32[] inArray3 = new Int32[Op3ElementCount]; Int32[] outArray = new Int32[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As <Int32, byte>(ref inArray1[0]), op1); Unsafe.WriteUnaligned(ref Unsafe.As <Int32, byte>(ref inArray2[0]), op2); Unsafe.WriteUnaligned(ref Unsafe.As <Int32, byte>(ref inArray3[0]), op3); Unsafe.CopyBlockUnaligned(ref Unsafe.As <Int32, byte>(ref outArray[0]), ref Unsafe.AsRef <byte>(result), (uint)Unsafe.SizeOf <Vector64 <Int32> >()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); }
public static unsafe void Call <T, U>(System.IntPtr pfn, void *arg1, ref T arg2, ref U arg3) { // This will be filled in by an IL transform }
public abstract unsafe void ReadnPixels([Flow(FlowDirection.In)] int x, [Flow(FlowDirection.In)] int y, [Flow(FlowDirection.In)] uint width, [Flow(FlowDirection.In)] uint height, [Flow(FlowDirection.In)] PixelFormat format, [Flow(FlowDirection.In)] PixelType type, [Flow(FlowDirection.In)] uint bufSize, [Count(Parameter = "bufSize"), Flow(FlowDirection.Out)] void* data);
private static unsafe partial int Sysctl(int *name, int namelen, void *value, size_t *len);
private static unsafe void LoadOrSaveSurfaceRegion(FileStream fileHandle, Surface surface, PdnRegion region, bool trueForSave) { Rectangle[] scans = region.GetRegionScansReadOnlyInt(); Rectangle regionBounds = region.GetBoundsInt(); Rectangle surfaceBounds = surface.Bounds; int scanCount = 0; void *[] ppvBuffers; uint[] lengths; regionBounds.Intersect(surfaceBounds); long length = (long)regionBounds.Width * (long)regionBounds.Height * (long)ColorBgra.SizeOf; if (scans.Length == 1 && length <= uint.MaxValue && surface.IsContiguousMemoryRegion(regionBounds)) { ppvBuffers = new void *[1]; lengths = new uint[1]; ppvBuffers[0] = surface.GetPointAddressUnchecked(regionBounds.Location); lengths[0] = (uint)length; } else { for (int i = 0; i < scans.Length; ++i) { Rectangle rect = scans[i]; rect.Intersect(surfaceBounds); if (rect.Width != 0 && rect.Height != 0) { scanCount += rect.Height; } } int scanIndex = 0; ppvBuffers = new void *[scanCount]; lengths = new uint[scanCount]; for (int i = 0; i < scans.Length; ++i) { Rectangle rect = scans[i]; rect.Intersect(surfaceBounds); if (rect.Width != 0 && rect.Height != 0) { for (int y = rect.Top; y < rect.Bottom; ++y) { ppvBuffers[scanIndex] = surface.GetPointAddressUnchecked(rect.Left, y); lengths[scanIndex] = (uint)(rect.Width * ColorBgra.SizeOf); ++scanIndex; } } } } if (trueForSave) { FileSystem.WriteToStreamingFileGather(fileHandle, ppvBuffers, lengths); } else { FileSystem.ReadFromStreamScatter(fileHandle, ppvBuffers, lengths); } }
int IMetadataImport.EnumFieldsWithName(ref void *enumHandle, int typeDef, string name, int *fieldDefs, int bufferLength, int *count) => throw new NotImplementedException();
int IMetadataImport.EnumUserStrings(ref void *enumHandle, int *userStrings, int bufferLength, int *count) => throw new NotImplementedException();
int IMetadataImport.EnumParams(ref void *enumHandle, int methodDef, int *paramDefs, int bufferLength, int *count) => throw new NotImplementedException();
public int SetPrivateData([NativeTypeName("const GUID &")] Guid* guid, [NativeTypeName("UINT")] uint DataSize, [NativeTypeName("const void *")] void* pData) { return ((delegate* stdcall<ID3D12GraphicsCommandList2*, Guid*, uint, void*, int>)(lpVtbl[4]))((ID3D12GraphicsCommandList2*)Unsafe.AsPointer(ref this), guid, DataSize, pData); }