mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
Eric Pouech -
Winelib host process support and Code cleanup. Steven Edwards - Change About box to reflect LGPL license change. svn path=/trunk/; revision=8124
This commit is contained in:
parent
e760b79c60
commit
02b8eb1430
11 changed files with 471 additions and 40 deletions
|
@ -299,8 +299,6 @@ BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
|
|||
|
||||
bHung = FALSE;
|
||||
|
||||
/*IsHungAppWindow = */(IsHungAppWindowProc)(FARPROC)GetProcAddress(GetModuleHandle(_T("USER32.DLL")), _T("IsHungAppWindow"));
|
||||
/*IsHungAppWindow = */ (IsHungAppWindowProc)(FARPROC)GetProcAddress(GetModuleHandle("USER32.DLL"), _T("IsHungAppWindow"));
|
||||
IsHungAppWindow = (IsHungAppWindowProc)(FARPROC)GetProcAddress(GetModuleHandle(_T("USER32.DLL")), "IsHungAppWindow");
|
||||
|
||||
if (IsHungAppWindow)
|
||||
|
@ -369,7 +367,6 @@ void AddOrUpdateHwnd(HWND hWnd, TCHAR *szTitle, HICON hIcon, BOOL bHung)
|
|||
/* It is not already in the list so add it */
|
||||
else
|
||||
{
|
||||
/* pAPLI = new APPLICATION_PAGE_LIST_ITEM; */
|
||||
pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)malloc(sizeof(APPLICATION_PAGE_LIST_ITEM));
|
||||
|
||||
pAPLI->hWnd = hWnd;
|
||||
|
@ -409,7 +406,6 @@ void AddOrUpdateHwnd(HWND hWnd, TCHAR *szTitle, HICON hIcon, BOOL bHung)
|
|||
ImageList_Remove(hImageListSmall, item.iItem);
|
||||
|
||||
ListView_DeleteItem(hApplicationPageListCtrl, item.iItem);
|
||||
/* delete pAPLI; */
|
||||
free(pAPLI);
|
||||
bItemRemoved = TRUE;
|
||||
}
|
||||
|
@ -725,7 +721,6 @@ void ApplicationPage_OnWindowsTileHorizontally(void)
|
|||
}
|
||||
}
|
||||
TileWindows(NULL, MDITILE_HORIZONTAL, NULL, nWndCount, hWndArray);
|
||||
/* delete[] hWndArray; */
|
||||
free(hWndArray);
|
||||
}
|
||||
|
||||
|
@ -737,7 +732,6 @@ void ApplicationPage_OnWindowsTileVertically(void)
|
|||
HWND* hWndArray;
|
||||
int nWndCount;
|
||||
|
||||
/* hWndArray = new HWND[ListView_GetItemCount(hApplicationPageListCtrl)]; */
|
||||
hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
||||
nWndCount = 0;
|
||||
|
||||
|
@ -758,7 +752,6 @@ void ApplicationPage_OnWindowsTileVertically(void)
|
|||
}
|
||||
|
||||
TileWindows(NULL, MDITILE_VERTICAL, NULL, nWndCount, hWndArray);
|
||||
/* delete[] hWndArray; */
|
||||
free(hWndArray);
|
||||
}
|
||||
|
||||
|
@ -812,7 +805,6 @@ void ApplicationPage_OnWindowsCascade(void)
|
|||
HWND* hWndArray;
|
||||
int nWndCount;
|
||||
|
||||
/* hWndArray = new HWND[ListView_GetItemCount(hApplicationPageListCtrl)]; */
|
||||
hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
||||
nWndCount = 0;
|
||||
|
||||
|
@ -831,7 +823,6 @@ void ApplicationPage_OnWindowsCascade(void)
|
|||
}
|
||||
}
|
||||
CascadeWindows(NULL, 0, NULL, nWndCount, hWndArray);
|
||||
/* delete[] hWndArray; */
|
||||
free(hWndArray);
|
||||
}
|
||||
|
||||
|
|
425
reactos/subsys/system/taskmgr/dbgchnl.c
Normal file
425
reactos/subsys/system/taskmgr/dbgchnl.c
Normal file
|
@ -0,0 +1,425 @@
|
|||
/*
|
||||
* ReactOS Task Manager
|
||||
*
|
||||
* dbgchnl.c
|
||||
*
|
||||
* Copyright (C) 2003 - 2004 Eric Pouech
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <winnt.h>
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "procpage.h"
|
||||
#include "perfdata.h"
|
||||
#include "column.h"
|
||||
#include "proclist.h"
|
||||
#include "dbgchnl.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/* TODO:
|
||||
* - the dialog box could be non modal
|
||||
* - in that case,
|
||||
* + could refresh channels from time to time
|
||||
* - get a better UI (replace the 'x' by real tick boxes in list view)
|
||||
* - implement a real solution around the get_symbol hack
|
||||
* - enhance visual feedback: the list is large, and it's hard to get the
|
||||
* right line when clicking on rightmost column (trace for example)
|
||||
* - get rid of printfs (error reporting) and use real message boxes
|
||||
* - include the column width settings in the full column management scheme
|
||||
*/
|
||||
|
||||
BOOL DebugChannelsAreSupported(void)
|
||||
{
|
||||
#ifdef WINE
|
||||
return TRUE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static DWORD get_selected_pid(void)
|
||||
{
|
||||
LVITEM lvitem;
|
||||
ULONG Index;
|
||||
DWORD dwProcessId;
|
||||
|
||||
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
|
||||
{
|
||||
memset(&lvitem, 0, sizeof(LVITEM));
|
||||
|
||||
lvitem.mask = LVIF_STATE;
|
||||
lvitem.stateMask = LVIS_SELECTED;
|
||||
lvitem.iItem = Index;
|
||||
|
||||
ListView_GetItem(hProcessPageListCtrl, &lvitem);
|
||||
|
||||
if (lvitem.state & LVIS_SELECTED)
|
||||
break;
|
||||
}
|
||||
|
||||
dwProcessId = PerfDataGetProcessId(Index);
|
||||
|
||||
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
|
||||
return 0;
|
||||
return dwProcessId;
|
||||
}
|
||||
|
||||
static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* user)
|
||||
{
|
||||
int j;
|
||||
char val[2];
|
||||
LVITEMA lvi;
|
||||
int index;
|
||||
HWND hChannelLV = (HWND)user;
|
||||
|
||||
memset(&lvi, 0, sizeof(lvi));
|
||||
|
||||
lvi.mask = LVIF_TEXT;
|
||||
lvi.pszText = buffer + 1;
|
||||
|
||||
index = ListView_InsertItem(hChannelLV, &lvi);
|
||||
if (index == -1) return 0;
|
||||
|
||||
val[1] = '\0';
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
val[0] = (buffer[0] & (1 << j)) ? 'x' : ' ';
|
||||
ListView_SetItemText(hChannelLV, index, j + 1, val);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct cce_user
|
||||
{
|
||||
const char* name; /* channel to look for */
|
||||
unsigned value, mask; /* how to change channel */
|
||||
unsigned done; /* number of successful changes */
|
||||
unsigned notdone; /* number of unsuccessful changes */
|
||||
};
|
||||
|
||||
/******************************************************************
|
||||
* change_channel_CB
|
||||
*
|
||||
* Callback used for changing a given channel attributes
|
||||
*/
|
||||
static int change_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* pmt)
|
||||
{
|
||||
struct cce_user* user = (struct cce_user*)pmt;
|
||||
|
||||
if (!user->name || !strcmp(buffer + 1, user->name))
|
||||
{
|
||||
buffer[0] = (buffer[0] & ~user->mask) | (user->value & user->mask);
|
||||
if (WriteProcessMemory(hProcess, addr, buffer, 1, NULL))
|
||||
user->done++;
|
||||
else
|
||||
user->notdone++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WINE
|
||||
/******************************************************************
|
||||
* get_symbol
|
||||
*
|
||||
* Here it gets ugly :-(
|
||||
* This is quick hack to get the address of first_dll in a running process
|
||||
* We make the following assumptions:
|
||||
* - libwine (lib) is loaded in all processes at the same address (or
|
||||
* at least at the same address at this process)
|
||||
* - we load the same libwine.so version in this process and in the
|
||||
* examined process
|
||||
* Final address is gotten by: 1/ querying the address of a known exported
|
||||
* symbol out of libwine.so with dlsym, 2/ then querying nm on libwine.so to
|
||||
* get the offset from the data segment of this known symbol and of first_dll,
|
||||
* 3/ computing the actual address of first_dll by adding the result of 1/ and
|
||||
* the delta of 2/.
|
||||
* Ugly, yes, but it somehow works. We should replace that with debughlp
|
||||
* library, that'd be way better. Exporting first_dll from libwine.so would make
|
||||
* this code simpler, but still ugly.
|
||||
*/
|
||||
/* FIXME: we only need those includes for the next function */
|
||||
#include <dlfcn.h> /* for RTLD_LAZY */
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "wine/library.h"
|
||||
|
||||
void* get_symbol(HANDLE hProcess, const char* name, const char* lib)
|
||||
{
|
||||
char buffer[1024];
|
||||
void* h;
|
||||
DWORD addr = 0, tmp = 0;
|
||||
FILE* f;
|
||||
char* env;
|
||||
|
||||
if (!(h = wine_dlopen(lib, RTLD_LAZY, buffer, sizeof(buffer))))
|
||||
{
|
||||
printf("Couldn't load %s (%s)\n", lib, buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env = getenv("LD_LIBRARY_PATH");
|
||||
if (env)
|
||||
{
|
||||
char *next, *ptr;
|
||||
struct stat s;
|
||||
|
||||
for (ptr = env = strdup(env); ptr; ptr = next)
|
||||
{
|
||||
next = strchr(ptr, ':');
|
||||
if (next) *next++ = '\0';
|
||||
sprintf(buffer, "nm %s", ptr);
|
||||
if (buffer[strlen(buffer) - 1] != '/') strcat(buffer, "/");
|
||||
strcat(buffer, lib);
|
||||
if (stat(buffer + 3, &s) == 0) break;
|
||||
}
|
||||
free(env);
|
||||
if (!ptr)
|
||||
{
|
||||
printf("Couldn't find %s in LD_LIBRARY_PATH\n", lib);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!(f = popen(buffer, "r")))
|
||||
{
|
||||
printf("Cannot execute '%s'\n", buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), f))
|
||||
{
|
||||
char *p = buffer + strlen(buffer) - 1;
|
||||
if (p < buffer) continue;
|
||||
if (*p == '\n') *p-- = 0;
|
||||
if (p - buffer < 11) continue;
|
||||
buffer[8] = '\0';
|
||||
if (!strcmp(&buffer[11], name)) addr += strtol(buffer, NULL, 16);
|
||||
if (buffer[9] == 'D' && !tmp && (tmp = (DWORD)wine_dlsym(h, &buffer[11], NULL, 0)) != 0)
|
||||
addr += tmp - strtol(buffer, NULL, 16);
|
||||
}
|
||||
pclose(f);
|
||||
return (char*)addr;
|
||||
}
|
||||
#else
|
||||
void* get_symbol(HANDLE hProcess, const char* name, const char* lib)
|
||||
{
|
||||
printf("get_symbol: not implemented on this platform\n");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct dll_option_layout
|
||||
{
|
||||
void* next;
|
||||
void* prev;
|
||||
char* const* channels;
|
||||
int nb_channels;
|
||||
};
|
||||
|
||||
typedef int (*EnumChannelCB)(HANDLE, void*, char*, void*);
|
||||
|
||||
/******************************************************************
|
||||
* enum_channel
|
||||
*
|
||||
* Enumerates all known channels on process hProcess through callback
|
||||
* ce.
|
||||
*/
|
||||
static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned unique)
|
||||
{
|
||||
struct dll_option_layout dol;
|
||||
int i, j, ret = 1;
|
||||
void* buf_addr;
|
||||
unsigned char buffer[32];
|
||||
void* addr;
|
||||
const char** cache = NULL;
|
||||
unsigned num_cache, used_cache;
|
||||
|
||||
addr = get_symbol(hProcess, "first_dll", "libwine.so");
|
||||
if (!addr) return -1;
|
||||
if (unique)
|
||||
cache = HeapAlloc(GetProcessHeap(), 0, (num_cache = 32) * sizeof(char*));
|
||||
else
|
||||
num_cache = 0;
|
||||
used_cache = 0;
|
||||
|
||||
for (;
|
||||
ret && addr && ReadProcessMemory(hProcess, addr, &dol, sizeof(dol), NULL);
|
||||
addr = dol.next)
|
||||
{
|
||||
for (i = 0; i < dol.nb_channels; i++)
|
||||
{
|
||||
if (ReadProcessMemory(hProcess, (void*)(dol.channels + i), &buf_addr, sizeof(buf_addr), NULL) &&
|
||||
ReadProcessMemory(hProcess, buf_addr, buffer, sizeof(buffer), NULL))
|
||||
{
|
||||
if (unique)
|
||||
{
|
||||
/* since some channels are defined in multiple compilation units,
|
||||
* they will appear several times...
|
||||
* so cache the channel's names we already reported and don't report
|
||||
* them again
|
||||
*/
|
||||
for (j = 0; j < used_cache; j++)
|
||||
if (!strcmp(cache[j], buffer + 1)) break;
|
||||
if (j != used_cache) continue;
|
||||
if (used_cache == num_cache)
|
||||
cache = HeapReAlloc(GetProcessHeap(), 0, cache, (num_cache *= 2) * sizeof(char*));
|
||||
cache[used_cache++] = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(buffer + 1) + 1),
|
||||
buffer + 1);
|
||||
}
|
||||
ret = ce(hProcess, buf_addr, buffer, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unique)
|
||||
{
|
||||
for (j = 0; j < used_cache; j++) HeapFree(GetProcessHeap(), 0, (char*)cache[j]);
|
||||
HeapFree(GetProcessHeap(), 0, cache);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DebugChannels_FillList(HWND hChannelLV)
|
||||
{
|
||||
HANDLE hProcess;
|
||||
|
||||
ListView_DeleteAllItems(hChannelLV);
|
||||
|
||||
hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ, FALSE, get_selected_pid());
|
||||
if (!hProcess) return; /* FIXME messagebox */
|
||||
SendMessage(hChannelLV, WM_SETREDRAW, FALSE, 0);
|
||||
enum_channel(hProcess, list_channel_CB, (void*)hChannelLV, TRUE);
|
||||
SendMessage(hChannelLV, WM_SETREDRAW, TRUE, 0);
|
||||
CloseHandle(hProcess);
|
||||
}
|
||||
|
||||
static void DebugChannels_OnCreate(HWND hwndDlg)
|
||||
{
|
||||
HWND hLV = GetDlgItem(hwndDlg, IDC_DEBUG_CHANNELS_LIST);
|
||||
LVCOLUMN lvc;
|
||||
|
||||
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
||||
lvc.fmt = LVCFMT_LEFT;
|
||||
lvc.pszText = _T("Debug Channel");
|
||||
lvc.cx = 100;
|
||||
ListView_InsertColumn(hLV, 0, &lvc);
|
||||
|
||||
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
||||
lvc.fmt = LVCFMT_CENTER;
|
||||
lvc.pszText = _T("Fixme");
|
||||
lvc.cx = 55;
|
||||
ListView_InsertColumn(hLV, 1, &lvc);
|
||||
|
||||
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
||||
lvc.fmt = LVCFMT_CENTER;
|
||||
lvc.pszText = _T("Err");
|
||||
lvc.cx = 55;
|
||||
ListView_InsertColumn(hLV, 2, &lvc);
|
||||
|
||||
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
||||
lvc.fmt = LVCFMT_CENTER;
|
||||
lvc.pszText = _T("Warn");
|
||||
lvc.cx = 55;
|
||||
ListView_InsertColumn(hLV, 3, &lvc);
|
||||
|
||||
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
|
||||
lvc.fmt = LVCFMT_CENTER;
|
||||
lvc.pszText = _T("Trace");
|
||||
lvc.cx = 55;
|
||||
ListView_InsertColumn(hLV, 4, &lvc);
|
||||
|
||||
DebugChannels_FillList(hLV);
|
||||
}
|
||||
|
||||
static void DebugChannels_OnNotify(HWND hDlg, LPARAM lParam)
|
||||
{
|
||||
NMHDR* nmh = (NMHDR*)lParam;
|
||||
|
||||
switch (nmh->code)
|
||||
{
|
||||
case NM_CLICK:
|
||||
if (nmh->idFrom == IDC_DEBUG_CHANNELS_LIST)
|
||||
{
|
||||
LVHITTESTINFO lhti;
|
||||
HWND hChannelLV;
|
||||
HANDLE hProcess;
|
||||
NMITEMACTIVATE* nmia = (NMITEMACTIVATE*)lParam;
|
||||
|
||||
hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, get_selected_pid());
|
||||
if (!hProcess) return; /* FIXME message box */
|
||||
lhti.pt = nmia->ptAction;
|
||||
hChannelLV = GetDlgItem(hDlg, IDC_DEBUG_CHANNELS_LIST);
|
||||
SendMessage(hChannelLV, LVM_SUBITEMHITTEST, 0, (LPARAM)&lhti);
|
||||
if (nmia->iSubItem >= 1 && nmia->iSubItem <= 4)
|
||||
{
|
||||
TCHAR val[2];
|
||||
TCHAR name[32];
|
||||
unsigned bitmask = 1 << (lhti.iSubItem - 1);
|
||||
struct cce_user user;
|
||||
|
||||
ListView_GetItemText(hChannelLV, lhti.iItem, 0, name, sizeof(name) / sizeof(name[0]));
|
||||
ListView_GetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val, sizeof(val) / sizeof(val[0]));
|
||||
user.name = name;
|
||||
user.value = (val[0] == 'x') ? 0 : bitmask;
|
||||
user.mask = bitmask;
|
||||
user.done = user.notdone = 0;
|
||||
enum_channel(hProcess, change_channel_CB, &user, FALSE);
|
||||
if (user.done)
|
||||
{
|
||||
val[0] ^= ('x' ^ ' ');
|
||||
ListView_SetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val);
|
||||
}
|
||||
if (user.notdone)
|
||||
printf("Some channel instance weren't correctly set\n");
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK DebugChannelsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
DebugChannels_OnCreate(hDlg);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case WM_NOTIFY:
|
||||
DebugChannels_OnNotify(hDlg, lParam);
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ProcessPage_OnDebugChannels(void)
|
||||
{
|
||||
DialogBox(hInst, (LPCTSTR)IDD_DEBUG_CHANNELS_DIALOG, hMainWnd, (DLGPROC)DebugChannelsDlgProc);
|
||||
}
|
2
reactos/subsys/system/taskmgr/dbgchnl.h
Normal file
2
reactos/subsys/system/taskmgr/dbgchnl.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
extern BOOL DebugChannelsAreSupported(void);
|
||||
extern void ProcessPage_OnDebugChannels(void);
|
|
@ -33,13 +33,6 @@
|
|||
#include "graphctl.h"
|
||||
#include "taskmgr.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
|
||||
LONG OldGraphCtrlWndProc;
|
||||
|
||||
static void GraphCtrl_Init(TGraphCtrl* this)
|
||||
|
|
|
@ -25,6 +25,7 @@ TARGET_OBJECTS = \
|
|||
affinity.o \
|
||||
applpage.o \
|
||||
column.o \
|
||||
dbgchnl.o \
|
||||
debug.o \
|
||||
endproc.o \
|
||||
font.o \
|
||||
|
|
|
@ -122,7 +122,6 @@ void PerfDataRefresh(void)
|
|||
return;
|
||||
|
||||
/* Get processor time information */
|
||||
/* SysProcessorTimeInfo = new SYSTEM_PROCESSORTIME_INFO[SystemBasicInfo.bKeNumberProcessors]; */
|
||||
SysProcessorTimeInfo = (PSYSTEM_PROCESSORTIME_INFO)malloc(sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors);
|
||||
status = NtQuerySystemInformation(SystemProcessorTimeInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors, &ulSize);
|
||||
if (status != NO_ERROR)
|
||||
|
@ -136,13 +135,11 @@ void PerfDataRefresh(void)
|
|||
do
|
||||
{
|
||||
BufferSize += 0x10000;
|
||||
/* SysHandleInfoData = new BYTE[BufferSize]; */
|
||||
SysHandleInfoData = (LPBYTE)malloc(BufferSize);
|
||||
|
||||
status = NtQuerySystemInformation(SystemHandleInformation, SysHandleInfoData, BufferSize, &ulSize);
|
||||
|
||||
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
|
||||
/* delete[] SysHandleInfoData; */
|
||||
free(SysHandleInfoData);
|
||||
}
|
||||
|
||||
|
@ -156,13 +153,11 @@ void PerfDataRefresh(void)
|
|||
do
|
||||
{
|
||||
BufferSize += 0x10000;
|
||||
/* pBuffer = new BYTE[BufferSize]; */
|
||||
pBuffer = (LPBYTE)malloc(BufferSize);
|
||||
|
||||
status = NtQuerySystemInformation(SystemProcessInformation, pBuffer, BufferSize, &ulSize);
|
||||
|
||||
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
|
||||
/* delete[] pBuffer; */
|
||||
free(pBuffer);
|
||||
}
|
||||
|
||||
|
@ -184,7 +179,6 @@ void PerfDataRefresh(void)
|
|||
* Save system processor time info
|
||||
*/
|
||||
if (SystemProcessorTimeInfo) {
|
||||
/* delete[] SystemProcessorTimeInfo; */
|
||||
free(SystemProcessorTimeInfo);
|
||||
}
|
||||
SystemProcessorTimeInfo = SysProcessorTimeInfo;
|
||||
|
@ -193,7 +187,6 @@ void PerfDataRefresh(void)
|
|||
* Save system handle info
|
||||
*/
|
||||
memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION));
|
||||
/* delete[] SysHandleInfoData; */
|
||||
free(SysHandleInfoData);
|
||||
|
||||
for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.bKeNumberProcessors; Idx++) {
|
||||
|
@ -239,11 +232,9 @@ void PerfDataRefresh(void)
|
|||
|
||||
/* Now alloc a new PERFDATA array and fill in the data */
|
||||
if (pPerfDataOld) {
|
||||
/* delete[] pPerfDataOld; */
|
||||
free(pPerfDataOld);
|
||||
}
|
||||
pPerfDataOld = pPerfData;
|
||||
/* pPerfData = new PERFDATA[ProcessCount]; */
|
||||
pPerfData = (PPERFDATA)malloc(sizeof(PERFDATA) * ProcessCount);
|
||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
|
||||
for (Idx=0; Idx<ProcessCount; Idx++) {
|
||||
|
@ -329,7 +320,6 @@ int MultiByteToWideChar(
|
|||
pPerfData[Idx].KernelTime.QuadPart = pSPI->KernelTime.QuadPart;
|
||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset);
|
||||
}
|
||||
/* delete[] pBuffer; */
|
||||
free(pBuffer);
|
||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "perfdata.h"
|
||||
#include "column.h"
|
||||
#include "proclist.h"
|
||||
#include "dbgchnl.h"
|
||||
#include <ctype.h>
|
||||
|
||||
HWND hProcessPage; /* Process List Property Page */
|
||||
|
@ -440,6 +441,9 @@ void ProcessPageShowContextMenu(DWORD dwProcessId)
|
|||
|
||||
if (si.dwNumberOfProcessors < 2)
|
||||
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);
|
||||
|
||||
if (!DebugChannelsAreSupported())
|
||||
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_DEBUGCHANNELS, MF_BYCOMMAND);
|
||||
|
||||
switch (dwProcessPriorityClass) {
|
||||
case REALTIME_PRIORITY_CLASS:
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#define IDB_TRAYMASK 150
|
||||
#define IDB_TRAYICON 153
|
||||
#define IDB_FONT 154
|
||||
#define IDD_DEBUG_CHANNELS_DIALOG 155
|
||||
#define IDC_DEBUG_CHANNELS_LIST 156
|
||||
|
||||
#define IDC_ENDTASK 1012
|
||||
#define IDC_SWITCHTO 1013
|
||||
#define IDC_NEWTASK 1014
|
||||
|
@ -176,15 +179,16 @@
|
|||
#define ID_PROCESS_PAGE_SETPRIORITY_NORMAL 32812
|
||||
#define ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL 32813
|
||||
#define ID_PROCESS_PAGE_SETPRIORITY_LOW 32814
|
||||
#define IDS_LICENSE 32815
|
||||
#define ID_PROCESS_PAGE_DEBUGCHANNELS 32815
|
||||
#define IDS_LICENSE 32816
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 155
|
||||
#define _APS_NEXT_COMMAND_VALUE 32815
|
||||
#define _APS_NEXT_RESOURCE_VALUE 157
|
||||
#define _APS_NEXT_COMMAND_VALUE 32817
|
||||
#define _APS_NEXT_CONTROL_VALUE 1048
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "column.h"
|
||||
#include "about.h"
|
||||
#include "trayicon.h"
|
||||
#include "dbgchnl.h"
|
||||
|
||||
#define STATUS_WINDOW 2001
|
||||
|
||||
|
@ -247,6 +248,9 @@ LRESULT CALLBACK TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPAR
|
|||
case ID_PROCESS_PAGE_SETPRIORITY_LOW:
|
||||
ProcessPage_OnSetPriorityLow();
|
||||
break;
|
||||
case ID_PROCESS_PAGE_DEBUGCHANNELS:
|
||||
ProcessPage_OnDebugChannels();
|
||||
break;
|
||||
case ID_HELP_ABOUT:
|
||||
OnAbout();
|
||||
break;
|
||||
|
@ -431,6 +435,7 @@ BOOL OnCreate(HWND hWnd)
|
|||
hProcessPage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PROCESS_PAGE), hTabWnd, (DLGPROC)ProcessPageWndProc);
|
||||
hPerformancePage = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PERFORMANCE_PAGE), hTabWnd, (DLGPROC)PerformancePageWndProc);
|
||||
#endif
|
||||
|
||||
/* Insert tabs */
|
||||
_tcscpy(szTemp, _T("Applications"));
|
||||
memset(&item, 0, sizeof(TCITEM));
|
||||
|
@ -641,7 +646,6 @@ void OnSize( UINT nType, int cx, int cy )
|
|||
cx = (rc.right - rc.left) + nXDifference;
|
||||
cy = (rc.bottom - rc.top) + nYDifference;
|
||||
SetWindowPos(hPerformancePage, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
||||
|
||||
}
|
||||
|
||||
void LoadSettings(void)
|
||||
|
|
|
@ -171,6 +171,7 @@ BEGIN
|
|||
|
||||
END
|
||||
MENUITEM "Set &Affinity...", ID_PROCESS_PAGE_SETAFFINITY
|
||||
MENUITEM "Edit Debug &Channels...", ID_PROCESS_PAGE_DEBUGCHANNELS
|
||||
END
|
||||
END
|
||||
|
||||
|
@ -278,7 +279,7 @@ BEGIN
|
|||
GROUPBOX "CPU Usage History",IDC_CPU_USAGE_HISTORY_FRAME,74,5,168,54,0,WS_EX_TRANSPARENT
|
||||
GROUPBOX "Memory Usage History",IDC_MEMORY_USAGE_HISTORY_FRAME,74,63,168,54,0,WS_EX_TRANSPARENT
|
||||
PUSHBUTTON "CPU Usage Display",IDC_CPU_USAGE_GRAPH,12,17,47,37,0,
|
||||
WS_EX_CLIENTEDGE
|
||||
WS_EX_CLIENTEDGE
|
||||
PUSHBUTTON "MEM Usage Display",IDC_MEM_USAGE_GRAPH,12,75,47,37,0,
|
||||
WS_EX_CLIENTEDGE
|
||||
PUSHBUTTON "CPU Usage History",IDC_CPU_USAGE_HISTORY_GRAPH,81,17,
|
||||
|
@ -287,6 +288,17 @@ BEGIN
|
|||
153,37,0,WS_EX_CLIENTEDGE
|
||||
END
|
||||
|
||||
IDD_DEBUG_CHANNELS_DIALOG DIALOG DISCARDABLE 0, 0, 247, 210
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Debug Channels"
|
||||
FONT 8, "Tahoma"
|
||||
BEGIN
|
||||
CONTROL "List2",IDC_DEBUG_CHANNELS_LIST,"SysListView32",LVS_REPORT |
|
||||
LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP |
|
||||
LVS_SORTASCENDING,7,7,233,177
|
||||
PUSHBUTTON "Close",IDOK,171,189,69,14
|
||||
END
|
||||
|
||||
IDD_AFFINITY_DIALOG DIALOG DISCARDABLE 0, 0, 231, 154
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Processor Affinity"
|
||||
|
@ -537,6 +549,11 @@ BEGIN
|
|||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#ifdef WINE
|
||||
#define res_dir .
|
||||
#else
|
||||
#define res_dir res
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -546,7 +563,7 @@ END
|
|||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
/* BINRES taskmgr.ico */
|
||||
IDI_TASKMANAGER ICON DISCARDABLE res/taskmgr.ico
|
||||
IDI_TASKMANAGER ICON DISCARDABLE res_dir/taskmgr.ico
|
||||
/* {
|
||||
'00 00 01 00 02 00 20 20 10 00 00 00 00 00 E8 02'
|
||||
'00 00 26 00 00 00 10 10 10 00 00 00 00 00 28 01'
|
||||
|
@ -619,7 +636,7 @@ IDI_TASKMANAGER ICON DISCARDABLE res/taskmgr.ico
|
|||
} */
|
||||
|
||||
/* BINRES window.ico */
|
||||
IDI_WINDOW ICON DISCARDABLE res/window.ico
|
||||
IDI_WINDOW ICON DISCARDABLE res_dir/window.ico
|
||||
/* {
|
||||
'00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
|
||||
'00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00'
|
||||
|
@ -672,7 +689,7 @@ IDI_WINDOW ICON DISCARDABLE res/window.ico
|
|||
} */
|
||||
|
||||
/* BINRES windowsm.ico */
|
||||
IDI_WINDOWSM ICON DISCARDABLE res/windowsm.ico
|
||||
IDI_WINDOWSM ICON DISCARDABLE res_dir/windowsm.ico
|
||||
/* {
|
||||
'00 00 01 00 01 00 10 10 10 00 00 00 00 00 28 01'
|
||||
'00 00 16 00 00 00 28 00 00 00 10 00 00 00 20 00'
|
||||
|
@ -743,7 +760,7 @@ END
|
|||
// Bitmap
|
||||
//
|
||||
/* BINRES traymask.bmp */
|
||||
IDB_TRAYMASK BITMAP DISCARDABLE res/traymask.bmp
|
||||
IDB_TRAYMASK BITMAP DISCARDABLE res_dir/traymask.bmp
|
||||
/* {
|
||||
'42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00'
|
||||
'00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00'
|
||||
|
@ -764,7 +781,7 @@ IDB_TRAYMASK BITMAP DISCARDABLE res/traymask.bmp
|
|||
} */
|
||||
|
||||
/* BINRES trayicon.bmp */
|
||||
IDB_TRAYICON BITMAP DISCARDABLE res/trayicon.bmp
|
||||
IDB_TRAYICON BITMAP DISCARDABLE res_dir/trayicon.bmp
|
||||
/* {
|
||||
'42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00'
|
||||
'00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00'
|
||||
|
@ -785,7 +802,7 @@ IDB_TRAYICON BITMAP DISCARDABLE res/trayicon.bmp
|
|||
} */
|
||||
|
||||
/* BINRES font.bmp */
|
||||
IDB_FONT BITMAP DISCARDABLE res/font.bmp
|
||||
IDB_FONT BITMAP DISCARDABLE res_dir/font.bmp
|
||||
/* {
|
||||
'42 4D 86 02 00 00 00 00 00 00 76 00 00 00 28 00'
|
||||
'00 00 60 00 00 00 0B 00 00 00 01 00 04 00 00 00'
|
||||
|
@ -902,7 +919,7 @@ BEGIN
|
|||
ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL
|
||||
"Sets process to the BELOW NORMAL priority class"
|
||||
ID_PROCESS_PAGE_SETPRIORITY_LOW "Sets process to the LOW priority class"
|
||||
IDS_LICENSE "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
|
||||
IDS_LICENSE "This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.\r\n\r\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
|
|
|
@ -163,7 +163,7 @@ BOOL TrayIcon_ShellAddTrayIcon(void)
|
|||
bRetVal = Shell_NotifyIcon(NIM_ADD, &nid);
|
||||
|
||||
if (hIcon)
|
||||
DeleteObject(hIcon);
|
||||
DestroyIcon(hIcon);
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ BOOL TrayIcon_ShellUpdateTrayIcon(void)
|
|||
bRetVal = Shell_NotifyIcon(NIM_MODIFY, &nid);
|
||||
|
||||
if (hIcon)
|
||||
DeleteObject(hIcon);
|
||||
DestroyIcon(hIcon);
|
||||
|
||||
return bRetVal;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue