Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

664 lines
21 KiB

  1. #include <stdarg.h>
  2. #include "AppManDebug.h"
  3. #if _TRACEON == TRUE
  4. #pragma message("Trace is on")
  5. CAppManDebugHandler g_oDebugHandler;
  6. CHAR g_szDebugString[256];
  7. #define APPMAN_REG_DBG
  8. //////////////////////////////////////////////////////////////////////////////////////////////
  9. //
  10. //////////////////////////////////////////////////////////////////////////////////////////////
  11. DWORD GetExternalMask(const DWORD dwMsgType)
  12. {
  13. return (DBG_EXTERNAL & dwMsgType);
  14. }
  15. //////////////////////////////////////////////////////////////////////////////////////////////
  16. //
  17. //////////////////////////////////////////////////////////////////////////////////////////////
  18. DWORD GetLevel(const DWORD dwMsgType)
  19. {
  20. DWORD dwLevel = 0;
  21. if ((DBG_ERROR | DBG_THROW | DBG_CATCH) & dwMsgType)
  22. {
  23. dwLevel = 0;
  24. }
  25. else if (DBG_WARNING & dwMsgType)
  26. {
  27. dwLevel = 1;
  28. }
  29. else if ((DBG_FUNCENTRY | DBG_FUNCEXIT | DBG_CONSTRUCTOR | DBG_DESTRUCTOR) & dwMsgType)
  30. {
  31. dwLevel = 2;
  32. }
  33. else
  34. {
  35. dwLevel = 5;
  36. }
  37. return dwLevel;
  38. }
  39. //////////////////////////////////////////////////////////////////////////////////////////////
  40. //
  41. //////////////////////////////////////////////////////////////////////////////////////////////
  42. DWORD GetSourceMask(const DWORD dwMsgType)
  43. {
  44. return (DBG_ALL_MODULES & dwMsgType);
  45. }
  46. //////////////////////////////////////////////////////////////////////////////////////////////
  47. //
  48. //////////////////////////////////////////////////////////////////////////////////////////////
  49. extern CHAR * MakeDebugString(const CHAR * szFormat, ...)
  50. {
  51. va_list ArgumentList;
  52. if (NULL != szFormat)
  53. {
  54. va_start(ArgumentList, szFormat);
  55. _vsnprintf(g_szDebugString, 256, szFormat, ArgumentList);
  56. va_end(ArgumentList);
  57. }
  58. return g_szDebugString;
  59. }
  60. //////////////////////////////////////////////////////////////////////////////////////////////
  61. //
  62. //////////////////////////////////////////////////////////////////////////////////////////////
  63. CAppManDebugHandler::CAppManDebugHandler(void)
  64. {
  65. m_fDebugInitialized = FALSE;
  66. m_dwDebugLevel = 0;
  67. m_dwDebugInternal = 0;
  68. m_dwSourceFlags = 0xffffffff;
  69. m_dwOperationalFlags = OP_NOTHING;
  70. m_dwReportMode = _CRTDBG_MODE_DEBUG;
  71. m_dwFunctionDepth = 0;
  72. strcpy(m_szOutputFilename,"c:\\AppManDebug.txt");
  73. m_MutexHandle = CreateMutex(NULL, FALSE, "AppManDebug");
  74. }
  75. //////////////////////////////////////////////////////////////////////////////////////////////
  76. //
  77. //////////////////////////////////////////////////////////////////////////////////////////////
  78. CAppManDebugHandler::~CAppManDebugHandler(void)
  79. {
  80. CloseHandle(m_MutexHandle);
  81. }
  82. //////////////////////////////////////////////////////////////////////////////////////////////
  83. //
  84. //////////////////////////////////////////////////////////////////////////////////////////////
  85. void CAppManDebugHandler::InitDebug(void)
  86. {
  87. DWORD dwType;
  88. DWORD dwSize;
  89. HKEY hRegistryKey = NULL;
  90. BYTE cBuffer[512];
  91. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGPATH_APPMAN, 0, KEY_READ, &hRegistryKey))
  92. {
  93. //
  94. // What is the debug level
  95. //
  96. dwSize = sizeof(cBuffer);
  97. if (ERROR_SUCCESS == RegQueryValueEx(hRegistryKey, "Debug", NULL, &dwType, (LPBYTE) cBuffer, &dwSize))
  98. {
  99. if ((REG_DWORD == dwType)&&(sizeof(DWORD) == dwSize))
  100. {
  101. m_dwDebugLevel = *((LPDWORD) cBuffer);
  102. }
  103. }
  104. //
  105. // What is the debug level
  106. //
  107. dwSize = sizeof(cBuffer);
  108. if (ERROR_SUCCESS == RegQueryValueEx(hRegistryKey, "DebugInternal", NULL, &dwType, (LPBYTE) cBuffer, &dwSize))
  109. {
  110. if ((REG_DWORD == dwType)&&(sizeof(DWORD) == dwSize))
  111. {
  112. m_dwDebugInternal = *((LPDWORD) cBuffer);
  113. }
  114. }
  115. //
  116. // What is the DebugSourceFlag
  117. //
  118. dwSize = sizeof(cBuffer);
  119. if (ERROR_SUCCESS == RegQueryValueEx(hRegistryKey, "DebugSourceFlags", NULL, &dwType, (LPBYTE) cBuffer, &dwSize))
  120. {
  121. if ((REG_DWORD == dwType)&&(sizeof(DWORD) == dwSize))
  122. {
  123. m_dwSourceFlags = *((LPDWORD) cBuffer);
  124. }
  125. }
  126. //
  127. // What is the DebugOperationFlags
  128. //
  129. dwSize = sizeof(cBuffer);
  130. if (ERROR_SUCCESS == RegQueryValueEx(hRegistryKey, "DebugOperationFlags", NULL, &dwType, (LPBYTE) cBuffer, &dwSize))
  131. {
  132. if ((REG_DWORD == dwType)&&(sizeof(DWORD) == dwSize))
  133. {
  134. m_dwOperationalFlags = *((LPDWORD) cBuffer);
  135. }
  136. }
  137. //
  138. // What is the DebugReportMode
  139. //
  140. // _CRTDBG_MODE_FILE 0x00000001
  141. // _CRTDBG_MODE_DEBUG 0x00000002
  142. // _CRTDBG_MODE_WNDW 0x00000004
  143. //
  144. dwSize = sizeof(cBuffer);
  145. if (ERROR_SUCCESS == RegQueryValueEx(hRegistryKey, "DebugReportMode", NULL, &dwType, (LPBYTE) cBuffer, &dwSize))
  146. {
  147. if ((REG_DWORD == dwType)&&(sizeof(DWORD) == dwSize))
  148. {
  149. m_dwReportMode = *((LPDWORD) cBuffer);
  150. }
  151. }
  152. //
  153. // What is the DebugOutputFilename
  154. //
  155. dwSize = sizeof(cBuffer);
  156. if (ERROR_SUCCESS == RegQueryValueEx(hRegistryKey, "DebugOutputFilename", NULL, &dwType, (LPBYTE) cBuffer, &dwSize))
  157. {
  158. if ((REG_SZ == dwType)&&(sizeof(DWORD) == dwSize))
  159. {
  160. strcpy(m_szOutputFilename, (LPCSTR) cBuffer);
  161. }
  162. }
  163. //
  164. // Check that the filename is valid and can be opened
  165. //
  166. if (_CRTDBG_MODE_FILE & m_dwReportMode)
  167. {
  168. HANDLE hFile;
  169. hFile = CreateFile(m_szOutputFilename, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  170. if (NULL == hFile)
  171. {
  172. m_dwReportMode &= ~_CRTDBG_MODE_FILE;
  173. }
  174. else
  175. {
  176. CloseHandle(hFile);
  177. }
  178. }
  179. //
  180. // Close the registry key
  181. //
  182. RegCloseKey(hRegistryKey);
  183. //
  184. // We are ready
  185. //
  186. m_fDebugInitialized = TRUE;
  187. }
  188. }
  189. //////////////////////////////////////////////////////////////////////////////////////////////
  190. //
  191. //////////////////////////////////////////////////////////////////////////////////////////////
  192. void CAppManDebugHandler::DebugPrintf(const DWORD dwMsgType, const DWORD dwLineNumber, LPCSTR szFilename, const TCHAR * szFormat, ...)
  193. {
  194. va_list sVariableList;
  195. DWORD dwProcessId, dwThreadId;
  196. SYSTEMTIME sSystemTime;
  197. CHAR szHeader[512];
  198. CHAR szBaseMessage[512];
  199. CHAR szIntermediateString[1024];
  200. CHAR szOutputString[1024];
  201. //
  202. // Initialize the debug spew
  203. //
  204. if (!m_fDebugInitialized)
  205. {
  206. InitDebug();
  207. m_fDebugInitialized = TRUE;
  208. }
  209. if (WAIT_TIMEOUT != WaitForSingleObject(m_MutexHandle, 1000))
  210. {
  211. //
  212. // Is this an internal message. If so, should we print it out
  213. //
  214. if (((0 == m_dwDebugInternal)&&(GetExternalMask(dwMsgType)))||(0 != m_dwDebugInternal))
  215. {
  216. if (m_dwDebugLevel >= GetLevel(dwMsgType))
  217. {
  218. if (m_dwSourceFlags & GetSourceMask(dwMsgType))
  219. {
  220. //
  221. // Build the main output message
  222. //
  223. va_start(sVariableList, szFormat);
  224. _vsnprintf(szBaseMessage, 512, szFormat, sVariableList);
  225. va_end(sVariableList);
  226. //
  227. // Build szTmpString
  228. //
  229. ZeroMemory(szHeader, sizeof(szHeader));
  230. memset(szHeader, 32, m_dwFunctionDepth * 2);
  231. szHeader[m_dwFunctionDepth * 2] = 0;
  232. switch(dwMsgType & DBG_LEVEL)
  233. {
  234. case DBG_ERROR
  235. : wsprintfA(szIntermediateString, "%s[ ERROR ] %s", szHeader, szBaseMessage);
  236. break;
  237. case DBG_THROW
  238. : wsprintfA(szIntermediateString, "%s[ THROW ] %s", szHeader, szBaseMessage);
  239. break;
  240. case DBG_CATCH
  241. : wsprintfA(szIntermediateString, "%s[ CATCH ] %s", szHeader, szBaseMessage);
  242. break;
  243. case DBG_WARNING
  244. : wsprintfA(szIntermediateString, "%s[ WARNING ] %s", szHeader, szBaseMessage);
  245. break;
  246. case DBG_FUNCENTRY
  247. : wsprintfA(szIntermediateString, "%s[vvvv] %s", szHeader, szBaseMessage);
  248. m_dwFunctionDepth++;
  249. break;
  250. case DBG_FUNCEXIT
  251. : m_dwFunctionDepth--;
  252. ZeroMemory(szHeader, sizeof(szHeader));
  253. memset(szHeader, 32, m_dwFunctionDepth * 2);
  254. szHeader[m_dwFunctionDepth * 2] = 0;
  255. wsprintfA(szIntermediateString, "%s[^^^^] %s", szHeader, szBaseMessage);
  256. break;
  257. case DBG_CONSTRUCTOR
  258. : wsprintfA(szIntermediateString, "%s[ CONSTRUCTOR ] %s", szHeader, szBaseMessage);
  259. m_dwFunctionDepth++;
  260. break;
  261. case DBG_DESTRUCTOR
  262. : m_dwFunctionDepth--;
  263. ZeroMemory(szHeader, sizeof(szHeader));
  264. memset(szHeader, 32, m_dwFunctionDepth * 2);
  265. szHeader[m_dwFunctionDepth * 2] = 0;
  266. wsprintfA(szIntermediateString, "%s[ DESTRUCTOR ] %s", szHeader, szBaseMessage);
  267. break;
  268. default
  269. : wsprintfA(szIntermediateString, "%s> %s", szHeader, szBaseMessage);
  270. break;
  271. }
  272. if (OP_OUTPUTTIMESTAMP & m_dwOperationalFlags)
  273. {
  274. if (OP_OUTPUTFILENAME & m_dwOperationalFlags)
  275. {
  276. if (OP_OUTPUTLINENUMBER & m_dwOperationalFlags)
  277. {
  278. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  279. {
  280. //
  281. // OUTPUTPTID, OUTPUTLINENUMBER, OUTPUTFILENAME, OUTPUTTIMESTAMP
  282. //
  283. dwProcessId = GetCurrentProcessId();
  284. dwThreadId = GetCurrentThreadId();
  285. GetLocalTime(&sSystemTime);
  286. wsprintfA(szOutputString, "[p%05d][t%05d] [Time %02d:%02d:%02d:%02d %02d-%02d-%04d] File %032s Line %05d %s\r\n", dwProcessId, dwThreadId, sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, szFilename, dwLineNumber, szIntermediateString);
  287. }
  288. else
  289. {
  290. //
  291. // OUTPUTLINENUMBER, OUTPUTFILENAME, OUTPUTTIMESTAMP
  292. //
  293. GetLocalTime(&sSystemTime);
  294. wsprintfA(szOutputString, "[Time %02d:%02d:%02d:%02d %02d-%02d-%04d] File %032s Line %05d %s\r\n", sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, szFilename, dwLineNumber, szIntermediateString);
  295. }
  296. }
  297. else
  298. {
  299. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  300. {
  301. //
  302. // OUTPUTPTID, OUTPUTFILENAME, OUTPUTTIMESTAMP
  303. //
  304. dwProcessId = GetCurrentProcessId();
  305. dwThreadId = GetCurrentThreadId();
  306. GetLocalTime(&sSystemTime);
  307. wsprintfA(szOutputString, "[p%05d][t%05d] [Time %02d:%02d:%02d:%02d %02d-%02d-%04d] File %032s %s\r\n", dwProcessId, dwThreadId, sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, szFilename, szIntermediateString);
  308. }
  309. else
  310. {
  311. //
  312. // OUTPUTFILENAME, OUTPUTTIMESTAMP
  313. //
  314. GetLocalTime(&sSystemTime);
  315. wsprintfA(szOutputString, "[Time %02d:%02d:%02d:%02d %02d-%02d-%04d] File %032s %s\r\n", sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, szFilename, szIntermediateString);
  316. }
  317. }
  318. }
  319. else
  320. {
  321. if (OP_OUTPUTLINENUMBER & m_dwOperationalFlags)
  322. {
  323. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  324. {
  325. //
  326. // OUTPUTPTID, OUTPUTLINENUMBER, OUTPUTTIMESTAMP
  327. //
  328. dwProcessId = GetCurrentProcessId();
  329. dwThreadId = GetCurrentThreadId();
  330. GetLocalTime(&sSystemTime);
  331. wsprintfA(szOutputString, "[p%05d][t%05d] [Time %02d:%02d:%02d:%02d %02d-%02d-%04d] Line %05d %s\r\n", dwProcessId, dwThreadId, sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, dwLineNumber, szIntermediateString);
  332. }
  333. else
  334. {
  335. //
  336. // OUTPUTLINENUMBER, OUTPUTTIMESTAMP
  337. //
  338. GetLocalTime(&sSystemTime);
  339. wsprintfA(szOutputString, "[Time %02d:%02d:%02d:%02d %02d-%02d-%04d] Line %05d %s\r\n", sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, dwLineNumber, szIntermediateString);
  340. }
  341. }
  342. else
  343. {
  344. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  345. {
  346. //
  347. // OUTPUTPTID, OUTPUTTIMESTAMP
  348. //
  349. dwProcessId = GetCurrentProcessId();
  350. dwThreadId = GetCurrentThreadId();
  351. GetLocalTime(&sSystemTime);
  352. wsprintfA(szOutputString, "[p%05d][t%05d] [Time %02d:%02d:%02d:%02d %02d-%02d-%04d] %05d %s\r\n", dwProcessId, dwThreadId, sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, szIntermediateString);
  353. }
  354. else
  355. {
  356. //
  357. // OUTPUTTIMESTAMP
  358. //
  359. GetLocalTime(&sSystemTime);
  360. wsprintfA(szOutputString, "[Time %02d:%02d:%02d:%02d %02d-%02d-%04d] %s\r\n", sSystemTime.wHour, sSystemTime.wMinute, sSystemTime.wSecond, sSystemTime.wMilliseconds, sSystemTime.wMonth, sSystemTime.wDay, sSystemTime.wYear, szIntermediateString);
  361. }
  362. }
  363. }
  364. }
  365. else
  366. {
  367. if (OP_OUTPUTFILENAME & m_dwOperationalFlags)
  368. {
  369. if (OP_OUTPUTLINENUMBER & m_dwOperationalFlags)
  370. {
  371. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  372. {
  373. //
  374. // OUTPUTPTID, OUTPUTLINENUMBER, OUTPUTFILENAME
  375. //
  376. dwProcessId = GetCurrentProcessId();
  377. dwThreadId = GetCurrentThreadId();
  378. wsprintfA(szOutputString, "[p%05d][t%05d] File %032s Line %05d %s\r\n", dwProcessId, dwThreadId, szFilename, dwLineNumber, szIntermediateString);
  379. }
  380. else
  381. {
  382. //
  383. // OUTPUTLINENUMBER, OUTPUTFILENAME
  384. //
  385. wsprintfA(szOutputString, "File %032s Line %05d %s\r\n", szFilename, dwLineNumber, szIntermediateString);
  386. }
  387. }
  388. else
  389. {
  390. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  391. {
  392. //
  393. // OUTPUTPTID, OUTPUTFILENAME
  394. //
  395. dwProcessId = GetCurrentProcessId();
  396. dwThreadId = GetCurrentThreadId();
  397. wsprintfA(szOutputString, "[p%05d][t%05d] File %032s %s\r\n", dwProcessId, dwThreadId, szFilename, szIntermediateString);
  398. }
  399. else
  400. {
  401. //
  402. // OUTPUTFILENAME
  403. //
  404. wsprintfA(szOutputString, "File %032s %s\r\n", szFilename, szIntermediateString);
  405. }
  406. }
  407. }
  408. else
  409. {
  410. if (OP_OUTPUTLINENUMBER & m_dwOperationalFlags)
  411. {
  412. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  413. {
  414. //
  415. // OUTPUTPTID, OUTPUTLINENUMBER
  416. //
  417. dwProcessId = GetCurrentProcessId();
  418. dwThreadId = GetCurrentThreadId();
  419. wsprintfA(szOutputString, "[p%05d][t%05d] Line %05d %s\r\n", dwProcessId, dwThreadId, dwLineNumber, szIntermediateString);
  420. }
  421. else
  422. {
  423. //
  424. // OUTPUTLINENUMBER
  425. //
  426. wsprintfA(szOutputString, "Line %05d %s\r\n", dwLineNumber, szIntermediateString);
  427. }
  428. }
  429. else
  430. {
  431. if (OP_OUTPUTPTID & m_dwOperationalFlags)
  432. {
  433. //
  434. // OUTPUTPTID
  435. //
  436. dwProcessId = GetCurrentProcessId();
  437. dwThreadId = GetCurrentThreadId();
  438. wsprintfA(szOutputString, "[p%05d][t%05d] %s\r\n", dwProcessId, dwThreadId, szIntermediateString);
  439. }
  440. else
  441. {
  442. //
  443. // NONE
  444. //
  445. wsprintfA(szOutputString, "%s\r\n", szIntermediateString);
  446. }
  447. }
  448. }
  449. }
  450. //
  451. // Should we output to file
  452. //
  453. if (_CRTDBG_MODE_FILE & m_dwReportMode)
  454. {
  455. HANDLE hFileHandle;
  456. DWORD dwBytesWritten;
  457. hFileHandle = CreateFile(m_szOutputFilename, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  458. if (INVALID_HANDLE_VALUE != hFileHandle)
  459. {
  460. SetFilePointer(hFileHandle, 0, NULL, FILE_END);
  461. WriteFile(hFileHandle, szOutputString, strlen(szOutputString), &dwBytesWritten, NULL);
  462. CloseHandle(hFileHandle);
  463. }
  464. }
  465. //
  466. // Should we output to the debug window
  467. //
  468. if ((_CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW) & m_dwReportMode)
  469. {
  470. OutputDebugString(szOutputString);
  471. }
  472. }
  473. }
  474. }
  475. //
  476. // Release the mutex
  477. //
  478. ReleaseMutex(m_MutexHandle);
  479. }
  480. }
  481. //////////////////////////////////////////////////////////////////////////////////////////////
  482. //
  483. //////////////////////////////////////////////////////////////////////////////////////////////
  484. void CAppManDebugHandler::DebugPrintfW(const DWORD dwMsgType, const DWORD dwLineNumber, LPCSTR szFilename, const wchar_t * wszFormat, ...)
  485. {
  486. CWin32API oWin32API;
  487. va_list sVariableList;
  488. WCHAR wszMessage[512];
  489. CHAR szMessage[512];
  490. va_start(sVariableList, wszFormat);
  491. _vsnwprintf(wszMessage, 512, wszFormat, sVariableList);
  492. oWin32API.WideCharToMultiByte(wszMessage, 512, szMessage, 512);
  493. va_end(sVariableList);
  494. DebugPrintf(dwMsgType, dwLineNumber, szFilename, szMessage);
  495. }
  496. //////////////////////////////////////////////////////////////////////////////////////////////
  497. //
  498. //////////////////////////////////////////////////////////////////////////////////////////////
  499. void CAppManDebugHandler::SetSourceFlags(const DWORD dwFilter)
  500. {
  501. m_dwSourceFlags = dwFilter;
  502. }
  503. //////////////////////////////////////////////////////////////////////////////////////////////
  504. //
  505. //////////////////////////////////////////////////////////////////////////////////////////////
  506. void CAppManDebugHandler::SetOperationalFlags(const DWORD dwOperationalFlags)
  507. {
  508. m_dwOperationalFlags = dwOperationalFlags;
  509. }
  510. //////////////////////////////////////////////////////////////////////////////////////////////
  511. //
  512. //////////////////////////////////////////////////////////////////////////////////////////////
  513. void CAppManDebugHandler::SetOutputFilename(LPCSTR szFilename)
  514. {
  515. wsprintfA(m_szOutputFilename, szFilename);
  516. }
  517. //////////////////////////////////////////////////////////////////////////////////////////////
  518. //
  519. //////////////////////////////////////////////////////////////////////////////////////////////
  520. DWORD CAppManDebugHandler::GetSourceFlags(void)
  521. {
  522. return m_dwSourceFlags;
  523. }
  524. //////////////////////////////////////////////////////////////////////////////////////////////
  525. //
  526. //////////////////////////////////////////////////////////////////////////////////////////////
  527. DWORD CAppManDebugHandler::GetOperationalFlags(void)
  528. {
  529. return m_dwOperationalFlags;
  530. }
  531. //////////////////////////////////////////////////////////////////////////////////////////////
  532. //
  533. //////////////////////////////////////////////////////////////////////////////////////////////
  534. void CAppManDebugHandler::GetOutputFilename(LPSTR szFilename)
  535. {
  536. wsprintfA(szFilename, m_szOutputFilename);
  537. }
  538. //////////////////////////////////////////////////////////////////////////////////////////////
  539. //
  540. //////////////////////////////////////////////////////////////////////////////////////////////
  541. CAutoTrace::CAutoTrace(DWORD dwModule, LPSTR lpFunctionName, INT iLine, LPSTR lpFileName)
  542. {
  543. //
  544. // Save the function name
  545. //
  546. m_dwModule = dwModule;
  547. strncpy(m_szFunctionName, lpFunctionName, MAX_PATH_CHARCOUNT);
  548. strncpy(m_szFilename, lpFileName, MAX_PATH_CHARCOUNT);
  549. g_oDebugHandler.DebugPrintf(m_dwModule | DBG_FUNCENTRY, iLine, m_szFilename, m_szFunctionName);
  550. }
  551. //////////////////////////////////////////////////////////////////////////////////////////////
  552. //
  553. //////////////////////////////////////////////////////////////////////////////////////////////
  554. CAutoTrace::~CAutoTrace(void)
  555. {
  556. g_oDebugHandler.DebugPrintf(m_dwModule | DBG_FUNCEXIT, NULL, m_szFilename, m_szFunctionName);
  557. }
  558. #endif // _TRACEON