Improved directory scanning performance by enlarging buffer size and fixed bug with external buffer corruption in NtQueryDirectoryFiles. Everything works!

This commit is contained in:
Berserker 2019-05-25 17:26:42 +03:00
parent fa991ef152
commit 4b1a3df792
2 changed files with 6 additions and 5 deletions

View File

@ -489,17 +489,18 @@ begin
WriteLog('[INNER] NtQueryDirectoryFile', 'Written entry: ' + EntryName); WriteLog('[INNER] NtQueryDirectoryFile', 'Written entry: ' + EntryName);
end; end;
if StructConvertResult <> TOO_SMALL_BUF then begin
with PFILE_ID_BOTH_DIR_INFORMATION(BufCaret)^ do begin with PFILE_ID_BOTH_DIR_INFORMATION(BufCaret)^ do begin
NextEntryOffset := 0; NextEntryOffset := 0;
FileIndex := 0; FileIndex := 0;
end; end;
end;
if StructConvertResult = TOO_SMALL_BUF then begin if StructConvertResult = TOO_SMALL_BUF then begin
OpenedFile.DirListing.SeekRel(-1); OpenedFile.DirListing.SeekRel(-1);
if IsFirstEntry then begin if IsFirstEntry then begin
result := STATUS_INFO_LENGTH_MISMATCH; result := STATUS_INFO_LENGTH_MISMATCH;
VarDump([BufLength, WinNative.GetFileInformationClassSize(InfoClass), BytesWritten, '---', Buffer, BufCaret, BufSize]);
end; end;
end else if StructConvertResult = TRUNCATED_NAME then begin end else if StructConvertResult = TRUNCATED_NAME then begin
if IsFirstEntry then begin if IsFirstEntry then begin

View File

@ -79,7 +79,7 @@ type
TSysDirScanner = class (Utils.TManagedObject, ISysDirScanner) TSysDirScanner = class (Utils.TManagedObject, ISysDirScanner)
protected const protected const
BUF_SIZE = (sizeof(WinNative.FILE_ID_BOTH_DIR_INFORMATION) + MAX_FILENAME_SIZE) * 10; BUF_SIZE = 65000;
protected protected
fOwnsDirHandle: boolean; fOwnsDirHandle: boolean;