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.

91 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. common.cxx
  6. Abstract:
  7. utils
  8. Author:
  9. Larry Zhu (LZhu) December 1, 2001 Created
  10. Environment:
  11. User Mode -Win32
  12. Revision History:
  13. --*/
  14. #include "precomp.hxx"
  15. #pragma hdrstop
  16. #include "common.hxx"
  17. BOOL
  18. DllMainDefaultHandler(
  19. IN HANDLE hModule,
  20. IN DWORD dwReason,
  21. IN DWORD dwReserved
  22. )
  23. {
  24. static CHAR szPrompt[MAX_PATH] = {0};
  25. switch (dwReason)
  26. {
  27. case DLL_THREAD_ATTACH:
  28. break;
  29. case DLL_THREAD_DETACH:
  30. break;
  31. case DLL_PROCESS_DETACH:
  32. DebugPrintf(SSPI_LOG, "DllMainDefaultHandler: DLL_PROCESS_DETACH\n");
  33. DebugLogClose();
  34. break;
  35. case DLL_PROCESS_ATTACH:
  36. {
  37. PSTR pszFileName = NULL;
  38. CHAR szDllPath[MAX_PATH] = {0};
  39. if (0 == GetModuleFileNameA(reinterpret_cast<HMODULE>(hModule), szDllPath, sizeof (szDllPath)))
  40. {
  41. DebugPrintf(SSPI_ERROR,
  42. "GetModuleFileNameA failed with last error %#x\n",
  43. GetLastError());
  44. return FALSE;
  45. }
  46. pszFileName = strrchr (szDllPath, '\\') + 1;
  47. if (!pszFileName)
  48. {
  49. pszFileName = szDllPath;
  50. }
  51. _snprintf(szPrompt, sizeof(szPrompt) - 1, "[%s] ", pszFileName);
  52. DebugLogOpen(szPrompt, -1);
  53. }
  54. DisableThreadLibraryCalls(reinterpret_cast<HMODULE>(hModule));
  55. DebugPrintf(SSPI_LOG, "DllMainDefaultHandler: DLL_PROCESS_ATTACH\n");
  56. break;
  57. default:
  58. break;
  59. }
  60. UNREFERENCED_PARAMETER(dwReserved);
  61. return TRUE;
  62. }