Skip to content

Instantly share code, notes, and snippets.

@ek0
Created October 29, 2019 00:15
Show Gist options
  • Save ek0/907ba19c050709e03a94d068b561b0b4 to your computer and use it in GitHub Desktop.
Save ek0/907ba19c050709e03a94d068b561b0b4 to your computer and use it in GitHub Desktop.
QBDI tests
#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