├── .gitignore ├── LICENSE ├── plugins ├── BinaryNinja │ ├── .gitignore │ ├── README.md │ ├── __init__.py │ ├── plugin.json │ └── requirements.txt ├── IDA │ └── REToolSync.py ├── VSCode │ ├── .eslintrc.json │ ├── .gitignore │ ├── .vscode │ │ ├── extensions.json │ │ ├── launch.json │ │ ├── settings.json │ │ └── tasks.json │ ├── .vscodeignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── extension.ts │ │ └── test │ │ │ ├── runTest.ts │ │ │ └── suite │ │ │ ├── extension.test.ts │ │ │ └── index.ts │ ├── test │ │ └── generate_addresses.py │ └── tsconfig.json ├── WinDbg │ ├── .gitignore │ ├── CMakeLists.txt │ ├── cmake.toml │ ├── cmkr.cmake │ ├── include │ │ ├── REToolSync │ │ │ ├── Extension.hpp │ │ │ └── cursor.hpp │ │ ├── easywsclient.hpp │ │ └── json.hpp │ └── src │ │ └── REToolSync │ │ ├── Extension.cpp │ │ ├── cursor.cpp │ │ └── easywsclient.cpp └── x64dbg │ ├── .gitignore │ ├── REToolSync.sln │ └── REToolSync │ ├── REToolSync.vcxproj │ ├── REToolSync.vcxproj.filters │ ├── easywsclient.cpp │ ├── easywsclient.hpp │ ├── json.hpp │ ├── plugin.cpp │ ├── plugin.h │ ├── 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 │ ├── sha1.cpp │ ├── sha1.hpp │ ├── stringutils.cpp │ └── stringutils.h └── server ├── REToolSync.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /plugins/x64dbg/REToolSync/PluginDevBuildTool.exe 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /plugins/BinaryNinja/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /plugins/BinaryNinja/README.md: -------------------------------------------------------------------------------- 1 | # Sample Plugin 2 | Author: **Vector 35 Inc** 3 | 4 | _This is a short description meant to fit on one line._ 5 | 6 | ## Description: 7 | This is a longer description meant for a sample plugin that demonstrates the metadata format for Binary Ninja plugins. Note that the [community-plugins repo](https://github.com/Vector35/community-plugins) contains a useful [utility](https://github.com/Vector35/community-plugins/blob/master/generate_plugininfo.py) to validate the plugin.json. Additionally, the [release helper](https://github.com/Vector35/release_helper) plugin is helpful for more easily pushing new releases, incrementing versions, and creating the appropriate GitHub tags. 8 | 9 | Note that originally we recommended specifying the contents of this entire file inside of the [plugin.json](./plugin.json) but the latest repository generator will use the readme contents directly which means you should simply leave an empty longdescription field. 10 | 11 | ## License 12 | 13 | This plugin is released under an [MIT license](./license). 14 | -------------------------------------------------------------------------------- /plugins/BinaryNinja/__init__.py: -------------------------------------------------------------------------------- 1 | from glob import glob 2 | import os 3 | import json 4 | import asyncio 5 | import queue 6 | import threading 7 | import traceback 8 | import struct 9 | import time 10 | import logging 11 | from typing import Tuple 12 | 13 | from binaryninja import * 14 | from binaryninjaui import * 15 | 16 | import tornado.ioloop 17 | import tornado.websocket 18 | import tornado.httpclient 19 | 20 | def get_static_info(): 21 | # TODO 22 | return { 23 | 'path': '', 24 | 'module': '', 25 | 'base': hex(0), 26 | 'size': hex(0), 27 | 'md5': '', 28 | 'sha256': '', 29 | 'crc32': hex(0), 30 | 'filesize': hex(0), 31 | } 32 | 33 | global_cursor = None 34 | global_selection = None 35 | global_frame = None 36 | 37 | def get_cursor() -> int: 38 | global global_cursor 39 | return global_cursor 40 | 41 | def get_selection() -> Tuple[bool, int, int]: 42 | global global_selection 43 | if global_selection is None: 44 | return False, 0, 0 45 | else: 46 | return True, global_selection[0], global_selection[1] 47 | 48 | # Reference: https://www.georgeho.org/tornado-websockets/ 49 | # IDAPython cheat sheet: https://gist.github.com/icecr4ck/7a7af3277787c794c66965517199fc9c 50 | # https://github.com/inforion/idapython-cheatsheet 51 | class WebSocketClient: 52 | def __init__(self, io_loop): 53 | self.connection: tornado.websocket.WebSocketClientConnection = None 54 | self.periodic_cb = tornado.ioloop.PeriodicCallback(self.timeout, 250) 55 | self.io_loop = io_loop 56 | self.num_messages = 0 57 | self.connection_count = 0 58 | self.reconnect_count = 0 59 | self.info = get_static_info() 60 | self.cursor_info = {} 61 | self.last_cursor = 0 62 | self.last_selection = None 63 | 64 | def start(self): 65 | self.connect_and_read() 66 | 67 | def stop(self): 68 | if self.connection: 69 | self.connection.close() 70 | self.connection = None 71 | if self.periodic_cb.is_running(): 72 | self.periodic_cb.stop() 73 | self.io_loop.stop() 74 | 75 | def timeout(self): 76 | cursor_info = {} 77 | cursor = get_cursor() 78 | if cursor is None: 79 | return 80 | selection = get_selection() 81 | 82 | cursor_info["address"] = hex(cursor) 83 | ok, start, end = selection 84 | if ok: 85 | cursor_info["selection_start"] = hex(start) 86 | cursor_info["selection_end"] = hex(end) 87 | else: 88 | cursor_info["selection_start"] = None 89 | cursor_info["selection_end"] = None 90 | 91 | if not cursor_info == self.cursor_info: 92 | #print(f"[REToolSync] cursor change: ({json.dumps(self.cursor_info)}) -> ({json.dumps(cursor_info)})") 93 | if self.connection: 94 | self.connection.write_message(json.dumps({"cursor": [cursor_info]})) 95 | 96 | self.cursor_info = cursor_info 97 | 98 | return 99 | 100 | def connect_and_read(self): 101 | endpoint = os.environ.get("RETOOLSYNC_ENDPOINT", "127.0.0.1:6969") 102 | request = tornado.httpclient.HTTPRequest(f"ws://{endpoint}/REToolSync", headers={"User-Agent": f"REToolSync Binary Ninja {os.getpid()}"}) 103 | print(f"[REToolSync] Connecting to {endpoint} ...") 104 | tornado.websocket.websocket_connect( 105 | url=request, 106 | callback=self.maybe_retry_connection, 107 | on_message_callback=self.on_message, 108 | ping_interval=10, 109 | ping_timeout=30, 110 | ) 111 | 112 | def maybe_retry_connection(self, future) -> None: 113 | try: 114 | self.connection = future.result() 115 | print("[REToolSync] Connected to server!") 116 | self.periodic_cb.start() 117 | self.connection.write_message(json.dumps(self.info)) 118 | self.connection_count += 1 119 | except ConnectionError as x: 120 | self.reconnect_count += 1 121 | if self.connection_count > 0 and self.reconnect_count < 10: 122 | print("[REToolSync] Could not reconnect, retrying in 3 seconds...") 123 | self.io_loop.call_later(3, self.connect_and_read) 124 | else: 125 | print("[REToolSync] Failed to connect, use the menu to retry") 126 | self.stop() 127 | except Exception as x: 128 | print(f"[REToolSync] exception: {x}, {type(x)}") 129 | raise x 130 | 131 | def on_message(self, message): 132 | if message is None: 133 | print("[REToolSync] Disconnected, reconnecting in 3 seconds...") 134 | self.periodic_cb.stop() 135 | self.io_loop.call_later(3, self.connect_and_read) 136 | return 137 | 138 | self.num_messages += 1 139 | 140 | msg = json.loads(message) 141 | if msg.get("request", "") == "goto": 142 | # Reference: https://github.com/joshwatson/binaryninja-bookmarks/blob/master/__init__.py#L71 143 | def goto(addr): 144 | global global_frame 145 | bv = global_frame.getCurrentBinaryView() 146 | bv.navigate(bv.file.view, addr) 147 | address = int(msg["address"], 16) 148 | print(f"[REToolSync] Goto {hex(address)}") 149 | mainthread.execute_on_main_thread(lambda: goto(address)) 150 | else: 151 | print(f"[REToolSync] unsupported message: {message}") 152 | 153 | def write_message(self, message): 154 | if self.connection: 155 | self.connection.write_message(message) 156 | 157 | def join_gui_thread(thread: threading.Thread, timeout=None): 158 | iterations = 0 159 | iteration_timeout = 0.1 160 | while True: 161 | if not thread.is_alive(): 162 | return True 163 | thread.join(iteration_timeout) 164 | #QtWidgets.QApplication.processEvents() 165 | if timeout is not None and iteration_timeout * iterations >= timeout: 166 | return False 167 | iterations += 1 168 | 169 | class Service: 170 | def __init__(self) -> None: 171 | self.started = False 172 | self.client: WebSocketClient = None 173 | self.wsthread: threading.Thread = None 174 | 175 | def start(self): 176 | self.stop() 177 | self.wsthread = threading.Thread(target=self.service_thread) 178 | self.wsthread.start() 179 | self.started = True 180 | print("[REToolSync] Service started") 181 | 182 | def stop(self): 183 | if not self.started: 184 | return 185 | 186 | if self.client is not None: 187 | self.client.stop() 188 | 189 | if not join_gui_thread(self.wsthread, 1.0): 190 | print("[REToolSync] Waiting for service to stop...") 191 | if not join_gui_thread(self.wsthread, 5.0): 192 | print(f"[REToolSync] deadlock while stopping service, please report an issue!\n") 193 | self.wsthread = None 194 | self.client = None 195 | print("[REToolSync] Service stopped") 196 | 197 | def service_thread(self): 198 | # Create a new event loop for the thread 199 | # https://github.com/tornadoweb/tornado/issues/2308#issuecomment-372582005 200 | loop = asyncio.new_event_loop() 201 | loop.set_debug(False) 202 | logging.getLogger("asyncio").setLevel(logging.CRITICAL) # Remove some debug spam 203 | asyncio.set_event_loop(loop) 204 | 205 | # Before starting the event loop, instantiate a WebSocketClient and add a 206 | # callback to the event loop to start it. This way the first thing the 207 | # event loop does is to start the client. 208 | io_loop = tornado.ioloop.IOLoop.current() 209 | self.client = WebSocketClient(io_loop) 210 | io_loop.add_callback(self.client.start) 211 | 212 | # Start the event loop. 213 | io_loop.start() 214 | 215 | # Signal that the service is finished 216 | self.started = False 217 | 218 | # Reference: https://github.com/Vector35/binaryninja-api/blob/ed820d2ab81470b3e5ac543d75211e87ff3bc738/python/examples/ui_notifications.py 219 | class UINotification(UIContextNotification): 220 | def __init__(self): 221 | UIContextNotification.__init__(self) 222 | UIContext.registerNotification(self) 223 | 224 | self.service = Service() 225 | self.service.start() 226 | 227 | def __del__(self): 228 | UIContext.unregisterNotification(self) 229 | 230 | self.service.stop() 231 | 232 | def OnAddressChange(self, context, frame, view, location): 233 | global global_cursor, global_selection 234 | global_cursor = location.getOffset() 235 | if view: 236 | global_selection = view.getSelectionOffsets() 237 | else: 238 | global_selection = None 239 | 240 | def OnViewChange(self, context, frame, t): 241 | # frame.getCurrentBinaryView() is the global `bv` object or the `view` in other callbacks 242 | global global_frame 243 | global_frame = frame 244 | 245 | # Register as a global so it doesn't get destructed 246 | notif = UINotification() 247 | -------------------------------------------------------------------------------- /plugins/BinaryNinja/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "pluginmetadataversion": 2, 3 | "name": "REToolSync", 4 | "type": [ 5 | "core", 6 | "ui", 7 | "architecture", 8 | "binaryview", 9 | "helper" 10 | ], 11 | "api": [ 12 | "python3" 13 | ], 14 | "description": "Improve your reverse engineering workflow.", 15 | "longdescription": "", 16 | "platforms": [ 17 | "Darwin", 18 | "Linux", 19 | "Windows" 20 | ], 21 | "installinstructions": { 22 | "Darwin": "Install the following pip packages: ...\n\nInstall the following brew packages: ...", 23 | "Linux": "Install the following pip packages: ...\n\nInstall the following apt packages: ...", 24 | "Windows": "Install the following pip packages: ...\n\nInstall the following libraries: ..." 25 | }, 26 | "dependencies": { 27 | "pip": [ 28 | "tornado" 29 | ] 30 | }, 31 | "version": "0.1.0", 32 | "author": "mrexodia", 33 | "minimumbinaryninjaversion": 3164 34 | } 35 | -------------------------------------------------------------------------------- /plugins/BinaryNinja/requirements.txt: -------------------------------------------------------------------------------- 1 | tornado -------------------------------------------------------------------------------- /plugins/VSCode/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | }, 19 | "ignorePatterns": [ 20 | "out", 21 | "dist", 22 | "**/*.d.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /plugins/VSCode/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | out/ 3 | *.vsix -------------------------------------------------------------------------------- /plugins/VSCode/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /plugins/VSCode/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/out/**/*.js" 17 | ], 18 | "preLaunchTask": "${defaultBuildTask}" 19 | }, 20 | { 21 | "name": "Extension Tests", 22 | "type": "extensionHost", 23 | "request": "launch", 24 | "args": [ 25 | "--extensionDevelopmentPath=${workspaceFolder}", 26 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" 27 | ], 28 | "outFiles": [ 29 | "${workspaceFolder}/out/test/**/*.js" 30 | ], 31 | "preLaunchTask": "${defaultBuildTask}" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /plugins/VSCode/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 10 | "typescript.tsc.autoDetect": "off" 11 | } -------------------------------------------------------------------------------- /plugins/VSCode/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /plugins/VSCode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | src/** 4 | .gitignore 5 | .yarnrc 6 | vsc-extension-quickstart.md 7 | **/tsconfig.json 8 | **/.eslintrc.json 9 | **/*.map 10 | **/*.ts 11 | -------------------------------------------------------------------------------- /plugins/VSCode/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "retoolsync" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | 9 | - Initial release -------------------------------------------------------------------------------- /plugins/VSCode/README.md: -------------------------------------------------------------------------------- 1 | # REToolSync 2 | 3 | This is an extension that improves your reverse engineering workflow using [REToolSync](https://github.com/mrexodia/REToolSync). 4 | 5 | ## Features 6 | 7 | If you print an address `0x12345` in the Terminal you can use Ctrl+Click to follow that address in all REToolSync-supported tools. 8 | 9 | ## Development 10 | 11 | ``` 12 | # Global dependencies 13 | npm i -g vsce yo generator-code 14 | # Local dependencies 15 | npm i 16 | # Build VSIX 17 | vsce package 18 | ``` -------------------------------------------------------------------------------- /plugins/VSCode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "retoolsync", 3 | "displayName": "REToolSync", 4 | "publisher": "REToolSync", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/mrexodia/REToolSync" 8 | }, 9 | "description": "Improve your reverse engineering workflow with VSCode", 10 | "version": "0.0.1", 11 | "engines": { 12 | "vscode": "^1.71.0" 13 | }, 14 | "categories": [ 15 | "Other" 16 | ], 17 | "activationEvents": [ 18 | "*" 19 | ], 20 | "main": "./out/extension.js", 21 | "contributes": { 22 | "commands": [ 23 | { 24 | "command": "retoolsync.helloWorld", 25 | "title": "REToolSync: Hello World" 26 | } 27 | ], 28 | "configuration": [ 29 | { 30 | "title": "REToolSync", 31 | "properties": { 32 | "retoolsync.server": { 33 | "type": "string", 34 | "default": "http://localhost:6969", 35 | "description": "Address of the REToolSync server" 36 | } 37 | } 38 | } 39 | ] 40 | }, 41 | "scripts": { 42 | "vscode:prepublish": "npm run compile", 43 | "compile": "tsc -p ./", 44 | "watch": "tsc -watch -p ./", 45 | "pretest": "npm run compile && npm run lint", 46 | "lint": "eslint src --ext ts", 47 | "test": "node ./out/test/runTest.js" 48 | }, 49 | "devDependencies": { 50 | "@types/glob": "^8.0.0", 51 | "@types/mocha": "^10.0.0", 52 | "@types/node": "16.x", 53 | "@types/vscode": "^1.71.0", 54 | "@typescript-eslint/eslint-plugin": "^5.38.1", 55 | "@typescript-eslint/parser": "^5.38.1", 56 | "@vscode/test-electron": "^2.1.5", 57 | "eslint": "^8.24.0", 58 | "glob": "^8.0.3", 59 | "mocha": "^10.0.0", 60 | "typescript": "^4.8.4" 61 | }, 62 | "dependencies": { 63 | "axios": "^0.27.2" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /plugins/VSCode/src/extension.ts: -------------------------------------------------------------------------------- 1 | // The module 'vscode' contains the VS Code extensibility API 2 | // Import the module and reference it with the alias vscode in your code below 3 | import * as vscode from "vscode"; 4 | import axios from "axios"; 5 | 6 | interface CustomTerminalLink extends vscode.TerminalLink { 7 | data: string; 8 | } 9 | 10 | // This method is called when your extension is activated 11 | // Your extension is activated the very first time the command is executed 12 | export function activate(context: vscode.ExtensionContext) { 13 | // Get server from configuration 14 | let server = vscode.workspace 15 | .getConfiguration("retoolsync") 16 | .get("server", "http://localhost:6969"); 17 | 18 | // Remove trailing / 19 | if (server.endsWith("/")) { 20 | server = server.substring(0, server.length - 1); 21 | } 22 | 23 | // https://stackoverflow.com/a/58139566/1806760 24 | let debug = vscode.window.createOutputChannel("REToolSync"); 25 | debug.appendLine(`REToolSync server: ${server}`); 26 | 27 | // Reference: https://www.eliostruyf.com/handle-links-in-the-terminal-from-your-vscode-extension/ 28 | const linkDisposable = vscode.window.registerTerminalLinkProvider({ 29 | provideTerminalLinks: ( 30 | context: vscode.TerminalLinkContext, 31 | token: vscode.CancellationToken 32 | ) => { 33 | // Detect the first instance of the word "link" if it exists and linkify it 34 | const matches = [...context.line.matchAll(/0x[0-9a-fA-F]+/g)]; 35 | 36 | return matches.map((match) => { 37 | const line = context.line; 38 | 39 | const startIndex = line.indexOf(match[0]); 40 | 41 | debug.appendLine(`Found potential address: ${match[0]}`); 42 | 43 | return { 44 | startIndex, 45 | length: match[0].length, 46 | tooltip: "REToolSync: Goto address", 47 | data: match[0], 48 | } as CustomTerminalLink; 49 | }); 50 | }, 51 | handleTerminalLink: async (link: CustomTerminalLink) => { 52 | const address = link.data; 53 | vscode.window.showInformationMessage( 54 | `REToolSync: Goto address: ${address}` 55 | ); 56 | try { 57 | debug.appendLine(`Goto address: ${address}`); 58 | const { data, status } = await axios.post( 59 | `${server}/api/goto?address=${address}`, 60 | null, 61 | { 62 | headers: { 63 | // eslint-disable-next-line @typescript-eslint/naming-convention 64 | "User-Agent": "REToolSync VSCode", 65 | }, 66 | } 67 | ); 68 | debug.appendLine(`Status: ${status}, Data: ${data}`); 69 | } catch (error) { 70 | const message = `Failed to goto address ${address}: ${error}`; 71 | debug.appendLine(message); 72 | vscode.window.showErrorMessage(message); 73 | } 74 | }, 75 | }); 76 | 77 | // The command has been defined in the package.json file 78 | // Now provide the implementation of the command with registerCommand 79 | // The commandId parameter must match the command field in package.json 80 | const commandDisposable = vscode.commands.registerCommand( 81 | "retoolsync.helloWorld", 82 | () => { 83 | // The code you place here will be executed every time your command is executed 84 | // Display a message box to the user 85 | vscode.window.showInformationMessage("Hello World from REToolSync!"); 86 | } 87 | ); 88 | 89 | // Clean up properly 90 | context.subscriptions.push(linkDisposable, commandDisposable); 91 | } 92 | 93 | // This method is called when your extension is deactivated 94 | export function deactivate() {} 95 | -------------------------------------------------------------------------------- /plugins/VSCode/src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from '@vscode/test-electron'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /plugins/VSCode/src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /plugins/VSCode/src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import * as Mocha from 'mocha'; 3 | import * as glob from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run(failures => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | console.error(err); 34 | e(err); 35 | } 36 | }); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /plugins/VSCode/test/generate_addresses.py: -------------------------------------------------------------------------------- 1 | link = "http://google.com" 2 | print("0x0000000140002476") 3 | for i in range(1000): 4 | print(f"test{i}") 5 | print("0x140002476") 6 | print("0x14000257c") -------------------------------------------------------------------------------- /plugins/VSCode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES2020", 5 | "outDir": "out", 6 | "lib": [ 7 | "ES2020" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true /* enable all strict type-checking options */ 12 | /* Additional Checks */ 13 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 14 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 15 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /plugins/WinDbg/.gitignore: -------------------------------------------------------------------------------- 1 | # cmkr 2 | build*/ 3 | cmake-build*/ 4 | .idea/ 5 | .vscode/ 6 | .cache/ 7 | -------------------------------------------------------------------------------- /plugins/WinDbg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file is automatically generated from cmake.toml - DO NOT EDIT 2 | # See https://github.com/build-cpp/cmkr for more information 3 | 4 | cmake_minimum_required(VERSION 3.15) 5 | 6 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) 7 | message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build") 8 | endif() 9 | 10 | set(CMKR_ROOT_PROJECT OFF) 11 | if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) 12 | set(CMKR_ROOT_PROJECT ON) 13 | 14 | # Bootstrap cmkr and automatically regenerate CMakeLists.txt 15 | include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT) 16 | if(CMKR_INCLUDE_RESULT) 17 | cmkr() 18 | endif() 19 | 20 | # Enable folder support 21 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 22 | 23 | # Create a configure-time dependency on cmake.toml to improve IDE support 24 | configure_file(cmake.toml cmake.toml COPYONLY) 25 | endif() 26 | 27 | project(REToolSync) 28 | 29 | # Target: REToolSync 30 | set(REToolSync_SOURCES 31 | "src/REToolSync/Extension.cpp" 32 | "src/REToolSync/cursor.cpp" 33 | "src/REToolSync/easywsclient.cpp" 34 | "include/REToolSync/Extension.hpp" 35 | "include/REToolSync/cursor.hpp" 36 | "include/easywsclient.hpp" 37 | "include/json.hpp" 38 | cmake.toml 39 | ) 40 | 41 | add_library(REToolSync SHARED) 42 | 43 | target_sources(REToolSync PRIVATE ${REToolSync_SOURCES}) 44 | source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${REToolSync_SOURCES}) 45 | 46 | target_compile_features(REToolSync PUBLIC 47 | cxx_std_20 48 | ) 49 | 50 | -------------------------------------------------------------------------------- /plugins/WinDbg/cmake.toml: -------------------------------------------------------------------------------- 1 | # Reference: https://build-cpp.github.io/cmkr/cmake-toml 2 | [project] 3 | name = "REToolSync" 4 | 5 | [target.REToolSync] 6 | type = "shared" 7 | sources = ["src/REToolSync/*.cpp"] 8 | headers = [ 9 | "include/REToolSync/*.h", 10 | "include/REToolSync/*.hpp", 11 | "include/*.hpp", 12 | "include/*.h", 13 | ] 14 | compile-features = ["cxx_std_20"] 15 | -------------------------------------------------------------------------------- /plugins/WinDbg/cmkr.cmake: -------------------------------------------------------------------------------- 1 | include_guard() 2 | 3 | # Change these defaults to point to your infrastructure if desired 4 | set(CMKR_REPO "https://github.com/build-cpp/cmkr" CACHE STRING "cmkr git repository" FORCE) 5 | set(CMKR_TAG "v0.2.23" CACHE STRING "cmkr git tag (this needs to be available forever)" FORCE) 6 | set(CMKR_COMMIT_HASH "" CACHE STRING "cmkr git commit hash (optional)" FORCE) 7 | 8 | # To bootstrap/generate a cmkr project: cmake -P cmkr.cmake 9 | if(CMAKE_SCRIPT_MODE_FILE) 10 | set(CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}/build") 11 | set(CMAKE_CURRENT_BINARY_DIR "${CMAKE_BINARY_DIR}") 12 | file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}") 13 | endif() 14 | 15 | # Set these from the command line to customize for development/debugging purposes 16 | set(CMKR_EXECUTABLE "" CACHE FILEPATH "cmkr executable") 17 | set(CMKR_SKIP_GENERATION OFF CACHE BOOL "skip automatic cmkr generation") 18 | set(CMKR_BUILD_TYPE "Debug" CACHE STRING "cmkr build configuration") 19 | mark_as_advanced(CMKR_REPO CMKR_TAG CMKR_COMMIT_HASH CMKR_EXECUTABLE CMKR_SKIP_GENERATION CMKR_BUILD_TYPE) 20 | 21 | # Disable cmkr if generation is disabled 22 | if(DEFINED ENV{CI} OR CMKR_SKIP_GENERATION OR CMKR_BUILD_SKIP_GENERATION) 23 | message(STATUS "[cmkr] Skipping automatic cmkr generation") 24 | unset(CMKR_BUILD_SKIP_GENERATION CACHE) 25 | macro(cmkr) 26 | endmacro() 27 | return() 28 | endif() 29 | 30 | # Disable cmkr if no cmake.toml file is found 31 | if(NOT CMAKE_SCRIPT_MODE_FILE AND NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake.toml") 32 | message(AUTHOR_WARNING "[cmkr] Not found: ${CMAKE_CURRENT_SOURCE_DIR}/cmake.toml") 33 | macro(cmkr) 34 | endmacro() 35 | return() 36 | endif() 37 | 38 | # Convert a Windows native path to CMake path 39 | if(CMKR_EXECUTABLE MATCHES "\\\\") 40 | string(REPLACE "\\" "/" CMKR_EXECUTABLE_CMAKE "${CMKR_EXECUTABLE}") 41 | set(CMKR_EXECUTABLE "${CMKR_EXECUTABLE_CMAKE}" CACHE FILEPATH "" FORCE) 42 | unset(CMKR_EXECUTABLE_CMAKE) 43 | endif() 44 | 45 | # Helper macro to execute a process (COMMAND_ERROR_IS_FATAL ANY is 3.19 and higher) 46 | function(cmkr_exec) 47 | execute_process(COMMAND ${ARGV} RESULT_VARIABLE CMKR_EXEC_RESULT) 48 | if(NOT CMKR_EXEC_RESULT EQUAL 0) 49 | message(FATAL_ERROR "cmkr_exec(${ARGV}) failed (exit code ${CMKR_EXEC_RESULT})") 50 | endif() 51 | endfunction() 52 | 53 | # Windows-specific hack (CMAKE_EXECUTABLE_PREFIX is not set at the moment) 54 | if(WIN32) 55 | set(CMKR_EXECUTABLE_NAME "cmkr.exe") 56 | else() 57 | set(CMKR_EXECUTABLE_NAME "cmkr") 58 | endif() 59 | 60 | # Use cached cmkr if found 61 | if(DEFINED ENV{CMKR_CACHE}) 62 | set(CMKR_DIRECTORY_PREFIX "$ENV{CMKR_CACHE}") 63 | string(REPLACE "\\" "/" CMKR_DIRECTORY_PREFIX "${CMKR_DIRECTORY_PREFIX}") 64 | if(NOT CMKR_DIRECTORY_PREFIX MATCHES "\\/$") 65 | set(CMKR_DIRECTORY_PREFIX "${CMKR_DIRECTORY_PREFIX}/") 66 | endif() 67 | # Build in release mode for the cache 68 | set(CMKR_BUILD_TYPE "Release") 69 | else() 70 | set(CMKR_DIRECTORY_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/_cmkr_") 71 | endif() 72 | set(CMKR_DIRECTORY "${CMKR_DIRECTORY_PREFIX}${CMKR_TAG}") 73 | set(CMKR_CACHED_EXECUTABLE "${CMKR_DIRECTORY}/bin/${CMKR_EXECUTABLE_NAME}") 74 | 75 | # Helper function to check if a string starts with a prefix 76 | # Cannot use MATCHES, see: https://github.com/build-cpp/cmkr/issues/61 77 | function(cmkr_startswith str prefix result) 78 | string(LENGTH "${prefix}" prefix_length) 79 | string(LENGTH "${str}" str_length) 80 | if(prefix_length LESS_EQUAL str_length) 81 | string(SUBSTRING "${str}" 0 ${prefix_length} str_prefix) 82 | if(prefix STREQUAL str_prefix) 83 | set("${result}" ON PARENT_SCOPE) 84 | return() 85 | endif() 86 | endif() 87 | set("${result}" OFF PARENT_SCOPE) 88 | endfunction() 89 | 90 | # Handle upgrading logic 91 | if(CMKR_EXECUTABLE AND NOT CMKR_CACHED_EXECUTABLE STREQUAL CMKR_EXECUTABLE) 92 | cmkr_startswith("${CMKR_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/_cmkr" CMKR_STARTSWITH_BUILD) 93 | cmkr_startswith("${CMKR_EXECUTABLE}" "${CMKR_DIRECTORY_PREFIX}" CMKR_STARTSWITH_CACHE) 94 | if(CMKR_STARTSWITH_BUILD) 95 | if(DEFINED ENV{CMKR_CACHE}) 96 | message(AUTHOR_WARNING "[cmkr] Switching to cached cmkr: '${CMKR_CACHED_EXECUTABLE}'") 97 | if(EXISTS "${CMKR_CACHED_EXECUTABLE}") 98 | set(CMKR_EXECUTABLE "${CMKR_CACHED_EXECUTABLE}" CACHE FILEPATH "Full path to cmkr executable" FORCE) 99 | else() 100 | unset(CMKR_EXECUTABLE CACHE) 101 | endif() 102 | else() 103 | message(AUTHOR_WARNING "[cmkr] Upgrading '${CMKR_EXECUTABLE}' to '${CMKR_CACHED_EXECUTABLE}'") 104 | unset(CMKR_EXECUTABLE CACHE) 105 | endif() 106 | elseif(DEFINED ENV{CMKR_CACHE} AND CMKR_STARTSWITH_CACHE) 107 | message(AUTHOR_WARNING "[cmkr] Upgrading cached '${CMKR_EXECUTABLE}' to '${CMKR_CACHED_EXECUTABLE}'") 108 | unset(CMKR_EXECUTABLE CACHE) 109 | endif() 110 | endif() 111 | 112 | if(CMKR_EXECUTABLE AND EXISTS "${CMKR_EXECUTABLE}") 113 | message(VERBOSE "[cmkr] Found cmkr: '${CMKR_EXECUTABLE}'") 114 | elseif(CMKR_EXECUTABLE AND NOT CMKR_EXECUTABLE STREQUAL CMKR_CACHED_EXECUTABLE) 115 | message(FATAL_ERROR "[cmkr] '${CMKR_EXECUTABLE}' not found") 116 | elseif(NOT CMKR_EXECUTABLE AND EXISTS "${CMKR_CACHED_EXECUTABLE}") 117 | set(CMKR_EXECUTABLE "${CMKR_CACHED_EXECUTABLE}" CACHE FILEPATH "Full path to cmkr executable" FORCE) 118 | message(STATUS "[cmkr] Found cached cmkr: '${CMKR_EXECUTABLE}'") 119 | else() 120 | set(CMKR_EXECUTABLE "${CMKR_CACHED_EXECUTABLE}" CACHE FILEPATH "Full path to cmkr executable" FORCE) 121 | message(VERBOSE "[cmkr] Bootstrapping '${CMKR_EXECUTABLE}'") 122 | 123 | message(STATUS "[cmkr] Fetching cmkr...") 124 | if(EXISTS "${CMKR_DIRECTORY}") 125 | cmkr_exec("${CMAKE_COMMAND}" -E rm -rf "${CMKR_DIRECTORY}") 126 | endif() 127 | find_package(Git QUIET REQUIRED) 128 | cmkr_exec("${GIT_EXECUTABLE}" 129 | clone 130 | --config advice.detachedHead=false 131 | --branch ${CMKR_TAG} 132 | --depth 1 133 | ${CMKR_REPO} 134 | "${CMKR_DIRECTORY}" 135 | ) 136 | if(CMKR_COMMIT_HASH) 137 | execute_process( 138 | COMMAND "${GIT_EXECUTABLE}" checkout -q "${CMKR_COMMIT_HASH}" 139 | RESULT_VARIABLE CMKR_EXEC_RESULT 140 | WORKING_DIRECTORY "${CMKR_DIRECTORY}" 141 | ) 142 | if(NOT CMKR_EXEC_RESULT EQUAL 0) 143 | message(FATAL_ERROR "Tag '${CMKR_TAG}' hash is not '${CMKR_COMMIT_HASH}'") 144 | endif() 145 | endif() 146 | message(STATUS "[cmkr] Building cmkr (using system compiler)...") 147 | cmkr_exec("${CMAKE_COMMAND}" 148 | --no-warn-unused-cli 149 | "${CMKR_DIRECTORY}" 150 | "-B${CMKR_DIRECTORY}/build" 151 | "-DCMAKE_BUILD_TYPE=${CMKR_BUILD_TYPE}" 152 | "-DCMAKE_UNITY_BUILD=ON" 153 | "-DCMAKE_INSTALL_PREFIX=${CMKR_DIRECTORY}" 154 | "-DCMKR_GENERATE_DOCUMENTATION=OFF" 155 | ) 156 | cmkr_exec("${CMAKE_COMMAND}" 157 | --build "${CMKR_DIRECTORY}/build" 158 | --config "${CMKR_BUILD_TYPE}" 159 | --parallel 160 | ) 161 | cmkr_exec("${CMAKE_COMMAND}" 162 | --install "${CMKR_DIRECTORY}/build" 163 | --config "${CMKR_BUILD_TYPE}" 164 | --prefix "${CMKR_DIRECTORY}" 165 | --component cmkr 166 | ) 167 | if(NOT EXISTS ${CMKR_EXECUTABLE}) 168 | message(FATAL_ERROR "[cmkr] Failed to bootstrap '${CMKR_EXECUTABLE}'") 169 | endif() 170 | cmkr_exec("${CMKR_EXECUTABLE}" version) 171 | message(STATUS "[cmkr] Bootstrapped ${CMKR_EXECUTABLE}") 172 | endif() 173 | execute_process(COMMAND "${CMKR_EXECUTABLE}" version 174 | RESULT_VARIABLE CMKR_EXEC_RESULT 175 | ) 176 | if(NOT CMKR_EXEC_RESULT EQUAL 0) 177 | message(FATAL_ERROR "[cmkr] Failed to get version, try clearing the cache and rebuilding") 178 | endif() 179 | 180 | # Use cmkr.cmake as a script 181 | if(CMAKE_SCRIPT_MODE_FILE) 182 | if(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake.toml") 183 | execute_process(COMMAND "${CMKR_EXECUTABLE}" init 184 | RESULT_VARIABLE CMKR_EXEC_RESULT 185 | ) 186 | if(NOT CMKR_EXEC_RESULT EQUAL 0) 187 | message(FATAL_ERROR "[cmkr] Failed to bootstrap cmkr project. Please report an issue: https://github.com/build-cpp/cmkr/issues/new") 188 | else() 189 | message(STATUS "[cmkr] Modify cmake.toml and then configure using: cmake -B build") 190 | endif() 191 | else() 192 | execute_process(COMMAND "${CMKR_EXECUTABLE}" gen 193 | RESULT_VARIABLE CMKR_EXEC_RESULT 194 | ) 195 | if(NOT CMKR_EXEC_RESULT EQUAL 0) 196 | message(FATAL_ERROR "[cmkr] Failed to generate project.") 197 | else() 198 | message(STATUS "[cmkr] Configure using: cmake -B build") 199 | endif() 200 | endif() 201 | endif() 202 | 203 | # This is the macro that contains black magic 204 | macro(cmkr) 205 | # When this macro is called from the generated file, fake some internal CMake variables 206 | get_source_file_property(CMKR_CURRENT_LIST_FILE "${CMAKE_CURRENT_LIST_FILE}" CMKR_CURRENT_LIST_FILE) 207 | if(CMKR_CURRENT_LIST_FILE) 208 | set(CMAKE_CURRENT_LIST_FILE "${CMKR_CURRENT_LIST_FILE}") 209 | get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) 210 | endif() 211 | 212 | # File-based include guard (include_guard is not documented to work) 213 | get_source_file_property(CMKR_INCLUDE_GUARD "${CMAKE_CURRENT_LIST_FILE}" CMKR_INCLUDE_GUARD) 214 | if(NOT CMKR_INCLUDE_GUARD) 215 | set_source_files_properties("${CMAKE_CURRENT_LIST_FILE}" PROPERTIES CMKR_INCLUDE_GUARD TRUE) 216 | 217 | file(SHA256 "${CMAKE_CURRENT_LIST_FILE}" CMKR_LIST_FILE_SHA256_PRE) 218 | 219 | # Generate CMakeLists.txt 220 | cmkr_exec("${CMKR_EXECUTABLE}" gen 221 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 222 | ) 223 | 224 | file(SHA256 "${CMAKE_CURRENT_LIST_FILE}" CMKR_LIST_FILE_SHA256_POST) 225 | 226 | # Delete the temporary file if it was left for some reason 227 | set(CMKR_TEMP_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CMakerLists.txt") 228 | if(EXISTS "${CMKR_TEMP_FILE}") 229 | file(REMOVE "${CMKR_TEMP_FILE}") 230 | endif() 231 | 232 | if(NOT CMKR_LIST_FILE_SHA256_PRE STREQUAL CMKR_LIST_FILE_SHA256_POST) 233 | # Copy the now-generated CMakeLists.txt to CMakerLists.txt 234 | # This is done because you cannot include() a file you are currently in 235 | configure_file(CMakeLists.txt "${CMKR_TEMP_FILE}" COPYONLY) 236 | 237 | # Add the macro required for the hack at the start of the cmkr macro 238 | set_source_files_properties("${CMKR_TEMP_FILE}" PROPERTIES 239 | CMKR_CURRENT_LIST_FILE "${CMAKE_CURRENT_LIST_FILE}" 240 | ) 241 | 242 | # 'Execute' the newly-generated CMakeLists.txt 243 | include("${CMKR_TEMP_FILE}") 244 | 245 | # Delete the generated file 246 | file(REMOVE "${CMKR_TEMP_FILE}") 247 | 248 | # Do not execute the rest of the original CMakeLists.txt 249 | return() 250 | endif() 251 | # Resume executing the unmodified CMakeLists.txt 252 | endif() 253 | endmacro() 254 | -------------------------------------------------------------------------------- /plugins/WinDbg/include/REToolSync/Extension.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | // #include "REToolSync/Extension.h" 10 | // #include "cursor.h" 11 | 12 | #define EXTENSION_NAME "REToolSync" 13 | 14 | HRESULT InitGlobals(); 15 | 16 | extern Microsoft::WRL::ComPtr g_DbgControl; 17 | extern Microsoft::WRL::ComPtr g_DbgClient; 18 | extern Microsoft::WRL::ComPtr g_DbgAdv; 19 | extern Microsoft::WRL::ComPtr g_DbgReg; 20 | extern Microsoft::WRL::ComPtr g_DbgSym; 21 | extern CRITICAL_SECTION g_CritSection; 22 | extern HANDLE g_WsThreadHandle; 23 | 24 | // extern Cursor g_CurrentStateCursor; 25 | 26 | enum LogLevel { 27 | LOG_ERROR = 0, 28 | LOG_WARNING = 1, 29 | LOG_INFO = 2, 30 | LOG_DEBUG = 3, 31 | }; 32 | 33 | #define LOG(level, ...) Log(level, __VA_ARGS__) 34 | 35 | inline void Log(LogLevel level, const char *format, ...) { 36 | #if _DEBUG 37 | va_list args; 38 | va_start(args, format); 39 | char buffer[1024]; 40 | StringCchVPrintf(buffer, 1024, format, args); 41 | va_end(args); 42 | 43 | switch (level) { 44 | case LOG_ERROR: 45 | g_DbgControl->Output(DEBUG_OUTPUT_NORMAL, "[%s !] %s\n", EXTENSION_NAME, 46 | buffer); 47 | break; 48 | 49 | case LOG_WARNING: 50 | g_DbgControl->Output(DEBUG_OUTPUT_NORMAL, "[%s *] %s\n", EXTENSION_NAME, 51 | buffer); 52 | break; 53 | 54 | case LOG_INFO: 55 | g_DbgControl->Output(DEBUG_OUTPUT_NORMAL, "[%s +] %s\n", EXTENSION_NAME, 56 | buffer); 57 | break; 58 | 59 | case LOG_DEBUG: 60 | g_DbgControl->Output(DEBUG_OUTPUT_NORMAL, "[%s ?] %s\n", EXTENSION_NAME, 61 | buffer); 62 | break; 63 | } 64 | #endif 65 | } -------------------------------------------------------------------------------- /plugins/WinDbg/include/REToolSync/cursor.hpp: -------------------------------------------------------------------------------- 1 | #include "../json.hpp" 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | using mod = std::pair; 8 | using mod_set = std::set; 9 | 10 | extern mod_set g_ModVec; 11 | 12 | class Cursor { 13 | /* 14 | * 15 | def get_static_info(): 16 | # This is the desired structure 17 | return { 18 | 'path': '', 19 | 20 | 'module': '', 21 | 'base': hex(0), 22 | 'size': hex(0), 23 | 'md5': '', 24 | 'sha256': '', 25 | 'crc32': hex(0), 26 | 'filesize': hex(0), 27 | } 28 | */ 29 | public: 30 | std::string tool_id = "windbg"; 31 | std::string architecture; 32 | // actual information 33 | uint64_t va = -1; 34 | uint32_t rva = -1; 35 | uint64_t fileoffset = -1; 36 | 37 | // metadata 38 | std::string filepath; 39 | std::string module; 40 | std::string sha1; 41 | std::string md5; 42 | uint32_t TimeDateStamp = -1; 43 | uint64_t loadedbase = -1; // image base as loaded in memory 44 | uint64_t imagebase = -1; // image base in the header 45 | uint32_t imagesize = -1; 46 | 47 | static bool translate_address(Cursor &c, mod &m); 48 | 49 | static uint64_t fromHex(const std::string &text); 50 | 51 | static uint64_t fromDec(const std::string &text); 52 | 53 | static std::string toHex(uint64_t value); 54 | 55 | std::string serialize(int indent = -1) const; 56 | static bool deserialize(const nlohmann::json::value_type &j, Cursor &c); 57 | // static bool deserialize(const nlohmann::json::value_type& j, Cursor& c); ; 58 | static bool deserialize(const char *json, Cursor &c); 59 | static bool deserialize(const char *json, std::vector &cs); 60 | 61 | Cursor() = default; 62 | }; 63 | 64 | bool get_cursors(); 65 | bool deserialize_modvec(const char *json, mod_set &mods); 66 | 67 | HRESULT GetCurrentInstructionCursor(_Out_ Cursor &c); -------------------------------------------------------------------------------- /plugins/WinDbg/include/easywsclient.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD 2 | #define EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD 3 | 4 | // This code comes from: 5 | // https://github.com/dhbaird/easywsclient 6 | // 7 | // It has been modified to support adding a User-Agent header on connection 8 | // 9 | // To get the latest version: 10 | // wget https://raw.github.com/dhbaird/easywsclient/master/easywsclient.hpp 11 | // wget https://raw.github.com/dhbaird/easywsclient/master/easywsclient.cpp 12 | 13 | #include 14 | #include 15 | 16 | namespace easywsclient { 17 | 18 | struct Callback_Imp { virtual void operator()(const std::string& message) = 0; }; 19 | struct BytesCallback_Imp { virtual void operator()(const std::vector& message) = 0; }; 20 | 21 | class WebSocket { 22 | public: 23 | typedef WebSocket* pointer; 24 | typedef enum readyStateValues { CLOSING, CLOSED, CONNECTING, OPEN } readyStateValues; 25 | 26 | // Factories: 27 | static pointer create_dummy(); 28 | static pointer from_url(const std::string& url, const std::string& origin = std::string(), const std::string& userAgent = std::string()); 29 | static pointer from_url_no_mask(const std::string& url, const std::string& origin = std::string(), const std::string& userAgent = std::string()); 30 | 31 | // Interfaces: 32 | virtual ~WebSocket() { } 33 | virtual void poll(int timeout = 0) = 0; // timeout in milliseconds 34 | virtual void send(const std::string& message) = 0; 35 | virtual void sendBinary(const std::string& message) = 0; 36 | virtual void sendBinary(const std::vector& message) = 0; 37 | virtual void sendPing() = 0; 38 | virtual void close() = 0; 39 | virtual readyStateValues getReadyState() const = 0; 40 | 41 | template 42 | void dispatch(Callable callable) 43 | // For callbacks that accept a string argument. 44 | { // N.B. this is compatible with both C++11 lambdas, functors and C function pointers 45 | struct _Callback : public Callback_Imp { 46 | Callable& callable; 47 | _Callback(Callable& callable) : callable(callable) { } 48 | void operator()(const std::string& message) { callable(message); } 49 | }; 50 | _Callback callback(callable); 51 | _dispatch(callback); 52 | } 53 | 54 | template 55 | void dispatchBinary(Callable callable) 56 | // For callbacks that accept a std::vector argument. 57 | { // N.B. this is compatible with both C++11 lambdas, functors and C function pointers 58 | struct _Callback : public BytesCallback_Imp { 59 | Callable& callable; 60 | _Callback(Callable& callable) : callable(callable) { } 61 | void operator()(const std::vector& message) { callable(message); } 62 | }; 63 | _Callback callback(callable); 64 | _dispatchBinary(callback); 65 | } 66 | 67 | protected: 68 | virtual void _dispatch(Callback_Imp& callable) = 0; 69 | virtual void _dispatchBinary(BytesCallback_Imp& callable) = 0; 70 | }; 71 | 72 | } // namespace easywsclient 73 | 74 | #endif /* EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD */ 75 | 76 | -------------------------------------------------------------------------------- /plugins/WinDbg/src/REToolSync/Extension.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include // ComPtr 15 | 16 | // 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | // 24 | 25 | #include "../../include/REToolSync/Extension.hpp" 26 | #include "../../include/REToolSync/cursor.hpp" 27 | #include "../../include/easywsclient.hpp" 28 | 29 | #pragma comment(lib, "dbgeng.lib") 30 | #pragma comment(lib, "wininet.lib") 31 | 32 | using Microsoft::WRL::ComPtr; 33 | 34 | std::unique_ptr ws; 35 | 36 | ComPtr g_DbgClient = nullptr; 37 | ComPtr g_DbgControl = nullptr; 38 | ComPtr g_DbgReg = nullptr; 39 | ComPtr g_DbgEventCallbacks = nullptr; 40 | ComPtr g_DbgSym = nullptr; 41 | Cursor g_CurrentStateCursor; 42 | Cursor g_PrevCursor; 43 | HANDLE g_Mutex; 44 | HANDLE g_ThreadHandle = INVALID_HANDLE_VALUE; 45 | BOOLEAN g_StopThread = false; 46 | 47 | /* 48 | // TODO: Fix this 49 | class EventCallbacks : public IDebugEventCallbacks { 50 | public: 51 | STDMETHOD_(ULONG, AddRef)() { return 1; } 52 | STDMETHOD_(ULONG, Release)() { return 0; } 53 | 54 | STDMETHOD(QueryInterface)(REFIID InterfaceId, PVOID *Interface) { 55 | if (IsEqualIID(InterfaceId, __uuidof(IDebugEventCallbacks))) { 56 | *Interface = (IDebugEventCallbacks *)this; 57 | return S_OK; 58 | } else { 59 | *Interface = nullptr; 60 | return E_NOINTERFACE; 61 | } 62 | } 63 | 64 | STDMETHOD(Breakpoint)(PDEBUG_BREAKPOINT Bp) { return DEBUG_STATUS_NO_CHANGE; } 65 | STDMETHOD(Exception)(PEXCEPTION_RECORD64 Exception, ULONG FirstChance) { 66 | return DEBUG_STATUS_NO_CHANGE; 67 | } 68 | STDMETHOD(CreateThread) 69 | (ULONG64 Handle, ULONG64 DataOffset, ULONG64 StartOffset) { 70 | return DEBUG_STATUS_NO_CHANGE; 71 | } 72 | STDMETHOD(ExitThread)(ULONG ExitCode) { return DEBUG_STATUS_NO_CHANGE; } 73 | STDMETHOD(CreateProcess) 74 | (ULONG64 ImageFileHandle, ULONG64 Handle, ULONG64 BaseOffset, 75 | ULONG ModuleSize, PCSTR ModuleName, PCSTR ImageName, ULONG CheckSum, 76 | ULONG TimeDateStamp, ULONG64 InitialThreadHandle, ULONG64 ThreadDataOffset, 77 | ULONG64 StartOffset) { 78 | return DEBUG_STATUS_NO_CHANGE; 79 | } 80 | STDMETHOD(ExitProcess)(ULONG ExitCode) { return DEBUG_STATUS_NO_CHANGE; } 81 | STDMETHOD(LoadModule) 82 | (ULONG64 ImageFileHandle, ULONG64 BaseOffset, ULONG ModuleSize, 83 | PCSTR ModuleName, PCSTR ImageName, ULONG CheckSum, ULONG TimeDateStamp) { 84 | return DEBUG_STATUS_NO_CHANGE; 85 | } 86 | STDMETHOD(UnloadModule)(PCSTR ImageBaseName, ULONG64 BaseOffset) { 87 | return DEBUG_STATUS_NO_CHANGE; 88 | } 89 | STDMETHOD(SystemError)(ULONG Error, ULONG Level) { 90 | return DEBUG_STATUS_NO_CHANGE; 91 | } 92 | STDMETHOD(SessionStatus)(ULONG Status) { return DEBUG_STATUS_NO_CHANGE; } 93 | STDMETHOD(ChangeDebuggeeState)(ULONG Flags, ULONG64 Argument) { 94 | return DEBUG_STATUS_NO_CHANGE; 95 | } 96 | STDMETHOD(ChangeEngineState)(ULONG Flags, ULONG64 Argument) { 97 | if (Flags & DEBUG_CES_EXECUTION_STATUS) { 98 | ULONG executionStatus; 99 | if (g_DbgControl->GetExecutionStatus(&executionStatus) == S_OK && 100 | (executionStatus == DEBUG_STATUS_STEP_OVER || 101 | executionStatus == DEBUG_STATUS_BREAK)) { 102 | // ULONG64 rip; 103 | 104 | if (GetCurrentInstructionCursor(g_CurrentStateCursor) == S_OK) { 105 | g_Mutex.lock(); 106 | Cursor TranslatedCursor = g_CurrentStateCursor; 107 | auto mod = std::make_pair(g_CurrentStateCursor.module, 108 | g_CurrentStateCursor.imagebase); 109 | Cursor::translate_address(TranslatedCursor, mod); 110 | nlohmann::json j; 111 | j["request"] = "goto"; 112 | j["address"] = TranslatedCursor.va; 113 | ws->send(j.dump()); 114 | g_Mutex.unlock(); 115 | } 116 | } 117 | } 118 | return DEBUG_STATUS_NO_CHANGE; 119 | } 120 | 121 | STDMETHOD(GetInterestMask)(PULONG Mask) { 122 | *Mask = DEBUG_EVENT_CHANGE_ENGINE_STATE; 123 | return S_OK; 124 | } 125 | 126 | STDMETHOD(ChangeSymbolState)(ULONG Flags, ULONG64 Argument) { 127 | return DEBUG_STATUS_NO_CHANGE; 128 | } 129 | }; 130 | 131 | EventCallbacks g_EventCallbacks; 132 | */ 133 | 134 | void ReconnectWebsocket(); // Forward declaration 135 | DWORD __stdcall WebSocketThreadProc(LPVOID Unused) { 136 | UNREFERENCED_PARAMETER(Unused); 137 | WaitForSingleObject(g_Mutex, INFINITE); 138 | ws.reset(easywsclient::WebSocket::from_url( 139 | "ws://localhost:6969/REToolSync", {}, 140 | "WinDbg " + std::to_string(GetCurrentProcessId()))); 141 | 142 | ReleaseMutex(g_Mutex); 143 | const DWORD pollTime = 200; // 200 MS ? 144 | DWORD sendTime = GetTickCount(); 145 | Cursor localCursor; 146 | 147 | if (ws != nullptr) { 148 | LOG(LOG_DEBUG, "Connected to server!"); 149 | } 150 | 151 | while (ws->getReadyState() != easywsclient::WebSocket::CLOSED) { 152 | WaitForSingleObject(g_Mutex, INFINITE); 153 | ws->poll(20); 154 | ws->dispatch([](const std::string &message) { 155 | Log(LOG_DEBUG, "Received message: %s", message.c_str()); 156 | }); 157 | ReleaseMutex(g_Mutex); 158 | } 159 | 160 | if (ws->getReadyState() == easywsclient::WebSocket::CLOSED) { 161 | LOG(LOG_DEBUG, "Disconnected from server!"); 162 | } 163 | ReconnectWebsocket(); 164 | return 0; 165 | } 166 | 167 | void ReconnectWebsocket() { 168 | CloseHandle(g_Mutex); 169 | LOG(LOG_DEBUG, "Reconnecting to server!"); 170 | std::this_thread::sleep_for(std::chrono::seconds(3)); 171 | g_ThreadHandle = 172 | CreateThread(nullptr, 0, WebSocketThreadProc, nullptr, 0, nullptr); 173 | } 174 | 175 | HRESULT IsIgnoreableEvent(BOOL *bIgnore) { 176 | HRESULT hr; 177 | ULONG Type, ProcessId, ThreadId, BreakpointId, ExtraInformationUsed, 178 | CommandSize; 179 | PDEBUG_BREAKPOINT Breakpoint; 180 | 181 | hr = g_DbgControl->GetLastEventInformation( 182 | &Type, &ProcessId, &ThreadId, &BreakpointId, sizeof(ULONG), 183 | &ExtraInformationUsed, NULL, NULL, NULL); 184 | 185 | if (FAILED(hr)) 186 | goto Done; 187 | 188 | switch (Type) { 189 | case DEBUG_EVENT_CHANGE_SYMBOL_STATE: 190 | case DEBUG_EVENT_UNLOAD_MODULE: 191 | case DEBUG_EVENT_LOAD_MODULE: 192 | case DEBUG_EVENT_CREATE_PROCESS: 193 | case DEBUG_EVENT_EXIT_PROCESS: 194 | case DEBUG_EVENT_CREATE_THREAD: 195 | case DEBUG_EVENT_EXIT_THREAD: 196 | case DEBUG_EVENT_SYSTEM_ERROR: 197 | *bIgnore = TRUE; 198 | break; 199 | case DEBUG_EVENT_BREAKPOINT: 200 | *bIgnore = FALSE; 201 | hr = g_DbgControl->GetBreakpointById(BreakpointId, &Breakpoint); 202 | if (FAILED(hr)) 203 | goto Done; 204 | 205 | /* 206 | hr = Breakpoint->GetCommand(, ULONG BufferSize, PULONG CommandSize); 207 | if (FAILED(hr)) 208 | goto Done; 209 | *bIgnore = CommandSize == 0; 210 | */ 211 | break; 212 | } 213 | Done: 214 | 215 | return hr; 216 | } 217 | 218 | bool RequestGoto(std::string address) { 219 | bool ret = false; 220 | HINTERNET hInternet = 221 | InternetOpenA("REToolSync", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); 222 | 223 | std::string postData = "address=" + address; 224 | 225 | if (hInternet == NULL) { 226 | return ret; 227 | } 228 | 229 | HINTERNET hConnect = InternetConnectA(hInternet, "localhost", 6969, nullptr, 230 | nullptr, INTERNET_SERVICE_HTTP, 0, 0); 231 | 232 | PCTSTR rgpszAcceptTypes[] = {"application/x-www-form-urlencoded", nullptr}; 233 | HINTERNET hRequest = HttpOpenRequestA( 234 | hConnect, "POST", std::string{"/api/goto?" + postData}.c_str(), nullptr, 235 | nullptr, rgpszAcceptTypes, 236 | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE, 0); 237 | 238 | if (hRequest == NULL) { 239 | return ret; 240 | } 241 | ret = HttpSendRequestA(hRequest, nullptr, 0, (LPVOID)postData.c_str(), 242 | postData.size()); 243 | Done: 244 | InternetCloseHandle(hRequest); 245 | InternetCloseHandle(hConnect); 246 | InternetCloseHandle(hInternet); 247 | return ret; 248 | } 249 | 250 | HRESULT InitGlobals() { 251 | HRESULT hr = S_OK; 252 | 253 | hr = DebugCreate(__uuidof(IDebugClient5), (void **)&g_DbgClient); 254 | if (FAILED(hr)) { 255 | return hr; 256 | } 257 | 258 | hr = DebugCreate(__uuidof(IDebugControl5), (void **)&g_DbgControl); 259 | if (FAILED(hr)) { 260 | return hr; 261 | } 262 | 263 | hr = DebugCreate(__uuidof(IDebugRegisters), (void **)&g_DbgReg); 264 | 265 | if (FAILED(hr)) { 266 | return hr; 267 | } 268 | 269 | hr = DebugCreate(__uuidof(IDebugSymbols3), (void **)&g_DbgSym); 270 | if (FAILED(hr)) { 271 | return hr; 272 | } 273 | 274 | /* 275 | hr = g_DbgClient->SetEventCallbacks(&g_EventCallbacks); 276 | if (FAILED(hr)) { 277 | return hr; 278 | }*/ 279 | 280 | return hr; 281 | } 282 | 283 | extern "C" __declspec(dllexport) HRESULT CALLBACK 284 | DebugExtensionInitialize(PULONG Version, PULONG Flags) { 285 | *Version = DEBUG_EXTENSION_VERSION(1, 0); 286 | *Flags = 0; 287 | PDEBUG_EVENT_CALLBACKS callbacks = nullptr; 288 | 289 | HRESULT hr = InitGlobals(); 290 | if (FAILED(hr)) { 291 | return hr; 292 | } 293 | 294 | g_Mutex = CreateMutex(nullptr, FALSE, nullptr); 295 | 296 | g_ThreadHandle = 297 | CreateThread(nullptr, 0, WebSocketThreadProc, nullptr, 0, nullptr); 298 | 299 | LOG(LOG_DEBUG, "Extension Loaded!"); 300 | 301 | if (FAILED(hr)) { 302 | return hr; 303 | } 304 | 305 | // hr = g_DbgClient->SetEventCallbacks(&g_EventCallbacks); 306 | 307 | hr = g_DbgClient->GetEventCallbacks(&callbacks); 308 | 309 | if (FAILED(hr)) { 310 | return hr; 311 | } 312 | 313 | auto ret = get_cursors(); 314 | 315 | if (ret == false) { 316 | return E_FAIL; 317 | } 318 | 319 | /* 320 | if (callbacks->QueryInterface(__uuidof(IDebugEventCallbacks), 321 | (void **)&g_EventCallbacks) != S_OK) { 322 | return E_NOINTERFACE; 323 | } 324 | */ 325 | 326 | return S_OK; 327 | } 328 | 329 | extern "C" __declspec(dllexport) HRESULT CALLBACK 330 | DebugExtensionNotify(ULONG Notify, ULONG64 Argument) { 331 | 332 | switch (Notify) { 333 | case DEBUG_NOTIFY_SESSION_ACTIVE: 334 | break; 335 | case DEBUG_NOTIFY_SESSION_INACTIVE: 336 | break; 337 | case DEBUG_NOTIFY_SESSION_ACCESSIBLE: { 338 | BOOL bIgnore = FALSE; 339 | if (IsIgnoreableEvent(&bIgnore)) { 340 | break; 341 | } 342 | if (SUCCEEDED(GetCurrentInstructionCursor(g_CurrentStateCursor))) { 343 | WaitForSingleObject(g_Mutex, INFINITE); 344 | Cursor TranslatedCursor = g_CurrentStateCursor; 345 | auto mod = std::make_pair(g_CurrentStateCursor.module, 346 | g_CurrentStateCursor.imagebase); 347 | Cursor::translate_address(TranslatedCursor, mod); 348 | nlohmann::json j; 349 | j["request"] = "goto"; 350 | j["address"] = Cursor::toHex(TranslatedCursor.va); 351 | ws->send(j.dump()); 352 | RequestGoto(j["address"].get()); 353 | ReleaseMutex(g_Mutex); 354 | } 355 | } break; 356 | default: 357 | break; 358 | } 359 | return S_OK; 360 | } 361 | 362 | extern "C" __declspec(dllexport) HRESULT CALLBACK DebugExtensionUninitialize() { 363 | LOG(LOG_DEBUG, "Extension Unloaded!"); 364 | 365 | g_DbgControl->Release(); 366 | g_DbgClient->Release(); 367 | // g_EventCallbacks.Release(); 368 | g_DbgReg->Release(); 369 | g_StopThread = true; 370 | 371 | ws->close(); 372 | 373 | return S_OK; 374 | } 375 | 376 | extern "C" __declspec(dllexport) HRESULT CALLBACK 377 | retoolsync(PDEBUG_CLIENT4 Client, PCSTR args) { 378 | UNREFERENCED_PARAMETER(Client); 379 | UNREFERENCED_PARAMETER(args); 380 | 381 | HRESULT hr; 382 | auto b = get_cursors(); 383 | if (FAILED(GetCurrentInstructionCursor(g_CurrentStateCursor))) { 384 | return E_FAIL; 385 | } 386 | 387 | if (!b) { 388 | LOG(LOG_ERROR, "Error fetching cursor"); 389 | } 390 | 391 | return S_OK; 392 | } -------------------------------------------------------------------------------- /plugins/WinDbg/src/REToolSync/cursor.cpp: -------------------------------------------------------------------------------- 1 | #include "../../include/REToolSync/cursor.hpp" 2 | #include 3 | #include 4 | 5 | #include "../../include/REToolSync/Extension.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | mod_set g_ModVec; 13 | 14 | std::string Cursor::toHex(uint64_t value) { 15 | std::stringstream ss; 16 | ss << "0x" << std::hex << value; 17 | return ss.str(); 18 | } 19 | 20 | uint64_t Cursor::fromHex(const std::string &value) { 21 | uint64_t result; 22 | std::stringstream ss; 23 | ss << std::hex << value; 24 | ss >> result; 25 | return result; 26 | } 27 | 28 | uint64_t Cursor::fromDec(const std::string &value) { 29 | uint64_t result; 30 | std::stringstream ss; 31 | ss << std::dec << value; 32 | ss >> result; 33 | return result; 34 | } 35 | 36 | std::string Cursor::serialize(int indent) const { 37 | nlohmann::json j; 38 | j["toolid"] = tool_id; 39 | j["architecture"] = architecture; 40 | j["va"] = toHex(va); 41 | j["rva"] = toHex(rva); 42 | j["fileoffset"] = toHex(fileoffset); 43 | j["filepath"] = filepath; 44 | j["module"] = module; 45 | j["sha1"] = sha1; 46 | j["md5"] = md5; 47 | j["TimeDateStamp"] = toHex(TimeDateStamp); 48 | j["loadedbase"] = toHex(loadedbase); 49 | j["imagebase"] = toHex(imagebase); 50 | j["imagesize"] = toHex(imagesize); 51 | return j.dump(indent); 52 | } 53 | 54 | bool Cursor::deserialize(const char *json, Cursor &c) { 55 | auto j = nlohmann::json::parse(json); 56 | if (!j.is_object()) { 57 | return false; 58 | } 59 | return deserialize(j, c); 60 | } 61 | 62 | bool Cursor::deserialize(const nlohmann::json::value_type &j, Cursor &c) { 63 | try { 64 | c = Cursor(); 65 | c.tool_id = j["toolid"]; 66 | c.architecture = j["architecture"]; 67 | // c.cursorid = j["cursorid"]; 68 | c.va = Cursor::fromHex(j["va"]); 69 | c.rva = (uint32_t)Cursor::fromHex(j["rva"]); 70 | c.fileoffset = Cursor::fromHex(j["fileoffset"]); 71 | c.filepath = j["filepath"]; 72 | c.sha1 = j["sha1"]; 73 | c.md5 = j["md5"]; 74 | c.module = j["module"]; 75 | c.TimeDateStamp = (uint32_t)Cursor::fromHex(j["TimeDateStamp"]); 76 | c.loadedbase = Cursor::fromHex(j["loadedbase"]); 77 | c.imagebase = Cursor::fromHex(j["imagebase"]); 78 | c.imagesize = (uint32_t)Cursor::fromHex(j["imagesize"]); 79 | } catch (const nlohmann::json::exception &) { 80 | return false; 81 | } catch (const std::invalid_argument &) { 82 | return false; 83 | } 84 | return true; 85 | } 86 | 87 | bool Cursor::deserialize(const char *json, std::vector &cs) { 88 | auto j = nlohmann::json::parse(json); 89 | if (!j.is_array()) { 90 | return false; 91 | } 92 | cs.reserve(j.size()); 93 | for (const auto &item : j) { 94 | Cursor c; 95 | if (!deserialize(item, c)) { 96 | return false; 97 | } 98 | cs.push_back(c); 99 | } 100 | return true; 101 | } 102 | 103 | std::string get_arch() { 104 | std::string arch = "x64"; 105 | ULONG proc_type = 0; 106 | HRESULT hr; 107 | 108 | hr = g_DbgControl->GetActualProcessorType(&proc_type); 109 | 110 | if (FAILED(hr)) { 111 | return arch; 112 | } 113 | 114 | switch (proc_type) { 115 | case IMAGE_FILE_MACHINE_AMD64: 116 | arch = "x64"; 117 | break; 118 | 119 | case IMAGE_FILE_MACHINE_ARM: 120 | arch = "arm"; 121 | break; 122 | case IMAGE_FILE_MACHINE_ARM64: 123 | arch = "arm64"; 124 | break; 125 | 126 | case IMAGE_FILE_MACHINE_I386: 127 | arch = "x86"; 128 | break; 129 | 130 | case IMAGE_FILE_MACHINE_IA64: 131 | arch = "x64"; 132 | break; 133 | 134 | default: 135 | break; 136 | } 137 | 138 | return arch; 139 | } 140 | 141 | HRESULT GetCurrentInstructionCursor(_Out_ Cursor &c) { 142 | HRESULT hr = E_FAIL; 143 | 144 | ULONG modIdx = 0; 145 | char modName[MAX_PATH] = {0}; 146 | hr = g_DbgReg->GetInstructionOffset(&c.va); 147 | if (FAILED(hr)) 148 | goto Done; 149 | 150 | hr = g_DbgSym->GetModuleByOffset(c.va, 0, &modIdx, &c.imagebase); 151 | if (FAILED(hr)) 152 | goto Done; 153 | hr = g_DbgSym->GetModuleNameString(DEBUG_MODNAME_MODULE, modIdx, c.imagebase, 154 | modName, MAX_PATH, nullptr); 155 | if (FAILED(hr)) 156 | goto Done; 157 | 158 | c.filepath = modName; 159 | 160 | if (c.filepath.find("\\") != std::string::npos) { 161 | 162 | c.module = c.filepath.substr(c.filepath.find_last_of("\\") + 1); 163 | } else { 164 | c.module = c.filepath; 165 | } 166 | 167 | c.rva = static_cast(c.va - c.imagebase); 168 | 169 | Done: 170 | return hr; 171 | } 172 | 173 | bool get_cursors() { 174 | // TODO: do this only once during initialization 175 | HINTERNET hSession = InternetOpenA("REToolSync", INTERNET_OPEN_TYPE_DIRECT, 176 | nullptr, nullptr, 0); 177 | 178 | if (!hSession) 179 | Log(LOG_ERROR, "InternetOpenA"); 180 | // InternetCloseHandle 181 | 182 | // TODO: error handling 183 | HINTERNET hConnection = InternetConnectA(hSession, 184 | "127.0.0.1", // Server 185 | 6969, 186 | nullptr, // Username 187 | nullptr, // Password 188 | INTERNET_SERVICE_HTTP, 189 | 0, // Synchronous 190 | 0); // No Context 191 | // InternetCloseHandle 192 | 193 | if (!hConnection) 194 | Log(LOG_ERROR, "InternetConnectA"); 195 | 196 | // TODO: error handling 197 | PCTSTR rgpszAcceptTypes[] = {"application/json", nullptr}; 198 | HINTERNET hRequest = HttpOpenRequestA( 199 | hConnection, "GET", "/api/clients", 200 | nullptr, // Default HTTP Version 201 | nullptr, // No Referer 202 | rgpszAcceptTypes, // Accept 203 | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE, // Flags 204 | NULL); // No Context 205 | // InternetCloseHandle 206 | 207 | if (!hRequest) 208 | Log(LOG_ERROR, "HttpOpenRequestA"); 209 | 210 | // TODO: error handling 211 | auto bSent = HttpSendRequestA(hRequest, 212 | nullptr, // No extra headers 213 | 0, // Header length 214 | nullptr, 0); 215 | 216 | if (!bSent) { 217 | Log(LOG_ERROR, "HttpSendRequestA: %x", GetLastError()); 218 | } 219 | 220 | std::string pData; 221 | 222 | DWORD dwContentLen; 223 | DWORD dwBufLen = sizeof(dwContentLen); 224 | if (HttpQueryInfoA(hRequest, 225 | HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, 226 | (LPVOID)&dwContentLen, &dwBufLen, 0)) { 227 | // You have a content length so you can calculate percent complete 228 | pData.resize(dwContentLen); 229 | DWORD dwReadSize = dwContentLen; 230 | DWORD dwBytesRead; 231 | 232 | InternetReadFile(hRequest, (char *)pData.data(), dwReadSize, 233 | &dwBytesRead); // TODO: error handling 234 | } else 235 | Log(LOG_ERROR, "no Content-Length header!"); 236 | 237 | if (pData.empty()) 238 | return false; 239 | 240 | Log(LOG_INFO, pData.c_str()); 241 | return deserialize_modvec(pData.c_str(), g_ModVec); 242 | } 243 | 244 | bool deserialize_modvec(const char *json, mod_set &mods) { 245 | auto j = nlohmann::json::parse(json); 246 | 247 | if (!j.is_array()) { 248 | return false; 249 | } 250 | 251 | for (auto &[k, v] : j.items()) { 252 | if (!v.is_object()) { 253 | continue; 254 | } 255 | 256 | if (!v.contains(std::string{"module"}) || 257 | !v.contains(std::string{"base"})) { 258 | continue; 259 | } 260 | 261 | auto mod_name = v["module"].get(); 262 | auto mod_addr = v["base"].get(); 263 | auto m = mod(mod_name, Cursor::fromHex(mod_addr)); 264 | 265 | mods.insert(m); 266 | } 267 | 268 | return true; 269 | } 270 | 271 | bool Cursor::translate_address(Cursor &c, mod &m) { 272 | bool ret = false; 273 | Cursor c2; 274 | 275 | if (m.first.empty() || m.second == 0) { 276 | return ret; 277 | } 278 | auto old_va = c.va; 279 | auto old_base = c.imagebase; 280 | 281 | auto modl = 282 | std::find_if(g_ModVec.begin(), g_ModVec.end(), [&](const mod &mod) { 283 | return mod.first.starts_with(m.first); 284 | }); 285 | 286 | if (modl != g_ModVec.end()) { 287 | c2.module = m.first; 288 | c2.imagebase = modl->second; 289 | c2.rva = c.va - c.imagebase; 290 | c2.va = c2.imagebase + c2.rva; 291 | c = c2; 292 | ret = true; 293 | } else { 294 | return false; 295 | } 296 | 297 | return ret; 298 | } -------------------------------------------------------------------------------- /plugins/x64dbg/.gitignore: -------------------------------------------------------------------------------- 1 | .vs/ 2 | bin/ 3 | Debug/ 4 | Release/ 5 | *.vcxproj.user 6 | *.VC.db 7 | .vs/ 8 | Release/ 9 | Debug/ 10 | x64/ 11 | *.vcxproj.user 12 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.572 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "REToolSync", "REToolSync\REToolSync.vcxproj", "{176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Debug|x64.ActiveCfg = Debug|x64 17 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Debug|x64.Build.0 = Debug|x64 18 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Debug|x86.ActiveCfg = Debug|Win32 19 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Debug|x86.Build.0 = Debug|Win32 20 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Release|x64.ActiveCfg = Release|x64 21 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Release|x64.Build.0 = Release|x64 22 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Release|x86.ActiveCfg = Release|Win32 23 | {176822C9-3CF8-41A9-81AB-8BBD3E3E2A32}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {89BFFDB5-E9F3-4DD3-B5DF-834D2F318437} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/REToolSync.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {e26abb2c-05ce-4474-aa6b-0d6f0bc27926} 14 | 15 | 16 | {836b0bc9-fdfe-4f45-945f-fd3e597aad9d} 17 | 18 | 19 | {c87c3d42-364d-4fe6-9ab3-8f7e8352af43} 20 | 21 | 22 | {17a1513c-2d16-432c-a7ec-8e31e09ebfbf} 23 | 24 | 25 | {b1cd7fb9-d2e4-448a-bf04-4f11115651f2} 26 | 27 | 28 | {c50e39c1-5972-409e-a5f3-904860f1a661} 29 | 30 | 31 | {831de1fc-1ccd-427d-a848-f62169b3743e} 32 | 33 | 34 | {ffcdd30c-5e60-4075-95bf-ea1ca7aad310} 35 | 36 | 37 | {83b94fba-0963-43a4-b8bd-12730a208fad} 38 | 39 | 40 | 41 | 42 | Header Files\pluginsdk\capstone 43 | 44 | 45 | Header Files\pluginsdk\capstone 46 | 47 | 48 | Header Files\pluginsdk\capstone 49 | 50 | 51 | Header Files\pluginsdk\capstone 52 | 53 | 54 | Header Files\pluginsdk\capstone 55 | 56 | 57 | Header Files\pluginsdk\capstone 58 | 59 | 60 | Header Files\pluginsdk\capstone 61 | 62 | 63 | Header Files\pluginsdk\capstone 64 | 65 | 66 | Header Files\pluginsdk\capstone 67 | 68 | 69 | Header Files\pluginsdk\capstone 70 | 71 | 72 | Header Files\pluginsdk\capstone 73 | 74 | 75 | Header Files\pluginsdk\dbghelp 76 | 77 | 78 | Header Files\pluginsdk\DeviceNameResolver 79 | 80 | 81 | Header Files\pluginsdk\jansson 82 | 83 | 84 | Header Files\pluginsdk\jansson 85 | 86 | 87 | Header Files\pluginsdk\jansson 88 | 89 | 90 | Header Files\pluginsdk\lz4 91 | 92 | 93 | Header Files\pluginsdk\lz4 94 | 95 | 96 | Header Files\pluginsdk\lz4 97 | 98 | 99 | Header Files\pluginsdk\XEDParse 100 | 101 | 102 | Header Files\pluginsdk\TitanEngine 103 | 104 | 105 | Header Files\pluginsdk 106 | 107 | 108 | Header Files\pluginsdk 109 | 110 | 111 | Header Files\pluginsdk 112 | 113 | 114 | Header Files\pluginsdk 115 | 116 | 117 | Header Files\pluginsdk 118 | 119 | 120 | Header Files\pluginsdk 121 | 122 | 123 | Header Files\pluginsdk 124 | 125 | 126 | Header Files\pluginsdk 127 | 128 | 129 | Header Files\pluginsdk 130 | 131 | 132 | Header Files\pluginsdk 133 | 134 | 135 | Header Files\pluginsdk 136 | 137 | 138 | Header Files\pluginsdk 139 | 140 | 141 | Header Files\pluginsdk 142 | 143 | 144 | Header Files\pluginsdk 145 | 146 | 147 | Header Files\pluginsdk 148 | 149 | 150 | Header Files\pluginsdk 151 | 152 | 153 | Header Files\pluginsdk 154 | 155 | 156 | Header Files\pluginsdk 157 | 158 | 159 | Header Files\pluginsdk 160 | 161 | 162 | Header Files\pluginsdk 163 | 164 | 165 | Header Files\pluginsdk 166 | 167 | 168 | Header Files\pluginsdk 169 | 170 | 171 | Header Files\pluginsdk 172 | 173 | 174 | Header Files 175 | 176 | 177 | Header Files 178 | 179 | 180 | Header Files 181 | 182 | 183 | Header Files 184 | 185 | 186 | Header Files 187 | 188 | 189 | Header Files 190 | 191 | 192 | 193 | 194 | Library Files 195 | 196 | 197 | Library Files 198 | 199 | 200 | Library Files 201 | 202 | 203 | Library Files 204 | 205 | 206 | Library Files 207 | 208 | 209 | Library Files 210 | 211 | 212 | Library Files 213 | 214 | 215 | Library Files 216 | 217 | 218 | Library Files 219 | 220 | 221 | Library Files 222 | 223 | 224 | Library Files 225 | 226 | 227 | Library Files 228 | 229 | 230 | Library Files 231 | 232 | 233 | Library Files 234 | 235 | 236 | Library Files 237 | 238 | 239 | Library Files 240 | 241 | 242 | 243 | 244 | Source Files 245 | 246 | 247 | Source Files 248 | 249 | 250 | Source Files 251 | 252 | 253 | Source Files 254 | 255 | 256 | Source Files 257 | 258 | 259 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/easywsclient.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD 2 | #define EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD 3 | 4 | // This code comes from: 5 | // https://github.com/dhbaird/easywsclient 6 | // 7 | // It has been modified to support adding a User-Agent header on connection 8 | // 9 | // To get the latest version: 10 | // wget https://raw.github.com/dhbaird/easywsclient/master/easywsclient.hpp 11 | // wget https://raw.github.com/dhbaird/easywsclient/master/easywsclient.cpp 12 | 13 | #include 14 | #include 15 | 16 | namespace easywsclient { 17 | 18 | struct Callback_Imp { virtual void operator()(const std::string& message) = 0; }; 19 | struct BytesCallback_Imp { virtual void operator()(const std::vector& message) = 0; }; 20 | 21 | class WebSocket { 22 | public: 23 | typedef WebSocket * pointer; 24 | typedef enum readyStateValues { CLOSING, CLOSED, CONNECTING, OPEN } readyStateValues; 25 | 26 | // Factories: 27 | static pointer create_dummy(); 28 | static pointer from_url(const std::string& url, const std::string& origin = std::string(), const std::string& userAgent = std::string()); 29 | static pointer from_url_no_mask(const std::string& url, const std::string& origin = std::string(), const std::string& userAgent = std::string()); 30 | 31 | // Interfaces: 32 | virtual ~WebSocket() { } 33 | virtual void poll(int timeout = 0) = 0; // timeout in milliseconds 34 | virtual void send(const std::string& message) = 0; 35 | virtual void sendBinary(const std::string& message) = 0; 36 | virtual void sendBinary(const std::vector& message) = 0; 37 | virtual void sendPing() = 0; 38 | virtual void close() = 0; 39 | virtual readyStateValues getReadyState() const = 0; 40 | 41 | template 42 | void dispatch(Callable callable) 43 | // For callbacks that accept a string argument. 44 | { // N.B. this is compatible with both C++11 lambdas, functors and C function pointers 45 | struct _Callback : public Callback_Imp { 46 | Callable& callable; 47 | _Callback(Callable& callable) : callable(callable) { } 48 | void operator()(const std::string& message) { callable(message); } 49 | }; 50 | _Callback callback(callable); 51 | _dispatch(callback); 52 | } 53 | 54 | template 55 | void dispatchBinary(Callable callable) 56 | // For callbacks that accept a std::vector argument. 57 | { // N.B. this is compatible with both C++11 lambdas, functors and C function pointers 58 | struct _Callback : public BytesCallback_Imp { 59 | Callable& callable; 60 | _Callback(Callable& callable) : callable(callable) { } 61 | void operator()(const std::vector& message) { callable(message); } 62 | }; 63 | _Callback callback(callable); 64 | _dispatchBinary(callback); 65 | } 66 | 67 | protected: 68 | virtual void _dispatch(Callback_Imp& callable) = 0; 69 | virtual void _dispatchBinary(BytesCallback_Imp& callable) = 0; 70 | }; 71 | 72 | } // namespace easywsclient 73 | 74 | #endif /* EASYWSCLIENT_HPP_20120819_MIOFVASDTNUASZDQPLFD */ 75 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/plugin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pluginmain.h" 4 | 5 | //plugin data 6 | #define PLUGIN_NAME "REToolSync" 7 | #define PLUGIN_VERSION 1 8 | 9 | //functions 10 | bool pluginInit(PLUG_INITSTRUCT* initStruct); 11 | void pluginStop(); 12 | void pluginSetup(); 13 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginmain.cpp: -------------------------------------------------------------------------------- 1 | #include "pluginmain.h" 2 | #include "plugin.h" 3 | 4 | int pluginHandle; 5 | HWND hwndDlg; 6 | int hMenu; 7 | int hMenuDisasm; 8 | int hMenuDump; 9 | int hMenuStack; 10 | 11 | PLUG_EXPORT bool pluginit(PLUG_INITSTRUCT* initStruct) 12 | { 13 | initStruct->pluginVersion = PLUGIN_VERSION; 14 | initStruct->sdkVersion = PLUG_SDKVERSION; 15 | strncpy_s(initStruct->pluginName, PLUGIN_NAME, _TRUNCATE); 16 | pluginHandle = initStruct->pluginHandle; 17 | return pluginInit(initStruct); 18 | } 19 | 20 | PLUG_EXPORT bool plugstop() 21 | { 22 | pluginStop(); 23 | return true; 24 | } 25 | 26 | PLUG_EXPORT void plugsetup(PLUG_SETUPSTRUCT* setupStruct) 27 | { 28 | hwndDlg = setupStruct->hwndDlg; 29 | hMenu = setupStruct->hMenu; 30 | hMenuDisasm = setupStruct->hMenuDisasm; 31 | hMenuDump = setupStruct->hMenuDump; 32 | hMenuStack = setupStruct->hMenuStack; 33 | pluginSetup(); 34 | } -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginmain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pluginsdk/bridgemain.h" 4 | #include "pluginsdk/_plugins.h" 5 | 6 | #include "pluginsdk/_scriptapi_argument.h" 7 | #include "pluginsdk/_scriptapi_assembler.h" 8 | #include "pluginsdk/_scriptapi_bookmark.h" 9 | #include "pluginsdk/_scriptapi_comment.h" 10 | #include "pluginsdk/_scriptapi_debug.h" 11 | #include "pluginsdk/_scriptapi_flag.h" 12 | #include "pluginsdk/_scriptapi_function.h" 13 | #include "pluginsdk/_scriptapi_gui.h" 14 | #include "pluginsdk/_scriptapi_label.h" 15 | #include "pluginsdk/_scriptapi_memory.h" 16 | #include "pluginsdk/_scriptapi_misc.h" 17 | #include "pluginsdk/_scriptapi_module.h" 18 | #include "pluginsdk/_scriptapi_pattern.h" 19 | #include "pluginsdk/_scriptapi_register.h" 20 | #include "pluginsdk/_scriptapi_stack.h" 21 | #include "pluginsdk/_scriptapi_symbol.h" 22 | 23 | #include "pluginsdk/capstone/capstone.h" 24 | #include "pluginsdk/DeviceNameResolver/DeviceNameResolver.h" 25 | #include "pluginsdk/jansson/jansson.h" 26 | #include "pluginsdk/lz4/lz4file.h" 27 | #include "pluginsdk/TitanEngine/TitanEngine.h" 28 | #include "pluginsdk/XEDParse/XEDParse.h" 29 | 30 | #ifdef _WIN64 31 | #pragma comment(lib, "pluginsdk/x64dbg.lib") 32 | #pragma comment(lib, "pluginsdk/x64bridge.lib") 33 | #pragma comment(lib, "pluginsdk/capstone/capstone_x64.lib") 34 | #pragma comment(lib, "pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.lib") 35 | #pragma comment(lib, "pluginsdk/jansson/jansson_x64.lib") 36 | #pragma comment(lib, "pluginsdk/lz4/lz4_x64.lib") 37 | #pragma comment(lib, "pluginsdk/TitanEngine/TitanEngine_x64.lib") 38 | #pragma comment(lib, "pluginsdk/XEDParse/XEDParse_x64.lib") 39 | #else 40 | #pragma comment(lib, "pluginsdk/x32dbg.lib") 41 | #pragma comment(lib, "pluginsdk/x32bridge.lib") 42 | #pragma comment(lib, "pluginsdk/capstone/capstone_x86.lib") 43 | #pragma comment(lib, "pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.lib") 44 | #pragma comment(lib, "pluginsdk/jansson/jansson_x86.lib") 45 | #pragma comment(lib, "pluginsdk/lz4/lz4_x86.lib") 46 | #pragma comment(lib, "pluginsdk/TitanEngine/TitanEngine_x86.lib") 47 | #pragma comment(lib, "pluginsdk/XEDParse/XEDParse_x86.lib") 48 | #endif //_WIN64 49 | 50 | #define Cmd(x) DbgCmdExecDirect(x) 51 | #define Eval(x) DbgValFromString(x) 52 | #define dprintf(x, ...) _plugin_logprintf("[" PLUGIN_NAME "] " x, __VA_ARGS__) 53 | #define dputs(x) _plugin_logprintf("[" PLUGIN_NAME "] %s\n", x) 54 | #define PLUG_EXPORT extern "C" __declspec(dllexport) 55 | 56 | //superglobal variables 57 | extern int pluginHandle; 58 | extern HWND hwndDlg; 59 | extern int hMenu; 60 | extern int hMenuDisasm; 61 | extern int hMenuDump; 62 | extern int hMenuStack; -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x64.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/DeviceNameResolver/DeviceNameResolver_x86.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x64.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x64.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x86.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/TitanEngine/TitanEngine_x86.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x64.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x64.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x86.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/XEDParse/XEDParse_x86.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | char szExeMainWindowTitle[MAX_PATH]; 47 | char szExeArgs[MAX_COMMAND_LINE_SIZE]; 48 | } DBGPROCESSINFO; 49 | 50 | typedef struct 51 | { 52 | DWORD rva; 53 | BYTE type; 54 | WORD size; 55 | } DBGRELOCATIONINFO; 56 | 57 | typedef enum 58 | { 59 | InstructionBody = 0, 60 | InstructionHeading = 1, 61 | InstructionTailing = 2, 62 | InstructionOverlapped = 3, // The byte was executed with differing instruction base addresses 63 | DataByte, // This and the following is not implemented yet. 64 | DataWord, 65 | DataDWord, 66 | DataQWord, 67 | DataFloat, 68 | DataDouble, 69 | DataLongDouble, 70 | DataXMM, 71 | DataYMM, 72 | DataMMX, 73 | DataMixed, //the byte is accessed in multiple ways 74 | InstructionDataMixed //the byte is both executed and written 75 | } TRACERECORDBYTETYPE; 76 | 77 | typedef enum 78 | { 79 | TraceRecordNone, 80 | TraceRecordBitExec, 81 | TraceRecordByteWithExecTypeAndCounter, 82 | TraceRecordWordWithExecTypeAndCounter 83 | } TRACERECORDTYPE; 84 | 85 | typedef struct 86 | { 87 | duint Handle; 88 | unsigned char TypeNumber; 89 | unsigned int GrantedAccess; 90 | } HANDLEINFO; 91 | 92 | // The longest ip address is 1234:6789:1234:6789:1234:6789:123.567.901.345 (46 bytes) 93 | #define TCP_ADDR_SIZE 50 94 | 95 | typedef struct 96 | { 97 | char RemoteAddress[TCP_ADDR_SIZE]; 98 | unsigned short RemotePort; 99 | char LocalAddress[TCP_ADDR_SIZE]; 100 | unsigned short LocalPort; 101 | char StateText[TCP_ADDR_SIZE]; 102 | unsigned int State; 103 | } TCPCONNECTIONINFO; 104 | 105 | typedef struct 106 | { 107 | duint handle; 108 | duint parent; 109 | DWORD threadId; 110 | DWORD style; 111 | DWORD styleEx; 112 | duint wndProc; 113 | bool enabled; 114 | RECT position; 115 | char windowTitle[MAX_COMMENT_SIZE]; 116 | char windowClass[MAX_COMMENT_SIZE]; 117 | } WINDOW_INFO; 118 | 119 | typedef struct 120 | { 121 | duint addr; 122 | duint size; 123 | duint flags; 124 | } HEAPINFO; 125 | 126 | typedef struct 127 | { 128 | const char* name; 129 | duint value; 130 | } CONSTANTINFO; 131 | 132 | typedef enum 133 | { 134 | MODSYMUNLOADED = 0, 135 | MODSYMLOADING, 136 | MODSYMLOADED 137 | } MODULESYMBOLSTATUS; 138 | 139 | typedef bool (*ASSEMBLEATEX)(duint addr, const char* instruction, char* error, bool fillnop); 140 | typedef bool (*SECTIONFROMADDR)(duint addr, char* section); 141 | typedef bool (*MODNAMEFROMADDR)(duint addr, char* modname, bool extension); 142 | typedef duint(*MODBASEFROMADDR)(duint addr); 143 | typedef duint(*MODBASEFROMNAME)(const char* modname); 144 | typedef duint(*MODSIZEFROMADDR)(duint addr); 145 | typedef bool (*ASSEMBLE)(duint addr, unsigned char* dest, int* size, const char* instruction, char* error); 146 | typedef bool (*PATCHGET)(duint addr); 147 | typedef bool (*PATCHINRANGE)(duint start, duint end); 148 | typedef bool (*MEMPATCH)(duint va, const unsigned char* src, duint size); 149 | typedef void (*PATCHRESTORERANGE)(duint start, duint end); 150 | typedef bool (*PATCHENUM)(DBGPATCHINFO* patchlist, size_t* cbsize); 151 | typedef bool (*PATCHRESTORE)(duint addr); 152 | typedef int (*PATCHFILE)(DBGPATCHINFO* patchlist, int count, const char* szFileName, char* error); 153 | typedef int (*MODPATHFROMADDR)(duint addr, char* path, int size); 154 | typedef int (*MODPATHFROMNAME)(const char* modname, char* path, int size); 155 | typedef bool (*DISASMFAST)(const unsigned char* data, duint addr, BASIC_INSTRUCTION_INFO* basicinfo); 156 | typedef void (*MEMUPDATEMAP)(); 157 | typedef void (*GETCALLSTACK)(DBGCALLSTACK* callstack); 158 | typedef void (*GETSEHCHAIN)(DBGSEHCHAIN* sehchain); 159 | typedef void (*SYMBOLDOWNLOADALLSYMBOLS)(const char* szSymbolStore); 160 | typedef bool (*GETJIT)(char* jit, bool x64); 161 | typedef bool (*GETJITAUTO)(bool* jitauto); 162 | typedef bool (*GETDEFJIT)(char* defjit); 163 | typedef bool (*GETPROCESSLIST)(DBGPROCESSINFO** entries, int* count); 164 | typedef bool (*GETPAGERIGHTS)(duint addr, char* rights); 165 | typedef bool (*SETPAGERIGHTS)(duint addr, const char* rights); 166 | typedef bool (*PAGERIGHTSTOSTRING)(DWORD protect, char* rights); 167 | typedef bool (*ISPROCESSELEVATED)(); 168 | typedef bool (*GETCMDLINE)(char* cmdline, size_t* cbsize); 169 | typedef bool (*SETCMDLINE)(const char* cmdline); 170 | typedef duint(*FILEOFFSETTOVA)(const char* modname, duint offset); 171 | typedef duint(*VATOFILEOFFSET)(duint va); 172 | typedef duint(*GETADDRFROMLINE)(const char* szSourceFile, int line, duint* displacement); 173 | typedef bool (*GETSOURCEFROMADDR)(duint addr, char* szSourceFile, int* line); 174 | typedef bool (*VALFROMSTRING)(const char* string, duint* value); 175 | typedef bool (*PATCHGETEX)(duint addr, DBGPATCHINFO* info); 176 | typedef bool (*GETBRIDGEBP)(BPXTYPE type, duint addr, BRIDGEBP* bp); 177 | typedef bool (*STRINGFORMATINLINE)(const char* format, size_t resultSize, char* result); 178 | typedef void (*GETMNEMONICBRIEF)(const char* mnem, size_t resultSize, char* result); 179 | typedef unsigned int (*GETTRACERECORDHITCOUNT)(duint address); 180 | typedef TRACERECORDBYTETYPE(*GETTRACERECORDBYTETYPE)(duint address); 181 | typedef bool (*SETTRACERECORDTYPE)(duint pageAddress, TRACERECORDTYPE type); 182 | typedef TRACERECORDTYPE(*GETTRACERECORDTYPE)(duint pageAddress); 183 | typedef bool (*ENUMHANDLES)(ListOf(HANDLEINFO) handles); 184 | typedef bool (*GETHANDLENAME)(duint handle, char* name, size_t nameSize, char* typeName, size_t typeNameSize); 185 | typedef bool (*ENUMTCPCONNECTIONS)(ListOf(TCPCONNECTIONINFO) connections); 186 | typedef duint(*GETDBGEVENTS)(); 187 | typedef int (*MODGETPARTY)(duint base); 188 | typedef void (*MODSETPARTY)(duint base, int party); 189 | typedef bool(*WATCHISWATCHDOGTRIGGERED)(unsigned int id); 190 | typedef bool(*MEMISCODEPAGE)(duint addr, bool refresh); 191 | typedef bool(*ANIMATECOMMAND)(const char* command); 192 | typedef void(*DBGSETDEBUGGEEINITSCRIPT)(const char* fileName); 193 | typedef const char* (*DBGGETDEBUGGEEINITSCRIPT)(); 194 | typedef bool(*HANDLESENUMWINDOWS)(ListOf(WINDOW_INFO) windows); 195 | typedef bool(*HANDLESENUMHEAPS)(ListOf(HEAPINFO) heaps); 196 | typedef bool(*THREADGETNAME)(DWORD tid, char* name); 197 | typedef bool(*ISDEPENABLED)(); 198 | typedef void(*GETCALLSTACKEX)(DBGCALLSTACK* callstack, bool cache); 199 | typedef bool(*GETUSERCOMMENT)(duint addr, char* comment); 200 | typedef void(*ENUMCONSTANTS)(ListOf(CONSTANTINFO) constants); 201 | typedef duint(*MEMBPSIZE)(duint addr); 202 | typedef bool(*MODRELOCATIONSFROMADDR)(duint addr, ListOf(DBGRELOCATIONINFO) relocations); 203 | typedef bool(*MODRELOCATIONATADDR)(duint addr, DBGRELOCATIONINFO* relocation); 204 | typedef bool(*MODRELOCATIONSINRANGE)(duint addr, duint size, ListOf(DBGRELOCATIONINFO) relocations); 205 | typedef duint(*DBGETHASH)(); 206 | typedef int(*SYMAUTOCOMPLETE)(const char* Search, char** Buffer, int MaxSymbols); 207 | typedef void(*REFRESHMODULELIST)(); 208 | typedef duint(*GETADDRFROMLINEEX)(duint mod, const char* szSourceFile, int line); 209 | typedef MODULESYMBOLSTATUS(*MODSYMBOLSTATUS)(duint mod); 210 | 211 | //The list of all the DbgFunctions() return value. 212 | //WARNING: This list is append only. Do not insert things in the middle or plugins would break. 213 | typedef struct DBGFUNCTIONS_ 214 | { 215 | ASSEMBLEATEX AssembleAtEx; 216 | SECTIONFROMADDR SectionFromAddr; 217 | MODNAMEFROMADDR ModNameFromAddr; 218 | MODBASEFROMADDR ModBaseFromAddr; 219 | MODBASEFROMNAME ModBaseFromName; 220 | MODSIZEFROMADDR ModSizeFromAddr; 221 | ASSEMBLE Assemble; 222 | PATCHGET PatchGet; 223 | PATCHINRANGE PatchInRange; 224 | MEMPATCH MemPatch; 225 | PATCHRESTORERANGE PatchRestoreRange; 226 | PATCHENUM PatchEnum; 227 | PATCHRESTORE PatchRestore; 228 | PATCHFILE PatchFile; 229 | MODPATHFROMADDR ModPathFromAddr; 230 | MODPATHFROMNAME ModPathFromName; 231 | DISASMFAST DisasmFast; 232 | MEMUPDATEMAP MemUpdateMap; 233 | GETCALLSTACK GetCallStack; 234 | GETSEHCHAIN GetSEHChain; 235 | SYMBOLDOWNLOADALLSYMBOLS SymbolDownloadAllSymbols; 236 | GETJITAUTO GetJitAuto; 237 | GETJIT GetJit; 238 | GETDEFJIT GetDefJit; 239 | GETPROCESSLIST GetProcessList; 240 | GETPAGERIGHTS GetPageRights; 241 | SETPAGERIGHTS SetPageRights; 242 | PAGERIGHTSTOSTRING PageRightsToString; 243 | ISPROCESSELEVATED IsProcessElevated; 244 | GETCMDLINE GetCmdline; 245 | SETCMDLINE SetCmdline; 246 | FILEOFFSETTOVA FileOffsetToVa; 247 | VATOFILEOFFSET VaToFileOffset; 248 | GETADDRFROMLINE GetAddrFromLine; 249 | GETSOURCEFROMADDR GetSourceFromAddr; 250 | VALFROMSTRING ValFromString; 251 | PATCHGETEX PatchGetEx; 252 | GETBRIDGEBP GetBridgeBp; 253 | STRINGFORMATINLINE StringFormatInline; 254 | GETMNEMONICBRIEF GetMnemonicBrief; 255 | GETTRACERECORDHITCOUNT GetTraceRecordHitCount; 256 | GETTRACERECORDBYTETYPE GetTraceRecordByteType; 257 | SETTRACERECORDTYPE SetTraceRecordType; 258 | GETTRACERECORDTYPE GetTraceRecordType; 259 | ENUMHANDLES EnumHandles; 260 | GETHANDLENAME GetHandleName; 261 | ENUMTCPCONNECTIONS EnumTcpConnections; 262 | GETDBGEVENTS GetDbgEvents; 263 | MODGETPARTY ModGetParty; 264 | MODSETPARTY ModSetParty; 265 | WATCHISWATCHDOGTRIGGERED WatchIsWatchdogTriggered; 266 | MEMISCODEPAGE MemIsCodePage; 267 | ANIMATECOMMAND AnimateCommand; 268 | DBGSETDEBUGGEEINITSCRIPT DbgSetDebuggeeInitScript; 269 | DBGGETDEBUGGEEINITSCRIPT DbgGetDebuggeeInitScript; 270 | HANDLESENUMWINDOWS EnumWindows; 271 | HANDLESENUMHEAPS EnumHeaps; 272 | THREADGETNAME ThreadGetName; 273 | ISDEPENABLED IsDepEnabled; 274 | GETCALLSTACKEX GetCallStackEx; 275 | GETUSERCOMMENT GetUserComment; 276 | ENUMCONSTANTS EnumConstants; 277 | ENUMCONSTANTS EnumErrorCodes; 278 | ENUMCONSTANTS EnumExceptions; 279 | MEMBPSIZE MemBpSize; 280 | MODRELOCATIONSFROMADDR ModRelocationsFromAddr; 281 | MODRELOCATIONATADDR ModRelocationAtAddr; 282 | MODRELOCATIONSINRANGE ModRelocationsInRange; 283 | DBGETHASH DbGetHash; 284 | SYMAUTOCOMPLETE SymAutoComplete; 285 | REFRESHMODULELIST RefreshModuleList; 286 | GETADDRFROMLINEEX GetAddrFromLineEx; 287 | MODSYMBOLSTATUS ModSymbolStatus; 288 | } DBGFUNCTIONS; 289 | 290 | #ifdef BUILD_DBG 291 | 292 | const DBGFUNCTIONS* dbgfunctionsget(); 293 | void dbgfunctionsinit(); 294 | 295 | #endif //BUILD_DBG 296 | 297 | #endif //_DBGFUNCTIONS_H 298 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | #include "jansson/jansson.h" 8 | #pragma warning(push) 9 | #pragma warning(disable:4091) 10 | #include 11 | #pragma warning(pop) 12 | 13 | #else 14 | 15 | #ifdef __GNUC__ 16 | #include "dbghelp/dbghelp.h" 17 | #else 18 | #pragma warning(push) 19 | #pragma warning(disable:4091) 20 | #include 21 | #pragma warning(pop) 22 | #endif // __GNUC__ 23 | 24 | #ifndef deflen 25 | #define deflen 1024 26 | #endif // deflen 27 | 28 | #include "bridgemain.h" 29 | #include "_dbgfunctions.h" 30 | #include "jansson/jansson.h" 31 | 32 | #endif // BUILD_DBG 33 | 34 | #endif // _PLUGIN_DATA_H 35 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | int hMenuGraph; //plugin graph menu handle 51 | int hMenuMemmap; //plugin memory map menu handle 52 | int hMenuSymmod; //plugin symbol module menu handle 53 | } PLUG_SETUPSTRUCT; 54 | 55 | typedef struct 56 | { 57 | void* data; //user data 58 | } PLUG_SCRIPTSTRUCT; 59 | 60 | //callback structures 61 | typedef struct 62 | { 63 | const char* szFileName; 64 | } PLUG_CB_INITDEBUG; 65 | 66 | typedef struct 67 | { 68 | void* reserved; 69 | } PLUG_CB_STOPDEBUG; 70 | 71 | typedef struct 72 | { 73 | CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo; 74 | IMAGEHLP_MODULE64* modInfo; 75 | const char* DebugFileName; 76 | PROCESS_INFORMATION* fdProcessInfo; 77 | } PLUG_CB_CREATEPROCESS; 78 | 79 | typedef struct 80 | { 81 | EXIT_PROCESS_DEBUG_INFO* ExitProcess; 82 | } PLUG_CB_EXITPROCESS; 83 | 84 | typedef struct 85 | { 86 | CREATE_THREAD_DEBUG_INFO* CreateThread; 87 | DWORD dwThreadId; 88 | } PLUG_CB_CREATETHREAD; 89 | 90 | typedef struct 91 | { 92 | EXIT_THREAD_DEBUG_INFO* ExitThread; 93 | DWORD dwThreadId; 94 | } PLUG_CB_EXITTHREAD; 95 | 96 | typedef struct 97 | { 98 | void* reserved; 99 | } PLUG_CB_SYSTEMBREAKPOINT; 100 | 101 | typedef struct 102 | { 103 | LOAD_DLL_DEBUG_INFO* LoadDll; 104 | IMAGEHLP_MODULE64* modInfo; 105 | const char* modname; 106 | } PLUG_CB_LOADDLL; 107 | 108 | typedef struct 109 | { 110 | UNLOAD_DLL_DEBUG_INFO* UnloadDll; 111 | } PLUG_CB_UNLOADDLL; 112 | 113 | typedef struct 114 | { 115 | OUTPUT_DEBUG_STRING_INFO* DebugString; 116 | } PLUG_CB_OUTPUTDEBUGSTRING; 117 | 118 | typedef struct 119 | { 120 | EXCEPTION_DEBUG_INFO* Exception; 121 | } PLUG_CB_EXCEPTION; 122 | 123 | typedef struct 124 | { 125 | BRIDGEBP* breakpoint; 126 | } PLUG_CB_BREAKPOINT; 127 | 128 | typedef struct 129 | { 130 | void* reserved; 131 | } PLUG_CB_PAUSEDEBUG; 132 | 133 | typedef struct 134 | { 135 | void* reserved; 136 | } PLUG_CB_RESUMEDEBUG; 137 | 138 | typedef struct 139 | { 140 | void* reserved; 141 | } PLUG_CB_STEPPED; 142 | 143 | typedef struct 144 | { 145 | DWORD dwProcessId; 146 | } PLUG_CB_ATTACH; 147 | 148 | typedef struct 149 | { 150 | PROCESS_INFORMATION* fdProcessInfo; 151 | } PLUG_CB_DETACH; 152 | 153 | typedef struct 154 | { 155 | DEBUG_EVENT* DebugEvent; 156 | } PLUG_CB_DEBUGEVENT; 157 | 158 | typedef struct 159 | { 160 | int hEntry; 161 | } PLUG_CB_MENUENTRY; 162 | 163 | typedef struct 164 | { 165 | MSG* message; 166 | long* result; 167 | bool retval; 168 | } PLUG_CB_WINEVENT; 169 | 170 | typedef struct 171 | { 172 | MSG* message; 173 | bool retval; 174 | } PLUG_CB_WINEVENTGLOBAL; 175 | 176 | typedef struct 177 | { 178 | json_t* root; 179 | int loadSaveType; 180 | } PLUG_CB_LOADSAVEDB; 181 | 182 | typedef struct 183 | { 184 | const char* symbol; 185 | bool retval; 186 | } PLUG_CB_FILTERSYMBOL; 187 | 188 | typedef struct 189 | { 190 | duint cip; 191 | bool stop; 192 | } PLUG_CB_TRACEEXECUTE; 193 | 194 | typedef struct 195 | { 196 | int hWindow; 197 | duint VA; 198 | } PLUG_CB_SELCHANGED; 199 | 200 | typedef struct 201 | { 202 | BridgeCFGraphList graph; 203 | } PLUG_CB_ANALYZE; 204 | 205 | typedef struct 206 | { 207 | duint addr; 208 | BRIDGE_ADDRINFO* addrinfo; 209 | bool retval; 210 | } PLUG_CB_ADDRINFO; 211 | 212 | typedef struct 213 | { 214 | const char* string; 215 | duint value; 216 | int* value_size; 217 | bool* isvar; 218 | bool* hexonly; 219 | bool retval; 220 | } PLUG_CB_VALFROMSTRING; 221 | 222 | typedef struct 223 | { 224 | const char* string; 225 | duint value; 226 | bool retval; 227 | } PLUG_CB_VALTOSTRING; 228 | 229 | typedef struct 230 | { 231 | GUIMENUTYPE hMenu; 232 | } PLUG_CB_MENUPREPARE; 233 | 234 | //enums 235 | typedef enum 236 | { 237 | CB_INITDEBUG, //PLUG_CB_INITDEBUG 238 | CB_STOPDEBUG, //PLUG_CB_STOPDEBUG 239 | CB_CREATEPROCESS, //PLUG_CB_CREATEPROCESS 240 | CB_EXITPROCESS, //PLUG_CB_EXITPROCESS 241 | CB_CREATETHREAD, //PLUG_CB_CREATETHREAD 242 | CB_EXITTHREAD, //PLUG_CB_EXITTHREAD 243 | CB_SYSTEMBREAKPOINT, //PLUG_CB_SYSTEMBREAKPOINT 244 | CB_LOADDLL, //PLUG_CB_LOADDLL 245 | CB_UNLOADDLL, //PLUG_CB_UNLOADDLL 246 | CB_OUTPUTDEBUGSTRING, //PLUG_CB_OUTPUTDEBUGSTRING 247 | CB_EXCEPTION, //PLUG_CB_EXCEPTION 248 | CB_BREAKPOINT, //PLUG_CB_BREAKPOINT 249 | CB_PAUSEDEBUG, //PLUG_CB_PAUSEDEBUG 250 | CB_RESUMEDEBUG, //PLUG_CB_RESUMEDEBUG 251 | CB_STEPPED, //PLUG_CB_STEPPED 252 | CB_ATTACH, //PLUG_CB_ATTACHED (before attaching, after CB_INITDEBUG) 253 | CB_DETACH, //PLUG_CB_DETACH (before detaching, before CB_STOPDEBUG) 254 | CB_DEBUGEVENT, //PLUG_CB_DEBUGEVENT (called on any debug event) 255 | CB_MENUENTRY, //PLUG_CB_MENUENTRY 256 | CB_WINEVENT, //PLUG_CB_WINEVENT 257 | CB_WINEVENTGLOBAL, //PLUG_CB_WINEVENTGLOBAL 258 | CB_LOADDB, //PLUG_CB_LOADSAVEDB 259 | CB_SAVEDB, //PLUG_CB_LOADSAVEDB 260 | CB_FILTERSYMBOL, //PLUG_CB_FILTERSYMBOL 261 | CB_TRACEEXECUTE, //PLUG_CB_TRACEEXECUTE 262 | CB_SELCHANGED, //PLUG_CB_SELCHANGED 263 | CB_ANALYZE, //PLUG_CB_ANALYZE 264 | CB_ADDRINFO, //PLUG_CB_ADDRINFO 265 | CB_VALFROMSTRING, //PLUG_CB_VALFROMSTRING 266 | CB_VALTOSTRING, //PLUG_CB_VALTOSTRING 267 | CB_MENUPREPARE, //PLUG_CB_MENUPREPARE 268 | CB_LAST 269 | } CBTYPE; 270 | 271 | typedef enum 272 | { 273 | FORMAT_ERROR, //generic failure (no message) 274 | FORMAT_SUCCESS, //success 275 | FORMAT_ERROR_MESSAGE, //formatting failed but an error was put in the buffer (there are always at least 511 characters available). 276 | FORMAT_BUFFER_TOO_SMALL //buffer too small (x64dbg will retry until the buffer is big enough) 277 | } FORMATRESULT; 278 | 279 | //typedefs 280 | typedef void (*CBPLUGIN)(CBTYPE cbType, void* callbackInfo); 281 | typedef bool (*CBPLUGINCOMMAND)(int argc, char** argv); 282 | typedef void (*CBPLUGINSCRIPT)(); 283 | typedef duint(*CBPLUGINEXPRFUNCTION)(int argc, duint* argv, void* userdata); 284 | typedef FORMATRESULT(*CBPLUGINFORMATFUNCTION)(char* dest, size_t destCount, int argc, char* argv[], duint value, void* userdata); 285 | typedef bool (*CBPLUGINPREDICATE)(void* userdata); 286 | 287 | //exports 288 | #ifdef __cplusplus 289 | extern "C" 290 | { 291 | #endif 292 | 293 | PLUG_IMPEXP void _plugin_registercallback(int pluginHandle, CBTYPE cbType, CBPLUGIN cbPlugin); 294 | PLUG_IMPEXP bool _plugin_unregistercallback(int pluginHandle, CBTYPE cbType); 295 | PLUG_IMPEXP bool _plugin_registercommand(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly); 296 | PLUG_IMPEXP bool _plugin_unregistercommand(int pluginHandle, const char* command); 297 | PLUG_IMPEXP void _plugin_logprintf(const char* format, ...); 298 | PLUG_IMPEXP void _plugin_logputs(const char* text); 299 | PLUG_IMPEXP void _plugin_logprint(const char* text); 300 | PLUG_IMPEXP void _plugin_debugpause(); 301 | PLUG_IMPEXP void _plugin_debugskipexceptions(bool skip); 302 | PLUG_IMPEXP int _plugin_menuadd(int hMenu, const char* title); 303 | PLUG_IMPEXP bool _plugin_menuaddentry(int hMenu, int hEntry, const char* title); 304 | PLUG_IMPEXP bool _plugin_menuaddseparator(int hMenu); 305 | PLUG_IMPEXP bool _plugin_menuclear(int hMenu); 306 | PLUG_IMPEXP void _plugin_menuseticon(int hMenu, const ICONDATA* icon); 307 | PLUG_IMPEXP void _plugin_menuentryseticon(int pluginHandle, int hEntry, const ICONDATA* icon); 308 | PLUG_IMPEXP void _plugin_menuentrysetchecked(int pluginHandle, int hEntry, bool checked); 309 | PLUG_IMPEXP void _plugin_menusetvisible(int pluginHandle, int hMenu, bool visible); 310 | PLUG_IMPEXP void _plugin_menuentrysetvisible(int pluginHandle, int hEntry, bool visible); 311 | PLUG_IMPEXP void _plugin_menusetname(int pluginHandle, int hMenu, const char* name); 312 | PLUG_IMPEXP void _plugin_menuentrysetname(int pluginHandle, int hEntry, const char* name); 313 | PLUG_IMPEXP void _plugin_menuentrysethotkey(int pluginHandle, int hEntry, const char* hotkey); 314 | PLUG_IMPEXP bool _plugin_menuremove(int hMenu); 315 | PLUG_IMPEXP bool _plugin_menuentryremove(int pluginHandle, int hEntry); 316 | PLUG_IMPEXP void _plugin_startscript(CBPLUGINSCRIPT cbScript); 317 | PLUG_IMPEXP bool _plugin_waituntilpaused(); 318 | PLUG_IMPEXP bool _plugin_registerexprfunction(int pluginHandle, const char* name, int argc, CBPLUGINEXPRFUNCTION cbFunction, void* userdata); 319 | PLUG_IMPEXP bool _plugin_unregisterexprfunction(int pluginHandle, const char* name); 320 | PLUG_IMPEXP bool _plugin_unload(const char* pluginName); 321 | PLUG_IMPEXP bool _plugin_load(const char* pluginName); 322 | PLUG_IMPEXP duint _plugin_hash(const void* data, duint size); 323 | PLUG_IMPEXP bool _plugin_registerformatfunction(int pluginHandle, const char* type, CBPLUGINFORMATFUNCTION cbFunction, void* userdata); 324 | PLUG_IMPEXP bool _plugin_unregisterformatfunction(int pluginHandle, const char* type); 325 | 326 | #ifdef __cplusplus 327 | } 328 | #endif 329 | 330 | #pragma pack(pop) 331 | 332 | #endif // _PLUGINS_H 333 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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); 26 | SCRIPT_EXPORT void DeleteRange(duint start, duint end); 27 | SCRIPT_EXPORT void Clear(); 28 | SCRIPT_EXPORT bool GetList(ListOf(FunctionInfo) list); //caller has the responsibility to free the list 29 | }; //Function 30 | }; //Script 31 | 32 | #endif //_SCRIPTAPI_FUNCTION_H 33 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | 34 | namespace Graph 35 | { 36 | SCRIPT_EXPORT duint SelectionGetStart(); 37 | }; //Graph 38 | 39 | namespace MemMap 40 | { 41 | SCRIPT_EXPORT duint SelectionGetStart(); 42 | }; //MemoryMap 43 | 44 | namespace SymMod 45 | { 46 | SCRIPT_EXPORT duint SelectionGetStart(); 47 | }; //SymMod 48 | }; //Gui 49 | 50 | namespace Gui 51 | { 52 | enum Window 53 | { 54 | DisassemblyWindow, 55 | DumpWindow, 56 | StackWindow, 57 | GraphWindow, 58 | MemMapWindow, 59 | SymModWindow 60 | }; 61 | 62 | SCRIPT_EXPORT bool SelectionGet(Window window, duint* start, duint* end); 63 | SCRIPT_EXPORT bool SelectionSet(Window window, duint start, duint end); 64 | SCRIPT_EXPORT duint SelectionGetStart(Window window); 65 | SCRIPT_EXPORT duint SelectionGetEnd(Window window); 66 | SCRIPT_EXPORT void Message(const char* message); 67 | SCRIPT_EXPORT bool MessageYesNo(const char* message); 68 | SCRIPT_EXPORT bool InputLine(const char* title, char* text); //text[GUI_MAX_LINE_SIZE] 69 | SCRIPT_EXPORT bool InputValue(const char* title, duint* value); 70 | SCRIPT_EXPORT void Refresh(); 71 | SCRIPT_EXPORT void AddQWidgetTab(void* qWidget); 72 | SCRIPT_EXPORT void ShowQWidgetTab(void* qWidget); 73 | SCRIPT_EXPORT void CloseQWidgetTab(void* qWidget); 74 | 75 | }; //Gui 76 | }; //Script 77 | 78 | #endif //_SCRIPTAPI_GUI_H -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | SCRIPT_EXPORT unsigned int GetProtect(duint addr, bool reserved = false, bool cache = true); 16 | SCRIPT_EXPORT duint GetBase(duint addr, bool reserved = false, bool cache = true); 17 | SCRIPT_EXPORT duint GetSize(duint addr, bool reserved = false, bool cache = true); 18 | 19 | SCRIPT_EXPORT unsigned char ReadByte(duint addr); 20 | SCRIPT_EXPORT bool WriteByte(duint addr, unsigned char data); 21 | SCRIPT_EXPORT unsigned short ReadWord(duint addr); 22 | SCRIPT_EXPORT bool WriteWord(duint addr, unsigned short data); 23 | SCRIPT_EXPORT unsigned int ReadDword(duint addr); 24 | SCRIPT_EXPORT bool WriteDword(duint addr, unsigned int data); 25 | SCRIPT_EXPORT unsigned long long ReadQword(duint addr); 26 | SCRIPT_EXPORT bool WriteQword(duint addr, unsigned long long data); 27 | SCRIPT_EXPORT duint ReadPtr(duint addr); 28 | SCRIPT_EXPORT bool WritePtr(duint addr, duint data); 29 | }; //Memory 30 | }; //Script 31 | 32 | #endif //_SCRIPTAPI_MEMORY_H -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | /// 11 | /// Evaluates an expression and returns the result. Analagous to using the Command field in x64dbg. 12 | /// 13 | /// Expressions can consist of memory locations, registers, flags, API names, labels, symbols, variables etc. 14 | /// 15 | /// Example: bool success = ParseExpression("[esp+8]", &val) 16 | /// 17 | /// The expression to evaluate. 18 | /// The result of the expression. 19 | /// True on success, False on failure. 20 | SCRIPT_EXPORT bool ParseExpression(const char* expression, duint* value); 21 | 22 | /// 23 | /// Returns the address of a function in the debuggee's memory space. 24 | /// 25 | /// Example: duint addr = RemoteGetProcAddress("kernel32.dll", "GetProcAddress") 26 | /// 27 | /// The name of the module. 28 | /// The name of the function. 29 | /// The address of the function in the debuggee. 30 | SCRIPT_EXPORT duint RemoteGetProcAddress(const char* module, const char* api); 31 | 32 | /// 33 | /// Returns the address for a label created in the disassembly window. 34 | /// 35 | /// Example: duint addr = ResolveLabel("sneaky_crypto") 36 | /// 37 | /// The name of the label to resolve. 38 | /// The memory address for the label. 39 | SCRIPT_EXPORT duint ResolveLabel(const char* label); 40 | 41 | /// 42 | /// Allocates the requested number of bytes from x64dbg's default process heap. 43 | /// 44 | /// Note: this allocation is in the debugger, not the debuggee. 45 | /// 46 | /// Memory allocated using this function should be Free'd after use. 47 | /// 48 | /// Example: void* addr = Alloc(0x100000) 49 | /// 50 | /// Number of bytes to allocate. 51 | /// A pointer to the newly allocated memory. 52 | SCRIPT_EXPORT void* Alloc(duint size); 53 | 54 | /// 55 | /// Frees memory previously allocated by Alloc. 56 | /// 57 | /// Example: Free(addr) 58 | /// 59 | /// Pointer returned by Alloc. 60 | /// Nothing. 61 | SCRIPT_EXPORT void Free(void* ptr); 62 | }; //Misc 63 | }; //Script 64 | 65 | #endif //_SCRIPTAPI_MISC_H -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | struct ModuleExport 28 | { 29 | duint ordinal; 30 | duint rva; 31 | duint va; 32 | bool forwarded; 33 | char forwardName[MAX_STRING_SIZE]; 34 | char name[MAX_STRING_SIZE]; 35 | char undecoratedName[MAX_STRING_SIZE]; 36 | }; 37 | 38 | struct ModuleImport 39 | { 40 | duint iatRva; 41 | duint iatVa; 42 | duint ordinal; //equal to -1 if imported by name 43 | char name[MAX_STRING_SIZE]; 44 | char undecoratedName[MAX_STRING_SIZE]; 45 | }; 46 | 47 | SCRIPT_EXPORT bool InfoFromAddr(duint addr, ModuleInfo* info); 48 | SCRIPT_EXPORT bool InfoFromName(const char* name, ModuleInfo* info); 49 | SCRIPT_EXPORT duint BaseFromAddr(duint addr); 50 | SCRIPT_EXPORT duint BaseFromName(const char* name); 51 | SCRIPT_EXPORT duint SizeFromAddr(duint addr); 52 | SCRIPT_EXPORT duint SizeFromName(const char* name); 53 | SCRIPT_EXPORT bool NameFromAddr(duint addr, char* name); //name[MAX_MODULE_SIZE] 54 | SCRIPT_EXPORT bool PathFromAddr(duint addr, char* path); //path[MAX_PATH] 55 | SCRIPT_EXPORT bool PathFromName(const char* name, char* path); //path[MAX_PATH] 56 | SCRIPT_EXPORT duint EntryFromAddr(duint addr); 57 | SCRIPT_EXPORT duint EntryFromName(const char* name); 58 | SCRIPT_EXPORT int SectionCountFromAddr(duint addr); 59 | SCRIPT_EXPORT int SectionCountFromName(const char* name); 60 | SCRIPT_EXPORT bool SectionFromAddr(duint addr, int number, ModuleSectionInfo* section); 61 | SCRIPT_EXPORT bool SectionFromName(const char* name, int number, ModuleSectionInfo* section); 62 | SCRIPT_EXPORT bool SectionListFromAddr(duint addr, ListOf(ModuleSectionInfo) list); 63 | SCRIPT_EXPORT bool SectionListFromName(const char* name, ListOf(ModuleSectionInfo) list); 64 | SCRIPT_EXPORT bool GetMainModuleInfo(ModuleInfo* info); 65 | SCRIPT_EXPORT duint GetMainModuleBase(); 66 | SCRIPT_EXPORT duint GetMainModuleSize(); 67 | SCRIPT_EXPORT duint GetMainModuleEntry(); 68 | SCRIPT_EXPORT int GetMainModuleSectionCount(); 69 | SCRIPT_EXPORT bool GetMainModuleName(char* name); //name[MAX_MODULE_SIZE] 70 | SCRIPT_EXPORT bool GetMainModulePath(char* path); //path[MAX_PATH] 71 | SCRIPT_EXPORT bool GetMainModuleSectionList(ListOf(ModuleSectionInfo) list); //caller has the responsibility to free the list 72 | SCRIPT_EXPORT bool GetList(ListOf(ModuleInfo) list); //caller has the responsibility to free the list 73 | SCRIPT_EXPORT bool GetExports(const ModuleInfo* mod, ListOf(ModuleExport) list); //caller has the responsibility to free the list 74 | SCRIPT_EXPORT bool GetImports(const ModuleInfo* mod, ListOf(ModuleImport) list); //caller has the responsibility to free the list 75 | }; //Module 76 | }; //Script 77 | 78 | #endif //_SCRIPTAPI_MODULE_H 79 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | CAX, 96 | CBX, 97 | CCX, 98 | CDX, 99 | CDI, 100 | CSI, 101 | CBP, 102 | CFLAGS 103 | }; //RegisterEnum 104 | 105 | SCRIPT_EXPORT duint Get(RegisterEnum reg); 106 | SCRIPT_EXPORT bool Set(RegisterEnum reg, duint value); 107 | SCRIPT_EXPORT int Size(); //gets architecture register size in bytes 108 | 109 | SCRIPT_EXPORT duint GetDR0(); 110 | SCRIPT_EXPORT bool SetDR0(duint value); 111 | SCRIPT_EXPORT duint GetDR1(); 112 | SCRIPT_EXPORT bool SetDR1(duint value); 113 | SCRIPT_EXPORT duint GetDR2(); 114 | SCRIPT_EXPORT bool SetDR2(duint value); 115 | SCRIPT_EXPORT duint GetDR3(); 116 | SCRIPT_EXPORT bool SetDR3(duint value); 117 | SCRIPT_EXPORT duint GetDR6(); 118 | SCRIPT_EXPORT bool SetDR6(duint value); 119 | SCRIPT_EXPORT duint GetDR7(); 120 | SCRIPT_EXPORT bool SetDR7(duint value); 121 | 122 | SCRIPT_EXPORT unsigned int GetEAX(); 123 | SCRIPT_EXPORT bool SetEAX(unsigned int value); 124 | SCRIPT_EXPORT unsigned short GetAX(); 125 | SCRIPT_EXPORT bool SetAX(unsigned short value); 126 | SCRIPT_EXPORT unsigned char GetAH(); 127 | SCRIPT_EXPORT bool SetAH(unsigned char value); 128 | SCRIPT_EXPORT unsigned char GetAL(); 129 | SCRIPT_EXPORT bool SetAL(unsigned char value); 130 | SCRIPT_EXPORT unsigned int GetEBX(); 131 | SCRIPT_EXPORT bool SetEBX(unsigned int value); 132 | SCRIPT_EXPORT unsigned short GetBX(); 133 | SCRIPT_EXPORT bool SetBX(unsigned short value); 134 | SCRIPT_EXPORT unsigned char GetBH(); 135 | SCRIPT_EXPORT bool SetBH(unsigned char value); 136 | SCRIPT_EXPORT unsigned char GetBL(); 137 | SCRIPT_EXPORT bool SetBL(unsigned char value); 138 | SCRIPT_EXPORT unsigned int GetECX(); 139 | SCRIPT_EXPORT bool SetECX(unsigned int value); 140 | SCRIPT_EXPORT unsigned short GetCX(); 141 | SCRIPT_EXPORT bool SetCX(unsigned short value); 142 | SCRIPT_EXPORT unsigned char GetCH(); 143 | SCRIPT_EXPORT bool SetCH(unsigned char value); 144 | SCRIPT_EXPORT unsigned char GetCL(); 145 | SCRIPT_EXPORT bool SetCL(unsigned char value); 146 | SCRIPT_EXPORT unsigned int GetEDX(); 147 | SCRIPT_EXPORT bool SetEDX(unsigned int value); 148 | SCRIPT_EXPORT unsigned short GetDX(); 149 | SCRIPT_EXPORT bool SetDX(unsigned short value); 150 | SCRIPT_EXPORT unsigned char GetDH(); 151 | SCRIPT_EXPORT bool SetDH(unsigned char value); 152 | SCRIPT_EXPORT unsigned char GetDL(); 153 | SCRIPT_EXPORT bool SetDL(unsigned char value); 154 | SCRIPT_EXPORT unsigned int GetEDI(); 155 | SCRIPT_EXPORT bool SetEDI(unsigned int value); 156 | SCRIPT_EXPORT unsigned short GetDI(); 157 | SCRIPT_EXPORT bool SetDI(unsigned short value); 158 | SCRIPT_EXPORT unsigned int GetESI(); 159 | SCRIPT_EXPORT bool SetESI(unsigned int value); 160 | SCRIPT_EXPORT unsigned short GetSI(); 161 | SCRIPT_EXPORT bool SetSI(unsigned short value); 162 | SCRIPT_EXPORT unsigned int GetEBP(); 163 | SCRIPT_EXPORT bool SetEBP(unsigned int value); 164 | SCRIPT_EXPORT unsigned short GetBP(); 165 | SCRIPT_EXPORT bool SetBP(unsigned short value); 166 | SCRIPT_EXPORT unsigned int GetESP(); 167 | SCRIPT_EXPORT bool SetESP(unsigned int value); 168 | SCRIPT_EXPORT unsigned short GetSP(); 169 | SCRIPT_EXPORT bool SetSP(unsigned short value); 170 | SCRIPT_EXPORT unsigned int GetEIP(); 171 | SCRIPT_EXPORT bool SetEIP(unsigned int value); 172 | 173 | #ifdef _WIN64 174 | SCRIPT_EXPORT unsigned long long GetRAX(); 175 | SCRIPT_EXPORT bool SetRAX(unsigned long long value); 176 | SCRIPT_EXPORT unsigned long long GetRBX(); 177 | SCRIPT_EXPORT bool SetRBX(unsigned long long value); 178 | SCRIPT_EXPORT unsigned long long GetRCX(); 179 | SCRIPT_EXPORT bool SetRCX(unsigned long long value); 180 | SCRIPT_EXPORT unsigned long long GetRDX(); 181 | SCRIPT_EXPORT bool SetRDX(unsigned long long value); 182 | SCRIPT_EXPORT unsigned long long GetRSI(); 183 | SCRIPT_EXPORT bool SetRSI(unsigned long long value); 184 | SCRIPT_EXPORT unsigned char GetSIL(); 185 | SCRIPT_EXPORT bool SetSIL(unsigned char value); 186 | SCRIPT_EXPORT unsigned long long GetRDI(); 187 | SCRIPT_EXPORT bool SetRDI(unsigned long long value); 188 | SCRIPT_EXPORT unsigned char GetDIL(); 189 | SCRIPT_EXPORT bool SetDIL(unsigned char value); 190 | SCRIPT_EXPORT unsigned long long GetRBP(); 191 | SCRIPT_EXPORT bool SetRBP(unsigned long long value); 192 | SCRIPT_EXPORT unsigned char GetBPL(); 193 | SCRIPT_EXPORT bool SetBPL(unsigned char value); 194 | SCRIPT_EXPORT unsigned long long GetRSP(); 195 | SCRIPT_EXPORT bool SetRSP(unsigned long long value); 196 | SCRIPT_EXPORT unsigned char GetSPL(); 197 | SCRIPT_EXPORT bool SetSPL(unsigned char value); 198 | SCRIPT_EXPORT unsigned long long GetRIP(); 199 | SCRIPT_EXPORT bool SetRIP(unsigned long long value); 200 | SCRIPT_EXPORT unsigned long long GetR8(); 201 | SCRIPT_EXPORT bool SetR8(unsigned long long value); 202 | SCRIPT_EXPORT unsigned int GetR8D(); 203 | SCRIPT_EXPORT bool SetR8D(unsigned int value); 204 | SCRIPT_EXPORT unsigned short GetR8W(); 205 | SCRIPT_EXPORT bool SetR8W(unsigned short value); 206 | SCRIPT_EXPORT unsigned char GetR8B(); 207 | SCRIPT_EXPORT bool SetR8B(unsigned char value); 208 | SCRIPT_EXPORT unsigned long long GetR9(); 209 | SCRIPT_EXPORT bool SetR9(unsigned long long value); 210 | SCRIPT_EXPORT unsigned int GetR9D(); 211 | SCRIPT_EXPORT bool SetR9D(unsigned int value); 212 | SCRIPT_EXPORT unsigned short GetR9W(); 213 | SCRIPT_EXPORT bool SetR9W(unsigned short value); 214 | SCRIPT_EXPORT unsigned char GetR9B(); 215 | SCRIPT_EXPORT bool SetR9B(unsigned char value); 216 | SCRIPT_EXPORT unsigned long long GetR10(); 217 | SCRIPT_EXPORT bool SetR10(unsigned long long value); 218 | SCRIPT_EXPORT unsigned int GetR10D(); 219 | SCRIPT_EXPORT bool SetR10D(unsigned int value); 220 | SCRIPT_EXPORT unsigned short GetR10W(); 221 | SCRIPT_EXPORT bool SetR10W(unsigned short value); 222 | SCRIPT_EXPORT unsigned char GetR10B(); 223 | SCRIPT_EXPORT bool SetR10B(unsigned char value); 224 | SCRIPT_EXPORT unsigned long long GetR11(); 225 | SCRIPT_EXPORT bool SetR11(unsigned long long value); 226 | SCRIPT_EXPORT unsigned int GetR11D(); 227 | SCRIPT_EXPORT bool SetR11D(unsigned int value); 228 | SCRIPT_EXPORT unsigned short GetR11W(); 229 | SCRIPT_EXPORT bool SetR11W(unsigned short value); 230 | SCRIPT_EXPORT unsigned char GetR11B(); 231 | SCRIPT_EXPORT bool SetR11B(unsigned char value); 232 | SCRIPT_EXPORT unsigned long long GetR12(); 233 | SCRIPT_EXPORT bool SetR12(unsigned long long value); 234 | SCRIPT_EXPORT unsigned int GetR12D(); 235 | SCRIPT_EXPORT bool SetR12D(unsigned int value); 236 | SCRIPT_EXPORT unsigned short GetR12W(); 237 | SCRIPT_EXPORT bool SetR12W(unsigned short value); 238 | SCRIPT_EXPORT unsigned char GetR12B(); 239 | SCRIPT_EXPORT bool SetR12B(unsigned char value); 240 | SCRIPT_EXPORT unsigned long long GetR13(); 241 | SCRIPT_EXPORT bool SetR13(unsigned long long value); 242 | SCRIPT_EXPORT unsigned int GetR13D(); 243 | SCRIPT_EXPORT bool SetR13D(unsigned int value); 244 | SCRIPT_EXPORT unsigned short GetR13W(); 245 | SCRIPT_EXPORT bool SetR13W(unsigned short value); 246 | SCRIPT_EXPORT unsigned char GetR13B(); 247 | SCRIPT_EXPORT bool SetR13B(unsigned char value); 248 | SCRIPT_EXPORT unsigned long long GetR14(); 249 | SCRIPT_EXPORT bool SetR14(unsigned long long value); 250 | SCRIPT_EXPORT unsigned int GetR14D(); 251 | SCRIPT_EXPORT bool SetR14D(unsigned int value); 252 | SCRIPT_EXPORT unsigned short GetR14W(); 253 | SCRIPT_EXPORT bool SetR14W(unsigned short value); 254 | SCRIPT_EXPORT unsigned char GetR14B(); 255 | SCRIPT_EXPORT bool SetR14B(unsigned char value); 256 | SCRIPT_EXPORT unsigned long long GetR15(); 257 | SCRIPT_EXPORT bool SetR15(unsigned long long value); 258 | SCRIPT_EXPORT unsigned int GetR15D(); 259 | SCRIPT_EXPORT bool SetR15D(unsigned int value); 260 | SCRIPT_EXPORT unsigned short GetR15W(); 261 | SCRIPT_EXPORT bool SetR15W(unsigned short value); 262 | SCRIPT_EXPORT unsigned char GetR15B(); 263 | SCRIPT_EXPORT bool SetR15B(unsigned char value); 264 | #endif //_WIN64 265 | 266 | SCRIPT_EXPORT duint GetCAX(); 267 | SCRIPT_EXPORT bool SetCAX(duint value); 268 | SCRIPT_EXPORT duint GetCBX(); 269 | SCRIPT_EXPORT bool SetCBX(duint value); 270 | SCRIPT_EXPORT duint GetCCX(); 271 | SCRIPT_EXPORT bool SetCCX(duint value); 272 | SCRIPT_EXPORT duint GetCDX(); 273 | SCRIPT_EXPORT bool SetCDX(duint value); 274 | SCRIPT_EXPORT duint GetCDI(); 275 | SCRIPT_EXPORT bool SetCDI(duint value); 276 | SCRIPT_EXPORT duint GetCSI(); 277 | SCRIPT_EXPORT bool SetCSI(duint value); 278 | SCRIPT_EXPORT duint GetCBP(); 279 | SCRIPT_EXPORT bool SetCBP(duint value); 280 | SCRIPT_EXPORT duint GetCSP(); 281 | SCRIPT_EXPORT bool SetCSP(duint value); 282 | SCRIPT_EXPORT duint GetCIP(); 283 | SCRIPT_EXPORT bool SetCIP(duint value); 284 | SCRIPT_EXPORT duint GetCFLAGS(); 285 | SCRIPT_EXPORT bool SetCFLAGS(duint value); 286 | }; //Register 287 | }; //Script 288 | 289 | #endif //_SCRIPTAPI_REGISTER_H -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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, //user-defined function 13 | Import, //IAT entry 14 | Export //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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/bridgegraph.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPH_H 2 | #define _GRAPH_H 3 | 4 | typedef struct 5 | { 6 | duint addr; //virtual address of the instruction 7 | unsigned char data[15]; //instruction bytes 8 | } BridgeCFInstruction; 9 | 10 | typedef struct 11 | { 12 | duint parentGraph; //function of which this node is a part 13 | duint start; //start of the block 14 | duint end; //end of the block (inclusive) 15 | duint brtrue; //destination if condition is true 16 | duint brfalse; //destination if condition is false 17 | duint icount; //number of instructions in node 18 | bool terminal; //node is a RET 19 | bool split; //node is a split (brtrue points to the next node) 20 | bool indirectcall; //node contains indirect calls (call reg, call [reg+X]) 21 | void* userdata; //user data 22 | ListInfo exits; //exits (including brtrue and brfalse, duint) 23 | ListInfo instrs; //block instructions 24 | } BridgeCFNodeList; 25 | 26 | typedef struct 27 | { 28 | duint entryPoint; //graph entry point 29 | void* userdata; //user data 30 | ListInfo nodes; //graph nodes (BridgeCFNodeList) 31 | } BridgeCFGraphList; 32 | 33 | #ifdef __cplusplus 34 | #if _MSC_VER >= 1700 && !defined(NO_CPP11) 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | struct BridgeCFNode 42 | { 43 | duint parentGraph = 0; //function of which this node is a part 44 | duint start = 0; //start of the block 45 | duint end = 0; //end of the block (inclusive) 46 | duint brtrue = 0; //destination if condition is true 47 | duint brfalse = 0; //destination if condition is false 48 | duint icount = 0; //number of instructions in node 49 | bool terminal = false; //node is a RET 50 | bool split = false; //node is a split (brtrue points to the next node) 51 | bool indirectcall = false; //node contains indirect calls (call reg, call [reg+X]) 52 | void* userdata = nullptr; //user data 53 | std::vector exits; //exits (including brtrue and brfalse) 54 | std::vector instrs; //block instructions 55 | 56 | static void Free(const BridgeCFNodeList* nodeList) 57 | { 58 | if(!BridgeList::Free(&nodeList->exits)) 59 | __debugbreak(); 60 | if(!BridgeList::Free(&nodeList->instrs)) 61 | __debugbreak(); 62 | } 63 | 64 | BridgeCFNode() = default; 65 | 66 | BridgeCFNode(const BridgeCFNodeList* nodeList, bool freedata) 67 | { 68 | if(!nodeList) 69 | __debugbreak(); 70 | parentGraph = nodeList->parentGraph; 71 | start = nodeList->start; 72 | end = nodeList->end; 73 | brtrue = nodeList->brtrue; 74 | brfalse = nodeList->brfalse; 75 | icount = nodeList->icount; 76 | terminal = nodeList->terminal; 77 | indirectcall = nodeList->indirectcall; 78 | split = nodeList->split; 79 | userdata = nodeList->userdata; 80 | if(!BridgeList::ToVector(&nodeList->exits, exits, freedata)) 81 | __debugbreak(); 82 | if(!BridgeList::ToVector(&nodeList->instrs, instrs, freedata)) 83 | __debugbreak(); 84 | } 85 | 86 | BridgeCFNode(duint parentGraph, duint start, duint end) 87 | : parentGraph(parentGraph), 88 | start(start), 89 | end(end) 90 | { 91 | } 92 | 93 | BridgeCFNodeList ToNodeList() const 94 | { 95 | BridgeCFNodeList out; 96 | out.parentGraph = parentGraph; 97 | out.start = start; 98 | out.end = end; 99 | out.brtrue = brtrue; 100 | out.brfalse = brfalse; 101 | out.icount = icount; 102 | out.terminal = terminal; 103 | out.indirectcall = indirectcall; 104 | out.split = split; 105 | out.userdata = userdata; 106 | BridgeList::CopyData(&out.exits, exits); 107 | BridgeList::CopyData(&out.instrs, instrs); 108 | return std::move(out); 109 | } 110 | }; 111 | 112 | struct BridgeCFGraph 113 | { 114 | duint entryPoint; //graph entry point 115 | void* userdata; //user data 116 | std::unordered_map nodes; //CFNode.start -> CFNode 117 | std::unordered_map> parents; //CFNode.start -> parents 118 | 119 | static void Free(const BridgeCFGraphList* graphList) 120 | { 121 | if(!graphList || graphList->nodes.size != graphList->nodes.count * sizeof(BridgeCFNodeList)) 122 | __debugbreak(); 123 | auto data = (BridgeCFNodeList*)graphList->nodes.data; 124 | for(int i = 0; i < graphList->nodes.count; i++) 125 | BridgeCFNode::Free(&data[i]); 126 | BridgeFree(data); 127 | } 128 | 129 | explicit BridgeCFGraph(const BridgeCFGraphList* graphList, bool freedata) 130 | { 131 | if(!graphList || graphList->nodes.size != graphList->nodes.count * sizeof(BridgeCFNodeList)) 132 | __debugbreak(); 133 | entryPoint = graphList->entryPoint; 134 | userdata = graphList->userdata; 135 | auto data = (BridgeCFNodeList*)graphList->nodes.data; 136 | for(int i = 0; i < graphList->nodes.count; i++) 137 | AddNode(BridgeCFNode(&data[i], freedata)); 138 | if(freedata && data) 139 | BridgeFree(data); 140 | } 141 | 142 | explicit BridgeCFGraph(duint entryPoint) 143 | : entryPoint(entryPoint), 144 | userdata(nullptr) 145 | { 146 | } 147 | 148 | void AddNode(const BridgeCFNode & node) 149 | { 150 | nodes[node.start] = node; 151 | AddParent(node.start, node.brtrue); 152 | AddParent(node.start, node.brfalse); 153 | } 154 | 155 | void AddParent(duint child, duint parent) 156 | { 157 | if(!child || !parent) 158 | return; 159 | auto found = parents.find(child); 160 | if(found == parents.end()) 161 | { 162 | parents[child] = std::unordered_set(); 163 | parents[child].insert(parent); 164 | } 165 | else 166 | found->second.insert(parent); 167 | } 168 | 169 | BridgeCFGraphList ToGraphList() const 170 | { 171 | BridgeCFGraphList out; 172 | out.entryPoint = entryPoint; 173 | out.userdata = userdata; 174 | std::vector nodeList; 175 | nodeList.reserve(nodes.size()); 176 | for(const auto & nodeIt : nodes) 177 | nodeList.push_back(nodeIt.second.ToNodeList()); 178 | BridgeList::CopyData(&out.nodes, nodeList); 179 | return std::move(out); 180 | } 181 | }; 182 | 183 | #endif //_MSC_VER 184 | #endif //__cplusplus 185 | 186 | #endif //_GRAPH_H -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 Free(const ListInfo* listInfo) 124 | { 125 | if(!listInfo || listInfo->size != listInfo->count * sizeof(Type) || (listInfo->count && !listInfo->data)) 126 | return false; 127 | BridgeFree(listInfo->data); 128 | return true; 129 | } 130 | 131 | static bool ToVector(const ListInfo* listInfo, std::vector & listData, bool freedata = true) 132 | { 133 | if(!listInfo || listInfo->size != listInfo->count * sizeof(Type) || (listInfo->count && !listInfo->data)) 134 | return false; 135 | listData.resize(listInfo->count); 136 | for(int i = 0; i < listInfo->count; i++) 137 | listData[i] = ((Type*)listInfo->data)[i]; 138 | if(freedata && listInfo->data) 139 | BridgeFree(listInfo->data); 140 | return true; 141 | } 142 | 143 | private: 144 | ListInfo _listInfo; 145 | }; 146 | 147 | #endif //__cplusplus 148 | 149 | #endif //_LIST_H -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/capstone/capstone_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/capstone/capstone_x64.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/capstone/capstone_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/capstone/capstone_x86.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 < 1600 || 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 | #if defined(_MSC_VER) && _MSC_VER <= 1700 99 | // redefine functions from inttypes.h used in cstool 100 | #define strtoull _strtoui64 101 | #endif 102 | 103 | #define PRId64 __PRI_64_LENGTH_MODIFIER__ "d" 104 | #define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i" 105 | #define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o" 106 | #define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u" 107 | #define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x" 108 | #define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X" 109 | 110 | #else 111 | // this system has inttypes.h by default 112 | #include 113 | #endif // defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x64.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x64.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x86.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/dbghelp/dbghelp_x86.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2016 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 strtoll 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 | /* Maximum recursion depth for parsing JSON input. 64 | This limits the depth of e.g. array-within-array constructions. */ 65 | #define JSON_PARSER_MAX_DEPTH 2048 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x64.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x64.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x64dbg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "jansson.h" 4 | 5 | typedef json_t* JSON; 6 | 7 | static JSON_INLINE 8 | json_t* json_hex(unsigned json_int_t value) 9 | { 10 | char hexvalue[20]; 11 | sprintf_s(hexvalue, "0x%llX", value); 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 = 0; 19 | const char* hexvalue; 20 | hexvalue = json_string_value(hex); 21 | if(!hexvalue) 22 | return 0; 23 | sscanf_s(hexvalue, "0x%llX", &ret); 24 | return ret; 25 | } 26 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x86.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/jansson/jansson_x86.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x64.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x64.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x86.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x86.a -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/lz4/lz4_x86.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/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 | -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/x32bridge.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/x32bridge.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/x32dbg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/x32dbg.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/x64bridge.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/x64bridge.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/pluginsdk/x64dbg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrexodia/REToolSync/74b27a24108231a86e522fd14133565eb86958d9/plugins/x64dbg/REToolSync/pluginsdk/x64dbg.lib -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/sha1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | sha1.cpp - source code of 3 | ============ 4 | SHA-1 in C++ 5 | ============ 6 | 100% Public Domain. 7 | Original C Code 8 | -- Steve Reid 9 | Small changes to fit into bglibs 10 | -- Bruce Guenter 11 | Translation to simpler C++ Code 12 | -- Volker Diels-Grabsch 13 | Safety fixes 14 | -- Eugene Hopkinson 15 | */ 16 | 17 | #include "sha1.hpp" 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | static const size_t BLOCK_INTS = 16; /* number of 32bit integers per SHA1 block */ 24 | static const size_t BLOCK_BYTES = BLOCK_INTS * 4; 25 | 26 | 27 | static void reset(uint32_t digest[], std::string &buffer, uint64_t &transforms) 28 | { 29 | /* SHA1 initialization constants */ 30 | digest[0] = 0x67452301; 31 | digest[1] = 0xefcdab89; 32 | digest[2] = 0x98badcfe; 33 | digest[3] = 0x10325476; 34 | digest[4] = 0xc3d2e1f0; 35 | 36 | /* Reset counters */ 37 | buffer = ""; 38 | transforms = 0; 39 | } 40 | 41 | 42 | static uint32_t rol(const uint32_t value, const size_t bits) 43 | { 44 | return (value << bits) | (value >> (32 - bits)); 45 | } 46 | 47 | 48 | static uint32_t blk(const uint32_t block[BLOCK_INTS], const size_t i) 49 | { 50 | return rol(block[(i + 13) & 15] ^ block[(i + 8) & 15] ^ block[(i + 2) & 15] ^ block[i], 1); 51 | } 52 | 53 | 54 | /* 55 | * (R0+R1), R2, R3, R4 are the different operations used in SHA1 56 | */ 57 | 58 | static void R0(const uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) 59 | { 60 | z += ((w&(x^y)) ^ y) + block[i] + 0x5a827999 + rol(v, 5); 61 | w = rol(w, 30); 62 | } 63 | 64 | 65 | static void R1(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) 66 | { 67 | block[i] = blk(block, i); 68 | z += ((w&(x^y)) ^ y) + block[i] + 0x5a827999 + rol(v, 5); 69 | w = rol(w, 30); 70 | } 71 | 72 | 73 | static void R2(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) 74 | { 75 | block[i] = blk(block, i); 76 | z += (w^x^y) + block[i] + 0x6ed9eba1 + rol(v, 5); 77 | w = rol(w, 30); 78 | } 79 | 80 | 81 | static void R3(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) 82 | { 83 | block[i] = blk(block, i); 84 | z += (((w | x)&y) | (w&x)) + block[i] + 0x8f1bbcdc + rol(v, 5); 85 | w = rol(w, 30); 86 | } 87 | 88 | 89 | static void R4(uint32_t block[BLOCK_INTS], const uint32_t v, uint32_t &w, const uint32_t x, const uint32_t y, uint32_t &z, const size_t i) 90 | { 91 | block[i] = blk(block, i); 92 | z += (w^x^y) + block[i] + 0xca62c1d6 + rol(v, 5); 93 | w = rol(w, 30); 94 | } 95 | 96 | 97 | /* 98 | * Hash a single 512-bit block. This is the core of the algorithm. 99 | */ 100 | 101 | static void transform(uint32_t digest[], uint32_t block[BLOCK_INTS], uint64_t &transforms) 102 | { 103 | /* Copy digest[] to working vars */ 104 | uint32_t a = digest[0]; 105 | uint32_t b = digest[1]; 106 | uint32_t c = digest[2]; 107 | uint32_t d = digest[3]; 108 | uint32_t e = digest[4]; 109 | 110 | /* 4 rounds of 20 operations each. Loop unrolled. */ 111 | R0(block, a, b, c, d, e, 0); 112 | R0(block, e, a, b, c, d, 1); 113 | R0(block, d, e, a, b, c, 2); 114 | R0(block, c, d, e, a, b, 3); 115 | R0(block, b, c, d, e, a, 4); 116 | R0(block, a, b, c, d, e, 5); 117 | R0(block, e, a, b, c, d, 6); 118 | R0(block, d, e, a, b, c, 7); 119 | R0(block, c, d, e, a, b, 8); 120 | R0(block, b, c, d, e, a, 9); 121 | R0(block, a, b, c, d, e, 10); 122 | R0(block, e, a, b, c, d, 11); 123 | R0(block, d, e, a, b, c, 12); 124 | R0(block, c, d, e, a, b, 13); 125 | R0(block, b, c, d, e, a, 14); 126 | R0(block, a, b, c, d, e, 15); 127 | R1(block, e, a, b, c, d, 0); 128 | R1(block, d, e, a, b, c, 1); 129 | R1(block, c, d, e, a, b, 2); 130 | R1(block, b, c, d, e, a, 3); 131 | R2(block, a, b, c, d, e, 4); 132 | R2(block, e, a, b, c, d, 5); 133 | R2(block, d, e, a, b, c, 6); 134 | R2(block, c, d, e, a, b, 7); 135 | R2(block, b, c, d, e, a, 8); 136 | R2(block, a, b, c, d, e, 9); 137 | R2(block, e, a, b, c, d, 10); 138 | R2(block, d, e, a, b, c, 11); 139 | R2(block, c, d, e, a, b, 12); 140 | R2(block, b, c, d, e, a, 13); 141 | R2(block, a, b, c, d, e, 14); 142 | R2(block, e, a, b, c, d, 15); 143 | R2(block, d, e, a, b, c, 0); 144 | R2(block, c, d, e, a, b, 1); 145 | R2(block, b, c, d, e, a, 2); 146 | R2(block, a, b, c, d, e, 3); 147 | R2(block, e, a, b, c, d, 4); 148 | R2(block, d, e, a, b, c, 5); 149 | R2(block, c, d, e, a, b, 6); 150 | R2(block, b, c, d, e, a, 7); 151 | R3(block, a, b, c, d, e, 8); 152 | R3(block, e, a, b, c, d, 9); 153 | R3(block, d, e, a, b, c, 10); 154 | R3(block, c, d, e, a, b, 11); 155 | R3(block, b, c, d, e, a, 12); 156 | R3(block, a, b, c, d, e, 13); 157 | R3(block, e, a, b, c, d, 14); 158 | R3(block, d, e, a, b, c, 15); 159 | R3(block, c, d, e, a, b, 0); 160 | R3(block, b, c, d, e, a, 1); 161 | R3(block, a, b, c, d, e, 2); 162 | R3(block, e, a, b, c, d, 3); 163 | R3(block, d, e, a, b, c, 4); 164 | R3(block, c, d, e, a, b, 5); 165 | R3(block, b, c, d, e, a, 6); 166 | R3(block, a, b, c, d, e, 7); 167 | R3(block, e, a, b, c, d, 8); 168 | R3(block, d, e, a, b, c, 9); 169 | R3(block, c, d, e, a, b, 10); 170 | R3(block, b, c, d, e, a, 11); 171 | R4(block, a, b, c, d, e, 12); 172 | R4(block, e, a, b, c, d, 13); 173 | R4(block, d, e, a, b, c, 14); 174 | R4(block, c, d, e, a, b, 15); 175 | R4(block, b, c, d, e, a, 0); 176 | R4(block, a, b, c, d, e, 1); 177 | R4(block, e, a, b, c, d, 2); 178 | R4(block, d, e, a, b, c, 3); 179 | R4(block, c, d, e, a, b, 4); 180 | R4(block, b, c, d, e, a, 5); 181 | R4(block, a, b, c, d, e, 6); 182 | R4(block, e, a, b, c, d, 7); 183 | R4(block, d, e, a, b, c, 8); 184 | R4(block, c, d, e, a, b, 9); 185 | R4(block, b, c, d, e, a, 10); 186 | R4(block, a, b, c, d, e, 11); 187 | R4(block, e, a, b, c, d, 12); 188 | R4(block, d, e, a, b, c, 13); 189 | R4(block, c, d, e, a, b, 14); 190 | R4(block, b, c, d, e, a, 15); 191 | 192 | /* Add the working vars back into digest[] */ 193 | digest[0] += a; 194 | digest[1] += b; 195 | digest[2] += c; 196 | digest[3] += d; 197 | digest[4] += e; 198 | 199 | /* Count the number of transformations */ 200 | transforms++; 201 | } 202 | 203 | 204 | static void buffer_to_block(const std::string &buffer, uint32_t block[BLOCK_INTS]) 205 | { 206 | /* Convert the std::string (byte buffer) to a uint32_t array (MSB) */ 207 | for(size_t i = 0; i < BLOCK_INTS; i++) 208 | { 209 | block[i] = (buffer[4 * i + 3] & 0xff) 210 | | (buffer[4 * i + 2] & 0xff) << 8 211 | | (buffer[4 * i + 1] & 0xff) << 16 212 | | (buffer[4 * i + 0] & 0xff) << 24; 213 | } 214 | } 215 | 216 | 217 | SHA1::SHA1() 218 | { 219 | reset(digest, buffer, transforms); 220 | } 221 | 222 | 223 | void SHA1::update(const std::string &s) 224 | { 225 | std::istringstream is(s); 226 | update(is); 227 | } 228 | 229 | 230 | void SHA1::update(std::istream &is) 231 | { 232 | while(true) 233 | { 234 | char sbuf[BLOCK_BYTES]; 235 | is.read(sbuf, BLOCK_BYTES - buffer.size()); 236 | buffer.append(sbuf, (std::size_t)is.gcount()); 237 | if(buffer.size() != BLOCK_BYTES) 238 | { 239 | return; 240 | } 241 | uint32_t block[BLOCK_INTS]; 242 | buffer_to_block(buffer, block); 243 | transform(digest, block, transforms); 244 | buffer.clear(); 245 | } 246 | } 247 | 248 | 249 | /* 250 | * Add padding and return the message digest. 251 | */ 252 | 253 | std::string SHA1::final() 254 | { 255 | /* Total number of hashed bits */ 256 | uint64_t total_bits = (transforms*BLOCK_BYTES + buffer.size()) * 8; 257 | 258 | /* Padding */ 259 | buffer += (char)0x80; 260 | size_t orig_size = buffer.size(); 261 | while(buffer.size() < BLOCK_BYTES) 262 | { 263 | buffer += (char)0x00; 264 | } 265 | 266 | uint32_t block[BLOCK_INTS]; 267 | buffer_to_block(buffer, block); 268 | 269 | if(orig_size > BLOCK_BYTES - 8) 270 | { 271 | transform(digest, block, transforms); 272 | for(size_t i = 0; i < BLOCK_INTS - 2; i++) 273 | { 274 | block[i] = 0; 275 | } 276 | } 277 | 278 | /* Append total_bits, split this uint64_t into two uint32_t */ 279 | block[BLOCK_INTS - 1] = (uint32_t)total_bits; 280 | block[BLOCK_INTS - 2] = (uint32_t)(total_bits >> 32); 281 | transform(digest, block, transforms); 282 | 283 | /* Hex std::string */ 284 | std::ostringstream result; 285 | for(size_t i = 0; i < sizeof(digest) / sizeof(digest[0]); i++) 286 | { 287 | result << std::hex << std::setfill('0') << std::setw(8); 288 | result << digest[i]; 289 | } 290 | 291 | /* Reset for next run */ 292 | reset(digest, buffer, transforms); 293 | 294 | return result.str(); 295 | } 296 | 297 | 298 | std::string SHA1::from_file(const wchar_t* filename) 299 | { 300 | std::ifstream stream(filename, std::ios::binary); 301 | SHA1 checksum; 302 | checksum.update(stream); 303 | return checksum.final(); 304 | } -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/sha1.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | sha1.hpp - header of 3 | ============ 4 | SHA-1 in C++ 5 | ============ 6 | 100% Public Domain. 7 | Original C Code 8 | -- Steve Reid 9 | Small changes to fit into bglibs 10 | -- Bruce Guenter 11 | Translation to simpler C++ Code 12 | -- Volker Diels-Grabsch 13 | Safety fixes 14 | -- Eugene Hopkinson 15 | */ 16 | 17 | #ifndef SHA1_HPP 18 | #define SHA1_HPP 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | class SHA1 26 | { 27 | public: 28 | SHA1(); 29 | void update(const std::string &s); 30 | void update(std::istream &is); 31 | std::string final(); 32 | static std::string from_file(const wchar_t* filename); 33 | 34 | private: 35 | uint32_t digest[5]; 36 | std::string buffer; 37 | uint64_t transforms; 38 | }; 39 | 40 | 41 | #endif /* SHA1_HPP */ -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/stringutils.cpp: -------------------------------------------------------------------------------- 1 | #include "stringutils.h" 2 | #include 3 | #include 4 | #include 5 | 6 | // Functions from x64dbg project: https://github.com/x64dbg/x64dbg 7 | //Conversion functions taken from: http://www.nubaria.com/en/blog/?p=289 8 | String Utf16ToUtf8(const WString & wstr) 9 | { 10 | String convertedString; 11 | int requiredSize = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0); 12 | if(requiredSize > 0) 13 | { 14 | std::vector buffer(requiredSize); 15 | WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], requiredSize, 0, 0); 16 | convertedString.assign(buffer.begin(), buffer.end() - 1); 17 | } 18 | return convertedString; 19 | } 20 | 21 | String Utf16ToUtf8(const wchar_t* wstr) 22 | { 23 | return Utf16ToUtf8(wstr ? WString(wstr) : WString()); 24 | } 25 | 26 | WString Utf8ToUtf16(const String & str) 27 | { 28 | WString convertedString; 29 | int requiredSize = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0); 30 | if(requiredSize > 0) 31 | { 32 | std::vector buffer(requiredSize); 33 | MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &buffer[0], requiredSize); 34 | convertedString.assign(buffer.begin(), buffer.end() - 1); 35 | } 36 | return convertedString; 37 | } 38 | 39 | WString Utf8ToUtf16(const char* str) 40 | { 41 | return Utf8ToUtf16(str ? String(str) : String()); 42 | } -------------------------------------------------------------------------------- /plugins/x64dbg/REToolSync/stringutils.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRINGUTILS_H 2 | #define _STRINGUTILS_H 3 | 4 | #include 5 | #include 6 | 7 | typedef std::string String; 8 | typedef std::wstring WString; 9 | 10 | 11 | String Utf16ToUtf8(const WString & wstr); 12 | String Utf16ToUtf8(const wchar_t* wstr); 13 | WString Utf8ToUtf16(const String & str); 14 | WString Utf8ToUtf16(const char* str); 15 | 16 | #endif //_STRINGUTILS_H -------------------------------------------------------------------------------- /server/REToolSync.py: -------------------------------------------------------------------------------- 1 | # Reference: https://www.georgeho.org/tornado-websockets/ 2 | import json 3 | import traceback 4 | import urllib.parse 5 | import uuid 6 | from typing import Any, Awaitable, Optional, Set, Union, Dict, List 7 | 8 | import tornado.ioloop 9 | import tornado.web 10 | import tornado.websocket 11 | import tornado.web 12 | import tornado.httputil 13 | import tornado.escape 14 | import tornado.httpclient 15 | 16 | def encode_url_params(endpoint: str, path: str, params: Dict[str, str]): 17 | url = endpoint 18 | if not url.endswith("/"): 19 | url += "/" 20 | url += path 21 | for i, (key, value) in enumerate(params.items()): 22 | if i == 0: 23 | url += "?" 24 | else: 25 | url += "&" 26 | url += f"{urllib.parse.quote(key)}={urllib.parse.quote(value)}" 27 | return url 28 | 29 | # TODO: properly define client features 30 | 31 | class AbstractClient: 32 | client_id: int 33 | 34 | async def client_send(self, request: str, params: Dict[str, str], data: Any): 35 | raise NotImplementedError() 36 | 37 | @property 38 | def client_info(self) -> dict: 39 | raise NotImplementedError() 40 | 41 | def client_removed(self): 42 | pass 43 | 44 | def client_features(self): 45 | return [] 46 | 47 | def __str__(self) -> str: 48 | return f"{self.__class__.__name__}(id: {self.client_id})" 49 | 50 | class Server: 51 | # These are (global) class variables 52 | __unique_id = 1 53 | __clients: Dict[int, AbstractClient] = dict() 54 | 55 | @staticmethod 56 | def get_clients() -> List[AbstractClient]: 57 | return list(Server.__clients.values()) 58 | 59 | @staticmethod 60 | def add_client(client: AbstractClient) -> None: 61 | client.client_id = Server.__unique_id 62 | Server.__unique_id += 1 63 | Server.__clients[client.client_id] = client 64 | print(f"Added {client}") 65 | 66 | @staticmethod 67 | def remove_client(client: AbstractClient) -> None: 68 | if client.client_id not in Server.__clients: 69 | raise IndexError(f"No such client: {client}") 70 | client.client_removed() 71 | print(f"Removed {client}") 72 | del Server.__clients[client.client_id] 73 | 74 | @staticmethod 75 | async def send_request(request: str, params: Dict[str, str], data: Any = None): 76 | # TODO: await? 77 | for client in Server.__clients.values(): 78 | await client.client_send(request, params, data) 79 | 80 | class WebSocketClient(tornado.websocket.WebSocketHandler, AbstractClient): 81 | def __init__(self, application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any) -> None: 82 | super().__init__(application, request, **kwargs) 83 | self.info = {} 84 | 85 | @property 86 | def client_info(self) -> dict: 87 | return self.info 88 | 89 | async def client_send(self, request: str, params: Dict[str, str], data: Any): 90 | # TODO: well-defined packet structure 91 | await self.write_message({ 92 | **params, 93 | "request": request, 94 | "data": data, 95 | }) 96 | 97 | def open(self): 98 | Server.add_client(self) 99 | user_agent = dict(self.request.headers.get_all()).get("User-Agent", "Unknown") 100 | 101 | # Add some information 102 | self.info.update({ 103 | "ip": self.request.remote_ip, 104 | "agent": user_agent 105 | }) 106 | print(f"open ({self.info})") 107 | 108 | # on_close is only called when the client hangs up(?) https://stackoverflow.com/a/21122752/1806760 109 | def on_connection_close(self) -> None: 110 | print(f"connection_close {self.client_id}") 111 | Server.remove_client(self) 112 | return super().on_connection_close() 113 | 114 | def on_message(self, message) -> Optional[Awaitable[None]]: 115 | try: 116 | print(f"message {self.client_id}: {message}") 117 | self.info.update(json.loads(message)) 118 | except: 119 | traceback.print_exc() 120 | super().on_finish() 121 | 122 | def on_ping(self, data: bytes) -> None: 123 | #print(f"ping {self.id}") 124 | return 125 | 126 | # https://www.tornadoweb.org/en/stable/websocket.html#configuration 127 | def check_origin(self, origin: str) -> bool: 128 | return True 129 | 130 | # Relevant reading: 131 | # - https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS 132 | # - https://developer.chrome.com/blog/private-network-access-preflight/ 133 | # - https://wicg.github.io/private-network-access 134 | # - https://stackoverflow.com/a/66555660 135 | class CorsHandler(tornado.web.RequestHandler): 136 | def set_default_headers(self): 137 | self.set_header("Access-Control-Allow-Origin", "*") 138 | 139 | def options(self, *args): 140 | self.set_header("Access-Control-Allow-Methods", "*") 141 | self.set_header("Access-Control-Request-Credentials", "true") 142 | self.set_header("Access-Control-Allow-Private-Network", "true") 143 | self.set_header("Access-Control-Allow-Headers", "*") 144 | self.set_status(204) # No Content 145 | 146 | class HTTPClient(AbstractClient): 147 | def __str__(self) -> str: 148 | return f"HTTPClient(id: {self.client_id}, endpoint: {self.endpoint})" 149 | 150 | def __init__(self, ping_interval: int, endpoint: str) -> None: 151 | self.endpoint = endpoint 152 | if self.endpoint.endswith("/"): 153 | self.endpoint = self.endpoint[:-1] 154 | self.periodic = tornado.ioloop.PeriodicCallback(self.ping_callback, ping_interval * 1000.0) 155 | self.info = { 156 | "endpoint": self.endpoint, 157 | } 158 | self.http = tornado.httpclient.AsyncHTTPClient() 159 | self.ping_failures = 0 160 | self.max_failures = 3 161 | 162 | async def ping(self): 163 | try: 164 | request = tornado.httpclient.HTTPRequest(self.endpoint + "/ping", "GET") 165 | response = await self.http.fetch(request) 166 | #print(f"Client {self.client_id} /ping -> {response.body}") 167 | return 200 >= response.code <= 299 168 | except Exception as e: 169 | print(f"Client {self.client_id} /ping error -> {e}") 170 | return False 171 | 172 | async def ping_callback(self): 173 | ping_ok = await self.ping() 174 | if not ping_ok: 175 | self.ping_failures += 1 176 | if self.ping_failures >= self.max_failures: 177 | Server.remove_client(self) 178 | else: 179 | self.ping_failures = 0 180 | 181 | async def client_send(self, request: str, params: Dict[str, str], data: Any): 182 | # TODO: check if this client supports the request 183 | url = encode_url_params(self.endpoint, request, params) 184 | if data is None: 185 | data = b"" 186 | try: 187 | # TODO: support custom headers 188 | request = tornado.httpclient.HTTPRequest(url, "POST", body=data) 189 | response = await self.http.fetch(request, False) 190 | print(f"Client {self.client_id} {url} -> HTTP {response.code}: {response.body}") 191 | except Exception as e: 192 | print(f"Client {self.client_id} {url} error -> {e}") 193 | 194 | @property 195 | def client_info(self) -> dict: 196 | return self.info 197 | 198 | def client_removed(self): 199 | if self.periodic.is_running(): 200 | self.periodic.stop() 201 | 202 | class ClientsHandler(CorsHandler): 203 | __tokens: Dict[str, HTTPClient] = dict() 204 | 205 | def set_default_headers(self): 206 | self.set_header("Content-Type", "application/json") 207 | 208 | def get(self): 209 | token = self.get_query_argument("token", None) 210 | if token is None: 211 | clients = [client.client_info for client in Server.get_clients()] 212 | self.write(json.dumps(clients)) 213 | else: 214 | client = ClientsHandler.__tokens.get(token, None) 215 | if client is None: 216 | return self.set_status(404) 217 | self.write(json.dumps(client.client_info)) 218 | 219 | async def post(self): 220 | data = tornado.escape.json_decode(self.request.body) 221 | if "endpoint" not in data: 222 | self.write("Missing 'endpoint' key in body") 223 | return self.set_status(400) 224 | 225 | ping_interval = 1 226 | 227 | endpoint = data["endpoint"] 228 | client = HTTPClient(ping_interval, endpoint) 229 | Server.add_client(client) 230 | ping_ok = await client.ping() 231 | if not ping_ok: 232 | Server.remove_client(client) 233 | self.write(f"No pong from {client.endpoint}/ping") 234 | return self.set_status(400) 235 | else: 236 | client.periodic.start() 237 | token = str(uuid.uuid4()) 238 | ClientsHandler.__tokens[token] = client 239 | self.write(json.dumps({ 240 | "token": token, 241 | })) 242 | 243 | def delete(self): 244 | token = self.get_query_argument("token") 245 | client = ClientsHandler.__tokens.get(token, None) 246 | if client is None: 247 | self.write(f"Invalid token: {token}") 248 | return self.set_status(400) 249 | del ClientsHandler.__tokens[token] 250 | Server.remove_client(client) 251 | 252 | class PingHandler(CorsHandler): 253 | def get(self): 254 | self.write(b"pong") 255 | 256 | class GotoHandler(CorsHandler): 257 | async def post(self): 258 | address = self.get_query_argument("address") 259 | print(f"goto:{address}") 260 | await Server.send_request("goto", { 261 | "address": address, 262 | }) 263 | self.write(f"Notified {len(Server.get_clients())} clients") 264 | 265 | def main(): 266 | # TODO: configuration 267 | ip, port = "0.0.0.0", 6969 268 | 269 | app = tornado.web.Application( 270 | [ 271 | (r"/REToolSync", WebSocketClient), 272 | (r"/api/ping", PingHandler), 273 | (r"/api/clients", ClientsHandler), 274 | (r"/api/goto", GotoHandler) 275 | ], 276 | websocket_ping_interval=10, 277 | websocket_ping_timeout=30, 278 | ) 279 | app.listen(port=port, address=ip) 280 | print(f"Listening on {ip}:{port}") 281 | 282 | # Create an event loop (what Tornado calls an IOLoop). 283 | io_loop = tornado.ioloop.IOLoop.current() 284 | 285 | # Start the event loop. 286 | io_loop.start() 287 | 288 | 289 | if __name__ == "__main__": 290 | main() -------------------------------------------------------------------------------- /server/requirements.txt: -------------------------------------------------------------------------------- 1 | tornado 2 | type-serialize --------------------------------------------------------------------------------