extern "C" DLL_EXPORT bool _dbg_getregdump(REGDUMP* regdump) { if(!DbgIsDebugging()) { memset(regdump, 0, sizeof(REGDUMP)); return true; } TITAN_ENGINE_CONTEXT_t titcontext; if(!GetFullContextDataEx(hActiveThread, &titcontext)) return false; TranslateTitanContextToRegContext(&titcontext, ®dump->regcontext); duint cflags = regdump->regcontext.eflags; regdump->flags.c = valflagfromstring(cflags, "cf"); regdump->flags.p = valflagfromstring(cflags, "pf"); regdump->flags.a = valflagfromstring(cflags, "af"); regdump->flags.z = valflagfromstring(cflags, "zf"); regdump->flags.s = valflagfromstring(cflags, "sf"); regdump->flags.t = valflagfromstring(cflags, "tf"); regdump->flags.i = valflagfromstring(cflags, "if"); regdump->flags.d = valflagfromstring(cflags, "df"); regdump->flags.o = valflagfromstring(cflags, "of"); x87FPURegister_t x87FPURegisters[8]; Getx87FPURegisters(x87FPURegisters, &titcontext); TranslateTitanFpuRegisters(x87FPURegisters, regdump->x87FPURegisters); GetMMXRegisters(regdump->mmx, &titcontext); GetMxCsrFields(& (regdump->MxCsrFields), regdump->regcontext.MxCsr); Getx87ControlWordFields(& (regdump->x87ControlWordFields), regdump->regcontext.x87fpu.ControlWord); Getx87StatusWordFields(& (regdump->x87StatusWordFields), regdump->regcontext.x87fpu.StatusWord); LASTERROR lastError; lastError.code = ThreadGetLastError(ThreadGetId(hActiveThread)); lastError.name = ErrorCodeToName(lastError.code); regdump->lastError = lastError; return true; }
DWORD DispatchCmd(po::variables_map argsMap, po::options_description& config) { DWORD dwError = ERROR_SUCCESS; dwError = DispatchInitFunctions(argsMap, config); BAIL_ON_ERROR(dwError); dwError = DispatchFunctions(argsMap, config); if( dwError == VMCA_ENUM_END) { dwError = ERROR_SUCCESS; // this is the Standard Success } BAIL_ON_ERROR(dwError); error : std::cout << "Status : " << ((dwError == 0) ? "Success" : "Failed") << std::endl; if(dwError != 0) { PSTR szErrorMessage = NULL; DWORD dwErrTemp = 0; std::cout << "Error Code : " << dwError << std::endl; dwErrTemp = VMCAGetErrorString(dwError, &szErrorMessage); if (dwErrTemp == ERROR_SUCCESS && szErrorMessage) { std::cout << "Error Message : " << szErrorMessage << std::endl; VMCA_SAFE_FREE_STRINGA(szErrorMessage); } else { std::cout << "Error Message : " << ErrorCodeToName(dwError) << std::endl; } } return dwError; }