LiteLoaderBDS-1.16.40/LLPreLoader/src/dllmain.cpp
2023-03-03 10:18:21 -08:00

26 lines
822 B
C++

// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "../include/pch.h"
#include "../include/Logger.h"
void fixUpLibDir();
void loadDlls();
#pragma comment(linker, "/export:GetServerSymbol=LLPreLoader.dlsym_real")
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
system("chcp 65001>nul");
// For #683, Change CWD to current module path
WCHAR cpath[MAX_PATH];
GetModuleFileName(hModule, cpath, MAX_PATH);
std::wstring path(cpath);
auto cwd = path.substr(0, path.find_last_of('\\'));
_wchdir(cwd.c_str());
loadconfig();
fixUpLibDir();
loadDlls();
}
if (ul_reason_for_call == DLL_PROCESS_DETACH) {
}
return TRUE;
}