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.

104 lines
4.8 KiB

  1. //*************************************************************
  2. //
  3. // Header file for Util.c
  4. //
  5. // Microsoft Confidential
  6. // Copyright (c) Microsoft Corporation 1995
  7. // All rights reserved
  8. //
  9. //*************************************************************
  10. #define FreeProducedString(psz) if((psz) != NULL) {LocalFree(psz);} else
  11. #define CCH_MAX_DEC 12 // Number of chars needed to hold 2^32 for IntToString
  12. LPWSTR ProduceWFromA(LPCSTR pszA);
  13. LPSTR ProduceAFromW(LPCWSTR pszW);
  14. LPTSTR CheckSlash (LPTSTR lpDir);
  15. LPTSTR CheckSlashEx(LPTSTR lpDir, UINT cchBuffer, UINT* pcchRemain );
  16. LPTSTR CheckSemicolon (LPTSTR lpDir);
  17. BOOL Delnode (LPTSTR lpDir);
  18. UINT CreateNestedDirectory(LPCTSTR lpDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
  19. UINT CreateNestedDirectoryEx(LPCTSTR lpDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes, BOOL bInheritEncryption);
  20. BOOL GetProfilesDirectoryEx(LPTSTR lpProfilesDir, LPDWORD lpcchSize, BOOL bExpand);
  21. BOOL GetDefaultUserProfileDirectoryEx (LPTSTR lpProfileDir, LPDWORD lpcchSize, BOOL bExpand);
  22. BOOL GetAllUsersProfileDirectoryEx (LPTSTR lpProfileDir, LPDWORD lpcchSize, BOOL bExpand);
  23. int StringToInt(LPTSTR lpNum);
  24. BOOL DeleteAllValues(HKEY hKey);
  25. BOOL MakeFileSecure (LPTSTR lpFile, DWORD dwOtherSids);
  26. BOOL GetSpecialFolderPath (INT csidl, LPTSTR lpPath);
  27. BOOL GetFolderPath (INT csidl, HANDLE hToken, LPTSTR lpPath);
  28. BOOL SetFolderPath (INT csidl, HANDLE hToken, LPTSTR lpPath);
  29. void CenterWindow (HWND hwnd);
  30. BOOL UnExpandSysRoot(LPCTSTR lpFile, LPTSTR lpResult, DWORD cchResult);
  31. LPTSTR AllocAndExpandEnvironmentStrings(LPCTSTR lpszSrc);
  32. void IntToString( INT i, LPTSTR sz);
  33. BOOL IsUserAGuest(HANDLE hToken);
  34. BOOL IsUserAnAdminMember(HANDLE hToken);
  35. BOOL IsUserALocalSystemMember(HANDLE hToken);
  36. BOOL IsUserAnInteractiveUser(HANDLE hToken);
  37. DWORD CheckUserInMachineForest(HANDLE hUserToken, BOOL* bInThisForest);
  38. BOOL MakeRegKeySecure(HANDLE hToken, HKEY hKeyRoot, LPTSTR lpKeyName);
  39. BOOL FlushSpecialFolderCache (void);
  40. BOOL CheckForVerbosePolicy (void);
  41. int ExtractCSIDL(LPCTSTR pcszPath, LPTSTR* ppszUsualPath);
  42. LPTSTR MyGetDomainDNSName (VOID);
  43. LPTSTR MyGetUserName (EXTENDED_NAME_FORMAT NameFormat);
  44. LPTSTR MyGetUserNameEx (EXTENDED_NAME_FORMAT NameFormat);
  45. LPTSTR MyGetComputerName (EXTENDED_NAME_FORMAT NameFormat);
  46. void StringToGuid( TCHAR *szValue, GUID *pGuid );
  47. void GuidToString( const GUID *pGuid, TCHAR * szValue);
  48. void GuidToStringEx( const GUID *pGuid, TCHAR * szValue, UINT cchValue);
  49. BOOL ValidateGuid( TCHAR *szValue );
  50. BOOL ValidateGuidPrefix( TCHAR *szValue );
  51. INT CompareGuid( GUID *pGuid1, GUID *pGuid2 );
  52. BOOL ImpersonateUser (HANDLE hNewUser, HANDLE *hOldUser);
  53. BOOL RevertToUser (HANDLE *hUser);
  54. BOOL RegCleanUpValue (HKEY hKeyRoot, LPTSTR lpSubKey, LPTSTR lpValueName);
  55. BOOL CreateSecureAdminDirectory (LPTSTR lpDirectory, DWORD dwOtherSids);
  56. BOOL AddPowerUserAce (LPTSTR lpFile);
  57. void ClosePingCritSec(void);
  58. LPTSTR GetUserGuid(HANDLE hToken);
  59. LPTSTR GetOldSidString(HANDLE hToken, LPTSTR lpKeyName);
  60. BOOL SetOldSidString(HANDLE hToken, LPTSTR lpSidString, LPTSTR lpKeyName);
  61. LPTSTR GetErrString(DWORD dwErr, LPTSTR szErr);
  62. LONG RegRenameKey(HKEY hKeyRoot, LPTSTR lpSrcKey, LPTSTR lpDestKey);
  63. BOOL IsNullGUID (GUID *pguid);
  64. BOOL GetMachineRole (LPINT piRole);
  65. BOOL IsUNCPath(LPCTSTR lpPath);
  66. LPTSTR MakePathUNC(LPTSTR pwszFile, LPTSTR szComputerName);
  67. LPTSTR SupportLongFileName (LPTSTR lpDir, LPDWORD lpWrkDirSize);
  68. BOOL SecureNestedDir (LPTSTR lpDir, PSECURITY_DESCRIPTOR pDirSd, PSECURITY_DESCRIPTOR pFileSd);
  69. BOOL SetEnvironmentVariableInBlock(PVOID *pEnv, LPTSTR lpVariable,
  70. LPTSTR lpValue, BOOL bOverwrite);
  71. DWORD ExpandUserEnvironmentStrings(PVOID pEnv, LPCTSTR lpSrc,
  72. LPTSTR lpDst, DWORD nSize);
  73. LPTSTR ConvertToShareName(LPTSTR lpShare);
  74. DWORD AbleToBypassCSC(HANDLE hTokenUser, LPCTSTR lpDir, LPTSTR *lppCscBypassedPath, TCHAR *cpDrive);
  75. void CancelCSCBypassedConnection(HANDLE hTokenUser, TCHAR cDrive);
  76. LPTSTR GetUserNameFromSid(LPTSTR lpSid);
  77. int GetNetworkName( LPWSTR* pszName, DWORD dwAdapterIndex );
  78. HRESULT GetProfileListKeyName(LPTSTR szKeyName, DWORD cchKeyName, LPTSTR szSidString);
  79. HRESULT SafeExpandEnvironmentStrings(LPCTSTR lpSrc, LPTSTR lpDst, DWORD nSize);
  80. HRESULT AppendName(LPTSTR lpBuffer, UINT cchBuffer, LPCTSTR lpParent, LPCTSTR lpChild, LPTSTR* lppEnd, UINT* pcchEnd);
  81. HRESULT TakeOwnership(LPTSTR lpFileName);
  82. HRESULT AddAdminAccess(LPTSTR lpFileName);
  83. HRESULT SetupPreferenceKey(LPCTSTR lpSidString);
  84. BOOL IsGuiSetupInProgress();
  85. //
  86. // Flags used to specify additional that needs to be present in ACEs
  87. //
  88. #define OTHERSIDS_EVERYONE 1
  89. #define OTHERSIDS_POWERUSERS 2
  90. #ifndef MAX
  91. #define MAX(a,b) (((a)>(b))?(a):(b))
  92. #endif
  93. #ifndef MIN
  94. #define MIN(a,b) (((a)<(b))?(a):(b))
  95. #endif