Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #81

Closed
wants to merge 4 commits into from
Closed

WIP #81

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion include/boost/dll/detail/pe_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <cstring>
#include <fstream>
#include <iostream>
#include <string> // for std::getline
#include <vector>

Expand Down Expand Up @@ -311,8 +312,10 @@ class pe_info {

static std::vector<std::string> symbols(std::ifstream& fs, const char* section_name) {
std::vector<std::string> ret;
std::cerr << "!!!!!! BEFORE header(fs)\n";

const header_t h = header(fs);
std::cerr << "!!!!!! AFTER header(fs)\n";

std::size_t section_begin_addr = 0;
std::size_t section_end_addr = 0;
Expand All @@ -322,6 +325,7 @@ class pe_info {
char name_helper[section_t::IMAGE_SIZEOF_SHORT_NAME_ + 1];
std::memset(name_helper, 0, sizeof(name_helper));
for (std::size_t i = 0;i < h.FileHeader.NumberOfSections;++i) {
std::cerr << "!!!!!! LOOP iteration " << i << "\n";
// There is no terminating null character if the string is exactly eight characters long
read_raw(fs, image_section_header);
std::memcpy(name_helper, image_section_header.Name, section_t::IMAGE_SIZEOF_SHORT_NAME_);
Expand All @@ -330,13 +334,16 @@ class pe_info {
section_end_addr = section_begin_addr + image_section_header.SizeOfRawData;
}
}
std::cerr << "!!!!!! END LOOP iteration\n";

// returning empty result if section was not found
if(section_begin_addr == 0 || section_end_addr == 0)
return ret;
}

std::cerr << "!!!!!! BEFORE exports(fs, h)\n";
const exports_t exprt = exports(fs, h);
std::cerr << "!!!!!! AFTER exports(fs, h) exprt.NumberOfFunctions " << exprt.NumberOfFunctions << " NumberOfNames = " << exprt.NumberOfNames << "\n";
const std::size_t exported_symbols = exprt.NumberOfFunctions;
const std::size_t fixed_names_addr = get_file_offset(fs, exprt.AddressOfNames, h);
const std::size_t fixed_ordinals_addr = get_file_offset(fs, exprt.AddressOfNameOrdinals, h);
Expand All @@ -347,25 +354,38 @@ class pe_info {
boost::dll::detail::WORD_ ordinal;
std::string symbol_name;
for (std::size_t i = 0;i < exported_symbols;++i) {
std::cerr << "!!!!!! LOOP exported_symbols iteration " << i << "\n";
// getting ordinal
fs.seekg(fixed_ordinals_addr + i * sizeof(ordinal));
read_raw(fs, ordinal);
std::cerr << "!!!!!! LOOP exported_symbols ordinal " << ordinal << "\n";
if (ordinal >= exported_symbols) {
std::cerr << "!!!!!! LOOP clang-win exiting\n";
continue;
}

// getting function addr
fs.seekg(fixed_functions_addr + ordinal * sizeof(ptr));
read_raw(fs, ptr);
std::cerr << "!!!!!! LOOP exported_symbols ptr " << ptr << "\n";
ptr = static_cast<boost::dll::detail::DWORD_>( get_file_offset(fs, ptr, h) );


std::cerr << "!!!!!! LOOP exported_symbols " << ptr << " >= " << section_end_addr << " || " << ptr << " < " << section_begin_addr << "\n";
if (ptr >= section_end_addr || ptr < section_begin_addr) {
std::cerr << "!!!!!! LOOP exported_symbols true is " << ptr << " >= " << section_end_addr << " || " << ptr << " < " << section_begin_addr << "\n";
continue;
}
std::cerr << "!!!!!! LOOP exported_symbols false is " << ptr << " >= " << section_end_addr << " || " << ptr << " < " << section_begin_addr << "\n";

fs.seekg(fixed_names_addr + i * sizeof(ptr));
read_raw(fs, ptr);
std::cerr << "!!!!!! LOOP exported_symbols read_raw " << ptr << "\n";
fs.seekg(get_file_offset(fs, ptr, h));
std::getline(fs, symbol_name, '\0');
std::cerr << "!!!!!! LOOP exported_symbols symbol_name " << symbol_name << "\n";
ret.push_back(symbol_name);
}
std::cerr << "!!!!!! END LOOP exported_symbols\n";

return ret;
}
Expand Down
34 changes: 0 additions & 34 deletions test/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,12 @@ skip_tags: true

environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 14,17,latest # latest is C++2a
ADDRMD: 32,64
# TODO: Clang 32bit job yields:
# LINK : fatal error LNK1171: unable to load mspdbcore.dll (error code: 126)
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
CXXSTD: 14,17
ADDRMD: 64
# Some issue with stdcxx=14 builds:
# clang-cl: error: linker command failed with exit code 1181 (use -v to see invocation)
# "clang-cl.exe" "clang-cl.exe" -m64 -m64 /link /link /incremental:no /incremental:no /manifest /manifest /DLL /subsystem:console /subsystem:console /out:"..\..\..\bin.v2\libs\dll\test\clang-win-9.0.1\release\address-model-64\cxxstd-14-iso\threading-multi\library1-clangw9-mt-x64-1_73.dll" /IMPLIB:"..\..\..\bin.v2\libs\dll\test\clang-win-9.0.1\release\address-model-64\cxxstd-14-iso\threading-multi\library1-clangw9-mt-x64-1_73.lib" @"..\..\..\bin.v2\libs\dll\test\clang-win-9.0.1\release\address-model-64\cxxstd-14-iso\threading-multi\library1-clangw9-mt-x64-1_73.dll.rsp"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: clang-win
CXXSTD: 17,2a
ADDRMD: 32,64

# TODO: Both Cygwins have problems with <link.h> and `dladdr`
#- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
# ADDPATH: C:\cygwin\bin;
# TOOLSET: gcc
# CXXSTD: 11,14,1z
#- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
# ADDPATH: C:\cygwin64\bin;
# TOOLSET: gcc
# CXXSTD: 11,14,1z
# MinGW 32 bit is not supported by boost system any more
#- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
# ADDPATH: C:\mingw\bin;
# TOOLSET: gcc
# CXXSTD: 11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 11,14,1z

before_build:
- set BOOST_BRANCH=develop
Expand Down
Loading