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

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Text;

namespace XFEEDToolBox.Plugin;

internal static unsafe partial class Navigation
{
    internal static uint SessionMenuSelfTest()
    {
        uint passed=0;
        byte* activity=stackalloc byte[0x500];new Span<byte>(activity,0x500).Clear();
        byte* definition=stackalloc byte[0x40];new Span<byte>(definition,0x40).Clear();
        byte* category=stackalloc byte[0x58];new Span<byte>(category,0x58).Clear();
        byte* button=stackalloc byte[0x78];new Span<byte>(button,0x78).Clear();
        byte* cached=stackalloc byte[0xC8];new Span<byte>(cached,0xC8).Clear();
        nuint* table=stackalloc nuint[2];table[0]=0;
        const string action="Confirmed Quit To Main Menu";
        var textBytes=Encoding.ASCII.GetBytes(action+"\0");
        fixed(byte* actionPointer=textBytes)
        {
            var text=(nuint)actionPointer;var textAddress=(nuint)(&text);
            var a=(nuint)activity;var d=(nuint)definition;var b=(nuint)button;var cache=(nuint)cached;var cat=(nuint)category;
            table[1]=image+SessionMenuSelect;
            Write(a+0x80,(nuint)table);Write(a+0x118,(nuint)0x1234);Write(a+0x10,d);
            Write(d+0x10,1u);Write(d+8,cat);category[0]=1;Write(cat+0x48,1u);Write(cat+0x40,b);
            Write(b,textAddress);Buffer.MemoryCopy(button,cached+0x30,0x78,0x78);
            Write(cache,(ushort)0x0101);Write(a+0x240,1UL);Write(a+0x248,cache);
            SessionMenuFrame frame=new(){flow=0x1234,state="Confirm Quit To Main Menu",next="Confirm Quit To Main Menu"};
            if(ReadSessionMenu(a,ref frame)&&frame.count==1&&frame.items![0].enabled&&frame.items[0].name==action)passed|=1;
            Write(cache,(ushort)0x0100);if(ReadSessionMenu(a,ref frame)&&!frame.items![0].enabled)passed|=2;
            cached[0x35]^=1;if(!ReadSessionMenu(a,ref frame))passed|=4;cached[0x35]^=1;
            Write(a+0x240,2UL);if(!ReadSessionMenu(a,ref frame))passed|=8;Write(a+0x240,1UL);
            Write(cat+0x48,65u);if(!ReadSessionMenu(a,ref frame))passed|=16;Write(cat+0x48,1u);
            frame.next="X"+frame.state[1..];if(!ReadSessionMenu(a,ref frame))passed|=32;frame.next=frame.state;
            if(!SessionActionAllowed("Pause","QuitApplication")&&!SessionActionAllowed("Pause","QuitGame")&&!SessionActionAllowed("Pause","ExitToDesktop")&&
               !SessionActionAllowed("Pause","Cancel Quit To Main Menu")&&SessionActionAllowed("Confirm Quit To Main Menu",action)
               &&SessionActionAllowed("Pause","ExitOptions")&&SessionActionAllowed("ExitOptions",action)
               &&!SessionActionAllowed("ExitOptions","Confirmed Quit Game")&&!SessionActionAllowed("ExitOptions","Confirmed Quit To Game"))passed|=64;
            if(SessionActionAllowed("InGame","@pause")&&!SessionActionAllowed("InGame",action)&&SessionActionAllowed("ContinueMenu","SetupPlaySolo")&&
               SessionActionAllowed("ContinueMenu","SetupPlayWithEveryone")&&!SessionActionAllowed("ContinueMenu","QuitApplication")
               &&SessionEntryActionAllowed("MainMenu","ContinueMenu")&&SessionEntryActionAllowed("ContinueMenu","SetupPlaySolo")
               &&!SessionEntryActionAllowed("InGame","@pause")&&!SessionEntryActionAllowed("Pause","Quit To Main Menu"))passed|=128;
            SessionMenuFrame entryFrame=new(){valid=true,tick=1000,state="MainMenu",next="MainMenu"};Snapshot noShip=default;
            if(!ReadSessionMenu(1,ref frame)&&SessionBeginAllowed(entryFrame,noShip,true,0,1100)
               &&!SessionBeginAllowed(entryFrame,noShip,false,0,1100)&&!SessionBeginAllowed(entryFrame,noShip,true,1200,1100)
               &&!SessionBeginAllowed(entryFrame,noShip,true,0,1400))passed|=256;
            table[1]=image+SessionPauseSelect;Write(a+0xC8,frame.flow);Write(a+0x140,0UL);Write(a+0x148,1UL);Write(a+0x150,cache);Write(cache,(ushort)0x0101);
            var pauseCountCorrect=ReadSessionMenu(a,ref frame)&&frame.items![0].enabled&&frame.selector==image+SessionPauseSelect;
            Write(a+0x140,1UL);Write(a+0x148,0UL);
            if(pauseCountCorrect&&!ReadSessionMenu(a,ref frame))passed|=512;
            Write(a+0x140,0UL);Write(a+0x148,1UL);
            Write(a+0x164,15f);if(ReadSessionMenu(a,ref frame)&&!frame.items![0].enabled)passed|=1024;
            table[1]++;if(!ReadSessionMenu(a,ref frame))passed|=2048;
        }
        return passed;
    }
}