| 1309 | } |
| 1310 | |
| 1311 | NT::NTSTATUS |
| 1312 | Ext2Open( |
| 1313 | PCHAR FileName, |
| 1314 | PHANDLE Handle, |
| 1315 | ULONG DesiredAccess |
| 1316 | ) |
| 1317 | { |
| 1318 | NT::IO_STATUS_BLOCK iosb; |
| 1319 | NT::NTSTATUS status; |
| 1320 | NT::ANSI_STRING AnsiFilespec; |
| 1321 | NT::UNICODE_STRING UnicodeFilespec; |
| 1322 | NT::OBJECT_ATTRIBUTES ObjectAttributes; |
| 1323 | |
| 1324 | SHORT UnicodeName[MAX_PATH]; |
| 1325 | CHAR AnsiName[MAX_PATH]; |
| 1326 | USHORT NameLength = 0; |
| 1327 | |
| 1328 | memset(UnicodeName, 0, sizeof(SHORT) * MAX_PATH); |
| 1329 | memset(AnsiName, 0, sizeof(UCHAR) * MAX_PATH); |
| 1330 | |
| 1331 | NameLength = (USHORT)strlen(FileName); |
| 1332 | ASSERT(NameLength < MAX_PATH); |
| 1333 | |
| 1334 | if (FileName[0] == '\\') { |
| 1335 | memmove(AnsiName, FileName, NameLength); |
| 1336 | } else { |
| 1337 | memmove(&AnsiName[0], "\\DosDevices\\", 12); |
| 1338 | memmove(&AnsiName[12], FileName, NameLength); |
| 1339 | NameLength += 12; |
| 1340 | } |
| 1341 | |
| 1342 | AnsiFilespec.MaximumLength = AnsiFilespec.Length = NameLength; |
| 1343 | AnsiFilespec.Buffer = AnsiName; |
| 1344 | |
| 1345 | UnicodeFilespec.MaximumLength = MAX_PATH * 2; |
| 1346 | UnicodeFilespec.Length = 0; |
| 1347 | UnicodeFilespec.Buffer = (PWSTR)UnicodeName; |
| 1348 | |
| 1349 | NT::RtlAnsiStringToUnicodeString(&UnicodeFilespec, &AnsiFilespec, FALSE); |
| 1350 | |
| 1351 | // |
| 1352 | // Setup the name in an object attributes structure. |
| 1353 | // Note that we create a name that is case INsensitive |
| 1354 | // |
| 1355 | |
| 1356 | ObjectAttributes.Length = sizeof(NT::OBJECT_ATTRIBUTES); |
| 1357 | ObjectAttributes.RootDirectory = NULL; |
| 1358 | ObjectAttributes.Attributes = 0; /*OBJ_CASE_INSENSITIVE;*/ |
| 1359 | ObjectAttributes.ObjectName = &UnicodeFilespec; |
| 1360 | ObjectAttributes.SecurityDescriptor = NULL; |
| 1361 | ObjectAttributes.SecurityQualityOfService = NULL; |
| 1362 | |
| 1363 | // |
| 1364 | // Do the create. In this particular case, we'll have the I/O Manager |
| 1365 | // make our write requests syncrhonous for our convenience. |
| 1366 | // |
| 1367 | status = NT::ZwCreateFile( |
| 1368 | Handle, // returned file handle |
no outgoing calls
no test coverage detected