mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-12 20:07:02 +00:00
Fix "converting null literal" warnings
This commit is contained in:
@@ -350,7 +350,11 @@ namespace BinaryObjectScanner.Wrappers
|
||||
return false;
|
||||
|
||||
// Read the data
|
||||
#if NET48
|
||||
byte[] data = ReadFromDataSource((int)lump.Offset, (int)lump.Length);
|
||||
#else
|
||||
byte[]? data = ReadFromDataSource((int)lump.Offset, (int)lump.Length);
|
||||
#endif
|
||||
if (data == null)
|
||||
return false;
|
||||
|
||||
@@ -442,7 +446,11 @@ namespace BinaryObjectScanner.Wrappers
|
||||
return false;
|
||||
|
||||
// Read the data
|
||||
#if NET48
|
||||
byte[] data = CreateTextureData(texture);
|
||||
#else
|
||||
byte[]? data = CreateTextureData(texture);
|
||||
#endif
|
||||
if (data == null)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -351,7 +351,11 @@ namespace BinaryObjectScanner.Wrappers
|
||||
if (dataBlock == null)
|
||||
continue;
|
||||
|
||||
#if NET48
|
||||
byte[] decompressed = new byte[dataBlock.UncompressedSize];
|
||||
#else
|
||||
byte[]? decompressed = new byte[dataBlock.UncompressedSize];
|
||||
#endif
|
||||
switch (folder.CompressionType & SabreTools.Models.MicrosoftCabinet.CompressionType.MASK_TYPE)
|
||||
{
|
||||
case SabreTools.Models.MicrosoftCabinet.CompressionType.TYPE_NONE:
|
||||
@@ -649,7 +653,7 @@ namespace BinaryObjectScanner.Wrappers
|
||||
{
|
||||
for (int j = 0; j < entry.DataBlocks.Length; j++)
|
||||
{
|
||||
SabreTools.Models.MicrosoftCabinet.CFDATA dataBlock = entry.DataBlocks[j];
|
||||
var dataBlock = entry.DataBlocks[j];
|
||||
builder.AppendLine($" Data Block {j}");
|
||||
if (dataBlock == null)
|
||||
{
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace BinaryObjectScanner.Wrappers
|
||||
#if NET48
|
||||
byte[] data = ReadFromDataSource((int)directoryItem.ItemOffset, (int)directoryItem.ItemLength);
|
||||
#else
|
||||
byte[] data = ReadFromDataSource((int)directoryItem.ItemOffset, (int)directoryItem.ItemLength);
|
||||
byte[]? data = ReadFromDataSource((int)directoryItem.ItemOffset, (int)directoryItem.ItemLength);
|
||||
#endif
|
||||
if (data == null)
|
||||
return false;
|
||||
|
||||
@@ -3133,7 +3133,11 @@ namespace BinaryObjectScanner.Wrappers
|
||||
foreach (var kvp in stringTable)
|
||||
{
|
||||
int index = kvp.Key;
|
||||
#if NET48
|
||||
string stringValue = kvp.Value;
|
||||
#else
|
||||
string? stringValue = kvp.Value;
|
||||
#endif
|
||||
builder.AppendLine($"{padding}String entry {index}: {stringValue}");
|
||||
}
|
||||
}
|
||||
@@ -3206,13 +3210,21 @@ namespace BinaryObjectScanner.Wrappers
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
#if NET48
|
||||
byte[] magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#else
|
||||
byte[]? magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#endif
|
||||
|
||||
if (entry.Data[0] == 0x4D && entry.Data[1] == 0x5A)
|
||||
if (magic == null)
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
else if (magic[0] == 0x4D && magic[1] == 0x5A)
|
||||
{
|
||||
builder.AppendLine($"{padding}Data: [Embedded Executable File]"); // TODO: Parse this out and print separately
|
||||
}
|
||||
else if (entry.Data[0] == 0x4D && entry.Data[1] == 0x53 && entry.Data[2] == 0x46 && entry.Data[3] == 0x54)
|
||||
else if (magic[0] == 0x4D && magic[1] == 0x53 && magic[2] == 0x46 && magic[3] == 0x54)
|
||||
{
|
||||
builder.AppendLine($"{padding}Data: [Embedded OLE Library File]"); // TODO: Parse this out and print separately
|
||||
}
|
||||
@@ -3773,13 +3785,21 @@ namespace BinaryObjectScanner.Wrappers
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
#if NET48
|
||||
byte[] magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#else
|
||||
byte[]? magic = entry.Data.ReadBytes(ref offset, Math.Min(entry.Data.Length, 16));
|
||||
#endif
|
||||
|
||||
if (entry.Data[0] == 0x4D && entry.Data[1] == 0x5A)
|
||||
if (magic == null)
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
else if (magic[0] == 0x4D && magic[1] == 0x5A)
|
||||
{
|
||||
builder.AppendLine($"{padding}Data: [Embedded Executable File]"); // TODO: Parse this out and print separately
|
||||
}
|
||||
else if (entry.Data[0] == 0x4D && entry.Data[1] == 0x53 && entry.Data[2] == 0x46 && entry.Data[3] == 0x54)
|
||||
else if (magic[0] == 0x4D && magic[1] == 0x53 && magic[2] == 0x46 && magic[3] == 0x54)
|
||||
{
|
||||
builder.AppendLine($"{padding}Data: [Embedded OLE Library File]"); // TODO: Parse this out and print separately
|
||||
}
|
||||
|
||||
@@ -201,7 +201,11 @@ namespace BinaryObjectScanner.Wrappers
|
||||
// Read the entire compressed data
|
||||
int compressedDataOffset = (int)CompressedDataOffset;
|
||||
int compressedDataLength = GetEndOfFile() - compressedDataOffset;
|
||||
#if NET48
|
||||
byte[] compressedData = ReadFromDataSource(compressedDataOffset, compressedDataLength);
|
||||
#else
|
||||
byte[]? compressedData = ReadFromDataSource(compressedDataOffset, compressedDataLength);
|
||||
#endif
|
||||
|
||||
// TODO: Figure out decompression
|
||||
// - Single-file archives seem to work
|
||||
@@ -324,7 +328,7 @@ namespace BinaryObjectScanner.Wrappers
|
||||
builder.AppendLine($" File Descriptor {i}");
|
||||
if (fileDescriptor == null)
|
||||
{
|
||||
builder.AppendLine(" [NULL]");
|
||||
builder.AppendLine(" [NULL]");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +258,11 @@ namespace BinaryObjectScanner.Wrappers
|
||||
#endif
|
||||
{
|
||||
// Read the data as a byte array first
|
||||
#if NET48
|
||||
byte[] sourceData = ReadFromDataSource(position, length);
|
||||
#else
|
||||
byte[]? sourceData = ReadFromDataSource(position, length);
|
||||
#endif
|
||||
if (sourceData == null)
|
||||
return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user