Newer
Older
AMI-Aptio-BIOS-Reversed / MrcOemHooksPeim / MrcOemHooksPeim.c
@Ajax Dong Ajax Dong 2 days ago 4 KB Init
/*
 *MrcOemHooksPeim.c
 *MrcOemHooksPeim PEI module decompiled from IDA
 */

#include "MrcOemHooksPeim.h"

// sub_FFDB7C54 @ 0xffdb7c54 void *sub_FFDB7C54(void *buf, unsigned int count, char value)
{
 memset(buf, value, count); /*0xffdb7c61*/
 return buf; /*0xffdb7c67*/
}

// SetStructPairs @ 0xffdb7c74 int SetStructPairs(int StructBase, int Index, int Value1, int Value2)
{
 do /*0xffdb7c8d*/
 {
 *(_DWORD *)(StructBase + 8 *Index - 8) = Value1; /*0xffdb7c85*/
 *(_DWORD *)(StructBase + 8 *Index-- - 4) = Value2; /*0xffdb7c89*/
 }
 while ( Index ); /*0xffdb7c8d*/
 return StructBase; /*0xffdb7c91*/
}

// Memset32Wrapper @ 0xffdb7c94 void *Memset32Wrapper(void *buf, unsigned int count, int value)
{
 memset32(buf, value, count); /*0xffdb7ca1*/
 return buf; /*0xffdb7ca7*/
}

// sub_FFDB7CD4 @ 0xffdb7cd4 char *sub_FFDB7CD4(char *dst, char *src, unsigned int count_1)
{
 unsigned int count; // edx char *dst_1; // edi char *src_1; // esi count = count_1; /*0xffdb7cde*/
 if ( src < dst && &src[count_1 - 1] >= dst ) /*0xffdb7cec*/
 {
 src_1 = &src[count_1 - 1]; /*0xffdb7d00*/
 dst_1 = &dst[count_1 - 1]; /*0xffdb7d02*/
 }
 else
 {
 count = count_1 & 3; /*0xffdb7cf0*/
 qmemcpy(dst, src, 4 * (count_1 >> 2)); /*0xffdb7cf9*/
 src_1 = &src[4 * (count_1 >> 2)]; /*0xffdb7cf9*/
 dst_1 = &dst[4 * (count_1 >> 2)]; /*0xffdb7cf9*/
 }
 qmemcpy(dst_1, src_1, count); /*0xffdb7d09*/
 return dst; /*0xffdb7d10*/
}

// sub_FFDB7D14 @ 0xffdb7d14 _WORD *sub_FFDB7D14(_WORD *a1, int a2, __int16 a3)
{
 _WORD *v3; // edi v3 = a1; /*0xffdb7d19*/
 while ( a2 ) /*0xffdb7d21*/
 {
 *v3++ = a3; /*0xffdb7d21*/
 --a2; /*0xffdb7d21*/
 }
 return a1; /*0xffdb7d28*/
}

// MrcOemHooksPeimEntryPoint @ 0xffdb7db4 EFI_STATUS MrcOemHooksPeimEntryPoint(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
 int BootModeVar; // eax int Status; // eax int DebugInstance; // eax int Status; // eax EFI_STATUS Status; // esi int Ptr; // eax if ( CheckBootModeFlag(0xFA044u) >= 0 ) /*0xffdb7dc6*/
 {
 SetBootModeFlag(); /*0xffdb7dc8*/
 BootModeVar = GetBootModeVar(); /*0xffdb7dcd*/
 *(_BYTE *)(BootModeVar + 1024068) |= 0x80u; /*0xffdb7dd8*/
 }
 Status = PeiInstallPpi(); /*0xffdb7ddc*/
 if ( Status < 0 ) /*0xffdb7df3*/
 {
 DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffdb7df8*/
 DebugInstance = GetDebugInstance(); /*0xffdb7e00*/
 if ( DebugInstance ) /*0xffdb7e07*/
 (*(void ( **)(const char *, int, const char *))(DebugInstance + 4))( /*0xffdb7e14*/
 "e:\\hs\\Build\\HR6N0XMLK\\DEBUG_VS2015\\IA32\\PurleyPlatPkg\\Platform\\Pei\\MrcOemHooksPeim\\MrcOemHooksPeim\\DEBUG\\AutoGen.c",
 804,
 "!EFI_ERROR (Status)");
 }
 Status = MrcOemHooksPeimMainInit((int)&unk_FFDCEF68); /*0xffdb7e1f*/
 Status = Status; /*0xffdb7e24*/
 if ( Status < 0 ) /*0xffdb7e29*/
 {
 DebugPrint(0x80000000, "\nASSERT_EFI_ERROR (Status = %r)\n", Status); /*0xffdb7e2e*/
 Ptr = GetDebugInstance(); /*0xffdb7e36*/
 if ( Ptr ) /*0xffdb7e3d*/
 (*(void ( **)(const char *, int, const char *))(Ptr + 4))( /*0xffdb7e4a*/
 "e:\\hs\\PurleyPlatPkg\\Platform\\Pei\\MrcOemHooksPeim\\MrcOemHooksPeim.c",
 157,
 "!EFI_ERROR (Status)");
 }
 return Status; /*0xffdb7e50*/
}

// GetDebugInstance @ 0xffdb7e57 int GetDebugInstance()
{
 _BYTE Temp[4]; // [esp+0h] [ebp-8h] BYREF int Result; // [esp+4h] [ebp-4h] BYREF if ( RegisterPeiNotifyCallback((int)&unk_FFDCEC48, 0, (int)Temp, (int)&Result) >= 0 ) /*0xffdb7e75*/
 return Result; /*0xffdb7e7b*/
 else return 0; /*0xffdb7e77*/
}

// DebugPrint @ 0xffdb7e82 int DebugPrint(int Result, const char *Result, ...)
{
 int result; // eax int ( **Result)(int, const char *, char *); // esi va_list va; // [esp+10h] [ebp+Ch] BYREF va_start(va, Result);
 result = GetDebugInstance(); /*0xffdb7e83*/
 Result = (int ( **)(int, const char *, char *))result; /*0xffdb7e88*/
 if ( result ) /*0xffdb7e8c*/
 {
 result = sub_FFDB7EC5(); /*0xffdb7e8e*/
 if ( (result & Result) != 0 ) /*0xffdb7e99*/
 return (*Result)(Result, Result, (char *)va); /*0xffdb7ea5*/
 }
 return result; /*0xffdb7eaa*/
}

// AssertEfiError @ 0xffdb7eac int AssertEfiError()
{
 int result; // eax result = GetDebugInstance(); /*0xffdb7eac*/
 if ( result ) /*0xffdb7eb3*/
 return (*(int (**)(void))(result + 4))(); /*0xffdb7eb5*/
 return result; /*0xffdb7eb8*/
}

// IsDebugEnabled @ 0xffdb7eb9 char IsDebugEnabled()
{
 return 1; /*0xffdb7ebb*/
}