diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 0501b83..30f22c2 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -26,7 +26,6 @@ pub fn set_complete(app: AppHandle) -> Result<(), AppError> { Ok(()) } -// TODO: 获取PE节点树的JSON数据 #[tauri::command] pub fn command_get_file_pe_node_tree_data() -> Result, AppError> { // 1. 如果没有打开文件,则返回错误 @@ -91,7 +90,6 @@ pub fn command_open_file(file_path: &str) -> Result<(), AppError> { } // 判断文件是否是64位 - // TODO: GLOBAL_IS_64_BIT let binding = GLOBAL_FILE_DATA.lock().unwrap(); let file_data = binding.as_ref().unwrap(); let is64bit = file_data.is_64_bit()?; diff --git a/src-tauri/src/services/file.rs b/src-tauri/src/services/file.rs index c00d2ef..fae4503 100644 --- a/src-tauri/src/services/file.rs +++ b/src-tauri/src/services/file.rs @@ -5,7 +5,6 @@ use crate::{app_error::AppError, pe_parse::{header::{ImageDosHeader, ImageFileHe use super::{GLOBAL_FILE_DATA, GLOBAL_IS_64_BIT}; -// TODO: 打开文件,并将文件映射到内存 pub fn mmap_mut_file(file_path: &str) -> Result { let file = std::fs::OpenOptions::new().read(true).open(file_path)?; diff --git a/src/components/NTHeader/NTHeader.tsx b/src/components/NTHeader/NTHeader.tsx index f3bab1f..89c4401 100644 --- a/src/components/NTHeader/NTHeader.tsx +++ b/src/components/NTHeader/NTHeader.tsx @@ -3,6 +3,7 @@ import NodeTableComponent, { } from "../NodeTableComponent/NodeTableComponent"; export default function NTHeader() { + // TODO: 这里要分64位和32位,最好让后端返回 const dataTemplate: DataTemplateInterface = { signature: { name: "Signature", diff --git a/src/components/NodeTableComponent/NodeTableComponent.tsx b/src/components/NodeTableComponent/NodeTableComponent.tsx index a1b15b1..f160d55 100644 --- a/src/components/NodeTableComponent/NodeTableComponent.tsx +++ b/src/components/NodeTableComponent/NodeTableComponent.tsx @@ -35,7 +35,8 @@ export interface DataType { // hex: 16进制 // enum: 枚举值,对于枚举的处理一律按位处理 // array: 数组 - data_type: "hex" | "enum" | "array"; + // char_array: 字符数组 + data_type: "hex" | "enum" | "array"| "char_array"; children?: DataType[]; } @@ -87,6 +88,7 @@ const EditableCell: React.FC> = ({ handleSave, ...restProps }) => { + // TODO: 如果值现在以16进制显示,那么编辑的时候也应该是16进制 const [editing, setEditing] = useState(false); const inputRef = useRef(null); const form = useContext(EditableContext)!; @@ -145,10 +147,8 @@ export default function NodeTableComponent(props: NodeTableComponentProps) { }>({}); const handleSwitchFieldHexMode = (field: string) => { - console.log("hexSwitchStatus", hexSwitchStatus); const newHexSwitchStatus = { ...hexSwitchStatus }; newHexSwitchStatus[field] = !newHexSwitchStatus[field]; - console.log("newHexSwitchStatus", newHexSwitchStatus); setHexSwitchStatus(newHexSwitchStatus); }; @@ -224,13 +224,13 @@ export default function NodeTableComponent(props: NodeTableComponentProps) { cloneData[key].value = null; cloneData[key].children = array; } - // TODO: 枚举值处理 - if(cloneData[key].data_type === "enum") { + // TODO: 枚举值处理, 把所有枚举放到一个成员,后面通过选项组件展示 + if (cloneData[key].data_type === "enum") { // children let children = []; let value = resData.fields[key]; for (let enumValue in cloneData[key].enum) { - if((value as number) & parseInt(enumValue)) { + if ((value as number) & parseInt(enumValue)) { children.push({ offset: cloneData[key].offset, name: cloneData[key].enum[enumValue].enum_name, @@ -241,19 +241,23 @@ export default function NodeTableComponent(props: NodeTableComponentProps) { }); } } - // cloneData[key].value = null; cloneData[key].children = children; } - } + // TODO: 字符数组处理 - // 3. 更新data - setData(Object.values(cloneData).sort((a, b) => a.offset - b.offset)); + } + // TODO: 应该从columns中获需要排序的字段,来进行排序 + // 如果cloneData的成员中有offset字段,那么需要按照offset排序 + let cloneDataArray = Object.values(cloneData); + if(cloneDataArray[0].offset){ + cloneDataArray.sort((a, b) => a.offset - b.offset); + } + setData(cloneDataArray); }; useEffect(() => { // 请求数据 invoke(props.command).then((resData: ResponsData) => { - console.log("resData", resData); handleData(resData); }); }, []); diff --git a/src/components/SectionHeaders/SectionHeaders.tsx b/src/components/SectionHeaders/SectionHeaders.tsx new file mode 100644 index 0000000..bde3548 --- /dev/null +++ b/src/components/SectionHeaders/SectionHeaders.tsx @@ -0,0 +1,62 @@ +import NodeTableComponent, { + DataTemplateInterface, + } from "../NodeTableComponent/NodeTableComponent"; + + export default function SectionHeaders() { + const dataTemplate: DataTemplateInterface = { + + + + /** + pub name: [u8; 8], + pub virtual_size: u32, + pub virtual_address: u32, + pub size_of_raw_data: u32, + pub pointer_to_raw_data: u32, + pub pointer_to_relocations: u32, + pub pointer_to_linenumbers: u32, + pub number_of_relocations: u16, + pub number_of_linenumbers: u16, + pub characteristics: SectionCharacteristics, + */ + }; + const command = "command_get_pe_data_optional_header"; + const columns = [ + { + title: "节区名(Byte[8])", + dataIndex: "name", + key: "name", + }, + { + title: "虚拟大小", + dataIndex: "offset", + key: "offset", + hexSwitch: true, + }, + { + title: "大小", + dataIndex: "size", + key: "size", + }, + { + title: "值", + dataIndex: "value", + key: "value", + hexSwitch: true, + editable: true, + }, + { + title: "描述信息", + dataIndex: "description", + key: "description", + }, + ]; + return ( + + ); + } + \ No newline at end of file