1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! A Rust library and tools providing easy access to the
//! [retdec.com](https://retdec.com) decompilation service through their public
//! [REST API](https://retdec.com/api/).
//!
//! You can either incorporate the library in your own tools:
//!
//! ```no_run
//! # use retdec::error::Result;
//! use retdec::{Decompiler, DecompilationArguments, File, Settings};
//!
//! # fn test() -> Result<()> {
//! let decompiler = Decompiler::new(
//!     Settings::new()
//!         .with_api_key("YOUR-API-KEY")
//! );
//! let mut decompilation = decompiler.start_decompilation(
//!     DecompilationArguments::new()
//!         .with_input_file(File::from_path("hello.exe")?)
//! )?;
//! decompilation.wait_until_finished()?;
//! let output_code = decompilation.get_output_hll_code()?;
//! print!("{}", output_code);
//! # Ok(()) }
//! ```
//!
//! or you can use the provided tool for stand-alone decompilations:
//!
//! ```text
//! $ decompiler -k YOUR-API-KEY hello.exe
//! ```
//!
//! Either way, you get the decompiled C code:
//!
//! ```text
//! //
//! // This file was generated by the Retargetable Decompiler
//! // Website: https://retdec.com
//! // Copyright (c) 2017 Retargetable Decompiler <info@retdec.com>
//! //
//!
//! int main(int argc, char ** argv) {
//!     printf("Hello, world!\n");
//!     return 0;
//! }
//! ```
//!
//! # Status
//!
//! Currently, the crate only provides very basic support for the
//! [decompilation](https://retdec.com/api/docs/decompiler.html) and
//! [file-analyzing](https://retdec.com/api/docs/fileinfo.html) services. **Support
//! for more features is under way as the crate is under development.**
//!
//! A summary of all the currently supported parts of the [retdec.com's
//! API](https://retdec.com/api/docs/index.html) is available
//! [here](https://github.com/s3rvac/retdec-rust/tree/master/STATUS.md).
//!
//! # License
//!
//! Licensed under either of
//!
//! * Apache License, Version 2.0,
//!   ([LICENSE-APACHE](https://github.com/s3rvac/retdec-rust/tree/master/LICENSE-APACHE)
//!   or http://www.apache.org/licenses/LICENSE-2.0)
//! * MIT License
//!   ([LICENSE-MIT](https://github.com/s3rvac/retdec-rust/tree/master/LICENSE-APACHE)
//!   or http://opensource.org/licenses/MIT)
//!
//! at your option.

// `error_chain!` can recurse deeply.
#![recursion_limit = "1024"]

// Add more lint checks.
#![deny(unsafe_code)]
#![deny(unstable_features)]
#![warn(missing_docs)]
#![warn(trivial_casts)]
#![warn(trivial_numeric_casts)]
#![warn(unused_extern_crates)]
#![warn(unused_import_braces)]
#![warn(unused_qualifications)]

extern crate clap;
extern crate hyper;
extern crate hyper_native_tls;
extern crate json;
extern crate regex;
extern crate multipart;
extern crate unidecode;
#[macro_use]
extern crate error_chain;

/// Crate version.
pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");

pub mod analysis;
pub mod decompilation;
pub mod decompiler;
pub mod error;
pub mod file;
pub mod fileinfo;
pub mod settings;
pub mod test;
pub mod tools;

// Reexports.
pub use analysis::Analysis;
pub use analysis::AnalysisArguments;
pub use decompilation::Decompilation;
pub use decompilation::DecompilationArguments;
pub use decompiler::Decompiler;
pub use error::Error;
pub use error::Result;
pub use file::File;
pub use fileinfo::Fileinfo;
pub use settings::Settings;

mod connection;
mod resource;
mod utils;