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.

137 lines
3.6 KiB

  1. typedef std::vector<String_t> StringVector_t;
  2. VOID ThrowLastWin32Error();
  3. VOID Throw(PCWSTR);
  4. class BuildFlavor_t;
  5. class Error_t;
  6. class FindFirstFileError_t;
  7. class DelayloadTool_t;
  8. class File_t;
  9. class Image_t;
  10. class Error_t
  11. {
  12. public:
  13. };
  14. class FindFirstFileError_t : public Error_t
  15. {
  16. public:
  17. HRESULT m_hresult;
  18. DWORD m_dwLastError;
  19. String_t m_strParameter;
  20. };
  21. VOID
  22. CollectDirectoryPathsNonRecursively(
  23. const String_t& directory,
  24. StringVector_t& paths
  25. );
  26. typedef BOOL (CALLBACK * PFN_COLLECTION_FILE_PATHS_RECURSIVELY_FILTER)(PVOID FilterContext, PCWSTR Directory, WIN32_FIND_DATAW * wfd);
  27. VOID
  28. CollectFilePathsRecursivelyHelper(
  29. const String_t& directory,
  30. StringVector_t& paths,
  31. PFN_COLLECTION_FILE_PATHS_RECURSIVELY_FILTER Filter,
  32. PVOID FilterContext,
  33. WIN32_FIND_DATAW& wfd
  34. );
  35. VOID
  36. CollectFilePathsRecursively(
  37. const String_t& directory,
  38. StringVector_t& paths,
  39. PFN_COLLECTION_FILE_PATHS_RECURSIVELY_FILTER Filter = NULL,
  40. PVOID FilterContext = NULL
  41. );
  42. class DelayloadTool_t
  43. {
  44. private:
  45. typedef DelayloadTool_t This_t;
  46. DelayloadTool_t(const DelayloadTool_t&);
  47. VOID operator=(const DelayloadTool_t&);
  48. public:
  49. ~DelayloadTool_t()
  50. {
  51. m_XmlWriter.Release();
  52. m_XmlAttributes.Release();
  53. }
  54. DelayloadTool_t() { }
  55. typedef String_t FilePath_t;
  56. typedef std::vector<FilePath_t> FilePaths_t;
  57. VOID ProcessBuild(const BuildFlavor_t& b);
  58. VOID ProcessFile(const FilePath_t& root, const FilePath_t& f);
  59. VOID Main(const StringVector_t& args);
  60. F::CXmlWriter m_XmlWriter;
  61. F::CXmlAttributes m_XmlAttributes;
  62. std::vector<BYTE> m_HeadersBuffer;
  63. ULONG m_OffsetToPe;
  64. PIMAGE_SECTION_HEADER m_HintSection;
  65. CFileStream m_OutFileStream;
  66. PIMAGE_OPTIONAL_HEADER32 m_OptionalHeader32;
  67. PIMAGE_OPTIONAL_HEADER64 m_OptionalHeader64;
  68. PIMAGE_NT_HEADERS GetNtHeaders() { return reinterpret_cast<PIMAGE_NT_HEADERS>(&m_HeadersBuffer[m_OffsetToPe]); }
  69. PVOID GetMappedBase() { return &m_HeadersBuffer[0]; }
  70. SIZE_T GetSizeOfPointer() { return (m_OptionalHeader32 ? 4 : m_OptionalHeader64 ? 8 : ~0); }
  71. String_t ReadOneDelayload(HANDLE FileHandle);
  72. };
  73. #define GET_OPTIONAL_HEADER_FIELD(o32, o64, f) ((o32) ? (o32)->f : (o64)->f)
  74. VOID DelayloadToolAssertFailed(const char* Expression, const char* File, unsigned long Line);
  75. VOID DelayloadToolInternalErrorCheckFailed(const char* Expression, const char* File, unsigned long Line);
  76. String_t NumberToString(ULONG Number, PCWSTR Format = L"0x%lx");
  77. String_t GetLastErrorString();
  78. String_t RemoveOptionChar(const String_t& s);
  79. VOID __cdecl Error(const wchar_t* s, ...);
  80. String_t GetEnv(PCWSTR s);
  81. String_t FindLatestReleaseOnServer(const String_t& Server);
  82. BOOL DelayloadTool_Filter(PVOID FilterContext, PCWSTR Directory, WIN32_FIND_DATAW * wfd);
  83. class BuildFlavor_t
  84. {
  85. public:
  86. WCHAR Name[12];
  87. WCHAR Processor[8];
  88. WCHAR ChkOrFre[8];
  89. WCHAR ReleaseServer[12]; // or "local"
  90. String_t * ActualRoot;
  91. };
  92. class File_t
  93. {
  94. public:
  95. String_t m_FullPath;
  96. String_t m_RelativePath;
  97. String_t m_LeafPath;
  98. String_t m_Error;
  99. };
  100. class Delayload_t
  101. {
  102. public:
  103. String_t m_LeafPath;
  104. };
  105. class Image_t : public File_t
  106. {
  107. public:
  108. std::vector<Delayload_t> m_Delayloads;
  109. };
  110. VOID SeekTo(HANDLE FileHandle, ULONG64 Offset);
  111. VOID SeekForward(HANDLE FileHandle, ULONG64 Offset);
  112. VOID SeekBackward(HANDLE FileHandle, LONG64 Offset);
  113. VOID Read(HANDLE FileHandle, VOID * Buffer, ULONG BytesToRead);