Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #68 from zerfl/hero-skills
Browse files Browse the repository at this point in the history
Add skills to heroes
  • Loading branch information
LukeCroteau authored May 14, 2021
2 parents a547f0d + 8f41c81 commit 6d1e928
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RaidExtractor
A tool made to extract information from the windows version of "Raid: Shadow Legends". Currently it supports v0.237 (as seen in Plarium Play launcher) and currently only extracts artifacts and current champions.
A tool made to extract information from the windows version of "Raid: Shadow Legends". Currently it supports v0.239 (as seen in Plarium Play launcher) and currently only extracts artifacts and current champions.

This application has 2 Modes:
* A Windows GUI application. The functionality is slim, but it works!
Expand Down
16 changes: 16 additions & 0 deletions RaidExtractor.Core/AccountDumpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,22 @@ public partial class Hero

[Newtonsoft.Json.JsonProperty("masteries", Required = Newtonsoft.Json.Required.Always)]
public List<int> Masteries { get; set; }

[Newtonsoft.Json.JsonProperty("skills", Required = Newtonsoft.Json.Required.Always)]
public List<Skill> Skills { get; set; }
}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.24.0 (Newtonsoft.Json v11.0.0.0)")]
public partial class Skill
{
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)]
public int Id { get; set; }

[Newtonsoft.Json.JsonProperty("typeId", Required = Newtonsoft.Json.Required.Always)]
public int TypeId { get; set; }

[Newtonsoft.Json.JsonProperty("level", Required = Newtonsoft.Json.Required.Always)]
public int Level { get; set; }
}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.24.0 (Newtonsoft.Json v11.0.0.0)")]
Expand Down
41 changes: 34 additions & 7 deletions RaidExtractor.Core/Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public AccountDump GetDump()
NativeWrapper.ReadProcessMemory(handle, buckets + 0x18, ref bucketCount);

var nodes = new IntPtr[bucketCount];
if (bucketCount > 0) NativeWrapper.ReadProcessMemoryArray(handle, buckets + 0x20, nodes);
if (bucketCount > 0) NativeWrapper.ReadProcessMemoryArray(handle, buckets + RaidStaticInformation.ListElementPointerArray, nodes);

for (var i = 0; i < nodes.Length; i++)
{
Expand Down Expand Up @@ -165,13 +165,13 @@ public AccountDump GetDump()

var bonusesPointer = artifactStruct.SecondaryBonuses;
var bonusCount = 0;
NativeWrapper.ReadProcessMemory(handle, bonusesPointer + 0x18, ref bonusCount);
NativeWrapper.ReadProcessMemory(handle, bonusesPointer + 0x10, ref bonusesPointer);
NativeWrapper.ReadProcessMemory(handle, bonusesPointer + RaidStaticInformation.ListCount, ref bonusCount);
NativeWrapper.ReadProcessMemory(handle, bonusesPointer + RaidStaticInformation.ListIndexArray, ref bonusesPointer);

artifact.SecondaryBonuses = new List<ArtifactBonus>();

var bonuses = new IntPtr[bonusCount];
if (bonusCount > 0) NativeWrapper.ReadProcessMemoryArray(handle, bonusesPointer + 0x20, bonuses, 0, bonuses.Length);
if (bonusCount > 0) NativeWrapper.ReadProcessMemoryArray(handle, bonusesPointer + RaidStaticInformation.ListElementPointerArray, bonuses, 0, bonuses.Length);

foreach (var bonusPointer in bonuses)
{
Expand Down Expand Up @@ -208,6 +208,7 @@ public AccountDump GetDump()

var heroStruct = new HeroStruct();
var heroMasteriesStruct = new HeroMasteryDataStruct();
var skillStruct = new SkillStruct();
var heroesById = new Dictionary<int, Hero>();
var heroes = new List<Hero>();
for (var i = 0; i < count; i++)
Expand Down Expand Up @@ -238,14 +239,40 @@ public AccountDump GetDump()
var masteryCount = 0;
if (heroStruct.MasteryData != IntPtr.Zero && masteriesPtr != IntPtr.Zero)
{
NativeWrapper.ReadProcessMemory(handle, masteriesPtr + 0x18, ref masteryCount);
NativeWrapper.ReadProcessMemory(handle, masteriesPtr + 0x10, ref masteriesPtr);
NativeWrapper.ReadProcessMemory(handle, masteriesPtr + RaidStaticInformation.ListCount, ref masteryCount);
NativeWrapper.ReadProcessMemory(handle, masteriesPtr + RaidStaticInformation.ListIndexArray, ref masteriesPtr);
}

var masteries = new int[masteryCount];
if (masteryCount > 0) NativeWrapper.ReadProcessMemoryArray(handle, masteriesPtr + 0x20, masteries, 0, masteries.Length);
if (masteryCount > 0) NativeWrapper.ReadProcessMemoryArray(handle, masteriesPtr + RaidStaticInformation.ListElementPointerArray, masteries, 0, masteries.Length);
hero.Masteries.AddRange(masteries);

var skillsPtr = heroStruct.Skills;
var skillsCount = 0;
if (skillsPtr != IntPtr.Zero)
{
NativeWrapper.ReadProcessMemory(handle, heroStruct.Skills + RaidStaticInformation.ListCount, ref skillsCount);
NativeWrapper.ReadProcessMemory(handle, heroStruct.Skills + RaidStaticInformation.ListIndexArray, ref skillsPtr);
}

hero.Skills = new List<Skill>();
var skills = new IntPtr[skillsCount];
if (skillsCount > 0) NativeWrapper.ReadProcessMemoryArray(handle, skillsPtr + RaidStaticInformation.ListElementPointerArray, skills, 0, skills.Length);

foreach (var skillPointer in skills)
{
NativeWrapper.ReadProcessMemory(handle, skillPointer, ref skillStruct);

var skill = new Skill
{
Id = skillStruct.Id,
TypeId = skillStruct.TypeId,
Level = skillStruct.Level,
};

hero.Skills.Add(skill);
}

if (heroTypeById.TryGetValue(hero.TypeId, out var heroType))
{
hero.Name = heroType.Name;
Expand Down
16 changes: 16 additions & 0 deletions RaidExtractor.Core/Native/SkillStruct.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Runtime.InteropServices;

namespace RaidExtractor.Core.Native
{
[StructLayout(LayoutKind.Explicit)]
public struct SkillStruct
{
[FieldOffset(0x18)]
public int Id;
[FieldOffset(0x1C)]
public int TypeId;
[FieldOffset(0x20)]
public int Level;
}
}

0 comments on commit 6d1e928

Please sign in to comment.