diff --git a/4J_Profile/Windows64/4J_Profile.cpp b/4J_Profile/Windows64/4J_Profile.cpp index fa30daf..1949a61 100644 --- a/4J_Profile/Windows64/4J_Profile.cpp +++ b/4J_Profile/Windows64/4J_Profile.cpp @@ -1,14 +1,14 @@ #include "4J_Profile.h" #include "PRO_Main.h" -void C_4JProfile::LoadSettings(void* gs, size_t gsSize) +int C_4JProfile::GetLockedProfile() { - InternalProfileManager.m_ProfileData.LoadSettings(gs, gsSize); + return InternalProfileManager.GetLockedProfile(); } -void C_4JProfile::SaveSettings(void* gs, size_t gsSize) +void C_4JProfile::SetLockedProfile(int iProf) { - InternalProfileManager.m_ProfileData.SaveSettings(gs, gsSize); + InternalProfileManager.SetLockedProfile(iProf); } bool C_4JProfile::IsSignedIn(int iQuadrant) @@ -31,6 +31,11 @@ bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) return InternalProfileManager.m_Sys.AllowedToPlayMultiplayer(iProf); } +void C_4JProfile::LoadGamertag() +{ + InternalProfileManager.m_Sys.LoadGamertag(); +} + void C_4JProfile::SetFakeGamerTag(char *name) { InternalProfileManager.m_Sys.SetFakeGamertag(name); @@ -71,6 +76,16 @@ bool C_4JProfile::IsSystemUIDisplayed() return 0; //str1k3r - matches durango profile lib } +void C_4JProfile::LoadSettings(void* gs, size_t gsSize) +{ + InternalProfileManager.m_ProfileData.LoadSettings(gs, gsSize); +} + +void C_4JProfile::SaveSettings(void* gs, size_t gsSize) +{ + InternalProfileManager.m_ProfileData.SaveSettings(gs, gsSize); +} + void C_4JProfile::SetDebugFullOverride(bool bVal) { InternalProfileManager.m_Sys.SetDebugFullOverride(bVal); diff --git a/4J_Profile/Windows64/PRO_Main.cpp b/4J_Profile/Windows64/PRO_Main.cpp index 61bb5a0..b798091 100644 --- a/4J_Profile/Windows64/PRO_Main.cpp +++ b/4J_Profile/Windows64/PRO_Main.cpp @@ -1,3 +1,13 @@ #include "PRO_Main.h" -CProfile InternalProfileManager; \ No newline at end of file +CProfile InternalProfileManager; + +int CProfile::GetLockedProfile() +{ + return 0; +} + +void CProfile::SetLockedProfile(int iProf) +{ + ; +} \ No newline at end of file diff --git a/4J_Profile/Windows64/PRO_Main.h b/4J_Profile/Windows64/PRO_Main.h index 464eade..8d007ed 100644 --- a/4J_Profile/Windows64/PRO_Main.h +++ b/4J_Profile/Windows64/PRO_Main.h @@ -6,6 +6,9 @@ class CProfile { public: + int GetLockedProfile(); + void SetLockedProfile(int iProf); + CSys m_Sys; CProfileData m_ProfileData; }; diff --git a/4J_Profile/Windows64/PRO_Sys.cpp b/4J_Profile/Windows64/PRO_Sys.cpp index ac0612f..1be86c8 100644 --- a/4J_Profile/Windows64/PRO_Sys.cpp +++ b/4J_Profile/Windows64/PRO_Sys.cpp @@ -26,6 +26,38 @@ bool CSys::IsGuest(int iQuadrant) return true; } +void CSys::LoadGamertag() +{ + wchar_t exeDir[MAX_PATH] = {}; + GetModuleFileNameW(NULL, exeDir, MAX_PATH); + wchar_t *lastSlash = wcsrchr(exeDir, '\\'); + if (lastSlash) *(lastSlash + 1) = '\0'; + + wchar_t filePath[MAX_PATH] = {}; + if(wcscpy_s(filePath, _countof(filePath), exeDir) != 0 || wcsncat_s(filePath, _countof(filePath), L"username.txt", _TRUNCATE) != 0) + { + return; + } + + FILE *file = NULL; + if (_wfopen_s(&file, filePath, L"r") == 0 && file) + { + wchar_t buffer[128] = {}; + if(fgetws(buffer, _countof(buffer), file)) + { + size_t len = wcslen(buffer); + while (len > 0 && (buffer[len-1] == '\n' || buffer[len-1] == '\r' || buffer[len-1] == ' ')) buffer[--len] = '\0'; + + if (len > 0) + { + wcscpy_s(fakeGamerTagW, _countof(fakeGamerTagW), buffer); + WideCharToMultiByte(CP_UTF8, 0, fakeGamerTagW, -1, fakeGamerTag, sizeof(fakeGamerTag), nullptr, nullptr); + } + } + fclose(file); + } +} + void CSys::SetFakeGamertag(char *name) { size_t chars = 0; diff --git a/4J_Profile/Windows64/PRO_Sys.h b/4J_Profile/Windows64/PRO_Sys.h index 90d0ed3..f933baf 100644 --- a/4J_Profile/Windows64/PRO_Sys.h +++ b/4J_Profile/Windows64/PRO_Sys.h @@ -11,6 +11,7 @@ public: bool IsGuest(int iQuadrant); // GAMERTAG + void LoadGamertag(); void SetFakeGamertag(char *name); char* GetGamertag(int iPad); wstring GetDisplayName(int iPad); diff --git a/Headers/Windows64/4J_Profile.h b/Headers/Windows64/4J_Profile.h index 5cf4c6e..90d41c9 100644 --- a/Headers/Windows64/4J_Profile.h +++ b/Headers/Windows64/4J_Profile.h @@ -75,6 +75,7 @@ public: // SYS int GetPrimaryPad(); void SetPrimaryPad(int iPad); + void LoadGamertag(); void SetFakeGamerTag(char *name); char* GetGamertag(int iPad); wstring GetDisplayName(int iPad);