916{
927 PSTR Buffer1, Buffer2, LoadOptions;
933
935
936
939 RealDiskCount = 0;
940
941
944 if (Buffer1 ==
NULL || Buffer2 ==
NULL)
945 {
947 }
948
949
951 {
953
954
955 Last =
strrchr(LoaderBlock->NtBootPathName,
'\\');
957
959 {
961 }
962
963
965 {
966
968 Saved = Last;
969 Last =
strrchr(LoaderBlock->NtBootPathName,
'\\');
970 *Saved = '\\';
971 }
972
973
975 {
977 }
978
979
980 NtSystemPath[0] = 'X';
981 NtSystemPath[1] = ':';
982
984
985
987 {
989 }
990
991
993 }
994
995
997 if (DiskCount != 0)
998 {
999 for (
i = 0;
i < DiskCount; ++
i)
1000 {
1001
1002 sprintf(Buffer1,
"\\Device\\Harddisk%d\\Partition%d",
i, 0);
1005 {
1006
1008 }
1009
1010
1012 &StringU1,
1019 &StatusBlock,
1023 {
1024
1025 sprintf(Buffer2,
"\\DosDevices\\PhysicalDrive%d",
i);
1029 {
1032 }
1033
1035
1036 RealDiskCount =
i + 1;
1037 }
1038
1040
1042 {
1044 {
1046 ++DiskCount;
1047 }
1048 }
1049 }
1050 }
1051
1052
1055
1056
1057 if (LoaderBlock->LoadOptions !=
NULL)
1058 {
1059 LoadOptions =
_strupr(LoaderBlock->LoadOptions);
1060 }
1061 else
1062 {
1064 }
1065
1066
1067 if (LoadOptions !=
NULL &&
1068 strstr(LoadOptions,
"MININT") != 0 &&
1070 {
1072 {
1073 *NtSystemPath = 'X';
1074 }
1075
1077 }
1078
1079
1081 if (RealDiskCount > DiskCount)
1082 {
1083 DiskCount = RealDiskCount;
1084 }
1086
1087
1088
1089
1090 HarddiskCount = 0;
1091 for (
i = 0;
i < DiskCount; ++
i)
1092 {
1093
1094 if (Devices !=
NULL)
1095 {
1096 HarddiskCount = Devices[
i];
1097 }
1098
1099
1103 {
1105 }
1106
1107
1108 SystemFound =
FALSE;
1109 swprintf(
Buffer,
L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, 1);
1111
1113 {
1114
1115 for (PartitionCount = 1; ; ++PartitionCount)
1116 {
1117 swprintf(
Buffer,
L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1120 {
1121 break;
1122 }
1123
1124
1126 {
1128 break;
1129 }
1130 }
1131 }
1132 else
1133 {
1134
1135 for (PartitionCount = 2; ; ++PartitionCount)
1136 {
1137
1139 {
1141
1142
1145 {
1146 break;
1147 }
1148 }
1149
1150
1151 swprintf(
Buffer,
L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1154 {
1155
1156 if (!SystemFound)
1157 {
1158 for (PartitionCount = 1; ; ++PartitionCount)
1159 {
1160 swprintf(
Buffer,
L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1163 {
1164 break;
1165 }
1166
1168 {
1170 break;
1171 }
1172 }
1173 }
1174
1175 break;
1176 }
1177 }
1178 }
1179
1180
1181 if (LayoutInfo !=
NULL)
1182 {
1184 }
1185
1186 HarddiskCount =
i + 1;
1187 }
1188
1189
1190 for (
i = 0;
i < DiskCount; ++
i)
1191 {
1192
1193 if (Devices !=
NULL)
1194 {
1195 HarddiskCount = Devices[
i];
1196 }
1197 else
1198 {
1200 }
1201
1202
1206 {
1208 }
1209
1210
1211 for (PartitionCount = 1; ; ++PartitionCount)
1212 {
1213 swprintf(
Buffer,
L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1216 {
1217 break;
1218 }
1219
1221 {
1223 }
1224 }
1225
1226
1227 if (LayoutInfo !=
NULL)
1228 {
1230 }
1231 }
1232
1233
1234 for (
i = 0;
i < DiskCount; ++
i)
1235 {
1236
1237 if (Devices !=
NULL)
1238 {
1239 HarddiskCount = Devices[
i];
1240 }
1241 else
1242 {
1244 }
1245
1246
1250 {
1252 }
1253
1254
1256 for (PartitionCount = 1; ; ++PartitionCount)
1257 {
1258 swprintf(
Buffer,
L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1261 {
1262 break;
1263 }
1264
1266 {
1268 }
1269 }
1270
1271
1272 for (PartitionCount = 1; ; ++PartitionCount)
1273 {
1275 {
1276 swprintf(
Buffer,
L"\\Device\\Harddisk%d\\Partition%d", HarddiskCount, PartitionCount);
1279 {
1280 if (LayoutInfo !=
NULL)
1281 {
1283 }
1284
1285 break;
1286 }
1287
1289 {
1291 }
1292 }
1293 }
1294 }
1295
1296
1297 if (Devices !=
NULL)
1298 {
1300 }
1301
1302
1304 {
1308 {
1310 }
1311 }
1312
1313
1315 {
1319 }
1320
1321
1323 {
1324
1326 if (DriveLetter != 0)
1327 {
1328 if (DriveLetter != 0xFF)
1329 {
1330 *NtSystemPath = DriveLetter;
1331 }
1332 }
1333
1334 else
1335 {
1338
1340 {
1341 DriveLetter = 'A';
1342 }
1344 {
1345 DriveLetter = 'D';
1346 }
1347 else
1348 {
1349 DriveLetter = 'C';
1350 }
1351
1352
1354 {
1355 ++DriveLetter;
1356
1357 if (DriveLetter > 'Z')
1358 {
1359 break;
1360 }
1361 }
1362
1363
1364 if (DriveLetter > 'Z')
1365 {
1366
1369 *NtSystemPath = 'Z';
1370 }
1371 else
1372 {
1373
1374 *NtSystemPath = DriveLetter;
1375 }
1376 }
1377
1379 }
1380
1381
1383}
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
PPARTENTRY SystemPartition
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
enum _PARTITION_TYPE PARTITION_TYPE
NTSTATUS HalpDeleteMountLetter(UCHAR DriveLetter)
PULONG IopComputeHarddiskDerangements(IN ULONG DiskCount)
NTSTATUS HalpQueryPartitionType(IN PUNICODE_STRING DeviceName, IN PDRIVE_LAYOUT_INFORMATION LayoutInfo, OUT PPARTITION_TYPE PartitionType)
BOOLEAN HalpIsOldStyleFloppy(PUNICODE_STRING DeviceName)
NTSTATUS HalpSetMountLetter(IN PUNICODE_STRING DeviceName, UCHAR DriveLetter)
UCHAR HalpNextDriveLetter(IN PUNICODE_STRING DeviceName, IN PSTRING NtDeviceName, OUT PUCHAR NtSystemPath, BOOLEAN IsRemovable)
NTSTATUS FASTCALL HalpQueryDriveLayout(IN PUNICODE_STRING DeviceName, OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo)
VOID HalpEnableAutomaticDriveLetterAssignment(VOID)
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define OBJ_CASE_INSENSITIVE
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Returns a pointer to the I/O manager's global configuration information structure.
#define sprintf(buf, format,...)
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI VOID NTAPI RtlInitString(PSTRING DestinationString, PCSZ SourceString)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
BOOLEAN IoRemoteBootClient
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)