GithubHelp home page GithubHelp logo

hlide / dos64-stub Goto Github PK

View Code? Open in Web Editor NEW

This project forked from baron-von-riedesel/dos64-stub

0.0 1.0 0.0 150 KB

small stub that allows to run "bare" 64-bit PE binaries in DOS

License: GNU General Public License v2.0

Assembly 95.73% Makefile 1.94% C 2.33%

dos64-stub's Introduction

  1. What is dos64stb good for?

  dos64stb is a small stub that is supposed to be added to a 64-bit 
  PE binary ( thru the link step ). It is the program that is executed
  when the binary is launched in DOS.
  dos64stb will do this:

   - check if the cpu is 64-bit
   - check if the PE image is "acceptable"
   - check if enough XMS memory is available to load the image
   - load the image into extended memory
   - setup GDT and switch to protected-mode
   - handle relocation info ( the image MUST contain base relocations )
   - setup IDT and page tables for 64-bit PAE paging
   - install a small "OS" (int 21h/31h) that allows the image to call
     real-mode DOS functions that don't need pointer translation.
   - reprogram master PIC, so IRQs 00h-07h are mapped to Int 78h-7fh
   - enable paging; call the entry point of the loaded 64-bit image


  2. Requirements
  
  to run an image with the dos64stb-stub one needs:

   - a 64-bit CPU
   - an installed DOS
   - an installed XMS host
   - enough extended memory to load the image


  3. Hot to use dos64stub?

  The stub is added to a 64-bit binary thru the link step. See file
  Makefile for how to do this with MS link or jwlink. The image must
  meet the following requirements:

   - Subsystem has to be "native"; avoids the image being loaded in Win64
   - image must contain base relocations
   - no dll references ("imports") are possible
   - base of image must be < 4 GB

  There are 2 samples supplied, Mon64.asm and TestC.c. Mon64 allows to
  display a few 64-bit resources. It also shows how the Int21 emulation
  installed by dos64stb is supposed to be used. TestC, the second sample,
  just shows how C source may be used with the stub. TestC.mak is
  supplied, which creates the binary using MSVC ( and JWasm, needed to
  assemble the micro-printf implementation in printf.asm ).

  dos64stb installs a tiny subset of the DPMI API. The functions that are
  supported are:
   - int 21h, ah=4Ch: terminate program
   - int 31h, ax=203h: set exception vector BL to CX:RDX
   - int 31h, ax=300h: simulate real-mode interrupt BL, RDI=real-mode call
     structure.
  

  4. Memory Layout
  
  The 64-bit binary runs in ring 0, 64-bit long mode. The first
  64 GB of memory are "identity mapped" by the stub. This may be adjusted
  in dosstb64.asm. When launched, dos64stb allocates a memory block in
  extended memory and initializes it like this (from lower to higher 
  addresses):
  
  - Page Tables (default: 1+1+64 pages)
  - IDT (1 page)
  - 64-bit PE image
  - stack
  - heap (optionally)

  5. License
  
  the source is distributed under the GNU GPL 2 license. See file
  COPYING for details. It was written by Andreas Grech.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.