2014-02-12 16:54:58 +00:00
|
|
|
#include "precomp.h"
|
|
|
|
#include "wraplog.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2014-02-17 16:41:10 +00:00
|
|
|
static INT openCount = 0;
|
|
|
|
static INT callLevel;
|
2014-02-12 16:54:58 +00:00
|
|
|
static FILE*log;
|
|
|
|
|
2014-02-17 16:41:10 +00:00
|
|
|
static INT nTemps;
|
2014-02-12 16:54:58 +00:00
|
|
|
static CHAR strTemp[10][256];
|
|
|
|
|
|
|
|
void WrapLogOpen()
|
|
|
|
{
|
|
|
|
if (openCount == 0)
|
|
|
|
{
|
2014-02-12 17:48:49 +00:00
|
|
|
log = fopen("G:\\RShellWrap.log", "w");
|
2014-02-12 16:54:58 +00:00
|
|
|
nTemps = 0;
|
|
|
|
callLevel = 0;
|
|
|
|
}
|
|
|
|
openCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapLogClose()
|
|
|
|
{
|
|
|
|
openCount--;
|
|
|
|
if (openCount == 0)
|
|
|
|
{
|
|
|
|
fclose(log);
|
|
|
|
log = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void __cdecl WrapLogMsg(_Printf_format_string_ const char* msg, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
for (int i = 0; i < callLevel; i++)
|
|
|
|
fputs(" ", log);
|
|
|
|
fputs("-- ", log);
|
|
|
|
va_start(args, msg);
|
|
|
|
vfprintf(log, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
fflush(log);
|
|
|
|
nTemps = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __cdecl WrapLogEnter(_Printf_format_string_ const char* msg, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
for (int i = 0; i < callLevel; i++)
|
|
|
|
fputs(" ", log);
|
|
|
|
fputs("ENTER >> ", log);
|
|
|
|
va_start(args, msg);
|
|
|
|
vfprintf(log, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
fflush(log);
|
|
|
|
callLevel++;
|
|
|
|
nTemps = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __cdecl WrapLogExit(_Printf_format_string_ const char* msg, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
callLevel--;
|
|
|
|
for (int i = 0; i < callLevel; i++)
|
|
|
|
fputs(" ", log);
|
|
|
|
fputs("EXIT <<< ", log);
|
|
|
|
va_start(args, msg);
|
|
|
|
vfprintf(log, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
fflush(log);
|
|
|
|
nTemps = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
LPSTR Wrap(const T& value);
|
|
|
|
|
|
|
|
template <>
|
|
|
|
LPSTR Wrap<GUID>(REFGUID guid)
|
|
|
|
{
|
2014-02-19 12:19:50 +00:00
|
|
|
LPSTR cStr = strTemp[nTemps++];
|
|
|
|
StringCchPrintfA(cStr, _countof(strTemp[0]),
|
2014-02-12 16:54:58 +00:00
|
|
|
"{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}",
|
|
|
|
guid.Data1, guid.Data2, guid.Data3,
|
|
|
|
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
|
|
|
|
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
|
2014-02-19 12:19:50 +00:00
|
|
|
return cStr;
|
2014-02-12 16:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
LPSTR Wrap<RECT>(const RECT& rect)
|
|
|
|
{
|
2014-02-19 12:19:50 +00:00
|
|
|
LPSTR cStr = strTemp[nTemps++];
|
|
|
|
StringCchPrintfA(cStr, _countof(strTemp[0]),
|
2014-02-12 16:54:58 +00:00
|
|
|
"{L: %d, T: %d, R: %d, B: %d}",
|
|
|
|
rect.left, rect.top, rect.right, rect.bottom);
|
2014-02-19 12:19:50 +00:00
|
|
|
return cStr;
|
2014-02-12 16:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
LPSTR Wrap<OLECMD>(const OLECMD& cmd)
|
|
|
|
{
|
2014-02-19 12:19:50 +00:00
|
|
|
LPSTR cStr = strTemp[nTemps++];
|
|
|
|
StringCchPrintfA(cStr, _countof(strTemp[0]),
|
2014-02-12 16:54:58 +00:00
|
|
|
"{ID: %d, F: %d}",
|
|
|
|
cmd.cmdID, cmd.cmdf);
|
2014-02-19 12:19:50 +00:00
|
|
|
return cStr;
|
2014-02-12 16:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
LPSTR Wrap<MSG>(const MSG& msg)
|
|
|
|
{
|
2014-02-19 12:19:50 +00:00
|
|
|
LPSTR cStr = strTemp[nTemps++];
|
|
|
|
StringCchPrintfA(cStr, _countof(strTemp[0]),
|
2014-02-12 16:54:58 +00:00
|
|
|
"{HWND: %d, Code: %d, W: %p, L: %p, T: %d, P.X: %d, P.Y: %d}",
|
|
|
|
msg.hwnd, msg.message, msg.wParam, msg.lParam, msg.time, msg.pt.x, msg.pt.y);
|
2014-02-19 12:19:50 +00:00
|
|
|
return cStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
LPSTR Wrap<BANDSITEINFO>(const BANDSITEINFO& bsi)
|
|
|
|
{
|
|
|
|
LPSTR cStr = strTemp[nTemps++];
|
|
|
|
StringCchPrintfA(cStr, _countof(strTemp[0]),
|
|
|
|
"{dwMask: %08x, dwState: %08x, dwStyle: %08x}",
|
|
|
|
bsi.dwMask, bsi.dwState, bsi.dwStyle);
|
|
|
|
return cStr;
|
2014-02-12 16:54:58 +00:00
|
|
|
}
|