News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

write_disk_file

Started by DanWebb314, June 25, 2012, 12:27:09 PM

Previous topic - Next topic

DanWebb314

I am trying to find out the proper way to use the "write_disk_file" proc.  Here is the following code.  When I assemble it I get error A2206: missing operator in expression.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include \masm32\include\masm32rt.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    .data?
      value dd ?

    .data
      fileName byte "data.bin"
      fnstrgPointer DWORD 0
      maxp1 DWORD 1024
      bufferPointer DWORD 0
     
    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    cls
    nop
    nop
    stralloc maxp1 ; get buffer
    mov bufferPointer, eax
    nop
    ;   code to fill buffer with data
    nop
    lea eax, fileName
    mov fnstrgPointer, eax

    invoke write_disk_file fnstrgPointer, bufferPointer, maxp1
   
    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start


Do you have any idea how to fix this or where to find an example?

MichaelW

You left a comma out of your invoke statement:

invoke write_disk_file, fnstrgPointer, bufferPointer, maxp1

Well Microsoft, here's another nice mess you've gotten us into.

KeepingRealBusy

Dan,

Forget what I said here before, I'm still in shell shock learning Windows 7.

Dave.

DanWebb314

Adding a comma works great.  When I add the code to put data in the buffer it works just the way I want.  My program must work with "stralloc maxp1" because it work with a very large buffer: 268,410,876 bytes

jj2007

Where do you get this stralloc stuff? 268 MB is no problem for a simple HeapAlloc...

include \masm32\include\masm32rt.inc

.code
start:
invoke HeapAlloc, rv(GetProcessHeap), HEAP_GENERATE_EXCEPTIONS, 800000000
xchg eax, edi
.if eax
print str$(edi), 9, "is the pointer", 13, 10
invoke HeapFree, rv(GetProcessHeap), 0, edi
inkey str$(eax), 9, "retval HeapFree", 13, 10
.else
inkey LastError$()
.endif
exit

end start

hutch--

OLE string works fine.  :biggrin: