diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-08 15:33:31 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-08 15:33:31 +0100 |
commit | 4c4d605d10109e02708984755405bbe0947ef5c4 (patch) | |
tree | 1d5ffe7909b24b6c79fd444b420741e85f6c2b57 /InjectorTest/main.cpp | |
parent | 8dfb8e866119f653802609b24165b0458149c4cc (diff) | |
download | NorthstarLauncher-4c4d605d10109e02708984755405bbe0947ef5c4.tar.gz NorthstarLauncher-4c4d605d10109e02708984755405bbe0947ef5c4.zip |
initial commit
Diffstat (limited to 'InjectorTest/main.cpp')
-rw-r--r-- | InjectorTest/main.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/InjectorTest/main.cpp b/InjectorTest/main.cpp new file mode 100644 index 00000000..351708c3 --- /dev/null +++ b/InjectorTest/main.cpp @@ -0,0 +1,68 @@ +#include <Windows.h> + +#define PROC_NAME L"Titanfall2-unpacked.exe" +#define DLL_NAME L"Northstar.dll" + +int main() { + STARTUPINFO startupInfo; + PROCESS_INFORMATION processInfo; + + memset(&startupInfo, 0, sizeof(startupInfo)); + memset(&processInfo, 0, sizeof(processInfo)); + + CreateProcessW(PROC_NAME, (LPWSTR)L"", NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &processInfo); + + HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll"); + LPTHREAD_START_ROUTINE pLoadLibraryW = + (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32, "LoadLibraryW"); + + SIZE_T dwLength = (wcslen(DLL_NAME) + 1) * 2; + LPVOID lpLibName = VirtualAllocEx(processInfo.hProcess, NULL, dwLength, MEM_COMMIT, PAGE_READWRITE); + + SIZE_T written = 0; + WriteProcessMemory(processInfo.hProcess, lpLibName, DLL_NAME, dwLength, &written); + + HANDLE hThread = CreateRemoteThread(processInfo.hProcess, NULL, NULL, pLoadLibraryW, lpLibName, NULL, NULL); + WaitForSingleObject(hThread, INFINITE); + CloseHandle(hThread); + + // TODO: need to call initialisenorthstar in the new process + // also rewrite injector to be clean lol + // (this does not currently work!!! ) + //LPTHREAD_START_ROUTINE pInitNorthstar = (LPTHREAD_START_ROUTINE)GetProcAddress((HMODULE)lpLibName, "InitialiseNorthstar"); + //HANDLE hInitThread = CreateRemoteThread(processInfo.hProcess, NULL, NULL, pInitNorthstar, NULL, NULL, NULL); + //WaitForSingleObject(hInitThread, INFINITE); + //CloseHandle(hInitThread); + + ResumeThread(processInfo.hThread); + + VirtualFreeEx(processInfo.hProcess, lpLibName, dwLength, MEM_RELEASE); + + CloseHandle(processInfo.hProcess); + CloseHandle(processInfo.hThread); + + return 0; +} + +/* +#define DEFAULT_PROCESS_NAME = L"Titanfall2.exe" + +int main(int argc, char** argv) +{ + STARTUPINFO startupInfo; + PROCESS_INFORMATION processInfo; + + memset(&startupInfo, 0, sizeof(startupInfo)); + memset(&processInfo, 0, sizeof(processInfo)); + + LPCWSTR processName; + if (argc > 0) + { + processName = *argv; + } + else + processName = DEFAULT_PROCESS_NAME; + + CreateProcessW() +} +*/
\ No newline at end of file |