Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
369 views
in Technique[技术] by (71.8m points)

.net - process.start() embedded exe without extracting to file first c#

I have an executable embedded into my app resources. ATM I use assembly reflection to extract the executable to its own file and then start the executive using process,START(). Is it possible to run the embedded executable straight from a stream instead of writing it to file first? Could someone please show me the most efficient way to do this please.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here's what I gather from your question, and your comments:

  1. You want to know if it is possible to execute an executable embedded into your program, without extracting it to disk first
  2. Your program is a .NET program
  3. The executable you want to execute is not a .NET program

The answer to that is: yes

However, the answer to that is also it is very, very, hard

What you have to do is, and note that I do not know all the details about this since I don't do this, but anyway:

  1. Load the executable code into memory
  2. Remap all addresses in the binary image so that they're correct in relation to the base address you loaded the executable at
  3. Possibly load external references, ie. other DLL's that executable need
  4. Remap the addresses of those references
  5. Possibly load references needed by the just loaded referenced DLL's
  6. Remape those dll's
  7. Repeat 3 through 6 until done
  8. Call the code

I'm assuming your question is "can I do 1 and 8", and the answer to that is no.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...