Java Code Examples for ghidra.program.model.mem.MemoryBlock#getStart()

The following examples show how to use ghidra.program.model.mem.MemoryBlock#getStart() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeManagerTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
   public void testRemoveBlock() throws Exception {
	ProgramModule root = treeManager.createRootModule("Test-One");
	ProgramModule r2 = treeManager.createRootModule("Test-Two");

	addBlock("TestBlock", 0x5000, 100);
	MemoryBlock b2 = addBlock("TestTwoBlock", 0x6000, 200);
	addBlock("TestThreeBlock", 0x6500, 100);

	int r1FragCount = root.getChildren().length;
	int r2FragCount = r2.getChildren().length;
	assertEquals(r1FragCount, r2FragCount);
	assertEquals(5, r1FragCount);
	Address startAddr = b2.getStart();
	Address endAddr = b2.getEnd();
	treeManager.deleteAddressRange(startAddr, endAddr, TaskMonitorAdapter.DUMMY_MONITOR);
	r1FragCount = root.getChildren().length;
	r2FragCount = r2.getChildren().length;
	assertEquals(r1FragCount, r2FragCount);
	assertEquals(4, r1FragCount);
}
 
Example 2
Source File: SymbolManagerTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetDefaultFunctionInOverlaySymbolByName() throws Exception {
	Memory memory = program.getMemory();
	MemoryBlock block = memory.createInitializedBlock("ov_12", addr(0), 5000, (byte) 0,
		TaskMonitorAdapter.DUMMY_MONITOR, true);
	Address ovAddress = block.getStart();
	assertEquals("ov_12::00000000", ovAddress.toString());

	Listing listing = program.getListing();

	AddressSet set = new AddressSet(ovAddress, ovAddress);
	Function f = listing.createFunction("fredFunc", ovAddress, set, SourceType.DEFAULT);
	assertNotNull(f);

	String defaultName = "FUN_ov_12__00000000";
	Symbol s1 = st.getPrimarySymbol(ovAddress);
	assertNotNull(s1);
	assertEquals(defaultName, s1.getName());
	assertTrue(s1.isPrimary());

	Symbol s = getUniqueSymbol(program, defaultName);
	assertNotNull(s);
	assertEquals(ovAddress, s.getAddress());
}
 
Example 3
Source File: ObjectiveC2_ClassAnalyzer.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void processSuperReferences(ObjectiveC2_State state) throws Exception {
	state.monitor.setMessage("Objective-C 2.0 Super References...");

	MemoryBlock block =
		state.program.getMemory().getBlock(ObjectiveC2_Constants.OBJC2_SUPER_REFS);
	if (block == null) {
		return;
	}
	ObjectiveC1_Utilities.clear(state, block);

	long count = block.getSize() / state.pointerSize;

	state.monitor.initialize((int) count);

	Address address = block.getStart();

	for (int i = 0; i < count; ++i) {
		if (state.monitor.isCancelled()) {
			break;
		}
		state.monitor.setProgress(i);
		ObjectiveC1_Utilities.createPointerAndReturnAddressBeingReferenced(state.program,
			address);
		address = address.add(state.pointerSize);
	}
}
 
Example 4
Source File: MemorySectionResolver.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Determine loaded memory conflict set.  Use physical address of loaded overlay
 * blocks to force reconciliation and avoid duplication.
 * @param rangeMin
 * @param rangeMax
 * @return conflict memory set
 */
private AddressSet getMemoryConflictSet(Address rangeMin, Address rangeMax) {

	// dedicated non-loaded overlay - don't bother with conflict check
	if (rangeMin.isNonLoadedMemoryAddress()) {
		return new AddressSet();
	}

	// Get base memory conflict set
	Memory memory = getMemory();
	AddressSet rangeSet = new AddressSet(rangeMin, rangeMax);
	AddressSet conflictSet = memory.intersect(rangeSet);

	// Add in loaded overlay conflicts (use their physical address)
	for (MemoryBlock block : memory.getBlocks()) {
		Address minAddr = block.getStart();
		Address maxAddr = block.getEnd();
		if (minAddr.isLoadedMemoryAddress() && minAddr.getAddressSpace().isOverlaySpace()) {
			AddressSet intersection = rangeSet.intersectRange(minAddr.getPhysicalAddress(),
				maxAddr.getPhysicalAddress());
			conflictSet.add(intersection);
		}
	}

	return conflictSet;
}
 
Example 5
Source File: PowerPC64_ElfExtension.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void findTocBase(ElfLoadHelper elfLoadHelper, TaskMonitor monitor) {

		// TODO: Verify that this works for non-V2 ABI cases (this assumes TOC based upon .got location)

		Program program = elfLoadHelper.getProgram();

		try {
			Address tocAddr = null;

			// Check for .toc section
			MemoryBlock tocBlock = program.getMemory().getBlock(".toc");
			if (tocBlock != null) {
				tocAddr = tocBlock.getStart();
			}
			else {
				MemoryBlock gotBlock =
					program.getMemory().getBlock(ElfSectionHeaderConstants.dot_got);
				if (gotBlock != null) {
					tocAddr = gotBlock.getStart().addNoWrap(0x8000);
				}
			}

			if (tocAddr != null) {
				elfLoadHelper.createSymbol(tocAddr, TOC_BASE, false, false, null);
			}

		}
		catch (AddressOverflowException | InvalidInputException e) {
			// ignore
		}
	}
 
Example 6
Source File: MemoryMapProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void selectAddress() {
	int row = memTable.getSelectedRow();
	int viewColumn = memTable.getSelectedColumn();
	int col = memTable.convertColumnIndexToModel(viewColumn);
	MemoryBlock block = mapModel.getBlockAt(row);
	if (block != null && (col == 1 || col == 2)) {
		Address addr = (col == 1 ? block.getStart() : block.getEnd());
		plugin.blockSelected(block, addr);
		memTable.setRowSelectionInterval(row, row);
	}
}
 
Example 7
Source File: EhFrameHeaderSection.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private int analyzeSection(MemoryBlock curMemBlock, TaskMonitor monitor)
		throws MemoryAccessException, AddressOutOfBoundsException,
		ExceptionHandlerFrameException {

	monitor.setMessage("Analyzing .eh_frame_hdr section");

	ProgramLocation loc = new ProgramLocation(program, curMemBlock.getStart());
	Address curAddress = loc.getAddress();

	ExceptionHandlerFrameHeader eh_frame_hdr =
		new ExceptionHandlerFrameHeader(monitor, program);
	eh_frame_hdr.addToDataTypeManager();
	eh_frame_hdr.create(curAddress);

	curAddress = curAddress.add(eh_frame_hdr.getLength());

	// NOTE: The process... method calls that follow are order dependent.
	//       Each one is passed the address of the field it will process and 
	//       returns the next address after that field, which will then be 
	//       used by the next field's process method.

	curAddress = processEncodedFramePointer(curAddress, eh_frame_hdr, curMemBlock);

	DwarfEHDecoder fdeCountDecoder = getFdeCountDecoder(eh_frame_hdr);
	Address fdeCountAddress = curAddress;

	curAddress = processEncodedFdeCount(fdeCountAddress, fdeCountDecoder);

	int fdeTableCnt = getFdeTableCount(fdeCountAddress, curMemBlock, fdeCountDecoder);
	if (fdeTableCnt > 0) {
		createFdeTable(curAddress, eh_frame_hdr, fdeTableCnt, monitor);
	}
	return fdeTableCnt;
}
 
Example 8
Source File: PatternStats.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void searchBlock(Program program, MemoryBlock block, TaskMonitor taskMonitor)
		throws IOException {
	taskMonitor.setMessage("Byte Search");
	taskMonitor.setMaximum((int) block.getSize());
	taskMonitor.setProgress(0);
	ArrayList<Match> mymatches = new ArrayList<>();
	long streamoffset = block.getStart().getOffset();
	root.apply(block.getData(), mymatches, taskMonitor);
	if (taskMonitor.isCancelled()) {
		return;
	}
	Address start = block.getStart();
	for (int i = 0; i < mymatches.size(); ++i) {
		Match match = mymatches.get(i);
		Address addr = start.add(match.getMarkOffset());
		if (!match.checkPostRules(streamoffset)) {
			continue;
		}
		PatternAccumulate accum = accumList.get(match.getSequenceIndex());
		MatchAction[] matchActions = match.getMatchActions();
		for (MatchAction matchAction : matchActions) {
			boolean isFalse = collectStats(accum, (MatchActionMarker) matchAction, addr);
			if (isFalse) {
				displayFalse(accum, addr);
				accum.addExample(addr);
			}
		}
	}
}
 
Example 9
Source File: BaseSectionProvider.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public ByteProvider getSectionAsByteProvider(String sectionName) throws IOException {

	MemoryBlock block = program.getMemory().getBlock(sectionName);
	if (block == null) {
		block = program.getMemory().getBlock("." + sectionName);
	}
	if (block != null) {
		// TODO: limit the returned ByteProvider to block.getSize() bytes
		return new MemoryByteProvider(program.getMemory(), block.getStart());
	}

	return null;
}
 
Example 10
Source File: ObjectiveC2_ClassAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void processClassList(ObjectiveC2_State state, BinaryReader reader) throws Exception {
	state.monitor.setMessage("Objective-C 2.0 Class Information...");

	MemoryBlock block =
		state.program.getMemory().getBlock(ObjectiveC2_Constants.OBJC2_CLASS_LIST);
	if (block == null) {
		return;
	}
	ObjectiveC1_Utilities.clear(state, block);

	long count = block.getSize() / state.pointerSize;

	state.monitor.initialize((int) count);

	Address address = block.getStart();

	for (int i = 0; i < count; ++i) {
		if (state.monitor.isCancelled()) {
			break;
		}
		state.monitor.setProgress(i);

		Address classAddress =
			ObjectiveC1_Utilities.createPointerAndReturnAddressBeingReferenced(state.program,
				address);
		reader.setPointerIndex(classAddress.getOffset());

		ObjectiveC2_Class clazz = new ObjectiveC2_Class(state, reader);
		clazz.applyTo();
		address = address.add(state.pointerSize);
	}
}
 
Example 11
Source File: iOS_KextStubFixupAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void markupNonLazySymbolPointerSection(Program program, MemoryBlock block,
		TaskMonitor monitor) {
	ReferenceManager referenceManager = program.getReferenceManager();
	Listing listing = program.getListing();
	listing.clearCodeUnits(block.getStart(), block.getEnd(), false);
	Address address = block.getStart();
	while (!monitor.isCancelled()) {
		if (address.compareTo(block.getEnd()) > 0) {
			break;
		}
		int length;
		try {
			Data data = listing.createData(address, new PointerDataType());
			Reference[] references = data.getReferencesFrom();
			for (Reference reference : references) {
				if (monitor.isCancelled()) {
					break;
				}
				referenceManager.delete(reference);
			}
			length = data.getLength();
		}
		catch (Exception e) {
			return;
		}
		address = address.add(length);
	}
}
 
Example 12
Source File: SymbolManagerTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetDefaultFunctionInOverlaySymbolByNameWith2WordSize() throws Exception {
	Program p = createDefaultProgram("whatever", ProgramBuilder._TOY_WORDSIZE2_BE, this);
	Address address = p.getAddressFactory().getDefaultAddressSpace().getAddress(0);
	int txID = p.startTransaction("test");
	Memory memory = p.getMemory();
	MemoryBlock block = memory.createInitializedBlock("ov12", address, 5000, (byte) 0,
		TaskMonitorAdapter.DUMMY_MONITOR, true);
	Address ovAddress = block.getStart();
	assertEquals("ov12::00000000", ovAddress.toString());
	ovAddress = ovAddress.add(2);
	Listing listing = p.getListing();
	st = p.getSymbolTable();

	AddressSet set = new AddressSet(ovAddress, ovAddress);

	Function f = listing.createFunction("fredFunc", ovAddress, set, SourceType.DEFAULT);

	p.endTransaction(txID, true);
	assertNotNull(f);

	String defaultName = "FUN_ov12__00000001";
	Symbol s1 = st.getPrimarySymbol(ovAddress);
	assertNotNull(s1);
	assertEquals(defaultName, s1.getName());
	assertTrue(s1.isPrimary());
}
 
Example 13
Source File: PowerPC64_ElfExtension.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void processOPDSection(ElfLoadHelper elfLoadHelper, TaskMonitor monitor)
		throws CancelledException {

	MemoryBlock opdBlock = elfLoadHelper.getProgram().getMemory().getBlock(".opd");
	if (opdBlock == null) {
		return;
	}

	monitor.setMessage("Processing Function Descriptor Symbols...");

	Address addr = opdBlock.getStart();
	Address endAddr = opdBlock.getEnd();

	monitor.setShowProgressValue(true);
	monitor.setProgress(0);
	monitor.setMaximum((endAddr.subtract(addr) + 1) / 24);
	int count = 0;

	try {
		while (addr.compareTo(endAddr) < 0) {
			monitor.checkCanceled();
			monitor.setProgress(++count);
			processOPDEntry(elfLoadHelper, addr);
			addr = addr.addNoWrap(24);
		}
	}
	catch (AddressOverflowException e) {
		// ignore end of space
	}

	// allow .opd section contents to be treated as constant values
	opdBlock.setWrite(false);
}
 
Example 14
Source File: PropertyManagerPluginScreenShots.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();

	// create some properties
	int id = program.startTransaction("test");
	PropertyMapManager pm = program.getUsrPropertyManager();
	pm.createIntPropertyMap("Foo Property");
	IntPropertyMap map1 = pm.createIntPropertyMap("Bar Property");
	Memory memory = program.getMemory();
	MemoryBlock block = memory.getBlock(".text");
	Address addr = block.getStart();
	for (int i = 0; i < 5000; i++) {
		map1.add(addr, i);
		addr = addr.add(10);
	}

	program.endTransaction(id, true);
	loadPlugin(PropertyManagerPlugin.class);
	showProvider(PropertyManagerProvider.class);
	PropertyManagerProvider provider = getProvider(PropertyManagerProvider.class);
	goToListing(0x00401082);
	final JTable table = (JTable) getInstanceField("table", provider);
	runSwing(new Runnable() {

		@Override
		public void run() {
			table.setRowSelectionInterval(0, 0);
		}
	});
}
 
Example 15
Source File: iOS_KextStubFixupAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private AddressSet toAddressSet(MemoryBlock block) {
	return new AddressSet(block.getStart(), block.getEnd());
}
 
Example 16
Source File: PefLoader.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void processImports(ContainerHeader header, Program program,
		ImportStateCache importState, MessageLog log, TaskMonitor monitor) {

	LoaderInfoHeader loader = header.getLoader();
	List<ImportedLibrary> libraries = loader.getImportedLibraries();
	List<ImportedSymbol> symbols = loader.getImportedSymbols();
	int symbolIndex = 0;

	MemoryBlock importBlock = makeFakeImportBlock(program, symbols, log, monitor);
	if (importBlock == null) {
		return;
	}

	Address start = importBlock.getStart();

	for (ImportedLibrary library : libraries) {
		if (monitor.isCancelled()) {
			return;
		}

		String libraryName = SymbolUtilities.replaceInvalidChars(library.getName(), true);

		int symbolCount = library.getImportedSymbolCount();
		int symbolStart = library.getFirstImportedSymbol();

		int totalSymbolCount = symbolStart + symbolCount;

		for (int i = symbolStart; i < totalSymbolCount; ++i) {
			if (monitor.isCancelled()) {
				return;
			}

			if (symbolIndex % 100 == 0) {
				monitor.setMessage(
					"Processing import " + symbolIndex + " of " + symbols.size());
			}
			++symbolIndex;

			String symbolName =
				SymbolUtilities.replaceInvalidChars(symbols.get(i).getName(), true);

			boolean success = importState.createLibrarySymbol(library, symbolName, start);
			if (!success) {
				log.appendMsg("Unable to create symbol.");
			}

			createPointer(program, start, log);
			program.getReferenceManager().removeAllReferencesFrom(start);
			addExternalReference(program, start, libraryName, symbolName, log);

			start = start.add(4);
		}
	}
}
 
Example 17
Source File: VxWorksSymTab_Finder.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private Address findSymTbl(VxSymbol vxSymbol) throws Exception {

		int testLen = 100;		// number of symbol tbl entries to look for

		boolean hasNonExecute = checkNonExecute();

		// Iterate through all memory blocks
		for (MemoryBlock block : currentProgram.getMemory().getBlocks()) {

			// Skip code/execute blocks if there are non-execute blocks,
			//  otherwise search everything.
			if (hasNonExecute && block.isExecute()) {
				continue;
			}

			// skip uninit
			if (!block.isInitialized()) {
				continue;
			}

			// Search current block for run of testLen symbol table entries
			int testBlkSize = vxSymbol.length * testLen;
			printf("   block: " + block.getName() + " (" + block.getStart() + ", " +
				block.getEnd() + ") ");
			printf("testBlkSize = " + Integer.toHexString(testBlkSize) + "  ");
			System.out.flush();
			long prevOffset = 0;
			Address cursor = block.getStart();
			while ((cursor != null) && isAddress(cursor.getOffset() + testBlkSize, block)) {

				// Script cancel check and visual feedback
				if (monitor.isCancelled()) {
					return null;
				}
				if ((cursor.getOffset() - prevOffset) >= 0x100000) {
					printf(".");
					System.out.flush();
					prevOffset = cursor.getOffset();
				}

				// Determine whether cursor now points to a symbol table
				int i = 0;
				for (Address entry = cursor; isSymTblEntry(entry, vxSymbol) &&
					(i < testLen); entry = entry.add(vxSymbol.length()), i++) {
				}
				if (i == testLen) {
					// May have symbol table -- verify length
					if (getSymTblLen(cursor, vxSymbol) != 0) {
						printf("\n");
						System.out.flush();
						return cursor;	// found  table -- stop searching
					}
					if (debug) {
						printf("Possible symbol table at " + cursor + " has length error\n");
					}
				}

				cursor = cursor.add(4);
			}
			printf("\n");
			printf("   search terminated at:  " + cursor + "\n");
			System.out.flush();
		}
		return null;
	}
 
Example 18
Source File: DebugFrameSection.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private List<RegionDescriptor> analyzeSection(MemoryBlock curMemBlock)
		throws MemoryAccessException, AddressOutOfBoundsException,
		ExceptionHandlerFrameException {

	monitor.setMessage("Analyzing " + curMemBlock.getName() + " section");
	monitor.setShowProgressValue(true);
	monitor.setIndeterminate(false);

	ProgramLocation loc = new ProgramLocation(program, curMemBlock.getStart());
	Address curAddress = loc.getAddress();

	List<RegionDescriptor> regions = new ArrayList<>();

	if (curAddress != null) {
		monitor.setMaximum(curMemBlock.getEnd().subtract(curAddress));
	}

	while (curAddress != null && curAddress.compareTo(curMemBlock.getEnd()) < 0) {
		if (monitor.isCancelled()) {
			return regions;
		}

		/* Get the Common Information Entry */
		Cie cie = getCie(curAddress);

		/* Check for the end of the frame record. */
		if (cie.isEndOfFrame()) {
			break;
		}

		curAddress = cie.getNextAddress();

		/* 
		 * Add each Frame Description Entry (FDE) for the current CIE.
		 */
		List<RegionDescriptor> newRegions = new ArrayList<>();

		while (curAddress != null && (curAddress.compareTo(curMemBlock.getEnd()) < 0)) {

			monitor.setProgress(curAddress.subtract(loc.getAddress()));

			Address currFdeAddr = curAddress;

			try {

				FrameDescriptionEntry fde = new FrameDescriptionEntry(monitor, program, this);
				RegionDescriptor region = fde.create(curAddress);

				if (fde.isEndOfFrame()) {
					break;
				}

				if (region != null) {
					newRegions.add(region);
					createFdeComment(curAddress);
				}

				curAddress = fde.getNextAddress(); // This can be null.

			}
			catch (ExceptionHandlerFrameException efe) {
				// May have run into another CIE.
				curAddress = currFdeAddr;
				break;
			}
		}

		createAugmentationData(newRegions, cie);

		regions.addAll(newRegions);
	}
	return regions;
}
 
Example 19
Source File: EhFrameSection.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private List<RegionDescriptor> analyzeSection(MemoryBlock curMemBlock)
		throws MemoryAccessException, AddressOutOfBoundsException, ExceptionHandlerFrameException {

	monitor.setMessage("Analyzing " + curMemBlock.getName() + " section");
	monitor.setShowProgressValue(true);
	monitor.setIndeterminate(false);
	long bytesInBlock = curMemBlock.getSize();
	monitor.initialize(bytesInBlock);

	Address startAddr = curMemBlock.getStart();
	ProgramLocation loc = new ProgramLocation(program, startAddr);
	Address curAddress = loc.getAddress();

	List<RegionDescriptor> regions = new ArrayList<>();


	while (curAddress != null && curAddress.compareTo(curMemBlock.getEnd()) < 0) {

		monitor.setProgress(curAddress.subtract(startAddr));

		/* Get the Common Information Entry (CIE) */
		Cie cie = getCie(curAddress);

		/* Check for the end of the frame record. */
		if (cie.isEndOfFrame()) {
			break;
		}

		curAddress = cie.getNextAddress();

		/* 
		 * Add each Frame Description Entry (FDE) for the current CIE.
		 */
		while (curAddress != null && (curAddress.compareTo(curMemBlock.getEnd()) < 0)) {

			monitor.setProgress(curAddress.subtract(startAddr));

			Address currFdeAddr = curAddress;

			try {

				FrameDescriptionEntry fde = new FrameDescriptionEntry(monitor, program, this);
				RegionDescriptor region = fde.create(curAddress);

				if (fde.isEndOfFrame()) {
					break;
				}

				if (region != null) {
					regions.add(region);
					createFdeComment(curAddress);
					monitor.incrementProgress(1);
				}

				curAddress = fde.getNextAddress(); // This can be null.

			} catch (ExceptionHandlerFrameException efe) {
				// May have run into another CIE.
				curAddress = currFdeAddr;
				break;
			}
		}

		createAugmentationData(regions, cie);
	}
	return regions;
}
 
Example 20
Source File: ExpandBlockDialog.java    From ghidra with Apache License 2.0 4 votes vote down vote up
/**
 * Create the main work panel.
 * @return JPanel
 */
private JPanel create(MemoryBlock block) {
	JPanel panel = new JPanel(new PairLayout(5, 5, 150));
	startAddressInput = new AddressInput();
	startAddressInput.setName("NewStartAddress");
	startAddressInput.setAddressFactory(addrFactory);
	endAddressInput = new AddressInput();
	endAddressInput.setName("EndAddress");
	endAddressInput.setAddressFactory(addrFactory);
	Address start = block.getStart();
	Address end = block.getEnd();

	startAddressInput.setAddress(start);
	startAddressInput.setAddressSpaceEditable(false);
	endAddressInput.setAddress(end);
	endAddressInput.setAddressSpaceEditable(false);

	boolean isExpandUp = dialogType == EXPAND_UP;

	startField = new JTextField(10);
	startField.setName("StartAddress");
	startField.setEnabled(isExpandUp);
	startField.setText(start.toString());

	endField = new JTextField(10);
	endField.setName("EndAddress");
	endField.setEnabled(!isExpandUp);
	endField.setText(end.toString());

	lengthField = new RegisterField(32, null, false);
	lengthField.setName("BlockLength");
	lengthField.setValue(Long.valueOf(model.getLength()));

	panel.add(
		new GLabel(isExpandUp ? "New Start Address:" : "Start Address:", SwingConstants.RIGHT));
	panel.add(isExpandUp ? (JComponent) startAddressInput : startField);
	panel.add(
		new GLabel(isExpandUp ? "End Address:" : "New End Address:", SwingConstants.RIGHT));
	panel.add(isExpandUp ? (JComponent) endField : endAddressInput);
	panel.add(new GLabel("Block Length:", SwingConstants.RIGHT));
	panel.add(lengthField);

	JPanel mainPanel = new JPanel(new BorderLayout());
	mainPanel.add(panel, BorderLayout.CENTER);
	return mainPanel;
}