| 128 | } |
| 129 | |
| 130 | void LCU::GetLeagueProcesses() |
| 131 | { |
| 132 | const std::vector<DWORD> allProcessIds = Auth::GetAllProcessIds(L"LeagueClientUx.exe"); |
| 133 | // remove unexisting clients |
| 134 | for (size_t i = 0; i < leagueProcesses.size(); i++) |
| 135 | { |
| 136 | bool exists = false; |
| 137 | for (const DWORD& proc : allProcessIds) |
| 138 | { |
| 139 | if (proc == leagueProcesses[i].first) |
| 140 | { |
| 141 | exists = true; |
| 142 | break; |
| 143 | } |
| 144 | } |
| 145 | if (!exists) |
| 146 | { |
| 147 | leagueProcesses.erase(leagueProcesses.begin() + i); |
| 148 | if (i == indexLeagueProcesses) |
| 149 | SetLeagueClientInfo(); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | for (const DWORD& proc : allProcessIds) |
| 154 | { |
| 155 | int foundIndex = -1; |
| 156 | for (size_t i = 0; i < leagueProcesses.size(); i++) |
| 157 | { |
| 158 | if (leagueProcesses[i].first == proc) |
| 159 | { |
| 160 | foundIndex = static_cast<int>(i); |
| 161 | break; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | if (foundIndex != -1 && !leagueProcesses[foundIndex].second.empty()) |
| 166 | continue; |
| 167 | |
| 168 | ClientInfo currentInfo = Auth::GetClientInfo(proc); |
| 169 | currentInfo.header = Auth::MakeLeagueHeader(currentInfo); |
| 170 | |
| 171 | size_t currentIndex = foundIndex; |
| 172 | if (foundIndex == -1) |
| 173 | { |
| 174 | currentIndex = leagueProcesses.size(); |
| 175 | std::pair<DWORD, std::string> temp = { proc, "" }; |
| 176 | leagueProcesses.emplace_back(temp); |
| 177 | } |
| 178 | |
| 179 | std::thread t([currentIndex, currentInfo]() { |
| 180 | short sessionFailCount = 0; |
| 181 | while (true) |
| 182 | { |
| 183 | cpr::Session session; |
| 184 | session.SetVerifySsl(false); |
| 185 | session.SetHeader(Utils::StringToHeader(currentInfo.header)); |
| 186 | session.SetUrl(std::format("https://127.0.0.1:{}/lol-login/v1/session", currentInfo.port)); |
| 187 | std::string procSession = session.Get().text; |