private static DirectoryEntry insertIcon(DirectoryEntry level1, int index, long languageId) {
    // We should construct and correctly add second and third level entries to a resource
    // Second level contains ID of icon
    // Third level contains languageId and raw data

    ResourceSectionReader section = level1.getSection();

    EntryDescription description2 = new EntryDescription();
    description2.getNameW().setValue(index);
    DirectoryEntry level2 = new DirectoryEntry(section, description2, index);

    level1.addDirectoryEntry(level2);
    level1.addIdEntry(description2);

    EntryDescription description3 = new EntryDescription();
    description3.getNameW().setValue(languageId);
    Bin.DWord offset = description3.getOffsetToData();
    DataEntry level3 = new DataEntry(section, offset, description3.getNameW());

    level2.addIdEntry(description3);
    level2.addDataEntry(level3);

    level3.initRawData();

    return level2;
  }
private static DirectoryEntry insertIcon(DirectoryEntry level1, int index, long languageId)