@@ -751,11 +751,14 @@ static __declspec(naked) void __cdecl WarnForDeprecatedCommands(void){
751751static const UInt32 kReportScriptError = 0x004FFF40 ;
752752static const UInt32 kDefaultCompilerCompileFormsArg = 0x00501A1A ;
753753static char kErrorCLimate [] = " Invalid Climate '%s' for parameter %s.\r\n Compiled script not saved!" ;
754+
755+
754756static __declspec (naked) void __cdecl HandleCustomTypes(void ) {
755757 __asm {
756758 cmp ecx, 0x27
757759 jne error
758-
760+ cmp [esp + 240h - 0Ch], 0
761+ jnz varSuccess
759762 push eax
760763 mov eax, [esp + 244h - 8h]
761764 test eax,eax
@@ -794,10 +797,61 @@ static __declspec(naked) void __cdecl HandleCustomTypes(void) {
794797 add esp, 0x10
795798 pop ebx
796799 jmp[kDefaultCompilerRetn ]
800+ varSuccess :
801+ jmp[kDefaultCompilerCompileFormsArg ]
802+
803+ }
804+ }
805+
806+ struct Unk {
807+ char unk00;
808+ char unk01;
809+ char unk02;
810+ char unk03;
811+ char unk04;
812+ char unk05;
813+ char unk06;
814+ char unk07;
815+ };
816+ static_assert (sizeof (Unk) == 8 );
817+
818+ static Unk* typeArray = (Unk*)0x009F128C ;
819+ static Unk* newTypeArray = new Unk[0x30 ];
820+
821+ static UInt32 kRetnTypeOverrideC = 0x00501077 ;
822+ static void __declspec (naked) TypeArrayOVerride(void ) {
823+ _asm{
824+ mov bl, byte ptr newTypeArray[eax * 8 ]
825+ jmp [kRetnTypeOverrideC ]
826+ }
827+ }
828+
829+ static UInt32 kRetnTypeOverride1 = 0x0050110F ;
830+ static UInt32 kRetnTypeOverride2 = 0x0050114E ;
831+
832+ static void __declspec (naked) TypeArrayOverride1(void ) {
833+ __asm {
834+ cmp byte ptr newTypeArray[eax*8 + 1 ],0
835+ jmp [kRetnTypeOverride1 ]
836+ }
837+ }
797838
839+ static void __declspec (naked) TypeArrayOverride2(void ) {
840+ __asm {
841+ cmp byte ptr newTypeArray[eax * 8 + 1 ], 0
842+ jmp[kRetnTypeOverride2 ]
798843 }
799844}
800845
846+ static UInt32 kRetnTypeOverride3 = 0x00458D48 ;
847+ static void __declspec (naked) TypeArrayOverride3(void ) {
848+ __asm {
849+ mov al, byte ptr newTypeArray[eax * 8 + 1 ]
850+ jmp[kRetnTypeOverride3 ]
851+ }
852+ }
853+
854+
801855void Hook_Compiler_Init ()
802856{
803857 // hook beginning of compilation process
@@ -812,8 +866,19 @@ void Hook_Compiler_Init()
812866 WriteRelJump (kExpressionParserBufferOverflowHookAddr_1 , (UInt32)&ExpressionParserBufferOverflowHook_1);
813867 WriteRelJump (kExpressionParserBufferOverflowHookAddr_2 , (UInt32)&ExpressionParserBufferOverflowHook_2);
814868 WriteRelJump (kDefaultCompilerHook , (UInt32)&HandleCustomTypes);
815-
869+ _MESSAGE (" %u %u %u" , typeArray[0x23 ].unk00 , typeArray[0x25 ].unk00 , typeArray[0x21 ].unk00 );
870+ _MESSAGE (" %u %u %u" , typeArray[0x23 ].unk01 , typeArray[0x25 ].unk01 , typeArray[0x21 ].unk01 );
816871 CompilerOverride::InitHooks ();
872+ memset (newTypeArray, 0 , 0x30 * 8 );
873+ memcpy (newTypeArray, typeArray, 0x26 * 8 );
874+ // newTypeArray[0x27].unk01 = 0;
875+ _MESSAGE (" %u %u %u %u" , newTypeArray[0x23 ].unk00 , newTypeArray[0x25 ].unk00 , newTypeArray[0x27 ].unk00 , newTypeArray[0x26 ].unk00 );
876+ _MESSAGE (" %u %u %u %u" , newTypeArray[0x23 ].unk01 , newTypeArray[0x25 ].unk01 , newTypeArray[0x27 ].unk01 , newTypeArray[0x26 ].unk01 );
877+ WriteRelJump (0x00501070 , (UInt32)&TypeArrayOVerride);
878+ WriteRelJump (0x00501107 , (UInt32)&TypeArrayOverride1);
879+ WriteRelJump (0x00501146 , (UInt32)&TypeArrayOverride2);
880+ WriteRelJump (0x00458D41 , (UInt32)&TypeArrayOverride3);
881+
817882}
818883
819884#else // run-time
0 commit comments