mirror of
https://github.com/DanielLMcGuire/LCE-SDK.git
synced 2026-05-21 17:24:30 +00:00
67 lines
1.2 KiB
C++
67 lines
1.2 KiB
C++
// dllmain.cpp
|
|
|
|
#include <windows.h>
|
|
#include <fstream>
|
|
|
|
class Minecraft;
|
|
|
|
typedef Minecraft* (*GetGameInstanceFn)();
|
|
|
|
void Log(const char* message)
|
|
{
|
|
char path[MAX_PATH];
|
|
GetCurrentDirectoryA(MAX_PATH, path);
|
|
strcat_s(path, "\\Project1.asi.log");
|
|
|
|
std::ofstream file(path, std::ios::app);
|
|
if (!file)
|
|
return;
|
|
|
|
file << message << "\n";
|
|
}
|
|
|
|
DWORD WINAPI MainThread(LPVOID)
|
|
{
|
|
// Wait for the game to initialize
|
|
Sleep(5000);
|
|
Log("Alive");
|
|
|
|
HMODULE hGame = GetModuleHandle(nullptr);
|
|
if (!hGame)
|
|
return 0;
|
|
|
|
auto getGameInstance =
|
|
(GetGameInstanceFn)GetProcAddress(hGame, "GetGameInstance");
|
|
|
|
if (!getGameInstance)
|
|
return 0;
|
|
|
|
Minecraft* minecraft = nullptr;
|
|
|
|
while (!minecraft)
|
|
{
|
|
minecraft = getGameInstance();
|
|
Sleep(100);
|
|
}
|
|
|
|
// START BLOCK
|
|
|
|
// You can replace this with whatever you want
|
|
char buf[128];
|
|
sprintf_s(buf, "Game ptr: 0x%p", minecraft);
|
|
Log(buf);
|
|
// END BLOCK
|
|
|
|
return 0;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport) void InitializeASI()
|
|
{
|
|
CreateThread(nullptr, 0, MainThread, nullptr, 0, nullptr);
|
|
}
|
|
|
|
BOOL APIENTRY DllMain(HMODULE, DWORD, LPVOID)
|
|
{
|
|
return TRUE;
|
|
}
|