2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
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)
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.
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.
22 #import <Cocoa/Cocoa.h>
25 #import "CheaterTypes.h"
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.
35 #define TC_EPSILON (0.1)
36 // defines the accuracy for floating point comparisons
39 @interface SearchContext
: NSObject
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.
46 TCVariableType _variableType
;
47 TCIntegerSign _integerSign
;
48 TCSearchOperator _operator
;
49 TCSearchType _searchType
;
51 // for fast access while iterating through the task loop.
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
58 Variable
*value
; // the value to compare against (TCGivenValue searches)
59 BOOL (*compareFunc
)(void const *, void const*); // comparison function
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
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
72 void *buffer
; // the working buffer for reading in memory from the other app
73 unsigned bufferSize
; // size of the working buffer
76 void *valuePtr
, *lastValuePtr
;
77 TCAddress
*addressPtr
, *lastAddressPtr
;
78 TCAddress
*lastRegionPtr
;
79 unsigned *lastPerRegionPtr
;
81 int progress
; // 0-100
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
;
94 - (TCVariableType
)variableType
;
95 - (TCIntegerSign
)integerSign
;
96 - (TCSearchOperator
)searchOperator
;
98 - (BOOL (*)(void const *, void const *))compareFunction
;
99 - (int (*)(id
, unsigned))iterationFunction
;