コード例 #1
0
ファイル: Xbox.FileSystem.cs プロジェクト: CodeAsm/open-sauce
        /// <summary>
        /// Dont use this, higher-level methods are available.  Use GetDriveFreeSpace or GetDriveSize instead.
        /// </summary>
        /// <param name="drive"></param>
        /// <param name="freeBytes"></param>
        /// <param name="driveSize"></param>
        /// <param name="totalFreeBytes"></param>
        private void GetDriveInformation(DriveLabel drive, out ulong freeBytes, out ulong driveSize, out ulong totalFreeBytes)
        {
            freeBytes = 0; driveSize = 0; totalFreeBytes = 0;
            SendCommand("drivefreespace name=\"{0}\"", drive.ToString() + ":\\");

            string msg = ReceiveMultilineResponse();
            freeBytes = Convert.ToUInt64(msg.Substring(msg.IndexOf("freetocallerlo") + 17, 8), 16);
            freeBytes |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("freetocallerhi") + 17, 8), 16) << 32);

            driveSize = Convert.ToUInt64(msg.Substring(msg.IndexOf("totalbyteslo") + 15, 8), 16);
            driveSize |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("totalbyteshi") + 15, 8), 16) << 32);

            totalFreeBytes = Convert.ToUInt64(msg.Substring(msg.IndexOf("totalfreebyteslo") + 19, 8), 16);
            totalFreeBytes |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("totalfreebyteshi") + 19, 8), 16) << 32);
        }
コード例 #2
0
        /// <summary>
        /// Unmounts the specified drive.
        /// </summary>
        /// <param name="drive">Drive letter.</param>
        public void UnMountDevice(DriveLabel drive)
        {
            string driveName = "\\??\\" + drive.ToString() + ":";

            // send unmounting info to xbox
            SetMemory(History.ScratchBuffer, (ushort)driveName.Length, (ushort)(driveName.Length + 1),
                      (uint)(History.ScratchBuffer + 8), driveName);

            // attempt to unmount device
            uint error = CallAddressEx(Kernel.IoDeleteSymbolicLink, null, true, History.ScratchBuffer);

            if (error != 0)
            {
                throw new ApiException("Failed to unmount the device");
            }
        }
コード例 #3
0
        /// <summary>
        /// Dont use this, higher-level methods are available.  Use GetDriveFreeSpace or GetDriveSize instead.
        /// </summary>
        /// <param name="drive"></param>
        /// <param name="freeBytes"></param>
        /// <param name="driveSize"></param>
        /// <param name="totalFreeBytes"></param>
        private void GetDriveInformation(DriveLabel drive, out ulong freeBytes, out ulong driveSize, out ulong totalFreeBytes)
        {
            freeBytes = 0; driveSize = 0; totalFreeBytes = 0;
            SendCommand("drivefreespace name=\"{0}\"", drive.ToString() + ":\\");

            string msg = ReceiveMultilineResponse();

            freeBytes  = Convert.ToUInt64(msg.Substring(msg.IndexOf("freetocallerlo") + 17, 8), 16);
            freeBytes |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("freetocallerhi") + 17, 8), 16) << 32);

            driveSize  = Convert.ToUInt64(msg.Substring(msg.IndexOf("totalbyteslo") + 15, 8), 16);
            driveSize |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("totalbyteshi") + 15, 8), 16) << 32);

            totalFreeBytes  = Convert.ToUInt64(msg.Substring(msg.IndexOf("totalfreebyteslo") + 19, 8), 16);
            totalFreeBytes |= (Convert.ToUInt64(msg.Substring(msg.IndexOf("totalfreebyteshi") + 19, 8), 16) << 32);
        }
コード例 #4
0
        /// <summary>
        /// Mounts the specified device to the specified drive letter.
        /// </summary>
        /// <param name="device">Device name</param>
        /// <param name="drive">Drive letter</param>
        public void MountDevice(Drive device, DriveLabel drive)
        {
            string driveName  = "\\??\\" + drive.ToString() + ":";
            string deviceName = string.Empty;

            switch (device)
            {
            case Drive.CDRom: deviceName = "\\Device\\CdRom0"; break;

            case Drive.DriveC: deviceName = "\\Device\\Harddisk0\\Partition2"; break;

            case Drive.DriveE: deviceName = "\\Device\\Harddisk0\\Partition1"; break;

            case Drive.DriveF: deviceName = "\\Device\\Harddisk0\\Partition6"; break;

            //case Device.DriveG: deviceName = "\\Device\\Harddisk0\\Partition7"; break;    // seems to be disabled in debug bios
            //case Device.DriveH: deviceName = "\\Device\\Harddisk0\\Partition8"; break;    // seems to be disabled in debug bios
            case Drive.DriveX: deviceName = "\\Device\\Harddisk0\\Partition3"; break;

            case Drive.DriveY: deviceName = "\\Device\\Harddisk0\\Partition4"; break;

            case Drive.DriveZ: deviceName = "\\Device\\Harddisk0\\Partition5"; break;
            }

            // send mounting info to xbox
            SetMemory(History.ScratchBuffer, (ushort)driveName.Length, (ushort)(driveName.Length + 1),
                      (uint)(History.ScratchBuffer + 16), (ushort)deviceName.Length, (ushort)(deviceName.Length + 1),
                      (uint)(History.ScratchBuffer + 16 + driveName.Length + 1), driveName, deviceName);

            // attempt to mount device
            uint error = CallAddressEx(Kernel.IoCreateSymbolicLink, null, true, History.ScratchBuffer, History.ScratchBuffer + 8);

            if (error != 0)
            {
                throw new ApiException("Failed to mount the device");
            }
        }
コード例 #5
0
ファイル: Xbox.FileSystem.cs プロジェクト: CodeAsm/open-sauce
        /// <summary>
        /// Unmounts the specified drive.
        /// </summary>
        /// <param name="drive">Drive letter.</param>
        public void UnMountDevice(DriveLabel drive)
        {
            string driveName = "\\??\\" + drive.ToString() + ":";

            // send unmounting info to xbox
            SetMemory(History.ScratchBuffer, (ushort)driveName.Length, (ushort)(driveName.Length + 1),
                (uint)(History.ScratchBuffer + 8), driveName);

            // attempt to unmount device
            uint error = CallAddressEx(Kernel.IoDeleteSymbolicLink, null, true, History.ScratchBuffer);
            if (error != 0) throw new ApiException("Failed to unmount the device");
        }
コード例 #6
0
ファイル: Xbox.FileSystem.cs プロジェクト: CodeAsm/open-sauce
        /// <summary>
        /// Mounts the specified device to the specified drive letter.
        /// </summary>
        /// <param name="device">Device name</param>
        /// <param name="drive">Drive letter</param>
        public void MountDevice(Drive device, DriveLabel drive)
        {
            string driveName = "\\??\\" + drive.ToString() + ":";
            string deviceName = string.Empty;
            switch (device)
            {
                case Drive.CDRom: deviceName = "\\Device\\CdRom0"; break;
                case Drive.DriveC: deviceName = "\\Device\\Harddisk0\\Partition2"; break;
                case Drive.DriveE: deviceName = "\\Device\\Harddisk0\\Partition1"; break;
                case Drive.DriveF: deviceName = "\\Device\\Harddisk0\\Partition6"; break;
                //case Device.DriveG: deviceName = "\\Device\\Harddisk0\\Partition7"; break;    // seems to be disabled in debug bios
                //case Device.DriveH: deviceName = "\\Device\\Harddisk0\\Partition8"; break;    // seems to be disabled in debug bios
                case Drive.DriveX: deviceName = "\\Device\\Harddisk0\\Partition3"; break;
                case Drive.DriveY: deviceName = "\\Device\\Harddisk0\\Partition4"; break;
                case Drive.DriveZ: deviceName = "\\Device\\Harddisk0\\Partition5"; break;
            }

            // send mounting info to xbox
            SetMemory(History.ScratchBuffer, (ushort)driveName.Length, (ushort)(driveName.Length + 1),
                (uint)(History.ScratchBuffer + 16), (ushort)deviceName.Length, (ushort)(deviceName.Length + 1),
                (uint)(History.ScratchBuffer + 16 + driveName.Length + 1), driveName, deviceName);

            // attempt to mount device
            uint error = CallAddressEx(Kernel.IoCreateSymbolicLink, null, true, History.ScratchBuffer, History.ScratchBuffer + 8);
            if (error != 0) throw new ApiException("Failed to mount the device");
        }