mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2026-09-25 21:41:22 -07:00
Use EFI BS FreePool, SetMem, CopyMem
This commit is contained in:
+2
-2
@@ -21,7 +21,7 @@ BOOLEAN ReadConfigFile(struct HackBGRT_config* config, EFI_FILE_HANDLE root_dir,
|
|||||||
// UTF-8 -> UCS-2
|
// UTF-8 -> UCS-2
|
||||||
EFI_STATUS e = BS->AllocatePool(EfiBootServicesData, data_bytes * 2 + 2, (void**)&str);
|
EFI_STATUS e = BS->AllocatePool(EfiBootServicesData, data_bytes * 2 + 2, (void**)&str);
|
||||||
if (EFI_ERROR(e)) {
|
if (EFI_ERROR(e)) {
|
||||||
FreePool(data);
|
BS->FreePool(data);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
UINT8* str0 = data;
|
UINT8* str0 = data;
|
||||||
@@ -51,7 +51,7 @@ BOOLEAN ReadConfigFile(struct HackBGRT_config* config, EFI_FILE_HANDLE root_dir,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
str[str_len] = 0;
|
str[str_len] = 0;
|
||||||
FreePool(data);
|
BS->FreePool(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < str_len;) {
|
for (int i = 0; i < str_len;) {
|
||||||
|
|||||||
+6
-6
@@ -64,12 +64,12 @@ static void SetResolution(int w, int h) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (info_size < sizeof(*info)) {
|
if (info_size < sizeof(*info)) {
|
||||||
FreePool(info);
|
BS->FreePool(info);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
new_w = info->HorizontalResolution;
|
new_w = info->HorizontalResolution;
|
||||||
new_h = info->VerticalResolution;
|
new_h = info->VerticalResolution;
|
||||||
FreePool(info);
|
BS->FreePool(info);
|
||||||
|
|
||||||
// Sum of missing w/h should be minimal.
|
// Sum of missing w/h should be minimal.
|
||||||
int new_missing = max(w - new_w, 0) + max(h - new_h, 0);
|
int new_missing = max(w - new_w, 0) + max(h - new_h, 0);
|
||||||
@@ -110,8 +110,8 @@ ACPI_SDT_HEADER* CreateXsdt(ACPI_SDT_HEADER* xsdt0, UINTN entries) {
|
|||||||
Log(1, L"HackBGRT: Failed to allocate memory for XSDT.\n");
|
Log(1, L"HackBGRT: Failed to allocate memory for XSDT.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ZeroMem(xsdt, xsdt_len);
|
BS->SetMem(xsdt, xsdt_len, 0);
|
||||||
CopyMem(xsdt, xsdt0, min(xsdt0->length, xsdt_len));
|
BS->CopyMem(xsdt, xsdt0, min(xsdt0->length, xsdt_len));
|
||||||
xsdt->length = xsdt_len;
|
xsdt->length = xsdt_len;
|
||||||
SetAcpiSdtChecksum(xsdt);
|
SetAcpiSdtChecksum(xsdt);
|
||||||
return xsdt;
|
return xsdt;
|
||||||
@@ -257,7 +257,7 @@ static BMP* LoadBMP(EFI_FILE_HANDLE root_dir, const CHAR16* path) {
|
|||||||
&& bmp->compression == 0) {
|
&& bmp->compression == 0) {
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
FreePool(bmp);
|
BS->FreePool(bmp);
|
||||||
Log(1, L"HackBGRT: Invalid BMP (%s)!\n", path);
|
Log(1, L"HackBGRT: Invalid BMP (%s)!\n", path);
|
||||||
} else {
|
} else {
|
||||||
Log(1, L"HackBGRT: Failed to load BMP (%s)!\n", path);
|
Log(1, L"HackBGRT: Failed to load BMP (%s)!\n", path);
|
||||||
@@ -282,7 +282,7 @@ static void CropBMP(BMP* bmp, int w, int h) {
|
|||||||
|
|
||||||
if (new_pitch < old_pitch) {
|
if (new_pitch < old_pitch) {
|
||||||
for (int i = 1; i < bmp->height; ++i) {
|
for (int i = 1; i < bmp->height; ++i) {
|
||||||
CopyMem(
|
BS->CopyMem(
|
||||||
(UINT8*) bmp + bmp->pixel_data_offset + i * new_pitch,
|
(UINT8*) bmp + bmp->pixel_data_offset + i * new_pitch,
|
||||||
(UINT8*) bmp + bmp->pixel_data_offset + i * old_pitch,
|
(UINT8*) bmp + bmp->pixel_data_offset + i * old_pitch,
|
||||||
new_pitch
|
new_pitch
|
||||||
|
|||||||
+6
-4
@@ -181,9 +181,11 @@ void* LoadFileWithPadding(EFI_FILE_HANDLE dir, const CHAR16* path, UINTN* size_p
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_FILE_INFO *info = LibFileInfo(handle);
|
UINT64 get_size = 0;
|
||||||
UINTN size = info->FileSize;
|
handle->SetPosition(handle, ~(UINT64)0);
|
||||||
FreePool(info);
|
handle->GetPosition(handle, &get_size);
|
||||||
|
handle->SetPosition(handle, 0);
|
||||||
|
UINTN size = (UINTN) get_size;
|
||||||
|
|
||||||
void* data = 0;
|
void* data = 0;
|
||||||
e = BS->AllocatePool(EfiBootServicesData, size + padding, &data);
|
e = BS->AllocatePool(EfiBootServicesData, size + padding, &data);
|
||||||
@@ -197,7 +199,7 @@ void* LoadFileWithPadding(EFI_FILE_HANDLE dir, const CHAR16* path, UINTN* size_p
|
|||||||
}
|
}
|
||||||
handle->Close(handle);
|
handle->Close(handle);
|
||||||
if (EFI_ERROR(e)) {
|
if (EFI_ERROR(e)) {
|
||||||
FreePool(data);
|
BS->FreePool(data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (size_ptr) {
|
if (size_ptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user