MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / GetSmcKeys

Function GetSmcKeys

rEFIt_UEFI/Platform/Nvram.cpp:460–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458INT8 SNum[1] = {1};
459
460VOID
461GetSmcKeys (BOOLEAN WriteToSMC)
462{
463 EFI_STATUS Status;
464 CHAR16 *Name;
465 EFI_GUID Guid;
466 UINTN NameSize;
467 UINTN NewNameSize;
468 UINT8 *Data;
469 UINTN DataSize;
470 INTN NumKey = 0;
471 STATIC UINTN Once = 0;
472 if (Once++) {
473 return;
474 }
475
476
477 NameSize = sizeof (CHAR16);
478 Name = (__typeof__(Name))AllocateZeroPool(NameSize);
479 if (Name == NULL) {
480 return;
481 }
482 DbgHeader("Dump SMC keys from NVRAM");
483 Status = gBS->LocateProtocol(&gAppleSMCProtocolGuid, NULL, (VOID**)&gAppleSmc);
484 if (!EFI_ERROR(Status)) {
485 DBG("found AppleSMC protocol\n");
486 } else {
487 DBG("no AppleSMC protocol\n");
488 gAppleSmc = NULL;
489 }
490
491 while (TRUE) {
492 NewNameSize = NameSize;
493 Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
494 if (Status == EFI_BUFFER_TOO_SMALL) {
495 Name = (__typeof__(Name))ReallocatePool (NameSize, NewNameSize, Name);
496 if (Name == NULL) {
497 return; //if something wrong then just do nothing
498 }
499
500 Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
501 NameSize = NewNameSize;
502 }
503
504 if (EFI_ERROR(Status)) {
505 break; //no more variables
506 }
507
508 if (!StrStr(Name, L"fakesmc-key")) {
509 continue; //the variable is not interesting for us
510 }
511
512 Data = (__typeof__(Data))GetNvramVariable(Name, &Guid, NULL, &DataSize);
513 if (Data) {
514 /* UINTN Index;
515 DBG(" %ls:", Name);
516 for (Index = 0; Index < DataSize; Index++) {
517 DBG("%02hhX ", *((UINT8*)Data + Index));

Callers 1

RefitMainFunction · 0.85

Calls 9

DbgHeaderFunction · 0.85
StrStrFunction · 0.85
GetNvramVariableFunction · 0.85
KeyFromNameFunction · 0.85
TypeFromNameFunction · 0.85
FourCharKeyFunction · 0.85
AllocateZeroPoolFunction · 0.50
ReallocatePoolFunction · 0.50
FreePoolFunction · 0.50

Tested by

no test coverage detected