PWALK.C
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:45k
源码类别:
Windows编程
开发平台:
Visual C++
- /******************************************************************************
- * This is a part of the Microsoft Source Code Samples.
- * Copyright (C) 1993-1997 Microsoft Corporation.
- * All rights reserved.
- * This source code is only intended as a supplement to
- * Microsoft Development Tools and/or WinHelp documentation.
- * See these sources for detailed information regarding the
- * Microsoft samples programs.
- *
- *
- * Note: pwalk will only work correctly with Win32 applications.
- *
- *
- ******************************************************************************/
- #include "pwalk.h"
- #define strtok My_mbstok
- #define MAX_DRIVES 26 /* maximum number of logical drives */
- /* system constants used externally */
- int xChar,
- yChar,
- xScreen,
- yScreen,
- yFrame,
- xFrame,
- yCaption,
- xVScrollBar;
- char szCaptionText[] ="Address State Prot Size BaseAddr Object Section Name ";
- char szFormat[] = "%08lX~%s ~%s ~%lu~%08lX~%s ~%s ~%s ~";
- SIZE sChar0;
- char szFormatPages[] = "%05lX~%s ~%s ~%lu~%05lX~%s ~%s ~%s ~";
- int taColumns[] = {TA_RIGHT, TA_LEFT, TA_LEFT, TA_RIGHT,
- TA_RIGHT, TA_RIGHT, TA_LEFT, TA_LEFT,
- };
- int xColumns[] = { 8, 9, 17, 31,
- 40, 46, 47, 55,
- };
- BOOL bNumbersAsBytes = TRUE;
- HFONT hFontVar;
- char szFilePath[MAX_PATH] = "";
- char szFilename[MAX_PATH] = "";
- HFONT hFont;
- LPVOID lpWalkerList = NULL;
- int *Objects;
- int nSortType = IDM_SORTADDRESS;
- HWND hWndSysStat, hWndProStat, hInitDlg, hMemWnd;
- HANDLE hChildEvents[nDEBUGEVENTS];
- DBGPROCESS *lpChildProcess = NULL;
- HMENU hPopup[MENUPOPUPS];
- char szCurPath[MAX_PATH];
- /* local functions */
- BOOL WINAPI InitEnvironment (HANDLE, int, char *);
- void WINAPI InitMenu (HWND);
- void WINAPI DrawListItem (DRAWITEMSTRUCT *);
- int WINAPI MakeVMQString (int, char *);
- DWORD WINAPI VMExceptionFilter (EXCEPTION_POINTERS *);
- void WINAPI SortList (HWND, int);
- BOOL WINAPI ViewableMemorySelection (HWND);
- static void TextOutFields (HDC, int, LPRECT, LPSTR);
- /****************************************************************************
- My_mbschr: strchr() DBCS version
- ****************************************************************************/
- unsigned char * _CRTAPI1 My_mbschr(
- unsigned char *psz, unsigned short uiSep)
- {
- while (*psz != ' ' && *psz != uiSep) {
- psz = CharNext(psz);
- }
- if (*psz == ' ' && uiSep != ' ') {
- return NULL;
- } else {
- return psz;
- }
- }
- /****************************************************************************
- My_mbstok: strtok() DBCS version
- ****************************************************************************/
- unsigned char * _CRTAPI1 My_mbstok(
- unsigned char *pszSrc, unsigned char *pszSep)
- {
- static char *pszSave = NULL;
- char *pszHead;
- char *psz;
- if (pszSrc == NULL) {
- if (pszSave == NULL) {
- return NULL;
- } else {
- psz = pszSave;
- }
- } else {
- psz = pszSrc;
- }
- /*********************************************/
- /* Skip delimiters to find a head of a token */
- /*********************************************/
- while (*psz) {
- if (IsDBCSLeadByte(*psz)) {
- break;
- } else if (NULL == My_mbschr(pszSep, *psz)) {
- break;
- }
- psz++;
- }
- if (*psz == ' ') {
- //No more token
- return (pszSave = NULL);
- }
- pszHead = psz;
- /******************************/
- /* Search a Tail of the token */
- /******************************/
- while (*psz) {
- if (IsDBCSLeadByte(*psz)) {
- psz += 2;
- continue;
- } else if (NULL != My_mbschr(pszSep, *psz)) {
- break;
- }
- psz++;
- }
- if (*psz == ' ') {
- pszSave = NULL;
- } else {
- //Found next delimiter
- pszSave = psz + 1;
- *psz = ' ';
- }
- return pszHead;
- }
- /* entry point of this executable */
- int WINAPI WinMain (hInstance, hPrevInstance, lpCmdLine, nCmdShow)
- HINSTANCE hInstance;
- HINSTANCE hPrevInstance;
- LPSTR lpCmdLine;
- int nCmdShow;
- {
- MSG msg;
- char *lpszCmdLine = NULL;
- char *lpCL;
- BOOL bSwitch;
- /* set current path for use later */
- GetCurrentDirectory (MAX_PATH, szCurPath);
- // parse and copy command line parameters to local memory
- lpCL = GetCommandLine ();
- if (lpszCmdLine = (char *)LocalAlloc (LPTR, strlen (lpCL) + 1))
- GetCmdLine (lpCL, lpszCmdLine, &bSwitch);
- /* start window environment */
- if (!InitEnvironment (hInstance, nCmdShow, IsValidFile (lpszCmdLine) ? lpszCmdLine : NULL))
- return FALSE;
- /* free memory allocated for lpCmdLine */
- if (lpszCmdLine)
- LocalFree ((HLOCAL)lpszCmdLine);
- /* main window message loop */
- while (GetMessage (&msg, NULL, 0, 0))
- {
- TranslateMessage (&msg);
- DispatchMessage (&msg);
- }
- /* return success of application */
- return TRUE;
- }
- /* start app */
- BOOL WINAPI InitEnvironment (
- HANDLE hInstance,
- int nCmdShow,
- char *lpszCmdLine)
- {
- WNDCLASS wc;
- char szClass[MAX_PATH];
- char szTitle[MAX_PATH];
- char szFilename[MAX_PATH];
- HWND hWnd;
- /* register system statistics window class */
- LoadString (hInstance, IDS_SYSSTATCLASS, szClass, sizeof (szClass));
- wc.style = 0;
- wc.lpfnWndProc = (WNDPROC)SysStatWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDR_SYSSTATICON));
- wc.hCursor = LoadCursor (0, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = szClass;
- if (!RegisterClass (&wc) )
- return FALSE;
- /* register process statistics window class */
- LoadString (hInstance, IDS_PROSTATCLASS, szClass, sizeof (szClass));
- wc.style = 0;
- wc.lpfnWndProc = (WNDPROC)ProStatWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDR_PROSTATICON));
- wc.hCursor = LoadCursor (0, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = szClass;
- if (!RegisterClass (&wc) )
- return FALSE;
- /* register the status bar window class */
- LoadString (hInstance, IDS_STATUSCLASS, szClass, sizeof (szClass));
- wc.style = 0;
- wc.lpfnWndProc = (WNDPROC)StatusWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = STATUSWXB;
- wc.hInstance = hInstance;
- wc.hIcon = (HICON)NULL;
- wc.hCursor = LoadCursor (0, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = szClass;
- if (!RegisterClass (&wc) )
- return FALSE;
- /* register the main frame window class */
- LoadString (hInstance, IDS_MEMVIEWCLASS, szClass, sizeof (szClass));
- wc.style = 0;
- wc.lpfnWndProc = (WNDPROC)MemWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = VIEWWXB;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDR_MAINICON));
- wc.hCursor = LoadCursor (0, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = szClass;
- if (!RegisterClass (&wc) )
- return FALSE;
- /* register the main frame window class */
- LoadString (hInstance, IDS_WALKERCLASS, szClass, sizeof (szClass));
- wc.style = 0;
- wc.lpfnWndProc = (WNDPROC)WalkerWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDR_MAINICON));
- wc.hCursor = LoadCursor (0, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = MAKEINTRESOURCE (IDR_WALKERMENU);
- wc.lpszClassName = szClass;
- if (!RegisterClass (&wc) )
- return FALSE;
- /* create window caption */
- LoadString (hInstance, IDS_CAPTION, szTitle, sizeof (szTitle));
- if (lpszCmdLine != NULL &&
- ((lpChildProcess = StartChildProcess (NULL, lpszCmdLine, hChildEvents)) != NULL))
- GetFileFromPath (lpszCmdLine, szFilename);
- else
- LoadString (hInstance, IDS_SELF, szFilename, MAX_PATH);
- strcat (szTitle, szFilename);
- /* create main frame window */
- hWnd = CreateWindow (szClass,
- szTitle,
- WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
- CW_USEDEFAULT,
- 0,
- CW_USEDEFAULT,
- 0,
- NULL,
- NULL,
- hInstance,
- NULL);
- /* update parent window handle in child process information structure */
- if (lpChildProcess != NULL)
- lpChildProcess->hWnd = hWnd;
- if (!hWnd)
- return 0;
- ShowWindow (hWnd, nCmdShow);
- UpdateWindow (hWnd);
- return TRUE;
- }
- /* main window procedure */
- LONG WINAPI WalkerWndProc (
- HWND hWnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
- {
- LONG lRet = 1;
- static LOGFONT lf_Font = {
- -10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, FIXED_PITCH | FF_DONTCARE,
- "Courier",
- };
- static LOGFONT lf_FontVar = {
- -10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, 0, // FIXED_PITCH | FF_DONTCARE,
- "MS Sans Serif",
- };
- /* On a Japanese system, change the fonts... should generalize to all FE */
- if (PRIMARYLANGID(GetUserDefaultLangID ()) == LANG_JAPANESE) {
- lf_Font.lfCharSet = SHIFTJIS_CHARSET;
- lstrcpy (lf_Font.lfFaceName , "Terminal");
- lf_FontVar.lfHeight= -12;
- lf_FontVar.lfCharSet = SHIFTJIS_CHARSET;
- lstrcpy (lf_Font.lfFaceName , "俵俽 僑僔僢僋");
- }
- switch (uMsg)
- {
- /* initialize menu before drawing */
- case WM_INITMENU:
- InitMenu (hWnd);
- break;
- /* display status messages for menu commands */
- case WM_MENUSELECT:
- {
- char *lpszMenuString;
- lpszMenuString = LocalAlloc (LPTR, MAX_PATH);
- if (HIWORD (wParam) == 0xFFFF)
- {
- LocalFree (lpszMenuString);
- lpszMenuString = NULL;
- }
- else if (HIWORD (wParam) & MF_POPUP)
- {
- int i;
- HMENU hPopupMenu = GetSubMenu ((HMENU)lParam, LOWORD (wParam));
- lpszMenuString = LocalAlloc (LPTR, MAX_PATH);
- for (i=0; i<MENUPOPUPS; i++)
- {
- if (hPopup[i] == hPopupMenu)
- {
- LoadString (GetModuleHandle (NULL),
- i+IDM_POPUPMENUS,
- lpszMenuString,
- MAX_PATH);
- break;
- }
- }
- }
- else
- LoadString (GetModuleHandle (NULL),
- LOWORD (wParam),
- lpszMenuString,
- MAX_PATH);
- /* send the status string, gray if necessary */
- SendMessage (GetDlgItem (hWnd, IDC_STATUSWND),
- WM_SETTEXT,
- (HIWORD (wParam) & MF_GRAYED) ?
- (LPARAM)GetSysColor (COLOR_GRAYTEXT):
- 0,
- (WPARAM)lpszMenuString);
- LocalFree (lpszMenuString);
- }
- break;
- case WM_CREATE:
- {
- HCURSOR hOldCursor;
- HDC hDC;
- TEXTMETRIC tm;
- char szWndClass[MAX_PATH];
- HWND hList, hStatus;
- int i=0, j, k;
- HMENU hMenu;
- /* build array of popup menu handles */
- hMenu = GetMenu (hWnd);
- for (k=0; k<MENUPOPUPS-(i-1); k++)
- {
- hPopup[i] = GetSubMenu (hMenu, k);
- j=0;
- while ((hPopup[i+j+1] = GetSubMenu (hPopup[i], j)) != NULL)
- j++;
- if (j)
- i+=j;
- i++;
- }
- /* put hourglass cursor up */
- hOldCursor = (HCURSOR)SetClassLong (hWnd, GCL_HCURSOR, 0);
- SetCursor (LoadCursor (0, IDC_WAIT));
- hDC = GetDC(hWnd);
- /* want a font with point size of 10 (smallest size it comes in) */
- lf_Font.lfHeight = -(10 * GetDeviceCaps(hDC, LOGPIXELSY)/72);
- hFont = CreateFontIndirect(&lf_Font);
- hFontVar = CreateFontIndirect(&lf_FontVar);
- // find the width of a '0' in the variable font
- //
- SelectObject(hDC, hFontVar);
- GetTextExtentPoint (hDC, "0", 1, &sChar0);
- SelectObject(hDC, hFont);
- /* initialize system constants */
- GetTextMetrics(hDC, &tm);
- yChar = tm.tmHeight;
- xChar = tm.tmAveCharWidth;
- xScreen = GetSystemMetrics(SM_CXSCREEN);
- yScreen = GetSystemMetrics(SM_CYSCREEN);
- yFrame = GetSystemMetrics(SM_CYFRAME);
- xFrame = GetSystemMetrics(SM_CXFRAME);
- yCaption = GetSystemMetrics(SM_CYCAPTION);
- xVScrollBar = GetSystemMetrics(SM_CXVSCROLL);
- //Actually, it's not good that a width of each column
- // depends on a width of "0"!!
- if (xChar > sChar0.cx) {
- // sChar0.cx = xChar;
- sChar0.cx = sChar0.cx * 12 / 10; //sChar0.cx *= 1.2
- }
- SelectObject(hDC, GetStockObject(SYSTEM_FONT));
- ReleaseDC(hWnd, hDC);
- /* create listbox for client area */
- LoadString (GetModuleHandle (NULL),
- IDS_LISTBOX,
- szWndClass,
- sizeof (szWndClass));
- hList = CreateWindow (szWndClass,
- NULL,
- WS_CHILD | WS_VISIBLE | WS_VSCROLL |
- LBS_EXTENDEDSEL | LBS_NOTIFY | LBS_OWNERDRAWFIXED |
- LBS_WANTKEYBOARDINPUT | LBS_NOINTEGRALHEIGHT,
- 0, 0, 0, 0,
- hWnd,
- (HMENU)IDC_LISTBOX,
- GetModuleHandle (NULL),
- NULL);
- /* if listbox failed, abort app */
- if (!IsWindow (hList))
- DestroyWindow(hWnd);
- SendMessage (hList, WM_SETFONT, (WPARAM)hFontVar, 0L);
- /* create status window for client area */
- LoadString (GetModuleHandle (NULL),
- IDS_STATUSCLASS,
- szWndClass,
- sizeof (szWndClass));
- if (!(hStatus = CreateWindow (szWndClass,
- NULL,
- WS_CHILD | WS_VISIBLE | WS_BORDER,
- 0, 0, 0, 0,
- hWnd,
- (HMENU)IDC_STATUSWND,
- GetModuleHandle (NULL),
- NULL)))
- ReportError (IDS_ERRCREATEWINDOW);
- /* initialize status window */
- SendMessage (GetDlgItem (hWnd, IDC_STATUSWND),
- UM_UPDATE,
- (WPARAM)lpChildProcess,
- 0);
- /* if child process post message to display initialization dialog */
- if (lpChildProcess != NULL)
- PostMessage (hWnd, UM_STARTINITDIALOG, 0, 0);
- /* remove hourglass cursor */
- SetClassLong (hWnd, GCL_HCURSOR, (LONG)hOldCursor);
- SetCursor (hOldCursor);
- }
- break;
- case UM_STARTINITDIALOG:
- /* start modal initializing information window */
- DialogBoxParam (GetModuleHandle (NULL),
- (char *)IDD_INITIALIZING,
- hWnd,
- InitDlgProc,
- (LPARAM)&hInitDlg);
- hInitDlg = NULL;
- break;
- case WM_SETFOCUS:
- /* keep focus in listbox when possible */
- SetFocus (GetDlgItem (hWnd, IDC_LISTBOX));
- break;
- case WM_MEASUREITEM:
- ((MEASUREITEMSTRUCT FAR *)lParam)->itemHeight = sChar0.cy;
- break;
- case WM_DRAWITEM:
- DrawListItem ((DRAWITEMSTRUCT FAR *)lParam);
- break;
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- RECT rc;
- /* draw the caption line above the list box */
- BeginPaint(hWnd, &ps);
- SetRect(&rc, 0, 0, GetSystemMetrics (SM_CXSCREEN), sChar0.cy);
- SelectObject(ps.hdc, hFontVar);
- SetTextColor(ps.hdc, GetSysColor(COLOR_CAPTIONTEXT));
- SetBkColor(ps.hdc, GetSysColor(COLOR_ACTIVECAPTION));
- TextOutFields (ps.hdc, 6, &rc, szCaptionText);
- SelectObject(ps.hdc, GetStockObject(SYSTEM_FONT));
- EndPaint(hWnd, &ps);
- }
- break;
- case WM_SIZE:
- /* size listbox and status bar */
- if ((wParam == SIZE_RESTORED) || (wParam == SIZE_MAXIMIZED))
- {
- int yBorder = GetSystemMetrics (SM_CYBORDER);
- int xBorder = GetSystemMetrics (SM_CXBORDER);
- int yStatus = yChar + 10*yBorder;
- /* size listbox */
- MoveWindow(GetDlgItem (hWnd, IDC_LISTBOX),
- 0,
- sChar0.cy,
- LOWORD(lParam),
- HIWORD(lParam)-(sChar0.cy + yStatus - yBorder),
- TRUE);
- /* size status bar */
- MoveWindow(GetDlgItem (hWnd, IDC_STATUSWND),
- 0-xBorder,
- HIWORD(lParam)-yStatus+yBorder,
- LOWORD(lParam) + 2*xBorder,
- yStatus,
- TRUE);
- }
- break;
- case WM_COMMAND:
- {
- switch (LOWORD (wParam))
- {
- case IDM_EXIT:
- SendMessage (hWnd, WM_CLOSE, 0, 0);
- break;
- case IDM_PROCESSUNLOAD:
- {
- char szFilename[MAX_PATH];
- char szTitle[MAX_PATH];
- HWND hViewWnd = NULL;
- /* close child process */
- CloseChildProcess (lpChildProcess, hChildEvents);
- lpChildProcess = NULL;
- SendMessage (GetDlgItem (hWnd, IDC_LISTBOX), LB_RESETCONTENT, 0, 0);
- SendMessage (GetDlgItem (hWnd, IDC_STATUSWND),
- UM_UPDATE,
- 0,
- 0);
- /* reset caption */
- LoadString (GetModuleHandle (NULL),
- IDS_CAPTION,
- szTitle,
- MAX_PATH);
- LoadString (GetModuleHandle (NULL),
- IDS_SELF,
- szFilename,
- MAX_PATH);
- strcat (szTitle, szFilename);
- SetWindowText (hWnd, szTitle);
- if (IsWindow (hWndSysStat))
- {
- InvalidateRect (hWndSysStat, NULL, TRUE);
- UpdateWindow (hWndSysStat);
- }
- if (IsWindow (hWndProStat))
- DestroyWindow (hWndProStat);
- while ((hViewWnd = EnumViewWindows (hWnd, hViewWnd)) != NULL)
- DestroyWindow (hViewWnd);
- }
- break;
- case IDM_PROCESSLOAD:
- {
- char szTitle[MAX_PATH];
- char szFilePath[MAX_PATH];
- HWND hViewWnd = NULL;
- /* detaching from old process, okay?? */
- if (lpChildProcess != NULL)
- {
- strcpy (szTitle, "Detach from process ");
- strcat (szTitle, lpChildProcess->szModule);
- strcat (szTitle, "?");
- LoadString (GetModuleHandle (NULL),
- IDS_WALKERCLASS,
- szFilePath,
- MAX_PATH);
- if (IDYES != MessageBox (hWnd,
- szTitle,
- szFilePath,
- MB_YESNO | MB_ICONQUESTION))
- break;
- }
- /* call open file dialog to get filename of exe, and validate */
- *szFilePath = 0;
- if (GetFileName (hWnd, szFilePath, NULL))
- {
- if (IsValidFile (szFilePath))
- {
- if (lpChildProcess != NULL)
- {
- /* close any open view windows for this process */
- while ((hViewWnd = EnumViewWindows (hWnd, hViewWnd)) != NULL)
- DestroyWindow (hViewWnd);
- CloseChildProcess (lpChildProcess, hChildEvents);
- SendMessage (GetDlgItem (hWnd, IDC_LISTBOX),
- LB_RESETCONTENT,
- 0,
- 0);
- SendMessage (GetDlgItem (hWnd, IDC_STATUSWND),
- UM_UPDATE,
- 0,
- 0);
- }
- if ((lpChildProcess =
- StartChildProcess (hWnd, szFilePath, hChildEvents)) != NULL)
- {
- /* force rewalk of process */
- PostMessage (hWnd, UM_STARTINITDIALOG, 0, 0);
- SendMessage (GetDlgItem (hWnd, IDC_STATUSWND),
- UM_UPDATE,
- (WPARAM)lpChildProcess,
- 0);
- /* load new window caption */
- LoadString (GetModuleHandle (NULL),
- IDS_CAPTION,
- szTitle,
- MAX_PATH);
- GetFileFromPath (szFilePath, szFilename);
- strcat (szTitle, szFilename);
- SetWindowText (hWnd, szTitle);
- }
- }
- }
- }
- break;
- case IDM_PROCESSREWALK:
- {
- HWND hList = GetDlgItem (hWnd, IDC_LISTBOX);
- int nCnt, nNewCnt, i;
- LPVOID lpNewList=NULL, lpTempList=NULL;
- HWND hViewWnd = NULL;
- /* clear listbox of current contents, but first find out how many exist */
- nCnt = SendMessage (hList, LB_GETCOUNT, 0, 0);
- SendMessage (hList, WM_SETREDRAW, 0, 0);
- SendMessage (hList, LB_RESETCONTENT, 0, 0);
- /* walk process address space */
- if (lpChildProcess != NULL)
- {
- nNewCnt = WalkProcess (lpChildProcess->hProcess, &lpNewList, &Objects);
- AnalyzeProcess (lpChildProcess, (LPVMOBJECT)lpNewList, nNewCnt);
- /* indentify which objects are new */
- if (nCnt)
- IdentifyNewObjects (lpWalkerList, nCnt, lpNewList, nNewCnt);
- /* free old list and update cnt */
- lpTempList = lpWalkerList;
- lpWalkerList = lpNewList;
- VirtualFree (lpTempList, TOTALVMRESERVE, MEM_DECOMMIT);
- VirtualFree (lpTempList, 0, MEM_RELEASE);
- nCnt = nNewCnt;
- }
- for (i=0; i<nCnt; i++)
- SendMessage (hList, LB_ADDSTRING, 0, i);
- /* sort if other than by address is selected */
- if (nSortType != IDM_SORTADDRESS)
- SortList (hList, nSortType);
- /* reenable redraw of listbox */
- SendMessage (hList, WM_SETREDRAW, 1, 0);
- InvalidateRect (hList, NULL, TRUE);
- UpdateWindow (hList);
- /* if any memory view windows, send update message */
- while ((hViewWnd = EnumViewWindows (hWnd, hViewWnd)) != NULL)
- {
- LPMEMVIEW pmv, pmvOld;
- int nAddress, nSize;
- MEMORY_BASIC_INFORMATION mbi;
- char *szCaption;
- /* retrieve view memory range */
- szCaption = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, MAX_PATH);
- GetWindowText (hViewWnd, szCaption, MAX_PATH);
- /* validate range */
- sscanf (strtok (szCaption, "-"), "%8x", &nAddress);
- sscanf (strtok (NULL, "