PORTS Forum

Ports and Interfaces => USB => Topic started by: clement2011 on May 29, 2012, 10:39:54 pm

Title: how to load usb sniffer driver
Post by: clement2011 on May 29, 2012, 10:39:54 pm
Hi:
I get the usbsniffer and see driver UsbSnoop.sys, the problem is if I hope to
write a gui which written by c sharp, how to load the driver? If there any
good example for that, thanks a lot
Title: Re: how to load usb sniffer driver
Post by: Jan Axelson on May 30, 2012, 12:35:20 pm
The source code shows how to do everything available from the GUI. For example, search around on BIN_USBSNOOPY.

Jan
Title: Re: how to load usb sniffer driver
Post by: clement2011 on May 30, 2012, 09:16:50 pm
I see a function UnpackAndInstall, after looking the function, it seems using FindResource to get the resource, and this invoke me some other question.I saw another third-party usbsniffer recently, and its ui is written by c sharp, but when I compile its source code, it
can not load its sysfile, however the exe file the web it provided can work well.
the error come from the following codes:
Code: [Select]
private static bool ExtractDriverFiles(out string mydir)
        {
            string tempdir = Path.GetTempPath();
            // This needs to be the same dir for uninstall (dpinst not cool here)
            mydir = Path.Combine(tempdir, "xxx_temp");
            try
            {
                Directory.CreateDirectory(mydir);
                WriteDrverFile(sysFile, mydir);
                WriteDrverFile(infFile, mydir);
                WriteDrverFile(coinstFile, mydir);
                WriteDrverFile(dpinstFile, mydir);
            }
            catch
            {
                return false;
            }
            return true;
        }
        private static void WriteDrverFile(string resname, string dir)
        {
            Assembly ass = Assembly.GetExecutingAssembly();
            ResourceManager rm = new ResourceManager("xxx.driver", ass);

            ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);
            byte[] buf = (byte[])set.GetObject(resname);

            Stream w = File.OpenWrite(Path.Combine(dir, resname));
            w.Write(buf, 0, buf.Length);
            w.Flush();
            w.Close();
        }


and the error comes from the following two caluse
Code: [Select]
            ResourceManager rm = new ResourceManager("xxx.driver", ass);

            ResourceSet set = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);

I still can not figure out the problem, and how to make sure the problem it is from and how to handle it,
thanks.
Title: Re: how to load usb sniffer driver
Post by: Jan Axelson on May 30, 2012, 10:57:18 pm
What is the error message?

Jan
Title: Re: how to load usb sniffer driver
Post by: clement2011 on May 31, 2012, 01:23:38 am
The error meesage show can not find out the resource, need to embedded xxx.driver.resources
Thanks
Title: Re: how to load usb sniffer driver
Post by: Jan Axelson on May 31, 2012, 08:40:48 am
If it can't find the resource, check your path settings or specify the complete path.

Jan
Title: Re: how to load usb sniffer driver
Post by: clement2011 on May 31, 2012, 08:42:40 pm
I don't know exactly how the usb driver be installed and load driver, and how to make sure its resource
location. I try to trace SnoopyPro0.22, but in visual studio 2010, after transformation, it can not
be compiled directly. And I still can not make sure another third-party freeware usb sniffer driver
can work well, even its exe file can work.
If there any good method to make sure the problem, thanks a lot.

Title: Re: how to load usb sniffer driver
Post by: Jan Axelson on May 31, 2012, 09:45:24 pm
I don't know of any updated version. You may need to search on the error messages you're seeing to find out how get it working

For help with Visual Studio and programming in general, see:

http://social.msdn.microsoft.com/Forums/en-US/category/vsvnext,visualstudio,vsarch,vsdbg,vstest,vstfs,vsdata,vsappdev,visualbasic,visualcsharp,visualc,visualfsharp,windowsapps

Jan

Title: Re: how to load usb sniffer driver
Post by: clement2011 on June 14, 2012, 03:13:02 am
Thanks