]> Dogcows Code - chaz/thecheat/blob - AppController.m
The Cheat 1.0b1
[chaz/thecheat] / AppController.m
1
2 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 // Project: The Cheat
4 //
5 // File: AppController.m
6 // Created: Wed Aug 13 2003
7 //
8 // Copyright: 2003 Chaz McGarvey. All rights reserved.
9 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
11 #import "AppController.h"
12
13 #include <mach/vm_map.h>
14 #include <mach/mach_traps.h>
15
16
17 // defines
18 #define PID_SELECTED [[[processList objectAtIndex:[processPopup indexOfSelectedItem]] objectForKey:@"NSApplicationProcessIdentifier"] intValue]
19 #define TYPE_SELECTED [typePopup indexOfSelectedItem]
20 #define SIZE_SELECTED [sizePopup indexOfSelectedItem]
21
22
23 @implementation AppController
24
25 - (id)init
26 {
27 if ( self = [super init] )
28 {
29
30 }
31
32 return self;
33 }
34
35 - (void)awakeFromNib
36 {
37 NSNotificationCenter *nc = [[NSWorkspace sharedWorkspace] notificationCenter];
38
39 [self rebuildProcessList];
40 [self updateProcessPopup];
41 [self updateTypePopup];
42 [self updateSizePopup];
43 [self updateChangeButton];
44 [self updateStatusText];
45
46 [nc addObserver:self selector:@selector(processListChanged:) name:@"NSWorkspaceDidLaunchApplicationNotification" object:nil];
47 [nc addObserver:self selector:@selector(processListChanged:) name:@"NSWorkspaceDidTerminateApplicationNotification" object:nil];
48
49 [self reset];
50 }
51
52
53 - (void)reset
54 {
55 if ( cheating )
56 {
57 cheating = NO;
58
59 [addressList release], addressList = nil;
60
61 // update the interface
62 [typePopup setEnabled:YES];
63 [sizePopup setEnabled:YES];
64 [searchTextField setStringValue:@""];
65 [changeTextField setStringValue:@""];
66 [addressTable reloadData];
67 }
68 }
69
70
71 - (void)firstSearch:(id)nothing
72 {
73 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
74
75 pid_t pid = (pid_t)PID_SELECTED;
76 vm_map_t task;
77
78 kern_return_t result;
79
80 vm_address_t address = 0x0;
81 vm_size_t size = 0;
82 vm_region_basic_info_data_t info;
83 mach_msg_type_number_t infoCnt = 8;
84 mach_port_t object_name = 0;
85
86 char unsigned *data;
87 vm_size_t dataCnt;
88
89 char unsigned *string8bit = (char unsigned *)[[searchTextField stringValue] lossyCString];
90 long unsigned stringSize = strlen( string8bit );
91 char integer8bit = (char)[searchTextField intValue];
92 short integer16bit = (short)[searchTextField intValue];
93 long integer32bit = (long)[searchTextField intValue];
94 long long integer64bit = (long long)[searchTextField intValue];
95 float float32bit = (float)[searchTextField floatValue];
96 double float64bit = (double)[searchTextField doubleValue];
97
98 BOOL done = NO;
99
100 if ( (result = task_for_pid( current_task(), pid, &task)) != KERN_SUCCESS )
101 {
102 NSLog( @"task_for_pid returned error: %i", result );
103 return;
104 }
105
106 addressList = [[NSMutableArray alloc] init];
107
108 while ( !done )
109 {
110 if ( (result = vm_region( task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)(&info), &infoCnt, &object_name )) != KERN_SUCCESS )
111 {
112 if ( result != KERN_INVALID_ADDRESS )
113 {
114 NSLog( @"vm_region returned error: %i", result );
115 }
116
117 done = YES;
118 }
119
120 //NSLog( @"address: %X, size: %i", address, size );
121
122 if ( (info.protection & VM_PROT_READ) && ((info.protection & VM_PROT_WRITE) >> 1) )
123 {
124 data = (char unsigned *)malloc( size );
125 dataCnt = size;
126
127 if ( (result = vm_read_overwrite( task, address, size, (vm_address_t)data, &dataCnt )) != KERN_SUCCESS && result != KERN_PROTECTION_FAILURE )
128 {
129 NSLog( @"vm_read_overwrite returned error: %i", result );
130 free( data );
131 done = YES;
132 }
133
134 if ( result == KERN_SUCCESS )
135 {
136 long unsigned i, max = (long unsigned)dataCnt;
137
138 //NSLog( @"data: %X, size: %i", (vm_address_t)data, dataCnt );
139
140 switch ( TYPE_SELECTED )
141 {
142 case TYPE_STRING:
143 switch ( SIZE_SELECTED )
144 {
145 case SIZE_8_BIT:
146 {
147 long unsigned maxString = max - stringSize;
148
149 for ( i = 0; i < maxString; i += sizeof(char unsigned) )
150 {
151 if ( strncmp( string8bit, data+i, stringSize ) == 0 )
152 {
153 [addressList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
154 }
155 }
156 }
157 break;
158 }
159 break;
160
161 case TYPE_INTEGER:
162 switch ( SIZE_SELECTED )
163 {
164 case SIZE_8_BIT:
165 {
166 for ( i = 0; i < max; i += sizeof(char) )
167 {
168 if ( integer8bit == *((char *)(data+i)) )
169 {
170 [addressList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
171 }
172 }
173 }
174 break;
175
176 case SIZE_16_BIT:
177 {
178 for ( i = 0; i < max; i += sizeof(short) )
179 {
180 if ( integer16bit == *((short *)(data+i)) )
181 {
182 [addressList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
183 }
184 }
185 }
186 break;
187
188 case SIZE_32_BIT:
189 {
190 for ( i = 0; i < max; i += sizeof(long) )
191 {
192 if ( integer32bit == *((long *)(data+i)) )
193 {
194 [addressList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
195 }
196 }
197 }
198 break;
199
200 case SIZE_64_BIT:
201 {
202 for ( i = 0; i < max; i += sizeof(long long) )
203 {
204 if ( integer64bit == *((long long *)(data+i)) )
205 {
206 [addressList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
207 }
208 }
209 }
210 break;
211 }
212 break;
213
214 case TYPE_FLOAT:
215 switch ( SIZE_SELECTED+2 )
216 {
217 case SIZE_32_BIT:
218 {
219 for ( i = 0; i < max; i += sizeof(float) )
220 {
221 if ( float32bit == *((float *)(data+i)) )
222 {
223 [addressList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
224 }
225 }
226 }
227 break;
228
229 case SIZE_64_BIT:
230 {
231 for ( i = 0; i < max; i += sizeof(double) )
232 {
233 if ( float64bit == *((double *)(data+i)) )
234 {
235 [addressList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
236 }
237 }
238 }
239 break;
240 }
241 break;
242 }
243 }
244
245 free( data );
246 }
247
248 address += size;
249 }
250
251 searching = NO;
252
253 // update the interface
254 [statusBar stopAnimation:self];
255 [self updateProcessPopup];
256 [self updateSearchButton];
257 [self updateTypePopup];
258 [self updateSizePopup];
259 [self updateChangeButton];
260 [self updateStatusText];
261 [addressTable reloadData];
262
263 [pool release];
264 }
265
266 - (void)search:(id)nothing
267 {
268 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
269
270 pid_t pid = (pid_t)PID_SELECTED;
271 vm_map_t task;
272
273 kern_return_t result;
274
275 vm_address_t address = 0x0;
276 vm_size_t size = 0;
277 vm_region_basic_info_data_t info;
278 mach_msg_type_number_t infoCnt = 8;
279 mach_port_t object_name = 0;
280
281 char unsigned *data;
282 vm_size_t dataCnt;
283
284 char unsigned *string8bit = (char unsigned *)[[searchTextField stringValue] lossyCString];
285 long unsigned stringSize = strlen( string8bit );
286 char integer8bit = (char)[searchTextField intValue];
287 short integer16bit = (short)[searchTextField intValue];
288 long integer32bit = (long)[searchTextField intValue];
289 long long integer64bit = (long long)[searchTextField intValue];
290 float float32bit = (float)[searchTextField floatValue];
291 double float64bit = (double)[searchTextField doubleValue];
292
293 long unsigned j, max = [addressList count];
294
295 NSMutableArray *newList = [[NSMutableArray alloc] init];
296
297 if ( (result = task_for_pid( current_task(), pid, &task)) != KERN_SUCCESS )
298 {
299 NSLog( @"task_for_pid returned error: %i", result );
300 return;
301 }
302
303 for ( j = 0; j < max; j++ )
304 {
305 long unsigned item = [[addressList objectAtIndex:j] unsignedLongValue];
306
307 address = (vm_address_t)item;
308
309 if ( (result = vm_region( task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)(&info), &infoCnt, &object_name )) != KERN_SUCCESS )
310 {
311 if ( result != KERN_INVALID_ADDRESS )
312 {
313 NSLog( @"vm_region returned error: %i", result );
314 }
315
316 break;
317 }
318
319 //NSLog( @"address: %X, size: %i", address, size );
320
321 if ( (info.protection & VM_PROT_READ) && ((info.protection & VM_PROT_WRITE) >> 1) )
322 {
323 data = (char unsigned *)malloc( size );
324 dataCnt = size;
325
326 if ( (result = vm_read_overwrite( task, address, size, (vm_address_t)data, &dataCnt )) != KERN_SUCCESS && result != KERN_PROTECTION_FAILURE )
327 {
328 NSLog( @"vm_read_overwrite returned error: %i", result );
329 free( data );
330 break;
331 }
332
333 if ( result == KERN_SUCCESS )
334 {
335 long unsigned i = item - (long unsigned)address;
336
337 if ( i < (long unsigned)dataCnt )
338 {
339 //NSLog( @"data: %X, size: %i", (vm_address_t)data, dataCnt );
340
341 switch ( TYPE_SELECTED )
342 {
343 case TYPE_STRING:
344 switch ( SIZE_SELECTED )
345 {
346 case SIZE_8_BIT:
347 {
348 if ( strncmp( string8bit, data+i, stringSize ) == 0 )
349 {
350 [newList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
351 }
352 }
353 break;
354 }
355 break;
356
357 case TYPE_INTEGER:
358 switch ( SIZE_SELECTED )
359 {
360 case SIZE_8_BIT:
361 {
362 if ( integer8bit == *((char *)(data+i)) )
363 {
364 [newList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
365 }
366 }
367 break;
368
369 case SIZE_16_BIT:
370 {
371 if ( integer16bit == *((short *)(data+i)) )
372 {
373 [newList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
374 }
375 }
376 break;
377
378 case SIZE_32_BIT:
379 {
380 if ( integer32bit == *((long *)(data+i)) )
381 {
382 [newList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
383 }
384 }
385 break;
386
387 case SIZE_64_BIT:
388 {
389 if ( integer64bit == *((long long *)(data+i)) )
390 {
391 [newList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
392 }
393 }
394 break;
395 }
396 break;
397
398 case TYPE_FLOAT:
399 switch ( SIZE_SELECTED+2 )
400 {
401 case SIZE_32_BIT:
402 {
403 if ( float32bit == *((float *)(data+i)) )
404 {
405 [newList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
406 }
407 }
408 break;
409
410 case SIZE_64_BIT:
411 {
412 if ( float64bit == *((double *)(data+i)) )
413 {
414 [newList addObject:[NSNumber numberWithUnsignedLong:(long unsigned)address + i]];
415 }
416 }
417 break;
418 }
419 break;
420 }
421 }
422 }
423
424 free( data );
425 }
426 }
427
428 [addressList release];
429 addressList = newList;
430
431 searching = NO;
432
433 // update the interface
434 [statusBar stopAnimation:self];
435 [self updateProcessPopup];
436 [self updateSearchButton];
437 [self updateTypePopup];
438 [self updateSizePopup];
439 [self updateChangeButton];
440 [self updateStatusText];
441 [addressTable reloadData];
442
443 [pool release];
444 }
445
446
447 - (void)change
448 {
449 pid_t pid = (pid_t)PID_SELECTED;
450 vm_map_t task;
451
452 kern_return_t result;
453
454 char unsigned *string8bit = (char unsigned *)[[changeTextField stringValue] lossyCString];
455 long unsigned stringSize = strlen( string8bit );
456 char integer8bit = (char)[changeTextField intValue];
457 short integer16bit = (short)[changeTextField intValue];
458 long integer32bit = (long)[changeTextField intValue];
459 long long integer64bit = (long long)[changeTextField intValue];
460 float float32bit = (float)[changeTextField floatValue];
461 double float64bit = (double)[changeTextField doubleValue];
462
463 NSEnumerator *enumerator = [addressTable selectedRowEnumerator];
464 NSNumber *row;
465
466 if ( (result = task_for_pid( current_task(), pid, &task)) != KERN_SUCCESS )
467 {
468 NSLog( @"task_for_pid returned error: %i", result );
469 return;
470 }
471
472 while ( row = [enumerator nextObject] )
473 {
474 long unsigned item = [[addressList objectAtIndex:[row intValue]] unsignedLongValue];
475
476 //NSLog( @"address: %X", item );
477
478 switch ( TYPE_SELECTED )
479 {
480 case TYPE_STRING:
481 switch ( SIZE_SELECTED )
482 {
483 case SIZE_8_BIT:
484 {
485 result = vm_write( task, (vm_address_t)item, (vm_offset_t)string8bit, (mach_msg_type_number_t)stringSize );
486 }
487 break;
488 }
489 break;
490
491 case TYPE_INTEGER:
492 switch ( SIZE_SELECTED )
493 {
494 case SIZE_8_BIT:
495 {
496 result = vm_write( task, (vm_address_t)item, (vm_offset_t)(&integer8bit), sizeof(char) );
497 }
498 break;
499
500 case SIZE_16_BIT:
501 {
502 result = vm_write( task, (vm_address_t)item, (vm_offset_t)(&integer16bit), sizeof(short) );
503 }
504 break;
505
506 case SIZE_32_BIT:
507 {
508 result = vm_write( task, (vm_address_t)item, (vm_offset_t)(&integer32bit), sizeof(long) );
509 }
510 break;
511
512 case SIZE_64_BIT:
513 {
514 result = vm_write( task, (vm_address_t)item, (vm_offset_t)(&integer64bit), sizeof(long long) );
515 }
516 break;
517 }
518 break;
519
520 case TYPE_FLOAT:
521 switch ( SIZE_SELECTED+2 )
522 {
523 case SIZE_32_BIT:
524 {
525 result = vm_write( task, (vm_address_t)item, (vm_offset_t)(&float32bit), sizeof(float) );
526 }
527 break;
528
529 case SIZE_64_BIT:
530 {
531 result = vm_write( task, (vm_address_t)item, (vm_offset_t)(&float64bit), sizeof(double) );
532 }
533 break;
534 }
535 break;
536 }
537 }
538 }
539
540
541 - (void)updateProcessPopup
542 {
543 if ( searching )
544 {
545 [processPopup setEnabled:NO];
546 }
547 else
548 {
549 [processPopup setEnabled:YES];
550 }
551 }
552
553 - (void)updateTypePopup
554 {
555 if ( cheating || searching )
556 {
557 [typePopup setEnabled:NO];
558 }
559 else
560 {
561 int selected = [typePopup indexOfSelectedItem];
562
563 [typePopup setEnabled:YES];
564
565 [typePopup removeAllItems];
566
567 [typePopup addItemWithTitle:@"String"];
568 [typePopup addItemWithTitle:@"Integer"];
569 [typePopup addItemWithTitle:@"Float"];
570
571 [typePopup selectItemAtIndex:selected];
572 }
573 }
574
575 - (void)updateSizePopup
576 {
577 if ( cheating || searching )
578 {
579 [sizePopup setEnabled:NO];
580 }
581 else
582 {
583 [sizePopup setEnabled:YES];
584
585 [sizePopup removeAllItems];
586
587 switch ( TYPE_SELECTED )
588 {
589 case TYPE_STRING:
590 [sizePopup addItemWithTitle:@" 8-bit"];
591 break;
592
593 case TYPE_INTEGER:
594 [sizePopup addItemWithTitle:@" 8-bit"];
595 [sizePopup addItemWithTitle:@"16-bit"];
596 [sizePopup addItemWithTitle:@"32-bit"];
597 [sizePopup addItemWithTitle:@"64-bit"];
598 break;
599
600 case TYPE_FLOAT:
601 [sizePopup addItemWithTitle:@"32-bit"];
602 [sizePopup addItemWithTitle:@"64-bit"];
603 break;
604 }
605 }
606 }
607
608 - (void)updateSearchButton
609 {
610 if ( searching )
611 {
612 [searchTextField setEnabled:NO];
613 [searchButton setEnabled:NO];
614 }
615 else
616 {
617 [searchTextField setEnabled:YES];
618 [searchButton setEnabled:YES];
619 }
620 }
621
622 - (void)updateChangeButton
623 {
624 if ( [addressTable selectedRow] == -1 || searching )
625 {
626 [changeTextField setEnabled:NO];
627 [changeButton setEnabled:NO];
628 }
629 else
630 {
631 [changeTextField setEnabled:YES];
632 [changeButton setEnabled:YES];
633 }
634 }
635
636 - (void)updateStatusText
637 {
638 if ( searching )
639 {
640 [statusText setStringValue:@"Searching..."];
641 }
642 else if ( !cheating )
643 {
644 [statusText setStringValue:[NSString stringWithFormat:@"PID: %i", PID_SELECTED]];
645 }
646 else // cheating
647 {
648 [statusText setStringValue:[NSString stringWithFormat:@"Found: %i", [addressList count]]];
649 }
650
651 [statusText display];
652 }
653
654
655 - (void)processListChanged:(NSNotification *)note
656 {
657 if ( cheating && [[note name] isEqualToString:@"NSWorkspaceDidTerminateApplicationNotification"] )
658 {
659 int pid = PID_SELECTED;
660 int other = [[[note userInfo] objectForKey:@"NSApplicationProcessIdentifier"] intValue];
661
662 // check to make sure the program we were cheating wasn't the one that quit
663 if ( pid == other )
664 {
665 // it was, so let's take care of it
666 NSBeginAlertSheet( @"", @"OK", nil, nil, window, nil, nil, nil, 0, @"The application that was being cheated has quit." );
667
668 [self reset];
669 }
670 }
671
672 [self rebuildProcessList];
673 [self updateProcessPopup];
674 [self updateStatusText];
675 }
676
677
678 - (void)rebuildProcessList
679 {
680 NSString *selected = [[processPopup titleOfSelectedItem] retain];
681 int i, max;
682
683 [processList release];
684 processList = [[[NSWorkspace sharedWorkspace] launchedApplications] retain];
685
686 max = [processList count];
687
688 [processPopup setImagePosition:NSImageOverlaps];
689
690 [processPopup removeAllItems];
691
692 for ( i = 0; i < max; i++ )
693 {
694 NSString *name = [[processList objectAtIndex:i] objectForKey:@"NSApplicationName"];
695 NSString *path = [[processList objectAtIndex:i] objectForKey:@"NSApplicationPath"];
696
697 NSImage *image = [[NSWorkspace sharedWorkspace] iconForFile:path];
698
699 [processPopup addItemWithTitle:name];
700
701 [image setScalesWhenResized:YES];
702 [image setSize:NSMakeSize( 16.0, 16.0 )];
703
704 [[processPopup itemAtIndex:i] setImage:image];
705
706 if ( [selected isEqualToString:[processPopup itemTitleAtIndex:i]] )
707 {
708 [processPopup selectItemAtIndex:i];
709 }
710 }
711
712 [selected release];
713 }
714
715
716 - (void)dealloc
717 {
718 [self reset];
719
720 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
721
722 [processList release];
723
724 [super dealloc];
725 }
726
727
728 - (IBAction)processPopup:(id)sender
729 {
730 [self reset];
731
732 [self updateStatusText];
733 }
734
735 - (IBAction)typePopup:(id)sender
736 {
737 [self updateSizePopup];
738 }
739
740 - (IBAction)searchButton:(id)sender
741 {
742 if ( [[searchTextField stringValue] isEqualToString:@""] )
743 {
744 NSBeep();
745 return;
746 }
747
748 searching = YES;
749
750 // update the interface
751 [statusBar startAnimation:self];
752 [self updateProcessPopup];
753 [self updateSearchButton];
754 [self updateTypePopup];
755 [self updateSizePopup];
756 [self updateChangeButton];
757 [self updateStatusText];
758
759 if ( !cheating )
760 {
761 cheating = YES;
762
763 [NSThread detachNewThreadSelector:@selector(firstSearch:) toTarget:self withObject:nil];
764 }
765 else
766 {
767 [NSThread detachNewThreadSelector:@selector(search:) toTarget:self withObject:nil];
768 }
769 /*
770 {
771 pid_t pid = (pid_t)PID_SELECTED;
772 vm_map_t task;
773
774 kern_return_t result;
775 //int waitStatus;
776
777 addressList = [[NSMutableArray alloc] init];
778
779 result = task_for_pid( current_task(), pid, &task );
780
781 if ( result == KERN_SUCCESS )
782 NSLog( @"KERN_SUCCESS" );
783 else if ( result == KERN_INVALID_ADDRESS )
784 NSLog( @"KERN_INVALID_ADDRESS" );
785 else if ( result == KERN_INVALID_ARGUMENT )
786 NSLog( @"KERN_INVALID_ARGUMENT" );
787 else if ( result == KERN_PROTECTION_FAILURE )
788 NSLog( @"KERN_PROTECTION_FAILURE" );
789 else if ( result == KERN_NO_SPACE )
790 NSLog( @"KERN_NO_SPACE" );
791
792 if ( ptrace( PT_ATTACH, pid, 0, 0 ) != -1 )
793 {
794 if ( waitpid( pid, &waitStatus, WUNTRACED ) == pid )
795 {
796 if ( WIFSTOPPED(waitStatus) )
797 {
798 NSLog( @"process stopped" );
799 }
800 else
801 {
802 NSLog( @"process didn't stop" );
803 }
804
805 {
806 vm_address_t address = 0x1b000;
807 vm_size_t size = 0;
808 vm_region_basic_info_data_t info;
809 mach_msg_type_number_t infoCnt = 8;
810 mach_port_t object_name = 0;
811
812 BOOL canRead, canWrite, canExecute;
813
814 char unsigned *data;
815 vm_size_t dataCnt;
816
817 NSLog( @"pid: %i, task: %i", pid, task );
818
819 result = vm_region( task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)(&info), &infoCnt, &object_name );
820
821 NSLog( @"info count: %i", (int)infoCnt );
822
823 if ( result == KERN_SUCCESS )
824 NSLog( @"KERN_SUCCESS" );
825 else if ( result == KERN_INVALID_ADDRESS )
826 NSLog( @"KERN_INVALID_ADDRESS" );
827 else if ( result == KERN_INVALID_ARGUMENT )
828 NSLog( @"KERN_INVALID_ARGUMENT" );
829 else if ( result == KERN_PROTECTION_FAILURE )
830 NSLog( @"KERN_PROTECTION_FAILURE" );
831 else if ( result == KERN_NO_SPACE )
832 NSLog( @"KERN_NO_SPACE" );
833
834 NSLog( @"address: %X, size: %i", address, size );
835
836 canRead = info.protection & VM_PROT_READ;
837 canWrite = (info.protection & VM_PROT_WRITE) >> 1;
838 canExecute = (info.protection & VM_PROT_EXECUTE) >> 2;
839
840 if ( canRead )
841 NSLog( @"can read" );
842 if ( canWrite )
843 NSLog( @"can write" );
844 if ( canExecute )
845 NSLog( @"can execute" );
846
847 data = (char unsigned *)malloc( size );
848 dataCnt = size;
849
850 result = vm_read_overwrite( task, address, size, (vm_address_t)data, &dataCnt );
851
852 if ( result == KERN_SUCCESS )
853 NSLog( @"KERN_SUCCESS" );
854 else if ( result == KERN_INVALID_ADDRESS )
855 NSLog( @"KERN_INVALID_ADDRESS" );
856 else if ( result == KERN_INVALID_ARGUMENT )
857 NSLog( @"KERN_INVALID_ARGUMENT" );
858 else if ( result == KERN_PROTECTION_FAILURE )
859 NSLog( @"KERN_PROTECTION_FAILURE" );
860 else if ( result == KERN_NO_SPACE )
861 NSLog( @"KERN_NO_SPACE" );
862
863 NSLog( @"data: %X, size: %i", (vm_address_t)data, dataCnt );
864
865 free( data );
866 }
867 }
868 else
869 {
870 NSLog( @"waitpid() failed" );
871 }
872
873 ptrace( PT_DETACH, pid, 0, 0 );
874 }
875 else
876 {
877 NSLog( @"ptrace() failed" );
878 }
879 }*/
880 }
881
882 - (IBAction)changeButton:(id)sender
883 {
884 [self change];
885 }
886
887
888 - (int)numberOfRowsInTableView:(NSTableView *)table
889 {
890 if ( cheating && !searching )
891 return [addressList count];
892
893 return 0;
894 }
895
896 - (id)tableView:(NSTableView *)table objectValueForTableColumn:(NSTableColumn *)column row:(int)row
897 {
898 return [NSString stringWithFormat:@"%X", [[addressList objectAtIndex:row] unsignedLongValue]];
899 }
900
901 - (void)tableView:(NSTableView *) setObjectValue:(id)object forTableColumn:(NSTableColumn *)column row:(int)row
902 {
903 return;
904 }
905
906 - (void)tableViewSelectionDidChange:(NSNotification *)note
907 {
908 [self updateChangeButton];
909 }
910
911
912 @end
This page took 0.070997 seconds and 5 git commands to generate.