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.

110 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. autolog.cxx
  5. Abstract:
  6. autolog
  7. Author:
  8. Larry Zhu (LZhu) December 1, 2001 Created
  9. Environment:
  10. User Mode
  11. Revision History:
  12. --*/
  13. #include "precomp.hxx"
  14. #pragma hdrstop
  15. #include "autolog.hxx"
  16. VOID __cdecl
  17. _tmain(
  18. IN INT argc,
  19. IN PTSTR argv[]
  20. )
  21. {
  22. TimeStamp CurrentTime = {0};
  23. AUTO_LOG_OPEN(TEXT("autolog.exe"));
  24. TNtStatus Status = STATUS_UNSUCCESSFUL;
  25. Status DBGCHK = STATUS_INVALID_PARAMETER;
  26. THResult hResult = E_FAIL;
  27. hResult DBGCHK = E_INVALIDARG;
  28. DBGCFG1(Status, STATUS_INVALID_PARAMETER);
  29. DBGCFG1(hResult, E_INVALIDARG);
  30. SspiPrint(SSPI_LOG, TEXT("No traces\n"));
  31. Status DBGCHK = STATUS_INVALID_PARAMETER;
  32. hResult DBGCHK = E_INVALIDARG;
  33. hResult DBGNOCHK = E_OUTOFMEMORY;
  34. Status DBGNOCHK = STATUS_NO_MEMORY;
  35. SspiPrint(SSPI_LOG, TEXT("With traces\n"));
  36. hResult DBGCHK = E_OUTOFMEMORY;
  37. hResult DBGCHK = S_OK;
  38. if (SUCCEEDED(hResult))
  39. {
  40. SspiPrint(SSPI_LOG, TEXT("This exe file name is %s\n"), argv[0]);
  41. GetSystemTimeAsFileTime((PFILETIME) &CurrentTime);
  42. SspiPrintHex(SSPI_LOG, TEXT("CurrentTime"), sizeof(CurrentTime), &CurrentTime);
  43. SspiPrintSysTimeAsLocalTime(SSPI_LOG, TEXT("CurrentTime"), &CurrentTime);
  44. }
  45. if (SUCCEEDED(hResult))
  46. {
  47. SspiPrint(SSPI_ERROR, TEXT("can not be here\n"));
  48. }
  49. else if (FAILED(hResult))
  50. {
  51. SspiPrint(SSPI_LOG, TEXT("right\n"));
  52. }
  53. hResult DBGCHK = E_OUTOFMEMORY;
  54. Status DBGCHK = STATUS_NO_MEMORY;
  55. //
  56. // how to use exceptions
  57. //
  58. // add /EHa into sources
  59. //
  60. // USER_C_FLAGS=$(USER_C_FLAGS) /EHa
  61. //
  62. SET_DBGSTATE_TRANS_FUNC(DbgStateC2CppExceptionTransFunc);
  63. try
  64. {
  65. int* p = NULL;
  66. *p = 0;
  67. }
  68. catch (UINT code)
  69. {
  70. SspiPrint(SSPI_WARN, TEXT("Exception caught %#x\n"), code);
  71. }
  72. AUTO_LOG_CLOSE();
  73. }