├── .gitignore ├── README.md ├── main.py ├── rzctl.py └── rzctl_nt.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Updates 2 | - @29.04.2024 3 | - No need to use .dll 4 | - Tested on Python 3.12.3 5 | 6 | ### Requirements 7 | - [Razer Synapse](https://www.razer.com/synapse-3) (Must have the macro addon installed.) 8 | 9 | ### Credits 10 | - [rzctl - Use razer synapse for the lulz](https://www.unknowncheats.me/forum/anti-cheat-bypass/450102-rzctl-razer-synapse-lulz.html) 11 | - [Sadmeme/rzctl](https://github.com/Sadmeme/rzctl) 12 | - [thefat32/rzctl](https://github.com/thefat32/rzctl) 13 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import time 2 | from rzctl import RZCONTROL, MOUSE_CLICK, KEYBOARD_INPUT_TYPE 3 | 4 | 5 | def main(): 6 | 7 | rzctl = RZCONTROL() 8 | 9 | if not rzctl.init(): 10 | print("Failed to initialize rzctl") 11 | 12 | while True: 13 | try: 14 | rzctl.mouse_move(100, 200, True) 15 | time.sleep(1) 16 | print("Left click") 17 | rzctl.mouse_click(MOUSE_CLICK.LEFT_DOWN) 18 | time.sleep(1 / 1000) 19 | rzctl.mouse_click(MOUSE_CLICK.LEFT_UP) 20 | time.sleep(1) 21 | print("Scroll wheel up") 22 | rzctl.mouse_click(MOUSE_CLICK.SCROLL_UP) 23 | time.sleep(1) 24 | rzctl.keyboard_input(30, KEYBOARD_INPUT_TYPE.KEYBOARD_DOWN) 25 | rzctl.keyboard_input(30, KEYBOARD_INPUT_TYPE.KEYBOARD_UP) 26 | 27 | time.sleep( 28 | 1 / 1000 29 | ) # Sleep is needed to avoid razer service overflowing, which delays all your inputs 30 | 31 | except KeyboardInterrupt: 32 | break 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /rzctl.py: -------------------------------------------------------------------------------- 1 | from rzctl_nt import ( 2 | ntdll, 3 | kernel32, 4 | find_sym_link, 5 | INVALID_HANDLE_VALUE, 6 | FILE_SHARE_READ, 7 | FILE_SHARE_WRITE, 8 | OPEN_EXISTING, 9 | Structure, 10 | c_int32, 11 | c_ulong, 12 | pointer, 13 | sizeof, 14 | byref, 15 | BOOL, 16 | ) 17 | 18 | 19 | def enum(**enums): 20 | return type("Enum", (), enums) 21 | 22 | 23 | MOUSE_CLICK = enum( 24 | LEFT_DOWN=1, 25 | LEFT_UP=2, 26 | RIGHT_DOWN=4, 27 | RIGHT_UP=8, 28 | SCROLL_CLICK_DOWN=16, 29 | SCROLL_CLICK_UP=32, 30 | BACK_DOWN=64, 31 | BACK_UP=128, 32 | FOWARD_DOWN=256, 33 | FOWARD_UP=512, 34 | SCROLL_DOWN=4287104000, 35 | SCROLL_UP=7865344, 36 | ) 37 | 38 | KEYBOARD_INPUT_TYPE = enum(KEYBOARD_DOWN=0, KEYBOARD_UP=1) 39 | 40 | 41 | class RZCONTROL_IOCTL_STRUCT(Structure): 42 | _fields_ = [ 43 | ("unk0", c_int32), 44 | ("unk1", c_int32), 45 | ("max_val_or_scan_code", c_int32), 46 | ("click_mask", c_int32), 47 | ("unk3", c_int32), 48 | ("x", c_int32), 49 | ("y", c_int32), 50 | ("unk4", c_int32), 51 | ] 52 | 53 | 54 | IOCTL_MOUSE = 0x88883020 55 | MAX_VAL = 65536 56 | RZCONTROL_MOUSE = 2 57 | RZCONTROL_KEYBOARD = 1 58 | 59 | 60 | class RZCONTROL: 61 | 62 | hDevice = INVALID_HANDLE_VALUE 63 | 64 | def __init__(self): 65 | pass 66 | 67 | def init(self): 68 | if RZCONTROL.hDevice != INVALID_HANDLE_VALUE: 69 | kernel32.CloseHandle(hDevice) 70 | found, name = find_sym_link("\\GLOBAL??", "RZCONTROL") 71 | if not found: 72 | return False 73 | sym_link = "\\\\?\\" + name 74 | RZCONTROL.hDevice = kernel32.CreateFileW( 75 | sym_link, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0 76 | ) 77 | return RZCONTROL.hDevice != INVALID_HANDLE_VALUE 78 | 79 | def impl_mouse_ioctl(self, ioctl): 80 | if ioctl: 81 | p_ioctl = pointer(ioctl) 82 | junk = c_ulong() 83 | bResult = kernel32.DeviceIoControl( 84 | RZCONTROL.hDevice, 85 | IOCTL_MOUSE, 86 | p_ioctl, 87 | sizeof(RZCONTROL_IOCTL_STRUCT), 88 | 0, 89 | 0, 90 | byref(junk), 91 | 0, 92 | ) 93 | if not bResult: 94 | self.init() 95 | 96 | def mouse_move(self, x, y, from_start_point): 97 | """if going from point, x and y will be the offset from current mouse position 98 | otherwise it will be a number in range of 1 to 65536, where 1, 1 is top left of screen 99 | if using multiple monitors the input values remain the same, but outcome different, i just don't recommend bothering with this bs 100 | note: x and/or y can not be 0 unless going from start point 101 | 102 | Args: 103 | x (int) 104 | y (int) 105 | from_start_point (bool) 106 | """ 107 | max_val = 0 108 | if not from_start_point: 109 | max_val = MAX_VAL 110 | if x < 1: 111 | x = 1 112 | if x > max_val: 113 | x = max_val 114 | if y < 1: 115 | y = 1 116 | if y > max_val: 117 | y = max_val 118 | mm = RZCONTROL_IOCTL_STRUCT(0, RZCONTROL_MOUSE, max_val, 0, 0, x, y, 0) 119 | self.impl_mouse_ioctl(mm) 120 | 121 | def mouse_click(self, click_mask): 122 | """ 123 | Args: 124 | click_mask (MOUSE_CLICK): 125 | """ 126 | mm = RZCONTROL_IOCTL_STRUCT( 127 | 0, 128 | RZCONTROL_MOUSE, 129 | 0, 130 | click_mask, 131 | 0, 132 | 0, 133 | 0, 134 | 0, 135 | ) 136 | self.impl_mouse_ioctl(mm) 137 | 138 | def keyboard_input(self, scan_code, up_down): 139 | """ 140 | Args: 141 | scan_code (short): https://www.millisecond.com/support/docs/current/html/language/scancodes.htm 142 | up_down (KEYBOARD_INPUT_TYPE): _description_ 143 | """ 144 | mm = RZCONTROL_IOCTL_STRUCT( 145 | 0, 146 | RZCONTROL_KEYBOARD, 147 | (int(scan_code) << 16), 148 | up_down, 149 | 0, 150 | 0, 151 | 0, 152 | 0, 153 | ) 154 | self.impl_mouse_ioctl(mm) 155 | -------------------------------------------------------------------------------- /rzctl_nt.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import ctypes 3 | from ctypes import * 4 | from ctypes.wintypes import * 5 | 6 | ntdll = windll.ntdll 7 | kernel32 = windll.kernel32 8 | 9 | NTSTATUS = c_long 10 | STATUS_SUCCESS = NTSTATUS(0x00000000).value 11 | STATUS_UNSUCCESSFUL = NTSTATUS(0xC0000001).value 12 | STATUS_BUFFER_TOO_SMALL = NTSTATUS(0xC0000023).value 13 | PVOID = c_void_p 14 | PWSTR = c_wchar_p 15 | DIRECTORY_QUERY = 0x0001 16 | OBJ_CASE_INSENSITIVE = 0x00000040 17 | INVALID_HANDLE_VALUE = -1 18 | FILE_SHARE_READ = 0x00000001 19 | FILE_SHARE_WRITE = 0x00000002 20 | OPEN_EXISTING = 3 21 | 22 | 23 | class UNICODE_STRING(Structure): 24 | _fields_ = [("Length", USHORT), ("MaximumLength", USHORT), ("Buffer", PWSTR)] 25 | 26 | 27 | class OBJECT_ATTRIBUTES(Structure): 28 | _fields_ = [ 29 | ("Length", ULONG), 30 | ("RootDirectory", HANDLE), 31 | ("ObjectName", POINTER(UNICODE_STRING)), 32 | ("Attributes", ULONG), 33 | ("SecurityDescriptor", PVOID), 34 | ("SecurityQualityOfService", PVOID), 35 | ] 36 | 37 | 38 | class OBJECT_DIRECTORY_INFORMATION(Structure): 39 | _fields_ = [("Name", UNICODE_STRING), ("TypeName", UNICODE_STRING)] 40 | 41 | 42 | def InitializeObjectAttributes( 43 | InitializedAttributes, ObjectName, Attributes, RootDirectory, SecurityDescriptor 44 | ): 45 | memset(addressof(InitializedAttributes), 0, sizeof(InitializedAttributes)) 46 | InitializedAttributes.Length = sizeof(InitializedAttributes) 47 | InitializedAttributes.ObjectName = ObjectName 48 | InitializedAttributes.Attributes = Attributes 49 | InitializedAttributes.RootDirectory = RootDirectory 50 | InitializedAttributes.SecurityDescriptor = SecurityDescriptor 51 | InitializedAttributes.SecurityQualityOfService = None 52 | 53 | 54 | def RtlInitUnicodeString(DestinationString, Src): 55 | memset(addressof(DestinationString), 0, sizeof(DestinationString)) 56 | DestinationString.Buffer = cast(Src, PWSTR) 57 | DestinationString.Length = sizeof(Src) - 2 58 | DestinationString.MaximumLength = DestinationString.Length 59 | return STATUS_SUCCESS 60 | 61 | 62 | def open_directory(root_handle, dir, desired_access): 63 | status = STATUS_UNSUCCESSFUL 64 | dir_handle = c_void_p() 65 | us_dir = UNICODE_STRING() 66 | p_us_dir = None 67 | if dir: 68 | w_dir = create_unicode_buffer(dir) 69 | us_dir = UNICODE_STRING() 70 | status = RtlInitUnicodeString(us_dir, w_dir) 71 | p_us_dir = pointer(us_dir) 72 | if status != STATUS_SUCCESS: 73 | print("RtlInitUnicodeString failed.") 74 | sys.exit(0) 75 | obj_attr = OBJECT_ATTRIBUTES() 76 | InitializeObjectAttributes( 77 | obj_attr, p_us_dir, OBJ_CASE_INSENSITIVE, root_handle, None 78 | ) 79 | status = ntdll.NtOpenDirectoryObject( 80 | byref(dir_handle), desired_access, byref(obj_attr) 81 | ) 82 | if status != STATUS_SUCCESS: 83 | print("NtOpenDirectoryObject failed.") 84 | sys.exit(0) 85 | return dir_handle 86 | 87 | 88 | def find_sym_link(dir, name): 89 | dir_handle = open_directory(None, "\\GLOBAL??", DIRECTORY_QUERY) 90 | if not dir_handle: 91 | sys.exit(0) 92 | status = STATUS_UNSUCCESSFUL 93 | query_context = ULONG(0) 94 | length = ULONG() 95 | objinf = OBJECT_DIRECTORY_INFORMATION() 96 | found = False 97 | out = None 98 | while True: 99 | status = ntdll.NtQueryDirectoryObject( 100 | dir_handle, 0, 0, True, False, byref(query_context), byref(length) 101 | ) 102 | if status != STATUS_BUFFER_TOO_SMALL: 103 | print("NtQueryDirectoryObject failed.") 104 | sys.exit(0) 105 | p_objinf = pointer(objinf) 106 | status = ntdll.NtQueryDirectoryObject( 107 | dir_handle, 108 | p_objinf, 109 | length, 110 | True, 111 | False, 112 | byref(query_context), 113 | byref(length), 114 | ) 115 | if status != STATUS_SUCCESS: 116 | print("NtQueryDirectoryObject failed.") 117 | sys.exit(0) 118 | _name = objinf.Name.Buffer 119 | if name in _name: 120 | found = True 121 | out = _name 122 | break 123 | ntdll.NtClose(dir_handle) 124 | return found, out 125 | --------------------------------------------------------------------------------