ReactOS  0.4.15-dev-3203-gacde1e0
FxUsbDeviceStringContext Struct Reference

#include <fxusbdevice.hpp>

Inheritance diagram for FxUsbDeviceStringContext:
Collaboration diagram for FxUsbDeviceStringContext:

Public Member Functions

 FxUsbDeviceStringContext (__in FX_URB_TYPE FxUrbType)
 
 ~FxUsbDeviceStringContext (VOID)
 
__checkReturn NTSTATUS AllocateUrb (__in USBD_HANDLE USBDHandle)
 
virtual VOID Dispose (VOID)
 
virtual VOID CopyParameters (__in FxRequestBase *Request)
 
VOID SetUrbInfo (__in UCHAR StringIndex, __in USHORT LangID)
 
USBD_STATUS GetUsbdStatus (VOID)
 
_Must_inspect_result_ NTSTATUS AllocateDescriptor (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in size_t BufferSize)
 
- Public Member Functions inherited from FxUsbRequestContext
 FxUsbRequestContext (__in FX_REQUEST_CONTEXT_TYPE Type)
 
VOID SetUsbType (__in WDF_USB_REQUEST_TYPE Type)
 
VOID __inline InitUsbParameters (VOID)
 
- Public Member Functions inherited from FxRequestContext
 FxRequestContext (__in FX_REQUEST_CONTEXT_TYPE Type)
 
virtual ~FxRequestContext (VOID)
 
virtual VOID StoreAndReferenceMemory (__in FxRequestBuffer *Buffer)
 
virtual VOID ReleaseAndRestore (__in FxRequestBase *Request)
 
__inline BOOLEAN IsType (__in FX_REQUEST_CONTEXT_TYPE Type)
 
VOID FormatWriteParams (__in_opt IFxMemory *WriteMemory, __in_opt PWDFMEMORY_OFFSET WriteOffsets)
 
VOID FormatReadParams (__in_opt IFxMemory *ReadMemory, __in_opt PWDFMEMORY_OFFSET ReadOffsets)
 
VOID FormatOtherParams (__in FxInternalIoctlParams *InternalIoctlParams)
 
- Public Member Functions inherited from FxStump
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType)
 
VOID operator delete (__in PVOID pointer)
 
PVOID operator new[] (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID operator delete[] (__in PVOID pointer)
 

Public Attributes

_URB_CONTROL_DESCRIPTOR_REQUEST m_UrbLegacy
 
_URB_CONTROL_DESCRIPTOR_REQUESTm_Urb
 
PUSB_STRING_DESCRIPTOR m_StringDescriptor
 
ULONG m_StringDescriptorLength
 
- Public Attributes inherited from FxUsbRequestContext
WDF_USB_REQUEST_COMPLETION_PARAMS m_UsbParameters
 
UMURB m_UmUrb
 
- Public Attributes inherited from FxRequestContext
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
 
IFxMemorym_RequestMemory
 
FX_REQUEST_CONTEXT_TYPE m_RequestType
 

Private Attributes

USBD_HANDLE m_USBDHandle
 

Additional Inherited Members

- Protected Member Functions inherited from FxRequestContext
VOID __inline InitCompletionParams (VOID)
 
- Protected Member Functions inherited from FxStump
 FxStump (VOID)
 
- Static Protected Member Functions inherited from FxRequestContext
static VOID _StoreAndReferenceMemoryWorker (__in PVOID Tag, __deref_out_opt IFxMemory **PPMemory, __in FxRequestBuffer *Buffer)
 

Detailed Description

Definition at line 93 of file fxusbdevice.hpp.

Constructor & Destructor Documentation

◆ FxUsbDeviceStringContext()

FxUsbDeviceStringContext::FxUsbDeviceStringContext ( __in FX_URB_TYPE  FxUrbType)

Definition at line 145 of file fxusbdevice.cpp.

147  :
149 {
150  m_USBDHandle = NULL;
154 
155  if (FxUrbType == FxUrbTypeLegacy) {
156  m_Urb = &m_UrbLegacy;
158  m_Urb->Hdr.Length = sizeof(*m_Urb);
160  }
161  else {
162  m_Urb = NULL;
163  }
164 }
_URB_CONTROL_DESCRIPTOR_REQUEST m_UrbLegacy
_URB_CONTROL_DESCRIPTOR_REQUEST * m_Urb
#define USB_STRING_DESCRIPTOR_TYPE
Definition: usb100.h:51
struct _URB_HEADER Hdr
Definition: usb.h:341
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
Definition: usb.h:97
#define NULL
Definition: types.h:112
FxUsbRequestContext(__in FX_REQUEST_CONTEXT_TYPE Type)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PUSB_STRING_DESCRIPTOR m_StringDescriptor

◆ ~FxUsbDeviceStringContext()

FxUsbDeviceStringContext::~FxUsbDeviceStringContext ( VOID  )

Definition at line 166 of file fxusbdevice.cpp.

169 {
170  if (m_StringDescriptor != NULL) {
173  }
174 
175  if (m_Urb && (m_Urb != &m_UrbLegacy)){
177  }
178  m_Urb = NULL;
179  m_USBDHandle = NULL;
180 }
_URB_CONTROL_DESCRIPTOR_REQUEST m_UrbLegacy
_URB_CONTROL_DESCRIPTOR_REQUEST * m_Urb
VOID USBD_UrbFree(_In_ USBD_HANDLE USBDHandle, _In_ PURB Urb)
Definition: usbstubum.cpp:33
Definition: usb.h:529
#define NULL
Definition: types.h:112
PUSB_STRING_DESCRIPTOR m_StringDescriptor
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361

Member Function Documentation

◆ AllocateDescriptor()

_Must_inspect_result_ NTSTATUS FxUsbDeviceStringContext::AllocateDescriptor ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in size_t  BufferSize 
)

Definition at line 303 of file fxusbdevice.cpp.

307 {
308  PUSB_STRING_DESCRIPTOR pDescriptor;
309  size_t length;
311 
313  return STATUS_SUCCESS;
314  }
315 
316  length = sizeof(USB_STRING_DESCRIPTOR) - sizeof(pDescriptor->bString[0]) +
317  BufferSize;
318 
319  pDescriptor = (PUSB_STRING_DESCRIPTOR) FxPoolAllocate(
320  FxDriverGlobals,
321  NonPagedPool,
322  length);
323 
324  if (pDescriptor == NULL) {
326  }
327 
328  if (m_StringDescriptor != NULL) {
330  }
331 
332  RtlZeroMemory(pDescriptor, length);
333 
334  m_StringDescriptor = pDescriptor;
335 
337 
338  return status;
339 }
#define RtlSizeTToULong
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
struct _USB_STRING_DESCRIPTOR USB_STRING_DESCRIPTOR
struct _USB_STRING_DESCRIPTOR * PUSB_STRING_DESCRIPTOR
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PUSB_STRING_DESCRIPTOR m_StringDescriptor
#define STATUS_SUCCESS
Definition: shellext.h:65
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
static SERVICE_STATUS status
Definition: service.c:31
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
Definition: ps.c:97

Referenced by FxUsbDevice::FormatStringRequest().

◆ AllocateUrb()

__checkReturn NTSTATUS FxUsbDeviceStringContext::AllocateUrb ( __in USBD_HANDLE  USBDHandle)

Definition at line 184 of file fxusbdevice.cpp.

187 {
189 
190  ASSERT(USBDHandle != NULL);
191  ASSERT(m_Urb == NULL);
192 
193  status = USBD_UrbAllocate(USBDHandle, (PURB*)&m_Urb);
194 
195  if (!NT_SUCCESS(status)) {
196  goto Done;
197  }
198 
199  m_USBDHandle = USBDHandle;
200 
202  m_Urb->Hdr.Length = sizeof(*m_Urb);
204 
205 Done:
206  return status;
207 }
_URB_CONTROL_DESCRIPTOR_REQUEST * m_Urb
LONG NTSTATUS
Definition: precomp.h:26
#define USB_STRING_DESCRIPTOR_TYPE
Definition: usb100.h:51
struct _URB_HEADER Hdr
Definition: usb.h:341
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
Definition: usb.h:97
Definition: usb.h:529
#define NULL
Definition: types.h:112
NTSTATUS USBD_UrbAllocate(_In_ USBD_HANDLE USBDHandle, _Outptr_result_bytebuffer_(sizeof(URB)) PURB *Urb)
Definition: usbstubum.cpp:46
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by FxUsbDevice::FormatStringRequest().

◆ CopyParameters()

VOID FxUsbDeviceStringContext::CopyParameters ( __in FxRequestBase Request)
virtual

Reimplemented from FxUsbRequestContext.

Definition at line 223 of file fxusbdevice.cpp.

226 {
227  //
228  // Make sure we got an even number of bytes and that we got a header
229  //
230  if ((m_StringDescriptor->bLength & 0x1) ||
233  }
234  else if (NT_SUCCESS(Request->GetSubmitFxIrp()->GetStatus())) {
235  //
236  // No matter what, indicate the required size to the caller
237  //
240 
241  if (m_UsbParameters.Parameters.DeviceString.RequiredSize >
243  //
244  // Too much string to fit into the buffer supplied by the client.
245  // Morph the status into a warning. Copy as much as we can.
246  //
251  }
252  else {
253  //
254  // Everything fits, copy it over
255  //
258 
262  }
263  }
264 
266 }
IFxMemory * m_RequestMemory
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
struct _USB_COMMON_DESCRIPTOR USB_COMMON_DESCRIPTOR
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
struct _WDF_USB_REQUEST_COMPLETION_PARAMS::@3659::@3660 DeviceString
virtual VOID CopyParameters(__in FxRequestBase *Request)
union _WDF_USB_REQUEST_COMPLETION_PARAMS::@3659 Parameters
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WDF_USB_REQUEST_COMPLETION_PARAMS m_UsbParameters
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PUSB_STRING_DESCRIPTOR m_StringDescriptor
virtual size_t GetBufferSize(VOID)=0
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159
virtual PVOID GetBuffer(VOID)=0

◆ Dispose()

VOID FxUsbDeviceStringContext::Dispose ( VOID  )
virtual

Reimplemented from FxRequestContext.

Definition at line 210 of file fxusbdevice.cpp.

213 {
214  if (m_Urb && (m_Urb != &m_UrbLegacy)){
216  m_Urb = NULL;
217  m_USBDHandle = NULL;
218  }
219 
220 }
_URB_CONTROL_DESCRIPTOR_REQUEST m_UrbLegacy
_URB_CONTROL_DESCRIPTOR_REQUEST * m_Urb
VOID USBD_UrbFree(_In_ USBD_HANDLE USBDHandle, _In_ PURB Urb)
Definition: usbstubum.cpp:33
Definition: usb.h:529
#define NULL
Definition: types.h:112

◆ GetUsbdStatus()

USBD_STATUS FxUsbDeviceStringContext::GetUsbdStatus ( VOID  )
virtual

Implements FxUsbRequestContext.

Definition at line 294 of file fxusbdevice.cpp.

297 {
298  return m_Urb->Hdr.Status;
299 }
_URB_CONTROL_DESCRIPTOR_REQUEST * m_Urb
struct _URB_HEADER Hdr
Definition: usb.h:341

◆ SetUrbInfo()

VOID FxUsbDeviceStringContext::SetUrbInfo ( __in UCHAR  StringIndex,
__in USHORT  LangID 
)

Definition at line 269 of file fxusbdevice.cpp.

273 {
275 
277 
278 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
281 
284 #elif (FX_CORE_MODE == FX_CORE_USER_MODE)
287 
290 #endif
291 }
_URB_CONTROL_DESCRIPTOR_REQUEST * m_Urb
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR StringIndex
Definition: wdfusb.h:1075
VOID SetUsbType(__in WDF_USB_REQUEST_TYPE Type)
#define ASSERT(a)
Definition: mode.c:44
struct _UMURB_DESCRIPTOR_REQUEST UmUrbDescriptorRequest
Definition: umusb.h:245
#define NULL
Definition: types.h:112
PUSB_STRING_DESCRIPTOR m_StringDescriptor
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075

Referenced by FxUsbDevice::FormatStringRequest().

Member Data Documentation

◆ m_StringDescriptor

PUSB_STRING_DESCRIPTOR FxUsbDeviceStringContext::m_StringDescriptor

◆ m_StringDescriptorLength

ULONG FxUsbDeviceStringContext::m_StringDescriptorLength

Definition at line 152 of file fxusbdevice.hpp.

Referenced by AllocateDescriptor(), FxUsbDeviceStringContext(), and SetUrbInfo().

◆ m_Urb

◆ m_UrbLegacy

◆ m_USBDHandle

USBD_HANDLE FxUsbDeviceStringContext::m_USBDHandle
private

The documentation for this struct was generated from the following files: