OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ | 5 #ifndef CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ |
6 #define CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ | 6 #define CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ |
7 | 7 |
8 #include <CoreFoundation/CoreFoundation.h> | 8 #include <CoreFoundation/CoreFoundation.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 class UDIFParser { | 44 class UDIFParser { |
45 public: | 45 public: |
46 // Constructs an instance from a stream. | 46 // Constructs an instance from a stream. |
47 explicit UDIFParser(ReadStream* stream); | 47 explicit UDIFParser(ReadStream* stream); |
48 ~UDIFParser(); | 48 ~UDIFParser(); |
49 | 49 |
50 // Parses the UDIF file. This method must be called before any other method. | 50 // Parses the UDIF file. This method must be called before any other method. |
51 // If this returns false, it is not legal to call any other methods. | 51 // If this returns false, it is not legal to call any other methods. |
52 bool Parse(); | 52 bool Parse(); |
53 | 53 |
54 // Returns the blob of DMG signature data. | |
55 const std::vector<uint8_t>& GetDmgSignatureData(); | |
56 | |
54 // Returns the number of partitions in this UDIF image. | 57 // Returns the number of partitions in this UDIF image. |
55 size_t GetNumberOfPartitions(); | 58 size_t GetNumberOfPartitions(); |
56 | 59 |
57 // Returns the partition name for a given partition number, in the range of | 60 // Returns the partition name for a given partition number, in the range of |
58 // [0,GetNumberOfPartitions()). This will include the number, name, and type | 61 // [0,GetNumberOfPartitions()). This will include the number, name, and type |
59 // of partition. E.g., "disk image (Apple_HFS : 2)". | 62 // of partition. E.g., "disk image (Apple_HFS : 2)". |
60 std::string GetPartitionName(size_t part_number); | 63 std::string GetPartitionName(size_t part_number); |
61 | 64 |
62 // Returns the partition type as a string for the given partition number. | 65 // Returns the partition type as a string for the given partition number. |
63 // E.g., "Apple_HFS" and "Apple_Free". | 66 // E.g., "Apple_HFS" and "Apple_Free". |
64 std::string GetPartitionType(size_t part_number); | 67 std::string GetPartitionType(size_t part_number); |
65 | 68 |
66 // Returns the size of the partition in bytes. | 69 // Returns the size of the partition in bytes. |
67 size_t GetPartitionSize(size_t part_number); | 70 size_t GetPartitionSize(size_t part_number); |
68 | 71 |
69 // Returns a stream of the raw partition data for the given partition | 72 // Returns a stream of the raw partition data for the given partition |
70 // number. | 73 // number. |
71 std::unique_ptr<ReadStream> GetPartitionReadStream(size_t part_number); | 74 std::unique_ptr<ReadStream> GetPartitionReadStream(size_t part_number); |
72 | 75 |
73 private: | 76 private: |
74 // Parses the blkx plist trailer structure. | 77 // Parses the blkx plist trailer structure. |
75 bool ParseBlkx(); | 78 bool ParseBlkx(); |
76 | 79 |
77 ReadStream* const stream_; // The stream backing the UDIF image. Weak. | 80 ReadStream* const stream_; // The stream backing the UDIF image. Weak. |
78 std::vector<std::string> partition_names_; // The names of all partitions. | 81 std::vector<std::string> partition_names_; // The names of all partitions. |
79 // All blocks in the UDIF image. | 82 // All blocks in the UDIF image. |
80 std::vector<std::unique_ptr<const UDIFBlock>> blocks_; | 83 std::vector<std::unique_ptr<const UDIFBlock>> blocks_; |
81 uint16_t block_size_; // The image's block size, in bytes. | 84 uint16_t block_size_; // The image's block size, in bytes. |
85 std::vector<uint8_t> | |
Jialiu Lin
2017/06/28 00:23:35
Nit: Shorten the comment to make it fit into one l
mortonm
2017/06/28 16:24:41
Done.
| |
86 signature_blob_; // Data that comprises the DMG signature | |
82 | 87 |
83 DISALLOW_COPY_AND_ASSIGN(UDIFParser); | 88 DISALLOW_COPY_AND_ASSIGN(UDIFParser); |
84 }; | 89 }; |
85 | 90 |
86 } // namespace dmg | 91 } // namespace dmg |
87 } // namespace safe_browsing | 92 } // namespace safe_browsing |
88 | 93 |
89 #endif // CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ | 94 #endif // CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ |
OLD | NEW |