From PE to Payload: A Technical Guide to Converting EXE to Shellcode
The most effective way to handle this conversion is through specialized tools that wrap the original executable with a custom loader. Donut (Highly Recommended)
Use a reflective loader (common for DLLs) — convert EXE to DLL or wrap logic into DLL, then use reflective loader shellcode to load it in-memory.
Use a tool (Donut / msfvenom) to produce shellcode that executes a PE in-memory (Donut supports EXE/NET/PE).