in teamcity-symbol-agent/src/main/java/jetbrains/buildServer/symbols/tools/BinaryGuidDumper.java [17:50]
public static void dumpBinaryGuidsToFile(Collection<File> files, File output, BuildProgressLogger buildLogger) {
final Element root = new Element("file-signs");
for (File file : files) {
RandomAccessFile randomAccess = null;
try {
randomAccess = new RandomAccessFile(file, "r");
//the PE offset is at byte [60,64)
int peOffset = readIntLE(randomAccess, 60);
int timestamp = readIntLE(randomAccess, peOffset + 8);
int size = readIntLE(randomAccess, peOffset + 80);
String signature = Integer.toHexString(timestamp) + Integer.toHexString(size);
final Element entry = new Element("file-sign-entry");
entry.setAttribute("file-path", file.getPath());
entry.setAttribute("file", file.getName());
entry.setAttribute("sign", signature);
root.addContent(entry);
} catch (IOException e) {
buildLogger.exception(e);
} finally {
if (randomAccess != null)
try {
randomAccess.close();
} catch (IOException e) {
//I hate you, checked exceptions
buildLogger.exception(e);
}
}
}
try {
XmlUtil.saveDocument(new Document(root), new FileOutputStream(output));
} catch (IOException e) {
buildLogger.exception(e);
}
}