Another take on menu's. This uses the hosting menu scroll view container as a menuba...
[chromium-blink-merge.git] / base / image_util.h
blobccdffc361fa46a1654555bcf34f6a5130cb29254
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file/namespace contains utility functions for gathering
6 // information about PE (Portable Executable) headers within
7 // images (dll's / exe's )
9 #ifndef BASE_IMAGE_UTIL_H_
10 #define BASE_IMAGE_UTIL_H_
11 #pragma once
13 #include <windows.h>
14 #include <vector>
16 #include "base/basictypes.h"
18 namespace image_util {
20 // Contains both the PE section name (.text, .reloc etc) and its size.
21 struct ImageSectionData {
22 ImageSectionData(const std::string& section_name, size_t section_size)
23 : name(section_name),
24 size_in_bytes(section_size) {
27 std::string name;
28 size_t size_in_bytes;
31 typedef std::vector<ImageSectionData> ImageSectionsData;
33 // Provides image statistics for modules of a specified process, or for the
34 // specified process' own executable file. To use, invoke CreateImageMetrics()
35 // to get an instance for a specified process, then access the information via
36 // methods.
37 class ImageMetrics {
38 public:
39 // Creates an ImageMetrics instance for given process owned by
40 // the caller.
41 explicit ImageMetrics(HANDLE process);
42 ~ImageMetrics();
44 // Fills a vector of ImageSectionsData containing name/size info
45 // for every section found in the specified dll's PE section table.
46 // The DLL must be loaded by the process associated with this ImageMetrics
47 // instance.
48 bool GetDllImageSectionData(const std::string& loaded_dll_name,
49 ImageSectionsData* section_sizes);
51 // Fills a vector if ImageSectionsData containing name/size info
52 // for every section found in the executable file of the process
53 // associated with this ImageMetrics instance.
54 bool GetProcessImageSectionData(ImageSectionsData* section_sizes);
56 private:
57 // Helper for GetDllImageSectionData and GetProcessImageSectionData
58 bool GetImageSectionSizes(char* qualified_path, ImageSectionsData* result);
60 HANDLE process_;
62 DISALLOW_COPY_AND_ASSIGN(ImageMetrics);
65 } // namespace image_util
67 #endif // BASE_IMAGE_UTIL_H_