<commit_before>use log::{debug};
use goblin::{Object};
use failure::{Error};
use byteorder::{ByteOrder, LittleEndian};

use super::super::super::arch::{RVA};
use super::super::super::workspace::Workspace;
use super::super::{Analyzer};


pub struct RuntimeFunctionAnalyzer {}

impl RuntimeFunctionAnalyzer {
    pub fn new() -> RuntimeFunctionAnalyzer {
        RuntimeFunctionAnalyzer {}
    }
}


struct RuntimeFunction {
    begin_address: RVA,
    end_address: RVA,
    unwind_data: RVA,
}


impl std::fmt::Debug for RuntimeFunction {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "RUNTIME_FUNCTION(begin: {:#x} end: {:#x} data: {:#x})",
               self.begin_address,
               self.end_address,
               self.unwind_data
        )
    }
}


impl Analyzer for RuntimeFunctionAnalyzer {
    fn get_name(&self) -> String {
        "RUNTIME_FUNCTION analyzer".to_string()
    }

    /// ```
    /// use lancelot::rsrc::*;
    /// use lancelot::arch::*;
    /// use lancelot::analysis::Analyzer;
    /// use lancelot::workspace::Workspace;
    /// use lancelot::analysis::pe::RuntimeFunctionAnalyzer;
    ///
    /// let mut ws = Workspace::from_bytes("k32.dll", &get_buf(Rsrc::K32))
    ///    .disable_analysis()
    ///    .load().unwrap();
    /// let anal = RuntimeFunctionAnalyzer::new();
    /// anal.analyze(&mut ws).unwrap();
    ///
    /// assert!(ws.get_meta(0x72A70).unwrap().is_insn());
    ///
    /// // this function is referenced in RUNTIME_FUNCTIONs,
    /// // and in code, tail jump at 0x1800112C2
    /// //
    /// //     .text:00000001800112C2     jmp     sub_1800019C8
    /// //
    /// assert!(ws.get_meta(0x19C8).unwrap().is_insn());
    /// ```
    fn analyze(&self, ws: &mut Workspace) -> Result<(), Error> {
        let (exception_directory, directory_size) = {
            let pe = match Object::parse(&ws.buf) {
                Ok(Object::PE(pe)) => pe,<commit_msg>analysis/runtimefunctions: tests passing again<commit_after>use log::{debug};
use goblin::{Object};
use failure::{Error};
use byteorder::{ByteOrder, LittleEndian};

use super::super::super::arch::{RVA};
use super::super::super::workspace::Workspace;
use super::super::{Analyzer};


pub struct RuntimeFunctionAnalyzer {}

impl RuntimeFunctionAnalyzer {
    pub fn new() -> RuntimeFunctionAnalyzer {
        RuntimeFunctionAnalyzer {}
    }
}


struct RuntimeFunction {
    begin_address: RVA,
    end_address: RVA,
    unwind_data: RVA,
}


impl std::fmt::Debug for RuntimeFunction {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "RUNTIME_FUNCTION(begin: {:#x} end: {:#x} data: {:#x})",
               self.begin_address,
               self.end_address,
               self.unwind_data
        )
    }
}


impl Analyzer for RuntimeFunctionAnalyzer {
    fn get_name(&self) -> String {
        "RUNTIME_FUNCTION analyzer".to_string()
    }

    /// ```
    /// use lancelot::rsrc::*;
    /// use lancelot::arch::*;
    /// use lancelot::analysis::Analyzer;
    /// use lancelot::workspace::Workspace;
    /// use lancelot::analysis::pe::RuntimeFunctionAnalyzer;
    ///
    /// let mut ws = Workspace::from_bytes("k32.dll", &get_buf(Rsrc::K32))
    ///    .disable_analysis()
    ///    .load().unwrap();
    /// let anal = RuntimeFunctionAnalyzer::new();
    /// anal.analyze(&mut ws).unwrap();
    ///
    /// assert!(ws.get_meta(RVA(0x72A70)).unwrap().is_insn());
    ///
    /// // this function is referenced in RUNTIME_FUNCTIONs,
    /// // and in code, tail jump at 0x1800112C2
    /// //
    /// //     .text:00000001800112C2     jmp     sub_1800019C8
    /// //
    /// assert!(ws.get_meta(RVA(0x19C8)).unwrap().is_insn());
    /// ```
    fn analyze(&self, ws: &mut Workspace) -> Result<(), Error> {
        let (exception_directory, directory_size) = {
            let pe = match Object::parse(&ws.buf) {
                Ok(Object::PE(pe)) => pe,
{'fraction_non_alphanumeric': 0.17970134143254873, 'fraction_numerical': 0.022779043280182234, 'mean_word_length': 2.6290174471992653, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 2, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2346643', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1289, 'n_words': 238}