ReactOS  0.4.15-dev-5112-g22d8c0f
misc.c File Reference
#include "serenum.h"
#include <debug.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

NTSTATUS SerenumInitMultiSzString (OUT PUNICODE_STRING Destination,...)
 
NTSTATUS NTAPI ForwardIrpToLowerDeviceAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI ForwardIrpToAttachedFdoAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI ForwardIrpAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS DuplicateUnicodeString (IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
 

Function Documentation

◆ DuplicateUnicodeString()

NTSTATUS DuplicateUnicodeString ( IN ULONG  Flags,
IN PCUNICODE_STRING  SourceString,
OUT PUNICODE_STRING  DestinationString 
)

Definition at line 141 of file misc.c.

145 {
150  {
152  }
153 
154 
155  if ((SourceString->Length == 0)
158  {
162  }
163  else
164  {
165  USHORT DestMaxLength = SourceString->Length;
166 
168  DestMaxLength += sizeof(UNICODE_NULL);
169 
171  if (DestinationString->Buffer == NULL)
172  return STATUS_NO_MEMORY;
173 
176  DestinationString->MaximumLength = DestMaxLength;
177 
180  }
181 
182  return STATUS_SUCCESS;
183 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
unsigned short Length
Definition: sprintf.c:451
#define SERENUM_TAG
Definition: serenum.h:58
void * Buffer
Definition: sprintf.c:453
#define UNICODE_NULL
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1895
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1895
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
unsigned short MaximumLength
Definition: sprintf.c:452

◆ ForwardIrpAndForget()

NTSTATUS NTAPI ForwardIrpAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 126 of file misc.c.

129 {
130  PDEVICE_OBJECT LowerDevice;
131 
132  ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
133  LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
134  ASSERT(LowerDevice);
135 
137  return IoCallDriver(LowerDevice, Irp);
138 }
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define ASSERT(a)
Definition: mode.c:44
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

◆ ForwardIrpToAttachedFdoAndForget()

NTSTATUS NTAPI ForwardIrpToAttachedFdoAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 108 of file misc.c.

111 {
112  PPDO_DEVICE_EXTENSION DeviceExtension;
114 
115  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
116  ASSERT(!DeviceExtension->Common.IsFDO);
117 
118  Fdo = DeviceExtension->AttachedFdo;
119  ASSERT(Fdo);
120  TRACE_(SERENUM, "Calling attached Fdo 0x%p\n", Fdo);
122  return IoCallDriver(Fdo, Irp);
123 }
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:59
#define TRACE_(x)
Definition: compat.h:76
PDEVICE_OBJECT AttachedFdo
Definition: parport.h:59
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by IrpStub(), and SerenumPdoPnp().

◆ ForwardIrpToLowerDeviceAndForget()

NTSTATUS NTAPI ForwardIrpToLowerDeviceAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 90 of file misc.c.

93 {
94  PFDO_DEVICE_EXTENSION DeviceExtension;
95  PDEVICE_OBJECT LowerDevice;
96 
97  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
98  ASSERT(DeviceExtension->Common.IsFDO);
99 
100  LowerDevice = DeviceExtension->LowerDevice;
101  ASSERT(LowerDevice);
102  TRACE_(SERENUM, "Calling lower device 0x%p\n", LowerDevice);
104  return IoCallDriver(LowerDevice, Irp);
105 }
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_(x)
Definition: compat.h:76
#define ASSERT(a)
Definition: mode.c:44
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:84
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130

Referenced by IrpStub().

◆ SerenumInitMultiSzString()

NTSTATUS SerenumInitMultiSzString ( OUT PUNICODE_STRING  Destination,
  ... 
)

Definition at line 18 of file misc.c.

21 {
22  va_list args;
23  PCSZ Source;
26  ULONG DestinationSize = 0;
28 
30 
31  /* Calculate length needed for destination unicode string */
33  Source = va_arg(args, PCSZ);
34  while (Source != NULL)
35  {
37  DestinationSize += RtlAnsiStringToUnicodeSize(&AnsiString)
38  + sizeof(WCHAR) /* final NULL */;
39  Source = va_arg(args, PCSZ);
40  }
41  va_end(args);
42  if (DestinationSize == 0)
43  {
45  return STATUS_SUCCESS;
46  }
47 
48  /* Initialize destination string */
49  DestinationSize += sizeof(WCHAR); // final NULL
51  if (!Destination->Buffer)
53  Destination->Length = 0;
54  Destination->MaximumLength = (USHORT)DestinationSize;
55 
56  /* Copy arguments to destination string */
57  /* Use a temporary unicode string, which buffer is shared with
58  * destination string, to copy arguments */
60  UnicodeString.MaximumLength = Destination->MaximumLength;
63  Source = va_arg(args, PCSZ);
64  while (Source != NULL)
65  {
68  if (!NT_SUCCESS(Status))
69  {
71  break;
72  }
73  Destination->Length += UnicodeString.Length + sizeof(WCHAR);
74  UnicodeString.MaximumLength -= UnicodeString.Length + sizeof(WCHAR);
75  UnicodeString.Buffer += UnicodeString.Length / sizeof(WCHAR) + 1;
76  UnicodeString.Length = 0;
77  Source = va_arg(args, PCSZ);
78  }
79  va_end(args);
80  if (NT_SUCCESS(Status))
81  {
82  /* Finish multi-sz string */
83  Destination->Buffer[Destination->Length / sizeof(WCHAR)] = L'\0';
84  Destination->Length += sizeof(WCHAR);
85  }
86  return Status;
87 }
CONST char * PCSZ
Definition: umtypes.h:125
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define args
Definition: format.c:66
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
#define SERENUM_TAG
Definition: serenum.h:58
Definition: match.c:390
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define L(x)
Definition: ntvdm.h:50
#define va_end(ap)
Definition: acmsvcex.h:90
#define FALSE
Definition: types.h:117
NTSYSAPI DWORD WINAPI RtlAnsiStringToUnicodeSize(const STRING *)
char * va_list
Definition: acmsvcex.h:78
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2977
va_start(ap, x)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define va_arg(ap, T)
Definition: acmsvcex.h:89
unsigned short USHORT
Definition: pedump.c:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_SUCCESS
Definition: shellext.h:65
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by SerenumDetectLegacyDevice().