Skip to content

Commit

Permalink
Add help option -IgSerNum to set windows registry
Browse files Browse the repository at this point in the history
Set windows registry ignore usb serial number.

Signed-off-by: Frank Li <frank.li@nxp.com>
  • Loading branch information
nxpfrankli committed May 25, 2021
1 parent 22c5181 commit 195014f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions uuu/uuu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void print_help(bool detail = false)
" you can use \"uuu uuu.inputlog\" next time to run all commands\n\n"
"uuu -udev linux: show udev rule to avoid sudo each time \n"
"uuu -lsusb List connected know devices\n"
"uuu -IgSerNum Set windows registry to ignore USB serial number for known uuu devices"
"uuu -h -H show help, -H means detail helps\n\n";
printf("%s", help);
printf("uuu [-d -m -v] -b[run] ");
Expand Down Expand Up @@ -782,6 +783,35 @@ void print_lsusb()
uuu_for_each_devices(print_usb_device, NULL);
}

int ignore_serial_number(const char *pro, const char *chip, const char */*comp*/, uint16_t vid, uint16_t pid, uint16_t /*bcdlow*/, uint16_t /*bcdhigh*/, void */*p*/)
{
printf("\t %s\t %s\t 0x%04X\t0x%04X\n", chip, pro, vid, pid);

char sub[128];
snprintf(sub, 128, "IgnoreHWSerNum%04x%04x", vid, pid);
const BYTE value = 1;

LSTATUS ret = RegSetKeyValueA(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\UsbFlags",
sub, REG_BINARY, &value, 1);
if(ret == ERROR_SUCCESS)
return 0;

printf("Set key failure, try run as administrator permission\n");
return -1;
}

int set_ignore_serial_number()
{
#ifndef WIN32
printf("Only windows system need set ignore serial number registry");
return -1;
#else
printf("Set window registry to ignore usb hardware serial number for known uuu device:\n");
return uuu_for_each_cfg(ignore_serial_number, NULL);
#endif
}

int main(int argc, char **argv)
{
if (auto_complete(argc, argv) == 0)
Expand Down Expand Up @@ -903,6 +933,10 @@ int main(int argc, char **argv)
print_lsusb();
return 0;
}
else if (s == "-IgSerNum")
{
return set_ignore_serial_number();
}
else if (s == "-e")
{
#ifndef WIN32
Expand Down

0 comments on commit 195014f

Please sign in to comment.