Hanqiang Cao

15 papers B 1C 1Journal 7Unranked 6
YearRankTypeTitle / Venue / Authors
2021 J jnl
CoRR
Olivier Rukundo, Hanqiang Cao
2021 J jnl
Appl. Intell.
Chunyi Yue, Hanqiang Cao, Guoping Xu, Youli Dong
2021 J jnl
Comput. Medical Imaging Graph.
Guoping Xu, Hanqiang Cao, Jayaram K. Udupa, Yubing Tong, Drew A. Torigian
2020 conf
ICBBS
Guoping Xu, Hanqiang Cao, Guoxing Jiang
2018 B conf
Image Processing
Guoping Xu, Jayaram K. Udupa, Yubing Tong, Hanqiang Cao, Dewey Odhner, Drew A. Torigian, Xingyu Wu
2017 J jnl
Expert Syst. Appl.
Chunyi Yue, Hanqiang Cao, Kun Xiong, Anqi Cui, Haocheng Qin, Ming Li
2016 J jnl
IEEE Commun. Lett.
Yongping Wang, Hanqiang Cao
2015 J jnl
IEEE Commun. Lett.
Yongping Wang, Hanqiang Cao
2012 J jnl
CoRR
Olivier Rukundo, Hanqiang Cao
2006 conf
Visual Information Processing
Sheng Yi, Hanqiang Cao, Xutao Li, Miao Liu
2006 conf
Visual Information Processing
Sheng Yi, Hanqiang Cao, Xutao Li, Miao Liu
2006 conf
Visual Information Processing
Xutao Li, Hanqiang Cao, Guangxi Zhu, Sheng Yi
2006 conf
Visual Information Processing
Miao Liu, Hanqiang Cao, Xutao Li, Sheng Yi
2002 C conf
VCIP
Hanqiang Cao, Guangxi Zhu, Yaoting Zhu, Zhaoqun Zhang, Rujun Chen, Xutao Li, Hongyan Zhao
1997 conf
Visual Information Processing
Zhengbing Zhang, Guangxi Zhu, Yaoting Zhu, Hanqiang Cao
tests/scripts/test_linking.py
← Index tests/scripts/test_linking.py python
#!/usr/bin/env python3
"""
Test script to verify the linking between decompiled and disassembled functions.
"""

import sys
import os
from pathlib import Path

# Add the redb directory to the path
sys.path.insert(0, str(Path(__file__).parent / "redb"))

from redb.extractors.decompiler.DecompileBinja import DecompileBinja
import logging

def test_linking():
    """Test that decompiled and disassembled functions are properly linked."""
    
    # Setup logging
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger("test_linking")
    
    # Use a simple test binary (you'll need to provide a path to a test binary)
    test_binary = "test_files/hello"  # Adjust this path as needed
    
    if not os.path.exists(test_binary):
        print(f"Test binary not found: {test_binary}")
        print("Please provide a valid binary path for testing")
        return False
    
    try:
        # Create and run the extractor
        with DecompileBinja(test_binary, logger) as extractor:
            success = extractor.extract()
            
            if not success:
                print("Extraction failed")
                return False
            
            # Get the analysis results
            results = extractor.analysis_results
            
            if not results:
                print("No analysis results")
                return False
            
            print(f"Analysis completed successfully")
            print(f"Decompiled functions: {len(results['decompiled'])}")
            print(f"Disassembled functions: {len(results['disassembled'])}")
            
            # Test linking
            linking_issues = []
            linked_pairs = 0
            decompiled_only = 0
            disassembled_only = 0
            
            # Check decompiled functions have proper linking
            for decomp_func in results['decompiled']:
                decomp_hash = decomp_func.get('decompiled_function_hash')
                disasm_hash = decomp_func.get('disassembled_function_hash')
                
                if disasm_hash is None:
                    decompiled_only += 1
                    print(f"⚠️  Decompiled function {decomp_func.get('decompiled_function_name')} has no disassembled link (decompiled-only)")
                else:
                    linked_pairs += 1
                    print(f"✓ Decompiled function {decomp_func.get('decompiled_function_name')} linked to disassembled hash: {disasm_hash[:16]}...")
            
            # Check disassembled functions have proper linking
            for disasm_func in results['disassembled']:
                disasm_hash = disasm_func.get('disassembled_function_hash')
                decomp_hash = disasm_func.get('decompiled_function_hash')
                
                if decomp_hash is None:
                    disassembled_only += 1
                    print(f"⚠️  Disassembled function {disasm_func.get('disassembled_function_name')} has no decompiled link (disassembled-only)")
                else:
                    print(f"✓ Disassembled function {disasm_func.get('disassembled_function_name')} linked to decompiled hash: {decomp_hash[:16]}...")
            
            # Verify cross-references are consistent
            decompiled_hashes = {f['decompiled_function_hash']: f for f in results['decompiled']}
            disassembled_hashes = {f['disassembled_function_hash']: f for f in results['disassembled']}
            
            for decomp_func in results['decompiled']:
                decomp_hash = decomp_func.get('decompiled_function_hash')
                disasm_hash = decomp_func.get('disassembled_function_hash')
                
                if disasm_hash and disasm_hash in disassembled_hashes:
                    corresponding_disasm = disassembled_hashes[disasm_hash]
                    if corresponding_disasm.get('decompiled_function_hash') != decomp_hash:
                        linking_issues.append(f"Inconsistent linking: decompiled {decomp_hash[:16]}... -> disassembled {disasm_hash[:16]}... but reverse link doesn't match")
            
            # Summary
            print(f"\n📊 Linking Summary:")
            print(f"  - Linked function pairs: {linked_pairs}")
            print(f"  - Decompiled-only functions: {decompiled_only}")
            print(f"  - Disassembled-only functions: {disassembled_only}")
            print(f"  - Total functions processed: {len(results['decompiled']) + len(results['disassembled'])}")
            
            if linking_issues:
                print(f"\n❌ Linking issues found:")
                for issue in linking_issues:
                    print(f"  - {issue}")
                return False
            else:
                print(f"\n✅ All linking tests passed!")
                print(f"✅ Cross-references are consistent!")
                return True
                
    except Exception as e:
        print(f"Test failed with exception: {e}")
        return False

if __name__ == "__main__":
    success = test_linking()
    sys.exit(0 if success else 1)