That’s a big topic and it’s hard to explain in one comment please have a look on the following resource as a start and I highly recommend doing more research into this if you’re interested in it https://securityxploded.com/memory-execution-of-executable.php