the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3
4#include <stdlib.h>
5#include <string.h>
6#include <cell/l10n.h>
7#include <cell/pad.h>
8#include <cell/cell_fs.h>
9#include <sys/process.h>
10#include <sys/ppu_thread.h>
11#include <cell/sysmodule.h>
12#include <cell/rtc.h>
13
14#include <libsn.h>
15
16#include <sysutil/sysutil_common.h>
17#include <sysutil/sysutil_sysparam.h>
18#include <sysutil/sysutil_savedata.h>
19
20#include "STO_TitleSmallStorage.h"
21#include "../Passphrase/ps3__np_conf.h"
22
23
24
25#if 0
26
27int32_t CTSS::TssSizeCheck(size_t size)
28{
29 printf("=======Tss Data size = %d\n", size);
30
31 //E Recommendation: The data's size should be checked against for the server operation mistake.
32 //E If it is necessary, implement size check based on your data format, please.
33
34 if (size == 0)
35 {
36 printf("Tss File size is 0 byte. Maybe, data isn't set on the server.\n\n");
37 printf("\tThe data is set with scp. The account is generable in PS3 Developer Network.\n");
38 printf("\tThere are three server environments. for development, environment for test, and product.\n");
39 }
40 return 0;
41}
42
43int32_t CTSS::TssHashCheck(void *data, size_t size)
44{
45 //E Recommendation: The data format should be include it's hash against for operation mistakes and crack.
46 //E If it is necessary, implement hash check based on your data format, please.
47 return 0;
48}
49
50int32_t CTSS::TssVersionCheck(void *data, size_t size)
51{
52 //E Recommendation: The data format should be include it's version for changes of the format.
53 //E If it is necessary, implement version check based on your data format, please.
54 return 0;
55}
56
57int32_t CTSS::doLookupTitleSmallStorage(void)
58{
59 int32_t ret = 0;
60 int32_t transId = 0;
61 void *data=NULL;
62 size_t dataSize=0;
63
64 SceNpId npId;
65 ret = sceNpManagerGetNpId(&npId);
66 if(ret < 0){
67 return ret;
68 }
69
70 ret = sceNpLookupInit();
71 if (ret < 0)
72 {
73 printf("sceNpLookupInit() failed. ret = 0x%x\n", ret);
74 goto error;
75 }
76 ret = sceNpTusInit(0);
77 if (ret < 0)
78 {
79 printf("sceNpTusInit() failed. ret = 0x%x\n", ret);
80 goto error;
81 }
82
83 ret = sceNpLookupCreateTitleCtx(&s_npCommunicationId, &npId);
84 if (ret < 0)
85 {
86 printf("sceNpLookupCreateTitleCtx() failed. ret = 0x%x\n", ret);
87 goto error;
88 }
89 m_lookupTitleCtxId = ret;
90
91 ret = sceNpTusCreateTitleCtx(&s_npCommunicationId, &s_npCommunicationPassphrase, &npId);
92 if (ret < 0)
93 {
94 printf("sceNpTusCreateTitleCtx() failed. ret = 0x%x\n", ret);
95 goto error;
96 }
97 printf("sceNpTusCreateTitleCtx() return %x\n", ret);
98 m_tusTitleCtxId = ret;
99
100 //memset(&npclient_info, 0x00, sizeof(npclient_info));
101
102 data = malloc(SCE_NET_NP_TSS_MAX_SIZE);
103 if (data == NULL)
104 {
105 printf("out of memory: can't allocate memory for titleSmallStorage\n");
106 ret = -1;
107 goto error;
108 }
109 memset(data, 0x00, SCE_NET_NP_TSS_MAX_SIZE);
110
111 ret = sceNpLookupCreateTransactionCtx(m_lookupTitleCtxId);
112 if (ret < 0)
113 {
114 printf("sceNpLookupCreateTransactionCtx() failed. ret = 0x%x\n", ret);
115 goto error;
116 }
117 transId = ret;
118
119
120// ret = sceNpLookupTitleSmallStorage(transId,
121// data,
122// SCE_NET_NP_TSS_MAX_SIZE,
123// &dataSize,
124// NULL);
125// if (ret < 0)
126// {
127// printf("sceNpLookupTitleSmallStorage() failed. ret = 0x%x\n", ret);
128// goto error;
129// }
130//
131// ret = TssSizeCheck(dataSize);
132// if (ret < 0)
133// {
134// goto error;
135// }
136// ret = TssHashCheck(data, dataSize);
137// if (ret < 0)
138// {
139// goto error;
140// }
141// ret = TssVersionCheck(data, dataSize);
142// if (ret < 0)
143// {
144// goto error;
145// }
146
147/*
148 // Process communication
149 void *data;
150 size_t dataSize;
151 SceNpTssSlotId slotId=SLOTID;
152 SceNpTssDataStatus dataStatus;
153 const char *ptr =NULL;
154 size_t recvdSize=0;
155 size_t totalSize=0;
156 size_t recvSize=0;
157
158 do {
159 ret = sceNpTssGetData(
160 transId,
161 slotId,
162 &dataStatus,
163 sizeof(SceNpTssDataStatus),
164 ptr,
165 recvSize,
166 NULL);
167 if (ret < 0)
168 {
169 // Error handling
170 goto error;
171 }
172 if (dataStatus.contentLength == 0)
173 {
174 // Processing when there is no data
175 goto finish;
176 }
177 if (ptr == NULL)
178 {
179 ptr = malloc(dataStatus.contentLength);
180 if (ptr == NULL){
181 // Error handling
182 goto error;
183 }
184 recvSize = BLOCKSIZE;
185 }
186 recvedSize += ret;
187 ptr += ret;
188 } while (recvedSize < dataStatus.contentLength);
189
190*/
191
192
193
194error:
195 if (transId > 0)
196 {
197 ret = sceNpLookupDestroyTransactionCtx(transId);
198 printf("sceNpLookupDestroyTransactionCtx() done. ret = 0x%x\n", ret);
199 }
200 if (data != NULL)
201 {
202 free(data);
203 }
204
205 sceNpTusTerm();
206
207 return 0;
208}
209
210#endif