22 #define PENUMERATE_DEFINED
23 typedef struct ENUMERATE_NT4 *PENUMERATE;
24 #include "cbm_driver.h"
76 PENUMERATE enumStruct;
83 DBG_IRQL( < DISPATCH_LEVEL);
84 enumStruct = ExAllocatePoolWithTag(PagedPool,
91 RtlZeroMemory(enumStruct,
sizeof(*enumStruct));
93 enumStruct->Count = 0;
97 DBG_IRQL( == PASSIVE_LEVEL);
98 enumStruct->MaxCount = IoGetConfigurationInformation()->ParallelCount;
104 if (enumStruct->MaxCount > 999)
107 "returned %u, truncating to 999", enumStruct->MaxCount));
109 enumStruct->MaxCount = 999;
114 DBG_IRQL( <= DISPATCH_LEVEL);
115 RtlInitUnicodeString(&enumStruct->DriverPrefix, L
"\\Device\\" DD_PARALLEL_PORT_BASE_NAME_U);
123 enumStruct->DriverNumber.Length = 3*
sizeof(wchar_t);
124 enumStruct->DriverNumber.MaximumLength = 4*
sizeof(wchar_t);
125 enumStruct->DriverNumber.Buffer = ExAllocatePoolWithTag(PagedPool,
130 enumStruct->CompleteDriverName.Length = 0;
131 enumStruct->CompleteDriverName.MaximumLength =
132 enumStruct->DriverPrefix.Length + enumStruct->DriverNumber.Length;
134 enumStruct->CompleteDriverName.Buffer = ExAllocatePoolWithTag(PagedPool,
139 if (enumStruct->DriverNumber.Buffer != NULL
140 && enumStruct->CompleteDriverName.Buffer != NULL)
142 ntStatus = STATUS_SUCCESS;
149 ntStatus = STATUS_INSUFFICIENT_RESOURCES;
162 ntStatus = STATUS_INSUFFICIENT_RESOURCES;
167 *EnumStruct = enumStruct;
169 FUNC_LEAVE_NTSTATUS(ntStatus);
210 ntStatus = STATUS_NO_MORE_ENTRIES;
212 if (EnumStruct->Count < EnumStruct->MaxCount)
216 DBG_IRQL( == PASSIVE_LEVEL);
217 ntStatus = RtlIntegerToUnicodeString(EnumStruct->Count, 10,
218 &EnumStruct->DriverNumber);
220 if (NT_SUCCESS(ntStatus))
224 DBG_IRQL( < DISPATCH_LEVEL);
225 RtlCopyUnicodeString(&EnumStruct->CompleteDriverName, &EnumStruct->DriverPrefix);
226 RtlAppendUnicodeStringToString(&EnumStruct->CompleteDriverName, &EnumStruct->DriverNumber);
228 retDriver = EnumStruct->CompleteDriverName.Buffer;
239 EnumStruct->CompleteDriverName.Buffer[0] = 0;
240 retDriver = EnumStruct->CompleteDriverName.Buffer;
243 *DriverName = retDriver;
245 FUNC_LEAVE_NTSTATUS(ntStatus);
270 DBG_IRQL( == PASSIVE_LEVEL);
274 if (EnumStruct->DriverNumber.Buffer != NULL)
276 DBG_IRQL( < DISPATCH_LEVEL);
277 ExFreePool(EnumStruct->DriverNumber.Buffer);
282 if (EnumStruct->CompleteDriverName.Buffer != NULL)
284 DBG_IRQL( < DISPATCH_LEVEL);
285 ExFreePool(EnumStruct->CompleteDriverName.Buffer);
290 DBG_IRQL( < DISPATCH_LEVEL);
291 ExFreePool(EnumStruct);
309 FUNC_LEAVE_NTSTATUS_CONST(STATUS_SUCCESS);
NTSTATUS ParPortEnumerate(PENUMERATE EnumStruct, PCWSTR *DriverName)
Get next enumerated parallel port driver.
ULONG MaxCount
The maximum number which the functions might return.
ULONG Count
The actual number which the functions just returned.
NTSTATUS ParPortEnumerateOpen(PENUMERATE *EnumStruct)
Start enumeration of the parallel port drivers.
NTSTATUS CbmOpenDeviceRegistryKey(IN PDEVICE_OBJECT a, IN ULONG b, IN ACCESS_MASK c, OUT PHANDLE d)
Stub for a function.
struct ENUMERATE_NT4 * PENUMERATE
pointer to a ENUMERATE_WDM or ENUMERATE_NT4 struct
UNICODE_STRING DriverPrefix
Prefix of the device names to be returned.
VOID ParPortEnumerateClose(PENUMERATE EnumStruct)
Stop enumeration of the parallel port drivers.
UNICODE_STRING DriverNumber
Memory for the number in the device names.
struct ENUMERATE_NT4 ENUMERATE
UNICODE_STRING CompleteDriverName
The complete driver name which will be returned.