From 4936c701b943399dab4a1da8070d24a3bfa29703 Mon Sep 17 00:00:00 2001
From: Urocu <103362793+Urocu@users.noreply.github.com>
Date: Fri, 22 Sep 2023 14:31:31 +0200
Subject: [PATCH] Added files
---
MemSubLoader.cbp | 46 ++++++++++
MemSubLoader.depend | 11 +++
MemSubLoader.layout | 10 ++
main.cpp | 217 ++++++++++++++++++++++++++++++++++++++++++++
obj/Release/main.o | Bin 0 -> 13863 bytes
5 files changed, 284 insertions(+)
create mode 100644 MemSubLoader.cbp
create mode 100644 MemSubLoader.depend
create mode 100644 MemSubLoader.layout
create mode 100644 main.cpp
create mode 100644 obj/Release/main.o
diff --git a/MemSubLoader.cbp b/MemSubLoader.cbp
new file mode 100644
index 0000000..01cff0c
--- /dev/null
+++ b/MemSubLoader.cbp
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MemSubLoader.depend b/MemSubLoader.depend
new file mode 100644
index 0000000..759bbe8
--- /dev/null
+++ b/MemSubLoader.depend
@@ -0,0 +1,11 @@
+# depslib dependency file v1.0
+1695385670 source:c:\users\tadeusz bindas\documents\github\memsubloader\memsubloader\main.cpp
+
+
+
+
+
+
+
+
+
diff --git a/MemSubLoader.layout b/MemSubLoader.layout
new file mode 100644
index 0000000..2cbdcdb
--- /dev/null
+++ b/MemSubLoader.layout
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..a0b173e
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,217 @@
+#ifndef UNICODE
+#define UNICODE
+#endif
+#define _WIN32_WINNT 0x0501
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define GAME 1
+#define TRANSLATION 2
+#define START 3
+
+HWND game_text = NULL;
+HWND file_text = NULL;
+HWND subtitles = NULL;
+HWND gameHWND = NULL;
+wchar_t gamePath[MAX_PATH] = {};
+wchar_t filePath[MAX_PATH] = {};
+PROCESS_INFORMATION pi;
+STARTUPINFO si;
+HWND gWindow = NULL;
+
+bool findAddress(uintptr_t &address, int offset)
+{
+ SIZE_T bytesRead;
+ int newAddress;
+ if (ReadProcessMemory(pi.hProcess, (LPCVOID)address, &newAddress, sizeof(newAddress), &bytesRead) )
+ {
+ address = newAddress;
+ address += offset;
+ return true;
+ }
+ return false;
+
+}
+
+void game_start()
+{
+ SIZE_T bytesRead;
+ int audID;
+ uintptr_t baseaddress;
+ uintptr_t addressToRead;
+
+ std::vector Text;
+
+ std::wstring ws( filePath );
+ std::string SfilePath( ws.begin(), ws.end() );
+ std::wifstream subfile;
+ subfile.open(SfilePath);
+ int num;
+ int offset[6];
+ if(subfile.is_open() && !subfile.eof())
+ {
+ subfile>>baseaddress;
+ subfile>>num;
+ for(int i = 0; i>offset[i];
+ while(getline(subfile, ws))
+ {
+ Text.push_back(ws);
+ }
+ }
+ else
+ SetWindowText(subtitles,L"File failed to open");
+ subfile.close();
+ int lastID = 0;
+ SetWindowText(subtitles,Text[0].c_str());
+ while (WaitForSingleObject( pi.hProcess, 0 ) == WAIT_TIMEOUT)
+ {
+ if (ReadProcessMemory(pi.hProcess, (LPCVOID)addressToRead, &audID, sizeof(audID), &bytesRead) && lastID!=audID && audID 0)
+ {
+ SetWindowText(subtitles,Text[audID].c_str());
+ lastID=audID;
+ }
+ MSG msg = { };
+ while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ addressToRead = baseaddress;
+ for( int i = 0; i < num; i++)
+ findAddress(addressToRead,offset[i]);
+ DWORD Width = GetSystemMetrics(SM_CXSCREEN);
+ DWORD Height = GetSystemMetrics(SM_CYSCREEN);
+ SetWindowPos(subtitles,HWND_TOPMOST, 0,Height-100,Width,100,NULL);
+ }
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+ DestroyWindow(subtitles);
+}
+
+bool OpenFileExplorer(HWND hwnd, wchar_t* filePath, int filePathSize, int button)
+{
+ OPENFILENAME ofn = { sizeof(OPENFILENAME) };
+ ofn.hwndOwner = hwnd;
+ if(button == GAME)
+ ofn.lpstrFilter = L"Executable Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0";
+ else
+ ofn.lpstrFilter = L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
+ ofn.lpstrFile = filePath;
+ ofn.nMaxFile = filePathSize;
+ ofn.Flags = OFN_FILEMUSTEXIST;
+
+ if (GetOpenFileName(&ofn))
+ return true;
+ else
+ return false;
+}
+
+LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg)
+ {
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case GAME:
+ if (OpenFileExplorer(hwnd, gamePath, MAX_PATH, LOWORD(wParam)))
+ SetWindowText(game_text, PathFindFileName(gamePath));
+ break;
+
+ case TRANSLATION:
+ if (OpenFileExplorer(hwnd, filePath, MAX_PATH, LOWORD(wParam)))
+ SetWindowText(file_text, PathFindFileName(filePath));
+ break;
+
+ case START:
+ {
+ if(gamePath[0] != NULL && filePath[0] != NULL)
+ {
+
+ ZeroMemory( &si, sizeof(si) );
+ si.cb = sizeof(si);
+ ZeroMemory( &pi, sizeof(pi) );
+ CreateProcess(gamePath, NULL,NULL,NULL,FALSE,0,NULL, NULL, &si,&pi);
+ WaitForInputIdle(pi.hProcess, INFINITE);
+ subtitles = CreateWindowEx(WS_EX_LAYERED|WS_EX_TRANSPARENT,L"STATIC", L"", WS_VISIBLE|WS_POPUP , 50, 100, 640, 100, hwnd, NULL, NULL, NULL);
+ SetLayeredWindowAttributes(subtitles, RGB(255, 255, 255), 128, LWA_ALPHA);
+ SetWindowText(subtitles, L"Loading...");
+ game_start();
+ }
+ else
+ MessageBox(hwnd, L"You must select both game and file", L"Warning", MB_ICONINFORMATION);
+ }
+ break;
+ }
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+ case WM_CREATE:
+ {
+ HFONT hFont = CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Arial");
+ game_text = CreateWindow(L"STATIC", L"No Game", WS_CHILD | WS_VISIBLE, 50, 100, 150, 20, hwnd, NULL, NULL, NULL);
+ file_text = CreateWindow(L"STATIC", L"No File", WS_CHILD | WS_VISIBLE, 440, 100, 150, 20, hwnd, NULL, NULL, NULL);
+ SendMessage(game_text, WM_SETFONT, (WPARAM)hFont, TRUE);
+ SendMessage(file_text, WM_SETFONT, (WPARAM)hFont, TRUE);
+ }
+ break;
+
+ case WM_PAINT:
+ {
+ PAINTSTRUCT ps;
+ HDC hdc = BeginPaint(hwnd, &ps);
+ FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
+ EndPaint(hwnd, &ps);
+ }
+ break;
+ }
+ return DefWindowProc(hwnd, uMsg, wParam, lParam);
+}
+
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
+ const wchar_t CLASS_NAME[] = L"Sample Window Class";
+
+ HWND Sub_hwnd;
+
+ WNDCLASS wc = { };
+ wc.lpfnWndProc = WindowProc;
+ wc.hInstance = hInstance;
+ wc.lpszClassName = CLASS_NAME;
+ RegisterClass(&wc);
+
+ RECT desktop;
+ const HWND hDesktop = GetDesktopWindow();
+ GetWindowRect(hDesktop, &desktop);
+
+ HWND hwnd = CreateWindowEx(0,CLASS_NAME,L"MemSubLoader",WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME,desktop.right/2 - 320,desktop.bottom/2 - 120,640,240,NULL,NULL,hInstance,NULL);
+
+ if (hwnd == NULL)
+ {
+ return 0;
+ }
+
+ CreateWindow(L"BUTTON", L"Choose Game", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 50, 50, 150, 50, hwnd, (HMENU)GAME, hInstance, NULL);
+ CreateWindow(L"BUTTON", L"Choose File", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 440, 50, 150, 50, hwnd, (HMENU)TRANSLATION, hInstance, NULL);
+ CreateWindow(L"BUTTON", L"Start", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 245, 150, 150, 50, hwnd, (HMENU)START, hInstance, NULL);
+
+ ShowWindow(hwnd, nCmdShow);
+
+ MSG msg = { };
+ while (GetMessage(&msg, NULL, 0, 0) > 0)
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ return 0;
+}
diff --git a/obj/Release/main.o b/obj/Release/main.o
new file mode 100644
index 0000000000000000000000000000000000000000..95b4bce31f0983728e9e6231dc363d395d8c9c44
GIT binary patch
literal 13863
zcmdT~4{#J!ntwwkI4ZjnHM*#=ZgfWv6k{d^NLcj(q>%`bmbEvKBzT~P{q=ner1xYiYLXKiim))sZOdu5L79V*Mlzq#M{
zUiX_xI=JeUS9Jr^{d?d0-uLf)?|ZL1v($4Lqt7ijG1kqI*Hfu$y*kI@vhGU8c6%5L
zUMJeG;1*!b>ndXrJyOIs8LVej`O3C*y0|azEp7?Cg{{k1rp62Gn8KL1oUwBO!7~*%
z$g97jMzo!4KS1Id#%A3pC?q~m*1YbHQ0PvFhwdjK?-TH~+I(dWU-g|;#e4xY-oCb&
z!u96wsII9krV`%>_|6yWrMN`(WU9zxvS%7%SAiJQ$Ad4$<&Nq()tq2o;3_M#W9-n$
z--8DrVVEe^t8@)#M{2Ex;0$w3uzsi^IE~~R4Z$+dX5sELOK|n>iV@ixe3yoVPG?8T
zb9vowHUt|=!1r@9!YIietu;=rK4R^^g}AIke@(ZQq5MIFiDgH6t=8c5?4jTev^>VI
zK6u&e3vK~Eh%YnBgU~+xK|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