shellext / Offset Calculator

Offset Calculator

Offset Calculator (frmOffsets) translates between virtual address, RVA, and file offset for a loaded PE, displays the section table, peeks at the bytes at the calculated offset, and runs DumpFix on memory-dumped images. Reachable from File Hash → right-click → Offset Calculator (32/64bit).

The dialog is initialized with a CPEEditor instance that already has the file loaded. The window caption is set to the file's ImageBase. The Entry Point label is filled in, the RVA field is pre-populated with the EP, and the calculation runs once on load — so you arrive at the dialog already looking at the bytes at the EP.

Offset Calculator dialog
Section table at top with name, virtual address, virtual size, raw offset, raw size, and characteristics. Three radio buttons choose which field is the input (the other two are computed); the bottom-right shows the section the address resolves into and a 6-byte hex peek at the calculated file offset.

Section table

The top listview shows every PE section. Columns:

ColumnDescription
NameSection name (.text, .data, etc).
Virtual AddrVirtualAddress field, hex (this is an RVA, not a fully-resolved VA).
Virtual SizeVirtualSize field, hex.
RawOffsetPointerToRawData, hex.
RawSizeSizeOfRawData, hex.
AttributesCharacteristics flags, hex.

Right-click on the section table:

ItemAction
Copy RowCopy just the selected row, tab-delimited, with the column headers shortened (VA / VSz / ROff / RSz / Attr) for clipboard-friendly width.
Copy TableSame as Copy Row but for every row.

The calculator

Three radio buttons on the left choose which field is the source of truth:

ModeInputs → Outputs
VirtAddressEnter a fully-resolved VA (hex). The dialog computes RVA = VA - ImageBase, then converts the RVA to a file offset. Errors out if VA is below ImageBase.
RVAEnter an RVA (hex). The dialog computes VA = RVA + ImageBase and the file offset.
FileOffsetEnter a file offset (hex). The dialog computes the matching RVA (and hence VA) by walking the section table.

After each calculation:

The two non-source text fields are visually disabled (gray background) but text-selectable — on purpose, so you can copy the result. (The author's note in the source: "i hate that lordpe disables the textbox because you cant copy the text..")

Dump Fix

The small underlined "Dump Fix" link in the bottom-right runs CDumpFix.QuickDumpFix against a copy of the loaded file (saved as <original>.fix). DumpFix is for memory-dumped PE images: it walks the section table and rewrites the raw-offset and raw-size fields to match how the image is laid out on disk after the dump (typically: align to disk, copy section data linearly).

After the fix, the dialog reloads <original>.fix as the new active file and shows a confirmation MsgBox. If the fix fails, the temp .fix file is deleted and a "Failed" message is shown.

The typical workflow: dump a section / process from memory, save it as a flat blob, open it in File Hash, invoke this dialog, click Dump Fix. The result should now be loadable by IDA / x64dbg / disassemblers in general.

Notes