Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2005-2009 Google Inc. | |
|
grt (UTC plus 2)
2014/07/30 15:05:37
put the files pulled from the omaha repository int
grt (UTC plus 2)
2014/07/30 15:05:37
since this is windows-specific, i think the right
grt (UTC plus 2)
2014/07/30 15:05:37
please have this reviewed as per: http://www.chrom
grt (UTC plus 2)
2014/07/30 15:05:37
add /third_party/omaha to .gitignore and do the sv
grt (UTC plus 2)
2014/07/30 15:05:37
have you made any modifications to this file or to
jackhou1
2014/07/31 03:24:56
Done. svn part committed at r286698.
jackhou1
2014/07/31 03:24:56
I'll update this CL when the new repo is available
jackhou1
2014/07/31 03:24:56
I needed to make a slight change in order to put t
jackhou1
2014/07/31 03:24:56
Done.
jackhou1
2014/07/31 03:24:56
Filed a bug for a repo. http://crbug.com/399167
grt (UTC plus 2)
2014/07/31 20:48:05
I've never done that, so I'm not sure if the third
| |
| 2 // | |
|
grt (UTC plus 2)
2014/07/30 15:05:37
have you run "src/tools/licenses.py scan" and "src
jackhou1
2014/07/31 03:24:56
These pass.
BTW checklicenses.py doesn't seem to
| |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 | |
| 17 #ifndef OMAHA_COMMON_EXTRACTOR_H_ | |
| 18 #define OMAHA_COMMON_EXTRACTOR_H_ | |
| 19 | |
| 20 #include <windows.h> | |
| 21 | |
| 22 namespace omaha { | |
| 23 | |
| 24 class TagExtractor { | |
| 25 public: | |
| 26 TagExtractor(); | |
| 27 virtual ~TagExtractor(); | |
| 28 | |
| 29 /** | |
| 30 * @return true if we successfully opened the file. | |
| 31 */ | |
| 32 bool OpenFile(const TCHAR* filename); | |
| 33 | |
| 34 /** | |
| 35 * @return true if we currently have a handle to an open file. | |
| 36 */ | |
| 37 bool IsFileOpen() const; | |
| 38 | |
| 39 void CloseFile(); | |
| 40 | |
| 41 /** | |
| 42 * Returns the tag in the current file. | |
| 43 * | |
| 44 * We're exploiting the empirical observation that Windows checks the | |
| 45 * signature on a PEF but doesn't care if the signature container includes | |
| 46 * extra bytes after the signature. | |
| 47 * | |
| 48 * Logic: | |
| 49 * | |
| 50 * - Sanity-check that we're a PEF image. | |
| 51 * - Find the signature, which should be stored in the PE "Certificates | |
| 52 * Directory" (dumpbin.exe /headers "Firefox Setup 1.0.7.exe") in a | |
| 53 * WIN_CERTIFICATE structure. | |
| 54 * - Crudely parse the ASN.1 signature to determine its end. | |
| 55 * - Read the signature starting from the first byte past the ASN.1. | |
| 56 * | |
| 57 * @param tag_buffer: a buffer that will be filled with the extracted tag as | |
| 58 * a null-terminated string, or NULL if the caller doesn't want the tag. | |
| 59 * | |
| 60 * @param tag_buffer_len: a pointer to an int that represents the length in | |
| 61 * bytes of the buffer pointed to by tag_buffer. If tag_buffer is NULL and | |
| 62 * there is a tag to extract, then we fill this int with the size of the | |
| 63 * smallest buffer needed to contain the tag (plus the null terminator). | |
| 64 * | |
| 65 * @return true if we found a tag and either successfully copied all of it | |
| 66 * into tag_buffer, or tag_buffer was NULL and we successfully returned | |
| 67 * the required buffer size in tag_buffer_len. | |
| 68 */ | |
| 69 bool ExtractTag(char* tag_buffer, int* tag_buffer_len); | |
| 70 bool ExtractTag(const char* binary_file, | |
| 71 size_t binary_file_length, | |
| 72 char* tag_buffer, | |
| 73 int* tag_buffer_len); | |
| 74 | |
| 75 int cert_length() const { return cert_length_; } | |
| 76 const void* cert_dir_base() const { return cert_dir_base_; } | |
| 77 | |
| 78 private: | |
| 79 HANDLE file_handle_; | |
| 80 HANDLE file_mapping_; | |
| 81 LPVOID file_base_; | |
| 82 size_t file_length_; | |
| 83 int cert_length_; | |
| 84 const void* cert_dir_base_; | |
| 85 | |
| 86 bool ReadTag(const char* tag_pointer, | |
| 87 char* tag_buffer, | |
| 88 int* tag_buffer_len) const; | |
| 89 | |
| 90 const void* GetCertificateDirectoryPointer(const void* base) const; | |
| 91 | |
| 92 const void* GetASN1SignaturePointer(const void* base) const; | |
| 93 | |
| 94 int GetASN1SignatureLength(const void* base) const; | |
| 95 | |
| 96 bool InternalExtractTag(const char* file_buffer, | |
| 97 char* tag_buffer, | |
| 98 int* tag_buffer_len); | |
| 99 | |
| 100 bool InternalReadCertificate(const char* file_buffer); | |
| 101 }; | |
| 102 | |
| 103 } // namespace omaha | |
| 104 | |
| 105 #endif // OMAHA_COMMON_EXTRACTOR_H_ | |
| OLD | NEW |