XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using static XFEEDToolBox.Plugin.Platform;

namespace XFEEDToolBox.Plugin;

internal static unsafe partial class Navigation
{
    private static uint LocalPlayerIdentitySelfTest()
    {
        // A sparse own-process fixture models the same pinned getter/global
        // addresses; only the touched pages contain data. No game is opened.
        const nuint size=0x6000000;
        var memory=Allocate(size);if(memory==0)return 0;
        try
        {
            var input=memory+0x10000;var local=memory+0x11000;var localTable=memory+0x12000;var pilot=memory+0x13000;
            var root=memory+0x14000;var metadata=memory+0x15000;var array=memory+0x16000;var slots=memory+0x17000;
            var actor=memory+0x18058;var actorTable=memory+0x19000;var rows=memory+0x1A000;var life=memory+0x1B000;
            Write(input+0x2E8,local);Write(local,localTable);Write(localTable+0x160,memory+0x978A90);Write(memory+0x978A90,0xC300000138818D48UL);
            Write(local+0x138,pilot);Write(pilot+0xC8,root+0x30);Write(root+0x10,metadata);Write(root+0x18,array);Write(metadata+0x18,1UL);Write(metadata+0x30,slots);
            Write(memory+0x5F05BA4,1u);Write(slots+16,0UL);Write(array,actor);Write(actor,actorTable);Write(actorTable+0x68,memory+0x2561290);
            Write(actor-0x58+0x970,1UL);Write(actor-0x58+0x978,rows);Write(rows+0x190,(byte)2);Write(rows+0x1B0,life);Write(rows+0x1B8,0);
            Write(life+0xC0,8u);Write(life+0xC8,root+0x30);
            nuint Read()=>LocalPlayerIdentity.ReadLife(input,memory,memory+size);uint passed=0;
            if(Read()==life)passed|=1;
            if(Read()!=life+8)passed|=2;
            Write(localTable+0x160,(nuint)0);if(Read()==0)passed|=4;Write(localTable+0x160,memory+0x978A90);
            Write(actorTable+0x68,(nuint)0);if(Read()==0)passed|=8;Write(actorTable+0x68,memory+0x2561290);
            Write(actor-0x58+0x970,33UL);if(Read()==0)passed|=16;Write(actor-0x58+0x970,1UL);
            Write(life+0xC0,7u);if(Read()==0)passed|=32;Write(life+0xC0,8u);
            Write(slots+16,1UL);if(Read()==0)passed|=64;Write(slots+16,0UL);
            Write(rows+0x1B8,-1);if(Read()==0)passed|=128;
            return passed;
        }
        finally{Free(memory);}
    }
#if PLUGIN_NAVIGATION
    [UnmanagedCallersOnly(EntryPoint="XFENavigationLocalPlayerIdentitySelfTest")]
    internal static uint ExportLocalPlayerIdentitySelfTest()=>RunTest(LocalPlayerIdentitySelfTest);
#endif
}