ReactOS 0.4.16-dev-122-g325d74c
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
172 return STATUS_NO_MEMORY;
173
176 DestinationString->MaximumLength = DestMaxLength;
177
180 }
181
182 return STATUS_SUCCESS;
183}
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
Definition: green.h:16
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1922
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1921
#define UNICODE_NULL
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
unsigned short USHORT
Definition: pedump.c:61
#define SERENUM_TAG
Definition: serenum.h:58
#define STATUS_SUCCESS
Definition: shellext.h:65
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
unsigned short MaximumLength
Definition: sprintf.c:452
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ 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}
_In_ PIRP Irp
Definition: csq.h:116
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define ASSERT(a)
Definition: mode.c:44
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

◆ 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}
#define TRACE_(x)
Definition: compat.h:76
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:59
PDEVICE_OBJECT AttachedFdo
Definition: parport.h:59
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461

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}
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:84

Referenced by IrpStub().

◆ SerenumInitMultiSzString()

NTSTATUS SerenumInitMultiSzString ( OUT PUNICODE_STRING  Destination,
  ... 
)

Definition at line 18 of file misc.c.

21{
26 ULONG DestinationSize = 0;
28
30
31 /* Calculate length needed for destination unicode string */
34 while (Source != NULL)
35 {
37 DestinationSize += RtlAnsiStringToUnicodeSize(&AnsiString)
38 + sizeof(WCHAR) /* final NULL */;
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)
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 */
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;
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}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
@ AnsiString
Definition: dnslib.h:19
Status
Definition: gdiplustypes.h:25
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3016
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define RtlAnsiStringToUnicodeSize(STRING)
Definition: nt_native.h:404
#define L(x)
Definition: ntvdm.h:50
#define args
Definition: format.c:66
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: match.c:390
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
CONST char * PCSZ
Definition: umtypes.h:125

Referenced by SerenumDetectLegacyDevice().