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.

102 lines
2.0 KiB

  1. #include "setupp.h"
  2. #pragma hdrstop
  3. HANDLE MyModuleHandle;
  4. WCHAR MyModuleFileName[MAX_PATH];
  5. BOOL
  6. CommonProcessAttach(
  7. IN BOOL Attach
  8. );
  9. //
  10. // Called by CRT when _DllMainCRTStartup is the DLL entry point
  11. //
  12. BOOL
  13. WINAPI
  14. DllMain(
  15. IN HANDLE DllHandle,
  16. IN DWORD Reason,
  17. IN LPVOID Reserved
  18. )
  19. {
  20. #define FUNCTION L"DllMain"
  21. ULONG MyModuleFileNameLength;
  22. BOOL b;
  23. UNREFERENCED_PARAMETER(Reserved);
  24. b = TRUE;
  25. switch(Reason) {
  26. case DLL_PROCESS_ATTACH:
  27. MyModuleHandle = DllHandle;
  28. MyModuleFileNameLength =
  29. GetModuleFileNameW(MyModuleHandle, MyModuleFileName, RTL_NUMBER_OF(MyModuleFileName));
  30. if (MyModuleFileNameLength == 0) {
  31. SetupDebugPrint1(L"SETUP: GetModuleFileNameW failed in " FUNCTION L", LastError is %d\n", GetLastError());
  32. b = FALSE;
  33. goto Exit;
  34. }
  35. if (MyModuleFileNameLength > RTL_NUMBER_OF(MyModuleFileName)) {
  36. SetupDebugPrint(L"SETUP: GetModuleFileNameW failed in " FUNCTION L", LastError is ERROR_INSUFFICIENT_BUFFER\n");
  37. b = FALSE;
  38. SetLastError(ERROR_INSUFFICIENT_BUFFER);
  39. goto Exit;
  40. }
  41. b = CommonProcessAttach(TRUE);
  42. //
  43. // Fall through to process first thread
  44. //
  45. case DLL_THREAD_ATTACH:
  46. break;
  47. case DLL_PROCESS_DETACH:
  48. CommonProcessAttach(FALSE);
  49. break;
  50. case DLL_THREAD_DETACH:
  51. break;
  52. }
  53. Exit:
  54. return(b);
  55. }
  56. BOOL
  57. CommonProcessAttach(
  58. IN BOOL Attach
  59. )
  60. {
  61. BOOL b;
  62. //
  63. // Assume success for detach, failure for attach
  64. //
  65. b = !Attach;
  66. if(Attach) {
  67. b = pSetupInitializeUtils();
  68. if (b)
  69. {
  70. b = RegisterActionItemListControl(TRUE) && (PlatformSpecificInit() == NO_ERROR);
  71. }
  72. } else {
  73. RegisterActionItemListControl(FALSE);
  74. pSetupUninitializeUtils();
  75. }
  76. return(b);
  77. }