/* * @implemented */ BOOL WINAPI SetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength) { NTSTATUS Status; Status = NtSetInformationToken(TokenHandle, TokenInformationClass, TokenInformation, TokenInformationLength); if (!NT_SUCCESS(Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } return TRUE; }
BOOL SetTokenInfo( HANDLE Token, TOKEN_INFORMATION_CLASS TokenInformationClass, PVOID Buffer) { NTSTATUS Status; ULONG BufferSize; BufferSize = GetAllocSize(Buffer); switch (TokenInformationClass) { case TokenOwner: case TokenPrimaryGroup: case TokenDefaultDacl: Status = NtSetInformationToken( Token, // Handle TokenInformationClass, // TokenInformationClass Buffer, // TokenInformation BufferSize // TokenInformationLength ); if (!NT_SUCCESS(Status)) { DbgPrint("SECEDIT: NtSetInformationToken failed, info class = 0x%x, status = 0x%lx\n", TokenInformationClass, Status); return(FALSE); } break; case TokenGroups: Status = NtAdjustGroupsToken( Token, // Handle FALSE, // Reset to default (PTOKEN_GROUPS)Buffer, // New State BufferSize, // Buffer Length NULL, // Previous State NULL // Return Length ); if (!NT_SUCCESS(Status)) { DbgPrint("SECEDIT: NtAdjustGroupsToken failed, status = 0x%lx\n", Status); return(FALSE); } break; case TokenPrivileges: Status = NtAdjustPrivilegesToken( Token, // Handle FALSE, // Disable all privileges (PTOKEN_PRIVILEGES)Buffer, // New State BufferSize, // Buffer Length NULL, // Previous State NULL // Return Length ); if (!NT_SUCCESS(Status)) { DbgPrint("SECEDIT: NtAdjustPrivilegesToken failed, status = 0x%lx\n", Status); return(FALSE); } break; default: // Unrecognised information type DbgPrint("SECEDIT: SetTokenInfo passed unrecognised infoclass, class = 0x%x\n", TokenInformationClass); return(FALSE); } return(TRUE); }