Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

any kind of mods
Post Reply
  • Author
  • Message
Offline
Posts: 35
Joined: 12 Jun 2013, 06:49

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Yeah, that's what I thought. However, both of these caused a CTD very soon after bringing up the main menu screen. However, the default 512Mb setting seems stable so I shall stick with that.

Offline
Posts: 31
Joined: 23 Jul 2013, 17:55

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Winterlove wrote:Yeah, that's what I thought. However, both of these caused a CTD very soon after bringing up the main menu screen. However, the default 512Mb setting seems stable so I shall stick with that.
Did you try 768Mb for first and 512Mb for second?

or maybe

1024Mb for first and 512/768Mb for second?
_________________
I5 3570k @ 4.5 GHz / GTX 660 Ti 3GB SLI / ASUS P8Z77-V / 8GB RAM / 4TB HDD's / Win7, Win8.1 64-bit

Offline
Posts: 29
Joined: 18 Jan 2014, 04:27

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Winterlove wrote:Yeah, that's what I thought. However, both of these caused a CTD very soon after bringing up the main menu screen. However, the default 512Mb setting seems stable so I shall stick with that.
Interesting it may be worth noting what system you are running, OS etc so as people may be able to figure out if there is a certain config etc this is not safe or stable for, for example myself i am running 768/512 without any problems.

Edit: After this I created a new set of DLL files and I am unable to adjust the 1st block over 768Mb without crashes.
Last edited by Daetarek on 19 Jan 2014, 12:22, edited 1 time in total.

Offline
Posts: 35
Joined: 12 Jun 2013, 06:49

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

That worked better. It seems you need to modify both - at least on my setup. 768Mb/512Mb takes noticably longer, but the game does load now.

For reference, I'm running Windows 7 64 bit on a Core i7 X 980 (overclocked from 3.33Ghz to 4GHz), with 12Gb of RAM and an AMD 7970.

Offline
Posts: 35
Joined: 12 Jun 2013, 06:49

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Just for giggles, I'm now using a version of the patch that allows you select 512/256Mb or 768/512Mb according whether the config option is 1 or 2 :)

Offline
User avatar
Posts: 9
Joined: 19 Jan 2014, 04:37

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Alright guys, it's 3 AM here so bear with me if I ramble. I've been playing with this Memory Patch all day and am ready to give feedback.

Mind = Blown

It's too good but it is true. Yes, it really does work. Initially tested ten times at five different freeze spots on my map with Safety Load turned OFF. Freezes every time at the exact same spots. Used the compiled skse_steam_loader.dll, tested all the previous freeze locations and never had a single CTD. Then proceeded to play the game normally for several hours. Rode on horseback from Whiterun to Falkreath, Markarth, Solitude, Dawnstar, and Riften. Not a single CTD. Interiors, exteriors, you name it. I actually got to play the game, the way it was meant to be played, with all the mods I want, without having to cross my fingers during known crash spots (menus, changing cells, heavily edited world space, etc).


I do think that the procedure could use a little fine tuning for those unfamiliar with the operation so I'll explain it with more clarity. Using Microsoft Visual C++ can appear intimidating but trust me, this is super easy. Here's a quick walk-through:

Before we begin, go to your Skyrim directory folder (Steam\steamapps\common\Skyrim) and back-up your original skse_steam_loader.dll as that is what is going to be replaced.

First, you'll need the SKSE source files. Download the 7z archive from SKSE.
You do NOT need to place these files inside the Skyrim directory folder. I kept my source files in a temporary location.

Download Microsoft Visual C++ Express 2010
Before you do anything else, UPDATE THE PROGRAM. You'll need to re-scan and install files multiple times until Windows Update no longer prompts you to install anything else.

In your newly downloaded SKSE folder, go to src, skse, skse.snl . SKSE.snl may not have the extension showing on your computer. You can verify that this is the correct file by right clicking and viewing Properties. Your folder path should look like this --> skse_1_06_16\src\skse\skse.snl .

Open skse.snl with Visual C++ Express 2010.
If a conversion window pops up click Next, choose "Yes, create a backup before converting" then Next, and Finish. Don't worry about the Security Warning. Uncheck the "Ask me for every project in this solution" as it does get annoying. Click OK to open the project. If prompted to remove "source control bindings" click Yes. Click Close when prompted that conversion is complete. Don't worry about all the Warnings in the Conversion Report.

Click on the arrow next to "steam_loader" and double click on "main.cpp". Copy and paste sheson's code in the bracket starting with

Code: Select all

InstallHook(void * retaddr, UInt32 hookSrc)
Placing the code just above

Code: Select all

FlushInstructionCache(GetCurrentProcess(), NULL, 0);
Now locate the "Debug" drop-down on the tool bar and change it to "Release".

On the left panel, locate and right click on "steam_loader" and select "Build".

Visual will now start spitting out a bunch lines in the Output section. The last line should say:
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Don't worry about the 1 failed. That's normal.

Go back to your folders and find the Release folder. Folder path should look like this --> skse_1_06_16\src\skse\Release
Copy the "skse_steam_loader.dll" file and replace the one found in your Skyrim directory.

Of course, if you're realllllllly lazy and don't want to get your hands dirty (don't worry I won't judge) you can just download my pre-compiled skse_steam_loader.dll found here.

Finally, create a new text document with the following:

[NotPlacebo]
GiveFirstBornToSheson=1


Save the text file as SKSE.ini and place it in your SKSE folder found in your Data folder. If you do not have an SKSE folder, create one then place the SKSE.ini file there. If you already have an SKSE folder, do not accidentally place the SKSE.ini file inside the Plugins folder. Folder path looks like this --> Steam\steamapps\common\Skyrim\Data\SKSE

ENBoost or newest version of ENB is required.

Stable uGridsToLoad is not required if you are not changing your uGrids. If you plan on keeping the default uGridsToLoad=5, you do not need Stable uGridsToLoad mod. If you want to play around with uGrids and test the capabilities of this memory patch or just want to increase your uGrids, download the mod.

Play the game!

In order to verify that the patch is working correctly, go to your Skyrim folder located under My Documents and locate the SKSE folder. Folder path --> Documents\my games\Skyrim\SKSE . Open up the "skse_steam_loader" text document and inside you should find a little message near the bottom saying "Sheson took your first born in exchange for more memory". This will let you know that the patch is correctly implemented and everything works as it should.

Hope this helps and happy modding! :)

Offline
User avatar
Posts: 64
Joined: 11 Sep 2013, 22:34

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Psychor wrote:Well this fix the opposite effect for me. :shock:

I haven't had a single CTD since using: (1) SafeteyLoad; (2) ShowRaceMenu Precache Killer. I compiled the DLL (as well as tried the pre-compiled DLL on Reddit in case I screwed something up), disabled SafeteyLoad, disabled ShowRaceMenu Precache Killer and ran the game. The result was a constant CTD at the character generation screen while trying to switch genders. I verified that the fix was active by checking skse_steam_loader.log.

However, if I run Skyrim with your fix and leave both SafeteyLoad and ShowRaceMenu Precache Killer enabled I don't experience a CTD. What's interesting though is that it takes longer to switch gender than it did prior to using your fix.

Sheson, any idea why your fix would be doing more harm than good for me?

Some of my settings in case it might help:
OS/Hardware=http://pc.thedigitalfoundry.com
uGridsToLoad=7
uExterior Cell Buffer=64
ENB=RealVision ENB (0.245 Boris; Wrapper)

I do appreciate your work - keep it up!
just to recap from above link. Win8 64 bit, 16GB

Things to test:
1) Turn off sfatey load but keep Precache Killer
2) Use VMMap to see if the first block is used up once in the game. If it is increase first block.

Post screenshot of VMMap if problem continues.

Offline
Posts: 29
Joined: 18 Jan 2014, 04:27

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

So after messing around with various dll's configs i figured there must be an easier way to swap between values without the need for a new file, and setting a single flag to swap between multiple configs added far too much code for my liking so i came up with the following.

Code: Select all

	UInt32   MemBlock1 = 256;
	UInt32   MemBlock2 = 256;
	UInt32   enableMemPatches = 0;
   if(GetConfigOption_UInt32("NotPlacebo", "GiveFirstBornToSheson", &enableMemPatches)) 
   {
	  GetConfigOption_UInt32("NotPlacebo", "MemBlock1", &MemBlock1);
	  GetConfigOption_UInt32("NotPlacebo", "MemBlock2", &MemBlock2);

		if(enableMemPatches)
      {

		  _MESSAGE("Sheson took your first born in exchange for more memory");
		  _MESSAGE("Set your first Memory Block to = %i", MemBlock1);
		  _MESSAGE("Set your second Memory Block to = %i", MemBlock2);

		 //These patch addresses only apply to tesv.exe 1.9.32.0.8
         //do not use this on any other version

         //1st block, request 512MB (0x0300) instead of 256MB (0x0200)
         //if too small cause of ILS or CTD when to much cell+buffer data does not fit anymore and engine allocates more memory.
         //tesv.exe:00687E73   sbb     edi, edi
         //tesv.exe:00687E75   push    0
         //tesv.exe:00687E77   and     edi, 0x0FFFFE00
         //tesv.exe:00687E7D   push    0x158
         //tesv.exe:00687E82   mov     ecx, offset 0x01B418B0
         //tesv.exe:00687E87   add     edi, 0x200   <-----
         //tesv.exe:00687E8D   call    0x00A48D60
         //tesv.exe:00687E92   test    eax, eax
         //tesv.exe:00687E94   jz      short 0x00687EB1
         //tesv.exe:00687E96   push    1
         //tesv.exe:00687E98   push    0
         //tesv.exe:00687E9A   push    offset 0x010CD3C8
         //tesv.exe:00687E9F   push    0x5500000
         //tesv.exe:00687EA4   shl     edi, 0x14
         //tesv.exe:00687EA7   push    edi
         //tesv.exe:00687EA8   mov     ecx, eax
         //tesv.exe:00687EAA   call    0x00A4DCF0
         SafeWrite32(0x00687e87+2, MemBlock1+256);

         //2nd block, request default 256MB (0x10000000), typically seems big enough
         //changing this value is not recommended because side effects are not yet properly tested
         //when 1st buffer is set over 512MB and there are a lot of mods this needs to be raised as well or tesv.exe crashes at start
         //however there are no commits over 256MB, hard coded max limits later in the code
         //tesv.exe:00A4E6B1   mov      ebp, dword ptr 0x0106B268
         //tesv.exe:00A4E6B7   push   4
         //tesv.exe:00A4E6B9   push   0x2000
         //tesv.exe:00A4E6BE   push   0x10000000   <-----
         //tesv.exe:00A4E6C3   mov      [ebx+0x8D08]
         //tesv.exe:00A4E6C9   mov      [ebx+0x8D0C]
         //tesv.exe:00A4E6CF   mov      [ebx+0x8D10]
         //tesv.exe:00A4E6D5   push   edi
         //tesv.exe:00A4E6D6   mov      [ebx+0x8D14]
         //tesv.exe:00A4E6DC   call   ebp
         SafeWrite32(0x00a4e6be+1, MemBlock2*1024*1024);

         //change movaps to movups (slower on old CPUs) in case memory is not 16byte aligned,
         //there are most likely more, but when 1st buffer large enough this is not problem anymore
      
         //this one is executed once per new cell load
         //tesv.exe:004BD82F   xorps   xmm0, xmm0
         //tesv.exe:004BD832   movaps   xmmword ptr [esi+0x9160], xmm0
         SafeWrite8(0x004bd832+1, 0x11);
      }
   }
This basically allows you to configure the Memory via the SKSE.ini file without having to rebuild every time, you place this code exactly where you placed Shesons code previously and build it in the same way, except a few small changes it is his exact same code.

the SKSE.ini lines are as follows

[NotPlacebo]
GiveFirstBornToSheson=1
MemBlock1=256
MemBlock2=256

MemBlock1 refers to the 1st blocks memory size in Mb
MemBlock2 refers to the 2nd blocks Memory Size in Mb

The Values i show above are the default game values, and you can adjust to your hearts content, in Mb.

Also note that if you want you can change the names of MemBlock1 and MemBlock2 to whatever you want them to be just make sure you change them in all the right places, its just what i was using.

You can also confirm that this is working by looking in your skse_steam_loader.log file, and below Shesons message you should see something similar to this...

Set your first Memory Block to = 768
Set your second Memory Block to = 512

Once again thanks heaps Sheson for a magic fix, i hope this little adjustment is something people can find useful

Edited to fix a mistake in my code, thanks Winterlove :D also simplified some references
Edited Further with Shesons recommended changes from the next page of this thread, thanks once more Sheson
Last edited by Daetarek on 19 Jan 2014, 15:03, edited 8 times in total.

Offline
Posts: 35
Joined: 12 Jun 2013, 06:49

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Small observation: The initialisers for DtkMemBlock1 and DtkMemBlock2 need to be hexadecimal constants, not decimal. Strange things may happen if an ini file contains values for just one of the two otherwise.

Offline
Posts: 29
Joined: 18 Jan 2014, 04:27

Re: Skyrim Memory Patch - fixing ILS, uGrids CTD, freezes

Winterlove wrote:Small observation: The initialisers for DtkMemBlock1 and DtkMemBlock2 need to be hexadecimal constants, not decimal. Strange things may happen if an ini file contains values for just one of the two otherwise.
I have fixed it now, should work no problems if you do not add the MemBlock entries in the INI file as standard config. Thanks for that :D

I had tried a few other methods but this seemed to be by far the most simple, however I am open to better solutions, always nice to learn another way to do something :D
Post Reply