port(2V0-b): verify window tree and fix 64-bit LZO lengths

This commit is contained in:
shen
2026-09-22 19:18:11 -07:00
parent b4c9d6cefc
commit a0ad587f78
13 changed files with 2694 additions and 13 deletions
+11 -7
View File
@@ -157,7 +157,8 @@ void CLZObject::BeginCompressInBuffer(const void * pvIn, UINT uiInLen, void * /*
bool CLZObject::Compress()
{
UINT iOutLen;
// PORT: lzo_uint is 64-bit here; the original UINT out parameter is 32-bit on Win32.
lzo_uint iOutLen;
BYTE * pbBuffer;
pbBuffer = m_pbBuffer + sizeof(THeader);
@@ -165,9 +166,9 @@ bool CLZObject::Compress()
pbBuffer += sizeof(DWORD);
#if defined( LZO1X_999_MEM_COMPRESS )
int r = lzo1x_999_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, (lzo_uint*) &iOutLen, CLZO::Instance().GetWorkMemory());
int r = lzo1x_999_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, &iOutLen, CLZO::Instance().GetWorkMemory());
#else
int r = lzo1x_1_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, (lzo_uint*) &iOutLen, CLZO::Instance().GetWorkMemory());
int r = lzo1x_1_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, &iOutLen, CLZO::Instance().GetWorkMemory());
#endif
if (LZO_E_OK != r)
@@ -176,7 +177,9 @@ bool CLZObject::Compress()
return false;
}
m_pHeader->dwCompressedSize = iOutLen;
if (iOutLen > UINT32_MAX)
return false;
m_pHeader->dwCompressedSize = static_cast<DWORD>(iOutLen);
m_bCompressed = true;
return true;
}
@@ -260,7 +263,8 @@ private:
bool CLZObject::Decompress(DWORD * pdwKey)
{
UINT uiSize;
// PORT: liblzo writes a native-width lzo_uint, while the pack header stays 32-bit.
lzo_uint uiSize;
int r;
if (m_pHeader->dwEncryptSize)
@@ -277,7 +281,7 @@ bool CLZObject::Decompress(DWORD * pdwKey)
return false;
}
if (LZO_E_OK != (r = lzo1x_decompress(pbDecryptedBuffer + sizeof(DWORD), m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
if (LZO_E_OK != (r = lzo1x_decompress(pbDecryptedBuffer + sizeof(DWORD), m_pHeader->dwCompressedSize, m_pbBuffer, &uiSize, NULL)))
{
TraceError("LZObject: Decompress failed(decrypt) ret %d\n", r);
return false;
@@ -288,7 +292,7 @@ bool CLZObject::Decompress(DWORD * pdwKey)
uiSize = m_pHeader->dwRealSize;
//if (LZO_E_OK != (r = lzo1x_decompress_safe(m_pbIn, m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
if (LZO_E_OK != (r = lzo1x_decompress(m_pbIn, m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
if (LZO_E_OK != (r = lzo1x_decompress(m_pbIn, m_pHeader->dwCompressedSize, m_pbBuffer, &uiSize, NULL)))
{
TraceError("LZObject: Decompress failed : ret %d, CompressedSize %d\n", r, m_pHeader->dwCompressedSize);
return false;
+12
View File
@@ -9,10 +9,12 @@
#include "EterPack/StdAfx.h"
#include "EterPack/EterPackManager.h"
#include "EterBase/CRC32.h"
#include "EterBase/lzo.h"
#include "../src/platform/UserInterface/UserInterface.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <map>
#include <set>
@@ -73,6 +75,16 @@ int main(int argc, char** argv)
}
PackSingletons();
// A 32-bit pack header must round-trip through liblzo's native-width output parameter.
const char sample[] = "40250 pack LZO length on a 64-bit host";
CLZObject compressed;
compressed.BeginCompress(sample, sizeof(sample));
CHECK(compressed.Compress());
CLZObject restored;
CHECK(restored.BeginDecompress(compressed.GetBuffer()));
CHECK(restored.Decompress());
CHECK(restored.GetSize() == sizeof(sample));
CHECK(std::memcmp(restored.GetBuffer(), sample, sizeof(sample)) == 0);
CHECK(PackInitialize("pack"));
CEterPackManager& mgr = CEterPackManager::Instance();
+6 -3
View File
@@ -244,8 +244,11 @@ static void run(UI::CWindowManager& wm)
CHECK(wm.IsFocusWindow(c) && !wm.IsFocusWindow(a));
CHECK(take_log() == "A:blur C:focus");
wm.DeactivateWindow();
CHECK(wm.IsFocusWindow(a));
CHECK(take_log() == "C:blur A:focus");
wm.DeactivateWindow();
CHECK(!wm.IsFocus());
take_log();
CHECK(take_log() == "A:blur");
// ---- 按键:RunKeyDownEvent 从 root 往下走,第一个 OnKeyDown 返回真的窗口吃掉它并被记成捕获者 ----
a->Hide(); // A 的处理器返回 0,藏起来让这段日志只剩 C
@@ -262,10 +265,10 @@ static void run(UI::CWindowManager& wm)
// ---- Update 沿着树走,Hide 的分支整支跳过 ----
take_log();
wm.Update();
CHECK(take_log() == "A:update B:update C:update");
CHECK(take_log() == "C:update A:update B:update");
b->Hide();
wm.Update();
CHECK(take_log() == "A:update C:update");
CHECK(take_log() == "C:update A:update");
b->Show();
// ---- 销毁:先从管理器的各个指针里摘干净,再从父窗口摘掉,真正的 delete 留到下一次 Update ----