taiHEN  1.0
CFW framework for PS Vita
Data Structures | Typedefs | Functions
Process Map Interface

Data structure for storing patches internally. More...

Data Structures

struct  _tai_proc_map
 The actual map in memory. More...
 
struct  _tai_proc
 Internal data for a process. More...
 

Typedefs

typedef struct _tai_proc_map tai_proc_map_t
 The actual map in memory.
 
typedef struct _tai_proc tai_proc_t
 Internal data for a process.
 

Functions

int proc_map_init (void)
 Initializes the map system. More...
 
void proc_map_deinit (void)
 Cleans up the map system. More...
 
tai_proc_map_tproc_map_alloc (int nbuckets)
 Allocates a new map. More...
 
void proc_map_free (tai_proc_map_t *map)
 Frees a map. More...
 
int proc_map_try_insert (tai_proc_map_t *map, tai_patch_t *patch, tai_patch_t **existing)
 Inserts into the map if no overlap or get patch that completely overlaps. More...
 
int proc_map_remove_all_pid (tai_proc_map_t *map, SceUID pid, tai_patch_t **head)
 Removes every patch associated with a given pid from the map. More...
 
int proc_map_remove (tai_proc_map_t *map, tai_patch_t *patch)
 Remove a single patch from the map. More...
 

Detailed Description

Data structure for storing patches internally.

Internal map structure

This is a thread-safe map data structure for keeping track of mappings from PID to a linked-list of patches (stored in tai_proc_t).

Function Documentation

§ proc_map_alloc()

tai_proc_map_t* proc_map_alloc ( int  nbuckets)

Allocates a new map.

Parameters
[in]nbucketsThe number of buckets for the map.
Returns
Pointer to an allocated map structure on success. Null on failure.

Definition at line 69 of file proc_map.c.

§ proc_map_deinit()

void proc_map_deinit ( void  )

Cleans up the map system.

Should be called before exit.

Definition at line 56 of file proc_map.c.

§ proc_map_free()

void proc_map_free ( tai_proc_map_t map)

Frees a map.

Parameters
mapThe map

Definition at line 89 of file proc_map.c.

§ proc_map_init()

int proc_map_init ( void  )

Initializes the map system.

Must be called on startup.

Returns
Zero on success or memory allocation error code.

Definition at line 38 of file proc_map.c.

§ proc_map_remove()

int proc_map_remove ( tai_proc_map_t map,
tai_patch_t patch 
)

Remove a single patch from the map.

Parameters
mapThe map
patchThe patch to remove
Returns
One if the patch was removed from the map and zero otherwise.

Definition at line 233 of file proc_map.c.

§ proc_map_remove_all_pid()

int proc_map_remove_all_pid ( tai_proc_map_t map,
SceUID  pid,
tai_patch_t **  head 
)

Removes every patch associated with a given pid from the map.

Returned is a new linked list containing every patch that has been removed from the proc map. Use the next pointer to iterate this linked list.

Since this invalidates all references for a PID, it should ONLY be called on the shutdown of a process. In other words, after calling this, any pointer reference for that process is invalid!

Also note that for optimization, all pointers to slab in the list are considered invalid! Maybe we should null the pointers out in the future.

Parameters
mapThe map
[in]pidThe pid to remove
[out]headThe head of the linked list contained items removed
Returns
One if any item has been removed.

Definition at line 202 of file proc_map.c.

§ proc_map_try_insert()

int proc_map_try_insert ( tai_proc_map_t map,
tai_patch_t patch,
tai_patch_t **  existing 
)

Inserts into the map if no overlap or get patch that completely overlaps.

If there is no overlap with any other element for a given PID, then insert the patch into the map. If there is overlap, the function will return zero and not insert the patch. If the overlap is complete (same address and size), then this will return a pointer to the overlapping patch also.

Parameters
mapThe map
[in]patchThe patch to attempt insert
[out]existingIf and only if there exists a patch with the same address and size, then the function returns zero and this pointer will be set to the patch that overlaps. Otherwise, this will output null.
Returns
One if patch has been inserted successfully. Zero if there is overlap and is not inserted.

Definition at line 114 of file proc_map.c.