the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1
2
3#pragma once
4
5#include "TLSStorage.h"
6#include <sys/synchronization.h>
7#include <sys/sys_time.h>
8#include <sys/timer.h>
9#include <sys/ppu_thread.h>
10#include <libsn.h>
11
12#ifndef _CONTENT_PACKAGE
13
14#define DEBUG_PRINTF(fmt, arg...) printf(fmt, ## arg)
15
16#else
17#define DEBUG_PRINTF(fmt, arg...) (void)0
18
19#endif
20
21char* getConsoleHomePath();
22char* getUsrDirPath();
23char* getConsoleHomePathBDPatch();
24char* getUsrDirPathBDPatch();
25char* getDirName();
26
27DWORD TlsAlloc(VOID);
28LPVOID TlsGetValue(DWORD dwTlsIndex);
29BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue);
30
31
32typedef struct _RECT
33{
34 LONG left;
35 LONG top;
36 LONG right;
37 LONG bottom;
38} RECT, *PRECT;
39
40
41typedef void ID3D11Device;
42typedef void ID3D11DeviceContext;
43typedef void IDXGISwapChain;
44typedef RECT D3D11_RECT;
45typedef void ID3D11Buffer;
46typedef DWORD (*PTHREAD_START_ROUTINE)( LPVOID lpThreadParameter);
47typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
48
49typedef int errno_t;
50
51// typedef struct _RTL_CRITICAL_SECTION {
52// //
53// // The following field is used for blocking when there is contention for
54// // the resource
55// //
56//
57// union {
58// ULONG_PTR RawEvent[4];
59// } Synchronization;
60//
61// //
62// // The following three fields control entering and exiting the critical
63// // section for the resource
64// //
65//
66// LONG LockCount;
67// LONG RecursionCount;
68// HANDLE OwningThread;
69// } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
70
71typedef sys_lwmutex_t RTL_CRITICAL_SECTION;
72typedef sys_lwmutex_t* PRTL_CRITICAL_SECTION;
73
74typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
75typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
76typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;
77
78void EnterCriticalSection(CRITICAL_SECTION* _c);
79void LeaveCriticalSection(CRITICAL_SECTION* _c);
80void InitializeCriticalSection(CRITICAL_SECTION* _c);
81void DeleteCriticalSection(CRITICAL_SECTION* _c);
82HANDLE CreateEvent(void* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName);
83VOID Sleep(DWORD dwMilliseconds);
84BOOL SetThreadPriority(HANDLE hThread, int nPriority);
85DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
86
87LONG InterlockedCompareExchangeRelease(LONG volatile *Destination, LONG Exchange,LONG Comperand );
88
89
90VOID InitializeCriticalSection(PCRITICAL_SECTION CriticalSection);
91VOID InitializeCriticalSectionAndSpinCount(PCRITICAL_SECTION CriticalSection, ULONG SpinCount);
92VOID DeleteCriticalSection(PCRITICAL_SECTION CriticalSection);
93VOID EnterCriticalSection(PCRITICAL_SECTION CriticalSection);
94VOID LeaveCriticalSection(PCRITICAL_SECTION CriticalSection);
95ULONG TryEnterCriticalSection(PCRITICAL_SECTION CriticalSection);
96DWORD WaitForMultipleObjects(DWORD nCount, CONST HANDLE *lpHandles,BOOL bWaitAll,DWORD dwMilliseconds);
97
98LONG64 InterlockedCompareExchangeRelease64(LONG64 volatile *Destination, LONG64 Exchange, LONG64 Comperand);
99
100BOOL CloseHandle(HANDLE hObject);
101BOOL SetEvent(HANDLE hEvent);
102
103HMODULE GetModuleHandle(LPCSTR lpModuleName);
104
105HANDLE CreateThread( void* lpThreadAttributes, DWORD dwStackSize, void* lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );
106DWORD ResumeThread( HANDLE hThread );
107sys_ppu_thread_t GetCurrentThreadId(VOID);
108DWORD WaitForMultipleObjectsEx(DWORD nCount,CONST HANDLE *lpHandles,BOOL bWaitAll,DWORD dwMilliseconds,BOOL bAlertable );
109BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode);
110
111
112LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
113BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
114
115DWORD GetFileSize( HANDLE hFile, LPDWORD lpFileSizeHigh );
116BOOL GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize );
117BOOL WriteFile(
118HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped );
119BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped );
120#define INVALID_SET_FILE_POINTER false
121BOOL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod);
122HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
123#define CreateFile CreateFileA
124BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
125#define CreateDirectory CreateDirectoryA
126BOOL DeleteFileA(LPCSTR lpFileName);
127#define DeleteFile DeleteFileA
128DWORD GetFileAttributesA(LPCSTR lpFileName);
129#define GetFileAttributes GetFileAttributesA
130BOOL MoveFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName);
131#define MoveFile MoveFileA
132
133#define MAX_PATH 260
134
135void __debugbreak();
136VOID DebugBreak(VOID);
137
138
139enum D3D11_BLEND
140{
141 D3D11_BLEND_ZERO = 1,
142 D3D11_BLEND_ONE = 2,
143 D3D11_BLEND_SRC_COLOR = 3,
144 D3D11_BLEND_INV_SRC_COLOR = 4,
145 D3D11_BLEND_SRC_ALPHA = 5,
146 D3D11_BLEND_INV_SRC_ALPHA = 6,
147 D3D11_BLEND_DEST_ALPHA = 7,
148 D3D11_BLEND_INV_DEST_ALPHA = 8,
149 D3D11_BLEND_DEST_COLOR = 9,
150 D3D11_BLEND_INV_DEST_COLOR = 10,
151 D3D11_BLEND_SRC_ALPHA_SAT = 11,
152 D3D11_BLEND_BLEND_FACTOR = 14,
153 D3D11_BLEND_INV_BLEND_FACTOR = 15,
154 D3D11_BLEND_SRC1_COLOR = 16,
155 D3D11_BLEND_INV_SRC1_COLOR = 17,
156 D3D11_BLEND_SRC1_ALPHA = 18,
157 D3D11_BLEND_INV_SRC1_ALPHA = 19
158};
159
160
161enum D3D11_COMPARISON_FUNC
162{
163 D3D11_COMPARISON_NEVER = 1,
164 D3D11_COMPARISON_LESS = 2,
165 D3D11_COMPARISON_EQUAL = 3,
166 D3D11_COMPARISON_LESS_EQUAL = 4,
167 D3D11_COMPARISON_GREATER = 5,
168 D3D11_COMPARISON_NOT_EQUAL = 6,
169 D3D11_COMPARISON_GREATER_EQUAL = 7,
170 D3D11_COMPARISON_ALWAYS = 8
171};
172
173
174typedef struct _SYSTEMTIME {
175 WORD wYear;
176 WORD wMonth;
177 WORD wDayOfWeek;
178 WORD wDay;
179 WORD wHour;
180 WORD wMinute;
181 WORD wSecond;
182 WORD wMilliseconds;
183} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
184
185VOID GetSystemTime( LPSYSTEMTIME lpSystemTime);
186BOOL FileTimeToSystemTime(CONST FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime);
187BOOL SystemTimeToFileTime(CONST SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime);
188VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);
189
190typedef struct _MEMORYSTATUS {
191 DWORD dwLength;
192 DWORD dwMemoryLoad;
193 SIZE_T dwTotalPhys;
194 SIZE_T dwAvailPhys;
195 SIZE_T dwTotalPageFile;
196 SIZE_T dwAvailPageFile;
197 SIZE_T dwTotalVirtual;
198 SIZE_T dwAvailVirtual;
199} MEMORYSTATUS, *LPMEMORYSTATUS;
200
201
202#define WINAPI
203
204#define CREATE_SUSPENDED 0x00000004
205
206#define THREAD_BASE_PRIORITY_LOWRT 15 // value that gets a thread to LowRealtime-1
207#define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost
208#define THREAD_BASE_PRIORITY_MIN -2 // minimum thread base priority boost
209#define THREAD_BASE_PRIORITY_IDLE -15 // value that gets a thread to idle
210
211#define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN
212#define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1)
213#define THREAD_PRIORITY_NORMAL 0
214#define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX
215#define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1)
216#define THREAD_PRIORITY_ERROR_RETURN (MAXLONG)
217
218#define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT
219#define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE
220
221#define WAIT_TIMEOUT 258L
222#define STATUS_ABANDONED_WAIT_0 ((DWORD )0x00000080L)
223#define WAIT_ABANDONED ((STATUS_ABANDONED_WAIT_0 ) + 0 )
224
225#define MAXUINT_PTR (~((UINT_PTR)0))
226#define MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
227#define MININT_PTR (~MAXINT_PTR)
228
229#define MAXULONG_PTR (~((ULONG_PTR)0))
230#define MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
231#define MINLONG_PTR (~MAXLONG_PTR)
232
233#define MAXUHALF_PTR ((UHALF_PTR)~0)
234#define MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
235#define MINHALF_PTR (~MAXHALF_PTR)
236
237#define INVALID_HANDLE_VALUE ((HANDLE)-1)
238//
239// Generic test for success on any status value (non-negative numbers
240// indicate success).
241//
242
243#define HRESULT_SUCCEEDED(Status) ((HRESULT)(Status) >= 0)
244
245//
246// and the inverse
247//
248// #define _HRESULT_TYPEDEF_(_sc) _sc
249
250#define FAILED(Status) ((HRESULT)(Status)<0)
251// #define MAKE_HRESULT(sev,fac,code) \
252// ((HRESULT) (((unsigned int)(sev)<<31) | ((unsigned int)(fac)<<16) | ((unsigned int)(code))) )
253// #define MAKE_SCODE(sev,fac,code) \
254// ((SCODE) (((unsigned int)(sev)<<31) | ((unsigned int)(fac)<<16) | ((unsigned int)(code))) )
255// #define E_FAIL _HRESULT_TYPEDEF_(0x80004005L)
256// #define E_ABORT _HRESULT_TYPEDEF_(0x80004004L)
257// #define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L)
258
259#define GENERIC_READ (0x80000000L)
260#define GENERIC_WRITE (0x40000000L)
261#define GENERIC_EXECUTE (0x20000000L)
262#define GENERIC_ALL (0x10000000L)
263
264#define FILE_SHARE_READ 0x00000001
265#define FILE_SHARE_WRITE 0x00000002
266#define FILE_SHARE_DELETE 0x00000004
267#define FILE_ATTRIBUTE_READONLY 0x00000001
268#define FILE_ATTRIBUTE_HIDDEN 0x00000002
269#define FILE_ATTRIBUTE_SYSTEM 0x00000004
270#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
271#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
272#define FILE_ATTRIBUTE_DEVICE 0x00000040
273#define FILE_ATTRIBUTE_NORMAL 0x00000080
274#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
275
276#define FILE_FLAG_WRITE_THROUGH 0x80000000
277#define FILE_FLAG_OVERLAPPED 0x40000000
278#define FILE_FLAG_NO_BUFFERING 0x20000000
279#define FILE_FLAG_RANDOM_ACCESS 0x10000000
280#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
281#define FILE_FLAG_DELETE_ON_CLOSE 0x04000000
282#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000
283
284#define FILE_BEGIN 0
285#define FILE_CURRENT 1
286#define FILE_END 2
287
288#define CREATE_NEW 1
289#define CREATE_ALWAYS 2
290#define OPEN_EXISTING 3
291#define OPEN_ALWAYS 4
292#define TRUNCATE_EXISTING 5
293
294#define PAGE_NOACCESS 0x01
295#define PAGE_READONLY 0x02
296#define PAGE_READWRITE 0x04
297#define PAGE_WRITECOPY 0x08
298#define PAGE_EXECUTE 0x10
299#define PAGE_EXECUTE_READ 0x20
300#define PAGE_EXECUTE_READWRITE 0x40
301#define PAGE_EXECUTE_WRITECOPY 0x80
302#define PAGE_GUARD 0x100
303#define PAGE_NOCACHE 0x200
304#define PAGE_WRITECOMBINE 0x400
305#define PAGE_USER_READONLY 0x1000
306#define PAGE_USER_READWRITE 0x2000
307#define MEM_COMMIT 0x1000
308#define MEM_RESERVE 0x2000
309#define MEM_DECOMMIT 0x4000
310#define MEM_RELEASE 0x8000
311#define MEM_FREE 0x10000
312#define MEM_PRIVATE 0x20000
313#define MEM_RESET 0x80000
314#define MEM_TOP_DOWN 0x100000
315#define MEM_NOZERO 0x800000
316#define MEM_LARGE_PAGES 0x20000000
317#define MEM_HEAP 0x40000000
318#define MEM_16MB_PAGES 0x80000000
319
320#define IGNORE 0 // Ignore signal
321#define INFINITE 0xFFFFFFFF // Infinite timeout
322#define WAIT_FAILED ((DWORD)0xFFFFFFFF)
323#define STATUS_WAIT_0 ((DWORD )0x00000000L)
324#define WAIT_OBJECT_0 ((STATUS_WAIT_0 ) + 0 )
325#define STATUS_PENDING ((DWORD )0x00000103L)
326#define STILL_ACTIVE STATUS_PENDING
327
328DWORD GetLastError(VOID);
329VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer);
330
331DWORD GetTickCount();
332BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency);
333BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount);
334
335
336#define ERROR_SUCCESS 0L
337#define ERROR_IO_PENDING 997L // dderror
338#define ERROR_CANCELLED 1223L
339//#define S_OK ((HRESULT)0x00000000L)
340#define S_FALSE ((HRESULT)0x00000001L)
341
342#define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
343#define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
344#define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
345#define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
346#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
347
348#define MoveMemory RtlMoveMemory
349#define CopyMemory RtlCopyMemory
350#define FillMemory RtlFillMemory
351#define ZeroMemory RtlZeroMemory
352
353#define CDECL
354#define APIENTRY
355#define wsprintfW swprintf
356#define wcsncpy_s wcsncpy
357#define _wcstoui64 wcstoll
358
359#define VK_ESCAPE 0x1B
360#define VK_RETURN 0x0D
361
362VOID OutputDebugStringW(LPCWSTR lpOutputString);
363VOID OutputDebugString(LPCSTR lpOutputString);
364VOID OutputDebugStringA(LPCSTR lpOutputString);
365
366errno_t _itoa_s(int _Value, char * _DstBuf, size_t _Size, int _Radix);
367errno_t _i64toa_s(__int64 _Val, char * _DstBuf, size_t _Size, int _Radix);
368
369int _wtoi(const wchar_t *_Str);
370
371#define __declspec(a)
372extern "C" int _wcsicmp (const wchar_t * dst, const wchar_t * src);
373
374size_t wcsnlen(const wchar_t *wcs, size_t maxsize);
375
376typedef struct _WIN32_FIND_DATAA {
377 DWORD dwFileAttributes;
378 FILETIME ftCreationTime;
379 FILETIME ftLastAccessTime;
380 FILETIME ftLastWriteTime;
381 DWORD nFileSizeHigh;
382 DWORD nFileSizeLow;
383 DWORD dwReserved0;
384 DWORD dwReserved1;
385 CHAR cFileName[ MAX_PATH ];
386 CHAR cAlternateFileName[ 14 ];
387} WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
388typedef WIN32_FIND_DATAA WIN32_FIND_DATA;
389typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
390typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
391
392typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
393 DWORD dwFileAttributes;
394 FILETIME ftCreationTime;
395 FILETIME ftLastAccessTime;
396 FILETIME ftLastWriteTime;
397 DWORD nFileSizeHigh;
398 DWORD nFileSizeLow;
399} WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;
400
401
402DWORD GetFileAttributesA(LPCSTR lpFileName);
403#define GetFileAttributes GetFileAttributesA
404typedef enum _GET_FILEEX_INFO_LEVELS {
405 GetFileExInfoStandard,
406 GetFileExMaxInfoLevel
407} GET_FILEEX_INFO_LEVELS;
408
409BOOL GetFileAttributesExA(LPCSTR lpFileName,GET_FILEEX_INFO_LEVELS fInfoLevelId,LPVOID lpFileInformation);
410#define GetFileAttributesEx GetFileAttributesExA
411
412BOOL DeleteFileA(LPCSTR lpFileName);
413#define DeleteFile DeleteFileA
414
415
416HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData);
417#define FindFirstFile FindFirstFileA
418
419BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData);
420#define FindNextFile FindNextFileA
421#define FindClose(hFindFile) CloseHandle(hFindFile)
422
423DWORD XGetLanguage();
424DWORD XGetLocale();
425DWORD XEnableGuestSignin(BOOL fEnable);
426
427#ifdef _CONTENT_PACKAGE
428#define PS3_STUBBED { }
429#else
430#define PS3_STUBBED { static bool bSet = false; if(!bSet){printf("missing function on PS3 : %s\n Tell MarkH about this, then press f5 to continue.", __FUNCTION__); bSet = true; assert(0);} }
431#endif