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.

113 lines
1.9 KiB

  1. //*************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation 1998
  4. // All rights reserved
  5. //
  6. // util.hxx
  7. //
  8. //*************************************************************
  9. #include <strsafe.h>
  10. #if !defined(__CUTIL_HXX__)
  11. #define __CUTIL_HXX__
  12. #define REMAP_DARWIN_STATUS( Status ) \
  13. Status = ((ERROR_SUCCESS_REBOOT_INITIATED == Status) || \
  14. (ERROR_SUCCESS_REBOOT_REQUIRED == Status) || \
  15. (ERROR_INSTALL_SUSPEND == Status)) \
  16. ? ERROR_SUCCESS : Status
  17. #define GUID_LENGTH 38
  18. inline void * __cdecl
  19. operator new (size_t Size)
  20. {
  21. return LocalAlloc(0, Size);
  22. }
  23. inline void __cdecl
  24. operator delete (void * pMem)
  25. {
  26. LocalFree( pMem );
  27. }
  28. void
  29. DwordToString(
  30. DWORD Number,
  31. WCHAR * wszNumber
  32. );
  33. BOOL
  34. LoadUser32Funcs();
  35. BOOL
  36. LoadLoadString();
  37. void
  38. FreeApplicationInfo(
  39. APPLICATION_INFO * ApplicationInfo
  40. );
  41. PSID
  42. AppmgmtGetUserSid(
  43. HANDLE hUserToken = 0
  44. );
  45. void
  46. GuidToString(
  47. GUID & Guid,
  48. PWCHAR pwszGuid
  49. );
  50. void GuidToString(
  51. GUID & Guid,
  52. PWCHAR * ppwszGuid
  53. );
  54. void StringToGuid(
  55. PWCHAR pwszGuid,
  56. GUID * pGuid
  57. );
  58. inline LPWSTR StringDuplicate(LPWSTR wszSource)
  59. {
  60. LPWSTR wszDest;
  61. LONG lSize;
  62. if ( ! wszSource )
  63. {
  64. return NULL;
  65. }
  66. lSize = lstrlen(wszSource) + 1;
  67. if (wszDest = new WCHAR [lSize])
  68. {
  69. (void) StringCchCopy(wszDest, lSize, wszSource);
  70. }
  71. return wszDest;
  72. }
  73. HRESULT CreateGuid(GUID *pGuid);
  74. DWORD ReadStringValue( HKEY hKey, WCHAR * pwszValueName, WCHAR ** ppwszValue );
  75. DWORD
  76. GetSidString(
  77. HANDLE hToken,
  78. UNICODE_STRING* pSidString
  79. );
  80. class CLoadMsi
  81. {
  82. public:
  83. CLoadMsi( DWORD &Status );
  84. ~CLoadMsi();
  85. private:
  86. HINSTANCE hMsi;
  87. };
  88. #endif __CUTIL_HXX__