diff --git a/X260.bbb b/X260.bbb new file mode 100644 index 0000000..4459e3c Binary files /dev/null and b/X260.bbb differ diff --git a/thinkpad_unlock_bios.c b/thinkpad_unlock_bios.c index fc61f00..8866658 100644 --- a/thinkpad_unlock_bios.c +++ b/thinkpad_unlock_bios.c @@ -3,12 +3,26 @@ /* run this program using the console pauser or add your own getch, system("pause") or input loop */ -const char bios_head[32]= +const char bios_head_X250[32]= { 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x5A,0xA5,0xF0,0x0F,0x03,0x00,0x04,0x03,0x06,0x02,0x10,0x15,0x20,0x01,0x21,0x00 }; +const char bios_head_X260[32]= +{ +0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x5A,0xA5,0xF0,0x0F,0x03,0x00,0x04,0x00,0x08,0x02,0x10,0x42,0x30,0x03,0x31,0x00 +}; + +/* +bios type: + + 0: need change + 1: X250 + 2: X260 + + +*/ +char bios_type=0; char buff[0xffffff]; -char id[32]; char outputdir[256]; char inputdir[256]; char chack_str(const char *a,char *b,int len) @@ -24,8 +38,135 @@ char chack_str(const char *a,char *b,int len) return 0; } -void tryunlock(char *dir) + +void change_bios_type() { + FILE *unlock_bios = NULL; + + + do + { + printf("选择BIOS机型:(输入编号)\n 1-> X250 \n 2-> X260 \n"); + scanf("%d",&bios_type); + + if(bios_type==1) + { + unlock_bios=fopen("./X250.bbb","rb"); + } + if(bios_type==2) + { + unlock_bios=fopen("./X260.bbb","rb"); + } + if(unlock_bios==NULL) + { + printf("ERROR_NOTFUND_THE_S_FILE\n"); + bios_type=0; + } + }while(bios_type==0); + + fread(buff,0xffffff,1,unlock_bios); + fclose(unlock_bios); + +/* + + + +*/ +} + + +char tryunlock(char *dir) +{ + int a=0; + if(dir==NULL) + { + printf(" 直接输入BIOS路径:\n 或输入命令:\n change 改变BIOS类型。\n exit 退出程序 \n"); + for(a=0;a<256;a++) + { + inputdir[a]=0; + } + scanf("%s",inputdir); + if(chack_str("change",inputdir,6)==0) + { + change_bios_type(); + return 1; + } + if(chack_str("exit",inputdir,4)==0) + { + return 0; + } + }else + { + a=0; + while(dir[a]!='\0') + { + inputdir[a]=dir[a]; + a++; + } + } + + if(bios_type==0) + { + change_bios_type(); + + } + + printf("Input flie %s\n",inputdir); + + FILE *bios=NULL; + FILE *output_bios=NULL; + bios=fopen(inputdir,"rb"); + char id[32]; + + if(bios==NULL) + { + printf("ERROR. can't Open file ..\n"); + }else + { + fread(id,32,1,bios); + if(chack_str(buff,id,32)) + { + printf("ERROR. Not Bios File\n"); + }else + { + //printf("try it..\n"); + if(fseek(bios,0xf00,SEEK_SET)) + { + printf("ERROR. -0\n"); + }else + { + fread(id,32,1,bios); + for(a=0;a<32;a++) + { + buff[0xf00+a]=id[a]; + } + for(a=0;a<256;a++) + { + outputdir[a]=0; + } + printf("id: %s \n",id); + sprintf(outputdir,"%s%s",inputdir,"_unlock.bin"); + printf("Output flie %s",outputdir); + output_bios=fopen(outputdir,"wb"); + if(output_bios==NULL) + { + printf("ERROR. can't Output file ..\n"); + }else + { + fwrite(buff,0xffffff,1,output_bios); + fclose(output_bios); + } + + printf("\n\n"); + } + } + + } + + fclose(bios); + + return 1; + /* int a; FILE *bios=NULL; FILE *output_bios=NULL; @@ -76,6 +217,7 @@ void tryunlock(char *dir) } fclose(bios); + */ } int main(int argc, char *argv[]) @@ -83,7 +225,7 @@ int main(int argc, char *argv[]) printf("ThinkPad Bios unlock..v0.1\n\n\n"); if(argc==1) { - printf("联想ThinkPad Bios超级密码解锁程序(目前仅支持X250)\n\n使用方法:\n"); + printf("联想ThinkPad Bios超级密码解锁程序。支持X250,X260(测试)\n\n使用方法:\n"); printf("1 使用编程器将原机Bios读出\n"); printf("2 将读出的内容以二进制格式bin保存\n"); printf("3 将bin文件拖进本程序,程序会自动生成解锁Bios,(支持批量拖入)\n"); @@ -92,42 +234,21 @@ int main(int argc, char *argv[]) printf("编写日期 2021-12-12 00:46 联系 吴文峰 邮箱 kevin@lmve.net \n\n"); printf("项目地址 https://git.lmve.net/kevin/thinkpad_unlock_bios \n博客地址 https://wnfed.com \n\n!!!请勿商用!!!\n\n"); } - - int a; - FILE *unlock_bios = NULL; - unlock_bios=fopen("./X250.bbb","rb"); - if(unlock_bios==NULL) - { - printf("ERROR_NOTFUND_THE_BIOS_FILE\n"); - return -1; - } - fread(buff,0xffffff,1,unlock_bios); - + while(argc>1) { argc--; - printf("Input flie %s\n",argv[argc]); tryunlock(argv[argc]); } printf("\n"); - printf("\n"); - while(1) + char while_flag=0; + do { - printf("请输入Bios文件路径,可通过拖拽文件到窗口快速输入,输入exit退出。\ndir:"); - for(a=0;a<256;a++) - { - inputdir[a]=0; - } - scanf("%s",inputdir); - if(chack_str("exit",inputdir,4)==0) - { - return 0; - } - tryunlock(inputdir); - } + while_flag=tryunlock(NULL); + }while(while_flag); //printf("have %d file\n",argc-1); //printf(argv[1]); diff --git a/thinkpad_unlock_bios.exe b/thinkpad_unlock_bios.exe index 85893db..142cb4e 100644 Binary files a/thinkpad_unlock_bios.exe and b/thinkpad_unlock_bios.exe differ