Ejemplo n.º 1
0
        public static void UnloadCargo(bool force)
        {
            if (_mCargo == null)
            {
                NFinalizeDeath.Assert("UnloadCargo: _mCargo is null.");
                return;
            }

            if (force || GameStates.IsTravelling)
            {
                foreach (FieldInfo item in new List <FieldInfo>(_mCargo.Keys))
                {
                    if (item == null)
                    {
                        continue;
                    }

                    try
                    {
                        item.SetValue(null, _mCargo[item]);
                    }
                    catch (Exception)
                    {
                        niec_native_func.OutputDebugString("Failed to SetValue() Type: " + typeof(T).ToString() + " | T: " + item.FieldType + " | Name: " + item.Name);
                    }

                    _mCargo[item] = null;
                }
            }
        }
Ejemplo n.º 2
0
 internal static void assert(string message)
 {
     NFinalizeDeath.Assert(message);
 }
Ejemplo n.º 3
0
        public unsafe static void init_class()
        {
            if (NFinalizeDeath.GameIs64Bit(false))
            {
                throw new NotSupportedException("Sims 3 64 bit version not supported.");
            }

#if !GameVersion_0_Release_2_0_209
            throw new NotSupportedException("Game versions not supported. Only Patch 1.67.2");
#else
            if (done_init_class)
            {
                return;
            }

            done_init_class = true;

            var type = typeof(niec_native_func);
            var m01  = (MonoMethod)type.GetMethod("niecmod_native_load_library", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            //uint* at = (uint*)0;
            uint func_address = 0;
            int  tem          = 0;

            if (m01 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_load_library\") failed");
                done_init_class = false;
                goto skip2;
            }

            //at = (uint*)((int)m01.mhandle.obj_address());
            tem = native00.Length + native00.Length
                  - 0x32;

            var native00_address = (uint)native00.obj_address();
            func_address = native00_address + 0x14;


            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native00_address + i) = 0xCCCCCCCC;
            }

            native00.obj_address(); // check SIGSEGV

            *(uint *)(func_address)        = NFinalizeDeath.SwapOrgerBit32(0x908B5C24u);
            *(uint *)(func_address + 0x4)  = NFinalizeDeath.SwapOrgerBit32(0x0483C308u);
            *(uint *)(func_address + 0x8)  = NFinalizeDeath.SwapOrgerBit32(0x53FF1580u);
            *(uint *)(func_address + 0xC)  = NFinalizeDeath.SwapOrgerBit32(0x62F90090u);
            *(uint *)(func_address + 0x10) = NFinalizeDeath.SwapOrgerBit32(0xC3909090u);

            cache_done_niecmod_native_load_library =
                niec_script_func.niecmod_script_set_custom_native_function(m01.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////////////////////////////

skip2:
            var m02 = (MonoMethod)type.GetMethod("niecmod_native_debug_text_to_debugger", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m02 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_debug_text_to_debugger\") failed");
                done_init_class = false;
                goto skip3;
            }

            //at = (uint*)((int)m02.mhandle.obj_address());
            tem = native01.Length + native01.Length
                  - 0x32;

            var native01_address = (uint)native01.obj_address();
            func_address = native01_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native01_address + i) = 0xCCCCCCCC;
            }

            native01.obj_address(); // check SIGSEGV

            *(uint *)(func_address)        = NFinalizeDeath.SwapOrgerBit32(0x608B4C24u);
            *(uint *)(func_address + 0x4)  = NFinalizeDeath.SwapOrgerBit32(0x2483C108u);
            *(uint *)(func_address + 0x8)  = NFinalizeDeath.SwapOrgerBit32(0x51FF1514u);
            *(uint *)(func_address + 0xC)  = NFinalizeDeath.SwapOrgerBit32(0x63F90061u);
            *(uint *)(func_address + 0x10) = NFinalizeDeath.SwapOrgerBit32(0xC3909090u);

            cache_done_niecmod_native_debug_text_to_debugger =
                niec_script_func.niecmod_script_set_custom_native_function(m02.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////////////////////////////

skip3:
            var m03 = (MonoMethod)type.GetMethod("IsDebuggerAttached_internal", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m03 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"IsDebuggerAttached_internal\") failed");
                goto skip4;
            }

            tem = native02.Length + native02.Length
                  - 0x32;

            var native02_address = (uint)native02.obj_address();
            func_address = native02_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native02_address + i) = 0xCCCCCCCC;
            }

            native02.obj_address(); // check SIGSEGV

            *(uint *)(func_address)       = NFinalizeDeath.SwapOrgerBit32(0x64A13000u);
            *(uint *)(func_address + 0x4) = NFinalizeDeath.SwapOrgerBit32(0x00000FB6u);
            *(uint *)(func_address + 0x8) = NFinalizeDeath.SwapOrgerBit32(0x4002C390u);

            cache_done_IsDebuggerAttached_internal =
                niec_script_func.niecmod_script_set_custom_native_function(m03.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip4:
            var m04 = (MonoMethod)type.GetMethod("DebuggerBreak", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m04 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"DebuggerBreak\") failed");
                goto skip5;
            }

            tem = native03.Length + native03.Length
                  - 0x32;

            var native03_address = (uint)native03.obj_address();
            func_address = native03_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native03_address + i) = 0xCCCCCCCC;
            }

            native03.obj_address(); // check SIGSEGV

            *(uint *)(func_address) = NFinalizeDeath.SwapOrgerBit32(0xCCC3CCCCu);

            cache_done_IsDebuggerBreak_internal =
                niec_script_func.niecmod_script_set_custom_native_function(m04.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip5:
            var m05 = (MonoMethod)type.GetMethod("niecmod_native_ptr_fs_zero", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m05 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_ptr_fs_zero\") failed");
                goto skip6;
            }

            tem = native04.Length + native04.Length
                  - 0x32;

            var native04_address = (uint)native04.obj_address();
            func_address = native04_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native04_address + i) = 0xCCCCCCCC;
            }

            native04.obj_address(); // check SIGSEGV

            *(uint *)(func_address)       = NFinalizeDeath.SwapOrgerBit32(0x8B5C2404u);
            *(uint *)(func_address + 0x4) = NFinalizeDeath.SwapOrgerBit32(0x648B0331u);
            *(uint *)(func_address + 0x8) = NFinalizeDeath.SwapOrgerBit32(0xDBC3CCCCu);

            cache_done_niecmod_native_ptr_fs_zero =
                niec_script_func.niecmod_script_set_custom_native_function(m05.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip6:
            var m06 = (MonoMethod)type.GetMethod("niecmod_native_message_box", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m06 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_message_box\") failed");
                goto skip7;
            }

            tem = native05.Length + native05.Length
                  - 0x32;

            var native05_address = (uint)native05.obj_address();
            func_address = native05_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native05_address + i) = 0xCCCCCCCC;
            }

            native05.obj_address(); // check SIGSEGV

            byte[] nativefunc_messagebox =
            {
                0x8B, 0x5C, 0x24, 0x08, 0x83, 0xC3, 0x08, 0x89, 0x5C, 0x24, 0x08, 0x8B,
                0x5C, 0x24, 0x0C, 0x83, 0xC3, 0x08, 0x89, 0x5C, 0x24, 0x0C, 0x83, 0xEC,
                0x08, 0x8B, 0x5C, 0x24, 0x08, 0x89, 0x5C, 0x24, 0x04, 0xFF, 0x74, 0x24,
                0x18, 0xFF, 0x74, 0x24, 0x18, 0xFF, 0x74, 0x24, 0x18, 0xFF, 0x74, 0x24,
                0x18, 0xFF, 0x15, 0x00, 0x68, 0xF9, 0x00, 0x83, 0xC4, 0x08, 0xC3, 0xCC
            };

            for (int i = 0; i < nativefunc_messagebox.Length; i++)
            {
                *(byte *)(func_address + i) = nativefunc_messagebox[i];
            }

            cache_done_niecmod_native_message_box =
                niec_script_func.niecmod_script_set_custom_native_function(m06.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip7:
            var m07 = (MonoMethod)type.GetMethod("niecmod_native_cpuid", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m07 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_cpuid\") failed");
                goto skip8;
            }

            tem = native06.Length + native06.Length
                  - 0x32;

            var native06_address = (uint)native06.obj_address();
            func_address = native06_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native06_address + i) = 0xCCCCCCCC;
            }

            native06.obj_address(); // check SIGSEGV

            byte[] nativefunc_cpuid =
            {
                0x60, 0x8B, 0x44, 0x24, 0x24, 0x8B, 0x5C, 0x24, 0x28, 0x8B, 0x4C, 0x24,
                0x2C, 0x8B, 0x54, 0x24, 0x30, 0x8B, 0x00, 0x8B, 0x1B, 0x8B, 0x09, 0x8B,
                0x12, 0x0F, 0xA2, 0x55, 0x89, 0xE5, 0x83, 0xEC, 0x10, 0x89, 0x04, 0x24,
                0x89, 0x5C, 0x24, 0x04, 0x89, 0x4C, 0x24, 0x08, 0x89, 0x54, 0x24, 0x0C,
                0x8B, 0x44, 0x24, 0x38, 0x8B, 0x5C, 0x24, 0x3C, 0x8B, 0x4C, 0x24, 0x40,
                0x8B, 0x54, 0x24, 0x44, 0x8B, 0x3C, 0x24, 0x89, 0x38, 0x8B, 0x7C, 0x24,
                0x04, 0x89, 0x3B, 0x8B, 0x7C, 0x24, 0x08, 0x89, 0x39, 0x8B, 0x7C, 0x24,
                0x0C, 0x89, 0x3A, 0x83, 0xC4, 0x10, 0x5D, 0x61, 0xC3
            };

            for (int i = 0; i < nativefunc_cpuid.Length; i++)
            {
                *(byte *)(func_address + i) = nativefunc_cpuid[i];
            }

            cache_done_niecmod_native_cpuid =
                niec_script_func.niecmod_script_set_custom_native_function(m07.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip8:
            var m08 = (MonoMethod)type.GetMethod("niecmod_native_file_create", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m08 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_file_create\") failed");
                goto skip9;
            }

            tem = native07.Length + native07.Length
                  - 0x32;

            var native07_address = (uint)native07.obj_address();
            func_address = native07_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native07_address + i) = 0xCCCCCCCC;
            }

            native07.obj_address(); // check SIGSEGV

            byte[] createfile_func =
            {
                0x8B, 0x5C, 0x24, 0x04, 0x83, 0xC3, 0x08, 0x90, 0x90, 0x90, 0x90, 0x90,
                0x90, 0x90, 0x31, 0xC0, 0x50, 0x68, 0x00, 0x00, 0x00, 0x80, 0x6A, 0x02,
                0x50, 0x6A, 0x03, 0x68, 0x00, 0x00, 0x00, 0x40, 0x53, 0x90, 0x90, 0x90,
                0x90, 0xFF, 0x15, 0x54, 0x63, 0xF9, 0x00, 0x31, 0xDB, 0xC3, 0x90, 0x90,
                0x90, 0x90, 0x90, 0x90
            };

            for (int i = 0; i < createfile_func.Length; i++)
            {
                *(byte *)(func_address + i) = createfile_func[i];
            }

            cache_done_niecmod_native_file_create =
                niec_script_func.niecmod_script_set_custom_native_function(m08.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip9:
            var m09 = (MonoMethod)type.GetMethod("niecmod_native_file_writetext", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m09 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_file_writetext\") failed");
                goto skip10;
            }

            tem = native08.Length + native08.Length
                  - 0x32;

            var native08_address = (uint)native08.obj_address();
            func_address = native08_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native08_address + i) = 0xCCCCCCCC;
            }

            native08.obj_address(); // check SIGSEGV

            byte[] writetext_func =
            {
                0x8B, 0x44, 0x24, 0x08, 0x83, 0xC0, 0x08, 0x8B, 0x5C, 0x24, 0x08, 0x83,
                0xC3, 0x04, 0x8B, 0x1B, 0x01, 0xDB, 0x90, 0x90, 0x90, 0x31, 0xD2, 0x52,
                0x52, 0x53, 0x50, 0xFF, 0x74, 0x24, 0x14, 0xFF, 0x15, 0x94, 0x63, 0xF9,
                0x00, 0xC3
            };

            for (int i = 0; i < writetext_func.Length; i++)
            {
                *(byte *)(func_address + i) = writetext_func[i];
            }

            cache_done_niecmod_native_file_writetext =
                niec_script_func.niecmod_script_set_custom_native_function(m09.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip10:
            var m10 = (MonoMethod)type.GetMethod("niecmod_native_file_write", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m10 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_file_write\") failed");
                goto skip11;
            }

            tem = native09.Length + native09.Length
                  - 0x32;

            var native09_address = (uint)native09.obj_address();
            func_address = native09_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native09_address + i) = 0xCCCCCCCC;
            }

            native09.obj_address(); // check SIGSEGV

            byte[] write_func =
            {
                0x31, 0xDB, 0x53, 0x53, 0xFF, 0x74, 0x24, 0x14, 0xFF, 0x74, 0x24, 0x14,
                0xFF, 0x74, 0x24, 0x14, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
                0x90, 0x90, 0x90, 0x90, 0x90, 0xFF, 0x15, 0x94, 0x63, 0xF9, 0x00, 0xC3
            };

            for (int i = 0; i < write_func.Length; i++)
            {
                *(byte *)(func_address + i) = write_func[i];
            }

            cache_done_niecmod_native_file_write =
                niec_script_func.niecmod_script_set_custom_native_function(m10.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

skip11:
            var m11 = (MonoMethod)type.GetMethod("niecmod_native_file_close", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (m11 == null)
            {
                NFinalizeDeath.Assert("type.GetMethod(\"niecmod_native_file_close\") failed");
                throw new NotSupportedException();
            }

            tem = native10.Length + native10.Length
                  - 0x32;

            var native10_address = (uint)native10.obj_address();
            func_address = native10_address + 0x14;

            for (int i = 0x10; i < tem; i++)
            {
                *(uint *)(native10_address + i) = 0xCCCCCCCC;
            }

            native10.obj_address(); // check SIGSEGV

            byte[] fileclose_func =
            {
                0xFF, 0x74, 0x24, 0x04, 0x90, 0xFF, 0x15, 0x9C, 0x63, 0xF9, 0x00, 0xC3
            };

            for (int i = 0; i < fileclose_func.Length; i++)
            {
                *(byte *)(func_address + i) = fileclose_func[i];
            }

            cache_done_niecmod_native_file_close =
                niec_script_func.niecmod_script_set_custom_native_function(m11.mhandle, new IntPtr()
            {
                value = (void *)func_address
            });

            ////////////////////////////////////////////////////////////////////////////////

            if (m01 != null)
            {
                OutputDebugString("niecmod_native_load_library: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m01.mhandle).ToString("X"));
            }
            if (m02 != null)
            {
                OutputDebugString("niecmod_native_debug_text_to_debugger: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m02.mhandle).ToString("X"));
            }
            if (m03 != null)
            {
                OutputDebugString("IsDebuggerAttached_internal: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m03.mhandle).ToString("X"));
            }
            if (m04 != null)
            {
                OutputDebugString("DebuggerBreak: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m04.mhandle).ToString("X"));
            }
            if (m05 != null)
            {
                OutputDebugString("niecmod_native_ptr_fs_zero: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m05.mhandle).ToString("X"));
            }
            if (m06 != null)
            {
                OutputDebugString("niecmod_native_message_box: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m06.mhandle).ToString("X"));
            }
            if (m07 != null)
            {
                OutputDebugString("niecmod_native_cpuid: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m07.mhandle).ToString("X"));
            }
            if (m08 != null)
            {
                OutputDebugString("niecmod_native_file_create: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m08.mhandle).ToString("X"));
            }
            if (m09 != null)
            {
                OutputDebugString("niecmod_native_file_writetext: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m09.mhandle).ToString("X"));
            }
            if (m10 != null)
            {
                OutputDebugString("niecmod_native_file_write: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m10.mhandle).ToString("X"));
            }
            if (m11 != null)
            {
                OutputDebugString("niecmod_native_file_close: func_address: 0x" + niec_script_func.niecmod_script_get_func_ptr(m11.mhandle).ToString("X"));
            }
#endif // GameVersion_0_Release_2_0_209
        }
Ejemplo n.º 4
0
        void StartUpSafeErrorTrapAdded()
        {
            if (NSC_ETRAP.IsDone)
            {
                return;
            }

            if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || ShouldACoreScipt2020())
            {
                NiecTask.Perform(delegate
                {
                    if (!NFinalizeDeath.GameIs64Bit(true) && ShouldACoreScipt2020() && !NiecHelperSituation.isdgmods)
                    {
                        if (!NFinalizeDeath.DoneSafePreventGetAssembliesPro && NFinalizeDeath.func_address_GetAssemblies != 0)
                        {
                            NFinalizeDeath.RemovePreventGetAssemblies();
                        }

                        Type.GetType("NRaas.Common, NRaasErrorTrap").GetMethod("OnPreLoad", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(null, new object[0]);

                        var p = Type.GetType("NRaas.ErrorTrap, NRaasErrorTrap");
                        if (p == null)
                        {
                            NFinalizeDeath.Assert("Type.GetType(\"NRaas.ErrorTrap, NRaasErrorTrap\"); == null");
                            goto faled;
                        }
                        else
                        {
                            var m = p.GetMethod("OnScriptError", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                            if (m != null)
                            {
                                var myM = typeof(SCOSR).GetMethod("OnScriptError", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

                                dontcall = true;
                                OnScriptError(null, null);
                                dontcall = false;

                                // Required if no create method pointer.
                                Delegate.CreateDelegate(typeof(SCOSR._SafeScriptError), m);

                                if (!niec_script_func.niecmod_script_copy_ptr_func_to_func(myM, m, false, false, true, false))
                                {
                                    goto faled;
                                }
                            }
                            else
                            {
                                goto faled;
                            }
                        }
                        _SafeOnScriptError = null;
                        DoneSafeErrorTrap  = true;
                        ShouldInjectedMethodOnScriptError = true;
                        if (NiecHelperSituation.___bOpenDGSIsInstalled_)
                        {
                            SetBoolScriptCore2020(false, false, false);
                        }
                        else
                        {
                            SetBoolScriptCore2020(AssemblyCheckByNiec.IsInstalled("AweCore"), true, true);
                        }
                        return;
                    }
                    faled:
                    for (int i = 0; i < 100; i++)
                    {
                        Simulator.Sleep(0);
                    }
                    if (!DoneSafeErrorTrap && AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap"))
                    {
                        Type.GetType("NRaas.Common, NRaasErrorTrap").GetMethod("OnPreLoad", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(null, new object[0]);
                    }
                    if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap"))
                    {
                        Type type = Type.GetType("ScriptCore.ExceptionTrap, ScriptCore", true);
                        if (type != null)
                        {
                            FieldInfo mField = type.GetField("OnScriptError", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                            if (mField != null)
                            {
                                MethodInfo mf = (mField.GetValue(null) as MulticastDelegate).method_info;
                                if (mf != null)
                                {
                                    NFinalizeDeath.sIs_m_OnScriptError = typeof(SCOSR).GetMethod("OnScriptError");
                                    if (mf == typeof(SCOSR).GetMethod("OnScriptError") || mf.DeclaringType == typeof(SCOSR))
                                    {
                                        DoneSafeErrorTrap = true;
                                    }
                                    else
                                    {
                                        SCOSR._SafeOnScriptError = (SCOSR._SafeScriptError)Delegate.CreateDelegate(typeof(SCOSR._SafeScriptError), mf);
                                        type = Type.GetType("ScriptCore.ExceptionTrap+ScriptError, ScriptCore", true);
                                        if (type != null)
                                        {
                                            mf = typeof(SCOSR).GetMethod("OnScriptError");
                                            if (mf != null)
                                            {
                                                mField.SetValue(null, Delegate.CreateDelegate(type, mf));
                                                DoneSafeErrorTrap = true;
                                                if (NiecHelperSituation.___bOpenDGSIsInstalled_)
                                                {
                                                    SetBoolScriptCore2020(false, false, false);
                                                }
                                                else
                                                {
                                                    SetBoolScriptCore2020(AssemblyCheckByNiec.IsInstalled("AweCore"), true, mField.GetValue(null) != null);
                                                }
                                                if (mField.GetValue(null) == null)
                                                {
                                                    NiecException.WriteLog("StartUpSafeErrorTrapAdded() Found mField.GetValue(null) == null");
                                                }
                                            }
                                            else
                                            {
                                                throw new NotSupportedException("OnScriptError not find");
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    NiecException.WriteLog("if (mf == null)");
                                }
                            }
                            else
                            {
                                throw new NotSupportedException("OnScriptError not find");
                            }
                        }
                    }
                });
            }
        }
Ejemplo n.º 5
0
        // public static Sim Aora => null;
        public override bool Run()
        {
            if (!Simulator.CheckYieldingContext(false))
            {
                return(false);
            }
            var definition = InteractionDefinition as Definition;

            NFinalizeDeath.Assert(definition != null, "InteractionDefinition as KillInLotCurrent.Definition Failed!");
            var deathType = definition != null ? definition.death : SimDescription.DeathType.Drown;

            if (Autonomous || Actor != PlumbBob.SelectedActor)
            {
                return(false);
            }
            if (!NFinalizeDeath.CheckAccept("Are You Sure MineKill Lot Current Get Sims?"))
            {
                return(false);
            }

            try
            {
                //var list = new List<Sim>();
                foreach (Sim sim in NFinalizeDeath.SC_GetObjectsOnLot <Sim>(Target.LotCurrent)) //Target.LotCurrent.GetAllActors())
                {
                    if (NiecHelperSituation.SimHasBeenDestroyed(sim))
                    {
                        if (NFinalizeDeath.ForceDestroyObject(sim, false))
                        {
                            continue;
                        }
                    }
                    if (sim != null && sim.SimDescription != null && !NFinalizeDeath.IsAllActiveHousehold_SimObject(sim) && !(sim.Service is GrimReaper))
                    {
                        //list.Add(sim);

                        if (sim.mInteractionQueue == null)
                        {
                            sim.mInteractionQueue = new Sims3.Gameplay.ActorSystems.InteractionQueue(sim);
                        }
                        if (NFinalizeDeath.IsOpenDGSInstalled)
                        {
                            KillPro.FastKill(sim, deathType, Actor, true, false);
                        }
                        else
                        {
                            var createKillSim = NFinalizeDeath.Interaction_CreateKillSim(sim, deathType);
                            if (createKillSim == null)
                            {
                                continue;
                            }
                            sim.mInteractionQueue.Add(createKillSim);
                        }
                    }
                }
                //if (list.Count > 0)
                //{
                //    foreach (Sim nlist in list)
                //    {
                //        KillPro.FastKill(nlist, definition.death, Actor, true, false);
                //        //KillSimNiecX.MineKill(nlist, definition.death, null, true, false);
                //    }
                //}
                return(true);
            }

            catch (Exception exception)
            {
                NiecException.PrintMessage(exception.Message + NiecException.NewLine + exception.StackTrace);
                return(true);
            }
        }
Ejemplo n.º 6
0
        public static bool _InjectMethod()
        {
            __dontcall = true;
            get_instance <BimDesc>().sc_set_logic(null, false);
            get_instance <Bim>().SCP_onscripterror(null);
            get_instance <NJOClass>().script_proxy_simulate();
            get_instance <nobjecoD>().sc_post_Load();
            get_instance <NiecModException>().sc_create_Logic(null);
            get_instance <NiecObjectPlus>().sc_dispose();
            get_instance <NiecPosture>().sc_on_reset();
            get_instance <NiecHelperSituationPosture>().sc_try_create_Logic(null);
            get_instance <NiecHelperSituation>().sc_restore_saved_task_context();
            __dontcall = false;

            ScriptCore.ScriptProxy obj = null;
            if (obj != null)
            {
                obj.SetLogic(null, false);
                obj.OnScriptError(null);
                obj.Simulate();
                obj.PostLoad();
                obj.CreateLogic(null);
                obj.Dispose();
                obj.OnReset();
                obj.TryCreateLogic(null);
                obj.RestoreSavedTaskContext();
            }

            var m00 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("sc_set_logic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m00 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"sc_set_logic\"); is null.");
                return(false);
            }
            var m01 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("SCP_onscripterror", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m01 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"SCP_onscripterror\"); is null.");
                return(false);
            }
            var m02 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("script_proxy_simulate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m02 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"script_proxy_simulate\"); is null.");
                return(false);
            }
            var m03 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("sc_post_Load", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m03 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"sc_post_Load\"); is null.");
                return(false);
            }
            var m04 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("sc_create_Logic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m04 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"sc_create_Logic\"); is null.");
                return(false);
            }
            var m05 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("sc_dispose", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m05 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"sc_dispose\"); is null.");
                return(false);
            }
            var m06 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("sc_on_reset", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m06 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"sc_on_reset\"); is null.");
                return(false);
            }
            var m07 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("sc_try_create_Logic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m07 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"sc_try_create_Logic\"); is null.");
                return(false);
            }
            var m08 = (MonoMethod)typeof(NSC_ETRAP).GetMethod("sc_restore_saved_task_context", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m08 == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(NSC_ETRAP).GetMethod(\"sc_restore_saved_task_context\"); is null.");
                return(false);
            }
            //////////
            var m00_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("SetLogic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(IScriptLogic), typeof(bool) }, null);

            if (m00_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"SetLogic\"); is null.");
                return(false);
            }
            var m01_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("OnScriptError", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m01_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"OnScriptError\"); is null.");
                return(false);
            }
            var m02_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("Simulate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m02_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"Simulate\"); is null.");
                return(false);
            }
            var m03_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("PostLoad", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m03_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"PostLoad\"); is null.");
                return(false);
            }
            var m04_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("CreateLogic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m04_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"CreateLogic\"); is null.");
                return(false);
            }
            var m05_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("Dispose", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m05_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"Dispose\"); is null.");
                return(false);
            }
            var m06_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("OnReset", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m06_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"OnReset\"); is null.");
                return(false);
            }
            var m07_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("TryCreateLogic", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m07_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"TryCreateLogic\"); is null.");
                return(false);
            }
            var m08_i = (MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod("RestoreSavedTaskContext", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (m08_i == null)
            {
                NFinalizeDeath.Assert("(MonoMethod)typeof(ScriptCore.ScriptProxy).GetMethod(\"RestoreSavedTaskContext\"); is null.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m00, m00_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m00, m00_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m01, m01_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m01, m01_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m02, m02_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m02, m02_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m03, m03_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m03, m03_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m04, m04_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m04, m04_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m05, m05_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m05, m05_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m06, m06_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m06, m06_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m07, m07_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m07, m07_i) failed.");
                return(false);
            }
            if (!NiecMod.Nra.niec_script_func.niecmod_script_copy_ptr_func_to_func(m08, m08_i, false, false, false, false))
            {
                NiecMod.Nra.NFinalizeDeath.Assert("NSC_ETRAP: copy_ptr_func_to_func(m08, m08_i) failed.");
                return(false);
            }
            return(true);
        }