- Use new APIs MmHeapAlloc / MmHeapFree for small and discardable memory allocations (not everywhere yet). There is currently no difference, since they all point to the same old memory allocator.

- Include bget.h to freeldr.h.

svn path=/trunk/; revision=31762
This commit is contained in:
Aleksey Bragin 2008-01-13 15:17:54 +00:00
parent ea6661ca60
commit 1449fc2b23
14 changed files with 108 additions and 107 deletions

View file

@ -131,7 +131,7 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
//
// Allocate the memory to hold the boot sector
//
FatVolumeBootSector = (PFAT_BOOTSECTOR) MmAllocateMemory(512);
FatVolumeBootSector = (PFAT_BOOTSECTOR) MmHeapAlloc(512);
Fat32VolumeBootSector = (PFAT32_BOOTSECTOR) FatVolumeBootSector;
FatXVolumeBootSector = (PFATX_BOOTSECTOR) FatVolumeBootSector;
@ -148,7 +148,7 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
// If this fails then abort
if (!MachDiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, (PVOID)DISKREADBUFFER))
{
MmFreeMemory(FatVolumeBootSector);
MmHeapFree(FatVolumeBootSector);
return FALSE;
}
RtlCopyMemory(FatVolumeBootSector, (PVOID)DISKREADBUFFER, 512);
@ -247,7 +247,7 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
sprintf(ErrMsg, "Invalid boot sector magic on drive 0x%x (expected 0xaa55 found 0x%x)",
DriveNumber, FatVolumeBootSector->BootSectorMagic);
FileSystemError(ErrMsg);
MmFreeMemory(FatVolumeBootSector);
MmHeapFree(FatVolumeBootSector);
return FALSE;
}
@ -259,7 +259,7 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
(! ISFATX(FatType) && 64 * 1024 < FatVolumeBootSector->SectorsPerCluster * FatVolumeBootSector->BytesPerSector))
{
FileSystemError("This file system has cluster sizes bigger than 64k.\nFreeLoader does not support this.");
MmFreeMemory(FatVolumeBootSector);
MmHeapFree(FatVolumeBootSector);
return FALSE;
}
@ -332,7 +332,7 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
return FALSE;
}
}
MmFreeMemory(FatVolumeBootSector);
MmHeapFree(FatVolumeBootSector);
//
// Initialize the disk cache for this drive
@ -445,7 +445,7 @@ PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG *DirectorySize, BOOL
// Attempt to allocate memory for directory buffer
//
DbgPrint((DPRINT_FILESYSTEM, "Trying to allocate (DirectorySize) %d bytes.\n", *DirectorySize));
DirectoryBuffer = MmAllocateMemory(*DirectorySize);
DirectoryBuffer = MmHeapAlloc(*DirectorySize);
if (DirectoryBuffer == NULL)
{
@ -459,7 +459,7 @@ PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG *DirectorySize, BOOL
{
if (!FatReadVolumeSectors(FatDriveNumber, RootDirSectorStart, RootDirSectors, DirectoryBuffer))
{
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
return NULL;
}
}
@ -467,7 +467,7 @@ PVOID FatBufferDirectory(ULONG DirectoryStartCluster, ULONG *DirectorySize, BOOL
{
if (!FatReadClusterChain(DirectoryStartCluster, 0xFFFFFFFF, DirectoryBuffer))
{
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
return NULL;
}
}
@ -817,7 +817,7 @@ BOOLEAN FatLookupFile(PCSTR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
if (!FatXSearchDirectoryBufferForFile(DirectoryBuffer, DirectorySize, PathPart, &FatFileInfo))
{
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
return FALSE;
}
}
@ -825,12 +825,12 @@ BOOLEAN FatLookupFile(PCSTR FileName, PFAT_FILE_INFO FatFileInfoPointer)
{
if (!FatSearchDirectoryBufferForFile(DirectoryBuffer, DirectorySize, PathPart, &FatFileInfo))
{
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
return FALSE;
}
}
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
//
// If we have another sub-directory to go then
@ -839,7 +839,7 @@ BOOLEAN FatLookupFile(PCSTR FileName, PFAT_FILE_INFO FatFileInfoPointer)
if ((i+1) < NumberOfPathParts)
{
DirectoryStartCluster = FatFileInfo.FileFatChain[0];
MmFreeMemory(FatFileInfo.FileFatChain);
MmHeapFree(FatFileInfo.FileFatChain);
}
}
@ -1007,7 +1007,7 @@ FILE* FatOpenFile(PCSTR FileName)
return NULL;
}
FileHandle = MmAllocateMemory(sizeof(FAT_FILE_INFO));
FileHandle = MmHeapAlloc(sizeof(FAT_FILE_INFO));
if (FileHandle == NULL)
{
@ -1071,7 +1071,7 @@ ULONG* FatGetClusterChainArray(ULONG StartCluster)
//
// Allocate array memory
//
ArrayPointer = MmAllocateMemory(ArraySize);
ArrayPointer = MmHeapAlloc(ArraySize);
if (ArrayPointer == NULL)
{
@ -1104,7 +1104,7 @@ ULONG* FatGetClusterChainArray(ULONG StartCluster)
//
if (!FatGetFatEntry(StartCluster, &StartCluster))
{
MmFreeMemory(ArrayPointer);
MmHeapFree(ArrayPointer);
return NULL;
}
}

View file

@ -139,7 +139,7 @@ static PVOID IsoBufferDirectory(ULONG DirectoryStartSector, ULONG DirectoryLengt
// Attempt to allocate memory for directory buffer
//
DbgPrint((DPRINT_FILESYSTEM, "Trying to allocate (DirectoryLength) %d bytes.\n", DirectoryLength));
DirectoryBuffer = MmAllocateMemory(DirectoryLength);
DirectoryBuffer = MmHeapAlloc(DirectoryLength);
if (DirectoryBuffer == NULL)
{
@ -153,7 +153,7 @@ static PVOID IsoBufferDirectory(ULONG DirectoryStartSector, ULONG DirectoryLengt
{
if (!MachDiskReadLogicalSectors(IsoDriveNumber, DirectoryStartSector + i, 1, (PVOID)DISKREADBUFFER))
{
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
return NULL;
}
RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, SECTORSIZE);
@ -224,11 +224,11 @@ static BOOLEAN IsoLookupFile(PCSTR FileName, PISO_FILE_INFO IsoFileInfoPointer)
//
if (!IsoSearchDirectoryBufferForFile(DirectoryBuffer, DirectoryLength, PathPart, &IsoFileInfo))
{
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
return FALSE;
}
MmFreeMemory(DirectoryBuffer);
MmHeapFree(DirectoryBuffer);
//
// If we have another sub-directory to go then

View file

@ -78,6 +78,7 @@
#include <keycodes.h>
#include <ver.h>
#include <cmdline.h>
#include <bget.h>
/* Needed by boot manager */
#include <bootmgr.h>
#include <oslist.h>

View file

@ -159,7 +159,7 @@ InfpCacheFreeLine (PINFCACHELINE Line)
Next = Line->Next;
if (Line->Key != NULL)
{
MmFreeMemory (Line->Key);
MmHeapFree (Line->Key);
Line->Key = NULL;
}
@ -167,12 +167,12 @@ InfpCacheFreeLine (PINFCACHELINE Line)
while (Line->FirstField != NULL)
{
Field = Line->FirstField->Next;
MmFreeMemory (Line->FirstField);
MmHeapFree (Line->FirstField);
Line->FirstField = Field;
}
Line->LastField = NULL;
MmFreeMemory (Line);
MmHeapFree (Line);
return Next;
}
@ -196,7 +196,7 @@ InfpCacheFreeSection (PINFCACHESECTION Section)
}
Section->LastLine = NULL;
MmFreeMemory (Section);
MmHeapFree (Section);
return Next;
}
@ -245,7 +245,7 @@ InfpCacheAddSection (PINFCACHE Cache,
/* Allocate and initialize the new section */
Size = sizeof(INFCACHESECTION) + strlen (Name);
Section = (PINFCACHESECTION)MmAllocateMemory (Size);
Section = (PINFCACHESECTION)MmHeapAlloc (Size);
if (Section == NULL)
{
// DPRINT("RtlAllocateHeap() failed\n");
@ -284,7 +284,7 @@ InfpCacheAddLine (PINFCACHESECTION Section)
return NULL;
}
Line = (PINFCACHELINE)MmAllocateMemory (sizeof(INFCACHELINE));
Line = (PINFCACHELINE)MmHeapAlloc (sizeof(INFCACHELINE));
if (Line == NULL)
{
// DPRINT("RtlAllocateHeap() failed\n");
@ -320,7 +320,7 @@ InfpAddKeyToLine (PINFCACHELINE Line,
if (Line->Key != NULL)
return NULL;
Line->Key = (PCHAR)MmAllocateMemory (strlen (Key) + 1);
Line->Key = (PCHAR)MmHeapAlloc (strlen (Key) + 1);
if (Line->Key == NULL)
return NULL;
@ -338,7 +338,7 @@ InfpAddFieldToLine (PINFCACHELINE Line,
ULONG Size;
Size = sizeof(INFCACHEFIELD) + strlen(Data);
Field = (PINFCACHEFIELD)MmAllocateMemory (Size);
Field = (PINFCACHEFIELD)MmHeapAlloc (Size);
if (Field == NULL)
{
return NULL;
@ -906,7 +906,7 @@ InfOpenFile(PHINF InfHandle,
// DPRINT("File size: %lu\n", FileLength);
/* Allocate file buffer */
FileBuffer = MmAllocateMemory (FileSize + 1);
FileBuffer = MmHeapAlloc (FileSize + 1);
if (FileBuffer == NULL)
{
// DPRINT1("RtlAllocateHeap() failed\n");
@ -921,7 +921,7 @@ InfOpenFile(PHINF InfHandle,
if (!Success)
{
// DPRINT("FsReadFile() failed\n");
MmFreeMemory (FileBuffer);
MmHeapFree (FileBuffer);
return FALSE;
}
@ -929,11 +929,11 @@ InfOpenFile(PHINF InfHandle,
FileBuffer[FileSize] = 0;
/* Allocate infcache header */
Cache = (PINFCACHE)MmAllocateMemory (sizeof(INFCACHE));
Cache = (PINFCACHE)MmHeapAlloc (sizeof(INFCACHE));
if (Cache == NULL)
{
// DPRINT("RtlAllocateHeap() failed\n");
MmFreeMemory (FileBuffer);
MmHeapFree (FileBuffer);
return FALSE;
}
@ -948,12 +948,12 @@ InfOpenFile(PHINF InfHandle,
ErrorLine);
if (!Success)
{
MmFreeMemory (Cache);
MmHeapFree (Cache);
Cache = NULL;
}
/* Free file buffer */
MmFreeMemory (FileBuffer);
MmHeapFree (FileBuffer);
*InfHandle = (HINF)Cache;
@ -979,7 +979,7 @@ InfCloseFile(HINF InfHandle)
}
Cache->LastSection = NULL;
MmFreeMemory(Cache);
MmHeapFree(Cache);
}

View file

@ -37,7 +37,7 @@ BOOLEAN IniFileInitialize(VOID)
// Get the file size & allocate enough memory for it
FreeLoaderIniFileSize = FsGetFileSize(Freeldr_Ini);
FreeLoaderIniFileData = MmAllocateMemory(FreeLoaderIniFileSize);
FreeLoaderIniFileData = MmHeapAlloc(FreeLoaderIniFileSize);
// If we are out of memory then return FALSE
if (FreeLoaderIniFileData == NULL)
@ -51,7 +51,7 @@ BOOLEAN IniFileInitialize(VOID)
if (!FsReadFile(Freeldr_Ini, FreeLoaderIniFileSize, NULL, FreeLoaderIniFileData))
{
FsCloseFile(Freeldr_Ini);
MmFreeMemory(FreeLoaderIniFileData);
MmHeapFree(FreeLoaderIniFileData);
return FALSE;
}
@ -60,7 +60,7 @@ BOOLEAN IniFileInitialize(VOID)
// Parse the .ini file data
Success = IniParseFile(FreeLoaderIniFileData, FreeLoaderIniFileSize);
MmFreeMemory(FreeLoaderIniFileData);
MmHeapFree(FreeLoaderIniFileData);
return Success;
}

View file

@ -178,7 +178,7 @@ BOOLEAN IniAddSection(PCSTR SectionName, ULONG* SectionId)
PINI_SECTION Section;
// Allocate a new section structure
Section = MmAllocateMemory(sizeof(INI_SECTION));
Section = MmHeapAlloc(sizeof(INI_SECTION));
if (!Section)
{
return FALSE;
@ -187,10 +187,10 @@ BOOLEAN IniAddSection(PCSTR SectionName, ULONG* SectionId)
RtlZeroMemory(Section, sizeof(INI_SECTION));
// Allocate the section name buffer
Section->SectionName = MmAllocateMemory(strlen(SectionName));
Section->SectionName = MmHeapAlloc(strlen(SectionName));
if (!Section->SectionName)
{
MmFreeMemory(Section);
MmHeapFree(Section);
return FALSE;
}
@ -212,7 +212,7 @@ BOOLEAN IniAddSettingValueToSection(ULONG SectionId, PCSTR SettingName, PCSTR Se
PINI_SECTION_ITEM SectionItem;
// Allocate a new item structure
SectionItem = MmAllocateMemory(sizeof(INI_SECTION_ITEM));
SectionItem = MmHeapAlloc(sizeof(INI_SECTION_ITEM));
if (!SectionItem)
{
return FALSE;
@ -221,19 +221,19 @@ BOOLEAN IniAddSettingValueToSection(ULONG SectionId, PCSTR SettingName, PCSTR Se
RtlZeroMemory(SectionItem, sizeof(INI_SECTION_ITEM));
// Allocate the setting name buffer
SectionItem->ItemName = MmAllocateMemory(strlen(SettingName) + 1);
SectionItem->ItemName = MmHeapAlloc(strlen(SettingName) + 1);
if (!SectionItem->ItemName)
{
MmFreeMemory(SectionItem);
MmHeapFree(SectionItem);
return FALSE;
}
// Allocate the setting value buffer
SectionItem->ItemValue = MmAllocateMemory(strlen(SettingValue) + 1);
SectionItem->ItemValue = MmHeapAlloc(strlen(SettingValue) + 1);
if (!SectionItem->ItemValue)
{
MmFreeMemory(SectionItem->ItemName);
MmFreeMemory(SectionItem);
MmHeapFree(SectionItem->ItemName);
MmHeapFree(SectionItem);
return FALSE;
}

View file

@ -46,7 +46,7 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
// Start with an 80-byte buffer
IniFileLineSize = 80;
IniFileLine = MmAllocateMemory(IniFileLineSize);
IniFileLine = MmHeapAlloc(IniFileLineSize);
if (!IniFileLine)
{
return FALSE;
@ -61,8 +61,8 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
if (IniFileLineSize < IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset))
{
IniFileLineSize = IniGetNextLineSize(IniFileData, IniFileSize, CurrentOffset);
MmFreeMemory(IniFileLine);
IniFileLine = MmAllocateMemory(IniFileLineSize);
MmHeapFree(IniFileLine);
IniFileLine = MmHeapAlloc(IniFileLineSize);
if (!IniFileLine)
{
return FALSE;
@ -84,21 +84,21 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
if (IniIsSectionName(IniFileLine, LineLength))
{
// Allocate a new section structure
CurrentSection = MmAllocateMemory(sizeof(INI_SECTION));
CurrentSection = MmHeapAlloc(sizeof(INI_SECTION));
if (!CurrentSection)
{
MmFreeMemory(IniFileLine);
MmHeapFree(IniFileLine);
return FALSE;
}
RtlZeroMemory(CurrentSection, sizeof(INI_SECTION));
// Allocate the section name buffer
CurrentSection->SectionName = MmAllocateMemory(IniGetSectionNameSize(IniFileLine, LineLength));
CurrentSection->SectionName = MmHeapAlloc(IniGetSectionNameSize(IniFileLine, LineLength));
if (!CurrentSection->SectionName)
{
MmFreeMemory(CurrentSection);
MmFreeMemory(IniFileLine);
MmHeapFree(CurrentSection);
MmHeapFree(IniFileLine);
return FALSE;
}
@ -128,31 +128,31 @@ BOOLEAN IniParseFile(PCHAR IniFileData, ULONG IniFileSize)
}
// Allocate a new item structure
CurrentItem = MmAllocateMemory(sizeof(INI_SECTION_ITEM));
CurrentItem = MmHeapAlloc(sizeof(INI_SECTION_ITEM));
if (!CurrentItem)
{
MmFreeMemory(IniFileLine);
MmHeapFree(IniFileLine);
return FALSE;
}
RtlZeroMemory(CurrentItem, sizeof(INI_SECTION_ITEM));
// Allocate the setting name buffer
CurrentItem->ItemName = MmAllocateMemory(IniGetSettingNameSize(IniFileLine, LineLength));
CurrentItem->ItemName = MmHeapAlloc(IniGetSettingNameSize(IniFileLine, LineLength));
if (!CurrentItem->ItemName)
{
MmFreeMemory(CurrentItem);
MmFreeMemory(IniFileLine);
MmHeapFree(CurrentItem);
MmHeapFree(IniFileLine);
return FALSE;
}
// Allocate the setting value buffer
CurrentItem->ItemValue = MmAllocateMemory(IniGetSettingValueSize(IniFileLine, LineLength));
CurrentItem->ItemValue = MmHeapAlloc(IniGetSettingValueSize(IniFileLine, LineLength));
if (!CurrentItem->ItemValue)
{
MmFreeMemory(CurrentItem->ItemName);
MmFreeMemory(CurrentItem);
MmFreeMemory(IniFileLine);
MmHeapFree(CurrentItem->ItemName);
MmHeapFree(CurrentItem);
MmHeapFree(IniFileLine);
return FALSE;
}

View file

@ -310,8 +310,8 @@ VOID MmFreeMemory(PVOID MemoryPointer)
PVOID MmHeapAlloc(ULONG MemorySize)
{
// Stub for WinLdr
return NULL;
// Temporary forwarder...
return MmAllocateMemoryWithType(MemorySize, LoaderOsloaderHeap);
}
VOID MmHeapFree(PVOID MemoryPointer)

View file

@ -119,8 +119,8 @@ BOOLEAN AllocateListMemory(PCHAR **SectionNamesPointer, PCHAR **DisplayNamesPoin
//
// Allocate memory to hold operating system list arrays
//
OperatingSystemSectionNames = MmAllocateMemory( sizeof(PCHAR) * OperatingSystemCount);
OperatingSystemDisplayNames = MmAllocateMemory( sizeof(PCHAR) * OperatingSystemCount);
OperatingSystemSectionNames = MmHeapAlloc( sizeof(PCHAR) * OperatingSystemCount);
OperatingSystemDisplayNames = MmHeapAlloc( sizeof(PCHAR) * OperatingSystemCount);
//
// If either allocation failed then return FALSE
@ -129,12 +129,12 @@ BOOLEAN AllocateListMemory(PCHAR **SectionNamesPointer, PCHAR **DisplayNamesPoin
{
if (OperatingSystemSectionNames != NULL)
{
MmFreeMemory(OperatingSystemSectionNames);
MmHeapFree(OperatingSystemSectionNames);
}
if (OperatingSystemDisplayNames != NULL)
{
MmFreeMemory(OperatingSystemDisplayNames);
MmHeapFree(OperatingSystemDisplayNames);
}
return FALSE;
@ -151,8 +151,8 @@ BOOLEAN AllocateListMemory(PCHAR **SectionNamesPointer, PCHAR **DisplayNamesPoin
//
for (Idx=0; Idx<OperatingSystemCount; Idx++)
{
OperatingSystemSectionNames[Idx] = MmAllocateMemory(80);
OperatingSystemDisplayNames[Idx] = MmAllocateMemory(80);
OperatingSystemSectionNames[Idx] = MmHeapAlloc(80);
OperatingSystemDisplayNames[Idx] = MmHeapAlloc(80);
//
// If it failed then jump to the cleanup code
@ -177,20 +177,20 @@ AllocateListMemoryFailed:
{
if (OperatingSystemSectionNames[Idx] != NULL)
{
MmFreeMemory(OperatingSystemSectionNames[Idx]);
MmHeapFree(OperatingSystemSectionNames[Idx]);
}
if (OperatingSystemDisplayNames[Idx] != NULL)
{
MmFreeMemory(OperatingSystemDisplayNames[Idx]);
MmHeapFree(OperatingSystemDisplayNames[Idx]);
}
}
//
// Free operating system list arrays
//
MmFreeMemory(OperatingSystemSectionNames);
MmFreeMemory(OperatingSystemDisplayNames);
MmHeapFree(OperatingSystemSectionNames);
MmHeapFree(OperatingSystemDisplayNames);
return FALSE;
}

View file

@ -32,7 +32,7 @@ static PVOID
NTAPI
CmpAllocate (SIZE_T Size, BOOLEAN Paged, ULONG Tag)
{
return MmAllocateMemory(Size);
return MmHeapAlloc(Size);
}
@ -40,7 +40,7 @@ static VOID
NTAPI
CmpFree (PVOID Ptr, IN ULONG Quota)
{
return MmFreeMemory(Ptr);
return MmHeapFree(Ptr);
}
static BOOLEAN
@ -62,7 +62,7 @@ RegImportValue (PHHIVE Hive,
if (ValueCell->Flags & VALUE_COMP_NAME)
{
wName = MmAllocateMemory ((ValueCell->NameLength + 1)*sizeof(WCHAR));
wName = MmHeapAlloc ((ValueCell->NameLength + 1)*sizeof(WCHAR));
for (i = 0; i < ValueCell->NameLength; i++)
{
wName[i] = ((PCHAR)ValueCell->Name)[i];
@ -71,7 +71,7 @@ RegImportValue (PHHIVE Hive,
}
else
{
wName = MmAllocateMemory (ValueCell->NameLength + sizeof(WCHAR));
wName = MmHeapAlloc (ValueCell->NameLength + sizeof(WCHAR));
memcpy (wName,
ValueCell->Name,
ValueCell->NameLength);
@ -93,7 +93,7 @@ RegImportValue (PHHIVE Hive,
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegSetValue() failed!\n"));
MmFreeMemory (wName);
MmHeapFree (wName);
return FALSE;
}
}
@ -111,12 +111,12 @@ RegImportValue (PHHIVE Hive,
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegSetValue() failed!\n"));
MmFreeMemory (wName);
MmHeapFree (wName);
return FALSE;
}
}
MmFreeMemory (wName);
MmHeapFree (wName);
return TRUE;
}
@ -147,7 +147,7 @@ RegImportSubKey(PHHIVE Hive,
if (KeyCell->Flags & KEY_COMP_NAME)
{
wName = MmAllocateMemory ((KeyCell->NameLength + 1) * sizeof(WCHAR));
wName = MmHeapAlloc ((KeyCell->NameLength + 1) * sizeof(WCHAR));
for (i = 0; i < KeyCell->NameLength; i++)
{
wName[i] = ((PCHAR)KeyCell->Name)[i];
@ -156,7 +156,7 @@ RegImportSubKey(PHHIVE Hive,
}
else
{
wName = MmAllocateMemory (KeyCell->NameLength + sizeof(WCHAR));
wName = MmHeapAlloc (KeyCell->NameLength + sizeof(WCHAR));
memcpy (wName,
KeyCell->Name,
KeyCell->NameLength);
@ -169,7 +169,7 @@ RegImportSubKey(PHHIVE Hive,
Error = RegCreateKey (ParentKey,
wName,
&SubKey);
MmFreeMemory (wName);
MmHeapFree (wName);
if (Error != ERROR_SUCCESS)
{
DbgPrint((DPRINT_REGISTRY, "RegCreateKey() failed!\n"));

View file

@ -28,7 +28,7 @@ VOID
RegInitializeRegistry (VOID)
{
/* Create root key */
RootKey = (FRLDRHKEY) MmAllocateMemory (sizeof(KEY));
RootKey = (FRLDRHKEY) MmHeapAlloc (sizeof(KEY));
InitializeListHead (&RootKey->SubKeyList);
InitializeListHead (&RootKey->ValueList);
@ -38,7 +38,7 @@ RegInitializeRegistry (VOID)
RootKey->ValueCount = 0;
RootKey->NameSize = 4;
RootKey->Name = MmAllocateMemory (4);
RootKey->Name = MmHeapAlloc (4);
wcscpy (RootKey->Name, L"\\");
RootKey->DataType = 0;
@ -244,7 +244,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
if (CmpResult != 0)
{
/* no key found -> create new subkey */
NewKey = (FRLDRHKEY)MmAllocateMemory(sizeof(KEY));
NewKey = (FRLDRHKEY)MmHeapAlloc(sizeof(KEY));
if (NewKey == NULL)
return(ERROR_OUTOFMEMORY);
@ -262,7 +262,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
CurrentKey->SubKeyCount++;
NewKey->NameSize = NameSize;
NewKey->Name = (PWCHAR)MmAllocateMemory(NewKey->NameSize);
NewKey->Name = (PWCHAR)MmHeapAlloc(NewKey->NameSize);
if (NewKey->Name == NULL)
return(ERROR_OUTOFMEMORY);
memcpy(NewKey->Name, name, NewKey->NameSize - sizeof(WCHAR));
@ -468,7 +468,7 @@ RegSetValue(FRLDRHKEY Key,
/* set default value */
if ((Key->Data != NULL) && (Key->DataSize > sizeof(PUCHAR)))
{
MmFreeMemory(Key->Data);
MmHeapFree(Key->Data);
}
if (DataSize <= sizeof(PUCHAR))
@ -479,7 +479,7 @@ RegSetValue(FRLDRHKEY Key,
}
else
{
Key->Data = MmAllocateMemory(DataSize);
Key->Data = MmHeapAlloc(DataSize);
Key->DataSize = DataSize;
Key->DataType = Type;
memcpy(Key->Data, Data, DataSize);
@ -508,7 +508,7 @@ RegSetValue(FRLDRHKEY Key,
/* add new value */
DbgPrint((DPRINT_REGISTRY, "No value found - adding new value\n"));
Value = (PVALUE)MmAllocateMemory(sizeof(VALUE));
Value = (PVALUE)MmHeapAlloc(sizeof(VALUE));
if (Value == NULL)
return(ERROR_OUTOFMEMORY);
@ -516,7 +516,7 @@ RegSetValue(FRLDRHKEY Key,
Key->ValueCount++;
Value->NameSize = (wcslen(ValueName)+1)*sizeof(WCHAR);
Value->Name = (PWCHAR)MmAllocateMemory(Value->NameSize);
Value->Name = (PWCHAR)MmHeapAlloc(Value->NameSize);
if (Value->Name == NULL)
return(ERROR_OUTOFMEMORY);
wcscpy(Value->Name, ValueName);
@ -528,7 +528,7 @@ RegSetValue(FRLDRHKEY Key,
/* set new value */
if ((Value->Data != NULL) && (Value->DataSize > sizeof(PUCHAR)))
{
MmFreeMemory(Value->Data);
MmHeapFree(Value->Data);
}
if (DataSize <= sizeof(PUCHAR))
@ -539,7 +539,7 @@ RegSetValue(FRLDRHKEY Key,
}
else
{
Value->Data = MmAllocateMemory(DataSize);
Value->Data = MmHeapAlloc(DataSize);
if (Value->Data == NULL)
return(ERROR_OUTOFMEMORY);
Value->DataType = Type;

View file

@ -33,7 +33,7 @@ STDCALL
RtlpAllocateMemory(ULONG Bytes,
ULONG Tag)
{
return MmAllocateMemory(Bytes);
return MmHeapAlloc(Bytes);
}
@ -42,5 +42,5 @@ STDCALL
RtlpFreeMemory(PVOID Mem,
ULONG Tag)
{
return MmFreeMemory(Mem);
return MmHeapFree(Mem);
}

View file

@ -559,7 +559,7 @@ VOID TuiMessageBox(PCSTR MessageText)
PVOID ScreenBuffer;
// Save the screen contents
ScreenBuffer = MmAllocateMemory(UiScreenWidth * UiScreenHeight * 2);
ScreenBuffer = MmHeapAlloc(UiScreenWidth * UiScreenHeight * 2);
TuiSaveScreen(ScreenBuffer);
// Display the message box
@ -567,7 +567,7 @@ VOID TuiMessageBox(PCSTR MessageText)
// Restore the screen contents
TuiRestoreScreen(ScreenBuffer);
MmFreeMemory(ScreenBuffer);
MmHeapFree(ScreenBuffer);
}
VOID TuiMessageBoxCritical(PCSTR MessageText)
@ -774,7 +774,7 @@ VOID TuiFadeInBackdrop(VOID)
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
{
TuiFadePalette = (PPALETTE_ENTRY)MmAllocateMemory(sizeof(PALETTE_ENTRY) * 64);
TuiFadePalette = (PPALETTE_ENTRY)MmHeapAlloc(sizeof(PALETTE_ENTRY) * 64);
if (TuiFadePalette != NULL)
{
@ -789,7 +789,7 @@ VOID TuiFadeInBackdrop(VOID)
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
{
VideoFadeIn(TuiFadePalette, 64);
MmFreeMemory(TuiFadePalette);
MmHeapFree(TuiFadePalette);
}
}
@ -799,7 +799,7 @@ VOID TuiFadeOut(VOID)
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed())
{
TuiFadePalette = (PPALETTE_ENTRY)MmAllocateMemory(sizeof(PALETTE_ENTRY) * 64);
TuiFadePalette = (PPALETTE_ENTRY)MmHeapAlloc(sizeof(PALETTE_ENTRY) * 64);
if (TuiFadePalette != NULL)
{
@ -817,7 +817,7 @@ VOID TuiFadeOut(VOID)
if (UiUseSpecialEffects && ! MachVideoIsPaletteFixed() && TuiFadePalette != NULL)
{
VideoRestorePaletteState(TuiFadePalette, 64);
MmFreeMemory(TuiFadePalette);
MmHeapFree(TuiFadePalette);
}
}
@ -841,7 +841,7 @@ BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
PVOID ScreenBuffer;
// Save the screen contents
ScreenBuffer = MmAllocateMemory(UiScreenWidth * UiScreenHeight * 2);
ScreenBuffer = MmHeapAlloc(UiScreenWidth * UiScreenHeight * 2);
TuiSaveScreen(ScreenBuffer);
// Find the height
@ -982,7 +982,7 @@ BOOLEAN TuiEditBox(PCSTR MessageText, PCHAR EditTextBuffer, ULONG Length)
// Restore the screen contents
TuiRestoreScreen(ScreenBuffer);
MmFreeMemory(ScreenBuffer);
MmHeapFree(ScreenBuffer);
return ReturnCode;
}

View file

@ -465,7 +465,7 @@ VOID UiShowMessageBoxesInSection(PCSTR SectionName)
//if (MessageBoxTextSize > 0)
{
// Allocate enough memory to hold the text
MessageBoxText = MmAllocateMemory(MessageBoxTextSize);
MessageBoxText = MmHeapAlloc(MessageBoxTextSize);
if (MessageBoxText)
{
@ -479,7 +479,7 @@ VOID UiShowMessageBoxesInSection(PCSTR SectionName)
UiMessageBox(MessageBoxText);
// Free the memory
MmFreeMemory(MessageBoxText);
MmHeapFree(MessageBoxText);
}
}
}