What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

Get the pid of the Archeage.exe process in which were running

Status
Not open for further replies.

mm2211

Community Developer
Joined
Dec 12, 2014
Messages
205
Reaction score
1
Can we obtain the pid of the attached Archeage.exe process in which the plugin is running ?

Its simple if we only assume 1 archeage client, but if you have multiple bots, it get a bit annoying. Currently i am using a somewhat unreliable method, that is, i check for lowest cpu time Archeage process, and assume this is the one the plugin is in (my standard usecase is autostarted plugin so it work out most of the time). But id like something a bit more reliable.


The reason i need the pid, is to detect client crash. Since archbuddy has a tendency to not clean the plugin out after a crash (it seem to kill the mainthread but thats it). No destructor called, no dispose, no appdomain unload nothing. So theres no way for a plugin that rely on threads, to properly clean itself up if Archeage crash (after which AB keep the plugin running with no Archeage process and prevent updating / shutting it down).

I currently have a thread that watch for the pid to be gone and when so, clean itself up. It work out ok, but id like it to be more reliable when starting from an already running client.

I'm open to suggestion on how to approach this
 
just replying here in case someone has the same question i had.

Seem it was already somewhat added with GetGameClientHandle() comparing it with the mainwindowhandle from the process list is more than good enough to find which process the plugin is running in.

Code:
Process[] localByName = Process.GetProcessesByName("ArcheAge");
IntPtr handleptr = GetGameClientHandle();
foreach (Process pr in localByName)
{
		if (pr.MainWindowHandle == handleptr)
		{
				pid = pr.Id;
				break;
		}
}
 
Status
Not open for further replies.
Back
Top