At 09:39 PM 9/18/00 +0200, you wrote:
>Hallo,
>
>I have some program crashing on exit:
>
>Call kernel32.446: GlobalHandle(4033d284) ret=0f725ce0 fs=008f
>Ret kernel32.446: GlobalHandle() retval=4033d25e ret=0f725ce0 fs=008f
>Call kernel32.453: GlobalUnlock(0000d25e) ret=0f725cee fs=008f
>CALL MSVCRT20.562: _except_handler3(<unknown, check return>) ret=4004480a fs=008f
<snip>
HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, 4096), h2;
BYTE *ptr;
UINT flags;
BOOL b;
ptr = (BYTE *)GlobalLock(h);
h2 = GlobalHandle(ptr);
flags = GlobalFlags(h);
b = GlobalUnlock((HGLOBAL)LOWORD(h2));
//b = GlobalUnlock(h2);
flags = GlobalFlags(h);
GlobalFree(h);
It does not crash, but it does not work correctly :
flags = 1 after the second GlobalFlags, while if I use
the commented out code
b = GlobalUnlock(h2);
flags = 0 (correct)
So IMHO it's an application bug. Handles are 32 bits
in Win32 and the doc is strongly warning about not
fooling with handle values (well, almost always, at least)
Some (officially) 32 bits app are still full of 16 bits code
so this could be some old code never updated completely.
>What to do about that?
Probably avoid the crash - easier said than done :-(
Gerard