@Test public void testUpdateChecksum() throws Exception { File srcFile = new File("target/test-classes/wineyes.exe"); File destFile = new File("target/test-classes/wineyes-big.exe"); FileUtils.copyFile(srcFile, destFile); RandomAccessFile raf = new RandomAccessFile(destFile, "rw"); raf.setLength(1024 * 1024 + 73); raf.close(); PEFile file = new PEFile(destFile); file.updateChecksum(); assertEquals("checksum", 0x0010483E, file.getCheckSum()); }
public synchronized void updateChecksum() { ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt((int) computeChecksum()); buffer.flip(); try { channel.position(peHeaderOffset + 88); channel.write(buffer); } catch (IOException e) { throw new RuntimeException(e); } }
PEFile implements Signable, Closeable { public synchronized void updateChecksum() { ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt((int) computeChecksum()); buffer.flip(); try { channel.position(peHeaderOffset + 88); channel.write(buffer); } catch (IOException e) { throw new RuntimeException(e); } } }
PEFile implements Signable, Closeable { public synchronized void updateChecksum() { ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt((int) computeChecksum()); buffer.flip(); try { channel.position(peHeaderOffset + 88); channel.write(buffer); } catch (IOException e) { throw new RuntimeException(e); } } PEFile(File file);  PEFile(SeekableByteChannel channel); }
PEFile implements Signable, Closeable { public synchronized void updateChecksum() { ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt((int) computeChecksum()); buffer.flip(); try { channel.position(peHeaderOffset + 88); channel.write(buffer); } catch (IOException e) { throw new RuntimeException(e); } } PEFile(File file);  PEFile(SeekableByteChannel channel); static boolean isPEFile(File file); void save(); synchronized void close(); MachineType getMachineType(); int getNumberOfSections(); Date getTimeDateStamp(); long getPointerToSymbolTable(); long getNumberOfSymbols(); int getSizeOfOptionalHeader(); int getCharacteristics(); PEFormat getFormat(); int getMajorLinkerVersion(); int getMinorLinkerVersion(); long getSizeOfCode(); long getSizeOfInitializedData(); long getSizeOfUninitializedData(); long getAddressOfEntryPoint(); long getBaseOfCode(); long getBaseOfData(); long getImageBase(); long getSectionAlignment(); long getFileAlignment(); int getMajorOperatingSystemVersion(); int getMinorOperatingSystemVersion(); int getMajorImageVersion(); int getMinorImageVersion(); int getMajorSubsystemVersion(); int getMinorSubsystemVersion(); long getWin32VersionValue(); long getSizeOfImage(); long getSizeOfHeaders(); long getCheckSum(); synchronized long computeChecksum(); synchronized void updateChecksum(); Subsystem getSubsystem(); int getDllCharacteristics(); long getSizeOfStackReserve(); long getSizeOfStackCommit(); long getSizeOfHeapReserve(); long getSizeOfHeapCommit(); long getLoaderFlags(); int getNumberOfRvaAndSizes(); DataDirectory getDataDirectory(DataDirectoryType type); synchronized void writeDataDirectory(DataDirectoryType type, byte[] data); @Override synchronized List<CMSSignedData> getSignatures(); @Override void setSignature(CMSSignedData signature); synchronized List<Section> getSections(); void printInfo(OutputStream out); void printInfo(PrintWriter out); @Override synchronized byte[] computeDigest(MessageDigest digest); byte[] computeDigest(DigestAlgorithm algorithm); @Override ASN1Object createIndirectData(DigestAlgorithm digestAlgorithm); synchronized void pad(int multiple); }
PEFile implements Signable, Closeable { public synchronized void updateChecksum() { ByteBuffer buffer = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt((int) computeChecksum()); buffer.flip(); try { channel.position(peHeaderOffset + 88); channel.write(buffer); } catch (IOException e) { throw new RuntimeException(e); } } PEFile(File file);  PEFile(SeekableByteChannel channel); static boolean isPEFile(File file); void save(); synchronized void close(); MachineType getMachineType(); int getNumberOfSections(); Date getTimeDateStamp(); long getPointerToSymbolTable(); long getNumberOfSymbols(); int getSizeOfOptionalHeader(); int getCharacteristics(); PEFormat getFormat(); int getMajorLinkerVersion(); int getMinorLinkerVersion(); long getSizeOfCode(); long getSizeOfInitializedData(); long getSizeOfUninitializedData(); long getAddressOfEntryPoint(); long getBaseOfCode(); long getBaseOfData(); long getImageBase(); long getSectionAlignment(); long getFileAlignment(); int getMajorOperatingSystemVersion(); int getMinorOperatingSystemVersion(); int getMajorImageVersion(); int getMinorImageVersion(); int getMajorSubsystemVersion(); int getMinorSubsystemVersion(); long getWin32VersionValue(); long getSizeOfImage(); long getSizeOfHeaders(); long getCheckSum(); synchronized long computeChecksum(); synchronized void updateChecksum(); Subsystem getSubsystem(); int getDllCharacteristics(); long getSizeOfStackReserve(); long getSizeOfStackCommit(); long getSizeOfHeapReserve(); long getSizeOfHeapCommit(); long getLoaderFlags(); int getNumberOfRvaAndSizes(); DataDirectory getDataDirectory(DataDirectoryType type); synchronized void writeDataDirectory(DataDirectoryType type, byte[] data); @Override synchronized List<CMSSignedData> getSignatures(); @Override void setSignature(CMSSignedData signature); synchronized List<Section> getSections(); void printInfo(OutputStream out); void printInfo(PrintWriter out); @Override synchronized byte[] computeDigest(MessageDigest digest); byte[] computeDigest(DigestAlgorithm algorithm); @Override ASN1Object createIndirectData(DigestAlgorithm digestAlgorithm); synchronized void pad(int multiple);  }