[FREELDR] Allow booting from NTFS volume. (#3775)

This commit is contained in:
Vadim Galyant 2022-03-19 17:44:42 +03:00 committed by GitHub
parent 1eed7ca9a9
commit d01f948925
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -65,6 +65,8 @@
#define NTFS_FILE_NAME_DOS 2 #define NTFS_FILE_NAME_DOS 2
#define NTFS_FILE_NAME_WIN32_AND_DOS 3 #define NTFS_FILE_NAME_WIN32_AND_DOS 3
#define NTFS_MFT_MASK 0x0000FFFFFFFFFFFFULL
#include <pshpack1.h> #include <pshpack1.h>
typedef struct typedef struct
{ {
@ -115,6 +117,8 @@ typedef struct
ULONG BytesAllocated; ULONG BytesAllocated;
ULONGLONG BaseMFTRecord; ULONGLONG BaseMFTRecord;
USHORT NextAttributeInstance; USHORT NextAttributeInstance;
USHORT Padding; // Align to 4 UCHAR boundary (NTFS 3.1+ (Windows XP and above))
ULONG MFTRecordNumber; // Number of this MFT Record (NTFS 3.1+ (Windows XP and above))
} NTFS_MFT_RECORD, *PNTFS_MFT_RECORD; } NTFS_MFT_RECORD, *PNTFS_MFT_RECORD;
typedef struct typedef struct
@ -185,7 +189,7 @@ typedef struct
USHORT Reserved; USHORT Reserved;
UCHAR FileNameLength; UCHAR FileNameLength;
UCHAR FileNameType; UCHAR FileNameType;
WCHAR FileName[0]; WCHAR FileName[1];
} NTFS_FILE_NAME_ATTR, *PNTFS_FILE_NAME_ATTR; } NTFS_FILE_NAME_ATTR, *PNTFS_FILE_NAME_ATTR;
typedef struct typedef struct
@ -197,7 +201,7 @@ typedef struct
ULONGLONG StartingVCN; ULONGLONG StartingVCN;
ULONGLONG BaseFileRef; ULONGLONG BaseFileRef;
USHORT AttrId; USHORT AttrId;
PWCHAR Name; WCHAR Name[1];
} NTFS_ATTR_LIST_ATTR, *PNTFS_ATTR_LIST_ATTR; } NTFS_ATTR_LIST_ATTR, *PNTFS_ATTR_LIST_ATTR;
typedef struct typedef struct

View file

@ -505,7 +505,7 @@ VOID NtfsPrintFile(PNTFS_INDEX_ENTRY IndexEntry)
AnsiFileName[i] = (CHAR)FileName[i]; AnsiFileName[i] = (CHAR)FileName[i];
AnsiFileName[i] = 0; AnsiFileName[i] = 0;
TRACE("- %s (%x)\n", AnsiFileName, IndexEntry->Data.Directory.IndexedFile); TRACE("- %s (%x)\n", AnsiFileName, (IndexEntry->Data.Directory.IndexedFile & NTFS_MFT_MASK));
} }
#endif #endif
@ -596,7 +596,7 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
{ {
if (NtfsCompareFileName(FileName, IndexEntry)) if (NtfsCompareFileName(FileName, IndexEntry))
{ {
*OutMFTIndex = IndexEntry->Data.Directory.IndexedFile; *OutMFTIndex = (IndexEntry->Data.Directory.IndexedFile & NTFS_MFT_MASK);
FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC); FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC);
FrLdrTempFree(MftRecord, TAG_NTFS_MFT); FrLdrTempFree(MftRecord, TAG_NTFS_MFT);
return TRUE; return TRUE;
@ -680,7 +680,7 @@ static BOOLEAN NtfsFindMftRecord(PNTFS_VOLUME_INFO Volume, ULONGLONG MFTIndex, P
if (NtfsCompareFileName(FileName, IndexEntry)) if (NtfsCompareFileName(FileName, IndexEntry))
{ {
TRACE("File found\n"); TRACE("File found\n");
*OutMFTIndex = IndexEntry->Data.Directory.IndexedFile; *OutMFTIndex = (IndexEntry->Data.Directory.IndexedFile & NTFS_MFT_MASK);
FrLdrTempFree(BitmapData, TAG_NTFS_BITMAP); FrLdrTempFree(BitmapData, TAG_NTFS_BITMAP);
FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC); FrLdrTempFree(IndexRecord, TAG_NTFS_INDEX_REC);
FrLdrTempFree(MftRecord, TAG_NTFS_MFT); FrLdrTempFree(MftRecord, TAG_NTFS_MFT);