IPB

Здравствуйте, гость ( Вход | Регистрация )

История благодарностей участнику RoseKavalier. Спасибо сказали: 2
Дата поста: В теме: За сообщение: Спасибо сказали:
19 Nov 2019, 21:51 Баг-репорты
привет)

There is a memory-leak, or worse crash-bug in 5.0RC63 using 32bit-mode when you load custom indexed pcx from data folder.
This happens when you use custom hero portraits for example.

sub_44F710 (read pcx from file) called from sub_44F5A0 happens after Palette565 constructor sub_522B40 which now places a COLOR32* at &Palette565[254] via HiHook.

In sub_44F710, Palette565 is read from the FILE pointer and overwrites the new COLOR32* within loop 44F808~44F84F.
If lucky, you will get a dump of incorrect colors on screen, if not immediate crash... in either case, almost guaranteed crash when the system frees the pcx as it tries to delete the palette entries that overwrote the COLOR32* buffer.

I made some prototype code which looks to resolve this, hope it helps to patch it.

Код
int __stdcall _HH_ReadPcxFromFile(HiHook* h, H3LoadedPCX* pcx, LPCSTR filename, int a3, int a4 ,int green_bits, int a6, int a7, int a8)
{
    PDWORD pal32 = PDWORD(PtrAt(&pcx->palette565.color[254]));

    const int r = THISCALL_8(int, h->GetDefaultFunc(), pcx, filename, a3, a4, green_bits, a6, a7, a8);

    const BOOL mode565 = green_bits == 6;

    for (int i = 0; i < 256; ++i)
    {
        if (mode565)
            pal32[i] = H3RGB565::Unpack(pcx->palette565.color[i].GetBits()) + 0xFF000000;
        else
            pal32[i] = H3RGB555::Unpack(pcx->palette565.color[i].GetBits()) + 0xFF000000;
    }

    PtrAt(&pcx->palette565.color[254]) = DWORD(pal32);

    return r;
}

...
if (h3_BitMode == 4) // only apply on 32-bit modes
    pi->WriteHiHook(0x44f710, SPLICE_, THISCALL_, _HH_ReadPcxFromFile);
magoth, baratorch

Текстовая версия Сейчас: 25 April 2024 - 04:21
Copyright by Алексей Крючков
Strategy Gamez by GrayMage
Programming by Degtyarev Dmitry
  Яндекс.Метрика