mirror of
https://github.com/reactos/reactos.git
synced 2025-07-09 17:17:53 +00:00
- Optimize IopApplyRosCdromArcHack by not searching for the second copy of ntoskrnl if we already found the first.
- Also optimize stack usage by only using an ANSI buffer instead of having another Unicode buffer and unicode strings. Saves 530 bytes of stack. svn path=/trunk/; revision=24457
This commit is contained in:
parent
5e214ceaa0
commit
b5f79593de
1 changed files with 44 additions and 20 deletions
|
@ -28,9 +28,9 @@ IopApplyRosCdromArcHack(IN ULONG i)
|
||||||
{
|
{
|
||||||
ULONG DeviceNumber = -1;
|
ULONG DeviceNumber = -1;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
ANSI_STRING InstallName;
|
||||||
UNICODE_STRING DeviceName;
|
UNICODE_STRING DeviceName;
|
||||||
WCHAR Buffer[MAX_PATH];
|
CHAR Buffer[MAX_PATH];
|
||||||
CHAR AnsiBuffer[MAX_PATH];
|
|
||||||
FILE_BASIC_INFORMATION FileInfo;
|
FILE_BASIC_INFORMATION FileInfo;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PCHAR p, q;
|
PCHAR p, q;
|
||||||
|
@ -39,9 +39,42 @@ IopApplyRosCdromArcHack(IN ULONG i)
|
||||||
p = strstr(KeLoaderBlock->ArcBootDeviceName, "cdrom");
|
p = strstr(KeLoaderBlock->ArcBootDeviceName, "cdrom");
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
|
/* Build installer name */
|
||||||
|
sprintf(Buffer, "\\Device\\CdRom%lu\\reactos\\ntoskrnl.exe", i);
|
||||||
|
RtlInitAnsiString(&InstallName, Buffer);
|
||||||
|
Status = RtlAnsiStringToUnicodeString(&DeviceName, &InstallName, TRUE);
|
||||||
|
if (!NT_SUCCESS(Status)) return FALSE;
|
||||||
|
|
||||||
/* Try to find the installer */
|
/* Try to find the installer */
|
||||||
swprintf(Buffer, L"\\Device\\CdRom%lu\\reactos\\ntoskrnl.exe", i);
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
RtlInitUnicodeString(&DeviceName, Buffer);
|
&DeviceName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = ZwQueryAttributesFile(&ObjectAttributes, &FileInfo);
|
||||||
|
|
||||||
|
/* Free the string */
|
||||||
|
RtlFreeUnicodeString(&DeviceName);
|
||||||
|
|
||||||
|
/* Check if we found the file */
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* We did, save the device number */
|
||||||
|
DeviceNumber = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Build live CD kernel name */
|
||||||
|
sprintf(Buffer,
|
||||||
|
"\\Device\\CdRom%lu\\reactos\\system32\\ntoskrnl.exe",
|
||||||
|
i);
|
||||||
|
RtlInitAnsiString(&InstallName, Buffer);
|
||||||
|
Status = RtlAnsiStringToUnicodeString(&DeviceName,
|
||||||
|
&InstallName,
|
||||||
|
TRUE);
|
||||||
|
if (!NT_SUCCESS(Status)) return FALSE;
|
||||||
|
|
||||||
|
/* Try to find it */
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&DeviceName,
|
&DeviceName,
|
||||||
0,
|
0,
|
||||||
|
@ -50,18 +83,9 @@ IopApplyRosCdromArcHack(IN ULONG i)
|
||||||
Status = ZwQueryAttributesFile(&ObjectAttributes, &FileInfo);
|
Status = ZwQueryAttributesFile(&ObjectAttributes, &FileInfo);
|
||||||
if (NT_SUCCESS(Status)) DeviceNumber = i;
|
if (NT_SUCCESS(Status)) DeviceNumber = i;
|
||||||
|
|
||||||
/* Try to find live CD boot */
|
/* Free the string */
|
||||||
swprintf(Buffer,
|
RtlFreeUnicodeString(&DeviceName);
|
||||||
L"\\Device\\CdRom%lu\\reactos\\system32\\ntoskrnl.exe",
|
}
|
||||||
i);
|
|
||||||
RtlInitUnicodeString(&DeviceName, Buffer);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&DeviceName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
Status = ZwQueryAttributesFile(&ObjectAttributes, &FileInfo);
|
|
||||||
if (NT_SUCCESS(Status)) DeviceNumber = i;
|
|
||||||
|
|
||||||
/* Build the name */
|
/* Build the name */
|
||||||
sprintf(p, "cdrom(%lu)", DeviceNumber);
|
sprintf(p, "cdrom(%lu)", DeviceNumber);
|
||||||
|
@ -71,9 +95,9 @@ IopApplyRosCdromArcHack(IN ULONG i)
|
||||||
if (q)
|
if (q)
|
||||||
{
|
{
|
||||||
q++;
|
q++;
|
||||||
strcpy(AnsiBuffer, q);
|
strcpy(Buffer, q);
|
||||||
sprintf(p, "cdrom(%lu)", DeviceNumber);
|
sprintf(p, "cdrom(%lu)", DeviceNumber);
|
||||||
strcat(p, AnsiBuffer);
|
strcat(p, Buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue