ReactOS  0.4.14-dev-50-g13bb5e2
ioctl.c File Reference
#include "usbport.h"
#include <debug.h>
Include dependency graph for ioctl.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI USBPORT_UserGetHcName (IN PDEVICE_OBJECT FdoDevice, IN PUSBUSER_CONTROLLER_UNICODE_NAME ControllerName, IN PUSB_UNICODE_NAME UnicodeName)
 
NTSTATUS NTAPI USBPORT_GetSymbolicName (IN PDEVICE_OBJECT RootHubPdo, IN PUNICODE_STRING DestinationString)
 
VOID NTAPI USBPORT_UserGetRootHubName (IN PDEVICE_OBJECT FdoDevice, IN PUSBUSER_CONTROLLER_UNICODE_NAME RootHubName, IN PUSB_UNICODE_NAME UnicodeName)
 
NTSTATUS NTAPI USBPORT_GetUnicodeName (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PULONG_PTR Information)
 
NTSTATUS NTAPI USBPORT_PdoDeviceControl (IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_PdoInternalDeviceControl (IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_FdoDeviceControl (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_FdoInternalDeviceControl (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file ioctl.c.

Function Documentation

◆ USBPORT_FdoDeviceControl()

NTSTATUS NTAPI USBPORT_FdoDeviceControl ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 396 of file ioctl.c.

398 {
400  PIO_STACK_LOCATION IoStack;
404 
405  DPRINT("USBPORT_FdoDeviceControl: Irp - %p\n", Irp);
406 
407  FdoExtension = FdoDevice->DeviceExtension;
408 
410  ControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
411 
412  switch (ControlCode)
413  {
415  DPRINT("USBPORT_FdoDeviceControl: IOCTL_USB_DIAGNOSTIC_MODE_ON\n");
417  break;
418 
420  DPRINT("USBPORT_FdoDeviceControl: IOCTL_USB_DIAGNOSTIC_MODE_OFF\n");
422  break;
423 
425  DPRINT1("USBPORT_FdoDeviceControl: IOCTL_USB_GET_NODE_INFORMATION\n");
427  break;
428 
430  DPRINT1("USBPORT_FdoDeviceControl: IOCTL_GET_HCD_DRIVERKEY_NAME\n");
432  break;
433 
434  case IOCTL_USB_USER_REQUEST:
435  DPRINT1("USBPORT_FdoDeviceControl: IOCTL_USB_USER_REQUEST UNIMPLEMENTED. FIXME\n");
436  break;
437 
438  default:
439  DPRINT1("USBPORT_FdoDeviceControl: Not supported IoControlCode - %x\n",
440  ControlCode);
442  break;
443  }
444 
445  Irp->IoStatus.Status = Status;
446  Irp->IoStatus.Information = Information;
448 
449  return Status;
450 }
#define IOCTL_GET_HCD_DRIVERKEY_NAME
Definition: usbioctl.h:165
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS NTAPI USBPORT_GetUnicodeName(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PULONG_PTR Information)
Definition: ioctl.c:211
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define USBPORT_FLAG_DIAGNOSTIC_MODE
Definition: usbport.h:76
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
#define IOCTL_USB_DIAGNOSTIC_MODE_OFF
Definition: usbioctl.h:150
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define IOCTL_USB_DIAGNOSTIC_MODE_ON
Definition: usbioctl.h:155
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define IOCTL_USB_GET_NODE_INFORMATION
Definition: usbioctl.h:169
Iosb Information
Definition: create.c:4377

Referenced by USBPORT_Dispatch().

◆ USBPORT_FdoInternalDeviceControl()

NTSTATUS NTAPI USBPORT_FdoInternalDeviceControl ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 454 of file ioctl.c.

456 {
457  DPRINT1("USBPORT_FdoInternalDeviceControl: UNIMPLEMENTED. FIXME. \n");
458  return 0;
459 }
#define DPRINT1
Definition: precomp.h:8

Referenced by USBPORT_Dispatch().

◆ USBPORT_GetSymbolicName()

NTSTATUS NTAPI USBPORT_GetSymbolicName ( IN PDEVICE_OBJECT  RootHubPdo,
IN PUNICODE_STRING  DestinationString 
)

Definition at line 62 of file ioctl.c.

64 {
66  PUNICODE_STRING RootHubName;
67  PWCHAR Buffer;
68  SIZE_T LengthName;
69  SIZE_T Length;
71  WCHAR Character;
72 
73  DPRINT("USBPORT_GetSymbolicName: ... \n");
74 
75  PdoExtension = RootHubPdo->DeviceExtension;
76  RootHubName = &PdoExtension->CommonExtension.SymbolicLinkName;
77  Buffer = RootHubName->Buffer;
78 
79  if (!Buffer)
80  {
81  return STATUS_UNSUCCESSFUL;
82  }
83 
84  LengthName = RootHubName->Length;
85 
87 
88  if (!SourceString)
89  {
92  }
93 
94  RtlZeroMemory(SourceString, LengthName);
95 
96  if (*Buffer == L'\\')
97  {
98  Buffer += 1;
99 
100  if (*Buffer == L'\\')
101  {
102  Buffer += 1;
103  goto Exit;
104  }
105 
106  Character = *Buffer;
107 
108  do
109  {
110  if (Character == UNICODE_NULL)
111  {
112  break;
113  }
114 
115  Buffer += 1;
116  Character = *Buffer;
117  }
118  while (*Buffer != L'\\');
119 
120  if (*Buffer == L'\\')
121  {
122  Buffer += 1;
123  }
124 
125 Exit:
126  Length = (ULONG_PTR)Buffer - (ULONG_PTR)RootHubName->Buffer;
127  }
128  else
129  {
130  Length = 0;
131  }
132 
134  (PVOID)((ULONG_PTR)RootHubName->Buffer + Length),
135  RootHubName->Length - Length);
136 
138 
139  DPRINT("USBPORT_RegisterDeviceInterface: DestinationString - %wZ\n",
141 
142  return STATUS_SUCCESS;
143 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
uint16_t * PWSTR
Definition: typedefs.h:54
uint16_t * PWCHAR
Definition: typedefs.h:54
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define USB_PORT_TAG
Definition: usbport.h:44
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void Exit(void)
Definition: sock.c:1331
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1869
static const WCHAR L[]
Definition: oid.c:1250
ULONG_PTR SIZE_T
Definition: typedefs.h:78
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by USBHI_GetRootHubSymbolicName(), and USBPORT_UserGetRootHubName().

◆ USBPORT_GetUnicodeName()

NTSTATUS NTAPI USBPORT_GetUnicodeName ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp,
IN PULONG_PTR  Information 
)

Definition at line 211 of file ioctl.c.

214 {
215  PUSB_HCD_DRIVERKEY_NAME DriverKey;
216  PIO_STACK_LOCATION IoStack;
219  ULONG Length;
220  PUSBUSER_CONTROLLER_UNICODE_NAME ControllerName;
221  PUSB_UNICODE_NAME UnicodeName;
222  ULONG ActualLength;
223 
224  DPRINT("USBPORT_GetUnicodeName: ... \n");
225 
226  *Information = 0;
227  DriverKey = Irp->AssociatedIrp.SystemBuffer;
228 
230  OutputBufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
231  IoControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
232 
233  if (OutputBufferLength < sizeof(USB_UNICODE_NAME))
234  {
236  }
237 
238  Length = sizeof(USBUSER_CONTROLLER_UNICODE_NAME);
239 
240  while (TRUE)
241  {
242  ControllerName = ExAllocatePoolWithTag(PagedPool,
243  Length,
244  USB_PORT_TAG);
245 
246  if (!ControllerName)
247  {
249  }
250 
251  RtlZeroMemory(ControllerName, Length);
252 
253  ControllerName->Header.RequestBufferLength = Length;
254  UnicodeName = &ControllerName->UnicodeName;
255 
257  {
258  ControllerName->Header.UsbUserRequest = USBUSER_GET_CONTROLLER_DRIVER_KEY;
259  USBPORT_UserGetHcName(FdoDevice, ControllerName, UnicodeName);
260  }
261  else
262  {
263  ControllerName->Header.UsbUserRequest = USBUSER_GET_ROOTHUB_SYMBOLIC_NAME;
264  USBPORT_UserGetRootHubName(FdoDevice, ControllerName, UnicodeName);
265  }
266 
267  if (ControllerName->Header.UsbUserStatusCode != UsbUserBufferTooSmall)
268  {
269  break;
270  }
271 
272  Length = ControllerName->Header.ActualBufferLength;
273 
274  ExFreePoolWithTag(ControllerName, USB_PORT_TAG);
275  }
276 
277  if (ControllerName->Header.UsbUserStatusCode != UsbUserSuccess)
278  {
279  ExFreePoolWithTag(ControllerName, USB_PORT_TAG);
280  return STATUS_UNSUCCESSFUL;
281  }
282 
283  ActualLength = sizeof(ULONG) + ControllerName->UnicodeName.Length;
284 
285  DriverKey->ActualLength = ActualLength;
286 
287  if (OutputBufferLength < ActualLength)
288  {
289  DriverKey->DriverKeyName[0] = UNICODE_NULL;
290  *Information = sizeof(USB_UNICODE_NAME);
291  }
292  else
293  {
294  RtlCopyMemory(DriverKey->DriverKeyName,
295  ControllerName->UnicodeName.String,
296  ControllerName->UnicodeName.Length);
297 
298  *Information = DriverKey->ActualLength;
299  }
300 
301  ExFreePoolWithTag(ControllerName, USB_PORT_TAG);
302 
303  return STATUS_SUCCESS;
304 }
VOID NTAPI USBPORT_UserGetHcName(IN PDEVICE_OBJECT FdoDevice, IN PUSBUSER_CONTROLLER_UNICODE_NAME ControllerName, IN PUSB_UNICODE_NAME UnicodeName)
Definition: ioctl.c:15
VOID NTAPI USBPORT_UserGetRootHubName(IN PDEVICE_OBJECT FdoDevice, IN PUSBUSER_CONTROLLER_UNICODE_NAME RootHubName, IN PUSB_UNICODE_NAME UnicodeName)
Definition: ioctl.c:147
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
#define IOCTL_GET_HCD_DRIVERKEY_NAME
Definition: usbioctl.h:165
_In_ PIRP Irp
Definition: csq.h:116
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1294
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define USB_PORT_TAG
Definition: usbport.h:44
#define UNICODE_NULL
void DPRINT(...)
Definition: polytest.cpp:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
WCHAR DriverKeyName[ANYSIZE_ARRAY]
Definition: usbioctl.h:325
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
Iosb Information
Definition: create.c:4377

Referenced by USBPORT_FdoDeviceControl().

◆ USBPORT_PdoDeviceControl()

NTSTATUS NTAPI USBPORT_PdoDeviceControl ( IN PDEVICE_OBJECT  PdoDevice,
IN PIRP  Irp 
)

Definition at line 308 of file ioctl.c.

310 {
311  DPRINT1("USBPORT_PdoDeviceControl: UNIMPLEMENTED. FIXME. \n");
312  return 0;
313 }
#define DPRINT1
Definition: precomp.h:8

Referenced by USBPORT_Dispatch().

◆ USBPORT_PdoInternalDeviceControl()

NTSTATUS NTAPI USBPORT_PdoInternalDeviceControl ( IN PDEVICE_OBJECT  PdoDevice,
IN PIRP  Irp 
)

Definition at line 317 of file ioctl.c.

319 {
321  PIO_STACK_LOCATION IoStack;
322  ULONG IoCtl;
324 
325  PdoExtension = PdoDevice->DeviceExtension;
327  IoCtl = IoStack->Parameters.DeviceIoControl.IoControlCode;
328 
329  //DPRINT("USBPORT_PdoInternalDeviceControl: PdoDevice - %p, Irp - %p, IoCtl - %x\n",
330  // PdoDevice,
331  // Irp,
332  // IoCtl);
333 
334  if (IoCtl == IOCTL_INTERNAL_USB_SUBMIT_URB)
335  {
336  return USBPORT_HandleSubmitURB(PdoDevice, Irp, URB_FROM_IRP(Irp));
337  }
338 
340  {
341  DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO\n");
342 
343  if (IoStack->Parameters.Others.Argument1)
344  *(PVOID *)IoStack->Parameters.Others.Argument1 = PdoDevice;
345 
346  if (IoStack->Parameters.Others.Argument2)
347  *(PVOID *)IoStack->Parameters.Others.Argument2 = PdoDevice;
348 
350  goto Exit;
351  }
352 
354  {
355  DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_GET_HUB_COUNT\n");
356 
357  if (IoStack->Parameters.Others.Argument1)
358  {
359  ++*(PULONG)IoStack->Parameters.Others.Argument1;
360  }
361 
363  goto Exit;
364  }
365 
366  if (IoCtl == IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE)
367  {
368  DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
369 
370  if (IoStack->Parameters.Others.Argument1)
371  {
372  *(PVOID *)IoStack->Parameters.Others.Argument1 = &PdoExtension->DeviceHandle;
373  }
374 
376  goto Exit;
377  }
378 
379  if (IoCtl == IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION)
380  {
381  DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
382  return USBPORT_IdleNotification(PdoDevice, Irp);
383  }
384 
385  DPRINT("USBPORT_PdoInternalDeviceControl: INVALID INTERNAL DEVICE CONTROL\n");
387 
388 Exit:
389  Irp->IoStatus.Status = Status;
391  return Status;
392 }
#define URB_FROM_IRP(Irp)
Definition: usb.h:85
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
static void Exit(void)
Definition: sock.c:1331
#define IOCTL_INTERNAL_USB_GET_HUB_COUNT
Definition: usbioctl.h:50
#define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
Definition: usbioctl.h:38
NTSTATUS NTAPI USBPORT_HandleSubmitURB(IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: urb.c:791
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
NTSTATUS NTAPI USBPORT_IdleNotification(IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
Definition: power.c:612
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by USBPORT_Dispatch().

◆ USBPORT_UserGetHcName()

VOID NTAPI USBPORT_UserGetHcName ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBUSER_CONTROLLER_UNICODE_NAME  ControllerName,
IN PUSB_UNICODE_NAME  UnicodeName 
)

Definition at line 15 of file ioctl.c.

18 {
20  ULONG Length;
23 
24  DPRINT("USBPORT_UserGetHcName: ... \n");
25 
26  FdoExtension = FdoDevice->DeviceExtension;
27 
28  Length = ControllerName->Header.RequestBufferLength -
29  sizeof(USBUSER_CONTROLLER_UNICODE_NAME);
30 
32 
33  Status = IoGetDeviceProperty(FdoExtension->CommonExtension.LowerPdoDevice,
35  Length,
36  UnicodeName->String,
37  &ResultLength);
38 
39  if (!NT_SUCCESS(Status))
40  {
42  {
43  ControllerName->Header.UsbUserStatusCode = UsbUserBufferTooSmall;
44  }
45  else
46  {
47  ControllerName->Header.UsbUserStatusCode = UsbUserInvalidParameter;
48  }
49  }
50  else
51  {
52  ControllerName->Header.UsbUserStatusCode = UsbUserSuccess;
53  UnicodeName->Length = ResultLength + sizeof(UNICODE_NULL);
54  }
55 
56  ControllerName->Header.ActualBufferLength = sizeof(USBUSER_CONTROLLER_UNICODE_NAME) +
58 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
LONG NTSTATUS
Definition: precomp.h:26
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1294
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define UNICODE_NULL
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4228
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by USBPORT_GetUnicodeName().

◆ USBPORT_UserGetRootHubName()

VOID NTAPI USBPORT_UserGetRootHubName ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBUSER_CONTROLLER_UNICODE_NAME  RootHubName,
IN PUSB_UNICODE_NAME  UnicodeName 
)

Definition at line 147 of file ioctl.c.

150 {
153  ULONG Length;
154  ULONG ResultLength = 0;
156 
157  DPRINT("USBPORT_UserGetRootHubName: ... \n");
158 
159  FdoExtension = FdoDevice->DeviceExtension;
160 
161  Length = RootHubName->Header.RequestBufferLength -
162  sizeof(USBUSER_CONTROLLER_UNICODE_NAME);
163 
165 
167 
168  if (NT_SUCCESS(Status))
169  {
170  ResultLength = UnicodeString.Length;
171 
172  if (UnicodeString.Length > Length)
173  {
174  UnicodeString.Length = Length;
176  }
177 
178  if (UnicodeString.Length)
179  {
180  RtlCopyMemory(UnicodeName->String,
181  UnicodeString.Buffer,
182  UnicodeString.Length);
183  }
184 
186  }
187 
188  if (!NT_SUCCESS(Status))
189  {
191  {
192  RootHubName->Header.UsbUserStatusCode = UsbUserBufferTooSmall;
193  }
194  else
195  {
196  RootHubName->Header.UsbUserStatusCode = UsbUserInvalidParameter;
197  }
198  }
199  else
200  {
201  RootHubName->Header.UsbUserStatusCode = UsbUserSuccess;
202  UnicodeName->Length = ResultLength + sizeof(UNICODE_NULL);
203  }
204 
205  RootHubName->Header.ActualBufferLength = sizeof(USBUSER_CONTROLLER_UNICODE_NAME) +
206  ResultLength;
207 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
LONG NTSTATUS
Definition: precomp.h:26
IN PDCB IN POEM_STRING IN PUNICODE_STRING UnicodeName
Definition: fatprocs.h:1294
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define UNICODE_NULL
NTSTATUS NTAPI USBPORT_GetSymbolicName(IN PDEVICE_OBJECT RootHubPdo, IN PUNICODE_STRING DestinationString)
Definition: ioctl.c:62
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by USBPORT_GetUnicodeName().