├── .github └── ISSUE_TEMPLATE │ ├── bug-report.md │ └── issue--task-template.md ├── LICENSE ├── README.md ├── apk └── gta_vc.apk ├── scripts ├── main.scm └── main.txt └── src ├── Android.mk ├── Application.mk ├── game ├── camera.cpp ├── camera.h ├── game.cpp ├── game.h ├── hooks.cpp ├── patches.cpp ├── patches.h ├── scripting.cpp └── scripting.h ├── main.cpp ├── main.h └── util ├── address.h ├── memory.cpp ├── memory.h ├── util.cpp └── util.h /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report a bug 4 | title: 'BUG: bug name' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | # Description 11 | 12 | # Device information 13 | **OS:** 14 | **Device name:** 15 | **Additional tools:** 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue--task-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 'Issue: Task template' 3 | about: Ready to work task issue. 4 | title: 'TASK-TAG: Task Title' 5 | labels: "\U0001F527 DEV-Task" 6 | assignees: '' 7 | 8 | --- 9 | 10 | # Description 11 | Full description of task 12 | 13 | # List of functionality requirements 14 | - [ ] Task No. 1 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024-present Evstegneev (fet1sov) Konstantin 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![image](https://github.com/fet1sov/VCMP-Android/assets/44091614/b18550ca-bf6b-4459-9485-9d593f571c7b) Vice City Multiplayer for Android OS 2 | ![alt-текст](https://i.imgur.com/lQEzDrK.png "Yes now it`s open-source") 3 | #### The open source multiplayer modification of GTA:VC on Android OS 4 | #### © fet1sov 5 | 6 | 7 | 8 | # How to build: 9 | 1. [Download a NDK](https://developer.android.com/ndk/downloads) 10 | 2. Unzip a NDK in folder 11 | 3. In NDK folder create folder "jni" 12 | 4. Download a sources from GitHub 13 | 5. Unzip sources in folder "jni" 14 | 6. Start the ndk-build.bat 15 | 7. After library was built go to: "libs/armeabi-v7a" 16 | 8. Insert the libVCMP.so in APK from sources (Its important cause original APK doenst work properly) 17 | 9. Install APK 18 | 10. Enjoy :) 19 | 20 | # ScreenShots 21 |

22 | 23 |

24 |

First day of Developing

25 | -------------------------------------------------------------------------------- /apk/gta_vc.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fet1sov/VCMP-Android/b342a5701c0f0603c818877d5699b385cfa1cfb9/apk/gta_vc.apk -------------------------------------------------------------------------------- /scripts/main.scm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fet1sov/VCMP-Android/b342a5701c0f0603c818877d5699b385cfa1cfb9/scripts/main.scm -------------------------------------------------------------------------------- /scripts/main.txt: -------------------------------------------------------------------------------- 1 | DEFINE OBJECTS 1 2 | DEFINE OBJECT SANNY BUILDER 3.2.2 3 | 4 | DEFINE MISSIONS 0 5 | 6 | //============== MAIN ================= 7 | 03A4: name_thread 'MAIN' 8 | fade 0 0 9 | 042C: set_total_missions_to 0 10 | 030D: set_total_mission_points_to 0 11 | 01F0: set_max_wanted_level_to 6 12 | 02ED: set_total_hidden_packages_to 0 13 | 0111: set_wasted_busted_check_to 0 14 | 00C0: set_current_time 12 0 15 | 01EB: set_traffic_density_multiplier_to 0.0 16 | 03DE: set_pedestrians_density_multiplier_to 0.0 17 | 04E4: unknown_refresh_game_renderer_at 468.7745 -1298.623 18 | 03CB: set_camera 468.7745 -1298.623 11.0712 19 | 0053: $PLAYER_CHAR = create_player #NULL at 468.7745 -1298.623 11.0712 20 | 01F5: $PLAYER_ACTOR = create_emulated_actor_from_player $PLAYER_CHAR 21 | 0180: set_on_mission_flag_to $ONMISSION 22 | fade 1 0 23 | wait 0 24 | if 25 | Player.Defined($PLAYER_CHAR) 26 | jf @MAIN_188 27 | set_weather 0 28 | 01B5: force_weather 0 29 | if 30 | not Actor.Dead($PLAYER_ACTOR) 31 | jf @MAIN_188 32 | 0352: set_actor $PLAYER_ACTOR skin_to 'PLAYER' 33 | 038B: load_requested_models 34 | if 35 | not Actor.Dead($PLAYER_ACTOR) 36 | jf @MAIN_188 37 | 0353: refresh_actor $PLAYER_ACTOR 38 | 39 | :MAIN_188 40 | wait 0 41 | select_interior 0 42 | Player.CanMove($PLAYER_CHAR) = False 43 | Camera.SetPosition(-1000.0, 191.5, 12.0, 0.0, 0.0, 0.0) 44 | Camera.PointAt(-1000.0, 185.5, 11.5, 2) 45 | 46 | :MAIN_203 47 | wait 1500 48 | jump @MAIN_203 49 | 50 | end_thread 51 | return 52 | //==================================== -------------------------------------------------------------------------------- /src/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := VCMP 6 | LOCAL_LDLIBS := -llog -lEGL -lGLESv2 7 | FILE_LIST := $(wildcard $(LOCAL_PATH)/*.cpp) 8 | FILE_LIST += $(wildcard $(LOCAL_PATH)/game/*.cpp) 9 | FILE_LIST += $(wildcard $(LOCAL_PATH)/util/*.cpp) 10 | 11 | LOCAL_SRC_FILES += $(FILE_LIST:$(LOCAL_PATH)/%=%) 12 | 13 | LOCAL_CPPFLAGS += -D_ARM_ -D_RAKNET_THREADSAFE 14 | LOCAL_CPPFLAGS += -w -pthread -fpack-struct=1 -Wall -fdiagnostics-color=auto -O2 -ffast-math -std=c++11 15 | include $(BUILD_SHARED_LIBRARY) 16 | -------------------------------------------------------------------------------- /src/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi-v7a arm64-v8a 2 | APP_PLATFORM := android-16 3 | APP_MODULES := VCMP 4 | APP_STL := c++_static -------------------------------------------------------------------------------- /src/game/camera.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "camera.h" 3 | 4 | void CCamera::SetBehindPlayer() 5 | { 6 | ScriptCommand(&set_camera_behind_player); 7 | } -------------------------------------------------------------------------------- /src/game/camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CCamera 4 | { 5 | public: 6 | CCamera() { } 7 | ~CCamera() {} 8 | 9 | void SetBehindPlayer(); 10 | }; -------------------------------------------------------------------------------- /src/game/game.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "game.h" 3 | 4 | void InitScripting(); 5 | void InstallHooks(); 6 | 7 | CGame::CGame() 8 | { 9 | m_pGameCamera = new CCamera(); 10 | } 11 | 12 | void CGame::InitGame() 13 | { 14 | LOGI("libGTAVC.so: Game has been inited!"); 15 | 16 | ApplyPatches(); 17 | InitScripting(); 18 | 19 | InstallHooks(); 20 | } -------------------------------------------------------------------------------- /src/game/game.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "camera.h" 4 | 5 | class CGame 6 | { 7 | public: 8 | CGame(); 9 | ~CGame() {}; 10 | 11 | void InitGame(); 12 | void StartGame(); 13 | private: 14 | CCamera* m_pGameCamera; 15 | }; -------------------------------------------------------------------------------- /src/game/hooks.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | 3 | void (*TouchEvent)(int, int, int posX, int posY); 4 | void TouchEvent_hook(int type, int num, int posX, int posY) 5 | { 6 | bool bRet; 7 | 8 | if(bRet) 9 | return TouchEvent(type, num, posX, posY); 10 | } 11 | 12 | void InstallHooks() 13 | { 14 | InstallHook(g_libGTAVC+HOOK_TOUCHEVENT, (uintptr_t)TouchEvent_hook, (uintptr_t*)&TouchEvent); 15 | } -------------------------------------------------------------------------------- /src/game/patches.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "patches.h" 3 | 4 | void ApplyPatches() 5 | { 6 | LOGI("libGTAVC.so: Patching the game..."); 7 | 8 | WriteMemory(g_libGTAVC+CLOCK_DATA, "VC:MP", 6); 9 | } -------------------------------------------------------------------------------- /src/game/patches.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ApplyPatches(); -------------------------------------------------------------------------------- /src/game/scripting.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "scripting.h" 3 | 4 | GAME_SCRIPT_THREAD *gst; 5 | uint8_t ScriptBuf[255]; 6 | uint32_t *pdwParamVars[18]; 7 | 8 | uint8_t ExecuteScriptBuf() 9 | { 10 | gst->dwScriptIP = (uintptr_t)ScriptBuf; 11 | 12 | #if defined(__aarch64__) 13 | (( void (*)(GAME_SCRIPT_THREAD*))(g_libGTAVC+0x19D1A4))(gst); 14 | #else 15 | (( void (*)(GAME_SCRIPT_THREAD*))(g_libGTAVC+0x144B14))(gst); 16 | #endif 17 | 18 | return gst->condResult; 19 | } 20 | 21 | int ScriptCommand(const SCRIPT_COMMAND *pScriptCommand, ...) 22 | { 23 | va_list ap; 24 | const char* p = pScriptCommand->Params; 25 | va_start(ap, pScriptCommand); 26 | memcpy(&ScriptBuf, &pScriptCommand->OpCode, 2); 27 | int buf_pos = 2; 28 | uint16_t var_pos = 0; 29 | 30 | for(int i = 0; i < 18; i++) 31 | gst->dwLocalVar[i] = 0; 32 | 33 | while(*p) 34 | { 35 | switch(*p) 36 | { 37 | case 'i': 38 | { 39 | int i = va_arg(ap, int); 40 | ScriptBuf[buf_pos] = 0x01; 41 | buf_pos++; 42 | memcpy(&ScriptBuf[buf_pos], &i, 4); 43 | buf_pos += 4; 44 | break; 45 | } 46 | case 'f': 47 | { 48 | float f = (float)va_arg(ap, double); 49 | ScriptBuf[buf_pos] = 0x06; 50 | buf_pos++; 51 | memcpy(&ScriptBuf[buf_pos], &f, 4); 52 | buf_pos += 4; 53 | break; 54 | } 55 | case 'v': 56 | { 57 | uint32_t *v = va_arg(ap, uint32_t*); 58 | ScriptBuf[buf_pos] = 0x03; 59 | buf_pos++; 60 | pdwParamVars[var_pos] = v; 61 | gst->dwLocalVar[var_pos] = *v; 62 | memcpy(&ScriptBuf[buf_pos], &var_pos, 2); 63 | buf_pos += 2; 64 | var_pos++; 65 | break; 66 | } 67 | case 's': 68 | { 69 | char* sz = va_arg(ap, char*); 70 | unsigned char aLen = strlen(sz); 71 | ScriptBuf[buf_pos] = 0x0E; 72 | buf_pos++; 73 | ScriptBuf[buf_pos] = aLen; 74 | buf_pos++; 75 | memcpy(&ScriptBuf[buf_pos],sz,aLen); 76 | buf_pos += aLen; 77 | break; 78 | } 79 | case 'z': 80 | { 81 | ScriptBuf[buf_pos] = 0x00; 82 | buf_pos++; 83 | break; 84 | } 85 | default: 86 | { 87 | return 0; 88 | } 89 | } 90 | ++p; 91 | } 92 | va_end(ap); 93 | 94 | int result = ExecuteScriptBuf(); 95 | if (var_pos) 96 | { 97 | for (int i=0; i < var_pos; i++) 98 | *pdwParamVars[i] = gst->dwLocalVar[i]; 99 | } 100 | 101 | return result; 102 | } 103 | 104 | void InitScripting() 105 | { 106 | gst = new GAME_SCRIPT_THREAD; 107 | memset(gst, 0, sizeof(GAME_SCRIPT_THREAD)); 108 | LOGI("Script: Inited!"); 109 | } 110 | -------------------------------------------------------------------------------- /src/game/scripting.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_SCRIPT_VARS 16 4 | #define MAX_SCRIPT_SIZE 255 5 | 6 | struct GAME_SCRIPT_THREAD 7 | { 8 | uint8_t Pad1[20]; // +00 9 | uintptr_t dwScriptIP; // +20 10 | uint8_t Pad2[36]; // +24 11 | uint32_t dwLocalVar[32]; // +60 12 | uint32_t dwTimers[2]; // +188 13 | uint8_t Pad3[33]; // +196 14 | uint8_t condResult; // +229 15 | uint8_t Pad4[10]; // +230 16 | uint16_t logicalOp; // +240 17 | uint8_t notFlag; // +242 18 | uint8_t Pad5[13]; // +243 19 | }; 20 | 21 | struct SCRIPT_COMMAND 22 | { 23 | uint32_t OpCode; 24 | char Params[MAX_SCRIPT_VARS]; 25 | }; 26 | 27 | int ScriptCommand(const SCRIPT_COMMAND* ScriptCommand, ...); 28 | 29 | const SCRIPT_COMMAND set_camera_behind_player = { 0x0373, "" }; 30 | const SCRIPT_COMMAND toggle_player_controllable = { 0x01B4, "ii" }; 31 | const SCRIPT_COMMAND set_camera = { 0x03CB, "fff" }; -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include 3 | 4 | uintptr_t g_libGTAVC = 0; 5 | char const* g_pStorage = nullptr; 6 | 7 | bool bNetworkInited = false; 8 | 9 | CGame *pGame = 0; 10 | 11 | void *Init(void *p) 12 | { 13 | pGame = new CGame(); 14 | 15 | while (true) 16 | { 17 | if (*(uintptr_t*)(g_libGTAVC+ADDR_GAMESTATE) == 9) 18 | { 19 | LOGI("libGTAVC.so: Game start sended!"); 20 | pGame->InitGame(); 21 | break; 22 | } else { 23 | usleep(5000); 24 | } 25 | } 26 | 27 | pthread_exit(0); 28 | } 29 | 30 | extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) 31 | { 32 | LOGI("VC:MP has inited!"); 33 | 34 | g_libGTAVC = findLibrary("libGTAVC.so"); 35 | if (!g_libGTAVC) 36 | { 37 | LOGI("ERROR: libGTAVC.so not found!"); 38 | } 39 | LOGI("libGTAVC.so: 0x%X", g_libGTAVC); 40 | 41 | g_pStorage = "/storage/emulated/0/Android/data/com.rockstargames.gtavc/files/"; 42 | if(!g_pStorage) 43 | { 44 | return LOGI("Error: Storage path not found!"); 45 | } 46 | LOGI("Storage path: %s", g_pStorage); 47 | 48 | /* Hooks */ 49 | InitHooks(); 50 | /* ========== */ 51 | 52 | pthread_t thread; 53 | pthread_create(&thread, 0, Init, 0); 54 | 55 | return JNI_VERSION_1_6; 56 | } 57 | 58 | uint32_t GetTickCount() 59 | { 60 | struct timeval tv; 61 | gettimeofday(&tv,NULL); 62 | return (tv.tv_sec*1000+tv.tv_usec/1000); 63 | } -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | extern uintptr_t g_libGTAVC; 11 | extern char const* g_pStorage; 12 | 13 | void InitNetwork(); 14 | uint32_t GetTickCount(); 15 | 16 | #define LOG_TAG "VICEMP" 17 | #define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) 18 | 19 | /* ============ */ 20 | #include "game/game.h" 21 | #include "game/camera.h" 22 | #include "game/scripting.h" 23 | #include "game/patches.h" 24 | 25 | #include "util/address.h" 26 | #include "util/util.h" 27 | #include "util/memory.h" 28 | /* ============ */ -------------------------------------------------------------------------------- /src/util/address.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(__aarch64__) 4 | 5 | #define ADDR_GAMESTATE 0x991E84 6 | #define MEM_START 0x3E41A8 7 | #define ADDR_STORAGE 0x9C8E40 8 | 9 | /* HOOKS */ 10 | #define HOOK_NVFOPEN 0x45A104 11 | #define HOOK_TOUCHEVENT 0x45D4E8 12 | 13 | #define ADDR_LOADINGSCREEN 0x1F8CC8 14 | 15 | /* Game Addresses */ 16 | #define PLAYER_MODEL_CHANGE 0x211730 17 | #define CLOCK_DATA 0x4B7844 18 | 19 | #else 20 | 21 | #define ADDR_GAMESTATE 0x469D24 22 | #define MEM_START 0x34D2BA 23 | #define ADDR_STORAGE 0x476740 24 | 25 | /* HOOKS */ 26 | #define HOOK_NVFOPEN 0x3A9FBC 27 | #define HOOK_TOUCHEVENT 0x3ACBA8 28 | 29 | #define ADDR_LOADINGSCREEN 0x1A23F8 30 | 31 | /* Game Addresses */ 32 | #define PLAYER_MODEL_CHANGE 0x1B9B1C 33 | #define CLOCK_DATA 0x3E6B40 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/util/memory.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "memory.h" 3 | #include 4 | 5 | #define HOOK_PROC "\x01\xB4\x01\xB4\x01\x48\x01\x90\x01\xBD\x00\xBF\x00\x00\x00\x00" 6 | 7 | uintptr_t mmap_start = 0, 8 | mmap_end = 0, 9 | memlib_start = 0, 10 | memlib_end = 0; 11 | 12 | void UnFuck(uintptr_t target) 13 | { 14 | mprotect((void*)(target & 0xFFFFF000), PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC); 15 | } 16 | 17 | void NOP(uintptr_t dest, size_t size) 18 | { 19 | for(uint32_t ptr = dest; ptr != (dest + size*2); ptr+=2) 20 | { 21 | *(char*)ptr = 0x00; 22 | *(char*)(ptr+1) = 0x46; 23 | } 24 | __builtin___clear_cache((char*)dest, (char*)(dest+size*2)); 25 | } 26 | 27 | void WriteMemory(uintptr_t dest, const char* src, size_t size) 28 | { 29 | mprotect((void*)(dest & 0xFFFFF000), PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC); 30 | memcpy((void*)dest, (void*)src, size); 31 | __builtin___clear_cache((char*)dest, (char*)(dest+size)); 32 | } 33 | 34 | void ReadMemory(uintptr_t dest, uintptr_t src, size_t size) 35 | { 36 | mprotect((void*)(src & 0xFFFFF000), PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC); 37 | memcpy((void*)dest, (void*)src, size); 38 | } 39 | 40 | void InitHooks() 41 | { 42 | LOGI("Hooks: Init hook system..."); 43 | memlib_start = g_libGTAVC+MEM_START; // gzprintf 44 | memlib_end = memlib_start+0x100; 45 | 46 | mmap_start = (uintptr_t)mmap(0, PAGE_SIZE, PROT_WRITE | PROT_READ | PROT_EXEC, 47 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 48 | mprotect((void*)(mmap_start & 0xFFFFF000), PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC); 49 | mmap_end = (mmap_start + PAGE_SIZE); 50 | LOGI("Hooks: Hook system inited!"); 51 | } 52 | 53 | void JMPCode(uintptr_t func, uintptr_t addr) 54 | { 55 | uint32_t code = ((addr-func-4) >> 12) & 0x7FF | 0xF000 | ((((addr-func-4) >> 1) & 0x7FF | 0xB800) << 16); 56 | WriteMemory(func, (const char*)&code, 4); 57 | } 58 | 59 | void WriteHookProc(uintptr_t addr, uintptr_t func) 60 | { 61 | char code[16]; 62 | memcpy(code, HOOK_PROC, 16); 63 | *(uint32_t*)&code[12] = (func | 1); 64 | WriteMemory(addr, (const char*)code, 16); 65 | } 66 | 67 | void InstallHook(uintptr_t addr, uintptr_t func, uintptr_t *orig) 68 | { 69 | LOGI("Install Hook: ADDR 0x%X FUNC 0x%X", addr, func); 70 | if(memlib_end < (memlib_start + 0x10) || mmap_end < (mmap_start + 0x20)) 71 | { 72 | LOGI("Hooks: Space Limit!"); 73 | exit(1); 74 | } 75 | 76 | ReadMemory(mmap_start, addr, 4); 77 | WriteHookProc(mmap_start+4, addr+4); 78 | *orig = mmap_start+1; 79 | mmap_start += 32; 80 | JMPCode(addr, memlib_start); 81 | WriteHookProc(memlib_start, func); 82 | memlib_start += 16; 83 | } 84 | 85 | void InstallMethodHook(uintptr_t addr, uintptr_t func) 86 | { 87 | UnFuck(addr); 88 | *(uintptr_t*)addr = func; 89 | } -------------------------------------------------------------------------------- /src/util/memory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void UnFuck(uintptr_t target); 4 | void NOP(uintptr_t dest, size_t size); 5 | void WriteMemory(uintptr_t dest, const char* src, size_t size); 6 | void ReadMemory(uintptr_t dest, uintptr_t src, size_t size); 7 | void InitHooks(); 8 | void JMPCode(uintptr_t func, uintptr_t addr); 9 | void WriteHookProc(uintptr_t addr, uintptr_t func); 10 | void InstallHook(uintptr_t addr, uintptr_t func, uintptr_t *orig); 11 | void InstallMethodHook(uintptr_t addr, uintptr_t func); -------------------------------------------------------------------------------- /src/util/util.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "util.h" 3 | 4 | uintptr_t findLibrary(const char *library) 5 | { 6 | char filename[0xFF] = {0}, 7 | buffer[2048] = {0}; 8 | FILE *fp = 0; 9 | uintptr_t address = 0; 10 | 11 | sprintf(filename, "/proc/%d/maps", getpid()); 12 | 13 | fp = fopen(filename, "rt"); 14 | if(fp == 0) 15 | { 16 | LOGI("can't open file %s", filename); 17 | goto done; 18 | } 19 | 20 | while(fgets(buffer, sizeof(buffer), fp)) 21 | { 22 | if(strstr(buffer, library)) 23 | { 24 | address = (uintptr_t)strtoul( buffer, 0, 16 ); 25 | break; 26 | } 27 | } 28 | 29 | done: 30 | 31 | if(fp) 32 | fclose(fp); 33 | 34 | return address; 35 | } -------------------------------------------------------------------------------- /src/util/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | uintptr_t findLibrary(const char *library); --------------------------------------------------------------------------------