Wei Wei

60 papers Journal 58Unranked 2
YearRankTypeTitle / Venue / Authors
2026 J jnl
CoRR
Chengyuan Yang, Zequn Sun, Wei Wei, Wei Hu
2025 conf
EMNLP (Findings)
Yi Liu, Xiangrong Zhu, Xiangyu Liu, Wei Wei, Wei Hu
2025 J jnl
CoRR
Yi Liu, Xiangrong Zhu, Xiangyu Liu, Wei Wei, Wei Hu
2025 J jnl
Unmanned Syst.
Caipei Yang, Jie Liu, Xuan Cai, Wei Wei, Ming-Feng Ge
2025 J jnl
IEEE Trans Autom. Sci. Eng.
Zhongjie Guo, Jiayu Bai, Wei Wei, Shengwei Mei, Weihao Hu
2025 J jnl
IEEE Trans Autom. Sci. Eng.
Zhaojian Wang, Wenxian Hao, Wei Wei, Zexin Sun
2025 J jnl
IEEE Trans. Smart Grid
Zhongjie Guo, Wei Wei, Yikui Liu, Weihao Hu, Chuanhao Hu
2024 J jnl
IEEE Trans. Smart Grid
Weilun Wang, Yikui Liu, Wei Wei, Lei Wu
2024 J jnl
IEEE Trans. Smart Grid
Santosh Sharma, Qifeng Li, Wei Wei
2024 J jnl
IEEE Trans. Smart Grid
Songjie Feng, Wei Wei, Yue Chen
2024 conf
ISGT Asia
Lianzhu Shan, Yu Ikemoto, Dai Zhang, Feng Liu, Wei Wei, Songjie Feng
2024 J jnl
CoRR
Rong-Peng Liu, Yunhe Hou, Yujia Li, Shunbo Lei, Wei Wei, Xiaozhe Wang
2023 J jnl
IEEE Trans Autom. Sci. Eng.
Peng Yang, Feng Liu, Wei Wei, Zhaojian Wang
2023 J jnl
IEEE Trans Autom. Sci. Eng.
Hongji Zhang, Tao Ding, Junjian Qi, Wei Wei, João P. S. Catalão, Mohammad Shahidehpour
2023 J jnl
IEEE CAA J. Autom. Sinica
Zhaojian Wang, Wei Wei, John Z. F. Pang, Feng Liu, Bo Yang, Xinping Guan, Shengwei Mei
2022 J jnl
IEEE Syst. J.
Ziqi Shen, Wei Wei, Tao Ding, Zhigang Li, Shengwei Mei
2022 J jnl
IEEE Trans. Smart Grid
Yi-De Wu, Ming-Feng Ge, Zhi-Wei Liu, Wen-Yi Zhang, Wei Wei
2022 J jnl
IEEE Trans. Smart Grid
Yue Chen, Wei Wei, Mingxuan Li, Laijun Chen, João P. S. Catalão
2022 J jnl
IEEE Trans. Ind. Electron.
Jing-Zhe Xu, Ming-Feng Ge, Zhi-Wei Liu, Wen-Yi Zhang, Wei Wei
2022 J jnl
IEEE Trans. Smart Grid
Boda Li, Ying Chen, Wei Wei, Zhaojian Wang, Shengwei Mei
2022 J jnl
IEEE Syst. J.
Zhongjie Guo, Wei Wei, Laijun Chen, Zhaojian Wang, João P. S. Catalão, Shengwei Mei
2022 J jnl
IEEE Syst. J.
Boda Li, Ying Chen, Wei Wei, Shengwei Mei, Yunhe Hou, Shanshan Shi
2022 J jnl
IEEE Syst. J.
Fazel Mohammadi, Behnam Mohammadi-Ivatloo, Gevork B. Gharehpetian, Mohd. Hasan Ali, Wei Wei, Ozan Erdinç, Mohammadamin Shirkhani
2022 J jnl
CoRR
Yue Chen, Wei Wei
2022 J jnl
IEEE Syst. J.
Yue Chen, Wei Wei, Cheng Wang, Miadreza Shafie-khah, João P. S. Catalão
2021 J jnl
IEEE Trans. Smart Grid
Yue Chen, Wei Wei, Han Wang, Quan Zhou, João P. S. Catalão
2021 J jnl
CoRR
Peng Yang, Feng Liu, Wei Wei, Zhaojian Wang
2021 J jnl
Autom.
Zhaojian Wang, Wei Wei, Changhong Zhao, Zhiyuan Ma, Zetian Zheng, Yunfan Zhang, Feng Liu
2021 J jnl
CoRR
Yue Chen, Wei Wei, Mingxuan Li, Laijun Chen, João P. S. Catalão
2021 J jnl
CoRR
Yue Chen, Wei Wei, Tongxin Li, Yunhe Hou, Feng Liu, João P. S. Catalão
2021 J jnl
IEEE Trans. Smart Grid
Boda Li, Ying Chen, Wei Wei, Shaowei Huang, Shengwei Mei
2021 J jnl
CoRR
Yue Chen, Wei Wei, Cheng Wang, Miadreza Shafie-khah, João P. S. Catalão
2021 J jnl
IEEE Trans. Ind. Informatics
Yang Cao, Wei Wei, Laijun Chen, Qiuwei Wu, Shengwei Mei
2020 J jnl
Comput. Chem. Eng.
Wei Wei, Danman Wu, Zhaojian Wang, Miadreza Shafie-khah, João P. S. Catalão
2020 J jnl
IEEE Trans. Smart Grid
Ming Qu, Tao Ding, Wei Wei, Zhaoyang Dong, Mohammad Shahidehpour, Shiwei Xia
2020 J jnl
IEEE Trans. Smart Grid
Yue Chen, Shengwei Mei, Fengyu Zhou, Steven H. Low, Wei Wei, Feng Liu
2020 J jnl
CoRR
Yanqi Liu, Zhigang Li, Wei Wei, Jiehui Zheng
2020 J jnl
IEEE Trans. Smart Grid
Cheng Wang, Zhihao Gong, Yile Liang, Wei Wei, Tianshu Bi
2020 J jnl
IEEE Trans. Smart Grid
Feifan Shen, Qiuwei Wu, Jin Zhao, Wei Wei, Nikos D. Hatziargyriou, Feng Liu
2020 J jnl
Syst. Control. Lett.
Zhaojian Wang, Feng Liu, Changhong Zhao, Zhiyuan Ma, Wei Wei
2020 J jnl
IEEE Trans. Ind. Informatics
Tao Ding, Yiting Xu, Wei Wei, Lei Wu
2020 J jnl
IEEE Trans. Smart Grid
Zhongjie Guo, Wei Wei, Laijun Chen, Zhaojian Wang, Shengwei Mei
2020 J jnl
IEEE Trans. Veh. Technol.
Rui Xie, Wei Wei, Qiuwei Wu, Tao Ding, Shengwei Mei
2019 J jnl
IEEE Trans. Ind. Informatics
Yile Liang, Wei Wei, Cheng Wang
2019 J jnl
IEEE Trans. Smart Grid
Yang Cao, Wei Wei, Lei Wu, Shengwei Mei, Mohammad Shahidehpour, Zhiyi Li
2019 J jnl
CoRR
Zhaojian Wang, Feng Liu, Zhiyuan Ma, Yue Chen, Mengshuo Jia, Wei Wei, Qiuwei Wu
2019 J jnl
CoRR
Zhaojian Wang, Feng Liu, Changhong Zhao, Zhiyuan Ma, Wei Wei
2019 J jnl
IEEE Access
Wei Wei, Longxian Hu, Qiuwei Wu, Tao Ding
2019 J jnl
IEEE Trans. Smart Grid
Yue Chen, Wei Wei, Feng Liu, Enzo E. Sauma, Shengwei Mei
2019 J jnl
IEEE Trans. Smart Grid
Rui Li, Wei Wei, Shengwei Mei, Qinran Hu, Qiuwei Wu
2019 J jnl
IEEE Access
Yang Cao, Wei Wei, Cheng Wang, Shengwei Mei, Shaowei Huang, Xuemin Zhang
2019 J jnl
IEEE Trans. Smart Grid
Zhaoxi Liu, Qiuwei Wu, Mohammad Shahidehpour, Canbing Li, Shaojun Huang, Wei Wei
2018 J jnl
IEEE Trans. Smart Grid
Wei Wei, Lei Wu, Jianhui Wang, Shengwei Mei
2017 J jnl
IEEE Trans. Smart Grid
Xindong Liu, Mohammad Shahidehpour, Yijia Cao, Lei Wu, Wei Wei, Xuan Liu
2017 J jnl
IEEE Trans. Smart Grid
Wei Wei, Jianhui Wang, Na Li, Shengwei Mei
2017 J jnl
IEEE Trans. Smart Grid
Wei Wei, Shengwei Mei, Lei Wu, Mohammad Shahidehpour, Yujuan Fang
2016 J jnl
IEEE Trans. Smart Grid
Wei Wei, Feng Liu, Shengwei Mei
2016 J jnl
CoRR
Rui Yao, Shaowei Huang, Kai Sun, Feng Liu, Xuemin Zhang, Shengwei Mei, Wei Wei, Lijie Ding
2015 J jnl
IEEE Trans. Smart Grid
Wei Wei, Feng Liu, Shengwei Mei
2015 J jnl
IEEE Trans. Smart Grid
Wei Wei, Feng Liu, Shengwei Mei, Yunhe Hou
redb/extractors/decompiler/_archive/GhidraDecompilerScript-latest.java
← Index redb/extractors/decompiler/_archive/GhidraDecompilerScript-latest.java java
import ghidra.app.script.GhidraScript;
import ghidra.program.model.listing.*;
import ghidra.app.decompiler.*;
import ghidra.program.model.block.*;
import ghidra.program.model.symbol.*;
import ghidra.program.model.pcode.*;
import ghidra.program.model.address.*;
import org.json.JSONObject;
import org.json.JSONArray;
import java.security.MessageDigest;
import java.nio.charset.StandardCharsets;

public class GhidraDecompilerScript extends GhidraScript {
    private DecompInterface decompInterface;
    private BasicBlockModel basicBlockModel;
    
    @Override
    public void run() throws Exception {
        // Get binary hash and filepath from arguments
        String[] args = getScriptArgs();
        if (args.length < 2) {
            System.err.println("{\"error\": \"Both SHA256 and filepath arguments are required\"}");
            return;
        }
        String sha256 = args[0];
        String filepath = args[1];

        // Initialize analysis components
        setupDecompiler();
        basicBlockModel = new BasicBlockModel(currentProgram);

        // Create the main JSON object for output
        JSONObject output = new JSONObject();
        output.put("sha256", sha256);
        output.put("decompiled", new JSONArray());
        output.put("disassembled", new JSONArray());
        output.put("cfg", new JSONArray());

        // Process all functions
        FunctionIterator functions = currentProgram.getFunctionManager().getFunctions(true);
        for (Function function : functions) {
            processFunction(function, output);
        }

        // Output the final JSON to stdout
        System.out.println(output.toString());
    }

    private void setupDecompiler() {
        decompInterface = new DecompInterface();
        DecompileOptions options = new DecompileOptions();
        decompInterface.setOptions(options);
        decompInterface.openProgram(currentProgram);
    }

    private void processFunction(Function function, JSONObject output) {
        Address entry = function.getEntryPoint();
        String functionName = function.getName();
        String functionAddress = entry.toString();

        // Process decompiled code
        processDecompiledCode(function, output.getJSONArray("decompiled"), 
                            functionName, functionAddress);

        // Process disassembled code
        processDisassembledCode(function, output.getJSONArray("disassembled"), 
                              functionName, functionAddress);

        // Process CFG
        processCFG(function, output.getJSONArray("cfg"), functionAddress);
    }

    private void processDecompiledCode(Function function, JSONArray decompArray, 
                                     String functionName, String functionAddress) {
        DecompileResults results = decompInterface.decompileFunction(function, 30, monitor);
        if (results.decompileCompleted()) {
            String decompiledCode = results.getDecompiledFunction().getC();
            String contentHash = calculateHash(decompiledCode);

            JSONObject functionObj = new JSONObject();
            functionObj.put("decompiled_content_hash", contentHash);
            functionObj.put("decompiled_function_name", functionName);
            functionObj.put("decompiled_function_address", functionAddress);
            functionObj.put("decompiled_function", decompiledCode);
            
            decompArray.put(functionObj);
        }
    }

    private void processDisassembledCode(Function function, JSONArray disasmArray, 
                                       String functionName, String functionAddress) {
        try {
            StringBuilder disassembly = new StringBuilder();
            StringBuilder normalized = new StringBuilder();
            int instructionCount = 0;

            Listing listing = currentProgram.getListing();
            AddressSetView functionBody = function.getBody();
            InstructionIterator instructions = listing.getInstructions(functionBody, true);

            while (instructions.hasNext()) {
                try {
                    Instruction instr = instructions.next();
                    String disasmLine = instr.toString();
                    disassembly.append(disasmLine).append("\n");
                    normalized.append(normalizeInstruction(disasmLine)).append("\n");
                    instructionCount++;
                } catch (Exception e) {
                    System.err.println("Error processing instruction in " + functionName + ": " + e.getMessage());
                }
            }

            String disassembledCode = disassembly.toString();
            String contentHash = calculateHash(disassembledCode);

            JSONObject functionObj = new JSONObject();
            functionObj.put("disassembled_content_hash", contentHash);
            functionObj.put("disassembled_function_name", functionName);
            functionObj.put("disassembled_function_address", functionAddress);
            functionObj.put("disassembled_function", disassembledCode);
            functionObj.put("normalized_disassembly", normalized.toString());
            functionObj.put("instruction_count", instructionCount);

            // Set similarity-related fields to null for now
            functionObj.put("minhash_signature", JSONObject.NULL);
            functionObj.put("opcode_frequency_vector", JSONObject.NULL);
            functionObj.put("api_calls_vector", JSONObject.NULL);
            functionObj.put("instruction_embedding", JSONObject.NULL);

            disasmArray.put(functionObj);
        } catch (Exception e) {
            System.err.println("Error processing disassembly for " + functionName + ": " + e.getMessage());
        }
    }

    private void processCFG(Function function, JSONArray cfgArray, String functionAddress) {
        try {
            CodeBlockIterator blocks = basicBlockModel.getCodeBlocksContaining(
                function.getBody(), monitor);

            while (blocks.hasNext()) {
                CodeBlock block = blocks.next();
                String blockInstructions = getBlockInstructions(block);
                String blockId = calculateHash(blockInstructions);

                JSONObject blockObj = new JSONObject();
                blockObj.put("block_id", blockId);
                blockObj.put("function_address", functionAddress);
                blockObj.put("block_instructions", blockInstructions);

                // Get successor blocks
                CodeBlockReferenceIterator successors = block.getDestinations(monitor);
                JSONArray successorAddresses = new JSONArray();
                while (successors.hasNext()) {
                    CodeBlockReference ref = successors.next();
                    successorAddresses.put(ref.getDestinationAddress().toString());
                }
                blockObj.put("successor_blocks", successorAddresses);

                cfgArray.put(blockObj);
            }
        } catch (Exception e) {
            System.err.println("{\"error\": \"Error processing CFG: " + 
                             e.getMessage().replace("\"", "'") + "\"}");
        }
    }

    private String normalizeInstruction(String instruction) {
        return instruction.replaceAll("0x[0-9a-fA-F]+", "IMM")
                        .replaceAll("\\b\\d+\\b", "NUM");
    }

    private String getBlockInstructions(CodeBlock block) {
        StringBuilder instructions = new StringBuilder();
        AddressIterator addresses = block.getAddresses(true);
        while (addresses.hasNext()) {
            Address addr = addresses.next();
            Instruction instr = currentProgram.getListing().getInstructionAt(addr);
            if (instr != null) {
                instructions.append(instr.toString()).append("\n");
            }
        }
        return instructions.toString();
    }

    private String calculateHash(String content) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest(content.getBytes(StandardCharsets.UTF_8));
            StringBuilder hexString = new StringBuilder();
            for (byte b : hash) {
                hexString.append(String.format("%02x", b));
            }
            return hexString.toString();
        } catch (Exception e) {
            System.err.println("{\"error\": \"Error calculating hash\"}");
            return "";
        }
    }
}