LC_CONFIG is now initialized with the proper logging level (resolved #9); replaced simplelog with env_logger; updated to latest leechcore version

main
ko1N 10 months ago
parent 370530ff5b
commit 04894ce6a7

723
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 02bc33dbed91d7df94e9514ba3b8c0454c3a727a
Subproject commit 6ebec0adef99d267eb56d3eddc720b2d54eb4de7

@ -19,9 +19,10 @@ crate-type = ["lib", "cdylib"]
memflow = { version = "0.2", features = ["plugins", "memmapfiles"] }
leechcore-sys = { version = "0.2", path = "../leechcore-sys" }
log = "0.4"
parking_lot = "0.12"
[dev-dependencies]
simplelog = "0.12"
env_logger = "0.11"
memflow-win32 = { version = "0.2" }
[features]

@ -17,18 +17,12 @@ or in any other path found in the official memflow documentation.
*/
use std::env::args;
use log::{info, Level};
use log::info;
use memflow::prelude::v1::*;
fn main() {
simplelog::TermLogger::init(
Level::Debug.to_level_filter(),
simplelog::Config::default(),
simplelog::TerminalMode::Stdout,
simplelog::ColorChoice::Auto,
)
.unwrap();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
let connector_args = if let Some(arg) = args().nth(1) {
arg.parse()

@ -15,19 +15,13 @@ https://docs.rs/memflow/0.1.5/memflow/connector/inventory/index.html
*/
use std::env::args;
use log::{info, Level};
use log::info;
use memflow::prelude::v1::*;
use memflow_win32::prelude::v1::*;
fn main() {
simplelog::TermLogger::init(
Level::Debug.to_level_filter(),
simplelog::Config::default(),
simplelog::TerminalMode::Stdout,
simplelog::ColorChoice::Auto,
)
.unwrap();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
let connector_args = if let Some(arg) = args().nth(1) {
arg.parse()

@ -6,18 +6,12 @@ and prints them to stdout.
use std::env::args;
use std::time::Instant;
use log::{info, Level};
use log::info;
use memflow::prelude::v1::*;
fn main() {
simplelog::TermLogger::init(
Level::Debug.to_level_filter(),
simplelog::Config::default(),
simplelog::TerminalMode::Stdout,
simplelog::ColorChoice::Auto,
)
.unwrap();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
let connector_args = if let Some(arg) = args().nth(1) {
arg.parse()

@ -1,11 +1,13 @@
use ::std::ptr::null_mut;
use parking_lot::Mutex;
use std::ffi::c_void;
use std::os::raw::c_char;
use std::path::Path;
use std::ptr;
use std::ptr::null_mut;
use std::slice;
use std::sync::{Arc, Mutex};
use std::sync::Arc;
use log::LevelFilter;
use log::{error, info};
use memflow::cglue;
@ -26,6 +28,25 @@ const BUF_LEN_ALIGN: usize = 8;
cglue_impl_group!(PciLeech, ConnectorInstance<'a>, {});
fn build_lc_config(device: &str, remote: Option<&str>, with_mem_map: bool) -> LC_CONFIG {
// configure verbosity based on current level
let printf_verbosity = match log::max_level() {
LevelFilter::Off => 0,
LevelFilter::Error | LevelFilter::Warn => LC_CONFIG_PRINTF_ENABLED,
LevelFilter::Info => LC_CONFIG_PRINTF_ENABLED | LC_CONFIG_PRINTF_V,
LevelFilter::Debug => {
LC_CONFIG_PRINTF_ENABLED
| LC_CONFIG_PRINTF_V
| LC_CONFIG_PRINTF_ENABLED
| LC_CONFIG_PRINTF_VV
}
LevelFilter::Trace => {
LC_CONFIG_PRINTF_ENABLED
| LC_CONFIG_PRINTF_V
| LC_CONFIG_PRINTF_ENABLED
| LC_CONFIG_PRINTF_VVV
}
};
// TODO: refactor how the static strings are handled
let cdevice = unsafe { &*(device.as_bytes() as *const [u8] as *const [c_char]) };
let mut adevice: [c_char; 260] = [0; 260];
@ -43,7 +64,7 @@ fn build_lc_config(device: &str, remote: Option<&str>, with_mem_map: bool) -> LC
LC_CONFIG {
dwVersion: LC_CONFIG_VERSION,
dwPrintfVerbosity: LC_CONFIG_PRINTF_ENABLED | LC_CONFIG_PRINTF_V | LC_CONFIG_PRINTF_VV,
dwPrintfVerbosity: printf_verbosity,
szDevice: adevice,
szRemote: aremote,
pfn_printf_opt: None, // TODO: custom info() wrapper
@ -157,6 +178,7 @@ impl PciLeech {
}
}
#[allow(clippy::arc_with_non_send_sync)]
Ok(Self {
handle: Arc::new(Mutex::new(handle)),
conf,
@ -271,7 +293,7 @@ impl PhysicalMemory for PciLeech {
// dispatch read
{
let handle = self.handle.lock().unwrap();
let handle = self.handle.lock();
unsafe {
LcReadScatter(*handle, num_pages as u32, mems);
}
@ -429,7 +451,7 @@ impl PhysicalMemory for PciLeech {
// dispatch write
{
let handle = self.handle.lock().unwrap();
let handle = self.handle.lock();
unsafe {
LcWriteScatter(*handle, num_pages as u32, mems);
}

Loading…
Cancel
Save