ok.. only 4 views on my last post, guess i scared some people off with the subject.. anyway, for those that didn't know, i'm trying to get the capacity of a floppy disk in bytes, as well as the number of bytes in a sector. i found a macro from bit7 that should have made the call to DeviceIoControl work for it, but i don't know what's going on.. here's my previous post..

ok.. so it's still not working. i used the CTL_CODE macro posted by Bit7, along with the constants i pulled from the c++ header file, make the call, and for some reason my structure comes back empty. here are the structures i used, as well as the relevant code. DrvGeo is a DISK_GEOMETRY structure.. any idea why it stays empty? my MEDIA_TYPE is likely wrong, but it's only there to make the DISK_GEOMETRY the right size anyway, i dunno.. any suggestions would be great.

MEDIA_TYPE STRUCT
Unknown dd ?
F5_1Pt2_512 dd ?
F3_1Pt44_512 dd ?
F3_2Pt88_512 dd ?
F3_20Pt8_512 dd ?
F3_720_512 dd ?
F5_360_512 dd ?
F5_320_512 dd ?
F5_320_1024 dd ?
F5_180_512 dd ?
F5_160_512 dd ?
RemoveableMedia dd ?
FixedMedia dd ?
MEDIA_TYPE ENDS

DISK_GEOMETRY STRUCT
Cylinders LARGE_INTEGER <>
MediaType MEDIA_TYPE <>
TracksPerCylinder dd ?
SectorsPerTrack dd ?
BytesPerSector dd ?
DISK_GEOMETRY ENDS



invoke CreateFile,addr sDrv,GENERIC_WRITE+GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL
mov hDisk,eax
.if hDisk == INVALID_HANDLE_VALUE
jmp usage
.endif

CTL_CODE IOCTL_DISK_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS
mov IOCTL_DISK_GET_DRIVE_GEOMETRY,eax
invoke DeviceIoControl,hDisk,IOCTL_DISK_GET_DRIVE_GEOMETRY,NULL,0,addr DrvGeo,sizeof DrvGeo,addr dRet,NULL
mov bRetCode,eax
.if eax == 0
jmp usage
.endif

;need low word in eax, why not returning value??
mov eax,dword ptr DrvGeo.Cylinders
mul DrvGeo.TracksPerCylinder
mul DrvGeo.SectorsPerTrack
mul DrvGeo.BytesPerSector
mov dDrvSize,eax
Posted on 2002-02-07 08:36:14 by mc`
mc`,

your MEDIA_TYPE definition is wrong, I suppose. Thats not a struct but an enumeration. So size of MEDIA_TYPE is 4.
Posted on 2002-02-07 10:22:43 by japheth
wow, i'm an idiot.. got it working, just changed MEDIA_TYPE to a dword.. i should really quit coding at 1 in the morning, i get too sloppy :P
Posted on 2002-02-07 17:12:29 by mc`