MCP will reobf classes with reserved names in windows to a legal file name. And FML will try to read these classes over the default ones.
This commit is contained in:
parent
48551959ec
commit
909b629fa4
3 changed files with 53 additions and 20 deletions
|
@ -106,25 +106,40 @@
|
|||
for class_file in fnmatch.filter(filelist, '*.class'):
|
||||
class_name = class_path + os.path.splitext(class_file)[0]
|
||||
bin_file = os.path.normpath(os.path.join(path, class_file))
|
||||
@@ -1554,7 +1565,16 @@
|
||||
except KeyError:
|
||||
self.logger.error('* File %s not found for %s', out_class, in_class)
|
||||
except IOError:
|
||||
- self.logger.error('* File %s failed extracting for %s', out_class, in_class)
|
||||
+ if not '/' in out_class:
|
||||
+ try:
|
||||
+ f = open(os.path.join(outpathlk[side], '_' + out_class, 'wb'))
|
||||
+ f.write(zipjar.read(out_class))
|
||||
+ f.close()
|
||||
+ self.logger.info('> Outputted %s to %s as %s', in_class.ljust(35), outpathlk[side], '_' + out_class)
|
||||
+ except IOError:
|
||||
+ self.logger.error('* File %s failed extracting for %s', out_class, in_class)
|
||||
+ else:
|
||||
+ self.logger.error('* File %s failed extracting for %s', out_class, in_class)
|
||||
@@ -1535,6 +1546,8 @@
|
||||
if not os.path.exists(outpathlk[side]):
|
||||
os.makedirs(outpathlk[side])
|
||||
|
||||
def downloadupdates(self, force=False):
|
||||
if not self.updateurl:
|
||||
@@ -1594,6 +1614,9 @@
|
||||
+ reserved = ['CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9']
|
||||
+
|
||||
# HINT: We extract the modified class files
|
||||
with closing(zipfile.ZipFile(jarlk[side])) as zipjar:
|
||||
for in_class in trgclasses:
|
||||
@@ -1548,6 +1561,23 @@
|
||||
out_class = out_class.replace(self.nullpkg, '')
|
||||
if out_class[0] == '/':
|
||||
out_class = out_class[1:]
|
||||
+
|
||||
+ rename = False
|
||||
+ for res in reserved:
|
||||
+ if out_class.upper().startswith(res):
|
||||
+ rename = True
|
||||
+ break
|
||||
+
|
||||
+ if rename:
|
||||
+ try:
|
||||
+ f = open(os.path.join(outpathlk[side], '_' + out_class), 'wb')
|
||||
+ f.write(zipjar.read(out_class))
|
||||
+ f.close()
|
||||
+ self.logger.info('> Outputted %s to %s as %s', in_class.ljust(35), outpathlk[side], '_' + out_class)
|
||||
+ except IOError:
|
||||
+ self.logger.error('* File %s failed extracting for %s', out_class, in_class)
|
||||
+ continue
|
||||
+
|
||||
try:
|
||||
zipjar.extract(out_class, outpathlk[side])
|
||||
self.logger.info('> Outputted %s to %s as %s', in_class.ljust(35), outpathlk[side], out_class)
|
||||
@@ -1594,6 +1624,9 @@
|
||||
sys.exit(1)
|
||||
|
||||
for entry in newfiles:
|
||||
|
@ -134,7 +149,7 @@
|
|||
if entry[3] == 'U':
|
||||
self.logger.info('Retrieving file from server : %s', entry[0])
|
||||
cur_file = os.path.normpath(entry[0])
|
||||
@@ -1614,6 +1637,9 @@
|
||||
@@ -1614,6 +1647,9 @@
|
||||
md5reoblk = {CLIENT: self.md5reobfclient, SERVER: self.md5reobfserver}
|
||||
outpathlk = {CLIENT: self.srcmodclient, SERVER: self.srcmodserver}
|
||||
src = {CLIENT: self.srcclient, SERVER: self.srcserver}
|
||||
|
@ -144,7 +159,7 @@
|
|||
|
||||
# HINT: We need a table for the old md5 and the new ones
|
||||
md5table = {}
|
||||
@@ -1656,3 +1682,6 @@
|
||||
@@ -1656,3 +1692,6 @@
|
||||
except IOError:
|
||||
self.logger.error('* File %s copy failed', in_class)
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.jar.Attributes.Name;
|
||||
|
@ -40,6 +41,8 @@ public class RelaunchClassLoader extends URLClassLoader
|
|||
private Map<Package,Manifest> packageManifests = new HashMap<Package,Manifest>();
|
||||
|
||||
private static Manifest EMPTY = new Manifest();
|
||||
|
||||
private static final String[] RESERVED = {"CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};
|
||||
|
||||
public RelaunchClassLoader(URL[] sources)
|
||||
{
|
||||
|
@ -271,6 +274,21 @@ public class RelaunchClassLoader extends URLClassLoader
|
|||
|
||||
public byte[] getClassBytes(String name) throws IOException
|
||||
{
|
||||
if (name.indexOf('.') == -1)
|
||||
{
|
||||
for (String res : RESERVED)
|
||||
{
|
||||
if (name.toUpperCase(Locale.ENGLISH).startsWith(res))
|
||||
{
|
||||
byte[] data = getClassBytes("_" + name);
|
||||
if (data != null)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InputStream classStream = null;
|
||||
try
|
||||
{
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue