Process( ).Handles empty in Vista 64-bit

delphi package - easy access to kernel objects etc.

Process( ).Handles empty in Vista 64-bit

Postby brian » Sat Jun 21, 2008 12:22 pm

It seems this doesn't work at all Vista-64 bit, process handles are empty, itemcount 0.
brian
 
Posts: 36
Joined: Fri Feb 29, 2008 11:12 am

Postby madshi » Thu Jul 03, 2008 9:21 pm

Sorry for the late reply.

The Windows API used for enumerating handles doesn't work when being called from within a 32bit process in a 64bit OS, sadly. You'd need a 64bit process to get this information. Shame on Microsoft... :cry:
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm

Postby brian » Sat Jul 05, 2008 3:58 am

Ahh I see. Shame on borland/cg for not having a 64-bit compiler yet.
brian
 
Posts: 36
Joined: Fri Feb 29, 2008 11:12 am

Postby brian » Sun May 16, 2010 7:51 am

After further testing, this seems to be working in Windows 7-64 bit, but only if both processes are running with the same user privileges. For example, you run your delphi app normally, and try to get the handles for another (32-bit) app that you ran as admin, it won't work. If both are are under normal privs or both as admin, it works. Think of any workaround for this?

example code


Var a: integer;
b: string;
begin

with Process('whatever.exe').Handles do
for a := 0 to ItemCount - 1 do
with Items[a] do
begin
Application.ProcessMessages;
if not IsValid then Continue;
if not (ObjType in [otFile, otFileMapping]) then Continue;
b := KernelObj.ObjName;
if b = '' then Continue;
memo1.lines.add(b);
end;
brian
 
Posts: 36
Joined: Fri Feb 29, 2008 11:12 am

Postby madshi » Tue May 18, 2010 8:25 am

I'm surprised that it works at all, but I won't complain about that... :wink:

I guess the "proper" solution to the privileges problem is to either install your app as a service, or to add a manifest to your exe file which tells Windows that you need admin rights.
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm

Postby brian » Tue May 18, 2010 8:28 am

Well, the thing is, if your app is running as admin, and the other app isn't, it still doesn't work, both have to be running on the same level :O
brian
 
Posts: 36
Joined: Fri Feb 29, 2008 11:12 am

Postby madshi » Tue May 18, 2010 8:45 am

That sounds very weird to me. Honestly, I have no idea why it behaves this way! Maybe MS has hardcoded the underlying APIs to work this way? Don't really know... :?
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm

Re: Process( ).Handles empty in Vista 64-bit

Postby Sugar70 » Wed Dec 22, 2010 12:50 am

You'd need a 64bit process to get this information. Shame on Microsoft... : :crazy: :crazy:
Sugar70
 
Posts: 2
Joined: Wed Dec 22, 2010 12:47 am

Re: Process( ).Handles empty in Vista 64-bit

Postby brian » Wed Dec 22, 2010 1:56 am

It does actually work with a 32-bit process, if both your application and the one retrieving the info about, are running on the same privilege level (user/user or admin/admin).
brian
 
Posts: 36
Joined: Fri Feb 29, 2008 11:12 am


Return to madKernel

Who is online

Users browsing this forum: Google [Bot] and 1 guest