Replies: 9 (Who?), Viewed: 476 times.
Test Subject
Original Poster
#1 Old 19th Aug 2020 at 7:35 PM Last edited by Same4254 : 22nd Aug 2020 at 4:46 PM.
Default I need Sockets or Native Code...
The quick version is that I need access to System.net.Socket for the mod I would like to write. It would also be nice to get Threading, but I have seen that this can be kinda achieved with the simulator.

The mscorlib.dll and System.dll that get extracted from S3PE do not have these classes, so I can't create a socket...

Things I have tried (or will try):
- This was incredibly dumb, but I wanted to try at least. I attempted to place in the real .net Framework 2.0 dll's (since .NET allows for specific versions when refrencing a .dll). To do this, I changed the version number of mscorlib, System, and System.xml (and their references to each other). That way, the game would use their version, but I could refrence the real .NET 2.0 dlls (since their version number would be different). This did not work. However, I noticed that in the S3PE preview, mscorlib *always* shows up as .NET Framework 4.0... why is this? See the attached image of the preview tab for the mscorlib element in simscore.package. It shows mscorlib to be .NET 4.0 and its location to be in my .Net folders, rather than the metadata of the dll itself.

- I also tried to insert a C++/CLR dll. This I created in VS 2008 and targetted .NET Framework 2.0 (with the Sims .dlls rather than the real mscorlib, system, and system.xml). However, when I put this .dll into s3pe, I got this error message: "Could not load file or assembly exception from HRESULT 0x80131019". I tried messing with it and Googling around, but could not get this to work. My thought was to have native C++ handle the socketing work, and just write handles for the socket events in C# to interact with the game. I also even tried to load the assembly at runtime with Reflection (this is astoundingly stupid), but this failed as well (the script was for an interaction on a ModerateTV. The object generated in the world, but had no interactions. I imagine there was a runtime error when generating the interactions for the TV, and thus no interactions were added to the game object)

- My next attempt will probably be to use this library called IKVM which is a .NET implementation of the JVM (I have no idea why someone would do this, but it exists). It would be a bit harder than the C++/CLR solution (which would be preferred). However, on the IKVM site they specify support for MONO (which seems to be the library we get when extracting C# dlls). However, I fear this solution will fall to the same problem that the C++/CLR route did. When adding the dll in s3pe, it complained that it could not load the dll (even though it built just fine).

- Another possibility would be a pipe to another program that runs the socketing work. However, pipe functionality (and processes) are not in the System library we are given from extracting the dlls...

- I notice that the game also has some "OnlineFeatures", however the implementation is in Sims3common.dll. It seems this is the section of code that connects to the internet to get to the store and check the login. I cannot find this dll anywhere except as an external module import in the IL code of some of the dlls S3PE give us. If anyone knows where this is and how to view it that would be interesting to investigate. It would be helpful if it is possible to modify that level of the code and expose the networking library it uses (though this is unpreferred to the other option, as the code there would likely be made for GET and POST requests rather than a TCP connection to be used at the C# level for scripting).

- The last stitch effort would be to decompile the normal mscorlib and system dlls, and do my best to copy and paste the IL code for the System.net namepace. This would be a lot of work and would probably not work due to how much of the other classes it would require (that may be modified by MONO).

I have a lot of programming experience, but I am new to modding the Sims 3. Are there any tools or libraries I am missing here? How can I get socketing?

Any notes or advice on any of these points would be greatly appreciated.

UPDATE: I think I have an interesting lead... Does anyone know of a way to import a native dll into the game? Rather than a C# dll, I am talking about a native, c++ dll file. S3PE and packages do not offer this. The goal here is to write all of the socketing in the native dll and then invoke the functions using DllImport.
Screenshots
Advertisement
Field Researcher
#2 Old 19th Aug 2020 at 8:26 PM
I think think that sockets and especially the TPL would be great. But if there was an easy way to implement it i would imagine people like twallan would have made use of it a long time ago when they got their insights into Sims 3.

The thing is, the C# layer of Sims 3 is stripped down and lacks many functions i would like to have (binary fromatter or real IO anyone ?)
The C# layer makes most of the calls to the cpp backbone of the game through dll imports.

So unless you find an undocumented Function in there tat you could import into your cs scripts, i think youd be out of luck.
Test Subject
Original Poster
#3 Old 19th Aug 2020 at 8:44 PM
Quote:
Originally Posted by Battery
I think think that sockets and especially the TPL would be great. But if there was an easy way to implement it i would imagine people like twallan would have made use of it a long time ago when they got their insights into Sims 3.

The thing is, the C# layer of Sims 3 is stripped down and lacks many functions i would like to have (binary fromatter or real IO anyone ?)
The C# layer makes most of the calls to the cpp backbone of the game through dll imports.

So unless you find an undocumented Function in there tat you could import into your cs scripts, i think youd be out of luck.


So I noticed that there is an online features class in the dll's (I imagine these would be web sockets). However the actual implementation is in Sims3common.dll. I searched in other packages and the sims 3 folders, but did not find this dll... Is this packaged in the .exe or something? Where is that dll?

Also, do you know why S3PE displays the .NET version number to be 4.0 in the preview tab (even though the target framework is meant to be 2.0)? This is quite strange.
Field Researcher
#4 Old 19th Aug 2020 at 8:51 PM
if you look at the actual dynamic library in an il decompiler you will see that the target network is 2.0 and not 4.0
the Sims3Common Dll resides within the .exe (TS3W.exe)

Actually i had similar ideas and had some hope to find something a few years back. But i could not find what i was looking for when using a hex editor to look at the functions.
Test Subject
Original Poster
#5 Old 19th Aug 2020 at 8:54 PM
Quote:
Originally Posted by Battery
if you look at the actual dynamic library in an il decompiler you will see that the target network is 2.0 and not 4.0
the Sims3Common Dll resides within the .exe (TS3W.exe)


Yes, I understand that. However, when I view the simcore.package in s3pe, all of the dlls show up as .NET 4.0 in the preview tab of s3pe. But after extracting the dlls with s3pe, the dlls come out as 2.0...
Field Researcher
#6 Old 19th Aug 2020 at 8:56 PM
Quote:
Originally Posted by Same4254
Yes, I understand that. However, when I view the simcore.package in s3pe, all of the dlls show up as .NET 4.0 in the preview tab of s3pe. But after extracting the dlls with s3pe, the dlls come out as 2.0...


Do they ? i did not find a mention to that in S3PE the only thing i can see there is the dll version
Test Subject
Original Poster
#7 Old 19th Aug 2020 at 9:03 PM
Quote:
Originally Posted by Battery
Do they ? i did not find a mention to that in S3PE the only thing i can see there is the dll version


I cannot figure out how to insert an image, but in the preview tab for simcore.package, it says that the version is 4.0.0 and the ImageRuntimeVersion is v4.0.30319. It also says that the location is in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll (rather than the dll that is in the package). It also lists the exported types, and it shows all of the standard namespaces and classes (rather than the ones we truly get when extracting the dll). This makes me think that S3PE checks the GAC for the signature in the dll metadata and matches to the first one it finds (the dll signature in the MONO dlls is the same as the real .NET signatures)...? Maybe? This is a guess, since I have no idea how S3PE works.
Field Researcher
#8 Old 19th Aug 2020 at 9:05 PM Last edited by Battery : 19th Aug 2020 at 9:31 PM.
Well thats possible, i think S3PE was built upon 4.0 so that could explain that
Test Subject
Original Poster
#9 Old 19th Aug 2020 at 9:06 PM
Quote:
Originally Posted by Battery
Well that possible i think S3PE was built upon 4.0 so that would explain that


That wouldn't make sense since the tool's job is to display the metadata of the dlls in the package, not the framework it runs in. If you look at the other packages the dlls there reference 2.0.0, not 4.0.0 (so it doesn't get the reference from the fact that the GUI runs in .NET 4.0)
Test Subject
Original Poster
#10 Old 9th Apr 2021 at 8:16 PM
Hello again! I have found a solution to this problem and I wanted to let you know, and anyone who is possibly subscribed to this thread. I posted it in a new thread because it is a new general approach to modding. It is titled: "A new class of modding that allows modders to use FIle I/O, Sockets, and printing to the screen: Bridge Modding". Give it a read
Back to top