コード例 #1
0
        // ***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();
        }
コード例 #2
0
        public void* GetPointer()
        {
            if (ptr == null)
                ptr = AllocateMemory(capacity);

            return ptr;
        }
コード例 #3
0
ファイル: StormDll.cs プロジェクト: gaknoia/babbot
 public bool Close()
 {
     bool r = StormDll.SFileCloseArchive(handle);
     if (r)
         handle = null;
     return r;
 }
コード例 #4
0
ファイル: LinearSystemLib.cs プロジェクト: meshdgp/MeshDGP
        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");
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: MemoryBlock.cs プロジェクト: cros107/CrystalBoy
		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
		}
コード例 #7
0
ファイル: ImageImports.cs プロジェクト: RoDaniel/featurehouse
        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;
            }
        }
コード例 #8
0
ファイル: UnsafeWin32MemoryMap.cs プロジェクト: scottwis/tiny
 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);
 }
コード例 #9
0
        public void Clear()
        {
            FreeMemory(ptr);
            ptr = null;

            count = 0;
            capacity = initialCapacity;
        }
コード例 #10
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public unsafe UIntPtr(ulong value)
        {
#if WIN32
            m_value = (void*)checked((uint)value);
#else
            m_value = (void *)value;
#endif
        }
コード例 #11
0
 public void Dispose()
 {
     if (_filter != null)
     {
         NativeApi.PhRemoveProcessTreeFilter(_filter);
         _filter = null;
     }
 }
コード例 #12
0
ファイル: StormDll.cs プロジェクト: icaca/boogiebot
 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;
 }
コード例 #13
0
ファイル: PosixMemoryMap.cs プロジェクト: scottwis/tiny
 public void Dispose()
 {
     if (m_pMemory != null) {
         Syscall.munmap((IntPtr)m_pMemory,m_size);
     }
     m_pMemory = null;
     GC.SuppressFinalize(this);
 }
コード例 #14
0
ファイル: Intptr.cs プロジェクト: huamichaelchen/corert
        public unsafe IntPtr(int value)
        {
#if BIT64
            _value = (void*)(long)value;
#else
            _value = (void*)value;
#endif
        }
コード例 #15
0
ファイル: UIntptr.cs プロジェクト: schellap/corert
        public unsafe UIntPtr(ulong value)
        {
#if BIT64
            _value = (void*)value;
#else
            _value = (void*)checked((uint)value);
#endif
        }
コード例 #16
0
ファイル: IntPtr.cs プロジェクト: destinyclown/coreclr
 public unsafe IntPtr(int value)
 {
     #if WIN32
         m_value = (void *)value;
     #else
         m_value = (void *)(long)value;
     #endif
 }
コード例 #17
0
	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;
	}
コード例 #18
0
ファイル: IntPtr.cs プロジェクト: jashook/coreclr
        public unsafe IntPtr(long value)
        {
#if BIT64
                m_value = (void *)value;
#else // !BIT64 (32)
                m_value = (void *)checked((int)value);
#endif
        }
コード例 #19
0
ファイル: IntPtr.cs プロジェクト: jashook/coreclr
        public unsafe IntPtr(int value)
        {
#if BIT64
                m_value = (void *)(long)value;
#else // !BIT64 (32)
                m_value = (void *)value;
#endif
        }
コード例 #20
0
ファイル: UnsafeBuffer.cs プロジェクト: zloiia/sdrsrc
 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;
 }
コード例 #21
0
        [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;
        }
コード例 #22
0
ファイル: CSharpTemp.Tests.cs プロジェクト: kidleon/CppSharp
 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]));
 }
コード例 #23
0
 public void CloseProcess()
 {
     bool done = CloseHandle(_processPtr);
     if (!done)
     {
         throw new Exception("CloseProcess failed");
     }
     _processPtr = null;
 }
コード例 #24
0
		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;
		}
コード例 #25
0
ファイル: UIntPtr.cs プロジェクト: ItsVeryWindy/mono
		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;
		}
コード例 #26
0
 public CDataStore(byte* buffer, int size)
 {
     this.vTable = null;
     this.Buffer = buffer;
     this.mBase  = 0;
     this.alloc  = -1;
     this.size   = size;
     this.read   = 0;
 }
コード例 #27
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;
		}
コード例 #28
0
ファイル: IntPtr.cs プロジェクト: randomize/VimConfig
 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;
 }
コード例 #29
0
	unsafe public UIntPtr(ulong value)
			{
				if(Size == 4 &&
				   value > ((ulong)(UInt32.MaxValue)))
				{
					throw new OverflowException(_("Overflow_Pointer"));
				}
				value_ = (void *)value;
			}
コード例 #30
0
 public CDataStore(byte* buffer, int size, int read = 0)
 {
     vTable = null;
     Buffer = buffer;
     mBase = 0;
     alloc = -1;
     this.size = size;
     this.read = read;
 }
コード例 #31
0
 int IMetadataImport.EnumCustomAttributes(ref void *enumHandle, int parent, int attributeType, int *customAttributes, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #32
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ptr">Pointer to counter data.</param>
 public UnsafeAtomicCounter64(void* ptr)
 {
     Counter = (long*)ptr;
 }
コード例 #33
0
 int IMetadataImport.CountEnum(void *enumHandle, out int count) => throw new NotImplementedException();
コード例 #34
0
 internal static extern void il2cpp_format_stack_trace(IntPtr ex, void *output, int output_size);
コード例 #35
0
 int IMetadataImport.EnumInterfaceImpls(ref void *enumHandle, int typeDef, int *interfaceImpls, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #36
0
 int IMetadataImport.EnumSignatures(ref void *enumHandle, int *signatureTokens, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #37
0
 int IMetadataImport.EnumMembers(ref void *enumHandle, int typeDef, int *memberDefs, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #38
0
 int IMetadataImport.EnumTypeRefs(ref void *enumHandle, int *typeRefs, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #39
0
ファイル: Memory.cs プロジェクト: Pravin044/TwinCat
 internal static extern unsafe int HeapSize(IntPtr hHeap, int flags, void *block);
コード例 #40
0
ファイル: Memory.cs プロジェクト: Pravin044/TwinCat
 internal static extern unsafe bool HeapFree(IntPtr hHeap, int flags, void *block);
コード例 #41
0
 int IMetadataImport.EnumUnresolvedMethods(ref void *enumHandle, int *methodDefs, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #42
0
 int IMetadataImport.ResetEnum(void *enumHandle, int position) => throw new NotImplementedException();
コード例 #43
0
ファイル: Memory.cs プロジェクト: Pravin044/TwinCat
 internal static extern unsafe void *HeapReAlloc(IntPtr hHeap, int flags, void *block, int size);
コード例 #44
0
 int IMetadataImport.EnumMethodSemantics(ref void *enumHandle, int methodDef, int *eventsAndProperties, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #45
0
 internal static extern void SendResponse(void *pContext);
コード例 #46
0
ファイル: IGL_SlimDX9.cs プロジェクト: wert23239/BizHawk
 public unsafe void BindArrayData(void *pData)
 {
     _pVertexData = new IntPtr(pData);
 }
コード例 #47
0
 internal static extern void il2cpp_format_exception(IntPtr ex, void *message, int message_size);
コード例 #48
0
 void IMetadataImport.CloseEnum(void *enumHandle) => throw new NotImplementedException();
コード例 #49
0
 internal static extern void AwaitRequest(out void *pContext);
コード例 #50
0
 int IMetadataImport.EnumProperties(ref void *enumHandle, int typeDef, int *properties, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #51
0
 /// <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);
        }
コード例 #53
0
 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
 }
コード例 #54
0
 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);
コード例 #55
0
 private static unsafe partial int Sysctl(int *name, int namelen, void *value, size_t *len);
コード例 #56
0
        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);
            }
        }
コード例 #57
0
 int IMetadataImport.EnumFieldsWithName(ref void *enumHandle, int typeDef, string name, int *fieldDefs, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #58
0
 int IMetadataImport.EnumUserStrings(ref void *enumHandle, int *userStrings, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #59
0
 int IMetadataImport.EnumParams(ref void *enumHandle, int methodDef, int *paramDefs, int bufferLength, int *count) => throw new NotImplementedException();
コード例 #60
0
 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);
 }