Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to change the Winning player data struct offsets, and…
… PlayerInfo structs on the fly.
- Loading branch information
1 parent
e801714
commit 94356c7
Showing
12 changed files
with
150 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,70 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using AUOffsetManager; | ||
using Discord; | ||
|
||
namespace AmongUsCapture | ||
{ | ||
|
||
public interface PlayerInfo | ||
public class PlayerInfo | ||
{ | ||
public abstract byte PlayerId { get; } | ||
public abstract IntPtr PlayerName {get; } | ||
public abstract byte ColorId { get; } | ||
public abstract uint HatId { get; } | ||
public abstract uint PetId { get; } | ||
public abstract uint SkinId { get; } | ||
public abstract byte Disconnected { get; } | ||
public abstract IntPtr Tasks { get; } | ||
public abstract byte IsImpostor { get; } | ||
public abstract byte IsDead { get; } | ||
public abstract IntPtr _object { get; } | ||
|
||
public bool GetIsDead() | ||
{ | ||
return this.IsDead > 0; | ||
public byte PlayerId; | ||
public String PlayerName; | ||
public PlayerColor ColorId; | ||
public uint HatId; | ||
public uint PetId; | ||
public uint SkinId; | ||
public bool Disconnected; | ||
public IntPtr Tasks; | ||
public bool IsImpostor; | ||
public bool IsDead; | ||
public IntPtr _object; //Assume this always has largest offset | ||
public PlayerInfo(IntPtr baseAddr, ProcessMemory MemInstance, GameOffsets CurrentOffsets) { | ||
unsafe { | ||
var baseAddrCopy = baseAddr; | ||
int last = MemInstance.OffsetAddress(ref baseAddrCopy, 0, 0); | ||
var intPtrSize = MemInstance.is64Bit ? 8 : 4; | ||
int size = ((int)Math.Ceiling((decimal) ((intPtrSize + CurrentOffsets.PlayerInfoStructOffsets.ObjectOffset)/8)))*8; //Find the nearest multiple of 8 | ||
byte[] buffer = MemInstance.Read(baseAddrCopy + last, size); | ||
PlayerInfoStructOffsets pOf = CurrentOffsets.PlayerInfoStructOffsets; | ||
fixed (byte* ptr = buffer) { | ||
var buffptr = (IntPtr) ptr; | ||
PlayerId = Marshal.ReadByte(buffptr, pOf.PlayerIDOffset); | ||
var NamePTR = Marshal.ReadIntPtr(buffptr, pOf.PlayerNameOffset); | ||
PlayerName = NamePTR == IntPtr.Zero ? "" : MemInstance.ReadString(NamePTR, CurrentOffsets.StringOffsets[0], CurrentOffsets.StringOffsets[1]); | ||
ColorId = (PlayerColor)(uint)Marshal.ReadInt32(buffptr, pOf.ColorIDOffset); | ||
HatId = (uint) Marshal.ReadInt32(buffptr, pOf.HatIDOffset); | ||
PetId = (uint) Marshal.ReadInt32(buffptr, pOf.PetIDOffset); | ||
SkinId = (uint) Marshal.ReadInt32(buffptr, pOf.SkinIDOffset); | ||
Disconnected = Marshal.ReadByte(buffptr, pOf.DisconnectedOffset) > 0; | ||
Tasks = Marshal.ReadIntPtr(buffptr, pOf.TasksOffset); | ||
IsImpostor = Marshal.ReadByte(buffptr, pOf.ImposterOffset) == 1; | ||
IsDead = Marshal.ReadByte(buffptr, pOf.DeadOffset) > 0; | ||
_object = Marshal.ReadIntPtr(buffptr, pOf.ObjectOffset); | ||
} | ||
} | ||
} | ||
|
||
public string GetPlayerName() | ||
public string GetPlayerName() { | ||
return PlayerName; | ||
} | ||
public bool GetIsDead() | ||
{ | ||
return ProcessMemory.getInstance().ReadString((IntPtr)this.PlayerName, 0x10, 0x14); | ||
return IsDead; | ||
} | ||
|
||
public bool GetIsImposter() | ||
{ | ||
return this.IsImpostor == 1; | ||
return IsImpostor; | ||
} | ||
|
||
public PlayerColor GetPlayerColor() | ||
{ | ||
return (PlayerColor)this.ColorId; | ||
return ColorId; | ||
} | ||
|
||
public bool GetIsDisconnected() | ||
{ | ||
return this.Disconnected > 0; | ||
return Disconnected; | ||
} | ||
} | ||
} |
Oops, something went wrong.