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.

82 lines
1.4 KiB

  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include "view.h"
  4. #include "thread.h"
  5. #include "dump.h"
  6. #include "except.h"
  7. #include "memory.h"
  8. extern BOOL g_bIsWin9X;
  9. static CRITICAL_SECTION tCritSec;
  10. static PTHREADFAULT pThreadHead = 0;
  11. VOID
  12. InitializeThreadData(VOID)
  13. {
  14. InitializeCriticalSection(&tCritSec);
  15. }
  16. PVOID
  17. GetProfilerThreadData(VOID)
  18. {
  19. PVOID pData;
  20. PTHREADFAULT pTemp = 0;
  21. DWORD dwThreadId;
  22. dwThreadId = GetCurrentThreadId();
  23. EnterCriticalSection(&tCritSec);
  24. pTemp = pThreadHead;
  25. while(pTemp) {
  26. if (pTemp->dwThreadId == dwThreadId) {
  27. break;
  28. }
  29. pTemp = pTemp->pNext;
  30. }
  31. LeaveCriticalSection(&tCritSec);
  32. return pTemp;
  33. }
  34. VOID
  35. SetProfilerThreadData(PVOID pData)
  36. {
  37. PTHREADFAULT pTemp;
  38. EnterCriticalSection(&tCritSec);
  39. pTemp = (PTHREADFAULT)pData;
  40. pTemp->dwThreadId = GetCurrentThreadId();
  41. pTemp->pNext = pThreadHead;
  42. pThreadHead = pTemp;
  43. LeaveCriticalSection(&tCritSec);
  44. }
  45. PTHREADFAULT
  46. AllocateProfilerThreadData(VOID)
  47. {
  48. PTHREADFAULT pTemp = 0;
  49. pTemp = AllocMem(sizeof(THREADFAULT));
  50. if (0 == pTemp) {
  51. return 0;
  52. }
  53. pTemp->dwCallLevel = 0;
  54. pTemp->dwPrevBP = 0;
  55. pTemp->pCallStackList = 0;
  56. pTemp->dwCallMarker = 0;
  57. pTemp->pNext = 0;
  58. //
  59. // Set thread data
  60. //
  61. SetProfilerThreadData(pTemp);
  62. return pTemp;
  63. }