├── LICENSE ├── MemoryMgr.h ├── MemoryMgr_all.h ├── betacam.cpp ├── build.cmd ├── extradirfix.cpp ├── hydraulics.cpp ├── lodfix.cpp ├── miscfix.cpp ├── noreplay.cpp ├── noskin.cpp ├── overridecd.cpp ├── portablegta.cpp ├── regionfree.cpp ├── screenshot.cpp ├── setfov.cpp └── vehicleflare.cpp /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 GTA modding 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MemoryMgr.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEMORYMGR 2 | #define __MEMORYMGR 3 | 4 | #define WRAPPER __declspec(naked) 5 | #define DEPRECATED __declspec(deprecated) 6 | #define EAXJMP(a) { _asm mov eax, a _asm jmp eax } 7 | #define VARJMP(a) { _asm jmp a } 8 | #define WRAPARG(a) UNREFERENCED_PARAMETER(a) 9 | 10 | #define NOVMT __declspec(novtable) 11 | #define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a 12 | 13 | enum 14 | { 15 | PATCH_CALL, 16 | PATCH_JUMP, 17 | PATCH_NOTHING, 18 | }; 19 | 20 | enum 21 | { 22 | III_10 = 1, 23 | III_11, 24 | III_STEAM, 25 | VC_10, 26 | VC_11, 27 | VC_STEAM 28 | }; 29 | 30 | extern int gtaversion; 31 | 32 | template 33 | inline T AddressByVersion(uintptr addressIII10, uintptr addressIII11, uintptr addressIIISteam, uintptr addressvc10, uintptr addressvc11, uintptr addressvcSteam) 34 | { 35 | if(gtaversion == -1){ 36 | if(*(uintptr*)0x5C1E75 == 0xB85548EC) gtaversion = III_10; 37 | else if(*(uintptr*)0x5C2135 == 0xB85548EC) gtaversion = III_11; 38 | else if(*(uintptr*)0x5C6FD5 == 0xB85548EC) gtaversion = III_STEAM; 39 | else if(*(uintptr*)0x667BF5 == 0xB85548EC) gtaversion = VC_10; 40 | else if(*(uintptr*)0x667C45 == 0xB85548EC) gtaversion = VC_11; 41 | else if(*(uintptr*)0x666BA5 == 0xB85548EC) gtaversion = VC_STEAM; 42 | else gtaversion = 0; 43 | } 44 | switch(gtaversion){ 45 | case III_10: 46 | return (T)addressIII10; 47 | case III_11: 48 | return (T)addressIII11; 49 | case III_STEAM: 50 | return (T)addressIIISteam; 51 | case VC_10: 52 | return (T)addressvc10; 53 | case VC_11: 54 | return (T)addressvc11; 55 | case VC_STEAM: 56 | return (T)addressvcSteam; 57 | default: 58 | return (T)0; 59 | } 60 | } 61 | 62 | inline bool 63 | is10(void) 64 | { 65 | return gtaversion == III_10 || gtaversion == VC_10; 66 | } 67 | 68 | inline bool 69 | isIII(void) 70 | { 71 | return gtaversion >= III_10 && gtaversion <= III_STEAM; 72 | } 73 | 74 | inline bool 75 | isVC(void) 76 | { 77 | return gtaversion >= VC_10 && gtaversion <= VC_STEAM; 78 | } 79 | 80 | #define PTRFROMCALL(addr) (uint32_t)(*(uint32_t*)((uint32_t)addr+1) + (uint32_t)addr + 5) 81 | #define INTERCEPT(saved, func, a) \ 82 | { \ 83 | saved = PTRFROMCALL(a); \ 84 | InjectHook(a, func); \ 85 | } 86 | 87 | template inline void 88 | Patch(AT address, T value) 89 | { 90 | DWORD dwProtect[2]; 91 | VirtualProtect((void*)address, sizeof(T), PAGE_EXECUTE_READWRITE, &dwProtect[0]); 92 | *(T*)address = value; 93 | VirtualProtect((void*)address, sizeof(T), dwProtect[0], &dwProtect[1]); 94 | } 95 | 96 | template inline void 97 | Nop(AT address, unsigned int nCount) 98 | { 99 | DWORD dwProtect[2]; 100 | VirtualProtect((void*)address, nCount, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 101 | memset((void*)address, 0x90, nCount); 102 | VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]); 103 | } 104 | 105 | template inline void 106 | InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING) 107 | { 108 | DWORD dwProtect[2]; 109 | switch ( nType ) 110 | { 111 | case PATCH_JUMP: 112 | VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 113 | *(BYTE*)address = 0xE9; 114 | break; 115 | case PATCH_CALL: 116 | VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 117 | *(BYTE*)address = 0xE8; 118 | break; 119 | default: 120 | VirtualProtect((void*)((DWORD)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 121 | break; 122 | } 123 | DWORD dwHook; 124 | _asm 125 | { 126 | mov eax, hook 127 | mov dwHook, eax 128 | } 129 | 130 | *(ptrdiff_t*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5; 131 | if ( nType == PATCH_NOTHING ) 132 | VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]); 133 | else 134 | VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]); 135 | } 136 | 137 | inline void ExtractCall(void *dst, uintptr a) 138 | { 139 | *(uintptr*)dst = (uintptr)(*(uintptr*)(a+1) + a + 5); 140 | } 141 | template 142 | inline void InterceptCall(void *dst, T func, uintptr a) 143 | { 144 | ExtractCall(dst, a); 145 | InjectHook(a, func); 146 | } 147 | template 148 | inline void InterceptVmethod(void *dst, T func, uintptr a) 149 | { 150 | *(uintptr*)dst = *(uintptr*)a; 151 | Patch(a, func); 152 | } 153 | 154 | #endif -------------------------------------------------------------------------------- /MemoryMgr_all.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEMORYMGR 2 | #define __MEMORYMGR 3 | 4 | #define WRAPPER __declspec(naked) 5 | #define DEPRECATED __declspec(deprecated) 6 | #define EAXJMP(a) { _asm mov eax, a _asm jmp eax } 7 | #define VARJMP(a) { _asm jmp a } 8 | #define WRAPARG(a) UNREFERENCED_PARAMETER(a) 9 | 10 | #define NOVMT __declspec(novtable) 11 | #define SETVMT(a) *((DWORD_PTR*)this) = (DWORD_PTR)a 12 | 13 | enum 14 | { 15 | PATCH_CALL, 16 | PATCH_JUMP, 17 | PATCH_NOTHING, 18 | }; 19 | 20 | enum 21 | { 22 | III_10 = 1, 23 | III_11, 24 | III_STEAM, 25 | VC_10, 26 | VC_11, 27 | VC_STEAM, 28 | SA_10 29 | }; 30 | 31 | extern int gtaversion; 32 | 33 | template 34 | inline T AddressByVersion(uintptr addressIII10, uintptr addressIII11, uintptr addressIIISteam, uintptr addressvc10, uintptr addressvc11, uintptr addressvcSteam, uintptr addressSA10) 35 | { 36 | if(gtaversion == -1){ 37 | if(*(uintptr*)0x5C1E75 == 0xB85548EC) gtaversion = III_10; 38 | else if(*(uintptr*)0x5C2135 == 0xB85548EC) gtaversion = III_11; 39 | else if(*(uintptr*)0x5C6FD5 == 0xB85548EC) gtaversion = III_STEAM; 40 | else if(*(uintptr*)0x667BF5 == 0xB85548EC) gtaversion = VC_10; 41 | else if(*(uintptr*)0x667C45 == 0xB85548EC) gtaversion = VC_11; 42 | else if(*(uintptr*)0x666BA5 == 0xB85548EC) gtaversion = VC_STEAM; 43 | else if(*(uintptr*)0x82457C == 0x94BF && *(uintptr*)0x8245BC != 0x94BF) gtaversion = SA_10; 44 | else gtaversion = 0; 45 | } 46 | switch(gtaversion){ 47 | case III_10: 48 | return (T)addressIII10; 49 | case III_11: 50 | return (T)addressIII11; 51 | case III_STEAM: 52 | return (T)addressIIISteam; 53 | case VC_10: 54 | return (T)addressvc10; 55 | case VC_11: 56 | return (T)addressvc11; 57 | case VC_STEAM: 58 | return (T)addressvcSteam; 59 | case SA_10: 60 | return (T)addressSA10; 61 | default: 62 | return (T)0; 63 | } 64 | } 65 | 66 | inline bool 67 | is10(void) 68 | { 69 | return gtaversion == III_10 || gtaversion == VC_10 || gtaversion == SA_10; 70 | } 71 | 72 | inline bool 73 | isIII(void) 74 | { 75 | return gtaversion >= III_10 && gtaversion <= III_STEAM; 76 | } 77 | 78 | inline bool 79 | isVC(void) 80 | { 81 | return gtaversion >= VC_10 && gtaversion <= VC_STEAM; 82 | } 83 | 84 | #define PTRFROMCALL(addr) (uint32_t)(*(uint32_t*)((uint32_t)addr+1) + (uint32_t)addr + 5) 85 | #define INTERCEPT(saved, func, a) \ 86 | { \ 87 | saved = PTRFROMCALL(a); \ 88 | InjectHook(a, func); \ 89 | } 90 | 91 | template inline void 92 | Patch(AT address, T value) 93 | { 94 | DWORD dwProtect[2]; 95 | VirtualProtect((void*)address, sizeof(T), PAGE_EXECUTE_READWRITE, &dwProtect[0]); 96 | *(T*)address = value; 97 | VirtualProtect((void*)address, sizeof(T), dwProtect[0], &dwProtect[1]); 98 | } 99 | 100 | template inline void 101 | Nop(AT address, unsigned int nCount) 102 | { 103 | DWORD dwProtect[2]; 104 | VirtualProtect((void*)address, nCount, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 105 | memset((void*)address, 0x90, nCount); 106 | VirtualProtect((void*)address, nCount, dwProtect[0], &dwProtect[1]); 107 | } 108 | 109 | template inline void 110 | InjectHook(AT address, HT hook, unsigned int nType=PATCH_NOTHING) 111 | { 112 | DWORD dwProtect[2]; 113 | switch ( nType ) 114 | { 115 | case PATCH_JUMP: 116 | VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 117 | *(BYTE*)address = 0xE9; 118 | break; 119 | case PATCH_CALL: 120 | VirtualProtect((void*)address, 5, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 121 | *(BYTE*)address = 0xE8; 122 | break; 123 | default: 124 | VirtualProtect((void*)((DWORD)address + 1), 4, PAGE_EXECUTE_READWRITE, &dwProtect[0]); 125 | break; 126 | } 127 | DWORD dwHook; 128 | _asm 129 | { 130 | mov eax, hook 131 | mov dwHook, eax 132 | } 133 | 134 | *(ptrdiff_t*)((DWORD)address + 1) = (DWORD)dwHook - (DWORD)address - 5; 135 | if ( nType == PATCH_NOTHING ) 136 | VirtualProtect((void*)((DWORD)address + 1), 4, dwProtect[0], &dwProtect[1]); 137 | else 138 | VirtualProtect((void*)address, 5, dwProtect[0], &dwProtect[1]); 139 | } 140 | 141 | inline void ExtractCall(void *dst, uintptr a) 142 | { 143 | *(uintptr*)dst = (uintptr)(*(uintptr*)(a+1) + a + 5); 144 | } 145 | template 146 | inline void InterceptCall(void *dst, T func, uintptr a) 147 | { 148 | ExtractCall(dst, a); 149 | InjectHook(a, func); 150 | } 151 | template 152 | inline void InterceptVmethod(void *dst, T func, uintptr a) 153 | { 154 | *(uintptr*)dst = *(uintptr*)a; 155 | Patch(a, func); 156 | } 157 | 158 | #endif -------------------------------------------------------------------------------- /betacam.cpp: -------------------------------------------------------------------------------- 1 | #define _USE_MATH_DEFINES 2 | #pragma comment(lib, "user32") 3 | 4 | #include "windows.h" 5 | #include 6 | #include 7 | typedef uintptr_t uintptr; 8 | #include "MemoryMgr_all.h" 9 | 10 | typedef uint8_t uint8, uchar; 11 | typedef uint16_t uint16, ushort; 12 | typedef uint32_t uint32, uint; 13 | typedef uint64_t uint64; 14 | typedef int8_t int8; 15 | typedef int16_t int16; 16 | typedef int32_t int32; 17 | typedef int64_t int64; 18 | 19 | #define nil NULL 20 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 21 | 22 | #define DEGTORAD(x) (float)((x)/180.0f*M_PI) 23 | 24 | 25 | int gtaversion = -1; 26 | 27 | static float returnAngle1(float x, float y) { return DEGTORAD(1.3f); } 28 | static float returnAngle2(float x, float y) { return DEGTORAD(0.0f); } 29 | static float returnAngle3(float x, float y) { return DEGTORAD(10.8f); } 30 | 31 | void 32 | patchIII10(void) 33 | { 34 | // beta-stlye vehicle cam 35 | Patch(0x468953 + 6, 0.05f); 36 | Patch(0x468972 + 6, 1.6f); 37 | Patch(0x468992 + 6, 2.4f); 38 | static float heightoffset = 0.35f; 39 | Patch(0x45C1D8 + 2, &heightoffset); 40 | 41 | InjectHook(0x466769, returnAngle1); 42 | InjectHook(0x4667A0, returnAngle2); 43 | InjectHook(0x4667D4, returnAngle3); 44 | } 45 | 46 | BOOL WINAPI 47 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 48 | { 49 | if(reason == DLL_PROCESS_ATTACH){ 50 | if(AddressByVersion(1, 0, 0, 0, 0, 0, 0)) 51 | patchIII10(); 52 | } 53 | 54 | return TRUE; 55 | } 56 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" 4 | 5 | cl /LD /I %RWSDK34% /I C:\Users\aap\src\lpng1634 "C:\Users\aap\src\lpng1634\projects\vstudio\Release Library\libpng16.lib" "C:\Users\aap\src\lpng1634\projects\vstudio\Release Library\zlib.lib" screenshot.cpp /Fescreenshot.dll 6 | cl /LD betacam.cpp /Febetacam.dll 7 | cl /LD betahud.cpp /Febetahud.dll 8 | cl /LD vehicleflare.cpp /Fevehicleflare.dll 9 | cl /LD iiifont.cpp /Feiiifont.dll 10 | cl /LD noreplay.cpp /Fenoreplay.dll 11 | cl /LD miscfix.cpp /Femiscfix.dll 12 | cl /LD noskin.cpp /Fenoskin.dll 13 | cl /LD /EHsc setfov.cpp /Fesetfov.dll 14 | cl /LD lodfix.cpp /Felodfix.dll 15 | cl /LD extradirfix.cpp /Feextradirfix.dll 16 | cl /LD overridecd.cpp /Feoverridecd.dll 17 | cl /LD portablegta.cpp /Feportablegta.dll 18 | cl /LD hydraulics.cpp /Fehydraulics.dll 19 | cl /LD regionfree.cpp /Feregionfree.dll 20 | cl /LD noskinshader.cpp /Fenoskinshader.dll 21 | cl /LD uncensor.cpp /Feuncensor.dll 22 | -------------------------------------------------------------------------------- /extradirfix.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr.h" // take from skygfx_vc 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | 19 | int gtaversion = -1; 20 | 21 | 22 | struct CDirectory 23 | { 24 | struct DirectoryInfo { 25 | uint32 offset; 26 | uint32 size; 27 | char name[24]; 28 | }; 29 | DirectoryInfo *entries; 30 | int32 maxFiles; 31 | int32 numFiles; 32 | 33 | void AddItem(DirectoryInfo *dirinfo, int imgid); 34 | int FindItem(char *name); 35 | }; 36 | int 37 | CDirectory::FindItem(char *name) 38 | { 39 | int i; 40 | for(i = 0; i < numFiles; i++) 41 | if(strcmpi(entries[i].name, name) == 0) 42 | return i; 43 | return -1; 44 | } 45 | void 46 | CDirectory::AddItem(DirectoryInfo *dirinfo, int imgid) 47 | { 48 | int i; 49 | DirectoryInfo dirinfo2 = *dirinfo; 50 | dirinfo2.offset |= imgid << 24; 51 | i = FindItem(dirinfo->name); 52 | if(i < 0) 53 | entries[numFiles++] = dirinfo2; 54 | } 55 | void __declspec(naked) 56 | dirEntryHookVC(void) 57 | { 58 | _asm{ 59 | mov edx, [esp+40h + 0x8] // fileID 60 | lea eax, [esp+40h - 0x34] // dir entry 61 | mov ecx, ds:0xA10730 // CStreaming::ms_pExtraObjectsDir 62 | push edx 63 | push eax 64 | call CDirectory::AddItem 65 | 66 | push dword ptr 0x40FCA2 67 | retn 68 | } 69 | } 70 | 71 | void __declspec(naked) 72 | dirEntryHookIII(void) 73 | { 74 | _asm{ 75 | mov edx, [esp+48h + 0x8] // fileID 76 | lea eax, [esp+48h - 0x3C] // dir entry 77 | mov ecx, ds:0x95CB90 // CStreaming::ms_pExtraObjectsDir 78 | push edx 79 | push eax 80 | call CDirectory::AddItem 81 | 82 | push dword ptr 0x406F30 83 | retn 84 | } 85 | } 86 | 87 | 88 | void 89 | patchVC10(void) 90 | { 91 | InjectHook(0x40FC92, dirEntryHookVC, PATCH_JUMP); 92 | } 93 | 94 | void 95 | patchIII10(void) 96 | { 97 | InjectHook(0x406F20, dirEntryHookIII, PATCH_JUMP); 98 | } 99 | 100 | BOOL WINAPI 101 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 102 | { 103 | if(reason == DLL_PROCESS_ATTACH){ 104 | AddressByVersion(0, 0, 0, 0, 0, 0); 105 | if (gtaversion == VC_10) 106 | patchVC10(); 107 | else if (gtaversion == III_10) 108 | patchIII10(); 109 | } 110 | 111 | return TRUE; 112 | } 113 | -------------------------------------------------------------------------------- /hydraulics.cpp: -------------------------------------------------------------------------------- 1 | #define _USE_MATH_DEFINES 2 | #pragma comment(lib, "user32") 3 | 4 | #include "windows.h" 5 | #include 6 | #include 7 | typedef uintptr_t uintptr; 8 | #include "MemoryMgr.h" // take from skygfx_vc 9 | 10 | typedef uint8_t uint8, uchar; 11 | typedef uint16_t uint16, ushort; 12 | typedef uint32_t uint32, uint; 13 | typedef uint64_t uint64; 14 | typedef int8_t int8; 15 | typedef int16_t int16; 16 | typedef int32_t int32; 17 | typedef int64_t int64; 18 | 19 | #define nil NULL 20 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 21 | 22 | int gtaversion = -1; 23 | 24 | void __declspec(naked) 25 | checkHydraulics(void) 26 | { 27 | _asm{ 28 | cmp eax, 135 // yardie 29 | je hydraulics 30 | cmp eax, 109 // esperanto 31 | je hydraulics 32 | // no hydraulics 33 | push 0x532035 34 | retn 35 | hydraulics: 36 | push 0x532027 37 | retn 38 | } 39 | } 40 | 41 | void 42 | patchIII10(void) 43 | { 44 | // hydraulics for esperanto 45 | InjectHook(0x532020, checkHydraulics, PATCH_JUMP); 46 | } 47 | 48 | BOOL WINAPI 49 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 50 | { 51 | if(reason == DLL_PROCESS_ATTACH){ 52 | AddressByVersion(0, 0, 0, 0, 0, 0); 53 | if (gtaversion == III_10) 54 | patchIII10(); 55 | } 56 | 57 | return TRUE; 58 | } 59 | -------------------------------------------------------------------------------- /lodfix.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr.h" // take from skygfx_vc 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | 19 | int gtaversion = -1; 20 | 21 | struct CBaseModelInfo 22 | { 23 | void **vtable; 24 | char name[24]; 25 | void *colModel; 26 | void *twodeffect; 27 | short id; 28 | ushort refCount; 29 | short txdSlot; 30 | uchar type; 31 | uchar num2dEffects; 32 | bool freeCol; 33 | }; 34 | static_assert(sizeof(CBaseModelInfo) == 0x30, "CBaseModelInfo: wrong size"); 35 | 36 | struct CSimpleModelInfo : public CBaseModelInfo 37 | { 38 | void *m_atomics[3]; 39 | float m_lodDistances[3]; 40 | uchar m_numAtomics; 41 | uchar m_alpha; 42 | ushort m_flags; 43 | 44 | void FindRelatedModel(void); 45 | float GetLargestLodDistance(void); 46 | void SetupBigBuilding(void); 47 | }; 48 | static_assert(sizeof(CSimpleModelInfo) == 0x4C, "CSimpleModelInfo: wrong size"); 49 | 50 | void *TheCamera = (void*)0x6FACF8; 51 | 52 | WRAPPER void CSimpleModelInfo::FindRelatedModel(void) { EAXJMP(0x517C00); } 53 | WRAPPER float CSimpleModelInfo::GetLargestLodDistance(void) { EAXJMP(0x517A60); } 54 | 55 | void 56 | CSimpleModelInfo::SetupBigBuilding(void) 57 | { 58 | CSimpleModelInfo *related; 59 | if(m_lodDistances[0] > 300.0f && m_atomics[2] == nil){ 60 | m_flags |= 0x10; // isBigBuilding 61 | FindRelatedModel(); 62 | related = (CSimpleModelInfo*)this->m_atomics[2]; 63 | if(related) 64 | m_lodDistances[2] = related->GetLargestLodDistance()/FIELD(float, TheCamera, 0xEC); // lodMult 65 | else{ 66 | if(strstr(this->name, "LOD")) 67 | m_lodDistances[2] = 100.0f; 68 | else 69 | m_lodDistances[2] = 0.0f; 70 | } 71 | } 72 | } 73 | 74 | void 75 | patchIII10(void) 76 | { 77 | InjectHook(0x476D96,& CSimpleModelInfo::SetupBigBuilding); 78 | } 79 | 80 | BOOL WINAPI 81 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 82 | { 83 | if(reason == DLL_PROCESS_ATTACH){ 84 | AddressByVersion(0, 0, 0, 0, 0, 0); 85 | if (gtaversion == III_10) 86 | patchIII10(); 87 | } 88 | 89 | return TRUE; 90 | } 91 | -------------------------------------------------------------------------------- /miscfix.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr.h" // take from skygfx_vc 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | int gtaversion = -1; 19 | 20 | void 21 | patchIII10(void) 22 | { 23 | // ignore txd.img 24 | InjectHook(0x48C12E, 0x48C14C, PATCH_JUMP); 25 | 26 | // increase range of ped/car density 27 | static float pedMax = 100.0f; 28 | static float carMax = 100.0f; 29 | Patch(0x59BE9F + 2, &pedMax); 30 | Patch(0x59BEB1 + 2, &pedMax); 31 | Patch(0x59BF16 + 2, &carMax); 32 | Patch(0x59BF28 + 2, &carMax); 33 | } 34 | 35 | BOOL WINAPI 36 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 37 | { 38 | if(reason == DLL_PROCESS_ATTACH){ 39 | AddressByVersion(0, 0, 0, 0, 0, 0); 40 | if (gtaversion == III_10) 41 | patchIII10(); 42 | } 43 | 44 | return TRUE; 45 | } 46 | -------------------------------------------------------------------------------- /noreplay.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr_all.h" 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | int gtaversion = -1; 19 | 20 | BOOL WINAPI 21 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 22 | { 23 | uintptr addr; 24 | if(reason == DLL_PROCESS_ATTACH){ 25 | addr = AddressByVersion(0x48C975, 0, 0, 0x4A45C3, 0, 0, 0x53C090); 26 | if(addr) 27 | Nop(addr, 5); 28 | } 29 | 30 | return TRUE; 31 | } 32 | -------------------------------------------------------------------------------- /noskin.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr.h" // take from skygfx_vc 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | int gtaversion = -1; 19 | 20 | struct MenuEntry 21 | { 22 | int32 function; 23 | char name[8]; 24 | int32 parameter; 25 | int32 targetmenu; 26 | }; 27 | struct MenuScreen 28 | { 29 | char name[8]; 30 | int32 unk1; 31 | int32 parent1; 32 | int32 parent2; 33 | int32 unk2; 34 | int32 unk3; 35 | MenuEntry entries[18]; 36 | }; 37 | MenuScreen *optionsScreen = (MenuScreen*)0x615754; 38 | 39 | struct GlobalScene 40 | { 41 | void *world; 42 | void *camera; 43 | }; 44 | GlobalScene &Scene = *(GlobalScene*)0x726768; 45 | 46 | void 47 | patchVC10(void) 48 | { 49 | int n; 50 | // remove player skin setup 51 | for(n = 0; optionsScreen->entries[n].name[0]; n++) 52 | if(strcmp(optionsScreen->entries[n].name, "FET_PSU") == 0) 53 | goto found; 54 | return; 55 | found: 56 | for(; n < 17; n++) 57 | optionsScreen->entries[n] = optionsScreen->entries[n+1]; 58 | memset(&optionsScreen->entries[17], 0, sizeof(MenuEntry)); 59 | 60 | // don't init skin 61 | // Nop(0x48C09A, 5); 62 | // struct{uchar m[3];} m = { {0xc2, 0x04, 0x00} }; 63 | // Patch(0x4A16D0, m); 64 | } 65 | 66 | void 67 | patchIII10(void) 68 | { 69 | int n; 70 | // remove player skin setup 71 | for(n = 0; optionsScreen->entries[n].name[0]; n++) 72 | if(strcmp(optionsScreen->entries[n].name, "FET_PSU") == 0) 73 | goto found; 74 | return; 75 | found: 76 | for(; n < 17; n++) 77 | optionsScreen->entries[n] = optionsScreen->entries[n+1]; 78 | memset(&optionsScreen->entries[17], 0, sizeof(MenuEntry)); 79 | 80 | // don't init skin 81 | Nop(0x48C09A, 5); 82 | struct{uchar m[3];} m = { {0xc2, 0x04, 0x00} }; 83 | Patch(0x4A16D0, m); 84 | } 85 | 86 | BOOL WINAPI 87 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 88 | { 89 | if(reason == DLL_PROCESS_ATTACH){ 90 | AddressByVersion(0, 0, 0, 0, 0, 0); 91 | if(gtaversion == III_10) 92 | patchIII10(); 93 | else if(gtaversion == VC_10) 94 | patchVC10(); 95 | } 96 | 97 | return TRUE; 98 | } 99 | -------------------------------------------------------------------------------- /overridecd.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr_all.h" // take from debugmenu 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | int gtaversion = -1; 19 | 20 | struct CdImage 21 | { 22 | char name[40]; 23 | char isNotPlayerImg; 24 | HANDLE streamHandle; 25 | }; 26 | 27 | CdImage *CStreaming__ms_files = (CdImage*)0x8E48D8; 28 | WRAPPER void CStreaming__LoadCdDirectory(const char *name, int fileid) { EAXJMP(0x5B6170); } 29 | 30 | void 31 | LoadCdDirectories(void) 32 | { 33 | int n; 34 | for(n = 0; n < 8; n++) 35 | if(CStreaming__ms_files[n].name[0] == '\0') 36 | break; 37 | while(n--) 38 | if(CStreaming__ms_files[n].isNotPlayerImg) 39 | CStreaming__LoadCdDirectory(CStreaming__ms_files[n].name, n); 40 | } 41 | 42 | void 43 | patchSA10(void) 44 | { 45 | InjectHook(0x5B82F0, LoadCdDirectories, PATCH_CALL); 46 | InjectHook(0x5B82F0 + 5, 0x5B8324, PATCH_JUMP); 47 | 48 | // swap gta3.img and gta_int.img 49 | Patch(0x408430 + 1, 0x858B20); 50 | Patch(0x40844C + 1, 0x858B20); 51 | 52 | Patch(0x40846E + 1, 0x858AF4); 53 | Patch(0x40848C + 1, 0x858AF4); 54 | } 55 | 56 | BOOL WINAPI 57 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 58 | { 59 | if(reason == DLL_PROCESS_ATTACH){ 60 | AddressByVersion(0, 0, 0, 0, 0, 0, 0); 61 | if (gtaversion == SA_10) 62 | patchSA10(); 63 | } 64 | 65 | return TRUE; 66 | } 67 | -------------------------------------------------------------------------------- /portablegta.cpp: -------------------------------------------------------------------------------- 1 | #pragma comment(lib, "user32") 2 | 3 | #define _CRT_SECURE_NO_WARNINGS 4 | #include 5 | #include 6 | typedef uintptr_t uintptr; 7 | #include "MemoryMgr_all.h" 8 | 9 | int gtaversion = -1; 10 | char userPath[MAX_PATH]; 11 | void *&Camera = *AddressByVersion(0x72676C, 0x72676C, 0x7368AC, 0x8100BC, 0x8100C4, 0x80F0C4, 0); 12 | char *tracksPath = (char*)0xC92168; 13 | char *galleryPath = (char*)0xC92268; 14 | 15 | void 16 | makedir(const char *path) 17 | { 18 | HANDLE h = CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING|FILE_ATTRIBUTE_NORMAL, NULL); 19 | if(h == (HANDLE)-1) 20 | CreateDirectoryA(path, NULL); 21 | else 22 | CloseHandle(h); 23 | } 24 | 25 | char* 26 | getUserFilesDir(void) 27 | { 28 | makedir(userPath); 29 | if(gtaversion == SA_10){ 30 | strcpy(galleryPath, userPath); 31 | strcat(galleryPath, "\\Gallery"); 32 | makedir(galleryPath); 33 | 34 | strcpy(tracksPath, userPath); 35 | strcat(tracksPath, "\\User Tracks"); 36 | makedir(tracksPath); 37 | } 38 | return userPath; 39 | } 40 | 41 | void (*getSaveFileName_orig)(const char *dir); 42 | void 43 | getSaveFileName(const char *dir) 44 | { 45 | getSaveFileName_orig(getUserFilesDir()); 46 | } 47 | 48 | int (*RsEventHandler_orig)(int a, int b); 49 | int 50 | delayedPatches(int a, int b) 51 | { 52 | char *p; 53 | GetModuleFileName(NULL, userPath, MAX_PATH); 54 | p = strrchr(userPath, '\\'); 55 | strcpy(p+1, "userfiles"); 56 | 57 | // Fail if RenderWare has already been started = loaded by MSS 58 | if(gtaversion != SA_10 && Camera){ 59 | MessageBox(NULL, "The portability plugin cannot be loaded by the default Mss32 ASI loader.\nUse another loader.", "Error", MB_ICONERROR | MB_OK); 60 | return FALSE; 61 | } 62 | 63 | if(gtaversion == III_10){ 64 | // also patched by SilentPatch. so better replace the calls instead 65 | //InjectHook(0x580BB0, getUserFilesDir, PATCH_JUMP); 66 | InjectHook(0x479080, getUserFilesDir); 67 | InjectHook(0x5811DD, getUserFilesDir); 68 | InjectHook(0x591EDD, getUserFilesDir); 69 | }else if(gtaversion == VC_10){ 70 | // InjectHook(0x602240, getUserFilesDir, PATCH_JUMP); 71 | 72 | InjectHook(0x48E020, getUserFilesDir); 73 | InjectHook(0x61D8CA, getUserFilesDir); 74 | 75 | InjectHook(0x601A40, 0x601B2A, PATCH_JUMP); 76 | InterceptCall(&getSaveFileName_orig, getSaveFileName, 0x601B30); 77 | }else if(gtaversion == SA_10){ 78 | InjectHook(0x744FB0, getUserFilesDir, PATCH_JUMP); 79 | } 80 | 81 | return RsEventHandler_orig(a, b); 82 | } 83 | 84 | BOOL WINAPI 85 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 86 | { 87 | if(reason == DLL_PROCESS_ATTACH){ 88 | if(AddressByVersion(1, 0, 0, 1, 0, 0, 1)) 89 | InterceptCall(&RsEventHandler_orig, delayedPatches, AddressByVersion(0x58275E, 0, 0, 0x5FFAFE, 0, 0, 0x748739)); 90 | } 91 | return TRUE; 92 | } 93 | -------------------------------------------------------------------------------- /regionfree.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr.h" // take from skygfx_vc 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | int gtaversion = -1; 19 | 20 | void 21 | patchIII10(void) 22 | { 23 | // don't set frenchGame and germanGame in 24 | // CMenuManager::InitialiseChangedLanguageSettings 25 | InjectHook(0x47A51B, 0x47A537, PATCH_JUMP); 26 | 27 | // and additionally nastyGame, noProstitues and m_PrefsAllowNastyGame in 28 | // InitialiseLanguage 29 | InjectHook(0x5821C2, 0x582222, PATCH_JUMP); 30 | } 31 | 32 | void 33 | patchVC10(void) 34 | { 35 | // same as patchIII10 36 | InjectHook(0x4A38EC, 0x4A3948, PATCH_JUMP); 37 | InjectHook(0x600B42, 0x600BA2, PATCH_JUMP); 38 | } 39 | 40 | BOOL WINAPI 41 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 42 | { 43 | if(reason == DLL_PROCESS_ATTACH){ 44 | AddressByVersion(0, 0, 0, 0, 0, 0); 45 | if (gtaversion == III_10) 46 | patchIII10(); 47 | else if(gtaversion == VC_10) 48 | patchVC10(); 49 | } 50 | 51 | return TRUE; 52 | } 53 | -------------------------------------------------------------------------------- /screenshot.cpp: -------------------------------------------------------------------------------- 1 | #pragma comment(lib, "user32") 2 | 3 | #define _CRT_SECURE_NO_WARNINGS 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef uintptr_t uintptr; 11 | #include "MemoryMgr_all.h" 12 | #include 13 | 14 | #define nil NULL 15 | typedef uint8_t uint8; 16 | 17 | int gtaversion = -1; 18 | 19 | static uint32_t RwImageCreate_A = AddressByVersion(0x5A9120, 0, 0, 0x651250, 0, 0, 0x8026E0); 20 | WRAPPER RwImage *RwImageCreate(RwInt32, RwInt32, RwInt32) { VARJMP(RwImageCreate_A); } 21 | static uint32_t RwImageAllocatePixels_A = AddressByVersion(0x5A91E0, 0, 0, 0x651310, 0, 0, 0x8027A0); 22 | WRAPPER RwImage *RwImageAllocatePixels(RwImage *) { VARJMP(RwImageAllocatePixels_A); } 23 | static uint32_t RwImageSetFromRaster_A = AddressByVersion(0x5BBF10, 0, 0, 0x660270, 0, 0, 0x804250); 24 | WRAPPER RwImage *RwImageSetFromRaster(RwImage*, RwRaster*) { VARJMP(RwImageSetFromRaster_A); } 25 | static uint32_t RwImageDestroy_A = AddressByVersion(0x5A9180, 0x5A9440, 0x5AB6A0, 0x6512B0, 0x651300, 0x650260, 0x802740); 26 | WRAPPER RwBool RwImageDestroy(RwImage*) { VARJMP(RwImageDestroy_A); } 27 | 28 | void 29 | writePNG(RwImage *img, const char *filename) 30 | { 31 | FILE *f; 32 | png_structp png; 33 | png_infop info; 34 | int x, y; 35 | png_byte **rows; 36 | uint8 *line; 37 | 38 | if(img->depth != 32) 39 | return; 40 | if(f = fopen(filename, "wb"), f == nil) 41 | return; 42 | 43 | png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nil, nil, nil); 44 | if(png == nil) 45 | goto fail1; 46 | 47 | info = png_create_info_struct(png); 48 | if(info == nil) 49 | goto fail2; 50 | 51 | if(setjmp(png_jmpbuf(png))) 52 | goto fail2; 53 | 54 | png_set_IHDR(png, 55 | info, 56 | img->width, 57 | img->height, 58 | 8, 59 | PNG_COLOR_TYPE_RGB, 60 | PNG_INTERLACE_NONE, 61 | PNG_COMPRESSION_TYPE_DEFAULT, 62 | PNG_FILTER_TYPE_DEFAULT); 63 | 64 | rows = (png_byte**)png_malloc(png, img->height * sizeof(png_byte*)); 65 | line = img->cpPixels; 66 | for(y = 0; y < img->height; y++) { 67 | png_byte *row = (png_byte*)png_malloc(png, img->width * 3); 68 | rows[y] = row; 69 | for(x = 0; x < img->width; x++) { 70 | *row++ = line[x*4 + 0]; 71 | *row++ = line[x*4 + 1]; 72 | *row++ = line[x*4 + 2]; 73 | } 74 | line += img->stride; 75 | } 76 | 77 | png_init_io(png, f); 78 | png_set_rows(png, info, rows); 79 | png_write_png(png, info, PNG_TRANSFORM_IDENTITY, nil); 80 | 81 | for(y = 0; y < img->height; y++) 82 | png_free(png, rows[y]); 83 | png_free(png, rows); 84 | 85 | fail2: 86 | png_destroy_write_struct(&png, &info); 87 | fail1: 88 | fclose(f); 89 | } 90 | 91 | RwImage* 92 | psGrabScreen(RwCamera *cam) 93 | { 94 | RwRaster *ras = cam->frameBuffer; 95 | assert(ras); 96 | RwImage *img = RwImageCreate(ras->width, ras->height, 32); 97 | assert(ras); 98 | RwImageAllocatePixels(img); 99 | RwImageSetFromRaster(img, ras); 100 | return img; 101 | } 102 | 103 | void 104 | RwGrabScreen(RwCamera *cam) 105 | { 106 | char name[256]; 107 | RwImage *img = psGrabScreen(cam); 108 | CreateDirectory("snapshots", nil); 109 | sprintf(name, "snapshots/snap_%lld.png", time(nil)); 110 | writePNG(img, name); 111 | RwImageDestroy(img); 112 | } 113 | 114 | void (*RsCameraShowRaster_orig)(RwCamera *cam); 115 | void 116 | RsCameraShowRasterHook(RwCamera *cam) 117 | { 118 | { 119 | static bool keystate = false; 120 | if(GetAsyncKeyState(VK_SNAPSHOT) & 0x8000){ 121 | if(!keystate){ 122 | keystate = true; 123 | RwGrabScreen(cam); 124 | } 125 | }else 126 | keystate = false; 127 | } 128 | RsCameraShowRaster_orig(cam); 129 | } 130 | 131 | BOOL WINAPI 132 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 133 | { 134 | if(reason == DLL_PROCESS_ATTACH){ 135 | if(AddressByVersion(1, 0, 0, 1, 0, 0, 1)) 136 | InterceptCall(&RsCameraShowRaster_orig, RsCameraShowRasterHook, AddressByVersion(0x48D45C, 0, 0, 0x4A6168, 0, 0, 0x53EC01)); 137 | } 138 | return TRUE; 139 | } 140 | -------------------------------------------------------------------------------- /setfov.cpp: -------------------------------------------------------------------------------- 1 | #define _USE_MATH_DEFINES 2 | #pragma comment(lib, "user32") 3 | 4 | #include "windows.h" 5 | #include 6 | #include 7 | typedef uintptr_t uintptr; 8 | #include "MemoryMgr_all.h" 9 | 10 | typedef uint8_t uint8, uchar; 11 | typedef uint16_t uint16, ushort; 12 | typedef uint32_t uint32, uint; 13 | typedef uint64_t uint64; 14 | typedef int8_t int8; 15 | typedef int16_t int16; 16 | typedef int32_t int32; 17 | typedef int64_t int64; 18 | 19 | #define nil NULL 20 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 21 | 22 | #define RADTODEG(x) (float)(180.0f*(x)/M_PI) 23 | #define DEGTORAD(x) (float)((x)/180.0f*M_PI) 24 | 25 | 26 | int gtaversion = -1; 27 | 28 | struct GlobalScene 29 | { 30 | void *world; 31 | void *camera; 32 | }; 33 | GlobalScene &Scene = *AddressByVersion(0x726768, 0, 0, 0x8100B8, 0, 0, 0xC17038); 34 | 35 | float FOV = 70.0f; 36 | 37 | 38 | void 39 | patchAllFOV(void) 40 | { 41 | // cam on a string 42 | Patch(0x45C11A + 6, FOV); 43 | // follow ped 44 | Patch(0x45E531 + 6, FOV); 45 | // follow ped with mouse 46 | Patch(0x45FF88 + 6, FOV); 47 | // fight cam 48 | Patch(0x45D312 + 6, FOV); 49 | // debug (although overriden...) 50 | Patch(0x45CCF9 + 6, FOV); 51 | // syphon crim in front 52 | Patch(0x463A7B + 6, FOV); 53 | // special fixed for syphon 54 | Patch(0x463119 + 6, FOV); 55 | // syphon 56 | Patch(0x46313F + 6, FOV); 57 | // behind car (where is this used?) 58 | Patch(0x45BE6D + 6, FOV); 59 | // behind boat 60 | Patch(0x45B52E + 6, FOV); 61 | // fixed 62 | Patch(0x45DB6E + 6, FOV); 63 | 64 | // WS fix FOV control 65 | // Patch(0x513547, FOV); 66 | } 67 | 68 | float hFov2vFov(float hfov) 69 | { 70 | void *raster = FIELD(void*, Scene.camera, 0x60); 71 | float w = FIELD(float, raster, 0xC); 72 | float h = FIELD(float, raster, 0x10); 73 | 74 | // => tan(hFOV/2) = tan(vFOV/2)*aspectRatio 75 | // => tan(vFOV/2) = tan(hFOV/2)/aspectRatio 76 | float ar1 = 4.0/3.0; 77 | float ar2 = w/h; 78 | hfov = DEGTORAD(hfov); 79 | float vfov = atan(tan(hfov/2) / ar1) *2; 80 | hfov = atan(tan(vfov/2) * ar2) *2; 81 | return RADTODEG(hfov); 82 | } 83 | float &CDraw__ms_fFOV = *(float*)AddressByVersion(0x5FBC6C, 0, 0, 0x696658, 0, 0, 0x8D5038); 84 | void (*CDraw__SetFOV_hook)(float fov); 85 | void CDraw__SetFOV(float fov) 86 | { 87 | CDraw__ms_fFOV = hFov2vFov(fov); 88 | } 89 | void CDraw__SetFOV_chain(float fov) 90 | { 91 | CDraw__SetFOV_hook(hFov2vFov(fov)); 92 | } 93 | 94 | char dllName[MAX_PATH]; 95 | bool wasHooked; 96 | 97 | void 98 | patchIII10(void) 99 | { 100 | char *s, *t; 101 | s = strrchr(dllName, '_'); 102 | if(s == NULL) goto set; 103 | *s++ = '\0'; 104 | t = strchr(s, '.'); 105 | if(t == NULL) goto set; 106 | *t = '\0'; 107 | FOV = atoi(s); 108 | 109 | set: 110 | uint32 addr = 0x4FE7B0; 111 | // convert FOV to aspect ratio 112 | if(*(uint8*)addr == 0xE9){ 113 | // Sombody already overwrote SetFOV with a jump, we assume it was WS fix 114 | // this does not seem to work very well...peds don't spawn correctly, WHY? 115 | // ExtractCall(&CDraw__SetFOV_hook, addr); 116 | // InjectHook(addr, CDraw__SetFOV_chain, PATCH_JUMP); 117 | }else{ 118 | // ignore aspect ratio in CameraSize and use raster dimensions instead 119 | // otherwise hFov2vFov won't give expected results 120 | InjectHook(0x5272BA, 0x5272D2, PATCH_JUMP); 121 | 122 | InjectHook(addr, CDraw__SetFOV, PATCH_JUMP); 123 | } 124 | 125 | patchAllFOV(); 126 | } 127 | 128 | void 129 | patchVC10(void) 130 | { 131 | uint32 addr = 0x54A2E0; 132 | // convert FOV to aspect ratio 133 | if(*(uint8*)addr == 0xE9){ 134 | // Sombody already overwrote SetFOV with a jump, we assume it was WS fix 135 | }else{ 136 | // ignore aspect ratio in CameraSize and use raster dimensions instead 137 | // otherwise hFov2vFov won't give expected results 138 | InjectHook(0x580900, 0x580918, PATCH_JUMP); 139 | 140 | InjectHook(addr, CDraw__SetFOV, PATCH_JUMP); 141 | } 142 | } 143 | 144 | void 145 | patchSA10(void) 146 | { 147 | uint32 addr = 0x6FF410; 148 | // convert FOV to aspect ratio 149 | if(*(uint8*)addr == 0xE9){ 150 | // Sombody already overwrote SetFOV with a jump, we assume it was WS fix 151 | }else{ 152 | // ignore aspect ratio in CameraSize and use raster dimensions instead 153 | // otherwise hFov2vFov won't give expected results 154 | InjectHook(0x72FCFE, 0x72FD16, PATCH_JUMP); 155 | 156 | InjectHook(addr, CDraw__SetFOV, PATCH_JUMP); 157 | } 158 | } 159 | 160 | BOOL WINAPI 161 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 162 | { 163 | if(reason == DLL_PROCESS_ATTACH){ 164 | AddressByVersion(0, 0, 0, 0, 0, 0, 0); 165 | GetModuleFileName(hInst, dllName, MAX_PATH); 166 | switch(gtaversion){ 167 | case III_10: 168 | patchIII10(); 169 | break; 170 | case VC_10: 171 | patchVC10(); 172 | break; 173 | case SA_10: 174 | patchSA10(); 175 | break; 176 | } 177 | } 178 | 179 | return TRUE; 180 | } 181 | -------------------------------------------------------------------------------- /vehicleflare.cpp: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #include 3 | typedef uintptr_t uintptr; 4 | #include "MemoryMgr.h" // take from skygfx_vc 5 | 6 | typedef uint8_t uint8, uchar; 7 | typedef uint16_t uint16, ushort; 8 | typedef uint32_t uint32, uint; 9 | typedef uint64_t uint64; 10 | typedef int8_t int8; 11 | typedef int16_t int16; 12 | typedef int32_t int32; 13 | typedef int64_t int64; 14 | 15 | #define nil NULL 16 | #define FIELD(type, var, offset) *(type*)((uint8*)var + offset) 17 | 18 | 19 | int gtaversion = -1; 20 | 21 | void 22 | patchIII10(void) 23 | { 24 | // Taken from gta3d mod 25 | // feel free to experiment 26 | 27 | // 28 | // vehicle light flare 29 | // 30 | // probably leave these alone 31 | // Patch(0x537CA4+1, 2); 32 | // Patch(0x537DAB+1, 2); 33 | // Patch(0x537F35+1, 2); 34 | 35 | // light 0 1 36 | Patch(0x5384AD+1, 2); 37 | Patch(0x53856C+1, 2); 38 | Patch(0x538511+1, 2); 39 | Patch(0x5385CC+1, 2); 40 | // kinda paired with bright light; light 0 1 41 | // Patch(0x538AE5+1, 2); 42 | // Patch(0x538654+1, 2); 43 | // Patch(0x538777+1, 2); 44 | // Patch(0x5388A2+1, 2); 45 | // Patch(0x5389C5+1, 2); 46 | // kinda paired with bright light; light 2 3 47 | // Patch(0x5391F5+1, 2); 48 | // Patch(0x539244+1, 2); 49 | // Patch(0x5390B4+1, 2); 50 | // Patch(0x539155+1, 2); 51 | // Patch(0x538E31+1, 2); 52 | // Patch(0x538F4C+1, 2); 53 | // paired with bright light 54 | // Patch(0x539B49+1, 2); 55 | // Patch(0x539B9F+1, 2); 56 | // // paired with bright light 57 | // Patch(0x5399C5+1, 2); 58 | // Patch(0x539A1B+1, 2); 59 | } 60 | 61 | BOOL WINAPI 62 | DllMain(HINSTANCE hInst, DWORD reason, LPVOID) 63 | { 64 | if(reason == DLL_PROCESS_ATTACH){ 65 | AddressByVersion(0, 0, 0, 0, 0, 0); 66 | if (gtaversion == III_10) 67 | patchIII10(); 68 | } 69 | 70 | return TRUE; 71 | } 72 | --------------------------------------------------------------------------------