0

How to run an executable file (.exe), which will be the program code, from memory without saving to disk?

  1. I have an .exe file stored as bytes. It was obtained using open('1.exe', 'rb').read().

  2. I put the byte literal in the Python code of a script: byteCode = b'\x00\x00\x00\...'.

  3. Now I need to run this executable. But from memory, without saving to disk.

john-hen
  • 4,410
  • 2
  • 23
  • 40
  • 4
    Welcome to StackOverFlow! Have a look on [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/reprex) and what is a [good question](https://stackoverflow.com/help/how-to-ask). You will even have rewards at visiting those pages. You need to be specific and ask a clear question. Do you want to run `.exe` file with python? – shaik moeed Jul 06 '19 at 17:37
  • It seems Op has the binary contents of an executable and wishes to run it without saving to disk first. – xrisk Jul 06 '19 at 18:28
  • 1
    Based on [this,](https://stackoverflow.com/questions/3553875/load-an-exe-file-and-run-it-from-memory) it dosen't appear to be very easy. Writing to a temporary directory and running it from there seems easiest. – Alex Jul 06 '19 at 18:33
  • 1
    Is it a Win32 exe? What OS are you using/targeting? Why do you have to execute it from memory not disc? Why not just run `1.exe`? – wjandrea Jul 06 '19 at 18:34
  • @wjandrea, yes it is Win32 exe. I am use Windows. – Павел Шеметов Jul 06 '19 at 18:37

0 Answers0