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.

95 lines
1.2 KiB

  1. #include "headers.hxx"
  2. HINSTANCE hResourceModuleHandle = 0;
  3. const wchar_t* RUNTIME_NAME = L"coretest";
  4. DWORD DEFAULT_LOGGING_OPTIONS = Burnslib::Log::OUTPUT_TYPICAL;
  5. // set the HeapFlags to trace allocations to see the leak detection
  6. void
  7. raise()
  8. {
  9. // force an AV
  10. char* null = 0;
  11. *null = 'X';
  12. }
  13. void
  14. DumpStack(DWORD64 stackTrace[], size_t traceMax)
  15. {
  16. for (int i = 0; stackTrace[i] and (i <= traceMax); ++i)
  17. {
  18. ::OutputDebugString(
  19. StackTrace::LookupAddress(stackTrace[i]).c_str());
  20. ::OutputDebugString(L"\r\n");
  21. }
  22. }
  23. void
  24. f3()
  25. {
  26. const size_t TRACE_MAX = 10;
  27. DWORD64 stackTrace[TRACE_MAX];
  28. size_t traceMax = TRACE_MAX;
  29. wchar_t* leak = new wchar_t;
  30. *leak = L'X';
  31. __try
  32. {
  33. raise();
  34. }
  35. __except(
  36. StackTrace::TraceFilter(
  37. stackTrace,
  38. traceMax,
  39. (GetExceptionInformation())->ContextRecord))
  40. {
  41. DumpStack(stackTrace, traceMax);
  42. }
  43. }
  44. void
  45. f2()
  46. {
  47. LOG_FUNCTION2(f2, L"this is f2");
  48. f3();
  49. }
  50. void
  51. f1()
  52. {
  53. LOG_FUNCTION(f1);
  54. f2();
  55. }
  56. VOID
  57. _cdecl
  58. main(int, char **)
  59. {
  60. LOG_FUNCTION(main);
  61. f1();
  62. LOG(L"now ending main");
  63. }