Skip to content

Commit

Permalink
Merge pull request #92 from gdt050579/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
gheorghitamutu authored Jul 19, 2022
2 parents 511b287 + c47e192 commit eb774aa
Show file tree
Hide file tree
Showing 38 changed files with 1,364 additions and 341 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: build

on:
push:
branches:
- main
branches: [ release, main, dev ]
workflow_dispatch:
pull_request:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ env:

on:
push:
branches: [ main ]
branches: [ release, main, dev ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [ release, main, dev ]
schedule:
- cron: '42 20 * * 0'

Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ jobs:
run: ls -R /Users/runner/work/GView/GView/bin/Release

- name: Create archive
working-directory: /Users/runner/work/GView/GView/bin/Release
run: |
output=$(zip -9 -r "GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip" /Users/runner/work/GView/GView/bin/Release)
output=$(zip -9 -r "GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip" .)
echo "$output"
- name: Store Artifacts
uses: actions/upload-artifact@v3
with:
name: apple_artifacts
path: "GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip"
path: "/Users/runner/work/GView/GView/bin/Release/GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip"
retention-days: 1

build-ubuntu:
Expand Down Expand Up @@ -127,15 +128,16 @@ jobs:
run: ls -R /home/runner/work/GView/GView/bin/Release

- name: Create archive
working-directory: /home/runner/work/GView/GView/bin/Release
run: |
output=$(zip -9 -r "GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip" /home/runner/work/GView/GView/bin/Release)
output=$(zip -9 -r "GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip" .)
echo "$output"
- name: Store Artifacts
uses: actions/upload-artifact@v3
with:
name: linux_artifacts
path: "GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip"
path: "/home/runner/work/GView/GView/bin/Release/GView-${{ runner.os }}-${{ env.GVIEW_VERSION }}.zip"
retention-days: 1

publish_job:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ name: Microsoft C++ Code Analysis

on:
push:
branches: [ main ]
branches: [ release, main, dev ]
pull_request:
branches: [ main ]
branches: [ release, main, dev ]

env:
# Path to the CMake build directory.
Expand Down
37 changes: 31 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,46 @@ cmake_minimum_required(VERSION 3.13)

project(GView VERSION 1.0)

include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)

if( supported )
message(STATUS "${PROJECT_NAME} => IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "${PROJECT_NAME} => IPO / LTO not supported: <${error}>")
endif()

# versioning
file(READ "GViewCore/include/GView.hpp" GView_content)
string(REGEX MATCH "#define GVIEW_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"" _ ${GView_content})
set(GVIEW_VERSION ${CMAKE_MATCH_1})
message("${PROJECT_NAME} version: ${GVIEW_VERSION}")

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEBUG_BUILD 1)
endif()

find_package(OpenSSL REQUIRED)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../bin/Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../bin/Release)
if (NOT MSVC)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../bin/${CMAKE_BUILD_TYPE}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../bin/${CMAKE_BUILD_TYPE}")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../bin/${CMAKE_BUILD_TYPE}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/../bin/${CMAKE_BUILD_TYPE}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/../bin/${CMAKE_BUILD_TYPE}")

if (MSVC)
add_definitions(-DBUILD_FOR_WINDOWS)
Expand Down Expand Up @@ -87,10 +111,11 @@ add_subdirectory(Types/LNK)
add_subdirectory(Types/JOB)
add_subdirectory(Types/PCAP)
add_subdirectory(Types/ELF)
add_subdirectory(Types/JT)
add_subdirectory(Types/INI)

# Generic plugins supported by GView
add_subdirectory(GenericPlugins/CharacterTable)
add_subdirectory(GenericPlugins/Hashes)

target_link_libraries(GView PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
110 changes: 110 additions & 0 deletions GViewCore/include/GView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,116 @@ namespace DigitalSignature
CORE_EXPORT bool CMSToStructure(const Buffer& buffer, Signature& output);
} // namespace DigitalSignature

namespace Golang
{
constexpr auto ELF_GO_BUILD_ID_TAG = 4U;
constexpr auto GNU_BUILD_ID_TAG = 3U;

constexpr auto ELF_GO_NOTE = std::string_view("Go\x00\x00", 4);
constexpr auto ELF_GNU_NOTE = std::string_view("GNU\x00", 4);

// version of the pclntab (Program Counter Line Table) -: https://go.dev/src/debug/gosym/pclntab.go
enum class PclntabVersion : int32
{
Unknown = -1,
_11 = 0,
_12 = 1,
_116 = 2,
_118 = 3,
};

enum class GoMagic : uint32 // https://go.dev/src/debug/gosym/pclntab.go
{
_12 = 0xfffffffb,
_116 = 0xfffffffa,
_118 = 0xfffffff0,
};

struct CORE_EXPORT GoFunctionHeader
{
GoMagic magic;
uint16 padding;
uint8 instructionSizeQuantum; // (1 for x86, 4 for ARM)
uint8 sizeOfUintptr; // in bytes
};

enum class Architecture : uint8
{
Unknown = 0,
x86 = 1,
x64 = 2
};

struct CORE_EXPORT FstEntry32
{
uint32 pc;
uint32 functionOffset;
};

struct FstEntry64
{
uint64 pc;
uint32 functionOffset;
};

struct CORE_EXPORT Func32
{
uint32 entry; // start pc
int32 name; // name (offset to C string)
int32 args; // size of arguments passed to function
int32 frame; // size of function frame, including saved caller PC
int32 pcsp; // pcsp table (offset to pcvalue table)
int32 pcfile; // pcfile table (offset to pcvalue table)
int32 pcln; // pcln table (offset to pcvalue table)
int32 nfuncdata; // number of entries in funcdata list
int32 npcdata; // number of entries in pcdata list
};

struct CORE_EXPORT Func64
{
uint64 entry; // start pc
int32 name; // name (offset to C string)
int32 args; // size of arguments passed to function
int32 frame; // size of function frame, including saved caller PC
int32 pcsp; // pcsp table (offset to pcvalue table)
int32 pcfile; // pcfile table (offset to pcvalue table)
int32 pcln; // pcln table (offset to pcvalue table)
int32 nfuncdata; // number of entries in funcdata list
int32 npcdata; // number of entries in pcdata list
};

struct CORE_EXPORT Function
{
char* name{ nullptr };
Func64 func;
};

struct CORE_EXPORT GoPclntab112
{
private:
void* context{ nullptr };
void Reset();

public:
GoPclntab112();
~GoPclntab112();
bool Process(const Buffer& buffer, Architecture arch);
GoFunctionHeader* GetHeader() const;
uint64 GetFilesCount() const;
bool GetFile(uint64 index, std::string_view& file) const;
uint64 GetFunctionsCount() const;
bool GetFunction(uint64 index, Function& func) const;
uint64 GetEntriesCount() const;
};

CORE_EXPORT const char* GetNameForGoMagic(GoMagic magic);
} // namespace Golang

namespace Pyc
{

}

namespace Compression
{
namespace LZXPRESS
Expand Down
28 changes: 18 additions & 10 deletions GViewCore/src/App/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,27 @@ void Instance::ShowErrors()
}
bool Instance::AddFileWindow(const std::filesystem::path& path)
{
if (std::filesystem::is_directory(path))
try
{
return AddFolder(path);
}
else
{
auto f = std::make_unique<AppCUI::OS::File>();
if (f->OpenRead(path) == false)
if (std::filesystem::is_directory(path))
{
errList.AddError("Fail to open file: %s", path.u8string().c_str());
RETURNERROR(false, "Fail to open file: %s", path.u8string().c_str());
return AddFolder(path);
}
return Add(Object::Type::File, std::move(f), path.filename().u16string(), path.u16string(), 0, path.extension().string());
else
{
auto f = std::make_unique<AppCUI::OS::File>();
if (f->OpenRead(path) == false)
{
errList.AddError("Fail to open file: %s", path.u8string().c_str());
RETURNERROR(false, "Fail to open file: %s", path.u8string().c_str());
}
return Add(Object::Type::File, std::move(f), path.filename().u16string(), path.u16string(), 0, path.extension().string());
}
}
catch (std::filesystem::filesystem_error /* e */)
{
errList.AddError("Fail to open file: %s", path.u8string().c_str());
RETURNERROR(false, "Fail to open file: %s", path.u8string().c_str());
}
}
bool Instance::AddBufferWindow(BufferView buf, const ConstString& name, string_view typeExtension)
Expand Down
2 changes: 2 additions & 0 deletions GViewCore/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ add_subdirectory(View)
add_subdirectory(Hashes)
add_subdirectory(DigitalSignature)
add_subdirectory(Compression)
add_subdirectory(Go)
add_subdirectory(Pyc)
target_sources(GViewCore PRIVATE main.cpp)


3 changes: 3 additions & 0 deletions GViewCore/src/Go/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target_sources(GViewCore PRIVATE
go.cpp
)
Loading

0 comments on commit eb774aa

Please sign in to comment.