|
10 | 10 | #include "Utils.hpp" |
11 | 11 | #include "Features/OverlayRender.hpp" |
12 | 12 |
|
| 13 | +#define RENDERCONTEXT_ALLOC_SIZE 0x672000 // 6.45 MB |
| 14 | + |
13 | 15 | class MemTexRegen : public ITextureRegenerator { |
14 | 16 | uint8_t *bgra; |
15 | 17 | int w, h; |
@@ -92,10 +94,29 @@ bool MaterialSystem::Init() { |
92 | 94 | OverlayRender::initMaterials(); |
93 | 95 | } |
94 | 96 |
|
| 97 | + this->renderContextSize = Memory::Scan<uint32_t *>(this->Name(), Offsets::RenderContextSize, Offsets::RenderContextSizeOff); |
| 98 | + this->RenderContextShutdown = Memory::Scan<_RenderContextShutdown>(this->Name(), Offsets::RenderContextShutdown); |
| 99 | + this->RenderContextInit = Memory::Scan<_RenderContextInit>(this->Name(), Offsets::RenderContextInit); |
| 100 | + if (this->renderContextSize && this->RenderContextShutdown && this->RenderContextInit) { |
| 101 | + if (*this->renderContextSize != RENDERCONTEXT_ALLOC_SIZE) { |
| 102 | + Memory::UnProtect((void *)this->renderContextSize, sizeof(uint32_t)); |
| 103 | + this->origRenderContextSize = *this->renderContextSize; |
| 104 | + *this->renderContextSize = RENDERCONTEXT_ALLOC_SIZE; |
| 105 | + this->RenderContextShutdown(); |
| 106 | + this->RenderContextInit(); |
| 107 | + } |
| 108 | + } |
| 109 | + |
95 | 110 | return this->hasLoaded = this->materials; |
96 | 111 | } |
97 | 112 | void MaterialSystem::Shutdown() { |
98 | 113 | Interface::Delete(this->materials); |
| 114 | + |
| 115 | + if (origRenderContextSize) { |
| 116 | + *renderContextSize = origRenderContextSize; |
| 117 | + RenderContextShutdown(); |
| 118 | + RenderContextInit(); |
| 119 | + } |
99 | 120 | } |
100 | 121 | IMaterial *MaterialSystem::FindMaterial(const char *materialName, const char *textureGroupName) { |
101 | 122 | auto func = (IMaterial *(__rescall *)(void *, const char *, const char *, bool, const char *))this->materials->Current(Offsets::FindMaterial); |
|
0 commit comments