├── Debug ├── x32 │ ├── symsrv.yes │ ├── capstone.dll │ ├── dbghelp.dll │ ├── srcsrv.dll │ ├── symchk.exe │ ├── symsrv.dll │ ├── TitanEngine.dll │ └── SyntaxCfg.json └── x64 │ ├── symsrv.yes │ ├── capstone.dll │ ├── dbghelp.dll │ ├── srcsrv.dll │ ├── symchk.exe │ ├── symsrv.dll │ ├── TitanEngine.dll │ └── SyntaxCfg.json ├── Release └── x32 │ ├── symsrv.yes │ ├── srcsrv.dll │ ├── symchk.exe │ ├── symsrv.dll │ ├── capstone.dll │ ├── dbghelp.dll │ └── TitanEngine.dll ├── mq ├── mq.h ├── mq.cpp ├── mq.rc ├── mq.vcproj ├── msgserv.cpp ├── protocol.h ├── resource.h ├── ClientLogic.h ├── ServerLogic.h ├── ClientLogic.cpp ├── ServerLogic.cpp ├── mq.def ├── dllmain.cpp ├── msgserv.h ├── msgclient.h └── msgclient.cpp ├── res ├── 1.bmp ├── 2.bmp ├── 3.bmp ├── TBCreator.rar ├── toolbar1.bmp └── toolbar2.bmp ├── ComLib ├── md5.h ├── deelx.h ├── ComUtil.h ├── mstring.h ├── servhlpr.h ├── winsize.h ├── ComUtil.cpp ├── GlobalDef.h ├── mstring.cpp ├── servhlpr.cpp ├── winsize.cpp ├── ComLib.vcproj ├── PrintFormater.h ├── SqliteOperator.h ├── json │ ├── json_value.cpp │ ├── json_writer.cpp │ ├── json.h │ ├── forwards.h │ ├── features.h │ ├── config.h │ ├── json_batchallocator.h │ └── writer.h ├── StrSafe.h ├── LibDef.h ├── crc32.h ├── dllmain.cpp ├── tpool.h ├── StrSafte.cpp ├── DbProxy.h ├── StrUtil.h ├── logger.h ├── ComLib.h ├── ComLib.def ├── LockBase.h ├── DbProxy.cpp ├── TransferEncoder.h ├── PrintFormater.cpp ├── crc32.c ├── tpool.cpp ├── SqliteOperator.cpp ├── StrUtil.cpp └── TransferEncoder.cpp ├── dbg ├── Script.h ├── main.cpp ├── symbol.h ├── CmdBase.h ├── DbgBase.h ├── Disasm.cpp ├── ProcDbg.h ├── Script.cpp ├── dbg.vcproj ├── minidump.h ├── symbol.cpp ├── BreakPoint.h ├── CmdBase.cpp ├── DbgCommon.cpp ├── DumpCmd.cpp ├── ProcCmd.cpp ├── ProcDbg.cpp ├── minidump.cpp ├── procmon.cpp ├── BreakPoint.cpp ├── ScriptRunner.h ├── include │ ├── 说明.txt │ └── changelog.txt ├── DumpDbgProxy.cpp ├── ProcDbgProxy.cpp ├── DescParser │ ├── DescCache.h │ ├── DescParser.h │ ├── DescCache.cpp │ ├── DescParser.cpp │ ├── DescPrinter.h │ └── DescPrinter.cpp ├── ScriptEngine │ ├── ScriptDef.h │ ├── ScriptHlpr.h │ ├── ScriptHlpr.cpp │ ├── ScriptParser.h │ ├── ScriptParser.cpp │ ├── ScriptExpression.cpp │ ├── ScriptExpression.h │ ├── ScriptAccessor.h │ └── ScriptAccessor.cpp ├── capstone │ ├── capstone_x64.lib │ ├── capstone_x86.lib │ ├── platform.h │ └── xcore.h ├── TitanEngine │ ├── TitanEngine.txt │ ├── TitanEngine_x64.lib │ └── TitanEngine_x86.lib ├── DbgCommon.h ├── MemoryBase.h ├── memory.h ├── DumpDbgProxy.h ├── UserContext.h ├── DbgBase.cpp ├── Disasm.h ├── DumpCmd.h ├── procmon.h ├── memory.cpp ├── MemoryBase.cpp ├── ProcDbgProxy.h ├── ProcCmd.h └── UserContext.cpp ├── libs ├── upx.exe ├── Dumper32.dll ├── Dumper64.dll └── SyntaxView.dll ├── VDebug ├── VDebug.rc ├── main.cpp ├── res │ ├── 111.bmp │ ├── 222.bmp │ ├── main.ico │ └── toolbar.bmp ├── VDebug.vcproj ├── view │ ├── CmdQueue.h │ ├── MainView.h │ ├── AboutDlg.cpp │ ├── ConfigView.h │ ├── FunView.cpp │ ├── MainView.cpp │ ├── OpenView.cpp │ ├── ProcView.cpp │ ├── SyntaxCfg.h │ ├── CmdShowView.cpp │ ├── ConfigView.cpp │ ├── StyleConfigMgr.h │ ├── StyleConfigMgr.cpp │ ├── FunSyntaxView.h │ ├── AboutDlg.h │ ├── FunSyntaxView.cpp │ ├── DialogBase.h │ ├── SyntaxDesc.cpp │ ├── FunView.h │ ├── CmdShowView.h │ ├── DialogBase.cpp │ ├── CmdQueue.cpp │ ├── SyntaxDesc.h │ ├── ViewBase.cpp │ ├── OpenView.h │ ├── ParserBase.cpp │ ├── ProcView.h │ ├── ViewBase.h │ └── SyntaxCfg.cpp ├── DbgCtrlService.cpp ├── SyntaxHlpr │ ├── SyntaxDef.h │ ├── SyntaxTextView.h │ ├── SyntaxTextView.cpp │ ├── include │ │ ├── Scintilla.h │ │ ├── BoostRegexSearch.h │ │ ├── ScintillaWidget.h │ │ └── ILexer.h │ ├── SyntaxEditView.h │ ├── SyntaxCache.h │ ├── export.h │ └── SyntaxCache.cpp ├── view.h ├── install │ ├── DbgInstall.h │ └── DbgInstall.cpp ├── DbgCtrlService.h └── resource.h ├── DbgCtrl ├── DbgCtrl.vcproj ├── DbgCtrlCom.cpp ├── DbgProtocol.h ├── DbgCtrlTool.cpp ├── DbgCtrl.def ├── DbgCtrlTool.h ├── dllmain.cpp ├── DbgCtrl.h ├── DbgClient.h ├── DbgService.h ├── DbgCtrlCom.h ├── DbgStat.h ├── DbgStat.cpp ├── DbgClient.cpp └── DbgService.cpp ├── runner ├── ServiceRunner.h ├── runner.vcproj ├── runner.h └── main.cpp ├── .gitignore ├── README.md └── VDebug.sln /Debug/x32/symsrv.yes: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Debug/x64/symsrv.yes: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Release/x32/symsrv.yes: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mq/mq.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/mq.h -------------------------------------------------------------------------------- /mq/mq.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/mq.cpp -------------------------------------------------------------------------------- /mq/mq.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/mq.rc -------------------------------------------------------------------------------- /res/1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/res/1.bmp -------------------------------------------------------------------------------- /res/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/res/2.bmp -------------------------------------------------------------------------------- /res/3.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/res/3.bmp -------------------------------------------------------------------------------- /ComLib/md5.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/md5.h -------------------------------------------------------------------------------- /dbg/Script.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/Script.h -------------------------------------------------------------------------------- /dbg/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/main.cpp -------------------------------------------------------------------------------- /dbg/symbol.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/symbol.h -------------------------------------------------------------------------------- /libs/upx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/libs/upx.exe -------------------------------------------------------------------------------- /mq/mq.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/mq.vcproj -------------------------------------------------------------------------------- /ComLib/deelx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/deelx.h -------------------------------------------------------------------------------- /dbg/CmdBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/CmdBase.h -------------------------------------------------------------------------------- /dbg/DbgBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DbgBase.h -------------------------------------------------------------------------------- /dbg/Disasm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/Disasm.cpp -------------------------------------------------------------------------------- /dbg/ProcDbg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ProcDbg.h -------------------------------------------------------------------------------- /dbg/Script.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/Script.cpp -------------------------------------------------------------------------------- /dbg/dbg.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/dbg.vcproj -------------------------------------------------------------------------------- /dbg/minidump.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/minidump.h -------------------------------------------------------------------------------- /dbg/symbol.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/symbol.cpp -------------------------------------------------------------------------------- /mq/msgserv.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/msgserv.cpp -------------------------------------------------------------------------------- /mq/protocol.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/protocol.h -------------------------------------------------------------------------------- /mq/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/resource.h -------------------------------------------------------------------------------- /ComLib/ComUtil.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/ComUtil.h -------------------------------------------------------------------------------- /ComLib/mstring.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/mstring.h -------------------------------------------------------------------------------- /ComLib/servhlpr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/servhlpr.h -------------------------------------------------------------------------------- /ComLib/winsize.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/winsize.h -------------------------------------------------------------------------------- /VDebug/VDebug.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/VDebug.rc -------------------------------------------------------------------------------- /VDebug/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/main.cpp -------------------------------------------------------------------------------- /dbg/BreakPoint.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/BreakPoint.h -------------------------------------------------------------------------------- /dbg/CmdBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/CmdBase.cpp -------------------------------------------------------------------------------- /dbg/DbgCommon.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DbgCommon.cpp -------------------------------------------------------------------------------- /dbg/DumpCmd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DumpCmd.cpp -------------------------------------------------------------------------------- /dbg/ProcCmd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ProcCmd.cpp -------------------------------------------------------------------------------- /dbg/ProcDbg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ProcDbg.cpp -------------------------------------------------------------------------------- /dbg/minidump.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/minidump.cpp -------------------------------------------------------------------------------- /dbg/procmon.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/procmon.cpp -------------------------------------------------------------------------------- /libs/Dumper32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/libs/Dumper32.dll -------------------------------------------------------------------------------- /libs/Dumper64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/libs/Dumper64.dll -------------------------------------------------------------------------------- /mq/ClientLogic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/ClientLogic.h -------------------------------------------------------------------------------- /mq/ServerLogic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/ServerLogic.h -------------------------------------------------------------------------------- /res/TBCreator.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/res/TBCreator.rar -------------------------------------------------------------------------------- /res/toolbar1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/res/toolbar1.bmp -------------------------------------------------------------------------------- /res/toolbar2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/res/toolbar2.bmp -------------------------------------------------------------------------------- /ComLib/ComUtil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/ComUtil.cpp -------------------------------------------------------------------------------- /ComLib/GlobalDef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/GlobalDef.h -------------------------------------------------------------------------------- /ComLib/mstring.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/mstring.cpp -------------------------------------------------------------------------------- /ComLib/servhlpr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/servhlpr.cpp -------------------------------------------------------------------------------- /ComLib/winsize.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/winsize.cpp -------------------------------------------------------------------------------- /VDebug/res/111.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/res/111.bmp -------------------------------------------------------------------------------- /VDebug/res/222.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/res/222.bmp -------------------------------------------------------------------------------- /VDebug/res/main.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/res/main.ico -------------------------------------------------------------------------------- /dbg/BreakPoint.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/BreakPoint.cpp -------------------------------------------------------------------------------- /dbg/ScriptRunner.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptRunner.h -------------------------------------------------------------------------------- /dbg/include/说明.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/include/说明.txt -------------------------------------------------------------------------------- /libs/SyntaxView.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/libs/SyntaxView.dll -------------------------------------------------------------------------------- /mq/ClientLogic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/ClientLogic.cpp -------------------------------------------------------------------------------- /mq/ServerLogic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/mq/ServerLogic.cpp -------------------------------------------------------------------------------- /ComLib/ComLib.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/ComLib.vcproj -------------------------------------------------------------------------------- /ComLib/PrintFormater.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/PrintFormater.h -------------------------------------------------------------------------------- /DbgCtrl/DbgCtrl.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/DbgCtrl/DbgCtrl.vcproj -------------------------------------------------------------------------------- /DbgCtrl/DbgCtrlCom.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/DbgCtrl/DbgCtrlCom.cpp -------------------------------------------------------------------------------- /DbgCtrl/DbgProtocol.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/DbgCtrl/DbgProtocol.h -------------------------------------------------------------------------------- /Debug/x32/capstone.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x32/capstone.dll -------------------------------------------------------------------------------- /Debug/x32/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x32/dbghelp.dll -------------------------------------------------------------------------------- /Debug/x32/srcsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x32/srcsrv.dll -------------------------------------------------------------------------------- /Debug/x32/symchk.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x32/symchk.exe -------------------------------------------------------------------------------- /Debug/x32/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x32/symsrv.dll -------------------------------------------------------------------------------- /Debug/x64/capstone.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x64/capstone.dll -------------------------------------------------------------------------------- /Debug/x64/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x64/dbghelp.dll -------------------------------------------------------------------------------- /Debug/x64/srcsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x64/srcsrv.dll -------------------------------------------------------------------------------- /Debug/x64/symchk.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x64/symchk.exe -------------------------------------------------------------------------------- /Debug/x64/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x64/symsrv.dll -------------------------------------------------------------------------------- /Release/x32/srcsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Release/x32/srcsrv.dll -------------------------------------------------------------------------------- /Release/x32/symchk.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Release/x32/symchk.exe -------------------------------------------------------------------------------- /Release/x32/symsrv.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Release/x32/symsrv.dll -------------------------------------------------------------------------------- /VDebug/VDebug.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/VDebug.vcproj -------------------------------------------------------------------------------- /VDebug/res/toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/res/toolbar.bmp -------------------------------------------------------------------------------- /VDebug/view/CmdQueue.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/CmdQueue.h -------------------------------------------------------------------------------- /VDebug/view/MainView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/MainView.h -------------------------------------------------------------------------------- /dbg/DumpDbgProxy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DumpDbgProxy.cpp -------------------------------------------------------------------------------- /dbg/ProcDbgProxy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ProcDbgProxy.cpp -------------------------------------------------------------------------------- /runner/ServiceRunner.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/runner/ServiceRunner.h -------------------------------------------------------------------------------- /runner/runner.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/runner/runner.vcproj -------------------------------------------------------------------------------- /ComLib/SqliteOperator.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/SqliteOperator.h -------------------------------------------------------------------------------- /DbgCtrl/DbgCtrlTool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/DbgCtrl/DbgCtrlTool.cpp -------------------------------------------------------------------------------- /Release/x32/capstone.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Release/x32/capstone.dll -------------------------------------------------------------------------------- /Release/x32/dbghelp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Release/x32/dbghelp.dll -------------------------------------------------------------------------------- /VDebug/view/AboutDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/AboutDlg.cpp -------------------------------------------------------------------------------- /VDebug/view/ConfigView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/ConfigView.h -------------------------------------------------------------------------------- /VDebug/view/FunView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/FunView.cpp -------------------------------------------------------------------------------- /VDebug/view/MainView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/MainView.cpp -------------------------------------------------------------------------------- /VDebug/view/OpenView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/OpenView.cpp -------------------------------------------------------------------------------- /VDebug/view/ProcView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/ProcView.cpp -------------------------------------------------------------------------------- /VDebug/view/SyntaxCfg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/SyntaxCfg.h -------------------------------------------------------------------------------- /ComLib/json/json_value.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/json/json_value.cpp -------------------------------------------------------------------------------- /ComLib/json/json_writer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/ComLib/json/json_writer.cpp -------------------------------------------------------------------------------- /Debug/x32/TitanEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x32/TitanEngine.dll -------------------------------------------------------------------------------- /Debug/x64/TitanEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Debug/x64/TitanEngine.dll -------------------------------------------------------------------------------- /Release/x32/TitanEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/Release/x32/TitanEngine.dll -------------------------------------------------------------------------------- /VDebug/DbgCtrlService.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/DbgCtrlService.cpp -------------------------------------------------------------------------------- /VDebug/view/CmdShowView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/CmdShowView.cpp -------------------------------------------------------------------------------- /VDebug/view/ConfigView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/ConfigView.cpp -------------------------------------------------------------------------------- /dbg/DescParser/DescCache.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DescParser/DescCache.h -------------------------------------------------------------------------------- /dbg/DescParser/DescParser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DescParser/DescParser.h -------------------------------------------------------------------------------- /dbg/include/changelog.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/include/changelog.txt -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/SyntaxDef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/SyntaxHlpr/SyntaxDef.h -------------------------------------------------------------------------------- /VDebug/view/StyleConfigMgr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/StyleConfigMgr.h -------------------------------------------------------------------------------- /dbg/DescParser/DescCache.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DescParser/DescCache.cpp -------------------------------------------------------------------------------- /dbg/DescParser/DescParser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DescParser/DescParser.cpp -------------------------------------------------------------------------------- /dbg/DescParser/DescPrinter.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DescParser/DescPrinter.h -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptDef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptEngine/ScriptDef.h -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptHlpr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptEngine/ScriptHlpr.h -------------------------------------------------------------------------------- /dbg/capstone/capstone_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/capstone/capstone_x64.lib -------------------------------------------------------------------------------- /dbg/capstone/capstone_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/capstone/capstone_x86.lib -------------------------------------------------------------------------------- /runner/runner.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_RUNNER_H_H_ 2 | #define RUNNER_RUNNER_H_H_ 3 | 4 | #endif //RUNNER_RUNNER_H_H_ -------------------------------------------------------------------------------- /VDebug/view/StyleConfigMgr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/view/StyleConfigMgr.cpp -------------------------------------------------------------------------------- /dbg/DescParser/DescPrinter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/DescParser/DescPrinter.cpp -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptHlpr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptEngine/ScriptHlpr.cpp -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptParser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptEngine/ScriptParser.h -------------------------------------------------------------------------------- /dbg/TitanEngine/TitanEngine.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/TitanEngine/TitanEngine.txt -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/SyntaxTextView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/SyntaxHlpr/SyntaxTextView.h -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptParser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptEngine/ScriptParser.cpp -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/SyntaxTextView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/SyntaxHlpr/SyntaxTextView.cpp -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/include/Scintilla.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/VDebug/SyntaxHlpr/include/Scintilla.h -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptExpression.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptEngine/ScriptExpression.cpp -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptExpression.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/ScriptEngine/ScriptExpression.h -------------------------------------------------------------------------------- /dbg/TitanEngine/TitanEngine_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/TitanEngine/TitanEngine_x64.lib -------------------------------------------------------------------------------- /dbg/TitanEngine/TitanEngine_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ExpLife0011/vdebug/HEAD/dbg/TitanEngine/TitanEngine_x86.lib -------------------------------------------------------------------------------- /DbgCtrl/DbgCtrl.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | MakeRequest 3 | ParserRequest 4 | MakeReply 5 | ParserReply 6 | 7 | MakeEvent 8 | ParserEvent 9 | -------------------------------------------------------------------------------- /VDebug/view.h: -------------------------------------------------------------------------------- 1 | #ifndef VIEW_VDEBUG_H_H_ 2 | #define VIEW_VDEBUG_H_H_ 3 | #include 4 | 5 | VOID ShowMainView(); 6 | #endif -------------------------------------------------------------------------------- /ComLib/StrSafe.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_SAFE_STR_H_H_ 2 | #define THREAD_SAFE_STR_H_H_ 3 | 4 | const char *__stdcall SafeStrCopyA(const char *); 5 | const wchar_t *__stdcall SafeStrCopyW(const wchar_t *); 6 | #endif -------------------------------------------------------------------------------- /ComLib/json/json.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_JSON 2 | #define _H_JSON 3 | 4 | #include "reader.h" 5 | #include "value.h" 6 | #include "writer.h" 7 | 8 | using namespace Json; 9 | 10 | #endif // #ifndef _H_JSON 11 | -------------------------------------------------------------------------------- /ComLib/LibDef.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBDEF_COMLIB_H_H_ 2 | #define LIBDEF_COMLIB_H_H_ 3 | 4 | #ifdef COMLIB_EXPORTS 5 | #define COMAPI _declspec(dllexport) 6 | #else 7 | #define COMAPI 8 | #endif 9 | #endif //LIBDEF_COMLIB_H_H_ -------------------------------------------------------------------------------- /DbgCtrl/DbgCtrlTool.h: -------------------------------------------------------------------------------- 1 | #ifndef DBGCTRLTOOL_DBGCTRL_H_H_ 2 | #define DBGCTRLTOOL_DBGCTRL_H_H_ 3 | #include 4 | 5 | unsigned short CalPortFormUnique(const std::string &unique); 6 | #endif //DBGCTRLTOOL_DBGCTRL_H_H_ -------------------------------------------------------------------------------- /mq/mq.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | MsgInitServ 3 | MsgInitClient 4 | MsgRegister 5 | MsgUnRegister 6 | MsgStrAlloc 7 | MsgStrCopy 8 | MsgStrFree 9 | MsgSend 10 | MsgSendForResult 11 | RundllFun 12 | -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/SyntaxEditView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | Syntax Edit Ctrl 10 | */ 11 | class SyntaxEditView { 12 | }; -------------------------------------------------------------------------------- /ComLib/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef _H_GDCRC32 2 | #define _H_GDCRC32 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | unsigned long __stdcall crc32(const char* buffer, int bufSize, unsigned long seed); 9 | #ifdef __cplusplus 10 | } 11 | #endif 12 | 13 | #endif // #ifndef _H_GDCRC32 14 | -------------------------------------------------------------------------------- /VDebug/view/FunSyntaxView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../SyntaxHlpr/SyntaxTextView.h" 4 | 5 | class CFunSyntaxView : public SyntaxTextView { 6 | public: 7 | CFunSyntaxView(); 8 | virtual ~CFunSyntaxView(); 9 | 10 | bool InitFunView(); 11 | private: 12 | }; -------------------------------------------------------------------------------- /DbgCtrl/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | HMODULE g_hThisMod = NULL; 4 | 5 | BOOL WINAPI DllMain(HMODULE hThisModule, DWORD dwReason, LPVOID reserved) 6 | { 7 | if (DLL_PROCESS_ATTACH == dwReason) 8 | { 9 | g_hThisMod = hThisModule; 10 | DisableThreadLibraryCalls(hThisModule); 11 | } 12 | else if (DLL_PROCESS_DETACH == dwReason) 13 | { 14 | } 15 | return TRUE; 16 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /VDebug/install/DbgInstall.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../../ComLib/mstring.h" 4 | 5 | class CDbgInstall { 6 | public: 7 | static CDbgInstall *GetInst(); 8 | bool InitInstall(); 9 | std::mstring GetInstallDir() const; 10 | std::mstring GetSytleCfgPath() const; 11 | 12 | private: 13 | CDbgInstall(); 14 | virtual ~CDbgInstall(); 15 | 16 | private: 17 | std::mstring mInstallDir; 18 | }; -------------------------------------------------------------------------------- /VDebug/view/AboutDlg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "DialogBase.h" 4 | 5 | class CAboutDlg : public CDialogBase { 6 | public: 7 | CAboutDlg(); 8 | virtual ~CAboutDlg(); 9 | 10 | private: 11 | INT_PTR OnInitDialog(WPARAM wp, LPARAM lp); 12 | virtual INT_PTR MessageProc(UINT msg, WPARAM wp, LPARAM lp); 13 | 14 | private: 15 | HBITMAP mBmp1; 16 | HBITMAP mBmp2; 17 | HWND mLinkVdebug; 18 | HWND mLinkHomePage; 19 | }; -------------------------------------------------------------------------------- /runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ServiceRunner.h" 3 | 4 | int WINAPI WinMain(HINSTANCE m, HINSTANCE p, LPSTR cmd, int show) 5 | { 6 | OutputDebugStringA("runner:WinMain"); 7 | int count = 0; 8 | LPWSTR *args = CommandLineToArgvW(GetCommandLineW(), &count); 9 | 10 | if (count == 2 && 0 == lstrcmpiW(args[1], L"-service")) 11 | { 12 | ServiceRunner::GetInstance()->InitServiceRunner(); 13 | } 14 | LocalFree(args); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /VDebug/view/FunSyntaxView.cpp: -------------------------------------------------------------------------------- 1 | #include "FunSyntaxView.h" 2 | 3 | CFunSyntaxView::CFunSyntaxView() { 4 | } 5 | 6 | CFunSyntaxView::~CFunSyntaxView() { 7 | } 8 | 9 | bool CFunSyntaxView::InitFunView() { 10 | ShowMargin(false); 11 | SetCaretColour(RGB(255, 255, 255)); 12 | 13 | SetFont("Lucida Console"); 14 | SetCaretSize(1); 15 | 16 | SendMsg(SCI_STYLESETSIZE, STYLE_DEFAULT, 10); 17 | ShowVsScrollBar(true); 18 | ShowHsScrollBar(true); 19 | return true; 20 | } -------------------------------------------------------------------------------- /ComLib/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | HMODULE g_hThisMod = NULL; 4 | 5 | BOOL WINAPI DllMain(HMODULE hThisModule, DWORD dwReason, LPVOID reserved) 6 | { 7 | if (DLL_PROCESS_ATTACH == dwReason) 8 | { 9 | g_hThisMod = hThisModule; 10 | DisableThreadLibraryCalls(hThisModule); 11 | } 12 | else if (DLL_PROCESS_DETACH == dwReason) 13 | { 14 | } 15 | return TRUE; 16 | } 17 | 18 | VOID WINAPI RundllFun(HWND hwnd, HINSTANCE hinst, LPSTR cmd, int show) { 19 | } -------------------------------------------------------------------------------- /mq/dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | HMODULE g_hThisMod = NULL; 4 | 5 | BOOL WINAPI DllMain(HMODULE hThisModule, DWORD dwReason, LPVOID reserved) 6 | { 7 | if (DLL_PROCESS_ATTACH == dwReason) 8 | { 9 | g_hThisMod = hThisModule; 10 | DisableThreadLibraryCalls(hThisModule); 11 | } 12 | else if (DLL_PROCESS_DETACH == dwReason) 13 | { 14 | } 15 | return TRUE; 16 | } 17 | 18 | VOID WINAPI RundllFun(HWND hwnd, HINSTANCE hinst, LPSTR cmd, int show) { 19 | MessageBoxW(0, 0, 0, 0); 20 | } -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/include/BoostRegexSearch.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOSTREGEXSEARCH_H 2 | #define BOOSTREGEXSEARCH_H 3 | 4 | #define SCFIND_REGEXP_DOTMATCHESNL 0x10000000 5 | #define SCFIND_REGEXP_EMPTYMATCH_MASK 0xE0000000 6 | #define SCFIND_REGEXP_EMPTYMATCH_NONE 0x00000000 7 | #define SCFIND_REGEXP_EMPTYMATCH_NOTAFTERMATCH 0x20000000 8 | #define SCFIND_REGEXP_EMPTYMATCH_ALL 0x40000000 9 | #define SCFIND_REGEXP_EMPTYMATCH_ALLOWATSTART 0x80000000 10 | #define SCFIND_REGEXP_SKIPCRLFASONE 0x08000000 11 | 12 | #endif -------------------------------------------------------------------------------- /dbg/DbgCommon.h: -------------------------------------------------------------------------------- 1 | #ifndef DBGCOMMON_DBG_H_H_ 2 | #define DBGCOMMON_DBG_H_H_ 3 | #include 4 | #include 5 | 6 | class CDbgCommon { 7 | public: 8 | static std::mstring GetSystemStr(DWORD majver, DWORD minver, DWORD product); 9 | static std::mstring GetExceptionDesc(DWORD code); 10 | static std::mstring GetProcSymFromAddr(DWORD64 dwAddr, const std::mstring &dllName, DWORD64 moduleBase); 11 | static std::mstring GetSymFromAddr(DWORD64 dwAddr, const std::mstring &dllName, DWORD64 moduleBase); 12 | }; 13 | #endif //DBGCOMMON_DBG_H_H_ -------------------------------------------------------------------------------- /dbg/MemoryBase.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORYBASE_DBG_H_H_ 2 | #define MEMORYBASE_DBG_H_H_ 3 | #include 4 | #include 5 | 6 | class CMemoryBase { 7 | public: 8 | virtual bool MemoryReadSafe(DWORD64 dwAddr, char *szBuffer, DWORD dwBufferSize, IN OUT DWORD *pReadSize) const = 0; 9 | std::ustring MemoryReadStrUnicode(DWORD64 dwAddr, DWORD dwMaxSize = 1024) const; 10 | std::mstring MemoryReadStrGbk(DWORD64 dwAddr, DWORD dwMaxSize = 1024) const; 11 | std::mstring MemoryReadStrUtf8(DWORD64 dwAddr, DWORD dwMaxSize = 1024) const; 12 | }; 13 | #endif //MEMORYBASE_DBG_H_H_ -------------------------------------------------------------------------------- /dbg/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_VDEBUG_H_H_ 2 | #define MEMORY_VDEBUG_H_H_ 3 | #include 4 | #include 5 | #include "MemoryBase.h" 6 | 7 | using namespace std; 8 | 9 | class CMemoryProc : public CMemoryBase 10 | { 11 | public: 12 | CMemoryProc(HANDLE hProcess); 13 | virtual ~CMemoryProc(); 14 | virtual bool MemoryReadSafe(DWORD64 dwAddr, char *szBuffer, DWORD dwBufferSize, IN OUT DWORD *pReadSize) const; 15 | private: 16 | bool MemoryReadPageSafe(DWORD64 dwAddr, char *szBuffer, DWORD dwBufferSize, IN OUT SIZE_T *pReadSize) const; 17 | protected: 18 | HANDLE m_hProcess; 19 | }; 20 | 21 | #endif -------------------------------------------------------------------------------- /VDebug/view/DialogBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | class CDialogBase { 6 | public: 7 | CDialogBase(); 8 | virtual ~CDialogBase(); 9 | 10 | int DoModule(HWND parent, DWORD id); 11 | BOOL CreateDlg(HWND parent, DWORD id); 12 | protected: 13 | HWND GetHandle() const; 14 | HWND GetParent() const; 15 | virtual INT_PTR MessageProc(UINT msg, WPARAM wp, LPARAM lp); 16 | 17 | private: 18 | static INT_PTR CALLBACK DialogProc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp); 19 | 20 | protected: 21 | static std::map msPtrSet; 22 | HWND mHwnd; 23 | HWND mParent; 24 | }; -------------------------------------------------------------------------------- /ComLib/tpool.h: -------------------------------------------------------------------------------- 1 | //thread pool lougd 2018 11-26 2 | #ifndef TPOOL_DPMSG_H_H_ 3 | #define TPOOL_DPMSG_H_H_ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "ComUtil.h" 9 | 10 | using namespace std; 11 | 12 | class ThreadRunable { 13 | public: 14 | virtual ~ThreadRunable() {} 15 | virtual void run() = 0; 16 | }; 17 | 18 | class ThreadPoolBase { 19 | public: 20 | virtual ~ThreadPoolBase() {} 21 | virtual bool exec(ThreadRunable *runable) = 0; 22 | }; 23 | 24 | ThreadPoolBase * __stdcall GetThreadPool(int initCount, int maxCount); 25 | 26 | void __stdcall DestroyThreadPool(); 27 | #endif //TPOOL_DPMSG_H_H_ -------------------------------------------------------------------------------- /DbgCtrl/DbgCtrl.h: -------------------------------------------------------------------------------- 1 | #ifndef DBGCTRL_DBGCTRL_H_H_ 2 | #define DBGCTRL_DBGCTRL_H_H_ 3 | 4 | #if _WIN64 || WIN64 5 | #ifdef _DEBUG 6 | #pragma comment(lib, "../Debug/DbgCtrl64.lib") 7 | #else 8 | #pragma comment(lib, "../Release/DbgCtrl64.lib") 9 | #endif //_DEBUG 10 | #else 11 | #ifdef _DEBUG 12 | #pragma comment(lib, "../Debug/DbgCtrl32.lib") 13 | #else 14 | #pragma comment(lib, "../Release/DbgCtrl32.lib") 15 | #endif //_DEBUG 16 | #endif //_WIN64 17 | 18 | #include "DbgService.h" 19 | #include "DbgClient.h" 20 | #include "DbgCtrlCom.h" 21 | #include "DbgProtocol.h" 22 | #include "DbgStat.h" 23 | #endif //DBGCTRL_DBGCTRL_H_H_ -------------------------------------------------------------------------------- /DbgCtrl/DbgClient.h: -------------------------------------------------------------------------------- 1 | #ifndef DBGCLIENT_DBGCTRL_H_H_ 2 | #define DBGCLIENT_DBGCTRL_H_H_ 3 | #include 4 | #include "DbgCtrlCom.h" 5 | 6 | typedef CtrlReply (__stdcall *pfnDbgClientProc)(const CtrlRequest &request, void *param); 7 | 8 | class DbgCtrlApi DbgClientBase { 9 | public: 10 | virtual ~DbgClientBase() {}; 11 | virtual bool InitClient(DbggerType type, const mstring &unique) = 0; 12 | virtual HDbgCtrl RegisterCtrlHandler(const std::mstring &cmd, pfnDbgClientProc pfn, void *param) = 0; 13 | virtual bool ReportDbgEvent(const EventInfo &eventInfo) = 0; 14 | static DbgClientBase *__stdcall newInstance(); 15 | }; 16 | #endif //DBGCLIENT_DBGCTRL_H_H_ -------------------------------------------------------------------------------- /ComLib/StrSafte.cpp: -------------------------------------------------------------------------------- 1 | #include "StrSafe.h" 2 | #include "LockBase.h" 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | static CCriticalSectionLockable gs_lock; 9 | static map gs_cache1; 10 | static map gs_cache2; 11 | 12 | const char *__stdcall SafeStrCopyA(const char *str) { 13 | CScopedLocker lock(&gs_lock); 14 | string &sp = gs_cache1[GetCurrentThreadId()]; 15 | sp = str; 16 | return sp.c_str(); 17 | } 18 | 19 | const wchar_t *__stdcall SafeStrCopyW(const wchar_t *str) { 20 | CScopedLocker lock(&gs_lock); 21 | wstring &sp = gs_cache2[GetCurrentThreadId()]; 22 | sp = str; 23 | return sp.c_str(); 24 | } -------------------------------------------------------------------------------- /VDebug/view/SyntaxDesc.cpp: -------------------------------------------------------------------------------- 1 | #include "SyntaxDesc.h" 2 | 3 | SyntaxDesc::SyntaxDesc(const ustring &wstrContent, const SyntaxColourDesc &colour) 4 | { 5 | SyntaxColourNode node(wstrContent, 0, colour); 6 | vector v; 7 | v.push_back(node); 8 | m_vSyntaxDesc.push_back(v); 9 | m_vShowInfo.push_back(wstrContent); 10 | } 11 | 12 | SyntaxDesc::SyntaxDesc(const ustring &wstrContent) 13 | { 14 | /* 15 | SyntaxColourNode node(wstrContent, 0, COLOUR_MSG); 16 | vector v; 17 | v.push_back(node); 18 | m_vSyntaxDesc.push_back(v); 19 | m_vShowInfo.push_back(wstrContent); 20 | */ 21 | } 22 | 23 | SyntaxDesc::SyntaxDesc() 24 | {} 25 | -------------------------------------------------------------------------------- /ComLib/DbProxy.h: -------------------------------------------------------------------------------- 1 | #ifndef DBPROXY_STATIC_H_H_ 2 | #define DBPROXY_STATIC_H_H_ 3 | #include 4 | #include "SqliteOperator.h" 5 | #include "LibDef.h" 6 | 7 | class COMAPI DbProxy { 8 | private: 9 | DbProxy(); 10 | 11 | public: 12 | virtual ~DbProxy(); 13 | static DbProxy *GetInstance(); 14 | bool InitDbEnv(); 15 | SqliteResult SelectCfg(const std::mstring &sql); 16 | bool ExecCfg(const std::mstring &sql); 17 | SqliteResult SelectSymbol(const std::mstring &sql); 18 | bool ExecSymbol(const std::mstring &sql); 19 | 20 | private: 21 | std::mstring mCfgDbPath; 22 | std::mstring mSymbolDbPath; 23 | SqliteOperator mCfgOpt; 24 | SqliteOperator mSymbolOpt; 25 | }; 26 | #endif //DBPROXY_STATIC_H_H_ -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptAccessor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "ScriptDef.h" 5 | #include "../DbgBase.h" 6 | #include "../MemoryBase.h" 7 | 8 | using namespace std; 9 | 10 | class CScriptAccessor { 11 | public: 12 | static CScriptAccessor *GetInst(); 13 | void SetContext(CMemoryBase *reader, CDbgBase *dbgger); 14 | void UpdateContext(); 15 | bool GetInternalVarData(const mstring &var, char *data); 16 | bool GetPtrData(DWORD64 ptr, int iSize, char *data); 17 | 18 | private: 19 | CScriptAccessor(); 20 | virtual ~CScriptAccessor(); 21 | 22 | private: 23 | CMemoryBase *mMemoryReader; 24 | CDbgBase *mDbgger; 25 | TITAN_ENGINE_CONTEXT_t mContext; 26 | }; -------------------------------------------------------------------------------- /DbgCtrl/DbgService.h: -------------------------------------------------------------------------------- 1 | #ifndef DBGSERVICE_DBGCTRL_H_H_ 2 | #define DBGSERVICE_DBGCTRL_H_H_ 3 | #include 4 | #include "DbgCtrlCom.h" 5 | 6 | typedef void (__stdcall *pfnDbgEventProc)(const EventInfo &eventInfo, void *param); 7 | 8 | class DbgCtrlApi DbgServiceBase { 9 | public: 10 | virtual ~DbgServiceBase() {}; 11 | virtual bool InitDbgService(const std::mstring &unique) = 0; 12 | virtual CtrlReply DispatchCurDbgger(const CtrlRequest &request) = 0; 13 | virtual CtrlReply DispatchSpecDbgger(DbggerType type, const CtrlRequest &request) = 0; 14 | virtual HDbgCtrl RegisterDbgEvent(const std::mstring &dbgEvent, pfnDbgEventProc pfn, void *param) = 0; 15 | virtual bool SetActivity(DbggerType type) = 0; 16 | 17 | static DbgServiceBase *_stdcall GetInstance(); 18 | }; 19 | #endif //DBGSERVICE_DBGCTRL_H_H_ -------------------------------------------------------------------------------- /ComLib/StrUtil.h: -------------------------------------------------------------------------------- 1 | #ifndef STRUTIL_COMSTATIC_H_H_ 2 | #define STRUTIL_COMSTATIC_H_H_ 3 | #include 4 | #include 5 | #include "mstring.h" 6 | 7 | std::wstring COMAPI __stdcall FormatW(const wchar_t *format, ...); 8 | std::string COMAPI __stdcall FormatA(const char *fmt, ...); 9 | 10 | std::string COMAPI __stdcall AtoU(const std::string &); 11 | std::string COMAPI __stdcall UtoA(const std::string &); 12 | std::wstring COMAPI __stdcall AtoW(const std::string &); 13 | std::string COMAPI _stdcall WtoA(const std::wstring &); 14 | std::wstring COMAPI __stdcall UtoW(const std::string &); 15 | std::string COMAPI __stdcall WtoU(const std::wstring &); 16 | 17 | std::list COMAPI SplitStrA(const std::mstring &str, const std::mstring &split); 18 | std::list COMAPI SplitStrW(const std::ustring &str, const std::ustring &split); 19 | #endif //STRUTIL_COMSTATIC_H_H_ -------------------------------------------------------------------------------- /ComLib/json/forwards.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_FORWARDS_H_INCLUDED 2 | # define JSON_FORWARDS_H_INCLUDED 3 | 4 | # include "config.h" 5 | 6 | namespace Json { 7 | 8 | // writer.h 9 | class FastWriter; 10 | class StyledWriter; 11 | 12 | // reader.h 13 | class Reader; 14 | 15 | // features.h 16 | class Features; 17 | 18 | // value.h 19 | typedef int Int; 20 | typedef unsigned int UInt; 21 | class StaticString; 22 | class Path; 23 | class PathArgument; 24 | class Value; 25 | class ValueIteratorBase; 26 | class ValueIterator; 27 | class ValueConstIterator; 28 | #ifdef JSON_VALUE_USE_INTERNAL_MAP 29 | class ValueAllocator; 30 | class ValueMapAllocator; 31 | class ValueInternalLink; 32 | class ValueInternalArray; 33 | class ValueInternalMap; 34 | #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 35 | 36 | } // namespace Json 37 | 38 | 39 | #endif // JSON_FORWARDS_H_INCLUDED 40 | -------------------------------------------------------------------------------- /ComLib/logger.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGGER_COMLIB_H_H_ 2 | #define LOGGER_COMLIB_H_H_ 3 | #include "ComLib.h" 4 | 5 | class Logger { 6 | public: 7 | virtual void LoggerInit(const wchar_t *format, ...) = 0; 8 | virtual void LoggerPrint(const wchar_t *format, ...) = 0; 9 | virtual void LoggerInfo(const wchar_t *format, ...) = 0; 10 | virtual void LoggerWarn(const wchar_t *format, ...) = 0; 11 | virtual void LoggerErr(const wchar_t *format, ...) = 0; 12 | }; 13 | 14 | static void _LoggerCommon(int level, const char *file, int line, const wchar_t *format, ...) { 15 | } 16 | 17 | #define LOGGER_PRINT(f, ...) _LoggerCommon(0, __FILE__, __LINE__, f, ##__VA_ARGS__) 18 | #define LOGGER_INFO(f, ...) _LoggerCommon(1, __FILE__, __LINE__, f, ##__VA_ARGS__) 19 | #define LOGGER_WARN(f, ...) _LoggerCommon(2, __FILE__, __LINE__, f, ##__VA_ARGS__) 20 | #define LOGGER_ERROR(f, ...) _LoggerCommon(3, __FILE__, __LINE__, f, ##__VA_ARGS__) 21 | Logger *GetLogger(); 22 | #endif //LOGGER_COMLIB_H_H_ -------------------------------------------------------------------------------- /VDebug/install/DbgInstall.cpp: -------------------------------------------------------------------------------- 1 | #include "DbgInstall.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | CDbgInstall *CDbgInstall::GetInst() { 7 | static CDbgInstall *sPtr = NULL; 8 | 9 | if (NULL == sPtr) 10 | { 11 | sPtr = new CDbgInstall(); 12 | } 13 | return sPtr; 14 | } 15 | 16 | CDbgInstall::CDbgInstall() { 17 | } 18 | 19 | CDbgInstall::~CDbgInstall() { 20 | } 21 | 22 | bool CDbgInstall::InitInstall() { 23 | char buff[512]; 24 | #ifdef _DEBUG 25 | GetModuleFileNameA(NULL, buff, sizeof(buff)); 26 | PathAppendA(buff, ".."); 27 | #else 28 | SHGetSpecialFolderPathW(NULL, buff, CSIDL_PROGRAM_FILES, TRUE); 29 | PathAppendA("vdebug"); 30 | #endif 31 | mInstallDir = buff; 32 | return true; 33 | } 34 | 35 | mstring CDbgInstall::GetInstallDir() const { 36 | return mInstallDir; 37 | } 38 | 39 | mstring CDbgInstall::GetSytleCfgPath() const { 40 | mstring path(mInstallDir); 41 | 42 | return path.path_append("StyleCfg.json"); 43 | } -------------------------------------------------------------------------------- /VDebug/view/FunView.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNVIEW_VDEBUG_H_H_ 2 | #define FUNVIEW_VDEBUG_H_H_ 3 | #include 4 | #include "ViewBase.h" 5 | #include "FunSyntaxView.h" 6 | 7 | class CFunctionView : public CWindowBase { 8 | public: 9 | CFunctionView(); 10 | virtual ~CFunctionView(); 11 | 12 | void ShowFunView(HWND parent); 13 | void SetStatText(const std::mstring &text); 14 | void AppendStatText(const std::mstring &text); 15 | void NotifyFunCover(); 16 | void CloseFunView(); 17 | private: 18 | void UsingCppStyle(); 19 | int OnInitDlg(HWND hwnd, WPARAM wp, LPARAM lp); 20 | int OnCommand(HWND hwnd, WPARAM wp, LPARAM lp); 21 | 22 | private: 23 | virtual LRESULT OnWindowMsg(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp); 24 | 25 | private: 26 | HWND mParent; 27 | CFunSyntaxView mEditView; 28 | CFunSyntaxView mStatView; 29 | HWND mComModule; 30 | HWND mBtnCheck; 31 | HWND mBtnOk; 32 | HWND mBtnCancel; 33 | }; 34 | #endif //FUNVIEW_VDEBUG_H_H_ -------------------------------------------------------------------------------- /ComLib/ComLib.h: -------------------------------------------------------------------------------- 1 | #ifndef COMLIB_COMLIB_H_H_ 2 | #define COMLIB_COMLIB_H_H_ 3 | #include "json/json.h" 4 | #include "ComUtil.h" 5 | #include "tpool.h" 6 | #include "StrSafe.h" 7 | #include "LockBase.h" 8 | #include "logger.h" 9 | #include "crc32.h" 10 | #include "winsize.h" 11 | #include "sqlite3.h" 12 | #include "SqliteOperator.h" 13 | #include "DbProxy.h" 14 | #include "TransferEncoder.h" 15 | #include "servhlpr.h" 16 | #include "mstring.h" 17 | #include "GlobalDef.h" 18 | #include "PrintFormater.h" 19 | 20 | #ifndef COMLIB_EXPORTS 21 | #if _WIN64 || WIN64 22 | #ifdef _DEBUG 23 | #pragma comment(lib, "../Debug/ComLib64.lib") 24 | #else 25 | #pragma comment(lib, "../Release/ComLib64.lib") 26 | #endif //_DEBUG 27 | #else 28 | #ifdef _DEBUG 29 | #pragma comment(lib, "../Debug/ComLib32.lib") 30 | #else 31 | #pragma comment(lib, "../Release/ComLib32.lib") 32 | #endif //_DEBUG 33 | #endif //_WIN64 34 | #endif //COMLIB_EXPORTS 35 | 36 | #define TCP_PORT_MQ 6011 37 | #endif //COMLIB_COMLIB_H_H_ -------------------------------------------------------------------------------- /dbg/DumpDbgProxy.h: -------------------------------------------------------------------------------- 1 | #ifndef PROC_DBG_PROXY_DBG_H_H_ 2 | #define PROC_DBG_PROXY_DBG_H_H_ 3 | #include 4 | #include 5 | #include "DumpCmd.h" 6 | #include "minidump.h" 7 | 8 | class DumpDbgProxy { 9 | private: 10 | DumpDbgProxy(); 11 | public: 12 | static DumpDbgProxy *GetInstance(); 13 | bool InitDumpDbgProxy(const char *unique); 14 | virtual ~DumpDbgProxy(); 15 | 16 | private: 17 | //Dbg Ctrl 18 | static CtrlReply __stdcall OpenDump(const CtrlRequest &request, void *param); 19 | static CtrlReply __stdcall DumpProc(const CtrlRequest &request, void *param); 20 | static CtrlReply __stdcall RunCmd(const CtrlRequest &request, void *param); 21 | 22 | std::mstring GetSystemStr(const DumpSystemInfo &system) const; 23 | std::mstring GetExceptionDesc(const DumpException &exception) const; 24 | private: 25 | bool mInit; 26 | CMiniDumpHlpr *mDumpHlpr; 27 | CDumpCmd *mCmdRunner; 28 | DbgClientBase *mDumpClient; 29 | bool mx64; 30 | }; 31 | #endif //PROC_DBG_PROXY_DBG_H_H_ -------------------------------------------------------------------------------- /mq/msgserv.h: -------------------------------------------------------------------------------- 1 | #ifndef MSGSERV_DPMSG_H_H_ 2 | #define MSGSERV_DPMSG_H_H_ 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | class CMsgClient; 11 | 12 | class ServEvent { 13 | public: 14 | virtual void OnServAccept(SOCKET client) = 0; 15 | virtual void OnServRecvData(SOCKET client, const string &strRecved, string &strResp) = 0; 16 | virtual void OnServSocketErr(SOCKET client) = 0; 17 | virtual void OnServSocketClose(SOCKET client) = 0; 18 | }; 19 | 20 | class CMsgServ { 21 | public: 22 | CMsgServ(); 23 | bool InitServ(unsigned short uLocalPort, ServEvent *pListener); 24 | void Close(); 25 | 26 | private: 27 | bool SetKeepAlive(); 28 | bool Bind(const string &strIp, unsigned short uPort, int iTimeOut); 29 | static DWORD WINAPI ServThread(LPVOID pParam); 30 | 31 | private: 32 | ServEvent *m_pListener; 33 | bool m_bInit; 34 | bool m_bStop; 35 | HANDLE m_hServThread; 36 | SOCKET m_servSocket; 37 | unsigned short m_uLocalPort; 38 | vector m_clientSet; 39 | }; 40 | #endif -------------------------------------------------------------------------------- /mq/msgclient.h: -------------------------------------------------------------------------------- 1 | #ifndef MSGCLIENT_DPMSG_H_H_ 2 | #define MSGCLIENT_DPMSG_H_H_ 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | class CMsgClient; 10 | 11 | class ClientEvent { 12 | public: 13 | virtual void OnClientConnect(CMsgClient &client) {} 14 | virtual void OnClientRecvData(CMsgClient &client, const string &strRecved, string &strResp) = 0; 15 | virtual void OnClientSocketErr(CMsgClient &client) = 0; 16 | }; 17 | 18 | class CMsgClient { 19 | public: 20 | CMsgClient(); 21 | bool InitClient(const string &strIp, unsigned short uPort, ClientEvent *pListener, int iTimeOut); 22 | bool Send(const string &strMsg) const; 23 | void Close(); 24 | 25 | private: 26 | bool TestConnect(); 27 | bool Connect(const string &strIp, unsigned short uPort, int iTimeOut); 28 | static DWORD WINAPI RecvThread(LPVOID pParam); 29 | 30 | private: 31 | ClientEvent *m_pListener; 32 | bool m_bInit; 33 | bool m_bStop; 34 | bool m_bTestConnent; 35 | HANDLE m_hRecvThread; 36 | SOCKET m_clientSock; 37 | string m_strSerIp; 38 | unsigned short m_uServPort; 39 | }; 40 | #endif -------------------------------------------------------------------------------- /dbg/UserContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | typedef DWORD HUserCtx; 10 | typedef void (WINAPI *pfnUserNotifyProc)(LPVOID pParam); 11 | 12 | class CUserContextMgr : public CCriticalSectionLockable { 13 | struct UserContextInfo 14 | { 15 | HANDLE mNotifyEvent; 16 | pfnUserNotifyProc mPfnCallback; 17 | LPVOID mParam; 18 | 19 | UserContextInfo() : mParam(NULL), mPfnCallback(NULL) 20 | { 21 | mNotifyEvent = NULL; 22 | } 23 | }; 24 | 25 | private: 26 | CUserContextMgr(); 27 | virtual ~CUserContextMgr(); 28 | 29 | public: 30 | static CUserContextMgr *GetInst(); 31 | 32 | HUserCtx GetUserCtx(pfnUserNotifyProc pfn = NULL, LPVOID p = NULL); 33 | void SetUserCtx(HUserCtx); 34 | void Close(HUserCtx); 35 | void WaitNotify(HUserCtx ctx, DWORD timeOut = -1); 36 | 37 | private: 38 | void InitCtxMgr(); 39 | bool GetInfoByIndex(HUserCtx ctx, UserContextInfo &info); 40 | bool DeleteByIndex(HUserCtx ctx); 41 | 42 | private: 43 | DWORD mSerial; 44 | map mCtxMap; 45 | }; -------------------------------------------------------------------------------- /dbg/DbgBase.cpp: -------------------------------------------------------------------------------- 1 | #include "DbgBase.h" 2 | #include 3 | 4 | bool CDbgBase::IsRegister(const ustring &wstr) const 5 | { 6 | static set *s_ptr = NULL; 7 | if (!s_ptr) 8 | { 9 | s_ptr = new set(); 10 | //x86 11 | s_ptr->insert(L"eax"), s_ptr->insert(L"ebx"); 12 | s_ptr->insert(L"ecx"), s_ptr->insert(L"edx"); 13 | s_ptr->insert(L"esi"), s_ptr->insert(L"edi"); 14 | s_ptr->insert(L"esp"), s_ptr->insert(L"ebp"); 15 | //x64 16 | s_ptr->insert(L"rax"), s_ptr->insert(L"rbx"); 17 | s_ptr->insert(L"rcx"), s_ptr->insert(L"rdx"); 18 | s_ptr->insert(L"rsi"), s_ptr->insert(L"rdi"); 19 | s_ptr->insert(L"r8"), s_ptr->insert(L"r9"); 20 | s_ptr->insert(L"r10"), s_ptr->insert(L"r11"); 21 | s_ptr->insert(L"r12"), s_ptr->insert(L"r13"); 22 | s_ptr->insert(L"r14"), s_ptr->insert(L"r15"); 23 | 24 | s_ptr->insert(L"cs"), s_ptr->insert(L"ss"); 25 | s_ptr->insert(L"ds"), s_ptr->insert(L"es"); 26 | s_ptr->insert(L"fs"), s_ptr->insert(L"gs"); 27 | } 28 | ustring wstrLower(wstr); 29 | wstrLower.trim(); 30 | wstrLower.makelower(); 31 | return (s_ptr->end() != s_ptr->find(wstrLower)); 32 | } -------------------------------------------------------------------------------- /dbg/Disasm.h: -------------------------------------------------------------------------------- 1 | #ifndef DISASM_VDEBUG_H_H_ 2 | #define DISASM_VDEBUG_H_H_ 3 | #include 4 | #include 5 | #include "capstone/capstone.h" 6 | #include 7 | 8 | using namespace std; 9 | 10 | struct DisasmInfo 11 | { 12 | mstring mAddrStr; 13 | DWORD64 mAddr; 14 | mstring mOpt; 15 | mstring mContent; 16 | mstring mByteCode; 17 | int mByteCount; 18 | BYTE mByteData[16]; 19 | 20 | DisasmInfo() 21 | { 22 | mAddr = 0; 23 | mByteCount = 0; 24 | ZeroMemory(mByteData, sizeof(mByteData)); 25 | } 26 | }; 27 | 28 | typedef BOOL (WINAPI *pfnDisasmProc)(const cs_insn *pAsmInfo, LPVOID pParam); 29 | 30 | class CDisasmParser 31 | { 32 | public: 33 | CDisasmParser(HANDLE hProcess); 34 | virtual ~CDisasmParser(); 35 | 36 | bool DisasmUntilReturn(DWORD64 dwAddr, vector &vInfo); 37 | bool DisasmWithSize(DWORD64 dwAddr, DWORD dwMaxSize, vector &vInfo); 38 | 39 | protected: 40 | bool DisasmInternal(DWORD64 dwAddr, pfnDisasmProc pfn, LPVOID pParam); 41 | static BOOL WINAPI DisasmCallback(const cs_insn *pAsmInfo, LPVOID pParam); 42 | 43 | protected: 44 | HANDLE m_hProcess; 45 | BOOL m_bx64; 46 | }; 47 | 48 | #endif -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/SyntaxCache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "SyntaxTextView.h" 8 | #include "export.h" 9 | 10 | class CSyntaxCache : public SyntaxTextView { 11 | public: 12 | CSyntaxCache(); 13 | virtual ~CSyntaxCache(); 14 | 15 | bool InitCache(int interval); 16 | void PushToCache(const std::string &label, const std::string &content); 17 | 18 | //clear all cache 19 | void ClearCache(); 20 | private: 21 | void Lock(); 22 | void UnLock(); 23 | static void CALLBACK TimerCache(HWND hwnd, 24 | UINT msg, 25 | UINT_PTR id, 26 | DWORD time 27 | ); 28 | 29 | struct DataCacheDesc { 30 | std::string mLabel; 31 | void *mParam; 32 | size_t mStartPos; 33 | size_t mLength; 34 | 35 | DataCacheDesc() { 36 | mStartPos = 0; 37 | mLength = 0; 38 | mParam = NULL; 39 | } 40 | }; 41 | private: 42 | int mInterval; 43 | //cache desc 44 | std::list mCacheDesc; 45 | //cache content 46 | std::string mCacheContent; 47 | //cache locker 48 | CRITICAL_SECTION mCacheLocker; 49 | static std::map msTimerCache; 50 | }; 51 | -------------------------------------------------------------------------------- /VDebug/view/CmdShowView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../SyntaxHlpr/SyntaxCache.h" 4 | #include "StyleConfigMgr.h" 5 | 6 | class CCmdShowView : public CSyntaxCache { 7 | public: 8 | CCmdShowView(); 9 | virtual ~CCmdShowView(); 10 | 11 | bool InitShowView(); 12 | bool LoadUserCfg(const CStyleConfig &cfg); 13 | private: 14 | static void __stdcall CallStackParser( 15 | int initStyle, 16 | unsigned int startPos, 17 | const char *ptr, 18 | int length, 19 | StyleContextBase *s, 20 | void *param 21 | ); 22 | static void __stdcall ModuleLoadedParser( 23 | int initStyle, 24 | unsigned int startPos, 25 | const char *ptr, 26 | int length, 27 | StyleContextBase *s, 28 | void *param 29 | ); 30 | static void __stdcall SendDefaultParser( 31 | int initStyle, 32 | unsigned int startPos, 33 | const char *ptr, 34 | int length, 35 | StyleContextBase *s, 36 | void *param 37 | ); 38 | static void __stdcall RecvDefaultParser( 39 | int initStyle, 40 | unsigned int startPos, 41 | const char *ptr, 42 | int length, 43 | StyleContextBase *s, 44 | void *param 45 | ); 46 | }; -------------------------------------------------------------------------------- /dbg/DumpCmd.h: -------------------------------------------------------------------------------- 1 | #ifndef DUMP_CMD_DBG_H_H_ 2 | #define DUMP_CMD_DBG_H_H_ 3 | #include 4 | #include 5 | #include "CmdBase.h" 6 | 7 | class CDumpCmd : public CCmdBase { 8 | private: 9 | CDumpCmd(); 10 | public: 11 | static CDumpCmd *GetInst(); 12 | virtual ~CDumpCmd(); 13 | void InitProcCmd(); 14 | virtual CtrlReply OnCommand(const std::mstring &cmd, const std::mstring ¶m, HUserCtx ctx); 15 | 16 | private: 17 | CtrlReply OnCmdDisass(const std::mstring &cmd, HUserCtx ctx); 18 | CtrlReply OnCmdUb(const std::mstring &cmd, HUserCtx ctx); 19 | CtrlReply OnCmdUf(const std::mstring &cmd, HUserCtx ctx); 20 | CtrlReply OnCmdKv(const std::mstring &cmd, HUserCtx ctx); 21 | CtrlReply OnCmdDb(const std::mstring &cmd, HUserCtx ctx); 22 | CtrlReply OnCmdDd(const std::mstring &cmd, HUserCtx ctx); 23 | CtrlReply OnCmdDu(const std::mstring &cmd, HUserCtx ctx); 24 | CtrlReply OnCmdDa(const std::mstring &cmd, HUserCtx ctx); 25 | CtrlReply OnCmdReg(const std::mstring &cmd, HUserCtx ctx); 26 | CtrlReply OnCmdTs(const std::mstring &cmd, HUserCtx ctx); 27 | CtrlReply OnCmdTc(const std::mstring &cmd, HUserCtx ctx); 28 | CtrlReply OnCmdLm(const std::mstring &cmd, HUserCtx ctx); 29 | CtrlReply OnCmdHelp(const std::mstring ¶m, HUserCtx ctx); 30 | }; 31 | #endif //DUMP_CMD_DBG_H_H_ -------------------------------------------------------------------------------- /ComLib/ComLib.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | 3 | GetThreadPool 4 | DestroyThreadPool 5 | 6 | SafeStrCopyA 7 | SafeStrCopyW 8 | 9 | MappingFileA 10 | CloseFileMapping 11 | 12 | crc32 13 | ErrMessage 14 | PrintDbgInternal 15 | GetPeVersionW 16 | GetPeVersionA 17 | GetPeDescStrA 18 | CentreWindow 19 | ShlParseShortcutsW 20 | IsPeFileA 21 | IsSameFileA 22 | IsSameFileW 23 | RevertWow64Red 24 | IterateProcW 25 | DisableWow64Red 26 | GetColourFromStr 27 | GetProcessCommandLineA 28 | GetProcessCommandLineW 29 | RundllFun 30 | 31 | SetCtlsCoord 32 | SetWindowRange 33 | 34 | RegGetDWORDFromRegA 35 | RegGetDWORDFromRegW 36 | RegSetDWORDValueA 37 | RegSetDWORDValueW 38 | RegSetStrValueW 39 | RegSetStrValueA 40 | RegEnumValuesA 41 | RegEnumValuesW 42 | RegGetStrValueExW 43 | RegGetStrValueExA 44 | 45 | CreateLowsdEvent 46 | RunInSession 47 | 48 | InstallLocalServiceW 49 | InstallLocalServiceA 50 | ServStartW 51 | ServStartA 52 | ServStopW 53 | ServStopA 54 | StartLocalServiceW 55 | StartLocalServiceA 56 | StopLocalServiceW 57 | StopLocalServiceA 58 | RemoveLocalServiceW 59 | RemoveLocalServiceA 60 | ReportLocalServStatus 61 | 62 | GetThreadPool 63 | DestroyThreadPool 64 | 65 | GetStrFormJson 66 | GetIntFromJson 67 | GetWindowStrW 68 | GetWindowStrA 69 | 70 | sqlite3_open 71 | sqlite3_open16 72 | sqlite3_exec 73 | sqlite3_close 74 | 75 | SetListColumnAutoSet 76 | 77 | ExecProcessA 78 | ExecProcessW 79 | 80 | GetWindowStr -------------------------------------------------------------------------------- /VDebug/view/DialogBase.cpp: -------------------------------------------------------------------------------- 1 | #include "DialogBase.h" 2 | 3 | using namespace std; 4 | 5 | map CDialogBase::msPtrSet; 6 | 7 | CDialogBase::CDialogBase() { 8 | } 9 | 10 | CDialogBase::~CDialogBase() { 11 | } 12 | 13 | int CDialogBase::DoModule(HWND parent, DWORD id) { 14 | mParent = parent; 15 | return DialogBoxParamA(NULL, MAKEINTRESOURCEA(id), parent, DialogProc, (LPARAM)this); 16 | } 17 | 18 | BOOL CDialogBase::CreateDlg(HWND parent, DWORD id) { 19 | mParent = parent; 20 | mHwnd = CreateDialogParamA(NULL, MAKEINTRESOURCEA(id), parent, DialogProc, (LPARAM)this); 21 | return (TRUE == IsWindow(mHwnd)); 22 | } 23 | 24 | HWND CDialogBase::GetHandle() const { 25 | return mHwnd; 26 | } 27 | 28 | INT_PTR CDialogBase::MessageProc(UINT msg, WPARAM wp, LPARAM lp) { 29 | return 0; 30 | } 31 | 32 | INT_PTR CDialogBase::DialogProc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp) { 33 | if (msg == WM_INITDIALOG) 34 | { 35 | CDialogBase *ptr = (CDialogBase *)lp; 36 | msPtrSet[hdlg] = ptr; 37 | ptr->mHwnd = hdlg; 38 | } 39 | 40 | map::iterator it = msPtrSet.find(hdlg); 41 | if (it == msPtrSet.end()) 42 | { 43 | return 0; 44 | } 45 | 46 | INT_PTR result = it->second->MessageProc(msg, wp, lp); 47 | if (msg == WM_DESTROY) 48 | { 49 | msPtrSet.erase(hdlg); 50 | } 51 | return result; 52 | } -------------------------------------------------------------------------------- /ComLib/json/features.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPTL_JSON_FEATURES_H_INCLUDED 2 | # define CPPTL_JSON_FEATURES_H_INCLUDED 3 | 4 | # include "forwards.h" 5 | 6 | namespace Json { 7 | 8 | /** \brief Configuration passed to reader and writer. 9 | * This configuration object can be used to force the Reader or Writer 10 | * to behave in a standard conforming way. 11 | */ 12 | class JSON_API Features 13 | { 14 | public: 15 | /** \brief A configuration that allows all features and assumes all strings are UTF-8. 16 | * - C & C++ comments are allowed 17 | * - Root object can be any JSON value 18 | * - Assumes Value strings are encoded in UTF-8 19 | */ 20 | static Features all(); 21 | 22 | /** \brief A configuration that is strictly compatible with the JSON specification. 23 | * - Comments are forbidden. 24 | * - Root object must be either an array or an object value. 25 | * - Assumes Value strings are encoded in UTF-8 26 | */ 27 | static Features strictMode(); 28 | 29 | /** \brief Initialize the configuration like JsonConfig::allFeatures; 30 | */ 31 | Features(); 32 | 33 | /// \c true if comments are allowed. Default: \c true. 34 | bool allowComments_; 35 | 36 | /// \c true if root must be either an array or an object value. Default: \c false. 37 | bool strictRoot_; 38 | }; 39 | 40 | } // namespace Json 41 | 42 | #endif // CPPTL_JSON_FEATURES_H_INCLUDED 43 | -------------------------------------------------------------------------------- /DbgCtrl/DbgCtrlCom.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_DBGCTRL_H_H_ 2 | #define COMMON_DBGCTRL_H_H_ 3 | #include 4 | 5 | enum DbggerType { 6 | em_dbg_proc86, 7 | em_dbg_proc64, 8 | em_dbg_dump86, 9 | em_dbg_dump64 10 | }; 11 | 12 | enum DbggerStatus 13 | { 14 | em_dbg_status_init, 15 | em_dbg_status_busy, 16 | em_dbg_status_free 17 | }; 18 | 19 | typedef long HDbgCtrl; 20 | 21 | #ifndef DBGCTRL_EXPORTS 22 | #define DbgCtrlApi _declspec(dllimport) 23 | #else 24 | #define DbgCtrlApi _declspec(dllexport) 25 | #endif 26 | 27 | #define REPLY_STAT_CMD_CODE_PARAM_ERR 1011 28 | 29 | struct CtrlRequest { 30 | std::mstring mCmd; 31 | Json::Value mContent; 32 | }; 33 | 34 | struct CtrlReply { 35 | int mStatus; 36 | std::mstring mLabel; 37 | std::mstring mShow; 38 | Json::Value mResult; 39 | 40 | CtrlReply() { 41 | mStatus = 0; 42 | } 43 | }; 44 | 45 | std::mstring __stdcall MakeRequest(const CtrlRequest &request); 46 | CtrlRequest __stdcall ParserRequest(const std::mstring &cmd); 47 | std::mstring __stdcall MakeReply(const CtrlReply &reply); 48 | CtrlReply __stdcall ParserReply(const std::mstring &reply); 49 | 50 | struct EventInfo { 51 | std::mstring mEvent; 52 | std::mstring mShow; 53 | Json::Value mContent; 54 | 55 | EventInfo() { 56 | } 57 | }; 58 | std::mstring __stdcall MakeEvent(const EventInfo &eventInfo); 59 | EventInfo __stdcall ParserEvent(const std::mstring &reply); 60 | #endif //COMMON_DBGCTRL_H_H_ 61 | -------------------------------------------------------------------------------- /dbg/procmon.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCMON_DBG_H_H_ 2 | #define PROCMON_DBG_H_H_ 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | typedef DWORD HProcListener; 13 | 14 | class ProcListener { 15 | public: 16 | virtual void OnProcChanged(HProcListener listener, const std::list &added, const std::list &killed) = 0; 17 | }; 18 | 19 | struct ProcRegisterInfo { 20 | HProcListener m_index; 21 | ProcListener *m_listener; 22 | std::set m_ProcCache; 23 | }; 24 | 25 | class ProcMonitor : public CCriticalSectionLockable { 26 | private: 27 | ProcMonitor(); 28 | 29 | public: 30 | static ProcMonitor *GetInstance(); 31 | virtual ~ProcMonitor(); 32 | 33 | HProcListener RegisterListener(ProcListener *listener); 34 | void UnRegisterListener(HProcListener); 35 | 36 | private: 37 | void RefushProc(); 38 | static bool GetProcSidAndUser(HANDLE process, std::mstring &sid, std::mstring &user); 39 | static BOOL WINAPI ProcHandlerW(PPROCESSENTRY32W pe, void *pParam); 40 | static DWORD WINAPI MonitorThread(LPVOID pParam); 41 | void DispatchProcChanged(); 42 | static DWORD GetProcUnique(DWORD pid); 43 | 44 | private: 45 | HANDLE m_hMonitorThread; 46 | HANDLE m_hExitNotify; 47 | std::map m_register; 48 | std::map m_ProcInfo; 49 | static int ms_curIndex; 50 | }; 51 | #endif //PROCMON_DBG_H_H_ -------------------------------------------------------------------------------- /VDebug/view/CmdQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "CmdQueue.h" 2 | 3 | using namespace std; 4 | 5 | CCmdQueue::CCmdQueue() : m_dwCurPos(0) 6 | {} 7 | 8 | CCmdQueue::~CCmdQueue() 9 | {} 10 | 11 | void CCmdQueue::EnterCmd(const mstring &wstrCmd) 12 | { 13 | mstring wstr(wstrCmd); 14 | wstr.trim(); 15 | 16 | set::const_iterator it; 17 | if (m_vCmdHash.end() != (it = m_vCmdHash.find(wstr))) 18 | { 19 | for (vector::const_iterator itCmd = m_vCmdList.begin() ; itCmd != m_vCmdList.end() ; itCmd++) 20 | { 21 | if (*itCmd == wstr) 22 | { 23 | m_vCmdList.erase(itCmd); 24 | break; 25 | } 26 | } 27 | } 28 | else 29 | { 30 | m_vCmdHash.insert(wstr); 31 | } 32 | m_vCmdList.push_back(wstr); 33 | m_dwCurPos = - 1; 34 | } 35 | 36 | mstring CCmdQueue::GetFrontCmd() 37 | { 38 | if (m_vCmdList.empty()) 39 | { 40 | return ""; 41 | } 42 | 43 | if (-1 == m_dwCurPos) 44 | { 45 | m_dwCurPos = (DWORD)m_vCmdList.size() - 1; 46 | return m_vCmdList[m_dwCurPos]; 47 | } 48 | 49 | if (m_dwCurPos) 50 | { 51 | return m_vCmdList[--m_dwCurPos]; 52 | } 53 | return m_vCmdList[0]; 54 | } 55 | 56 | mstring CCmdQueue::GetLastCmd() 57 | { 58 | if (m_vCmdList.empty() || -1 == m_dwCurPos) 59 | { 60 | return ""; 61 | } 62 | 63 | if (m_dwCurPos < (m_vCmdList.size() - 1)) 64 | { 65 | return m_vCmdList[++m_dwCurPos]; 66 | } 67 | return m_vCmdList[m_vCmdList.size() - 1]; 68 | } -------------------------------------------------------------------------------- /dbg/memory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "memory.h" 4 | #include "TitanEngine/TitanEngine.h" 5 | 6 | #define PAGE_SIZE 0x1000 7 | 8 | CMemoryProc::CMemoryProc(HANDLE hProcess) 9 | { 10 | m_hProcess = hProcess; 11 | } 12 | 13 | CMemoryProc::~CMemoryProc() 14 | {} 15 | 16 | bool CMemoryProc::MemoryReadPageSafe(DWORD64 dwAddr, char *szBuffer, DWORD dwBufferSize, IN OUT SIZE_T *pReadSize) const 17 | { 18 | if (dwBufferSize > (PAGE_SIZE - (dwAddr & (PAGE_SIZE - 1)))) 19 | { 20 | ErrMessage(L"Read Page Memory Error"); 21 | return false; 22 | } 23 | 24 | return ::MemoryReadSafe(m_hProcess, (LPVOID)dwAddr, szBuffer, dwBufferSize, pReadSize); 25 | } 26 | 27 | bool CMemoryProc::MemoryReadSafe(DWORD64 dwAddr, char *szBuffer, DWORD dwBufferSize, IN OUT DWORD *pReadSize) const 28 | { 29 | if (!szBuffer || !dwBufferSize) 30 | { 31 | return false; 32 | } 33 | 34 | DWORD dwOffset = 0; 35 | DWORD dwRequest = dwBufferSize; 36 | DWORD dwLeftInFirstPage = (PAGE_SIZE - (dwAddr & (PAGE_SIZE - 1))); 37 | DWORD dwReadSize = min(dwLeftInFirstPage, dwRequest); 38 | 39 | pReadSize[0] = 0; 40 | while (dwReadSize) 41 | { 42 | SIZE_T dw = 0; 43 | MemoryReadPageSafe(dwAddr + dwOffset, szBuffer + dwOffset, dwReadSize, &dw); 44 | 45 | pReadSize[0] += (DWORD)dw; 46 | if (dw != dwReadSize) 47 | { 48 | break; 49 | } 50 | 51 | dwOffset += (DWORD)dw; 52 | dwRequest -= (DWORD)dw; 53 | dwReadSize = min(PAGE_SIZE, dwRequest); 54 | } 55 | return true; 56 | } -------------------------------------------------------------------------------- /dbg/MemoryBase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "MemoryBase.h" 4 | 5 | using namespace std; 6 | 7 | std::ustring CMemoryBase::MemoryReadStrUnicode(DWORD64 dwAddr, DWORD dwMaxSize) const { 8 | if (!dwAddr || !dwMaxSize) 9 | { 10 | return L""; 11 | } 12 | 13 | WCHAR cBuffer = 0; 14 | DWORD dwOffset = 0; 15 | ustring wstrBuffer; 16 | while (TRUE) 17 | { 18 | DWORD dwRead = 0; 19 | if (!MemoryReadSafe(dwAddr + dwOffset, (char *)&cBuffer, sizeof(WCHAR), &dwRead)) 20 | { 21 | break; 22 | } 23 | 24 | dwOffset += sizeof(WCHAR); 25 | if (0 == cBuffer) 26 | { 27 | return wstrBuffer; 28 | } 29 | 30 | wstrBuffer += cBuffer; 31 | } 32 | 33 | return L""; 34 | } 35 | 36 | std::mstring CMemoryBase::MemoryReadStrGbk(DWORD64 dwAddr, DWORD dwMaxSize) const { 37 | if (!dwAddr || !dwMaxSize) 38 | { 39 | return ""; 40 | } 41 | 42 | char cBuffer = 0; 43 | DWORD dwOffset = 0; 44 | mstring strBuffer; 45 | while (TRUE) 46 | { 47 | DWORD dwRead = 0; 48 | if (!MemoryReadSafe(dwAddr + dwOffset, (char *)&cBuffer, sizeof(char), &dwRead)) 49 | { 50 | break; 51 | } 52 | 53 | dwOffset += sizeof(char); 54 | if (0 == cBuffer) 55 | { 56 | return strBuffer; 57 | } 58 | 59 | strBuffer += cBuffer; 60 | } 61 | 62 | return ""; 63 | } 64 | 65 | std::mstring CMemoryBase::MemoryReadStrUtf8(DWORD64 dwAddr, DWORD dwMaxSize) const { 66 | return ""; 67 | } -------------------------------------------------------------------------------- /dbg/ProcDbgProxy.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCDBGPROXY_DBG_H_H_ 2 | #define PROCDBGPROXY_DBG_H_H_ 3 | #include 4 | #include 5 | #include 6 | #include "ProcDbg.h" 7 | #include "ProcCmd.h" 8 | #include "procmon.h" 9 | 10 | class ProcDbgProxy : public ProcListener { 11 | private: 12 | ProcDbgProxy(); 13 | public: 14 | static ProcDbgProxy *GetInstance(); 15 | bool InitProcDbgProxy(const char *unique); 16 | virtual ~ProcDbgProxy(); 17 | 18 | private: 19 | //Dbg Ctrl 20 | static CtrlReply __stdcall GetProcInfo(const CtrlRequest &request, void *param); 21 | static CtrlReply __stdcall ExecProc(const CtrlRequest &request, void *param); 22 | static CtrlReply __stdcall AttachProc(const CtrlRequest &request, void *param); 23 | static CtrlReply __stdcall RunCmd(const CtrlRequest &request, void *param); 24 | static CtrlReply __stdcall DetachProc(const CtrlRequest &request, void *param); 25 | static CtrlReply __stdcall BreakDebugger(const CtrlRequest &request, void *param); 26 | 27 | //struct function desc ctrl 28 | static CtrlReply __stdcall DescTest(const CtrlRequest &request, void *param); 29 | static CtrlReply __stdcall DescSave(const CtrlRequest &request, void *param); 30 | 31 | private: 32 | //proc event 33 | virtual void OnProcChanged(HProcListener listener, const list &added, const list &killed); 34 | 35 | private: 36 | bool m_init; 37 | bool m_x64; 38 | CProcDbgger *m_pProcDbgger; 39 | CProcCmd *m_pCmdRunner; 40 | DbgClientBase *m_pDbgClient; 41 | HProcListener m_hProcListener; 42 | 43 | }; 44 | #endif //PROCDBGPROXY_DBG_H_H_ -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/include/ScintillaWidget.h: -------------------------------------------------------------------------------- 1 | /* Scintilla source code edit control */ 2 | /** @file ScintillaWidget.h 3 | ** Definition of Scintilla widget for GTK+. 4 | ** Only needed by GTK+ code but is harmless on other platforms. 5 | **/ 6 | /* Copyright 1998-2001 by Neil Hodgson 7 | * The License.txt file describes the conditions under which this software may be distributed. */ 8 | 9 | #ifndef SCINTILLAWIDGET_H 10 | #define SCINTILLAWIDGET_H 11 | 12 | #if defined(GTK) 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #define SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, scintilla_get_type (), ScintillaObject) 19 | #define SCINTILLA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass) 20 | #define IS_SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, scintilla_get_type ()) 21 | 22 | typedef struct _ScintillaObject ScintillaObject; 23 | typedef struct _ScintillaClass ScintillaClass; 24 | 25 | struct _ScintillaObject { 26 | GtkContainer cont; 27 | void *pscin; 28 | }; 29 | 30 | struct _ScintillaClass { 31 | GtkContainerClass parent_class; 32 | 33 | void (* command) (ScintillaObject *ttt); 34 | void (* notify) (ScintillaObject *ttt); 35 | }; 36 | 37 | GType scintilla_get_type (void); 38 | GtkWidget* scintilla_new (void); 39 | void scintilla_set_id (ScintillaObject *sci, uptr_t id); 40 | sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam); 41 | void scintilla_release_resources(void); 42 | 43 | #define SCINTILLA_NOTIFY "sci-notify" 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /ComLib/LockBase.h: -------------------------------------------------------------------------------- 1 | #ifndef LOCKBASE_VDEBUG_H_H_ 2 | #define LOCKBASE_VDEBUG_H_H_ 3 | #include 4 | 5 | class CLockable 6 | { 7 | public: 8 | virtual void Lock() const = 0; 9 | virtual void Unlock() const = 0; 10 | }; 11 | 12 | class CCriticalSectionLockable : public CLockable 13 | { 14 | public: 15 | CCriticalSectionLockable() 16 | { 17 | InitializeCriticalSection(&m_cs); 18 | } 19 | 20 | virtual ~CCriticalSectionLockable() 21 | { 22 | DeleteCriticalSection(&m_cs); 23 | } 24 | 25 | virtual void Lock() const 26 | { 27 | EnterCriticalSection(&m_cs); 28 | } 29 | 30 | virtual void Unlock() const 31 | { 32 | LeaveCriticalSection(&m_cs); 33 | } 34 | 35 | private: 36 | mutable CRITICAL_SECTION m_cs; 37 | }; 38 | 39 | class CScopedLocker 40 | { 41 | public: 42 | CScopedLocker(const CLockable *pLockable) 43 | : m_pLockable(pLockable) 44 | , m_pcs(NULL) 45 | { 46 | m_pLockable->Lock(); 47 | } 48 | 49 | CScopedLocker(LPCRITICAL_SECTION lpCs) 50 | : m_pLockable(NULL) 51 | , m_pcs(lpCs) 52 | { 53 | EnterCriticalSection(m_pcs); 54 | } 55 | 56 | virtual ~CScopedLocker() 57 | { 58 | if (m_pLockable) 59 | { 60 | m_pLockable->Unlock(); 61 | } 62 | else if (m_pcs) 63 | { 64 | LeaveCriticalSection(m_pcs); 65 | } 66 | } 67 | 68 | private: 69 | CScopedLocker(const CScopedLocker &); 70 | CScopedLocker &operator=(const CScopedLocker &); 71 | 72 | private: 73 | const CLockable *m_pLockable; 74 | LPCRITICAL_SECTION m_pcs; 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /ComLib/json/config.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_CONFIG_H_INCLUDED 2 | # define JSON_CONFIG_H_INCLUDED 3 | 4 | /// If defined, indicates that json library is embedded in CppTL library. 5 | //# define JSON_IN_CPPTL 1 6 | 7 | /// If defined, indicates that json may leverage CppTL library 8 | //# define JSON_USE_CPPTL 1 9 | /// If defined, indicates that cpptl vector based map should be used instead of std::map 10 | /// as Value container. 11 | //# define JSON_USE_CPPTL_SMALLMAP 1 12 | /// If defined, indicates that Json specific container should be used 13 | /// (hash table & simple deque container with customizable allocator). 14 | /// THIS FEATURE IS STILL EXPERIMENTAL! 15 | //# define JSON_VALUE_USE_INTERNAL_MAP 1 16 | /// Force usage of standard new/malloc based allocator instead of memory pool based allocator. 17 | /// The memory pools allocator used optimization (initializing Value and ValueInternalLink 18 | /// as if it was a POD) that may cause some validation tool to report errors. 19 | /// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined. 20 | //# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1 21 | 22 | /// If defined, indicates that Json use exception to report invalid type manipulation 23 | /// instead of C assert macro. 24 | # define JSON_USE_EXCEPTION 1 25 | 26 | # ifdef JSON_IN_CPPTL 27 | # include 28 | # ifndef JSON_USE_CPPTL 29 | # define JSON_USE_CPPTL 1 30 | # endif 31 | # endif 32 | 33 | # ifdef JSON_IN_CPPTL 34 | # define JSON_API CPPTL_API 35 | # elif defined(JSON_DLL_BUILD) 36 | # define JSON_API __declspec(dllexport) 37 | # elif defined(JSON_DLL) 38 | # define JSON_API __declspec(dllimport) 39 | # else 40 | # define JSON_API 41 | # endif 42 | 43 | #endif // JSON_CONFIG_H_INCLUDED 44 | -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/export.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPORT_SyntaxTextView_H_H_ 2 | #define EXPORT_SyntaxTextView_H_H_ 3 | 4 | struct LabelNode { 5 | const char *m_label; 6 | const char *m_content; 7 | void *mParam; 8 | 9 | int m_startPos; 10 | int m_endPos; 11 | 12 | LabelNode() { 13 | m_label = NULL, m_content = NULL; 14 | mParam = NULL; 15 | m_startPos = 0, m_endPos = 0; 16 | } 17 | }; 18 | 19 | class StyleContextBase { 20 | public: 21 | virtual void Complete() = 0; 22 | virtual bool More() const = 0; 23 | virtual void Forward() = 0; 24 | 25 | virtual int GetStat() = 0; 26 | 27 | virtual void Forward(int n) = 0; 28 | virtual void ForwardBytes(int n) = 0; 29 | virtual void ChangeState(int state) = 0; 30 | virtual void SetState(int state) = 0; 31 | 32 | virtual void ForwardSetState(int state) = 0; 33 | virtual int LengthCurrent() const = 0; 34 | virtual int GetRelative(int n) = 0; 35 | 36 | virtual int GetRelativeCharacter(int n) = 0; 37 | virtual bool Match(char c) const = 0; 38 | virtual bool Match(char c1, char c2) const = 0; 39 | virtual bool Match(const char *s) = 0; 40 | virtual bool MatchIgnoreCase(const char *s) = 0; 41 | virtual bool MatchIgnoreCase2(const char *s) = 0; 42 | virtual void GetCurrent(char *s, unsigned int len) = 0; 43 | virtual void GetCurrentLowered(char *s, unsigned int len) = 0; 44 | }; 45 | 46 | typedef void (__stdcall *pfnColouriseTextProc)( 47 | int initStyle, 48 | unsigned int startPos, 49 | const char *data, 50 | int length, 51 | StyleContextBase *sc 52 | ); 53 | 54 | void __stdcall RegisterSyntaxProc(const char *label, pfnColouriseTextProc pfn); 55 | #endif //EXPORT_SyntaxTextView_H_H_ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vdebug 2 | 码云git地址:https://gitee.com/lougd/vdebug.git 3 | 4 | 编译完成的程序包:https://pan.baidu.com/s/1krJLAFQEeKQ6aq-BV7NTJw 5 | 6 | 联系作者:qq:412776488 mail:lougdhr@126.com 7 | 8 | 如果觉得这个工具或者源码对你有用,请给作者点个star,感谢! 9 | 10 | #### 开发记录 11 | 之前一直用的微软自家的windbg调试器,有些功能用的不大习惯,比如windbg的条件断点,语法畸形并且效率很低,于是就有了自己开发一个的念头,正好开发的过程中自己也学习调试方面的相关知识,于是就有了这个项目,然后业余时间做了很久,后来由于转android开发了,一直搁置,部分功能尚未完成,自己也没有很多时间开发,于是就想将这个项目开源,让大家一起来完善这个项目。欢迎调试大牛来帮忙完善这个调试器,新人也可以通过这个项目来学习调试的相关知识。 12 | 13 | #### 功能介绍 14 | 15 | ``` 16 | vdebug是一个windows平台的调试器,主要特点(部分正在开发)如下: 17 | 1.绿色,小巧,不依赖额外的库 18 | 2.支持32/64位程序调试 19 | 3.支持分析dump内存影像文件 20 | 4.内置简洁易用的调试脚本,可以方便的写调试脚本 21 | 5.可以自行导入C语言格式的函数类型解析函数参数 22 | 6.漂亮的语法高亮控件 23 | 24 | 该调试器中用到的库有: 25 | Scintilla 强大开源的语法高亮控件 26 | capstone 反汇编引擎 27 | sqlite3 文件数据库 28 | jsoncpp json解析库 29 | TitanEngine 调试脚本引擎 30 | deelx 正则表达式引擎 31 | 感谢这些开源组件的作者! 32 | ``` 33 | 34 | 主界面截图: 35 | ![输入图片说明](https://images.gitee.com/uploads/images/2019/1005/115408_46baa519_498054.png "111.png") 36 | ![输入图片说明](https://images.gitee.com/uploads/images/2019/1005/115433_27b265bf_498054.png "222.png") 37 | 38 | #### 软件架构 39 | ``` 40 | 本工程由vs2008开发工具开发,主要的功能模块如下: 41 | ├─ComLib 项目公共动态库,实现各个项目通用的功能。 42 | ├─dbg 调试器核心功能模块,实现调试器的核心功能 43 | ├─DbgCtrl 调试功能代理中间件,调试控制层和调试实现层的中间件 44 | ├─mq 消息中间件,用于不同的进程,不同的组件之间实时通讯 45 | ├─runner 功能启动器,用于通过服务启动调试器的各个组件来提升调试组件的权限 46 | └─vdebug 调试器的控制层和展示层,用于数据展示以及与dbg进行调试交互 47 | ``` 48 | 49 | #### 接下来可能要做的功能 50 | 51 | ``` 52 | 1.反汇编关联pdb符号。 53 | 2.内存搜索,内存读写断点等基本功能。 54 | 3.64位程序调试支持,dump分析支持。 55 | 4.丰富调试脚本引擎,加入更加丰富的内置函数。 56 | 57 | ``` 58 | 59 | #### 作者信息 60 | ![输入图片说明](https://images.gitee.com/uploads/images/2019/1005/135224_1fe10ac0_498054.png "3333.png") 61 | 62 | qq:412776488 mail:lougdhr@126.com -------------------------------------------------------------------------------- /dbg/ScriptEngine/ScriptAccessor.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptAccessor.h" 2 | 3 | CScriptAccessor *CScriptAccessor::GetInst() { 4 | static CScriptAccessor *s_ptr = NULL; 5 | 6 | if (NULL == s_ptr) 7 | { 8 | s_ptr = new CScriptAccessor(); 9 | } 10 | return s_ptr; 11 | } 12 | 13 | CScriptAccessor::CScriptAccessor() { 14 | mMemoryReader = NULL; 15 | mDbgger = NULL; 16 | } 17 | 18 | CScriptAccessor::~CScriptAccessor() {} 19 | 20 | void CScriptAccessor::SetContext(CMemoryBase *reader, CDbgBase *dbgger) { 21 | mMemoryReader = reader; 22 | mDbgger = dbgger; 23 | UpdateContext(); 24 | } 25 | 26 | void CScriptAccessor::UpdateContext() { 27 | mContext = mDbgger->GetCurrentContext(); 28 | } 29 | 30 | bool CScriptAccessor::GetInternalVarData(const mstring &var, char *data) { 31 | if (var == "@csp") 32 | { 33 | memcpy(data, &mContext.csp, sizeof(ULONG_PTR)); 34 | } else if (var == "@cbp") 35 | { 36 | memcpy(data, &mContext.cbp, sizeof(ULONG_PTR)); 37 | } else if (var == "@cip") 38 | { 39 | memcpy(data, &mContext.cip, sizeof(ULONG_PTR)); 40 | } else if (var == "@cax") 41 | { 42 | memcpy(data, &mContext.cax, sizeof(ULONG_PTR)); 43 | } else if (var == "@ccx") 44 | { 45 | } 46 | else if (var == "@param0") 47 | { 48 | } else if (var == "@param1") 49 | { 50 | } else if (var == "@param2") 51 | { 52 | } else if (var == "@param3") 53 | { 54 | } else { 55 | return false; 56 | } 57 | return true; 58 | } 59 | 60 | bool CScriptAccessor::GetPtrData(DWORD64 ptr, int iSize, char *data) { 61 | DWORD readSize = 0; 62 | return mMemoryReader->MemoryReadSafe(ptr, data, iSize, &readSize); 63 | } -------------------------------------------------------------------------------- /DbgCtrl/DbgStat.h: -------------------------------------------------------------------------------- 1 | #ifndef DBGSTATUS_DBGCTRL_H_H_ 2 | #define DBGSTATUS_DBGCTRL_H_H_ 3 | #include 4 | #include 5 | #include 6 | #include "DbgCtrlCom.h" 7 | 8 | struct DbgStat { 9 | DbggerType mDbggerType; 10 | DbggerStatus mDbggerStatus; 11 | DWORD mCurTid; 12 | 13 | DbgStat() { 14 | mDbggerType = em_dbg_proc86; 15 | mDbggerStatus = em_dbg_status_init; 16 | mCurTid = 0; 17 | } 18 | }; 19 | 20 | typedef DWORD HDbgStatus; 21 | typedef void (__stdcall *pfnDbgStatusNotifyProc)(const DbgStat &status, void *param); 22 | 23 | struct DbgStatRegisterInfo { 24 | DWORD mIndex; 25 | void *mParam; 26 | pfnDbgStatusNotifyProc mNotifyProc; 27 | 28 | DbgStatRegisterInfo() { 29 | mIndex = 0; 30 | mParam = NULL; 31 | mNotifyProc = NULL; 32 | } 33 | }; 34 | 35 | class DbgCtrlApi CDbgStatMgr { 36 | public: 37 | static CDbgStatMgr *GetInst(); 38 | BOOL InitStatMgr(const std::mstring &unique); 39 | BOOL ReportDbgStatus(const DbgStat &status); 40 | HDbgStatus RegisterStatusNotify(pfnDbgStatusNotifyProc pfn, void *param); 41 | void UnRegisterStatusNotify(HDbgStatus); 42 | 43 | private: 44 | CDbgStatMgr(); 45 | virtual ~CDbgStatMgr(); 46 | static DWORD WINAPI NotifyThread(LPVOID pParam); 47 | DbgStat ParserStatDesc(const mstring &desc) const; 48 | void OnDispatchStat(); 49 | 50 | private: 51 | HANDLE mNotifyThread; 52 | DWORD mSerial; 53 | std::mstring mUnique; 54 | std::mstring mCachePath; 55 | HANDLE mNotifyEvent; 56 | std::list mRegisterCache; 57 | 58 | std::mstring mTimeStamp; 59 | std::mstring mStatDesc; 60 | }; 61 | #endif //DBGSTATUS_DBGCTRL_H_H_ -------------------------------------------------------------------------------- /ComLib/DbProxy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "DbProxy.h" 5 | 6 | using namespace std; 7 | 8 | DbProxy::DbProxy() { 9 | } 10 | 11 | DbProxy::~DbProxy() { 12 | } 13 | 14 | DbProxy *DbProxy::GetInstance() { 15 | static DbProxy *s_ptr = NULL; 16 | if (s_ptr == NULL) 17 | { 18 | s_ptr = new DbProxy(); 19 | } 20 | 21 | return s_ptr; 22 | } 23 | 24 | bool DbProxy::InitDbEnv() { 25 | mCfgDbPath = GetConfigDbPath(); 26 | mSymbolDbPath = GetSymbolDbPath(); 27 | 28 | if (INVALID_FILE_ATTRIBUTES == GetFileAttributesA(mCfgDbPath.c_str())) 29 | { 30 | char dir[512]; 31 | lstrcpynA(dir, mCfgDbPath.c_str(), 512); 32 | PathAppendA(dir, ".."); 33 | SHCreateDirectoryExA(NULL, dir, NULL); 34 | } 35 | 36 | SqliteOperator opt(mCfgDbPath); 37 | //tOpenHistory id path param dir time Dbgger cache 38 | opt.Exec("create table if not exists tOpenHistory(id BIGINT PRIMARY KEY, path CHAR(512), param TEXT, dir TEXT, time CHAR(32))"); 39 | return true; 40 | } 41 | 42 | SqliteResult DbProxy::SelectCfg(const mstring &sql) { 43 | mCfgOpt.Open(mCfgDbPath); 44 | SqliteResult res = mCfgOpt.Select(sql); 45 | mCfgOpt.Close(); 46 | return res; 47 | } 48 | 49 | bool DbProxy::ExecCfg(const mstring &sql) { 50 | mCfgOpt.Open(mCfgDbPath); 51 | bool ret = mCfgOpt.Exec(sql); 52 | mCfgOpt.Close(); 53 | return ret; 54 | } 55 | 56 | SqliteResult DbProxy::SelectSymbol(const mstring &sql) { 57 | mSymbolOpt.Open(mSymbolDbPath); 58 | SqliteResult res = mSymbolOpt.Select(sql); 59 | mSymbolOpt.Close(); 60 | return res; 61 | } 62 | 63 | bool DbProxy::ExecSymbol(const mstring &sql) { 64 | mSymbolOpt.Open(mSymbolDbPath); 65 | bool ret = mSymbolOpt.Exec(sql); 66 | mSymbolOpt.Close(); 67 | return ret; 68 | } -------------------------------------------------------------------------------- /ComLib/TransferEncoder.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSFERENCODER_COMLIB_H_H_ 2 | #define TRANSFERENCODER_COMLIB_H_H_ 3 | #include 4 | #include 5 | #include 6 | #include "LibDef.h" 7 | #include "GlobalDef.h" 8 | 9 | struct ProcInfoSet { 10 | std::list mAddSet; 11 | std::list mKillSet; 12 | }; 13 | std::mstring COMAPI __stdcall EncodeProcMon(const ProcInfoSet &procSet); 14 | ProcInfoSet COMAPI __stdcall DecodeProcMon(const std::mstring &json); 15 | 16 | struct ProcCreateInfo { 17 | DWORD mPid; 18 | std::mstring mImage; 19 | std::mstring mBaseAddr; 20 | std::mstring mEntryAddr; 21 | }; 22 | std::mstring COMAPI __stdcall EncodeProcCreate(const ProcCreateInfo &info); 23 | ProcCreateInfo COMAPI __stdcall DecodeProcCreate(const std::mstring &json); 24 | 25 | struct DllLoadInfo { 26 | std::mstring mDllName; 27 | std::mstring mBaseAddr; 28 | std::mstring mEndAddr; 29 | }; 30 | std::mstring COMAPI __stdcall EncodeDllLoadInfo(const DllLoadInfo &info); 31 | DllLoadInfo COMAPI __stdcall DecodeDllLoadInfo(const std::mstring &json); 32 | 33 | struct RegisterContent { 34 | TITAN_ENGINE_CONTEXT_t mContext; 35 | std::mstring mCipStr; 36 | }; 37 | std::mstring COMAPI __stdcall EncodeCmdRegister(const RegisterContent &context); 38 | RegisterContent COMAPI __stdcall DecodeCmdRegister(const std::mstring &json); 39 | 40 | struct CallStackSingle { 41 | std::mstring mReturn; 42 | std::mstring mParam0; 43 | std::mstring mParam1; 44 | std::mstring mParam2; 45 | std::mstring mParam3; 46 | std::mstring mAddr; 47 | std::mstring mFunction; 48 | }; 49 | 50 | struct CallStackData { 51 | std::list mCallStack; 52 | }; 53 | std::mstring COMAPI __stdcall EncodeCmdCallStack(const CallStackData &callStack); 54 | CallStackData COMAPI __stdcall DecodeCmdCallStack(const std::mstring &json); 55 | #endif //TRANSFERENCODER_H_H_ -------------------------------------------------------------------------------- /VDebug/view/SyntaxDesc.h: -------------------------------------------------------------------------------- 1 | #ifndef SYNTAXDESC_VDEBUG_H_H_ 2 | #define SYNTAXDESC_VDEBUG_H_H_ 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | struct SyntaxColourNode 11 | { 12 | std::mstring m_strContent; 13 | DWORD m_dwStartPos; 14 | DWORD m_dwLength; 15 | 16 | SyntaxColourDesc m_vHightLightDesc; 17 | 18 | SyntaxColourNode( 19 | const mstring &strKeyWord, 20 | DWORD dwStartPos = 0, 21 | SyntaxColourDesc vDesc = SyntaxColourDesc() 22 | ) 23 | { 24 | m_strContent = strKeyWord; 25 | m_dwStartPos = dwStartPos; 26 | m_dwLength = (DWORD)m_strContent.size(); 27 | m_vHightLightDesc = vDesc; 28 | } 29 | }; 30 | 31 | struct SyntaxDesc 32 | { 33 | SyntaxDesc(const ustring &wstrContent, const SyntaxColourDesc &colour); 34 | SyntaxDesc(const ustring &wstrContent); 35 | SyntaxDesc(); 36 | 37 | SyntaxDesc &operator+=(const SyntaxDesc &desc) 38 | { 39 | m_vSyntaxDesc.insert(m_vSyntaxDesc.end(), desc.m_vSyntaxDesc.begin(), desc.m_vSyntaxDesc.end()); 40 | m_vShowInfo.insert(m_vShowInfo.end(), desc.m_vShowInfo.begin(), desc.m_vShowInfo.end()); 41 | return *this; 42 | } 43 | 44 | SyntaxDesc &operator+=(const ustring &wstr) 45 | { 46 | *this += SyntaxDesc(wstr); 47 | return *this; 48 | } 49 | 50 | bool operator=(const SyntaxDesc &desc) 51 | { 52 | m_vSyntaxDesc = desc.m_vSyntaxDesc; 53 | m_vShowInfo = desc.m_vShowInfo; 54 | return true; 55 | } 56 | 57 | BOOL IsValid() const 58 | { 59 | return TRUE; 60 | } 61 | 62 | VOID Clear() 63 | { 64 | m_vSyntaxDesc.clear(); 65 | m_vShowInfo.clear(); 66 | } 67 | 68 | vector> m_vSyntaxDesc; 69 | vector m_vShowInfo; 70 | }; 71 | #endif -------------------------------------------------------------------------------- /VDebug/view/ViewBase.cpp: -------------------------------------------------------------------------------- 1 | #include "ViewBase.h" 2 | 3 | map *CWindowBase::m_pWndRegister = new map(); 4 | 5 | LRESULT CWindowBase::OnWindowMsg(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp) 6 | { 7 | return 0; 8 | } 9 | 10 | BOOL CWindowBase::CreateDlg(DWORD dwId, HWND hParent, BOOL bDoModule) 11 | { 12 | if (bDoModule) 13 | { 14 | DialogBoxParamA(NULL, MAKEINTRESOURCEA(dwId), hParent, DlgProc, (LPARAM)this); 15 | } 16 | else 17 | { 18 | m_hwnd = ::CreateDialogParamA(NULL, MAKEINTRESOURCEA(dwId), hParent, DlgProc, (LPARAM)this); 19 | mstring dd = GetStdErrorStr(); 20 | int ee = 0; 21 | } 22 | return IsWindow(m_hwnd); 23 | } 24 | 25 | INT_PTR CWindowBase::DlgProc(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp) 26 | { 27 | if (WM_INITDIALOG == uMsg) 28 | { 29 | CWindowBase *ptr = (CWindowBase *)lp; 30 | ptr->m_hwnd = hwnd; 31 | RegisterWnd(ptr); 32 | } 33 | 34 | CWindowBase *pWnd = GetWndFromHandle(hwnd); 35 | 36 | LRESULT res = 0; 37 | if (pWnd) 38 | { 39 | res = pWnd->OnWindowMsg(hwnd, uMsg, wp, lp); 40 | } 41 | 42 | if (WM_DESTROY == uMsg) 43 | { 44 | UnRegisterWnd(hwnd); 45 | } 46 | return res; 47 | } 48 | 49 | LRESULT CWindowBase::WinBaseProc(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp) 50 | { 51 | if (WM_NCCREATE == uMsg) 52 | { 53 | return DefWindowProc(hwnd, uMsg, wp, lp); 54 | } 55 | else if (WM_CREATE == uMsg) 56 | { 57 | RECT rt = {0}; 58 | GetWindowRect(hwnd, &rt); 59 | CWindowBase *ptr = (CWindowBase *)((CREATESTRUCT *)lp)->lpCreateParams; 60 | ptr->m_hwnd = hwnd; 61 | RegisterWnd(ptr); 62 | } 63 | 64 | CWindowBase *pWnd = GetWndFromHandle(hwnd); 65 | 66 | LRESULT res = 0; 67 | if (pWnd) 68 | { 69 | res = pWnd->OnWindowMsg(hwnd, uMsg, wp, lp); 70 | } 71 | 72 | if (WM_DESTROY == uMsg) 73 | { 74 | UnRegisterWnd(hwnd); 75 | } 76 | return res; 77 | } -------------------------------------------------------------------------------- /VDebug/view/OpenView.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENVIEW_VDEBUG_H_H_ 2 | #define OPENVIEW_VDEBUG_H_H_ 3 | #include 4 | #include "ViewBase.h" 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | struct ProcParam { 11 | BOOL succ; 12 | BOOL x64; 13 | std::mstring path; 14 | std::mstring command; 15 | std::mstring dir; 16 | 17 | ProcParam() { 18 | succ = FALSE; 19 | x64 = FALSE; 20 | } 21 | }; 22 | 23 | class PeFileOpenDlg : public CCriticalSectionLockable 24 | { 25 | struct HistoryInfo { 26 | unsigned long mId; 27 | std::mstring mPath; 28 | std::mstring mParam; 29 | std::mstring mDir; 30 | std::mstring mTime; 31 | }; 32 | 33 | private: 34 | PeFileOpenDlg(); 35 | public: 36 | static PeFileOpenDlg *GetInstance(); 37 | virtual ~PeFileOpenDlg(); 38 | BOOL ShowFileOpenDlg(HWND parent, ProcParam ¶m); 39 | 40 | private: 41 | void OnHistorySelect(int index) const; 42 | bool SaveHistory(HistoryInfo &history) const; 43 | std::vector GetHistory(int maxSize) const; 44 | int OnInitDialog(HWND hdlg, WPARAM wp, LPARAM lp); 45 | int OnSize(HWND hdlg, WPARAM wp, LPARAM lp); 46 | int OnTimer(HWND hdlg, WPARAM wp, LPARAM lp); 47 | int OnNotify(HWND hdlg, WPARAM wp, LPARAM lp); 48 | int OnCommand(HWND hdlg, WPARAM wp, LPARAM lp); 49 | static UINT_PTR CALLBACK OFNHookProc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp); 50 | static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam); 51 | 52 | private: 53 | HWND m_hdlg; 54 | ProcParam m_param; 55 | 56 | HWND m_hParent; 57 | HWND m_hTextPath; 58 | HWND m_hComExPath; 59 | HWND m_hEditPath; 60 | 61 | HWND m_hTextType; 62 | HWND m_hComType; 63 | 64 | HWND m_hBtnOk; 65 | HWND m_hBtnCancel; 66 | 67 | HWND m_hTextParam; 68 | HWND m_hEditParam; 69 | HWND m_hTextDir; 70 | HWND m_hEditDir; 71 | HWND m_hTextHistory; 72 | HWND m_hComHistory; 73 | HWND m_hEditStatus; 74 | 75 | vector mHistory; 76 | }; 77 | #endif -------------------------------------------------------------------------------- /dbg/ProcCmd.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCCMD_DBG_H_H_ 2 | #define PROCCMD_DBG_H_H_ 3 | #include 4 | #include 5 | #include "CmdBase.h" 6 | #include "ProcDbg.h" 7 | 8 | class CProcCmd : public CCmdBase { 9 | private: 10 | CProcCmd(); 11 | public: 12 | static CProcCmd *GetInst(); 13 | virtual ~CProcCmd(); 14 | void InitProcCmd(CProcDbgger *pDbgger); 15 | 16 | private: 17 | static CtrlReply OnCmdBp(const mstring &cmd, HUserCtx ctx); 18 | static CtrlReply OnCmdBl(const mstring &cmd, HUserCtx ctx); 19 | static CtrlReply OnCmdBc(const mstring &cmd, HUserCtx ctx); 20 | static CtrlReply OnCmdBu(const mstring &cmd, HUserCtx ctx); 21 | static CtrlReply OnCmdBe(const mstring &cmd, HUserCtx ctx); 22 | static CtrlReply OnBreak(const mstring &cmd, HUserCtx ctx); 23 | static CtrlReply OnCmdDisass(const mstring &cmd, HUserCtx ctx); 24 | static CtrlReply OnCmdUb(const mstring &cmd, HUserCtx ctx); 25 | static CtrlReply OnCmdUf(const mstring &cmd, HUserCtx ctx); 26 | static CtrlReply OnCmdGo(const mstring &cmd, HUserCtx ctx); 27 | static CtrlReply OnCmdGu(const mstring &cmd, HUserCtx ctx); 28 | static CtrlReply OnCmdKv(const mstring &cmd, HUserCtx ctx); 29 | static CtrlReply OnCmdDb(const mstring &cmd, HUserCtx ctx); 30 | static CtrlReply OnCmdDd(const mstring &cmd, HUserCtx ctx); 31 | static CtrlReply OnCmdDu(const mstring &cmd, HUserCtx ctx); 32 | static CtrlReply OnCmdDa(const mstring &cmd, HUserCtx ctx); 33 | static CtrlReply OnCmdReg(const mstring &cmd, HUserCtx ctx); 34 | static CtrlReply OnCmdScript(const mstring &cmd, HUserCtx ctx); 35 | static CtrlReply OnCmdTs(const mstring &cmd, HUserCtx ctx); 36 | static CtrlReply OnCmdTc(const mstring &cmd, HUserCtx ctx); 37 | static CtrlReply OnCmdLm(const mstring &cmd, HUserCtx ctx); 38 | static CtrlReply OnCmdPf(const mstring &cmd, HUserCtx ctx); 39 | static CtrlReply OnCmdHelp(const mstring ¶m, HUserCtx ctx); 40 | 41 | static void __cdecl GuCmdCallback(); 42 | private: 43 | static CProcDbgger *mProcDbgger; 44 | }; 45 | #endif //PROCCMD_DBG_H_H_ -------------------------------------------------------------------------------- /dbg/UserContext.cpp: -------------------------------------------------------------------------------- 1 | #include "UserContext.h" 2 | 3 | CUserContextMgr::CUserContextMgr() { 4 | mSerial = 0x1f; 5 | } 6 | 7 | CUserContextMgr::~CUserContextMgr() { 8 | } 9 | 10 | CUserContextMgr *CUserContextMgr::GetInst() { 11 | static CUserContextMgr *sPtr = NULL; 12 | 13 | if (NULL == sPtr) 14 | { 15 | sPtr = new CUserContextMgr(); 16 | } 17 | return sPtr; 18 | } 19 | 20 | HUserCtx CUserContextMgr::GetUserCtx(pfnUserNotifyProc pfn, LPVOID p) { 21 | DWORD dwCur = mSerial++; 22 | 23 | UserContextInfo ctx; 24 | ctx.mNotifyEvent = CreateEventA(NULL, FALSE, FALSE, NULL); 25 | ctx.mPfnCallback = pfn; 26 | ctx.mParam = p; 27 | mCtxMap[dwCur] = ctx; 28 | return dwCur; 29 | } 30 | 31 | bool CUserContextMgr::GetInfoByIndex(HUserCtx ctx, UserContextInfo &info) { 32 | CScopedLocker locker(this); 33 | map::const_iterator it = mCtxMap.find(ctx); 34 | if (it == mCtxMap.end()) 35 | { 36 | return false; 37 | } 38 | 39 | info = it->second; 40 | return true; 41 | } 42 | 43 | bool CUserContextMgr::DeleteByIndex(HUserCtx ctx) { 44 | CScopedLocker locker(this); 45 | map::const_iterator it = mCtxMap.find(ctx); 46 | if (it == mCtxMap.end()) 47 | { 48 | return false; 49 | } 50 | 51 | mCtxMap.erase(it); 52 | return true; 53 | } 54 | 55 | void CUserContextMgr::SetUserCtx(HUserCtx ctx) { 56 | UserContextInfo info; 57 | if (!GetInfoByIndex(ctx, info)) 58 | { 59 | return; 60 | } 61 | 62 | if (info.mNotifyEvent) 63 | { 64 | SetEvent(info.mNotifyEvent); 65 | } 66 | 67 | if (info.mPfnCallback) 68 | { 69 | info.mPfnCallback(info.mParam); 70 | } 71 | } 72 | 73 | void CUserContextMgr::Close(HUserCtx ctx) { 74 | CScopedLocker locker(this); 75 | UserContextInfo info; 76 | if (!GetInfoByIndex(ctx, info)) 77 | { 78 | return; 79 | } 80 | 81 | DeleteByIndex(ctx); 82 | } 83 | 84 | void CUserContextMgr::WaitNotify(HUserCtx ctx, DWORD timeOut) { 85 | UserContextInfo info; 86 | if (!GetInfoByIndex(ctx, info)) 87 | { 88 | return; 89 | } 90 | 91 | WaitForSingleObject(info.mNotifyEvent, timeOut); 92 | } -------------------------------------------------------------------------------- /VDebug/view/ParserBase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ParserBase.h" 4 | #include "mstring.h" 5 | 6 | using namespace std; 7 | 8 | bool CParserBase::IsNumberStr(LPCWSTR wszBuffer) 9 | { 10 | DWORD dwIdex = 0; 11 | WCHAR cLetter = 0; 12 | 13 | ustring wstr(wszBuffer); 14 | if (0 == wstr.comparei(L"0x")) 15 | { 16 | dwIdex = 2; 17 | } 18 | 19 | while (TRUE) 20 | { 21 | cLetter = wszBuffer[dwIdex]; 22 | 23 | if (!cLetter) 24 | { 25 | break; 26 | } 27 | 28 | if (cLetter >= 'A' && cLetter <= 'F') 29 | { 30 | cLetter |= 32; 31 | } 32 | 33 | if (!((cLetter >= 'a' && cLetter <= 'f') || (cLetter >= '0' && cLetter <= '9') || cLetter == 'h')) 34 | { 35 | return FALSE; 36 | } 37 | dwIdex++; 38 | } 39 | return (0 != dwIdex); 40 | } 41 | 42 | bool CParserBase::IsWordCutChar(WCHAR cLetter) 43 | { 44 | static set s_vWordCutChars; 45 | if (s_vWordCutChars.empty()) 46 | { 47 | s_vWordCutChars.insert(L' '); 48 | s_vWordCutChars.insert(L'['); 49 | s_vWordCutChars.insert(L']'); 50 | s_vWordCutChars.insert(L'+'); 51 | s_vWordCutChars.insert(L'-'); 52 | s_vWordCutChars.insert(L'('); 53 | s_vWordCutChars.insert(L')'); 54 | s_vWordCutChars.insert(L','); 55 | s_vWordCutChars.insert(L'!'); 56 | s_vWordCutChars.insert(L'`'); 57 | } 58 | 59 | return (s_vWordCutChars.end() != s_vWordCutChars.find(cLetter)); 60 | } 61 | 62 | std::wstring CParserBase::GetSingleWorld(LPCWSTR wszBuffer, DWORD dwCurrentPos, DWORD &dwWordPos) 63 | { 64 | DWORD dwIdex = dwCurrentPos; 65 | WCHAR cLetter = 0; 66 | 67 | while(TRUE) 68 | { 69 | cLetter = wszBuffer[dwIdex]; 70 | if (!IsWordCutChar(cLetter) || (0 == cLetter)) 71 | { 72 | break; 73 | } 74 | dwIdex++; 75 | } 76 | 77 | DWORD dwStart = dwIdex; 78 | while(TRUE) 79 | { 80 | cLetter = wszBuffer[dwIdex]; 81 | if (IsWordCutChar(cLetter) || (0 == cLetter)) 82 | { 83 | break; 84 | } 85 | dwIdex++; 86 | } 87 | 88 | if (dwIdex > dwStart) 89 | { 90 | dwWordPos = dwStart; 91 | return wstring(wszBuffer + dwStart, dwIdex - dwStart); 92 | } 93 | return L""; 94 | } -------------------------------------------------------------------------------- /VDebug/DbgCtrlService.h: -------------------------------------------------------------------------------- 1 | #ifndef DBGSERVICE_VDEBUG_H_H_ 2 | #define DBGSERVICE_VDEBUG_H_H_ 3 | #include 4 | #include 5 | #include 6 | 7 | class DbgCtrlService { 8 | private: 9 | DbgCtrlService(); 10 | 11 | public: 12 | static DbgCtrlService *GetInstance(); 13 | virtual ~DbgCtrlService(); 14 | 15 | bool InitCtrlService(); 16 | bool SetDebugger(DbggerType type); 17 | DbggerStatus GetDebuggerStat(); 18 | bool BreakDbgProcInCtrlService() const; 19 | bool ExecProc(const std::mstring &path, const std::mstring ¶m); 20 | bool AttachProc(DWORD pid); 21 | bool DetachProc(); 22 | 23 | bool TestDescStr(const std::mstring &dll, const std::mstring &str); 24 | bool InputDescStr(const std::mstring &dll, const std::mstring &str, bool cover = false); 25 | 26 | bool OpenDump(const std::mstring &path) const; 27 | CtrlReply RunCmdInCtrlService(const std::mstring &cmd); 28 | 29 | //proc monitor 30 | bool StartProcMon(); 31 | void StopProcMon(); 32 | 33 | private: 34 | void SetCtrlStatus(DbggerStatus stat); 35 | void OnCmdReply(const std::mstring &content); 36 | 37 | //Proc Debug Event 38 | static void WINAPI OnProcCreate(const EventInfo &eventInfo, void *param); 39 | static void WINAPI OnSystemBreakpoint(const EventInfo &eventInfo, void *param); 40 | static void WINAPI OnUserBreakpoint(const EventInfo &eventInfo, void *param); 41 | static void WINAPI OnDbgMessage(const EventInfo &eventInfo, void *param); 42 | static void WINAPI OnProcExit(const EventInfo &eventInfo, void *param); 43 | static void WINAPI OnModuleLoad(const EventInfo &eventInfo, void *param); 44 | static void WINAPI OnModuleUnLoad(const EventInfo &eventInfo, void *param); 45 | static void WINAPI OnDetachDbgger(const EventInfo &eventInfo, void *param); 46 | static void WINAPI OnProgramException(const EventInfo &eventInfo, void *param); 47 | 48 | //Proc changed 49 | static void WINAPI OnProcChanged(const EventInfo &eventInfo, void *param); 50 | 51 | //Dbg Status 52 | static void __stdcall DbgStatusNotifyProc(const DbgStat &status, void *param); 53 | private: 54 | void RunProcInUser(LPCSTR image, LPCSTR cmd, DWORD session); 55 | private: 56 | DbggerType m_type; 57 | DbggerStatus m_stat; 58 | std::mstring m_DbgChannel; 59 | std::mstring m_unique; 60 | DbgServiceBase *m_pCtrlService; 61 | bool m_procMon; 62 | }; 63 | #endif //DBGSERVICE_VDEBUG_H_H_ -------------------------------------------------------------------------------- /VDebug/view/ProcView.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCVIEW_VDEBUG_H_H_ 2 | #define PROCVIEW_VDEBUG_H_H_ 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "ViewBase.h" 10 | 11 | using namespace std; 12 | 13 | struct ProcShowInfo 14 | { 15 | ProcMonInfo info; //proc info 16 | DWORD m_dwIcoIdex; //ico index 17 | std::mstring m_indexStr;//index str 18 | std::mstring m_procShow;//proc show 19 | 20 | ProcShowInfo() { 21 | m_dwIcoIdex = -1; 22 | } 23 | }; 24 | 25 | typedef LRESULT (CALLBACK *PWIN_PROC)(HWND, UINT, WPARAM, LPARAM); 26 | 27 | class CProcSelectView : public CWindowBase, public CCriticalSectionLockable 28 | { 29 | public: 30 | CProcSelectView() : m_hParent(NULL), m_hFont(NULL), m_hProcList(NULL), m_hImageList(NULL), m_dwSelectPid(0) 31 | { 32 | m_pfnFilterEditProc = NULL; 33 | } 34 | 35 | virtual ~CProcSelectView() 36 | {} 37 | 38 | BOOL SetFont(HFONT hFont); 39 | 40 | BOOL Refush(); 41 | 42 | BOOL Create(); 43 | 44 | BOOL DoModule(HWND hParent); 45 | 46 | DWORD GetSelectProc() 47 | { 48 | return m_dwSelectPid; 49 | } 50 | 51 | void OnProcChanged(const ProcInfoSet &info); 52 | void DeleteFromSet(vector &procSet, const list &killed, bool freeMem); 53 | void DeleteProcCache(); 54 | protected: 55 | INT_PTR OnInitDlg(HWND hwnd, WPARAM wp, LPARAM lp); 56 | 57 | VOID OnGetListCtrlDisplsy(IN OUT NMLVDISPINFOA* ptr); 58 | void OnListColumnClick(IN NMLISTVIEW *ptr); 59 | 60 | void OnListItemChanged(HWND hwnd, WPARAM wp, LPARAM lp); 61 | INT_PTR OnNotify(HWND hwnd, WPARAM wp, LPARAM lp); 62 | INT_PTR OnClose(HWND hwnd, WPARAM wp, LPARAM lp); 63 | INT_PTR OnCommand(HWND hwnd, WPARAM wp, LPARAM lp); 64 | INT_PTR OnFilterProc(HWND hwnd, WPARAM wp, LPARAM lp); 65 | static LRESULT WINAPI FilterEditProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); 66 | 67 | protected: 68 | void InitListCtrl(); 69 | VOID CalWidthByColumns() const; 70 | void RefushProc(); 71 | int GetFileIco(const mstring &wstrFile); 72 | mstring GetSearchStr(ProcShowInfo *ptr); 73 | mstring GetLastSelectDir(); 74 | void RecordLastSelect(LPCWSTR wszDir); 75 | 76 | protected: 77 | virtual LRESULT OnWindowMsg(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp); 78 | 79 | protected: 80 | HWND m_hParent; 81 | HWND m_hEditFlt; 82 | HWND m_hEditInfo; 83 | HWND m_hEditStatus; 84 | HWND m_hProcList; 85 | HFONT m_hFont; 86 | DWORD m_dwSelectPid; 87 | PWIN_PROC m_pfnFilterEditProc; 88 | 89 | HIMAGELIST m_hImageList; 90 | map m_icoIndex; 91 | vector m_procShow; 92 | vector m_procAll; 93 | mstring m_searchStr; 94 | mstring m_statusMsg; 95 | 96 | static map ms_peIcon; 97 | }; 98 | #endif -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/SyntaxCache.cpp: -------------------------------------------------------------------------------- 1 | #include "SyntaxCache.h" 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | #define TIMER_CACHE (WM_USER + 7001) 8 | map CSyntaxCache::msTimerCache; 9 | 10 | CSyntaxCache::CSyntaxCache() { 11 | mInterval = 0; 12 | 13 | InitializeCriticalSection(&mCacheLocker); 14 | } 15 | 16 | CSyntaxCache::~CSyntaxCache() { 17 | } 18 | 19 | void CSyntaxCache::Lock() { 20 | EnterCriticalSection(&mCacheLocker); 21 | } 22 | void CSyntaxCache::UnLock() { 23 | LeaveCriticalSection(&mCacheLocker); 24 | } 25 | 26 | bool CSyntaxCache::InitCache(int interval) { 27 | mInterval = interval; 28 | 29 | HWND hwnd = SyntaxTextView::GetWindow(); 30 | assert(IsWindow(hwnd)); 31 | 32 | msTimerCache[hwnd] = this; 33 | SetTimer(hwnd, TIMER_CACHE, interval, TimerCache); 34 | return true; 35 | } 36 | 37 | void CSyntaxCache::TimerCache(HWND hwnd, UINT msg, UINT_PTR id, DWORD time) 38 | { 39 | if (TIMER_CACHE == id) 40 | { 41 | map::iterator it = msTimerCache.find(hwnd); 42 | 43 | if (it == msTimerCache.end()) 44 | { 45 | return; 46 | } 47 | 48 | CSyntaxCache *ptr = it->second; 49 | ptr->Lock(); 50 | if (ptr->mCacheContent.empty()) 51 | { 52 | ptr->UnLock(); 53 | return; 54 | } 55 | 56 | for (list::const_iterator ij = ptr->mCacheDesc.begin() ; ij != ptr->mCacheDesc.end() ; ij++) 57 | { 58 | const DataCacheDesc &tmp = *ij; 59 | ptr->AppendText(tmp.mLabel, ptr->mCacheContent.substr(tmp.mStartPos, tmp.mLength)); 60 | } 61 | ptr->mCacheDesc.clear(); 62 | ptr->mCacheContent.clear(); 63 | ptr->UnLock(); 64 | } 65 | } 66 | 67 | void CSyntaxCache::ClearCache() { 68 | Lock(); 69 | mCacheDesc.clear(); 70 | mCacheContent.clear(); 71 | UnLock(); 72 | } 73 | 74 | void CSyntaxCache::PushToCache(const std::string &label, const std::string &content) { 75 | if (content.empty()) 76 | { 77 | return; 78 | } 79 | 80 | Lock(); 81 | bool newItem = false; 82 | size_t lastPos = 0; 83 | if (!mCacheDesc.empty()) 84 | { 85 | DataCacheDesc &lastDesc = *mCacheDesc.rbegin(); 86 | 87 | //Merge content 88 | if (lastDesc.mLabel == label) 89 | { 90 | lastDesc.mLength += content.size(); 91 | } else { 92 | newItem = true; 93 | lastPos = lastDesc.mStartPos + lastDesc.mLength; 94 | } 95 | } else { 96 | newItem = true; 97 | } 98 | 99 | if (newItem) 100 | { 101 | DataCacheDesc desc; 102 | desc.mLabel = label; 103 | desc.mStartPos = lastPos; 104 | desc.mLength = content.size(); 105 | mCacheDesc.push_back(desc); 106 | } 107 | mCacheContent += content; 108 | UnLock(); 109 | } 110 | -------------------------------------------------------------------------------- /Debug/x64/SyntaxCfg.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalCfg": { 3 | "lineNumber": 1, 4 | "defTextColour": "0,0,255", 5 | "defBackColour": "null", 6 | "viewBackColour": "40,40,40", 7 | "curLineColour": "60,56,54" 8 | }, 9 | "SyntaxCfg": { 10 | "addr": { 11 | "textColour": "128,255,255", 12 | "backColour": "null", 13 | "bold": 1, 14 | "italic": 1 15 | }, 16 | "error": { 17 | "textColour": "252,205,109", 18 | "backColour": "null", 19 | "bold": 1, 20 | "italic": 1 21 | }, 22 | "msg": { 23 | "textColour": "252,205,109", 24 | "backColour": "null", 25 | "bold": 0, 26 | "italic": 1 27 | }, 28 | "msg2": { 29 | "textColour": "101,132,91", 30 | "backColour": "null", 31 | "bold": 0, 32 | "italic": 1 33 | }, 34 | "hex": { 35 | "textColour": "252,153,60", 36 | "backColour": "null", 37 | "bold": 0, 38 | "italic": 1 39 | }, 40 | "data": { 41 | "textColour": "153,153,153", 42 | "backColour": "null", 43 | "bold": 0, 44 | "italic": 1 45 | }, 46 | "btye": { 47 | "textColour": "255,128,128", 48 | "backColour": "null", 49 | "bold": 0, 50 | "italic": 1 51 | }, 52 | "inst": { 53 | "textColour": "255,165,70", 54 | "backColour": "null", 55 | "bold": 0, 56 | "italic": 1 57 | }, 58 | "inst2": { 59 | "textColour": "255,165,70", 60 | "backColour": "null", 61 | "bold": 0, 62 | "italic": 1 63 | }, 64 | "call": { 65 | "textColour": "101,132,92", 66 | "backColour": "null", 67 | "bold": 0, 68 | "italic": 1 69 | }, 70 | "jmp": { 71 | "textColour": "101,132,91", 72 | "backColour": "null", 73 | "bold": 0, 74 | "italic": 1 75 | }, 76 | "proc": { 77 | "textColour": "252,205,109", 78 | "backColour": "null", 79 | "bold": 0, 80 | "italic": 1 81 | }, 82 | "module": { 83 | "textColour": "252,205,109", 84 | "backColour": "null", 85 | "bold": 0, 86 | "italic": 1 87 | }, 88 | "param": { 89 | "textColour": "153,153,153", 90 | "backColour": "null", 91 | "bold": 0, 92 | "italic": 1 93 | }, 94 | "num": { 95 | "textColour": "255,255,128", 96 | "backColour": "null", 97 | "bold": 0, 98 | "italic": 1 99 | } 100 | , 101 | "keyword": { 102 | "textColour": "128,128,192", 103 | "backColour": "null", 104 | "bold": 0, 105 | "italic": 1 106 | }, 107 | "register": { 108 | "textColour": "128,222,84", 109 | "backColour": "null", 110 | "bold": 0, 111 | "italic": 1 112 | }, 113 | "hight": { 114 | "textColour": "19,255,192", 115 | "backColour": "null", 116 | "bold": 0, 117 | "italic": 1 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /Debug/x32/SyntaxCfg.json: -------------------------------------------------------------------------------- 1 | { 2 | "globalCfg": { 3 | "lineNumber": 1, 4 | "defTextColour": "0,0,255", 5 | "defBackColour": "40,40,40", 6 | "viewBackColour": "40,40,40", 7 | "curLineColour": "60,56,54" 8 | }, 9 | "syntaxCfg": { 10 | "addr": { 11 | "textColour": "128,255,255", 12 | "backColour": "null", 13 | "bold": 1, 14 | "italic": 1 15 | }, 16 | "error": { 17 | "textColour": "252,205,109", 18 | "backColour": "null", 19 | "bold": 1, 20 | "italic": 1 21 | }, 22 | "msg": { 23 | "textColour": "252,205,109", 24 | "backColour": "null", 25 | "bold": 0, 26 | "italic": 1 27 | }, 28 | "default": { 29 | "textColour": "252,205,109", 30 | "backColour": "null", 31 | "bold": 0, 32 | "italic": 1 33 | }, 34 | "hex": { 35 | "textColour": "252,153,60", 36 | "backColour": "null", 37 | "bold": 0, 38 | "italic": 1 39 | }, 40 | "data": { 41 | "textColour": "153,153,153", 42 | "backColour": "null", 43 | "bold": 0, 44 | "italic": 1 45 | }, 46 | "btye": { 47 | "textColour": "255,128,128", 48 | "backColour": "null", 49 | "bold": 0, 50 | "italic": 1 51 | }, 52 | "inst": { 53 | "textColour": "255,165,70", 54 | "backColour": "null", 55 | "bold": 0, 56 | "italic": 1 57 | }, 58 | "inst2": { 59 | "textColour": "255,165,70", 60 | "backColour": "null", 61 | "bold": 0, 62 | "italic": 1 63 | }, 64 | "call": { 65 | "textColour": "101,132,92", 66 | "backColour": "null", 67 | "bold": 0, 68 | "italic": 1 69 | }, 70 | "jmp": { 71 | "textColour": "101,132,91", 72 | "backColour": "null", 73 | "bold": 0, 74 | "italic": 1 75 | }, 76 | "proc": { 77 | "textColour": "252,205,109", 78 | "backColour": "null", 79 | "bold": 0, 80 | "italic": 1 81 | }, 82 | "module": { 83 | "textColour": "252,205,109", 84 | "backColour": "null", 85 | "bold": 0, 86 | "italic": 1 87 | }, 88 | "param": { 89 | "textColour": "153,153,153", 90 | "backColour": "null", 91 | "bold": 0, 92 | "italic": 1 93 | }, 94 | "num": { 95 | "textColour": "255,255,128", 96 | "backColour": "null", 97 | "bold": 0, 98 | "italic": 1 99 | } 100 | , 101 | "keyword": { 102 | "textColour": "128,128,192", 103 | "backColour": "null", 104 | "bold": 0, 105 | "italic": 1 106 | }, 107 | "register": { 108 | "textColour": "128,222,84", 109 | "backColour": "null", 110 | "bold": 0, 111 | "italic": 1 112 | }, 113 | "hight": { 114 | "textColour": "19,255,192", 115 | "backColour": "null", 116 | "bold": 0, 117 | "italic": 1 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /VDebug/view/ViewBase.h: -------------------------------------------------------------------------------- 1 | #ifndef VIEWBASE_VDEBUG_H_H_ 2 | #define VIEWBASE_VDEBUG_H_H_ 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | class CWindowBase 10 | { 11 | public: 12 | CWindowBase() 13 | { 14 | m_hwnd = NULL; 15 | ZeroMemory(&m_wndClass, sizeof(m_wndClass)); 16 | m_bRegisterSucc = FALSE; 17 | } 18 | 19 | virtual ~CWindowBase() 20 | {} 21 | 22 | virtual LRESULT OnWindowMsg(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp); 23 | virtual BOOL SetFont(HFONT hFont) 24 | { 25 | return FALSE; 26 | } 27 | 28 | virtual BOOL Refush() 29 | { 30 | return FALSE; 31 | } 32 | 33 | virtual BOOL RegisterWnd(const WNDCLASSW &WndClass) 34 | { 35 | WNDCLASSW vCurClass = WndClass; 36 | vCurClass.lpfnWndProc = WinBaseProc; 37 | WNDCLASSW vWndClass = {0}; 38 | if (!GetClassInfoW(NULL, vCurClass.lpszClassName, &vWndClass)) 39 | { 40 | if(!RegisterClassW(&vCurClass)) 41 | { 42 | return FALSE; 43 | } 44 | } 45 | m_wndClass = vCurClass; 46 | m_bRegisterSucc = TRUE; 47 | return TRUE; 48 | } 49 | 50 | virtual BOOL CreateWnd(HWND hParent, DWORD dwX, DWORD dwY, DWORD dwCX, DWORD dwCY, DWORD dwFlag) 51 | { 52 | if (!m_bRegisterSucc) 53 | { 54 | return FALSE; 55 | } 56 | 57 | extern HINSTANCE g_hInstance; 58 | m_hwnd = CreateWindowW( 59 | m_wndClass.lpszClassName, 60 | L"", 61 | WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL, 62 | dwX, dwY, 63 | dwCX, 64 | dwCY, 65 | hParent, 66 | NULL, 67 | g_hInstance, 68 | this 69 | ); 70 | return IsWindow(m_hwnd); 71 | } 72 | 73 | virtual BOOL CreateDlg(DWORD dwId, HWND hParent = NULL, BOOL bDoModule = TRUE); 74 | 75 | VOID Attach(HWND hwnd) 76 | { 77 | m_hwnd = hwnd; 78 | } 79 | 80 | HWND GetWndHandle() 81 | { 82 | return m_hwnd; 83 | } 84 | 85 | BOOL SendMsg(UINT uMsg, WPARAM wp, LPARAM lp) 86 | { 87 | if (IsWindow(m_hwnd)) 88 | { 89 | return (BOOL)SendMessageW(m_hwnd, uMsg, wp, lp); 90 | } 91 | return FALSE; 92 | } 93 | protected: 94 | HWND m_hwnd; 95 | WNDCLASSW m_wndClass; 96 | BOOL m_bRegisterSucc; 97 | 98 | protected: 99 | static map *m_pWndRegister; 100 | 101 | static VOID RegisterWnd(CWindowBase *ptr) 102 | { 103 | if (ptr && IsWindow(ptr->GetWndHandle())) 104 | { 105 | (*m_pWndRegister)[ptr->GetWndHandle()] = ptr; 106 | } 107 | } 108 | 109 | static VOID UnRegisterWnd(HWND hwnd) 110 | { 111 | if (m_pWndRegister->end() != m_pWndRegister->find(hwnd)) 112 | { 113 | m_pWndRegister->erase(hwnd); 114 | } 115 | } 116 | 117 | static CWindowBase *GetWndFromHandle(HWND hwnd) 118 | { 119 | if (m_pWndRegister->end() != m_pWndRegister->find(hwnd)) 120 | { 121 | return (*m_pWndRegister)[hwnd]; 122 | } 123 | return NULL; 124 | } 125 | 126 | static LRESULT CALLBACK WinBaseProc(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp); 127 | static INT_PTR CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wp, LPARAM lp); 128 | }; 129 | #endif -------------------------------------------------------------------------------- /ComLib/PrintFormater.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mstring.h" 3 | #include "PrintFormater.h" 4 | #include "StrUtil.h" 5 | 6 | using namespace std; 7 | 8 | PrintFormater::PrintFormater() { 9 | m_space = 2; 10 | } 11 | 12 | PrintFormater::~PrintFormater() { 13 | } 14 | 15 | void PrintFormater::SetSpaceCount(int count) { 16 | m_space = count; 17 | } 18 | 19 | bool PrintFormater::Reset() { 20 | m_matrix1.clear(); 21 | m_matrix2.clear(); 22 | return true; 23 | } 24 | 25 | bool PrintFormater::SetRule(const mstring &type) { 26 | list result = SplitStrA(type, ";"); 27 | m_rule.clear(); 28 | for (list::const_iterator it = result.begin() ; it != result.end() ; it++) 29 | { 30 | m_rule.push_back(atoi(it->c_str())); 31 | } 32 | return true; 33 | } 34 | 35 | PrintFormater &PrintFormater::operator << (const mstring &data) { 36 | if (data.empty()) 37 | { 38 | m_matrix1.push_back(" "); 39 | } else { 40 | m_matrix1.push_back(data); 41 | } 42 | return *this; 43 | } 44 | 45 | PrintFormater &PrintFormater::operator << (PrintFormatStat stat) { 46 | if (stat == line_end) 47 | { 48 | m_matrix2.push_back(m_matrix1); 49 | m_matrix1.clear(); 50 | } else if (stat == space) 51 | { 52 | m_matrix1.push_back(" "); 53 | } 54 | return *this; 55 | } 56 | 57 | bool PrintFormater::StartSession(const mstring &type) { 58 | return true; 59 | } 60 | 61 | bool PrintFormater::EndSession() { 62 | return true; 63 | } 64 | 65 | mstring PrintFormater::GetResult() { 66 | mstring result; 67 | vector resultSet = GetResultSet(); 68 | for (vector::const_iterator it = resultSet.begin() ; it != resultSet.end() ; it++) 69 | { 70 | result += *it; 71 | result += "\r\n"; 72 | } 73 | return result; 74 | } 75 | 76 | vector PrintFormater::GetResultSet() { 77 | vector result; 78 | 79 | int nodeSize = (int)m_matrix2[0].size(); 80 | int lineSize = (int)m_matrix2.size(); 81 | 82 | //init format rule 83 | while ((int)m_rule.size() < nodeSize) { 84 | m_rule.push_back(0); 85 | } 86 | int i = 0; 87 | int j = 0; 88 | for (i = 0 ; i < nodeSize ; i++) 89 | { 90 | int maxSize = 0; 91 | for (j = 0 ; j < lineSize ; j++) 92 | { 93 | if ((int)m_matrix2[j][i].size() > maxSize) 94 | { 95 | maxSize = m_matrix2[j][i].size(); 96 | } 97 | } 98 | 99 | if (m_rule[i] == 0) 100 | { 101 | m_rule[i] = maxSize; 102 | } 103 | } 104 | 105 | result.clear(); 106 | for (i = 0 ; i < lineSize ; i++) 107 | { 108 | mstring tmp; 109 | for (j = 0 ; j < nodeSize ; j++) 110 | { 111 | string node = m_matrix2[i][j]; 112 | if ((int)node.size() < m_rule[j]) 113 | { 114 | if (j != (nodeSize - 1)) 115 | { 116 | int count = m_rule[j] - node.size(); 117 | while (count > 0) { 118 | node += " "; 119 | count--; 120 | } 121 | } 122 | 123 | tmp += node; 124 | } else { 125 | tmp += node; 126 | } 127 | 128 | if (j != (nodeSize - 1)) 129 | { 130 | for (int k = 0 ; k < m_space ; k++) 131 | { 132 | tmp += " "; 133 | } 134 | } 135 | } 136 | result.push_back(tmp); 137 | } 138 | return result; 139 | } -------------------------------------------------------------------------------- /ComLib/crc32.c: -------------------------------------------------------------------------------- 1 | #include "crc32.h" 2 | 3 | unsigned long __stdcall crc32(const char* buffer, int size, unsigned long seed) 4 | { 5 | static long crc32_table[] = 6 | { 7 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 8 | 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 9 | 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 10 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 11 | 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 12 | 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 13 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 14 | 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 15 | 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 16 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 17 | 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 18 | 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 19 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 20 | 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 21 | 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 22 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 23 | 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 24 | 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 25 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 26 | 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 27 | 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 28 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 29 | 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 30 | 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 31 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 32 | 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 33 | 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 34 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 35 | 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 36 | 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 37 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 38 | 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 39 | }; 40 | 41 | unsigned long crc_val = seed; 42 | int i = 0; 43 | 44 | for (; i < size; i++) 45 | { 46 | crc_val = crc32_table[(unsigned char)(crc_val ^ (long)(((const unsigned char*)buffer)[i]))] ^ ((crc_val >> 8) & 0x00ffffff); 47 | } 48 | 49 | return ~crc_val; 50 | } 51 | -------------------------------------------------------------------------------- /ComLib/tpool.cpp: -------------------------------------------------------------------------------- 1 | #include "tpool.h" 2 | #include "LockBase.h" 3 | 4 | class ThreadPool : public CCriticalSectionLockable, public ThreadPoolBase { 5 | public: 6 | ThreadPool(int initCount = 1, int maxCount = 4); 7 | bool exec(ThreadRunable *runable); 8 | virtual ~ThreadPool(); 9 | string toString(); 10 | 11 | private: 12 | bool CreateNewThread(); 13 | 14 | private: 15 | HANDLE m_hWorkNotify; 16 | HANDLE m_hExitNotify; 17 | int m_initCount; 18 | int m_curCount; 19 | int m_freeCount; 20 | int m_maxCount; 21 | list m_runable; 22 | vector m_threadSet; 23 | static DWORD WINAPI ThreadProc(LPVOID pParam); 24 | }; 25 | 26 | ThreadPool::ThreadPool(int initCount, int maxCount) { 27 | m_hWorkNotify = CreateEventW(NULL, FALSE, FALSE, NULL); 28 | m_hExitNotify = CreateEventW(NULL, TRUE, FALSE, NULL); 29 | 30 | m_initCount = initCount; 31 | m_maxCount = maxCount; 32 | m_freeCount = initCount; 33 | m_curCount = initCount; 34 | for (int i = 0 ; i < m_initCount ; i++) 35 | { 36 | HANDLE h = CreateThread(NULL, 0, ThreadProc, this, 0, NULL); 37 | m_threadSet.push_back(h); 38 | } 39 | } 40 | 41 | ThreadPool::~ThreadPool() { 42 | SetEvent(m_hExitNotify); 43 | WaitForMultipleObjects((DWORD)m_threadSet.size(), &(m_threadSet[0]), TRUE, 3000); 44 | 45 | for (int i = 0 ; i < (int)m_threadSet.size() ; i++) 46 | { 47 | DWORD dw; 48 | GetExitCodeThread(m_threadSet[i], &dw); 49 | 50 | if (dw == STILL_ACTIVE) 51 | { 52 | TerminateThread(m_threadSet[i], 0); 53 | } 54 | } 55 | CloseHandle(m_hWorkNotify); 56 | CloseHandle(m_hExitNotify); 57 | } 58 | 59 | bool ThreadPool::CreateNewThread() { 60 | CScopedLocker lock(this); 61 | if ((m_freeCount == 0) && (m_curCount < m_maxCount)) 62 | { 63 | HANDLE h = CreateThread(NULL, 0, ThreadProc, this, 0, NULL); 64 | m_threadSet.push_back(h); 65 | m_freeCount++; 66 | m_curCount++; 67 | return true; 68 | } 69 | return false; 70 | } 71 | 72 | bool ThreadPool::exec(ThreadRunable *runable) { 73 | CScopedLocker lock(this); 74 | m_runable.push_back(runable); 75 | 76 | if (m_freeCount == 0) 77 | { 78 | CreateNewThread(); 79 | } 80 | SetEvent(m_hWorkNotify); 81 | return true; 82 | } 83 | 84 | string ThreadPool::toString() { 85 | return ""; 86 | } 87 | 88 | DWORD ThreadPool::ThreadProc(LPVOID pParam) { 89 | ThreadPool *pThis = (ThreadPool *)pParam; 90 | HANDLE arry[] = {pThis->m_hWorkNotify, pThis->m_hExitNotify}; 91 | while (true) { 92 | DWORD dw = WaitForMultipleObjects(2, arry, FALSE, INFINITE); 93 | 94 | if (dw == WAIT_OBJECT_0) 95 | { 96 | while (true) { 97 | ThreadRunable *pRunable = NULL; 98 | { 99 | CScopedLocker lock(pThis); 100 | if (pThis->m_runable.empty()) 101 | { 102 | break; 103 | } 104 | pThis->m_freeCount--; 105 | pRunable = *(pThis->m_runable.begin()); 106 | pThis->m_runable.pop_front(); 107 | } 108 | 109 | pRunable->run(); 110 | { 111 | CScopedLocker lock(pThis); 112 | delete pRunable; 113 | pThis->m_freeCount++; 114 | } 115 | } 116 | } else { 117 | break; 118 | } 119 | } 120 | return 0; 121 | } 122 | 123 | ThreadPoolBase *__stdcall GetThreadPool(int initCount, int maxCount) { 124 | return new ThreadPool(initCount, maxCount); 125 | } 126 | 127 | void __stdcall DestroyThreadPool(ThreadPoolBase *p) { 128 | delete p; 129 | } -------------------------------------------------------------------------------- /DbgCtrl/DbgStat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DbgStat.h" 3 | 4 | using namespace std; 5 | 6 | CDbgStatMgr *CDbgStatMgr::GetInst() { 7 | static CDbgStatMgr *s_ptr = NULL; 8 | 9 | if (NULL == s_ptr) 10 | { 11 | s_ptr = new CDbgStatMgr(); 12 | } 13 | return s_ptr; 14 | } 15 | 16 | CDbgStatMgr::CDbgStatMgr() { 17 | mNotifyThread = NULL; 18 | mSerial = 0xff11; 19 | } 20 | 21 | BOOL CDbgStatMgr::InitStatMgr(const std::mstring &unique) { 22 | mUnique = unique; 23 | mCachePath = FormatA("%hs\\%hs", REG_VDEBUG_STATUS, unique.c_str()); 24 | mstring eventName = FormatA("Global\\%hs_StatusNotify", unique.c_str()); 25 | 26 | mNotifyEvent = OpenEventA(EVENT_ALL_ACCESS, FALSE, eventName.c_str()); 27 | 28 | if (mNotifyEvent == NULL) 29 | { 30 | mNotifyEvent = CreateLowsdEvent(FALSE, FALSE, eventName.c_str()); 31 | } 32 | dp(L"event:%p", mNotifyEvent); 33 | return TRUE; 34 | } 35 | 36 | CDbgStatMgr::~CDbgStatMgr() { 37 | } 38 | 39 | BOOL CDbgStatMgr::ReportDbgStatus(const DbgStat &status) { 40 | Value root; 41 | root["dbggerType"] = status.mDbggerType; 42 | root["dbggerStatus"] = status.mDbggerStatus; 43 | root["curThread"] = (int)status.mCurTid; 44 | 45 | mstring desc = FastWriter().write(root); 46 | mstring time = GetCurTimeStr1("%04d-%02d-%02d %02d:%02d:%02d %03d"); 47 | 48 | RegSetStrValueA( 49 | HKEY_LOCAL_MACHINE, 50 | mCachePath.c_str(), 51 | "desc", 52 | desc.c_str() 53 | ); 54 | RegSetStrValueA( 55 | HKEY_LOCAL_MACHINE, 56 | mCachePath.c_str(), 57 | "stamp", 58 | time.c_str() 59 | ); 60 | SetEvent(mNotifyEvent); 61 | return TRUE; 62 | } 63 | 64 | DbgStat CDbgStatMgr::ParserStatDesc(const mstring &desc) const { 65 | DbgStat stat; 66 | 67 | if (desc.empty()) 68 | { 69 | return stat; 70 | } 71 | 72 | Value root; 73 | Reader().parse(desc, root); 74 | stat.mDbggerType = (DbggerType)root["dbggerType"].asInt(); 75 | stat.mDbggerStatus = (DbggerStatus)root["dbggerStatus"].asInt(); 76 | stat.mCurTid = root["curThread"].asInt(); 77 | return stat; 78 | } 79 | 80 | HDbgStatus CDbgStatMgr::RegisterStatusNotify(pfnDbgStatusNotifyProc pfn, void *param) { 81 | DbgStatRegisterInfo newInfo; 82 | newInfo.mIndex = mSerial++; 83 | newInfo.mNotifyProc = pfn; 84 | newInfo.mParam = param; 85 | mRegisterCache.push_back(newInfo); 86 | 87 | if (!mNotifyThread) 88 | { 89 | mNotifyThread = CreateThread(NULL, 0, NotifyThread, NULL, 0, NULL); 90 | } 91 | return newInfo.mIndex; 92 | } 93 | 94 | void CDbgStatMgr::UnRegisterStatusNotify(HDbgStatus index) { 95 | for (list::const_iterator it = mRegisterCache.begin() ; it != mRegisterCache.end() ; it++) 96 | { 97 | if (it->mIndex == index) 98 | { 99 | mRegisterCache.erase(it); 100 | return; 101 | } 102 | } 103 | } 104 | 105 | void CDbgStatMgr::OnDispatchStat() { 106 | mstring desc = RegGetStrValueExA(HKEY_LOCAL_MACHINE, mCachePath.c_str(), "desc"); 107 | 108 | if (!desc.empty() && desc != mStatDesc) 109 | { 110 | DbgStat stat = ParserStatDesc(desc); 111 | for (list::const_iterator it = mRegisterCache.begin() ; it != mRegisterCache.end() ; it++) 112 | { 113 | it->mNotifyProc(stat, it->mParam); 114 | } 115 | mStatDesc = desc; 116 | } 117 | } 118 | 119 | DWORD CDbgStatMgr::NotifyThread(LPVOID pParam) { 120 | while (TRUE) { 121 | GetInst()->OnDispatchStat(); 122 | 123 | WaitForSingleObject(GetInst()->mNotifyEvent, 1000 * 10); 124 | } 125 | } -------------------------------------------------------------------------------- /DbgCtrl/DbgClient.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "DbgClient.h" 5 | #include "DbgCtrlTool.h" 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | using namespace Json; 12 | 13 | struct DbgClientCache { 14 | string m_CtrlCode; 15 | void *m_param; 16 | pfnDbgClientProc m_proc; 17 | int m_idex; 18 | }; 19 | 20 | class DbgClient : public DbgClientBase, public CCriticalSectionLockable { 21 | public: 22 | DbgClient(); 23 | virtual ~DbgClient(); 24 | virtual bool InitClient(DbggerType type, const mstring &unique); 25 | virtual HDbgCtrl RegisterCtrlHandler(const std::mstring &cmd, pfnDbgClientProc pfn, void *param); 26 | virtual bool ReportDbgEvent(const EventInfo &eventInfo); 27 | 28 | private: 29 | static LPCSTR WINAPI ClientNotify(LPCSTR szChannel, LPCSTR szContent, void *pParam); 30 | 31 | private: 32 | bool m_init; 33 | DbggerType m_type; 34 | mstring m_unique; 35 | unsigned short m_ServPort; 36 | long m_curIndex; 37 | map> m_RegisterSet; 38 | }; 39 | 40 | DbgClientBase *DbgClientBase::newInstance() { 41 | return new DbgClient(); 42 | } 43 | 44 | DbgClient::DbgClient() : 45 | m_init(false), 46 | m_type(em_dbg_proc86), 47 | m_ServPort(6010), 48 | m_curIndex(0xffab){ 49 | } 50 | 51 | DbgClient ::~DbgClient() { 52 | } 53 | 54 | bool DbgClient::InitClient(DbggerType type, const mstring &unique) { 55 | if (m_init) 56 | { 57 | return true; 58 | } 59 | 60 | m_unique = unique; 61 | m_ServPort = CalPortFormUnique(unique); 62 | m_type = type; 63 | 64 | mstring channel; 65 | switch (type) { 66 | case em_dbg_proc86: 67 | channel = CHANNEL_RPOC32; 68 | break; 69 | case em_dbg_proc64: 70 | channel = CHANNEL_RPOC64; 71 | break; 72 | case em_dbg_dump86: 73 | channel = CHANNEL_DUMP32; 74 | break; 75 | case em_dbg_dump64: 76 | channel = CHANNEL_DUMP64; 77 | break; 78 | } 79 | 80 | MsgInitClient(m_ServPort); 81 | MsgRegister(channel.c_str(), ClientNotify, this); 82 | return true; 83 | } 84 | 85 | bool DbgClient::ReportDbgEvent(const EventInfo &eventInfo) { 86 | MsgSend(CHANNEL_PROC_SERVER, MakeEvent(eventInfo).c_str()); 87 | return true; 88 | } 89 | 90 | HDbgCtrl DbgClient::RegisterCtrlHandler(const mstring &cmd, pfnDbgClientProc pfn, void *param) { 91 | CScopedLocker lock(this); 92 | DbgClientCache *cache = new DbgClientCache(); 93 | cache->m_CtrlCode = cmd; 94 | cache->m_proc = pfn; 95 | cache->m_param = param; 96 | cache->m_idex = m_curIndex++; 97 | m_RegisterSet[cmd].push_back(cache); 98 | return cache->m_idex ; 99 | } 100 | 101 | LPCSTR DbgClient::ClientNotify(LPCSTR szChannel, LPCSTR szContent, void *pParam) { 102 | DbgClient *pThis = (DbgClient *)pParam; 103 | 104 | Value json; 105 | Reader().parse(szContent, json); 106 | string result; 107 | 108 | do 109 | { 110 | if (json.type() != objectValue) 111 | { 112 | break; 113 | } 114 | 115 | mstring type = json["type"].asString(); 116 | 117 | if (type == "ctrl") 118 | { 119 | CtrlRequest request = ParserRequest(szContent); 120 | CScopedLocker lock(pThis); 121 | map>::const_iterator it; 122 | it = pThis->m_RegisterSet.find(request.mCmd); 123 | 124 | if (it == pThis->m_RegisterSet.end()) 125 | { 126 | break; 127 | } 128 | 129 | const list &tmp = it->second; 130 | for (list::const_iterator ij = tmp.begin() ; ij != tmp.end() ; ij++) 131 | { 132 | DbgClientCache *ptr = *ij; 133 | CtrlReply reply = ptr->m_proc(request, ptr->m_param); 134 | result = MakeReply(reply); 135 | } 136 | } 137 | } while (FALSE); 138 | return MsgStrCopy(result.c_str()); 139 | } -------------------------------------------------------------------------------- /dbg/capstone/platform.h: -------------------------------------------------------------------------------- 1 | /* Capstone Disassembly Engine */ 2 | /* By Axel Souchet & Nguyen Anh Quynh, 2014 */ 3 | 4 | #ifndef CAPSTONE_PLATFORM_H 5 | #define CAPSTONE_PLATFORM_H 6 | 7 | 8 | // handle C99 issue (for pre-2013 VisualStudio) 9 | #if !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) 10 | // MSVC 11 | 12 | // stdbool.h 13 | #if (_MSC_VER < 1800) || defined(_KERNEL_MODE) 14 | // this system does not have stdbool.h 15 | #ifndef __cplusplus 16 | typedef unsigned char bool; 17 | #define false 0 18 | #define true 1 19 | #endif // __cplusplus 20 | 21 | #else 22 | // VisualStudio 2013+ -> C99 is supported 23 | #include 24 | #endif // (_MSC_VER < 1800) || defined(_KERNEL_MODE) 25 | 26 | #else 27 | // not MSVC -> C99 is supported 28 | #include 29 | #endif // !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) 30 | 31 | 32 | // handle inttypes.h / stdint.h compatibility 33 | #if defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) 34 | #include "windowsce/stdint.h" 35 | #endif // defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) 36 | 37 | #if defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) 38 | // this system does not have inttypes.h 39 | 40 | #if defined(_MSC_VER) && (_MSC_VER < 1600 || defined(_KERNEL_MODE)) 41 | // this system does not have stdint.h 42 | typedef signed char int8_t; 43 | typedef signed short int16_t; 44 | typedef signed int int32_t; 45 | typedef unsigned char uint8_t; 46 | typedef unsigned short uint16_t; 47 | typedef unsigned int uint32_t; 48 | typedef signed long long int64_t; 49 | typedef unsigned long long uint64_t; 50 | 51 | #define INT8_MIN (-127i8 - 1) 52 | #define INT16_MIN (-32767i16 - 1) 53 | #define INT32_MIN (-2147483647i32 - 1) 54 | #define INT64_MIN (-9223372036854775807i64 - 1) 55 | #define INT8_MAX 127i8 56 | #define INT16_MAX 32767i16 57 | #define INT32_MAX 2147483647i32 58 | #define INT64_MAX 9223372036854775807i64 59 | #define UINT8_MAX 0xffui8 60 | #define UINT16_MAX 0xffffui16 61 | #define UINT32_MAX 0xffffffffui32 62 | #define UINT64_MAX 0xffffffffffffffffui64 63 | #endif // defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE)) 64 | 65 | #define __PRI_8_LENGTH_MODIFIER__ "hh" 66 | #define __PRI_64_LENGTH_MODIFIER__ "ll" 67 | 68 | #define PRId8 __PRI_8_LENGTH_MODIFIER__ "d" 69 | #define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i" 70 | #define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o" 71 | #define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u" 72 | #define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x" 73 | #define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X" 74 | 75 | #define PRId16 "hd" 76 | #define PRIi16 "hi" 77 | #define PRIo16 "ho" 78 | #define PRIu16 "hu" 79 | #define PRIx16 "hx" 80 | #define PRIX16 "hX" 81 | 82 | #if defined(_MSC_VER) && _MSC_VER <= 1700 83 | #define PRId32 "ld" 84 | #define PRIi32 "li" 85 | #define PRIo32 "lo" 86 | #define PRIu32 "lu" 87 | #define PRIx32 "lx" 88 | #define PRIX32 "lX" 89 | #else // OSX 90 | #define PRId32 "d" 91 | #define PRIi32 "i" 92 | #define PRIo32 "o" 93 | #define PRIu32 "u" 94 | #define PRIx32 "x" 95 | #define PRIX32 "X" 96 | #endif // defined(_MSC_VER) && _MSC_VER <= 1700 97 | 98 | #if defined(_MSC_VER) && _MSC_VER <= 1700 99 | // redefine functions from inttypes.h used in cstool 100 | #define strtoull _strtoui64 101 | #endif 102 | 103 | #define PRId64 __PRI_64_LENGTH_MODIFIER__ "d" 104 | #define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i" 105 | #define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o" 106 | #define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u" 107 | #define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x" 108 | #define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X" 109 | 110 | #else 111 | // this system has inttypes.h by default 112 | #include 113 | #endif // defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /VDebug/SyntaxHlpr/include/ILexer.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file ILexer.h 3 | ** Interface between Scintilla and lexers. 4 | **/ 5 | // Copyright 1998-2010 by Neil Hodgson 6 | // The License.txt file describes the conditions under which this software may be distributed. 7 | 8 | #ifndef ILEXER_H 9 | #define ILEXER_H 10 | 11 | #ifdef SCI_NAMESPACE 12 | namespace Scintilla { 13 | #endif 14 | #include "../SyntaxLabel.h" 15 | 16 | #ifdef _WIN32 17 | #define SCI_METHOD __stdcall 18 | #else 19 | #define SCI_METHOD 20 | #endif 21 | 22 | enum { dvOriginal=0, dvLineEnd=1 }; 23 | 24 | class IDocument { 25 | public: 26 | IDocument() { 27 | CSyntaxLabel::RegisterLabel(this); 28 | } 29 | 30 | virtual ~IDocument() { 31 | CSyntaxLabel::UnRegisterLabel(this); 32 | } 33 | 34 | virtual int SCI_METHOD Version() const = 0; 35 | virtual void SCI_METHOD SetErrorStatus(int status) = 0; 36 | virtual int SCI_METHOD Length() const = 0; 37 | virtual void SCI_METHOD GetCharRange(char *buffer, int position, int lengthRetrieve) const = 0; 38 | virtual char SCI_METHOD StyleAt(int position) const = 0; 39 | virtual int SCI_METHOD LineFromPosition(int position) const = 0; 40 | virtual int SCI_METHOD LineStart(int line) const = 0; 41 | virtual int SCI_METHOD GetLevel(int line) const = 0; 42 | virtual int SCI_METHOD SetLevel(int line, int level) = 0; 43 | virtual int SCI_METHOD GetLineState(int line) const = 0; 44 | virtual int SCI_METHOD SetLineState(int line, int state) = 0; 45 | virtual void SCI_METHOD StartStyling(int position, char mask) = 0; 46 | virtual bool SCI_METHOD SetStyleFor(int length, char style) = 0; 47 | virtual bool SCI_METHOD SetStyles(int length, const char *styles) = 0; 48 | virtual void SCI_METHOD DecorationSetCurrentIndicator(int indicator) = 0; 49 | virtual void SCI_METHOD DecorationFillRange(int position, int value, int fillLength) = 0; 50 | virtual void SCI_METHOD ChangeLexerState(int start, int end) = 0; 51 | virtual int SCI_METHOD CodePage() const = 0; 52 | virtual bool SCI_METHOD IsDBCSLeadByte(char ch) const = 0; 53 | virtual const char * SCI_METHOD BufferPointer() = 0; 54 | virtual int SCI_METHOD GetLineIndentation(int line) = 0; 55 | }; 56 | 57 | class IDocumentWithLineEnd : public IDocument { 58 | public: 59 | virtual int SCI_METHOD LineEnd(int line) const = 0; 60 | virtual int SCI_METHOD GetRelativePosition(int positionStart, int characterOffset) const = 0; 61 | virtual int SCI_METHOD GetCharacterAndWidth(int position, int *pWidth) const = 0; 62 | }; 63 | 64 | enum { lvOriginal=0, lvSubStyles=1 }; 65 | 66 | class ILexer { 67 | public: 68 | virtual int SCI_METHOD Version() const = 0; 69 | virtual void SCI_METHOD Release() = 0; 70 | virtual const char * SCI_METHOD PropertyNames() = 0; 71 | virtual int SCI_METHOD PropertyType(const char *name) = 0; 72 | virtual const char * SCI_METHOD DescribeProperty(const char *name) = 0; 73 | virtual int SCI_METHOD PropertySet(const char *key, const char *val) = 0; 74 | virtual const char * SCI_METHOD DescribeWordListSets() = 0; 75 | virtual int SCI_METHOD WordListSet(int n, const char *wl) = 0; 76 | virtual void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) = 0; 77 | virtual void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) = 0; 78 | virtual void * SCI_METHOD PrivateCall(int operation, void *pointer) = 0; 79 | }; 80 | 81 | class ILexerWithSubStyles : public ILexer { 82 | public: 83 | virtual int SCI_METHOD LineEndTypesSupported() = 0; 84 | virtual int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) = 0; 85 | virtual int SCI_METHOD SubStylesStart(int styleBase) = 0; 86 | virtual int SCI_METHOD SubStylesLength(int styleBase) = 0; 87 | virtual int SCI_METHOD StyleFromSubStyle(int subStyle) = 0; 88 | virtual int SCI_METHOD PrimaryStyleFromStyle(int style) = 0; 89 | virtual void SCI_METHOD FreeSubStyles() = 0; 90 | virtual void SCI_METHOD SetIdentifiers(int style, const char *identifiers) = 0; 91 | virtual int SCI_METHOD DistanceToSecondaryStyles() = 0; 92 | virtual const char * SCI_METHOD GetSubStyleBases() = 0; 93 | }; 94 | 95 | class ILoader { 96 | public: 97 | virtual int SCI_METHOD Release() = 0; 98 | // Returns a status code from SC_STATUS_* 99 | virtual int SCI_METHOD AddData(char *data, int length) = 0; 100 | virtual void * SCI_METHOD ConvertToDocument() = 0; 101 | }; 102 | 103 | #ifdef SCI_NAMESPACE 104 | } 105 | #endif 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /ComLib/json/json_batchallocator.h: -------------------------------------------------------------------------------- 1 | #ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED 2 | # define JSONCPP_BATCHALLOCATOR_H_INCLUDED 3 | 4 | # include 5 | # include 6 | 7 | # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 8 | 9 | namespace Json { 10 | 11 | /* Fast memory allocator. 12 | * 13 | * This memory allocator allocates memory for a batch of object (specified by 14 | * the page size, the number of object in each page). 15 | * 16 | * It does not allow the destruction of a single object. All the allocated objects 17 | * can be destroyed at once. The memory can be either released or reused for future 18 | * allocation. 19 | * 20 | * The in-place new operator must be used to construct the object using the pointer 21 | * returned by allocate. 22 | */ 23 | template 25 | class BatchAllocator 26 | { 27 | public: 28 | typedef AllocatedType Type; 29 | 30 | BatchAllocator( unsigned int objectsPerPage = 255 ) 31 | : freeHead_( 0 ) 32 | , objectsPerPage_( objectsPerPage ) 33 | { 34 | // printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() ); 35 | assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space. 36 | assert( objectsPerPage >= 16 ); 37 | batches_ = allocateBatch( 0 ); // allocated a dummy page 38 | currentBatch_ = batches_; 39 | } 40 | 41 | ~BatchAllocator() 42 | { 43 | for ( BatchInfo *batch = batches_; batch; ) 44 | { 45 | BatchInfo *nextBatch = batch->next_; 46 | free( batch ); 47 | batch = nextBatch; 48 | } 49 | } 50 | 51 | /// allocate space for an array of objectPerAllocation object. 52 | /// @warning it is the responsability of the caller to call objects constructors. 53 | AllocatedType *allocate() 54 | { 55 | if ( freeHead_ ) // returns node from free list. 56 | { 57 | AllocatedType *object = freeHead_; 58 | freeHead_ = *(AllocatedType **)object; 59 | return object; 60 | } 61 | if ( currentBatch_->used_ == currentBatch_->end_ ) 62 | { 63 | currentBatch_ = currentBatch_->next_; 64 | while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ ) 65 | currentBatch_ = currentBatch_->next_; 66 | 67 | if ( !currentBatch_ ) // no free batch found, allocate a new one 68 | { 69 | currentBatch_ = allocateBatch( objectsPerPage_ ); 70 | currentBatch_->next_ = batches_; // insert at the head of the list 71 | batches_ = currentBatch_; 72 | } 73 | } 74 | AllocatedType *allocated = currentBatch_->used_; 75 | currentBatch_->used_ += objectPerAllocation; 76 | return allocated; 77 | } 78 | 79 | /// Release the object. 80 | /// @warning it is the responsability of the caller to actually destruct the object. 81 | void release( AllocatedType *object ) 82 | { 83 | assert( object != 0 ); 84 | *(AllocatedType **)object = freeHead_; 85 | freeHead_ = object; 86 | } 87 | 88 | private: 89 | struct BatchInfo 90 | { 91 | BatchInfo *next_; 92 | AllocatedType *used_; 93 | AllocatedType *end_; 94 | AllocatedType buffer_[objectPerAllocation]; 95 | }; 96 | 97 | // disabled copy constructor and assignement operator. 98 | BatchAllocator( const BatchAllocator & ); 99 | void operator =( const BatchAllocator &); 100 | 101 | static BatchInfo *allocateBatch( unsigned int objectsPerPage ) 102 | { 103 | const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation 104 | + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage; 105 | BatchInfo *batch = static_cast( malloc( mallocSize ) ); 106 | batch->next_ = 0; 107 | batch->used_ = batch->buffer_; 108 | batch->end_ = batch->buffer_ + objectsPerPage; 109 | return batch; 110 | } 111 | 112 | BatchInfo *batches_; 113 | BatchInfo *currentBatch_; 114 | /// Head of a single linked list within the allocated space of freeed object 115 | AllocatedType *freeHead_; 116 | unsigned int objectsPerPage_; 117 | }; 118 | 119 | 120 | } // namespace Json 121 | 122 | # endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION 123 | 124 | #endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED 125 | 126 | -------------------------------------------------------------------------------- /ComLib/SqliteOperator.cpp: -------------------------------------------------------------------------------- 1 | #include "SqliteOperator.h" 2 | 3 | using namespace std; 4 | 5 | SqliteIterator::SqliteIterator() { 6 | mData = NULL; 7 | } 8 | 9 | SqliteIterator::SqliteIterator(const SqliteIterator ©) { 10 | mData = copy.mData; 11 | } 12 | 13 | SqliteIterator::SqliteIterator(const IteratorCache *it) { 14 | mData = it; 15 | } 16 | 17 | SqliteIterator::~SqliteIterator() { 18 | } 19 | 20 | SqliteIterator &SqliteIterator::operator=(const SqliteIterator ©) { 21 | mData = copy.mData; 22 | return *this; 23 | } 24 | 25 | SqliteIterator SqliteIterator::operator++() { 26 | mData = mData->mNext; 27 | return *this; 28 | } 29 | 30 | bool SqliteIterator::operator!=(const SqliteIterator &dst) { 31 | return (mData != dst.mData); 32 | } 33 | 34 | mstring SqliteIterator::GetValue(const mstring &name) { 35 | map::const_iterator it = mData->mCurData.find(name); 36 | if (mData->mCurData.end() != it) 37 | { 38 | return it->second; 39 | } 40 | return ""; 41 | } 42 | 43 | SqliteIterator SqliteIterator::GetNext() { 44 | return mData->mNext; 45 | } 46 | 47 | SqliteResult::SqliteResult() { 48 | } 49 | 50 | void SqliteResult::SetResult(const std::list *resultSet) { 51 | mResultSet = resultSet; 52 | } 53 | 54 | bool SqliteResult::IsValid() { 55 | return mResultSet != NULL && !mResultSet->empty(); 56 | } 57 | 58 | bool SqliteResult::IsEmpty() { 59 | return !IsValid(); 60 | } 61 | 62 | SqliteIterator SqliteResult::begin() { 63 | if (mResultSet == NULL || mResultSet->empty()) 64 | { 65 | return NULL; 66 | } 67 | 68 | return *(mResultSet->begin()); 69 | } 70 | 71 | SqliteIterator SqliteResult::end() { 72 | return NULL; 73 | } 74 | 75 | SqliteOperator::SqliteOperator() { 76 | mInit = false; 77 | mDb = NULL; 78 | } 79 | 80 | SqliteOperator::SqliteOperator(const std::mstring &filePath) { 81 | Open(filePath); 82 | } 83 | 84 | bool SqliteOperator::IsOpen() { 85 | return (mDb != NULL); 86 | } 87 | 88 | SqliteOperator::~SqliteOperator() { 89 | Close(); 90 | Clear(); 91 | } 92 | 93 | void SqliteOperator::Clear() { 94 | for (list::iterator it = mCacheSet.begin() ; it != mCacheSet.end() ; it++) 95 | { 96 | delete (*it); 97 | } 98 | mCacheSet.clear(); 99 | } 100 | 101 | int SqliteOperator::SelectCallback(void *data, int argc, char **argv, char **name) { 102 | SqliteOperator *ptr = (SqliteOperator *)data; 103 | IteratorCache *newData = new IteratorCache(); 104 | newData->mNext = NULL; 105 | for (int i = 0 ; i < argc ; i++) 106 | { 107 | newData->mCurData.insert(make_pair(name[i], argv[i])); 108 | } 109 | 110 | if (!ptr->mCacheSet.empty()) 111 | { 112 | IteratorCache *endNode = *(ptr->mCacheSet.rbegin()); 113 | endNode->mNext = newData; 114 | } 115 | ptr->mCacheSet.push_back(newData); 116 | return 0; 117 | } 118 | 119 | bool SqliteOperator::Open(const std::mstring &filePath) { 120 | mInit = (0 == sqlite3_open(filePath.c_str(), &mDb)); 121 | return mInit; 122 | } 123 | 124 | void SqliteOperator::Close() { 125 | if (mDb) 126 | { 127 | sqlite3_close(mDb); 128 | mDb = NULL; 129 | } 130 | } 131 | 132 | SqliteResult &SqliteOperator::Select(const std::mstring &sql) { 133 | char *err = NULL; 134 | Clear(); 135 | if (SQLITE_OK != sqlite3_exec(mDb, sql.c_str(), SelectCallback, this, &err)) 136 | { 137 | throw SqliteException(err); 138 | } 139 | mResult.SetResult(&mCacheSet); 140 | return mResult; 141 | } 142 | 143 | bool SqliteOperator::Update(const std::mstring &sql) { 144 | Exec(sql.c_str()); 145 | return true; 146 | } 147 | 148 | bool SqliteOperator::Delete(const std::mstring &sql) { 149 | Exec(sql.c_str()); 150 | return true; 151 | } 152 | 153 | bool SqliteOperator::Insert(const std::mstring &sql) { 154 | Exec(sql.c_str()); 155 | return true; 156 | } 157 | 158 | bool SqliteOperator::Exec(const std::mstring &sql) { 159 | char *err = NULL; 160 | if (SQLITE_OK != sqlite3_exec(mDb, sql.c_str(), NULL, NULL, &err)) 161 | { 162 | throw SqliteException(err); 163 | } 164 | 165 | mError = err; 166 | return true; 167 | } 168 | 169 | mstring SqliteOperator::GetError() { 170 | return mError; 171 | } 172 | 173 | bool SqliteOperator::TransBegin() { 174 | return true; 175 | } 176 | 177 | bool SqliteOperator::TransSubmit() { 178 | return true; 179 | } -------------------------------------------------------------------------------- /mq/msgclient.cpp: -------------------------------------------------------------------------------- 1 | #include "msgclient.h" 2 | #include 3 | 4 | #pragma comment(lib, "Ws2_32.lib") 5 | 6 | CMsgClient::CMsgClient() : 7 | m_pListener(NULL), 8 | m_bInit(false), 9 | m_bStop(false), 10 | m_hRecvThread(NULL), 11 | m_clientSock(INVALID_SOCKET), 12 | m_uServPort(0), 13 | m_bTestConnent(false) { 14 | } 15 | 16 | bool CMsgClient::Connect(const string &strIp, unsigned short uPort, int iTimeOut) { 17 | unsigned long ul = 1; 18 | ioctlsocket(m_clientSock, FIONBIO, (unsigned long*)&ul); 19 | SOCKADDR_IN servAddr ; 20 | servAddr.sin_family = AF_INET ; 21 | servAddr.sin_port = htons(uPort); 22 | servAddr.sin_addr.S_un.S_addr = inet_addr(strIp.c_str()); 23 | 24 | connect(m_clientSock, (sockaddr *)&servAddr, sizeof(servAddr)); 25 | 26 | struct timeval timeout; 27 | fd_set r; 28 | FD_ZERO(&r); 29 | FD_SET(m_clientSock, &r); 30 | timeout.tv_sec = iTimeOut / 1000; 31 | timeout.tv_usec = 0; 32 | int ret = 0; 33 | select(0, 0, &r, 0, &timeout); 34 | 35 | bool bStat = false; 36 | if (FD_ISSET(m_clientSock, &r)) 37 | { 38 | bStat = true; 39 | } else { 40 | bStat = false; 41 | } 42 | unsigned long ul1= 0 ; 43 | ioctlsocket(m_clientSock, FIONBIO, (unsigned long*)&ul1); 44 | if (false == bStat) 45 | { 46 | LOGGER_ERROR(L"ioctlsocket err:%d", WSAGetLastError()); 47 | closesocket(m_clientSock); 48 | m_clientSock = INVALID_SOCKET; 49 | return false; 50 | } 51 | return true; 52 | } 53 | 54 | bool CMsgClient::InitClient(const string &strIp, unsigned short uPort, ClientEvent *pListener, int iTimeOut) { 55 | if (m_bInit) 56 | { 57 | return true; 58 | } 59 | 60 | m_bStop = false; 61 | m_clientSock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); 62 | if (INVALID_SOCKET == m_clientSock) 63 | { 64 | return false; 65 | } 66 | 67 | m_strSerIp = strIp; 68 | m_uServPort = uPort; 69 | m_pListener = pListener; 70 | if (Connect(strIp, uPort, iTimeOut)) { 71 | m_bInit = true; 72 | m_hRecvThread = CreateThread(NULL, 0, RecvThread, this, 0, NULL); 73 | m_pListener->OnClientConnect(*this); 74 | return true; 75 | } 76 | return false; 77 | } 78 | 79 | bool CMsgClient::Send(const string &strMsg) const { 80 | if (!m_bInit) { 81 | return false; 82 | } 83 | ::send(m_clientSock, strMsg.c_str(), static_cast(strMsg.size()), 0); 84 | return true; 85 | } 86 | 87 | void CMsgClient::Close() { 88 | if (m_bInit && INVALID_SOCKET != m_clientSock) 89 | { 90 | m_bStop = true; 91 | ::closesocket(m_clientSock); 92 | 93 | if (WAIT_TIMEOUT == WaitForSingleObject(m_hRecvThread, 3000)) 94 | { 95 | TerminateThread(m_hRecvThread, 0); 96 | } 97 | CloseHandle(m_hRecvThread); 98 | m_hRecvThread = NULL; 99 | m_clientSock = INVALID_SOCKET; 100 | m_bInit = false; 101 | } 102 | } 103 | 104 | bool CMsgClient::TestConnect() { 105 | m_clientSock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); 106 | LOGGER_PRINT(L"test connect ip:%hs, port:%d", m_strSerIp.c_str(), m_uServPort); 107 | if (Connect(m_strSerIp, m_uServPort, 3000)) 108 | { 109 | m_bTestConnent = false; 110 | m_pListener->OnClientConnect(*this); 111 | return true; 112 | } else { 113 | m_bTestConnent = true; 114 | return false; 115 | } 116 | } 117 | 118 | DWORD CMsgClient::RecvThread(LPVOID pParam) { 119 | CMsgClient *pThis = (CMsgClient *)pParam; 120 | 121 | char buffer[2048]; 122 | int iRecv = 0; 123 | while (true) { 124 | if (pThis->m_bTestConnent) 125 | { 126 | if (!pThis->TestConnect()) 127 | { 128 | LOGGER_ERROR(L"test connect err:%d", WSAGetLastError()); 129 | Sleep(1000); 130 | continue; 131 | } 132 | } 133 | 134 | if ((iRecv = ::recv(pThis->m_clientSock, buffer, sizeof(buffer), 0)) > 0) { 135 | string strResp; 136 | pThis->m_pListener->OnClientRecvData(*pThis, string(buffer, iRecv), strResp); 137 | 138 | if (!strResp.empty()) 139 | { 140 | pThis->Send(strResp); 141 | } 142 | } else { 143 | LOGGER_ERROR(L"recv data err:%d", WSAGetLastError()); 144 | pThis->m_pListener->OnClientSocketErr(*pThis); 145 | //close for socket err and test connect again 146 | closesocket(pThis->m_clientSock); 147 | pThis->m_clientSock = INVALID_SOCKET; 148 | pThis->m_bTestConnent = true; 149 | 150 | if (pThis->m_bStop) { 151 | LOGGER_PRINT(L"stop socket"); 152 | break; 153 | } 154 | } 155 | } 156 | return 0; 157 | } -------------------------------------------------------------------------------- /DbgCtrl/DbgService.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "DbgProtocol.h" 8 | #include "DbgService.h" 9 | #include "DbgCtrlTool.h" 10 | 11 | using namespace std; 12 | using namespace Json; 13 | 14 | struct DbgServiceCache { 15 | string m_event; 16 | void *m_param; 17 | pfnDbgEventProc m_proc; 18 | int m_idex; 19 | }; 20 | 21 | class DbgService : public DbgServiceBase, CCriticalSectionLockable { 22 | public: 23 | DbgService(); 24 | virtual ~DbgService(); 25 | virtual bool InitDbgService(const mstring &unique); 26 | virtual CtrlReply DispatchCurDbgger(const CtrlRequest &request); 27 | virtual CtrlReply DispatchSpecDbgger(DbggerType type, const CtrlRequest &request); 28 | virtual HDbgCtrl RegisterDbgEvent(const std::mstring &dbgEvent, pfnDbgEventProc pfn, void *param); 29 | virtual bool SetActivity(DbggerType type); 30 | 31 | private: 32 | std::mstring GetSpecChannel(DbggerType type) const; 33 | bool DispatchEventToRegister(const EventInfo &info) const; 34 | static LPCSTR WINAPI ServerNotify(LPCSTR wszChannel, LPCSTR wszContent, void *pParam); 35 | 36 | private: 37 | map> m_RegisterSet; 38 | string m_unique; 39 | unsigned short m_port; 40 | long m_curIndex; 41 | string m_curChannel; 42 | DbggerType m_DbgClient; 43 | }; 44 | 45 | DbgService::DbgService() :m_port(0), m_curIndex(0xffea){ 46 | } 47 | 48 | DbgService::~DbgService() { 49 | } 50 | 51 | LPCSTR DbgService::ServerNotify(LPCSTR szChannel, LPCSTR szContent, void *pParam) { 52 | string result; 53 | DbgService *pThis = (DbgService *)pParam; 54 | 55 | do 56 | { 57 | if (0 == lstrcmpA(szChannel, CHANNEL_PROC_SERVER)) 58 | { 59 | Value json; 60 | Reader().parse(szContent, json); 61 | 62 | mstring type = json["type"].asString(); 63 | 64 | if (type == "event") 65 | { 66 | EventInfo eventInfo = ParserEvent(szContent); 67 | pThis->DispatchEventToRegister(eventInfo); 68 | } 69 | } else { 70 | } 71 | } while (false); 72 | return MsgStrCopy(result.c_str()); 73 | } 74 | 75 | bool DbgService::DispatchEventToRegister(const EventInfo &eventInfo) const { 76 | map>::const_iterator it = m_RegisterSet.find(eventInfo.mEvent); 77 | 78 | if (it == m_RegisterSet.end()) 79 | { 80 | return false; 81 | } 82 | 83 | for (list::const_iterator ij = it->second.begin() ; ij != it->second.end() ; ij++) 84 | { 85 | DbgServiceCache *ptr = *ij; 86 | ptr->m_proc(eventInfo, ptr->m_param); 87 | } 88 | return true; 89 | } 90 | 91 | bool DbgService::InitDbgService(const mstring &unique) { 92 | m_unique = unique; 93 | m_port = CalPortFormUnique(unique); 94 | 95 | MsgInitServ(m_port); 96 | MsgInitClient(m_port); 97 | MsgRegister(CHANNEL_PROC_SERVER, ServerNotify, this); 98 | return true; 99 | } 100 | 101 | CtrlReply DbgService::DispatchCurDbgger(const CtrlRequest &request) { 102 | return DispatchSpecDbgger(m_DbgClient, request); 103 | } 104 | 105 | CtrlReply DbgService::DispatchSpecDbgger(DbggerType type, const CtrlRequest &request) { 106 | mstring channel = GetSpecChannel(type); 107 | 108 | LPCSTR sz = MsgSendForResult(channel.c_str(), MakeRequest(request).c_str()); 109 | mstring result = sz; 110 | MsgStrFree(sz); 111 | return ParserReply(result); 112 | } 113 | 114 | mstring DbgService::GetSpecChannel(DbggerType type) const { 115 | mstring channel; 116 | switch (type) { 117 | case em_dbg_proc86: 118 | channel = CHANNEL_RPOC32; 119 | break; 120 | case em_dbg_proc64: 121 | channel = CHANNEL_RPOC64; 122 | break; 123 | case em_dbg_dump86: 124 | channel = CHANNEL_DUMP32; 125 | break; 126 | case em_dbg_dump64: 127 | channel = CHANNEL_DUMP64; 128 | break; 129 | } 130 | return channel; 131 | } 132 | 133 | bool DbgService::SetActivity(DbggerType type) { 134 | m_DbgClient = type; 135 | m_curChannel = GetSpecChannel(type); 136 | return true; 137 | } 138 | 139 | HDbgCtrl DbgService::RegisterDbgEvent(const mstring &eventName, pfnDbgEventProc pfn, void *param) { 140 | CScopedLocker lock(this); 141 | DbgServiceCache *cache = new DbgServiceCache(); 142 | cache->m_idex = m_curIndex++; 143 | cache->m_event = eventName; 144 | cache->m_param = param; 145 | cache->m_proc = pfn; 146 | m_RegisterSet[eventName].push_back(cache); 147 | return cache->m_idex; 148 | } 149 | 150 | DbgServiceBase *DbgServiceBase::GetInstance() { 151 | static DbgService *s_ptr = NULL; 152 | if (!s_ptr) 153 | { 154 | s_ptr = new DbgService(); 155 | } 156 | return s_ptr; 157 | } -------------------------------------------------------------------------------- /ComLib/StrUtil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "StrUtil.h" 5 | 6 | using namespace std; 7 | 8 | typedef string strutf8; 9 | strutf8 ToUtf8W(const wstring &str); 10 | wstring ToWideChar(const string &str); 11 | string ToMultiByte(const wstring &str); 12 | wstring ToCommonW(const strutf8 &str); 13 | 14 | strutf8 ToUtf8A(const string &str) 15 | { 16 | return ToUtf8W(ToWideChar(str)); 17 | } 18 | 19 | strutf8 ToUtf8W(const wstring &str) 20 | { 21 | strutf8 ret; 22 | 23 | int count = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, NULL, 0, NULL, NULL); 24 | 25 | if (count > 0) 26 | { 27 | char *buffer = new char[count]; 28 | 29 | if (buffer != 0) 30 | { 31 | WideCharToMultiByte(CP_UTF8, 0, str.c_str(), -1, buffer, count, NULL, NULL); 32 | ret = buffer; 33 | 34 | delete []buffer; 35 | } 36 | } 37 | 38 | return ret; 39 | } 40 | 41 | string ToCommonA(const strutf8 &str) 42 | { 43 | return ToMultiByte(ToCommonW(str)); 44 | } 45 | 46 | wstring ToCommonW(const strutf8 &str) 47 | { 48 | wstring ret; 49 | 50 | int count = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0); 51 | 52 | if (count > 0) 53 | { 54 | wchar_t *buffer = new wchar_t[count]; 55 | 56 | if (buffer != 0) 57 | { 58 | MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, buffer, count); 59 | ret = buffer; 60 | 61 | delete []buffer; 62 | } 63 | } 64 | 65 | return ret; 66 | } 67 | 68 | string ToMultiByte(const wstring &str) 69 | { 70 | string ret; 71 | 72 | int count = WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, NULL, 0, NULL, NULL); 73 | 74 | if (count > 0) 75 | { 76 | char *buffer = new char[count]; 77 | 78 | if (buffer != 0) 79 | { 80 | WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, buffer, count, NULL, NULL); 81 | ret = buffer; 82 | 83 | delete []buffer; 84 | } 85 | } 86 | 87 | return ret; 88 | } 89 | 90 | wstring ToWideChar(const string &str) 91 | { 92 | wstring ret; 93 | 94 | int count = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0); 95 | 96 | if (count > 0) 97 | { 98 | wchar_t *buffer = new wchar_t[count]; 99 | 100 | if (buffer != 0) 101 | { 102 | MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, buffer, count); 103 | ret = buffer; 104 | 105 | delete []buffer; 106 | } 107 | } 108 | 109 | return ret; 110 | } 111 | 112 | string __stdcall AtoU(const string &str) { 113 | return ToUtf8A(str); 114 | } 115 | 116 | string __stdcall UtoA(const string &str) { 117 | return ToCommonA(str); 118 | } 119 | 120 | wstring __stdcall AtoW(const string &str) { 121 | return ToWideChar(str); 122 | } 123 | 124 | string __stdcall WtoA(const wstring &wstr) { 125 | return ToMultiByte(wstr); 126 | } 127 | 128 | wstring __stdcall UtoW(const string &str) { 129 | return ToCommonW(str); 130 | } 131 | 132 | string __stdcall WtoU(const wstring &wstr) { 133 | return ToUtf8W(wstr); 134 | } 135 | 136 | string __stdcall FormatA(const char *format, ...) { 137 | char szText[2048] = {0}; 138 | va_list val; 139 | 140 | va_start(val, format); 141 | wvnsprintfA(szText, RTL_NUMBER_OF(szText), format, val); 142 | va_end(val); 143 | return szText; 144 | } 145 | 146 | wstring __stdcall FormatW(const wchar_t *format, ...) 147 | { 148 | wchar_t szText[2048] = {0}; 149 | va_list val; 150 | 151 | va_start(val, format); 152 | wvnsprintfW(szText, RTL_NUMBER_OF(szText), format, val); 153 | va_end(val); 154 | 155 | return szText; 156 | } 157 | 158 | list SplitStrA(const mstring &str, const mstring &split) { 159 | list result; 160 | if (split.empty()) 161 | { 162 | return result; 163 | } 164 | 165 | size_t last = 0; 166 | size_t pos = 0; 167 | while (true) { 168 | pos = str.find(split, last); 169 | 170 | if (pos == mstring::npos) 171 | { 172 | if (str.size() > last) 173 | { 174 | result.push_back(str.substr(last)); 175 | } 176 | return result; 177 | } 178 | 179 | if (pos > last) 180 | { 181 | result.push_back(str.substr(last, pos - last)); 182 | } 183 | last = pos + split.size(); 184 | } 185 | } 186 | 187 | list SplitStrW(const ustring &str, const ustring &split) { 188 | list result; 189 | if (split.empty()) 190 | { 191 | return result; 192 | } 193 | 194 | size_t last = 0; 195 | size_t pos = 0; 196 | while (true) { 197 | pos = str.find(split, last); 198 | 199 | if (pos == ustring::npos) 200 | { 201 | if (str.size() > last) 202 | { 203 | result.push_back(str.substr(last)); 204 | } 205 | return result; 206 | } 207 | 208 | if (pos > last) 209 | { 210 | result.push_back(str.substr(last, pos - last)); 211 | } 212 | last = pos + split.size(); 213 | } 214 | } -------------------------------------------------------------------------------- /VDebug.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vdebug", "VDebug\VDebug.vcproj", "{C2879715-B07F-49B8-A525-2355F4B1A030}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {652CC710-0062-496A-8F38-4A8D779F34CB} = {652CC710-0062-496A-8F38-4A8D779F34CB} 7 | {AB55F249-56FA-436F-89F9-EF6A930373E9} = {AB55F249-56FA-436F-89F9-EF6A930373E9} 8 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0} = {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ComLib", "ComLib\ComLib.vcproj", "{652CC710-0062-496A-8F38-4A8D779F34CB}" 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mq", "mq\mq.vcproj", "{AB55F249-56FA-436F-89F9-EF6A930373E9}" 14 | ProjectSection(ProjectDependencies) = postProject 15 | {652CC710-0062-496A-8F38-4A8D779F34CB} = {652CC710-0062-496A-8F38-4A8D779F34CB} 16 | EndProjectSection 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dbg", "dbg\dbg.vcproj", "{5BA61742-8B83-4F8B-AE0A-3AF7DE6B383A}" 19 | ProjectSection(ProjectDependencies) = postProject 20 | {652CC710-0062-496A-8F38-4A8D779F34CB} = {652CC710-0062-496A-8F38-4A8D779F34CB} 21 | {AB55F249-56FA-436F-89F9-EF6A930373E9} = {AB55F249-56FA-436F-89F9-EF6A930373E9} 22 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0} = {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0} 23 | EndProjectSection 24 | EndProject 25 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DbgCtrl", "DbgCtrl\DbgCtrl.vcproj", "{AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0}" 26 | ProjectSection(ProjectDependencies) = postProject 27 | {652CC710-0062-496A-8F38-4A8D779F34CB} = {652CC710-0062-496A-8F38-4A8D779F34CB} 28 | {AB55F249-56FA-436F-89F9-EF6A930373E9} = {AB55F249-56FA-436F-89F9-EF6A930373E9} 29 | EndProjectSection 30 | EndProject 31 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "runner\runner.vcproj", "{29A41601-2B64-4F24-9083-55FC8F1D5E77}" 32 | ProjectSection(ProjectDependencies) = postProject 33 | {652CC710-0062-496A-8F38-4A8D779F34CB} = {652CC710-0062-496A-8F38-4A8D779F34CB} 34 | EndProjectSection 35 | EndProject 36 | Global 37 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 38 | Debug|Win32 = Debug|Win32 39 | Debug|x64 = Debug|x64 40 | Release|Win32 = Release|Win32 41 | Release|x64 = Release|x64 42 | EndGlobalSection 43 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 44 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Debug|Win32.ActiveCfg = Debug|Win32 45 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Debug|Win32.Build.0 = Debug|Win32 46 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Debug|x64.ActiveCfg = Debug|x64 47 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Debug|x64.Build.0 = Debug|x64 48 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Release|Win32.ActiveCfg = Release|Win32 49 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Release|Win32.Build.0 = Release|Win32 50 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Release|x64.ActiveCfg = Release|x64 51 | {C2879715-B07F-49B8-A525-2355F4B1A030}.Release|x64.Build.0 = Release|x64 52 | {652CC710-0062-496A-8F38-4A8D779F34CB}.Debug|Win32.ActiveCfg = Debug|Win32 53 | {652CC710-0062-496A-8F38-4A8D779F34CB}.Debug|Win32.Build.0 = Debug|Win32 54 | {652CC710-0062-496A-8F38-4A8D779F34CB}.Debug|x64.ActiveCfg = Debug|Win32 55 | {652CC710-0062-496A-8F38-4A8D779F34CB}.Release|Win32.ActiveCfg = Release|Win32 56 | {652CC710-0062-496A-8F38-4A8D779F34CB}.Release|Win32.Build.0 = Release|Win32 57 | {652CC710-0062-496A-8F38-4A8D779F34CB}.Release|x64.ActiveCfg = Release|Win32 58 | {AB55F249-56FA-436F-89F9-EF6A930373E9}.Debug|Win32.ActiveCfg = Debug|Win32 59 | {AB55F249-56FA-436F-89F9-EF6A930373E9}.Debug|Win32.Build.0 = Debug|Win32 60 | {AB55F249-56FA-436F-89F9-EF6A930373E9}.Debug|x64.ActiveCfg = Debug|Win32 61 | {AB55F249-56FA-436F-89F9-EF6A930373E9}.Release|Win32.ActiveCfg = Release|Win32 62 | {AB55F249-56FA-436F-89F9-EF6A930373E9}.Release|Win32.Build.0 = Release|Win32 63 | {AB55F249-56FA-436F-89F9-EF6A930373E9}.Release|x64.ActiveCfg = Release|Win32 64 | {5BA61742-8B83-4F8B-AE0A-3AF7DE6B383A}.Debug|Win32.ActiveCfg = Debug|Win32 65 | {5BA61742-8B83-4F8B-AE0A-3AF7DE6B383A}.Debug|Win32.Build.0 = Debug|Win32 66 | {5BA61742-8B83-4F8B-AE0A-3AF7DE6B383A}.Debug|x64.ActiveCfg = Debug|Win32 67 | {5BA61742-8B83-4F8B-AE0A-3AF7DE6B383A}.Release|Win32.ActiveCfg = Release|Win32 68 | {5BA61742-8B83-4F8B-AE0A-3AF7DE6B383A}.Release|Win32.Build.0 = Release|Win32 69 | {5BA61742-8B83-4F8B-AE0A-3AF7DE6B383A}.Release|x64.ActiveCfg = Release|Win32 70 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0}.Debug|Win32.ActiveCfg = Debug|Win32 71 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0}.Debug|Win32.Build.0 = Debug|Win32 72 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0}.Debug|x64.ActiveCfg = Debug|Win32 73 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0}.Release|Win32.ActiveCfg = Release|Win32 74 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0}.Release|Win32.Build.0 = Release|Win32 75 | {AC5297FB-D1BD-439F-A8CC-BE8A85D49BD0}.Release|x64.ActiveCfg = Release|Win32 76 | {29A41601-2B64-4F24-9083-55FC8F1D5E77}.Debug|Win32.ActiveCfg = Debug|Win32 77 | {29A41601-2B64-4F24-9083-55FC8F1D5E77}.Debug|Win32.Build.0 = Debug|Win32 78 | {29A41601-2B64-4F24-9083-55FC8F1D5E77}.Debug|x64.ActiveCfg = Debug|Win32 79 | {29A41601-2B64-4F24-9083-55FC8F1D5E77}.Release|Win32.ActiveCfg = Release|Win32 80 | {29A41601-2B64-4F24-9083-55FC8F1D5E77}.Release|Win32.Build.0 = Release|Win32 81 | {29A41601-2B64-4F24-9083-55FC8F1D5E77}.Release|x64.ActiveCfg = Release|Win32 82 | EndGlobalSection 83 | GlobalSection(SolutionProperties) = preSolution 84 | HideSolutionNode = FALSE 85 | EndGlobalSection 86 | EndGlobal 87 | -------------------------------------------------------------------------------- /VDebug/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by VDebug.rc 4 | // 5 | #define IDD_MAINVIEW 101 6 | #define IDI_ICON1 104 7 | #define IDI_MAIN 104 8 | #define IDB_TOOLBAR 105 9 | #define IDD_PROC_ATTACH 106 10 | #define IDR_MAIN 107 11 | #define IDD_PROC_OPEN 108 12 | #define IDD_IMPORT_FUNDEF 117 13 | #define IDD_ABOUT 118 14 | #define IDB_BITMAP1 126 15 | #define IDB_BITMAP2 127 16 | #define IDC_EDIT1 1001 17 | #define IDC_EDT_COMMAND 1001 18 | #define IDC_EDT_MSG 1001 19 | #define IDC_EDT_PEOPEN_PATH 1001 20 | #define IDC_PROC_EDT_INFO 1001 21 | #define IDC_ABOUT_EDT_VERSION 1001 22 | #define IDC_EDT_STATUS 1002 23 | #define IDC_EDIT3 1002 24 | #define IDC_EDT_PEOPEN_CMD 1002 25 | #define IDC_PROC_EDT_STATUS 1002 26 | #define IDC_EDT_OPEN_CMD 1002 27 | #define IDC_EDIT4 1003 28 | #define IDC_EDT_WORKDIR 1003 29 | #define IDC_EDT_PEOPEN_WORKDIR 1003 30 | #define IDC_EDT_OPEN_WORKDIR 1003 31 | #define IDC_LIST1 1004 32 | #define IDC_LIST_PROC 1004 33 | #define IDC_PROC_LIST_PROC 1004 34 | #define IDC_EDT_OPEN_WORKDIR2 1004 35 | #define IDC_EDT_OPEN_STATUS 1004 36 | #define IDC_BTN_ATTACH 1005 37 | #define IDC_PROC_BTN_ATTACH 1005 38 | #define IDC_BTN_OPEN 1006 39 | #define IDC_PROC_BTN_OPEN 1006 40 | #define IDC_BTN_REFUSH 1007 41 | #define IDC_EDIT2 1008 42 | #define IDC_EDT_FILTER 1008 43 | #define IDC_EDT_PEOPEN_STATUS 1008 44 | #define IDC_PROC_EDT_FLT 1008 45 | #define IDC_ABOUT_EDT_DESC 1008 46 | #define IDC_BUTTON1 1009 47 | #define IDC_BTN_PEOPEN_SELECT 1009 48 | #define IDC_BUTTON2 1010 49 | #define IDC_BTN_PEOPEN_DEBUG 1010 50 | #define IDC_OPEN_TEXT1 1012 51 | #define IDC_OPEN_TEXT2 1013 52 | #define IDC_OPEN_TEXT3 1014 53 | #define IDC_OPEN_COM_HISTORY 1016 54 | #define IDC_IMPORT_COM_MODULE 1017 55 | #define IDC_IMPORT_BTN_OK 1018 56 | #define IDC_IMPORT_BTN_CANCEL 1019 57 | #define IDC_IMPORT_BTN_OK2 1020 58 | #define IDC_IMPORT_BTN_CHECK 1020 59 | #define IDC_ABOUT_ICO 1024 60 | #define IDC_LINK_VDEBUG 1027 61 | #define IDC_LINK_HOMEPAGE 1028 62 | #define IDC_STATIC1 1029 63 | #define IDC_STATIC2 1030 64 | #define ID_40001 40001 65 | #define ID_40002 40002 66 | #define ID_40003 40003 67 | #define ID_40004 40004 68 | #define ID_40005 40005 69 | #define ID_40006 40006 70 | #define ID_40007 40007 71 | #define ID_40008 40008 72 | #define ID_40009 40009 73 | #define ID_40010 40010 74 | #define IDC 40011 75 | #define IDC_CMD_OPEN 40012 76 | #define IDC_CMD_ATTACH 40013 77 | #define IDC_CMD_ 40014 78 | #define IDC_CMD_OPEN_DUMP 40015 79 | #define IDC_CMD_SET 40016 80 | #define IDC_CMD_SET_SYMBOL 40017 81 | #define IDC_CMD_SET_COLOUR 40018 82 | #define IDC_CMD_RESTART 40019 83 | #define IDC_CMD_DETACH 40020 84 | #define IDC_CMD_CREATE_DUMP 40021 85 | #define IDC_CMD_HELP 40022 86 | #define IDC_CMD_ABOUT 40023 87 | #define ID_40024 40024 88 | #define ID_Menu 40025 89 | #define IDC_CMD_IMPORT_FUN 40026 90 | #define ID_40027 40027 91 | #define ID_40028 40028 92 | #define IDC_CMD_SET_STYLE 40029 93 | #define IDD_CONFIG 40100 94 | #define IDC_COM_FONT 40101 95 | #define IDC_COM_SIZE 40102 96 | #define IDC_ST_FONT 40103 97 | #define IDC_CK_LINENUM 40104 98 | #define IDC_BTN_CFG_RESET 40105 99 | #define IDC_BTN_CFG_OK 40106 100 | #define IDC_EDT_TEXT1 40107 101 | #define IDC_EDT_BACK1 40108 102 | #define IDC_EDT_TEXT2 40109 103 | #define IDC_EDT_BACK2 40110 104 | #define IDC_EDT_TEXT3 40111 105 | #define IDC_EDT_BACK3 40112 106 | #define IDC_EDT_TEXT4 40113 107 | #define IDC_EDT_BACK4 40114 108 | #define IDC_ST_OTHER 40115 109 | #define IDC_EDT_SEL_RGB 40116 110 | #define IDC_EDT_SEL_ALPHA 40117 111 | 112 | // Next default values for new objects 113 | // 114 | #ifdef APSTUDIO_INVOKED 115 | #ifndef APSTUDIO_READONLY_SYMBOLS 116 | #define _APS_NEXT_RESOURCE_VALUE 128 117 | #define _APS_NEXT_COMMAND_VALUE 40030 118 | #define _APS_NEXT_CONTROL_VALUE 1031 119 | #define _APS_NEXT_SYMED_VALUE 101 120 | #endif 121 | #endif 122 | -------------------------------------------------------------------------------- /VDebug/view/SyntaxCfg.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "SyntaxCfg.h" 7 | #include 8 | #include "../SyntaxHlpr/SyntaxTextView.h" 9 | 10 | using namespace std; 11 | 12 | static map *gs_pSyntaxMap = NULL; 13 | static map *gs_pSyntaxCfg = NULL; 14 | static bool gs_bInit = false; 15 | 16 | static DWORD gs_defTextColour = 0; 17 | static DWORD gs_defBackColour = 0; 18 | static DWORD gs_CaretLineColour = 0; 19 | static DWORD gs_SelTextColour = 0; 20 | static DWORD gs_SelBackColour = 0; 21 | static DWORD gs_SelAlpha = 0; 22 | 23 | SyntaxColourDesc *GetSyntaxCfg(int type) 24 | { 25 | map::const_iterator it = gs_pSyntaxCfg->find(type); 26 | if (gs_pSyntaxCfg->end() != it) 27 | { 28 | return it->second; 29 | } 30 | return NULL; 31 | } 32 | 33 | static SyntaxColourDesc *_GetDescFromJson(const mstring &key, const Value &json) 34 | { 35 | SyntaxColourDesc *desc = new SyntaxColourDesc(); 36 | desc->m_dwTextColour = GetColourFromStr(json["textColour"].asString().c_str()); 37 | desc->m_dwBackColour = GetColourFromStr(json["backColour"].asString().c_str()); 38 | desc->m_bBold = json["bold"].asInt(); 39 | desc->m_bItalic = json["italic"].asInt(); 40 | 41 | if (desc->m_dwTextColour == NULL_COLOUR) 42 | { 43 | desc->m_dwTextColour = gs_defTextColour; 44 | } 45 | 46 | if (desc->m_dwBackColour == NULL_COLOUR) 47 | { 48 | desc->m_dwBackColour = gs_defBackColour; 49 | } 50 | desc->m_strDesc = key; 51 | return desc; 52 | } 53 | 54 | static void _InitSyntaxCfg() { 55 | gs_pSyntaxMap = new map(); 56 | gs_pSyntaxCfg = new map(); 57 | 58 | gs_pSyntaxMap->insert(make_pair("default", STYLE_DBG_DEFAULT)); 59 | gs_pSyntaxMap->insert(make_pair("addr", STYLE_DBG_ADDR)); 60 | gs_pSyntaxMap->insert(make_pair("register", STYLE_DBG_REGISTER)); 61 | gs_pSyntaxMap->insert(make_pair("error", STYLE_DBG_ERROR)); 62 | gs_pSyntaxMap->insert(make_pair("message", STYLE_DBG_MESSAGE)); 63 | gs_pSyntaxMap->insert(make_pair("hex", STYLE_DBG_HEX)); 64 | gs_pSyntaxMap->insert(make_pair("data", STYLE_DBG_DATA)); 65 | gs_pSyntaxMap->insert(make_pair("byte", STYLE_DBG_BYTE)); 66 | gs_pSyntaxMap->insert(make_pair("inst", STYLE_DBG_INST)); 67 | gs_pSyntaxMap->insert(make_pair("call", STYLE_DBG_CALL)); 68 | gs_pSyntaxMap->insert(make_pair("jmp", STYLE_DBG_JMP)); 69 | gs_pSyntaxMap->insert(make_pair("proc", STYLE_DBG_PROC)); 70 | gs_pSyntaxMap->insert(make_pair("module", STYLE_DBG_MODULE)); 71 | gs_pSyntaxMap->insert(make_pair("param", STYLE_DBG_PARAM)); 72 | gs_pSyntaxMap->insert(make_pair("keyword", STYLE_DBG_KEYWORD)); 73 | gs_pSyntaxMap->insert(make_pair("number", STYLE_DBG_NUMBER)); 74 | gs_pSyntaxMap->insert(make_pair("hight", STYLE_DBG_HIGHT)); 75 | } 76 | 77 | BOOL UpdateSyntaxView(SyntaxTextView *pSyntaxView) { 78 | pSyntaxView->SetDefStyle(gs_defTextColour, gs_defBackColour); 79 | pSyntaxView->ShowCaretLine(true, gs_CaretLineColour, 100); 80 | //pSyntaxView->SendMsg(SCI_SETSELFORE, 1, gs_SelTextColour); 81 | pSyntaxView->SendMsg(SCI_SETSELBACK, 1, gs_SelBackColour); 82 | pSyntaxView->SendMsg(SCI_SETSELALPHA, gs_SelAlpha, 0); 83 | 84 | map::const_iterator it; 85 | for (it = gs_pSyntaxCfg->begin() ; it != gs_pSyntaxCfg->end() ; it++) 86 | { 87 | SyntaxColourDesc *desc = it->second; 88 | pSyntaxView->SetStyle(it->first, desc->m_dwTextColour, desc->m_dwBackColour); 89 | } 90 | return TRUE; 91 | } 92 | 93 | BOOL LoadSyntaxCfg(const string &path) 94 | { 95 | if (!gs_bInit) 96 | { 97 | gs_bInit = true; 98 | 99 | _InitSyntaxCfg(); 100 | } 101 | 102 | PFILE_MAPPING_STRUCT pMapping = NULL; 103 | BOOL stat = FALSE; 104 | 105 | do 106 | { 107 | pMapping = MappingFileA(path.c_str()); 108 | if (pMapping == NULL || pMapping->hFile == INVALID_HANDLE_VALUE) 109 | { 110 | break; 111 | } 112 | 113 | Value root; 114 | Reader().parse((const char *)pMapping->lpView, root); 115 | 116 | if (root.type() != objectValue) 117 | { 118 | break; 119 | } 120 | 121 | //Global Config 122 | Value golbal = root["globalCfg"]; 123 | Value cfg = root["syntaxCfg"]; 124 | 125 | /* 126 | { 127 | "lineNumber": 1, 128 | "defTextColour": "0,0,255", 129 | "defBackColour": "40,40,40", 130 | "viewBackColour": "40,40,40", 131 | "curLineColour": "60,56,54", 132 | "selTextColour": "255,0,0", 133 | "selBackColour": "0,255,0", 134 | "selAlpha":100 135 | } 136 | */ 137 | gs_defTextColour = GetColourFromStr(GetStrFormJson(golbal, "defTextColour").c_str()); 138 | gs_defBackColour = GetColourFromStr(GetStrFormJson(golbal, "defBackColour").c_str()); 139 | gs_CaretLineColour = GetColourFromStr(GetStrFormJson(golbal, "curLineColour").c_str()); 140 | gs_SelTextColour = GetColourFromStr(GetStrFormJson(golbal, "selTextColour").c_str()); 141 | gs_SelBackColour = GetColourFromStr(GetStrFormJson(golbal, "selBackColour").c_str()); 142 | gs_SelAlpha = GetIntFromJson(golbal, "selAlpha"); 143 | 144 | for (Json::Value::iterator it = cfg.begin() ; it != cfg.end() ; it++) { 145 | SyntaxColourDesc *desc = _GetDescFromJson(it.key().asString(), *it); 146 | 147 | map::const_iterator ij = gs_pSyntaxMap->find(desc->m_strDesc); 148 | if (ij != gs_pSyntaxMap->end()) 149 | { 150 | gs_pSyntaxCfg->insert(make_pair(ij->second, desc)); 151 | } 152 | } 153 | } while (FALSE); 154 | 155 | if (pMapping) 156 | { 157 | CloseFileMapping(pMapping); 158 | } 159 | return stat; 160 | } -------------------------------------------------------------------------------- /dbg/capstone/xcore.h: -------------------------------------------------------------------------------- 1 | #ifndef CAPSTONE_XCORE_H 2 | #define CAPSTONE_XCORE_H 3 | 4 | /* Capstone Disassembly Engine */ 5 | /* By Nguyen Anh Quynh , 2014-2015 */ 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "platform.h" 12 | 13 | #ifdef _MSC_VER 14 | #pragma warning(disable:4201) 15 | #endif 16 | 17 | //> Operand type for instruction's operands 18 | typedef enum xcore_op_type 19 | { 20 | XCORE_OP_INVALID = 0, // = CS_OP_INVALID (Uninitialized). 21 | XCORE_OP_REG, // = CS_OP_REG (Register operand). 22 | XCORE_OP_IMM, // = CS_OP_IMM (Immediate operand). 23 | XCORE_OP_MEM, // = CS_OP_MEM (Memory operand). 24 | } xcore_op_type; 25 | 26 | //> XCore registers 27 | typedef enum xcore_reg 28 | { 29 | XCORE_REG_INVALID = 0, 30 | 31 | XCORE_REG_CP, 32 | XCORE_REG_DP, 33 | XCORE_REG_LR, 34 | XCORE_REG_SP, 35 | XCORE_REG_R0, 36 | XCORE_REG_R1, 37 | XCORE_REG_R2, 38 | XCORE_REG_R3, 39 | XCORE_REG_R4, 40 | XCORE_REG_R5, 41 | XCORE_REG_R6, 42 | XCORE_REG_R7, 43 | XCORE_REG_R8, 44 | XCORE_REG_R9, 45 | XCORE_REG_R10, 46 | XCORE_REG_R11, 47 | 48 | //> pseudo registers 49 | XCORE_REG_PC, // pc 50 | 51 | // internal thread registers 52 | // see The-XMOS-XS1-Architecture(X7879A).pdf 53 | XCORE_REG_SCP, // save pc 54 | XCORE_REG_SSR, // save status 55 | XCORE_REG_ET, // exception type 56 | XCORE_REG_ED, // exception data 57 | XCORE_REG_SED, // save exception data 58 | XCORE_REG_KEP, // kernel entry pointer 59 | XCORE_REG_KSP, // kernel stack pointer 60 | XCORE_REG_ID, // thread ID 61 | 62 | XCORE_REG_ENDING, // <-- mark the end of the list of registers 63 | } xcore_reg; 64 | 65 | // Instruction's operand referring to memory 66 | // This is associated with XCORE_OP_MEM operand type above 67 | typedef struct xcore_op_mem 68 | { 69 | uint8_t base; // base register, can be safely interpreted as 70 | // a value of type `xcore_reg`, but it is only 71 | // one byte wide 72 | uint8_t index; // index register, same conditions apply here 73 | int32_t disp; // displacement/offset value 74 | int direct; // +1: forward, -1: backward 75 | } xcore_op_mem; 76 | 77 | // Instruction operand 78 | typedef struct cs_xcore_op 79 | { 80 | xcore_op_type type; // operand type 81 | union 82 | { 83 | xcore_reg reg; // register value for REG operand 84 | int32_t imm; // immediate value for IMM operand 85 | xcore_op_mem mem; // base/disp value for MEM operand 86 | }; 87 | } cs_xcore_op; 88 | 89 | // Instruction structure 90 | typedef struct cs_xcore 91 | { 92 | // Number of operands of this instruction, 93 | // or 0 when instruction has no operand. 94 | uint8_t op_count; 95 | cs_xcore_op operands[8]; // operands for this instruction. 96 | } cs_xcore; 97 | 98 | //> XCore instruction 99 | typedef enum xcore_insn 100 | { 101 | XCORE_INS_INVALID = 0, 102 | 103 | XCORE_INS_ADD, 104 | XCORE_INS_ANDNOT, 105 | XCORE_INS_AND, 106 | XCORE_INS_ASHR, 107 | XCORE_INS_BAU, 108 | XCORE_INS_BITREV, 109 | XCORE_INS_BLA, 110 | XCORE_INS_BLAT, 111 | XCORE_INS_BL, 112 | XCORE_INS_BF, 113 | XCORE_INS_BT, 114 | XCORE_INS_BU, 115 | XCORE_INS_BRU, 116 | XCORE_INS_BYTEREV, 117 | XCORE_INS_CHKCT, 118 | XCORE_INS_CLRE, 119 | XCORE_INS_CLRPT, 120 | XCORE_INS_CLRSR, 121 | XCORE_INS_CLZ, 122 | XCORE_INS_CRC8, 123 | XCORE_INS_CRC32, 124 | XCORE_INS_DCALL, 125 | XCORE_INS_DENTSP, 126 | XCORE_INS_DGETREG, 127 | XCORE_INS_DIVS, 128 | XCORE_INS_DIVU, 129 | XCORE_INS_DRESTSP, 130 | XCORE_INS_DRET, 131 | XCORE_INS_ECALLF, 132 | XCORE_INS_ECALLT, 133 | XCORE_INS_EDU, 134 | XCORE_INS_EEF, 135 | XCORE_INS_EET, 136 | XCORE_INS_EEU, 137 | XCORE_INS_ENDIN, 138 | XCORE_INS_ENTSP, 139 | XCORE_INS_EQ, 140 | XCORE_INS_EXTDP, 141 | XCORE_INS_EXTSP, 142 | XCORE_INS_FREER, 143 | XCORE_INS_FREET, 144 | XCORE_INS_GETD, 145 | XCORE_INS_GET, 146 | XCORE_INS_GETN, 147 | XCORE_INS_GETR, 148 | XCORE_INS_GETSR, 149 | XCORE_INS_GETST, 150 | XCORE_INS_GETTS, 151 | XCORE_INS_INCT, 152 | XCORE_INS_INIT, 153 | XCORE_INS_INPW, 154 | XCORE_INS_INSHR, 155 | XCORE_INS_INT, 156 | XCORE_INS_IN, 157 | XCORE_INS_KCALL, 158 | XCORE_INS_KENTSP, 159 | XCORE_INS_KRESTSP, 160 | XCORE_INS_KRET, 161 | XCORE_INS_LADD, 162 | XCORE_INS_LD16S, 163 | XCORE_INS_LD8U, 164 | XCORE_INS_LDA16, 165 | XCORE_INS_LDAP, 166 | XCORE_INS_LDAW, 167 | XCORE_INS_LDC, 168 | XCORE_INS_LDW, 169 | XCORE_INS_LDIVU, 170 | XCORE_INS_LMUL, 171 | XCORE_INS_LSS, 172 | XCORE_INS_LSUB, 173 | XCORE_INS_LSU, 174 | XCORE_INS_MACCS, 175 | XCORE_INS_MACCU, 176 | XCORE_INS_MJOIN, 177 | XCORE_INS_MKMSK, 178 | XCORE_INS_MSYNC, 179 | XCORE_INS_MUL, 180 | XCORE_INS_NEG, 181 | XCORE_INS_NOT, 182 | XCORE_INS_OR, 183 | XCORE_INS_OUTCT, 184 | XCORE_INS_OUTPW, 185 | XCORE_INS_OUTSHR, 186 | XCORE_INS_OUTT, 187 | XCORE_INS_OUT, 188 | XCORE_INS_PEEK, 189 | XCORE_INS_REMS, 190 | XCORE_INS_REMU, 191 | XCORE_INS_RETSP, 192 | XCORE_INS_SETCLK, 193 | XCORE_INS_SET, 194 | XCORE_INS_SETC, 195 | XCORE_INS_SETD, 196 | XCORE_INS_SETEV, 197 | XCORE_INS_SETN, 198 | XCORE_INS_SETPSC, 199 | XCORE_INS_SETPT, 200 | XCORE_INS_SETRDY, 201 | XCORE_INS_SETSR, 202 | XCORE_INS_SETTW, 203 | XCORE_INS_SETV, 204 | XCORE_INS_SEXT, 205 | XCORE_INS_SHL, 206 | XCORE_INS_SHR, 207 | XCORE_INS_SSYNC, 208 | XCORE_INS_ST16, 209 | XCORE_INS_ST8, 210 | XCORE_INS_STW, 211 | XCORE_INS_SUB, 212 | XCORE_INS_SYNCR, 213 | XCORE_INS_TESTCT, 214 | XCORE_INS_TESTLCL, 215 | XCORE_INS_TESTWCT, 216 | XCORE_INS_TSETMR, 217 | XCORE_INS_START, 218 | XCORE_INS_WAITEF, 219 | XCORE_INS_WAITET, 220 | XCORE_INS_WAITEU, 221 | XCORE_INS_XOR, 222 | XCORE_INS_ZEXT, 223 | 224 | XCORE_INS_ENDING, // <-- mark the end of the list of instructions 225 | } xcore_insn; 226 | 227 | //> Group of XCore instructions 228 | typedef enum xcore_insn_group 229 | { 230 | XCORE_GRP_INVALID = 0, // = CS_GRP_INVALID 231 | 232 | //> Generic groups 233 | // all jump instructions (conditional+direct+indirect jumps) 234 | XCORE_GRP_JUMP, // = CS_GRP_JUMP 235 | 236 | XCORE_GRP_ENDING, // <-- mark the end of the list of groups 237 | } xcore_insn_group; 238 | 239 | #ifdef __cplusplus 240 | } 241 | #endif 242 | 243 | #endif 244 | -------------------------------------------------------------------------------- /ComLib/json/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_WRITER_H_INCLUDED 2 | # define JSON_WRITER_H_INCLUDED 3 | 4 | # include "value.h" 5 | # include 6 | # include 7 | # include 8 | 9 | namespace Json { 10 | 11 | class Value; 12 | 13 | /** \brief Abstract class for writers. 14 | */ 15 | class JSON_API Writer 16 | { 17 | public: 18 | virtual ~Writer(); 19 | 20 | virtual std::string write( const Value &root ) = 0; 21 | }; 22 | 23 | /** \brief Outputs a Value in JSON format without formatting (not human friendly). 24 | * 25 | * The JSON document is written in a single line. It is not intended for 'human' consumption, 26 | * but may be usefull to support feature such as RPC where bandwith is limited. 27 | * \sa Reader, Value 28 | */ 29 | class JSON_API FastWriter : public Writer 30 | { 31 | public: 32 | FastWriter(); 33 | virtual ~FastWriter(){} 34 | 35 | void enableYAMLCompatibility(); 36 | 37 | public: // overridden from Writer 38 | virtual std::string write( const Value &root ); 39 | 40 | private: 41 | void writeValue( const Value &value ); 42 | 43 | std::string document_; 44 | bool yamlCompatiblityEnabled_; 45 | }; 46 | 47 | /** \brief Writes a Value in JSON format in a human friendly way. 48 | * 49 | * The rules for line break and indent are as follow: 50 | * - Object value: 51 | * - if empty then print {} without indent and line break 52 | * - if not empty the print '{', line break & indent, print one value per line 53 | * and then unindent and line break and print '}'. 54 | * - Array value: 55 | * - if empty then print [] without indent and line break 56 | * - if the array contains no object value, empty array or some other value types, 57 | * and all the values fit on one lines, then print the array on a single line. 58 | * - otherwise, it the values do not fit on one line, or the array contains 59 | * object or non empty array, then print one value per line. 60 | * 61 | * If the Value have comments then they are outputed according to their #CommentPlacement. 62 | * 63 | * \sa Reader, Value, Value::setComment() 64 | */ 65 | class JSON_API StyledWriter: public Writer 66 | { 67 | public: 68 | StyledWriter(); 69 | virtual ~StyledWriter(){} 70 | 71 | public: // overridden from Writer 72 | /** \brief Serialize a Value in JSON format. 73 | * \param root Value to serialize. 74 | * \return String containing the JSON document that represents the root value. 75 | */ 76 | virtual std::string write( const Value &root ); 77 | 78 | private: 79 | void writeValue( const Value &value ); 80 | void writeArrayValue( const Value &value ); 81 | bool isMultineArray( const Value &value ); 82 | void pushValue( const std::string &value ); 83 | void writeIndent(); 84 | void writeWithIndent( const std::string &value ); 85 | void indent(); 86 | void unindent(); 87 | void writeCommentBeforeValue( const Value &root ); 88 | void writeCommentAfterValueOnSameLine( const Value &root ); 89 | bool hasCommentForValue( const Value &value ); 90 | static std::string normalizeEOL( const std::string &text ); 91 | 92 | typedef std::vector ChildValues; 93 | 94 | ChildValues childValues_; 95 | std::string document_; 96 | std::string indentString_; 97 | int rightMargin_; 98 | int indentSize_; 99 | bool addChildValues_; 100 | }; 101 | 102 | /** \brief Writes a Value in JSON format in a human friendly way, 103 | to a stream rather than to a string. 104 | * 105 | * The rules for line break and indent are as follow: 106 | * - Object value: 107 | * - if empty then print {} without indent and line break 108 | * - if not empty the print '{', line break & indent, print one value per line 109 | * and then unindent and line break and print '}'. 110 | * - Array value: 111 | * - if empty then print [] without indent and line break 112 | * - if the array contains no object value, empty array or some other value types, 113 | * and all the values fit on one lines, then print the array on a single line. 114 | * - otherwise, it the values do not fit on one line, or the array contains 115 | * object or non empty array, then print one value per line. 116 | * 117 | * If the Value have comments then they are outputed according to their #CommentPlacement. 118 | * 119 | * \param indentation Each level will be indented by this amount extra. 120 | * \sa Reader, Value, Value::setComment() 121 | */ 122 | class JSON_API StyledStreamWriter 123 | { 124 | public: 125 | StyledStreamWriter( std::string indentation="\t" ); 126 | ~StyledStreamWriter(){} 127 | 128 | public: 129 | /** \brief Serialize a Value in JSON format. 130 | * \param out Stream to write to. (Can be ostringstream, e.g.) 131 | * \param root Value to serialize. 132 | * \note There is no point in deriving from Writer, since write() should not return a value. 133 | */ 134 | void write( std::ostream &out, const Value &root ); 135 | 136 | private: 137 | void writeValue( const Value &value ); 138 | void writeArrayValue( const Value &value ); 139 | bool isMultineArray( const Value &value ); 140 | void pushValue( const std::string &value ); 141 | void writeIndent(); 142 | void writeWithIndent( const std::string &value ); 143 | void indent(); 144 | void unindent(); 145 | void writeCommentBeforeValue( const Value &root ); 146 | void writeCommentAfterValueOnSameLine( const Value &root ); 147 | bool hasCommentForValue( const Value &value ); 148 | static std::string normalizeEOL( const std::string &text ); 149 | 150 | typedef std::vector ChildValues; 151 | 152 | ChildValues childValues_; 153 | std::ostream* document_; 154 | std::string indentString_; 155 | int rightMargin_; 156 | std::string indentation_; 157 | bool addChildValues_; 158 | }; 159 | 160 | std::string JSON_API valueToString( Int value ); 161 | std::string JSON_API valueToString( UInt value ); 162 | std::string JSON_API valueToString( double value ); 163 | std::string JSON_API valueToString( bool value ); 164 | std::string JSON_API valueToQuotedString( const char *value ); 165 | 166 | /// \brief Output using the StyledStreamWriter. 167 | /// \see Json::operator>>() 168 | std::ostream& operator<<( std::ostream&, const Value &root ); 169 | 170 | } // namespace Json 171 | 172 | 173 | 174 | #endif // JSON_WRITER_H_INCLUDED 175 | -------------------------------------------------------------------------------- /ComLib/TransferEncoder.cpp: -------------------------------------------------------------------------------- 1 | #include "TransferEncoder.h" 2 | #include "json/json.h" 3 | 4 | using namespace std; 5 | using namespace Json; 6 | 7 | /* 8 | { 9 | "cmd":"event", 10 | "content":{ 11 | "type":"proc_add", 12 | "data":{ 13 | "added":[ 14 | { 15 | "unique":12345, 16 | "pid":1234, 17 | "procPath":"d:\\abcdef.exe", 18 | "procDesc":"desc", 19 | "cmd":"abcdef", 20 | "startTime":"2018-11-11 11:11:11:123", 21 | "x64":1, 22 | "session":1, 23 | "user":"DESKTOP-DCTRL5K\\Administrator", 24 | "sid":"S-1-5-21-2669793992-3689076831-3814312677-500" 25 | }, 26 | ... 27 | ], 28 | "killed":[ 29 | 1111,2222,3333 30 | ] 31 | } 32 | } 33 | } 34 | */ 35 | utf8_mstring __stdcall EncodeProcMon(const ProcInfoSet &procSet) { 36 | Value root, added(arrayValue), killed(arrayValue); 37 | for (list::const_iterator it = procSet.mAddSet.begin() ; it != procSet.mAddSet.end() ; it++) 38 | { 39 | Value node; 40 | node["unique"] = (UINT)it->procUnique; 41 | node["pid"] = (UINT)it->procPid; 42 | node["procPath"] = it->procPath; 43 | node["procDesc"] = it->procDesc; 44 | node["cmd"] = it->procCmd; 45 | node["startTime"] = it->startTime; 46 | node["x64"] = int(it->x64); 47 | node["session"] = (UINT)it->sessionId; 48 | node["user"] = it->procUser; 49 | node["sid"] = it->procUserSid; 50 | added.append(node); 51 | } 52 | root["added"] = added; 53 | 54 | for (list::const_iterator ij = procSet.mKillSet.begin() ; ij != procSet.mKillSet.end() ; ij++) 55 | { 56 | killed.append((UINT)*ij); 57 | } 58 | root["killed"] = killed; 59 | return FastWriter().write(root); 60 | } 61 | 62 | ProcInfoSet __stdcall DecodeProcMon(const utf8_mstring &json) { 63 | ProcInfoSet result; 64 | Value root, added, killed; 65 | Reader().parse(json, root); 66 | added = root["added"], killed = root["killed"]; 67 | 68 | for (size_t i = 0 ; i != added.size() ; i++) 69 | { 70 | Value node = added[i]; 71 | ProcMonInfo info; 72 | info.procUnique = node["unique"].asUInt(); 73 | info.procPid = node["pid"].asUInt(); 74 | info.procPath = node["procPath"].asString(); 75 | info.procDesc = node["procDesc"].asString(); 76 | info.procCmd = node["cmd"].asString(); 77 | info.startTime = node["startTime"].asString(); 78 | info.x64 = node["x64"].asInt(); 79 | info.sessionId = node["session"].asInt(); 80 | info.procUser = node["user"].asString(); 81 | info.procUserSid = node["sid"].asString(); 82 | result.mAddSet.push_back(info); 83 | } 84 | 85 | for (size_t j = 0 ; j < killed.size() ; j++) 86 | { 87 | result.mKillSet.push_back(killed[j].asUInt()); 88 | } 89 | return result; 90 | } 91 | 92 | std::utf8_mstring _declspec(dllexport) __stdcall EncodeProcCreate(const ProcCreateInfo &info) { 93 | Value content; 94 | content["pid"] = (UINT)info.mPid; 95 | content["image"] = info.mImage; 96 | content["baseAddr"] = info.mBaseAddr; 97 | content["entryAddr"] = info.mEntryAddr; 98 | return FastWriter().write(content); 99 | } 100 | 101 | ProcCreateInfo _declspec(dllexport) __stdcall DecodeProcCreate(const std::utf8_mstring &json) { 102 | ProcCreateInfo info; 103 | Value content; 104 | Reader().parse(json, content); 105 | 106 | info.mPid = content["pid"].asUInt(); 107 | info.mImage = content["image"].asString(); 108 | info.mBaseAddr = content["baseAddr"].asString(); 109 | info.mEntryAddr = content["entryAddr"].asString(); 110 | return info; 111 | } 112 | 113 | /* 114 | { 115 | "cmd":"event", 116 | "content":{ 117 | "type":"moduleload", 118 | "data":{ 119 | "name":"kernel32.dll", 120 | "baseAddr":"0x4344353", 121 | "endAddr":"0x43443ff" 122 | } 123 | } 124 | } 125 | */ 126 | std::mstring _declspec(dllexport) __stdcall EncodeDllLoadInfo(const DllLoadInfo &info) { 127 | Value data; 128 | data["name"] = info.mDllName; 129 | data["baseAddr"] = info.mBaseAddr; 130 | data["endAddr"] = info.mEndAddr; 131 | 132 | return FastWriter().write(data); 133 | } 134 | 135 | DllLoadInfo _declspec(dllexport) __stdcall DecodeDllLoadInfo(const std::mstring &json) { 136 | DllLoadInfo info; 137 | Value content; 138 | Reader().parse(json, content); 139 | 140 | info.mDllName = content["name"].asString(); 141 | info.mBaseAddr = content["baseAddr"].asString(); 142 | info.mEndAddr = content["endAddr"].asString(); 143 | return info; 144 | } 145 | 146 | mstring _declspec(dllexport) __stdcall EncodeCmdRegister(const RegisterContent &context) { 147 | return "{}"; 148 | } 149 | 150 | RegisterContent _declspec(dllexport) __stdcall DecodeCmdRegister(const std::mstring &json) { 151 | return RegisterContent(); 152 | } 153 | 154 | /* 155 | { 156 | "cmd": "reply", 157 | "content": { 158 | "status": 0, 159 | "reason": "abcdef", 160 | "result":{ 161 | "cmdCode":0, 162 | "cmdShow":"abcd1234", 163 | "cmdResult": [{ 164 | "addr": "0x0xabcd12ff", 165 | "function":"kernel32!CreateFileW", 166 | "param0": "0xabcd1234", 167 | "param1": "0xabcd1234", 168 | "param2": "0xabcd1233", 169 | "param3": "0xabcd1233" 170 | }] 171 | } 172 | } 173 | } 174 | */ 175 | mstring _declspec(dllexport) __stdcall EncodeCmdCallStack(const CallStackData &callStack) { 176 | Value result(arrayValue); 177 | 178 | for (list::const_iterator it = callStack.mCallStack.begin() ; it != callStack.mCallStack.end() ; it++) 179 | { 180 | Value single; 181 | single["addr"] = it->mAddr; 182 | single["function"] = it->mFunction; 183 | single["param0"] = it->mParam0; 184 | single["param1"] = it->mParam1; 185 | single["param2"] = it->mParam2; 186 | single["param3"] = it->mParam3; 187 | result.append(single); 188 | } 189 | return FastWriter().write(result); 190 | } 191 | 192 | CallStackData __stdcall DecodeCmdCallStack(const mstring &json) { 193 | CallStackData data; 194 | Value result; 195 | 196 | Reader().parse(json, result); 197 | for (int i = 0 ; i < (int)result.size() ; i++) 198 | { 199 | Value singleJson = result[i]; 200 | CallStackSingle single; 201 | single.mAddr = singleJson["addr"].asString(); 202 | single.mFunction = singleJson["function"].asString(); 203 | single.mParam0 = singleJson["param0"].asString(); 204 | single.mParam1 = singleJson["param1"].asString(); 205 | single.mParam2 = singleJson["param2"].asString(); 206 | single.mParam3 = singleJson["param3"].asString(); 207 | data.mCallStack.push_back(single); 208 | } 209 | return data; 210 | } --------------------------------------------------------------------------------