2
Answers

How could I use C++ code with C#?

Sergio Fonseca

Sergio Fonseca

16y
3.1k
1

It's an bypass for PostMessageA (For a game) but it's in C++ and I belive C# doesn't have assembler to let me convert it so how could I get this to work with C#? I don't know enought C++ to create DLLs :-(

Code:

DWORD dwPostMessage = (DWORD)GetProcAddress( LoadLibrary( _T("user32.dll") ), "PostMessageA") + 5;
_declspec(dllexport) BOOL WINAPI __PostMessageA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
   _asm
   {
      mov edi,edi
      push ebp
      mov ebp,esp
      jmp dword ptr ds:[dwPostMessage]
   }
}

BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved )
{
    switch ( dwReason )
    {
          case DLL_PROCESS_ATTACH:
          case DLL_THREAD_ATTACH:
          case DLL_THREAD_DETACH:
          case DLL_PROCESS_DETACH:
               break;
    }
}

Answers (2)