Recently I have been reading up articles about DLL injection and I understand them fairly well.
However, what I don’t understand is why APIs such as CreateRemoteThread, WriteProcessMemory(in being able to write to the memory of another process) and VirtualAllocEx(in being able to allocat memory in the context of another process) were implemented in the first place.
What was the original need for such APIs? Just curious.
WriteProcessMemorywas made for ring3 debuggers that need to securely write process memory, most commonly forINT 3breakpoints or user provided memory edits.along the same line,
CreateRemoteThreadcan also be used for debugging purposes, however, MSDN can enlighten us onCreateRemoteThreada bit more:IIRC,
CreateRemoteThreadis also used by debuggers to hook application native expection handlers, commonly set bySetExceptionHandler, which requires call from the target process as the handler is stored in the PEB.VirtualAllocExis just how windows virtual memory system operates, it needs a context to allocate in, be it in the current process, a child process or a remote process.VirtualAllocin fact is nothing more than a pass through wrapper of the Ex variant, it just passes a special constant that indicates the handle of the caller process is to be used.