Source Code Cross Referenced for PEOldMSHeader.java in  » Installer » jsmooth » net » charabia » jsmoothgen » pe » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Installer » jsmooth » net.charabia.jsmoothgen.pe 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          JSmooth: a VM wrapper toolkit for Windows
003:          Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
004:
005:          This program is free software; you can redistribute it and/or modify
006:          it under the terms of the GNU General Public License as published by
007:          the Free Software Foundation; either version 2 of the License, or
008:          (at your option) any later version.
009:
010:          This program is distributed in the hope that it will be useful,
011:          but WITHOUT ANY WARRANTY; without even the implied warranty of
012:          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:          GNU General Public License for more details.
014:
015:          You should have received a copy of the GNU General Public License
016:          along with this program; if not, write to the Free Software
017:          Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
018:
019:         */
020:
021:        /*
022:         * PEOldMSHeader.java
023:         *
024:         * Created on 28 juillet 2003, 22:05
025:         */
026:
027:        package net.charabia.jsmoothgen.pe;
028:
029:        import java.io.*;
030:        import java.nio.*;
031:        import java.nio.channels.*;
032:
033:        /**
034:         *
035:         * @author  Rodrigo
036:         */
037:        public class PEOldMSHeader implements  Cloneable {
038:            int e_cblp; // Bytes on last page of file //  2
039:            int e_cp; // Pages in file //  4
040:            int e_crlc; // Relocations //  6
041:            int e_cparhdr; // Size of header in paragraphs //  8
042:            int e_minalloc; // Minimum extra paragraphs needed //  A
043:            int e_maxalloc; // Maximum extra paragraphs needed //  C
044:            int e_ss; // Initial (relative) SS value //  E
045:            int e_sp; // Initial SP value // 10
046:            int e_csum; // Checksum // 12
047:            int e_ip; // Initial IP value // 14
048:            int e_cs; // Initial (relative) CS value // 16
049:            int e_lfarlc; // File address of relocation table // 18
050:            int e_ovno; // Overlay number // 1A
051:            int[] e_res = new int[4]; // Reserved words // 1C
052:            int e_oemid; // OEM identifier (for e_oeminfo) // 24
053:            int e_oeminfo; // OEM information; e_oemid specific // 26
054:            int[] e_res2 = new int[10]; // Reserved words // 28
055:            long e_lfanew; // File address of new exe header // 3C
056:
057:            private PEFile m_pe;
058:
059:            /** Creates a new instance of PEOldMSHeader */
060:            public PEOldMSHeader(PEFile pe) {
061:                m_pe = pe;
062:            }
063:
064:            public Object clone() throws CloneNotSupportedException {
065:                return super .clone();
066:            }
067:
068:            public void read() throws IOException {
069:                FileChannel ch = m_pe.getChannel();
070:                ByteBuffer mz = ByteBuffer.allocate(64);
071:                mz.order(ByteOrder.LITTLE_ENDIAN);
072:
073:                ch.read(mz, 0);
074:                mz.position(0);
075:
076:                byte m = mz.get();
077:                byte z = mz.get();
078:                if ((m == 77) && (z == 90)) {
079:                    //		System.out.println("MZ found !");
080:                }
081:
082:                e_cblp = mz.getShort(); // Bytes on last page of file //  2
083:                e_cp = mz.getShort(); // Pages in file //  4
084:                e_crlc = mz.getShort(); // Relocations //  6
085:                e_cparhdr = mz.getShort(); // Size of header in paragraphs //  8
086:                e_minalloc = mz.getShort(); // Minimum extra paragraphs needed //  A
087:                e_maxalloc = mz.getShort(); // Maximum extra paragraphs needed //  C
088:                e_ss = mz.getShort(); // Initial (relative) SS value //  E
089:                e_sp = mz.getShort(); // Initial SP value // 10
090:                e_csum = mz.getShort(); // Checksum // 12
091:                e_ip = mz.getShort(); // Initial IP value // 14
092:                e_cs = mz.getShort(); // Initial (relative) CS value // 16
093:                e_lfarlc = mz.getShort(); // File address of relocation table // 18
094:                e_ovno = mz.getShort(); // Overlay number // 1A
095:
096:                for (int i = 0; i < 4; i++)
097:                    e_res[i] = mz.getShort();
098:
099:                e_oemid = mz.getShort(); // OEM identifier (for e_oeminfo) // 24
100:                e_oeminfo = mz.getShort(); // OEM information; e_oemid specific // 26
101:
102:                for (int i = 0; i < 10; i++)
103:                    e_res2[i] = mz.getShort(); // Reserved words // 28
104:
105:                e_lfanew = mz.getInt(); // File address of new exe header // 3C
106:
107:                //	System.out.println("exe header : " + e_lfanew);
108:            }
109:
110:            public void dump(PrintStream out) {
111:                out.println("MSHeader:");
112:
113:                out.println("e_cblp: " + e_cblp
114:                        + " // Bytes on last page of file //  2");
115:                out.println("e_cp: " + e_cp + " // Pages in file //  4");
116:                out.println("e_crlc: " + e_crlc + " // Relocations //  6");
117:                out.println("e_cparhdr: " + e_cparhdr
118:                        + " // Size of header in paragraphs //  8");
119:                out.println("e_minalloc: " + e_minalloc
120:                        + " // Minimum extra paragraphs needed //  A");
121:                out.println("e_maxalloc: " + e_maxalloc
122:                        + " // Maximum extra paragraphs needed //  C");
123:                out.println("e_ss: " + e_ss
124:                        + " // Initial (relative) SS value //  E");
125:                out.println("e_sp: " + e_sp + " // Initial SP value // 10");
126:                out.println("e_csum: " + e_csum + " // Checksum // 12");
127:                out.println("e_ip: " + e_ip + " // Initial IP value // 14");
128:                out.println("e_cs: " + e_cs
129:                        + " // Initial (relative) CS value // 16");
130:                out.println("e_lfarlc: " + e_lfarlc
131:                        + " // File address of relocation table // 18");
132:                out.println("e_ovno: " + e_ovno + " // Overlay number // 1A");
133:                //	int[] e_res = new int[4];        // Reserved words // 1C
134:                out.println("e_oemid: " + e_oemid
135:                        + " // OEM identifier (for e_oeminfo) // 24");
136:                out.println("e_oeminfo: " + e_oeminfo
137:                        + " // OEM information; e_oemid specific // 26");
138:                //	int[] e_res2 = new int[10];      // Reserved words // 28
139:                out.println("e_lfanew: " + e_lfanew
140:                        + " // File address of new exe header // 3C");
141:            }
142:
143:            public ByteBuffer get() {
144:                ByteBuffer mz = ByteBuffer.allocate(64);
145:                mz.order(ByteOrder.LITTLE_ENDIAN);
146:                mz.position(0);
147:
148:                mz.put((byte) 77);
149:                mz.put((byte) 90);
150:
151:                mz.putShort((short) e_cblp); // Bytes on last page of file //  2
152:                mz.putShort((short) e_cp); // Pages in file //  4
153:                mz.putShort((short) e_crlc); // Relocations //  6
154:                mz.putShort((short) e_cparhdr); // Size of header in paragraphs //  8
155:
156:                mz.putShort((short) e_minalloc); // Minimum extra paragraphs needed //  A
157:                mz.putShort((short) e_maxalloc); // Maximum extra paragraphs needed //  C
158:                mz.putShort((short) e_ss); // Initial (relative) SS value //  E
159:                mz.putShort((short) e_sp); // Initial SP value // 10
160:                mz.putShort((short) e_csum); // Checksum // 12
161:                mz.putShort((short) e_ip); // Initial IP value // 14
162:                mz.putShort((short) e_cs); // Initial (relative) CS value // 16
163:                mz.putShort((short) e_lfarlc); // File address of relocation table // 18
164:                mz.putShort((short) e_ovno); // Overlay number // 1A
165:
166:                for (int i = 0; i < 4; i++)
167:                    mz.putShort((short) e_res[i]);
168:
169:                mz.putShort((short) e_oemid); // OEM identifier (for e_oeminfo) // 24
170:                mz.putShort((short) e_oeminfo); // OEM information; e_oemid specific // 26
171:
172:                for (int i = 0; i < 10; i++)
173:                    mz.putShort((short) e_res2[i]); // Reserved words // 28
174:
175:                mz.putInt((int) e_lfanew); // File address of new exe header // 3C
176:
177:                mz.position(0);
178:                return mz;
179:            }
180:
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.