Esempio n. 1
0
        /// <Summary>Creates a new overlapped pool.</Summary>
        public OvlK(KUSB_HANDLE UsbHandle, int MaxOverlappedCount, KOVL_POOL_FLAG Flags)
        {
            bool success = AllKFunctions.OvlK_Init(out mHandleStruct, UsbHandle, MaxOverlappedCount, Flags);

            if (!success) throw new Exception(string.Format("{0} failed initializing. ErrorCode={1:X8}h", GetType().Name, Marshal.GetLastWin32Error()));

            Debug.Print("{0} Init: handle 0x{1:X16}", GetType().Name, mHandleStruct.Pointer.ToInt64());
        }
Esempio n. 2
0
        /// <Summary>Initializes a new uni-directional pipe stream.</Summary>
        public StmK(KUSB_HANDLE UsbHandle, byte PipeID, int MaxTransferSize, int MaxPendingTransfers, int MaxPendingIO, ref KSTM_CALLBACK Callbacks, KSTM_FLAG Flags)
        {
            bool success = AllKFunctions.StmK_Init(out mHandleStruct, UsbHandle, PipeID, MaxTransferSize, MaxPendingTransfers, MaxPendingIO, ref Callbacks, Flags);

            if (!success) throw new Exception(string.Format("{0} failed initializing. ErrorCode={1:X8}h", GetType().Name, Marshal.GetLastWin32Error()));

            Debug.Print("{0} Init: handle 0x{1:X16}", GetType().Name, mHandleStruct.Pointer.ToInt64());
        }
Esempio n. 3
0
 /// <Summary>Clones the specified interface handle.</Summary>
 public virtual bool Clone(out KUSB_HANDLE DstInterfaceHandle)
 {
     return driverAPI.Clone(mHandleStruct, out DstInterfaceHandle);
 }
Esempio n. 4
0
 /// <Summary>Retrieves a handle for an associated interface.</Summary>
 public virtual bool GetAssociatedInterface(byte AssociatedInterfaceIndex, out KUSB_HANDLE AssociatedInterfaceHandle)
 {
     return driverAPI.GetAssociatedInterface(mHandleStruct, AssociatedInterfaceIndex, out AssociatedInterfaceHandle);
 }
Esempio n. 5
0
        protected virtual void Dispose(bool disposing)
        {
            if (!mbDisposed)
            {
                if (mHandleStruct.Pointer != IntPtr.Zero)
                {
                    AllKFunctions.UsbK_Free(mHandleStruct);
                    Debug.Print("{0} Dispose: Freed Handle:{1:X16}h Explicit:{2}", GetType().Name, mHandleStruct.Pointer.ToInt64(), disposing);
                }
                else
                    Debug.Print("{0} Dispose: [WARNING] Handle is null", GetType().Name);

                mHandleStruct = new KUSB_HANDLE(IntPtr.Zero);
                mbDisposed = true;
            }
        }
Esempio n. 6
0
 /// <Summary>Retrieves a handle for an associated interface.</Summary>
 public bool GetAssociatedInterface(byte AssociatedInterfaceIndex, out KUSB_HANDLE AssociatedInterfaceHandle)
 {
     return driverAPI.GetAssociatedInterface(handle, AssociatedInterfaceIndex, out AssociatedInterfaceHandle);
 }
Esempio n. 7
0
 /// <Summary>Clones the specified interface handle.</Summary>
 public bool Clone(out KUSB_HANDLE DstInterfaceHandle)
 {
     return driverAPI.Clone(handle, out DstInterfaceHandle);
 }
Esempio n. 8
0
        /// <Summary>Initializes a new uni-directional pipe stream.</Summary>
        public StmK(KUSB_HANDLE UsbHandle, byte PipeID, int MaxTransferSize, int MaxPendingTransfers, int MaxPendingIO, ref KSTM_CALLBACK Callbacks, KSTM_FLAG Flags)
        {
            RuntimeHelpers.PrepareConstrainedRegions();

            try
            {
            }
            finally
            {
                bool success = Functions.StmK_Init(out handle, UsbHandle, PipeID, MaxTransferSize, MaxPendingTransfers, MaxPendingIO, ref Callbacks, Flags);

                if (!success || handle.IsInvalid || handle.IsClosed)
                {
                    handle.SetHandleAsInvalid();
                    int errorCode = Marshal.GetLastWin32Error();
                    throw new Exception(GetType().Name + " failed. ErrorCode=" + errorCode.ToString("X"));
                }
            }
        }
Esempio n. 9
0
        /// <Summary>Creates a new overlapped pool.</Summary>
        public OvlK(KUSB_HANDLE UsbHandle, int MaxOverlappedCount, KOVL_POOL_FLAG Flags)
        {
            RuntimeHelpers.PrepareConstrainedRegions();

            try
            {
            }
            finally
            {
                bool success = Functions.OvlK_Init(out handle, UsbHandle, MaxOverlappedCount, Flags);

                if (!success || handle.IsInvalid || handle.IsClosed)
                {
                    handle.SetHandleAsInvalid();
                    int errorCode = Marshal.GetLastWin32Error();
                    throw new Exception(GetType().Name + " failed. ErrorCode=" + errorCode.ToString("X"));
                }
            }
        }