From baabec77f73d9c6e93ade9ee077442245718026d Mon Sep 17 00:00:00 2001 From: str1k3r <115313679+S1l3ntStr1ke87@users.noreply.github.com> Date: Sun, 30 Aug 2026 16:41:59 -0400 Subject: [PATCH] feat(windows64): 4JLibs durango parity / switch to wide --- 4J_Input/4J_Input.vcxproj.filters | 6 +-- 4J_Input/stdafx.h | 4 ++ 4J_Profile/stdafx.h | 4 ++ 4J_Render/stdafx.h | 4 ++ 4J_Storage/Windows64/4J_Storage.cpp | 10 ++--- 4J_Storage/Windows64/STO_DLC.cpp | 63 ++++++++++++++--------------- 4J_Storage/Windows64/STO_DLC.h | 20 ++++----- 4J_Storage/stdafx.h | 6 +++ Headers/Windows64/4J_Storage.h | 10 ++--- Headers/extraX64.h | 2 +- 10 files changed, 73 insertions(+), 56 deletions(-) diff --git a/4J_Input/4J_Input.vcxproj.filters b/4J_Input/4J_Input.vcxproj.filters index dcd0b24..74305d5 100644 --- a/4J_Input/4J_Input.vcxproj.filters +++ b/4J_Input/4J_Input.vcxproj.filters @@ -293,9 +293,6 @@ - - Source Files - Source Files @@ -314,5 +311,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/4J_Input/stdafx.h b/4J_Input/stdafx.h index eb68d72..cd473ea 100644 --- a/4J_Input/stdafx.h +++ b/4J_Input/stdafx.h @@ -1,13 +1,17 @@ #ifndef PCH_H #define PCH_H +#ifdef _WIN64 #define WIN32_LEAN_AND_MEAN #include #include #include #include +#endif +#ifndef _XBOX #include "extraX64.h" +#endif #endif //PCH_H diff --git a/4J_Profile/stdafx.h b/4J_Profile/stdafx.h index eb68d72..cd473ea 100644 --- a/4J_Profile/stdafx.h +++ b/4J_Profile/stdafx.h @@ -1,13 +1,17 @@ #ifndef PCH_H #define PCH_H +#ifdef _WIN64 #define WIN32_LEAN_AND_MEAN #include #include #include #include +#endif +#ifndef _XBOX #include "extraX64.h" +#endif #endif //PCH_H diff --git a/4J_Render/stdafx.h b/4J_Render/stdafx.h index 7b612d8..6084efc 100644 --- a/4J_Render/stdafx.h +++ b/4J_Render/stdafx.h @@ -1,6 +1,7 @@ #ifndef PCH_H #define PCH_H +#ifdef _WIN64 #define WIN32_LEAN_AND_MEAN #include @@ -11,7 +12,10 @@ #include #include #include +#endif +#ifndef _XBOX #include "extraX64.h" +#endif #endif //PCH_H diff --git a/4J_Storage/Windows64/4J_Storage.cpp b/4J_Storage/Windows64/4J_Storage.cpp index 969818b..b192893 100644 --- a/4J_Storage/Windows64/4J_Storage.cpp +++ b/4J_Storage/Windows64/4J_Storage.cpp @@ -218,7 +218,7 @@ void C4JStorage::RegisterMarketplaceCountsCallback(int (*Func)(LPVOID lpParam, C ; } -void C4JStorage::SetDLCPackageRoot(char *pszDLCRoot) +void C4JStorage::SetDLCPackageRoot(wchar_t *pszDLCRoot) { InternalStorageManager.m_DLC.SetPackageRoot(pszDLCRoot); } @@ -268,22 +268,22 @@ XCONTENT_DATA &C4JStorage::GetDLC(DWORD dw) return InternalStorageManager.m_DLC.GetDLC(dw); } -DWORD C4JStorage::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive) +DWORD C4JStorage::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCWSTR szMountDrive) { return InternalStorageManager.m_DLC.MountInstalledDLC(iPad, dwDLC, Func, lpParam, szMountDrive); } -DWORD C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive) +DWORD C4JStorage::UnmountInstalledDLC(LPCWSTR szMountDrive) { return InternalStorageManager.m_DLC.UnmountInstalledDLC(szMountDrive); } -void C4JStorage::GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList) +void C4JStorage::GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList) { InternalStorageManager.m_DLC.GetMountedDLCFileList(szMountDrive, fileList); } -std::string C4JStorage::GetMountedPath(std::string szMount) +std::wstring C4JStorage::GetMountedPath(std::wstring szMount) { return InternalStorageManager.m_DLC.GetMountedPath(szMount); } diff --git a/4J_Storage/Windows64/STO_DLC.cpp b/4J_Storage/Windows64/STO_DLC.cpp index 9ac9bea..c01c134 100644 --- a/4J_Storage/Windows64/STO_DLC.cpp +++ b/4J_Storage/Windows64/STO_DLC.cpp @@ -63,10 +63,10 @@ C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, m_iHasNewInstalledDLCs = true; bool ret = false; - DWORD atts = GetFileAttributesA("Windows64Media/DLC"); + DWORD atts = GetFileAttributesW(L"Windows64Media/DLC"); if (atts == -1) { - atts = GetFileAttributesA("Windows64/DLC"); + atts = GetFileAttributesW(L"Windows64/DLC"); ret = true; } @@ -81,34 +81,34 @@ C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, HANDLE hFindFile; if (ret) { - hFindFile = FindFirstFileA("Windows64/DLC/*", &hFind); + hFindFile = FindFirstFileW(L"Windows64/DLC/*", &hFind); } else { - hFindFile = FindFirstFileA("Windows64Media/DLC/*", &hFind); + hFindFile = FindFirstFileW(L"Windows64Media/DLC/*", &hFind); } - if (hFindFile != (HANDLE)-1LL) + if (hFindFile != INVALID_HANDLE_VALUE) { do { atts = hFind.dwFileAttributes; bool isArt = hFind.dwFileAttributes != -1 && (hFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); - if (isArt && hFind.cFileName[0] != '.') + if (isArt && hFind.cFileName[0] != L'.') { XCONTENT_DATA data; if (ret) { - sprintf(data.szFileName, "Windows64/DLC/%s", hFind.cFileName); + swprintf_s(data.szFileName, _countof(data.szFileName), L"Windows64/DLC/%s", hFind.cFileName); } else { - sprintf(data.szFileName, "Windows64Media/DLC/%s", hFind.cFileName); + swprintf_s(data.szFileName, _countof(data.szFileName), L"Windows64Media/DLC/%s", hFind.cFileName); } - swprintf(data.szDisplayName, 256, L"%S", hFind.cFileName); + swprintf_s(data.szDisplayName, 256, L"%s", hFind.cFileName); int displayNameLen = wcslen(data.szDisplayName); data.DeviceID = 0; @@ -116,14 +116,14 @@ C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, AddInstalled(&data); } - } while (FindNextFileA(hFindFile, &hFind)); + } while (FindNextFileW(hFindFile, &hFind)); FindClose(hFindFile); } return C4JStorage::EDLC_Idle; } -DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive) +DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCWSTR szMountDrive) { this->m_pMountedDLCFunc = Func; this->m_pMountedDLCParam = lpParam; @@ -139,7 +139,7 @@ DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DW this->m_uiCurrentMappedDLC = dwDLC; - char *dlcdirPath = m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName; + wchar_t *dlcdirPath = m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName; m_vDLCDriveMappings.push_back(DriveMapping(dlcdirPath, m_szMountPath)); m_iHasNewMountedDLCs = true; @@ -147,9 +147,9 @@ DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DW return 997; } -DWORD CDLC::UnmountInstalledDLC(LPCSTR szMountDrive) +DWORD CDLC::UnmountInstalledDLC(LPCWSTR szMountDrive) { - LPCSTR szDrive = nullptr; + LPCWSTR szDrive = nullptr; if (szMountDrive) { @@ -172,49 +172,48 @@ DWORD CDLC::UnmountInstalledDLC(LPCSTR szMountDrive) return 0; } -void CDLC::GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList) +void CDLC::GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList) { - char *dlcdirPath = new char[256]; - sprintf(dlcdirPath, "%s/*", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName); + wchar_t dlcdirPath[256]; + swprintf_s(dlcdirPath, 256, L"%s/*", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName); - _WIN32_FIND_DATAA atts; - HANDLE hFind = FindFirstFileA(dlcdirPath, &atts); - if (hFind != (HANDLE)-1LL) + _WIN32_FIND_DATAW atts; + HANDLE hFind = FindFirstFileW(dlcdirPath, &atts); + if (hFind != INVALID_HANDLE_VALUE) { do { if (atts.dwFileAttributes == -1 || (atts.dwFileAttributes & 0x10) != 0x10) { - char dir[256]; - sprintf(dir, "%s/%s", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName, atts.cFileName); + wchar_t dir[256]; + swprintf_s(dir, _countof(dir), L"%s/%s", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName, atts.cFileName); fileList.push_back(dir); } - } while (FindNextFileA(hFind, &atts)); + } while (FindNextFileW(hFind, &atts)); FindClose(hFind); } - delete[] dlcdirPath; } -std::string CDLC::GetMountedPath(std::string szMount) +std::wstring CDLC::GetMountedPath(std::wstring szMount) { for (int ch = 0; ch < szMount.size(); ++ch) { if (szMount[ch] == '/' || szMount[ch] == '\\') { - return ""; + return L""; } if (szMount[ch] == ':') { - std::string driveName = szMount.substr(0, ch); + std::wstring driveName = szMount.substr(0, ch); for (int i = 0; i < m_vDLCDriveMappings.size(); i++) { if (m_vDLCDriveMappings[i].m_szMountPath == driveName) { - std::string newPath = m_vDLCDriveMappings[i].m_szDirectoryPath; + std::wstring newPath = m_vDLCDriveMappings[i].m_szDirectoryPath; - newPath.append(szMount.substr(ch + 1, -1)); + newPath.append(szMount.substr(ch + 1)); return newPath; } @@ -223,7 +222,7 @@ std::string CDLC::GetMountedPath(std::string szMount) } } - return ""; + return L""; } void CDLC::SetDLCProductCode(const char *szProductCode) @@ -241,9 +240,9 @@ int CDLC::GetAvailableDLCCount(int iPad) return 0; } -void CDLC::SetPackageRoot(char *pszDLCRoot) +void CDLC::SetPackageRoot(wchar_t *pszDLCRoot) { - strcpy(this->m_szPackageRoot, pszDLCRoot); + wcscpy(this->m_szPackageRoot, pszDLCRoot); } void CDLC::Tick(void) diff --git a/4J_Storage/Windows64/STO_DLC.h b/4J_Storage/Windows64/STO_DLC.h index 8aa6604..38590c7 100644 --- a/4J_Storage/Windows64/STO_DLC.h +++ b/4J_Storage/Windows64/STO_DLC.h @@ -30,13 +30,13 @@ class CDLC public: struct DriveMapping { - DriveMapping(std::string szDirectoryPath, std::string szMountPath) : m_szDirectoryPath(szDirectoryPath), m_szMountPath(szMountPath) + DriveMapping(std::wstring szDirectoryPath, std::wstring szMountPath) : m_szDirectoryPath(szDirectoryPath), m_szMountPath(szMountPath) { ; } - std::string m_szMountPath; - std::string m_szDirectoryPath; + std::wstring m_szMountPath; + std::wstring m_szDirectoryPath; }; XCONTENT_DATA &GetDLC(DWORD dw); @@ -46,15 +46,15 @@ public: DWORD dwOfferTypesBitmask = XMARKETPLACE_OFFERING_TYPE_CONTENT); void ClearOffers(); C4JStorage::EDLCStatus GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, int), LPVOID lpParam); - DWORD MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); - void GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList); - std::string GetMountedPath(std::string szMount); + DWORD MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCWSTR szMountDrive = NULL); + DWORD UnmountInstalledDLC(LPCWSTR szMountDrive = NULL); + void GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList); + std::wstring GetMountedPath(std::wstring szMount); void SetDLCProductCode(const char *szProductCode); void SetProductUpgradeKey(const char *szProductCode); int GetAvailableDLCCount(int iPad); - void SetPackageRoot(char *pszDLCRoot); + void SetPackageRoot(wchar_t *pszDLCRoot); void Tick(void); void AddInstalled(XCONTENT_DATA *data); @@ -70,10 +70,10 @@ public: DWORD m_iHasNewMountedDLCs; int (*m_pMountedDLCFunc)(LPVOID, int, DWORD, DWORD); LPVOID m_pMountedDLCParam; - std::string m_szMountPath; + std::wstring m_szMountPath; DWORD m_uiCurrentMappedDLC; DWORD m_dwLicenseMask; - char m_szPackageRoot[40]; + wchar_t m_szPackageRoot[40]; DWORD dwordC0; std::vector m_vDLCDriveMappings; char m_szDLCProductCode[16]; diff --git a/4J_Storage/stdafx.h b/4J_Storage/stdafx.h index eb68d72..fbe6752 100644 --- a/4J_Storage/stdafx.h +++ b/4J_Storage/stdafx.h @@ -1,6 +1,7 @@ #ifndef PCH_H #define PCH_H +#ifdef _WIN64 #define WIN32_LEAN_AND_MEAN #include @@ -8,6 +9,11 @@ #include #include +#include +#endif + +#ifndef _XBOX #include "extraX64.h" +#endif #endif //PCH_H diff --git a/Headers/Windows64/4J_Storage.h b/Headers/Windows64/4J_Storage.h index cc23cd4..8d1b1e3 100644 --- a/Headers/Windows64/4J_Storage.h +++ b/Headers/Windows64/4J_Storage.h @@ -285,7 +285,7 @@ public: // DLC void RegisterMarketplaceCountsCallback(int (*Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS*, int), LPVOID lpParam); - void SetDLCPackageRoot(char* pszDLCRoot); + void SetDLCPackageRoot(wchar_t* pszDLCRoot); C4JStorage::EDLCStatus GetDLCOffers(int iPad, int(*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask = XMARKETPLACE_OFFERING_TYPE_CONTENT); DWORD CancelGetDLCOffers(); void ClearDLCOffers(); @@ -296,10 +296,10 @@ public: C4JStorage::EDLCStatus GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, int), LPVOID lpParam); XCONTENT_DATA& GetDLC(DWORD dw); - DWORD MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive = NULL); - DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); - void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); - std::string GetMountedPath(std::string szMount); + DWORD MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCWSTR szMountDrive = NULL); + DWORD UnmountInstalledDLC(LPCWSTR szMountDrive = NULL); + void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); + std::wstring GetMountedPath(std::wstring szMount); // Global title storage C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, C4JStorage::eTMS_FileType eFileType, diff --git a/Headers/extraX64.h b/Headers/extraX64.h index c5a63aa..653b0e1 100644 --- a/Headers/extraX64.h +++ b/Headers/extraX64.h @@ -354,7 +354,7 @@ typedef struct _XCONTENT_DATA XCONTENTDEVICEID DeviceID; DWORD dwContentType; WCHAR szDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH]; - CHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH]; + WCHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH]; } XCONTENT_DATA, *PXCONTENT_DATA; #endif //__PS3__