mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Windows: defines NtCurrentProcess and uses it
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "common/processing.h"
|
||||
#include "common/io.h"
|
||||
#include "common/windows/unicode.h"
|
||||
#include "common/windows/nt.h"
|
||||
|
||||
#include <stdalign.h>
|
||||
#include <windows.h>
|
||||
@@ -213,7 +214,7 @@ exit:
|
||||
bool ffProcessGetInfoWindows(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName, FFstrbuf* exePath, bool* gui)
|
||||
{
|
||||
FF_AUTO_CLOSE_FD HANDLE hProcess = pid == 0
|
||||
? GetCurrentProcess()
|
||||
? NtCurrentProcess()
|
||||
: OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
|
||||
|
||||
if (hProcess == NULL)
|
||||
|
||||
@@ -266,3 +266,7 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX
|
||||
};
|
||||
ULONG Flags; // PROCESS_LUID_DOSDEVICES_ONLY
|
||||
} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX;
|
||||
|
||||
#ifndef NtCurrentProcess
|
||||
#define NtCurrentProcess() ((HANDLE)(LONG_PTR)-1)
|
||||
#endif
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user