taiHEN  1.0
CFW framework for PS Vita
taihen_internal.h
1 
4 #ifndef TAI_INTERNAL_HEADER
5 #define TAI_INTERNAL_HEADER
6 
7 #include <psp2kern/types.h>
8 #include <inttypes.h>
9 #include <stdio.h>
10 #include "taihen.h"
11 #include "slab.h"
12 
14 extern unsigned char log_ctr;
15 
17 #ifdef ENABLE_LOGGING
18 #define LOG(fmt, ...) printf("%02X [%s:%d] " fmt "\n", log_ctr++, __FUNCTION__, __LINE__, ##__VA_ARGS__)
19 #else
20 #define LOG(fmt, ...)
21 #endif
22 
24 #define FUNC_SAVE_SIZE 16
25 
27 #define SHARED_PID 0x80000000
28 
30 #define DEFAULT_FW_VERSION 0x3600000
31 
40 typedef enum {
41  HOOKS,
42  INJECTION
44 
48 typedef struct _tai_hook {
49  struct _tai_hook_user u;
50  // TODO: obfuscate these two kernel pointers as they might be stored in userland
51  // also put a MAC over them
52  struct _tai_hook *next;
53  struct _tai_patch *patch;
54 } tai_hook_t;
55 
59 typedef struct _tai_inject {
60  void *saved;
61  size_t size;
62  struct _tai_patch *patch;
63 } tai_inject_t;
64 
68 typedef struct _tai_hook_list {
69  void *func;
70  void *old;
71  void *saved;
72  struct _tai_hook *head;
74 
78 typedef struct _tai_patch {
79  uint32_t sce_reserved[2];
80  union {
81  struct _tai_inject inject;
82  struct _tai_hook_list hooks;
83  } data;
85  SceUID uid;
86  SceUID pid;
87  uintptr_t addr;
88  size_t size;
89  struct _tai_patch *next;
90  struct slab_chain *slab;
91 } tai_patch_t;
92 
103 typedef struct _tai_proc {
104  SceUID pid;
106  struct slab_chain slab;
107  struct _tai_proc *next;
108 } tai_proc_t;
109 
112 #endif // TAI_INTERNAL_HEADER
void * saved
The original data (allocated on inject)
tai_patch_type_t type
Type of patch (hook chain or injection)
struct _tai_patch * patch
The patch containing this injection.
struct _tai_proc * next
Next process in this map bucket.
struct _tai_hook_user u
Used by TAI_CONTINUE to find next hook to run.
size_t size
Size of the patch.
struct _tai_hook tai_hook_t
Hook data stored in address space of process to patch.
struct _tai_patch * next
Next patch in the linked list for this process.
A chain of hooks.
uintptr_t addr
Address being patched.
struct _tai_hook * next
Next hook for this process + address.
Internal data for a process.
A patch containing either a hook chain or an injection.
tai_patch_type_t
struct _tai_inject tai_inject_t
Injection data.
struct _tai_patch * patch
The patch containing this hook.
struct slab_chain * slab
Slab chain for this process (copied from the owner tai_proc_t)
size_t size
Size of original data.
void * func
Address of the function to hook.
struct _tai_patch tai_patch_t
A patch containing either a hook chain or an injection.
SceUID pid
Process owning this object.
Hook data stored in address space of process to patch.
void * saved
Data saved by libsubstitute to restore the function.
void * old
A function pointer used to call the original function.
SceUID uid
Kernel object id of this object.
struct _tai_hook * head
The linked list of hooks on this process + address.
SceUID pid
Process ID (the key in the map)
tai_patch_t * head
Linked list of patches for this process.
Internal structure.
Definition: taihen.h:220
Injection data.
struct _tai_proc tai_proc_t
Internal data for a process.
struct _tai_hook_list tai_hook_list_t
A chain of hooks.