TP-Link Archer C7 v5 EU nvrammanager nm_checkSoftVer() dissasembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
root@ArcherC7v5:/# nvrammanager -r /proc/self/fd/1 -p soft-version | |
soft_ver:1.1.0 Build 20201120 rel.50406 | |
fw_id:C339BA6D3F263C8AB6919A76DF430336 | |
root@ArcherC7v5:/# md5sum /usr/bin/nvrammanager | |
404b8d952f7cdc97199a0afc2e081a9a /usr/bin/nvrammanager | |
*/ | |
int nm_checkSoftVer(int param_1,int param_2) | |
{ | |
int r; | |
uint32_t fw_version_hl; | |
int ret; | |
int upd_fw_minor; | |
uint upd_fw_major; | |
uint cur_fw_minor; | |
uint cur_fw_major; | |
uint soft_version_nvram [2]; | |
char buf [51]; | |
memset(soft_version_nvram,0,0x32); | |
ret = 0; | |
cur_fw_major = 0; | |
cur_fw_minor = 0; | |
upd_fw_major = 0; | |
upd_fw_minor = 0; | |
if ((0xb < param_2 + -8) && (r = strncmp((char *)(param_1 + 8),"soft_ver:",9), r == 0)) { | |
sscanf((char *)(param_1 + 0x11),"%d.%d.%*s",&upd_fw_major,&upd_fw_minor); | |
r = nm_api_readPtnFromNvram("soft-version",soft_version_nvram,0x32); | |
if (r < 1) { | |
printf("[NM_Error](%s) %05d: failed to read partition from flash!\r\n\r\n","nm_checkSoftVer", | |
0x333); | |
} | |
else { | |
r = strncmp((char *)soft_version_nvram,"soft_ver:",9); | |
if (r == 0) { | |
sscanf(buf,"%d.%d.%*s",&cur_fw_major,&cur_fw_minor); | |
} | |
else { | |
fw_version_hl = ntohl(soft_version_nvram[0]); | |
soft_version_nvram[0] = fw_version_hl & 0xffffff; | |
cur_fw_major = (fw_version_hl << 8) >> 0x18; | |
cur_fw_minor = (soft_version_nvram[0] << 0x10) >> 0x18; | |
} | |
printf(" (curFw_ver, newFw_ver) == (%d.%d, %d.%d) ",cur_fw_major,cur_fw_minor,upd_fw_major, | |
upd_fw_minor); | |
if (((int)upd_fw_major < (int)cur_fw_major) || | |
((ret = 1, cur_fw_major == upd_fw_major && (upd_fw_minor < (int)cur_fw_minor)))) { | |
ret = 0; | |
printf("[NM_Error](%s) %05d: Firmwave not supports, check failed.\r\n\r\n","nm_checkSoftVer" | |
,0x350); | |
} | |
} | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment