Fix locking exception

This commit is contained in:
Matt Nadareski
2022-12-14 21:30:53 -08:00
parent b5c8d05814
commit 1f40c2e052
3 changed files with 43 additions and 32 deletions

View File

@@ -137,13 +137,17 @@ namespace BurnOutSharp.Builder
int charWidth = nullTerminator.Length;
List<char> keyChars = new List<char>();
while (offset < content.Length && BitConverter.ToUInt16(content, offset) != 0x0000)
while (offset < content.Length)
{
keyChars.Add(encoding.GetChars(content, offset, charWidth)[0]); offset += charWidth;
}
offset += 2;
char c = encoding.GetChars(content, offset, charWidth)[0];
keyChars.Add(c);
offset += charWidth;
return new string(keyChars.ToArray());
if (c == '\0')
break;
}
return new string(keyChars.ToArray()).TrimEnd('\0');
}
#endregion

View File

@@ -583,21 +583,18 @@ namespace BurnOutSharp.Wrappers
{
get
{
lock (_sourceDataLock)
{
// Use the cached data if possible
if (_debugData != null && _debugData.Count != 0)
return _debugData;
// If we have no resource table, just return
if (DebugTable?.DebugDirectoryTable == null
|| DebugTable.DebugDirectoryTable.Length == 0)
return null;
// Otherwise, build and return the cached dictionary
ParseDebugTable();
// Use the cached data if possible
if (_debugData != null && _debugData.Count != 0)
return _debugData;
}
// If we have no resource table, just return
if (DebugTable?.DebugDirectoryTable == null
|| DebugTable.DebugDirectoryTable.Length == 0)
return null;
// Otherwise, build and return the cached dictionary
ParseDebugTable();
return _debugData;
}
}
@@ -2815,16 +2812,19 @@ namespace BurnOutSharp.Wrappers
if (DebugData == null)
return Enumerable.Empty<object>();
return DebugData.Select(r => r.Value)
var nb10Found = DebugData.Select(r => r.Value)
.Select(r => r as Models.PortableExecutable.NB10ProgramDatabase)
.Where(n => n != null)
.Where(n => n.PdbFileName.Contains("path"))
.Select(n => (object)n)
.Concat(DebugData.Select(r => r.Value)
.Select(r => r as Models.PortableExecutable.RSDSProgramDatabase)
.Where(r => r != null)
.Where(r => r.PathAndFileName.Contains("path"))
.Select(r => (object)r));
.Where(n => n.PdbFileName.Contains(path))
.Select(n => (object)n);
var rsdsFound = DebugData.Select(r => r.Value)
.Select(r => r as Models.PortableExecutable.RSDSProgramDatabase)
.Where(r => r != null)
.Where(r => r.PathAndFileName.Contains(path))
.Select(r => (object)r);
return nb10Found.Concat(rsdsFound);
}
/// <summary>

View File

@@ -126,17 +126,24 @@ namespace BurnOutSharp.Tools
/// </summary>
public static string ReadString(this byte[] content, ref int offset, Encoding encoding)
{
if (offset >= content.Length)
return null;
byte[] nullTerminator = encoding.GetBytes(new char[] { '\0' });
int charWidth = nullTerminator.Length;
List<char> keyChars = new List<char>();
while (BitConverter.ToUInt16(content, offset) != 0x0000)
while (offset < content.Length)
{
keyChars.Add(encoding.GetChars(content, offset, charWidth)[0]); offset += charWidth;
}
offset += 2;
char c = encoding.GetChars(content, offset, charWidth)[0];
keyChars.Add(c);
offset += charWidth;
return new string(keyChars.ToArray());
if (c == '\0')
break;
}
return new string(keyChars.ToArray()).TrimEnd('\0');
}
/// <summary>