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