Windows: defines NtCurrentProcess and uses it

This commit is contained in:
李通洲
2026-02-13 16:18:24 +08:00
parent dee4b36a46
commit df87cdfa6e
5 changed files with 11 additions and 4 deletions
+2 -1
View File
@@ -1,13 +1,14 @@
#include "bootmgr.h"
#include "efi_helper.h"
#include "common/io.h"
#include "common/windows/nt.h"
#include <windows.h>
const char* enablePrivilege(const wchar_t* privilege)
{
FF_AUTO_CLOSE_FD HANDLE token = NULL;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token))
if (!OpenProcessToken(NtCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token))
return "OpenProcessToken() failed";
TOKEN_PRIVILEGES tp = {
+1 -1
View File
@@ -12,7 +12,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks)
{
PROCESS_DEVICEMAP_INFORMATION_EX info = {};
ULONG size = 0;
if(!NT_SUCCESS(NtQueryInformationProcess(GetCurrentProcess(), ProcessDeviceMap, &info, sizeof(info), &size)))
if(!NT_SUCCESS(NtQueryInformationProcess(NtCurrentProcess(), ProcessDeviceMap, &info, sizeof(info), &size)))
return "NtQueryInformationProcess(ProcessDeviceMap) failed";
// For cross-platform portability; used by `presets/examples/13.jsonc`
@@ -6,6 +6,7 @@
#include "common/windows/registry.h"
#include "common/windows/unicode.h"
#include "common/windows/version.h"
#include "common/windows/nt.h"
#include "common/stringUtils.h"
#include <stdalign.h>
@@ -223,7 +224,7 @@ static bool detectDefaultTerminal(FFTerminalResult* result)
conhost:;
ULONG_PTR conhostPid = 0;
ULONG size;
if(NT_SUCCESS(NtQueryInformationProcess(GetCurrentProcess(), ProcessConsoleHostProcess, &conhostPid, sizeof(conhostPid), &size)) && conhostPid != 0)
if(NT_SUCCESS(NtQueryInformationProcess(NtCurrentProcess(), ProcessConsoleHostProcess, &conhostPid, sizeof(conhostPid), &size)) && conhostPid != 0)
{
// For Windows Terminal, it reports the PID of OpenConsole
if(ffProcessGetInfoWindows((uint32_t) conhostPid, NULL, &result->processName, &result->exe, &result->exeName, &result->exePath, NULL))