Ka Fai Cedric Yiu

85 papers B 1C 2Journal 78Unranked 4
YearRankTypeTitle / Venue / Authors
2025 J jnl
Neural Comput. Appl.
Kit Yan Chan, Ka Fai Cedric Yiu, Dowon Kim
2025 J jnl
Digit. Signal Process.
Qi He, Zhiguo Feng, Zhibao Li, Ka Fai Cedric Yiu
2024 J jnl
Inf. Sci.
Bao Qing Hu, Ka Fai Cedric Yiu
2024 J jnl
Neural Comput. Appl.
Kit Yan Chan, Ka Fai Cedric Yiu, Shan Guo, Huimin Jiang
2024 J jnl
INFORMS J. Comput.
Wei Xu, Jie Tang, Ka Fai Cedric Yiu, Jian-Wen Peng
2024 J jnl
J. Oper. Res. Soc.
Stan Yip, Yinghong Zou, Ronald Tsz Hin Hung, Ka Fai Cedric Yiu
2024 J jnl
Sensors
Kit Yan Chan, Ka Fai Cedric Yiu, Dowon Kim, Ahmed Abu-Siada
2024 J jnl
CoRR
Hao Mark Chen, Wayne Luk, Ka Fai Cedric Yiu, Rui Li, Konstantin Mishchenko, Stylianos I. Venieris, Hongxiang Fan
2024 J jnl
Sensors
Yuhan Zhang, Zhibao Li, Ka Fai Cedric Yiu
2023 J jnl
Appl. Soft Comput.
Wai Man Tang, Ka Fai Cedric Yiu, Kit Yan Chan, Kai Zhang
2023 J jnl
J. Frankl. Inst.
Maolin Wang, Xinsong Yang, Shuoyu Mao, Ka Fai Cedric Yiu, Ju H. Park
2023 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
He Qi, Mingjie Gao, Ka Fai Cedric Yiu, Sven Nordholm
2023 J jnl
Neurocomputing
N. Man, S. Guo, Ka Fai Cedric Yiu, Cyril S. K. Leung
2022 J jnl
Circuits Syst. Signal Process.
Qi He, Siow Yong Low, Ka Fai Cedric Yiu
2021 J jnl
Appl. Soft Comput.
Kit Yan Chan, Ka Fai Cedric Yiu, Hak-Keung Lam, Bert Wei Wong
2020 J jnl
Digit. Signal Process.
Zhibao Li, Ka Fai Cedric Yiu, Yu-Hong Dai, Sven Nordholm
2020 J jnl
Autom.
Wei Xu, Zhi Guo Feng, Gui-Hua Lin, Ka Fai Cedric Yiu, Liying Yu
2020 J jnl
J. Optim. Theory Appl.
Zhi Guo Feng, Fei Chen, Lin Chen, Ka Fai Cedric Yiu
2020 J jnl
Multidimens. Syst. Signal Process.
Lara Nahma, Hai Huyen Dam, Ka Fai Cedric Yiu, Sven Nordholm
2020 J jnl
Int. J. Inf. Technol. Decis. Mak.
Wai Man Tang, Ka Fai Cedric Yiu, Heung Wong
2019 J jnl
Optim. Lett.
Yue Shi, Zhiguo Feng, Ka Fai Cedric Yiu
2019 J jnl
Multim. Tools Appl.
Ka Fai Cedric Yiu
2019 J jnl
Optim. Lett.
Ming Jie Gao, Ka Fai Cedric Yiu
2019 J jnl
Int. J. Fuzzy Syst.
Wai Man Tang, Ka Fai Cedric Yiu, Kit Yan Chan, Heung Wong
2019 J jnl
IEEE Trans. Circuits Syst. II Express Briefs
He Qi, Zhi Guo Feng, Ka Fai Cedric Yiu, Sven Nordholm
2018 J jnl
Circuits Syst. Signal Process.
Zhi Guo Feng, Ka Fai Cedric Yiu, Soon Yi Wu
2018 J jnl
Int. J. Intell. Syst.
Bao Qing Hu, Heung Wong, Ka Fai Cedric Yiu
2018 J jnl
Int. J. Reconfigurable Comput.
Ka Fai Cedric Yiu, Siow Yong Low
2018 J jnl
Comput. Stat. Data Anal.
T. P. Yuen, Heung Wong, Ka Fai Cedric Yiu
2018 J jnl
Sensors
Mingjie Gao, Ka Fai Cedric Yiu, Sven Nordholm
2018 J jnl
SIAM J. Control. Optim.
Jingzhen Liu, Ka Fai Cedric Yiu, Alain Bensoussan
2018 J jnl
Appl. Soft Comput.
Hao Jiang, Wai-Ki Ching, Ka Fai Cedric Yiu, Yushan Qiu
2017 J jnl
IEEE Trans. Syst. Man Cybern. Syst.
Kit Yan Chan, Hak-Keung Lam, Ka Fai Cedric Yiu, Tharam S. Dillon
2017 J jnl
SIAM J. Control. Optim.
Yuan-Hua Ni, Ka Fai Cedric Yiu, Huanshui Zhang, Ji-Feng Zhang
2017 J jnl
Autom.
Wei Xu, Zhi Guo Feng, Jian-Wen Peng, Ka Fai Cedric Yiu
2016 J jnl
Eng. Appl. Artif. Intell.
Zhibao Li, Ka Fai Cedric Yiu
2016 J jnl
ACM Trans. Sens. Networks
Mingjie Gao, Ka Fai Cedric Yiu, Sven Nordholm, Yinyu Ye
2016 J jnl
Knowl. Based Syst.
Bao Qing Hu, Heung Wong, Ka Fai Cedric Yiu
2015 conf
DSP
Ming Jie Gao, Ka Fai Cedric Yiu
2015 J jnl
J. Optim. Theory Appl.
Zhi Guo Feng, Ka Fai Cedric Yiu, Sven E. Nordholm
2014 J jnl
IEEE Trans. Instrum. Meas.
Kit Yan Chan, Siow Yong Low, Sven Nordholm, Ka Fai Cedric Yiu
2014 J jnl
IEEE Signal Process. Lett.
Kit Yan Chan, Sven Nordholm, Siow Yong Low, Pei Chee Yong, Ka Fai Cedric Yiu
2014 J jnl
Appl. Soft Comput.
Kit Yan Chan, Pei Chee Yong, Sven Nordholm, Ka Fai Cedric Yiu, Hak-Keung Lam
2014 J jnl
Appl. Soft Comput.
Ka Fai Cedric Yiu, Zhibao Li, Siow Yong Low, Sven Nordholm
2014 J jnl
Appl. Soft Comput.
Ka Fai Cedric Yiu
2014 J jnl
IEEE ACM Trans. Audio Speech Lang. Process.
Zhibao Li, Ka Fai Cedric Yiu, Sven Nordholm
2014 J jnl
Digit. Signal Process.
Zhi Guo Feng, Ka Fai Cedric Yiu
2013 J jnl
Optim. Methods Softw.
Ka Fai Cedric Yiu, Ming Jie Gao, T. J. Shiu, S. Y. Wu, T. Tran, I. Claesson
2013 J jnl
Appl. Soft Comput.
Zhibao Li, Ka Fai Cedric Yiu, Zhi Guo Feng
2013 J jnl
Appl. Soft Comput.
Leong Kwan Li, Sally Shao, Ka Fai Cedric Yiu
2013 J jnl
Optim. Methods Softw.
Zhi Guo Feng, Ka Fai Cedric Yiu, Kok Lay Teo
2013 J jnl
Risk Decis. Anal.
Ka Fai Cedric Yiu
2013 J jnl
Math. Comput. Model.
Kai-Ling Mak, P. Peng, Ka Fai Cedric Yiu, L. K. Li
2013 C conf
ICICS
Zhibao Li, Ka Fai Cedric Yiu
2013 J jnl
Math. Comput. Model.
S. Y. Wang, Ka Fai Cedric Yiu, Kai-Ling Mak
2013 J jnl
Neurocomputing
Kit Yan Chan, Sven Nordholm, Ka Fai Cedric Yiu, Roberto Togneri
2012 J jnl
Risk Decis. Anal.
Jingzhen Liu, Ka Fai Cedric Yiu, Tak Kuen Siu
2012 J jnl
EURASIP J. Adv. Signal Process.
Zhi Guo Feng, Ka Fai Cedric Yiu, Kok Lay Teo, Sven Nordholm
2012 J jnl
IEEE Trans. Ind. Informatics
Kit Yan Chan, Ka Fai Cedric Yiu, Tharam S. Dillon, Sven Nordholm, Sai-Ho Ling
2012 C conf
ICARCV
Kit Yan Chan, Sven Nordholm, Ka Fai Cedric Yiu
2012 conf
CSO
Na Song, Wai-Ki Ching, Tak Kuen Siu, Ka Fai Cedric Yiu
2012 J jnl
IEEE Trans. Signal Process.
Zhi Guo Feng, Ka Fai Cedric Yiu, Sven E. Nordholm
2012 J jnl
Digit. Signal Process.
Ka Fai Cedric Yiu, Yao Lu, Chun Hok Ho, Wayne Luk, Jiaquan Huo, Sven Nordholm
2011 J jnl
IEEE Trans. Signal Process.
Zhi Guo Feng, Ka Fai Cedric Yiu, Sven E. Nordholm
2011 J jnl
J. Comput. Appl. Math.
Hong Jun Zhou, Ka Fai Cedric Yiu, Leong Kwan Li
2011 J jnl
Multim. Tools Appl.
Peihua Qiu, Ka Fai Cedric Yiu, Lipo Wang
2010 J jnl
Optim. Methods Softw.
Ka Fai Cedric Yiu, Wei-Yong Yan, Kok Lay Teo, Siow Yong Low
2010 J jnl
Autom.
Ka Fai Cedric Yiu, Jingzhen Liu, Tak Kuen Siu, Wai-Ki Ching
2009 J jnl
Image Vis. Comput.
Kai-Ling Mak, P. Peng, Ka Fai Cedric Yiu
2009 J jnl
Autom.
Ryan C. Loxton, Kok Lay Teo, Volker Rehbock, Ka Fai Cedric Yiu
2009 B conf
NSS
Kit Yan Chan, Siow Yong Low, Sven Nordholm, Ka Fai Cedric Yiu, Sai-Ho Ling
2008 conf
ASAP
Ka Fai Cedric Yiu, Chun Hok Ho, Nedelko Grbic, Yao Lu, Xiaoxiang Shi, Wayne Luk
2007 J jnl
Comput. Oper. Res.
Ka Fai Cedric Yiu, Kai-Ling Mak, Henry Y. K. Lau
2006 J jnl
Signal Process.
Ka Fai Cedric Yiu, Nedelko Grbic, Sven Nordholm, Kok Lay Teo
2006 J jnl
Signal Process.
Jiaquan Huo, Ka Fai Cedric Yiu, Sven Nordholm, Kok Lay Teo
2006 conf
ERSA
Chun Hok Ho, Ka Fai Cedric Yiu, Jiaquan Huo, Sven Nordholm, Wayne Luk
2005 J jnl
Eur. J. Oper. Res.
Kai-Ling Mak, K. K. Lai, W. C. Ng, Ka Fai Cedric Yiu
2004 J jnl
J. Glob. Optim.
Ka Fai Cedric Yiu, Yi Liu, Kok Lay Teo
2004 J jnl
IEEE Signal Process. Lett.
Ka Fai Cedric Yiu, Nedelko Grbic, Sven Nordholm, Kok Lay Teo
2003 J jnl
IEEE Trans. Speech Audio Process.
Ka Fai Cedric Yiu, Xiaoqi Yang, Sven Nordholm, Kok Lay Teo
2002 J jnl
IEEE Signal Process. Lett.
Ka Fai Cedric Yiu, Nedelko Grbic, Kok Lay Teo, Sven Nordholm
2001 J jnl
IEEE Trans. Neural Networks
Ka Fai Cedric Yiu, Song Wang, Kok Lay Teo, Ah Chung Tsoi
1997 J jnl
J. Chem. Inf. Comput. Sci.
K. Yip, Kin Y. Tam, Ka Fai Cedric Yiu
1997 J jnl
J. Comput. Chem.
Ka Fai Cedric Yiu, Kin Y. Tam, S. C. Tsang
1995 J jnl
SIAM J. Sci. Comput.
Ka Fai Cedric Yiu
tests/unit/test_decompile_medium_level.py
← Index tests/unit/test_decompile_medium_level.py python
# tests/unit/test_decompile_medium_level.py
"""Unit tests (mocked BN) for bninja/analysis/medium_level.py
   and bninja/analysis/medium_level_normalization.py."""
# tests/unit/test_decompile_medium_level.py
import sys
from unittest.mock import MagicMock, patch

# Installa gli stubs BN
from tests.unit.conftest_binja_stubs import install_binja_stubs
install_binja_stubs()

# ── Definisci MockMLILInstruction PRIMA di importare il modulo ──
class MockMLILInstruction:
    def __init__(self, operation, address=0, operands=None):
        self.operation = operation
        self.address = address
        self.operands = operands or []

# ── Patcha il modulo BN in modo che isinstance() funzioni ──
sys.modules["binaryninja"].MediumLevelILInstruction = MockMLILInstruction
sys.modules["binaryninja"].SSAVariable = type("SSAVariable", (), {})
sys.modules["binaryninja"].Variable = type("Variable", (), {})
sys.modules["binaryninja"].ILIntrinsic = type("ILIntrinsic", (), {})

# Ora importa il modulo — vede già i tipi corretti
from redb.extractors.decompiler.bninja.analysis.medium_level_normalization import (
    MediumLevelNormalization,
)	

class MockMLILFunction:
    def __init__(self, instructions):
        self._instructions = instructions

    @property
    def instructions(self):
        return iter(self._instructions)

    @property
    def basic_blocks(self):
        # one block containing all instructions, good enough for MinHasher
        block = MagicMock()
        block.__iter__ = lambda self_: iter([])  # not used by MediumLevelAnalysis
        return [block]


class MockFunction:
    def __init__(self, name="func", start=0x1000, mlil=None):
        self.name = name
        self.start = start
        self.mlil = mlil



class TestMediumLevelNormalization:
    def setup_method(self):
        from redb.extractors.decompiler.bninja.analysis.medium_level_normalization import (
            MediumLevelNormalization,
        )
        self.norm = MediumLevelNormalization()

    def test_normalize_skeleton_single_instruction(self):
        il = MockMLILInstruction(operation=42, operands=[])
        result = self.norm.normalize_instruction_all_levels(il)
        assert result == [42]

    def test_normalize_skeleton_nested(self):
        inner = MockMLILInstruction(operation=7, operands=[])
        outer = MockMLILInstruction(operation=1, operands=[inner])
        result = self.norm.normalize_instruction_all_levels(outer)
        assert result == [1, 7]

    def test_normalize_skeleton_with_list_operand(self):
        inner_a = MockMLILInstruction(operation=10, operands=[])
        inner_b = MockMLILInstruction(operation=11, operands=[])
        outer = MockMLILInstruction(operation=2, operands=[[inner_a, inner_b]])
        result = self.norm.normalize_instruction_all_levels(outer)
        assert result == [2, 10, 11]

    def test_normalize_skeleton_none(self):
        result = self.norm.normalize_instruction_all_levels(None)
        # collect on None should leave ops empty
        assert result == []

    def test_normalize_typed_appends_leaf_types(self):
        # operand is a plain int -> "CONST"
        il = MockMLILInstruction(operation=3, operands=[42])
        result = self.norm.normalize_instr_with_operands(il)
        assert result == [3, "CONST"]

    def test_normalize_typed_bool_before_int(self):
        # bool must be detected before int (since bool is an int subclass)
        il = MockMLILInstruction(operation=4, operands=[True])
        result = self.norm.normalize_instr_with_operands(il)
        assert result == [4, "BOOL"]

    def test_normalize_typed_float(self):
        il = MockMLILInstruction(operation=5, operands=[1.5])
        result = self.norm.normalize_instr_with_operands(il)
        assert result == [5, "FLOAT_CONST"]

    def test_normalize_typed_str(self):
        il = MockMLILInstruction(operation=6, operands=["hello"])
        result = self.norm.normalize_instr_with_operands(il)
        assert result == [6, "STR"]

    def test_normalize_typed_unknown_falls_back_to_typename(self):
        class Weird:
            pass
        il = MockMLILInstruction(operation=8, operands=[Weird()])
        result = self.norm.normalize_instr_with_operands(il)
        assert result == [8, "WEIRD"]

    def test_normalize_typed_nested_mlil(self):
        inner = MockMLILInstruction(operation=99, operands=[7])
        outer = MockMLILInstruction(operation=1, operands=[inner])
        result = self.norm.normalize_instr_with_operands(outer)
        assert result == [1, 99, "CONST"]

    def test_normalize_typed_list_mixed(self):
        inner = MockMLILInstruction(operation=50, operands=[])
        il = MockMLILInstruction(operation=2, operands=[[inner, 99]])
        result = self.norm.normalize_instr_with_operands(il)
        assert result == [2, 50, "CONST"]


class TestMediumLevelAnalysis:
    def _make_analysis(self, instructions=None, mlil=True, start=0x1000):
        from redb.extractors.decompiler.bninja.analysis.medium_level import (
            MediumLevelAnalysis,
        )
        mlil_func = MockMLILFunction(instructions or []) if mlil else None
        func = MockFunction(name="testfunc", start=start, mlil=mlil_func)
        bv = MagicMock()
        return MediumLevelAnalysis(func, bv, MagicMock())

    def test_collect_returns_empty_when_no_mlil(self):
        a = self._make_analysis(mlil=False)
        sk, sk_addr, ty, ty_addr = a._collect_mlil_skeleton_and_typed()
        assert sk == [] and sk_addr == [] and ty == [] and ty_addr == []

    def test_collect_skeleton_and_typed_basic(self):
        instrs = [
            MockMLILInstruction(operation=1, address=0x1000, operands=[]),
            MockMLILInstruction(operation=2, address=0x1004, operands=[42]),
        ]
        a = self._make_analysis(instructions=instrs, start=0x1000)
        sk, sk_addr, ty, ty_addr = a._collect_mlil_skeleton_and_typed()

        assert sk == [[1], [2]]
        assert ty == [[1], [2, "CONST"]]
        assert sk_addr == [(0, [1]), (4, [2])]
        assert ty_addr == [(0, [1]), (4, [2, "CONST"])]

    def test_collect_negative_offset_clamped_to_zero(self):
        instrs = [
            MockMLILInstruction(operation=1, address=0x900, operands=[]),
        ]
        a = self._make_analysis(instructions=instrs, start=0x1000)
        _, sk_addr, _, ty_addr = a._collect_mlil_skeleton_and_typed()
        assert sk_addr[0][0] == 0
        assert ty_addr[0][0] == 0

    def test_log_error_records_entry(self):
        a = self._make_analysis()
        a.log_error("boom", "fname", 0x1234, ValueError("x"), "loc")
        assert len(a.errors) == 1
        err = a.errors[0]
        assert err["function_name"] == "fname"
        assert err["function_address"] == "4660"  # hex 0x1234
        assert err["error_location"] == "loc"
        assert err["error_message"] == "boom"
        assert err["error_type"] == "ValueError"
        assert "timestamp" in err

    @patch(
        "redb.extractors.decompiler.bninja.analysis.medium_level.MinHasher"
    )
    def test_analyze_returns_expected_keys(self, mock_minhasher):
        mock_minhasher.return_value.calculateMinHash.return_value = [1, 2, 3]

        instrs = [
            MockMLILInstruction(operation=1, address=0x1000, operands=[]),
            MockMLILInstruction(operation=2, address=0x1004, operands=[42]),
            MockMLILInstruction(operation=3, address=0x1008, operands=[]),
        ]
        a = self._make_analysis(instructions=instrs, start=0x1000)
        result, errors = a.analyze()

        expected_keys = {
            "function_address",
            "body_mlil_skeleton_vector",
            "sha256_mlil_skeleton",
            "tlsh_mlil_skeleton",
            "minhash_mlil_skeleton",
            "body_mlil_typed_vector",
            "sha256_mlil_typed",
            "tlsh_mlil_typed",
            "minhash_mlil_typed",
        }
        assert set(result.keys()) == expected_keys
        assert result["function_address"] == 0x1000
        assert result["minhash_mlil_skeleton"] == [1, 2, 3]
        assert result["minhash_mlil_typed"] == [1, 2, 3]
        assert errors == []

    @patch(
        "redb.extractors.decompiler.bninja.analysis.medium_level.MinHasher"
    )
    def test_analyze_empty_mlil(self, mock_minhasher):
        mock_minhasher.return_value.calculateMinHash.return_value = []
        a = self._make_analysis(mlil=False)
        result, errors = a.analyze()
        assert result["body_mlil_skeleton_vector"] == []
        assert result["body_mlil_typed_vector"] == []
        assert errors == []

    @patch(
        "redb.extractors.decompiler.bninja.analysis.medium_level.MinHasher"
    )
    def test_analyze_sha256_differs_skeleton_vs_typed(self, mock_minhasher):
        mock_minhasher.return_value.calculateMinHash.return_value = []

        instrs = [
            MockMLILInstruction(operation=1, address=0x1000, operands=[42]),
            MockMLILInstruction(operation=2, address=0x1004, operands=["foo"]),
            MockMLILInstruction(operation=3, address=0x1008, operands=[True]),
        ]
        a = self._make_analysis(instructions=instrs)
        result, _ = a.analyze()
        # skeleton ignores operand leaves, typed includes them -> different hashes
        assert result["sha256_mlil_skeleton"] != result["sha256_mlil_typed"]


class TestMinHasherMLILKinds:
    def _make_func(self, instrs):
        # MinHasher iterates basic_blocks then over each block
        block = MagicMock()
        block.__iter__ = lambda self_: iter(instrs)
        f = MagicMock()
        f.basic_blocks = [block]
        return f

    def test_mlil_skeleton_uses_medium_normalizer(self):
        from redb.extractors.decompiler.bninja.similarity.minhasher import (
            MinHasher, TokenKind,
        )
        instrs = [
            MockMLILInstruction(operation=i, operands=[]) for i in range(5)
        ]
        func = self._make_func(instrs)
        hasher = MinHasher(seed=42, il_function=func, kind=TokenKind.MLIL)
        result = hasher.calculateMinHash()
        # 5 instructions -> 3 trigrams -> non-empty signature
        assert result != []

    def test_typed_mlil_differs_from_skeleton(self):
        from redb.extractors.decompiler.bninja.similarity.minhasher import (
            MinHasher, TokenKind,
        )
        instrs = [
            MockMLILInstruction(operation=1, operands=[42]),
            MockMLILInstruction(operation=2, operands=["s"]),
            MockMLILInstruction(operation=3, operands=[True]),
            MockMLILInstruction(operation=4, operands=[1.5]),
        ]
        func = self._make_func(instrs)
        skel = MinHasher(seed=42, il_function=func, kind=TokenKind.MLIL).calculateMinHash()
        typed = MinHasher(seed=42, il_function=func, kind=TokenKind.TYPED_MLIL).calculateMinHash()
        # Same seed, same instructions, but typed has extra leaf tokens
        # -> hashes should generally differ
        assert skel != typed

    def test_mlil_too_few_instructions(self):
        from redb.extractors.decompiler.bninja.similarity.minhasher import (
            MinHasher, TokenKind,
        )
        instrs = [MockMLILInstruction(operation=1, operands=[])] * 2
        func = self._make_func(instrs)
        hasher = MinHasher(seed=42, il_function=func, kind=TokenKind.MLIL)
        assert hasher.calculateMinHash() == []

    def test_unsupported_kind_raises(self):
        from redb.extractors.decompiler.bninja.similarity.minhasher import MinHasher
        func = self._make_func([])
        hasher = MinHasher(seed=42, il_function=func, kind="bogus")
        with pytest.raises(ValueError):
            hasher.calculateMinHash()