forked from naehrwert/scetool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rvk.cpp
123 lines (104 loc) · 2.59 KB
/
rvk.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright (c) 2011-2013 by naehrwert
* This file is released under the GPLv2.
*/
#include <stdio.h>
#include "types.h"
#include "util.h"
#include "sce.h"
#include "rvk.h"
#include "tables.h"
static void _print_rvk_header(FILE *fp, rvk_header_t *h)
{
fprintf(fp, "[*] Revoke List Header:\n");
fprintf(fp, " type_0 0x%08X\n", h->type_0);
fprintf(fp, " type_1 0x%08X\n", h->type_1);
if(h->type_0 == 4)
fprintf(fp, " Version %s\n", sce_version_to_str(h->opaque));
else
fprintf(fp, " Opaque 0x%016llX\n", h->opaque);
fprintf(fp, " Entry Count 0x%08X\n", h->entcnt);
}
/*
typedef struct _prg_rvk_entry
{
u32 self_type; //3, 4
u32 unk_1; //1, 3
union
{
u64 version; //unk_1 == 1
u64 unk_2; //unk_1 == 3
};
union
{
u64 auth_id;
u64 unk_3;
};
u8 unk_4[8];
} prg_rvk_entry_t;
*/
static void _print_prg_rvk_entry_header(FILE *fp)
{
fprintf(fp, "[*] Program Revoke List Entries:\n");
fprintf(fp, " Type Check Version Auth-ID/unk_3 Mask\n");
}
static id_to_name_t _check_type_values[] =
{
{CHECK_SELF_NEQU_RVK, "!="},
{CHECK_SELF_EQU_RVK, "=="},
{CHECK_SELF_LT_RVK, "<"},
{CHECK_SELF_LTEQU_RVK, "<="},
{CHECK_SELF_GT_RVK, ">"},
{CHECK_SELF_GTEQU_RVK, ">="},
{0, NULL}
};
static void _print_prg_rvk_entry(FILE *fp, prg_rvk_entry_t *e)
{
const s8 *name;
name = _get_name(_self_types, e->self_type);
if(name != NULL)
fprintf(fp, " %-19s ", name);
else
fprintf(fp, " 0x%08X ", e->self_type);
name = _get_name(_check_type_values, e->check_type);
if(name != NULL)
fprintf(fp, "%-2s ", name);
else
fprintf(fp, "%08X ", e->check_type);
fprintf(fp, "%s ", sce_version_to_str(e->version));
name = _get_name(_auth_ids, e->auth_id);
if(name != NULL)
fprintf(fp, "%-16s ", name);
else
fprintf(fp, "%016llX ", e->auth_id);
fprintf(fp, "%016llX ", e->mask);
fprintf(fp, "\n");
}
void rvk_print(FILE *fp, sce_buffer_ctxt_t *ctxt)
{
u32 i;
rvk_header_t *rvkh = (rvk_header_t *)(ctxt->scebuffer + ctxt->metash[0].data_offset);
_es_rvk_header(rvkh);
_print_rvk_header(fp, rvkh);
//Program revoke.
if(rvkh->type_0 == 4)
{
prg_rvk_entry_t *ent = (prg_rvk_entry_t *)(ctxt->scebuffer + ctxt->metash[1].data_offset);
_print_prg_rvk_entry_header(fp);
for(i = 0; i < rvkh->entcnt; i++)
{
_es_prg_rvk_entry(&ent[i]);
_print_prg_rvk_entry(fp, &ent[i]);
}
}
else if(rvkh->type_0 == 3)
{
fprintf(fp, "[*] Package Revoke List Entries:\n");
u8 *ent = (u8 *)(ctxt->scebuffer + ctxt->metash[1].data_offset);
for(i = 0; i < rvkh->entcnt; i++)
{
_hexdump(fp, " ent", i*0x20, ent, 0x20, TRUE);
ent += 0x20;
}
}
}