Example #1
0
 public ModuleDependency(final UnsignedInteger moduleTypeId, final UnsignedInteger moduleVersion) {
   if (moduleTypeId.intValue() > 65535) {
     throw new IllegalArgumentException(
         "Illegal moduleTypeId value > 65535, only ushort values allowed");
   }
   if (moduleVersion.intValue() > 65535) {
     throw new IllegalArgumentException(
         "Illegal version moduleVersion > 65535, only ushort values allowed");
   }
   this.moduleTypeId = moduleTypeId.shortValue();
   this.moduleVersion = moduleVersion.shortValue();
 }
 @Test
 public void testInfoForFatBinaryAndLittleEndian() {
   MachoMagicInfo info = new MachoMagicInfo(UnsignedInteger.fromIntBits(0xBEBAFECA));
   assertThat(info.isValidMachMagic(), equalTo(true));
   assertThat(info.is64Bit(), equalTo(false));
   assertThat(info.isSwapped(), equalTo(true));
   assertThat(info.isMachObjectHeaderMagic(), equalTo(false));
   assertThat(info.isFatBinaryHeaderMagic(), equalTo(true));
 }
  public static void checkValues(SegmentCommand command, boolean is64Bit) {
    if (is64Bit) {
      assertThat(
          command.getLoadCommandCommonFields().getCmd(),
          equalToObject(SegmentCommand.LC_SEGMENT_64));
      assertThat(command.getLoadCommandCommonFields().getCmdsize().intValue(), equalTo(72));
    } else {
      assertThat(
          command.getLoadCommandCommonFields().getCmd(), equalToObject(SegmentCommand.LC_SEGMENT));
      assertThat(command.getLoadCommandCommonFields().getCmdsize().intValue(), equalTo(56));
    }

    assertThat(command.getSegname(), equalToObject("SEGNAME"));
    assertThat(command.getVmaddr().intValue(), equalTo(0x10));
    assertThat(command.getVmsize().intValue(), equalTo(0x20));
    assertThat(command.getFileoff().intValue(), equalTo(0x30));
    assertThat(command.getFilesize().intValue(), equalTo(0x40));
    assertThat(command.getMaxprot(), equalToObject(0x50));
    assertThat(command.getInitprot(), equalToObject(0x60));
    assertThat(command.getNsects(), equalToObject(UnsignedInteger.fromIntBits(0x70)));
    assertThat(command.getFlags(), equalToObject(UnsignedInteger.fromIntBits(0x80)));
  }
 @Override
 public void startPositionNode(final UnsignedInteger position) {
   writer.startStatement(Rfc6020Mapping.POSITION);
   writer.writeArgument(position.toString());
 }
 @Test
 public void testInvalidMagic() {
   MachoMagicInfo info = new MachoMagicInfo(UnsignedInteger.fromIntBits(0x12345678));
   assertThat(info.isValidMachMagic(), equalTo(false));
 }