News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Real Mode

Started by OneX, December 14, 2011, 11:39:56 AM

Previous topic - Next topic

bomz

Find theoretic tutorial how back to real mode. it have sense only if you making your own OS

bomz

#16
Under DOS back to real mode use HIMEM.SYS and Dos4GW, Windows 3.

http://sasm.narod.ru/docs/pm/pm_in/chap_10.htm code from here. as author says it's really working example. I am just descriptor understanding - the begining

OneX

#17
Removed by admin.

1 warning, any further nonsense of this type and we will assist you in finding another forum that will tolerate bad manners.

bomz



General descriptor table and Local(?) descriptor table - just read about it. Studied to ask questions.

You can't back from windows to real mode. You may only use Real Virtual Mode. (virtual-8086 mode) or V-Mode

of course you do - but you can't find microsoft documentation how save windows, and you must do this from system kernel not from driver. patch ntoskrnl.exe

http://technet.microsoft.com/ru-ru/sysinternals/bb469930
http://hex.pp.ua/nt-native-applications-shell-eng.php
Fun club NT kernel applications
http://website.masm32.com/kmdtute/index.html

bomz

This just working example for MASM32 without any comments now. To protected without back to Real. But it work.

Prepare GDT - General Desriptor Table with ZERO Descriptor, Descriptor for Code, Data, Stack and Video buffer. Set GDTR register to this GDT. Set processor to protected mode and print String. Than infinite loop
Sad I can't translate all site, but author very good and main - very simple explain all about Protected mode, and you move to make your own half-OS

bomz


bomz

Add some comments in English. and find some English URL's. can't say that this is the best.
Now I want re-read all from the begining, optimizing code and go to Protected IRQ's. (Than memory, multiple tasks...)

http://www.coralcdn.org/05au-cs240c/lab/i386/s05_01.htm
http://www.rcollins.org/ddj/Aug98/Aug98.html
http://www.cs.cmu.edu/~410/doc/segments/segments.html
http://linuxgazette.net/issue82/raghu.html   - Writing your own Toy OS By Raghu and Chitkala
http://en.wikibooks.org/wiki/X86_Assembly/Global_Descriptor_Table

jj2007

Hi bomz,
Not working here on XP SP2. Which assembler, which linker are you using? Which commandline options?

bomz

MASM32 10, ML.EXE 8.0, batch file for compiling and DOS floppy image in first ZIP file. If you want try it on real machine may boot it with GRUB4DOS

Quote@ECHO OFF
COLOR 9F
C:\masm32\bin\ml.exe /AT /omf NONAME.asm
C:\masm32\bin\LINK16.EXE /TINY NONAME.obj,NONAME.com,nul,,,
del NONAME.obj
pause
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=4580
http://support.microsoft.com/kb/958162/en
Grub4Dos
http://code.google.com/p/grub4dos-chenall/downloads/list
menu.lst
Quotemap --mem /DOS.IMA (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

Magnum

Not working on XP Sp3 Home Edition.

Does it only work in a virtual box ?
Have a great day,
                         Andy

bomz

Wait. I try it now on real machine. reboot need. 5-10 min

bomz

#26
All OK. Put to system disk with XP files from this archive: grldr, DOS.IMA, menu.lst. Add to BOOT.INI string
QuoteC:\grldr="Grub4Dos"
Reboot your computer and PRESS F5 (or F8) - In Windows menu choose Grub4Dos
type in DOS command prompt PMODE

http://zalil.ru/32327924

http://reboot.pro/ forum about Grub4Dos. This is universal Boot Manager which including allow boot ISO (CD), IMG (HD) and IMA (floppy) images so that BIOS see them like real devices
Allow BOOT devices, MBR, PBR, files from devices like NTLDR IO.SYS, PXE, universal linux bootloader....... changes devices by places( hd0-hd1 hd1-hd0), hide devices and partition...

Quote.386

.model flat, stdcall
option casemap :none

include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\user32.inc
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\user32.lib
includelib \MASM32\LIB\kernel32.lib

.data
mestitle   db "Bomz",0
form      db "Adress GDTR: %u", 13, 10, "Limit GDTR: %u", 13, 10, 13, 10
      db "Adress IDTR: %u", 13, 10, "Limit IDTR: %u", 13, 10, 13, 10
      db "Adress LDT: %u",0

.data?
buffer      db 512 dup(?)
value      fword ?
value1      fword ?
value2      word ?,?

.code
start:
   SGDT value
   SIDT value1
   SLDT value2
   mov eax, dword ptr[value+2]
   movzx ebx, word ptr[value]
   mov ecx, dword ptr[value1+2]
   movzx edx, word ptr[value1]
   mov esi, dword ptr[value2]
   invoke wsprintf,ADDR buffer,ADDR form,eax, ebx,ecx,edx,esi
   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_ICONASTERISK
   invoke ExitProcess,0
end start

mineiro

When you create a virtual floppy using Vmware, it create a file fully filled with zeros, with the same size of one floppy.
The code below is one that I have found inside this board, is a simply boot. Just give the resulting file as a floppy image to vmware and boot it.

I remember that Sr agner have write some code that switch betwen real and protected mode (pcmdos).

bomz

#28
I make floppy image with WinImage (or UltaISO). And MS DOS 8.0 boot disk with Windows XP using floppy virtual drive

http://sourceforge.net/projects/vfd/

Back to REAL mode from Windows UNREAL - it's need not only patch NTLDR, to make BACKPOINT, it's need not only find path how call this back from kernel - but it need FULLY reprogramming IRQ controller. Any driver which do this would be very very slowly. and I think this is the reason why windows 95 and higher don't back to real mode, and Windows 2000 nit use DOS at all

bomz

#29
How under DOS get RAM Memory full size (include busy for different devices)