| View previous topic :: View next topic |
| Author |
Message |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Sun May 20, 2007 2:16 pm Post subject: Info of a process... |
|
|
O well its me again... I'm using this simple code | Code: | #include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <string>
using namespace std;
int main( )
{
cout<<endl<<"Running Processes"<<endl;
HANDLE WINAPI CreateToolhelp32Snapshot(
DWORD dwFlags,
DWORD th32ProcessID
);
HANDLE hSnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
BOOL WINAPI Process32Next(
HANDLE hSnapshot,
LPPROCESSENTRY32 lppe
);
PROCESSENTRY32* processInfo=new PROCESSENTRY32;
processInfo->dwSize=sizeof(PROCESSENTRY32);
int index=0;
while(Process32Next(hSnapShot,processInfo)!=FALSE)
{
cout<<endl<<"***********************************************";
cout<<endl<<"\t\t\t"<<++index;
cout<<endl<<"***********************************************";
cout<<endl<<"Process ID: "<<processInfo->th32ProcessID;
cout<<endl<<"Name: "<<processInfo->szExeFile;
}
CloseHandle(hSnapShot);
cout<<endl;
cout<<endl<<"***********************************************";
cout<<endl<<endl;
//HANDLE OpenProcess(
// DWORD dwDesiredAccess,
// BOOL bInheritHandle,
// DWORD dwProcessId
// );
int processID;
cout<<"Enter ProcessID to get handle of the process: ";
cin>>processID;
HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,TRUE,processID);
if(hProcess==NULL)
{
cout<<"Unable to get handle of process: "<<processID;
cout<<"Error is: "<<GetLastError();
return 1;
}
cout<<endl<<"Priority Class: "<<GetPriorityClass(hProcess);
SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS);
CloseHandle(hProcess);
cout<<endl<<"Enter Process ID to terminate that process: ";
cin>>processID;
hProcess=OpenProcess(PROCESS_ALL_ACCESS,TRUE,processID);
if(hProcess==NULL)
{
cout<<"Unable to get handle of process: "<<processID;
cout<<"Error is: "<<GetLastError();
}
TerminateProcess(hProcess,0);
delete processInfo;
return 0;
} |
To enumerate every process running. So here I have 2 questions:
1- How can I modify the code so it filters the processes and gives me the info on a specific process? In my case it MS... And I know that it hides at the start but if I run it fast I can still get the PID.
2- Heres the interesting part (at least for me) I'm not trying to edit MS memory... all I want is to close it A lot of methods doesn't work: SendMessage, EndTask and more. But TerminateProcess does, I know his because theres this program called Advanced Process Termination and it uses a lot of techniques=> http://www.diamondcs.com.au/index.php?page=process-termination-methods
and 1 of those is TerminateProcess. HERES THE QUESTION, to use TerminateProcess you must have the process handle, to get it you must use OpenProcess but since gameguard wont let you, how come the program is able to do it? They even have a fonction, you only tell the PID and it will terminate! I would like to know how to do this. SO I can finally finish my project.
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun May 20, 2007 3:04 pm Post subject: |
|
|
1) Function I use. Took it out of my injector.
| Code: | DWORD GetProcessID(char* strProcessName)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE)
return FALSE;
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if(Process32First(hProcessSnap, &pe32) == 0)
{
CloseHandle(hProcessSnap);
return FALSE;
}
else
{
do
{
if(stricmp(pe32.szExeFile, strProcessName) == 0)
{
CloseHandle(hProcessSnap);
return pe32.th32ProcessID;
}
} while(Process32Next(hProcessSnap, &pe32));
}
}
CloseHandle(hProcessSnap);
return FALSE;
} |
2) As for OpenProcess() - Just do it before gameguard has loaded but maplestory.exe is visible in the process list. Save the HANDLE for later.
|
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Sun May 20, 2007 4:18 pm Post subject: |
|
|
Flyte, Thanks a lot! But I just can't get it I read your code many times, but I don't get it. Where do I specify what process I'm looking for?
And for the OpenProcess, that's what I thought but when I tried it didn't work, must of messed up somewhere... Going to try again.
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun May 20, 2007 4:22 pm Post subject: |
|
|
| zomgiownyou wrote: | Flyte, Thanks a lot! But I just can't get it I read your code many times, but I don't get it. Where do I specify what process I'm looking for?
And for the OpenProcess, that's what I thought but when I tried it didn't work, must of messed up somewhere... Going to try again. |
It is a function. Just give it the pointer to a defined/char string. Or just put the string in it.
| Code: | | DWORD pID = GetProcessID("MapleStory.exe"); |
|
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Sun May 20, 2007 4:35 pm Post subject: |
|
|
I see well I compiled | Code: |
DWORD pID = GetProcessID("MapleStory.exe");
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE)
return FALSE;
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if(Process32First(hProcessSnap, &pe32) == 0)
{
CloseHandle(hProcessSnap);
return FALSE;
}
else
{
do
{
if(stricmp(pe32.szExeFile, "MapleStory") == 0)
{
CloseHandle(hProcessSnap);
return pe32.th32ProcessID;
}
} while(Process32Next(hProcessSnap, &pe32));
}
}
CloseHandle(hProcessSnap);
return FALSE;
} |
And I got "error C2065: 'GetProcessID' : undeclared identifier"
Looked in MSDN and everything seems alright.
_________________
|
|
| Back to top |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Sun May 20, 2007 4:51 pm Post subject: |
|
|
| zomgiownyou wrote: | I see well I compiled
And I got "error C2065: 'GetProcessID' : undeclared identifier"
Looked in MSDN and everything seems alright. |
First declare the function, then call it. Ex:
| Code: |
int inc (int n){
return n+1;
}
int main (){
int a = 0;
a = inc (a);
return 0;
}
|
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Last edited by DeltaFlyer on Sun May 20, 2007 4:52 pm; edited 2 times in total |
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun May 20, 2007 4:51 pm Post subject: |
|
|
| zomgiownyou wrote: | I see well I compiled | Code: |
DWORD pID = GetProcessID("MapleStory.exe");
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE)
return FALSE;
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if(Process32First(hProcessSnap, &pe32) == 0)
{
CloseHandle(hProcessSnap);
return FALSE;
}
else
{
do
{
if(stricmp(pe32.szExeFile, "MapleStory") == 0)
{
CloseHandle(hProcessSnap);
return pe32.th32ProcessID;
}
} while(Process32Next(hProcessSnap, &pe32));
}
}
CloseHandle(hProcessSnap);
return FALSE;
} |
And I got "error C2065: 'GetProcessID' : undeclared identifier"
Looked in MSDN and everything seems alright. |
You are using it wrong.
Observe:
| Code: | //All includes and whatnot here.
DWORD GetProcessID(char* strProcessName); //Declare the function.
int main(/*crap here*/)
{
DWORD pID = GetProcessID("MapleStory.exe"); //Call function.
}
DWORD GetProcessID(char* strProcessName)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE)
return FALSE;
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if(Process32First(hProcessSnap, &pe32) == 0)
{
CloseHandle(hProcessSnap);
return FALSE;
}
else
{
do
{
if(stricmp(pe32.szExeFile, strProcessName) == 0)
{
CloseHandle(hProcessSnap);
return pe32.th32ProcessID;
}
} while(Process32Next(hProcessSnap, &pe32));
}
}
CloseHandle(hProcessSnap);
return FALSE;
} |
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun May 20, 2007 5:13 pm Post subject: |
|
|
That is if you use CreateProcess(). For a process that is already running you are better off enumerating them. Since there is almost no way to get the HANDLE of a process without the PID first.
|
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Sun May 20, 2007 6:59 pm Post subject: |
|
|
I understand now. Thanks a lot. O yeah, so pID holds the value right
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun May 20, 2007 7:25 pm Post subject: |
|
|
| zomgiownyou wrote: | | I understand now. Thanks a lot. O yeah, so pID holds the value right |
Yep.
|
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Mon May 21, 2007 12:35 pm Post subject: |
|
|
Cool, its works. I have another small question, I wanted to use this SetDlgItemText(Hwnd, IDC_PID, pID );
And its not the first time happening, it gives me "cannot convert parameter 3 from 'unsigned long' to 'const char *'" How do you fix this >=0
_________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Mon May 21, 2007 12:43 pm Post subject: |
|
|
char lol[10];
memset(&lol, 0, sizeof(lol));
itoa(pID, lol, 10);
SetDlgItemText(Hwnd, IDC_PID, lol);
|
|
| Back to top |
|
 |
|