| 4532 | } |
| 4533 | |
| 4534 | UINT8 FfsEngine::patchVtf(QByteArray &vtf) |
| 4535 | { |
| 4536 | if (!oldPeiCoreEntryPoint) { |
| 4537 | msg(tr("patchVtf: PEI Core entry point can't be determined. VTF can't be patched.")); |
| 4538 | return ERR_PEI_CORE_ENTRY_POINT_NOT_FOUND; |
| 4539 | } |
| 4540 | |
| 4541 | if (!newPeiCoreEntryPoint || oldPeiCoreEntryPoint == newPeiCoreEntryPoint) |
| 4542 | // No need to patch anything |
| 4543 | return ERR_SUCCESS; |
| 4544 | |
| 4545 | // Replace last occurrence of oldPeiCoreEntryPoint with newPeiCoreEntryPoint |
| 4546 | QByteArray old((char*)&oldPeiCoreEntryPoint, sizeof(oldPeiCoreEntryPoint)); |
| 4547 | int i = vtf.lastIndexOf(old); |
| 4548 | if (i == -1) { |
| 4549 | msg(tr("patchVtf: PEI Core entry point can't be found in VTF. VTF not patched.")); |
| 4550 | return ERR_SUCCESS; |
| 4551 | } |
| 4552 | UINT32* data = (UINT32*)(vtf.data() + i); |
| 4553 | *data = newPeiCoreEntryPoint; |
| 4554 | |
| 4555 | return ERR_SUCCESS; |
| 4556 | } |
| 4557 | |
| 4558 | UINT8 FfsEngine::getEntryPoint(const QByteArray &file, UINT32& entryPoint) |
| 4559 | { |