Source code of Windows XP (NT5)
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.

110 lines
3.4 KiB

  1. #ifndef ANSPARSE_H
  2. #define ANSPARSE_H
  3. class PATCH_LANGUAGE;
  4. class AnswerParser;
  5. ///////////////////////////////////////////////////////////////////////////////
  6. //
  7. // PATCH_LANGUAGE, the language structure, one for each language
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. typedef PATCH_LANGUAGE* PPATCH_LANGUAGE;
  11. class PATCH_LANGUAGE
  12. {
  13. public:
  14. HANDLE s_hScriptFile;
  15. WCHAR s_wszScriptFile[STRING_LENGTH];
  16. WCHAR s_wszLanguage[LANGUAGE_LENGTH];
  17. WCHAR s_wszDirectory[STRING_LENGTH];
  18. WCHAR s_wszPatchDirectory[STRING_LENGTH];
  19. WCHAR s_wszSubPatchDirectory[STRING_LENGTH];
  20. WCHAR s_wszSubExceptDirectory[STRING_LENGTH];
  21. ULONG s_iDirectoryCount;
  22. ULONG s_iPatchDirectoryCount;
  23. ULONG s_iSubPatchDirectoryCount;
  24. ULONG s_iSubExceptDirectoryCount;
  25. ULONG s_iComplete;
  26. BOOL s_blnBase;
  27. PPATCH_LANGUAGE s_pNext;
  28. PATCH_LANGUAGE();
  29. ~PATCH_LANGUAGE();
  30. };
  31. ///////////////////////////////////////////////////////////////////////////////
  32. //
  33. // AnswerParse, parses the answerfile and fill in the language structures
  34. //
  35. ///////////////////////////////////////////////////////////////////////////////
  36. class AnswerParser
  37. {
  38. private:
  39. HANDLE m_hAnsFile;
  40. PPATCH_LANGUAGE m_pHead;
  41. WCHAR m_structHash[EXCEP_FILE_LIMIT][SHORT_STRING_LENGTH];
  42. BYTE m_structHashUsed[EXCEP_FILE_LIMIT];
  43. VOID CreateNewLanguage(IN PPATCH_LANGUAGE pNode, IN WCHAR* strBegin, IN WCHAR* strEnd);
  44. VOID GetHashValues(IN CONST WCHAR* pwszFileName, OUT ULONG& iHash1, OUT ULONG& iHash2);
  45. BOOL SaveFileExceptHash(IN WCHAR* pwszFileName);
  46. BOOL IsUnicodeFile(IN HANDLE hFile);
  47. BOOL ReadLine(IN HANDLE hFile, IN WCHAR* strLine);
  48. public:
  49. AnswerParser();
  50. ~AnswerParser();
  51. WCHAR m_wszBaseDirectory[STRING_LENGTH];
  52. ULONG m_iBaseDirectoryCount;
  53. PPATCH_LANGUAGE GetBaseLanguage(VOID);
  54. PPATCH_LANGUAGE GetNextLanguage(VOID);
  55. BOOL IsFileExceptHash(IN CONST WCHAR* pwszFileName);
  56. BOOL Parse(IN CONST WCHAR* pwszAnswerFile);
  57. };
  58. ///////////////////////////////////////////////////////////////////////////////
  59. //
  60. // SAMPLEFILE, a sample answerfile, shows the user what to do for languages
  61. //
  62. ///////////////////////////////////////////////////////////////////////////////
  63. static WCHAR* SAMPLEFILE[] =
  64. {
  65. L";Sample answer file for OEMPatch.\015\012",
  66. L";The answer file must be named OEMPatch.ans.\015\012",
  67. L";The answer file has two main fields, [(language)] and [except].\015\012",
  68. L";Each line ends with (;) except the headers. (;) is also used for comments.\015\012",
  69. L"\015\012",
  70. L"[usa]\015\012",
  71. L";directory is where the image is located\015\012",
  72. L"directory=;\015\012",
  73. L";the base files for patch is based on the usa image, only one language can be the base\015\012",
  74. L";however, you can use another language as the base\015\012",
  75. L";where the base files will be\015\012",
  76. L"base_directory=;\015\012",
  77. L";where the patch files will be\015\012",
  78. L"patch_directory=;\015\012",
  79. L"\015\012",
  80. L"[ger]\015\012",
  81. L"directory=;\015\012",
  82. L"patch_directory=;\015\012",
  83. L"\015\012",
  84. L"[chs]\015\012",
  85. L"directory=;\015\012",
  86. L"patch_directory=;\015\012",
  87. L"\015\012",
  88. L"[cht]\015\012",
  89. L"directory=;\015\012",
  90. L"patch_directory=;\015\012",
  91. L"\015\012",
  92. L"[kor]\015\012",
  93. L"directory=;\015\012",
  94. L"patch_directory=;\015\012",
  95. L"\015\012",
  96. L";the except file section lists all the files that are not to be patched\015\012",
  97. L"[except]\015\012",
  98. L"ntdll.dll\015\012",
  99. L"\000"
  100. };
  101. #endif // ANSPARSE_H