# Analysis examples

Canonical HTML: <https://www.de-decompiler.com/analysis_examples.htm>

These walkthroughs use DE Decompiler 26.7 to examine Windows binaries and revisit saved analysis. Each example shows where to look in the interface and how to interpret the recovered output.

## Follow SQL logic in decompiled code

This example uses a recovered procedure from an application built with Delphi 6. The goal is to see when the code opens a database connection, runs a query and branches on the result.

1. Find `FileExists` and the string `db.akd`. The file check controls whether the code calls a routine that still has a generated name.
2. Follow the assignments to `Self.db.Connected` and `Self.q2.Active`. The listing clears the query text, passes a string beginning with `SELECT version FROM` to `SQL.Add`, and sets the query active.
3. Read the test `((Self.q2.RecordCount - 1) <> 0)`. A count other than one takes the branch with the message-box call.

The recovered listing shows the query setup and the condition for the message. Use this to narrow the code review to the connection setup, the query text and both branches. The screenshot shows the beginning of the SQL statement.

[The recovered listing places the file check, query setup and record-count comparison in the same procedure.](https://www.de-decompiler.com/image/articles/de_decompiler_267/de_decompiler_267_sql_db_decompilation.png)

[Read the full 26.7 walkthrough](https://www.de-decompiler.com/de_decompiler_267.htm#workflow)

## Extract graphics from a VCL form

Photo Catalog is a Win32 sample built with Delphi 13. Its form contains two illustrations embedded in a binary DFM resource.

1. Open the executable in DE Decompiler. In `Forms`, select `TfrmPhotoCatalog` to see the recovered layout and identify the two pictures.
2. Open `Plugins` → `FRX Image Viewer`. Select a thumbnail to inspect the image. The status bar shows its format and dimensions.
3. Choose `Save to file` to export a selected PNG. Repeat for the other thumbnail.

Both PNGs are 240 × 144 pixels. The files below match the original byte ranges in the executable.

[FRX Image Viewer displays both embedded pictures. Morning Coast is selected.](https://www.de-decompiler.com/image/screenshots/frx-viewer.png)

- [Mountain Ridge](https://www.de-decompiler.com/image/analysis-examples/mountain-ridge.png)
- [Morning Coast](https://www.de-decompiler.com/image/analysis-examples/morning-coast.png)

[FRX Image Viewer guide](https://www.de-decompiler.com/help/plugins.htm#frx-image-viewer)

<!-- Additional analysis examples -->

## From a VCL button to its handler

Photo Catalog, Win32, Delphi 13

1. Open `TfrmPhotoCatalog` in `Designer (read only)` and select `Show details`. The property pane lists the button’s event binding.
2. Double-click the event row. DE Decompiler opens `TfrmPhotoCatalog.btnShowDetailsClick` and selects it in the project tree.
3. The recovered listing assigns a new message to `Self.lblStatus.Caption`. This is how the button updates the status label.

- [The selected button and its event in the form designer.](https://www.de-decompiler.com/image/analysis-examples/demo-vcl-event.png)
- [The handler selected after following the event binding.](https://www.de-decompiler.com/image/analysis-examples/demo-vcl-handler.png)

## Check a Win64 loop against native instructions

Loop Preview, Win64, Delphi 13

1. Open `LoopPreview.exe` and find `SumTo` under `Code` → `ExportTable` → `ExportTable`. The decompiler shows a `for` loop with a generated argument name, `arg_1`. The routine adds the integers from 1 through N.
2. Switch to `Disassembler`. The forward `JG` skips the loop body if the starting value is above the upper bound. The backward `JNZ` returns to the body for the next iteration, and the final `MOV` places the sum in `EAX`.
3. The sample returns 0 for `N = 0` and 10 for `N = 4`. These inputs exercise the empty loop and a loop that updates its accumulator.

- [Recovered listing of the Win64 routine.](https://www.de-decompiler.com/image/analysis-examples/demo-loop-code.png)
- [The forward exit check and backward loop jump in the native disassembly.](https://www.de-decompiler.com/image/analysis-examples/demo-loop-asm.png)

## Reopen saved analysis from a VDD database

Photo Catalog, DE Decompiler 26.7

1. Open the handler and choose `File` → `Data Base` → `Save Decompiled Data As DataBase`. Confirm the option to process all code before saving.
2. Start a fresh DE Decompiler session and select `Open Decompiled DataBase`. The saved project tree and VDD information appear.
3. With the original EXE unavailable, reopen the form and follow its event link. The saved form, its two pictures and the previously decoded handler remain available. Procedures that were not cached still need the matching binary.

- [A fresh session reports that the VDD was loaded.](https://www.de-decompiler.com/image/analysis-examples/demo-vdd-loaded.png)
- [The form and embedded pictures are available from the saved analysis.](https://www.de-decompiler.com/image/analysis-examples/demo-vdd-form.png)
