mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
tolerate missing classes in interceptFileOperations
If we fail to resolve a given class (e.g. due to ProGuard obfuscating or eliminating it), just move on to the next one rather than return immediately. Otherwise, we may miss intercepting methods of classes we can resolve.
This commit is contained in:
parent
4d1711cd04
commit
0987255552
@ -1691,37 +1691,41 @@ interceptFileOperations(Thread* t)
|
||||
MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
|
||||
|
||||
{ object fileClass = resolveClass
|
||||
(t, root(t, Machine::BootLoader), "java/io/File");
|
||||
if (fileClass == 0) return;
|
||||
(t, root(t, Machine::BootLoader), "java/io/File", false);
|
||||
|
||||
if (fileClass) {
|
||||
object filePathField = findFieldInClass2
|
||||
(t, fileClass, "path", "Ljava/lang/String;");
|
||||
if (filePathField == 0) return;
|
||||
|
||||
if (filePathField) {
|
||||
cp->filePathField = fieldOffset(t, filePathField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ object fileDescriptorClass = resolveClass
|
||||
(t, root(t, Machine::BootLoader), "java/io/FileDescriptor");
|
||||
if (fileDescriptorClass == 0) return;
|
||||
(t, root(t, Machine::BootLoader), "java/io/FileDescriptor", false);
|
||||
|
||||
if (fileDescriptorClass) {
|
||||
object fileDescriptorFdField = findFieldInClass2
|
||||
(t, fileDescriptorClass, "fd", "I");
|
||||
if (fileDescriptorFdField == 0) return;
|
||||
|
||||
if (fileDescriptorFdField) {
|
||||
cp->fileDescriptorFdField = fieldOffset(t, fileDescriptorFdField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ object fileInputStreamClass = resolveClass
|
||||
(t, root(t, Machine::BootLoader), "java/io/FileInputStream");
|
||||
if (fileInputStreamClass == 0) return;
|
||||
(t, root(t, Machine::BootLoader), "java/io/FileInputStream", false);
|
||||
|
||||
if (fileInputStreamClass) {
|
||||
PROTECT(t, fileInputStreamClass);
|
||||
|
||||
object fileInputStreamFdField = findFieldInClass2
|
||||
(t, fileInputStreamClass, "fd", "Ljava/io/FileDescriptor;");
|
||||
if (fileInputStreamFdField == 0) return;
|
||||
|
||||
if (fileInputStreamFdField) {
|
||||
cp->fileInputStreamFdField = fieldOffset(t, fileInputStreamFdField);
|
||||
|
||||
intercept(t, fileInputStreamClass, "open", "(Ljava/lang/String;)V",
|
||||
@ -1742,63 +1746,73 @@ interceptFileOperations(Thread* t)
|
||||
intercept(t, fileInputStreamClass, "close0", "()V",
|
||||
voidPointer(closeFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ object zipEntryClass = resolveClass
|
||||
(t, root(t, Machine::BootLoader), "java/util/zip/ZipEntry");
|
||||
if (zipEntryClass == 0) return;
|
||||
(t, root(t, Machine::BootLoader), "java/util/zip/ZipEntry", false);
|
||||
|
||||
if (zipEntryClass) {
|
||||
PROTECT(t, zipEntryClass);
|
||||
|
||||
object zipEntryNameField = findFieldInClass2
|
||||
(t, zipEntryClass, "name", "Ljava/lang/String;");
|
||||
if (zipEntryNameField == 0) return;
|
||||
|
||||
if (zipEntryNameField) {
|
||||
cp->zipEntryNameField = fieldOffset(t, zipEntryNameField);
|
||||
|
||||
object zipEntryTimeField = findFieldInClass2
|
||||
(t, zipEntryClass, "time", "J");
|
||||
if (zipEntryTimeField == 0) return;
|
||||
|
||||
if (zipEntryTimeField) {
|
||||
cp->zipEntryTimeField = fieldOffset(t, zipEntryTimeField);
|
||||
|
||||
object zipEntryCrcField = findFieldInClass2
|
||||
(t, zipEntryClass, "crc", "J");
|
||||
if (zipEntryCrcField == 0) return;
|
||||
|
||||
if (zipEntryCrcField) {
|
||||
cp->zipEntryCrcField = fieldOffset(t, zipEntryCrcField);
|
||||
|
||||
object zipEntrySizeField = findFieldInClass2
|
||||
(t, zipEntryClass, "size", "J");
|
||||
if (zipEntrySizeField == 0) return;
|
||||
|
||||
if (zipEntrySizeField) {
|
||||
cp->zipEntrySizeField = fieldOffset(t, zipEntrySizeField);
|
||||
|
||||
object zipEntryCsizeField = findFieldInClass2
|
||||
(t, zipEntryClass, "csize", "J");
|
||||
if (zipEntryCsizeField == 0) return;
|
||||
|
||||
if (zipEntryCsizeField) {
|
||||
cp->zipEntryCsizeField = fieldOffset(t, zipEntryCsizeField);
|
||||
|
||||
object zipEntryMethodField = findFieldInClass2
|
||||
(t, zipEntryClass, "method", "I");
|
||||
if (zipEntryMethodField == 0) return;
|
||||
|
||||
cp->zipEntryMethodField = fieldOffset(t, zipEntryMethodField);
|
||||
if (zipEntryMethodField) {
|
||||
cp->zipEntryMethodField = fieldOffset
|
||||
(t, zipEntryMethodField);
|
||||
|
||||
intercept(t, zipEntryClass, "initFields", "(J)V",
|
||||
voidPointer(initializeZipEntryFields));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ object zipFileClass = resolveClass
|
||||
(t, root(t, Machine::BootLoader), "java/util/zip/ZipFile");
|
||||
if (zipFileClass == 0) return;
|
||||
(t, root(t, Machine::BootLoader), "java/util/zip/ZipFile", false);
|
||||
|
||||
if (zipFileClass) {
|
||||
PROTECT(t, zipFileClass);
|
||||
|
||||
object zipFileJzfileField = findFieldInClass2
|
||||
(t, zipFileClass, "jzfile", "J");
|
||||
if (zipFileJzfileField == 0) return;
|
||||
|
||||
if (zipFileJzfileField) {
|
||||
cp->zipFileJzfileField = fieldOffset(t, zipFileJzfileField);
|
||||
|
||||
intercept(t, zipFileClass, "open", "(Ljava/lang/String;IJ)J",
|
||||
@ -1834,14 +1848,18 @@ interceptFileOperations(Thread* t)
|
||||
intercept(t, zipFileClass, "close", "(J)V",
|
||||
voidPointer(closeZipFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ object jarFileClass = resolveClass
|
||||
(t, root(t, Machine::BootLoader), "java/util/jar/JarFile");
|
||||
if (jarFileClass == 0) return;
|
||||
(t, root(t, Machine::BootLoader), "java/util/jar/JarFile", false);
|
||||
|
||||
intercept(t, jarFileClass, "getMetaInfEntryNames", "()[Ljava/lang/String;",
|
||||
if (jarFileClass) {
|
||||
intercept(t, jarFileClass, "getMetaInfEntryNames",
|
||||
"()[Ljava/lang/String;",
|
||||
voidPointer(getJarFileMetaInfEntryNames));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
@ -1854,8 +1872,8 @@ interceptFileOperations(Thread* t)
|
||||
|
||||
object fsClass = resolveClass
|
||||
(t, root(t, Machine::BootLoader), fsClassName, false);
|
||||
if (fsClass == 0) return;
|
||||
|
||||
if (fsClass) {
|
||||
PROTECT(t, fsClass);
|
||||
|
||||
intercept(t, fsClass, gbaMethodName, "(Ljava/io/File;)I",
|
||||
@ -1867,6 +1885,7 @@ interceptFileOperations(Thread* t)
|
||||
intercept(t, fsClass, "getLength", "(Ljava/io/File;)J",
|
||||
voidPointer(getFileLength));
|
||||
}
|
||||
}
|
||||
|
||||
intercept(t, type(t, Machine::ClassLoaderType), "loadLibrary",
|
||||
"(Ljava/lang/Class;Ljava/lang/String;Z)V",
|
||||
|
Loading…
Reference in New Issue
Block a user