Created
October 29, 2019 00:15
-
-
Save ek0/907ba19c050709e03a94d068b561b0b4 to your computer and use it in GitHub Desktop.
QBDI tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <QBDI.h> | |
int Test(int a, int b) | |
{ | |
return a + b; | |
} | |
QBDI::VMAction printInstruction(QBDI::VMInstanceRef vm, | |
QBDI::GPRState* gprState, | |
QBDI::FPRState* fprState, | |
void* data) { | |
const QBDI::InstAnalysis* instAnalysis = vm->getInstAnalysis(); | |
std::cout << std::setbase(16) << instAnalysis->address << " " | |
<< instAnalysis->disassembly << std::endl << std::setbase(10); | |
return QBDI::VMAction::CONTINUE; | |
} | |
int main() { | |
uint8_t* fakestack = nullptr; | |
QBDI::VM* vm = new QBDI::VM(); | |
QBDI::GPRState* state = vm->getGPRState(); | |
QBDI::allocateVirtualStack(state, 0x1000000, &fakestack); | |
vm->addInstrumentedModuleFromAddr((QBDI::rword)Test); | |
vm->addCodeCB(QBDI::PREINST, printInstruction, NULL); | |
QBDI::rword retVal; | |
vm->call(&retVal, (QBDI::rword)Test, { 42, 42 }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment