News:

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

winioctl.h

Started by Ian_B, July 29, 2006, 05:12:44 PM

Previous topic - Next topic

Ian_B

Am I missing something? Is there really no INCLUDE currently available for winioctl.h?  :eek

ToutEnMasm

Hello,
Translate it
              ToutEnMasm

James Ladd

Most of the things in there are in the windows.inc. Check some of the definitions and search for them in the other includes.

Ian_B

Quote from: James Ladd on July 29, 2006, 10:40:18 PM
Most of the things in there are in the windows.inc. Check some of the definitions and search for them in the other includes.

By "most" you can't mean any of the structures, like DISK_GEOMETRY, or any of the IOCTL control codes for use with DeviceIoControl, which is however listed in the kernel32 lib/inc. So that doesn't leave much...  :eek

ToutEnMasm

Hello,

Join is a translated winioctl.h that my own translator made .It's not the holy bible.
But using it with care ,it can be very useful. Delet the IF,that are kept only to show differences between the original and the translate.
                            ToutEnMasm

                                 


[attachment deleted by admin]

hutch--

If you have an easy translation of the following C unum the structures are easy enough.


//
// Define the media types supported by the driver.
//

typedef enum _MEDIA_TYPE {
    Unknown,                // Format is unknown
    F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
    F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
    F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
    F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
    F3_720_512,             // 3.5",  720KB,  512 bytes/sector
    F5_360_512,             // 5.25", 360KB,  512 bytes/sector
    F5_320_512,             // 5.25", 320KB,  512 bytes/sector
    F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
    F5_180_512,             // 5.25", 180KB,  512 bytes/sector
    F5_160_512,             // 5.25", 160KB,  512 bytes/sector
    RemovableMedia,         // Removable media other than floppy
    FixedMedia,             // Fixed hard disk media
    F3_120M_512,            // 3.5", 120M Floppy
    F3_640_512,             // 3.5" ,  640KB,  512 bytes/sector
    F5_640_512,             // 5.25",  640KB,  512 bytes/sector
    F5_720_512,             // 5.25",  720KB,  512 bytes/sector
    F3_1Pt2_512,            // 3.5" ,  1.2Mb,  512 bytes/sector
    F3_1Pt23_1024,          // 3.5" ,  1.23Mb, 1024 bytes/sector
    F5_1Pt23_1024,          // 5.25",  1.23MB, 1024 bytes/sector
    F3_128Mb_512,           // 3.5" MO 128Mb   512 bytes/sector
    F3_230Mb_512,           // 3.5" MO 230Mb   512 bytes/sector
    F8_256_128,             // 8",     256KB,  128 bytes/sector
    F3_200Mb_512,           // 3.5",   200M Floppy (HiFD)
    F3_240M_512,            // 3.5",   240Mb Floppy (HiFD)
    F3_32M_512              // 3.5",   32Mb Floppy
} MEDIA_TYPE, *PMEDIA_TYPE;
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm


The translation is in the winioctl.sdk that i posted and the translation seem correct
I is translated in a structure and not as constants because C++ use them as structures.
It would be good if a macro can do the same thing in masm
                                ToutEnMasm



MEDIA_TYPE STRUCT
Unknown DWORD 000000000H ; Format is unknown
F5_1Pt2_512 DWORD 000000001H ; 5.25", 1.2MB,  512 bytes/sector
F3_1Pt44_512 DWORD 000000002H ; 3.5",  1.44MB, 512 bytes/sector
F3_2Pt88_512 DWORD 000000003H ; 3.5",  2.88MB, 512 bytes/sector
F3_20Pt8_512 DWORD 000000004H ; 3.5",  20.8MB, 512 bytes/sector
F3_720_512 DWORD 000000005H ; 3.5",  720KB,  512 bytes/sector
F5_360_512 DWORD 000000006H ; 5.25", 360KB,  512 bytes/sector
F5_320_512 DWORD 000000007H ; 5.25", 320KB,  512 bytes/sector
F5_320_1024 DWORD 000000008H ; 5.25", 320KB,  1024 bytes/sector
F5_180_512 DWORD 000000009H ; 5.25", 180KB,  512 bytes/sector
F5_160_512 DWORD 00000000AH ; 5.25", 160KB,  512 bytes/sector
RemovableMedia DWORD 00000000BH ; Removable media other than floppy
FixedMedia DWORD 00000000CH ; Fixed hard disk media
F3_120M_512 DWORD 00000000DH ; 3.5", 120M Floppy
F3_640_512 DWORD 00000000EH ; 3.5" ,  640KB,  512 bytes/sector
F5_640_512 DWORD 00000000FH ; 5.25",  640KB,  512 bytes/sector
F5_720_512 DWORD 000000010H ; 5.25",  720KB,  512 bytes/sector
F3_1Pt2_512 DWORD 000000011H ; 3.5" ,  1.2Mb,  512 bytes/sector
F3_1Pt23_1024 DWORD 000000012H ; 3.5" ,  1.23Mb, 1024 bytes/sector
F5_1Pt23_1024 DWORD 000000013H ; 5.25",  1.23MB, 1024 bytes/sector
F3_128Mb_512 DWORD 000000014H ; 3.5" MO 128Mb   512 bytes/sector
F3_230Mb_512 DWORD 000000015H ; 3.5" MO 230Mb   512 bytes/sector
F8_256_128 DWORD 000000016H ; 8",     256KB,  128 bytes/sector
F3_200Mb_512 DWORD 000000017H ; 3.5",   200M Floppy (HiFD)
F3_240M_512 DWORD 000000018H ; 3.5",   240Mb Floppy (HiFD)
F3_32M_512 DWORD 000000019H ; 3.5",   32Mb Floppy
MEDIA_TYPE ENDS

Ian_B

Quote from: ToutEnMasm on July 30, 2006, 08:55:04 AM
I is translated in a structure and not as constants because C++ use them as structures.

What is the point of translating that as a "structure"? This would not be an include designed for C++, but an include designed for MASM. The "enum" is just a series of constant values that you would use to check the result. Far more critically, I can't tell you how frustrating it was to search through so many people's documentation for that "structure" (including MSDN) and never once find a single reference to the SIZE of the MEDIA_TYPE entry in the DISK_GEOMETRY structure. Until I wrote my own code and speculatively set it as a DWORD, and confirmed the result by reading the output, there seemed no way of finding out.

I don't see any benefit of including complexity that isn't needed to do something very simple, which is just to provide a list of constant identifiers. But since I've tried this approach to disk access with DeviceIoControl and found it has no benefit for me, I just don't care what you do with it anyway. Sorry I mentioned it.  :'(

Ian_B

drizz

Nobody heard of KmdKit?  :dazzled:
http://www.freewebs.com/four-f/

http://website.masm32.com/kmdtute/index.html needs an update? KmdKit v1.8 is current.

awesome work by Four-F...
The truth cannot be learned ... it can only be recognized.

ToutEnMasm


this code seems complex to you ?
mov eax,MEDIA_TYPE.F5_1Pt2_512 ; mov eax,1

The benefit is for the one who create the translation code.Structures can be reused in other structures , in API .
If the translation modifie structure in constants , what did you do when you are to translate something who used this structure ?,you are very embarrassed.
                    ToutEnMasm




Ian_B

Shouldn't matter, as long as all the references within the MASM32 project are consistent. This information is unlikely to be used by anyone else, as they will use the original MS winioctrl.h header as-is. And the only references to this useless enum are within this header which is only used for the results of calls to DeviceIoControl. Same with the "extension" to this enum for STORAGE_MEDIA_TYPE.

It's a return value for Chrissake! It's only going to be used in code like this:

ASSUME EDI:PTR DISK_GEOMETRY
.IF [edi].MediaType == RemovableMedia    ; RemovableMedia = 11, constant value
;    do something if removable media disk
.ELSEIF [edi].MediaType == FixedMedia    ; FixedMedia = 12, constant value
;    do something if fixed disk
.ELSEIF [edi].MediaType != Unknown    ; Unknown = 0, constant value
;    some form of floppy - do subcheck if that's what we wanted
.ENDIF


Ian_B

Sorry, hutch, but my "grumpy-old-man" pressure-valve is at critical again. I think another break from this forum is imminent.  :'(

drizz

ToutEnMasm,
mov eax,MEDIA_TYPE.F5_1Pt2_512 will not work, this gives offset into the structure,
i.e. mov eax,4
mov eax,MEDIA_TYPE.F3_2Pt88_512 == mov eax,12

i sometimes use my macro for enums (also if i want to printout equates)

?Enum macro __EnumStart:=<0>,__EnumArgs:vararg
LOCAL i,arg
i = __EnumStart
for arg,<__EnumArgs>
ifnb <arg>
&arg equ i
endif
;       uncomment here for printout, to print decimal, remove 0 h and comment radix lines
; .radix 16
; %echo &arg equ 0@CatStr(%i)h
; .radix 10
i = i + 1
endm
endm


?Enum 0,Unknown,F5_1Pt2_512,F3_1Pt44_512,F3_2Pt88_512, etc.
The truth cannot be learned ... it can only be recognized.

ToutEnMasm



I see that you are abble to make the differences between enumeration of constants and structures.
Not so hard.
See the various parts of the sdk,and not only this file , and you will see that this type of structure are usable as part of other structures (modifying the size) and are used to pass arguments to api.
                                                  ToutEnMasm

                                           

hutch--

 :bg

Ian,

> Sorry, hutch, but my "grumpy-old-man" pressure-valve is at critical again. I think another break from this forum is imminent.

It sounds like a holiday in the south of France, a comfortable chair, a tall drink and a beach umbrella is in order.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm

 :bg

If you want to burn ,go to south of france.
                             
                               ToutEnMasm