MCPcopy Create free account
hub / github.com/KuhakuPixel/AceTheGame / scan_cmd_handler

Function scan_cmd_handler

ACE/engine/src/cheat_cmd_handler.cpp:73–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72template <typename T>
73void scan_cmd_handler(ACE_scanner<T> *scanner,
74
75 Scan_Utils::E_operator_type operator_type,
76
77 cheat_mode_config *cheat_config,
78
79 T num_to_find) {
80
81 double scan_time = -1;
82
83 TIME_ACTION(
84
85 {
86 if (!cheat_config->initial_scan_done) {
87
88 // TODO: add test on how well this is?
89 // ================= find memory mapped regions to scan =============
90 char path_to_maps[200];
91 snprintf(path_to_maps, 199, "/proc/%d/maps", cheat_config->pid);
92 // get all mem segments of program with pid [cheat_config->pid]
93 std::vector<struct mem_segment> proc_mem_segments =
94 parse_proc_map_file(path_to_maps);
95 //
96 std::vector<struct mem_segment> segments_to_scan = {};
97 for (size_t i = 0; i < proc_mem_segments.size(); i++) {
98 bool is_suitable = mem_segment_is_suitable(proc_mem_segments[i]);
99
100 if (is_suitable || cheat_config->scan_all_region)
101 segments_to_scan.push_back(proc_mem_segments[i]);
102 }
103 frontend_print("Found %zu regions to be scanned\n",
104 segments_to_scan.size());
105 // =================================================================
106 // do scan
107 scanner->initial_scan_multiple(segments_to_scan, operator_type,
108 num_to_find);
109 // mark initial scan has been done
110 // so subsequent scan or filter operation know
111 // about it
112 cheat_config->initial_scan_done = true;
113 }
114
115 else {
116 scanner->filter_from_cmp_val(operator_type, num_to_find);
117 }
118 },
119
120 &scan_time
121
122 );
123
124 frontend_print("current matches: %zu\n",
125 scanner->get_current_scan_result().get_matches_count());
126 frontend_print("Done in: %lf s\n", scan_time);
127}
128template <typename T>
129void write_cmd_handler(ACE_scanner<T> *scanner, T val_to_write) {
130

Callers

nothing calls this directly

Calls 7

parse_proc_map_fileFunction · 0.85
mem_segment_is_suitableFunction · 0.85
frontend_printFunction · 0.85
initial_scan_multipleMethod · 0.80
filter_from_cmp_valMethod · 0.80
get_matches_countMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected