Skip to main content
gamedev.net
🔒 Locked

running machine code from within a program

Started by skillfreak Jan 6, 2003 at 11:26 AM 2 replies 1k views
Original Post
skillfreak
skillfreak
Here is what i am looking to do. I want to write a program that can bind to an exe. When the exe executes I am looking for a way to run the bound exe without copying to h/d. Basicly a packer.. but if it is an exe i want the exe to run from ram and not simply copied to the drive and then run. Does this make sense? Thanks for anyones help, Andy
Joltman
Joltman
If I havent missunderstood you, the thing you want to do is to write some lowlevel code that will hook the interrupt that goes of when you run an exe-file or simular. Its years since I done anything assemblish with interrupts, but you should start by browsing through an interruptlist, google it.

//Jolt
The nice thing about C++ is that only your friends can handle your private parts.
skillfreak
skillfreak
well.. here
a packer would work very simply liiike
0. execute packer with option of attach file or something
1. packer opens target file
2. packer opens itself
3. append target file to packet on h/d only
( if this is not possible.. then simply copy the packer to a new file + target file )
4. execute newly modified or created file ( depending on last statement ) without attach option

this is where my question comes in
a) you could simply copy the total_file_size - orig_file_size to a seperate file and execute it straight to the os.
b) i'm thinking you can start a thread or something.. and execute code from other parts of the program.. I've seen an compiler that runs commands with a loop. was very easy.
i just wanna execute machine code!!! >=| grrrr!~

there is a simple solution. i'm just not seeing it. hmpf*
Thanks,
Andy

[edited by - skillfreak on January 6, 2003 2:08:22 PM]
NickB
NickB
Some commercial packers literally uncompress the file from their own image, execute it & then delete it when it finishes running - not very good if you are trying to prevent someone hacking it. [EDIT:] to be clear, onto the HDD.
To do something a little more complex than that, you need to create an extra segment in the PE file that contains the unpacking code, compress the rest of the file, alter the PE headers so that the OS loads the file appropriatelly then alter the entry point to be into the unpacking code, unpack the code (& probably recreate the imports table, load the dlls etc.) then you just execute a simple JMP to the original entry point.

[edited by - NickB on January 6, 2003 5:24:30 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.