[PE] 添加x86版本

This commit is contained in:
Perfare 2022-06-10 03:54:28 +08:00
parent 6327879c05
commit 2dcb36d8be
4 changed files with 45 additions and 11 deletions

View file

@ -1,9 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Il2CppDumper", "Il2CppDumper\Il2CppDumper.csproj", "{2087F99A-A655-41C1-84BB-54798AEA4080}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Il2CppDumper", "Il2CppDumper\Il2CppDumper.csproj", "{2087F99A-A655-41C1-84BB-54798AEA4080}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Il2CppDumper-x86", "Il2CppDumper\Il2CppDumper-x86.csproj", "{D108619F-DD4C-4D70-ABC2-861E17DB5AC1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{2087F99A-A655-41C1-84BB-54798AEA4080}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2087F99A-A655-41C1-84BB-54798AEA4080}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2087F99A-A655-41C1-84BB-54798AEA4080}.Release|Any CPU.Build.0 = Release|Any CPU
{D108619F-DD4C-4D70-ABC2-861E17DB5AC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D108619F-DD4C-4D70-ABC2-861E17DB5AC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D108619F-DD4C-4D70-ABC2-861E17DB5AC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D108619F-DD4C-4D70-ABC2-861E17DB5AC1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;net5.0;net6.0</TargetFrameworks>
<Version>1.0.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Copyright>Copyright © Perfare 2016-2022</Copyright>
<Prefer32Bit>true</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</Project>

View file

@ -3,10 +3,12 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;net5.0;net6.0</TargetFrameworks>
<Version>1.0.0</Version>
<Version>1.0.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Copyright>Copyright © Perfare 2016-2020</Copyright>
<Copyright>Copyright © Perfare 2016-2022</Copyright>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>

View file

@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
@ -27,10 +28,13 @@ namespace Il2CppDumper
throw new InvalidDataException("ERROR: Invalid PE file");
}
var fileHeader = reader.ReadClass<FileHeader>();
if ((fileHeader.Machine == 0x14c && Environment.Is64BitProcess) //64bit process can't load 32bit dll
|| (fileHeader.Machine == 0x8664 && !Environment.Is64BitProcess)) //32bit process can't load 64bit dll
if (fileHeader.Machine == 0x14c && Environment.Is64BitProcess) //64bit process can't load 32bit dll
{
return new PE(new MemoryStream(buff));
throw new InvalidOperationException("The file is a 32-bit file, please try to load it with Il2CppDumper-x86.exe");
}
if (fileHeader.Machine == 0x8664 && !Environment.Is64BitProcess) //32bit process can't load 64bit dll
{
throw new InvalidOperationException("The file is a 64-bit file, please try to load it with Il2CppDumper.exe");
}
var pos = reader.Position;
reader.Position = pos + fileHeader.SizeOfOptionalHeader;
@ -41,9 +45,7 @@ namespace Il2CppDumper
var handle = LoadLibrary(fileName);
if (handle == IntPtr.Zero)
{
//Missing dependent DLL
//throw new Win32Exception();
return new PE(new MemoryStream(buff));
throw new Win32Exception(Marshal.GetLastWin32Error());
}
foreach (var section in sections)
{