-
Notifications
You must be signed in to change notification settings - Fork 13
/
SearchContext.h
93 lines (68 loc) · 2.88 KB
/
SearchContext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* The Cheat - The legendary universal game trainer for Mac OS X.
* http://www.brokenzipper.com/trac/wiki/TheCheat
*
* Copyright (c) 2003-2011, Charles McGarvey et al.
*
* Distributable under the terms and conditions of the 2-clause BSD
* license; see the file COPYING for the legal text of the license.
*/
#import <Cocoa/Cocoa.h>
#include "ChazLog.h"
#import "CheaterTypes.h"
#import "Searching.h"
#import "VMRegion.h"
#import "Variable.h"
#define TC_BUFFER_SIZE (8192)
// used when buffers are expanded; use a multiple for 4096 because
// the virtual memory system uses those sizes for optimization.
#define TC_EPSILON (0.1)
// defines the accuracy for floating point comparisons
@interface SearchContext : NSObject
{
/*
* So here's the big, bad, rather ugly search context class.
* There is quite a bit to keep track of, as you can see.
*/
TCVariableType _variableType;
TCIntegerSign _integerSign;
TCSearchOperator _operator;
TCSearchType _searchType;
// for fast access while iterating through the task loop.
@public;
pid_t process; // the pid of the process being searched
unsigned regionCount; // estimation of the # of regions used for progress reporting
VMRegion lastRegion; // used to find the next region to search
Variable *value; // the value to compare against (TCGivenValue searches)
BOOL (*compareFunc)(void const *, void const*); // comparison function
TCArray addresses; // array to store hit addresses
TCArray values; // parallel array to store hit values
TCArray regions; // array of addresses, one for each region which contains a hit
TCArray perRegion; // number of variables found for each region
unsigned numberOfResults; // actual number of hits so far
TCArray lastAddresses; // the addresses of variables to check
TCArray lastValues; // the values to compare against (TCLastValue searches)
TCArray lastRegions; // optimizes "again" searches
TCArray lastPerRegion; // parallels lastRegions
void *buffer; // the working buffer for reading in memory from the other app
unsigned bufferSize; // size of the working buffer
// pointers
void *valuePtr, *lastValuePtr;
TCAddress *addressPtr, *lastAddressPtr;
TCAddress *lastRegionPtr;
unsigned *lastPerRegionPtr;
int progress; // 0-100
}
// Initialization
// this initializer must be used to create a context for a first-time search
- (id)initWithPID:(pid_t)pid searchOperator:(TCSearchOperator)op value:(Variable *)val;
// these initializers take data from the last search that was performed
- (id)initWithLastContext:(SearchContext *)context searchOperator:(TCSearchOperator)op;
- (id)initWithLastContext:(SearchContext *)context searchOperator:(TCSearchOperator)op value:(Variable *)val;
// Accessors
- (TCVariableType)variableType;
- (TCIntegerSign)integerSign;
- (TCSearchOperator)searchOperator;
- (BOOL (*)(void const *, void const *))compareFunction;
- (int (*)(id, unsigned))iterationFunction;
@end