Skip to content

OcAppleFirmwarePasswordLib: Correct protocol reverse - #656

Open
ilikesn0w wants to merge 1 commit into
acidanthera:masterfrom
ilikesn0w:AFWPReverseCorrect
Open

ilikesn0w wants to merge 1 commit into
acidanthera:masterfrom
ilikesn0w:AFWPReverseCorrect

Conversation

@ilikesn0w

Copy link
Copy Markdown
Contributor

Some corrections to AppleFirmwarePassword protocol reverse. I think it's OK if OcAppleFirmwarePasswordLib reports that there is no password in the system since we don't use it anyway.

Comment on lines +96 to +108
Status = gBS->LocateHandleBuffer (ByProtocol, &gAppleFirmwarePasswordProtocolGuid, NULL, &HandleCount, &HandleBuffer);
if (!EFI_ERROR (Status) && (HandleCount != 0) && (HandleBuffer != NULL)) {
for (Index = 0; Index < HandleCount; Index++) {
FwPass = NULL;
Status = OcHandleProtocolFallback (HandleBuffer[Index], &gAppleFirmwarePasswordProtocolGuid, (VOID **)&FwPass);
if (!EFI_ERROR (Status) && (FwPass != NULL) && (FwPass->Signature == APPLE_FIRMWARE_PASSWORD_PROTOCOL_SIGNATURE)) {
FreePool (HandleBuffer);
return FwPass;
}
}

FreePool (HandleBuffer);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apple does it like this:

Status = gBS->LocateHandleBuffer(
             SearchType: ByProtocol,
             Protocol: &APPLE_FIRMWARE_PASSWORD_PROTOCOL_GUID,
             SearchKey: nullptr,
             NoHandles,
             &Buffer);
  if ( (Status & 0x8000000000000000uLL) == 0LL )
  {
    if ( NoHandles[0] != 0 )
    {
      v4 = 0;
      while ( 1 )
      {
        Status = gBS->HandleProtocol(
                   Handle: Buffer[v4],
                   Protocol: &APPLE_FIRMWARE_PASSWORD_PROTOCOL_GUID,
                   Interface: (void **)&AppleFirmwarePasswordProtocol);
        if ( (Status & 0x8000000000000000uLL) == 0LL && AppleFirmwarePasswordProtocol->Signature == 0x4457535341505746LL )
          break;
        if ( ++v4 >= NoHandles[0] )
          goto LABEL_9;
      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant