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:
2 files changed
+29
-30
No files matched your search
+13
-13
@@ -13,12 +13,13 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL Java_nativeAgentInit(JNIEnv* env, jclass clazz, jobjectArray args, jobject instrumentation);
|
||||
extern "C" JNIEXPORT jint JNICALL Java_nativeAgentStart(JNIEnv* env, jclass clazz);
|
||||
extern "C" JNIEXPORT jint JNICALL Java_ru_faumaray_VoidLoaderAgent_nativeAgentStart(JNIEnv* env, jclass clazz);
|
||||
extern "C" JNIEXPORT jint JNICALL Java_ru_faumaray_VoidLoaderAgent_nativeAgentInit(JNIEnv* env, jclass jclass, jobject instrumentation, jobjectArray args);
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_ru_faumaray_VoidLoaderAgent_nativeCleanup(JNIEnv* env, jclass clazz);
|
||||
extern "C" {
|
||||
JNIEXPORT jint JNICALL Java_nativeAgentInit(JNIEnv*, jclass, jobjectArray, jobject);
|
||||
JNIEXPORT jint JNICALL Java_nativeAgentStart(JNIEnv*, jclass);
|
||||
JNIEXPORT jint JNICALL Java_ru_faumaray_VoidLoaderAgent_nativeAgentStart(JNIEnv*, jclass);
|
||||
JNIEXPORT jint JNICALL Java_ru_faumaray_VoidLoaderAgent_nativeAgentInit(JNIEnv*, jclass, jobject, jobjectArray);
|
||||
JNIEXPORT void JNICALL Java_ru_faumaray_VoidLoaderAgent_nativeCleanup(JNIEnv*, jclass);
|
||||
}
|
||||
namespace vl::Agent {
|
||||
|
||||
class Agent {
|
||||
@@ -56,12 +57,11 @@ public:
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::filesystem::path> findMods(const std::string& dir);
|
||||
friend int JNICALL ::Java_nativeAgentInit(JNIEnv* env, jclass clazz, jobjectArray args, jobject instrumentation);
|
||||
friend int JNICALL ::Java_nativeAgentInit(JNIEnv* env, jclass clazz, jobjectArray args, jobject instrumentation);
|
||||
friend int JNICALL ::Java_nativeAgentStart(JNIEnv* env, jclass clazz);
|
||||
friend int JNICALL ::Java_ru_faumaray_VoidLoaderAgent_nativeAgentStart(JNIEnv* env, jclass clazz);
|
||||
friend int JNICALL ::Java_ru_faumaray_VoidLoaderAgent_nativeAgentInit(JNIEnv* env, jclass jclass, jobject instrumentation, jobjectArray args);
|
||||
friend void JNICALL ::Java_ru_faumaray_VoidLoaderAgent_nativeCleanup(JNIEnv* env, jclass clazz);
|
||||
friend jint ::Java_nativeAgentInit(JNIEnv*, jclass, jobjectArray, jobject);
|
||||
friend jint ::Java_nativeAgentStart(JNIEnv*, jclass);
|
||||
friend jint ::Java_ru_faumaray_VoidLoaderAgent_nativeAgentStart(JNIEnv*, jclass);
|
||||
friend jint ::Java_ru_faumaray_VoidLoaderAgent_nativeAgentInit(JNIEnv*, jclass, jobject, jobjectArray);
|
||||
friend void ::Java_ru_faumaray_VoidLoaderAgent_nativeCleanup(JNIEnv*, jclass);
|
||||
friend class ClassTransformer;
|
||||
friend class vl::mod::ModLoader;
|
||||
private:
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
std::unique_ptr<vl::mod::ModLoader> m_modloader;
|
||||
std::unique_ptr<ClassTransformer> m_transformer;
|
||||
vl::mod::Context m_context;
|
||||
std::atomic<bool> m_isValid;
|
||||
std::atomic<bool> m_isValid{false};
|
||||
std::shared_ptr<vl::logging::Logger> m_logger;
|
||||
static std::unique_ptr<Agent> instance_;
|
||||
static std::once_flag initFlag_;
|
||||
|
||||
+16
-17
@@ -17,18 +17,17 @@ namespace vl::Agent {
|
||||
auto currentPath = std::filesystem::current_path();
|
||||
if (!args.contains("gameDir"))
|
||||
{
|
||||
args["gameDir"] = currentPath;
|
||||
args["gameDir"] = currentPath.string();
|
||||
}
|
||||
auto gameDir = args["gameDir"];
|
||||
auto dataDir = args["gameDir"] + std::filesystem::path::preferred_separator + "data";
|
||||
auto logDir = args["gameDir"] + std::filesystem::path::preferred_separator + "logs";
|
||||
auto modsDir = args["gameDir"] + std::filesystem::path::preferred_separator + "mods";
|
||||
m_context = {
|
||||
.gameDir = std::move(gameDir),
|
||||
.dataDir = std::move(dataDir),
|
||||
.logDir = std::move(logDir),
|
||||
.apiVersion = {1,0,0},
|
||||
};
|
||||
std::filesystem::path gameDir = args["gameDir"];
|
||||
std::filesystem::path dataDir = gameDir / "data";
|
||||
std::filesystem::path logDir = gameDir / "logs";
|
||||
std::filesystem::path modsDir = gameDir / "mods";
|
||||
m_context = {}; // if defaultable
|
||||
m_context.gameDir = std::move(gameDir);
|
||||
m_context.dataDir = std::move(dataDir);
|
||||
m_context.logDir = std::move(logDir);
|
||||
m_context.apiVersion = {1,0,0};
|
||||
auto mods = findMods(modsDir);
|
||||
if (!mods.contains("VoidLoaderApi.vlmod"))
|
||||
{
|
||||
@@ -58,7 +57,7 @@ namespace vl::Agent {
|
||||
std::unordered_map<std::string, std::filesystem::path> result;
|
||||
for (auto& entry : std::filesystem::directory_iterator(dir)) {
|
||||
if (entry.path().extension() == ".vlmod") {
|
||||
result.emplace(entry.path().filename(), std::filesystem::absolute(entry.path()));
|
||||
result.emplace(entry.path().filename().string(), std::filesystem::absolute(entry.path()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -81,7 +80,7 @@ extern "C" JNIEXPORT jint JNICALL Java_nativeAgentInit(JNIEnv* env, jclass clazz
|
||||
|
||||
auto& instance = vl::Agent::Agent::getInstance(argsMap);
|
||||
try {
|
||||
auto coreLogDir = std::string(instance.m_context.logDir) + std::filesystem::path::preferred_separator + "VoidLoader";
|
||||
auto coreLogDir = (instance.m_context.logDir / "VoidLoader").string();
|
||||
vl::logging::init_voidloader_logger();
|
||||
instance.m_logger = vl::logging::LoggerManager::instance().createCombined("VoidLoader", coreLogDir.c_str(), 512'000, vl::logging::Level::Trace);
|
||||
vl::logging::LoggerManager::instance().createConsole("VoidLoader")->setLevel(vl::logging::Level::Info);
|
||||
@@ -104,9 +103,9 @@ extern "C" JNIEXPORT jint JNICALL Java_nativeAgentInit(JNIEnv* env, jclass clazz
|
||||
instance.m_jni = env;
|
||||
|
||||
jvmtiEventCallbacks callbacks = {0};
|
||||
callbacks.ClassFileLoadHook = &instance.m_transformer->classFileLoadHook;
|
||||
callbacks.VMInit = &instance.vmInit;
|
||||
callbacks.VMDeath = &instance.vmDeath;
|
||||
callbacks.ClassFileLoadHook = &ClassTransformer::classFileLoadHook; // provide a static thunk
|
||||
callbacks.VMInit = &vl::Agent::Agent::vmInit; // static
|
||||
callbacks.VMDeath = &vl::Agent::Agent::vmDeath; // static
|
||||
|
||||
auto cerror = instance.m_jmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
|
||||
if (cerror != JVMTI_ERROR_NONE) {
|
||||
@@ -134,7 +133,7 @@ extern "C" JNIEXPORT jint JNICALL Java_nativeAgentStart(JNIEnv* env, jclass claz
|
||||
for (auto& [name, path] : instance.m_mods)
|
||||
{
|
||||
instance.m_logger->trace("Loading mod: {}", name);
|
||||
loaded += instance.m_modloader->loadModule(path, instance.m_context, false);
|
||||
loaded += instance.m_modloader->loadModule(path.string(), instance.m_context, false);
|
||||
}
|
||||
instance.m_logger->info("Mods loaded: {}, Starting", loaded);
|
||||
|
||||
|
||||
Reference in new issue
Block a user