problem reading the right sector

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
aliceinchains
Posts: 14
Joined: Wed Aug 13, 2014 11:04 am

problem reading the right sector

Post by aliceinchains »

Ok so I searched and I didn't see any specific offset or misunderstood how HxD logical disk sector 1 isn't CHS int 0x13 ah=2 cylinder 0 head 0 sector 2 reading from a usb drive defined as floppy by the bios but I cant read my usb drive as a physical disk using HxD. If someone can tell me the best way to figure out what is sector 2 in HxD for windows 8.1 64bit. I tried several different hex editors and even Ubuntu dd and I couldn't get it to read the right sector so is there any program that uses the bios to write sectors for any operating system you know of because I might switch to that one :D TY
Octocontrabass
Member
Member
Posts: 5590
Joined: Mon Mar 25, 2013 7:01 pm

Re: problem reading the right sector

Post by Octocontrabass »

In HxD, you must open the physical disk, not the logical disk.

If you're already doing that, then your code must be wrong. Try stepping through it in an emulator with a debugger, such as Bochs, and see if you can figure out why it doesn't work.
aliceinchains
Posts: 14
Joined: Wed Aug 13, 2014 11:04 am

Re: problem reading the right sector

Post by aliceinchains »

Ok so I switched to a drive HxD considers a physical drive and I can now read the drive after booting back into windows 8.1 without formatting or doing anything to the drive just opening with hxd and I cant find the string of text so maybe my code is wrong...

Nasm

Code: Select all

use16
org 0x7c00

cli

mov ax, 0x0100
mov ss, ax
mov sp, 0x1000

sti

mov [0x7000], dl

mov [0x2000], byte 0x77
mov [0x2001], byte 0x69
mov [0x2002], byte 0x6b
mov [0x2003], byte 0x69
mov [0x2004], byte 0x2e
mov [0x2005], byte 0x6f
mov [0x2006], byte 0x73
mov [0x2007], byte 0x64
mov [0x2008], byte 0x65
mov [0x2009], byte 0x76
mov [0x200a], byte 0x2e
mov [0x200b], byte 0x6f
mov [0x200c], byte 0x72
mov [0x200d], byte 0x67

mov ah, 0x03
mov al, 0x01 ;sectors to write count
mov ch, 0x00 ;track
mov cl, 0x02 ;sector
mov dh, 0x00 ;head
mov dl, [0x7000] ;drive number
mov bx, 0x2000 ;es:bx
int 0x13

jmp $

times 510 - ($ - $$) db 0
dw 0xaa55
this is the raw hex dump of the boot sector

FA B8 00 01 8E D0 BC 00 10 FB 88 16 00 70 C6 06
00 20 77 C6 06 01 20 69 C6 06 02 20 6B C6 06 03
20 69 C6 06 04 20 2E C6 06 05 20 6F C6 06 06 20
73 C6 06 07 20 64 C6 06 08 20 65 C6 06 09 20 76
C6 06 0A 20 2E C6 06 0B 20 6F C6 06 0C 20 72 C6
06 0D 20 67 B4 03 B0 01 B5 00 B1 02 B6 00 8A 16
00 70 BB 00 20 CD 13 EB FE 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA
Octocontrabass
Member
Member
Posts: 5590
Joined: Mon Mar 25, 2013 7:01 pm

Re: problem reading the right sector

Post by Octocontrabass »

You haven't initialized DS or ES. That's not going to work very well!
aliceinchains
Posts: 14
Joined: Wed Aug 13, 2014 11:04 am

Re: problem reading the right sector

Post by aliceinchains »

Sweet so I ran it and I opened up HxD and it was right there in sector 1

added this right after stack setup

Code: Select all

xor ax, ax
mov ds, ax
mov es, ax
Post Reply