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.

98 lines
2.9 KiB

  1. //
  2. // SafeReg.h
  3. //
  4. // Functions to ensure strings read from the registry are null-terminated.
  5. //
  6. // History:
  7. //
  8. // 2002-03-20 KenSh Created
  9. //
  10. // Copyright (c) 2002 Microsoft Corporation
  11. //
  12. #pragma once
  13. #define REG_E_MORE_DATA HRESULT_FROM_WIN32(ERROR_MORE_DATA)
  14. // Override these if you need a custom allocator for the safe reg functions
  15. #ifndef SafeRegMalloc
  16. #define SafeRegMalloc malloc
  17. #define SafeRegFree(p) ((p) ? free(p) : NULL)
  18. #endif
  19. HRESULT WINAPI SafeRegQueryStringValueCch
  20. (
  21. IN HKEY hkey,
  22. IN LPCTSTR pszValueName,
  23. OUT LPTSTR pszBuf,
  24. IN int cchBuf,
  25. OUT OPTIONAL int* pcchValueSize, // S_OK: chars written, excluding trailing null
  26. // REG_E_MORE_DATA: required size, including null
  27. OUT OPTIONAL BOOL* pfExpandSz = NULL // TRUE if reg string is actually REG_EXPAND_SZ
  28. );
  29. HRESULT WINAPI SafeRegQueryStringValueCb
  30. (
  31. IN HKEY hkey,
  32. IN LPCTSTR pszValueName,
  33. OUT LPTSTR pszBuf,
  34. IN int cbBuf,
  35. OUT OPTIONAL int* pcbValueSize, // S_OK: bytes written, excluding trailing null
  36. // REG_E_MORE_DATA: required size, including null
  37. OUT OPTIONAL BOOL* pfExpandSz = NULL // TRUE if reg string is actually REG_EXPAND_SZ
  38. );
  39. HRESULT WINAPI SafeRegQueryMultiStringValueCch
  40. (
  41. IN HKEY hkey,
  42. IN LPCTSTR pszValueName,
  43. OUT LPTSTR pszBuf,
  44. IN int cchBuf,
  45. OUT OPTIONAL int* pcchValueSize // S_OK: chars written, excluding final trailing null
  46. // REG_E_MORE_DATA: required size, including nulls
  47. );
  48. HRESULT WINAPI SafeRegQueryMultiStringValueCb
  49. (
  50. IN HKEY hkey,
  51. IN LPCTSTR pszValueName,
  52. OUT LPTSTR pszBuf,
  53. IN int cbBuf,
  54. OUT OPTIONAL int* pcbValueSize // S_OK: bytes written, excluding final trailing null
  55. // REG_E_MORE_DATA: required size, including nulls
  56. );
  57. HRESULT WINAPI SafeRegQueryStringValueCchAlloc
  58. (
  59. IN HKEY hkey,
  60. IN LPCTSTR pszValueName,
  61. OUT LPTSTR* ppszBuf,
  62. OUT OPTIONAL int* pcchValueSize, // chars written, excluding trailing null
  63. OUT OPTIONAL BOOL* pfExpandSz = NULL //TRUE if reg string is actually REG_EXPAND_SZ
  64. );
  65. HRESULT WINAPI SafeRegQueryStringValueCbAlloc
  66. (
  67. IN HKEY hkey,
  68. IN LPCTSTR pszValueName,
  69. OUT LPTSTR* ppszBuf,
  70. OUT OPTIONAL int* pcbValueSize, // bytes written, excluding trailing null
  71. OUT OPTIONAL BOOL* pfExpandSz = NULL // TRUE if reg string is actually REG_EXPAND_SZ
  72. );
  73. HRESULT WINAPI SafeRegQueryMultiStringValueCchAlloc
  74. (
  75. IN HKEY hkey,
  76. IN LPCTSTR pszValueName,
  77. OUT LPTSTR* ppszBuf,
  78. OUT OPTIONAL int* pcchValueSize // chars written, excluding final trailing null
  79. );
  80. HRESULT WINAPI SafeRegQueryMultiStringValueCbAlloc
  81. (
  82. IN HKEY hkey,
  83. IN LPCTSTR pszValueName,
  84. OUT LPTSTR* ppszBuf,
  85. OUT OPTIONAL int* pcchValueSize // chars written, excluding final trailing null
  86. );