diff --git a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.rc b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.rc index 761f90d..7b0bc7b 100644 Binary files a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.rc and b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.rc differ diff --git a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj index d0f1f63..5791fc1 100644 --- a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj +++ b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj @@ -91,10 +91,11 @@ NotUsing Level3 true - WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions);NOMINMAX pch.h C:\git_work\a2l\a2l_test\TestLibDlg\IncSourceTestDlg\include;C:\git_work\a2l\a2l_test\TestLibDlg\IncSourceTestDlg\src;C:\boost\include\boost-1_87;%(AdditionalIncludeDirectories) stdcpp20 + Default Windows @@ -199,9 +200,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -218,6 +243,7 @@ + Create Create diff --git a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj.filters b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj.filters index 85e8be1..a3a8794 100644 --- a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj.filters +++ b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj.filters @@ -16,6 +16,9 @@ {ab092bfb-4c1e-40f2-bfa9-349fda25fa4c} + + {00f7a33d-e5dd-4f72-bbad-87059b065042} + @@ -63,6 +66,78 @@ src + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + @@ -185,6 +260,9 @@ src + + 소스 파일 + diff --git a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.cpp b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.cpp index f30038a..4967980 100644 --- a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.cpp +++ b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.cpp @@ -10,6 +10,15 @@ #include "afxdialogex.h" #include +#include +#include +#include + + +#include +#include "intelhex.h" +#include "elfio.hpp" +#include "elfio_dump.hpp" #ifdef _DEBUG #define new DEBUG_NEW @@ -96,6 +105,8 @@ BEGIN_MESSAGE_MAP(CIncSourceTestDlgDlg, CDialogEx) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON_OPEN, &CIncSourceTestDlgDlg::OnBnClickedButtonOpen) + ON_BN_CLICKED(IDC_BUTTON_ELF, &CIncSourceTestDlgDlg::OnBnClickedButtonElf) + ON_BN_CLICKED(IDC_BUTTON_HEX, &CIncSourceTestDlgDlg::OnBnClickedButtonHex) END_MESSAGE_MAP() @@ -587,4 +598,135 @@ void CIncSourceTestDlgDlg::AddLogString(std::string strMessage) message_w.assign(strMessage.begin(), strMessage.end()); pListBox->AddString(message_w.c_str()); -} \ No newline at end of file +} +void CIncSourceTestDlgDlg::OnBnClickedButtonElf() +{ + // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다. + TCHAR hexExt[] = _T("*.elf"); + TCHAR hexBaseFilter[] = _T("ELF file(*.ELF) | *.elf;*.ELF | 모든파일(*.*) | *.* ||"); + CFileDialog dlg(TRUE, hexExt, NULL, OFN_HIDEREADONLY, hexBaseFilter); + + if (dlg.DoModal() == IDOK) { + + std::wstring strPath = dlg.GetPathName().GetBuffer(); + + std::string strHexPath; + + strHexPath.assign(strPath.begin(), strPath.end()); + + ELFIO::elfio reader; + if (reader.load(strHexPath.c_str())) { + // Print ELF file properties + std::cout << "ELF file class : "; + + if (reader.get_class() == ELFIO::ELFCLASS32) { + std::cout << "ELF32" << std::endl; + AddLogString(string_format("ELF file class : ELF32")); + } + else { + std::cout << "ELF64" << std::endl; + AddLogString(string_format("ELF file class : ELF64")); + } + + std::cout << "ELF file encoding : "; + if (reader.get_encoding() == ELFIO::ELFDATA2LSB) { + std::cout << "Little endian" << std::endl; + AddLogString(string_format("ELF file encoding : Little endian")); + } + else { + std::cout << "Big endian" << std::endl; + AddLogString(string_format("ELF file encoding : Big endian")); + } + + // Print ELF file sections info + ELFIO::Elf_Half sec_num = reader.sections.size(); + std::cout << "Number of sections: " << sec_num << std::endl; + AddLogString(string_format("Number of sections: %d", sec_num)); + for (int i = 0; i < sec_num; ++i) { + ELFIO::section* psec = reader.sections[i]; + std::cout << " [" << i << "] " << psec->get_name() << "\t" + << psec->get_size() << std::endl; + + AddLogString(string_format(" [%d] %s [%d]", i, psec->get_name(), psec->get_size())); + + // Access to section's data + // const char* p = reader.sections[i]->get_data() + } + + // Print ELF file segments info + ELFIO::Elf_Half seg_num = reader.segments.size(); + std::cout << "Number of segments: " << seg_num << std::endl; + AddLogString(string_format("Number of segments: %d", seg_num)); + for (int i = 0; i < seg_num; ++i) { + const ELFIO::segment* pseg = reader.segments[i]; + std::cout << " [" << i << "] 0x" << std::hex << pseg->get_flags() + << "\t0x" << pseg->get_virtual_address() << "\t0x" + << pseg->get_file_size() << "\t0x" << pseg->get_memory_size() + << std::endl; + + AddLogString(string_format(" [%d] 0x%X 0x%X [%d]", i, pseg->get_flags(), pseg->get_virtual_address(), pseg->get_memory_size())); + // Access to segments's data + // const char* p = reader.segments[i]->get_data() + } + + for (int i = 0; i < sec_num; ++i) { + ELFIO::section* psec = reader.sections[i]; + // Check section type + if (psec->get_type() == ELFIO::SHT_SYMTAB) { + const ELFIO::symbol_section_accessor symbols(reader, psec); + for (unsigned int j = 0; j < symbols.get_symbols_num(); ++j) { + std::string name; + ELFIO::Elf64_Addr value; + ELFIO::Elf_Xword size; + unsigned char bind; + unsigned char type; + ELFIO::Elf_Half section_index; + unsigned char other; + + // Read symbol properties + symbols.get_symbol(j, name, value, size, bind, type, + section_index, other); + std::cout << j << " " << name << " " << value << std::endl; + + if (type == 1) + AddLogString(string_format("[%d][%d] %s 0x%X %d type=%d bind=%d section_index=0x%X other=%d",i, j, name.c_str(), value, size, type, bind, section_index, other)); + } + } + } + + } + + } + + +} + +void CIncSourceTestDlgDlg::OnBnClickedButtonHex() +{ + // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다. + + + TCHAR hexExt[] = _T("*.hex"); + TCHAR hexBaseFilter[] = _T("HEX file(*.HEX) | *.hex;*.HEX | 모든파일(*.*) | *.* ||"); + CFileDialog dlg(TRUE, hexExt, NULL, OFN_HIDEREADONLY, hexBaseFilter); + + if (dlg.DoModal() == IDOK) { + + std::wstring strPath = dlg.GetPathName().GetBuffer(); + + std::string strHexPath; + + strHexPath.assign(strPath.begin(), strPath.end()); + + intelhex::hex_data ithex; + + ithex.load(strHexPath.c_str()); + + intelhex::hex_data::iterator iter = ithex.begin(); + + for (; iter != ithex.end(); iter++) { + (*iter).second; + } + + } +} diff --git a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.h b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.h index d7c7cd3..96e03e4 100644 --- a/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.h +++ b/TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.h @@ -61,4 +61,7 @@ public: private: void loadA2lFile(std::string strFilePath); void AddLogString(std::string strMessage); +public: + afx_msg void OnBnClickedButtonElf(); + afx_msg void OnBnClickedButtonHex(); }; diff --git a/TestLibDlg/IncSourceTestDlg/resource.h b/TestLibDlg/IncSourceTestDlg/resource.h index ee9d76a..c206487 100644 --- a/TestLibDlg/IncSourceTestDlg/resource.h +++ b/TestLibDlg/IncSourceTestDlg/resource.h @@ -8,8 +8,10 @@ #define IDS_ABOUTBOX 101 #define IDD_INCSOURCETESTDLG_DIALOG 102 #define IDR_MAINFRAME 128 +#define IDC_BUTTON_ELF 1000 #define IDC_LIST_DATA 1001 #define IDC_BUTTON_OPEN 1002 +#define IDC_BUTTON_HEX 1003 // Next default values for new objects // @@ -17,7 +19,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 130 #define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_CONTROL_VALUE 1004 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif