ok, so i'm still working on the disk drive imaging program. anyway, i'm kinda stuck right now, for compatibility's sake, i'm trying to get the geometry of the floppy disk so i can be sure the image file is for that specific type of floppy. basically what i really need is a way to get the total bytes the floppy can hold, and how many bytes are in each sector for that specific floppy. anyway, any help that could be given here is much appreciated, thanks in advance.
btw, a bit of c++ code i found:

bReturnCode = DeviceIoControl(hDisketteFile,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
&ourDiskGeometry,
sizeof(ourDiskGeometry),
&dwBytesReturned,
(LPOVERLAPPED) NULL
);

problem is with IOCTL_DISK_GET_DRIVE_GEOMETRY, the definition looks like this..

#define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)

i found all the other stuff, but i have no clue whatsoever what CTL_CODE does.. so i'm kinda stuck there. anyone that can help translate this, or has an entirely different method i can use, please help!
Posted on 2002-02-05 21:47:27 by mc`
CTL_CODE looks very much like a macro ;). The easiest way for you
to get its value is probably to compile a litte test app that simple
wsprintfs IOCTL_DISK_GET_DRIVE_GEOMETRY to a buffer and MessageBox'es
it to screen.

Or write your stuff in a highlevel language ;).
Posted on 2002-02-05 22:21:11 by f0dder
yeah.. i figured someone would suggest that.. i'll probably try the wsprintf thing tomorrow after i figure what i did with my visual studio cd.. so thanks for the input f0dder, but are there any other suggestions?
Posted on 2002-02-05 22:32:17 by mc`
figure out how the macro works, implement it as a masm macro.
Convert all the necessary #defines to asm EQUs and/or macros.
Posted on 2002-02-05 22:38:42 by f0dder
f0dder: that was my original goal, the problem was that i couldn't even find the macro anywhere. anyone know what it does, or for that matter where it can be found?
Posted on 2002-02-05 22:41:12 by mc`
grep all the header files of psdk or ddk... it must be there somewhere :P
Posted on 2002-02-05 22:43:03 by f0dder
tried that, all it found were a few headers that use it, nothing that defines it.. i dunno, i'm kinda confused now.. i think i'm gonna need to try to find another method of getting the info, problem is i ran out of ideas hours ago :P
Posted on 2002-02-05 23:08:19 by mc`
Posted on 2002-02-06 01:27:28 by LaptoniC
Doh!!!!! :grin:
Posted on 2002-02-06 01:35:44 by NaN
wow, i didn't see those, guess i was searching for the wrong thing. thanks a lot LaptoniC!
Posted on 2002-02-06 08:24:29 by mc`
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-06 15:35:39 by mc`