Code Monkey home page Code Monkey logo

faser's People

Contributors

br0kej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

faser's Issues

Error when creating nlp from cfg

Was getting some errors when generating esil and disasm from cfg.
Error creating file "test_file_cfg"-dis-singles.txt: No such file or directory (os error 2)

I looks like it was adding a " to the text file.

I modified the code and it works now. I will continue to look at other features to make sure no other bugs are found.

    /// Generates a file containing every instruction within each of the functions
    /// within the AGFJFile.
    ///
    /// This ignores control flow and simple iterates the JSON objects from the top to
    /// the bottom.
    pub fn generate_linear_bb_walk(mut self, esil: bool) {
        //let fname_string: PathBuf = get_save_file_path(&self.filename, &self.output_path, None, None);
        //let fname_string = if esil {format!("{:?}-esil-singles.txt", fname_string)} else {format!("{:?}-dis-singles.txt", fname_string)};

        let fname_string: PathBuf = get_save_file_path(&self.filename, &self.output_path, None, None);
        let fname_string = if esil {format!("{}-esil-singles.txt", fname_string.display())} else {format!("{}-dis-singles.txt", fname_string.display())};

        if !Path::new(&fname_string).exists() {
            self.load_and_deserialize()
                .expect("Unable to load and desearlize JSON");

            let (sender, receiver) = channel();

            self.functions.unwrap().par_iter_mut().for_each_with(
                sender,
                |s, func: &mut Vec<AGFJFunc>| {
                    s.send(func[0].get_function_instructions(esil, &self.min_blocks, self.reg_norm))
                        .unwrap()
                },
            );

            let res: Vec<Vec<String>> = receiver.iter().filter(|x| x.is_some()).flatten().collect();

            //let write_file = File::create(fname_string).unwrap();
            let write_file = match File::create(&fname_string) {
                Ok(file) => file,
                Err(e) => {
                    //eprintln!("Error creating file: {}", e);
                    eprintln!("Error creating file {}: {}", fname_string, e);
                    return;
                }
            };

            let mut writer = BufWriter::new(&write_file);

            for func in res {
                for bb in func {
                    writer
                        .write_all(bb.as_bytes())
                        .expect("Unable to write bytes.");
                    writer.write_all(b"\n").expect("Unable to write bytes.");
                }
            }
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.