fixing mingw errors
VoidLoader/VoidLoaderCore/pipeline/head There was a failure building this commit

Signed-off-by: Faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2025-10-21 00:31:17 +03:00
1 parent df54abb9ad
commit 71bfa7b32d
5 files changed
+125 -119

No files matched your search

+5 -3
View File
@@ -1,9 +1,11 @@
#pragma once
#if defined(unix)
#include <string>
namespace vl::mod {
void* LoadLibrary(const std::string& path, bool isGlobal);
bool CloseLibrary(void* handle);
void* LoadSymbol(void* handle, const std::string& name);
void* LoadLibrary(const std::string& path, bool isGlobal);
bool CloseLibrary(void* handle);
void* LoadSymbol(void* handle, const std::string& name);
}
#endif
+5 -4
View File
@@ -2,8 +2,9 @@
#if defined(_WIN32)
#include <string>
void* LoadLibrary(const std::string& path, bool isGlobal);
bool CloseLibrary(void* handle);
void* LoadSymbol(void* handle, const std::string& name);
namespace vl::mod {
void* LoadLibrary(const std::string& path, bool isGlobal);
bool CloseLibrary(void* handle);
void* LoadSymbol(void* handle, const std::string& name);
}
#endif
+1 -1
View File
@@ -35,7 +35,7 @@ namespace vl::Agent {
return;
}
LoadLibrary(mods.at("VoidLoaderApi.vlmod").string(), true);
vl::mod::LoadLibrary(mods.at("VoidLoaderApi.vlmod").string(), true);
mods.erase("VoidLoaderApi.vlmod");
mods.erase("VoidLoader.vlmod");
+15 -14
View File
@@ -2,19 +2,20 @@
#include <Mods/LoadLibraryUnix.hpp>
#include <dlfcn.h>
void* LoadLibrary(const std::string& path, bool isGlobal)
{
dlerror();
return dlopen(path.c_str(), isGlobal ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW);
}
bool CloseLibrary(void* handle)
{
return dlclose(handle) == 0;
}
void* LoadSymbol(void* handle, const std::string& name)
{
dlerror();
return dlsym(handle, name.c_str());
namespace vl::mod {
void* LoadLibrary(const std::string& path, bool isGlobal)
{
dlerror();
return dlopen(path.c_str(), isGlobal ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW);
}
bool CloseLibrary(void* handle)
{
return dlclose(handle) == 0;
}
void* LoadSymbol(void* handle, const std::string& name)
{
dlerror();
return dlsym(handle, name.c_str());
}
}
#endif
+99 -97
View File
@@ -4,111 +4,113 @@
#include <assert.h>
#include <cstdint>
#include <windows.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
static int32_t __wtf8_decode1(const char** input) {
uint32_t code_point;
uint8_t b1;
uint8_t b2;
uint8_t b3;
uint8_t b4;
b1 = **input;
if (b1 <= 0x7F)
return b1; /* ASCII code point */
if (b1 < 0xC2)
return -1; /* invalid: continuation byte */
code_point = b1;
namespace vl::mod {
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
static int32_t __wtf8_decode1(const char** input) {
uint32_t code_point;
uint8_t b1;
uint8_t b2;
uint8_t b3;
uint8_t b4;
b2 = *++*input;
if ((b2 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b2 & 0x3F);
if (b1 <= 0xDF)
return 0x7FF & code_point; /* two-byte character */
b1 = **input;
if (b1 <= 0x7F)
return b1; /* ASCII code point */
if (b1 < 0xC2)
return -1; /* invalid: continuation byte */
code_point = b1;
b3 = *++*input;
if ((b3 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b3 & 0x3F);
if (b1 <= 0xEF)
return 0xFFFF & code_point; /* three-byte character */
b2 = *++*input;
if ((b2 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b2 & 0x3F);
if (b1 <= 0xDF)
return 0x7FF & code_point; /* two-byte character */
b4 = *++*input;
if ((b4 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b4 & 0x3F);
if (b1 <= 0xF4) {
code_point &= 0x1FFFFF;
if (code_point <= 0x10FFFF)
return code_point; /* four-byte character */
b3 = *++*input;
if ((b3 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b3 & 0x3F);
if (b1 <= 0xEF)
return 0xFFFF & code_point; /* three-byte character */
b4 = *++*input;
if ((b4 & 0xC0) != 0x80)
return -1; /* invalid: not a continuation byte */
code_point = (code_point << 6) | (b4 & 0x3F);
if (b1 <= 0xF4) {
code_point &= 0x1FFFFF;
if (code_point <= 0x10FFFF)
return code_point; /* four-byte character */
}
/* code point too large */
return -1;
}
/* code point too large */
return -1;
}
ssize_t wtf8_length_as_utf16(const char* source_ptr) {
size_t w_target_len = 0;
int32_t code_point;
ssize_t wtf8_length_as_utf16(const char* source_ptr) {
size_t w_target_len = 0;
int32_t code_point;
do {
code_point = __wtf8_decode1(&source_ptr);
if (code_point < 0)
return -1;
if (code_point > 0xFFFF)
do {
code_point = __wtf8_decode1(&source_ptr);
if (code_point < 0)
return -1;
if (code_point > 0xFFFF)
w_target_len++;
w_target_len++;
w_target_len++;
} while (*source_ptr++);
} while (*source_ptr++);
return w_target_len;
return w_target_len;
}
void wtf8_to_utf16(const char* source_ptr,
WCHAR* w_target,
size_t w_target_len) {
int32_t code_point;
do {
code_point = __wtf8_decode1(&source_ptr);
/* uv_wtf8_length_as_utf16 should have been called and checked first. */
assert(code_point >= 0);
if (code_point > 0xFFFF) {
assert(code_point < 0x10FFFF);
*w_target++ = (((code_point - 0x10000) >> 10) + 0xD800);
*w_target++ = ((code_point - 0x10000) & 0x3FF) + 0xDC00;
w_target_len -= 2;
} else {
*w_target++ = code_point;
w_target_len -= 1;
}
} while (*source_ptr++);
(void)w_target_len;
assert(w_target_len == 0);
}
void* LoadLibrary(const std::string& path, bool isGlobal)
{
WCHAR filename_w[32768];
ssize_t r;
void* handle = nullptr;
r = wtf8_length_as_utf16(path.c_str());
if (r < 0)
return nullptr;
if ((size_t) r > ARRAY_SIZE(filename_w))
return nullptr;
wtf8_to_utf16(path.c_str(), filename_w, r);
return LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
bool CloseLibrary(void* handle)
{
return FreeLibrary(static_cast<HMODULE>(handle)) != 0;
}
void* LoadSymbol(void* handle, const std::string& name)
{
return (void*)(uintptr_t) GetProcAddress(static_cast<HMODULE>(handle), name.c_str());
}
}
void wtf8_to_utf16(const char* source_ptr,
WCHAR* w_target,
size_t w_target_len) {
int32_t code_point;
do {
code_point = __wtf8_decode1(&source_ptr);
/* uv_wtf8_length_as_utf16 should have been called and checked first. */
assert(code_point >= 0);
if (code_point > 0xFFFF) {
assert(code_point < 0x10FFFF);
*w_target++ = (((code_point - 0x10000) >> 10) + 0xD800);
*w_target++ = ((code_point - 0x10000) & 0x3FF) + 0xDC00;
w_target_len -= 2;
} else {
*w_target++ = code_point;
w_target_len -= 1;
}
} while (*source_ptr++);
(void)w_target_len;
assert(w_target_len == 0);
}
void* LoadLibrary(const std::string& path, bool isGlobal)
{
WCHAR filename_w[32768];
ssize_t r;
void* handle = nullptr;
r = wtf8_length_as_utf16(path.c_str());
if (r < 0)
return nullptr;
if ((size_t) r > ARRAY_SIZE(filename_w))
return nullptr;
wtf8_to_utf16(path.c_str(), filename_w, r);
return LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
}
bool CloseLibrary(void* handle)
{
return FreeLibrary(static_cast<HMODULE>(handle)) != 0;
}
void* LoadSymbol(void* handle, const std::string& name)
{
return (void*)(uintptr_t) GetProcAddress(static_cast<HMODULE>(handle), name.c_str());
}
#endif