News:

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

GET_LENGTH_INFORMATION structure

Started by azdps, May 12, 2011, 07:54:50 AM

Previous topic - Next topic

azdps

I'm having a problem with the GET_LENGTH_INFORMATION structure. I get the following 2 errors when assembling:

error A2138: invalid data initializer
error A2036: too many initial values for structure


I found a link to the microsoft website which describes the error's I'm getting
http://support.microsoft.com/kb/94912

Any recommendations would be great. Here is the code I have been working with:

.586
.model flat, stdcall
option casemap: none

     include         /masm32/include/windows.inc
     include         /masm32/include/kernel32.inc
     include         /masm32/include/user32.inc
     include         /masm32/include/comctl32.inc
     include         /masm32/include/masm32.inc
     include         /masm32/include/debug.inc
     include         /masm32/include/Setupapi.inc

   
     includelib      /masm32/lib/kernel32.lib
     includelib      /masm32/lib/user32.lib
     includelib      /masm32/lib/comctl32.lib
     includelib      /masm32/lib/masm32.lib
     includelib      /masm32/lib/debug.lib
     includelib      /masm32/lib/Setupapi.lib

     
     GET_LENGTH_INFORMATION struct
      iLength            LARGE_INTEGER <>
     GET_LENGTH_INFORMATION ends

     IOCTL_DISK_GET_LENGTH_INFO equ 2D005Ch
     
.data
     DrivePath db "C:\",0

.data?
     hDrive           HANDLE ?
     cbReturned       dd ?
     len              GET_LENGTH_INFORMATION <?>

.code
start:

     invoke CreateFile,addr DrivePath,FILE_LIST_DIRECTORY,FILE_SHARE_READ + FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0
     mov hDrive,eax
   
     invoke DeviceIoControl,hDrive,IOCTL_DISK_GET_LENGTH_INFO, 0,0,addr len, sizeof GET_LENGTH_INFORMATION, addr cbReturned, 0
   
     invoke CloseHandle,hDrive
     invoke ExitProcess,0

end start

[/size]

MichaelW

Try:

len  GET_LENGTH_INFORMATION <>

eschew obfuscation

donkey

or try:

len DQ ?

A LARGE_INTEGER structure is just a qword or a union of 2 dwords but in both cases it resolves to a qword.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

it's a nested structure inside a structure   :P

     len              GET_LENGTH_INFORMATION <<?>>
or
     len              GET_LENGTH_INFORMATION <<<?,?>>>

i think either of those will work
Michael's way is easier   :bg
Edgar is also right

the way i handle simple stuff like this is...
lenQ    LABEL   QWORD
lenL    dd ?
lenH    dd ?


then, you can grab the QWORD with lenQ

azdps

Wasnt able to get it to work for some reason. DeviceIOControl fails.

MichaelW

To get an idea of why it's failing, call the GetLastError function and check the error code that it returns. Another alternative is the MASM32 LastError$() macro, which will get the last error-code value and return the offset address of a system-defined error string. Depending on your app, you can then either display the string with the print macro or in a message box.
eschew obfuscation

lingo

#6
"i think either of those will work
Michael's way is easier   
Edgar is also right"


Wrong! :lol
try  with
-  IOCTL_DISK_GET_LENGTH_INFO equ 7405Ch
-  DrivePath db "\\.\C:",0

- len  db  24 Dup(0)

and

invoke DeviceIoControl,hDrive,IOCTL_DISK_GET_LENGTH_INFO, 0,0,addr len, sizeof len, addr cbReturned, 0

dedndave

#7
obviously, you took my statement out of context, ***offending content removed***

PBrennick

Dave,
Maybe I'll go away for another couple of years if language such as that has become acceptable.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

jj2007

Quote from: dedndave on May 16, 2011, 11:21:32 AM
obviously, you took my statement out of context, fucking moron

Dave, really :naughty:

Rumpelstilzchen is still the fastest assembly coder in Toronto, and produces the nicest GPFs in town :P

lingo

"The Campus
A protected forum where programmers learning assembler can ask questions in a sensible and safe atmosphere without being harassed or insulted."

Super protection from the forum's idiots!!! :lol

BogdanOntanu

Indeed Dave... what happened to your good manners ?

Please avoid this kind of statements  :D
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

sinsi

With lingo's corrections the code works fine but only if run as administrator (win7 pro x64). I would imagine that vista would also require admin.
Light travels faster than sound, that's why some people seem bright until you hear them.

hutch--

 :bg

Now now kiddies, you have to be an Australian to know how to use naughty words in a consistent manner.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php