Click here to Skip to main content
11,414,234 members (69,998 online)
Click here to Skip to main content

Force Vista Ready Boost

, 21 Sep 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
Forces Vista ready boost on a specific removable drive

Introduction 

ReadyBoost is a technology built into Windows Vista that caches disk reads onto a flash memory device. It can work with USB memory keys, flash memory cards, such as SD and CompactFlash, and other types of flash devices. It caches all types of file reads, not just the working set, nor just DLLs or other persistent operating system data.

Note

ReadyBoost does not cache file writes—it's a write-through cache. That way, you never lose any precious data that's meant to be written to a hard drive. After all, a flash memory key can get yanked out of a system at any time. The cache itself is encrypted using AES-128 encryption, so no one can steal your flash memory key and casually browse through the cache file to see what you've been doing.

Background

According to Microsoft, the minimum requirements for a USB memory device to be ReadyBoost capable is 2.5MB/sec for 4K random access reads and 1.5MB/sec for 512K random writes—and that rate has to be achieved across the whole flash memory space. When you plug a USB memory device into the system, Vista actually does a performance check to see if the device meets the standard. Vista won't allow you to use a device and that's where this application was built. 

Overview

General questions regarding Microsoft ReadyBoost are answered by Matt Ayers from Microsoft can be found here.

You may also want to read about "Vista ReadyBoost or SnailBoost" here.

Using the Code

The code is mainly about finding and editing the Windows registry key of a certain removable drive and fake its read and write speed values:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.Win32;

namespace QForce_Ready_Boost
{
    public partial class Form1 : Form
    {        
        RegistryKey key;   
        public Form1()
        {
            InitializeComponent();
        }

        string[] arDrives;
        string strDrive;
        DriveInfo di;

        private void load_drivers()
        {
            try
            {
                combo_Drives.Items.Clear();
                arDrives = System.Environment.GetLogicalDrives();
                foreach (string strDriveName in arDrives)
                {
                    di = new DriveInfo(strDriveName);
                    if (di.DriveType == DriveType.Removable)
                        combo_Drives.Items.Add(di.VolumeLabel + 
			" (" + strDriveName.Replace("\\", "") + ")");
                }
                if (combo_Drives.Items.Count > 0 && combo_Drives.Text.Length == 0)
                    combo_Drives.Text = combo_Drives.Items[0].ToString();
            }
            catch (Exception)
            { }
        }

When you click the force button, the registry values for WriteSpeedKBs and ReadSpeedKBs are simply altered to ReadyBoost compatible values (10,000,000 in our case):

private void btn_Force_Click(object sender, EventArgs e)
{
    try
    {
	di = new DriveInfo(combo_Drives.Text.Substring
			(combo_Drives.Text.Length - 3, 2) + "\\");

	string keyLocation = @"Software\Microsoft\Windows NT\CurrentVersion\
	EMDMgmt\_??_USBSTOR#Disk&Ven_&Prod_USB_DISK_2.0&Rev_PMAP#077C0EA5004B&0#
	{53f56307-b6bf-11d0-94f2-00a0c91efb8b}" + strDrive + "_1078135262";

	key = Registry.LocalMachine.OpenSubKey(keyLocation, true);

	key.SetValue("ReadSpeedKBs", 10000000, RegistryValueKind.DWord);
	key.SetValue("WriteSpeedKBs", 10000000, RegistryValueKind.DWord);
	key.SetValue("PhysicalDeviceSizeMB",
		Math.Round(((double)di.TotalSize/1024)/1024) , 
		RegistryValueKind.DWord);
	key.SetValue("RecommendedCacheSizeMB", 
		Math.Round(((double)di.TotalFreeSpace / 1024) / 1024) / 2, 
		RegistryValueKind.DWord);
	key.SetValue("CacheSizeInMB", trackBar1.Value, RegistryValueKind.DWord);

	key.SetValue("HasSlowRegions", 00000000, RegistryValueKind.DWord);

	MessageBox.Show("Drive " + combo_Drives.Text + 
		"\nforced successfully!","Success",MessageBoxButtons.OK,
		MessageBoxIcon.Information);
    }
    catch (Exception ex)
    { 
	MessageBox.Show("Please select a valid drive", 
	"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 
    }

    btn_Force.Enabled = false;           
}
//By Muammar Yacoob

Points of Interest 

You may have noticed the strange looking name of the registry key including the removable drive name:

_??_USBSTOR#Disk&Ven_&Prod_USB_DISK_2.0&Rev_PMAP#077C0EA5004B&0#
{53f56307-b6bf-11d0-94f2-00a0c91efb8b}" <blink>+ strDrive +</blink>
"_1078135262";

Well, I just noticed that Vista is using it no matter what drive we used and used it as a constant in my code!  

Please tell me if it's different in your case, so we might come up with a new idea of detecting the changes.

History

  • 21st September, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Muammar©
Retired QSoft
Yemen Yemen
Biography?! I'm not dead yet!
www.QSoftOnline.com

Comments and Discussions

 
GeneralVista is using it no matter what drive we used.... Pin
axelriet, 21-Sep-08 15:05
memberaxelriet21-Sep-08 15:05 
AnswerRe: Vista is using it no matter what drive we used.... Pin
Muammar©, 21-Sep-08 22:37
memberMuammar©21-Sep-08 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150427.2 | Last Updated 21 Sep 2008
Article Copyright 2008 by Muammar©
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid