Skip to content

Commit

Permalink
[PE] 添加x86版本
Browse files Browse the repository at this point in the history
  • Loading branch information
Perfare committed Jun 9, 2022
1 parent 6327879 commit 2dcb36d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
12 changes: 9 additions & 3 deletions Il2CppDumper.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
24 changes: 24 additions & 0 deletions Il2CppDumper/Il2CppDumper-x86.csproj
Original file line number Diff line number Diff line change
@@ -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>
6 changes: 4 additions & 2 deletions Il2CppDumper/Il2CppDumper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
14 changes: 8 additions & 6 deletions Il2CppDumper/Utils/PELoader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -27,10 +28,13 @@ public static PE Load(string fileName)
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;
Expand All @@ -41,9 +45,7 @@ public static PE Load(string fileName)
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)
{
Expand Down

0 comments on commit 2dcb36d

Please sign in to comment.