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

Method getVTable

rEFIt_UEFI/Platform/kernel_patcher.cpp:81–120  ·  view source on GitHub ↗

Slice the purpose of the procedure is to find a table of symbols in the shifted kernel

Source from the content-addressed store, hash-verified

79//Slice
80// the purpose of the procedure is to find a table of symbols in the shifted kernel
81EFI_STATUS LOADER_ENTRY::getVTable()
82{
83 DBG("kernel at 0x%llx\n", (UINTN)KernelData);
84// INT32 LinkAdr = FindBin(KernelData, 0x3000, (const UINT8 *)kLinkEditSegment, (UINT32)strlen(kLinkEditSegment));
85// if (LinkAdr == -1) {
86// DBG("no LinkEdit\n");
87// return EFI_NOT_FOUND;
88// }
89// const UINT8 vtable[] = {0x04, 00,00,00, 0x0F, 0x08, 00, 00};
90// const UINT8 vtableSur[] = {0x25, 00,00,00, 0x0F, 0x06, 00, 00};
91 //25000000 0F060000 940BFF00 80FFFFFF
92 //00FFFFFF FF0FFFFF 00000000 FFFFFFFF
93
94 // INT32 Tabble = FindBin(KernelData, 0x5000000, vtableSur, 8);
95 INT32 NTabble = FindBin(KernelData, KERNEL_MAX_SIZE, (const UINT8 *)ctor_used, (UINT32)strlen(ctor_used));
96 DBG("ctor_used found at 0x%x\n", NTabble);
97 if (NTabble < 0) {
98 return EFI_NOT_FOUND;
99 }
100 while (KernelData[NTabble] || KernelData[NTabble-1]) --NTabble;
101 NTabble &= ~0x03; //align, may be 0x07?
102// NTabble -=4;
103 DBG(" NTabble=%x\n", NTabble);
104// DBG("LinkAdr=%x NTabble=%x Tabble=%x\n",LinkAdr, NTabble, Tabble);
105// SEGMENT *LinkSeg = (SEGMENT*)&KernelData[LinkAdr];
106// AddrVtable = LinkSeg->AddrVtable;
107// SizeVtable = LinkSeg->SizeVtable;
108// NamesTable = LinkSeg->AddrNames;
109 //TODO find an origin of the shift
110 shift = NamesTable - NTabble;
111// DBG_RT("AddrVtable=%x Size=%x AddrNames=%x shift=%x\n", AddrVtable, SizeVtable, NamesTable, shift);
112 NamesTable = NTabble;
113 AddrVtable -= shift;
114// AddrVtable = Tabble;
115 DBG("AddrVtable=%x Size=%x AddrNames=%x shift=%x\n", AddrVtable, SizeVtable, NamesTable, shift);
116 SegVAddr = FindBin(KernelData+KernelOffset, 0x600, (const UINT8 *)kTextSegment, (UINT32)strlen(kTextSegment));
117 SegVAddr += KernelOffset;
118 DBG("SegVAddr=0x%x\n", SegVAddr);
119 return EFI_SUCCESS;
120}
121
122UINT32 LOADER_ENTRY::searchSectionByNum(UINT8 * binary, UINT32 Num)
123{

Callers

nothing calls this directly

Calls 2

FindBinFunction · 0.85
strlenFunction · 0.50

Tested by

no test coverage detected