mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +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);
|
MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
|
||||||
|
|
||||||
{ object fileClass = resolveClass
|
{ object fileClass = resolveClass
|
||||||
(t, root(t, Machine::BootLoader), "java/io/File");
|
(t, root(t, Machine::BootLoader), "java/io/File", false);
|
||||||
if (fileClass == 0) return;
|
|
||||||
|
|
||||||
|
if (fileClass) {
|
||||||
object filePathField = findFieldInClass2
|
object filePathField = findFieldInClass2
|
||||||
(t, fileClass, "path", "Ljava/lang/String;");
|
(t, fileClass, "path", "Ljava/lang/String;");
|
||||||
if (filePathField == 0) return;
|
|
||||||
|
|
||||||
|
if (filePathField) {
|
||||||
cp->filePathField = fieldOffset(t, filePathField);
|
cp->filePathField = fieldOffset(t, filePathField);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{ object fileDescriptorClass = resolveClass
|
{ object fileDescriptorClass = resolveClass
|
||||||
(t, root(t, Machine::BootLoader), "java/io/FileDescriptor");
|
(t, root(t, Machine::BootLoader), "java/io/FileDescriptor", false);
|
||||||
if (fileDescriptorClass == 0) return;
|
|
||||||
|
|
||||||
|
if (fileDescriptorClass) {
|
||||||
object fileDescriptorFdField = findFieldInClass2
|
object fileDescriptorFdField = findFieldInClass2
|
||||||
(t, fileDescriptorClass, "fd", "I");
|
(t, fileDescriptorClass, "fd", "I");
|
||||||
if (fileDescriptorFdField == 0) return;
|
|
||||||
|
|
||||||
|
if (fileDescriptorFdField) {
|
||||||
cp->fileDescriptorFdField = fieldOffset(t, fileDescriptorFdField);
|
cp->fileDescriptorFdField = fieldOffset(t, fileDescriptorFdField);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{ object fileInputStreamClass = resolveClass
|
{ object fileInputStreamClass = resolveClass
|
||||||
(t, root(t, Machine::BootLoader), "java/io/FileInputStream");
|
(t, root(t, Machine::BootLoader), "java/io/FileInputStream", false);
|
||||||
if (fileInputStreamClass == 0) return;
|
|
||||||
|
|
||||||
|
if (fileInputStreamClass) {
|
||||||
PROTECT(t, fileInputStreamClass);
|
PROTECT(t, fileInputStreamClass);
|
||||||
|
|
||||||
object fileInputStreamFdField = findFieldInClass2
|
object fileInputStreamFdField = findFieldInClass2
|
||||||
(t, fileInputStreamClass, "fd", "Ljava/io/FileDescriptor;");
|
(t, fileInputStreamClass, "fd", "Ljava/io/FileDescriptor;");
|
||||||
if (fileInputStreamFdField == 0) return;
|
|
||||||
|
|
||||||
|
if (fileInputStreamFdField) {
|
||||||
cp->fileInputStreamFdField = fieldOffset(t, fileInputStreamFdField);
|
cp->fileInputStreamFdField = fieldOffset(t, fileInputStreamFdField);
|
||||||
|
|
||||||
intercept(t, fileInputStreamClass, "open", "(Ljava/lang/String;)V",
|
intercept(t, fileInputStreamClass, "open", "(Ljava/lang/String;)V",
|
||||||
@ -1742,63 +1746,73 @@ interceptFileOperations(Thread* t)
|
|||||||
intercept(t, fileInputStreamClass, "close0", "()V",
|
intercept(t, fileInputStreamClass, "close0", "()V",
|
||||||
voidPointer(closeFile));
|
voidPointer(closeFile));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{ object zipEntryClass = resolveClass
|
{ object zipEntryClass = resolveClass
|
||||||
(t, root(t, Machine::BootLoader), "java/util/zip/ZipEntry");
|
(t, root(t, Machine::BootLoader), "java/util/zip/ZipEntry", false);
|
||||||
if (zipEntryClass == 0) return;
|
|
||||||
|
|
||||||
|
if (zipEntryClass) {
|
||||||
PROTECT(t, zipEntryClass);
|
PROTECT(t, zipEntryClass);
|
||||||
|
|
||||||
object zipEntryNameField = findFieldInClass2
|
object zipEntryNameField = findFieldInClass2
|
||||||
(t, zipEntryClass, "name", "Ljava/lang/String;");
|
(t, zipEntryClass, "name", "Ljava/lang/String;");
|
||||||
if (zipEntryNameField == 0) return;
|
|
||||||
|
|
||||||
|
if (zipEntryNameField) {
|
||||||
cp->zipEntryNameField = fieldOffset(t, zipEntryNameField);
|
cp->zipEntryNameField = fieldOffset(t, zipEntryNameField);
|
||||||
|
|
||||||
object zipEntryTimeField = findFieldInClass2
|
object zipEntryTimeField = findFieldInClass2
|
||||||
(t, zipEntryClass, "time", "J");
|
(t, zipEntryClass, "time", "J");
|
||||||
if (zipEntryTimeField == 0) return;
|
|
||||||
|
|
||||||
|
if (zipEntryTimeField) {
|
||||||
cp->zipEntryTimeField = fieldOffset(t, zipEntryTimeField);
|
cp->zipEntryTimeField = fieldOffset(t, zipEntryTimeField);
|
||||||
|
|
||||||
object zipEntryCrcField = findFieldInClass2
|
object zipEntryCrcField = findFieldInClass2
|
||||||
(t, zipEntryClass, "crc", "J");
|
(t, zipEntryClass, "crc", "J");
|
||||||
if (zipEntryCrcField == 0) return;
|
|
||||||
|
|
||||||
|
if (zipEntryCrcField) {
|
||||||
cp->zipEntryCrcField = fieldOffset(t, zipEntryCrcField);
|
cp->zipEntryCrcField = fieldOffset(t, zipEntryCrcField);
|
||||||
|
|
||||||
object zipEntrySizeField = findFieldInClass2
|
object zipEntrySizeField = findFieldInClass2
|
||||||
(t, zipEntryClass, "size", "J");
|
(t, zipEntryClass, "size", "J");
|
||||||
if (zipEntrySizeField == 0) return;
|
|
||||||
|
|
||||||
|
if (zipEntrySizeField) {
|
||||||
cp->zipEntrySizeField = fieldOffset(t, zipEntrySizeField);
|
cp->zipEntrySizeField = fieldOffset(t, zipEntrySizeField);
|
||||||
|
|
||||||
object zipEntryCsizeField = findFieldInClass2
|
object zipEntryCsizeField = findFieldInClass2
|
||||||
(t, zipEntryClass, "csize", "J");
|
(t, zipEntryClass, "csize", "J");
|
||||||
if (zipEntryCsizeField == 0) return;
|
|
||||||
|
|
||||||
|
if (zipEntryCsizeField) {
|
||||||
cp->zipEntryCsizeField = fieldOffset(t, zipEntryCsizeField);
|
cp->zipEntryCsizeField = fieldOffset(t, zipEntryCsizeField);
|
||||||
|
|
||||||
object zipEntryMethodField = findFieldInClass2
|
object zipEntryMethodField = findFieldInClass2
|
||||||
(t, zipEntryClass, "method", "I");
|
(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",
|
intercept(t, zipEntryClass, "initFields", "(J)V",
|
||||||
voidPointer(initializeZipEntryFields));
|
voidPointer(initializeZipEntryFields));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{ object zipFileClass = resolveClass
|
{ object zipFileClass = resolveClass
|
||||||
(t, root(t, Machine::BootLoader), "java/util/zip/ZipFile");
|
(t, root(t, Machine::BootLoader), "java/util/zip/ZipFile", false);
|
||||||
if (zipFileClass == 0) return;
|
|
||||||
|
|
||||||
|
if (zipFileClass) {
|
||||||
PROTECT(t, zipFileClass);
|
PROTECT(t, zipFileClass);
|
||||||
|
|
||||||
object zipFileJzfileField = findFieldInClass2
|
object zipFileJzfileField = findFieldInClass2
|
||||||
(t, zipFileClass, "jzfile", "J");
|
(t, zipFileClass, "jzfile", "J");
|
||||||
if (zipFileJzfileField == 0) return;
|
|
||||||
|
|
||||||
|
if (zipFileJzfileField) {
|
||||||
cp->zipFileJzfileField = fieldOffset(t, zipFileJzfileField);
|
cp->zipFileJzfileField = fieldOffset(t, zipFileJzfileField);
|
||||||
|
|
||||||
intercept(t, zipFileClass, "open", "(Ljava/lang/String;IJ)J",
|
intercept(t, zipFileClass, "open", "(Ljava/lang/String;IJ)J",
|
||||||
@ -1834,14 +1848,18 @@ interceptFileOperations(Thread* t)
|
|||||||
intercept(t, zipFileClass, "close", "(J)V",
|
intercept(t, zipFileClass, "close", "(J)V",
|
||||||
voidPointer(closeZipFile));
|
voidPointer(closeZipFile));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{ object jarFileClass = resolveClass
|
{ object jarFileClass = resolveClass
|
||||||
(t, root(t, Machine::BootLoader), "java/util/jar/JarFile");
|
(t, root(t, Machine::BootLoader), "java/util/jar/JarFile", false);
|
||||||
if (jarFileClass == 0) return;
|
|
||||||
|
|
||||||
intercept(t, jarFileClass, "getMetaInfEntryNames", "()[Ljava/lang/String;",
|
if (jarFileClass) {
|
||||||
|
intercept(t, jarFileClass, "getMetaInfEntryNames",
|
||||||
|
"()[Ljava/lang/String;",
|
||||||
voidPointer(getJarFileMetaInfEntryNames));
|
voidPointer(getJarFileMetaInfEntryNames));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
@ -1854,8 +1872,8 @@ interceptFileOperations(Thread* t)
|
|||||||
|
|
||||||
object fsClass = resolveClass
|
object fsClass = resolveClass
|
||||||
(t, root(t, Machine::BootLoader), fsClassName, false);
|
(t, root(t, Machine::BootLoader), fsClassName, false);
|
||||||
if (fsClass == 0) return;
|
|
||||||
|
|
||||||
|
if (fsClass) {
|
||||||
PROTECT(t, fsClass);
|
PROTECT(t, fsClass);
|
||||||
|
|
||||||
intercept(t, fsClass, gbaMethodName, "(Ljava/io/File;)I",
|
intercept(t, fsClass, gbaMethodName, "(Ljava/io/File;)I",
|
||||||
@ -1867,6 +1885,7 @@ interceptFileOperations(Thread* t)
|
|||||||
intercept(t, fsClass, "getLength", "(Ljava/io/File;)J",
|
intercept(t, fsClass, "getLength", "(Ljava/io/File;)J",
|
||||||
voidPointer(getFileLength));
|
voidPointer(getFileLength));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
intercept(t, type(t, Machine::ClassLoaderType), "loadLibrary",
|
intercept(t, type(t, Machine::ClassLoaderType), "loadLibrary",
|
||||||
"(Ljava/lang/Class;Ljava/lang/String;Z)V",
|
"(Ljava/lang/Class;Ljava/lang/String;Z)V",
|
||||||
|
Loading…
Reference in New Issue
Block a user