2016-11-09 20:39:39 +01:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// DATA //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
#define T_WINDOW_TITLE "Process Manager"
|
|
|
|
#define T_SHOW_SYSTEM_PROCESSES "Show system"
|
|
|
|
#define T_DETAILS "Details"
|
|
|
|
#define T_END_PROCESS "End process"
|
|
|
|
|
2019-03-18 23:31:13 +01:00
|
|
|
#define BOTPANEL_H 36
|
2016-11-09 20:39:39 +01:00
|
|
|
|
|
|
|
enum {
|
2019-03-18 23:31:13 +01:00
|
|
|
BTN_ID_SHOW_SYSTEM_PROCESSES=200,
|
2016-11-09 20:39:39 +01:00
|
|
|
BTN_ID_KILL_PROCESS,
|
|
|
|
BTN_ID_SHOW_PROCESS_INFO
|
|
|
|
};
|
|
|
|
|
|
|
|
int current_process_id = 0;
|
|
|
|
unsigned maxcpu;
|
|
|
|
int proc_list[256];
|
|
|
|
|
2018-04-19 22:12:07 +02:00
|
|
|
checkbox show_system = { T_SHOW_SYSTEM_PROCESSES, false };
|
|
|
|
|
2016-11-09 20:39:39 +01:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// CODE //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
2019-03-18 23:31:13 +01:00
|
|
|
void Processes__Main()
|
2016-11-09 20:39:39 +01:00
|
|
|
{
|
2018-04-19 22:12:07 +02:00
|
|
|
int btn;
|
2018-04-16 00:44:36 +02:00
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
2018-09-13 22:33:53 +02:00
|
|
|
maxcpu = GetCpuFrequency();
|
2019-03-18 23:31:13 +01:00
|
|
|
goto _PROCESS_REDRAW;
|
2016-11-09 20:39:39 +01:00
|
|
|
loop()
|
|
|
|
{
|
|
|
|
WaitEventTimeout(50);
|
|
|
|
switch(EAX & 0xFF)
|
|
|
|
{
|
|
|
|
case evMouse:
|
|
|
|
SelectList_ProcessMouse();
|
|
|
|
break;
|
|
|
|
case evKey:
|
|
|
|
GetKeys();
|
|
|
|
if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
|
|
|
|
break;
|
|
|
|
case evButton:
|
|
|
|
btn = GetButtonID();
|
2019-03-18 23:31:13 +01:00
|
|
|
Sysmon__ButtonEvent(btn);
|
|
|
|
|
2018-04-19 22:12:07 +02:00
|
|
|
if (show_system.click(btn))
|
|
|
|
{
|
2016-11-09 20:39:39 +01:00
|
|
|
SelectList_LineChanged();
|
|
|
|
}
|
|
|
|
if (BTN_ID_KILL_PROCESS == btn)
|
|
|
|
{
|
|
|
|
KillProcess(current_process_id);
|
|
|
|
pause(10);
|
|
|
|
SelectList_LineChanged();
|
|
|
|
}
|
|
|
|
if (BTN_ID_SHOW_PROCESS_INFO == btn)
|
|
|
|
{
|
|
|
|
io.run("/sys/tinfo", itoa(GetProcessSlot(current_process_id)));
|
|
|
|
}
|
|
|
|
break;
|
2019-03-18 23:31:13 +01:00
|
|
|
case evReDraw:
|
|
|
|
_PROCESS_REDRAW:
|
|
|
|
if (!Sysmon__DefineAndDrawWindow()) break;
|
|
|
|
|
|
|
|
SelectList_Init(WIN_PAD, WIN_CONTENT_Y,
|
|
|
|
WIN_CONTENT_W-scroll1.size_x,
|
|
|
|
WIN_CONTENT_H-BOTPANEL_H-TAB_HEIGHT, false);
|
2016-11-09 20:39:39 +01:00
|
|
|
SelectList_DrawBorder();
|
2019-03-18 23:31:13 +01:00
|
|
|
|
2020-04-18 01:52:24 +02:00
|
|
|
//DrawWideRectangle(0, 0, Form.cwidth, Form.cheight, 4, sc.work);
|
2016-11-09 20:39:39 +01:00
|
|
|
DrawBar(select_list.x-2, select_list.y+select_list.h+2,
|
2020-04-18 01:52:24 +02:00
|
|
|
select_list.w+scroll1.size_x+4, BOTPANEL_H, sc.work);
|
2019-03-18 23:31:13 +01:00
|
|
|
DrawCaptButton(Form.cwidth-110-WIN_PAD,
|
2016-11-09 20:39:39 +01:00
|
|
|
select_list.y+select_list.h+5,
|
|
|
|
110,25,BTN_ID_KILL_PROCESS,0xF38181, 0xFFFfff, T_END_PROCESS);
|
2019-03-18 23:31:13 +01:00
|
|
|
DrawCaptButton(Form.cwidth-230-WIN_PAD,
|
2016-11-09 20:39:39 +01:00
|
|
|
select_list.y+select_list.h+5,
|
|
|
|
110,25,BTN_ID_SHOW_PROCESS_INFO,
|
2020-04-18 01:52:24 +02:00
|
|
|
sc.button, sc.button_text, T_DETAILS);
|
2018-04-19 22:12:07 +02:00
|
|
|
show_system.draw(select_list.x + 3, select_list.y+select_list.h+10);
|
2016-11-09 20:39:39 +01:00
|
|
|
default:
|
|
|
|
SelectList_LineChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 23:31:13 +01:00
|
|
|
void Processes__GetProcessList()
|
2016-11-09 20:39:39 +01:00
|
|
|
{
|
|
|
|
int i, j;
|
2019-03-18 23:31:13 +01:00
|
|
|
proc_info Process;
|
|
|
|
|
2016-11-09 20:39:39 +01:00
|
|
|
select_list.count=0;
|
2016-11-14 01:42:32 +01:00
|
|
|
for (i=0; i<MAX_PROCESS_COUNT; i++)
|
2016-11-09 20:39:39 +01:00
|
|
|
{
|
|
|
|
GetProcessInfo(#Process, i);
|
|
|
|
if (Process.name)
|
|
|
|
{
|
|
|
|
for (j=0; j<11; j++) if (Process.name[j]!=' ') {
|
2018-04-19 22:12:07 +02:00
|
|
|
if (show_system.checked==false) {
|
2016-11-09 20:39:39 +01:00
|
|
|
//do not show system process
|
|
|
|
if (Process.name[0]=='@') break;
|
|
|
|
if (!strcmp(#Process.name, "IDLE")) break;
|
|
|
|
if (!strcmp(#Process.name, "OS")) break;
|
|
|
|
}
|
|
|
|
proc_list[select_list.count] = i;
|
|
|
|
select_list.count++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SelectList_DrawLine(dword i)
|
|
|
|
{
|
|
|
|
int posy;
|
|
|
|
char cpu_use[16];
|
|
|
|
dword bg_color;
|
2019-03-18 23:31:13 +01:00
|
|
|
proc_info Process;
|
|
|
|
|
2016-11-09 20:39:39 +01:00
|
|
|
GetProcessInfo(#Process, proc_list[i+select_list.first]);
|
|
|
|
|
|
|
|
posy = i *select_list.item_h + select_list.y;
|
|
|
|
if (i % 2) bg_color = 0xFFFfff; else bg_color = 0xF0F0F0;
|
|
|
|
if (i+select_list.first == select_list.cur_y) {
|
|
|
|
current_process_id = Process.ID;
|
|
|
|
bg_color = 0x67CCEB;
|
|
|
|
}
|
|
|
|
DrawBar(select_list.x, posy, select_list.w, select_list.item_h, bg_color);
|
|
|
|
WriteText(select_list.x+005, posy+select_list.text_y, select_list.font_type, 0, #Process.name);
|
|
|
|
WriteText(select_list.w/10*5+select_list.x, posy+select_list.text_y, select_list.font_type, 0x444444, ConvertSizeToKb(Process.use_memory));
|
|
|
|
sprintf(#cpu_use, "%i %%", Process.use_cpu*100/maxcpu);
|
|
|
|
if (maxcpu) WriteText(select_list.w/10*8+select_list.x - calc(strlen(#cpu_use)-4*8),
|
|
|
|
posy+select_list.text_y, select_list.font_type, 0x444444, #cpu_use);
|
|
|
|
}
|
|
|
|
|
2019-03-18 23:31:13 +01:00
|
|
|
void SelectList_LineChanged()
|
|
|
|
{
|
|
|
|
Processes__GetProcessList();
|
|
|
|
SelectList_Draw();
|
|
|
|
}
|