diff --git a/balong-usbdload.c b/balong-usbdload.c index 5179536..539084c 100644 --- a/balong-usbdload.c +++ b/balong-usbdload.c @@ -2,15 +2,14 @@ // // #include -#include -#include #include -#include -#include -#include #ifndef WIN32 //%%%% +#include +#include +#include +#include #include #include #include @@ -322,7 +321,8 @@ printf("\n Утилита предназначена для аварийной U #ifndef WIN32 "-p - последовательный порт для общения с загрузчиком (по умолчанию /dev/ttyUSB0)\n" #else -"-p - последовательный порт для общения с загрузчиком\n" +"-p # - номер последовательного порта для общения с загрузчиком (например, -p8)\n" +" если ключ -p не указан, производится автоопределение порта\n" #endif "-f - грузить usbloader только до fastboot (без запуска линукса)\n\ -b - аналогично -f, дополнительно отключить проверку дефектных блоков при стирании\n\ @@ -375,7 +375,7 @@ printf("\n Утилита предназначена для аварийной U } } -printf("\n Аварийный USB-загрузчик Balong-чипсета, версия 2.03, (c) forth32, 2015"); +printf("\n Аварийный USB-загрузчик Balong-чипсета, версия 2.20, (c) forth32, 2015"); #ifdef WIN32 printf("\n Порт для Windows 32bit (c) rust3028, 2016"); #endif @@ -491,17 +491,24 @@ for(bl=0;bl<2;bl++) { } // Удаление процедуры flash_eraseall if (!cflag) { - res=pv7r2(blk[bl].pbuf, blk[bl].size) + pv7r11(blk[bl].pbuf, blk[bl].size) \ - + pv7r1(blk[bl].pbuf, blk[bl].size) + pv7r22(blk[bl].pbuf, blk[bl].size) \ - + pv7r22_2(blk[bl].pbuf, blk[bl].size) + pv7r22_3(blk[bl].pbuf, blk[bl].size); - if (res != 0) printf("\n\n * Удалена процедура flash_eraseal по смещению %08x",res); - else { - printf("\n Процедура eraseall не найдена в загрузчике - используйте ключ -с для загрузки без патча!\n"); - return; - } - } - - + res = pv7r1(blk[bl].pbuf, blk[bl].size); + if (res == 0) + res = pv7r2(blk[bl].pbuf, blk[bl].size); + if (res == 0) + res = pv7r11(blk[bl].pbuf, blk[bl].size); + if (res == 0) + res = pv7r22(blk[bl].pbuf, blk[bl].size); + if (res == 0) + res = pv7r22_2(blk[bl].pbuf, blk[bl].size); + if (res == 0) + res = pv7r22_3(blk[bl].pbuf, blk[bl].size); + if (res != 0) printf("\n\n * Удалена процедура flash_eraseall по смещению %08x", blk[bl].offset + res); + else { + printf("\n Процедура eraseall не найдена в загрузчике - используйте ключ -с для загрузки без патча!\n"); + return; + } + } + } //--------------------------------------------------------------------- diff --git a/loader-patch.c b/loader-patch.c index 5f9882d..a045634 100644 --- a/loader-patch.c +++ b/loader-patch.c @@ -1,8 +1,18 @@ #include -#include #include + +#ifndef WIN32 +//%%%% +#include #include #include +#else +//%%%% +#include +#include "getopt.h" +#include "printf.h" +#endif + #include "patcher.h" @@ -56,7 +66,7 @@ printf("\n Программа автоматической модификаци return; } -in=fopen(argv[optind],"r"); +in=fopen(argv[optind],"rb"); if (in == 0) { printf("\n Ошибка открытия файла %s",argv[optind]); return; @@ -74,41 +84,41 @@ fclose(in); //================================================================================== -res=pv7r22_3(buf, fsize); +res=pv7r1(buf, fsize); if (res != 0) { - printf("\n* Найдена сигнатура типа V7R22_3 по смещению %08x",res); + printf("\n* Найдена сигнатура типа V7R1 по смещению %08x",res); goto endpatch; -} +} -res=pv7r22_2(buf, fsize); +res=pv7r2(buf, fsize); if (res != 0) { - printf("\n* Найдена сигнатура типа V7R22_2 по смещению %08x",res); + printf("\n* Найдена сигнатура типа V7R2 по смещению %08x",res); goto endpatch; -} +} -res=pv7r22(buf, fsize); +res=pv7r11(buf, fsize); if (res != 0) { - printf("\n* Найдена сигнатура типа V7R22 по смещению %08x",res); + printf("\n* Найдена сигнатура типа V7R11 по смещению %08x",res); goto endpatch; -} +} -res=pv7r1(buf, fsize); +res=pv7r22(buf, fsize); if (res != 0) { - printf("\n* Найдена сигнатура типа V7R1 по смещению %08x",res); + printf("\n* Найдена сигнатура типа V7R22 по смещению %08x",res); goto endpatch; } -res=pv7r2(buf, fsize); +res=pv7r22_2(buf, fsize); if (res != 0) { - printf("\n* Найдена сигнатура типа V7R2 по смещению %08x",res); + printf("\n* Найдена сигнатура типа V7R22_2 по смещению %08x",res); goto endpatch; -} +} -res=pv7r11(buf, fsize); +res=pv7r22_3(buf, fsize); if (res != 0) { - printf("\n* Найдена сигнатура типа V7R11 по смещению %08x",res); + printf("\n* Найдена сигнатура типа V7R22_3 по смещению %08x",res); goto endpatch; -} +} printf("\n! Сигнатура eraseall-патча не найдена"); @@ -122,7 +132,7 @@ if (bflag) { } if (oflag) { - out=fopen(outfilename,"w"); + out=fopen(outfilename,"wb"); if (out != 0) { fwrite(buf,1,fsize,out); fclose(out); diff --git a/ptable-injector.c b/ptable-injector.c index ae7ba39..53fb523 100644 --- a/ptable-injector.c +++ b/ptable-injector.c @@ -3,9 +3,19 @@ // #include #include + +#ifndef WIN32 +//%%%% #include #include #include +#else +//%%%% +#include +#include "getopt.h" +#include "printf.h" +#endif + #include "parts.h" @@ -31,7 +41,6 @@ while ((opt = getopt(argc, argv, "mr:hx")) != -1) { case 'h': printf("\n Утилита для замены таблицы разделов в загрузчиках usbloader\ -\n Модем должен находиться в режиме fastboot\ \n\n\ %s [ключи] <имя файла usbloader>\n\n\ Допустимы следующие ключи:\n\n\ @@ -65,7 +74,7 @@ if (optind>=argc) { return; } -ldr=fopen(argv[optind],"r+"); +ldr=fopen(argv[optind],"r+b"); if (ldr == 0) { printf("\n Ошибка открытия файла %s\n",argv[optind]); return; @@ -83,7 +92,7 @@ if (ptaddr == 0) { fread(&ptable,sizeof(ptable),1,ldr); if (xflag) { - out=fopen("ptable.bin","w"); + out=fopen("ptable.bin","wb"); fwrite(&ptable,sizeof(ptable),1,out); fclose(out); } @@ -96,7 +105,7 @@ if (mflag | xflag) return; if (rflag) { - in=fopen(ptfile,"r"); + in=fopen(ptfile,"rb"); if (in == 0) { printf("\n Ошибка открытия файла %s",ptfile); return; diff --git a/ptable-list.c b/ptable-list.c index ab176f6..176d5d6 100644 --- a/ptable-list.c +++ b/ptable-list.c @@ -3,9 +3,19 @@ // #include #include + +#ifndef WIN32 +//%%%% #include #include #include +#else +//%%%% +#include +#include "getopt.h" +#include "printf.h" +#endif + #include "parts.h" @@ -23,7 +33,7 @@ if (argc != 2) { return; } -in=fopen(argv[optind],"r+"); +in=fopen(argv[optind],"r+b"); if (in == 0) { printf("\n Ошибка открытия файла %s\n",argv[optind]); return; diff --git a/usbloader-b525.bin b/usbloader-b525.bin index 05d9cba..876eecc 100644 Binary files a/usbloader-b525.bin and b/usbloader-b525.bin differ diff --git a/usbloader-b528.bin b/usbloader-b528.bin new file mode 100644 index 0000000..05d9cba Binary files /dev/null and b/usbloader-b528.bin differ diff --git a/usblsafe-b528.bin b/usblsafe-b528.bin new file mode 100644 index 0000000..a12dc4f Binary files /dev/null and b/usblsafe-b528.bin differ diff --git a/usblsafe_b315.bin b/usblsafe_b315.bin new file mode 100644 index 0000000..5331989 Binary files /dev/null and b/usblsafe_b315.bin differ diff --git a/usblsafe_b315s.bin b/usblsafe_b315s.bin deleted file mode 100644 index a78ec3b..0000000 Binary files a/usblsafe_b315s.bin and /dev/null differ diff --git a/usblsafe_b525.bin b/usblsafe_b525.bin new file mode 100644 index 0000000..b7c62f6 Binary files /dev/null and b/usblsafe_b525.bin differ diff --git a/winbuild/Release/balong_usbdload.exe b/winbuild/Release/balong_usbdload.exe index 86ca05d..151da67 100644 Binary files a/winbuild/Release/balong_usbdload.exe and b/winbuild/Release/balong_usbdload.exe differ diff --git a/winbuild/Release/loader-patch.exe b/winbuild/Release/loader-patch.exe new file mode 100644 index 0000000..b8abc98 Binary files /dev/null and b/winbuild/Release/loader-patch.exe differ diff --git a/winbuild/Release/ptable-injector.exe b/winbuild/Release/ptable-injector.exe new file mode 100644 index 0000000..65301d4 Binary files /dev/null and b/winbuild/Release/ptable-injector.exe differ diff --git a/winbuild/Release/ptable-list.exe b/winbuild/Release/ptable-list.exe new file mode 100644 index 0000000..9423fe6 Binary files /dev/null and b/winbuild/Release/ptable-list.exe differ diff --git a/winbuild/balong_usbdload.sln b/winbuild/balong_usbdload.sln index 3dc7d2d..1fc6f53 100644 --- a/winbuild/balong_usbdload.sln +++ b/winbuild/balong_usbdload.sln @@ -3,6 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "balong_usbdload", "balong_usbdload\balong_usbdload.vcxproj", "{6327503F-A1F5-49F8-906E-99EBAF484E75}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ptable-injector", "ptable-injector\ptable-injector.vcxproj", "{46C5A298-B5FF-458B-9F2E-1AC79AFC68C3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loader-patch", "loader-patch\loader-patch.vcxproj", "{9171DC4C-4C60-4B42-A84B-CD55B9BD17F6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ptable-list", "ptable-list\ptable-list.vcxproj", "{B7796E39-5EF2-448E-A37A-248A7F309F85}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -13,6 +19,18 @@ Global {6327503F-A1F5-49F8-906E-99EBAF484E75}.Debug|Win32.Build.0 = Debug|Win32 {6327503F-A1F5-49F8-906E-99EBAF484E75}.Release|Win32.ActiveCfg = Release|Win32 {6327503F-A1F5-49F8-906E-99EBAF484E75}.Release|Win32.Build.0 = Release|Win32 + {46C5A298-B5FF-458B-9F2E-1AC79AFC68C3}.Debug|Win32.ActiveCfg = Debug|Win32 + {46C5A298-B5FF-458B-9F2E-1AC79AFC68C3}.Debug|Win32.Build.0 = Debug|Win32 + {46C5A298-B5FF-458B-9F2E-1AC79AFC68C3}.Release|Win32.ActiveCfg = Release|Win32 + {46C5A298-B5FF-458B-9F2E-1AC79AFC68C3}.Release|Win32.Build.0 = Release|Win32 + {9171DC4C-4C60-4B42-A84B-CD55B9BD17F6}.Debug|Win32.ActiveCfg = Debug|Win32 + {9171DC4C-4C60-4B42-A84B-CD55B9BD17F6}.Debug|Win32.Build.0 = Debug|Win32 + {9171DC4C-4C60-4B42-A84B-CD55B9BD17F6}.Release|Win32.ActiveCfg = Release|Win32 + {9171DC4C-4C60-4B42-A84B-CD55B9BD17F6}.Release|Win32.Build.0 = Release|Win32 + {B7796E39-5EF2-448E-A37A-248A7F309F85}.Debug|Win32.ActiveCfg = Debug|Win32 + {B7796E39-5EF2-448E-A37A-248A7F309F85}.Debug|Win32.Build.0 = Debug|Win32 + {B7796E39-5EF2-448E-A37A-248A7F309F85}.Release|Win32.ActiveCfg = Release|Win32 + {B7796E39-5EF2-448E-A37A-248A7F309F85}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/winbuild/balong_usbdload/balong_usbdload.vcxproj b/winbuild/balong_usbdload/balong_usbdload.vcxproj index 5e6c6f3..7edd5b9 100644 --- a/winbuild/balong_usbdload/balong_usbdload.vcxproj +++ b/winbuild/balong_usbdload/balong_usbdload.vcxproj @@ -54,7 +54,7 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir) + $(ProjectDir);$(ProjectDir)\..\shared Console @@ -71,7 +71,7 @@ true true WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir) + $(ProjectDir);$(ProjectDir)\..\shared Console @@ -85,13 +85,13 @@ - + - - + + diff --git a/winbuild/loader-patch/loader-patch.vcxproj b/winbuild/loader-patch/loader-patch.vcxproj new file mode 100644 index 0000000..291fb18 --- /dev/null +++ b/winbuild/loader-patch/loader-patch.vcxproj @@ -0,0 +1,90 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {9171DC4C-4C60-4B42-A84B-CD55B9BD17F6} + Win32Proj + loaderpatch + + + + Application + true + v110_xp + Unicode + Static + + + Application + false + v110_xp + true + Unicode + Static + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir);$(ProjectDir)\..\shared + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir);$(ProjectDir)\..\shared + + + Console + false + true + true + + + + + + + + + + + \ No newline at end of file diff --git a/winbuild/loader-patch/loader-patch.vcxproj.filters b/winbuild/loader-patch/loader-patch.vcxproj.filters new file mode 100644 index 0000000..697394f --- /dev/null +++ b/winbuild/loader-patch/loader-patch.vcxproj.filters @@ -0,0 +1,28 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/winbuild/ptable-injector/ptable-injector.vcxproj b/winbuild/ptable-injector/ptable-injector.vcxproj new file mode 100644 index 0000000..c7da8ba --- /dev/null +++ b/winbuild/ptable-injector/ptable-injector.vcxproj @@ -0,0 +1,90 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {46C5A298-B5FF-458B-9F2E-1AC79AFC68C3} + Win32Proj + ptableinjector + + + + Application + true + v110_xp + Unicode + Static + + + Application + false + v110_xp + true + Unicode + Static + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir);$(ProjectDir)\..\shared + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir);$(ProjectDir)\..\shared + + + Console + false + true + true + + + + + + + + + + + \ No newline at end of file diff --git a/winbuild/ptable-injector/ptable-injector.vcxproj.filters b/winbuild/ptable-injector/ptable-injector.vcxproj.filters new file mode 100644 index 0000000..075d02d --- /dev/null +++ b/winbuild/ptable-injector/ptable-injector.vcxproj.filters @@ -0,0 +1,28 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/winbuild/ptable-list/ptable-list.vcxproj b/winbuild/ptable-list/ptable-list.vcxproj new file mode 100644 index 0000000..e4a6f81 --- /dev/null +++ b/winbuild/ptable-list/ptable-list.vcxproj @@ -0,0 +1,90 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {B7796E39-5EF2-448E-A37A-248A7F309F85} + Win32Proj + ptablelist + + + + Application + true + v110_xp + Unicode + Static + + + Application + false + v110_xp + true + Unicode + Static + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir);$(ProjectDir)\..\shared + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir);$(ProjectDir)\..\shared + + + Console + false + true + true + + + + + + + + + + + \ No newline at end of file diff --git a/winbuild/ptable-list/ptable-list.vcxproj.filters b/winbuild/ptable-list/ptable-list.vcxproj.filters new file mode 100644 index 0000000..a55cb51 --- /dev/null +++ b/winbuild/ptable-list/ptable-list.vcxproj.filters @@ -0,0 +1,28 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/winbuild/balong_usbdload/getopt.c b/winbuild/shared/getopt.c similarity index 100% rename from winbuild/balong_usbdload/getopt.c rename to winbuild/shared/getopt.c diff --git a/winbuild/balong_usbdload/getopt.h b/winbuild/shared/getopt.h similarity index 100% rename from winbuild/balong_usbdload/getopt.h rename to winbuild/shared/getopt.h diff --git a/winbuild/balong_usbdload/printf.h b/winbuild/shared/printf.h similarity index 96% rename from winbuild/balong_usbdload/printf.h rename to winbuild/shared/printf.h index 8102048..b5a0c80 100644 --- a/winbuild/balong_usbdload/printf.h +++ b/winbuild/shared/printf.h @@ -1,13 +1,13 @@ -static int printf(const char* format, ...) -{ - static char ostr[2048]; - static wchar_t wstr[2048]; - va_list args; - - va_start(args, format); - vsprintf(ostr, format, args); - va_end(args); - MultiByteToWideChar(CP_UTF8, 0, ostr, -1, wstr, 2048); - WideCharToMultiByte(CP_OEMCP, 0, wstr, -1, ostr, 2048, NULL, NULL); - return printf_s("%s", ostr); -} +static int printf(const char* format, ...) +{ + static char ostr[2048]; + static wchar_t wstr[2048]; + va_list args; + + va_start(args, format); + vsprintf(ostr, format, args); + va_end(args); + MultiByteToWideChar(CP_UTF8, 0, ostr, -1, wstr, 2048); + WideCharToMultiByte(CP_OEMCP, 0, wstr, -1, ostr, 2048, NULL, NULL); + return printf_s("%s", ostr); +}