Author Topic: write_disk_file  (Read 6023 times)

DanWebb314

  • Guest
write_disk_file
« on: June 25, 2012, 12:27:09 PM »
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.

Code: [Select]
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    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

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Re: write_disk_file
« Reply #1 on: June 25, 2012, 12:44:58 PM »
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

  • Member
  • ***
  • Posts: 426
Re: write_disk_file
« Reply #2 on: June 25, 2012, 12:50:35 PM »
Dan,

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

Dave.

DanWebb314

  • Guest
Re: write_disk_file
« Reply #3 on: June 25, 2012, 01:49:06 PM »
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

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: write_disk_file
« Reply #4 on: June 25, 2012, 06:09:54 PM »
Where do you get this stralloc stuff? 268 MB is no problem for a simple HeapAlloc...

Code: [Select]
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--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: write_disk_file
« Reply #5 on: June 25, 2012, 07:56:13 PM »
OLE string works fine.  :biggrin:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: