Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ private bool TryReadDirectClientState(
ClientContextTargetObjectId);
}

if (!memory.TryReadUInt32(
// A bool: client.exe only reads and writes this field with byte moves.
// The three bytes after it are padding the client never initializes,
// so a 32-bit read can see stale heap data and never reach zero.
if (!memory.TryReadByte(
clientContextAddress +
ClientContextLoadingOrTransitionFlag,
out var loadingOrTransitionFlag))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public sealed record ClientNavigationStateObservation
public uint CurrentClientTime { get; init; }

/// <summary>
/// Raw SClient +0x1198 gate around part of frame processing. Its broader
/// SClient +0x1198 gate (a bool) around part of frame processing. Its broader
/// semantic meaning is intentionally not named as a loading flag.
/// </summary>
public uint FrameProcessingGateFlag { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ public ClientNavigationStateObservation Observe(
ClientContextLocalPlayerObjectId,
out var localPlayerObjectId);

_ = TryReadUInt32(
memory,
clientContextAddress,
// A bool, the same field as ClientSessionObserver's
// LoadingOrTransitionFlag; see there.
_ = memory.TryReadByte(
clientContextAddress +
ClientContextFrameProcessingGate,
out var frameProcessingGateFlag);

Expand Down
19 changes: 19 additions & 0 deletions Source/Net7ClientManager.Observations/ProcessMemoryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ public bool TryReadUInt32(
return true;
}

public bool TryReadByte(
uint address,
out byte value)
{
value = 0;

if (!this.TryReadBytes(
address,
1,
out var bytes))
{
return false;
}

value = bytes[0];

return true;
}

public bool TryReadBytes(
uint address,
int length,
Expand Down