| 15 | { |
| 16 | |
| 17 | std::shared_ptr<AppSharedMessage> DxAddressLoader::LoadDxAddress() { |
| 18 | auto cap_message = std::make_shared<AppSharedMessage>(); |
| 19 | auto output = ProcessUtil::StartProcessAndOutput("tc_graphics_offsets.exe", {}); |
| 20 | if (output.empty()) { |
| 21 | LOGE("Failed to run "); |
| 22 | return nullptr; |
| 23 | } |
| 24 | |
| 25 | auto fn_get_address_number = [](std::vector<std::string>& parsed_line) -> uint64_t { |
| 26 | auto hex_str = parsed_line.at(parsed_line.size() - 1); |
| 27 | auto address = 0; |
| 28 | try { |
| 29 | address = std::stoi(hex_str, nullptr, 16); |
| 30 | } catch (...) { |
| 31 | LOGE("Convert to integer failed: {}", hex_str); |
| 32 | } |
| 33 | return address; |
| 34 | }; |
| 35 | |
| 36 | bool is_d3d9 = false; |
| 37 | bool is_dxgi = false; |
| 38 | for (const auto& line : output) { |
| 39 | LOGI("{}", line); |
| 40 | if (line.starts_with("[d3d9]")) { |
| 41 | is_d3d9 = true; |
| 42 | is_dxgi = false; |
| 43 | continue; |
| 44 | } |
| 45 | if (line.starts_with("[dxgi]")) { |
| 46 | is_d3d9 = false; |
| 47 | is_dxgi = true; |
| 48 | continue; |
| 49 | } |
| 50 | |
| 51 | if (!is_dxgi && !is_d3d9) { |
| 52 | continue; |
| 53 | } |
| 54 | |
| 55 | std::vector<std::string> parsed_line; |
| 56 | StringUtil::Split(line, parsed_line, "="); |
| 57 | auto address = fn_get_address_number(parsed_line); |
| 58 | |
| 59 | if (is_d3d9) { |
| 60 | if (line.starts_with("present=")) { |
| 61 | cap_message->d3d9_present = address; |
| 62 | } |
| 63 | else if (line.starts_with("present_ex=")) { |
| 64 | cap_message->d3d9_present_ex = address; |
| 65 | } |
| 66 | else if (line.starts_with("present_swap=")) { |
| 67 | cap_message->d3d9_present_swap = address; |
| 68 | } |
| 69 | else if (line.starts_with("d3d9_clsoff=")) { |
| 70 | cap_message->d3d9_d3d9_clsoff = address; |
| 71 | } |
| 72 | else if (line.starts_with("is_d3d9ex_clsoff=")) { |
| 73 | cap_message->d3d9_is_d3d9ex_clsoff = address; |
| 74 | } |
nothing calls this directly
no outgoing calls
no test coverage detected