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
) ) {
168 if ( context
->bufferSize
< VMRegionSize( region
) ) {
169 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
171 context
->buffer
= buf
;
172 context
->bufferSize
= VMRegionSize( region
);
179 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
183 top
= *context
->lastPerRegionPtr
;
185 for ( i
= 0; i
< top
; i
++ ) {
187 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
188 if ( context
->compareFunc(ptr
,context
->value
->_value
) ) {
189 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
190 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
191 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
193 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
194 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
195 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
198 *context
->addressPtr
= *context
->lastAddressPtr
;
199 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize( context
->values
) );
201 context
->numberOfResults
++;
204 context
->addressPtr
++;
205 context
->valuePtr
+= TCArrayElementSize( context
->values
);
208 context
->lastAddressPtr
++;
213 context
->lastRegionPtr
++;
214 context
->lastPerRegionPtr
++;
216 if ( hitsPerRegion
> 0 ) {
217 TCAddress addr
= VMRegionAddress( region
);
218 unsigned index
= TCArrayElementCount( context
->regions
);
219 unsigned newsize
= index
+ 1;
221 TCArrayResize( context
->regions
, newsize
);
222 TCArrayResize( context
->perRegion
, newsize
);
224 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
225 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
228 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
230 context
->lastRegion
= region
;
234 free( context
->buffer
);
235 context
->buffer
= NULL
;
236 TCArrayResize( context
->addresses
, context
->numberOfResults
);
237 TCArrayResize( context
->values
, context
->numberOfResults
);
243 int SearchIterationLastValue( ThreadedTask
*task
, unsigned iteration
)
245 SearchContext
*context
= [task context
];
247 unsigned hitsPerRegion
= 0;
253 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
255 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
256 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
257 if ( VMRegionIsNotNull( region
) ) {
259 if ( context
->bufferSize
< VMRegionSize( region
) ) {
260 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
262 context
->buffer
= buf
;
263 context
->bufferSize
= VMRegionSize( region
);
270 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
274 top
= *context
->lastPerRegionPtr
;
276 for ( i
= 0; i
< top
; i
++ ) {
278 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
279 if ( context
->compareFunc(ptr
,context
->lastValuePtr
) ) {
280 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
281 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
282 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
284 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
285 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
286 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
289 *context
->addressPtr
= *context
->lastAddressPtr
;
290 memcpy( context
->valuePtr
, ptr
, TCArrayElementSize(context
->values
) );
292 context
->numberOfResults
++;
295 context
->addressPtr
++;
296 context
->valuePtr
+= TCArrayElementSize(context
->values
);
299 context
->lastAddressPtr
++;
300 context
->lastValuePtr
+= TCArrayElementSize(context
->values
);
305 context
->lastRegionPtr
++;
306 context
->lastPerRegionPtr
++;
308 if ( hitsPerRegion
> 0 ) {
309 TCAddress addr
= VMRegionAddress( region
);
310 unsigned index
= TCArrayElementCount( context
->regions
);
311 unsigned newsize
= index
+ 1;
313 TCArrayResize( context
->regions
, newsize
);
314 TCArrayResize( context
->perRegion
, newsize
);
316 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
317 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
320 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
322 context
->lastRegion
= region
;
326 free( context
->buffer
);
327 context
->buffer
= NULL
;
328 TCArrayResize( context
->addresses
, context
->numberOfResults
);
329 TCArrayResize( context
->values
, context
->numberOfResults
);
336 int SearchStringIteration( ThreadedTask
*task
, unsigned iteration
)
338 SearchContext
*context
= [task context
];
340 unsigned hitsPerRegion
= 0;
343 void *ptr
, *top
, *hit
;
346 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
347 if ( VMRegionIsNotNull( region
) ) {
349 if ( context
->bufferSize
< VMRegionSize(region
) ) {
350 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
352 context
->buffer
= buf
;
353 context
->bufferSize
= VMRegionSize(region
);
360 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
364 ptr
= context
->buffer
;
365 top
= context
->buffer
+ VMRegionSize( region
);
366 offset
= VMRegionAddress( region
) - (TCAddress
)context
->buffer
;
369 hit
= bmsearch( context
->value
->_value
, context
->value
->_size
, ptr
, top
- ptr
);
371 if ( context
->numberOfResults
>= TCArrayElementCount(context
->addresses
) ) {
372 TCArrayResize( context
->addresses
, TCArrayElementCount(context
->addresses
) + TC_BUFFER_SIZE
/ sizeof(TCAddress
) );
373 context
->addressPtr
= (TCAddress
*)TCArrayBytes(context
->addresses
) + context
->numberOfResults
;
375 if ( context
->numberOfResults
>= TCArrayElementCount(context
->values
) ) {
376 TCArrayResize( context
->values
, TCArrayElementCount(context
->values
) + TC_BUFFER_SIZE
/ TCArrayElementSize(context
->values
) );
377 context
->valuePtr
= TCArrayBytes(context
->values
) + context
->numberOfResults
* TCArrayElementSize(context
->values
);
380 *context
->addressPtr
= (TCAddress
)hit
+ offset
;
381 memcpy( context
->valuePtr
, hit
, context
->value
->_size
);
382 context
->addressPtr
++;
383 context
->valuePtr
+= context
->value
->_size
;
385 context
->numberOfResults
++;
394 if ( hitsPerRegion
> 0 ) {
395 TCAddress addr
= VMRegionAddress( region
);
396 unsigned index
= TCArrayElementCount( context
->regions
);
397 unsigned newsize
= index
+ 1;
399 TCArrayResize( context
->regions
, newsize
);
400 TCArrayResize( context
->perRegion
, newsize
);
402 TCArraySetElementAtIndex( context
->regions
, index
, &addr
);
403 TCArraySetElementAtIndex( context
->perRegion
, index
, &hitsPerRegion
);
406 ReportSearchProgress( task
, iteration
, context
->regionCount
, &context
->progress
);
408 context
->lastRegion
= region
;
412 free( context
->buffer
);
413 context
->buffer
= NULL
;
414 TCArrayResize( context
->addresses
, context
->numberOfResults
);
415 TCArrayResize( context
->values
, context
->numberOfResults
);
420 int SearchStringIterationAgain( ThreadedTask
*task
, unsigned iteration
)
422 SearchContext
*context
= [task context
];
424 unsigned hitsPerRegion
= 0;
430 if ( iteration
< TCArrayElementCount( context
->lastRegions
) ) {
432 context
->lastRegion
= VMMakeRegion( context
->process
, *(context
->lastRegionPtr
), 0 );
433 region
= VMNextRegionWithAttributes( context
->process
, context
->lastRegion
, VMREGION_READABLE | VMREGION_WRITABLE
);
434 if ( VMRegionIsNotNull( region
) ) {
436 if ( context
->bufferSize
< VMRegionSize( region
) ) {
437 char *buf
= realloc( context
->buffer
, VMRegionSize( region
) );
439 context
->buffer
= buf
;
440 context
->bufferSize
= VMRegionSize( region
);
447 if ( !VMRegionBytes( region
, context
->buffer
, &size
) ) {
451 top
= *context
->lastPerRegionPtr
;
453 for ( i
= 0; i
< top
; i
++ ) {
455 ptr
= context
->buffer
+ *context
->lastAddressPtr
- VMRegionAddress(region
);
456 if ( 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 ( 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
;