Adding memory violations catches and null checks to NameString and GameObj
This commit is contained in:
@@ -955,7 +955,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
private unsafe void CheckCharacterForDrawing(nint address, string characterName)
|
||||
{
|
||||
if (address == nint.Zero)
|
||||
return;
|
||||
|
||||
var gameObj = (GameObject*)address;
|
||||
|
||||
if (gameObj == null || gameObj->ObjectKind == 0)
|
||||
return;
|
||||
var drawObj = gameObj->DrawObject;
|
||||
bool isDrawing = false;
|
||||
bool isDrawingChanged = false;
|
||||
@@ -1052,16 +1058,28 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
if (!IsAnythingDrawing)
|
||||
{
|
||||
var gameObj = (GameObject*)playerAddress;
|
||||
var currentName = gameObj != null ? gameObj->NameString ?? string.Empty : string.Empty;
|
||||
var charaName = string.IsNullOrEmpty(currentName) ? actor.Name : currentName;
|
||||
CheckCharacterForDrawing(playerAddress, charaName);
|
||||
if (IsAnythingDrawing)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
try
|
||||
{
|
||||
var gameObj = (GameObject*)playerAddress;
|
||||
|
||||
if (gameObj == null || gameObj->ObjectKind == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var currentName = gameObj->NameString ?? string.Empty;
|
||||
var charaName = string.IsNullOrEmpty(currentName) ? actor.Name : currentName;
|
||||
|
||||
CheckCharacterForDrawing(playerAddress, charaName);
|
||||
|
||||
if (IsAnythingDrawing)
|
||||
break;
|
||||
}
|
||||
catch (AccessViolationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Memory access violation reading character at {addr}", playerAddress.ToString("X"));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user