5

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");

Leigh
  • 28,765
  • 10
  • 55
  • 103
Thomas Nappo
  • 241
  • 4
  • 13
  • 2
    Practically impossible, I'd say. SOme motivation? – leonbloy Jun 18 '12 at 17:07
  • Why is Runtime.exec() unsuitable? – user949300 Jun 18 '12 at 17:22
  • The file I am trying to run will flag a false-positive, for sure, with antivirus software. – Thomas Nappo Jun 18 '12 at 17:27
  • 4
    That sounds really safe... there's a reason antivirus software flags executable files. They don't do it "for fun". – qJake Jun 18 '12 at 17:41
  • 5
    As a novice, you want to do something which expert developers who decades of experience in security try very hard to ensure you can't do? I would suggest you try off your anti-virus software or try something else. You have a better chance of become the President of the USA. – Peter Lawrey Jun 18 '12 at 18:29

1 Answers1

2

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.

Community
  • 1
  • 1
Wug
  • 12,956
  • 4
  • 34
  • 54