├── .github
├── dependabot.yml
└── workflows
│ └── maven.yml
├── LICENSE
├── README.md
├── hexeditor.jar
├── hexeditor.png
├── hexeditor2.png
├── hexeditor3.png
├── pom-central.xml
├── pom.xml
└── src
└── main
├── java
└── com
│ └── github
│ └── hexeditor
│ ├── UI$1.java
│ ├── UI.java
│ ├── accent.java
│ ├── binEdit.java
│ ├── binPanel.java
│ ├── edObj.java
│ ├── filterRW.java
│ ├── findT.java
│ ├── jEP.java
│ ├── math.java
│ ├── saveT.java
│ └── slaveT.java
└── resources
└── com
└── github
└── hexeditor
├── ReadMeEn.htm
├── ReadMeFr.htm
└── shortKey.htm
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "maven" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "weekly"
12 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Java CI
10 |
11 | on:
12 | push:
13 | branches: [ "master" ]
14 | pull_request:
15 | branches: [ "master" ]
16 |
17 | jobs:
18 | build:
19 |
20 | runs-on: ubuntu-latest
21 |
22 | steps:
23 | - uses: actions/checkout@v3
24 | - name: Set up JDK 11
25 | uses: actions/setup-java@v3
26 | with:
27 | java-version: '11'
28 | distribution: 'temurin'
29 | cache: maven
30 | - name: Build with Maven
31 | run: mvn -B package --file pom.xml
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | hexeditor
2 | =========
3 |
4 | [](https://central.sonatype.com/artifact/com.github.javadev/hexeditor/1.0)
5 | [](https://github.com/javadev/hexeditor/actions/workflows/maven.yml)
6 |
7 | The binary file editor.
8 |
9 | [](https://github.com/javadev/hexeditor/)
10 |
11 | [](https://github.com/javadev/hexeditor/)
12 |
13 | [](https://github.com/javadev/hexeditor/)
14 |
--------------------------------------------------------------------------------
/hexeditor.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javadev/hexeditor/e8eaaca4cb584ceedffbe352fa595c4d6f7c5f4f/hexeditor.jar
--------------------------------------------------------------------------------
/hexeditor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javadev/hexeditor/e8eaaca4cb584ceedffbe352fa595c4d6f7c5f4f/hexeditor.png
--------------------------------------------------------------------------------
/hexeditor2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javadev/hexeditor/e8eaaca4cb584ceedffbe352fa595c4d6f7c5f4f/hexeditor2.png
--------------------------------------------------------------------------------
/hexeditor3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javadev/hexeditor/e8eaaca4cb584ceedffbe352fa595c4d6f7c5f4f/hexeditor3.png
--------------------------------------------------------------------------------
/pom-central.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.github.javadev
6 | hexeditor
7 | jar
8 | 1.0
9 | Binary file editor
10 | The binary file editor
11 | https://github.com/javadev/hexeditor
12 |
13 |
14 |
15 | Valentyn Kolesnikov
16 |
17 |
18 |
19 |
20 |
21 | Apache License, Version 2.0
22 | http://www.apache.org/licenses/LICENSE-2.0.txt
23 | repo
24 |
25 |
26 |
27 |
28 | scm:git:git://github.com/javadev/hexeditor.git
29 | scm:git:git://github.com/javadev/hexeditor.git
30 | https://github.com/javadev/hexeditor
31 |
32 |
33 |
34 | UTF-8
35 |
36 |
37 |
38 | GitHub Actions
39 | https://github.com/javadev/hexeditor/actions
40 |
41 |
42 |
43 | GitHub Issues
44 | https://github.com/javadev/hexeditor/issues
45 |
46 |
47 |
48 |
49 |
50 | org.apache.maven.plugins
51 | maven-compiler-plugin
52 | 3.11.0
53 |
54 | 1.8
55 | 1.8
56 | UTF-8
57 |
58 |
59 |
60 | org.apache.maven.plugins
61 | maven-jar-plugin
62 | 2.4
63 |
64 |
65 |
66 | com.github.hexeditor.UI
67 |
68 |
69 |
70 |
71 |
72 | org.apache.maven.plugins
73 | maven-source-plugin
74 |
75 |
76 | attach-sources
77 |
78 | jar
79 |
80 |
81 |
82 |
83 |
84 | org.apache.maven.plugins
85 | maven-javadoc-plugin
86 | 2.10.1
87 |
88 |
89 | attach-sources
90 |
91 | jar
92 |
93 |
94 |
95 |
96 |
97 | org.apache.maven.plugins
98 | maven-gpg-plugin
99 | 1.6
100 |
101 |
102 | sign-artifacts
103 | verify
104 |
105 | sign
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.github
6 | hexeditor
7 | jar
8 | 1.0-SNAPSHOT
9 | Binary file editor
10 | The binary file editor
11 | https://github.com/javadev/hexeditor
12 |
13 |
14 |
15 | Valentyn Kolesnikov
16 |
17 |
18 |
19 |
20 |
21 | Apache License
22 | http://www.apache.org/licenses/LICENSE-2.0.html
23 | repo
24 |
25 |
26 |
27 |
28 | scm:git:git://github.com/javadev/hexeditor.git
29 | scm:git:git://github.com/javadev/hexeditor.git
30 | https://github.com/javadev/hexeditor
31 |
32 |
33 |
34 | UTF-8
35 |
36 |
37 |
38 | GitHub Actions
39 | https://github.com/javadev/hexeditor/actions
40 |
41 |
42 |
43 | GitHub Issues
44 | https://github.com/javadev/hexeditor/issues
45 |
46 |
47 |
48 | ${project.artifactId}
49 |
50 |
51 | org.apache.maven.plugins
52 | maven-compiler-plugin
53 | 3.14.0
54 |
55 | 1.8
56 | 1.8
57 | UTF-8
58 |
59 |
60 |
61 | org.apache.maven.plugins
62 | maven-jar-plugin
63 | 3.4.2
64 |
65 |
66 |
67 | com.github.hexeditor.UI
68 |
69 |
70 |
71 |
72 |
73 | org.apache.maven.plugins
74 | maven-shade-plugin
75 | 3.6.0
76 |
77 |
78 | package
79 |
80 | shade
81 |
82 |
83 |
84 |
85 | *:*
86 |
87 | META-INF/maven/**
88 | META-INF/services/**
89 | META-INF/COPYRIGHT.html
90 | META-INF/LICENSE*
91 | META-INF/NOTICE*
92 | META-INF/README.txt
93 | META-INF/DEPENDENCIES*
94 | LICENSE.txt
95 | rhinoDiff.txt
96 | license/**
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | org.apache.maven.plugins
106 | maven-site-plugin
107 | 3.21.0
108 |
109 |
110 |
111 | org.codehaus.mojo
112 | cobertura-maven-plugin
113 | 2.6
114 |
115 |
116 | org.apache.maven.plugins
117 | maven-surefire-report-plugin
118 | 2.3
119 |
120 |
121 | org.apache.maven.plugins
122 | maven-jxr-plugin
123 | 2.1
124 |
125 |
126 | org.apache.maven.plugins
127 | maven-checkstyle-plugin
128 | 2.8
129 |
130 | ${basedir}/checkstyle.xml
131 | true
132 |
133 |
134 |
135 | org.apache.maven.plugins
136 | maven-pmd-plugin
137 |
138 | 1.5
139 |
140 | rulesets/java/basic.xml
141 | rulesets/java/design.xml
142 | rulesets/java/junit.xml
143 | rulesets/java/finalizers.xml
144 | rulesets/java/clone.xml
145 | rulesets/java/unusedcode.xml
146 | rulesets/java/imports.xml
147 | rulesets/java/strings.xml
148 | rulesets/java/braces.xml
149 | rulesets/java/codesize.xml
150 | rulesets/java/coupling.xml
151 | rulesets/java/strictexception.xml
152 |
153 |
154 |
155 |
156 | org.codehaus.mojo
157 | taglist-maven-plugin
158 | 2.0
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/UI$1.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.awt.GraphicsEnvironment;
4 | import java.awt.Insets;
5 | import java.awt.Rectangle;
6 | import java.awt.Toolkit;
7 | import javax.swing.ImageIcon;
8 | import javax.swing.JFrame;
9 |
10 | final class UI$1 implements Runnable {
11 |
12 | private final String[] val$args;
13 |
14 | UI$1(String[] var1) {
15 | this.val$args = var1;
16 | }
17 |
18 | public void run() {
19 | JFrame var1 =
20 | new JFrame(
21 | 1 < this.val$args.length && this.val$args[0].equals("-slave")
22 | ? "hexeditor.jar currently linked to " + this.val$args[1]
23 | : "hexeditor.jar https://github.com/javadev/hexeditor Updated: 2014-07-29",
24 | GraphicsEnvironment.getLocalGraphicsEnvironment()
25 | .getDefaultScreenDevice()
26 | .getDefaultConfiguration());
27 | var1.setIconImage((new ImageIcon(UI.logo)).getImage());
28 | var1.setDefaultCloseOperation(3);
29 | Rectangle var2 = var1.getGraphicsConfiguration().getBounds();
30 | Insets var3 = Toolkit.getDefaultToolkit().getScreenInsets(var1.getGraphicsConfiguration());
31 | int var4 = var2.width - var3.left - var3.right;
32 | int var5 = var2.height - var3.top - var3.bottom;
33 | var4 = 700 < var4 ? 700 : var4;
34 | var5 = 999 < var5 ? var5 : var5;
35 | if (1 < this.val$args.length && this.val$args[0].equals("-slave")) {
36 | var1.setBounds(
37 | var2.x + var2.width - var4,
38 | var2.y + (var2.height + var3.top - var3.bottom - var5) >> 1,
39 | var4,
40 | var5);
41 | } else {
42 | var1.setBounds(
43 | var2.x + (var2.width + var3.left - var3.right - var4) >> 1,
44 | var2.y + (var2.height + var3.top - var3.bottom - var5) >> 1,
45 | var4,
46 | var5);
47 | }
48 |
49 | UI.jRP = var1.getRootPane();
50 | UI.all();
51 | JFrame.setDefaultLookAndFeelDecorated(true);
52 | var1.getContentPane().add(UI.access$000(), "Center");
53 | var1.setVisible(true);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/UI.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.awt.BorderLayout;
4 | import java.io.File;
5 | import java.io.FileOutputStream;
6 | import java.io.PrintStream;
7 | import java.util.Enumeration;
8 | import java.util.Properties;
9 | import javax.swing.JApplet;
10 | import javax.swing.JLabel;
11 | import javax.swing.JPanel;
12 | import javax.swing.JRootPane;
13 | import javax.swing.SwingUtilities;
14 | import javax.swing.UIManager;
15 |
16 | public class UI extends JApplet {
17 |
18 | private static final String link = "https://github.com/javadev/hexeditor";
19 | private static final String appName = "hexeditor.jar";
20 | private static final String version = "2014-07-29";
21 | private static boolean applet = false;
22 | private static JPanel jP = new JPanel(new BorderLayout());
23 | private static Runtime rT = Runtime.getRuntime();
24 | private static String[] arg = null;
25 | static final byte[] logo =
26 | new byte[] {
27 | (byte) 71,
28 | (byte) 73,
29 | (byte) 70,
30 | (byte) 56,
31 | (byte) 57,
32 | (byte) 97,
33 | (byte) 16,
34 | (byte) 0,
35 | (byte) 16,
36 | (byte) 0,
37 | (byte) -128,
38 | (byte) 0,
39 | (byte) 0,
40 | (byte) 0,
41 | (byte) 0,
42 | (byte) 0,
43 | (byte) -1,
44 | (byte) -1,
45 | (byte) -1,
46 | (byte) 33,
47 | (byte) -7,
48 | (byte) 4,
49 | (byte) 1,
50 | (byte) 0,
51 | (byte) 0,
52 | (byte) 1,
53 | (byte) 0,
54 | (byte) 44,
55 | (byte) 0,
56 | (byte) 0,
57 | (byte) 0,
58 | (byte) 0,
59 | (byte) 16,
60 | (byte) 0,
61 | (byte) 16,
62 | (byte) 0,
63 | (byte) 0,
64 | (byte) 2,
65 | (byte) 40,
66 | (byte) -116,
67 | (byte) -113,
68 | (byte) -87,
69 | (byte) -101,
70 | (byte) 0,
71 | (byte) -26,
72 | (byte) 24,
73 | (byte) 124,
74 | (byte) 33,
75 | (byte) 74,
76 | (byte) 107,
77 | (byte) 25,
78 | (byte) -90,
79 | (byte) -102,
80 | (byte) 70,
81 | (byte) 14,
82 | (byte) 77,
83 | (byte) -50,
84 | (byte) -57,
85 | (byte) 109,
86 | (byte) -93,
87 | (byte) -9,
88 | (byte) 100,
89 | (byte) -37,
90 | (byte) 49,
91 | (byte) 34,
92 | (byte) -85,
93 | (byte) -24,
94 | (byte) -94,
95 | (byte) 83,
96 | (byte) 85,
97 | (byte) -54,
98 | (byte) -86,
99 | (byte) 76,
100 | (byte) 87,
101 | (byte) -115,
102 | (byte) -60,
103 | (byte) -9,
104 | (byte) 71,
105 | (byte) 1,
106 | (byte) 0,
107 | (byte) 59
108 | };
109 | public static JRootPane jRP = null;
110 | public static String browse = null;
111 | public static final String htmlBase = null;
112 | public static final String htmlReport = null;
113 | public static final String htmlEnd = null;
114 |
115 | static void all() {
116 | try {
117 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
118 | } catch (Exception var1) {;
119 | }
120 |
121 | jP.add(new binPanel(applet, arg));
122 | }
123 |
124 | public void init() {
125 | applet = true;
126 | jRP = this.getRootPane();
127 | all();
128 | String var1 = this.getParameter("JAVAMINVERSION");
129 | if (System.getProperty("java.specification.version").compareToIgnoreCase(var1) < 0) {
130 | this.getContentPane()
131 | .add(
132 | new JLabel(
133 | "
Java version found: "
134 | + System.getProperty("java.version")
135 | + ", needed: "
136 | + var1),
137 | "Center");
138 | } else {
139 | this.getContentPane().add(jP, "Center");
140 | }
141 | }
142 |
143 | public static void main(String[] var0) {
144 | arg = (String[]) ((String[]) var0.clone());
145 | if (!applet && var0 != null && 0 < var0.length) {
146 | for (int var1 = 0; var1 < var0.length; ++var1) {
147 | if (var0[var1].toLowerCase().equals("-bug")) {
148 | bugReport();
149 | }
150 | }
151 | }
152 |
153 | SwingUtilities.invokeLater(new UI$1(var0));
154 | }
155 |
156 | private static void bugReport() {
157 | try {
158 | System.setErr(
159 | new PrintStream(
160 | new FileOutputStream(
161 | new File(
162 | System.getProperty("user.dir"),
163 | "Hexeditor.jar_BugReport.txt"))));
164 | StringBuffer var1 =
165 | new StringBuffer(
166 | "if you find errors, feel free to send me a mail with a short explaination and this file at: @T \r\n\r\nHexeditor.jar 2014-07-29\r\n");
167 | Properties var2 = System.getProperties();
168 | Enumeration var3 = var2.propertyNames();
169 |
170 | while (var3.hasMoreElements()) {
171 | String var0 = (String) var3.nextElement();
172 | if (" user.name user.home ".indexOf(var0) == -1) {
173 | try {
174 | var1.append(var0 + " " + var2.getProperty(var0) + "\n");
175 | } catch (Exception var5) {
176 | var1.append(var0 + " SECURITY EXCEPTION!\n");
177 | }
178 | }
179 | }
180 |
181 | var1.append("\r\nµP\t" + rT.availableProcessors());
182 | var1.append(
183 | "\r\nMem(MiB), free/total/max: "
184 | + (rT.freeMemory() >> 20)
185 | + "/"
186 | + (rT.totalMemory() >> 20)
187 | + "/"
188 | + (rT.maxMemory() >> 20));
189 | var1.append("\r\n\r\nError messages:");
190 | System.err.println(var1);
191 | } catch (Exception var6) {;
192 | }
193 | }
194 |
195 | static JPanel access$000() {
196 | return jP;
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/accent.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | class accent {
4 |
5 | public static final String[] s =
6 | new String[] {
7 | "@AaÀÁÂÃÄÅàáâãäåĀāĂ㥹ǍǎǞǟǠǡǺǻȀȁȂȃȦȧȺḀḁẚẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặ₳ÅⒶⓐⱥⱯ@Aa",
8 | "BbƀƁƂƃƄƅɃɓḂḃḄḅḆḇℬ␢ⒷⓑBb",
9 | "Cc¢©ÇçĆćĈĉĊċČčƇƈȻȼḈḉ₡₢ℂ℃℄ℭⒸⓒꜾꜿCc",
10 | "DdÐðĎďĐđƉƊƋƌȡɖɗḊḋḌḍḎḏḐḑḒḓ₫₯ⅅⅆ∂ⒹⓓꝩꝺDd",
11 | "EeÈÉÊËèéêëĒēĔĕĖėĘęĚěƎǝȄȅȆȇȨȩḔḕḖḗḘḙḚḛḜḝẸẹẺẻẼẽẾếỀềỂểỄễỆệ₠€ℇ℮ℯℰⅇⒺⓔⱸⱻEe",
12 | "FfƑƒḞḟ₣℉ℱℲ⅍ⒻⓕꜰꝫꝼꟻFf",
13 | "GgĜĝĞğĠġĢģƓǤǥǦǧǴǵɠɡḠḡ₲ℊ⅁ⒼⓖꝽꝾꝿGg",
14 | "HhĤĥĦħȞȟḢḣḤḥḦḧḨḩḪḫẖ₴ℋℌℍℎℏⒽⓗⱧⱨⱵⱶHh",
15 | "IiÌÍÎÏìíîïĨĩĪīĬĭĮįİıƗǏǐȈȉȊȋɨӀḬḭḮḯỈỉỊịℐℑℹⅈⒾⓘꟾIi",
16 | "JjĴĵǰȷɈɉⅉⒿⓙⱼJj",
17 | "KkĶķĸƘƙǨǩḰḱḲḳḴḵ₭KⓀⓚⱩⱪꝀꝁꝂꝃꝄꝅKk",
18 | "Ll£ĹĺĻļĽľĿŀŁłƚȴȽḶḷḸḹḺḻḼḽ₤₶ℒℓ℔⅂⅃ⓁⓛⱠⱡⱢꝆꝇꝈꝉꞀꞁLl",
19 | "MmƜɯḾḿṀṁṂṃ₥ℳⓂⓜⱮꟽꟿMm",
20 | "NnÑñŃńŅņŇňʼnŊŋƝƞǸǹȠȵɲṄṅṆṇṈṉṊṋ₦₪ℕ№ⓃⓝNn",
21 | "OoÒÓÔÕÖØòóôõöøŌōŎŏŐőƆƟƠơǑǒǪǫǬǭǾǿȌȍȎȏȪȫȬȭȮȯȰȱɔɵṌṍṎṏṐṑṒṓỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợℴ∅ⓄⓞⱺꝊꝋꝌꝍOo",
22 | "PpƤƥṔṕṖṗ₧₱℗℘ℙⓅⓟⱣꝐꝑꝒꝓꝔꝕꟼPp",
23 | "QqɊɋℚ℺ⓆⓠꝖꝗꝘꝙQq",
24 | "Rr®ŔŕŖŗŘřȐȑȒȓɌɍṘṙṚṛṜṝṞṟ₨ℛℜℝ℞℟ⓇⓡⱤⱹꝚꝛꞂꞃRr",
25 | "$SsŚśŜŝŞşŠšſȘșȿṠṡṢṣṤṥṦṧṨṩẛẜẝ₷⅀ⓈⓢⱾꜱꞄꞅ$Ss",
26 | "TtŢţŤťŦŧƫƬƭƮȚțȶȾʈṪṫṬṭṮṯṰṱẗ₮₸ⓉⓣⱦꞆꞇTt",
27 | "UuÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųƯưǓǔǕǖǗǘǙǚǛǜȔȕȖȗɄʉṲṳṴṵṶṷṸṹṺṻỤụỦủỨứỪừỬửỮữỰựⓊⓤUu",
28 | "VvƲɅʋʌṼṽṾṿỼỽⓋⓥⱱⱴⱽꝞꝟVv",
29 | "WwŴŵẀẁẂẃẄẅẆẇẈẉẘ₩ⓌⓦⱲⱳWw",
30 | "Xx×ẊẋẌẍⓍⓧXx",
31 | "Yy¥ÝýÿŶŷŸƳƴȲȳɎɏẎẏẙỲỳỴỵỶỷỸỹỾỿ⅄ⓎⓨYy",
32 | "ZzŹźŻżŽžƵƶȤȥɀẐẑẒẓẔẕℤℨⓏⓩⱫⱬⱿꝢꝣZz",
33 | "ÞþꝤꝥꝦꝧ",
34 | "ÆæǢǣǼǽ",
35 | "Œœɶ",
36 | "0⁰⓪⓿0",
37 | "1¹ⁱⅠⅰ①⑰⒈⓵1",
38 | "2²Ⅱⅱ②⑵⒉⓶2",
39 | "3³Ⅲⅲ③⑶⒊⓷3",
40 | "4⁴Ⅳⅳ④⑷⒋⓸4",
41 | "5⁵Ⅴⅴ⑤⑸⒌⓹5",
42 | "6⁶Ⅵⅵ⑥⑹⒍⓺6",
43 | "7⁷Ⅶⅶ⑦⑺⒎⓻7",
44 | "8Ȣȣ⁸Ⅷⅷ⑧⑻⒏⓼8",
45 | "9⁹Ⅸⅸ⑨⑼⒐⓽9",
46 | "ƷƸƹǮǯȜȝʒ",
47 | "ꜸꜹꜺꜻ",
48 | "ƿǷᚹ",
49 | "DŽDždžDZDzdz",
50 | "LJLjlj",
51 | "NJNjnj",
52 | "℡☎☏✆",
53 | "ɑΆΑάα∝ⱭⱰ",
54 | "ßΒβϐẞ",
55 | "ƔɣΓγℽℾ",
56 | "ƍΔδẟ∆",
57 | "Εεϵ϶∍ƐɛΈέ",
58 | "ΗηΉή",
59 | "Θθϑ",
60 | "ƖɩͅͺΊΙΪίιϊι℩",
61 | "Κκϰ",
62 | "ƛΛλ",
63 | "µΜμ",
64 | "ΌΟοό",
65 | "Ππϖℼℿ∏",
66 | "Ρρϱϼ",
67 | "ƩʃͻͼͽΣςσϚϛϲϹϽϾϿ∑",
68 | "ƱʊΎΥΫΰυϋύϒϔ℧☋",
69 | "ɸΦφϕⱷ",
70 | "ΏΩωώΩ☊",
71 | "ϘϙϞϟ",
72 | "ͲͳϠϡ",
73 | "Ͱͱ",
74 | "Ͷͷ"
75 | };
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/binEdit.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Color;
5 | import java.awt.Cursor;
6 | import java.awt.Font;
7 | import java.awt.FontMetrics;
8 | import java.awt.Graphics;
9 | import java.awt.Toolkit;
10 | import java.awt.datatransfer.Clipboard;
11 | import java.awt.datatransfer.ClipboardOwner;
12 | import java.awt.datatransfer.DataFlavor;
13 | import java.awt.datatransfer.StringSelection;
14 | import java.awt.event.ActionEvent;
15 | import java.awt.event.ActionListener;
16 | import java.awt.event.AdjustmentEvent;
17 | import java.awt.event.AdjustmentListener;
18 | import java.awt.event.KeyEvent;
19 | import java.awt.event.KeyListener;
20 | import java.awt.event.MouseEvent;
21 | import java.awt.event.MouseListener;
22 | import java.awt.event.MouseMotionListener;
23 | import java.awt.event.MouseWheelEvent;
24 | import java.awt.event.MouseWheelListener;
25 | import java.awt.image.BufferedImage;
26 | import java.io.File;
27 | import java.io.IOException;
28 | import java.io.RandomAccessFile;
29 | import java.math.BigDecimal;
30 | import java.math.BigInteger;
31 | import java.util.Iterator;
32 | import java.util.Stack;
33 | import java.util.Vector;
34 | import javax.imageio.ImageIO;
35 | import javax.swing.ButtonGroup;
36 | import javax.swing.JComponent;
37 | import javax.swing.JFileChooser;
38 | import javax.swing.JOptionPane;
39 | import javax.swing.JRadioButton;
40 | import javax.swing.JScrollBar;
41 | import javax.swing.JTextField;
42 | import javax.swing.Timer;
43 |
44 | class binEdit extends JComponent
45 | implements MouseListener,
46 | MouseMotionListener,
47 | MouseWheelListener,
48 | KeyListener,
49 | ActionListener,
50 | AdjustmentListener {
51 |
52 | boolean nibArea = true;
53 | boolean isNibLow = false;
54 | boolean jSbSource = true;
55 | boolean isApplet;
56 | boolean isOled = false;
57 | int[] xPos;
58 | int[] xNib = new int[32];
59 | int[] xTxt = new int[16];
60 | int[] cShift = new int[256];
61 | int wChar = -1;
62 | int wPanel = -1;
63 | int hMargin = -1;
64 | int hChar = -1;
65 | int hPanel = -1;
66 | int fontSize = 0;
67 | int caretVisible = 0;
68 | int maxRow = -1;
69 | int maxPos;
70 | int hLimit = -1;
71 | Font font;
72 | long virtualSize = 0L;
73 | long scrPos = 0L;
74 | long firstPos = 0L;
75 | long lastPos = 0L;
76 | long newPos = 0L;
77 | long clipboardSize;
78 | long jSBStep = 1L;
79 | JFileChooser jFC;
80 | JScrollBar jSB = new JScrollBar(1, 0, 1, 0, 1);
81 | Object[] InsDelOption = new Object[7];
82 | JRadioButton[] InsDelB = new JRadioButton[5];
83 | JTextField InsDelTF = new JTextField();
84 | Timer timer = new Timer(500, this);
85 | Clipboard clipboard;
86 | RandomAccessFile rAF;
87 | Stack undoStack = new Stack();
88 | Vector srcV = new Vector();
89 | Vector markV = new Vector();
90 | Vector MarkV = new Vector();
91 | Vector v1 = new Vector();
92 | Vector XCV = new Vector();
93 | Byte byteCtrlY = null;
94 | edObj eObj = null;
95 | edObj eObjCtrlY = null;
96 | File f1 = null;
97 | public binPanel topPanel;
98 | saveT sav;
99 | findT find;
100 | long longInput = 0L;
101 |
102 | public binEdit(binPanel var1, boolean var2) {
103 | this.setLayout(new BorderLayout());
104 | this.add(this.jSB, "East");
105 | this.setGrid(14);
106 | this.addMouseListener(this);
107 | this.addMouseMotionListener(this);
108 | this.addMouseWheelListener(this);
109 | this.addKeyListener(this);
110 | this.jSB.setEnabled(true);
111 | this.jSB.setFocusable(true);
112 | this.jSB.setUnitIncrement(1);
113 | this.jSB.addMouseWheelListener(this);
114 | this.jSB.addAdjustmentListener(this);
115 | this.timer.addActionListener(this);
116 | this.topPanel = var1;
117 | this.isApplet = var2;
118 | String[] var3 =
119 | new String[] {
120 | "Delete",
121 | "Insert & fill with 0x00",
122 | "Insert & fill with 0xFF",
123 | "Insert & fill with 0x20 (space)",
124 | "or Insert clipboard"
125 | };
126 | ButtonGroup var4 = new ButtonGroup();
127 |
128 | for (int var5 = 0; var5 < this.InsDelB.length; ++var5) {
129 | (this.InsDelB[var5] = new JRadioButton(var3[var5])).addActionListener(this);
130 | var4.add(this.InsDelB[var5]);
131 | this.InsDelOption[var5 < 4 ? var5 : 6] = this.InsDelB[var5];
132 | }
133 |
134 | this.InsDelOption[4] = "Bytes to delete or to insert (0x.. for hexa entry):";
135 | this.InsDelTF.setColumns(9);
136 | this.InsDelOption[5] = this.InsDelTF;
137 | if (!var2) {
138 | this.jFC = new JFileChooser(System.getProperty("user.dir"));
139 | this.jFC.setAcceptAllFileFilterUsed(false);
140 | JFileChooser var10001 = this.jFC;
141 | this.jFC.setDialogType(0);
142 | var10001 = this.jFC;
143 | this.jFC.setFileSelectionMode(2);
144 | this.jFC.setMultiSelectionEnabled(false);
145 | this.jFC.setDragEnabled(false);
146 | this.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
147 | } else {
148 | this.jSbSource = false;
149 | this.jSB.setValue(0);
150 | this.pushHObj(
151 | new edObj(0L, 0L, 2),
152 | "\tTry Hexeditor.jar with this virtual file.\n An applet cannot access a real file nor the clipboard.\n The File menu, Ctrl+X, Ctrl+C, & Ctrl+V are therefore inhibited.");
153 | }
154 |
155 | this.focus();
156 | }
157 |
158 | public void closeFile() {
159 | if (this.rAF != null) {
160 | try {
161 | this.rAF.close();
162 | } catch (Exception var2) {
163 | System.err.println("Ctrl+OQ " + var2);
164 | }
165 | }
166 |
167 | this.f1 = null;
168 | this.undoStack.clear();
169 | this.doVirtual();
170 | System.gc();
171 | }
172 |
173 | public void loadFile(File var1) {
174 | this.f1 = var1;
175 | this.topPanel.JTFile.setText(
176 | this.f1.toString() + (this.f1.canWrite() ? "" : " ( ReadOnly ) "));
177 |
178 | try {
179 | this.rAF = new RandomAccessFile(this.f1, this.f1.canWrite() ? "rw" : "r");
180 | this.jSbSource = false;
181 | this.jSB.setValue(0);
182 | this.undoStack.push(new edObj(0L, this.f1.length(), 0));
183 | this.doVirtual();
184 | this.focus();
185 | } catch (Exception var3) {
186 | System.err.println("loadFile " + var3);
187 | }
188 |
189 | this.eObjCtrlY = null;
190 | this.byteCtrlY = null;
191 | }
192 |
193 | private void focus() {
194 | if (!this.requestFocusInWindow()) {
195 | this.requestFocus();
196 | }
197 | }
198 |
199 | private void setGrid(int var1) {
200 | byte var3 = 11;
201 | byte var4 = 35;
202 | int var5 = -3;
203 | int var2;
204 | if (var1 != this.fontSize) {
205 | this.fontSize = var1 < var3 ? var3 : (var4 < var1 ? var4 : var1);
206 | FontMetrics var6 =
207 | this.getFontMetrics(
208 | this.font =
209 | new Font(
210 | "Monospaced",
211 | this.fontSize < 27 ? 0 : 1,
212 | this.fontSize));
213 | this.cShift = var6.getWidths();
214 | this.wChar = -1;
215 |
216 | for (var2 = 0; var2 < 256; ++var2) {
217 | this.wChar =
218 | var2 != 9 && this.cShift[var2] > this.wChar
219 | ? this.cShift[var2]
220 | : this.wChar;
221 | }
222 |
223 | this.wChar =
224 | var6.charWidth('\u2219') > this.wChar ? var6.charWidth('\u2219') : this.wChar;
225 |
226 | for (var2 = 0; var2 < 256; ++var2) {
227 | this.cShift[var2] = this.wChar - this.cShift[var2] >> 1;
228 | }
229 |
230 | this.wChar >>= 1;
231 | this.hChar = var6.getHeight();
232 | this.hMargin = var6.getLeading() + var6.getAscent();
233 | }
234 |
235 | this.maxRow = (this.hPanel - this.hMargin) / this.hChar + 1;
236 | this.maxPos = (this.maxRow << 4) - 1;
237 | this.xPos = new int[Long.toHexString(this.virtualSize + 32L).length() + 1 >> 1 << 1];
238 |
239 | for (var2 = this.xPos.length - 1; -1 < var2; --var2) {
240 | this.xPos[var2] = var5 += var2 % 2 == 0 ? 2 : 3;
241 | }
242 |
243 | for (var2 = 0; var2 < this.xNib.length; ++var2) {
244 | int var10003 = (var2 & 1) == 1 ? 2 : ((var2 & 7) == 0 ? 5 : 3);
245 | int var10002 = var5 + ((var2 & 1) == 1 ? 2 : ((var2 & 7) == 0 ? 5 : 3));
246 | var5 += var10003;
247 | this.xNib[var2] = var10002;
248 | }
249 |
250 | var5 += 4;
251 |
252 | for (var2 = 0; var2 < this.xTxt.length; ++var2) {
253 | var5 += 2;
254 | this.xTxt[var2] = var5;
255 | }
256 |
257 | long var8 = (this.virtualSize >> 4) + 2L;
258 | if (var8 < 1073741824L) {
259 | this.jSbSource = false;
260 | this.jSB.setMaximum((int) var8);
261 | this.jSbSource = false;
262 | this.jSB.setVisibleAmount(this.maxRow);
263 | this.jSbSource = false;
264 | this.jSB.setBlockIncrement(this.maxRow - 1);
265 | this.jSBStep = 16L;
266 | } else {
267 | var2 = (int) (var8 >> 30);
268 | this.jSbSource = false;
269 | this.jSB.setMaximum(1073741824);
270 | this.jSbSource = false;
271 | this.jSB.setVisibleAmount(1);
272 | this.jSbSource = false;
273 | this.jSB.setBlockIncrement(1048576);
274 | this.jSBStep = (long) var2 << 4;
275 | }
276 | }
277 |
278 | public void adjustmentValueChanged(AdjustmentEvent var1) {
279 | if (var1.getSource() == this.jSB && this.jSbSource) {
280 | this.slideScr((long) this.jSB.getValue() * this.jSBStep, false);
281 | }
282 |
283 | this.jSbSource = true;
284 | }
285 |
286 | protected void slideScr(long var1, boolean var3) {
287 | long var4 =
288 | this.virtualSize < 9223372036854775792L
289 | ? this.virtualSize & -16L
290 | : 9223372036854775792L;
291 | if (var3 || var1 >= 0L) {
292 | if (var3 && (this.lastPos < var1 || var1 < this.lastPos - (long) this.maxPos)) {
293 | this.scrPos = this.lastPos - (long) (this.maxPos >> 1) & -16L;
294 | } else {
295 | this.scrPos = var1 & -16L;
296 | }
297 | }
298 |
299 | if (var4 - (long) this.maxPos + 31L <= this.scrPos) {
300 | this.scrPos = var4 - (long) this.maxPos + 31L;
301 | }
302 |
303 | if (this.scrPos < 0L) {
304 | this.scrPos = 0L;
305 | }
306 |
307 | if (this.scrPos != (long) this.jSB.getValue() * this.jSBStep) {
308 | this.jSbSource = false;
309 | this.jSB.setValue((int) (this.scrPos / this.jSBStep));
310 | }
311 |
312 | this.setSrc();
313 | this.rePaint();
314 | this.caretVisible = 0;
315 | this.timer.restart();
316 | }
317 |
318 | protected void goTo(String var1) {
319 | if (var1 != null) {
320 | this.String2long(var1);
321 | if (this.longInput < 0L) {
322 | this.longInput = this.lastPos;
323 | }
324 |
325 | this.firstPos =
326 | this.lastPos =
327 | this.longInput < this.virtualSize ? this.longInput : this.virtualSize;
328 | this.isNibLow = false;
329 | this.slideScr(0L, true);
330 | }
331 | }
332 |
333 | protected void paintComponent(Graphics var1) {
334 | this.paintImg(var1, true);
335 | }
336 |
337 | protected void paintImg(Graphics var1, boolean var2) {
338 | char[] var3 =
339 | new char[] {
340 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
341 | };
342 | Color[] var4 =
343 | new Color[] {
344 | Color.WHITE,
345 | Color.BLACK,
346 | new Color(50, 50, 50, 40),
347 | new Color(50, 50, 50, 80),
348 | Color.GREEN,
349 | Color.RED,
350 | Color.BLUE,
351 | Color.YELLOW,
352 | Color.MAGENTA,
353 | Color.CYAN,
354 | Color.GREEN.darker(),
355 | new Color(0, 0, 0, 0)
356 | };
357 | byte[] var5 = new byte[2];
358 | int[] var10 = new int[2];
359 | int[] var11 = new int[2];
360 | long var12 = 0L;
361 | if (this.hPanel != this.getHeight()) {
362 | this.wPanel = this.getWidth();
363 | this.hPanel = this.getHeight();
364 | this.setGrid(this.fontSize);
365 | this.setSrc();
366 | }
367 |
368 | var1.setColor(var4[this.isOled ? 1 : 0]);
369 | var1.fillRect(0, 0, this.getWidth(), this.getHeight());
370 | var1.setFont(this.font);
371 | var1.setColor(var4[this.isOled ? 7 : 6]);
372 | this.hLimit = 0;
373 |
374 | char var6;
375 | int var8;
376 | int var9;
377 | for (var9 = 0; var9 < this.maxRow; ++var9) {
378 | var12 = this.scrPos + (long) (var9 << 4);
379 | if ((this.virtualSize | 15L) < var12 || var12 < 0L) {
380 | break;
381 | }
382 |
383 | for (var8 = 0; var8 < this.xPos.length; ++var8) {
384 | var6 = var3[(int) (var12 & 15L)];
385 | var1.drawString(
386 | "" + var6,
387 | this.cShift[var6] + this.wChar * this.xPos[var8],
388 | this.hLimit = this.hMargin + this.hChar * var9);
389 | var12 >>= 4;
390 | }
391 | }
392 |
393 | if (var12 < 0L) {
394 | var1.setColor(var4[5]);
395 | var1.drawString(
396 | "-- Limit = 0x7FFFFFFFFFFFFFFE = Long.MAX_VALUE-1 = 2^63-2 = 9223372036854775806 --",
397 | 0,
398 | this.hMargin + this.hChar * var9 - 3);
399 | }
400 |
401 | var1.setColor(var4[9]);
402 | boolean var16 = this.firstPos < this.lastPos;
403 | var10 = this.pos2XY(var16 ? this.firstPos : this.lastPos);
404 | var11 = this.pos2XY(!var16 ? this.firstPos : this.lastPos);
405 | if (this.lastPos != this.firstPos && this.lastPos >= this.scrPos) {
406 | if (var10[1] == var11[1]) {
407 | var1.fillRect(
408 | this.wChar * this.xNib[var10[0] * 2] - 2,
409 | this.hChar * var10[1] + 3,
410 | this.wChar * (this.xNib[var11[0] * 2] - this.xNib[var10[0] * 2]),
411 | this.hChar - 4);
412 | var1.fillRect(
413 | this.wChar * this.xTxt[var10[0]],
414 | this.hChar * var10[1] + 3,
415 | this.wChar * (this.xTxt[var11[0]] - this.xTxt[var10[0]]),
416 | this.hChar - 4);
417 | } else if (var10[1] + 1 == var11[1] && var11[0] == 0) {
418 | var1.fillRect(
419 | this.wChar * this.xNib[var10[0] * 2] - 2,
420 | this.hChar * var10[1] + 3,
421 | this.wChar * (this.xNib[31] + 2 - this.xNib[var10[0] * 2]),
422 | this.hChar - 4);
423 | var1.fillRect(
424 | this.wChar * this.xTxt[var10[0]],
425 | this.hChar * var10[1] + 3,
426 | this.wChar * (this.xTxt[15] + 2 - this.xTxt[var10[0]]),
427 | this.hChar - 4);
428 | } else {
429 | var1.fillRect(
430 | this.wChar * this.xNib[var10[0] * 2] - 2,
431 | this.hChar * var10[1] + 3,
432 | this.wChar * (this.xNib[31] + 2 - this.xNib[var10[0] * 2]) + 4,
433 | this.hChar - 4);
434 | var1.fillRect(
435 | this.wChar * this.xNib[0] - 2,
436 | this.hChar * (var10[1] + 1) - 1,
437 | this.wChar * (this.xNib[31] + 2 - this.xNib[0]) + 4,
438 | this.hChar * (var11[1] - var10[1] - 1) + 4);
439 | if (this.xNib[var11[0] * 2] != this.xNib[0]) {
440 | var1.fillRect(
441 | this.wChar * this.xNib[0] - 2,
442 | this.hChar * var11[1] + 3,
443 | this.wChar * (this.xNib[var11[0] * 2] - this.xNib[0]),
444 | this.hChar - 4);
445 | }
446 |
447 | var1.fillRect(
448 | this.wChar * this.xTxt[var10[0]],
449 | this.hChar * var10[1] + 3,
450 | this.wChar * (this.xTxt[15] + 2 - this.xTxt[var10[0]]),
451 | this.hChar - 4);
452 | var1.fillRect(
453 | this.wChar * this.xTxt[0],
454 | this.hChar * (var10[1] + 1) - 1,
455 | this.wChar * (this.xTxt[15] + 2 - this.xTxt[0]),
456 | this.hChar * (var11[1] - var10[1] - 1) + 4);
457 | var1.fillRect(
458 | this.wChar * this.xTxt[0],
459 | this.hChar * var11[1] + 3,
460 | this.wChar * (this.xTxt[var11[0]] - this.xTxt[0]),
461 | this.hChar - 4);
462 | }
463 | }
464 |
465 | if (this.isOled) {
466 | var1.setXORMode(Color.BLACK);
467 | }
468 |
469 | for (int var7 = 0; var7 < this.srcV.size() && var7 < this.maxRow << 4; ++var7) {
470 | var8 = var7 % 16;
471 | var9 = var7 >> 4;
472 | var5 = (byte[]) ((byte[]) ((byte[]) this.srcV.get(var7)));
473 | var1.setColor(var4[var5[1] != 1 ? 11 : (this.isOled ? 2 : 2)]);
474 | var1.fillRect(
475 | this.wChar * this.xNib[var8 * 2] - 2,
476 | this.hChar * var9 + 3,
477 | this.wChar * 5,
478 | this.hChar - 4);
479 | var1.fillRect(
480 | this.wChar * this.xTxt[var8],
481 | this.hChar * var9 + 3,
482 | this.wChar * 2,
483 | this.hChar - 4);
484 | var1.setColor(var4[2 < var5[1] ? (this.isOled ? 0 : 5) : (this.isOled ? 4 : 1)]);
485 | var6 = var3[(255 & var5[0]) >> 4];
486 | var1.drawString(
487 | "" + var6,
488 | this.cShift[var6] + this.wChar * this.xNib[var8 * 2],
489 | this.hMargin + this.hChar * var9);
490 | var6 = var3[(255 & var5[0]) % 16];
491 | var1.drawString(
492 | "" + var6,
493 | this.cShift[var6] + this.wChar * this.xNib[var8 * 2 + 1],
494 | this.hMargin + this.hChar * var9);
495 | var6 = (char) (255 & var5[0]);
496 | if (Character.isISOControl(var6)) {
497 | var1.drawString(
498 | "∙", this.wChar * this.xTxt[var8], this.hMargin + this.hChar * var9);
499 | } else {
500 | var1.drawString(
501 | "" + var6,
502 | this.cShift[var6] + this.wChar * this.xTxt[var8],
503 | this.hMargin + this.hChar * var9);
504 | }
505 | }
506 |
507 | var1.setPaintMode();
508 | var1.setColor(var4[10]);
509 | long var14;
510 | Iterator var17;
511 | if (this.markV != null && 0 < this.markV.size()) {
512 | var17 = this.markV.iterator();
513 |
514 | while (var17.hasNext()) {
515 | var14 = ((Long) var17.next()).longValue();
516 | if (this.virtualSize <= var14) {
517 | var17.remove();
518 | } else if (this.scrPos <= var14 && var14 - (long) this.maxPos <= this.scrPos) {
519 | var10 = this.pos2XY(var14);
520 | var1.fillRect(
521 | this.wChar * (this.xNib[0] - 1),
522 | this.hChar * (var10[1] + 1) - 2,
523 | this.wChar * (this.xNib[var10[0] << 1] - this.xNib[0] + 1) - 2,
524 | 1);
525 | var1.fillRect(
526 | this.wChar * this.xNib[var10[0] << 1] - 2,
527 | this.hChar * var10[1] + 3,
528 | 1,
529 | this.hChar - 4);
530 | var1.fillRect(
531 | this.wChar * this.xNib[var10[0] << 1] - 2,
532 | this.hChar * var10[1] + 3,
533 | this.wChar * (this.xNib[31] - this.xNib[var10[0] << 1] + 3),
534 | 1);
535 | var1.fillRect(
536 | this.wChar * (this.xTxt[0] - 1),
537 | this.hChar * (var10[1] + 1) - 2,
538 | this.wChar * (this.xTxt[var10[0]] - this.xTxt[0] + 1),
539 | 1);
540 | var1.fillRect(
541 | this.wChar * this.xTxt[var10[0]] - 1,
542 | this.hChar * var10[1] + 3,
543 | 1,
544 | this.hChar - 4);
545 | var1.fillRect(
546 | this.wChar * this.xTxt[var10[0]],
547 | this.hChar * var10[1] + 3,
548 | this.wChar * (this.xTxt[15] - this.xTxt[var10[0]] + 3),
549 | 1);
550 | }
551 | }
552 | }
553 |
554 | if (this.MarkV != null && 0 < this.MarkV.size()) {
555 | var17 = this.MarkV.iterator();
556 |
557 | while (var17.hasNext()) {
558 | var14 = ((Long) var17.next()).longValue();
559 | if (this.virtualSize <= var14) {
560 | var17.remove();
561 | } else if (this.scrPos <= var14 && var14 - (long) this.maxPos <= this.scrPos) {
562 | var10 = this.pos2XY(var14);
563 | var1.fillRect(
564 | this.wChar * (this.xNib[0] - 1),
565 | this.hChar * (var10[1] + 1) - 2,
566 | this.wChar * (this.xNib[var10[0] << 1] - this.xNib[0] + 1),
567 | 2);
568 | var1.fillRect(
569 | this.wChar * this.xNib[var10[0] << 1] - 2,
570 | this.hChar * var10[1] + 3,
571 | 2,
572 | this.hChar - 3);
573 | var1.fillRect(
574 | this.wChar * this.xNib[var10[0] << 1] - 2,
575 | this.hChar * var10[1] + 3,
576 | this.wChar * (this.xNib[31] - this.xNib[var10[0] << 1] + 3),
577 | 2);
578 | var1.fillRect(
579 | this.wChar * (this.xTxt[0] - 1),
580 | this.hChar * (var10[1] + 1) - 2,
581 | this.wChar * (this.xTxt[var10[0]] - this.xTxt[0] + 1),
582 | 2);
583 | var1.fillRect(
584 | this.wChar * this.xTxt[var10[0]] - 1,
585 | this.hChar * var10[1] + 3,
586 | 2,
587 | this.hChar - 3);
588 | var1.fillRect(
589 | this.wChar * this.xTxt[var10[0]],
590 | this.hChar * var10[1] + 3,
591 | this.wChar * (this.xTxt[15] - this.xTxt[var10[0]] + 3),
592 | 2);
593 | }
594 | }
595 | }
596 |
597 | if (this.scrPos <= this.lastPos && this.lastPos - (long) this.maxPos <= this.scrPos) {
598 | var1.setColor(var4[8]);
599 | var11 = this.pos2XY(this.lastPos);
600 | if (this.caretVisible < 2 || !var2) {
601 | var1.fillRect(
602 | this.wChar
603 | * (this.nibArea
604 | ? this.xNib[
605 | (var11[0] << 1) + (this.isNibLow ? 1 : 0)]
606 | : this.xTxt[var11[0]])
607 | - 1,
608 | this.hChar * var11[1] + 3,
609 | 2,
610 | this.hChar - 4);
611 | }
612 |
613 | var1.fillRect(
614 | this.wChar * (this.nibArea ? this.xTxt[var11[0]] : this.xNib[var11[0] << 1]),
615 | this.hChar * (var11[1] + 1) - 2,
616 | this.wChar << (this.nibArea ? 1 : 2),
617 | 2);
618 | }
619 | }
620 |
621 | private int[] pos2XY(long var1) {
622 | var1 -= this.scrPos;
623 | int var3 = var1 < 0L ? 0 : (var1 < (long) (this.maxPos + 1) ? (int) var1 : this.maxPos + 1);
624 | int[] var4 = new int[] {var3 % 16, var3 >> 4};
625 | return var4;
626 | }
627 |
628 | protected void rePaint() {
629 | this.repaint();
630 | this.setStatus();
631 | }
632 |
633 | protected void setStatus() {
634 | int var3 = this.topPanel.viewCBox[1].getSelectedIndex();
635 | String var7 = "";
636 | if (this.firstPos != this.lastPos) {
637 | if (this.lastPos - this.firstPos < 2147483647L
638 | && this.firstPos - this.lastPos < 2147483647L) {
639 | this.topPanel.JTsizes.setText(this.lastPos - this.firstPos + " bytes selected.");
640 | } else {
641 | this.topPanel.JTsizes.setForeground(Color.red);
642 | this.topPanel.JTsizes.setText("Don\'t select more than 2^31-1 bytes!");
643 | }
644 | } else {
645 | StringBuffer var6 =
646 | new StringBuffer(this.isApplet ? "Offset: " : "Offset: ");
647 | var6.append(this.coloredLong(this.lastPos))
648 | .append("/-")
649 | .append(this.coloredLong(this.virtualSize - this.lastPos));
650 | this.topPanel.JTsizes.setForeground(Color.black);
651 | this.topPanel.JTsizes.setText(var6.toString());
652 | }
653 |
654 | this.topPanel.JTView.setText("");
655 | if (this.lastPos >= this.scrPos && this.scrPos + (long) this.srcV.size() >= this.lastPos) {
656 | if (this.lastPos <= this.virtualSize) {
657 | int var5 =
658 | var3 != 0 && var3 != 1
659 | ? (var3 != 2 && var3 != 3
660 | ? (var3 != 4 && var3 != 5 && var3 != 8
661 | ? (var3 != 6 && var3 != 7 && var3 != 9
662 | ? (var3 != 10 && var3 != 11 ? 128 : 64)
663 | : 8)
664 | : 4)
665 | : 2)
666 | : 1;
667 | int var4 =
668 | (int)
669 | ((this.virtualSize < this.scrPos + (long) this.srcV.size()
670 | ? this.virtualSize
671 | : this.scrPos + (long) this.srcV.size())
672 | - this.lastPos);
673 | if (var4 == 0 || var4 < var5 && var5 < 9) {
674 | return;
675 | }
676 |
677 | var4 = var5 < var4 ? var5 : (var3 != 12 ? var4 : var4 >> 1 << 1);
678 | byte[] var1 = new byte[var4];
679 |
680 | for (var4 = 0; var4 < var1.length; ++var4) {
681 | var1[var4] =
682 | ((byte[])
683 | ((byte[])
684 | this.srcV.get(
685 | (int)
686 | (this.lastPos
687 | - this.scrPos
688 | + (long) var4))))
689 | [0];
690 | }
691 |
692 | var5 = var1[0];
693 |
694 | try {
695 | if (var3 == 0) {
696 | for (var4 = 0; var4 < 8; ++var4) {
697 | var7 = var7 + ((var5 & 128) == 128 ? '1' : '0');
698 | if (var4 == 3) {
699 | var7 = var7 + ' ';
700 | }
701 |
702 | var5 <<= 1;
703 | }
704 | } else if (var3 == 1) {
705 | var7 = Integer.toString(var5) + " / " + Integer.toString(var5 & 255);
706 | } else if (var3 == 8) {
707 | var7 =
708 | this.topPanel.fForm.format(
709 | (double)
710 | Float.intBitsToFloat(
711 | (new BigInteger(var1)).intValue()));
712 | } else if (var3 == 9) {
713 | var7 =
714 | this.topPanel.dForm.format(
715 | Double.longBitsToDouble(
716 | (new BigInteger(var1)).longValue()));
717 | } else if (var3 == 10) {
718 | var7 =
719 | new String(
720 | var1,
721 | this.topPanel.cp437Available ? "cp437" : "ISO-8859-1");
722 | } else if (var3 == 11) {
723 | var7 = new String(var1, "UTF-8");
724 | } else if (var3 == 12) {
725 | var7 =
726 | new String(
727 | var1,
728 | this.topPanel.viewCBox[0].getSelectedIndex() < 1
729 | ? "UTF-16BE"
730 | : "UTF-16LE");
731 | } else {
732 | byte[] var2 = new byte[var3 < 6 ? var3 : (var3 == 6 ? 8 : 9)];
733 | var2[0] = 0;
734 | if (this.topPanel.viewCBox[0].getSelectedIndex() < 1) {
735 | if ((var2.length & 1) == 0) {
736 | System.arraycopy(var1, 0, var2, 0, var2.length);
737 | } else {
738 | System.arraycopy(var1, 0, var2, 1, var2.length - 1);
739 | }
740 | } else {
741 | for (var4 = var2.length & 1; var4 < var2.length; ++var4) {
742 | var2[var4] = var1[var2.length - var4 - 1];
743 | }
744 | }
745 |
746 | var7 = (new BigInteger(var2)).toString();
747 | }
748 | } catch (Exception var9) {
749 | System.err.println("setStatus " + var9);
750 | }
751 |
752 | this.topPanel.JTView.setText(var7.replaceAll("\t", " ").replaceAll("\n", " "));
753 | this.topPanel.JTView.setCaretPosition(0);
754 | }
755 | }
756 | }
757 |
758 | private String coloredLong(long var1) {
759 | boolean var3 = this.topPanel.hexOffset;
760 | StringBuffer var4 = new StringBuffer(var3 ? "0x" : "");
761 | String var5 = var3 ? Long.toHexString(var1).toUpperCase() : Long.toString(var1);
762 | int var7 = var5.length();
763 | if (var3 && var7 % 2 == 1) {
764 | var5 = "0" + var5;
765 | }
766 |
767 | var7 = var3 ? 0 : var7 % 3;
768 | if (this.isApplet) {
769 | var4.append(var5);
770 | } else {
771 | int var6;
772 | for (var6 = 0; var6 < var5.length(); ++var6) {
773 | if (var6 % (var3 ? 4 : 6) == var7) {
774 | var4.append("");
775 | }
776 |
777 | var4.append(var5.charAt(var6));
778 | if (var6 % (var3 ? 4 : 6) == (var3 ? 1 : 2 + var7)) {
779 | var4.append(" ");
780 | }
781 | }
782 |
783 | if (!var3 && var6 % 6 < 3 + var7) {
784 | var4.append("");
785 | }
786 | }
787 |
788 | return var4.toString();
789 | }
790 |
791 | public void actionPerformed(ActionEvent var1) {
792 | if (var1.getSource() == this.timer) {
793 | int[] var2 = this.pos2XY(this.lastPos);
794 | this.caretVisible = ++this.caretVisible % 4;
795 | if ((this.caretVisible & 1) == 0) {
796 | this.paintImmediately(
797 | this.wChar * (this.nibArea ? this.xNib[var2[0] << 1] : this.xTxt[var2[0]])
798 | - 1,
799 | this.hChar * var2[1] + 3,
800 | this.wChar + 1 << 1,
801 | this.hChar - 3);
802 | }
803 | } else if (var1.getSource() != this.InsDelB[4]) {
804 | this.InsDelTF.setEnabled(true);
805 | } else {
806 | this.InsDelTF.setEnabled(true);
807 | boolean var4 = this.topPanel.hexOffset;
808 | String var3 =
809 | var4
810 | ? Long.toHexString(this.clipboardSize).toUpperCase()
811 | : Long.toString(this.clipboardSize);
812 | if (var4 && var3.length() % 2 == 1) {
813 | var3 = "0" + var3;
814 | }
815 |
816 | this.InsDelTF.setText((var4 ? "0x" : "") + var3);
817 | this.fromClipboard(true);
818 | }
819 | }
820 |
821 | public void mouseClicked(MouseEvent var1) {}
822 |
823 | public void mouseReleased(MouseEvent var1) {}
824 |
825 | public void mouseEntered(MouseEvent var1) {
826 | this.setCursor(new Cursor(2));
827 | }
828 |
829 | public void mouseExited(MouseEvent var1) {
830 | this.setCursor((Cursor) null);
831 | }
832 |
833 | public void mousePressed(MouseEvent var1) {
834 | this.focus();
835 | this.lastPos = this.getCaretPos(var1);
836 | this.caretVisible = 0;
837 | if (var1.isShiftDown()) {
838 | this.isNibLow = false;
839 | this.rePaint();
840 | } else {
841 | this.firstPos = this.lastPos;
842 | this.rePaint();
843 | this.timer.restart();
844 | }
845 | }
846 |
847 | public void mouseMoved(MouseEvent var1) {}
848 |
849 | public void mouseDragged(MouseEvent var1) {
850 | if (this.lastPos != (this.newPos = this.getCaretPos(var1))) {
851 | this.lastPos = this.newPos;
852 | this.isNibLow = false;
853 | this.rePaint();
854 | }
855 | }
856 |
857 | protected long getCaretPos(MouseEvent var1) {
858 | int var3 = -2;
859 | int var4 =
860 | (var1.getX() < this.getWidth()
861 | ? (0 < var1.getX() ? var1.getX() - 3 * this.wChar / 2 : 0)
862 | : this.getWidth())
863 | / this.wChar;
864 |
865 | int var2;
866 | for (var2 = 0; var2 < this.xNib.length && var3 < 0; ++var2) {
867 | if (var4 < this.xNib[var2]) {
868 | var3 = var2;
869 | }
870 | }
871 |
872 | if (var3 < 0 && var4 < this.xNib[this.xNib.length - 1] + 3) {
873 | var3 = this.xNib.length - 1;
874 | }
875 |
876 | this.nibArea = -2 < var3;
877 | this.isNibLow = 1 == (var3 & 1);
878 | var3 >>= 1;
879 |
880 | for (var2 = 0; var2 < this.xTxt.length && var3 < 0; ++var2) {
881 | if (var4 < this.xTxt[var2]) {
882 | var3 = var2;
883 | }
884 | }
885 |
886 | this.newPos =
887 | this.scrPos
888 | + (long)
889 | ((var1.getY() < this.getHeight()
890 | ? (0 < var1.getY() ? var1.getY() / this.hChar : 0)
891 | : this.maxRow - 1)
892 | << 4)
893 | + (long) (var3 < 0 ? 15 : var3);
894 | if (this.virtualSize <= this.newPos || this.newPos < 0L) {
895 | this.newPos = this.virtualSize;
896 | this.isNibLow = false;
897 | }
898 |
899 | if ((this.lastPos != this.newPos || this.lastPos + 1L != this.newPos)
900 | && !this.undoStack.isEmpty()) {
901 | ((edObj) this.undoStack.lastElement()).isEditing = false;
902 | }
903 |
904 | return this.newPos;
905 | }
906 |
907 | public void mouseWheelMoved(MouseWheelEvent var1) {
908 | if (!var1.isControlDown()) {
909 | this.slideScr(
910 | this.scrPos
911 | + (long) var1.getWheelRotation()
912 | * (var1.getScrollType() == 0 ? 32L : (long) this.maxPos + 1L),
913 | false);
914 | } else {
915 | this.setGrid(this.fontSize - 3 * var1.getWheelRotation());
916 | this.slideScr(this.scrPos, true);
917 | this.rePaint();
918 | }
919 | }
920 |
921 | public void keyReleased(KeyEvent var1) {}
922 |
923 | public void keyPressed(KeyEvent var1) {
924 | switch (var1.getKeyCode()) {
925 | case 8:
926 | this.KeyFromMenu(90);
927 | case 33:
928 | this.newPos = this.lastPos - ((long) this.maxPos - 15L);
929 | break;
930 | case 34:
931 | this.newPos = this.lastPos + ((long) this.maxPos - 15L);
932 | break;
933 | case 35:
934 | if (!var1.isControlDown() && this.lastPos + 15L <= this.virtualSize) {
935 | this.newPos = this.lastPos | 15L;
936 | } else {
937 | this.newPos = this.virtualSize - 1L;
938 | }
939 | break;
940 | case 36:
941 | if (!var1.isControlDown()) {
942 | this.newPos = this.lastPos & -16L;
943 | } else {
944 | this.newPos = 0L;
945 | }
946 | break;
947 | case 37:
948 | case 226:
949 | this.newPos = this.lastPos - (this.isNibLow ? 0L : 1L);
950 | break;
951 | case 38:
952 | case 224:
953 | this.newPos = this.lastPos - 16L;
954 | break;
955 | case 39:
956 | case 227:
957 | this.newPos = this.lastPos + 1L;
958 | break;
959 | case 40:
960 | case 225:
961 | this.newPos = this.lastPos + 16L;
962 | break;
963 | default:
964 | return;
965 | }
966 |
967 | this.isNibLow = false;
968 | long var2 = this.newPos - this.lastPos;
969 | if (this.newPos == -1L && this.lastPos < 99999L) {
970 | this.lastPos = 0L;
971 | } else if (this.newPos <= 0L && this.lastPos < 99999L) {
972 | this.lastPos = this.newPos & 15L;
973 | } else if ((this.newPos == this.virtualSize || this.newPos == this.virtualSize + 1L)
974 | && var2 == 1L) {
975 | this.lastPos = this.virtualSize;
976 | } else if (this.virtualSize > this.newPos && this.newPos >= 0L) {
977 | this.lastPos = this.newPos;
978 | } else {
979 | this.lastPos =
980 | (this.virtualSize - 1L & -16L)
981 | + (this.newPos & 15L)
982 | - ((this.newPos & 15L) <= (this.virtualSize - 1L & 15L) ? 0L : 16L);
983 | }
984 |
985 | if (!var1.isShiftDown()) {
986 | this.firstPos = this.lastPos;
987 | }
988 |
989 | if (!this.undoStack.empty() && ((edObj) this.undoStack.lastElement()).isEditing) {
990 | ((edObj) this.undoStack.lastElement()).isEditing = false;
991 | }
992 |
993 | if (9223372036854775792L - (long) this.maxPos + 16L < this.scrPos) {
994 | this.slideScr(this.scrPos = Long.MAX_VALUE & -16L - (long) this.maxPos + 15L, true);
995 | } else if (this.newPos >= this.scrPos && var2 != -((long) this.maxPos - 15L)) {
996 | if (this.scrPos >= this.newPos - (long) this.maxPos
997 | && var2 != (long) this.maxPos - 15L) {
998 | this.timer.stop();
999 | this.rePaint();
1000 | this.caretVisible = 0;
1001 | this.timer.restart();
1002 | } else {
1003 | this.slideScr(this.scrPos += var2 + 15L & -16L, true);
1004 | }
1005 | } else {
1006 | this.slideScr(this.scrPos = this.scrPos + var2 & -16L, true);
1007 | }
1008 | }
1009 |
1010 | public void KeyFromMenu(int var1) {
1011 | char[] var2 =
1012 | new char[] {
1013 | '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
1014 | };
1015 | boolean var3 = true;
1016 | boolean var4 = this.sav != null || this.find != null;
1017 | Object[] var8 =
1018 | new Object[] {"Valid entry are: decimal, hexa (0x..) or percent (..%)"};
1019 | int var5;
1020 | String var6;
1021 | long var10;
1022 | long var12;
1023 | switch (var1) {
1024 | case 45:
1025 | case 107:
1026 | case 109:
1027 | case 521:
1028 | this.setGrid(this.fontSize + (var1 != 107 && var1 != 521 ? -3 : 3));
1029 | this.slideScr(this.scrPos, true);
1030 | this.rePaint();
1031 | break;
1032 | case 65:
1033 | if (this.virtualSize < 2147483648L) {
1034 | this.firstPos = 0L;
1035 | this.lastPos = this.virtualSize;
1036 | this.rePaint();
1037 | } else {
1038 | JOptionPane.showMessageDialog(this, "Selection cannot be greater than 2GiB");
1039 | }
1040 | break;
1041 | case 67:
1042 | case 88:
1043 | if (this.firstPos != this.lastPos && !var4 && !this.isApplet) {
1044 | boolean var21 = this.firstPos < this.lastPos;
1045 | var10 = var21 ? this.firstPos : this.lastPos;
1046 | var12 = !var21 ? this.firstPos : this.lastPos;
1047 |
1048 | try {
1049 | this.XCV = this.virtualStack(var10, var12);
1050 | char[] var22;
1051 | if (!this.nibArea) {
1052 | var22 = new char[this.XCV.size()];
1053 |
1054 | for (var5 = 0; var5 < this.XCV.size(); ++var5) {
1055 | var22[var5] =
1056 | (char) (255 & ((byte[]) ((byte[]) this.XCV.get(var5)))[0]);
1057 | if (Character.isISOControl(var22[var5])
1058 | && "\t\\u000A\f\\u000D".indexOf(var22[var5]) < 0) {
1059 | throw new Exception(
1060 | "\'" + (var22[var5] & 255) + "\' isIsoControl");
1061 | }
1062 | }
1063 | } else {
1064 | var22 = new char[this.XCV.size() << 1];
1065 |
1066 | for (var5 = 0; var5 < this.XCV.size(); ++var5) {
1067 | var22[2 * var5] =
1068 | var2[
1069 | (255 & ((byte[]) ((byte[]) this.XCV.get(var5)))[0])
1070 | >> 4];
1071 | var22[2 * var5 + 1] =
1072 | var2[
1073 | (255 & ((byte[]) ((byte[]) this.XCV.get(var5)))[0])
1074 | % 16];
1075 | }
1076 | }
1077 |
1078 | this.clipboard.setContents(
1079 | new StringSelection(new String(var22)), (ClipboardOwner) null);
1080 | } catch (Exception var20) {
1081 | JOptionPane.showMessageDialog(
1082 | this, "Can\'t copy text into the clipboard:\n" + var20);
1083 | }
1084 |
1085 | if (var1 == 88) {
1086 | this.pushHObj(new edObj(var10, var12 - var10, 8), (String) null);
1087 | }
1088 | }
1089 | break;
1090 | case 68:
1091 | case 85:
1092 | var12 = 0L;
1093 | long var14 = this.virtualSize;
1094 | this.isNibLow = false;
1095 | Iterator var23;
1096 | if (this.markV != null && 0 < this.markV.size()) {
1097 | for (var23 = this.markV.iterator();
1098 | var23.hasNext();
1099 | var14 = this.lastPos < var10 && var10 < var14 ? var10 : var14) {
1100 | var10 = ((Long) var23.next()).longValue();
1101 | var12 = var12 < var10 && var10 < this.lastPos ? var10 : var12;
1102 | }
1103 | }
1104 |
1105 | if (this.MarkV != null && 0 < this.MarkV.size()) {
1106 | for (var23 = this.MarkV.iterator();
1107 | var23.hasNext();
1108 | var14 = this.lastPos < var10 && var10 < var14 ? var10 : var14) {
1109 | var10 = ((Long) var23.next()).longValue();
1110 | var12 = var12 < var10 && var10 < this.lastPos ? var10 : var12;
1111 | }
1112 | }
1113 |
1114 | this.firstPos = this.lastPos = var1 == 85 ? var12 : var14;
1115 | this.slideScr(0L, true);
1116 | break;
1117 | case 70:
1118 | if (this.find == null) {
1119 | this.topPanel.find();
1120 | }
1121 | break;
1122 | case 71:
1123 | this.goTo(JOptionPane.showInputDialog(this, var8, "Hexeditor.jar: GoTo", -1));
1124 | break;
1125 | case 77:
1126 | Long var9 = new Long(this.lastPos);
1127 | if (this.markV.remove(var9)) {
1128 | this.MarkV.add(var9);
1129 | } else if (!this.MarkV.remove(var9)) {
1130 | this.markV.add(var9);
1131 | }
1132 |
1133 | this.rePaint();
1134 | break;
1135 | case 79:
1136 | case 81:
1137 | if (!var4 && !this.isApplet) {
1138 | if (this.rAF == null && !this.undoStack.empty()
1139 | || this.rAF != null && 1 < this.undoStack.size()) {
1140 | var5 =
1141 | JOptionPane.showConfirmDialog(
1142 | this, "Save the current modified file?");
1143 | if (var5 == 2) {
1144 | break;
1145 | }
1146 |
1147 | if (var5 == 0) {
1148 | this.save1();
1149 | break;
1150 | }
1151 | }
1152 |
1153 | this.closeFile();
1154 | if (var1 == 79 && this.jFC.showOpenDialog(this) == 0) {
1155 | this.loadFile(this.jFC.getSelectedFile());
1156 | }
1157 | } else {
1158 | JOptionPane.showMessageDialog(this, "Busy, save or find running.");
1159 | }
1160 | break;
1161 | case 80:
1162 | var5 = this.wChar * (this.xTxt[15] + 9);
1163 | var5 = var5 < this.getWidth() ? var5 : this.getWidth();
1164 | BufferedImage var16 = new BufferedImage(var5, this.hLimit + 10, 8);
1165 | this.paintImg(var16.getGraphics(), false);
1166 | var6 = this.f1.getPath();
1167 | var5 = 1;
1168 |
1169 | File var17;
1170 | do {
1171 | var17 = new File(var6 + var5 + ".png");
1172 | ++var5;
1173 | } while (var17.exists());
1174 |
1175 | try {
1176 | ImageIO.write(var16, "png", var17);
1177 | } catch (IOException var19) {
1178 | var19.printStackTrace();
1179 | }
1180 | break;
1181 | case 83:
1182 | if (this.sav == null && !this.isApplet) {
1183 | this.save1();
1184 | }
1185 | break;
1186 | case 84:
1187 | this.nibArea = !this.nibArea;
1188 | this.isNibLow = false;
1189 | this.timer.stop();
1190 | this.repaint();
1191 | this.caretVisible = 0;
1192 | this.timer.restart();
1193 | break;
1194 | case 86:
1195 | if (!var4 && !this.isApplet && (var6 = this.fromClipboard(true)) != null) {
1196 | this.pushHObj(new edObj(this.lastPos, (long) var6.length(), 4), var6);
1197 | }
1198 | break;
1199 | case 87:
1200 | this.isOled = !this.isOled;
1201 | this.rePaint();
1202 | break;
1203 | case 89:
1204 | if (this.eObjCtrlY != null) {
1205 | this.pushHObj(this.eObjCtrlY, (String) null);
1206 | this.eObjCtrlY = null;
1207 | } else if (this.byteCtrlY != null) {
1208 | this.eObj.B.push(this.byteCtrlY);
1209 | this.firstPos = ++this.lastPos;
1210 | if (this.scrPos < this.lastPos - (long) this.maxPos) {
1211 | this.scrPos += 16L;
1212 | }
1213 |
1214 | this.doVirtual();
1215 | this.byteCtrlY = null;
1216 | }
1217 | break;
1218 | case 90:
1219 | if (!var4
1220 | && !this.undoStack.empty()
1221 | && (1 < this.undoStack.size()
1222 | || 1 == this.undoStack.size()
1223 | && 2 < ((edObj) this.undoStack.lastElement()).a1)) {
1224 | this.eObj = this.eObjCtrlY = (edObj) this.undoStack.lastElement();
1225 | if (this.eObj.isEditing && !this.eObj.B.empty()) {
1226 | this.byteCtrlY = (Byte) this.eObj.B.pop();
1227 | if (!this.isNibLow) {
1228 | this.firstPos = --this.lastPos;
1229 | } else {
1230 | this.isNibLow = false;
1231 | }
1232 |
1233 | if ((this.eObj.size = (long) this.eObj.B.size()) == 0L) {
1234 | this.undoStack.pop();
1235 | this.byteCtrlY = null;
1236 | } else {
1237 | this.eObjCtrlY = null;
1238 | }
1239 | } else {
1240 | this.firstPos = this.lastPos = this.eObj.p1;
1241 | this.undoStack.pop();
1242 | }
1243 |
1244 | this.doVirtual();
1245 | this.slideScr(this.scrPos, true);
1246 | }
1247 | break;
1248 | case 127:
1249 | case 155:
1250 | if (!var4) {
1251 | this.InsDelB[var1 == 127 ? 0 : 1].setSelected(true);
1252 | this.InsDelTF.setEnabled(true);
1253 | String var7 = this.fromClipboard(false);
1254 | if (JOptionPane.showConfirmDialog(
1255 | this, this.InsDelOption, "Hexeditor.jar: DEL/INS", 2)
1256 | != 2) {
1257 | label298:
1258 | {
1259 | if (this.InsDelB[4].isSelected()) {
1260 | if (!this.isApplet
1261 | && var7 != null
1262 | && this.virtualSize + (long) var7.length()
1263 | < Long.MAX_VALUE) {
1264 | this.pushHObj(
1265 | new edObj(this.lastPos, (long) var7.length(), 6), var7);
1266 | }
1267 | } else {
1268 | if ((var6 = this.InsDelTF.getText()) == null) {
1269 | break label298;
1270 | }
1271 |
1272 | this.String2long(var6);
1273 | if (this.longInput < 1L) {
1274 | break label298;
1275 | }
1276 |
1277 | if (this.InsDelB[0].isSelected()) {
1278 | this.longInput =
1279 | this.longInput + this.lastPos < this.virtualSize
1280 | ? this.longInput
1281 | : this.virtualSize - this.lastPos;
1282 | } else if (Long.MAX_VALUE < this.virtualSize + this.longInput) {
1283 | this.longInput = Long.MAX_VALUE - this.virtualSize;
1284 | }
1285 |
1286 | this.pushHObj(
1287 | new edObj(
1288 | this.lastPos,
1289 | this.longInput,
1290 | this.InsDelB[0].isSelected() ? 8 : 6),
1291 | this.InsDelB[0].isSelected()
1292 | ? null
1293 | : (this.InsDelB[1].isSelected()
1294 | ? " "
1295 | : (this.InsDelB[2].isSelected()
1296 | ? "ÿ"
1297 | : " ")));
1298 | }
1299 |
1300 | this.isNibLow = false;
1301 | this.eObjCtrlY = null;
1302 | this.byteCtrlY = null;
1303 | this.InsDelTF.setText("");
1304 | }
1305 | }
1306 | }
1307 | }
1308 |
1309 | this.focus();
1310 | }
1311 |
1312 | private void pushHObj(edObj var1, String var2) {
1313 | if (!this.undoStack.isEmpty()) {
1314 | (this.eObj = (edObj) this.undoStack.lastElement()).isEditing = false;
1315 | }
1316 |
1317 | if (var2 != null) {
1318 | for (int var3 = 0; var3 < var2.length(); ++var3) {
1319 | var1.B.push(Byte.valueOf((byte) var2.charAt(var3)));
1320 | }
1321 | }
1322 |
1323 | this.undoStack.push(var1);
1324 | this.firstPos = this.lastPos;
1325 | this.doVirtual();
1326 | }
1327 |
1328 | private String fromClipboard(boolean var1) {
1329 | String var4 = null;
1330 | StringBuffer var5 = new StringBuffer();
1331 |
1332 | try {
1333 | var4 =
1334 | (String)
1335 | this.clipboard
1336 | .getContents((Object) null)
1337 | .getTransferData(DataFlavor.stringFlavor);
1338 | if (var4 == null || var4.length() < 1) {
1339 | throw new Exception("nothing to paste");
1340 | }
1341 |
1342 | if (Long.MAX_VALUE < this.lastPos + (long) var4.length()) {
1343 | throw new Exception("file cannot exceed Long.MAX_VALUE");
1344 | }
1345 |
1346 | if (this.nibArea) {
1347 | if (var4.length() % 2 != 0) {
1348 | throw new Exception(
1349 | "Nibble area, String must be an hexa string with odd characters.");
1350 | }
1351 |
1352 | var4 = var4.toUpperCase();
1353 |
1354 | for (int var3 = 0; var3 < var4.length(); var3 += 2) {
1355 | if ("0123456789ABCDEFabcdef".indexOf(var4.charAt(var3)) < 0
1356 | || "0123456789ABCDEFabcdef".indexOf(var4.charAt(var3 + 1)) < 0) {
1357 | throw new Exception("Nibble area, String must be an hexa string.");
1358 | }
1359 |
1360 | var5.append(
1361 | (char)
1362 | (("0123456789ABCDEFabcdef".indexOf(var4.charAt(var3)) << 4)
1363 | + "0123456789ABCDEFabcdef"
1364 | .indexOf(var4.charAt(var3 + 1))));
1365 | }
1366 |
1367 | var4 = var5.toString();
1368 | }
1369 |
1370 | this.clipboardSize = (long) var4.length();
1371 | } catch (Exception var7) {
1372 | var4 = null;
1373 | this.clipboardSize = 0L;
1374 | if (var1) {
1375 | JOptionPane.showMessageDialog(
1376 | this, "Can\'t paste text from the clipboard:\n" + var7);
1377 | }
1378 | }
1379 |
1380 | return var4;
1381 | }
1382 |
1383 | protected void String2long(String var1) {
1384 | this.longInput = -1L;
1385 | boolean var3 = true;
1386 | boolean var4 = true;
1387 | int var5 = -1;
1388 | int var6 = 0;
1389 | int var2;
1390 | if ((var2 = var1.length()) != 0 && !var1.equals("-") && !var1.equals("+")) {
1391 | BigDecimal var7 = null;
1392 | BigInteger var8 = null;
1393 | boolean var9 = false;
1394 | boolean var10 = var1.startsWith("0x") || var1.startsWith("Ox") || var1.startsWith("ox");
1395 | String var11 = "yzafpnµm kMGTPEZY";
1396 | String var12 = "KMGTPE";
1397 | String[] var10000 = new String[] {"c", "d", "da", "h"};
1398 | var1.replaceAll(" ", "");
1399 | if (1 < var1.length() && !var10) {
1400 | if (var9 = 105 == var1.charAt(var1.length() - 1)) {
1401 | var5 = var12.indexOf(var1.charAt(var1.length() - 2));
1402 | } else {
1403 | int var18 =
1404 | var1.endsWith("c")
1405 | ? -2
1406 | : (var1.endsWith("d")
1407 | ? -1
1408 | : (var1.endsWith("da")
1409 | ? 1
1410 | : (var1.endsWith("h")
1411 | ? 2
1412 | : (var1.endsWith("%") ? -2 : 0))));
1413 | int var19 = var11.indexOf(var1.charAt(var1.length() - 1));
1414 | var6 = var18 != 0 ? var18 : (-1 < var19 ? var19 * 3 - 24 : 0);
1415 | }
1416 | }
1417 |
1418 | if (!var9 || var1.length() >= 3 && var5 >= 0) {
1419 | if (var10) {
1420 | if (var1.length() < 3) {
1421 | return;
1422 | }
1423 |
1424 | try {
1425 | var8 = new BigInteger(var1.substring(2, var2), 16);
1426 | } catch (Exception var16) {
1427 | return;
1428 | }
1429 | } else {
1430 | while (0 < var2) {
1431 | try {
1432 | var7 = new BigDecimal(var1.substring(0, var2));
1433 | break;
1434 | } catch (Exception var17) {
1435 | --var2;
1436 | }
1437 | }
1438 |
1439 | if (var2 == 0 || var7 == null) {
1440 | return;
1441 | }
1442 |
1443 | var7 =
1444 | var7.scaleByPowerOfTen(var6)
1445 | .multiply(BigDecimal.valueOf(1L << 10 * (var5 + 1)));
1446 | var8 = var7.toBigInteger();
1447 | }
1448 |
1449 | long var14 = var8.longValue();
1450 | if (var8.signum() < 0) {
1451 | this.longInput = -1L;
1452 | } else if (BigInteger.valueOf(Long.MAX_VALUE).compareTo(var8) < 0) {
1453 | this.longInput = Long.MAX_VALUE;
1454 | } else {
1455 | this.longInput = var14;
1456 | }
1457 | }
1458 | }
1459 | }
1460 |
1461 | public void keyTyped(KeyEvent var1) {
1462 | boolean var3 = this.sav != null || this.find != null;
1463 | char var5 = var1.getKeyChar();
1464 | boolean var6 = false;
1465 | int var7 = "0123456789ABCDEFabcdef".indexOf(Character.toUpperCase(var5));
1466 | if (!var1.isAltDown()
1467 | && !var1.isControlDown()
1468 | && !Character.isISOControl(var5)
1469 | && var5 < 256
1470 | && var1.getSource() == this
1471 | && 0L < this.virtualSize
1472 | && !var3
1473 | && (!this.nibArea || -1 < var7)) {
1474 | if (!this.undoStack.empty() && ((edObj) this.undoStack.lastElement()).isEditing) {
1475 | this.eObj = (edObj) this.undoStack.lastElement();
1476 | } else {
1477 | this.eObj = new edObj(this.lastPos, 0L, 4);
1478 | this.undoStack.push(this.eObj);
1479 | this.eObj.isEditing = true;
1480 | }
1481 |
1482 | if (!this.nibArea) {
1483 | this.eObj.B.push(Byte.valueOf((byte) var5));
1484 | if (this.lastPos < Long.MAX_VALUE) {
1485 | this.firstPos = ++this.lastPos;
1486 | }
1487 | } else if (-1 < "0123456789ABCDEFabcdef".indexOf(var5)) {
1488 | byte var4;
1489 | if ((int) (this.lastPos - this.scrPos) < this.srcV.size()) {
1490 | var4 =
1491 | ((byte[]) ((byte[]) this.srcV.get((int) (this.lastPos - this.scrPos))))
1492 | [0];
1493 | } else {
1494 | var4 = 0;
1495 | }
1496 |
1497 | var4 = (byte) (this.isNibLow ? (var4 & 240) + var7 : (var7 << 4) + (var4 & 15));
1498 | if (this.isNibLow
1499 | && !this.eObj.B.empty()
1500 | && this.eObj.p1 + (long) this.eObj.B.size() == this.lastPos + 1L) {
1501 | this.eObj.B.pop();
1502 | }
1503 |
1504 | this.eObj.B.push(Byte.valueOf(var4));
1505 | if (!(this.isNibLow = !this.isNibLow) && this.lastPos < Long.MAX_VALUE) {
1506 | this.firstPos = ++this.lastPos;
1507 | }
1508 | }
1509 |
1510 | if (this.scrPos < this.lastPos - (long) this.maxPos) {
1511 | this.scrPos += 16L;
1512 | }
1513 |
1514 | this.eObjCtrlY = null;
1515 | this.byteCtrlY = null;
1516 | this.doVirtual();
1517 | }
1518 | }
1519 |
1520 | protected void doVirtual() {
1521 | this.v1.clear();
1522 | if (this.undoStack.isEmpty()) {
1523 | this.scrPos = this.firstPos = this.lastPos = this.virtualSize = 0L;
1524 | this.markV.clear();
1525 | this.MarkV.clear();
1526 | this.jSbSource = false;
1527 | this.jSB.setValue(0);
1528 | this.topPanel.JTFile.setText("");
1529 | this.topPanel.fJTF[1].setText("");
1530 | this.setGrid(this.fontSize);
1531 | this.setSrc();
1532 | this.rePaint();
1533 | this.caretVisible = 0;
1534 | this.timer.restart();
1535 | } else {
1536 | edObj var5 = (edObj) this.undoStack.lastElement();
1537 | if (var5.a1 != 6 && var5.a1 != 8) {
1538 | var5.size = var5.B.size() != 0 ? (long) var5.B.size() : var5.size;
1539 | var5.p2 = var5.p1 + var5.size;
1540 | }
1541 |
1542 | if (!this.isApplet) {
1543 | String var10 = this.topPanel.JTFile.getText();
1544 | if (var10.endsWith(" *")) {
1545 | var10 = var10.substring(0, var10.length() - 2);
1546 | }
1547 |
1548 | this.topPanel.JTFile.setText(var10 + (1 < this.undoStack.size() ? " *" : ""));
1549 | }
1550 |
1551 | var5 = (edObj) this.undoStack.firstElement();
1552 | this.v1.add(new edObj(0L, var5.p2, var5.offset, var5));
1553 |
1554 | for (int var1 = 1; var1 < this.undoStack.size(); ++var1) {
1555 | var5 = (edObj) this.undoStack.get(var1);
1556 | edObj var9 = var5.a1 == 8 ? null : new edObj(var5.p1, var5.p2, var5.offset, var5);
1557 | long var3 = var5.a1 == 6 ? var5.size : (var5.a1 == 8 ? -var5.size : 0L);
1558 | int var2 = this.v1.size() - 1;
1559 | if (var5 != null && var5.p1 != var5.p2) {
1560 | for (; -1 < var2; --var2) {
1561 | edObj var6 = (edObj) this.v1.get(var2);
1562 | if (var2 == this.v1.size() - 1 && var6.p2 == var5.p1) {
1563 | this.v1AddNoNull(var2 + 1, var9);
1564 | break;
1565 | }
1566 |
1567 | if (var5.p2 <= var6.p1) {
1568 | var6.p1 += var3;
1569 | var6.p2 += var3;
1570 | } else {
1571 | if (var5.a1 == 6 && var6.p1 == var5.p1) {
1572 | var6.p1 += var3;
1573 | var6.p2 += var3;
1574 | this.v1AddNoNull(var2, var9);
1575 | break;
1576 | }
1577 |
1578 | if (var5.a1 != 6 && var5.p1 <= var6.p1 && var6.p2 <= var5.p2) {
1579 | this.v1.remove(var2);
1580 | if (var6.p2 == var5.p2) {
1581 | this.v1AddNoNull(var2, var9);
1582 | }
1583 | } else {
1584 | if (var5.a1 != 6 && var5.p1 < var6.p2 && var6.p2 <= var5.p2) {
1585 | if (var6.p2 == var5.p2) {
1586 | this.v1AddNoNull(var2 + 1, var9);
1587 | }
1588 |
1589 | var6.p2 = var5.p1;
1590 | break;
1591 | }
1592 |
1593 | if (var5.a1 == 6 || var5.p1 > var6.p1 || var6.p1 >= var5.p2) {
1594 | if (var6.p1 < var5.p1 && (var5.p2 < var6.p2 || var5.a1 == 6)) {
1595 | edObj var7 = this.v1Clone(var6);
1596 | var7.p2 = var5.p1;
1597 | var6.offset += (var5.a1 == 6 ? var5.p1 : var5.p2) - var6.p1;
1598 | var6.p1 = var5.a1 == 8 ? var5.p1 : var5.p2;
1599 | var6.p2 += var3;
1600 | if (var6.p1 == var6.p2) {
1601 | this.v1.remove(var2);
1602 | }
1603 |
1604 | this.v1AddNoNull(var2, var9);
1605 | this.v1AddNoNull(var2, var7);
1606 | }
1607 | break;
1608 | }
1609 |
1610 | var6.offset += var5.p2 - var6.p1;
1611 | var6.p1 = var5.p2;
1612 | this.v1AddNoNull(var2, var9);
1613 | }
1614 | }
1615 | }
1616 | }
1617 | }
1618 |
1619 | long var12 =
1620 | this.v1 != null && this.v1.size() != 0
1621 | ? ((edObj) this.v1.lastElement()).p2
1622 | : 0L;
1623 | if (this.virtualSize != var12) {
1624 | this.virtualSize = var12;
1625 | this.setGrid(this.fontSize);
1626 | }
1627 |
1628 | this.setSrc();
1629 | this.rePaint();
1630 | this.caretVisible = 0;
1631 | this.timer.restart();
1632 | }
1633 | }
1634 |
1635 | protected void v1AddNoNull(int var1, edObj var2) {
1636 | if (var2 != null && -1 < var1 && var1 <= this.v1.size() && var2.p1 != var2.p2) {
1637 | this.v1.add(var1, var2);
1638 | }
1639 | }
1640 |
1641 | protected edObj v1Clone(edObj var1) {
1642 | if (var1 != null && var1.p1 != var1.p2) {
1643 | edObj var2 = new edObj(var1.p1, var1.p2, var1.offset, var1.o);
1644 | return var2;
1645 | } else {
1646 | return null;
1647 | }
1648 | }
1649 |
1650 | protected Vector virtualStack(long var1, long var3) {
1651 | byte[] var5 = new byte[2];
1652 | int var8 = 0;
1653 | int var10 = 0;
1654 | long var17 = var1;
1655 | edObj var19 = null;
1656 |
1657 | Vector var20;
1658 | for (var20 = new Vector(); var8 < this.v1.size(); ++var8) {
1659 | var19 = (edObj) this.v1.get(var8);
1660 | if (var1 < var19.p2) {
1661 | break;
1662 | }
1663 | }
1664 |
1665 | while (var8 < this.v1.size()) {
1666 | var19 = (edObj) this.v1.get(var8);
1667 | long var11 = var19.p1 - var19.offset;
1668 | long var13 = var19.p2 < var3 ? var19.p2 : var3;
1669 | if (var19.o.a1 != 4 && var19.o.a1 != 2 && (var19.o.a1 != 6 || 1 >= var19.o.B.size())) {
1670 | if (var19.o.a1 == 6) {
1671 | var5[1] = (byte) var19.o.a1;
1672 |
1673 | for (var5[0] = ((Byte) var19.o.B.get(0)).byteValue(); var17 < var13; ++var17) {
1674 | var20.add(var5.clone());
1675 | }
1676 | } else {
1677 | try {
1678 | var5[1] = (byte) (var19.p1 != var19.offset ? 1 : var19.o.a1);
1679 | byte[] var6 = new byte[(int) (var13 - var17)];
1680 | this.rAF.seek(var17 - var11);
1681 | int var9 = 0;
1682 |
1683 | int var7;
1684 | while (var9 < var6.length) {
1685 | var7 = this.rAF.read(var6, var9, var6.length - var9);
1686 | if (var7 < 0) {
1687 | throw new IOException("EOF");
1688 | }
1689 |
1690 | var9 += var7;
1691 | if (var7 == 0) {
1692 | ++var10;
1693 | if (var10 == 9) {
1694 | var17 = var13;
1695 | JOptionPane.showMessageDialog(this, "Unable to access file");
1696 | }
1697 | }
1698 | }
1699 |
1700 | for (var7 = 0; var17 < var13 || var7 < var10; ++var7) {
1701 | var5[0] = var6[var7];
1702 | var20.add(var5.clone());
1703 | ++var17;
1704 | }
1705 | } catch (Exception var22) {
1706 | System.err.println("virtualStack " + var22);
1707 | }
1708 | }
1709 | } else {
1710 | for (var5[1] = (byte) (var19.a1 == 2 && var19.p1 != var19.offset ? 1 : var19.o.a1);
1711 | var17 < var13;
1712 | ++var17) {
1713 | var5[0] = ((Byte) var19.o.B.get((int) (var17 - var11))).byteValue();
1714 | var20.add(var5.clone());
1715 | }
1716 | }
1717 |
1718 | if (var3 < var19.p2) {
1719 | break;
1720 | }
1721 |
1722 | ++var8;
1723 | }
1724 |
1725 | return var20;
1726 | }
1727 |
1728 | protected void setSrc() {
1729 | this.srcV =
1730 | this.virtualStack(
1731 | this.scrPos,
1732 | this.scrPos + (long) this.maxPos + 1L < 0L
1733 | ? Long.MAX_VALUE
1734 | : this.scrPos + (long) this.maxPos + 1L);
1735 | }
1736 |
1737 | protected boolean save1() {
1738 | JFileChooser var1 = new JFileChooser();
1739 | var1.setFileSelectionMode(0);
1740 | var1.setAcceptAllFileFilterUsed(false);
1741 | var1.setDialogTitle("Save as...");
1742 | var1.setDialogType(1);
1743 | var1.setMultiSelectionEnabled(false);
1744 | var1.setDragEnabled(false);
1745 | var1.setFileFilter(new filterRW());
1746 | if (this.f1 != null && this.f1.canWrite()) {
1747 | var1.setSelectedFile(this.f1);
1748 | } else {
1749 | var1.setCurrentDirectory(
1750 | this.f1 == null
1751 | ? new File(System.getProperty("user.dir"))
1752 | : this.f1.getParentFile());
1753 | }
1754 |
1755 | if (var1.showSaveDialog(this) != 0) {
1756 | return false;
1757 | } else {
1758 | this.topPanel.saveRunning(true);
1759 | if (this.sav != null) {
1760 | this.sav.interrupt();
1761 | }
1762 |
1763 | (this.sav = new saveT()).setDaemon(true);
1764 | this.sav.f1 = this.f1;
1765 | this.sav.f2 = var1.getSelectedFile();
1766 | this.sav.v1 = this.v1;
1767 | this.sav.hexV = this;
1768 | this.sav.jPBar = this.topPanel.savePBar;
1769 | this.sav.start();
1770 | return true;
1771 | }
1772 | }
1773 |
1774 | protected void save2(File var1) {
1775 | if (var1 != null) {
1776 | this.f1 = new File(var1, "");
1777 | this.topPanel.JTFile.setText(
1778 | this.f1.toString() + (this.f1.canWrite() ? "" : " (ReadOnly)"));
1779 |
1780 | try {
1781 | this.rAF = new RandomAccessFile(this.f1, "rw");
1782 | } catch (Exception var3) {
1783 | System.err.println(var3);
1784 | }
1785 |
1786 | this.undoStack.clear();
1787 | this.undoStack.push(new edObj(0L, this.f1.length(), 0));
1788 | this.doVirtual();
1789 | }
1790 |
1791 | this.topPanel.saveRunning(false);
1792 | this.sav = null;
1793 | this.eObjCtrlY = null;
1794 | this.byteCtrlY = null;
1795 | }
1796 |
1797 | protected void find1() {
1798 | if (this.virtualSize != 0L
1799 | && (this.topPanel.finByte != null || this.topPanel.findChar != null)) {
1800 | this.String2long(this.topPanel.fJTF[1].getText());
1801 | if (this.find != null) {
1802 | this.find.interrupt();
1803 | }
1804 |
1805 | (this.find = new findT()).setDaemon(true);
1806 | this.find.f1 = this.f1;
1807 | this.find.v1 = this.v1;
1808 | this.find.isApplet = this.isApplet;
1809 | this.find.ignoreCase = this.topPanel.useFindChar;
1810 | this.find.pos =
1811 | this.longInput < 0L
1812 | ? (this.firstPos == this.lastPos ? this.lastPos : this.lastPos + 1L)
1813 | : (this.virtualSize - 1L < this.longInput
1814 | ? this.virtualSize - 1L
1815 | : (this.virtualSize - 1L == this.longInput
1816 | ? 0L
1817 | : this.longInput + 1L));
1818 | this.find.inBytes = this.topPanel.finByte;
1819 | this.find.inChars = this.topPanel.findChar;
1820 | this.find.wordSize = 1 << this.topPanel.fJCB[3].getSelectedIndex();
1821 | this.find.hexV = this;
1822 | this.find.jPBar = this.topPanel.findPBar;
1823 | this.topPanel.findRunning(true);
1824 | this.find.start();
1825 | }
1826 | }
1827 |
1828 | protected void find2(long var1, long var3) {
1829 | this.slideScr(0L, true);
1830 | StringBuffer var5 = new StringBuffer("0x");
1831 | String var6 = Long.toHexString(var3).toUpperCase();
1832 | if (var6.length() % 2 == 1) {
1833 | var5.append("0");
1834 | }
1835 |
1836 | this.topPanel.findRunning(false);
1837 | this.topPanel.fJTF[1].setText(var5.append(var6).toString());
1838 | this.find = null;
1839 | this.lastPos = var3;
1840 | this.firstPos = var1;
1841 | this.isNibLow = false;
1842 | this.slideScr(0L, true);
1843 | }
1844 | }
1845 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/binPanel.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Color;
5 | import java.awt.Dimension;
6 | import java.awt.GridBagConstraints;
7 | import java.awt.GridBagLayout;
8 | import java.awt.Insets;
9 | import java.awt.event.ActionEvent;
10 | import java.awt.event.ActionListener;
11 | import java.awt.event.ItemEvent;
12 | import java.awt.event.ItemListener;
13 | import java.awt.event.MouseEvent;
14 | import java.awt.event.MouseListener;
15 | import java.math.BigDecimal;
16 | import java.math.BigInteger;
17 | import java.nio.charset.Charset;
18 | import java.text.DecimalFormat;
19 | import java.text.DecimalFormatSymbols;
20 | import java.util.Arrays;
21 | import java.util.Locale;
22 | import javax.swing.BorderFactory;
23 | import javax.swing.Box;
24 | import javax.swing.JButton;
25 | import javax.swing.JCheckBox;
26 | import javax.swing.JComboBox;
27 | import javax.swing.JComponent;
28 | import javax.swing.JLabel;
29 | import javax.swing.JMenu;
30 | import javax.swing.JMenuBar;
31 | import javax.swing.JMenuItem;
32 | import javax.swing.JPanel;
33 | import javax.swing.JProgressBar;
34 | import javax.swing.JTextField;
35 | import javax.swing.KeyStroke;
36 | import javax.swing.border.TitledBorder;
37 | import javax.swing.event.CaretEvent;
38 | import javax.swing.event.CaretListener;
39 |
40 | public class binPanel extends JPanel
41 | implements ActionListener, ItemListener, CaretListener, MouseListener {
42 |
43 | JTextField JTFile = new JTextField();
44 | JProgressBar savePBar = new JProgressBar(0, 0, 0);
45 | JProgressBar findPBar = new JProgressBar(0, 0, 0);
46 | binEdit hexV;
47 | JComponent help = this.help();
48 | boolean helpFlag = false;
49 | boolean cp437Available = false;
50 | boolean useFindChar = false;
51 | JComboBox[] viewCBox = new JComboBox[2];
52 | JTextField JTView = new JTextField();
53 | JLabel JTsizes = new JLabel("");
54 | byte[] selection;
55 | JLabel fJL = new JLabel(" ");
56 | JButton[] fJB = new JButton[2];
57 | JComboBox[] fJCB = new JComboBox[4];
58 | JTextField[] fJTF = new JTextField[2];
59 | JCheckBox fJRB = new JCheckBox("Ignore case:");
60 | JPanel jPBBP = new JPanel(new BorderLayout());
61 | JPanel fP0 = new JPanel(new BorderLayout());
62 | JPanel fP1 = this.findPanel();
63 | JPanel stat = this.status();
64 | JPanel frameFile;
65 | byte[] finByte;
66 | byte[] finByteU;
67 | byte[][][] findChar;
68 | JMenuBar menuBar = new JMenuBar();
69 | JMenu menu;
70 | JMenuItem menuItem;
71 | boolean isApplet = false;
72 | boolean hexOffset = true;
73 | slaveT slave;
74 | DecimalFormatSymbols dFS = new DecimalFormatSymbols();
75 | DecimalFormat fForm = new DecimalFormat("#.##########E0");
76 | DecimalFormat dForm = new DecimalFormat("#.###################E0");
77 |
78 | public binPanel(boolean var1, String[] var2) {
79 | this.isApplet = var1;
80 | this.setLayout(new BorderLayout());
81 | String[][] var5 =
82 | new String[][] {
83 | {"File", "Open", "Save as ", "Close file (Q)", "Screen to Png"},
84 | {
85 | "Edit",
86 | "Select All",
87 | "Undo (Z)",
88 | "Redo (Y)",
89 | "Cut (X)",
90 | "Copy",
91 | "Paste (V)",
92 | "Find",
93 | "Insert (before)",
94 | "Delete"
95 | },
96 | {
97 | "View",
98 | "Goto",
99 | "Toggle position Mark",
100 | "Down to next mark",
101 | "Up to previous mark ",
102 | "Toggle caret ",
103 | "Higher fontSize",
104 | "Lower fontSize",
105 | "Black/White background"
106 | },
107 | {"hidden", "Font +", "Font -"},
108 | {"Help", "Toggle help"}
109 | };
110 | int[][] var6 =
111 | new int[][] {
112 | {70, 79, 83, 81, 80},
113 | {69, 65, 90, 89, 88, 67, 86, 70, 155, 127},
114 | {86, 71, 77, 68, 85, 84, 107, 109, 87},
115 | {178, 521, 45},
116 | {72, 72}
117 | };
118 | int[][] var7 =
119 | new int[][] {
120 | {70, 79, 83, 81, 80},
121 | {69, 65, 90, 89, 88, 67, 86, 70, 73, 68},
122 | {86, 71, 77, 68, 85, 84, 72, 76, 87},
123 | {72, 43, 45},
124 | {72, 72}
125 | };
126 | int[][] var8 =
127 | new int[][] {
128 | {0, 2, 2, 2, 2},
129 | {0, 2, 2, 2, 2, 2, 2, 2, 0, 0},
130 | {0, 2, 2, 2, 2, 2, 2, 2, 2},
131 | {0, 2, 2},
132 | {0, 2}
133 | };
134 |
135 | for (int var3 = 0; var3 < var5.length; ++var3) {
136 | (this.menu = new JMenu(var5[var3][0])).setMnemonic(var7[var3][0]);
137 | if (var3 != 0 || !var1) {
138 | for (int var4 = 1; var4 < var5[var3].length; ++var4) {
139 | this.menuItem = new JMenuItem(var5[var3][var4], var7[var3][var4]);
140 | if (var3 != 4) {
141 | this.menuItem.setAccelerator(
142 | KeyStroke.getKeyStroke(var6[var3][var4], var8[var3][var4]));
143 | }
144 |
145 | this.menuItem.addActionListener(this);
146 | this.menu.add(this.menuItem);
147 | if (var3 == 1 && (var4 == 1 || var4 == 3 || var4 == 6 || var4 == 7)
148 | || var3 == 2 && (var4 == 1 || var4 == 4 || var4 == 5 || var4 == 7)) {
149 | this.menu.addSeparator();
150 | }
151 | }
152 | }
153 |
154 | if (var3 != 3) {
155 | this.menuBar.add(this.menu);
156 | }
157 | }
158 |
159 | UI.jRP.setJMenuBar(this.menuBar);
160 | this.add(this.frameFile = this.frame(var2));
161 | this.dFS.setDecimalSeparator('.');
162 | this.fForm.setDecimalFormatSymbols(this.dFS);
163 | this.dForm.setDecimalFormatSymbols(this.dFS);
164 | }
165 |
166 | private JPanel frame(String[] var1) {
167 | this.savePBar.setStringPainted(true);
168 | this.savePBar.setString("");
169 | this.JTView.setEditable(false);
170 | JPanel var2 = new JPanel(new GridBagLayout());
171 | GridBagConstraints var3 = new GridBagConstraints();
172 | var3.fill = 2;
173 | var3.weightx = 1.0D;
174 | var3.gridx = var3.gridy = 0;
175 | this.JTFile.setEditable(false);
176 | var2.add(this.JTFile, var3);
177 | ++var3.gridy;
178 | var2.add(this.jPBBP, var3);
179 | ++var3.gridy;
180 | var2.add(this.fP0, var3);
181 | ++var3.gridy;
182 | var2.add(Box.createVerticalStrut(3), var3);
183 | var3.fill = 1;
184 | var3.weighty = 1.0D;
185 | ++var3.gridy;
186 | var2.add(this.hexV = new binEdit(this, this.isApplet), var3);
187 | var3.fill = 2;
188 | var3.weighty = 0.0D;
189 | ++var3.gridy;
190 | var2.add(this.stat, var3);
191 | this.fJCB[2].setSelectedIndex(6);
192 | if (var1 != null && 0 < var1.length) {
193 | if (var1[0].equals("-slave")) {
194 | (this.slave = new slaveT()).setDaemon(true);
195 | this.slave.hexV = this.hexV;
196 | this.slave.start();
197 | } else {
198 | this.hexV.loadFile(new java.io.File(var1[0]));
199 | }
200 | }
201 |
202 | return var2;
203 | }
204 |
205 | public JComponent help() {
206 | jEP var1 = new jEP((String) null, false);
207 | var1.setContentType("text/html");
208 | String var2 = Locale.getDefault().getLanguage();
209 | var2 = "ReadMe" + Character.toUpperCase(var2.charAt(0)) + var2.charAt(1) + ".htm";
210 |
211 | try {
212 | var1.eP
213 | .getEditorKit()
214 | .read(
215 | UI.class
216 | .getResource(
217 | UI.class.getResource(var2) == null
218 | ? "ReadMeEn.htm"
219 | : var2)
220 | .openStream(),
221 | var1.eP.getDocument(),
222 | 0);
223 | var1.eP
224 | .getEditorKit()
225 | .read(
226 | UI.class.getResource("shortKey.htm").openStream(),
227 | var1.eP.getDocument(),
228 | var1.eP.getDocument().getLength());
229 | } catch (Exception var4) {;
230 | }
231 |
232 | return var1;
233 | }
234 |
235 | private JPanel findPanel() {
236 | String[][] var3 =
237 | new String[][] {
238 | {"BE", "LE"},
239 | {"Signed", "Unsigned"},
240 | {
241 | "Short (16)",
242 | "Int (32)",
243 | "Long (64)",
244 | "Float (32)",
245 | "Double (64)",
246 | "Hexa",
247 | "ISO/CEI 8859-1",
248 | "UTF-8",
249 | "UTF-16"
250 | },
251 | {"8 bits", "16 bits", "32 bits", "64 bits", "128 bits"},
252 | {
253 | "Big-indian (natural order) or Little-indian (Intel order).",
254 | "Only for integer",
255 | "Data type",
256 | "Select \'64\' if you search a machine instruction for a 64 bits processor. If you don\'t know, left it at \'8\'."
257 | },
258 | {"BE", "Unsigned", "ISO/CEI 8859-1", "128 bits"},
259 | {"Next", "Hide"}
260 | };
261 | JPanel var4 = new JPanel(new GridBagLayout());
262 | JPanel var5 = new JPanel(new GridBagLayout());
263 | JPanel var6 = new JPanel(new GridBagLayout());
264 | var4.setBorder(BorderFactory.createTitledBorder("Find:"));
265 | ((TitledBorder) var4.getBorder()).setTitleColor(Color.blue);
266 | GridBagConstraints var7 = new GridBagConstraints();
267 | var7.anchor = 21;
268 | var4.add(var5, var7);
269 | var7.fill = 2;
270 | ++var7.gridx;
271 | var4.add(var6, var7);
272 | this.findPBar.setStringPainted(true);
273 | var4.add(this.findPBar, var7);
274 | var5.add(this.fJTF[0] = new JTextField());
275 | this.fJTF[0].addCaretListener(this);
276 | var5.add(new JLabel(" "));
277 | var5.add(this.fJL);
278 |
279 | int var1;
280 | for (var1 = 0; var1 < this.fJCB.length; ++var1) {
281 | this.fJCB[var1] = new JComboBox();
282 | this.fJCB[var1].setPrototypeDisplayValue(var3[5][var1]);
283 | this.fJCB[var1].setToolTipText(var3[4][var1]);
284 |
285 | for (int var2 = 0; var2 < var3[var1].length; ++var2) {
286 | this.fJCB[var1].addItem(var3[var1][var2]);
287 | }
288 |
289 | this.fJCB[var1].addItemListener(this);
290 | var6.add(this.fJCB[var1]);
291 | }
292 |
293 | this.fJRB.setHorizontalTextPosition(2);
294 | this.fJRB.setMargin(new Insets(0, 1, 0, 1));
295 | this.fJRB.addActionListener(this);
296 | var6.add(this.fJRB);
297 | this.fJTF[0].setPreferredSize(
298 | new Dimension(
299 | this.fJCB[0].getPreferredSize().width
300 | + this.fJCB[1].getPreferredSize().width
301 | + this.fJCB[2].getPreferredSize().width
302 | + this.fJCB[3].getPreferredSize().width,
303 | this.fJTF[0].getPreferredSize().height));
304 | var6.add(Box.createHorizontalGlue());
305 | var6.add(new JLabel(" From:"));
306 | var6.add(this.fJTF[1] = new JTextField(15));
307 |
308 | for (var1 = 0; var1 < this.fJB.length; ++var1) {
309 | this.fJB[var1] = new JButton(var3[6][var1]);
310 | this.fJB[var1].setMargin(new Insets(3, 2, 3, 2));
311 | this.fJB[var1].addActionListener(this);
312 | var6.add(this.fJB[var1]);
313 | }
314 |
315 | return var4;
316 | }
317 |
318 | private JPanel status() {
319 | String[][] var1 =
320 | new String[][] {
321 | {"BE", "LE "},
322 | {
323 | "Binary",
324 | "Byte, signed/unsigned ",
325 | "Short (16), signed",
326 | "Short (16), unsigned",
327 | "Int (32), signed",
328 | "Int (32), unsigned",
329 | "Long (64), signed",
330 | "Long (64), unsigned",
331 | "Float (32)",
332 | "Double (64)",
333 | "DOS-US/OEM-US/cp437",
334 | "UTF-8",
335 | "UTF-16"
336 | },
337 | {
338 | "Big-Endian (natural order) or little-Endian (Intel order).",
339 | "Conversion rule for the data following the caret (shown here after)."
340 | }
341 | };
342 |
343 | try {
344 | if (!(this.cp437Available = Charset.isSupported("cp437"))) {
345 | var1[1][10] = "ISO/CEI 8859-1";
346 | }
347 | } catch (Exception var6) {;
348 | }
349 |
350 | JPanel var4 = new JPanel(new GridBagLayout());
351 | var4.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
352 | GridBagConstraints var5 = new GridBagConstraints();
353 | var5.fill = 1;
354 | var5.insets = new Insets(0, 0, 0, 0);
355 |
356 | for (int var2 = 0; var2 < this.viewCBox.length; ++var2) {
357 | this.viewCBox[var2] = new JComboBox();
358 | this.viewCBox[var2].setPrototypeDisplayValue(var1[var2][1]);
359 | this.viewCBox[var2].setToolTipText(var1[2][var2]);
360 |
361 | for (int var3 = 0; var3 < var1[var2].length; ++var3) {
362 | this.viewCBox[var2].addItem(var1[var2][var3]);
363 | }
364 |
365 | ++var5.gridx;
366 | var4.add(this.viewCBox[var2], var5);
367 | }
368 |
369 | this.viewCBox[1].setSelectedIndex(1);
370 | var5.weightx = 1.0D;
371 | ++var5.gridx;
372 | this.JTView.setPreferredSize(
373 | new Dimension(
374 | this.JTView.getPreferredSize().width,
375 | this.viewCBox[0].getMinimumSize().height));
376 | var4.add(this.JTView, var5);
377 | var5.weightx = 0.0D;
378 | ++var5.gridx;
379 | var4.add(Box.createHorizontalStrut(3), var5);
380 | ++var5.gridx;
381 | var4.add(this.JTsizes, var5);
382 | ++var5.gridx;
383 | var4.add(Box.createHorizontalStrut(3), var5);
384 | this.viewCBox[0].addItemListener(this);
385 | this.viewCBox[1].addItemListener(this);
386 | this.JTsizes.addMouseListener(this);
387 | return var4;
388 | }
389 |
390 | public void actionPerformed(ActionEvent var1) {
391 | if (var1.getSource() == this.fJRB) {
392 | this.checkFindEntry();
393 | } else if (var1.getSource() == this.fJB[0] && this.fJB[0].getText() == "Next") {
394 | this.hexV.find1();
395 | } else if (var1.getSource() == this.fJB[0] && this.fJB[0].getText() == "Stop") {
396 | this.hexV.find.interrupt();
397 | } else if (var1.getSource() == this.fJB[1]) {
398 | this.fP0.removeAll();
399 | this.validate();
400 | this.repaint();
401 | this.hexV.slideScr(-1L, false);
402 | } else if (var1.getSource().getClass().isInstance(new JMenuItem())) {
403 | boolean var2 =
404 | ((JMenuItem) ((JMenuItem) var1.getSource())).getText().equals("Toggle help");
405 | if (var2 || this.helpFlag) {
406 | this.removeAll();
407 | if (this.helpFlag) {
408 | this.add(this.frameFile);
409 | } else {
410 | this.add(this.help);
411 | }
412 |
413 | this.validate();
414 | this.repaint();
415 | }
416 |
417 | this.helpFlag = !this.helpFlag && var2;
418 | if (!var2) {
419 | this.hexV.KeyFromMenu(((JMenuItem) var1.getSource()).getAccelerator().getKeyCode());
420 | }
421 | }
422 | }
423 |
424 | public void itemStateChanged(ItemEvent var1) {
425 | if (var1.getSource() != this.viewCBox[0] && var1.getSource() != this.viewCBox[1]) {
426 | if (var1.getSource() == this.fJCB[2]) {
427 | int var2 = this.fJCB[2].getSelectedIndex();
428 | this.fJCB[0].setEnabled(var2 < 5 || var2 == 8);
429 | this.fJCB[1].setEnabled(var2 < 3);
430 | this.fJRB.setEnabled(5 < var2);
431 | }
432 |
433 | this.checkFindEntry();
434 | } else {
435 | this.hexV.rePaint();
436 | }
437 | }
438 |
439 | public void caretUpdate(CaretEvent var1) {
440 | this.checkFindEntry();
441 | }
442 |
443 | protected void saveRunning(boolean var1) {
444 | if (var1) {
445 | this.jPBBP.add(this.savePBar);
446 | } else {
447 | this.jPBBP.removeAll();
448 | }
449 |
450 | this.savePBar.setValue(0);
451 | this.validate();
452 | this.repaint();
453 | }
454 |
455 | protected void find() {
456 | this.findPBar.setString("");
457 | this.fP0.add(this.fP1, "West");
458 | this.validate();
459 | this.repaint();
460 | }
461 |
462 | protected void findRunning(boolean var1) {
463 | boolean var2 = false;
464 | this.fJB[0].setText(var1 ? "Stop" : "Next");
465 | this.fJB[1].setEnabled(!var1);
466 | this.findPBar.setValue(0);
467 | if (!var1) {
468 | this.findPBar.setString("");
469 | }
470 | }
471 |
472 | private void checkFindEntry() {
473 | boolean var1 = false;
474 | BigDecimal var3 = null;
475 | double var11 = 0.0D;
476 | float var14 = 0.0F;
477 | long var15 = System.currentTimeMillis();
478 | long[] var17 = new long[2];
479 | StringBuffer var18 = new StringBuffer(220);
480 | var18.append("");
481 |
482 | while (System.currentTimeMillis() < var15 + 50L) {;
483 | }
484 |
485 | String var19 = this.fJTF[0].getText();
486 | String var20 = null;
487 | int var21 = var19.length();
488 | int var22 = this.fJCB[2].getSelectedIndex();
489 | boolean var24 = false;
490 | boolean var25 = false;
491 | this.useFindChar = this.fJRB.isSelected() && 5 < var22;
492 | if (var21 == 0) {
493 | this.fJL.setText(" ");
494 | } else {
495 | int var32;
496 | int var23;
497 | if (var22 < 5
498 | && !var19.startsWith("0x")
499 | && !var19.startsWith("Ox")
500 | && !var19.startsWith("ox")) {
501 | if (var19.charAt(0) == 45 && this.fJCB[1].getSelectedIndex() == 1 && var22 < 3) {
502 | this.fJL.setText(
503 | "Input must be positive for unsigned integer. ");
504 | return;
505 | }
506 |
507 | if (var19.equals("-") || var19.equals("+")) {
508 | this.fJL.setText(" ");
509 | return;
510 | }
511 |
512 | BigDecimal var4 =
513 | var22 == 0
514 | ? BigDecimal.valueOf(-32768L)
515 | : (var22 == 1
516 | ? BigDecimal.valueOf(-2147483648L)
517 | : (var22 == 2
518 | ? BigDecimal.valueOf(Long.MIN_VALUE)
519 | : (var22 == 3
520 | ? BigDecimal.valueOf(
521 | -3.4028234663852886E38D)
522 | : BigDecimal.valueOf(
523 | -1.7976931348623157E308D))));
524 | BigDecimal var5;
525 | if (2 < var22) {
526 | var5 =
527 | var22 == 3
528 | ? BigDecimal.valueOf(3.4028234663852886E38D)
529 | : BigDecimal.valueOf(Double.MAX_VALUE);
530 | } else if (this.fJCB[1].getSelectedIndex() == 0) {
531 | var5 =
532 | var22 == 0
533 | ? BigDecimal.valueOf(32767L)
534 | : (var22 == 1
535 | ? BigDecimal.valueOf(2147483647L)
536 | : BigDecimal.valueOf(Long.MAX_VALUE));
537 | } else {
538 | var5 =
539 | var22 == 0
540 | ? BigDecimal.valueOf(65535L)
541 | : (var22 == 1
542 | ? BigDecimal.valueOf(4294967295L)
543 | : new BigDecimal("18446744073709551615"));
544 | }
545 |
546 | this.finByte = new byte[var22 < 3 ? 2 << var22 : (var22 == 3 ? 4 : 8)];
547 |
548 | while (0 < var21) {
549 | try {
550 | var3 = new BigDecimal(var19.substring(0, var21));
551 | if (var3.compareTo(var4) >= 0 && var5.compareTo(var3) >= 0) {
552 | break;
553 | }
554 |
555 | throw new Exception("");
556 | } catch (Exception var31) {
557 | --var21;
558 | }
559 | }
560 |
561 | if (var21 == 0) {
562 | this.fJL.setText("Input must be a number. ");
563 | } else if (var22 < 3) {
564 | BigInteger var7;
565 | try {
566 | var7 = var3.setScale(0, 7).unscaledValue();
567 | } catch (Exception var27) {
568 | var7 = var3.setScale(0, 5).unscaledValue();
569 | var1 = true;
570 | }
571 |
572 | if (var7.signum() < 0) {
573 | var15 = var7.longValue();
574 | if (this.fJCB[0].getSelectedIndex() == 0) {
575 | for (var23 = 0; var23 < this.finByte.length; ++var23) {
576 | this.finByte[this.finByte.length - var23 - 1] =
577 | (byte) ((int) (var15 & 255L));
578 | var15 >>>= 8;
579 | }
580 | } else {
581 | for (var23 = 0; var23 < this.finByte.length; ++var23) {
582 | this.finByte[var23] = (byte) ((int) (var15 & 255L));
583 | var15 >>>= 8;
584 | }
585 | }
586 | } else {
587 | byte[] var2 = var7.toByteArray();
588 | var32 =
589 | this.finByte.length < var2.length
590 | ? this.finByte.length
591 | : var2.length;
592 | Arrays.fill(this.finByte, (byte) 0);
593 | if (this.fJCB[0].getSelectedIndex() == 0) {
594 | for (var23 = 1; var23 <= var32; ++var23) {
595 | this.finByte[this.finByte.length - var23] =
596 | var2[var2.length - var23];
597 | }
598 | } else {
599 | for (var23 = 0; var23 < var32; ++var23) {
600 | this.finByte[var23] = var2[var2.length - 1 - var23];
601 | }
602 | }
603 | }
604 | } else {
605 | float var13 = var3.floatValue();
606 | double var9 = var3.doubleValue();
607 | this.useFindChar =
608 | var1 =
609 | 0
610 | != (var32 =
611 | var3.compareTo(
612 | new BigDecimal(
613 | var22 == 3
614 | ? (double) var13
615 | : var9)));
616 | var15 =
617 | var17[0] =
618 | var22 == 3
619 | ? (long) Float.floatToRawIntBits(var13)
620 | : Double.doubleToRawLongBits(var9);
621 | if (this.fJCB[0].getSelectedIndex() == 0) {
622 | for (var23 = 0; var23 < this.finByte.length; ++var23) {
623 | this.finByte[this.finByte.length - var23 - 1] =
624 | (byte) ((int) (var15 & 255L));
625 | var15 >>>= 8;
626 | }
627 | } else {
628 | for (var23 = 0; var23 < this.finByte.length; ++var23) {
629 | this.finByte[var23] = (byte) ((int) (var15 & 255L));
630 | var15 >>>= 8;
631 | }
632 | }
633 |
634 | if (this.useFindChar) {
635 | var17[1] =
636 | var22 == 3
637 | ? (long)
638 | Float.floatToRawIntBits(
639 | var14 =
640 | 0 < var32
641 | ? math.nextUp(var13)
642 | : math.nextDown(var13))
643 | : Double.doubleToRawLongBits(
644 | var11 =
645 | 0 < var32
646 | ? math.nextUp(var9)
647 | : math.nextDown(var9));
648 | if (var22 == 3) {
649 | var18.append(var32 < 0 ? "< " : "> ")
650 | .append(this.fForm.format(new BigDecimal((double) var13)))
651 | .append(" " + (var32 < 0 ? "> " : "< "))
652 | .append(this.fForm.format(new BigDecimal((double) var14)));
653 | } else {
654 | var18.append(var32 < 0 ? "< " : "> ")
655 | .append(this.dForm.format(new BigDecimal(var9)))
656 | .append(" " + (var32 < 0 ? "> " : "< "))
657 | .append(this.dForm.format(new BigDecimal(var11)));
658 | }
659 |
660 | this.findChar = new byte[1][2][var22 == 3 ? 4 : 8];
661 |
662 | for (var32 = 0; var32 < 2; ++var32) {
663 | if (this.fJCB[0].getSelectedIndex() == 0) {
664 | for (var23 = 0; var23 < this.findChar[0][var32].length; ++var23) {
665 | this.findChar[0][var32][this.finByte.length - var23 - 1] =
666 | (byte) ((int) (var17[var32] & 255L));
667 | var17[var32] >>>= 8;
668 | }
669 | } else {
670 | for (var23 = 0; var23 < this.findChar[0][var32].length; ++var23) {
671 | this.findChar[0][var32][var23] =
672 | (byte) ((int) (var17[var32] & 255L));
673 | var17[var32] >>>= 8;
674 | }
675 | }
676 | }
677 | }
678 | }
679 | } else if (var22 == 5) {
680 | var19 = var19.trim().replaceAll(" ", "");
681 | if (var19.startsWith("0x") || var19.startsWith("Ox") || var19.startsWith("ox")) {
682 | var19 = var19.substring(2);
683 | }
684 |
685 | for (var21 = 0;
686 | var21 < var19.length()
687 | && -1 < "0123456789abcdefABCDEF".indexOf(var19.charAt(var21));
688 | ++var21) {;
689 | }
690 |
691 | if (var21 < 2) {
692 | this.fJL.setText(
693 | var21 == var19.length()
694 | ? " "
695 | : "Input must be a hexa string. ");
696 | return;
697 | }
698 |
699 | this.finByte = new byte[var21 >> 1];
700 |
701 | try {
702 | for (var23 = 0; var23 < this.finByte.length; ++var23) {
703 | this.finByte[var23] =
704 | (byte)
705 | Integer.parseInt(
706 | var19.substring(var23 << 1, var23 * 2 + 2), 16);
707 | }
708 | } catch (Exception var30) {;
709 | }
710 | } else if (var22 == 6) {
711 | while (0 < var21) {
712 | try {
713 | var20 = var19.substring(0, var21);
714 | this.finByte = var20.getBytes("ISO-8859-1");
715 | if (!var20.equals(new String(this.finByte, "ISO-8859-1"))) {
716 | throw new Exception("");
717 | }
718 | break;
719 | } catch (Exception var28) {
720 | --var21;
721 | }
722 | }
723 |
724 | if (var21 < 1) {
725 | this.fJL.setText(
726 | "Input must be an ISO-8859-1 string. ");
727 | return;
728 | }
729 | } else {
730 | while (0 < var21) {
731 | try {
732 | var20 = var19.substring(0, var21);
733 | this.finByte =
734 | var20.getBytes(
735 | var22 == 7
736 | ? "UTF-8"
737 | : (this.fJCB[0].getSelectedIndex() == 0
738 | ? "UTF-16BE"
739 | : "UTF-16LE"));
740 | break;
741 | } catch (Exception var29) {
742 | --var21;
743 | }
744 | }
745 |
746 | if (var21 < 1) {
747 | this.fJL.setText("Input must be an UTF string. ");
748 | return;
749 | }
750 | }
751 |
752 | if (var22 < 3 || 4 < var22 || !var1) {
753 | for (var23 = 0; var23 < this.finByte.length; ++var23) {
754 | var32 = this.finByte[var23] & 255;
755 | var18.append(
756 | (var32 < 16 ? "0" : "") + Integer.toHexString(var32).toUpperCase());
757 | if ((var23 + 1) % 16 == 0) {
758 | var18.append(" ");
759 | } else if ((var23 + 1) % (1 << this.fJCB[3].getSelectedIndex()) == 0) {
760 | var18.append(" ");
761 | }
762 | }
763 | }
764 |
765 | var19 = var19.toUpperCase();
766 | if (var21 == var19.length() - 1
767 | && (var22 >= 5 || var19.charAt(var19.length() - 1) != 69)) {
768 | var18.append("The last char is invalid. ");
769 | } else if (var21 < var19.length() - 1
770 | && (var21 != var19.length() - 2
771 | || var22 >= 5
772 | || var19.charAt(var19.length() - 2) != 69
773 | || var19.charAt(var19.length() - 1) != 43
774 | && var19.charAt(var19.length() - 1) != 45)) {
775 | var18.append("The last ")
776 | .append(var19.length() - var21)
777 | .append(" caracters are invalid. ");
778 | }
779 |
780 | if (var1 && !this.useFindChar) {
781 | var18.append(
782 | "The binary doesn\'t represent exactly the significand. ");
783 | }
784 |
785 | this.fJL.setText(var18.toString());
786 | if (var20 != null
787 | && 0 < var20.length()
788 | && this.fJRB.isSelected()
789 | && !var20.toUpperCase().equals(var20.toLowerCase())) {
790 | var20 = var20.toUpperCase();
791 | this.findChar = new byte[var20.length()][][];
792 |
793 | for (var21 = 0; var21 < var20.length(); ++var21) {
794 | char var8 = var20.charAt(var21);
795 | var23 = var8 == Character.toLowerCase(var8) ? 1 : 2;
796 | if (1 < var23) {
797 | for (var22 = 0; var22 < accent.s.length; ++var22) {
798 | if (-1 < accent.s[var22].indexOf(var8)) {
799 | var23 = accent.s[var22].length();
800 | break;
801 | }
802 | }
803 | }
804 |
805 | this.findChar[var21] = new byte[var23][];
806 |
807 | for (var32 = 0; var32 < var23; ++var32) {
808 | if (var23 < 3) {
809 | var8 = var32 == 0 ? var8 : Character.toUpperCase(var8);
810 | } else if (var22 < accent.s.length) {
811 | var8 = accent.s[var22].charAt(var32);
812 | }
813 |
814 | if (var22 == 6) {
815 | this.findChar[var21][var32] = new byte[1];
816 | this.findChar[var21][var32][0] =
817 | var8 < 256 ? (byte) var8 : this.findChar[var21][0][0];
818 | } else if (var22 == 8) {
819 | this.findChar[var21][var32] = new byte[2];
820 | this.findChar[var21][var32][1 - this.fJCB[0].getSelectedIndex()] =
821 | (byte) (var8 & 255);
822 | this.findChar[var21][var32][this.fJCB[0].getSelectedIndex()] =
823 | (byte) (var8 >> 8);
824 | } else {
825 | this.findChar[var21][var32] =
826 | new byte
827 | [var8 < 128
828 | ? 1
829 | : (var8 < 2048 ? 2 : (var8 < 65536 ? 3 : 4))];
830 | if (var8 < 128) {
831 | this.findChar[var21][var32][0] = (byte) var8;
832 | } else {
833 | int var33;
834 | for (var33 = this.findChar[var21][var32].length - 1;
835 | 0 < var33;
836 | --var33) {
837 | this.findChar[var21][var32][var33] = (byte) (var8 & 63 | 128);
838 | var8 = (char) (var8 >> 6);
839 | }
840 |
841 | var33 = this.findChar[var21][var32].length;
842 | this.findChar[var21][var32][0] =
843 | (byte)
844 | (var8
845 | | (var33 == 2
846 | ? 192
847 | : (var33 == 3 ? 224 : 240)));
848 | }
849 | }
850 | }
851 | }
852 | }
853 | }
854 | }
855 |
856 | public void mouseReleased(MouseEvent var1) {}
857 |
858 | public void mouseEntered(MouseEvent var1) {}
859 |
860 | public void mouseExited(MouseEvent var1) {}
861 |
862 | public void mousePressed(MouseEvent var1) {}
863 |
864 | public void mouseClicked(MouseEvent var1) {
865 | this.hexOffset = !this.hexOffset;
866 | this.hexV.setStatus();
867 | }
868 | }
869 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/edObj.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.util.Stack;
4 |
5 | class edObj {
6 |
7 | int a1;
8 | public long p1 = -1L;
9 | public long p2 = -1L;
10 | public long offset = 0L;
11 | public long size = 0L;
12 | public boolean isEditing = false;
13 | edObj o = null;
14 | public Stack B = new Stack();
15 |
16 | public edObj(long var1, long var3, int var5) {
17 | this.p1 = var1;
18 | this.a1 = var5;
19 | this.size = var3;
20 | this.p2 = this.p1 + var3;
21 | }
22 |
23 | public edObj(long var1, long var3, long var5, edObj var7) {
24 | this.p1 = var1;
25 | this.p2 = var3;
26 | this.offset = var5;
27 | this.o = var7;
28 | }
29 |
30 | public String toString() {
31 | return this.o != null
32 | ? "p//offset: "
33 | + this.p1
34 | + "/"
35 | + this.p2
36 | + "//"
37 | + this.offset
38 | + " \to.a1: "
39 | + this.o.a1
40 | + " \to.B.size/o.size: "
41 | + this.o.B.size()
42 | + "/"
43 | + this.o.size
44 | : "p: "
45 | + this.p1
46 | + "/"
47 | + this.p2
48 | + " \ta1: "
49 | + this.a1
50 | + " \tB.size/size: "
51 | + this.B.size()
52 | + "/"
53 | + this.size;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/filterRW.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.io.File;
4 | import javax.swing.filechooser.FileFilter;
5 |
6 | class filterRW extends FileFilter {
7 |
8 | public boolean accept(File var1) {
9 | return var1.canWrite();
10 | }
11 |
12 | public String getDescription() {
13 | return "";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/findT.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.IOException;
6 | import java.util.Vector;
7 | import javax.swing.JProgressBar;
8 |
9 | class findT extends Thread {
10 |
11 | File f1;
12 | Vector v1;
13 | boolean isApplet;
14 | boolean ignoreCase;
15 | long pos;
16 | byte[] inBytes = null;
17 | byte[][][] inChars = (byte[][][]) null;
18 | binEdit hexV;
19 | JProgressBar jPBar;
20 | private boolean isFound = false;
21 | private int realLength = 0;
22 | private int inCharsLength = 0;
23 | protected int wordSize;
24 | private long virtualSize;
25 | private Vector pile = new Vector();
26 |
27 | public void run() {
28 | boolean var1 = false;
29 | boolean var3 = false;
30 | FileInputStream var5 = null;
31 | byte[] var6 = new byte[2097152];
32 | edObj var7 = null;
33 | if (this.v1 != null && this.v1.size() != 0) {
34 | long var12 = 0L;
35 | this.virtualSize = ((edObj) this.v1.lastElement()).p2;
36 | this.jPBar.setMaximum(1073741824);
37 | int var2;
38 | int var4;
39 | int var18;
40 | if (!this.ignoreCase) {
41 | this.inCharsLength = this.inBytes.length;
42 | } else {
43 | for (var2 = 0; var2 < this.inChars.length; ++var2) {
44 | var4 = 0;
45 |
46 | for (var18 = 0; var18 < this.inChars[var2].length; ++var18) {
47 | var4 =
48 | var4 < this.inChars[var2][var18].length
49 | ? var4
50 | : this.inChars[var2][var18].length;
51 | }
52 |
53 | this.inCharsLength += var4;
54 | }
55 | }
56 |
57 | for (var18 = 0; var18 < this.v1.size(); ++var18) {
58 | var7 = (edObj) this.v1.get(var18);
59 | if (this.pos < var7.p2) {
60 | break;
61 | }
62 | }
63 |
64 | try {
65 | if (this.f1 != null) {
66 | var5 = new FileInputStream(this.f1);
67 | }
68 |
69 | while (var18 < this.v1.size() && this.next()) {
70 | var7 = (edObj) this.v1.get(var18);
71 | long var8 = var7.p1 - var7.offset;
72 | if (var7.o.a1 != 4
73 | && var7.o.a1 != 2
74 | && (var7.o.a1 != 6 || 1 >= var7.o.B.size())) {
75 | if (var7.o.a1 == 6) {
76 | byte var17 = ((Byte) var7.o.B.get(0)).byteValue();
77 |
78 | while (this.pos < var7.p2 && this.next()) {
79 | this.findB(var17);
80 | if (this.pile.size() == 0
81 | && this.pos < var7.p2 - (long) this.inCharsLength) {
82 | this.pos = var7.p2 - (long) this.inCharsLength;
83 | }
84 | }
85 | } else {
86 | long var10;
87 | for (var10 = this.pos - var8;
88 | var12 < var10;
89 | var12 += var5.skip(var10 - var12)) {;
90 | }
91 |
92 | while (this.pos < var7.p2 && this.next()) {
93 | var10 = var7.p2 - this.pos;
94 | var2 = var5.read(var6, 0, var10 < 2097152L ? (int) var10 : 2097152);
95 | if (var2 <= 0) {
96 | throw new IOException(
97 | var2 == 0 ? "Unable to access file" : "EOF");
98 | }
99 |
100 | var12 += (long) var2;
101 |
102 | for (var4 = 0; var4 < var2 && this.next(); ++var4) {
103 | this.findB(var6[var4]);
104 | }
105 |
106 | this.setJPBar();
107 | }
108 | }
109 | } else {
110 | while (this.pos < var7.p2 && this.next()) {
111 | this.findB(((Byte) var7.o.B.get((int) (this.pos - var8))).byteValue());
112 | }
113 | }
114 |
115 | this.setJPBar();
116 | ++var18;
117 | }
118 |
119 | if (this.f1 != null) {
120 | var5.close();
121 | }
122 | } catch (Exception var16) {
123 | System.err.println(
124 | "findT " + var16 + "\n\t" + var7 + "\n\t" + var18 + "\t" + this.pos);
125 | }
126 |
127 | try {
128 | var5.close();
129 | } catch (Exception var15) {;
130 | }
131 |
132 | this.hexV.find2(
133 | this.pos,
134 | this.pos
135 | - (long)
136 | (this.isFound
137 | ? (this.ignoreCase
138 | ? this.realLength
139 | : this.inBytes.length)
140 | : 0));
141 | }
142 | }
143 |
144 | protected void setJPBar() {
145 | this.jPBar.setValue((int) (1.07374182E9F * ((float) this.pos / (float) this.virtualSize)));
146 | this.jPBar.setString(
147 | (float) ((int) ((float) this.pos / ((float) this.virtualSize / 1000.0F))) / 10.0F
148 | + "%");
149 | }
150 |
151 | private boolean next() {
152 | return !this.isFound && !Thread.currentThread().isInterrupted();
153 | }
154 |
155 | private void findB(byte var1) {
156 | int[] var6 = new int[4];
157 | int var3;
158 | int var4;
159 | if (!this.ignoreCase) {
160 | for (var3 = this.pile.size() - 1; -1 < var3; --var3) {
161 | var4 = ((Integer) this.pile.get(var3)).intValue();
162 | if (this.inBytes[var4] != var1) {
163 | this.pile.remove(var3);
164 | } else {
165 | if (var4 + 1 >= this.inBytes.length) {
166 | this.isFound = true;
167 | break;
168 | }
169 |
170 | this.pile.set(var3, new Integer(var4 + 1));
171 | }
172 | }
173 |
174 | if (var1 == this.inBytes[0] && this.pos % (long) this.wordSize == 0L) {
175 | this.pile.add(new Integer(1));
176 | if (this.inBytes.length == 1) {
177 | this.isFound = true;
178 | }
179 | }
180 | } else {
181 | for (var3 = this.pile.size() - 1; -1 < var3; --var3) {
182 | var6 = (int[]) ((int[]) this.pile.get(var3));
183 | ++var6[2];
184 | ++var6[3];
185 | if (this.inChars[var6[0]][var6[1]].length <= var6[2]) {
186 | ++var6[0];
187 | var6[1] = var6[2] = 0;
188 | }
189 |
190 | if (this.inChars.length <= var6[0]) {
191 | this.pile.remove(var3);
192 | } else if (var1 == this.inChars[var6[0]][var6[1]][var6[2]]) {
193 | this.pile.set(var3, var6.clone());
194 | if (var6[2] + 1 == this.inChars[var6[0]][var6[1]].length
195 | && var6[0] + 1 == this.inChars.length) {
196 | this.isFound = true;
197 | }
198 | } else {
199 | for (var4 = var6[1] + 1; var4 < this.inChars[var6[0]].length; ++var4) {
200 | int var5;
201 | for (var5 = 0;
202 | var5 < var6[2]
203 | && var5 < this.inChars[var6[0]][var4].length
204 | && this.inChars[var6[0]][var4][var5]
205 | == this.inChars[var6[0]][var6[1]][var5];
206 | ++var5) {;
207 | }
208 |
209 | if (var5 < var6[2]) {
210 | this.pile.remove(var3);
211 | break;
212 | }
213 |
214 | if (var1 == this.inChars[var6[0]][var4][var5]) {
215 | var6[1] = var4;
216 | this.pile.set(var3, var6.clone());
217 | if (var6[2] + 1 == this.inChars[var6[0]][var6[1]].length
218 | && var6[0] + 1 == this.inChars.length) {
219 | this.isFound = true;
220 | }
221 | break;
222 | }
223 |
224 | if (var4 + 1 == this.inChars[var6[0]].length) {
225 | this.pile.remove(var3);
226 | break;
227 | }
228 | }
229 |
230 | if (var6[0] + 1 == this.inChars.length
231 | && var6[1] + 1 == this.inChars[0].length
232 | && var6[2] + 1 == this.inChars[0][1].length) {
233 | this.pile.remove(var3);
234 | }
235 | }
236 |
237 | if (this.isFound) {
238 | this.realLength = var6[3];
239 | break;
240 | }
241 | }
242 |
243 | if (this.pos % (long) this.wordSize == 0L) {
244 | for (var3 = 0; var3 < this.inChars[0].length; ++var3) {
245 | if (var1 == this.inChars[0][var3][0]) {
246 | var6[0] = var6[2] = 0;
247 | var6[1] = var3;
248 | var6[3] = 1;
249 | this.pile.add(var6.clone());
250 | if (this.inChars.length + this.inChars[0][var3].length == 2) {
251 | this.isFound = true;
252 | this.realLength = var6[3];
253 | }
254 | break;
255 | }
256 | }
257 | }
258 | }
259 |
260 | ++this.pos;
261 | }
262 | }
263 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/jEP.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.net.URL;
4 | import java.text.MessageFormat;
5 | import javax.swing.JEditorPane;
6 | import javax.swing.JScrollPane;
7 | import javax.swing.event.HyperlinkEvent;
8 | import javax.swing.event.HyperlinkEvent.EventType;
9 | import javax.swing.event.HyperlinkListener;
10 |
11 | class jEP extends JScrollPane implements HyperlinkListener {
12 |
13 | JEditorPane eP = new JEditorPane();
14 | String s1;
15 | public String s2 = null;
16 |
17 | public jEP(String var1, boolean var2) {
18 | super(22, 30);
19 | this.eP.addHyperlinkListener(this);
20 | this.eP.setText(var1);
21 | this.s1 = var1;
22 | this.eP.setEditable(var2);
23 | this.eP.setCaretPosition(0);
24 | this.getViewport().setView(this.eP);
25 | }
26 |
27 | public void setContentType(String var1) {
28 | this.eP.setContentType(var1);
29 | }
30 |
31 | public void setUrl(URL var1) {
32 | try {
33 | this.eP.setPage(var1);
34 | this.eP.setCaretPosition(0);
35 | } catch (Exception var3) {
36 | this.eP.setText("Help file not found");
37 | }
38 | }
39 |
40 | public void hyperlinkUpdate(HyperlinkEvent var1) {
41 | if (var1.getEventType() == EventType.ACTIVATED) {
42 | UI.browse = var1.getURL().toString();
43 | this.Browser2(var1.getURL());
44 | }
45 | }
46 |
47 | public void Browser2(URL var1) {
48 | String var2 = System.getProperty("os.name");
49 | String var5 = new String(var1.toExternalForm());
50 |
51 | try {
52 | String var3;
53 | MessageFormat var4;
54 | Object[] var6;
55 | if (var2.startsWith("Win")) {
56 | var6 = new Object[] {var1.toString()};
57 | String var7 =
58 | -1 >= var2.indexOf("9") && -1 >= var2.indexOf("Me")
59 | ? "cmd.exe /c start \"\" \"{0}\""
60 | : "command.com /c start \"{0}\"";
61 | var4 = new MessageFormat(var7);
62 | var3 = var4.format(var6);
63 | if (var1.getProtocol().equals("file")) {
64 | throw new Exception(
65 | "This class doesn\'t allow the opening a file, avoiding evil code.");
66 | }
67 |
68 | if (var1.toString().startsWith("mailto:")) {
69 | throw new Exception("This class doesn\'t allow the opening of mailto: .");
70 | }
71 | } else if (var2.startsWith("Mac OS")) {
72 | var6 = new Object[] {var5, var1.toString()};
73 | var4 = new MessageFormat("open -a /Applications/Safari.app {0}");
74 | var3 = var4.format(var6);
75 | } else {
76 | var6 = new Object[] {var5, var1.toString()};
77 | var4 = new MessageFormat(System.getProperty("mozilla {0}"));
78 | var3 = var4.format(var6);
79 | }
80 |
81 | Runtime.getRuntime().exec(var3);
82 | } catch (Exception var8) {
83 | System.err.println("Could not invoke browser: " + var8);
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/math.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | class math {
4 |
5 | public static double nextUp(double var0) {
6 | if (!Double.isNaN(var0) && var0 != Double.POSITIVE_INFINITY) {
7 | var0 += 0.0D;
8 | return Double.longBitsToDouble(
9 | Double.doubleToRawLongBits(var0) + (var0 >= 0.0D ? 1L : -1L));
10 | } else {
11 | return var0;
12 | }
13 | }
14 |
15 | public static float nextUp(float var0) {
16 | if (!Float.isNaN(var0) && var0 != Float.POSITIVE_INFINITY) {
17 | var0 += 0.0F;
18 | return Float.intBitsToFloat(Float.floatToRawIntBits(var0) + (var0 >= 0.0F ? 1 : -1));
19 | } else {
20 | return var0;
21 | }
22 | }
23 |
24 | public static double nextDown(double var0) {
25 | return !Double.isNaN(var0) && var0 != Double.NEGATIVE_INFINITY
26 | ? (var0 == 0.0D
27 | ? -4.9E-324D
28 | : Double.longBitsToDouble(
29 | Double.doubleToRawLongBits(var0) + (var0 > 0.0D ? -1L : 1L)))
30 | : var0;
31 | }
32 |
33 | public static float nextDown(float var0) {
34 | return !Float.isNaN(var0) && var0 != Float.NEGATIVE_INFINITY
35 | ? (var0 == 0.0F
36 | ? -1.4E-45F
37 | : Float.intBitsToFloat(
38 | Float.floatToRawIntBits(var0) + (var0 > 0.0F ? -1 : 1)))
39 | : var0;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/saveT.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.io.BufferedOutputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileOutputStream;
7 | import java.io.IOException;
8 | import java.util.Arrays;
9 | import java.util.Vector;
10 | import javax.swing.JOptionPane;
11 | import javax.swing.JProgressBar;
12 |
13 | class saveT extends Thread {
14 |
15 | File f1;
16 | File f2;
17 | Vector v1;
18 | binEdit hexV;
19 | JProgressBar jPBar;
20 | private long time;
21 | private long virtualSize;
22 | private long pos;
23 |
24 | public void run() {
25 | boolean var1 = false;
26 | int var3 = 0;
27 | FileInputStream var5 = null;
28 | byte[] var8 = new byte[2097152];
29 | if (this.v1 != null && this.v1.size() != 0) {
30 | long var14 = 0L;
31 | this.pos = 0L;
32 | this.time = System.currentTimeMillis();
33 | this.virtualSize = ((edObj) this.v1.lastElement()).p2;
34 | this.jPBar.setMaximum(1073741824);
35 |
36 | edObj var9;
37 | while (var3 < this.v1.size()) {
38 | var9 = (edObj) this.v1.get(var3);
39 | if (this.pos < var9.p2) {
40 | break;
41 | }
42 |
43 | ++var3;
44 | }
45 |
46 | BufferedOutputStream var16 = null;
47 |
48 | try {
49 | if (this.f1 != null) {
50 | var5 = new FileInputStream(this.f1);
51 | }
52 |
53 | File var6 = new File(this.f2.getPath() + ".TMP");
54 |
55 | for (var16 = new BufferedOutputStream(new FileOutputStream(var6), 2097152);
56 | var3 < this.v1.size() && this.next();
57 | ++var3) {
58 | var9 = (edObj) this.v1.get(var3);
59 | long var10 = var9.p1 - var9.offset;
60 | this.pos = var9.p1;
61 | if (var9.o.a1 != 4
62 | && var9.o.a1 != 2
63 | && (var9.o.a1 != 6 || 1 >= var9.o.B.size())) {
64 | int var2;
65 | long var12;
66 | if (var9.o.a1 == 6) {
67 | Arrays.fill(var8, ((Byte) var9.o.B.get(0)).byteValue());
68 |
69 | while (this.pos < var9.p2 && this.next()) {
70 | var12 = var9.p2 - this.pos;
71 | var2 = var12 < 2097152L ? (int) var12 : 2097152;
72 | var16.write(var8, 0, var2);
73 | this.pos += (long) var2;
74 | this.setJPBar();
75 | }
76 | } else {
77 | for (var12 = this.pos - var10;
78 | var14 < var12;
79 | var14 += var5.skip(var12 - var14)) {;
80 | }
81 |
82 | while (this.pos < var9.p2 && this.next()) {
83 | var12 = var9.p2 - this.pos;
84 | var2 = var5.read(var8, 0, var12 < 2097152L ? (int) var12 : 2097152);
85 | if (var2 <= 0) {
86 | throw new IOException(
87 | var2 == 0 ? "Unable to access file" : "EOF");
88 | }
89 |
90 | var14 += (long) var2;
91 | var16.write(var8, 0, var2);
92 | this.pos += (long) var2;
93 | this.setJPBar();
94 | }
95 | }
96 | } else {
97 | while (this.pos < var9.p2 && this.next()) {
98 | var16.write(
99 | ((Byte) var9.o.B.get((int) (this.pos - var10))).byteValue());
100 | ++this.pos;
101 | }
102 |
103 | this.setJPBar();
104 | }
105 | }
106 |
107 | var16.close();
108 | if (var5 != null) {
109 | var5.close();
110 | }
111 |
112 | if (this.hexV.rAF != null) {
113 | this.hexV.rAF.close();
114 | }
115 |
116 | if (this.f1 != null && this.f1.equals(this.f2)) {
117 | File var7 = new File(this.f1.getParent(), this.f1.getName() + ".bak");
118 | if (var7.exists()) {
119 | var7.delete();
120 | }
121 |
122 | this.f1.renameTo(var7);
123 | }
124 |
125 | var6.renameTo(this.f2);
126 | this.hexV.save2(this.f2);
127 | } catch (Exception var20) {
128 | JOptionPane.showMessageDialog(this.hexV, var20);
129 | this.hexV.save2((File) null);
130 | }
131 |
132 | try {
133 | var16.close();
134 | } catch (Exception var19) {;
135 | }
136 |
137 | try {
138 | var5.close();
139 | } catch (Exception var18) {;
140 | }
141 | }
142 | }
143 |
144 | protected void setJPBar() {
145 | this.jPBar.setValue((int) (1.07374182E9F * ((float) this.pos / (float) this.virtualSize)));
146 | this.jPBar.setString(
147 | this.toTime(this.pos, this.virtualSize, System.currentTimeMillis() - this.time));
148 | }
149 |
150 | private boolean next() {
151 | return !Thread.currentThread().isInterrupted();
152 | }
153 |
154 | private String toTime(long var1, long var3, long var5) {
155 | StringBuffer var7 =
156 | new StringBuffer(
157 | Float.toString(
158 | (float) ((int) ((float) var1 / ((float) var3 / 1000.0F))) / 10.0F));
159 | var7.append("% saved");
160 | if (var1 != 0L) {
161 | var5 = var5 / 1000L * (var3 / var1);
162 | }
163 |
164 | if (var5 == Long.MAX_VALUE) {
165 | return "";
166 | } else {
167 | long[] var8 = new long[] {86400L, 3600L, 60L, 1L};
168 | String[] var9 = new String[] {"D ", "H ", "mn ", "s "};
169 | int var11 = 0;
170 | var7.append(", time remaining ");
171 |
172 | for (int var10 = 0; var10 < var8.length && var11 < 2; ++var10) {
173 | long var12;
174 | if ((var12 = var5 / var8[var10]) != 0L || var11 == 1) {
175 | if (var12 < 10L && 0 < var11) {
176 | var7.append("0");
177 | }
178 |
179 | var7.append(var12).append(var9[var10]);
180 | var5 %= var8[var10];
181 | ++var11;
182 | }
183 | }
184 |
185 | return var7.toString();
186 | }
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/src/main/java/com/github/hexeditor/slaveT.java:
--------------------------------------------------------------------------------
1 | package com.github.hexeditor;
2 |
3 | import java.awt.event.ActionEvent;
4 | import java.awt.event.ActionListener;
5 | import java.io.BufferedReader;
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.io.InputStreamReader;
9 | import java.util.Vector;
10 | import javax.swing.Timer;
11 |
12 | class slaveT extends Thread implements ActionListener {
13 |
14 | binEdit hexV;
15 | Timer timer = new Timer(300, this);
16 | private BufferedReader bR;
17 |
18 | slaveT() {
19 | this.bR = new BufferedReader(new InputStreamReader(System.in));
20 | }
21 |
22 | public void run() {
23 | this.timer.addActionListener(this);
24 | this.timer.start();
25 | }
26 |
27 | public void actionPerformed(ActionEvent var1) {
28 | boolean var2 = true;
29 | boolean var3 = false;
30 | int var4 = 0;
31 | int var5 = 0;
32 | String var9 = null;
33 | StringBuffer var11 = new StringBuffer();
34 | Vector var12 = new Vector();
35 | if (var1.getSource() == this.timer) {
36 | this.timer.stop();
37 |
38 | try {
39 | if (!this.bR.ready()) {
40 | this.timer.setDelay(300);
41 | } else {
42 | var9 = this.bR.readLine().replaceAll(" ", " ");
43 | this.timer.setDelay(50);
44 | }
45 | } catch (IOException var14) {;
46 | }
47 |
48 | if (var9 != null && 0 < var9.length()) {
49 | for (; var5 < var9.length(); ++var5) {
50 | var2 = true;
51 | if (var9.charAt(var5) == 34) {
52 | var2 = !var2;
53 | } else if (var2 && var9.charAt(var5) == 32) {
54 | var12.add(var9.substring(var4, var5));
55 | var4 = var5 + 1;
56 | }
57 | }
58 |
59 | var12.add(var9.substring(var4, var5));
60 | if (0 < var12.size()) {
61 | var9 = (String) var12.firstElement();
62 | if (var9.equals("-goto") && var12.size() == 2) {
63 | this.hexV.goTo((String) var12.elementAt(1));
64 | } else if ((var9.equals("-Mark")
65 | || var9.equals("-mark")
66 | || var9.equals("-delmark")
67 | || var9.equals("-delMark"))
68 | && 1 < var12.size()) {
69 | for (var4 = 1; var4 < var12.size(); ++var4) {
70 | try {
71 | Long var8 = Long.valueOf((String) var12.elementAt(var4));
72 | if (var9.equals("-Mark") && !this.hexV.MarkV.contains(var8)) {
73 | this.hexV.MarkV.add(var8);
74 | } else if (var9.equals("-mark")
75 | && !this.hexV.markV.contains(var8)) {
76 | this.hexV.markV.add(var8);
77 | } else if (var9.equals("-delMark")) {
78 | this.hexV.MarkV.remove(var8);
79 | } else if (var9.equals("-delmark")) {
80 | this.hexV.markV.remove(var8);
81 | }
82 | } catch (Exception var15) {;
83 | }
84 | }
85 | } else if (var9.equals("-file") && var12.size() == 2) {
86 | var9 = (String) var12.elementAt(1);
87 | if (var2 = (var9.length() & 3) == 0) {
88 | var4 = 0;
89 |
90 | while (var4 < var9.length() - 3 && var2) {
91 | long var6 = 0L;
92 |
93 | for (var5 = 0; var5 < 4 && var2; ++var5) {
94 | char var16 = var9.charAt(var4);
95 | var2 = 48 <= var16 && var16 <= 57 || 65 <= var16 && var16 <= 90;
96 | var6 =
97 | (var6 << 4)
98 | + (long) var16
99 | - (long) (48 <= var16 && var16 <= 57 ? 48 : 55);
100 | ++var4;
101 | }
102 |
103 | var11.append((char) ((int) var6));
104 | }
105 | }
106 |
107 | this.hexV.loadFile(new File(var11.toString()));
108 | } else if (var9.equals("-close")) {
109 | this.hexV.closeFile();
110 | }
111 | }
112 | }
113 |
114 | this.timer.restart();
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/resources/com/github/hexeditor/ReadMeEn.htm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javadev/hexeditor/e8eaaca4cb584ceedffbe352fa595c4d6f7c5f4f/src/main/resources/com/github/hexeditor/ReadMeEn.htm
--------------------------------------------------------------------------------
/src/main/resources/com/github/hexeditor/ReadMeFr.htm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/javadev/hexeditor/e8eaaca4cb584ceedffbe352fa595c4d6f7c5f4f/src/main/resources/com/github/hexeditor/ReadMeFr.htm
--------------------------------------------------------------------------------
/src/main/resources/com/github/hexeditor/shortKey.htm:
--------------------------------------------------------------------------------
1 |
2 | File menu usage
3 | Ctrl+O Open a file.
4 | Ctrl+S Save.
5 | Ctrl+Q Leave (close) the current file.
6 | Ctrl+P Create a png of the current screen.
7 |
8 |
9 |
10 | Edit menu usage
11 | Ctrl+A Select all.
12 | Ctrl+Z Undo the last modification.
13 | Ctrl+X Copy then cut.
14 | Ctrl+C Copy.
15 | Ctrl+V Paste.
16 | Ctrl+F Find dialog box.
17 | Insert/delete Insert/delete dialog box.
18 |
19 |
20 |
21 | View menu usage
22 | Ctrl+G Goto dialog box.
23 | Ctrl+M Toggle position mark between tiny line, bold line or no mark.
24 | Ctrl+D Go down to the next mark, or the end of the file.
25 | Ctrl+U Go up to previous mark, or the beginning of the file.
26 | Ctrl+T Toggle caret between nibble area and text area.
27 | Ctrl+H Change the font to higher size.
28 | Ctrl+L Change the font to lower size.
29 | Ctrl+W Toggle Black/White background, usefull for OLED screen.
30 |
31 |
32 |
33 | Other usage
34 | Arrow Left/Right Move cursor to left/right.
35 | Shift+Arrow Left/Right Move cursor with selection to the Left/Right.
36 | Arrow Up/Down Move cursor up/down one line.
37 | Shift+Arrow Up Selecting lines in an upwards direction.
38 | Shift+Arrow Down Selecting lines in a downward direction.
39 | Home Go to beginning of line.
40 | Shift+Home Go and select to the beginning of a line.
41 | End Go to end of line.
42 | Shift+End Go and select to end of line.
43 | Ctrl+Home Go to start of document.
44 | Ctrl+Shift+Home Go and select text to start of document.
45 | Ctrl+End Go to end of document.
46 | Ctrl+Shift+End Go and select text to end of document.
47 | Insert/delete Insert/delete dialog box.
48 | PageUp/PageDown Screen page up / page down.
49 | Shift+PageUp Move up screen page with selection.
50 | Shift+PageDown Move down screen page with selection.
51 | Ctrl+Mouse wheel Change the font size.
52 |
53 |
54 |
--------------------------------------------------------------------------------