void get_d3d9_offsets(struct d3d9_offsets *offsets) { d3d9_info info = {}; bool success = d3d9_init(info); if (success) { uint8_t **vt = *(uint8_t***)info.device; uint8_t *crr = vt[125]; offsets->present = vtable_offset(info.module, info.device, 17); offsets->present_ex = vtable_offset(info.module, info.device, 121); offsets->present_swap = vtable_offset(info.module, info.swap, 3); for (size_t i = 0; i < MAX_FUNC_SCAN_BYTES; i++) { if (pattern_matches(&crr[i])) { #define get_offset(x) *(uint32_t*)&crr[i + x] #ifdef _WIN64 uint32_t off1 = get_offset(3); uint32_t off2 = get_offset(9); #else uint32_t off1 = get_offset(2); uint32_t off2 = get_offset(8); #endif /* check to make sure offsets are within * expected values */ if (off1 > 0xFFFF || off2 > 0xFFFF) break; /* check to make sure offsets actually point * toward expected data */ #ifdef _MSC_VER __try { uint8_t *ptr = (uint8_t*)(info.device); uint8_t *d3d9_ptr = *(uint8_t**)(ptr + off1); if (d3d9_ptr != (uint8_t*)info.d3d9ex) break; BOOL &is_d3d9ex = *(BOOL*)(d3d9_ptr + off2); if (is_d3d9ex != TRUE) break; } __except(EXCEPTION_EXECUTE_HANDLER) { break; } #endif offsets->d3d9_clsoff = off1; offsets->is_d3d9ex_clsoff = off2; break; } } }
void surveil(piu *entry) { for (int i = 0; i < num_requests; ++i) { surveillance_request *request = &requests_to_scan[i]; for (int j = 0; j < request->num_patterns; ++j) { if (pattern_matches(entry, &request->user_patterns[j], &request->piu_patterns[j])) { printf("Pattern Matches!\n"); } } } }
cell_state lookup_rule_table(cell_state rule[8], struct cells_t *cells, size_t idx) { for(int i = 0; i < 8; i++) { if(pattern_matches(cells, idx, PATTERNS[i][0], PATTERNS[i][1], PATTERNS[i][2])) { return rule[i]; } } fprintf(stderr, "Reached impossible pattern, quitting.\n"); exit(EXIT_FAILURE); }