Results 1 to 4 of 4

Thread: run exe in memory

  1. #1

    Thread Starter
    Lively Member Tygur's Avatar
    Join Date
    Jul 2002
    Posts
    108

    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.

  2. #2
    Addicted Member ChuckB's Avatar
    Join Date
    Jul 2002
    Location
    South Carolina, USA
    Posts
    157
    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

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    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
  •  



Click Here to Expand Forum to Full Width