mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 14:53:40 +00:00
[FREELDR]
Improve heap allocations by using tags and using the temp heap for all temporary allocations that will not be used by the kernel. This avoids heap fragmentation for the default heap. Increase the temp heap size to 32 MB and limit the size of the cache to the temp heap size minus 128 KB to avoid exhausting the heap with cache data. See CORE-4413. This commit is dedicated to Ronja, my beloved cat who passed away on 5th of December. Rest in peace, little Schnuppel. svn path=/trunk/; revision=61428
This commit is contained in:
parent
56f0833252
commit
eada6279cd
41 changed files with 474 additions and 321 deletions
|
@ -276,7 +276,7 @@ DetectPnpBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST)
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST)
|
||||||
+ sizeof(CM_PNP_BIOS_INSTALLATION_CHECK) + (NodeSize * NodeCount);
|
+ sizeof(CM_PNP_BIOS_INSTALLATION_CHECK) + (NodeSize * NodeCount);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -376,7 +376,7 @@ GetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
sizeof(CM_DISK_GEOMETRY_DEVICE_DATA);
|
sizeof(CM_DISK_GEOMETRY_DEVICE_DATA);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate a full resource descriptor\n");
|
ERR("Failed to allocate a full resource descriptor\n");
|
||||||
|
@ -416,7 +416,7 @@ GetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TRACE("Reading disk geometry failed\n");
|
TRACE("Reading disk geometry failed\n");
|
||||||
MmHeapFree(PartialResourceList);
|
FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
|
TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
|
||||||
|
@ -507,7 +507,7 @@ DetectBiosFloppyPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
|
||||||
|
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
sizeof(CM_FLOPPY_DEVICE_DATA);
|
sizeof(CM_FLOPPY_DEVICE_DATA);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -563,7 +563,7 @@ DetectBiosFloppyController(PCONFIGURATION_COMPONENT_DATA BusKey)
|
||||||
|
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -635,7 +635,7 @@ DetectSystem(VOID)
|
||||||
/* Allocate resource descriptor */
|
/* Allocate resource descriptor */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
|
sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -1036,7 +1036,7 @@ DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey,
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
||||||
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
memset(PartialResourceList, 0, Size);
|
memset(PartialResourceList, 0, Size);
|
||||||
PartialResourceList->Version = 1;
|
PartialResourceList->Version = 1;
|
||||||
PartialResourceList->Revision = 1;
|
PartialResourceList->Revision = 1;
|
||||||
|
@ -1099,7 +1099,7 @@ DetectSerialPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) +
|
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) +
|
||||||
sizeof(CM_SERIAL_DEVICE_DATA);
|
sizeof(CM_SERIAL_DEVICE_DATA);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -1203,7 +1203,7 @@ DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
|
||||||
if (Irq[i] != (ULONG) - 1)
|
if (Irq[i] != (ULONG) - 1)
|
||||||
Size += sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
Size += sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
|
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -1342,7 +1342,7 @@ DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
sizeof(CM_KEYBOARD_DEVICE_DATA);
|
sizeof(CM_KEYBOARD_DEVICE_DATA);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -1395,7 +1395,7 @@ DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -1576,7 +1576,7 @@ DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
|
||||||
{
|
{
|
||||||
TRACE("Detected PS2 port\n");
|
TRACE("Detected PS2 port\n");
|
||||||
|
|
||||||
PartialResourceList = MmHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST));
|
PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST), TAG_HW_RESOURCE_LIST);
|
||||||
memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST));
|
memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST));
|
||||||
|
|
||||||
/* Initialize resource descriptor */
|
/* Initialize resource descriptor */
|
||||||
|
@ -1612,7 +1612,7 @@ DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
|
||||||
/* Initialize resource descriptor */
|
/* Initialize resource descriptor */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
||||||
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
memset(PartialResourceList, 0, Size);
|
memset(PartialResourceList, 0, Size);
|
||||||
PartialResourceList->Version = 1;
|
PartialResourceList->Version = 1;
|
||||||
PartialResourceList->Revision = 1;
|
PartialResourceList->Revision = 1;
|
||||||
|
@ -1695,7 +1695,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
||||||
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
|
|
@ -73,7 +73,8 @@ DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
|
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
PartialResourceList =
|
PartialResourceList =
|
||||||
MmHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
|
FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize,
|
||||||
|
TAG_HW_RESOURCE_LIST);
|
||||||
|
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
if (FindApmBios())
|
if (FindApmBios())
|
||||||
{
|
{
|
||||||
/* Create 'Configuration Data' value */
|
/* Create 'Configuration Data' value */
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
memset(PartialResourceList, 0, Size);
|
memset(PartialResourceList, 0, Size);
|
||||||
PartialResourceList->Version = 0;
|
PartialResourceList->Version = 0;
|
||||||
PartialResourceList->Revision = 0;
|
PartialResourceList->Revision = 0;
|
||||||
|
|
|
@ -48,7 +48,7 @@ static LONG DiskClose(ULONG FileId)
|
||||||
{
|
{
|
||||||
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
|
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
|
||||||
|
|
||||||
MmHeapFree(Context);
|
FrLdrTempFree(Context, TAG_HW_DISK_CONTEXT);
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ static LONG DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
SectorCount = PartitionTableEntry.PartitionSectorCount;
|
SectorCount = PartitionTableEntry.PartitionSectorCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context = MmHeapAlloc(sizeof(DISKCONTEXT));
|
Context = FrLdrTempAlloc(sizeof(DISKCONTEXT), TAG_HW_DISK_CONTEXT);
|
||||||
if (!Context)
|
if (!Context)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
Context->DriveNumber = DriveNumber;
|
Context->DriveNumber = DriveNumber;
|
||||||
|
|
|
@ -120,7 +120,7 @@ DetectPciIrqRoutingTable(PCONFIGURATION_COMPONENT_DATA BusKey)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
|
Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors) +
|
||||||
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + Table->TableSize;
|
2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) + Table->TableSize;
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -178,7 +178,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
{
|
{
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors);
|
Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -216,7 +216,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
PartialDescriptors) +
|
PartialDescriptors) +
|
||||||
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) +
|
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) +
|
||||||
sizeof(PCI_REGISTRY_INFO);
|
sizeof(PCI_REGISTRY_INFO);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (!PartialResourceList)
|
if (!PartialResourceList)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -241,7 +241,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST,
|
Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST,
|
||||||
PartialDescriptors);
|
PartialDescriptors);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (!PartialResourceList)
|
if (!PartialResourceList)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
|
|
@ -48,7 +48,7 @@ GetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
sizeof(CM_DISK_GEOMETRY_DEVICE_DATA);
|
sizeof(CM_DISK_GEOMETRY_DEVICE_DATA);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate a full resource descriptor\n");
|
ERR("Failed to allocate a full resource descriptor\n");
|
||||||
|
@ -82,7 +82,7 @@ GetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERR("Reading disk geometry failed\n");
|
ERR("Reading disk geometry failed\n");
|
||||||
MmHeapFree(PartialResourceList);
|
FrLdrHeapFree(PartialResourceList, TAG_HW_RESOURCE_LIST);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
|
TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
|
||||||
|
@ -114,7 +114,7 @@ DiskClose(ULONG FileId)
|
||||||
{
|
{
|
||||||
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
|
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
|
||||||
|
|
||||||
MmHeapFree(Context);
|
FrLdrTempFree(Context, TAG_HW_DISK_CONTEXT);
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
SectorCount = 0; /* FIXME */
|
SectorCount = 0; /* FIXME */
|
||||||
}
|
}
|
||||||
|
|
||||||
Context = MmHeapAlloc(sizeof(DISKCONTEXT));
|
Context = FrLdrTempAlloc(sizeof(DISKCONTEXT), TAG_HW_DISK_CONTEXT);
|
||||||
if (!Context)
|
if (!Context)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
Context->DriveNumber = DriveNumber;
|
Context->DriveNumber = DriveNumber;
|
||||||
|
@ -338,7 +338,7 @@ DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
|
||||||
GEOMETRY Geometry;
|
GEOMETRY Geometry;
|
||||||
PCONFIGURATION_COMPONENT_DATA DiskKey, ControllerKey;
|
PCONFIGURATION_COMPONENT_DATA DiskKey, ControllerKey;
|
||||||
UCHAR DiskCount;
|
UCHAR DiskCount;
|
||||||
USHORT i;
|
ULONG i;
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
BOOLEAN Changed;
|
BOOLEAN Changed;
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
|
||||||
/* Allocate resource descriptor */
|
/* Allocate resource descriptor */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
|
||||||
sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
|
sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
ERR("Failed to allocate resource descriptor\n");
|
ERR("Failed to allocate resource descriptor\n");
|
||||||
|
@ -463,7 +463,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
|
||||||
/* Set 'Configuration Data' value */
|
/* Set 'Configuration Data' value */
|
||||||
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
|
||||||
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
PartialResourceList = MmHeapAlloc(Size);
|
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
|
||||||
if (PartialResourceList == NULL)
|
if (PartialResourceList == NULL)
|
||||||
{
|
{
|
||||||
TRACE(
|
TRACE(
|
||||||
|
|
|
@ -56,6 +56,8 @@ PVOID KernelMemory = 0;
|
||||||
#define KernelMemorySize (8 * 1024 * 1024)
|
#define KernelMemorySize (8 * 1024 * 1024)
|
||||||
#define XROUNDUP(x,n) ((((ULONG)x) + ((n) - 1)) & (~((n) - 1)))
|
#define XROUNDUP(x,n) ((((ULONG)x) + ((n) - 1)) & (~((n) - 1)))
|
||||||
|
|
||||||
|
#define TAG_MBOOT 'oobM'
|
||||||
|
|
||||||
char reactos_module_strings[64][256]; // Array to hold module names
|
char reactos_module_strings[64][256]; // Array to hold module names
|
||||||
|
|
||||||
/* Load Address of Next Module */
|
/* Load Address of Next Module */
|
||||||
|
@ -462,7 +464,7 @@ FrLdrMapModule(FILE *KernelImage, PCHAR ImageName, PCHAR MemLoadAddr, ULONG Kern
|
||||||
//phnum = ehdr.e_phnum;
|
//phnum = ehdr.e_phnum;
|
||||||
shsize = ehdr.e_shentsize;
|
shsize = ehdr.e_shentsize;
|
||||||
shnum = ehdr.e_shnum;
|
shnum = ehdr.e_shnum;
|
||||||
sptr = (PCHAR)MmHeapAlloc(shnum * shsize);
|
sptr = (PCHAR)FrLdrTempAlloc(shnum * shsize, TAG_MBOOT);
|
||||||
|
|
||||||
/* Read section headers */
|
/* Read section headers */
|
||||||
FsSetFilePointer(KernelImage, ehdr.e_shoff);
|
FsSetFilePointer(KernelImage, ehdr.e_shoff);
|
||||||
|
@ -563,14 +565,14 @@ FrLdrMapModule(FILE *KernelImage, PCHAR ImageName, PCHAR MemLoadAddr, ULONG Kern
|
||||||
|
|
||||||
if (!ELF_SECTION(targetSection)->sh_addr) continue;
|
if (!ELF_SECTION(targetSection)->sh_addr) continue;
|
||||||
|
|
||||||
RelocSection = MmHeapAlloc(shdr->sh_size);
|
RelocSection = FrLdrTempAlloc(shdr->sh_size, TAG_MBOOT);
|
||||||
FsSetFilePointer(KernelImage, relstart);
|
FsSetFilePointer(KernelImage, relstart);
|
||||||
FsReadFile(KernelImage, shdr->sh_size, NULL, RelocSection);
|
FsReadFile(KernelImage, shdr->sh_size, NULL, RelocSection);
|
||||||
|
|
||||||
/* Get the symbol section */
|
/* Get the symbol section */
|
||||||
shdr = ELF_SECTION(shdr->sh_link);
|
shdr = ELF_SECTION(shdr->sh_link);
|
||||||
|
|
||||||
SymbolSection = MmHeapAlloc(shdr->sh_size);
|
SymbolSection = FrLdrTempAlloc(shdr->sh_size, TAG_MBOOT);
|
||||||
FsSetFilePointer(KernelImage, shdr->sh_offset);
|
FsSetFilePointer(KernelImage, shdr->sh_offset);
|
||||||
FsReadFile(KernelImage, shdr->sh_size, NULL, SymbolSection);
|
FsReadFile(KernelImage, shdr->sh_size, NULL, SymbolSection);
|
||||||
|
|
||||||
|
@ -645,11 +647,11 @@ FrLdrMapModule(FILE *KernelImage, PCHAR ImageName, PCHAR MemLoadAddr, ULONG Kern
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(SymbolSection);
|
FrLdrTempFree(SymbolSection, TAG_MBOOT);
|
||||||
MmHeapFree(RelocSection);
|
FrLdrTempFree(RelocSection, TAG_MBOOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(sptr);
|
FrLdrTempFree(sptr, TAG_MBOOT);
|
||||||
|
|
||||||
ModuleData->ModStart = (ULONG)MemLoadAddr;
|
ModuleData->ModStart = (ULONG)MemLoadAddr;
|
||||||
/* Increase the next Load Base */
|
/* Increase the next Load Base */
|
||||||
|
|
|
@ -247,7 +247,7 @@ VOID RunLoader(VOID)
|
||||||
//
|
//
|
||||||
// Create list of display names
|
// Create list of display names
|
||||||
//
|
//
|
||||||
OperatingSystemDisplayNames = MmHeapAlloc(sizeof(PCSTR) * OperatingSystemCount);
|
OperatingSystemDisplayNames = FrLdrTempAlloc(sizeof(PCSTR) * OperatingSystemCount, 'mNSO');
|
||||||
if (!OperatingSystemDisplayNames)
|
if (!OperatingSystemDisplayNames)
|
||||||
{
|
{
|
||||||
goto reboot;
|
goto reboot;
|
||||||
|
|
15
reactos/boot/freeldr/freeldr/cache/blocklist.c
vendored
15
reactos/boot/freeldr/freeldr/cache/blocklist.c
vendored
|
@ -100,7 +100,7 @@ PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNu
|
||||||
// We will need to add the block to the
|
// We will need to add the block to the
|
||||||
// drive's list of cached blocks. So allocate
|
// drive's list of cached blocks. So allocate
|
||||||
// the block memory.
|
// the block memory.
|
||||||
CacheBlock = MmHeapAlloc(sizeof(CACHE_BLOCK));
|
CacheBlock = FrLdrTempAlloc(sizeof(CACHE_BLOCK), TAG_CACHE_BLOCK);
|
||||||
if (CacheBlock == NULL)
|
if (CacheBlock == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -110,18 +110,19 @@ PCACHE_BLOCK CacheInternalAddBlockToCache(PCACHE_DRIVE CacheDrive, ULONG BlockNu
|
||||||
// allocate room for the block data
|
// allocate room for the block data
|
||||||
RtlZeroMemory(CacheBlock, sizeof(CACHE_BLOCK));
|
RtlZeroMemory(CacheBlock, sizeof(CACHE_BLOCK));
|
||||||
CacheBlock->BlockNumber = BlockNumber;
|
CacheBlock->BlockNumber = BlockNumber;
|
||||||
CacheBlock->BlockData = MmHeapAlloc(CacheDrive->BlockSize * CacheDrive->BytesPerSector);
|
CacheBlock->BlockData = FrLdrTempAlloc(CacheDrive->BlockSize * CacheDrive->BytesPerSector,
|
||||||
|
TAG_CACHE_DATA);
|
||||||
if (CacheBlock->BlockData ==NULL)
|
if (CacheBlock->BlockData ==NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(CacheBlock);
|
FrLdrTempFree(CacheBlock, TAG_CACHE_BLOCK);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try to read in the block
|
// Now try to read in the block
|
||||||
if (!MachDiskReadLogicalSectors(CacheDrive->DriveNumber, (BlockNumber * CacheDrive->BlockSize), CacheDrive->BlockSize, (PVOID)DISKREADBUFFER))
|
if (!MachDiskReadLogicalSectors(CacheDrive->DriveNumber, (BlockNumber * CacheDrive->BlockSize), CacheDrive->BlockSize, (PVOID)DISKREADBUFFER))
|
||||||
{
|
{
|
||||||
MmHeapFree(CacheBlock->BlockData);
|
FrLdrTempFree(CacheBlock->BlockData, TAG_CACHE_DATA);
|
||||||
MmHeapFree(CacheBlock);
|
FrLdrTempFree(CacheBlock, TAG_CACHE_BLOCK);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
RtlCopyMemory(CacheBlock->BlockData, (PVOID)DISKREADBUFFER, CacheDrive->BlockSize * CacheDrive->BytesPerSector);
|
RtlCopyMemory(CacheBlock->BlockData, (PVOID)DISKREADBUFFER, CacheDrive->BlockSize * CacheDrive->BytesPerSector);
|
||||||
|
@ -163,8 +164,8 @@ BOOLEAN CacheInternalFreeBlock(PCACHE_DRIVE CacheDrive)
|
||||||
RemoveEntryList(&CacheBlockToFree->ListEntry);
|
RemoveEntryList(&CacheBlockToFree->ListEntry);
|
||||||
|
|
||||||
// Free the block memory and the block structure
|
// Free the block memory and the block structure
|
||||||
MmHeapFree(CacheBlockToFree->BlockData);
|
FrLdrTempFree(CacheBlockToFree->BlockData, TAG_CACHE_DATA);
|
||||||
MmHeapFree(CacheBlockToFree);
|
FrLdrTempFree(CacheBlockToFree, TAG_CACHE_BLOCK);
|
||||||
|
|
||||||
// Update the cache data
|
// Update the cache data
|
||||||
CacheBlockCount--;
|
CacheBlockCount--;
|
||||||
|
|
8
reactos/boot/freeldr/freeldr/cache/cache.c
vendored
8
reactos/boot/freeldr/freeldr/cache/cache.c
vendored
|
@ -72,8 +72,8 @@ BOOLEAN CacheInitializeDrive(UCHAR DriveNumber)
|
||||||
CACHE_BLOCK,
|
CACHE_BLOCK,
|
||||||
ListEntry);
|
ListEntry);
|
||||||
|
|
||||||
MmHeapFree(NextCacheBlock->BlockData);
|
FrLdrTempFree(NextCacheBlock->BlockData, TAG_CACHE_DATA);
|
||||||
MmHeapFree(NextCacheBlock);
|
FrLdrTempFree(NextCacheBlock, TAG_CACHE_BLOCK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ BOOLEAN CacheInitializeDrive(UCHAR DriveNumber)
|
||||||
CacheBlockCount = 0;
|
CacheBlockCount = 0;
|
||||||
CacheSizeLimit = TotalPagesInLookupTable / 8 * MM_PAGE_SIZE;
|
CacheSizeLimit = TotalPagesInLookupTable / 8 * MM_PAGE_SIZE;
|
||||||
CacheSizeCurrent = 0;
|
CacheSizeCurrent = 0;
|
||||||
if (CacheSizeLimit < (64 * 1024))
|
if (CacheSizeLimit > TEMP_HEAP_SIZE - (128 * 1024))
|
||||||
{
|
{
|
||||||
CacheSizeLimit = (64 * 1024);
|
CacheSizeLimit = TEMP_HEAP_SIZE - (128 * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheManagerInitialized = TRUE;
|
CacheManagerInitialized = TRUE;
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
|
|
||||||
#define SCSI_PORT_NEXT_REQUEST_READY 0x0008
|
#define SCSI_PORT_NEXT_REQUEST_READY 0x0008
|
||||||
|
|
||||||
|
#define TAG_SCSI_DEVEXT 'DscS'
|
||||||
|
#define TAG_SCSI_ACCESS_RANGES 'AscS'
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(SCSIPORT);
|
DBG_DEFAULT_CHANNEL(SCSIPORT);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -1097,7 +1100,7 @@ ScsiPortInitialize(
|
||||||
Again = FALSE;
|
Again = FALSE;
|
||||||
|
|
||||||
DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + HwInitializationData->DeviceExtensionSize;
|
DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) + HwInitializationData->DeviceExtensionSize;
|
||||||
DeviceExtension = MmHeapAlloc(DeviceExtensionSize);
|
DeviceExtension = FrLdrTempAlloc(DeviceExtensionSize, TAG_SCSI_DEVEXT);
|
||||||
if (!DeviceExtension)
|
if (!DeviceExtension)
|
||||||
{
|
{
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
@ -1116,15 +1119,16 @@ ScsiPortInitialize(
|
||||||
FirstConfigCall);
|
FirstConfigCall);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
MmHeapFree(DeviceExtension);
|
FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortConfig.NumberOfAccessRanges = HwInitializationData->NumberOfAccessRanges;
|
PortConfig.NumberOfAccessRanges = HwInitializationData->NumberOfAccessRanges;
|
||||||
PortConfig.AccessRanges = MmHeapAlloc(sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges);
|
PortConfig.AccessRanges = FrLdrTempAlloc(sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges,
|
||||||
|
TAG_SCSI_ACCESS_RANGES);
|
||||||
if (!PortConfig.AccessRanges)
|
if (!PortConfig.AccessRanges)
|
||||||
{
|
{
|
||||||
MmHeapFree(DeviceExtension);
|
FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
RtlZeroMemory(PortConfig.AccessRanges, sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges);
|
RtlZeroMemory(PortConfig.AccessRanges, sizeof(ACCESS_RANGE) * HwInitializationData->NumberOfAccessRanges);
|
||||||
|
@ -1151,14 +1155,14 @@ ScsiPortInitialize(
|
||||||
&SlotNumber))
|
&SlotNumber))
|
||||||
{
|
{
|
||||||
/* Continue to the next bus, nothing here */
|
/* Continue to the next bus, nothing here */
|
||||||
MmHeapFree(DeviceExtension);
|
FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
|
||||||
return STATUS_INTERNAL_ERROR;
|
return STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PortConfig.BusInterruptLevel)
|
if (!PortConfig.BusInterruptLevel)
|
||||||
{
|
{
|
||||||
/* Bypass this slot, because no interrupt was assigned */
|
/* Bypass this slot, because no interrupt was assigned */
|
||||||
MmHeapFree(DeviceExtension);
|
FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
|
||||||
return STATUS_INTERNAL_ERROR;
|
return STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1171,7 +1175,7 @@ ScsiPortInitialize(
|
||||||
&PortConfig,
|
&PortConfig,
|
||||||
&Again) != SP_RETURN_FOUND)
|
&Again) != SP_RETURN_FOUND)
|
||||||
{
|
{
|
||||||
MmHeapFree(DeviceExtension);
|
FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
|
||||||
return STATUS_INTERNAL_ERROR;
|
return STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,7 +1193,7 @@ ScsiPortInitialize(
|
||||||
/* Initialize adapter */
|
/* Initialize adapter */
|
||||||
if (!DeviceExtension->HwInitialize(DeviceExtension->MiniPortDeviceExtension))
|
if (!DeviceExtension->HwInitialize(DeviceExtension->MiniPortDeviceExtension))
|
||||||
{
|
{
|
||||||
MmHeapFree(DeviceExtension);
|
FrLdrTempFree(DeviceExtension, TAG_SCSI_DEVEXT);
|
||||||
return STATUS_INTERNAL_ERROR;
|
return STATUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,12 @@ ULONG Ext2GroupCount = 0; // Number of groups
|
||||||
ULONG Ext2InodesPerBlock = 0; // Number of inodes in one block
|
ULONG Ext2InodesPerBlock = 0; // Number of inodes in one block
|
||||||
ULONG Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
|
ULONG Ext2GroupDescPerBlock = 0; // Number of group descriptors in one block
|
||||||
|
|
||||||
|
#define TAG_EXT_BLOCK_LIST 'LtxE'
|
||||||
|
#define TAG_EXT_FILE 'FtxE'
|
||||||
|
#define TAG_EXT_BUFFER 'BtxE'
|
||||||
|
#define TAG_EXT_SUPER_BLOCK 'StxE'
|
||||||
|
#define TAG_EXT_GROUP_DESC 'GtxE'
|
||||||
|
|
||||||
BOOLEAN DiskGetBootVolume(PUCHAR DriveNumber, PULONGLONG StartSector, PULONGLONG SectorCount, int *FsType)
|
BOOLEAN DiskGetBootVolume(PUCHAR DriveNumber, PULONGLONG StartSector, PULONGLONG SectorCount, int *FsType)
|
||||||
{
|
{
|
||||||
*DriveNumber = 0;
|
*DriveNumber = 0;
|
||||||
|
@ -143,7 +149,7 @@ PEXT2_FILE_INFO Ext2OpenFile(PCSTR FileName)
|
||||||
{
|
{
|
||||||
if (TempExt2FileInfo.FileBlockList != NULL)
|
if (TempExt2FileInfo.FileBlockList != NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(TempExt2FileInfo.FileBlockList);
|
FrLdrTempFree(TempExt2FileInfo.FileBlockList, TAG_EXT_BLOCK_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -185,20 +191,20 @@ PEXT2_FILE_INFO Ext2OpenFile(PCSTR FileName)
|
||||||
|
|
||||||
if (TempExt2FileInfo.FileBlockList != NULL)
|
if (TempExt2FileInfo.FileBlockList != NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(TempExt2FileInfo.FileBlockList);
|
FrLdrTempFree(TempExt2FileInfo.FileBlockList, TAG_EXT_BLOCK_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ext2OpenFile(FullPath);
|
return Ext2OpenFile(FullPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileHandle = MmHeapAlloc(sizeof(EXT2_FILE_INFO));
|
FileHandle = FrLdrTempAlloc(sizeof(EXT2_FILE_INFO), TAG_EXT_FILE);
|
||||||
|
|
||||||
if (FileHandle == NULL)
|
if (FileHandle == NULL)
|
||||||
{
|
{
|
||||||
if (TempExt2FileInfo.FileBlockList != NULL)
|
if (TempExt2FileInfo.FileBlockList != NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(TempExt2FileInfo.FileBlockList);
|
FrLdrTempFree(TempExt2FileInfo.FileBlockList, TAG_EXT_BLOCK_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -267,11 +273,11 @@ BOOLEAN Ext2LookupFile(PCSTR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
|
||||||
//
|
//
|
||||||
if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (ULONG)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
|
if (!Ext2SearchDirectoryBufferForFile(DirectoryBuffer, (ULONG)Ext2GetInodeFileSize(&InodeData), PathPart, &DirectoryEntry))
|
||||||
{
|
{
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_EXT_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_EXT_BUFFER);
|
||||||
|
|
||||||
DirectoryInode = DirectoryEntry.inode;
|
DirectoryInode = DirectoryEntry.inode;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +586,7 @@ BOOLEAN Ext2ReadSuperBlock(VOID)
|
||||||
//
|
//
|
||||||
if (Ext2SuperBlock != NULL)
|
if (Ext2SuperBlock != NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(Ext2SuperBlock);
|
FrLdrTempFree(Ext2SuperBlock, TAG_EXT_SUPER_BLOCK);
|
||||||
|
|
||||||
Ext2SuperBlock = NULL;
|
Ext2SuperBlock = NULL;
|
||||||
}
|
}
|
||||||
|
@ -588,7 +594,7 @@ BOOLEAN Ext2ReadSuperBlock(VOID)
|
||||||
//
|
//
|
||||||
// Now allocate the memory to hold the super block
|
// Now allocate the memory to hold the super block
|
||||||
//
|
//
|
||||||
Ext2SuperBlock = (PEXT2_SUPER_BLOCK)MmHeapAlloc(1024);
|
Ext2SuperBlock = (PEXT2_SUPER_BLOCK)FrLdrTempAlloc(1024, TAG_EXT_SUPER_BLOCK);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make sure we got the memory
|
// Make sure we got the memory
|
||||||
|
@ -731,7 +737,7 @@ BOOLEAN Ext2ReadGroupDescriptors(VOID)
|
||||||
//
|
//
|
||||||
if (Ext2GroupDescriptors != NULL)
|
if (Ext2GroupDescriptors != NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(Ext2GroupDescriptors);
|
FrLdrTempFree(Ext2GroupDescriptors, TAG_EXT_GROUP_DESC);
|
||||||
|
|
||||||
Ext2GroupDescriptors = NULL;
|
Ext2GroupDescriptors = NULL;
|
||||||
}
|
}
|
||||||
|
@ -740,7 +746,7 @@ BOOLEAN Ext2ReadGroupDescriptors(VOID)
|
||||||
// Now allocate the memory to hold the group descriptors
|
// Now allocate the memory to hold the group descriptors
|
||||||
//
|
//
|
||||||
GroupDescBlockCount = ROUND_UP(Ext2GroupCount, Ext2GroupDescPerBlock) / Ext2GroupDescPerBlock;
|
GroupDescBlockCount = ROUND_UP(Ext2GroupCount, Ext2GroupDescPerBlock) / Ext2GroupDescPerBlock;
|
||||||
Ext2GroupDescriptors = (PEXT2_GROUP_DESC)MmHeapAlloc(GroupDescBlockCount * Ext2BlockSizeInBytes);
|
Ext2GroupDescriptors = (PEXT2_GROUP_DESC)FrLdrTempAlloc(GroupDescBlockCount * Ext2BlockSizeInBytes, TAG_EXT_GROUP_DESC);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make sure we got the memory
|
// Make sure we got the memory
|
||||||
|
@ -804,14 +810,14 @@ BOOLEAN Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE Inode
|
||||||
// Now allocate the memory to hold the group descriptors
|
// Now allocate the memory to hold the group descriptors
|
||||||
//
|
//
|
||||||
ASSERT(DirectoryFileInfo.FileSize <= 0xFFFFFFFF);
|
ASSERT(DirectoryFileInfo.FileSize <= 0xFFFFFFFF);
|
||||||
*DirectoryBuffer = (PEXT2_DIR_ENTRY)MmHeapAlloc((ULONG)DirectoryFileInfo.FileSize);
|
*DirectoryBuffer = (PEXT2_DIR_ENTRY)FrLdrTempAlloc((ULONG)DirectoryFileInfo.FileSize, TAG_EXT_BUFFER);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make sure we got the memory
|
// Make sure we got the memory
|
||||||
//
|
//
|
||||||
if (*DirectoryBuffer == NULL)
|
if (*DirectoryBuffer == NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(DirectoryFileInfo.FileBlockList);
|
FrLdrTempFree(DirectoryFileInfo.FileBlockList, TAG_EXT_BLOCK_LIST);
|
||||||
FileSystemError("Out of memory.");
|
FileSystemError("Out of memory.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -819,13 +825,13 @@ BOOLEAN Ext2ReadDirectory(ULONG Inode, PVOID* DirectoryBuffer, PEXT2_INODE Inode
|
||||||
// Now read the root directory data
|
// Now read the root directory data
|
||||||
if (!Ext2ReadFileBig(&DirectoryFileInfo, DirectoryFileInfo.FileSize, NULL, *DirectoryBuffer))
|
if (!Ext2ReadFileBig(&DirectoryFileInfo, DirectoryFileInfo.FileSize, NULL, *DirectoryBuffer))
|
||||||
{
|
{
|
||||||
MmHeapFree(*DirectoryBuffer);
|
FrLdrTempFree(*DirectoryBuffer, TAG_EXT_BUFFER);
|
||||||
*DirectoryBuffer = NULL;
|
*DirectoryBuffer = NULL;
|
||||||
MmHeapFree(DirectoryFileInfo.FileBlockList);
|
FrLdrTempFree(DirectoryFileInfo.FileBlockList, TAG_EXT_BLOCK_LIST);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(DirectoryFileInfo.FileBlockList);
|
FrLdrTempFree(DirectoryFileInfo.FileBlockList, TAG_EXT_BLOCK_LIST);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,9 +872,7 @@ BOOLEAN Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Leng
|
||||||
|
|
||||||
TRACE("Ext2ReadPartialBlock() BlockNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", BlockNumber, StartingOffset, Length, Buffer);
|
TRACE("Ext2ReadPartialBlock() BlockNumber = %d StartingOffset = %d Length = %d Buffer = 0x%x\n", BlockNumber, StartingOffset, Length, Buffer);
|
||||||
|
|
||||||
TempBuffer = FrLdrHeapAllocate(FrLdrTempHeap,
|
TempBuffer = FrLdrTempAlloc(Ext2BlockSizeInBytes, TAG_EXT_BUFFER);
|
||||||
Ext2BlockSizeInBytes,
|
|
||||||
'2TXE');
|
|
||||||
|
|
||||||
if (!Ext2ReadBlock(BlockNumber, TempBuffer))
|
if (!Ext2ReadBlock(BlockNumber, TempBuffer))
|
||||||
{
|
{
|
||||||
|
@ -877,7 +881,7 @@ BOOLEAN Ext2ReadPartialBlock(ULONG BlockNumber, ULONG StartingOffset, ULONG Leng
|
||||||
|
|
||||||
memcpy(Buffer, ((PUCHAR)TempBuffer + StartingOffset), Length);
|
memcpy(Buffer, ((PUCHAR)TempBuffer + StartingOffset), Length);
|
||||||
|
|
||||||
FrLdrHeapFree(FrLdrTempHeap, TempBuffer, '2TXE');
|
FrLdrTempFree(TempBuffer, TAG_EXT_BUFFER);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +1033,7 @@ ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||||
BlockCount = (ULONG)(FileSize / Ext2BlockSizeInBytes);
|
BlockCount = (ULONG)(FileSize / Ext2BlockSizeInBytes);
|
||||||
|
|
||||||
// Allocate the memory for the block list
|
// Allocate the memory for the block list
|
||||||
BlockList = MmHeapAlloc(BlockCount * sizeof(ULONG));
|
BlockList = FrLdrTempAlloc(BlockCount * sizeof(ULONG), TAG_EXT_BLOCK_LIST);
|
||||||
if (BlockList == NULL)
|
if (BlockList == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1050,7 +1054,7 @@ ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||||
{
|
{
|
||||||
if (!Ext2CopyIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount, Inode->blocks.indir_block))
|
if (!Ext2CopyIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount, Inode->blocks.indir_block))
|
||||||
{
|
{
|
||||||
MmHeapFree(BlockList);
|
FrLdrTempFree(BlockList, TAG_EXT_BLOCK_LIST);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1060,7 +1064,7 @@ ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||||
{
|
{
|
||||||
if (!Ext2CopyDoubleIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount, Inode->blocks.double_indir_block))
|
if (!Ext2CopyDoubleIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount, Inode->blocks.double_indir_block))
|
||||||
{
|
{
|
||||||
MmHeapFree(BlockList);
|
FrLdrTempFree(BlockList, TAG_EXT_BLOCK_LIST);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1070,7 +1074,7 @@ ULONG* Ext2ReadBlockPointerList(PEXT2_INODE Inode)
|
||||||
{
|
{
|
||||||
if (!Ext2CopyTripleIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount, Inode->blocks.tripple_indir_block))
|
if (!Ext2CopyTripleIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount, Inode->blocks.tripple_indir_block))
|
||||||
{
|
{
|
||||||
MmHeapFree(BlockList);
|
FrLdrTempFree(BlockList, TAG_EXT_BLOCK_LIST);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1100,9 +1104,7 @@ BOOLEAN Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInLis
|
||||||
|
|
||||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
||||||
|
|
||||||
BlockBuffer = FrLdrHeapAllocate(FrLdrTempHeap,
|
BlockBuffer = FrLdrTempAlloc(Ext2BlockSizeInBytes, TAG_EXT_BUFFER);
|
||||||
Ext2BlockSizeInBytes,
|
|
||||||
'2TXE');
|
|
||||||
if (!BlockBuffer)
|
if (!BlockBuffer)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1119,7 +1121,7 @@ BOOLEAN Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInLis
|
||||||
(*CurrentBlockInList)++;
|
(*CurrentBlockInList)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrLdrHeapFree(FrLdrTempHeap, BlockBuffer, '2TXE');
|
FrLdrTempFree(BlockBuffer, TAG_EXT_BUFFER);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1136,7 @@ BOOLEAN Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBloc
|
||||||
|
|
||||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
||||||
|
|
||||||
BlockBuffer = (ULONG*)MmHeapAlloc(Ext2BlockSizeInBytes);
|
BlockBuffer = (ULONG*)FrLdrTempAlloc(Ext2BlockSizeInBytes, TAG_EXT_BUFFER);
|
||||||
if (BlockBuffer == NULL)
|
if (BlockBuffer == NULL)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1142,7 +1144,7 @@ BOOLEAN Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBloc
|
||||||
|
|
||||||
if (!Ext2ReadBlock(DoubleIndirectBlock, BlockBuffer))
|
if (!Ext2ReadBlock(DoubleIndirectBlock, BlockBuffer))
|
||||||
{
|
{
|
||||||
MmHeapFree(BlockBuffer);
|
FrLdrTempFree(BlockBuffer, TAG_EXT_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,12 +1152,12 @@ BOOLEAN Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBloc
|
||||||
{
|
{
|
||||||
if (!Ext2CopyIndirectBlockPointers(BlockList, CurrentBlockInList, BlockCount, BlockBuffer[CurrentBlock]))
|
if (!Ext2CopyIndirectBlockPointers(BlockList, CurrentBlockInList, BlockCount, BlockBuffer[CurrentBlock]))
|
||||||
{
|
{
|
||||||
MmHeapFree(BlockBuffer);
|
FrLdrTempFree(BlockBuffer, TAG_EXT_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(BlockBuffer);
|
FrLdrTempFree(BlockBuffer, TAG_EXT_BUFFER);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,7 +1171,7 @@ BOOLEAN Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBloc
|
||||||
|
|
||||||
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
BlockPointersPerBlock = Ext2BlockSizeInBytes / sizeof(ULONG);
|
||||||
|
|
||||||
BlockBuffer = (ULONG*)MmHeapAlloc(Ext2BlockSizeInBytes);
|
BlockBuffer = (ULONG*)FrLdrTempAlloc(Ext2BlockSizeInBytes, TAG_EXT_BUFFER);
|
||||||
if (BlockBuffer == NULL)
|
if (BlockBuffer == NULL)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1177,7 +1179,7 @@ BOOLEAN Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBloc
|
||||||
|
|
||||||
if (!Ext2ReadBlock(TripleIndirectBlock, BlockBuffer))
|
if (!Ext2ReadBlock(TripleIndirectBlock, BlockBuffer))
|
||||||
{
|
{
|
||||||
MmHeapFree(BlockBuffer);
|
FrLdrTempFree(BlockBuffer, TAG_EXT_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1185,12 +1187,12 @@ BOOLEAN Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBloc
|
||||||
{
|
{
|
||||||
if (!Ext2CopyDoubleIndirectBlockPointers(BlockList, CurrentBlockInList, BlockCount, BlockBuffer[CurrentBlock]))
|
if (!Ext2CopyDoubleIndirectBlockPointers(BlockList, CurrentBlockInList, BlockCount, BlockBuffer[CurrentBlock]))
|
||||||
{
|
{
|
||||||
MmHeapFree(BlockBuffer);
|
FrLdrTempFree(BlockBuffer, TAG_EXT_BUFFER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(BlockBuffer);
|
FrLdrTempFree(BlockBuffer, TAG_EXT_BUFFER);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,7 +1200,7 @@ LONG Ext2Close(ULONG FileId)
|
||||||
{
|
{
|
||||||
PEXT2_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
|
PEXT2_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
|
||||||
|
|
||||||
MmHeapFree(FileHandle);
|
FrLdrTempFree(FileHandle, TAG_EXT_FILE);
|
||||||
|
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,11 @@ BOOLEAN FatReadClusterChain(PFAT_VOLUME_INFO Volume, ULONG StartClusterNumber
|
||||||
BOOLEAN FatReadPartialCluster(PFAT_VOLUME_INFO Volume, ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer);
|
BOOLEAN FatReadPartialCluster(PFAT_VOLUME_INFO Volume, ULONG ClusterNumber, ULONG StartingOffset, ULONG Length, PVOID Buffer);
|
||||||
BOOLEAN FatReadVolumeSectors(PFAT_VOLUME_INFO Volume, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
|
BOOLEAN FatReadVolumeSectors(PFAT_VOLUME_INFO Volume, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
|
||||||
|
|
||||||
|
#define TAG_FAT_CHAIN 'CtaT'
|
||||||
|
#define TAG_FAT_FILE 'FtaF'
|
||||||
|
#define TAG_FAT_VOLUME 'VtaF'
|
||||||
|
#define TAG_FAT_BUFFER 'BtaF'
|
||||||
|
|
||||||
typedef struct _FAT_VOLUME_INFO
|
typedef struct _FAT_VOLUME_INFO
|
||||||
{
|
{
|
||||||
ULONG BytesPerSector; /* Number of bytes per sector */
|
ULONG BytesPerSector; /* Number of bytes per sector */
|
||||||
|
@ -431,7 +436,8 @@ PVOID FatBufferDirectory(PFAT_VOLUME_INFO Volume, ULONG DirectoryStartCluster, U
|
||||||
// Attempt to allocate memory for directory buffer
|
// Attempt to allocate memory for directory buffer
|
||||||
//
|
//
|
||||||
TRACE("Trying to allocate (DirectorySize) %d bytes.\n", *DirectorySize);
|
TRACE("Trying to allocate (DirectorySize) %d bytes.\n", *DirectorySize);
|
||||||
DirectoryBuffer = MmHeapAlloc(*DirectorySize + sizeof(DIRECTORY_BUFFER));
|
DirectoryBuffer = FrLdrTempAlloc(*DirectorySize + sizeof(DIRECTORY_BUFFER),
|
||||||
|
TAG_FAT_BUFFER);
|
||||||
|
|
||||||
if (DirectoryBuffer == NULL)
|
if (DirectoryBuffer == NULL)
|
||||||
{
|
{
|
||||||
|
@ -445,7 +451,7 @@ PVOID FatBufferDirectory(PFAT_VOLUME_INFO Volume, ULONG DirectoryStartCluster, U
|
||||||
{
|
{
|
||||||
if (!FatReadVolumeSectors(Volume, Volume->RootDirSectorStart, Volume->RootDirSectors, DirectoryBuffer->Data))
|
if (!FatReadVolumeSectors(Volume, Volume->RootDirSectorStart, Volume->RootDirSectors, DirectoryBuffer->Data))
|
||||||
{
|
{
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_FAT_BUFFER);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,7 +459,7 @@ PVOID FatBufferDirectory(PFAT_VOLUME_INFO Volume, ULONG DirectoryStartCluster, U
|
||||||
{
|
{
|
||||||
if (!FatReadClusterChain(Volume, DirectoryStartCluster, 0xFFFFFFFF, DirectoryBuffer->Data))
|
if (!FatReadClusterChain(Volume, DirectoryStartCluster, 0xFFFFFFFF, DirectoryBuffer->Data))
|
||||||
{
|
{
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_FAT_BUFFER);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,11 +837,11 @@ LONG FatLookupFile(PFAT_VOLUME_INFO Volume, PCSTR FileName, ULONG DeviceId, PFAT
|
||||||
//
|
//
|
||||||
if (!(FatFileInfo.Attributes & ATTR_DIRECTORY))
|
if (!(FatFileInfo.Attributes & ATTR_DIRECTORY))
|
||||||
{
|
{
|
||||||
MmHeapFree(FatFileInfo.FileFatChain);
|
FrLdrTempFree(FatFileInfo.FileFatChain, TAG_FAT_CHAIN);
|
||||||
return ENOTDIR;
|
return ENOTDIR;
|
||||||
}
|
}
|
||||||
DirectoryStartCluster = FatFileInfo.FileFatChain[0];
|
DirectoryStartCluster = FatFileInfo.FileFatChain[0];
|
||||||
MmHeapFree(FatFileInfo.FileFatChain);
|
FrLdrTempFree(FatFileInfo.FileFatChain, TAG_FAT_CHAIN);
|
||||||
FatFileInfo.FileFatChain = NULL;
|
FatFileInfo.FileFatChain = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -911,9 +917,7 @@ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPoi
|
||||||
//TRACE("FatGetFatEntry() Retrieving FAT entry for cluster %d.\n", Cluster);
|
//TRACE("FatGetFatEntry() Retrieving FAT entry for cluster %d.\n", Cluster);
|
||||||
|
|
||||||
// We need a buffer for 2 secors
|
// We need a buffer for 2 secors
|
||||||
ReadBuffer = FrLdrHeapAllocate(FrLdrTempHeap,
|
ReadBuffer = FrLdrTempAlloc(2 * Volume->BytesPerSector, TAG_FAT_BUFFER);
|
||||||
2 * Volume->BytesPerSector,
|
|
||||||
'xTAF');
|
|
||||||
if (!ReadBuffer)
|
if (!ReadBuffer)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -999,7 +1003,7 @@ BOOLEAN FatGetFatEntry(PFAT_VOLUME_INFO Volume, ULONG Cluster, ULONG* ClusterPoi
|
||||||
|
|
||||||
//TRACE("FAT entry is 0x%x.\n", fat);
|
//TRACE("FAT entry is 0x%x.\n", fat);
|
||||||
|
|
||||||
FrLdrHeapFree(FrLdrTempHeap, ReadBuffer, 'xTAF');
|
FrLdrTempFree(ReadBuffer, TAG_FAT_BUFFER);
|
||||||
|
|
||||||
*ClusterPointer = fat;
|
*ClusterPointer = fat;
|
||||||
|
|
||||||
|
@ -1058,7 +1062,7 @@ ULONG* FatGetClusterChainArray(PFAT_VOLUME_INFO Volume, ULONG StartCluster)
|
||||||
//
|
//
|
||||||
// Allocate array memory
|
// Allocate array memory
|
||||||
//
|
//
|
||||||
ArrayPointer = MmHeapAlloc(ArraySize);
|
ArrayPointer = FrLdrTempAlloc(ArraySize, TAG_FAT_CHAIN);
|
||||||
|
|
||||||
if (ArrayPointer == NULL)
|
if (ArrayPointer == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1091,7 +1095,7 @@ ULONG* FatGetClusterChainArray(PFAT_VOLUME_INFO Volume, ULONG StartCluster)
|
||||||
//
|
//
|
||||||
if (!FatGetFatEntry(Volume, StartCluster, &StartCluster))
|
if (!FatGetFatEntry(Volume, StartCluster, &StartCluster))
|
||||||
{
|
{
|
||||||
MmHeapFree(ArrayPointer);
|
FrLdrTempFree(ArrayPointer, TAG_FAT_CHAIN);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1183,7 +1187,7 @@ BOOLEAN FatReadPartialCluster(PFAT_VOLUME_INFO Volume, ULONG ClusterNumber, ULON
|
||||||
// Calculate rounded up read size
|
// Calculate rounded up read size
|
||||||
ReadSize = SectorCount * Volume->BytesPerSector;
|
ReadSize = SectorCount * Volume->BytesPerSector;
|
||||||
|
|
||||||
ReadBuffer = FrLdrHeapAllocate(FrLdrTempHeap, ReadSize, 'xTAF');
|
ReadBuffer = FrLdrTempAlloc(ReadSize, TAG_FAT_BUFFER);
|
||||||
if (!ReadBuffer)
|
if (!ReadBuffer)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1195,7 +1199,7 @@ BOOLEAN FatReadPartialCluster(PFAT_VOLUME_INFO Volume, ULONG ClusterNumber, ULON
|
||||||
status = TRUE;
|
status = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrLdrHeapFree(FrLdrTempHeap, ReadBuffer, 'xTAF');
|
FrLdrTempFree(ReadBuffer, TAG_FAT_BUFFER);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1397,8 +1401,8 @@ LONG FatClose(ULONG FileId)
|
||||||
{
|
{
|
||||||
PFAT_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
|
PFAT_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
|
||||||
|
|
||||||
if (FileHandle->FileFatChain) MmHeapFree(FileHandle->FileFatChain);
|
if (FileHandle->FileFatChain) FrLdrTempFree(FileHandle->FileFatChain, TAG_FAT_CHAIN);
|
||||||
MmHeapFree(FileHandle);
|
FrLdrTempFree(FileHandle, TAG_FAT_FILE);
|
||||||
|
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1450,7 +1454,7 @@ LONG FatOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
else if (!IsDirectory && OpenMode != OpenReadOnly)
|
else if (!IsDirectory && OpenMode != OpenReadOnly)
|
||||||
return ENOTDIR;
|
return ENOTDIR;
|
||||||
|
|
||||||
FileHandle = MmHeapAlloc(sizeof(FAT_FILE_INFO));
|
FileHandle = FrLdrTempAlloc(sizeof(FAT_FILE_INFO), TAG_FAT_FILE);
|
||||||
if (!FileHandle)
|
if (!FileHandle)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
|
@ -1523,7 +1527,7 @@ const DEVVTBL* FatMount(ULONG DeviceId)
|
||||||
//
|
//
|
||||||
// Allocate data for volume information
|
// Allocate data for volume information
|
||||||
//
|
//
|
||||||
Volume = MmHeapAlloc(sizeof(FAT_VOLUME_INFO));
|
Volume = FrLdrTempAlloc(sizeof(FAT_VOLUME_INFO), TAG_FAT_VOLUME);
|
||||||
if (!Volume)
|
if (!Volume)
|
||||||
return NULL;
|
return NULL;
|
||||||
RtlZeroMemory(Volume, sizeof(FAT_VOLUME_INFO));
|
RtlZeroMemory(Volume, sizeof(FAT_VOLUME_INFO));
|
||||||
|
@ -1536,13 +1540,13 @@ const DEVVTBL* FatMount(ULONG DeviceId)
|
||||||
ret = ArcSeek(DeviceId, &Position, SeekAbsolute);
|
ret = ArcSeek(DeviceId, &Position, SeekAbsolute);
|
||||||
if (ret != ESUCCESS)
|
if (ret != ESUCCESS)
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_FAT_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = ArcRead(DeviceId, Buffer, sizeof(Buffer), &Count);
|
ret = ArcRead(DeviceId, Buffer, sizeof(Buffer), &Count);
|
||||||
if (ret != ESUCCESS || Count != sizeof(Buffer))
|
if (ret != ESUCCESS || Count != sizeof(Buffer))
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_FAT_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1554,7 +1558,7 @@ const DEVVTBL* FatMount(ULONG DeviceId)
|
||||||
!RtlEqualMemory(BootSector32->FileSystemType, "FAT32 ", 8) &&
|
!RtlEqualMemory(BootSector32->FileSystemType, "FAT32 ", 8) &&
|
||||||
!RtlEqualMemory(BootSectorX->FileSystemType, "FATX", 4))
|
!RtlEqualMemory(BootSectorX->FileSystemType, "FATX", 4))
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_FAT_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1564,7 +1568,7 @@ const DEVVTBL* FatMount(ULONG DeviceId)
|
||||||
ret = ArcGetFileInformation(DeviceId, &FileInformation);
|
ret = ArcGetFileInformation(DeviceId, &FileInformation);
|
||||||
if (ret != ESUCCESS)
|
if (ret != ESUCCESS)
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_FAT_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SectorCount.HighPart = FileInformation.EndingAddress.HighPart;
|
SectorCount.HighPart = FileInformation.EndingAddress.HighPart;
|
||||||
|
@ -1581,7 +1585,7 @@ const DEVVTBL* FatMount(ULONG DeviceId)
|
||||||
//
|
//
|
||||||
if (!FatOpenVolume(Volume, BootSector, SectorCount.QuadPart))
|
if (!FatOpenVolume(Volume, BootSector, SectorCount.QuadPart))
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_FAT_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
||||||
|
|
||||||
|
#define TAG_DEVICE_NAME 'NDsF'
|
||||||
|
#define TAG_DEVICE 'vDsF'
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -280,7 +283,7 @@ LONG ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
Length = FileName - Path + Count;
|
Length = FileName - Path + Count;
|
||||||
if (Count != 0)
|
if (Count != 0)
|
||||||
{
|
{
|
||||||
DeviceName = MmHeapAlloc(FileName - Path + Count);
|
DeviceName = FrLdrTempAlloc(FileName - Path + Count, TAG_DEVICE_NAME);
|
||||||
if (!DeviceName)
|
if (!DeviceName)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
for (p = Path, q = DeviceName; p != FileName; p++)
|
for (p = Path, q = DeviceName; p != FileName; p++)
|
||||||
|
@ -417,7 +420,7 @@ VOID FsRegisterDevice(CHAR* Prefix, const DEVVTBL* FuncTable)
|
||||||
TRACE("FsRegisterDevice() Prefix = %s\n", Prefix);
|
TRACE("FsRegisterDevice() Prefix = %s\n", Prefix);
|
||||||
|
|
||||||
Length = strlen(Prefix) + 1;
|
Length = strlen(Prefix) + 1;
|
||||||
pNewEntry = MmHeapAlloc(sizeof(DEVICE) + Length);
|
pNewEntry = FrLdrTempAlloc(sizeof(DEVICE) + Length, TAG_DEVICE);
|
||||||
if (!pNewEntry)
|
if (!pNewEntry)
|
||||||
return;
|
return;
|
||||||
pNewEntry->FuncTable = FuncTable;
|
pNewEntry->FuncTable = FuncTable;
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#define SECTORSIZE 2048
|
#define SECTORSIZE 2048
|
||||||
|
#define TAG_ISO_BUFFER 'BosI'
|
||||||
|
#define TAG_ISO_FILE 'FosI'
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ static LONG IsoBufferDirectory(ULONG DeviceId, ULONG DirectoryStartSector, ULONG
|
||||||
// Attempt to allocate memory for directory buffer
|
// Attempt to allocate memory for directory buffer
|
||||||
//
|
//
|
||||||
TRACE("Trying to allocate (DirectoryLength) %d bytes.\n", DirectoryLength);
|
TRACE("Trying to allocate (DirectoryLength) %d bytes.\n", DirectoryLength);
|
||||||
DirectoryBuffer = MmHeapAlloc(DirectoryLength);
|
DirectoryBuffer = FrLdrTempAlloc(DirectoryLength, TAG_ISO_BUFFER);
|
||||||
if (!DirectoryBuffer)
|
if (!DirectoryBuffer)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
|
@ -124,13 +126,13 @@ static LONG IsoBufferDirectory(ULONG DeviceId, ULONG DirectoryStartSector, ULONG
|
||||||
ret = ArcSeek(DeviceId, &Position, SeekAbsolute);
|
ret = ArcSeek(DeviceId, &Position, SeekAbsolute);
|
||||||
if (ret != ESUCCESS)
|
if (ret != ESUCCESS)
|
||||||
{
|
{
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = ArcRead(DeviceId, DirectoryBuffer, SectorCount * SECTORSIZE, &Count);
|
ret = ArcRead(DeviceId, DirectoryBuffer, SectorCount * SECTORSIZE, &Count);
|
||||||
if (ret != ESUCCESS || Count != SectorCount * SECTORSIZE)
|
if (ret != ESUCCESS || Count != SectorCount * SECTORSIZE)
|
||||||
{
|
{
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
|
||||||
return EIO;
|
return EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,11 +217,11 @@ static LONG IsoLookupFile(PCSTR FileName, ULONG DeviceId, PISO_FILE_INFO IsoFile
|
||||||
//
|
//
|
||||||
if (!IsoSearchDirectoryBufferForFile(DirectoryBuffer, DirectoryLength, PathPart, &IsoFileInfo))
|
if (!IsoSearchDirectoryBufferForFile(DirectoryBuffer, DirectoryLength, PathPart, &IsoFileInfo))
|
||||||
{
|
{
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(DirectoryBuffer);
|
FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we have another sub-directory to go then
|
// If we have another sub-directory to go then
|
||||||
|
@ -242,7 +244,7 @@ LONG IsoClose(ULONG FileId)
|
||||||
{
|
{
|
||||||
PISO_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
|
PISO_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
|
||||||
|
|
||||||
MmHeapFree(FileHandle);
|
FrLdrTempFree(FileHandle, TAG_ISO_FILE);
|
||||||
|
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +282,7 @@ LONG IsoOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
if (ret != ESUCCESS)
|
if (ret != ESUCCESS)
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
|
|
||||||
FileHandle = MmHeapAlloc(sizeof(ISO_FILE_INFO));
|
FileHandle = FrLdrTempAlloc(sizeof(ISO_FILE_INFO), TAG_ISO_FILE);
|
||||||
if (!FileHandle)
|
if (!FileHandle)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,15 @@
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#define TAG_NTFS_CONTEXT 'CftN'
|
||||||
|
#define TAG_NTFS_LIST 'LftN'
|
||||||
|
#define TAG_NTFS_MFT 'MftN'
|
||||||
|
#define TAG_NTFS_INDEX_REC 'IftN'
|
||||||
|
#define TAG_NTFS_BITMAP 'BftN'
|
||||||
|
#define TAG_NTFS_FILE 'FftN'
|
||||||
|
#define TAG_NTFS_VOLUME 'VftN'
|
||||||
|
#define TAG_NTFS_DATA 'DftN'
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
||||||
|
|
||||||
typedef struct _NTFS_VOLUME_INFO
|
typedef struct _NTFS_VOLUME_INFO
|
||||||
|
@ -98,7 +107,8 @@ static PNTFS_ATTR_CONTEXT NtfsPrepareAttributeContext(PNTFS_ATTR_RECORD AttrReco
|
||||||
{
|
{
|
||||||
PNTFS_ATTR_CONTEXT Context;
|
PNTFS_ATTR_CONTEXT Context;
|
||||||
|
|
||||||
Context = MmHeapAlloc(FIELD_OFFSET(NTFS_ATTR_CONTEXT, Record) + AttrRecord->Length);
|
Context = FrLdrTempAlloc(FIELD_OFFSET(NTFS_ATTR_CONTEXT, Record) + AttrRecord->Length,
|
||||||
|
TAG_NTFS_CONTEXT);
|
||||||
RtlCopyMemory(&Context->Record, AttrRecord, AttrRecord->Length);
|
RtlCopyMemory(&Context->Record, AttrRecord, AttrRecord->Length);
|
||||||
if (AttrRecord->IsNonResident)
|
if (AttrRecord->IsNonResident)
|
||||||
{
|
{
|
||||||
|
@ -129,7 +139,7 @@ static PNTFS_ATTR_CONTEXT NtfsPrepareAttributeContext(PNTFS_ATTR_RECORD AttrReco
|
||||||
|
|
||||||
static VOID NtfsReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
|
static VOID NtfsReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
|
||||||
{
|
{
|
||||||
MmHeapFree(Context);
|
FrLdrTempFree(Context, TAG_NTFS_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN NtfsDiskRead(PNTFS_VOLUME_INFO Volume, ULONGLONG Offset, ULONGLONG Length, PCHAR Buffer)
|
static BOOLEAN NtfsDiskRead(PNTFS_VOLUME_INFO Volume, ULONGLONG Offset, ULONGLONG Length, PCHAR Buffer)
|
||||||
|
@ -384,7 +394,7 @@ static PNTFS_ATTR_CONTEXT NtfsFindAttributeHelper(PNTFS_VOLUME_INFO Volume, PNTF
|
||||||
|
|
||||||
ListSize = NtfsGetAttributeSize(&ListContext->Record);
|
ListSize = NtfsGetAttributeSize(&ListContext->Record);
|
||||||
if(ListSize <= 0xFFFFFFFF)
|
if(ListSize <= 0xFFFFFFFF)
|
||||||
ListBuffer = MmHeapAlloc((ULONG)ListSize);
|
ListBuffer = FrLdrTempAlloc((ULONG)ListSize, TAG_NTFS_LIST);
|
||||||
else
|
else
|
||||||
ListBuffer = NULL;
|
ListBuffer = NULL;
|
||||||
|
|
||||||
|
@ -403,7 +413,7 @@ static PNTFS_ATTR_CONTEXT NtfsFindAttributeHelper(PNTFS_VOLUME_INFO Volume, PNTF
|
||||||
Type, Name, NameLength);
|
Type, Name, NameLength);
|
||||||
|
|
||||||
NtfsReleaseAttributeContext(ListContext);
|
NtfsReleaseAttributeContext(ListContext);
|
||||||
MmHeapFree(ListBuffer);
|
FrLdrTempFree(ListBuffer, TAG_NTFS_LIST);
|
||||||
|
|
||||||
if (Context != NULL)
|
if (Context != NULL)
|
||||||
return Context;
|
return Context;
|
||||||
|
@ -551,7 +561,7 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
|
||||||
ULONG RecordOffset;
|
ULONG RecordOffset;
|
||||||
ULONG IndexBlockSize;
|
ULONG IndexBlockSize;
|
||||||
|
|
||||||
MftRecord = MmHeapAlloc(Volume->MftRecordSize);
|
MftRecord = FrLdrTempAlloc(Volume->MftRecordSize, TAG_NTFS_MFT);
|
||||||
if (MftRecord == NULL)
|
if (MftRecord == NULL)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -564,14 +574,14 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
|
||||||
IndexRootCtx = NtfsFindAttribute(Volume, MftRecord, NTFS_ATTR_TYPE_INDEX_ROOT, L"$I30");
|
IndexRootCtx = NtfsFindAttribute(Volume, MftRecord, NTFS_ATTR_TYPE_INDEX_ROOT, L"$I30");
|
||||||
if (IndexRootCtx == NULL)
|
if (IndexRootCtx == NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexRecord = MmHeapAlloc(Volume->IndexRecordSize);
|
IndexRecord = FrLdrTempAlloc(Volume->IndexRecordSize, TAG_NTFS_INDEX_REC);
|
||||||
if (IndexRecord == NULL)
|
if (IndexRecord == NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,8 +600,8 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
|
||||||
if (NtfsCompareFileName(FileName, IndexEntry))
|
if (NtfsCompareFileName(FileName, IndexEntry))
|
||||||
{
|
{
|
||||||
*OutMFTIndex = IndexEntry->Data.Directory.IndexedFile;
|
*OutMFTIndex = IndexEntry->Data.Directory.IndexedFile;
|
||||||
MmHeapFree(IndexRecord);
|
FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC);
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
IndexEntry = (PNTFS_INDEX_ENTRY)((PCHAR)IndexEntry + IndexEntry->Length);
|
IndexEntry = (PNTFS_INDEX_ENTRY)((PCHAR)IndexEntry + IndexEntry->Length);
|
||||||
|
@ -607,20 +617,20 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
|
||||||
if (IndexBitmapCtx == NULL)
|
if (IndexBitmapCtx == NULL)
|
||||||
{
|
{
|
||||||
TRACE("Corrupted filesystem!\n");
|
TRACE("Corrupted filesystem!\n");
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
BitmapDataSize = NtfsGetAttributeSize(&IndexBitmapCtx->Record);
|
BitmapDataSize = NtfsGetAttributeSize(&IndexBitmapCtx->Record);
|
||||||
TRACE("BitmapDataSize: %x\n", (ULONG)BitmapDataSize);
|
TRACE("BitmapDataSize: %x\n", (ULONG)BitmapDataSize);
|
||||||
if(BitmapDataSize <= 0xFFFFFFFF)
|
if(BitmapDataSize <= 0xFFFFFFFF)
|
||||||
BitmapData = MmHeapAlloc((ULONG)BitmapDataSize);
|
BitmapData = FrLdrTempAlloc((ULONG)BitmapDataSize, TAG_NTFS_BITMAP);
|
||||||
else
|
else
|
||||||
BitmapData = NULL;
|
BitmapData = NULL;
|
||||||
|
|
||||||
if (BitmapData == NULL)
|
if (BitmapData == NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(IndexRecord);
|
FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC);
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
NtfsReadAttribute(Volume, IndexBitmapCtx, 0, BitmapData, (ULONG)BitmapDataSize);
|
NtfsReadAttribute(Volume, IndexBitmapCtx, 0, BitmapData, (ULONG)BitmapDataSize);
|
||||||
|
@ -630,9 +640,9 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
|
||||||
if (IndexAllocationCtx == NULL)
|
if (IndexAllocationCtx == NULL)
|
||||||
{
|
{
|
||||||
TRACE("Corrupted filesystem!\n");
|
TRACE("Corrupted filesystem!\n");
|
||||||
MmHeapFree(BitmapData);
|
FrLdrTempFree(BitmapData, TAG_NTFS_BITMAP);
|
||||||
MmHeapFree(IndexRecord);
|
FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC);
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
IndexAllocationSize = NtfsGetAttributeSize(&IndexAllocationCtx->Record);
|
IndexAllocationSize = NtfsGetAttributeSize(&IndexAllocationCtx->Record);
|
||||||
|
@ -674,9 +684,9 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
|
||||||
{
|
{
|
||||||
TRACE("File found\n");
|
TRACE("File found\n");
|
||||||
*OutMFTIndex = IndexEntry->Data.Directory.IndexedFile;
|
*OutMFTIndex = IndexEntry->Data.Directory.IndexedFile;
|
||||||
MmHeapFree(BitmapData);
|
FrLdrTempFree(BitmapData, TAG_NTFS_BITMAP);
|
||||||
MmHeapFree(IndexRecord);
|
FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC);
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
NtfsReleaseAttributeContext(IndexAllocationCtx);
|
NtfsReleaseAttributeContext(IndexAllocationCtx);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -687,16 +697,16 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
|
||||||
}
|
}
|
||||||
|
|
||||||
NtfsReleaseAttributeContext(IndexAllocationCtx);
|
NtfsReleaseAttributeContext(IndexAllocationCtx);
|
||||||
MmHeapFree(BitmapData);
|
FrLdrTempFree(BitmapData, TAG_NTFS_BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(IndexRecord);
|
FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TRACE("Can't read MFT record\n");
|
TRACE("Can't read MFT record\n");
|
||||||
}
|
}
|
||||||
MmHeapFree(MftRecord);
|
FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -750,7 +760,7 @@ LONG NtfsClose(ULONG FileId)
|
||||||
PNTFS_FILE_HANDLE FileHandle = FsGetDeviceSpecific(FileId);
|
PNTFS_FILE_HANDLE FileHandle = FsGetDeviceSpecific(FileId);
|
||||||
|
|
||||||
NtfsReleaseAttributeContext(FileHandle->DataContext);
|
NtfsReleaseAttributeContext(FileHandle->DataContext);
|
||||||
MmHeapFree(FileHandle);
|
FrLdrTempFree(FileHandle, TAG_NTFS_FILE);
|
||||||
|
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -795,7 +805,8 @@ LONG NtfsOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
//
|
//
|
||||||
// Allocate file structure
|
// Allocate file structure
|
||||||
//
|
//
|
||||||
FileHandle = MmHeapAlloc(sizeof(NTFS_FILE_HANDLE) + Volume->MftRecordSize);
|
FileHandle = FrLdrTempAlloc(sizeof(NTFS_FILE_HANDLE) + Volume->MftRecordSize,
|
||||||
|
TAG_NTFS_FILE);
|
||||||
if (!FileHandle)
|
if (!FileHandle)
|
||||||
{
|
{
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
@ -809,7 +820,7 @@ LONG NtfsOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
MftRecord = (PNTFS_MFT_RECORD)(FileHandle + 1);
|
MftRecord = (PNTFS_MFT_RECORD)(FileHandle + 1);
|
||||||
if (!NtfsLookupFile(Volume, Path, MftRecord, &FileHandle->DataContext))
|
if (!NtfsLookupFile(Volume, Path, MftRecord, &FileHandle->DataContext))
|
||||||
{
|
{
|
||||||
MmHeapFree(FileHandle);
|
FrLdrTempFree(FileHandle, TAG_NTFS_FILE);
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,7 +885,7 @@ const DEVVTBL* NtfsMount(ULONG DeviceId)
|
||||||
//
|
//
|
||||||
// Allocate data for volume information
|
// Allocate data for volume information
|
||||||
//
|
//
|
||||||
Volume = MmHeapAlloc(sizeof(NTFS_VOLUME_INFO));
|
Volume = FrLdrTempAlloc(sizeof(NTFS_VOLUME_INFO), TAG_NTFS_VOLUME);
|
||||||
if (!Volume)
|
if (!Volume)
|
||||||
return NULL;
|
return NULL;
|
||||||
RtlZeroMemory(Volume, sizeof(NTFS_VOLUME_INFO));
|
RtlZeroMemory(Volume, sizeof(NTFS_VOLUME_INFO));
|
||||||
|
@ -887,13 +898,13 @@ const DEVVTBL* NtfsMount(ULONG DeviceId)
|
||||||
ret = ArcSeek(DeviceId, &Position, SeekAbsolute);
|
ret = ArcSeek(DeviceId, &Position, SeekAbsolute);
|
||||||
if (ret != ESUCCESS)
|
if (ret != ESUCCESS)
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = ArcRead(DeviceId, &Volume->BootSector, sizeof(Volume->BootSector), &Count);
|
ret = ArcRead(DeviceId, &Volume->BootSector, sizeof(Volume->BootSector), &Count);
|
||||||
if (ret != ESUCCESS || Count != sizeof(Volume->BootSector))
|
if (ret != ESUCCESS || Count != sizeof(Volume->BootSector))
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,7 +913,7 @@ const DEVVTBL* NtfsMount(ULONG DeviceId)
|
||||||
//
|
//
|
||||||
if (!RtlEqualMemory(Volume->BootSector.SystemId, "NTFS", 4))
|
if (!RtlEqualMemory(Volume->BootSector.SystemId, "NTFS", 4))
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,10 +940,10 @@ const DEVVTBL* NtfsMount(ULONG DeviceId)
|
||||||
// Read MFT index
|
// Read MFT index
|
||||||
//
|
//
|
||||||
TRACE("Reading MFT index...\n");
|
TRACE("Reading MFT index...\n");
|
||||||
Volume->MasterFileTable = MmHeapAlloc(Volume->MftRecordSize);
|
Volume->MasterFileTable = FrLdrTempAlloc(Volume->MftRecordSize, TAG_NTFS_MFT);
|
||||||
if (!Volume->MasterFileTable)
|
if (!Volume->MasterFileTable)
|
||||||
{
|
{
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Position.QuadPart = Volume->BootSector.MftLocation * Volume->ClusterSize;
|
Position.QuadPart = Volume->BootSector.MftLocation * Volume->ClusterSize;
|
||||||
|
@ -940,28 +951,28 @@ const DEVVTBL* NtfsMount(ULONG DeviceId)
|
||||||
if (ret != ESUCCESS)
|
if (ret != ESUCCESS)
|
||||||
{
|
{
|
||||||
FileSystemError("Failed to seek to Master File Table record.");
|
FileSystemError("Failed to seek to Master File Table record.");
|
||||||
MmHeapFree(Volume->MasterFileTable);
|
FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = ArcRead(DeviceId, Volume->MasterFileTable, Volume->MftRecordSize, &Count);
|
ret = ArcRead(DeviceId, Volume->MasterFileTable, Volume->MftRecordSize, &Count);
|
||||||
if (ret != ESUCCESS || Count != Volume->MftRecordSize)
|
if (ret != ESUCCESS || Count != Volume->MftRecordSize)
|
||||||
{
|
{
|
||||||
FileSystemError("Failed to read the Master File Table record.");
|
FileSystemError("Failed to read the Master File Table record.");
|
||||||
MmHeapFree(Volume->MasterFileTable);
|
FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Keep room to read partial sectors
|
// Keep room to read partial sectors
|
||||||
//
|
//
|
||||||
Volume->TemporarySector = MmHeapAlloc(Volume->BootSector.BytesPerSector);
|
Volume->TemporarySector = FrLdrTempAlloc(Volume->BootSector.BytesPerSector, TAG_NTFS_DATA);
|
||||||
if (!Volume->TemporarySector)
|
if (!Volume->TemporarySector)
|
||||||
{
|
{
|
||||||
FileSystemError("Failed to allocate memory.");
|
FileSystemError("Failed to allocate memory.");
|
||||||
MmHeapFree(Volume->MasterFileTable);
|
FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,8 +989,8 @@ const DEVVTBL* NtfsMount(ULONG DeviceId)
|
||||||
if (!Volume->MFTContext)
|
if (!Volume->MFTContext)
|
||||||
{
|
{
|
||||||
FileSystemError("Can't find data attribute for Master File Table.");
|
FileSystemError("Can't find data attribute for Master File Table.");
|
||||||
MmHeapFree(Volume->MasterFileTable);
|
FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
|
||||||
MmHeapFree(Volume);
|
FrLdrTempFree(Volume, TAG_NTFS_VOLUME);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#define TAG_PXE_FILE 'FexP'
|
||||||
#define NO_FILE ((ULONG)-1)
|
#define NO_FILE ((ULONG)-1)
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
DBG_DEFAULT_CHANNEL(FILESYSTEM);
|
||||||
|
@ -129,7 +130,7 @@ static LONG PxeClose(ULONG FileId)
|
||||||
_OpenFile = NO_FILE;
|
_OpenFile = NO_FILE;
|
||||||
if (_CachedFile)
|
if (_CachedFile)
|
||||||
{
|
{
|
||||||
MmHeapFree(_CachedFile);
|
FrLdrTempFree(_CachedFile, TAG_PXE_FILE);
|
||||||
_CachedFile = NULL;
|
_CachedFile = NULL;
|
||||||
}
|
}
|
||||||
return ESUCCESS;
|
return ESUCCESS;
|
||||||
|
@ -165,7 +166,7 @@ static LONG PxeOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
_FileSize = sizeData.FileSize;
|
_FileSize = sizeData.FileSize;
|
||||||
if (_FileSize < 1024 * 1024)
|
if (_FileSize < 1024 * 1024)
|
||||||
{
|
{
|
||||||
_CachedFile = MmHeapAlloc(_FileSize);
|
_CachedFile = FrLdrTempAlloc(_FileSize, TAG_PXE_FILE);
|
||||||
// Don't check for allocation failure, we support _CachedFile = NULL
|
// Don't check for allocation failure, we support _CachedFile = NULL
|
||||||
}
|
}
|
||||||
_CachedLength = 0;
|
_CachedLength = 0;
|
||||||
|
@ -179,7 +180,7 @@ static LONG PxeOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
||||||
{
|
{
|
||||||
if (_CachedFile)
|
if (_CachedFile)
|
||||||
{
|
{
|
||||||
MmHeapFree(_CachedFile);
|
FrLdrTempFree(_CachedFile, TAG_PXE_FILE);
|
||||||
_CachedFile = NULL;
|
_CachedFile = NULL;
|
||||||
}
|
}
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define TAG_HW_RESOURCE_LIST 'lRwH'
|
||||||
|
#define TAG_HW_DISK_CONTEXT 'cDwH'
|
||||||
|
|
||||||
#define HAS_OPTION_MENU_CUSTOM_BOOT
|
#define HAS_OPTION_MENU_CUSTOM_BOOT
|
||||||
#define HAS_OPTION_MENU_REBOOT
|
#define HAS_OPTION_MENU_REBOOT
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define TAG_CACHE_DATA 'DcaC'
|
||||||
|
#define TAG_CACHE_BLOCK 'BcaC'
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// This structure describes a cached block element. The disk is divided up into
|
// This structure describes a cached block element. The disk is divided up into
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
|
|
||||||
#define INI_FILE_COMMENT_CHAR ';'
|
#define INI_FILE_COMMENT_CHAR ';'
|
||||||
|
|
||||||
|
#define TAG_INI_FILE 'FinI'
|
||||||
|
#define TAG_INI_SECTION 'SinI'
|
||||||
|
#define TAG_INI_SECTION_ITEM 'IinI'
|
||||||
|
#define TAG_INI_NAME 'NinI'
|
||||||
|
#define TAG_INI_VALUE 'VinI'
|
||||||
|
|
||||||
// This structure describes a single .ini file item
|
// This structure describes a single .ini file item
|
||||||
// The item format in the .ini file is:
|
// The item format in the .ini file is:
|
||||||
// Name=Value
|
// Name=Value
|
||||||
|
@ -75,3 +81,4 @@ BOOLEAN IniReadSettingByNumber(ULONG_PTR SectionId, ULONG SettingNumber, PCHA
|
||||||
BOOLEAN IniReadSettingByName(ULONG_PTR SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize);
|
BOOLEAN IniReadSettingByName(ULONG_PTR SectionId, PCSTR SettingName, PCHAR Buffer, ULONG BufferSize);
|
||||||
BOOLEAN IniAddSection(PCSTR SectionName, ULONG_PTR* SectionId);
|
BOOLEAN IniAddSection(PCSTR SectionName, ULONG_PTR* SectionId);
|
||||||
BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue);
|
BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue);
|
||||||
|
VOID IniCleanup(VOID);
|
||||||
|
|
|
@ -117,10 +117,10 @@ VOID MmFreeMemory(PVOID MemoryPointer);
|
||||||
PVOID MmAllocateMemoryAtAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
|
PVOID MmAllocateMemoryAtAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
|
||||||
PVOID MmAllocateHighestMemoryBelowAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
|
PVOID MmAllocateHighestMemoryBelowAddress(SIZE_T MemorySize, PVOID DesiredAddress, TYPE_OF_MEMORY MemoryType);
|
||||||
|
|
||||||
PVOID MmHeapAlloc(SIZE_T MemorySize);
|
|
||||||
VOID MmHeapFree(PVOID MemoryPointer);
|
|
||||||
|
|
||||||
/* Heap */
|
/* Heap */
|
||||||
|
#define DEFAULT_HEAP_SIZE (1024 * 1024)
|
||||||
|
#define TEMP_HEAP_SIZE (32 * 1024 * 1024)
|
||||||
|
|
||||||
extern PVOID FrLdrDefaultHeap;
|
extern PVOID FrLdrDefaultHeap;
|
||||||
extern PVOID FrLdrTempHeap;
|
extern PVOID FrLdrTempHeap;
|
||||||
|
|
||||||
|
@ -145,13 +145,44 @@ VOID
|
||||||
FrLdrHeapCleanupAll(VOID);
|
FrLdrHeapCleanupAll(VOID);
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
FrLdrHeapAllocate(
|
FrLdrHeapAllocateEx(
|
||||||
PVOID HeapHandle,
|
PVOID HeapHandle,
|
||||||
SIZE_T ByteSize,
|
SIZE_T ByteSize,
|
||||||
ULONG Tag);
|
ULONG Tag);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
FrLdrHeapFree(
|
FrLdrHeapFreeEx(
|
||||||
PVOID HeapHandle,
|
PVOID HeapHandle,
|
||||||
PVOID Pointer,
|
PVOID Pointer,
|
||||||
ULONG Tag);
|
ULONG Tag);
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
PVOID
|
||||||
|
FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
|
||||||
|
{
|
||||||
|
return FrLdrHeapAllocateEx(FrLdrDefaultHeap, MemorySize, Tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
VOID
|
||||||
|
FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
|
||||||
|
{
|
||||||
|
FrLdrHeapFreeEx(FrLdrDefaultHeap, MemoryPointer, Tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID
|
||||||
|
FORCEINLINE
|
||||||
|
FrLdrTempAlloc(
|
||||||
|
ULONG Size, ULONG Tag)
|
||||||
|
{
|
||||||
|
return FrLdrHeapAllocateEx(FrLdrTempHeap, Size, Tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
FORCEINLINE
|
||||||
|
FrLdrTempFree(
|
||||||
|
PVOID Allocation, ULONG Tag)
|
||||||
|
{
|
||||||
|
FrLdrHeapFreeEx(FrLdrTempHeap, Allocation, Tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
#ifndef __REGISTRY_H
|
#ifndef __REGISTRY_H
|
||||||
#define __REGISTRY_H
|
#define __REGISTRY_H
|
||||||
|
|
||||||
|
#define TAG_REG_NAME 'NgeR'
|
||||||
|
#define TAG_REG_KEY 'KgeR'
|
||||||
|
#define TAG_REG_KEY_DATA 'DgeR'
|
||||||
|
#define TAG_REG_VALUE 'VgeR'
|
||||||
|
|
||||||
typedef struct _REG_KEY
|
typedef struct _REG_KEY
|
||||||
{
|
{
|
||||||
LIST_ENTRY KeyList;
|
LIST_ENTRY KeyList;
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#include <arc/setupblk.h>
|
#include <arc/setupblk.h>
|
||||||
|
|
||||||
|
#define TAG_WLDR_DTE 'eDlW'
|
||||||
|
#define TAG_WLDR_BDE 'dBlW'
|
||||||
|
#define TAG_WLDR_NAME 'mNlW'
|
||||||
|
|
||||||
/* Entry-point to kernel */
|
/* Entry-point to kernel */
|
||||||
typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
|
typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
/* actual string limit is MAX_INF_STRING_LENGTH+1 (plus terminating null) under Windows */
|
/* actual string limit is MAX_INF_STRING_LENGTH+1 (plus terminating null) under Windows */
|
||||||
#define MAX_STRING_LEN (MAX_INF_STRING_LENGTH+1)
|
#define MAX_STRING_LEN (MAX_INF_STRING_LENGTH+1)
|
||||||
|
|
||||||
|
#define TAG_INF_KEY 'KfnI'
|
||||||
|
#define TAG_INF_FIELD 'ffnI'
|
||||||
|
#define TAG_INF_LINE 'LfnI'
|
||||||
|
#define TAG_INF_SECTION 'SfnI'
|
||||||
|
#define TAG_INF_CACHE 'CfnI'
|
||||||
|
#define TAG_INF_FILE 'FfnI'
|
||||||
|
|
||||||
typedef struct _INFCACHEFIELD
|
typedef struct _INFCACHEFIELD
|
||||||
{
|
{
|
||||||
|
@ -158,7 +164,7 @@ InfpCacheFreeLine(
|
||||||
Next = Line->Next;
|
Next = Line->Next;
|
||||||
if (Line->Key != NULL)
|
if (Line->Key != NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(Line->Key);
|
FrLdrTempFree(Line->Key, TAG_INF_KEY);
|
||||||
Line->Key = NULL;
|
Line->Key = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,12 +172,12 @@ InfpCacheFreeLine(
|
||||||
while (Line->FirstField != NULL)
|
while (Line->FirstField != NULL)
|
||||||
{
|
{
|
||||||
Field = Line->FirstField->Next;
|
Field = Line->FirstField->Next;
|
||||||
MmHeapFree(Line->FirstField);
|
FrLdrTempFree(Line->FirstField, TAG_INF_FIELD);
|
||||||
Line->FirstField = Field;
|
Line->FirstField = Field;
|
||||||
}
|
}
|
||||||
Line->LastField = NULL;
|
Line->LastField = NULL;
|
||||||
|
|
||||||
MmHeapFree(Line);
|
FrLdrTempFree(Line, TAG_INF_LINE);
|
||||||
|
|
||||||
return Next;
|
return Next;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +203,7 @@ InfpCacheFreeSection(
|
||||||
}
|
}
|
||||||
Section->LastLine = NULL;
|
Section->LastLine = NULL;
|
||||||
|
|
||||||
MmHeapFree(Section);
|
FrLdrTempFree(Section, TAG_INF_SECTION);
|
||||||
|
|
||||||
return Next;
|
return Next;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +256,7 @@ InfpCacheAddSection(
|
||||||
|
|
||||||
/* Allocate and initialize the new section */
|
/* Allocate and initialize the new section */
|
||||||
Size = sizeof(INFCACHESECTION) + strlen(Name);
|
Size = sizeof(INFCACHESECTION) + strlen(Name);
|
||||||
Section = (PINFCACHESECTION)MmHeapAlloc(Size);
|
Section = (PINFCACHESECTION)FrLdrTempAlloc(Size, TAG_INF_SECTION);
|
||||||
if (Section == NULL)
|
if (Section == NULL)
|
||||||
{
|
{
|
||||||
// DPRINT("RtlAllocateHeap() failed\n");
|
// DPRINT("RtlAllocateHeap() failed\n");
|
||||||
|
@ -290,7 +296,7 @@ InfpCacheAddLine(PINFCACHESECTION Section)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Line = (PINFCACHELINE)MmHeapAlloc(sizeof(INFCACHELINE));
|
Line = (PINFCACHELINE)FrLdrTempAlloc(sizeof(INFCACHELINE), TAG_INF_LINE);
|
||||||
if (Line == NULL)
|
if (Line == NULL)
|
||||||
{
|
{
|
||||||
// DPRINT("RtlAllocateHeap() failed\n");
|
// DPRINT("RtlAllocateHeap() failed\n");
|
||||||
|
@ -328,7 +334,7 @@ InfpAddKeyToLine(
|
||||||
if (Line->Key != NULL)
|
if (Line->Key != NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Line->Key = MmHeapAlloc(strlen(Key) + 1);
|
Line->Key = FrLdrTempAlloc(strlen(Key) + 1, TAG_INF_KEY);
|
||||||
if (Line->Key == NULL)
|
if (Line->Key == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -348,7 +354,7 @@ InfpAddFieldToLine(
|
||||||
SIZE_T Size;
|
SIZE_T Size;
|
||||||
|
|
||||||
Size = sizeof(INFCACHEFIELD) + strlen(Data);
|
Size = sizeof(INFCACHEFIELD) + strlen(Data);
|
||||||
Field = (PINFCACHEFIELD)MmHeapAlloc(Size);
|
Field = (PINFCACHEFIELD)FrLdrTempAlloc(Size, TAG_INF_FIELD);
|
||||||
if (Field == NULL)
|
if (Field == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -966,7 +972,7 @@ InfOpenFile(
|
||||||
//
|
//
|
||||||
// Allocate buffer to cache the file
|
// Allocate buffer to cache the file
|
||||||
//
|
//
|
||||||
FileBuffer = MmHeapAlloc(FileSize + 1);
|
FileBuffer = FrLdrTempAlloc(FileSize + 1, TAG_INF_FILE);
|
||||||
if (!FileBuffer)
|
if (!FileBuffer)
|
||||||
{
|
{
|
||||||
ArcClose(FileId);
|
ArcClose(FileId);
|
||||||
|
@ -980,7 +986,7 @@ InfOpenFile(
|
||||||
if ((ret != ESUCCESS) || (Count != FileSize))
|
if ((ret != ESUCCESS) || (Count != FileSize))
|
||||||
{
|
{
|
||||||
ArcClose(FileId);
|
ArcClose(FileId);
|
||||||
MmHeapFree(FileBuffer);
|
FrLdrTempFree(FileBuffer, TAG_INF_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,10 +1003,10 @@ InfOpenFile(
|
||||||
//
|
//
|
||||||
// Allocate infcache header
|
// Allocate infcache header
|
||||||
//
|
//
|
||||||
Cache = (PINFCACHE)MmHeapAlloc(sizeof(INFCACHE));
|
Cache = (PINFCACHE)FrLdrTempAlloc(sizeof(INFCACHE), TAG_INF_CACHE);
|
||||||
if (!Cache)
|
if (!Cache)
|
||||||
{
|
{
|
||||||
MmHeapFree(FileBuffer);
|
FrLdrTempFree(FileBuffer, TAG_INF_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,14 +1024,14 @@ InfOpenFile(
|
||||||
ErrorLine);
|
ErrorLine);
|
||||||
if (!Success)
|
if (!Success)
|
||||||
{
|
{
|
||||||
MmHeapFree(Cache);
|
FrLdrTempFree(Cache, TAG_INF_CACHE);
|
||||||
Cache = NULL;
|
Cache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Free file buffer, as it has been parsed
|
// Free file buffer, as it has been parsed
|
||||||
//
|
//
|
||||||
MmHeapFree(FileBuffer);
|
FrLdrTempFree(FileBuffer, TAG_INF_FILE);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return .inf parsed contents
|
// Return .inf parsed contents
|
||||||
|
@ -1054,7 +1060,7 @@ InfCloseFile(HINF InfHandle)
|
||||||
}
|
}
|
||||||
Cache->LastSection = NULL;
|
Cache->LastSection = NULL;
|
||||||
|
|
||||||
MmHeapFree(Cache);
|
FrLdrTempFree(Cache, TAG_INF_CACHE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ BOOLEAN IniFileInitialize(VOID)
|
||||||
//
|
//
|
||||||
// Allocate memory to cache the whole freeldr.ini
|
// Allocate memory to cache the whole freeldr.ini
|
||||||
//
|
//
|
||||||
FreeLoaderIniFileData = MmHeapAlloc(FreeLoaderIniFileSize);
|
FreeLoaderIniFileData = FrLdrTempAlloc(FreeLoaderIniFileSize, TAG_INI_FILE);
|
||||||
if (!FreeLoaderIniFileData)
|
if (!FreeLoaderIniFileData)
|
||||||
{
|
{
|
||||||
UiMessageBoxCritical("Out of memory while loading freeldr.ini.");
|
UiMessageBoxCritical("Out of memory while loading freeldr.ini.");
|
||||||
|
@ -88,7 +88,7 @@ BOOLEAN IniFileInitialize(VOID)
|
||||||
{
|
{
|
||||||
UiMessageBoxCritical("Error while reading freeldr.ini.");
|
UiMessageBoxCritical("Error while reading freeldr.ini.");
|
||||||
ArcClose(FileId);
|
ArcClose(FileId);
|
||||||
MmHeapFree(FreeLoaderIniFileData);
|
FrLdrTempFree(FreeLoaderIniFileData, TAG_INI_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ BOOLEAN IniFileInitialize(VOID)
|
||||||
// Do some cleanup, and return
|
// Do some cleanup, and return
|
||||||
//
|
//
|
||||||
ArcClose(FileId);
|
ArcClose(FileId);
|
||||||
MmHeapFree(FreeLoaderIniFileData);
|
FrLdrTempFree(FreeLoaderIniFileData, TAG_INI_FILE);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ BOOLEAN IniAddSection(PCSTR SectionName, ULONG_PTR* SectionId)
|
||||||
PINI_SECTION Section;
|
PINI_SECTION Section;
|
||||||
|
|
||||||
// Allocate a new section structure
|
// Allocate a new section structure
|
||||||
Section = MmHeapAlloc(sizeof(INI_SECTION));
|
Section = FrLdrTempAlloc(sizeof(INI_SECTION), TAG_INI_SECTION);
|
||||||
if (!Section)
|
if (!Section)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -190,10 +190,10 @@ BOOLEAN IniAddSection(PCSTR SectionName, ULONG_PTR* SectionId)
|
||||||
RtlZeroMemory(Section, sizeof(INI_SECTION));
|
RtlZeroMemory(Section, sizeof(INI_SECTION));
|
||||||
|
|
||||||
// Allocate the section name buffer
|
// Allocate the section name buffer
|
||||||
Section->SectionName = MmHeapAlloc(strlen(SectionName) + sizeof(CHAR));
|
Section->SectionName = FrLdrTempAlloc(strlen(SectionName) + sizeof(CHAR), TAG_INI_NAME);
|
||||||
if (!Section->SectionName)
|
if (!Section->SectionName)
|
||||||
{
|
{
|
||||||
MmHeapFree(Section);
|
FrLdrTempFree(Section, TAG_INI_SECTION);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,13 +209,52 @@ BOOLEAN IniAddSection(PCSTR SectionName, ULONG_PTR* SectionId)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID IniFreeSection(PINI_SECTION Section)
|
||||||
|
{
|
||||||
|
PLIST_ENTRY ListEntry;
|
||||||
|
PINI_SECTION_ITEM SectionItem;
|
||||||
|
|
||||||
|
// Loop while there are section items
|
||||||
|
while (!IsListEmpty(&Section->SectionItemList))
|
||||||
|
{
|
||||||
|
// Remove the section item
|
||||||
|
ListEntry = RemoveHeadList(&Section->SectionItemList);
|
||||||
|
SectionItem = CONTAINING_RECORD(ListEntry, INI_SECTION_ITEM, ListEntry);
|
||||||
|
|
||||||
|
// Free it
|
||||||
|
FrLdrTempFree(SectionItem->ItemName, TAG_INI_NAME);
|
||||||
|
FrLdrTempFree(SectionItem->ItemValue, TAG_INI_VALUE);
|
||||||
|
FrLdrTempFree(SectionItem, TAG_INI_SECTION_ITEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
FrLdrTempFree(Section->SectionName, TAG_INI_NAME);
|
||||||
|
FrLdrTempFree(Section, TAG_INI_SECTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID IniCleanup(VOID)
|
||||||
|
{
|
||||||
|
PLIST_ENTRY ListEntry;
|
||||||
|
PINI_SECTION Section;
|
||||||
|
|
||||||
|
// Loop while there are sections
|
||||||
|
while (!IsListEmpty(&IniFileSectionListHead))
|
||||||
|
{
|
||||||
|
// Remove the section
|
||||||
|
ListEntry = RemoveHeadList(&IniFileSectionListHead);
|
||||||
|
Section = CONTAINING_RECORD(ListEntry, INI_SECTION, ListEntry);
|
||||||
|
|
||||||
|
// Free it
|
||||||
|
IniFreeSection(Section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue)
|
BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCSTR SettingValue)
|
||||||
{
|
{
|
||||||
PINI_SECTION Section = (PINI_SECTION)SectionId;
|
PINI_SECTION Section = (PINI_SECTION)SectionId;
|
||||||
PINI_SECTION_ITEM SectionItem;
|
PINI_SECTION_ITEM SectionItem;
|
||||||
|
|
||||||
// Allocate a new item structure
|
// Allocate a new item structure
|
||||||
SectionItem = MmHeapAlloc(sizeof(INI_SECTION_ITEM));
|
SectionItem = FrLdrTempAlloc(sizeof(INI_SECTION_ITEM), TAG_INI_SECTION_ITEM);
|
||||||
if (!SectionItem)
|
if (!SectionItem)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -224,19 +263,19 @@ BOOLEAN IniAddSettingValueToSection(ULONG_PTR SectionId, PCSTR SettingName, PCST
|
||||||
RtlZeroMemory(SectionItem, sizeof(INI_SECTION_ITEM));
|
RtlZeroMemory(SectionItem, sizeof(INI_SECTION_ITEM));
|
||||||
|
|
||||||
// Allocate the setting name buffer
|
// Allocate the setting name buffer
|
||||||
SectionItem->ItemName = MmHeapAlloc(strlen(SettingName) + 1);
|
SectionItem->ItemName = FrLdrTempAlloc(strlen(SettingName) + 1, TAG_INI_NAME);
|
||||||
if (!SectionItem->ItemName)
|
if (!SectionItem->ItemName)
|
||||||
{
|
{
|
||||||
MmHeapFree(SectionItem);
|
FrLdrTempFree(SectionItem, TAG_INI_SECTION_ITEM);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate the setting value buffer
|
// Allocate the setting value buffer
|
||||||
SectionItem->ItemValue = MmHeapAlloc(strlen(SettingValue) + 1);
|
SectionItem->ItemValue = FrLdrTempAlloc(strlen(SettingValue) + 1, TAG_INI_VALUE);
|
||||||
if (!SectionItem->ItemValue)
|
if (!SectionItem->ItemValue)
|
||||||
{
|
{
|
||||||
MmHeapFree(SectionItem->ItemName);
|
FrLdrTempFree(SectionItem->ItemName, TAG_INI_NAME);
|
||||||
MmHeapFree(SectionItem);
|
FrLdrTempFree(SectionItem, TAG_INI_SECTION_ITEM);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
|
||||||
|
|
||||||
// Start with an 80-byte buffer
|
// Start with an 80-byte buffer
|
||||||
IniFileLineSize = 80;
|
IniFileLineSize = 80;
|
||||||
IniFileLine = MmHeapAlloc(IniFileLineSize);
|
IniFileLine = FrLdrTempAlloc(IniFileLineSize, TAG_INI_FILE);
|
||||||
if (!IniFileLine)
|
if (!IniFileLine)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -63,8 +63,8 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
|
||||||
if (IniFileLineSize < IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset))
|
if (IniFileLineSize < IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset))
|
||||||
{
|
{
|
||||||
IniFileLineSize = IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset);
|
IniFileLineSize = IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset);
|
||||||
MmHeapFree(IniFileLine);
|
FrLdrTempFree(IniFileLine, TAG_INI_FILE);
|
||||||
IniFileLine = MmHeapAlloc(IniFileLineSize);
|
IniFileLine = FrLdrTempAlloc(IniFileLineSize, TAG_INI_FILE);
|
||||||
if (!IniFileLine)
|
if (!IniFileLine)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -86,21 +86,21 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
|
||||||
if (IniIsSectionName(IniFileLine, LineLength))
|
if (IniIsSectionName(IniFileLine, LineLength))
|
||||||
{
|
{
|
||||||
// Allocate a new section structure
|
// Allocate a new section structure
|
||||||
CurrentSection = MmHeapAlloc(sizeof(INI_SECTION));
|
CurrentSection = FrLdrTempAlloc(sizeof(INI_SECTION), TAG_INI_SECTION);
|
||||||
if (!CurrentSection)
|
if (!CurrentSection)
|
||||||
{
|
{
|
||||||
MmHeapFree(IniFileLine);
|
FrLdrTempFree(IniFileLine, TAG_INI_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(CurrentSection, sizeof(INI_SECTION));
|
RtlZeroMemory(CurrentSection, sizeof(INI_SECTION));
|
||||||
|
|
||||||
// Allocate the section name buffer
|
// Allocate the section name buffer
|
||||||
CurrentSection->SectionName = MmHeapAlloc(IniGetSectionNameSize(IniFileLine, LineLength));
|
CurrentSection->SectionName = FrLdrTempAlloc(IniGetSectionNameSize(IniFileLine, LineLength), TAG_INI_NAME);
|
||||||
if (!CurrentSection->SectionName)
|
if (!CurrentSection->SectionName)
|
||||||
{
|
{
|
||||||
MmHeapFree(CurrentSection);
|
FrLdrTempFree(CurrentSection, TAG_INI_FILE);
|
||||||
MmHeapFree(IniFileLine);
|
FrLdrTempFree(IniFileLine, TAG_INI_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,31 +130,31 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a new item structure
|
// Allocate a new item structure
|
||||||
CurrentItem = MmHeapAlloc(sizeof(INI_SECTION_ITEM));
|
CurrentItem = FrLdrTempAlloc(sizeof(INI_SECTION_ITEM), TAG_INI_SECTION_ITEM);
|
||||||
if (!CurrentItem)
|
if (!CurrentItem)
|
||||||
{
|
{
|
||||||
MmHeapFree(IniFileLine);
|
FrLdrTempFree(IniFileLine, TAG_INI_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(CurrentItem, sizeof(INI_SECTION_ITEM));
|
RtlZeroMemory(CurrentItem, sizeof(INI_SECTION_ITEM));
|
||||||
|
|
||||||
// Allocate the setting name buffer
|
// Allocate the setting name buffer
|
||||||
CurrentItem->ItemName = MmHeapAlloc(IniGetSettingNameSize(IniFileLine, LineLength));
|
CurrentItem->ItemName = FrLdrTempAlloc(IniGetSettingNameSize(IniFileLine, LineLength), TAG_INI_NAME);
|
||||||
if (!CurrentItem->ItemName)
|
if (!CurrentItem->ItemName)
|
||||||
{
|
{
|
||||||
MmHeapFree(CurrentItem);
|
FrLdrTempFree(CurrentItem, TAG_INI_SECTION_ITEM);
|
||||||
MmHeapFree(IniFileLine);
|
FrLdrTempFree(IniFileLine, TAG_INI_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate the setting value buffer
|
// Allocate the setting value buffer
|
||||||
CurrentItem->ItemValue = MmHeapAlloc(IniGetSettingValueSize(IniFileLine, LineLength));
|
CurrentItem->ItemValue = FrLdrTempAlloc(IniGetSettingValueSize(IniFileLine, LineLength), TAG_INI_VALUE);
|
||||||
if (!CurrentItem->ItemValue)
|
if (!CurrentItem->ItemValue)
|
||||||
{
|
{
|
||||||
MmHeapFree(CurrentItem->ItemName);
|
FrLdrTempFree(CurrentItem->ItemName, TAG_INI_NAME);
|
||||||
MmHeapFree(CurrentItem);
|
FrLdrTempFree(CurrentItem, TAG_INI_SECTION_ITEM);
|
||||||
MmHeapFree(IniFileLine);
|
FrLdrTempFree(IniFileLine, TAG_INI_FILE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +174,8 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
|
||||||
CurrentLineNumber++;
|
CurrentLineNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FrLdrTempFree(IniFileLine, TAG_INI_FILE);
|
||||||
|
|
||||||
TRACE("Parsed %d sections and %d settings.\n", IniFileSectionCount, IniFileSettingCount);
|
TRACE("Parsed %d sections and %d settings.\n", IniFileSectionCount, IniFileSettingCount);
|
||||||
TRACE("IniParseFile() done.\n");
|
TRACE("IniParseFile() done.\n");
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,6 @@
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(HEAP);
|
DBG_DEFAULT_CHANNEL(HEAP);
|
||||||
|
|
||||||
#define DEFAULT_HEAP_SIZE (1024 * 1024)
|
|
||||||
#define TEMP_HEAP_SIZE (1024 * 1024)
|
|
||||||
|
|
||||||
#define REDZONE_MARK 0xCCCCCCCCCCCCCCCCULL
|
#define REDZONE_MARK 0xCCCCCCCCCCCCCCCCULL
|
||||||
#define REDZONE_ALLOCATION 24
|
#define REDZONE_ALLOCATION 24
|
||||||
#define REDZONE_LOW_OFFSET 16
|
#define REDZONE_LOW_OFFSET 16
|
||||||
|
@ -147,6 +144,11 @@ FrLdrHeapDestroy(
|
||||||
(ULONG_PTR)Heap / MM_PAGE_SIZE,
|
(ULONG_PTR)Heap / MM_PAGE_SIZE,
|
||||||
(PFN_COUNT)(Heap->MaximumSize / MM_PAGE_SIZE),
|
(PFN_COUNT)(Heap->MaximumSize / MM_PAGE_SIZE),
|
||||||
LoaderFirmwareTemporary);
|
LoaderFirmwareTemporary);
|
||||||
|
|
||||||
|
#if DBG
|
||||||
|
/* Make sure everything is dead */
|
||||||
|
RtlFillMemory(Heap, Heap->MaximumSize, 0xCCCCCCCC);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FREELDR_HEAP_VERIFIER
|
#ifdef FREELDR_HEAP_VERIFIER
|
||||||
|
@ -182,7 +184,7 @@ FrLdrHeapRelease(
|
||||||
PHEAP Heap = HeapHandle;
|
PHEAP Heap = HeapHandle;
|
||||||
PHEAP_BLOCK Block;
|
PHEAP_BLOCK Block;
|
||||||
PUCHAR StartAddress, EndAddress;
|
PUCHAR StartAddress, EndAddress;
|
||||||
PFN_COUNT FreePages, AllFreePages = 0;
|
PFN_COUNT FreePages, AllPages, AllFreePages = 0;
|
||||||
TRACE("HeapRelease(%p)\n", HeapHandle);
|
TRACE("HeapRelease(%p)\n", HeapHandle);
|
||||||
|
|
||||||
/* Loop all heap chunks */
|
/* Loop all heap chunks */
|
||||||
|
@ -238,7 +240,8 @@ FrLdrHeapRelease(
|
||||||
if (Block->Size == 0) break;
|
if (Block->Size == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("HeapRelease() done, freed %ld pages\n", AllFreePages);
|
AllPages = Heap->MaximumSize / MM_PAGE_SIZE;
|
||||||
|
TRACE("HeapRelease() done, freed %lu of %lu pages\n", AllFreePages, AllPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -256,7 +259,7 @@ FrLdrHeapCleanupAll(VOID)
|
||||||
Heap->AllocationTime, Heap->FreeTime, Heap->AllocationTime + Heap->FreeTime);
|
Heap->AllocationTime, Heap->FreeTime, Heap->AllocationTime + Heap->FreeTime);
|
||||||
|
|
||||||
|
|
||||||
/* Release fre pages */
|
/* Release free pages from the default heap */
|
||||||
FrLdrHeapRelease(FrLdrDefaultHeap);
|
FrLdrHeapRelease(FrLdrDefaultHeap);
|
||||||
|
|
||||||
Heap = FrLdrTempHeap;
|
Heap = FrLdrTempHeap;
|
||||||
|
@ -266,7 +269,7 @@ FrLdrHeapCleanupAll(VOID)
|
||||||
Heap->CurrentAllocBytes, Heap->MaxAllocBytes, Heap->LargestAllocation,
|
Heap->CurrentAllocBytes, Heap->MaxAllocBytes, Heap->LargestAllocation,
|
||||||
Heap->NumAllocs, Heap->NumFrees);
|
Heap->NumAllocs, Heap->NumFrees);
|
||||||
|
|
||||||
/* Destroy the heap */
|
/* Destroy the temp heap */
|
||||||
FrLdrHeapDestroy(FrLdrTempHeap);
|
FrLdrHeapDestroy(FrLdrTempHeap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +314,7 @@ FrLdrHeapInsertFreeList(
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
FrLdrHeapAllocate(
|
FrLdrHeapAllocateEx(
|
||||||
PVOID HeapHandle,
|
PVOID HeapHandle,
|
||||||
SIZE_T ByteSize,
|
SIZE_T ByteSize,
|
||||||
ULONG Tag)
|
ULONG Tag)
|
||||||
|
@ -426,7 +429,7 @@ FrLdrHeapAllocate(
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
FrLdrHeapFree(
|
FrLdrHeapFreeEx(
|
||||||
PVOID HeapHandle,
|
PVOID HeapHandle,
|
||||||
PVOID Pointer,
|
PVOID Pointer,
|
||||||
ULONG Tag)
|
ULONG Tag)
|
||||||
|
@ -471,6 +474,11 @@ FrLdrHeapFree(
|
||||||
/* Mark as free */
|
/* Mark as free */
|
||||||
Block->Tag = 0;
|
Block->Tag = 0;
|
||||||
|
|
||||||
|
#if DBG
|
||||||
|
/* Erase contents */
|
||||||
|
RtlFillMemory(Block->Data, Block->Size * sizeof(HEAP_BLOCK), 0xCCCCCCCC);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Update heap usage */
|
/* Update heap usage */
|
||||||
Heap->NumFrees++;
|
Heap->NumFrees++;
|
||||||
Heap->CurrentAllocBytes -= Block->Size * sizeof(HEAP_BLOCK);
|
Heap->CurrentAllocBytes -= Block->Size * sizeof(HEAP_BLOCK);
|
||||||
|
@ -530,18 +538,6 @@ MmInitializeHeap(PVOID PageLookupTable)
|
||||||
FrLdrDefaultHeap, FrLdrTempHeap);
|
FrLdrDefaultHeap, FrLdrTempHeap);
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID
|
|
||||||
MmHeapAlloc(SIZE_T MemorySize)
|
|
||||||
{
|
|
||||||
return FrLdrHeapAllocate(FrLdrDefaultHeap, MemorySize, 'pHmM');
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
|
||||||
MmHeapFree(PVOID MemoryPointer)
|
|
||||||
{
|
|
||||||
FrLdrHeapFree(FrLdrDefaultHeap, MemoryPointer, 'pHmM');
|
|
||||||
}
|
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
NTAPI
|
NTAPI
|
||||||
ExAllocatePoolWithTag(
|
ExAllocatePoolWithTag(
|
||||||
|
@ -549,7 +545,7 @@ ExAllocatePoolWithTag(
|
||||||
IN SIZE_T NumberOfBytes,
|
IN SIZE_T NumberOfBytes,
|
||||||
IN ULONG Tag)
|
IN ULONG Tag)
|
||||||
{
|
{
|
||||||
return FrLdrHeapAllocate(FrLdrDefaultHeap, NumberOfBytes, Tag);
|
return FrLdrHeapAllocateEx(FrLdrDefaultHeap, NumberOfBytes, Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
|
@ -558,7 +554,7 @@ ExAllocatePool(
|
||||||
IN POOL_TYPE PoolType,
|
IN POOL_TYPE PoolType,
|
||||||
IN SIZE_T NumberOfBytes)
|
IN SIZE_T NumberOfBytes)
|
||||||
{
|
{
|
||||||
return FrLdrHeapAllocate(FrLdrDefaultHeap, NumberOfBytes, 0);
|
return FrLdrHeapAllocateEx(FrLdrDefaultHeap, NumberOfBytes, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -566,7 +562,7 @@ NTAPI
|
||||||
ExFreePool(
|
ExFreePool(
|
||||||
IN PVOID P)
|
IN PVOID P)
|
||||||
{
|
{
|
||||||
FrLdrHeapFree(FrLdrDefaultHeap, P, 0);
|
FrLdrHeapFreeEx(FrLdrDefaultHeap, P, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -575,7 +571,7 @@ ExFreePoolWithTag(
|
||||||
IN PVOID P,
|
IN PVOID P,
|
||||||
IN ULONG Tag)
|
IN ULONG Tag)
|
||||||
{
|
{
|
||||||
FrLdrHeapFree(FrLdrDefaultHeap, P, Tag);
|
FrLdrHeapFreeEx(FrLdrDefaultHeap, P, Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
|
@ -587,7 +583,7 @@ RtlAllocateHeap(
|
||||||
{
|
{
|
||||||
PVOID ptr;
|
PVOID ptr;
|
||||||
|
|
||||||
ptr = FrLdrHeapAllocate(FrLdrDefaultHeap, Size, ' ltR');
|
ptr = FrLdrHeapAllocateEx(FrLdrDefaultHeap, Size, ' ltR');
|
||||||
if (ptr && (Flags & HEAP_ZERO_MEMORY))
|
if (ptr && (Flags & HEAP_ZERO_MEMORY))
|
||||||
{
|
{
|
||||||
RtlZeroMemory(ptr, Size);
|
RtlZeroMemory(ptr, Size);
|
||||||
|
@ -603,6 +599,6 @@ RtlFreeHeap(
|
||||||
IN ULONG Flags,
|
IN ULONG Flags,
|
||||||
IN PVOID HeapBase)
|
IN PVOID HeapBase)
|
||||||
{
|
{
|
||||||
FrLdrHeapFree(FrLdrDefaultHeap, HeapBase, ' ltR');
|
FrLdrHeapFreeEx(FrLdrDefaultHeap, HeapBase, ' ltR');
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,6 @@ PFN_NUMBER MmHighestPhysicalPage = 0;
|
||||||
PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap;
|
PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap;
|
||||||
ULONG BiosMemoryMapEntryCount;
|
ULONG BiosMemoryMapEntryCount;
|
||||||
|
|
||||||
extern ULONG_PTR MmHeapPointer;
|
|
||||||
extern ULONG_PTR MmHeapStart;
|
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
AddMemoryDescriptor(
|
AddMemoryDescriptor(
|
||||||
IN OUT PFREELDR_MEMORY_DESCRIPTOR List,
|
IN OUT PFREELDR_MEMORY_DESCRIPTOR List,
|
||||||
|
|
|
@ -19,13 +19,16 @@
|
||||||
|
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
|
|
||||||
|
#define TAG_STRING ' rtS'
|
||||||
|
#define TAG_OS_ITEM 'tISO'
|
||||||
|
|
||||||
static PCSTR CopyString(PCSTR Source)
|
static PCSTR CopyString(PCSTR Source)
|
||||||
{
|
{
|
||||||
PSTR Dest;
|
PSTR Dest;
|
||||||
|
|
||||||
if (!Source)
|
if (!Source)
|
||||||
return NULL;
|
return NULL;
|
||||||
Dest = MmHeapAlloc(strlen(Source) + 1);
|
Dest = FrLdrHeapAlloc(strlen(Source) + 1, TAG_STRING);
|
||||||
if (Dest)
|
if (Dest)
|
||||||
{
|
{
|
||||||
strcpy(Dest, Source);
|
strcpy(Dest, Source);
|
||||||
|
@ -61,7 +64,7 @@ OperatingSystemItem* InitOperatingSystemList(ULONG* OperatingSystemCountPointer)
|
||||||
//
|
//
|
||||||
// Allocate memory to hold operating system lists
|
// Allocate memory to hold operating system lists
|
||||||
//
|
//
|
||||||
Items = MmHeapAlloc(Count * sizeof(OperatingSystemItem));
|
Items = FrLdrHeapAlloc(Count * sizeof(OperatingSystemItem), TAG_OS_ITEM);
|
||||||
if (!Items)
|
if (!Items)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -18,6 +18,9 @@ PCONFIGURATION_COMPONENT_DATA FldrArcHwTreeRoot;
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
#define TAG_HW_COMPONENT_DATA 'DCwH'
|
||||||
|
#define TAG_HW_NAME 'mNwH'
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
NTAPI
|
NTAPI
|
||||||
FldrpHwHeapAlloc(IN SIZE_T Size)
|
FldrpHwHeapAlloc(IN SIZE_T Size)
|
||||||
|
@ -25,7 +28,7 @@ FldrpHwHeapAlloc(IN SIZE_T Size)
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
|
|
||||||
/* Allocate memory from generic bootloader heap */
|
/* Allocate memory from generic bootloader heap */
|
||||||
Buffer = MmHeapAlloc(Size);
|
Buffer = FrLdrHeapAlloc(Size, 'pHwH');
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +43,7 @@ FldrSetIdentifier(IN PCONFIGURATION_COMPONENT_DATA ComponentData,
|
||||||
|
|
||||||
/* Allocate memory for the identifier */
|
/* Allocate memory for the identifier */
|
||||||
IdentifierLength = strlen(IdentifierString) + 1;
|
IdentifierLength = strlen(IdentifierString) + 1;
|
||||||
Identifier = MmHeapAlloc(IdentifierLength);
|
Identifier = FrLdrHeapAlloc(IdentifierLength, TAG_HW_NAME);
|
||||||
if (!Identifier) return;
|
if (!Identifier) return;
|
||||||
|
|
||||||
/* Copy the identifier */
|
/* Copy the identifier */
|
||||||
|
@ -58,7 +61,8 @@ FldrCreateSystemKey(OUT PCONFIGURATION_COMPONENT_DATA *SystemNode)
|
||||||
PCONFIGURATION_COMPONENT Component;
|
PCONFIGURATION_COMPONENT Component;
|
||||||
|
|
||||||
/* Allocate the root */
|
/* Allocate the root */
|
||||||
FldrArcHwTreeRoot = MmHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA));
|
FldrArcHwTreeRoot = FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA),
|
||||||
|
TAG_HW_COMPONENT_DATA);
|
||||||
if (!FldrArcHwTreeRoot) return;
|
if (!FldrArcHwTreeRoot) return;
|
||||||
|
|
||||||
/* Set it up */
|
/* Set it up */
|
||||||
|
@ -125,7 +129,8 @@ FldrCreateComponentKey(IN PCONFIGURATION_COMPONENT_DATA SystemNode,
|
||||||
PCONFIGURATION_COMPONENT Component;
|
PCONFIGURATION_COMPONENT Component;
|
||||||
|
|
||||||
/* Allocate the node for this component */
|
/* Allocate the node for this component */
|
||||||
ComponentData = MmHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA));
|
ComponentData = FrLdrHeapAlloc(sizeof(CONFIGURATION_COMPONENT_DATA),
|
||||||
|
TAG_HW_COMPONENT_DATA);
|
||||||
if (!ComponentData) return;
|
if (!ComponentData) return;
|
||||||
|
|
||||||
/* Now save our parent */
|
/* Now save our parent */
|
||||||
|
|
|
@ -35,7 +35,7 @@ PVOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CmpAllocate (SIZE_T Size, BOOLEAN Paged, ULONG Tag)
|
CmpAllocate (SIZE_T Size, BOOLEAN Paged, ULONG Tag)
|
||||||
{
|
{
|
||||||
return MmHeapAlloc(Size);
|
return FrLdrHeapAllocateEx(FrLdrDefaultHeap, Size, Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
CmpFree (PVOID Ptr, IN ULONG Quota)
|
CmpFree (PVOID Ptr, IN ULONG Quota)
|
||||||
{
|
{
|
||||||
MmHeapFree(Ptr);
|
FrLdrHeapFreeEx(FrLdrDefaultHeap, Ptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -68,7 +68,7 @@ RegImportValue (
|
||||||
|
|
||||||
if (ValueCell->Flags & VALUE_COMP_NAME)
|
if (ValueCell->Flags & VALUE_COMP_NAME)
|
||||||
{
|
{
|
||||||
wName = MmHeapAlloc ((ValueCell->NameLength + 1) * sizeof(WCHAR));
|
wName = FrLdrTempAlloc((ValueCell->NameLength + 1) * sizeof(WCHAR), TAG_REG_NAME);
|
||||||
for (i = 0; i < ValueCell->NameLength; i++)
|
for (i = 0; i < ValueCell->NameLength; i++)
|
||||||
{
|
{
|
||||||
wName[i] = ((PCHAR)ValueCell->Name)[i];
|
wName[i] = ((PCHAR)ValueCell->Name)[i];
|
||||||
|
@ -77,7 +77,7 @@ RegImportValue (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wName = MmHeapAlloc(ValueCell->NameLength + sizeof(WCHAR));
|
wName = FrLdrTempAlloc(ValueCell->NameLength + sizeof(WCHAR), TAG_REG_NAME);
|
||||||
memcpy(wName, ValueCell->Name, ValueCell->NameLength);
|
memcpy(wName, ValueCell->Name, ValueCell->NameLength);
|
||||||
wName[ValueCell->NameLength / sizeof(WCHAR)] = 0;
|
wName[ValueCell->NameLength / sizeof(WCHAR)] = 0;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ RegImportValue (
|
||||||
if (Error != ERROR_SUCCESS)
|
if (Error != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("RegSetValue() failed!\n");
|
ERR("RegSetValue() failed!\n");
|
||||||
MmHeapFree(wName);
|
FrLdrTempFree(wName, TAG_REG_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,12 +115,12 @@ RegImportValue (
|
||||||
if (Error != ERROR_SUCCESS)
|
if (Error != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("RegSetValue() failed!\n");
|
ERR("RegSetValue() failed!\n");
|
||||||
MmHeapFree(wName);
|
FrLdrTempFree(wName, TAG_REG_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(wName);
|
FrLdrTempFree(wName, TAG_REG_NAME);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ RegImportSubKey(
|
||||||
|
|
||||||
if (KeyCell->Flags & KEY_COMP_NAME)
|
if (KeyCell->Flags & KEY_COMP_NAME)
|
||||||
{
|
{
|
||||||
wName = MmHeapAlloc((KeyCell->NameLength + 1) * sizeof(WCHAR));
|
wName = FrLdrTempAlloc((KeyCell->NameLength + 1) * sizeof(WCHAR), TAG_REG_NAME);
|
||||||
for (i = 0; i < KeyCell->NameLength; i++)
|
for (i = 0; i < KeyCell->NameLength; i++)
|
||||||
{
|
{
|
||||||
wName[i] = ((PCHAR)KeyCell->Name)[i];
|
wName[i] = ((PCHAR)KeyCell->Name)[i];
|
||||||
|
@ -208,7 +208,7 @@ RegImportSubKey(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wName = MmHeapAlloc(KeyCell->NameLength + sizeof(WCHAR));
|
wName = FrLdrTempAlloc(KeyCell->NameLength + sizeof(WCHAR), TAG_REG_NAME);
|
||||||
memcpy(wName, KeyCell->Name, KeyCell->NameLength);
|
memcpy(wName, KeyCell->Name, KeyCell->NameLength);
|
||||||
wName[KeyCell->NameLength / sizeof(WCHAR)] = 0;
|
wName[KeyCell->NameLength / sizeof(WCHAR)] = 0;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ RegImportSubKey(
|
||||||
|
|
||||||
/* Create new sub key */
|
/* Create new sub key */
|
||||||
Error = RegCreateKey(ParentKey, wName, &SubKey);
|
Error = RegCreateKey(ParentKey, wName, &SubKey);
|
||||||
MmHeapFree(wName);
|
FrLdrTempFree(wName, TAG_REG_NAME);
|
||||||
if (Error != ERROR_SUCCESS)
|
if (Error != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ERR("RegCreateKey() failed!\n");
|
ERR("RegCreateKey() failed!\n");
|
||||||
|
|
|
@ -29,7 +29,7 @@ VOID
|
||||||
RegInitializeRegistry (VOID)
|
RegInitializeRegistry (VOID)
|
||||||
{
|
{
|
||||||
/* Create root key */
|
/* Create root key */
|
||||||
RootKey = MmHeapAlloc(sizeof(KEY));
|
RootKey = FrLdrHeapAlloc(sizeof(KEY), TAG_REG_KEY);
|
||||||
|
|
||||||
InitializeListHead(&RootKey->SubKeyList);
|
InitializeListHead(&RootKey->SubKeyList);
|
||||||
InitializeListHead(&RootKey->ValueList);
|
InitializeListHead(&RootKey->ValueList);
|
||||||
|
@ -39,7 +39,7 @@ RegInitializeRegistry (VOID)
|
||||||
RootKey->ValueCount = 0;
|
RootKey->ValueCount = 0;
|
||||||
|
|
||||||
RootKey->NameSize = 4;
|
RootKey->NameSize = 4;
|
||||||
RootKey->Name = MmHeapAlloc(4);
|
RootKey->Name = FrLdrHeapAlloc(4, TAG_REG_NAME);
|
||||||
wcscpy (RootKey->Name, L"\\");
|
wcscpy (RootKey->Name, L"\\");
|
||||||
|
|
||||||
RootKey->DataType = 0;
|
RootKey->DataType = 0;
|
||||||
|
@ -242,7 +242,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
|
||||||
if (CmpResult != 0)
|
if (CmpResult != 0)
|
||||||
{
|
{
|
||||||
/* no key found -> create new subkey */
|
/* no key found -> create new subkey */
|
||||||
NewKey = MmHeapAlloc(sizeof(KEY));
|
NewKey = FrLdrHeapAlloc(sizeof(KEY), TAG_REG_KEY);
|
||||||
if (NewKey == NULL) return ERROR_OUTOFMEMORY;
|
if (NewKey == NULL) return ERROR_OUTOFMEMORY;
|
||||||
|
|
||||||
InitializeListHead(&NewKey->SubKeyList);
|
InitializeListHead(&NewKey->SubKeyList);
|
||||||
|
@ -259,7 +259,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
|
||||||
CurrentKey->SubKeyCount++;
|
CurrentKey->SubKeyCount++;
|
||||||
|
|
||||||
NewKey->NameSize = NameSize;
|
NewKey->NameSize = NameSize;
|
||||||
NewKey->Name = (PWCHAR)MmHeapAlloc(NewKey->NameSize);
|
NewKey->Name = (PWCHAR)FrLdrHeapAlloc(NewKey->NameSize, TAG_REG_NAME);
|
||||||
if (NewKey->Name == NULL) return ERROR_OUTOFMEMORY;
|
if (NewKey->Name == NULL) return ERROR_OUTOFMEMORY;
|
||||||
|
|
||||||
memcpy(NewKey->Name, name, NewKey->NameSize - sizeof(WCHAR));
|
memcpy(NewKey->Name, name, NewKey->NameSize - sizeof(WCHAR));
|
||||||
|
@ -452,7 +452,7 @@ RegSetValue(FRLDRHKEY Key,
|
||||||
/* set default value */
|
/* set default value */
|
||||||
if ((Key->Data != NULL) && (Key->DataSize > sizeof(PUCHAR)))
|
if ((Key->Data != NULL) && (Key->DataSize > sizeof(PUCHAR)))
|
||||||
{
|
{
|
||||||
MmHeapFree(Key->Data);
|
FrLdrHeapFree(Key->Data, TAG_REG_KEY_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataSize <= sizeof(PUCHAR))
|
if (DataSize <= sizeof(PUCHAR))
|
||||||
|
@ -463,7 +463,7 @@ RegSetValue(FRLDRHKEY Key,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Key->Data = MmHeapAlloc(DataSize);
|
Key->Data = FrLdrHeapAlloc(DataSize, TAG_REG_KEY_DATA);
|
||||||
Key->DataSize = DataSize;
|
Key->DataSize = DataSize;
|
||||||
Key->DataType = Type;
|
Key->DataType = Type;
|
||||||
memcpy(Key->Data, Data, DataSize);
|
memcpy(Key->Data, Data, DataSize);
|
||||||
|
@ -489,14 +489,14 @@ RegSetValue(FRLDRHKEY Key,
|
||||||
/* add new value */
|
/* add new value */
|
||||||
TRACE("No value found - adding new value\n");
|
TRACE("No value found - adding new value\n");
|
||||||
|
|
||||||
Value = (PVALUE)MmHeapAlloc(sizeof(VALUE));
|
Value = (PVALUE)FrLdrHeapAlloc(sizeof(VALUE), TAG_REG_VALUE);
|
||||||
if (Value == NULL) return ERROR_OUTOFMEMORY;
|
if (Value == NULL) return ERROR_OUTOFMEMORY;
|
||||||
|
|
||||||
InsertTailList(&Key->ValueList, &Value->ValueList);
|
InsertTailList(&Key->ValueList, &Value->ValueList);
|
||||||
Key->ValueCount++;
|
Key->ValueCount++;
|
||||||
|
|
||||||
Value->NameSize = (ULONG)(wcslen(ValueName)+1) * sizeof(WCHAR);
|
Value->NameSize = (ULONG)(wcslen(ValueName)+1) * sizeof(WCHAR);
|
||||||
Value->Name = MmHeapAlloc(Value->NameSize);
|
Value->Name = FrLdrHeapAlloc(Value->NameSize, TAG_REG_NAME);
|
||||||
if (Value->Name == NULL) return ERROR_OUTOFMEMORY;
|
if (Value->Name == NULL) return ERROR_OUTOFMEMORY;
|
||||||
wcscpy(Value->Name, ValueName);
|
wcscpy(Value->Name, ValueName);
|
||||||
Value->DataType = REG_NONE;
|
Value->DataType = REG_NONE;
|
||||||
|
@ -507,7 +507,7 @@ RegSetValue(FRLDRHKEY Key,
|
||||||
/* set new value */
|
/* set new value */
|
||||||
if ((Value->Data != NULL) && (Value->DataSize > sizeof(PUCHAR)))
|
if ((Value->Data != NULL) && (Value->DataSize > sizeof(PUCHAR)))
|
||||||
{
|
{
|
||||||
MmHeapFree(Value->Data);
|
FrLdrHeapFree(Value->Data, TAG_REG_KEY_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataSize <= sizeof(PUCHAR))
|
if (DataSize <= sizeof(PUCHAR))
|
||||||
|
@ -518,7 +518,7 @@ RegSetValue(FRLDRHKEY Key,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Value->Data = MmHeapAlloc(DataSize);
|
Value->Data = FrLdrHeapAlloc(DataSize, TAG_REG_KEY_DATA);
|
||||||
if (Value->Data == NULL) return ERROR_OUTOFMEMORY;
|
if (Value->Data == NULL) return ERROR_OUTOFMEMORY;
|
||||||
Value->DataType = Type;
|
Value->DataType = Type;
|
||||||
Value->DataSize = DataSize;
|
Value->DataSize = DataSize;
|
||||||
|
@ -620,7 +620,7 @@ RegDeleteValue(FRLDRHKEY Key,
|
||||||
if ((ValueName == NULL) || (*ValueName == 0))
|
if ((ValueName == NULL) || (*ValueName == 0))
|
||||||
{
|
{
|
||||||
/* delete default value */
|
/* delete default value */
|
||||||
if (Key->Data != NULL) MmFreeMemory(Key->Data);
|
if (Key->Data != NULL) FrLdrHeapFree(Key->Data, TAG_REG_KEY_DATA);
|
||||||
Key->Data = NULL;
|
Key->Data = NULL;
|
||||||
Key->DataSize = 0;
|
Key->DataSize = 0;
|
||||||
Key->DataType = 0;
|
Key->DataType = 0;
|
||||||
|
@ -641,20 +641,20 @@ RegDeleteValue(FRLDRHKEY Key,
|
||||||
|
|
||||||
/* delete value */
|
/* delete value */
|
||||||
Key->ValueCount--;
|
Key->ValueCount--;
|
||||||
if (Value->Name != NULL) MmFreeMemory(Value->Name);
|
if (Value->Name != NULL) FrLdrHeapFree(Value->Name, TAG_REG_NAME);
|
||||||
Value->Name = NULL;
|
Value->Name = NULL;
|
||||||
Value->NameSize = 0;
|
Value->NameSize = 0;
|
||||||
|
|
||||||
if (Value->DataSize > sizeof(PUCHAR))
|
if (Value->DataSize > sizeof(PUCHAR))
|
||||||
{
|
{
|
||||||
if (Value->Data != NULL) MmFreeMemory(Value->Data);
|
if (Value->Data != NULL) FrLdrHeapFree(Value->Data, TAG_REG_KEY_DATA);
|
||||||
}
|
}
|
||||||
Value->Data = NULL;
|
Value->Data = NULL;
|
||||||
Value->DataSize = 0;
|
Value->DataSize = 0;
|
||||||
Value->DataType = 0;
|
Value->DataType = 0;
|
||||||
|
|
||||||
RemoveEntryList(&Value->ValueList);
|
RemoveEntryList(&Value->ValueList);
|
||||||
MmFreeMemory(Value);
|
FrLdrHeapFree(Value, TAG_REG_VALUE);
|
||||||
}
|
}
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ NTAPI
|
||||||
RtlpAllocateMemory(ULONG Bytes,
|
RtlpAllocateMemory(ULONG Bytes,
|
||||||
ULONG Tag)
|
ULONG Tag)
|
||||||
{
|
{
|
||||||
return MmHeapAlloc(Bytes);
|
return FrLdrHeapAllocateEx(FrLdrDefaultHeap, Bytes, Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ NTAPI
|
||||||
RtlpFreeMemory(PVOID Mem,
|
RtlpFreeMemory(PVOID Mem,
|
||||||
ULONG Tag)
|
ULONG Tag)
|
||||||
{
|
{
|
||||||
MmHeapFree(Mem);
|
FrLdrHeapFreeEx(FrLdrDefaultHeap, Mem, Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
#ifndef _M_ARM
|
#ifndef _M_ARM
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
|
|
||||||
|
#define TAG_TUI_SCREENBUFFER 'SiuT'
|
||||||
|
#define TAG_TAG_TUI_PALETTE 'PiuT'
|
||||||
|
|
||||||
PVOID TextVideoBuffer = NULL;
|
PVOID TextVideoBuffer = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -542,7 +545,8 @@ VOID TuiMessageBox(PCSTR MessageText)
|
||||||
PVOID ScreenBuffer;
|
PVOID ScreenBuffer;
|
||||||
|
|
||||||
// Save the screen contents
|
// Save the screen contents
|
||||||
ScreenBuffer = MmHeapAlloc(UiScreenWidth * UiScreenHeight * 2);
|
ScreenBuffer = FrLdrTempAlloc(UiScreenWidth * UiScreenHeight * 2,
|
||||||
|
TAG_TUI_SCREENBUFFER);
|
||||||
TuiSaveScreen(ScreenBuffer);
|
TuiSaveScreen(ScreenBuffer);
|
||||||
|
|
||||||
// Display the message box
|
// Display the message box
|
||||||
|
@ -550,7 +554,7 @@ VOID TuiMessageBox(PCSTR MessageText)
|
||||||
|
|
||||||
// Restore the screen contents
|
// Restore the screen contents
|
||||||
TuiRestoreScreen(ScreenBuffer);
|
TuiRestoreScreen(ScreenBuffer);
|
||||||
MmHeapFree(ScreenBuffer);
|
FrLdrTempFree(ScreenBuffer, TAG_TUI_SCREENBUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID TuiMessageBoxCritical(PCSTR MessageText)
|
VOID TuiMessageBoxCritical(PCSTR MessageText)
|
||||||
|
@ -758,7 +762,8 @@ VOID TuiFadeInBackdrop(VOID)
|
||||||
|
|
||||||
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
|
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
|
||||||
{
|
{
|
||||||
TuiFadePalette = (PPALETTE_ENTRY)MmHeapAlloc(sizeof(PALETTE_ENTRY) * 64);
|
TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
|
||||||
|
TAG_TAG_TUI_PALETTE);
|
||||||
|
|
||||||
if (TuiFadePalette != NULL)
|
if (TuiFadePalette != NULL)
|
||||||
{
|
{
|
||||||
|
@ -773,7 +778,7 @@ VOID TuiFadeInBackdrop(VOID)
|
||||||
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
|
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
|
||||||
{
|
{
|
||||||
VideoFadeIn(TuiFadePalette, 64);
|
VideoFadeIn(TuiFadePalette, 64);
|
||||||
MmHeapFree(TuiFadePalette);
|
FrLdrTempFree(TuiFadePalette, TAG_TAG_TUI_PALETTE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +788,8 @@ VOID TuiFadeOut(VOID)
|
||||||
|
|
||||||
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
|
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
|
||||||
{
|
{
|
||||||
TuiFadePalette = (PPALETTE_ENTRY)MmHeapAlloc(sizeof(PALETTE_ENTRY) * 64);
|
TuiFadePalette = (PPALETTE_ENTRY)FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * 64,
|
||||||
|
TAG_TAG_TUI_PALETTE);
|
||||||
|
|
||||||
if (TuiFadePalette != NULL)
|
if (TuiFadePalette != NULL)
|
||||||
{
|
{
|
||||||
|
@ -801,7 +807,7 @@ VOID TuiFadeOut(VOID)
|
||||||
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
|
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
|
||||||
{
|
{
|
||||||
VideoRestorePaletteState(TuiFadePalette, 64);
|
VideoRestorePaletteState(TuiFadePalette, 64);
|
||||||
MmHeapFree(TuiFadePalette);
|
FrLdrTempFree(TuiFadePalette, TAG_TAG_TUI_PALETTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -826,7 +832,8 @@ BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
|
||||||
PVOID ScreenBuffer;
|
PVOID ScreenBuffer;
|
||||||
|
|
||||||
// Save the screen contents
|
// Save the screen contents
|
||||||
ScreenBuffer = MmHeapAlloc(UiScreenWidth * UiScreenHeight * 2);
|
ScreenBuffer = FrLdrTempAlloc(UiScreenWidth * UiScreenHeight * 2,
|
||||||
|
TAG_TUI_SCREENBUFFER);
|
||||||
TuiSaveScreen(ScreenBuffer);
|
TuiSaveScreen(ScreenBuffer);
|
||||||
|
|
||||||
// Find the height
|
// Find the height
|
||||||
|
@ -1029,7 +1036,7 @@ BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
|
||||||
|
|
||||||
// Restore the screen contents
|
// Restore the screen contents
|
||||||
TuiRestoreScreen(ScreenBuffer);
|
TuiRestoreScreen(ScreenBuffer);
|
||||||
MmHeapFree(ScreenBuffer);
|
FrLdrTempFree(ScreenBuffer, TAG_TUI_SCREENBUFFER);
|
||||||
|
|
||||||
return ReturnCode;
|
return ReturnCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#define TAG_UI_TEXT 'xTiU'
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(UI);
|
DBG_DEFAULT_CHANNEL(UI);
|
||||||
|
|
||||||
ULONG UiScreenWidth; // Screen Width
|
ULONG UiScreenWidth; // Screen Width
|
||||||
|
@ -401,7 +403,7 @@ VOID UiShowMessageBoxesInSection(PCSTR SectionName)
|
||||||
//if (MessageBoxTextSize > 0)
|
//if (MessageBoxTextSize > 0)
|
||||||
{
|
{
|
||||||
// Allocate enough memory to hold the text
|
// Allocate enough memory to hold the text
|
||||||
MessageBoxText = MmHeapAlloc(MessageBoxTextSize);
|
MessageBoxText = FrLdrTempAlloc(MessageBoxTextSize, TAG_UI_TEXT);
|
||||||
|
|
||||||
if (MessageBoxText)
|
if (MessageBoxText)
|
||||||
{
|
{
|
||||||
|
@ -415,7 +417,7 @@ VOID UiShowMessageBoxesInSection(PCSTR SectionName)
|
||||||
UiMessageBox(MessageBoxText);
|
UiMessageBox(MessageBoxText);
|
||||||
|
|
||||||
// Free the memory
|
// Free the memory
|
||||||
MmHeapFree(MessageBoxText);
|
FrLdrTempFree(MessageBoxText, TAG_UI_TEXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,9 @@
|
||||||
#ifndef _M_ARM
|
#ifndef _M_ARM
|
||||||
#include <freeldr.h>
|
#include <freeldr.h>
|
||||||
|
|
||||||
#define RGB_MAX 64
|
#define RGB_MAX 64
|
||||||
#define RGB_MAX_PER_ITERATION 64
|
#define RGB_MAX_PER_ITERATION 64
|
||||||
|
#define TAG_PALETTE_COLORS 'claP'
|
||||||
|
|
||||||
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
|
VOID VideoSetAllColorsToBlack(ULONG ColorCount)
|
||||||
{
|
{
|
||||||
|
@ -40,7 +41,7 @@ VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
|
||||||
UCHAR Color;
|
UCHAR Color;
|
||||||
PPALETTE_ENTRY PaletteColors;
|
PPALETTE_ENTRY PaletteColors;
|
||||||
|
|
||||||
PaletteColors = MmHeapAlloc(sizeof(PALETTE_ENTRY) * ColorCount);
|
PaletteColors = FrLdrTempAlloc(sizeof(PALETTE_ENTRY) * ColorCount, TAG_PALETTE_COLORS);
|
||||||
if (!PaletteColors) return;
|
if (!PaletteColors) return;
|
||||||
|
|
||||||
for (Index=0; Index<RGB_MAX; Index++)
|
for (Index=0; Index<RGB_MAX; Index++)
|
||||||
|
@ -91,7 +92,7 @@ VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MmHeapFree(PaletteColors);
|
FrLdrTempFree(PaletteColors, TAG_PALETTE_COLORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID VideoFadeOut(ULONG ColorCount)
|
VOID VideoFadeOut(ULONG ColorCount)
|
||||||
|
|
|
@ -183,7 +183,8 @@ WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
|
||||||
BaseDllName, FullDllName, BasePA);
|
BaseDllName, FullDllName, BasePA);
|
||||||
|
|
||||||
/* Allocate memory for a data table entry, zero-initialize it */
|
/* Allocate memory for a data table entry, zero-initialize it */
|
||||||
DataTableEntry = (PLDR_DATA_TABLE_ENTRY)MmHeapAlloc(sizeof(LDR_DATA_TABLE_ENTRY));
|
DataTableEntry = (PLDR_DATA_TABLE_ENTRY)FrLdrHeapAlloc(sizeof(LDR_DATA_TABLE_ENTRY),
|
||||||
|
TAG_WLDR_DTE);
|
||||||
if (DataTableEntry == NULL)
|
if (DataTableEntry == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
RtlZeroMemory(DataTableEntry, sizeof(LDR_DATA_TABLE_ENTRY));
|
RtlZeroMemory(DataTableEntry, sizeof(LDR_DATA_TABLE_ENTRY));
|
||||||
|
@ -201,10 +202,10 @@ WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
|
||||||
/* Initialize BaseDllName field (UNICODE_STRING) from the Ansi BaseDllName
|
/* Initialize BaseDllName field (UNICODE_STRING) from the Ansi BaseDllName
|
||||||
by simple conversion - copying each character */
|
by simple conversion - copying each character */
|
||||||
Length = (USHORT)(strlen(BaseDllName) * sizeof(WCHAR));
|
Length = (USHORT)(strlen(BaseDllName) * sizeof(WCHAR));
|
||||||
Buffer = (PWSTR)MmHeapAlloc(Length);
|
Buffer = (PWSTR)FrLdrHeapAlloc(Length, TAG_WLDR_NAME);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(DataTableEntry);
|
FrLdrHeapFree(DataTableEntry, TAG_WLDR_DTE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
RtlZeroMemory(Buffer, Length);
|
RtlZeroMemory(Buffer, Length);
|
||||||
|
@ -220,10 +221,10 @@ WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
|
||||||
/* Initialize FullDllName field (UNICODE_STRING) from the Ansi FullDllName
|
/* Initialize FullDllName field (UNICODE_STRING) from the Ansi FullDllName
|
||||||
using the same method */
|
using the same method */
|
||||||
Length = (USHORT)(strlen(FullDllName) * sizeof(WCHAR));
|
Length = (USHORT)(strlen(FullDllName) * sizeof(WCHAR));
|
||||||
Buffer = (PWSTR)MmHeapAlloc(Length);
|
Buffer = (PWSTR)FrLdrHeapAlloc(Length, TAG_WLDR_NAME);
|
||||||
if (Buffer == NULL)
|
if (Buffer == NULL)
|
||||||
{
|
{
|
||||||
MmHeapFree(DataTableEntry);
|
FrLdrHeapFree(DataTableEntry, TAG_WLDR_DTE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
RtlZeroMemory(Buffer, Length);
|
RtlZeroMemory(Buffer, Length);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
DBG_DEFAULT_CHANNEL(WINDOWS);
|
DBG_DEFAULT_CHANNEL(WINDOWS);
|
||||||
|
#define TAG_BOOT_OPTIONS 'pOtB'
|
||||||
|
|
||||||
void
|
void
|
||||||
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
|
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||||
|
@ -139,7 +140,8 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
{
|
{
|
||||||
CHAR FileName[512];
|
CHAR FileName[512];
|
||||||
CHAR BootPath[512];
|
CHAR BootPath[512];
|
||||||
LPCSTR LoadOptions, BootOptions;
|
LPCSTR LoadOptions;
|
||||||
|
LPSTR BootOptions;
|
||||||
BOOLEAN BootFromFloppy;
|
BOOLEAN BootFromFloppy;
|
||||||
ULONG i, ErrorLine;
|
ULONG i, ErrorLine;
|
||||||
HINF InfHandle;
|
HINF InfHandle;
|
||||||
|
@ -199,17 +201,21 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BootOptions = LoadOptions;
|
|
||||||
|
|
||||||
#if DBG
|
#if DBG
|
||||||
/* Get debug load options and use them */
|
/* Get debug load options and use them */
|
||||||
if (InfFindFirstLine(InfHandle, "SetupData", "DbgOsLoadOptions", &InfContext))
|
if (InfFindFirstLine(InfHandle, "SetupData", "DbgOsLoadOptions", &InfContext))
|
||||||
{
|
{
|
||||||
if (InfGetDataField(&InfContext, 1, &LoadOptions))
|
LPCSTR DbgLoadOptions;
|
||||||
BootOptions = LoadOptions;
|
|
||||||
|
if (InfGetDataField(&InfContext, 1, &DbgLoadOptions))
|
||||||
|
LoadOptions = DbgLoadOptions;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Copy loadoptions (original string will be freed) */
|
||||||
|
BootOptions = FrLdrTempAlloc(strlen(LoadOptions) + 1, TAG_BOOT_OPTIONS);
|
||||||
|
strcpy(BootOptions, LoadOptions);
|
||||||
|
|
||||||
TRACE("BootOptions: '%s'\n", BootOptions);
|
TRACE("BootOptions: '%s'\n", BootOptions);
|
||||||
|
|
||||||
UiDrawStatusText("Setup is loading...");
|
UiDrawStatusText("Setup is loading...");
|
||||||
|
@ -232,6 +238,9 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
/* Get a list of boot drivers */
|
/* Get a list of boot drivers */
|
||||||
SetupLdrScanBootDrivers(&LoaderBlock->BootDriverListHead, InfHandle, BootPath);
|
SetupLdrScanBootDrivers(&LoaderBlock->BootDriverListHead, InfHandle, BootPath);
|
||||||
|
|
||||||
|
/* Close the inf file */
|
||||||
|
InfCloseFile(InfHandle);
|
||||||
|
|
||||||
/* Load ReactOS */
|
/* Load ReactOS */
|
||||||
LoadAndBootWindowsCommon(_WIN32_WINNT_WS03,
|
LoadAndBootWindowsCommon(_WIN32_WINNT_WS03,
|
||||||
LoaderBlock,
|
LoaderBlock,
|
||||||
|
|
|
@ -144,9 +144,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
PARC_DISK_SIGNATURE_EX ArcDiskSig;
|
PARC_DISK_SIGNATURE_EX ArcDiskSig;
|
||||||
|
|
||||||
/* Allocate the ARC structure */
|
/* Allocate the ARC structure */
|
||||||
ArcDiskSig = FrLdrHeapAllocate(FrLdrDefaultHeap,
|
ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD');
|
||||||
sizeof(ARC_DISK_SIGNATURE_EX),
|
|
||||||
'giSD');
|
|
||||||
|
|
||||||
/* Copy the data over */
|
/* Copy the data over */
|
||||||
ArcDiskSig->DiskSignature.Signature = reactos_arc_disk_info[i].Signature;
|
ArcDiskSig->DiskSignature.Signature = reactos_arc_disk_info[i].Signature;
|
||||||
|
@ -752,6 +750,9 @@ LoadAndBootWindowsCommon(
|
||||||
/* "Stop all motors", change videomode */
|
/* "Stop all motors", change videomode */
|
||||||
MachPrepareForReactOS(Setup);
|
MachPrepareForReactOS(Setup);
|
||||||
|
|
||||||
|
/* Cleanup ini file */
|
||||||
|
IniCleanup();
|
||||||
|
|
||||||
/* Debugging... */
|
/* Debugging... */
|
||||||
//DumpMemoryAllocMap();
|
//DumpMemoryAllocMap();
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
|
||||||
|
|
||||||
/* Get the Name Group */
|
/* Get the Name Group */
|
||||||
BufferSize = 4096;
|
BufferSize = 4096;
|
||||||
GroupNameBuffer = MmHeapAlloc(BufferSize);
|
GroupNameBuffer = FrLdrHeapAlloc(BufferSize, TAG_WLDR_NAME);
|
||||||
rc = RegQueryValue(hGroupKey, L"List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize);
|
rc = RegQueryValue(hGroupKey, L"List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize);
|
||||||
TRACE_CH(REACTOS, "RegQueryValue(): rc %d\n", (int)rc);
|
TRACE_CH(REACTOS, "RegQueryValue(): rc %d\n", (int)rc);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
|
@ -545,7 +545,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
|
||||||
break;
|
break;
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
MmHeapFree(GroupNameBuffer);
|
FrLdrHeapFree(GroupNameBuffer, TAG_WLDR_NAME);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//TRACE_CH(REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName);
|
//TRACE_CH(REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName);
|
||||||
|
@ -624,7 +624,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
|
||||||
break;
|
break;
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
MmHeapFree(GroupNameBuffer);
|
FrLdrHeapFree(GroupNameBuffer, TAG_WLDR_NAME);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//TRACE_CH(REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName);
|
//TRACE_CH(REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName);
|
||||||
|
@ -694,7 +694,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free allocated memory */
|
/* Free allocated memory */
|
||||||
MmHeapFree(GroupNameBuffer);
|
FrLdrHeapFree(GroupNameBuffer, TAG_WLDR_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
@ -707,7 +707,7 @@ WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
USHORT PathLength;
|
USHORT PathLength;
|
||||||
|
|
||||||
BootDriverEntry = MmHeapAlloc(sizeof(BOOT_DRIVER_LIST_ENTRY));
|
BootDriverEntry = FrLdrHeapAlloc(sizeof(BOOT_DRIVER_LIST_ENTRY), TAG_WLDR_BDE);
|
||||||
|
|
||||||
if (!BootDriverEntry)
|
if (!BootDriverEntry)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -724,19 +724,19 @@ WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
|
||||||
|
|
||||||
BootDriverEntry->FilePath.Length = 0;
|
BootDriverEntry->FilePath.Length = 0;
|
||||||
BootDriverEntry->FilePath.MaximumLength = PathLength;
|
BootDriverEntry->FilePath.MaximumLength = PathLength;
|
||||||
BootDriverEntry->FilePath.Buffer = MmHeapAlloc(PathLength);
|
BootDriverEntry->FilePath.Buffer = FrLdrHeapAlloc(PathLength, TAG_WLDR_NAME);
|
||||||
|
|
||||||
if (!BootDriverEntry->FilePath.Buffer)
|
if (!BootDriverEntry->FilePath.Buffer)
|
||||||
{
|
{
|
||||||
MmHeapFree(BootDriverEntry);
|
FrLdrHeapFree(BootDriverEntry, TAG_WLDR_BDE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, ImagePath);
|
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, ImagePath);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
MmHeapFree(BootDriverEntry->FilePath.Buffer);
|
FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
|
||||||
MmHeapFree(BootDriverEntry);
|
FrLdrHeapFree(BootDriverEntry, TAG_WLDR_BDE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -746,35 +746,35 @@ WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
|
||||||
PathLength = (USHORT)wcslen(ServiceName)*sizeof(WCHAR) + sizeof(L"system32\\drivers\\.sys");
|
PathLength = (USHORT)wcslen(ServiceName)*sizeof(WCHAR) + sizeof(L"system32\\drivers\\.sys");
|
||||||
BootDriverEntry->FilePath.Length = 0;
|
BootDriverEntry->FilePath.Length = 0;
|
||||||
BootDriverEntry->FilePath.MaximumLength = PathLength;
|
BootDriverEntry->FilePath.MaximumLength = PathLength;
|
||||||
BootDriverEntry->FilePath.Buffer = MmHeapAlloc(PathLength);
|
BootDriverEntry->FilePath.Buffer = FrLdrHeapAlloc(PathLength, TAG_WLDR_NAME);
|
||||||
|
|
||||||
if (!BootDriverEntry->FilePath.Buffer)
|
if (!BootDriverEntry->FilePath.Buffer)
|
||||||
{
|
{
|
||||||
MmHeapFree(BootDriverEntry);
|
FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, L"system32\\drivers\\");
|
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, L"system32\\drivers\\");
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
MmHeapFree(BootDriverEntry->FilePath.Buffer);
|
FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
|
||||||
MmHeapFree(BootDriverEntry);
|
FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, ServiceName);
|
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, ServiceName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
MmHeapFree(BootDriverEntry->FilePath.Buffer);
|
FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
|
||||||
MmHeapFree(BootDriverEntry);
|
FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, L".sys");
|
Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, L".sys");
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
MmHeapFree(BootDriverEntry->FilePath.Buffer);
|
FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
|
||||||
MmHeapFree(BootDriverEntry);
|
FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -783,7 +783,7 @@ WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
|
||||||
PathLength = (USHORT)(wcslen(RegistryPath) + wcslen(ServiceName))*sizeof(WCHAR) + sizeof(UNICODE_NULL);
|
PathLength = (USHORT)(wcslen(RegistryPath) + wcslen(ServiceName))*sizeof(WCHAR) + sizeof(UNICODE_NULL);
|
||||||
BootDriverEntry->RegistryPath.Length = 0;
|
BootDriverEntry->RegistryPath.Length = 0;
|
||||||
BootDriverEntry->RegistryPath.MaximumLength = PathLength;
|
BootDriverEntry->RegistryPath.MaximumLength = PathLength;
|
||||||
BootDriverEntry->RegistryPath.Buffer = MmHeapAlloc(PathLength);
|
BootDriverEntry->RegistryPath.Buffer = FrLdrHeapAlloc(PathLength, TAG_WLDR_NAME);
|
||||||
if (!BootDriverEntry->RegistryPath.Buffer)
|
if (!BootDriverEntry->RegistryPath.Buffer)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue