Truxton usb get when
Jump to navigation
Jump to search
This retrieves the date and time of when this USB device was seen.
This corresponds to the [When] column of the [USBDevice] table.
Syntax
uint64_t truxton_usb_get_when( uint64_t usb_handle );
Parameters
usb_handle
This handle comes from calling truxton_usb_create().
Return value
When the USB device was seen in FILETIME ticks. If no timestamp is associated with the USB device, zero will be returned.
Sample
void dump_usb(uint64_t usb_handle)
{
uint64_t integer_value = 0;
char temp_string[ 1024 ];
truxton_usb_get_id( usb_handle, temp_string, sizeof(temp_string) );
printf( "USB ID is %s\n", temp_string );
truxton_usb_get_media_id( usb_handle, temp_string, sizeof(temp_string) );
printf( "Media ID is %s\n", temp_string );
truxton_usb_get_file_id( usb_handle, temp_string, sizeof(temp_string) );
printf( "File ID is %s\n", temp_string );
truxton_usb_get_device_id( usb_handle, temp_string, sizeof(temp_string) );
printf( "Device ID is \"%s\"\n", temp_string );
integer_value = truxton_usb_get_device_type( usb_handle );
printf( "Device type is %" PRIu64 "\n", integer_value );
integer_value = truxton_usb_get_file_offset( usb_handle );
printf( "File offset is %" PRIu64 "\n", integer_value );
integer_value = truxton_usb_get_vendor_id( usb_handle );
printf( "VID is %" PRIu64 "\n", integer_value );
integer_value = truxton_usb_get_product_id( usb_handle );
printf( "PID is %" PRIu64 "\n", integer_value );
integer_value = truxton_usb_get_revision( usb_handle );
printf( "Revision is %" PRIu64 "\n", integer_value );
integer_value = truxton_usb_get_when( usb_handle );
printf( "When is %" PRIu64 "\n", integer_value );
}
The PRIu64 in the sample code above is a standard way of formatting a 64-bit unsigned integer in C.
Over the years, different compilers on different operating systems used different format specifiers for things, these PRI macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.