Skip to content

Commit

Permalink
Merge branch 'cjmanca-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Icehunter committed Jul 3, 2015
2 parents 4846eeb + 30f858c commit c962b87
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 73 deletions.
24 changes: 18 additions & 6 deletions FFXIVAPP.Client/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,6 @@ public static void SetSignatures()
Value = "47616D654D61696E000000",
Offset = 1344 // pre 3.0 = 1260
});
//AppViewModel.Instance.Signatures.Add(new Signature
//{
// Key = "CHARMAP",
// Value = "DB0F49416F12833AFFFFFFFF00000000000000000000000000000000????????DB0FC940AAAA26416D30763FDB0FC93FDB0F49416F12833A",
// Offset = 476 // pre 3.0 2.4
//});
AppViewModel.Instance.Signatures.Add(new Signature
{
Key = "CHARMAP",
Expand Down Expand Up @@ -736,6 +730,24 @@ public static void SetSignatures()
Value = "0000??00000000000000DB0FC940AAAA26416D30763FDB0FC93FDB0F49416F12833AFFFFFFFF00000000??00??00??00??00??????00??00????0000????????????",
Offset = 106
});

MemoryHandler.Instance.PointerPaths["CHARMAP"] = new List<uint>()
{
0x003B1710,
0x18
};

MemoryHandler.Instance.PointerPaths["AGRO"] = new List<uint>()
{
0x002321B4,
0x0
};
MemoryHandler.Instance.PointerPaths["AGRO_COUNT"] = new List<uint>()
{
0x002321B4,
0x900
};

break;
}
}
Expand Down
38 changes: 37 additions & 1 deletion FFXIVAPP.Client/Memory/MemoryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
// POSSIBILITY OF SUCH DAMAGE.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
Expand All @@ -48,6 +49,7 @@ public class MemoryHandler : INotifyPropertyChanged
#region Property Bindings

private static MemoryHandler _instance;
private Dictionary<string, List<uint>> _pointerPaths;
private Process _process;
private IntPtr _processHandle;
private SigScanner _sigScanner;
Expand Down Expand Up @@ -91,6 +93,16 @@ public SigScanner SigScanner
}
}

public Dictionary<String, List<uint>> PointerPaths
{
get { return _pointerPaths ?? (_pointerPaths = new Dictionary<string, List<uint>>()); }
set
{
_pointerPaths = value;
RaisePropertyChanged();
}
}

#endregion

#region Private Structs
Expand Down Expand Up @@ -134,7 +146,7 @@ public void SetProcess(Process process)
Process = process;
try
{
ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)process.Id);
ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint) process.Id);
}
catch (Exception ex)
{
Expand All @@ -144,6 +156,30 @@ public void SetProcess(Process process)
SigScanner.Locations.Clear();
}

public static uint ResolvePointerPath(string pathname)
{
return Instance._pointerPaths.ContainsKey(pathname) ? ResolvePointerPath(Instance._pointerPaths[pathname]) : 0;
}

public static uint ResolvePointerPath(IEnumerable<uint> path)
{
var address = GetStaticAddress(0);
var nextAddress = address;

foreach (var offset in path)
{
address = nextAddress + offset;
nextAddress = (uint) Instance.GetInt32(address);
}

return address;
}

public static uint GetStaticAddress(uint offset)
{
return (uint) Instance.Process.MainModule.BaseAddress.ToInt64() + offset;
}

/// <summary>
/// </summary>
/// <param name="address"> </param>
Expand Down
6 changes: 3 additions & 3 deletions FFXIVAPP.Client/Memory/MonsterWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e)
var endianSize = 4;
var limit = 344;
var chunkSize = endianSize * limit;

var characterAddressMap = MemoryHandler.Instance.GetByteArray(MemoryHandler.Instance.SigScanner.Locations["CHARMAP"], chunkSize);

var sourceData = new List<byte[]>();

for (var i = 0; i <= (chunkSize / endianSize); i += endianSize)
{
var characterAddress = BitConverter.ToUInt32(characterAddressMap, i);
Expand Down
141 changes: 82 additions & 59 deletions FFXIVAPP.Client/Memory/PartyInfoWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e)
{
var partyEntities = new List<PartyEntity>();
var partyCount = MemoryHandler.Instance.GetByte(PartyCountMap);

if (partyCount > 0 && partyCount < 9)
{
for (uint i = 0; i < partyCount; i++)
Expand All @@ -135,71 +136,22 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e)
}
var address = PartyInfoMap + (i * size);
var actor = MemoryHandler.Instance.GetStructure<Structures.PartyMember>(address);
var entry = new PartyEntity
{
Name = MemoryHandler.Instance.GetString(address, 32),
ID = actor.ID,
Coordinate = new Coordinate(actor.X, actor.Z, actor.Y),
X = actor.X,
Z = actor.Z,
Y = actor.Y,
Level = actor.Level,
HPCurrent = actor.HPCurrent,
HPMax = actor.HPMax,
MPCurrent = actor.MPCurrent,
MPMax = actor.MPMax,
Job = actor.Job
};
if (entry.HPMax == 0)
{
entry.HPMax = 1;
}
foreach (var status in actor.Statuses)
{
var statusEntry = new StatusEntry
{
TargetName = entry.Name,
StatusID = status.StatusID,
Duration = status.Duration,
CasterID = status.CasterID
};
try
{
var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
statusEntry.IsCompanyAction = statusInfo.CompanyAction;
var statusKey = statusInfo.Name.English;
switch (Settings.Default.GameLanguage)
{
case "French":
statusKey = statusInfo.Name.French;
break;
case "Japanese":
statusKey = statusInfo.Name.Japanese;
break;
case "German":
statusKey = statusInfo.Name.German;
break;
case "Chinese":
statusKey = statusInfo.Name.Chinese;
break;
}
statusEntry.StatusName = statusKey;
}
catch (Exception ex)
{
statusEntry.StatusName = "UNKNOWN";
}
if (statusEntry.IsValid())
{
entry.StatusEntries.Add(statusEntry);
}
}
var entry = GetPartyEntity(address, actor);
if (entry.IsValid)
{
partyEntities.Add(entry);
}
}
}
else if (partyCount == 0)
{
var actor = MemoryHandler.Instance.GetStructure<Structures.PartyMember>(PartyInfoMap);
var entry = GetPartyEntity(PartyInfoMap, actor);
if (entry.IsValid)
{
partyEntities.Add(entry);
}
}
AppContextHelper.Instance.RaiseNewPartyEntries(partyEntities);
}
catch (Exception ex)
Expand All @@ -214,6 +166,77 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e)
scannerWorker.BeginInvoke(delegate { }, scannerWorker);
}

private static PartyEntity GetPartyEntity(uint address, Structures.PartyMember actor)
{
try
{
var entry = new PartyEntity
{
Name = MemoryHandler.Instance.GetString(address, 32),
ID = actor.ID,
Coordinate = new Coordinate(actor.X, actor.Z, actor.Y),
X = actor.X,
Z = actor.Z,
Y = actor.Y,
Level = actor.Level,
HPCurrent = actor.HPCurrent,
HPMax = actor.HPMax,
MPCurrent = actor.MPCurrent,
MPMax = actor.MPMax,
Job = actor.Job
};
if (entry.HPMax == 0)
{
entry.HPMax = 1;
}
foreach (var status in actor.Statuses)
{
var statusEntry = new StatusEntry
{
TargetName = entry.Name,
StatusID = status.StatusID,
Duration = status.Duration,
CasterID = status.CasterID
};
try
{
var statusInfo = StatusEffectHelper.StatusInfo(statusEntry.StatusID);
statusEntry.IsCompanyAction = statusInfo.CompanyAction;
var statusKey = statusInfo.Name.English;
switch (Settings.Default.GameLanguage)
{
case "French":
statusKey = statusInfo.Name.French;
break;
case "Japanese":
statusKey = statusInfo.Name.Japanese;
break;
case "German":
statusKey = statusInfo.Name.German;
break;
case "Chinese":
statusKey = statusInfo.Name.Chinese;
break;
}
statusEntry.StatusName = statusKey;
}
catch (Exception ex)
{
statusEntry.StatusName = "UNKNOWN";
}
if (statusEntry.IsValid())
{
entry.StatusEntries.Add(statusEntry);
}
}
return entry;
}
catch (Exception ex)
{
}
return new PartyEntity();
}

#endregion

#region Implementation of INotifyPropertyChanged
Expand Down
11 changes: 7 additions & 4 deletions FFXIVAPP.Client/Memory/PlayerInfoWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e)
enmityStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 3384;
break;
default:
enmityCount = MemoryHandler.Instance.GetInt16(MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 0x16C35C); // 0x1C590); // 116032
enmityStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 0x16BA5C; // 0x1CE94; // 118340;
enmityStructure = MemoryHandler.ResolvePointerPath("AGRO");
enmityCount = MemoryHandler.Instance.GetInt16(MemoryHandler.ResolvePointerPath("AGRO_COUNT"));

//enmityCount = MemoryHandler.Instance.GetInt16(MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 0x16C35C); // 0x1C590); // 116032
//enmityStructure = MemoryHandler.Instance.SigScanner.Locations["CHARMAP"] + 0x16BA5C; // 0x1CE94; // 118340;
break;
}
var enmityEntries = new List<EnmityEntry>();
Expand All @@ -141,8 +144,8 @@ private void ScanTimerElapsed(object sender, ElapsedEventArgs e)
var enmityEntry = new EnmityEntry
{
Name = MemoryHandler.Instance.GetString(address),
ID = (uint)MemoryHandler.Instance.GetInt32(address + 64),
Enmity = (uint)MemoryHandler.Instance.GetInt16(address + 68)
ID = (uint) MemoryHandler.Instance.GetInt32(address + 64),
Enmity = (uint) MemoryHandler.Instance.GetInt16(address + 68)
};
if (enmityEntry.ID > 0)
{
Expand Down
Binary file modified distribution/FFXIVAPP.Client.exe
Binary file not shown.

0 comments on commit c962b87

Please sign in to comment.