Qt 获取usb设备信息 hacking

/**************************************************************************
 *                       Qt 获取usb设备信息 hacking
 * 声明:
 *     本文主要是为了查看之前朋友留下的Qt获取usb设备信息软件运作机制。
 *
 *                                       2015-12-31 深圳 南山平山村 曾剑锋
 *************************************************************************/

一、usbfs 文件系统
    需要在Linux内核中打开usbfs选项:
    ───────────────────────────────────────────────────────────────────────────
    ┌────────────────────────────── USB support ──────────────────────────────┐
    │  Arrow keys navigate the menu.  <Enter> selects submenus --->.          │
    │  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, │
    │  <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help, </> │
    │  for Search.  Legend: [*] built-in  [ ] excluded  <M> module  < >       │
    │ ┌─────────────────────────────────────────────────────────────────────┐ │
    │ │    --- USB support                                                  │ │
    │ │    <*>   Support for Host-side USB                                  │ │
    │ │    [*]     USB verbose debug messages                               │ │
    │ │    [*]     USB announce new devices                                 │ │
    │ │            *** Miscellaneous USB options ***                        │ │
    │ │    [*]     USB device filesystem (DEPRECATED)    <----------- these │ │
    │ │    [*]     USB device class-devices (DEPRECATED)                    │ │
    │ │    [ ]     Dynamic USB minor allocation                             │ │
    │ │    [*]     USB runtime power management (autosuspend) and wakeup    │ │
    │ │    [*]       OTG support                                            │ │
    │ └────v(+)─────────────────────────────────────────────────────────────┘ │
    ├─────────────────────────────────────────────────────────────────────────┤
    │                    <Select>    < Exit >    < Help >                     │
    └─────────────────────────────────────────────────────────────────────────┘

二、cat mainwindow.cpp
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
        delete ui;
    }

    void MainWindow::on_pushButton_clicked()
    {
        if(myprocess)
            delete myprocess;

        myprocess = new QProcess(this);
        connect(myprocess, SIGNAL(readyReadStandardOutput()),this, SLOT(result()));
        connect(myprocess, SIGNAL(readyReadStandardError()),this, SLOT(result()));

        /**
         * If you say Y here (and to "/proc file system support" in the "File
         * systems" section, above), you will get a file /proc/bus/usb/devices
         * which lists the devices currently connected to your USB bus or
         * busses, and for every connected device a file named
         * "/proc/bus/usb/xxx/yyy", where xxx is the bus number and yyy the
         * device number; the latter files can be used by user space programs
         * to talk directly to the device. These files are "virtual", meaning
         * they are generated on the fly and not stored on the hard drive.
         *
         * You may need to mount the usbfs file system to see the files, use
         * mount -t usbfs none /proc/bus/usb
         *
         * For the format of the various /proc/bus/usb/ files, please read
         * <file:Documentation/usb/proc_usb_info.txt>.
         */
        myprocess->start("cat /proc/bus/usb/devices");
        ui->result->clear();
    }
    void MainWindow::result()
    {
        QString abc = myprocess->readAllStandardOutput();
        ui->result->append(abc.trimmed());
        QString efg = myprocess->readAllStandardError();
        if(efg.length()>1)ui->result->append(efg.trimmed());
    }

 

时间: 2024-09-20 16:40:20

Qt 获取usb设备信息 hacking的相关文章

guid-windows GUID SetupDiGerClassDevs(...)获取USB设备信息失败

问题描述 windows GUID SetupDiGerClassDevs(...)获取USB设备信息失败 下面这段代码是为了获取本机USB设备驱动handle的,可是逐句运行的时候, SetupDiGerClassDevs返回值老是 INVALID_HANDLE_VALUE. #pragma comment(lib,"setupapi") //ERROR linkerror 1120 #include<Windows.h> #include<SetupAPI.h&g

usb-使用WMI获取 USB设备接口描述

问题描述 使用WMI获取 USB设备接口描述 我已经通过这篇文章C#:基于WMI查询USB设备 了解到使用通 SELECT * FROM Win32_PnPEntity WHERE DeviceID=" + Dependent 可以获取usb设备的deviceDescription 要查询usb的interfaceDescription 该用什么查询语句呢

ubuntu-linux系统利用libudev获取USB设备的VID和PID?请各位大侠帮一忙,谢谢!

问题描述 linux系统利用libudev获取USB设备的VID和PID?请各位大侠帮一忙,谢谢! 我在Ubuntu14.04终端下lsusb可以看到识别到的USB设备,但是Unable to find parent usb device.我的设备会虚拟出串口,如ttyUSB0,ttyUSB1,ttyUSB2,我想知道如何获取该设备的VID和PID,通过网上找的代码,不知道如何修改以下两个函数的相关参数? udev_enumerate_add_match_subsystem(enumerate,

UWP 应用获取各类系统、用户信息 (2) - 商店授权信息、零售演示模式信息、广告 ID、EAS 设备信息、硬件识别信息、移动网络信息

原文:UWP 应用获取各类系统.用户信息 (2) - 商店授权信息.零售演示模式信息.广告 ID.EAS 设备信息.硬件识别信息.移动网络信息 应用开发中,开发者时常需要获取一些系统.用户信息用于数据统计遥测.问题反馈.用户识别等功能.本文旨在介绍在 Windows UWP 应用中获取一些常用系统.用户信息的方法.示例项目代码可参见 Github: https://github.com/validvoid/UWP-SystemInfoCollector 由于涉及内容较多,故本文会分为多篇展开.本

GPGPU OpenCL 获取设备信息

在使用OpenCL编程中,需要对GPU设备的底层理解,这样才能更好的进行代码优化. 比如计算单元CU数量,每个CU的执行单元PE数量,每个CU中的共享内存大小等等.只有了解了这些才能更好的使用共享内存,设计核函数的运行参数等. 本文:http://www.cnblogs.com/xudong-bupt/p/3586050.html  1.clGetDeviceInfo OpenCL使用clGetDeviceInfo函数获取设备具体,函数原型如下: cl_int clGetDeviceInfo (

C# 系统应用之通过注册表获取USB使用记录(一)

该文章是"个人电脑历史记录清除软件"项目的系统应用系列文章.前面已经讲述了如何清除IE浏览器的历史记录.获取Windows最近访问文件记录.清除回收站等功能.现在我需要完成的是删除USB设备上的U盘.手机.移动硬盘等记录,真心觉得这方面资料特别少.这篇文章首先主要讲述了通过注册表获取USB使用记录,希望对大家有所帮助. 一.注册表基本知识 注册表(registry)是Windows系统中一个重要的数据库,它用于存储有关应用程序.用户和系统信息.注册表的结构就像一颗树.树的顶级节点(hi

vid pid-windows列举usb设备VID PID

问题描述 windows列举usb设备VID PID C++获取windows usb 设备信息VID和PID 解决方案 USB设备的VID与PIDUSB设备的VID和PIDUSB设备的VID和PID 解决方案二: http://www.codeproject.com/KB/system/HwDetect.aspxhttp://www.cnblogs.com/SunYu/archive/2010/04/29/1723977.html 解决方案三: 不知道你是用windows的什么设备,wince

Android中查看USB连接的外接设备信息的代码实例_Android

1,USB存储设备(如:U盘,移动硬盘):  //USB存储设备 插拔监听与 SD卡插拔监听一致. 复制代码 代码如下:  private USBBroadCastReceiver mBroadcastReceiver;      IntentFilter iFilter = new IntentFilter();       iFilter.addAction(Intent.ACTION_MEDIA_EJECT);       iFilter.addAction(Intent.ACTION_M

Android中查看USB连接的外接设备信息的代码实例

1,USB存储设备(如:U盘,移动硬盘): //USB存储设备 插拔监听与 SD卡插拔监听一致.复制代码 代码如下: private USBBroadCastReceiver mBroadcastReceiver; IntentFilter iFilter = new IntentFilter();       iFilter.addAction(Intent.ACTION_MEDIA_EJECT);       iFilter.addAction(Intent.ACTION_MEDIA_MOU