From 6e10162ffb3d3654de8a4f2904005764399a0482 Mon Sep 17 00:00:00 2001 From: UnknownObject <38148526+UnknownObject000@users.noreply.github.com> Date: Wed, 13 Jan 2021 17:30:54 +0800 Subject: [PATCH] Add files via upload --- LOGOIMGEditor/LOGOIMGEditor.sln | 31 ++++ LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.cpp | 115 ++++++++++++++ .../LOGOIMGEditor/LOGOIMGEditor.vcxproj | 147 ++++++++++++++++++ .../LOGOIMGEditor.vcxproj.filters | 22 +++ .../LOGOIMGEditor/LOGOIMGEditor.vcxproj.user | 4 + 5 files changed, 319 insertions(+) create mode 100644 LOGOIMGEditor/LOGOIMGEditor.sln create mode 100644 LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.cpp create mode 100644 LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj create mode 100644 LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.filters create mode 100644 LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.user diff --git a/LOGOIMGEditor/LOGOIMGEditor.sln b/LOGOIMGEditor/LOGOIMGEditor.sln new file mode 100644 index 0000000..c8b43f9 --- /dev/null +++ b/LOGOIMGEditor/LOGOIMGEditor.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LOGOIMGEditor", "LOGOIMGEditor\LOGOIMGEditor.vcxproj", "{03636210-291F-40AE-A519-CB5857387FB4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03636210-291F-40AE-A519-CB5857387FB4}.Debug|x64.ActiveCfg = Debug|x64 + {03636210-291F-40AE-A519-CB5857387FB4}.Debug|x64.Build.0 = Debug|x64 + {03636210-291F-40AE-A519-CB5857387FB4}.Debug|x86.ActiveCfg = Debug|Win32 + {03636210-291F-40AE-A519-CB5857387FB4}.Debug|x86.Build.0 = Debug|Win32 + {03636210-291F-40AE-A519-CB5857387FB4}.Release|x64.ActiveCfg = Release|x64 + {03636210-291F-40AE-A519-CB5857387FB4}.Release|x64.Build.0 = Release|x64 + {03636210-291F-40AE-A519-CB5857387FB4}.Release|x86.ActiveCfg = Release|Win32 + {03636210-291F-40AE-A519-CB5857387FB4}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {619FA7EB-45FB-4BA8-AFB4-866CB3E729C0} + EndGlobalSection +EndGlobal diff --git a/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.cpp b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.cpp new file mode 100644 index 0000000..4a4fd0a --- /dev/null +++ b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.cpp @@ -0,0 +1,115 @@ +// LOGOIMGEditor.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 +// + +#include +#include +#include + +#define EXIT_MAIN(code,fmt,...) {printf("main() exited. Code %d\nMessage: ",code);printf(fmt,__VA_ARGS__);return code;}; + +using namespace std; + +/* + +offsets: +00: 0x00000000 - 0x00004FFF - don't know +01: 0x00005000 - 0x0073FD07 - image 1 +(ZEROS) +02: 0x00740000 - 0x00E7AFD7 - image 2 +(ZEROS) +03: 0x00E7B000 - 0x015B5FD7 - image 3 +(ZEROS) +04: 0x015B6000 - 0x01820000 - image 4 + +*/ + +bool FileExist(string file) +{ + fstream io(file.c_str(), ios::in); + bool ret = io.is_open(); + io.close(); + return ret; +} + +int GetOffset(int img, bool front) +{ + switch (img) + { + case 1: + return (front ? 0x00005000 : 0x0073FD07); + case 2: + return (front ? 0x00740000 : 0x00E7AFD7); + case 3: + return (front ? 0x00E7B000 : 0x015B5FD7); + case 4: + return (front ? 0x015B6000 : 0x01820000); + } + return 0; +} + +int main(int argc,char* argv[]) +{ + if (argc != 7) + EXIT_MAIN(-32767, "This tool take 6 partmers insteaed of %d.\n[Usage] LOGOIMGEditor.exe [old_img_file] [new_img_file] [normal_bmp] [fastboot_bmp] [unlocked_bmp] [destroyed_bmp]\n", argc - 1); + if (!FileExist(argv[1])) + EXIT_MAIN(-65534, "Image file \"%s\" does not exist.\n", argv[1]); + for (int i = 3; i < 7; i++) + if (!FileExist(argv[i])) + EXIT_MAIN(-65535, "BMP file \"%s\" does not exist.\n", argv[i]); + const string input_file_path = argv[1]; + const string output_file_path = argv[2]; + fstream input(input_file_path.c_str(), ios::in | ios::binary); + if (!input.is_open()) + EXIT_MAIN(-1, "Cannot open input file\n"); + fstream output(output_file_path.c_str(), ios::out | ios::binary); + if (!output.is_open()) + EXIT_MAIN(-2, "Cannot open output file\n"); + char buffer[1]; + int bytecnt = 0x00004FFF; + //I don't know the meaning of bytes before 0x00004FFFF, so just copy them. + printf("Copying bytes before 0x00004FFF......\n"); + for (int i = 0; i < 0x00004FFF; i++) + { + input.read(buffer, 1); + output.write(buffer, 1); + memset(buffer, 0, sizeof(buffer)); + } + input.close(); + //Repeat:write every image to the new .img file, and add some zeros bewteen two image. + for (int i = 3; i < 7; i++) + { + printf("Processing image %d (%s)......\n", i - 2, argv[i]); + input.open(argv[i], ios::in | ios::binary); + if (!input.is_open()) + { + output.close(); + EXIT_MAIN(-3, "Cannot open input image \"%s\"\n", argv[i]); + } + printf("Filling zeros between images......\n"); + while (bytecnt < GetOffset(i - 2, true)) + { + memset(buffer, 0, sizeof(buffer)); + output.write(buffer, 1); + bytecnt++; + } + printf("Writing image......\n"); + while (!input.eof()) + { + input.read(buffer, 1); + output.write(buffer, 1); + memset(buffer, 0, sizeof(buffer)); + bytecnt++; + } + input.close(); + } + //fill up zeros in the end of the file. + printf("Filling zeros at the end of file......\n"); + while (bytecnt < GetOffset(4, false)) + { + memset(buffer, 0, sizeof(buffer)); + output.write(buffer, 1); + bytecnt++; + } + output.close(); + EXIT_MAIN(0, "Successfully finished.\n"); +} \ No newline at end of file diff --git a/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj new file mode 100644 index 0000000..d761934 --- /dev/null +++ b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {03636210-291f-40ae-a519-cb5857387fb4} + LOGOIMGEditor + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.filters b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.filters new file mode 100644 index 0000000..803588f --- /dev/null +++ b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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 + + + + + 源文件 + + + \ No newline at end of file diff --git a/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.user b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.user new file mode 100644 index 0000000..0f14913 --- /dev/null +++ b/LOGOIMGEditor/LOGOIMGEditor/LOGOIMGEditor.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file