feat: 优化和增加TODO
This commit is contained in:
parent
45148ead6e
commit
90e3e22e44
@ -26,7 +26,6 @@ pub fn set_complete(app: AppHandle) -> Result<(), AppError> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 获取PE节点树的JSON数据
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn command_get_file_pe_node_tree_data() -> Result<Vec<PeNodeTreeData>, AppError> {
|
pub fn command_get_file_pe_node_tree_data() -> Result<Vec<PeNodeTreeData>, AppError> {
|
||||||
// 1. 如果没有打开文件,则返回错误
|
// 1. 如果没有打开文件,则返回错误
|
||||||
@ -91,7 +90,6 @@ pub fn command_open_file(file_path: &str) -> Result<(), AppError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断文件是否是64位
|
// 判断文件是否是64位
|
||||||
// TODO: GLOBAL_IS_64_BIT
|
|
||||||
let binding = GLOBAL_FILE_DATA.lock().unwrap();
|
let binding = GLOBAL_FILE_DATA.lock().unwrap();
|
||||||
let file_data = binding.as_ref().unwrap();
|
let file_data = binding.as_ref().unwrap();
|
||||||
let is64bit = file_data.is_64_bit()?;
|
let is64bit = file_data.is_64_bit()?;
|
||||||
|
@ -5,7 +5,6 @@ use crate::{app_error::AppError, pe_parse::{header::{ImageDosHeader, ImageFileHe
|
|||||||
|
|
||||||
use super::{GLOBAL_FILE_DATA, GLOBAL_IS_64_BIT};
|
use super::{GLOBAL_FILE_DATA, GLOBAL_IS_64_BIT};
|
||||||
|
|
||||||
// TODO: 打开文件,并将文件映射到内存
|
|
||||||
pub fn mmap_mut_file(file_path: &str) -> Result<Mmap, std::io::Error> {
|
pub fn mmap_mut_file(file_path: &str) -> Result<Mmap, std::io::Error> {
|
||||||
let file = std::fs::OpenOptions::new().read(true).open(file_path)?;
|
let file = std::fs::OpenOptions::new().read(true).open(file_path)?;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import NodeTableComponent, {
|
|||||||
} from "../NodeTableComponent/NodeTableComponent";
|
} from "../NodeTableComponent/NodeTableComponent";
|
||||||
|
|
||||||
export default function NTHeader() {
|
export default function NTHeader() {
|
||||||
|
// TODO: 这里要分64位和32位,最好让后端返回
|
||||||
const dataTemplate: DataTemplateInterface = {
|
const dataTemplate: DataTemplateInterface = {
|
||||||
signature: {
|
signature: {
|
||||||
name: "Signature",
|
name: "Signature",
|
||||||
|
@ -35,7 +35,8 @@ export interface DataType {
|
|||||||
// hex: 16进制
|
// hex: 16进制
|
||||||
// enum: 枚举值,对于枚举的处理一律按位处理
|
// enum: 枚举值,对于枚举的处理一律按位处理
|
||||||
// array: 数组
|
// array: 数组
|
||||||
data_type: "hex" | "enum" | "array";
|
// char_array: 字符数组
|
||||||
|
data_type: "hex" | "enum" | "array"| "char_array";
|
||||||
children?: DataType[];
|
children?: DataType[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +88,7 @@ const EditableCell: React.FC<React.PropsWithChildren<EditableCellProps>> = ({
|
|||||||
handleSave,
|
handleSave,
|
||||||
...restProps
|
...restProps
|
||||||
}) => {
|
}) => {
|
||||||
|
// TODO: 如果值现在以16进制显示,那么编辑的时候也应该是16进制
|
||||||
const [editing, setEditing] = useState(false);
|
const [editing, setEditing] = useState(false);
|
||||||
const inputRef = useRef<InputRef>(null);
|
const inputRef = useRef<InputRef>(null);
|
||||||
const form = useContext(EditableContext)!;
|
const form = useContext(EditableContext)!;
|
||||||
@ -145,10 +147,8 @@ export default function NodeTableComponent(props: NodeTableComponentProps) {
|
|||||||
}>({});
|
}>({});
|
||||||
|
|
||||||
const handleSwitchFieldHexMode = (field: string) => {
|
const handleSwitchFieldHexMode = (field: string) => {
|
||||||
console.log("hexSwitchStatus", hexSwitchStatus);
|
|
||||||
const newHexSwitchStatus = { ...hexSwitchStatus };
|
const newHexSwitchStatus = { ...hexSwitchStatus };
|
||||||
newHexSwitchStatus[field] = !newHexSwitchStatus[field];
|
newHexSwitchStatus[field] = !newHexSwitchStatus[field];
|
||||||
console.log("newHexSwitchStatus", newHexSwitchStatus);
|
|
||||||
setHexSwitchStatus(newHexSwitchStatus);
|
setHexSwitchStatus(newHexSwitchStatus);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -224,13 +224,13 @@ export default function NodeTableComponent(props: NodeTableComponentProps) {
|
|||||||
cloneData[key].value = null;
|
cloneData[key].value = null;
|
||||||
cloneData[key].children = array;
|
cloneData[key].children = array;
|
||||||
}
|
}
|
||||||
// TODO: 枚举值处理
|
// TODO: 枚举值处理, 把所有枚举放到一个成员,后面通过选项组件展示
|
||||||
if(cloneData[key].data_type === "enum") {
|
if (cloneData[key].data_type === "enum") {
|
||||||
// children
|
// children
|
||||||
let children = [];
|
let children = [];
|
||||||
let value = resData.fields[key];
|
let value = resData.fields[key];
|
||||||
for (let enumValue in cloneData[key].enum) {
|
for (let enumValue in cloneData[key].enum) {
|
||||||
if((value as number) & parseInt(enumValue)) {
|
if ((value as number) & parseInt(enumValue)) {
|
||||||
children.push({
|
children.push({
|
||||||
offset: cloneData[key].offset,
|
offset: cloneData[key].offset,
|
||||||
name: cloneData[key].enum[enumValue].enum_name,
|
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;
|
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(() => {
|
useEffect(() => {
|
||||||
// 请求数据
|
// 请求数据
|
||||||
invoke(props.command).then((resData: ResponsData) => {
|
invoke(props.command).then((resData: ResponsData) => {
|
||||||
console.log("resData", resData);
|
|
||||||
handleData(resData);
|
handleData(resData);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
62
src/components/SectionHeaders/SectionHeaders.tsx
Normal file
62
src/components/SectionHeaders/SectionHeaders.tsx
Normal file
@ -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 (
|
||||||
|
<NodeTableComponent
|
||||||
|
dataTemplate={dataTemplate}
|
||||||
|
command={command}
|
||||||
|
columns={columns as any}
|
||||||
|
></NodeTableComponent>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user