[FREELDR] Switch to RtlZeroMemory() from memset().

This commit is contained in:
Hermès Bélusca-Maïto 2021-11-19 02:22:00 +01:00
parent 497fee1622
commit 60d4a34892
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
9 changed files with 29 additions and 25 deletions

View file

@ -81,7 +81,7 @@ DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
return;
}
memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
PartialResourceList->Version = 0;
PartialResourceList->Revision = 0;
PartialResourceList->Count = 1;

View file

@ -138,7 +138,7 @@ DetectPciIrqRoutingTable(PCONFIGURATION_COMPONENT_DATA BusKey)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 2;
@ -196,7 +196,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
/* Create new bus key */
FldrCreateComponentKey(SystemKey,
@ -235,7 +235,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 1;
@ -261,7 +261,7 @@ DetectPciBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
}
/* Create the bus key */

View file

@ -20,7 +20,7 @@ KeInitializeEvent(
IN EVENT_TYPE Type,
IN BOOLEAN State)
{
memset(Event, 0, sizeof(*Event));
RtlZeroMemory(Event, sizeof(*Event));
}
VOID

View file

@ -124,7 +124,7 @@ PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
return NULL;
}
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 1;
@ -617,7 +617,8 @@ DetectSerialPointerPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey,
ERR("Failed to allocate resource descriptor\n");
return;
}
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 0;
@ -936,7 +937,7 @@ DetectKeyboardPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 1;
@ -997,7 +998,7 @@ DetectKeyboardController(PCONFIGURATION_COMPONENT_DATA BusKey)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 3;
@ -1215,7 +1216,8 @@ DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey)
ERR("Failed to allocate resource descriptor\n");
return;
}
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 0;
@ -1318,7 +1320,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 0;
@ -1452,9 +1454,8 @@ VOID __cdecl ChainLoadBiosBootSectorCode(
VOID
MachInit(const char *CmdLine)
{
memset(&MachVtbl, 0, sizeof(MACHVTBL));
/* Setup vtbl */
RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
MachVtbl.ConsPutChar = PcConsPutChar;
MachVtbl.ConsKbHit = PcConsKbHit;
MachVtbl.ConsGetCh = PcConsGetCh;

View file

@ -235,7 +235,7 @@ DetectBiosFloppyPeripheral(PCONFIGURATION_COMPONENT_DATA ControllerKey)
return;
}
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 1;
@ -375,7 +375,7 @@ DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 1;

View file

@ -118,6 +118,9 @@ MachInit(const char *CmdLine)
{
if (!Pc98ArchTest())
{
ERR("This is not a supported PC98!\n");
/* Disable and halt the CPU */
_disable();
__halt();
@ -126,7 +129,7 @@ MachInit(const char *CmdLine)
}
/* Setup vtbl */
RtlZeroMemory(&MachVtbl, sizeof(MACHVTBL));
RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
MachVtbl.ConsPutChar = Pc98ConsPutChar;
MachVtbl.ConsKbHit = Pc98ConsKbHit;
MachVtbl.ConsGetCh = Pc98ConsGetCh;

View file

@ -110,7 +110,7 @@ XboxGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
return NULL;
}
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 1;
@ -223,7 +223,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
RtlZeroMemory(PartialResourceList, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 0;
@ -304,8 +304,6 @@ MachInit(const char *CmdLine)
PCI_TYPE1_CFG_BITS PciCfg1;
ULONG PciId;
memset(&MachVtbl, 0, sizeof(MACHVTBL));
/* Check for Xbox by identifying device at PCI 0:0:0, if it's
* 0x10DE/0x02A5 then we're running on an Xbox */
@ -322,19 +320,21 @@ MachInit(const char *CmdLine)
PciId = READ_PORT_ULONG((PULONG)PCI_TYPE1_DATA_PORT);
if (PciId != 0x02A510DE)
{
ERR("This is not original Xbox!\n");
ERR("This is not an original Xbox!\n");
/* Disable and halt the CPU */
_disable();
__halt();
while (TRUE);
while (TRUE)
NOTHING;
}
/* Set LEDs to red before anything is initialized */
XboxSetLED("rrrr");
/* Setup vtbl */
RtlZeroMemory(&MachVtbl, sizeof(MachVtbl));
MachVtbl.ConsPutChar = XboxConsPutChar;
MachVtbl.ConsKbHit = XboxConsKbHit;
MachVtbl.ConsGetCh = XboxConsGetCh;

View file

@ -299,7 +299,7 @@ DiskGetBrfrPartitionEntry(
return FALSE;
}
memset(PartitionTableEntry, 0, sizeof(PARTITION_TABLE_ENTRY));
RtlZeroMemory(PartitionTableEntry, sizeof(PARTITION_TABLE_ENTRY));
PartitionTableEntry->SystemIndicator = XboxPartitions[PartitionNumber - 1].SystemIndicator;
PartitionTableEntry->SectorCountBeforePartition = XboxPartitions[PartitionNumber - 1].SectorCountBeforePartition;
PartitionTableEntry->PartitionSectorCount = XboxPartitions[PartitionNumber - 1].PartitionSectorCount;

View file

@ -166,7 +166,7 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
static inline void init_path(const struct btrfs_super_block *sb, struct btrfs_path *path)
{
memset(path, 0, sizeof(*path));
RtlZeroMemory(path, sizeof(*path));
path->tree_buf = FrLdrTempAlloc(sb->nodesize, TAG_BTRFS_NODE);
}