コード例 #1
0
/*
 *  Prints the USB device information
 *
 *  device      - USB device pointer
 *
 */
void printDeviceInfo(IOUSBDeviceInterface300** device)
{
    unsigned short vendorId = 0;
    unsigned short productId = 0;
    unsigned short releaseVersion = 0;
    
    char manufacturer[255];
    char product[255];
    char serial[255];
    
    (*device)->GetDeviceVendor(device, &vendorId);
    (*device)->GetDeviceProduct(device, &productId);
    (*device)->GetDeviceReleaseNumber(device, &releaseVersion);
    
    unsigned char stringIndex = 0;
    
    if ((*device)->USBGetManufacturerStringIndex(device, &stringIndex) == kIOReturnSuccess)
        retrieveString(device, stringIndex, manufacturer, sizeof(manufacturer));
    
    if ((*device)->USBGetProductStringIndex(device, &stringIndex) == kIOReturnSuccess)
        retrieveString(device, stringIndex, product, sizeof(product));
    
    if ((*device)->USBGetSerialNumberStringIndex(device, &stringIndex) == kIOReturnSuccess)
        retrieveString(device, stringIndex, serial, sizeof(serial));
    
    printf("[i] USB [%04x:%04x %s v%d] \"%s\" by \"%s\"\n",
           vendorId,
           productId,
           serial,
           releaseVersion,
           product,
           manufacturer);
}
コード例 #2
0
std::string Ingredient::getName() const {
	return retrieveString(NAME);
}