Hi,
I am currently working on a program that will open running processes (for example a running program) for editing and searching. I was wondering how I would list all of the running processes in a seperate window (not the main window) then make them selectable for opening. Any help is appreciated.
Regards,
RIF
I am currently working on a program that will open running processes (for example a running program) for editing and searching. I was wondering how I would list all of the running processes in a seperate window (not the main window) then make them selectable for opening. Any help is appreciated.
Regards,
RIF
If you are running under win9x this may help you, but under winNT, 2000, XP you'll have to use EnumProcesses Api.
-- --------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------
;-------- Shows how to use CreateToolhelp32Snapshot to list processes (Win9x only) ---------
;-------------------------------------------------------------------------------------------
.386
.model flat, stdcall
option casemap:none
include c:\masm32\include\windows.inc
;include c:\masm32\include\masm32.inc
include c:\MASM32\INCLUDE\masm32.inc
include c:\MASM32\INCLUDE\user32.inc
include c:\MASM32\INCLUDE\kernel32.inc
includelib c:\MASM32\LIB\masm32.lib
includelib c:\MASM32\LIB\user32.lib
includelib c:\MASM32\LIB\kernel32.lib
;includelib c:\masm32\lib\masm32.lib
.data
Err db "Erreur !",0
PE PROCESSENTRY32 <>
.data?
processId dd ?
hSnapshot dd ?
.code
start:
invoke CreateToolhelp32Snapshot, TH32CS_SNAPPROCESS,0
cmp eax,-1
jz err_exit
mov hSnapshot,eax
mov PE.dwSize,SIZEOF PE
invoke Process32First, hSnapshot, addr PE
test eax,eax
jz err_exit
Rblot:
invoke MessageBox,0, addr PE.szExeFile, 0, 0
invoke Process32Next, hSnapshot, addr PE
test eax,eax
jne Rblot
invoke ExitProcess,NULL ; Exits ok, it means all processes were enumerates
err_exit:
invoke MessageBox,0, addr Err ,0, MB_OK
invoke ExitProcess,-1
end start
-- --------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------
;-------- Shows how to use CreateToolhelp32Snapshot to list processes (Win9x only) ---------
;-------------------------------------------------------------------------------------------
.386
.model flat, stdcall
option casemap:none
include c:\masm32\include\windows.inc
;include c:\masm32\include\masm32.inc
include c:\MASM32\INCLUDE\masm32.inc
include c:\MASM32\INCLUDE\user32.inc
include c:\MASM32\INCLUDE\kernel32.inc
includelib c:\MASM32\LIB\masm32.lib
includelib c:\MASM32\LIB\user32.lib
includelib c:\MASM32\LIB\kernel32.lib
;includelib c:\masm32\lib\masm32.lib
.data
Err db "Erreur !",0
PE PROCESSENTRY32 <>
.data?
processId dd ?
hSnapshot dd ?
.code
start:
invoke CreateToolhelp32Snapshot, TH32CS_SNAPPROCESS,0
cmp eax,-1
jz err_exit
mov hSnapshot,eax
mov PE.dwSize,SIZEOF PE
invoke Process32First, hSnapshot, addr PE
test eax,eax
jz err_exit
Rblot:
invoke MessageBox,0, addr PE.szExeFile, 0, 0
invoke Process32Next, hSnapshot, addr PE
test eax,eax
jne Rblot
invoke ExitProcess,NULL ; Exits ok, it means all processes were enumerates
err_exit:
invoke MessageBox,0, addr Err ,0, MB_OK
invoke ExitProcess,-1
end start
Where would I place the EnumProcesses Api at in this example?
As far as I know EnumProcesses is just giving you the process Identifiers but you will probably want to display that processes window title and maybe some other information. So I sugest creating a proc wich calls EnumProcesses and gets any info about them you need.
what exactly does enumprocesses do and what is its syntax?
That information can be found here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/psapi_5kqb.asp
it is just giving you the Process id numbers of all running processes at the time you call it.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/psapi_5kqb.asp
it is just giving you the Process id numbers of all running processes at the time you call it.
Look up Toolhelp32 and/or PSAPI and read for yourself before
asking more questions. And don't go use this for anything naughty,
or your post will probably magically disappear :].
asking more questions. And don't go use this for anything naughty,
or your post will probably magically disappear :].
why dont you use createprocess or findwindow for your "trainer" or whatever you want to call it, and while youre at it you may want to download win32.hlp.
there is a trillion examples of read and write processmemory all over the web.
either you are completely new to programming in which case i suggest you start with something simple (MessageBoxA)
or you have a severe case of dyslexia.
http://www.google.com/search?q=win32asm+writeprocessmemory&hl=sv&lr=
returns 8 hits, all which appear to be very relevant to what youre doing.
http://www.google.com/search?hl=sv&q=win32asm+findwindow&lr=
returns 9 hits, and might also be something for you to look at.
there is a trillion examples of read and write processmemory all over the web.
either you are completely new to programming in which case i suggest you start with something simple (MessageBoxA)
or you have a severe case of dyslexia.
http://www.google.com/search?q=win32asm+writeprocessmemory&hl=sv&lr=
returns 8 hits, all which appear to be very relevant to what youre doing.
http://www.google.com/search?hl=sv&q=win32asm+findwindow&lr=
returns 9 hits, and might also be something for you to look at.
Okay first of all I have already tried looking up enumprocess in MY api reference and there is nothing about it. Second, this isnt for a trainer. I dont even work on those anymore. Tired what you need to do is quit being lazy and get a username instead of typing tired all of the time. Since I AM a newbie, I am trying to program a few easy programs so I can practice at what I am learning. And I already know how to program windows and make message boxes etc. That is easy stuff. What I want to do is list all running processes in a window but i dont know how to LIST THE PROCESSES!! All i know how to do is make the window. Also toolhelp32 does not work in xp and i have xp. What i suggest tired, is you read the question that people ask instead of jumping to conclusions. How do you know if i have win32.hlp or not? I had it as soon as i started programming! Oh and I remember hearing something about these forums being for help?? Maybe its just me who knows..
Also toolhelp32 does not work in xp and i have xp.
XP is based on the NT kernel, that is why you don't have that dll.
Here is what you need to do:
- check whether user is running Win9x/Me or NT/2K/XP
- if it is the Win9x combo, use the process snapshot as previously detailed
- if it is the NT combo, use EnumProcesses.
There must be a billion examples out there on using these two techniques. I would suggest you avoid the C++ ones, they tend to be a little cryptic, instead check out the VB sources, they could be a lot easier to read and translate.