 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu May 15, 2008 8:45 am Post subject: |
|
|
The refresh button is the concept you want. Create a thread or timer to constantly call the function you use to pull the process list. Send the clear message before updating and such. (Protip: Common sense works well when programming.. >.>)
And no, your example isn't 'correct' for EnumProcesses. EnumProcesses returns the process ids in an array, if you want to display them you need to print them out into a string buffer before sending them to the listbox.
_________________
- Retired. |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu May 15, 2008 8:57 am Post subject: |
|
|
| Wiccaan wrote: | The refresh button is the concept you want. Create a thread or timer to constantly call the function you use to pull the process list. Send the clear message before updating and such. (Protip: Common sense works well when programming.. >.>)
And no, your example isn't 'correct' for EnumProcesses. EnumProcesses returns the process ids in an array, if you want to display them you need to print them out into a string buffer before sending them to the listbox. |
| Code: |
DWORD epProcesses[1024], epByteRet, epNumProcesses;
EnumProcesses(epProcesses, sizeof(epProcesses), epByteRet);
epNumProcesses = epByteRet / sizeof(DWORD);
for(int i = 0; i<epNumProcess; i++) {
char *sepProcesses[epNumProcesses];
sepProcesses[i] = (char*)epProcesses[i];
SendMessage(hList, LB_ADDSTRING, NULL, (LPARAM)sepProcesses[i]);
}
|
Why do I have a feeling that is wrong...
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu May 15, 2008 9:52 am Post subject: |
|
|
Something like this:
| Code: | char szProcId[255] = {0};
sprintf_s( szProcId, 255, "%d", epProcesses[i] );
SendMessage( hList, LB_ADDSTRING, NULL, (LPARAM)szProcId ); |
_________________
- Retired. |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu May 15, 2008 4:02 pm Post subject: |
|
|
| Wiccaan wrote: | Something like this:
| Code: | char szProcId[255] = {0};
sprintf_s( szProcId, 255, "%d", epProcesses[i] );
SendMessage( hList, LB_ADDSTRING, NULL, (LPARAM)szProcId ); |
|
| Code: |
DWORD epProcesses[1024], epByteRet, epNumProcesses;
EnumProcesses(epProcesses, sizeof(epProcesses), epByteRet);
epNumProcesses = epByteRet / sizeof(DWORD);
for(int i = 0; i<epNumProcess; i++) {
char pid[255];
sprintf_s(pid, 255, "%d", epProcesses[i]);
SendMessage(hList, WM_SETTEXT, NULL, (LPARAM)pid);
}
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu May 15, 2008 4:35 pm Post subject: |
|
|
| x0r wrote: | | Wiccaan wrote: | Or instead of including psapi (if you don't want to) you can call ZwQuerySystemInformation yourself with SystemProcessesAndThreadsInformation ( 5 ) to get the same result.
CreateToolhelp32Snapshot also calls ZwQuerySystemInformation as does EnumProcess, so you get the same results basically either way. One function offers more results then the other. |
Without trying to be rude, that's incredibly stupid. You should never use undocumented APIs.
Anyway, a call to CreateToolhelp32Snapshot would take much more time than EnumProcesses and when you throw the process loop into it you're looking at a much slower result. The main point of EmunProcesses is to be much faster than the alternative. |
ZwQuerySystemInformation is documented.
http://msdn.microsoft.com/en-us/library/ms725506(VS.85).aspx
Most if not all the NT API are documented, whether it be through MSDN, or other sites, there are lots of references to learn about them. Calling them just because you think they are undocumented is far from 'stupid' as they can do a lot in the means of hacking.
_________________
- Retired. |
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Thu May 15, 2008 5:00 pm Post subject: |
|
|
| Wiccaan wrote: | | x0r wrote: | | Wiccaan wrote: | Or instead of including psapi (if you don't want to) you can call ZwQuerySystemInformation yourself with SystemProcessesAndThreadsInformation ( 5 ) to get the same result.
CreateToolhelp32Snapshot also calls ZwQuerySystemInformation as does EnumProcess, so you get the same results basically either way. One function offers more results then the other. |
Without trying to be rude, that's incredibly stupid. You should never use undocumented APIs.
Anyway, a call to CreateToolhelp32Snapshot would take much more time than EnumProcesses and when you throw the process loop into it you're looking at a much slower result. The main point of EmunProcesses is to be much faster than the alternative. |
ZwQuerySystemInformation is documented.
http://msdn.microsoft.com/en-us/library/ms725506(VS.85).aspx
Most if not all the NT API are documented, whether it be through MSDN, or other sites, there are lots of references to learn about them. Calling them just because you think they are undocumented is far from 'stupid' as they can do a lot in the means of hacking. |
I think he might be referring to SystemProcessesAndThreadsInformation, I did a quick Google search, and nothing turned up immediately; that might be the reason that I don't see it though--I'm not too interested in seeing it. =P
Anyways, EnumProcesses, in my opinion, just seems like the way to go in this situation.
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu May 15, 2008 5:25 pm Post subject: |
|
|
| Quote: | The ZwQuerySystemInformation function and the structures that it returns are internal to the operating system and subject to change from one release of Windows to another. To maintain the compatibility of your application, it is better to use the alternate functions previously mentioned instead.
If you do use ZwQuerySystemInformation, access the function through run-time dynamic linking. This gives your code an opportunity to respond gracefully if the function has been changed or removed from the operating system. Signature changes, however, may not be detectable.
This function has no associated import library. You must use the LoadLibrary and GetProcAddress functions to dynamically link to Ntdll.dll. |
Just sayin
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri May 16, 2008 7:52 am Post subject: |
|
|
Bickering aside. What about the code. I have everything fine with enumprocesses as long as rewriting goes, and I'm pretty sure I can do the time. But how do I compare the process selected and the one I have. Watch:
| Code: |
void ListProcess() {
DWORD epProcesses[1024], epByteRet, epNumProcesses;
EnumProcesses(epProcesses, sizeof(epProcesses), &epByteRet);
epNumProcesses = epByteRet/sizeof(DWORD);
for(int i = 0; i<epNumProcesses; i++) {
char pid[255];
sprintf_s(pid, 255, "%d", epProcesses[i]);
SendMessage(hList, LB_SETTEXT, NULL, (LPARAM)pid);
}
}
BOOK PK(char *szExe) {
DWORD pkProcesses, pkByteRet, pkNumProcesses;
EnumProcesses(pkProcesses, sizeof(pkProcesses), &pkByteRet);
pkNumProcesses = pkByteRet/sizeof(DWORD);
for(int i = 0; i<pkNumProcesses; i++) {
char PKid[255];
sprintf_s(PKid, 255, "%d", pkProcesses[i]);
if(strcmp(pid, szExe) == 0) {
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, NULL, PKid);
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
return TRUE;
}
return FALSE;
}
}
void GetIndexName() {
char szExe[260];
int index = SendMessage(hList, LB_GETCURSEL, NULL, NULL);
if(index != LB_ERR) {
SendMessage(hList, LB_GETTEXT, (WPARAM)index, (LPARAM)szExe);
PK(szExe);
SendMessage(hList, LB_DELETESTRING, (WPARAM)index, NULL);
}
else {
MessageBox(NULL, "Couldn't kill process!", "Error!", MB_OK | MB_ICONEXCLAMATION);
}
}
|
If you look at the PK function, I just realized that I'm comparing the process id (integer) to the process name (string). How am I supposed to get the process name into a variable?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Fri May 16, 2008 9:11 am Post subject: |
|
|
The heck?
You can't do strcmp if one of the parameters is clearly not a string. You can get a PID from a process name but it isn't foolproof as some processes have the same names, etc.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri May 16, 2008 2:13 pm Post subject: |
|
|
| Zand wrote: | The heck?
You can't do strcmp if one of the parameters is clearly not a string. You can get a PID from a process name but it isn't foolproof as some processes have the same names, etc. |
Technically its numbers stored inside a string.
its as if I did
| Code: |
char pid[] = "1025";
|
But that's not my problem. I need to get the process name, and yea seeing as most of the system processes (as you mentioned) are run more than once (svchost.exe for example) I would get the same pid. Hmmm...seems like CreateToolhelp32Snapshot may be bettere? Oh yeah and can I get the process name like this?
| Code: |
char pname[255];
sprintf_s(pname, 255, "%s", epProcesses[i]);
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|