0

I have written a simple Lossless compression algorithm in order to learn a little about compressions and how it is work and in order to check my algorithm I open a exe file read it to variable do the mathematical operation on it run the reverse mathematical operation and run it. (I saved the file and try to run it with subprocess.popen

This lead me to think if I have the uncorrupted EXE file in python variable can I run it directly from memory without save it to disk?

for example like this:

import example_run_exe_file_from_variable

a_file = open("example.exe", "rb")
full_file = a_file.read()
a_file.close()
.
.
.
.
example_run_exe_file_from_variable.run(full_file)

Thanks!

mal
  • 5
  • 2
  • Does this answer your question? [Load an EXE file and run it from memory](https://stackoverflow.com/questions/3553875/load-an-exe-file-and-run-it-from-memory) – Peter Badida Sep 10 '21 at 15:49
  • Basically ^, but using Win32 API from Python via Ctypes, Cython or alternatives. – Peter Badida Sep 10 '21 at 15:49
  • 1
    @PeterBadida that is a `c#` question, not a good duplicate target for this python question IMO – Pranav Hosangadi Sep 10 '21 at 15:55
  • @PranavHosangadi as Python doesn't target using binaries this way with its standard library, it's a generic question with an application for C# like this is for Python and both end up in using Win32 API just in a different wrapping mechanism - which is the reasoning for the duplicate vote. Therefore OP might just end up with rewriting [this](https://stackoverflow.com/a/9233591/5994041) or similar approach with Ctypes/Cython. Same like other linked questions to the duplicate candidate. – Peter Badida Sep 10 '21 at 16:01

0 Answers0