Skip to content

Commit 628aa5c

Browse files
committed
Add support for the XTAC file format ##bin
1 parent df15299 commit 628aa5c

File tree

10 files changed

+813
-1
lines changed

10 files changed

+813
-1
lines changed

dist/plugins-cfg/plugins.def.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ bin.xcoff64
138138
bin.xnu_kernelcache
139139
bin.z64
140140
bin.zimg
141+
bin.xtac
141142
bin_ldr.ldr_linux
142143
bin_xtr.xtr_dyldcache
143144
bin_xtr.xtr_fatmach0

libr/bin/format/xtac/xtac.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) FFRI Security, Inc., 2023 / Author: FFRI Security, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef _INCLUDE_XTAC_H_
18+
#define _INCLUDE_XTAC_H_
19+
20+
#include <r_types.h>
21+
22+
#define XTAC_MAGIC "XTAC"
23+
24+
typedef struct x86_arm_addr_pair_t {
25+
ut32 x86_rva;
26+
ut32 arm64_rva;
27+
} X86ArmAddrPair;
28+
29+
// NOTE: Here "pointer" means RVA from the image base of the cache file
30+
typedef struct r_bin_xtac_header_t {
31+
ut32 magic; // signature (always "XTAC")
32+
ut32 version; // version of XTAC
33+
ut32 is_updated; // cache file is updated (1) or not (0)
34+
ut32 ptr_to_addr_pairs; // pointer to x86 to arm address pairs
35+
ut32 num_of_addr_pairs; // number of address pairs
36+
ut32 ptr_to_mod_name; // pointer to module name
37+
ut32 size_of_mod_name; // size of module name (in bytes)
38+
ut32 ptr_to_nt_pname; // pointer to NT path name
39+
ut32 size_of_nt_pname; // size of NT path name (in bytes)
40+
ut32 ptr_to_head_blck_stub; // pointer to head BLCK stub
41+
ut32 ptr_to_tail_blck_stub; // pointer to tail BLCK stub
42+
ut32 size_of_blck_stub_code; // size of BLCK stub code (not including BLCK stub header)
43+
ut32 ptr_to_xtac_linked_list_head; // pointer to the head of linked list for updating
44+
// xtac.exe uses this for accessing the location to be corrected
45+
ut32 ptr_to_xtac_linked_list_tail; // pointer to the tail of linked list for updating
46+
} RBinXtacHeader;
47+
48+
typedef struct r_bin_blck_stub_header_t {
49+
ut32 magic; // signature (always "BLCK")
50+
ut32 offset_to_next_entry; // offset to the next entry from the current BLCK stub code
51+
ut32 ptr_to_next_entry; // pointer to the next BLCK stub
52+
ut32 padding; // padding (always 0)
53+
54+
ut32 ptr_to_entry; // pointer to this entry
55+
} RBinBlckStubHeader;
56+
57+
typedef struct r_bin_xtac_linked_list_entry_t {
58+
ut32 meta_and_offset; // metadata (upper 8bits) and quarter of offset to next entry (lower 24bits)
59+
ut32 forward_edge_addr; // x86 RVA of forward edge address
60+
ut32 backward_edge_addr; // x86 RVA of backward edge address
61+
62+
ut32 ptr_to_entry; // pointer to this entry
63+
} RBinXtacLinkedListEntry;
64+
65+
typedef struct r_bin_xtac_obj_t {
66+
RBinXtacHeader *header;
67+
X86ArmAddrPair *address_pairs;
68+
ut16 *mod_name_u16;
69+
char *mod_name_u8;
70+
ut16 *nt_path_name_u16;
71+
char *nt_path_name_u8;
72+
73+
RBuffer *b;
74+
RList *blck_stubs; // RList of r_bin_bock_stub_header_t
75+
RList *xtac_linked_list; // RList of r_bin_xtac_linked_list_entry_t
76+
Sdb *kv;
77+
bool verbose;
78+
int size;
79+
} RBinXtacObj;
80+
81+
#endif

libr/bin/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ r_bin_sources = [
8585
'p/bin_xtr_xalz.c',
8686
'p/bin_z64.c',
8787
'p/bin_zimg.c',
88+
'p/bin_xtac.c',
8889
# implementation
8990
'format/bflt/bflt.c',
9091
'format/coff/coff.c',

libr/bin/p/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ FORMATS+=dex.mk fs.mk ningb.mk coff.mk xcoff64.mk ningba.mk xbe.mk zimg.mk
2323
FORMATS+=omf.mk cgc.mk dol.mk rel.mk nes.mk mbn.mk psxexe.mk
2424
FORMATS+=vsf.mk nin3ds.mk bflt.mk wasm.mk sfc.mk
2525
FORMATS+=mdmp.mk z64.mk qnx.mk prg.mk dmp64.mk
26+
FORMATS+=xtac.mk
2627

2728
FORMATS+=xtr_dyldcache.mk
2829
FORMATS+=xtr_fatmach0.mk

0 commit comments

Comments
 (0)