Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trigger: Process
#1
function: process_watcher
trigger: $p 0x7 ""
Code:
Copy      Help
function event pid pidparent $name
;event: 1 started, 2 ended, 4 running
sel event
,case 1
,
,case 2
,
,case 3

how much can i do with that ?
how reliable/stable is it ?

--
can it auto kill process when IsHungWindow ?
can it end a process when ram usage is higher then n mb ?
pi
#2
It is reliable and stable. On Vista does not work for some processes if QM is not as admin. But it is probably because ShutDownProcess does not have enough privileges, not because the trigger woul not work.

pid can be passed to ShutDownProcess.

I used that to kill that annoying Vista processes that start while I am working and eat computer resources.

Quote:can it auto kill process when IsHungWindow ?
can it end a process when ram usage is higher then n mb ?

No, unless then starts some process.
#3
process_watcher
Code:
Copy      Help
function event pid pidparent $name
;event: 1 started, 2 ended, 4 running
str exe_name
sel event
,case 1
,,out pid
,,_s=PidToExename(pid exe_name 1)
,,out _s
,case 2
,
,case 3

i must be blind, why does _s not show the exe path ?
i get always 0.
pi
#4
PidToExename does not return a string.
#5
how to make it return the exe name or path as string ?
that would allow me to use

sel pid2exe(pid) 1
case "firefox"
pi
#6
function'str arguments
...
ret local str var


But it is dangerous. When you assign the function to a str variable, then OK. But if you assign it to a lpstr variable or function argument, the lpstr will be invalid. Same with sel.

Or can be

function'lpstr arguments
...
ret thread-local str variable

Then you can assign it to str, lpstr, sel, etc. The string becomes invalid when the thread exits or the function called again, but it is usually already not used then.

For these reasons it is better to use str& argument instead.
#7
i try and try ...

please show me how you would transform PidToExename to pid2exe,
so that it can be used for sel.

thanks
:oops: :oops: :oops:
pi
#8
The best way - use str member function that returns lpstr of itself. Forgot that yesterday.

Member function str.PidToExename
Code:
Copy      Help
;/
function$ pid [flags] ;;flags: 1 full

;Gets program name from process id.

;EXAMPLE
;int pid
;if(!GetWindowThreadProcessId(win("" "Shell_TrayWnd") &pid)) ret
;out _s.PidToExename(pid 1)



#if _winnt

int hp hm i
this.len=0
hp=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ 0 pid); if(!hp) ret
if(EnumProcessModules(hp &hm 4 &i))
,this.all(MAX_PATH)
,if(flags&1) this.fix(GetModuleFileNameEx(hp hm this MAX_PATH))
,else this.fix(GetModuleBaseName(hp hm this MAX_PATH)); if(this.endi(".exe")) this.fix(this.len-4)
CloseHandle(hp)
ret this

#endif


Forum Jump:


Users browsing this thread: 1 Guest(s)