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.
26 * WARNING! BEWARE! WATCH OUT!
28 * This source code file makes use of goto jump statements. If goto statements
29 * are disagreeable to you, you may want to skip over this file or you face the
30 * possibility that you will be changed in a very deep and personal way.
32 * You have been warned.
36 /* Here are some handy functions used in this file. */
38 void ReportSearchProgress( ThreadedTask
*task
, unsigned iteration
, unsigned regions
, int *progress
)
40 int newProgress
= (iteration
* 100) / regions
;
41 if ( newProgress
> *progress
) {
42 *progress
= newProgress
;
43 [task reportProgress
:newProgress
];
49 * This is a real gem. I have no idea where I got this, but it is a wicked
50 * fast string searching algorithm. Hope it's not patented...
53 void *bmsearch( char *pat
, int m
, char *text
, int n
) {
54 int i
,j
,k
,skip
[ASIZE
];if(m
==0)return 0;
55 for(k
=0;k
<ASIZE
;k
++)skip
[k
]=m
;
56 for(k
=0;k
<m
-1;k
++)skip
[(int)pat
[k
]]=m
-k
-1;
57 for(k
=m
-1;k
<n
;k
+=skip
[(int)text
[k
]&(ASIZE
-1)]){
58 for(j
=m
-1,i
=k
;j
>=0&&text
[i
]==pat
[j
];j
--)i
--;
59 if(j
==-1)return(text
+i
+1);}
65 #pragma mark Search Functions
68 int SearchIteration( ThreadedTask
*task
, unsigned iteration
)
70 SearchContext
*context
= [task context
];
72 unsigned hitsPerRegion
= 0;
78 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
79 if ( VMRegionIsNotNull( region
) ) {
81 if ( context
->bufferSize
< VMRegionSize( region
) ) {
82 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
84 context
->buffer
= buf
;
85 context
->bufferSize
= VMRegionSize( region
);
92 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
96 ptr
= context
->buffer
;
97 top
= context
->buffer
+ VMRegionSize( region
);
98 offset
= VMRegionAddress( region
) - (TCAddress
)context
->buffer
;
100 while ( ptr
< top
) {
101 char firstValue
[context
->value
->_size
];
102 memcpy(firstValue
, ptr
, context
->value
->_size
);
104 if (context
->value
->_isEmulated
)
106 if (context
->value
->_type
== TCFloat
)
108 CFSwappedFloat32 firstSwappedFloat
= CFConvertFloat32HostToSwapped(*((float *)firstValue
));
109 memcpy(firstValue
, &firstSwappedFloat
, context
->value
->_size
);
111 else if (context
->value
->_type
== TCDouble
)
113 CFSwappedFloat64 firstSwappedDouble
= CFConvertDoubleHostToSwapped(*((double *)firstValue
));
114 memcpy(firstValue
, &firstSwappedDouble
, context
->value
->_size
);
118 if ( context
->compareFunc(firstValue
,context
->value
->_value
) ) {
119 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
120 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
121 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
123 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
124 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
125 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
128 *context
->addressPtr
= (TCAddress
)ptr
+ offset
;
129 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize( context
->values
) );
131 context
->numberOfResults
++;
134 context
->addressPtr
++;
135 context
->valuePtr
+= TCArrayElementSize( context
->values
);
138 ptr
+= TCArrayElementSize( context
->values
);
142 if ( hitsPerRegion
> 0 ) {
143 TCAddress addr
= VMRegionAddress( region
);
144 unsigned index
= TCArrayElementCount( context
->regions
);
145 unsigned newsize
= index
+ 1;
147 TCArrayResize( context
->regions
, newsize
);
148 TCArrayResize( context
->perRegion
, newsize
);
150 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
151 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
154 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
156 context
->lastRegion
= region
;
160 free( context
->buffer
);
161 context
->buffer
= NULL
;
162 TCArrayResize( context
->addresses
, context
->numberOfResults
);
163 TCArrayResize( context
->values
, context
->numberOfResults
);
169 int SearchIterationAgain( ThreadedTask
*task
, unsigned iteration
)
171 SearchContext
*context
= [task context
];
173 unsigned hitsPerRegion
= 0;
179 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
181 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
182 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
183 if ( VMRegionIsNotNull( region
) ) {
184 if ( context
->bufferSize
< VMRegionSize( region
) ) {
185 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
187 context
->buffer
= buf
;
188 context
->bufferSize
= VMRegionSize( region
);
195 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
199 top
= *context
->lastPerRegionPtr
;
201 for ( i
= 0; i
< top
; i
++ ) {
202 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
204 char firstValue
[context
->value
->_size
];
205 memcpy(firstValue
, ptr
, context
->value
->_size
);
207 if (context
->value
->_isEmulated
)
209 if (context
->value
->_type
== TCFloat
)
211 CFSwappedFloat32 firstSwappedFloat
= CFConvertFloat32HostToSwapped(*((float *)firstValue
));
212 memcpy(firstValue
, &firstSwappedFloat
, context
->value
->_size
);
214 else if (context
->value
->_type
== TCDouble
)
216 CFSwappedFloat64 firstSwappedDouble
= CFConvertDoubleHostToSwapped(*((double *)firstValue
));
217 memcpy(firstValue
, &firstSwappedDouble
, context
->value
->_size
);
221 if (ptr
>= context
->buffer
&& context
->compareFunc(firstValue
,context
->value
->_value
)) {
222 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
223 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
224 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
226 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
227 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
228 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
231 *context
->addressPtr
= *context
->lastAddressPtr
;
232 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize( context
->values
) );
234 context
->numberOfResults
++;
237 context
->addressPtr
++;
238 context
->valuePtr
+= TCArrayElementSize( context
->values
);
241 context
->lastAddressPtr
++;
246 context
->lastRegionPtr
++;
247 context
->lastPerRegionPtr
++;
249 if ( hitsPerRegion
> 0 ) {
250 TCAddress addr
= VMRegionAddress( region
);
251 unsigned index
= TCArrayElementCount( context
->regions
);
252 unsigned newsize
= index
+ 1;
254 TCArrayResize( context
->regions
, newsize
);
255 TCArrayResize( context
->perRegion
, newsize
);
257 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
258 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
261 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
263 context
->lastRegion
= region
;
267 free( context
->buffer
);
268 context
->buffer
= NULL
;
269 TCArrayResize( context
->addresses
, context
->numberOfResults
);
270 TCArrayResize( context
->values
, context
->numberOfResults
);
276 int SearchIterationLastValue( ThreadedTask
*task
, unsigned iteration
)
278 SearchContext
*context
= [task context
];
280 unsigned hitsPerRegion
= 0;
286 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
288 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
289 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
290 if ( VMRegionIsNotNull( region
) ) {
292 if ( context
->bufferSize
< VMRegionSize( region
) ) {
293 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
295 context
->buffer
= buf
;
296 context
->bufferSize
= VMRegionSize( region
);
303 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
307 top
= *context
->lastPerRegionPtr
;
309 for ( i
= 0; i
< top
; i
++ ) {
311 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
312 if ( ptr
>= context
->buffer
&& context
->compareFunc(ptr
,context
->lastValuePtr
) ) {
313 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
314 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
315 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
317 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
318 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
319 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
322 *context
->addressPtr
= *context
->lastAddressPtr
;
323 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize(context
->values
) );
325 context
->numberOfResults
++;
328 context
->addressPtr
++;
329 context
->valuePtr
+= TCArrayElementSize(context
->values
);
332 context
->lastAddressPtr
++;
333 context
->lastValuePtr
+= TCArrayElementSize(context
->values
);
338 context
->lastRegionPtr
++;
339 context
->lastPerRegionPtr
++;
341 if ( hitsPerRegion
> 0 ) {
342 TCAddress addr
= VMRegionAddress( region
);
343 unsigned index
= TCArrayElementCount( context
->regions
);
344 unsigned newsize
= index
+ 1;
346 TCArrayResize( context
->regions
, newsize
);
347 TCArrayResize( context
->perRegion
, newsize
);
349 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
350 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
353 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
355 context
->lastRegion
= region
;
359 free( context
->buffer
);
360 context
->buffer
= NULL
;
361 TCArrayResize( context
->addresses
, context
->numberOfResults
);
362 TCArrayResize( context
->values
, context
->numberOfResults
);
369 int SearchStringIteration( ThreadedTask
*task
, unsigned iteration
)
371 SearchContext
*context
= [task context
];
373 unsigned hitsPerRegion
= 0;
376 void *ptr
, *top
, *hit
;
379 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
380 if ( VMRegionIsNotNull( region
) ) {
382 if ( context
->bufferSize
< VMRegionSize(region
) ) {
383 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
385 context
->buffer
= buf
;
386 context
->bufferSize
= VMRegionSize(region
);
393 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
397 ptr
= context
->buffer
;
398 top
= context
->buffer
+ VMRegionSize( region
);
399 offset
= VMRegionAddress( region
) - (TCAddress
)context
->buffer
;
402 hit
= bmsearch( context
->value
->_value
, context
->value
->_size
, ptr
, top
- ptr
);
404 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
405 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
406 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
408 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
409 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
410 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
413 *context
->addressPtr
= (TCAddress
)hit
+ offset
;
414 memcpy( context
->valuePtr
, hit
, context
->value
->_size
);
415 context
->addressPtr
++;
416 context
->valuePtr
+= context
->value
->_size
;
418 context
->numberOfResults
++;
427 if ( hitsPerRegion
> 0 ) {
428 TCAddress addr
= VMRegionAddress( region
);
429 unsigned index
= TCArrayElementCount( context
->regions
);
430 unsigned newsize
= index
+ 1;
432 TCArrayResize( context
->regions
, newsize
);
433 TCArrayResize( context
->perRegion
, newsize
);
435 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
436 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
439 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
441 context
->lastRegion
= region
;
445 free( context
->buffer
);
446 context
->buffer
= NULL
;
447 TCArrayResize( context
->addresses
, context
->numberOfResults
);
448 TCArrayResize( context
->values
, context
->numberOfResults
);
453 int SearchStringIterationAgain( ThreadedTask
*task
, unsigned iteration
)
455 SearchContext
*context
= [task context
];
457 unsigned hitsPerRegion
= 0;
463 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
465 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
466 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
467 if ( VMRegionIsNotNull( region
) ) {
469 if ( context
->bufferSize
< VMRegionSize( region
) ) {
470 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
472 context
->buffer
= buf
;
473 context
->bufferSize
= VMRegionSize( region
);
480 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
484 top
= *context
->lastPerRegionPtr
;
486 for ( i
= 0; i
< top
; i
++ ) {
488 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
490 if ( ptr
>= context
->buffer
&& memcmp( ptr
, context
->value
->_value
, MIN(TCArrayElementSize(context
->values
),context
->buffer
+VMRegionAddress(region
)-ptr
) ) == 0 ) {
491 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
492 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
493 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
495 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
496 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
497 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
500 *context
->addressPtr
= *context
->lastAddressPtr
;
501 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize( context
->values
) );
502 context
->addressPtr
++;
503 context
->valuePtr
+= TCArrayElementSize( context
->values
);
505 context
->numberOfResults
++;
509 context
->lastAddressPtr
++;
514 context
->lastRegionPtr
++;
515 context
->lastPerRegionPtr
++;
517 if ( hitsPerRegion
> 0 ) {
518 TCAddress addr
= VMRegionAddress( region
);
519 unsigned index
= TCArrayElementCount( context
->regions
);
520 unsigned newsize
= index
+ 1;
522 TCArrayResize( context
->regions
, newsize
);
523 TCArrayResize( context
->perRegion
, newsize
);
525 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
526 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
529 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
531 context
->lastRegion
= region
;
535 free( context
->buffer
);
536 context
->buffer
= NULL
;
537 TCArrayResize( context
->addresses
, context
->numberOfResults
);
538 TCArrayResize( context
->values
, context
->numberOfResults
);
543 int SearchStringIterationLastValue( ThreadedTask
*task
, unsigned iteration
)
545 SearchContext
*context
= [task context
];
547 unsigned hitsPerRegion
= 0;
553 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
555 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
556 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
557 if ( VMRegionIsNotNull( region
) ) {
559 if ( context
->bufferSize
< VMRegionSize( region
) ) {
560 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
562 context
->buffer
= buf
;
563 context
->bufferSize
= VMRegionSize( region
);
570 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
574 top
= *context
->lastPerRegionPtr
;
576 for ( i
= 0; i
< top
; i
++ ) {
578 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
579 if ( ptr
>= context
->buffer
&& memcmp( ptr
, context
->lastValuePtr
, MIN(TCArrayElementSize(context
->values
),context
->buffer
+VMRegionAddress(region
)-ptr
) ) == 0 ) {
580 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
581 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
582 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
584 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
585 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
586 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
589 *context
->addressPtr
= *context
->lastAddressPtr
;
590 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize(context
->values
) );
591 context
->addressPtr
++;
592 context
->valuePtr
+= TCArrayElementSize(context
->values
);
594 context
->numberOfResults
++;
598 context
->lastAddressPtr
++;
599 context
->lastValuePtr
+= TCArrayElementSize(context
->lastValues
);
604 context
->lastRegionPtr
++;
605 context
->lastPerRegionPtr
++;
607 if ( hitsPerRegion
> 0 ) {
608 TCAddress addr
= VMRegionAddress( region
);
609 unsigned index
= TCArrayElementCount( context
->regions
);
610 unsigned newsize
= index
+ 1;
612 TCArrayResize( context
->regions
, newsize
);
613 TCArrayResize( context
->perRegion
, newsize
);
615 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
616 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
619 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
621 context
->lastRegion
= region
;
625 free( context
->buffer
);
626 context
->buffer
= NULL
;
627 TCArrayResize( context
->addresses
, context
->numberOfResults
);
628 TCArrayResize( context
->values
, context
->numberOfResults
);
636 #pragma mark Comparison Functions
640 BOOL EqualInt64( void const *first
, void const *second
) {
641 return *(SInt64
*)first
== *(SInt64
*)second
;
643 BOOL EqualInt32( void const *first
, void const *second
) {
644 return *(SInt32
*)first
== *(SInt32
*)second
;
646 BOOL EqualInt16( void const *first
, void const *second
) {
647 return *(SInt16
*)first
== *(SInt16
*)second
;
649 BOOL EqualInt8( void const *first
, void const *second
) {
650 return *(SInt8
*)first
== *(SInt8
*)second
;
652 BOOL EqualUInt64( void const *first
, void const *second
) {
653 return *(UInt64
*)first
== *(UInt64
*)second
;
655 BOOL EqualUInt32( void const *first
, void const *second
) {
656 return *(UInt32
*)first
== *(UInt32
*)second
;
658 BOOL EqualUInt16( void const *first
, void const *second
) {
659 return *(UInt16
*)first
== *(UInt16
*)second
;
661 BOOL EqualUInt8( void const *first
, void const *second
) {
662 return *(UInt8
*)first
== *(UInt8
*)second
;
664 BOOL EqualFloat( void const *first
, void const *second
) {
665 return TC_EPSILON
> ABS( *(float *)first
- *(float *)second
);
667 BOOL EqualDouble( void const *first
, void const *second
) {
668 return TC_EPSILON
> ABS( *(double *)first
- *(double *)second
);
671 BOOL NotEqualInt64( void const *first
, void const *second
) {
672 return *(SInt64
*)first
!= *(SInt64
*)second
;
674 BOOL NotEqualInt32( void const *first
, void const *second
) {
675 return *(SInt32
*)first
!= *(SInt32
*)second
;
677 BOOL NotEqualInt16( void const *first
, void const *second
) {
678 return *(SInt16
*)first
!= *(SInt16
*)second
;
680 BOOL NotEqualInt8( void const *first
, void const *second
) {
681 return *(SInt8
*)first
!= *(SInt8
*)second
;
683 BOOL NotEqualUInt64( void const *first
, void const *second
) {
684 return *(UInt64
*)first
!= *(UInt64
*)second
;
686 BOOL NotEqualUInt32( void const *first
, void const *second
) {
687 return *(UInt32
*)first
!= *(UInt32
*)second
;
689 BOOL NotEqualUInt16( void const *first
, void const *second
) {
690 return *(UInt16
*)first
!= *(UInt16
*)second
;
692 BOOL NotEqualUInt8( void const *first
, void const *second
) {
693 return *(UInt8
*)first
!= *(UInt8
*)second
;
695 BOOL NotEqualFloat( void const *first
, void const *second
) {
696 return TC_EPSILON
<= ABS( *(float *)first
- *(float *)second
);
698 BOOL NotEqualDouble( void const *first
, void const *second
) {
699 return TC_EPSILON
<= ABS( *(double *)first
- *(double *)second
);
702 BOOL LessThanInt64( void const *first
, void const *second
) {
703 return *(SInt64
*)first
< *(SInt64
*)second
;
705 BOOL LessThanInt32( void const *first
, void const *second
) {
706 return *(SInt32
*)first
< *(SInt32
*)second
;
708 BOOL LessThanInt16( void const *first
, void const *second
) {
709 return *(SInt16
*)first
< *(SInt16
*)second
;
711 BOOL LessThanInt8( void const *first
, void const *second
) {
712 return *(SInt8
*)first
< *(SInt8
*)second
;
714 BOOL LessThanUInt64( void const *first
, void const *second
) {
715 return *(UInt64
*)first
< *(UInt64
*)second
;
717 BOOL LessThanUInt32( void const *first
, void const *second
) {
718 return *(UInt32
*)first
< *(UInt32
*)second
;
720 BOOL LessThanUInt16( void const *first
, void const *second
) {
721 return *(UInt16
*)first
< *(UInt16
*)second
;
723 BOOL LessThanUInt8( void const *first
, void const *second
) {
724 return *(UInt8
*)first
< *(UInt8
*)second
;
726 BOOL LessThanFloat( void const *first
, void const *second
) {
727 return *(float *)first
< *(float *)second
;
729 BOOL LessThanDouble( void const *first
, void const *second
) {
730 return *(double *)first
< *(double *)second
;
733 BOOL GreaterThanInt64( void const *first
, void const *second
) {
734 return *(SInt64
*)first
> *(SInt64
*)second
;
736 BOOL GreaterThanInt32( void const *first
, void const *second
) {
737 return *(SInt32
*)first
> *(SInt32
*)second
;
739 BOOL GreaterThanInt16( void const *first
, void const *second
) {
740 return *(SInt16
*)first
> *(SInt16
*)second
;
742 BOOL GreaterThanInt8( void const *first
, void const *second
) {
743 return *(SInt8
*)first
> *(SInt8
*)second
;
745 BOOL GreaterThanUInt64( void const *first
, void const *second
) {
746 return *(UInt64
*)first
> *(UInt64
*)second
;
748 BOOL GreaterThanUInt32( void const *first
, void const *second
) {
749 return *(UInt32
*)first
> *(UInt32
*)second
;
751 BOOL GreaterThanUInt16( void const *first
, void const *second
) {
752 return *(UInt16
*)first
> *(UInt16
*)second
;
754 BOOL GreaterThanUInt8( void const *first
, void const *second
) {
755 return *(UInt8
*)first
> *(UInt8
*)second
;
757 BOOL GreaterThanFloat( void const *first
, void const *second
) {
758 return *(float *)first
> *(float *)second
;
760 BOOL GreaterThanDouble( void const *first
, void const *second
) {
761 return *(double *)first
> *(double *)second
;