ReactOS 0.4.15-dev-7924-g5949c20
drivemap.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for drivemap.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (DISK)
 
BOOLEAN DriveMapIsValidDriveString (PCSTR DriveString)
 
UCHAR DriveMapGetBiosDriveNumber (PCSTR DeviceName)
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( DISK  )

◆ DriveMapGetBiosDriveNumber()

UCHAR DriveMapGetBiosDriveNumber ( PCSTR  DeviceName)

Definition at line 66 of file drivemap.c.

67{
68 UCHAR BiosDriveNumber = 0;
69
70 TRACE("DriveMapGetBiosDriveNumber(%s)\n", DeviceName);
71
72 // If they passed in a number string then just
73 // convert it to decimal and return it
74 if (DeviceName[0] >= '0' && DeviceName[0] <= '9')
75 {
76 return (UCHAR)strtoul(DeviceName, NULL, 0);
77 }
78
79 // Convert the drive number string into a number
80 // 'hd1' = 1
81 BiosDriveNumber = atoi(&DeviceName[2]);
82
83 // If it's a hard disk then set the high bit
84 if ((DeviceName[0] == 'h' || DeviceName[0] == 'H') &&
85 (DeviceName[1] == 'd' || DeviceName[1] == 'D'))
86 {
87 BiosDriveNumber |= 0x80;
88 }
89
90 return BiosDriveNumber;
91}
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
#define NULL
Definition: types.h:112
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ DriveMapIsValidDriveString()

BOOLEAN DriveMapIsValidDriveString ( PCSTR  DriveString)

Definition at line 34 of file drivemap.c.

35{
37
38 // Now verify that the user has given us appropriate strings
39 if ((strlen(DriveString) < 3) ||
40 ((DriveString[0] != 'f') && (DriveString[0] != 'F') &&
41 (DriveString[0] != 'h') && (DriveString[0] != 'H')) ||
42 ((DriveString[1] != 'd') && (DriveString[1] != 'D')))
43 {
44 return FALSE;
45 }
46
47 // Now verify that the user has given us appropriate numbers
48 // Make sure that only numeric characters were given
49 for (Index = 2; Index < strlen(DriveString); Index++)
50 {
51 if (DriveString[Index] < '0' || DriveString[Index] > '9')
52 {
53 return FALSE;
54 }
55 }
56
57 // Now make sure that they are not outrageous values (i.e. hd90874)
58 if ((atoi(&DriveString[2]) < 0) || (atoi(&DriveString[2]) > 0xff))
59 {
60 return FALSE;
61 }
62
63 return TRUE;
64}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index