View previous topic :: View next topic |
Author |
Message |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
Posted: Sun Nov 18, 2007 7:20 pm Post subject: Get PID ( C# ) |
|
|
Hello, Im wondering if anyone has an idea of how to get the PID of a running Application?
Ex.
Lunia.exe PID : xxxxx
Im using C#.
Thanks in adv.
_________________
CEF Moderator since 2007 ^_^
ZenX-Engine |
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun Nov 18, 2007 7:33 pm Post subject: |
|
|
heres it in c++, i assume you can change it. I don't know c#
Code: | void GetPID(void){
int i;
bool con;
PROCESSENTRY32 cProcessEntry32;
HANDLE cSnapshotHandle;
cSnapshotHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
cProcessEntry32.dwSize = sizeof(cProcessEntry32);
con = Process32First(cSnapshotHandle, cProcessEntry32);
while(con != 0)
{
MessageBox(hwnd,cProcessEntry32.th32ProcessID, "PID", MB_OK);
con = Process32Next(cSnapshotHandle, cProcessEntry32);
}
CloseHandle(cSnapshotHandle);
} |
something like that. That will get the PID of ALL running processes. You can explore the PROCESSENTRY32 Structure and figure out how to just get lunia.
_________________
|
|
Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Nov 18, 2007 7:35 pm Post subject: |
|
|
Code: |
//using System.Diagnostics
Process[] myProcesses = Process.GetProcessesByName("lunia");
foreach(Process myProcess in myProcesses)
{
Console.WriteLine("Lunia.exe PID : " + myProcess.Id.ToString());
}
|
_________________
Last edited by appalsap on Sun Nov 18, 2007 7:38 pm; edited 2 times in total |
|
Back to top |
|
 |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
Posted: Sun Nov 18, 2007 7:37 pm Post subject: |
|
|
appalsap wrote: | Code: |
//using System.Diagnostics
Process[] myProcesses = Process.GetProcessesByName("lunia");
foreach(Process myProcess in myProcesses)
{
Console.WriteLine("Lunia.exe PID : " + myProcess.Id.ToString());
}
|
|
Thanks, Appalsap.
You always save me when i need to be saved.
Im using this for my Lunia bypass, so this is a definite help.
+Rep.
_________________
CEF Moderator since 2007 ^_^
ZenX-Engine |
|
Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Nov 18, 2007 7:41 pm Post subject: |
|
|
Woh...
Since when did Appal know C#?
|
|
Back to top |
|
 |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
|
Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Nov 18, 2007 7:50 pm Post subject: |
|
|
I learned that little bit (the bit that Appal posted, and yes, I knew it before), from gamesguru's tutorial.
Search for a post by him (using search, or check like the 3rd page of Crack Me's), and get the link to his C# Trainer tutorial.
It really explains a lot, and I'm sure you'll find it helpfull in at least some way.
|
|
Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Nov 18, 2007 7:58 pm Post subject: |
|
|
Code: |
if (myProcesses.Length == 0)
{
MessageBox.Show("Pid Could not be resolved");
}
|
_________________
|
|
Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Nov 18, 2007 8:03 pm Post subject: |
|
|
Code: |
private void GetPID(string ProcessName)
{
Process[] myProcesses = Process.GetProcessesByName(ProcessName);
if (myProcesses.Length == 0)
{
Console.WriteLine("No running application with title " + ProcessName + " found.");
return;
}
foreach(Process p in myProcesses)
{
Console.WriteLine(ProcessName + " PID : " + p.Id.ToString());
}
}
|
More dynamic. =)
|
|
Back to top |
|
 |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
Posted: Sun Nov 18, 2007 8:37 pm Post subject: |
|
|
Thanks, works like a charm.
But ONEEE more thing, i thought i had this figured, but, i need to Compare Line 1 in a ini File to a certain string.
Example.
public MyFile = C:\Verify.ini;
If (MyFile.Line1 == "0x00456")
{
MessageBox.show("j00 Failz");
}
Edit :
@ Samuri - Nice!
Ill use that as well(The pat you added in).
_________________
CEF Moderator since 2007 ^_^
ZenX-Engine |
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Nov 18, 2007 9:05 pm Post subject: |
|
|
XML files are more compatible with .Net than INI files. Use those.
This is the perfect opportunity to try on my newest image:
|
|
Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Nov 18, 2007 9:10 pm Post subject: |
|
|
Doesn't matter if it's only one line though.
Code: |
//using System.IO
FileStream file = null;
StreamReader reader = null;
try
{
file = new FileStream("c:\\verify.ini", FileMode.Open);
reader = new StreamReader(file);
if (reader.ReadLine() == "0x00456")
{
MessageBox.show("j00 Failz");
}
}
finally
{
reader.Close();
file.Close();
}
|
_________________
|
|
Back to top |
|
 |
ZenX Grandmaster Cheater Supreme
Reputation: 1
Joined: 26 May 2007 Posts: 1021 Location: ">>Pointer<<" : Address 00400560 Offset :1FE
|
|
Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sun Nov 18, 2007 9:35 pm Post subject: |
|
|
Code: |
//using System.IO
FileStream file = null;
StreamReader reader = null;
try
{
file = new FileStream("c:\\verify.ini", FileMode.Open);
reader = new StreamReader(file);
if (reader.ReadLine() == "0x00456")
{
MessageBox.show("j00 Failz");
}
}
finally
{
reader.Close();
file.Close();
}
| [/quote]
Two things:
1)
Code: |
file = new FileStream("c:\\verify.ini", FileMode.Open);
|
You can do better than that, right?
Code: |
file = new FileStream(@"c:\verify.ini", FileMode.Open);
|
Nobody likes to see a bunch of slashes when they don't need to. =)
2)
I understand what try-catch-finally is, but why use finally?
You could just
Code: |
try
{
file = new FileStream("c:\\verify.ini", FileMode.Open);
reader = new StreamReader(file);
if (reader.ReadLine() == "0x00456")
{
MessageBox.show("j00 Failz");
}
}
reader.Close();
file.Close();
|
Is it supposed to be good practice or something?
|
|
Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Nov 18, 2007 10:04 pm Post subject: |
|
|
samuri25404 wrote: | Nobody likes to see a bunch of slashes when they don't need to. =) |
that's a matter of style
samuri25404 wrote: | I understand what try-catch-finally is, but why use finally? |
because there are many cases where the read could throw an exception (file empty, permission denied etc) and It's good to make sure the file gets closed.
_________________
|
|
Back to top |
|
 |
|