Source Code Cross Referenced for PESection.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:         * PESection.java
023:         *
024:         * Created on 29 juillet 2003, 21:34
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 PESection implements  Cloneable {
038:            byte[] ANSI_Name; //  	Name of the Section. Can be anything (0)(8BYTES)
039:            long VirtualSize; // 	The size of the section when it is mapped to memory. Must be a multiple of 4096. (8)(DWORD)
040:            long VirtualAddress; // 	An rva to where it should be mapped in memory. (12)(DWORD)
041:            long SizeOfRawData; // 	The size of the section in the PE file. Must be a multiple of 512 (16)(DWORD)
042:            long PointerToRawData; // 	A file based offset which points to the location of this sections data (20)(DWORD)
043:            long PointerToRelocations; // 	In EXE's this field is meaningless, and is set 0 (24)(DWORD)
044:            long PointerToLinenumbers; // 	This is the file-based offset of the line number table. This field is only used for debug purposes, and is usualy set to 0 (28)(DWORD)
045:            int NumberOfRelocations; // 	In EXE's this field is meaningless, and is set 0 (32)(WORD)
046:            int NumberOfLinenumbers; // 	The number of line numbers in the line number table for this section. This field is only used for debug purposes, and is usualy set to 0 (34)(WORD)
047:            long Characteristics; // 	The kind of data stored in this section ie. Code, Data, Import data, Relocation data (36)(DWORD)
048:
049:            private long m_baseoffset;
050:            private PEFile m_pe;
051:
052:            /** Creates a new instance of PESection */
053:            public PESection(PEFile pef, long baseoffset) {
054:                m_pe = pef;
055:                m_baseoffset = baseoffset;
056:            }
057:
058:            public Object clone() throws CloneNotSupportedException {
059:                return super .clone();
060:            }
061:
062:            public String getName() {
063:                StringBuffer buffer = new StringBuffer();
064:                for (int i = 0; i < 8; i++)
065:                    buffer.append((char) ANSI_Name[i]);
066:                return buffer.toString();
067:            }
068:
069:            public void read() throws IOException {
070:                FileChannel ch = m_pe.getChannel();
071:                ByteBuffer head = ByteBuffer.allocate(40);
072:                head.order(ByteOrder.LITTLE_ENDIAN);
073:                ch.position(m_baseoffset);
074:                ch.read(head);
075:                head.position(0);
076:
077:                ANSI_Name = new byte[8];
078:                for (int i = 0; i < 8; i++)
079:                    ANSI_Name[i] = head.get();
080:
081:                VirtualSize = head.getInt();
082:                VirtualAddress = head.getInt();
083:                SizeOfRawData = head.getInt();
084:                PointerToRawData = head.getInt();
085:                PointerToRelocations = head.getInt();
086:                PointerToLinenumbers = head.getInt();
087:                NumberOfRelocations = head.getShort();
088:                NumberOfLinenumbers = head.getShort();
089:                Characteristics = head.getInt();
090:            }
091:
092:            public void dump(PrintStream out) {
093:                out.println("SECTION:");
094:                out.print("  Name= ");
095:                for (int i = 0; i < 8; i++)
096:                    out.print((char) ANSI_Name[i]);
097:                out.println("");
098:                out
099:                        .println("  VirtualSize= "
100:                                + VirtualSize
101:                                + "  // 	The size of the section when it is mapped to memory. Must be a multiple of 4096. (8)(DWORD)");
102:                out
103:                        .println("  VirtualAddress= "
104:                                + VirtualAddress
105:                                + "   // 	An rva to where it should be mapped in memory. (12)(DWORD)");
106:                out
107:                        .println("  SizeOfRawData= "
108:                                + SizeOfRawData
109:                                + "   // 	The size of the section in the PE file. Must be a multiple of 512 (16)(DWORD)");
110:                out
111:                        .println("  PointerToRawData= "
112:                                + PointerToRawData
113:                                + "   // 	A file based offset which points to the location of this sections data (20)(DWORD)");
114:                out
115:                        .println("  PointerToRelocations= "
116:                                + PointerToRelocations
117:                                + "   // 	In EXE's this field is meaningless, and is set 0 (24)(DWORD)");
118:                out
119:                        .println("  PointerToLinenumbers= "
120:                                + PointerToLinenumbers
121:                                + "   // 	This is the file-based offset of the line number table. This field is only used for debug purposes, and is usualy set to 0 (28)(DWORD)");
122:                out
123:                        .println("  NumberOfRelocations= "
124:                                + NumberOfRelocations
125:                                + "   // 	In EXE's this field is meaningless, and is set 0 (32)(WORD)");
126:                out
127:                        .println("  NumberOfLinenumbers= "
128:                                + NumberOfLinenumbers
129:                                + "   // 	The number of line numbers in the line number table for this section. This field is only used for debug purposes, and is usualy set to 0 (34)(WORD)");
130:                out
131:                        .println("  Characteristics= "
132:                                + Characteristics
133:                                + "   // 	The kind of data stored in this section ie. Code, Data, Import data, Relocation data (36)(DWORD)");
134:
135:            }
136:
137:            public ByteBuffer get() {
138:                ByteBuffer head = ByteBuffer.allocate(40);
139:                head.order(ByteOrder.LITTLE_ENDIAN);
140:                head.position(0);
141:
142:                for (int i = 0; i < 8; i++)
143:                    head.put((byte) ANSI_Name[i]);
144:
145:                head.putInt((int) VirtualSize);
146:                head.putInt((int) VirtualAddress);
147:                head.putInt((int) SizeOfRawData);
148:                head.putInt((int) PointerToRawData);
149:                head.putInt((int) PointerToRelocations);
150:                head.putInt((int) PointerToLinenumbers);
151:                head.putShort((short) NumberOfRelocations);
152:                head.putShort((short) NumberOfLinenumbers);
153:                head.putInt((int) Characteristics);
154:
155:                head.position(0);
156:                return head;
157:            }
158:
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.