fix: 修复一个bug&引入32和64位的版本

This commit is contained in:
381848900@qq.com 2024-12-11 20:11:17 +08:00
parent 25529dd73d
commit d7038a42d8
2 changed files with 518 additions and 266 deletions

View File

@ -65,6 +65,7 @@ pub fn get_file_header_data() -> Result<ResponseFileHeaderData, AppError> {
pub struct ResponseOptionalHeaderData {
pub fields: ImageOptionalHeader,
pub base_offset: usize,
pub is_64_bit: bool,
}
@ -73,9 +74,11 @@ pub fn get_optional_header_data() -> Result<ResponseOptionalHeaderData, AppError
let file_data = binding.as_ref().unwrap();
let optional_header = file_data.get_optional_header()?;
let optional_header_offset = file_data.get_optional_header_offset()?;
let is_64_bit = file_data.is_64_bit()?;
let result = ResponseOptionalHeaderData {
fields: optional_header.clone(),
base_offset: optional_header_offset,
is_64_bit,
};
Ok(result)
}

View File

@ -4,9 +4,8 @@ import NodeTableComponent, {
} from "../NodeTableComponent/NodeTableComponent";
import { invoke } from "@tauri-apps/api/core";
export default function OptionalHeader() {
const [data, setData] = useState<any[]>([]);
const dataTemplate: DataTemplateInterface = {
const dataTemplate: DataTemplateInterface = {
magic: {
name: "magic",
offset: 0,
@ -71,10 +70,18 @@ export default function OptionalHeader() {
data_type: "hex",
description: "代码段基址",
},
base_of_data: {
name: "base_of_data",
offset: 24,
size: 4,
value: null,
data_type: "hex",
description: "数据段基址",
},
image_base: {
name: "image_base",
offset: 24,
size: 8,
offset: 28,
size: 4,
value: null,
data_type: "hex",
description: "映像基址",
@ -194,38 +201,38 @@ export default function OptionalHeader() {
size_of_stack_reserve: {
name: "size_of_stack_reserve",
offset: 72,
size: 8,
size: 4,
value: null,
data_type: "hex",
description: "堆栈保留大小",
},
size_of_stack_commit: {
name: "size_of_stack_commit",
offset: 80,
size: 8,
offset: 76,
size: 4,
value: null,
data_type: "hex",
description: "堆栈提交大小",
},
size_of_heap_reserve: {
name: "size_of_heap_reserve",
offset: 88,
size: 8,
offset: 80,
size: 4,
value: null,
data_type: "hex",
description: "堆保留大小",
},
size_of_heap_commit: {
name: "size_of_heap_commit",
offset: 96,
size: 8,
offset: 84,
size: 4,
value: null,
data_type: "hex",
description: "堆提交大小",
},
loader_flags: {
name: "loader_flags",
offset: 104,
offset: 88,
size: 4,
value: null,
data_type: "hex",
@ -233,15 +240,250 @@ export default function OptionalHeader() {
},
number_of_rva_and_sizes: {
name: "number_of_rva_and_sizes",
offset: 108,
offset: 92,
size: 4,
value: null,
data_type: "hex",
description: "RVA和大小数量",
},
};
const command = "command_get_pe_data_optional_header";
const columns = [
};
const dataTemplate64: DataTemplateInterface = {
magic: {
name: "magic",
offset: 0,
size: 2,
value: null,
data_type: "hex",
description: "PE文件标志",
},
major_linker_version: {
name: "major_linker_version",
offset: 2,
size: 1,
value: null,
data_type: "hex",
description: "链接器主版本号",
},
minor_linker_version: {
name: "minor_linker_version",
offset: 3,
size: 1,
value: null,
data_type: "hex",
description: "链接器次版本号",
},
size_of_code: {
name: "size_of_code",
offset: 4,
size: 4,
value: null,
data_type: "hex",
description: "代码段大小",
},
size_of_initialized_data: {
name: "size_of_initialized_data",
offset: 8,
size: 4,
value: null,
data_type: "hex",
description: "初始化数据段大小",
},
size_of_uninitialized_data: {
name: "size_of_uninitialized_data",
offset: 12,
size: 4,
value: null,
data_type: "hex",
description: "未初始化数据段大小",
},
address_of_entry_point: {
name: "address_of_entry_point",
offset: 16,
size: 4,
value: null,
data_type: "hex",
description: "入口点地址",
},
base_of_code: {
name: "base_of_code",
offset: 20,
size: 4,
value: null,
data_type: "hex",
description: "代码段基址",
},
image_base: {
name: "image_base",
offset: 24,
size: 4,
value: null,
data_type: "hex",
description: "映像基址",
},
section_alignment: {
name: "section_alignment",
offset: 28,
size: 4,
value: null,
data_type: "hex",
description: "节对齐",
},
file_alignment: {
name: "file_alignment",
offset: 32,
size: 4,
value: null,
data_type: "hex",
description: "文件对齐",
},
major_operating_system_version: {
name: "major_operating_system_version",
offset: 36,
size: 2,
value: null,
data_type: "hex",
description: "操作系统主版本号",
},
minor_operating_system_version: {
name: "minor_operating_system_version",
offset: 38,
size: 2,
value: null,
data_type: "hex",
description: "操作系统次版本号",
},
major_image_version: {
name: "major_image_version",
offset: 40,
size: 2,
value: null,
data_type: "hex",
description: "映像主版本号",
},
minor_image_version: {
name: "minor_image_version",
offset: 42,
size: 2,
value: null,
data_type: "hex",
description: "映像次版本号",
},
major_subsystem_version: {
name: "major_subsystem_version",
offset: 44,
size: 2,
value: null,
data_type: "hex",
description: "子系统主版本号",
},
minor_subsystem_version: {
name: "minor_subsystem_version",
offset: 46,
size: 2,
value: null,
data_type: "hex",
description: "子系统次版本号",
},
win32_version_value: {
name: "win32_version_value",
offset: 48,
size: 4,
value: null,
data_type: "hex",
description: "Win32版本值",
},
size_of_image: {
name: "size_of_image",
offset: 52,
size: 4,
value: null,
data_type: "hex",
description: "映像大小",
},
size_of_headers: {
name: "size_of_headers",
offset: 56,
size: 4,
value: null,
data_type: "hex",
description: "头部大小",
},
checksum: {
name: "checksum",
offset: 60,
size: 4,
value: null,
data_type: "hex",
description: "校验和",
},
subsystem: {
name: "subsystem",
offset: 64,
size: 2,
value: null,
data_type: "hex",
description: "子系统",
},
dll_characteristics: {
name: "dll_characteristics",
offset: 66,
size: 2,
value: null,
data_type: "hex",
description: "DLL特性",
},
size_of_stack_reserve: {
name: "size_of_stack_reserve",
offset: 68,
size: 8,
value: null,
data_type: "hex",
description: "堆栈保留大小",
},
size_of_stack_commit: {
name: "size_of_stack_commit",
offset: 76,
size: 8,
value: null,
data_type: "hex",
description: "堆栈提交大小",
},
size_of_heap_reserve: {
name: "size_of_heap_reserve",
offset: 84,
size: 8,
value: null,
data_type: "hex",
description: "堆保留大小",
},
size_of_heap_commit: {
name: "size_of_heap_commit",
offset: 92,
size: 8,
value: null,
data_type: "hex",
description: "堆提交大小",
},
loader_flags: {
name: "loader_flags",
offset: 100,
size: 4,
value: null,
data_type: "hex",
description: "加载器标志",
},
number_of_rva_and_sizes: {
name: "number_of_rva_and_sizes",
offset: 104,
size: 4,
value: null,
data_type: "hex",
description: "RVA和大小数量",
},
};
const columns = [
{
title: "字段名",
dataIndex: "name",
@ -270,17 +512,24 @@ export default function OptionalHeader() {
dataIndex: "description",
key: "description",
},
];
];
export default function OptionalHeader() {
const [data, setData] = useState<any[]>([]);
const [is64, setIs64] = useState(false);
const command = "command_get_pe_data_optional_header";
useEffect(() => {
invoke(command).then((res) => {
const {is_64_bit} = res as any;
setIs64(is_64_bit);
setData(res as any);
});
}, []);
return (
<NodeTableComponent
dataTemplate={dataTemplate}
dataTemplate={is64 ? dataTemplate64 : dataTemplate}
defaultData={data}
columns={columns as any}
></NodeTableComponent>