Thread: Copy to RAM - HELP

  1. #1
    Registered User
    Join Date
    Jun 2017
    Posts
    4

    Copy to RAM - HELP

    Hello,
    I'm pretty new at C programming and i made a goal to make my learning more complex.... So

    I would like to copy an .exe file directly into RAM memory from flash, execute that file, and after computer restart, file should be gone... (deleted)

    Can anyone help where to start?
    Thanks
    Back2tec

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    This is handled automatically by almost all operating systems. To do it manually by yourself, you don't only need to know the EXE format and how to load it but also somehow alter the addresses used by the program to cope with it not being loaded inside its own, isolated memory space. This can be really, really hard! Are you sure you want to do this?
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Jun 2017
    Posts
    4
    hello GReaper, thanks for comment...
    I hope i explained myself good for the first time, but I will try it again...
    SO....
    I want to copy and execute my .exe file only to RAM memory from USB, not on a hard drive.
    Basically, exe file will be copied, run in RAM memory, do the job and then gone, after restart...
    Can you help?
    Oh yes, and all that i would like to write in C language....

    It can also be in other way....
    write a script or some other .exe file which would be on USB also, after executing, the this file, it will copy our first file directly in RAM and execute it... In that case we will have two exe files, but it is good for me

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Is the operating system already running, and if so, which one?

    Or are you aiming to plug your USB into a machine, switch it on, and run your program?

    I'm curious as to what this "delete file after execute" is all about.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jun 2017
    Posts
    4
    ok this is how i imagine this will work:
    Operating system is running (in my case Windows 7)
    1. I plug in USB with exe file(files)
    2. I execute the exe file (on USB)
    3. file copies itself to RAM memory and runs

    Second scenario:
    we have two exe files:
    File(1) is file which will be copied to RAM
    File(2) is file which is copying File(1) into RAM after executing it (File(2)) on USB
    The later procedure is the same.

    And about delete.... well as long as I know everything is deleted from RAM after reboot.. that's all
    Last edited by back2tec; 06-13-2017 at 01:15 PM.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Oh, you mean gone from RAM, not deleted from the file system on the USB.

    Well that's simple - just read up on auto-run.

    But most people with any sense turn that off because it's such a security hole.

    As for the reboot thing, from a functional point of view, the rebooting OS cares nothing about what RAM contains.
    Forensically, DRAM isn't instantaneously forgetful when power is removed. If you rebooted forensic s/w for example, it may be possible to find scraps of information from the previous live system.

    Don't forget that Windows could have stored copies of various parts of your program in the swap file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Jun 2017
    Posts
    4
    well.... auto run is not going to work for me, just because of what you have said.
    Maybe the second case which I've described is better,
    so any ideas on how to?

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > well.... auto run is not going to work for me, just because of what you have said.
    Surely you're not suggesting you want to run a .exe file from USB with absolutely no user involvement or permission.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    I'm not saying that this is true, but this smells like a possible example of some sort of Malware.

    Would the OP please explain further what this .exe file is, what it will do when executed, and why he wants to do it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using Copy-on-write For Fast Copy?
    By SMurf in forum Tech Board
    Replies: 7
    Last Post: 01-25-2017, 06:26 AM
  2. Replies: 2
    Last Post: 11-20-2013, 01:34 PM
  3. Replies: 2
    Last Post: 10-13-2013, 07:36 PM
  4. fd copy
    By mary in forum C Programming
    Replies: 12
    Last Post: 07-18-2002, 06:22 PM

Tags for this Thread