@@ -179,10 +179,14 @@ bool Incremental ( vector <uint64_t> &found, const char * what, T& output,
179
179
}
180
180
goto incremental_more;
181
181
}
182
- else if (select. empty () )
182
+ else if (select == " q " )
183
183
{
184
184
return false ;
185
185
}
186
+ else if (select.empty ())
187
+ {
188
+ goto incremental_more;
189
+ }
186
190
else
187
191
{
188
192
if (numberz)
@@ -399,29 +403,91 @@ void FindData(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& range
399
403
DF->Detach ();
400
404
}
401
405
}
402
- /*
403
- while(Incremental(found, "integer",test1))
406
+
407
+ bool TriggerIncremental ( vector <uint64_t > &found )
408
+ {
409
+ string select;
410
+ if (found.empty ())
411
+ {
412
+ cout << " search ready - position the DF cursor and hit enter when ready" << endl;
413
+ }
414
+ else if ( found.size () == 1 )
415
+ {
416
+ cout << " Found single coord!" << endl;
417
+ cout << hex << " 0x" << found[0 ] << endl;
418
+ }
419
+ else
420
+ {
421
+ cout << " Found " << dec << found.size () << " coords." << endl;
422
+ }
423
+ incremental_more:
424
+ cout << " >>" ;
425
+ std::getline (cin, select);
426
+ size_t num = 0 ;
427
+ if ( sscanf (select.c_str ()," p %d" , &num) && num > 0 )
428
+ {
429
+ cout << " Found coords:" << endl;
430
+ for (int i = 0 ; i < min (found.size (), num);i++)
431
+ {
432
+ cout << hex << " 0x" << found[i] << endl;
433
+ }
434
+ goto incremental_more;
435
+ }
436
+ else if (select == " p" )
437
+ {
438
+ cout << " Found coords:" << endl;
439
+ for (int i = 0 ; i < found.size ();i++)
440
+ {
441
+ cout << hex << " 0x" << found[i] << endl;
442
+ }
443
+ goto incremental_more;
444
+ }
445
+ else if (select == " q" )
446
+ {
447
+ return false ;
448
+ }
449
+ else return true ;
450
+ }
451
+
452
+
453
+ void FindCoords (DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
454
+ {
455
+ vector <uint64_t > found;
456
+ int size = 4 ;
457
+ do
458
+ {
459
+ getNumber (" Select coord size (2,4 bytes)" ,size, 4 );
460
+ } while (size != 2 && size != 4 );
461
+ while (TriggerIncremental (found))
404
462
{
405
463
DFMgr.Refresh ();
406
464
DFHack::Context * DF = DFMgr.getSingleContext ();
407
465
DF->Attach ();
408
- SegmentedFinder sf(ranges,DF);
409
- switch(size)
466
+ DFHack::Position * pos = DF->getPosition ();
467
+ pos->Start ();
468
+ int32_t x, y, z;
469
+ pos->getCursorCoords (x,y,z);
470
+ cout << " Searching for: " << dec << x << " :" << y << " :" << z << endl;
471
+ Bytestream select;
472
+ if (size == 2 )
410
473
{
411
- case 1:
412
- sf.Incremental<uint8_t,uint8_t>(test1,alignment,found, equalityP<uint8_t> );
413
- break ;
414
- case 2:
415
- sf.Incremental<uint16_t,uint16_t>(test1,alignment,found, equalityP<uint16_t>);
416
- break;
417
- case 4:
418
- sf.Incremental <uint32_t,uint32_t>(test1,alignment,found, equalityP<uint32_t> );
419
- break ;
474
+ select. insert < uint16_t >(x);
475
+ select. insert < uint16_t >(y );
476
+ select. insert < uint16_t >(z) ;
477
+ }
478
+ else
479
+ {
480
+ select. insert < uint32_t >(x);
481
+ select. insert <uint32_t >(y );
482
+ select. insert < uint32_t >(z) ;
420
483
}
484
+ cout << select << endl;
485
+ SegmentedFinder sf (ranges,DF);
486
+ sf.Incremental < Bytestream ,uint32_t >(select,1 ,found, findBytestream);
421
487
DF->Detach ();
422
488
}
423
489
}
424
- */
490
+
425
491
void PtrTrace (DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
426
492
{
427
493
int element_size;
@@ -841,64 +907,69 @@ int main (void)
841
907
" Select search type: 1=number(default), 2=vector by length, 3=vector>object>string,\n "
842
908
" 4=string, 5=automated offset search, 6=vector by address in its array,\n "
843
909
" 7=pointer vector by address of an object, 8=vector>first object>string\n "
844
- " 9=string buffers, 10=known data, 11=backpointers, 12=data+backpointers\n " ;
910
+ " 9=string buffers, 10=known data, 11=backpointers, 12=data+backpointers\n "
911
+ " 13=coord lookup\n " ;
845
912
int mode;
846
913
do
847
914
{
848
915
getNumber (prompt,mode, 1 , false );
916
+ switch (mode)
917
+ {
918
+ case 1 :
919
+ DF->Detach ();
920
+ FindIntegers (DFMgr, selected_ranges);
921
+ break ;
922
+ case 2 :
923
+ DF->Detach ();
924
+ FindVectorByLength (DFMgr, selected_ranges);
925
+ break ;
926
+ case 3 :
927
+ DF->Detach ();
928
+ FindVectorByObjectRawname (DFMgr, selected_ranges);
929
+ break ;
930
+ case 4 :
931
+ DF->Detach ();
932
+ FindStrings (DFMgr, selected_ranges);
933
+ break ;
934
+ case 5 :
935
+ autoSearch (DF,selected_ranges);
936
+ break ;
937
+ case 6 :
938
+ DF->Detach ();
939
+ FindVectorByBounds (DFMgr,selected_ranges);
940
+ break ;
941
+ case 7 :
942
+ DF->Detach ();
943
+ FindPtrVectorsByObjectAddress (DFMgr,selected_ranges);
944
+ break ;
945
+ case 8 :
946
+ DF->Detach ();
947
+ FindVectorByFirstObjectRawname (DFMgr, selected_ranges);
948
+ break ;
949
+ case 9 :
950
+ DF->Detach ();
951
+ FindStrBufs (DFMgr, selected_ranges);
952
+ break ;
953
+ case 10 :
954
+ DF->Detach ();
955
+ FindData (DFMgr, selected_ranges);
956
+ break ;
957
+ case 11 :
958
+ DF->Detach ();
959
+ PtrTrace (DFMgr, selected_ranges);
960
+ break ;
961
+ case 12 :
962
+ DF->Detach ();
963
+ DataPtrTrace (DFMgr, selected_ranges);
964
+ break ;
965
+ case 13 :
966
+ DF->Detach ();
967
+ FindCoords (DFMgr, selected_ranges);
968
+ break ;
969
+ default :
970
+ cout << " not implemented :(" << endl;
971
+ }
849
972
} while (mode < 1 || mode > 12 );
850
- switch (mode)
851
- {
852
- case 1 :
853
- DF->Detach ();
854
- FindIntegers (DFMgr, selected_ranges);
855
- break ;
856
- case 2 :
857
- DF->Detach ();
858
- FindVectorByLength (DFMgr, selected_ranges);
859
- break ;
860
- case 3 :
861
- DF->Detach ();
862
- FindVectorByObjectRawname (DFMgr, selected_ranges);
863
- break ;
864
- case 4 :
865
- DF->Detach ();
866
- FindStrings (DFMgr, selected_ranges);
867
- break ;
868
- case 5 :
869
- autoSearch (DF,selected_ranges);
870
- break ;
871
- case 6 :
872
- DF->Detach ();
873
- FindVectorByBounds (DFMgr,selected_ranges);
874
- break ;
875
- case 7 :
876
- DF->Detach ();
877
- FindPtrVectorsByObjectAddress (DFMgr,selected_ranges);
878
- break ;
879
- case 8 :
880
- DF->Detach ();
881
- FindVectorByFirstObjectRawname (DFMgr, selected_ranges);
882
- break ;
883
- case 9 :
884
- DF->Detach ();
885
- FindStrBufs (DFMgr, selected_ranges);
886
- break ;
887
- case 10 :
888
- DF->Detach ();
889
- FindData (DFMgr, selected_ranges);
890
- break ;
891
- case 11 :
892
- DF->Detach ();
893
- PtrTrace (DFMgr, selected_ranges);
894
- break ;
895
- case 12 :
896
- DF->Detach ();
897
- DataPtrTrace (DFMgr, selected_ranges);
898
- break ;
899
- default :
900
- cout << " not implemented :(" << endl;
901
- }
902
973
#ifndef LINUX_BUILD
903
974
cout << " Done. Press any key to continue" << endl;
904
975
cin.ignore ();
0 commit comments