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.

53 lines
1.3 KiB

  1. #include <windows.h>
  2. #include <setupapi.h>
  3. #include "globals.h"
  4. #include "sfp.h"
  5. // globals
  6. SFPINSTALLCATALOG g_pfSfpInstallCatalog = NULL;
  7. SFPDELETECATALOG g_pfSfpDeleteCatalog = NULL;
  8. SFPDUPLICATECATALOG g_pfSfpDuplicateCatalog = NULL;
  9. // static variables
  10. static HINSTANCE s_hSfcDll = NULL;
  11. BOOL LoadSfcDLL()
  12. {
  13. BOOL bRet = FALSE;
  14. if ((s_hSfcDll = LoadLibrary("sfc.dll")) != NULL)
  15. {
  16. // ordinal 8 is SfpInstallCatalog, and
  17. // ordinal 9 is SfpDeleteCatalog
  18. g_pfSfpInstallCatalog = (SFPINSTALLCATALOG) GetProcAddress(s_hSfcDll, MAKEINTRESOURCE(8));
  19. g_pfSfpDeleteCatalog = (SFPDELETECATALOG) GetProcAddress(s_hSfcDll, MAKEINTRESOURCE(9));
  20. g_pfSfpDuplicateCatalog = (SFPDUPLICATECATALOG) GetProcAddress(s_hSfcDll, "SfpDuplicateCatalog");
  21. if (g_pfSfpInstallCatalog != NULL &&
  22. g_pfSfpDeleteCatalog != NULL &&
  23. g_pfSfpDuplicateCatalog != NULL)
  24. {
  25. bRet = TRUE;
  26. }
  27. }
  28. else
  29. {
  30. DWORD dwRet = GetLastError();
  31. AdvWriteToLog("LoadSfcDLL: LoadLibrary of sfc.dll failed with %1!lu!\r\n", dwRet);
  32. }
  33. return bRet;
  34. }
  35. VOID UnloadSfcDLL()
  36. {
  37. if (s_hSfcDll != NULL)
  38. {
  39. FreeLibrary(s_hSfcDll);
  40. s_hSfcDll = NULL;
  41. }
  42. }