My apologies if this isn't the right forum, but it looks like this board has a lot of sharp coders and was hoping you might be able to help.

I just want to read a frigging floppy boot sector from inside a Win32 VC++6 application.
I'd like to have an "unsigned char ucBuff[512]" buffer that I can then use as with...

_asm {
MOV AX,0201h
MOV CX,0001h
INT 13h
But get an Access Violation on the MOV ES,DX ...

I've tried DPMI (also new to me)
_asm {
mov ax, 0100h
mov bx, 0020h
int 31h

mov , dx
mov , ax

push es

mov ax, 0201h
mov es, dx
xor bx, bx
mov cx, 0001h
mov dx, 0000h
int 13h

// Need Some Way To Read It Back!

pop es

mov ax, 0101h
mov dx,
int 31h
And I get an Access Violation on the first INT 13h ...

What am I doing wrong? How can I just get my <superfluous and repetitive expletives removed> boot sector? :mad:

Any and all help is greatly appreciated!

Posted on 2002-10-26 21:20:04 by Solonari
Win32 is not the same 16 bit DOS. Either use a 16 bit dos linker or use windows memory model and api calls instead of segments and ints.
Posted on 2002-10-26 21:26:33 by _js_
>What am I doing wrong?
Simple, you cannot modify segments, call ints (an the like) under protected mode...
Why do you need to do this ?
Posted on 2002-10-26 21:27:21 by Axial
Its not VC++6 that is causing the problems, or your code (Im assuming that you are compiling this code to run under windows)

The problem lies in the fact that you are attempting to call real mode interupts and change segment selectors in a protected mode environment. Windows cannot allow this so crashes your app.

Intead try reading your floppy boot sector the "windows way" by using CreateFile to open the disk (I think this only works under the NT family of windows - see your documentation). There is also another method that uses vwin32.vxd (From memory but 9x specific) to indirectly call or emulate certain Int 13h functions.
Posted on 2002-10-26 21:34:07 by huh
I was under the impression that the DPMI INT 31h calls might allow me to "simulate" a real-mode environment and at least get a few pieces of info out of the standard BIOS interrupts.

JS - Need Win32, so DOS linker is out of the question, but I can't find any docs that explain how to read an absolute sector in VC6 (and I might tick someone off if I asked that question here ;-))

Axial - I've never liked the word "can't" so please excuse my stubbornness ;-) ... As for answering your question, I want to pull the boot sector from a floppy so I can manipulate it and put it back down. A friend of mine wanted something like this, so I'm trying to figure out the best way without getting Macrosoft angry with me for distributing their boot sector(s)...

Huh - I run Win2K, so your trick might be useful ... if you've got spare time for a little expansion on that idea, would you mind giving a couple extra helpful tidbits?

And you guys just go to prove that I was right. Sharp and fast around here. :-)

Posted on 2002-10-26 21:56:21 by Solonari
I only know the very basics of C++ programing and Ive never used VC6 before, but from the MSDN library (Or platform SDK):

Posted on 2002-10-27 02:03:56 by huh
HD access in Win32 is OS specific. For Win9x, you have to get a handle with

vw32str db "\\.\vwin32",0

invoke CreateFile addr vw32str,0,0,0,0,FILE_FLAG_DELETE_ON_CLOSE,0

With this handle read sectors with

invoke DeviceIoControl,handle,VWIN32_DIOC_DOS_INT13,\
addr dioc,size DIOCRegs,addr dioc,size DIOCRegs,cbptr,0

dioc is structure:

reg_EBX DD ?
reg_EDX DD ?
reg_ECX DD ?
reg_EAX DD ?
reg_EDI DD ?
reg_ESI DD ?
reg_Flags DD ?

check MS docs for DeviceIOControl for further details or do a search in this forum, as this matter has handled by several threads.

Remeber, thats for Win9x only!
Posted on 2002-10-27 03:35:27 by japheth