Leanpub Header

Skip to main content

Topics

Assembly and Reverse Engineering

From registers and calling conventions to disassemblers, live instrumentation, unknown file formats and coding agents, reverse engineering as told through the free samples of Leanpub books.

Created from the free samples of 8 Leanpub books, with every source cited.

Reverse engineering is the work of recovering how a piece of software behaves, and why it was built that way, from the software itself when its source code or documentation is missing. Ordinary development runs forward, from requirements through design and source code to a compiled executable; reverse engineering starts from the executable and works back through each stage.[1] Assembly language is the form in which that executable can be read: the instructions a processor carries out, written one per line, acting on the processor's registers or on memory reached through them.[2]

The field is wider than disassembly. One source lists five levels at which the work is done: readable source code that nobody documented, compiled binaries, network protocols, file formats, and the behaviour of a system observed from outside. It holds that all five follow one method, which is to observe, form a hypothesis, test it and revise.[6] The books published in 2026 add a new participant, the coding agent that drives a disassembler or writes a parser, and they agree that what such an agent says is a hypothesis to be tested and never evidence.[5][8]

This article covers what reverse engineering is used for, the law around it, the assembly language and machine model a reader needs, static and dynamic analysis, file formats and protocols, the techniques programs use to resist analysis, and work with coding agents. Its sources are the free samples of eight Leanpub books, all published in 2026. The pool is small, and it is mostly about reverse engineering: only one sample teaches assembly language itself, as groundwork for another subject, and none contains a full disassembly listing. Assembly appears here as that sample presents it.

Where to start

A reader who can program and has never opened a disassembler has one general starting point. The Reverse Engineering Handbook: From Beginner to Expert (2026) assumes basic programming in a language such as C or Python and no knowledge of assembly, binary formats or debugging, and its seventeen chapters are meant to be read in order, from how a processor executes code to firmware, protocols and patching.[1] The reader who wants the machine level first can begin with Buffer Overflow Exploitation and Defense Evasion (2026), which asks for basic C, including pointers and dynamic allocation, and builds assembly language and calling conventions from nothing on the way to its own subject, memory corruption.[2]

Three books suit a working developer with a particular kind of target. Mastering Frida (2026) needs fluency in one programming language and comfort in a terminal, and no reverse engineering experience; it teaches the instrumentation of running programs.[3] Reverse Engineering Databases and Storage Formats (2026) assumes programming and no knowledge of database internals, and works on bytes in files, not on code.[4] Decoding the Network with Claude Code (2026) asks for basic networking and simple Python scripting and applies the same discipline to captured traffic.[8]

Two books are about doing the work with a coding agent. Practical Agentic Reverse Engineering (2026) is written for developers and security researchers who are new to disassembly tooling and requires no fluent reading of assembly.[5] Reverse Engineering with Claude Code (2026) assumes programming, the command line and basic systems concepts, and gives most of its attention to inherited and undocumented systems.[6] Evasion Engineering (2026) is the one book for experienced readers: it assumes assembly language, C and reverse engineering concepts and does not teach them.[7]

History

The episode most often told about the field's legitimacy dates from 1982. A start-up wanted to build a portable computer that ran the software of the dominant personal computer, which required a functionally identical copy of that machine's copyrighted firmware. One team of engineers studied the original's behaviour and wrote functional specifications; a second team, whose members had never seen the original code, wrote new firmware from the specifications alone. This clean-room method produced a lawful compatible machine and opened the market for clones.[1]

The security side of the field has an equally early landmark. In November 1988 a worm spread across the Internet by sending a network service on Unix systems more data than its fixed-size buffer could hold, which overwrote a return address on the stack and let the worm run its own code. An estimated ten per cent of the computers then connected were infected.[2] Understanding such an attack, then and now, means reading what the processor does with the bytes it is given.

Software began resisting analysis in the same years. A boot-sector virus of 1986 intercepted disk reads to hide its own presence, and the first known polymorphic virus, in 1990, encrypted its body under a random key and rewrote its decryption routine on every infection, so that no two copies shared a byte sequence.[7] Checks for an attached debugger appeared early as well, because debugging was then the main means of analysis.[7]

What reverse engineering is used for

The general handbook among the sources lists the professional uses. Malware analysis and incident response come first: a sample found in the wild has to be taken apart to learn what it does, how it spreads and how to detect it, and one testing institute registers more than 450,000 new malicious or unwanted programs a day. Vulnerability research applies the same skills to commercial software to find flaws before attackers do. The other uses it names are interoperability, the analysis of firmware in routers, medical equipment and industrial controllers, the maintenance of old systems whose source code has been lost, forensic investigation, and the checking of patent claims.[1]

Interoperability has produced some of the best-known open-source software. Samba, which lets Unix-like systems take part in Windows file sharing, was built largely by reverse engineering a network protocol, and Wine, which runs Windows applications on other operating systems, by reverse engineering a programming interface.[1] The book on storage formats makes the same case for files: a format that cannot be read keeps its users tied to one vendor's software, and a compatible reader written from the bytes ends that dependence.[4]

Much of the work is done on systems an organisation already owns. One source describes the usual situation as a service written by someone who left years ago, a file format whose creator has gone out of business, or a production fault in a component whose behaviour was never specified, and treats reverse engineering as a routine engineering capability, not a last resort.[6] Storage formats give further reasons: recovering records from a damaged database that its own software refuses to open, answering a forensic question about a deleted row, and checking whether data said to be encrypted or erased really is.[4]

Law, authorisation and ethics

Every source in the pool sets a boundary before it teaches a technique. The legal position depends on the jurisdiction, the software and the purpose. In the United States, the Digital Millennium Copyright Act generally forbids circumventing technical protection measures, and its section 1201(f) exempts reverse engineering whose sole purpose is to make an independently created program interoperate with others. A rulemaking held every three years grants further temporary exemptions; the cycle that concluded in October 2024 renewed the one for security research, along with those for preserving abandoned software and for repairing consumer devices.[1] A 1992 appeals court decision held that disassembling a program to understand its interface for the sake of interoperability is fair use under copyright law.[1] In the European Union, Article 6 of the Software Directive (2009/24/EC) permits decompilation where it is indispensable for obtaining the information needed to build an interoperable program.[1]

None of this is a general permission. Licence agreements commonly prohibit reverse engineering, and how far such clauses can be enforced varies from one jurisdiction to another.[1] The book on coding agents describes the fair-use footing and the statutory exemption as narrow, and adds that an agent does not make an analysis lawful: the responsibility for authorisation stays with the person who directs it.[5] Examining a system that one neither owns nor controls can amount to unauthorised access under computer crime law even when the purpose is harmless.[6]

The practical rule the books share is to work only on software one owns, has written or holds explicit permission to analyse. The Frida book adds deliberately vulnerable laboratory targets to that list and observes that an instrumentation tool has no notion of who owns the process it touches.[3] A flaw found along the way is reported privately to the vendor, with reasonable time allowed for a fix before anything is published.[2]

Assembly language and the machine underneath

The one sample that teaches the machine level begins with the von Neumann architecture, in which instructions and data share one memory. The sample calls this the source of the computer's flexibility and of its basic weakness, since data placed where the processor expects instructions will be executed.[2] Memory is a linear array of numbered bytes. A 64-bit x86 processor currently uses 48 bits of each virtual address, which gives every process an address space of 256 terabytes.[2]

Registers and calling conventions

Registers are small storage locations inside the processor, far faster than main memory, and every assembly instruction operates on them or on memory addressed through them. The 64-bit x86 architecture has sixteen general-purpose registers. RAX conventionally holds arithmetic results and a function's return value; RSP points to the top of the stack, which grows downward, so that pushing a value decreases RSP; RBP conventionally marks a fixed point within the current stack frame, and a chain of saved RBP values is what lets a debugger print a backtrace.[2] Two special registers matter as much. RIP holds the address of the next instruction and cannot be written directly: only calls, jumps, returns and interrupts change it. RFLAGS holds the condition bits, such as the zero and carry flags, that arithmetic sets and conditional jumps test.[2]

A calling convention is the agreement about which registers carry a function's arguments and which a function must preserve. The sample contrasts two. Under the System V convention used on Linux, RDI and RSI carry the first two arguments and R8 and R9 the fifth and sixth; under the Windows 64-bit convention, RCX carries the first argument and R8 and R9 the third and fourth.[2] A reader of disassembled code needs the convention in order to tell what a function receives. The general handbook gives calling conventions a chapter of their own, after its chapters on processor architecture, assembly language and executable formats; the sample does not include them.[1]

Instructions and the execution cycle

The processor repeats one cycle. It fetches the instruction at the address in RIP, decodes it, executes it and writes back the result; processors that execute instructions out of order add a final step that commits results in program order, so that the visible behaviour matches sequential execution.[2] Instructions on 64-bit x86 vary in length from one to fifteen bytes, so the processor has to begin decoding an instruction before it knows where the next one starts.[2]

A small set of instructions accounts for most of what a beginner reads: MOV copies data between registers and memory, PUSH and POP move values to and from the stack, CALL pushes the return address and jumps to a function, RET pops that address back into RIP, JMP transfers control unconditionally, and LEA computes an address without reading memory.[2] Operands are found through addressing modes, of which the most common adds a displacement to a base register, optionally with an index register scaled by one, two, four or eight; this is how compiled code reaches the elements of an array.[2]

Two further facts shape everything a reverse engineer sees. The architecture is little-endian: the least significant byte of a multi-byte value sits at the lowest address, so an address printed in the usual way appears in memory with its bytes reversed.[2] And the hardware separates privilege levels, of which operating systems normally use two, one for the kernel and one for applications, with system calls as the controlled crossing between them.[2] Each page of memory also carries permission bits, including one that forbids execution, which is why a running program's code pages and data pages are distinct.[2]

Static and dynamic analysis

The general handbook describes the work as five phases. Acquisition and triage establish what the file is: its format (PE on Windows, ELF on Linux, Mach-O on macOS), its processor architecture, whether it is packed, and what strings it contains. Static analysis examines the binary without running it. Dynamic analysis runs it under controlled conditions. Instrumentation and automation scale the work with scripts, and a final phase combines the findings into a report. The phases are not strictly sequential: a function that looks suspicious in the disassembly is traced at run time, and behaviour seen in a debugger is taken back to the control flow graph.[1]

Static analysis rests on two operations. Disassembly converts machine code into assembly language, and decompilation reconstructs higher-level pseudocode from it.[1] Of the tools the handbook covers, Ghidra, radare2 and its graphical front end Cutter are free and open source, and the two commercial disassemblers it also teaches offer evaluation or reduced-price licences.[1] Static analysis is safe, because the program never runs, and it shows what a program is capable of doing.[3][1]

The Frida book names four limits of the static view. The state of a running program, such as a decrypted buffer or a configuration fetched from a server, is nowhere in the file. Address space layout randomisation loads the same binary at a different base address on every run. Code that is generated or downloaded at run time is absent from the file. And control flow that has been obfuscated can be close to unreadable on the page while behaving quite ordinarily when executed.[3] Dynamic analysis supplies real values, real addresses and the real order of events, at a price: the analyst is tied to a live process that may crash, may depend on inputs that cannot be reproduced, and may notice it is being watched.[3] In practice the two are combined, with static reading used to find candidate functions and dynamic observation to see what passes through them.[3] The handbook's debuggers for this phase include GDB, LLDB and x64dbg.[1]

Because dynamic analysis means running code that may be hostile, the handbook treats the laboratory as part of the method: a separate virtual machine for each operating system, a snapshot taken before each sample is run, network adapters isolated from the outside world, and shared folders and the shared clipboard disabled. QEMU emulates other processor architectures on an ordinary computer, which matters for firmware.[1]

Dynamic instrumentation

Dynamic instrumentation goes further than a debugger: it places the analyst's own code inside the running program. Frida, an open-source toolkit, injects a script into a live process, where it can read and scan memory, trace control flow, replace the behaviour of a function or call the program's internal functions directly.[3] The handbook lists it beside the debuggers and uses it on Windows, Linux and Android.[1]

No operating system offers a call that runs a function inside another process, so every injection framework is built from three moves: take control of the target, write a payload into its memory, and redirect execution to it. On Linux and Android the mechanism is the ptrace system call, which is subject to permission checks that explain why Android work usually needs a rooted device; on Apple platforms it is a right to the target's task port, granted by the kernel; on Windows it is a thread created remotely in the target that loads a library.[3] In each case the payload is a shared library, which in Frida's case is its agent.[3]

Frida's design follows from that. The agent runs inside the target with an embedded JavaScript engine, and a host program outside, written in Python or another language, exchanges messages with it. The separation means that a fault in the analyst's own tooling does not corrupt the target, and a crash of the target does not bring the tooling down.[3] Functions are found by name through the symbol table; a release build that has been stripped of symbols keeps its functions and loses the names, and they have to be located by other means.[3] The book also warns that version 17 of the toolkit, released in May 2025, removed older interfaces and moved the Java and Objective-C bridges out of the core, so that much tutorial material published before it no longer runs unchanged.[3]

File formats and protocols

The same method applies where there is no code to disassemble. Reverse Engineering Databases and Storage Formats starts from the habit of reading a hex dump: an offset column, the bytes in hexadecimal, and a text column in which printable characters appear as themselves. The reader learns to recognise the signatures that identify file types, the repeating structures that suggest arrays or headers, and the runs of zeros that indicate padding.[4]

Most binary formats share an anatomy. A magic number at a fixed position identifies the format (an SQLite database file begins with a readable string naming the format, a PNG image with a fixed four-byte sequence); a header, usually of fixed size, carries the version, global parameters, checksums and offsets; the body holds the data; and some formats end with a trailer for integrity checks or navigation.[4] Byte order has to be settled before any multi-byte value can be read. The book's heuristic is to interpret a field in both orders and keep the one that gives plausible numbers: a page size of 4,096 is reasonable, and one of a gigabyte is not.[4] It needs no commercial software for any of this, relying on the standard Linux utilities xxd, strings and od.[4]

Three working principles follow: no conclusion without evidence, no byte interpreted outside its context and without cross-checking against other sample files, and an expectation that the work proceeds by wrong guesses corrected, with the reasoning written down.[4] The book has the reader design a small format first, with a magic number, a version, a record count and a header checksum, and then goes on to pages, B-tree indexes, write-ahead logs and crash recovery, which the sample does not reach.[4]

Network protocols are approached in the same way. Decoding the Network with Claude Code opens with undocumented binary traffic on an unfamiliar port and a decision to be made within the hour, and sets out a sequence: gather what can be observed directly, form hypotheses (the structure might be type-length-value, for instance), test them by writing parsers and comparing sessions, and record each conclusion as a fact, an inference or a working hypothesis.[8] It argues that searching a capture for known signatures leaves the analyst helpless before a protocol nobody has seen.[8]

Resistance to analysis

Software that does not want to be understood works against each phase of the workflow. Evasion Engineering distinguishes three categories: evasion of signatures, which changes how code or data looks; evasion of behavioural detection, which avoids the run-time activity that monitors look for; and evasion of analysis, which detects sandboxes, debuggers and reverse engineering tools and responds to them. Capable software usually combines all three.[7]

The techniques that bear most on static analysis are the oldest. Polymorphic code keeps its body encrypted and varies the decryption routine by substituting instructions, renaming registers and inserting instructions that do nothing; metamorphic code rewrites its whole body in the same manner while preserving what it does.[7] A packer compresses or encrypts an executable and replaces its entry point with a stub that restores the original code at run time. UPX, released in 1996, was designed to make files smaller, and the same mechanism hides a payload from a disassembler, which is why a packed file cannot be judged malicious from its structure alone.[7] Checking whether a file is packed is accordingly part of triage.[1]

For the analyst, the consequence is that static and dynamic findings can disagree, and that a program which behaves differently when observed has to be approached with that in mind.[1] The general handbook gives a chapter to defeating obfuscation and anti-debugging and to unpacking protected binaries, and Evasion Engineering gives chapters to anti-debugging architectures, code obfuscation and polymorphic systems; neither sample includes those chapters.[1][7]

Reverse engineering with coding agents

Three of the eight books are about work done with an AI coding agent, and they agree on its place. An agent can read across many files, run tools and interpret their output, write analysis scripts and parsers, draft documentation and propose hypotheses. It is not a disassembler, a decompiler or a debugger, and it does not verify its own claims.[6] Asked to explain something from partial information, it tends to fill the gaps with plausible invention, such as a call path or an interface that does not exist, and one source calls treating its output as a substitute for tool output or human checking the most common failure of AI-assisted reverse engineering.[6] The protocol book describes the agent as a fast and capable junior analyst who is dangerous to trust without verification.[8]

The books answer with a discipline about evidence. Reverse Engineering with Claude Code keeps static evidence, drawn from artifacts without running them, apart from dynamic evidence, drawn from observed execution, and holds that a finding is strong when source analysis, run-time observation and tool output all support it.[6] Practical Agentic Reverse Engineering builds on an open-source tool, REA, which connects an agent through the Model Context Protocol to Ghidra and to analysers for JavaScript applications, Android packages and network captures, and returns each finding with the evidence behind it.[5] Its method is a loop of six steps (ask, trace, read the evidence, follow up, reconstruct, verify), and it treats decompiled C as a hypothesis that is confirmed by differential testing, in which the same inputs are run against the reconstruction and the original binary.[5]

The division of labour it proposes leaves three things with the person: the research question, the boundary of what may be analysed, and the final verification.[5] The book names the failures an agent introduces, which are invented addresses, stale tool state and the loss of context over a long session, and it notes a practical point about confidentiality: analysis runs on the analyst's machine, but the results pass to the agent, and so to the provider of its model.[5]

Questions about Assembly and Reverse Engineering

Which reverse engineering book should I start with?

A reader who can program in C or Python and has never used a disassembler can start with The Reverse Engineering Handbook: From Beginner to Expert (2026), which assumes no assembly and is meant to be read in order.[1] A reader who wants the machine level first can start with Buffer Overflow Exploitation and Defense Evasion (2026), which builds assembly and calling conventions from basic C.[2]

Do I need to know assembly language to reverse engineer software?

For compiled binaries, yes: disassembly turns machine code into assembly, and the general handbook teaches assembly before its tools because the tools' output has to be read.[1] Reverse engineering a file format or a network protocol works on bytes and needs none.[4][8] One book on agent-driven analysis requires no fluent reading of assembly, on condition that every reconstruction is tested against the original binary.[5]

It depends on the jurisdiction, the software and the purpose.[1] United States law exempts reverse engineering done solely for interoperability from its ban on circumventing protection measures, and the European Union's Software Directive permits decompilation where it is indispensable for interoperability; licence agreements may still forbid it, and their enforceability varies.[1] The sources teach on software the reader owns or is explicitly authorised to analyse.[3]

What is the difference between static and dynamic analysis?

Static analysis examines a binary without running it, through disassembly and decompilation, and shows what the program is capable of doing.[1] Dynamic analysis observes the program while it runs and gives real values, addresses and control flow, at the cost of depending on a live process that may crash or detect the observer.[3] The two are normally used together.[3]

What does the RIP register do?

On 64-bit x86 processors RIP holds the address of the next instruction to execute.[2] It cannot be written directly and changes only through calls, jumps, returns and interrupts, and a return instruction loads it from the top of the stack.[2]

Can an AI coding agent reverse engineer a binary for me?

It can do the mechanical work of driving a disassembler, tracing references and drafting a reconstruction.[5] Its output is a hypothesis: an agent does not verify its own claims and may invent call paths or addresses, so the sources confirm each result against tool output or by testing a reconstruction against the original binary.[6][5]

Sources

Every source is a Leanpub book or course. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.

  1. 1.
    The Reverse Engineering Handbook: From Beginner to Expert, Steve Publications: A Complete Guide to Binary Analysis, Debugging, and Software Deconstruction Free sample: the introduction and chapter 1 on what reverse engineering is used for, the law, the five-phase workflow and the laboratory; the later chapters are cited from the contents. 2026. Free sample: PDF · EPUB
  2. 2.
    Buffer Overflow Exploitation and Defense Evasion, Steve Publications: A Deep Dive into Memory Corruption Vulnerabilities, Exploitation, and Defense Free sample: the introduction and chapter 1 on memory addressing, the x86-64 registers, the execution cycle, byte order, privilege levels and paging. 2026. Free sample: PDF · EPUB
  3. 3.
    Mastering Frida, Steve Publications: Dynamic Instrumentation, Reverse Engineering and Security Testing with frida.re Free sample: the introduction, chapter 1 on static and dynamic analysis, the process model and injection on each platform, and part of chapter 2 on the toolkit's components. 2026. Free sample: PDF · EPUB
  4. 4.
    Reverse Engineering Databases and Storage Formats, Steve Publications: From Binary Bytes to Complete Understanding Free sample: chapter 1 on why storage formats are reverse engineered, chapter 2 on hex dumps, byte order, encodings and file anatomy, and the opening of chapter 3 on designing a simple format. 2026. Free sample: PDF · EPUB
  5. 5.
    Practical Agentic Reverse Engineering, Ground Truth Books: Binaries, Electron, Android and the Web with REA and Ghidra Free sample: chapter 1 on the tool, the intended reader, the legal limits and the outline of every chapter, and the opening of chapter 5 on the evidence loop. 2026. Free sample: PDF · EPUB
  6. 6.
    Reverse Engineering with Claude Code, Steve Publications: AI-Assisted Analysis, Understanding, and Reconstruction of Software Systems Free sample: the introduction on method, the agent's abilities and limits, authorisation and kinds of evidence, and the opening of chapter 1 on the levels of reverse engineering. 2026. Free sample: PDF · EPUB
  7. 7.
    Evasion Engineering, Steve Publications: A Comprehensive Technical Reference: From Foundational Concepts to Advanced Implementation Free sample: the introduction and part of chapter 1 on the categories of evasion and their history, including polymorphic code, packers and anti-debugging. 2026. Free sample: PDF · EPUB
  8. 8.
    Decoding the Network with Claude Code, Steve Publications: A Practical Guide to Understanding, Reverse Engineering, and Automating Network Data Analysis Free sample: the introduction on the method of protocol analysis and the agent's role in it, and the opening of chapter 1. 2026. Free sample: PDF · EPUB

Further reading

Other books in the library on the same ground, not cited above.

  • CPU Performance Engineering, Steve Publications: From Architecture to Optimization - A Practical Guide to Making Software Faster How processors execute instructions, from pipelines and branch prediction to caches, written for measuring and improving performance. 2026. Free sample: PDF · EPUB
  • Offensive Security Testing, Steve Publications: Methodologies for Professional Assessment A methodology for penetration testing, one of whose fourteen chapters covers fuzzing, binary analysis and protocol reverse engineering. 2026. Free sample: PDF · EPUB

This is an article created from the free samples of 8 Leanpub books. We're building these articles to provide you, the Leanpub reader, with a good jumping-off point to discover more Leanpub books that are interesting and relevant to you. We never use material which is paid-only when building these articles: we only use material which is already free on Leanpub. However, Leanpub authors can opt out from inclusion in articles from their book settings page.

Updated November 2026.

In the Leanpub store: 24 books in the Reverse Engineering category

All topics