├── .gitignore ├── CVSym ├── BinImage │ ├── BinImage.h │ ├── BinImage.vcproj │ ├── BinImage.vcxproj │ ├── BinImage.vcxproj.filters │ ├── BinImagePrivate.h │ ├── BinImagePublic.h │ ├── BinUtil.cpp │ ├── BinUtil.h │ ├── Common.cpp │ ├── Common.h │ ├── DbgFile.cpp │ ├── DbgFile.h │ ├── ImageFile.cpp │ ├── ImageFile.h │ └── targetver.h ├── CVSTI │ ├── CVSTI.h │ ├── CVSTI.rc │ ├── CVSTI.vcproj │ ├── CVSTI.vcxproj │ ├── CVSTI.vcxproj.filters │ ├── CVSTIPublic.cpp │ ├── CVSTIPublic.h │ ├── Common.cpp │ ├── Common.h │ ├── DataSource.cpp │ ├── DataSource.h │ ├── IAddressMap.h │ ├── IDataSource.h │ ├── IDebugContainer.h │ ├── ILoadCallback.h │ ├── ISession.h │ ├── ImageAddrMap.cpp │ ├── ImageAddrMap.h │ ├── ImageDebugContainer.cpp │ ├── ImageDebugContainer.h │ ├── STIUtil.h │ ├── Session.cpp │ ├── Session.h │ ├── dllmain.cpp │ ├── resource.h │ └── targetver.h ├── CVSym.sln ├── CVSym │ ├── CVExeFmt.h │ ├── CVRec.h │ ├── CVSym.h │ ├── CVSym.vcproj │ ├── CVSym.vcxproj │ ├── CVSym.vcxproj.filters │ ├── CVSymInternal.h │ ├── CVSymPublic.h │ ├── Common.cpp │ ├── Common.h │ ├── DebugStore.cpp │ ├── DebugStore.h │ ├── Error.h │ ├── ISymbolInfo.h │ ├── OMFAddrTable.h │ ├── OMFHashTable.h │ ├── PDBDebugStore.cpp │ ├── PDBDebugStore.h │ ├── ReadMe.txt │ ├── SymbolInfo.cpp │ ├── SymbolInfo.h │ ├── SymbolInfoBase.cpp │ ├── SymbolInfoBase.h │ ├── TypeInfo.cpp │ ├── TypeInfo.h │ ├── Util.cpp │ ├── Util.h │ ├── cvconst.h │ ├── cvexefmt_old.h │ ├── cvinfo.h │ ├── cvinfo_old.h │ └── targetver.h └── Include │ ├── MagoCVConst.h │ └── MagoCVSTI.h ├── DebugEngine ├── DebugEngine.sln ├── Debuggees │ ├── test1 │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── test1.cpp │ │ ├── test1.vcproj │ │ ├── test1.vcxproj │ │ └── test1.vcxproj.filters │ ├── testEvents │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── testEvents.cpp │ │ ├── testEvents.vcproj │ │ ├── testEvents.vcxproj │ │ └── testEvents.vcxproj.filters │ ├── testOptions │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── testOptions.cpp │ │ ├── testOptions.vcproj │ │ ├── testOptions.vcxproj │ │ └── testOptions.vcxproj.filters │ ├── testSleep │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── testSleep.cpp │ │ ├── testSleep.vcproj │ │ ├── testSleep.vcxproj │ │ └── testSleep.vcxproj.filters │ ├── testStepOneThread │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── testStepOneThread.cpp │ │ ├── testStepOneThread.vcproj │ │ ├── testStepOneThread.vcxproj │ │ └── testStepOneThread.vcxproj.filters │ └── testThread │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── testThread.cpp │ │ ├── testThread.vcproj │ │ ├── testThread.vcxproj │ │ └── testThread.vcxproj.filters ├── Exec │ ├── CommandFunctor.h │ ├── Common.cpp │ ├── Common.h │ ├── DebuggerProxy.cpp │ ├── DebuggerProxy.h │ ├── DecodeX86.cpp │ ├── DecodeX86.h │ ├── Enumerator.h │ ├── Error.h │ ├── EventCallback.h │ ├── Exec.cpp │ ├── Exec.h │ ├── Exec.vcproj │ ├── Exec.vcxproj │ ├── Exec.vcxproj.filters │ ├── IModule.h │ ├── IProcess.h │ ├── Iter.h │ ├── Log.cpp │ ├── Log.h │ ├── Machine.h │ ├── MachineX64.cpp │ ├── MachineX64.h │ ├── MachineX86.cpp │ ├── MachineX86.h │ ├── MachineX86Base.cpp │ ├── MachineX86Base.h │ ├── MakeMachine.cpp │ ├── MakeMachine.h │ ├── Module.cpp │ ├── Module.h │ ├── PathResolver.cpp │ ├── PathResolver.h │ ├── Process.cpp │ ├── Process.h │ ├── Thread.cpp │ ├── Thread.h │ ├── ThreadX86.cpp │ ├── ThreadX86.h │ ├── Types.h │ ├── Utility.cpp │ ├── Utility.h │ └── targetver.h ├── Include │ ├── MagoDECommon.h │ ├── MagoDEE.h │ ├── MagoRemoteCmd.acf │ ├── MagoRemoteCmd.idl │ ├── MagoRemoteCmd.idl.c │ ├── MagoRemoteCommon.idl │ ├── MagoRemoteEvent.acf │ ├── MagoRemoteEvent.idl │ ├── MagoRemoteEvent.idl.c │ └── WinPlat.h ├── MagoNatDE │ ├── ArchData.cpp │ ├── ArchData.h │ ├── ArchDataX64.cpp │ ├── ArchDataX64.h │ ├── ArchDataX86.cpp │ ├── ArchDataX86.h │ ├── BPBinderCallback.cpp │ ├── BPBinderCallback.h │ ├── BPBinders.cpp │ ├── BPBinders.h │ ├── BPDocumentContext.cpp │ ├── BPDocumentContext.h │ ├── BoundBreakpoint.cpp │ ├── BoundBreakpoint.h │ ├── BpResolutionLocation.h │ ├── BreakpointResolution.cpp │ ├── BreakpointResolution.h │ ├── CVDecls.cpp │ ├── CVDecls.h │ ├── CodeContext.cpp │ ├── CodeContext.h │ ├── ComEnumWithCount.h │ ├── Common.cpp │ ├── Common.h │ ├── Config.cpp │ ├── Config.h │ ├── DRuntime.cpp │ ├── DRuntime.h │ ├── DebuggerProxy.cpp │ ├── DebuggerProxy.h │ ├── DiaLoadCallback.cpp │ ├── DiaLoadCallback.h │ ├── DisassemblyStream.cpp │ ├── DisassemblyStream.h │ ├── DocTracker.cpp │ ├── DocTracker.h │ ├── DocumentContext.cpp │ ├── DocumentContext.h │ ├── Engine.cpp │ ├── Engine.h │ ├── Engine.rgs │ ├── EnumFrameInfo.cpp │ ├── EnumFrameInfo.h │ ├── EnumPropertyInfo.cpp │ ├── EnumPropertyInfo.h │ ├── EnumX86Reg.cpp │ ├── EnumX86Reg.h │ ├── ErrorBreakpoint.cpp │ ├── ErrorBreakpoint.h │ ├── ErrorBreakpointResolution.cpp │ ├── ErrorBreakpointResolution.h │ ├── ErrorProperty.cpp │ ├── ErrorProperty.h │ ├── EventCallback.cpp │ ├── EventCallback.h │ ├── Events.cpp │ ├── Events.h │ ├── ExceptionTable.cpp │ ├── ExceptionTable.h │ ├── Expr.cpp │ ├── Expr.h │ ├── ExprContext.cpp │ ├── ExprContext.h │ ├── FormatNum.cpp │ ├── FormatNum.h │ ├── FrameProperty.cpp │ ├── FrameProperty.h │ ├── ICoreProcess.h │ ├── IDebuggerProxy.h │ ├── IRemoteEventCallback.h │ ├── InstCache.cpp │ ├── InstCache.h │ ├── LocalProcess.cpp │ ├── LocalProcess.h │ ├── MagoNatDE.cpp │ ├── MagoNatDE.def │ ├── MagoNatDE.idl │ ├── MagoNatDE.idl.c │ ├── MagoNatDE.rc │ ├── MagoNatDE.rgs │ ├── MagoNatDE.vcproj │ ├── MagoNatDE.vcxproj │ ├── MagoNatDE.vcxproj.filters │ ├── MagoNatDEPS.vcproj │ ├── MagoNatDEps.def │ ├── MemoryBytes.cpp │ ├── MemoryBytes.h │ ├── Module.cpp │ ├── Module.h │ ├── PendingBreakpoint.cpp │ ├── PendingBreakpoint.h │ ├── Program.cpp │ ├── Program.h │ ├── ProgramNode.cpp │ ├── ProgramNode.h │ ├── Property.cpp │ ├── Property.h │ ├── ReadMe.txt │ ├── RegProperty.cpp │ ├── RegProperty.h │ ├── RegisterSet.cpp │ ├── RegisterSet.h │ ├── RemoteDebuggerProxy.cpp │ ├── RemoteDebuggerProxy.h │ ├── RemoteEventRpc.cpp │ ├── RemoteEventRpc.h │ ├── RemoteProcess.cpp │ ├── RemoteProcess.h │ ├── RpcUtil.cpp │ ├── RpcUtil.h │ ├── SingleDocumentContext.cpp │ ├── SingleDocumentContext.h │ ├── StackFrame.cpp │ ├── StackFrame.h │ ├── Thread.cpp │ ├── Thread.h │ ├── Utility.cpp │ ├── Utility.h │ ├── WinStackWalker.cpp │ ├── WinStackWalker.h │ ├── dbgmetric_alt.h │ ├── dllmain.cpp │ ├── dllmain.h │ ├── resource.h │ ├── targetver.h │ └── winternl2.h ├── MagoRemote │ ├── App.cpp │ ├── App.h │ ├── Common.cpp │ ├── Common.h │ ├── EventCallback.cpp │ ├── EventCallback.h │ ├── MagoRemote.cpp │ ├── MagoRemote.h │ ├── MagoRemote.ico │ ├── MagoRemote.rc │ ├── MagoRemote.vcproj │ ├── MagoRemote.vcxproj │ ├── MagoRemote.vcxproj.filters │ ├── MagoRemoteSmall.ico │ ├── ReadMe.txt │ ├── RemoteCmdRpc.cpp │ ├── RemoteCmdRpc.h │ ├── RpcUtil.cpp │ ├── RpcUtil.h │ ├── resource.h │ └── targetver.h └── UnitTests │ ├── utest1 │ ├── stdafx.cpp │ ├── stdafx.h │ ├── targetver.h │ ├── utest1.cpp │ ├── utest1.vcproj │ ├── utest1.vcxproj │ └── utest1.vcxproj.filters │ └── utestExec │ ├── EventCallbackBase.cpp │ ├── EventCallbackBase.h │ ├── EventSuite.cpp │ ├── EventSuite.h │ ├── MultiEventCallbackBase.cpp │ ├── MultiEventCallbackBase.h │ ├── StartStopSuite.cpp │ ├── StartStopSuite.h │ ├── StepOneThreadSuite.cpp │ ├── StepOneThreadSuite.h │ ├── Utility.cpp │ ├── Utility.h │ ├── stdafx.cpp │ ├── stdafx.h │ ├── targetver.h │ ├── utestExec.cpp │ ├── utestExec.vcproj │ ├── utestExec.vcxproj │ └── utestExec.vcxproj.filters ├── EED ├── EED.sln ├── EED │ ├── Array.h │ ├── Common.cpp │ ├── Common.h │ ├── Declaration.h │ ├── EE.h │ ├── EED.cpp │ ├── EED.h │ ├── EED.vcproj │ ├── EED.vcxproj │ ├── EED.vcxproj.filters │ ├── EnumValues.cpp │ ├── EnumValues.h │ ├── Error.h │ ├── Eval.cpp │ ├── Eval.h │ ├── EvalAssign.cpp │ ├── EvalBARL.cpp │ ├── EvalLiteral.cpp │ ├── EvalOther.cpp │ ├── Expression.cpp │ ├── Expression.h │ ├── FormatValue.cpp │ ├── FormatValue.h │ ├── FromRawValue.cpp │ ├── FromRawValue.h │ ├── ITypeEnv.h │ ├── Keywords.cpp │ ├── Keywords.h │ ├── NameTable.h │ ├── NamedChars.cpp │ ├── NamedChars.h │ ├── Object.cpp │ ├── Object.h │ ├── Parser.cpp │ ├── Parser.h │ ├── ParserDecl.cpp │ ├── PropTables.cpp │ ├── PropTables.h │ ├── Properties.cpp │ ├── Properties.h │ ├── Property.h │ ├── ReadMe.txt │ ├── Scanner.cpp │ ├── Scanner.h │ ├── SharedString.cpp │ ├── SharedString.h │ ├── SimpleNameTable.cpp │ ├── SimpleNameTable.h │ ├── Strings.h │ ├── Token.h │ ├── Type.cpp │ ├── Type.h │ ├── TypeCommon.h │ ├── TypeEnv.cpp │ ├── TypeEnv.h │ ├── TypeUnresolved.cpp │ ├── TypeUnresolved.h │ ├── UniAlpha.cpp │ ├── UniAlpha.h │ └── targetver.h ├── EEDTest │ ├── AppSettings.h │ ├── BuildingContentHandler.cpp │ ├── BuildingContentHandler.h │ ├── Common.cpp │ ├── Common.h │ ├── DataElement.cpp │ ├── DataElement.h │ ├── DataEnv.cpp │ ├── DataEnv.h │ ├── DataValue.cpp │ ├── DataValue.h │ ├── DeclDataElement.cpp │ ├── DeclDataElement.h │ ├── DiaDecls.cpp │ ├── DiaDecls.h │ ├── EEDTest.cpp │ ├── EEDTest.vcproj │ ├── EEDTest.vcxproj │ ├── EEDTest.vcxproj.filters │ ├── Element.h │ ├── ErrorStr.cpp │ ├── ErrorStr.h │ ├── EventCallbackBase.cpp │ ├── EventCallbackBase.h │ ├── GenTests │ │ ├── genArithTest.d │ │ ├── genCastTest.d │ │ ├── genUnaryTest.d │ │ ├── hash.ps1 │ │ ├── makeBin.ps1 │ │ ├── makeRel1.ps1 │ │ ├── makeUna.ps1 │ │ └── testAll.ps1 │ ├── PrintingContentHandler.cpp │ ├── PrintingContentHandler.h │ ├── ProgValueEnv.cpp │ ├── ProgValueEnv.h │ ├── RefDataElement.cpp │ ├── RefDataElement.h │ ├── SampleData.xml │ ├── SampleTest.xml │ ├── SaxErrorHandler.cpp │ ├── SaxErrorHandler.h │ ├── SymUtil.cpp │ ├── SymUtil.h │ ├── TestElement.cpp │ ├── TestElement.h │ ├── TestReal10.cpp │ ├── TypeDataElement.cpp │ ├── TypeDataElement.h │ ├── ValueDataElement.cpp │ ├── ValueDataElement.h │ ├── targetver.h │ └── winternl2.h ├── Include │ └── MagoEED.h ├── MagoGC │ ├── MagoGC.vcxproj │ └── magogc.d ├── MagoNatCC │ ├── .vsdbg-config.json │ ├── MagoNatCC.def │ ├── MagoNatCC.rc │ ├── MagoNatCC.vcxproj │ ├── MagoNatCC.vcxproj.filters │ ├── MagoNatCC.vsdconfigxml │ ├── MagoNatCCService.cpp │ ├── MagoNatCCService.h │ ├── Resource.h │ ├── dllmain.cpp │ ├── dllmain.h │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h ├── MagoNatEE │ ├── Common.cpp │ ├── Common.h │ ├── MagoNatEE.cpp │ ├── MagoNatEE.h │ ├── MagoNatEE.rc │ ├── MagoNatEE.vcproj │ ├── MagoNatEE.vcxproj │ ├── MagoNatEE.vcxproj.filters │ ├── dllmain.cpp │ ├── resource.h │ └── targetver.h ├── Real │ ├── Common.h │ ├── Complex.cpp │ ├── Complex.h │ ├── Real.cpp │ ├── Real.h │ ├── Real.vcproj │ ├── Real.vcxproj │ ├── Real.vcxproj.filters │ ├── Real_x64.asm │ └── targetver.h ├── ddemangle │ ├── COPYING.LIB │ ├── COPYING3.LIB │ ├── d-demangle.c │ ├── demangle.h │ ├── libiberty.h │ └── safe-ctype.h └── gdtoa │ ├── README │ ├── arith.h │ ├── dmisc.c │ ├── dtoa.c │ ├── g_Qfmt.c │ ├── g__fmt.c │ ├── g_ddfmt.c │ ├── g_dfmt.c │ ├── g_ffmt.c │ ├── g_xLfmt.c │ ├── g_xfmt.c │ ├── gd_qnan.h │ ├── gdcvt.c │ ├── gdtoa.c │ ├── gdtoa.h │ ├── gdtoa.vcproj │ ├── gdtoa.vcxproj │ ├── gdtoa.vcxproj.filters │ ├── gdtoa_fltrnds.h │ ├── gdtoaimp.h │ ├── gethex.c │ ├── gmisc.c │ ├── hd_init.c │ ├── hexnan.c │ ├── misc.c │ ├── printf.c │ ├── printf.c0 │ ├── smisc.c │ ├── stdafx.cpp │ ├── stdafx.h │ ├── stdio1.h │ ├── strtoIQ.c │ ├── strtoId.c │ ├── strtoIdd.c │ ├── strtoIf.c │ ├── strtoIg.c │ ├── strtoIx.c │ ├── strtoIxL.c │ ├── strtod.c │ ├── strtodI.c │ ├── strtodg.c │ ├── strtodnrp.c │ ├── strtof.c │ ├── strtopQ.c │ ├── strtopd.c │ ├── strtopdd.c │ ├── strtopf.c │ ├── strtopx.c │ ├── strtopxL.c │ ├── strtorQ.c │ ├── strtord.c │ ├── strtordd.c │ ├── strtorf.c │ ├── strtorx.c │ ├── strtorxL.c │ ├── sum.c │ └── ulp.c ├── Include ├── Guard.h ├── MagoTargetVer.h ├── MagoVersion.h └── SmartPtr.h ├── Install ├── EngineMetrics_2005_32.reg ├── EngineMetrics_2005_64.reg ├── EngineMetrics_2008_32.reg ├── EngineMetrics_2008_64.reg ├── EngineMetrics_2010_32.reg ├── EngineMetrics_2010_64.reg ├── EngineMetrics_2013_32.reg ├── EngineMetrics_2013_64.reg ├── Exceptions_2005_32.reg ├── Exceptions_2005_64.reg ├── Exceptions_2008_32.reg ├── Exceptions_2008_64.reg ├── Exceptions_2010_32.reg └── Exceptions_2010_64.reg ├── LICENSE.txt ├── MagoDELauncher ├── MagoDELauncher.sln └── MagoDELauncher │ ├── AssemblyInfo.cs │ ├── CommandBar.resx │ ├── Connect.cs │ ├── LaunchForm.Designer.cs │ ├── LaunchForm.cs │ ├── LaunchForm.resx │ ├── MagoDELauncher.AddIn │ └── MagoDELauncher.csproj ├── MagoDbg.sln ├── MagoDbg_2010.sln ├── MagoMI ├── editline │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── README │ ├── editline.vcxproj │ ├── include │ │ └── readline.h │ └── source │ │ ├── config.h │ │ ├── editline.c │ │ ├── el_globals.h │ │ ├── fn_complete.c │ │ ├── histedit.h │ │ └── history.c ├── gdblogger │ ├── gdblogger.cpp │ └── gdblogger.vcxproj └── mago-mi │ ├── README.md │ ├── mago-mi.vcxproj │ └── source │ ├── MIEngine.cpp │ ├── MIEngine.h │ ├── cmdinput.cpp │ ├── cmdinput.h │ ├── cmdline.cpp │ ├── cmdline.h │ ├── debugger.cpp │ ├── debugger.h │ ├── logger.cpp │ ├── logger.h │ ├── mago-mi.cpp │ ├── micommand.cpp │ ├── micommand.h │ ├── miutils.cpp │ └── miutils.h ├── NOTICE.txt ├── PropSheets ├── MagoDbg_properties.props ├── MagoDbg_winsdk.props └── ReadMe.txt ├── ReadMe.txt ├── appveyor.yml ├── cpptest ├── AUTHORS ├── BUGS ├── COPYING ├── ChangeLog ├── INSTALL ├── INSTALL.quick ├── INSTALL.quick.in ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── README.in ├── aclocal.m4 ├── autogen.sh ├── config │ ├── config.guess │ ├── config.h.in │ ├── config.sub │ ├── depcomp │ ├── install-sh │ ├── ltmain.sh │ ├── missing │ └── stamp-h.in ├── configure ├── configure.ac ├── doc │ ├── Doxyfile │ ├── Doxyfile.in │ ├── Makefile.am │ ├── Makefile.in │ ├── footer.html │ ├── header.html │ ├── images │ │ ├── html-example.html │ │ ├── screenshot-compiler.png │ │ ├── screenshot-text-terse.png │ │ └── screenshot-text-verbose.png │ ├── main.dox │ ├── test.dox │ └── tutorial.dox ├── libcpptest.pc ├── libcpptest.pc.in ├── src │ ├── Makefile.am │ ├── Makefile.in │ ├── collectoroutput.cpp │ ├── compileroutput.cpp │ ├── cpptest-assert.h │ ├── cpptest-collectoroutput.h │ ├── cpptest-compileroutput.h │ ├── cpptest-htmloutput.h │ ├── cpptest-output.h │ ├── cpptest-source.h │ ├── cpptest-suite.h │ ├── cpptest-textoutput.h │ ├── cpptest-time.h │ ├── cpptest.h │ ├── htmloutput.cpp │ ├── missing.cpp │ ├── missing.h │ ├── source.cpp │ ├── suite.cpp │ ├── textoutput.cpp │ ├── time.cpp │ ├── utils.cpp │ └── utils.h ├── test │ ├── Makefile.am │ ├── Makefile.in │ └── mytest.cpp └── win │ ├── cpptest.vcxproj │ └── winconfig.h └── udis86 ├── LICENSE.txt ├── _ReadMe.txt ├── config.h ├── config.h.in ├── docs ├── Makefile.am ├── manual │ ├── Makefile.am │ ├── conf.py │ ├── getstarted.rst │ ├── index.rst │ ├── libudis86.rst │ └── static │ │ └── udis86.css └── x86 │ ├── Makefile.am │ ├── README │ ├── avx.xml │ ├── optable.xml │ └── optable.xsl ├── libudis86 ├── decode.c ├── decode.h ├── extern.h ├── input.c ├── input.h ├── itab.c ├── itab.h ├── libudis86.vcproj ├── libudis86.vcxproj ├── libudis86.vcxproj.filters ├── syn-att.c ├── syn-intel.c ├── syn.c ├── syn.h ├── types.h ├── udint.h └── udis86.c ├── udcli ├── Makefile.am ├── udcli.c └── udcli.vcproj ├── udis86.h ├── udis86.sln └── udis86 ├── resource.h ├── udis86.def ├── udis86.rc ├── udis86.vcproj ├── udis86.vcxproj └── udis86.vcxproj.filters /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /ipch 3 | /.vs 4 | *.user 5 | -------------------------------------------------------------------------------- /CVSym/BinImage/BinImage.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #include "BinImagePublic.h" 12 | #include "ImageFile.h" 13 | #include "DbgFile.h" 14 | -------------------------------------------------------------------------------- /CVSym/BinImage/BinImagePrivate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | inline HRESULT GetLastHr() 12 | { 13 | return HRESULT_FROM_WIN32( GetLastError() ); 14 | } 15 | 16 | 17 | const HRESULT E_BAD_FORMAT = HRESULT_FROM_WIN32( ERROR_BAD_FORMAT ); 18 | 19 | 20 | const DWORD MaxSectionCount = 96; 21 | -------------------------------------------------------------------------------- /CVSym/BinImage/BinImagePublic.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | struct DataDirInfo 12 | { 13 | uint32_t FileOffset; 14 | uint32_t Size; 15 | IMAGE_SECTION_HEADER* SectionHeader; 16 | }; 17 | -------------------------------------------------------------------------------- /CVSym/BinImage/BinUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | bool FindDataDirectoryData( 12 | WORD dirCount, 13 | IMAGE_DATA_DIRECTORY* dataDirs, 14 | WORD secCount, 15 | IMAGE_SECTION_HEADER* secHeaders, 16 | bool mappedAsImage, 17 | WORD dirEntryId, 18 | DataDirInfo& dirInfo ); 19 | -------------------------------------------------------------------------------- /CVSym/BinImage/Common.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BinImage.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /CVSym/BinImage/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #include "targetver.h" 16 | 17 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 18 | 19 | // C 20 | #include 21 | #include 22 | 23 | // Windows 24 | #include 25 | 26 | // Magus 27 | #include 28 | 29 | // This project 30 | #include "BinImagePrivate.h" 31 | #include "BinImagePublic.h" 32 | -------------------------------------------------------------------------------- /CVSym/BinImage/DbgFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace BinImage 12 | { 13 | class DbgFile 14 | { 15 | FileHandlePtr mHFile; 16 | HandlePtr mHMapping; 17 | 18 | IMAGE_SEPARATE_DEBUG_HEADER mHeader; 19 | BYTE* mSecHeaderBuf; 20 | 21 | public: 22 | DbgFile(); 23 | ~DbgFile(); 24 | 25 | HRESULT LoadFile( const wchar_t* filename ); 26 | 27 | bool Validate( DWORD timeDateStamp ); 28 | 29 | const IMAGE_SEPARATE_DEBUG_HEADER* GetHeader(); 30 | const IMAGE_SECTION_HEADER* GetSectionHeaders(); 31 | const IMAGE_DEBUG_DIRECTORY* GetDebugDirs(); 32 | 33 | HRESULT GetFileHandle( HANDLE& handle ); 34 | HRESULT GetMappingHandle( HANDLE& handle ); 35 | }; 36 | } 37 | -------------------------------------------------------------------------------- /CVSym/BinImage/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /CVSym/CVSTI/CVSTI.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #include "CVSTIPublic.h" 12 | 13 | #include "../CVSym/CVSymPublic.h" 14 | #include "../CVSym/ISymbolInfo.h" 15 | 16 | #include "IDataSource.h" 17 | #include "ISession.h" 18 | #include "ILoadCallback.h" 19 | -------------------------------------------------------------------------------- /CVSym/CVSTI/CVSTIPublic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #include "Common.h" 9 | #include "CVSTIPublic.h" 10 | #include "DataSource.h" 11 | 12 | 13 | namespace MagoST 14 | { 15 | HRESULT MakeDataSource( IDataSource*& dataSource ) 16 | { 17 | RefPtr newDataSource; 18 | 19 | newDataSource = new DataSource(); 20 | if ( newDataSource == NULL ) 21 | return E_OUTOFMEMORY; 22 | 23 | dataSource = newDataSource.Detach(); 24 | 25 | return S_OK; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CVSym/CVSTI/CVSTIPublic.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #if 1 // building into static library now 12 | #define EXPORT 13 | #elif defined( CVSTI_EXPORTS ) 14 | #define EXPORT __declspec( dllexport ) 15 | #else 16 | #define EXPORT __declspec( dllimport ) 17 | #endif 18 | 19 | 20 | namespace MagoST 21 | { 22 | class IDataSource; 23 | 24 | 25 | EXPORT HRESULT MakeDataSource( IDataSource*& dataSource ); 26 | } 27 | -------------------------------------------------------------------------------- /CVSym/CVSTI/Common.cpp: -------------------------------------------------------------------------------- 1 | // Common.cpp : source file that includes just the standard includes 2 | // CVSTI.pch will be the pre-compiled header 3 | // Common.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /CVSym/CVSTI/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #include "targetver.h" 16 | 17 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 18 | 19 | // C 20 | #include 21 | #include 22 | 23 | // STL 24 | #include 25 | #include 26 | #include 27 | 28 | // Windows 29 | #include 30 | 31 | // Magus 32 | #include 33 | 34 | // CVSym project 35 | #include "..\CVSym\Error.h" 36 | #include "..\CVSym\CVSym.h" 37 | 38 | // BinImage project 39 | #include "..\BinImage\BinImage.h" 40 | 41 | // Windows declarations that I don't want 42 | #undef max 43 | #undef min 44 | -------------------------------------------------------------------------------- /CVSym/CVSTI/DataSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "IDataSource.h" 11 | #include 12 | 13 | namespace MagoST 14 | { 15 | class IDebugContainer; 16 | class IAddressMap; 17 | 18 | 19 | class DataSource : public IDataSource 20 | { 21 | long mRefCount; 22 | 23 | std::unique_ptr mDebugContainer; 24 | BYTE* mDebugView; 25 | DWORD mDebugSize; 26 | MagoST::IDebugStore* mStore; 27 | 28 | RefPtr mAddrMap; 29 | 30 | public: 31 | DataSource(); 32 | ~DataSource(); 33 | 34 | virtual void AddRef(); 35 | virtual void Release(); 36 | 37 | virtual HRESULT LoadDataForExe( 38 | const wchar_t* filename, 39 | ILoadCallback* callback ); 40 | 41 | virtual HRESULT InitDebugInfo( const wchar_t* filename, const wchar_t* searchPath ); 42 | 43 | virtual HRESULT InitDebugInfo( IDiaSession* session, IAddressMap* addrMap ); 44 | 45 | virtual HRESULT OpenSession( ISession*& session ); 46 | 47 | IDebugStore* GetDebugStore(); 48 | RefPtr GetAddressMap(); 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /CVSym/CVSTI/IAddressMap.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoST 12 | { 13 | class IAddressMap 14 | { 15 | public: 16 | virtual void AddRef() = 0; 17 | virtual void Release() = 0; 18 | 19 | // returns ~0 on section not found 20 | virtual uint32_t MapSecOffsetToRVA( uint16_t secIndex, uint32_t offset ) = 0; 21 | virtual uint16_t MapRVAToSecOffset( uint32_t rva, uint32_t& offset ) = 0; 22 | virtual uint16_t FindSection( const char* name ) = 0; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /CVSym/CVSTI/IDataSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | struct IDiaSession; 11 | 12 | namespace MagoST 13 | { 14 | class IAddressMap; 15 | class ISession; 16 | class ILoadCallback; 17 | 18 | 19 | class IDataSource 20 | { 21 | public: 22 | virtual void AddRef() = 0; 23 | virtual void Release() = 0; 24 | 25 | virtual HRESULT LoadDataForExe( 26 | const wchar_t* filename, 27 | ILoadCallback* callback ) = 0; 28 | 29 | virtual HRESULT InitDebugInfo( const wchar_t* filename, const wchar_t* searchPath ) = 0; 30 | 31 | virtual HRESULT InitDebugInfo( IDiaSession* session, IAddressMap* addrMap ) = 0; 32 | 33 | virtual HRESULT OpenSession( ISession*& session ) = 0; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /CVSym/CVSTI/IDebugContainer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoST 12 | { 13 | class IAddressMap; 14 | 15 | 16 | class IDebugContainer 17 | { 18 | public: 19 | virtual ~IDebugContainer() { } 20 | 21 | virtual HRESULT LockDebugSection( BYTE*& bytes, DWORD& size ) = 0; 22 | virtual HRESULT UnlockDebugSection( BYTE* bytes ) = 0; 23 | 24 | virtual bool HasAddressMap() = 0; 25 | virtual HRESULT GetAddressMap( IAddressMap*& map ) = 0; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /CVSym/CVSTI/ILoadCallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoST 12 | { 13 | class ILoadCallback 14 | { 15 | public: 16 | virtual void AddRef() = 0; 17 | virtual void Release() = 0; 18 | 19 | virtual HRESULT NotifyDebugDir ( 20 | bool fExecutable, 21 | DWORD cbData, 22 | BYTE data[] 23 | ) = 0; 24 | 25 | virtual HRESULT NotifyOpenDBG ( 26 | const wchar_t* dbgPath, 27 | HRESULT resultCode 28 | ) = 0; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /CVSym/CVSTI/ImageAddrMap.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "IAddressMap.h" 11 | 12 | struct IDiaSession; 13 | 14 | namespace MagoST 15 | { 16 | class ImageAddrMap : public IAddressMap 17 | { 18 | struct Section 19 | { 20 | uint32_t RVA; 21 | uint32_t Size; 22 | char Name[8]; 23 | }; 24 | 25 | long mRefCount; 26 | UniquePtr mSections; 27 | uint16_t mSecCount; 28 | 29 | public: 30 | ImageAddrMap(); 31 | 32 | virtual void AddRef(); 33 | virtual void Release(); 34 | 35 | virtual uint32_t MapSecOffsetToRVA( uint16_t secIndex, uint32_t offset ); 36 | virtual uint16_t MapRVAToSecOffset( uint32_t rva, uint32_t& offset ); 37 | virtual uint16_t FindSection( const char* name ); 38 | 39 | HRESULT LoadFromSections( uint16_t count, const IMAGE_SECTION_HEADER* secHeaders ); 40 | 41 | HRESULT LoadFromDiaSession( IDiaSession* session ); 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /CVSym/CVSTI/ImageDebugContainer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "IDebugContainer.h" 11 | #include 12 | 13 | 14 | namespace MagoST 15 | { 16 | class ILoadCallback; 17 | 18 | 19 | class ImageDebugContainer : public IDebugContainer 20 | { 21 | std::unique_ptr mImage; 22 | std::unique_ptr mDbg; 23 | IMAGE_DEBUG_DIRECTORY mDebugDir; 24 | 25 | public: 26 | HRESULT LoadExe( const wchar_t* filename, ILoadCallback* callback ); 27 | HRESULT LoadDbg( const wchar_t* filename, ILoadCallback* callback ); 28 | 29 | virtual HRESULT LockDebugSection( BYTE*& bytes, DWORD& size ); 30 | virtual HRESULT UnlockDebugSection( BYTE* bytes ); 31 | 32 | virtual bool HasAddressMap(); 33 | virtual HRESULT GetAddressMap( IAddressMap*& map ); 34 | 35 | private: 36 | HRESULT LoadDbg( 37 | BinImage::ImageFile* image, 38 | const IMAGE_DEBUG_DIRECTORY* miscDebugDir, 39 | ILoadCallback* callback ); 40 | 41 | static void AlignAddress( DWORD unalignedAddr, DWORD& alignedAddr, DWORD& diff ); 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /CVSym/CVSTI/STIUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | inline HRESULT GetLastHr() 12 | { 13 | return HRESULT_FROM_WIN32( GetLastError() ); 14 | } 15 | 16 | struct MappedDeleter 17 | { 18 | static void Delete( void* p ) 19 | { 20 | BOOL bRet = UnmapViewOfFile( p ); 21 | UNREFERENCED_PARAMETER( bRet ); 22 | _ASSERT( bRet ); 23 | } 24 | }; 25 | 26 | struct MappedPtr : UniquePtrBase 27 | { 28 | MappedPtr() 29 | : UniquePtrBase() 30 | { 31 | } 32 | 33 | explicit MappedPtr( void* ptr ) 34 | : UniquePtrBase( ptr ) 35 | { 36 | } 37 | 38 | ~MappedPtr() 39 | { 40 | Delete(); 41 | } 42 | 43 | MappedPtr& operator=( void* ptr ) 44 | { 45 | Attach( ptr ); 46 | return *this; 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /CVSym/CVSTI/dllmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | 7 | Purpose: Defines the entry point for the DLL 8 | */ 9 | 10 | #include "Common.h" 11 | 12 | 13 | BOOL APIENTRY DllMain( HMODULE hModule, 14 | DWORD reason, 15 | LPVOID lpReserved ) 16 | { 17 | UNREFERENCED_PARAMETER( lpReserved ); 18 | 19 | switch ( reason ) 20 | { 21 | case DLL_PROCESS_ATTACH: 22 | DisableThreadLibraryCalls( hModule ); 23 | break; 24 | 25 | case DLL_THREAD_ATTACH: 26 | case DLL_THREAD_DETACH: 27 | case DLL_PROCESS_DETACH: 28 | break; 29 | } 30 | 31 | return TRUE; 32 | } 33 | -------------------------------------------------------------------------------- /CVSym/CVSTI/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by CVSTI.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /CVSym/CVSTI/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /CVSym/CVSym/CVSym.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #include "CVSymPublic.h" 12 | #include "DebugStore.h" 13 | #include "ISymbolInfo.h" 14 | -------------------------------------------------------------------------------- /CVSym/CVSym/Common.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // CVSym.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /CVSym/CVSym/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #include "targetver.h" 16 | 17 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 18 | 19 | // C 20 | #include 21 | #include 22 | 23 | // STL 24 | #include 25 | #include 26 | 27 | // Windows 28 | #include 29 | 30 | // Magus 31 | #include 32 | 33 | // This project 34 | #include "Error.h" 35 | #include "CVSymPublic.h" 36 | #include "CVSymInternal.h" 37 | #include "CVRec.h" 38 | #include "CVExeFmt.h" 39 | -------------------------------------------------------------------------------- /CVSym/CVSym/Error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | const HRESULT E_ALREADY_INIT = HRESULT_FROM_WIN32( ERROR_ALREADY_INITIALIZED ); 12 | const HRESULT E_NOT_FOUND = HRESULT_FROM_WIN32( ERROR_NOT_FOUND ); 13 | const HRESULT E_INSUFFICIENT_BUFFER = HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER ); 14 | const HRESULT E_BAD_FORMAT = HRESULT_FROM_WIN32( ERROR_BAD_FORMAT ); 15 | -------------------------------------------------------------------------------- /CVSym/CVSym/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Allowing symbol names longer than 255 characters in CodeView 2 | ------------------------------------------------------------ 3 | 4 | Important: This is a non-standard extension. 5 | 6 | Because the CodeView debug information format limits the names of symbols to 7 | 255 characters, the D compiler DMD uses a new encoding that allows for names 8 | that are longer than the official limit. 9 | 10 | The following is the special encoding is used for non-public symbols. 11 | 12 | 1. If the name is less than or equal to 255 characters, then the standard 13 | encoding is used, where there is a 1 byte length prefix. 14 | 2. Otherwise, the bytes of the name are laid out as follows: 15 | a. 1 byte: 255 16 | b. 1 byte: 0 17 | c. 2 bytes: the real name length (little endian) 18 | d. * bytes: the real name characters 19 | -------------------------------------------------------------------------------- /CVSym/CVSym/Util.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | union CodeViewFieldType; 13 | union CodeViewSymbol; 14 | 15 | struct SymString; 16 | 17 | namespace MagoST 18 | { 19 | struct Variant; 20 | } 21 | 22 | 23 | uint16_t GetNumLeafSize( uint16_t* numLeaf ); 24 | void GetNumLeafValue( uint16_t* numLeaf, MagoST::Variant& value ); 25 | uint32_t GetUIntValue( uint16_t* numericLeaf ); 26 | DWORD GetFieldLength( CodeViewFieldType* type ); 27 | bool QuickGetAddrOffset( CodeViewSymbol* sym, uint32_t& offset ); 28 | bool QuickGetName( CodeViewSymbol* sym, SymString& name ); 29 | bool QuickGetAddrSegment( CodeViewSymbol* sym, uint16_t& segment ); 30 | bool QuickGetLength( CodeViewSymbol* sym, uint32_t& length ); 31 | 32 | bool ExactFileNameMatch( const char* pathA, size_t pathALen, const char* pathB, size_t pathBLen ); 33 | bool PartialFileNameMatch( const char* pathA, size_t pathALen, const char* pathB, size_t pathBLen ); 34 | 35 | std::wstring SymStringToWString( const SymString& sym ); 36 | -------------------------------------------------------------------------------- /CVSym/CVSym/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /CVSym/Include/MagoCVConst.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #include "..\CVSym\cvconst.h" 12 | -------------------------------------------------------------------------------- /CVSym/Include/MagoCVSTI.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | // CodeView/STI symbol table 12 | #include "..\CVSTI\CVSTI.h" 13 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/test1/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // test1.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/test1/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/test1/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/test1/test1.cpp: -------------------------------------------------------------------------------- 1 | // test1.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | 7 | int _tmain(int argc, _TCHAR* argv[]) 8 | { 9 | int i = 0; 10 | i++; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/test1/test1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testEvents/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // testEvents.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testEvents/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testEvents/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testEvents/testEvents.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/DebugEngine/Debuggees/testEvents/testEvents.cpp -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testEvents/testEvents.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testOptions/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // testOptions.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testOptions/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testOptions/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testOptions/testOptions.cpp: -------------------------------------------------------------------------------- 1 | // testOptions.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | 7 | 8 | int _tmain(int argc, _TCHAR* argv[]) 9 | { 10 | if ( argc != 4 ) 11 | return 1; 12 | 13 | wchar_t dir[ MAX_PATH ] = L""; 14 | 15 | // Buffer everything, so the test doesn't get partial results. 16 | setvbuf( stderr, NULL, _IOFBF, 1000 ); 17 | setvbuf( stdout, NULL, _IOFBF, 1000 ); 18 | setvbuf( stdin, NULL, _IOFBF, 1000 ); 19 | 20 | GetCurrentDirectory( _countof( dir ), dir ); 21 | 22 | fwprintf( stderr, L"%ls\n", argv[3] ); 23 | fwprintf( stderr, L"%ls\n", argv[1] ); 24 | fwprintf( stderr, L"%ls\n", argv[2] ); 25 | fwprintf( stderr, L"%ls\n", dir ); 26 | 27 | for ( int i = 0; i < 3; i++ ) 28 | { 29 | char varName[256] = ""; 30 | char varVal[256] = ""; 31 | 32 | scanf_s( "%s", varName, _countof( varName ) ); 33 | 34 | GetEnvironmentVariableA( varName, varVal, _countof( varVal ) ); 35 | 36 | //OutputDebugStringA( varName ); 37 | //OutputDebugStringA( varVal ); 38 | 39 | printf( "%s\n", varVal ); 40 | } 41 | 42 | // flush these in the same order that test will read them 43 | fflush( stderr ); 44 | fflush( stdout ); 45 | 46 | return -333; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testOptions/testOptions.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testSleep/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // testSleep.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testSleep/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testSleep/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testSleep/testSleep.cpp: -------------------------------------------------------------------------------- 1 | // testSleep.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | 7 | int _tmain(int argc, _TCHAR* argv[]) 8 | { 9 | Sleep( INFINITE ); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testSleep/testSleep.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testStepOneThread/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // testStepOneThread.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testStepOneThread/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testStepOneThread/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testStepOneThread/testStepOneThread.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testThread/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // testThread.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testThread/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testThread/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testThread/testThread.cpp: -------------------------------------------------------------------------------- 1 | // testThread.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | 6 | 7 | DWORD CALLBACK ThreadProc( void* param ) 8 | { 9 | Sleep( 1500 ); 10 | _asm 11 | { 12 | //mov ebx, 0 13 | //idiv ebx 14 | //int 3 15 | mov eax, 0 16 | } 17 | Sleep( 6000 ); 18 | return 0; 19 | } 20 | 21 | int _tmain(int argc, _TCHAR* argv[]) 22 | { 23 | HANDLE hThread[2] = { 0 }; 24 | 25 | Sleep( 1000 ); 26 | 27 | hThread[0] = CreateThread( 28 | NULL, 29 | 0, 30 | ThreadProc, 31 | NULL, 32 | 0, 33 | NULL ); 34 | 35 | hThread[1] = CreateThread( 36 | NULL, 37 | 0, 38 | ThreadProc, 39 | NULL, 40 | 0, 41 | NULL ); 42 | 43 | Sleep( 4500 ); 44 | 45 | WaitForMultipleObjects( _countof( hThread ), hThread, TRUE, INFINITE ); 46 | 47 | return 0; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /DebugEngine/Debuggees/testThread/testThread.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /DebugEngine/Exec/Common.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Exec.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/Exec/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #define _CRTDBG_MAP_ALLOC 16 | 17 | #include "targetver.h" 18 | 19 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 20 | 21 | // C 22 | #include 23 | #include 24 | #include 25 | 26 | // C++ 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | // Windows 35 | #include 36 | // these are just a few of many that are more trouble than they're worth 37 | #undef min 38 | #undef max 39 | 40 | // Magus 41 | #include 42 | 43 | 44 | const DWORD NO_DEBUG_EVENT = 0; 45 | 46 | 47 | // This project 48 | #include "Types.h" 49 | #include "Utility.h" 50 | #include "Log.h" 51 | #include "Error.h" 52 | -------------------------------------------------------------------------------- /DebugEngine/Exec/DecodeX86.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/DebugEngine/Exec/DecodeX86.h -------------------------------------------------------------------------------- /DebugEngine/Exec/Enumerator.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | template 12 | class Enumerator 13 | { 14 | public: 15 | virtual ~Enumerator() { } 16 | 17 | virtual void Release() = 0; 18 | 19 | virtual int GetCount() = 0; 20 | virtual T GetCurrent() = 0; 21 | virtual bool MoveNext() = 0; 22 | virtual void Reset() = 0; 23 | }; 24 | -------------------------------------------------------------------------------- /DebugEngine/Exec/Error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | enum 12 | { 13 | EXEC_HR_FACILITY = 0x1611, 14 | }; 15 | 16 | const HRESULT E_ALREADY_INIT = HRESULT_FROM_WIN32( ERROR_ALREADY_INITIALIZED ); 17 | const HRESULT E_WRONG_THREAD = HRESULT_FROM_WIN32( ERROR_INVALID_THREAD_ID ); 18 | // the alternatives for E_WRONG_THREAD are RPC_E_ATTEMPTED_MULTITHREAD and RPC_E_WRONG_THREAD 19 | const HRESULT E_TIMEOUT = HRESULT_FROM_WIN32( ERROR_SEM_TIMEOUT ); 20 | const HRESULT E_NOT_FOUND = HRESULT_FROM_WIN32( ERROR_NOT_FOUND ); 21 | const HRESULT E_INSUFFICIENT_BUFFER = HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER ); 22 | const HRESULT E_WRONG_STATE = MAKE_HRESULT( SEVERITY_ERROR, EXEC_HR_FACILITY, 0 ); 23 | const HRESULT E_PROCESS_ENDED = MAKE_HRESULT( SEVERITY_ERROR, EXEC_HR_FACILITY, 1 ); 24 | -------------------------------------------------------------------------------- /DebugEngine/Exec/IModule.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class IModule 12 | { 13 | public: 14 | virtual ~IModule() { } 15 | 16 | virtual void AddRef() = 0; 17 | virtual void Release() = 0; 18 | 19 | virtual Address GetImageBase() = 0; 20 | virtual uint32_t GetDebugInfoFileOffset() = 0; 21 | virtual uint32_t GetDebugInfoSize() = 0; 22 | virtual uint32_t GetSize() = 0; 23 | virtual uint16_t GetMachine() = 0; 24 | virtual const wchar_t* GetPath() = 0; 25 | virtual const wchar_t* GetSymbolSearchPath() = 0; 26 | virtual Address GetPreferredImageBase() = 0; 27 | 28 | virtual bool IsDeleted() = 0; 29 | }; 30 | -------------------------------------------------------------------------------- /DebugEngine/Exec/IProcess.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | enum CreateMethod 12 | { 13 | Create_Launch, 14 | Create_Attach, 15 | }; 16 | 17 | class Thread; 18 | template 19 | class Enumerator; 20 | 21 | 22 | // Methods of the IProcess class are safe to call from any thread. 23 | // They are accurate when run from the debug thread, or when the process is stopped. 24 | 25 | // See the WinNT.h header file for processor-specific definitions of 26 | // machine type. For x86, the machine type is IMAGE_FILE_MACHINE_I386. 27 | 28 | class IProcess 29 | { 30 | public: 31 | virtual ~IProcess() { } 32 | 33 | virtual void AddRef() = 0; 34 | virtual void Release() = 0; 35 | 36 | virtual CreateMethod GetCreateMethod() = 0; 37 | virtual HANDLE GetHandle() = 0; 38 | virtual uint32_t GetId() = 0; 39 | virtual const wchar_t* GetExePath() = 0; 40 | virtual Address GetEntryPoint() = 0; 41 | virtual uint16_t GetMachineType() = 0; 42 | virtual Address GetImageBase() = 0; 43 | virtual uint32_t GetImageSize() = 0; 44 | 45 | virtual bool IsStopped() = 0; 46 | virtual bool IsDeleted() = 0; 47 | virtual bool IsTerminating() = 0; 48 | virtual bool ReachedLoaderBp() = 0; 49 | 50 | // threads 51 | 52 | virtual bool FindThread( uint32_t id, Thread*& thread ) = 0; 53 | virtual HRESULT EnumThreads( Enumerator< Thread* >*& en ) = 0; 54 | }; 55 | -------------------------------------------------------------------------------- /DebugEngine/Exec/Log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class Log 12 | { 13 | public: 14 | // call Enable(false) to disable logs 15 | static void Enable(bool enabled); 16 | static void LogDebugEvent( const DEBUG_EVENT& event ); 17 | static void LogMessage( const char* msg ); 18 | }; 19 | -------------------------------------------------------------------------------- /DebugEngine/Exec/MachineX64.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "MachineX86Base.h" 11 | 12 | 13 | class MachineX64 : public MachineX86Base 14 | { 15 | // A cached context for the thread that reported an event 16 | CONTEXT mContext; 17 | bool mIsContextCached; 18 | bool mEnableSS; 19 | 20 | public: 21 | MachineX64(); 22 | 23 | protected: 24 | virtual bool Is64Bit(); 25 | virtual HRESULT CacheThreadContext(); 26 | virtual HRESULT FlushThreadContext(); 27 | virtual HRESULT ChangeCurrentPC( int32_t byteOffset ); 28 | virtual HRESULT SetSingleStep( bool enable ); 29 | virtual HRESULT ClearSingleStep(); 30 | virtual HRESULT GetCurrentPC( Address& address ); 31 | virtual HRESULT GetReturnAddress( Address& address ); 32 | 33 | virtual HRESULT SuspendThread( Thread* thread ); 34 | virtual HRESULT ResumeThread( Thread* thread ); 35 | 36 | virtual HRESULT GetThreadContextInternal( 37 | uint32_t threadId, 38 | uint32_t features, 39 | uint64_t extFeatures, 40 | void* context, 41 | uint32_t size ); 42 | virtual HRESULT SetThreadContextInternal( uint32_t threadId, const void* context, uint32_t size ); 43 | 44 | virtual ThreadControlProc GetWinSuspendThreadProc(); 45 | 46 | private: 47 | HRESULT GetThreadContextWithCache( HANDLE hThread, void* context, uint32_t size ); 48 | HRESULT SetThreadContextWithCache( HANDLE hThread, const void* context, uint32_t size ); 49 | }; 50 | 51 | 52 | HRESULT MakeMachineX64( IMachine*& machine ); 53 | -------------------------------------------------------------------------------- /DebugEngine/Exec/MakeMachine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Common.h" 11 | #include "MakeMachine.h" 12 | 13 | #if defined( _M_IX86 ) 14 | #include "MachineX86.h" 15 | #elif defined( _M_X64 ) 16 | #include "MachineX86.h" 17 | #include "MachineX64.h" 18 | #endif 19 | 20 | 21 | HRESULT MakeMachine( WORD machineType, IMachine*& machine ) 22 | { 23 | HRESULT hr = E_NOTIMPL; 24 | 25 | #if defined( _M_IX86 ) 26 | if ( machineType == IMAGE_FILE_MACHINE_I386 ) 27 | { 28 | hr = MakeMachineX86( machine ); 29 | } 30 | #elif defined( _M_X64 ) 31 | if (machineType == IMAGE_FILE_MACHINE_I386) 32 | { 33 | hr = MakeMachineX86(machine); 34 | } 35 | else if (machineType == IMAGE_FILE_MACHINE_AMD64) 36 | { 37 | hr = MakeMachineX64(machine); 38 | } 39 | #elif defined( _M_ARM64 ) 40 | if (machineType == IMAGE_FILE_MACHINE_ARM64) 41 | { 42 | // todo: hr = MakeMachineARM64(machine); 43 | } 44 | #else 45 | #error Mago doesn't implement a core debugger for the current architecture. 46 | #endif 47 | 48 | return hr; 49 | } 50 | -------------------------------------------------------------------------------- /DebugEngine/Exec/MakeMachine.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class IMachine; 12 | 13 | 14 | HRESULT MakeMachine( WORD machineType, IMachine*& machine ); 15 | -------------------------------------------------------------------------------- /DebugEngine/Exec/PathResolver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | // TODO: speed up by caching 12 | class PathResolver 13 | { 14 | std::vector< wchar_t > mScratchPath; 15 | 16 | public: 17 | HRESULT Init(); 18 | 19 | HRESULT GetFilePath( HANDLE hProcess, HANDLE hFile, void* baseAddr, std::wstring& path ); 20 | HRESULT GetModulePath( HANDLE hProcess, HMODULE hMod, std::wstring& path ); 21 | HRESULT GetProcessModulePath( HANDLE hProcess, std::wstring& path ); 22 | 23 | private: 24 | HRESULT ResolveDeviceName( const std::wstring& devPath, HANDLE hFile, std::wstring& filePath ); 25 | HRESULT DriveResolveDeviceName( const std::wstring& devPath, HANDLE hFile, std::wstring& filePath ); 26 | 27 | HRESULT GetMappedDeviceName( HANDLE hProcess, void* baseAddr ); 28 | HRESULT QueryDosDeviceWithScratch( const wchar_t* driveName ); 29 | 30 | bool ExpandScratchPath(); 31 | }; 32 | -------------------------------------------------------------------------------- /DebugEngine/Exec/Thread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #include "Common.h" 9 | #include "Thread.h" 10 | 11 | 12 | Thread::Thread( HANDLE hThread, uint32_t id, Address startAddr, Address tebBase ) 13 | : mRefCount( 0 ), 14 | mhThread( hThread ), 15 | mId( id ), 16 | mStartAddr( startAddr ), 17 | mTebBase( tebBase ) 18 | { 19 | _ASSERT( hThread != NULL ); 20 | _ASSERT( id != 0 ); 21 | } 22 | 23 | Thread::~Thread() 24 | { 25 | if ( mhThread != NULL ) 26 | { 27 | CloseHandle( mhThread ); 28 | } 29 | } 30 | 31 | 32 | void Thread::AddRef() 33 | { 34 | InterlockedIncrement( &mRefCount ); 35 | } 36 | 37 | void Thread::Release() 38 | { 39 | LONG newRefCount = InterlockedDecrement( &mRefCount ); 40 | _ASSERT( newRefCount >= 0 ); 41 | if ( newRefCount == 0 ) 42 | { 43 | delete this; 44 | } 45 | } 46 | 47 | 48 | HANDLE Thread::GetHandle() 49 | { 50 | return mhThread; 51 | } 52 | 53 | uint32_t Thread::GetId() 54 | { 55 | return mId; 56 | } 57 | 58 | Address Thread::GetStartAddr() 59 | { 60 | return mStartAddr; 61 | } 62 | 63 | Address Thread::GetTebBase() 64 | { 65 | return mTebBase; 66 | } 67 | -------------------------------------------------------------------------------- /DebugEngine/Exec/Thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class Thread 12 | { 13 | LONG mRefCount; 14 | HANDLE mhThread; 15 | uint32_t mId; 16 | Address mStartAddr; 17 | Address mTebBase; 18 | 19 | public: 20 | Thread( HANDLE hThread, uint32_t id, Address startAddr, Address tebBase ); 21 | ~Thread(); 22 | 23 | void AddRef(); 24 | void Release(); 25 | 26 | HANDLE GetHandle(); 27 | uint32_t GetId(); 28 | Address GetStartAddr(); 29 | Address GetTebBase(); 30 | }; 31 | -------------------------------------------------------------------------------- /DebugEngine/Exec/Types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | typedef uintptr_t Address; 12 | 13 | struct AddressRange 14 | { 15 | Address Begin; 16 | Address End; 17 | }; 18 | 19 | enum RunMode 20 | { 21 | RunMode_Run, 22 | RunMode_Break, 23 | RunMode_Wait, 24 | }; 25 | 26 | enum ProbeRunMode 27 | { 28 | ProbeRunMode_Run, 29 | ProbeRunMode_Break, 30 | ProbeRunMode_Wait, 31 | ProbeRunMode_WalkThunk, 32 | }; 33 | -------------------------------------------------------------------------------- /DebugEngine/Exec/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /DebugEngine/Include/MagoDECommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #define AGENT_STARTUP_EVENT_PREFIX L"MagoRemoteStartup" 12 | #define AGENT_LOCAL_PROTOCOL_SEQUENCE L"ncalrpc" 13 | #define AGENT_CMD_IF_LOCAL_ENDPOINT_PREFIX L"MagoRemoteCmd" 14 | #define AGENT_EVENT_IF_LOCAL_ENDPOINT_PREFIX L"MagoRemoteEvent" 15 | 16 | enum 17 | { 18 | GUID_LENGTH = 38, 19 | 20 | // The event's name's format is MagoRemoteStartup 21 | // example: MagoRemoteStartup{00000000-0000-0000-0000-000000000000} 22 | AgentStartupEventNameLength = _countof( AGENT_STARTUP_EVENT_PREFIX ) - 1 + GUID_LENGTH, 23 | AgentStartupTimeoutMillis = 30 * 1000, 24 | }; 25 | 26 | #ifndef PF_XSAVE_ENABLED // not available before SDK 7.0 27 | #define PF_XSAVE_ENABLED 17 28 | #endif 29 | 30 | namespace Mago 31 | { 32 | enum ProcFeaturesX86 33 | { 34 | PF_X86_None = 0, 35 | PF_X86_MMX = 1, 36 | PF_X86_3DNow = 2, 37 | PF_X86_SSE = 4, 38 | PF_X86_SSE2 = 8, 39 | PF_X86_SSE3 = 0x10, 40 | PF_X86_AVX = 0x20, 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /DebugEngine/Include/MagoDEE.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | // Exec (test target) 12 | #include "..\Exec\Types.h" 13 | #include "..\Exec\Exec.h" 14 | #include "..\Exec\Error.h" 15 | #include "..\Exec\EventCallback.h" 16 | #include "..\Exec\IProcess.h" 17 | #include "..\Exec\IModule.h" 18 | #include "..\Exec\Thread.h" 19 | #include "..\Exec\Enumerator.h" 20 | -------------------------------------------------------------------------------- /DebugEngine/Include/MagoRemoteCmd.acf: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | [ 9 | strict_context_handle, 10 | explicit_handle 11 | ] 12 | interface MagoRemoteCmd 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /DebugEngine/Include/MagoRemoteCmd.idl.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // wrapper to add file into project that is generated into the intermediate folder 9 | 10 | #ifdef MAGOREMOTE 11 | #include "MagoRemoteCmd_s.c" 12 | #else 13 | #include "MagoRemoteCmd_c.c" 14 | #endif -------------------------------------------------------------------------------- /DebugEngine/Include/MagoRemoteCommon.idl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // MagoRemoteCommon.idl : IDL source for common definitions for MagoNatDE IPC 9 | // 10 | 11 | 12 | typedef unsigned __int64 MagoRemote_Address; 13 | 14 | typedef struct MagoRemote_AddressRange 15 | { 16 | MagoRemote_Address Begin; 17 | MagoRemote_Address End; 18 | } MagoRemote_AddressRange; 19 | -------------------------------------------------------------------------------- /DebugEngine/Include/MagoRemoteEvent.acf: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | [ 9 | strict_context_handle, 10 | explicit_handle 11 | ] 12 | interface MagoRemoteEvent 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /DebugEngine/Include/MagoRemoteEvent.idl.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // wrapper to add file into project that is generated into the intermediate folder 9 | 10 | #ifdef MAGOREMOTE 11 | #include "MagoRemoteEvent_c.c" 12 | #else 13 | #include "MagoRemoteEvent_s.c" 14 | #endif 15 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/ArchData.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #include "Common.h" 9 | #include "ArchData.h" 10 | #include "ArchDataX86.h" 11 | #include "ArchDataX64.h" 12 | 13 | 14 | namespace Mago 15 | { 16 | ArchData::ArchData() 17 | : mRefCount( 0 ) 18 | { 19 | } 20 | 21 | void ArchData::AddRef() 22 | { 23 | InterlockedIncrement( &mRefCount ); 24 | } 25 | 26 | void ArchData::Release() 27 | { 28 | int newRefCount = InterlockedDecrement( &mRefCount ); 29 | if ( newRefCount == 0 ) 30 | delete this; 31 | } 32 | 33 | HRESULT ArchData::MakeArchData( UINT32 procType, UINT64 procFeatures, ArchData*& archData ) 34 | { 35 | switch ( procType ) 36 | { 37 | case IMAGE_FILE_MACHINE_I386: 38 | archData = new ArchDataX86( procFeatures ); 39 | break; 40 | 41 | case IMAGE_FILE_MACHINE_AMD64: 42 | archData = new ArchDataX64( procFeatures ); 43 | break; 44 | 45 | default: 46 | return E_UNSUPPORTED_BINARY; 47 | } 48 | 49 | if ( archData == NULL ) 50 | return E_OUTOFMEMORY; 51 | 52 | archData->AddRef(); 53 | 54 | return S_OK; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/BPBinders.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "BPBinderCallback.h" 11 | 12 | 13 | namespace Mago 14 | { 15 | class BPCodeFileLineBinder : public BPBinder 16 | { 17 | CComBSTR mFilename; 18 | DWORD mReqLineStart; 19 | DWORD mReqLineEnd; 20 | 21 | public: 22 | BPCodeFileLineBinder( IDebugBreakpointRequest2* request ); 23 | 24 | virtual void Bind( Module* mod, ModuleBinding* binding, BPBoundBPMaker* maker, Error& err ); 25 | 26 | private: 27 | void PutDocError( Error& err ); 28 | void PutLineError( Error& err ); 29 | 30 | bool BindToFile( bool exactMatch, const char* fileName, size_t fileNameLen, Module* mod, ModuleBinding* binding, BPBoundBPMaker* maker, Error& err ); 31 | }; 32 | 33 | 34 | class BPCodeAddressBinder : public BPBinder 35 | { 36 | Address64 mAddress; 37 | 38 | public: 39 | BPCodeAddressBinder( IDebugBreakpointRequest2* request ); 40 | 41 | virtual void Bind( Module* mod, ModuleBinding* binding, BPBoundBPMaker* maker, Error& err ); 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/BPDocumentContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "DocumentContext.h" 11 | 12 | 13 | namespace Mago 14 | { 15 | class PendingBreakpoint; 16 | 17 | 18 | // Relies on a pending breakpoint for enumerating code contexts. 19 | 20 | class BPDocumentContext : 21 | public DocumentContext, 22 | public CComObjectRootEx 23 | { 24 | RefPtr mBPParent; 25 | 26 | public: 27 | 28 | DECLARE_NOT_AGGREGATABLE(BPDocumentContext) 29 | 30 | BEGIN_COM_MAP(BPDocumentContext) 31 | COM_INTERFACE_ENTRY(IDebugDocumentContext2) 32 | END_COM_MAP() 33 | 34 | //////////////////////////////////////////////////////////// 35 | // IDebugDocumentContext2 36 | 37 | STDMETHOD( EnumCodeContexts )( IEnumDebugCodeContexts2** ppEnumCodeCxts ); 38 | 39 | public: 40 | HRESULT Init( 41 | PendingBreakpoint* pendingBP, 42 | const wchar_t* filename, 43 | TEXT_POSITION& statementBegin, 44 | TEXT_POSITION& statementEnd, 45 | const wchar_t* langName, 46 | const GUID& langGuid ); 47 | 48 | virtual HRESULT Clone( DocumentContext** ppDocContext ); 49 | 50 | void Dispose(); 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/BreakpointResolution.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "BpResolutionLocation.h" 11 | 12 | 13 | namespace Mago 14 | { 15 | class BreakpointResolution : 16 | public CComObjectRootEx, 17 | public IDebugBreakpointResolution2 18 | { 19 | BpResolutionLocation mResLoc; 20 | CComPtr mAD7Prog; 21 | CComPtr mAD7Thread; 22 | 23 | public: 24 | BreakpointResolution(); 25 | ~BreakpointResolution(); 26 | 27 | DECLARE_NOT_AGGREGATABLE(BreakpointResolution) 28 | 29 | BEGIN_COM_MAP(BreakpointResolution) 30 | COM_INTERFACE_ENTRY(IDebugBreakpointResolution2) 31 | END_COM_MAP() 32 | 33 | //////////////////////////////////////////////////////////// 34 | // IDebugBreakpointResolution2 35 | 36 | STDMETHOD( GetBreakpointType )( BP_TYPE* pBPType ); 37 | STDMETHOD( GetResolutionInfo )( 38 | BPRESI_FIELDS dwFields, 39 | BP_RESOLUTION_INFO* pBPResolutionInfo ); 40 | 41 | public: 42 | // TODO: move with r-value refs 43 | HRESULT Init( 44 | BpResolutionLocation& bpresLoc, 45 | IDebugProgram2* pProgram, 46 | IDebugThread2* pThread ); 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/Common.cpp: -------------------------------------------------------------------------------- 1 | // Common.cpp : source file that includes just the standard includes 2 | // MagoNatDE.pch will be the pre-compiled header 3 | // Common.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/DiaLoadCallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace Mago 12 | { 13 | class DiaLoadCallback : 14 | public MagoST::ILoadCallback 15 | { 16 | public: 17 | struct SearchStatus 18 | { 19 | std::wstring Path; 20 | HRESULT ResultCode; 21 | }; 22 | 23 | typedef std::list< SearchStatus > SearchList; 24 | 25 | private: 26 | long mRefCount; 27 | SearchList mSearchList; 28 | 29 | public: 30 | DiaLoadCallback(); 31 | ~DiaLoadCallback(); 32 | 33 | //////////////////////////////////////////////////////////// 34 | // ILoadCallback 35 | 36 | virtual void AddRef(); 37 | virtual void Release(); 38 | 39 | virtual HRESULT NotifyDebugDir( 40 | /* [in] */ bool fExecutable, 41 | /* [in] */ DWORD cbData, 42 | /* [size_is][in] */ BYTE* pbData ); 43 | 44 | virtual HRESULT NotifyOpenDBG( 45 | /* [in] */ LPCOLESTR dbgPath, 46 | /* [in] */ HRESULT resultCode ); 47 | 48 | STDMETHOD( RestrictRegistryAccess )(); 49 | 50 | STDMETHOD( RestrictSymbolServerAccess )(); 51 | 52 | public: 53 | const SearchList& GetSearchList(); 54 | HRESULT GetSearchText( BSTR* text ); 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/Engine.rgs: -------------------------------------------------------------------------------- 1 | HKCR 2 | { 3 | NoRemove CLSID 4 | { 5 | ForceRemove {97348AC0-2B6B-4B99-A245-4C7E2C09D403} = s 'MagoNativeEngine Class' 6 | { 7 | InprocServer32 = s '%MODULE%' 8 | { 9 | val ThreadingModel = s 'Free' 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/EnumFrameInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "ComEnumWithCount.h" 11 | 12 | 13 | namespace Mago 14 | { 15 | class FrameInfoArray 16 | { 17 | FRAMEINFO* mArray; 18 | size_t mLen; 19 | 20 | public: 21 | FrameInfoArray( size_t length ); 22 | ~FrameInfoArray(); 23 | 24 | size_t GetLength() const; 25 | FRAMEINFO& operator[]( size_t i ) const; 26 | FRAMEINFO* Get() const; 27 | FRAMEINFO* Detach(); 28 | 29 | private: 30 | FrameInfoArray( const FrameInfoArray& ); 31 | FrameInfoArray& operator=( const FrameInfoArray& ); 32 | }; 33 | 34 | class _CopyFrameInfo 35 | { 36 | public: 37 | static HRESULT copy( FRAMEINFO* dest, const FRAMEINFO* source ); 38 | static void init( FRAMEINFO* p ); 39 | static void destroy( FRAMEINFO* p ); 40 | }; 41 | 42 | typedef CComEnumWithCount< 43 | IEnumDebugFrameInfo2, 44 | &IID_IEnumDebugFrameInfo2, 45 | FRAMEINFO, 46 | _CopyFrameInfo, 47 | CComMultiThreadModel 48 | > EnumDebugFrameInfo; 49 | 50 | typedef ScopedStruct FrameInfo; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/EnumX86Reg.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace Mago 12 | { 13 | struct RegGroupInternal; 14 | 15 | 16 | void GetX86RegisterGroups( const RegGroupInternal*& groups, uint32_t& count ); 17 | } 18 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/ErrorBreakpoint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #include "Common.h" 9 | #include "ErrorBreakpoint.h" 10 | 11 | 12 | namespace Mago 13 | { 14 | // ErrorBreakpoint 15 | 16 | ErrorBreakpoint::ErrorBreakpoint() 17 | { 18 | } 19 | 20 | ErrorBreakpoint::~ErrorBreakpoint() 21 | { 22 | } 23 | 24 | 25 | ////////////////////////////////////////////////////////////////////////////// 26 | // IDebugErrorBreakpoint2 27 | 28 | HRESULT ErrorBreakpoint::GetPendingBreakpoint( IDebugPendingBreakpoint2** ppPendingBreakpoint ) 29 | { 30 | if ( ppPendingBreakpoint == NULL ) 31 | return E_INVALIDARG; 32 | 33 | *ppPendingBreakpoint = mPendingBP; 34 | (*ppPendingBreakpoint)->AddRef(); 35 | return S_OK; 36 | } 37 | 38 | HRESULT ErrorBreakpoint::GetBreakpointResolution( IDebugErrorBreakpointResolution2** ppErrorResolution ) 39 | { 40 | if ( ppErrorResolution == NULL ) 41 | return E_INVALIDARG; 42 | 43 | *ppErrorResolution = mBPRes; 44 | (*ppErrorResolution)->AddRef(); 45 | return S_OK; 46 | } 47 | 48 | 49 | //---------------------------------------------------------------------------- 50 | 51 | void ErrorBreakpoint::Init( 52 | IDebugPendingBreakpoint2* ppPendingBreakpoint, 53 | IDebugErrorBreakpointResolution2* ppErrorResolution ) 54 | { 55 | _ASSERT( ppPendingBreakpoint != NULL ); 56 | _ASSERT( ppErrorResolution != NULL ); 57 | 58 | mPendingBP = ppPendingBreakpoint; 59 | mBPRes = ppErrorResolution; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/ErrorBreakpoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace Mago 12 | { 13 | class ErrorBreakpoint : 14 | public CComObjectRootEx, 15 | public IDebugErrorBreakpoint2 16 | { 17 | CComPtr mPendingBP; 18 | CComPtr mBPRes; 19 | 20 | public: 21 | ErrorBreakpoint(); 22 | ~ErrorBreakpoint(); 23 | 24 | DECLARE_NOT_AGGREGATABLE(ErrorBreakpoint) 25 | 26 | BEGIN_COM_MAP(ErrorBreakpoint) 27 | COM_INTERFACE_ENTRY(IDebugErrorBreakpoint2) 28 | END_COM_MAP() 29 | 30 | //////////////////////////////////////////////////////////// 31 | // IDebugErrorBreakpoint2 32 | 33 | STDMETHOD( GetPendingBreakpoint )( IDebugPendingBreakpoint2** ppPendingBreakpoint ); 34 | STDMETHOD( GetBreakpointResolution )( IDebugErrorBreakpointResolution2** ppErrorResolution ); 35 | 36 | public: 37 | void Init( 38 | IDebugPendingBreakpoint2* ppPendingBreakpoint, 39 | IDebugErrorBreakpointResolution2* ppErrorResolution ); 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/ErrorBreakpointResolution.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "BpResolutionLocation.h" 11 | 12 | 13 | namespace Mago 14 | { 15 | class ErrorBreakpointResolution : 16 | public CComObjectRootEx, 17 | public IDebugErrorBreakpointResolution2 18 | { 19 | BP_ERROR_TYPE mErrType; 20 | BpResolutionLocation mResLoc; 21 | CComBSTR mMsg; 22 | CComPtr mAD7Prog; 23 | CComPtr mAD7Thread; 24 | 25 | public: 26 | ErrorBreakpointResolution(); 27 | ~ErrorBreakpointResolution(); 28 | 29 | DECLARE_NOT_AGGREGATABLE(ErrorBreakpointResolution) 30 | 31 | BEGIN_COM_MAP(ErrorBreakpointResolution) 32 | COM_INTERFACE_ENTRY(IDebugErrorBreakpointResolution2) 33 | END_COM_MAP() 34 | 35 | //////////////////////////////////////////////////////////// 36 | // IDebugErrorBreakpointResolution2 37 | 38 | STDMETHOD( GetBreakpointType )( BP_TYPE* pBPType ); 39 | STDMETHOD( GetResolutionInfo )( 40 | BPERESI_FIELDS dwFields, 41 | BP_ERROR_RESOLUTION_INFO* pErrorResolutionInfo ); 42 | 43 | public: 44 | HRESULT Init( 45 | BpResolutionLocation& bpresLoc, 46 | IDebugProgram2* pProgram, 47 | IDebugThread2* pThread, 48 | const wchar_t* msg, 49 | BP_ERROR_TYPE errType ); 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/Expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | class IEEDParsedExpr; 14 | } 15 | 16 | 17 | namespace Mago 18 | { 19 | class ExprContext; 20 | 21 | 22 | class Expr : 23 | public CComObjectRootEx, 24 | public IDebugExpression2 25 | { 26 | CComBSTR mExprText; 27 | RefPtr mContext; 28 | RefPtr mParsedExpr; 29 | 30 | public: 31 | Expr(); 32 | ~Expr(); 33 | 34 | DECLARE_NOT_AGGREGATABLE(Expr) 35 | 36 | BEGIN_COM_MAP(Expr) 37 | COM_INTERFACE_ENTRY(IDebugExpression2) 38 | END_COM_MAP() 39 | 40 | //////////////////////////////////////////////////////////// 41 | // IDebugExpression2 42 | 43 | STDMETHOD( EvaluateAsync )( 44 | EVALFLAGS dwFlags, 45 | IDebugEventCallback2* pExprCallback ); 46 | 47 | STDMETHOD( Abort )(); 48 | 49 | STDMETHOD( EvaluateSync )( 50 | EVALFLAGS dwFlags, 51 | DWORD dwTimeout, 52 | IDebugEventCallback2* pExprCallback, 53 | IDebugProperty2** ppResult ); 54 | 55 | public: 56 | HRESULT Init( MagoEE::IEEDParsedExpr* parsedExpr, const wchar_t* exprText, ExprContext* exprContext ); 57 | 58 | private: 59 | HRESULT MakeErrorPropertyOrReturnOriginalError( HRESULT hrErr, IDebugProperty2** ppResult ); 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/FormatNum.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | 13 | void FormatFloat80( void* f80, wchar_t* str, size_t strLen ); 14 | void FormatFloat64( double f64, wchar_t* str, size_t strLen ); 15 | void FormatFloat32( float f32, wchar_t* str, size_t strLen ); 16 | 17 | 18 | enum 19 | { 20 | // +X.YYY...YYYe+ZZZZ 21 | // Significand sign: 1 22 | // Significand digits: Real10::Digits 23 | // Decimal point: 1 24 | // Exponent 'e' 1 25 | // Exponent sign: 1 26 | // Exponent digits: 4 27 | Float80DecStrLen = Real10::Digits + 8, 28 | 29 | // Like Float80, but 30 | // Exponent digits: 3 31 | Float64DecStrLen = std::numeric_limits::digits10 + 7, 32 | 33 | // Like Float80, but 34 | // Exponent digits: 3 35 | Float32DecStrLen = std::numeric_limits::digits10 + 7, 36 | }; 37 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/MagoNatDE.def: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2010 Aldo J. Nunez 3 | ; 4 | ; Licensed under the Apache License, Version 2.0. 5 | ; See the LICENSE text file for details. 6 | ; 7 | ; MagoNatDE.def : Declares the module parameters. 8 | 9 | LIBRARY "MagoNatDE.DLL" 10 | 11 | EXPORTS 12 | DllCanUnloadNow PRIVATE 13 | DllGetClassObject PRIVATE 14 | DllRegisterServer PRIVATE 15 | DllUnregisterServer PRIVATE 16 | DllInstall PRIVATE 17 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/MagoNatDE.idl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // MagoNatDE.idl : IDL source for MagoNatDE 9 | // 10 | 11 | // This file will be processed by the MIDL tool to 12 | // produce the type library (MagoNatDE.tlb) and marshalling code. 13 | 14 | import "oaidl.idl"; 15 | import "ocidl.idl"; 16 | import "msdbg.idl"; 17 | 18 | 19 | [ 20 | uuid(E348A53A-470A-4A70-9B55-1E02F352790D), 21 | version(1.0), 22 | helpstring("MagoNatDE 1.0 Type Library") 23 | ] 24 | library MagoNatDELib 25 | { 26 | importlib("stdole2.tlb"); 27 | [ 28 | uuid(97348AC0-2B6B-4B99-A245-4C7E2C09D403), 29 | helpstring("MagoNativeEngine Class") 30 | ] 31 | coclass MagoNativeEngine 32 | { 33 | [default] interface IDebugEngine3; 34 | }; 35 | }; 36 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/MagoNatDE.idl.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // wrapper to add file into project that is generated into the intermediate folder 9 | 10 | #include "MagoNatDE_i.c" 11 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/MagoNatDE.rgs: -------------------------------------------------------------------------------- 1 | HKCR 2 | { 3 | NoRemove AppID 4 | { 5 | '%APPID%' = s 'MagoNatDE' 6 | 'MagoNatDE.DLL' 7 | { 8 | val AppID = s '%APPID%' 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/MagoNatDEps.def: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (c) 2010 Aldo J. Nunez 3 | ; 4 | ; Licensed under the Apache License, Version 2.0. 5 | ; See the LICENSE text file for details. 6 | ; 7 | 8 | LIBRARY "MagoNatDEPS" 9 | 10 | EXPORTS 11 | DllGetClassObject PRIVATE 12 | DllCanUnloadNow PRIVATE 13 | DllRegisterServer PRIVATE 14 | DllUnregisterServer PRIVATE 15 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/MemoryBytes.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace Mago 12 | { 13 | class IDebuggerProxy; 14 | class ICoreProcess; 15 | 16 | 17 | class MemoryBytes : 18 | public CComObjectRootEx, 19 | public IDebugMemoryBytes2 20 | { 21 | Address64 mAddr; 22 | uint64_t mSize; 23 | IDebuggerProxy* mDebugger; 24 | RefPtr mProc; 25 | 26 | public: 27 | MemoryBytes(); 28 | ~MemoryBytes(); 29 | 30 | DECLARE_NOT_AGGREGATABLE(MemoryBytes) 31 | 32 | BEGIN_COM_MAP(MemoryBytes) 33 | COM_INTERFACE_ENTRY(IDebugMemoryBytes2) 34 | END_COM_MAP() 35 | 36 | //////////////////////////////////////////////////////////// 37 | // IDebugMemoryBytes2 38 | 39 | STDMETHOD( ReadAt )( 40 | IDebugMemoryContext2* pStartContext, 41 | DWORD dwCount, 42 | BYTE* rgbMemory, 43 | DWORD* pdwRead, 44 | DWORD* pdwUnreadable ); 45 | STDMETHOD( WriteAt )( 46 | IDebugMemoryContext2* pStartContext, 47 | DWORD dwCount, 48 | BYTE* rgbMemory ); 49 | STDMETHOD( GetSize )( 50 | UINT64* pqwSize ); 51 | 52 | public: 53 | void Init( Address64 addr, uint64_t size, IDebuggerProxy* debugger, ICoreProcess* proc ); 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/ProgramNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace Mago 12 | { 13 | class ProgramNode : 14 | public CComObjectRootEx, 15 | public IDebugProgramNode2 16 | { 17 | DWORD mPid; 18 | 19 | public: 20 | ProgramNode(); 21 | ~ProgramNode(); 22 | 23 | void SetProcessId( DWORD pid ); 24 | 25 | DECLARE_NOT_AGGREGATABLE(ProgramNode) 26 | 27 | BEGIN_COM_MAP(ProgramNode) 28 | COM_INTERFACE_ENTRY(IDebugProgramNode2) 29 | END_COM_MAP() 30 | 31 | //////////////////////////////////////////////////////////// 32 | // IDebugProgramNode2 33 | 34 | STDMETHOD( GetProgramName )( BSTR* pbstrProgramName ); 35 | STDMETHOD( GetHostName )( DWORD dwHostNameType, BSTR* pbstrHostName ); 36 | STDMETHOD( GetHostPid )( AD_PROCESS_ID* pHostProcessId ); 37 | STDMETHOD( GetHostMachineName_V7 )( BSTR* pbstrHostMachineName ); 38 | STDMETHOD( Attach_V7 )( 39 | IDebugProgram2* pMDMProgram, 40 | IDebugEventCallback2* pCallback, 41 | DWORD dwReason ); 42 | STDMETHOD( GetEngineInfo )( BSTR* pbstrEngine, GUID* pguidEngine ); 43 | STDMETHOD( DetachDebugger_V7 )(); 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/RemoteEventRpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace Mago 12 | { 13 | class IRemoteEventCallback; 14 | 15 | 16 | void SetRemoteEventCallback( IRemoteEventCallback* callback ); 17 | } 18 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/RpcUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | int RPC_ENTRY CommonRpcExceptionFilter( unsigned long exceptionCode ); 12 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/SingleDocumentContext.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #include "Common.h" 9 | #include "SingleDocumentContext.h" 10 | 11 | 12 | namespace Mago 13 | { 14 | HRESULT SingleDocumentContext::EnumCodeContexts( 15 | IEnumDebugCodeContexts2** ppEnumCodeCxts 16 | ) 17 | { 18 | _ASSERT( false ); 19 | UNREFERENCED_PARAMETER( ppEnumCodeCxts ); 20 | return E_FAIL; 21 | } 22 | 23 | HRESULT SingleDocumentContext::Init( 24 | const wchar_t* filename, 25 | TEXT_POSITION& statementBegin, 26 | TEXT_POSITION& statementEnd, 27 | const wchar_t* langName, 28 | const GUID& langGuid ) 29 | { 30 | return DocumentContext::Init( filename, statementBegin, statementEnd, langName, langGuid ); 31 | } 32 | 33 | HRESULT SingleDocumentContext::Clone( DocumentContext** ppDocContext ) 34 | { 35 | HRESULT hr = S_OK; 36 | RefPtr docContext; 37 | 38 | hr = MakeCComObject( docContext ); 39 | if ( FAILED( hr ) ) 40 | return hr; 41 | 42 | hr = docContext->Init( mFilename, mStatementBegin, mStatementEnd, mLangName, mLangGuid ); 43 | if ( FAILED( hr ) ) 44 | return hr; 45 | 46 | *ppDocContext = docContext.Detach(); 47 | return S_OK; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/SingleDocumentContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "DocumentContext.h" 11 | 12 | 13 | namespace Mago 14 | { 15 | class SingleDocumentContext : 16 | public DocumentContext, 17 | public CComObjectRootEx 18 | { 19 | public: 20 | 21 | DECLARE_NOT_AGGREGATABLE(SingleDocumentContext) 22 | 23 | BEGIN_COM_MAP(SingleDocumentContext) 24 | COM_INTERFACE_ENTRY(IDebugDocumentContext2) 25 | END_COM_MAP() 26 | 27 | //////////////////////////////////////////////////////////// 28 | // IDebugDocumentContext2 29 | 30 | STDMETHOD( EnumCodeContexts )( IEnumDebugCodeContexts2** ppEnumCodeCxts ); 31 | 32 | public: 33 | HRESULT Init( 34 | const wchar_t* filename, 35 | TEXT_POSITION& statementBegin, 36 | TEXT_POSITION& statementEnd, 37 | const wchar_t* langName, 38 | const GUID& langGuid ); 39 | 40 | virtual HRESULT Clone( DocumentContext** ppDocContext ); 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/WinStackWalker.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "ArchData.h" 11 | #include 12 | 13 | 14 | namespace Mago 15 | { 16 | class WindowsStackWalker : public StackWalker 17 | { 18 | uint32_t mMachineType; 19 | STACKFRAME64 mGenericFrame; 20 | void* mProcessContext; 21 | ReadProcessMemory64Proc mReadMemProc; 22 | FunctionTableAccess64Proc mFuncTabProc; 23 | GetModuleBase64Proc mGetModBaseProc; 24 | UniquePtr mThreadContext; 25 | uint32_t mThreadContextSize; 26 | 27 | public: 28 | // Works like the DbgHelp StackWalk64 routine. 29 | WindowsStackWalker( 30 | uint32_t machineType, 31 | uint64_t pc, 32 | uint64_t stack, 33 | uint64_t frame, 34 | void* processContext, 35 | ReadProcessMemory64Proc readMemProc, 36 | FunctionTableAccess64Proc funcTabProc, 37 | GetModuleBase64Proc getModBaseProc ); 38 | HRESULT Init( const void* threadContext, uint32_t threadContextSize ); 39 | 40 | virtual bool WalkStack(); 41 | 42 | virtual void GetThreadContext( const void*& context, uint32_t& contextSize ); 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/dllmain.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | 7 | Purpose: global module object used for ATL and COM features 8 | */ 9 | 10 | class CMagoNatDEModule : public CAtlDllModuleT< CMagoNatDEModule > 11 | { 12 | typedef CAtlDllModuleT< CMagoNatDEModule > base; 13 | 14 | public : 15 | DECLARE_LIBID(LIBID_MagoNatDELib) 16 | DECLARE_REGISTRY_APPID_RESOURCEID(IDR_MAGONATDE, "{B84E2188-D769-444A-AF27-95165CE204B0}") 17 | 18 | HRESULT RegisterServer( BOOL bRegTypeLib = FALSE, const CLSID* pCLSID = NULL ) throw(); 19 | HRESULT UnregisterServer( BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL ) throw(); 20 | }; 21 | 22 | extern class CMagoNatDEModule _AtlModule; 23 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MagoNatDE.rc 4 | // 5 | #define IDS_PROJNAME 100 6 | #define IDR_MAGONATDE 101 7 | #define IDR_ENGINE 102 8 | 9 | // Next default values for new objects 10 | // 11 | #ifdef APSTUDIO_INVOKED 12 | #ifndef APSTUDIO_READONLY_SYMBOLS 13 | #define _APS_NEXT_RESOURCE_VALUE 201 14 | #define _APS_NEXT_COMMAND_VALUE 32768 15 | #define _APS_NEXT_CONTROL_VALUE 201 16 | #define _APS_NEXT_SYMED_VALUE 103 17 | #endif 18 | #endif 19 | -------------------------------------------------------------------------------- /DebugEngine/MagoNatDE/targetver.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/App.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace Mago 12 | { 13 | // Notify the application that a debugging session was opened or closed. 14 | void NotifyAddSession(); 15 | void NotifyRemoveSession(); 16 | 17 | // Returns true only if opening a new debugging session is allowed. 18 | bool NewSession(); 19 | 20 | int RunSingleSessionLoop( const wchar_t* sessionUuidStr ); 21 | } 22 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/Common.cpp: -------------------------------------------------------------------------------- 1 | // Common.cpp : source file that includes just the standard includes 2 | // MagoRemote.pch will be the pre-compiled header 3 | // Common.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // Common.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #include "targetver.h" 16 | 17 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 18 | // Windows Header Files: 19 | #include 20 | 21 | // C RunTime Header Files 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 28 | 29 | // ATL 30 | #include 31 | #include 32 | 33 | // C 34 | #include 35 | #include 36 | 37 | // C++ 38 | #include 39 | 40 | // Magus 41 | #include 42 | #include 43 | 44 | // Debug Exec 45 | #include "..\Exec\Types.h" 46 | #include "..\Exec\Enumerator.h" 47 | #include "..\Exec\Error.h" 48 | #include "..\Exec\Exec.h" 49 | #include "..\Exec\EventCallback.h" 50 | #include "..\Exec\IProcess.h" 51 | #include "..\Exec\Thread.h" 52 | #include "..\Exec\IModule.h" 53 | 54 | // Windows declarations that I don't want 55 | #undef max 56 | #undef min 57 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/MagoRemote.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "resource.h" 11 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/MagoRemote.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/DebugEngine/MagoRemote/MagoRemote.ico -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/MagoRemote.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/DebugEngine/MagoRemote/MagoRemote.rc -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/MagoRemoteSmall.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/DebugEngine/MagoRemote/MagoRemoteSmall.ico -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/RemoteCmdRpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | HRESULT InitRpcServerLocal( const wchar_t* sessionUuidStr ); 12 | void UninitRpcServer(); 13 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/RpcUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | int RPC_ENTRY CommonRpcExceptionFilter( unsigned long exceptionCode ); 12 | wchar_t* MidlAllocString( const wchar_t* str ); 13 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MagoRemote.rc 4 | // 5 | #define IDS_APP_TITLE 100 6 | #define IDI_MAGOREMOTE 101 7 | #define IDI_MAGOREMOTESMALL 102 8 | 9 | // Next default values for new objects 10 | // 11 | #ifdef APSTUDIO_INVOKED 12 | #ifndef APSTUDIO_READONLY_SYMBOLS 13 | #define _APS_NO_MFC 1 14 | #define _APS_NEXT_RESOURCE_VALUE 129 15 | #define _APS_NEXT_COMMAND_VALUE 32768 16 | #define _APS_NEXT_CONTROL_VALUE 1000 17 | #define _APS_NEXT_SYMED_VALUE 103 18 | #endif 19 | #endif 20 | -------------------------------------------------------------------------------- /DebugEngine/MagoRemote/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utest1/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // test1.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utest1/stdafx.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #define _CRTDBG_MAP_ALLOC 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utest1/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utest1/utest1.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utestExec/EventSuite.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/DebugEngine/UnitTests/utestExec/EventSuite.cpp -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utestExec/EventSuite.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | class Exec; 11 | class EventCallbackBase; 12 | 13 | 14 | class EventSuite : public Test::Suite 15 | { 16 | Exec* mExec; 17 | EventCallbackBase* mCallback; 18 | 19 | public: 20 | EventSuite(); 21 | 22 | void setup(); 23 | void tear_down(); 24 | 25 | private: 26 | void TestModuleLoad(); 27 | void TestOutputString(); 28 | void TestExceptionHandledFirstChance(); 29 | void TestExceptionNotHandledFirstChanceNotCaught(); 30 | void TestExceptionNotHandledFirstChanceCaught(); 31 | void TestExceptionNotHandledAllChances(); 32 | 33 | void TryHandlingException( bool firstTimeHandled, bool expectedChanceSecondTime ); 34 | void RunDebuggee( RefPtr& process ); 35 | void AssertModuleLoads( IProcess* process ); 36 | void AssertOutputStrings(); 37 | }; 38 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utestExec/StartStopSuite.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | class EventCallbackBase; 11 | 12 | 13 | class StartStopSuite : public Test::Suite 14 | { 15 | Exec* mExec; 16 | EventCallbackBase* mCallback; 17 | 18 | public: 19 | StartStopSuite(); 20 | 21 | void setup(); 22 | void tear_down(); 23 | 24 | private: 25 | void TestInit(); 26 | void TestLaunchDestroyExecStopped(); 27 | void TestLaunchDestroyExecRunning(); 28 | void TestBeginToEnd(); 29 | void TestTerminateStopped(); 30 | void TestTerminateRunning(); 31 | void TestOptionsSameConsole(); 32 | void TestOptionsNewConsole(); 33 | void TestDetachRunning(); 34 | void TestDetachStopped(); 35 | void TestAttach(); 36 | void TestAsyncBreak(); 37 | void TestMultiProcess(); 38 | 39 | void TestDetachCore( bool detachWhileRunning ); 40 | 41 | void TryOptions( bool newConsole ); 42 | void BuildEnv( wchar_t* env, int envSize, 43 | char* expectedEnv, int expectedEnvSize, 44 | char* requestedEnv, int requestedEnvSize ); 45 | void MakeStdPipes( HandlePtr& inFileRead, HandlePtr& inFileWrite, 46 | HandlePtr& outFileRead, HandlePtr& outFileWrite, 47 | HandlePtr& errFileRead, HandlePtr& errFileWrite, bool& ok ); 48 | 49 | void AssertProcessFinished( uint32_t pid ); 50 | void AssertProcessFinished( uint32_t pid, uint32_t expectedExitCode ); 51 | void AssertConsoleWindow( bool newConsole, DWORD procId ); 52 | }; 53 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utestExec/StepOneThreadSuite.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | struct Step; 11 | class EventCallbackBase; 12 | 13 | 14 | class StepOneThreadSuite : public Test::Suite 15 | { 16 | Exec* mExec; 17 | EventCallbackBase* mCallback; 18 | 19 | public: 20 | StepOneThreadSuite(); 21 | 22 | void setup(); 23 | void tear_down(); 24 | 25 | private: 26 | void StepInstructionInAssembly(); 27 | void StepInstructionOver(); 28 | void StepInstructionInSourceHaveSource(); 29 | void StepInstructionInSourceNoSource(); 30 | void StepInstructionOverInterruptedByBP(); 31 | 32 | void RunDebuggee( Step* steps, int stepsCount ); 33 | }; 34 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utestExec/Utility.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | BOOL CreateAnonymousPipe( 12 | HANDLE* readHandle, 13 | HANDLE* writeHandle, 14 | LPSECURITY_ATTRIBUTES secAttrRead, 15 | LPSECURITY_ATTRIBUTES secAttrWrite, 16 | DWORD bufSize, 17 | const wchar_t* pipeName, 18 | bool overlappedRead, 19 | bool overlappedWrite ); 20 | 21 | 22 | struct FrameX86 23 | { 24 | DWORD Eip; 25 | DWORD Ebp; 26 | }; 27 | 28 | struct FrameX64 29 | { 30 | DWORD64 Rip; 31 | DWORD64 Rbp; 32 | }; 33 | 34 | void ReadCallstackX86( HANDLE hProcess, HANDLE hThread, std::list& stack ); 35 | void ReadCallstackX64( HANDLE hProcess, HANDLE hThread, std::list& stack ); 36 | 37 | 38 | #ifdef _WIN64 39 | 40 | typedef WOW64_CONTEXT CONTEXT_X86; 41 | #define CONTEXT_X86_FULL WOW64_CONTEXT_FULL 42 | #define GetThreadContextX86 Wow64GetThreadContext 43 | #define SetThreadContextX86 Wow64SetThreadContext 44 | #define EXCEPTION_BREAKPOINT_X86 0x4000001F 45 | #define EXCEPTION_SINGLE_STEP_X86 0x4000001E 46 | 47 | #else 48 | 49 | typedef CONTEXT CONTEXT_X86; 50 | #define CONTEXT_X86_FULL CONTEXT_FULL 51 | #define GetThreadContextX86 GetThreadContext 52 | #define SetThreadContextX86 SetThreadContext 53 | #define EXCEPTION_BREAKPOINT_X86 EXCEPTION_BREAKPOINT 54 | #define EXCEPTION_SINGLE_STEP_X86 EXCEPTION_SINGLE_STEP 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utestExec/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // testExec.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /DebugEngine/UnitTests/utestExec/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /EED/EED/Common.cpp: -------------------------------------------------------------------------------- 1 | // Common.cpp : source file that includes just the standard includes 2 | // EED.pch will be the pre-compiled header 3 | // Common.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /EED/EED/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #include "targetver.h" 16 | 17 | // C 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | // C++ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | // Windows 35 | #include 36 | 37 | // Magus 38 | #include 39 | 40 | // This project 41 | #include "../Real/Real.h" 42 | #include "../Real/Complex.h" 43 | 44 | 45 | #undef min 46 | #undef max 47 | 48 | 49 | #include "EE.h" 50 | -------------------------------------------------------------------------------- /EED/EED/FormatValue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include 11 | 12 | namespace MagoEE 13 | { 14 | HRESULT FormatBasicValue( const DataObject& objVal, const FormatOptions& fmtopt, std::wstring& outStr ); 15 | HRESULT FormatValue( IValueBinder* binder, const DataObject& objVal, FormatData& fmtdata, 16 | std::function complete ); 17 | 18 | HRESULT GetRawStringLength( IValueBinder* binder, const DataObject& objVal, uint32_t& length ); 19 | HRESULT FormatRawString( 20 | IValueBinder* binder, 21 | const DataObject& objVal, 22 | uint32_t bufCharLen, 23 | uint32_t& bufCharLenWritten, 24 | wchar_t* buf ); 25 | 26 | HRESULT FormatTextViewerString( IValueBinder* binder, const DataObject& objVal, std::wstring& text ); 27 | 28 | HRESULT FormatRawStructValue( IValueBinder* binder, const void* srcBuf, Type* type, FormatData& fmtdata ); 29 | } 30 | -------------------------------------------------------------------------------- /EED/EED/FromRawValue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | struct Real10; 11 | 12 | namespace MagoEE 13 | { 14 | class Type; 15 | union DataValue; 16 | 17 | HRESULT WriteInt( uint8_t* buffer, uint32_t bufSize, Type* type, uint64_t val ); 18 | HRESULT WriteFloat( uint8_t* buffer, uint32_t bufSize, Type* type, const Real10& val ); 19 | 20 | uint64_t ReadInt( const void* srcBuf, uint32_t bufOffset, size_t size, bool isSigned ); 21 | Real10 ReadFloat( const void* srcBuf, uint32_t bufOffset, Type* type ); 22 | HRESULT FromRawValue( const void* srcBuf, Type* type, DataValue& value ); 23 | } 24 | -------------------------------------------------------------------------------- /EED/EED/ITypeEnv.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | class Type; 14 | class Declaration; 15 | class ParameterList; 16 | class Parameter; 17 | enum ENUMTY; 18 | enum ALIASTY; 19 | 20 | 21 | class ITypeEnv 22 | { 23 | public: 24 | virtual void AddRef() = 0; 25 | virtual void Release() = 0; 26 | 27 | virtual int GetPointerSize() = 0; 28 | virtual Type* GetType( ENUMTY ty ) = 0; 29 | virtual Type* GetVoidPointerType() = 0; 30 | virtual Type* GetAliasType( ALIASTY ty ) = 0; 31 | 32 | virtual HRESULT NewPointer( Type* pointed, Type*& pointer ) = 0; 33 | virtual HRESULT NewReference( Type* pointed, Type*& pointer ) = 0; 34 | virtual HRESULT NewDArray( Type* elem, Type*& type ) = 0; 35 | virtual HRESULT NewAArray( Type* elem, Type* key, Type*& type ) = 0; 36 | virtual HRESULT NewSArray( Type* elem, uint32_t length, Type*& type ) = 0; 37 | virtual HRESULT NewStruct( Declaration* decl, Type*& type ) = 0; 38 | virtual HRESULT NewEnum( Declaration* decl, Type*& type ) = 0; 39 | virtual HRESULT NewTypedef( const wchar_t* name, Type* aliasedType, Type*& type ) = 0; 40 | virtual HRESULT NewParam( StorageClass storage, Type* type, Parameter*& param ) = 0; 41 | virtual HRESULT NewParams( ParameterList*& paramList ) = 0; 42 | virtual HRESULT NewFunction( Type* returnType, Type* thisPtrType, ParameterList* params, uint8_t callConv, int varArgs, Type*& type ) = 0; 43 | virtual HRESULT NewDelegate( Type* funcType, Type*& type ) = 0; 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /EED/EED/Keywords.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | enum TOK; 11 | 12 | 13 | TOK MapToKeyword( const wchar_t* id ); 14 | TOK MapToKeyword( const wchar_t* id, size_t len ); 15 | -------------------------------------------------------------------------------- /EED/EED/NameTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Strings.h" 11 | 12 | 13 | namespace MagoEE 14 | { 15 | class NameTable 16 | { 17 | public: 18 | virtual void AddRef() = 0; 19 | virtual void Release() = 0; 20 | 21 | virtual ByteString* AddString( const char* str, size_t length ) = 0; 22 | virtual Utf16String* AddString( const wchar_t* str, size_t length ) = 0; 23 | virtual Utf32String* AddString( const dchar_t* str, size_t length ) = 0; 24 | 25 | virtual Utf16String* GetEmpty() = 0; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /EED/EED/NamedChars.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | MagoEE::dchar_t MapNamedCharacter( const wchar_t* name ); 12 | MagoEE::dchar_t MapNamedCharacter( const wchar_t* name, size_t len ); 13 | -------------------------------------------------------------------------------- /EED/EED/Object.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #include "Common.h" 9 | #include "Object.h" 10 | 11 | 12 | namespace MagoEE 13 | { 14 | Object::Object() 15 | : mRefCount( 0 ) 16 | { 17 | } 18 | 19 | Object::~Object() 20 | { 21 | } 22 | 23 | void Object::AddRef() 24 | { 25 | mRefCount++; 26 | } 27 | 28 | void Object::Release() 29 | { 30 | mRefCount--; 31 | _ASSERT( mRefCount >= 0 ); 32 | if ( mRefCount == 0 ) 33 | { 34 | delete this; 35 | } 36 | } 37 | 38 | ObjectKind ObjectList::GetObjectKind() 39 | { 40 | return ObjectKind_ObjectList; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /EED/EED/Object.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | enum ObjectKind 14 | { 15 | ObjectKind_None, 16 | ObjectKind_ObjectList, 17 | ObjectKind_Expression, 18 | ObjectKind_CastExpression, 19 | ObjectKind_ExpressionList, 20 | ObjectKind_Type, 21 | ObjectKind_NamePart, 22 | ObjectKind_Parameter, 23 | ObjectKind_ParameterList, 24 | }; 25 | 26 | class Object 27 | { 28 | long mRefCount; 29 | 30 | public: 31 | Object(); 32 | virtual ~Object(); 33 | 34 | virtual void AddRef(); 35 | virtual void Release(); 36 | 37 | virtual ObjectKind GetObjectKind() = 0; 38 | }; 39 | 40 | 41 | class ObjectList : public Object 42 | { 43 | public: 44 | std::list< RefPtr > List; 45 | 46 | virtual ObjectKind GetObjectKind(); 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /EED/EED/PropTables.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | class StdProperty; 14 | 15 | 16 | HRESULT InitPropTables(); 17 | void FreePropTables(); 18 | 19 | StdProperty* FindBaseProperty( const wchar_t* name ); 20 | StdProperty* FindIntProperty( const wchar_t* name ); 21 | StdProperty* FindFloatProperty( const wchar_t* name ); 22 | StdProperty* FindDArrayProperty( const wchar_t* name ); 23 | StdProperty* FindSArrayProperty( const wchar_t* name ); 24 | StdProperty* FindTupleProperty( const wchar_t* name ); 25 | StdProperty* FindDelegateProperty( const wchar_t* name ); 26 | StdProperty* FindFieldProperty( const wchar_t* name ); 27 | } 28 | -------------------------------------------------------------------------------- /EED/EED/Property.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | class ITypeEnv; 14 | class Type; 15 | class Declaration; 16 | union DataValue; 17 | 18 | 19 | class StdProperty 20 | { 21 | public: 22 | virtual bool GetType( ITypeEnv* typeEnv, Type* parentType, Declaration* parentDecl, Type*& type ) = 0; 23 | virtual bool UsesParentValue() = 0; 24 | virtual bool GetValue( Type* parentType, Declaration* parentDecl, DataValue& result ) = 0; 25 | virtual bool GetValue( Type* parentType, Declaration* parentDecl, const DataValue& parentVal , DataValue& result ) = 0; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /EED/EED/SharedString.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | // A reference counted wide string that supports taking in-place substrings of. 14 | // This class is not multithread safe. 15 | 16 | class SharedString 17 | { 18 | long mRefCount; 19 | wchar_t* mBuf; 20 | uint32_t mCapacity; 21 | uint32_t mLen; 22 | uint32_t mCutLen; 23 | wchar_t mLastCutChar; 24 | 25 | public: 26 | ~SharedString(); 27 | 28 | // lengths and capacities below do not include the nul-char 29 | 30 | void AddRef(); 31 | void Release(); 32 | 33 | uint32_t GetCapacity(); 34 | uint32_t GetLength(); 35 | 36 | bool Append( const wchar_t* str ); 37 | 38 | const wchar_t* GetCut( uint32_t len ); 39 | void ReleaseCut(); 40 | 41 | static bool Make( uint32_t capacity, RefPtr& str ); 42 | 43 | private: 44 | SharedString( wchar_t* buf, uint32_t capacity ); 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /EED/EED/SimpleNameTable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "NameTable.h" 11 | 12 | 13 | namespace MagoEE 14 | { 15 | class SimpleNameTable : public NameTable 16 | { 17 | typedef std::vector ByteStringVector; 18 | typedef std::vector Utf16StringVector; 19 | typedef std::vector Utf32StringVector; 20 | 21 | long mRefCount; 22 | ByteStringVector mByteStrs; 23 | Utf16StringVector mUtf16Strs; 24 | Utf32StringVector mUtf32Strs; 25 | 26 | public: 27 | SimpleNameTable(); 28 | ~SimpleNameTable(); 29 | 30 | virtual void AddRef(); 31 | virtual void Release(); 32 | 33 | virtual ByteString* AddString( const char* str, size_t length ); 34 | virtual Utf16String* AddString( const wchar_t* str, size_t length ); 35 | virtual Utf32String* AddString( const dchar_t* str, size_t length ); 36 | 37 | virtual Utf16String* GetEmpty(); 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /EED/EED/Strings.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | enum StringKind 14 | { 15 | StringKind_Byte, 16 | StringKind_Utf16, 17 | StringKind_Utf32 18 | }; 19 | 20 | struct String 21 | { 22 | StringKind Kind; 23 | uint32_t Length; 24 | }; 25 | 26 | struct ByteString : public String 27 | { 28 | char* Str; 29 | }; 30 | 31 | struct Utf16String : public String 32 | { 33 | wchar_t* Str; 34 | }; 35 | 36 | struct Utf32String : public String 37 | { 38 | dchar_t* Str; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /EED/EED/TypeCommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | enum ENUMTY 14 | { 15 | Tarray, // slice array, aka T[] 16 | Tsarray, // static array, aka T[dimension] 17 | Tnarray, // resizable array, aka T[new] 18 | Taarray, // associative array, aka T[type] 19 | Tpointer, 20 | Treference, 21 | Tfunction, 22 | Tident, 23 | Tclass, 24 | Tstruct, 25 | Tenum, 26 | Ttypedef, 27 | Tdelegate, 28 | 29 | Tnone, 30 | Tvoid, 31 | Tint8, 32 | Tuns8, 33 | Tint16, 34 | Tuns16, 35 | Tint32, 36 | Tuns32, 37 | Tint64, 38 | Tuns64, 39 | Tfloat32, 40 | Tfloat64, 41 | Tfloat80, 42 | 43 | Timaginary32, 44 | Timaginary64, 45 | Timaginary80, 46 | 47 | Tcomplex32, 48 | Tcomplex64, 49 | Tcomplex80, 50 | 51 | Tbit, 52 | Tbool, 53 | Tchar, 54 | Twchar, 55 | Tdchar, 56 | 57 | Terror, 58 | Tinstance, 59 | Ttypeof, 60 | Ttuple, 61 | Tslice, 62 | Treturn, 63 | TMAX 64 | }; 65 | 66 | enum ALIASTY 67 | { 68 | Tsize_t, 69 | Tptrdiff_t, 70 | 71 | ALIASTMAX 72 | }; 73 | 74 | enum UdtKind 75 | { 76 | Udt_Struct, 77 | Udt_Class, 78 | Udt_Union 79 | }; 80 | } 81 | -------------------------------------------------------------------------------- /EED/EED/UniAlpha.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | bool IsHexDigit( wchar_t c ); 14 | bool IsOctalDigit( wchar_t c ); 15 | bool IsIdentChar( wchar_t c ); 16 | bool IsUniAlpha( wchar_t ch ); 17 | bool IsIdentifier( const wchar_t* str ); 18 | 19 | int Utf8To32( const char* utf8Str, int utf8Len, dchar_t* utf32Str, int utf32Len ); 20 | int Utf8To16( const char* utf8Str, int utf8Len, wchar_t* utf16Str, int utf16Len ); 21 | int Utf16To8( const wchar_t* utf16Str, int utf16Len, char* utf8Str, int utf8Len ); 22 | int Utf16To32( const wchar_t* utf16Str, int utf16Len, dchar_t* utf32Str, int utf32Len ); 23 | int Utf32To16( bool ignoreErrors, const dchar_t* utf32Str, int utf32Len, wchar_t* utf16Str, int utf16Len, bool& truncated ); 24 | 25 | void AppendChar32( std::wstring& str, dchar_t c ); 26 | void AppendChar32( std::vector& str, dchar_t c ); 27 | 28 | size_t dcslen( const dchar_t* s ); 29 | dchar_t* dmemchr( dchar_t* s, dchar_t c, size_t n ); 30 | } 31 | -------------------------------------------------------------------------------- /EED/EED/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /EED/EEDTest/AppSettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class DataEnv; 12 | class TestFactory; 13 | 14 | 15 | struct AppSettings 16 | { 17 | bool SelfTest; 18 | bool PromoteTypedValue; 19 | bool AllowAssignment; 20 | bool TempAssignment; 21 | 22 | // TODO: I don't like this 23 | DataEnv* TestEvalDataEnv; 24 | TestFactory* TestElemFactory; 25 | }; 26 | 27 | 28 | extern AppSettings gAppSettings; 29 | -------------------------------------------------------------------------------- /EED/EEDTest/Common.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // EEDTest.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /EED/EEDTest/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #include "targetver.h" 16 | 17 | // C 18 | #define _CRTDBG_MAP_ALLOC 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | // C++ 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | // Windows 34 | #include 35 | #include 36 | 37 | // ATL 38 | #include 39 | 40 | // Magus 41 | #include 42 | 43 | #include "../Real/Real.h" 44 | #include "../Real/Complex.h" 45 | #include "../EED/EED.h" 46 | -------------------------------------------------------------------------------- /EED/EEDTest/DataElement.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Element.h" 11 | 12 | namespace MagoEE 13 | { 14 | class Type; 15 | enum ENUMTY; 16 | class Declaration; 17 | } 18 | 19 | 20 | // TODO: make Declaration derive from this 21 | class IScope 22 | { 23 | public: 24 | virtual HRESULT FindObject( const wchar_t* name, MagoEE::Declaration*& decl ) = 0; 25 | }; 26 | 27 | 28 | // TODO: should be IMemoryEnv 29 | class IDataEnv 30 | { 31 | public: 32 | virtual MagoEE::Address Allocate( uint32_t size ) = 0; 33 | }; 34 | 35 | 36 | class DataFactory : public ElementFactory 37 | { 38 | public: 39 | Element* NewElement( const wchar_t* name ); 40 | }; 41 | 42 | 43 | class DataElement : public Element 44 | { 45 | public: 46 | virtual void BindTypes( MagoEE::ITypeEnv* typeEnv, IScope* scope ) 47 | { 48 | } 49 | }; 50 | 51 | 52 | class DeclDataElement; 53 | class TypeDataElement; 54 | class ValueDataElement; 55 | class RefDataElement; 56 | 57 | #include "DeclDataElement.h" 58 | #include "TypeDataElement.h" 59 | #include "ValueDataElement.h" 60 | #include "RefDataElement.h" 61 | -------------------------------------------------------------------------------- /EED/EEDTest/DataValue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | namespace MagoEE 12 | { 13 | class Type; 14 | class Declaration; 15 | } 16 | 17 | 18 | class DataObj 19 | { 20 | public: 21 | enum Kind 22 | { 23 | LValue, 24 | RValue 25 | }; 26 | 27 | private: 28 | RefPtr mType; 29 | 30 | public: 31 | MagoEE::DataValue Value; 32 | 33 | DataObj(); 34 | virtual ~DataObj(); 35 | 36 | virtual Kind GetKind() const = 0; 37 | MagoEE::Type* GetType() const; 38 | virtual bool GetAddress( MagoEE::Address& addr ); 39 | virtual bool GetDeclaration( MagoEE::Declaration*& decl ); 40 | void SetType( MagoEE::Type* type ); 41 | void SetType( const RefPtr& type ); 42 | virtual std::wstring ToString() = 0; 43 | 44 | protected: 45 | void AppendValue( std::wstring& str ); 46 | }; 47 | 48 | 49 | class LValueObj : public DataObj 50 | { 51 | RefPtr mDecl; 52 | MagoEE::Address mAddr; 53 | 54 | public: 55 | LValueObj( MagoEE::Declaration* decl, MagoEE::Address addr ); 56 | 57 | virtual Kind GetKind() const; 58 | virtual bool GetAddress( MagoEE::Address& addr ); 59 | virtual bool GetDeclaration( MagoEE::Declaration*& decl ); 60 | virtual std::wstring ToString(); 61 | }; 62 | 63 | 64 | class RValueObj : public DataObj 65 | { 66 | public: 67 | virtual Kind GetKind() const; 68 | virtual std::wstring ToString(); 69 | }; 70 | -------------------------------------------------------------------------------- /EED/EEDTest/Element.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class Element 12 | { 13 | long mRefCount; 14 | 15 | public: 16 | Element() 17 | : mRefCount( 0 ) 18 | { 19 | } 20 | 21 | virtual ~Element() 22 | { 23 | } 24 | 25 | virtual void AddRef() 26 | { 27 | mRefCount++; 28 | } 29 | 30 | virtual void Release() 31 | { 32 | mRefCount--; 33 | if ( mRefCount == 0 ) 34 | delete this; 35 | } 36 | 37 | virtual const wchar_t* GetName() 38 | { 39 | return NULL; 40 | } 41 | 42 | virtual void AddChild( Element* elem ) = 0; 43 | virtual void SetAttribute( const wchar_t* name, const wchar_t* value ) = 0; 44 | virtual void SetAttribute( const wchar_t* name, Element* elemValue ) = 0; 45 | virtual void PrintElement() = 0; 46 | }; 47 | 48 | 49 | class ElementFactory 50 | { 51 | public: 52 | virtual Element* NewElement( const wchar_t* name ) = 0; 53 | }; 54 | -------------------------------------------------------------------------------- /EED/EEDTest/ErrorStr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #include "Common.h" 9 | #include "ErrorStr.h" 10 | 11 | 12 | static const wchar_t* gErrStrs[] = 13 | { 14 | L"Expression couldn't be evaluated", 15 | L"Syntax error", 16 | L"Incompatible types for operator", 17 | L"Value expected", 18 | L"Expression has no type", 19 | L"Type resolve failed", 20 | L"Bad cast", 21 | L"Expression has no address", 22 | L"L-value expected", 23 | L"Can't cast to bool", 24 | L"Divide by zero", 25 | L"Bad indexing operation", 26 | }; 27 | 28 | static wchar_t gTempStr[256] = L""; 29 | 30 | 31 | const wchar_t* GetErrorString( HRESULT hr ) 32 | { 33 | DWORD fac = HRESULT_FACILITY( hr ); 34 | DWORD code = HRESULT_CODE( hr ); 35 | 36 | if ( fac != MagoEE::HR_FACILITY ) 37 | { 38 | DWORD nRet = 0; 39 | 40 | nRet = FormatMessage( 41 | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, 42 | NULL, 43 | hr, 44 | 0, 45 | gTempStr, 46 | _countof( gTempStr ), 47 | NULL ); 48 | if ( nRet == 0 ) 49 | return gErrStrs[0]; 50 | 51 | return gTempStr; 52 | } 53 | 54 | if ( code >= _countof( gErrStrs ) ) 55 | return gErrStrs[0]; 56 | 57 | return gErrStrs[code]; 58 | } 59 | -------------------------------------------------------------------------------- /EED/EEDTest/ErrorStr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | const wchar_t* GetErrorString( HRESULT hr ); 12 | -------------------------------------------------------------------------------- /EED/EEDTest/GenTests/hash.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 Aldo J. Nunez 3 | # 4 | # Licensed under the Apache License, Version 2.0. 5 | # See the LICENSE text file for details. 6 | # 7 | 8 | function ByteToUpper( [byte] $b ) 9 | { 10 | return [byte] ($b -band 0xDF) 11 | } 12 | 13 | function IntToUpper( [uint32] $i ) 14 | { 15 | return [uint32] ($i -band 0xDFDFDFDF) 16 | } 17 | 18 | 19 | function GetSymbolNameHash( $name ) 20 | { 21 | [uint32] $end = 0 22 | [uint32] $wordLen = 0 23 | [uint32] $sum = 0 24 | 25 | $nameLen = $name.length 26 | 27 | while ( ($nameLen -band 3) -ne 0 ) 28 | { 29 | $end = $end -bor (ByteToUpper( $name[ $nameLen - 1 ] )) 30 | $end = $end * 256 # << 8 31 | $nameLen-- 32 | } 33 | 34 | $wordLen = $nameLen / 4 35 | 36 | for ( [uint32] $i = 0; $i -lt $wordLen; $i++ ) 37 | { 38 | $wordName = 0 39 | 40 | for ( $j = 3; $j -ge 0; $j-- ) 41 | { 42 | $wordName *= 256 43 | $wordName = $wordName -bor ($name[$i * 4 + $j] -band 0xFF) 44 | } 45 | 46 | $sum = $sum -bxor (IntToUpper( $wordName )) 47 | 48 | # rotl 49 | 50 | # $hi = $sum >> 28 51 | [uint32] $hi = ($sum -band 0xF0000000) / (256*256*256*16) -band 0xFF 52 | 53 | # $sum <<= 4 54 | [uint64] $longSum = $sum * 16 55 | $sum = [uint32] ($longSum -band 0x00000000FFFFFFFFL) 56 | 57 | $sum = $sum -bor $hi 58 | } 59 | 60 | $sum = $sum -bxor $end 61 | 62 | return $sum 63 | } 64 | 65 | "hash of '$args' = " 66 | $hash = GetSymbolNameHash( $args[0] ) 67 | "{0} (0x{0:X})" -f $hash 68 | -------------------------------------------------------------------------------- /EED/EEDTest/GenTests/makeRel1.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 Aldo J. Nunez 3 | # 4 | # Licensed under the Apache License, Version 2.0. 5 | # See the LICENSE text file for details. 6 | # 7 | 8 | $toolGen = ".\genArithTest" 9 | 10 | $prefix = "Hello" 11 | 12 | $binSetSpecs = 13 | @( 14 | "IntInt", 15 | "IntFloat", 16 | "FloatInt", 17 | "FloatFloat" 18 | ) 19 | 20 | $binTestSpecs = 21 | @( 22 | @{ op="<"; fileOp="Less" } 23 | @{ op="<="; fileOp="LessEqual" } 24 | @{ op=">"; fileOp="Greater" } 25 | @{ op=">="; fileOp="GreaterEqual" } 26 | @{ op="!<>="; fileOp="Unordered" } 27 | @{ op="<>"; fileOp="LessGreater" } 28 | @{ op="<>="; fileOp="LessGreaterEqual" } 29 | @{ op="!<="; fileOp="UnorderedGreater" } 30 | @{ op="!<"; fileOp="UnorderedGreaterEqual" } 31 | @{ op="!>="; fileOp="UnorderedLess" } 32 | @{ op="!>"; fileOp="UnorderedLessEqual" } 33 | @{ op="!<>"; fileOp="UnorderedEqual" } 34 | ) 35 | 36 | foreach ( $i in 1..4 ) 37 | { 38 | foreach ( $test in $binTestSpecs ) 39 | { 40 | $filename = "test{0}{1}.xml" -f $test.fileOp, $binSetSpecs[$i-1] 41 | if ( $forceOverwrite -or -not (test-path $filename) ) 42 | { 43 | "$filename not found" 44 | #& $toolGen $i "$($test.op)" $prefix > $filename 45 | & $toolGen $i $test.op $prefix > $filename 46 | } 47 | else 48 | { 49 | "$filename found" 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /EED/EEDTest/GenTests/makeUna.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 Aldo J. Nunez 3 | # 4 | # Licensed under the Apache License, Version 2.0. 5 | # See the LICENSE text file for details. 6 | # 7 | 8 | param ( $binSets, $binOps, $prefix, $toolGen, [switch] $whatIf, [switch] $force ) 9 | 10 | 11 | $setSpecs = 12 | @( 13 | "Int", 14 | "Float" 15 | ) 16 | 17 | $testSpecs = 18 | @{ 19 | "negate" = "Negate"; 20 | "bitnot" = "BitNot"; 21 | "not" = "Not"; 22 | "unaryadd" = "UnaryAdd"; 23 | } 24 | 25 | 26 | if ( $toolGen -eq $null ) 27 | { 28 | $toolGen = ".\genUnaryTest" 29 | } 30 | 31 | if ( $prefix -eq $null ) 32 | { 33 | $prefix = "Hello" 34 | } 35 | 36 | if ( $binSets -eq $null ) 37 | { 38 | $binSets = 1..2 39 | } 40 | 41 | if ( $binOps -eq $null ) 42 | { 43 | $binOps = $testSpecs.keys 44 | } 45 | 46 | 47 | foreach ( $i in $binSets ) 48 | { 49 | foreach ( $op in $binOps ) 50 | { 51 | $fileOp = $testSpecs[$op] 52 | $filename = "test{0}{1}.xml" -f $fileOp, $setSpecs[$i-1] 53 | 54 | if ( $force.isPresent -or -not (test-path $filename) ) 55 | { 56 | if ( $whatIf.isPresent ) 57 | { 58 | "didn't find $filename" 59 | } 60 | else 61 | { 62 | "generating $filename" 63 | & $toolGen $i $op $prefix > $filename 64 | } 65 | } 66 | else 67 | { 68 | "found $filename" 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /EED/EEDTest/GenTests/testAll.ps1: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 Aldo J. Nunez 3 | # 4 | # Licensed under the Apache License, Version 2.0. 5 | # See the LICENSE text file for details. 6 | # 7 | 8 | param ( [switch] $self ) 9 | 10 | $t1 = get-date 11 | $passedCount = 0 12 | 13 | dir test*.xml |% ` 14 | { 15 | if ( $self.isPresent ) 16 | { 17 | $selfArg = "-self" 18 | } 19 | 20 | ..\..\release\eedtest -data ..\d1.xml -test $_ $selfArg 21 | if ( $LASTEXITCODE -ne 0 ) 22 | { 23 | echo "Error in test file $($_.name)." 24 | exit 1 25 | } 26 | 27 | $passedCount++ 28 | } 29 | 30 | $t2 = get-date 31 | $span = $t2 - $t1 32 | 33 | "Tests passed: $passedCount" 34 | "Duration: $span" 35 | -------------------------------------------------------------------------------- /EED/EEDTest/RefDataElement.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class RefDataElement : public DataElement 12 | { 13 | public: 14 | virtual bool GetAddress( MagoEE::Address& addr ) = 0; 15 | 16 | static RefPtr MakeRefElement( const wchar_t* value ); 17 | }; 18 | 19 | 20 | class DeclRefDataElement : public RefDataElement 21 | { 22 | std::wstring mPath; 23 | RefPtr mDecl; 24 | 25 | public: 26 | virtual void BindTypes( MagoEE::ITypeEnv* typeEnv, IScope* scope ); 27 | virtual bool GetAddress( MagoEE::Address& addr ); 28 | 29 | virtual void AddChild( Element* elem ); 30 | virtual void SetAttribute( const wchar_t* name, const wchar_t* value ); 31 | virtual void SetAttribute( const wchar_t* name, Element* elemValue ); 32 | virtual void PrintElement(); 33 | }; 34 | -------------------------------------------------------------------------------- /EED/EEDTest/SaxErrorHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class SAXErrorHandler : public ISAXErrorHandler 12 | { 13 | LONG mRefCount; 14 | 15 | public: 16 | SAXErrorHandler(); 17 | virtual ~SAXErrorHandler(); 18 | 19 | // This must be correctly implemented, if your handler must be a COM Object (in this example it does not) 20 | HRESULT __stdcall QueryInterface( const GUID& riid,void** ppvObject ); 21 | ULONG __stdcall AddRef(); 22 | ULONG __stdcall Release(); 23 | 24 | virtual HRESULT STDMETHODCALLTYPE error( 25 | /* [in] */ ISAXLocator *pLocator, 26 | /* [in] */ const wchar_t *pwchErrorMessage, 27 | /* [in] */ HRESULT hrErrorCode); 28 | 29 | virtual HRESULT STDMETHODCALLTYPE fatalError( 30 | /* [in] */ ISAXLocator *pLocator, 31 | /* [in] */ const wchar_t *pwchErrorMessage, 32 | /* [in] */ HRESULT hrErrorCode); 33 | 34 | virtual HRESULT STDMETHODCALLTYPE ignorableWarning( 35 | /* [in] */ ISAXLocator *pLocator, 36 | /* [in] */ const wchar_t *pwchErrorMessage, 37 | /* [in] */ HRESULT hrErrorCode); 38 | 39 | private: 40 | void ReportError( 41 | /* [in] */ const wchar_t __RPC_FAR *pwchVal, 42 | /* [in] */ HRESULT errCode); 43 | }; 44 | -------------------------------------------------------------------------------- /EED/EEDTest/SymUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | HRESULT FindBasicType( const wchar_t* name, MagoEE::ITypeEnv* typeEnv, MagoEE::Declaration*& decl ); 12 | 13 | 14 | struct IDiaSymbol; 15 | 16 | void PrintSymProps( IDiaSymbol* sym ); 17 | -------------------------------------------------------------------------------- /EED/EEDTest/TestReal10.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | 3 | #include "../Real/Real.h" 4 | #include 5 | 6 | bool TestReal10() 7 | { 8 | Real10 r0, rnan, r1, r2, r3, r4, r5; 9 | r0.Zero(); 10 | assert(r0.IsZero()); 11 | assert(!r0.IsNan()); 12 | rnan.LoadNan(); 13 | assert(rnan.IsNan()); 14 | 15 | r1.FromDouble(1); 16 | r2.FromFloat(2); 17 | r3.FromInt32(3); 18 | r4.FromInt64(4); 19 | r5.FromUInt64((1LLU << 63) + 1); 20 | 21 | assert(!r1.IsZero()); 22 | assert(!r5.IsZero()); 23 | 24 | Real10 r6; r6.Mul(r2, r3); 25 | Real10 r7; r7.Add(r6, r1); 26 | Real10 rm2; rm2.Negate(r2); 27 | Real10 r8; r8.Sub(r6, rm2); 28 | Real10 rm3; rm3.Div(r6, rm2); 29 | Real10 rr1; rr1.Rem(r7, r2); 30 | Real10 ra2; ra2.Abs(rm2); 31 | 32 | assert(r1.ToInt16() == 1); 33 | assert(r2.ToInt32() == 2); 34 | assert(r3.ToInt64() == 3); 35 | assert(r4.ToUInt64() == 4); 36 | assert(r5.ToUInt64() == (1LLU << 63) + 1); 37 | assert(r6.ToDouble() == 6); 38 | assert(r7.ToDouble() == 7); 39 | assert(r8.ToFloat() == 8); 40 | assert(rm2.ToFloat() == -2); 41 | assert(rm3.ToFloat() == -3); 42 | assert(rr1.ToFloat() == 1); 43 | assert(ra2.ToFloat() == 2); 44 | 45 | assert(Real10::IsLess(Real10::Compare(r1, r2))); 46 | assert(Real10::IsEqual(Real10::Compare(r1, rr1))); 47 | assert(Real10::IsGreater(Real10::Compare(r3, r2))); 48 | 49 | assert(r1.FitsInDouble()); 50 | r0.LoadEpsilon(); 51 | r1.Add(r1, r0); 52 | assert(!Real10::IsEqual(Real10::Compare(r1, rr1))); 53 | 54 | return true; 55 | } -------------------------------------------------------------------------------- /EED/EEDTest/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /EED/Include/MagoEED.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #include "..\MagoNatEE\MagoNatEE.h" 12 | -------------------------------------------------------------------------------- /EED/MagoNatCC/.vsdbg-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://aka.ms/vs/vsdbg-config-schema", 3 | "languages": [ 4 | { 5 | "languageId": "{002a2de9-8bb6-484d-9800-7e4ad4084715}", 6 | "vendorId": "{994b45c4-e6e9-11d2-903f-00c04fa302a1}", 7 | "name": "D", 8 | "codeViewCompilerIds": [ { "code": 68 } ] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /EED/MagoNatCC/MagoNatCC.def: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Microsoft. All rights reserved. 2 | ; Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | LIBRARY "MagoNatCC.DLL" 5 | 6 | EXPORTS 7 | DllCanUnloadNow PRIVATE 8 | DllGetClassObject PRIVATE 9 | 10 | -------------------------------------------------------------------------------- /EED/MagoNatCC/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MagoNatEE.rc 4 | // 5 | 6 | #define IDS_PROJNAME 100 7 | 8 | // Next default values for new objects 9 | // 10 | #ifdef APSTUDIO_INVOKED 11 | #ifndef APSTUDIO_READONLY_SYMBOLS 12 | #define _APS_NEXT_RESOURCE_VALUE 201 13 | #define _APS_NEXT_COMMAND_VALUE 32768 14 | #define _APS_NEXT_CONTROL_VALUE 201 15 | #define _APS_NEXT_SYMED_VALUE 101 16 | #endif 17 | #endif 18 | -------------------------------------------------------------------------------- /EED/MagoNatCC/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include "stdafx.h" 5 | #include "resource.h" 6 | #include "dllmain.h" 7 | 8 | #include "Common.h" 9 | #include "EED.h" 10 | 11 | #include 12 | 13 | CMagoNatEEModule _AtlModule; 14 | 15 | // DLL Entry Point 16 | extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID lpReserved) 17 | { 18 | #ifdef _DEBUG 19 | if (dwReason == DLL_PROCESS_ATTACH) 20 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 21 | #endif 22 | 23 | BOOL rc = _AtlModule.DllMain(dwReason, lpReserved); 24 | 25 | switch ( dwReason ) 26 | { 27 | case DLL_PROCESS_ATTACH: 28 | MagoEE::Init(); 29 | break; 30 | 31 | case DLL_PROCESS_DETACH: 32 | MagoEE::Uninit(); 33 | break; 34 | 35 | case DLL_THREAD_ATTACH: 36 | case DLL_THREAD_DETACH: 37 | break; 38 | } 39 | 40 | return rc; 41 | } 42 | 43 | // Used to determine whether the DLL can be unloaded by OLE 44 | STDAPI DllCanUnloadNow(void) 45 | { 46 | return _AtlModule.DllCanUnloadNow(); 47 | } 48 | 49 | // Returns a class factory to create an object of the requested type 50 | STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) 51 | { 52 | return _AtlModule.DllGetClassObject(rclsid, riid, ppv); 53 | } 54 | -------------------------------------------------------------------------------- /EED/MagoNatCC/dllmain.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | class CMagoNatEEModule : public CAtlDllModuleT< CMagoNatEEModule > 5 | { 6 | }; 7 | 8 | extern class CMagoNatEEModule _AtlModule; 9 | -------------------------------------------------------------------------------- /EED/MagoNatCC/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | // stdafx.cpp : source file that includes just the standard includes 5 | // MagoNatEE.pch will be the pre-compiled header 6 | // stdafx.obj will contain the pre-compiled type information 7 | 8 | #include "stdafx.h" 9 | -------------------------------------------------------------------------------- /EED/MagoNatCC/stdafx.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | // stdafx.h : include file for standard system include files, 5 | // or project specific include files that are used frequently, 6 | // but are changed infrequently 7 | 8 | #pragma once 9 | 10 | #ifndef STRICT 11 | #define STRICT 12 | #endif 13 | 14 | #include "targetver.h" 15 | 16 | #define _ATL_FREE_THREADED 17 | #define _ATL_NO_AUTOMATIC_NAMESPACE 18 | 19 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 20 | 21 | #include "resource.h" 22 | #include 23 | #include 24 | #include 25 | 26 | // missing in some versions of ? 27 | typedef enum CorGCReferenceType CorGCReferenceType; 28 | 29 | #include 30 | #include 31 | 32 | using namespace ATL; 33 | using namespace Microsoft::VisualStudio::Debugger; 34 | using namespace Microsoft::VisualStudio::Debugger::CallStack; 35 | -------------------------------------------------------------------------------- /EED/MagoNatCC/targetver.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | // The following macros define the minimum required platform. The minimum required platform 7 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 8 | // your application. The macros work by enabling all features available on platform versions up to and 9 | // including the version specified. 10 | 11 | // Modify the following defines if you have to target a platform prior to the ones specified below. 12 | // Refer to MSDN for the latest info on corresponding values for different platforms. 13 | #ifndef WINVER // Specifies that the minimum required platform is Windows Vista. 14 | #define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. 15 | #endif 16 | 17 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 18 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 19 | #endif 20 | 21 | #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. 22 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 23 | #endif 24 | 25 | #ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. 26 | #define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /EED/MagoNatEE/Common.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MagoNatEE.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "Common.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /EED/MagoNatEE/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | // stdafx.h : include file for standard system include files, 9 | // or project specific include files that are used frequently, but 10 | // are changed infrequently 11 | // 12 | 13 | #pragma once 14 | 15 | #include "targetver.h" 16 | 17 | #include 18 | #include 19 | 20 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 21 | // Windows Header Files: 22 | #include 23 | 24 | #include 25 | 26 | #include "..\Real\Real.h" 27 | #include "..\Real\Complex.h" 28 | #include "..\EED\EED.h" 29 | -------------------------------------------------------------------------------- /EED/MagoNatEE/dllmain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | 7 | Purpose: Defines the entry point for the DLL 8 | */ 9 | 10 | #include "Common.h" 11 | 12 | 13 | BOOL APIENTRY DllMain( HMODULE hModule, 14 | DWORD reason, 15 | LPVOID lpReserved ) 16 | { 17 | UNREFERENCED_PARAMETER( lpReserved ); 18 | 19 | switch ( reason ) 20 | { 21 | case DLL_PROCESS_ATTACH: 22 | DisableThreadLibraryCalls( hModule ); 23 | MagoEE::Init(); 24 | break; 25 | 26 | case DLL_PROCESS_DETACH: 27 | MagoEE::Uninit(); 28 | break; 29 | 30 | case DLL_THREAD_ATTACH: 31 | case DLL_THREAD_DETACH: 32 | break; 33 | } 34 | 35 | return TRUE; 36 | } 37 | -------------------------------------------------------------------------------- /EED/MagoNatEE/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MagoNatEE.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /EED/MagoNatEE/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /EED/Real/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "targetver.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | -------------------------------------------------------------------------------- /EED/Real/Complex.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "Real.h" 11 | 12 | 13 | struct Complex10 14 | { 15 | Real10 RealPart; 16 | Real10 ImaginaryPart; 17 | 18 | static uint16_t Compare( const Complex10& left, const Complex10& right ); 19 | 20 | void Zero(); 21 | 22 | void Add( const Complex10& left, const Complex10& right ); 23 | void Sub( const Complex10& left, const Complex10& right ); 24 | void Mul( const Complex10& left, const Complex10& right ); 25 | void Div( const Complex10& left, const Complex10& right ); 26 | void Rem( const Complex10& left, const Real10& right ); 27 | void Negate( const Complex10& orig ); 28 | }; 29 | -------------------------------------------------------------------------------- /EED/Real/Real.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Source Files 45 | 46 | 47 | -------------------------------------------------------------------------------- /EED/Real/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /EED/ddemangle/demangle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define XNEWVEC(T, n) malloc(sizeof(T)*(n)) 4 | #define XRESIZEVEC(T, p, n) realloc(p, sizeof(T)*(n)) 5 | #define XDELETEVEC(p) free(p) 6 | 7 | #define DMGL_NO_OPTS 0 /* For readability... */ 8 | #define DMGL_PARAMS (1 << 0) /* Include function args */ 9 | #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ 10 | #define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ 11 | #define DMGL_VERBOSE (1 << 3) /* Include implementation details. */ 12 | #define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */ 13 | -------------------------------------------------------------------------------- /EED/ddemangle/libiberty.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/EED/ddemangle/libiberty.h -------------------------------------------------------------------------------- /EED/ddemangle/safe-ctype.h: -------------------------------------------------------------------------------- 1 | /* replacement macros. 2 | 3 | To avoid conflicts, this header defines the isxxx functions in upper 4 | case, e.g. ISALPHA not isalpha. */ 5 | 6 | #ifndef SAFE_CTYPE_H 7 | #define SAFE_CTYPE_H 8 | 9 | #include 10 | 11 | #define ISALPHA isalpha 12 | #define ISALNUM isalnum 13 | #define ISBLANK isblank 14 | #define ISCNTRL iscntrl 15 | #define ISDIGIT isdigit 16 | #define ISGRAPH isgraph 17 | #define ISLOWER islower 18 | #define ISPRINT isprint 19 | #define ISPUNCT ispunct 20 | #define ISSPACE isspace 21 | #define ISUPPER isupper 22 | #define ISXDIGIT isxdigit 23 | 24 | #endif /* SAFE_CTYPE_H */ 25 | -------------------------------------------------------------------------------- /EED/gdtoa/arith.h: -------------------------------------------------------------------------------- 1 | #define IEEE_8087 2 | #define Arith_Kind_ASL 1 3 | #define Double_Align 4 | -------------------------------------------------------------------------------- /EED/gdtoa/gd_qnan.h: -------------------------------------------------------------------------------- 1 | #define f_QNAN 0xffc00000 2 | #define d_QNAN0 0x0 3 | #define d_QNAN1 0xfff80000 4 | #define ld_QNAN0 0x0 5 | #define ld_QNAN1 0xfff80000 6 | #define ld_QNAN2 0x0 7 | #define ld_QNAN3 0x0 8 | #define ldus_QNAN0 0x0 9 | #define ldus_QNAN1 0x0 10 | #define ldus_QNAN2 0x0 11 | #define ldus_QNAN3 0xc000 12 | #define ldus_QNAN4 0x7fff 13 | -------------------------------------------------------------------------------- /EED/gdtoa/gdtoa_fltrnds.h: -------------------------------------------------------------------------------- 1 | FPI *fpi, fpi1; 2 | int Rounding; 3 | #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ 4 | Rounding = Flt_Rounds; 5 | #else /*}{*/ 6 | Rounding = 1; 7 | switch(fegetround()) { 8 | case FE_TOWARDZERO: Rounding = 0; break; 9 | case FE_UPWARD: Rounding = 2; break; 10 | case FE_DOWNWARD: Rounding = 3; 11 | } 12 | #endif /*}}*/ 13 | fpi = &fpi0; 14 | if (Rounding != 1) { 15 | fpi1 = fpi0; 16 | fpi = &fpi1; 17 | fpi1.rounding = Rounding; 18 | } 19 | -------------------------------------------------------------------------------- /EED/gdtoa/printf.c: -------------------------------------------------------------------------------- 1 | #ifdef __sun 2 | #define Use_GDTOA_Qtype 3 | #else 4 | #if defined(__i386) || defined(__x86_64) 5 | #define Use_GDTOA_for_i386_long_double 6 | #endif 7 | #endif 8 | #include "printf.c0" 9 | -------------------------------------------------------------------------------- /EED/gdtoa/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // fp.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /EED/gdtoa/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | -------------------------------------------------------------------------------- /Include/Guard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | class Guard 12 | { 13 | CRITICAL_SECTION mCritSec; 14 | 15 | public: 16 | Guard() 17 | { 18 | InitializeCriticalSection( &mCritSec ); 19 | } 20 | 21 | ~Guard() 22 | { 23 | DeleteCriticalSection( &mCritSec ); 24 | } 25 | 26 | void Enter() 27 | { 28 | EnterCriticalSection( &mCritSec ); 29 | } 30 | 31 | void Leave() 32 | { 33 | LeaveCriticalSection( &mCritSec ); 34 | } 35 | }; 36 | 37 | class GuardedArea 38 | { 39 | Guard& mGuard; 40 | 41 | public: 42 | explicit GuardedArea( Guard& guard ) 43 | : mGuard( guard ) 44 | { 45 | mGuard.Enter(); 46 | } 47 | 48 | ~GuardedArea() 49 | { 50 | mGuard.Leave(); 51 | } 52 | 53 | private: 54 | GuardedArea& operator =( GuardedArea& other ); 55 | }; 56 | -------------------------------------------------------------------------------- /Include/MagoVersion.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Aldo J. Nunez 3 | 4 | Licensed under the Apache License, Version 2.0. 5 | See the LICENSE text file for details. 6 | */ 7 | 8 | #pragma once 9 | 10 | 11 | #define MAGO_VERSION_MAJOR 1 12 | #define MAGO_VERSION_MINOR 0 13 | 14 | #ifndef MAGO_VERSION_BUILD 15 | #define MAGO_VERSION_BUILD 0 16 | #endif 17 | 18 | #define MAGO_VERSION_REVISION 0 19 | 20 | 21 | #define MAGO_MAKE_STRING2( x ) #x 22 | #define MAGO_MAKE_STRING( x ) MAGO_MAKE_STRING2( x ) 23 | 24 | #define MAGO_FILEVERSION MAGO_VERSION_MAJOR,MAGO_VERSION_MINOR,MAGO_VERSION_BUILD,MAGO_VERSION_REVISION 25 | #define MAGO_FILEVERSION_STR MAGO_MAKE_STRING( MAGO_VERSION_MAJOR.MAGO_VERSION_MINOR.MAGO_VERSION_BUILD.MAGO_VERSION_REVISION ) 26 | #define MAGO_PRODVERSION MAGO_FILEVERSION 27 | #define MAGO_PRODVERSION_STR MAGO_MAKE_STRING( MAGO_VERSION_MAJOR.MAGO_VERSION_MINOR ) 28 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2005_32.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2005_64.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\8.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2008_32.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2008_64.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2010_32.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2010_64.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2013_32.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\12.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /Install/EngineMetrics_2013_64.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\AD7Metrics\Engine\{97348AC0-2B6B-4B99-A245-4C7E2C09D403}] 4 | "AlwaysLoadLocal"=dword:00000001 5 | "CLSID"="{97348AC0-2B6B-4B99-A245-4C7E2C09D403}" 6 | "Name"="Mago Native" 7 | "ENC"=dword:00000000 8 | "Disassembly"=dword:00000001 9 | "Exceptions"=dword:00000001 10 | 11 | -------------------------------------------------------------------------------- /MagoDELauncher/MagoDELauncher.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagoDELauncher", "MagoDELauncher\MagoDELauncher.csproj", "{943C78EE-68BB-45E1-84A3-3FD30BE5D619}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {943C78EE-68BB-45E1-84A3-3FD30BE5D619}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {943C78EE-68BB-45E1-84A3-3FD30BE5D619}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {943C78EE-68BB-45E1-84A3-3FD30BE5D619}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {943C78EE-68BB-45E1-84A3-3FD30BE5D619}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /MagoMI/editline/AUTHORS: -------------------------------------------------------------------------------- 1 | Paolo Tosco 2 | 3 | Please feel free to contact the corresponding author 4 | to request information or report bugs. 5 | 6 | http://mingweditline.sourceforge.net/ 7 | -------------------------------------------------------------------------------- /MagoMI/editline/COPYING: -------------------------------------------------------------------------------- 1 | WinEditLine (formerly MinGWEditLine) 2 | Copyright 2010-2014 Paolo Tosco 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of WinEditLine (formerly MinGWEditLine) nor the 15 | name of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /MagoMI/editline/source/config.h: -------------------------------------------------------------------------------- 1 | #define WinEditLine_VERSION_MAJOR 2 2 | #define WinEditLine_VERSION_MINOR 1 3 | -------------------------------------------------------------------------------- /MagoMI/mago-mi/source/cmdinput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "miutils.h" 5 | 6 | /// input callback interface 7 | class CmdInputCallback { 8 | public: 9 | virtual ~CmdInputCallback() {} 10 | /// called on new input line 11 | virtual void onInputLine(std::wstring &s) = 0; 12 | /// called when ctrl+c or ctrl+break is called 13 | virtual void onCtrlBreak() = 0; 14 | }; 15 | 16 | /// console or redirected stdin input 17 | /// Supports readline editor for windows console 18 | struct CmdInput { 19 | private: 20 | CmdInputCallback * _callback; 21 | bool _inConsole; 22 | bool _closed; 23 | bool _enabled; 24 | StringBuffer _buf; 25 | void lineCompleted(); 26 | public: 27 | CmdInput(); 28 | ~CmdInput(); 29 | void enable(bool enabled); 30 | void showPrompt(); 31 | bool inConsole() { return _inConsole; } 32 | /// sets input callback 33 | void setCallback(CmdInputCallback * callback) { 34 | _callback = callback; 35 | } 36 | 37 | /// returns true if stdin/stdout is closed 38 | bool isClosed(); 39 | /// poll input, return false if stdin is closed or eof 40 | bool poll(); 41 | }; 42 | 43 | /// global cmd input object 44 | extern CmdInput _cmdinput; 45 | 46 | /// write line to stdout, returns false if writing is failed 47 | bool writeStdout(std::wstring s); 48 | /// write line to stderr, returns false if writing is failed 49 | bool writeStderr(std::wstring s); 50 | 51 | /// formatted output to debugger stdout 52 | bool writeStdout(const char * fmt, ...); 53 | /// formatted output to debugger stdout 54 | bool writeStdout(const wchar_t * fmt, ...); 55 | /// formatted output to debugger stderr 56 | bool writeStderr(const char * fmt, ...); 57 | /// formatted output to debugger stderr 58 | bool writeStderr(const wchar_t * fmt, ...); 59 | -------------------------------------------------------------------------------- /MagoMI/mago-mi/source/cmdline.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define EMULATED_GDB_VERSION L"7.1.90" 4 | #define MAGO_MI_VERSION L"0.3.3" 5 | #define VERSION_STRING L"GNU gdb (mago-mi " MAGO_MI_VERSION L") " EMULATED_GDB_VERSION 6 | #define VERSION_EXPLANATION_STRING L"(Actually it's mago-mi debugger. Version shows GDB for Eclipse CDT compatibility)" 7 | 8 | // Command line arguments parser 9 | extern "C" void parseCommandLine(int argc, wchar_t *argv[]); 10 | 11 | #define MAX_PARAM_COUNT 10000 12 | struct ExecutableInfo { 13 | std::wstring exename; 14 | wstring_vector args; 15 | std::wstring dir; 16 | std::wstring logFile; 17 | std::wstring logLevel; 18 | std::wstring tty; 19 | int argCount() { return (int)args.size(); } 20 | bool verbose; 21 | bool miMode; 22 | bool silent; 23 | bool stopOnEntry; 24 | 25 | ExecutableInfo(); 26 | ~ExecutableInfo(); 27 | void clear(); 28 | void setExecutable(std::wstring exe); 29 | void setDir(std::wstring directory); 30 | void addArg(std::wstring param); 31 | void setTty(std::wstring tty); 32 | void dumpParams(); 33 | 34 | bool hasExecutableSpecified(); 35 | }; 36 | 37 | extern ExecutableInfo params; 38 | 39 | -------------------------------------------------------------------------------- /MagoMI/mago-mi/source/mago-mi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/MagoMI/mago-mi/source/mago-mi.cpp -------------------------------------------------------------------------------- /PropSheets/MagoDbg_winsdk.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder) 6 | $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder) 7 | $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion) 8 | $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@ProductVersion) 9 | 10 | $(WindowsTargetPlatformVersion_10).0 11 | $(WindowsTargetPlatformVersion_10) 12 | 13 | 14 | -------------------------------------------------------------------------------- /PropSheets/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Third-Party Libraries 2 | ===================== 3 | 4 | Mago Debugger tests depend on several third-party libraries. When built with Visual Studio 2010 or 5 | later, the various projects that make up Mago look up the paths to these libraries' include 6 | and library files using a property sheet MagoDbg_properties.props in the PropSheets folder. 7 | 8 | The property sheet uses several environment variables: 9 | 10 | Name Value (a path to) 11 | ---- ----------------- 12 | VS_SDK_PATH overwrite Visual Studio 2008 SDK path (or later SDK) 13 | CPPTEST_1_1_0_SRC_PATH CppTest 1.1.0 source code (only needed for some tests) 14 | CPPTEST_1_1_0_LIB_PATH CppTest 1.1.0 library 15 | 16 | You should also have the DIA SDK installed with Visual Studio. 17 | 18 | Mago is ready to build after one of these steps: 19 | 20 | 1. Define environment variables that match the macros above. Then run msbuild or Visual Studio 21 | from the command line where the environment variables are defined. 22 | 2. Replace the macro references with their values in MagoDbg_properties.props. 23 | -------------------------------------------------------------------------------- /cpptest/AUTHORS: -------------------------------------------------------------------------------- 1 | Current maintainers 2 | Nate Gallaher 3 | Sebastian Pipping 4 | 5 | Main author: 6 | Niklas Lundell 7 | 8 | Contributors: 9 | David Morris - pkg-config and installation patches. 10 | Robin Patenall - migration to XHTML 1.0 strict 11 | Sebastian Pipping - several bugfixes 12 | Nate Gallaher - additional assertion macros 13 | Robert Buchholz - build system fixes 14 | Dagobert Michelsen - build system fixes 15 | -------------------------------------------------------------------------------- /cpptest/BUGS: -------------------------------------------------------------------------------- 1 | CppTest bug tracker at SourceForge 2 | https://sourceforge.net/tracker/?atid=550611&group_id=77564&func=browse 3 | -------------------------------------------------------------------------------- /cpptest/ChangeLog: -------------------------------------------------------------------------------- 1 | 2 | See NEWS for more information. 3 | 4 | -------------------------------------------------------------------------------- /cpptest/INSTALL.quick: -------------------------------------------------------------------------------- 1 | Installing the CppTest library 2 | 3 | Table of contents 4 | ================= 5 | 6 | - Using GNU tools 7 | - Simple install procedure 8 | - Configuration options 9 | - Under Microsoft Windows 10 | 11 | Using GNU tools 12 | =============== 13 | 14 | For more detailed information about the installation process, see INSTALL. 15 | 16 | Simple install procedure 17 | ------------------------ 18 | 19 | > gzip -cd cpptest-1.1.2.tar.gz | tar xvf - # unpack the sources 20 | > cd cpptest-1.1.2 # change to the its directory 21 | > ./configure # run the 'configure' script 22 | > make # build 'cpptest' 23 | 24 | [ Become root if necessary ] 25 | 26 | > make install 27 | 28 | Configuration options 29 | --------------------- 30 | 31 | The 'configure' script can be given a number of options to enable 32 | and disable various features. For a complete list, type: 33 | 34 | ./configure --help 35 | 36 | Under Microsoft Windows 37 | ======================= 38 | 39 | Windows specific files are found under the 'win' directory. 40 | 41 | If you are using Microsoft Visual Studio .NET, there is a project/solution 42 | created under win\VisualStudio.Net. This solution creates both the library 43 | and the test program. 44 | 45 | -------------------------------------------------------------------------------- /cpptest/INSTALL.quick.in: -------------------------------------------------------------------------------- 1 | Installing the CppTest library 2 | 3 | Table of contents 4 | ================= 5 | 6 | - Using GNU tools 7 | - Simple install procedure 8 | - Configuration options 9 | - Under Microsoft Windows 10 | 11 | Using GNU tools 12 | =============== 13 | 14 | For more detailed information about the installation process, see INSTALL. 15 | 16 | Simple install procedure 17 | ------------------------ 18 | 19 | > gzip -cd cpptest-@VERSION@.tar.gz | tar xvf - # unpack the sources 20 | > cd cpptest-@VERSION@ # change to the its directory 21 | > ./configure # run the 'configure' script 22 | > make # build 'cpptest' 23 | 24 | [ Become root if necessary ] 25 | 26 | > make install 27 | 28 | Configuration options 29 | --------------------- 30 | 31 | The 'configure' script can be given a number of options to enable 32 | and disable various features. For a complete list, type: 33 | 34 | ./configure --help 35 | 36 | Under Microsoft Windows 37 | ======================= 38 | 39 | Windows specific files are found under the 'win' directory. 40 | 41 | If you are using Microsoft Visual Studio .NET, there is a project/solution 42 | created under win\VisualStudio.Net. This solution creates both the library 43 | and the test program. 44 | 45 | -------------------------------------------------------------------------------- /cpptest/config/stamp-h.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/cpptest/config/stamp-h.in -------------------------------------------------------------------------------- /cpptest/doc/footer.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | Supported by: 4 |

5 | SourceForge Logo 7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /cpptest/doc/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | CppTest - A C++ Unit Testing Framework 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 18 | 19 |
12 | CppTest home page 13 | 16 | CppTest project page 17 |
20 |
21 | 22 | -------------------------------------------------------------------------------- /cpptest/doc/images/screenshot-compiler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/cpptest/doc/images/screenshot-compiler.png -------------------------------------------------------------------------------- /cpptest/doc/images/screenshot-text-terse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/cpptest/doc/images/screenshot-text-terse.png -------------------------------------------------------------------------------- /cpptest/doc/images/screenshot-text-verbose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainers/mago/ab21c776807ba3ba7ca0ab593a73dcccc38430ae/cpptest/doc/images/screenshot-text-verbose.png -------------------------------------------------------------------------------- /cpptest/doc/test.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | \namespace Test 4 | 5 | This is the namespace used by CppTest. 6 | 7 | */ 8 | 9 | -------------------------------------------------------------------------------- /cpptest/libcpptest.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: libcpptest 7 | Description: C++ test suite 8 | Version: 1.1.2 9 | Libs: -L${libdir} -lcpptest 10 | Cflags: -I${includedir} 11 | 12 | 13 | -------------------------------------------------------------------------------- /cpptest/libcpptest.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libcpptest 7 | Description: C++ test suite 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lcpptest 10 | Cflags: -I${includedir} 11 | 12 | 13 | -------------------------------------------------------------------------------- /cpptest/src/cpptest.h: -------------------------------------------------------------------------------- 1 | // --- 2 | // 3 | // $Id: cpptest.h,v 1.3 2005/06/08 08:08:06 nilu Exp $ 4 | // 5 | // CppTest - A C++ Unit Testing Framework 6 | // Copyright (c) 2003 Niklas Lundell 7 | // 8 | // --- 9 | // 10 | // This library is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Lesser General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2 of the License, or (at your option) any later version. 14 | // 15 | // This library is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | // Lesser General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU Lesser General Public 21 | // License along with this library; if not, write to the 22 | // Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 | // Boston, MA 02111-1307, USA. 24 | // 25 | // --- 26 | 27 | /** \file */ 28 | 29 | #ifndef CPPTEST_H 30 | #define CPPTEST_H 31 | 32 | #include "cpptest-assert.h" 33 | #include "cpptest-source.h" 34 | #include "cpptest-suite.h" 35 | #include "cpptest-time.h" 36 | 37 | #include "cpptest-compileroutput.h" 38 | #include "cpptest-htmloutput.h" 39 | #include "cpptest-textoutput.h" 40 | 41 | #endif // #ifndef CPPTEST_H 42 | 43 | -------------------------------------------------------------------------------- /cpptest/src/missing.h: -------------------------------------------------------------------------------- 1 | // --- 2 | // 3 | // $Id: missing.h,v 1.4 2008/07/15 20:33:31 hartwork Exp $ 4 | // 5 | // CppTest - A C++ Unit Testing Framework 6 | // Copyright (c) 2003 Niklas Lundell 7 | // 8 | // --- 9 | // 10 | // This library is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Lesser General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2 of the License, or (at your option) any later version. 14 | // 15 | // This library is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | // Lesser General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU Lesser General Public 21 | // License along with this library; if not, write to the 22 | // Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 | // Boston, MA 02111-1307, USA. 24 | // 25 | // --- 26 | 27 | #ifndef CPPTEST_MISSING_H 28 | #define CPPTEST_MISSING_H 29 | 30 | #if (defined(__WIN32__) || defined(WIN32)) 31 | # include "winconfig.h" 32 | #else 33 | # include "config.h" 34 | #endif 35 | 36 | namespace Test 37 | { 38 | #ifndef HAVE_GETTIMEOFDAY 39 | 40 | struct timeval 41 | { 42 | long tv_sec; 43 | long tv_usec; 44 | }; 45 | 46 | extern int gettimeofday(timeval* tv, void*); 47 | 48 | #endif // #ifndef HAVE_GETTIMEOFDAY 49 | 50 | #ifndef HAVE_ROUND 51 | extern double round(double d); 52 | #endif 53 | 54 | } // namespace Test 55 | 56 | #endif // #ifndef CPPTEST_MISSING_H 57 | -------------------------------------------------------------------------------- /cpptest/src/utils.cpp: -------------------------------------------------------------------------------- 1 | // --- 2 | // 3 | // $Id: utils.cpp,v 1.5 2008/07/15 20:33:31 hartwork Exp $ 4 | // 5 | // CppTest - A C++ Unit Testing Framework 6 | // Copyright (c) 2003 Niklas Lundell 7 | // 8 | // --- 9 | // 10 | // This library is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Lesser General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2 of the License, or (at your option) any later version. 14 | // 15 | // This library is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | // Lesser General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU Lesser General Public 21 | // License along with this library; if not, write to the 22 | // Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 | // Boston, MA 02111-1307, USA. 24 | // 25 | // --- 26 | 27 | 28 | #if (defined(__WIN32__) || defined(WIN32)) 29 | # include "winconfig.h" 30 | #else 31 | # include "config.h" 32 | #endif 33 | 34 | #include "missing.h" 35 | #include "utils.h" 36 | 37 | namespace Test 38 | { 39 | // Computes the procentage of correct tests. 40 | // 41 | int 42 | correct(int tests, int errors) 43 | { 44 | if ((errors == 0) || (tests == 0)) 45 | return 100; 46 | 47 | return (tests - errors) * 100 / tests; 48 | } 49 | 50 | } // namespace Test 51 | -------------------------------------------------------------------------------- /cpptest/src/utils.h: -------------------------------------------------------------------------------- 1 | // --- 2 | // 3 | // $Id: utils.h,v 1.3 2005/06/08 08:08:06 nilu Exp $ 4 | // 5 | // CppTest - A C++ Unit Testing Framework 6 | // Copyright (c) 2003 Niklas Lundell 7 | // 8 | // --- 9 | // 10 | // This library is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Lesser General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2 of the License, or (at your option) any later version. 14 | // 15 | // This library is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | // Lesser General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU Lesser General Public 21 | // License along with this library; if not, write to the 22 | // Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 | // Boston, MA 02111-1307, USA. 24 | // 25 | // --- 26 | 27 | #ifndef CPPTEST_UTILS_H 28 | #define CPPTEST_UTILS_H 29 | 30 | namespace Test 31 | { 32 | extern int correct(int tests, int errors); 33 | 34 | } // namespace Test 35 | 36 | #endif // #ifndef CPPTEST_UTILS_H 37 | -------------------------------------------------------------------------------- /cpptest/test/Makefile.am: -------------------------------------------------------------------------------- 1 | ## --- 2 | ## 3 | ## $Id: Makefile.am,v 1.5 2008/07/13 18:28:11 hartwork Exp $ 4 | ## 5 | ## CppTest - A C++ Unit Testing Framework 6 | ## Copyright (c) 2003 Niklas Lundell 7 | ## 8 | ## --- 9 | ## 10 | ## This library is free software; you can redistribute it and/or 11 | ## modify it under the terms of the GNU Lesser General Public 12 | ## License as published by the Free Software Foundation; either 13 | ## version 2 of the License, or (at your option) any later version. 14 | ## 15 | ## This library is distributed in the hope that it will be useful, 16 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | ## Lesser General Public License for more details. 19 | ## 20 | ## You should have received a copy of the GNU Lesser General Public 21 | ## License along with this library; if not, write to the 22 | ## Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 | ## Boston, MA 02111-1307, USA. 24 | ## 25 | ## --- 26 | 27 | WARN_FLAGS = 28 | if WARNINGS 29 | WARN_FLAGS += -W -Wall 30 | endif 31 | 32 | AM_CXXFLAGS = $(WARN_FLAGS) 33 | 34 | noinst_PROGRAMS = mytest 35 | 36 | mytest_LDFLAGS = -static 37 | mytest_LDADD = ../src/libcpptest.la 38 | mytest_SOURCES = mytest.cpp 39 | 40 | MOSTLYCLEANFILES = 41 | 42 | CLEANFILES = 43 | 44 | DISTCLEANFILES = \ 45 | Makefile 46 | 47 | MAINTAINERCLEANFILES = \ 48 | Makefile.in 49 | 50 | -------------------------------------------------------------------------------- /cpptest/win/winconfig.h: -------------------------------------------------------------------------------- 1 | // --- 2 | // 3 | // $Id: winconfig.h,v 1.1 2008/07/15 20:33:31 hartwork Exp $ 4 | // 5 | // CppTest - A C++ Unit Testing Framework 6 | // Copyright (c) 2003 Niklas Lundell 7 | // 8 | // --- 9 | // 10 | // This library is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Lesser General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2 of the License, or (at your option) any later version. 14 | // 15 | // This library is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | // Lesser General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU Lesser General Public 21 | // License along with this library; if not, write to the 22 | // Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 | // Boston, MA 02111-1307, USA. 24 | // 25 | // --- 26 | 27 | #ifndef TEST_CONFIG_H 28 | #define TEST_CONFIG_H 29 | 30 | // Capabilities 31 | // 32 | #define HAVE_GETTICKCOUNT 33 | 34 | // Compiler specific stuff 35 | // 36 | #if _MSC_VER == 1200 // MS Visual C++ 6.0 37 | #pragma warning (disable: 4786) 38 | #endif 39 | 40 | #if _MSC_VER > 1300 // MS Visual C++ .NET 2002 and above 41 | #pragma warning (disable: 4267) 42 | #endif 43 | 44 | #endif // #ifndef TEST_CONFIG_H 45 | -------------------------------------------------------------------------------- /udis86/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2012, Vivek Thampi 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 20 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /udis86/_ReadMe.txt: -------------------------------------------------------------------------------- 1 | The version is 1.7.2 + additional commits up to commit 2 | 56ff6c87c11de0ffa725b14339004820556e343d from https://github.com/vmt/udis86 3 | 4 | The original distribution of udis86 comes with files for building on UNIX-like 5 | systems and test suite. I left those files out and built my own Visual Studio projects. 6 | The source depends on a file config.h which is generated from the original build 7 | files based on the file config.h.in. I copied config.h.in to config.h and changed it 8 | as needed. 9 | 10 | You can find the project page online here: 11 | http://sourceforge.net/projects/udis86 12 | -------------------------------------------------------------------------------- /udis86/config.h: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_STDINT_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDLIB_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STRINGS_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRING_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_SYS_STAT_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_TYPES_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_UNISTD_H 32 | 33 | /* Name of package */ 34 | #undef PACKAGE 35 | 36 | /* Define to the address where bug reports for this package should be sent. */ 37 | #undef PACKAGE_BUGREPORT 38 | 39 | /* Define to the full name of this package. */ 40 | #undef PACKAGE_NAME 41 | 42 | /* Define to the full name and version of this package. */ 43 | #define PACKAGE_STRING "Udis86 CLI 1.7" 44 | 45 | /* Define to the one symbol short name of this package. */ 46 | #undef PACKAGE_TARNAME 47 | 48 | /* Define to the version of this package. */ 49 | #undef PACKAGE_VERSION 50 | 51 | /* Define to 1 if you have the ANSI C header files. */ 52 | #undef STDC_HEADERS 53 | 54 | /* Version number of package */ 55 | #undef VERSION 56 | -------------------------------------------------------------------------------- /udis86/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_STDINT_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDLIB_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STRINGS_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRING_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_SYS_STAT_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_TYPES_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_UNISTD_H 32 | 33 | /* Name of package */ 34 | #undef PACKAGE 35 | 36 | /* Define to the address where bug reports for this package should be sent. */ 37 | #undef PACKAGE_BUGREPORT 38 | 39 | /* Define to the full name of this package. */ 40 | #undef PACKAGE_NAME 41 | 42 | /* Define to the full name and version of this package. */ 43 | #undef PACKAGE_STRING 44 | 45 | /* Define to the one symbol short name of this package. */ 46 | #undef PACKAGE_TARNAME 47 | 48 | /* Define to the version of this package. */ 49 | #undef PACKAGE_VERSION 50 | 51 | /* Define to 1 if you have the ANSI C header files. */ 52 | #undef STDC_HEADERS 53 | 54 | /* Version number of package */ 55 | #undef VERSION 56 | -------------------------------------------------------------------------------- /udis86/docs/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = x86 manual 2 | MAINTAINERCLEANFILES = Makefile.in 3 | -------------------------------------------------------------------------------- /udis86/docs/manual/Makefile.am: -------------------------------------------------------------------------------- 1 | manualdir = ${docdir}/manual 2 | 3 | rst_sources = \ 4 | index.rst \ 5 | getstarted.rst \ 6 | libudis86.rst 7 | 8 | # 9 | # The official distribution only contains the rst files. So users 10 | # may generate documentation using Sphinx if they wish to. 11 | # 12 | EXTRA_DIST = \ 13 | $(rst_sources) \ 14 | udis86.info \ 15 | conf.py \ 16 | static 17 | 18 | MAINTAINERCLEANFILES = \ 19 | Makefile.in \ 20 | udis86.info 21 | 22 | if HAVE_SPHINX_DOC 23 | 24 | html-local: 25 | $(SPHINX_BUILD) -c $(srcdir) -b html $(srcdir) $(builddir)/html 26 | 27 | udis86.info: $(rst_sources) 28 | $(SPHINX_BUILD) -E -c $(srcdir) -b texinfo $(srcdir) $(builddir)/texinfo 29 | $(MAKEINFO) --no-split $(builddir)/texinfo/udis86.texi 30 | 31 | check-local: html-local 32 | 33 | else 34 | 35 | udis86.info: $(rst_sources) 36 | html-local udis86.info: 37 | @echo "" 38 | @echo "------------------------------------------------------------------" 39 | @echo "" 40 | @echo " Please make sure you have Sphinx (sphinx-doc.org) version 1.1.3" 41 | @echo " or above, to be able to build documentation." 42 | @echo "" 43 | @echo " You can also find documentation at http://udis86.sourceforge.net/" 44 | @echo "" 45 | @echo "------------------------------------------------------------------" 46 | @echo "" 47 | @exit 1 48 | 49 | endif 50 | 51 | install-info-local: udis86.info 52 | install-info --info-dir=$(infodir) $< 53 | 54 | clean-local: 55 | -rm -rf $(builddir)/html 56 | -rm -rf $(builddir)/texinfo $(builddir)/udis86.info 57 | -------------------------------------------------------------------------------- /udis86/docs/manual/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys, os 3 | 4 | source_suffix = '.rst' 5 | master_doc = 'index' 6 | project = u'udis86' 7 | copyright = u'2013, Vivek Thampi' 8 | version = '1.7' 9 | release = '1.7.2' 10 | 11 | # List of patterns, relative to source directory, that match files and 12 | # directories to ignore when looking for source files. 13 | exclude_patterns = ['_build'] 14 | 15 | pygments_style = 'sphinx' 16 | html_theme = 'pyramid' 17 | html_theme_options = { "nosidebar" : True } 18 | html_static_path = ['static'] 19 | html_style = "udis86.css" 20 | htmlhelp_basename = 'udis86doc' 21 | 22 | latex_documents = [ 23 | ('index', 'udis86.tex', u'udis86 Documentation', 24 | u'Vivek Thampi', 'manual'), 25 | ] 26 | 27 | man_pages = [ 28 | ('index', 'udis86', u'udis86 Documentation', 29 | [u'Vivek Thampi'], 1) 30 | ] 31 | 32 | texinfo_documents = [ 33 | ('index', 'udis86', u'udis86 Documentation', 34 | u'Vivek Thampi', 'udis86', 'Disassembler library for x86.', 35 | 'Miscellaneous', True), 36 | ] 37 | -------------------------------------------------------------------------------- /udis86/docs/manual/getstarted.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | =============== 3 | 4 | 5 | Building and Installing udis86 6 | ------------------------------ 7 | 8 | udis86 is developed for unix-like environments, and like most software, 9 | the basic steps towards building and installing it are as follows. 10 | 11 | .. code:: 12 | 13 | $ ./configure 14 | $ make 15 | $ make install 16 | 17 | Depending on your choice of install location, you may need to have root 18 | privileges to do an install. The install scripts copy the necessary header 19 | and library files to appropriate locations in your system. 20 | 21 | 22 | Interfacing with libudis86: A Quick Example 23 | ------------------------------------------- 24 | 25 | The following is an example of a program that interfaces with libudis86 26 | and uses the API to generate assembly language output for 64-bit code, 27 | input from STDIN. 28 | 29 | .. code-block:: c 30 | 31 | #include 32 | #include 33 | 34 | int main() 35 | { 36 | ud_t ud_obj; 37 | 38 | ud_init(&ud_obj); 39 | ud_set_input_file(&ud_obj, stdin); 40 | ud_set_mode(&ud_obj, 64); 41 | ud_set_syntax(&ud_obj, UD_SYN_INTEL); 42 | 43 | while (ud_disassemble(&ud_obj)) { 44 | printf("\t%s\n", ud_insn_asm(&ud_obj)); 45 | } 46 | 47 | return 0; 48 | } 49 | 50 | To compile the program (using gcc): 51 | 52 | .. code:: 53 | 54 | $ gcc -ludis86 example.c -o example 55 | 56 | This example should give you an idea of how this library can be used. The 57 | following sections describe, in detail, the complete API of libudis86. 58 | -------------------------------------------------------------------------------- /udis86/docs/manual/index.rst: -------------------------------------------------------------------------------- 1 | .. udis86 documentation master file 2 | 3 | Welcome to udis86's documentation! 4 | ================================== 5 | 6 | Udis86 is a disassembler engine that decodes a stream of binary 7 | machine code bytes as opcodes defined in the x86 and x86-64 class 8 | of Instruction Set Archictures. The core component of this project 9 | is libudis86 which provides a clean and simple interface to 10 | disassemble binary code, and to inspect the disassembly to various 11 | degrees of detail. The library is designed to aid software 12 | projects that entail analysis and manipulation of all flavors of 13 | x86 binary code. 14 | 15 | 16 | .. toctree:: 17 | :maxdepth: 3 18 | 19 | getstarted 20 | libudis86 21 | 22 | Indices and tables 23 | ================== 24 | 25 | * :ref:`genindex` 26 | * :ref:`search` 27 | 28 | -------------------------------------------------------------------------------- /udis86/docs/x86/Makefile.am: -------------------------------------------------------------------------------- 1 | x86dir = ${docdir}/x86 2 | dist_x86_DATA = optable.xml optable.xsl 3 | 4 | MAINTAINERCLEANFILES = Makefile.in 5 | -------------------------------------------------------------------------------- /udis86/docs/x86/README: -------------------------------------------------------------------------------- 1 | x86 optable reference 2 | --------------------- 3 | (incomplete) 4 | 5 | P - modrm (reg mmx) 6 | PR - modrm (rm mmx, mod must be 11b) 7 | Q - modrm (rm mmx if mod=11b else mem) 8 | 9 | V - modrm (reg - xmm) 10 | VR - modrm (rm xmm, mod must be 11b) 11 | W - modrm (rm xmm if mod=11b else mem) 12 | 13 | G - modrm (reg - gpr) 14 | S - modrm (reg - seg) 15 | VR - modrm (rm gpr, mod must be 11b) 16 | E - modrm (rm gpr if mod=11b else mem) 17 | M - modrm (mem), mod!=11b 18 | 19 | I - immediate 20 | J - relative immediate 21 | O - memory offset 22 | 23 | C - control reg 24 | D - debug reg 25 | 26 | 27 | opc <> 28 | 29 | /n - modrm reg field extends opcode 30 | /Mnn - disassembly mode extends opcode 31 | /Onn - operand mode extends opcode 32 | /mod=!11 - modrm mod field extends opcode 33 | 34 | 35 | -------------------------------------------------------------------------------- /udis86/libudis86/input.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * input.h 3 | * 4 | * Copyright (c) 2006, Vivek Mohan 5 | * All rights reserved. See LICENSE 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | #ifndef UD_INPUT_H 9 | #define UD_INPUT_H 10 | 11 | #include "types.h" 12 | 13 | uint8_t inp_next(struct ud*); 14 | uint8_t inp_peek(struct ud*); 15 | uint8_t inp_uint8(struct ud*); 16 | uint16_t inp_uint16(struct ud*); 17 | uint32_t inp_uint32(struct ud*); 18 | uint64_t inp_uint64(struct ud*); 19 | void inp_move(struct ud*, size_t); 20 | void inp_back(struct ud*); 21 | 22 | /* inp_init() - Initializes the input system. */ 23 | #define inp_init(u) \ 24 | do { \ 25 | u->inp_curr = 0; \ 26 | u->inp_fill = 0; \ 27 | u->inp_ctr = 0; \ 28 | u->inp_end = 0; \ 29 | } while (0) 30 | 31 | /* inp_start() - Should be called before each de-code operation. */ 32 | #define inp_start(u) u->inp_ctr = 0 33 | 34 | /* inp_back() - Resets the current pointer to its position before the current 35 | * instruction disassembly was started. 36 | */ 37 | #define inp_reset(u) \ 38 | do { \ 39 | u->inp_curr -= u->inp_ctr; \ 40 | u->inp_ctr = 0; \ 41 | } while (0) 42 | 43 | /* inp_sess() - Returns the pointer to current session. */ 44 | #define inp_sess(u) (u->inp_sess) 45 | 46 | /* inp_cur() - Returns the current input byte. */ 47 | #define inp_curr(u) ((u)->inp_cache[(u)->inp_curr]) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /udis86/udcli/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = udcli 2 | udcli_SOURCES = udcli.c 3 | udcli_CFLAGS = -I$(top_srcdir)/libudis86 -I$(top_srcdir) 4 | udcli_LDADD = $(top_builddir)/libudis86/libudis86.la 5 | MAINTAINERCLEANFILES = Makefile.in 6 | -------------------------------------------------------------------------------- /udis86/udis86.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * udis86.h 3 | * 4 | * Copyright (c) 2002, 2003, 2004 Vivek Mohan 5 | * All rights reserved. See (LICENSE) 6 | * ----------------------------------------------------------------------------- 7 | */ 8 | 9 | #ifndef UDIS86_H 10 | #define UDIS86_H 11 | 12 | #include "libudis86/types.h" 13 | #include "libudis86/extern.h" 14 | #include "libudis86/itab.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /udis86/udis86/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by udis86.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /udis86/udis86/udis86.def: -------------------------------------------------------------------------------- 1 | 2 | EXPORTS 3 | ud_init 4 | ud_set_mode 5 | ud_set_pc 6 | ud_set_vendor 7 | ud_set_syntax 8 | ud_decode 9 | ud_disassemble 10 | ud_translate_intel 11 | ud_translate_att 12 | ud_insn_asm 13 | ud_insn_ptr 14 | ud_insn_off 15 | ud_insn_hex 16 | ud_insn_len 17 | ud_lookup_mnemonic 18 | ud_set_input_buffer -------------------------------------------------------------------------------- /udis86/udis86/udis86.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | 28 | 29 | Resource Files 30 | 31 | 32 | --------------------------------------------------------------------------------