//
// LnvDriverPei.efi - cleaned decompilation
//
#include <Uefi.h>
#include <PiPei.h>
void *MemSet(void *buf, unsigned int count, char value)
{
memset(buf, value, count);
return buf;
}
int CopyMem(int a1, int a2, int a3, int a4)
{
do {
*(_DWORD *)(a1 + 8 * a2 - 8) = a3;
*(_DWORD *)(a1 + 8 * a2-- - 4) = a4;
} while (a2);
return a1;
}
void *MemZero(void *buf, unsigned int count, int value)
{
memset32(buf, value, count);
return buf;
}
char *AsciiStrCpyS(char *dst, char *src, unsigned int count)
{
unsigned int count_1;
char *dst_1;
char *src_1;
count_1 = count;
if (src < dst && &src[count - 1] >= dst) {
src_1 = &src[count - 1];
dst_1 = &dst[count - 1];
} else {
count_1 = count & 3;
qmemcpy(dst, src, 4 * (count >> 2));
src_1 = &src[4 * (count >> 2)];
dst_1 = &dst[4 * (count >> 2)];
}
qmemcpy(dst_1, src_1, count_1);
return dst;
}
static int GetDebugService(void);
static int DebugPrintLevelEnabled(void);
static int PeiServicesGetPointer(void);
static int LnvDebugSwitchPpiCallback(char *fmt, ...);
static int CmosWriteByte(int CmosAddress, int DataValue);
static char *InternalBuildGuidHob(int HobGuid, char *DataBuffer);
EFI_STATUS ModuleEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
int NotifyStatus;
int ConstructorStatus;
int InitStatus;
EFI_STATUS FinalStatus;
if ((*(int (**)(EFI_SYSTEM_TABLE *, void *, _DWORD, _DWORD, void *))(LODWORD(SystemTable->Hdr.Signature) + 32))(
SystemTable,
&unk_FFE3E344,
0,
0,
&unk_FFE3E3C8) < 0)
{
NotifyStatus = (*(int (**)(EFI_SYSTEM_TABLE *, void *))(LODWORD(SystemTable->Hdr.Signature) + 36))(
SystemTable,
&unk_FFE3E3B8);
ConstructorStatus = NotifyStatus;
if (NotifyStatus < 0) {
DebugPrint(-1, "PEI - PeiLnvSendIpmiCmdLibConstructor NotifyPpi Status = %r \n", NotifyStatus);
DebugPrint(-1, "PeiLnvSendIpmiCmdLibConstructor Status = %r \n", ConstructorStatus);
}
}
InitStatus = (*(int (**)(EFI_SYSTEM_TABLE *, void *))(LODWORD(SystemTable->Hdr.Signature) + 36))(
SystemTable,
&unk_FFE3E394);
FinalStatus = InitStatus;
if (InitStatus < 0)
DebugPrint(-1, "PEI - LnvDriverPEI_Init NotifyPpi Status = %r \n", InitStatus);
LnvDebugSwitchInit(SystemTable);
return FinalStatus;
}
int MemoryDiscoveredPpiCallback(void)
{
LnvDebugSwitchPpiCallback("PEI - gEfiPeiMemoryDiscoveredPpiGuid Signaled");
return 0;
}
int BootInRecoveryModePpiCallback(void)
{
LnvDebugSwitchPpiCallback("PEI - gEfiPeiBootInRecoveryModePpiGuid Signaled");
return 0;
}
int EndOfPeiSignalPpiCallback(void)
{
LnvDebugSwitchPpiCallback("PEI - gEfiEndOfPeiSignalPpiGuid Signaled");
return 0;
}
int __thiscall LnvDebugSwitchInit(EFI_SYSTEM_TABLE *SystemTable)
{
int Signature;
int result;
int PeiSwitchValue;
int CmosStatus;
int HobGuid;
int DebugValue;
int DxeCmosStatus;
int DxeDebugValue;
int PeiCmosStatus;
int HobGuid_1;
int DxeSwitchByte;
int DxeCmosStatus2;
int SmmDebugByte;
_BYTE ConfigData[3];
unsigned __int8 PeiDebugSwitch;
char src[4];
unsigned __int8 SmmDebugSwitch;
int DataSize;
int (**GetVariableProtocol)(_DWORD, const __int16 *, void *, _DWORD, int *, _BYTE *);
char DefaultDebugSwitch;
Signature = SystemTable->Hdr.Signature;
DataSize = 10;
GetVariableProtocol = 0;
DefaultDebugSwitch = 0x80;
result = (*(int (**)(EFI_SYSTEM_TABLE *, void *, _DWORD, _DWORD, int (***)(_DWORD, const __int16 *, void *, _DWORD, int *, _BYTE *)))(Signature + 32))(
SystemTable,
&unk_FFE3E324,
0,
0,
&GetVariableProtocol);
if (!result) {
result = (*GetVariableProtocol)(GetVariableProtocol, L"LnvSetup", &unk_FFE3E374, 0, &DataSize, ConfigData);
if (!result) {
if (ConfigData[2]) {
LOBYTE(PeiSwitchValue) = PeiDebugSwitch;
PeiCmosStatus = CmosWriteByte(33360, PeiSwitchValue);
if (PeiCmosStatus < 0)
DebugPrint(-1, "RDBG CmosWriteByte PEI_DEBUG_SWITCH_BY_NVRAM_OFFSET , %x , Status = %r \n", PeiDebugSwitch, PeiCmosStatus);
InternalBuildGuidHob(HobGuid_1, src);
DebugPrint(-1, "RDBG BuildGuidDataHob gLnvDebugSwitchHobGuid \n");
LOBYTE(DxeSwitchByte) = src[0];
DxeCmosStatus2 = CmosWriteByte(33368, DxeSwitchByte);
if (DxeCmosStatus2 < 0)
DebugPrint(-1, "RDBG CmosWriteByte DXE_DEBUG_SWITCH_BY_NVRAM_OFFSET , %x , Status = %r \n", (unsigned __int8)src[0], DxeCmosStatus2);
LOBYTE(SmmDebugByte) = SmmDebugSwitch;
result = CmosWriteByte(33376, SmmDebugByte);
if (result < 0)
return DebugPrint(-1, "RDBG CmosWriteByte SMM_DEBUG_SWITCH_BY_NVRAM_OFFSET , %x , Status = %r \n", SmmDebugSwitch, result);
} else {
LOBYTE(PeiSwitchValue) = DefaultDebugSwitch;
CmosStatus = CmosWriteByte(33360, PeiSwitchValue);
if (CmosStatus < 0)
DebugPrint(-1, "RDBG CmosWriteByte PEI_DEBUG_SWITCH_BY_NVRAM_OFFSET , %x , Status = %r \n", (unsigned __int8)DefaultDebugSwitch, CmosStatus);
InternalBuildGuidHob(HobGuid, &DefaultDebugSwitch);
DebugPrint(-1, "RDBG BuildGuidDataHob gLnvDebugSwitchHobGuid \n");
LOBYTE(DebugValue) = DefaultDebugSwitch;
DxeCmosStatus = CmosWriteByte(33368, DebugValue);
if (DxeCmosStatus < 0)
DebugPrint(-1, "RDBG CmosWriteByte DXE_DEBUG_SWITCH_BY_NVRAM_OFFSET , %x , Status = %r \n", (unsigned __int8)DefaultDebugSwitch, DxeCmosStatus);
LOBYTE(DxeDebugValue) = DefaultDebugSwitch;
result = CmosWriteByte(33376, DxeDebugValue);
if (result < 0)
return DebugPrint(-1, "RDBG CmosWriteByte SMM_DEBUG_SWITCH_BY_NVRAM_OFFSET , %x , Status = %r \n", (unsigned __int8)DefaultDebugSwitch, result);
}
}
}
return result;
}
int GetDebugService(void)
{
int PpiServices;
int Guid;
int DebugServicePtr;
PpiServices = PeiServicesGetPointer();
if ((*(int (**)(int, void *, _DWORD, int *, int *))(*(_DWORD *)PpiServices + 32))(
PpiServices,
&unk_FFE3E334,
0,
&Guid,
&DebugServicePtr) >= 0)
return DebugServicePtr;
return 0;
}
int DebugPrint(int a1, const char *a2, ...)
{
int result;
int (**v3)(int, const char *, char *);
va_list va;
va_start(va, a2);
result = GetDebugService();
v3 = (int (**)(int, const char *, char *))result;
if (result) {
result = DebugPrintLevelEnabled();
if ((result & a1) != 0)
return (*v3)(a1, a2, (char *)va);
}
return result;
}
int PeiServicesGetIdt(int a, int b, int c)
{
int result;
result = GetDebugService();
if (result)
return (*(int (**)(int, int, int))(result + 4))(a, b, c);
return result;
}
int InternalHobConstructor(int HobGuid, int HobType)
{
int PpiServices;
int DebugService;
int HobPtr;
PpiServices = PeiServicesGetPointer();
if ((*(int (**)(int, int, int, int *))(*(_DWORD *)PpiServices + 52))(PpiServices, 4, HobType, &HobPtr) < 0)
HobPtr = 0;
if (!HobPtr) {
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c", 250, "Hob != ((void *) 0)");
}
return HobPtr;
}
char *InternalBuildGuidHob(int HobGuid, char *DataBuffer)
{
int DebugService;
int HobPtr;
int HobCopy;
if (!DataBuffer) {
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\MdePkg\\Library\\PeiHobLib\\HobLib.c", 466, "Data != ((void *) 0) || DataLength == 0");
}
HobPtr = InternalHobConstructor(HobGuid, 25);
HobCopy = HobPtr;
if (!HobPtr)
return 0;
HobConstructorInternal((void *)(HobPtr + 8));
if (HobCopy == -24)
return 0;
return StrCpySInternal((char *)(HobCopy + 24), DataBuffer);
}
int __thiscall GetCmosService(void *this)
{
int PpiServices;
_DWORD CmosProtocolGuid[4];
CmosProtocolGuid[0] = -859887738;
CmosProtocolGuid[1] = 1124650348;
CmosProtocolGuid[2] = 1482881725;
CmosProtocolGuid[3] = -2118136208;
if (!this)
return -2147483646;
PpiServices = PeiServicesGetPointer();
if (PpiServices)
return (*(int (**)(int, _DWORD *, _DWORD, _DWORD, void *))(*(_DWORD *)PpiServices + 32))(PpiServices, CmosProtocolGuid, 0, 0, this);
return -2147483645;
}
int CmosWriteByte(int CmosAddress, int DataValue)
{
int Status;
int CmosProtocol;
CmosProtocol = 0;
Status = GetCmosService(&CmosProtocol);
if (Status >= 0)
return (*(int (**)(int, int, int))(CmosProtocol + 8))(CmosProtocol, CmosAddress, DataValue);
return Status;
}
int LnvDebugSwitchPpiCallback(char *fmt, ...)
{
int Status;
unsigned int SprintLength;
unsigned int FormatLength;
int PpiServices;
double DebugBuffer;
char DebugStatus;
_BYTE LogBuffer[255];
_BYTE _r_n[230];
char PrintStatus;
unsigned __int16 RtcYear;
unsigned __int8 RtcMonth;
unsigned __int8 RtcDay;
unsigned __int8 RtcHour;
unsigned __int8 RtcMinute;
unsigned __int8 RtcSecond;
char OutputByte;
va_list va;
va_start(va, fmt);
OutputByte = 0;
if (!fmt)
return -2147483646;
SprintLength = AsciiSPrint(_r_n, 0x100u, 0, fmt, (char *)va);
PrintStatus = SprintLength <= 0xE6 ? PrintStatus : 0;
ReadRtcDateTime(&RtcYear);
DebugStatus = 0;
LODWORD(DebugBuffer) = _r_n;
FormatLength = AsciiSPrintFormat(LogBuffer, 0xFEu, "%04d/%02d/%02d-%02d:%02d:%02d : %a.", RtcYear, RtcMonth, RtcDay, RtcHour, RtcMinute, RtcSecond, DebugBuffer);
if (FormatLength > 0xFD)
return -2147483643;
PpiServices = PeiServicesGetPointer();
Status = (*(int (**)(int, void *, _DWORD, _DWORD, char **))(*(_DWORD *)PpiServices + 32))(PpiServices, &unk_FFE3E344, 0, 0, &fmt);
if (Status >= 0)
return (*((int (**)(char *, int, _DWORD, int, char *, _DWORD, _DWORD, char *))fmt + 3))(fmt, 46, 0, 71, &DebugStatus, (unsigned __int8)(FormatLength + 2), 0, &OutputByte);
return Status;
}
int PeiLnvSendIpmiCmdConstructor(int PeiServices)
{
int LocateStatus;
int ReturnStatus;
int DebugService;
LocateStatus = (*(int (**)(int, void *, _DWORD, _DWORD, void *))(*(_DWORD *)PeiServices + 32))(PeiServices, &unk_FFE3E344, 0, 0, &unk_FFE3E3C8);
ReturnStatus = LocateStatus;
if (LocateStatus < 0) {
DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", LocateStatus);
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\LenovoServerPkg\\Library\\LnvIpmiLib\\IpmiCmd\\PeiLnvSendIpmiCmdLib.c", 218, "!EFI_ERROR (Status)");
}
return ReturnStatus;
}
int DebugPrintLevelEnabled(void)
{
unsigned __int8 RtcIndexReg;
char DebugLevel;
char LevelCheck;
RtcIndexReg = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg & 0x80 | 0x4A);
DebugLevel = __inbyte(0x71u);
LevelCheck = DebugLevel;
if ((unsigned __int8)DebugLevel <= 3u) {
if (!LevelCheck)
return 0;
goto LABEL_5;
}
LevelCheck = n3;
if (!n3) {
LevelCheck = MEMORY[0xFDAF0490] & 2 | 1;
}
LABEL_5:
if (LevelCheck != -1)
return LevelCheck != 1 ? -2147483578 : -2147483644;
return 0;
}
int PeiServicesGetPointer(void)
{
int PeiServicesPtr;
_BYTE Idtr[2];
int IdtrBase;
X86ReadIdtr(Idtr);
PeiServicesPtr = *(_DWORD *)(IdtrBase - 4);
if (!PeiServicesPtr)
PeiServicesGetIdt((int)"e:\\hs\\MdePkg\\Library\\PeiServicesTablePointerLibIdt\\PeiServicesTablePointer.c", 48, (int)"PeiServices != ((void *) 0)");
return PeiServicesPtr;
}
void *HobConstructorInternal(void *this)
{
__int64 Unaligned64;
__int64 Unaligned64_1;
Unaligned64 = ReadUnaligned64(&unk_FFE3E314);
WriteUnaligned32(Unaligned64, SHIDWORD(Unaligned64));
Unaligned64_1 = ReadUnaligned64(&unk_FFE3E31C);
WriteUnaligned32(Unaligned64_1, SHIDWORD(Unaligned64_1));
return this;
}
char *StrCpySInternal(char *dst, char *src)
{
if (dst == src)
return dst;
return AsciiStrCpyS(dst, src, 1u);
}
int RtcCenturySet(char CenturyByte)
{
int RtcDataPtr;
int RtcDataPtr_1;
unsigned __int8 CenturyBcd;
unsigned __int8 CenturyMsb;
char CenturyBcd2;
unsigned __int8 CenturyLsb;
unsigned int CenturyDec;
char CenturyDec2;
unsigned int CenturyDec3;
int CenturyResult;
unsigned __int8 RtcIndexRead;
RtcDataPtr_1 = RtcDataPtr;
CenturyBcd = *(_BYTE *)(RtcDataPtr + 4);
CenturyMsb = CenturyBcd & 0x7F;
CenturyBcd2 = CenturyBcd >> 7;
*(_BYTE *)(RtcDataPtr + 4) = CenturyMsb;
if ((CenturyByte & 4) == 0) {
CenturyLsb = *(_BYTE *)(RtcDataPtr + 6);
CenturyDec = *(unsigned __int8 *)(RtcDataPtr + 2);
*(_WORD *)RtcDataPtr = (unsigned __int8)(*(_BYTE *)RtcDataPtr - 6 * (*(_BYTE *)RtcDataPtr >> 4));
CenturyDec2 = -6 * (CenturyDec >> 4);
CenturyDec3 = *(unsigned __int8 *)(RtcDataPtr_1 + 3);
*(_BYTE *)(RtcDataPtr_1 + 2) += CenturyDec2;
*(_BYTE *)(RtcDataPtr_1 + 3) += -6 * (CenturyDec3 >> 4);
CenturyResult = *(unsigned __int8 *)(RtcDataPtr_1 + 5) >> 4;
*(_BYTE *)(RtcDataPtr_1 + 4) = CenturyMsb - 6 * (CenturyMsb >> 4);
*(_BYTE *)(RtcDataPtr_1 + 5) += -6 * CenturyResult;
*(_BYTE *)(RtcDataPtr_1 + 6) = CenturyLsb - 6 * (CenturyLsb >> 4);
}
if ((CenturyByte & 2) == 0) {
if (CenturyBcd2) {
RtcIndexRead = *(_BYTE *)(RtcDataPtr_1 + 4);
if (RtcIndexRead < 0xCu)
*(_BYTE *)(RtcDataPtr_1 + 4) = RtcIndexRead + 12;
} else if (*(_BYTE *)(RtcDataPtr_1 + 4) == 12) {
*(_BYTE *)(RtcDataPtr_1 + 4) = 0;
}
}
*(_DWORD *)(RtcDataPtr_1 + 8) = 0;
*(_WORD *)(RtcDataPtr_1 + 12) = 2047;
*(_BYTE *)(RtcDataPtr_1 + 14) = 0;
return 2047;
}
bool IsLeapYear(void)
{
unsigned __int8 RtcIndexReg;
unsigned __int8 CenturyReg;
unsigned __int8 CenturyReg_1;
unsigned __int8 RtcIndexReg2;
unsigned __int8 YearReg;
unsigned __int8 RtcIndexReg3;
char CenturyCalc;
unsigned __int8 RtcIndexReg4;
RtcIndexReg = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg & 0x80 | 0x32);
CenturyReg = __inbyte(0x71u);
CenturyReg_1 = CenturyReg;
RtcIndexReg2 = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg2 & 0x80 | 0x32);
__outbyte(0x71u, 0);
YearReg = __inbyte(0x70u);
__outbyte(0x70u, YearReg & 0x80 | 0x32);
RtcIndexReg3 = __inbyte(0x71u);
CenturyCalc = RtcIndexReg3 & 0x7F;
RtcIndexReg4 = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg4 & 0x80 | 0x32);
__outbyte(0x71u, CenturyReg_1);
return CenturyCalc == 25 || CenturyCalc == 32;
}
bool IsHobInitialized(void)
{
unsigned __int8 RtcIndexReg;
unsigned __int8 HobInitFlag;
int TimeoutCount;
unsigned __int8 RtcIndexReg2;
char RtcUpdateFlag;
unsigned __int8 RtcIndexReg3;
unsigned __int8 RtcIndexReg4;
unsigned __int8 n0x80;
RtcIndexReg = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg & 0x80 | 0xD);
HobInitFlag = __inbyte(0x71u);
if (HobInitFlag < 0x80u)
return 0;
TimeoutCount = 10001;
RtcIndexReg2 = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg2 & 0x80 | 0xA);
RtcUpdateFlag = __inbyte(0x71u);
while (RtcUpdateFlag < 0 && TimeoutCount) {
RtcIndexReg3 = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg3 & 0x80 | 0xA);
RtcUpdateFlag = __inbyte(0x71u);
--TimeoutCount;
}
RtcIndexReg4 = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexReg4 & 0x80 | 0xD);
n0x80 = __inbyte(0x71u);
return TimeoutCount && n0x80 >= 0x80u;
}
char __thiscall ReadRtcDateTime(_BYTE *this)
{
unsigned __int8 RtcIndexVal;
char CenturyByte;
unsigned __int8 SecIndexVal;
unsigned __int8 RtcSecond;
unsigned __int8 MinIndexVal;
unsigned __int8 RtcMinute;
unsigned __int8 HourIndexVal;
unsigned __int8 RtcHour;
unsigned __int8 DayIndexVal;
unsigned __int8 RtcDay;
unsigned __int8 MonthIndexVal;
unsigned __int8 RtcMonth;
unsigned __int8 YearIndexVal;
unsigned __int8 RtcYearLow;
bool IsLeapYear;
unsigned __int8 CentIndexVal;
unsigned __int8 RtcCentury;
char CenturyByte_1;
if (!this || !IsHobInitialized())
return 0;
RtcIndexVal = __inbyte(0x70u);
__outbyte(0x70u, RtcIndexVal & 0x80 | 0xB);
CenturyByte = __inbyte(0x71u);
CenturyByte_1 = CenturyByte;
SecIndexVal = __inbyte(0x70u);
__outbyte(0x70u, SecIndexVal & 0x80);
RtcSecond = __inbyte(0x71u);
*(this + 6) = RtcSecond;
MinIndexVal = __inbyte(0x70u);
__outbyte(0x70u, MinIndexVal & 0x80 | 2);
RtcMinute = __inbyte(0x71u);
*(this + 5) = RtcMinute;
HourIndexVal = __inbyte(0x70u);
__outbyte(0x70u, HourIndexVal & 0x80 | 4);
RtcHour = __inbyte(0x71u);
*(this + 4) = RtcHour;
DayIndexVal = __inbyte(0x70u);
__outbyte(0x70u, DayIndexVal & 0x80 | 7);
RtcDay = __inbyte(0x71u);
*(this + 3) = RtcDay;
MonthIndexVal = __inbyte(0x70u);
__outbyte(0x70u, MonthIndexVal & 0x80 | 8);
RtcMonth = __inbyte(0x71u);
*(this + 2) = RtcMonth;
YearIndexVal = __inbyte(0x70u);
__outbyte(0x70u, YearIndexVal & 0x80 | 9);
RtcYearLow = __inbyte(0x71u);
*(_WORD *)this = RtcYearLow;
RtcCenturySet(CenturyByte_1);
IsLeapYear = ::IsLeapYear();
CentIndexVal = __inbyte(0x70u);
__outbyte(0x70u, CentIndexVal & 0x80 | 0x32);
RtcCentury = __inbyte(0x71u);
if (IsLeapYear)
RtcCentury &= ~0x80u;
*(_WORD *)this += 100 * (unsigned __int8)(RtcCentury - 6 * (RtcCentury >> 4));
return 1;
}
unsigned int AsciiSPrintFormat(_BYTE *_r_n, unsigned int n254, char *fmt, ...)
{
va_list va;
va_start(va, fmt);
return AsciiSPrint(_r_n, n254, 0, fmt, (char *)va);
}
_BYTE *BasePrintLibSPrintMarker(_BYTE *a1, unsigned int a2, int i, __int16 a4, int a5)
{
int j;
for (j = 0; j < i; ++j) {
if ((unsigned int)a1 >= a2)
break;
*a1 = a4;
if (a5 != 1)
a1[1] = HIBYTE(a4);
a1 += a5;
}
return a1;
}
_BYTE *DivU64x32Remainder(_BYTE *_r_n, unsigned int n16, int a3, unsigned int a4)
{
_BYTE *_r_n_1;
int DebugService;
int v7;
int v8;
unsigned __int64 v9;
unsigned int v11;
int v12;
int *v13;
unsigned int n16_1;
_r_n_1 = _r_n;
v13 = &v12;
n16_1 = n16;
*_r_n = 0;
do {
if (!n16) {
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\MdePkg\\Library\\BaseLib\\DivU64x32Remainder.c", 47, "Divisor != 0");
}
v11 = a4 / n16_1;
LODWORD(v9) = a3;
HIDWORD(v9) = a4 % n16_1;
v7 = v9 / n16_1;
v8 = v9 % n16_1;
if (v13)
*v13 = v8;
++_r_n_1;
a3 = v7;
a4 = v11;
*_r_n_1 = byte_FFE3E094[v12];
} while (v11 | v7);
return _r_n_1;
}
unsigned int AsciiSPrintUnicode(_BYTE *_r_n, unsigned int n38, __int16 a3, char *fmt, ...)
{
va_list va;
va_start(va, fmt);
return AsciiSPrint(_r_n, n38, a3, fmt, (char *)va);
}
void *__thiscall X86ReadIdtr(void *this)
{
void *this_1;
if (!this)
PeiServicesGetIdt((int)"e:\\hs\\MdePkg\\Library\\BaseLib\\X86ReadIdtr.c", 37, (int)"Idtr != ((void *) 0)");
this_1 = this;
__sidt(this);
return this_1;
}
__int16 __thiscall ReadUnaligned16(void *this)
{
int DebugService;
if (!this) {
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 38, "Buffer != ((void *) 0)");
}
return *(_WORD *)this;
}
__int64 __thiscall ReadUnaligned64(void *this)
{
int DebugService;
if (!this) {
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 192, "Buffer != ((void *) 0)");
}
return *(_QWORD *)this;
}
int WriteUnaligned32(int Unaligned64, int a2)
{
_DWORD *v2;
_DWORD *v3;
int DebugService;
v3 = v2;
if (!v2) {
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\MdePkg\\Library\\BaseLib\\Unaligned.c", 219, "Buffer != ((void *) 0)");
}
*v3 = Unaligned64;
v3[1] = a2;
return Unaligned64;
}
unsigned int __thiscall StrLenInternal(char *String)
{
int DebugService;
unsigned int StrIndex;
if (((unsigned __int8)String & 1) != 0) {
DebugService = GetDebugService();
if (DebugService)
(*(void (**)(const char *, int, const char *))(DebugService + 4))("e:\\hs\\MdePkg\\Library\\BaseLib\\SafeString.c", 128, "((UINTN) String & 0x00000001) == 0");
}
if (!String)
return 0;
StrIndex = 0;
if (*(_WORD *)String) {
while (StrIndex < 0xF4240) {
++StrIndex;
if (!*((_WORD *)String + StrIndex))
return StrIndex;
}
return 1000001;
}
return StrIndex;
}
unsigned int __thiscall StrSizeInternal(char *String)
{
unsigned int n0xF4240;
n0xF4240 = 0;
if (String && *String) {
while (n0xF4240 < 0xF4240) {
if (!*(String + ++n0xF4240))
return n0xF4240;
}
return 1000001;
}
return n0xF4240;
}