├── src
├── BlackBone
│ ├── PatternSearch.cpp
│ ├── PatternSearch.h
│ ├── BlackBone.vcxproj.user
│ ├── AsmHelper.h
│ ├── AsmHelperBase.cpp
│ ├── Winheaders.h
│ ├── AsmJit
│ │ ├── ApiEnd.h
│ │ ├── MemoryMarker.cpp
│ │ ├── Operand.h
│ │ ├── ApiBegin.h
│ │ ├── Assembler.h
│ │ ├── Defs.cpp
│ │ ├── MemoryMarker.h
│ │ ├── Logger.cpp
│ │ ├── Config.h
│ │ ├── CodeGenerator.cpp
│ │ ├── Regenerate.py
│ │ ├── Util_p.h
│ │ ├── CodeGenerator.h
│ │ ├── Util.cpp
│ │ ├── Platform.cpp
│ │ ├── Logger.h
│ │ ├── Platform.h
│ │ ├── MemoryManager.h
│ │ └── Compiler.cpp
│ ├── Win7Specific.h
│ ├── LDasm.h
│ ├── DynImport.cpp
│ ├── MExcept.h
│ ├── ImageNET.h
│ ├── DynImport.h
│ ├── Types.h
│ ├── Threads.h
│ ├── FileProjection.h
│ ├── ProcessCore.cpp
│ ├── AsmStack.hpp
│ ├── Win8Specific.h
│ ├── Utils.h
│ ├── x86Subsystem.h
│ ├── ProcessCore.h
│ ├── NameResolve.h
│ ├── AsmHelperBase.h
│ ├── FileProjection.cpp
│ ├── AsmHelper32.h
│ ├── Process.h
│ ├── AsmHelper64.h
│ ├── Macro.h
│ ├── ProcessMemory.h
│ ├── Threads.cpp
│ ├── Process.cpp
│ ├── ProcessMemory.cpp
│ ├── x86Subsystem.cpp
│ ├── Utils.cpp
│ ├── MemBlock.cpp
│ ├── Wow64Subsystem.h
│ ├── FunctionTypes.h
│ ├── PEParser.h
│ ├── ProcessModules.h
│ ├── ImageNET.cpp
│ ├── Thread.h
│ ├── MemBlock.h
│ ├── AsmVariant.hpp
│ └── RemoteFunction.hpp
└── TestApp
│ ├── TestApp.vcxproj.filters
│ └── TestApp.vcxproj.user
├── .gitignore
├── LICENSE
├── BlackBone.sln
└── README.md
/src/BlackBone/PatternSearch.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TopoIogist/Blackbone/HEAD/src/BlackBone/PatternSearch.cpp
--------------------------------------------------------------------------------
/src/BlackBone/PatternSearch.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TopoIogist/Blackbone/HEAD/src/BlackBone/PatternSearch.h
--------------------------------------------------------------------------------
/src/BlackBone/BlackBone.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/BlackBone/AsmHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef _M_AMD64
4 | #define AsmJitHelper AsmHelper64
5 | #include "AsmHelper64.h"
6 | #else
7 | #include "AsmHelper32.h"
8 | #define AsmJitHelper AsmHelper32
9 | #endif // _M_AMD64
10 |
--------------------------------------------------------------------------------
/src/TestApp/TestApp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/BlackBone/AsmHelperBase.cpp:
--------------------------------------------------------------------------------
1 | #include "AsmHelperBase.h"
2 |
3 | namespace ds_mmap
4 | {
5 | CAsmHelperBase::CAsmHelperBase(AsmJit::Assembler& _a)
6 | : a(_a)
7 | {
8 | }
9 |
10 | CAsmHelperBase::~CAsmHelperBase(void)
11 | {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/BlackBone/Winheaders.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef WIN32_LEAN_AND_MEAN
4 | #define WIN32_LEAN_AND_MEAN
5 | #endif
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #pragma warning(disable : 4005)
14 | #include
15 | #pragma warning(default : 4005)
16 |
--------------------------------------------------------------------------------
/src/BlackBone/AsmJit/ApiEnd.h:
--------------------------------------------------------------------------------
1 | // [AsmJit]
2 | // Complete JIT Assembler for C++ Language.
3 | //
4 | // [License]
5 | // Zlib - See COPYING file in this package.
6 |
7 | #if defined(_MSC_VER)
8 |
9 | // Pop disabled warnings by ApiBegin.h
10 | #pragma warning(pop)
11 |
12 | // Rename symbols back.
13 | #undef vsnprintf
14 | #undef snprintf
15 |
16 | #endif // _MSC_VER
17 |
--------------------------------------------------------------------------------
/src/TestApp/TestApp.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WindowsLocalDebugger
5 | NativeOnly
6 |
7 |
8 | NativeOnly
9 |
10 |
--------------------------------------------------------------------------------
/src/BlackBone/AsmJit/MemoryMarker.cpp:
--------------------------------------------------------------------------------
1 | // [AsmJit]
2 | // Complete JIT Assembler for C++ Language.
3 | //
4 | // [License]
5 | // Zlib - See COPYING file in this package.
6 |
7 | // [Dependencies]
8 | #include "Build.h"
9 | #include "MemoryMarker.h"
10 |
11 | // [Api-Begin]
12 | #include "ApiBegin.h"
13 |
14 | namespace AsmJit {
15 |
16 | // ============================================================================
17 | // [AsmJit::MemoryMarker]
18 | // ============================================================================
19 |
20 | MemoryMarker::MemoryMarker() ASMJIT_NOTHROW {}
21 | MemoryMarker::~MemoryMarker() ASMJIT_NOTHROW {}
22 |
23 | } // AsmJit namespace
24 |
25 | // [Api-End]
26 | #include "ApiEnd.h"
27 |
--------------------------------------------------------------------------------
/src/BlackBone/Win7Specific.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Winheaders.h"
4 |
5 | namespace blackbone
6 | {
7 | #pragma warning(disable : 4201)
8 |
9 | struct _LDR_DATA_TABLE_ENTRY_W7 : LDR_DATA_TABLE_ENTRY_BASE_T
10 | {
11 | _LIST_ENTRY ForwarderLinks;
12 | _LIST_ENTRY ServiceTagLinks;
13 | _LIST_ENTRY StaticLinks;
14 | void * ContextInformation;
15 | unsigned long OriginalBase;
16 | _LARGE_INTEGER LoadTime;
17 | };
18 |
19 | typedef struct _RTL_INVERTED_FUNCTION_TABLE7
20 | {
21 | ULONG Count;
22 | ULONG MaxCount;
23 | ULONG Pad[0x1];
24 | RTL_INVERTED_FUNCTION_TABLE_ENTRY Entries[0x200];
25 |
26 | } RTL_INVERTED_FUNCTION_TABLE7, *PRTL_INVERTED_FUNCTION_TABLE7;
27 |
28 | #pragma warning(default : 4201)
29 | }
--------------------------------------------------------------------------------
/src/BlackBone/AsmJit/Operand.h:
--------------------------------------------------------------------------------
1 | // [AsmJit]
2 | // Complete JIT Assembler for C++ Language.
3 | //
4 | // [License]
5 | // Zlib - See COPYING file in this package.
6 |
7 | // [Guard]
8 | #ifndef _ASMJIT_OPERAND_H
9 | #define _ASMJIT_OPERAND_H
10 |
11 | // [Dependencies]
12 | #include "Build.h"
13 |
14 | namespace AsmJit {
15 |
16 | //! @addtogroup AsmJit_Core
17 | //! @{
18 |
19 | // There is currently no platform independent code.
20 |
21 | //! @}
22 |
23 | } // AsmJit namespace
24 |
25 | // ============================================================================
26 | // [Platform Specific]
27 | // ============================================================================
28 |
29 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64)
30 | #include "OperandX86X64.h"
31 | #endif // ASMJIT_X86 || ASMJIT_X64
32 |
33 | // [Guard]
34 | #endif // _ASMJIT_OPERAND_H
35 |
--------------------------------------------------------------------------------
/src/BlackBone/AsmJit/ApiBegin.h:
--------------------------------------------------------------------------------
1 | // [AsmJit]
2 | // Complete JIT Assembler for C++ Language.
3 | //
4 | // [License]
5 | // Zlib - See COPYING file in this package.
6 |
7 | // MSVC
8 | #if defined(_MSC_VER)
9 |
10 | // Disable some warnings we know about
11 | #pragma warning(push)
12 | #pragma warning(disable: 4127) // conditional expression is constant
13 | #pragma warning(disable: 4251) // struct needs to have dll-interface to be used
14 | // by clients of struct ...
15 | #pragma warning(disable: 4275) // non dll-interface struct ... used as base for
16 | // dll-interface struct
17 | #pragma warning(disable: 4355) // this used in base member initializer list
18 | #pragma warning(disable: 4800) // forcing value to bool 'true' or 'false'
19 |
20 | // Rename symbols.
21 | #define vsnprintf _vsnprintf
22 | #define snprintf _snprintf
23 |
24 | #endif // _MSC_VER
25 |
--------------------------------------------------------------------------------
/src/BlackBone/AsmJit/Assembler.h:
--------------------------------------------------------------------------------
1 | // [AsmJit]
2 | // Complete JIT Assembler for C++ Language.
3 | //
4 | // [License]
5 | // Zlib - See COPYING file in this package.
6 |
7 | // [Guard]
8 | #ifndef _ASMJIT_ASSEMBLER_H
9 | #define _ASMJIT_ASSEMBLER_H
10 |
11 | // [Dependencies]
12 | #include "Build.h"
13 |
14 | namespace AsmJit {
15 |
16 | // ============================================================================
17 | // [Forward Declarations]
18 | // ============================================================================
19 |
20 | struct Logger;
21 | struct MemoryManager;
22 | struct EInstruction;
23 |
24 | } // AsmJit namespace
25 |
26 | // ============================================================================
27 | // [Platform Specific]
28 | // ============================================================================
29 |
30 | // [X86 / X64]
31 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64)
32 | #include "AssemblerX86X64.h"
33 | #endif // ASMJIT_X86 || ASMJIT_X64
34 |
35 | // [Guard]
36 | #endif // _ASMJIT_ASSEMBLER_H
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #OS junk files
2 | [Tt]humbs.db
3 | *.DS_Store
4 |
5 | #Visual Studio files
6 | *.[Oo]bj
7 | #*.user
8 | *.aps
9 | *.pch
10 | *.vspscc
11 | *.vssscc
12 | *_i.c
13 | *_p.c
14 | *.ncb
15 | *.suo
16 | *.tlb
17 | *.tlh
18 | *.bak
19 | *.[Cc]ache
20 | *.ilk
21 | *.log
22 | *.tlog
23 | *.pdb
24 | *.cer
25 | *.lib
26 | *.sbr
27 | *.sdf
28 | *.opensdf
29 | *.unsuccessfulbuild
30 | *.lastbuildstate
31 | ipch/
32 | obj/
33 | [Bb]in
34 | [Dd]ebug*/
35 | [Rr]elease*/
36 | Ankh.NoLoad
37 |
38 | #MonoDevelop
39 | *.pidb
40 | *.userprefs
41 |
42 | #Tooling
43 | _ReSharper*/
44 | *.resharper
45 | [Tt]est[Rr]esult*
46 | *.sass-cache
47 |
48 | #Project files
49 | [Bb]uild/
50 |
51 | #Subversion files
52 | .svn
53 |
54 | # Office Temp Files
55 | ~$*
56 |
57 | #NuGet
58 | packages/
59 |
60 | #ncrunch
61 | *ncrunch*
62 | *crunch*.local.xml
63 |
64 | # visual studio database projects
65 | *.dbmdl
66 |
67 | #Test files
68 | *.testsettings
69 |
70 | #Generated libraries
71 | *.dll
72 | *.bin
73 | *.sys
74 | #and files
75 | GeneratedFiles*/
76 |
77 | *.ggpk
78 |
79 | /VADPurge/export.h
80 |
--------------------------------------------------------------------------------
/src/BlackBone/AsmJit/Defs.cpp:
--------------------------------------------------------------------------------
1 | // [AsmJit]
2 | // Complete JIT Assembler for C++ Language.
3 | //
4 | // [License]
5 | // Zlib - See COPYING file in this package.
6 |
7 | // [Dependencies]
8 | #include "Defs.h"
9 |
10 | // [Api-Begin]
11 | #include "ApiBegin.h"
12 |
13 | namespace AsmJit {
14 |
15 | const char* getErrorString(uint32_t error) ASMJIT_NOTHROW
16 | {
17 | static const char* errorMessage[] = {
18 | "No error",
19 |
20 | "No heap memory",
21 | "No virtual memory",
22 |
23 | "Unknown instruction",
24 | "Illegal instruction",
25 | "Illegal addressing",
26 | "Illegal short jump",
27 |
28 | "No function defined",
29 | "Incomplete function",
30 |
31 | "Not enough registers",
32 | "Registers overlap",
33 |
34 | "Incompatible argument",
35 | "Incompatible return value",
36 |
37 | "Unknown error"
38 | };
39 |
40 | // Saturate error code to be able to use errorMessage[].
41 | if (error > _ERROR_COUNT) error = _ERROR_COUNT;
42 |
43 | return errorMessage[error];
44 | }
45 |
46 | } // AsmJit
47 |
48 | // [Api-End]
49 | #include "ApiEnd.h"
50 |
--------------------------------------------------------------------------------
/src/BlackBone/LDasm.h:
--------------------------------------------------------------------------------
1 | #ifndef _LDASM_
2 | #define _LDASM_
3 |
4 | #include "string.h"
5 |
6 | #ifdef _M_AMD64
7 | #define is_x64 1
8 | #else
9 | #define is_x64 0
10 | #endif//_M_AMD64
11 |
12 | #ifdef __cplusplus
13 | extern "C"
14 | {
15 | #endif
16 |
17 | #define F_INVALID 0x01
18 | #define F_PREFIX 0x02
19 | #define F_REX 0x04
20 | #define F_MODRM 0x08
21 | #define F_SIB 0x10
22 | #define F_DISP 0x20
23 | #define F_IMM 0x40
24 | #define F_RELATIVE 0x80
25 |
26 | typedef unsigned char u8;
27 | typedef unsigned long u32;
28 |
29 | typedef struct _ldasm_data
30 | {
31 | u8 flags;
32 | u8 rex;
33 | u8 modrm;
34 | u8 sib;
35 | u8 opcd_offset;
36 | u8 opcd_size;
37 | u8 disp_offset;
38 | u8 disp_size;
39 | u8 imm_offset;
40 | u8 imm_size;
41 | } ldasm_data;
42 |
43 | unsigned int __fastcall ldasm( void *code, ldasm_data *ld, u32 is64 );
44 | unsigned long __fastcall SizeOfProc( void *Proc );
45 | void* __fastcall ResolveJmp( void *Proc );
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif//_LDASM_
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 DarthTon
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | 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, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/src/BlackBone/DynImport.cpp:
--------------------------------------------------------------------------------
1 | #include "DynImport.h"
2 |
3 | std::unordered_map blackbone::DynImport::_funcs;
4 | std::mutex blackbone::DynImport::_mapGuard;
5 |
6 | namespace blackbone
7 | {
8 |
9 | ///
10 | /// Load function into database
11 | ///
12 | /// Function name
13 | /// Module name
14 | /// true on success
15 | bool DynImport::load( const std::string& name, const std::wstring& module )
16 | {
17 | auto mod = GetModuleHandleW( module.c_str() );
18 | return load( name, mod );
19 | }
20 |
21 | ///
22 | /// Load function into database
23 | ///
24 | /// Function name
25 | /// Module base
26 | /// true on success
27 | bool blackbone::DynImport::load( const std::string& name, HMODULE hMod )
28 | {
29 | std::lock_guard lg( _mapGuard );
30 |
31 | auto proc = GetProcAddress( hMod, name.c_str() );
32 | if (proc)
33 | {
34 | _funcs.insert( std::make_pair( name, proc ) );
35 | return true;
36 | }
37 |
38 | return false;
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/src/BlackBone/MExcept.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Winheaders.h"
4 | #include "MemBlock.h"
5 |
6 | namespace blackbone
7 | {
8 |
9 | ///
10 | /// Exception handling support for arbitrary code
11 | ///
12 | class MExcept
13 | {
14 | public:
15 | // For debug purposes only
16 | static void* g_pImageBase;
17 | static size_t g_imageSize;
18 |
19 | protected:
20 | MExcept( class Process& proc );
21 | ~MExcept();
22 |
23 | ///
24 | /// Inject VEH wrapper into process
25 | /// Used to enable execution of SEH handlers out of image
26 | ///
27 | /// Target image base address
28 | /// Size of the image
29 | /// Error code
30 | NTSTATUS CreateVEH( size_t pTargetBase, size_t imageSize );
31 |
32 | ///
33 | /// Removes VEH from target process
34 | ///
35 | ///
36 | NTSTATUS RemoveVEH();
37 |
38 | private:
39 | MExcept( const MExcept& ) = delete;
40 | MExcept& operator =(const MExcept&) = delete;
41 |
42 | private:
43 | class Process& _proc; // Underlying process
44 | MemBlock _pVEHCode; // VEH function codecave
45 | size_t _hVEH = 0; // VEH handle
46 | };
47 |
48 | }
--------------------------------------------------------------------------------
/src/BlackBone/ImageNET.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Winheaders.h"
4 | #include
5 | #include
6 |
7 | #include