annotate dep/animia/src/win32.cpp @ 118:39521c47c7a3

*: another huge megacommit, SORRY The torrents page works a lot better now Added the edit option to the anime list right click menu Vectorized currently playing files Available player and extensions are now loaded at runtime from files in (dotpath)/players.json and (dotpath)/extensions.json These paths are not permanent and will likely be moved to (dotpath)/recognition ... ... ...
author Paper <mrpapersonic@gmail.com>
date Tue, 07 Nov 2023 23:40:54 -0500
parents eab9e623eb84
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
1 /**
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
2 * win32.cpp
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
3 * - provides support for Windows clients
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
4 *
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
5 **/
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include "win32.h"
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
7 #include <fileapi.h>
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
8 #include <handleapi.h>
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
9 #include <iostream>
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10 #include <libloaderapi.h>
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #include <ntdef.h>
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 #include <psapi.h>
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
13 #include <shlobj.h>
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
14 #include <stdexcept>
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 #include <string>
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
16 #include <stringapiset.h>
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
17 #include <tlhelp32.h>
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 #include <unordered_map>
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
19 #include <vector>
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
20 #include <windows.h>
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
21 #include <winternl.h>
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
22
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 /* This file is noticably more complex than Unix and Linux, and that's because
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
24 there is no "simple" way to get the paths of a file. In fact, this thing requires
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
25 you to use *internal functions* that can't even be linked to, hence why we have to
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
26 use GetProcAddress and such. What a mess. */
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 #define SystemExtendedHandleInformation ((SYSTEM_INFORMATION_CLASS)0x40)
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 constexpr NTSTATUS STATUS_INFO_LENGTH_MISMATCH = 0xC0000004UL;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 constexpr NTSTATUS STATUS_SUCCESS = 0x00000000UL;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 static unsigned short file_type_index = 0;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 struct SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX {
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
35 PVOID Object;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
36 ULONG_PTR UniqueProcessId;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
37 HANDLE HandleValue;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
38 ACCESS_MASK GrantedAccess;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
39 USHORT CreatorBackTraceIndex;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
40 USHORT ObjectTypeIndex;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
41 ULONG HandleAttributes;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
42 ULONG Reserved;
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 };
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 struct SYSTEM_HANDLE_INFORMATION_EX {
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
46 ULONG_PTR NumberOfHandles;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
47 ULONG_PTR Reserved;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
48 SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handles[1];
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 };
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50
84
eab9e623eb84 dep/animia: update from upstream
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
51 namespace Animia { namespace Windows {
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 /* All of this BS is required on Windows. Why? */
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 HANDLE DuplicateHandle(HANDLE process_handle, HANDLE handle) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56 HANDLE dup_handle = nullptr;
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
57 const bool result =
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
58 ::DuplicateHandle(process_handle, handle, ::GetCurrentProcess(), &dup_handle, 0, false, DUPLICATE_SAME_ACCESS);
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 return result ? dup_handle : nullptr;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 PVOID GetNTDLLAddress(LPCSTR proc_name) {
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
63 return reinterpret_cast<PVOID>(::GetProcAddress(::GetModuleHandleA("ntdll.dll"), proc_name));
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 NTSTATUS QuerySystemInformation(SYSTEM_INFORMATION_CLASS cls, PVOID sysinfo, ULONG len, PULONG retlen) {
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
67 static const auto func =
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
68 reinterpret_cast<decltype(::NtQuerySystemInformation)*>(GetNTDLLAddress("NtQuerySystemInformation"));
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 return func(cls, sysinfo, len, retlen);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72 NTSTATUS QueryObject(HANDLE handle, OBJECT_INFORMATION_CLASS cls, PVOID objinf, ULONG objinflen, PULONG retlen) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 static const auto func = reinterpret_cast<decltype(::NtQueryObject)*>(GetNTDLLAddress("NtQueryObject"));
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74 return func(handle, cls, objinf, objinflen, retlen);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 std::vector<SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX> GetSystemHandleInformation() {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 std::vector<SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX> res;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 ULONG cb = 1 << 19;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 NTSTATUS status = STATUS_SUCCESS;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 SYSTEM_HANDLE_INFORMATION_EX* info;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 do {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 status = STATUS_NO_MEMORY;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 if (!(info = (SYSTEM_HANDLE_INFORMATION_EX*)malloc(cb *= 2)))
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 continue;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
89 res.reserve(cb);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
90
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 if (0 <= (status = QuerySystemInformation(SystemExtendedHandleInformation, info, cb, &cb))) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92 if (ULONG_PTR handles = info->NumberOfHandles) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
93 SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX* entry = info->Handles;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94 do {
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
95 if (entry)
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
96 res.push_back(*entry);
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 } while (entry++, --handles);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 free(info);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 } while (status == STATUS_INFO_LENGTH_MISMATCH);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 return res;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 OBJECT_TYPE_INFORMATION QueryObjectTypeInfo(HANDLE handle) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 OBJECT_TYPE_INFORMATION info;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 QueryObject(handle, ObjectTypeInformation, &info, sizeof(info), NULL);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109 return info;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
111
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
112 /* we're using UTF-8. originally, I had used just the ANSI versions of functions, but that
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
113 sucks massive dick. this way we get unicode in the way every single other OS does it */
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
114 std::string UnicodeStringToUtf8(std::wstring string) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
115 unsigned long size = ::WideCharToMultiByte(CP_UTF8, 0, string.c_str(), string.length(), NULL, 0, NULL, NULL);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
116 std::string ret = std::string(size, '\0');
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
117 ::WideCharToMultiByte(CP_UTF8, 0, string.c_str(), string.length(), &ret.front(), ret.length(), NULL, NULL);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
118 return ret;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
119 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
120
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
121 std::string UnicodeStringToUtf8(UNICODE_STRING string) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
122 unsigned long size = ::WideCharToMultiByte(CP_UTF8, 0, string.Buffer, string.Length, NULL, 0, NULL, NULL);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
123 std::string ret = std::string(size, '\0');
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
124 ::WideCharToMultiByte(CP_UTF8, 0, string.Buffer, string.Length, &ret.front(), ret.length(), NULL, NULL);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
125 return ret;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
126 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
127
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
128 std::wstring Utf8StringToUnicode(std::string string) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
129 unsigned long size = ::MultiByteToWideChar(CP_UTF8, 0, string.c_str(), string.length(), NULL, 0);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
130 std::wstring ret = std::wstring(size, L'\0');
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
131 ::MultiByteToWideChar(CP_UTF8, 0, string.c_str(), string.length(), &ret.front(), ret.length());
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 return ret;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 std::string GetHandleType(HANDLE handle) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 OBJECT_TYPE_INFORMATION info = QueryObjectTypeInfo(handle);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
137 return UnicodeStringToUtf8(info.TypeName);
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
138 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 std::string GetFinalPathNameByHandle(HANDLE handle) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141 std::wstring buffer;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
142
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
143 int result = ::GetFinalPathNameByHandleW(handle, NULL, 0, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
144 buffer.resize(result);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145 ::GetFinalPathNameByHandleW(handle, &buffer.front(), buffer.size(), FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
146 buffer.resize(buffer.find('\0'));
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
148 return UnicodeStringToUtf8(buffer);
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
149 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 bool IsFileHandle(HANDLE handle, unsigned short object_type_index) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 if (file_type_index)
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 return object_type_index == file_type_index;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 else if (!handle)
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 return true;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156 else if (GetHandleType(handle) == "File") {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157 file_type_index = object_type_index;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158 return true;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
159 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160 return false;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 bool IsFileMaskOk(ACCESS_MASK access_mask) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164 if (!(access_mask & FILE_READ_DATA))
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
165 return false;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
167 if ((access_mask & FILE_APPEND_DATA) || (access_mask & FILE_WRITE_EA) || (access_mask & FILE_WRITE_ATTRIBUTES))
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
168 return false;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
169
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170 return true;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
173 bool IsFilePathOk(const std::string& path) {
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
174 if (path.empty())
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
175 return false;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
176
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
177 const auto file_attributes = GetFileAttributesA(path.c_str());
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
178 if ((file_attributes == INVALID_FILE_ATTRIBUTES) || (file_attributes & FILE_ATTRIBUTE_DIRECTORY))
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
179 return false;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
180
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
181 return true;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
182 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
183
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
184 std::string GetSystemDirectory() {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
185 PWSTR path_wch;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
186 SHGetKnownFolderPath(FOLDERID_Windows, 0, NULL, &path_wch);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
187 std::wstring path_wstr(path_wch);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
188 CoTaskMemFree(path_wch);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
189 return UnicodeStringToUtf8(path_wstr);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
190 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
191
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
192 bool IsSystemFile(const std::string& path) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
193 std::wstring path_w = Utf8StringToUnicode(path);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
194 CharUpperBuffW(&path_w.front(), path_w.length());
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
195 std::wstring windir_w = Utf8StringToUnicode(GetSystemDirectory());
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
196 CharUpperBuffW(&windir_w.front(), windir_w.length());
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
197 return path_w.find(windir_w) == 4;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
198 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
199
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
200 std::vector<int> get_all_pids() {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
201 std::vector<int> ret;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
202 HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
203 PROCESSENTRY32 pe32;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
204 pe32.dwSize = sizeof(PROCESSENTRY32);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
205
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
206 if (hProcessSnap == INVALID_HANDLE_VALUE)
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
207 return std::vector<int>();
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
208
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
209 if (!Process32First(hProcessSnap, &pe32))
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
210 return std::vector<int>();
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
211
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
212 ret.push_back(pe32.th32ProcessID);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
213 while (Process32Next(hProcessSnap, &pe32)) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
214 ret.push_back(pe32.th32ProcessID);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
215 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
216 // clean the snapshot object
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
217 CloseHandle(hProcessSnap);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
218
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
219 return ret;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
220 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
221
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
222 std::string get_process_name(int pid) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
223 unsigned long size = 256, ret_size = 0;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
224 HANDLE handle = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
225 if (!handle)
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
226 return "";
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
227
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
228 std::wstring ret(size, L'\0');
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
229 while (size < 32768) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
230 ret.resize(size, L'\0');
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
231
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
232 if (!(ret_size = ::GetModuleBaseNameW(handle, 0, &ret.front(), ret.length())))
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
233 ret = L"";
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
234 else if (size > ret_size)
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
235 ret.resize(ret.find('\0'));
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
236
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
237 size *= 2;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
238 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
239
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
240 CloseHandle(handle);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
241
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
242 return UnicodeStringToUtf8(ret);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
243 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
244
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
245 std::vector<std::string> get_open_files(int pid) {
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
246 std::vector<std::string> ret;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
247 std::vector<SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX> info = GetSystemHandleInformation();
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
248 for (auto& h : info) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
249 if (h.UniqueProcessId != pid)
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
250 continue;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
251
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
252 if (!IsFileHandle(nullptr, h.ObjectTypeIndex))
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
253 continue;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
254 if (!IsFileMaskOk(h.GrantedAccess))
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
255 continue;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
256
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
257 const HANDLE proc = ::OpenProcess(PROCESS_DUP_HANDLE, false, pid);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
258 HANDLE handle = DuplicateHandle(proc, h.HandleValue);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
259 if (!handle)
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
260 continue;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
261
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
262 if (GetFileType(handle) != FILE_TYPE_DISK)
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
263 continue;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
264
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
265 std::string path = GetFinalPathNameByHandle(handle);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
266 if (!IsFilePathOk(path))
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
267 continue;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
268
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
269 ret.push_back(path);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
270 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
271 return ret;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
272 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
273
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
274 std::vector<std::string> filter_system_files(const std::vector<std::string>& source) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
275 std::vector<std::string> ret;
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
276 for (const std::string& s : source) {
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
277 if (!IsSystemFile(s))
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
278 ret.push_back(s);
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
279 }
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 56
diff changeset
280 return ret;
56
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
281 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
282
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
283 std::unordered_map<int, std::vector<std::string>> get_all_open_files() {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
284 std::unordered_map<int, std::vector<std::string>> map;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
285 std::vector<SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX> info = GetSystemHandleInformation();
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
286 for (auto& h : info) {
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
287 int pid = h.UniqueProcessId;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
288
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
289 if (!IsFileHandle(nullptr, h.ObjectTypeIndex))
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
290 continue;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
291 if (!IsFileMaskOk(h.GrantedAccess))
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
292 continue;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
293
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
294 const HANDLE proc = ::OpenProcess(PROCESS_DUP_HANDLE, false, pid);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
295 HANDLE handle = DuplicateHandle(proc, h.HandleValue);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
296 if (!handle)
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
297 continue;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
298
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
299 if (GetFileType(handle) != FILE_TYPE_DISK)
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
300 continue;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
301
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
302 std::string path = GetFinalPathNameByHandle(handle);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
303 if (!IsFilePathOk(path))
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
304 continue;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
305
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
306 if (map.find(pid) == map.end())
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
307 map[pid] = {};
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
308 map[pid].push_back(path);
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
309 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
310 return map;
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
311 }
6ff7aabeb9d7 deps: add animia for open files detection
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
312
84
eab9e623eb84 dep/animia: update from upstream
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
313 } // namespace Windows
eab9e623eb84 dep/animia: update from upstream
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
314 } // namespace Animia