Skip to content

Commit

Permalink
win32: Even more better directory test.
Browse files Browse the repository at this point in the history
This somewhat reverts 4e28c2b, though I
think that was intended to fix the same issue. t5092 was intermittently
failing on Windows, because depending on the scheduling of the two
run.sh scripts, sometimes it will get a write event on 'ignoredir', even
though it's a directory and we shouldn't be getting write events for it.
Apparently the test created in the other commit doesn't always work, so
we should also check for CreateOptions' FILE_DIRECTORY_FILE as well.

The other flaky test is t5091, which revealed that the
GetFileInformationByHandle wasn't actually returning successfully,
partly because we were using the FileHandle incorrectly and partly
because it fails with invalid permissions (not sure why on the latter
part, seeing as how it was just opened).
  • Loading branch information
gittup committed Oct 7, 2020
1 parent 6566e4e commit d33fd69
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/dllinject/dllinject.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,15 @@ NTSTATUS WINAPI NtCreateFile_hook(
PUNICODE_STRING uni = ObjectAttributes->ObjectName;

DEBUG_HOOK("NtCreateFile[%08x] '%.*ls': %x, %x, %x\n", rc, uni->Length/2, uni->Buffer, ShareAccess, DesiredAccess, CreateOptions);
if(rc == STATUS_SUCCESS && *PFileHandle) {
BY_HANDLE_FILE_INFORMATION info;
if(GetFileInformationByHandle(*PFileHandle, &info) != 0) {
if(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if(CreateOptions & FILE_DIRECTORY_FILE) {
DEBUG_HOOK(" - Has FILE_DIRECTORY_FILE set.\n");
is_directory = 1;
} else {
if(rc == STATUS_SUCCESS && *PFileHandle != INVALID_HANDLE_VALUE && GetFileAttributesW_orig) {
DWORD attributes = GetFileAttributesW_orig(uni->Buffer);
if(attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
is_directory = 1;
DEBUG_HOOK(" - determined to be a directory by GetFileAttributesW instead of FILE_DIRECTORY_FILE\n");
}
}
}
Expand Down

0 comments on commit d33fd69

Please sign in to comment.