• Stars
    star
    161
  • Rank 233,395 (Top 5 %)
  • Language
    Assembly
  • License
    GNU General Publi...
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

small stub that allows to run "bare" 64-bit PE binaries in DOS
  1. About Dos64stb and Dos64stb2

  Dos64stb and Dos64stb2 are small stubs that are supposed to be added to a
  64-bit PE binary by the link step. Stubs are programs that are executed
  when the binary is launched in DOS. 
  
  Both stubs will do:

   - check if the cpu is 64-bit
   - check if the PE image is "acceptable"
   - check if enough XMS memory is available
   - setup IDT and page tables for 64-bit PAE paging
   - read & move the image into extended memory
   - install a small "OS" (int 21h/31h) so one may call
     real-mode DOS functions that don't need pointer translation.
   - reprogram master PIC, so IRQs 00h-07h are mapped to Int 78h-7fh
   - switch to long-mode
   - call the entry point of the loaded 64-bit image

  Dos64stb will additionally handle base relocations, it requires the binary
  to contain such relocations. Also, Dos64stb does identity-map the first 
  64 GB of physical memory, using 2MB pages, not caring at all whether the
  machine contains 64 GB of physical memory or not.

  OTOH, Dos64stb2 doesn't require the image to contain base relocations,
  because it should be able to load the image at its prefered loading address.
  Dos64stb2 maps just the memory that the image needs to run, that is:
  
   - image, stack & heap
   - conventional memory region, address 0-0xfffffh
   - IDT, mapped at 0x100000.
  
  Also, Dos64stb2 uses "normal" 4 kB pages for mapping. There are no 
  restrictions for the image's base address, it may be any valid 64-bit
  address.

  The 64-bit binary runs in ring 0, 64-bit long mode.   


  2. Requirements
  
  to run an image with Dos64stb/Dos64stb2 attached one needs:

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


  3. How to use the Stubs?

  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
   - no dll references ("imports") are possible
   - Dos64stb only: image must contain base relocations - they must NOT be 
     "stripped".
   - Dos64stb only: 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 ).

  The stubs install 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
 
  a). Dos64stb
 
  The first 64 GB of memory are "identity mapped". This may be adjusted
  in Dos64stb.asm. When launched, Dos64stb allocates a memory block in
  extended memory and initializes it like this (from lower to higher 
  addresses):
  
  - Paging Tables (default: 1+1+64 pages)
  - IDT (1 page)
  - 64-bit PE image
  - stack
  - heap (optionally)

  b) Dos64stb2

  Dos64stb2 doesn't map the paging tables, and the IDT is always mapped at
  0x100000h. The image itself is mapped at its prefered load address. Note
  that the valid address space is split into two parts:

   1. 0000000000000000-00007fffffffffff
   2. ffff800000000000-ffffffffffffffff

   or, in other words, the upper 17 bits of the address must be
   identical. The image, including stack and heap, must fit in
   one of those 2 parts. So, for example, an image with base 
   address 7fffffff0000 and size of image+stack+heap > 64 kB cannot
   be loaded.


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

More Repositories

1

HX

Home of the HX DOS Extender and its included DPMI-host HDPMI.
Assembly
192
star
2

Jemm

Jemm386 and JemmEx are socalled EMMs ( Expanded Memory Managers ) or, more exactly, V86 monitors.
Assembly
125
star
3

JWasm

Masm compatible assembler
C
105
star
4

VSBHDA

Sound Blaster emulation for DOS
C
59
star
5

DOS-debug

Debug and DebugX (short: Debug/X) are extended versions of MS DEBUG
Assembly
57
star
6

HimemX

DOS extended memory (XMS) server
Assembly
51
star
7

HimemSX

eXtended Memory Manager (XMM) that can manage memory beyond the 4 GB barrier, up to 1 terabyte.
Assembly
39
star
8

DOS32pae

DOS32pae is a "micro" (or perhaps "nano") DOS extender using PAE paging
Assembly
31
star
9

HDAutils

Utilities for bare metal access to the High Definition Audio controller in DOS
Assembly
21
star
10

jwlink

jwlink is a fork of the open watcom linker wlink. May create 16-, 32- and 64-bit binaries.
C
21
star
11

ComView

Win32 tool that allows to play with COM objects ( create objects of classes, call methods, set/get properties ). Can also create assembly include files from typelibs.
Assembly
17
star
12

HX-OpenWatcom-Debugger

The Open Watcom Debugger, with a few bug fixes and trap files for HX. May debug real-mode and protected-mode programs.
C
16
star
13

ProcWin

displays processes, modules and memory layout
C++
16
star
14

WinInc

Windows 32/64-bit Include files and Import Libraries
C++
15
star
15

DOS71BSG

MS-DOS 7.1 FAT32 Bootsector for GPT-partitioned disks
Assembly
15
star
16

WDe

DOS Disk Editor, handles all types of FAT file systems ( including exFAT )
Assembly
14
star
17

ExplASM

Windows Explorer application written in assembly
Assembly
14
star
18

Deb386

Ring 0 debugger for HDPMI, Jemm and Win31/9X VMM
Assembly
13
star
19

XDMA

simple Ultra-DMA DOS driver for "vintage" PCs
Assembly
12
star
20

AHCI1

displays AHCI information in DOS
Assembly
9
star
21

PlayCD

play audio CDs in DOS
9
star
22

SetMtrr

displays status of MTRRs, allows 1) to set fixed registers and 2) to set VESA LFB to type write-combine
Assembly
8
star
23

XMSTools

Tools to play with XMS functions, useful to test XMMs.
Assembly
8
star
24

debxxf

A set of DPMI debuggers for DOS and 16-bit Windows
Assembly
8
star
25

DispMSR

A small DOS utility that displays MSRs of Intel & AMD cpus.
Assembly
8
star
26

AHCICDU

AHCI CD/DVD driver for DOS ( real-mode only )
Assembly
8
star
27

h2incX

tool to convert C header files to assembly include files (Masm style)
Assembly
7
star
28

Dos32cm

Variant of Dos64stub, running binary in compatibility mode
Assembly
7
star
29

PCItools

A few small tools to display PCI info in DOS
Assembly
7
star
30

SB16PCM

Simple DOS PCM Player for SoundBlaster 16
Assembly
7
star
31

DumpOMF

displays contents of OMF object modules
Assembly
6
star
32

FTE

Text Editor
C++
5
star
33

APICtools

Some tools to test and display APIC status in DOS
Assembly
5
star
34

IDEcheck

Harddisk check utility
Assembly
4
star
35

JDeb386

PL0 debugger for Jemm
Assembly
3
star
36

VWin32

displays VWIN32 status in Win9x OSes
Assembly
2
star
37

Testcases

2
star