X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fthecheat;a=blobdiff_plain;f=CheatServer.m;fp=CheatServer.m;h=ba4ca6e48b791350c1c3f88bb6e6c55306752231;hp=2a8ed8ca899879aeac5835398396c425bacffc03;hb=9177098dc6655dd04fee9d22167335473531c484;hpb=42cf7bbe564d70233a0d73baee613f209eb00eb6 diff --git a/CheatServer.m b/CheatServer.m index 2a8ed8c..ba4ca6e 100644 --- a/CheatServer.m +++ b/CheatServer.m @@ -12,13 +12,16 @@ #import "SearchResults.h" +#include "chaz.h" + #include #include +#include // Internal Functions -BOOL inline compare_float( float a, float b ); -BOOL inline compare_double( double a, double b ); +//BOOL inline compare_float( float a, float b ); +//BOOL inline compare_double( double a, double b ); @implementation CheatServer @@ -613,7 +616,7 @@ BOOL inline compare_double( double a, double b ); for ( i = 0; i < top; i++ ) { - if ( compare_float( *(data+i), value ) ) + if ( cl_compare_float_eps( *(data+i), value, 0.1f ) == 0 ) { results[resultsAmount++] = (TCaddress)address + i * sizeof(value); } @@ -685,7 +688,7 @@ BOOL inline compare_double( double a, double b ); for ( i = 0; i < top; i++ ) { - if ( compare_double( *(data+i), value ) ) + if ( cl_compare_double_eps( *(data+i), value, 0.1 ) == 0 ) { results[resultsAmount++] = (TCaddress)address + i * sizeof(value); } @@ -969,7 +972,7 @@ BOOL inline compare_double( double a, double b ); if ( (result = vm_read_overwrite( processTask, address, sizeof(data), (vm_address_t)(&data), &dataLength )) == KERN_SUCCESS ) { - if ( compare_float( data, value ) ) + if ( cl_compare_float_eps( data, value, 0.1f ) == 0 ) { results[resultsAmount++] = address; } @@ -1026,7 +1029,7 @@ BOOL inline compare_double( double a, double b ); if ( (result = vm_read_overwrite( processTask, address, sizeof(data), (vm_address_t)(&data), &dataLength )) == KERN_SUCCESS ) { - if ( compare_double( data, value ) ) + if ( cl_compare_double_eps( data, value, 0.1 ) == 0 ) { results[resultsAmount++] = address; } @@ -1844,35 +1847,66 @@ BOOL inline compare_double( double a, double b ); { int wait_status; - if ( ptrace( PT_ATTACH, processID, 0, 0 ) != -1 ) + NS_DURING { - if ( waitpid( processID, &wait_status, WUNTRACED ) == processID ) + if ( ptrace( PT_ATTACH, processID, 0, 0 ) != -1 ) { - if ( WIFSTOPPED(wait_status) ) + if ( waitpid( processID, &wait_status, WUNTRACED ) == processID ) { - processPaused = YES; - [self sendPauseFinished:YES]; + if ( WIFSTOPPED(wait_status) ) + { + processPaused = YES; + [self sendPauseFinished:YES]; + } + else + { + NSLog( @"ERROR: process couldn't be paused" ); + [self sendPauseFinished:NO]; + [self sendError:@"Could not pause target because of an unknown error." fatal:NO]; + } } else { NSLog( @"ERROR: process couldn't be paused" ); [self sendPauseFinished:NO]; - [self sendError:@"Process couldn't be paused." fatal:NO]; + [self sendError:@"Could not pause target because of an unknown error." fatal:NO]; } } else { NSLog( @"ERROR: process couldn't be paused" ); [self sendPauseFinished:NO]; - [self sendError:@"Process couldn't be paused." fatal:NO]; + + switch ( errno ) + { + case ESRCH: + [self sendError:@"Could not pause target because there is no valid target to pause." fatal:NO]; + break; + + case EINVAL: + [self sendError:@"Could not pause target because a process cannot pause itself." fatal:NO]; + break; + + case EBUSY: + [self sendError:@"Could not pause target because the target is being controlled by another instance or application." fatal:NO]; + break; + + case EPERM: + [self sendError:@"Could not pause target because this type of application cannot be paused." fatal:NO]; + break; + + default: + [self sendError:@"Could not pause target because of an unknown error." fatal:NO]; + break; + } } } - else + NS_HANDLER { - NSLog( @"ERROR: process couldn't be paused" ); [self sendPauseFinished:NO]; - [self sendError:@"Process couldn't be paused." fatal:NO]; + [self sendError:[NSString stringWithFormat:@"Could not pause target because an exception (%@) was raised: %@", [localException name], [localException reason]] fatal:NO]; } + NS_ENDHANDLER } else { @@ -2019,7 +2053,7 @@ BOOL inline compare_double( double a, double b ); %%%%%%%%%%%%%%%%%%%%%% Internal Functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - +/* BOOL compare_float( float a, float b ) { float const feps = 0.0001f; @@ -2032,4 +2066,4 @@ BOOL compare_double( double a, double b ) double const deps = 0.0000001; return deps > fabs( a - b ); -} \ No newline at end of file +}*/ \ No newline at end of file