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.

228 lines
6.4 KiB

  1. /*****************************************************************************/
  2. /*
  3. /* Copyright (c) 2001 Microsoft Corporation, All Rights Reserved /
  4. /*
  5. /*****************************************************************************/
  6. #ifndef __WMI_FilePrivateProfile_H__
  7. #define __WMI_FilePrivateProfile_H__
  8. DWORD
  9. APIENTRY
  10. WMI_FILE_GetPrivateProfileStringW(
  11. LPCWSTR lpAppName,
  12. LPCWSTR lpKeyName,
  13. LPCWSTR lpDefault,
  14. LPWSTR lpReturnedString,
  15. DWORD nSize,
  16. LPCWSTR lpFileName
  17. );
  18. UINT
  19. APIENTRY
  20. WMI_FILE_GetPrivateProfileIntW(
  21. LPCWSTR lpAppName,
  22. LPCWSTR lpKeyName,
  23. INT nDefault,
  24. LPCWSTR lpFileName
  25. );
  26. BOOL
  27. APIENTRY
  28. WMI_FILE_WritePrivateProfileStringW(
  29. LPCWSTR lpAppName,
  30. LPCWSTR lpKeyName,
  31. LPCWSTR lpString,
  32. LPCWSTR lpFileName
  33. );
  34. DWORD
  35. APIENTRY
  36. WMI_FILE_GetPrivateProfileSectionW(
  37. LPCWSTR lpAppName,
  38. LPWSTR lpReturnedString,
  39. DWORD nSize,
  40. LPCWSTR lpFileName
  41. );
  42. BOOL
  43. APIENTRY
  44. WMI_FILE_WritePrivateProfileSectionW(
  45. LPCWSTR lpAppName,
  46. LPCWSTR lpString,
  47. LPCWSTR lpFileName
  48. );
  49. class CWMI_FILE_IniFileObject
  50. {
  51. public:
  52. ULONG m_EnvironmentUpdateCount;
  53. HANDLE m_FileHandle;
  54. BOOL m_WriteAccess;
  55. BOOL m_UnicodeFile;
  56. BOOL m_LockedFile;
  57. ULONG m_EndOfFile;
  58. PVOID m_BaseAddress;
  59. SIZE_T m_CommitSize;
  60. SIZE_T m_RegionSize;
  61. ULONG m_UpdateOffset;
  62. ULONG m_UpdateEndOffset;
  63. ULONG m_DirectoryInformationLength;
  64. FILE_STANDARD_INFORMATION m_StandardInformation;
  65. CWMI_FILE_IniFileObject();
  66. ~CWMI_FILE_IniFileObject();
  67. };
  68. class CWMI_FILE_IniFile
  69. {
  70. public:
  71. typedef enum _INIFILE_OPERATION {
  72. Enum_ReadKeyValueOp,
  73. Enum_WriteKeyValueOp,
  74. Enum_ReadKeyNamesOp,
  75. Enum_ReadSectionNamesOp,
  76. Enum_ReadSectionOp,
  77. Enum_WriteSectionOp
  78. } INIFILE_OPERATION;
  79. INIFILE_OPERATION m_Operation;
  80. BOOL m_IsWriteOperation;
  81. CWMI_FILE_IniFileObject m_IniFile;
  82. LPCWSTR m_FileName;
  83. ANSI_STRING m_ApplicationName;
  84. ANSI_STRING m_VariableName;
  85. UNICODE_STRING m_ApplicationNameU;
  86. UNICODE_STRING m_VariableNameU;
  87. BOOL m_IsMultiValueStrings;
  88. LPSTR m_ValueBuffer;
  89. ULONG m_ValueLength;
  90. LPWSTR m_ValueBufferU;
  91. ULONG m_ValueLengthU;
  92. ULONG m_ResultChars;
  93. ULONG m_ResultMaxChars;
  94. LPWSTR m_ResultBufferU;
  95. PVOID m_TextCurrent;
  96. PVOID m_TextStart;
  97. PVOID m_TextEnd;
  98. ANSI_STRING m_SectionName;
  99. ANSI_STRING m_KeywordName;
  100. ANSI_STRING m_KeywordValue;
  101. PANSI_STRING m_AnsiSectionName;
  102. PANSI_STRING m_AnsiKeywordName;
  103. PANSI_STRING m_AnsiKeywordValue;
  104. UNICODE_STRING m_SectionNameU;
  105. UNICODE_STRING m_KeywordNameU;
  106. UNICODE_STRING m_KeywordValueU;
  107. PUNICODE_STRING m_UnicodeSectionName;
  108. PUNICODE_STRING m_UnicodeKeywordName;
  109. PUNICODE_STRING m_UnicodeKeywordValue;
  110. CWMI_FILE_IniFile();
  111. ~CWMI_FILE_IniFile();
  112. static NTSTATUS ReadWriteIniFile(
  113. IN BOOL WriteOperation,
  114. IN BOOL SectionOperation,
  115. IN LPCWSTR FileName,
  116. IN LPCWSTR ApplicationName,
  117. IN LPCWSTR VariableName,
  118. IN OUT LPWSTR VariableValue,
  119. IN OUT PULONG VariableValueLength
  120. );
  121. NTSTATUS CaptureIniFileParameters(
  122. INIFILE_OPERATION a_Operation,
  123. BOOL a_WriteOperation,
  124. BOOL a_MultiValueStrings,
  125. LPCWSTR a_FileName,
  126. LPCWSTR a_ApplicationName,
  127. LPCWSTR a_VariableName,
  128. LPWSTR a_VariableValue,
  129. PULONG a_ResultMaxChars
  130. );
  131. NTSTATUS OpenIniFileOnDisk();
  132. NTSTATUS ReadWriteIniFileOnDisk();
  133. NTSTATUS CloseIniFileOnDisk();
  134. NTSTATUS ReadKeywordValue();
  135. NTSTATUS ReadKeywordNames();
  136. NTSTATUS ReadSection();
  137. NTSTATUS ReadSectionNames();
  138. NTSTATUS AdvanceTextPointer(
  139. IN ULONG StopAt
  140. );
  141. NTSTATUS FindSection();
  142. NTSTATUS FindKeyword();
  143. BOOL GetApplicationName(
  144. OUT PANSI_STRING *ApplicationName OPTIONAL,
  145. OUT PUNICODE_STRING *ApplicationNameU OPTIONAL
  146. );
  147. BOOL GetVariableName(
  148. OUT PANSI_STRING *VariableName OPTIONAL,
  149. OUT PUNICODE_STRING *VariableNameU OPTIONAL
  150. );
  151. BOOL GetVariableValue(
  152. OUT PBYTE *VariableValue OPTIONAL,
  153. OUT LPWSTR *VariableValueU OPTIONAL,
  154. OUT PULONG VariableValueLength
  155. );
  156. NTSTATUS AppendStringToResultBuffer(
  157. IN PANSI_STRING String OPTIONAL,
  158. IN PUNICODE_STRING StringU OPTIONAL,
  159. IN BOOL IncludeNull
  160. );
  161. NTSTATUS AppendBufferToResultBuffer(
  162. IN PBYTE Buffer OPTIONAL,
  163. IN LPWSTR BufferU OPTIONAL,
  164. IN ULONG Chars,
  165. IN BOOL IncludeNull
  166. );
  167. NTSTATUS WriteKeywordValue(
  168. IN PUNICODE_STRING VariableName OPTIONAL
  169. );
  170. NTSTATUS ModifyMappedFile(
  171. IN PVOID AddressInFile,
  172. IN ULONG SizeToRemove,
  173. IN PVOID InsertBuffer,
  174. IN ULONG InsertAmount
  175. );
  176. NTSTATUS WriteSection();
  177. NTSTATUS AppendNullToResultBuffer()
  178. {
  179. return AppendBufferToResultBuffer(NULL,
  180. NULL,
  181. 0,
  182. TRUE
  183. );
  184. }
  185. };
  186. #endif