Skip to content

Commit

Permalink
no cpp include
Browse files Browse the repository at this point in the history
hopefully Sylmir approved
  • Loading branch information
jsgnextortex committed Oct 23, 2024
1 parent e213b82 commit 2556811
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
29 changes: 28 additions & 1 deletion dsound/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include "dsound/Logger.h"
#include "updater/updater.h"
#include "updater/updater_resources.h"
#include <windows.h>
#include <psapi.h> // For MODULEINFO

#include <string>
#include "../launcher_core/utils.cpp"

typedef int (*ModInitFunc)(int, char **);

Expand Down Expand Up @@ -121,6 +122,32 @@ DWORD RedirectLua(HMODULE* outLua) {

static HMODULE luaHandle = NULL;


std::string GetExeVersion() {
HMODULE hModule = GetModuleHandle(NULL);
MODULEINFO modInfo;
if (!GetModuleInformation(GetCurrentProcess(), hModule, &modInfo, sizeof(MODULEINFO))) {
return "Fucked";
}
const char* baseAddress = (const char*)modInfo.lpBaseOfDll;
size_t moduleSize = modInfo.SizeOfImage;
const char* searchStr = "isaacv";

for (size_t i = 0; i < moduleSize - strlen(searchStr); ++i) {
const char* potentialMatch = baseAddress + i;
if (strncmp(potentialMatch, searchStr, strlen(searchStr)) == 0) {
const char* afterIsaacv = potentialMatch + strlen(searchStr);
const char* dashPos = strchr(afterIsaacv, '-');

if (dashPos) {
return std::string(afterIsaacv, dashPos);
}
}
}

return "Fucked";
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if(ul_reason_for_call == DLL_PROCESS_ATTACH)
Expand Down
27 changes: 0 additions & 27 deletions launcher_core/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "dsound/utils.h"
#include <cstdio>
#include <cstdarg>
#include <windows.h>
#include <psapi.h> // For MODULEINFO

#include <atomic>
#include <string>
Expand All @@ -19,31 +17,6 @@ void InitCLI() {
argv = CommandLineToArgvA(GetCommandLineA(), &argc);
}

std::string GetExeVersion() {
HMODULE hModule = GetModuleHandle(NULL);
MODULEINFO modInfo;
if (!GetModuleInformation(GetCurrentProcess(), hModule, &modInfo, sizeof(MODULEINFO))) {
return "Fucked";
}
const char* baseAddress = (const char*)modInfo.lpBaseOfDll;
size_t moduleSize = modInfo.SizeOfImage;
const char* searchStr = "isaacv";

for (size_t i = 0; i < moduleSize - strlen(searchStr); ++i) {
const char* potentialMatch = baseAddress + i;
if (strncmp(potentialMatch, searchStr, strlen(searchStr)) == 0) {
const char* afterIsaacv = potentialMatch + strlen(searchStr);
const char* dashPos = strchr(afterIsaacv, '-');

if (dashPos) {
return std::string(afterIsaacv, dashPos);
}
}
}

return "Fucked";
}

PCHAR* CommandLineToArgvA(PCHAR CmdLine, int* _argc)
{
PCHAR* argv;
Expand Down

0 comments on commit 2556811

Please sign in to comment.