Добавлена поддержка чипсета balong v7r22 и роутера B525

pull/40/head
forth32 7 years ago
parent 08f415015c
commit 63a4ea20b9

@ -74,6 +74,12 @@ fclose(in);
//==================================================================================
res=pv7r22(buf, fsize);
if (res != 0) {
printf("\n* Найдена сигнатура типа V7R22 по смещению %08x",res);
goto endpatch;
}
res=pv7r1(buf, fsize);
if (res != 0) {
printf("\n* Найдена сигнатура типа V7R1 по смещению %08x",res);

@ -1,21 +1,38 @@
#include <stdint.h>
#include <string.h>
#include "patcher.h"
#include <stdlib.h>
//***********************************************************************
//* Поиск сигнатуры и наложение патча
//*
//* ptype=0 - nop-патч
//* ptype=1 - br-патч
//***********************************************************************
uint32_t patch(struct defpatch fp, uint8_t* buf, uint32_t fsize) {
uint32_t patch(struct defpatch fp, uint8_t* buf, uint32_t fsize, uint32_t ptype) {
// накладываемый патч - mov r0,#0
const char nop0[4]={0, 0, 0xa0, 0xe3};
uint32_t i;
uint8_t c;
for(i=8;i<(fsize-60);i+=4) {
if (memcmp(buf+i,fp.sig, fp.sigsize) == 0) {
// найдена сигнатура - накладываем патч и уходим
memcpy(buf+i+fp.sigsize+fp.poffset,nop0,4);
return i;
switch (ptype) {
case 0:
memcpy(buf+i+fp.sigsize+fp.poffset,nop0,4);
return i;
case 1:
c=*(buf+i+fp.sigsize+fp.poffset);
c|=0xe0;
*(buf+i+fp.sigsize+fp.poffset)=c;
return i;
default:
exit(11);
}
}
}
// сигнатрура не найдена
@ -26,6 +43,11 @@ return 0;
// Описатели патчей
//**********************************************
const char sigburn_v7r22[]={
0x12, 0x3B, 0xA0, 0xE3, 0x4A, 0x35, 0x4A, 0xE3, 0x00, 0x20, 0xA0, 0xE3,
0x78, 0x20, 0xC3, 0xE5, 0x79, 0x20, 0xC3, 0xE5, 0x7A, 0x20, 0xC3, 0xE5,
0x7B, 0x20, 0xC3, 0xE5, 0x00, 0x00, 0xA0, 0xE3};
const char sigburn_v7r11[]={
0x00, 0x00, 0x50, 0xE3, 0x70, 0x80, 0xBD, 0x08, 0x00, 0x30, 0xA0, 0xE3,
0x4E, 0x26, 0x04, 0xE3, 0xE0, 0x3F, 0x44, 0xE3, 0x55, 0x22, 0x44, 0xE3,
@ -45,6 +67,7 @@ const char sigburn_v7r1[]={
const char sigbad[]={0x04, 0x10, 0x8D, 0xE2, 0x04, 0x00, 0xA0, 0xE1};
struct defpatch patch_v7r22={sigburn_v7r22, sizeof(sigburn_v7r22), -37};
struct defpatch patch_v7r11={sigburn_v7r11, sizeof(sigburn_v7r11), 4};
struct defpatch patch_v7r2={sigburn_v7r2, sizeof(sigburn_v7r2), 16};
struct defpatch patch_v7r1={sigburn_v7r1, sizeof(sigburn_v7r1), 0};
@ -55,8 +78,9 @@ struct defpatch patch_erasebad={sigbad, sizeof(sigbad), 0};
//* Процедуры патча под разные чипсеты и задачи
//****************************************************
uint32_t pv7r2 (uint8_t* buf, uint32_t fsize) { return patch(patch_v7r2, buf, fsize); }
uint32_t pv7r11 (uint8_t* buf, uint32_t fsize) { return patch(patch_v7r11, buf, fsize); }
uint32_t pv7r1 (uint8_t* buf, uint32_t fsize) { return patch(patch_v7r1, buf, fsize); }
uint32_t perasebad (uint8_t* buf, uint32_t fsize) { return patch(patch_erasebad, buf, fsize); }
uint32_t pv7r2 (uint8_t* buf, uint32_t fsize) { return patch(patch_v7r2, buf, fsize,0); }
uint32_t pv7r11 (uint8_t* buf, uint32_t fsize) { return patch(patch_v7r11, buf, fsize,0); }
uint32_t pv7r1 (uint8_t* buf, uint32_t fsize) { return patch(patch_v7r1, buf, fsize,0); }
uint32_t pv7r22 (uint8_t* buf, uint32_t fsize) { return patch(patch_v7r22, buf, fsize,1); }
uint32_t perasebad (uint8_t* buf, uint32_t fsize) { return patch(patch_erasebad, buf, fsize,0); }

@ -11,12 +11,13 @@ struct defpatch {
//***********************************************************************
//* Поиск сигнатуры и наложение патча
//***********************************************************************
uint32_t patch(struct defpatch fp, uint8_t* buf, uint32_t fsize);
uint32_t patch(struct defpatch fp, uint8_t* buf, uint32_t fsize, uint32_t ptype);
//****************************************************
//* Процедуры патча под разные чипсеты и задачи
//****************************************************
uint32_t pv7r22 (uint8_t* buf, uint32_t fsize);
uint32_t pv7r2 (uint8_t* buf, uint32_t fsize);
uint32_t pv7r11 (uint8_t* buf, uint32_t fsize);
uint32_t pv7r1 (uint8_t* buf, uint32_t fsize);

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 MiB

Loading…
Cancel
Save