├── Builder ├── Builder.cpp ├── Builder.sln ├── Builder.vcxproj ├── Builder.vcxproj.filters ├── Builder.vcxproj.user ├── ReadMe.txt ├── common.cpp ├── common.h ├── engine.cpp ├── engine.h ├── export.def ├── stdafx.cpp ├── stdafx.h ├── targetver.h ├── utility.cpp └── utility.h ├── FixCode ├── VxShellCode.inc └── uFixCode.pas ├── README.md └── UI ├── MainForm.dfm ├── MainForm.pas ├── ShellCode.dpr └── ShellCodeEngine.pas /Builder/Builder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/Builder/Builder.cpp -------------------------------------------------------------------------------- /Builder/Builder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Builder", "Builder.vcxproj", "{346D7CE9-32C9-4B95-8969-2E2E5596791F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Debug|x64.ActiveCfg = Debug|x64 17 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Debug|x64.Build.0 = Debug|x64 18 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Debug|x86.Build.0 = Debug|Win32 20 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Release|x64.ActiveCfg = Release|x64 21 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Release|x64.Build.0 = Release|x64 22 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Release|x86.ActiveCfg = Release|Win32 23 | {346D7CE9-32C9-4B95-8969-2E2E5596791F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Builder/Builder.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {346D7CE9-32C9-4B95-8969-2E2E5596791F} 23 | Win32Proj 24 | Builder 25 | 8.1 26 | 27 | 28 | 29 | Application 30 | true 31 | v140_xp 32 | Unicode 33 | 34 | 35 | DynamicLibrary 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | NotUsing 87 | Level3 88 | Disabled 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Console 94 | true 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | Use 104 | Level3 105 | Disabled 106 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 107 | true 108 | 109 | 110 | Console 111 | true 112 | export.def 113 | 114 | 115 | 116 | 117 | Level3 118 | NotUsing 119 | MaxSpeed 120 | true 121 | true 122 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 123 | true 124 | 125 | 126 | Windows 127 | true 128 | true 129 | true 130 | export.def 131 | 132 | 133 | 134 | 135 | Level3 136 | Use 137 | MaxSpeed 138 | true 139 | true 140 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 141 | true 142 | 143 | 144 | Console 145 | true 146 | true 147 | true 148 | export.def 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /Builder/Builder.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {ddedba51-1aac-4f41-945a-8ecea349b649} 18 | 19 | 20 | {ad6f719b-b289-4f63-bb6c-83b2c8f26516} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 头文件 29 | 30 | 31 | Common 32 | 33 | 34 | Common 35 | 36 | 37 | Core 38 | 39 | 40 | 41 | 42 | 源文件 43 | 44 | 45 | 源文件 46 | 47 | 48 | Core 49 | 50 | 51 | Common 52 | 53 | 54 | 55 | 56 | 源文件 57 | 58 | 59 | -------------------------------------------------------------------------------- /Builder/Builder.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Builder/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 控制台应用程序:Builder 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 Builder 应用程序。 6 | 7 | 本文件概要介绍组成 Builder 应用程序的每个文件的内容。 8 | 9 | 10 | Builder.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | Builder.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | Builder.cpp 17 | 这是主应用程序源文件。 18 | 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 其他标准文件: 21 | 22 | StdAfx.h, StdAfx.cpp 23 | 这些文件用于生成名为 Builder.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 24 | 25 | ///////////////////////////////////////////////////////////////////////////// 26 | 其他注释: 27 | 28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | -------------------------------------------------------------------------------- /Builder/common.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/Builder/common.cpp -------------------------------------------------------------------------------- /Builder/common.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_COMMON_H 2 | #define COMMON_COMMON_H 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define SAFE_CLOSE(x) do { \ 9 | if(x != nullptr) \ 10 | CloseHandle(x); \ 11 | x = nullptr; \ 12 | } while(0); 13 | 14 | #define SAFE_RELEASE(x) do { \ 15 | if(x != nullptr) \ 16 | delete x; \ 17 | x = nullptr; \ 18 | } while(0); 19 | 20 | #define ASSERT(x) do { \ 21 | if (!(x)) \ 22 | assert(#x, __FILE__, __LINE__); \ 23 | } while (0); 24 | 25 | #define DBGOUT(fmt, ...) do { \ 26 | debug(fmt, __VA_ARGS__); \ 27 | } while (0); 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif // __cplusplus 32 | void __cdecl debug(char* fmt, ...); 33 | void assert(char* code, char* file, int line); 34 | #ifdef __cplusplus 35 | } 36 | #endif // __cplusplus 37 | 38 | #endif // COMMON_COMMON_H -------------------------------------------------------------------------------- /Builder/engine.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/Builder/engine.cpp -------------------------------------------------------------------------------- /Builder/engine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/Builder/engine.h -------------------------------------------------------------------------------- /Builder/export.def: -------------------------------------------------------------------------------- 1 | LIBRARY Builder 2 | EXPORTS 3 | CreateInstance 4 | DeleteInstance 5 | AddObj 6 | AddModule 7 | Build 8 | GetFuncList 9 | -------------------------------------------------------------------------------- /Builder/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/Builder/stdafx.cpp -------------------------------------------------------------------------------- /Builder/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/Builder/stdafx.h -------------------------------------------------------------------------------- /Builder/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/Builder/targetver.h -------------------------------------------------------------------------------- /Builder/utility.cpp: -------------------------------------------------------------------------------- 1 | #include "utility.h" 2 | 3 | string extract_filename(string& path) { 4 | string ret = ""; 5 | auto pos = path.find_last_of("\\"); 6 | if (pos != string::npos) { 7 | ret = path.substr(pos + 1, path.length()); 8 | } 9 | else { 10 | ret = path; 11 | } 12 | return ret; 13 | } 14 | 15 | string decode_fun(string& name) { 16 | auto ret = name; 17 | if (name.length() < 2) return ret; 18 | if (name[0] == '?') { 19 | ret = name; 20 | } else { 21 | auto pos = name.find("__imp_"); 22 | if (pos != string::npos) ret = name.substr(pos + 6, name.length() - pos - 6); 23 | if (ret[0] == '_') ret = ret.substr(1, name.length() - 1); 24 | pos = ret.find("@"); 25 | if (pos != string::npos) ret = ret.substr(0, pos); 26 | } 27 | return ret; 28 | } 29 | 30 | uint32_t HashStringFromRol3Xor(const char* sz) { 31 | _asm { 32 | mov eax, sz 33 | push esi 34 | cdq 35 | test eax, eax 36 | jz finished 37 | mov esi, eax 38 | xor eax, eax 39 | calc_hash : 40 | lodsb 41 | test al, al 42 | jz finished 43 | rol edx, 3 44 | xor dl, al 45 | jmp calc_hash 46 | finished : 47 | mov eax, edx 48 | pop esi 49 | } 50 | } 51 | 52 | FileLoader::FileLoader(std::string& path): buffer_base_(nullptr), filename_(path) { 53 | loaded_ = loadfile(path); 54 | } 55 | 56 | FileLoader::~FileLoader() { 57 | closefile(); 58 | } 59 | 60 | int FileLoader::loadfile(std::string& path) { 61 | file_handle_ = CreateFileA(path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); 62 | if (file_handle_ == INVALID_HANDLE_VALUE) return 0; 63 | total_size_ = GetFileSize(file_handle_, nullptr); 64 | map_handle_ = CreateFileMapping(file_handle_, nullptr, PAGE_READONLY, 0, 0, nullptr); 65 | if (map_handle_ == nullptr) { 66 | SAFE_CLOSE(file_handle_); 67 | return 0; 68 | } 69 | buffer_base_ = (char*)MapViewOfFile(map_handle_, FILE_MAP_READ, 0, 0, 0); 70 | if (buffer_base_ == nullptr) { 71 | SAFE_CLOSE(map_handle_); 72 | SAFE_CLOSE(file_handle_); 73 | return 0; 74 | } 75 | return 1; 76 | } 77 | 78 | void FileLoader::closefile() { 79 | if (buffer_base_ != nullptr) 80 | UnmapViewOfFile((void*)buffer_base_); 81 | SAFE_CLOSE(map_handle_); 82 | SAFE_CLOSE(file_handle_); 83 | } -------------------------------------------------------------------------------- /Builder/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_UTILITY_H 2 | #define COMMON_UTILITY_H 3 | #include "common.h" 4 | #include 5 | 6 | using std::string; 7 | 8 | class FileLoader { 9 | public: 10 | FileLoader(std::string& path); 11 | ~FileLoader(); 12 | inline char* base() { 13 | return buffer_base_; 14 | }; 15 | inline size_t size() { 16 | return total_size_; 17 | }; 18 | inline int loaded() { 19 | return loaded_; 20 | }; 21 | private: 22 | int loadfile(std::string& path); 23 | void closefile(); 24 | private: 25 | std::string filename_; 26 | HANDLE file_handle_, map_handle_; 27 | char* buffer_base_; 28 | size_t total_size_; 29 | int loaded_; 30 | }; 31 | 32 | string extract_filename(string& path); 33 | string decode_fun(string& name); 34 | uint32_t HashStringFromRol3Xor(const char* sz); 35 | 36 | #endif // COMMON_UTILITY_H 37 | -------------------------------------------------------------------------------- /FixCode/VxShellCode.inc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/FixCode/VxShellCode.inc -------------------------------------------------------------------------------- /FixCode/uFixCode.pas: -------------------------------------------------------------------------------- 1 | { 2 | apiname|hash|offset|apiname|hash|offset|0x00| 3 | rva,offset,rva,offset,0xFFFFFFFF,Entry Offset 4 | 5 | //need function 6 | loadlibrary 7 | getprocaddress 8 | virtualalloc} 9 | 10 | unit uFixCode; 11 | 12 | interface 13 | uses 14 | Winapi.Windows, VxWindows, VxSystem, Bpe32b; 15 | 16 | type 17 | PFixReloc = ^TFixReloc; 18 | TFixReloc = packed record 19 | Rva: UInt32; 20 | Offset: UInt32; 21 | end; 22 | 23 | function SaveFixCodeToMem(lpMem: Pointer): UInt32; 24 | function SaveFixCodeToFile(szFileName: string): UInt32; 25 | 26 | procedure FixCodeBegin(); stdcall; 27 | function FixCodeEntry(): Pointer; stdcall; 28 | procedure FixCodeEnd(); stdcall; 29 | implementation 30 | 31 | procedure FixCodeBegin(); assembler; 32 | asm 33 | pushad 34 | call FixCodeEntry 35 | mov [esp + 7 * 4], eax 36 | popad 37 | jmp eax 38 | end; 39 | 40 | {$INCLUDE VxShellCode.inc} 41 | function FixCodeEntry(): Pointer; stdcall; 42 | label 43 | __NEXT_API; 44 | var 45 | hKernel32, hDll: HMODULE; 46 | xLoadLibraryA: TLoadLibraryA; 47 | xGetProcAddress: TGetProcAddress; 48 | xVirtualAlloc: TVirtualAlloc; 49 | lpSeek: Pointer; 50 | Api: Pointer; 51 | lpReloc: PFixReloc; 52 | Entry: UInt32; 53 | lpShellData: Pointer; 54 | ShellDataSize: UInt32; 55 | begin 56 | lpShellData := _GetFixAddress(@FixCodeEnd); 57 | if (PUInt32(lpShellData)^ <> $00000000) then 58 | begin 59 | Result := Pointer(PUInt32(lpShellData)^); 60 | Exit; 61 | end; 62 | // get all need api 63 | hKernel32 := _GetKernelBase_PEB(); 64 | @xGetProcAddress := _GetProcAddress_FromHash($F2509B84, nil, hKernel32); 65 | @xLoadLibraryA := _GetProcAddress_FromHash($A412FD89, @xGetProcAddress, hKernel32); 66 | @xVirtualAlloc := _GetProcAddress_FromHash($AB16D0AE, @xGetProcAddress, hKernel32); 67 | // fix 68 | lpSeek := Pointer(UInt32(lpShellData) + PUInt32(UInt32(lpShellData) + 4)^); 69 | while (True) do 70 | begin 71 | if (PUInt32(lpSeek)^ = $4D3C2B1A) then Break; 72 | hDll := xLoadLibraryA(PAnsiChar(lpSeek)); 73 | while (PUInt8(lpSeek)^ <> $00) do Inc(PUInt8(lpSeek)); 74 | Inc(PUInt8(lpSeek)); 75 | while (PUInt32(lpSeek)^ <> $1A2B3C4D) do 76 | begin 77 | Api := _GetProcAddress_FromHash(PUInt32(lpSeek)^, @xGetProcAddress, hDll); 78 | Inc(PUInt32(lpSeek)); 79 | PUInt32(UInt32(lpShellData) + PUInt32(lpSeek)^)^ := UInt32(Api); 80 | Inc(PUInt32(lpSeek)); 81 | end; 82 | Inc(PUInt32(lpSeek)); 83 | end; 84 | Inc(PUInt32(lpSeek)); 85 | // fix reloc 86 | lpReloc := PFixReloc(lpSeek); 87 | while (lpReloc^.Rva <> $FFFFFFFF) do 88 | begin 89 | PUInt32(UInt32(lpShellData) + lpReloc^.Rva)^ := UInt32(lpShellData) + lpReloc^.Offset; 90 | Inc(lpReloc); 91 | end; 92 | // return entry 93 | Entry := lpReloc^.Offset + UInt32(lpShellData); 94 | PUInt32(lpShellData)^ := Entry; 95 | Result := Pointer(Entry); 96 | end; 97 | 98 | procedure FixCodeEnd(); stdcall; begin end; 99 | 100 | function SaveFixCodeToFile(szFileName: string): UInt32; 101 | var 102 | lpBuffer: Pointer; 103 | CodeSize: UInt32; 104 | begin 105 | Result := 0; 106 | CodeSize := UInt32(@FixCodeEnd) - UInt32(@FixCodeBegin); 107 | lpBuffer := VX_MemAlloc(CodeSize); 108 | if (lpBuffer = nil) then Exit; 109 | VX_ZeroMem(lpBuffer, CodeSize); 110 | SaveFixCodeToMem(lpBuffer); 111 | if (VX_WriteDataToFile(PChar(szFileName), lpBuffer, CodeSize, False)) then 112 | begin 113 | Result := CodeSize; 114 | end; 115 | VX_MemFree(lpBuffer); 116 | end; 117 | 118 | function SaveFixCodeToMem(lpMem: Pointer): UInt32; 119 | var 120 | Code: Pointer; 121 | CodeSize: UInt32; 122 | lpPolyBuffer: Pointer; 123 | dwMaxSize, dwPloySize: UInt32; 124 | begin 125 | Result := 0; 126 | Code := Pointer(@FixCodeBegin); 127 | CodeSize := UInt32(@FixCodeEnd) - UInt32(@FixCodeBegin); 128 | //dwMaxSize := _GetBpe32MaxCryptSize(CodeSize); 129 | //if (IsBadWritePtr(lpMem, dwMaxSize)) then Exit; 130 | //dwPloySize := _Bpe32_Engine(lpMem, Code, CodeSize); 131 | //Result := dwPloySize; 132 | if (IsBadWritePtr(lpMem, CodeSize)) then Exit; 133 | CopyMemory(lpMem, Code, CodeSize); 134 | Result := CodeSize; 135 | end; 136 | 137 | end. 138 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ObjToShellCode 2 | -------------------------------------------------------------------------------- /UI/MainForm.dfm: -------------------------------------------------------------------------------- 1 | object Form2: TForm2 2 | Left = 0 3 | Top = 0 4 | Caption = 'Form2' 5 | ClientHeight = 370 6 | ClientWidth = 550 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'Tahoma' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | OnCreate = FormCreate 15 | OnDestroy = FormDestroy 16 | PixelsPerInch = 96 17 | TextHeight = 13 18 | object btn1: TRzButton 19 | Left = 352 20 | Top = 16 21 | Height = 23 22 | Caption = #22686#21152'OBJ' 23 | TabOrder = 0 24 | OnClick = btn1Click 25 | end 26 | object btn2: TRzButton 27 | Left = 352 28 | Top = 45 29 | Caption = #22686#21152#27169#22359 30 | TabOrder = 1 31 | OnClick = btn2Click 32 | end 33 | object btn3: TRzButton 34 | Left = 457 35 | Top = 76 36 | Caption = #29983#25104 37 | TabOrder = 2 38 | OnClick = btn3Click 39 | end 40 | object mmo1: TMemo 41 | Left = 0 42 | Top = 113 43 | Width = 550 44 | Height = 257 45 | Align = alBottom 46 | ImeName = #20013#25991'('#31616#20307') - '#24517#24212' Bing '#36755#20837#27861 47 | TabOrder = 3 48 | ExplicitTop = 80 49 | ExplicitWidth = 474 50 | end 51 | object cbbEntry: TRzComboBox 52 | Left = 25 53 | Top = 76 54 | Width = 304 55 | Height = 21 56 | Style = csDropDownList 57 | ImeName = #20013#25991'('#31616#20307') - '#24517#24212' Bing '#36755#20837#27861 58 | TabOrder = 4 59 | end 60 | object btn4: TRzButton 61 | Left = 352 62 | Top = 76 63 | Caption = #33719#21462#20989#25968 64 | TabOrder = 5 65 | OnClick = btn4Click 66 | end 67 | object edt1: TRzEdit 68 | Left = 25 69 | Top = 49 70 | Width = 304 71 | Height = 21 72 | Text = '' 73 | ImeName = #20013#25991'('#31616#20307') - '#24517#24212' Bing '#36755#20837#27861 74 | TabOrder = 6 75 | end 76 | object btn5: TRzButton 77 | Left = 106 78 | Top = 15 79 | Caption = 'showlog' 80 | TabOrder = 7 81 | OnClick = btn5Click 82 | end 83 | object btn6: TRzButton 84 | Left = 25 85 | Top = 15 86 | Caption = 'hidelog' 87 | TabOrder = 8 88 | OnClick = btn6Click 89 | end 90 | object dlgOpen1: TOpenDialog 91 | Filter = 'COMMON OBJECT FILE|*.Obj;' 92 | Options = [ofHideReadOnly, ofAllowMultiSelect, ofEnableSizing] 93 | Left = 256 94 | end 95 | object dlgSave1: TSaveDialog 96 | Left = 208 97 | end 98 | end 99 | -------------------------------------------------------------------------------- /UI/MainForm.pas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killeven/ObjToShellCode/7fd1cf1edd0b73f49b17b64996c0c12796e92c88/UI/MainForm.pas -------------------------------------------------------------------------------- /UI/ShellCode.dpr: -------------------------------------------------------------------------------- 1 | program ShellCode; 2 | 3 | uses 4 | Vcl.Forms, 5 | MainForm in 'MainForm.pas' {Form2}, 6 | ShellCodeEngine in 'ShellCodeEngine.pas'; 7 | 8 | {$R *.res} 9 | 10 | begin 11 | Application.Initialize; 12 | Application.MainFormOnTaskbar := True; 13 | Application.CreateForm(TForm2, Form2); 14 | Application.Run; 15 | end. 16 | -------------------------------------------------------------------------------- /UI/ShellCodeEngine.pas: -------------------------------------------------------------------------------- 1 | unit ShellCodeEngine; 2 | 3 | interface 4 | 5 | type 6 | SCEInstance = Pointer; 7 | TCallBack = procedure(name: PAnsiChar); stdcall; 8 | TEngine = class 9 | private 10 | instance: SCEInstance; 11 | public 12 | constructor Create; 13 | destructor Destroy; override; 14 | function AddObj(path: PAnsiChar): Boolean; 15 | function AddModule(path: PAnsiChar): Boolean; stdcall; 16 | function Build(savepath: PAnsiChar; entryname: PAnsiChar): Boolean; stdcall; 17 | procedure GetFuncList(callback: TCallBack); stdcall; 18 | end; 19 | 20 | implementation 21 | 22 | const ShellCodeEngineDll = 'Builder.dll'; 23 | function xCreateInstance(): SCEInstance; stdcall; external ShellCodeEngineDll name 'CreateInstance'; 24 | procedure xDeleteInstance(instance: SCEInstance); stdcall; external ShellCodeEngineDll name 'DeleteInstance'; 25 | function xAddObj(instance: SCEInstance; path: PAnsiChar): Boolean; stdcall; external ShellCodeEngineDll name 'AddObj'; 26 | function xAddModule(instance: SCEInstance; path: PAnsiChar): Boolean; stdcall; external ShellCodeEngineDll name 'AddModule'; 27 | function xBuild(instance: SCEInstance; savepath: PAnsiChar; entryname: PAnsiChar): Boolean; stdcall; external ShellCodeEngineDll name 'Build'; 28 | procedure xGetFuncList(instance: SCEInstance; callback: TCallBack); stdcall; external ShellCodeEngineDll name 'GetFuncList'; 29 | 30 | { TEngine } 31 | 32 | function TEngine.AddModule(path: PAnsiChar): Boolean; 33 | begin 34 | Result := xAddModule(instance, path); 35 | end; 36 | 37 | function TEngine.AddObj(path: PAnsiChar): Boolean; 38 | begin 39 | Result := xAddObj(instance, path); 40 | end; 41 | 42 | function TEngine.Build(savepath, entryname: PAnsiChar): Boolean; 43 | begin 44 | Result := xBuild(instance, savepath, entryname); 45 | end; 46 | 47 | constructor TEngine.Create; 48 | begin 49 | instance := xCreateInstance(); 50 | end; 51 | 52 | destructor TEngine.Destroy; 53 | begin 54 | xDeleteInstance(instance); 55 | end; 56 | 57 | procedure TEngine.GetFuncList(callback: TCallBack); 58 | begin 59 | xGetFuncList(instance, callback); 60 | end; 61 | 62 | end. 63 | --------------------------------------------------------------------------------