public static extern BOOL ReadFile(
     HANDLE hFile,
     byte *lpBuffer,
     DWORD nNumberOfBytesToRead,
     DWORD *lpNumberOfBytesRead,
     OVERLAPPED *lpOverlapped
     );
 public static extern BOOL WriteFile(
     HANDLE hFile,
     byte *lpBuffer,
     DWORD nNumberOfBytesToWrite,
     DWORD *lpNumberOfBytesWritten,
     OVERLAPPED *lpOverlapped
     );
Exemple #3
0
        private void ReceivePacket(byte *ReceiveData, DWORD *ReceiveLength)
        {
            uint ReceiveDelay = 1000;

            DWORD ExpectedReceiveLength = *ReceiveLength;

            OpenPipes();
            _MPUSBRead(myInPipe, (void *)ReceiveData, ExpectedReceiveLength, ReceiveLength, ReceiveDelay);
            ClosePipes();
        }
Exemple #4
0
 // ********************************************************************************
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="def"></param>
 /// <returns></returns>
 /// <created>UPh,25.02.2014</created>
 /// <changed>UPh,25.02.2014</changed>
 // ********************************************************************************
 bool SerializeDWordAttribute(string name, DWORD *value, int def /*= 0*/)
 {
     if (IsReading())
     {
         if (!GetDWordAttribute(name, value))
         {
             *value = def;
         }
         return(true);
     }
     else if (IsWriting())
     {
         WriteDWordAttribute(name, *value);
         return(true);
     }
     return(false);
 }
Exemple #5
0
        // Decode Count DWORDs at Source into (Count * 4) Bytes at Target
        static unsafe void Decode(IntPtr Source, IntPtr Target, UInt32 Count)
        {
            UInt32 I;
            DWORD *S = (DWORD *)Source;
            byte * T = (byte *)Target;

            for (I = 1; I <= Count; I++)
            {
                *T = (byte)(*S & 0xff);
                T++;
                *T = (byte)((*S >> 8) & 0xff);
                T++;
                *T = (byte)((*S >> 16) & 0xff);
                T++;
                *T = (byte)((*S >> 24) & 0xff);
                T++;
                S++;
            }
        }
Exemple #6
0
        // Encode Count bytes at Source into (Count / 4) DWORDs at Target
        static unsafe void Encode(IntPtr Source, IntPtr Target, UInt32 Count)
        {
            UInt32 I;
            byte * S = (byte *)Source;
            DWORD *T = (DWORD *)Target;

            for (I = 1; I <= Count / 4; I++)
            {
                *T = *S;
                S++;
                *T = *T | ((DWORD)(*S) << 8);
                S++;
                *T = *T | ((DWORD)(*S) << 16);
                S++;
                *T = *T | ((DWORD)(*S) << 24);
                S++;
                T++;
            }
        }
 virtual HRESULT STDMETHODCALLTYPE GetHelpContext(
     /* [out] */ DWORD *pdwHelpContext) = 0;
Exemple #8
0
 private static extern DWORD _MPUSBReadInt(void *handle, DWORD *pData, DWORD dwLen, DWORD *pLength, DWORD dwMilliseconds);
Exemple #9
0
 private static extern DWORD _MPUSBWrite(void *handle, void *pData, DWORD dwLen, DWORD *pLength, DWORD dwMilliseconds);
Exemple #10
0
        private DWORD SendReceivePacket(byte *SendData, DWORD SendLength, byte *ReceiveData, DWORD *ReceiveLength)
        {
            uint SendDelay    = 1000;
            uint ReceiveDelay = 1000;

            DWORD SentDataLength;
            DWORD ExpectedReceiveLength = *ReceiveLength;

            OpenPipes();

            if (_MPUSBWrite(myOutPipe, (void *)SendData, SendLength, &SentDataLength, SendDelay) == 1)
            {
                if (_MPUSBRead(myInPipe, (void *)ReceiveData, ExpectedReceiveLength, ReceiveLength, ReceiveDelay) == 1)
                {
                    if (*ReceiveLength == ExpectedReceiveLength)
                    {
                        ClosePipes();
                        return(1);                                  // Success!
                    }
                    else if (*ReceiveLength < ExpectedReceiveLength)
                    {
                        ClosePipes();
                        return(2);                                  // Partially failed, incorrect receive length
                    }
                }
            }
            ClosePipes();
            return(0);             // Operation Failed
        }
Exemple #11
0
 public HRESULT GetChannelMask(
     DWORD *pChannelmask
     )
 => ((delegate * unmanaged[Stdcall] < void *, DWORD *, HRESULT >)_vtbl[19])(Unsafe.AsPointer(ref this), pChannelmask);