├── .gitattributes ├── .gitignore ├── .gitmodules ├── Asm ├── Asm.def ├── Asm.h ├── Asm.inc ├── Asm.vcxproj ├── Asm.vcxproj.filters ├── AsmPrivate.h ├── CopyPages.asm ├── FillPages.asm ├── InjectionThunk.asm ├── InjectionThunk3.asm ├── InjectionThunk4.asm ├── InjectionThunk5.asm ├── InjectionThunkLeafTest.asm ├── InjectionThunkOriginal.asm ├── Misc.asm ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── AsmLib ├── AsmLib.vcxproj └── AsmLib.vcxproj.filters ├── BenchmarkExe ├── Benchmark.asm ├── BenchmarkExe.vcxproj ├── BenchmarkExe.vcxproj.filters ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── CallStack1.dgml ├── Crt.props ├── Cu ├── Cu.cuh └── TraceStoreKernels.cu ├── DebugEngine ├── DebugEngine.h ├── DebugEngine.vcxproj ├── DebugEngine.vcxproj.filters ├── DebugEngineBuildCommand.c ├── DebugEngineCommands.c ├── DebugEngineCommands.h ├── DebugEngineConstants.c ├── DebugEngineConstants.h ├── DebugEngineDisplayType.c ├── DebugEngineEventCallbacks.c ├── DebugEngineEventLoop.c ├── DebugEngineExamineSymbols.c ├── DebugEngineExecuteCommand.c ├── DebugEngineInputCallbacks.c ├── DebugEngineInterfaces.c ├── DebugEngineInterfaces.h ├── DebugEngineOutput.c ├── DebugEngineOutputCallbacks.c ├── DebugEngineOutputCallbacks2.c ├── DebugEnginePrivate.h ├── DebugEngineSettingsMeta.c ├── DebugEngineUnassembleFunction.c ├── DestroyDebugEngine.c ├── DestroyDebugEngineSession.c ├── InitializeDebugEngine.c ├── InitializeDebugEngineSession.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── DebugEngineLib ├── DebugEngineLib.vcxproj └── DebugEngineLib.vcxproj.filters ├── DebuggerSettings.xml ├── Dia2Dump.exe ├── DriverMinimumRules.ruleset ├── IncludeFileDependencies1.dgml ├── InjectionThunk ├── InjectionRemoteThreadEntry.c ├── InjectionThunk.def ├── InjectionThunk.h ├── InjectionThunk.vcxproj ├── InjectionThunk.vcxproj.filters ├── InjectionThunkPrivate.h ├── _InjectionThunk.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── LICENSE ├── ModuleLoaderExe ├── ModuleLoaderExe.vcxproj ├── ModuleLoaderExe.vcxproj.filters ├── ModuleLoaderExeMain.c ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── NT.props ├── PGO-README.md ├── PerfectHashTable.sln ├── PerfectHashTable ├── BenchmarkPerfectHashTable.c ├── Chm_01.c ├── Chm_01.h ├── CreatePerfectHashTable.c ├── CreatePerfectHashTableContext.c ├── DestroyPerfectHashTable.c ├── DestroyPerfectHashTableContext.c ├── DestroyPerfectHashTableKeys.c ├── LoadPerfectHashTable.c ├── LoadPerfectHashTableKeys.c ├── PerfectHashTable.def ├── PerfectHashTable.h ├── PerfectHashTable.vcxproj ├── PerfectHashTable.vcxproj.filters ├── PerfectHashTableAllocator.c ├── PerfectHashTableConstants.c ├── PerfectHashTableConstants.h ├── PerfectHashTableDelete.c ├── PerfectHashTableHash.c ├── PerfectHashTableInsert.c ├── PerfectHashTableLookup.c ├── PerfectHashTableMask.c ├── PerfectHashTableNames.c ├── PerfectHashTablePrime.c ├── PerfectHashTablePrime.h ├── PerfectHashTablePrivate.h ├── PerfectHashTableRefCount.c ├── PerfectHashTableTls.c ├── SelfTestPerfectHashTable.c ├── TestPerfectHashTable.c ├── data │ ├── .gitignore │ └── generate.py ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── PerfectHashTableBenchmarkSingleExe ├── PerfectHashTableBenchmarkSingleExe.vcxproj ├── PerfectHashTableBenchmarkSingleExe.vcxproj.filters ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── PerfectHashTableSelfTestExe ├── PerfectHashTableSelfTestExe.vcxproj ├── PerfectHashTableSelfTestExe.vcxproj.filters ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── Python ├── FindPythonDll.c ├── Python.c ├── Python.h ├── Python.vcxproj ├── Python.vcxproj.filters ├── Python.vcxproj.user ├── Python27-Exports.txt ├── PythonAllocators.c ├── PythonConstants.c ├── PythonDllFiles.h ├── PythonFunction.c ├── PythonImage.c ├── PythonImage.h ├── PythonLineNumbers.c ├── PythonPathTableEntry.c ├── PythonPrivate.h ├── PythonTypes.c ├── distutils │ └── 2.7 │ │ └── msvc9compiler.py ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── PythonApp ├── .gitattributes ├── .gitignore ├── PythonApp.pyproj ├── bin │ ├── tracer.bat │ ├── tracer.py │ ├── tracerdev.bat │ └── tracerdev.py ├── conf │ ├── tracer-win10x64-vm1.conf │ ├── tracer.conf │ └── tracerdev.conf ├── ez_setup.py ├── lib │ ├── .gitattributes │ ├── .gitignore │ ├── tracer │ │ ├── __init__.py │ │ ├── _version.py │ │ ├── cdb.py │ │ ├── cli.py │ │ ├── command.py │ │ ├── commandinvariant.py │ │ ├── commands.py │ │ ├── config.py │ │ ├── constants.py │ │ ├── convert.py │ │ ├── dbgeng │ │ │ ├── __init__.py │ │ │ └── display_type.py │ │ ├── debug.py │ │ ├── device.py │ │ ├── dll-disabled.py │ │ ├── dll │ │ │ ├── Allocator.py │ │ │ ├── Python.py │ │ │ ├── PythonTracer.py │ │ │ ├── Rtl.py │ │ │ ├── TraceStore.py │ │ │ ├── TracerConfig.py │ │ │ └── __init__.py │ │ ├── example_commands.py │ │ ├── exe.py │ │ ├── invariant.py │ │ ├── kbhit.py │ │ ├── load.py │ │ ├── logic.py │ │ ├── path.py │ │ ├── pipe_win32.py │ │ ├── progressbar.py │ │ ├── reader.py │ │ ├── runvspyprof.py │ │ ├── sourcefile.py │ │ ├── test │ │ │ ├── __init__.py │ │ │ ├── constants.py │ │ │ ├── test_dbgeng.py │ │ │ └── test_dbgeng2.py │ │ ├── testprof.py │ │ ├── tracer-disabled.py │ │ ├── tracer.py │ │ ├── types.py │ │ ├── util.py │ │ ├── util_win32.py │ │ ├── vspyprof.py │ │ └── wintypes.py │ └── tracerdev │ │ ├── __init__.py │ │ ├── commands.py │ │ ├── config.py │ │ └── rtl.py ├── pt.py ├── ptd.py ├── py27test.py ├── setup.py └── versioneer.py ├── PythonExe ├── .gitignore ├── PathHack.h ├── PythonExe.h ├── PythonExe.vcxproj ├── PythonExe.vcxproj.filters ├── main.c ├── main_hooked.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── PythonProject ├── PythonProject.c ├── PythonProject.h ├── PythonProject.vcxproj ├── PythonProject.vcxproj.filters ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── PythonTracer ├── NewPythonPathTableEntry.c ├── PyTraceEvent1.c ├── PyTraceEvent2.c ├── PyTraceEvent3.c ├── PyTraceEvent4.c ├── PythonTracer.c ├── PythonTracer.h ├── PythonTracer.vcxproj ├── PythonTracer.vcxproj.filters ├── PythonTracerCallbackWorkers.c ├── PythonTracerCallbacks.c ├── PythonTracerConstants.c ├── PythonTracerConstants.h ├── PythonTracerPrivate.h ├── PythonTracerTraceStoreRelocations.c ├── PythonTracerTypes.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── PythonTracerInjection ├── PythonTracerDebugEventCallbacks.c ├── PythonTracerInjection.c ├── PythonTracerInjection.def ├── PythonTracerInjection.h ├── PythonTracerInjection.vcxproj ├── PythonTracerInjection.vcxproj.filters ├── PythonTracerInjectionPrivate.h ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── README.md ├── Rtl ├── AtExitEx.c ├── AtExitEx.h ├── BitManipulationInline.h ├── Buffer.c ├── Commandline.c ├── Commandline.h ├── CopyFunction.c ├── CopyPages.c ├── CopyPagesNonTemporalAvx2.asm ├── Cu.h ├── Cuda.h ├── DbgHelpFunctionPointerTypedefs.h ├── DisableWarnings.h ├── File.c ├── HeapAllocator.c ├── HeapAllocator.h ├── InjectThunk.c ├── Injection.c ├── Injection.h ├── InjectionInitialize.c ├── InjectionInline.h ├── InjectionPrivate.c ├── InjectionRemoteThreadEntryThunk.c ├── Loader.c ├── Memory.h ├── Path.c ├── PathEnvironmentVariable.c ├── Privilege.c ├── Registry.c ├── Rtl.c ├── Rtl.def ├── Rtl.h ├── Rtl.vcxproj ├── Rtl.vcxproj.filters ├── RtlAtExitRundown.c ├── RtlConstants.c ├── RtlConstants.h ├── RtlGlobalAtExitRundown.c ├── RtlPrivate.h ├── Sqlite.h ├── String.c ├── SymbolLoader.c ├── Time.h ├── UnicodeString.c ├── __C_specific_handler.c ├── __C_specific_handler.h ├── __chkstk.s ├── atexit.c ├── atexit.h ├── dllmain.c ├── memset.c ├── memset.h ├── sha1.c ├── sha1.h ├── sqlite3.h ├── sqlite3ext.h ├── stdafx.c ├── stdafx.h └── targetver.h ├── RtlLib ├── RtlLib.vcxproj ├── RtlLib.vcxproj.filters ├── stdafx.c ├── stdafx.h └── targetver.h ├── SALExamples.h ├── ScratchExe ├── Scratch.asm ├── ScratchExe.vcxproj ├── ScratchExe.vcxproj.filters ├── TestStructuredExceptionHandling.asm ├── TestStructuredExceptionHandling2.asm ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── StringTable.h ├── StringTable ├── CopyStringArray.c ├── CreateStringArray.c ├── CreateStringTable.c ├── DestroyStringTable.c ├── IsPrefixOfStringInTable_C.c ├── IsStringInTableC.c ├── PrefixSearchStringTable.c ├── SearchStringTable.c ├── StringLoadStoreOperations.h ├── StringTable.h ├── StringTable.inc ├── StringTable.vcxproj ├── StringTable.vcxproj.filters ├── StringTableAllocator.c ├── StringTableConstants.h ├── StringTableConstants_C.c ├── StringTablePrivate.h ├── StringTableTestGlue.h ├── StringTableTypes.c ├── StringTable_x64.asm ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── StringTable2 ├── CopyStringArray.c ├── CreateStringArray.c ├── CreateStringArray_2.c ├── CreateStringTable.c ├── DestroyStringTable.c ├── IntegerDivision_x64.asm ├── IsPrefixOfCStrInArray_1.c ├── IsPrefixOfStringInTable_1.c ├── IsPrefixOfStringInTable_10.c ├── IsPrefixOfStringInTable_11.c ├── IsPrefixOfStringInTable_12.c ├── IsPrefixOfStringInTable_13.c ├── IsPrefixOfStringInTable_14.c ├── IsPrefixOfStringInTable_15.c ├── IsPrefixOfStringInTable_2.c ├── IsPrefixOfStringInTable_3.c ├── IsPrefixOfStringInTable_4.c ├── IsPrefixOfStringInTable_5.c ├── IsPrefixOfStringInTable_6.c ├── IsPrefixOfStringInTable_7.c ├── IsPrefixOfStringInTable_8.c ├── IsPrefixOfStringInTable_9.c ├── IsPrefixOfStringInTable_x64_1.asm ├── IsPrefixOfStringInTable_x64_10.asm ├── IsPrefixOfStringInTable_x64_11.asm ├── IsPrefixOfStringInTable_x64_12.asm ├── IsPrefixOfStringInTable_x64_13.asm ├── IsPrefixOfStringInTable_x64_14.asm ├── IsPrefixOfStringInTable_x64_15.asm ├── IsPrefixOfStringInTable_x64_16.asm ├── IsPrefixOfStringInTable_x64_2.asm ├── IsPrefixOfStringInTable_x64_3.asm ├── IsPrefixOfStringInTable_x64_4.asm ├── IsPrefixOfStringInTable_x64_5.asm ├── IsPrefixOfStringInTable_x64_6.asm ├── IsPrefixOfStringInTable_x64_7.asm ├── IsPrefixOfStringInTable_x64_8.asm ├── IsPrefixOfStringInTable_x64_9.asm ├── README.md ├── SearchStringTable.c ├── StringLoadStoreOperations.h ├── StringTable.def ├── StringTable.h ├── StringTable.inc ├── StringTable2.vcxproj ├── StringTable2.vcxproj.filters ├── StringTableAllocator.c ├── StringTableConstants.h ├── StringTableConstants_C.c ├── StringTablePrivate.h ├── StringTableTestGlue.c ├── StringTableTestGlue.h ├── StringTableTypes.c ├── TestStringTable.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── StringTable2BenchmarkExe ├── StringTable2BenchmarkExe.vcxproj ├── StringTable2BenchmarkExe.vcxproj.filters ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── StringTable2Test ├── StringTable2Test.vcxproj ├── StringTable2Test.vcxproj.filters ├── stdafx.cpp ├── stdafx.h ├── targetver.h ├── unittest1.cpp └── unittest2.cpp ├── StringTablePerformanceTest ├── StringTablePerformanceTest.vcxproj ├── StringTablePerformanceTest.vcxproj.filters ├── main.cpp ├── stdafx.c ├── stdafx.h └── targetver.h ├── TestInjectionExe ├── TestInjectThunk.c ├── TestInjection.c ├── TestInjection.h ├── TestInjectionExe.vcxproj ├── TestInjectionExe.vcxproj.filters ├── TestInjectionMain.c ├── TestInjectionObjects.c ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TestStringTable ├── TestStringTable.vcxproj ├── TestStringTable.vcxproj.filters ├── stdafx.cpp ├── stdafx.h ├── targetver.h ├── unittest1.cpp └── unittest2.cpp ├── ThunkExe ├── ThunkExe.vcxproj ├── ThunkExe.vcxproj.filters ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TlsTracerHeap ├── TlsAwareTracerHeap.c ├── TlsTracerHeap.c ├── TlsTracerHeap.def ├── TlsTracerHeap.h ├── TlsTracerHeap.vcxproj ├── TlsTracerHeap.vcxproj.filters ├── TlsTracerHeapGlobals.c ├── TlsTracerHeapPrivate.h ├── TlsTracerHeapProcessAttach.c ├── TlsTracerHeapProcessDetach.c ├── TlsTracerHeapSetTracerConfig.c ├── TlsTracerHeapThreadAttach.c ├── TlsTracerHeapThreadDetach.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TraceStore ├── TraceStore.c ├── TraceStore.h ├── TraceStore.vcxproj ├── TraceStore.vcxproj.filters ├── TraceStoreAddress.c ├── TraceStoreAddressRange.c ├── TraceStoreAllocation.c ├── TraceStoreAllocator.c ├── TraceStoreAtExitEx.c ├── TraceStoreBind.c ├── TraceStoreCallbacks.c ├── TraceStoreConstants.c ├── TraceStoreConstants.h ├── TraceStoreContext.c ├── TraceStoreDebugEngine.c ├── TraceStoreIndex.h ├── TraceStoreIntervals.c ├── TraceStoreLoader.c ├── TraceStoreMemoryMap.c ├── TraceStoreMetadata.c ├── TraceStorePath.c ├── TraceStorePerformance.c ├── TraceStorePrivate.h ├── TraceStoreRelocation.c ├── TraceStoreSession.c ├── TraceStoreSqlite3ExtInit.c ├── TraceStoreSqlite3Functions.c ├── TraceStoreSqlite3IntervalModule.c ├── TraceStoreSqlite3Module.c ├── TraceStoreSqlite3Schemas.c ├── TraceStoreSqlite3Schemas.h ├── TraceStoreSqlite3Tls.c ├── TraceStoreSymbols.c ├── TraceStoreTime.c ├── TraceStoreTimer.c ├── TraceStoreTraits.c ├── TraceStoreTypes.c ├── TraceStoreWorkingSet.c ├── TraceStores.c ├── TraceStoresGlobalRundown.c ├── TraceStoresRundown.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TraceStoreSqlite3Ext ├── Sqlite3Allocator.c ├── TraceStoreSqlite3Ext.def ├── TraceStoreSqlite3Ext.h ├── TraceStoreSqlite3Ext.vcxproj ├── TraceStoreSqlite3Ext.vcxproj.filters ├── TraceStoreSqlite3ExtInit.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TracedPythonExe ├── TracedPythonExe.c ├── TracedPythonExe.def ├── TracedPythonExe.h ├── TracedPythonExe.vcxproj ├── TracedPythonExe.vcxproj.filters ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TracedPythonSession ├── DestroyTracedPythonSession.c ├── InitializeTracedPythonSession.c ├── InitializeTracedPythonSessionFromPythonDllModule.c ├── InjectedTracedPythonSessionRemoteThreadEntry.c ├── SanitizePathEnvironmentVariableForPython.c ├── TracedPythonSession.h ├── TracedPythonSession.vcxproj ├── TracedPythonSession.vcxproj.filters ├── TracedPythonSessionPrivate.h ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TracedPythonSessionLib ├── TracedPythonSessionLib.vcxproj └── TracedPythonSessionLib.vcxproj.filters ├── Tracer.props ├── Tracer.sln ├── TracerBase.props ├── TracerConfig ├── CreateTraceSessionDirectory.c ├── DestroyTracerConfig.c ├── GlobalTracerConfig.c ├── HeapAllocator.c ├── InitializeTracerConfig.c ├── RtlString.c ├── RtlString.h ├── TracerBootstrap.h ├── TracerConfig.def ├── TracerConfig.h ├── TracerConfig.vcxproj ├── TracerConfig.vcxproj.filters ├── TracerConfigConstants.c ├── TracerConfigConstants.h ├── TracerConfigDebug.def ├── TracerConfigPrivate.c ├── TracerConfigPrivate.h ├── TracerConfigRegistry.h ├── TracerPath.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TracerConfigLib ├── TracerConfigLib.vcxproj └── TracerConfigLib.vcxproj.filters ├── TracerControlDriver ├── .gitignore ├── DriverUtil.asm ├── DriverUtil.h ├── SDV-default.xml ├── TracerControlConstants.h ├── TracerControlDebug.h ├── TracerControlDriver.c ├── TracerControlDriver.h ├── TracerControlDriver.inf ├── TracerControlDriver.vcxproj ├── TracerControlDriver.vcxproj.filters ├── TracerControlDriverIoctl.h ├── runsdvui.cmd ├── sdv-map.h ├── sdv-user.sdv ├── stdafx.c └── stdafx.h ├── TracerCore ├── TracerCore.c ├── TracerCore.h ├── TracerCore.vcxproj ├── TracerCore.vcxproj.filters ├── TracerCorePrivate.h ├── TracerExeMain.c ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TracerCoreLib ├── TracerCoreLib.vcxproj └── TracerCoreLib.vcxproj.filters ├── TracerExe ├── TracerExe.vcxproj ├── TracerExe.vcxproj.filters ├── main.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TracerFull.sln ├── TracerHeap ├── DefaultTracerHeap.c ├── DefaultTracerHeapPrivate.h ├── TracerHeap.h ├── TracerHeap.vcxproj ├── TracerHeap.vcxproj.filters ├── dllmain.c ├── stdafx.c ├── stdafx.h └── targetver.h ├── TracerHeapLib ├── TracerHeapLib.vcxproj └── TracerHeapLib.vcxproj.filters ├── TypeInfoDump.exe ├── Wdk.props ├── appveyor.yml ├── build-ptx.bat ├── cdb-commands.txt ├── cdb-output.txt ├── cdb-simple-commands.txt ├── cdb-simple.bat ├── ctags.exe ├── ctags.pdb ├── dbg-dump-type.bat ├── debug-build-x64.bat ├── make-cdb-commands.sh ├── mknewlib.sh ├── mknewproj.sh ├── pgienv.bat ├── release-build-x64.bat ├── run-cdb.bat ├── st2-test-debug.bat ├── st2-test-release.bat ├── st2b-pginstrument.bat ├── st2b-pgoptimize.bat ├── st2b-release.bat ├── t.bat ├── t.py ├── td.bat ├── td.py ├── update-pgd.bat ├── v140-to-v120.sh ├── v140-to-v141.sh └── v141-to-v140.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior (used when a rule below doesn't match) 2 | * text=auto 3 | 4 | # Some Windows-specific files should always be CRLF 5 | *.bat eol=crlf 6 | *.sln* eol=crlf 7 | *.vcxproj* eol=crlf 8 | *.pyproj* eol=crlf 9 | *.dgml eol=crlf 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.sdf 2 | *.opensdf 3 | .vs 4 | x64 5 | ipch 6 | Debug 7 | Release 8 | *.opendb 9 | tags 10 | *.pyc 11 | Tracer.VC.db 12 | build.err 13 | build.log 14 | msbuild.log 15 | sdv 16 | sdv.temp 17 | *.vcxproj.user 18 | .ipynb_checkpoints 19 | TestResults 20 | *.pgd 21 | .idea 22 | .cache 23 | *.dgml 24 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Pdb"] 2 | path = Pdb 3 | url = https://github.com/Microsoft/microsoft-pdb 4 | -------------------------------------------------------------------------------- /Asm/Asm.def: -------------------------------------------------------------------------------- 1 | LIBRARY Asm 2 | EXPORTS 3 | CopyPagesNonTemporalAvx2_v1 @1 4 | CopyPagesNonTemporalAvx2_v2 @2 5 | CopyPagesNonTemporalAvx2_v3 @3 6 | CopyPagesNonTemporalAvx2_v4 @4 7 | CopyPagesNonTemporal=CopyPagesNonTemporalAvx2_v4 @5 8 | FillPagesNonTemporalAvx2_v1 @6 9 | FillPagesNonTemporal=FillPagesNonTemporalAvx2_v1 @7 10 | InjectionThunk=InjectionThunk @8 -------------------------------------------------------------------------------- /Asm/Asm.inc: -------------------------------------------------------------------------------- 1 | ;++ 2 | ; 3 | ; Copyright (c) 2017 Trent Nelson 4 | ; 5 | ; Module Name: 6 | ; 7 | ; Asm.inc 8 | ; 9 | ; Abstract: 10 | ; 11 | ; This is the main include file for all assembly language modules. It 12 | ; contains includes, constant definitions and macros that are used in 13 | ; subroutines. 14 | ; 15 | ;-- 16 | 17 | ; 18 | ; Include the main Windows DDK MASM header. 19 | ; 20 | 21 | include ksamd64.inc 22 | 23 | ; 24 | ; Define macros for inserting start and end markers that can be detected by 25 | ; Intel's code analysis tool IACA. 26 | ; 27 | 28 | IACA_VC_START macro Name 29 | 30 | mov byte ptr gs:[06fh], 06fh 31 | 32 | endm 33 | 34 | IACA_VC_END macro Name 35 | 36 | mov byte ptr gs:[0deh], 0deh 37 | 38 | endm 39 | 40 | ; vim:set tw=80 ts=8 sw=4 sts=4 et syntax=masm fo=croql comments=:; : 41 | 42 | -------------------------------------------------------------------------------- /Asm/AsmPrivate.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | AsmPrivate.h 8 | 9 | Abstract: 10 | 11 | This is the private header file for the Asm component. It defines function 12 | typedefs and function declarations for all major (i.e. not local to the 13 | module) functions available for use by individual modules within this 14 | component. 15 | 16 | --*/ 17 | 18 | #ifndef _ASM_INTERNAL_BUILD 19 | #error AsmPrivate.h being included but _ASM_INTERNAL_BUILD not set. 20 | #endif 21 | 22 | #pragma once 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "stdafx.h" 29 | 30 | #ifdef __cplusplus 31 | } // extern "C" 32 | #endif 33 | 34 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 35 | -------------------------------------------------------------------------------- /Asm/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the Rtl DLL. It is responsible for 12 | hooking into the DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH messages in 13 | order to facilitate atexit() rundown functionality. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | BOOL 20 | APIENTRY 21 | _DllMainCRTStartup( 22 | _In_ HMODULE Module, 23 | _In_ DWORD Reason, 24 | _In_ LPVOID Reserved 25 | ) 26 | { 27 | return TRUE; 28 | } 29 | 30 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 31 | -------------------------------------------------------------------------------- /Asm/stdafx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.c 8 | 9 | Abstract: 10 | 11 | This is the precompiled source file for the Rtl component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /Asm/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the Rtl component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include 21 | #include "Asm.h" 22 | 23 | #ifdef _ASM_INTERNAL_BUILD 24 | #include "AsmPrivate.h" 25 | #endif 26 | 27 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 28 | -------------------------------------------------------------------------------- /Asm/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /AsmLib/AsmLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {5E52BE2C-7EE5-41A7-BCE5-617D109F3358} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {71822B06-9498-414D-9757-6AEE2A72D878} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {A436F165-0CE2-4890-9503-05083C3164F8} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | 37 | 38 | Source Files 39 | 40 | 41 | Source Files 42 | 43 | 44 | -------------------------------------------------------------------------------- /BenchmarkExe/Benchmark.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/BenchmarkExe/Benchmark.asm -------------------------------------------------------------------------------- /BenchmarkExe/BenchmarkExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {466163B9-E1EB-4C53-AE85-5B75AEEA44F2} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {946BC200-CFEE-4D56-AEA6-8E42DEA05651} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {5859055B-AA91-4667-89FC-26374708B8BA} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Source Files 42 | 43 | 44 | -------------------------------------------------------------------------------- /BenchmarkExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /BenchmarkExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the BenchmarkExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/__C_specific_handler.h" 22 | 23 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 24 | -------------------------------------------------------------------------------- /BenchmarkExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Crt.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Cu/Cu.cuh: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | Cu.cuh 8 | 9 | Abstract: 10 | 11 | This module is the main header file for the Cu component. 12 | 13 | --*/ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | // 20 | // Define NT-style typedefs. 21 | // 22 | 23 | typedef char CHAR; 24 | typedef short SHORT; 25 | typedef long LONG; 26 | typedef wchar_t WCHAR; // wc, 16-bit UNICODE character 27 | 28 | typedef WCHAR *PWCHAR, *LPWCH, *PWCH; 29 | 30 | typedef CHAR *PCHAR, *LPCH, *PCH; 31 | 32 | typedef float FLOAT; 33 | typedef double DOUBLE; 34 | typedef FLOAT *PFLOAT; 35 | typedef DOUBLE *PDOUBLE; 36 | 37 | typedef unsigned char UCHAR; 38 | typedef unsigned short USHORT; 39 | typedef unsigned long ULONG; 40 | 41 | typedef UCHAR *PUCHAR; 42 | typedef USHORT *PUSHORT; 43 | typedef ULONG *PULONG; 44 | 45 | typedef CHAR *PCHAR; 46 | typedef SHORT *PSHORT; 47 | typedef LONG *PLONG; 48 | 49 | typedef long long LONGLONG; 50 | typedef long long LONG64; 51 | typedef unsigned long long ULONGLONG; 52 | typedef unsigned long long ULONG64; 53 | 54 | typedef LONG64 *PLONG64; 55 | typedef ULONG64 *PULONG64; 56 | 57 | #define VOID void 58 | 59 | // 60 | // Define CUDA macros and typedefs in NT style. 61 | // 62 | 63 | #define HOST __host__ 64 | #define GLOBAL __global__ 65 | #define DEVICE __device__ 66 | #define GridDim gridDim 67 | #define BlockDim blockDim 68 | #define BlockIndex blockIdx 69 | #define ThreadIndex threadIdx 70 | 71 | 72 | #define FOR_EACH_1D(Index, Total) \ 73 | for (Index = BlockIndex.x * BlockDim.x + ThreadIndex.x; \ 74 | Index < Total; \ 75 | Index += BlockDim.x * GridDim.x) 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab syntax=cuda : 82 | -------------------------------------------------------------------------------- /Cu/TraceStoreKernels.cu: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TraceStoreKernels.cu 8 | 9 | Abstract: 10 | 11 | This module implements CUDA kernels for various trace store functions. 12 | 13 | --*/ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #include "Cu.cuh" 20 | #include 21 | 22 | GLOBAL 23 | VOID 24 | SinglePrecisionAlphaXPlusY( 25 | _In_ LONG Total, 26 | _In_ FLOAT Alpha, 27 | _In_ PFLOAT X, 28 | _Out_ PFLOAT Y 29 | ) 30 | { 31 | LONG Index; 32 | 33 | FOR_EACH_1D(Index, Total) { 34 | Y[Index] = Alpha * X[Index] + Y[Index]; 35 | } 36 | } 37 | 38 | GLOBAL 39 | VOID 40 | DeltaTimestamp( 41 | _In_ ULONG64 Total, 42 | _In_ PULONG64 Timestamp, 43 | _Out_ PULONG64 Delta 44 | ) 45 | { 46 | ULONG64 Index; 47 | 48 | if (ThreadIndex.x % 32 == 0) { 49 | return; 50 | } 51 | 52 | FOR_EACH_1D(Index, Total) { 53 | Delta[Index] = Timestamp[Index] - Timestamp[Index-1]; 54 | } 55 | } 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 62 | -------------------------------------------------------------------------------- /DebugEngine/DebugEngineConstants.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | DebugEngineConstants.c 8 | 9 | Abstract: 10 | 11 | This module defines constants used by the DebugEngine component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "stdafx.h" 22 | 23 | #pragma component(browser, off) 24 | extern CONST DEBUGEVENTCALLBACKS DebugEventCallbacks; 25 | extern CONST DEBUGINPUTCALLBACKS DebugInputCallbacks; 26 | extern CONST DEBUGOUTPUTCALLBACKS DebugOutputCallbacks; 27 | extern CONST DEBUGOUTPUTCALLBACKS2 DebugOutputCallbacks2; 28 | 29 | DEBUG_ENGINE_DATA CONST CHAR StringTableDelimiter; 30 | DEBUG_ENGINE_DATA CONST STRING ExamineSymbolsPrefixes; 31 | DEBUG_ENGINE_DATA CONST STRING ExamineSymbolsBasicTypes1; 32 | DEBUG_ENGINE_DATA CONST STRING ExamineSymbolsBasicTypes2; 33 | DEBUG_ENGINE_DATA CONST STRING FunctionArgumentTypes1; 34 | DEBUG_ENGINE_DATA CONST STRING FunctionArgumentTypes2; 35 | DEBUG_ENGINE_DATA CONST STRING FunctionArgumentVectorTypes1; 36 | DEBUG_ENGINE_DATA CONST STRING DisplayTypes1; 37 | DEBUG_ENGINE_DATA CONST STRING DisplayTypes2; 38 | 39 | DEBUG_ENGINE_DATA CONST STRING CommandLineOptions; 40 | DEBUG_ENGINE_DATA CONST USHORT NumberOfCommandLineMatchIndexOptions; 41 | DEBUG_ENGINE_DATA CONST SHORT CommandLineMatchIndexToOption[]; 42 | 43 | DEBUG_ENGINE_DATA CONST STRING DisplayTypeCustomStructureName; 44 | DEBUG_ENGINE_DATA CONST STRING ExamineSymbolsCustomStructureName; 45 | DEBUG_ENGINE_DATA CONST STRING UnassembleFunctionCustomStructureName; 46 | #pragma component(browser, on) 47 | 48 | #ifdef __cplusplus 49 | }; // extern "C" 50 | #endif 51 | 52 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 53 | -------------------------------------------------------------------------------- /DebugEngine/DestroyDebugEngine.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | DestroyDebugEngine.c 8 | 9 | Abstract: 10 | 11 | This module implements the DestroyDebugEngine() routine. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | _Use_decl_annotations_ 18 | VOID 19 | DestroyDebugEngine( 20 | PPDEBUG_ENGINE EnginePointer, 21 | PBOOL IsProcessTerminating 22 | ) 23 | /*++ 24 | 25 | Routine Description: 26 | 27 | This routine destroys a previously created DEBUG_ENGINE structure. It is 28 | responsible for releasing internal COM interfaces. 29 | 30 | Arguments: 31 | 32 | EnginePointer - Supplies the address of a variable that contains the 33 | address of the DEBUG_ENGINE structure to destroy. This pointer 34 | will be cleared by this routine. 35 | 36 | IsProcessTerminating - Optionally supplies a pointer to a boolean variable 37 | that indicates whether or not the process is terminating. 38 | 39 | Return Value: 40 | 41 | None. 42 | 43 | --*/ 44 | { 45 | PDEBUG_ENGINE Engine; 46 | 47 | // 48 | // Validate arguments. 49 | // 50 | 51 | if (!ARGUMENT_PRESENT(EnginePointer)) { 52 | return; 53 | } 54 | 55 | // 56 | // Initialize the local engine alias then clean the caller's pointer. 57 | // 58 | 59 | Engine = *EnginePointer; 60 | *EnginePointer = NULL; 61 | 62 | // 63 | // Release any interfaces we've created. 64 | // 65 | 66 | #define RELEASE_INTERFACE(Name) \ 67 | if (Engine->I##Name) { \ 68 | Engine->##Name->Release(Engine->I##Name); \ 69 | Engine->I##Name = NULL; \ 70 | } 71 | 72 | RELEASE_INTERFACE(DataSpaces); 73 | RELEASE_INTERFACE(Advanced); 74 | RELEASE_INTERFACE(Symbols); 75 | RELEASE_INTERFACE(Control); 76 | RELEASE_INTERFACE(Client); 77 | 78 | return; 79 | } 80 | 81 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 82 | -------------------------------------------------------------------------------- /DebugEngine/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /DebugEngine/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /DebugEngine/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the DebugEngine component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "targetver.h" 22 | 23 | #include 24 | #include "../Rtl/Rtl.h" 25 | #include "../StringTable.h" 26 | 27 | // 28 | // Disable source browsing for DbgEng.h to avoid this: 29 | // 30 | // dbgeng.h(18410): warning BK4504: file contains too many references; 31 | // ignoring further references from this source 32 | // 33 | 34 | #pragma component(browser, off) 35 | #include 36 | #pragma component(browser, on) 37 | 38 | #include "DebugEngineInterfaces.h" 39 | #include "DebugEngine.h" 40 | 41 | #ifdef _DEBUG_ENGINE_INTERNAL_BUILD 42 | 43 | #include "../Rtl/__C_specific_handler.h" 44 | #include "../TracerConfig/TracerConfig.h" 45 | #include "DebugEnginePrivate.h" 46 | #include "DebugEngineConstants.h" 47 | #include "DebugEngineCommands.h" 48 | 49 | #endif // _DEBUG_ENGINE_INTERNAL_BUILD 50 | 51 | #ifdef __cplusplus 52 | } // extern "C" 53 | #endif 54 | 55 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 56 | -------------------------------------------------------------------------------- /DebugEngine/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Dia2Dump.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/Dia2Dump.exe -------------------------------------------------------------------------------- /InjectionThunk/InjectionThunk.def: -------------------------------------------------------------------------------- 1 | LIBRARY InjectionThunk 2 | EXPORTS 3 | InjectionThunk -------------------------------------------------------------------------------- /InjectionThunk/InjectionThunk.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | InjectionThunk.h 8 | 9 | Abstract: 10 | 11 | This is the main header file for the InjectionThunk component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define INJECTION_THUNK_CALL_CONV __stdcall 22 | 23 | #ifdef _INJECTION_THUNK_INTERNAL_BUILD 24 | 25 | // 26 | // This is an internal build of the InjectionThunk component. 27 | // 28 | 29 | #define INJECTION_THUNK_API __declspec(dllexport) 30 | #define INJECTION_THUNK_DATA extern __declspec(dllexport) 31 | 32 | #include "stdafx.h" 33 | 34 | #elif _INJECTION_THUNK_NO_API_EXPORT_IMPORT 35 | 36 | // 37 | // We're being included by someone who doesn't want dllexport or dllimport. 38 | // This is useful for creating new .exe-based projects for things like unit 39 | // testing or performance testing/profiling. 40 | // 41 | 42 | #define INJECTION_THUNK_API 43 | #define INJECTION_THUNK_DATA extern 44 | 45 | #else 46 | 47 | // 48 | // We're being included by an external component. 49 | // 50 | 51 | #define INJECTION_THUNK_API __declspec(dllimport) 52 | #define INJECTION_THUNK_DATA extern __declspec(dllimport) 53 | 54 | #include "../Rtl/Rtl.h" 55 | 56 | #endif 57 | 58 | #ifdef __cplusplus 59 | } // extern "C" 60 | #endif 61 | 62 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab nowrap : 63 | -------------------------------------------------------------------------------- /InjectionThunk/InjectionThunk.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {9AD9E948-4780-4D00-A80C-55E69F460A9C} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {7BAACB72-BBFA-4036-A37D-687FD451287B} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {2BB499E9-4FB6-4CC3-AE72-E0FB5F3CCACC} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Source Files 42 | 43 | 44 | 45 | 46 | Source Files 47 | 48 | 49 | -------------------------------------------------------------------------------- /InjectionThunk/InjectionThunkPrivate.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | InjectionThunkPrivate.h 8 | 9 | Abstract: 10 | 11 | This is the private header file for the InjectionThunk component. It 12 | defines function typedefs and function declarations for all major (i.e. 13 | not local to the module) functions available for use by individual modules 14 | within this component. 15 | 16 | --*/ 17 | 18 | #ifndef _INJECTION_THUNK_INTERNAL_BUILD 19 | #error InjectionThunkPrivate.h being included but _INJECTION_THUNK_INTERNAL_BUILD not set. 20 | #endif 21 | 22 | #pragma once 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "stdafx.h" 29 | 30 | // 31 | // Private function declarations. 32 | // 33 | 34 | #pragma component(browser, off) 35 | #pragma component(browser, on) 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif 40 | 41 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 42 | -------------------------------------------------------------------------------- /InjectionThunk/_InjectionThunk.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | InjectionThunk.c 8 | 9 | Abstract: 10 | 11 | This module provides routines for the InjectionThunk component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | #define LOAD_LIBRARY_INJECTION_THUNK_FAILED ((ULONG)-1) 18 | #define GET_PROC_ADDRESS_FUNCTION_NAME_FAILED ((ULONG)-2) 19 | #define ERROR_THREAD_ENTRY_RETURNED ((ULONG)-3) 20 | 21 | /* 22 | DECLSPEC_NORETURN 23 | VOID 24 | _InjectionThunk( 25 | PRTL_INJECTION_THUNK_CONTEXT Thunk 26 | ) 27 | { 28 | HMODULE ModuleHandle; 29 | PRTLP_INJECTION_REMOTE_THREAD_ENTRY ThreadEntry; 30 | 31 | Thunk->ReturnAddressInThunk = _ReturnAddress(); 32 | Thunk->AddressOfReturnAddress = _AddressOfReturnAddress(); 33 | 34 | // 35 | // Load the InjectionThunk.dll module. 36 | // 37 | 38 | ModuleHandle = Thunk->LoadLibraryW(Thunk->InjectionThunkDllPath); 39 | if (!ModuleHandle) { 40 | Thunk->ExitThread(LOAD_LIBRARY_INJECTION_THUNK_FAILED); 41 | } 42 | 43 | // 44 | // Resolve the injection entry point. 45 | // 46 | 47 | ThreadEntry = (PRTLP_INJECTION_REMOTE_THREAD_ENTRY)( 48 | GetProcAddress( 49 | ModuleHandle, 50 | Thunk->InjectionThunkName 51 | ) 52 | ); 53 | 54 | if (!ThreadEntry) { 55 | Thunk->ExitThread(GET_PROC_ADDRESS_FUNCTION_NAME_FAILED); 56 | } 57 | 58 | ThreadEntry((PRTL_INJECTION_CONTEXT)Thunk); 59 | 60 | // 61 | // If things are operating correctly, this should never get hit. 62 | // 63 | 64 | __debugbreak(); 65 | 66 | Thunk->ExitThread(ERROR_THREAD_ENTRY_RETURNED); 67 | } 68 | */ 69 | 70 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 71 | -------------------------------------------------------------------------------- /InjectionThunk/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the InjectionThunk DLL. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | BOOL 18 | APIENTRY 19 | _DllMainCRTStartup( 20 | _In_ HMODULE Module, 21 | _In_ DWORD Reason, 22 | _In_ LPVOID Reserved 23 | ) 24 | { 25 | UNREFERENCED_PARAMETER(Module); 26 | 27 | switch (Reason) { 28 | case DLL_PROCESS_ATTACH: 29 | break; 30 | case DLL_THREAD_ATTACH: 31 | break; 32 | case DLL_THREAD_DETACH: 33 | break; 34 | case DLL_PROCESS_DETACH: 35 | break; 36 | } 37 | 38 | return TRUE; 39 | } 40 | 41 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 42 | -------------------------------------------------------------------------------- /InjectionThunk/stdafx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.c 8 | 9 | Abstract: 10 | 11 | This is the precompiled source file for the InjectionThunk component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /InjectionThunk/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the InjectionThunk component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "..\Rtl\Rtl.h" 22 | #include "InjectionThunk.h" 23 | 24 | #ifdef _INJECTION_THUNK_INTERNAL_BUILD 25 | #include "InjectionThunkPrivate.h" 26 | #endif 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | #endif 31 | 32 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 33 | -------------------------------------------------------------------------------- /InjectionThunk/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ModuleLoaderExe/ModuleLoaderExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {AB3707CE-FC84-4F71-AE08-CD0D62850648} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {2B34BB95-0D79-4DF4-889B-A02E5CBC8000} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {568315A1-4F7E-420B-A3BB-0AB45C2BC800} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /ModuleLoaderExe/main.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | main.c 8 | 9 | Abstract: 10 | 11 | This module is the main entry point for the tracer executable. 12 | It implements mainCRTStartup(), which simply calls LoadModulesExeMain(). 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | LONG ModuleLoaderExeMain(VOID); 19 | 20 | DECLSPEC_NORETURN 21 | VOID 22 | WINAPI 23 | mainCRTStartup() 24 | { 25 | ExitProcess(ModuleLoaderExeMain()); 26 | } 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /ModuleLoaderExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /ModuleLoaderExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the ModuleLoaderExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/__C_specific_handler.h" 22 | #include "../TracerHeap/TracerHeap.h" 23 | #include "../TracerConfig/TracerConfig.h" 24 | #include "../TracerConfig/TracerConfigPrivate.h" 25 | 26 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 27 | -------------------------------------------------------------------------------- /ModuleLoaderExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /NT.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | x64 5 | Release 6 | 7 | -------------------------------------------------------------------------------- /PGO-README.md: -------------------------------------------------------------------------------- 1 | Steps for generating a profile-guided optimization (PGO) build: 2 | 3 | 1. Select PGInstrument build config and rebuild solution. 4 | 2. Run the training program (e.g. x64\PGInstrument\StringTable2BenchmarkExe.exe) 5 | 3. Run update-pgd.bat. 6 | 4. Select PGOptimize build config and *build* solution. Don't select 7 | rebuild, as it deletes all the .pgd files generated by the PGInstrument 8 | phase and generally breaks everything. 9 | 10 | -------------------------------------------------------------------------------- /PerfectHashTable/PerfectHashTable.def: -------------------------------------------------------------------------------- 1 | LIBRARY PerfectHashTable 2 | EXPORTS 3 | SetCSpecificHandler 4 | LoadPerfectHashTableKeys 5 | DestroyPerfectHashTableKeys 6 | CreatePerfectHashTableContext 7 | DestroyPerfectHashTableContext 8 | CreatePerfectHashTable 9 | LoadPerfectHashTable 10 | TestPerfectHashTable 11 | GetPerfectHashTableAlgorithmName 12 | GetPerfectHashTableHashFunctionName 13 | GetPerfectHashTableMaskFunctionName 14 | InitializePerfectHashTableAllocator 15 | InitializePerfectHashTableAllocatorFromRtlBootstrap 16 | SelfTestPerfectHashTable 17 | PerfectHashTableBenchmarkSingleMain 18 | PerfectHashTableBenchmarkAllMain 19 | -------------------------------------------------------------------------------- /PerfectHashTable/PerfectHashTableAllocator.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PerfectHashTableAllocator.c 8 | 9 | Abstract: 10 | 11 | This module implements the perfect hash allocator initialization routines. 12 | We currently use the Rtl component's heap-backed allocator, although this 13 | can be changed easily at a later date. 14 | 15 | N.B. Two allocators are provided, one bootstrap allocator and one normal 16 | one, as this allows a downstream component to obtain an allocator 17 | prior to initializing the RTL structure. This is useful in unit tests. 18 | 19 | --*/ 20 | 21 | #include "stdafx.h" 22 | 23 | _Use_decl_annotations_ 24 | BOOL 25 | InitializePerfectHashTableAllocatorFromRtlBootstrap( 26 | PRTL_BOOTSTRAP RtlBootstrap, 27 | PALLOCATOR Allocator 28 | ) 29 | { 30 | return RtlBootstrap->InitializeHeapAllocator(Allocator); 31 | } 32 | 33 | _Use_decl_annotations_ 34 | BOOL 35 | InitializePerfectHashTableAllocator( 36 | PRTL Rtl, 37 | PALLOCATOR Allocator 38 | ) 39 | { 40 | return Rtl->InitializeHeapAllocator(Allocator); 41 | } 42 | 43 | 44 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 45 | -------------------------------------------------------------------------------- /PerfectHashTable/PerfectHashTablePrime.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PerfectHashTablePrime.h 8 | 9 | Abstract: 10 | 11 | This is the header file for the prime number module of the PerfectHashTable 12 | component. It declares structures and functions related to the handling of 13 | prime numbers. 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | // 20 | // Declare array of prime numbers. 21 | // 22 | 23 | const ULONGLONG Primes[]; 24 | const USHORT NumberOfPrimes; 25 | 26 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 27 | -------------------------------------------------------------------------------- /PerfectHashTable/PerfectHashTableRefCount.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PerfectHashTableRefCount.c 8 | 9 | Abstract: 10 | 11 | This module implements the AddRef and Release routines for the 12 | PerfectHashTable component. 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | _Use_decl_annotations_ 19 | ULONG 20 | PerfectHashTableAddRef( 21 | PPERFECT_HASH_TABLE Table 22 | ) 23 | /*++ 24 | 25 | Routine Description: 26 | 27 | Increments the reference count for a perfect hash table. 28 | 29 | Arguments: 30 | 31 | Table - Supplies a pointer to the table for which the reference count 32 | is to be incremented. 33 | 34 | Return Value: 35 | 36 | The new reference count. 37 | 38 | --*/ 39 | { 40 | return InterlockedIncrement(&Table->ReferenceCount); 41 | } 42 | 43 | _Use_decl_annotations_ 44 | ULONG 45 | PerfectHashTableRelease( 46 | PPERFECT_HASH_TABLE Table 47 | ) 48 | /*++ 49 | 50 | Routine Description: 51 | 52 | Decrements the reference count associated with a perfect hash table. If 53 | this is the last reference, the table is destroyed. 54 | 55 | Arguments: 56 | 57 | Table - Supplies a pointer to the table for which the reference count 58 | is to be decremented. 59 | 60 | Return Value: 61 | 62 | The new reference count. 63 | 64 | --*/ 65 | { 66 | ULONG Count = InterlockedDecrement(&Table->ReferenceCount); 67 | PPERFECT_HASH_TABLE TablePointer = Table; 68 | 69 | if (Count > 0) { 70 | return Count; 71 | } 72 | 73 | DestroyPerfectHashTable(&TablePointer, NULL); 74 | 75 | return Count; 76 | } 77 | 78 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 79 | -------------------------------------------------------------------------------- /PerfectHashTable/data/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | *.keys 3 | *.pht1 4 | *.png 5 | -------------------------------------------------------------------------------- /PerfectHashTable/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the PerfectHashTable component. It 12 | hooks into process and thread attach and detach messages in order to provide 13 | TLS glue (see PerfectHashTableTls.c for more information). 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | BOOL 20 | APIENTRY 21 | _DllMainCRTStartup( 22 | _In_ HMODULE Module, 23 | _In_ DWORD Reason, 24 | _In_ LPVOID Reserved 25 | ) 26 | { 27 | BOOL IsProcessTerminating = FALSE; 28 | switch (Reason) { 29 | case DLL_PROCESS_ATTACH: 30 | if (!PerfectHashTableTlsProcessAttach(Module, Reason, Reserved)) { 31 | return FALSE; 32 | } 33 | break; 34 | case DLL_THREAD_ATTACH: 35 | break; 36 | case DLL_THREAD_DETACH: 37 | break; 38 | case DLL_PROCESS_DETACH: 39 | if (!PerfectHashTableTlsProcessDetach(Module, Reason, Reserved)) { 40 | NOTHING; 41 | } 42 | break; 43 | } 44 | 45 | return TRUE; 46 | } 47 | 48 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 49 | -------------------------------------------------------------------------------- /PerfectHashTable/stdafx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.c 8 | 9 | Abstract: 10 | 11 | This is the precompiled source file for the PerfectHash component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /PerfectHashTable/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the PerfectHashTable component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | // 20 | // appears to need _PREFAST_ defined. 21 | // 22 | 23 | #ifndef _PREFAST_ 24 | #define _PREFAST_ 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include "../Rtl/Rtl.h" 33 | #include "../Rtl/__C_specific_handler.h" 34 | #include "../Rtl/atexit.h" 35 | #include "PerfectHashTable.h" 36 | 37 | #ifdef _PERFECT_HASH_TABLE_INTERNAL_BUILD 38 | #include "PerfectHashTablePrime.h" 39 | #include "PerfectHashTablePrivate.h" 40 | #include "PerfectHashTableConstants.h" 41 | #endif 42 | 43 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 44 | -------------------------------------------------------------------------------- /PerfectHashTable/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PerfectHashTableBenchmarkSingleExe/PerfectHashTableBenchmarkSingleExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {641F4330-2C34-4301-B84A-4CE5A06CC0F7} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {08A214F7-4B19-4B49-CC34-717FD950DC55} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {E38ED500-814E-469A-D9AC-5AD3267CEB29} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /PerfectHashTableBenchmarkSingleExe/main.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | main.c 8 | 9 | Abstract: 10 | 11 | This is the main file for the PerfectHashTableBenchmarkSingle executable. 12 | It implements mainCRTStartup(), which simply calls the 13 | PerfectHashTableBenchmarkSingleMain() routine. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | typedef 20 | ULONG 21 | (BENCHMARK_MAIN)( 22 | VOID 23 | ); 24 | typedef BENCHMARK_MAIN *PBENCHMARK_MAIN; 25 | 26 | DECLSPEC_NORETURN 27 | VOID 28 | WINAPI 29 | mainCRTStartup() 30 | { 31 | ULONG ExitCode; 32 | HMODULE Module; 33 | PROC Proc; 34 | PBENCHMARK_MAIN Main; 35 | 36 | 37 | Module = LoadLibraryA("PerfectHashTable.dll"); 38 | Proc = GetProcAddress(Module, "PerfectHashTableBenchmarkSingleMain"); 39 | if (!Proc) { 40 | __debugbreak(); 41 | ExitCode = 1; 42 | } else { 43 | Main = (PBENCHMARK_MAIN)Proc; 44 | ExitCode = Main(); 45 | } 46 | 47 | ExitProcess(ExitCode); 48 | } 49 | 50 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 51 | -------------------------------------------------------------------------------- /PerfectHashTableBenchmarkSingleExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /PerfectHashTableBenchmarkSingleExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the PerfectHashTable's single 12 | benchmark runner executable. 13 | 14 | --*/ 15 | 16 | #pragma once 17 | 18 | #include "targetver.h" 19 | 20 | #include 21 | #include "../Rtl/Rtl.h" 22 | #include "../Rtl/__C_specific_handler.h" 23 | #include "../PerfectHashTable/PerfectHashTable.h" 24 | 25 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 26 | -------------------------------------------------------------------------------- /PerfectHashTableBenchmarkSingleExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PerfectHashTableSelfTestExe/PerfectHashTableSelfTestExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {641F4330-2C34-4301-A84A-4CE5A06CC0F7} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {08A214F7-4B19-4B49-8C34-717FD950DC55} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {E38ED500-814E-469A-A9AC-5AD3267CEB29} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /PerfectHashTableSelfTestExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /PerfectHashTableSelfTestExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the PerfectHashTable's 12 | self-test component. 13 | 14 | --*/ 15 | 16 | #pragma once 17 | 18 | #include "targetver.h" 19 | 20 | #include 21 | #include "../Rtl/Rtl.h" 22 | #include "../Rtl/__C_specific_handler.h" 23 | #include "../PerfectHashTable/PerfectHashTable.h" 24 | 25 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 26 | -------------------------------------------------------------------------------- /PerfectHashTableSelfTestExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Python/Python.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Python/PythonImage.c: -------------------------------------------------------------------------------- 1 | #include "PythonImage.h" 2 | -------------------------------------------------------------------------------- /Python/PythonImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /Python/PythonTypes.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PythonTypes.c 8 | 9 | Abstract: 10 | 11 | Define trace store types. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // 18 | // Define the trace store types owned by this module. 19 | // 20 | 21 | // 22 | // N.B. Keep these sorted alphabetically. In vim, mark the start and end brace 23 | // with ma and mb, then issue the command: 24 | // 25 | // :'a,'b !sort -b -k 2 26 | // 27 | 28 | typedef struct _TRACE_STORE_TYPES { 29 | PPYTHON_FUNCTION PythonFunction; 30 | PPYTHON_FUNCTION_TABLE PythonFunctionTable; 31 | PPYTHON_FUNCTION_TABLE_ENTRY PythonFunctionTableEntry; 32 | PPYTHON_MODULE_TABLE PythonModuleTable; 33 | PPYTHON_MODULE_TABLE_ENTRY PythonModuleTableEntry; 34 | PPYTHON_PATH_TABLE PythonPathTable; 35 | PPYTHON_PATH_TABLE_ENTRY PythonPathTableEntry; 36 | } TRACE_STORE_TYPES; 37 | typedef TRACE_STORE_TYPES *PTRACE_STORE_TYPES; 38 | 39 | // 40 | // Type exposure functions. 41 | // 42 | 43 | DECLSPEC_DLLEXPORT 44 | VOID 45 | TraceStoreTypes( 46 | PTRACE_STORE_TYPES Types 47 | ) 48 | { 49 | UNREFERENCED_PARAMETER(Types); 50 | } 51 | 52 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 53 | -------------------------------------------------------------------------------- /Python/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /Python/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /Python/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the Python component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "Python.h" 22 | #include "PythonPrivate.h" 23 | #include "PythonDllFiles.h" 24 | 25 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 26 | -------------------------------------------------------------------------------- /Python/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PythonApp/.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | 3 | *.sln text eol=crlf 4 | -------------------------------------------------------------------------------- /PythonApp/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .ipynb_checkpoints 3 | -------------------------------------------------------------------------------- /PythonApp/bin/tracer.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | %ANACONDA2%\python.exe %~dp0\tracer.py %* 3 | -------------------------------------------------------------------------------- /PythonApp/bin/tracer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | 6 | def join_path(*args): 7 | return os.path.abspath(os.path.normpath(os.path.join(*args))) 8 | 9 | try: 10 | from tracer.cli import main 11 | except ImportError: 12 | path = os.path.abspath(__file__) 13 | if os.path.islink(path): 14 | target = os.readlink(path) 15 | if target.endswith('tracer/bin/tracer'): 16 | libdir = target[:-len('bin/tracer')-1] 17 | sys.path.insert(0, libdir) 18 | else: 19 | libdir = join_path(path, '../lib') 20 | sys.path.insert(0, libdir) 21 | 22 | from tracer.cli import main 23 | 24 | if __name__ == '__main__': 25 | main() 26 | 27 | # vi:set ts=8 sw=4 sts=4 expandtab tw=78 syntax=python: 28 | -------------------------------------------------------------------------------- /PythonApp/bin/tracerdev.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | %ANACONDA2%\python.exe %~dp0\tracerdev.py %* 3 | -------------------------------------------------------------------------------- /PythonApp/bin/tracerdev.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | 6 | def join_path(*args): 7 | return os.path.abspath(os.path.normpath(os.path.join(*args))) 8 | 9 | try: 10 | from tracer.cli import main 11 | except ImportError: 12 | path = os.path.abspath(__file__) 13 | libdir = join_path(path, '../lib') 14 | sys.path.insert(0, libdir) 15 | 16 | from tracer.cli import main 17 | 18 | if __name__ == '__main__': 19 | main('tracerdev', 'tracerdev') 20 | 21 | # vi:set ts=8 sw=4 sts=4 expandtab tw=78 syntax=python: 22 | -------------------------------------------------------------------------------- /PythonApp/conf/tracer-win10x64-vm1.conf: -------------------------------------------------------------------------------- 1 | [main] 2 | src_dir = s:\ 3 | 4 | [tracer] 5 | tracer_dir = s:\tracer 6 | -------------------------------------------------------------------------------- /PythonApp/conf/tracer.conf: -------------------------------------------------------------------------------- 1 | [main] 2 | src_dir = $HOME/src 3 | 4 | [tracer_control_driver] 5 | device_name = \Device\TracerControlDriver 6 | win32_device_name = \\.\TracerControl\Python\Foo 7 | 8 | [sqllocaldb] 9 | versions = 11, 12, 13 10 | sqllocaldb11_exe = C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqllocaldb.exe 11 | sqllocaldb12_exe = C:\Program Files\Microsoft SQL Server\120\Tools\Binn\sqllocaldb.exe 12 | sqllocaldb13_exe = C:\Program Files\Microsoft SQL Server\130\Tools\Binn\sqllocaldb.exe 13 | 14 | [ptvs] 15 | python_exe = 16 | dir = $HOME/src/ptvs 17 | dll_path = BuildOutput/Release14.0/raw/binaries/vspyprof.dll 18 | debug_dll_path = BuildOutput/Debug14.0/raw/binaries/vspyprof.dll 19 | custom_dir = 20 | custom_dll_path = 21 | custom_debug_dll_path = 22 | 23 | [tracer] 24 | python_exe = 25 | tracer_dir = $HOME/src/tracer 26 | tracer_trace_store_dll_path = x64/Release/TraceStore.dll 27 | tracer_trace_store_debug_dll_path = x64/Debug/TraceStore.dll 28 | tracer_rtl_dll_path = x64/Release/Rtl.dll 29 | tracer_rtl_debug_dll_path = x64/Debug/Rtl.dll 30 | tracer_sqlite3_dll_path = x64/Release/Sqlite3102.dll 31 | tracer_sqlite3_debug_dll_path = x64/Debug/Sqlite3102.dll 32 | tracer_tracersqlite_dll_path = x64/Release/TracerSqlite.dll 33 | tracer_tracersqlite_debug_dll_path = x64/Debug/TracerSqlite.dll 34 | tracer_python_dll_path = x64/Release/Python.dll 35 | tracer_python_debug_dll_path = x64/Debug/Python.dll 36 | tracer_pythontracer_dll_path = x64/Release/PythonTracer.dll 37 | tracer_pythontracer_debug_dll_path = x64/Debug/PythonTracer.dll 38 | -------------------------------------------------------------------------------- /PythonApp/conf/tracerdev.conf: -------------------------------------------------------------------------------- 1 | [main] 2 | src_dir = $HOME/src 3 | 4 | [sqllocaldb] 5 | versions = 11, 12, 13 6 | sqllocaldb11_exe = C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqllocaldb.exe 7 | sqllocaldb12_exe = C:\Program Files\Microsoft SQL Server\120\Tools\Binn\sqllocaldb.exe 8 | sqllocaldb13_exe = C:\Program Files\Microsoft SQL Server\130\Tools\Binn\sqllocaldb.exe 9 | 10 | [ptvs] 11 | python_exe = 12 | dir = $HOME/src/ptvs 13 | dll_path = BuildOutput/Release14.0/raw/binaries/vspyprof.dll 14 | debug_dll_path = BuildOutput/Debug14.0/raw/binaries/vspyprof.dll 15 | custom_dir = 16 | custom_dll_path = 17 | custom_debug_dll_path = 18 | 19 | [tracer] 20 | python_exe = 21 | tracer_dir = $HOME/src/tracer 22 | tracer_dll_path = x64/Release/Tracer.dll 23 | tracer_debug_dll_path = x64/Debug/Tracer.dll 24 | tracer_rtl_dll_path = x64/Release/Rtl.dll 25 | tracer_rtl_debug_dll_path = x64/Debug/Rtl.dll 26 | tracer_sqlite3_dll_path = x64/Release/Sqlite3102.dll 27 | tracer_sqlite3_debug_dll_path = x64/Debug/Sqlite3102.dll 28 | tracer_python_dll_path = x64/Release/Python.dll 29 | tracer_python_debug_dll_path = x64/Debug/Python.dll 30 | tracer_pythontracer_dll_path = x64/Release/PythonTracer.dll 31 | tracer_pythontracer_debug_dll_path = x64/Debug/PythonTracer.dll 32 | -------------------------------------------------------------------------------- /PythonApp/lib/.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=auto 2 | -------------------------------------------------------------------------------- /PythonApp/lib/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | tpn.egg-info 3 | -------------------------------------------------------------------------------- /PythonApp/lib/tracer/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/PythonApp/lib/tracer/__init__.py -------------------------------------------------------------------------------- /PythonApp/lib/tracer/commandinvariant.py: -------------------------------------------------------------------------------- 1 | #=============================================================================== 2 | # Imports 3 | #=============================================================================== 4 | from .command import ( 5 | Command, 6 | ) 7 | 8 | from .invariant import ( 9 | InvariantAwareObject, 10 | ) 11 | 12 | #=============================================================================== 13 | # Commands 14 | #=============================================================================== 15 | 16 | class InvariantAwareCommand(InvariantAwareObject, Command): 17 | def __init__(self, *args, **kwds): 18 | long_opts = kwds.get('long_opts', {}) 19 | short_opts = kwds.get('short_opts', {}) 20 | for (s, l) in zip(('v', 'q', 'c'), ('verbose', 'quiet', 'conf')): 21 | attr = '_%s_' % l 22 | if getattr(self, attr): 23 | assert l not in long_opts, (l, long_opts) 24 | assert s not in short_opts, (s, short_opts) 25 | long_opts[l] = None 26 | short_opts[s] = None 27 | 28 | kwds['long_opts'] = long_opts 29 | kwds['short_opts'] = short_opts 30 | InvariantAwareObject.__init__(self, *args, **kwds) 31 | 32 | del kwds['long_opts'] 33 | del kwds['short_opts'] 34 | Command.__init__(self, *args, **kwds) 35 | 36 | # vim:set ts=8 sw=4 sts=4 tw=78 et: 37 | -------------------------------------------------------------------------------- /PythonApp/lib/tracer/constants.py: -------------------------------------------------------------------------------- 1 | #=============================================================================== 2 | # Imports 3 | #=============================================================================== 4 | 5 | 6 | # vim:set ts=8 sw=4 sts=4 tw=78 et: # 7 | -------------------------------------------------------------------------------- /PythonApp/lib/tracer/dbgeng/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/PythonApp/lib/tracer/dbgeng/__init__.py -------------------------------------------------------------------------------- /PythonApp/lib/tracer/dll/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | # vim:set ts=8 sw=4 sts=4 tw=80 et : 4 | -------------------------------------------------------------------------------- /PythonApp/lib/tracer/example_commands.py: -------------------------------------------------------------------------------- 1 | #=============================================================================== 2 | # Imports 3 | #=============================================================================== 4 | import os 5 | 6 | from .command import ( 7 | Command, 8 | CommandError, 9 | ) 10 | 11 | #=============================================================================== 12 | # Miscellaneous/Generic Commands 13 | #=============================================================================== 14 | class DumpConfigCommand(Command): 15 | def run(self): 16 | self.conf.write(self.ostream) 17 | 18 | class ShowConfigFileLoadOrderCommand(Command): 19 | def run(self): 20 | if not self.conf.files: 21 | raise CommandError('no configuration files are being loaded') 22 | self._out(os.linesep.join(self.conf.files)) 23 | 24 | 25 | # vim:set ts=8 sw=4 sts=4 tw=78 et: 26 | -------------------------------------------------------------------------------- /PythonApp/lib/tracer/pipe_win32.py: -------------------------------------------------------------------------------- 1 | #=============================================================================== 2 | # Imports 3 | #=============================================================================== 4 | import os 5 | 6 | from win32pipe import CreatePipe 7 | from pywintypes import SECURITY_ATTRIBUTES 8 | from msvcrt import open_osfhandle 9 | 10 | #=============================================================================== 11 | # Classes 12 | #=============================================================================== 13 | class Pipe(object): 14 | def __init__(self, fd, mode): 15 | assert mode in ('r', 'w') 16 | self._mode = mode 17 | 18 | flags = os.O_APPEND | os.O_BINARY 19 | flags |= os.O_RDONLY if mode == 'r' else os.O_WRONLY 20 | handle = open_osfhandle(fd, flags) 21 | self._f = os.fdopen(handle, mode + 'b') 22 | self._h = handle 23 | self._fd = fd 24 | 25 | def __getattr__(self, attr): 26 | if attr[0] == '_': 27 | return object.__getattr__(self, attr) 28 | else: 29 | return getattr(self._f, attr) 30 | def seekable(self): 31 | return False 32 | def readable(self): 33 | return 'r' in self._mode 34 | def writable(self): 35 | return 'w' in self._mode 36 | 37 | def pipe(): 38 | sa = SECURITY_ATTRIBUTES() 39 | sa.bInheritHandle = 1 40 | (r, w) = CreatePipe(sa, 0) 41 | return (Pipe(r, 'r'), Pipe(w, 'w')) 42 | 43 | # vim:set ts=8 sw=4 sts=4 tw=78 et: 44 | -------------------------------------------------------------------------------- /PythonApp/lib/tracer/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/PythonApp/lib/tracer/test/__init__.py -------------------------------------------------------------------------------- /PythonApp/lib/tracer/test/constants.py: -------------------------------------------------------------------------------- 1 | #=============================================================================== 2 | # Constants 3 | #=============================================================================== 4 | 5 | 6 | # vim:set ts=8 sw=4 sts=4 tw=80 et : 7 | -------------------------------------------------------------------------------- /PythonApp/lib/tracer/testprof.py: -------------------------------------------------------------------------------- 1 | #=============================================================================== 2 | # Imports 3 | #=============================================================================== 4 | try: 5 | from tpn.cli import run 6 | except ImportError: 7 | import sys 8 | from os.path import ( 9 | join, 10 | abspath, 11 | dirname, 12 | normpath, 13 | ) 14 | lib_dir = normpath(join(dirname(abspath(__file__)), '..')) 15 | sys.path.insert(0, lib_dir) 16 | from tpn.cli import run 17 | 18 | #=============================================================================== 19 | # Main 20 | #=============================================================================== 21 | def main(): 22 | run('tpn tpn bt') 23 | 24 | if __name__ == '__main__': 25 | main() 26 | 27 | # vim:set ts=8 sw=4 sts=4 tw=78 et: 28 | -------------------------------------------------------------------------------- /PythonApp/lib/tracerdev/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/PythonApp/lib/tracerdev/__init__.py -------------------------------------------------------------------------------- /PythonApp/lib/tracerdev/rtl.py: -------------------------------------------------------------------------------- 1 | #=============================================================================== 2 | # Imports 3 | #=============================================================================== 4 | import sys 5 | 6 | import textwrap 7 | 8 | from tracer.sourcefile import HeaderFile 9 | 10 | #=============================================================================== 11 | # Helpers 12 | #=============================================================================== 13 | 14 | #=============================================================================== 15 | # Classes 16 | #=============================================================================== 17 | class RtlSource: 18 | header = None 19 | source = None 20 | 21 | class RtlSource(SourceFile): 22 | def sync(self): 23 | pass 24 | 25 | class RtlHeader(HeaderFile): 26 | def sync(self): 27 | pass 28 | 29 | class RtlHeader(HeaderFile): 30 | def sync(self): 31 | pass 32 | 33 | # vim:set ts=8 sw=4 sts=4 tw=80 et : 34 | -------------------------------------------------------------------------------- /PythonApp/pt.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from os.path import ( 3 | join, 4 | abspath, 5 | dirname, 6 | normpath, 7 | ) 8 | 9 | libdir = abspath(normpath(join(dirname(__file__), 'lib'))) 10 | 11 | sys.path.insert(0, libdir) 12 | 13 | from tracer.cli import main as cli_main 14 | cli_main(program_name='tracer', library_name='tracer') 15 | -------------------------------------------------------------------------------- /PythonApp/ptd.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from os.path import ( 3 | join, 4 | abspath, 5 | dirname, 6 | normpath, 7 | ) 8 | 9 | libdir = abspath(normpath(join(dirname(__file__), 'lib'))) 10 | 11 | sys.path.insert(0, libdir) 12 | 13 | from tracer.cli import main as cli_main 14 | cli_main(program_name='tracerdev', library_name='tracerdev') 15 | -------------------------------------------------------------------------------- /PythonExe/.gitignore: -------------------------------------------------------------------------------- 1 | hostname.h 2 | -------------------------------------------------------------------------------- /PythonExe/PathHack.h: -------------------------------------------------------------------------------- 1 | #include "hostname.h" 2 | 3 | #ifdef COUGAR 4 | static CONST CHAR PythonExePath[] = \ 5 | "C:\\Users\\Trent\\Anaconda\\envs\\py2711\\python.exe"; 6 | 7 | static CONST CHAR PythonDllPath[] = \ 8 | "S:\\Source\\cpython\\PCbuild\\amd64\\python27.dll"; 9 | 10 | static CONST CHAR PythonPrefix[] = \ 11 | "C:\\Users\\Trent\\Anaconda\\envs\\py2711"; 12 | 13 | #elif defined FALCON 14 | 15 | static CONST CHAR PythonExePath[] = \ 16 | "C:\\Anaconda3\\envs\\py27\\python.exe"; 17 | 18 | static CONST CHAR PythonDllPath[] = \ 19 | "S:\\cpython-2.7\\PCbuild\\amd64\\python27.dll"; 20 | 21 | static CONST CHAR PythonPrefix[] = \ 22 | "C:\\Users\\Trent\\Anaconda\\envs\\py2711"; 23 | 24 | #else 25 | 26 | static CONST CHAR PythonExePath[] = \ 27 | "C:\\Users\\trent\\Anaconda2\\python.exe"; 28 | 29 | static CONST CHAR PythonDllPath[] = \ 30 | "C:\\Users\\trent\\Anaconda2\\python27.dll"; 31 | 32 | static CONST CHAR PythonPrefix[] = \ 33 | "C:\\Users\\trent\\Anaconda2"; 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /PythonExe/PythonExe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/PythonExe/PythonExe.h -------------------------------------------------------------------------------- /PythonExe/PythonExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {23F5C0FD-C395-42C8-B424-4C2A623F325F} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {6794DDB4-008C-44CD-B24C-A92D06C2B1D9} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {E4D66B90-BE5E-43D9-AAD3-C38D0A5CE94F} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /PythonExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /PythonExe/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targetver.h" 4 | 5 | #include 6 | #include "../Rtl/Rtl.h" 7 | #include "../Hook/Hook.h" 8 | #include "../Python/Python.h" -------------------------------------------------------------------------------- /PythonExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PythonProject/PythonProject.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PythonProject.c 8 | 9 | Abstract: 10 | 11 | TBD. 12 | 13 | --*/ 14 | #include "stdafx.h" 15 | 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /PythonProject/PythonProject.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {DBCD06D2-885C-44AD-8FDC-D6F9427ECB4C} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {7888FCBA-623F-4D31-AB12-EC91C98921AA} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {8B0D0B77-CB93-4AF8-A85F-FA380973A7D0} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /PythonProject/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /PythonProject/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /PythonProject/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TraceStore component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include 21 | #include "../Rtl/Rtl.h" 22 | 23 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 24 | -------------------------------------------------------------------------------- /PythonProject/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PythonTracer/PyTraceEvent3.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PyTraceEvent3.c 8 | 9 | Abstract: 10 | 11 | This module is a dummy tracer that doesn't actually do anything. It is 12 | intended to be used to capture the overhead of enabling the Python tracing 13 | and profiling machinery. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | _Use_decl_annotations_ 24 | BOOL 25 | PyTraceEvent3( 26 | PPYTHON_TRACE_CONTEXT Context, 27 | PPYTHON_FUNCTION Function, 28 | PPYTHON_EVENT_TRAITS EventTraits, 29 | PPYFRAMEOBJECT FrameObject, 30 | PPYOBJECT ArgObject 31 | ) 32 | { 33 | return TRUE; 34 | } 35 | 36 | #ifdef __cplusplus 37 | }; // extern "C" 38 | #endif 39 | 40 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 41 | -------------------------------------------------------------------------------- /PythonTracer/PyTraceEvent4.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PyTraceEvent4.c 8 | 9 | Abstract: 10 | 11 | This is currently a placeholder module. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | _Use_decl_annotations_ 22 | BOOL 23 | PyTraceEvent4( 24 | PPYTHON_TRACE_CONTEXT Context, 25 | PPYTHON_FUNCTION Function, 26 | PPYTHON_EVENT_TRAITS EventTraits, 27 | PPYFRAMEOBJECT FrameObject, 28 | PPYOBJECT ArgObject 29 | ) 30 | { 31 | return TRUE; 32 | } 33 | 34 | #ifdef __cplusplus 35 | }; // extern "C" 36 | #endif 37 | 38 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 39 | -------------------------------------------------------------------------------- /PythonTracer/PythonTracerCallbacks.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PythonTracerCallbacks.c 8 | 9 | Abstract: 10 | 11 | This module contains all callbacks used by the PythonTracer component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | _Use_decl_annotations_ 18 | VOID 19 | CALLBACK 20 | NewPythonPathTableEntryCallback( 21 | PTP_CALLBACK_INSTANCE Instance, 22 | PPYTHON_TRACE_CONTEXT Context, 23 | PTP_WORK Work 24 | ) 25 | /*++ 26 | 27 | Routine Description: 28 | 29 | This routine is the callback target for the new Python path table entry 30 | event. 31 | 32 | Arguments: 33 | 34 | Instance - Not used. 35 | 36 | Context - Supplies a pointer to a PYTHON_TRACE_CONTEXT structure. 37 | 38 | Work - Not used. 39 | 40 | Return Value: 41 | 42 | None. 43 | 44 | --*/ 45 | { 46 | BOOL Success; 47 | PPYTHON_PATH_TABLE_ENTRY Entry; 48 | 49 | // 50 | // Validate arguments. 51 | // 52 | 53 | if (!ARGUMENT_PRESENT(Context)) { 54 | return; 55 | } 56 | 57 | 58 | if (!PopNewPathTableEntry(Context, &Entry)) { 59 | return; 60 | } 61 | 62 | InterlockedIncrement(&Context->ActiveNewPythonPathTableEntryCallbacks); 63 | 64 | TRY_MAPPED_MEMORY_OP { 65 | Success = NewPythonPathTableEntry(Context, Entry); 66 | } CATCH_STATUS_IN_PAGE_ERROR { 67 | Success = FALSE; 68 | NOTHING; 69 | } 70 | 71 | InterlockedDecrement(&Context->ActiveNewPythonPathTableEntryCallbacks); 72 | 73 | if (!Success) { 74 | OutputDebugStringA("NewPythonPathTableEntryCallback failed for: "); 75 | OutputDebugStringA(Entry->Path.Buffer); 76 | } 77 | 78 | return; 79 | } 80 | 81 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 82 | -------------------------------------------------------------------------------- /PythonTracer/PythonTracerConstants.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TraceStoreConstants.h 8 | 9 | Abstract: 10 | 11 | This module declares constants used by the PythonTracer component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // 18 | // Constant unicode strings. 19 | // 20 | 21 | CONST UNICODE_STRING RootRegistryPath = \ 22 | RTL_CONSTANT_STRING(ROOT_REGISTRY_PATH); 23 | 24 | CONST UNICODE_STRING RunHistoryDateFormat = \ 25 | RTL_CONSTANT_STRING(RUN_HISTORY_DATE_FORMAT); 26 | 27 | CONST UNICODE_STRING RunHistoryRegistryPathPrefix = \ 28 | RTL_CONSTANT_STRING(RUN_HISTORY_REGISTRY_PATH_PREFIX); 29 | 30 | CONST UNICODE_STRING RunHistoryRegistryPathFormat = \ 31 | RTL_CONSTANT_STRING(RUN_HISTORY_REGISTRY_PATH_FORMAT); 32 | 33 | // 34 | // Trace event types. 35 | // 36 | 37 | CONST PPY_TRACE_EVENT PythonTraceEventTypeToFunctionPointer[] = { 38 | PyTraceEvent1, 39 | PyTraceEvent2, 40 | PyTraceEvent3, 41 | PyTraceEvent4 42 | }; 43 | 44 | 45 | // 46 | // CallbackWorker types. 47 | // 48 | // 49 | 50 | CONST PPY_TRACE_CALLBACK PythonTraceCallbackWorkerTypeToFunctionPointer[] = { 51 | PyTraceCallbackWorker1, 52 | PyTraceCallbackWorker2 53 | }; 54 | 55 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 56 | -------------------------------------------------------------------------------- /PythonTracer/PythonTracerConstants.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TraceStoreConstants.h 8 | 9 | Abstract: 10 | 11 | This module declares constants used by the PythonTracer component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "stdafx.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | CONST UNICODE_STRING RootRegistryPath; 24 | CONST UNICODE_STRING RunHistoryDateFormat; 25 | CONST UNICODE_STRING RunHistoryRegistryPathPrefix; 26 | CONST UNICODE_STRING RunHistoryRegistryPathFormat; 27 | 28 | CONST PPY_TRACE_EVENT PythonTraceEventTypeToFunctionPointer[]; 29 | CONST PPY_TRACE_CALLBACK PythonTraceCallbackWorkerTypeToFunctionPointer[]; 30 | 31 | #ifdef __cplusplus 32 | }; // extern "C" 33 | #endif 34 | 35 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 36 | -------------------------------------------------------------------------------- /PythonTracer/PythonTracerTypes.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PythonTracerTypes.c 8 | 9 | Abstract: 10 | 11 | Define trace store types. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // 18 | // Define the trace store types owned by this module. 19 | // 20 | 21 | // 22 | // N.B. Keep these sorted alphabetically. In vim, mark the start and end brace 23 | // with ma and mb, then issue the command: 24 | // 25 | // :'a,'b !sort -b -k 2 26 | // 27 | 28 | typedef struct _TRACE_STORE_TYPES { 29 | PPYTHON_EVENT_TRAITS_EX TraceEventTraitsEx; 30 | PPYTHON_TRACE_EVENT2 TraceEvent; 31 | } TRACE_STORE_TYPES; 32 | typedef TRACE_STORE_TYPES *PTRACE_STORE_TYPES; 33 | 34 | // 35 | // Type exposure functions. 36 | // 37 | 38 | DECLSPEC_DLLEXPORT 39 | VOID 40 | TraceStoreTypes( 41 | PTRACE_STORE_TYPES Types 42 | ) 43 | { 44 | UNREFERENCED_PARAMETER(Types); 45 | } 46 | 47 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 48 | -------------------------------------------------------------------------------- /PythonTracer/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /PythonTracer/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /PythonTracer/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the PythonTracer component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include 21 | #include "../Rtl/Rtl.h" 22 | #include "../Rtl/__C_specific_handler.h" 23 | #include "../Rtl/AtExitEx.h" 24 | #include "../Python/Python.h" 25 | #include "../TraceStore/TraceStore.h" 26 | #include "../StringTable.h" 27 | #include "PythonTracer.h" 28 | 29 | #ifdef _PYTHON_TRACER_INTERNAL_BUILD 30 | #include "PythonTracerConstants.h" 31 | #include "PythonTracerPrivate.h" 32 | #endif 33 | 34 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 35 | -------------------------------------------------------------------------------- /PythonTracer/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /PythonTracerInjection/PythonTracerInjection.def: -------------------------------------------------------------------------------- 1 | LIBRARY PythonTracerInjection 2 | EXPORTS 3 | InitializeTracerInjection=InitializePythonTracerInjection @1 4 | -------------------------------------------------------------------------------- /PythonTracerInjection/PythonTracerInjection.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | PythonTracerInjection.h 8 | 9 | Abstract: 10 | 11 | This is the main header file for the PythonTracerInjection component. 12 | This component is responsible for provided the necessary injection 13 | facilities for Python tracing. 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #ifdef _PYTHON_TRACER_INJECTION_INTERNAL_BUILD 24 | 25 | // 26 | // This is an internal build of the PythonTracerInjection component. 27 | // 28 | 29 | #ifdef _PYTHON_TRACER_INJECTION_DLL_BUILD 30 | 31 | // 32 | // This is the DLL build. 33 | // 34 | 35 | #define PYTHON_TRACER_INJECTION_API __declspec(dllexport) 36 | #define PYTHON_TRACER_INJECTION_DATA extern __declspec(dllexport) 37 | 38 | #else 39 | 40 | // 41 | // This is the static library build. 42 | // 43 | 44 | #define PYTHON_TRACER_INJECTION_API 45 | #define PYTHON_TRACER_INJECTION_DATA extern 46 | 47 | #endif 48 | 49 | #include "stdafx.h" 50 | 51 | #else 52 | 53 | // 54 | // We're being included by an external component. 55 | // 56 | 57 | #define PYTHON_TRACER_INJECTION_API __declspec(dllimport) 58 | #define PYTHON_TRACER_INJECTION_DATA extern __declspec(dllimport) 59 | 60 | #include 61 | #include "../Rtl/Rtl.h" 62 | #include "../Python/Python.h" 63 | #include "../DebugEngine/DebugEngine.h" 64 | #include "../DebugEngine/DebugEngineInterfaces.h" 65 | #include "../TraceStore/TraceStore.h" 66 | #include "../TracerCore/TracerCore.h" 67 | #include "../StringTable.h" 68 | #include "../PythonTracer/PythonTracer.h" 69 | #include "../TracerConfig/TracerConfig.h" 70 | #include "../TracedPythonSession/TracedPythonSession.h" 71 | 72 | #endif 73 | 74 | INITIALIZE_TRACER_INJECTION InitializePythonTracerInjection; 75 | 76 | #ifdef __cplusplus 77 | }; // extern "C" 78 | #endif 79 | 80 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 81 | -------------------------------------------------------------------------------- /PythonTracerInjection/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /PythonTracerInjection/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /PythonTracerInjection/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the PythonTracerInjection component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | 21 | #include "../Rtl/Rtl.h" 22 | #include "../Python/Python.h" 23 | #include "../DebugEngine/DebugEngine.h" 24 | #include "../DebugEngine/DebugEngineInterfaces.h" 25 | #include "../TracerConfig/TracerConfig.h" 26 | #include "../TracerCore/TracerCore.h" 27 | #include "../TracerHeap/TracerHeap.h" 28 | #include "../TraceStore/TraceStore.h" 29 | #include "../StringTable.h" 30 | #include "../PythonTracer/PythonTracer.h" 31 | #include "../TracedPythonSession/TracedPythonSession.h" 32 | #include "PythonTracerInjection.h" 33 | 34 | #ifdef _PYTHON_TRACER_INJECTION_INTERNAL_BUILD 35 | #include "PythonTracerInjectionPrivate.h" 36 | #endif 37 | 38 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 39 | -------------------------------------------------------------------------------- /PythonTracerInjection/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /Rtl/AtExitEx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | AtExitEx.c 8 | 9 | Abstract: 10 | 11 | This module implements the SetAtExitEx() and AtExitEx() stubs. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | PATEXITEX AtExitExImpl = NULL; 18 | 19 | VOID 20 | SetAtExitEx( 21 | PATEXITEX AtExitEx 22 | ) 23 | { 24 | AtExitExImpl = AtExitEx; 25 | } 26 | 27 | #pragma warning(push) 28 | #pragma warning(disable: 4028 4273) 29 | 30 | _Use_decl_annotations_ 31 | BOOL 32 | AtExitEx( 33 | PATEXITEX_CALLBACK Callback, 34 | PATEXITEX_FLAGS Flags, 35 | PVOID Context, 36 | struct _RTL_ATEXIT_ENTRY **EntryPointer 37 | ) 38 | { 39 | return AtExitExImpl(Callback, Flags, Context, EntryPointer); 40 | } 41 | 42 | #pragma warning(pop) 43 | 44 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 45 | -------------------------------------------------------------------------------- /Rtl/AtExitEx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | AtExitEx.h 8 | 9 | Abstract: 10 | 11 | This module provides the necessary scaffolding to use the AtExitEx() 12 | function without needing to have any knowledge of the Rtl library. 13 | 14 | To make use of this functionality, add this file and AtExitEx.c to your 15 | project. For components loaded via the TracedPythonSession component, 16 | SetAtExitEx() will be called automatically as soon as the component has 17 | been dynamically loaded (via LoadLibrary()). 18 | 19 | --*/ 20 | 21 | #ifdef _NO_RTL 22 | 23 | typedef struct _Struct_size_bytes_(sizeof(ULONG)) _ATEXITEX_FLAGS { 24 | ULONG SuppressExceptions:1; 25 | } ATEXITEX_FLAGS, *PATEXITEX_FLAGS; 26 | C_ASSERT(sizeof(ATEXITEX_FLAGS) == sizeof(ULONG)); 27 | 28 | typedef 29 | VOID 30 | (CALLBACK ATEXITEX_CALLBACK)( 31 | _In_ BOOL IsProcessTerminating, 32 | _In_opt_ PVOID Context 33 | ); 34 | typedef ATEXITEX_CALLBACK *PATEXITEX_CALLBACK; 35 | 36 | typedef 37 | _Success_(return == 0) 38 | BOOL 39 | (ATEXITEX)( 40 | _In_ PATEXITEX_CALLBACK Callback, 41 | _In_opt_ PATEXITEX_FLAGS Flags, 42 | _In_opt_ PVOID Context, 43 | _Outptr_opt_result_nullonfailure_ struct _RTL_ATEXIT_ENTRY **EntryPointer 44 | ); 45 | typedef ATEXITEX *PATEXITEX; 46 | 47 | typedef 48 | VOID 49 | (SET_ATEXITEX)( 50 | _In_ PATEXITEX AtExitEx 51 | ); 52 | typedef SET_ATEXITEX *PSET_ATEXITEX; 53 | 54 | #endif 55 | 56 | extern PATEXITEX AtExitExImpl; 57 | __declspec(dllexport) SET_ATEXITEX SetAtExitEx; 58 | 59 | #pragma warning(push) 60 | #pragma warning(disable: 4028 4273) 61 | 62 | ATEXITEX AtExitEx; 63 | 64 | #pragma warning(pop) 65 | 66 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 67 | -------------------------------------------------------------------------------- /Rtl/Commandline.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | Commandline.h 8 | 9 | Abstract: 10 | 11 | This is the header file for the Rtl commandline component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "stdafx.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef 24 | PPWSTR 25 | (COMMAND_LINE_TO_ARGVW)( 26 | _In_ PWSTR CommandLine, 27 | _Out_ PLONG NumberOfArgs 28 | ); 29 | typedef COMMAND_LINE_TO_ARGVW *PCOMMAND_LINE_TO_ARGVW; 30 | 31 | typedef PWSTR (WINAPI GET_COMMAND_LINE)(VOID); 32 | typedef GET_COMMAND_LINE *PGET_COMMAND_LINE; 33 | 34 | typedef PPSTR *PPPSTR; 35 | 36 | typedef 37 | _Success_(return != 0) 38 | BOOL 39 | (ARGVW_TO_ARGVA)( 40 | _In_ PPWSTR ArgvW, 41 | _In_ ULONG NumberOfArguments, 42 | _Out_ PPPSTR ArgvA, 43 | _In_opt_ PSTR Argv0, 44 | _In_ PALLOCATOR Allocator 45 | ); 46 | typedef ARGVW_TO_ARGVA *PARGVW_TO_ARGVA; 47 | RTL_API ARGVW_TO_ARGVA ArgvWToArgvA; 48 | 49 | #define MAX_ARGV 100 50 | 51 | #ifdef __cplusplus 52 | } // extern "C" 53 | #endif 54 | 55 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 56 | -------------------------------------------------------------------------------- /Rtl/Cuda.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | Cuda.h 8 | 9 | Abstract: 10 | 11 | WIP. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | 18 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 19 | -------------------------------------------------------------------------------- /Rtl/DisableWarnings.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | DisableWarnings.h 8 | 9 | Abstract: 10 | 11 | This header file disables a common set of warnings for the codebase in 12 | order to still compile with the warning level set to 4. 13 | 14 | --*/ 15 | 16 | #pragma once 17 | 18 | // 19 | // Disabled intentionally: 20 | // 21 | // 4201: nameless struct/union 22 | // 4214: bit field types other than int 23 | // 4115: named type definitions in parenthesis 24 | // 25 | // Currently disabled, but can be re-enabled once code is cleaned up. 26 | // 27 | // 4057: A* differs in indirection to slightly different base type from B* 28 | // 4204: non-constant aggregate initializer 29 | // 4221: A cannot be initialized using address of automatic variable B 30 | // 4054: type-cast from function pointer to LPCTSTR 31 | // 32 | 33 | #pragma warning(disable: 4201 4214 4115 4057 4204 4221 4054) 34 | 35 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 36 | -------------------------------------------------------------------------------- /Rtl/InjectionInitialize.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | Injection.c 8 | 9 | Abstract: 10 | 11 | This module implements the Rtl component's remote thread and code injection 12 | component. Functions are provided for creating injection packets, adding 13 | injection payloads to packets, adding symbol requests to packets, destroying 14 | packets, and performing the actual injection. 15 | 16 | --*/ 17 | 18 | #include "stdafx.h" 19 | 20 | #pragma data_seg(".shared") 21 | RTL_INJECTION_SHARED InjectionShared = { 0 }; 22 | #pragma data_seg() 23 | #pragma comment(linker, "/section:.shared,rws") 24 | 25 | BOOL 26 | CALLBACK 27 | RtlpInitializeInjectionCallback( 28 | PINIT_ONCE InitOnce, 29 | PVOID Parameter, 30 | PVOID *lpContext 31 | ) 32 | { 33 | return TRUE; 34 | } 35 | 36 | BOOL 37 | RtlInitializeInjection( 38 | VOID 39 | ) 40 | { 41 | BOOL Status; 42 | 43 | Status = InitOnceExecuteOnce(&InjectionShared.InitOnce, 44 | RtlpInitializeInjectionCallback, 45 | NULL, 46 | NULL); 47 | 48 | return Status; 49 | } 50 | 51 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 52 | -------------------------------------------------------------------------------- /Rtl/InjectionPrivate.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | InjectionPrivate.c 8 | 9 | Abstract: 10 | 11 | This module implements private routines pertaining to the injection of code 12 | into a remote process. Routines are provided for getting an address of a 13 | currently executing function, obtaining an approximate code size of a 14 | function given an address within the function, skipping jumps when given 15 | a pointer to byte code. 16 | 17 | --*/ 18 | 19 | #include "stdafx.h" 20 | 21 | 22 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 23 | -------------------------------------------------------------------------------- /Rtl/Rtl.def: -------------------------------------------------------------------------------- 1 | LIBRARY Rtl 2 | EXPORTS 3 | RtlHeapAllocatorInitialize 4 | RtlHeapAllocatorInitializeEx 5 | RtlHeapAllocatorDestroy 6 | AppendIntegerToCharBufferEx 7 | AppendCStrToCharBuffer 8 | AppendUnicodeStringToWideCharBuffer 9 | AppendWideCStrToWideCharBuffer 10 | AppendWideCharBufferToWideCharBuffer 11 | AppendWideCharToWideCharBuffer 12 | AppendIntegerToWideCharBuffer 13 | -------------------------------------------------------------------------------- /Rtl/RtlConstants.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | RtlConstants.h 8 | 9 | Abstract: 10 | 11 | This module declares constants used by the Rtl component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "stdafx.h" 22 | 23 | RTL_DATA CONST UNICODE_STRING RtlInjectionSignalEventNamePrefix; 24 | RTL_DATA CONST UNICODE_STRING RtlInjectionWaitEventNamePrefix; 25 | 26 | RTL_DATA CONST PCSTR RtlFunctionNames[]; 27 | RTL_DATA CONST PCSTR RtlExFunctionNames[]; 28 | RTL_DATA CONST PCSTR DbgHelpFunctionNames[]; 29 | RTL_DATA CONST PCSTR CuFunctionNames[]; 30 | 31 | #ifdef __cplusplus 32 | }; // extern "C" 33 | #endif 34 | 35 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab nowrap : 36 | -------------------------------------------------------------------------------- /Rtl/__C_specific_handler.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | __C_specific_handler.c 8 | 9 | Abstract: 10 | 11 | This module implements the __C_specific_handler endpoint. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | #include "__C_specific_handler.h" 17 | 18 | P__C_SPECIFIC_HANDLER __C_specific_handler_impl = NULL; 19 | 20 | VOID 21 | SetCSpecificHandler( 22 | P__C_SPECIFIC_HANDLER Handler 23 | ) 24 | { 25 | __C_specific_handler_impl = Handler; 26 | } 27 | 28 | #pragma warning(push) 29 | #pragma warning(disable: 4028 4273) 30 | 31 | EXCEPTION_DISPOSITION 32 | __cdecl 33 | __C_specific_handler( 34 | PEXCEPTION_RECORD ExceptionRecord, 35 | ULONG_PTR Frame, 36 | PCONTEXT Context, 37 | struct _DISPATCHER_CONTEXT *Dispatch 38 | ) 39 | { 40 | return __C_specific_handler_impl(ExceptionRecord, 41 | Frame, 42 | Context, 43 | Dispatch); 44 | } 45 | 46 | #pragma warning(pop) 47 | 48 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 49 | -------------------------------------------------------------------------------- /Rtl/__C_specific_handler.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | __C_specific_handler.h 8 | 9 | Abstract: 10 | 11 | This module provides the necessary scaffolding to use structured exception 12 | handling via __try/__except/__finally C language constructs without needing 13 | to link to a C runtime library. 14 | 15 | To make use of this functionality, include this file in one of your C file 16 | components, after Rtl.h has been included. After loading Rtl, set the 17 | __C_specific_handler_impl to the value of Rtl->__C_specific_handler. 18 | 19 | --*/ 20 | 21 | #ifdef _NO_RTL 22 | 23 | #include 24 | 25 | typedef 26 | EXCEPTION_DISPOSITION 27 | (__cdecl __C_SPECIFIC_HANDLER)( 28 | PEXCEPTION_RECORD ExceptionRecord, 29 | ULONG_PTR Frame, 30 | PCONTEXT Context, 31 | struct _DISPATCHER_CONTEXT *Dispatch 32 | ); 33 | typedef __C_SPECIFIC_HANDLER *P__C_SPECIFIC_HANDLER; 34 | 35 | typedef 36 | VOID 37 | (SET_C_SPECIFIC_HANDLER)( 38 | _In_ P__C_SPECIFIC_HANDLER Handler 39 | ); 40 | typedef SET_C_SPECIFIC_HANDLER *PSET_C_SPECIFIC_HANDLER; 41 | 42 | #endif 43 | 44 | extern P__C_SPECIFIC_HANDLER __C_specific_handler_impl; 45 | __declspec(dllexport) SET_C_SPECIFIC_HANDLER SetCSpecificHandler; 46 | 47 | #pragma warning(push) 48 | #pragma warning(disable: 4028 4273) 49 | 50 | __C_SPECIFIC_HANDLER __C_specific_handler; 51 | 52 | #pragma warning(pop) 53 | 54 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 55 | -------------------------------------------------------------------------------- /Rtl/__chkstk.s: -------------------------------------------------------------------------------- 1 | 2 | include ksamd64.inc 3 | 4 | LEAF_ENTRY __chkstk, _TEXT$00 5 | ret 6 | LEAF_END __chkstk, _TEXT$00 7 | 8 | end 9 | 10 | ; vim:set tw=80 ts=8 sw=8 sts=8 expandtab: 11 | -------------------------------------------------------------------------------- /Rtl/atexit.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | RtlAtExit.c 8 | 9 | Abstract: 10 | 11 | This module implements our custom atexit() support. Functions are provided 12 | for registering new functions to call at process exit. The actual act of 13 | calling registered functions at exit is done by hooking into dllmain.c's 14 | _DllMainCRTStartup() function; specifically, the DLL_PROCESS_DETACH message. 15 | 16 | --*/ 17 | 18 | #include "stdafx.h" 19 | 20 | PATEXIT atexit_impl = NULL; 21 | 22 | VOID 23 | SetAtExit( 24 | PATEXIT AtExit 25 | ) 26 | { 27 | atexit_impl = AtExit; 28 | } 29 | 30 | #pragma warning(push) 31 | #pragma warning(disable: 4028 4273) 32 | 33 | INT 34 | atexit( 35 | PATEXITFUNC AtExitFunction 36 | ) 37 | { 38 | return atexit_impl(AtExitFunction); 39 | } 40 | 41 | #pragma warning(pop) 42 | 43 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 44 | -------------------------------------------------------------------------------- /Rtl/atexit.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | atexit.h 8 | 9 | Abstract: 10 | 11 | This module provides the necessary scaffolding to use the atexit() function 12 | without needing to link to a C runtime library. 13 | 14 | To make use of this functionality, include this file in one of your C file 15 | components, after Rtl.h has been included. After loading Rtl, set the 16 | atexit_impl to the value of Rtl->atexit. 17 | 18 | --*/ 19 | 20 | #ifdef _NO_RTL 21 | 22 | typedef 23 | VOID 24 | (__cdecl ATEXITFUNC)( 25 | VOID 26 | ); 27 | typedef ATEXITFUNC *PATEXITFUNC; 28 | 29 | typedef 30 | _Success_(return == 0) 31 | INT 32 | (ATEXIT)( 33 | _In_ PATEXITFUNC AtExitFunction 34 | ); 35 | typedef ATEXIT *PATEXIT; 36 | 37 | #endif 38 | 39 | extern PATEXIT atexit_impl; 40 | __declspec(dllexport) SET_ATEXIT SetAtExit; 41 | 42 | #pragma warning(push) 43 | #pragma warning(disable: 4028 4273) 44 | 45 | ATEXIT atexit; 46 | 47 | #pragma warning(pop) 48 | 49 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 50 | -------------------------------------------------------------------------------- /Rtl/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the Rtl DLL. It is responsible for 12 | hooking into the DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH messages in 13 | order to facilitate atexit() rundown functionality. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | BOOL 20 | APIENTRY 21 | _DllMainCRTStartup( 22 | _In_ HMODULE Module, 23 | _In_ DWORD Reason, 24 | _In_ LPVOID Reserved 25 | ) 26 | { 27 | BOOL IsProcessTerminating; 28 | 29 | switch (Reason) { 30 | case DLL_PROCESS_ATTACH: 31 | if (!InitializeGlobalRtlAtExitRundown()) { 32 | return FALSE; 33 | } 34 | break; 35 | case DLL_THREAD_ATTACH: 36 | break; 37 | case DLL_THREAD_DETACH: 38 | break; 39 | case DLL_PROCESS_DETACH: 40 | IsProcessTerminating = (Reserved != NULL); 41 | RundownGlobalAtExitFunctions(IsProcessTerminating); 42 | DestroyGlobalRtlAtExitRundown(); 43 | break; 44 | } 45 | 46 | return TRUE; 47 | } 48 | 49 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 50 | -------------------------------------------------------------------------------- /Rtl/memset.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | memset.c 8 | 9 | Abstract: 10 | 11 | This module supplies a simple memset() implementation. It is typically 12 | included by projects that need it (based on unresolved external symbol 13 | errors when linking) if their PGO builds otherwise fail. 14 | 15 | It is not used or included in the Rtl binary. Other projects simply 16 | include it. 17 | 18 | --*/ 19 | 20 | #pragma intrinsic(__stosb) 21 | #pragma function(memset) 22 | void *memset(void *s, int c, __int64 n) 23 | { 24 | __stosb(s, c, n); 25 | return s; 26 | } 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /Rtl/memset.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | memset.h 8 | 9 | Abstract: 10 | 11 | This module supplies an extern definition of the memset function. It is 12 | included by projects that need it (based on unresolved external symbol 13 | errors when linking) if their PGO builds otherwise fail. 14 | 15 | --*/ 16 | 17 | #pragma function(memset) 18 | extern "C" void *memset(void *s, int c, size_t n); 19 | 20 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 21 | -------------------------------------------------------------------------------- /Rtl/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 routine optimized to do word accesses rather than byte accesses, 3 | * and to avoid unnecessary copies into the context array. 4 | * 5 | * This was initially based on the Mozilla SHA1 implementation, although 6 | * none of the original Mozilla code remains. 7 | */ 8 | 9 | typedef struct { 10 | unsigned long long size; 11 | unsigned int H[5]; 12 | unsigned int W[16]; 13 | } blk_SHA_CTX; 14 | 15 | void blk_SHA1_Init(blk_SHA_CTX *ctx); 16 | void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len); 17 | void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx); 18 | 19 | #define platform_SHA_CTX blk_SHA_CTX 20 | #define platform_SHA1_Init blk_SHA1_Init 21 | #define platform_SHA1_Update blk_SHA1_Update 22 | #define platform_SHA1_Final blk_SHA1_Final 23 | -------------------------------------------------------------------------------- /Rtl/stdafx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.c 8 | 9 | Abstract: 10 | 11 | This is the precompiled source file for the Rtl component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /Rtl/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the Rtl component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #define CINTERFACE 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | // 28 | // Disable "inconsistent SAL annotation" warnings before importing the 29 | // intrinsics headers. 30 | // 31 | 32 | #pragma warning(push) 33 | #pragma warning(disable: 28251) 34 | #include 35 | #include 36 | #pragma warning(pop) 37 | 38 | #include "Rtl.h" 39 | 40 | #ifdef _RTL_INTERNAL_BUILD 41 | #include "RtlConstants.h" 42 | #include "atexit.h" 43 | #include "AtExitEx.h" 44 | #include "RtlPrivate.h" 45 | #endif 46 | 47 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 48 | -------------------------------------------------------------------------------- /Rtl/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /RtlLib/RtlLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {C13057E8-2BD2-4C3F-87C0-CB78D98A245D} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {5273946A-A19C-449B-9242-E2268C57D322} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {300D8DE1-A160-4B48-A202-71295C34D7A2} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | -------------------------------------------------------------------------------- /RtlLib/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /RtlLib/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the RtlLib component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include "../Rtl/Rtl.h" 20 | #include "../Rtl/atexit.h" 21 | #include "../Rtl/AtExitEx.h" 22 | 23 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 24 | -------------------------------------------------------------------------------- /RtlLib/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /ScratchExe/ScratchExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {785843F3-9561-4504-8A27-183C28FF7E9D} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {7527785E-4FDA-4DA6-AF3E-B0069A32A45D} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {D56063BF-37FB-4E50-AF80-2405886712AA} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Source Files 42 | 43 | 44 | -------------------------------------------------------------------------------- /ScratchExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /ScratchExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the ScratchExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/__C_specific_handler.h" 22 | #include "../DebugEngine/DebugEngine.h" 23 | #include "../TraceStore/TraceStore.h" 24 | #include "../TracerHeap/TracerHeap.h" 25 | #include "../TracerConfig/TracerConfig.h" 26 | #include "../TracerCore/TracerCore.h" 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /ScratchExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /StringTable.h: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is used to simplify toggling of underlying StringTable 4 | // implementations in a single location (versus having to change the 5 | // include files of all dependent projects). 6 | // 7 | 8 | #if 0 9 | #include "StringTable/StringTable.h" 10 | #else 11 | #include "StringTable2/StringTable.h" 12 | #endif 13 | 14 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 15 | -------------------------------------------------------------------------------- /StringTable/DestroyStringTable.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | DestroyStringTable.c 8 | 9 | Abstract: 10 | 11 | This module implements the functionality to destroy a previously created 12 | STRING_TABLE structure. 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | _Use_decl_annotations_ 19 | VOID 20 | DestroyStringTable( 21 | PALLOCATOR StringTableAllocator, 22 | PALLOCATOR StringArrayAllocator, 23 | PSTRING_TABLE StringTable 24 | ) 25 | /*++ 26 | 27 | Routine Description: 28 | 29 | Destroys a StringTable structure. 30 | 31 | Arguments: 32 | 33 | StringTableAllocator - Supplies a pointer to the ALLOCATOR structure that 34 | was used to create the STRING_TABLE. 35 | 36 | StringArrayAllocator - Supplies a pointer to an ALLOCATOR structure that 37 | may have been used to create the STRING_ARRAY. 38 | 39 | StringTable - Supplies a pointer to a STRING_TABLE struct to be destroyed. 40 | 41 | Return Value: 42 | 43 | None. 44 | 45 | --*/ 46 | { 47 | // 48 | // Validate arguments. 49 | // 50 | 51 | if (!ARGUMENT_PRESENT(StringTable)) { 52 | return; 53 | } 54 | 55 | if (!ARGUMENT_PRESENT(StringTableAllocator)) { 56 | return; 57 | } 58 | 59 | if (!ARGUMENT_PRESENT(StringArrayAllocator)) { 60 | return; 61 | } 62 | 63 | // 64 | // If the string array isn't embedded, free it first. 65 | // 66 | 67 | if (!HasEmbeddedStringArray(StringTable)) { 68 | StringArrayAllocator->Free( 69 | StringArrayAllocator->Context, 70 | StringTable->pStringArray 71 | ); 72 | StringTable->pStringArray = NULL; 73 | } 74 | 75 | // 76 | // Free the StringTable and return. 77 | // 78 | 79 | StringTableAllocator->Free(StringTableAllocator->Context, StringTable); 80 | 81 | return; 82 | } 83 | 84 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 85 | -------------------------------------------------------------------------------- /StringTable/StringTableConstants.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | StringTableConstants.h 8 | 9 | Abstract: 10 | 11 | This module defines constants related to the StringTable component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "stdafx.h" 22 | 23 | static CONST USHORT StringArraysPerTable = 16; 24 | 25 | 26 | FORCEINLINE 27 | USHORT 28 | GetNumberOfTablesRequiredForStringArray( 29 | _In_ PSTRING_ARRAY StringArray 30 | ) 31 | { 32 | return ALIGN_UP(StringArray->NumberOfElements, 16) / 16; 33 | } 34 | 35 | #ifdef __cplusplus 36 | }; // extern "C" { 37 | #endif 38 | 39 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 40 | -------------------------------------------------------------------------------- /StringTable/StringTableConstants_C.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | PARALLEL_SUFFIX_MOVE_MASK32 4 | ParallelSuffix32HighBitFromEveryOtherByte = { 5 | 0xaaaaaaaa, // Mask (0b10101010101010101010101010101010) 6 | 0x22222222, // Move0 (0b00100010001000100010001000100010) 7 | 0x18181818, // Move1 (0b00011000000110000001100000011000) 8 | 0x07800780, // Move2 (0b00000111100000000000011110000000) 9 | 0x007f8000, // Move3 (0b00000000011111111000000000000000) 10 | 0x80000000, // Move4 (0b10000000000000000000000000000000) 11 | 0xffffffff, // Unused5 12 | 0x00000000 // Unused6 13 | }; 14 | 15 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 16 | -------------------------------------------------------------------------------- /StringTable/StringTablePrivate.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | StringTablePrivate.h 8 | 9 | Abstract: 10 | 11 | This is the private header file for the StringTable component. It defines 12 | function typedefs and function declarations for all major (i.e. not local 13 | to the module) functions available for use by individual modules within 14 | this component. 15 | 16 | --*/ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "stdafx.h" 25 | 26 | //////////////////////////////////////////////////////////////////////////////// 27 | // Function typedefs and inline functions for internal modules. 28 | //////////////////////////////////////////////////////////////////////////////// 29 | 30 | COPY_STRING_ARRAY CopyStringArray; 31 | DESTROY_STRING_TABLE DestroyStringTable; 32 | CREATE_STRING_ARRAY_FROM_DELIMITED_STRING CreateStringArrayFromDelimitedString; 33 | CREATE_STRING_TABLE CreateSingleStringTable; 34 | SEARCH_STRING_TABLE_SLOTS_FOR_FIRST_PREFIX_MATCH 35 | SearchStringTableSlotsForFirstPrefixMatch; 36 | MALLOC StringTableMalloc; 37 | CALLOC StringTableCalloc; 38 | REALLOC StringTableRealloc; 39 | FREE StringTableFree; 40 | FREE_POINTER StringTableFreePointer; 41 | INITIALIZE_ALLOCATOR StringTableInitializeAllocator; 42 | DESTROY_ALLOCATOR StringTableDestroyAllocator; 43 | 44 | #ifdef __cplusplus 45 | }; // extern "C" 46 | #endif 47 | 48 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 49 | -------------------------------------------------------------------------------- /StringTable/StringTableTypes.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | StringTableTypes.c 8 | 9 | Abstract: 10 | 11 | Define trace store types. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // 18 | // Define the trace store types owned by this module. 19 | // 20 | 21 | // 22 | // N.B. Keep these sorted alphabetically. In vim, mark the start and end brace 23 | // with ma and mb, then issue the command: 24 | // 25 | // :'a,'b !sort -b -k 2 26 | // 27 | 28 | typedef struct _TRACE_STORE_TYPES { 29 | PSTRING_ARRAY StringArray; 30 | PSTRING_TABLE StringTable; 31 | } TRACE_STORE_TYPES; 32 | typedef TRACE_STORE_TYPES *PTRACE_STORE_TYPES; 33 | 34 | // 35 | // Type exposure functions. 36 | // 37 | 38 | DECLSPEC_DLLEXPORT 39 | VOID 40 | TraceStoreTypes( 41 | PTRACE_STORE_TYPES Types 42 | ) 43 | { 44 | UNREFERENCED_PARAMETER(Types); 45 | } 46 | 47 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 48 | -------------------------------------------------------------------------------- /StringTable/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /StringTable/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 4 | -------------------------------------------------------------------------------- /StringTable/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the StringTable component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include "../Rtl/Rtl.h" 23 | #include "StringTable.h" 24 | #include "StringTablePrivate.h" 25 | #include "StringTableConstants.h" 26 | #include "StringLoadStoreOperations.h" 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /StringTable/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 | -------------------------------------------------------------------------------- /StringTable2/DestroyStringTable.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | DestroyStringTable.c 8 | 9 | Abstract: 10 | 11 | This module implements the functionality to destroy a previously created 12 | STRING_TABLE structure. 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | _Use_decl_annotations_ 19 | VOID 20 | DestroyStringTable( 21 | PALLOCATOR StringTableAllocator, 22 | PALLOCATOR StringArrayAllocator, 23 | PSTRING_TABLE StringTable 24 | ) 25 | /*++ 26 | 27 | Routine Description: 28 | 29 | Destroys a StringTable structure. 30 | 31 | Arguments: 32 | 33 | StringTableAllocator - Supplies a pointer to the ALLOCATOR structure that 34 | was used to create the STRING_TABLE. 35 | 36 | StringArrayAllocator - Supplies a pointer to an ALLOCATOR structure that 37 | may have been used to create the STRING_ARRAY. 38 | 39 | StringTable - Supplies a pointer to a STRING_TABLE struct to be destroyed. 40 | 41 | Return Value: 42 | 43 | None. 44 | 45 | --*/ 46 | { 47 | // 48 | // Validate arguments. 49 | // 50 | 51 | if (!ARGUMENT_PRESENT(StringTable)) { 52 | return; 53 | } 54 | 55 | if (!ARGUMENT_PRESENT(StringTableAllocator)) { 56 | return; 57 | } 58 | 59 | if (!ARGUMENT_PRESENT(StringArrayAllocator)) { 60 | return; 61 | } 62 | 63 | // 64 | // If the string array isn't embedded, free it first. 65 | // 66 | 67 | if (!HasEmbeddedStringArray(StringTable)) { 68 | StringArrayAllocator->Free( 69 | StringArrayAllocator->Context, 70 | StringTable->pStringArray 71 | ); 72 | StringTable->pStringArray = NULL; 73 | } 74 | 75 | // 76 | // Free the StringTable and return. 77 | // 78 | 79 | StringTableAllocator->AlignedFree(StringTableAllocator->Context, 80 | StringTable); 81 | 82 | return; 83 | } 84 | 85 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 86 | -------------------------------------------------------------------------------- /StringTable2/IsPrefixOfCStrInArray_1.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2018 Trent Nelson 4 | 5 | Module Name: 6 | 7 | IsPrefixOfCStrInArray_*.c 8 | 9 | Abstract: 10 | 11 | These modules implement the IsPrefixOfStringInTable routine. 12 | 13 | N.B. Keep this header identical between files to declutter diff output. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | // 20 | // A prefix search using C-style NULL-terminated strings and no string table 21 | // support. 22 | // 23 | 24 | _Use_decl_annotations_ 25 | STRING_TABLE_INDEX 26 | IsPrefixOfCStrInArray( 27 | PCSZ *StringArray, 28 | PCSZ String, 29 | PSTRING_MATCH Match 30 | ) 31 | { 32 | PCSZ Left; 33 | PCSZ Right; 34 | PCSZ *Target; 35 | ULONG Index = 0; 36 | ULONG Count; 37 | 38 | for (Target = StringArray; *Target != NULL; Target++, Index++) { 39 | Count = 0; 40 | Left = String; 41 | Right = *Target; 42 | 43 | while (*Left && *Right && *Left++ == *Right++) { 44 | Count++; 45 | } 46 | 47 | if (Count > 0 && !*Right) { 48 | if (ARGUMENT_PRESENT(Match)) { 49 | Match->Index = (BYTE)Index; 50 | Match->NumberOfMatchedCharacters = (BYTE)Count; 51 | Match->String = NULL; 52 | } 53 | return (STRING_TABLE_INDEX)Index; 54 | } 55 | } 56 | 57 | return NO_MATCH_FOUND; 58 | } 59 | 60 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 61 | -------------------------------------------------------------------------------- /StringTable2/README.md: -------------------------------------------------------------------------------- 1 | # StringTable2 2 | 3 | This component implements an optimized routine for determining if a string 4 | has any prefix matches within a table of known strings. 5 | 6 | It is the second iteration of the functionality, with ../StringTable being the 7 | first. This version differs from the first version primarily in that it does 8 | not use an array of 16-bit unsigned shorts for capturing string lengths, which 9 | means the main IsPrefixOfStringInTable routine only uses AVX primitives, not 10 | AVX2 primitives. 11 | 12 | This component is supported by some unit tests, living at ../StringTable2Test, 13 | and a benchmark utility, ../StringTable2BenchmarkExe. 14 | 15 | See also: [Is Prefix Of String In Table? A Journey Into SIMD String Processing](http://trent.me/is-prefix-of-string-in-table/). 16 | -------------------------------------------------------------------------------- /StringTable2/StringTable.def: -------------------------------------------------------------------------------- 1 | LIBRARY StringTable2 2 | EXPORTS 3 | SetCSpecificHandler 4 | CopyStringArray 5 | CreateStringTable 6 | DestroyStringTable 7 | InitializeStringTableAllocator 8 | InitializeStringTableAllocatorFromRtlBootstrap 9 | CreateStringArrayFromDelimitedString 10 | CreateStringTableFromDelimitedString 11 | CreateStringTableFromDelimitedEnvironmentVariable 12 | TestIsPrefixOfStringInTableFunctions 13 | IsStringInTable 14 | IsPrefixOfStringInTable_1 15 | IsPrefixOfStringInTable_2 16 | IsPrefixOfStringInTable_3 17 | IsPrefixOfStringInTable_4 18 | IsPrefixOfStringInTable_5 19 | IsPrefixOfStringInTable_6 20 | IsPrefixOfStringInTable_7 21 | IsPrefixOfStringInTable_8 22 | IsPrefixOfStringInTable_9 23 | IsPrefixOfStringInTable_10 24 | IsPrefixOfStringInTable_11 25 | IsPrefixOfStringInTable_12 26 | IsPrefixOfStringInTable_13 27 | IsPrefixOfStringInTable_14 28 | IsPrefixOfStringInTable_15 29 | IsPrefixOfStringInTable_x64_1 30 | IsPrefixOfStringInTable_x64_2 31 | IsPrefixOfStringInTable_x64_3 32 | IsPrefixOfStringInTable_x64_4 33 | IsPrefixOfStringInTable_x64_5 34 | IsPrefixOfStringInTable_x64_6 35 | IsPrefixOfStringInTable_x64_7 36 | IsPrefixOfStringInTable_x64_8 37 | IsPrefixOfStringInTable_x64_9 38 | IsPrefixOfStringInTable_x64_10 39 | IsPrefixOfStringInTable_x64_11 40 | IsPrefixOfStringInTable_x64_12 41 | IsPrefixOfStringInTable_x64_13 42 | IsPrefixOfStringInTable_x64_14 43 | IsPrefixOfStringInTable_x64_15 44 | IsPrefixOfStringInTable_x64_16 45 | IsPrefixOfCStrInArray 46 | CreateStringArrayFromDelimitedString_1=CreateStringArrayFromDelimitedString 47 | CreateStringArrayFromDelimitedString_2 48 | IntegerDivision_x64_1 49 | IsPrefixOfStringInTable=IsPrefixOfStringInTable_x64_12 50 | -------------------------------------------------------------------------------- /StringTable2/StringTableAllocator.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | StringTableAllocator.c 8 | 9 | Abstract: 10 | 11 | This module wraps the Rtl bootstrap heap allocator. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | _Use_decl_annotations_ 18 | BOOL 19 | InitializeStringTableAllocatorFromRtlBootstrap( 20 | PRTL_BOOTSTRAP RtlBootstrap, 21 | PALLOCATOR Allocator 22 | ) 23 | { 24 | return RtlBootstrap->InitializeHeapAllocator(Allocator); 25 | } 26 | 27 | _Use_decl_annotations_ 28 | BOOL 29 | InitializeStringTableAllocator( 30 | PRTL Rtl, 31 | PALLOCATOR Allocator 32 | ) 33 | { 34 | return Rtl->InitializeHeapAllocator(Allocator); 35 | } 36 | 37 | 38 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 39 | -------------------------------------------------------------------------------- /StringTable2/StringTableConstants.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | StringTableConstants.h 8 | 9 | Abstract: 10 | 11 | This module defines constants related to the StringTable component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "stdafx.h" 22 | 23 | static CONST USHORT StringArraysPerTable = 16; 24 | 25 | 26 | FORCEINLINE 27 | USHORT 28 | GetNumberOfTablesRequiredForStringArray( 29 | _In_ PSTRING_ARRAY StringArray 30 | ) 31 | { 32 | return ALIGN_UP(StringArray->NumberOfElements, 16) / 16; 33 | } 34 | 35 | #ifdef __cplusplus 36 | }; // extern "C" { 37 | #endif 38 | 39 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 40 | -------------------------------------------------------------------------------- /StringTable2/StringTableConstants_C.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | PARALLEL_SUFFIX_MOVE_MASK32 4 | ParallelSuffix32HighBitFromEveryOtherByte = { 5 | 0xaaaaaaaa, // Mask (0b10101010101010101010101010101010) 6 | 0x22222222, // Move0 (0b00100010001000100010001000100010) 7 | 0x18181818, // Move1 (0b00011000000110000001100000011000) 8 | 0x07800780, // Move2 (0b00000111100000000000011110000000) 9 | 0x007f8000, // Move3 (0b00000000011111111000000000000000) 10 | 0x80000000, // Move4 (0b10000000000000000000000000000000) 11 | 0xffffffff, // Unused5 12 | 0x00000000 // Unused6 13 | }; 14 | 15 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 16 | -------------------------------------------------------------------------------- /StringTable2/StringTablePrivate.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | StringTablePrivate.h 8 | 9 | Abstract: 10 | 11 | This is the private header file for the StringTable component. It defines 12 | function typedefs and function declarations for all major (i.e. not local 13 | to the module) functions available for use by individual modules within 14 | this component. 15 | 16 | --*/ 17 | 18 | #pragma once 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "stdafx.h" 25 | 26 | //////////////////////////////////////////////////////////////////////////////// 27 | // Function typedefs and inline functions for internal modules. 28 | //////////////////////////////////////////////////////////////////////////////// 29 | 30 | COPY_STRING_ARRAY CopyStringArray; 31 | DESTROY_STRING_TABLE DestroyStringTable; 32 | CREATE_STRING_ARRAY_FROM_DELIMITED_STRING CreateStringArrayFromDelimitedString; 33 | CREATE_STRING_ARRAY_FROM_DELIMITED_STRING CreateStringArrayFromDelimitedString_2; 34 | CREATE_STRING_TABLE CreateSingleStringTable; 35 | MALLOC StringTableMalloc; 36 | CALLOC StringTableCalloc; 37 | REALLOC StringTableRealloc; 38 | FREE StringTableFree; 39 | FREE_POINTER StringTableFreePointer; 40 | INITIALIZE_ALLOCATOR StringTableInitializeAllocator; 41 | DESTROY_ALLOCATOR StringTableDestroyAllocator; 42 | 43 | #ifdef __cplusplus 44 | }; // extern "C" 45 | #endif 46 | 47 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 48 | -------------------------------------------------------------------------------- /StringTable2/StringTableTypes.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | StringTableTypes.c 8 | 9 | Abstract: 10 | 11 | Define trace store types. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // 18 | // Define the trace store types owned by this module. 19 | // 20 | 21 | // 22 | // N.B. Keep these sorted alphabetically. In vim, mark the start and end brace 23 | // with ma and mb, then issue the command: 24 | // 25 | // :'a,'b !sort -b -k 2 26 | // 27 | 28 | typedef struct _TRACE_STORE_TYPES { 29 | PSTRING_ARRAY StringArray; 30 | PSTRING_TABLE StringTable; 31 | } TRACE_STORE_TYPES; 32 | typedef TRACE_STORE_TYPES *PTRACE_STORE_TYPES; 33 | 34 | // 35 | // Type exposure functions. 36 | // 37 | 38 | DECLSPEC_DLLEXPORT 39 | VOID 40 | TraceStoreTypes( 41 | PTRACE_STORE_TYPES Types 42 | ) 43 | { 44 | UNREFERENCED_PARAMETER(Types); 45 | } 46 | 47 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 48 | -------------------------------------------------------------------------------- /StringTable2/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /StringTable2/stdafx.c: -------------------------------------------------------------------------------- 1 | 2 | #include "stdafx.h" 3 | 4 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 5 | -------------------------------------------------------------------------------- /StringTable2/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the StringTable component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include "../Rtl/Rtl.h" 23 | #include "StringTable.h" 24 | #include "StringTablePrivate.h" 25 | #include "StringTableConstants.h" 26 | #include "StringLoadStoreOperations.h" 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /StringTable2/targetver.h: -------------------------------------------------------------------------------- 1 |  2 | #pragma once 3 | 4 | // Including SDKDDKVer.h defines the highest available Windows platform. 5 | 6 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 7 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 8 | 9 | #include 10 | -------------------------------------------------------------------------------- /StringTable2BenchmarkExe/StringTable2BenchmarkExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {C6DBBA22-2FA0-4772-A28D-4525BDEFB889} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {ACF1A371-54BB-4A5F-9152-22088852D10F} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {33463A88-7B0B-46C6-8C42-075BE5F91E9A} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /StringTable2BenchmarkExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /StringTable2BenchmarkExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the BenchmarkExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/__C_specific_handler.h" 22 | #include "../StringTable.h" 23 | #include "../StringTable2/StringTableTestGlue.h" 24 | 25 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 26 | -------------------------------------------------------------------------------- /StringTable2BenchmarkExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /StringTable2Test/StringTable2Test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {2695609C-1146-42D5-B4F0-B3E67C35E3CF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {FFE06DD1-EE3E-446A-BFEC-F29EFEAC3F4D} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {6E19829F-48B9-4A72-9FDA-DD847C1B0B42} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /StringTable2Test/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // TestStringTable.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 | -------------------------------------------------------------------------------- /StringTable2Test/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 | // Headers for CppUnitTest 11 | #include "CppUnitTest.h" 12 | 13 | #include "../StringTable.h" 14 | #include "../StringTable2/StringTableTestGlue.h" 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /StringTable2Test/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 | -------------------------------------------------------------------------------- /StringTablePerformanceTest/stdafx.c: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // StringTablePerformanceTest.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 | -------------------------------------------------------------------------------- /StringTablePerformanceTest/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the StringTablePerformanceTest 12 | component. 13 | 14 | --*/ 15 | 16 | #pragma once 17 | 18 | #include "../StringTable/stdafx.h" 19 | 20 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 21 | -------------------------------------------------------------------------------- /StringTablePerformanceTest/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 | -------------------------------------------------------------------------------- /TestInjectionExe/TestInjection.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TestInjection.h 8 | 9 | Abstract: 10 | 11 | This is the header file for the TestInjection component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "stdafx.h" 22 | 23 | typedef 24 | LONG 25 | (TEST_INJECTION)( 26 | _In_ PRTL Rtl, 27 | _In_ PALLOCATOR Allocator, 28 | _In_ PTRACER_CONFIG TracerConfig, 29 | _In_ PDEBUG_ENGINE_SESSION DebugEngineSession 30 | ); 31 | typedef TEST_INJECTION *PTEST_INJECTION; 32 | 33 | typedef STARTUPINFOW *PSTARTUPINFOW; 34 | 35 | BOOL 36 | CreateThunkExe( 37 | PSTARTUPINFOW StartupInfo, 38 | PPROCESS_INFORMATION ProcessInfo 39 | ); 40 | 41 | extern PUNICODE_STRING InjectionThunkActiveDllPath; 42 | extern PUNICODE_STRING InjectionThunkDebugDllPath; 43 | extern PUNICODE_STRING InjectionThunkReleaseDllPath; 44 | 45 | extern PUNICODE_STRING TestInjectionActiveExePath; 46 | extern PUNICODE_STRING TestInjectionDebugExePath; 47 | extern PUNICODE_STRING TestInjectionReleaseExePath; 48 | 49 | extern ULONG TestDummyLong; 50 | 51 | TEST_INJECTION TestInjection; 52 | 53 | BOOL 54 | TestInjectThunk( 55 | PRTL Rtl, 56 | PALLOCATOR Allocator, 57 | PTRACER_CONFIG TracerConfig, 58 | PDEBUG_ENGINE_SESSION Session 59 | ); 60 | 61 | BOOL 62 | TestInjectionObjects( 63 | PRTL Rtl, 64 | PALLOCATOR Allocator, 65 | PTRACER_CONFIG TracerConfig, 66 | PDEBUG_ENGINE_SESSION Session 67 | ); 68 | 69 | ULONG TestInjectionMain(VOID); 70 | 71 | #ifdef __cplusplus 72 | } // extern "C" 73 | #endif 74 | 75 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 76 | -------------------------------------------------------------------------------- /TestInjectionExe/main.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | main.c 8 | 9 | Abstract: 10 | 11 | This module is the main entry point for the TestInjection executable. 12 | It implements mainCRTStartup(), which simply calls TestInjectionMain(). 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | VOID 19 | WINAPI 20 | mainCRTStartup() 21 | { 22 | ExitProcess(TestInjectionMain()); 23 | } 24 | 25 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 26 | -------------------------------------------------------------------------------- /TestInjectionExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /TestInjectionExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TestInjectionExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/__C_specific_handler.h" 22 | #include "../TracerHeap/TracerHeap.h" 23 | #include "../TracerConfig/TracerConfig.h" 24 | #include "../DebugEngine/DebugEngine.h" 25 | #include "TestInjection.h" 26 | 27 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 28 | -------------------------------------------------------------------------------- /TestInjectionExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TestStringTable/TestStringTable.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;hh;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;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /TestStringTable/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // TestStringTable.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 | -------------------------------------------------------------------------------- /TestStringTable/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 | // Headers for CppUnitTest 11 | #include "CppUnitTest.h" 12 | 13 | #include "../StringTable/StringTable.h" 14 | #include "../StringTable/StringTableTestGlue.h" 15 | #include "../TracerHeap/TracerHeap.h" 16 | 17 | // TODO: reference additional headers your program requires here 18 | -------------------------------------------------------------------------------- /TestStringTable/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 | -------------------------------------------------------------------------------- /ThunkExe/ThunkExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {3B64375B-F6A0-46F3-9F20-DBC4AF9D1DD0} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {49E5CB25-7A71-4E11-B740-1A35643C47A7} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {8AA924F8-E134-4C07-B391-D54F8B0505C7} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /ThunkExe/main.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | main.c 8 | 9 | Abstract: 10 | 11 | This module is the main entry point for the thunk executable. 12 | It implements mainCRTStartup(). 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | DECLSPEC_NORETURN 19 | VOID 20 | WINAPI 21 | mainCRTStartup() 22 | { 23 | LONG ExitCode; 24 | 25 | #if 0 26 | PRTL Rtl; 27 | PTRACER_CONFIG TracerConfig; 28 | ALLOCATOR Allocator; 29 | 30 | #pragma comment(lib, "TracerHeapLib") 31 | #pragma comment(lib, "TracerConfigLib") 32 | 33 | 34 | if (!DefaultHeapInitializeAllocator(&Allocator)) { 35 | ExitCode = 1; 36 | goto Error; 37 | } 38 | 39 | CHECKED_MSG( 40 | CreateAndInitializeTracerConfigAndRtl( 41 | &Allocator, 42 | (PUNICODE_STRING)&TracerRegistryPath, 43 | &TracerConfig, 44 | &Rtl 45 | ), 46 | "CreateAndInitializeTracerConfigAndRtl()" 47 | ); 48 | #endif 49 | 50 | ExitCode = 0; 51 | 52 | SleepEx(INFINITE, TRUE); 53 | 54 | goto Error; 55 | 56 | Error: 57 | 58 | ExitProcess(ExitCode); 59 | } 60 | 61 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 62 | -------------------------------------------------------------------------------- /ThunkExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /ThunkExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the ThunkExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/__C_specific_handler.h" 22 | #include "../DebugEngine/DebugEngine.h" 23 | #include "../TraceStore/TraceStore.h" 24 | #include "../TracerHeap/TracerHeap.h" 25 | #include "../TracerConfig/TracerConfig.h" 26 | #include "../TracerCore/TracerCore.h" 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /ThunkExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TlsTracerHeap/TlsTracerHeap.def: -------------------------------------------------------------------------------- 1 | LIBRARY TlsTracerHeap 2 | EXPORTS 3 | TlsIndex @1 DATA 4 | TlsTracerHeapSetTracerConfig @2 5 | TracerConfig @3 DATA 6 | -------------------------------------------------------------------------------- /TlsTracerHeap/TlsTracerHeapGlobals.c: -------------------------------------------------------------------------------- 1 | 2 | #include "stdafx.h" 3 | 4 | ULONG TlsIndex = TLS_OUT_OF_INDEXES; 5 | PTRACER_CONFIG TracerConfig = NULL; 6 | 7 | // 8 | // Copies of the old allocation routines that will be restored when the last 9 | // thread detaches. 10 | // 11 | 12 | PMALLOC OriginalMalloc = NULL; 13 | PCALLOC OriginalCalloc = NULL; 14 | PREALLOC OriginalRealloc = NULL; 15 | PFREE OriginalFree = NULL; 16 | PFREE_POINTER OriginalFreePointer = NULL; 17 | -------------------------------------------------------------------------------- /TlsTracerHeap/TlsTracerHeapProcessAttach.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | _Use_decl_annotations_ 4 | BOOL 5 | TlsTracerHeapProcessAttach( 6 | HMODULE Module, 7 | ULONG Reason, 8 | LPVOID Reserved 9 | ) 10 | { 11 | 12 | TlsIndex = TlsAlloc(); 13 | 14 | if (TlsIndex == TLS_OUT_OF_INDEXES) { 15 | OutputDebugStringA("TlsAlloc() returned TLS_OUT_OF_INDEXES.\n"); 16 | return FALSE; 17 | } 18 | 19 | return TRUE; 20 | } 21 | 22 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 23 | -------------------------------------------------------------------------------- /TlsTracerHeap/TlsTracerHeapProcessDetach.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TlsTracerHeapProcessDetach.c 8 | 9 | Abstract: 10 | 11 | This module implements the TlsTracerHeapProcessDetach routine. It is 12 | called by the dllmain module when a DLL_PROCESS_DETACH indication is 13 | received. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | _Use_decl_annotations_ 20 | BOOL 21 | TlsTracerHeapProcessDetach( 22 | HMODULE Module, 23 | ULONG Reason, 24 | LPVOID Reserved 25 | ) 26 | { 27 | BOOL Success; 28 | BOOL IsProcessTerminating; 29 | 30 | IsProcessTerminating = (Reserved != NULL); 31 | if (IsProcessTerminating) { 32 | return TRUE; 33 | } 34 | 35 | if (TlsIndex == TLS_OUT_OF_INDEXES) { 36 | 37 | // 38 | // We shouldn't be able to get into this state, as TlsAlloc() is 39 | // attempted at DLL load time (DLL_PROCESS_ATTACH), and will indicate 40 | // an error if it failed, blocking the DLL from being loaded. 41 | // 42 | 43 | goto End; 44 | } 45 | 46 | Success = TlsFree(TlsIndex); 47 | 48 | if (!Success) { 49 | OutputDebugStringA("TlsFree() failed.\n"); 50 | } 51 | 52 | End: 53 | 54 | // 55 | // Note that we always return TRUE here, even if we had a failure. We're 56 | // only called at DLL_PROCESS_DETACH, so there's not much we can do when 57 | // there is actually an error anyway. 58 | // 59 | 60 | return TRUE; 61 | } 62 | 63 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 64 | -------------------------------------------------------------------------------- /TlsTracerHeap/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the TlsTracerHeap component. It 12 | is responsible for hooking into the various process and thread attach and 13 | detach methods (via _DllMainCRTStartup) and calling the relevant callback. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | BOOL 20 | APIENTRY 21 | _DllMainCRTStartup( 22 | _In_ HMODULE Module, 23 | _In_ DWORD Reason, 24 | _In_ LPVOID Reserved 25 | ) 26 | { 27 | BOOL Success; 28 | 29 | switch (Reason) { 30 | 31 | case DLL_PROCESS_ATTACH: 32 | 33 | Success = TlsTracerHeapProcessAttach(Module, Reason, Reserved); 34 | break; 35 | 36 | case DLL_THREAD_ATTACH: 37 | 38 | Success = TlsTracerHeapThreadAttach(Module, Reason, Reserved); 39 | break; 40 | 41 | case DLL_THREAD_DETACH: 42 | 43 | Success = TlsTracerHeapThreadDetach(Module, Reason, Reserved); 44 | break; 45 | 46 | case DLL_PROCESS_DETACH: 47 | 48 | Success = TlsTracerHeapProcessDetach(Module, Reason, Reserved); 49 | break; 50 | } 51 | 52 | return Success; 53 | } 54 | 55 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 56 | -------------------------------------------------------------------------------- /TlsTracerHeap/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /TlsTracerHeap/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "targetver.h" 4 | 5 | #include 6 | #include "../Rtl/Rtl.h" 7 | #include "TlsTracerHeap.h" 8 | #include "TlsTracerHeapPrivate.h" 9 | 10 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 11 | -------------------------------------------------------------------------------- /TlsTracerHeap/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TraceStore/TraceStoreSession.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TraceStoreSession.c 8 | 9 | Abstract: 10 | 11 | This module implements trace store session functionality. Functions 12 | are provided for initializing a trace store session record. 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | _Use_decl_annotations_ 19 | BOOL 20 | InitializeTraceSession( 21 | PRTL Rtl, 22 | PTRACE_SESSION TraceSession, 23 | PULONG SizeOfTraceSession 24 | ) 25 | /*++ 26 | 27 | Routine Description: 28 | 29 | This routine initializes an allocated TRACE_SESSION record. 30 | 31 | Arguments: 32 | 33 | TBD. 34 | 35 | Return Value: 36 | 37 | TRUE on success, FALSE on failure. 38 | 39 | --*/ 40 | { 41 | if (!TraceSession) { 42 | if (SizeOfTraceSession) { 43 | *SizeOfTraceSession = sizeof(*TraceSession); 44 | } 45 | return FALSE; 46 | } 47 | 48 | if (!SizeOfTraceSession) { 49 | return FALSE; 50 | } 51 | 52 | if (*SizeOfTraceSession < sizeof(*TraceSession)) { 53 | return FALSE; 54 | } else if (*SizeOfTraceSession == 0) { 55 | *SizeOfTraceSession = sizeof(*TraceSession); 56 | } 57 | 58 | SecureZeroMemory(TraceSession, sizeof(*TraceSession)); 59 | 60 | TraceSession->Rtl = Rtl; 61 | 62 | GetSystemTimeAsFileTime(&TraceSession->SystemTime); 63 | return TRUE; 64 | 65 | } 66 | 67 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 68 | -------------------------------------------------------------------------------- /TraceStore/TraceStoreSqlite3Schemas.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TraceStoreSqliteSchemas.c 8 | 9 | Abstract: 10 | 11 | This module defines sqlite3 virtual table schemas. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // 18 | // Trace Store schemas. 19 | // 20 | 21 | extern CONST LPCSTR TraceStoreSchemas[]; 22 | extern CONST CHAR TraceStoreIntervalSchema[]; 23 | extern CONST PTRACE_STORE_SQLITE3_COLUMN TraceStoreSqlite3Columns[]; 24 | 25 | // 26 | // Metadata Store schemas. 27 | // 28 | 29 | extern CONST CHAR TraceStoreMetadataInfoSchema[]; 30 | extern CONST CHAR TraceStoreAllocationSchema[]; 31 | extern CONST CHAR TraceStoreRelocationSchema[]; 32 | extern CONST CHAR TraceStoreAddressSchema[]; 33 | extern CONST CHAR TraceStoreAddressRangeSchema[]; 34 | extern CONST CHAR TraceStoreAllocationTimestampSchema[]; 35 | extern CONST CHAR TraceStoreAllocationTimestampDeltaSchema[]; 36 | extern CONST CHAR TraceStoreSynchronizationSchema[]; 37 | extern CONST CHAR TraceStoreInfoSchema[]; 38 | 39 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 40 | -------------------------------------------------------------------------------- /TraceStore/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the TraceStore DLL. It is responsible 12 | for hooking into the DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH messages 13 | in order to facilitate trace stores rundown functionality. 14 | 15 | --*/ 16 | 17 | #include "stdafx.h" 18 | 19 | BOOL 20 | APIENTRY 21 | _DllMainCRTStartup( 22 | _In_ HMODULE Module, 23 | _In_ DWORD Reason, 24 | _In_ LPVOID Reserved 25 | ) 26 | { 27 | BOOL IsProcessTerminating = FALSE; 28 | switch (Reason) { 29 | case DLL_PROCESS_ATTACH: 30 | if (!TraceStoreSqlite3TlsProcessAttach(Module, Reason, Reserved)) { 31 | return FALSE; 32 | } 33 | if (!InitializeGlobalTraceStoresRundown()) { 34 | return FALSE; 35 | } 36 | break; 37 | case DLL_THREAD_ATTACH: 38 | break; 39 | case DLL_THREAD_DETACH: 40 | break; 41 | case DLL_PROCESS_DETACH: 42 | RundownGlobalTraceStores(); 43 | DestroyGlobalTraceStoresRundown(); 44 | if (!TraceStoreSqlite3TlsProcessDetach(Module, Reason, Reserved)) { 45 | NOTHING; 46 | } 47 | break; 48 | } 49 | 50 | return TRUE; 51 | } 52 | 53 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 54 | -------------------------------------------------------------------------------- /TraceStore/stdafx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.c 8 | 9 | Abstract: 10 | 11 | This is the precompiled source file for the TraceStore component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /TraceStore/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TraceStore component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | // 20 | // appears to need _PREFAST_ defined. 21 | // 22 | 23 | #ifndef _PREFAST_ 24 | #define _PREFAST_ 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include "../Rtl/Rtl.h" 33 | #include "../Rtl/Sqlite.h" 34 | #include "../Rtl/Cu.h" 35 | #include "../Rtl/__C_specific_handler.h" 36 | #include "../Rtl/atexit.h" 37 | #include "../TracerConfig/TracerConfig.h" 38 | #include "../TracerHeap/TracerHeap.h" 39 | #include "../DebugEngine/DebugEngine.h" 40 | #include "TraceStoreIndex.h" 41 | #include "TraceStore.h" 42 | #include "TraceStorePrivate.h" 43 | #include "TraceStoreConstants.h" 44 | 45 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 46 | -------------------------------------------------------------------------------- /TraceStore/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TraceStoreSqlite3Ext/TraceStoreSqlite3Ext.def: -------------------------------------------------------------------------------- 1 | LIBRARY TraceStoreSqlite3Ext 2 | EXPORTS 3 | sqlite3_extension_init=TraceStoreSqlite3ExtInit 4 | -------------------------------------------------------------------------------- /TraceStoreSqlite3Ext/TraceStoreSqlite3Ext.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TraceStoreSqlite3ExtLoader.h 8 | 9 | Abstract: 10 | 11 | This is the main header file for the TraceStore sqlite3 extension component. 12 | It defines structures and functions related to the implementation of the 13 | component. 14 | 15 | --*/ 16 | 17 | #pragma once 18 | 19 | #include "stdafx.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef 26 | VOID 27 | (INITIALIZE_ALLOCATOR_FROM_SQLITE3)( 28 | _Inout_ PALLOCATOR Allocator, 29 | _In_ PCSQLITE3 Sqlite3 30 | ); 31 | typedef INITIALIZE_ALLOCATOR_FROM_SQLITE3 *PINITIALIZE_ALLOCATOR_FROM_SQLITE3; 32 | extern INITIALIZE_ALLOCATOR_FROM_SQLITE3 InitializeAllocatorFromSqlite3; 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif 37 | 38 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 39 | -------------------------------------------------------------------------------- /TraceStoreSqlite3Ext/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the TraceStoreSqlite3ExtLoader DLL. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | BOOL 18 | APIENTRY 19 | _DllMainCRTStartup( 20 | _In_ HMODULE Module, 21 | _In_ DWORD Reason, 22 | _In_ LPVOID Reserved 23 | ) 24 | { 25 | switch (Reason) { 26 | case DLL_PROCESS_ATTACH: 27 | break; 28 | case DLL_THREAD_ATTACH: 29 | break; 30 | case DLL_THREAD_DETACH: 31 | break; 32 | case DLL_PROCESS_DETACH: 33 | break; 34 | } 35 | 36 | return TRUE; 37 | } 38 | 39 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 40 | -------------------------------------------------------------------------------- /TraceStoreSqlite3Ext/stdafx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.c 8 | 9 | Abstract: 10 | 11 | This is the precompiled source file for the TraceStoreSqlite3ExtLoader component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /TraceStoreSqlite3Ext/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TraceStoreSqlite3ExtLoader 12 | component. 13 | 14 | --*/ 15 | 16 | #pragma once 17 | 18 | #include "targetver.h" 19 | 20 | // 21 | // appears to need _PREFAST_ defined. 22 | // 23 | 24 | #ifndef _PREFAST_ 25 | #define _PREFAST_ 26 | #endif 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include "../Rtl/Rtl.h" 34 | #include "../Rtl/Sqlite.h" 35 | #include "../Rtl/__C_specific_handler.h" 36 | #include "../TracerConfig/TracerConfig.h" 37 | #include "../TraceStore/TraceStore.h" 38 | #include "TraceStoreSqlite3Ext.h" 39 | 40 | #ifdef _TRACE_STORE_SQLITE3_EXT_INTERNAL_BUILD 41 | #include "../TraceStore/TraceStorePrivate.h" 42 | #endif 43 | 44 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 45 | -------------------------------------------------------------------------------- /TraceStoreSqlite3Ext/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TracedPythonExe/TracedPythonExe.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/TracedPythonExe/TracedPythonExe.c -------------------------------------------------------------------------------- /TracedPythonExe/TracedPythonExe.def: -------------------------------------------------------------------------------- 1 | LIBRARY tpython 2 | EXPORTS 3 | Main @1 4 | -------------------------------------------------------------------------------- /TracedPythonExe/TracedPythonExe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/TracedPythonExe/TracedPythonExe.h -------------------------------------------------------------------------------- /TracedPythonExe/TracedPythonExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {598CDF90-596D-4C82-A2CE-4D54418C0881} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {18D7DD82-0FA5-4287-927A-B6316D2BA1A6} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {79880724-CCDD-4663-BA98-6D653647D004} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Source Files 42 | 43 | 44 | -------------------------------------------------------------------------------- /TracedPythonExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /TracedPythonExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TracedPythonExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/__C_specific_handler.h" 22 | #include "../Python/Python.h" 23 | #include "../TraceStore/TraceStore.h" 24 | #include "../TracerHeap/TracerHeap.h" 25 | #include "../PythonTracer/PythonTracer.h" 26 | #include "../TracerConfig/TracerConfig.h" 27 | #include "../TracedPythonSession/TracedPythonSession.h" 28 | 29 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 30 | -------------------------------------------------------------------------------- /TracedPythonExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TracedPythonSession/dllmain.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | BOOL 4 | APIENTRY 5 | _DllMainCRTStartup( 6 | _In_ HMODULE Module, 7 | _In_ DWORD Reason, 8 | _In_ LPVOID Reserved 9 | ) 10 | { 11 | switch (Reason) { 12 | case DLL_PROCESS_ATTACH: 13 | break; 14 | case DLL_THREAD_ATTACH: 15 | break; 16 | case DLL_THREAD_DETACH: 17 | break; 18 | case DLL_PROCESS_DETACH: 19 | break; 20 | } 21 | 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /TracedPythonSession/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /TracedPythonSession/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TracedPythonSession component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | 21 | #include "../Rtl/Rtl.h" 22 | #include "../Python/Python.h" 23 | #include "../TracerConfig/TracerConfig.h" 24 | #include "../TracerHeap/TracerHeap.h" 25 | #include "../TraceStore/TraceStore.h" 26 | #include "../StringTable.h" 27 | #include "../PythonTracer/PythonTracer.h" 28 | #include "TracedPythonSession.h" 29 | 30 | #ifdef _TRACED_PYTHON_SESSION_INTERNAL_BUILD 31 | #include "TracedPythonSessionPrivate.h" 32 | #endif 33 | 34 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 35 | -------------------------------------------------------------------------------- /TracedPythonSession/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TracerConfig/TracerConfig.def: -------------------------------------------------------------------------------- 1 | LIBRARY TracerConfig 2 | EXPORTS 3 | TracerConfig=GlobalTracerConfig @1 DATA 4 | CreateTraceSessionDirectory=CreateGlobalTraceSessionDirectory @2 5 | -------------------------------------------------------------------------------- /TracerConfig/TracerConfigDebug.def: -------------------------------------------------------------------------------- 1 | LIBRARY TracerConfig 2 | EXPORTS 3 | TracerConfig=GlobalTracerConfig @1 DATA 4 | CreateTraceSessionDirectory=CreateGlobalTraceSessionDirectory @2 5 | DestroyTraceSessionDirectories=DestroyGlobalTraceSessionDirectory @3 6 | -------------------------------------------------------------------------------- /TracerConfig/TracerConfigRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 5 | -------------------------------------------------------------------------------- /TracerConfig/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This module is the DLL main entry point for the TracerConfig component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | _Use_decl_annotations_ 18 | VOID 19 | _DebugBreak( 20 | VOID 21 | ) 22 | { 23 | __debugbreak(); 24 | } 25 | 26 | BOOL 27 | APIENTRY 28 | _DllMainCRTStartup( 29 | _In_ HMODULE Module, 30 | _In_ DWORD Reason, 31 | _In_ LPVOID Reserved 32 | ) 33 | { 34 | switch (Reason) { 35 | case DLL_PROCESS_ATTACH: 36 | break; 37 | case DLL_THREAD_ATTACH: 38 | break; 39 | case DLL_THREAD_DETACH: 40 | break; 41 | case DLL_PROCESS_DETACH: 42 | break; 43 | } 44 | 45 | return TRUE; 46 | } 47 | 48 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 49 | -------------------------------------------------------------------------------- /TracerConfig/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /TracerConfig/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TracerConfig component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include "../Rtl/Rtl.h" 20 | #include "../TracerHeap/TracerHeap.h" 21 | #include "TracerConfig.h" 22 | #include "TracerConfigConstants.h" 23 | 24 | #ifdef _TRACER_CONFIG_INTERNAL_BUILD 25 | #include "TracerConfigPrivate.h" 26 | #endif 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /TracerConfig/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TracerControlDriver/.gitignore: -------------------------------------------------------------------------------- 1 | TracerControlDriver.vcxproj.user 2 | -------------------------------------------------------------------------------- /TracerControlDriver/DriverUtil.asm: -------------------------------------------------------------------------------- 1 | title "Tracer Control Driver Utility Routines" 2 | ;++ 3 | ; 4 | ; Copyright (c) Trent Nelson, 2016. 5 | ; 6 | ; Module Name: 7 | ; 8 | ; DriverUtil.asm 9 | ; 10 | ; Abstract: 11 | ; 12 | ; This module implements miscellaneous assembly routines called by the 13 | ; TracerControl kernel driver. 14 | ; 15 | ;-- 16 | 17 | 18 | include ksamd64.inc 19 | 20 | ;++ 21 | ; 22 | ; VOID 23 | ; ReadCr3(_Out_ PULONGLONG Buffer) 24 | ; 25 | ; Routine Description: 26 | ; 27 | ; This routine reads the Cr3 control register and writes the contents into 28 | ; the destination address pointed to by Buffer. 29 | ; 30 | ; Arguments: 31 | ; 32 | ; Buffer - A pointer to the destination address. 33 | ; 34 | ; Return Value: 35 | ; 36 | ; None 37 | ; 38 | ;-- 39 | 40 | LEAF_ENTRY ReadCr3, _TEXT$00 41 | 42 | mov rax, Cr3 ; Save Cr3 into rax. 43 | mov [rcx], rax ; Write to user's buffer. 44 | xor rax, rax ; Clear rax as we don't return a value. 45 | ret 46 | 47 | LEAF_END ReadCr3, _TEXT$00 48 | 49 | ;++ 50 | ; 51 | ; VOID 52 | ; ReadDr7(_Out_ PULONGLONG Buffer) 53 | ; 54 | ; Routine Description: 55 | ; 56 | ; This routine reads the Dr7 control register and writes the contents into 57 | ; the destination address pointed to by Buffer. 58 | ; 59 | ; Arguments: 60 | ; 61 | ; Buffer - A pointer to the destination address. 62 | ; 63 | ; Return Value: 64 | ; 65 | ; None 66 | ; 67 | ;-- 68 | 69 | LEAF_ENTRY ReadDr7, _TEXT$00 70 | 71 | mov rax, Dr7 ; Save Dr7 into rax. 72 | mov [rcx], rax ; Write to user's buffer. 73 | xor rax, rax ; Clear rax as we don't return a value. 74 | ret 75 | 76 | LEAF_END ReadDr7, _TEXT$00 77 | 78 | ; vim:set tw=80 ts=8 sw=8 sts=8 expandtab syntax=masm formatoptions=croql : 79 | 80 | end 81 | -------------------------------------------------------------------------------- /TracerControlDriver/DriverUtil.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | 4 | --*/ 5 | 6 | #pragma once 7 | 8 | // 9 | // ReadCr3 10 | // 11 | 12 | typedef 13 | VOID 14 | (READ_CR3)( 15 | _Out_ PULONGLONG Buffer 16 | ); 17 | 18 | typedef READ_CR3 *PREAD_CR3; 19 | 20 | extern READ_CR3 ReadCr3; 21 | 22 | // 23 | // ReadDr7 24 | // 25 | 26 | typedef 27 | VOID 28 | (READ_DR7)( 29 | _Out_ PULONGLONG Buffer 30 | ); 31 | 32 | typedef READ_DR7 *PREAD_DR7; 33 | 34 | extern READ_DR7 ReadDr7; 35 | 36 | 37 | // vim: set ts=8 sw=4 sts=4 expandtab si ai : 38 | -------------------------------------------------------------------------------- /TracerControlDriver/SDV-default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -halt_labels -gate RunDispatchFunction -driver -arrays -no_pa 3 -field_pa_version nocollapse -max_fields_nocollapse 100 4 | 5 | 6 | 7 | 100000 8 | 3000 9 | 2500 10 | 4 11 | 12 | no_cfg_support.lib,bufferoverflowfastfailk.lib,csq.lib,int64.lib,rtlver.lib,ntstrsafe.lib,sehupd.lib,wdmsec.lib,wdm.lib,ntoskrnl.lib,BufferOverflowK.lib,hal.lib,wmilib.lib,memcmp.lib,usbd.lib,armrt.lib 13 | engineq 14 | 15 | esp 16 | -------------------------------------------------------------------------------- /TracerControlDriver/TracerControlConstants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stdafx.h" 4 | #include 5 | 6 | typedef CONST UNICODE_STRING TRACER_CONTROL_DEVICE_NAME; 7 | typedef CONST UNICODE_STRING TRACER_CONTROL_WIN32_DEVICE_NAME; 8 | 9 | static TRACER_CONTROL_DEVICE_NAME TracerControlDeviceName = \ 10 | RTL_CONSTANT_STRING(L"\\Device\\TracerControlDriver"); 11 | 12 | static TRACER_CONTROL_WIN32_DEVICE_NAME TracerControlWin32DeviceName = \ 13 | RTL_CONSTANT_STRING(L"\\Global??\\TracerControl"); 14 | 15 | //static TRACER_CONTROL_DEVICE_NAME DeviceName = \ 16 | // RTL_CONSTANT_STRING(L"\\Device\\TracerControlDriver"); 17 | 18 | //static CONST UNICODE_STRING DeviceName = \ 19 | // RTL_CONSTANT_STRING(L"\\Device\\TracerControlDriver"); 20 | 21 | //static CONST UNICODE_STRING Win32DeviceName = \ 22 | // RTL_CONSTANT_STRING(L"\\Global??\\TracerControl"); 23 | 24 | 25 | // vim: set ts=8 sw=4 sts=4 expandtab si ai : 26 | -------------------------------------------------------------------------------- /TracerControlDriver/TracerControlDebug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if DBG 4 | #define ENTER(Name) DbgPrint("TracerControl!" Name ": Entered.\n") 5 | #define LEAVE(Name) DbgPrint("TracerControl!" Name ": Leaving.\n") 6 | #define LEAVE_STATUS(Name, Status) ( \ 7 | DbgPrint( \ 8 | "TracerControl!" Name ": Leaving (NTSTATUS = 0x%0x).\n", \ 9 | Status \ 10 | ) \ 11 | ) 12 | #define DEBUG(Message) DbgPrint("TracerControl!" Message) 13 | #define DEBUG1(Message, Arg1) DbgPrint("TracerControl!" Message, Arg1) 14 | #define DEBUG2(Message, Arg1, Arg2) \ 15 | DbgPrint("TracerControl!" Message, Arg1, Arg2) 16 | #else 17 | #define ENTER(Name) 18 | #define LEAVE(Name) 19 | #define LEAVE_STATUS(Name, Status) 20 | #define DEBUG(Message) 21 | #define DEBUG1(Message, Arg1) 22 | #define DEBUG2(Message, Arg1, Arg2) 23 | #endif 24 | 25 | // vim: set ts=8 sw=4 sts=4 expandtab si ai : 26 | -------------------------------------------------------------------------------- /TracerControlDriver/TracerControlDriver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stdafx.h" 4 | #include 5 | #include "TracerControlDriverIoctl.h" 6 | #include "TracerControlDebug.h" 7 | #include "TracerControlConstants.h" 8 | #include "DriverUtil.h" 9 | 10 | // 11 | // TracerControl Driver's Device Extension Object. 12 | // 13 | 14 | typedef struct _Struct_size_bytes_(SizeInBytes) _TRACER_CONTROL_DEV_EXT { 15 | USHORT Size; 16 | USHORT Padding[3]; 17 | } TRACER_CONTROL_DEV_EXT, *PTRACER_CONTROL_DEV_EXT; 18 | 19 | // 20 | // Driver entry and dispatch type definitions. 21 | // 22 | 23 | typedef DRIVER_INITIALIZE TRACER_CONTROL_INITIALIZE; 24 | typedef DRIVER_UNLOAD TRACER_CONTROL_UNLOAD; 25 | 26 | DRIVER_INITIALIZE DriverEntry; 27 | DRIVER_UNLOAD TracerControlUnload; 28 | 29 | typedef 30 | _Dispatch_type_(IRP_MJ_DEVICE_CONTROL) 31 | DRIVER_DISPATCH 32 | TRACER_CONTROL_DEVICE_CONTROL, *PTRACER_CONTROL_DEVICE_CONTROL; 33 | 34 | _Dispatch_type_(IRP_MJ_DEVICE_CONTROL) 35 | DRIVER_DISPATCH 36 | TracerControlDeviceControl; 37 | 38 | typedef 39 | _Dispatch_type_(IRP_MJ_CREATE) 40 | DRIVER_DISPATCH 41 | TRACER_CONTROL_CREATE, *PTRACER_CONTROL_CREATE; 42 | 43 | _Dispatch_type_(IRP_MJ_CREATE) 44 | DRIVER_DISPATCH 45 | TracerControlCreate; 46 | 47 | typedef 48 | _Dispatch_type_(IRP_MJ_CLOSE) 49 | DRIVER_DISPATCH 50 | TRACER_CONTROL_CLOSE, *PTRACER_CONTROL_CLOSE; 51 | 52 | _Dispatch_type_(IRP_MJ_CLOSE) 53 | DRIVER_DISPATCH 54 | TracerControlClose; 55 | 56 | typedef 57 | _Dispatch_type_(IRP_MJ_WRITE) 58 | DRIVER_DISPATCH 59 | TRACER_CONTROL_WRITE, *PTRACER_CONTROL_WRITE; 60 | 61 | _Dispatch_type_(IRP_MJ_WRITE) 62 | DRIVER_DISPATCH 63 | TracerControlWrite; 64 | 65 | typedef 66 | _Dispatch_type_(IRP_MJ_READ) 67 | DRIVER_DISPATCH 68 | TRACER_CONTROL_READ, *PTRACER_CONTROL_READ; 69 | 70 | _Dispatch_type_(IRP_MJ_READ) 71 | DRIVER_DISPATCH 72 | TracerControlRead; 73 | 74 | // vim: set ts=8 sw=4 sts=4 expandtab si ai : 75 | -------------------------------------------------------------------------------- /TracerControlDriver/TracerControlDriver.inf: -------------------------------------------------------------------------------- 1 | ; 2 | ; TracerControlDriver.inf 3 | ; 4 | 5 | [Version] 6 | Signature="$WINDOWS NT$" 7 | Class= 8 | ClassGuid= 9 | Provider= 10 | DriverVer= 11 | CatalogFile= 12 | 13 | [DestinationDirs] 14 | DefaultDestDir = 12 15 | 16 | 17 | [SourceDisksNames] 18 | 1 = %DiskName%,,,"" 19 | 20 | [SourceDisksFiles] 21 | 22 | 23 | [Manufacturer] 24 | %ManufacturerName%=Standard,NT$ARCH$ 25 | 26 | [Standard.NT$ARCH$] 27 | 28 | 29 | [Strings] 30 | ManufacturerName="" 31 | ClassName="" 32 | DiskName="TracerControlDriver Source Disk" 33 | -------------------------------------------------------------------------------- /TracerControlDriver/TracerControlDriverIoctl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define FILE_DEVICE_TRACER_CONTROL 52118 4 | 5 | #define IOCTL_TRACER_CONTROL_DEVEXT_SIZE \ 6 | CTL_CODE(FILE_DEVICE_TRACER_CONTROL, \ 7 | 2049, \ 8 | METHOD_BUFFERED, \ 9 | FILE_ANY_ACCESS) 10 | 11 | #define IOCTL_TRACER_CONTROL_READ_CR3 \ 12 | CTL_CODE(FILE_DEVICE_TRACER_CONTROL, \ 13 | 2050, \ 14 | METHOD_BUFFERED, \ 15 | FILE_ANY_ACCESS) 16 | 17 | #define IOCTL_TRACER_CONTROL_READ_DR7 \ 18 | CTL_CODE(FILE_DEVICE_TRACER_CONTROL, \ 19 | 2051, \ 20 | METHOD_BUFFERED, \ 21 | FILE_ANY_ACCESS) 22 | 23 | // vim: set ts=8 sw=4 sts=4 expandtab si ai : 24 | -------------------------------------------------------------------------------- /TracerControlDriver/runsdvui.cmd: -------------------------------------------------------------------------------- 1 | cd /d "C:\Users\r541964\Home\src\tracer\TracerControlDriver" &&msbuild "TracerControlDriver.vcxproj" /t:sdv /p:inputs="/devenv /check" /p:configuration="Release" /p:platform="x64" 2 | exit 0 -------------------------------------------------------------------------------- /TracerControlDriver/sdv-map.h: -------------------------------------------------------------------------------- 1 | //Approved=false 2 | //DriverEntry 3 | #define fun_DriverEntry DriverEntry 4 | //TracerControlUnload 5 | #define fun_DriverUnload TracerControlUnload 6 | //TracerControlClose 7 | #define fun_IRP_MJ_CLOSE TracerControlClose 8 | //TracerControlCreate 9 | #define fun_IRP_MJ_CREATE TracerControlCreate 10 | //TracerControlDeviceControl 11 | #define fun_IRP_MJ_DEVICE_CONTROL TracerControlDeviceControl 12 | //TracerControlRead 13 | #define fun_IRP_MJ_READ TracerControlRead 14 | //TracerControlWrite 15 | #define fun_IRP_MJ_WRITE TracerControlWrite 16 | -------------------------------------------------------------------------------- /TracerControlDriver/sdv-user.sdv: -------------------------------------------------------------------------------- 1 | Default.sdv -------------------------------------------------------------------------------- /TracerControlDriver/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" -------------------------------------------------------------------------------- /TracerControlDriver/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "TracerControlDriverIoctl.h" 5 | #include "TracerControlDriver.h" 6 | -------------------------------------------------------------------------------- /TracerCore/TracerCore.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TracerCore.c 8 | 9 | Abstract: 10 | 11 | This module provides routines for the TracerCore component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /TracerCore/TracerCore.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {6A80F336-BDAB-40D8-969E-54A8BC279423} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {A192CC25-F4EB-4462-BF24-7E709F782FD9} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {9B1412A1-FCCD-4DC3-8417-AA61B4D4D051} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | -------------------------------------------------------------------------------- /TracerCore/TracerCorePrivate.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | TracerCorePrivate.h 8 | 9 | Abstract: 10 | 11 | This is the private header file for the TracerCore component. It defines function 12 | typedefs and function declarations for all major (i.e. not local to the 13 | module) functions available for use by individual modules within this 14 | component. 15 | 16 | --*/ 17 | 18 | #ifndef _TRACER_CORE_INTERNAL_BUILD 19 | #error TracerCorePrivate.h being included but _TRACER_CORE_INTERNAL_BUILD not set. 20 | #endif 21 | 22 | #pragma once 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include "stdafx.h" 29 | 30 | // 31 | // Private function declarations. 32 | // 33 | 34 | #pragma component(browser, off) 35 | #pragma component(browser, on) 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif 40 | 41 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 42 | -------------------------------------------------------------------------------- /TracerCore/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the TracerCore DLL. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | BOOL IsProcessTerminating = FALSE; 18 | 19 | BOOL 20 | APIENTRY 21 | _DllMainCRTStartup( 22 | _In_ HMODULE Module, 23 | _In_ DWORD Reason, 24 | _In_ LPVOID Reserved 25 | ) 26 | { 27 | UNREFERENCED_PARAMETER(Module); 28 | 29 | switch (Reason) { 30 | case DLL_PROCESS_ATTACH: 31 | break; 32 | case DLL_THREAD_ATTACH: 33 | break; 34 | case DLL_THREAD_DETACH: 35 | break; 36 | case DLL_PROCESS_DETACH: 37 | IsProcessTerminating = (Reserved != NULL); 38 | break; 39 | } 40 | 41 | return TRUE; 42 | } 43 | 44 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 45 | -------------------------------------------------------------------------------- /TracerCore/stdafx.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.c 8 | 9 | Abstract: 10 | 11 | This is the precompiled source file for the TracerCore component. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 18 | -------------------------------------------------------------------------------- /TracerCore/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TracerCore component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include "../Rtl/Rtl.h" 22 | #include "../DebugEngine/DebugEngine.h" 23 | #include "../DebugEngine/DebugEngineInterfaces.h" 24 | #include "../TraceStore/TraceStore.h" 25 | #include "../TracerHeap/TracerHeap.h" 26 | #include "../TracerConfig/TracerConfig.h" 27 | #include "TracerCore.h" 28 | 29 | #ifdef _TRACER_CORE_INTERNAL_BUILD 30 | #include "TracerCorePrivate.h" 31 | #endif 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif 36 | 37 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 38 | -------------------------------------------------------------------------------- /TracerCore/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TracerCoreLib/TracerCoreLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {350C9D3F-33A8-4EA1-9A7D-8787A1EFBD92} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {09F15BF1-D5A3-4D59-92C5-BBEE2200B99A} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {68BE85F1-95EB-47DA-A01C-76B4B8F89473} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /TracerExe/TracerExe.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {99320348-7629-4817-8BBB-2EFBBB078192} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {C7735912-B86C-49A3-B746-700E36CE9B85} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {D439CF05-E68D-4071-8A95-7E0FB881A9EA} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | -------------------------------------------------------------------------------- /TracerExe/main.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2017 Trent Nelson 4 | 5 | Module Name: 6 | 7 | main.c 8 | 9 | Abstract: 10 | 11 | This module is the main entry point for the tracer executable. 12 | It implements mainCRTStartup(), which simply calls TracerExeMain(). 13 | 14 | --*/ 15 | 16 | #include "stdafx.h" 17 | 18 | DECLSPEC_NORETURN 19 | VOID 20 | WINAPI 21 | mainCRTStartup() 22 | { 23 | ExitProcess(TracerExeMain()); 24 | } 25 | 26 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 27 | -------------------------------------------------------------------------------- /TracerExe/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /TracerExe/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TracerExe component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include 20 | #include "../Rtl/Rtl.h" 21 | #include "../Rtl/HeapAllocator.h" 22 | #include "../Rtl/__C_specific_handler.h" 23 | #include "../DebugEngine/DebugEngine.h" 24 | #include "../TraceStore/TraceStore.h" 25 | #include "../TracerConfig/TracerConfig.h" 26 | #include "../TracerCore/TracerCore.h" 27 | 28 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 29 | -------------------------------------------------------------------------------- /TracerExe/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TracerHeap/DefaultTracerHeapPrivate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Memory.h" 4 | 5 | MALLOC DefaultHeapMalloc; 6 | CALLOC DefaultHeapCalloc; 7 | REALLOC DefaultHeapRealloc; 8 | FREE DefaultHeapFree; 9 | INITIALIZE_ALLOCATOR DefaultHeapInitializeAllocator; 10 | DESTROY_ALLOCATOR DefaultHeapDestroyAllocator; 11 | 12 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 13 | -------------------------------------------------------------------------------- /TracerHeap/TracerHeap.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {88605708-5C65-47FE-A251-218DF4B73730} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {D791FEC6-1A64-4755-B983-063C89A8D1B2} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {C1A17A44-3223-430C-B01E-B4378FAC045B} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /TracerHeap/dllmain.c: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | dllmain.c 8 | 9 | Abstract: 10 | 11 | This is the DLL main entry point for the TracerHeap DLL. 12 | 13 | --*/ 14 | 15 | #include "stdafx.h" 16 | 17 | BOOL 18 | APIENTRY 19 | _DllMainCRTStartup( 20 | _In_ HMODULE Module, 21 | _In_ DWORD Reason, 22 | _In_ LPVOID Reserved 23 | ) 24 | { 25 | switch (Reason) { 26 | case DLL_PROCESS_ATTACH: 27 | break; 28 | case DLL_THREAD_ATTACH: 29 | break; 30 | case DLL_THREAD_DETACH: 31 | break; 32 | case DLL_PROCESS_DETACH: 33 | break; 34 | } 35 | 36 | return TRUE; 37 | } 38 | 39 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 40 | -------------------------------------------------------------------------------- /TracerHeap/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 4 | -------------------------------------------------------------------------------- /TracerHeap/stdafx.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2016 Trent Nelson 4 | 5 | Module Name: 6 | 7 | stdafx.h 8 | 9 | Abstract: 10 | 11 | This is the precompiled header file for the TracerHeap component. 12 | 13 | --*/ 14 | 15 | #pragma once 16 | 17 | #include "targetver.h" 18 | 19 | #include "../Rtl/Rtl.h" 20 | #include "TracerHeap.h" 21 | 22 | // vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 23 | -------------------------------------------------------------------------------- /TracerHeap/targetver.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /TracerHeapLib/TracerHeapLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | 12 | 13 | Header Files 14 | 15 | 16 | Header Files 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | {c175e934-e82a-4505-aff9-092872410540} 25 | 26 | 27 | {f8b9c70b-ea37-4041-b41c-b74b7c2fba9f} 28 | 29 | 30 | -------------------------------------------------------------------------------- /TypeInfoDump.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/TypeInfoDump.exe -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 2 | 0.1.8.{build} 3 | 4 | image: 5 | #- Visual Studio 2015 6 | - Visual Studio 2017 7 | 8 | configuration: 9 | Release 10 | 11 | platform: 12 | x64 13 | 14 | build: 15 | project: 16 | Tracer.sln 17 | -------------------------------------------------------------------------------- /build-ptx.bat: -------------------------------------------------------------------------------- 1 | rem @echo off 2 | 3 | @set sources=TraceStoreKernels 4 | 5 | @for %%s in (%sources%) do ( 6 | nvcc -ptx Cu\%%s.cu -o x64\Debug\%%s.ptx ^ 7 | -Wno-deprecated-gpu-targets ^ 8 | --cudart=none ^ 9 | --device-debug ^ 10 | --generate-line-info ^ 11 | --restrict 12 | 13 | nvcc -ptx Cu\%%s.cu -o x64\Release\%%s.ptx ^ 14 | -Wno-deprecated-gpu-targets ^ 15 | --optimize 3 ^ 16 | --generate-line-info ^ 17 | --restrict 18 | ) 19 | 20 | @rem vim:set ts=8 sw=4 sts=4 tw=80 expandtab : 21 | -------------------------------------------------------------------------------- /cdb-simple-commands.txt: -------------------------------------------------------------------------------- 1 | bp ModuleLoader!MaybeBreak 2 | g 3 | -------------------------------------------------------------------------------- /cdb-simple.bat: -------------------------------------------------------------------------------- 1 | cdb -2 -cf cdb-simple-commands.txt x64\Debug\ModuleLoader.exe 2 | -------------------------------------------------------------------------------- /ctags.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/ctags.exe -------------------------------------------------------------------------------- /ctags.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tpn/tracer/221ae67558fa08a8a45ddd82c237417c0085b5a5/ctags.pdb -------------------------------------------------------------------------------- /dbg-dump-type.bat: -------------------------------------------------------------------------------- 1 | Dia2Dump -type %1 x64\Debug\TraceStore.pdb 2 | -------------------------------------------------------------------------------- /debug-build-x64.bat: -------------------------------------------------------------------------------- 1 | msbuild Tracer.sln /t:Build /p:Configuration=Debug;Platform=x64 2 | -------------------------------------------------------------------------------- /make-cdb-commands.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OUTPUT=cdb-commands.txt 4 | CDB_OUTPUT=cdb-output.txt 5 | 6 | (cat < $OUTPUT 13 | 14 | find . -type f -iname "*.h" | 15 | xargs grep -ni '^typedef.*struct _.* {$' | 16 | sed -e 's/_Struct_size.* _/_/' \ 17 | -e 's/ DECLSPEC_ALIGN.\d+. / /' \ 18 | -e 's/^../dt -v /' \ 19 | -e 's/\/.*typedef struct _/!_/' \ 20 | -e 's/ {$//' >> $OUTPUT 21 | 22 | (cat <> $OUTPUT 27 | 28 | # vim:set ts=8 sw=4 sts=4 tw=80 et : 29 | -------------------------------------------------------------------------------- /pgienv.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set PogoSafeMode=1 4 | set VCPROFILE_PATH=S:\Source\tracer\x64 5 | if not defined VC14 ( 6 | setx VC14 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64" 7 | set VC14="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64" 8 | ) 9 | 10 | rem 11 | rem If pgomgr isn't on our path, we need to add the VC14 bin directory. 12 | rem 13 | 14 | setlocal enabledelayedexpansion 15 | 16 | set _ADD_PATH=1 17 | 18 | for /f "usebackq" %%i in (`pgomgr 2^>NUL`) do ( 19 | set _ADD_PATH=0 20 | ) 21 | 22 | endlocal & ( 23 | if %_ADD_PATH% == 1 ( 24 | echo Adding VC14 to PATH. 25 | set "PATH=%VC14%;%PATH%" 26 | ) 27 | ) 28 | 29 | rem vim:set ts=8 sw=4 sts=4 expandtab tw=80: 30 | -------------------------------------------------------------------------------- /release-build-x64.bat: -------------------------------------------------------------------------------- 1 | msbuild Tracer.sln /t:Build /p:Configuration=Release;Platform=x64 2 | -------------------------------------------------------------------------------- /run-cdb.bat: -------------------------------------------------------------------------------- 1 | cdb -cf cdb-commands.txt x64\Debug\ModuleLoader.exe 2 | -------------------------------------------------------------------------------- /st2-test-debug.bat: -------------------------------------------------------------------------------- 1 | vstest.console.exe /platform:x64 x64\Debug\StringTable2Test.dll 2 | -------------------------------------------------------------------------------- /st2-test-release.bat: -------------------------------------------------------------------------------- 1 | vstest.console.exe /platform:x64 x64\Release\StringTable2Test.dll -------------------------------------------------------------------------------- /st2b-pginstrument.bat: -------------------------------------------------------------------------------- 1 | x64\PGInstrument\StringTable2BenchmarkExe.exe %* 2 | call update-pgd.bat -------------------------------------------------------------------------------- /st2b-pgoptimize.bat: -------------------------------------------------------------------------------- 1 | x64\PGOptimize\StringTable2BenchmarkExe.exe %* -------------------------------------------------------------------------------- /st2b-release.bat: -------------------------------------------------------------------------------- 1 | x64\Release\StringTable2BenchmarkExe.exe %* -------------------------------------------------------------------------------- /t.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | python.exe %~dp0t.py %* 3 | -------------------------------------------------------------------------------- /t.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | 6 | def join_path(*args): 7 | return os.path.abspath(os.path.normpath(os.path.join(*args))) 8 | 9 | try: 10 | from tracer.cli import main 11 | except ImportError: 12 | path = os.path.abspath(__file__) 13 | libdir = join_path(path, 'PythonApp/lib') 14 | sys.path.insert(0, libdir) 15 | 16 | from tracer.cli import main 17 | 18 | if __name__ == '__main__': 19 | main('tracer', 'tracer') 20 | 21 | # vi:set ts=8 sw=4 sts=4 expandtab tw=78 syntax=python: 22 | -------------------------------------------------------------------------------- /td.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | python.exe %~dp0td.py %* 3 | -------------------------------------------------------------------------------- /td.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | 6 | def join_path(*args): 7 | return os.path.abspath(os.path.normpath(os.path.join(*args))) 8 | 9 | try: 10 | from tracer.cli import main 11 | except ImportError: 12 | path = os.path.abspath(__file__) 13 | libdir = join_path(path, 'PythonApp/lib') 14 | sys.path.insert(0, libdir) 15 | 16 | from tracer.cli import main 17 | 18 | if __name__ == '__main__': 19 | main('tracerdev', 'tracerdev') 20 | 21 | # vi:set ts=8 sw=4 sts=4 expandtab tw=78 syntax=python: 22 | -------------------------------------------------------------------------------- /update-pgd.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal enableextensions 4 | 5 | rem If input is Rtl!1.pgc, then: 6 | rem i = Rtl 7 | rem j = 1 8 | rem k = pgc 9 | rem 10 | rem We want to generate: 11 | rem pgomgr /merge x64\PGInstrument\Rtl!1.pgc x64\Rtl.pgd 12 | 13 | echo on 14 | 15 | @for /f "usebackq tokens=1,2,3 delims=!." %%i in (`dir /b x64\PGInstrument\*.pgc`) do ( 16 | pgomgr /merge "x64\PGInstrument\%%i!%%j.%%k" x64\%%i.pgd 17 | ) 18 | -------------------------------------------------------------------------------- /v140-to-v120.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find . -type f -iname "*vcxproj" | xargs perl -pi.bak -e 's/v140/v120/;' 4 | -------------------------------------------------------------------------------- /v140-to-v141.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find . -type f -iname "*vcxproj" | xargs perl -pi.bak -e 's/v140/v141/;' 4 | -------------------------------------------------------------------------------- /v141-to-v140.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find . -type f -iname "*vcxproj" | xargs perl -pi.bak -e 's/v141/v140/;' 4 | --------------------------------------------------------------------------------