📄 memwnd.c
字号:
case WM_SHOWWINDOW:
if( IsWindow( info->dialog ) ) {
if( !wparam && LOWORD( lparam ) == SW_PARENTCLOSING ) {
ShowWindow( info->dialog, SW_HIDE );
} else if( wparam && LOWORD( lparam ) == SW_PARENTOPENING ) {
ShowWindow( info->dialog, SW_SHOWNOACTIVATE );
}
}
return( DefWindowProc( hwnd, msg, wparam, lparam ) );
case WM_KEYDOWN:
switch( wparam ) {
case VK_UP:
case VK_LEFT:
wparam = SB_LINEUP;
break;
case VK_DOWN:
case VK_RIGHT:
wparam = SB_LINEDOWN;
break;
case VK_PRIOR:
wparam = SB_PAGEUP;
break;
case VK_NEXT:
wparam = SB_PAGEDOWN;
break;
#if(0)
/* I don't support these functions because it takes too long
* to perform an end operation on an assembly window if it is the
* first operation */
case VK_HOME:
wparam = SB_TOP;
break;
case VK_END:
wparam = SB_BOTTOM;
break;
#endif
default:
return( DefWindowProc( hwnd, msg, wparam, lparam ) );
}
case WM_VSCROLL:
if( ISCODE( info ) ) {
ScrollAsm( hwnd, GET_WM_VSCROLL_CODE( wparam, lparam ),
GET_WM_VSCROLL_POS( wparam, lparam ), info );
} else {
ScrollData( hwnd, GET_WM_VSCROLL_CODE( wparam, lparam ),
GET_WM_VSCROLL_POS( wparam, lparam ), info );
}
break;
case WM_COMMAND:
cmd = LOWORD( wparam );
switch( cmd ) {
case MEMINFO_SAVE:
MemSave( info, hwnd, TRUE );
break;
case MEMINFO_SAVE_TO:
MemSave( info, hwnd, FALSE );
break;
case MEMINFO_SHOW:
inst = GET_HINSTANCE( hwnd );
DisplaySegInfo( hwnd, inst, info );
break;
case MEMINFO_AUTO_POS:
menu = GetMenu( hwnd );
state = CheckMenuItem( menu, MEMINFO_AUTO_POS, MF_CHECKED );
if( state == MF_CHECKED ) {
CheckMenuItem( menu, MEMINFO_AUTO_POS, MF_UNCHECKED );
info->autopos = FALSE;
} else {
info->autopos = TRUE;
PositionSegInfo( info->dialog );
}
break;
case MEMINFO_EXIT:
SendMessage( hwnd, WM_CLOSE, 0, 0L );
break;
case MEMINFO_CODE_16:
case MEMINFO_CODE_32:
info->ins_cnt = 0;
info->offset = info->base;
/* fall through */
case MEMINFO_BYTE:
case MEMINFO_WORD:
case MEMINFO_DWORD:
if( ISCODE( info ) ) {
info->offset -= ( info->offset - info->base ) % info->bytesdisp;
}
menu = GetMenu( hwnd );
CheckMenuItem( menu, info->disp_type, MF_UNCHECKED );
CheckMenuItem( menu, cmd, MF_CHECKED );
info->disp_type = wparam;
GetClientRect( hwnd, &area );
size = MAKELONG( area.right - area.left, area.bottom - area.top );
wbrush = GetStockObject( WHITE_BRUSH );
if( IsWindowVisible( info->scrlbar ) ) {
area.right -= GetSystemMetrics( SM_CXVSCROLL );
}
dc = GetDC( hwnd );
FillRect( dc, &area, wbrush );
ReleaseDC( hwnd, dc );
GetClientRect( hwnd, &area );
ReSizeMemBox( hwnd, size, info );
break;
case MEMINFO_OFFSET:
inst = GET_HINSTANCE( hwnd );
fp = MakeProcInstance( (FARPROC)OffsetProc, inst );
DialogBox( inst, "OFFSETDLG", hwnd, (DLGPROC)fp );
FreeProcInstance( fp );
break;
}
break;
case WM_CLOSE:
if( !MemConfigInfo.forget_pos ) {
MemConfigInfo.maximized = info->maximized;
MemConfigInfo.autopos_info = info->autopos;
if( ISCODE( info ) ) {
MemConfigInfo.code_disp_type = info->disp_type;
} else {
MemConfigInfo.disp_type = info->disp_type;
}
if( !info->maximized ) {
GetWindowRect( hwnd, &area );
MemConfigInfo.xpos = area.left;
MemConfigInfo.ypos = area.top;
MemConfigInfo.xsize = area.right - area.left;
MemConfigInfo.ysize = area.bottom - area.top;
}
}
DestroyWindow( hwnd );
break;
case WM_DESTROY:
SendMessage( info->parent, WM_USER, 0, 0 );
if( info != NULL && info->curwnd ) {
CurWindow = NULL;
}
break;
case WM_NCDESTROY:
if( info != NULL ) {
if( info->asm != NULL ) {
MemFree( info->asm );
}
MemFree( info );
}
/* fall through */
default:
return( DefWindowProc( hwnd, msg, wparam, lparam ) );
}
return( TRUE );
}
static void PositionSegInfo( HWND hwnd ) {
HWND parent;
RECT psize;
RECT dsize;
int dwidth;
int dheight;
int scrn_width;
int scrn_hite;
int xpos;
int ypos;
parent = GetParent( hwnd );
GetWindowRect( parent, &psize );
GetWindowRect( hwnd, &dsize );
dwidth = dsize.right - dsize.left;
dheight = dsize.bottom - dsize.top;
scrn_hite = GetSystemMetrics( SM_CYSCREEN );
scrn_width = GetSystemMetrics( SM_CXSCREEN );
xpos = psize.left;
ypos = psize.top;
if( ypos < 0 ) ypos = 0;
if( psize.bottom + dheight <= scrn_hite
&& psize.left + dwidth <= scrn_width ) {
ypos = psize.bottom;
} else if( psize.top > dheight && psize.left + dwidth <= scrn_width ) {
ypos = psize.top - dheight;
} else if( psize.left > dwidth ) {
xpos = psize.left - dwidth;
} else if( psize.right + dwidth < scrn_width ) {
xpos = psize.right;
} else {
xpos = psize.left;
ypos = psize.bottom - dheight;
}
SetWindowPos( hwnd, NULL, xpos, ypos, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
} /* PositionSegInfo */
BOOL __export FAR PASCAL SegInfoProc( HWND hwnd, WORD msg, WORD wparam,
DWORD lparam )
{
HWND parent;
HMENU mh;
wparam = wparam;
lparam = lparam;
switch( msg ) {
case WM_INITDIALOG:
PositionSegInfo( hwnd );
break;
#ifndef NOUSE3D
case WM_SYSCOLORCHANGE:
Ctl3dColorChange();
break;
#endif
case WM_CLOSE:
DestroyWindow( hwnd );
break;
case WM_DESTROY:
parent = GetParent( hwnd );
mh = GetMenu( parent );
EnableMenuItem( mh, MEMINFO_SHOW, MF_ENABLED );
break;
case WM_NCDESTROY:
#ifndef __NT__
DialCount --;
if( DialCount == 0 ) {
FreeProcInstance( DialProc );
}
#endif
return( FALSE ); /* we need to let WINDOWS see this message or
fonts are left undeleted */
break;
default:
return( FALSE );
}
return( TRUE );
}
static void DisplaySegInfo( HWND parent, HANDLE instance, MemWndInfo *info ) {
#ifdef __NT__
parent = parent;
instance = instance;
info = info;
#else
GLOBALENTRY ge;
descriptor desc;
HWND hwnd;
char buf[10];
char *ptr;
char *rcstr;
HMENU mh;
mh = GetMenu( parent );
EnableMenuItem( mh, MEMINFO_SHOW, MF_GRAYED );
if( DialCount == 0 ) {
DialProc = MakeProcInstance( (FARPROC)SegInfoProc, instance );
}
DialCount ++;
if( info->isdpmi ) {
GetADescriptor( info->sel, &desc );
hwnd = CreateDialog( instance, "SEL_INFO", parent, (DLGPROC)DialProc );
sprintf( buf, "%04X", info->sel );
SetDlgItemText( hwnd, SEL_INFO_SEL, buf );
// SetWORDStaticField( hwnd, SEL_INFO_SEL, info->sel );
sprintf( buf, "%08X", GET_DESC_BASE( desc ) );
SetDlgItemText( hwnd, SEL_INFO_BASE, buf );
// SetDWORDStaticField( hwnd, SEL_INFO_BASE, GET_DESC_BASE( desc ) );
sprintf( buf, "%08X", GET_DESC_LIMIT( desc ) );
SetDlgItemText( hwnd, SEL_INFO_LIMIT, buf );
// SetDWORDStaticField( hwnd, SEL_INFO_LIMIT, GET_DESC_LIMIT( desc ) );
if( desc.type == 2 ) {
rcstr = AllocRCString( MWND_DATA );
} else {
rcstr = AllocRCString( MWND_CODE );
}
SetDlgItemText( hwnd, SEL_INFO_TYPE, rcstr );
FreeRCString( rcstr );
sprintf( buf, "%1d", desc.dpl );
SetDlgItemText( hwnd, SEL_INFO_DPL, buf );
if( desc.granularity ) {
rcstr = AllocRCString( MWND_PAGE );
} else {
rcstr = AllocRCString( MWND_BYTE );
}
SetDlgItemText( hwnd, SEL_INFO_GRAN, rcstr );
FreeRCString( rcstr );
ptr = buf;
CreateAccessString( ptr, &desc );
SetDlgItemText( hwnd, SEL_INFO_ACCESS, buf );
} else {
ge.dwSize = sizeof( GLOBALENTRY );
GlobalEntryHandle( &ge, (HGLOBAL)info->sel );
hwnd = CreateDialog( instance, "HDL_INFO", parent, (DLGPROC)DialProc );
sprintf( buf, "%04X", ge.hBlock );
SetDlgItemText( hwnd, HDL_INFO_HDL, buf );
// SetWORDStaticField( hwnd, HDL_INFO_HDL, ge.hBlock );
sprintf( buf, "%08X", ge.dwAddress );
SetDlgItemText( hwnd, HDL_INFO_ADDR, buf );
// SetDWORDStaticField( hwnd, HDL_INFO_ADDR, ge.dwAddress );
sprintf( buf, "%04X", ge.dwBlockSize );
SetDlgItemText( hwnd, HDL_INFO_SIZE, buf );
// SetWORDStaticField( hwnd, HDL_INFO_SIZE, ge.dwBlockSize );
sprintf( buf, "%04X", ge.wcLock );
SetDlgItemText( hwnd, HDL_INFO_LOCK, buf );
// SetWORDStaticField( hwnd, HDL_INFO_LOCK, ge.wcLock );
sprintf( buf, "%04X", ge.wcPageLock );
SetDlgItemText( hwnd, HDL_INFO_PLOCK, buf );
// SetWORDStaticField( hwnd, HDL_INFO_PLOCK, ge.wcPageLock );
}
info->dialog = hwnd;
#endif
} /* DisplaySegInfo */
HWND DispMem( HANDLE instance, HWND parent, WORD seg, BOOL isdpmi ) {
HWND hdl;
char buf[50];
MemWndInfo *info;
BOOL maximize;
#ifndef __NT__
descriptor desc;
GLOBALENTRY ge;
desc = desc;
if( isdpmi ) {
RCsprintf( buf, MWND_MEM_DISP_FOR_SEL_X, seg );
} else {
RCsprintf( buf, MWND_MEM_DISP_FOR_HDL_X, seg );
}
#endif
if( !MemConfigInfo.init ) {
SetDefMemConfig();
}
maximize = MemConfigInfo.maximized;
if( CurWindow != NULL ) {
if( MemConfigInfo.allowmult == WND_REPLACE ) {
SendMessage( CurWindow, WM_CLOSE, 0, 0L );
} else if( MemConfigInfo.allowmult == WND_SINGLE ) {
return( NULL );
}
}
info = MemAlloc( sizeof( MemWndInfo ) );
if( info == NULL ) {
RCMessageBox( parent, MWND_CANT_DISP_MEM_WND, MemConfigInfo.appname,
MB_OK | MB_ICONHAND | MB_SYSTEMMODAL );
return( NULL );
}
info->sel = seg;
info->limit = GetASelectorLimit( seg );
info->lastline = 0;
info->bytesdisp = 1;
info->ins_cnt = 0;
info->width = 0;
info->parent = parent;
info->dialog = NULL;
info->isdpmi = isdpmi;
info->autopos = MemConfigInfo.autopos_info;
#ifndef __NT__
if( isdpmi ) {
GetADescriptor( seg, &desc );
if( desc.type == 2 ) {
info->disp_type = MemConfigInfo.disp_type;
} else {
info->disp_type = MemConfigInfo.code_disp_type;
}
} else {
memset( &ge, 0, sizeof( GLOBALENTRY ) );
ge.dwSize = sizeof( GLOBALENTRY );
GlobalEntryHandle( &ge, (HGLOBAL)seg );
if( ge.wType == GT_CODE ) {
info->disp_type = MemConfigInfo.code_disp_type;
} else {
info->disp_type = MemConfigInfo.disp_type;
}
}
info->base = 0;
#else
info->disp_type = MemConfigInfo.disp_type;
info->base = CurBase;
#endif
info->offset = info->base;
info->asm = NULL;
if( MemConfigInfo.allowmult != WND_MULTI ) {
info->curwnd = TRUE;
CurWindow = hdl;
} else {
info->curwnd = FALSE;
}
hdl = CreateWindow(
MEM_DISPLAY_CLASS, /* Window class name */
buf, /* Window caption */
WS_OVERLAPPED|WS_CAPTION
|WS_SYSMENU|WS_THICKFRAME
|WS_MAXIMIZEBOX, /* Window style */
0, /* Initial X position */
0, /* Initial Y position */
0, /* Initial X size */
0, /* Initial Y size */
parent, /* Parent window handle */
NULL, /* Window menu handle */
instance, /* Program instance handle */
info ); /* Create parameters */
if( hdl == NULL || info->scrlbar == NULL ) {
RCMessageBox( parent, MWND_CANT_DISP_MEM_WND, MemConfigInfo.appname,
MB_OK | MB_ICONHAND | MB_SYSTEMMODAL );
DestroyWindow( hdl );
MemFree( info );
return( NULL );
}
if( maximize ) {
ShowWindow( hdl, SW_SHOWMAXIMIZED );
} else {
ShowWindow( hdl, SW_SHOWNORMAL );
}
if( MemConfigInfo.allowmult != WND_MULTI ) {
CurWindow = hdl;
}
return( hdl );
}
#ifdef __NT__
HWND DispNTMem( HWND parent, HANDLE instance, HANDLE prochdl, DWORD offset,
DWORD limit, char *title ) {
HWND ret;
ProcessHdl = prochdl;
CurLimit = limit;
CurBase = offset;
ret = DispMem( instance, parent, 0, FALSE );
SetWindowText( ret, title );
return( ret );
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -