Skip to content

Commit 2bde184

Browse files
committed
Added process browser to Address Space Monitor. Bumped to version 0.4.
1 parent ac040f7 commit 2bde184

File tree

7 files changed

+103
-16
lines changed

7 files changed

+103
-16
lines changed

Changelog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ Changelog
4444

4545
memmon/memmon.cpp memmon/memmon.rc memmon/mmpainter.cpp memmon/mmpainter.h:
4646
Added snapshot save and load functionality.
47+
48+
2007-08-02 Charles Bailey
49+
memmon/memmon.cpp memmon/memmon.rc memmon/memmon.vcproj:
50+
Added simple process browser.

memmon/memmon.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
#include "mmpainter.h"
77
#include "mmprefs.h"
88

9+
#include <sstream>
910
#include <crtdbg.h>
1011

1112
#define MAX_LOADSTRING 100
1213

14+
using std::wostringstream;
15+
1316
namespace
1417
{
1518
// Global Variables:
@@ -167,26 +170,99 @@ void MyPaint(HDC hdc, PAINTSTRUCT* ps)
167170
}
168171
}
169172

173+
void PopulateProcessList(HWND listBox)
174+
{
175+
DWORD pids[1024];
176+
DWORD pids_ret_size;
177+
178+
if (::EnumProcesses(pids, sizeof pids, &pids_ret_size))
179+
{
180+
HANDLE hProc;
181+
TCHAR procname[1024];
182+
183+
for (size_t i = 0; i < (pids_ret_size / sizeof(DWORD)); ++i)
184+
{
185+
hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pids[i]);
186+
if (hProc != NULL)
187+
{
188+
//::GetProcessImageFileName(hProc, procname, sizeof procname / sizeof(TCHAR));
189+
//::GetModuleFileNameEx(hProc, NULL, procname, sizeof procname / sizeof(TCHAR));
190+
if (::GetModuleBaseName(hProc, NULL, procname, sizeof procname / sizeof(TCHAR)))
191+
{
192+
LRESULT lRes = ::SendMessage( listBox, LB_ADDSTRING, 0, LPARAM(procname) );
193+
if (lRes >= 0)
194+
{
195+
::SendMessage( listBox, LB_SETITEMDATA, lRes, pids[i] );
196+
}
197+
}
198+
else if (::GetProcessImageFileName(hProc, procname, sizeof procname / sizeof(TCHAR)))
199+
{
200+
LRESULT lRes = ::SendMessage( listBox, LB_ADDSTRING, 0, LPARAM(procname) );
201+
if (lRes >= 0)
202+
{
203+
::SendMessage( listBox, LB_SETITEMDATA, lRes, pids[i] );
204+
}
205+
}
206+
207+
}
208+
}
209+
}
210+
}
211+
170212
INT_PTR CALLBACK AttachProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
171213
{
172214
INT_PTR ret = (INT_PTR)FALSE;
173215
switch (message)
174216
{
217+
175218
case WM_COMMAND:
176219
{
177220
_TCHAR tmp[200] = { 0 };
178221
switch (LOWORD(wParam))
179222
{
223+
case IDC_PROCLIST:
224+
switch (HIWORD(wParam))
225+
{
226+
case LBN_SELCHANGE:
227+
{
228+
LRESULT lRes = ::SendMessage(HWND(lParam), LB_GETCURSEL, 0, 0);
229+
230+
if (lRes >= 0)
231+
{
232+
lRes = ::SendMessage(HWND(lParam), LB_GETITEMDATA, lRes, 0);
233+
if (lRes >= 0)
234+
{
235+
wostringstream oss;
236+
oss << lRes;
237+
SetDlgItemText(hwndDlg, IDC_EDIT1, oss.str().c_str());
238+
}
239+
}
240+
}
241+
break;
242+
case LBN_DBLCLK:
243+
::SendMessage(hwndDlg, WM_COMMAND, IDOK, 0);
244+
break;
245+
}
246+
break;
247+
180248
case IDOK:
181249
GetDlgItemText(hwndDlg, IDC_EDIT1, tmp, 200);
182250
pPaint->SetProcessId( _ttoi(tmp) );
251+
// Drop through
183252
case IDCANCEL:
184253
EndDialog(hwndDlg, wParam);
185254
ret = (INT_PTR)TRUE;
186255
}
187256
}
188257
break;
189258
case WM_INITDIALOG:
259+
{
260+
HWND hProcList = ::GetDlgItem(hwndDlg, IDC_PROCLIST);
261+
if (hProcList != NULL)
262+
{
263+
PopulateProcessList(hProcList);
264+
}
265+
}
190266
// Return true to set default focus
191267
ret = (INT_PTR)TRUE;
192268
}

memmon/memmon.rc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,21 @@ CAPTION "About"
8181
FONT 8, "MS Shell Dlg", 0, 0, 0x0
8282
BEGIN
8383
ICON IDI_MEMMON,IDC_MYICON,14,9,20,20
84-
LTEXT "Address Space Monitor Version 0.3a",IDC_STATIC,49,10,119,8,SS_NOPREFIX
84+
LTEXT "Address Space Monitor Version 0.4a",IDC_STATIC,49,10,119,8,SS_NOPREFIX
8585
LTEXT "Copyright (c) 2007 Charles Bailey",IDC_STATIC,49,20,119,8
8686
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
8787
END
8888

89-
IDD_ATTACH_DLOG DIALOGEX 0, 0, 186, 46
89+
IDD_ATTACH_DLOG DIALOGEX 0, 0, 350, 209
9090
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
9191
CAPTION "Attach to process"
9292
FONT 8, "MS Shell Dlg", 400, 0, 0x1
9393
BEGIN
94-
EDITTEXT IDC_EDIT1,7,25,102,14,ES_AUTOHSCROLL | ES_NUMBER
95-
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
96-
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
94+
EDITTEXT IDC_EDIT1,7,20,102,14,ES_AUTOHSCROLL | ES_NUMBER
95+
DEFPUSHBUTTON "OK",IDOK,293,7,50,14
96+
PUSHBUTTON "Cancel",IDCANCEL,293,24,50,14
9797
LTEXT "Process Id:",IDC_STATIC,7,7,37,8
98+
LISTBOX IDC_PROCLIST,7,48,336,154,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
9899
END
99100

100101
IDD_PREFS_DLOG DIALOGEX 0, 0, 186, 177
@@ -153,9 +154,9 @@ BEGIN
153154
IDD_ATTACH_DLOG, DIALOG
154155
BEGIN
155156
LEFTMARGIN, 7
156-
RIGHTMARGIN, 179
157+
RIGHTMARGIN, 343
157158
TOPMARGIN, 7
158-
BOTTOMMARGIN, 39
159+
BOTTOMMARGIN, 202
159160
END
160161

161162
IDD_PREFS_DLOG, DIALOG
@@ -175,8 +176,8 @@ END
175176
//
176177

177178
VS_VERSION_INFO VERSIONINFO
178-
FILEVERSION 0,3,1,0
179-
PRODUCTVERSION 0,3,1,0
179+
FILEVERSION 0,4,1,0
180+
PRODUCTVERSION 0,4,1,0
180181
FILEFLAGSMASK 0x17L
181182
#ifdef _DEBUG
182183
FILEFLAGS 0x1L
@@ -192,12 +193,12 @@ BEGIN
192193
BLOCK "080904b0"
193194
BEGIN
194195
VALUE "FileDescription", "Address Space Monitor exe"
195-
VALUE "FileVersion", "0.3"
196+
VALUE "FileVersion", "0.4"
196197
VALUE "InternalName", "memmon"
197198
VALUE "LegalCopyright", "Copyright (c) 2007 Charles Bailey"
198199
VALUE "OriginalFilename", "memmon.exe"
199200
VALUE "ProductName", "Address Space Monitor"
200-
VALUE "ProductVersion", "0.3"
201+
VALUE "ProductVersion", "0.4"
201202
END
202203
END
203204
BLOCK "VarFileInfo"

memmon/memmon.vcproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
/>
6666
<Tool
6767
Name="VCLinkerTool"
68+
AdditionalDependencies="psapi.lib"
6869
LinkIncremental="2"
6970
GenerateDebugInformation="true"
7071
SubSystem="2"
@@ -143,6 +144,7 @@
143144
/>
144145
<Tool
145146
Name="VCLinkerTool"
147+
AdditionalDependencies="psapi.lib"
146148
LinkIncremental="2"
147149
GenerateDebugInformation="true"
148150
SubSystem="2"
@@ -218,6 +220,7 @@
218220
/>
219221
<Tool
220222
Name="VCLinkerTool"
223+
AdditionalDependencies="psapi.lib"
221224
LinkIncremental="1"
222225
GenerateDebugInformation="true"
223226
SubSystem="2"
@@ -296,6 +299,7 @@
296299
/>
297300
<Tool
298301
Name="VCLinkerTool"
302+
AdditionalDependencies="psapi.lib"
299303
LinkIncremental="1"
300304
GenerateDebugInformation="true"
301305
SubSystem="2"

memmon/resource.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define IDC_EDIT_K 1003
2121
#define IDC_CHECK_CPUCOUNT 1004
2222
#define IDC_CHECK_TOPMOST 1005
23+
#define IDC_PROCLIST 1006
2324
#define ID_FILE_ATTACH 32771
2425
#define ID_Menu 32772
2526
#define IDM_EDIT_PREFERENCES 32773
@@ -35,7 +36,7 @@
3536
#define _APS_NO_MFC 1
3637
#define _APS_NEXT_RESOURCE_VALUE 131
3738
#define _APS_NEXT_COMMAND_VALUE 32779
38-
#define _APS_NEXT_CONTROL_VALUE 1005
39+
#define _APS_NEXT_CONTROL_VALUE 1007
3940
#define _APS_NEXT_SYMED_VALUE 110
4041
#endif
4142
#endif

memmon/stdafx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@
3535

3636

3737
// TODO: reference additional headers your program requires here
38-
#include "shellapi.h"
38+
#include <psapi.h>
39+
#include <shellapi.h>

memtools.iss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33

44
[Setup]
55
AppName=Address Space Monitor
6-
AppVerName=Address Space Monitor 0.3a
6+
AppVerName=Address Space Monitor 0.4a
77
AppPublisher=Charles Bailey
88
AppCopyright=Copyright (c) 2007 Charles Bailey
99
AppPublisherURL=http://www.hashpling.org
1010
AppSupportURL=http://www.hashpling.org
1111
AppUpdatesURL=http://www.hashpling.org
1212
DefaultDirName={pf}\memmon
1313
DefaultGroupName=Address Space Monitor
14-
OutputBaseFilename=asmsetup-0_3
14+
OutputBaseFilename=asmsetup-0_4
1515
OutputDir=installer
1616
Compression=lzma
1717
SolidCompression=yes
1818
PrivilegesRequired=none
1919
ArchitecturesInstallIn64BitMode=x64
2020
LicenseFile=licence.txt
21-
VersionInfoVersion=0.3.1.0
21+
VersionInfoVersion=0.4.1.0
2222

2323
[Languages]
2424
Name: "english"; MessagesFile: "compiler:Default.isl"

0 commit comments

Comments
 (0)