From: <fr...@us...> - 2019-07-10 07:30:21
|
Revision: 4959 http://sourceforge.net/p/mp-plugins/code/4959 Author: framug Date: 2019-07-10 07:30:19 +0000 (Wed, 10 Jul 2019) Log Message: ----------- MultiShortcut V2.7 : change the way to hack the dll since changes in DOTNET result in compil modifications. Modified Paths: -------------- trunk/plugins/MultiShortcut/DLLFix/Program.cs trunk/plugins/MultiShortcut/DLLFix/Properties/AssemblyInfo.cs trunk/plugins/MultiShortcut/MultiShortcut/Properties/AssemblyInfo.cs Modified: trunk/plugins/MultiShortcut/DLLFix/Program.cs =================================================================== --- trunk/plugins/MultiShortcut/DLLFix/Program.cs 2019-07-09 05:23:33 UTC (rev 4958) +++ trunk/plugins/MultiShortcut/DLLFix/Program.cs 2019-07-10 07:30:19 UTC (rev 4959) @@ -31,6 +31,12 @@ 0x63, 0x75, 0x74 }; + byte[] search_bytes2 = new byte[] + { + // M u l t i S h o r t c u t + 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x53, 0x68, 0x6F, 0x72, 0x74, 0x63, 0x75, 0x74 + }; + byte fileCounter = 0; string myPath = System.Reflection.Assembly.GetExecutingAssembly().Location; @@ -44,8 +50,8 @@ Console.WriteLine("** **"); Console.WriteLine("*******************************************************"); Console.WriteLine(""); - Console.WriteLine("1.) Patching files...\n"); - // Parse all MP plugins DLL + Console.WriteLine("1.) Patching files... first method\n"); + // Parse all MP plugins DLL first time foreach (string s in files) { using (Stream st = new FileStream(s, FileMode.Open, FileAccess.ReadWrite)) @@ -64,7 +70,6 @@ for (int i = 0; i < bytes_read + offset - search_bytes.Length; i++) { match = true; - // Loop inside 43 bytes until differ. for (int j = 0; j < search_bytes.Length; j++) { @@ -102,6 +107,71 @@ } } + Console.WriteLine(""); + Console.WriteLine("1.) First method ended\n"); + Console.WriteLine(""); + Console.WriteLine("\n3.) Press a key to continue..."); + Console.ReadKey(); + + Console.WriteLine(""); + Console.WriteLine("1.) Patching files... second method\n"); + // Parse all MP plugins DLL second time + foreach (string s in files) + { + using (Stream st = new FileStream(s, FileMode.Open, FileAccess.ReadWrite)) + { + int offset = 0; + long file_pos = 0; + int bytes_read = 0; + byte[] buffer = new byte[65536]; + + bool match = false; + + // Loop for each 64 KB buffer length until EOF or, found what searched + while ((bytes_read = st.Read(buffer, offset, buffer.Length - offset)) > 0 && !match) + { + // Loop for each searched bytes : 13 bytes length step, in this case. + for (int i = 0; i < bytes_read + offset - search_bytes2.Length; i++) + { + match = true; + + // Loop inside 13 bytes until differ. + for (int j = 0; j < search_bytes2.Length; j++) + { + if (search_bytes2[j] != buffer[i + j]) + { + match = false; + break; + } + } + + // We found "MultiShortcut" inside the DLL code. + // Then, it's most likely a MultiShortcut DLL. + if (match) + { + // Replace value number in the dll code then, ability to have duplicate plugins. + st.Seek(file_pos + i - offset + search_bytes2.Length, SeekOrigin.Begin); + byte[] replaceBuffer = new byte[] { (Byte)(48 + (fileCounter > 9 ? ((int)fileCounter / 10) : 0)), (Byte)(48 + ((int)fileCounter % 10)) }; + string Sreplaced = Encoding.ASCII.GetString(replaceBuffer); + st.Write(replaceBuffer, 0, replaceBuffer.Length); + Console.WriteLine(" - PATCHED: {0} with {1} value.", s.Substring(s.LastIndexOf('\\') + 1), Sreplaced); + fileCounter++; + break; + } + } + + file_pos = st.Position; + + offset = search_bytes2.Length; + // recopy the end of the buffer + for (int i = 0; i < offset; i++) + { + buffer[i] = buffer[buffer.Length - offset + i]; + } + } + } + } + Console.WriteLine("\n2.) Done."); Console.WriteLine("\n3.) Press Enter to close..."); Console.ReadKey(); Modified: trunk/plugins/MultiShortcut/DLLFix/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MultiShortcut/DLLFix/Properties/AssemblyInfo.cs 2019-07-09 05:23:33 UTC (rev 4958) +++ trunk/plugins/MultiShortcut/DLLFix/Properties/AssemblyInfo.cs 2019-07-10 07:30:19 UTC (rev 4959) @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] Modified: trunk/plugins/MultiShortcut/MultiShortcut/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MultiShortcut/MultiShortcut/Properties/AssemblyInfo.cs 2019-07-09 05:23:33 UTC (rev 4958) +++ trunk/plugins/MultiShortcut/MultiShortcut/Properties/AssemblyInfo.cs 2019-07-10 07:30:19 UTC (rev 4959) @@ -33,8 +33,8 @@ // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.6.0.0")] -[assembly: AssemblyFileVersion("2.6.0.0")] +[assembly: AssemblyVersion("2.7.0.0")] +[assembly: AssemblyFileVersion("2.7.0.0")] // MediaPortal plugin version compatibility [assembly: CompatibleVersion("1.5.100.0")] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |