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 if ( context
->compareFunc(ptr
,context
->value
->_value
) ) {
102 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
103 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
104 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
106 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
107 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
108 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
111 *context
->addressPtr
= (TCAddress
)ptr
+ offset
;
112 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize( context
->values
) );
114 context
->numberOfResults
++;
117 context
->addressPtr
++;
118 context
->valuePtr
+= TCArrayElementSize( context
->values
);
121 ptr
+= TCArrayElementSize( context
->values
);
125 if ( hitsPerRegion
> 0 ) {
126 TCAddress addr
= VMRegionAddress( region
);
127 unsigned index
= TCArrayElementCount( context
->regions
);
128 unsigned newsize
= index
+ 1;
130 TCArrayResize( context
->regions
, newsize
);
131 TCArrayResize( context
->perRegion
, newsize
);
133 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
134 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
137 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
139 context
->lastRegion
= region
;
143 free( context
->buffer
);
144 context
->buffer
= NULL
;
145 TCArrayResize( context
->addresses
, context
->numberOfResults
);
146 TCArrayResize( context
->values
, context
->numberOfResults
);
152 int SearchIterationAgain( ThreadedTask
*task
, unsigned iteration
)
154 SearchContext
*context
= [task context
];
156 unsigned hitsPerRegion
= 0;
162 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
164 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
165 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
166 if ( VMRegionIsNotNull( region
) ) {
167 if ( context
->bufferSize
< VMRegionSize( region
) ) {
168 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
170 context
->buffer
= buf
;
171 context
->bufferSize
= VMRegionSize( region
);
178 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
182 top
= *context
->lastPerRegionPtr
;
184 for ( i
= 0; i
< top
; i
++ ) {
185 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
187 if (ptr
>= context
->buffer
&& context
->compareFunc(ptr
,context
->value
->_value
)) {
188 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
189 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
190 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
192 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
193 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
194 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
197 *context
->addressPtr
= *context
->lastAddressPtr
;
198 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize( context
->values
) );
200 context
->numberOfResults
++;
203 context
->addressPtr
++;
204 context
->valuePtr
+= TCArrayElementSize( context
->values
);
207 context
->lastAddressPtr
++;
212 context
->lastRegionPtr
++;
213 context
->lastPerRegionPtr
++;
215 if ( hitsPerRegion
> 0 ) {
216 TCAddress addr
= VMRegionAddress( region
);
217 unsigned index
= TCArrayElementCount( context
->regions
);
218 unsigned newsize
= index
+ 1;
220 TCArrayResize( context
->regions
, newsize
);
221 TCArrayResize( context
->perRegion
, newsize
);
223 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
224 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
227 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
229 context
->lastRegion
= region
;
233 free( context
->buffer
);
234 context
->buffer
= NULL
;
235 TCArrayResize( context
->addresses
, context
->numberOfResults
);
236 TCArrayResize( context
->values
, context
->numberOfResults
);
242 int SearchIterationLastValue( ThreadedTask
*task
, unsigned iteration
)
244 SearchContext
*context
= [task context
];
246 unsigned hitsPerRegion
= 0;
252 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
254 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
255 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
256 if ( VMRegionIsNotNull( region
) ) {
258 if ( context
->bufferSize
< VMRegionSize( region
) ) {
259 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
261 context
->buffer
= buf
;
262 context
->bufferSize
= VMRegionSize( region
);
269 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
273 top
= *context
->lastPerRegionPtr
;
275 for ( i
= 0; i
< top
; i
++ ) {
277 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
278 if ( ptr
>= context
->buffer
&& context
->compareFunc(ptr
,context
->lastValuePtr
) ) {
279 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
280 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
281 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
283 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
284 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
285 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
288 *context
->addressPtr
= *context
->lastAddressPtr
;
289 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize(context
->values
) );
291 context
->numberOfResults
++;
294 context
->addressPtr
++;
295 context
->valuePtr
+= TCArrayElementSize(context
->values
);
298 context
->lastAddressPtr
++;
299 context
->lastValuePtr
+= TCArrayElementSize(context
->values
);
304 context
->lastRegionPtr
++;
305 context
->lastPerRegionPtr
++;
307 if ( hitsPerRegion
> 0 ) {
308 TCAddress addr
= VMRegionAddress( region
);
309 unsigned index
= TCArrayElementCount( context
->regions
);
310 unsigned newsize
= index
+ 1;
312 TCArrayResize( context
->regions
, newsize
);
313 TCArrayResize( context
->perRegion
, newsize
);
315 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
316 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
319 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
321 context
->lastRegion
= region
;
325 free( context
->buffer
);
326 context
->buffer
= NULL
;
327 TCArrayResize( context
->addresses
, context
->numberOfResults
);
328 TCArrayResize( context
->values
, context
->numberOfResults
);
335 int SearchStringIteration( ThreadedTask
*task
, unsigned iteration
)
337 SearchContext
*context
= [task context
];
339 unsigned hitsPerRegion
= 0;
342 void *ptr
, *top
, *hit
;
345 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
346 if ( VMRegionIsNotNull( region
) ) {
348 if ( context
->bufferSize
< VMRegionSize(region
) ) {
349 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
351 context
->buffer
= buf
;
352 context
->bufferSize
= VMRegionSize(region
);
359 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
363 ptr
= context
->buffer
;
364 top
= context
->buffer
+ VMRegionSize( region
);
365 offset
= VMRegionAddress( region
) - (TCAddress
)context
->buffer
;
368 hit
= bmsearch( context
->value
->_value
, context
->value
->_size
, ptr
, top
- ptr
);
370 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
371 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
372 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
374 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
375 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
376 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
379 *context
->addressPtr
= (TCAddress
)hit
+ offset
;
380 memcpy( context
->valuePtr
, hit
, context
->value
->_size
);
381 context
->addressPtr
++;
382 context
->valuePtr
+= context
->value
->_size
;
384 context
->numberOfResults
++;
393 if ( hitsPerRegion
> 0 ) {
394 TCAddress addr
= VMRegionAddress( region
);
395 unsigned index
= TCArrayElementCount( context
->regions
);
396 unsigned newsize
= index
+ 1;
398 TCArrayResize( context
->regions
, newsize
);
399 TCArrayResize( context
->perRegion
, newsize
);
401 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
402 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
405 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
407 context
->lastRegion
= region
;
411 free( context
->buffer
);
412 context
->buffer
= NULL
;
413 TCArrayResize( context
->addresses
, context
->numberOfResults
);
414 TCArrayResize( context
->values
, context
->numberOfResults
);
419 int SearchStringIterationAgain( ThreadedTask
*task
, unsigned iteration
)
421 SearchContext
*context
= [task context
];
423 unsigned hitsPerRegion
= 0;
429 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
431 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
432 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
433 if ( VMRegionIsNotNull( region
) ) {
435 if ( context
->bufferSize
< VMRegionSize( region
) ) {
436 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
438 context
->buffer
= buf
;
439 context
->bufferSize
= VMRegionSize( region
);
446 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
450 top
= *context
->lastPerRegionPtr
;
452 for ( i
= 0; i
< top
; i
++ ) {
454 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
456 if ( ptr
>= context
->buffer
&& memcmp( ptr
, context
->value
->_value
, MIN(TCArrayElementSize(context
->values
),context
->buffer
+VMRegionAddress(region
)-ptr
) ) == 0 ) {
457 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
458 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
459 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
461 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
462 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
463 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
466 *context
->addressPtr
= *context
->lastAddressPtr
;
467 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize( context
->values
) );
468 context
->addressPtr
++;
469 context
->valuePtr
+= TCArrayElementSize( context
->values
);
471 context
->numberOfResults
++;
475 context
->lastAddressPtr
++;
480 context
->lastRegionPtr
++;
481 context
->lastPerRegionPtr
++;
483 if ( hitsPerRegion
> 0 ) {
484 TCAddress addr
= VMRegionAddress( region
);
485 unsigned index
= TCArrayElementCount( context
->regions
);
486 unsigned newsize
= index
+ 1;
488 TCArrayResize( context
->regions
, newsize
);
489 TCArrayResize( context
->perRegion
, newsize
);
491 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
492 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
495 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
497 context
->lastRegion
= region
;
501 free( context
->buffer
);
502 context
->buffer
= NULL
;
503 TCArrayResize( context
->addresses
, context
->numberOfResults
);
504 TCArrayResize( context
->values
, context
->numberOfResults
);
509 int SearchStringIterationLastValue( ThreadedTask
*task
, unsigned iteration
)
511 SearchContext
*context
= [task context
];
513 unsigned hitsPerRegion
= 0;
519 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
521 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
522 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
523 if ( VMRegionIsNotNull( region
) ) {
525 if ( context
->bufferSize
< VMRegionSize( region
) ) {
526 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
528 context
->buffer
= buf
;
529 context
->bufferSize
= VMRegionSize( region
);
536 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
540 top
= *context
->lastPerRegionPtr
;
542 for ( i
= 0; i
< top
; i
++ ) {
544 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
545 if ( ptr
>= context
->buffer
&& memcmp( ptr
, context
->lastValuePtr
, MIN(TCArrayElementSize(context
->values
),context
->buffer
+VMRegionAddress(region
)-ptr
) ) == 0 ) {
546 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
547 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
548 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
550 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
551 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
552 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
555 *context
->addressPtr
= *context
->lastAddressPtr
;
556 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize(context
->values
) );
557 context
->addressPtr
++;
558 context
->valuePtr
+= TCArrayElementSize(context
->values
);
560 context
->numberOfResults
++;
564 context
->lastAddressPtr
++;
565 context
->lastValuePtr
+= TCArrayElementSize(context
->lastValues
);
570 context
->lastRegionPtr
++;
571 context
->lastPerRegionPtr
++;
573 if ( hitsPerRegion
> 0 ) {
574 TCAddress addr
= VMRegionAddress( region
);
575 unsigned index
= TCArrayElementCount( context
->regions
);
576 unsigned newsize
= index
+ 1;
578 TCArrayResize( context
->regions
, newsize
);
579 TCArrayResize( context
->perRegion
, newsize
);
581 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
582 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
585 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
587 context
->lastRegion
= region
;
591 free( context
->buffer
);
592 context
->buffer
= NULL
;
593 TCArrayResize( context
->addresses
, context
->numberOfResults
);
594 TCArrayResize( context
->values
, context
->numberOfResults
);
602 #pragma mark Comparison Functions
606 BOOL EqualInt64( void const *first
, void const *second
) {
607 return *(SInt64
*)first
== *(SInt64
*)second
;
609 BOOL EqualInt32( void const *first
, void const *second
) {
610 return *(SInt32
*)first
== *(SInt32
*)second
;
612 BOOL EqualInt16( void const *first
, void const *second
) {
613 return *(SInt16
*)first
== *(SInt16
*)second
;
615 BOOL EqualInt8( void const *first
, void const *second
) {
616 return *(SInt8
*)first
== *(SInt8
*)second
;
618 BOOL EqualUInt64( void const *first
, void const *second
) {
619 return *(UInt64
*)first
== *(UInt64
*)second
;
621 BOOL EqualUInt32( void const *first
, void const *second
) {
622 return *(UInt32
*)first
== *(UInt32
*)second
;
624 BOOL EqualUInt16( void const *first
, void const *second
) {
625 return *(UInt16
*)first
== *(UInt16
*)second
;
627 BOOL EqualUInt8( void const *first
, void const *second
) {
628 return *(UInt8
*)first
== *(UInt8
*)second
;
630 BOOL EqualFloat( void const *first
, void const *second
) {
631 return TC_EPSILON
> ABS( *(float *)first
- *(float *)second
);
633 BOOL EqualDouble( void const *first
, void const *second
) {
634 return TC_EPSILON
> ABS( *(double *)first
- *(double *)second
);
637 BOOL NotEqualInt64( void const *first
, void const *second
) {
638 return *(SInt64
*)first
!= *(SInt64
*)second
;
640 BOOL NotEqualInt32( void const *first
, void const *second
) {
641 return *(SInt32
*)first
!= *(SInt32
*)second
;
643 BOOL NotEqualInt16( void const *first
, void const *second
) {
644 return *(SInt16
*)first
!= *(SInt16
*)second
;
646 BOOL NotEqualInt8( void const *first
, void const *second
) {
647 return *(SInt8
*)first
!= *(SInt8
*)second
;
649 BOOL NotEqualUInt64( void const *first
, void const *second
) {
650 return *(UInt64
*)first
!= *(UInt64
*)second
;
652 BOOL NotEqualUInt32( void const *first
, void const *second
) {
653 return *(UInt32
*)first
!= *(UInt32
*)second
;
655 BOOL NotEqualUInt16( void const *first
, void const *second
) {
656 return *(UInt16
*)first
!= *(UInt16
*)second
;
658 BOOL NotEqualUInt8( void const *first
, void const *second
) {
659 return *(UInt8
*)first
!= *(UInt8
*)second
;
661 BOOL NotEqualFloat( void const *first
, void const *second
) {
662 return TC_EPSILON
<= ABS( *(float *)first
- *(float *)second
);
664 BOOL NotEqualDouble( void const *first
, void const *second
) {
665 return TC_EPSILON
<= ABS( *(double *)first
- *(double *)second
);
668 BOOL LessThanInt64( void const *first
, void const *second
) {
669 return *(SInt64
*)first
< *(SInt64
*)second
;
671 BOOL LessThanInt32( void const *first
, void const *second
) {
672 return *(SInt32
*)first
< *(SInt32
*)second
;
674 BOOL LessThanInt16( void const *first
, void const *second
) {
675 return *(SInt16
*)first
< *(SInt16
*)second
;
677 BOOL LessThanInt8( void const *first
, void const *second
) {
678 return *(SInt8
*)first
< *(SInt8
*)second
;
680 BOOL LessThanUInt64( void const *first
, void const *second
) {
681 return *(UInt64
*)first
< *(UInt64
*)second
;
683 BOOL LessThanUInt32( void const *first
, void const *second
) {
684 return *(UInt32
*)first
< *(UInt32
*)second
;
686 BOOL LessThanUInt16( void const *first
, void const *second
) {
687 return *(UInt16
*)first
< *(UInt16
*)second
;
689 BOOL LessThanUInt8( void const *first
, void const *second
) {
690 return *(UInt8
*)first
< *(UInt8
*)second
;
692 BOOL LessThanFloat( void const *first
, void const *second
) {
693 return *(float *)first
< *(float *)second
;
695 BOOL LessThanDouble( void const *first
, void const *second
) {
696 return *(double *)first
< *(double *)second
;
699 BOOL GreaterThanInt64( void const *first
, void const *second
) {
700 return *(SInt64
*)first
> *(SInt64
*)second
;
702 BOOL GreaterThanInt32( void const *first
, void const *second
) {
703 return *(SInt32
*)first
> *(SInt32
*)second
;
705 BOOL GreaterThanInt16( void const *first
, void const *second
) {
706 return *(SInt16
*)first
> *(SInt16
*)second
;
708 BOOL GreaterThanInt8( void const *first
, void const *second
) {
709 return *(SInt8
*)first
> *(SInt8
*)second
;
711 BOOL GreaterThanUInt64( void const *first
, void const *second
) {
712 return *(UInt64
*)first
> *(UInt64
*)second
;
714 BOOL GreaterThanUInt32( void const *first
, void const *second
) {
715 return *(UInt32
*)first
> *(UInt32
*)second
;
717 BOOL GreaterThanUInt16( void const *first
, void const *second
) {
718 return *(UInt16
*)first
> *(UInt16
*)second
;
720 BOOL GreaterThanUInt8( void const *first
, void const *second
) {
721 return *(UInt8
*)first
> *(UInt8
*)second
;
723 BOOL GreaterThanFloat( void const *first
, void const *second
) {
724 return *(float *)first
> *(float *)second
;
726 BOOL GreaterThanDouble( void const *first
, void const *second
) {
727 return *(double *)first
> *(double *)second
;