-
Notifications
You must be signed in to change notification settings - Fork 13
/
LocalCheater.m
774 lines (631 loc) · 20.5 KB
/
LocalCheater.m
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
/*
* 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 "LocalCheater.h"
#include "cheat_global.h"
// memory dump function
int _MemoryDumpTask( ThreadedTask *task, unsigned iteration );
@interface LocalCheater ( Private )
// internal methods so they can be used throughout the class
- (void)_clearSearch;
- (BOOL)_pauseTarget; // returns TRUE for success
- (BOOL)_resumeTarget; // returns TRUE for success
// handling app launching/quitting
- (void)_applicationLaunched:(NSNotification *)note;
- (void)_applicationTerminated:(NSNotification *)note;
// cheating
- (unsigned)_doChange:(NSArray *)variables;
- (void)_changeTimer:(NSTimer *)timer;
// watch variables
- (void)_doWatch;
- (void)_watchTimer:(NSTimer *)timer;
// tasks
- (int)_memoryDumpTask:(ThreadedTask *)task iteration:(unsigned)iteration;
@end
@implementation LocalCheater
- (id)init
{
if ( self = [super init] ) {
NSNotificationCenter *nc= [[NSWorkspace sharedWorkspace] notificationCenter];
// register for app launch/quit notifications
[nc addObserver:self selector:@selector(_applicationLaunched:) name:NSWorkspaceDidLaunchApplicationNotification object:nil];
[nc addObserver:self selector:@selector(_applicationTerminated:) name:NSWorkspaceDidTerminateApplicationNotification object:nil];
_searchResults = [[NSMutableArray alloc] init];
_savedResults = [[NSMutableArray alloc] init];
_returnLimit = -1;
}
return self;
}
- (void)dealloc
{
[(NSNotificationCenter *)[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
// make sure the process isn't left paused
[self _resumeTarget];
// release local objects
[_target release];
[self _clearSearch];
// make sure everything is cancelled.
[_searchTask cancelAndRemoveDelegate];
[_dumpTask cancelAndRemoveDelegate];
[self stopChangingVariables];
[self stopWatchingVariables];
[_searchTask release];
[_dumpTask release];
[_processes release];
[super dealloc];
}
- (BOOL)shouldCopy
{
return _shouldCopy;
}
- (void)setShouldCopy:(BOOL)flag
{
_shouldCopy = flag;
}
- (NSString *)hostAddress
{
//return @"127.0.0.1";
return @"this computer";
}
// #############################################################################
#pragma mark Cheater Override
// #############################################################################
- (void)connect
{
if ( !_isConnected ) {
_isConnected = YES;
// return as connected
[_delegate cheaterDidConnect:self];
}
}
- (void)disconnect
{
if ( _isConnected ) {
[_searchTask cancelAndRemoveDelegate];
[_dumpTask cancelAndRemoveDelegate];
[self stopChangingVariables];
[self stopWatchingVariables];
_isConnected = NO;
// return as disconnected
//[_delegate cheaterDidDisconnect:self];
}
}
- (void)authenticateWithPassword:(NSString *)password
{
// being a local cheater, authentication really isn't required.
// return succes every time.
_isAuthenticated = YES;
[_delegate cheaterAcceptedPassword:self];
}
- (void)getProcessList
{
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
// NSArray *launchedApps = [workspace launchedApplications];
// unsigned i, len = [launchedApps count];
ProcessSerialNumber psn = {0, kNoProcess};
if ( !_processes ) {
//_processes = [[NSMutableArray alloc] initWithCapacity:len];
_processes = [[NSMutableArray alloc] initWithCapacity:1];
}
// compile process array
// for ( i = 0; i < len; i++ ) {
while(/*procNotFound != */!GetNextProcess(&psn)) {
// NSDictionary *application = [launchedApps objectAtIndex:i];
NSDictionary *application = (NSDictionary *)ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask);
void *bundlePath = [application objectForKey:@"BundlePath"];
// don't allow The Cheat to be cheated
// if ( [[application objectForKey:@"NSApplicationBundleIdentifier"] isEqualToString:[[NSBundle mainBundle] bundleIdentifier]] ) {
if ( [[application objectForKey:(NSString *)kCFBundleIdentifierKey] isEqualToString:[[NSBundle mainBundle] bundleIdentifier]] ) {
continue;
}
/*Process *process = [[Process alloc] initWithName:[application objectForKey:@"NSApplicationName"]]
version:ApplicationVersion( [application objectForKey:@"NSApplicationPath"] )
icon:[workspace iconForFile:[application objectForKey:@"NSApplicationPath"]]
pid:[[application objectForKey:@"NSApplicationProcessIdentifier"] intValue]];*/
Process *process = [[Process alloc] initWithName:[application objectForKey:(NSString *)kCFBundleNameKey]
version:ApplicationVersion( bundlePath ? bundlePath: [application objectForKey:(NSString *)kCFBundleExecutableKey] )
icon:[workspace iconForFile:bundlePath ? bundlePath: [application objectForKey:(NSString *)kCFBundleExecutableKey]]
pid:[[application objectForKey:@"pid"] intValue]];
[_processes addObject:process];
[process release];
}
// return process list
[_delegate cheater:self didFindProcesses:[NSArray arrayWithArray:_processes]];
}
- (void)setTarget:(Process *)target
{
// unpause the current target if needed
[self resumeTarget];
// clear the search
[self clearSearch];
// set the new target
[_target release];
if ( _shouldCopy ) {
_target = [target copy];
[_delegate cheater:self didSetTarget:[_target copy]];
}
else {
_target = [target retain];
[_delegate cheater:self didSetTarget:_target];
}
}
- (void)pauseTarget
{
// attempt to pause the current target
if ( !_isTargetPaused && [self _pauseTarget] ) {
[_delegate cheaterPausedTarget:self];
}
else {
[_delegate cheater:self echo:@"This process cannot be paused."];
}
}
- (void)resumeTarget
{
// attempt to resume the current target
if ( _isTargetPaused && [self _resumeTarget] ) {
[_delegate cheaterResumedTarget:self];
}
else {
[_delegate cheater:self echo:@"This process cannot be resumed."];
}
}
- (void)limitReturnedResults:(unsigned)limit
{
_returnLimit = limit;
}
- (void)searchForVariable:(Variable *)var comparison:(TCSearchOperator)op
{
SearchContext *context;
void *function;
if ( _searchTask ) {
ChazLog( @"there is already a search task" );
return;
}
if ( [_searchResults count] > 0 ) {
SearchContext *lastContext = [_searchResults lastObject];
if ( ([var type] == TCString) && ([lastContext->value valueSize] < [var valueSize]) ) {
// string size not good
[_delegate cheater:self didFailLastRequest:@"String is too long."];
return;
}
context = [[SearchContext alloc] initWithLastContext:[_searchResults lastObject] searchOperator:op value:var];
}
else {
context = [[SearchContext alloc] initWithPID:[_target pid] searchOperator:op value:var];
}
function = [context iterationFunction];
if ( function ) {
SearchContext *searchContext = context;
if (searchContext->value->_type != TCFloat && searchContext->value->_type != TCDouble)
{
bigEndianValue(searchContext->value->_value, searchContext->value);
}
_searchTask = [[ThreadedTask alloc] initWithFunction:function
context:context
delegate:self];
if ( ![_searchTask run] ) {
// task didn't run
[_searchTask release];
_searchTask = nil;
[_delegate cheater:self didFailLastRequest:@"Internal error."];
}
}
else {
[_delegate cheater:self didFailLastRequest:@"Invalid search parameters."];
}
[context release];
}
- (void)searchLastValuesComparison:(TCSearchOperator)op
{
SearchContext *context;
void *function;
if ( _searchTask ) {
ChazLog( @"there is already a search task" );
return;
}
if ( [_searchResults count] > 0 ) {
context = [[SearchContext alloc] initWithLastContext:[_searchResults lastObject] searchOperator:op];
}
else {
ChazLog( @"doing a searchLastValues search without previous results..." );
[_delegate cheater:self didFailLastRequest:@"Invalid search."];
return;
}
function = [context iterationFunction];
if ( function ) {
_searchTask = [[ThreadedTask alloc] initWithFunction:function
context:context
delegate:self];
if ( ![_searchTask run] ) {
// task didn't run
[_searchTask release];
_searchTask = nil;
[_delegate cheater:self didFailLastRequest:@"Internal error."];
}
}
else {
[_delegate cheater:self didFailLastRequest:@"Invalid search parameters."];
}
[context release];
}
- (void)cancelSearch
{
[_searchTask cancelWithoutWaiting];
}
- (void)clearSearch
{
[self _clearSearch];
[_delegate cheaterDidClearSearch:self];
}
- (void)getMemoryDump
{
if ( _dumpTask ) {
ChazLog( @"there is already a dump task" );
return;
}
_dumpTask = [[ThreadedTask alloc] initWithFunction:_MemoryDumpTask
context:[[[DumpContext alloc] initWithPID:[_target pid]] autorelease]
delegate:self];
if ( ![_dumpTask run] ) {
[_dumpTask release];
_dumpTask = nil;
[_delegate cheater:self didFailLastRequest:@"Internal error."];
}
}
int _MemoryDumpTask( ThreadedTask *task, unsigned iteration )
{
DumpContext *context = [task context];
VMRegion region = VMNextRegionWithAttributes( context->process, context->lastRegion, VMREGION_READABLE );
if ( VMRegionIsNotNull( region ) ) {
[context->dump appendData:VMRegionData( region )];
context->lastRegion = region;
// continue looping
return 1;
}
else {
// no more regions, exit
return 0;
}
}
- (void)cancelMemoryDump
{
[_dumpTask cancelWithoutWaiting];
}
- (void)makeVariableChanges:(NSArray *)variables repeat:(BOOL)doRepeat interval:(NSTimeInterval)repeatInterval
{
unsigned changes;
[self stopChangingVariables];
// repeat the changes if necessary
if ( doRepeat ) {
if ( _shouldCopy ) {
_cheatVariables = [variables copy];
}
else {
_cheatVariables = [variables retain];
}
_cheatTimer = [[NSTimer scheduledTimerWithTimeInterval:repeatInterval
target:self
selector:@selector(_changeTimer:)
userInfo:nil
repeats:YES] retain];
[[NSRunLoop currentRunLoop] addTimer:_cheatTimer forMode:NSEventTrackingRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:_cheatTimer forMode:NSModalPanelRunLoopMode];
}
// change variables
changes = [self _doChange:variables];
[_delegate cheater:self didChangeVariables:changes];
}
- (void)stopChangingVariables
{
if ( _cheatVariables ) {
[_cheatTimer invalidate];
[_cheatTimer release];
_cheatTimer = nil;
[_cheatVariables release];
_cheatVariables = nil;
// report back to delegate
[_delegate cheaterDidStopChangingVariables:self];
}
}
- (void)undo
{
SearchContext *searchContext;
TCArray variables;
TCArray values;
if ( searchContext = [_searchResults lastObject] ) {
[_savedResults addObject:searchContext];
[_searchResults removeLastObject];
[self stopWatchingVariables];
if ( searchContext = [_searchResults lastObject] ) {
if ( _shouldCopy ) {
variables = TCArrayCopyElements( searchContext->addresses, _returnLimit );
values = TCArrayCopyElements( searchContext->values, _returnLimit );
}
else {
variables = TCArrayCopyContainer( searchContext->addresses, _returnLimit );
values = TCArrayCopyContainer( searchContext->values, _returnLimit );
}
[_delegate cheater:self didRevertToVariables:variables actualAmount:TCArrayElementCount( searchContext->addresses )];
[_delegate cheater:self didFindValues:values];
}
[_delegate cheaterDidUndo:self];
}
}
- (void)redo
{
SearchContext *searchContext;
TCArray variables;
TCArray values;
[self stopWatchingVariables];
if ( searchContext = [_savedResults lastObject] ) {
[_searchResults addObject:searchContext];
[_savedResults removeLastObject];
if ( _shouldCopy ) {
variables = TCArrayCopyElements( searchContext->addresses, _returnLimit );
values = TCArrayCopyElements( searchContext->values, _returnLimit );
}
else {
variables = TCArrayCopyContainer( searchContext->addresses, _returnLimit );
values = TCArrayCopyContainer( searchContext->values, _returnLimit );
}
[_delegate cheater:self didRevertToVariables:variables actualAmount:TCArrayElementCount( searchContext->addresses )];
[_delegate cheater:self didFindValues:values];
[_delegate cheaterDidRedo:self];
}
}
- (void)watchVariablesAtIndex:(unsigned)index count:(unsigned)count interval:(NSTimeInterval)checkInterval
{
SearchContext *context;
unsigned i, top;
ChazLog( @"watchVariablesAtIndex:.." );
[self stopWatchingVariables];
if ( count == 0 ) {
ChazLog( @"invalid watch parameters: 0 count" );
return;
}
if ( context = [_searchResults lastObject] ) {
TCArray addresses = context->addresses;
TCArray values = context->values;
// check the index & count
if ( index + count <= TCArrayElementCount( addresses ) ) {
// save current values
NSMutableArray *vars = [[NSMutableArray alloc] initWithCapacity:count];
top = index + count;
for ( i = index; i < top; i++ ) {
Variable *var = [[Variable alloc] initWithType:[context variableType] integerSign:[context integerSign]];
[var setProcess:_target];
[var setAddress:*(TCAddress *)TCArrayElementAtIndex( addresses, i )];
[var setValue:TCArrayElementAtIndex(values, i) size:TCArrayElementSize(values)];
[vars addObject:var];
[var release];
}
_watchVariables = [[NSArray arrayWithArray:vars] retain];
[vars release];
_watchRange = NSMakeRange( index, count );
_watchTimer = [[NSTimer scheduledTimerWithTimeInterval:checkInterval
target:self
selector:@selector(_watchTimer:)
userInfo:nil
repeats:YES] retain];
[[NSRunLoop currentRunLoop] addTimer:_watchTimer forMode:NSEventTrackingRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:_watchTimer forMode:NSModalPanelRunLoopMode];
// do a watch check right now
[self _doWatch];
}
else {
ChazLog( @"invalid watch parameters" );
}
}
}
- (void)stopWatchingVariables
{
if ( _watchVariables ) {
[_watchTimer invalidate];
[_watchTimer release];
_watchTimer = nil;
[_watchVariables release];
_watchVariables = nil;
}
}
// #############################################################################
#pragma mark ThreadedTaskDelegate
// #############################################################################
- (void)threadedTaskFinished:(ThreadedTask *)theTask
{
id context = [theTask context];
[self stopWatchingVariables];
ChazLog( @"threaded task finished" );
if ( [context isKindOfClass:[SearchContext class]] ) {
SearchContext *searchContext = context;
TCArray variables;
TCArray values;
if ( _shouldCopy ) {
variables = TCArrayCopyElements( searchContext->addresses, _returnLimit );
values = TCArrayCopyElements( searchContext->values, _returnLimit );
}
else {
variables = TCArrayCopyContainer( searchContext->addresses, _returnLimit );
values = TCArrayCopyContainer( searchContext->values, _returnLimit );
}
[_searchResults addObject:searchContext];
[_searchTask release];
_searchTask = nil;
[_delegate cheater:self didFindVariables:variables actualAmount:TCArrayElementCount( searchContext->addresses )];
[_delegate cheater:self didFindValues:values];
}
else if ( [context isKindOfClass:[DumpContext class]] ) {
DumpContext *dumpContext = context;
[_delegate cheater:self didDumpMemory:dumpContext->dump];
[_dumpTask release];
_dumpTask = nil;
}
}
- (void)threadedTaskCancelled:(ThreadedTask *)theTask
{
id context = [theTask context];
ChazLog( @"threaded task cancelled" );
if ( [context isKindOfClass:[SearchContext class]] ) {
[_delegate cheaterDidCancelSearch:self];
[_searchTask release];
_searchTask = nil;
}
else if ( [context isKindOfClass:[DumpContext class]] ) {
[_delegate cheaterDidCancelMemoryDump:self];
[_dumpTask release];
_dumpTask = nil;
}
}
- (void)threadedTask:(ThreadedTask *)theTask failedWithErrorCode:(int)errorCode
{
id context = [theTask context];
ChazLog( @"threaded task failed with code: %i", errorCode );
if ( [context isKindOfClass:[SearchContext class]] ) {
[_delegate cheater:self didFailLastRequest:[NSString stringWithFormat:@"Search failed with error: %i", errorCode]];
[_searchTask release];
_searchTask = nil;
}
else if ( [context isKindOfClass:[DumpContext class]] ) {
[_delegate cheater:self didFailLastRequest:[NSString stringWithFormat:@"Dump failed with error: %i", errorCode]];
[_dumpTask release];
_dumpTask = nil;
}
}
- (void)threadedTask:(ThreadedTask *)theTask reportedProgress:(int)theProgress
{
[_delegate cheater:self didReportProgress:theProgress];
}
// #############################################################################
#pragma mark Private Methods
// #############################################################################
- (void)_clearSearch
{
[self stopWatchingVariables];
[self cancelSearch];
// empty the results array
[_searchResults removeAllObjects];
[_savedResults removeAllObjects];
}
- (BOOL)_pauseTarget
{
// attempt to pause
if ( VMStopProcess( [_target pid] ) ) {
_isTargetPaused = YES;
return YES;
}
_isTargetPaused = NO;
return NO;
}
- (BOOL)_resumeTarget
{
if ( VMContinueProcess( [_target pid] ) ) {
_isTargetPaused = NO;
return YES;
}
_isTargetPaused = YES;
return NO;
}
- (void)_applicationLaunched:(NSNotification *)note
{
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSDictionary *application = [note userInfo];
NSString *bundleID;
// don't allow The Cheat to be cheated
bundleID = [application objectForKey:@"NSApplicationBundleIdentifier"];
if ( bundleID && [bundleID isEqualToString:[[NSBundle mainBundle] bundleIdentifier]] ) {
return;
}
Process *process = [[Process alloc] initWithName:[application objectForKey:@"NSApplicationName"]
version:ApplicationVersion( [application objectForKey:@"NSApplicationPath"] )
icon:[workspace iconForFile:[application objectForKey:@"NSApplicationPath"]]
pid:[[application objectForKey:@"NSApplicationProcessIdentifier"] intValue]];
if ( ![_processes containsObject:process] ) {
[_processes addObject:process];
// inform the delegate of the new process
[_delegate cheater:self didAddProcess:process];
}
// cleanup
[process release];
}
- (void)_applicationTerminated:(NSNotification *)note
{
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSDictionary *application = [note userInfo];
Process *process = [[Process alloc] initWithName:[application objectForKey:@"NSApplicationName"]
version:ApplicationVersion( [application objectForKey:@"NSApplicationPath"] )
icon:[workspace iconForFile:[application objectForKey:@"NSApplicationPath"]]
pid:[[application objectForKey:@"NSApplicationProcessIdentifier"] intValue]];
// if this is the current process, take appropriate actions
if ( [_target isEqual:process] ) {
[self cancelSearch];
[self clearSearch];
[self cancelMemoryDump];
[self stopChangingVariables];
[_delegate cheater:self didRemoveProcess:process];
[_delegate cheater:self didFailLastRequest:@"The target quit."];
}
else {
// inform the delegate of the removed process
[_delegate cheater:self didRemoveProcess:process];
}
[_processes removeObject:process];
// cleanup
[process release];
}
- (unsigned)_doChange:(NSArray *)variables
{
unsigned i, top;
unsigned successes = 0;
top = [variables count];
for ( i = 0; i < top; i++ ) {
Variable *variable = [variables objectAtIndex:i];
if ([[variable process] pid] != [_target pid])
{
[variable setProcess:_target];
}
char buffer[variable->_size];
memcpy(buffer, variable->_value, variable->_size);
bigEndianValue(buffer, variable);
if ( VMWriteBytes( [_target pid], [variable address], buffer, [variable valueSize] ) )
{
successes++;
}
}
return successes;
}
- (void)_changeTimer:(NSTimer *)timer
{
unsigned changes = [self _doChange:_cheatVariables];
[_delegate cheater:self didChangeVariables:changes];
}
- (void)_doWatch
{
unsigned i, top;
char value[TC_MAX_VAR_SIZE];
mach_vm_size_t size;
top = [_watchVariables count];
for ( i = 0; i < top; i++ ) {
Variable *variable = [_watchVariables objectAtIndex:i];
size = [variable valueSize];
if ( VMReadBytes( [_target pid], [variable address], value, &size ) ) {
bigEndianValue(value, variable);
// check if memory changed
if (memcmp(value, variable->_value, size) != 0)
{
[variable setValue:value];
// inform delegate of the change
[_delegate cheater:self variableAtIndex:_watchRange.location+i didChangeTo:variable];
}
}
}
}
- (void)_watchTimer:(NSTimer *)timer
{
[self _doWatch];
}
@end