fixing mingw errors
VoidLoader/VoidLoaderCore/pipeline/head There was a failure building this commit
VoidLoader/VoidLoaderCore/pipeline/head There was a failure building this commit
Signed-off-by: Faumaray <faumaray@gmail.com>
This commit is contained in:
5 files changed
+125
-119
No files matched your search
@@ -1,9 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#if defined(unix)
|
#if defined(unix)
|
||||||
#include <string>
|
#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
|
#endif
|
||||||
@@ -2,8 +2,9 @@
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
namespace vl::mod {
|
||||||
void* LoadLibrary(const std::string& path, bool isGlobal);
|
void* LoadLibrary(const std::string& path, bool isGlobal);
|
||||||
bool CloseLibrary(void* handle);
|
bool CloseLibrary(void* handle);
|
||||||
void* LoadSymbol(void* handle, const std::string& name);
|
void* LoadSymbol(void* handle, const std::string& name);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
+1
-1
@@ -35,7 +35,7 @@ namespace vl::Agent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadLibrary(mods.at("VoidLoaderApi.vlmod").string(), true);
|
vl::mod::LoadLibrary(mods.at("VoidLoaderApi.vlmod").string(), true);
|
||||||
mods.erase("VoidLoaderApi.vlmod");
|
mods.erase("VoidLoaderApi.vlmod");
|
||||||
mods.erase("VoidLoader.vlmod");
|
mods.erase("VoidLoader.vlmod");
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,20 @@
|
|||||||
|
|
||||||
#include <Mods/LoadLibraryUnix.hpp>
|
#include <Mods/LoadLibraryUnix.hpp>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
namespace vl::mod {
|
||||||
void* LoadLibrary(const std::string& path, bool isGlobal)
|
void* LoadLibrary(const std::string& path, bool isGlobal)
|
||||||
{
|
{
|
||||||
dlerror();
|
dlerror();
|
||||||
return dlopen(path.c_str(), isGlobal ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW);
|
return dlopen(path.c_str(), isGlobal ? RTLD_NOW | RTLD_GLOBAL : RTLD_NOW);
|
||||||
}
|
}
|
||||||
bool CloseLibrary(void* handle)
|
bool CloseLibrary(void* handle)
|
||||||
{
|
{
|
||||||
return dlclose(handle) == 0;
|
return dlclose(handle) == 0;
|
||||||
}
|
}
|
||||||
void* LoadSymbol(void* handle, const std::string& name)
|
void* LoadSymbol(void* handle, const std::string& name)
|
||||||
{
|
{
|
||||||
dlerror();
|
dlerror();
|
||||||
return dlsym(handle, name.c_str());
|
return dlsym(handle, name.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
+99
-97
@@ -4,111 +4,113 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <windows.h>
|
#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;
|
namespace vl::mod {
|
||||||
if (b1 <= 0x7F)
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
return b1; /* ASCII code point */
|
static int32_t __wtf8_decode1(const char** input) {
|
||||||
if (b1 < 0xC2)
|
uint32_t code_point;
|
||||||
return -1; /* invalid: continuation byte */
|
uint8_t b1;
|
||||||
code_point = b1;
|
uint8_t b2;
|
||||||
|
uint8_t b3;
|
||||||
|
uint8_t b4;
|
||||||
|
|
||||||
b2 = *++*input;
|
b1 = **input;
|
||||||
if ((b2 & 0xC0) != 0x80)
|
if (b1 <= 0x7F)
|
||||||
return -1; /* invalid: not a continuation byte */
|
return b1; /* ASCII code point */
|
||||||
code_point = (code_point << 6) | (b2 & 0x3F);
|
if (b1 < 0xC2)
|
||||||
if (b1 <= 0xDF)
|
return -1; /* invalid: continuation byte */
|
||||||
return 0x7FF & code_point; /* two-byte character */
|
code_point = b1;
|
||||||
|
|
||||||
b3 = *++*input;
|
b2 = *++*input;
|
||||||
if ((b3 & 0xC0) != 0x80)
|
if ((b2 & 0xC0) != 0x80)
|
||||||
return -1; /* invalid: not a continuation byte */
|
return -1; /* invalid: not a continuation byte */
|
||||||
code_point = (code_point << 6) | (b3 & 0x3F);
|
code_point = (code_point << 6) | (b2 & 0x3F);
|
||||||
if (b1 <= 0xEF)
|
if (b1 <= 0xDF)
|
||||||
return 0xFFFF & code_point; /* three-byte character */
|
return 0x7FF & code_point; /* two-byte character */
|
||||||
|
|
||||||
b4 = *++*input;
|
b3 = *++*input;
|
||||||
if ((b4 & 0xC0) != 0x80)
|
if ((b3 & 0xC0) != 0x80)
|
||||||
return -1; /* invalid: not a continuation byte */
|
return -1; /* invalid: not a continuation byte */
|
||||||
code_point = (code_point << 6) | (b4 & 0x3F);
|
code_point = (code_point << 6) | (b3 & 0x3F);
|
||||||
if (b1 <= 0xF4) {
|
if (b1 <= 0xEF)
|
||||||
code_point &= 0x1FFFFF;
|
return 0xFFFF & code_point; /* three-byte character */
|
||||||
if (code_point <= 0x10FFFF)
|
|
||||||
return code_point; /* four-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 */
|
ssize_t wtf8_length_as_utf16(const char* source_ptr) {
|
||||||
return -1;
|
size_t w_target_len = 0;
|
||||||
}
|
int32_t code_point;
|
||||||
|
|
||||||
ssize_t wtf8_length_as_utf16(const char* source_ptr) {
|
do {
|
||||||
size_t w_target_len = 0;
|
code_point = __wtf8_decode1(&source_ptr);
|
||||||
int32_t code_point;
|
if (code_point < 0)
|
||||||
|
return -1;
|
||||||
do {
|
if (code_point > 0xFFFF)
|
||||||
code_point = __wtf8_decode1(&source_ptr);
|
w_target_len++;
|
||||||
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
|
#endif
|
||||||
Reference in new issue
Block a user