├── .gitattributes ├── 978-1-4842-9152-8.jpg ├── Chapter10 └── LocalVariables.cpp ├── Chapter11 ├── Arithmetic.cpp └── FunctionParameters.cpp ├── Chapter13 ├── Arithmetic.cpp ├── Arithmetic.h └── FunctionParameters.cpp ├── Chapter2 └── ArithmeticProjectC.cpp ├── Chapter4 └── PointersProject.asm ├── Chapter6 └── MemoryPointers.asm ├── Chapter8 └── PointersAsVariables.cpp ├── Chapter9 ├── SimpleStack.c ├── func.c ├── func2.c └── func3.c ├── Contributing.md ├── LICENSE.txt ├── README.md └── errata.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /978-1-4842-9152-8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/linux-debugging-disassembling-reversing/bcbfadc8b85a0e0de1671be9bdecf04b689ac7c3/978-1-4842-9152-8.jpg -------------------------------------------------------------------------------- /Chapter10/LocalVariables.cpp: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | int a, b; 4 | 5 | a = 1; 6 | b = 1; 7 | 8 | b = b + a; 9 | ++a; 10 | b = b * a; 11 | 12 | return 0; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Chapter11/Arithmetic.cpp: -------------------------------------------------------------------------------- 1 | int arithmetic (int a, int b) 2 | { 3 | b = b + a; 4 | ++a; 5 | b = b * a; 6 | 7 | return b; 8 | } 9 | -------------------------------------------------------------------------------- /Chapter11/FunctionParameters.cpp: -------------------------------------------------------------------------------- 1 | int arithmetic (int a, int b); 2 | 3 | int main(int argc, char* argv[]) 4 | { 5 | int result = arithmetic (1, 1); 6 | 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Chapter13/Arithmetic.cpp: -------------------------------------------------------------------------------- 1 | #include "Arithmetic.h" 2 | 3 | bool arithmetic (int a, int *b) 4 | { 5 | if (!b) 6 | { 7 | return false; 8 | } 9 | 10 | *b = *b + a; 11 | ++a; 12 | *b = *b * a; 13 | 14 | return true; 15 | } -------------------------------------------------------------------------------- /Chapter13/Arithmetic.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ARITHMETIC_H__ 3 | #define __ARITHMETIC_H__ 4 | 5 | bool arithmetic (int a, int *b); 6 | 7 | #endif -------------------------------------------------------------------------------- /Chapter13/FunctionParameters.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Arithmetic.h" 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | int a, b; 7 | 8 | printf("Enter a and b: "); 9 | scanf("%d %d", &a, &b); 10 | 11 | if (arithmetic (a, &b)) 12 | { 13 | printf("Result = %d", b); 14 | } 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Chapter2/ArithmeticProjectC.cpp: -------------------------------------------------------------------------------- 1 | int a, b; 2 | 3 | int main(int argc, char* argv[]) 4 | { 5 | a = 1; 6 | 7 | b = 1; 8 | 9 | b = b + a; 10 | 11 | ++a; 12 | 13 | b = b * a; 14 | 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Chapter4/PointersProject.asm: -------------------------------------------------------------------------------- 1 | .global _start 2 | 3 | .data 4 | 5 | a: .int 0 6 | b: .int 0 7 | 8 | .text 9 | 10 | main: 11 | _start: 12 | lea a, %rax 13 | movl $1, (%rax) 14 | 15 | lea b, %rbx 16 | movl $1, (%rbx) 17 | 18 | mov (%rax), %edx 19 | add %edx, (%rbx) 20 | 21 | incl (%rax) 22 | 23 | mov (%rax), %eax 24 | imul (%rbx), %eax 25 | mov %eax, (%rbx) 26 | 27 | mov $0x3c, %rax 28 | mov $0, %rdi 29 | syscall 30 | -------------------------------------------------------------------------------- /Chapter6/MemoryPointers.asm: -------------------------------------------------------------------------------- 1 | .global _start 2 | 3 | .data 4 | 5 | a: .int 0 6 | b: .int 0 7 | pa: .quad 0 8 | pb: .quad b 9 | 10 | .text 11 | 12 | main: 13 | _start: 14 | lea a, %rax 15 | mov %rax, pa 16 | 17 | mov pa, %rax 18 | movl $1, (%rax) 19 | 20 | mov pb, %rbx 21 | movl $1, (%rbx) 22 | 23 | mov (%rax), %ecx 24 | add (%rbx), %ecx 25 | mov %ecx, (%rbx) 26 | 27 | mov $0x3c, %rax 28 | mov $0, %rdi 29 | syscall 30 | 31 | -------------------------------------------------------------------------------- /Chapter8/PointersAsVariables.cpp: -------------------------------------------------------------------------------- 1 | int a, b; 2 | int *pa, *pb; 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | pa = &a; 7 | pb = &b; 8 | 9 | *pa = 1; 10 | *pb = 1; 11 | 12 | *pb = *pb + *pa; 13 | 14 | ++*pa; 15 | 16 | *pb = *pb * *pa; 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Chapter9/SimpleStack.c: -------------------------------------------------------------------------------- 1 | void func(); 2 | 3 | int main(int argc, char* argv[]) 4 | { 5 | func(); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Chapter9/func.c: -------------------------------------------------------------------------------- 1 | void func2(); 2 | 3 | void func() 4 | { 5 | func2(); 6 | } 7 | -------------------------------------------------------------------------------- /Chapter9/func2.c: -------------------------------------------------------------------------------- 1 | void func3(); 2 | 3 | void func2() 4 | { 5 | func3(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /Chapter9/func3.c: -------------------------------------------------------------------------------- 1 | void func3() 2 | { 3 | __asm__ volatile("int $0x03"); 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Apress Source Code 2 | 3 | Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. 4 | 5 | ## How to Contribute 6 | 7 | 1. Make sure you have a GitHub account. 8 | 2. Fork the repository for the relevant book. 9 | 3. Create a new branch on which to make your change, e.g. 10 | `git checkout -b my_code_contribution` 11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. 12 | 5. Submit a pull request. 13 | 14 | Thank you for your contribution! -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Freeware License, some rights reserved 2 | 3 | Copyright (c) 2023 Dmitry Vostokov 4 | 5 | Permission is hereby granted, free of charge, to anyone obtaining a copy 6 | of this software and associated documentation files (the "Software"), 7 | to work with the Software within the limits of freeware distribution and fair use. 8 | This includes the rights to use, copy, and modify the Software for personal use. 9 | Users are also allowed and encouraged to submit corrections and modifications 10 | to the Software for the benefit of other users. 11 | 12 | It is not allowed to reuse, modify, or redistribute the Software for 13 | commercial use in any way, or for a user’s educational materials such as books 14 | or blog articles without prior permission from the copyright holder. 15 | 16 | The above copyright notice and this permission notice need to be included 17 | in all copies or substantial portions of the software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apress Source Code 2 | 3 | This repository accompanies [*Foundations of Linux Debugging, Disassembling, and Reversing*](https://link.springer.com/book/10.1007/978-1-4842-9153-5) by Dmitry Vostokov (Apress, 2023). 4 | 5 | [comment]: #cover 6 | ![Cover image](978-1-4842-9152-8.jpg) 7 | 8 | Download the files as a zip using the green button, or clone the repository to your machine using Git. 9 | 10 | ## Releases 11 | 12 | Release v1.0 corresponds to the code in the published book, without corrections or updates. 13 | 14 | ## Contributions 15 | 16 | See the file Contributing.md for more information on how you can contribute to this repository. -------------------------------------------------------------------------------- /errata.md: -------------------------------------------------------------------------------- 1 | # Errata for *Foundations of Linux Debugging, Disassembling, and Reversing* 2 | 3 | On **page xx** [Summary of error]: 4 | 5 | Details of error here. Highlight key pieces in **bold**. 6 | 7 | *** 8 | 9 | On **page xx** [Summary of error]: 10 | 11 | Details of error here. Highlight key pieces in **bold**. 12 | 13 | *** --------------------------------------------------------------------------------