Created
September 17, 2025 06:57
-
-
Save lifehackerhansol/3342d4b4b722cb5c48bf503fac83a6dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| struct fwimage_trailer { | |
| uint32_t magic; | |
| uint32_t crc32; | |
| uint8_t type; | |
| uint8_t __pad[3]; | |
| uint32_t size; | |
| }; | |
| #define FWIMAGE_MAGIC 0x46577830 /* FWx0 */ | |
| static int check_image(u_char * load_addr,u_char nand_offset,unsigned long size) | |
| { | |
| struct fwimage_trailer tr; | |
| unsigned long tr_offset = 0; | |
| u_char outbuf[16]={0}; | |
| unsigned long ulImage_len = 0; | |
| if(load_addr == NULL ) | |
| { | |
| return 0; | |
| } | |
| tr_offset = size-sizeof(struct fwimage_trailer); | |
| memcpy(&tr , &load_addr[tr_offset] ,sizeof(struct fwimage_trailer)); | |
| if( htonl(tr.magic) != FWIMAGE_MAGIC ) | |
| { | |
| printf("\n tr magic is error. upgrade fail! \n" ); | |
| return 0; | |
| } | |
| ulImage_len = size - htonl(tr.size); | |
| printf("\n ulImage_len is : [%X]\n" , ulImage_len ); | |
| md5(load_addr, ulImage_len , &outbuf[0]); | |
| printf("\nDIR-X3260 md5 : [%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x] \n" , | |
| outbuf[0] , outbuf[1] , outbuf[2] , outbuf[3] , outbuf[4] , outbuf[5] , outbuf[6] , outbuf[7] , | |
| outbuf[8] , outbuf[9] , outbuf[10] , outbuf[11] , outbuf[12] , outbuf[13] , outbuf[14] , outbuf[15] ); | |
| if(size > 0x1440000) | |
| { | |
| if(!strncmp(&load_addr[0x1440022] , "DIR-X3260", strlen("DIR-X3260"))) | |
| { | |
| printf("DEVICE Name is : %c%c%c%c%c%c%c%c%c \n" , load_addr[0x1440022], load_addr[0x1440023], load_addr[0x1440024] | |
| , load_addr[0x1440025], load_addr[0x1440026], load_addr[0x1440027], load_addr[0x1440028], load_addr[0x1440029], load_addr[0x144002A]); | |
| return 1; | |
| } | |
| }else if((size > 0x1000000) && (!strncmp(&load_addr[size-283] , "DIR-X3260" , strlen("DIR-X3260")))) | |
| { | |
| printf("DEVICE name is : %c%c%c%c%c%c%c%c%c \n" , load_addr[size-283], load_addr[size-282], load_addr[size-281], load_addr[size-280] | |
| , load_addr[size-279], load_addr[size-278], load_addr[size-277], load_addr[size-276]); | |
| return 1; | |
| } | |
| printf("\n Unknown software. upgrade fail! \n" ); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment