News:

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

Main Menu

Need help with my first masm program

Started by coffeeprog, July 29, 2021, 01:21:16 AM

Previous topic - Next topic

jj2007

Quote from: Biterider on August 09, 2021, 07:56:47 PMthe GlobalAlloc and LocalAlloc functions are essentially the same.

Thanks, Biterider. In the meantime, I made an interesting discovery: Nidud was partially right.

Two posts above I attached two proggies: The first one GlobalAlloc's 200MB and exits without freeing them. The second one WinExec's the first 10,000 times. No problem, tested fine on Windows 7-64.

However, if you replace GlobalAlloc with SysAllocString as shown below, the behaviour changes dramatically. Test it only with maximum caution - I had to press the power button for five seconds to get out of the mess (and I had to do that three times...).

After only 20 iterations in the loop of the launcher posted above, the system may freeze completely. I've put "may" in bold, because, ehm, it depends :cool:

include \masm32\include\masm32rt.inc

.code
start:
  mov ecx, 200000000
  push ecx
  invoke GlobalAlloc, GMEM_FIXED, ecx
  pop ecx
  .While 1
dec ecx
.Break .if Sign?
mov byte ptr [eax+ecx], "x"
  .Endw
  push eax
  invoke SysAllocString, eax
  .if !eax
print str$(rv(GetTickCount)), "..."
print LastError$()
print chr$(13)
  .endif
  call GlobalFree 
  exit
end start

nidud

#31
deleted