알짜게시판

[Delphi] 권한상승

[code]
function SetPrivilege(lpszPrivilege: string; Enabled: Boolean): Boolean;
var
  TokenHandle: THandle;
  TokenPriv, TokenPriv_Prev: TOKEN_PRIVILEGES;
  ReturnLength: Cardinal;
begin
  if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, TokenHandle) then
  begin
    try
      if LookupPrivilegeValue(nil, PChar(lpszPrivilege), TokenPriv.Privileges[0].Luid) then
      begin
        TokenPriv.PrivilegeCount := 1;

        case Enabled of
          True: TokenPriv.Privileges[0].Attributes  := SE_PRIVILEGE_ENABLED;
          False: TokenPriv.Privileges[0].Attributes := 0;
        end;

        ReturnLength := 0;
        TokenPriv_Prev := TokenPriv;

        AdjustTokenPrivileges(TokenHandle, False, TokenPriv, SizeOf(TokenPriv_Prev), TokenPriv_Prev, ReturnLength);
      end;
    finally
      CloseHandle(TokenHandle);
    end;
  end;

  Result := GetLastError = ERROR_SUCCESS;
  if not Result then raise Exception.Create(SysErrorMessage(GetLastError));
end;
[/code]

번호 제목 글쓴이 조회 날짜
5 [그누보드] 임의로 테마설정하기 2,288 09-16
4 [워드프레스] 회원가입시 닉네임 필드 추가하기 2,266 09-21
3 [워드프레스] 단어 수정하기 2,161 05-19
2 [PHP] 지정 폴더 내 PHP 파일 최종 수정일 확인하기 1,909 06-20
열람 [Delphi] 권한상승 1,791 09-04
목록