MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2LoadDisks

Function Ext2LoadDisks

Ext2Mgr/enumDisk.cpp:1432–1511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1430}
1431
1432BOOL
1433Ext2LoadDisks()
1434{
1435 ULONG i = 0, j = 0;
1436 NT::NTSTATUS status;
1437 CHAR drvName[MAX_PATH];
1438
1439 if (g_nDisks == 0) {
1440 return FALSE;
1441 }
1442
1443 gDisks = (PEXT2_DISK) malloc(sizeof(EXT2_DISK) * g_nDisks);
1444 if (gDisks == NULL) {
1445 return FALSE;
1446 }
1447 memset(gDisks, 0, sizeof(EXT2_DISK) * g_nDisks);
1448
1449 while (i < g_nDisks && j < 256) {
1450
1451 HANDLE Handle = NULL;
1452
1453 gDisks[i].Magic = EXT2_DISK_MAGIC;
1454 gDisks[i].Null = EXT2_DISK_NULL_MAGIC;
1455 gDisks[i].OrderNo = (UCHAR) j;
1456 gDisks[i].bLoaded = FALSE;
1457 sprintf(drvName, "PhysicalDrive%d\0", j);
1458 if (QueryDosDevice(drvName, gDisks[i].Name, MAX_PATH) == 0) {
1459 sprintf(gDisks[i].Name, "\\DosDevices\\PhysicalDrive%d\0", j);
1460 }
1461 j++;
1462
1463 status = Ext2Open(gDisks[i].Name, &Handle, EXT2_DESIRED_ACCESS);
1464 if (!NT_SUCCESS(status)) {
1465 continue;
1466 }
1467
1468 status = Ext2QueryDisk(Handle, &gDisks[i].DiskGeometry);
1469 if (NT_SUCCESS(status)) {
1470 gDisks[i].bEjected = FALSE;
1471 } else {
1472 if (STATUS_NO_MEDIA_IN_DEVICE == status) {
1473 gDisks[i].bEjected = TRUE;
1474 } else {
1475 goto Next;
1476 }
1477 }
1478
1479 status = Ext2QueryProperty( Handle, StorageDeviceProperty,
1480 (PVOID)&gDisks[i].SDD,
1481 sizeof(STORAGE_DEVICE_DESCRIPTOR)
1482 );
1483 if (!NT_SUCCESS(status)) {
1484 goto Next;
1485 }
1486
1487 status = Ext2QueryProperty( Handle, StorageAdapterProperty,
1488 (PVOID)&gDisks[i].SAD,
1489 sizeof(STORAGE_ADAPTER_DESCRIPTOR)

Callers 2

OnInitDialogMethod · 0.85
OnRefreshMethod · 0.85

Calls 5

Ext2OpenFunction · 0.85
Ext2QueryDiskFunction · 0.85
Ext2QueryPropertyFunction · 0.85
Ext2QueryDriveLayoutFunction · 0.85
Ext2CloseFunction · 0.70

Tested by

no test coverage detected