From 3170e232cf92eace6043f9450661ae0d039cf100 Mon Sep 17 00:00:00 2001 From: Fischsalat <64608145+Fischsalat@users.noreply.github.com> Date: Wed, 30 Aug 2023 19:10:28 +0200 Subject: [PATCH] Initial commit --- .gitignore | 350 ++++++++++++++++++ .../IDA UnrealEngien exec importer.vcxproj | 195 ++++++++++ ...UnrealEngien exec importer.vcxproj.filters | 35 ++ IDA UnrealEngien exec importer/Main.cpp | 84 +++++ IDA UnrealEngien exec importer/ida_file.h | 134 +++++++ IDA UnrealEngien exec importer/ida_string.h | 267 +++++++++++++ IDAExecFunctions64.sln | 31 ++ 7 files changed, 1096 insertions(+) create mode 100644 .gitignore create mode 100644 IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj create mode 100644 IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj.filters create mode 100644 IDA UnrealEngien exec importer/Main.cpp create mode 100644 IDA UnrealEngien exec importer/ida_file.h create mode 100644 IDA UnrealEngien exec importer/ida_string.h create mode 100644 IDAExecFunctions64.sln diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfcfd56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,350 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ diff --git a/IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj b/IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj new file mode 100644 index 0000000..53031b3 --- /dev/null +++ b/IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj @@ -0,0 +1,195 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {67ca0520-676a-436b-a249-67334661dee8} + IDAUnrealEngienexecimporter + 10.0 + IDAExecFunctions64 + + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;$(IncludePath) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\plugins + + + false + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;$(IncludePath) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\plugins + + + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;$(IncludePath) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\plugins + + + false + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;$(IncludePath) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\plugins + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;%(AdditionalIncludeDirectories) + stdcpp17 + + + Console + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64;%(AdditionalLibraryDirectories) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64\ida.lib;%(AdditionalDependencies) + + + cd "C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1" +ida64.exe + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;%(AdditionalIncludeDirectories) + stdcpp17 + + + Console + true + true + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64;%(AdditionalLibraryDirectories) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64\ida.lib;%(AdditionalDependencies) + + + cd "C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1" +ida64.exe + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;%(AdditionalIncludeDirectories) + stdcpp17 + + + Console + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64;%(AdditionalLibraryDirectories) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64\ida.lib;%(AdditionalDependencies) + + + cd "C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1" +ida64.exe + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\include;%(AdditionalIncludeDirectories) + stdcpp17 + + + Console + true + true + true + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64;%(AdditionalLibraryDirectories) + C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1\idasdk77\lib\x64_win_vc_64\ida.lib;%(AdditionalDependencies) + + + cd "C:\Program Files\IDA.Pro.7.7.SP1.Windows.Portable.Decompilers.-.x86.x64.ARM64\IDA Pro 7.7 SP1" +ida64.exe + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj.filters b/IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj.filters new file mode 100644 index 0000000..0c40f3e --- /dev/null +++ b/IDA UnrealEngien exec importer/IDA UnrealEngien exec importer.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Header Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/IDA UnrealEngien exec importer/Main.cpp b/IDA UnrealEngien exec importer/Main.cpp new file mode 100644 index 0000000..7aea2f9 --- /dev/null +++ b/IDA UnrealEngien exec importer/Main.cpp @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "ida_file.h" +#include "ida_string.h" + +size_t get_real_imagebase() +{ + return getinf(INF_IMAGEBASE); +} + +struct plugin_ctx_t : public plugmod_t +{ + virtual bool idaapi run(size_t) override + { + msg("Hello, world! (cpp)\n"); + msg("Imagebase: 0x%X\n", get_imagebase()); + msg("Addr: 0x%X\n", get_real_imagebase() + 0x1444); + set_name((get_real_imagebase() + 0x1444), "IDK::Hell2"); + + ida_string result = ask_file(false, "*.idmap", "Load the file, or %s", "die!"); + + const char* reselult = result.c_str(); + + msg("Selected result.c_str(): %s\n", result.c_str()); + + ida_file selected_file(result, ida_file::open_mode::binary_read_only); + + auto image_base = get_real_imagebase(); + msg("Imagebase: 0x%llX\n", image_base); + msg("Imagebase: 0x%llX\n", get_real_imagebase()); + + hook_type_t processor_hook = HT_IDP; + + if (selected_file.is_open()) + { + while (selected_file.can_read_more()) + { + uint32 offset = selected_file.read(); + uint16 name_len = selected_file.read(); + + ida_string name_string = selected_file.read_string(name_len); + + set_name(image_base + offset, name_string.c_str()); + + //msg("offset: 0x%X\n", offset); + //msg("name_len: 0x%X\n", name_len); + //msg("name_string: %s\n", name_string.c_str()); + } + } + + return true; + } +}; + + +//-------------------------------------------------------------------------- +static plugmod_t* idaapi init() +{ + return new plugin_ctx_t; +} + +//-------------------------------------------------------------------------- +plugin_t PLUGIN = +{ + IDP_INTERFACE_VERSION, + PLUGIN_UNL // Unload the plugin immediately after calling 'run' + | PLUGIN_MULTI, // The plugin can work with multiple idbs in parallel + init, // initialize + nullptr, + nullptr, + nullptr, // long comment about the plugin + nullptr, // multiline help about the plugin + "HellWorld", // the preferred short name of the plugin + "Ctrl-Alt-A", // the preferred hotkey to run the plugin +}; \ No newline at end of file diff --git a/IDA UnrealEngien exec importer/ida_file.h b/IDA UnrealEngien exec importer/ida_file.h new file mode 100644 index 0000000..9c10c8d --- /dev/null +++ b/IDA UnrealEngien exec importer/ida_file.h @@ -0,0 +1,134 @@ +#pragma once +#include +#include + +#include "ida_string.h" + +class ida_file +{ +public: + enum class open_mode + { + none, + read_only, + binary_read_only, + read_write, + binary_read_write, + }; + +private: + FILE* file; + open_mode mode; + int pos; + int size; + +public: + ida_file() + : file(nullptr) + , mode(open_mode::none) + , pos(0) + , size(0) + { + } + + ida_file(const char* file_path, open_mode new_mode = open_mode::read_only) + : file(nullptr) + , mode(new_mode) + , pos(0) + , size(0) + { + if (open_file(file_path, new_mode)) + { + qfseek(file, 0, SEEK_END); + size = qftell(file); + qfseek(file, 0, SEEK_SET); + msg("POS: %d", qftell(file)); + } + } + + ~ida_file() + { + close_file(); + } + +public: + bool is_open() + { + return file && mode != open_mode::none; + } + + bool can_write() + { + return is_open() && (mode >= open_mode::read_write); + } + + bool open_file(const char* file_name, open_mode new_mode = open_mode::read_only) + { + if (is_open()) + close_file(); + + mode = new_mode; + + switch (mode) + { + case open_mode::read_only: + file = fopenRT(file_name); + break; + case open_mode::binary_read_only: + file = fopenRB(file_name); + break; + case open_mode::read_write: + file = fopenWT(file_name); + break; + case open_mode::binary_read_write: + file = fopenWB(file_name); + break; + default: + break; + } + + return file != nullptr; + } + + void close_file() + { + qfclose(file); + file = nullptr; + mode = open_mode::none; + pos = 0; + } + +public: + template + void read(T& out_value) + { + pos += sizeof(T); + qfread(file, &out_value, sizeof(T)); + } + + template + T read() + { + T ret_value; + pos += sizeof(T); + + qfread(file, &ret_value, sizeof(T)); + + return ret_value; + } + + ida_string read_string(int length) + { + ida_string ret; + pos += length; + + qfread(file, ret.buffer(length), length); + + return ret; + } + + bool can_read_more() + { + return pos < size; + } +}; diff --git a/IDA UnrealEngien exec importer/ida_string.h b/IDA UnrealEngien exec importer/ida_string.h new file mode 100644 index 0000000..2034c2f --- /dev/null +++ b/IDA UnrealEngien exec importer/ida_string.h @@ -0,0 +1,267 @@ +#pragma once +#include +#include + +template +class ida_string_base +{ +private: + static constexpr int char_size = sizeof(char_type); + + static constexpr uintptr_t use_allocated_buffer_mask = 0x8000000000000000; + +private: + union + { + struct + { + char_type* buffer_start; + char_type* buffer_end; + }; + + unsigned char inline_buffer[0xF]; + unsigned char inline_length_inverse : 4; + unsigned char reserved : 3; + unsigned char use_allocated_buffer : 1; + }; + +public: + ida_string_base() + : buffer_start(nullptr) + , buffer_end(nullptr) + { + mark_as_allocated(); + } + + ida_string_base(const char_type* str, bool take_ownership = false) + : buffer_start(nullptr) + , buffer_end(nullptr) + { + //int length = ida_string_base::strlen(str); + int length = qstrlen(str); + + if (take_ownership) + { + takeover_outline_string(str, length); + return; + } + + if (is_length_suitable_for_inline(length)) + { + place_string_inline(str, length); + return; + } + + allocate_outline_string(str, length); + } + + ida_string_base(ida_string_base&& other) + : buffer_start(other.buffer_start) + , buffer_end(other.buffer_end) + { + other.buffer_start = nullptr; + other.buffer_end = nullptr; + } + + ida_string_base(const ida_string_base& other) + : buffer_start(nullptr) + , buffer_end(nullptr) + { + if (other.is_inline_string()) + { + memcpy(*this, &other, sizeof(ida_string_base)); + return; + } + + allocate_outline_string(other, other.length()); + } + + ~ida_string_base() + { + cleanup_self(); + } + +public: + ida_string_base& operator=(const char* string) + { + cleanup_self(); + + int length = qstrlen(string); + + if (is_length_suitable_for_inline(length)) + { + place_string_inline(string, length); + return *this; + } + + allocate_outline_string(string, length); + + return *this; + } + + ida_string_base& operator=(ida_string_base&& other) + { + cleanup_self(); + + memcpy(this, &other, sizeof(ida_string_base)); + memset(&other, 0, sizeof(ida_string_base)); + + return *this; + } + + ida_string_base& operator=(const ida_string_base& other) + { + cleanup_self(); + + if (other.is_inline_string()) + { + memcpy(*this, &other, sizeof(ida_string_base)); + return; + } + + return *this; + } + +private: + void place_string_inline(const char_type* string, int len) + { + memset(this, 0, sizeof(ida_string_base)); + inline_length_inverse = 0x10 - len; + use_allocated_buffer = false; + memcpy(inline_buffer, string, len * char_size); + } + + void fit_outline_buffer(int len) + { + int length_with_null_terminator = len + 1; + + buffer_start = reinterpret_cast((is_empty() || is_inline_string()) ? qalloc(length_with_null_terminator) : qrealloc(buffer_start, length_with_null_terminator)); + + buffer_end = buffer_start + length_with_null_terminator; + buffer_start[len] = 0; + mark_as_allocated(); + } + + void allocate_outline_string(const char_type* string, int len) + { + fit_outline_buffer(len); + + memcpy(buffer_start, string, len * char_size); + } + + void takeover_outline_string(const char_type* string, int len) + { + int length_with_null_terminator = len + 1; + + buffer_start = const_cast(string); + buffer_end = const_cast(string + length_with_null_terminator); + mark_as_allocated(); + } + + void cleanup_self() + { + if (is_inline_string()) + return; + + qfree(buffer_start); + memset(this, 0, sizeof(ida_string_base)); + } + +private: + static int strlen(const char_type* str) + { + int len = 0; + while (str[len] != 0) + len++; + + return len; + } + +private: + void mark_as_allocated() + { + buffer_end = reinterpret_cast(reinterpret_cast(buffer_end) | use_allocated_buffer_mask); + } + + bool is_length_suitable_for_inline(int len) const + { + return (len * char_size) < 0x10; + } + + bool is_inline_string() const + { + return !(reinterpret_cast(buffer_end) & use_allocated_buffer_mask); + } + + int get_inline_length_bytes() const + { + return 0x10 - inline_length_inverse; + } + + inline const char_type* get_buffer_start() const + { + return buffer_start; + } + + inline const char_type* get_buffer_end() const + { + return reinterpret_cast(reinterpret_cast(buffer_end) & ~use_allocated_buffer_mask); + } + + int length_bytes() const + { + if (is_inline_string()) + return get_inline_length_bytes(); + + return reinterpret_cast(get_buffer_start()) - reinterpret_cast(get_buffer_end()); + } + +public: + inline bool operator==(const ida_string_base& other) const + { + return length() == other.length() && (qstrcmp(c_str(), other.c_str()) == 0); + } + + inline bool operator!=(const ida_string_base& other) const + { + return length() != other.length() || (qstrcmp(c_str(), other.c_str()) != 0); + } + + operator const char_type* () const + { + return c_str(); + } + +public: + int length() const + { + if (length_bytes() <= 0) + return 0; + + return length_bytes() - 1; + } + + bool is_empty() const + { + return length() == 0; + } + + const char_type* c_str() const + { + if (is_inline_string()) + return reinterpret_cast(inline_buffer); + + return buffer_start; + } + + char* buffer(int required_buffer_size) + { + if (length() < required_buffer_size) + fit_outline_buffer(required_buffer_size); + + return const_cast(c_str()); + } +}; + +using ida_string = ida_string_base; +using ida_wstring = ida_string_base; \ No newline at end of file diff --git a/IDAExecFunctions64.sln b/IDAExecFunctions64.sln new file mode 100644 index 0000000..1781a45 --- /dev/null +++ b/IDAExecFunctions64.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.33328.57 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IDA UnrealEngien exec importer", "IDA UnrealEngien exec importer\IDA UnrealEngien exec importer.vcxproj", "{67CA0520-676A-436B-A249-67334661DEE8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {67CA0520-676A-436B-A249-67334661DEE8}.Debug|x64.ActiveCfg = Debug|x64 + {67CA0520-676A-436B-A249-67334661DEE8}.Debug|x64.Build.0 = Debug|x64 + {67CA0520-676A-436B-A249-67334661DEE8}.Debug|x86.ActiveCfg = Debug|Win32 + {67CA0520-676A-436B-A249-67334661DEE8}.Debug|x86.Build.0 = Debug|Win32 + {67CA0520-676A-436B-A249-67334661DEE8}.Release|x64.ActiveCfg = Release|x64 + {67CA0520-676A-436B-A249-67334661DEE8}.Release|x64.Build.0 = Release|x64 + {67CA0520-676A-436B-A249-67334661DEE8}.Release|x86.ActiveCfg = Release|Win32 + {67CA0520-676A-436B-A249-67334661DEE8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B29EF4C7-601F-4439-937B-EEC49B92F955} + EndGlobalSection +EndGlobal