Leaked source code of windows server 2003
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.

856 lines
41 KiB

  1. /**MOD+**********************************************************************/
  2. /* Module: wtrcint.c */
  3. /* */
  4. /* Purpose: Internal tracing functions - Windows specific. */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1997 */
  7. /* */
  8. /****************************************************************************/
  9. /** Changes:
  10. * $Log: Y:/logs/trc/wtrcint.c_v $
  11. *
  12. * Rev 1.10 22 Aug 1997 15:11:48 SJ
  13. * SFR1291: Win16 Trace DLL doesn't write integers to ini file properly
  14. *
  15. * Rev 1.9 09 Jul 1997 18:03:42 AK
  16. * SFR1016: Initial changes to support Unicode
  17. *
  18. * Rev 1.8 03 Jul 1997 13:29:04 AK
  19. * SFR0000: Initial development completed
  20. **/
  21. /**MOD-**********************************************************************/
  22. /****************************************************************************/
  23. /* */
  24. /* INCLUDES */
  25. /* */
  26. /****************************************************************************/
  27. #include <adcg.h>
  28. /****************************************************************************/
  29. /* Define TRC_FILE and TRC_GROUP. */
  30. /****************************************************************************/
  31. #define TRC_FILE "wtrcint"
  32. #define TRC_GROUP TRC_GROUP_TRACE
  33. /****************************************************************************/
  34. /* Trace specific includes. */
  35. /* */
  36. /* Note that including atrcapi.h automatically includes wtrcapi.h for us. */
  37. /****************************************************************************/
  38. #include <atrcapi.h>
  39. #include <atrcint.h>
  40. #include <wtrcrc.h>
  41. #include <ndcgver.h>
  42. /****************************************************************************/
  43. /* */
  44. /* DATA */
  45. /* */
  46. /****************************************************************************/
  47. #define DC_INCLUDE_DATA
  48. #include <atrcdata.c>
  49. #undef DC_INCLUDE_DATA
  50. /****************************************************************************/
  51. /* */
  52. /* FUNCTIONS */
  53. /* */
  54. /****************************************************************************/
  55. /****************************************************************************/
  56. /* FUNCTION: TRCGetModuleFileName(...) */
  57. /* */
  58. /* DESCRIPTION: */
  59. /* ============ */
  60. /* This function gets the DLL module file name, without path or extension. */
  61. /* Global trchModule must contain the library module handle (WIN32) or */
  62. /* instance handle (WIN16). */
  63. /* */
  64. /* PARAMETERS: */
  65. /* =========== */
  66. /* pModuleName : address of buffer into which the module name is written. */
  67. /* */
  68. /* RETURNS: */
  69. /* ======== */
  70. /* DC_RC_OK is successful, error code otherwise. */
  71. /* */
  72. /****************************************************************************/
  73. DCUINT DCINTERNAL TRCGetModuleFileName(PDCTCHAR pModuleName,
  74. UINT cchModuleName)
  75. {
  76. DCINT rc = DC_RC_OK;
  77. PDCTCHAR pTemp;
  78. PDCTCHAR pName;
  79. DCTCHAR pModuleFileName[TRC_FILE_NAME_SIZE];
  80. HRESULT hr;
  81. /************************************************************************/
  82. /* Get the trace DLL module file name. We use this later when we get a */
  83. /* stack trace. */
  84. /************************************************************************/
  85. if ( GetModuleFileName(trchModule,
  86. pModuleFileName,
  87. TRC_FILE_NAME_SIZE) != 0 )
  88. {
  89. pModuleFileName[TRC_FILE_NAME_SIZE-1] = 0;
  90. /********************************************************************/
  91. /* The module file name is currently in the form of a complete */
  92. /* path - however we only want the actual module name. */
  93. /********************************************************************/
  94. pName = pModuleFileName;
  95. pTemp = DC_TSTRCHR(pName, _T('\\'));
  96. while (NULL != pTemp)
  97. {
  98. pName = pTemp + 1;
  99. pTemp = DC_TSTRCHR(pName, _T('\\'));
  100. }
  101. /********************************************************************/
  102. /* Now remove the file name extension - we do this by replacing */
  103. /* the decimal point with a null. */
  104. /********************************************************************/
  105. pTemp = DC_TSTRCHR(pName, _T('.'));
  106. if (NULL != pTemp)
  107. {
  108. *pTemp = _T('\0');
  109. }
  110. /********************************************************************/
  111. /* Finally copy what remains into the caller's buffer */
  112. /********************************************************************/
  113. hr = StringCchCopy(pModuleName, cchModuleName, pName);
  114. if (FAILED(hr)) {
  115. rc = TRC_RC_IO_ERROR;
  116. }
  117. }
  118. else
  119. {
  120. rc = TRC_RC_IO_ERROR;
  121. }
  122. return(rc);
  123. }
  124. /**PROC+*********************************************************************/
  125. /* Name: TRCAssertDlgProc */
  126. /* */
  127. /* Purpose: Dialog Proc for assert box */
  128. /* */
  129. /* Returns: TRUE / FALSE */
  130. /* */
  131. /* Params: IN usual Windows parameters */
  132. /* */
  133. /**PROC-*********************************************************************/
  134. INT_PTR CALLBACK TRCAssertDlgProc(HWND hwndDlg,
  135. UINT msg,
  136. WPARAM wParam,
  137. LPARAM lParam)
  138. {
  139. INT_PTR rc = FALSE;
  140. RECT rect;
  141. DCINT xPos;
  142. DCINT yPos;
  143. PDCTCHAR pText;
  144. switch (msg)
  145. {
  146. case WM_INITDIALOG:
  147. {
  148. /****************************************************************/
  149. /* Set the text */
  150. /****************************************************************/
  151. pText = (PDCTCHAR)lParam;
  152. SetDlgItemText(hwndDlg, TRC_ID_TEXT, pText);
  153. SetWindowText(hwndDlg, TRC_ASSERT_TITLE);
  154. /****************************************************************/
  155. /* Center on the screen, and set to topmost. */
  156. /****************************************************************/
  157. GetWindowRect(hwndDlg, &rect);
  158. xPos = ( GetSystemMetrics(SM_CXSCREEN) -
  159. (rect.right - rect.left)) / 2;
  160. yPos = ( GetSystemMetrics(SM_CYSCREEN) -
  161. (rect.bottom - rect.top)) / 2;
  162. SetWindowPos(hwndDlg,
  163. HWND_TOPMOST,
  164. xPos, yPos,
  165. rect.right - rect.left,
  166. rect.bottom - rect.top,
  167. SWP_NOACTIVATE);
  168. rc = TRUE;
  169. }
  170. break;
  171. case WM_COMMAND:
  172. {
  173. switch(DC_GET_WM_COMMAND_ID(wParam))
  174. {
  175. case IDABORT:
  176. case IDRETRY:
  177. case IDIGNORE:
  178. {
  179. PostMessage(hwndDlg,
  180. WM_USER + DC_GET_WM_COMMAND_ID(wParam),
  181. 0, 0);
  182. rc = TRUE;
  183. }
  184. break;
  185. default:
  186. {
  187. /********************************************************/
  188. /* Ignore other messages */
  189. /********************************************************/
  190. }
  191. break;
  192. }
  193. }
  194. case WM_CLOSE:
  195. {
  196. /****************************************************************/
  197. /* If 'x' selected, treat as 'Ignore' */
  198. /****************************************************************/
  199. PostMessage(hwndDlg, WM_USER + IDIGNORE, 0, 0);
  200. }
  201. break;
  202. default:
  203. {
  204. /****************************************************************/
  205. /* Ignore */
  206. /****************************************************************/
  207. }
  208. break;
  209. }
  210. return(rc);
  211. } /* TRCAssertDlgProc */
  212. /****************************************************************************/
  213. /* FUNCTION: TRCDisplayAssertBox(...) */
  214. /* */
  215. /* DESCRIPTION: */
  216. /* ============ */
  217. /* This function displays an assert box and then decides (based on the user */
  218. /* action) whether to kill the thread, jump into a debugger or just ignore */
  219. /* the assert. */
  220. /* */
  221. /* PARAMETERS: */
  222. /* =========== */
  223. /* pText : a pointer to the null-terminated assert text string. */
  224. /* */
  225. /* RETURNS: */
  226. /* ======== */
  227. /* Nothing. */
  228. /* */
  229. /****************************************************************************/
  230. DCVOID DCINTERNAL TRCDisplayAssertBox(PDCTCHAR pText)
  231. {
  232. HWND hwndDlg;
  233. MSG msg;
  234. DCINT rc;
  235. HRESULT hr;
  236. TCHAR szFormattedText[TRC_FRMT_BUFFER_SIZE];
  237. /************************************************************************/
  238. /* If we are not currently displaying an assert dialog box then display */
  239. /* one. This function will display an assert box and then handle the */
  240. /* user action (i.e. whether we kill the thread, jump into the */
  241. /* debugger or just ignore (!) the assert). */
  242. /* */
  243. /* Note that the testing and setting of the flag is not done under a */
  244. /* mutex and therefore can potentially be preempted. There is */
  245. /* therefore the possibility that multiple threads can assert */
  246. /* simulataneously (a rare occurance) and thus we end up with multiple */
  247. /* assert dialogs on the screen. However we avoid the cascading assert */
  248. /* problem. */
  249. /************************************************************************/
  250. if (TEST_FLAG(trcpFilter->trcStatus, TRC_STATUS_ASSERT_DISPLAYED))
  251. {
  252. DC_QUIT;
  253. }
  254. /************************************************************************/
  255. /* Set the flag to indicate that an assert is currently displayed, */
  256. /* display the assert and then clear the flag. */
  257. /************************************************************************/
  258. SET_FLAG(trcpFilter->trcStatus, TRC_STATUS_ASSERT_DISPLAYED);
  259. /************************************************************************/
  260. /* To prevent re-entrancy, do not use MessageBox. Create a dialog and */
  261. /* use a message loop to handle this until it has been dismissed. Note */
  262. /* that this will block the thread which issued the assert. */
  263. /* Pass the assert text to the dialog's WM_INITDDIALOG callback. */
  264. /************************************************************************/
  265. hwndDlg = CreateDialogParam(trchModule,
  266. MAKEINTRESOURCE(TRC_IDD_ASSERT),
  267. NULL,
  268. TRCAssertDlgProc,
  269. (LPARAM)(pText));
  270. if (hwndDlg == NULL)
  271. {
  272. /********************************************************************/
  273. /* Use Message Box - but note that this will give reentrancy */
  274. /* problems. Since the choice on this dialog is */
  275. /* Abort/Retry/Ignore, we add an explanatory message to the effect */
  276. /* that 'Retry' is really 'Debug'. */
  277. /********************************************************************/
  278. hr = StringCchPrintf(szFormattedText,
  279. SIZE_TCHARS(szFormattedText),
  280. _T("%s %s"),
  281. pText,
  282. TRC_ASSERT_TEXT2);
  283. if (SUCCEEDED(hr)) {
  284. rc = MessageBox(NULL,
  285. pText,
  286. TRC_ASSERT_TITLE,
  287. MB_ABORTRETRYIGNORE | MB_ICONSTOP |
  288. MB_SETFOREGROUND);
  289. }
  290. else {
  291. DC_QUIT;
  292. }
  293. }
  294. else
  295. {
  296. /********************************************************************/
  297. /* Show the dialog. */
  298. /********************************************************************/
  299. ShowWindow(hwndDlg, SW_SHOW);
  300. /********************************************************************/
  301. /* Only pull off messages for this dialog. */
  302. /********************************************************************/
  303. while (GetMessage (&msg, hwndDlg, 0, 0))
  304. {
  305. TranslateMessage(&msg);
  306. DispatchMessage(&msg);
  307. /****************************************************************/
  308. /* WM_USER + ID??? is used to terminate processing. */
  309. /****************************************************************/
  310. if (msg.message >= WM_USER)
  311. {
  312. /************************************************************/
  313. /* finished */
  314. /************************************************************/
  315. EndDialog(hwndDlg, IDOK);
  316. break;
  317. }
  318. }
  319. /********************************************************************/
  320. /* Get the return code from the message ID */
  321. /********************************************************************/
  322. if (msg.message >= WM_USER)
  323. {
  324. rc = msg.message - WM_USER;
  325. }
  326. else
  327. {
  328. /****************************************************************/
  329. /* WM_QUIT - treat as an Abort. */
  330. /****************************************************************/
  331. rc = IDABORT;
  332. }
  333. }
  334. /************************************************************************/
  335. /* Now that the assert box is no more, clear the flag. */
  336. /************************************************************************/
  337. CLEAR_FLAG(trcpFilter->trcStatus, TRC_STATUS_ASSERT_DISPLAYED);
  338. /************************************************************************/
  339. /* Switch on the return code from MessageBox. */
  340. /************************************************************************/
  341. switch (rc)
  342. {
  343. case IDABORT:
  344. {
  345. /****************************************************************/
  346. /* Abort selected - so exit the current thread. */
  347. /****************************************************************/
  348. TRCExitProcess(TRC_THREAD_EXIT);
  349. }
  350. break;
  351. case IDRETRY:
  352. {
  353. /****************************************************************/
  354. /* Retry selected - jump into the debugger if JIT (Just In */
  355. /* Time) debugging is enabled. */
  356. /****************************************************************/
  357. DebugBreak();
  358. }
  359. break;
  360. case IDIGNORE:
  361. {
  362. /****************************************************************/
  363. /* Ignore selected - just blindly carry on... */
  364. /****************************************************************/
  365. }
  366. break;
  367. }
  368. DC_EXIT_POINT:
  369. return;
  370. } /* TRCDisplayAssertBox */
  371. /****************************************************************************/
  372. /* FUNCTION: TRCInternalTrace(...) */
  373. /* */
  374. /* DESCRIPTION: */
  375. /* ============ */
  376. /* This function writes a string to the debugger on every process attach */
  377. /* detach. Note that in general the mutex will not have been obtained */
  378. /* when this function is called. */
  379. /* */
  380. /* The problem with this function is that DllMain will call this function */
  381. /* every time a thread attaches / detaches at which point it has the */
  382. /* process critical section. However we may be in the middle of a stack */
  383. /* trace on another thread and holding the trace mutex. Stack tracing */
  384. /* requires the process critical section while holding the trace mutex */
  385. /* which deadlocks if DllMain is waiting on the trace mutex. */
  386. /* */
  387. /* PARAMETERS: */
  388. /* =========== */
  389. /* type : is this an process/thread attach/detach or a symbols */
  390. /* loading/loaded/unloaded. */
  391. /* */
  392. /* RETURNS: */
  393. /* ======== */
  394. /* Nothing. */
  395. /* */
  396. /****************************************************************************/
  397. DCVOID DCINTERNAL TRCInternalTrace(DCUINT32 type)
  398. {
  399. PDCTCHAR pStatus;
  400. DC_DATE theDate;
  401. DC_TIME theTime;
  402. DCUINT32 processId;
  403. DCUINT32 threadId;
  404. DCUINT32 length;
  405. DCTCHAR szOutputBuffer[TRC_FRMT_BUFFER_SIZE];
  406. HRESULT hr;
  407. /************************************************************************/
  408. /* Determine whether this is an attach or a detach. */
  409. /************************************************************************/
  410. switch (type)
  411. {
  412. case TRC_TRACE_DLL_INITIALIZE:
  413. {
  414. pStatus = _T("Trace initialized");
  415. }
  416. break;
  417. case TRC_TRACE_DLL_TERMINATE:
  418. {
  419. pStatus = _T("Trace terminated ");
  420. }
  421. break;
  422. case TRC_PROCESS_ATTACH_NOTIFY:
  423. {
  424. pStatus = _T("Process attached ");
  425. }
  426. break;
  427. case TRC_PROCESS_DETACH_NOTIFY:
  428. {
  429. pStatus = _T("Process detached ");
  430. }
  431. break;
  432. case TRC_THREAD_ATTACH_NOTIFY:
  433. {
  434. pStatus = _T("Thread attached ");
  435. }
  436. break;
  437. case TRC_THREAD_DETACH_NOTIFY:
  438. {
  439. pStatus = _T("Thread detached ");
  440. }
  441. break;
  442. case TRC_SYMBOLS_LOADING_NOTIFY:
  443. {
  444. pStatus = _T("Loading symbols ");
  445. }
  446. break;
  447. case TRC_SYMBOLS_LOADED_NOTIFY:
  448. {
  449. pStatus = _T("Symbols loaded ");
  450. }
  451. break;
  452. case TRC_SYMBOLS_UNLOAD_NOTIFY:
  453. {
  454. pStatus = _T("Symbols freed ");
  455. }
  456. break;
  457. case TRC_FILES_RESET:
  458. {
  459. pStatus = _T("Trace files reset");
  460. }
  461. break;
  462. default:
  463. {
  464. pStatus = _T("Undefined ");
  465. }
  466. break;
  467. }
  468. /************************************************************************/
  469. /* Get the current date and time. */
  470. /************************************************************************/
  471. TRCGetCurrentDate(&theDate);
  472. TRCGetCurrentTime(&theTime);
  473. /************************************************************************/
  474. /* Get our process and thread IDs. */
  475. /************************************************************************/
  476. processId = TRCGetCurrentProcessId();
  477. threadId = TRCGetCurrentThreadId();
  478. /************************************************************************/
  479. /* Format the attach/detach string. */
  480. /************************************************************************/
  481. hr = StringCchPrintf(
  482. szOutputBuffer,
  483. SIZE_TCHARS(szOutputBuffer),
  484. _T("### %s (") TRC_PROC_FMT _T(":") TRC_THRD_FMT _T(") at ")
  485. _T("") TRC_TIME_FMT _T(" ") TRC_DATE_FMT _T(" ###\r\n"),
  486. pStatus,
  487. processId,
  488. threadId,
  489. theTime.hour,
  490. theTime.min,
  491. theTime.sec,
  492. theTime.hundredths,
  493. theDate.day,
  494. theDate.month,
  495. theDate.year
  496. );
  497. if (SUCCEEDED(hr)) {
  498. /************************************************************************/
  499. /* Now output this string to the debugger. We can't output this to */
  500. /* file as we need to have the trace mutex to do that and we may not */
  501. /* have the mutex. To avoid confusion we only write to the debugger. */
  502. /************************************************************************/
  503. length = DC_TSTRLEN(szOutputBuffer);
  504. OutputDebugString(szOutputBuffer);
  505. }
  506. return;
  507. } /* TRCInternalTrace */
  508. /****************************************************************************/
  509. /* FUNCTION: TRCMaybeSwapFile(...) */
  510. /* */
  511. /* DESCRIPTION: */
  512. /* ============ */
  513. /* This function checks if the current trace file has enough space to */
  514. /* accomodate a string of the supplied length and, if not, makes the other */
  515. /* trace file current. */
  516. /* */
  517. /* PARAMETERS: */
  518. /* =========== */
  519. /* length : length of the string. */
  520. /* */
  521. /* RETURNS: */
  522. /* ======== */
  523. /* Nothing. */
  524. /* */
  525. /****************************************************************************/
  526. DCVOID DCINTERNAL TRCMaybeSwapFile(DCUINT length)
  527. {
  528. /************************************************************************/
  529. /* If the length of the string plus the offset is greater than the */
  530. /* length of the trace file then we need to swap trace files. */
  531. /************************************************************************/
  532. if ((trcpSharedData->trcOffset + length) > trcpConfig->maxFileSize)
  533. {
  534. /********************************************************************/
  535. /* We need to swap trace files so set the offset to 0 and then */
  536. /* flip the trace file. */
  537. /********************************************************************/
  538. trcpSharedData->trcOffset = 0;
  539. trcpSharedData->trcIndicator++;
  540. trcpSharedData->trcIndicator %= TRC_NUM_FILES;
  541. /********************************************************************/
  542. /* Now we need to reset the new trace file by blanking it out. */
  543. /********************************************************************/
  544. TRCBlankFile(trcpSharedData->trcIndicator);
  545. }
  546. DC_EXIT_POINT:
  547. return;
  548. } /* TRCOutputToFile */
  549. /****************************************************************************/
  550. /* FUNCTION: TRCReadProfInt(...) */
  551. /* */
  552. /* DESCRIPTION: */
  553. /* ============ */
  554. /* This reads a private profile integer from the registry. */
  555. /* */
  556. /* PARAMETERS: */
  557. /* =========== */
  558. /* pSection : section containing the entry to read */
  559. /* pEntry : entry name of integer to retrieve */
  560. /* pValue : buffer to return the entry in */
  561. /* */
  562. /* RETURNS: */
  563. /* ======== */
  564. /* 0 : success */
  565. /* TRC_RC_IO_ERROR : I/O error. */
  566. /* */
  567. /****************************************************************************/
  568. DCUINT DCINTERNAL TRCReadProfInt(PDCTCHAR pEntry,
  569. PDCUINT32 pValue)
  570. {
  571. DCUINT rc = 0;
  572. /************************************************************************/
  573. /* First try to read the value from the current user section */
  574. /************************************************************************/
  575. rc = TRCReadEntry(HKEY_CURRENT_USER,
  576. pEntry,
  577. (PDCTCHAR)pValue,
  578. sizeof(*pValue),
  579. REG_DWORD);
  580. if (0 != rc)
  581. {
  582. /********************************************************************/
  583. /* Couldn't read the value from the current user section. Try to */
  584. /* pick up a default value from the local machine section. */
  585. /********************************************************************/
  586. rc = TRCReadEntry(HKEY_LOCAL_MACHINE,
  587. pEntry,
  588. (PDCTCHAR)pValue,
  589. sizeof(*pValue),
  590. REG_DWORD);
  591. if (0 != rc)
  592. {
  593. /****************************************************************/
  594. /* There is nothing we can do so just fall through. */
  595. /****************************************************************/
  596. }
  597. }
  598. return(rc);
  599. } /* TRCReadProfInt */
  600. /****************************************************************************/
  601. /* FUNCTION: TRCReadProfString(...) */
  602. /* */
  603. /* DESCRIPTION: */
  604. /* ============ */
  605. /* This reads a private profile string from registry. */
  606. /* */
  607. /* PARAMETERS: */
  608. /* =========== */
  609. /* pSection : section containing the entry to read. */
  610. /* pEntry : entry name of string to retrieve (if NULL all entries */
  611. /* in the section are returned). */
  612. /* pBuffer : buffer to return the entry in. */
  613. /* bufferSize : size of the buffer in bytes. */
  614. /* */
  615. /* RETURNS: */
  616. /* ======== */
  617. /* 0 : success. */
  618. /* TRC_RC_IO_ERROR : I/O error. */
  619. /* */
  620. /****************************************************************************/
  621. DCUINT DCINTERNAL TRCReadProfString(PDCTCHAR pEntry,
  622. PDCTCHAR pBuffer,
  623. DCINT16 bufferSize)
  624. {
  625. DCUINT rc = 0;
  626. /************************************************************************/
  627. /* First try to read the value from the current user section. */
  628. /************************************************************************/
  629. rc = TRCReadEntry(HKEY_CURRENT_USER,
  630. pEntry,
  631. pBuffer,
  632. bufferSize,
  633. REG_SZ);
  634. if (0 != rc)
  635. {
  636. /********************************************************************/
  637. /* Couldn't read the value from the current user section. Try to */
  638. /* pick up a default value from the local machine section. */
  639. /********************************************************************/
  640. rc = TRCReadEntry(HKEY_LOCAL_MACHINE,
  641. pEntry,
  642. pBuffer,
  643. bufferSize,
  644. REG_SZ);
  645. if (0 != rc)
  646. {
  647. /****************************************************************/
  648. /* There is nothing we can do so just fall through. */
  649. /****************************************************************/
  650. }
  651. }
  652. return(rc);
  653. } /* TRCReadProfString */
  654. /****************************************************************************/
  655. /* FUNCTION: TRCResetTraceFiles(...) */
  656. /* */
  657. /* DESCRIPTION: */
  658. /* ============ */
  659. /* This function resets the trace files. It nulls out both trace files */
  660. /* and then resets the file offset to 0 and the file indicator to file 0. */
  661. /* */
  662. /* PARAMETERS: */
  663. /* =========== */
  664. /* None. */
  665. /* */
  666. /* RETURNS: */
  667. /* ======== */
  668. /* Nothing. */
  669. /* */
  670. /****************************************************************************/
  671. DCVOID DCINTERNAL TRCResetTraceFiles(DCVOID)
  672. {
  673. DCUINT i;
  674. /************************************************************************/
  675. /* Blank out the trace files. Note that we must have the mutex at this */
  676. /* point. */
  677. /************************************************************************/
  678. for (i = 0; i < TRC_NUM_FILES; i++)
  679. {
  680. TRCBlankFile(i);
  681. }
  682. /************************************************************************/
  683. /* Set the trace file indicator to file 0 and set the file offset to 0. */
  684. /************************************************************************/
  685. trcpSharedData->trcIndicator = 0;
  686. trcpSharedData->trcOffset = 0;
  687. /************************************************************************/
  688. /* Output a debug string. */
  689. /************************************************************************/
  690. TRCInternalTrace(TRC_FILES_RESET);
  691. } /* TRCResetTraceFiles */
  692. /****************************************************************************/
  693. /* FUNCTION: TRCWriteProfInt(...) */
  694. /* */
  695. /* DESCRIPTION: */
  696. /* ============ */
  697. /* This writes a private profile integer to the registry. */
  698. /* */
  699. /* PARAMETERS: */
  700. /* =========== */
  701. /* pSection : section containing the entry written */
  702. /* pEntry : entry name of integer to write. If the entry does not */
  703. /* exist it is created and if it is NULL the entire */
  704. /* section is deleted. */
  705. /* pValue : pointer to the integer to be written. If the pointer */
  706. /* is NULL the entry is deleted. */
  707. /* */
  708. /* RETURNS: */
  709. /* ======== */
  710. /* 0 : success */
  711. /* TRC_RC_IO_ERROR : I/O error. */
  712. /* */
  713. /****************************************************************************/
  714. DCUINT DCINTERNAL TRCWriteProfInt(PDCTCHAR pEntry,
  715. PDCUINT32 pValue)
  716. {
  717. DCUINT rc = 0;
  718. /************************************************************************/
  719. /* Write the entry to the current user section. */
  720. /************************************************************************/
  721. rc = TRCWriteEntry(HKEY_CURRENT_USER,
  722. pEntry,
  723. (PDCTCHAR)pValue,
  724. sizeof(DCINT),
  725. REG_DWORD);
  726. if (0 != rc)
  727. {
  728. TRCDebugOutput(_T("Failed to write int"));
  729. }
  730. return(rc);
  731. } /* TRCWriteProfInt */
  732. /****************************************************************************/
  733. /* FUNCTION: TRCWriteProfString(...) */
  734. /* */
  735. /* DESCRIPTION: */
  736. /* ============ */
  737. /* This writes a private profile string to the registry. */
  738. /* */
  739. /* PARAMETERS: */
  740. /* =========== */
  741. /* pSection : section containing the entry written */
  742. /* pEntry : entry name of string to write. If the entry does not */
  743. /* exist it is created and if it is NULL the entire */
  744. /* section is deleted. */
  745. /* pBuffer : buffer containing the entry. If the buffer is NULL */
  746. /* the entry is deleted. */
  747. /* */
  748. /* RETURNS: */
  749. /* ======== */
  750. /* 0 : success */
  751. /* TRC_RC_IO_ERROR : I/O error. */
  752. /* */
  753. /****************************************************************************/
  754. DCUINT DCINTERNAL TRCWriteProfString(PDCTCHAR pEntry,
  755. PDCTCHAR pBuffer)
  756. {
  757. DCUINT rc = 0;
  758. /************************************************************************/
  759. /* Write the entry to the current user section */
  760. /************************************************************************/
  761. rc = TRCWriteEntry(HKEY_CURRENT_USER,
  762. pEntry,
  763. pBuffer,
  764. DC_TSTRBYTELEN(pBuffer),
  765. REG_SZ);
  766. if (0 != rc)
  767. {
  768. TRCDebugOutput(_T("Failed to write string"));
  769. }
  770. return(rc);
  771. } /* TRCWriteProfString */
  772. #include <ntrcint.c>