Example #1
0
        public static unsafe RawHid FromPointer(void *ptr)
        {
            var result = new RawHid();
            var intPtr = (int *)ptr;

            result.dwSizeHid = intPtr[0];
            result.dwCount   = intPtr[1];
            result.rawData   = new byte[result.ElementSize * result.Count];
            Marshal.Copy(new IntPtr(&intPtr[2]), result.rawData, 0, result.rawData.Length);

            return(result);
        }
Example #2
0
        public static unsafe RawHid FromPointer(void *ptr)
        {
            var result = new RawHid();
            var intPtr = (int *)ptr;

            result.dwSizeHid = intPtr[0];
            result.dwCount   = intPtr[1];
            result.rawData   = new byte[result.ElementSize * result.Count];

            fixed(byte *rawDataPtr = result.rawData)
            {
#if NET45
                Unsafe.CopyBlock(&intPtr[2], rawDataPtr, (uint)result.rawData.Length);
#else
                Buffer.MemoryCopy(&intPtr[2], rawDataPtr, result.rawData.Length, result.rawData.Length);
#endif
            }

            return(result);
        }