Skip to content

Commit

Permalink
Convert pf commands to rzshell
Browse files Browse the repository at this point in the history
  • Loading branch information
XVilka committed Feb 15, 2024
1 parent ac63502 commit 6be1920
Show file tree
Hide file tree
Showing 43 changed files with 11,283 additions and 18,192 deletions.
12 changes: 6 additions & 6 deletions librz/bin/d/bios
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# BIOS parameter block
pf.bpb .b.[8]zwbwbwwbwwwxx jmp oem_id bytes_per_sector sectors_per_cluster reserved_sectors num_fat num_dir_ent num_sectors type sectors_per_fat sectors_per_track num_heads num_hidden large_sectors
pf.ebpb16 bbbx[11]z[8]z[448].w drive_num ntflags_or_reserved signature volume_id volume_label system_id bootable_signature
pf.ebpb32 xwbbxww[12]bbbbx[11]z[8]z[420].w sectors_per_fat flags version.major version.minor root_cluster fsinfo_cluster backup_boot_cluster reserved drive_num ntflags_or_reserved signature volume_id volume_label system_id bootable_signature
pf.bpb16 ?? (bpb)bios_parameter_block (ebpb16)extended_boot_record
pf.bpb32 ?? (bpb)bios_parameter_block (ebpb32)extended_boot_record
pfn bpb ".b.[8]zwbwbwwbwwwxx jmp oem_id bytes_per_sector sectors_per_cluster reserved_sectors num_fat num_dir_ent num_sectors type sectors_per_fat sectors_per_track num_heads num_hidden large_sectors"
pfn ebpb16 "bbbx[11]z[8]z[448].w drive_num ntflags_or_reserved signature volume_id volume_label system_id bootable_signature"
pfn ebpb32 "xwbbxww[12]bbbbx[11]z[8]z[420].w sectors_per_fat flags version.major version.minor root_cluster fsinfo_cluster backup_boot_cluster reserved drive_num ntflags_or_reserved signature volume_id volume_label system_id bootable_signature"
pfn bpb16 "?? (bpb)bios_parameter_block (ebpb16)extended_boot_record"
pfn bpb32 "?? (bpb)bios_parameter_block (ebpb32)extended_boot_record"

# Data access packet (for INT 13h)
pf.dap bbwwwq size reserved sector offset segment start
pfn dap "bbwwwq size reserved sector offset segment start"
2 changes: 1 addition & 1 deletion librz/bin/d/dex
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pf.dex_magic [8]c
pfn dex_magic "[8]c"
8 changes: 4 additions & 4 deletions librz/bin/d/elf32
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pfo elf_enums
pf.elf_ident [4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version
pf.elf_header ?[2]E[2]E[4]ExxxxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx
pf.elf_phdr [4]Exxxxx[4]Ex (elf_p_type)type offset vaddr paddr filesz memsz (elf_p_flags)flags align
pf.elf_shdr x[4]E[4]Exxxxxxx name (elf_s_type)type (elf_s_flags_32)flags addr offset size link info addralign entsize
pfn elf_ident "[4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version"
pfn elf_header "?[2]E[2]E[4]ExxxxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx"
pfn elf_phdr "[4]Exxxxx[4]Ex (elf_p_type)type offset vaddr paddr filesz memsz (elf_p_flags)flags align"
pfn elf_shdr "x[4]E[4]Exxxxxxx name (elf_s_type)type (elf_s_flags_32)flags addr offset size link info addralign entsize"
8 changes: 4 additions & 4 deletions librz/bin/d/elf64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pfo elf_enums
pf.elf_ident [4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version
pf.elf_header ?[2]E[2]E[4]EqqqxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx
pf.elf_phdr [4]E[4]Eqqqqqq (elf_p_type)type (elf_p_flags)flags offset vaddr paddr filesz memsz align
pf.elf_shdr x[4]E[8]Eqqqxxqq name (elf_s_type)type (elf_s_flags_64)flags addr offset size link info addralign entsize
pfn elf_ident "[4]z[1]E[1]E[1]E.:: magic (elf_class)class (elf_data)data (elf_hdr_version)version"
pfn elf_header "?[2]E[2]E[4]EqqqxN2N2N2N2N2N2 (elf_ident)ident (elf_type)type (elf_machine)machine (elf_obj_version)version entry phoff shoff flags ehsize phentsize phnum shentsize shnum shstrndx"
pfn elf_phdr "[4]E[4]Eqqqqqq (elf_p_type)type (elf_p_flags)flags offset vaddr paddr filesz memsz align"
pfn elf_shdr "x[4]E[8]Eqqqxxqq name (elf_s_type)type (elf_s_flags_64)flags addr offset size link info addralign entsize"
3 changes: 0 additions & 3 deletions librz/bin/d/fat

This file was deleted.

56 changes: 29 additions & 27 deletions librz/bin/d/macho
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,32 @@ td "enum mach0_header_filetype {MH_OBJECT=1, MH_EXECUTE=2, MH_FVMLIB=3, MH_CORE=
td "enum mach0_header_flags {MH_NOUNDEFS=1, MH_INCRLINK=2,MH_DYLDLINK=4,MH_BINDATLOAD=8,MH_PREBOUND=0x10, MH_SPLIT_SEGS=0x20,MH_LAZY_INIT=0x40,MH_TWOLEVEL=0x80, MH_FORCE_FLAT=0x100,MH_NOMULTIDEFS=0x200,MH_NOFIXPREBINDING=0x400, MH_PREBINDABLE=0x800, MH_ALLMODSBOUND=0x1000, MH_SUBSECTIONS_VIA_SYMBOLS=0x2000, MH_CANONICAL=0x4000,MH_WEAK_DEFINES=0x8000, MH_BINDS_TO_WEAK=0x10000,MH_ALLOW_STACK_EXECUTION=0x20000, MH_ROOT_SAFE=0x40000,MH_SETUID_SAFE=0x80000, MH_NO_REEXPORTED_DYLIBS=0x100000,MH_PIE=0x200000, MH_DEAD_STRIPPABLE_DYLIB=0x400000, MH_HAS_TLV_DESCRIPTORS=0x800000, MH_NO_HEAP_EXECUTION=0x1000000};"
td "enum mach0_section_types {S_REGULAR=0, S_ZEROFILL=1, S_CSTRING_LITERALS=2, S_4BYTE_LITERALS=3, S_8BYTE_LITERALS=4, S_LITERAL_POINTERS=5, S_NON_LAZY_SYMBOL_POINTERS=6, S_LAZY_SYMBOL_POINTERS=7, S_SYMBOL_STUBS=8, S_MOD_INIT_FUNC_POINTERS=9, S_MOD_TERM_FUNC_POINTERS=0xa, S_COALESCED=0xb, S_GB_ZEROFILL=0xc, S_INTERPOSING=0xd, S_16BYTE_LITERALS=0xe, S_DTRACE_DOF=0xf, S_LAZY_DYLIB_SYMBOL_POINTERS=0x10, S_THREAD_LOCAL_REGULAR=0x11, S_THREAD_LOCAL_ZEROFILL=0x12, S_THREAD_LOCAL_VARIABLES=0x13, S_THREAD_LOCAL_VARIABLE_POINTERS=0x14, S_THREAD_LOCAL_INIT_FUNCTION_POINTERS=0x15, S_INIT_FUNC_OFFSETS=0x16};"
td "enum mach0_section_attrs {S_ATTR_PURE_INSTRUCTIONS=0x800000ULL, S_ATTR_NO_TOC=0x400000ULL, S_ATTR_STRIP_STATIC_SYMS=0x200000ULL, S_ATTR_NO_DEAD_STRIP=0x100000ULL, S_ATTR_LIVE_SUPPORT=0x080000ULL, S_ATTR_SELF_MODIFYING_CODE=0x040000ULL, S_ATTR_DEBUG=0x020000ULL, S_ATTR_SOME_INSTRUCTIONS=0x000004ULL, S_ATTR_EXT_RELOC=0x000002ULL, S_ATTR_LOC_RELOC=0x000001ULL};"
pf.mach0_header xxx[4]Edd[4]B magic cputype cpusubtype (mach0_header_filetype)filetype ncmds sizeofcmds (mach0_header_flags)flags
pf.mach0_segment [4]Ed[16]zxxxxoodx (mach0_load_command_type)cmd cmdsize segname vmaddr vmsize fileoff filesize maxprot initprot nsects flags
pf.mach0_segment64 [4]Ed[16]zqqqqoodx (mach0_load_command_type)cmd cmdsize segname vmaddr vmsize fileoff filesize maxprot initprot nsects flags
pf.mach0_symtab_command [4]Edxdxd (mach0_load_command_type)cmd cmdsize symoff nsyms stroff strsize
pf.mach0_dysymtab_command [4]Edddddddddddxdxdxxxd (mach0_load_command_type)cmd cmdsize ilocalsym nlocalsym iextdefsym nextdefsym iundefsym nundefsym tocoff ntoc moddtaboff nmodtab extrefsymoff nextrefsyms inddirectsymoff nindirectsyms extreloff nextrel locreloff nlocrel
pf.mach0_section [16]z[16]zxxxxxx[1]E[3]Bxx sectname segname addr size offset align reloff nreloc (mach0_section_types)flags_type (mach0_section_attrs)flags_attr reserved1 reserved2
pf.mach0_section64 [16]z[16]zqqxxxx[1]E[3]Bxxx sectname segname addr size offset align reloff nreloc (mach0_section_types)flags_type (mach0_section_attrs)flags_attr reserved1 reserved2 reserved3
pf.mach0_dylib xxxxz name_offset timestamp current_version compatibility_version name
pf.mach0_dylib_command [4]Ed? (mach0_load_command_type)cmd cmdsize (mach0_dylib)dylib
pf.mach0_id_dylib_command [4]Ed? (mach0_load_command_type)cmd cmdsize (mach0_dylib)dylib
pf.mach0_uuid_command [4]Ed[16]b (mach0_load_command_type)cmd cmdsize uuid
pf.mach0_rpath_command [4]Edxz (mach0_load_command_type)cmd cmdsize path_offset path
pf.mach0_entry_point_command [4]Edqq (mach0_load_command_type)cmd cmdsize entryoff stacksize
pf.mach0_encryption_info64_command [4]Edxddx (mach0_load_command_type)cmd cmdsize offset size id padding
pf.mach0_encryption_info_command [4]Edxdd (mach0_load_command_type)cmd cmdsize offset size id
pf.mach0_code_signature_command [4]Edxd (mach0_load_command_type)cmd cmdsize offset size
pf.mach0_dyld_info_only_command [4]Edxdxdxdxdxd (mach0_load_command_type)cmd cmdsize rebase_off rebase_size bind_off bind_size weak_bind_off weak_bind_size lazy_bind_off lazy_bind_size export_off export_size
pf.mach0_load_dylinker_command [4]Edxz (mach0_load_command_type)cmd cmdsize name_offset name
pf.mach0_id_dylinker_command [4]Edxz (mach0_load_command_type)cmd cmdsize name_offset name
pf.mach0_build_version_command [4]Ed[4]Exxd (mach0_load_command_type)cmd cmdsize (mach0_build_platform)platform minos sdk ntools
pf.mach0_build_version_tool [4]Ex (mach0_build_tool)tool version
pf.mach0_source_version_command [4]Edq (mach0_load_command_type)cmd cmdsize version
pf.mach0_function_starts_command [4]Edxd (mach0_load_command_type)cmd cmdsize offset size
pf.mach0_data_in_code_command [4]Edxd (mach0_load_command_type)cmd cmdsize offset size
pf.mach0_version_min_command [4]Edxx (mach0_load_command_type)cmd cmdsize version reserved
pf.mach0_segment_split_info_command [4]Edxd (mach0_load_command_type)cmd cmdsize offset size
pf.mach0_unixthread_command [4]Eddd (mach0_load_command_type)cmd cmdsize flavor count
pfn mach0_header "xxx[4]Edd[4]B magic cputype cpusubtype (mach0_header_filetype)filetype ncmds
sizeofcmds (mach0_header_flags)flags"
pfn mach0_segment "[4]Ed[16]zxxxxoodx (mach0_load_command_type)cmd cmdsize segname vmaddr vmsize fileoff filesize maxprot initprot nsects flags"
pfn mach0_segment64 "[4]Ed[16]zqqqqoodx (mach0_load_command_type)cmd cmdsize segname vmaddr vmsize fileoff filesize maxprot initprot nsects flags"
pfn mach0_symtab_command "[4]Edxdxd (mach0_load_command_type)cmd cmdsize symoff nsyms stroff strsize"
pfn mach0_dysymtab_command "[4]Edddddddddddxdxdxxxd (mach0_load_command_type)cmd cmdsize ilocalsym nlocalsym iextdefsym nextdefsym iundefsym nundefsym tocoff ntoc moddtaboff nmodtab extrefsymoff nextrefsyms inddirectsymoff nindirectsyms extreloff nextrel locreloff nlocrel"
pfn mach0_section "[16]z[16]zxxxxxx[1]E[3]Bxx sectname segname addr size offset align reloff nreloc (mach0_section_types)flags_type (mach0_section_attrs)flags_attr reserved1 reserved2"
pfn mach0_section64 "[16]z[16]zqqxxxx[1]E[3]Bxxx sectname segname addr size offset align reloff
nreloc (mach0_section_types)flags_type (mach0_section_attrs)flags_attr reserved1 reserved2 reserved3"
pfn mach0_dylib "xxxxz name_offset timestamp current_version compatibility_version name"
pfn mach0_dylib_command "[4]Ed? (mach0_load_command_type)cmd cmdsize (mach0_dylib)dylib"
pfn mach0_id_dylib_command "[4]Ed? (mach0_load_command_type)cmd cmdsize (mach0_dylib)dylib"
pfn mach0_uuid_command "[4]Ed[16]b (mach0_load_command_type)cmd cmdsize uuid"
pfn mach0_rpath_command "[4]Edxz (mach0_load_command_type)cmd cmdsize path_offset path"
pfn mach0_entry_point_command "[4]Edqq (mach0_load_command_type)cmd cmdsize entryoff stacksize"
pfn mach0_encryption_info64_command "[4]Edxddx (mach0_load_command_type)cmd cmdsize offset size id padding"
pfn mach0_encryption_info_command "[4]Edxdd (mach0_load_command_type)cmd cmdsize offset size id"
pfn mach0_code_signature_command "[4]Edxd (mach0_load_command_type)cmd cmdsize offset size"
pfn mach0_dyld_info_only_command "[4]Edxdxdxdxdxd (mach0_load_command_type)cmd cmdsize rebase_off rebase_size bind_off bind_size weak_bind_off weak_bind_size lazy_bind_off lazy_bind_size export_off export_size"
pfn mach0_load_dylinker_command "[4]Edxz (mach0_load_command_type)cmd cmdsize name_offset name"
pfn mach0_id_dylinker_command "[4]Edxz (mach0_load_command_type)cmd cmdsize name_offset name"
pfn mach0_build_version_command "[4]Ed[4]Exxd (mach0_load_command_type)cmd cmdsize (mach0_build_platform)platform minos sdk ntools"
pfn mach0_build_version_tool "[4]Ex (mach0_build_tool)tool version"
pfn mach0_source_version_command "[4]Edq (mach0_load_command_type)cmd cmdsize version"
pfn mach0_function_starts_command "[4]Edxd (mach0_load_command_type)cmd cmdsize offset size"
pfn mach0_data_in_code_command "[4]Edxd (mach0_load_command_type)cmd cmdsize offset size"
pfn mach0_version_min_command "[4]Edxx (mach0_load_command_type)cmd cmdsize version reserved"
pfn mach0_segment_split_info_command "[4]Edxd (mach0_load_command_type)cmd cmdsize offset size"
pfn mach0_unixthread_command "[4]Eddd (mach0_load_command_type)cmd cmdsize flavor count"
1 change: 0 additions & 1 deletion librz/bin/d/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ format_files = [
'elf64',
'elf_enums',
'pe32',
'trx',
'mz',
'zip'
]
Expand Down
2 changes: 1 addition & 1 deletion librz/bin/d/mz
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pf.dos_header [2]zwwwwwwwwwwwww[4]www[10]wx e_magic e_cblp e_cp e_crlc e_cparhdr e_minalloc e_maxalloc e_ss e_sp e_csum e_ip e_cs e_lfarlc e_ovno e_res e_oemid e_oeminfo e_res2 e_lfanew
pfn dos_header "[2]zwwwwwwwwwwwww[4]www[10]wx e_magic e_cblp e_cp e_crlc e_cparhdr e_minalloc e_maxalloc e_ss e_sp e_csum e_ip e_cs e_lfarlc e_ovno e_res e_oemid e_oeminfo e_res2 e_lfanew"
2 changes: 0 additions & 2 deletions librz/bin/d/ntfs

This file was deleted.

8 changes: 4 additions & 4 deletions librz/bin/d/pe32
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pfo mz
pf.pe_nt_image_headers32 [4]z?? signature (pe_image_file_header)fileHeader (pe_image_optional_header32)optionalHeader
pf.pe_image_optional_header32 [2]Ebbxxxxxxxxxwwwwwwxxxx[2]E[2]Bxxxxxx[16]? (pe_magic)magic majorLinkerVersion minorLinkerVersion sizeOfCode sizeOfInitializedData sizeOfUninitializedData addressOfEntryPoint baseOfCode baseOfData imageBase sectionAlignment fileAlignment majorOperatingSystemVersion minorOperatingSystemVersion majorImageVersion minorImageVersion majorSubsystemVersion minorSubsystemVersion win32VersionValue sizeOfImage sizeOfHeaders checkSum (pe_subsystem)subsystem (pe_dllcharacteristics)dllCharacteristics sizeOfStackReserve sizeOfStackCommit sizeOfHeapReserve sizeOfHeapCommit loaderFlags numberOfRvaAndSizes (pe_image_data_directory)dataDirectory
pf.pe_image_file_header [2]Ewtxxw[2]B (pe_machine)machine numberOfSections timeDateStamp pointerToSymbolTable numberOfSymbols sizeOfOptionalHeader (pe_characteristics)characteristics
pf.pe_image_data_directory xx virtualAddress size
pfn pe_nt_image_headers32 "[4]z?? signature (pe_image_file_header)fileHeader (pe_image_optional_header32)optionalHeader"
pfn pe_image_optional_header32 "[2]Ebbxxxxxxxxxwwwwwwxxxx[2]E[2]Bxxxxxx[16]? (pe_magic)magic majorLinkerVersion minorLinkerVersion sizeOfCode sizeOfInitializedData sizeOfUninitializedData addressOfEntryPoint baseOfCode baseOfData imageBase sectionAlignment fileAlignment majorOperatingSystemVersion minorOperatingSystemVersion majorImageVersion minorImageVersion majorSubsystemVersion minorSubsystemVersion win32VersionValue sizeOfImage sizeOfHeaders checkSum (pe_subsystem)subsystem (pe_dllcharacteristics)dllCharacteristics sizeOfStackReserve sizeOfStackCommit sizeOfHeapReserve sizeOfHeapCommit loaderFlags numberOfRvaAndSizes (pe_image_data_directory)dataDirectory"
pfn pe_image_file_header "[2]Ewtxxw[2]B (pe_machine)machine numberOfSections timeDateStamp pointerToSymbolTable numberOfSymbols sizeOfOptionalHeader (pe_characteristics)characteristics"
pfn pe_image_data_directory "xx virtualAddress size"
27 changes: 0 additions & 27 deletions librz/bin/d/trx

This file was deleted.

12 changes: 6 additions & 6 deletions librz/bin/d/zip
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pf.zip_local_file_hdr xwwwwwxxxww magic extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras
pf.zip_data_desc xxx crc32 compressed_size uncompressed_size
pf.zip_central_directory_hdr xwwwwwwxxxwwwwwxx magic encoder extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras comment diskstart filetype filemode offset
pf.zip_end_central_dir xwwwwxxw magic disk finaldisk entries finalentries rootsize rootseek comment
pf.zip64_end_central_dir xqwwxxqqqq magic size encoder extract disk finaldisk entries finalentries rootsize rootseek
pf.zip64_end_central_dir_loc xxqx magic disk rootseek disks
pfn zip_local_file_hdr "xwwwwwxxxww magic extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras"
pfn zip_data_desc "xxx crc32 compressed_size uncompressed_size"
pfn zip_central_directory_hdr "xwwwwwwxxxwwwwwxx magic encoder extract flags compression last_mod_time last_mod_date crc32 compressed_size uncompressed_size namlen extras comment diskstart filetype filemode offset"
pfn zip_end_central_dir "xwwwwxxw magic disk finaldisk entries finalentries rootsize rootseek comment"
pfn zip64_end_central_dir "xqwwxxqqqq magic size encoder extract disk finaldisk entries finalentries rootsize rootseek"
pfn zip64_end_central_dir_loc "xxqx magic disk rootseek disks"
8 changes: 4 additions & 4 deletions librz/core/canalysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -4401,8 +4401,9 @@ RZ_API RZ_OWN char *rz_core_analysis_var_display(RZ_NONNULL RzCore *core, RZ_NON
ut64 regval = rz_debug_reg_get(core->dbg, var->storage.reg);
r = rz_core_print_hexdump_refs(core, wordsize, wordsize, regval);
} else {
// TODO: convert to API
r = rz_core_cmd_strf(core, "pf r (%s)", var->storage.reg);
char *regfmt = rz_str_newf("r (%s)", var->storage.reg);
r = rz_core_print_format(core, regfmt, RZ_PRINT_MUSTSEE, core->offset);
free(regfmt);
}
rz_strbuf_append(sb, r);
free(r);
Expand All @@ -4415,8 +4416,7 @@ RZ_API RZ_OWN char *rz_core_analysis_var_display(RZ_NONNULL RzCore *core, RZ_NON
int wordsize = rz_analysis_get_address_bits(core->analysis) / 8;
r = rz_core_print_hexdump_refs(core, wordsize, wordsize, addr);
} else {
// TODO: convert to API
r = rz_core_cmd_strf(core, "pf %s @ 0x%" PFMT64x, fmt, addr);
r = rz_core_print_format(core, fmt, RZ_PRINT_MUSTSEE, addr);
}
rz_strbuf_append(sb, r);
free(r);
Expand Down
7 changes: 5 additions & 2 deletions librz/core/cmd/cmd_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2033,8 +2033,11 @@ RZ_IPI RzCmdStatus rz_analysis_global_variable_print_handler(RzCore *core, int a
free(fmt);
return RZ_CMD_STATUS_ERROR;
}
// TODO: Convert to the API
rz_core_cmdf(core, "pf %s @ 0x%08" PFMT64x "\n", fmt, glob->addr);
char *r = rz_core_print_format(core, fmt, RZ_PRINT_MUSTSEE, glob->addr);
if (r) {
rz_cons_print(r);
}
free(r);
free(fmt);
return RZ_CMD_STATUS_OK;
}
Expand Down
Loading

0 comments on commit 6be1920

Please sign in to comment.