Well if I change the DLL_PROCESS_ATTACH case to this:

case DLL_PROCESS_ATTACH:
        MessageBoxA(null, "Injected!", "DLL", MB_OK);
        
        g_hInst = hInstance;
        dll_process_attach(hInstance, true);
        
        try
        {
                *cast(int*)0x12FE6C = 1337;
        }
        catch(Exception e)
        {
                MessageBoxA(null, "Exception!", "DLL", MB_OK);
        }
        
        MessageBoxA(null, "Finished!", "DLL", MB_OK);
break;


then I get the "Injected!" and "Finished!" MessageBox()s popping up, but not the "Exception!", so yes the code does get past the cast line (but still crashes). The same thing happens even if I remove the try/catch block and the cast line altogether.

I changed my post-mortem debugger from the default Dr. Watson to Visual Studio's just-in-time debugger, and after it displays "Finished!", I get an unhandled win32 exception in the injected process.

And yer, I would normally use WriteProcessMemory() for something this trivial, but I want to eventually do some more advanced stuff.

Reply via email to