feat: 解析导入表
This commit is contained in:
@@ -173,7 +173,7 @@ impl AppState {
|
||||
import_module.module_name_rva = origin_item.name;
|
||||
import_module.timestamp = origin_item.time_date_stamp;
|
||||
// 2. 获取函数表
|
||||
let mut functions: Vec<ImportFunctionTableItem> = Vec::new();
|
||||
let mut functions: Vec<ImportFunctionTable> = Vec::new();
|
||||
// 获取函数表的FOA
|
||||
let mut base_offset = mmap.rva_to_foa(origin_item.original_first_thunk)? as usize;
|
||||
// 循环解析函数表
|
||||
@@ -222,10 +222,11 @@ impl AppState {
|
||||
CStr::from_ptr(ptr).to_str()?.to_string()
|
||||
};
|
||||
import_function_table.function_name = function_name;
|
||||
functions.push(ImportFunctionTableItem::Named(import_function_table));
|
||||
functions.push(import_function_table);
|
||||
}
|
||||
false => {
|
||||
functions.push(ImportFunctionTableItem::Ordinal(import_function_table));
|
||||
import_function_table.function_type = ImportFunctionTableItem::Ordinal;
|
||||
functions.push(import_function_table);
|
||||
}
|
||||
}
|
||||
// 下一个
|
||||
@@ -242,7 +243,7 @@ impl AppState {
|
||||
#[derive(Debug, Default, Clone, Serialize)]
|
||||
pub struct ImportModuleTable {
|
||||
pub module_name: String, // 模块名称
|
||||
pub functions: Vec<ImportFunctionTableItem>, // 这里要另一个结构体来描述
|
||||
pub functions: Vec<ImportFunctionTable>, // 这里要另一个结构体来描述
|
||||
pub timestamp: u32, // 时间戳
|
||||
pub forwarder_chain: u32, // 转发链
|
||||
pub module_name_rva: u32, // dll名称的RVA
|
||||
@@ -251,12 +252,13 @@ pub struct ImportModuleTable {
|
||||
}
|
||||
|
||||
// 因为导入查找表可能是函数名、也可能是序号 所以用枚举包一下最好
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize, Default)]
|
||||
pub enum ImportFunctionTableItem {
|
||||
// 命名的导入函数
|
||||
Named(ImportFunctionTable),
|
||||
#[default]
|
||||
Named,
|
||||
// 序号表示的
|
||||
Ordinal(ImportFunctionTable),
|
||||
Ordinal,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Serialize)]
|
||||
@@ -264,4 +266,5 @@ pub struct ImportFunctionTable {
|
||||
pub function_name: String, // 函数名称
|
||||
pub function_address: u32, // 函数地址 IAT
|
||||
pub function_hint: u16, // 函数提示
|
||||
pub function_type: ImportFunctionTableItem
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user