From fcc777a5acc8fcde3490072f7d77af0d2a4b4b49 Mon Sep 17 00:00:00 2001 From: Ocarinaoftime Date: Wed, 25 Mar 2026 09:40:37 -0400 Subject: [PATCH 1/2] Add more ECResults and add ec_csup.cpp --- src/sdk/ec/csup.h | 78 ++++++++++++++++++++++++++++++++++++++ src/sdk/ec/result.h | 55 ++++++++++++++++++++++++++- src/sdk/ec/src/ec_csup.cpp | 59 ++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 src/sdk/ec/csup.h create mode 100644 src/sdk/ec/src/ec_csup.cpp diff --git a/src/sdk/ec/csup.h b/src/sdk/ec/csup.h new file mode 100644 index 000000000..96bfae2c5 --- /dev/null +++ b/src/sdk/ec/csup.h @@ -0,0 +1,78 @@ +#include + +enum ECOperation { + EC_OP_Invalid = 0, + EC_OP_PurchaseTitle = 1, + EC_OP_Unused1 = 2, + EC_OP_SyncTickets = 3, + EC_OP_RefreshCachedBalance = 4, + EC_OP_PurchasePoints = 5, + EC_OP_GetTitle = 6, + EC_OP_CheckRegistration = 7, + EC_OP_Register = 8, + EC_OP_Unregister = 9, + EC_OP_Transfer = 10, + EC_OP_DeleteOwnership = 11, + EC_OP_PurchaseGiftTitle = 12, + EC_OP_AcceptGiftTitle = 13, + EC_OP_CheckDeviceStatus = 14, + EC_OP_SyncRegistration = 15, + EC_OP_Connect = 16, + EC_OP_DownloadContents = 17, + EC_OP_Subscribe = 18, + EC_OP_GetChallenge = 19, + EC_OP_UpdateStatus = 20, + EC_OP_ListTitles = 21, + EC_OP_ListContentSets = 22, + EC_OP_ListSubscriptionPricings = 23, + EC_OP_ListPointsPricings = 24, + EC_OP_ListECardItems = 25, + EC_OP_ListTitleContents = 26, +}; + +enum ECOpPhase { + EC_PHASE_NoPhase = 0, + EC_PHASE_Starting = 1, + EC_PHASE_Done = 2, + EC_PHASE_PurchasingTitle = 3, + EC_PHASE_Unused1 = 4, + EC_PHASE_DownloadingContent = 5, + EC_PHASE_GettingTicketsFromServer = 6, + EC_PHASE_GettingPointsBalance = 7, + EC_PHASE_PurchasingPoints = 8, + EC_PHASE_CheckingRegistrationStatus = 9, + EC_PHASE_Registering = 10, + EC_PHASE_Unregistering = 11, + EC_PHASE_Transfer = 12, + EC_PHASE_DeletingOwnership = 13, + EC_PHASE_AcceptingGiftTitle = 14, + EC_PHASE_GettingDeviceStatus = 15, + EC_PHASE_SyncingRegistration = 16, + EC_PHASE_Connecting = 17, + EC_PHASE_UpdatingStatus = 18, + EC_PHASE_ListingTitles = 19, + EC_PHASE_ListingContentSets = 20, + EC_PHASE_ListingSubscriptionPricings = 21, + EC_PHASE_ListingPointsPricings = 22, + EC_PHASE_ListingECardItems = 23, + EC_PHASE_GettingECardBalance = 24, + EC_PHASE_Subscribing = 25, + EC_PHASE_GettingChallenge = 26, + EC_PHASE_ListingTitleContents = 27, +}; + +struct ECProgress { + // total size: 0x9C + ECResult status; // offset 0x0, size 0x4 + enum ECOperation operation; // offset 0x4, size 0x4 + enum ECOpPhase phase; // offset 0x8, size 0x4 + long isCancelRequested; // offset 0xC, size 0x4 + unsigned long totalSize; // offset 0x10, size 0x4 + unsigned long downloadedSize; // offset 0x14, size 0x4 + long errCode; // offset 0x18, size 0x4 + char errInfo[128]; // offset 0x1C, size 0x80 +}; + +namespace ec { + unsigned long getExternalErrCode(ECProgress *progress); +} \ No newline at end of file diff --git a/src/sdk/ec/result.h b/src/sdk/ec/result.h index a9deaf910..c72015397 100644 --- a/src/sdk/ec/result.h +++ b/src/sdk/ec/result.h @@ -5,8 +5,61 @@ enum ECResult { ECResult_Success = 0, ECResult_Failure = -1, + + ECResult_UnkFail = -2, - ECResult_InvalidBufHeap = -4004, + ECResult_ECFail = -4001, /* Generic error */ + ECResult_NotSupported = -4002, /* Feature not implemented */ + ECResult_InsufficientResource = -4003, + ECResult_InvalidBufHeap = -4004, + ECResult_NoMemory = -4005, + ECResult_NotFound = -4006, + ECResult_NotBusy = -4007, /* no active async operation */ + ECResult_Busy = -4008, + ECResult_NotDone = -4009, + + ECResult_NetNotAvailable = -4013, /* Internet access not available */ + ECResult_WebServiceError = -4015, /* Server reports a problem */ + ECResult_InvalidECard = -4017, /* Invalid eCard */ + ECResult_Overflow = -4018, /* Output too big for buf provided */ + /* Should never see EC_E~~RROR_OVERFLOW */ + ECResult_ContentRecvErr = -4019, /* Error getting content from server */ + ECResult_ContentSizeMismatch = -4020, /* Downloaded content size doesn't match tmd */ + + ECResult_WebServiceResError = -4034, /* invalid web service response */ + ECResult_TicketImportErr = -4035, /* problem importing ticket */ + ECResult_TMDImportErr = -4036, /* problem importing title */ + ECResult_ContentImportErr = -4037, /* problem importing title content */ + ECResult_Canceled = -4038, /* an extended operation was canceled */ + ECResult_AlreadyInitialized = -4039, /* one time only action was previously done */ + ECResult_Init = -4041, /* library has not been initialized */ + ECResult_NotRegistered = -4042, /* device is not registered */ + ECResult_RecvWSErr = -4043, /* recv error on web service response */ + ECResult_NotActive = -4044, /* expected operation is not active op */ + ECResult_FileRead = -4045, + ECResult_FileWrite = -4046, + ECResult_TitleNotOwned = -4050, /* Title is not owned */ + ECResult_BadHeap = -4051, /* Bad heap */ + ECResult_HeaderParseErr = -4052, /* Could not parse http header */ + ECResult_ConfigErr = -4053, /* Invalid configuration (e.g. url is invalid) */ + ECResult_CancelFailed = -4054, /* Could not cancel asynchronous operaton */ + ECResult_UserINodes = -4055, /* Operation would exceed max user inodes */ + ECResult_UserBlocks = -4056, /* Operation would exceed max user blocks */ + ECResult_SystemINodes = -4057, /* Operation would exceed max sys inodes */ + ECResult_SystemBlocks = -4058, /* Operation would exceed max sys blocks */ + ECResult_NoDeviceCode = -4065, /* Operation requires device code */ + ECResult_NeedTicketSync = -4066, /* Operation requres ticket sync */ + ECResult_NeedECConnect = -4069, /* Operation requires EC_Connect() */ + ECResult_NoTMD = -4070, /* Title TMD is not on device */ + ECResult_NeedFirmwareUpdate = -4071, /* Title requires updated firmware */ + ECResult_PCPassIncorrect = -4074, /* Parental control password doesn't match */ + ECResult_NoPC = -4075, /* Parental control is not enabled */ + ECResult_NeedEULA = -4076, /* Customer has not agreed to EULA */ + ECResult_AgeRestricted = -4077, /* Opration requires parental control password */ + ECResult_PointsRestricted = -4078, /* Opration requires parental control password */ + ECResult_TitleOwned = -4079, /* Attempt purchase already owned item */ + ECResult_InsufficientFunds = -4081, /* Not enough funds to purchase the item */ + }; #define EC_SUCCESS(expr) ((expr) >= 0) diff --git a/src/sdk/ec/src/ec_csup.cpp b/src/sdk/ec/src/ec_csup.cpp new file mode 100644 index 000000000..88a1f2a86 --- /dev/null +++ b/src/sdk/ec/src/ec_csup.cpp @@ -0,0 +1,59 @@ +#include + +int EC_GetCustomerSupportCode(int p1) { + int code; + if (p1 >= 0) { + code = 0; + } else { + code = 200000; + if (-p1 <= 9999) { + code = code - p1; + } + } + return code; +} + +namespace ec { + unsigned long getExternalErrCode(ECProgress *progress) { + ECResult status = progress->status; + long errCode = progress->errCode; + if (ECResult_WebServiceResError < status) { + if (status != ECResult_WebServiceError) { + if (status < ECResult_WebServiceError) { + if (status == ECResult_InvalidECard) goto label1; + } else if (status == ECResult_NotDone || (-4010 < status && ECResult_Failure < status)) { + errCode = 0; + goto label3; + } + goto label2; + } + goto label1; + } + if (status == ECResult_TitleOwned) goto label1; + if (status < ECResult_TitleOwned) { + if (status == ECResult_InsufficientFunds) goto label1; + } else if (status == ECResult_AgeRestricted) goto label1; + if (status == ECResult_NotRegistered) { + if (errCode <= 0) goto label2; +label1: + if (errCode <= 0) goto someLabel; + errCode = errCode + 205000; + if (206999 < errCode) errCode = 205000; + goto label3; + } +label2: + if ((status == ECResult_ContentRecvErr || status == ECResult_ECFail || status == ECResult_RecvWSErr) && errCode < 0) { + errCode = 200000 - errCode; + if (204999 < errCode) errCode = 200000; + goto label3; + } +someLabel: + if (status < ECResult_Success && (errCode = 200000 - status, 204999 < errCode)) { + errCode = 200000; + } +label3: + if (errCode == 0) return 0; + if (9998 >= errCode - 200001U) return -(errCode - 200000); + return -10000; + }; +} \ No newline at end of file From 6afc0645ac27792ac11dafa8f06de1b4e268c57d Mon Sep 17 00:00:00 2001 From: Ocarinaoftime Date: Thu, 26 Mar 2026 11:56:18 -0400 Subject: [PATCH 2/2] Add ec_api.cpp and dependencies --- src/sdk/ec/api.h | 23 +++ src/sdk/ec/asyncOp.h | 35 ++++ src/sdk/ec/dk.h | 12 ++ src/sdk/ec/shoplog_bw.h | 4 + src/sdk/ec/src/ec_api.cpp | 374 ++++++++++++++++++++++++++++++++++++++ src/sdk/ec/string.h | 2 + 6 files changed, 450 insertions(+) create mode 100644 src/sdk/ec/api.h create mode 100644 src/sdk/ec/asyncOp.h create mode 100644 src/sdk/ec/dk.h create mode 100644 src/sdk/ec/shoplog_bw.h create mode 100644 src/sdk/ec/src/ec_api.cpp diff --git a/src/sdk/ec/api.h b/src/sdk/ec/api.h new file mode 100644 index 000000000..7b90b5f06 --- /dev/null +++ b/src/sdk/ec/api.h @@ -0,0 +1,23 @@ +#ifndef EC_API_H +#define EC_API_H + +#include +#include +#include + +class ECContentInfo { + int field0x0; //size 0x4, offset 0x0 + short field0x4; //size 0x2, offset 0x4 + short field0x6; //size 0x2, offset 0x6 + int field0x8; //size 0x4, offset 0x8 + int field0xc; //size 0x4, offset 0xc + void operator=(const ECContentInfo &other); +}; + +namespace ec { + const char *buildDateTime = (char *)"Feb 8 2010 20:10:32"; + ECResult deleteTitleContent(unsigned long long); + ECResult getTitleInfos(ECTitleInfo *, unsigned long *, unsigned long long, bool); +} + +#endif \ No newline at end of file diff --git a/src/sdk/ec/asyncOp.h b/src/sdk/ec/asyncOp.h new file mode 100644 index 000000000..be402a5bb --- /dev/null +++ b/src/sdk/ec/asyncOp.h @@ -0,0 +1,35 @@ +#ifndef RVL_EC_ASYNCOP_H +#define RVL_EC_ASYNCOP_H + +#include +#include +#include + +class ECAsyncOpEnv; +class ECAsyncOp; + +class ECAsyncOpEnv { +public: + _SHRThread *opThread; //offset 0x4, size 0x4 + int unk0x4c; //offset 0x4c, size 0x4. maybe cached balance? + bool unk0x50; //offset 0x50, size 0x1 + ECString unk0xc0; //offset 0xc0, size 0x4 + bool unk0x174; //offset 0x174, size 0x1 + ECString m_AppId; //offset 0x178, size 0x4 + ECString m_TIN; //offset 0x184, size 0x4 + int unk0x190; //offset 0x190, size 0x4 (need to check this) + ECResult init(); + ~ECAsyncOpEnv(); + ECResult checkParentalControlPassword(char const *, long *); + void lock(); + void unlock(); + void lockProgress(); + void unlockProgress(); + ECResult shutDown(); +}; + +namespace ec { + ECAsyncOpEnv *op; +} + +#endif \ No newline at end of file diff --git a/src/sdk/ec/dk.h b/src/sdk/ec/dk.h new file mode 100644 index 000000000..77308200a --- /dev/null +++ b/src/sdk/ec/dk.h @@ -0,0 +1,12 @@ +#ifndef RVL_EC_DK_H +#define RVL_EC_DK_H + +#include +#include + +namespace ec { + ECResult init(ECNameValue *, unsigned long); + ECResult shutdown(); +} + +#endif \ No newline at end of file diff --git a/src/sdk/ec/shoplog_bw.h b/src/sdk/ec/shoplog_bw.h new file mode 100644 index 000000000..d3634b6d7 --- /dev/null +++ b/src/sdk/ec/shoplog_bw.h @@ -0,0 +1,4 @@ +#ifndef RVL_EC_SHOPLOG_BW_H +#define RVL_EC_SHOPLOG_BW_H +unsigned int checkECDKSyncNeededForTitle(); +#endif \ No newline at end of file diff --git a/src/sdk/ec/src/ec_api.cpp b/src/sdk/ec/src/ec_api.cpp new file mode 100644 index 000000000..aa26e5d7b --- /dev/null +++ b/src/sdk/ec/src/ec_api.cpp @@ -0,0 +1,374 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +ECResult EC_Init(ECNameValue *p1, unsigned long p2) { + ECResult status; + if (ec::op != 0x0) { + status = ECResult_AlreadyInitialized; + } else { + if (p2 == 0 || p1 == 0x0) { + status = ECResult_InvalidBufHeap; + } else { + try { + status = ec::init(p1, p2); + if (status == ECResult_Success) { + status = ec::op->init(); + ec::logmsg(ECLogLevel_Info, "ECommerce Library built %s\n", ec::buildDateTime); + } + } catch (std::exception) { + ec::logmsg(ECLogLevel_Error, "Caught exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x38); //0x38 should be __LINE__ + status = ECResult_NoMemory; + } catch (std::bad_alloc) { + ec::logmsg(ECLogLevel_Error, "Caught bad_alloc exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x38); //0x38 should be __LINE__ + status = ECResult_ECFail; + } + } //do nothing? + } + return status; +} + +int EC_Shutdown() { + ECResult status; + if (ec::op == NULL) { + return ECResult_Success; + } else { + try { + ec::dumpMemInfo(); + status = ec::op->shutDown(); + if (status == ECResult_Success && (status = ec::shutdown(), status == ECResult_Success)) { + ec::op->~ECAsyncOpEnv(); + ec::op = NULL; + } + ec::dumpMemInfo(); + } catch (std::exception) { + ec::logmsg(ECLogLevel_Error, "Caught exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x51); + status = ECResult_NoMemory; + } catch (std::bad_alloc) { + ec::logmsg(ECLogLevel_Error, "Caught bad_alloc exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x51); + status = ECResult_ECFail; + } + } + return status; +} + +int EC_SetParameter(const char *paramId, const char *value) { + ECResult status; + if (ec::op == NULL) { + return ECResult_Init; + } else if (paramId == NULL) { + return ECResult_InvalidBufHeap; + } else { + try { + ec::op->lock(); + status = ECResult_Success; + int cmp = strncmp(paramId, "TIN", 4); + if (cmp == 0) { + if (value == NULL) { + ec::op->m_TIN = ""; + } else { + ec::op->m_TIN = value; + } + } else { + cmp = strncmp(paramId, "AppId", 6); + if (cmp == 0) { + if (value == NULL) { + ec::op->m_AppId = ""; + } else { + ec::op->m_AppId = value; + } + } else { + cmp = strncmp(paramId, "PCPW", 5); //Parental control password + if (cmp == 0) { + long what = 0xffffffC0; + status = ec::op->checkParentalControlPassword(value, &what); + if (status == ECResult_Success && what == 0) { + status = ECResult_PCPassIncorrect; + } + } else { + cmp = strncmp(paramId, "USE_NCRS", 9); //what is NCRs + if (cmp == 0) { + if (value == NULL) { + ec::isUseNCRs = false; + } else { + ec::isUseNCRs = (true - (value == 0)); + } + } else { + cmp = strncmp(paramId, "SPAVE_CHECK_POLICY", 19); + if (cmp == 0) { + if (value == NULL) { + status = ECResult_InvalidBufHeap; + } else { + cmp = strncmp(value, "SPACE_CHECK_USER_ONLY", 22); + if (cmp == 0) { + ec::op->unk0x190 = 0; + } else { + cmp == strncmp(value, "SPACE_CHECK_ENTIRE_FS", 22); + if (cmp == 0) { + ec::op->unk0x190 = 1; + } else { + status = ECResult_InvalidBufHeap; + } + } + } + } else { + status = ECResult_NotFound; + } + } + } + } + } + } catch(std::exception) { + ec::logmsg(ECLogLevel_Error, "Caught exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x9d); + status = ECResult_NoMemory; + } catch(std::bad_alloc) { + ec::logmsg(ECLogLevel_Error, "Caught bad_alloc exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x9d); + status = ECResult_ECFail; + } + ec::op->unlock(); + } + return status; +} + +int EC_GetProgress(unsigned long p1, ECResult *p2) { + ECResult status; + if (ec::op == NULL) { + if (p2 != NULL) { + p2[6] = ECResult_Init; + *p2 = ECResult_Init; + } + return ECResult_Init; + } else if (p2 == NULL) { + return ECResult_InvalidBufHeap; + } else { + ec::op->lockProgress(); + try { + _SHRThread *pOpThread = ec::op->opThread; + if (pOpThread == NULL) { + p2[6] = ECResult_NotBusy; + *p2 = ECResult_NotBusy; + } else if (p1 == 0 || p1 != pOpThread->osThread.context.gprs[1]) { + p2[6] = ECResult_NotActive; + *p2 = ECResult_NotActive; + } else { + *p2 = (ECResult)pOpThread->osThread.context.gprs[8]; + unsigned long *pEVar3 = (unsigned long *)p2 + 6; + unsigned long *puVar2 = pOpThread->osThread.context.gprs + 14; + p2[1] = (ECResult)pOpThread->osThread.context.gprs[9]; + p2[2] = (ECResult)pOpThread->osThread.context.gprs[10]; + p2[3] = (ECResult)pOpThread->osThread.context.gprs[11]; + p2[4] = (ECResult)pOpThread->osThread.context.gprs[12]; + p2[5] = (ECResult)pOpThread->osThread.context.gprs[13]; + p2[6] = (ECResult)pOpThread->osThread.context.gprs[14]; + int iVar5 = 16; + unsigned long *puVar1; + unsigned long result; + //TODO: do something about this + do { + puVar1++; + puVar2 += 2; + result = *puVar2; + pEVar3[1] = *puVar1; + pEVar3 += 2; + *pEVar3 = result; + iVar5--; + } while (iVar5 != 0); + result = ec::getExternalErrCode((ECProgress *)(ec::op->opThread->osThread.context.gprs + 8)); + p2[6] = (ECResult)result; + } + status = *p2; + } catch (std::exception) { + ec::logmsg(ECLogLevel_Error, "Caught exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x38); //0x38 should be __LINE__ + status = ECResult_NoMemory; + } catch (std::bad_alloc) { + ec::logmsg(ECLogLevel_Error, "Caught bad_alloc exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x38); //0x38 should be __LINE__ + status = ECResult_ECFail; + } + ec::op->unlockProgress(); + } + return status; +} + +//TODO: Work on this function +int EC_CancelOperation(unsigned long param_1) { + ECResult status; + _SHRThread *p_Var1; + + if (ec::op == NULL) { + return ECResult_Init; + } else { + ec::op->lock(); + status = ECResult_Success; + p_Var1 = ec::op->opThread; + if (p_Var1 == NULL) { + status = ECResult_NotBusy; + } else if (param_1 == 0 && param_1 != p_Var1->osThread.context.gprs[1]) { + status = ECResult_NotActive; + if (p_Var1->osThread.context.gprs[8] == ECResult_NotBusy) { + status = ECResult_NotBusy; + } else { + p_Var1->osThread.context.gprs[11] = 1; + } + } else { + status = ECResult_NotActive; + } + ec::op->unlock(); + } + return status; +} + +//TODO: Work on cntlzw on line 234 +ECResult EC_GetCachedBalance(int *param_1) { + ECResult status; + if (ec::op == NULL) { + status = ECResult_Init; + } else if (param_1 == NULL) { + status = ECResult_InvalidBufHeap; + } else if (ec::op->unk0x174 == false) { + status = ECResult_NeedECConnect; + } else { + if (ec::op->unk0xc0.size() != 0) { + status = ECResult_NotRegistered; + } else { + if (ec::op->unk0x50 == false) { + status = ECResult_NotFound; + } else { + status = ECResult_Success; + *param_1 = ec::op->unk0x4c; + } + } + } + return status; +} + +ECResult EC_DeleteTitle() { + ECResult status; + unsigned long long content; + if (ec::op == NULL) { + return ECResult_Init; + } else { + try { + status = ec::deleteTitleContent(content); + } catch(std::exception) { + ec::logmsg(ECLogLevel_Error, "Caught exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x11c); + status = ECResult_NoMemory; + } catch(std::bad_alloc) { + ec::logmsg(ECLogLevel_Error, "Caught bad_alloc exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x11c); + status = ECResult_ECFail; + } + } + return status; +} + +//TODO: Work on this function +int EC_GetTitleInfo(unsigned long long titleId, ECTitleInfo *titleInfo, int *param_3) { + ECResult EVar1; + int iVar2; + unsigned long long in_stack_ffffffcc; + + if (ec::op == NULL) { + EVar1 = ECResult_Init; + } else if (param_3 == NULL) { + EVar1 = ECResult_InvalidBufHeap; + } else if (titleInfo == 0 && titleId == 0x0) { + EVar1 = ECResult_InvalidBufHeap; + } else { + try { + ec::op->lock(); + iVar2 = 1; + EVar1 = ec::getTitleInfos(titleInfo,(unsigned long *)0xffffffc8,titleId, in_stack_ffffffcc); + if ((EVar1 == ECResult_Success) && (iVar2 == 0)) { + EVar1 = ECResult_TitleNotOwned; + } + ec::op->unlock(); + } catch(std::exception) { + ec::logmsg(ECLogLevel_Error, "Caught exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x144); + EVar1 = ECResult_NoMemory; + } catch(std::bad_alloc) { + ec::logmsg(ECLogLevel_Error, "Caught bad_alloc exception at FILE: ec_api.cpp LINE: %d COMPILED: Feb 8 2010 20:10:32 \n", 0x144); + EVar1 = ECResult_ECFail; + } + } + return EVar1; +} + +//TODO: Work on this entire function (it's way too long) +ECResult ec::getTitleInfos(ECTitleInfo *titleInfo, unsigned long *p1, unsigned long long p2, bool p3) {} + +//TODO: Figure out the types for the parameters here +//TODO: EC_GetOverhead is called by WiiCommergeMgr::InitCommerce +//TODO: Also figure out if there's a better way to do this. the `goto` spam seems a little ridiculous +//? p1 is overhead type? +ECResult EC_GetOverhead(int p1, int *p2, int *p3) { + ECResult status = ECResult_Success; + if (p2 == NULL || p3 == NULL) return ECResult_InvalidBufHeap; + /*if (p1 != 0) { + if (p1 != 2) { + if (p1 != 1) { + if (p1 != 3) { + goto f; + } else { + *p2 = 3; + *p3 = 8; + goto end; + } + } else { + *p2 = 2; + *p3 = 6; + goto end; + } + } else { + *p2 = 2; + *p3 = 2; + goto end; + } + } else { + *p2 = 3; + *p3 = 8; + goto end; + } +f: + status = ECResult_InvalidBufHeap; +end:*/ + if (p1 == 0) goto label1; + if (p1 == 2) goto label2; + if (p1 == 1) goto label3; + if (p1 == 3) goto label4; + goto beforeEnd; +label1: + *p2 = 3; + *p3 = 8; + goto end; +label2: + *p2 = 2; + *p3 = 6; + goto end; +label3: + *p2 = 2; + *p3 = 2; + goto end; +label4: + *p2 = 3; + *p3 = 8; + goto end; +beforeEnd: + status = ECResult_InvalidBufHeap; +end: + return status; +} + +//TODO: work on the two `lwz` before `bl checkECDKSyncNeededForTitle` +int EC_GetIsSyncNeeded() { + int status; + if (ec::op == NULL) { + status = -4041; + } else { + status = checkECDKSyncNeededForTitle() != 0 & -4006; + } + return status; +} diff --git a/src/sdk/ec/string.h b/src/sdk/ec/string.h index 27a9aac3b..ccb18e977 100644 --- a/src/sdk/ec/string.h +++ b/src/sdk/ec/string.h @@ -9,6 +9,8 @@ typedef std::basic_string, ECAllocator > ECSt namespace ec { + extern bool isUseNCRs; + class ECOstringstream { public: ECOstringstream& operator<<(const ECString& str);