Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static unsafe partial int NtQueryDirectoryFile(
IntPtr ApcRoutine,
IntPtr ApcContext,
IO_STATUS_BLOCK* IoStatusBlock,
IntPtr FileInformation,
void* FileInformation,
uint Length,
FILE_INFORMATION_CLASS FileInformationClass,
BOOLEAN ReturnSingleEntry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract unsafe partial class FileSystemEnumerator<TResult> : CriticalFin
private Interop.NtDll.FILE_FULL_DIR_INFORMATION* _entry;
private TResult? _current;

private IntPtr _buffer;
private void* _buffer;
private int _bufferLength;
private IntPtr _directoryHandle;
private string? _currentPath;
Expand Down Expand Up @@ -89,7 +89,7 @@ private void Init()
// We'll only suppress the media insertion prompt on the topmost directory as that is the
// most likely scenario and we don't want to take the perf hit for large enumerations.
// (We weren't consistent with how we handled this historically.)
using (default(DisableMediaInsertionPrompt))
using (DisableMediaInsertionPrompt.Create())
{
// We need to initialize the directory handle up front to ensure
// we immediately throw IO exceptions for missing directory/etc.
Expand All @@ -107,9 +107,9 @@ private void Init()
try
{
// NtQueryDirectoryFile needs its buffer to be 64bit aligned to work
// successfully with FileFullDirectoryInformation on ARM32. AllocHGlobal
// will return pointers aligned as such, new byte[] does not.
_buffer = Marshal.AllocHGlobal(_bufferLength);
// successfully with FileFullDirectoryInformation on ARM32. AlignedAlloc
// guarantees the required alignment, new byte[] does not.
_buffer = NativeMemory.AlignedAlloc((nuint)_bufferLength, sizeof(ulong));
Comment on lines 109 to +112
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we switch to just Alloc now that win-arm is not supported?

}
catch
{
Expand Down Expand Up @@ -381,12 +381,12 @@ private void InternalDispose(bool disposing)
_pending = null;
}

if (_buffer != default)
if (_buffer != null)
{
Marshal.FreeHGlobal(_buffer);
NativeMemory.AlignedFree(_buffer);
}

_buffer = default;
_buffer = null;
}
}

Expand Down
Loading