├── src
├── ui
│ ├── bug.icns
│ ├── icon.rc
│ ├── icon_72529.ico
│ ├── icon_72529.png
│ ├── icons.qrc
│ ├── inttablewidget.hpp
│ ├── inttablewidget.cpp
│ └── mainwindow.h
├── version.hpp
├── structures
│ ├── noteformat.hpp
│ ├── capabilities.hpp
│ ├── relocation.hpp
│ ├── symtable_entry.hpp
│ ├── programheader.hpp
│ ├── dynamicstruct.hpp
│ ├── sectionheader.hpp
│ └── elfheader.hpp
├── datastructures
│ ├── search_value.hpp
│ ├── search_node.hpp
│ ├── search_node.cpp
│ └── search_tree.hpp
├── segment_types
│ ├── segment_type.cpp
│ ├── interp_segment.cpp
│ ├── debuglink_segment.cpp
│ ├── comment_segment.cpp
│ ├── interp_segment.hpp
│ ├── comment_segment.hpp
│ ├── debuglink_segment.hpp
│ ├── readonly_segment.hpp
│ ├── note_segment.hpp
│ ├── strtable_segment.hpp
│ ├── readonly_segment.cpp
│ ├── strtable_segment.cpp
│ └── segment_type.hpp
├── initarray.hpp
├── abstract_dynamic.hpp
├── abstract_symbol.hpp
├── endian.h
├── segment.cpp
├── segment.hpp
├── symbols.hpp
├── initarray.cpp
├── programheaders.hpp
├── abstract_programheader.hpp
├── dynamicsection.hpp
├── abstract_sectionheader.hpp
├── programheaders.cpp
├── sectionheaders.hpp
└── tests
│ └── tiny_tests.cpp
├── test_files
├── bf
├── true
├── 32_arm_ls
├── 32_intel_ls
├── 64_intel_ls
├── 32_mips_be_ping
└── 64_intel_ls_upx
├── lib
├── gtest-1.6.0
│ ├── xcode
│ │ ├── Config
│ │ │ ├── TestTarget.xcconfig
│ │ │ ├── FrameworkTarget.xcconfig
│ │ │ ├── StaticLibraryTarget.xcconfig
│ │ │ ├── DebugProject.xcconfig
│ │ │ ├── ReleaseProject.xcconfig
│ │ │ └── General.xcconfig
│ │ ├── Samples
│ │ │ └── FrameworkSample
│ │ │ │ ├── Info.plist
│ │ │ │ ├── widget.h
│ │ │ │ ├── widget.cc
│ │ │ │ ├── runtests.sh
│ │ │ │ └── widget_test.cc
│ │ ├── Resources
│ │ │ └── Info.plist
│ │ └── Scripts
│ │ │ └── runtests.sh
│ ├── m4
│ │ ├── ltversion.m4
│ │ └── gtest.m4
│ ├── CONTRIBUTORS
│ ├── COPYING
│ ├── test
│ │ ├── production.cc
│ │ ├── gtest_main_unittest.cc
│ │ ├── gtest_uninitialized_test_.cc
│ │ ├── gtest_xml_outfile1_test_.cc
│ │ ├── gtest_xml_outfile2_test_.cc
│ │ ├── gtest-typed-test2_test.cc
│ │ ├── gtest_help_test_.cc
│ │ ├── production.h
│ │ ├── gtest_all_test.cc
│ │ ├── gtest_prod_test.cc
│ │ ├── gtest_sole_header_test.cc
│ │ ├── gtest-param-test_test.h
│ │ ├── gtest_no_test_unittest.cc
│ │ ├── gtest-typed-test_test.h
│ │ ├── gtest_throw_on_failure_test_.cc
│ │ ├── gtest_uninitialized_test.py
│ │ ├── gtest_list_tests_unittest_.cc
│ │ ├── gtest-param-test2_test.cc
│ │ ├── gtest_color_test_.cc
│ │ ├── gtest_break_on_failure_unittest_.cc
│ │ ├── gtest_throw_on_failure_ex_test.cc
│ │ └── gtest_shuffle_test_.cc
│ ├── src
│ │ ├── gtest_main.cc
│ │ └── gtest-all.cc
│ ├── fused-src
│ │ └── gtest
│ │ │ └── gtest_main.cc
│ ├── codegear
│ │ ├── gtest_all.cc
│ │ ├── gtest_link.cc
│ │ └── gtest.groupproj
│ ├── scripts
│ │ └── test
│ │ │ └── Makefile
│ ├── samples
│ │ ├── sample4_unittest.cc
│ │ ├── sample1.h
│ │ ├── sample4.cc
│ │ ├── sample4.h
│ │ ├── sample2.cc
│ │ ├── sample1.cc
│ │ └── sample2.h
│ ├── build-aux
│ │ └── config.h.in
│ ├── msvc
│ │ ├── gtest.sln
│ │ ├── gtest-md.sln
│ │ └── gtest.vcproj
│ ├── include
│ │ └── gtest
│ │ │ └── gtest_prod.h
│ ├── configure.ac
│ └── make
│ │ └── Makefile
└── hash-lib
│ ├── md5.h
│ ├── sha1.h
│ └── sha256.h
└── LICENSE
/src/ui/bug.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/src/ui/bug.icns
--------------------------------------------------------------------------------
/src/ui/icon.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/src/ui/icon.rc
--------------------------------------------------------------------------------
/test_files/bf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/test_files/bf
--------------------------------------------------------------------------------
/test_files/true:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/test_files/true
--------------------------------------------------------------------------------
/test_files/32_arm_ls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/test_files/32_arm_ls
--------------------------------------------------------------------------------
/src/ui/icon_72529.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/src/ui/icon_72529.ico
--------------------------------------------------------------------------------
/src/ui/icon_72529.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/src/ui/icon_72529.png
--------------------------------------------------------------------------------
/test_files/32_intel_ls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/test_files/32_intel_ls
--------------------------------------------------------------------------------
/test_files/64_intel_ls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/test_files/64_intel_ls
--------------------------------------------------------------------------------
/test_files/32_mips_be_ping:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/test_files/32_mips_be_ping
--------------------------------------------------------------------------------
/test_files/64_intel_ls_upx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jacob-baines/elfparser/HEAD/test_files/64_intel_ls_upx
--------------------------------------------------------------------------------
/src/ui/icons.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | icon_72529.ico
4 |
5 |
--------------------------------------------------------------------------------
/src/version.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SC_VERSION_HPP
2 | #define SC_VERSION_HPP
3 |
4 | #include
5 |
6 | namespace elfparser
7 | {
8 | std::string s_version("Version: ELF Parser 1.4.0\nDate: November 2, 2014\nAuthor: Jacob Baines");
9 | }
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Config/TestTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // TestTarget.xcconfig
3 | //
4 | // These are Test target settings for the gtest framework and examples. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 |
7 | PRODUCT_NAME = $(TARGET_NAME)
8 | HEADER_SEARCH_PATHS = ../include
9 |
--------------------------------------------------------------------------------
/src/structures/noteformat.hpp:
--------------------------------------------------------------------------------
1 | #ifndef NOTE_FORMAT_HPP
2 | #define NOTE_FORMAT_HPP
3 |
4 | namespace elf
5 | {
6 | #pragma pack(push, 1)
7 | struct note
8 | {
9 | boost::uint32_t m_nameSize;
10 | boost::uint32_t m_descSize;
11 | boost::uint32_t m_type;
12 | };
13 | #pragma pack(pop)
14 | }
15 |
16 | #endif
--------------------------------------------------------------------------------
/src/ui/inttablewidget.hpp:
--------------------------------------------------------------------------------
1 | #ifdef QT_GUI
2 | #ifndef INTENTRY_HPP
3 | #define INTENTRY_HPP
4 |
5 | #include
6 | #include
7 |
8 | class IntWidgetItem : public QTableWidgetItem
9 | {
10 | public:
11 | IntWidgetItem(boost::uint64_t p_value, bool p_hex = false);
12 | ~IntWidgetItem();
13 |
14 | bool operator <(const QTableWidgetItem &other) const;
15 |
16 | private:
17 | //! the underlying value in int format
18 | boost::uint64_t m_value;
19 | };
20 |
21 | #endif
22 | #endif
23 |
--------------------------------------------------------------------------------
/src/datastructures/search_value.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SEARCH_VALUE_HPP
2 | #define SEARCH_VALUE_HPP
3 |
4 | #include
5 |
6 | #include "../structures/capabilities.hpp"
7 |
8 | class SearchValue
9 | {
10 | public:
11 |
12 | SearchValue(const std::string& p_search, elf::Capabilties p_capabilities,
13 | const std::string& p_info) :
14 | m_search(p_search),
15 | m_type(p_capabilities),
16 | m_info(p_info)
17 | {
18 | }
19 |
20 | ~SearchValue()
21 | {
22 | }
23 |
24 | public:
25 | std::string m_search;
26 | elf::Capabilties m_type;
27 | std::string m_info;
28 | };
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Config/FrameworkTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // FrameworkTarget.xcconfig
3 | //
4 | // These are Framework target settings for the gtest framework and examples. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Dynamic libs need to be position independent
11 | GCC_DYNAMIC_NO_PIC = NO
12 |
13 | // Dynamic libs should not have their external symbols stripped.
14 | STRIP_STYLE = non-global
15 |
16 | // Let the user install by specifying the $DSTROOT with xcodebuild
17 | SKIP_INSTALL = NO
18 |
--------------------------------------------------------------------------------
/src/segment_types/segment_type.cpp:
--------------------------------------------------------------------------------
1 | #include "segment_type.hpp"
2 |
3 | SegmentType::SegmentType (const char*, boost::uint32_t p_offset,
4 | boost::uint32_t p_size, elf::section_type p_type) :
5 | m_type(p_type),
6 | m_offset(p_offset),
7 | m_size(p_size),
8 | m_strings(NULL)
9 | {
10 | }
11 |
12 | SegmentType::~SegmentType()
13 | {
14 | }
15 |
16 | elf::section_type SegmentType::getType() const
17 | {
18 | return m_type;
19 | }
20 |
21 | boost::uint32_t SegmentType::getOffset() const
22 | {
23 | return m_offset;
24 | }
25 |
26 | void SegmentType::setStrSegment(SegmentType* p_strSegment)
27 | {
28 | m_strings = p_strSegment;
29 | }
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | ELF Parser
2 | Copyright (C) 2015 Jacob Baines
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Config/StaticLibraryTarget.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // StaticLibraryTarget.xcconfig
3 | //
4 | // These are static library target settings for libgtest.a. It
5 | // is set in the "Based On:" dropdown in the "Target" info dialog.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Static libs can be included in bundles so make them position independent
11 | GCC_DYNAMIC_NO_PIC = NO
12 |
13 | // Static libs should not have their internal globals or external symbols
14 | // stripped.
15 | STRIP_STYLE = debugging
16 |
17 | // Let the user install by specifying the $DSTROOT with xcodebuild
18 | SKIP_INSTALL = NO
19 |
--------------------------------------------------------------------------------
/src/structures/capabilities.hpp:
--------------------------------------------------------------------------------
1 | #ifndef CAPABILITIES_HPP
2 | #define CAPABILITIES_HPP
3 |
4 | namespace elf
5 | {
6 | enum Capabilties
7 | {
8 | k_fileFunctions = 0,
9 | k_networkFunctions,
10 | k_processManipulation,
11 | k_pipeFunctions,
12 | k_crypto,
13 | k_infoGathering,
14 | k_envVariables,
15 | k_permissions,
16 | k_syslog,
17 | k_packetSniff,
18 | k_shell,
19 | k_packed,
20 | k_irc,
21 | k_http,
22 | k_compression,
23 | k_ipAddress,
24 | k_url,
25 | k_hooking,
26 | k_antidebug,
27 | k_dropper,
28 | k_filePath
29 | };
30 | }
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/segment_types/interp_segment.cpp:
--------------------------------------------------------------------------------
1 | #include "interp_segment.hpp"
2 |
3 | #include
4 |
5 | InterpSegment::InterpSegment(const char* start, boost::uint32_t p_offset,
6 | boost::uint32_t p_size,
7 | elf::section_type p_type) :
8 | SegmentType(start, p_offset, p_size, p_type),
9 | m_interpreter(start + p_offset)
10 | {
11 | }
12 |
13 | InterpSegment::~InterpSegment()
14 | {
15 | }
16 |
17 | std::string InterpSegment::printToStdOut() const
18 | {
19 | std::stringstream return_value;
20 | return_value << "Interpreter (offset=0x" << std::hex << m_offset
21 | << ", size=" << std::dec << m_size << ")\n"
22 | << "\tValue=\"" << m_interpreter << "\"\n";
23 | return return_value.str();
24 | }
25 |
--------------------------------------------------------------------------------
/src/initarray.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INIT_ARRAY_HPP
2 | #define INIT_ARRAY_HPP
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | class InitArray
9 | {
10 | public:
11 | explicit InitArray(const std::string& p_name);
12 | ~InitArray();
13 |
14 | void set(const char* p_data, boost::uint32_t p_size, boost::uint32_t p_offset,
15 | boost::uint32_t p_entries, bool p_is64, bool p_isLE);
16 |
17 | boost::uint32_t getOffset() const;
18 |
19 | std::vector >& getEntries();
20 |
21 | std::string printToStd() const;
22 |
23 | private:
24 |
25 | std::string m_name;
26 | boost::uint32_t m_offset;
27 | std::vector > m_entries;
28 | };
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/src/segment_types/debuglink_segment.cpp:
--------------------------------------------------------------------------------
1 | #include "debuglink_segment.hpp"
2 |
3 | #include
4 |
5 | DebugLinkSegment::DebugLinkSegment(const char* start, boost::uint32_t p_offset,
6 | boost::uint32_t p_size,
7 | elf::section_type p_type) :
8 | SegmentType(start, p_offset, p_size, p_type),
9 | m_file(start + p_offset)
10 | {
11 | }
12 |
13 | DebugLinkSegment::~DebugLinkSegment()
14 | {
15 | }
16 |
17 | std::string DebugLinkSegment::printToStdOut() const
18 | {
19 | std::stringstream return_value;
20 | return_value << "Debug Link Segment (offset=0x" << std::hex << m_offset
21 | << ", size=" << std::dec << m_size << ")\n"
22 | << "\tFile=\"" << m_file << "\"\n";
23 | return return_value.str();
24 | }
25 |
--------------------------------------------------------------------------------
/src/segment_types/comment_segment.cpp:
--------------------------------------------------------------------------------
1 | #include "comment_segment.hpp"
2 |
3 | #include
4 |
5 | CommentSegment::CommentSegment(const char* start, boost::uint32_t p_offset,
6 | boost::uint32_t p_size,
7 | elf::section_type p_type) :
8 | SegmentType(start, p_offset, p_size, p_type),
9 | m_comment(start + p_offset)
10 | {
11 | }
12 |
13 | CommentSegment::~CommentSegment()
14 | {
15 | }
16 |
17 | std::string CommentSegment::printToStdOut() const
18 | {
19 | std::stringstream return_value;
20 | return_value << "Comment Segment (offset=0x" << std::hex << m_offset
21 | << ", size=" << std::dec << m_size << ")\n"
22 | << "\tString=\"" << m_comment << "\"\n";
23 | return return_value.str();
24 | }
25 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/m4/ltversion.m4:
--------------------------------------------------------------------------------
1 | # ltversion.m4 -- version numbers -*- Autoconf -*-
2 | #
3 | # Copyright (C) 2004 Free Software Foundation, Inc.
4 | # Written by Scott James Remnant, 2004
5 | #
6 | # This file is free software; the Free Software Foundation gives
7 | # unlimited permission to copy and/or distribute it, with or without
8 | # modifications, as long as this notice is preserved.
9 |
10 | # Generated from ltversion.in.
11 |
12 | # serial 3017 ltversion.m4
13 | # This file is part of GNU Libtool
14 |
15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b])
16 | m4_define([LT_PACKAGE_REVISION], [1.3017])
17 |
18 | AC_DEFUN([LTVERSION_VERSION],
19 | [macro_version='2.2.6b'
20 | macro_revision='1.3017'
21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
22 | _LT_DECL(, macro_revision, 0)
23 | ])
24 |
--------------------------------------------------------------------------------
/src/ui/inttablewidget.cpp:
--------------------------------------------------------------------------------
1 | #ifdef QT_GUI
2 | #include "inttablewidget.hpp"
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | IntWidgetItem::IntWidgetItem(boost::uint64_t p_value, bool p_hex) :
9 | QTableWidgetItem(),
10 | m_value(p_value)
11 | {
12 | if (!p_hex)
13 | {
14 | QString intValue(boost::lexical_cast(m_value).c_str());
15 | setText(intValue);
16 | }
17 | else
18 | {
19 | std::stringstream value;
20 | value << "0x" << std::hex << p_value;
21 | QString intValue(value.str().c_str());
22 | setText(intValue);
23 | }
24 | }
25 |
26 | IntWidgetItem::~IntWidgetItem()
27 | {
28 | }
29 |
30 | bool IntWidgetItem::operator <(const QTableWidgetItem& other) const
31 | {
32 | const IntWidgetItem& otherCasted = dynamic_cast(other);
33 | return m_value < otherCasted.m_value;
34 | }
35 | #endif
36 |
--------------------------------------------------------------------------------
/src/abstract_dynamic.hpp:
--------------------------------------------------------------------------------
1 | #ifndef ABSTRACT_DYNAMIC_HPP
2 | #define ABSTRACT_DYNAMIC_HPP
3 |
4 | #include
5 | #include
6 |
7 | class AbstractDynamicEntry
8 | {
9 | public:
10 | AbstractDynamicEntry(boost::uint64_t p_tag, boost::uint64_t p_value);
11 | AbstractDynamicEntry(const AbstractDynamicEntry& p_rhs);
12 | ~AbstractDynamicEntry();
13 |
14 | boost::uint64_t getTag() const;
15 | boost::uint64_t getValue() const;
16 |
17 | bool hasString() const;
18 | void setString(const std::string& p_value);
19 | const std::string& getString() const;
20 | void createString(const char* p_strOffset);
21 |
22 | std::string printToStdOut() const;
23 |
24 | private:
25 |
26 | //! Disable evil things
27 | AbstractDynamicEntry& operator=(const AbstractDynamicEntry& p_rhs);
28 |
29 | private:
30 | boost::uint64_t m_tag;
31 | boost::uint64_t m_value;
32 | std::string m_stringValue;
33 | };
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Samples/FrameworkSample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.google.gtest.${PRODUCT_NAME:identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | CSResourcesFileMapped
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/datastructures/search_node.hpp:
--------------------------------------------------------------------------------
1 | #ifndef ELFPARSER_SEARCHNODE_HPP
2 | #define ELFPARSER_SEARCHNODE_HPP
3 |
4 | #include
5 |
6 | class SearchNode
7 | {
8 | public:
9 |
10 | SearchNode();
11 | ~SearchNode();
12 |
13 | SearchNode* getNext(const unsigned char p_value) const;
14 |
15 | std::size_t getNextSize() const { return sizeof(m_next) / sizeof(void*); }
16 |
17 | void setNext(const unsigned char p_value, SearchNode* p_node);
18 |
19 | const std::set& getStoredData() const;
20 | void addReturnValues(const std::set& p_dataSet);
21 | void addReturnValue(void* p_data);
22 |
23 | SearchNode* getFailure() const;
24 | void setFailure(SearchNode* const p_node);
25 |
26 | private:
27 |
28 | SearchNode(const SearchNode& p_rhs);
29 | SearchNode& operator=(const SearchNode& p_rhs);
30 |
31 | private:
32 |
33 | std::set m_storedData;
34 | SearchNode* m_next[256];
35 | SearchNode* m_failureNode;
36 | };
37 |
38 | #endif
39 |
40 |
--------------------------------------------------------------------------------
/src/datastructures/search_node.cpp:
--------------------------------------------------------------------------------
1 | #include "search_node.hpp"
2 |
3 | #include
4 |
5 | SearchNode::SearchNode() :
6 | m_storedData(),
7 | m_next(),
8 | m_failureNode(NULL)
9 | {
10 | }
11 |
12 | SearchNode::~SearchNode()
13 | {
14 | }
15 |
16 | SearchNode* SearchNode::getNext(const unsigned char p_value) const
17 | {
18 | return m_next[p_value];
19 | }
20 |
21 | void SearchNode::setNext(const unsigned char p_value, SearchNode* p_node)
22 | {
23 | m_next[p_value] = p_node;
24 | }
25 |
26 | const std::set& SearchNode::getStoredData() const
27 | {
28 | return m_storedData;
29 | }
30 |
31 | void SearchNode::addReturnValues(const std::set& p_dataSet)
32 | {
33 | m_storedData.insert(p_dataSet.begin(), p_dataSet.end());
34 | }
35 |
36 | void SearchNode::addReturnValue(void* p_data)
37 | {
38 | m_storedData.insert(p_data);
39 | }
40 |
41 | SearchNode* SearchNode::getFailure() const
42 | {
43 | return m_failureNode;
44 | }
45 |
46 | void SearchNode::setFailure(SearchNode* const p_node)
47 | {
48 | m_failureNode = p_node;
49 | }
50 |
--------------------------------------------------------------------------------
/src/structures/relocation.hpp:
--------------------------------------------------------------------------------
1 | #ifndef RELOCATION_HPP
2 | #define RELOCATION_HPP
3 |
4 | #include
5 | #include
6 |
7 | namespace elf
8 | {
9 | struct relocation_32
10 | {
11 | boost::uint32_t m_offset;
12 | boost::uint32_t m_info;
13 | };
14 |
15 | BOOST_STATIC_ASSERT(sizeof(relocation_32) == 8);
16 |
17 | struct relocation_64
18 | {
19 | boost::uint64_t m_offset;
20 | boost::uint64_t m_info;
21 | };
22 |
23 | BOOST_STATIC_ASSERT(sizeof(relocation_64) == 16);
24 |
25 | #pragma pack(push, 1)
26 | struct rela_32
27 | {
28 | boost::uint32_t m_offset;
29 | boost::uint32_t m_info;
30 | boost::uint32_t m_addend;
31 | };
32 |
33 | BOOST_STATIC_ASSERT(sizeof(rela_32) == 12);
34 |
35 | struct rela_64
36 | {
37 | boost::uint64_t m_offset;
38 | boost::uint64_t m_info;
39 | boost::uint64_t m_addend;
40 | };
41 | #pragma pack(pop)
42 | BOOST_STATIC_ASSERT(sizeof(rela_64) == 24);
43 | }
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Config/DebugProject.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // DebugProject.xcconfig
3 | //
4 | // These are Debug Configuration project settings for the gtest framework and
5 | // examples. It is set in the "Based On:" dropdown in the "Project" info
6 | // dialog.
7 | // This file is based on the Xcode Configuration files in:
8 | // http://code.google.com/p/google-toolbox-for-mac/
9 | //
10 |
11 | #include "General.xcconfig"
12 |
13 | // No optimization
14 | GCC_OPTIMIZATION_LEVEL = 0
15 |
16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off
17 | DEPLOYMENT_POSTPROCESSING = NO
18 |
19 | // Dead code stripping off
20 | DEAD_CODE_STRIPPING = NO
21 |
22 | // Debug symbols should be on obviously
23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES
24 |
25 | // Define the DEBUG macro in all debug builds
26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1
27 |
28 | // These are turned off to avoid STL incompatibilities with client code
29 | // // Turns on special C++ STL checks to "encourage" good STL use
30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS
31 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.google.${PRODUCT_NAME}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | GTEST_VERSIONINFO_LONG
21 | CFBundleShortVersionString
22 | GTEST_VERSIONINFO_SHORT
23 | CFBundleGetInfoString
24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT}
25 | NSHumanReadableCopyright
26 | ${GTEST_VERSIONINFO_ABOUT}
27 | CSResourcesFileMapped
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Config/ReleaseProject.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // ReleaseProject.xcconfig
3 | //
4 | // These are Release Configuration project settings for the gtest framework
5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info
6 | // dialog.
7 | // This file is based on the Xcode Configuration files in:
8 | // http://code.google.com/p/google-toolbox-for-mac/
9 | //
10 |
11 | #include "General.xcconfig"
12 |
13 | // subconfig/Release.xcconfig
14 |
15 | // Optimize for space and size (Apple recommendation)
16 | GCC_OPTIMIZATION_LEVEL = s
17 |
18 | // Deploment postprocessing is what triggers Xcode to strip
19 | DEPLOYMENT_POSTPROCESSING = YES
20 |
21 | // No symbols
22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO
23 |
24 | // Dead code strip does not affect ObjC code but can help for C
25 | DEAD_CODE_STRIPPING = YES
26 |
27 | // NDEBUG is used by things like assert.h, so define it for general compat.
28 | // ASSERT going away in release tends to create unused vars.
29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable
30 |
31 | // When we strip we want to strip all symbols in release, but save externals.
32 | STRIP_STYLE = all
33 |
--------------------------------------------------------------------------------
/src/segment_types/interp_segment.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INTERP_SEGMENT_HPP
2 | #define INTERP_SEGMENT_HPP
3 |
4 | #include "segment_type.hpp"
5 |
6 | #include
7 | #include
8 |
9 | /*!
10 | * Stores the interpreter in a string. Example of the content:
11 | * "/lib64/ld-linux-x86-64.so.2"
12 | */
13 | class InterpSegment : public SegmentType
14 | {
15 | public:
16 |
17 | /*!
18 | * Puts the interpreter into m_interpreter
19 | * \param[in] p_start the start of the binary
20 | * \param[in] p_offset the offset to this segment
21 | * \param[in] p_size the size of this segment
22 | * \param[in] p_type elf::k_progbits
23 | */
24 | InterpSegment(const char* start, boost::uint32_t p_offset,
25 | boost::uint32_t p_size, elf::section_type p_type);
26 |
27 | //! Nothing of note
28 | ~InterpSegment();
29 |
30 | //! \return the string representation of the interp segment
31 | virtual std::string printToStdOut() const;
32 |
33 | private:
34 |
35 | //! disable evil things
36 | InterpSegment(const InterpSegment& p_rhs);
37 | InterpSegment& operator=(const InterpSegment& p_rhs);
38 |
39 | private:
40 |
41 | //! The name of the interpreter
42 | std::string m_interpreter;
43 | };
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/src/abstract_symbol.hpp:
--------------------------------------------------------------------------------
1 | #ifndef ABSTRACT_SYMBOL_HPP
2 | #define ABSTRACT_SYMBOL_HPP
3 |
4 | #include
5 | #include
6 |
7 | namespace elf
8 | {
9 | namespace symbol
10 | {
11 | struct symtable_entry32;
12 | struct symtable_entry64;
13 | }
14 | }
15 |
16 | class AbstractSymbol
17 | {
18 | public:
19 | AbstractSymbol(const char* p_data, boost::uint32_t p_offset,
20 | bool p_is64, bool p_isLE);
21 | AbstractSymbol(const AbstractSymbol& p_rhs);
22 | ~AbstractSymbol();
23 |
24 | boost::uint32_t getStructSize() const;
25 | boost::uint8_t getType() const;
26 | boost::uint8_t getInfo() const;
27 | std::string getTypeName() const;
28 | std::string getBinding() const;
29 | boost::uint64_t getValue() const;
30 | boost::uint32_t getNameIndex() const;
31 | const std::string& getName() const;
32 | boost::uint16_t getSectionIndex() const;
33 |
34 | void setName(const std::string& p_name);
35 |
36 | private:
37 |
38 | // disable evil things
39 | AbstractSymbol& operator=(const AbstractSymbol& p_rhs);
40 |
41 | private:
42 |
43 | const elf::symbol::symtable_entry32* m_symbol32;
44 | const elf::symbol::symtable_entry64* m_symbol64;
45 | std::string m_name;
46 | bool m_is64;
47 | bool m_isLE;
48 | };
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/segment_types/comment_segment.hpp:
--------------------------------------------------------------------------------
1 | #ifndef COMMENT_SEGMENT_HPP
2 | #define COMMENT_SEGMENT_HPP
3 |
4 | #include "segment_type.hpp"
5 |
6 | #include
7 | #include
8 |
9 | /*!
10 | * The comment segment. Holds pretty generic information. Example of the
11 | * contents of a comment segment:
12 | * "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
13 | */
14 | class CommentSegment : public SegmentType
15 | {
16 | public:
17 |
18 | /*!
19 | * Puts the comment into m_comment
20 | * \param[in] p_start the start of the binary
21 | * \param[in] p_offset the offset to this segment
22 | * \param[in] p_size the size of this segment
23 | * \param[in] p_type elf::k_progbits
24 | */
25 | CommentSegment(const char* p_start, boost::uint32_t p_offset,
26 | boost::uint32_t p_size, elf::section_type p_type);
27 |
28 | //! Nothing of note
29 | ~CommentSegment();
30 |
31 | //! \return the string representation of the comment segment
32 | virtual std::string printToStdOut() const;
33 |
34 | private:
35 |
36 | //! disable evil things
37 | CommentSegment(const CommentSegment& p_rhs);
38 | CommentSegment& operator=(const CommentSegment& p_rhs);
39 |
40 | private:
41 |
42 | //! The strings that the comment holds
43 | std::string m_comment;
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/src/segment_types/debuglink_segment.hpp:
--------------------------------------------------------------------------------
1 | #ifndef DEBUGLINK_SEGMENT_HPP
2 | #define DEBUGLINK_SEGMENT_HPP
3 |
4 | #include "segment_type.hpp"
5 |
6 | #include
7 | #include
8 |
9 | /*!
10 | * Holds the file name pointed at by the debug link. See more information here:
11 | * https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
12 | */
13 | class DebugLinkSegment : public SegmentType
14 | {
15 | public:
16 |
17 | /*!
18 | * Puts the file name into m_file
19 | * \param[in] p_start the start of the binary
20 | * \param[in] p_offset the offset to this segment
21 | * \param[in] p_size the size of this segment
22 | * \param[in] p_type elf::k_progbits
23 | */
24 | DebugLinkSegment(const char* start, boost::uint32_t p_offset,
25 | boost::uint32_t p_size, elf::section_type p_type);
26 |
27 | //! Nothing of note
28 | ~DebugLinkSegment();
29 |
30 | //! \return the string representation of the debug link
31 | virtual std::string printToStdOut() const;
32 |
33 | private:
34 |
35 | //! Disable evil things
36 | DebugLinkSegment(const DebugLinkSegment& p_rhs);
37 | DebugLinkSegment& operator=(const DebugLinkSegment& p_rhs);
38 |
39 | private:
40 |
41 | //! The filename the debug link points to
42 | std::string m_file;
43 | };
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/src/endian.h:
--------------------------------------------------------------------------------
1 | #ifndef __FINK_ENDIANDEV_PKG_ENDIAN_H__
2 | #define __FINK_ENDIANDEV_PKG_ENDIAN_H__ 1
3 |
4 | /** compatibility header for endian.h
5 | * This is a simple compatibility shim to convert
6 | * BSD/Linux endian macros to the Mac OS X equivalents.
7 | * It is public domain.
8 | * */
9 |
10 | #ifdef APPLE
11 | #include
12 |
13 | #define htobe16(x) OSSwapHostToBigInt16(x)
14 | #define htole16(x) OSSwapHostToLittleInt16(x)
15 | #define be16toh(x) OSSwapBigToHostInt16(x)
16 | #define le16toh(x) OSSwapLittleToHostInt16(x)
17 |
18 | #define htobe32(x) OSSwapHostToBigInt32(x)
19 | #define htole32(x) OSSwapHostToLittleInt32(x)
20 | #define be32toh(x) OSSwapBigToHostInt32(x)
21 | #define le32toh(x) OSSwapLittleToHostInt32(x)
22 |
23 | #define htobe64(x) OSSwapHostToBigInt64(x)
24 | #define htole64(x) OSSwapHostToLittleInt64(x)
25 | #define be64toh(x) OSSwapBigToHostInt64(x)
26 | #define le64toh(x) OSSwapLittleToHostInt64(x)
27 | #elif WINDOWS
28 | #include
29 | #include
30 |
31 | #define htons(x) _byteswap_ushort(x)
32 | #define ntohs(x) _byteswap_ushort(x)
33 |
34 | #define htonl(x) _byteswap_ulong(x)
35 | #define ntohl(x) _byteswap_ulong(x)
36 |
37 | #define htobe64(x) htonll(x)
38 | #define htole64(x) (x)
39 | #define be64toh(x) ntohll(x)
40 | #define le64toh(x) (x)
41 | #endif
42 |
43 | #endif /* __FINK_ENDIANDEV_PKG_ENDIAN_H__ */
44 |
--------------------------------------------------------------------------------
/src/segment.cpp:
--------------------------------------------------------------------------------
1 | #include "segment.hpp"
2 | #include "structures/sectionheader.hpp"
3 |
4 | #include
5 |
6 | Segment::Segment(const std::string& p_name, const std::string& p_type,
7 | boost::uint64_t p_physOffset, boost::uint64_t p_virtAddress,
8 | boost::uint64_t p_size, boost::uint32_t p_link,
9 | bool p_executable, bool p_writable, bool p_isDynamic) :
10 | m_name(p_name),
11 | m_type(p_type),
12 | m_physOffset(p_physOffset),
13 | m_virtAddress(p_virtAddress),
14 | m_size(p_size),
15 | m_link(p_link),
16 | m_executable(p_executable),
17 | m_writable(p_writable),
18 | m_isDynamic(p_isDynamic)
19 | {
20 | }
21 |
22 | Segment::~Segment()
23 | {
24 | }
25 |
26 | boost::uint64_t Segment::getVirtAddress() const
27 | {
28 | return m_virtAddress;
29 | }
30 |
31 | boost::uint64_t Segment::getSize() const
32 | {
33 | return m_size;
34 | }
35 |
36 | boost::uint64_t Segment::getPhysOffset() const
37 | {
38 | return m_physOffset;
39 | }
40 |
41 | boost::uint32_t Segment::getLink() const
42 | {
43 | return m_link;
44 | }
45 |
46 | const std::string& Segment::getName() const
47 | {
48 | return m_name;
49 | }
50 |
51 | const std::string& Segment::getType() const
52 | {
53 | return m_type;
54 | }
55 |
56 | bool Segment::isDynamic() const
57 | {
58 | return m_isDynamic;
59 | }
60 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/xcode/Config/General.xcconfig:
--------------------------------------------------------------------------------
1 | //
2 | // General.xcconfig
3 | //
4 | // These are General configuration settings for the gtest framework and
5 | // examples.
6 | // This file is based on the Xcode Configuration files in:
7 | // http://code.google.com/p/google-toolbox-for-mac/
8 | //
9 |
10 | // Build for PPC and Intel, 32- and 64-bit
11 | ARCHS = i386 x86_64 ppc ppc64
12 |
13 | // Zerolink prevents link warnings so turn it off
14 | ZERO_LINK = NO
15 |
16 | // Prebinding considered unhelpful in 10.3 and later
17 | PREBINDING = NO
18 |
19 | // Strictest warning policy
20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow
21 |
22 | // Work around Xcode bugs by using external strip. See:
23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html
24 | SEPARATE_STRIP = YES
25 |
26 | // Force C99 dialect
27 | GCC_C_LANGUAGE_STANDARD = c99
28 |
29 | // not sure why apple defaults this on, but it's pretty risky
30 | ALWAYS_SEARCH_USER_PATHS = NO
31 |
32 | // Turn on position dependent code for most cases (overridden where appropriate)
33 | GCC_DYNAMIC_NO_PIC = YES
34 |
35 | // Default SDK and minimum OS version is 10.4
36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk
37 | MACOSX_DEPLOYMENT_TARGET = 10.4
38 | GCC_VERSION = 4.0
39 |
40 | // VERSIONING BUILD SETTINGS (used in Info.plist)
41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc.
42 |
--------------------------------------------------------------------------------
/src/ui/mainwindow.h:
--------------------------------------------------------------------------------
1 | void on_aboutButton_clicked();
2 | #ifdef QT_GUI
3 | #ifndef MAINWINDOW_H
4 | #define MAINWINDOW_H
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | namespace Ui {
11 | class MainWindow;
12 | }
13 | class ELFParser;
14 | class QTableWidgetItem;
15 | class QTreeWidgetItem;
16 |
17 | class MainWindow : public QMainWindow
18 | {
19 | Q_OBJECT
20 |
21 | public:
22 | explicit MainWindow(QWidget *parent = 0);
23 | ~MainWindow();
24 |
25 | private slots:
26 | void reset();
27 | void openFile();
28 | void closeAbout();
29 | void overviewToClipboard();
30 | void on_aboutButton_clicked();
31 | void sectionSelected(QTableWidgetItem*, QTableWidgetItem*);
32 | void programSelected(QTableWidgetItem*, QTableWidgetItem*);
33 |
34 | private:
35 | //! The main window that is created by mainwindow.ui
36 | Ui::MainWindow* m_ui;
37 |
38 | //! The dialog window
39 | boost::scoped_ptr m_dialog;
40 |
41 | //! All the allocated Table values
42 | boost::ptr_vector m_tableItems;
43 |
44 | //! All the allocated Tree values
45 | boost::ptr_vector m_treeItems;
46 |
47 | //! The reusable copy action
48 | boost::scoped_ptr m_copyAction;
49 |
50 | //! The reusable ELF parser
51 | boost::scoped_ptr m_parser;
52 | };
53 |
54 | #endif // MAINWINDOW_H
55 | #endif
56 |
--------------------------------------------------------------------------------
/src/structures/symtable_entry.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SYMTABLE_ENTRY_HPP
2 | #define SYMTABLE_ENTRY_HPP
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace elf
9 | {
10 | namespace symbol
11 | {
12 | #pragma pack(push, 1)
13 | struct symtable_entry32
14 | {
15 | boost::uint32_t m_name;
16 | boost::uint32_t m_address;
17 | boost::uint32_t m_size;
18 | boost::uint8_t m_info;
19 | boost::uint8_t m_other;
20 | boost::uint16_t m_shndx;
21 | };
22 |
23 | BOOST_STATIC_ASSERT(sizeof(symtable_entry32) == 16);
24 |
25 | struct symtable_entry64
26 | {
27 | boost::uint32_t m_name;
28 | boost::uint8_t m_info;
29 | boost::uint8_t m_other;
30 | boost::uint16_t m_shndx;
31 | boost::uint64_t m_address;
32 | boost::uint64_t m_size;
33 | };
34 |
35 | BOOST_STATIC_ASSERT(sizeof(symtable_entry64) == 24);
36 | #pragma pack(pop)
37 |
38 | enum binding
39 | {
40 | k_local = 0,
41 | k_global,
42 | k_weak
43 | };
44 |
45 | enum type
46 | {
47 | k_notype = 0,
48 | k_object,
49 | k_function,
50 | k_section,
51 | k_file,
52 | k_common,
53 | k_tls
54 | };
55 | }
56 | }
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/CONTRIBUTORS:
--------------------------------------------------------------------------------
1 | # This file contains a list of people who've made non-trivial
2 | # contribution to the Google C++ Testing Framework project. People
3 | # who commit code to the project are encouraged to add their names
4 | # here. Please keep the list sorted by first names.
5 |
6 | Ajay Joshi
7 | Balázs Dán
8 | Bharat Mediratta
9 | Chandler Carruth
10 | Chris Prince
11 | Chris Taylor
12 | Dan Egnor
13 | Eric Roman
14 | Hady Zalek
15 | Jeffrey Yasskin
16 | Jói Sigurðsson
17 | Keir Mierle
18 | Keith Ray
19 | Kenton Varda
20 | Manuel Klimek
21 | Markus Heule
22 | Mika Raento
23 | Miklós Fazekas
24 | Pasi Valminen
25 | Patrick Hanna
26 | Patrick Riley
27 | Peter Kaminski
28 | Preston Jackson
29 | Rainer Klaffenboeck
30 | Russ Cox
31 | Russ Rufer
32 | Sean Mcafee
33 | Sigurður Ásgeirsson
34 | Tracy Bialik
35 | Vadim Berman
36 | Vlad Losev
37 | Zhanyong Wan
38 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/COPYING:
--------------------------------------------------------------------------------
1 | Copyright 2008, Google Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | * Redistributions in binary form must reproduce the above
11 | copyright notice, this list of conditions and the following disclaimer
12 | in the documentation and/or other materials provided with the
13 | distribution.
14 | * Neither the name of Google Inc. nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/src/datastructures/search_tree.hpp:
--------------------------------------------------------------------------------
1 | #ifndef ELFPARSER_SEARCH_HPP
2 | #define ELFPARSER_SEARCH_HPP
3 |
4 | #include "search_node.hpp"
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | #include
11 |
12 | /*
13 | * This is a basic automata implemenation. Used for efficient searching.
14 | */
15 | class SearchTree
16 | {
17 | public:
18 |
19 | SearchTree();
20 | ~SearchTree();
21 |
22 | void addWord(const unsigned char* p_input,
23 | unsigned char p_length, void* p_storeData);
24 | void addWord(const char* p_input, unsigned char p_length, void* p_storeData);
25 | void addWord(const std::string& p_string,
26 | void* p_storeData);
27 |
28 | std::set findOffsets(const char* const p_inputString,
29 | const std::size_t p_inputLength);
30 | std::set search(const char* const p_inputString,
31 | const std::size_t p_inputLength);
32 |
33 | std::set search(const unsigned char* const p_inputString,
34 | const std::size_t p_inputLength);
35 |
36 | void compile();
37 |
38 | private:
39 |
40 | void doAddWord(SearchNode* p_node, const unsigned char* p_input,
41 | unsigned char p_length, void* p_storeData);
42 |
43 | private:
44 |
45 | SearchNode m_rootNode;
46 |
47 | bool m_ready;
48 |
49 | boost::ptr_vector m_nodeVector;
50 | };
51 |
52 | #endif
53 |
54 |
--------------------------------------------------------------------------------
/src/structures/programheader.hpp:
--------------------------------------------------------------------------------
1 | #ifndef PROGRAM_HEADER_HPP
2 | #define PROGRAM_HEADER_HPP
3 |
4 | #include
5 | #include
6 |
7 | namespace elf
8 | {
9 | struct program_header_32
10 | {
11 | boost::uint32_t m_type;
12 | boost::uint32_t m_offset;
13 | boost::uint32_t m_vaddr;
14 | boost::uint32_t m_paddr;
15 | boost::uint32_t m_filesz;
16 | boost::uint32_t m_memsz;
17 | boost::uint32_t m_flags;
18 | boost::uint32_t m_align;
19 | };
20 |
21 | BOOST_STATIC_ASSERT(sizeof(program_header_32) == 32);
22 |
23 | struct program_header_64
24 | {
25 | boost::uint32_t m_type;
26 | boost::uint32_t m_flags;
27 | boost::uint64_t m_offset;
28 | boost::uint64_t m_vaddr;
29 | boost::uint64_t m_paddr;
30 | boost::uint64_t m_filesz;
31 | boost::uint64_t m_memsz;
32 | boost::uint64_t m_align;
33 | };
34 |
35 | BOOST_STATIC_ASSERT(sizeof(program_header_64) == 56);
36 |
37 | enum programheader_type
38 | {
39 | k_pnull = 0,
40 | k_pload,
41 | k_pdynamic,
42 | k_pinterp,
43 | k_pnote,
44 | k_pshlib,
45 | k_pphdr,
46 | k_ptls,
47 | k_gnuEh = 0x6474e550,
48 | k_gnuStack = 0x6474e551,
49 | k_gnuRelRo = 0x6474e552,
50 | k_reginfo = 0x70000000,
51 | k_exidx = 0x70000001
52 | };
53 |
54 | enum programheader_flags
55 | {
56 | k_pfexec = 1,
57 | k_pfwrite = 2,
58 | k_pfread = 4
59 | };
60 | }
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/src/segment.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SEGMENT_HPP
2 | #define SEGMENT_HPP
3 |
4 | #include
5 | #include
6 |
7 | class Segment
8 | {
9 | public:
10 | Segment(const std::string& p_name, const std::string& p_type,
11 | boost::uint64_t p_physOffset, boost::uint64_t p_virtAddress,
12 | boost::uint64_t p_size, boost::uint32_t p_link,
13 | bool p_executable, bool p_writable,
14 | bool p_isDynamic);
15 | ~Segment();
16 |
17 | boost::uint64_t getVirtAddress() const;
18 | boost::uint64_t getSize() const;
19 | boost::uint64_t getPhysOffset() const;
20 | boost::uint32_t getLink() const;
21 | const std::string& getName() const;
22 | const std::string& getType() const;
23 | bool isDynamic() const;
24 |
25 | private:
26 | //! disable evil things
27 | Segment& operator=(const Segment& p_rhs);
28 | private:
29 |
30 | //! the name of this segment
31 | std::string m_name;
32 |
33 | //! the type of this segment
34 | std::string m_type;
35 |
36 | //! the file offset to this segment
37 | boost::uint64_t m_physOffset;
38 |
39 | //! the virtual address of this segment
40 | boost::uint64_t m_virtAddress;
41 |
42 | //! size on file
43 | boost::uint64_t m_size;
44 |
45 | //! the link to another table that may exist
46 | boost::uint32_t m_link;
47 |
48 | //! indicates if the area is executable
49 | bool m_executable;
50 |
51 | //! indicates if this area is writable
52 | bool m_writable;
53 |
54 | //! indicates if this is the dynamic section
55 | bool m_isDynamic;
56 | };
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/segment_types/readonly_segment.hpp:
--------------------------------------------------------------------------------
1 | #ifndef READONLY_SEGMENT_HPP
2 | #define READONLY_SEGMENT_HPP
3 |
4 | #include "segment_type.hpp"
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | /*!
12 | * This segment parses the read only segment looking for ascii strings
13 | */
14 | class ReadOnlySegment : public SegmentType
15 | {
16 | public:
17 |
18 | /*!
19 | * Parses the read only segment looking for ascii strings
20 | * \param[in] p_start the start of the image
21 | * \param[in] p_offset the offset to this segment
22 | * \param[in] p_size the size of this segment
23 | * \param[in] p_type the type of this segment
24 | */
25 | ReadOnlySegment(const char* p_start, boost::uint32_t p_offset,
26 | boost::uint32_t p_size, elf::section_type p_type);
27 |
28 | //! Nothing of note
29 | ~ReadOnlySegment();
30 |
31 | /*!
32 | * Looks for "evil" strings and add them to the reasons vector
33 | * \param[in] p_reasons the scoring vector to put the scores into
34 | * \param[in] unused capabilties set
35 | */
36 | void evaluate(std::vector >& p_reasons,
37 | std::map >&) const;
38 |
39 | //! \return the string representation of the read only segment
40 | virtual std::string printToStdOut() const;
41 |
42 | private:
43 |
44 | //! Disable evil things
45 | ReadOnlySegment(const ReadOnlySegment& p_rhs);
46 | ReadOnlySegment& operator=(const ReadOnlySegment& p_rhs);
47 |
48 | private:
49 |
50 | //! The ascii strings in the read only segment
51 | std::set m_asciiStrings;
52 | };
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/structures/dynamicstruct.hpp:
--------------------------------------------------------------------------------
1 | #ifndef DYNAMICSTRUCT_HPP
2 | #define DYNAMICSTRUCT_HPP
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace elf
10 | {
11 | namespace dynamic
12 | {
13 | struct dynamic_32
14 | {
15 | boost::uint32_t m_tag;
16 | union
17 | {
18 | boost::uint32_t m_val;
19 | boost::uint32_t m_ptr;
20 | };
21 | };
22 |
23 | BOOST_STATIC_ASSERT(8 == sizeof(dynamic_32));
24 |
25 | struct dynamic_64
26 | {
27 | boost::uint64_t m_tag;
28 | union
29 | {
30 | boost::uint64_t m_val;
31 | boost::uint64_t m_ptr;
32 | };
33 | };
34 |
35 | BOOST_STATIC_ASSERT(16 == sizeof(dynamic_64));
36 |
37 | enum tag
38 | {
39 | k_needed = 1,
40 | k_pltrelsz,
41 | k_pltgot,
42 | k_hash,
43 | k_strtab,
44 | k_symtab,
45 | k_rela,
46 | k_relasz,
47 | k_relaent,
48 | k_strsz,
49 | k_syment,
50 | k_init,
51 | k_fini,
52 | k_soname,
53 | k_rpath,
54 | k_symbolic,
55 | k_rel,
56 | k_relsz,
57 | k_relent,
58 | k_pltrel,
59 | k_debug,
60 | k_textrel,
61 | k_jmprel,
62 | k_bindnow,
63 | k_initarray,
64 | k_finiarray,
65 | k_init_arraysz,
66 | k_fini_arraysz,
67 | k_gnuhash = 0x6ffffef5
68 | };
69 | }
70 | }
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/src/segment_types/note_segment.hpp:
--------------------------------------------------------------------------------
1 | #ifndef NOTE_SEGMENT_HPP
2 | #define NOTE_SEGMENT_HPP
3 |
4 | #include "segment_type.hpp"
5 |
6 | #include
7 | #include
8 |
9 | namespace elf
10 | {
11 | struct note;
12 | }
13 |
14 | /*!
15 | * Parses the note segment and tries to interpret the contents. Some parsed
16 | * examples:
17 | * "Name="GNU, Type=1, Type String="NT_GNU_ABI_TAG", Description="OS Linux 2.6.24""
18 | * "Name="GNU", Type=3, Type String="NT_GNU_BUILD_ID", Description="f21bf131b6da48c9bfe35b117c5b15a687174362""
19 | */
20 | class NoteSegment : public SegmentType
21 | {
22 | public:
23 |
24 | /*!
25 | * Parses the note and stores the values into the member variables
26 | * \param[in] p_start the start of the binary
27 | * \param[in] p_offset the offset to this segment
28 | * \param[in] p_size the size of this segment
29 | * \param[in] p_type elf::k_note
30 | */
31 | NoteSegment(const char* start, boost::uint32_t p_offset,
32 | boost::uint32_t p_size, elf::section_type p_type);
33 |
34 | //nothing of note (lol)
35 | ~NoteSegment();
36 |
37 | //! \return the string representation of the note segment
38 | virtual std::string printToStdOut() const;
39 |
40 | private:
41 |
42 | //!disable evil things
43 | NoteSegment(const NoteSegment& p_rhs);
44 | NoteSegment& operator=(const NoteSegment& p_rhs);
45 |
46 | private:
47 |
48 | //! A pointer to the start of the note structure
49 | const elf::note* m_note;
50 |
51 | //! The name of the note
52 | std::string m_name;
53 |
54 | //! The interpreted type of the note
55 | std::string m_noteType;
56 |
57 | //! The interpreted description of the note
58 | std::string m_description;
59 | };
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/src/segment_types/strtable_segment.hpp:
--------------------------------------------------------------------------------
1 | #ifndef STRINGTABLE_SEGMENT_HPP
2 | #define STRINGTABLE_SEGMENT_HPP
3 |
4 | #include "segment_type.hpp"
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | /*!
11 | * Holds all the strings in the string table
12 | */
13 | class StringTableSegment : public SegmentType
14 | {
15 | public:
16 |
17 | /*!
18 | * Parses the string table for strings and stores them in the m_strings set
19 | * \param[in] p_start the start of the image
20 | * \param[in] p_offset the offset to this segment
21 | * \param[in] p_size the size of the segment
22 | * \param[in] p_type the type of segment
23 | */
24 | StringTableSegment(const char* p_start, boost::uint32_t p_offset,
25 | boost::uint32_t p_size, elf::section_type p_type);
26 |
27 | //! nothing of note
28 | ~StringTableSegment();
29 |
30 | //! \return the number of strings in m_strings
31 | std::size_t getSize() const;
32 |
33 | /*!
34 | * Looks up a string in the string table and demangles it (Linux only)
35 | * \param[in] p_index the index of the string to look up
36 | * \return the string in the table
37 | */
38 | std::string stringLookup(std::size_t p_index) const;
39 |
40 | //! \return a string representation of the String Table
41 | virtual std::string printToStdOut() const;
42 |
43 | private:
44 |
45 | //! Disable evil things
46 | StringTableSegment(const StringTableSegment& p_rhs);
47 | StringTableSegment& operator=(const StringTableSegment& p_rhs);
48 |
49 | private:
50 |
51 | //! A set of the strings in the segment
52 | std::set m_stringsSet;
53 |
54 | //! The start of the segment
55 | const char* m_start;
56 | };
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/structures/sectionheader.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SECTION_HEADER_HPP
2 | #define SECTION_HEADER_HPP
3 |
4 | #include
5 | #include
6 |
7 | namespace elf
8 | {
9 | struct section_header_32
10 | {
11 | boost::uint32_t m_name;
12 | boost::uint32_t m_type;
13 | boost::uint32_t m_flags;
14 | boost::uint32_t m_addr;
15 | boost::uint32_t m_offset;
16 | boost::uint32_t m_size;
17 | boost::uint32_t m_link;
18 | boost::uint32_t m_info;
19 | boost::uint32_t m_addralign;
20 | boost::uint32_t m_entsize;
21 | };
22 |
23 | BOOST_STATIC_ASSERT(sizeof(section_header_32) == 40);
24 |
25 | struct section_header_64
26 | {
27 | boost::uint32_t m_name;
28 | boost::uint32_t m_type;
29 | boost::uint64_t m_flags;
30 | boost::uint64_t m_addr;
31 | boost::uint64_t m_offset;
32 | boost::uint64_t m_size;
33 | boost::uint32_t m_link;
34 | boost::uint32_t m_info;
35 | boost::uint64_t m_addralign;
36 | boost::uint64_t m_entsize;
37 | };
38 |
39 | BOOST_STATIC_ASSERT(sizeof(section_header_64) == 64);
40 |
41 | enum section_type
42 | {
43 | k_null = 0,
44 | k_progbits,
45 | k_symtab,
46 | k_strtab,
47 | k_rela,
48 | k_hash,
49 | k_dynamic,
50 | k_note,
51 | k_nobits,
52 | k_rel,
53 | k_shlib,
54 | k_dynsym,
55 | k_initArray = 14,
56 | k_finiArray = 15,
57 | k_gnuHash = 0x6ffffff6,
58 | k_gnuVersionR = 0x6ffffffe,
59 | k_gnuVersion = 0x6fffffff
60 | };
61 |
62 | enum section_flags
63 | {
64 | k_shwrite = 1,
65 | k_shalloc = 2,
66 | k_shexec = 4
67 | };
68 | }
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/segment_types/readonly_segment.cpp:
--------------------------------------------------------------------------------
1 | #include "readonly_segment.hpp"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | ReadOnlySegment::ReadOnlySegment(const char* start, boost::uint32_t p_offset,
8 | boost::uint32_t p_size, elf::section_type p_type) :
9 | SegmentType(start, p_offset, p_size, p_type),
10 | m_asciiStrings()
11 | {
12 | std::string current;
13 | const char* readOnly = start + p_offset;
14 | for (boost::uint32_t i = 0; i < p_size; ++i)
15 | {
16 | if (isprint(static_cast(readOnly[i])))
17 | {
18 | current.push_back(readOnly[i]);
19 | }
20 | else
21 | {
22 | if (current.size() > 7)
23 | {
24 | m_asciiStrings.insert(current);
25 | }
26 | current.clear();
27 | }
28 | }
29 | }
30 |
31 | ReadOnlySegment::~ReadOnlySegment()
32 | {
33 | }
34 |
35 | std::string ReadOnlySegment::printToStdOut() const
36 | {
37 | std::stringstream return_value;
38 | return_value << "Read Only Segment (offset=0x" << std::hex << m_offset
39 | << ", size=" << std::dec << m_size << ", strings="
40 | << m_asciiStrings.size() << ")\n";
41 |
42 | BOOST_FOREACH(const std::string& p_ascii, m_asciiStrings)
43 | {
44 | return_value << "\tString=\"" << p_ascii << "\"\n";
45 | }
46 | return return_value.str();
47 | }
48 |
49 | void ReadOnlySegment::evaluate(std::vector >& p_reasons,
50 | std::map >&) const
51 | {
52 | if (m_asciiStrings.empty())
53 | {
54 | p_reasons.push_back(std::make_pair(5, std::string("No ascii strings in the read only section.")));
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/test/production.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 | //
32 | // This is part of the unit test for include/gtest/gtest_prod.h.
33 |
34 | #include "production.h"
35 |
36 | PrivateCode::PrivateCode() : x_(0) {}
37 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/src/gtest_main.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | #include
31 |
32 | #include "gtest/gtest.h"
33 |
34 | GTEST_API_ int main(int argc, char **argv) {
35 | std::cout << "Running main() from gtest_main.cc\n";
36 |
37 | testing::InitGoogleTest(&argc, argv);
38 | return RUN_ALL_TESTS();
39 | }
40 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/fused-src/gtest/gtest_main.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | #include
31 |
32 | #include "gtest/gtest.h"
33 |
34 | GTEST_API_ int main(int argc, char **argv) {
35 | std::cout << "Running main() from gtest_main.cc\n";
36 |
37 | testing::InitGoogleTest(&argc, argv);
38 | return RUN_ALL_TESTS();
39 | }
40 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/codegear/gtest_all.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2009, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: Josh Kelley (joshkel@gmail.com)
31 | //
32 | // Google C++ Testing Framework (Google Test)
33 | //
34 | // C++Builder's IDE cannot build a static library from files with hyphens
35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 .
36 | // This file serves as a workaround.
37 |
38 | #include "src/gtest-all.cc"
39 |
--------------------------------------------------------------------------------
/lib/hash-lib/md5.h:
--------------------------------------------------------------------------------
1 | // //////////////////////////////////////////////////////////
2 | // md5.h
3 | // Copyright (c) 2014 Stephan Brumme. All rights reserved.
4 | // see http://create.stephan-brumme.com/disclaimer.html
5 | //
6 |
7 | #pragma once
8 |
9 | //#include "hash.h"
10 | #include
11 |
12 | // define fixed size integer types
13 | #ifdef _MSC_VER
14 | // Windows
15 | typedef unsigned __int8 uint8_t;
16 | typedef unsigned __int32 uint32_t;
17 | typedef unsigned __int64 uint64_t;
18 | #else
19 | // GCC
20 | #include
21 | #endif
22 |
23 |
24 | /// compute MD5 hash
25 | /** Usage:
26 | MD5 md5;
27 | std::string myHash = md5("Hello World"); // std::string
28 | std::string myHash2 = md5("How are you", 11); // arbitrary data, 11 bytes
29 |
30 | // or in a streaming fashion:
31 |
32 | MD5 md5;
33 | while (more data available)
34 | md5.add(pointer to fresh data, number of new bytes);
35 | std::string myHash3 = md5.getHash();
36 | */
37 | class MD5 //: public Hash
38 | {
39 | public:
40 | /// same as reset()
41 | MD5();
42 |
43 | /// compute MD5 of a memory block
44 | std::string operator()(const void* data, size_t numBytes);
45 | /// compute MD5 of a string, excluding final zero
46 | std::string operator()(const std::string& text);
47 |
48 | /// add arbitrary number of bytes
49 | void add(const void* data, size_t numBytes);
50 |
51 | /// return latest hash as 16 hex characters
52 | std::string getHash();
53 |
54 | /// restart
55 | void reset();
56 |
57 | private:
58 | /// process 64 bytes
59 | void processBlock(const void* data);
60 | /// process everything left in the internal buffer
61 | void processBuffer();
62 |
63 | /// split into 64 byte blocks (=> 512 bits)
64 | enum { BlockSize = 512 / 8 };
65 |
66 | /// size of processed data in bytes
67 | uint64_t m_numBytes;
68 | /// valid bytes in m_buffer
69 | size_t m_bufferSize;
70 | /// bytes not processed yet
71 | uint8_t m_buffer[BlockSize];
72 | /// hash, stored as integers
73 | uint32_t m_hash[4];
74 | };
75 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/scripts/test/Makefile:
--------------------------------------------------------------------------------
1 | # A Makefile for fusing Google Test and building a sample test against it.
2 | #
3 | # SYNOPSIS:
4 | #
5 | # make [all] - makes everything.
6 | # make TARGET - makes the given target.
7 | # make check - makes everything and runs the built sample test.
8 | # make clean - removes all files generated by make.
9 |
10 | # Points to the root of fused Google Test, relative to where this file is.
11 | FUSED_GTEST_DIR = output
12 |
13 | # Paths to the fused gtest files.
14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h
15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
16 |
17 | # Where to find the sample test.
18 | SAMPLE_DIR = ../../samples
19 |
20 | # Where to find gtest_main.cc.
21 | GTEST_MAIN_CC = ../../src/gtest_main.cc
22 |
23 | # Flags passed to the preprocessor.
24 | # We have no idea here whether pthreads is available in the system, so
25 | # disable its use.
26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0
27 |
28 | # Flags passed to the C++ compiler.
29 | CXXFLAGS += -g
30 |
31 | all : sample1_unittest
32 |
33 | check : all
34 | ./sample1_unittest
35 |
36 | clean :
37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o
38 |
39 | $(FUSED_GTEST_H) :
40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR)
41 |
42 | $(FUSED_GTEST_ALL_CC) :
43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR)
44 |
45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)
46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
47 |
48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)
49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)
50 |
51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h
52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc
53 |
54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \
55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)
56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc
57 |
58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o
59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@
60 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/test/gtest_main_unittest.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2006, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include "gtest/gtest.h"
33 |
34 | // Tests that we don't have to define main() when we link to
35 | // gtest_main instead of gtest.
36 |
37 | namespace {
38 |
39 | TEST(GTestMainTest, ShouldSucceed) {
40 | }
41 |
42 | } // namespace
43 |
44 | // We are using the main() function defined in src/gtest_main.cc, so
45 | // we don't define it here.
46 |
--------------------------------------------------------------------------------
/lib/hash-lib/sha1.h:
--------------------------------------------------------------------------------
1 | // //////////////////////////////////////////////////////////
2 | // sha1.h
3 | // Copyright (c) 2014 Stephan Brumme. All rights reserved.
4 | // see http://create.stephan-brumme.com/disclaimer.html
5 | //
6 |
7 | #pragma once
8 |
9 | //#include "hash.h"
10 | #include
11 |
12 | // define fixed size integer types
13 | #ifdef _MSC_VER
14 | // Windows
15 | typedef unsigned __int8 uint8_t;
16 | typedef unsigned __int32 uint32_t;
17 | typedef unsigned __int64 uint64_t;
18 | #else
19 | // GCC
20 | #include
21 | #endif
22 |
23 |
24 | /// compute SHA1 hash
25 | /** Usage:
26 | SHA1 sha1;
27 | std::string myHash = sha1("Hello World"); // std::string
28 | std::string myHash2 = sha1("How are you", 11); // arbitrary data, 11 bytes
29 |
30 | // or in a streaming fashion:
31 |
32 | SHA1 sha1;
33 | while (more data available)
34 | sha1.add(pointer to fresh data, number of new bytes);
35 | std::string myHash3 = sha1.getHash();
36 | */
37 | class SHA1 //: public Hash
38 | {
39 | public:
40 | /// same as reset()
41 | SHA1();
42 |
43 | /// compute SHA1 of a memory block
44 | std::string operator()(const void* data, size_t numBytes);
45 | /// compute SHA1 of a string, excluding final zero
46 | std::string operator()(const std::string& text);
47 |
48 | /// add arbitrary number of bytes
49 | void add(const void* data, size_t numBytes);
50 |
51 | /// return latest hash as 16 hex characters
52 | std::string getHash();
53 |
54 | /// restart
55 | void reset();
56 |
57 | private:
58 | /// process 64 bytes
59 | void processBlock(const void* data);
60 | /// process everything left in the internal buffer
61 | void processBuffer();
62 |
63 | /// split into 64 byte blocks (=> 512 bits)
64 | enum { BlockSize = 512 / 8, HashValues = 5 };
65 |
66 | /// size of processed data in bytes
67 | uint64_t m_numBytes;
68 | /// valid bytes in m_buffer
69 | size_t m_bufferSize;
70 | /// bytes not processed yet
71 | uint8_t m_buffer[BlockSize];
72 | /// hash, stored as integers
73 | uint32_t m_hash[HashValues];
74 | };
75 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/samples/sample4_unittest.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include "gtest/gtest.h"
33 | #include "sample4.h"
34 |
35 | // Tests the Increment() method.
36 | TEST(Counter, Increment) {
37 | Counter c;
38 |
39 | // EXPECT_EQ() evaluates its arguments exactly once, so they
40 | // can have side effects.
41 |
42 | EXPECT_EQ(0, c.Increment());
43 | EXPECT_EQ(1, c.Increment());
44 | EXPECT_EQ(2, c.Increment());
45 | }
46 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/samples/sample1.h:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_
35 | #define GTEST_SAMPLES_SAMPLE1_H_
36 |
37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1.
38 | int Factorial(int n);
39 |
40 | // Returns true iff n is a prime number.
41 | bool IsPrime(int n);
42 |
43 | #endif // GTEST_SAMPLES_SAMPLE1_H_
44 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/test/gtest_uninitialized_test_.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2008, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 | //
30 | // Author: wan@google.com (Zhanyong Wan)
31 |
32 | #include "gtest/gtest.h"
33 |
34 | TEST(DummyTest, Dummy) {
35 | // This test doesn't verify anything. We just need it to create a
36 | // realistic stage for testing the behavior of Google Test when
37 | // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being
38 | // called first.
39 | }
40 |
41 | int main() {
42 | return RUN_ALL_TESTS();
43 | }
44 |
--------------------------------------------------------------------------------
/lib/gtest-1.6.0/samples/sample4.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2005, Google Inc.
2 | // All rights reserved.
3 | //
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are
6 | // met:
7 | //
8 | // * Redistributions of source code must retain the above copyright
9 | // notice, this list of conditions and the following disclaimer.
10 | // * Redistributions in binary form must reproduce the above
11 | // copyright notice, this list of conditions and the following disclaimer
12 | // in the documentation and/or other materials provided with the
13 | // distribution.
14 | // * Neither the name of Google Inc. nor the names of its
15 | // contributors may be used to endorse or promote products derived from
16 | // this software without specific prior written permission.
17 | //
18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 | // A sample program demonstrating using Google C++ testing framework.
31 | //
32 | // Author: wan@google.com (Zhanyong Wan)
33 |
34 | #include
35 |
36 | #include "sample4.h"
37 |
38 | // Returns the current counter value, and increments it.
39 | int Counter::Increment() {
40 | return counter_++;
41 | }
42 |
43 | // Prints the current counter value to STDOUT.
44 | void Counter::Print() const {
45 | printf("%d", counter_);
46 | }
47 |
--------------------------------------------------------------------------------
/lib/hash-lib/sha256.h:
--------------------------------------------------------------------------------
1 | // //////////////////////////////////////////////////////////
2 | // sha256.h
3 | // Copyright (c) 2014 Stephan Brumme. All rights reserved.
4 | // see http://create.stephan-brumme.com/disclaimer.html
5 | //
6 |
7 | #pragma once
8 |
9 | //#include "hash.h"
10 | #include
11 |
12 | // define fixed size integer types
13 | #ifdef _MSC_VER
14 | // Windows
15 | typedef unsigned __int8 uint8_t;
16 | typedef unsigned __int32 uint32_t;
17 | typedef unsigned __int64 uint64_t;
18 | #else
19 | // GCC
20 | #include
21 | #endif
22 |
23 |
24 | /// compute SHA256 hash
25 | /** Usage:
26 | SHA256 sha256;
27 | std::string myHash = sha256("Hello World"); // std::string
28 | std::string myHash2 = sha256("How are you", 11); // arbitrary data, 11 bytes
29 |
30 | // or in a streaming fashion:
31 |
32 | SHA256 sha256;
33 | while (more data available)
34 | sha256.add(pointer to fresh data, number of new bytes);
35 | std::string myHash3 = sha256.getHash();
36 | */
37 | class SHA256 //: public Hash
38 | {
39 | public:
40 | /// same as reset()
41 | SHA256();
42 |
43 | /// compute SHA256 of a memory block
44 | std::string operator()(const void* data, size_t numBytes);
45 | /// compute SHA256 of a string, excluding final zero
46 | std::string operator()(const std::string& text);
47 |
48 | /// add arbitrary number of bytes
49 | void add(const void* data, size_t numBytes);
50 |
51 | /// return latest hash as 16 hex characters
52 | std::string getHash();
53 |
54 | /// restart
55 | void reset();
56 |
57 | private:
58 | /// process 64 bytes
59 | void processBlock(const void* data);
60 | /// process everything left in the internal buffer
61 | void processBuffer();
62 |
63 | /// split into 64 byte blocks (=> 512 bits)
64 | enum { BlockSize = 512 / 8, HashValues = 8 };
65 |
66 | /// size of processed data in bytes
67 | uint64_t m_numBytes;
68 | /// valid bytes in m_buffer
69 | size_t m_bufferSize;
70 | /// bytes not processed yet
71 | uint8_t m_buffer[BlockSize];
72 | /// hash, stored as integers
73 | uint32_t m_hash[8];
74 | };
75 |
--------------------------------------------------------------------------------
/src/symbols.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SYMBOLS_HPP
2 | #define SYMBOLS_HPP
3 |
4 | #include
5 | #include