ReactOS  0.4.13-dev-92-gf251225
misc.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Universal Serial Bus Bulk Driver Library
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: lib/drivers/libusb/misc.cpp
5  * PURPOSE: USB Common Driver Library.
6  * PROGRAMMERS:
7  * Michael Martin (michael.martin@reactos.org)
8  * Johannes Anderwald (johannes.anderwald@reactos.org)
9  */
10 
11 #include "libusb.h"
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 //
17 // driver verifier
18 //
19 IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine;
20 
22 NTAPI
25  PIRP Irp,
26  PVOID Context)
27 {
28  if (Irp->PendingReturned)
29  {
31  }
33 }
34 
36 NTAPI
38 {
39  KEVENT Event;
41 
42  //
43  // initialize event
44  //
46 
47  //
48  // copy irp stack location
49  //
51 
52  //
53  // set completion routine
54  //
56 
57 
58  //
59  // call driver
60  //
62 
63 
64  //
65  // check if pending
66  //
67  if (Status == STATUS_PENDING)
68  {
69  //
70  // wait for the request to finish
71  //
73 
74  //
75  // copy status code
76  //
77  Status = Irp->IoStatus.Status;
78  }
79 
80  //
81  // done
82  //
83  return Status;
84 }
85 
87 NTAPI
90  PBUS_INTERFACE_STANDARD busInterface)
91 {
92  KEVENT Event;
94  PIRP Irp;
96  PIO_STACK_LOCATION Stack;
97 
98  if ((!DeviceObject) || (!busInterface))
99  return STATUS_UNSUCCESSFUL;
100 
102 
104  DeviceObject,
105  NULL,
106  0,
107  NULL,
108  &Event,
109  &IoStatus);
110 
111  if (Irp == NULL)
112  {
114  }
115 
117  Stack->MajorFunction = IRP_MJ_PNP;
119  Stack->Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);
120  Stack->Parameters.QueryInterface.InterfaceType = (LPGUID)&GUID_BUS_INTERFACE_STANDARD;
121  Stack->Parameters.QueryInterface.Version = 1;
122  Stack->Parameters.QueryInterface.Interface = (PINTERFACE)busInterface;
123  Stack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
124  Irp->IoStatus.Status=STATUS_NOT_SUPPORTED ;
125 
127 
128  if (Status == STATUS_PENDING)
129  {
131 
132  Status=IoStatus.Status;
133  }
134 
135  return Status;
136 }
137 
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine
Definition: misc.cpp:19
NTSTATUS NTAPI SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: misc.cpp:37
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
NTSTATUS NTAPI GetBusInterface(PDEVICE_OBJECT DeviceObject, PBUS_INTERFACE_STANDARD busInterface)
Definition: misc.cpp:88
smooth NULL
Definition: ftsmooth.c:416
struct _INTERFACE * PINTERFACE
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_QUERY_INTERFACE
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _BUS_INTERFACE_STANDARD BUS_INTERFACE_STANDARD
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IO_NO_INCREMENT
Definition: iotypes.h:565
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
GUID * LPGUID
Definition: guiddef.h:76