mirror of
https://github.com/reactos/reactos.git
synced 2025-05-18 00:31:27 +00:00
[USETUP] Group constant strings together. In EventThread(), use RtlReAllocateHeap() to resize the pnp-event buffer.
svn path=/branches/setup_improvements/; revision=75654
This commit is contained in:
parent
c560342f08
commit
959323902f
1 changed files with 28 additions and 22 deletions
|
@ -46,6 +46,9 @@ InstallDriver(
|
||||||
UNICODE_STRING ImagePathU = RTL_CONSTANT_STRING(L"ImagePath");
|
UNICODE_STRING ImagePathU = RTL_CONSTANT_STRING(L"ImagePath");
|
||||||
UNICODE_STRING StartU = RTL_CONSTANT_STRING(L"Start");
|
UNICODE_STRING StartU = RTL_CONSTANT_STRING(L"Start");
|
||||||
UNICODE_STRING TypeU = RTL_CONSTANT_STRING(L"Type");
|
UNICODE_STRING TypeU = RTL_CONSTANT_STRING(L"Type");
|
||||||
|
UNICODE_STRING UpperFiltersU = RTL_CONSTANT_STRING(L"UpperFilters");
|
||||||
|
PWSTR keyboardClass = L"kbdclass\0";
|
||||||
|
|
||||||
UNICODE_STRING StringU;
|
UNICODE_STRING StringU;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
HANDLE hService;
|
HANDLE hService;
|
||||||
|
@ -55,8 +58,6 @@ InstallDriver(
|
||||||
ULONG Disposition;
|
ULONG Disposition;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
BOOLEAN deviceInstalled = FALSE;
|
BOOLEAN deviceInstalled = FALSE;
|
||||||
UNICODE_STRING UpperFiltersU = RTL_CONSTANT_STRING(L"UpperFilters");
|
|
||||||
PWSTR keyboardClass = L"kbdclass\0";
|
|
||||||
|
|
||||||
/* Check if we know the hardware */
|
/* Check if we know the hardware */
|
||||||
if (!SetupFindFirstLineW(hInf, L"HardwareIdsDatabase", HardwareId, &Context))
|
if (!SetupFindFirstLineW(hInf, L"HardwareIdsDatabase", HardwareId, &Context))
|
||||||
|
@ -206,6 +207,7 @@ InstallDevice(
|
||||||
{
|
{
|
||||||
UNICODE_STRING HardwareIDU = RTL_CONSTANT_STRING(L"HardwareID");
|
UNICODE_STRING HardwareIDU = RTL_CONSTANT_STRING(L"HardwareID");
|
||||||
UNICODE_STRING CompatibleIDsU = RTL_CONSTANT_STRING(L"CompatibleIDs");
|
UNICODE_STRING CompatibleIDsU = RTL_CONSTANT_STRING(L"CompatibleIDs");
|
||||||
|
|
||||||
UNICODE_STRING DeviceIdU;
|
UNICODE_STRING DeviceIdU;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
LPCWSTR HardwareID;
|
LPCWSTR HardwareID;
|
||||||
|
@ -339,14 +341,15 @@ EventThread(IN LPVOID lpParameter)
|
||||||
{
|
{
|
||||||
UNICODE_STRING EnumU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum");
|
UNICODE_STRING EnumU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum");
|
||||||
UNICODE_STRING ServicesU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services");
|
UNICODE_STRING ServicesU = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services");
|
||||||
PPLUGPLAY_EVENT_BLOCK PnpEvent;
|
|
||||||
|
PPLUGPLAY_EVENT_BLOCK PnpEvent, NewPnpEvent;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
ULONG PnpEventSize;
|
ULONG PnpEventSize;
|
||||||
HINF hInf;
|
HINF hInf;
|
||||||
HANDLE hEnum, hServices;
|
HANDLE hEnum, hServices;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
hInf = *(HINF *)lpParameter;
|
hInf = *(HINF*)lpParameter;
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes, &EnumU, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
InitializeObjectAttributes(&ObjectAttributes, &EnumU, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||||
Status = NtOpenKey(&hEnum, KEY_QUERY_VALUE, &ObjectAttributes);
|
Status = NtOpenKey(&hEnum, KEY_QUERY_VALUE, &ObjectAttributes);
|
||||||
|
@ -366,33 +369,31 @@ EventThread(IN LPVOID lpParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
PnpEventSize = 0x1000;
|
PnpEventSize = 0x1000;
|
||||||
PnpEvent = (PPLUGPLAY_EVENT_BLOCK)RtlAllocateHeap(ProcessHeap, 0, PnpEventSize);
|
PnpEvent = RtlAllocateHeap(ProcessHeap, 0, PnpEventSize);
|
||||||
if (PnpEvent == NULL)
|
if (PnpEvent == NULL)
|
||||||
{
|
{
|
||||||
NtClose(hEnum);
|
Status = STATUS_NO_MEMORY;
|
||||||
NtClose(hServices);
|
goto Quit;
|
||||||
return STATUS_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
DPRINT("Calling NtGetPlugPlayEvent()\n");
|
DPRINT("Calling NtGetPlugPlayEvent()\n");
|
||||||
|
|
||||||
/* Wait for the next pnp event */
|
/* Wait for the next PnP event */
|
||||||
Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize);
|
Status = NtGetPlugPlayEvent(0, 0, PnpEvent, PnpEventSize);
|
||||||
|
|
||||||
/* Resize the buffer for the PnP event if it's too small. */
|
/* Resize the buffer for the PnP event if it's too small */
|
||||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||||
{
|
{
|
||||||
PnpEventSize += 0x400;
|
PnpEventSize += 0x400;
|
||||||
RtlFreeHeap(ProcessHeap, 0, PnpEvent);
|
NewPnpEvent = RtlReAllocateHeap(ProcessHeap, 0, PnpEvent, PnpEventSize);
|
||||||
PnpEvent = (PPLUGPLAY_EVENT_BLOCK)RtlAllocateHeap(ProcessHeap, 0, PnpEventSize);
|
if (NewPnpEvent == NULL)
|
||||||
if (PnpEvent == NULL)
|
|
||||||
{
|
{
|
||||||
NtClose(hEnum);
|
Status = STATUS_NO_MEMORY;
|
||||||
NtClose(hServices);
|
goto Quit;
|
||||||
return STATUS_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
PnpEvent = NewPnpEvent;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +403,7 @@ EventThread(IN LPVOID lpParameter)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process the pnp event */
|
/* Process the PnP event */
|
||||||
DPRINT("Received PnP Event\n");
|
DPRINT("Received PnP Event\n");
|
||||||
if (IsEqualIID(&PnpEvent->EventGuid, (REFGUID)&GUID_DEVICE_ENUMERATED))
|
if (IsEqualIID(&PnpEvent->EventGuid, (REFGUID)&GUID_DEVICE_ENUMERATED))
|
||||||
{
|
{
|
||||||
|
@ -414,15 +415,20 @@ EventThread(IN LPVOID lpParameter)
|
||||||
DPRINT("Unknown event\n");
|
DPRINT("Unknown event\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dequeue the current pnp event and signal the next one */
|
/* Dequeue the current PnP event and signal the next one */
|
||||||
NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0);
|
NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlFreeHeap(ProcessHeap, 0, PnpEvent);
|
Status = STATUS_SUCCESS;
|
||||||
NtClose(hEnum);
|
|
||||||
NtClose(hServices);
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
Quit:
|
||||||
|
if (PnpEvent)
|
||||||
|
RtlFreeHeap(ProcessHeap, 0, PnpEvent);
|
||||||
|
|
||||||
|
NtClose(hServices);
|
||||||
|
NtClose(hEnum);
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
|
|
Loading…
Reference in a new issue