Global (Windows): prefers NtClose over CloseHandle

This commit is contained in:
李通洲
2026-03-13 10:58:38 +08:00
parent ea6ad4ac86
commit ca9c67353f
5 changed files with 11 additions and 11 deletions
+3 -3
View File
@@ -128,12 +128,12 @@ static bool createSubfolders(wchar_t* fileName)
if (!NT_SUCCESS(status))
{
if (closeRoot && hRoot != INVALID_HANDLE_VALUE)
CloseHandle(hRoot);
NtClose(hRoot);
return false;
}
if (closeRoot && hRoot != INVALID_HANDLE_VALUE)
CloseHandle(hRoot);
NtClose(hRoot);
hRoot = hNew;
closeRoot = true;
@@ -141,7 +141,7 @@ static bool createSubfolders(wchar_t* fileName)
}
if (closeRoot && hRoot != INVALID_HANDLE_VALUE)
CloseHandle(hRoot);
NtClose(hRoot);
return true;
}
+2 -2
View File
@@ -116,7 +116,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle*
&piProcInfo // receives PROCESS_INFORMATION
);
CloseHandle(hChildPipeWrite);
NtClose(hChildPipeWrite);
if(!success)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
@@ -124,7 +124,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle*
return "CreateProcessA() failed";
}
CloseHandle(piProcInfo.hThread); // we don't need the thread handle
NtClose(piProcInfo.hThread); // we don't need the thread handle
outHandle->pid = piProcInfo.hProcess;
outHandle->pipeRead = hChildPipeRead;
hChildPipeRead = INVALID_HANDLE_VALUE; // ownership transferred, don't close it
+1 -1
View File
@@ -204,7 +204,7 @@ static inline bool wrapClose(FFNativeFD* pfd)
#ifndef _WIN32
close(*pfd);
#else
CloseHandle(*pfd);
NtClose(*pfd);
#endif
return true;
+4 -4
View File
@@ -4,7 +4,7 @@
#ifdef FF_HAVE_THREADS
#if defined(_WIN32)
#include <handleapi.h>
#include <winternl.h>
#include <synchapi.h>
#include <process.h>
#include <processthreadsapi.h>
@@ -18,16 +18,16 @@
}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static __stdcall unsigned fn ## ThreadMain (void* data) { fn((paramType)data); return 0; }
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) static __stdcall unsigned fn ## ThreadMain () { fn(); return 0; }
static inline void ffThreadDetach(FFThreadType thread) { CloseHandle(thread); }
static inline void ffThreadDetach(FFThreadType thread) { NtClose(thread); }
static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout)
{
if (WaitForSingleObject(thread, timeout == 0 ? (DWORD) -1 : timeout) != 0 /*WAIT_OBJECT_0*/)
{
TerminateThread(thread, (DWORD) -1);
CloseHandle(thread);
NtClose(thread);
return false;
}
CloseHandle(thread);
NtClose(thread);
return true;
}
#else
@@ -98,7 +98,7 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
device->connectable = ffBluetoothIsConnectable(hRadio);
device->discoverable = ffBluetoothIsDiscoverable(hRadio);
CloseHandle(hRadio);
NtClose(hRadio);
} while (ffBluetoothFindNextRadio(hFind, &hRadio));
ffBluetoothFindRadioClose(hFind);