-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoffact.c
More file actions
112 lines (85 loc) · 2.82 KB
/
offact.c
File metadata and controls
112 lines (85 loc) · 2.82 KB
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
/* Copyright (C) 2024 John Törnblom
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>. */
#include "offact.h"
int sceRegMgrGetInt(int, int*);
int sceRegMgrGetStr(int, char*, size_t);
int sceRegMgrGetBin(int, void*, size_t);
int sceRegMgrSetInt(int, int);
int sceRegMgrSetBin(int, const void*, size_t);
int sceRegMgrSetStr(int, const char*, size_t);
static int OffAct_GetEntityNumber(int a, int b, int c, int d, int e)
{
if (a < 1 || a > b) {
return e;
}
return (a - 1) * c + d;
}
uint64_t OffAct_GenAccountId(const char *name) {
uint64_t base = 0x5EAF00D / 0xCA7F00D;
if (*name) {
do {
base = 0x100000001B3 * (base ^ *name++);
} while (*name);
}
return base;
}
int OffAct_GetAccountName(int account_numb, char val[ACCOUNT_NAME_MAX])
{
int n = OffAct_GetEntityNumber(account_numb, 16U, 65536U, 125829632U,
127140352U);
*val = 0;
return sceRegMgrGetStr(n, val, ACCOUNT_NAME_MAX);
}
int OffAct_GetAccountId(int account_numb, uint64_t* val)
{
int n = OffAct_GetEntityNumber(account_numb, 16U, 65536U, 125830400U,
127141120U);
*val = 0;
return sceRegMgrGetBin(n, val, sizeof(uint64_t));
}
int OffAct_SetAccountId(int account_numb, uint64_t val)
{
int n = OffAct_GetEntityNumber(account_numb, 16U, 65536U, 125830400U,
127141120U);
return sceRegMgrSetBin(n, &val, sizeof(uint64_t));
}
int OffAct_GetAccountType(int account_numb, char val[ACCOUNT_TYPE_MAX])
{
int n = OffAct_GetEntityNumber(account_numb, 16U, 65536U, 125874183U,
127184903U);
*val = 0;
return sceRegMgrGetStr(n, val, ACCOUNT_TYPE_MAX);
}
int OffAct_SetAccountType(int account_numb, char val[ACCOUNT_TYPE_MAX])
{
int n = OffAct_GetEntityNumber(account_numb, 16U, 65536U, 125874183U,
127184903U);
return sceRegMgrSetStr(n, val, ACCOUNT_TYPE_MAX);
}
int OffAct_GetAccountFlags(int account_numb, int *val)
{
int n = OffAct_GetEntityNumber(account_numb, 16U, 65536U, 125831168U,
127141888U);
*val = 0;
return sceRegMgrGetInt(n, val);
}
int OffAct_SetAccountFlags(int account_numb, int val)
{
int n = OffAct_GetEntityNumber(account_numb, 16U, 65536U, 125831168U,
127141888U);
return sceRegMgrSetInt(n, val);
}
/* Local Variables: */
/* tab-width: 8 */
/* c-basic-offset: 4 */
/* End: */