extern "C" DLL_EXPORT void _dbg_dbgexitsignal() { dputs("Stopping running debuggee..."); cbDebugStop(0, 0); dputs("Aborting scripts..."); scriptabort(); dputs("Waiting for the debuggee to be stopped..."); wait(WAITID_STOP); //after this, debugging stopped dputs("Unloading plugins..."); pluginunload(); dputs("Stopping command thread..."); bStopCommandLoopThread = true; WaitForThreadTermination(hCommandLoopThread); dputs("Cleaning up allocated data..."); cmdfree(command_list); varfree(); MsgFreeStack(gMsgStack); yr_finalize(); Capstone::GlobalFinalize(); dputs("Checking for mem leaks..."); if(memleaks()) dprintf("%d memory leak(s) found!\n", memleaks()); else DeleteFileA(alloctrace); dputs("Cleaning up wait objects..."); waitdeinitialize(); dputs("Cleaning up debugger threads..."); dbgstop(); dputs("Exit signal processed successfully!"); bIsStopped = true; }
void epfree( /* free a parse tree */ EPNODE *epar ) { EPNODE *ep; switch (epar->type) { case VAR: varfree(epar->v.ln); break; case SYM: freestr(epar->v.name); break; case NUM: case CHAN: case ARG: case CLKT: break; default: while ((ep = epar->v.kid) != NULL) { epar->v.kid = ep->sibling; epfree(ep); } break; } efree((char *)epar); }
EPNODE * dpop( /* pop a definition */ char *name ) { VARDEF *vp; EPNODE *dp; if ((vp = varlookup(name)) == NULL || vp->def == NULL) return(NULL); dp = vp->def; vp->def = dp->sibling; varfree(vp); return(dp); }
/** \brief Initializes various default variables. */ void varinit() { varfree(); // General variables varnew("$result\1$res", 0, VAR_SYSTEM); varnew("$result1\1$res1", 0, VAR_SYSTEM); varnew("$result2\1$res2", 0, VAR_SYSTEM); varnew("$result3\1$res3", 0, VAR_SYSTEM); varnew("$result4\1$res4", 0, VAR_SYSTEM); // InitDebug variables varnew("$hProcess\1$hp", 0, VAR_READONLY); // Process handle varnew("$pid", 0, VAR_READONLY); // Process ID // Hidden variables varnew("$ans\1$an", 0, VAR_HIDDEN); // Read-only variables varnew("$lastalloc", 0, VAR_READONLY); // Last memory allocation varnew("$_EZ_FLAG", 0, VAR_READONLY); // Equal/zero flag for internal use (1 = equal, 0 = unequal) varnew("$_BS_FLAG", 0, VAR_READONLY); // Bigger/smaller flag for internal use (1 = bigger, 0 = smaller) }
extern "C" DLL_EXPORT void _dbg_dbgexitsignal() { cbStopDebug(0, 0); scriptabort(); wait(WAITID_STOP); //after this, debugging stopped pluginunload(); TerminateThread(hCommandLoopThread, 0); CloseHandle(hCommandLoopThread); cmdfree(command_list); varfree(); MsgFreeStack(gMsgStack); yr_finalize(); Capstone::GlobalFinalize(); if(memleaks()) { char msg[256] = ""; sprintf(msg, "%d memory leak(s) found!\n\nPlease send contact the authors of x64dbg.", memleaks()); MessageBoxA(0, msg, "error", MB_ICONERROR | MB_SYSTEMMODAL); } else DeleteFileA(alloctrace); SectionLockerGlobal::Deinitialize(); }