News:

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

Main Menu

Access Violation with a global variable inside WndProc

Started by xandaz, December 19, 2016, 12:33:55 PM

Previous topic - Next topic

xandaz

   Hi guys. Long time no see. I'm trying to get back on track. The problem is of the sort:
.data
hToolbar  HWND ?
...
.code
...
WndProc...
...
    mov hToolbar,eax ( this right after CreateWndowEx )


olly says access violation.
works with local variables.
thanks

jj2007

Aggressive linker settings?

Using /MERGE:.data=.text, this one works with polink but with M$ link it crashes:include \masm32\include\masm32rt.inc

.data
global dd ?

.code
start:
  mov global, eax
  print "ok"
  exit
end start

BugCatcher

Doesn't uninitialized data (?) have to be in a unitialized data section .data?

hutch--

Try this.


.data?        ; <<<< UNinitialised data section.
hToolbar  HWND ?

jj2007

Quote from: BugCatcher on December 22, 2016, 02:16:53 AM
Doesn't uninitialized data (?) have to be in a unitialized data section .data?

In can be in data?, but it doesn't have to. You increase your exe size by 4 bytes, but that's the only disadvantage.

xandaz

   Really? I thought the question mark didn't matter... let me see. Thanks guys

xandaz

   Not working... this never happened. Could it be one of those stupid things? I have a lot of that. Skipping the obvious details is my speciallty. ty

xandaz

   Solved. Using WSTR instead of UCSTR. Forgot to mention it has been a problem before. ty