MCPcopy Create free account
hub / github.com/clementgallet/libTAS / sendAddresses

Method sendAddresses

src/program/UnityPatching.cpp:1062–1102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1060}
1061
1062void UnityPatching::sendAddresses(Context* context)
1063{
1064 /* Find and send symbol addresses for main executable or `UnityPlayer_s.debug` */
1065 std::filesystem::path unityplayer = context->gameexecutable.parent_path() / "UnityPlayer.so";
1066 bool has_unityplayer = std::filesystem::exists(unityplayer);
1067
1068 std::filesystem::path debugfile = context->gameexecutable.parent_path() / "UnityPlayer_s.debug";
1069 bool has_unityplayer_debug = std::filesystem::exists(debugfile);
1070
1071 std::pair<uintptr_t,uintptr_t> executablefile_segment;
1072 int gameArch = extractBinaryType(context->gameexecutable);
1073
1074 /* If the executable is position-independent (pie), it will be mapped
1075 * somewhere, and the symbol is only an offset, so we need the base
1076 * address of the executable and adds to it. We use `file` to determine
1077 * if the executable is pie */
1078 bool is_pie = gameArch & BT_PIEAPP;
1079 bool is_64bit = gameArch & BT_ELF64;
1080
1081 if (has_unityplayer) {
1082 executablefile_segment = BaseAddresses::getAddress("UnityPlayer.so");
1083 is_pie = true;
1084 }
1085 else {
1086 debugfile = context->gameexecutable;
1087 executablefile_segment = BaseAddresses::getExecutableSection();
1088 }
1089
1090 /* Send Unity function pointers from symbol locations */
1091 bool found_symbols = false;
1092 if (has_unityplayer_debug || !has_unityplayer) {
1093
1094 uintptr_t base_address = is_pie ? executablefile_segment.first : 0;
1095 found_symbols = sendAddressesFromSymbols(debugfile, base_address);
1096 }
1097
1098 /* If no symbol present, try to find functions by signature */
1099 if (!found_symbols) {
1100 sendAddressesFromSignatures(executablefile_segment, is_64bit);
1101 }
1102}

Callers

nothing calls this directly

Calls 1

extractBinaryTypeFunction · 0.85

Tested by

no test coverage detected