python - Run binary exe in python script without writing it to a disk
问题描述
Now even tough this question kinda already exists (Run in-memory binary executable from bytes object)
I am going to create this question as that question has been dead for years
How do i run exe bytes directly thru python
So basically this:
Bytes = bytesFile.read()
"Execute Bytes as exe in memory"
In theory, this should be possible
Maybe by later on hard coding it in with a hex editor somehow (would have to code in binary and holy fuck I would prefer not)
Or by running it into Pyinstaller or some alternative
Or maybe creating a special sort of thread that doesn't run python but runs applications (in bytes form)
Just post your crazy ideas in the comments
But please please please don't be like: "why?, why would you want that?, Your best option is just to create it in a temporary directory"
Because TRUST ME I KNOW I CAN CREATE A TEMPORARY DIRECTORY. I am creating this question because there is no alternative for me
If you found a matrix way out then sure post about it
But please respect my original question and don't find some way out of this, just try to help me
A few things to note:
Exe as in windows 10 64 bit app executable
I am not creating a virus! I'm making a PERSONAL merging application. But I won't make the end result public, and I won't use it to make anything malicious, just some fun game engine projects
I am using windows 10 as stated before
And I am using python 3.10
Edit:
I saw a comment from @Mihai that told me about ramDisk
The only problem is: that would take too much memory!
As I would have to resave the bytes (that are already in the main program) into an empty executable and run that, but then (if I take an example of the bytes being 1 gigabyte), this would happen:
1 gigabyte on disk (the program and the bytes as a variable in that program)
1 gigabyte on memory (to save the bytes as an executable on a ramdisk)
1 more gigabyte on memory (when the executable (of 1 gigabyte) is ren it will take 1 gigabyte of memory space)
Any fix for this?
解决方案
推荐阅读
- eclipse - 修改现有的 ecore 文件?
- go - How time.sleep changes result of this program that uses channels
- javascript - does to disable colour contrast from axe.min.js
- c - 结构值在传递回 main 时不成立
- firebird - NAS 存储 Firebird 数据库
- excel - 如何在 VBA excel 中检查和删除空格
- sql - SQL:从另一个表更新一个表
- python-3.x - 从另一个脚本 Python3 调用脚本
- excel - 如何根据特定的单元格值过滤数据透视表
- oracle - Check record exist before update