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.

68 lines
2.1 KiB

  1. #include "precomp.h"
  2. #include <sddl.h>
  3. #include "ssdlhelper.h"
  4. SDDL sddl_wrapper;
  5. SDDL::function_type
  6. SDDL::GetFunction(void)
  7. {
  8. function_type return_function = DummyConvertStringSecurityDescriptorToSecurityDescriptor;
  9. if (lock_.acquire())
  10. {
  11. return_function = current_function_;
  12. if (current_function_==0)
  13. {
  14. HMODULE advapi = LoadLibrary(L"advapi32.dll");
  15. if (advapi)
  16. {
  17. current_function_ = (function_type)GetProcAddress(advapi,"ConvertStringSecurityDescriptorToSecurityDescriptorW");
  18. FreeLibrary(advapi);
  19. }
  20. if (current_function_==0)
  21. {
  22. current_function_ = DummyConvertStringSecurityDescriptorToSecurityDescriptor;
  23. }
  24. return_function = current_function_;
  25. }
  26. lock_.release();
  27. };
  28. return return_function;
  29. };
  30. BOOL SDDL::ConvertStringSecurityDescriptorToSecurityDescriptor(
  31. LPCTSTR StringSecurityDescriptor, // security descriptor string
  32. DWORD StringSDRevision, // revision level
  33. PSECURITY_DESCRIPTOR *SecurityDescriptor, // SD
  34. PULONG SecurityDescriptorSize // SD size
  35. )
  36. {
  37. return (sddl_wrapper.GetFunction())(StringSecurityDescriptor,
  38. StringSDRevision,
  39. SecurityDescriptor,
  40. SecurityDescriptorSize);
  41. };
  42. BOOL SDDL::DummyConvertStringSecurityDescriptorToSecurityDescriptor(
  43. LPCTSTR StringSecurityDescriptor, // security descriptor string
  44. DWORD StringSDRevision, // revision level
  45. PSECURITY_DESCRIPTOR *SecurityDescriptor, // SD
  46. PULONG SecurityDescriptorSize // SD size
  47. )
  48. {
  49. if (SecurityDescriptor==0)
  50. return ERROR_INVALID_PARAMETER;
  51. if (SecurityDescriptorSize)
  52. *SecurityDescriptorSize = 0;
  53. *SecurityDescriptor = 0;
  54. return TRUE;
  55. };
  56. bool SDDL::hasSDDLSupport()
  57. {
  58. return sddl_wrapper.GetFunction() != DummyConvertStringSecurityDescriptorToSecurityDescriptor;
  59. }