mirror of
https://github.com/atom0s/Steamless.git
synced 2024-12-19 23:07:41 +01:00
API: (PE32) Adjusted 'Parse' method to exit early if the DOS stub is invalid. (Avoids attempting to read an invalid NT header block.)
API: (PE64) Adjusted 'Parse' method to exit early if the DOS stub is invalid. (Avoids attempting to read an invalid NT header block.)
This commit is contained in:
parent
7f92aded2c
commit
4c3c6e757c
2 changed files with 12 additions and 8 deletions
|
@ -85,12 +85,14 @@ namespace Steamless.API.PE32
|
||||||
if (this.FileData.Length < (Marshal.SizeOf(typeof(NativeApi32.ImageDosHeader32)) + Marshal.SizeOf(typeof(NativeApi32.ImageNtHeaders32))))
|
if (this.FileData.Length < (Marshal.SizeOf(typeof(NativeApi32.ImageDosHeader32)) + Marshal.SizeOf(typeof(NativeApi32.ImageNtHeaders32))))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Read the file headers..
|
// Read the file DOS header..
|
||||||
this.DosHeader = Pe32Helpers.GetStructure<NativeApi32.ImageDosHeader32>(this.FileData);
|
this.DosHeader = Pe32Helpers.GetStructure<NativeApi32.ImageDosHeader32>(this.FileData);
|
||||||
this.NtHeaders = Pe32Helpers.GetStructure<NativeApi32.ImageNtHeaders32>(this.FileData, this.DosHeader.e_lfanew);
|
if (!this.DosHeader.IsValid)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Validate the headers..
|
// Read the file NT headers..
|
||||||
if (!this.DosHeader.IsValid || !this.NtHeaders.IsValid)
|
this.NtHeaders = Pe32Helpers.GetStructure<NativeApi32.ImageNtHeaders32>(this.FileData, this.DosHeader.e_lfanew);
|
||||||
|
if (!this.NtHeaders.IsValid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Read and store the dos header if it exists..
|
// Read and store the dos header if it exists..
|
||||||
|
|
|
@ -85,12 +85,14 @@ namespace Steamless.API.PE64
|
||||||
if (this.FileData.Length < (Marshal.SizeOf(typeof(NativeApi64.ImageDosHeader64)) + Marshal.SizeOf(typeof(NativeApi64.ImageNtHeaders64))))
|
if (this.FileData.Length < (Marshal.SizeOf(typeof(NativeApi64.ImageDosHeader64)) + Marshal.SizeOf(typeof(NativeApi64.ImageNtHeaders64))))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Read the file headers..
|
// Read the file DOS header..
|
||||||
this.DosHeader = Pe64Helpers.GetStructure<NativeApi64.ImageDosHeader64>(this.FileData);
|
this.DosHeader = Pe64Helpers.GetStructure<NativeApi64.ImageDosHeader64>(this.FileData);
|
||||||
this.NtHeaders = Pe64Helpers.GetStructure<NativeApi64.ImageNtHeaders64>(this.FileData, this.DosHeader.e_lfanew);
|
if (!this.DosHeader.IsValid)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Validate the headers..
|
// Read the file NT headers..
|
||||||
if (!this.DosHeader.IsValid || !this.NtHeaders.IsValid)
|
this.NtHeaders = Pe64Helpers.GetStructure<NativeApi64.ImageNtHeaders64>(this.FileData, this.DosHeader.e_lfanew);
|
||||||
|
if (!this.NtHeaders.IsValid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Read and store the dos header if it exists..
|
// Read and store the dos header if it exists..
|
||||||
|
|
Loading…
Reference in a new issue