diff --git a/Chakra/Chakra.cpp b/Chakra/Chakra.cpp index 90d89b881e..f6b396538f 100644 --- a/Chakra/Chakra.cpp +++ b/Chakra/Chakra.cpp @@ -3,7 +3,27 @@ #include "pch.h" #include "framework.h" +#include #include "Chakra.h" +void preload() { + static std::vector> libs; + std::filesystem::create_directory("plugins_preload"); + std::filesystem::directory_iterator ent("plugins_preload"); + std::cout << "[Chakra] Loading preload plugins\n"; + for (auto& i : ent) { + if (i.is_regular_file() && i.path().extension() == ".dll") { + auto lib = LoadLibrary(i.path().c_str()); + if (lib) { + std::cout << "[Chakra] Plugin " << canonical(i.path()) << " loaded\n"; + libs.push_back({ std::wstring{ i.path().c_str() }, lib }); + } + else { + std::cout << "[Chakra] Error when loading " << i.path() << "\n"; + } + } + } +} + #pragma comment(linker, "/export:HookFunction=LiteLoader.HookFunction") #pragma comment(linker, "/export:GetServerSymbol=LiteLoader.dlsym_real") \ No newline at end of file diff --git a/Chakra/Chakra.vcxproj b/Chakra/Chakra.vcxproj index 2829cdefff..2c9cd1d9e2 100644 --- a/Chakra/Chakra.vcxproj +++ b/Chakra/Chakra.vcxproj @@ -146,6 +146,7 @@ NDEBUG;CHAKRA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true pch.h + stdcpp17 Windows diff --git a/Chakra/dllmain.cpp b/Chakra/dllmain.cpp index 114a327746..9685953088 100644 --- a/Chakra/dllmain.cpp +++ b/Chakra/dllmain.cpp @@ -1,6 +1,8 @@ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" +void preload(); + BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -10,6 +12,8 @@ BOOL APIENTRY DllMain( HMODULE hModule, { case DLL_PROCESS_ATTACH: { std::wcout << "LiteLoader Injected" << std::endl; + system("chcp 65001"); + preload(); if (!LoadLibrary(TEXT("LiteLoader.dll"))) { std::wcout << "[Error] Can't load LiteLoader " << GetLastError() << std::endl; exit(1); diff --git a/LiteLoader/LiteLoader.cpp b/LiteLoader/LiteLoader.cpp index 431285ad2f..fa3ae59123 100644 --- a/LiteLoader/LiteLoader.cpp +++ b/LiteLoader/LiteLoader.cpp @@ -66,7 +66,7 @@ static void entry(bool fixcwd) { THook(int, "main", int a, void* b) { std::ios::sync_with_stdio(false); - system("chcp 65001"); + //system("chcp 65001"); entry(a > 1); return original(a, b); } diff --git a/headers/liteloader.h b/headers/liteloader.h index f1796cdc36..13946a5f30 100644 --- a/headers/liteloader.h +++ b/headers/liteloader.h @@ -1,3 +1,3 @@ #pragma once #define LIAPI __declspec(dllexport) -const std::string getVersion = "0.1.1 Beta"; \ No newline at end of file +const std::string getVersion = "0.1.2"; \ No newline at end of file