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