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]
Try:
len GET_LENGTH_INFORMATION <>
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.
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
Wasnt able to get it to work for some reason. DeviceIOControl fails.
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.
"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
obviously, you took my statement out of context, ***offending content removed***
Dave,
Maybe I'll go away for another couple of years if language such as that has become acceptable.
Paul
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
"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
Indeed Dave... what happened to your good manners ?
Please avoid this kind of statements :D
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.
:bg
Now now kiddies, you have to be an Australian to know how to use naughty words in a consistent manner.
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?
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
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