# HG changeset patch # User Paper # Date 1712893158 14400 # Node ID aa55bcfb5b799432c7e2a90d281d1de41e9e2259 # Parent 97ea6a3e1954d05424775e0eb9806bceb442375c win32: make builds work again diff -r 97ea6a3e1954 -r aa55bcfb5b79 include/animone/fd/win32.h --- a/include/animone/fd/win32.h Thu Apr 11 22:05:41 2024 -0400 +++ b/include/animone/fd/win32.h Thu Apr 11 23:39:18 2024 -0400 @@ -4,13 +4,12 @@ #include #include -#include - #include "animone/fd.h" #include "animone/types.h" namespace animone::internal::win32 { +bool GetProcessName(pid_t pid, std::string& name); bool EnumerateOpenProcesses(process_proc_t process_proc); bool EnumerateOpenFiles(const std::set& pids, open_file_proc_t open_file_proc); diff -r 97ea6a3e1954 -r aa55bcfb5b79 include/animone/util/win32.h --- a/include/animone/util/win32.h Thu Apr 11 22:05:41 2024 -0400 +++ b/include/animone/util/win32.h Thu Apr 11 23:39:18 2024 -0400 @@ -1,8 +1,9 @@ #ifndef ANIMONE_ANIMONE_UTIL_WIN32_H_ #define ANIMONE_ANIMONE_UTIL_WIN32_H_ +#include #include -#include +#include #include #include @@ -22,6 +23,7 @@ std::string ToUtf8String(const UNICODE_STRING& string); std::wstring ToWstring(const std::string& string); +std::wstring GetProcessPath(DWORD process_id); std::wstring GetFileNameFromPath(const std::wstring& path); std::wstring GetFileNameWithoutExtension(const std::wstring& filename); diff -r 97ea6a3e1954 -r aa55bcfb5b79 src/fd/win32.cc --- a/src/fd/win32.cc Thu Apr 11 22:05:41 2024 -0400 +++ b/src/fd/win32.cc Thu Apr 11 23:39:18 2024 -0400 @@ -34,7 +34,6 @@ * TODO: implement SystemHandleInformation for systems older than XP */ static constexpr SYSTEM_INFORMATION_CLASS SystemExtendedHandleInformation = static_cast(0x40); -static constexpr SYSTEM_INFORMATION_CLASS SystemHandleInformation = static_cast(0x10); static constexpr NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004UL; /* this is filled in at runtime because it's not guaranteed to be (and isn't) @@ -70,7 +69,9 @@ } NTSTATUS QuerySystemInformation(SYSTEM_INFORMATION_CLASS cls, PVOID sysinfo, ULONG len, - PULONG retlen){return nt_query_system_information(cls, sysinfo, len, retlen)} + PULONG retlen){ + return nt_query_system_information(cls, sysinfo, len, retlen); + } NTSTATUS QueryObject(HANDLE handle, OBJECT_INFORMATION_CLASS cls, PVOID objinf, ULONG objinflen, PULONG retlen) { return nt_query_object(handle, cls, objinf, objinflen, retlen); @@ -80,8 +81,7 @@ HMODULE ntdll; decltype(::NtQuerySystemInformation)* nt_query_system_information; decltype(::NtQueryObject)* nt_query_object; - -} +}; Ntdll ntdll; @@ -96,10 +96,10 @@ /* we should really put a cap on this */ ULONG cb = 1 << 19; NTSTATUS status = STATUS_NO_MEMORY; - std::unique_ptr info(malloc(cb)); + std::unique_ptr info; do { - info.reset(malloc(cb *= 2)); + info.reset(reinterpret_cast(malloc(cb *= 2))); if (!info) continue; @@ -179,11 +179,12 @@ } bool GetProcessName(pid_t pid, std::string& name) { - std::wstring wname = GetProcessPath(); + std::wstring wname = GetProcessPath(pid); if (wname.empty()) return false; - return ToUtf8String(GetFileNameWithoutExtension(GetFileNameFromPath(wname))); + name = ToUtf8String(GetFileNameWithoutExtension(GetFileNameFromPath(wname))); + return true; } bool EnumerateOpenProcesses(process_proc_t process_proc) { diff -r 97ea6a3e1954 -r aa55bcfb5b79 src/win/win32.cc --- a/src/win/win32.cc Thu Apr 11 22:05:41 2024 -0400 +++ b/src/win/win32.cc Thu Apr 11 23:39:18 2024 -0400 @@ -9,6 +9,7 @@ #include "animone.h" #include "animone/util/win32.h" #include "animone/win.h" +#include "animone/fd.h" #include #include @@ -120,9 +121,9 @@ Process process; process.pid = GetWindowProcessId(hwnd); - process.name = fd::GetProcessName(process.pid) + GetProcessName(process.pid, process.name); - auto& window_proc = *reinterpret_cast(param); + auto& window_proc = *reinterpret_cast(param); if (!window_proc(process, window)) return FALSE;