Add DumpMem function to apitests lib for debugging purposes

svn path=/trunk/; revision=38045
This commit is contained in:
Timo Kreuzer 2008-12-13 16:52:49 +00:00
parent 4a3e577b8f
commit 702df456d2
2 changed files with 31 additions and 0 deletions

View file

@ -80,6 +80,36 @@ WriteRow(HANDLE hFile, LPDWORD lpdwBytesWritten, LPWSTR pszFunction, PTESTINFO p
return TRUE;
}
static CHAR
GetDisplayChar(CHAR c)
{
if (c < 32) return '.';
return c;
}
VOID
DumpMem(PVOID pData, ULONG cbSize, ULONG nWidth)
{
ULONG cLines = (cbSize + nWidth - 1) / nWidth;
ULONG cbLastLine = cbSize % nWidth;
INT i,j;
for (i = 0; i <= cLines; i++)
{
printf("%08lx: ", i*nWidth);
for (j = 0; j < (i == cLines? cbLastLine : nWidth); j++)
{
printf("%02x ", ((BYTE*)pData)[i*nWidth + j]);
}
printf(" ");
for (j = 0; j < (i == cLines? cbLastLine : nWidth); j++)
{
printf("%c", GetDisplayChar(((CHAR*)pData)[i*nWidth + j]));
}
printf("\n");
}
}
int
TestMain(LPWSTR pszName, LPWSTR pszModule)
{

View file

@ -91,5 +91,6 @@ int TestMain(LPWSTR pszExe, LPWSTR pszModule);
extern TESTENTRY TestList[];
INT NumTests(void);
BOOL IsFunctionPresent(LPWSTR lpszFunction);
VOID DumpMem(PVOID pData, ULONG cbSize, ULONG nWidth);
#endif /* _APITEST_H */