├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── client ├── CMakeLists.txt ├── glfw3_2018.lib ├── include │ ├── data │ │ ├── binary.h │ │ ├── hexdump_cache.h │ │ └── log_output.h │ ├── error │ │ └── not_implemented_exception.h │ ├── machine_decompiler.h │ └── ui │ │ ├── about_modal.h │ │ ├── console_window.h │ │ ├── disasm_window.h │ │ ├── element.h │ │ ├── flow_graph_window.h │ │ ├── functions_window.h │ │ ├── hexdump_window.h │ │ ├── manager.h │ │ ├── modal.h │ │ ├── open_file_modal.h │ │ ├── ribbon.h │ │ ├── strings_window.h │ │ └── window.h └── src │ ├── data │ ├── binary.cc │ ├── hexdump_cache.cc │ └── log_output.cc │ ├── machine_decompiler.cc │ ├── main.cc │ └── ui │ ├── about_modal.cc │ ├── console_window.cc │ ├── disasm_window.cc │ ├── element.cc │ ├── flow_graph_window.cc │ ├── functions_window.cc │ ├── hexdump_window.cc │ ├── manager.cc │ ├── modal.cc │ ├── open_file_modal.cc │ ├── ribbon.cc │ ├── strings_window.cc │ └── window.cc └── server └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /build* -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "client/imgui"] 2 | path = client/imgui 3 | url = https://github.com/ocornut/imgui.git -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(machine-decompiler) 3 | 4 | add_subdirectory(client) 5 | add_subdirectory(server) 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Machine Decompiler 2 | 3 | This is a work-in-progress cross-platform decompiler designed to work using 4 | machine learning, rather than algorithmically, allowing users to train the 5 | decompiler together to produce an always-updating product. 6 | 7 | ## Building from source 8 | 9 | ```bash 10 | mkdir -p build 11 | cd build 12 | cmake -DCMAKE_BUILD_TYPE=Release ../ 13 | cmake --build . 14 | ``` 15 | 16 | The client binary should be located in `build/client/md-client(.exe)`. The 17 | server binary should be located in `build/server/md-server(.exe)`. 18 | 19 | ## Running the client 20 | 21 | The default, community integration server credentials are as follows 22 | 23 | ``` 24 | community.hostname.tld 25 | ``` 26 | 27 | ## Running the server 28 | 29 | _TDB_ 30 | 31 | ## Included Works 32 | 33 | This software utilizes [dear imgui](https://github.com/ocornut/imgui), which is 34 | also licensed under the MIT license. As this is the same license this software 35 | is released under, we have not included an additional copy of the MIT license 36 | with the source. 37 | -------------------------------------------------------------------------------- /client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(client) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | 6 | # The main application sources 7 | 8 | set(SOURCES 9 | src/main.cc 10 | src/machine_decompiler.cc 11 | src/data/binary.cc 12 | src/data/log_output.cc 13 | src/data/hexdump_cache.cc 14 | src/ui/manager.cc 15 | src/ui/element.cc 16 | src/ui/window.cc 17 | src/ui/modal.cc 18 | src/ui/ribbon.cc 19 | src/ui/functions_window.cc 20 | src/ui/strings_window.cc 21 | src/ui/disasm_window.cc 22 | src/ui/hexdump_window.cc 23 | src/ui/console_window.cc 24 | src/ui/flow_graph_window.cc 25 | src/ui/open_file_modal.cc 26 | src/ui/about_modal.cc 27 | ) 28 | 29 | # Get the current branch we're building 30 | find_package(Git) 31 | if (GIT_FOUND) 32 | message("Found git ${GIT_EXECUTABLE}") 33 | endif(GIT_FOUND) 34 | message(${CMAKE_CURRENT_SOURCE_DIR}) 35 | execute_process( 36 | COMMAND "\"${GIT_EXECUTABLE}\" rev-parse --abbrev-ref HEAD -- | head -n1" 37 | RESULT_VARIABLE RESULT 38 | OUTPUT_VARIABLE MD_BRANCH 39 | ) 40 | if (RESULT EQUAL 0) 41 | message("Detected branch ${MD_BRANCH}") 42 | else() 43 | set(MD_BRANCH "UNKNOWN") 44 | message("Unable to detect git branch: ${RESULT}") 45 | message("Not in git repository, set branch to ${MD_BRANCH}") 46 | endif() 47 | add_definitions("-DBRANCH=\"${MD_BRANCH}\"") 48 | 49 | # Generic dear imgui sources required for bindings-independent GUIs 50 | 51 | add_library(imgui STATIC 52 | imgui/imgui.cpp 53 | imgui/imgui_draw.cpp 54 | imgui/imgui_widgets.cpp 55 | ) 56 | 57 | # We want to use as generic bindings as possifle for imgui so we don't have 58 | # to write any platform-specific code 59 | 60 | add_library(imgui-bindings STATIC 61 | imgui/examples/imgui_impl_glfw.cpp 62 | imgui/examples/imgui_impl_opengl3.cpp 63 | imgui/examples/libs/gl3w/GL/gl3w.c) 64 | target_include_directories(imgui-bindings PUBLIC 65 | ${CMAKE_CURRENT_SOURCE_DIR}/imgui 66 | ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples 67 | ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples/libs/glfw/include 68 | ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples/libs/gl3w 69 | ) 70 | find_library(GLFW3_LIB 71 | NAMES glfw3_2018 72 | PATHS "${CMAKE_CURRENT_SOURCE_DIR}" 73 | PATH_SUFFIXES lib 74 | NO_DEFAULT_PATH 75 | ) 76 | find_library(OPENGL_LIB 77 | NAMES Opengl32 78 | PATH_SUFFIXES lib 79 | ) 80 | target_link_libraries(imgui-bindings ${OPENGL_LIB} ${GLFW3_LIB}) 81 | 82 | add_executable(md-client ${SOURCES}) 83 | target_link_libraries(md-client 84 | imgui 85 | imgui-bindings 86 | ) 87 | 88 | target_include_directories(md-client PUBLIC 89 | ${CMAKE_CURRENT_SOURCE_DIR}/include 90 | ${CMAKE_CURRENT_SOURCE_DIR}/imgui 91 | ${CMAKE_CURRENT_SOURCE_DIR}/imgui/examples 92 | ) 93 | 94 | add_compile_options(-Wall -Wextra -Werror) -------------------------------------------------------------------------------- /client/glfw3_2018.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jha/machine-decompiler/129371bb180bd82019abd3a19557e75c18ca57b1/client/glfw3_2018.lib -------------------------------------------------------------------------------- /client/include/data/binary.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #ifdef _MSC_VER 26 | #include 27 | #endif // _MSC_VER 28 | 29 | #include "data/hexdump_cache.h" 30 | 31 | namespace machine_decompiler { 32 | namespace client { 33 | namespace data { 34 | 35 | class Binary { 36 | std::string path_; 37 | #ifdef _MSC_VER 38 | HANDLE bin_file_; 39 | HANDLE bin_file_mapping_; 40 | #endif // _MSC_VER 41 | void const* buffer_; 42 | uint64_t length_; 43 | HexdumpCache hexdump_cache_; 44 | 45 | public: 46 | explicit Binary(std::string const& path); 47 | ~Binary(); 48 | 49 | void Load() noexcept(false); 50 | 51 | std::string const& path() const { 52 | return path_; 53 | } 54 | void const* buffer() const { 55 | return buffer_; 56 | } 57 | uint64_t length() const { 58 | return length_; 59 | } 60 | HexdumpCache const& hexdump_cache() const { 61 | return hexdump_cache_; 62 | } 63 | }; 64 | 65 | } // namespace data 66 | } // namespace client 67 | } // namespace machine_decompiler 68 | -------------------------------------------------------------------------------- /client/include/data/hexdump_cache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_DATA_HEXDUMP_CACHE_H_ 24 | #define MACHINE_DECOMPILER_DATA_HEXDUMP_CACHE_H_ 25 | 26 | #include 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace data { 31 | 32 | class Binary; 33 | 34 | class HexdumpCache { 35 | Binary& binary_; 36 | char const* hex_buff_; 37 | uint64_t hex_buff_length_; 38 | 39 | public: 40 | explicit HexdumpCache(Binary& binary); 41 | ~HexdumpCache(); 42 | 43 | void Load(); 44 | 45 | Binary& binary() { 46 | return binary_; 47 | } 48 | char const* hex_buff() const { 49 | return hex_buff_; 50 | } 51 | uint64_t hex_buff_length() const { 52 | return hex_buff_length_; 53 | } 54 | }; 55 | 56 | } // namespace data 57 | } // namespace client 58 | } // namespace machine_decompiler 59 | 60 | #endif // MACHINE_DECOMPILER_DATA_HEXDUMP_CACHE_H_ 61 | -------------------------------------------------------------------------------- /client/include/data/log_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_DATA_LOG_OUTPUT_H_ 24 | #define MACHINE_DECOMPILER_DATA_LOG_OUTPUT_H_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace machine_decompiler { 33 | namespace client { 34 | namespace data { 35 | 36 | class LogOutput { 37 | std::mutex output_mutex_; 38 | std::list output_; 39 | 40 | public: 41 | LogOutput(); 42 | void Log(char const* fmt, ...); 43 | unsigned LatestHistory(std::string const* dstHistory[], unsigned maxLines); 44 | }; 45 | 46 | } // namespace data 47 | } // namespace client 48 | } // namespace machine_decompiler 49 | 50 | #endif // MACHINE_DECOMPILER_DATA_LOG_OUTPUT_H_ 51 | -------------------------------------------------------------------------------- /client/include/error/not_implemented_exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_ERROR_NOT_IMPLEMENTED_H_ 24 | #define MACHINE_DECOMPILER_ERROR_NOT_IMPLEMENTED_H_ 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | namespace machine_decompiler { 32 | namespace client { 33 | namespace error { 34 | 35 | class NotImplementedException : public std::logic_error { 36 | char const* msg_; 37 | 38 | public: 39 | explicit NotImplementedException(std::string const& member) 40 | :std::logic_error(member) { 41 | auto local = (std::string(std::logic_error::what()) 42 | + " is not yet implemented"); 43 | msg_ = new char[local.size() + 1]; 44 | strcpy(const_cast(msg_), local.c_str()); 45 | } 46 | 47 | ~NotImplementedException() { 48 | delete msg_; 49 | } 50 | 51 | char const* what() const override { 52 | return msg_; 53 | } 54 | }; 55 | 56 | } // namespace error 57 | } // namespace client 58 | } // namespace machine_decompiler 59 | 60 | #define NotImplementedException() NotImplementedException(__FUNCTION__) 61 | 62 | #endif // MACHINE_DECOMPILER_ERROR_NOT_IMPLEMENTED_H_ 63 | -------------------------------------------------------------------------------- /client/include/machine_decompiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_H_ 24 | #define MACHINE_DECOMPILER_H_ 25 | 26 | #include 27 | 28 | #include "data/log_output.h" 29 | #include "data/binary.h" 30 | #include "ui/manager.h" 31 | 32 | namespace machine_decompiler { 33 | namespace client { 34 | 35 | class MachineDecompiler { 36 | data::LogOutput log_output_; 37 | data::Binary* binary_; 38 | ui::Manager ui_manager_; 39 | 40 | public: 41 | MachineDecompiler(); 42 | void ShowWindow(); 43 | void LoadBinary(std::string& path) noexcept(false); 44 | 45 | ui::Manager& ui_manager() { 46 | return ui_manager_; 47 | } 48 | data::LogOutput& log_output() { 49 | return log_output_; 50 | } 51 | data::Binary* binary() { 52 | return binary_; 53 | } 54 | }; 55 | 56 | } // namespace client 57 | } // namespace machine_decompiler 58 | 59 | #endif // MACHINE_DECOMPILER_H_ 60 | -------------------------------------------------------------------------------- /client/include/ui/about_modal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_ABOUT_H_ 24 | #define MACHINE_DECOMPILER_UI_ABOUT_H_ 25 | 26 | #include "ui/modal.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class AboutModal : public Modal { 33 | protected: 34 | void Render() override; 35 | 36 | public: 37 | explicit AboutModal(Manager& manager); 38 | }; 39 | 40 | } // namespace ui 41 | } // namespace client 42 | } // namespace machine_decompiler 43 | 44 | #endif // MACHINE_DECOMPILER_UI_ABOUT_H_ 45 | -------------------------------------------------------------------------------- /client/include/ui/console_window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_CONSOLE_WINDOW_H_ 24 | #define MACHINE_DECOMPILER_UI_CONSOLE_WINDOW_H_ 25 | 26 | #include "ui/window.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class Manager; 33 | 34 | class ConsoleWindow : public Window { 35 | protected: 36 | void Render() override; 37 | 38 | public: 39 | explicit ConsoleWindow(Manager& manager); 40 | ~ConsoleWindow() override = default; 41 | 42 | void Show() override; 43 | }; 44 | 45 | } // namespace ui 46 | } // namespace client 47 | } // namespace machine_decompiler 48 | 49 | #endif // MACHINE_DECOMPILER_UI_CONSOLE_WINDOW_H_ 50 | -------------------------------------------------------------------------------- /client/include/ui/disasm_window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_DISASM_WINDOW_H_ 24 | #define MACHINE_DECOMPILER_UI_DISASM_WINDOW_H_ 25 | 26 | #include "ui/window.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class Manager; 33 | 34 | class DisasmWindow : public Window { 35 | protected: 36 | void Render() override; 37 | 38 | public: 39 | explicit DisasmWindow(Manager& manager); 40 | ~DisasmWindow() override = default; 41 | }; 42 | 43 | } // namespace ui 44 | } // namespace client 45 | } // namespace machine_decompiler 46 | 47 | #endif // MACHINE_DECOMPILER_UI_DISASM_WINDOW_H_ 48 | -------------------------------------------------------------------------------- /client/include/ui/element.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_ELEMENT_H_ 24 | #define MACHINE_DECOMPILER_UI_ELEMENT_H_ 25 | 26 | #include 27 | 28 | #include 29 | 30 | namespace machine_decompiler { 31 | namespace client { 32 | namespace ui { 33 | 34 | class Manager; 35 | 36 | class Element { 37 | Manager& manager_; 38 | std::string id_; 39 | ImVec2 default_size_; 40 | 41 | protected: 42 | explicit Element(Manager& manager, 43 | std::string const& title, ImVec2 const& default_size); 44 | 45 | virtual void Render() = 0; 46 | 47 | public: 48 | virtual ~Element() = default; 49 | 50 | virtual void Show() = 0; 51 | 52 | Manager& manager() { 53 | return manager_; 54 | } 55 | std::string const& id() const { 56 | return id_; 57 | } 58 | ImVec2 const& default_size() const { 59 | return default_size_; 60 | } 61 | }; 62 | 63 | } // namespace ui 64 | } // namespace client 65 | } // namespace machine_decompiler 66 | 67 | #endif // MACHINE_DECOMPILER_UI_ELEMENT_H_ 68 | -------------------------------------------------------------------------------- /client/include/ui/flow_graph_window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_FLOW_GRAPH_WINDOW_H_ 24 | #define MACHINE_DECOMPILER_UI_FLOW_GRAPH_WINDOW_H_ 25 | 26 | #include "ui/window.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class FlowGraphWindow : public Window { 33 | protected: 34 | void Render() override; 35 | 36 | public: 37 | FlowGraphWindow(Manager& manager); 38 | }; 39 | 40 | } // namespace ui 41 | } // namespace client 42 | } // namespace machine_decompiler 43 | 44 | #endif // MACHINE_DECOMPILER_UI_FLOW_GRAPH_WINDOW_H_ 45 | -------------------------------------------------------------------------------- /client/include/ui/functions_window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_FUNCTIONS_WINDOW_H_ 24 | #define MACHINE_DECOMPILER_UI_FUNCTIONS_WINDOW_H_ 25 | 26 | #include "ui/window.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class FunctionsWindow : public Window { 33 | protected: 34 | void Render() override; 35 | 36 | public: 37 | FunctionsWindow(Manager& manager); 38 | ~FunctionsWindow() override = default; 39 | }; 40 | 41 | } // namespace ui 42 | } // namespace client 43 | } // namespace machine_decompiler 44 | 45 | #endif // MACHINE_DECOMPILER_UI_FUNCTIONS_WINDOW_H_ 46 | -------------------------------------------------------------------------------- /client/include/ui/hexdump_window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_HEXDUMP_WINDOW_H_ 24 | #define MACHINE_DECOMPILER_UI_HEXDUMP_WINDOW_H_ 25 | 26 | #include "ui/window.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class Manager; 33 | 34 | class HexdumpWindow : public Window { 35 | protected: 36 | void Render() override; 37 | 38 | public: 39 | explicit HexdumpWindow(Manager& manager); 40 | ~HexdumpWindow() override = default; 41 | 42 | void Show() override; 43 | }; 44 | 45 | } // namespace ui 46 | } // namespace client 47 | } // namespace machine_decompiler 48 | 49 | #endif // MACHINE_DECOMPILER_UI_HEXDUMP_WINDOW_H_ 50 | -------------------------------------------------------------------------------- /client/include/ui/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_MANAGER_H_ 24 | #define MACHINE_DECOMPILER_UI_MANAGER_H_ 25 | 26 | #include 27 | 28 | #include "ui/element.h" 29 | 30 | namespace machine_decompiler { 31 | namespace client { 32 | 33 | class MachineDecompiler; 34 | 35 | namespace ui { 36 | 37 | class Manager { 38 | MachineDecompiler& decompiler_; 39 | std::vector elements_; 40 | std::vector add_queue_; 41 | 42 | public: 43 | explicit Manager(MachineDecompiler& decompiler); 44 | 45 | void Add(Element* elem); 46 | bool Remove(Element* elem); 47 | void Show(); 48 | 49 | MachineDecompiler& decompiler() { 50 | return decompiler_; 51 | } 52 | }; 53 | 54 | } // namespace ui 55 | } // namespace client 56 | } // namespace machine_decompiler 57 | 58 | #endif // MACHINE_DECOMPILER_UI_MANAGER_H_ 59 | -------------------------------------------------------------------------------- /client/include/ui/modal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_MODAL_H_ 24 | #define MACHINE_DECOMPILER_UI_MODAL_H_ 25 | 26 | #include 27 | 28 | #include "ui/element.h" 29 | 30 | namespace machine_decompiler { 31 | namespace client { 32 | namespace ui { 33 | 34 | namespace { 35 | ImVec2 const defModalSize(0, 0); 36 | } // namespace 37 | 38 | class Modal : public Element { 39 | bool open_; 40 | 41 | public: 42 | explicit Modal(Manager& manager, 43 | std::string const& title, ImVec2 const& default_size = defModalSize); 44 | 45 | void Show() override; 46 | 47 | bool open() const { 48 | return open_; 49 | } 50 | }; 51 | 52 | } // namespace ui 53 | } // namespace client 54 | } // namespace machine_decompiler 55 | 56 | #endif // MACHINE_DECOMPILER_UI_MODAL_H_ 57 | -------------------------------------------------------------------------------- /client/include/ui/open_file_modal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_OPEN_FILE_H_ 24 | #define MACHINE_DECOMPILER_UI_OPEN_FILE_H_ 25 | 26 | #include "ui/modal.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class OpenFileModal : public Modal { 33 | char text_buff_[1024]; 34 | 35 | protected: 36 | void Render() override; 37 | 38 | public: 39 | explicit OpenFileModal(Manager& manager); 40 | }; 41 | 42 | } // namespace ui 43 | } // namespace client 44 | } // namespace machine_decompiler 45 | 46 | #endif // MACHINE_DECOMPILER_UI_OPEN_FILE_H_ 47 | -------------------------------------------------------------------------------- /client/include/ui/ribbon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_RIBBON_H_ 24 | #define MACHINE_DECOMPILER_UI_RIBBON_H_ 25 | 26 | #include "ui/element.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class Ribbon : public Element { 33 | protected: 34 | ~Ribbon() override = default; 35 | 36 | void Render() override; 37 | 38 | public: 39 | explicit Ribbon(Manager& manager); 40 | 41 | void Show() override; 42 | }; 43 | 44 | } // namespace ui 45 | } // namespace client 46 | } // namespace machine_decompiler 47 | 48 | #endif // MACHINE_DECOMPILER_UI_RIBBON_H_ 49 | -------------------------------------------------------------------------------- /client/include/ui/strings_window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_STRINGS_WINDOW_H_ 24 | #define MACHINE_DECOMPILER_UI_STRINGS_WINDOW_H_ 25 | 26 | #include "ui/window.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | class Manager; 33 | 34 | class StringsWindow : public Window { 35 | protected: 36 | void Render() override; 37 | 38 | public: 39 | explicit StringsWindow(Manager& manager); 40 | ~StringsWindow() override = default; 41 | }; 42 | 43 | } // namespace ui 44 | } // namespace client 45 | } // namespace machine_decompiler 46 | 47 | #endif // MACHINE_DECOMPILER_UI_STRINGS_WINDOW_H_ 48 | -------------------------------------------------------------------------------- /client/include/ui/window.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef MACHINE_DECOMPILER_UI_WINDOW_H_ 24 | #define MACHINE_DECOMPILER_UI_WINDOW_H_ 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include "ui/element.h" 31 | 32 | namespace machine_decompiler { 33 | namespace client { 34 | namespace ui { 35 | 36 | namespace { 37 | 38 | ImVec2 const newWindowDefaultSize(128, 256); 39 | 40 | } // namespace 41 | 42 | class Manager; 43 | 44 | class Window : public Element { 45 | bool open_; 46 | bool new_window_; 47 | 48 | protected: 49 | explicit Window(Manager& manager, 50 | std::string const& title, ImVec2 const& defSize = newWindowDefaultSize); 51 | 52 | public: 53 | void Show() override; 54 | 55 | bool open() const { 56 | return open_; 57 | } 58 | 59 | private: 60 | bool new_window() { 61 | if (new_window_) { 62 | new_window_ = false; 63 | return true; 64 | } 65 | return false; 66 | } 67 | }; 68 | 69 | } // namespace ui 70 | } // namespace client 71 | } // namespace machine_decompiler 72 | 73 | #endif // MACHINE_DECOMPILER_UI_WINDOW_H_ 74 | -------------------------------------------------------------------------------- /client/src/data/binary.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #ifdef _MSC_VER 26 | 27 | #endif // _MSC_VER 28 | #ifdef __unix__ 29 | #include 30 | #include 31 | #include 32 | #endif // __unix__ 33 | 34 | #include "data/binary.h" 35 | #include "error/not_implemented_exception.h" 36 | 37 | namespace machine_decompiler { 38 | namespace client { 39 | namespace data { 40 | 41 | Binary::Binary(std::string const& path) 42 | : path_(path), 43 | #ifdef _MSC_VER 44 | bin_file_(nullptr), 45 | bin_file_mapping_(nullptr), 46 | #endif // _MSC_VER 47 | buffer_(nullptr), 48 | length_(0ll), 49 | hexdump_cache_(*this) { 50 | } 51 | 52 | #ifdef _MSC_VER 53 | Binary::~Binary() { 54 | if (bin_file_mapping_ != nullptr) 55 | CloseHandle(bin_file_); 56 | if (bin_file_ != nullptr) 57 | CloseHandle(bin_file_); 58 | } 59 | #endif // _MSC_VER 60 | 61 | #ifdef __unix__ 62 | Binary::~Binary() = default; 63 | #endif // __unix__ 64 | 65 | #ifdef _MSC_VER 66 | void Binary::Load() { 67 | // Open a Windows HANDLE to an existing file 68 | bin_file_ = CreateFileA( 69 | path_.c_str(), 70 | GENERIC_READ | GENERIC_WRITE, 71 | 0, 72 | nullptr, // TODO: Can't be inherited by child processes! 73 | OPEN_EXISTING, 74 | FILE_ATTRIBUTE_NORMAL, 75 | nullptr); 76 | if (bin_file_ == nullptr) 77 | throw std::exception(("Unable to open file " + path()).c_str()); 78 | 79 | LARGE_INTEGER fileSize; 80 | if (!GetFileSizeEx(bin_file_, &fileSize)) 81 | throw std::exception(("Unable to get file size for " + path()).c_str()); 82 | 83 | bin_file_mapping_ = CreateFileMappingA( 84 | bin_file_, 85 | nullptr, 86 | PAGE_READWRITE, 87 | 0, 0, 88 | nullptr); 89 | if (bin_file_mapping_ == nullptr) { 90 | throw std::exception( 91 | ("Unable to map file " + path() + " into memory").c_str()); 92 | } 93 | 94 | auto const* mem = MapViewOfFile( 95 | bin_file_mapping_, 96 | FILE_MAP_ALL_ACCESS, 97 | 0, 0, 98 | 0); 99 | if (mem == nullptr) 100 | throw std::exception(("Unable to map view of file " + path()).c_str()); 101 | 102 | buffer_ = mem; 103 | length_ = static_cast(fileSize.QuadPart); 104 | 105 | hexdump_cache_.Load(); 106 | } 107 | #endif // _MSC_VER 108 | 109 | #ifdef __unix__ 110 | void Binary::Load() { 111 | // Try to open the file 112 | auto fd = open(path.c_str(), O_RDWR); 113 | if (fd == -1) 114 | throw std::exception("Unable to open file " + path); 115 | 116 | // Get the size of the file 117 | 118 | // Map the file into memory 119 | auto const* bin_disk = mmap(nullptr, 0ll, PROT_READ, MAP_PRIVATE, fd, 0); 120 | if (bin_disk == MAP_FAILED) { 121 | close(fd); 122 | throw std::exception("Unable to map " + path + " into memory"); 123 | } 124 | hexdump_cache_.Load(); 125 | } 126 | #endif // __unix__ 127 | 128 | } // namespace data 129 | } // namespace client 130 | } // namespace machine_decompiler 131 | -------------------------------------------------------------------------------- /client/src/data/hexdump_cache.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "data/hexdump_cache.h" 27 | #include "data/binary.h" 28 | 29 | namespace machine_decompiler { 30 | namespace client { 31 | namespace data { 32 | 33 | namespace { 34 | unsigned const kMaxLineLen = ((16 * 3) + 2 + (16 * 2) + 1); 35 | } // namespace 36 | 37 | HexdumpCache::HexdumpCache(Binary& binary) 38 | : binary_(binary), 39 | hex_buff_(nullptr) { 40 | } 41 | 42 | HexdumpCache::~HexdumpCache() { 43 | delete hex_buff_; 44 | } 45 | 46 | void HexdumpCache::Load() { 47 | delete hex_buff_; 48 | auto* buff = new char[((binary().length() / 16) + 1) * kMaxLineLen]; 49 | auto const* p = reinterpret_cast(binary().buffer()); 50 | hex_buff_ = buff; 51 | uint64_t i; 52 | 53 | // Process 16 bytes at a time 54 | auto aligned_len = binary().length() - (binary().length() % 16); 55 | for (i = 0ll; i < aligned_len; i += 16, p += 16) { 56 | buff += sprintf(buff, 57 | "%02X %02X %02X %02X %02X %02X %02X %02X " 58 | "%02X %02X %02X %02X %02X %02X %02X %02X " 59 | "%c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n", 60 | p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], 61 | p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15], 62 | p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], 63 | p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); 64 | } 65 | 66 | // Process 1 byte at a time. This algorithm is borrowed from Stack Overflow 67 | char leftover[17]; 68 | for (i = aligned_len; i < binary().length(); ++i, ++p) { 69 | if ((i % 16) == 0) { 70 | if (i != 0) 71 | buff += sprintf(buff, " %s\n", leftover); 72 | } 73 | 74 | buff += sprintf(buff, " %02X", *p); 75 | 76 | if (*p < 0x20 || (*p > 0x7e)) 77 | leftover[i % 16] = '.'; 78 | else 79 | leftover[i % 16] = *p; 80 | leftover[(i % 16) + 1] = '\0'; 81 | } 82 | 83 | while ((i % 16) != 0) { 84 | buff += sprintf(buff, " "); 85 | ++i; 86 | } 87 | 88 | // Print out final ASCII bit 89 | sprintf(buff, " %s\n", leftover); 90 | 91 | hex_buff_length_ = static_cast(buff - hex_buff_); 92 | } 93 | 94 | } // namespace data 95 | } // namespace client 96 | } // namespace machine_decompiler 97 | -------------------------------------------------------------------------------- /client/src/data/log_output.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "data/log_output.h" 26 | 27 | namespace machine_decompiler { 28 | namespace client { 29 | namespace data { 30 | 31 | LogOutput::LogOutput() 32 | : output_mutex_(), 33 | output_() { 34 | } 35 | 36 | void LogOutput::Log(char const* fmt, ...) { 37 | char buff[1024 * 16]; 38 | va_list args; 39 | va_start(args, fmt); 40 | vsnprintf(buff, sizeof (buff) - 1, fmt, args); 41 | va_end(args); 42 | std::lock_guard lock(output_mutex_); 43 | output_.push_front(std::string(buff)); 44 | } 45 | 46 | unsigned LogOutput::LatestHistory( 47 | std::string const* dstHistory[], unsigned maxlen) { 48 | if (maxlen == 0) 49 | return 0; 50 | 51 | auto start_idx = maxlen, written = 0u; 52 | if (maxlen > output_.size()) 53 | start_idx = output_.size(); 54 | 55 | for (auto& line : output_) { 56 | dstHistory[--start_idx] = &line; 57 | written++; 58 | if (start_idx == 0) 59 | break; 60 | } 61 | 62 | return written; 63 | } 64 | 65 | } // namespace data 66 | } // namespace client 67 | } // namespace machine_decompiler 68 | -------------------------------------------------------------------------------- /client/src/machine_decompiler.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include "machine_decompiler.h" 31 | 32 | namespace machine_decompiler { 33 | namespace client { 34 | 35 | namespace { 36 | 37 | void glfw_error_callback(int error, char const* description) { 38 | fprintf(stderr, "Glfw Error %d: %s\n", error, description); 39 | } 40 | 41 | ImVec4 const clearColor = ImVec4(.2f, .2f, .2f, 1.f); 42 | 43 | } // namespace 44 | 45 | MachineDecompiler::MachineDecompiler() 46 | : log_output_(), 47 | binary_(nullptr), 48 | ui_manager_(*this) { 49 | } 50 | 51 | void MachineDecompiler::ShowWindow() { 52 | glfwSetErrorCallback(glfw_error_callback); 53 | if (!glfwInit()) { 54 | fprintf(stderr, "glfwInit()\n"); 55 | return; 56 | } 57 | 58 | #if __APPLE__ 59 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); 60 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); 61 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 62 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); 63 | auto const* glsl_version = "#version 150"; 64 | #else // __APPLE__ 65 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); 66 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); 67 | auto const* glsl_version = "#version 130"; 68 | #endif // __APPLE__ 69 | 70 | auto* window = glfwCreateWindow(640, 480, "Machine Decompiler", 71 | nullptr, nullptr); 72 | glfwMakeContextCurrent(window); 73 | glfwSwapInterval(1); 74 | 75 | if (gl3wInit() != 0) { 76 | fprintf(stderr, "gl3wInit()\n"); 77 | return; 78 | } 79 | 80 | IMGUI_CHECKVERSION(); 81 | ImGui::CreateContext(); 82 | auto& io = ImGui::GetIO(); 83 | io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; 84 | 85 | ImGui::StyleColorsDark(); 86 | auto& style = ImGui::GetStyle(); 87 | style.WindowRounding = 4.f; 88 | style.DisplayWindowPadding = ImVec2(0, 0); 89 | 90 | ImGui_ImplGlfw_InitForOpenGL(window, true); 91 | ImGui_ImplOpenGL3_Init(glsl_version); 92 | 93 | log_output().Log("Welcome to Machine Decompiler!"); 94 | 95 | while (!glfwWindowShouldClose(window)) { 96 | glfwPollEvents(); 97 | 98 | ImGui_ImplOpenGL3_NewFrame(); 99 | ImGui_ImplGlfw_NewFrame(); 100 | ImGui::NewFrame(); 101 | 102 | ui_manager().Show(); 103 | 104 | ImGui::Render(); 105 | glfwMakeContextCurrent(window); 106 | int dw, dh; 107 | glfwGetFramebufferSize(window, &dw, &dh); 108 | glViewport(0, 0, dw, dh); 109 | glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w); 110 | glClear(GL_COLOR_BUFFER_BIT); 111 | ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); 112 | 113 | glfwMakeContextCurrent(window); 114 | glfwSwapBuffers(window); 115 | } 116 | } 117 | 118 | void MachineDecompiler::LoadBinary(std::string& path) { 119 | if (binary() != nullptr) 120 | delete binary(); 121 | try { 122 | binary_ = new data::Binary(path); 123 | binary()->Load(); 124 | log_output().Log("Finished loading %s.", path.c_str()); 125 | } catch (std::exception const& ex) { 126 | log_output().Log("Error loading %s: %s.", path.c_str(), ex.what()); 127 | } 128 | } 129 | 130 | } // namespace client 131 | } // namespace machine_decompiler -------------------------------------------------------------------------------- /client/src/main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include "machine_decompiler.h" 24 | 25 | int main(int argc, char const** args) { 26 | using namespace machine_decompiler::client; 27 | MachineDecompiler decompiler; 28 | decompiler.ShowWindow(); 29 | 30 | if (argc > 1) { 31 | try { 32 | std::string path(args[1]); 33 | decompiler.LoadBinary(path); 34 | } catch (const std::exception&) { 35 | } 36 | // Try to load the file path in args[1] 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /client/src/ui/about_modal.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include "ui/about_modal.h" 24 | #include "ui/manager.h" 25 | 26 | namespace machine_decompiler { 27 | namespace client { 28 | namespace ui { 29 | 30 | namespace { 31 | char const* aboutMessages[] = { 32 | "Machine Decompiler", 33 | "MD " BRANCH, 34 | "", 35 | "Copyright (C) 2018 - 2019", 36 | "github.com/jha", 37 | "", 38 | "Your feedback and contributions are appreciated!", 39 | "Please visit github.com/jha/machine-decompiler", 40 | }; 41 | } // namespace 42 | 43 | AboutModal::AboutModal(Manager& manager) 44 | : Modal(manager, "About Machine Decompiler") { 45 | } 46 | 47 | void AboutModal::Render() { 48 | for (auto const& line : aboutMessages) { 49 | ImGui::Text(line); 50 | } 51 | } 52 | 53 | } // namespace ui 54 | } // namespace client 55 | } // namespace machine_decompiler 56 | -------------------------------------------------------------------------------- /client/src/ui/console_window.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/console_window.h" 26 | #include "ui/manager.h" 27 | #include "machine_decompiler.h" 28 | 29 | namespace machine_decompiler { 30 | namespace client { 31 | namespace ui { 32 | 33 | namespace { 34 | 35 | ImVec2 const defWinSize(512, 128); 36 | unsigned const maxHistory = 1000; 37 | 38 | } // namespace 39 | 40 | ConsoleWindow::ConsoleWindow(Manager &manager) 41 | : Window(manager, "Console", defWinSize) { 42 | } 43 | 44 | void ConsoleWindow::Render() { 45 | static std::string const* history[maxHistory]; 46 | auto len = manager().decompiler().log_output().LatestHistory( 47 | history, maxHistory); 48 | static char strbuff[maxHistory * 1024]; 49 | 50 | char* curr = strbuff; 51 | for (auto i = 0u; i < len; ++i) 52 | curr += sprintf(curr, "%s\n", history[i]->c_str()); 53 | 54 | ImVec2 size(ImGui::GetWindowContentRegionWidth(), 55 | ImGui::GetWindowHeight() - 20); 56 | ImGui::InputTextMultiline("", strbuff, sizeof (strbuff), 57 | size, ImGuiInputTextFlags_ReadOnly); 58 | } 59 | 60 | void ConsoleWindow::Show() { 61 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.f, 0.f)); 62 | auto const& winbg = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; 63 | ImGui::PushStyleColor(ImGuiCol_FrameBg, winbg); 64 | Window::Show(); 65 | ImGui::PopStyleColor(1); 66 | ImGui::PopStyleVar(1); 67 | } 68 | 69 | } // namespace ui 70 | } // namespace client 71 | } // namespace machine_decompiler 72 | -------------------------------------------------------------------------------- /client/src/ui/disasm_window.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/disasm_window.h" 26 | #include "ui/manager.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | namespace { 33 | 34 | ImVec2 const defWinSize(384, 512); 35 | 36 | } // namespace 37 | 38 | DisasmWindow::DisasmWindow(Manager &manager) 39 | : Window(manager, "Disassembly", defWinSize) { 40 | } 41 | 42 | void DisasmWindow::Render() { 43 | 44 | } 45 | 46 | } // namespace ui 47 | } // namespace client 48 | } // namespace machine_decompiler 49 | -------------------------------------------------------------------------------- /client/src/ui/element.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/element.h" 26 | 27 | namespace machine_decompiler { 28 | namespace client { 29 | namespace ui { 30 | 31 | namespace { 32 | 33 | std::string fmtptr(void const* ptr) { 34 | char buff[64] = {0}; 35 | sprintf(buff, "%04X", reinterpret_cast(ptr)); 36 | return std::string(buff); 37 | } 38 | 39 | } // namespace 40 | 41 | Element::Element(Manager &manager, 42 | std::string const &title, ImVec2 const &default_size) 43 | : manager_(manager), 44 | id_(title + "##" + fmtptr(this)), 45 | default_size_(default_size) { 46 | } 47 | 48 | } // namespace ui 49 | } // namespace client 50 | } // namespace machine_decompiler 51 | -------------------------------------------------------------------------------- /client/src/ui/flow_graph_window.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/flow_graph_window.h" 26 | 27 | namespace machine_decompiler { 28 | namespace client { 29 | namespace ui { 30 | 31 | namespace { 32 | ImVec2 const defWinSize(384, 384); 33 | } // namespace 34 | 35 | FlowGraphWindow::FlowGraphWindow(Manager& manager) 36 | : Window(manager, "Flow Graph", defWinSize) { 37 | } 38 | 39 | void FlowGraphWindow::Render() { 40 | ImGui::BeginChild((id() + "_flow_graph").c_str()); 41 | ImGui::Text("flow graph window"); 42 | ImGui::EndChild(); 43 | } 44 | 45 | } // namespace ui 46 | } // namespace client 47 | } // namespace machine_decompiler 48 | -------------------------------------------------------------------------------- /client/src/ui/functions_window.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/functions_window.h" 26 | 27 | namespace machine_decompiler { 28 | namespace client { 29 | namespace ui { 30 | 31 | FunctionsWindow::FunctionsWindow(Manager& manager) 32 | : Window(manager, "Functions") { 33 | } 34 | 35 | void FunctionsWindow::Render() { 36 | ImGui::BeginChild((id() + "_fn_list").c_str()); 37 | for (auto i = 0u; i < 100; ++i) { 38 | ImGui::Text("sub_%02X", i + 0x1000); 39 | } 40 | ImGui::EndChild(); 41 | } 42 | 43 | } // namespace ui 44 | } // namespace client 45 | } // namespace machine_decompiler 46 | -------------------------------------------------------------------------------- /client/src/ui/hexdump_window.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/hexdump_window.h" 26 | #include "ui/manager.h" 27 | #include "machine_decompiler.h" 28 | 29 | namespace machine_decompiler { 30 | namespace client { 31 | namespace ui { 32 | 33 | namespace { 34 | 35 | ImVec2 const defWinSize(256, 384); 36 | 37 | } // namespace 38 | 39 | HexdumpWindow::HexdumpWindow(Manager &manager) 40 | : Window(manager, "Hexdump", defWinSize) { 41 | } 42 | 43 | void HexdumpWindow::Render() { 44 | auto& hdc = manager().decompiler().binary()->hexdump_cache(); 45 | 46 | ImVec2 size(ImGui::GetWindowContentRegionWidth(), 47 | ImGui::GetWindowHeight() - 20); 48 | ImGui::InputTextMultiline("", const_cast(hdc.hex_buff()), 49 | hdc.hex_buff_length(), size, ImGuiInputTextFlags_ReadOnly); 50 | } 51 | 52 | void HexdumpWindow::Show() { 53 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.f, 0.f)); 54 | auto const& winbg = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; 55 | ImGui::PushStyleColor(ImGuiCol_FrameBg, winbg); 56 | Window::Show(); 57 | ImGui::PopStyleColor(1); 58 | ImGui::PopStyleVar(1); 59 | } 60 | 61 | } // namespace ui 62 | } // namespace client 63 | } // namespace machine_decompiler 64 | -------------------------------------------------------------------------------- /client/src/ui/manager.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include "ui/ribbon.h" 24 | #include "ui/manager.h" 25 | 26 | namespace machine_decompiler { 27 | namespace client { 28 | namespace ui { 29 | 30 | Manager::Manager(MachineDecompiler& decompiler) 31 | : decompiler_(decompiler), 32 | elements_(), 33 | add_queue_() { 34 | elements_.push_back(new Ribbon(*this)); 35 | } 36 | 37 | void Manager::Add(Element* elem) { 38 | add_queue_.push_back(elem); 39 | } 40 | 41 | bool Manager::Remove(Element* elem) { 42 | auto it = std::find(elements_.begin(), elements_.end(), elem); 43 | if (it != elements_.end()) { 44 | delete (*it); 45 | elements_.erase(it); 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | void Manager::Show() { 52 | for (auto* it : elements_) { 53 | it->Show(); 54 | } 55 | for (auto* it : add_queue_) { 56 | elements_.push_back(it); 57 | } 58 | add_queue_.clear(); 59 | } 60 | 61 | } // namespace ui 62 | } // namespace client 63 | } // namespace machine_decompiler 64 | -------------------------------------------------------------------------------- /client/src/ui/modal.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include "ui/modal.h" 24 | #include "ui/manager.h" 25 | 26 | namespace machine_decompiler { 27 | namespace client { 28 | namespace ui { 29 | 30 | Modal::Modal(Manager &manager, 31 | std::string const& title, ImVec2 const& default_size) 32 | : open_(true), 33 | Element(manager, title, default_size) { 34 | } 35 | 36 | void Modal::Show() { 37 | ImGui::OpenPopup(id().c_str()); 38 | if (ImGui::BeginPopupModal(id().c_str(), &open_)) { 39 | Render(); 40 | ImGui::EndPopup(); 41 | } 42 | if (!open()) 43 | manager().Remove(this); 44 | } 45 | 46 | } // namespace ui 47 | } // namespace client 48 | } // namespace machine_decompiler 49 | -------------------------------------------------------------------------------- /client/src/ui/open_file_modal.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/open_file_modal.h" 26 | #include "ui/manager.h" 27 | #include "machine_decompiler.h" 28 | 29 | namespace machine_decompiler { 30 | namespace client { 31 | namespace ui { 32 | 33 | OpenFileModal::OpenFileModal(Manager &manager) 34 | : Modal(manager, "Open File") { 35 | memset(text_buff_, 0, sizeof (text_buff_)); 36 | } 37 | 38 | void OpenFileModal::Render() { 39 | ImGui::Text("Paste file path to load. Supports HTTP/S"); 40 | ImGui::PushItemWidth(-0.1f); 41 | ImGui::InputText("", text_buff_, sizeof (text_buff_)); 42 | ImGui::PopItemWidth(); 43 | if (ImGui::Button("Load")) { 44 | std::string path(text_buff_); 45 | manager().decompiler().LoadBinary(path); 46 | manager().Remove(this); 47 | } 48 | } 49 | 50 | } // namespace ui 51 | } // namespace client 52 | } // namespace machine_decompiler 53 | -------------------------------------------------------------------------------- /client/src/ui/ribbon.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/ribbon.h" 26 | #include "ui/manager.h" 27 | #include "ui/functions_window.h" 28 | #include "ui/strings_window.h" 29 | #include "ui/disasm_window.h" 30 | #include "ui/hexdump_window.h" 31 | #include "ui/console_window.h" 32 | #include "ui/open_file_modal.h" 33 | #include "ui/about_modal.h" 34 | 35 | namespace machine_decompiler { 36 | namespace client { 37 | namespace ui { 38 | 39 | Ribbon::Ribbon(Manager& manager) 40 | : Element(manager, "", ImVec2(0, 0)) { 41 | } 42 | 43 | void Ribbon::Render() { 44 | // File 45 | if (ImGui::BeginMenu("File")) { 46 | if (ImGui::MenuItem("Open", "Ctrl+O")) { 47 | manager().Add(new OpenFileModal(manager())); 48 | } 49 | if (ImGui::MenuItem("Save", "Ctrl+S")) { 50 | 51 | } 52 | ImGui::EndMenu(); 53 | } 54 | 55 | // View 56 | if (ImGui::BeginMenu("View")) { 57 | if (ImGui::MenuItem("Functions", "Ctrl+N")) { 58 | manager().Add(new FunctionsWindow(manager())); 59 | } 60 | if (ImGui::MenuItem("Strings", "Ctrl+T")) { 61 | manager().Add(new StringsWindow(manager())); 62 | } 63 | if (ImGui::MenuItem("Disassembly", "Ctrl+D")) { 64 | manager().Add(new DisasmWindow(manager())); 65 | } 66 | if (ImGui::MenuItem("Hexdump", "Ctrl+H")) { 67 | manager().Add(new HexdumpWindow(manager())); 68 | } 69 | if (ImGui::MenuItem("Console", "Ctrl+K")) { 70 | manager().Add(new ConsoleWindow(manager())); 71 | } 72 | ImGui::EndMenu(); 73 | } 74 | 75 | // Settings 76 | if (ImGui::BeginMenu("Settings")) { 77 | if (ImGui::MenuItem("Fonts")) { 78 | 79 | } 80 | if (ImGui::MenuItem("Proxy")) { 81 | 82 | } 83 | ImGui::EndMenu(); 84 | } 85 | 86 | // Help 87 | if (ImGui::BeginMenu("Help")) { 88 | if (ImGui::MenuItem("About")) { 89 | manager().Add(new AboutModal(manager())); 90 | } 91 | ImGui::EndMenu(); 92 | } 93 | } 94 | 95 | void Ribbon::Show() { 96 | if (ImGui::BeginMainMenuBar()) { 97 | Render(); 98 | ImGui::EndMainMenuBar(); 99 | } 100 | } 101 | 102 | } // namespace ui 103 | } // namespace client 104 | } // namespace machine_decompiler 105 | -------------------------------------------------------------------------------- /client/src/ui/strings_window.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include "ui/strings_window.h" 26 | #include "ui/manager.h" 27 | 28 | namespace machine_decompiler { 29 | namespace client { 30 | namespace ui { 31 | 32 | namespace { 33 | 34 | ImVec2 const defWinSize(256, 384); 35 | 36 | } // namespace 37 | 38 | StringsWindow::StringsWindow(Manager &manager) 39 | : Window(manager, "Strings", defWinSize) { 40 | } 41 | 42 | void StringsWindow::Render() { 43 | 44 | } 45 | 46 | } // namespace ui 47 | } // namespace client 48 | } // namespace machine_decompiler 49 | -------------------------------------------------------------------------------- /client/src/ui/window.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 github.com/jha 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | * IN THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "ui/window.h" 28 | #include "ui/manager.h" 29 | 30 | namespace machine_decompiler { 31 | namespace client { 32 | namespace ui { 33 | 34 | namespace { 35 | 36 | ImVec2 const winMinSize(128, 64); 37 | ImVec2 const winMaxSize(10000, 10000); 38 | 39 | } // namespace 40 | 41 | Window::Window(Manager& manager, 42 | std::string const& title, ImVec2 const& defSize) 43 | : open_(true), 44 | new_window_(true), 45 | Element(manager, title, defSize) { 46 | } 47 | 48 | void Window::Show() { 49 | if (open()) { 50 | ImGui::SetNextWindowSizeConstraints(winMinSize, winMaxSize); 51 | if (new_window()) 52 | ImGui::SetNextWindowSize(default_size()); 53 | if (ImGui::Begin(id().c_str(), &open_)) 54 | Render(); 55 | ImGui::End(); 56 | } else { 57 | manager().Remove(this); 58 | } 59 | } 60 | 61 | } // namespace ui 62 | } // namespace client 63 | } // namespace machine_decompiler 64 | -------------------------------------------------------------------------------- /server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | project(server) --------------------------------------------------------------------------------