diff dep/animone/src/fd/win32.cc @ 267:09c5bd74fe93

win32: make builds work again
author Paper <paper@paper.us.eu.org>
date Thu, 11 Apr 2024 23:39:18 -0400
parents 862d0d8619f6
children 65df2813d0de
line wrap: on
line diff
--- a/dep/animone/src/fd/win32.cc	Thu Apr 11 22:05:41 2024 -0400
+++ b/dep/animone/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<SYSTEM_INFORMATION_CLASS>(0x40);
-static constexpr SYSTEM_INFORMATION_CLASS SystemHandleInformation = static_cast<SYSTEM_INFORMATION_CLASS>(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<SYSTEM_HANDLE_INFORMATION_EX> info(malloc(cb));
+	std::unique_ptr<SYSTEM_HANDLE_INFORMATION_EX> info;
 
 	do {
-		info.reset(malloc(cb *= 2));
+		info.reset(reinterpret_cast<SYSTEM_HANDLE_INFORMATION_EX*>(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) {