AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Why Cant Start A service.

Ein Thema von ZuBi · begonnen am 21. Jun 2005 · letzter Beitrag vom 20. Aug 2005
 
NicoDE
(Gast)

n/a Beiträge
 
#17

Re: Why Cant Start A service.

  Alt 20. Aug 2005, 17:45
Zitat von Olli:
How can you distinguish? Well, easy. You have two choices:
- Get the module handle of the EXE and check the name for svchost.exe vs. rundll32.exe
- Check under which account you run. SYSTEM is most likely the result when running under svchost.exe
You should use this code to check for the 'System Process Context':
Delphi-Quellcode:
function IsSystemProcessContext: Boolean;
(** )
type
  TLUID = LARGE_INTEGER;
  TTokenStatistics = packed record
    TokenId          : TLUID;
    AuthenticationId  : TLUID;
    ExpirationTime    : LARGE_INTEGER;
    TokenType        : TTokenType;
    ImpersonationLevel: TSecurityImpersonationLevel;
    DynamicCharged    : DWORD;
    DynamicAvailable  : DWORD;
    GroupCount        : DWORD;
    PrivilegeCount    : DWORD;
    ModifiedId        : TLUID;
  end;
const
  SYSTEM_LUID: LARGE_INTEGER = (LowPart: $03E7; HighPart: $0);
(**)

var
  TokenHandle: THandle;
  TokenInformation: TTokenStatistics;
  ReturnLength: DWORD;
begin
  Result := False;
  if OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, TokenHandle) then
    try
      Result := GetTokenInformation(TokenHandle, TokenStatistics,
        Addr(TokenInformation), SizeOf(TTokenStatistics), ReturnLength) and
        (TokenInformation.AuthenticationId.LowPart = SYSTEM_LUID.LowPart) and
        (TokenInformation.AuthenticationId.HighPart = SYSTEM_LUID.HighPart);
    finally
      CloseHandle(TokenHandle);
    end;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:44 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz