Class IconExe
- java.lang.Object
-
- org.eclipse.pde.internal.swt.tools.IconExe
-
public class IconExe extends java.lang.ObjectCustomize the icon of a Windows exe WARNING! This class is not part of SWT API. It is NOT API. It is an internal tool that may be changed or removed at anytime. Based on MSDN "An In-Depth Look into the Win32 Portable Executable File Format". Win x64 support (Bug #238001) based on MSDN "x64 Primer: Everything You Need To Know To Start Programming 64-Bit Windows Systems".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classIconExe.BITMAPINFOstatic classIconExe.BITMAPINFOHEADERstatic classIconExe.CURSORDIRstatic classIconExe.FileFormatstatic classIconExe.ICONRESDIRstatic classIconExe.IconResInfostatic classIconExe.IMAGE_DATA_DIRECTORYstatic classIconExe.IMAGE_DOS_HEADERstatic classIconExe.IMAGE_FILE_HEADERstatic classIconExe.IMAGE_NT_HEADERSstatic classIconExe.IMAGE_OPTIONAL_HEADERstatic classIconExe.IMAGE_RESOURCE_DATA_ENTRYstatic classIconExe.IMAGE_RESOURCE_DIRECTORYstatic classIconExe.IMAGE_RESOURCE_DIRECTORY_ENTRYstatic classIconExe.IMAGE_SECTION_HEADER(package private) static classIconExe.ImageData(package private) static classIconExe.ImageLoader(package private) static classIconExe.LEDataInputStreamstatic classIconExe.NEWHEADER(package private) static classIconExe.PaletteDatastatic classIconExe.RESDIR(package private) static classIconExe.RGB(package private) static classIconExe.RGBQUAD(package private) static classIconExe.SWT(package private) static classIconExe.WinBMPFileFormat(package private) static classIconExe.WinICOFileFormat
-
Field Summary
Fields Modifier and Type Field Description (package private) static intBMPHeaderFixedSize(package private) static booleanDEBUG(package private) inticonCnt(package private) IconExe.IconResInfo[]iconInfo(package private) static intIMAGE_DIRECTORY_ENTRY_RESOURCE(package private) static intIMAGE_DOS_SIGNATURE(package private) static intIMAGE_NT_OPTIONAL_HDR32_MAGIC(package private) static intIMAGE_NT_OPTIONAL_HDR64_MAGIC(package private) static intIMAGE_NT_SIGNATURE(package private) static intRES_ICON(package private) static intRT_GROUP_ICON(package private) static intRT_ICONstatic java.lang.StringVERSION
-
Constructor Summary
Constructors Constructor Description IconExe()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static byte[]bitInvertData(byte[] data, int startIndex, int endIndex)(package private) static byte[]convertPad(byte[] data, int width, int height, int depth, int pad, int newPad)(package private) static voidcopyFile(java.lang.String src, java.lang.String dst)(package private) voiddumpResourceDirectory(java.io.RandomAccessFile raf, int imageResourceDirectoryOffset, int resourceBase, int delta, int type, int level, boolean rt_icon_root)(package private) static voidflipScanLines(byte[] data, int stride, int height)(package private) IconExe.IconResInfo[]getIcons(java.io.RandomAccessFile raf)(package private) static byte[]loadData(IconExe.BITMAPINFOHEADER bih, java.io.RandomAccessFile raf)(package private) static byte[]loadData(IconExe.BITMAPINFOHEADER bih, java.io.RandomAccessFile raf, int stride)(package private) static IconExe.ImageData[]loadIcons(java.lang.String program)Retrieve the Desktop icons provided in the Windows executable program.(package private) static IconExe.PaletteDataloadPalette(IconExe.BITMAPINFOHEADER bih, java.io.RandomAccessFile raf)static voidmain(java.lang.String[] args)Replace the Desktop icons provided in the Windows executable program with matching icons provided by the user.(package private) static IconExe.PaletteDatapaletteFromBytes(byte[] bytes, int numColors)(package private) static byte[]paletteToBytes(IconExe.PaletteData pal)(package private) static IconExe.ImageDataparseIcon(java.io.RandomAccessFile raf, int offset, int size)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.BITMAPINFO bi)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.BITMAPINFOHEADER bih)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.CURSORDIR c)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.ICONRESDIR i)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_DATA_DIRECTORY idd)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_DOS_HEADER idh)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_FILE_HEADER ifh)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_NT_HEADERS inh)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_OPTIONAL_HEADER ioh)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_RESOURCE_DATA_ENTRY irde)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_RESOURCE_DIRECTORY ird)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_RESOURCE_DIRECTORY_ENTRY irde)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.IMAGE_SECTION_HEADER ish)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.NEWHEADER nh)(package private) static voidread(java.io.RandomAccessFile raf, IconExe.RESDIR rs)(package private) static intread4(java.io.RandomAccessFile raf)(package private) static longread8(java.io.RandomAccessFile raf)(package private) static booleanreadIconGroup(java.io.RandomAccessFile raf, int offset, int size)(package private) static intreadU2(java.io.RandomAccessFile raf)(package private) static voidunloadIcon(java.io.RandomAccessFile raf, IconExe.ImageData icon)(package private) static intunloadIcons(java.lang.String program, IconExe.ImageData[] icons)Replace the Desktop icons provided in the Windows executable program with icons provided by the user.(package private) static voidunloadMaskData(java.io.RandomAccessFile raf, IconExe.ImageData icon)(package private) static voidunloadShapeData(java.io.RandomAccessFile raf, IconExe.ImageData icon)(package private) static voidwrite4(java.io.RandomAccessFile raf, int value)(package private) static voidwriteU2(java.io.RandomAccessFile raf, int value)
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
DEBUG
static final boolean DEBUG
- See Also:
- Constant Field Values
-
iconInfo
IconExe.IconResInfo[] iconInfo
-
iconCnt
int iconCnt
-
IMAGE_DOS_SIGNATURE
static final int IMAGE_DOS_SIGNATURE
- See Also:
- Constant Field Values
-
IMAGE_NT_SIGNATURE
static final int IMAGE_NT_SIGNATURE
- See Also:
- Constant Field Values
-
IMAGE_DIRECTORY_ENTRY_RESOURCE
static final int IMAGE_DIRECTORY_ENTRY_RESOURCE
- See Also:
- Constant Field Values
-
RES_ICON
static final int RES_ICON
- See Also:
- Constant Field Values
-
RT_ICON
static final int RT_ICON
- See Also:
- Constant Field Values
-
RT_GROUP_ICON
static final int RT_GROUP_ICON
- See Also:
- Constant Field Values
-
BMPHeaderFixedSize
static final int BMPHeaderFixedSize
- See Also:
- Constant Field Values
-
IMAGE_NT_OPTIONAL_HDR64_MAGIC
static final int IMAGE_NT_OPTIONAL_HDR64_MAGIC
- See Also:
- Constant Field Values
-
IMAGE_NT_OPTIONAL_HDR32_MAGIC
static final int IMAGE_NT_OPTIONAL_HDR32_MAGIC
- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionReplace the Desktop icons provided in the Windows executable program with matching icons provided by the user. Takes 2 arguments argument 0: the Windows executable e.g c:/eclipse/eclipse.exe argument 1: The .ico file to write to the given executable e.g. c:/myApp.ico Note 1. Write access to the executable program is required. As a result, that program must not be currently running or edited elsewhere. Note 2. The Eclipse 3.4 launcher requires an .ico file with the following 7 images (in any order). 1. 48x48, 32 bit (RGB / Alpha Channel) 2. 32x32, 32 bit (RGB / Alpha Channel) 3. 16x16, 32 bit (RGB / Alpha Channel) 4. 48x48, 8 bit (256 colors) 5. 32x32, 8 bit (256 colors) 6. 24x24, 8 bit (256 colors) 7. 16x16, 8 bit (256 colors) A user icon matching exactly the width/height/depth of an executable icon will be written to the executable and will replace that executable icon. If an executable icon does not match a user icon, it is silently left as is. Note 3. This function modifies the content of the executable program and may cause its corruption.- Throws:
java.lang.Exception
-
loadIcons
static IconExe.ImageData[] loadIcons(java.lang.String program) throws java.io.FileNotFoundException, java.io.IOException
Retrieve the Desktop icons provided in the Windows executable program. These icons are typically shown in various places of the Windows desktop. Note. The Eclipse 3.4 launcher returns the following 7 images (in any order). 1. 48x48, 32 bit (RGB / Alpha Channel) 2. 32x32, 32 bit (RGB / Alpha Channel) 3. 16x16, 32 bit (RGB / Alpha Channel) 4. 48x48, 8 bit (256 colors) 5. 32x32, 8 bit (256 colors) 6. 24x24, 8 bit (256 colors) 7. 16x16, 8 bit (256 colors)- Parameters:
program- the Windows executable e.g c:/eclipse/eclipse.exe- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
unloadIcons
static int unloadIcons(java.lang.String program, IconExe.ImageData[] icons) throws java.io.FileNotFoundException, java.io.IOExceptionReplace the Desktop icons provided in the Windows executable program with icons provided by the user. Note 1. Write access to the executable program is required. As a result, that program must not be currently running or edited elsewhere. Note 2. Use loadIcons to determine which set of icons (width, height, depth) is required to replace the icons in the executable program. A user icon matching exactly the width/height/depth of an executable icon will be written to the executable and will replace that executable icon. If an executable icon does not match a user icon, it is left as is. Verify the return value matches the number of icons to write. Finally, use loadIcons after this operation to verify the icons have changed as expected. Note 3. The Eclipse 3.4 launcher requires the following 7 images (in any order). 1. 48x48, 32 bit (RGB / Alpha Channel) 2. 32x32, 32 bit (RGB / Alpha Channel) 3. 16x16, 32 bit (RGB / Alpha Channel) 4. 48x48, 8 bit (256 colors) 5. 32x32, 8 bit (256 colors) 6. 24x24, 8 bit (256 colors) 7. 16x16, 8 bit (256 colors) Note 4. This function modifies the content of the executable program and may cause its corruption.- Parameters:
program- the Windows executable e.g c:/eclipse/eclipse.exeicons- to write to the given executable- Returns:
- the number of icons from the original program that were not successfully replaced (0 if success)
- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
getIcons
IconExe.IconResInfo[] getIcons(java.io.RandomAccessFile raf) throws java.io.IOException
- Throws:
java.io.IOException
-
dumpResourceDirectory
void dumpResourceDirectory(java.io.RandomAccessFile raf, int imageResourceDirectoryOffset, int resourceBase, int delta, int type, int level, boolean rt_icon_root) throws java.io.IOException- Throws:
java.io.IOException
-
parseIcon
static IconExe.ImageData parseIcon(java.io.RandomAccessFile raf, int offset, int size) throws java.io.IOException
- Throws:
java.io.IOException
-
bitInvertData
static byte[] bitInvertData(byte[] data, int startIndex, int endIndex)
-
convertPad
static final byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad)
-
loadPalette
static IconExe.PaletteData loadPalette(IconExe.BITMAPINFOHEADER bih, java.io.RandomAccessFile raf) throws java.io.IOException
- Throws:
java.io.IOException
-
paletteFromBytes
static IconExe.PaletteData paletteFromBytes(byte[] bytes, int numColors)
-
loadData
static byte[] loadData(IconExe.BITMAPINFOHEADER bih, java.io.RandomAccessFile raf) throws java.io.IOException
- Throws:
java.io.IOException
-
flipScanLines
static void flipScanLines(byte[] data, int stride, int height)
-
loadData
static byte[] loadData(IconExe.BITMAPINFOHEADER bih, java.io.RandomAccessFile raf, int stride) throws java.io.IOException
- Throws:
java.io.IOException
-
unloadIcon
static void unloadIcon(java.io.RandomAccessFile raf, IconExe.ImageData icon) throws java.io.IOException- Throws:
java.io.IOException
-
paletteToBytes
static byte[] paletteToBytes(IconExe.PaletteData pal)
-
unloadMaskData
static void unloadMaskData(java.io.RandomAccessFile raf, IconExe.ImageData icon)
-
unloadShapeData
static void unloadShapeData(java.io.RandomAccessFile raf, IconExe.ImageData icon)
-
readIconGroup
static boolean readIconGroup(java.io.RandomAccessFile raf, int offset, int size) throws java.io.IOException- Throws:
java.io.IOException
-
copyFile
static void copyFile(java.lang.String src, java.lang.String dst) throws java.io.FileNotFoundException, java.io.IOException- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.BITMAPINFOHEADER bih) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.BITMAPINFO bi) throws java.io.IOException- Throws:
java.io.IOException
-
readU2
static int readU2(java.io.RandomAccessFile raf) throws java.io.IOException- Throws:
java.io.IOException
-
read4
static int read4(java.io.RandomAccessFile raf) throws java.io.IOException- Throws:
java.io.IOException
-
read8
static long read8(java.io.RandomAccessFile raf) throws java.io.IOException- Throws:
java.io.IOException
-
write4
static void write4(java.io.RandomAccessFile raf, int value) throws java.io.IOException- Throws:
java.io.IOException
-
writeU2
static void writeU2(java.io.RandomAccessFile raf, int value) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_DOS_HEADER idh) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_FILE_HEADER ifh) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_DATA_DIRECTORY idd) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_OPTIONAL_HEADER ioh) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_NT_HEADERS inh) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_SECTION_HEADER ish) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_RESOURCE_DIRECTORY ird) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_RESOURCE_DIRECTORY_ENTRY irde) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.IMAGE_RESOURCE_DATA_ENTRY irde) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.NEWHEADER nh) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.ICONRESDIR i) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.CURSORDIR c) throws java.io.IOException- Throws:
java.io.IOException
-
read
static void read(java.io.RandomAccessFile raf, IconExe.RESDIR rs) throws java.io.IOException- Throws:
java.io.IOException
-
-