예제 #1
0
        public bool WriteAccount(int index, API.XOnline.ONLINE_USER_ACCOUNT_STRUCT account)
        {
            int max = MaxAccounts;

            if (max == 0 || (index > (max - 1)))
            {
                return(false);
            }
            if (!API.XOnline.SignOnlineUserSignature(ref account))
            {
                return(false);
            }
            if (Win32.SetFilePointer(handle, 0, IntPtr.Zero, Win32.MoveMethod.FILE_BEGIN) != Win32.INVALID_SET_FILE_POINTER)
            {
                byte[] sectors = new byte[0x400];                                                   //2 sectors (1 sector = 512 bytes (0x200))
                uint   read    = 0;
                if (Win32.ReadFile(handle, sectors, 0x400, ref read, IntPtr.Zero) && read == 0x400) //read the FATX header out
                {
                    if (Win32.SetFilePointer(handle, 0, IntPtr.Zero, Win32.MoveMethod.FILE_BEGIN) != Win32.INVALID_SET_FILE_POINTER)
                    {
                        byte[] buffer = account.Serialize();
                        Array.Copy(buffer, 0, sectors, (0x50 + (index * 0x6C)), 0x6C);         //copy the account data into the header
                        uint written = 0;
                        if (Win32.WriteFile(handle, sectors, 0x400, ref written, IntPtr.Zero)) //write the FATX header back
                        {
                            return(written == 0x400);
                        }
                    }
                }
            }
            return(false);
        }
예제 #2
0
        public bool WriteAccount(int index, API.XOnline.ONLINE_USER_ACCOUNT_STRUCT account)
        {
            int max = MaxAccounts;

            if (max == 0 || (index > (max - 1)))
            {
                return(false);
            }
            if (!API.XOnline.SignOnlineUserSignature(ref account))
            {
                return(false);
            }
            byte[] buffer = account.Serialize();
            try
            {
                stream.Seek((0x50 + (index * 0x6C)), SeekOrigin.Begin);
                stream.Write(buffer, 0, 0x6C);
                stream.Flush();
            }
            catch { return(false); }
            return(true);
        }