mirror of https://github.com/x64dbg/zydis
added CMakeLists.txt for cross-platform builds
minor code changes to be standard-conform
This commit is contained in:
parent
319fe310e6
commit
8cfc7e90e3
|
@ -0,0 +1,64 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
|
project(VerteronDisassemblerEngine)
|
||||||
|
|
||||||
|
option(BUILD_EXAMPLES "Build examples" TRUE)
|
||||||
|
|
||||||
|
if (NOT CONFIGURED_ONCE)
|
||||||
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
|
||||||
|
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
set(compiler_specific "-std=c++0x -Werror")
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
set(compiler_specific "/WX /D_CRT_SECURE_NO_WARNINGS")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${compiler_specific}"
|
||||||
|
CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${compiler_specific}"
|
||||||
|
CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Library
|
||||||
|
set(vde_headers
|
||||||
|
"VerteronDisassemblerEngine/VXDisassembler.h"
|
||||||
|
"VerteronDisassemblerEngine/VXDisassemblerTypes.h"
|
||||||
|
"VerteronDisassemblerEngine/VXDisassemblerUtils.h"
|
||||||
|
"VerteronDisassemblerEngine/VXInstructionDecoder.h"
|
||||||
|
"VerteronDisassemblerEngine/VXInstructionFormatter.h"
|
||||||
|
"VerteronDisassemblerEngine/VXOpcodeTable.h")
|
||||||
|
set(vde_sources
|
||||||
|
"VerteronDisassemblerEngine/VXDisassemblerUtils.cpp"
|
||||||
|
"VerteronDisassemblerEngine/VXInstructionFormatter.cpp"
|
||||||
|
"VerteronDisassemblerEngine/VXOpcodeTable.cpp"
|
||||||
|
"VerteronDisassemblerEngine/VXInstructionDecoder.cpp")
|
||||||
|
|
||||||
|
add_library("VerteronDisassemblerEngine"
|
||||||
|
${vde_headers}
|
||||||
|
${vde_sources})
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
if (BUILD_EXAMPLES)
|
||||||
|
include_directories("VerteronDisassemblerEngine")
|
||||||
|
|
||||||
|
add_executable("CustomDataSource"
|
||||||
|
"Examples/CustomDataSource/Main.cpp")
|
||||||
|
target_link_libraries("CustomDataSource" "VerteronDisassemblerEngine")
|
||||||
|
|
||||||
|
add_executable("PerformanceTest"
|
||||||
|
"Examples/PerformanceTest/Main.cpp")
|
||||||
|
target_link_libraries("PerformanceTest" "VerteronDisassemblerEngine")
|
||||||
|
|
||||||
|
add_executable("SimpleDemo"
|
||||||
|
"Examples/SimpleDemo/Main.cpp")
|
||||||
|
target_link_libraries("SimpleDemo" "VerteronDisassemblerEngine")
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
add_executable("SymbolResolver"
|
||||||
|
"Examples/SymbolResolver/Main.cpp")
|
||||||
|
target_link_libraries("SymbolResolver" "VerteronDisassemblerEngine")
|
||||||
|
else ()
|
||||||
|
message(STATUS "Example 'SymbolResolver' not compatible with platform, ignoring.")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(CONFIGURED_ONCE TRUE CACHE INTERNAL "CMake has configured at least once.")
|
|
@ -29,9 +29,8 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
|
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -29,9 +29,8 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
|
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
#include <tchar.h>
|
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -29,15 +29,14 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
|
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
#include <tchar.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include "VXDisassembler.h"
|
#include <VXDisassembler.h>
|
||||||
|
|
||||||
using namespace Verteron;
|
using namespace Verteron;
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
uint8_t data32[] =
|
uint8_t data32[] =
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,19 +29,18 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
|
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
#include <tchar.h>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "VXDisassembler.h"
|
#include <VXDisassembler.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
using namespace Verteron;
|
using namespace Verteron;
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Find module base in memory
|
// Find module base in memory
|
||||||
void *moduleBase = GetModuleHandle(L"kernel32.dll");
|
void *moduleBase = GetModuleHandle("kernel32.dll");
|
||||||
uintptr_t baseAddress = reinterpret_cast<uintptr_t>(moduleBase);
|
uintptr_t baseAddress = reinterpret_cast<uintptr_t>(moduleBase);
|
||||||
// Parse PE headers
|
// Parse PE headers
|
||||||
PIMAGE_DOS_HEADER dosHeader = static_cast<PIMAGE_DOS_HEADER>(moduleBase);
|
PIMAGE_DOS_HEADER dosHeader = static_cast<PIMAGE_DOS_HEADER>(moduleBase);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "VXDisassemblerUtils.h"
|
#include "VXDisassemblerUtils.h"
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace Verteron
|
namespace Verteron
|
||||||
{
|
{
|
||||||
|
@ -215,7 +216,7 @@ char const* VXBaseInstructionFormatter::outputString()
|
||||||
// Write the formatted text to the output buffer
|
// Write the formatted text to the output buffer
|
||||||
assert((bufLen - offset) > 0);
|
assert((bufLen - offset) > 0);
|
||||||
strLen =
|
strLen =
|
||||||
vsnprintf_s(&m_outputBuffer[offset], bufLen - offset, _TRUNCATE, format, arguments);
|
std::vsnprintf(&m_outputBuffer[offset], bufLen - offset, format, arguments);
|
||||||
} while (strLen < 0);
|
} while (strLen < 0);
|
||||||
// Increase the string length
|
// Increase the string length
|
||||||
m_outputStringLen = offset + strLen + 1;
|
m_outputStringLen = offset + strLen + 1;
|
||||||
|
|
Loading…
Reference in New Issue