Autor Beitrag
LittleBen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Mi 07.11.12 22:02 
Guten Abend,
gibt es eine Funktion, mit der man anhand der PID (oder des Handles) feststellen kann, ob der Prozess über Adminrechten verfügt?
Die Funktion zum Überprüfen, ob der User diese Rechte hat, ist mir bekannt.

Viele Grüße,
Littleben
ChrisCross
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 124
Erhaltene Danke: 12

Windows 10 64 bit
Delphi XE6 Starter
BeitragVerfasst: Mi 07.11.12 22:27 
www.delphi-treff.de/...tratorrechte-pruefen

Meinst du so etwas? Oder habe ich dich falsch verstanden?

/Edit: :autsch: das weißt du ja bereits
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Mi 07.11.12 22:32 
:zustimm: Jup, das kenn ich schon ;)
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Do 08.11.12 02:22 
Soweit ich herausgefunden habe laufen Prozesse die mit UAC gestartet wurden im Integrity-Mode "High". Demnach könntest du einfach den Integrity-Mode eines Prozesses herausfinden und nachsehen ob dieser auf High gesetzt ist. Wie man das macht findest du auf dieser MSDN-Seite

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Do 08.11.12 16:24 
Vielen Dank! Das ist das, was ich gesucht habe. Nur habe ich noch ein kleines verständnis Problem.
GetCurrentProcess gibt laut MSDN nur ein pseudo Handle zurück und um die Rechte eines anderen Prozesses herauszubekommen, muss ich ja dessen pseudo Handle herausfinden. Nur wie?

Zitat:
A pseudo handle is a special constant, currently (HANDLE)-1, that is interpreted as the current process handle. For compatibility with future operating systems, it is best to call GetCurrentProcess instead of hard-coding this constant value. The calling process can use a pseudo handle to specify its own process whenever a process handle is required. Pseudo handles are not inherited by child processes.

msdn.microsoft.com/e...79%28v=vs.85%29.aspx
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19273
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 08.11.12 16:34 
Du kannst auch den Prozess mit OpenProcess öffnen, dann hast du ein "richtiges" Handle. ;-)
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Do 08.11.12 21:02 
Aber dieses "richtige" Handle kann ja an der stelle OpenProcessToken gar nicht gebrauchen :P

Hier der gefundene Code:
www.plugins-soft.com.../integritylevel.html
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19273
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 08.11.12 23:09 
user profile iconLittleBen hat folgendes geschrieben Zum zitierten Posting springen:
Aber dieses "richtige" Handle kann ja an der stelle OpenProcessToken gar nicht gebrauchen :P
:gruebel: :?!?:

Du gibst das einfach an OpenProcessToken und fertig. :nixweiss: Die Funktion ist mit einem richtigen Handle genauso glücklich wie mit dem Pseudohandle für den eigenen Prozess, warum auch nicht?
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Do 08.11.12 23:15 
Nönönö :P Gibt eine Exception aus (Code kommt morgen, PC schon aus).
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19273
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 08.11.12 23:49 
Dann liegt das vielleicht daran:
Zitat:
The process must have the PROCESS_QUERY_INFORMATION access permission.
Welchen Fehlercode bekommst du denn?
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Fr 09.11.12 23:02 
PROCESS_QUERY_INFORMATION habe ich als Argument drin...
Ich bekomme die Fehlermeldung: "Externe Exception C0000008"
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19273
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 09.11.12 23:19 
Mit ansonsten dem geposteten Quelltext?
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Fr 09.11.12 23:42 
Entschuldigung, ich nehme alles zurück... :autsch:
Ich habe per OpenProcess probiert, ein Prozess mit Administratorrechten zu öffnen und danach nicht abgefragt, ob der Wert 0 ist. Und da ich diesen Prozess nicht öffnen darf, war das Handle 0. Kann ich das Handle auch ohne Adminrechte herausfinden?
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 10.11.12 00:48 
Du kannst das dann ja triangulieren ;)

Wenn du Admin bist, bekommst du ein Handle und davon eine korrekte Antwort.
Wenn du nicht Admin bist, bekommst du entweder Handle&Antwort (die dann "nein" ist) oder kein Handle, was bedeutet dass der Prozess ein höheres Level hat und dann höchstwahrscheinlich entweder Admin oder SystemService ist... :zwinker:

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Sa 10.11.12 11:49 
Das ist natürlich eine sehr saubere Lösung :P Werde es nachher mal ausprobieren.

EDIT: Wo wir schon beim Thema sind ist mir eingefallen: Ist es möglich dieses Integrity Level eines Prozesses zu verändern (angenommen man ist Admin)?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19273
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 10.11.12 16:33 
Man kann nicht nachträglich den Adminstatus ändern, nein. Aus Sicherheitsgründen wird ausschließlich beim Starten eines Prozesses entschieden, ob dieser als Admin läuft oder nicht. Hinterher lässt sich das nicht ändern.