Skip to content

Commit

Permalink
fixed login, added riot id changer
Browse files Browse the repository at this point in the history
  • Loading branch information
KebsCS committed Apr 5, 2024
1 parent 1829366 commit ee9a65e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 48 deletions.
2 changes: 1 addition & 1 deletion KBotExt/KBotExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ int WINAPI wWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPWSTR
closedNow = true;
if (!LCU::leagueProcesses.empty())
LCU::leagueProcesses.clear();
if (FindWindowA("RCLIENT", "Riot Client"))
if (FindWindowA(NULL, "Riot Client"))
{
if (LCU::riot.port == 0)
{
Expand Down
10 changes: 9 additions & 1 deletion KBotExt/LCU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ bool LCU::SetRiotClientInfo(const ClientInfo& info)

bool LCU::SetRiotClientInfo()
{
return SetRiotClientInfo(Auth::GetClientInfo(Auth::GetProcessId(L"RiotClientUx.exe")));
const auto riotClients = Auth::GetAllProcessIds(L"Riot Client.exe");
for (const DWORD& clientPid : riotClients)
{
const auto info = Auth::GetClientInfo(clientPid);
if (info.port == 0)
continue;
return SetRiotClientInfo(info);
}
return false;
}

bool LCU::SetLeagueClientInfo(const ClientInfo& info)
Expand Down
2 changes: 1 addition & 1 deletion KBotExt/LoginTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LoginTab
{
while (true)
{
if (FindWindowA("RCLIENT", "Riot Client") && LCU::riot.port != 0)
if (FindWindowA(NULL, "Riot Client") && LCU::riot.port != 0)
{
// waits to be sure that client is fully loaded
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
Expand Down
113 changes: 68 additions & 45 deletions KBotExt/MiscTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,57 +481,80 @@ class MiscTab

ImGui::Separator();

if (ImGui::Button("Tournament of Souls - unlock all"))
{
LCU::Request("POST", "/lol-marketing-preferences/v1/partition/sfm2023", R"({
"SmallConspiracyFan" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
"SmallGwenPykeFan" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
"SmallJhinFan" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
"SmallSettFans" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
"SmallShaco" : "True,True",
"hasNewAbility" : "False",
"hasNewFanLine" : "False",
"hasPlayedTutorial" : "True",
"hasSeenCelebration_Story" : "True",
"hasSeenLoadoutTutorial" : "True",
"hasSeenMapTutorial" : "True",
"loadout_active_e" : "2",
"loadout_active_q" : "1",
"loadout_active_r" : "2",
"loadout_active_w" : "2",
"numNodesUnlocked" : "20",
"progress" : "20"
})");
ImGui::Text("Change your Riot ID:");
static char bufGameName[50];
ImGui::SetNextItemWidth(static_cast<float>(S.Window.width / 4));
ImGui::InputText("##inputGameName", bufGameName, IM_ARRAYSIZE(bufGameName));

Json::Value root;
Json::CharReaderBuilder builder;
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
JSONCPP_STRING err;
std::string getGrants = LCU::Request("GET", "/lol-rewards/v1/grants");
ImGui::SameLine();
ImGui::Text("#");
ImGui::SameLine();
static char bufTagLine[50];
ImGui::SetNextItemWidth(static_cast<float>(S.Window.width / 5));
ImGui::InputText("##inputTagLine", bufTagLine, IM_ARRAYSIZE(bufTagLine));

if (reader->parse(getGrants.c_str(), getGrants.c_str() + static_cast<int>(getGrants.length()), &root, &err))
ImGui::SameLine();
if (ImGui::Button("Change##buttonRiotID"))
{
std::string newRiotId = std::string(bufGameName) + "#" + std::string(bufTagLine);
if (MessageBoxA(nullptr, std::string("Your new Riot ID will be: " + newRiotId).c_str(), "Are you sure?", MB_OKCANCEL) == IDOK)
{
if (root.isArray())
{
for (auto grant : root)
{
for (Json::Value& reward : grant["rewardGroup"]["rewards"])
{
Json::Value body;
body["rewardGroupId"] = grant["info"]["rewardGroupId"].asString();
body["selections"] = {};
body["selections"].append(reward["id"].asString());

result += LCU::Request("POST", std::format("/lol-rewards/v1/grants/{}/select", grant["info"]["id"].asString()),
body.toStyledString());
}
}
}
result = LCU::Request("POST", "https://127.0.0.1/lol-summoner/v1/save-alias",
"{\"gameName\": \"" + std::string(bufGameName) + "\", \"tagLine\": \"" + std::string(bufTagLine) + "\"}");
}
}

ImGui::SameLine();
ImGui::HelpMarker("You need reputation for this to work");
// if (ImGui::Button("Tournament of Souls - unlock all"))
// {
// LCU::Request("POST", "/lol-marketing-preferences/v1/partition/sfm2023", R"({
// "SmallConspiracyFan" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
// "SmallGwenPykeFan" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
// "SmallJhinFan" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
// "SmallSettFans" : "True,True,True,True,True,True,True,True,True,True,True,True,True,True,True",
// "SmallShaco" : "True,True",
// "hasNewAbility" : "False",
// "hasNewFanLine" : "False",
// "hasPlayedTutorial" : "True",
// "hasSeenCelebration_Story" : "True",
// "hasSeenLoadoutTutorial" : "True",
// "hasSeenMapTutorial" : "True",
// "loadout_active_e" : "2",
// "loadout_active_q" : "1",
// "loadout_active_r" : "2",
// "loadout_active_w" : "2",
// "numNodesUnlocked" : "20",
// "progress" : "20"
//})");
//
// Json::Value root;
// Json::CharReaderBuilder builder;
// const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
// JSONCPP_STRING err;
// std::string getGrants = LCU::Request("GET", "/lol-rewards/v1/grants");
//
// if (reader->parse(getGrants.c_str(), getGrants.c_str() + static_cast<int>(getGrants.length()), &root, &err))
// {
// if (root.isArray())
// {
// for (auto grant : root)
// {
// for (Json::Value& reward : grant["rewardGroup"]["rewards"])
// {
// Json::Value body;
// body["rewardGroupId"] = grant["info"]["rewardGroupId"].asString();
// body["selections"] = {};
// body["selections"].append(reward["id"].asString());
//
// result += LCU::Request("POST", std::format("/lol-rewards/v1/grants/{}/select", grant["info"]["id"].asString()),
// body.toStyledString());
// }
// }
// }
// }
// }
//
// ImGui::SameLine();
// ImGui::HelpMarker("You need reputation for this to work");

static Json::StreamWriterBuilder wBuilder;
static std::string sResultJson;
Expand Down

0 comments on commit ee9a65e

Please sign in to comment.