]> Dogcows Code - chaz/thecheat/blob - SearchContext.h
The Cheat 1.2.1
[chaz/thecheat] / SearchContext.h
1
2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 1, or (at your option)
9 // any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //
20
21
22 #import <Cocoa/Cocoa.h>
23 #include "ChazLog.h"
24
25 #import "CheaterTypes.h"
26 #import "Searching.h"
27 #import "VMRegion.h"
28 #import "Variable.h"
29
30
31 #define TC_BUFFER_SIZE (8192)
32 // used when buffers are expanded; use a multiple for 4096 because
33 // the virtual memory system uses those sizes for optimization.
34
35 #define TC_EPSILON (0.1)
36 // defines the accuracy for floating point comparisons
37
38
39 @interface SearchContext : NSObject
40 {
41 /*
42 * So here's the big, bad, rather ugly search context class.
43 * There is quite a bit to keep track of, as you can see.
44 */
45
46 TCVariableType _variableType;
47 TCIntegerSign _integerSign;
48 TCSearchOperator _operator;
49 TCSearchType _searchType;
50
51 // for fast access while iterating through the task loop.
52 @public;
53
54 pid_t process; // the pid of the process being searched
55 unsigned regionCount; // estimation of the # of regions used for progress reporting
56 VMRegion lastRegion; // used to find the next region to search
57
58 Variable *value; // the value to compare against (TCGivenValue searches)
59 BOOL (*compareFunc)(void const *, void const*); // comparison function
60
61 TCArray addresses; // array to store hit addresses
62 TCArray values; // parallel array to store hit values
63 TCArray regions; // array of addresses, one for each region which contains a hit
64 TCArray perRegion; // number of variables found for each region
65 unsigned numberOfResults; // actual number of hits so far
66
67 TCArray lastAddresses; // the addresses of variables to check
68 TCArray lastValues; // the values to compare against (TCLastValue searches)
69 TCArray lastRegions; // optimizes "again" searches
70 TCArray lastPerRegion; // parallels lastRegions
71
72 void *buffer; // the working buffer for reading in memory from the other app
73 unsigned bufferSize; // size of the working buffer
74
75 // pointers
76 void *valuePtr, *lastValuePtr;
77 TCAddress *addressPtr, *lastAddressPtr;
78 TCAddress *lastRegionPtr;
79 unsigned *lastPerRegionPtr;
80
81 int progress; // 0-100
82 }
83
84 // Initialization
85
86 // this initializer must be used to create a context for a first-time search
87 - (id)initWithPID:(pid_t)pid searchOperator:(TCSearchOperator)op value:(Variable *)val;
88 // these initializers take data from the last search that was performed
89 - (id)initWithLastContext:(SearchContext *)context searchOperator:(TCSearchOperator)op;
90 - (id)initWithLastContext:(SearchContext *)context searchOperator:(TCSearchOperator)op value:(Variable *)val;
91
92 // Accessors
93
94 - (TCVariableType)variableType;
95 - (TCIntegerSign)integerSign;
96 - (TCSearchOperator)searchOperator;
97
98 - (BOOL (*)(void const *, void const *))compareFunction;
99 - (int (*)(id, unsigned))iterationFunction;
100
101
102 @end
This page took 0.034927 seconds and 4 git commands to generate.