using CreateRemoteThread and WriteProcessMemory
I injected a dll that brings up a message box!
but the DLL is loaded
only thing no message box!
The process is notepad!
Im using Dev c++ Mingw
Did you check for any call errors especially in the VirtualAllocEx, WriteProcessMemory, CreateRemoteThread. Normally, these are the "risk" areas where these bugs arise. Check the error values and compare them and see why the error is caused.
It really boils down to what you want to achieve, for example performing a DLL injection is more suitable for "exporting" large-chunks of code due to the compact design. However if you are more or less looking to export small amount of code like hooks or such, code injection is the way to go.
In my experience, of doing online jobs here and there - I am pretty sure that DLL injection is more used in commercial conditions keeping in mind *majority* of developers find code injection difficult OR too cumbersome.
When it comes to Security related programming, code injection is preferred due to dynamic support you EXE has over the remote thread, not to mention code injection is more difficult to hinder as there is no system call stub to block code injection, whereas DLL injection can be blocked with a filter hook on LdrLoadDll.
To be honest DLL injection is way simpler and BIG WOULD love to use it however DLL injections are just too easy to block.