Execute an executable program (.exe) from memory in Java

不羁岁月 提交于 2019-12-10 16:45:45

问题


I want to execute a program in memory on Windows. I do not want to write the file to disk. I just want to pass in a byte array (which is the program I want to execute) as a parameter.

I am not skilled enough to write the native code to do this. Again, this should be Windows native.

The program I want to execute in memory is not a Java program. It is an executable (.exe)! The executable is meant to be read and run IN MEMORY, not through Runtime.getRuntime().exec("example.exe");


回答1:


I can't comment yet, otherwise I would. You should be able to find some useful information here, where people are trying to solve the same problem using C++. Pray tell, are you trying to write a program that is cross platform, or Windows only? Your use of the ".exe" indicates windows only.

CreateProcess from memory buffer

You should theoretically be able to make this work by using Windows API calls, as long as you aren't trying to make this cross platform.



来源:https://stackoverflow.com/questions/11087612/execute-an-executable-program-exe-from-memory-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!