summaryrefslogtreecommitdiffstats
path: root/src/dviewhelper
diff options
context:
space:
mode:
authorsagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2009-06-06 15:16:25 (GMT)
committersagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2009-06-06 15:16:25 (GMT)
commit75930c8588ebf9f5eb77d5e49b7b7e6e33c2c15a (patch)
tree79d0064b694da77fbc9a44a256ba1333513e1466 /src/dviewhelper
parent5f8ec64d826f844ccc5e5f5b8767545e305a6e81 (diff)
downloadcv2pdb-75930c8588ebf9f5eb77d5e49b7b7e6e33c2c15a.zip
cv2pdb-75930c8588ebf9f5eb77d5e49b7b7e6e33c2c15a.tar.gz
cv2pdb-75930c8588ebf9f5eb77d5e49b7b7e6e33c2c15a.tar.bz2
v0.5:
* fixed error in __viewhelper field of string type, that could screw up type info * added support for wstring and dstring * fixed problems with debug info inside library by combining debug info of different modules into a single pseudo-module * now also replaces '.' by '@' in enumerator types for more consistent debug info
Diffstat (limited to 'src/dviewhelper')
-rw-r--r--src/dviewhelper/dviewhelper.cpp72
1 files changed, 61 insertions, 11 deletions
diff --git a/src/dviewhelper/dviewhelper.cpp b/src/dviewhelper/dviewhelper.cpp
index 594c231..110cc09 100644
--- a/src/dviewhelper/dviewhelper.cpp
+++ b/src/dviewhelper/dviewhelper.cpp
@@ -6,8 +6,11 @@
// 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)
+// Compile the DLL and add the following lines to AUTOEXP.DAT in section [AutoExpand]
+// string_viewhelper=$ADDIN(<path to the DLL>\dviewhelper.dll,_DStringView@28)
+// wstring_viewhelper=$ADDIN(<path to the DLL>\dviewhelper.dll,_DWStringView@28)
+// dstring_viewhelper=$ADDIN(<path to the DLL>\dviewhelper.dll,_DDStringView@28)
+// object_viewhelper=$ADDIN(<path to the DLL>\dviewhelper.dll,_DObjectView@28)
//
///////////////////////////////////////////////////////////////////////////////
@@ -35,9 +38,10 @@ struct DString
DWORD data;
};
-__declspec(dllexport)
-HRESULT WINAPI DStringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
- char *pResult, size_t max, DWORD reserved)
+///////////////////////////////////////////////////////////////////////////////
+
+HRESULT WINAPI StringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
+ char *pResult, size_t max, DWORD sizePerChar)
{
// Get the string struct
DString dstr;
@@ -53,19 +57,65 @@ HRESULT WINAPI DStringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOO
return S_OK;
}
+ char* pData = pResult + 1;
DWORD cnt = (dstr.length < max - 3 ? dstr.length : max - 3);
- if (pHelper->ReadDebuggeeMemory(pHelper, dstr.data, cnt, pResult + 1, &read) != S_OK)
+ if (sizePerChar * cnt > max)
+ pData = new char[sizePerChar * cnt];
+
+ if (pHelper->ReadDebuggeeMemory(pHelper, dstr.data, sizePerChar * cnt, pData, &read) != S_OK)
{
strncpy(pResult,"Cannot access data", max);
- return S_OK;
+ }
+ else
+ {
+ //! @todo: proper utf8/16/32 translation
+ for (DWORD p = 0; p < cnt; p++)
+ {
+ int ch;
+ if (sizePerChar == 4)
+ ch = ((long*) pData) [p];
+ else if (sizePerChar == 2)
+ ch = ((short*) pData) [p];
+ else
+ ch = pData [p];
+
+ if (ch >= 128 && ch < -128)
+ pResult[p + 1] = -1;
+ else
+ pResult[p + 1] = (char) ch;
+ }
+ pResult[0] = '\"';
+ pResult[cnt+1] = '\"';
+ pResult[cnt+2] = 0;
}
- pResult[0] = '\"';
- pResult[cnt+1] = '\"';
- pResult[cnt+2] = 0;
+ if(pData != pResult + 1)
+ delete [] pData;
return S_OK;
}
+
+__declspec(dllexport)
+HRESULT WINAPI DStringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
+ char *pResult, size_t max, DWORD reserved)
+{
+ return StringView(dwAddress, pHelper, nBase, bUniStrings, pResult, max, 1);
+}
+
+__declspec(dllexport)
+HRESULT WINAPI DWStringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
+ char *pResult, size_t max, DWORD reserved)
+{
+ return StringView(dwAddress, pHelper, nBase, bUniStrings, pResult, max, 2);
+}
+
+__declspec(dllexport)
+HRESULT WINAPI DDStringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
+ char *pResult, size_t max, DWORD reserved)
+{
+ return StringView(dwAddress, pHelper, nBase, bUniStrings, pResult, max, 4);
+}
+
__declspec(dllexport)
HRESULT WINAPI DObjectView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
char *pResult, size_t max, DWORD reserved)
@@ -107,4 +157,4 @@ HRESULT WINAPI DObjectView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOO
return S_OK;
}
-} // extern "C" \ No newline at end of file
+} // extern "C"