LuaFunctionRegisterSpreadsheet/Launcher/Launcher.cpp

36 lines
1.3 KiB
C++
Raw Permalink Normal View History

#include <iostream>
#include <Windows.h>
#include <detours.h>
int main()
{
std::string wow_directory = R"(C:\Users\alphaomega\Documents\World-of-Warcraft-3.3.5a.12340-enUS-WIN\)";
char launcherDirectory[MAX_PATH] = { 0 };
GetModuleFileNameA(NULL, launcherDirectory, MAX_PATH);
size_t lastBackslash = ((std::string)launcherDirectory).rfind('\\');
std::string lpDllName = ((std::string)launcherDirectory).substr(0, lastBackslash + 1) + "Hook.dll";
STARTUPINFOA lpStartupInfo;
ZeroMemory(&lpStartupInfo, sizeof(lpStartupInfo));
PROCESS_INFORMATION lpProcessInformation;
ZeroMemory(&lpProcessInformation, sizeof(lpProcessInformation));
lpStartupInfo.cb = sizeof(lpStartupInfo);
DetourCreateProcessWithDllA(
(wow_directory + "Wow.exe").c_str(), // lpApplicationName
NULL, // lpCommandLine,
NULL, // lpProcessAttributes,
NULL, // lpThreadAttributes,
TRUE, // bInheritHandles,
CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED, // dwCreationFlags,
NULL, // lpEnvironment,
wow_directory.c_str(), // lpCurrentDirectory,
&lpStartupInfo, // lpStartupInfo
&lpProcessInformation, // lpProcessInformation
lpDllName.c_str(), // lpDllName
NULL // pfCreateProcessA
);
ResumeThread(lpProcessInformation.hThread);
return 0;
}