[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; return;
} }
memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize); RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
PartialResourceList->Version = 0; PartialResourceList->Version = 0;
PartialResourceList->Revision = 0; PartialResourceList->Revision = 0;
PartialResourceList->Count = 1; PartialResourceList->Count = 1;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -299,7 +299,7 @@ DiskGetBrfrPartitionEntry(
return FALSE; return FALSE;
} }
memset(PartitionTableEntry, 0, sizeof(PARTITION_TABLE_ENTRY)); RtlZeroMemory(PartitionTableEntry, sizeof(PARTITION_TABLE_ENTRY));
PartitionTableEntry->SystemIndicator = XboxPartitions[PartitionNumber - 1].SystemIndicator; PartitionTableEntry->SystemIndicator = XboxPartitions[PartitionNumber - 1].SystemIndicator;
PartitionTableEntry->SectorCountBeforePartition = XboxPartitions[PartitionNumber - 1].SectorCountBeforePartition; PartitionTableEntry->SectorCountBeforePartition = XboxPartitions[PartitionNumber - 1].SectorCountBeforePartition;
PartitionTableEntry->PartitionSectorCount = XboxPartitions[PartitionNumber - 1].PartitionSectorCount; 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) 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); path->tree_buf = FrLdrTempAlloc(sb->nodesize, TAG_BTRFS_NODE);
} }