need some help with function detouring

Keinshen1

Member
Joined
Nov 3, 2019
Messages
5
Reaction score
1
Location
Uganda
Hi,
I new in this so sorry if I act silly...

I've tried to recall "addMessageToChatWindow" from s0beit(or d3d9.dll module)
[ SCREENSHOTS IN THE ATTACHMENTS ]

I wrote this on my blank CPP project:
Code:
#include <Windows.h>
#include <iostream>

void Main()
{
    DWORD dwS0b = (DWORD)GetModuleHandleA("d3d9.dll");

    while (true) {
        if (GetAsyncKeyState(VK_INSERT))
            ((void(__cdecl*)(const char* a1))(dwS0b + 0x83550))("Test 123");
    }
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) {
    static HANDLE hThread;

    switch (dwReason)
    {
    case DLL_PROCESS_DETACH:
        if (hThread)
            TerminateThread(hThread, 0);
        break;

    case DLL_PROCESS_ATTACH:
        DisableThreadLibraryCalls(hModule);
        hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Main, 0, 0, 0);
        break;
    }
    return TRUE;
}
And seems like it's crashing...
Can someone tell me why or give me an example of how it should be ?
 

Attachments

  • 1.png
    1.png
    18.6 KB · Views: 25
  • 2.png
    2.png
    15.9 KB · Views: 25
  • 3.png
    3.png
    28 KB · Views: 20

Keinshen1

Member
Joined
Nov 3, 2019
Messages
5
Reaction score
1
Location
Uganda

0x_

Wtf I'm not new....
Administrator
Joined
Feb 18, 2013
Messages
1,118
Reaction score
166
Where do you get the THIS pointer? Your class? Or exactly the same as in your linked CChat.cpp?
Please post a crashlog.
 
Top