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