chovy-sign/GameBuilder/Psp/NpDrmPsar.cs

59 lines
1.6 KiB
C#
Raw Normal View History

using Li.Progress;
using Li.Utilities;
2023-04-16 19:48:32 +00:00
using PspCrypto;
2023-04-14 03:55:11 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
2023-04-16 13:07:43 +00:00
namespace GameBuilder.Psp
2023-04-14 03:55:11 +00:00
{
2023-04-16 19:48:32 +00:00
public abstract class NpDrmPsar : ProgressTracker, IDisposable
2023-04-14 03:55:11 +00:00
{
2023-04-15 17:22:43 +00:00
public NpDrmPsar(NpDrmInfo npDrmInfo)
2023-04-14 03:55:11 +00:00
{
2023-04-15 17:22:43 +00:00
DrmInfo = npDrmInfo;
2023-04-14 03:55:11 +00:00
Psar = new MemoryStream();
psarUtil = new StreamUtil(Psar);
2023-04-16 19:48:32 +00:00
2023-04-14 03:55:11 +00:00
}
2023-04-15 17:22:43 +00:00
public NpDrmInfo DrmInfo;
2023-04-14 03:55:11 +00:00
public MemoryStream Psar;
internal StreamUtil psarUtil;
public abstract void CreatePsar();
2023-04-15 17:22:43 +00:00
public abstract byte[] GenerateDataPsp();
public static byte[] CreateStartDat(byte[] image)
{
using(MemoryStream startDatStream = new MemoryStream())
{
StreamUtil startDatUtil = new StreamUtil(startDatStream);
startDatUtil.WriteStr("STARTDAT");
startDatUtil.WriteInt32(0x1);
startDatUtil.WriteInt32(0x1);
startDatUtil.WriteInt32(0x50);
startDatUtil.WriteInt32(image.Length);
startDatUtil.WriteInt32(0x0);
startDatUtil.WriteInt32(0x0);
startDatUtil.WritePadding(0, 0x30);
startDatUtil.WriteBytes(image);
startDatStream.Seek(0x00, SeekOrigin.Begin);
return startDatStream.ToArray();
}
}
2023-04-14 03:55:11 +00:00
public virtual void Dispose()
{
Psar.Dispose();
}
}
}