Initial Commit

This commit is contained in:
2023-01-02 23:35:53 -05:00
parent a302b49950
commit ceee973ad7
150 changed files with 12229 additions and 89 deletions

29
util/lib.c Normal file
View File

@ -0,0 +1,29 @@
#include <windows.h>
#include <stdbool.h>
wchar_t *module_file_name(HMODULE module)
{
size_t buf_len;
DWORD len;
wchar_t *buf;
buf_len = MAX_PATH;
buf = malloc(buf_len * sizeof(*buf));
while (true) {
len = GetModuleFileNameW(module, buf, buf_len);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
buf_len = len;
buf = realloc(buf, buf_len * sizeof(*buf));
break;
}
buf_len *= 2;
buf = realloc(buf, buf_len * sizeof(*buf));
}
return buf;
}