예제 #1
0
 public unsafe void Dispose()
 {
     Clear();
     if (Data != null)
     {
         NativeUtility.Free(Data);
         Data       = null;
         DataLength = 0;
     }
 }
예제 #2
0
            //private void Viewport_UpdateBegin( Viewport viewport )
            //{
            //	//generator?.PerformUpdate();
            //}

            void Shutdown()
            {
                if (imageData != IntPtr.Zero)
                {
                    NativeUtility.Free(imageData);
                    imageData = IntPtr.Zero;
                }

                texture?.Dispose();
                texture  = null;
                viewport = null;
                textureRead?.Dispose();
                textureRead = null;
            }
예제 #3
0
        public unsafe void Add(ref T item)
        {
            if (Count == DataLength)
            {
                T * oldData   = Data;
                int oldLength = DataLength;

                DataLength = oldLength != 0 ? oldLength * 2 : 4;
                Data       = (T *)NativeUtility.Alloc(NativeUtility.MemoryAllocationType.Utility, DataLength * sizeof(T));
                NativeUtility.CopyMemory(Data, oldData, Count * sizeof(T));

                NativeUtility.Free(oldData);
            }
            Data[Count++] = item;
        }
예제 #4
0
 static void ReleaseHandle(IntPtr usedRef)
 {
     NativeUtility.Free(usedRef);
 }
예제 #5
0
        public override string[] GetNativeModuleNames()
        {
            //copy from WindowsPlatformFunctionality

            string[] result;

            unsafe
            {
                try
                {
                    uint needBytes;
                    if (EnumProcessModules(Process.GetCurrentProcess().Handle,
                                           null, 0, &needBytes))
                    {
                        int     count = (int)needBytes / (int)sizeof(IntPtr);
                        IntPtr *array = (IntPtr *)NativeUtility.Alloc(NativeUtility.MemoryAllocationType.Utility, (int)needBytes).ToPointer();

                        uint needBytes2;
                        if (EnumProcessModules(Process.GetCurrentProcess().Handle,
                                               array, needBytes, &needBytes2))
                        {
                            if (needBytes2 < needBytes)
                            {
                                count = (int)needBytes2 / (int)sizeof(IntPtr);
                            }

                            result = new string[count];

                            StringBuilder stringBuilder = new StringBuilder(2048);

                            for (int n = 0; n < count; n++)
                            {
                                stringBuilder.Length = 0;
                                GetModuleFileNameEx(Process.GetCurrentProcess().Handle,
                                                    array[n], stringBuilder, (uint)stringBuilder.Capacity);

                                result[n] = stringBuilder.ToString();
                            }
                        }
                        else
                        {
                            result = new string[0];
                        }

                        NativeUtility.Free((IntPtr)array);
                    }
                    else
                    {
                        result = new string[0];
                    }
                }
                catch
                {
                    result = new string[0];
                }
            }

            return(result);


            //// it seems it works, but it's cross-platform?
            //var wp = new WindowsPlatformFunctionality();
            //return wp.GetNativeModuleNames();
        }