Use codepage 850 when decoding PC GEM resources.

This commit is contained in:
2018-02-28 20:04:58 +00:00
parent ece71a9953
commit 83495c22ce

View File

@@ -29,7 +29,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Claunia.Encoding; using System.Text;
namespace libexeinfo namespace libexeinfo
{ {
@@ -120,7 +120,15 @@ namespace libexeinfo
Recognized = false; Recognized = false;
if(BaseStream == null) return; if(BaseStream == null) return;
byte[] buffer = new byte[Marshal.SizeOf(typeof(MZHeader))]; byte[] buffer = new byte[Marshal.SizeOf(typeof(MZHeader))];
Encoding encoding;
try { encoding = Encoding.GetEncoding("ibm850"); }
catch
{
try { encoding = Encoding.GetEncoding("ibm850"); }
catch { encoding = Encoding.ASCII; }
}
BaseStream.Position = 0; BaseStream.Position = 0;
BaseStream.Read(buffer, 0, buffer.Length); BaseStream.Read(buffer, 0, buffer.Length);
@@ -178,8 +186,7 @@ namespace libexeinfo
List<short> knownNodes = new List<short>(); List<short> knownNodes = new List<short>();
ResourceObjectRoots[i] = ResourceObjectRoots[i] =
GEM.ProcessResourceObject(nodes, ref knownNodes, 0, resourceStream, strings, false, GEM.ProcessResourceObject(nodes, ref knownNodes, 0, resourceStream, strings, false, encoding);
Encoding.AtariSTEncoding);
} }
} }
else if(ResourceHeader.rsh_nobs > 0) else if(ResourceHeader.rsh_nobs > 0)
@@ -198,8 +205,7 @@ namespace libexeinfo
ResourceObjectRoots = new GEM.TreeObjectNode[1]; ResourceObjectRoots = new GEM.TreeObjectNode[1];
// TODO: Correct encoding? // TODO: Correct encoding?
ResourceObjectRoots[0] = ResourceObjectRoots[0] =
GEM.ProcessResourceObject(nodes, ref knownNodes, 0, resourceStream, strings, false, GEM.ProcessResourceObject(nodes, ref knownNodes, 0, resourceStream, strings, false, encoding);
Encoding.AtariSTEncoding);
} }
if(strings.Count > 0) if(strings.Count > 0)