comparison dep/animone/src/fd/win32.cc @ 310:a4257370de16

dep/animone: prepare for v1.0 release; it should be ready by now
author Paper <paper@paper.us.eu.org>
date Tue, 11 Jun 2024 04:38:51 -0400
parents b1f625b0227c
children a7d4e5107531
comparison
equal deleted inserted replaced
309:bf89fbf7ff38 310:a4257370de16
1 /*
2 * fd/win32.cc: support for windows
3 *
4 * this file is noticably more complex than *nix, and that's because
5 * there is no "simple" way to get the paths of a file. In fact, this thing requires
6 * you to use *internal functions* that can't even be linked to, hence why we have to
7 * use GetProcAddress and such. what a mess.
8 *
9 * Speaking of which, because this file uses internal functions of the OS, it is not
10 * even guaranteed to work far into the future. however, just like with macOS, these
11 * things have stayed the same since Vista so if Microsoft *really* wants compatibility
12 * then they're pretty much forced to keeping this the same anyway.
13 */
1 #include "animone/fd/win32.h" 14 #include "animone/fd/win32.h"
2 #include "animone.h" 15 #include "animone.h"
3 #include "animone/util/win32.h" 16 #include "animone/util/win32.h"
4 17
5 #include <stdexcept> 18 #include <stdexcept>
16 #include <stringapiset.h> 29 #include <stringapiset.h>
17 #include <tlhelp32.h> 30 #include <tlhelp32.h>
18 #include <windows.h> 31 #include <windows.h>
19 #include <winternl.h> 32 #include <winternl.h>
20 33
21 /* This file is noticably more complex than Unix and Linux, and that's because
22 * there is no "simple" way to get the paths of a file. In fact, this thing requires
23 * you to use *internal functions* that can't even be linked to, hence why we have to
24 * use GetProcAddress and such. What a mess.
25 *
26 * Speaking of which, because this file uses internal functions of the OS, it is not
27 * guaranteed to work far into the future. However, it has worked since NT 6.0 (Vista)
28 * at least, so it's unlikely to be changed much ever.
29 */
30
31 /* SystemExtendedHandleInformation is only available in NT 5.1+ (XP and higher) and provides information for 34 /* SystemExtendedHandleInformation is only available in NT 5.1+ (XP and higher) and provides information for
32 * 32-bit PIDs, unlike SystemHandleInformation 35 * 32-bit PIDs, unlike SystemHandleInformation
33 */ 36 */
34 static constexpr SYSTEM_INFORMATION_CLASS SystemExtendedHandleInformation = static_cast<SYSTEM_INFORMATION_CLASS>(0x40); 37 static constexpr SYSTEM_INFORMATION_CLASS SystemExtendedHandleInformation = static_cast<SYSTEM_INFORMATION_CLASS>(0x40);
35 static constexpr NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004UL; 38 static constexpr NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004UL;