├── .github
├── FUNDING.yml
├── dependabot.yml
└── workflows
│ ├── [A] build and test, release if requested.yml
│ └── [A] update documentation.yml
├── .gitignore
├── LICENSE
├── README.md
├── docs
├── _config.yml
├── _layouts
│ └── default.html
├── assets
│ ├── css
│ │ └── style.scss
│ └── fonts
│ │ ├── CooperBlackStd.eot
│ │ ├── CooperBlackStd.ttf
│ │ ├── CooperBlackStd.woff
│ │ └── CooperBlackStd.woff2
├── favicon.png
├── index.md
└── logo.png
├── java-hook
├── bin
│ ├── io
│ │ └── github
│ │ │ └── toolfactory
│ │ │ └── jvm
│ │ │ └── function
│ │ │ └── catalog
│ │ │ └── ThrowExceptionFunction$ForJava7.class
│ ├── java
│ │ └── lang
│ │ │ ├── ConsulterRetrieverForJDK9.class
│ │ │ └── reflect
│ │ │ └── AccessibleSetterInvokerForJDK9.class
│ └── jdk
│ │ └── internal
│ │ └── loader
│ │ ├── BuiltinClassLoader.class
│ │ ├── ClassLoaderDelegateForJDK9.class
│ │ └── URLClassPath.class
├── compileExternalClasses.cmd
├── compileExternalClasses.sh
├── pom.xml
└── src
│ └── main
│ └── java
│ ├── java
│ └── lang
│ │ ├── ConsulterRetrieverForJDK9.java
│ │ └── reflect
│ │ └── AccessibleSetterInvokerForJDK9.java
│ └── jdk
│ └── internal
│ └── loader
│ └── ClassLoaderDelegateForJDK9.java
├── java
├── pom.xml
├── sa-pom.xml
└── src
│ ├── main
│ ├── java
│ │ ├── io
│ │ │ └── github
│ │ │ │ └── toolfactory
│ │ │ │ └── jvm
│ │ │ │ ├── DefaultDriver.java
│ │ │ │ ├── Driver.java
│ │ │ │ ├── DriverAbst.java
│ │ │ │ ├── DynamicDriver.java
│ │ │ │ ├── HybridDriver.java
│ │ │ │ ├── Info.java
│ │ │ │ ├── InfoImpl.java
│ │ │ │ ├── NativeDriver.java
│ │ │ │ ├── function
│ │ │ │ ├── InitializeException.java
│ │ │ │ ├── catalog
│ │ │ │ │ ├── AllocateInstanceFunction.java
│ │ │ │ │ ├── BuiltinClassLoaderClassSupplier.java
│ │ │ │ │ ├── ClassLoaderDelegateClassSupplier.java
│ │ │ │ │ ├── ConstructorInvokeFunction.java
│ │ │ │ │ ├── ConsulterSupplier.java
│ │ │ │ │ ├── ConsulterSupplyFunction.java
│ │ │ │ │ ├── ConvertToBuiltinClassLoaderFunction.java
│ │ │ │ │ ├── DeepConsulterSupplyFunction.java
│ │ │ │ │ ├── DefineHookClassFunction.java
│ │ │ │ │ ├── GetClassByNameFunction.java
│ │ │ │ │ ├── GetDeclaredConstructorsFunction.java
│ │ │ │ │ ├── GetDeclaredFieldFunction.java
│ │ │ │ │ ├── GetDeclaredFieldsFunction.java
│ │ │ │ │ ├── GetDeclaredMethodFunction.java
│ │ │ │ │ ├── GetDeclaredMethodsFunction.java
│ │ │ │ │ ├── GetFieldValueFunction.java
│ │ │ │ │ ├── GetLoadedClassesRetrieverFunction.java
│ │ │ │ │ ├── GetLoadedPackagesFunction.java
│ │ │ │ │ ├── GetPackageFunction.java
│ │ │ │ │ ├── GetResourcesFunction.java
│ │ │ │ │ ├── MethodInvokeFunction.java
│ │ │ │ │ ├── PrivateLookupInMethodHandleSupplier.java
│ │ │ │ │ ├── SetAccessibleFunction.java
│ │ │ │ │ ├── SetFieldValueFunction.java
│ │ │ │ │ ├── StopThreadFunction.java
│ │ │ │ │ ├── ThrowExceptionFunction.java
│ │ │ │ │ ├── UnsafeSupplier.java
│ │ │ │ │ └── UnsafeWrapper.java
│ │ │ │ └── template
│ │ │ │ │ ├── BiFunction.java
│ │ │ │ │ ├── Consumer.java
│ │ │ │ │ ├── Function.java
│ │ │ │ │ ├── Supplier.java
│ │ │ │ │ ├── ThrowingBiConsumer.java
│ │ │ │ │ ├── ThrowingBiFunction.java
│ │ │ │ │ ├── ThrowingFunction.java
│ │ │ │ │ ├── ThrowingQuadFunction.java
│ │ │ │ │ ├── ThrowingTriFunction.java
│ │ │ │ │ └── TriConsumer.java
│ │ │ │ └── util
│ │ │ │ ├── BufferHandler.java
│ │ │ │ ├── Classes.java
│ │ │ │ ├── CleanableSupplier.java
│ │ │ │ ├── JavaClass.java
│ │ │ │ ├── ObjectProvider.java
│ │ │ │ ├── Properties.java
│ │ │ │ ├── Resources.java
│ │ │ │ ├── Streams.java
│ │ │ │ ├── Strings.java
│ │ │ │ ├── ThrowingBiConsumerAdapter.java
│ │ │ │ └── ThrowingFunctionAdapter.java
│ │ └── module-info.java
│ └── resources
│ │ └── jvm-driver.properties
│ └── test
│ ├── java
│ └── io
│ │ └── github
│ │ └── toolfactory
│ │ ├── jvm
│ │ └── test
│ │ │ ├── AllTestsSuite.java
│ │ │ ├── BaseTest.java
│ │ │ ├── DefaultDriverTest.java
│ │ │ ├── DynamicDriverTest.java
│ │ │ ├── HybridDriverTest.java
│ │ │ └── NativeDriverTest.java
│ │ └── util
│ │ └── Reflection.java
│ └── resources
│ └── jvm-driver.properties
├── launcher
└── eclipse
│ ├── ToolFactory JVM Driver - Debug attacher.launch
│ ├── ToolFactory JVM Driver - build and test with REMOTE DEBUG.launch
│ ├── ToolFactory JVM Driver - clean package install.launch
│ ├── ToolFactory JVM Driver - parent - clean package install.launch
│ └── ToolFactory JVM Driver - test.launch
└── pom.xml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: https://www.paypal.com/donate/?cmd=_donations&business=EY4TMTW8SWDAC&item_name=Support+maintenance+and+improvement+of+ToolFactory+JVM+Driver¤cy_code=EUR&source=url
2 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "maven"
4 | directory: "/"
5 | schedule:
6 | interval: "monthly"
7 | time: "02:00"
8 | - package-ecosystem: "github-actions"
9 | directory: "/"
10 | schedule:
11 | interval: "monthly"
12 | time: "03:00"
13 |
--------------------------------------------------------------------------------
/.github/workflows/[A] update documentation.yml:
--------------------------------------------------------------------------------
1 | # This file is part of ToolFactory JVM driver.
2 | #
3 | # Hosted at: https://github.com/toolfactory/jvm-driver
4 | #
5 | # - -
6 | #
7 | # The MIT License (MIT)
8 | #
9 | # Copyright (c) 2021 Luke Hutchison, Roberto Gentili
10 | #
11 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
12 | # documentation files (the "Software"), to deal in the Software without restriction, including without
13 | # limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 | # the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
15 | # conditions:
16 | #
17 | # The above copyright notice and this permission notice shall be included in all copies or substantial
18 | # portions of the Software.
19 | #
20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
21 | # LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
22 | # EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
24 | # OR OTHER DEALINGS IN THE SOFTWARE.
25 | #
26 | name: Update index page
27 |
28 | on:
29 | push:
30 | branches:
31 | - main
32 | paths:
33 | - "**README.md"
34 |
35 | jobs:
36 | update-index-page:
37 | runs-on: ubuntu-latest
38 | name: Update index page
39 | steps:
40 | - uses: actions/checkout@master
41 | - name: Overwrite the index.md
42 | run: |
43 | git config user.name "${{ github.event.head_commit.committer.name }}"
44 | git config user.email "${{ github.event.head_commit.committer.email }}"
45 | git pull origin ${{github.ref}}
46 | cp "./README.md" "./docs/index.md"
47 | git add .
48 | git commit -am "Update" --allow-empty
49 | git push
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Log file
2 | *.log
3 |
4 | # BlueJ files
5 | *.ctxt
6 |
7 | # Mobile Tools for Java (J2ME)
8 | .mtj.tmp/
9 |
10 | # Package Files #
11 | *.jar
12 | *.war
13 | *.nar
14 | *.ear
15 | *.tar.gz
16 | *.rar
17 |
18 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
19 | hs_err_pid*
20 |
21 | /.project
22 | /.settings
23 | /.classpath
24 | /target/
25 |
26 | /java/.project
27 | /java/.settings
28 | /java/.classpath
29 | /java/target/
30 |
31 | /java-hook/.project
32 | /java-hook/.settings
33 | /java-hook/.classpath
34 | /java-hook/target/
35 |
36 | /native/.project
37 | /native/.settings
38 | /native/.classpath
39 | /native/target/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Luke Hutchison, Roberto Gentili
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
2 | title: ToolFactory JVM driver
3 | google_analytics: UA-154852845-4
4 | show_downloads: false
--------------------------------------------------------------------------------
/docs/_layouts/default.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {% if site.google_analytics %}
6 |
7 |
13 | {% endif %}
14 |
15 |
16 | {% seo %}
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
36 |
37 |
38 | {{ content }}
39 |
40 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/docs/assets/css/style.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | @import "{{ site.theme }}";
5 | .page-header {
6 | background-image: linear-gradient(120deg, #183153, #158fcc);
7 | }
8 |
9 | h1.project-name {
10 | font-family: 'Cooper Std';
11 | font-size: 3.25rem;
12 | line-height: 1.00em;
13 | }
14 |
15 | @font-face {
16 | font-family: 'Cooper Std';
17 | src: url('CooperBlackStd.eot');
18 | src: local('Cooper Std Black'), local('CooperBlackStd'),
19 | url('./../fonts/CooperBlackStd.eot?#iefix') format('embedded-opentype'),
20 | url('./../fonts/CooperBlackStd.woff2') format('woff2'),
21 | url('./../fonts/CooperBlackStd.woff') format('woff'),
22 | url('./../fonts/CooperBlackStd.ttf') format('truetype');
23 | font-weight: 900;
24 | font-style: normal;
25 | font-display: swap;
26 | }
27 |
28 | .main-content {
29 | h1 {
30 | color: #158fcc;
31 | }
32 | h2 {
33 | color: #158fcc;
34 | }
35 | h3 {
36 | color: #158fcc;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/docs/assets/fonts/CooperBlackStd.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/docs/assets/fonts/CooperBlackStd.eot
--------------------------------------------------------------------------------
/docs/assets/fonts/CooperBlackStd.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/docs/assets/fonts/CooperBlackStd.ttf
--------------------------------------------------------------------------------
/docs/assets/fonts/CooperBlackStd.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/docs/assets/fonts/CooperBlackStd.woff
--------------------------------------------------------------------------------
/docs/assets/fonts/CooperBlackStd.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/docs/assets/fonts/CooperBlackStd.woff2
--------------------------------------------------------------------------------
/docs/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/docs/favicon.png
--------------------------------------------------------------------------------
/docs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/docs/logo.png
--------------------------------------------------------------------------------
/java-hook/bin/io/github/toolfactory/jvm/function/catalog/ThrowExceptionFunction$ForJava7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/java-hook/bin/io/github/toolfactory/jvm/function/catalog/ThrowExceptionFunction$ForJava7.class
--------------------------------------------------------------------------------
/java-hook/bin/java/lang/ConsulterRetrieverForJDK9.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/java-hook/bin/java/lang/ConsulterRetrieverForJDK9.class
--------------------------------------------------------------------------------
/java-hook/bin/java/lang/reflect/AccessibleSetterInvokerForJDK9.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/java-hook/bin/java/lang/reflect/AccessibleSetterInvokerForJDK9.class
--------------------------------------------------------------------------------
/java-hook/bin/jdk/internal/loader/BuiltinClassLoader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/java-hook/bin/jdk/internal/loader/BuiltinClassLoader.class
--------------------------------------------------------------------------------
/java-hook/bin/jdk/internal/loader/ClassLoaderDelegateForJDK9.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/java-hook/bin/jdk/internal/loader/ClassLoaderDelegateForJDK9.class
--------------------------------------------------------------------------------
/java-hook/bin/jdk/internal/loader/URLClassPath.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toolfactory/jvm-driver/a346bf6798d32b8e7ad765707c765cc86c8c7aff/java-hook/bin/jdk/internal/loader/URLClassPath.class
--------------------------------------------------------------------------------
/java-hook/compileExternalClasses.cmd:
--------------------------------------------------------------------------------
1 | :: This file is part of ToolFactory JVM driver.
2 | ::
3 | :: Hosted at: https://github.com/toolfactory/jvm-driver
4 | ::
5 | :: - -
6 | ::
7 | :: The MIT License (MIT)
8 | ::
9 | :: Copyright (c) 2021 Luke Hutchison, Roberto Gentili
10 | ::
11 | :: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
12 | :: documentation files (the "Software"), to deal in the Software without restriction, including without
13 | :: limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 | :: the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
15 | :: conditions:
16 | ::
17 | :: The above copyright notice and this permission notice shall be included in all copies or substantial
18 | :: portions of the Software.
19 | ::
20 | :: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
21 | :: LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
22 | :: EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 | :: AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
24 | :: OR OTHER DEALINGS IN THE SOFTWARE.
25 | ::
26 | @echo off
27 | call "%1/bin/javac.exe" -cp "%2;%3;" --release 9 "%4/jdk/internal/loader/ClassLoaderDelegateForJDK9.java" -d "%5"
28 | call "%1/bin/javac.exe" -cp "%2;%3;" --release 8 "%4/java/lang/reflect/AccessibleSetterInvokerForJDK9.java" -d "%5"
29 | call "%1/bin/javac.exe" -cp "%2;%3;" --release 8 "%4/java/lang/ConsulterRetrieverForJDK9.java" -d "%5"
30 |
--------------------------------------------------------------------------------
/java-hook/compileExternalClasses.sh:
--------------------------------------------------------------------------------
1 | # This file is part of ToolFactory JVM driver.
2 | #
3 | # Hosted at: https://github.com/toolfactory/jvm-driver
4 | #
5 | # - -
6 | #
7 | # The MIT License (MIT)
8 | #
9 | # Copyright (c) 2021 Luke Hutchison, Roberto Gentili
10 | #
11 | # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
12 | # documentation files (the "Software"), to deal in the Software without restriction, including without
13 | # limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 | # the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
15 | # conditions:
16 | #
17 | # The above copyright notice and this permission notice shall be included in all copies or substantial
18 | # portions of the Software.
19 | #
20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
21 | # LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
22 | # EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
24 | # OR OTHER DEALINGS IN THE SOFTWARE.
25 | #
26 | #!bin/bash/
27 |
28 | $1/bin/javac -cp "$2:$3:" --release 9 "$4/jdk/internal/loader/ClassLoaderDelegateForJDK9.java" -d "$5"
29 | $1/bin/javac -cp "$2:$3:" --release 8 "$4/java/lang/reflect/AccessibleSetterInvokerForJDK9.java" -d "$5"
30 | $1/bin/javac -cp "$2:$3:" --release 8 "$4/java/lang/ConsulterRetrieverForJDK9.java" -d "$5"
31 |
--------------------------------------------------------------------------------
/java-hook/pom.xml:
--------------------------------------------------------------------------------
1 |
27 |
28 | 4.0.0
29 |
30 |
31 | io.github.toolfactory
32 | jvm-driver-parent
33 | ${revision}
34 |
35 |
36 | jvm-driver-hook
37 |
38 | pom
39 |
40 |
41 | UTF-8
42 | UTF-8
43 | ${project_jdk_version}
44 | ${project_jdk_version}
45 | 3.0.0
46 |
47 |
48 |
49 |
50 |
51 | org.codehaus.mojo
52 | exec-maven-plugin
53 | ${exec-maven-plugin.version}
54 |
55 |
56 | compile
57 | compile external classes
58 |
59 | exec
60 |
61 |
62 | ${project.basedir}/compileExternalClasses.${org.codehaus.mojo.exec-maven-plugin.exec-extension}
63 |
64 | ${java.home}
65 | ${project.basedir}/bin
66 | ${project.basedir}/../java/target/classes
67 | ${project.basedir}/src/main/java
68 | ${project.basedir}/bin
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | windows-profile
80 |
81 |
82 | Windows
83 |
84 |
85 |
86 | cmd
87 |
88 |
89 |
90 | unix-profile
91 |
92 |
93 | unix
94 | Linux
95 |
96 |
97 |
98 | sh
99 |
100 |
101 |
102 | mac-profile
103 |
104 |
105 | mac
106 |
107 |
108 |
109 | sh
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/java-hook/src/main/java/java/lang/ConsulterRetrieverForJDK9.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ToolFactory JVM driver.
3 | *
4 | * Hosted at: https://github.com/toolfactory/jvm-driver
5 | *
6 | * --
7 | *
8 | * The MIT License (MIT)
9 | *
10 | * Copyright (c) 2021 Luke Hutchison, Roberto Gentili
11 | *
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13 | * documentation files (the "Software"), to deal in the Software without restriction, including without
14 | * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15 | * the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
16 | * conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all copies or substantial
19 | * portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 | * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
23 | * EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
25 | * OR OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package java.lang;
28 |
29 | import java.lang.invoke.MethodHandle;
30 | import java.lang.invoke.MethodHandles;
31 | import java.lang.invoke.MethodHandles.Lookup;
32 | import java.lang.invoke.MethodType;
33 | import java.util.function.Function;
34 |
35 | @SuppressWarnings("unchecked")
36 | public class ConsulterRetrieverForJDK9 implements Function, MethodHandles.Lookup> {
37 | private static MethodHandle consulterRetriever;
38 | public final static MethodHandles.Lookup mainConsulter;
39 |
40 | static {
41 | mainConsulter = MethodHandles.lookup();
42 | }
43 |
44 | @Override
45 | public Lookup apply(Class> cls) {
46 | try {
47 | return (MethodHandles.Lookup)consulterRetriever.invokeWithArguments(cls, mainConsulter);
48 | } catch (Throwable exc) {
49 | return throwExceptionWithReturn(exc);
50 | }
51 | }
52 |
53 | private static T throwExceptionWithReturn(Throwable exc) {
54 | throwException(exc);
55 | return null;
56 | }
57 |
58 | private static void throwException(Throwable exc) throws E{
59 | throw (E)exc;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/java-hook/src/main/java/java/lang/reflect/AccessibleSetterInvokerForJDK9.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ToolFactory JVM driver.
3 | *
4 | * Hosted at: https://github.com/toolfactory/jvm-driver
5 | *
6 | * --
7 | *
8 | * The MIT License (MIT)
9 | *
10 | * Copyright (c) 2021 Luke Hutchison, Roberto Gentili
11 | *
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13 | * documentation files (the "Software"), to deal in the Software without restriction, including without
14 | * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15 | * the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
16 | * conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all copies or substantial
19 | * portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 | * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
23 | * EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
25 | * OR OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package java.lang.reflect;
28 |
29 | import java.lang.reflect.AccessibleObject;
30 | import java.lang.reflect.Method;
31 | import java.lang.invoke.MethodHandle;
32 | import java.lang.invoke.MethodHandles;
33 | import java.util.function.BiConsumer;
34 |
35 | @SuppressWarnings("unchecked")
36 | public class AccessibleSetterInvokerForJDK9 implements BiConsumer {
37 | private static MethodHandle accessibleSetterMethodHandle;
38 | // Lazy initialized by io.github.toolfactory.jvm.function.catalog.SetAccessibleFunction
39 | public static MethodHandles.Lookup mainConsulter;
40 |
41 | static {
42 | try {
43 | Method accessibleSetterMethod = AccessibleObject.class.getDeclaredMethod("setAccessible0", boolean.class);
44 | accessibleSetterMethodHandle = mainConsulter.unreflect(accessibleSetterMethod);
45 | } catch (Throwable exc) {
46 | throwException(exc);
47 | }
48 |
49 | }
50 |
51 | private static void throwException(Throwable exc) throws E{
52 | throw (E)exc;
53 | }
54 |
55 | @Override
56 | public void accept(AccessibleObject accessibleObject, Boolean flag) {
57 | try {
58 | accessibleSetterMethodHandle.invokeWithArguments(accessibleObject, flag);
59 | } catch (Throwable exc) {
60 | throwException(exc);
61 | }
62 | }
63 |
64 | }
--------------------------------------------------------------------------------
/java-hook/src/main/java/jdk/internal/loader/ClassLoaderDelegateForJDK9.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ToolFactory JVM driver.
3 | *
4 | * Hosted at: https://github.com/toolfactory/jvm-driver
5 | *
6 | * --
7 | *
8 | * The MIT License (MIT)
9 | *
10 | * Copyright (c) 2021 Luke Hutchison, Roberto Gentili
11 | *
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13 | * documentation files (the "Software"), to deal in the Software without restriction, including without
14 | * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15 | * the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
16 | * conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all copies or substantial
19 | * portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 | * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
23 | * EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
25 | * OR OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package jdk.internal.loader;
28 |
29 | import java.io.IOException;
30 | import java.io.InputStream;
31 | import java.net.URL;
32 | import java.util.Enumeration;
33 | import java.lang.invoke.MethodHandle;
34 |
35 |
36 | public class ClassLoaderDelegateForJDK9 extends BuiltinClassLoader {
37 |
38 | private ClassLoader classLoader;
39 | private MethodHandle loadClassMethod;
40 |
41 | static {
42 | ClassLoader.registerAsParallelCapable();
43 | }
44 |
45 | ClassLoaderDelegateForJDK9(BuiltinClassLoader parent, ClassLoader classLoader, MethodHandle loadClassMethodHandle) {
46 | super("ClassLoaderDelegateOf" + classLoader.toString(), parent, null);
47 | this.classLoader = classLoader;
48 | this.loadClassMethod = loadClassMethodHandle;
49 | }
50 |
51 | @Override
52 | protected Class> loadClassOrNull(String className, boolean resolve) {
53 | try {
54 | return (Class>)loadClassMethod.invokeWithArguments(classLoader, className, resolve);
55 | } catch (Throwable exc) {
56 | exc.printStackTrace();
57 | return null;
58 | }
59 | }
60 |
61 | @Override
62 | protected Class> loadClass(String className, boolean resolve) throws ClassNotFoundException {
63 | try {
64 | return (Class>)loadClassMethod.invokeWithArguments(classLoader, className, resolve);
65 | } catch (ClassNotFoundException exc) {
66 | throw exc;
67 | } catch (Throwable exc) {
68 | throw new ClassNotFoundException(className, exc);
69 | }
70 | }
71 |
72 | @Override
73 | public URL getResource(String name) {
74 | return classLoader.getResource(name);
75 | }
76 |
77 | @Override
78 | public Enumeration getResources(String name) throws IOException {
79 | return classLoader.getResources(name);
80 | }
81 |
82 | @Override
83 | public InputStream getResourceAsStream(String name) {
84 | return classLoader.getResourceAsStream(name);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/java/src/main/java/io/github/toolfactory/jvm/DefaultDriver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ToolFactory JVM driver.
3 | *
4 | * Hosted at: https://github.com/toolfactory/jvm-driver
5 | *
6 | * --
7 | *
8 | * The MIT License (MIT)
9 | *
10 | * Copyright (c) 2021 Luke Hutchison, Roberto Gentili
11 | *
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13 | * documentation files (the "Software"), to deal in the Software without restriction, including without
14 | * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15 | * the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
16 | * conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all copies or substantial
19 | * portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 | * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
23 | * EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
25 | * OR OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package io.github.toolfactory.jvm;
28 |
29 |
30 | import io.github.toolfactory.jvm.function.catalog.AllocateInstanceFunction;
31 | import io.github.toolfactory.jvm.function.catalog.BuiltinClassLoaderClassSupplier;
32 | import io.github.toolfactory.jvm.function.catalog.ClassLoaderDelegateClassSupplier;
33 | import io.github.toolfactory.jvm.function.catalog.ConstructorInvokeFunction;
34 | import io.github.toolfactory.jvm.function.catalog.ConsulterSupplyFunction;
35 | import io.github.toolfactory.jvm.function.catalog.ConvertToBuiltinClassLoaderFunction;
36 | import io.github.toolfactory.jvm.function.catalog.DeepConsulterSupplyFunction;
37 | import io.github.toolfactory.jvm.function.catalog.DefineHookClassFunction;
38 | import io.github.toolfactory.jvm.function.catalog.GetClassByNameFunction;
39 | import io.github.toolfactory.jvm.function.catalog.GetDeclaredConstructorsFunction;
40 | import io.github.toolfactory.jvm.function.catalog.GetDeclaredFieldsFunction;
41 | import io.github.toolfactory.jvm.function.catalog.GetDeclaredMethodsFunction;
42 | import io.github.toolfactory.jvm.function.catalog.GetFieldValueFunction;
43 | import io.github.toolfactory.jvm.function.catalog.GetLoadedClassesRetrieverFunction;
44 | import io.github.toolfactory.jvm.function.catalog.GetLoadedPackagesFunction;
45 | import io.github.toolfactory.jvm.function.catalog.GetPackageFunction;
46 | import io.github.toolfactory.jvm.function.catalog.GetResourcesFunction;
47 | import io.github.toolfactory.jvm.function.catalog.MethodInvokeFunction;
48 | import io.github.toolfactory.jvm.function.catalog.SetAccessibleFunction;
49 | import io.github.toolfactory.jvm.function.catalog.SetFieldValueFunction;
50 | import io.github.toolfactory.jvm.function.catalog.StopThreadFunction;
51 | import io.github.toolfactory.jvm.function.catalog.ThrowExceptionFunction;
52 |
53 |
54 | public class DefaultDriver extends DriverAbst {
55 |
56 | @Override
57 | protected Class extends ThrowExceptionFunction> getThrowExceptionFunctionClass() {
58 | return ThrowExceptionFunction.class;
59 | }
60 |
61 |
62 | @Override
63 | protected Class extends AllocateInstanceFunction> getAllocateInstanceFunctionClass() {
64 | return AllocateInstanceFunction.class;
65 | }
66 |
67 |
68 | @Override
69 | protected Class extends GetFieldValueFunction> getGetFieldValueFunctionClass() {
70 | return GetFieldValueFunction.class;
71 | }
72 |
73 |
74 | @Override
75 | protected Class extends SetFieldValueFunction> getSetFieldValueFunctionClass() {
76 | return SetFieldValueFunction.class;
77 | }
78 |
79 |
80 | @Override
81 | protected Class extends DefineHookClassFunction> getDefineHookClassFunctionClass() {
82 | return DefineHookClassFunction.class;
83 | }
84 |
85 |
86 | @Override
87 | protected Class extends ConsulterSupplyFunction> getConsulterSupplyFunctionClass() {
88 | return ConsulterSupplyFunction.class;
89 | }
90 |
91 |
92 | @Override
93 | protected Class extends GetDeclaredFieldsFunction> getGetDeclaredFieldsFunctionClass() {
94 | return GetDeclaredFieldsFunction.class;
95 | }
96 |
97 |
98 | @Override
99 | protected Class extends GetDeclaredMethodsFunction> getGetDeclaredMethodsFunctionClass() {
100 | return GetDeclaredMethodsFunction.class;
101 | }
102 |
103 |
104 | @Override
105 | protected Class extends GetDeclaredConstructorsFunction> getGetDeclaredConstructorsFunctionClass() {
106 | return GetDeclaredConstructorsFunction.class;
107 | }
108 |
109 |
110 | @Override
111 | protected Class extends SetAccessibleFunction> getSetAccessibleFunctionClass() {
112 | return SetAccessibleFunction.class;
113 | }
114 |
115 |
116 | @Override
117 | protected Class extends ConstructorInvokeFunction> getConstructorInvokeFunctionClass() {
118 | return ConstructorInvokeFunction.class;
119 | }
120 |
121 |
122 | @Override
123 | protected Class extends MethodInvokeFunction> getMethodInvokeFunctionClass() {
124 | return MethodInvokeFunction.class;
125 | }
126 |
127 |
128 | @Override
129 | protected Class extends GetPackageFunction> getGetPackageFunctionClass() {
130 | return GetPackageFunction.class;
131 | }
132 |
133 |
134 | @Override
135 | protected Class extends GetResourcesFunction> getGetResourcesFunctionClass() {
136 | return GetResourcesFunction.class;
137 | }
138 |
139 |
140 | @Override
141 | protected Class extends GetClassByNameFunction> getGetClassByNameFunctionClass() {
142 | return GetClassByNameFunction.class;
143 | }
144 |
145 |
146 | @Override
147 | protected Class extends BuiltinClassLoaderClassSupplier> getBuiltinClassLoaderClassSupplierClass() {
148 | return BuiltinClassLoaderClassSupplier.class;
149 | }
150 |
151 |
152 | @Override
153 | protected Class extends ClassLoaderDelegateClassSupplier> getClassLoaderDelegateClassSupplierClass() {
154 | return ClassLoaderDelegateClassSupplier.class;
155 | }
156 |
157 |
158 | @Override
159 | protected Class extends DeepConsulterSupplyFunction> getDeepConsulterSupplyFunctionClass() {
160 | return DeepConsulterSupplyFunction.class;
161 | }
162 |
163 |
164 | @Override
165 | protected Class extends GetLoadedClassesRetrieverFunction> getGetLoadedClassesRetrieverFunctionClass() {
166 | return GetLoadedClassesRetrieverFunction.class;
167 | }
168 |
169 |
170 | @Override
171 | protected Class extends GetLoadedPackagesFunction> getGetLoadedPackagesFunctionClass() {
172 | return GetLoadedPackagesFunction.class;
173 | }
174 |
175 |
176 | @Override
177 | protected Class extends ConvertToBuiltinClassLoaderFunction> getConvertToBuiltinClassLoaderFunctionClass() {
178 | return ConvertToBuiltinClassLoaderFunction.class;
179 | }
180 |
181 |
182 | @Override
183 | protected Class extends StopThreadFunction> getStopThreadFunctionClass() {
184 | return StopThreadFunction.class;
185 | }
186 |
187 |
188 | }
189 |
--------------------------------------------------------------------------------
/java/src/main/java/io/github/toolfactory/jvm/DynamicDriver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of ToolFactory JVM driver.
3 | *
4 | * Hosted at: https://github.com/toolfactory/jvm-driver
5 | *
6 | * --
7 | *
8 | * The MIT License (MIT)
9 | *
10 | * Copyright (c) 2021 Luke Hutchison, Roberto Gentili
11 | *
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13 | * documentation files (the "Software"), to deal in the Software without restriction, including without
14 | * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15 | * the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
16 | * conditions:
17 | *
18 | * The above copyright notice and this permission notice shall be included in all copies or substantial
19 | * portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 | * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
23 | * EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
25 | * OR OTHER DEALINGS IN THE SOFTWARE.
26 | */
27 | package io.github.toolfactory.jvm;
28 |
29 |
30 | import java.util.Map;
31 |
32 | import io.github.toolfactory.jvm.function.catalog.AllocateInstanceFunction;
33 | import io.github.toolfactory.jvm.function.catalog.ConsulterSupplier;
34 | import io.github.toolfactory.jvm.function.catalog.GetFieldValueFunction;
35 | import io.github.toolfactory.jvm.function.catalog.GetLoadedClassesRetrieverFunction;
36 | import io.github.toolfactory.jvm.function.catalog.GetLoadedPackagesFunction;
37 | import io.github.toolfactory.jvm.function.catalog.SetAccessibleFunction;
38 | import io.github.toolfactory.jvm.function.catalog.SetFieldValueFunction;
39 | import io.github.toolfactory.jvm.util.ObjectProvider;
40 | import io.github.toolfactory.jvm.util.ObjectProvider.BuildingException;
41 |
42 |
43 | public class DynamicDriver extends DefaultDriver {
44 |
45 | @Override
46 | protected Map