Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Lab Assistant
Original Poster
#1 Old 8th Nov 2014 at 11:23 AM Last edited by ArtUrlWWW : 8th Nov 2014 at 1:48 PM.
Default [SOLVED] Strange style of programming in NRAAS mods.
Hello.
In NRaas.MasterControllerSpace.Sims.Advanced.AdjustAutonomy has code, what changes private field
autonomy.mAutonomyDisabledCount
I understand, what in repository https://github.com/Chain-Reaction/NRaas has DLLs with patched game DLL's - with changed private fields to public. OK, it's correct and I can compile NRaasMasterController.dll . I have original NRAAS mods, what I have download -
NRaas_StoryProgression.package
NRaas_MasterController.package
NRaas_Overwatch.package
NRaas_MasterControllerCheats.package
NRaas_Mover.package
NRaas_Decensor.package
NRaas_MasterControllerIntegration.package
NRaas_MasterControllerProgression.package
As I understand, I must put to the NRaas_MasterControllerCheats.package not only NRaasMasterController.dll , but also I must put 0x03D6C8D903CE868C_Sims3GameplaySystems.dll to the package, because 0x03D6C8D903CE868C_Sims3GameplaySystems.dll - is the patched version of the game DLL. It's all OK. I understand it.
But I can't understand only one thing - in original NRAAS packages - NRaas_MasterController.package and NRaas_MasterControllerCheats.package has no S3SA with patched 0x03D6C8D903CE868C_Sims3GameplaySystems.dll ! Only S3SA for NRaasMasterController.dll and S3SA for NRaasMasterControllerCheats.dll . Where is in original NRAAS packages package, what contains patched DLL 0x03D6C8D903CE868C_Sims3GameplaySystems.dll ?
How works this magic? If no package with patched DLL's in mods dir, then must me catched Exception in game, when NRaasMasterController.dll will try to access private field in original game DLL!
You can test it. Create first C# class library project libDLL and make class
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace libDLL
{
    public class Class1
    {
        public int a = 0;
    }
}

in it.
Create second C# project - Windows application and make code in it:
Code:
using libDLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Class1 cl1 = new Class1();
            cl1.a = 500000;
            MessageBox.Show(this, "XXX " + cl1.a);
        }
    }
}


Compile and run it - it will be OK and MessageBox will shown.
After it in DLL library change public modifier of the in variable to the private modifier.
Code:
 
using System;
using System.Collections.Generic;
using System.Text;

namespace libDLL
{
    public class Class1
    {
        private int a = 0;
    }
}

Compile DLL and put it in dir, where located compiled exe. Try to start exe. It will get Exception on putton press:
Code:
System.FieldAccessException: libDLL.Class1.a
   в WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e)
   в System.Windows.Forms.Control.OnClick(EventArgs e)
   в System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   в System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   в System.Windows.Forms.Control.WndProc(Message& m)
   в System.Windows.Forms.ButtonBase.WndProc(Message& m)
   в System.Windows.Forms.Button.WndProc(Message& m)
   в System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   в System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


But it's doesn't happend in game in NRAAS mods and mods works correctly...

Can you explain to me, how it's work?

Best regards, Arthur.
Advertisement
1978 gallons of pancake batter
#2 Old 8th Nov 2014 at 12:43 PM
TS3 uses a version of the MONO portable framework that doesn't check visibility etc. during run time. Because of that, you can access private fields, inherit from sealed classes, assign readonly fields, change the access modifier in overriden members etc. All the forbidden stuff. The compiler wouldn't let something like that slide, though, so you need modified game libraries to get that code to compile. Once compiled it runs in TS3 no problem.

Just don't try a stunt like that in the .NET CLR.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Lab Assistant
Original Poster
#3 Old 8th Nov 2014 at 1:48 PM
Thank you!
Test Subject
#4 Old 10th Nov 2014 at 2:09 AM
Quote: Originally posted by Buzzler
TS3 uses a version of the MONO portable framework that doesn't check visibility etc. during run time. Because of that, you can access private fields, inherit from sealed classes, assign readonly fields, change the access modifier in overriden members etc. All the forbidden stuff. The compiler wouldn't let something like that slide, though, so you need modified game libraries to get that code to compile. Once compiled it runs in TS3 no problem.

Just don't try a stunt like that in the .NET CLR.


Any link where we can pick up such modified libraries? Thanks!
Inventor
#5 Old 10th Nov 2014 at 10:33 AM Last edited by Arsil : 10th Nov 2014 at 10:46 AM.
This is to do it yourself:
http://www.den.simlogical.com/denfo...hp?topic=1689.0

There are also libraries already unprotected to download,
but I'm not sure if it's all right to link them here.
Test Subject
#6 Old 12th Nov 2014 at 6:08 PM
Quote: Originally posted by Arsil
This is to do it yourself:
http://www.den.simlogical.com/denfo...hp?topic=1689.0

There are also libraries already unprotected to download,
but I'm not sure if it's all right to link them here.


Thank you, Arsil!
Back to top