Mylifeismyhome / tInjector

Windows Injector examples in c/pp
MIT License
4 stars 2 forks source link

Process Crash after successfull injection #1

Closed Narumiii closed 1 year ago

Narumiii commented 1 year ago

Hello, first of all thank you for your contribution with this project im here to report an issue when you map.

The dll with Manual Map ThreadHijacking inject successfully and no issues if you just call a message box or something like that, hoewer if you create a thread or hook a function on the injected process this one will freeze and crash, to make things clear if you don't do anything more than calling a simple messagebox or AllocConole everything will be fine but you can't do anything more, no createthread and no hooks (no matter what kind of hooks if detours or not)

Here ill leave an example code im doing to test it.

// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <stdio.h>

void thstuff()//if this get called by createthread will crash the process
{
    AllocConsole();
    FILE* pFile = nullptr;
    freopen_s(&pFile, "CONOUT$", "w", stdout);

    printf("testest\r\n");

    while (true)
    {
        printf("loop\r\n");
        Sleep(100);
    }
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)thstuff, 0, 0, 0);//if we create a thread will crash once called otherwise no crash.
        break;
    }
    return TRUE;
}
Narumiii commented 1 year ago

Nevermind was my issue, the injector removes the mapped module from memory itself after returning execution status.

Mylifeismyhome commented 1 year ago

actually my bad, it was not supposed to unmap after injection, I pushed an updated, now it does not unmap on successfully injection.

Narumiii commented 1 year ago

actually my bad, it was not supposed to unmap after injection, I pushed an updated, now it does not unmap on successfully injection.

Thank you for updating. By the way i saw you added SetWindowHook LoadLibrary injection would be nice if you add an example with SetWindowHooks and ManualMap too!

Mylifeismyhome commented 1 year ago

no big deal, I added more comments in SetWindowHookEx and a comment in the top that will explain to you what you need to implement in your module (dll) to make it work

just check it out :)

https://github.com/Mylifeismyhome/tInjector/blob/main/tInjector/SetWindowsHookEx.cpp

all this is just a simple example of how it works, do not use it on any be/eac protected game, they will immediately clap u for it :) I created this to study it myself but it does help a lot, of how injection under the windows api can be done.

Narumiii commented 1 year ago

no big deal, I added more comments in SetWindowHookEx and a comment in the top that will explain to you what you need to implement in your module (dll) to make it work

just check it out :)

https://github.com/Mylifeismyhome/tInjector/blob/main/tInjector/SetWindowsHookEx.cpp

all this is just a simple example of how it works, do not use it on any be/eac protected game, they will immediately clap u for it :) I created this to study it myself but it does help a lot, of how injection under the windows api can be done.

Hi, i think you misundertanded what i was trying to say xD. I was trying to say that would be nice if you add a SetWindowHook injection with manualmap instead of just loading the dll file into the game like loadlibrary.

Here's an example : https://github.com/M-r-J-o-h-n/SWH-Injector

Mylifeismyhome commented 1 year ago

So you want to call SetWindowHookEx and it should execute the shellcode that was mapped into the target process to execute a manual map, instead of using CreateRemoteThread or to hijack an existing one?

or are u more aiming for a working rwx meme injector? all I know is that it works on BE Protected games still, but EAC got a way to detect it.

add me on discord for further talk: MYLIFEISMYHOME#0728