Skip to content

Commit b1fd842

Browse files
committed
reveal names in ranked lobby
1 parent c17f44d commit b1fd842

6 files changed

Lines changed: 66 additions & 15 deletions

File tree

KBotExt/Auth.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "Auth.h"
1010
#include "Utils.h"
1111

12-
ClientInfo Auth::GetClientInfo(const DWORD& pid)
12+
ClientInfo Auth::GetClientInfo(const DWORD& pid, bool riotClient)
1313
{
1414
if (!pid)
1515
return {};
@@ -19,27 +19,29 @@ ClientInfo Auth::GetClientInfo(const DWORD& pid)
1919
return {};
2020

2121
ClientInfo info;
22-
info.port = GetPort(cmdLine);
23-
info.token = GetToken(cmdLine);
22+
info.port = GetPort(cmdLine, riotClient);
23+
info.token = GetToken(cmdLine, riotClient);
2424
info.path = GetProcessPath(pid);
2525
info.version = GetFileVersion(info.path);
2626

2727
return info;
2828
}
2929

30-
int Auth::GetPort(const std::string& cmdLine)
30+
int Auth::GetPort(const std::string& cmdLine, bool riotClient)
3131
{
32-
std::regex regexStr("--app-port=(\\d*)");
32+
std::regex regexStr;
33+
regexStr = riotClient ? ("--riotclient-app-port=(\\d*)") : ("--app-port=(\\d*)");
3334
std::smatch m;
3435
if (std::regex_search(cmdLine, m, regexStr))
3536
return std::stoi(m[1].str());
3637

3738
return 0;
3839
}
3940

40-
std::string Auth::GetToken(const std::string& cmdLine)
41+
std::string Auth::GetToken(const std::string& cmdLine, bool riotClient)
4142
{
42-
std::regex regexStr("--remoting-auth-token=([\\w-]*)");
43+
std::regex regexStr;
44+
regexStr = riotClient ? ("--riotclient-auth-token=([\\w-]*)") : ("--remoting-auth-token=([\\w-]*)");
4345
std::smatch m;
4446
if (std::regex_search(cmdLine, m, regexStr))
4547
{

KBotExt/Auth.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class Auth
2222

2323
static std::vector<DWORD> GetAllProcessIds(const std::wstring& processName);
2424

25-
static ClientInfo GetClientInfo(const DWORD& pid);
25+
// set riotClient flag when you need Riot Client info but RiotClientUx.exe is closed
26+
static ClientInfo GetClientInfo(const DWORD& pid, bool riotClient = false);
2627
static DWORD GetProcessId(const std::wstring& processName);
2728

2829
static std::string MakeLeagueHeader(const ClientInfo& info);
@@ -31,8 +32,8 @@ class Auth
3132
private:
3233
static inline Base64 base64;
3334

34-
static int GetPort(const std::string& cmdLine);
35-
static std::string GetToken(const std::string& cmdLine);
35+
static int GetPort(const std::string& cmdLine, bool riotClient = false);
36+
static std::string GetToken(const std::string& cmdLine, bool riotClient = false);
3637

3738
static std::wstring GetProcessCommandLine(const DWORD& processId);
3839
static std::wstring GetProcessPath(const DWORD& processId);

KBotExt/CustomTab.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,24 @@ class CustomTab
4848
static char inputPort[64] = "";
4949
ImGui::Text("Port:");
5050
ImGui::InputText("##inputPort", inputPort, 64, ImGuiInputTextFlags_CharsDecimal);
51+
52+
static char inputHeader[1024 * 16];
53+
ImGui::Text("Header:");
54+
ImGui::InputTextMultiline("##inputHeader", (inputHeader), IM_ARRAYSIZE(inputHeader), ImVec2(600, 100), ImGuiInputTextFlags_AllowTabInput);
55+
56+
if (ImGui::Button("Set Riot Client Info"))
57+
{
58+
LCU::SetCurrentClientRiotInfo();
59+
std::strcpy(inputPort, std::to_string(LCU::riot.port).c_str());
60+
std::strcpy(inputHeader, LCU::riot.header.c_str());
61+
}
62+
5163
std::string sPort = std::string(inputPort);
5264
if (!sPort.empty())
5365
customPort = std::stoi(sPort);
5466
else
55-
customPort = -1;
67+
customPort = 443;
5668

57-
static char inputHeader[1024 * 16];
58-
ImGui::Text("Header:");
59-
ImGui::InputTextMultiline("##inputHeader", (inputHeader), IM_ARRAYSIZE(inputHeader), ImVec2(600, 100), ImGuiInputTextFlags_AllowTabInput);
6069
std::string sHeader = std::string(inputHeader);
6170
customHeader = sHeader;
6271
}

KBotExt/GameTab.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,15 +864,24 @@ class GameTab
864864
Json::Value rootRegion;
865865
Json::Value rootCSelect;
866866
Json::Value rootSummoner;
867+
Json::Value rootPartcipants;
868+
869+
std::wstring summNames = L"";
870+
bool isRanked = false;
867871

868872
if (reader->parse(champSelect.c_str(), champSelect.c_str() + static_cast<int>(champSelect.length()), &rootCSelect, &err))
869873
{
870874
auto teamArr = rootCSelect["myTeam"];
871875
if (teamArr.isArray())
872876
{
873-
std::wstring summNames = L"";
874877
for (Json::Value::ArrayIndex i = 0; i < teamArr.size(); ++i)
875878
{
879+
if (teamArr[i]["nameVisibilityType"].asString() == "HIDDEN")
880+
{
881+
isRanked = true;
882+
break;
883+
}
884+
876885
std::string summId = teamArr[i]["summonerId"].asString();
877886
if (summId != "0")
878887
{
@@ -884,6 +893,26 @@ class GameTab
884893
}
885894
}
886895

896+
if (isRanked)
897+
{
898+
summNames = L"";
899+
900+
LCU::SetCurrentClientRiotInfo();
901+
std::string participants = HTTP::Request("GET", "https://127.0.0.1/chat/v5/participants/champ-select", "",
902+
LCU::riot.header, "", "", LCU::riot.port);
903+
if (reader->parse(participants.c_str(), participants.c_str() + static_cast<int>(participants.length()), &rootPartcipants, &err))
904+
{
905+
auto participantsArr = rootPartcipants["participants"];
906+
if (participantsArr.isArray())
907+
{
908+
for (Json::Value::ArrayIndex i = 0; i < participantsArr.size(); ++i)
909+
{
910+
summNames += Utils::StringToWstring(participantsArr[i]["name"].asString()) + L",";
911+
}
912+
}
913+
}
914+
}
915+
887916
std::wstring region;
888917
if (website == "U.GG") // platformId (euw1, eun1, na1)
889918
{
@@ -904,6 +933,9 @@ class GameTab
904933

905934
if (!region.empty())
906935
{
936+
if (summNames.empty())
937+
return "Failed to get summoner names";
938+
907939
if (summNames.at(summNames.size() - 1) == L',')
908940
summNames.pop_back();
909941

KBotExt/LCU.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ bool LCU::SetLeagueClientInfo()
5757
return SetLeagueClientInfo(Auth::GetClientInfo(LCU::leagueProcesses[LCU::indexLeagueProcesses].first));
5858
}
5959

60+
bool LCU::SetCurrentClientRiotInfo()
61+
{
62+
return SetRiotClientInfo(Auth::GetClientInfo(LCU::leagueProcesses[LCU::indexLeagueProcesses].first, true));
63+
}
64+
6065
void LCU::GetLeagueProcesses()
6166
{
6267
std::vector<DWORD>allProcessIds = Auth::GetAllProcessIds(L"LeagueClientUx.exe");

KBotExt/LCU.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class LCU
1717
static bool SetLeagueClientInfo(const ClientInfo& info);
1818
static bool SetLeagueClientInfo();
1919

20+
static bool SetCurrentClientRiotInfo();
21+
2022
static inline std::vector<std::pair<DWORD, std::string>> leagueProcesses;
2123
static inline size_t indexLeagueProcesses = 0; // currently selected process
2224
static void GetLeagueProcesses();

0 commit comments

Comments
 (0)