diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2023-05-21 21:48:52 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2023-05-21 22:11:16 +0100 |
commit | 2ba71f27c46dc38b76e932b1b1967d96a9b9f107 (patch) | |
tree | 0b38c40d0e562e4d4e6cf39aff40bcefee204c4a /src/os-win32.h | |
parent | 5dff423338e82a8d9a201534f3f10aee7de0ad56 (diff) |
Improve os_dlfile() interface
Might as well return the length since we have it anyway. Also this maybe
fixes the totally busted Linux code but it's still untested and probably
doesn't work for reasons that will be discovered later on.
Diffstat (limited to 'src/os-win32.h')
-rw-r--r-- | src/os-win32.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/os-win32.h b/src/os-win32.h index 8f554bd..365e2dc 100644 --- a/src/os-win32.h +++ b/src/os-win32.h @@ -53,16 +53,16 @@ static inline void *os_dlsym(void *m, const char *s) { return (void *)GetProcAddress(m, s); } -static inline bool os_dlfile(void *m, unsigned short *buf, int sz) { +static inline int os_dlfile(void *m, unsigned short *buf, int sz) { unsigned int n = GetModuleFileNameW(m, buf, sz); - if (n == 0 || n == sz) return false; + if (n == 0 || n == sz) return -1; // get the canonical capitalisation, as for some reason GetModuleFileName() // returns all lowercase. this doesn't really matter except it looks nicer GetLongPathNameW(buf, buf, n + 1); // the drive letter will also be lower case, if it is an actual drive letter // of course. it should be; I'm not gonna lose sleep over UNC paths and such if (buf[0] >= L'a' && buf[0] <= L'z' && buf[1] == L':') buf[0] &= ~32u; - return true; + return n; } static inline bool os_mprot(void *addr, int len, int fl) { |