Author: ion
Date: Mon Oct 9 01:16:20 2006
New Revision: 24457
URL:
http://svn.reactos.org/svn/reactos?rev=24457&view=rev
Log:
- 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.
Modified:
trunk/reactos/ntoskrnl/io/iomgr/arcname.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/arcname.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/arcname.…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/arcname.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/arcname.c Mon Oct 9 01:16:20 2006
@@ -28,9 +28,9 @@
{
ULONG DeviceNumber = -1;
OBJECT_ATTRIBUTES ObjectAttributes;
+ ANSI_STRING InstallName;
UNICODE_STRING DeviceName;
- WCHAR Buffer[MAX_PATH];
- CHAR AnsiBuffer[MAX_PATH];
+ CHAR Buffer[MAX_PATH];
FILE_BASIC_INFORMATION FileInfo;
NTSTATUS Status;
PCHAR p, q;
@@ -39,29 +39,53 @@
p = strstr(KeLoaderBlock->ArcBootDeviceName, "cdrom");
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 */
- swprintf(Buffer, L"\\Device\\CdRom%lu\\reactos\\ntoskrnl.exe", i);
- RtlInitUnicodeString(&DeviceName, Buffer);
InitializeObjectAttributes(&ObjectAttributes,
&DeviceName,
0,
NULL,
NULL);
Status = ZwQueryAttributesFile(&ObjectAttributes, &FileInfo);
- if (NT_SUCCESS(Status)) DeviceNumber = i;
-
- /* Try to find live CD boot */
- swprintf(Buffer,
- 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;
+
+ /* 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,
+ &DeviceName,
+ 0,
+ NULL,
+ NULL);
+ Status = ZwQueryAttributesFile(&ObjectAttributes, &FileInfo);
+ if (NT_SUCCESS(Status)) DeviceNumber = i;
+
+ /* Free the string */
+ RtlFreeUnicodeString(&DeviceName);
+ }
/* Build the name */
sprintf(p, "cdrom(%lu)", DeviceNumber);
@@ -71,9 +95,9 @@
if (q)
{
q++;
- strcpy(AnsiBuffer, q);
+ strcpy(Buffer, q);
sprintf(p, "cdrom(%lu)", DeviceNumber);
- strcat(p, AnsiBuffer);
+ strcat(p, Buffer);
}
}