]> Dogcows Code - chaz/thecheat/blob - Searching.m
The Cheat 1.2.4
[chaz/thecheat] / Searching.m
1
2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
5 //
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)
9 // any later version.
10 //
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.
15 //
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.
19 //
20
21
22 #import "Searching.h"
23
24
25 /*
26 * WARNING! BEWARE! WATCH OUT!
27 *
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.
31 *
32 * You have been warned.
33 */
34
35
36 /* Here are some handy functions used in this file. */
37
38 void ReportSearchProgress( ThreadedTask *task, unsigned iteration, unsigned regions, int *progress )
39 {
40 int newProgress = (iteration * 100) / regions;
41 if ( newProgress > *progress ) {
42 *progress = newProgress;
43 [task reportProgress:newProgress];
44 }
45 }
46
47
48 /*
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...
51 */
52 #define ASIZE 256
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);}
60 return NULL;
61 }
62
63
64 #pragma mark -
65 #pragma mark Search Functions
66
67
68 int SearchIteration( ThreadedTask *task, unsigned iteration )
69 {
70 SearchContext *context = [task context];
71 VMRegion region;
72 unsigned hitsPerRegion = 0;
73 vm_size_t size;
74
75 void *ptr, *top;
76 TCAddress offset;
77
78 region = VMNextRegionWithAttributes( context->process, context->lastRegion, VMREGION_READABLE | VMREGION_WRITABLE );
79 if ( VMRegionIsNotNull( region ) ) {
80
81 if ( context->bufferSize < VMRegionSize( region ) ) {
82 char *buf = realloc( context->buffer, VMRegionSize( region ) );
83 if ( buf ) {
84 context->buffer = buf;
85 context->bufferSize = VMRegionSize( region );
86 }
87 else {
88 goto FAILURE;
89 }
90 }
91
92 if ( !VMRegionBytes( region, context->buffer, &size ) ) {
93 goto FAILURE;
94 }
95
96 ptr = context->buffer;
97 top = context->buffer + VMRegionSize( region );
98 offset = VMRegionAddress( region ) - (TCAddress)context->buffer;
99
100 while ( ptr < top ) {
101 char firstValue[context->value->_size];
102 memcpy(firstValue, ptr, context->value->_size);
103
104 if (context->value->_isEmulated)
105 {
106 if (context->value->_type == TCFloat)
107 {
108 CFSwappedFloat32 firstSwappedFloat = CFConvertFloat32HostToSwapped(*((float *)firstValue));
109 memcpy(firstValue, &firstSwappedFloat, context->value->_size);
110 }
111 else if (context->value->_type == TCDouble)
112 {
113 CFSwappedFloat64 firstSwappedDouble = CFConvertDoubleHostToSwapped(*((double *)firstValue));
114 memcpy(firstValue, &firstSwappedDouble, context->value->_size);
115 }
116 }
117
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;
122 }
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);
126 }
127
128 *context->addressPtr = (TCAddress)ptr + offset;
129 memcpy( context->valuePtr, ptr, TCArrayElementSize( context->values ) );
130
131 context->numberOfResults++;
132 hitsPerRegion++;
133
134 context->addressPtr++;
135 context->valuePtr += TCArrayElementSize( context->values );
136 }
137
138 ptr += TCArrayElementSize( context->values );
139 }
140
141 FAILURE:;
142 if ( hitsPerRegion > 0 ) {
143 TCAddress addr = VMRegionAddress( region );
144 unsigned index = TCArrayElementCount( context->regions );
145 unsigned newsize = index + 1;
146
147 TCArrayResize( context->regions, newsize );
148 TCArrayResize( context->perRegion, newsize );
149
150 TCArraySetElementAtIndex( context->regions, index, &addr );
151 TCArraySetElementAtIndex( context->perRegion, index, &hitsPerRegion );
152 }
153
154 ReportSearchProgress( task, iteration, context->regionCount, &context->progress );
155
156 context->lastRegion = region;
157 return 1;
158 }
159 else {
160 free( context->buffer );
161 context->buffer = NULL;
162 TCArrayResize( context->addresses, context->numberOfResults );
163 TCArrayResize( context->values, context->numberOfResults );
164 return 0;
165 }
166 }
167
168
169 int SearchIterationAgain( ThreadedTask *task, unsigned iteration )
170 {
171 SearchContext *context = [task context];
172 VMRegion region;
173 unsigned hitsPerRegion = 0;
174 vm_size_t size;
175
176 void *ptr;
177 unsigned i, top;
178
179 if ( iteration < TCArrayElementCount( context->lastRegions ) ) {
180
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 ) );
186 if ( buf ) {
187 context->buffer = buf;
188 context->bufferSize = VMRegionSize( region );
189 }
190 else {
191 goto FAILURE;
192 }
193 }
194
195 if ( !VMRegionBytes( region, context->buffer, &size ) ) {
196 goto FAILURE;
197 }
198
199 top = *context->lastPerRegionPtr;
200
201 for ( i = 0; i < top; i++ ) {
202 ptr = context->buffer + *context->lastAddressPtr - VMRegionAddress(region);
203
204 char firstValue[context->value->_size];
205 memcpy(firstValue, ptr, context->value->_size);
206
207 if (context->value->_isEmulated)
208 {
209 if (context->value->_type == TCFloat)
210 {
211 CFSwappedFloat32 firstSwappedFloat = CFConvertFloat32HostToSwapped(*((float *)firstValue));
212 memcpy(firstValue, &firstSwappedFloat, context->value->_size);
213 }
214 else if (context->value->_type == TCDouble)
215 {
216 CFSwappedFloat64 firstSwappedDouble = CFConvertDoubleHostToSwapped(*((double *)firstValue));
217 memcpy(firstValue, &firstSwappedDouble, context->value->_size);
218 }
219 }
220
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;
225 }
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);
229 }
230
231 *context->addressPtr = *context->lastAddressPtr;
232 memcpy( context->valuePtr, ptr, TCArrayElementSize( context->values ) );
233
234 context->numberOfResults++;
235 hitsPerRegion++;
236
237 context->addressPtr++;
238 context->valuePtr += TCArrayElementSize( context->values );
239 }
240
241 context->lastAddressPtr++;
242 }
243 }
244
245 FAILURE:;
246 context->lastRegionPtr++;
247 context->lastPerRegionPtr++;
248
249 if ( hitsPerRegion > 0 ) {
250 TCAddress addr = VMRegionAddress( region );
251 unsigned index = TCArrayElementCount( context->regions );
252 unsigned newsize = index + 1;
253
254 TCArrayResize( context->regions, newsize );
255 TCArrayResize( context->perRegion, newsize );
256
257 TCArraySetElementAtIndex( context->regions, index, &addr );
258 TCArraySetElementAtIndex( context->perRegion, index, &hitsPerRegion );
259 }
260
261 ReportSearchProgress( task, iteration, context->regionCount, &context->progress );
262
263 context->lastRegion = region;
264 return 1;
265 }
266 else {
267 free( context->buffer );
268 context->buffer = NULL;
269 TCArrayResize( context->addresses, context->numberOfResults );
270 TCArrayResize( context->values, context->numberOfResults );
271 return 0;
272 }
273 }
274
275
276 int SearchIterationLastValue( ThreadedTask *task, unsigned iteration )
277 {
278 SearchContext *context = [task context];
279 VMRegion region;
280 unsigned hitsPerRegion = 0;
281 vm_size_t size;
282
283 void *ptr;
284 unsigned i, top;
285
286 if ( iteration < TCArrayElementCount( context->lastRegions ) ) {
287
288 context->lastRegion = VMMakeRegion( context->process, *(context->lastRegionPtr), 0 );
289 region = VMNextRegionWithAttributes( context->process, context->lastRegion, VMREGION_READABLE | VMREGION_WRITABLE );
290 if ( VMRegionIsNotNull( region ) ) {
291
292 if ( context->bufferSize < VMRegionSize( region ) ) {
293 char *buf = realloc( context->buffer, VMRegionSize( region ) );
294 if ( buf ) {
295 context->buffer = buf;
296 context->bufferSize = VMRegionSize( region );
297 }
298 else {
299 goto FAILURE;
300 }
301 }
302
303 if ( !VMRegionBytes( region, context->buffer, &size ) ) {
304 goto FAILURE;
305 }
306
307 top = *context->lastPerRegionPtr;
308
309 for ( i = 0; i < top; i++ ) {
310
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;
316 }
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);
320 }
321
322 *context->addressPtr = *context->lastAddressPtr;
323 memcpy( context->valuePtr, ptr, TCArrayElementSize(context->values) );
324
325 context->numberOfResults++;
326 hitsPerRegion++;
327
328 context->addressPtr++;
329 context->valuePtr += TCArrayElementSize(context->values);
330 }
331
332 context->lastAddressPtr++;
333 context->lastValuePtr += TCArrayElementSize(context->values);
334 }
335 }
336
337 FAILURE:;
338 context->lastRegionPtr++;
339 context->lastPerRegionPtr++;
340
341 if ( hitsPerRegion > 0 ) {
342 TCAddress addr = VMRegionAddress( region );
343 unsigned index = TCArrayElementCount( context->regions );
344 unsigned newsize = index + 1;
345
346 TCArrayResize( context->regions, newsize );
347 TCArrayResize( context->perRegion, newsize );
348
349 TCArraySetElementAtIndex( context->regions, index, &addr );
350 TCArraySetElementAtIndex( context->perRegion, index, &hitsPerRegion );
351 }
352
353 ReportSearchProgress( task, iteration, context->regionCount, &context->progress );
354
355 context->lastRegion = region;
356 return 1;
357 }
358 else {
359 free( context->buffer );
360 context->buffer = NULL;
361 TCArrayResize( context->addresses, context->numberOfResults );
362 TCArrayResize( context->values, context->numberOfResults );
363 return 0;
364 }
365 }
366
367
368
369 int SearchStringIteration( ThreadedTask *task, unsigned iteration )
370 {
371 SearchContext *context = [task context];
372 VMRegion region;
373 unsigned hitsPerRegion = 0;
374 vm_size_t size;
375
376 void *ptr, *top, *hit;
377 TCAddress offset;
378
379 region = VMNextRegionWithAttributes( context->process, context->lastRegion, VMREGION_READABLE | VMREGION_WRITABLE );
380 if ( VMRegionIsNotNull( region ) ) {
381
382 if ( context->bufferSize < VMRegionSize(region) ) {
383 char *buf = realloc( context->buffer, VMRegionSize( region ) );
384 if ( buf ) {
385 context->buffer = buf;
386 context->bufferSize = VMRegionSize(region);
387 }
388 else {
389 goto FAILURE;
390 }
391 }
392
393 if ( !VMRegionBytes( region, context->buffer, &size ) ) {
394 goto FAILURE;
395 }
396
397 ptr = context->buffer;
398 top = context->buffer + VMRegionSize( region );
399 offset = VMRegionAddress( region ) - (TCAddress)context->buffer;
400
401 do {
402 hit = bmsearch( context->value->_value, context->value->_size, ptr, top - ptr );
403 if ( hit ) {
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;
407 }
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);
411 }
412
413 *context->addressPtr = (TCAddress)hit + offset;
414 memcpy( context->valuePtr, hit, context->value->_size );
415 context->addressPtr++;
416 context->valuePtr += context->value->_size;
417
418 context->numberOfResults++;
419 hitsPerRegion++;
420 }
421
422 ptr = hit + 1;
423 }
424 while ( hit );
425
426 FAILURE:;
427 if ( hitsPerRegion > 0 ) {
428 TCAddress addr = VMRegionAddress( region );
429 unsigned index = TCArrayElementCount( context->regions );
430 unsigned newsize = index + 1;
431
432 TCArrayResize( context->regions, newsize );
433 TCArrayResize( context->perRegion, newsize );
434
435 TCArraySetElementAtIndex( context->regions, index, &addr );
436 TCArraySetElementAtIndex( context->perRegion, index, &hitsPerRegion );
437 }
438
439 ReportSearchProgress( task, iteration, context->regionCount, &context->progress );
440
441 context->lastRegion = region;
442 return 1;
443 }
444 else {
445 free( context->buffer );
446 context->buffer = NULL;
447 TCArrayResize( context->addresses, context->numberOfResults );
448 TCArrayResize( context->values, context->numberOfResults );
449 return 0;
450 }
451 }
452
453 int SearchStringIterationAgain( ThreadedTask *task, unsigned iteration )
454 {
455 SearchContext *context = [task context];
456 VMRegion region;
457 unsigned hitsPerRegion = 0;
458 vm_size_t size;
459
460 void *ptr;
461 unsigned i, top;
462
463 if ( iteration < TCArrayElementCount( context->lastRegions ) ) {
464
465 context->lastRegion = VMMakeRegion( context->process, *(context->lastRegionPtr), 0 );
466 region = VMNextRegionWithAttributes( context->process, context->lastRegion, VMREGION_READABLE | VMREGION_WRITABLE );
467 if ( VMRegionIsNotNull( region ) ) {
468
469 if ( context->bufferSize < VMRegionSize( region ) ) {
470 char *buf = realloc( context->buffer, VMRegionSize( region ) );
471 if ( buf ) {
472 context->buffer = buf;
473 context->bufferSize = VMRegionSize( region );
474 }
475 else {
476 goto FAILURE;
477 }
478 }
479
480 if ( !VMRegionBytes( region, context->buffer, &size ) ) {
481 goto FAILURE;
482 }
483
484 top = *context->lastPerRegionPtr;
485
486 for ( i = 0; i < top; i++ ) {
487
488 ptr = context->buffer + *context->lastAddressPtr - VMRegionAddress(region);
489
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;
494 }
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);
498 }
499
500 *context->addressPtr = *context->lastAddressPtr;
501 memcpy( context->valuePtr, ptr, TCArrayElementSize( context->values ) );
502 context->addressPtr++;
503 context->valuePtr += TCArrayElementSize( context->values );
504
505 context->numberOfResults++;
506 hitsPerRegion++;
507 }
508
509 context->lastAddressPtr++;
510 }
511 }
512
513 FAILURE:;
514 context->lastRegionPtr++;
515 context->lastPerRegionPtr++;
516
517 if ( hitsPerRegion > 0 ) {
518 TCAddress addr = VMRegionAddress( region );
519 unsigned index = TCArrayElementCount( context->regions );
520 unsigned newsize = index + 1;
521
522 TCArrayResize( context->regions, newsize );
523 TCArrayResize( context->perRegion, newsize );
524
525 TCArraySetElementAtIndex( context->regions, index, &addr );
526 TCArraySetElementAtIndex( context->perRegion, index, &hitsPerRegion );
527 }
528
529 ReportSearchProgress( task, iteration, context->regionCount, &context->progress );
530
531 context->lastRegion = region;
532 return 1;
533 }
534 else {
535 free( context->buffer );
536 context->buffer = NULL;
537 TCArrayResize( context->addresses, context->numberOfResults );
538 TCArrayResize( context->values, context->numberOfResults );
539 return 0;
540 }
541 }
542
543 int SearchStringIterationLastValue( ThreadedTask *task, unsigned iteration )
544 {
545 SearchContext *context = [task context];
546 VMRegion region;
547 unsigned hitsPerRegion = 0;
548 vm_size_t size;
549
550 void *ptr;
551 unsigned i, top;
552
553 if ( iteration < TCArrayElementCount( context->lastRegions ) ) {
554
555 context->lastRegion = VMMakeRegion( context->process, *(context->lastRegionPtr), 0 );
556 region = VMNextRegionWithAttributes( context->process, context->lastRegion, VMREGION_READABLE | VMREGION_WRITABLE );
557 if ( VMRegionIsNotNull( region ) ) {
558
559 if ( context->bufferSize < VMRegionSize( region ) ) {
560 char *buf = realloc( context->buffer, VMRegionSize( region ) );
561 if ( buf ) {
562 context->buffer = buf;
563 context->bufferSize = VMRegionSize( region );
564 }
565 else {
566 goto FAILURE;
567 }
568 }
569
570 if ( !VMRegionBytes( region, context->buffer, &size ) ) {
571 goto FAILURE;
572 }
573
574 top = *context->lastPerRegionPtr;
575
576 for ( i = 0; i < top; i++ ) {
577
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;
583 }
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);
587 }
588
589 *context->addressPtr = *context->lastAddressPtr;
590 memcpy( context->valuePtr, ptr, TCArrayElementSize(context->values) );
591 context->addressPtr++;
592 context->valuePtr += TCArrayElementSize(context->values);
593
594 context->numberOfResults++;
595 hitsPerRegion++;
596 }
597
598 context->lastAddressPtr++;
599 context->lastValuePtr += TCArrayElementSize(context->lastValues);
600 }
601 }
602
603 FAILURE:;
604 context->lastRegionPtr++;
605 context->lastPerRegionPtr++;
606
607 if ( hitsPerRegion > 0 ) {
608 TCAddress addr = VMRegionAddress( region );
609 unsigned index = TCArrayElementCount( context->regions );
610 unsigned newsize = index + 1;
611
612 TCArrayResize( context->regions, newsize );
613 TCArrayResize( context->perRegion, newsize );
614
615 TCArraySetElementAtIndex( context->regions, index, &addr );
616 TCArraySetElementAtIndex( context->perRegion, index, &hitsPerRegion );
617 }
618
619 ReportSearchProgress( task, iteration, context->regionCount, &context->progress );
620
621 context->lastRegion = region;
622 return 1;
623 }
624 else {
625 free( context->buffer );
626 context->buffer = NULL;
627 TCArrayResize( context->addresses, context->numberOfResults );
628 TCArrayResize( context->values, context->numberOfResults );
629 return 0;
630 }
631 }
632
633
634
635 #pragma mark -
636 #pragma mark Comparison Functions
637
638
639
640 BOOL EqualInt64( void const *first, void const *second ) {
641 return *(SInt64 *)first == *(SInt64 *)second;
642 }
643 BOOL EqualInt32( void const *first, void const *second ) {
644 return *(SInt32 *)first == *(SInt32 *)second;
645 }
646 BOOL EqualInt16( void const *first, void const *second ) {
647 return *(SInt16 *)first == *(SInt16 *)second;
648 }
649 BOOL EqualInt8( void const *first, void const *second ) {
650 return *(SInt8 *)first == *(SInt8 *)second;
651 }
652 BOOL EqualUInt64( void const *first, void const *second ) {
653 return *(UInt64 *)first == *(UInt64 *)second;
654 }
655 BOOL EqualUInt32( void const *first, void const *second ) {
656 return *(UInt32 *)first == *(UInt32 *)second;
657 }
658 BOOL EqualUInt16( void const *first, void const *second ) {
659 return *(UInt16 *)first == *(UInt16 *)second;
660 }
661 BOOL EqualUInt8( void const *first, void const *second ) {
662 return *(UInt8 *)first == *(UInt8 *)second;
663 }
664 BOOL EqualFloat( void const *first, void const *second ) {
665 return TC_EPSILON > ABS( *(float *)first - *(float *)second );
666 }
667 BOOL EqualDouble( void const *first, void const *second ) {
668 return TC_EPSILON > ABS( *(double *)first - *(double *)second );
669 }
670
671 BOOL NotEqualInt64( void const *first, void const *second ) {
672 return *(SInt64 *)first != *(SInt64 *)second;
673 }
674 BOOL NotEqualInt32( void const *first, void const *second ) {
675 return *(SInt32 *)first != *(SInt32 *)second;
676 }
677 BOOL NotEqualInt16( void const *first, void const *second ) {
678 return *(SInt16 *)first != *(SInt16 *)second;
679 }
680 BOOL NotEqualInt8( void const *first, void const *second ) {
681 return *(SInt8 *)first != *(SInt8 *)second;
682 }
683 BOOL NotEqualUInt64( void const *first, void const *second ) {
684 return *(UInt64 *)first != *(UInt64 *)second;
685 }
686 BOOL NotEqualUInt32( void const *first, void const *second ) {
687 return *(UInt32 *)first != *(UInt32 *)second;
688 }
689 BOOL NotEqualUInt16( void const *first, void const *second ) {
690 return *(UInt16 *)first != *(UInt16 *)second;
691 }
692 BOOL NotEqualUInt8( void const *first, void const *second ) {
693 return *(UInt8 *)first != *(UInt8 *)second;
694 }
695 BOOL NotEqualFloat( void const *first, void const *second ) {
696 return TC_EPSILON <= ABS( *(float *)first - *(float *)second );
697 }
698 BOOL NotEqualDouble( void const *first, void const *second ) {
699 return TC_EPSILON <= ABS( *(double *)first - *(double *)second );
700 }
701
702 BOOL LessThanInt64( void const *first, void const *second ) {
703 return *(SInt64 *)first < *(SInt64 *)second;
704 }
705 BOOL LessThanInt32( void const *first, void const *second ) {
706 return *(SInt32 *)first < *(SInt32 *)second;
707 }
708 BOOL LessThanInt16( void const *first, void const *second ) {
709 return *(SInt16 *)first < *(SInt16 *)second;
710 }
711 BOOL LessThanInt8( void const *first, void const *second ) {
712 return *(SInt8 *)first < *(SInt8 *)second;
713 }
714 BOOL LessThanUInt64( void const *first, void const *second ) {
715 return *(UInt64 *)first < *(UInt64 *)second;
716 }
717 BOOL LessThanUInt32( void const *first, void const *second ) {
718 return *(UInt32 *)first < *(UInt32 *)second;
719 }
720 BOOL LessThanUInt16( void const *first, void const *second ) {
721 return *(UInt16 *)first < *(UInt16 *)second;
722 }
723 BOOL LessThanUInt8( void const *first, void const *second ) {
724 return *(UInt8 *)first < *(UInt8 *)second;
725 }
726 BOOL LessThanFloat( void const *first, void const *second ) {
727 return *(float *)first < *(float *)second;
728 }
729 BOOL LessThanDouble( void const *first, void const *second ) {
730 return *(double *)first < *(double *)second;
731 }
732
733 BOOL GreaterThanInt64( void const *first, void const *second ) {
734 return *(SInt64 *)first > *(SInt64 *)second;
735 }
736 BOOL GreaterThanInt32( void const *first, void const *second ) {
737 return *(SInt32 *)first > *(SInt32 *)second;
738 }
739 BOOL GreaterThanInt16( void const *first, void const *second ) {
740 return *(SInt16 *)first > *(SInt16 *)second;
741 }
742 BOOL GreaterThanInt8( void const *first, void const *second ) {
743 return *(SInt8 *)first > *(SInt8 *)second;
744 }
745 BOOL GreaterThanUInt64( void const *first, void const *second ) {
746 return *(UInt64 *)first > *(UInt64 *)second;
747 }
748 BOOL GreaterThanUInt32( void const *first, void const *second ) {
749 return *(UInt32 *)first > *(UInt32 *)second;
750 }
751 BOOL GreaterThanUInt16( void const *first, void const *second ) {
752 return *(UInt16 *)first > *(UInt16 *)second;
753 }
754 BOOL GreaterThanUInt8( void const *first, void const *second ) {
755 return *(UInt8 *)first > *(UInt8 *)second;
756 }
757 BOOL GreaterThanFloat( void const *first, void const *second ) {
758 return *(float *)first > *(float *)second;
759 }
760 BOOL GreaterThanDouble( void const *first, void const *second ) {
761 return *(double *)first > *(double *)second;
762 }
763
764
765
766
767
This page took 0.067608 seconds and 4 git commands to generate.