Thread: how would i get my (DOS) program to run all out of upper memory?

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    3

    how would i get my (DOS) program to run all out of upper memory?

    relatively new to C, but have used BASIC for many many years. i'm programming a program that takes over int 13h BIOS code and simulates a physical hard drive by accessing a raw image over TCP. what i'm not sure how to do is make my code run entirely out of the highest point in memory possible (highest under 640 KB that is) so that i can modify the BIOS data area to make the OS think the highest available block of memory is under my program's memory space. this way i can keep my routines in RAM while loading a boot sector over the network and jumping to it for a full boot over TCP.

    otherwise, the newly booting instance of DOS/windows/linux would overwrite my code and that's certainly no good. any ideas?

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Most (all?) modern operating systems will quickly load "protected mode" drivers to avoid the use of "int13"; therefore, such operating systems will avoid your code and its network images.

    For example, you can do this with some older versions of Windows (Windows 98), but I don't think the Linux kernel has ever used "int13" (the loader may well read the kernel into memory using "int13").



    However, you can use the technique to load an entire Linux kernel and customized initial image into memory (loaded entirely by the... loader); once your computer is "running under Linux" you can "chain" your way into virtually any operating system image stored on a network drive, floppy disc, or almost anything else. (Using some combination of "VirtualBox", "Grub", "SysLinux", and other such tools.)

    Soma

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    3
    Quote Originally Posted by phantomotap View Post
    Most (all?) modern operating systems will quickly load "protected mode" drivers to avoid the use of "int13"; therefore, such operating systems will avoid your code and its network images.

    For example, you can do this with some older versions of Windows (Windows 98), but I don't think the Linux kernel has ever used "int13" (the loader may well read the kernel into memory using "int13").



    However, you can use the technique to load an entire Linux kernel and customized initial image into memory (loaded entirely by the... loader); once your computer is "running under Linux" you can "chain" your way into virtually any operating system image stored on a network drive, floppy disc, or almost anything else. (Using some combination of "VirtualBox", "Grub", "SysLinux", and other such tools.)

    Soma
    you can actually make linux use the bios routines if the option is enabled in the kernel. it's in there as a fallback. i'm mostly just writing to this get some more practice at C.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    There are plenty of things to practice on which are a hell of a lot easier to debug than boot loaders "Hey, where did I put my OS install disks?"
    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
    Dec 2007
    Posts
    2,675

  6. #6
    Registered User
    Join Date
    Aug 2010
    Posts
    3
    Quote Originally Posted by Salem View Post
    There are plenty of things to practice on which are a hell of a lot easier to debug than boot loaders "Hey, where did I put my OS install disks?"
    i've mostly got all the code written already, just needed some info on this. this isn't technically a boot loader, either. it's more of a.... boot loader loader. õ_ô

  7. #7
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Quote Originally Posted by miker00lz View Post
    you can actually make linux use the bios routines if the option is enabled in the kernel. it's in there as a fallback. i'm mostly just writing to this get some more practice at C.
    Yeah, that's kind of impossible... Once in protected mode, int 13, along with all ints from 0 to 31h, are reserved for cpu exceptions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. memory not released after running program
    By lehe in forum Linux Programming
    Replies: 21
    Last Post: 01-01-2011, 03:32 AM
  2. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  3. Memory Fragmentation with Dynamic FIFO Queue
    By fguy817817 in forum Linux Programming
    Replies: 17
    Last Post: 10-31-2009, 04:17 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM