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