#1

8th Nov 2014 at 11:23 AM
Last edited by ArtUrlWWW : 8th Nov 2014 at
1:48 PM.
Posts: 133
Thanks: 1494 in 13 Posts
10 Achievements
[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.