summaryrefslogtreecommitdiffstats
path: root/src/dviewhelper
diff options
context:
space:
mode:
authorsagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2009-06-04 21:34:44 (GMT)
committersagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2009-06-04 21:34:44 (GMT)
commit890a9b3e4f9384f8937646d49848aa669f93ed8e (patch)
tree922645525e098b8a22ff6c890df830eac382a39d /src/dviewhelper
parent1ebb42385c535860df1455656f39699bffb20937 (diff)
downloadcv2pdb-890a9b3e4f9384f8937646d49848aa669f93ed8e.zip
cv2pdb-890a9b3e4f9384f8937646d49848aa669f93ed8e.tar.gz
cv2pdb-890a9b3e4f9384f8937646d49848aa669f93ed8e.tar.bz2
Diffstat (limited to 'src/dviewhelper')
-rw-r--r--src/dviewhelper/dviewhelper.cpp110
-rw-r--r--src/dviewhelper/dviewhelper.vcproj186
2 files changed, 296 insertions, 0 deletions
diff --git a/src/dviewhelper/dviewhelper.cpp b/src/dviewhelper/dviewhelper.cpp
new file mode 100644
index 0000000..594c231
--- /dev/null
+++ b/src/dviewhelper/dviewhelper.cpp
@@ -0,0 +1,110 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// DViewHelper - Expression Evaluator for the D string and object class
+// Copyright (c) 2009 by Rainer Schuetze, All Rights Reserved
+//
+// License for redistribution is given by the Artistic License 2.0
+// see file LICENSE for further details
+//
+// Compile the DLL and add this to AUTOEXP.DAT in section [AutoExpand]
+// string=$ADDIN(<path to the DLL>\dviewhelper.dll,_DStringView@28)
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#define _CRT_SECURE_NO_WARNINGS
+
+#include <windows.h>
+#include <stdio.h>
+
+extern "C" {
+
+// Copied from MSDN
+struct DEBUGHELPER
+{
+ DWORD dwVersion;
+ BOOL (WINAPI *ReadDebuggeeMemory)(DEBUGHELPER *pThis, DWORD dwAddr, DWORD nWant, VOID* pWhere, DWORD *nGot);
+ // from here only when dwVersion >= 0x20000
+ DWORDLONG (WINAPI *GetRealAddress)(DEBUGHELPER *pThis);
+ BOOL (WINAPI *ReadDebuggeeMemoryEx)(DEBUGHELPER *pThis, DWORDLONG qwAddr, DWORD nWant, VOID* pWhere, DWORD *nGot);
+ int (WINAPI *GetProcessorType)(DEBUGHELPER *pThis);
+};
+
+struct DString
+{
+ DWORD length;
+ DWORD data;
+};
+
+__declspec(dllexport)
+HRESULT WINAPI DStringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
+ char *pResult, size_t max, DWORD reserved)
+{
+ // Get the string struct
+ DString dstr;
+ DWORD read;
+ if (pHelper->ReadDebuggeeMemory(pHelper, dwAddress, sizeof(dstr), &dstr, &read) != S_OK)
+ {
+ strncpy(pResult,"Cannot access struct", max);
+ return S_OK;
+ }
+ if (dstr.length == 0)
+ {
+ strncpy(pResult,"\"\"", max);
+ return S_OK;
+ }
+
+ DWORD cnt = (dstr.length < max - 3 ? dstr.length : max - 3);
+ if (pHelper->ReadDebuggeeMemory(pHelper, dstr.data, cnt, pResult + 1, &read) != S_OK)
+ {
+ strncpy(pResult,"Cannot access data", max);
+ return S_OK;
+ }
+
+ pResult[0] = '\"';
+ pResult[cnt+1] = '\"';
+ pResult[cnt+2] = 0;
+ return S_OK;
+}
+
+__declspec(dllexport)
+HRESULT WINAPI DObjectView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
+ char *pResult, size_t max, DWORD reserved)
+{
+ if(dwAddress == 0)
+ {
+ strncpy(pResult,"null", max);
+ return S_OK;
+ }
+
+ DWORD read;
+ DWORD vtablePtr;
+ if (pHelper->ReadDebuggeeMemory(pHelper, dwAddress, sizeof(vtablePtr), &vtablePtr, &read) != S_OK)
+ {
+ strncpy(pResult,"Cannot access object", max);
+ return S_OK;
+ }
+ DWORD classinfoPtr;
+ if (pHelper->ReadDebuggeeMemory(pHelper, vtablePtr, sizeof(vtablePtr), &classinfoPtr, &read) != S_OK)
+ {
+ strncpy(pResult,"Cannot access vtable", max);
+ return S_OK;
+ }
+ DString dstr;
+ if (pHelper->ReadDebuggeeMemory(pHelper, classinfoPtr + 16, sizeof(dstr), &dstr, &read) != S_OK)
+ {
+ strncpy(pResult,"Cannot access class info", max);
+ return S_OK;
+ }
+
+ DWORD cnt = (dstr.length < max - 1 ? dstr.length : max - 1);
+ if (pHelper->ReadDebuggeeMemory(pHelper, dstr.data, cnt, pResult, &read) != S_OK)
+ {
+ strncpy(pResult,"Cannot access name data", max);
+ return S_OK;
+ }
+
+ pResult[cnt] = 0;
+ return S_OK;
+}
+
+} // extern "C" \ No newline at end of file
diff --git a/src/dviewhelper/dviewhelper.vcproj b/src/dviewhelper/dviewhelper.vcproj
new file mode 100644
index 0000000..67e1907
--- /dev/null
+++ b/src/dviewhelper/dviewhelper.vcproj
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="dviewhelper"
+ ProjectGUID="{E4424774-A7A0-4502-8626-2723904D70EA}"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../bin/$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)/$(ProjectName)"
+ ConfigurationType="2"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/$(ProjectName).dll"
+ LinkIncremental="2"
+ ModuleDefinitionFile=""
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../bin/$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)/$(ProjectName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/$(ProjectName).dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\dviewhelper.cpp"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>