Examples of PEFile


Examples of net.charabia.jsmoothgen.pe.PEFile

                fireFailedChange();
                return false;
            }

            fireStepChange(10, "Scanning skeleton...");
            PEFile pe = new PEFile(pattern);
            pe.open();
            PEResourceDirectory resdir = pe.getResourceDirectory();

            boolean resb = false;

            //
            // Adds the jar only if the user selected one
            //
            if (data.getEmbeddedJar() == true) {
                if (data.getJarLocation() == null) {
                    m_errors.add("Error: Jar is not specified!");
                    fireFailedChange();
                    return false;
                }

                fireStepChange(40, "Loading Jar...");
                File jarloc = concFile(basedir, new File(data.getJarLocation()));
                if (jarloc.exists() == false) {
                    m_errors.add("Error: Can't find jar at " + jarloc);
                    fireFailedChange();
                    return false;
                }

                ByteBuffer jardata = load(jarloc);

                fireStepChange(60, "Adding Jar to Resources...");
                resb = resdir.replaceResource(skel.getResourceCategory(), skel.getResourceJarId(), 1033, jardata);
                if (resb == false) {
                    m_errors.add("Error: Can't replace jar resource! It is probably missing from the skeleton.");
                    fireFailedChange();
                    return false;
                }
            }

            fireStepChange(70, "Adding Properties and Manifest to Resources...");
            // Properties...
            String props = PropertiesBuilder.makeProperties(basedir, data);
            ByteBuffer propdata = convert(props);
            resb = resdir.replaceResource(skel.getResourceCategory(), skel.getResourcePropsId(), 1033, propdata);

            // Manifest...
            String manifest = PropertiesBuilder.makeManifest(data, skel);
            if (manifest == null || manifest.isEmpty()) {
                manifest = "";
            }
            ByteBuffer manifestData = convert(manifest);
            resb = resdir.replaceManifest(1, 1033, manifestData);

            if (data.getIconLocation() != null) {
                fireStepChange(80, "Loading icon...");
                String iconpath;
                if (new java.io.File(data.getIconLocation()).isAbsolute())
                    iconpath = data.getIconLocation();
                else
                    iconpath = new java.io.File(basedir, data.getIconLocation()).getAbsolutePath();

                Image img = getScaledImage(iconpath, 32, 32);
                //Hashtable set = calculateColorCount(img);
                //        System.out.println("COLORS TOTAL 4: " + set.size());

                if (img != null) {
                    net.charabia.jsmoothgen.pe.res.ResIcon32 resicon = new net.charabia.jsmoothgen.pe.res.ResIcon32(img);
                    pe.replaceDefaultIcon(resicon);
                }
            }

            fireStepChange(90, "Saving exe...");
            pe.dumpTo(out);

            //    System.out.println("PROPERTIES:\n" + props);

            fireCompleteChange();
            return true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.