News:

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

Main Menu

Problems closing handles give error o memory access....HELP

Started by xandaz, November 19, 2020, 08:48:19 AM

Previous topic - Next topic

xandaz

    i have this code for app termination. it should close the handles of the files associated with their respective windows...
close_handles:   
        cmp     noMdiChild,0
        je      done_close_handles
        invoke  SendMessage,hMdi,WM_MDIGETACTIVE,0,0
        mov     hCurrentWindow,eax
        invoke  GetWindowLong,eax,GWL_USERDATA
        invoke  CloseHandle,[eax.MdiStruct.hFile]
        invoke  SendMessage,hWnd,WM_MDIDESTROY,hCurrentWindow,0
        dec     noMdiChild
        jmp     close_handles   


When i close the app it gives an error on memory access that is not for reading. can someone help me out?

xandaz

   I''m using SendMessage,hMdiClient,WM_USER+100,0,0 But the mdiproc doesnt recieve the message. Why the hell would that be?

xandaz

   Well...i guess the problem is how to send messages to mdi child proc.

zedd151

Could we see a little more code?

You could try to use a message box to see if the said handles actually exist, for debugging..

invoke MessageBox, 0, hex$(handle), 0, 0

where handle is the suspect handle

;;;;;;;;;;;;

Or run it in a debugger and see better what is going on with the code while stepping the code.


jj2007


daydreamer

Quote from: xandaz on November 19, 2020, 09:44:57 AM
   Well...i guess the problem is how to send messages to mdi child proc.
look at Hutch example for send messages between two programs,maybe you need too register custom messages to make them work?
I think you should add some error checking code,checking for return eax==NULL and use a messagebox,because later down in the code NULL pointer gives you that error on memory access
sometimes its just forget to addr filename,instead of just filename in invoke
@JJ
crystall ball sounds like a great name for a debugger :biggrin:
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

xandaz

    Thanks guys. I've tried also PostMessage and MdiProc doesn't recieve the message....

xandaz

   did something stupid. I subclassed the MDIClient window and call both CallWindowProc and DefMdiChildProc. It accepts the message