The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: azdps on May 12, 2011, 07:54:50 AM

Title: GET_LENGTH_INFORMATION structure
Post by: azdps on May 12, 2011, 07:54:50 AM
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]
Title: Re: GET_LENGTH_INFORMATION structure
Post by: MichaelW on May 12, 2011, 08:28:08 AM
Try:

len  GET_LENGTH_INFORMATION <>

Title: Re: GET_LENGTH_INFORMATION structure
Post by: donkey on May 12, 2011, 08:34:28 AM
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.
Title: Re: GET_LENGTH_INFORMATION structure
Post by: dedndave on May 12, 2011, 01:05:27 PM
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
Title: Re: GET_LENGTH_INFORMATION structure
Post by: azdps on May 14, 2011, 07:33:09 PM
Wasnt able to get it to work for some reason. DeviceIOControl fails.
Title: Re: GET_LENGTH_INFORMATION structure
Post by: MichaelW on May 16, 2011, 12:24:17 AM
To get an idea of why it's failing, call the  GetLastError (http://msdn.microsoft.com/en-us/library/ms679360(v=vs.85).aspx) 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.
Title: Re: GET_LENGTH_INFORMATION structure
Post by: lingo on May 16, 2011, 03:23:31 AM
"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
Title: Re: GET_LENGTH_INFORMATION structure
Post by: dedndave on May 16, 2011, 11:21:32 AM
obviously, you took my statement out of context, ***offending content removed***
Title: Re: GET_LENGTH_INFORMATION structure
Post by: PBrennick on May 16, 2011, 12:51:56 PM
Dave,
Maybe I'll go away for another couple of years if language such as that has become acceptable.

Paul
Title: Re: GET_LENGTH_INFORMATION structure
Post by: oex on May 16, 2011, 02:06:34 PM
Quote from: dedndave on May 16, 2011, 11:21:32 AM
fucking moron

:lol Couldnt help but laugh
Title: Re: GET_LENGTH_INFORMATION structure
Post by: jj2007 on May 16, 2011, 02:42:31 PM
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
Title: Re: GET_LENGTH_INFORMATION structure
Post by: lingo on May 16, 2011, 03:50:20 PM
"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
Title: Re: GET_LENGTH_INFORMATION structure
Post by: BogdanOntanu on May 19, 2011, 07:38:01 AM
Indeed Dave... what happened to your good manners ?

Please avoid this kind of statements  :D
Title: Re: GET_LENGTH_INFORMATION structure
Post by: sinsi on May 19, 2011, 08:43:12 AM
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.
Title: Re: GET_LENGTH_INFORMATION structure
Post by: hutch-- on May 19, 2011, 11:21:19 AM
 :bg

Now now kiddies, you have to be an Australian to know how to use naughty words in a consistent manner.
Title: Re: GET_LENGTH_INFORMATION structure
Post by: jj2007 on May 19, 2011, 11:29:35 AM
Quote from: hutch-- on May 19, 2011, 11:21:19 AM
Now now kiddies, you have to be an Australian to know how to use naughty words in a consistent manner.

Hutch,
Now which are the naughty words in Sinsi's post? You must translate, for me it looks harmless ::)

Quote from: sinsi on May 19, 2011, 08:43:12 AM
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.

P.S.: Or did you mean the "idiot" in lingo's post?
Title: Re: GET_LENGTH_INFORMATION structure
Post by: sinsi on May 19, 2011, 11:40:17 AM
Quote from: hutch-- on May 19, 2011, 11:21:19 AM
Now now kiddies, you have to be an Australian to know how to use naughty words in a consistent manner.
Fckn oath!

Thanks for the quoting of the original, makes sense now. Naughty dave  :lol
Title: Re: GET_LENGTH_INFORMATION structure
Post by: hutch-- on May 19, 2011, 12:52:00 PM
JJ,

The comment was in the plural. To be consistent with "naughty words" you have to grow up in a culture that encapsulates them as idiom rather than append them as an afterthought. Now this means if some unmitigated phukn idiot thinks they have something to say you tell 'em to let go of their reproductive organ first so they can swap hands to relieve the symptoms of repetitive strain injury.  :bg