|
-
Sep 13th, 2002, 06:14 PM
#1
Thread Starter
Lively Member
run exe in memory
Is there any way I could get the contents of a regular windows exe file and put it into a byte array, then run it? It doesn't have to run in its own process. I just sorta wanna run the code in it...
Getting the contents into the array is easy. It's running it that's giving me trouble.
Before the why-would-you-do-that questions come up, I'd like to mention that the final code will actually be more complicated than that, and that is only part of the story.
-
Sep 15th, 2002, 11:05 PM
#2
Addicted Member
Hi
Don't know C++ answer. I have used DOS debug to write some assembler in which you punch a program into a memory segment and run it using all sorts of interrupts.
I then wrote a mouse function in QBASIC in which I had to load assembly code (in bytes) into a variable and then had calls which executed this code.
So, you might search for some QBASIC or Debug stuff to get some answers...or even ask on this Assembly Language forum.
Regards,
ChuckB
-
Sep 16th, 2002, 09:12 AM
#3
The tricky part about running it is that all addresses in the exe assume that the exe is loaded at the address 0x00040000. If this is not the case the loader runs over it and replaces all addresses with correct ones (so if the exe references 0x000400A0 but is loaded at 0x00050000 the loader will make this address 0x000500A0).
Since you app is probably loaded at 0x00040000 there is no chance that the other exe ca be loaded at 0x00040000 too. So you have to emulate the loader and replace addresses.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 16th, 2002, 11:34 AM
#4
Retired VBF Adm1nistrator
Search on planetsourcecode, under vb for code on using ASM from inside VB.
Its an image fading example.
Anyway, he's loading executable data into memory and causing the computer to execute it
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|