WGH handle
handle
Global memory handle of memory object to convert.
To convert a global memory handle to a pointer, use the WGH command. WGH converts a global memory handle into a near or a far pointer. Use WLH to convert local memory handles.
The WDG and WDL commands convert the handle into a pointer and display the value of the pointer in segment:offset format. You can then use that value to access the memory.
In a Windows program, the GlobalLock function is used to convert memory handles into near or far pointers. You may know the handle of the memory object, but you might not know what near or far address it refers to unless you are debugging in an area where the program has just called GlobalLock.
You use the WGH command at any time to find out what the pointer addresses are for global memory handles.
The following example is used to display a string in Window's global heap. First, the following code sets up the string:
HANDLE hGlobalMem;
LPSTR lpstr;
hGlobalMem = GlobalAlloc( GMEM_MOVEABLE, 10L )
lpstr = GlobalLock( hGlobalMem );
lstrcpy( lpstr, "ABCDEF" );
GlobalUnlock( hGlobalMem );
You can display the contents of the string with the following sequence of commands:
>wgh hGlobalMem
0192:6E30
>? *(char far*) 0x0192:0x6E30,s