The screencopy you posted is the list of Handles of a Process
This is done with NtQuerySystemInformation and SystemExtendedHandleInformation flag
I had posted a test in C# : GetHandlesFromPID in this thread
You can convert it into VB with tools like https://converter.telerik.com/
Process details in VB.Net
Hi, I am trying to obtain details of a running process. I have access to the process, I mean by that I can get the process object no problem.
I would like to find details like ProcessExplorer is able to display.
It's this line "File" with a local path that I would like to be able to read. Any idea of how this can be done?
Developer technologies VB
-
Castorix31 90,521 Reputation points
2021-03-08T16:06:09.83+00:00
2 additional answers
Sort by: Most helpful
-
Dewayne Basnett 1,381 Reputation points
2021-03-08T16:05:23.513+00:00 Maybe this?
Dim p As Process = Process.GetCurrentProcess Dim f As String = p.MainModule.FileName
-
Alexandre A. Cote 1 Reputation point
2021-03-15T17:30:12.627+00:00 I was wondering if you could give me a hint here. First of, thanks for the above solution, it gives what I am looking for. My only issue, is to get these information for a single process.
I tried a couple of thing, but this is the last one:Process nmsdProc = null; Process[] allProc = Process.GetProcesses(); foreach (Process p in allProc) { if(p.ProcessName == "nmsd") { nmsdProc = p; break; } } if (nmsdProc == null) { MessageBox.Show("nmsd was not found"); return; } uint UintnmsdId = (uint)(int)nmsdProc.Id; Process targetProc = new Process(); IntPtr hDup = IntPtr.Zero; try { bool bReturn = DuplicateHandle(Process.GetProcessById(nmsdProc.Id).Handle, nmsdProc.Handle, GetCurrentProcess(), ref hDup, 0, false, DUPLICATE_SAME_ACCESS); } catch (Exception eee) { MessageBox.Show("Problem with Handle Duplicate ... " + eee.Message); } if (hDup != IntPtr.Zero) {
The above code get to the last line "hDup" with a value of "0x0000000000000000" ... I do know that the variable "nmsdProc" do get assign a value, and the code do not throw any exception. So the problem is with the "DuplicateHandle" function that do not seem to assign the dupplicate to hDup.
Any hint on what is wrong?Thanks