SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SHIII Mods Workshop
Forget password? Reset here

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 11-11-15, 02:50 PM   #1
a.g.
Swabbie
 
Join Date: Nov 2015
Posts: 11
Downloads: 18
Uploads: 0
Exclamation Crash: comments at the start of ini files considered harmful.

I had my first consistent game crash in real play within a certain area, and investigated. I turns out, the code that is used by the game to read ini-style files has a bug: if there are comments before the first [...] label, it can rarely and semi-randomly cause one such section within the file to be effectively emptied of all contents. If it happens to an .eqp file, the game will crash whenever the affected ship tries to be rendered, whether in mission or in Museum (in my case, the damage was to Sea\NTRW_\NTRW_.eqp for GWX's ASW Trawler).

This bug can be fixed with a relatively small patch, but an easier workaround may be to never use comments at the very start of an ini file.

The technical cause of the bug is as follows: the ini reader uses hashes to index ini sections, without any support for collisions; it also for some reason reads and stores comments into memory. If a comment occurs at the start of the file, it creates an empty section without a name to store it, and does not initialize the hash value for that empty section. If the memory happens to contain a value that matches the hash of one of the real section names, the collision will prevent any of the values within it to be read.

This is the patch that worked for me (it's for the Steam version in case it matters):

 

Code:
Zero out the whole structure, instead of just 4 fields:

.text:10005C72                 cmp     ebx, 0FFFFFFFFh
.text:10005C75                 mov     [esi+0Ch], edi
.text:10005C78                 mov     [esi+10h], edi
.text:10005C7B                 mov     [esi], edi
.text:10005C7D                 mov     [esi+4], edi

==>

.text:10005C72                 mov     edi, esi
.text:10005C74                 mov     ecx, 5
.text:10005C79                 xor     eax, eax
.text:10005C7B                 rep stosd
.text:10005C7D                 cmp     ebx, 0FFFFFFFFh

------
This difference file is created by The Interactive Disassembler

FileManager.dll
00005C72: 83 89
00005C73: FB F7
00005C74: FF B9
00005C75: 89 05
00005C76: 7E 00
00005C77: 0C 00
00005C78: 89 00
00005C79: 7E 31
00005C7A: 10 C0
00005C7B: 89 F3
00005C7C: 3E AB
00005C7D: 89 83
00005C7E: 7E FB
00005C7F: 04 FF
a.g. is offline   Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.