From b5deb50112b8cf5c127ae39efc15988caadaac3f Mon Sep 17 00:00:00 2001 From: SmokelessCPU Date: Thu, 4 Aug 2022 12:27:44 +0200 Subject: [PATCH] Fixed Implicit Casting --- SmokelessRuntimeEFIPatcher/OpCode.c | 4 ++-- .../SmokelessRuntimeEFIPatcher.c | 16 ++++++++-------- SmokelessRuntimeEFIPatcher/Utility.c | 14 +++++++------- SmokelessRuntimeEFIPatcher/Utility.h | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/SmokelessRuntimeEFIPatcher/OpCode.c b/SmokelessRuntimeEFIPatcher/OpCode.c index e1165b6..96f0411 100644 --- a/SmokelessRuntimeEFIPatcher/OpCode.c +++ b/SmokelessRuntimeEFIPatcher/OpCode.c @@ -2,7 +2,7 @@ #include "Utility.h" EFI_STATUS LoadFS(EFI_HANDLE ImageHandle, CHAR8 *FileName, EFI_LOADED_IMAGE_PROTOCOL **ImageInfo, EFI_HANDLE *AppImageHandle) { - UINTN ExitDataSize; + //UINTN ExitDataSize; UINTN NumHandles; UINTN Index; EFI_HANDLE *SFS_Handles; @@ -108,7 +108,7 @@ EFI_STATUS FindLoadedImageFromName(EFI_HANDLE ImageHandle, CHAR8 *FileName, EFI_ for (UINTN i = 0; i < HandleSize; i++) { - Status = gBS->HandleProtocol(Handles[i], &gEfiLoadedImageProtocolGuid, ImageInfo); + Status = gBS->HandleProtocol(Handles[i], &gEfiLoadedImageProtocolGuid, (VOID **)ImageInfo); if (Status == EFI_SUCCESS) { CHAR16 *String = FindLoadedImageFileName(*ImageInfo); diff --git a/SmokelessRuntimeEFIPatcher/SmokelessRuntimeEFIPatcher.c b/SmokelessRuntimeEFIPatcher/SmokelessRuntimeEFIPatcher.c index 957ea1d..c3a309f 100755 --- a/SmokelessRuntimeEFIPatcher/SmokelessRuntimeEFIPatcher.c +++ b/SmokelessRuntimeEFIPatcher/SmokelessRuntimeEFIPatcher.c @@ -301,8 +301,8 @@ EFI_STATUS EFIAPI SREPEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *Syst Prev_OP->ARG3 = 0xFFFFFFFF; Prev_OP->ARG6 = AsciiStrLen(&ConfigData[curr_pos]) / 2; Print(L"Found %d Bytes\n\r", Prev_OP->ARG6); - Prev_OP->ARG7 = AllocateZeroPool(Prev_OP->ARG6); - AsciiStrHexToBytes(&ConfigData[curr_pos], Prev_OP->ARG6 * 2, Prev_OP->ARG7, Prev_OP->ARG6); + Prev_OP->ARG7 = (UINT64)AllocateZeroPool(Prev_OP->ARG6); + AsciiStrHexToBytes(&ConfigData[curr_pos], Prev_OP->ARG6 * 2, (UINT8 *)Prev_OP->ARG7, Prev_OP->ARG6); } continue; } @@ -313,10 +313,10 @@ EFI_STATUS EFIAPI SREPEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *Syst Prev_OP->ARG4 = AsciiStrLen(&ConfigData[curr_pos]) / 2; Print(L"Found %d Bytes\n\r", Prev_OP->ARG4); Prev_OP->ARG5_Dyn_Alloc = TRUE; - Prev_OP->ARG5 = AllocateZeroPool(Prev_OP->ARG4); - AsciiStrHexToBytes(&ConfigData[curr_pos], Prev_OP->ARG4 * 2, Prev_OP->ARG5, Prev_OP->ARG4); + Prev_OP->ARG5 = (UINT64)AllocateZeroPool(Prev_OP->ARG4); + AsciiStrHexToBytes(&ConfigData[curr_pos], Prev_OP->ARG4 * 2, (UINT8 *)Prev_OP->ARG5, Prev_OP->ARG4); Print(L"Patch Byte\n\r"); - PrintDump(Prev_OP->ARG4, Prev_OP->ARG5); + PrintDump(Prev_OP->ARG4, (UINT8 *)Prev_OP->ARG5); continue; } } @@ -350,7 +350,7 @@ EFI_STATUS EFIAPI SREPEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *Syst break; case PATCH: Print(L"Patching Image Size %x: \n\r", ImageInfo->ImageSize); - PrintDump(next->ARG6, next->ARG7); + PrintDump(next->ARG6, (UINT8 *)next->ARG7); PrintDump(next->ARG6, ((UINT8 *)ImageInfo->ImageBase) + 0x1A383); // PrintDump(0x200, (UINT8 *)(LoadedImage->ImageBase)); @@ -360,7 +360,7 @@ EFI_STATUS EFIAPI SREPEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *Syst Print(L"Finding Offset\n\r"); for (UINTN i = 0; i < ImageInfo->ImageSize - next->ARG6; i += 1) { - if (CompareMem(((UINT8 *)ImageInfo->ImageBase) + i, next->ARG7, next->ARG6) == 0) + if (CompareMem(((UINT8 *)ImageInfo->ImageBase) + i, (UINT8 *)next->ARG7, next->ARG6) == 0) { next->ARG3 = i; Print(L"Found at %x\n\r", i); @@ -384,7 +384,7 @@ EFI_STATUS EFIAPI SREPEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *Syst BaseOffset = next->ARG3; Print(L"Offset %x\n\r", next->ARG3); // PrintDump(next->ARG4+10,ImageInfo->ImageBase + next->ARG3 -5 ); - CopyMem(ImageInfo->ImageBase + next->ARG3, next->ARG5, next->ARG4); + CopyMem(ImageInfo->ImageBase + next->ARG3, (UINT8 *)next->ARG5, next->ARG4); Print(L"Patched\n\r"); // PrintDump(next->ARG4+10,ImageInfo->ImageBase + next->ARG3 -5 ); break; diff --git a/SmokelessRuntimeEFIPatcher/Utility.c b/SmokelessRuntimeEFIPatcher/Utility.c index 7f63828..181f869 100644 --- a/SmokelessRuntimeEFIPatcher/Utility.c +++ b/SmokelessRuntimeEFIPatcher/Utility.c @@ -53,7 +53,7 @@ FindLoadedImageFileName( return Buffer; } -UINT8 *FindBaseAddressFromName(CHAR16 **Name) +UINT8 *FindBaseAddressFromName(const CHAR16 *Name) { EFI_STATUS Status; UINTN HandleSize = 0; @@ -70,7 +70,7 @@ UINT8 *FindBaseAddressFromName(CHAR16 **Name) EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocol; for (UINTN i = 0; i < HandleSize; i++) { - Status = gBS->HandleProtocol(Handles[i], &gEfiLoadedImageProtocolGuid, &LoadedImageProtocol); + Status = gBS->HandleProtocol(Handles[i], &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImageProtocol); if (Status == EFI_SUCCESS) { CHAR16 *String = FindLoadedImageFileName(LoadedImageProtocol); @@ -152,13 +152,13 @@ LocateAndLoadFvFromName(CHAR16 *Name, EFI_SECTION_TYPE Section_Type, UINT8 **Buf EFI_STATUS Status; EFI_HANDLE *HandleBuffer; UINTN NumberOfHandles; - UINT32 FvStatus; - EFI_FV_FILE_ATTRIBUTES Attributes; - UINTN Size; + //UINT32 FvStatus; + //EFI_FV_FILE_ATTRIBUTES Attributes; + // UINTN Size; UINTN Index; EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance; - FvStatus = 0; + // FvStatus = 0; // // Locate protocol. @@ -219,7 +219,7 @@ LocateAndLoadFvFromName(CHAR16 *Name, EFI_SECTION_TYPE Section_Type, UINT8 **Buf Print(L"Guid :%g, FileSize %d, Name : %s, Type %d \n\r", NameGuid, FileSize, String, FileType); - Status = FvInstance->ReadSection(FvInstance, &NameGuid, Section_Type, 0, Buffer, BufferSize, &AuthenticationStatus); + Status = FvInstance->ReadSection(FvInstance, &NameGuid, Section_Type, 0,(VOID **) Buffer, BufferSize, &AuthenticationStatus); Print(L"Result Cause %r\n\r", Status); FreePool(String); return EFI_SUCCESS; diff --git a/SmokelessRuntimeEFIPatcher/Utility.h b/SmokelessRuntimeEFIPatcher/Utility.h index de4bcea..f31defe 100644 --- a/SmokelessRuntimeEFIPatcher/Utility.h +++ b/SmokelessRuntimeEFIPatcher/Utility.h @@ -32,6 +32,6 @@ EFI_STATUS LoadandRunImage(EFI_HANDLE ImageHandle, CHAR16 *FileName, EFI_HANDLE *AppImageHandle); -UINT8 * FindBaseAddressFromName(CHAR16 **Name); +UINT8 *FindBaseAddressFromName(const CHAR16 *Name); EFI_STATUS LocateAndLoadFvFromName(CHAR16 *Name, EFI_SECTION_TYPE Section_Type,UINT8 **Buffer,UINTN *BufferSize);