Home > .NET, General Tech > Sharp Launcher for DreamCheeky USB Rocket Launcher working on Windows 7 x64

Sharp Launcher for DreamCheeky USB Rocket Launcher working on Windows 7 x64

I have been sitting on this solution for a while and have finally got around to posting about it and sharing the solution with others who might find it handy.

For those of you not really interested in my explanations of the changes I made and just want the software download links are at the bottom of the post.

DreamCheeky rocket launcher

I currently have one of these DreamCheeky USB Rocket Launchers setup on my desk at work. At the time I purchased this device, the best .NET open source project for controlling the DreamCheeky rocket launcher was a project called Sharp Launcher. http://code.google.com/p/sharplauncher/

However, once my work machine was upgraded to Windows 7 64 bit, I had not been able to enjoy the device as the latest version of Sharp Launcher (1.3), does not work under a 64 bit operating system.

After some Googling and finding no solution, only a number of people asking the same questions, I decided to jump in and fix it.

Now I want to point out that I have tried to get in contact with the original developer to supply him with the changes and have got no response. I have also looked at contributing to the code.google project but it is not actually setup as a source repository, just has a zip of the code for download.

My alternative is to post both the binaries and the source here and hopefully someone stumbles across it who knows how to contact this guy.

I take no credit for the original code just the few minor tweaks I have made to make it work in a 64 bit environment. I have also not made any attempt to clean up the code, remove any warnings, test it on more than 1 or 2 systems, or anything else as this was purely an effort to get this existing software to work under 64 bit.

After downloading the source code for version 1.3 from here and converting the solution to VS 2010, I found the straight away the code did not compile.
Error List 1

Error number 3 is the issue so I change the code from

public bool UnregisterHandle()
    if (this.handle != null)
        return Win32Usb.UnregisterForUsbEvents(this.handle);


public bool UnregisterHandle()
    return this.handle != null && Win32Usb.UnregisterForUsbEvents(this.handle);

This allows us to compile and run the software, however as expected my device is not found.
No USB Launchers Found

By debugging in I found that the call to SetupDiEnumDeviceInterfaces on line 266 of LibHid/HIDDevice.cs was returning false. Now this next bit took me a hell of a long time to work out. Looking back it should have been pretty obvious but I began my search in completely the wrong direction. Long story short, I worked out this was due the type of the Reserved property of the DeviceInterfaceData struct in LibHid/Win32Usb.cs.
This needs to be changed from int

public int Reserved;

to ulong

public ulong Reserved;

This is due to the fact that the returned SP_DEVICE_INTERFACE_DATA Structure returns the reserved property as a ULONG_PTR.
This of course works in a 32 bit environment but the 64 bit data does not fit into a standard 32 bit int.

Once this change was made I continued to debug the process and came across this gem at line 234 in LibHid/HIDDevice.cs.

oDetail.Size = 5;	// hardcoded to 5! Sorry, but this works and trying more future proof versions by setting the size to 
                           the struct sizeof failed miserably. If you manage to sort it, mail me! Thx

To rectify this we need to declare a dll import and define the IsWow64Process

[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);

And then change that offending line to

 bool is64BitProcess;
 IsWow64Process(Process.GetCurrentProcess().Handle, out is64BitProcess);
 oDetail.Size = (IntPtr.Size == 8 || (IntPtr.Size == 4 && is64BitProcess)) ? 8 : 5;

I know at least 1 reader of this will say the IsWow64Process method wont exist in earlier version of kernel32 such as under Windows 2000 or XP < SP1 but for what I'm trying to achieve here I am assuming if you are on those older versions you will be using the already released version of Sharp launcher and wont need this Windows 7 x64 version. đŸ˜€

So now we can compile and run the application and this time we will see the device has been detected correctly and we now have control of our cube defense system.
USB Launcher Found

I hope this has provided some insight to a few people and also provided an opportunity to enjoy your USB rocket launcher again.

Now to hook this up to the build failure notifications… Muhahaha…

UPDATE: I have uploaded the source to GitHub

Updated source can be found here: SharpLauncher on GitHub

Binaries can be found here: SharpLauncher Binaries

  1. Micke Joh
    October 10, 2014 at 11:27 pm

    where can I find an exe-file for this? Cheers from Sweden, /Micke

  2. October 16, 2014 at 1:13 pm
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: