Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit 8751fa2

Browse files
committed
last update
1 parent 32da28b commit 8751fa2

12 files changed

+51
-98
lines changed

BundleExporter/BundleExporter.csproj

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
56
<Authors>aianlinb</Authors>
67
<Copyright>Copyright © 2020-2021 aianlinb.</Copyright>
7-
<AssemblyVersion>2.3.0.0</AssemblyVersion>
8+
<Version>2.6.0</Version>
89
<Platforms>x64</Platforms>
9-
<OutputType>Exe</OutputType>
10-
</PropertyGroup>
11-
12-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
13-
<OutputPath>..\Release</OutputPath>
14-
<DefineConstants>DEBUG;TRACE</DefineConstants>
15-
<DebugType>full</DebugType>
16-
<PlatformTarget>x64</PlatformTarget>
17-
</PropertyGroup>
18-
19-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
20-
<OutputPath>..\Release\Release</OutputPath>
2110
<PlatformTarget>x64</PlatformTarget>
22-
<Optimize>true</Optimize>
2311
</PropertyGroup>
2412

2513
<ItemGroup>
+4-16
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
56
<Authors>aianlinb</Authors>
67
<Copyright>Copyright © 2020-2021 aianlinb.</Copyright>
7-
<AssemblyVersion>2.3.0.0</AssemblyVersion>
8+
<Version>2.6.0</Version>
89
<Platforms>x64</Platforms>
9-
<OutputType>Exe</OutputType>
10-
</PropertyGroup>
11-
12-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
13-
<OutputPath>..\Release</OutputPath>
14-
<DefineConstants>DEBUG;TRACE</DefineConstants>
15-
<DebugType>full</DebugType>
16-
<PlatformTarget>x64</PlatformTarget>
17-
</PropertyGroup>
18-
19-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
20-
<OutputPath>..\Release\Release</OutputPath>
2110
<PlatformTarget>x64</PlatformTarget>
22-
<Optimize>true</Optimize>
2311
</PropertyGroup>
2412

2513
<ItemGroup>
2614
<ProjectReference Include="..\LibBundle\LibBundle.csproj" />
2715
</ItemGroup>
2816

29-
</Project>
17+
</Project>

LibBundle/BundleContainer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace LibBundle {
77
public class BundleContainer {
8-
[DllImport("oo2core_8_win64.dll")]
8+
[DllImport("oo2core_9_win64.dll")]
99
public static extern int OodleLZ_Decompress(byte[] buffer, int bufferSize, byte[] result, long outputBufferSize, int a, int b, int c, IntPtr d, long e, IntPtr f, IntPtr g, IntPtr h, long i, int ThreadModule);
10-
[DllImport("oo2core_8_win64.dll")]
10+
[DllImport("oo2core_9_win64.dll")]
1111
public static extern int OodleLZ_Compress(ENCODE_TYPES format, byte[] buffer, long bufferSize, byte[] outputBuffer, COMPRESSTION_LEVEL level, IntPtr opts, long offs, long unused, IntPtr scratch, long scratch_size);
1212
public enum ENCODE_TYPES {
1313
LZH = 0,

LibBundle/IndexContainer.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using LibBundle.Records;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
54
using System.Text;
65

76
namespace LibBundle
@@ -12,8 +11,8 @@ public class IndexContainer
1211
public readonly BundleRecord[] Bundles;
1312
public readonly FileRecord[] Files;
1413
public readonly DirectoryRecord[] Directorys;
15-
public readonly Dictionary<ulong, FileRecord> FindFiles = new Dictionary<ulong, FileRecord>();
16-
public readonly HashSet<string> Paths = new HashSet<string>();
14+
public readonly Dictionary<ulong, FileRecord> FindFiles = new();
15+
public readonly HashSet<string> Paths = new();
1716
public readonly byte[] directoryBundleData;
1817

1918
protected static BinaryReader tmp;
@@ -169,7 +168,9 @@ public virtual byte[] Save()
169168
public virtual BundleRecord GetSmallestBundle(IList<BundleRecord> Bundles = null)
170169
{
171170
Bundles ??= this.Bundles;
172-
var result = Bundles.ElementAt(0);
171+
if (Bundles.Count == 0)
172+
return null;
173+
var result = Bundles[0];
173174
var l = Bundles[0].UncompressedSize;
174175
foreach (var b in Bundles)
175176
if (b.UncompressedSize < l)
@@ -191,7 +192,7 @@ public static ulong FNV1a64Hash(string str)
191192
var hash = 0xCBF29CE484222325UL;
192193
foreach (var by in bs)
193194
hash = (hash ^ by) * 0x100000001B3UL;
194-
// Equal to: bs.Aggregate(0xCBF29CE484222325UL, (current, by) => (current ^ by) * 0x100000001B3);
195+
// Equals to: bs.Aggregate(0xCBF29CE484222325UL, (current, by) => (current ^ by) * 0x100000001B3);
195196
return hash;
196197
}
197198
}

LibBundle/LibBundle.csproj

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<Authors>aianlinb</Authors>
6-
<Copyright>Copyright © 2020-2021 aianlinb.</Copyright>
7-
<AssemblyVersion>2.4.6.0</AssemblyVersion>
6+
<Copyright>Copyright © 2020-2022 aianlinb.</Copyright>
7+
<Version>2.6.0</Version>
88
<Platforms>x64</Platforms>
9-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
10-
</PropertyGroup>
11-
12-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
13-
<OutputPath>..\Release</OutputPath>
14-
<DefineConstants>DEBUG;TRACE</DefineConstants>
15-
<DebugType>full</DebugType>
16-
<PlatformTarget>x64</PlatformTarget>
17-
</PropertyGroup>
18-
19-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
20-
<OutputPath>..\Release\Release</OutputPath>
219
<PlatformTarget>x64</PlatformTarget>
22-
<Optimize>true</Optimize>
10+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
2311
</PropertyGroup>
2412

25-
</Project>
13+
</Project>

LibBundle/Records/BundleRecord.cs

+18-17
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,51 @@ namespace LibBundle.Records
77
{
88
public class BundleRecord
99
{
10-
public long IndexOffset;
1110
public int NameLength;
1211
public string Name;
1312
public int UncompressedSize;
1413

1514
public int bundleIndex;
1615
public int validSize;
17-
public readonly List<FileRecord> Files = new List<FileRecord>();
18-
internal readonly Dictionary<FileRecord, byte[]> FileToAdd = new Dictionary<FileRecord, byte[]>();
16+
public readonly List<FileRecord> Files = new();
17+
internal readonly Dictionary<FileRecord, byte[]> FileToAdd = new();
1918
protected BundleContainer _bundle;
19+
private bool bundleNull;
2020

2121
public BundleContainer Bundle
2222
{
2323
get
2424
{
25+
if (bundleNull)
26+
return null;
2527
Read();
2628
return _bundle;
2729
}
2830
}
2931

3032
public BundleRecord(BinaryReader br)
3133
{
32-
IndexOffset = br.BaseStream.Position;
3334
NameLength = br.ReadInt32();
3435
Name = Encoding.UTF8.GetString(br.ReadBytes(NameLength)) + ".bundle.bin";
3536
UncompressedSize = br.ReadInt32();
3637
}
3738

38-
public virtual void Read(BinaryReader br = null, long? Offset = null)
39-
{
39+
public virtual void Read(BinaryReader br = null, long? Offset = null) {
4040
if (_bundle != null) return;
41-
if (Offset.HasValue)
42-
{
41+
if (Offset.HasValue) {
4342
br.BaseStream.Seek(Offset.Value, SeekOrigin.Begin);
4443
_bundle = new BundleContainer(br);
45-
}
46-
else if (br == null)
47-
{
44+
} else if (br == null)
4845
_bundle = new BundleContainer(Name);
49-
}
46+
47+
// This will result in reading from the wrong place when bundle.bin is not found
48+
/*
5049
else
51-
{
5250
_bundle = new BundleContainer(br);
53-
}
51+
*/
52+
53+
else
54+
bundleNull = true;
5455
}
5556

5657
public virtual void Save(string newPath = null, string originalPath = null)
@@ -64,7 +65,7 @@ public virtual void Save(string newPath = null, string originalPath = null)
6465
d.Key.Offset = (int)data.Position + Bundle.uncompressed_size;
6566
data.Write(d.Value, 0, d.Key.Size);
6667
}
67-
UncompressedSize = (int)data.Length + Bundle.uncompressed_size;
68+
UncompressedSize = validSize = (int)data.Length + Bundle.uncompressed_size;
6869
FileToAdd.Clear();
6970
if (newPath != null)
7071
File.WriteAllBytes(newPath, Bundle.AppendAndSave(data, originalPath));
@@ -95,7 +96,7 @@ public virtual byte[] Save(BinaryReader br, long? Offset = null)
9596
}
9697
else
9798
{
98-
UncompressedSize = (int)data.Length + Bundle.uncompressed_size;
99+
UncompressedSize = validSize =(int)data.Length + Bundle.uncompressed_size;
99100
result = Bundle.AppendAndSave(data, br?.BaseStream ?? Bundle.Read());
100101
}
101102
FileToAdd.Clear();
@@ -113,7 +114,7 @@ public virtual void SaveWithRecompression(string newPath = null, string original
113114
d.Key.Offset = (int)data.Position;
114115
data.Write(d.Value, 0, d.Key.Size);
115116
}
116-
UncompressedSize = (int)data.Length;
117+
UncompressedSize = validSize = (int)data.Length;
117118
FileToAdd.Clear();
118119
Bundle.Save(data, newPath ?? originalPath);
119120
}

LibBundle/Records/DirectoryRecord.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ namespace LibBundle.Records
55
{
66
public class DirectoryRecord
77
{
8-
public long indexOffset;
9-
public List<FileRecord> children = new List<FileRecord>(); // Files only
8+
public List<FileRecord> children = new(); // Files only
109

1110
public ulong NameHash;
1211
public int Offset;
@@ -15,7 +14,6 @@ public class DirectoryRecord
1514

1615
public DirectoryRecord(BinaryReader br)
1716
{
18-
indexOffset = br.BaseStream.Position;
1917
NameHash = br.ReadUInt64();
2018
Offset = br.ReadInt32();
2119
Size = br.ReadInt32();

LibBundle/Records/FileRecord.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace LibBundle.Records
44
{
55
public class FileRecord
66
{
7-
public long indexOffset;
87
public BundleRecord bundleRecord;
98
public DirectoryRecord parent;
109
public string path;
@@ -16,7 +15,6 @@ public class FileRecord
1615

1716
public FileRecord(BinaryReader br)
1817
{
19-
indexOffset = br.BaseStream.Position;
2018
NameHash = br.ReadUInt64();
2119
BundleIndex = br.ReadInt32();
2220
Offset = br.ReadInt32();
@@ -37,7 +35,8 @@ public virtual void Move(BundleRecord target)
3735
{
3836
if (bundleRecord.FileToAdd.TryGetValue(this, out var data))
3937
bundleRecord.FileToAdd.Remove(this);
40-
else data = Read();
38+
else
39+
data = Read();
4140
bundleRecord.Files.Remove(this);
4241
target.Files.Add(this);
4342
target.FileToAdd[this] = data;

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This repository is deprecated
2+
See https://github.com/aianlinb/LibGGPK2
13
# LibBundle
24
Library for handling *.bundle.bin in GGPK of game PathOfExile after version 3.11.2
35
# VisualBundle

VisualBundle/MainWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Window x:Class="VisualBundle.MainWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
Title="VisualBundle v2.3.1" Height="480" Width="850" Loaded="OnLoaded" Closing="OnWindowClosing" DragEnter="OnDragEnter" Drop="OnDragDrop" AllowDrop="True">
4+
Title="VisualBundle v2.6.0" Height="480" Width="850" Loaded="OnLoaded" Closing="OnWindowClosing" DragEnter="OnDragEnter" Drop="OnDragDrop" AllowDrop="True">
55
<Window.Resources>
66
<HierarchicalDataTemplate x:Key="FileViewItemTemplate" DataType="x:Type VisualBundle:ItemModel" ItemsSource="{Binding ChildItems}">
77
<StackPanel Orientation="Horizontal">

VisualBundle/MainWindow.xaml.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public partial class MainWindow : Window
2626

2727
public MainWindow()
2828
{
29-
InitializeComponent();
3029
Application.Current.DispatcherUnhandledException += OnUnhandledException;
30+
InitializeComponent();
3131
}
3232

3333
public void OnUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
@@ -158,7 +158,7 @@ private void OnTreeView1SelectedChanged(object sender, RoutedPropertyChangedEven
158158
}
159159
else //Selected Bundle File
160160
{
161-
offsetView.Text = br.IndexOffset.ToString();
161+
offsetView.Text = "";
162162
sizeView.Text = br.UncompressedSize.ToString();
163163
noView.Text = br.bundleIndex.ToString();
164164
var root = new FolderModel("Bundles2");
@@ -199,7 +199,7 @@ private void OnTreeView2SelectedChanged(object sender, RoutedPropertyChangedEven
199199
else //Selected File
200200
{
201201
BOffsetView.Text = fr.Offset.ToString();
202-
IOffsetView.Text = fr.indexOffset.ToString();
202+
IOffsetView.Text = "";
203203
fSizeView.Text = fr.Size.ToString();
204204
ButtonExport.IsEnabled = true;
205205
ButtonReplace.IsEnabled = true;

VisualBundle/VisualBundle.csproj

+4-16
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net5.0-windows</TargetFramework>
6-
<UseWPF>true</UseWPF>
5+
<TargetFramework>net6.0-windows</TargetFramework>
76
<Authors>aianlinb</Authors>
87
<Copyright>Copyright © 2020-2021 aianlinb</Copyright>
9-
<AssemblyVersion>2.3.0.0</AssemblyVersion>
8+
<Version>2.6.0</Version>
109
<Platforms>x64</Platforms>
11-
</PropertyGroup>
12-
13-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
14-
<OutputPath>..\Release</OutputPath>
15-
<DefineConstants>DEBUG;TRACE</DefineConstants>
16-
<DebugType>full</DebugType>
1710
<PlatformTarget>x64</PlatformTarget>
18-
</PropertyGroup>
19-
20-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
21-
<OutputPath>..\Release\Release</OutputPath>
22-
<PlatformTarget>x64</PlatformTarget>
23-
<Optimize>true</Optimize>
11+
<UseWPF>true</UseWPF>
2412
</PropertyGroup>
2513

2614
<ItemGroup>
@@ -42,4 +30,4 @@
4230
</EmbeddedResource>
4331
</ItemGroup>
4432

45-
</Project>
33+
</Project>

0 commit comments

Comments
 (0)