├── .gitignore ├── AStyle.dll ├── AStyleWhore.exe ├── FunctionGraph.cpp ├── FunctionGraph.h ├── angelscript ├── angelscript.h ├── angelscript.lib ├── angelscript64.lib ├── sampleScript.as ├── scriptstdstring.cpp └── scriptstdstring.h ├── hooks └── pre-commit ├── icons.h ├── install.bat ├── install32.bat ├── install64.bat ├── pluginmain.cpp ├── pluginmain.h ├── pluginsdk ├── DeviceNameResolver │ ├── DeviceNameResolver.h │ ├── DeviceNameResolver_x64.a │ ├── DeviceNameResolver_x64.lib │ ├── DeviceNameResolver_x86.a │ └── DeviceNameResolver_x86.lib ├── TitanEngine │ ├── TitanEngine.h │ ├── TitanEngine_x64.a │ ├── TitanEngine_x64.lib │ ├── TitanEngine_x86.a │ └── TitanEngine_x86.lib ├── XEDParse │ ├── XEDParse.h │ ├── XEDParse_x64.a │ ├── XEDParse_x64.lib │ ├── XEDParse_x86.a │ └── XEDParse_x86.lib ├── _dbgfunctions.h ├── _plugin_types.h ├── _plugins.h ├── _scriptapi.h ├── _scriptapi_argument.h ├── _scriptapi_assembler.h ├── _scriptapi_bookmark.h ├── _scriptapi_comment.h ├── _scriptapi_debug.h ├── _scriptapi_flag.h ├── _scriptapi_function.h ├── _scriptapi_gui.h ├── _scriptapi_label.h ├── _scriptapi_memory.h ├── _scriptapi_misc.h ├── _scriptapi_module.h ├── _scriptapi_pattern.h ├── _scriptapi_register.h ├── _scriptapi_stack.h ├── _scriptapi_symbol.h ├── bridgegraph.h ├── bridgelist.h ├── bridgemain.h ├── capstone │ ├── arm.h │ ├── arm64.h │ ├── capstone.h │ ├── capstone_x64.lib │ ├── capstone_x86.lib │ ├── m68k.h │ ├── mips.h │ ├── platform.h │ ├── ppc.h │ ├── sparc.h │ ├── systemz.h │ ├── x86.h │ └── xcore.h ├── dbghelp │ ├── dbghelp.h │ ├── dbghelp_x64.a │ ├── dbghelp_x64.lib │ ├── dbghelp_x86.a │ └── dbghelp_x86.lib ├── jansson │ ├── jansson.h │ ├── jansson_config.h │ ├── jansson_x64.a │ ├── jansson_x64.lib │ ├── jansson_x64dbg.h │ ├── jansson_x86.a │ └── jansson_x86.lib ├── lz4 │ ├── lz4.h │ ├── lz4_x64.a │ ├── lz4_x64.lib │ ├── lz4_x86.a │ ├── lz4_x86.lib │ ├── lz4file.h │ └── lz4hc.h ├── x32bridge.lib ├── x32dbg.lib ├── x64bridge.lib ├── x64dbg.lib └── yara │ ├── yara.h │ ├── yara │ ├── ahocorasick.h │ ├── arena.h │ ├── atoms.h │ ├── compiler.h │ ├── elf.h │ ├── error.h │ ├── exec.h │ ├── exefiles.h │ ├── filemap.h │ ├── globals.h │ ├── hash.h │ ├── hex_lexer.h │ ├── lexer.h │ ├── libyara.h │ ├── limits.h │ ├── mem.h │ ├── modules.h │ ├── object.h │ ├── parser.h │ ├── pe.h │ ├── proc.h │ ├── re.h │ ├── re_lexer.h │ ├── rules.h │ ├── scan.h │ ├── sizedstr.h │ ├── stream.h │ ├── strutils.h │ ├── threading.h │ ├── types.h │ └── utils.h │ ├── yara_x64.lib │ └── yara_x86.lib ├── script.cpp ├── script.h ├── test.cpp ├── test.h ├── x64_dbg_testplugin.cbp ├── x64_dbg_testplugin.sln ├── x64_dbg_testplugin.vcxproj ├── x64_dbg_testplugin.vcxproj.filters └── x64_dbg_testplugin.vcxproj.user /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | Win32/ 4 | x64/ 5 | *.opensdf 6 | *.sdf 7 | *.suo 8 | *.layout 9 | *.depend 10 | ipch/ 11 | -------------------------------------------------------------------------------- /AStyle.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/AStyle.dll -------------------------------------------------------------------------------- /AStyleWhore.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/AStyleWhore.exe -------------------------------------------------------------------------------- /FunctionGraph.cpp: -------------------------------------------------------------------------------- 1 | #include "FunctionGraph.h" 2 | #include 3 | #include 4 | #include 5 | 6 | struct previous_edge_struct_s 7 | { 8 | ULONG_PTR source; 9 | ULONG_PTR targetfalse; 10 | ULONG_PTR targettrue; 11 | }; 12 | 13 | #define TEXTLEN 256 14 | 15 | static char vcg_params[] = "manhattan_edges: yes\n" 16 | "layoutalgorithm: mindepth\n" 17 | "finetuning: no\n" 18 | "layout_downfactor: 100\n" 19 | "layout_upfactor: 0\n" 20 | "layout_nearfactor: 0\n" 21 | "xlspace: 12\n" 22 | "yspace: 30\n" 23 | "colorentry 32: 0 0 0\n" 24 | "colorentry 33: 0 0 255\n" 25 | "colorentry 34: 0 0 255\n" 26 | "colorentry 35: 128 128 128\n" 27 | "colorentry 36: 128 128 128\n" 28 | "colorentry 37: 0 0 128\n" 29 | "colorentry 38: 0 0 128\n" 30 | "colorentry 39: 0 0 255\n" 31 | "colorentry 40: 0 0 255\n" 32 | "colorentry 41: 0 0 128\n" 33 | "colorentry 42: 0 128 0\n" 34 | "colorentry 43: 0 255 0\n" 35 | "colorentry 44: 0 128 0\n" 36 | "colorentry 45: 255 128 0\n" 37 | "colorentry 46: 0 128 0\n" 38 | "colorentry 47: 128 128 255\n" 39 | "colorentry 48: 255 0 0\n" 40 | "colorentry 49: 128 128 0\n" 41 | "colorentry 50: 1 1 1\n" 42 | "colorentry 51: 192 192 192\n" 43 | "colorentry 52: 0 0 255\n" 44 | "colorentry 53: 0 0 255\n" 45 | "colorentry 54: 0 0 255\n" 46 | "colorentry 55: 128 128 128\n" 47 | "colorentry 56: 128 128 255\n" 48 | "colorentry 57: 0 128 0\n" 49 | "colorentry 58: 0 0 128\n" 50 | "colorentry 59: 0 0 255\n" 51 | "colorentry 60: 128 0 128\n" 52 | "colorentry 61: 0 128 0\n" 53 | "colorentry 62: 0 128 0\n" 54 | "colorentry 63: 0 128 64\n" 55 | "colorentry 64: 0 0 128\n" 56 | "colorentry 65: 0 0 128\n" 57 | "colorentry 66: 255 0 255\n" 58 | "colorentry 67: 128 128 0\n" 59 | "colorentry 68: 0 0 128\n" 60 | "colorentry 69: 0 0 255\n" 61 | "colorentry 70: 0 0 128\n" 62 | "colorentry 71: 0 0 255\n" 63 | "colorentry 72: 0 0 0\n" 64 | "colorentry 73: 255 255 255\n" 65 | "colorentry 74: 192 187 175\n" 66 | "colorentry 75: 0 255 255\n" 67 | "colorentry 76: 0 0 0\n" 68 | "colorentry 77: 128 0 0\n" 69 | "colorentry 78: 128 128 128\n" 70 | "colorentry 79: 128 128 0\n" 71 | "colorentry 80: 255 0 255\n" 72 | "colorentry 81: 0 0 0\n" 73 | "colorentry 82: 0 0 255\n" 74 | "colorentry 83: 100 255 255\n"; 75 | 76 | //escape comments 77 | static void sanitize(const char* comment, char* cleaned) 78 | { 79 | char* t; 80 | for(t = cleaned; *comment; comment++) 81 | { 82 | if(*comment == '"') 83 | { 84 | *t++ = '\\'; 85 | *t = '"'; 86 | } 87 | else if(*comment == '\\') 88 | { 89 | *t++ = '\\'; 90 | *t = '\\'; 91 | } 92 | else 93 | { 94 | *t = *comment; 95 | } 96 | t++; 97 | } 98 | *t = '\0'; 99 | } 100 | 101 | bool make_flowchart(ULONG_PTR start, ULONG_PTR end, const wchar_t* szTargetFile, GETINSTRINFO getInstrInfo) 102 | { 103 | HANDLE temp_file = CreateFileW(szTargetFile, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 104 | if(temp_file == INVALID_HANDLE_VALUE) 105 | return false; 106 | 107 | char buffer[TEXTLEN * 2 + 4]; 108 | ULONG_PTR currentnode = start; 109 | 110 | int writelen = sprintf(buffer, "graph: {\ntitle: \"Graph of %p\"\n", start); 111 | DWORD len_written; 112 | WriteFile(temp_file, buffer, (DWORD) writelen, &len_written, NULL); 113 | WriteFile(temp_file, vcg_params, (DWORD) strlen(vcg_params), &len_written, NULL); 114 | writelen = sprintf(buffer, "node: { title: \"%p\" vertical_order: 0 color: 83 fontname: \"courR12\" label: \"%p:", currentnode, currentnode); 115 | WriteFile(temp_file, buffer, (DWORD) writelen, &len_written, NULL); 116 | 117 | std::set nodelist; //list of node addresses, just to make sure we are not handling nodes multiple times 118 | std::list disasmlist; 119 | ULONG_PTR psize = 0; 120 | ULONG_PTR current_addr = start; 121 | 122 | // first pass - disassemble instructions and enumerate nodes 123 | do 124 | { 125 | current_addr += psize; 126 | 127 | //get instr_info 128 | instr_info disasm_result; 129 | ULONG_PTR next_addr = getInstrInfo(current_addr, &disasm_result); 130 | psize = next_addr - current_addr; 131 | if(psize <= 0) 132 | psize = 1; 133 | 134 | //add instr_info to list 135 | disasmlist.push_back(disasm_result); 136 | 137 | // enumerate nodes 138 | if(currentnode == 0) 139 | { 140 | currentnode = current_addr; 141 | nodelist.insert(currentnode); 142 | } 143 | if((disasm_result.jmpaddr >= start) && (disasm_result.jmpaddr < end)) 144 | { 145 | // this is a jump - start of an edge and pointer to a node 146 | nodelist.insert(disasm_result.jmpaddr); 147 | currentnode = 0; // update current_addrnode on next pass 148 | } 149 | } 150 | while(current_addr + psize <= end); 151 | 152 | // walk through saved disasm list and split into nodes 153 | currentnode = start; 154 | bool orphannode = true; 155 | previous_edge_struct_s previous_edge; 156 | memset(&previous_edge, 0, sizeof(previous_edge_struct_s)); 157 | std::string edgelist; 158 | for(std::list::iterator i = disasmlist.begin(); i != disasmlist.end(); ++i) 159 | { 160 | instr_info disasm_result = *i; 161 | current_addr = disasm_result.addr; 162 | 163 | //node contents (address) 164 | if(nodelist.find(current_addr) != nodelist.end()) //found current_addr in set 165 | { 166 | if(orphannode) 167 | { 168 | writelen = sprintf(buffer, "edge: { sourcename: \"%p\" targetname: \"%p\" }\n", currentnode, current_addr); 169 | edgelist += buffer; 170 | } 171 | orphannode = true; 172 | currentnode = current_addr; 173 | writelen = sprintf(buffer, "\" }\n"); 174 | WriteFile(temp_file, buffer, (DWORD) writelen, &len_written, NULL); 175 | writelen = sprintf(buffer, "node: { title: \"%p\" color: 83 fontname: \"courR12\" label: \"%p:", current_addr, current_addr); 176 | WriteFile(temp_file, buffer, (DWORD) writelen, &len_written, NULL); 177 | } 178 | 179 | //node contents (disassembly) 180 | if(disasm_result.comment.length()) 181 | { 182 | char clean_comment[TEXTLEN * 2]; 183 | sanitize(disasm_result.comment.c_str(), clean_comment); 184 | writelen = sprintf(buffer, "\n%s\t; %s", disasm_result.instrText.c_str(), clean_comment); 185 | } 186 | else 187 | { 188 | writelen = sprintf(buffer, "\n%s", disasm_result.instrText.c_str()); 189 | } 190 | 191 | WriteFile(temp_file, buffer, (DWORD)writelen, &len_written, NULL); 192 | 193 | if(previous_edge.source != 0) 194 | { 195 | // append stored edge info with currentnode info to edgelist buffer 196 | previous_edge.targetfalse = currentnode; 197 | writelen = sprintf(buffer, "edge: { sourcename: \"%p\" targetname: \"%p\" label: \"false\" color: red }\n", previous_edge.source, previous_edge.targetfalse); 198 | edgelist += buffer; 199 | writelen = sprintf(buffer, "edge: { sourcename: \"%p\" targetname: \"%p\" label: \"true\" color: darkgreen }\n", previous_edge.source, previous_edge.targettrue); 200 | edgelist += buffer; 201 | previous_edge.source = 0; 202 | } 203 | 204 | if((disasm_result.jmpaddr >= start) && (disasm_result.jmpaddr < end)) 205 | { 206 | // this is a jump - start of an edge and pointer to a node 207 | orphannode = false; 208 | previous_edge.source = currentnode; 209 | previous_edge.targettrue = disasm_result.jmpaddr; 210 | previous_edge.targetfalse = 0; 211 | 212 | if(!_stricmp(disasm_result.instrText.substr(0, 3).c_str(), "jmp")) 213 | { 214 | // straight jmp, no true/false 215 | writelen = sprintf(buffer, "edge: { sourcename: \"%p\" targetname: \"%p\" }\n", previous_edge.source, previous_edge.targettrue); 216 | edgelist += buffer; 217 | previous_edge.source = 0; 218 | } 219 | } 220 | } 221 | 222 | // close last node 223 | writelen = sprintf(buffer, "\" vertical_order: %d }\n", nodelist.size()); 224 | WriteFile(temp_file, buffer, (DWORD)writelen, &len_written, NULL); 225 | 226 | // write edgelist 227 | WriteFile(temp_file, edgelist.c_str(), (DWORD)edgelist.length(), &len_written, NULL); 228 | 229 | writelen = sprintf(buffer, "}\n"); 230 | WriteFile(temp_file, buffer, (DWORD)writelen, &len_written, NULL); 231 | 232 | CloseHandle(temp_file); 233 | 234 | return true; 235 | } 236 | -------------------------------------------------------------------------------- /FunctionGraph.h: -------------------------------------------------------------------------------- 1 | #ifndef _FUNCTIONGRAPH_H 2 | #define _FUNCTIONGRAPH_H 3 | 4 | #include 5 | #include 6 | 7 | struct instr_info 8 | { 9 | ULONG_PTR addr; 10 | ULONG_PTR jmpaddr; 11 | std::string instrText; 12 | std::string comment; 13 | }; 14 | 15 | typedef ULONG_PTR(*GETINSTRINFO)(ULONG_PTR addr, instr_info* info); 16 | 17 | bool make_flowchart(ULONG_PTR start, ULONG_PTR end, const wchar_t* szTargetFile, GETINSTRINFO getInstrInfo); 18 | 19 | #endif //_FUNCTIONGRAPH_H -------------------------------------------------------------------------------- /angelscript/angelscript.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/angelscript/angelscript.lib -------------------------------------------------------------------------------- /angelscript/angelscript64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/angelscript/angelscript64.lib -------------------------------------------------------------------------------- /angelscript/sampleScript.as: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | // Print the value that we received 4 | Print("Script started!\n"); 5 | 6 | // Do some stepping 7 | for(int i=0; i<100; i++) { 8 | Print("Stepping " + (i+1) + "...\n"); 9 | StepIn(); 10 | } 11 | StepOver(); 12 | StepOut(); 13 | } 14 | -------------------------------------------------------------------------------- /angelscript/scriptstdstring.h: -------------------------------------------------------------------------------- 1 | // 2 | // Script std::string 3 | // 4 | // This function registers the std::string type with AngelScript to be used as the default string type. 5 | // 6 | // The string type is registered as a value type, thus may have performance issues if a lot of 7 | // string operations are performed in the script. However, for relatively few operations, this should 8 | // not cause any problem for most applications. 9 | // 10 | 11 | #ifndef SCRIPTSTDSTRING_H 12 | #define SCRIPTSTDSTRING_H 13 | 14 | #ifndef ANGELSCRIPT_H 15 | // Avoid having to inform include path if header is already include before 16 | #include "angelscript.h" 17 | #endif 18 | 19 | #include 20 | 21 | //--------------------------- 22 | // Compilation settings 23 | // 24 | 25 | // The use of the string pool can improve performance quite drastically 26 | // for scripts that work with a lot of literal string constants. 27 | // 28 | // 1 = on 29 | // 0 = off 30 | 31 | #ifndef AS_USE_STRINGPOOL 32 | #define AS_USE_STRINGPOOL 1 33 | #endif 34 | 35 | // Sometimes it may be desired to use the same method names as used by C++ STL. 36 | // This may for example reduce time when converting code from script to C++ or 37 | // back. 38 | // 39 | // 0 = off 40 | // 1 = on 41 | 42 | #ifndef AS_USE_STLNAMES 43 | #define AS_USE_STLNAMES 0 44 | #endif 45 | 46 | BEGIN_AS_NAMESPACE 47 | 48 | void RegisterStdString(asIScriptEngine* engine); 49 | void RegisterStdStringUtils(asIScriptEngine* engine); 50 | 51 | END_AS_NAMESPACE 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Simple script to auto-format every source file before committing. 4 | # 5 | 6 | #check if the formatter is present 7 | if [ ! -f ./AStyleWhore.exe ]; then 8 | echo "AStyleWhore not found!" 9 | exit 0 10 | fi 11 | 12 | #format the code 13 | "./AStyleWhore.exe" Silent 14 | 15 | #exit when nothing needs to be done 16 | if [ $? == 0 ]; then 17 | exit 0 18 | fi 19 | 20 | #stage the formatted files (when staged in this commit) 21 | gitFiles=$(git diff-index --name-only --cached HEAD) 22 | if [[ -n "${gitFiles}" ]]; then 23 | for fname in $gitFiles; do 24 | git add --all -- "${fname}" 25 | done 26 | fi 27 | 28 | #cancel commit if the changes were undone by the formatting 29 | gitFiles=$(git diff-index --name-only --cached HEAD) 30 | if [ -z "$gitFiles" ]; then 31 | "./AStyleWhore.exe" "After formatting, no files were staged..." 32 | exit 1 33 | fi 34 | -------------------------------------------------------------------------------- /icons.h: -------------------------------------------------------------------------------- 1 | #ifndef _ICONS_H 2 | #define _ICONS_H 3 | 4 | static unsigned char icon_rocket[762] = 5 | { 6 | 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 7 | 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 8 | 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 9 | 0xF3, 0xFF, 0x61, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 10 | 0x74, 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 11 | 0x41, 0x64, 0x6F, 0x62, 0x65, 0x20, 0x49, 0x6D, 0x61, 0x67, 12 | 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x71, 0xC9, 0x65, 0x3C, 13 | 0x00, 0x00, 0x02, 0x9C, 0x49, 0x44, 0x41, 0x54, 0x78, 0xDA, 14 | 0x84, 0x53, 0x5F, 0x48, 0x53, 0x61, 0x14, 0xFF, 0x7D, 0x77, 15 | 0xB7, 0xCD, 0x70, 0xFD, 0xD9, 0x6A, 0xA4, 0x73, 0xEB, 0x1F, 16 | 0xC3, 0x94, 0xB6, 0x5D, 0x72, 0x62, 0xA1, 0x08, 0x8A, 0x84, 17 | 0x82, 0x42, 0x24, 0x95, 0xD1, 0xC3, 0x4A, 0xCB, 0xE8, 0xA9, 18 | 0x57, 0x09, 0x7A, 0x2C, 0x0A, 0x7B, 0xA8, 0x40, 0x82, 0x09, 19 | 0xBD, 0xF8, 0x62, 0x0F, 0xBE, 0x04, 0x3E, 0xA4, 0x0F, 0x19, 20 | 0xE4, 0x88, 0x89, 0x6D, 0x12, 0x2B, 0x88, 0x48, 0x99, 0xA3, 21 | 0x39, 0x75, 0x13, 0xAE, 0x4D, 0xE7, 0xEE, 0x76, 0xEF, 0xED, 22 | 0xFB, 0xAE, 0xDD, 0xE1, 0x14, 0xEA, 0xC0, 0x8F, 0xEF, 0xE3, 23 | 0x9C, 0xFB, 0xFB, 0x9D, 0x73, 0xBE, 0x73, 0x2E, 0xC1, 0x2E, 24 | 0x33, 0x18, 0x0C, 0xE0, 0x38, 0x0E, 0xB2, 0x2C, 0x43, 0x51, 25 | 0x94, 0x9D, 0x21, 0xE1, 0x27, 0x21, 0x8F, 0x56, 0x55, 0xD5, 26 | 0x9A, 0x05, 0x4C, 0x1B, 0xD4, 0x91, 0x00, 0x86, 0x79, 0xBB, 27 | 0xDD, 0x0E, 0x42, 0x88, 0x06, 0x66, 0xEC, 0x8C, 0xC7, 0xE3, 28 | 0xBB, 0x75, 0x05, 0x8A, 0xF3, 0xCE, 0x9C, 0xD4, 0x55, 0xE8, 29 | 0xB9, 0x86, 0xEA, 0xDA, 0x5A, 0x48, 0x0B, 0x0B, 0x78, 0x3B, 30 | 0x3A, 0x7A, 0x87, 0xAF, 0xAC, 0xAC, 0xD4, 0x32, 0x32, 0xE8, 31 | 0xB6, 0x4B, 0x40, 0x23, 0x4B, 0x52, 0x3E, 0x30, 0x37, 0x17, 32 | 0x81, 0xF3, 0xD5, 0x6B, 0x4C, 0x09, 0x35, 0xF0, 0xD5, 0xD7, 33 | 0xE3, 0x10, 0x20, 0x71, 0xF8, 0xB7, 0x15, 0xC9, 0xC1, 0xE0, 34 | 0x34, 0xAB, 0x0F, 0xE1, 0xF0, 0x17, 0x78, 0x83, 0xDF, 0xB0, 35 | 0x10, 0x8B, 0xE1, 0x08, 0x21, 0x5B, 0xDC, 0xFF, 0xC8, 0xB3, 36 | 0x9F, 0xC3, 0x81, 0xB3, 0x6E, 0x2F, 0x0E, 0x1C, 0x6F, 0xC1, 37 | 0xEC, 0xEC, 0x57, 0x58, 0x2C, 0x15, 0x88, 0x51, 0x72, 0xC5, 38 | 0xD8, 0xA4, 0x78, 0x14, 0xD8, 0x22, 0x3E, 0x9F, 0x6F, 0x4F, 39 | 0x0B, 0xA1, 0x50, 0xA8, 0x98, 0xB9, 0xF3, 0x72, 0x2F, 0x0E, 40 | 0x57, 0x35, 0x6B, 0xFE, 0x54, 0xEC, 0x03, 0x5E, 0x0C, 0x0E, 41 | 0xC2, 0x68, 0xE4, 0xC4, 0x8E, 0x8E, 0xC6, 0x97, 0x65, 0x65, 42 | 0x65, 0xEF, 0x78, 0x16, 0x50, 0x55, 0xF5, 0x3A, 0x7D, 0x71, 43 | 0x27, 0xBB, 0x67, 0x32, 0x99, 0x02, 0x7D, 0xC8, 0x8D, 0x5C, 44 | 0x4E, 0x0A, 0x2C, 0x2D, 0x25, 0xE0, 0x3C, 0xE9, 0x41, 0xB5, 45 | 0xD7, 0xA7, 0x09, 0x7C, 0xE7, 0xC5, 0x12, 0x32, 0xFD, 0xEE, 46 | 0x13, 0x11, 0x04, 0x96, 0x0C, 0x03, 0x43, 0x43, 0x43, 0x4F, 47 | 0x57, 0x56, 0x56, 0x90, 0x4E, 0xA7, 0xD1, 0xD4, 0xD4, 0x84, 48 | 0x48, 0x24, 0x82, 0x86, 0x86, 0x0B, 0xF8, 0x31, 0xBF, 0x86, 49 | 0x50, 0x34, 0xAD, 0x55, 0xD8, 0x5C, 0x57, 0x25, 0xF6, 0xDD, 50 | 0xEC, 0x2C, 0x92, 0xB5, 0xB1, 0x5B, 0xAD, 0x56, 0x36, 0x73, 51 | 0x79, 0x66, 0x66, 0xA6, 0xE0, 0x72, 0xB9, 0xEA, 0x19, 0x99, 52 | 0xF5, 0xC8, 0x19, 0x38, 0x4C, 0x87, 0x3F, 0xA2, 0xE6, 0x94, 53 | 0x00, 0xA1, 0xC6, 0x41, 0x71, 0x4C, 0xBC, 0x7A, 0xA5, 0xAD, 54 | 0x84, 0xAC, 0x8D, 0xDD, 0x66, 0xB3, 0xB1, 0x16, 0x58, 0xE6, 55 | 0xBB, 0xD1, 0x68, 0x34, 0xC0, 0xC8, 0x39, 0x29, 0x87, 0xE4, 56 | 0xEF, 0x24, 0x14, 0x5E, 0x01, 0x51, 0x09, 0x5A, 0xCF, 0x5D, 57 | 0x2A, 0x29, 0x5B, 0x27, 0x6F, 0x6E, 0x6E, 0x82, 0xEB, 0x5B, 58 | 0x5D, 0xC5, 0xED, 0x54, 0x0A, 0xFD, 0xAA, 0x9A, 0x77, 0xBB, 59 | 0xDD, 0xF7, 0x4D, 0xE5, 0xA6, 0x22, 0xD9, 0x62, 0xB1, 0xC0, 60 | 0xE1, 0x74, 0xAC, 0x7B, 0x3C, 0x27, 0x86, 0x77, 0x92, 0x19, 61 | 0x71, 0x71, 0x71, 0x51, 0x03, 0x3F, 0xB0, 0x2D, 0x66, 0x43, 62 | 0x05, 0x6E, 0x9C, 0xE9, 0xC1, 0x7C, 0x7B, 0x5B, 0xFB, 0x93, 63 | 0x91, 0xF1, 0x91, 0x07, 0xCC, 0x69, 0x2E, 0x37, 0xAF, 0x07, 64 | 0xC7, 0x83, 0x07, 0xCD, 0x66, 0x73, 0x3E, 0x9B, 0xCD, 0x6A, 65 | 0xE4, 0x14, 0x4D, 0xC6, 0x04, 0x74, 0xD3, 0x67, 0xD7, 0x02, 66 | 0x3F, 0x92, 0xBD, 0x5D, 0xEA, 0xE9, 0xC7, 0xF7, 0x14, 0xBB, 67 | 0xBF, 0xCB, 0xFF, 0x4C, 0x27, 0x7B, 0x1A, 0x3D, 0xAC, 0x45, 68 | 0x22, 0x8A, 0x22, 0x12, 0x89, 0x44, 0x09, 0x59, 0x17, 0xD8, 69 | 0x4F, 0xB3, 0x5B, 0x70, 0x11, 0x71, 0x4C, 0x22, 0xD9, 0x3F, 70 | 0xA6, 0xD8, 0x6F, 0xA9, 0xEA, 0xAF, 0xEE, 0xD6, 0xEE, 0xC0, 71 | 0xC4, 0xFB, 0x89, 0x37, 0x9C, 0x91, 0x43, 0x3E, 0x9F, 0xE7, 72 | 0xE8, 0x78, 0x51, 0x28, 0x14, 0xF6, 0x6C, 0x1B, 0x59, 0x03, 73 | 0x1C, 0xB2, 0x17, 0xEE, 0xEC, 0x32, 0x5C, 0x53, 0xCB, 0xC8, 74 | 0x3E, 0x07, 0x22, 0x73, 0x74, 0xC3, 0x68, 0xCC, 0xC4, 0xF3, 75 | 0x7C, 0x35, 0x1D, 0x5F, 0x1D, 0xAD, 0x60, 0x99, 0x8A, 0x8C, 76 | 0x53, 0x5F, 0x0E, 0xDB, 0x31, 0x06, 0x89, 0x81, 0x09, 0x58, 77 | 0xA9, 0x6E, 0xF9, 0x43, 0x40, 0x1C, 0x06, 0x58, 0x0A, 0x23, 78 | 0xC5, 0x3E, 0x0A, 0x5E, 0x5B, 0x7E, 0xBA, 0x67, 0x14, 0xEC, 79 | 0xBF, 0x66, 0x31, 0xF9, 0xEF, 0xA9, 0xDF, 0xE5, 0x3F, 0x02, 80 | 0x0C, 0x00, 0xA5, 0xE1, 0x2F, 0x71, 0xD8, 0x1A, 0xDF, 0xDB, 81 | 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 82 | 0x60, 0x82 83 | }; 84 | 85 | static unsigned char icon_adler32[664] = 86 | { 87 | 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 88 | 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 89 | 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 90 | 0xF3, 0xFF, 0x61, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 91 | 0x74, 0x53, 0x6F, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x00, 92 | 0x41, 0x64, 0x6F, 0x62, 0x65, 0x20, 0x49, 0x6D, 0x61, 0x67, 93 | 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x71, 0xC9, 0x65, 0x3C, 94 | 0x00, 0x00, 0x02, 0x3A, 0x49, 0x44, 0x41, 0x54, 0x78, 0xDA, 95 | 0x94, 0x93, 0x5F, 0x68, 0x92, 0x51, 0x18, 0xC6, 0x9F, 0xF3, 96 | 0x7D, 0x1A, 0x7C, 0x3A, 0x06, 0xC2, 0x24, 0x02, 0xBB, 0x30, 97 | 0x2A, 0x71, 0x88, 0x8D, 0xA0, 0x6E, 0xB2, 0xD2, 0x41, 0x17, 98 | 0x81, 0xCA, 0x17, 0x2B, 0xFA, 0x03, 0x0A, 0xC1, 0x12, 0x26, 99 | 0x06, 0x6D, 0xC4, 0x90, 0xBA, 0x30, 0x2F, 0xB2, 0x3F, 0x17, 100 | 0x5D, 0xEC, 0x22, 0xA8, 0x0D, 0x22, 0xA4, 0xBA, 0xC8, 0xD1, 101 | 0x4D, 0xD1, 0x45, 0x20, 0x6B, 0x83, 0xC8, 0x88, 0x99, 0x11, 102 | 0xC4, 0xA8, 0x51, 0x17, 0x93, 0x2E, 0xEC, 0x62, 0xD6, 0x14, 103 | 0x75, 0x47, 0x4F, 0xBE, 0x67, 0x4C, 0x08, 0x6C, 0xE1, 0x81, 104 | 0xC3, 0xCB, 0x7B, 0xDE, 0xDF, 0xF3, 0xF0, 0x9E, 0xF7, 0x3B, 105 | 0x1F, 0x53, 0x27, 0xD5, 0x3B, 0x00, 0xF6, 0xA1, 0xF7, 0x55, 106 | 0xE0, 0xB7, 0xF8, 0x84, 0x01, 0x2D, 0x0C, 0xF1, 0x2B, 0x4F, 107 | 0x7C, 0xE7, 0xE6, 0x9E, 0xC1, 0x6A, 0xB5, 0xFE, 0x57, 0x55, 108 | 0x2A, 0x95, 0xF0, 0xD8, 0x7B, 0x02, 0x86, 0xD4, 0x59, 0x46, 109 | 0xB9, 0xD2, 0x36, 0x60, 0x67, 0xB2, 0xB3, 0x68, 0x34, 0x1A, 110 | 0x18, 0xEE, 0xDF, 0x8E, 0x62, 0xB1, 0xB8, 0x65, 0x24, 0x8E, 111 | 0x78, 0xD2, 0x6D, 0x18, 0x34, 0xC1, 0x34, 0x4D, 0x43, 0xA5, 112 | 0x52, 0xC1, 0x60, 0x5D, 0xC3, 0xF2, 0xDB, 0x65, 0x1C, 0xB7, 113 | 0xEE, 0xEC, 0x1A, 0xA9, 0x4E, 0x1C, 0xF1, 0xA4, 0x23, 0x03, 114 | 0xA6, 0x5E, 0x54, 0x5F, 0xCF, 0x8E, 0x26, 0x8F, 0x38, 0xD6, 115 | 0x8C, 0xB8, 0x7A, 0x3B, 0x8B, 0x5F, 0x95, 0xE6, 0x3F, 0xDB, 116 | 0xEF, 0x37, 0xAB, 0xB8, 0x3E, 0x39, 0x8C, 0xA5, 0xBE, 0x75, 117 | 0x8C, 0xCC, 0x24, 0xE6, 0xF9, 0x14, 0x3F, 0x0A, 0x75, 0x4C, 118 | 0x9D, 0xD7, 0x1F, 0xE9, 0xC2, 0x15, 0x73, 0x09, 0xAF, 0xD7, 119 | 0x2B, 0x0A, 0x85, 0x82, 0x68, 0xB5, 0x5A, 0x22, 0x9F, 0xCF, 120 | 0x8B, 0x50, 0x28, 0x24, 0x23, 0xE5, 0x74, 0x4E, 0x75, 0xE2, 121 | 0x88, 0x27, 0x9D, 0x10, 0x02, 0x8A, 0x68, 0x0A, 0x76, 0xDA, 122 | 0xEE, 0xC4, 0xDC, 0xD8, 0x05, 0x70, 0xCE, 0x91, 0x4A, 0xA5, 123 | 0xA0, 0xEB, 0x3A, 0x9C, 0x4E, 0x27, 0xCA, 0xE5, 0x32, 0x12, 124 | 0x89, 0x84, 0xCC, 0x1D, 0x0E, 0x87, 0xAC, 0x13, 0x47, 0x3C, 125 | 0xE9, 0xA8, 0x2B, 0x03, 0xDD, 0xE5, 0xE1, 0xE7, 0x3C, 0xAE, 126 | 0xBD, 0xFB, 0x06, 0x0B, 0xB7, 0x20, 0x10, 0x08, 0xC0, 0xEF, 127 | 0xF7, 0x23, 0x9D, 0x4E, 0xA3, 0x56, 0xAB, 0xC1, 0xE3, 0xF1, 128 | 0x20, 0x12, 0x89, 0x20, 0x93, 0xC9, 0x48, 0x83, 0x43, 0x53, 129 | 0x77, 0x61, 0x3F, 0x68, 0xEF, 0xCC, 0x40, 0x01, 0x87, 0x72, 130 | 0xD2, 0xB6, 0x07, 0xAF, 0xCE, 0x87, 0xE4, 0x84, 0x49, 0x18, 131 | 0x0C, 0x06, 0xA5, 0x11, 0x19, 0x84, 0xC3, 0x61, 0x24, 0x93, 132 | 0x49, 0x79, 0x4E, 0x75, 0xE2, 0x88, 0x27, 0xDD, 0x46, 0x07, 133 | 0x1C, 0x2C, 0xFD, 0xE5, 0x23, 0x6E, 0x2C, 0xAE, 0xC0, 0xB4, 134 | 0x6E, 0x42, 0x2C, 0x16, 0x83, 0xDB, 0xED, 0x46, 0x2E, 0x97, 135 | 0x03, 0x63, 0x4C, 0xEE, 0x78, 0x3C, 0x2E, 0x87, 0x48, 0x9D, 136 | 0xF9, 0xEE, 0x3F, 0x80, 0x6D, 0xBF, 0x8D, 0x0C, 0x58, 0xC7, 137 | 0x60, 0x64, 0xC7, 0x2E, 0xB8, 0x7C, 0x4E, 0x5C, 0x7E, 0x9F, 138 | 0x45, 0x34, 0x1A, 0xFD, 0x6B, 0xF2, 0x74, 0x85, 0xCD, 0x65, 139 | 0xB5, 0x68, 0x98, 0xF6, 0x1D, 0xC3, 0x27, 0x53, 0x1D, 0x0B, 140 | 0x7C, 0xA1, 0x73, 0x05, 0xF6, 0xB4, 0xF8, 0x15, 0x97, 0xBE, 141 | 0xBF, 0xC1, 0xCD, 0xF1, 0xC3, 0x60, 0x5E, 0x86, 0x97, 0xF7, 142 | 0x4E, 0x75, 0x8D, 0x54, 0x27, 0x8E, 0xF8, 0xCD, 0x0E, 0x14, 143 | 0x34, 0xC0, 0xAA, 0xD5, 0x2A, 0x8C, 0x46, 0x23, 0x16, 0xD5, 144 | 0xDF, 0x18, 0x18, 0x1C, 0xC0, 0xF3, 0x9F, 0x2B, 0x5D, 0x23, 145 | 0xD5, 0x89, 0x23, 0x9E, 0x74, 0xD2, 0x40, 0x94, 0x05, 0x9B, 146 | 0xDE, 0x7D, 0x00, 0xED, 0x6F, 0x8D, 0x17, 0xAB, 0x3F, 0x60, 147 | 0x36, 0x9B, 0xB7, 0x8C, 0xC4, 0x11, 0x4F, 0x3A, 0xF9, 0x12, 148 | 0xB1, 0x17, 0x33, 0xE8, 0xC3, 0x50, 0xCF, 0xFF, 0xE2, 0x1A, 149 | 0x3E, 0x88, 0x25, 0x31, 0x4A, 0x2E, 0xDB, 0xDA, 0xDB, 0xD2, 150 | 0xDE, 0x6A, 0x0F, 0x72, 0x7A, 0xEF, 0xAB, 0xED, 0x97, 0x58, 151 | 0xFF, 0x23, 0xC0, 0x00, 0xB1, 0x22, 0x28, 0x4D, 0x19, 0x8C, 152 | 0xC8, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 153 | 0xAE, 0x42, 0x60, 0x82 154 | }; 155 | 156 | #endif //_ICONS_H -------------------------------------------------------------------------------- /install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo Run this to install the auto-format hook. 3 | copy hooks\pre-commit .git\hooks\pre-commit -------------------------------------------------------------------------------- /install32.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set PLUGINDIR=..\x64dbg\bin\x32\plugins 3 | mkdir %PLUGINDIR% 4 | copy bin\x32\testplugin.dll %PLUGINDIR%\testplugin.dp32 -------------------------------------------------------------------------------- /install64.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set PLUGINDIR=..\x64dbg\bin\x64\plugins 3 | mkdir %PLUGINDIR% 4 | copy bin\x64\testplugin.dll %PLUGINDIR%\testplugin.dp64 -------------------------------------------------------------------------------- /pluginmain.cpp: -------------------------------------------------------------------------------- 1 | #include "pluginmain.h" 2 | #include "test.h" 3 | 4 | #define plugin_name "testplugin" 5 | #define plugin_version 1 6 | 7 | int pluginHandle; 8 | HWND hwndDlg; 9 | int hMenu; 10 | int hMenuDisasm; 11 | int hMenuDump; 12 | int hMenuStack; 13 | 14 | DLL_EXPORT bool pluginit(PLUG_INITSTRUCT* initStruct) 15 | { 16 | initStruct->pluginVersion = plugin_version; 17 | initStruct->sdkVersion = PLUG_SDKVERSION; 18 | strcpy(initStruct->pluginName, plugin_name); 19 | pluginHandle = initStruct->pluginHandle; 20 | testInit(initStruct); 21 | return true; 22 | } 23 | 24 | DLL_EXPORT bool plugstop() 25 | { 26 | testStop(); 27 | return true; 28 | } 29 | 30 | DLL_EXPORT void plugsetup(PLUG_SETUPSTRUCT* setupStruct) 31 | { 32 | hwndDlg = setupStruct->hwndDlg; 33 | hMenu = setupStruct->hMenu; 34 | hMenuDisasm = setupStruct->hMenuDisasm; 35 | hMenuDump = setupStruct->hMenuDump; 36 | hMenuStack = setupStruct->hMenuStack; 37 | testSetup(); 38 | } 39 | 40 | extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 41 | { 42 | return TRUE; 43 | } 44 | -------------------------------------------------------------------------------- /pluginmain.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLUGINMAIN_H 2 | #define _PLUGINMAIN_H 3 | 4 | #include 5 | #include "pluginsdk\_plugins.h" 6 | 7 | #ifndef DLL_EXPORT 8 | #define DLL_EXPORT __declspec(dllexport) 9 | #endif //DLL_EXPORT 10 | 11 | //superglobal variables 12 | extern int pluginHandle; 13 | extern HWND hwndDlg; 14 | extern int hMenu; 15 | extern int hMenuDisasm; 16 | extern int hMenuDump; 17 | extern int hMenuStack; 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | DLL_EXPORT bool pluginit(PLUG_INITSTRUCT* initStruct); 25 | DLL_EXPORT bool plugstop(); 26 | DLL_EXPORT void plugsetup(PLUG_SETUPSTRUCT* setupStruct); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif //_PLUGINMAIN_H 33 | -------------------------------------------------------------------------------- /pluginsdk/DeviceNameResolver/DeviceNameResolver.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEVICENAMERESOLVER_H 2 | #define _DEVICENAMERESOLVER_H 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" 8 | { 9 | #endif 10 | 11 | __declspec(dllexport) bool DevicePathToPathW(const wchar_t* szDevicePath, wchar_t* szPath, size_t nSizeInChars); 12 | __declspec(dllexport) bool DevicePathToPathA(const char* szDevicePath, char* szPath, size_t nSizeInChars); 13 | __declspec(dllexport) bool DevicePathFromFileHandleW(HANDLE hFile, wchar_t* szDevicePath, size_t nSizeInChars); 14 | __declspec(dllexport) bool DevicePathFromFileHandleA(HANDLE hFile, char* szDevicePath, size_t nSizeInChars); 15 | __declspec(dllexport) bool PathFromFileHandleW(HANDLE hFile, wchar_t* szPath, size_t nSizeInChars); 16 | __declspec(dllexport) bool PathFromFileHandleA(HANDLE hFile, char* szPath, size_t nSizeInChars); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif // _DEVICENAMERESOLVER_H 23 | -------------------------------------------------------------------------------- /pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.a -------------------------------------------------------------------------------- /pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.lib -------------------------------------------------------------------------------- /pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.a -------------------------------------------------------------------------------- /pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.lib -------------------------------------------------------------------------------- /pluginsdk/TitanEngine/TitanEngine_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/TitanEngine/TitanEngine_x64.a -------------------------------------------------------------------------------- /pluginsdk/TitanEngine/TitanEngine_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/TitanEngine/TitanEngine_x64.lib -------------------------------------------------------------------------------- /pluginsdk/TitanEngine/TitanEngine_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/TitanEngine/TitanEngine_x86.a -------------------------------------------------------------------------------- /pluginsdk/TitanEngine/TitanEngine_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/TitanEngine/TitanEngine_x86.lib -------------------------------------------------------------------------------- /pluginsdk/XEDParse/XEDParse.h: -------------------------------------------------------------------------------- 1 | #ifndef _XEDPARSE_H 2 | #define _XEDPARSE_H 3 | 4 | #include 5 | 6 | //XEDParse defines 7 | #ifdef XEDPARSE_BUILD 8 | #define XEDPARSE_EXPORT __declspec(dllexport) 9 | #else 10 | #define XEDPARSE_EXPORT __declspec(dllimport) 11 | #endif //XEDPARSE_BUILD 12 | 13 | #define XEDPARSE_CALL //calling convention 14 | 15 | #define XEDPARSE_MAXBUFSIZE 256 16 | #define XEDPARSE_MAXASMSIZE 16 17 | 18 | //typedefs 19 | typedef bool (XEDPARSE_CALL* CBXEDPARSE_UNKNOWN)(const char* text, ULONGLONG* value); 20 | 21 | //XEDParse enums 22 | enum XEDPARSE_STATUS 23 | { 24 | XEDPARSE_ERROR = 0, 25 | XEDPARSE_OK = 1 26 | }; 27 | 28 | //XEDParse structs 29 | #pragma pack(push,8) 30 | struct XEDPARSE 31 | { 32 | bool x64; // use 64-bit instructions 33 | ULONGLONG cip; //instruction pointer (for relative addressing) 34 | unsigned int dest_size; //destination size (returned by XEDParse) 35 | CBXEDPARSE_UNKNOWN cbUnknown; //unknown operand callback 36 | unsigned char dest[XEDPARSE_MAXASMSIZE]; //destination buffer 37 | char instr[XEDPARSE_MAXBUFSIZE]; //instruction text 38 | char error[XEDPARSE_MAXBUFSIZE]; //error text (in case of an error) 39 | }; 40 | #pragma pack(pop) 41 | 42 | #ifdef __cplusplus 43 | extern "C" 44 | { 45 | #endif 46 | 47 | XEDPARSE_EXPORT XEDPARSE_STATUS XEDPARSE_CALL XEDParseAssemble(XEDPARSE* XEDParse); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif // _XEDPARSE_H 54 | -------------------------------------------------------------------------------- /pluginsdk/XEDParse/XEDParse_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/XEDParse/XEDParse_x64.a -------------------------------------------------------------------------------- /pluginsdk/XEDParse/XEDParse_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/XEDParse/XEDParse_x64.lib -------------------------------------------------------------------------------- /pluginsdk/XEDParse/XEDParse_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/XEDParse/XEDParse_x86.a -------------------------------------------------------------------------------- /pluginsdk/XEDParse/XEDParse_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/XEDParse/XEDParse_x86.lib -------------------------------------------------------------------------------- /pluginsdk/_dbgfunctions.h: -------------------------------------------------------------------------------- 1 | #ifndef _DBGFUNCTIONS_H 2 | #define _DBGFUNCTIONS_H 3 | 4 | #ifndef __cplusplus 5 | #include 6 | #endif 7 | 8 | typedef struct 9 | { 10 | char mod[MAX_MODULE_SIZE]; 11 | duint addr; 12 | unsigned char oldbyte; 13 | unsigned char newbyte; 14 | } DBGPATCHINFO; 15 | 16 | typedef struct 17 | { 18 | duint addr; 19 | duint from; 20 | duint to; 21 | char comment[MAX_COMMENT_SIZE]; 22 | } DBGCALLSTACKENTRY; 23 | 24 | typedef struct 25 | { 26 | int total; 27 | DBGCALLSTACKENTRY* entries; 28 | } DBGCALLSTACK; 29 | 30 | typedef struct 31 | { 32 | duint addr; 33 | duint handler; 34 | } DBGSEHRECORD; 35 | 36 | typedef struct 37 | { 38 | duint total; 39 | DBGSEHRECORD* records; 40 | } DBGSEHCHAIN; 41 | 42 | typedef struct 43 | { 44 | DWORD dwProcessId; 45 | char szExeFile[MAX_PATH]; 46 | } DBGPROCESSINFO; 47 | 48 | typedef enum 49 | { 50 | InstructionBody = 0, 51 | InstructionHeading = 1, 52 | InstructionTailing = 2, 53 | InstructionOverlapped = 3, // The byte was executed with differing instruction base addresses 54 | DataByte, // This and the following is not implemented yet. 55 | DataWord, 56 | DataDWord, 57 | DataQWord, 58 | DataFloat, 59 | DataDouble, 60 | DataLongDouble, 61 | DataXMM, 62 | DataYMM, 63 | DataMMX, 64 | DataMixed, //the byte is accessed in multiple ways 65 | InstructionDataMixed //the byte is both executed and written 66 | } TRACERECORDBYTETYPE; 67 | 68 | typedef enum 69 | { 70 | TraceRecordNone, 71 | TraceRecordBitExec, 72 | TraceRecordByteWithExecTypeAndCounter, 73 | TraceRecordWordWithExecTypeAndCounter 74 | } TRACERECORDTYPE; 75 | 76 | typedef struct 77 | { 78 | duint Handle; 79 | unsigned char TypeNumber; 80 | unsigned int GrantedAccess; 81 | } HANDLEINFO; 82 | 83 | // The longest ip address is 1234:6789:1234:6789:1234:6789:123.567.901.345 (46 bytes) 84 | #define TCP_ADDR_SIZE 50 85 | 86 | typedef struct 87 | { 88 | char RemoteAddress[TCP_ADDR_SIZE]; 89 | unsigned short RemotePort; 90 | char LocalAddress[TCP_ADDR_SIZE]; 91 | unsigned short LocalPort; 92 | char StateText[TCP_ADDR_SIZE]; 93 | unsigned int State; 94 | } TCPCONNECTIONINFO; 95 | 96 | typedef bool (*ASSEMBLEATEX)(duint addr, const char* instruction, char* error, bool fillnop); 97 | typedef bool (*SECTIONFROMADDR)(duint addr, char* section); 98 | typedef bool (*MODNAMEFROMADDR)(duint addr, char* modname, bool extension); 99 | typedef duint(*MODBASEFROMADDR)(duint addr); 100 | typedef duint(*MODBASEFROMNAME)(const char* modname); 101 | typedef duint(*MODSIZEFROMADDR)(duint addr); 102 | typedef bool (*ASSEMBLE)(duint addr, unsigned char* dest, int* size, const char* instruction, char* error); 103 | typedef bool (*PATCHGET)(duint addr); 104 | typedef bool (*PATCHINRANGE)(duint start, duint end); 105 | typedef bool (*MEMPATCH)(duint va, const unsigned char* src, duint size); 106 | typedef void (*PATCHRESTORERANGE)(duint start, duint end); 107 | typedef bool (*PATCHENUM)(DBGPATCHINFO* patchlist, size_t* cbsize); 108 | typedef bool (*PATCHRESTORE)(duint addr); 109 | typedef int (*PATCHFILE)(DBGPATCHINFO* patchlist, int count, const char* szFileName, char* error); 110 | typedef int (*MODPATHFROMADDR)(duint addr, char* path, int size); 111 | typedef int (*MODPATHFROMNAME)(const char* modname, char* path, int size); 112 | typedef bool (*DISASMFAST)(const unsigned char* data, duint addr, BASIC_INSTRUCTION_INFO* basicinfo); 113 | typedef void (*MEMUPDATEMAP)(); 114 | typedef void (*GETCALLSTACK)(DBGCALLSTACK* callstack); 115 | typedef void (*GETSEHCHAIN)(DBGSEHCHAIN* sehchain); 116 | typedef void (*SYMBOLDOWNLOADALLSYMBOLS)(const char* szSymbolStore); 117 | typedef bool (*GETJIT)(char* jit, bool x64); 118 | typedef bool (*GETJITAUTO)(bool* jitauto); 119 | typedef bool (*GETDEFJIT)(char* defjit); 120 | typedef bool (*GETPROCESSLIST)(DBGPROCESSINFO** entries, int* count); 121 | typedef bool (*GETPAGERIGHTS)(duint addr, char* rights); 122 | typedef bool (*SETPAGERIGHTS)(duint addr, const char* rights); 123 | typedef bool (*PAGERIGHTSTOSTRING)(DWORD protect, char* rights); 124 | typedef bool (*ISPROCESSELEVATED)(); 125 | typedef bool (*GETCMDLINE)(char* cmdline, size_t* cbsize); 126 | typedef bool (*SETCMDLINE)(const char* cmdline); 127 | typedef duint(*FILEOFFSETTOVA)(const char* modname, duint offset); 128 | typedef duint(*VATOFILEOFFSET)(duint va); 129 | typedef duint(*GETADDRFROMLINE)(const char* szSourceFile, int line, duint* displacement); 130 | typedef bool (*GETSOURCEFROMADDR)(duint addr, char* szSourceFile, int* line); 131 | typedef bool (*VALFROMSTRING)(const char* string, duint* value); 132 | typedef bool (*PATCHGETEX)(duint addr, DBGPATCHINFO* info); 133 | typedef bool (*GETBRIDGEBP)(BPXTYPE type, duint addr, BRIDGEBP* bp); 134 | typedef bool (*STRINGFORMATINLINE)(const char* format, size_t resultSize, char* result); 135 | typedef void (*GETMNEMONICBRIEF)(const char* mnem, size_t resultSize, char* result); 136 | typedef unsigned int (*GETTRACERECORDHITCOUNT)(duint address); 137 | typedef TRACERECORDBYTETYPE(*GETTRACERECORDBYTETYPE)(duint address); 138 | typedef bool (*SETTRACERECORDTYPE)(duint pageAddress, TRACERECORDTYPE type); 139 | typedef TRACERECORDTYPE(*GETTRACERECORDTYPE)(duint pageAddress); 140 | typedef bool (*ENUMHANDLES)(ListOf(HANDLEINFO) handles); 141 | typedef bool (*GETHANDLENAME)(duint handle, char* name, size_t nameSize, char* typeName, size_t typeNameSize); 142 | typedef bool (*ENUMTCPCONNECTIONS)(ListOf(TCPCONNECTIONINFO) connections); 143 | typedef duint(*GETDBGEVENTS)(); 144 | typedef int (*MODGETPARTY)(duint base); 145 | typedef void (*MODSETPARTY)(duint base, int party); 146 | typedef bool (*WATCHISWATCHDOGTRIGGERED)(unsigned int id); 147 | 148 | typedef struct DBGFUNCTIONS_ 149 | { 150 | ASSEMBLEATEX AssembleAtEx; 151 | SECTIONFROMADDR SectionFromAddr; 152 | MODNAMEFROMADDR ModNameFromAddr; 153 | MODBASEFROMADDR ModBaseFromAddr; 154 | MODBASEFROMNAME ModBaseFromName; 155 | MODSIZEFROMADDR ModSizeFromAddr; 156 | ASSEMBLE Assemble; 157 | PATCHGET PatchGet; 158 | PATCHINRANGE PatchInRange; 159 | MEMPATCH MemPatch; 160 | PATCHRESTORERANGE PatchRestoreRange; 161 | PATCHENUM PatchEnum; 162 | PATCHRESTORE PatchRestore; 163 | PATCHFILE PatchFile; 164 | MODPATHFROMADDR ModPathFromAddr; 165 | MODPATHFROMNAME ModPathFromName; 166 | DISASMFAST DisasmFast; 167 | MEMUPDATEMAP MemUpdateMap; 168 | GETCALLSTACK GetCallStack; 169 | GETSEHCHAIN GetSEHChain; 170 | SYMBOLDOWNLOADALLSYMBOLS SymbolDownloadAllSymbols; 171 | GETJITAUTO GetJitAuto; 172 | GETJIT GetJit; 173 | GETDEFJIT GetDefJit; 174 | GETPROCESSLIST GetProcessList; 175 | GETPAGERIGHTS GetPageRights; 176 | SETPAGERIGHTS SetPageRights; 177 | PAGERIGHTSTOSTRING PageRightsToString; 178 | ISPROCESSELEVATED IsProcessElevated; 179 | GETCMDLINE GetCmdline; 180 | SETCMDLINE SetCmdline; 181 | FILEOFFSETTOVA FileOffsetToVa; 182 | VATOFILEOFFSET VaToFileOffset; 183 | GETADDRFROMLINE GetAddrFromLine; 184 | GETSOURCEFROMADDR GetSourceFromAddr; 185 | VALFROMSTRING ValFromString; 186 | PATCHGETEX PatchGetEx; 187 | GETBRIDGEBP GetBridgeBp; 188 | STRINGFORMATINLINE StringFormatInline; 189 | GETMNEMONICBRIEF GetMnemonicBrief; 190 | GETTRACERECORDHITCOUNT GetTraceRecordHitCount; 191 | GETTRACERECORDBYTETYPE GetTraceRecordByteType; 192 | SETTRACERECORDTYPE SetTraceRecordType; 193 | GETTRACERECORDTYPE GetTraceRecordType; 194 | ENUMHANDLES EnumHandles; 195 | GETHANDLENAME GetHandleName; 196 | ENUMTCPCONNECTIONS EnumTcpConnections; 197 | GETDBGEVENTS GetDbgEvents; 198 | MODGETPARTY ModGetParty; 199 | MODSETPARTY ModSetParty; 200 | WATCHISWATCHDOGTRIGGERED WatchIsWatchdogTriggered; 201 | } DBGFUNCTIONS; 202 | 203 | #ifdef BUILD_DBG 204 | 205 | const DBGFUNCTIONS* dbgfunctionsget(); 206 | void dbgfunctionsinit(); 207 | 208 | #endif //BUILD_DBG 209 | 210 | #endif //_DBGFUNCTIONS_H 211 | -------------------------------------------------------------------------------- /pluginsdk/_plugin_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLUGIN_DATA_H 2 | #define _PLUGIN_DATA_H 3 | 4 | #ifdef BUILD_DBG 5 | 6 | #include "_global.h" 7 | 8 | #else 9 | 10 | #ifdef __GNUC__ 11 | #include "dbghelp/dbghelp.h" 12 | #else 13 | #include 14 | #endif // __GNUC__ 15 | 16 | #ifndef deflen 17 | #define deflen 1024 18 | #endif // deflen 19 | 20 | #include "bridgemain.h" 21 | #include "_dbgfunctions.h" 22 | #include "jansson/jansson.h" 23 | 24 | #endif // BUILD_DBG 25 | 26 | #endif // _PLUGIN_DATA_H 27 | -------------------------------------------------------------------------------- /pluginsdk/_plugins.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLUGINS_H 2 | #define _PLUGINS_H 3 | 4 | #ifndef __cplusplus 5 | #include 6 | #endif 7 | 8 | #ifndef PLUG_IMPEXP 9 | #ifdef BUILD_DBG 10 | #define PLUG_IMPEXP __declspec(dllexport) 11 | #else 12 | #define PLUG_IMPEXP __declspec(dllimport) 13 | #endif //BUILD_DBG 14 | #endif //PLUG_IMPEXP 15 | 16 | #include "_plugin_types.h" 17 | 18 | //default structure alignments forced 19 | #ifdef _WIN64 20 | #pragma pack(push, 16) 21 | #else //x86 22 | #pragma pack(push, 8) 23 | #endif //_WIN64 24 | 25 | //defines 26 | #define PLUG_SDKVERSION 1 27 | 28 | #define PLUG_DB_LOADSAVE_DATA 1 29 | #define PLUG_DB_LOADSAVE_ALL 2 30 | 31 | //structures 32 | typedef struct 33 | { 34 | //provided by the debugger 35 | int pluginHandle; 36 | //provided by the pluginit function 37 | int sdkVersion; 38 | int pluginVersion; 39 | char pluginName[256]; 40 | } PLUG_INITSTRUCT; 41 | 42 | typedef struct 43 | { 44 | //provided by the debugger 45 | HWND hwndDlg; //gui window handle 46 | int hMenu; //plugin menu handle 47 | int hMenuDisasm; //plugin disasm menu handle 48 | int hMenuDump; //plugin dump menu handle 49 | int hMenuStack; //plugin stack menu handle 50 | } PLUG_SETUPSTRUCT; 51 | 52 | typedef struct 53 | { 54 | void* data; //user data 55 | } PLUG_SCRIPTSTRUCT; 56 | 57 | //callback structures 58 | typedef struct 59 | { 60 | const char* szFileName; 61 | } PLUG_CB_INITDEBUG; 62 | 63 | typedef struct 64 | { 65 | void* reserved; 66 | } PLUG_CB_STOPDEBUG; 67 | 68 | typedef struct 69 | { 70 | CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo; 71 | IMAGEHLP_MODULE64* modInfo; 72 | const char* DebugFileName; 73 | PROCESS_INFORMATION* fdProcessInfo; 74 | } PLUG_CB_CREATEPROCESS; 75 | 76 | typedef struct 77 | { 78 | EXIT_PROCESS_DEBUG_INFO* ExitProcess; 79 | } PLUG_CB_EXITPROCESS; 80 | 81 | typedef struct 82 | { 83 | CREATE_THREAD_DEBUG_INFO* CreateThread; 84 | DWORD dwThreadId; 85 | } PLUG_CB_CREATETHREAD; 86 | 87 | typedef struct 88 | { 89 | EXIT_THREAD_DEBUG_INFO* ExitThread; 90 | DWORD dwThreadId; 91 | } PLUG_CB_EXITTHREAD; 92 | 93 | typedef struct 94 | { 95 | void* reserved; 96 | } PLUG_CB_SYSTEMBREAKPOINT; 97 | 98 | typedef struct 99 | { 100 | LOAD_DLL_DEBUG_INFO* LoadDll; 101 | IMAGEHLP_MODULE64* modInfo; 102 | const char* modname; 103 | } PLUG_CB_LOADDLL; 104 | 105 | typedef struct 106 | { 107 | UNLOAD_DLL_DEBUG_INFO* UnloadDll; 108 | } PLUG_CB_UNLOADDLL; 109 | 110 | typedef struct 111 | { 112 | OUTPUT_DEBUG_STRING_INFO* DebugString; 113 | } PLUG_CB_OUTPUTDEBUGSTRING; 114 | 115 | typedef struct 116 | { 117 | EXCEPTION_DEBUG_INFO* Exception; 118 | } PLUG_CB_EXCEPTION; 119 | 120 | typedef struct 121 | { 122 | BRIDGEBP* breakpoint; 123 | } PLUG_CB_BREAKPOINT; 124 | 125 | typedef struct 126 | { 127 | void* reserved; 128 | } PLUG_CB_PAUSEDEBUG; 129 | 130 | typedef struct 131 | { 132 | void* reserved; 133 | } PLUG_CB_RESUMEDEBUG; 134 | 135 | typedef struct 136 | { 137 | void* reserved; 138 | } PLUG_CB_STEPPED; 139 | 140 | typedef struct 141 | { 142 | DWORD dwProcessId; 143 | } PLUG_CB_ATTACH; 144 | 145 | typedef struct 146 | { 147 | PROCESS_INFORMATION* fdProcessInfo; 148 | } PLUG_CB_DETACH; 149 | 150 | typedef struct 151 | { 152 | DEBUG_EVENT* DebugEvent; 153 | } PLUG_CB_DEBUGEVENT; 154 | 155 | typedef struct 156 | { 157 | int hEntry; 158 | } PLUG_CB_MENUENTRY; 159 | 160 | typedef struct 161 | { 162 | MSG* message; 163 | long* result; 164 | bool retval; 165 | } PLUG_CB_WINEVENT; 166 | 167 | typedef struct 168 | { 169 | MSG* message; 170 | bool retval; 171 | } PLUG_CB_WINEVENTGLOBAL; 172 | 173 | typedef struct 174 | { 175 | json_t* root; 176 | int loadSaveType; 177 | } PLUG_CB_LOADSAVEDB; 178 | 179 | //enums 180 | typedef enum 181 | { 182 | CB_INITDEBUG, //PLUG_CB_INITDEBUG 183 | CB_STOPDEBUG, //PLUG_CB_STOPDEBUG 184 | CB_CREATEPROCESS, //PLUG_CB_CREATEPROCESS 185 | CB_EXITPROCESS, //PLUG_CB_EXITPROCESS 186 | CB_CREATETHREAD, //PLUG_CB_CREATETHREAD 187 | CB_EXITTHREAD, //PLUG_CB_EXITTHREAD 188 | CB_SYSTEMBREAKPOINT, //PLUG_CB_SYSTEMBREAKPOINT 189 | CB_LOADDLL, //PLUG_CB_LOADDLL 190 | CB_UNLOADDLL, //PLUG_CB_UNLOADDLL 191 | CB_OUTPUTDEBUGSTRING, //PLUG_CB_OUTPUTDEBUGSTRING 192 | CB_EXCEPTION, //PLUG_CB_EXCEPTION 193 | CB_BREAKPOINT, //PLUG_CB_BREAKPOINT 194 | CB_PAUSEDEBUG, //PLUG_CB_PAUSEDEBUG 195 | CB_RESUMEDEBUG, //PLUG_CB_RESUMEDEBUG 196 | CB_STEPPED, //PLUG_CB_STEPPED 197 | CB_ATTACH, //PLUG_CB_ATTACHED (before attaching, after CB_INITDEBUG) 198 | CB_DETACH, //PLUG_CB_DETACH (before detaching, before CB_STOPDEBUG) 199 | CB_DEBUGEVENT, //PLUG_CB_DEBUGEVENT (called on any debug event) 200 | CB_MENUENTRY, //PLUG_CB_MENUENTRY 201 | CB_WINEVENT, //PLUG_CB_WINEVENT 202 | CB_WINEVENTGLOBAL, //PLUG_CB_WINEVENTGLOBAL 203 | CB_LOADDB, //PLUG_CB_LOADSAVEDB 204 | CB_SAVEDB //PLUG_CB_LOADSAVEDB 205 | } CBTYPE; 206 | 207 | //typedefs 208 | typedef void (*CBPLUGIN)(CBTYPE cbType, void* callbackInfo); 209 | typedef bool (*CBPLUGINCOMMAND)(int argc, char** argv); 210 | typedef void (*CBPLUGINSCRIPT)(); 211 | typedef duint(*CBPLUGINEXPRFUNCTION)(int argc, duint* argv, void* userdata); 212 | 213 | //exports 214 | #ifdef __cplusplus 215 | extern "C" 216 | { 217 | #endif 218 | 219 | PLUG_IMPEXP void _plugin_registercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin); 220 | PLUG_IMPEXP bool _plugin_unregistercallback(int pluginHandle, CBTYPE cbType); 221 | PLUG_IMPEXP bool _plugin_registercommand(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly); 222 | PLUG_IMPEXP bool _plugin_unregistercommand(int pluginHandle, const char* command); 223 | PLUG_IMPEXP void _plugin_logprintf(const char* format, ...); 224 | PLUG_IMPEXP void _plugin_logputs(const char* text); 225 | PLUG_IMPEXP void _plugin_debugpause(); 226 | PLUG_IMPEXP void _plugin_debugskipexceptions(bool skip); 227 | PLUG_IMPEXP int _plugin_menuadd(int hMenu, const char* title); 228 | PLUG_IMPEXP bool _plugin_menuaddentry(int hMenu, int hEntry, const char* title); 229 | PLUG_IMPEXP bool _plugin_menuaddseparator(int hMenu); 230 | PLUG_IMPEXP bool _plugin_menuclear(int hMenu); 231 | PLUG_IMPEXP void _plugin_menuseticon(int hMenu, const ICONDATA* icon); 232 | PLUG_IMPEXP void _plugin_menuentryseticon(int pluginHandle, int hEntry, const ICONDATA* icon); 233 | PLUG_IMPEXP void _plugin_startscript(CBPLUGINSCRIPT cbScript); 234 | PLUG_IMPEXP bool _plugin_waituntilpaused(); 235 | PLUG_IMPEXP bool _plugin_registerexprfunction(int pluginHandle, const char* name, int argc, CBPLUGINEXPRFUNCTION cbFunction, void* userdata); 236 | PLUG_IMPEXP bool _plugin_unregisterexprfunction(int pluginHandle, const char* name); 237 | 238 | #ifdef __cplusplus 239 | } 240 | #endif 241 | 242 | #pragma pack(pop) 243 | 244 | #endif // _PLUGINS_H 245 | -------------------------------------------------------------------------------- /pluginsdk/_scriptapi.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPT_API_H 2 | #define _SCRIPT_API_H 3 | 4 | #include "_plugins.h" 5 | 6 | #define SCRIPT_EXPORT PLUG_IMPEXP 7 | 8 | #endif //_SCRIPT_API_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_argument.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_ARGUMENT_H 2 | #define _SCRIPTAPI_ARGUMENT_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Argument 9 | { 10 | struct ArgumentInfo 11 | { 12 | char mod[MAX_MODULE_SIZE]; 13 | duint rvaStart; 14 | duint rvaEnd; 15 | bool manual; 16 | duint instructioncount; 17 | }; 18 | 19 | SCRIPT_EXPORT bool Add(duint start, duint end, bool manual, duint instructionCount = 0); 20 | SCRIPT_EXPORT bool Add(const ArgumentInfo* info); 21 | SCRIPT_EXPORT bool Get(duint addr, duint* start = nullptr, duint* end = nullptr, duint* instructionCount = nullptr); 22 | SCRIPT_EXPORT bool GetInfo(duint addr, ArgumentInfo* info); 23 | SCRIPT_EXPORT bool Overlaps(duint start, duint end); 24 | SCRIPT_EXPORT bool Delete(duint address); 25 | SCRIPT_EXPORT void DeleteRange(duint start, duint end, bool deleteManual = false); 26 | SCRIPT_EXPORT void Clear(); 27 | SCRIPT_EXPORT bool GetList(ListOf(ArgumentInfo) list); //caller has the responsibility to free the list 28 | }; //Argument 29 | }; //Script 30 | 31 | #endif //_SCRIPTAPI_ARGUMENT_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_assembler.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_ASSEMBLER_H 2 | #define _SCRIPTAPI_ASSEMBLER_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Assembler 9 | { 10 | SCRIPT_EXPORT bool Assemble(duint addr, unsigned char* dest, int* size, const char* instruction); //dest[16] 11 | SCRIPT_EXPORT bool AssembleEx(duint addr, unsigned char* dest, int* size, const char* instruction, char* error); //dest[16], error[MAX_ERROR_SIZE] 12 | SCRIPT_EXPORT bool AssembleMem(duint addr, const char* instruction); 13 | SCRIPT_EXPORT bool AssembleMemEx(duint addr, const char* instruction, int* size, char* error, bool fillnop); //error[MAX_ERROR_SIZE] 14 | }; //Assembler 15 | }; //Script 16 | 17 | #endif //_SCRIPTAPI_ASSEMBLER_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_bookmark.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_BOOKMARK_H 2 | #define _SCRIPTAPI_BOOKMARK_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Bookmark 9 | { 10 | struct BookmarkInfo 11 | { 12 | char mod[MAX_MODULE_SIZE]; 13 | duint rva; 14 | bool manual; 15 | }; 16 | 17 | SCRIPT_EXPORT bool Set(duint addr, bool manual = false); 18 | SCRIPT_EXPORT bool Set(const BookmarkInfo* info); 19 | SCRIPT_EXPORT bool Get(duint addr); 20 | SCRIPT_EXPORT bool GetInfo(duint addr, BookmarkInfo* info); 21 | SCRIPT_EXPORT bool Delete(duint addr); 22 | SCRIPT_EXPORT void DeleteRange(duint start, duint end); 23 | SCRIPT_EXPORT void Clear(); 24 | SCRIPT_EXPORT bool GetList(ListOf(BookmarkInfo) list); //caller has the responsibility to free the list 25 | }; //Bookmark 26 | }; //Script 27 | 28 | #endif //_SCRIPTAPI_BOOKMARK_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_comment.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_COMMENT_H 2 | #define _SCRIPTAPI_COMMENT_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Comment 9 | { 10 | struct CommentInfo 11 | { 12 | char mod[MAX_MODULE_SIZE]; 13 | duint rva; 14 | char text[MAX_LABEL_SIZE]; 15 | bool manual; 16 | }; 17 | 18 | SCRIPT_EXPORT bool Set(duint addr, const char* text, bool manual = false); 19 | SCRIPT_EXPORT bool Set(const CommentInfo* info); 20 | SCRIPT_EXPORT bool Get(duint addr, char* text); //text[MAX_COMMENT_SIZE] 21 | SCRIPT_EXPORT bool GetInfo(duint addr, CommentInfo* info); 22 | SCRIPT_EXPORT bool Delete(duint addr); 23 | SCRIPT_EXPORT void DeleteRange(duint start, duint end); 24 | SCRIPT_EXPORT void Clear(); 25 | SCRIPT_EXPORT bool GetList(ListOf(CommentInfo) list); //caller has the responsibility to free the list 26 | }; //Comment 27 | }; //Script 28 | 29 | #endif //_SCRIPTAPI_COMMENT_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_DEBUG_H 2 | #define _SCRIPTAPI_DEBUG_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Debug 9 | { 10 | enum HardwareType 11 | { 12 | HardwareAccess, 13 | HardwareWrite, 14 | HardwareExecute 15 | }; 16 | 17 | SCRIPT_EXPORT void Wait(); 18 | SCRIPT_EXPORT void Run(); 19 | SCRIPT_EXPORT void Pause(); 20 | SCRIPT_EXPORT void Stop(); 21 | SCRIPT_EXPORT void StepIn(); 22 | SCRIPT_EXPORT void StepOver(); 23 | SCRIPT_EXPORT void StepOut(); 24 | SCRIPT_EXPORT bool SetBreakpoint(duint address); 25 | SCRIPT_EXPORT bool DeleteBreakpoint(duint address); 26 | SCRIPT_EXPORT bool DisableBreakpoint(duint address); 27 | SCRIPT_EXPORT bool SetHardwareBreakpoint(duint address, HardwareType type = HardwareExecute); 28 | SCRIPT_EXPORT bool DeleteHardwareBreakpoint(duint address); 29 | }; //Debug 30 | }; //Script 31 | 32 | #endif //_SCRIPTAPI_DEBUG_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_flag.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_FLAG_H 2 | #define _SCRIPTAPI_FLAG_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Flag 9 | { 10 | enum FlagEnum 11 | { 12 | ZF, 13 | OF, 14 | CF, 15 | PF, 16 | SF, 17 | TF, 18 | AF, 19 | DF, 20 | IF 21 | }; 22 | 23 | SCRIPT_EXPORT bool Get(FlagEnum flag); 24 | SCRIPT_EXPORT bool Set(FlagEnum flag, bool value); 25 | 26 | SCRIPT_EXPORT bool GetZF(); 27 | SCRIPT_EXPORT bool SetZF(bool value); 28 | SCRIPT_EXPORT bool GetOF(); 29 | SCRIPT_EXPORT bool SetOF(bool value); 30 | SCRIPT_EXPORT bool GetCF(); 31 | SCRIPT_EXPORT bool SetCF(bool value); 32 | SCRIPT_EXPORT bool GetPF(); 33 | SCRIPT_EXPORT bool SetPF(bool value); 34 | SCRIPT_EXPORT bool GetSF(); 35 | SCRIPT_EXPORT bool SetSF(bool value); 36 | SCRIPT_EXPORT bool GetTF(); 37 | SCRIPT_EXPORT bool SetTF(bool value); 38 | SCRIPT_EXPORT bool GetAF(); 39 | SCRIPT_EXPORT bool SetAF(bool value); 40 | SCRIPT_EXPORT bool GetDF(); 41 | SCRIPT_EXPORT bool SetDF(bool value); 42 | SCRIPT_EXPORT bool GetIF(); 43 | SCRIPT_EXPORT bool SetIF(bool value); 44 | }; 45 | }; 46 | 47 | #endif //_SCRIPTAPI_FLAG_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_function.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_FUNCTION_H 2 | #define _SCRIPTAPI_FUNCTION_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Function 9 | { 10 | struct FunctionInfo 11 | { 12 | char mod[MAX_MODULE_SIZE]; 13 | duint rvaStart; 14 | duint rvaEnd; 15 | bool manual; 16 | duint instructioncount; 17 | }; 18 | 19 | SCRIPT_EXPORT bool Add(duint start, duint end, bool manual, duint instructionCount = 0); 20 | SCRIPT_EXPORT bool Add(const FunctionInfo* info); 21 | SCRIPT_EXPORT bool Get(duint addr, duint* start = nullptr, duint* end = nullptr, duint* instructionCount = nullptr); 22 | SCRIPT_EXPORT bool GetInfo(duint addr, FunctionInfo* info); 23 | SCRIPT_EXPORT bool Overlaps(duint start, duint end); 24 | SCRIPT_EXPORT bool Delete(duint address); 25 | SCRIPT_EXPORT void DeleteRange(duint start, duint end, bool deleteManual = false); 26 | SCRIPT_EXPORT void Clear(); 27 | SCRIPT_EXPORT bool GetList(ListOf(FunctionInfo) list); //caller has the responsibility to free the list 28 | }; //Function 29 | }; //Script 30 | 31 | #endif //_SCRIPTAPI_FUNCTION_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_GUI_H 2 | #define _SCRIPTAPI_GUI_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Gui 9 | { 10 | namespace Disassembly 11 | { 12 | SCRIPT_EXPORT bool SelectionGet(duint* start, duint* end); 13 | SCRIPT_EXPORT bool SelectionSet(duint start, duint end); 14 | SCRIPT_EXPORT duint SelectionGetStart(); 15 | SCRIPT_EXPORT duint SelectionGetEnd(); 16 | }; //Disassembly 17 | 18 | namespace Dump 19 | { 20 | SCRIPT_EXPORT bool SelectionGet(duint* start, duint* end); 21 | SCRIPT_EXPORT bool SelectionSet(duint start, duint end); 22 | SCRIPT_EXPORT duint SelectionGetStart(); 23 | SCRIPT_EXPORT duint SelectionGetEnd(); 24 | }; //Dump 25 | 26 | namespace Stack 27 | { 28 | SCRIPT_EXPORT bool SelectionGet(duint* start, duint* end); 29 | SCRIPT_EXPORT bool SelectionSet(duint start, duint end); 30 | SCRIPT_EXPORT duint SelectionGetStart(); 31 | SCRIPT_EXPORT duint SelectionGetEnd(); 32 | }; //Stack 33 | }; //Gui 34 | 35 | namespace Gui 36 | { 37 | enum Window 38 | { 39 | DisassemblyWindow, 40 | DumpWindow, 41 | StackWindow 42 | }; 43 | 44 | SCRIPT_EXPORT bool SelectionGet(Window window, duint* start, duint* end); 45 | SCRIPT_EXPORT bool SelectionSet(Window window, duint start, duint end); 46 | SCRIPT_EXPORT duint SelectionGetStart(Window window); 47 | SCRIPT_EXPORT duint SelectionGetEnd(Window window); 48 | SCRIPT_EXPORT void Message(const char* message); 49 | SCRIPT_EXPORT bool MessageYesNo(const char* message); 50 | SCRIPT_EXPORT bool InputLine(const char* title, char* text); //text[GUI_MAX_LINE_SIZE] 51 | SCRIPT_EXPORT bool InputValue(const char* title, duint* value); 52 | SCRIPT_EXPORT void Refresh(); 53 | SCRIPT_EXPORT void AddQWidgetTab(void* qWidget); 54 | SCRIPT_EXPORT void ShowQWidgetTab(void* qWidget); 55 | SCRIPT_EXPORT void CloseQWidgetTab(void* qWidget); 56 | 57 | }; //Gui 58 | }; //Script 59 | 60 | #endif //_SCRIPTAPI_GUI_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_label.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_LABEL_H 2 | #define _SCRIPTAPI_LABEL_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Label 9 | { 10 | struct LabelInfo 11 | { 12 | char mod[MAX_MODULE_SIZE]; 13 | duint rva; 14 | char text[MAX_LABEL_SIZE]; 15 | bool manual; 16 | }; 17 | 18 | SCRIPT_EXPORT bool Set(duint addr, const char* text, bool manual = false); 19 | SCRIPT_EXPORT bool Set(const LabelInfo* info); 20 | SCRIPT_EXPORT bool FromString(const char* label, duint* addr); 21 | SCRIPT_EXPORT bool Get(duint addr, char* text); //text[MAX_LABEL_SIZE] 22 | SCRIPT_EXPORT bool GetInfo(duint addr, LabelInfo* info); 23 | SCRIPT_EXPORT bool Delete(duint addr); 24 | SCRIPT_EXPORT void DeleteRange(duint start, duint end); 25 | SCRIPT_EXPORT void Clear(); 26 | SCRIPT_EXPORT bool GetList(ListOf(LabelInfo) list); //caller has the responsibility to free the list 27 | }; //Label 28 | }; //Script 29 | 30 | #endif //_SCRIPTAPI_LABEL_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_memory.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_MEMORY_H 2 | #define _SCRIPTAPI_MEMORY_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Memory 9 | { 10 | SCRIPT_EXPORT bool Read(duint addr, void* data, duint size, duint* sizeRead); 11 | SCRIPT_EXPORT bool Write(duint addr, const void* data, duint size, duint* sizeWritten); 12 | SCRIPT_EXPORT bool IsValidPtr(duint addr); 13 | SCRIPT_EXPORT duint RemoteAlloc(duint addr, duint size); 14 | SCRIPT_EXPORT bool RemoteFree(duint addr); 15 | 16 | SCRIPT_EXPORT unsigned char ReadByte(duint addr); 17 | SCRIPT_EXPORT bool WriteByte(duint addr, unsigned char data); 18 | SCRIPT_EXPORT unsigned short ReadWord(duint addr); 19 | SCRIPT_EXPORT bool WriteWord(duint addr, unsigned short data); 20 | SCRIPT_EXPORT unsigned int ReadDword(duint addr); 21 | SCRIPT_EXPORT bool WriteDword(duint addr, unsigned int data); 22 | SCRIPT_EXPORT unsigned long long ReadQword(duint addr); 23 | SCRIPT_EXPORT bool WriteQword(duint addr, unsigned long long data); 24 | SCRIPT_EXPORT duint ReadPtr(duint addr); 25 | SCRIPT_EXPORT bool WritePtr(duint addr, duint data); 26 | }; //Memory 27 | }; //Script 28 | 29 | #endif //_SCRIPTAPI_MEMORY_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_misc.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_MISC_H 2 | #define _SCRIPTAPI_MISC_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Misc 9 | { 10 | SCRIPT_EXPORT bool ParseExpression(const char* expression, duint* value); 11 | SCRIPT_EXPORT duint RemoteGetProcAddress(const char* module, const char* api); 12 | SCRIPT_EXPORT duint ResolveLabel(const char* label); 13 | SCRIPT_EXPORT void* Alloc(duint size); 14 | SCRIPT_EXPORT void Free(void* ptr); 15 | }; //Misc 16 | }; //Script 17 | 18 | #endif //_SCRIPTAPI_MISC_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_module.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_MODULE_H 2 | #define _SCRIPTAPI_MODULE_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Module 9 | { 10 | struct ModuleInfo 11 | { 12 | duint base; 13 | duint size; 14 | duint entry; 15 | int sectionCount; 16 | char name[MAX_MODULE_SIZE]; 17 | char path[MAX_PATH]; 18 | }; 19 | 20 | struct ModuleSectionInfo 21 | { 22 | duint addr; 23 | duint size; 24 | char name[MAX_SECTION_SIZE * 5]; 25 | }; 26 | 27 | SCRIPT_EXPORT bool InfoFromAddr(duint addr, ModuleInfo* info); 28 | SCRIPT_EXPORT bool InfoFromName(const char* name, ModuleInfo* info); 29 | SCRIPT_EXPORT duint BaseFromAddr(duint addr); 30 | SCRIPT_EXPORT duint BaseFromName(const char* name); 31 | SCRIPT_EXPORT duint SizeFromAddr(duint addr); 32 | SCRIPT_EXPORT duint SizeFromName(const char* name); 33 | SCRIPT_EXPORT bool NameFromAddr(duint addr, char* name); //name[MAX_MODULE_SIZE] 34 | SCRIPT_EXPORT bool PathFromAddr(duint addr, char* path); //path[MAX_PATH] 35 | SCRIPT_EXPORT bool PathFromName(const char* name, char* path); //path[MAX_PATH] 36 | SCRIPT_EXPORT duint EntryFromAddr(duint addr); 37 | SCRIPT_EXPORT duint EntryFromName(const char* name); 38 | SCRIPT_EXPORT int SectionCountFromAddr(duint addr); 39 | SCRIPT_EXPORT int SectionCountFromName(const char* name); 40 | SCRIPT_EXPORT bool SectionFromAddr(duint addr, int number, ModuleSectionInfo* section); 41 | SCRIPT_EXPORT bool SectionFromName(const char* name, int number, ModuleSectionInfo* section); 42 | SCRIPT_EXPORT bool SectionListFromAddr(duint addr, ListOf(ModuleSectionInfo) list); 43 | SCRIPT_EXPORT bool SectionListFromName(const char* name, ListOf(ModuleSectionInfo) list); 44 | SCRIPT_EXPORT bool GetMainModuleInfo(ModuleInfo* info); 45 | SCRIPT_EXPORT duint GetMainModuleBase(); 46 | SCRIPT_EXPORT duint GetMainModuleSize(); 47 | SCRIPT_EXPORT duint GetMainModuleEntry(); 48 | SCRIPT_EXPORT int GetMainModuleSectionCount(); 49 | SCRIPT_EXPORT bool GetMainModuleName(char* name); //name[MAX_MODULE_SIZE] 50 | SCRIPT_EXPORT bool GetMainModulePath(char* path); //path[MAX_PATH] 51 | SCRIPT_EXPORT bool GetMainModuleSectionList(ListOf(ModuleSectionInfo) list); //caller has the responsibility to free the list 52 | SCRIPT_EXPORT bool GetList(ListOf(ModuleInfo) list); //caller has the responsibility to free the list 53 | }; //Module 54 | }; //Script 55 | 56 | #endif //_SCRIPTAPI_MODULE_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_pattern.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_PATTERN_H 2 | #define _SCRIPTAPI_PATTERN_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Pattern 9 | { 10 | SCRIPT_EXPORT duint Find(unsigned char* data, duint datasize, const char* pattern); 11 | SCRIPT_EXPORT duint FindMem(duint start, duint size, const char* pattern); 12 | SCRIPT_EXPORT void Write(unsigned char* data, duint datasize, const char* pattern); 13 | SCRIPT_EXPORT void WriteMem(duint start, duint size, const char* pattern); 14 | SCRIPT_EXPORT bool SearchAndReplace(unsigned char* data, duint datasize, const char* searchpattern, const char* replacepattern); 15 | SCRIPT_EXPORT bool SearchAndReplaceMem(duint start, duint size, const char* searchpattern, const char* replacepattern); 16 | }; 17 | }; 18 | 19 | #endif //_SCRIPTAPI_FIND_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_register.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_REGISTER_H 2 | #define _SCRIPTAPI_REGISTER_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Register 9 | { 10 | enum RegisterEnum 11 | { 12 | DR0, 13 | DR1, 14 | DR2, 15 | DR3, 16 | DR6, 17 | DR7, 18 | 19 | EAX, 20 | AX, 21 | AH, 22 | AL, 23 | EBX, 24 | BX, 25 | BH, 26 | BL, 27 | ECX, 28 | CX, 29 | CH, 30 | CL, 31 | EDX, 32 | DX, 33 | DH, 34 | DL, 35 | EDI, 36 | DI, 37 | ESI, 38 | SI, 39 | EBP, 40 | BP, 41 | ESP, 42 | SP, 43 | EIP, 44 | 45 | #ifdef _WIN64 46 | RAX, 47 | RBX, 48 | RCX, 49 | RDX, 50 | RSI, 51 | SIL, 52 | RDI, 53 | DIL, 54 | RBP, 55 | BPL, 56 | RSP, 57 | SPL, 58 | RIP, 59 | R8, 60 | R8D, 61 | R8W, 62 | R8B, 63 | R9, 64 | R9D, 65 | R9W, 66 | R9B, 67 | R10, 68 | R10D, 69 | R10W, 70 | R10B, 71 | R11, 72 | R11D, 73 | R11W, 74 | R11B, 75 | R12, 76 | R12D, 77 | R12W, 78 | R12B, 79 | R13, 80 | R13D, 81 | R13W, 82 | R13B, 83 | R14, 84 | R14D, 85 | R14W, 86 | R14B, 87 | R15, 88 | R15D, 89 | R15W, 90 | R15B, 91 | #endif //_WIN64 92 | 93 | CIP, 94 | CSP, 95 | }; //RegisterEnum 96 | 97 | SCRIPT_EXPORT duint Get(RegisterEnum reg); 98 | SCRIPT_EXPORT bool Set(RegisterEnum reg, duint value); 99 | SCRIPT_EXPORT int Size(); //gets architecture register size in bytes 100 | 101 | SCRIPT_EXPORT duint GetDR0(); 102 | SCRIPT_EXPORT bool SetDR0(duint value); 103 | SCRIPT_EXPORT duint GetDR1(); 104 | SCRIPT_EXPORT bool SetDR1(duint value); 105 | SCRIPT_EXPORT duint GetDR2(); 106 | SCRIPT_EXPORT bool SetDR2(duint value); 107 | SCRIPT_EXPORT duint GetDR3(); 108 | SCRIPT_EXPORT bool SetDR3(duint value); 109 | SCRIPT_EXPORT duint GetDR6(); 110 | SCRIPT_EXPORT bool SetDR6(duint value); 111 | SCRIPT_EXPORT duint GetDR7(); 112 | SCRIPT_EXPORT bool SetDR7(duint value); 113 | 114 | SCRIPT_EXPORT unsigned int GetEAX(); 115 | SCRIPT_EXPORT bool SetEAX(unsigned int value); 116 | SCRIPT_EXPORT unsigned short GetAX(); 117 | SCRIPT_EXPORT bool SetAX(unsigned short value); 118 | SCRIPT_EXPORT unsigned char GetAH(); 119 | SCRIPT_EXPORT bool SetAH(unsigned char value); 120 | SCRIPT_EXPORT unsigned char GetAL(); 121 | SCRIPT_EXPORT bool SetAL(unsigned char value); 122 | SCRIPT_EXPORT unsigned int GetEBX(); 123 | SCRIPT_EXPORT bool SetEBX(unsigned int value); 124 | SCRIPT_EXPORT unsigned short GetBX(); 125 | SCRIPT_EXPORT bool SetBX(unsigned short value); 126 | SCRIPT_EXPORT unsigned char GetBH(); 127 | SCRIPT_EXPORT bool SetBH(unsigned char value); 128 | SCRIPT_EXPORT unsigned char GetBL(); 129 | SCRIPT_EXPORT bool SetBL(unsigned char value); 130 | SCRIPT_EXPORT unsigned int GetECX(); 131 | SCRIPT_EXPORT bool SetECX(unsigned int value); 132 | SCRIPT_EXPORT unsigned short GetCX(); 133 | SCRIPT_EXPORT bool SetCX(unsigned short value); 134 | SCRIPT_EXPORT unsigned char GetCH(); 135 | SCRIPT_EXPORT bool SetCH(unsigned char value); 136 | SCRIPT_EXPORT unsigned char GetCL(); 137 | SCRIPT_EXPORT bool SetCL(unsigned char value); 138 | SCRIPT_EXPORT unsigned int GetEDX(); 139 | SCRIPT_EXPORT bool SetEDX(unsigned int value); 140 | SCRIPT_EXPORT unsigned short GetDX(); 141 | SCRIPT_EXPORT bool SetDX(unsigned short value); 142 | SCRIPT_EXPORT unsigned char GetDH(); 143 | SCRIPT_EXPORT bool SetDH(unsigned char value); 144 | SCRIPT_EXPORT unsigned char GetDL(); 145 | SCRIPT_EXPORT bool SetDL(unsigned char value); 146 | SCRIPT_EXPORT unsigned int GetEDI(); 147 | SCRIPT_EXPORT bool SetEDI(unsigned int value); 148 | SCRIPT_EXPORT unsigned short GetDI(); 149 | SCRIPT_EXPORT bool SetDI(unsigned short value); 150 | SCRIPT_EXPORT unsigned int GetESI(); 151 | SCRIPT_EXPORT bool SetESI(unsigned int value); 152 | SCRIPT_EXPORT unsigned short GetSI(); 153 | SCRIPT_EXPORT bool SetSI(unsigned short value); 154 | SCRIPT_EXPORT unsigned int GetEBP(); 155 | SCRIPT_EXPORT bool SetEBP(unsigned int value); 156 | SCRIPT_EXPORT unsigned short GetBP(); 157 | SCRIPT_EXPORT bool SetBP(unsigned short value); 158 | SCRIPT_EXPORT unsigned int GetESP(); 159 | SCRIPT_EXPORT bool SetESP(unsigned int value); 160 | SCRIPT_EXPORT unsigned short GetSP(); 161 | SCRIPT_EXPORT bool SetSP(unsigned short value); 162 | SCRIPT_EXPORT unsigned int GetEIP(); 163 | SCRIPT_EXPORT bool SetEIP(unsigned int value); 164 | 165 | #ifdef _WIN64 166 | SCRIPT_EXPORT unsigned long long GetRAX(); 167 | SCRIPT_EXPORT bool SetRAX(unsigned long long value); 168 | SCRIPT_EXPORT unsigned long long GetRBX(); 169 | SCRIPT_EXPORT bool SetRBX(unsigned long long value); 170 | SCRIPT_EXPORT unsigned long long GetRCX(); 171 | SCRIPT_EXPORT bool SetRCX(unsigned long long value); 172 | SCRIPT_EXPORT unsigned long long GetRDX(); 173 | SCRIPT_EXPORT bool SetRDX(unsigned long long value); 174 | SCRIPT_EXPORT unsigned long long GetRSI(); 175 | SCRIPT_EXPORT bool SetRSI(unsigned long long value); 176 | SCRIPT_EXPORT unsigned char GetSIL(); 177 | SCRIPT_EXPORT bool SetSIL(unsigned char value); 178 | SCRIPT_EXPORT unsigned long long GetRDI(); 179 | SCRIPT_EXPORT bool SetRDI(unsigned long long value); 180 | SCRIPT_EXPORT unsigned char GetDIL(); 181 | SCRIPT_EXPORT bool SetDIL(unsigned char value); 182 | SCRIPT_EXPORT unsigned long long GetRBP(); 183 | SCRIPT_EXPORT bool SetRBP(unsigned long long value); 184 | SCRIPT_EXPORT unsigned char GetBPL(); 185 | SCRIPT_EXPORT bool SetBPL(unsigned char value); 186 | SCRIPT_EXPORT unsigned long long GetRSP(); 187 | SCRIPT_EXPORT bool SetRSP(unsigned long long value); 188 | SCRIPT_EXPORT unsigned char GetSPL(); 189 | SCRIPT_EXPORT bool SetSPL(unsigned char value); 190 | SCRIPT_EXPORT unsigned long long GetRIP(); 191 | SCRIPT_EXPORT bool SetRIP(unsigned long long value); 192 | SCRIPT_EXPORT unsigned long long GetR8(); 193 | SCRIPT_EXPORT bool SetR8(unsigned long long value); 194 | SCRIPT_EXPORT unsigned int GetR8D(); 195 | SCRIPT_EXPORT bool SetR8D(unsigned int value); 196 | SCRIPT_EXPORT unsigned short GetR8W(); 197 | SCRIPT_EXPORT bool SetR8W(unsigned short value); 198 | SCRIPT_EXPORT unsigned char GetR8B(); 199 | SCRIPT_EXPORT bool SetR8B(unsigned char value); 200 | SCRIPT_EXPORT unsigned long long GetR9(); 201 | SCRIPT_EXPORT bool SetR9(unsigned long long value); 202 | SCRIPT_EXPORT unsigned int GetR9D(); 203 | SCRIPT_EXPORT bool SetR9D(unsigned int value); 204 | SCRIPT_EXPORT unsigned short GetR9W(); 205 | SCRIPT_EXPORT bool SetR9W(unsigned short value); 206 | SCRIPT_EXPORT unsigned char GetR9B(); 207 | SCRIPT_EXPORT bool SetR9B(unsigned char value); 208 | SCRIPT_EXPORT unsigned long long GetR10(); 209 | SCRIPT_EXPORT bool SetR10(unsigned long long value); 210 | SCRIPT_EXPORT unsigned int GetR10D(); 211 | SCRIPT_EXPORT bool SetR10D(unsigned int value); 212 | SCRIPT_EXPORT unsigned short GetR10W(); 213 | SCRIPT_EXPORT bool SetR10W(unsigned short value); 214 | SCRIPT_EXPORT unsigned char GetR10B(); 215 | SCRIPT_EXPORT bool SetR10B(unsigned char value); 216 | SCRIPT_EXPORT unsigned long long GetR11(); 217 | SCRIPT_EXPORT bool SetR11(unsigned long long value); 218 | SCRIPT_EXPORT unsigned int GetR11D(); 219 | SCRIPT_EXPORT bool SetR11D(unsigned int value); 220 | SCRIPT_EXPORT unsigned short GetR11W(); 221 | SCRIPT_EXPORT bool SetR11W(unsigned short value); 222 | SCRIPT_EXPORT unsigned char GetR11B(); 223 | SCRIPT_EXPORT bool SetR11B(unsigned char value); 224 | SCRIPT_EXPORT unsigned long long GetR12(); 225 | SCRIPT_EXPORT bool SetR12(unsigned long long value); 226 | SCRIPT_EXPORT unsigned int GetR12D(); 227 | SCRIPT_EXPORT bool SetR12D(unsigned int value); 228 | SCRIPT_EXPORT unsigned short GetR12W(); 229 | SCRIPT_EXPORT bool SetR12W(unsigned short value); 230 | SCRIPT_EXPORT unsigned char GetR12B(); 231 | SCRIPT_EXPORT bool SetR12B(unsigned char value); 232 | SCRIPT_EXPORT unsigned long long GetR13(); 233 | SCRIPT_EXPORT bool SetR13(unsigned long long value); 234 | SCRIPT_EXPORT unsigned int GetR13D(); 235 | SCRIPT_EXPORT bool SetR13D(unsigned int value); 236 | SCRIPT_EXPORT unsigned short GetR13W(); 237 | SCRIPT_EXPORT bool SetR13W(unsigned short value); 238 | SCRIPT_EXPORT unsigned char GetR13B(); 239 | SCRIPT_EXPORT bool SetR13B(unsigned char value); 240 | SCRIPT_EXPORT unsigned long long GetR14(); 241 | SCRIPT_EXPORT bool SetR14(unsigned long long value); 242 | SCRIPT_EXPORT unsigned int GetR14D(); 243 | SCRIPT_EXPORT bool SetR14D(unsigned int value); 244 | SCRIPT_EXPORT unsigned short GetR14W(); 245 | SCRIPT_EXPORT bool SetR14W(unsigned short value); 246 | SCRIPT_EXPORT unsigned char GetR14B(); 247 | SCRIPT_EXPORT bool SetR14B(unsigned char value); 248 | SCRIPT_EXPORT unsigned long long GetR15(); 249 | SCRIPT_EXPORT bool SetR15(unsigned long long value); 250 | SCRIPT_EXPORT unsigned int GetR15D(); 251 | SCRIPT_EXPORT bool SetR15D(unsigned int value); 252 | SCRIPT_EXPORT unsigned short GetR15W(); 253 | SCRIPT_EXPORT bool SetR15W(unsigned short value); 254 | SCRIPT_EXPORT unsigned char GetR15B(); 255 | SCRIPT_EXPORT bool SetR15B(unsigned char value); 256 | #endif //_WIN64 257 | 258 | SCRIPT_EXPORT duint GetCIP(); 259 | SCRIPT_EXPORT bool SetCIP(duint value); 260 | SCRIPT_EXPORT duint GetCSP(); 261 | SCRIPT_EXPORT bool SetCSP(duint value); 262 | }; //Register 263 | }; //Script 264 | 265 | #endif //_SCRIPTAPI_REGISTER_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_stack.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_STACK_H 2 | #define _SCRIPTAPI_STACK_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Stack 9 | { 10 | SCRIPT_EXPORT duint Pop(); 11 | SCRIPT_EXPORT duint Push(duint value); //returns the previous top, equal to Peek(1) 12 | SCRIPT_EXPORT duint Peek(int offset = 0); //offset is in multiples of Register::Size(), for easy x32/x64 portability 13 | }; //Stack 14 | }; //Script 15 | 16 | #endif //_SCRIPTAPI_STACK_H -------------------------------------------------------------------------------- /pluginsdk/_scriptapi_symbol.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTAPI_SYMBOL_H 2 | #define _SCRIPTAPI_SYMBOL_H 3 | 4 | #include "_scriptapi.h" 5 | 6 | namespace Script 7 | { 8 | namespace Symbol 9 | { 10 | enum SymbolType 11 | { 12 | Function, 13 | Import, 14 | Export 15 | }; 16 | 17 | struct SymbolInfo 18 | { 19 | char mod[MAX_MODULE_SIZE]; 20 | duint rva; 21 | char name[MAX_LABEL_SIZE]; 22 | bool manual; 23 | SymbolType type; 24 | }; 25 | 26 | SCRIPT_EXPORT bool GetList(ListOf(SymbolInfo) list); //caller has the responsibility to free the list 27 | }; //Symbol 28 | }; //Script 29 | 30 | #endif //_SCRIPTAPI_SYMBOL_H -------------------------------------------------------------------------------- /pluginsdk/bridgegraph.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPH_H 2 | #define _GRAPH_H 3 | 4 | typedef struct 5 | { 6 | duint parentGraph; //function of which this node is a part 7 | duint start; //start of the block 8 | duint end; //end of the block (inclusive) 9 | duint brtrue; //destination if condition is true 10 | duint brfalse; //destination if condition is false 11 | duint icount; //number of instructions in node 12 | bool terminal; //node is a RET 13 | bool split; //node is a split (brtrue points to the next node) 14 | void* userdata; //user data 15 | ListInfo exits; //exits (including brtrue and brfalse, duint) 16 | ListInfo data; //block data 17 | } BridgeCFNodeList; 18 | 19 | typedef struct 20 | { 21 | duint entryPoint; //graph entry point 22 | void* userdata; //user data 23 | ListInfo nodes; //graph nodes (BridgeCFNodeList) 24 | } BridgeCFGraphList; 25 | 26 | #ifdef __cplusplus 27 | #if _MSC_VER > 1300 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | struct BridgeCFNode 35 | { 36 | duint parentGraph; //function of which this node is a part 37 | duint start; //start of the block 38 | duint end; //end of the block (inclusive) 39 | duint brtrue; //destination if condition is true 40 | duint brfalse; //destination if condition is false 41 | duint icount; //number of instructions in node 42 | bool terminal; //node is a RET 43 | bool split; //node is a split (brtrue points to the next node) 44 | void* userdata; //user data 45 | std::vector exits; //exits (including brtrue and brfalse) 46 | std::vector data; //block data 47 | 48 | explicit BridgeCFNode(BridgeCFNodeList* nodeList, bool freedata = true) 49 | { 50 | if(!nodeList) 51 | __debugbreak(); 52 | parentGraph = nodeList->parentGraph; 53 | start = nodeList->start; 54 | end = nodeList->end; 55 | brtrue = nodeList->brtrue; 56 | brfalse = nodeList->brfalse; 57 | icount = nodeList->icount; 58 | terminal = nodeList->terminal; 59 | split = nodeList->split; 60 | userdata = nodeList->userdata; 61 | if(!BridgeList::ToVector(&nodeList->exits, exits, freedata)) 62 | __debugbreak(); 63 | if(!BridgeList::ToVector(&nodeList->data, data, freedata)) 64 | __debugbreak(); 65 | } 66 | 67 | explicit BridgeCFNode(duint parentGraph, duint start, duint end) 68 | : parentGraph(parentGraph), 69 | start(start), 70 | end(end), 71 | brtrue(0), 72 | brfalse(0), 73 | icount(0), 74 | terminal(false), 75 | split(false), 76 | userdata(nullptr) 77 | { 78 | } 79 | 80 | explicit BridgeCFNode() 81 | : BridgeCFNode(0, 0, 0) 82 | { 83 | } 84 | 85 | BridgeCFNodeList ToNodeList() const 86 | { 87 | BridgeCFNodeList out; 88 | out.parentGraph = parentGraph; 89 | out.start = start; 90 | out.end = end; 91 | out.brtrue = brtrue; 92 | out.brfalse = brfalse; 93 | out.icount = icount; 94 | out.terminal = terminal; 95 | out.split = split; 96 | out.userdata = userdata; 97 | BridgeList::CopyData(&out.exits, exits); 98 | BridgeList::CopyData(&out.data, data); 99 | return std::move(out); 100 | } 101 | }; 102 | 103 | struct BridgeCFGraph 104 | { 105 | duint entryPoint; //graph entry point 106 | void* userdata; //user data 107 | std::unordered_map nodes; //CFNode.start -> CFNode 108 | std::unordered_map> parents; //CFNode.start -> parents 109 | 110 | explicit BridgeCFGraph(BridgeCFGraphList* graphList, bool freedata = true) 111 | { 112 | if(!graphList || graphList->nodes.size != graphList->nodes.count * sizeof(BridgeCFNodeList)) 113 | __debugbreak(); 114 | entryPoint = graphList->entryPoint; 115 | userdata = graphList->userdata; 116 | auto data = (BridgeCFNodeList*)graphList->nodes.data; 117 | for(int i = 0; i < graphList->nodes.count; i++) 118 | AddNode(BridgeCFNode(&data[i], freedata)); 119 | if(freedata && data) 120 | BridgeFree(data); 121 | } 122 | 123 | explicit BridgeCFGraph(duint entryPoint) 124 | : entryPoint(entryPoint), 125 | userdata(nullptr) 126 | { 127 | } 128 | 129 | void AddNode(const BridgeCFNode & node) 130 | { 131 | nodes[node.start] = node; 132 | AddParent(node.start, node.brtrue); 133 | AddParent(node.start, node.brfalse); 134 | } 135 | 136 | void AddParent(duint child, duint parent) 137 | { 138 | if(!child || !parent) 139 | return; 140 | auto found = parents.find(child); 141 | if(found == parents.end()) 142 | parents[child] = std::unordered_set(std::initializer_list { parent }); 143 | else 144 | found->second.insert(parent); 145 | } 146 | 147 | BridgeCFGraphList ToGraphList() const 148 | { 149 | BridgeCFGraphList out; 150 | out.entryPoint = entryPoint; 151 | out.userdata = userdata; 152 | std::vector nodeList; 153 | nodeList.reserve(nodes.size()); 154 | for(const auto & nodeIt : nodes) 155 | nodeList.push_back(nodeIt.second.ToNodeList()); 156 | BridgeList::CopyData(&out.nodes, nodeList); 157 | return std::move(out); 158 | } 159 | }; 160 | 161 | #endif //_MSC_VER 162 | #endif //__cplusplus 163 | 164 | #endif //_GRAPH_H -------------------------------------------------------------------------------- /pluginsdk/bridgelist.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIST_H 2 | #define _LIST_H 3 | 4 | typedef struct 5 | { 6 | int count; //Number of element in the list. 7 | size_t size; //Size of list in bytes (used for type checking). 8 | void* data; //Pointer to the list contents. Must be deleted by the caller using BridgeFree (or BridgeList::Free). 9 | } ListInfo; 10 | 11 | #define ListOf(Type) ListInfo* 12 | 13 | #ifdef __cplusplus 14 | 15 | #include 16 | 17 | /** 18 | \brief A list object. This object is NOT thread safe. 19 | \tparam Type BridgeList contents type. 20 | */ 21 | template 22 | class BridgeList 23 | { 24 | public: 25 | /** 26 | \brief BridgeList constructor. 27 | \param _freeData (Optional) the free function. 28 | */ 29 | explicit BridgeList() 30 | { 31 | memset(&_listInfo, 0, sizeof(_listInfo)); 32 | } 33 | 34 | /** 35 | \brief BridgeList destructor. 36 | */ 37 | ~BridgeList() 38 | { 39 | Cleanup(); 40 | } 41 | 42 | /** 43 | \brief Gets the list data. 44 | \return Returns ListInfo->data. Can be null if the list was never initialized. Will be destroyed once this object goes out of scope! 45 | */ 46 | Type* Data() const 47 | { 48 | return reinterpret_cast(_listInfo.data); 49 | } 50 | 51 | /** 52 | \brief Gets the number of elements in the list. This will crash the program if the data is not consistent with the specified template argument. 53 | \return The number of elements in the list. 54 | */ 55 | int Count() const 56 | { 57 | if(_listInfo.size != _listInfo.count * sizeof(Type)) //make sure the user is using the correct type. 58 | __debugbreak(); 59 | return _listInfo.count; 60 | } 61 | 62 | /** 63 | \brief Cleans up the list, freeing the list data when it is not null. 64 | */ 65 | void Cleanup() 66 | { 67 | if(_listInfo.data) 68 | { 69 | BridgeFree(_listInfo.data); 70 | _listInfo.data = nullptr; 71 | } 72 | } 73 | 74 | /** 75 | \brief Reference operator (cleans up the previous list) 76 | \return Pointer to the ListInfo. 77 | */ 78 | ListInfo* operator&() 79 | { 80 | Cleanup(); 81 | return &_listInfo; 82 | } 83 | 84 | /** 85 | \brief Array indexer operator. This will crash if you try to access out-of-bounds. 86 | \param index Zero-based index of the item you want to get. 87 | \return Reference to a value at that index. 88 | */ 89 | Type & operator[](size_t index) const 90 | { 91 | if(index >= size_t(Count())) //make sure the out-of-bounds access is caught as soon as possible. 92 | __debugbreak(); 93 | return Data()[index]; 94 | } 95 | 96 | /** 97 | \brief Copies data to a ListInfo structure.. 98 | \param [out] listInfo If non-null, information describing the list. 99 | \param listData Data to copy in the ListInfo structure. 100 | \return true if it succeeds, false if it fails. 101 | */ 102 | static bool CopyData(ListInfo* listInfo, const std::vector & listData) 103 | { 104 | if(!listInfo) 105 | return false; 106 | listInfo->count = int(listData.size()); 107 | listInfo->size = listInfo->count * sizeof(Type); 108 | if(listInfo->count) 109 | { 110 | listInfo->data = BridgeAlloc(listInfo->size); 111 | Type* curItem = reinterpret_cast(listInfo->data); 112 | for(const auto & item : listData) 113 | { 114 | *curItem = item; 115 | ++curItem; 116 | } 117 | } 118 | else 119 | listInfo->data = nullptr; 120 | return true; 121 | } 122 | 123 | static bool ToVector(const ListInfo* listInfo, std::vector & listData, bool freedata = true) 124 | { 125 | if(!listInfo || listInfo->size != listInfo->count * sizeof(Type) || (listInfo->count && !listInfo->data)) 126 | return false; 127 | listData.resize(listInfo->count); 128 | for(int i = 0; i < listInfo->count; i++) 129 | listData[i] = ((Type*)listInfo->data)[i]; 130 | if(freedata && listInfo->data) 131 | BridgeFree(listInfo->data); 132 | return true; 133 | } 134 | 135 | private: 136 | ListInfo _listInfo; 137 | }; 138 | 139 | #endif //__cplusplus 140 | 141 | #endif //_LIST_H -------------------------------------------------------------------------------- /pluginsdk/capstone/capstone_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/capstone/capstone_x64.lib -------------------------------------------------------------------------------- /pluginsdk/capstone/capstone_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/capstone/capstone_x86.lib -------------------------------------------------------------------------------- /pluginsdk/capstone/platform.h: -------------------------------------------------------------------------------- 1 | /* Capstone Disassembly Engine */ 2 | /* By Axel Souchet & Nguyen Anh Quynh, 2014 */ 3 | 4 | #ifndef CAPSTONE_PLATFORM_H 5 | #define CAPSTONE_PLATFORM_H 6 | 7 | 8 | // handle C99 issue (for pre-2013 VisualStudio) 9 | #if !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) 10 | // MSVC 11 | 12 | // stdbool.h 13 | #if (_MSC_VER < 1800) || defined(_KERNEL_MODE) 14 | // this system does not have stdbool.h 15 | #ifndef __cplusplus 16 | typedef unsigned char bool; 17 | #define false 0 18 | #define true 1 19 | #endif // __cplusplus 20 | 21 | #else 22 | // VisualStudio 2013+ -> C99 is supported 23 | #include 24 | #endif // (_MSC_VER < 1800) || defined(_KERNEL_MODE) 25 | 26 | #else 27 | // not MSVC -> C99 is supported 28 | #include 29 | #endif // !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) 30 | 31 | 32 | // handle inttypes.h / stdint.h compatibility 33 | #if defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) 34 | #include "windowsce/stdint.h" 35 | #endif // defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) 36 | 37 | #if defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) 38 | // this system does not have inttypes.h 39 | 40 | #if defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE)) 41 | // this system does not have stdint.h 42 | typedef signed char int8_t; 43 | typedef signed short int16_t; 44 | typedef signed int int32_t; 45 | typedef unsigned char uint8_t; 46 | typedef unsigned short uint16_t; 47 | typedef unsigned int uint32_t; 48 | typedef signed long long int64_t; 49 | typedef unsigned long long uint64_t; 50 | 51 | #define INT8_MIN (-127i8 - 1) 52 | #define INT16_MIN (-32767i16 - 1) 53 | #define INT32_MIN (-2147483647i32 - 1) 54 | #define INT64_MIN (-9223372036854775807i64 - 1) 55 | #define INT8_MAX 127i8 56 | #define INT16_MAX 32767i16 57 | #define INT32_MAX 2147483647i32 58 | #define INT64_MAX 9223372036854775807i64 59 | #define UINT8_MAX 0xffui8 60 | #define UINT16_MAX 0xffffui16 61 | #define UINT32_MAX 0xffffffffui32 62 | #define UINT64_MAX 0xffffffffffffffffui64 63 | #endif // defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE)) 64 | 65 | #define __PRI_8_LENGTH_MODIFIER__ "hh" 66 | #define __PRI_64_LENGTH_MODIFIER__ "ll" 67 | 68 | #define PRId8 __PRI_8_LENGTH_MODIFIER__ "d" 69 | #define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i" 70 | #define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o" 71 | #define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u" 72 | #define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x" 73 | #define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X" 74 | 75 | #define PRId16 "hd" 76 | #define PRIi16 "hi" 77 | #define PRIo16 "ho" 78 | #define PRIu16 "hu" 79 | #define PRIx16 "hx" 80 | #define PRIX16 "hX" 81 | 82 | #if defined(_MSC_VER) && _MSC_VER <= 1700 83 | #define PRId32 "ld" 84 | #define PRIi32 "li" 85 | #define PRIo32 "lo" 86 | #define PRIu32 "lu" 87 | #define PRIx32 "lx" 88 | #define PRIX32 "lX" 89 | #else // OSX 90 | #define PRId32 "d" 91 | #define PRIi32 "i" 92 | #define PRIo32 "o" 93 | #define PRIu32 "u" 94 | #define PRIx32 "x" 95 | #define PRIX32 "X" 96 | #endif // defined(_MSC_VER) && _MSC_VER <= 1700 97 | 98 | #define PRId64 __PRI_64_LENGTH_MODIFIER__ "d" 99 | #define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i" 100 | #define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o" 101 | #define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u" 102 | #define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x" 103 | #define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X" 104 | 105 | #else 106 | // this system has inttypes.h by default 107 | #include 108 | #endif // defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /pluginsdk/capstone/xcore.h: -------------------------------------------------------------------------------- 1 | #ifndef CAPSTONE_XCORE_H 2 | #define CAPSTONE_XCORE_H 3 | 4 | /* Capstone Disassembly Engine */ 5 | /* By Nguyen Anh Quynh , 2014-2015 */ 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #include "platform.h" 12 | 13 | #ifdef _MSC_VER 14 | #pragma warning(disable:4201) 15 | #endif 16 | 17 | //> Operand type for instruction's operands 18 | typedef enum xcore_op_type 19 | { 20 | XCORE_OP_INVALID = 0, // = CS_OP_INVALID (Uninitialized). 21 | XCORE_OP_REG, // = CS_OP_REG (Register operand). 22 | XCORE_OP_IMM, // = CS_OP_IMM (Immediate operand). 23 | XCORE_OP_MEM, // = CS_OP_MEM (Memory operand). 24 | } xcore_op_type; 25 | 26 | //> XCore registers 27 | typedef enum xcore_reg 28 | { 29 | XCORE_REG_INVALID = 0, 30 | 31 | XCORE_REG_CP, 32 | XCORE_REG_DP, 33 | XCORE_REG_LR, 34 | XCORE_REG_SP, 35 | XCORE_REG_R0, 36 | XCORE_REG_R1, 37 | XCORE_REG_R2, 38 | XCORE_REG_R3, 39 | XCORE_REG_R4, 40 | XCORE_REG_R5, 41 | XCORE_REG_R6, 42 | XCORE_REG_R7, 43 | XCORE_REG_R8, 44 | XCORE_REG_R9, 45 | XCORE_REG_R10, 46 | XCORE_REG_R11, 47 | 48 | //> pseudo registers 49 | XCORE_REG_PC, // pc 50 | 51 | // internal thread registers 52 | // see The-XMOS-XS1-Architecture(X7879A).pdf 53 | XCORE_REG_SCP, // save pc 54 | XCORE_REG_SSR, // save status 55 | XCORE_REG_ET, // exception type 56 | XCORE_REG_ED, // exception data 57 | XCORE_REG_SED, // save exception data 58 | XCORE_REG_KEP, // kernel entry pointer 59 | XCORE_REG_KSP, // kernel stack pointer 60 | XCORE_REG_ID, // thread ID 61 | 62 | XCORE_REG_ENDING, // <-- mark the end of the list of registers 63 | } xcore_reg; 64 | 65 | // Instruction's operand referring to memory 66 | // This is associated with XCORE_OP_MEM operand type above 67 | typedef struct xcore_op_mem 68 | { 69 | uint8_t base; // base register, can be safely interpreted as 70 | // a value of type `xcore_reg`, but it is only 71 | // one byte wide 72 | uint8_t index; // index register, same conditions apply here 73 | int32_t disp; // displacement/offset value 74 | int direct; // +1: forward, -1: backward 75 | } xcore_op_mem; 76 | 77 | // Instruction operand 78 | typedef struct cs_xcore_op 79 | { 80 | xcore_op_type type; // operand type 81 | union 82 | { 83 | xcore_reg reg; // register value for REG operand 84 | int32_t imm; // immediate value for IMM operand 85 | xcore_op_mem mem; // base/disp value for MEM operand 86 | }; 87 | } cs_xcore_op; 88 | 89 | // Instruction structure 90 | typedef struct cs_xcore 91 | { 92 | // Number of operands of this instruction, 93 | // or 0 when instruction has no operand. 94 | uint8_t op_count; 95 | cs_xcore_op operands[8]; // operands for this instruction. 96 | } cs_xcore; 97 | 98 | //> XCore instruction 99 | typedef enum xcore_insn 100 | { 101 | XCORE_INS_INVALID = 0, 102 | 103 | XCORE_INS_ADD, 104 | XCORE_INS_ANDNOT, 105 | XCORE_INS_AND, 106 | XCORE_INS_ASHR, 107 | XCORE_INS_BAU, 108 | XCORE_INS_BITREV, 109 | XCORE_INS_BLA, 110 | XCORE_INS_BLAT, 111 | XCORE_INS_BL, 112 | XCORE_INS_BF, 113 | XCORE_INS_BT, 114 | XCORE_INS_BU, 115 | XCORE_INS_BRU, 116 | XCORE_INS_BYTEREV, 117 | XCORE_INS_CHKCT, 118 | XCORE_INS_CLRE, 119 | XCORE_INS_CLRPT, 120 | XCORE_INS_CLRSR, 121 | XCORE_INS_CLZ, 122 | XCORE_INS_CRC8, 123 | XCORE_INS_CRC32, 124 | XCORE_INS_DCALL, 125 | XCORE_INS_DENTSP, 126 | XCORE_INS_DGETREG, 127 | XCORE_INS_DIVS, 128 | XCORE_INS_DIVU, 129 | XCORE_INS_DRESTSP, 130 | XCORE_INS_DRET, 131 | XCORE_INS_ECALLF, 132 | XCORE_INS_ECALLT, 133 | XCORE_INS_EDU, 134 | XCORE_INS_EEF, 135 | XCORE_INS_EET, 136 | XCORE_INS_EEU, 137 | XCORE_INS_ENDIN, 138 | XCORE_INS_ENTSP, 139 | XCORE_INS_EQ, 140 | XCORE_INS_EXTDP, 141 | XCORE_INS_EXTSP, 142 | XCORE_INS_FREER, 143 | XCORE_INS_FREET, 144 | XCORE_INS_GETD, 145 | XCORE_INS_GET, 146 | XCORE_INS_GETN, 147 | XCORE_INS_GETR, 148 | XCORE_INS_GETSR, 149 | XCORE_INS_GETST, 150 | XCORE_INS_GETTS, 151 | XCORE_INS_INCT, 152 | XCORE_INS_INIT, 153 | XCORE_INS_INPW, 154 | XCORE_INS_INSHR, 155 | XCORE_INS_INT, 156 | XCORE_INS_IN, 157 | XCORE_INS_KCALL, 158 | XCORE_INS_KENTSP, 159 | XCORE_INS_KRESTSP, 160 | XCORE_INS_KRET, 161 | XCORE_INS_LADD, 162 | XCORE_INS_LD16S, 163 | XCORE_INS_LD8U, 164 | XCORE_INS_LDA16, 165 | XCORE_INS_LDAP, 166 | XCORE_INS_LDAW, 167 | XCORE_INS_LDC, 168 | XCORE_INS_LDW, 169 | XCORE_INS_LDIVU, 170 | XCORE_INS_LMUL, 171 | XCORE_INS_LSS, 172 | XCORE_INS_LSUB, 173 | XCORE_INS_LSU, 174 | XCORE_INS_MACCS, 175 | XCORE_INS_MACCU, 176 | XCORE_INS_MJOIN, 177 | XCORE_INS_MKMSK, 178 | XCORE_INS_MSYNC, 179 | XCORE_INS_MUL, 180 | XCORE_INS_NEG, 181 | XCORE_INS_NOT, 182 | XCORE_INS_OR, 183 | XCORE_INS_OUTCT, 184 | XCORE_INS_OUTPW, 185 | XCORE_INS_OUTSHR, 186 | XCORE_INS_OUTT, 187 | XCORE_INS_OUT, 188 | XCORE_INS_PEEK, 189 | XCORE_INS_REMS, 190 | XCORE_INS_REMU, 191 | XCORE_INS_RETSP, 192 | XCORE_INS_SETCLK, 193 | XCORE_INS_SET, 194 | XCORE_INS_SETC, 195 | XCORE_INS_SETD, 196 | XCORE_INS_SETEV, 197 | XCORE_INS_SETN, 198 | XCORE_INS_SETPSC, 199 | XCORE_INS_SETPT, 200 | XCORE_INS_SETRDY, 201 | XCORE_INS_SETSR, 202 | XCORE_INS_SETTW, 203 | XCORE_INS_SETV, 204 | XCORE_INS_SEXT, 205 | XCORE_INS_SHL, 206 | XCORE_INS_SHR, 207 | XCORE_INS_SSYNC, 208 | XCORE_INS_ST16, 209 | XCORE_INS_ST8, 210 | XCORE_INS_STW, 211 | XCORE_INS_SUB, 212 | XCORE_INS_SYNCR, 213 | XCORE_INS_TESTCT, 214 | XCORE_INS_TESTLCL, 215 | XCORE_INS_TESTWCT, 216 | XCORE_INS_TSETMR, 217 | XCORE_INS_START, 218 | XCORE_INS_WAITEF, 219 | XCORE_INS_WAITET, 220 | XCORE_INS_WAITEU, 221 | XCORE_INS_XOR, 222 | XCORE_INS_ZEXT, 223 | 224 | XCORE_INS_ENDING, // <-- mark the end of the list of instructions 225 | } xcore_insn; 226 | 227 | //> Group of XCore instructions 228 | typedef enum xcore_insn_group 229 | { 230 | XCORE_GRP_INVALID = 0, // = CS_GRP_INVALID 231 | 232 | //> Generic groups 233 | // all jump instructions (conditional+direct+indirect jumps) 234 | XCORE_GRP_JUMP, // = CS_GRP_JUMP 235 | 236 | XCORE_GRP_ENDING, // <-- mark the end of the list of groups 237 | } xcore_insn_group; 238 | 239 | #ifdef __cplusplus 240 | } 241 | #endif 242 | 243 | #endif 244 | -------------------------------------------------------------------------------- /pluginsdk/dbghelp/dbghelp_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/dbghelp/dbghelp_x64.a -------------------------------------------------------------------------------- /pluginsdk/dbghelp/dbghelp_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/dbghelp/dbghelp_x64.lib -------------------------------------------------------------------------------- /pluginsdk/dbghelp/dbghelp_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/dbghelp/dbghelp_x86.a -------------------------------------------------------------------------------- /pluginsdk/dbghelp/dbghelp_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/dbghelp/dbghelp_x86.lib -------------------------------------------------------------------------------- /pluginsdk/jansson/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2014 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The CMake system will generate the jansson_config.h file and 13 | * copy it to the build and install directories. 14 | */ 15 | 16 | #ifndef JANSSON_CONFIG_H 17 | #define JANSSON_CONFIG_H 18 | 19 | /* Define this so that we can disable scattered automake configuration in source files */ 20 | #ifndef JANSSON_USING_CMAKE 21 | #define JANSSON_USING_CMAKE 22 | #endif 23 | 24 | /* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used, 25 | * as we will also check for __int64 etc types. 26 | * (the definition was used in the automake system) */ 27 | 28 | /* Bring in the cmake-detected defines */ 29 | #define HAVE_STDINT_H 1 30 | /* #undef HAVE_INTTYPES_H */ 31 | /* #undef HAVE_SYS_TYPES_H */ 32 | 33 | /* Include our standard type header for the integer typedef */ 34 | 35 | #if defined(HAVE_STDINT_H) 36 | # include 37 | #elif defined(HAVE_INTTYPES_H) 38 | # include 39 | #elif defined(HAVE_SYS_TYPES_H) 40 | # include 41 | #endif 42 | 43 | 44 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 45 | defined to `inline', otherwise empty. In C++, the inline is always 46 | supported. */ 47 | #ifdef __cplusplus 48 | #define JSON_INLINE inline 49 | #else 50 | #define JSON_INLINE __inline 51 | #endif 52 | 53 | 54 | #define json_int_t long long 55 | #define json_strtoint _strtoi64 56 | #define JSON_INTEGER_FORMAT "I64d" 57 | 58 | 59 | /* If locale.h and localeconv() are available, define to 1, otherwise to 0. */ 60 | #define JSON_HAVE_LOCALECONV 1 61 | 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /pluginsdk/jansson/jansson_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/jansson/jansson_x64.a -------------------------------------------------------------------------------- /pluginsdk/jansson/jansson_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/jansson/jansson_x64.lib -------------------------------------------------------------------------------- /pluginsdk/jansson/jansson_x64dbg.h: -------------------------------------------------------------------------------- 1 | typedef json_t* JSON; 2 | 3 | static JSON_INLINE 4 | json_t* json_hex(unsigned json_int_t value) 5 | { 6 | char hexvalue[20]; 7 | #ifdef _WIN64 8 | sprintf(hexvalue, "0x%llX", value); 9 | #else //x64 10 | sprintf(hexvalue, "0x%X", value); 11 | #endif //_WIN64 12 | return json_string(hexvalue); 13 | } 14 | 15 | static JSON_INLINE 16 | unsigned json_int_t json_hex_value(const json_t* hex) 17 | { 18 | unsigned json_int_t ret; 19 | const char* hexvalue; 20 | hexvalue = json_string_value(hex); 21 | if(!hexvalue) 22 | return 0; 23 | #ifdef _WIN64 24 | sscanf(hexvalue, "0x%llX", &ret); 25 | #else //x64 26 | sscanf(hexvalue, "0x%X", &ret); 27 | #endif //_WIN64 28 | return ret; 29 | } -------------------------------------------------------------------------------- /pluginsdk/jansson/jansson_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/jansson/jansson_x86.a -------------------------------------------------------------------------------- /pluginsdk/jansson/jansson_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/jansson/jansson_x86.lib -------------------------------------------------------------------------------- /pluginsdk/lz4/lz4_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/lz4/lz4_x64.a -------------------------------------------------------------------------------- /pluginsdk/lz4/lz4_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/lz4/lz4_x64.lib -------------------------------------------------------------------------------- /pluginsdk/lz4/lz4_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/lz4/lz4_x86.a -------------------------------------------------------------------------------- /pluginsdk/lz4/lz4_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/lz4/lz4_x86.lib -------------------------------------------------------------------------------- /pluginsdk/lz4/lz4file.h: -------------------------------------------------------------------------------- 1 | #ifndef _LZ4FILE_H 2 | #define _LZ4FILE_H 3 | 4 | typedef enum _LZ4_STATUS 5 | { 6 | LZ4_SUCCESS, 7 | LZ4_FAILED_OPEN_INPUT, 8 | LZ4_FAILED_OPEN_OUTPUT, 9 | LZ4_NOT_ENOUGH_MEMORY, 10 | LZ4_INVALID_ARCHIVE, 11 | LZ4_CORRUPTED_ARCHIVE 12 | } LZ4_STATUS; 13 | 14 | #if defined (__cplusplus) 15 | extern "C" 16 | { 17 | #endif 18 | 19 | __declspec(dllimport) LZ4_STATUS LZ4_compress_file(const char* input_filename, const char* output_filename); 20 | __declspec(dllimport) LZ4_STATUS LZ4_compress_fileW(const wchar_t* input_filename, const wchar_t* output_filename); 21 | __declspec(dllimport) LZ4_STATUS LZ4_decompress_file(const char* input_filename, const char* output_filename); 22 | __declspec(dllimport) LZ4_STATUS LZ4_decompress_fileW(const wchar_t* input_filename, const wchar_t* output_filename); 23 | 24 | #if defined (__cplusplus) 25 | } 26 | #endif 27 | 28 | #endif //_LZ4FILE_H -------------------------------------------------------------------------------- /pluginsdk/lz4/lz4hc.h: -------------------------------------------------------------------------------- 1 | /* 2 | LZ4 HC - High Compression Mode of LZ4 3 | Header File 4 | Copyright (C) 2011-2014, Yann Collet. 5 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above 14 | copyright notice, this list of conditions and the following disclaimer 15 | in the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | You can contact the author at : 31 | - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html 32 | - LZ4 source repository : http://code.google.com/p/lz4/ 33 | */ 34 | #ifndef _LZ4HC_H 35 | #define _LZ4HC_H 36 | 37 | #if defined (__cplusplus) 38 | extern "C" 39 | { 40 | #endif 41 | 42 | 43 | __declspec(dllimport) int LZ4_compressHC(const char* source, char* dest, int inputSize); 44 | /* 45 | LZ4_compressHC : 46 | return : the number of bytes in compressed buffer dest 47 | or 0 if compression fails. 48 | note : destination buffer must be already allocated. 49 | To avoid any problem, size it to handle worst cases situations (input data not compressible) 50 | Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h") 51 | */ 52 | 53 | __declspec(dllimport) int LZ4_compressHC_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize); 54 | /* 55 | LZ4_compress_limitedOutput() : 56 | Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'. 57 | If it cannot achieve it, compression will stop, and result of the function will be zero. 58 | This function never writes outside of provided output buffer. 59 | 60 | inputSize : Max supported value is 1 GB 61 | maxOutputSize : is maximum allowed size into the destination buffer (which must be already allocated) 62 | return : the number of output bytes written in buffer 'dest' 63 | or 0 if compression fails. 64 | */ 65 | 66 | 67 | __declspec(dllimport) int LZ4_compressHC2(const char* source, char* dest, int inputSize, int compressionLevel); 68 | __declspec(dllimport) int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); 69 | /* 70 | Same functions as above, but with programmable 'compressionLevel'. 71 | Recommended values are between 4 and 9, although any value between 0 and 16 will work. 72 | 'compressionLevel'==0 means use default 'compressionLevel' value. 73 | Values above 16 behave the same as 16. 74 | Equivalent variants exist for all other compression functions below. 75 | */ 76 | 77 | /* Note : 78 | Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license) 79 | */ 80 | 81 | 82 | /************************************** 83 | Using an external allocation 84 | **************************************/ 85 | __declspec(dllimport) int LZ4_sizeofStateHC(void); 86 | __declspec(dllimport) int LZ4_compressHC_withStateHC(void* state, const char* source, char* dest, int inputSize); 87 | __declspec(dllimport) int LZ4_compressHC_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize); 88 | 89 | __declspec(dllimport) int LZ4_compressHC2_withStateHC(void* state, const char* source, char* dest, int inputSize, int compressionLevel); 90 | __declspec(dllimport) int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); 91 | 92 | /* 93 | These functions are provided should you prefer to allocate memory for compression tables with your own allocation methods. 94 | To know how much memory must be allocated for the compression tables, use : 95 | int LZ4_sizeofStateHC(); 96 | 97 | Note that tables must be aligned for pointer (32 or 64 bits), otherwise compression will fail (return code 0). 98 | 99 | The allocated memory can be provided to the compressions functions using 'void* state' parameter. 100 | LZ4_compress_withStateHC() and LZ4_compress_limitedOutput_withStateHC() are equivalent to previously described functions. 101 | They just use the externally allocated memory area instead of allocating their own (on stack, or on heap). 102 | */ 103 | 104 | 105 | /************************************** 106 | Streaming Functions 107 | **************************************/ 108 | __declspec(dllimport) void* LZ4_createHC(const char* inputBuffer); 109 | __declspec(dllimport) int LZ4_compressHC_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize); 110 | __declspec(dllimport) int LZ4_compressHC_limitedOutput_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize); 111 | __declspec(dllimport) char* LZ4_slideInputBufferHC(void* LZ4HC_Data); 112 | __declspec(dllimport) int LZ4_freeHC(void* LZ4HC_Data); 113 | 114 | __declspec(dllimport) int LZ4_compressHC2_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel); 115 | __declspec(dllimport) int LZ4_compressHC2_limitedOutput_continue(void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); 116 | 117 | /* 118 | These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks. 119 | In order to achieve this, it is necessary to start creating the LZ4HC Data Structure, thanks to the function : 120 | 121 | void* LZ4_createHC (const char* inputBuffer); 122 | The result of the function is the (void*) pointer on the LZ4HC Data Structure. 123 | This pointer will be needed in all other functions. 124 | If the pointer returned is NULL, then the allocation has failed, and compression must be aborted. 125 | The only parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer. 126 | The input buffer must be already allocated, and size at least 192KB. 127 | 'inputBuffer' will also be the 'const char* source' of the first block. 128 | 129 | All blocks are expected to lay next to each other within the input buffer, starting from 'inputBuffer'. 130 | To compress each block, use either LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(). 131 | Their behavior are identical to LZ4_compressHC() or LZ4_compressHC_limitedOutput(), 132 | but require the LZ4HC Data Structure as their first argument, and check that each block starts right after the previous one. 133 | If next block does not begin immediately after the previous one, the compression will fail (return 0). 134 | 135 | When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to : 136 | char* LZ4_slideInputBufferHC(void* LZ4HC_Data); 137 | must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer. 138 | Note that, for this function to work properly, minimum size of an input buffer must be 192KB. 139 | ==> The memory position where the next input data block must start is provided as the result of the function. 140 | 141 | Compression can then resume, using LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(), as usual. 142 | 143 | When compression is completed, a call to LZ4_freeHC() will release the memory used by the LZ4HC Data Structure. 144 | */ 145 | 146 | __declspec(dllimport) int LZ4_sizeofStreamStateHC(void); 147 | __declspec(dllimport) int LZ4_resetStreamStateHC(void* state, const char* inputBuffer); 148 | 149 | /* 150 | These functions achieve the same result as : 151 | void* LZ4_createHC (const char* inputBuffer); 152 | 153 | They are provided here to allow the user program to allocate memory using its own routines. 154 | 155 | To know how much space must be allocated, use LZ4_sizeofStreamStateHC(); 156 | Note also that space must be aligned for pointers (32 or 64 bits). 157 | 158 | Once space is allocated, you must initialize it using : LZ4_resetStreamStateHC(void* state, const char* inputBuffer); 159 | void* state is a pointer to the space allocated. 160 | It must be aligned for pointers (32 or 64 bits), and be large enough. 161 | The parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer. 162 | The input buffer must be already allocated, and size at least 192KB. 163 | 'inputBuffer' will also be the 'const char* source' of the first block. 164 | 165 | The same space can be re-used multiple times, just by initializing it each time with LZ4_resetStreamState(). 166 | return value of LZ4_resetStreamStateHC() must be 0 is OK. 167 | Any other value means there was an error (typically, state is not aligned for pointers (32 or 64 bits)). 168 | */ 169 | 170 | 171 | #if defined (__cplusplus) 172 | } 173 | #endif 174 | 175 | #endif //_LZ4HC_H 176 | -------------------------------------------------------------------------------- /pluginsdk/x32bridge.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/x32bridge.lib -------------------------------------------------------------------------------- /pluginsdk/x32dbg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/x32dbg.lib -------------------------------------------------------------------------------- /pluginsdk/x64bridge.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/x64bridge.lib -------------------------------------------------------------------------------- /pluginsdk/x64dbg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/x64dbg.lib -------------------------------------------------------------------------------- /pluginsdk/yara/yara.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_YARA_H 18 | #define YR_YARA_H 19 | 20 | #include "yara/utils.h" 21 | #include "yara/filemap.h" 22 | #include "yara/compiler.h" 23 | #include "yara/modules.h" 24 | #include "yara/object.h" 25 | #include "yara/libyara.h" 26 | #include "yara/error.h" 27 | #include "yara/stream.h" 28 | #include "yara/hash.h" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/ahocorasick.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _AHOCORASICK_H 18 | #define _AHOCORASICK_H 19 | 20 | #include "limits.h" 21 | #include "atoms.h" 22 | #include "types.h" 23 | 24 | 25 | #define YR_AC_ROOT_STATE 0 26 | #define YR_AC_NEXT_STATE(t) (t >> 32) 27 | #define YR_AC_INVALID_TRANSITION(t, c) (((t) & 0xFFFF) != c) 28 | 29 | #define YR_AC_MAKE_TRANSITION(state, code, flags) \ 30 | ((uint64_t)((((uint64_t) state) << 32) | ((flags) << 16) | (code))) 31 | 32 | #define YR_AC_USED_FLAG 0x1 33 | 34 | #define YR_AC_USED_TRANSITION_SLOT(x) ((x) & (YR_AC_USED_FLAG << 16)) 35 | #define YR_AC_UNUSED_TRANSITION_SLOT(x) (!YR_AC_USED_TRANSITION_SLOT(x)) 36 | 37 | 38 | typedef struct _YR_AC_TABLES 39 | { 40 | YR_AC_TRANSITION* transitions; 41 | YR_AC_MATCH_TABLE_ENTRY* matches; 42 | 43 | } YR_AC_TABLES; 44 | 45 | 46 | int yr_ac_automaton_create( 47 | YR_AC_AUTOMATON** automaton); 48 | 49 | 50 | int yr_ac_automaton_destroy( 51 | YR_AC_AUTOMATON* automaton); 52 | 53 | 54 | int yr_ac_add_string( 55 | YR_AC_AUTOMATON* automaton, 56 | YR_STRING* string, 57 | YR_ATOM_LIST_ITEM* atom, 58 | YR_ARENA* matches_arena); 59 | 60 | 61 | int yr_ac_compile( 62 | YR_AC_AUTOMATON* automaton, 63 | YR_ARENA* arena, 64 | YR_AC_TABLES* tables); 65 | 66 | 67 | void yr_ac_print_automaton( 68 | YR_AC_AUTOMATON* automaton); 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/arena.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_ARENA_H 18 | #define YR_ARENA_H 19 | 20 | #include 21 | #include 22 | 23 | #include "stream.h" 24 | 25 | #define ARENA_FLAGS_FIXED_SIZE 1 26 | #define ARENA_FLAGS_COALESCED 2 27 | #define ARENA_FILE_VERSION 10 28 | 29 | #define EOL ((size_t) -1) 30 | 31 | 32 | typedef struct _YR_RELOC 33 | { 34 | uint32_t offset; 35 | struct _YR_RELOC* next; 36 | 37 | } YR_RELOC; 38 | 39 | 40 | typedef struct _YR_ARENA_PAGE 41 | { 42 | 43 | uint8_t* new_address; 44 | uint8_t* address; 45 | 46 | size_t size; 47 | size_t used; 48 | 49 | YR_RELOC* reloc_list_head; 50 | YR_RELOC* reloc_list_tail; 51 | 52 | struct _YR_ARENA_PAGE* next; 53 | struct _YR_ARENA_PAGE* prev; 54 | 55 | } YR_ARENA_PAGE; 56 | 57 | 58 | typedef struct _YR_ARENA 59 | { 60 | int flags; 61 | 62 | YR_ARENA_PAGE* page_list_head; 63 | YR_ARENA_PAGE* current_page; 64 | 65 | } YR_ARENA; 66 | 67 | 68 | int yr_arena_create( 69 | size_t initial_size, 70 | int flags, 71 | YR_ARENA** arena); 72 | 73 | 74 | void yr_arena_destroy( 75 | YR_ARENA* arena); 76 | 77 | 78 | void* yr_arena_base_address( 79 | YR_ARENA* arena); 80 | 81 | 82 | void* yr_arena_next_address( 83 | YR_ARENA* arena, 84 | void* address, 85 | size_t offset); 86 | 87 | 88 | int yr_arena_coalesce( 89 | YR_ARENA* arena); 90 | 91 | 92 | int yr_arena_reserve_memory( 93 | YR_ARENA* arena, 94 | size_t size); 95 | 96 | 97 | int yr_arena_allocate_memory( 98 | YR_ARENA* arena, 99 | size_t size, 100 | void** allocated_memory); 101 | 102 | 103 | int yr_arena_allocate_struct( 104 | YR_ARENA* arena, 105 | size_t size, 106 | void** allocated_memory, 107 | ...); 108 | 109 | 110 | int yr_arena_make_relocatable( 111 | YR_ARENA* arena, 112 | void* base, 113 | ...); 114 | 115 | 116 | int yr_arena_write_data( 117 | YR_ARENA* arena, 118 | void* data, 119 | size_t size, 120 | void** written_data); 121 | 122 | 123 | int yr_arena_write_string( 124 | YR_ARENA* arena, 125 | const char* string, 126 | char** written_string); 127 | 128 | 129 | int yr_arena_append( 130 | YR_ARENA* target_arena, 131 | YR_ARENA* source_arena); 132 | 133 | 134 | int yr_arena_load_stream( 135 | YR_STREAM* stream, 136 | YR_ARENA** arena); 137 | 138 | 139 | int yr_arena_save_stream( 140 | YR_ARENA* arena, 141 | YR_STREAM* stream); 142 | 143 | 144 | int yr_arena_duplicate( 145 | YR_ARENA* arena, 146 | YR_ARENA** duplicated); 147 | 148 | 149 | void yr_arena_print( 150 | YR_ARENA* arena); 151 | 152 | #endif 153 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/atoms.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_ATOMS_H 18 | #define YR_ATOMS_H 19 | 20 | #include "limits.h" 21 | #include "re.h" 22 | 23 | #define ATOM_TREE_LEAF 1 24 | #define ATOM_TREE_AND 2 25 | #define ATOM_TREE_OR 3 26 | 27 | 28 | typedef struct _ATOM_TREE_NODE 29 | { 30 | uint8_t type; 31 | uint8_t atom_length; 32 | uint8_t atom[MAX_ATOM_LENGTH]; 33 | 34 | uint8_t* forward_code; 35 | uint8_t* backward_code; 36 | 37 | RE_NODE* recent_nodes[MAX_ATOM_LENGTH]; 38 | 39 | struct _ATOM_TREE_NODE* children_head; 40 | struct _ATOM_TREE_NODE* children_tail; 41 | struct _ATOM_TREE_NODE* next_sibling; 42 | 43 | } ATOM_TREE_NODE; 44 | 45 | 46 | typedef struct _ATOM_TREE 47 | { 48 | ATOM_TREE_NODE* current_leaf; 49 | ATOM_TREE_NODE* root_node; 50 | 51 | } ATOM_TREE; 52 | 53 | 54 | typedef struct _YR_ATOM_LIST_ITEM 55 | { 56 | uint8_t atom_length; 57 | uint8_t atom[MAX_ATOM_LENGTH]; 58 | 59 | uint16_t backtrack; 60 | 61 | uint8_t* forward_code; 62 | uint8_t* backward_code; 63 | 64 | struct _YR_ATOM_LIST_ITEM* next; 65 | 66 | } YR_ATOM_LIST_ITEM; 67 | 68 | 69 | int yr_atoms_extract_from_re( 70 | RE* re, 71 | int flags, 72 | YR_ATOM_LIST_ITEM** atoms); 73 | 74 | 75 | int yr_atoms_extract_from_string( 76 | uint8_t* string, 77 | int string_length, 78 | int flags, 79 | YR_ATOM_LIST_ITEM** atoms); 80 | 81 | 82 | int yr_atoms_min_quality( 83 | YR_ATOM_LIST_ITEM* atom_list); 84 | 85 | 86 | void yr_atoms_list_destroy( 87 | YR_ATOM_LIST_ITEM* list_head); 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_COMPILER_H 18 | #define YR_COMPILER_H 19 | 20 | #include 21 | #include 22 | 23 | #include "ahocorasick.h" 24 | #include "arena.h" 25 | #include "hash.h" 26 | #include "utils.h" 27 | 28 | 29 | #define YARA_ERROR_LEVEL_ERROR 0 30 | #define YARA_ERROR_LEVEL_WARNING 1 31 | 32 | 33 | typedef void (*YR_COMPILER_CALLBACK_FUNC)( 34 | int error_level, 35 | const char* file_name, 36 | int line_number, 37 | const char* message, 38 | void* user_data); 39 | 40 | 41 | typedef struct _YR_FIXUP 42 | { 43 | int64_t* address; 44 | struct _YR_FIXUP* next; 45 | 46 | } YR_FIXUP; 47 | 48 | 49 | typedef struct _YR_COMPILER 50 | { 51 | int errors; 52 | int error_line; 53 | int last_error; 54 | int last_error_line; 55 | int last_result; 56 | 57 | jmp_buf error_recovery; 58 | 59 | YR_ARENA* sz_arena; 60 | YR_ARENA* rules_arena; 61 | YR_ARENA* strings_arena; 62 | YR_ARENA* code_arena; 63 | YR_ARENA* re_code_arena; 64 | YR_ARENA* compiled_rules_arena; 65 | YR_ARENA* externals_arena; 66 | YR_ARENA* namespaces_arena; 67 | YR_ARENA* metas_arena; 68 | YR_ARENA* matches_arena; 69 | YR_ARENA* automaton_arena; 70 | 71 | YR_AC_AUTOMATON* automaton; 72 | YR_HASH_TABLE* rules_table; 73 | YR_HASH_TABLE* objects_table; 74 | YR_HASH_TABLE* strings_table; 75 | YR_NAMESPACE* current_namespace; 76 | YR_RULE* current_rule; 77 | 78 | YR_FIXUP* fixup_stack_head; 79 | 80 | int namespaces_count; 81 | 82 | uint8_t* loop_address[MAX_LOOP_NESTING]; 83 | char* loop_identifier[MAX_LOOP_NESTING]; 84 | int loop_depth; 85 | int loop_for_of_mem_offset; 86 | 87 | int allow_includes; 88 | 89 | char* file_name_stack[MAX_INCLUDE_DEPTH]; 90 | int file_name_stack_ptr; 91 | 92 | FILE* file_stack[MAX_INCLUDE_DEPTH]; 93 | int file_stack_ptr; 94 | 95 | char last_error_extra_info[MAX_COMPILER_ERROR_EXTRA_INFO]; 96 | 97 | char lex_buf[LEX_BUF_SIZE]; 98 | char* lex_buf_ptr; 99 | unsigned short lex_buf_len; 100 | 101 | char include_base_dir[MAX_PATH]; 102 | void* user_data; 103 | 104 | YR_COMPILER_CALLBACK_FUNC callback; 105 | 106 | } YR_COMPILER; 107 | 108 | 109 | #define yr_compiler_set_error_extra_info(compiler, info) \ 110 | strlcpy( \ 111 | compiler->last_error_extra_info, \ 112 | info, \ 113 | sizeof(compiler->last_error_extra_info)); \ 114 | 115 | 116 | #define yr_compiler_set_error_extra_info_fmt(compiler, fmt, ...) \ 117 | snprintf( \ 118 | compiler->last_error_extra_info, \ 119 | sizeof(compiler->last_error_extra_info), \ 120 | fmt, __VA_ARGS__); 121 | 122 | 123 | int _yr_compiler_push_file( 124 | YR_COMPILER* compiler, 125 | FILE* fh); 126 | 127 | 128 | FILE* _yr_compiler_pop_file( 129 | YR_COMPILER* compiler); 130 | 131 | 132 | int _yr_compiler_push_file_name( 133 | YR_COMPILER* compiler, 134 | const char* file_name); 135 | 136 | 137 | void _yr_compiler_pop_file_name( 138 | YR_COMPILER* compiler); 139 | 140 | 141 | YR_API int yr_compiler_create( 142 | YR_COMPILER** compiler); 143 | 144 | 145 | YR_API void yr_compiler_destroy( 146 | YR_COMPILER* compiler); 147 | 148 | 149 | YR_API void yr_compiler_set_callback( 150 | YR_COMPILER* compiler, 151 | YR_COMPILER_CALLBACK_FUNC callback, 152 | void* user_data); 153 | 154 | 155 | YR_API int yr_compiler_add_file( 156 | YR_COMPILER* compiler, 157 | FILE* rules_file, 158 | const char* namespace_, 159 | const char* file_name); 160 | 161 | 162 | YR_API int yr_compiler_add_string( 163 | YR_COMPILER* compiler, 164 | const char* rules_string, 165 | const char* namespace_); 166 | 167 | 168 | YR_API char* yr_compiler_get_error_message( 169 | YR_COMPILER* compiler, 170 | char* buffer, 171 | int buffer_size); 172 | 173 | 174 | YR_API char* yr_compiler_get_current_file_name( 175 | YR_COMPILER* context); 176 | 177 | 178 | YR_API int yr_compiler_define_integer_variable( 179 | YR_COMPILER* compiler, 180 | const char* identifier, 181 | int64_t value); 182 | 183 | 184 | YR_API int yr_compiler_define_boolean_variable( 185 | YR_COMPILER* compiler, 186 | const char* identifier, 187 | int value); 188 | 189 | 190 | YR_API int yr_compiler_define_float_variable( 191 | YR_COMPILER* compiler, 192 | const char* identifier, 193 | double value); 194 | 195 | 196 | YR_API int yr_compiler_define_string_variable( 197 | YR_COMPILER* compiler, 198 | const char* identifier, 199 | const char* value); 200 | 201 | 202 | YR_API int yr_compiler_get_rules( 203 | YR_COMPILER* compiler, 204 | YR_RULES** rules); 205 | 206 | 207 | #endif 208 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/elf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _ELF_H 18 | #define _ELF_H 19 | 20 | #include 21 | 22 | 23 | // 32-bit ELF base types 24 | 25 | typedef uint32_t elf32_addr_t; 26 | typedef uint16_t elf32_half_t; 27 | typedef uint32_t elf32_off_t; 28 | typedef uint32_t elf32_word_t; 29 | 30 | // 64-bit ELF base types 31 | 32 | typedef uint64_t elf64_addr_t; 33 | typedef uint16_t elf64_half_t; 34 | typedef uint64_t elf64_off_t; 35 | typedef uint32_t elf64_word_t; 36 | typedef uint64_t elf64_xword_t; 37 | 38 | #define ELF_MAGIC 0x464C457F 39 | 40 | #define ELF_ET_NONE 0x0000 // no type 41 | #define ELF_ET_REL 0x0001 // relocatable 42 | #define ELF_ET_EXEC 0x0002 // executeable 43 | #define ELF_ET_DYN 0x0003 // Shared-Object-File 44 | #define ELF_ET_CORE 0x0004 // Corefile 45 | #define ELF_ET_LOPROC 0xFF00 // Processor-specific 46 | #define ELF_ET_HIPROC 0x00FF // Processor-specific 47 | 48 | #define ELF_EM_NONE 0x0000 // no type 49 | #define ELF_EM_M32 0x0001 // AT&T WE 32100 50 | #define ELF_EM_SPARC 0x0002 // SPARC 51 | #define ELF_EM_386 0x0003 // Intel 80386 52 | #define ELF_EM_68K 0x0004 // Motorola 68000 53 | #define ELF_EM_88K 0x0005 // Motorola 88000 54 | #define ELF_EM_860 0x0007 // Intel 80860 55 | #define ELF_EM_MIPS 0x0008 // MIPS I Architecture 56 | #define ELF_EM_MIPS_RS3_LE 0x000A // MIPS RS3000 Little-endian 57 | #define ELF_EM_PPC 0x0014 // PowerPC 58 | #define ELF_EM_PPC64 0x0015 // 64-bit PowerPC 59 | #define ELF_EM_ARM 0x0028 // ARM 60 | #define ELF_EM_X86_64 0x003E // AMD/Intel x86_64 61 | #define ELF_EM_AARCH64 0x00B7 // 64-bit ARM 62 | 63 | #define ELF_CLASS_NONE 0x0000 64 | #define ELF_CLASS_32 0x0001 // 32bit file 65 | #define ELF_CLASS_64 0x0002 // 64bit file 66 | 67 | #define ELF_DATA_NONE 0x0000 68 | #define ELF_DATA_2LSB 0x0001 69 | #define ELF_DATA_2MSB 0x002 70 | 71 | 72 | #define ELF_SHT_NULL 0 // Section header table entry unused 73 | #define ELF_SHT_PROGBITS 1 // Program data 74 | #define ELF_SHT_SYMTAB 2 // Symbol table 75 | #define ELF_SHT_STRTAB 3 // String table 76 | #define ELF_SHT_RELA 4 // Relocation entries with addends 77 | #define ELF_SHT_HASH 5 // Symbol hash table 78 | #define ELF_SHT_DYNAMIC 6 // Dynamic linking information 79 | #define ELF_SHT_NOTE 7 // Notes 80 | #define ELF_SHT_NOBITS 8 // Program space with no data (bss) 81 | #define ELF_SHT_REL 9 // Relocation entries, no addends 82 | #define ELF_SHT_SHLIB 10 // Reserved 83 | #define ELF_SHT_DYNSYM 11 // Dynamic linker symbol table 84 | #define ELF_SHT_NUM 12 // Number of defined types 85 | 86 | #define ELF_SHF_WRITE 0x1 // Section is writable 87 | #define ELF_SHF_ALLOC 0x2 // Section is present during execution 88 | #define ELF_SHF_EXECINSTR 0x4 // Section contains executable instructions 89 | 90 | #define ELF_SHN_LORESERVE 0xFF00 91 | 92 | #define ELF_PT_NULL 0 // The array element is unused 93 | #define ELF_PT_LOAD 1 // Loadable segment 94 | #define ELF_PT_DYNAMIC 2 // Segment contains dynamic linking info 95 | #define ELF_PT_INTERP 3 // Contains interpreter pathname 96 | #define ELF_PT_NOTE 4 // Location & size of auxiliary info 97 | #define ELF_PT_SHLIB 5 // Reserved, unspecified semantics 98 | #define ELF_PT_PHDR 6 // Location and size of program header table 99 | #define ELF_PT_TLS 7 // Thread-Local Storage 100 | #define ELF_PT_GNU_EH_FRAME 0x6474e550 101 | #define ELF_PT_GNU_STACK 0x6474e551 102 | 103 | #define ELF_PF_X 0x1 // Segment is executable 104 | #define ELF_PF_W 0x2 // Segment is writable 105 | #define ELF_PF_R 0x4 // Segment is readable 106 | 107 | #define ELF_PN_XNUM 0xffff 108 | 109 | #pragma pack(push,1) 110 | 111 | typedef struct 112 | { 113 | uint32_t magic; 114 | uint8_t _class; 115 | uint8_t data; 116 | uint8_t version; 117 | uint8_t pad[8]; 118 | uint8_t nident; 119 | 120 | } elf_ident_t; 121 | 122 | 123 | typedef struct 124 | { 125 | elf_ident_t ident; 126 | elf32_half_t type; 127 | elf32_half_t machine; 128 | elf32_word_t version; 129 | elf32_addr_t entry; 130 | elf32_off_t ph_offset; 131 | elf32_off_t sh_offset; 132 | elf32_word_t flags; 133 | elf32_half_t header_size; 134 | elf32_half_t ph_entry_size; 135 | elf32_half_t ph_entry_count; 136 | elf32_half_t sh_entry_size; 137 | elf32_half_t sh_entry_count; 138 | elf32_half_t sh_str_table_index; 139 | 140 | } elf32_header_t; 141 | 142 | 143 | typedef struct 144 | { 145 | elf_ident_t ident; 146 | elf64_half_t type; 147 | elf64_half_t machine; 148 | elf64_word_t version; 149 | elf64_addr_t entry; 150 | elf64_off_t ph_offset; 151 | elf64_off_t sh_offset; 152 | elf64_word_t flags; 153 | elf64_half_t header_size; 154 | elf64_half_t ph_entry_size; 155 | elf64_half_t ph_entry_count; 156 | elf64_half_t sh_entry_size; 157 | elf64_half_t sh_entry_count; 158 | elf64_half_t sh_str_table_index; 159 | 160 | } elf64_header_t; 161 | 162 | 163 | typedef struct 164 | { 165 | elf32_word_t type; 166 | elf32_off_t offset; 167 | elf32_addr_t virt_addr; 168 | elf32_addr_t phys_addr; 169 | elf32_word_t file_size; 170 | elf32_word_t mem_size; 171 | elf32_word_t flags; 172 | elf32_word_t alignment; 173 | 174 | } elf32_program_header_t; 175 | 176 | 177 | typedef struct 178 | { 179 | elf64_word_t type; 180 | elf64_word_t flags; 181 | elf64_off_t offset; 182 | elf64_addr_t virt_addr; 183 | elf64_addr_t phys_addr; 184 | elf64_xword_t file_size; 185 | elf64_xword_t mem_size; 186 | elf64_xword_t alignment; 187 | 188 | } elf64_program_header_t; 189 | 190 | 191 | typedef struct 192 | { 193 | elf32_word_t name; 194 | elf32_word_t type; 195 | elf32_word_t flags; 196 | elf32_addr_t addr; 197 | elf32_off_t offset; 198 | elf32_word_t size; 199 | elf32_word_t link; 200 | elf32_word_t info; 201 | elf32_word_t align; 202 | elf32_word_t entry_size; 203 | 204 | } elf32_section_header_t; 205 | 206 | 207 | typedef struct 208 | { 209 | elf64_word_t name; 210 | elf64_word_t type; 211 | elf64_xword_t flags; 212 | elf64_addr_t addr; 213 | elf64_off_t offset; 214 | elf64_xword_t size; 215 | elf64_word_t link; 216 | elf64_word_t info; 217 | elf64_xword_t align; 218 | elf64_xword_t entry_size; 219 | 220 | } elf64_section_header_t; 221 | 222 | 223 | #pragma pack(pop) 224 | 225 | #endif -------------------------------------------------------------------------------- /pluginsdk/yara/yara/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_ERROR_H 18 | #define YR_ERROR_H 19 | 20 | #include 21 | 22 | #if defined(_WIN32) || defined(__CYGWIN__) 23 | #include 24 | #endif 25 | 26 | #ifndef ERROR_SUCCESS 27 | #define ERROR_SUCCESS 0 28 | #endif 29 | 30 | #define ERROR_INSUFICIENT_MEMORY 1 31 | #define ERROR_COULD_NOT_ATTACH_TO_PROCESS 2 32 | #define ERROR_COULD_NOT_OPEN_FILE 3 33 | #define ERROR_COULD_NOT_MAP_FILE 4 34 | #define ERROR_INVALID_FILE 6 35 | #define ERROR_CORRUPT_FILE 7 36 | #define ERROR_UNSUPPORTED_FILE_VERSION 8 37 | #define ERROR_INVALID_REGULAR_EXPRESSION 9 38 | #define ERROR_INVALID_HEX_STRING 10 39 | #define ERROR_SYNTAX_ERROR 11 40 | #define ERROR_LOOP_NESTING_LIMIT_EXCEEDED 12 41 | #define ERROR_DUPLICATED_LOOP_IDENTIFIER 13 42 | #define ERROR_DUPLICATED_IDENTIFIER 14 43 | #define ERROR_DUPLICATED_TAG_IDENTIFIER 15 44 | #define ERROR_DUPLICATED_META_IDENTIFIER 16 45 | #define ERROR_DUPLICATED_STRING_IDENTIFIER 17 46 | #define ERROR_UNREFERENCED_STRING 18 47 | #define ERROR_UNDEFINED_STRING 19 48 | #define ERROR_UNDEFINED_IDENTIFIER 20 49 | #define ERROR_MISPLACED_ANONYMOUS_STRING 21 50 | #define ERROR_INCLUDES_CIRCULAR_REFERENCE 22 51 | #define ERROR_INCLUDE_DEPTH_EXCEEDED 23 52 | #define ERROR_WRONG_TYPE 24 53 | #define ERROR_EXEC_STACK_OVERFLOW 25 54 | #define ERROR_SCAN_TIMEOUT 26 55 | #define ERROR_TOO_MANY_SCAN_THREADS 27 56 | #define ERROR_CALLBACK_ERROR 28 57 | #define ERROR_INVALID_ARGUMENT 29 58 | #define ERROR_TOO_MANY_MATCHES 30 59 | #define ERROR_INTERNAL_FATAL_ERROR 31 60 | #define ERROR_NESTED_FOR_OF_LOOP 32 61 | #define ERROR_INVALID_FIELD_NAME 33 62 | #define ERROR_UNKNOWN_MODULE 34 63 | #define ERROR_NOT_A_STRUCTURE 35 64 | #define ERROR_NOT_INDEXABLE 36 65 | #define ERROR_NOT_A_FUNCTION 37 66 | #define ERROR_INVALID_FORMAT 38 67 | #define ERROR_TOO_MANY_ARGUMENTS 39 68 | #define ERROR_WRONG_ARGUMENTS 40 69 | #define ERROR_WRONG_RETURN_TYPE 41 70 | #define ERROR_DUPLICATED_STRUCTURE_MEMBER 42 71 | #define ERROR_EMPTY_STRING 43 72 | #define ERROR_DIVISION_BY_ZERO 44 73 | #define ERROR_REGULAR_EXPRESSION_TOO_LARGE 45 74 | #define ERROR_TOO_MANY_RE_FIBERS 46 75 | 76 | 77 | #define FAIL_ON_ERROR(x) { \ 78 | int result = (x); \ 79 | if (result != ERROR_SUCCESS) \ 80 | return result; \ 81 | } 82 | 83 | #define FAIL_ON_ERROR_WITH_CLEANUP(x, cleanup) { \ 84 | int result = (x); \ 85 | if (result != ERROR_SUCCESS) { \ 86 | cleanup; \ 87 | return result; \ 88 | } \ 89 | } 90 | 91 | #define FAIL_ON_COMPILER_ERROR(x) { \ 92 | compiler->last_result = (x); \ 93 | if (compiler->last_result != ERROR_SUCCESS) \ 94 | return compiler->last_result; \ 95 | } 96 | 97 | 98 | #ifdef NDEBUG 99 | #define assertf(expr, msg, ...) ((void)0) 100 | #else 101 | #define assertf(expr, msg, ...) \ 102 | if(!(expr)) { \ 103 | fprintf(stderr, "%s:%d: " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ 104 | abort(); \ 105 | } 106 | #endif 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/exec.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013-2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_EXEC_H 18 | #define YR_EXEC_H 19 | 20 | #include "hash.h" 21 | #include "scan.h" 22 | #include "types.h" 23 | #include "rules.h" 24 | 25 | 26 | #define UNDEFINED 0xFFFABADAFABADAFFLL 27 | #define IS_UNDEFINED(x) ((size_t)(x) == (size_t) UNDEFINED) 28 | 29 | #define OP_ERROR 0 30 | #define OP_HALT 255 31 | 32 | #define OP_AND 1 33 | #define OP_OR 2 34 | #define OP_NOT 3 35 | #define OP_BITWISE_NOT 4 36 | #define OP_BITWISE_AND 5 37 | #define OP_BITWISE_OR 6 38 | #define OP_BITWISE_XOR 7 39 | #define OP_SHL 8 40 | #define OP_SHR 9 41 | #define OP_MOD 10 42 | #define OP_INT_TO_DBL 11 43 | #define OP_STR_TO_BOOL 12 44 | #define OP_PUSH 13 45 | #define OP_POP 14 46 | #define OP_CALL 15 47 | #define OP_OBJ_LOAD 16 48 | #define OP_OBJ_VALUE 17 49 | #define OP_OBJ_FIELD 18 50 | #define OP_INDEX_ARRAY 19 51 | #define OP_COUNT 20 52 | #define OP_LENGTH 21 53 | #define OP_FOUND 22 54 | #define OP_FOUND_AT 23 55 | #define OP_FOUND_IN 24 56 | #define OP_OFFSET 25 57 | #define OP_OF 26 58 | #define OP_PUSH_RULE 27 59 | #define OP_INIT_RULE 28 60 | #define OP_MATCH_RULE 29 61 | #define OP_INCR_M 30 62 | #define OP_CLEAR_M 31 63 | #define OP_ADD_M 32 64 | #define OP_POP_M 33 65 | #define OP_PUSH_M 34 66 | #define OP_SWAPUNDEF 35 67 | #define OP_JNUNDEF 36 68 | #define OP_JLE 37 69 | #define OP_FILESIZE 38 70 | #define OP_ENTRYPOINT 39 71 | #define OP_CONTAINS 40 72 | #define OP_MATCHES 41 73 | #define OP_IMPORT 42 74 | #define OP_LOOKUP_DICT 43 75 | #define OP_JFALSE 44 76 | #define OP_JTRUE 45 77 | 78 | 79 | #define _OP_EQ 0 80 | #define _OP_NEQ 1 81 | #define _OP_LT 2 82 | #define _OP_GT 3 83 | #define _OP_LE 4 84 | #define _OP_GE 5 85 | #define _OP_ADD 6 86 | #define _OP_SUB 7 87 | #define _OP_MUL 8 88 | #define _OP_DIV 9 89 | #define _OP_MINUS 10 90 | 91 | 92 | #define OP_INT_BEGIN 100 93 | #define OP_INT_EQ (OP_INT_BEGIN + _OP_EQ) 94 | #define OP_INT_NEQ (OP_INT_BEGIN + _OP_NEQ) 95 | #define OP_INT_LT (OP_INT_BEGIN + _OP_LT) 96 | #define OP_INT_GT (OP_INT_BEGIN + _OP_GT) 97 | #define OP_INT_LE (OP_INT_BEGIN + _OP_LE) 98 | #define OP_INT_GE (OP_INT_BEGIN + _OP_GE) 99 | #define OP_INT_ADD (OP_INT_BEGIN + _OP_ADD) 100 | #define OP_INT_SUB (OP_INT_BEGIN + _OP_SUB) 101 | #define OP_INT_MUL (OP_INT_BEGIN + _OP_MUL) 102 | #define OP_INT_DIV (OP_INT_BEGIN + _OP_DIV) 103 | #define OP_INT_MINUS (OP_INT_BEGIN + _OP_MINUS) 104 | #define OP_INT_END OP_INT_MINUS 105 | 106 | #define OP_DBL_BEGIN 120 107 | #define OP_DBL_EQ (OP_DBL_BEGIN + _OP_EQ) 108 | #define OP_DBL_NEQ (OP_DBL_BEGIN + _OP_NEQ) 109 | #define OP_DBL_LT (OP_DBL_BEGIN + _OP_LT) 110 | #define OP_DBL_GT (OP_DBL_BEGIN + _OP_GT) 111 | #define OP_DBL_LE (OP_DBL_BEGIN + _OP_LE) 112 | #define OP_DBL_GE (OP_DBL_BEGIN + _OP_GE) 113 | #define OP_DBL_ADD (OP_DBL_BEGIN + _OP_ADD) 114 | #define OP_DBL_SUB (OP_DBL_BEGIN + _OP_SUB) 115 | #define OP_DBL_MUL (OP_DBL_BEGIN + _OP_MUL) 116 | #define OP_DBL_DIV (OP_DBL_BEGIN + _OP_DIV) 117 | #define OP_DBL_MINUS (OP_DBL_BEGIN + _OP_MINUS) 118 | #define OP_DBL_END OP_DBL_MINUS 119 | 120 | #define OP_STR_BEGIN 140 121 | #define OP_STR_EQ (OP_STR_BEGIN + _OP_EQ) 122 | #define OP_STR_NEQ (OP_STR_BEGIN + _OP_NEQ) 123 | #define OP_STR_LT (OP_STR_BEGIN + _OP_LT) 124 | #define OP_STR_GT (OP_STR_BEGIN + _OP_GT) 125 | #define OP_STR_LE (OP_STR_BEGIN + _OP_LE) 126 | #define OP_STR_GE (OP_STR_BEGIN + _OP_GE) 127 | #define OP_STR_END OP_STR_GE 128 | 129 | #define IS_INT_OP(x) ((x) >= OP_INT_BEGIN && (x) <= OP_INT_END) 130 | #define IS_DBL_OP(x) ((x) >= OP_DBL_BEGIN && (x) <= OP_DBL_END) 131 | #define IS_STR_OP(x) ((x) >= OP_STR_BEGIN && (x) <= OP_STR_END) 132 | 133 | #define OP_READ_INT 240 134 | #define OP_INT8 (OP_READ_INT + 0) 135 | #define OP_INT16 (OP_READ_INT + 1) 136 | #define OP_INT32 (OP_READ_INT + 2) 137 | #define OP_UINT8 (OP_READ_INT + 3) 138 | #define OP_UINT16 (OP_READ_INT + 4) 139 | #define OP_UINT32 (OP_READ_INT + 5) 140 | #define OP_INT8BE (OP_READ_INT + 6) 141 | #define OP_INT16BE (OP_READ_INT + 7) 142 | #define OP_INT32BE (OP_READ_INT + 8) 143 | #define OP_UINT8BE (OP_READ_INT + 9) 144 | #define OP_UINT16BE (OP_READ_INT + 10) 145 | #define OP_UINT32BE (OP_READ_INT + 11) 146 | 147 | 148 | #define OPERATION(operator, op1, op2) \ 149 | (IS_UNDEFINED(op1) || IS_UNDEFINED(op2)) ? (UNDEFINED) : (op1 operator op2) 150 | 151 | 152 | #define COMPARISON(operator, op1, op2) \ 153 | (IS_UNDEFINED(op1) || IS_UNDEFINED(op2)) ? (0) : (op1 operator op2) 154 | 155 | 156 | int yr_execute_code( 157 | YR_RULES* rules, 158 | YR_SCAN_CONTEXT* context, 159 | int timeout, 160 | time_t start_time); 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/exefiles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_EXEFILES_H 18 | #define YR_EXEFILES_H 19 | 20 | uint64_t yr_get_entry_point_offset( 21 | uint8_t* buffer, 22 | size_t buffer_length); 23 | 24 | 25 | uint64_t yr_get_entry_point_address( 26 | uint8_t* buffer, 27 | size_t buffer_length, 28 | size_t base_address); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/filemap.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2015. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_FILEMAP_H 18 | #define YR_FILEMAP_H 19 | 20 | #ifdef _MSC_VER 21 | #define off_t int64_t 22 | #else 23 | #include 24 | #endif 25 | 26 | #if defined(_WIN32) || defined(__CYGWIN__) 27 | #include 28 | #define YR_FILE_DESCRIPTOR HANDLE 29 | #else 30 | #define YR_FILE_DESCRIPTOR int 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | #include "utils.h" 37 | 38 | 39 | typedef struct _YR_MAPPED_FILE 40 | { 41 | YR_FILE_DESCRIPTOR file; 42 | size_t size; 43 | uint8_t* data; 44 | #if defined(_WIN32) || defined(__CYGWIN__) 45 | HANDLE mapping; 46 | #endif 47 | 48 | } YR_MAPPED_FILE; 49 | 50 | 51 | YR_API int yr_filemap_map( 52 | const char* file_path, 53 | YR_MAPPED_FILE* pmapped_file); 54 | 55 | 56 | YR_API int yr_filemap_map_fd( 57 | YR_FILE_DESCRIPTOR file, 58 | off_t offset, 59 | size_t size, 60 | YR_MAPPED_FILE* pmapped_file); 61 | 62 | 63 | YR_API int yr_filemap_map_ex( 64 | const char* file_path, 65 | off_t offset, 66 | size_t size, 67 | YR_MAPPED_FILE* pmapped_file); 68 | 69 | 70 | YR_API void yr_filemap_unmap( 71 | YR_MAPPED_FILE* pmapped_file); 72 | 73 | 74 | YR_API void yr_filemap_unmap_fd( 75 | YR_MAPPED_FILE* pmapped_file); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_GLOBALS_H 18 | #define YR_GLOBALS_H 19 | 20 | extern char lowercase[256]; 21 | extern char altercase[256]; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_HASH_H 18 | #define YR_HASH_H 19 | 20 | #include "utils.h" 21 | 22 | typedef struct _YR_HASH_TABLE_ENTRY 23 | { 24 | char* key; 25 | char* ns; 26 | void* value; 27 | 28 | struct _YR_HASH_TABLE_ENTRY* next; 29 | 30 | } YR_HASH_TABLE_ENTRY; 31 | 32 | 33 | typedef struct _YR_HASH_TABLE 34 | { 35 | int size; 36 | 37 | YR_HASH_TABLE_ENTRY* buckets[1]; 38 | 39 | } YR_HASH_TABLE; 40 | 41 | 42 | typedef int (*YR_HASH_TABLE_FREE_VALUE_FUNC)(void* value); 43 | 44 | 45 | YR_API int yr_hash_table_create( 46 | int size, 47 | YR_HASH_TABLE** table); 48 | 49 | 50 | YR_API void yr_hash_table_clean( 51 | YR_HASH_TABLE* table, 52 | YR_HASH_TABLE_FREE_VALUE_FUNC free_value); 53 | 54 | 55 | YR_API void yr_hash_table_destroy( 56 | YR_HASH_TABLE* table, 57 | YR_HASH_TABLE_FREE_VALUE_FUNC free_value); 58 | 59 | 60 | YR_API void* yr_hash_table_lookup( 61 | YR_HASH_TABLE* table, 62 | const char* key, 63 | const char* ns); 64 | 65 | 66 | YR_API int yr_hash_table_add( 67 | YR_HASH_TABLE* table, 68 | const char* key, 69 | const char* ns, 70 | void* value); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/hex_lexer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007. Victor M. Alvarez [plusvic@gmail.com]. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "re.h" 18 | 19 | #undef yyparse 20 | #undef yylex 21 | #undef yyerror 22 | #undef yyfatal 23 | #undef yychar 24 | #undef yydebug 25 | #undef yynerrs 26 | #undef yyget_extra 27 | #undef yyget_lineno 28 | 29 | #undef YY_FATAL_ERROR 30 | #undef YY_DECL 31 | #undef LEX_ENV 32 | 33 | #define yyparse hex_yyparse 34 | #define yylex hex_yylex 35 | #define yyerror hex_yyerror 36 | #define yyfatal hex_yyfatal 37 | #define yychar hex_yychar 38 | #define yydebug hex_yydebug 39 | #define yynerrs hex_yynerrs 40 | #define yyget_extra hex_yyget_extra 41 | #define yyget_lineno hex_yyget_lineno 42 | 43 | 44 | #ifndef YY_TYPEDEF_YY_SCANNER_T 45 | #define YY_TYPEDEF_YY_SCANNER_T 46 | typedef void* yyscan_t; 47 | #endif 48 | 49 | #define YY_EXTRA_TYPE RE* 50 | #define YY_USE_CONST 51 | 52 | 53 | typedef struct _HEX_LEX_ENVIRONMENT 54 | { 55 | int token_count; 56 | int inside_or; 57 | int last_error_code; 58 | char last_error_message[256]; 59 | 60 | } HEX_LEX_ENVIRONMENT; 61 | 62 | 63 | #define YY_FATAL_ERROR(msg) hex_yyfatal(yyscanner, msg) 64 | 65 | #define LEX_ENV ((HEX_LEX_ENVIRONMENT*) lex_env) 66 | 67 | #include 68 | 69 | #define YY_DECL int hex_yylex \ 70 | (YYSTYPE * yylval_param , yyscan_t yyscanner, HEX_LEX_ENVIRONMENT* lex_env) 71 | 72 | 73 | YY_EXTRA_TYPE yyget_extra( 74 | yyscan_t yyscanner); 75 | 76 | int yylex( 77 | YYSTYPE* yylval_param, 78 | yyscan_t yyscanner, 79 | HEX_LEX_ENVIRONMENT* lex_env); 80 | 81 | int yyparse( 82 | void* yyscanner, 83 | HEX_LEX_ENVIRONMENT* lex_env); 84 | 85 | void yyerror( 86 | yyscan_t yyscanner, 87 | HEX_LEX_ENVIRONMENT* lex_env, 88 | const char* error_message); 89 | 90 | void yyfatal( 91 | yyscan_t yyscanner, 92 | const char* error_message); 93 | 94 | int yr_parse_hex_string( 95 | const char* hex_string, 96 | int flags, 97 | RE** re, 98 | RE_ERROR* error); 99 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/lexer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007. Victor M. Alvarez [plusvic@gmail.com]. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "compiler.h" 18 | 19 | 20 | #undef yyparse 21 | #undef yylex 22 | #undef yyerror 23 | #undef yyfatal 24 | #undef yychar 25 | #undef yydebug 26 | #undef yynerrs 27 | #undef yyget_extra 28 | #undef yyget_lineno 29 | 30 | #undef YY_DECL 31 | #undef YY_FATAL_ERROR 32 | #undef YY_EXTRA_TYPE 33 | 34 | #define yyparse yara_yyparse 35 | #define yylex yara_yylex 36 | #define yyerror yara_yyerror 37 | #define yyfatal yara_yyfatal 38 | #define yywarning yara_yywarning 39 | #define yychar yara_yychar 40 | #define yydebug yara_yydebug 41 | #define yynerrs yara_yynerrs 42 | #define yyget_extra yara_yyget_extra 43 | #define yyget_lineno yara_yyget_lineno 44 | 45 | 46 | #ifndef YY_TYPEDEF_YY_SCANNER_T 47 | #define YY_TYPEDEF_YY_SCANNER_T 48 | typedef void* yyscan_t; 49 | #endif 50 | 51 | #ifndef YY_TYPEDEF_EXPRESSION_T 52 | #define YY_TYPEDEF_EXPRESSION_T 53 | 54 | 55 | // Expression type constants are powers of two because they are used as flags. 56 | // For example: 57 | // CHECK_TYPE(whatever, EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT) 58 | // The expression above is used to ensure that the type of "whatever" is either 59 | // integer or float. 60 | 61 | #define EXPRESSION_TYPE_BOOLEAN 1 62 | #define EXPRESSION_TYPE_INTEGER 2 63 | #define EXPRESSION_TYPE_STRING 4 64 | #define EXPRESSION_TYPE_REGEXP 8 65 | #define EXPRESSION_TYPE_OBJECT 16 66 | #define EXPRESSION_TYPE_FLOAT 32 67 | 68 | typedef struct _EXPRESSION 69 | { 70 | int type; 71 | 72 | union 73 | { 74 | int64_t integer; 75 | YR_OBJECT* object; 76 | SIZED_STRING* sized_string; 77 | } value; 78 | 79 | const char* identifier; 80 | 81 | } EXPRESSION; 82 | 83 | union YYSTYPE; 84 | 85 | #endif 86 | 87 | 88 | #define YY_DECL int yylex( \ 89 | union YYSTYPE* yylval_param, yyscan_t yyscanner, YR_COMPILER* compiler) 90 | 91 | 92 | #define YY_FATAL_ERROR(msg) yara_yyfatal(yyscanner, msg) 93 | 94 | 95 | #define YY_EXTRA_TYPE YR_COMPILER* 96 | #define YY_USE_CONST 97 | 98 | 99 | int yyget_lineno(yyscan_t yyscanner); 100 | 101 | int yylex( 102 | union YYSTYPE* yylval_param, 103 | yyscan_t yyscanner, 104 | YR_COMPILER* compiler); 105 | 106 | int yyparse( 107 | void* yyscanner, 108 | YR_COMPILER* compiler); 109 | 110 | void yyerror( 111 | yyscan_t yyscanner, 112 | YR_COMPILER* compiler, 113 | const char* error_message); 114 | 115 | void yywarning( 116 | yyscan_t yyscanner, 117 | const char* message_fmt, 118 | ...); 119 | 120 | void yyfatal( 121 | yyscan_t yyscanner, 122 | const char* error_message); 123 | 124 | YY_EXTRA_TYPE yyget_extra( 125 | yyscan_t yyscanner); 126 | 127 | int yr_lex_parse_rules_string( 128 | const char* rules_string, 129 | YR_COMPILER* compiler); 130 | 131 | int yr_lex_parse_rules_file( 132 | FILE* rules_file, 133 | YR_COMPILER* compiler); 134 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/libyara.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_LIBYARA_H 18 | #define YR_LIBYARA_H 19 | 20 | #include "utils.h" 21 | 22 | #define YR_MAJOR_VERSION 3 23 | #define YR_MINOR_VERSION 4 24 | #define YR_MICRO_VERSION 0 25 | 26 | // Version as a string 27 | #define YR_VERSION "3.4.0" 28 | 29 | 30 | // Version as a single 4-byte hex number, e.g. 0x030401 == 3.4.1. 31 | #define YR_VERSION_HEX ((YR_MAJOR_VERSION << 16) | \ 32 | (YR_MINOR_VERSION << 8) | \ 33 | (YR_MICRO_VERSION << 0)) 34 | 35 | 36 | // Enumerated type listing configuration options 37 | typedef enum _YR_CONFIG_NAME 38 | { 39 | YR_CONFIG_STACK_SIZE, 40 | YR_CONFIG_MAX 41 | 42 | } YR_CONFIG_NAME; 43 | 44 | 45 | #define DEFAULT_STACK_SIZE 16384 46 | 47 | 48 | YR_API int yr_initialize(void); 49 | 50 | 51 | YR_API int yr_finalize(void); 52 | 53 | 54 | YR_API void yr_finalize_thread(void); 55 | 56 | 57 | YR_API int yr_get_tidx(void); 58 | 59 | 60 | YR_API void yr_set_tidx(int); 61 | 62 | 63 | YR_API int yr_set_configuration(YR_CONFIG_NAME, void*); 64 | 65 | 66 | YR_API int yr_get_configuration(YR_CONFIG_NAME, void*); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_LIMITS_H 18 | #define YR_LIMITS_H 19 | 20 | #if defined(_WIN32) || defined(__CYGWIN__) 21 | #include 22 | #endif 23 | 24 | 25 | // MAX_THREADS is the number of threads that can use a YR_RULES 26 | // object simultaneosly. This value is limited by the number of 27 | // bits in tidx_mask. 28 | 29 | #define MAX_THREADS 32 30 | 31 | 32 | #ifndef MAX_PATH 33 | #define MAX_PATH 1024 34 | #endif 35 | 36 | #define MAX_COMPILER_ERROR_EXTRA_INFO 256 37 | #define MAX_ATOM_LENGTH 4 38 | #define MAX_LOOP_NESTING 4 39 | #define MAX_ARENA_PAGES 32 40 | #define MAX_INCLUDE_DEPTH 16 41 | #define MAX_STRING_MATCHES 1000000 42 | #define MAX_FUNCTION_ARGS 128 43 | #define MAX_FAST_HEX_RE_STACK 300 44 | #define MAX_OVERLOADED_FUNCTIONS 10 45 | #define MAX_HEX_STRING_TOKENS 10000 46 | 47 | #define LOOP_LOCAL_VARS 4 48 | #define STRING_CHAINING_THRESHOLD 200 49 | #define LEX_BUF_SIZE 8192 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_MEM_H 18 | #define YR_MEM_H 19 | 20 | #include 21 | 22 | #include "config.h" 23 | 24 | #ifdef DMALLOC 25 | 26 | #define yr_malloc malloc 27 | #define yr_calloc calloc 28 | #define yr_realloc realloc 29 | #define yr_free free 30 | #define yr_strdup strdup 31 | #define yr_strndup strndup 32 | 33 | #include 34 | 35 | #else 36 | 37 | void* yr_calloc( 38 | size_t count, 39 | size_t size); 40 | 41 | void* yr_malloc( 42 | size_t size); 43 | 44 | void* yr_realloc( 45 | void* ptr, 46 | size_t size); 47 | 48 | void yr_free( 49 | void* ptr); 50 | 51 | char* yr_strdup( 52 | const char* str); 53 | 54 | char* yr_strndup( 55 | const char* str, size_t n); 56 | 57 | #endif 58 | 59 | int yr_heap_alloc(void); 60 | 61 | int yr_heap_free(void); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/object.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_OBJECT_H 18 | #define YR_OBJECT_H 19 | 20 | #ifdef _MSC_VER 21 | 22 | #include 23 | #define isnan _isnan 24 | 25 | #ifndef INFINITY 26 | #define INFINITY (DBL_MAX + DBL_MAX) 27 | #endif 28 | 29 | #ifndef NAN 30 | #define NAN (INFINITY-INFINITY) 31 | #endif 32 | 33 | #endif 34 | 35 | #include "types.h" 36 | 37 | 38 | #define OBJECT_CREATE 1 39 | 40 | #define OBJECT_TYPE_INTEGER 1 41 | #define OBJECT_TYPE_STRING 2 42 | #define OBJECT_TYPE_STRUCTURE 3 43 | #define OBJECT_TYPE_ARRAY 4 44 | #define OBJECT_TYPE_FUNCTION 5 45 | #define OBJECT_TYPE_REGEXP 6 46 | #define OBJECT_TYPE_DICTIONARY 7 47 | #define OBJECT_TYPE_FLOAT 8 48 | 49 | 50 | int yr_object_create( 51 | int8_t type, 52 | const char* identifier, 53 | YR_OBJECT* parent, 54 | YR_OBJECT** object); 55 | 56 | 57 | int yr_object_function_create( 58 | const char* identifier, 59 | const char* arguments_fmt, 60 | const char* return_fmt, 61 | YR_MODULE_FUNC func, 62 | YR_OBJECT* parent, 63 | YR_OBJECT** function); 64 | 65 | 66 | int yr_object_from_external_variable( 67 | YR_EXTERNAL_VARIABLE* external, 68 | YR_OBJECT** object); 69 | 70 | 71 | void yr_object_destroy( 72 | YR_OBJECT* object); 73 | 74 | 75 | YR_OBJECT* yr_object_lookup_field( 76 | YR_OBJECT* object, 77 | const char* field_name); 78 | 79 | 80 | YR_OBJECT* yr_object_lookup( 81 | YR_OBJECT* root, 82 | int flags, 83 | const char* pattern, 84 | ...); 85 | 86 | 87 | int yr_object_has_undefined_value( 88 | YR_OBJECT* object, 89 | const char* field, 90 | ...); 91 | 92 | int64_t yr_object_get_integer( 93 | YR_OBJECT* object, 94 | const char* field, 95 | ...); 96 | 97 | 98 | SIZED_STRING* yr_object_get_string( 99 | YR_OBJECT* object, 100 | const char* field, 101 | ...); 102 | 103 | 104 | int yr_object_set_integer( 105 | int64_t value, 106 | YR_OBJECT* object, 107 | const char* field, 108 | ...); 109 | 110 | 111 | int yr_object_set_float( 112 | double value, 113 | YR_OBJECT* object, 114 | const char* field, 115 | ...); 116 | 117 | 118 | int yr_object_set_string( 119 | const char* value, 120 | size_t len, 121 | YR_OBJECT* object, 122 | const char* field, 123 | ...); 124 | 125 | 126 | YR_OBJECT* yr_object_array_get_item( 127 | YR_OBJECT* object, 128 | int flags, 129 | int index); 130 | 131 | 132 | int yr_object_array_set_item( 133 | YR_OBJECT* object, 134 | YR_OBJECT* item, 135 | int index); 136 | 137 | 138 | YR_OBJECT* yr_object_dict_get_item( 139 | YR_OBJECT* object, 140 | int flags, 141 | const char* key); 142 | 143 | 144 | int yr_object_dict_set_item( 145 | YR_OBJECT* object, 146 | YR_OBJECT* item, 147 | const char* key); 148 | 149 | 150 | int yr_object_structure_set_member( 151 | YR_OBJECT* object, 152 | YR_OBJECT* member); 153 | 154 | 155 | YR_OBJECT* yr_object_get_root( 156 | YR_OBJECT* object); 157 | 158 | 159 | YR_API void yr_object_print_data( 160 | YR_OBJECT* object, 161 | int indent, 162 | int print_identifier); 163 | 164 | 165 | #endif 166 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_PARSER_H 18 | #define YR_PARSER_H 19 | 20 | 21 | #include "lexer.h" 22 | 23 | 24 | int yr_parser_emit( 25 | yyscan_t yyscanner, 26 | uint8_t instruction, 27 | uint8_t** instruction_address); 28 | 29 | 30 | int yr_parser_emit_with_arg( 31 | yyscan_t yyscanner, 32 | uint8_t instruction, 33 | int64_t argument, 34 | uint8_t** instruction_address, 35 | int64_t** argument_address); 36 | 37 | 38 | int yr_parser_emit_with_arg_double( 39 | yyscan_t yyscanner, 40 | uint8_t instruction, 41 | double argument, 42 | uint8_t** instruction_address, 43 | double** argument_address); 44 | 45 | 46 | int yr_parser_emit_with_arg_reloc( 47 | yyscan_t yyscanner, 48 | uint8_t instruction, 49 | int64_t argument, 50 | uint8_t** instruction_address, 51 | int64_t** argument_address); 52 | 53 | 54 | int yr_parser_check_types( 55 | YR_COMPILER* compiler, 56 | YR_OBJECT_FUNCTION* function, 57 | const char* actual_args_fmt); 58 | 59 | 60 | YR_STRING* yr_parser_lookup_string( 61 | yyscan_t yyscanner, 62 | const char* identifier); 63 | 64 | 65 | int yr_parser_lookup_loop_variable( 66 | yyscan_t yyscanner, 67 | const char* identifier); 68 | 69 | 70 | YR_RULE* yr_parser_reduce_rule_declaration_phase_1( 71 | yyscan_t yyscanner, 72 | int32_t flags, 73 | const char* identifier); 74 | 75 | 76 | int yr_parser_reduce_rule_declaration_phase_2( 77 | yyscan_t yyscanner, 78 | YR_RULE* rule); 79 | 80 | 81 | YR_STRING* yr_parser_reduce_string_declaration( 82 | yyscan_t yyscanner, 83 | int32_t flags, 84 | const char* identifier, 85 | SIZED_STRING* str); 86 | 87 | 88 | YR_META* yr_parser_reduce_meta_declaration( 89 | yyscan_t yyscanner, 90 | int32_t type, 91 | const char* identifier, 92 | const char* string, 93 | int64_t integer); 94 | 95 | 96 | int yr_parser_reduce_string_identifier( 97 | yyscan_t yyscanner, 98 | const char* identifier, 99 | uint8_t instruction, 100 | uint64_t at_offset); 101 | 102 | 103 | int yr_parser_emit_pushes_for_strings( 104 | yyscan_t yyscanner, 105 | const char* identifier); 106 | 107 | 108 | int yr_parser_reduce_external( 109 | yyscan_t yyscanner, 110 | const char* identifier, 111 | uint8_t intruction); 112 | 113 | 114 | int yr_parser_reduce_import( 115 | yyscan_t yyscanner, 116 | SIZED_STRING* module_name); 117 | 118 | 119 | int yr_parser_reduce_operation( 120 | yyscan_t yyscanner, 121 | const char* operation, 122 | EXPRESSION left_operand, 123 | EXPRESSION right_operand); 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/proc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_PROC_H 18 | #define YR_PROC_H 19 | 20 | #include "types.h" 21 | 22 | int yr_process_get_memory( 23 | int pid, 24 | YR_MEMORY_BLOCK** first_block); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/re.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_RE_H 18 | #define YR_RE_H 19 | 20 | #include 21 | 22 | #include "arena.h" 23 | #include "sizedstr.h" 24 | 25 | #define RE_NODE_LITERAL 1 26 | #define RE_NODE_MASKED_LITERAL 2 27 | #define RE_NODE_ANY 3 28 | #define RE_NODE_CONCAT 4 29 | #define RE_NODE_ALT 5 30 | #define RE_NODE_RANGE 6 31 | #define RE_NODE_STAR 7 32 | #define RE_NODE_PLUS 8 33 | #define RE_NODE_CLASS 9 34 | #define RE_NODE_WORD_CHAR 10 35 | #define RE_NODE_NON_WORD_CHAR 11 36 | #define RE_NODE_SPACE 12 37 | #define RE_NODE_NON_SPACE 13 38 | #define RE_NODE_DIGIT 14 39 | #define RE_NODE_NON_DIGIT 15 40 | #define RE_NODE_EMPTY 16 41 | #define RE_NODE_ANCHOR_START 17 42 | #define RE_NODE_ANCHOR_END 18 43 | #define RE_NODE_WORD_BOUNDARY 19 44 | #define RE_NODE_NON_WORD_BOUNDARY 20 45 | 46 | 47 | #define RE_OPCODE_ANY 0xA0 48 | #define RE_OPCODE_ANY_EXCEPT_NEW_LINE 0xA1 49 | #define RE_OPCODE_LITERAL 0xA2 50 | #define RE_OPCODE_LITERAL_NO_CASE 0xA3 51 | #define RE_OPCODE_MASKED_LITERAL 0xA4 52 | #define RE_OPCODE_CLASS 0xA5 53 | #define RE_OPCODE_CLASS_NO_CASE 0xA6 54 | #define RE_OPCODE_WORD_CHAR 0xA7 55 | #define RE_OPCODE_NON_WORD_CHAR 0xA8 56 | #define RE_OPCODE_SPACE 0xA9 57 | #define RE_OPCODE_NON_SPACE 0xAA 58 | #define RE_OPCODE_DIGIT 0xAB 59 | #define RE_OPCODE_NON_DIGIT 0xAC 60 | #define RE_OPCODE_MATCH 0xAD 61 | 62 | #define RE_OPCODE_MATCH_AT_END 0xB0 63 | #define RE_OPCODE_MATCH_AT_START 0xB1 64 | #define RE_OPCODE_WORD_BOUNDARY 0xB2 65 | #define RE_OPCODE_NON_WORD_BOUNDARY 0xB3 66 | 67 | #define RE_OPCODE_SPLIT_A 0xC0 68 | #define RE_OPCODE_SPLIT_B 0xC1 69 | #define RE_OPCODE_PUSH 0xC2 70 | #define RE_OPCODE_POP 0xC3 71 | #define RE_OPCODE_JNZ 0xC4 72 | #define RE_OPCODE_JUMP 0xC5 73 | 74 | 75 | #define RE_FLAGS_FAST_HEX_REGEXP 0x02 76 | #define RE_FLAGS_BACKWARDS 0x04 77 | #define RE_FLAGS_EXHAUSTIVE 0x08 78 | #define RE_FLAGS_WIDE 0x10 79 | #define RE_FLAGS_NO_CASE 0x20 80 | #define RE_FLAGS_SCAN 0x40 81 | #define RE_FLAGS_DOT_ALL 0x80 82 | #define RE_FLAGS_NOT_AT_START 0x100 83 | #define RE_FLAGS_GREEDY 0x400 84 | #define RE_FLAGS_UNGREEDY 0x800 85 | 86 | 87 | typedef struct RE RE; 88 | typedef struct RE_NODE RE_NODE; 89 | typedef struct RE_ERROR RE_ERROR; 90 | 91 | typedef uint8_t RE_SPLIT_ID_TYPE; 92 | typedef uint8_t* RE_CODE; 93 | 94 | #define CHAR_IN_CLASS(chr, cls) \ 95 | ((cls)[(chr) / 8] & 1 << ((chr) % 8)) 96 | 97 | 98 | #define IS_WORD_CHAR(chr) \ 99 | (isalnum(chr) || (chr) == '_') 100 | 101 | 102 | struct RE_NODE 103 | { 104 | int type; 105 | 106 | union 107 | { 108 | int value; 109 | int count; 110 | int start; 111 | }; 112 | 113 | union 114 | { 115 | int mask; 116 | int end; 117 | }; 118 | 119 | int greedy; 120 | 121 | uint8_t* class_vector; 122 | 123 | RE_NODE* left; 124 | RE_NODE* right; 125 | 126 | RE_CODE forward_code; 127 | RE_CODE backward_code; 128 | }; 129 | 130 | 131 | struct RE 132 | { 133 | 134 | uint32_t flags; 135 | RE_NODE* root_node; 136 | YR_ARENA* code_arena; 137 | RE_CODE code; 138 | }; 139 | 140 | 141 | struct RE_ERROR 142 | { 143 | 144 | char message[512]; 145 | 146 | }; 147 | 148 | 149 | typedef int RE_MATCH_CALLBACK_FUNC( 150 | uint8_t* match, 151 | int match_length, 152 | int flags, 153 | void* args); 154 | 155 | 156 | int yr_re_create( 157 | RE** re); 158 | 159 | 160 | int yr_re_parse( 161 | const char* re_string, 162 | int flags, 163 | RE** re, 164 | RE_ERROR* error); 165 | 166 | 167 | int yr_re_parse_hex( 168 | const char* hex_string, 169 | int flags, 170 | RE** re, 171 | RE_ERROR* error); 172 | 173 | 174 | int yr_re_compile( 175 | const char* re_string, 176 | int flags, 177 | YR_ARENA* code_arena, 178 | RE** re, 179 | RE_ERROR* error); 180 | 181 | 182 | void yr_re_destroy( 183 | RE* re); 184 | 185 | 186 | void yr_re_print( 187 | RE* re); 188 | 189 | 190 | RE_NODE* yr_re_node_create( 191 | int type, 192 | RE_NODE* left, 193 | RE_NODE* right); 194 | 195 | 196 | void yr_re_node_destroy( 197 | RE_NODE* node); 198 | 199 | 200 | SIZED_STRING* yr_re_extract_literal( 201 | RE* re); 202 | 203 | 204 | int yr_re_contains_dot_star( 205 | RE* re); 206 | 207 | 208 | int yr_re_split_at_chaining_point( 209 | RE* re, 210 | RE** result_re, 211 | RE** remainder_re, 212 | int32_t* min_gap, 213 | int32_t* max_gap); 214 | 215 | 216 | int yr_re_emit_code( 217 | RE* re, 218 | YR_ARENA* arena); 219 | 220 | 221 | int yr_re_exec( 222 | RE_CODE re_code, 223 | uint8_t* input, 224 | size_t input_size, 225 | int flags, 226 | RE_MATCH_CALLBACK_FUNC callback, 227 | void* callback_args); 228 | 229 | 230 | int yr_re_match( 231 | RE_CODE re_code, 232 | const char* target); 233 | 234 | 235 | int yr_re_initialize(void); 236 | 237 | 238 | int yr_re_finalize(void); 239 | 240 | 241 | int yr_re_finalize_thread(void); 242 | 243 | #endif 244 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/re_lexer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #undef yyparse 18 | #undef yylex 19 | #undef yyerror 20 | #undef yyfatal 21 | #undef yychar 22 | #undef yydebug 23 | #undef yynerrs 24 | #undef yyget_extra 25 | #undef yyget_lineno 26 | 27 | #undef YY_FATAL_ERROR 28 | #undef YY_DECL 29 | #undef LEX_ENV 30 | 31 | 32 | #define yyparse re_yyparse 33 | #define yylex re_yylex 34 | #define yyerror re_yyerror 35 | #define yyfatal re_yyfatal 36 | #define yychar re_yychar 37 | #define yydebug re_yydebug 38 | #define yynerrs re_yynerrs 39 | #define yyget_extra re_yyget_extra 40 | #define yyget_lineno re_yyget_lineno 41 | 42 | 43 | #ifndef YY_TYPEDEF_YY_SCANNER_T 44 | #define YY_TYPEDEF_YY_SCANNER_T 45 | typedef void* yyscan_t; 46 | #endif 47 | 48 | #define YY_EXTRA_TYPE RE* 49 | #define YY_USE_CONST 50 | 51 | 52 | typedef struct _RE_LEX_ENVIRONMENT 53 | { 54 | int negated_class; 55 | uint8_t class_vector[32]; 56 | int last_error_code; 57 | char last_error_message[256]; 58 | 59 | } RE_LEX_ENVIRONMENT; 60 | 61 | 62 | #define LEX_ENV ((RE_LEX_ENVIRONMENT*) lex_env) 63 | 64 | #define YY_FATAL_ERROR(msg) re_yyfatal(yyscanner, msg) 65 | 66 | #include 67 | 68 | #define YY_DECL int re_yylex \ 69 | (YYSTYPE * yylval_param , yyscan_t yyscanner, RE_LEX_ENVIRONMENT* lex_env) 70 | 71 | 72 | YY_EXTRA_TYPE yyget_extra( 73 | yyscan_t yyscanner); 74 | 75 | int yylex( 76 | YYSTYPE* yylval_param, 77 | yyscan_t yyscanner, 78 | RE_LEX_ENVIRONMENT* lex_env); 79 | 80 | int yyparse( 81 | void* yyscanner, 82 | RE_LEX_ENVIRONMENT* lex_env); 83 | 84 | void yyerror( 85 | yyscan_t yyscanner, 86 | RE_LEX_ENVIRONMENT* lex_env, 87 | const char* error_message); 88 | 89 | void yyfatal( 90 | yyscan_t yyscanner, 91 | const char* error_message); 92 | 93 | int yr_parse_re_string( 94 | const char* re_string, 95 | int flags, 96 | RE** re, 97 | RE_ERROR* error); 98 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/rules.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_RULES_H 18 | #define YR_RULES_H 19 | 20 | #include "types.h" 21 | #include "utils.h" 22 | #include "filemap.h" 23 | 24 | 25 | #define CALLBACK_MSG_RULE_MATCHING 1 26 | #define CALLBACK_MSG_RULE_NOT_MATCHING 2 27 | #define CALLBACK_MSG_SCAN_FINISHED 3 28 | #define CALLBACK_MSG_IMPORT_MODULE 4 29 | #define CALLBACK_MSG_MODULE_IMPORTED 5 30 | 31 | #define CALLBACK_CONTINUE 0 32 | #define CALLBACK_ABORT 1 33 | #define CALLBACK_ERROR 2 34 | 35 | 36 | #define yr_rule_tags_foreach(rule, tag_name) \ 37 | for (tag_name = rule->tags; \ 38 | tag_name != NULL && *tag_name != '\0'; \ 39 | tag_name += strlen(tag_name) + 1) 40 | 41 | 42 | #define yr_rule_metas_foreach(rule, meta) \ 43 | for (meta = rule->metas; !META_IS_NULL(meta); meta++) 44 | 45 | 46 | #define yr_rule_strings_foreach(rule, string) \ 47 | for (string = rule->strings; !STRING_IS_NULL(string); string++) 48 | 49 | 50 | #define yr_string_matches_foreach(string, match) \ 51 | for (match = STRING_MATCHES(string).head; match != NULL; match = match->next) 52 | 53 | 54 | #define yr_rules_foreach(rules, rule) \ 55 | for (rule = rules->rules_list_head; !RULE_IS_NULL(rule); rule++) 56 | 57 | 58 | 59 | YR_API int yr_rules_scan_mem( 60 | YR_RULES* rules, 61 | uint8_t* buffer, 62 | size_t buffer_size, 63 | int flags, 64 | YR_CALLBACK_FUNC callback, 65 | void* user_data, 66 | int timeout); 67 | 68 | 69 | YR_API int yr_rules_scan_file( 70 | YR_RULES* rules, 71 | const char* filename, 72 | int flags, 73 | YR_CALLBACK_FUNC callback, 74 | void* user_data, 75 | int timeout); 76 | 77 | 78 | YR_API int yr_rules_scan_fd( 79 | YR_RULES* rules, 80 | YR_FILE_DESCRIPTOR fd, 81 | int flags, 82 | YR_CALLBACK_FUNC callback, 83 | void* user_data, 84 | int timeout); 85 | 86 | 87 | YR_API int yr_rules_scan_proc( 88 | YR_RULES* rules, 89 | int pid, 90 | int flags, 91 | YR_CALLBACK_FUNC callback, 92 | void* user_data, 93 | int timeout); 94 | 95 | 96 | YR_API int yr_rules_save( 97 | YR_RULES* rules, 98 | const char* filename); 99 | 100 | 101 | YR_API int yr_rules_save_stream( 102 | YR_RULES* rules, 103 | YR_STREAM* stream); 104 | 105 | 106 | YR_API int yr_rules_load( 107 | const char* filename, 108 | YR_RULES** rules); 109 | 110 | 111 | YR_API int yr_rules_load_stream( 112 | YR_STREAM* stream, 113 | YR_RULES** rules); 114 | 115 | 116 | YR_API int yr_rules_destroy( 117 | YR_RULES* rules); 118 | 119 | 120 | YR_API int yr_rules_define_integer_variable( 121 | YR_RULES* rules, 122 | const char* identifier, 123 | int64_t value); 124 | 125 | 126 | YR_API int yr_rules_define_boolean_variable( 127 | YR_RULES* rules, 128 | const char* identifier, 129 | int value); 130 | 131 | 132 | YR_API int yr_rules_define_float_variable( 133 | YR_RULES* rules, 134 | const char* identifier, 135 | double value); 136 | 137 | 138 | YR_API int yr_rules_define_string_variable( 139 | YR_RULES* rules, 140 | const char* identifier, 141 | const char* value); 142 | 143 | 144 | YR_API void yr_rules_print_profiling_info( 145 | YR_RULES* rules); 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_SCAN_H 18 | #define YR_SCAN_H 19 | 20 | #include "types.h" 21 | 22 | // Bitmasks for flags. 23 | #define SCAN_FLAGS_FAST_MODE 1 24 | #define SCAN_FLAGS_PROCESS_MEMORY 2 25 | 26 | 27 | int yr_scan_verify_match( 28 | YR_SCAN_CONTEXT* context, 29 | YR_AC_MATCH* ac_match, 30 | uint8_t* data, 31 | size_t data_size, 32 | size_t data_base, 33 | size_t offset); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/sizedstr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef _SIZEDSTR_H 18 | #define _SIZEDSTR_H 19 | 20 | #include 21 | 22 | // 23 | // This struct is used to support strings containing null chars. The length of 24 | // the string is stored along the string data. However the string data is also 25 | // terminated with a null char. 26 | // 27 | 28 | #define SIZED_STRING_FLAGS_NO_CASE 1 29 | #define SIZED_STRING_FLAGS_DOT_ALL 2 30 | 31 | typedef struct _SIZED_STRING 32 | { 33 | size_t length; 34 | int flags; 35 | char c_string[1]; 36 | 37 | } SIZED_STRING; 38 | 39 | 40 | int sized_string_cmp( 41 | SIZED_STRING* s1, 42 | SIZED_STRING* s2); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_STREAM_H 18 | #define YR_STREAM_H 19 | 20 | #include 21 | 22 | typedef size_t (*YR_STREAM_READ_FUNC)( 23 | void* ptr, 24 | size_t size, 25 | size_t count, 26 | void* user_data); 27 | 28 | 29 | typedef size_t (*YR_STREAM_WRITE_FUNC)( 30 | const void* ptr, 31 | size_t size, 32 | size_t count, 33 | void* user_data); 34 | 35 | 36 | typedef struct _YR_STREAM 37 | { 38 | void* user_data; 39 | 40 | YR_STREAM_READ_FUNC read; 41 | YR_STREAM_WRITE_FUNC write; 42 | 43 | } YR_STREAM; 44 | 45 | 46 | size_t yr_stream_read( 47 | void* ptr, 48 | size_t size, 49 | size_t count, 50 | YR_STREAM* stream); 51 | 52 | 53 | size_t yr_stream_write( 54 | const void* ptr, 55 | size_t size, 56 | size_t count, 57 | YR_STREAM* stream); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/strutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_STRUTILS_H 18 | #define YR_STRUTILS_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "config.h" 25 | 26 | // Cygwin already has these functions. 27 | #if defined(_WIN32) && !defined(__CYGWIN__) 28 | #if defined(_MSC_VER) && _MSC_VER < 1900 29 | #define snprintf _snprintf 30 | #endif 31 | #define strcasecmp _stricmp 32 | #define strncasecmp _strnicmp 33 | #endif 34 | 35 | 36 | uint64_t xtoi( 37 | const char* hexstr); 38 | 39 | 40 | #if !HAVE_STRLCPY && !defined(strlcpy) 41 | size_t strlcpy( 42 | char* dst, 43 | const char* src, 44 | size_t size); 45 | #endif 46 | 47 | 48 | #if !HAVE_STRLCAT && !defined(strlcat) 49 | size_t strlcat( 50 | char* dst, 51 | const char* src, 52 | size_t size); 53 | #endif 54 | 55 | 56 | #if !HAVE_MEMMEM && !defined(memmem) 57 | void* memmem( 58 | const void* haystack, 59 | size_t haystack_size, 60 | const void* needle, 61 | size_t needle_size); 62 | #endif 63 | 64 | 65 | int strnlen_w( 66 | const char* w_str); 67 | 68 | 69 | int strcmp_w( 70 | const char* w_str, 71 | const char* str); 72 | 73 | 74 | size_t strlcpy_w( 75 | char* dst, 76 | const char* w_src, 77 | size_t n); 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/threading.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #ifndef YR_MUTEX_H 18 | #define YR_MUTEX_H 19 | 20 | 21 | 22 | #if defined(_WIN32) || defined(__CYGWIN__) 23 | 24 | #include 25 | 26 | typedef DWORD YR_THREAD_ID; 27 | typedef DWORD YR_THREAD_STORAGE_KEY; 28 | typedef HANDLE YR_MUTEX; 29 | 30 | #else 31 | 32 | #include 33 | 34 | typedef pthread_t YR_THREAD_ID; 35 | typedef pthread_key_t YR_THREAD_STORAGE_KEY; 36 | typedef pthread_mutex_t YR_MUTEX; 37 | 38 | #endif 39 | 40 | YR_THREAD_ID yr_current_thread_id(void); 41 | 42 | int yr_mutex_create(YR_MUTEX*); 43 | int yr_mutex_destroy(YR_MUTEX*); 44 | int yr_mutex_lock(YR_MUTEX*); 45 | int yr_mutex_unlock(YR_MUTEX*); 46 | 47 | int yr_thread_storage_create(YR_THREAD_STORAGE_KEY*); 48 | int yr_thread_storage_destroy(YR_THREAD_STORAGE_KEY*); 49 | int yr_thread_storage_set_value(YR_THREAD_STORAGE_KEY*, void*); 50 | void* yr_thread_storage_get_value(YR_THREAD_STORAGE_KEY*); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014. The YARA Authors. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef YR_UTILS_H 19 | #define YR_UTILS_H 20 | 21 | #ifndef TRUE 22 | #define TRUE 1 23 | #endif 24 | 25 | #ifndef FALSE 26 | #define FALSE 0 27 | #endif 28 | 29 | #ifndef NULL 30 | #define NULL 0 31 | #endif 32 | 33 | #ifdef __cplusplus 34 | #define EXTERNC extern "C" 35 | #else 36 | #define EXTERNC 37 | #endif 38 | 39 | #if defined(__GNUC__) 40 | #define YR_API EXTERNC __attribute__((visibility("default"))) 41 | #elif defined(_MSC_VER) 42 | #define YR_API EXTERNC __declspec(dllexport) 43 | #else 44 | #define YR_API EXTERNC 45 | #endif 46 | 47 | #if defined(__GNUC__) 48 | #define YR_ALIGN(n) __attribute__((aligned(n))) 49 | #elif defined(_MSC_VER) 50 | #define YR_ALIGN(n) __declspec(align(n)) 51 | #else 52 | #define YR_ALIGN(n) 53 | #endif 54 | 55 | #define yr_min(x, y) ((x < y) ? (x) : (y)) 56 | #define yr_max(x, y) ((x > y) ? (x) : (y)) 57 | 58 | #define PTR_TO_INT64(x) ((int64_t) (size_t) x) 59 | 60 | 61 | #ifdef NDEBUG 62 | 63 | #define assertf(expr, msg, ...) ((void)0) 64 | 65 | #else 66 | 67 | #include 68 | 69 | #define assertf(expr, msg, ...) \ 70 | if(!(expr)) { \ 71 | fprintf(stderr, "%s:%d: " msg "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ 72 | abort(); \ 73 | } 74 | 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /pluginsdk/yara/yara_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/yara/yara_x64.lib -------------------------------------------------------------------------------- /pluginsdk/yara/yara_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x64dbg/testplugin/4ceae85ca8e8b63ff155495311c2c4b92febce99/pluginsdk/yara/yara_x86.lib -------------------------------------------------------------------------------- /script.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPT_H 2 | #define _SCRIPT_H 3 | 4 | #include "pluginmain.h" 5 | 6 | void cbScript(); 7 | 8 | #endif //_SCRIPT_H -------------------------------------------------------------------------------- /test.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEST_H 2 | #define _TEST_H 3 | 4 | #include "pluginmain.h" 5 | 6 | //menu identifiers 7 | #define MENU_DUMP 0 8 | #define MENU_TEST 1 9 | #define MENU_SELECTION 2 10 | #define MENU_FILEOFFSET 3 11 | #define MENU_GRAPH_SELECTION 4 12 | #define MENU_GRAPH_FUNCTION 5 13 | #define MENU_SCRIPT 6 14 | 15 | #define MENU_DISASM_ADLER32 7 16 | #define MENU_DUMP_ADLER32 8 17 | #define MENU_STACK_ADLER32 9 18 | #define MENU_DISASM_GRAPH_SELECTION 10 19 | #define MENU_DISASM_GRAPH_FUNCTION 11 20 | 21 | //functions 22 | void testInit(PLUG_INITSTRUCT* initStruct); 23 | void testStop(); 24 | void testSetup(); 25 | 26 | #endif // _TEST_H 27 | -------------------------------------------------------------------------------- /x64_dbg_testplugin.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 82 | 83 | -------------------------------------------------------------------------------- /x64_dbg_testplugin.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "x64_dbg_testplugin", "x64_dbg_testplugin.vcxproj", "{C1055F2B-A0C2-0005-0D1B-3C99DC93F137}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Release|Win32 = Release|Win32 9 | Release|x64 = Release|x64 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {C1055F2B-A0C2-0005-0D1B-3C99DC93F137}.Release|Win32.ActiveCfg = Release|Win32 13 | {C1055F2B-A0C2-0005-0D1B-3C99DC93F137}.Release|Win32.Build.0 = Release|Win32 14 | {C1055F2B-A0C2-0005-0D1B-3C99DC93F137}.Release|x64.ActiveCfg = Release|x64 15 | {C1055F2B-A0C2-0005-0D1B-3C99DC93F137}.Release|x64.Build.0 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /x64_dbg_testplugin.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Release 6 | Win32 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | Win32Proj 102 | {C1055F2B-A0C2-0005-0D1B-3C99DC93F137} 103 | 104 | 105 | 106 | DynamicLibrary 107 | false 108 | v120_xp 109 | 110 | 111 | DynamicLibrary 112 | false 113 | v120_xp 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | false 127 | $(SolutionDir)bin\x32\ 128 | $(Platform)\$(Configuration)\ 129 | testplugin 130 | .dll 131 | 132 | 133 | false 134 | $(SolutionDir)bin\x64\ 135 | testplugin 136 | .dll 137 | 138 | 139 | 140 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;%(PreprocessorDefinitions) 141 | MultiThreadedDLL 142 | Level3 143 | ProgramDatabase 144 | 145 | 146 | MachineX86 147 | true 148 | Windows 149 | true 150 | true 151 | winmm.lib;angelscript\angelscript.lib;psapi.lib;pluginsdk\x32dbg.lib;pluginsdk\x32bridge.lib;pluginsdk\TitanEngine\TitanEngine_x86.lib;%(AdditionalDependencies) 152 | 153 | 154 | 155 | 156 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;X64_DBG_EXPORTS;%(PreprocessorDefinitions) 157 | MultiThreadedDLL 158 | Level3 159 | ProgramDatabase 160 | 161 | 162 | true 163 | Windows 164 | true 165 | true 166 | winmm.lib;angelscript\angelscript64.lib;psapi.lib;pluginsdk\x64dbg.lib;pluginsdk\x64bridge.lib;pluginsdk\TitanEngine\TitanEngine_x64.lib;%(AdditionalDependencies) 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /x64_dbg_testplugin.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | --------------------------------------------------------------------------------