You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mutator.cpp 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <bits/stdc++.h>
  2. #include "BPatch.h"
  3. #include "BPatch_snippet.h"
  4. #include "BPatch_point.h"
  5. #include "BPatch_function.h"
  6. #include "BPatch_binaryEdit.h"
  7. using namespace std;
  8. using namespace Dyninst;
  9. int main()
  10. {
  11. BPatch bpatch;
  12. BPatch_binaryEdit* handle = bpatch.openBinary("a.out", NULL);
  13. if (!handle) {
  14. printf("error opening\n");
  15. exit(1);
  16. }
  17. BPatch_image* apimg = handle->getImage();
  18. vector<BPatch_function*> functions;
  19. apimg->findFunction("main", functions);
  20. vector<BPatch_point*>* pt = functions[0]->findPoint(BPatch_entry);
  21. functions.clear();
  22. apimg->findFunction("fe", functions);
  23. BPatch_function *f0 = functions[0];
  24. vector<BPatch_snippet*> argss;
  25. BPatch_funcCallExpr fnc(*f0, argss);
  26. functions.clear();
  27. apimg->findFunction("fne", functions);
  28. BPatch_function *f1 = functions[0];
  29. BPatch_funcCallExpr fnc1(*f1, argss);
  30. cout << "Testing :: " << "0 | 1" << endl;
  31. BPatch_ifExpr ifexp4(BPatch_boolExpr(BPatch_eq, BPatch_constExpr(0), BPatch_constExpr(1)), fnc, fnc1 );
  32. handle->insertSnippet(ifexp4, *pt);
  33. handle->writeFile("mutated.out");
  34. return 0;
  35. }