SlideShare a Scribd company logo
C++ and Assembly: Debugging
and Reverse Engineering
Mike Gelfand
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
About me
• Mike Gelfand
• Principal developer at SolarWinds MSP
• Used a handful of programming languages in the past 10+ years
• Love cats
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Agenda
• What is the assembly language and how does it compare to C++?
• How do we leverage assembly knowledge in everyday life?
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Assembly Language,
whatever that is
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Typical use in modern age
•Operating systems (bootloaders,
hardware setup)
•Compilers (intermediate language, inline
assembler)
•Performance-critical code (encryption,
graphics, scientific simulations)
•Reverse engineering
•Debugging
leal -12(%ecx, %eax, 8), %edi
movzbl %ah, %ebp
fsub %st, %st(3)
(AT&T)
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Just how bad could it be?
CAN I HAZ
CLARITY?!
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Just how bad could it be?
leal -12(%ecx, %eax, 8), %edi
movzbl %ah, %ebp
fsub %st, %st(3)
(AT&T)
lea edi, [ecx + eax * 8 - 12]
movzx ebp, ah
fsub st(3), st
(Intel)
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Switching between Intel and AT&T flavors
Switch to Intel:
(gdb) set disassembly-flavor intel
(lldb) settings set target.x86-disassembly-flavor intel
Switch to AT&T (but why?):
(gdb) set disassembly-flavor att
(lldb) settings set target.x86-disassembly-flavor att
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
x86 registers overview © Wikipedia
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
General-purpose registers in the wild
Register Name Meaning [Extra] Use
RAX, EAX, AX Accumulator Result of multiplication or division
RBX, EBX, BX Base index Array index
RCX, ECX, CX Counter Number of iterations left in the loop or string operation
RDX, EDX, DX Data Multiplication result or dividend upper bits
RSP, ESP, SP Stack pointer Address of the top of the stack
RBP, EBP, BP Stack base pointer Address of the current stack frame
RSI, ESI, SI Source index Address of the current source operand of string operations
RDI, EDI, DI Destination index Address of the current destination operand of string operations
RIP, EIP Instruction pointer Address of the current instruction being executed
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
C++ vs. Assembly: Basic stuff
C++
int a = 5;
a += 7;
int b = a - 4;
a |= b;
bool c = a & 7;
a *= b;
b = *(int*)(a + b);
Assembly (AT&T)
mov $5, %eax
add $7, %eax
lea -4(%eax), %ebx
or %ebx, %eax
test $7, %eax
imul %ebx
mov (%eax, %ebx), %ebx
Assembly (Intel)
mov eax, 5
add eax, 7
lea ebx, [eax - 4]
or eax, ebx
test eax, 7
imul ebx
mov ebx, [eax + ebx]
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Flags register
Flag Meaning Category Use
CF Carry Status Carry or borrow indication (addition, subtraction, shift)
PF Parity Status Floating-point C2 flag check (e.g. FUCOM with NaN value)
AF Adjust Status Same as CF but just for the lower nibble (think BCD)
ZF Zero Status Result is zero/non-zero
SF Sign Status Result is negative/positive
OF Overflow Status Sign bit changed when adding two numbers of same sign, or subtracting two numbers of
different signs
DF Direction Control Specifies string processing direction
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
C++ vs. Assembly: Branching
C++
int a = 10;
while (a > 0)
{
if (a % 2 == 0)
a -= 3;
else
a /= 2;
}
Assembly (compiler)
[0x1f73] <+3>: mov ecx, 10
[0x1f76] <+6>: test ecx, ecx
[0x1f78] <+8>: jle 0x1f93 ; <+35>
[0x1f7a] <+10>: nop word ptr [eax + eax]
[0x1f80] <+16>: lea edx, [ecx - 0x3]
[0x1f83] <+19>: mov eax, ecx
[0x1f85] <+21>: shr eax
[0x1f87] <+23>: test cl, 0x1
[0x1f8a] <+26>: cmove eax, edx
[0x1f8d] <+29>: test eax, eax
[0x1f8f] <+31>: mov ecx, eax
[0x1f91] <+33>: jg 0x1f80 ; <+16>
[0x1f93] <+35>:
Assembly (human)
mov eax, 10
loop_start:
cmp eax, 0
jle finish
test eax, 1
jnz divide
sub eax, 3
jmp loop_start
divide:
sar eax, 1
jmp loop_start
finish:
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Calling conventions
• Where parameters and results reside
• In which order parameters are passed
• Who cleans up after the call
• What registers are preserved and who does it
• etc.
Currently in wide use:
• x86: cdecl, stdcall
• x64: MS, System V
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
C++ vs. Assembly: Calling functions (non-virtual, cdecl)
int f(int a, int b)
{
return a + b;
}
int g()
{
return f(2, 3) + 4;
}
f(int, int):
mov eax, DWORD PTR [esp + 0x8]
add eax, DWORD PTR [esp + 0x4]
ret
g():
push 0x3
push 0x2
call 0x8048520 <f(int, int)>
pop edx
add eax, 0x4
pop ecx
ret
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
C++ vs. Assembly: Calling functions (virtual, cdecl)
struct I
{
virtual int f(int a, int b) = 0;
};
struct A : public I
{
int f(int a, int b) override
{
return a + b;
}
};
int g(I& x)
{
return x.f(2, 3) + 4;
}
A::f(int, int):
mov eax, DWORD PTR [esp + 0xc]
add eax, DWORD PTR [esp + 0x8]
ret
g(I&):
sub esp, 0x10
mov eax, DWORD PTR [esp + 0x14]
mov edx, DWORD PTR [eax]
push 0x3
push 0x2
push eax
call DWORD PTR [edx]
add esp, 0x1c
add eax, 0x4
ret
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Assembly & Disassember
The Rescue Rangers
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #1: Waiting in kernel mode
// In a header far, far away
ULONG const TimeoutMs = 30000;
// Waiting up to 30 seconds for event to happen
LARGE_INTEGER timeout;
timeout.QuadPart = -1 * TimeoutMs * 10 * 1000;
NTSTATUS const waitResult =
KeWaitForSingleObject(&event, Executive,
KernelMode, FALSE, &timeout);
mov eax, dword ptr [TimeoutMs]
lea rcx, [rsp + 0x48] ; 1st arg
imul eax, eax, 0xFFFFD8F0
xor r9d, r9d ; 4th arg
xor r8d, r8d ; 3rd arg
xor edx, edx ; 2nd arg
mov qword ptr [rsp + 0x40], rax
lea rax, [rsp + 0x40]
mov qword ptr [rsp + 0x20], rax ; 5th arg
call qword ptr [_imp_KeWaitForSingleObject]
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #1: Waiting in kernel mode
// In a header far, far away
LONG const TimeoutMs = 30000;
// Waiting up to 30 seconds for event to happen
LARGE_INTEGER timeout;
timeout.QuadPart = -1 * TimeoutMs * 10 * 1000;
NTSTATUS const waitResult =
KeWaitForSingleObject(&event, Executive,
KernelMode, FALSE, &timeout);
mov eax, dword ptr [TimeoutMs]
lea rcx, [rsp + 0x48] ; 1st arg
imul eax, eax, 0xFFFFD8F0
xor r9d, r9d ; 4th arg
xor r8d, r8d ; 3rd arg
xor edx, edx ; 2nd arg
cdqe
mov qword ptr [rsp + 0x40], rax
lea rax, [rsp + 0x40]
mov qword ptr [rsp + 0x20], rax ; 5th arg
call qword ptr [_imp_KeWaitForSingleObject]
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #2: Magic statics
struct Data
{
int x;
Data() : x(123) {}
};
Data& GetData()
{
static Data data;
return data;
}
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #2: Magic statics
GCC 4.2.1 (released 10 years ago)
0x08048560 <_Z7GetDatav+0>: push ebp
0x08048561 <_Z7GetDatav+1>: mov ebp,esp
0x08048563 <_Z7GetDatav+3>: sub esp,0x8
0x08048566 <_Z7GetDatav+6>: cmp BYTE PTR ds:0x8049790,0x0
0x0804856d <_Z7GetDatav+13>: je 0x8048576 <_Z7GetDatav+22>
0x0804856f <_Z7GetDatav+15>: leave
0x08048570 <_Z7GetDatav+16>: mov eax,0x8049798
0x08048575 <_Z7GetDatav+21>: ret
0x08048576 <_Z7GetDatav+22>: mov DWORD PTR [esp],0x8049790
0x0804857d <_Z7GetDatav+29>: call 0x80483e4 <__cxa_guard_acquire@plt>
0x08048582 <_Z7GetDatav+34>: test eax,eax
0x08048584 <_Z7GetDatav+36>: je 0x804856f <_Z7GetDatav+15>
0x08048586 <_Z7GetDatav+38>: mov DWORD PTR [esp],0x8049798
0x0804858d <_Z7GetDatav+45>: call 0x80485e0 <Data>
0x08048592 <_Z7GetDatav+50>: mov DWORD PTR [esp],0x8049790
0x08048599 <_Z7GetDatav+57>: call 0x8048414 <__cxa_guard_release@plt>
0x0804859e <_Z7GetDatav+62>: mov eax,0x8049798
0x080485a3 <_Z7GetDatav+67>: leave
0x080485a4 <_Z7GetDatav+68>: ret
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #2: Magic statics
MSVC 12 (Visual Studio 2013)
example!GetData [example.cpp @ 14]:
14 00e61040 a14485e800 mov eax,dword ptr [example!$S1 (00e88544)]
15 00e61045 a801 test al,1
15 00e61047 7512 jne example!GetData+0x1b (00e6105b)
example!GetData+0x9 [example.cpp @ 15]:
15 00e61049 83c801 or eax,1
15 00e6104c b94085e800 mov ecx,offset example!data (00e88540)
15 00e61051 a34485e800 mov dword ptr [example!$S1 (00e88544)],eax
15 00e61056 e8aaffffff call example!ILT+0(??0DataQAEXZ) (00e61005)
example!GetData+0x1b [example.cpp @ 16]:
16 00e6105b b84085e800 mov eax,offset example!data (00e88540)
17 00e61060 c3 ret
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #2: Magic statics
MSVC 15 (Visual Studio 2017)
example!GetData [example.cpp @ 14]:
14 010765a0 64a12c000000 mov eax,dword ptr fs:[0000002Ch]
15 010765a6 8b0d80fc0c01 mov ecx,dword ptr [example!_tls_index (010cfc80)]
15 010765ac 8b0c88 mov ecx,dword ptr [eax+ecx*4]
15 010765af a14cfc0c01 mov eax,dword ptr [example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c)]
15 010765b4 3b8104010000 cmp eax,dword ptr [ecx+104h]
15 010765ba 7f06 jg example!GetData+0x22 (010765c2)
example!GetData+0x1c [example.cpp @ 16]:
16 010765bc b848fc0c01 mov eax,offset example!data (010cfc48)
17 010765c1 c3 ret
example!GetData+0x22 [example.cpp @ 15]:
15 010765c2 684cfc0c01 push offset example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c)
15 010765c7 e8d9afffff call example!ILT+1440(__Init_thread_header) (010715a5)
15 010765cc 83c404 add esp,4
15 010765cf 833d4cfc0c01ff cmp dword ptr [example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c)],0FFFFFFFFh
15 010765d6 75e4 jne example!GetData+0x1c (010765bc)
example!GetData+0x38 [example.cpp @ 15]:
15 010765d8 b948fc0c01 mov ecx,offset example!data (010cfc48)
15 010765dd e857c1ffff call example!ILT+5940(??0DataQAEXZ) (01072739)
15 010765e2 684cfc0c01 push offset example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c)
15 010765e7 e89eb6ffff call example!ILT+3205(__Init_thread_footer) (01071c8a)
15 010765ec 83c404 add esp,4
15 010765ef ebcb jmp example!GetData+0x1c (010765bc)
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #3: Code obfuscation
push edx
push 0x4920
mov dword ptr [esp], ecx
mov dword ptr [esp], edi
mov edi, 0x16BC2A97
push eax
mov eax, 0x7C4B60CD
add dword ptr [esp + 8], eax
mov eax, dword ptr [esp]
add esp, 4
add dword ptr [esp + 4], edi
sub dword ptr [esp + 4], 0x7C4B60CD
pop edi
push dword ptr [esp]
pop eax
push esi
mov esi, esp
add esi, 4
add esi, 4
xchg dword ptr [esp], esi
pop esp
push ebp
mov ebp, 0x16BC2A97
sub eax, ebp
pop ebp
mov edx, dword ptr [esp]
add esp, 4
void f(x86_regs32_t& regs, std::vector<std::uint32_t>& stack)
{
stack.push_back(regs.edx);
stack.push_back(0x4920);
stack[stack.size() - 1 - 0] = regs.ecx;
stack[stack.size() - 1 - 0] = regs.edi;
regs.edi = 0x16BC2A97;
stack.push_back(regs.eax);
regs.eax = 0x7C4B60CD;
stack[stack.size() - 1 - 2] += regs.eax;
regs.eax = stack[stack.size() - 1 - 0];
stack.pop_back();
stack[stack.size() - 1 - 1] += regs.edi;
stack[stack.size() - 1 - 1] -= 0x7C4B60CD;
regs.edi = stack[stack.size() - 1 - 0]; stack.pop_back();
stack.push_back(stack[stack.size() - 1 - 0]);
regs.eax = stack[stack.size() - 1 - 0]; stack.pop_back();
stack.push_back(regs.esi);
regs.esi = 0;
regs.esi += 1;
regs.esi += 1;
std::swap(stack[stack.size() - 1 - 0], regs.esi);
stack.resize(stack.size() - stack[stack.size() - 1 - 0] + 1);
stack.push_back(regs.ebp);
regs.ebp = 0x16BC2A97;
regs.eax -= regs.ebp;
regs.ebp = stack[stack.size() - 1 - 0]; stack.pop_back();
regs.edx = stack[stack.size() - 1 - 0];
stack.pop_back();
}
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Example #3: Code obfuscation
mov eax, edx
add edx, 0x16BC2A97
void f(std::uint32_t& eax, std::uint32_t& edx)
{
regs.eax = regs.edx;
regs.edx += 0x16BC2A97;
}
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
The Stuff
in case you’re interested
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Want to learn assembly and contribute at the same time?
• FASM — modern and fast assembler written in assembly
http://flatassembler.net/
• Menuet OS, Kolibri OS, BareMetal, and whole lot more
http://wiki.osdev.org/Projects
• KOL & MCK by Vladimir Kladov (achtung: Delphi)
http://kolmck.ru/
© 2017 SolarWinds MSP UK Ltd. All rights reserved.
Questions?
mike.gelfand@solarwinds.com
mikedld@mikedld.com
The SolarWinds and SolarWinds MSP trademarks are the
exclusive property of SolarWinds MSP UK Ltd. or its affiliates
and may be registered or pending registration with the U.S.
Patent and Trademark Office and in other countries. All other
SolarWinds MSP UK and SolarWinds trademarks, service
marks, and logos may be common law marks or are registered
or pending registration. All other trademarks mentioned
herein are used for identification purposes only and are
trademarks (and may be registered trademarks) of their
respective companies.

More Related Content

What's hot

The Ring programming language version 1.5.4 book - Part 25 of 185
The Ring programming language version 1.5.4 book - Part 25 of 185The Ring programming language version 1.5.4 book - Part 25 of 185
The Ring programming language version 1.5.4 book - Part 25 of 185
Mahmoud Samir Fayed
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareDaniel Blezek
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
Chih-Hsuan Kuo
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"
Yulia Tsisyk
 
IoT to the Database: Soldering, Python and a little PL/SQL
IoT to the Database: Soldering, Python and a little PL/SQLIoT to the Database: Soldering, Python and a little PL/SQL
IoT to the Database: Soldering, Python and a little PL/SQL
Blaine Carter
 
Pandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with codePandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with code
Tim Hong
 
ANPR FPGA Workshop
ANPR FPGA WorkshopANPR FPGA Workshop
A comparison of apache spark supervised machine learning algorithms for dna s...
A comparison of apache spark supervised machine learning algorithms for dna s...A comparison of apache spark supervised machine learning algorithms for dna s...
A comparison of apache spark supervised machine learning algorithms for dna s...
Valerio Morfino
 
The elements of a functional mindset
The elements of a functional mindsetThe elements of a functional mindset
The elements of a functional mindset
Eric Normand
 
Cosmological Perturbations and Numerical Simulations
Cosmological Perturbations and Numerical SimulationsCosmological Perturbations and Numerical Simulations
Cosmological Perturbations and Numerical Simulations
Ian Huston
 
【論文紹介】Relay: A New IR for Machine Learning Frameworks
【論文紹介】Relay: A New IR for Machine Learning Frameworks【論文紹介】Relay: A New IR for Machine Learning Frameworks
【論文紹介】Relay: A New IR for Machine Learning Frameworks
Takeo Imai
 
PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)
Hansol Kang
 
Network security
Network securityNetwork security
Network security
Rakesh chaudhary
 
Scala for Java programmers
Scala for Java programmersScala for Java programmers
Scala for Java programmers
輝 子安
 
Evaluation of X32 ABI for Virtualization and Cloud
Evaluation of X32 ABI for Virtualization and CloudEvaluation of X32 ABI for Virtualization and Cloud
Evaluation of X32 ABI for Virtualization and Cloud
The Linux Foundation
 
Fast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in PracticeFast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in Practice
Rakuten Group, Inc.
 
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
Maho Nakata
 
A compact bytecode format for JavaScriptCore
A compact bytecode format for JavaScriptCoreA compact bytecode format for JavaScriptCore
A compact bytecode format for JavaScriptCore
Tadeu Zagallo
 
Verification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed SystemsVerification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed Systems
Mykola Novik
 

What's hot (20)

The Ring programming language version 1.5.4 book - Part 25 of 185
The Ring programming language version 1.5.4 book - Part 25 of 185The Ring programming language version 1.5.4 book - Part 25 of 185
The Ring programming language version 1.5.4 book - Part 25 of 185
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics Hardware
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"
 
IoT to the Database: Soldering, Python and a little PL/SQL
IoT to the Database: Soldering, Python and a little PL/SQLIoT to the Database: Soldering, Python and a little PL/SQL
IoT to the Database: Soldering, Python and a little PL/SQL
 
AA-sort with SSE4.1
AA-sort with SSE4.1AA-sort with SSE4.1
AA-sort with SSE4.1
 
Pandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with codePandas+postgre sql 實作 with code
Pandas+postgre sql 實作 with code
 
ANPR FPGA Workshop
ANPR FPGA WorkshopANPR FPGA Workshop
ANPR FPGA Workshop
 
A comparison of apache spark supervised machine learning algorithms for dna s...
A comparison of apache spark supervised machine learning algorithms for dna s...A comparison of apache spark supervised machine learning algorithms for dna s...
A comparison of apache spark supervised machine learning algorithms for dna s...
 
The elements of a functional mindset
The elements of a functional mindsetThe elements of a functional mindset
The elements of a functional mindset
 
Cosmological Perturbations and Numerical Simulations
Cosmological Perturbations and Numerical SimulationsCosmological Perturbations and Numerical Simulations
Cosmological Perturbations and Numerical Simulations
 
【論文紹介】Relay: A New IR for Machine Learning Frameworks
【論文紹介】Relay: A New IR for Machine Learning Frameworks【論文紹介】Relay: A New IR for Machine Learning Frameworks
【論文紹介】Relay: A New IR for Machine Learning Frameworks
 
PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)PyTorch 튜토리얼 (Touch to PyTorch)
PyTorch 튜토리얼 (Touch to PyTorch)
 
Network security
Network securityNetwork security
Network security
 
Scala for Java programmers
Scala for Java programmersScala for Java programmers
Scala for Java programmers
 
Evaluation of X32 ABI for Virtualization and Cloud
Evaluation of X32 ABI for Virtualization and CloudEvaluation of X32 ABI for Virtualization and Cloud
Evaluation of X32 ABI for Virtualization and Cloud
 
Fast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in PracticeFast Wavelet Tree Construction in Practice
Fast Wavelet Tree Construction in Practice
 
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
quantum chemistry on quantum computer handson by Q# (2019/8/4@MDR Hongo, Tokyo)
 
A compact bytecode format for JavaScriptCore
A compact bytecode format for JavaScriptCoreA compact bytecode format for JavaScriptCore
A compact bytecode format for JavaScriptCore
 
Verification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed SystemsVerification of Concurrent and Distributed Systems
Verification of Concurrent and Distributed Systems
 

Viewers also liked

C++Now Trip Report
C++Now Trip ReportC++Now Trip Report
C++Now Trip Report
corehard_by
 
Ускоряем сборку С++ проектов. Практика использования unity-сборок
Ускоряем сборку С++ проектов. Практика использования unity-сборокУскоряем сборку С++ проектов. Практика использования unity-сборок
Ускоряем сборку С++ проектов. Практика использования unity-сборок
corehard_by
 
Analysis and interpretation of monitoring data
Analysis and interpretation of monitoring dataAnalysis and interpretation of monitoring data
Analysis and interpretation of monitoring data
corehard_by
 
Restinio - header-only http and websocket server
Restinio - header-only http and websocket serverRestinio - header-only http and websocket server
Restinio - header-only http and websocket server
corehard_by
 
(Не)чёткий поиск
(Не)чёткий поиск(Не)чёткий поиск
(Не)чёткий поиск
corehard_by
 
C++ в играх, больших и не очень
C++ в играх, больших и не оченьC++ в играх, больших и не очень
C++ в играх, больших и не очень
corehard_by
 
MxxRu::externals: Repositoryless Dependency Manager
MxxRu::externals: Repositoryless Dependency ManagerMxxRu::externals: Repositoryless Dependency Manager
MxxRu::externals: Repositoryless Dependency Manager
corehard_by
 
Benchmark it
Benchmark itBenchmark it
Benchmark it
corehard_by
 
Actors for fun and profit
Actors for fun and profitActors for fun and profit
Actors for fun and profit
corehard_by
 
The beast is becoming functional
The beast is becoming functionalThe beast is becoming functional
The beast is becoming functional
corehard_by
 
Обработка потока данных на примере deep packet inspection: внутренняя архитек...
Обработка потока данных на примере deep packet inspection: внутренняя архитек...Обработка потока данных на примере deep packet inspection: внутренняя архитек...
Обработка потока данных на примере deep packet inspection: внутренняя архитек...
corehard_by
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel mode
corehard_by
 
Субъекторная модель
Субъекторная модельСубъекторная модель
Субъекторная модель
corehard_by
 
Abseil - let the savior come?
Abseil - let the savior come?Abseil - let the savior come?
Abseil - let the savior come?
corehard_by
 
Поиск уязвимостей с использованием статического анализа кода
Поиск уязвимостей с использованием статического анализа кодаПоиск уязвимостей с использованием статического анализа кода
Поиск уязвимостей с использованием статического анализа кода
corehard_by
 
Battle: BDD vs notBDD
Battle: BDD vs notBDDBattle: BDD vs notBDD
Battle: BDD vs notBDD
COMAQA.BY
 
Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11
corehard_by
 
Слои тестового фрамеворка. Что? Где? Когда?
Слои тестового фрамеворка. Что? Где? Когда?Слои тестового фрамеворка. Что? Где? Когда?
Слои тестового фрамеворка. Что? Где? Когда?
COMAQA.BY
 
Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...
Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...
Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...
Ontico
 
Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)
Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)
Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)
Ontico
 

Viewers also liked (20)

C++Now Trip Report
C++Now Trip ReportC++Now Trip Report
C++Now Trip Report
 
Ускоряем сборку С++ проектов. Практика использования unity-сборок
Ускоряем сборку С++ проектов. Практика использования unity-сборокУскоряем сборку С++ проектов. Практика использования unity-сборок
Ускоряем сборку С++ проектов. Практика использования unity-сборок
 
Analysis and interpretation of monitoring data
Analysis and interpretation of monitoring dataAnalysis and interpretation of monitoring data
Analysis and interpretation of monitoring data
 
Restinio - header-only http and websocket server
Restinio - header-only http and websocket serverRestinio - header-only http and websocket server
Restinio - header-only http and websocket server
 
(Не)чёткий поиск
(Не)чёткий поиск(Не)чёткий поиск
(Не)чёткий поиск
 
C++ в играх, больших и не очень
C++ в играх, больших и не оченьC++ в играх, больших и не очень
C++ в играх, больших и не очень
 
MxxRu::externals: Repositoryless Dependency Manager
MxxRu::externals: Repositoryless Dependency ManagerMxxRu::externals: Repositoryless Dependency Manager
MxxRu::externals: Repositoryless Dependency Manager
 
Benchmark it
Benchmark itBenchmark it
Benchmark it
 
Actors for fun and profit
Actors for fun and profitActors for fun and profit
Actors for fun and profit
 
The beast is becoming functional
The beast is becoming functionalThe beast is becoming functional
The beast is becoming functional
 
Обработка потока данных на примере deep packet inspection: внутренняя архитек...
Обработка потока данных на примере deep packet inspection: внутренняя архитек...Обработка потока данных на примере deep packet inspection: внутренняя архитек...
Обработка потока данных на примере deep packet inspection: внутренняя архитек...
 
C++ in kernel mode
C++ in kernel modeC++ in kernel mode
C++ in kernel mode
 
Субъекторная модель
Субъекторная модельСубъекторная модель
Субъекторная модель
 
Abseil - let the savior come?
Abseil - let the savior come?Abseil - let the savior come?
Abseil - let the savior come?
 
Поиск уязвимостей с использованием статического анализа кода
Поиск уязвимостей с использованием статического анализа кодаПоиск уязвимостей с использованием статического анализа кода
Поиск уязвимостей с использованием статического анализа кода
 
Battle: BDD vs notBDD
Battle: BDD vs notBDDBattle: BDD vs notBDD
Battle: BDD vs notBDD
 
Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11Mixing C++ & Python II: Pybind11
Mixing C++ & Python II: Pybind11
 
Слои тестового фрамеворка. Что? Где? Когда?
Слои тестового фрамеворка. Что? Где? Когда?Слои тестового фрамеворка. Что? Где? Когда?
Слои тестового фрамеворка. Что? Где? Когда?
 
Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...
Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...
Метаданные для кластера: гонка key-value-героев / Руслан Рагимов, Светлана Ла...
 
Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)
Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)
Честное перформанс-тестирование / Дмитрий Пивоваров (ZeroTurnaround)
 

Similar to C++ and Assembly: Debugging and Reverse Engineering

Implement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdfImplement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
meerobertsonheyde608
 
Gettingstartedwithmatlabimageprocessing
GettingstartedwithmatlabimageprocessingGettingstartedwithmatlabimageprocessing
Gettingstartedwithmatlabimageprocessing
tvanii
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Sergey Platonov
 
Scale17x buffer overflows
Scale17x buffer overflowsScale17x buffer overflows
Scale17x buffer overflows
johseg
 
Vectorization on x86: all you need to know
Vectorization on x86: all you need to knowVectorization on x86: all you need to know
Vectorization on x86: all you need to knowRoberto Agostino Vitillo
 
Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityDefconRussia
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
National Cheng Kung University
 
The forgotten art of assembly
The forgotten art of assemblyThe forgotten art of assembly
The forgotten art of assembly
Marian Marinov
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadache
camsec
 
Fast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! AalborgFast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Sri Ambati
 
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdfTranslate the following CC++ code into MIPS Assembly Codevoid ch.pdf
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf
fcsondhiindia
 
class04_x86assembly.ppt hy there u need be
class04_x86assembly.ppt hy there u need beclass04_x86assembly.ppt hy there u need be
class04_x86assembly.ppt hy there u need be
mnewg218
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
Andrey Karpov
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)bolovv
 
WCTF 2018 binja Editorial
WCTF 2018 binja EditorialWCTF 2018 binja Editorial
WCTF 2018 binja Editorial
Charo_IT
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
oysteing
 
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen TatarynovWorkshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Fwdays
 
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...Positive Hack Days
 
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
ManhHoangVan
 

Similar to C++ and Assembly: Debugging and Reverse Engineering (20)

Implement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdfImplement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
 
Gettingstartedwithmatlabimageprocessing
GettingstartedwithmatlabimageprocessingGettingstartedwithmatlabimageprocessing
Gettingstartedwithmatlabimageprocessing
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
Scale17x buffer overflows
Scale17x buffer overflowsScale17x buffer overflows
Scale17x buffer overflows
 
Vectorization on x86: all you need to know
Vectorization on x86: all you need to knowVectorization on x86: all you need to know
Vectorization on x86: all you need to know
 
Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software security
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
The forgotten art of assembly
The forgotten art of assemblyThe forgotten art of assembly
The forgotten art of assembly
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadache
 
Fast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! AalborgFast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
Fast, stable and scalable true radix sorting with Matt Dowle at useR! Aalborg
 
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdfTranslate the following CC++ code into MIPS Assembly Codevoid ch.pdf
Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf
 
class04_x86assembly.ppt hy there u need be
class04_x86assembly.ppt hy there u need beclass04_x86assembly.ppt hy there u need be
class04_x86assembly.ppt hy there u need be
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 
WCTF 2018 binja Editorial
WCTF 2018 binja EditorialWCTF 2018 binja Editorial
WCTF 2018 binja Editorial
 
MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0MySQL Optimizer: What’s New in 8.0
MySQL Optimizer: What’s New in 8.0
 
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen TatarynovWorkshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
Workshop "Can my .NET application use less CPU / RAM?", Yevhen Tatarynov
 
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
 
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
 

More from corehard_by

C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
corehard_by
 
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
corehard_by
 
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений ОхотниковC++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
corehard_by
 
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр ТитовC++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
corehard_by
 
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
corehard_by
 
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья ШишковC++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
corehard_by
 
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
corehard_by
 
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
corehard_by
 
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
corehard_by
 
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
corehard_by
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
corehard_by
 
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
corehard_by
 
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел ФилоновC++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
corehard_by
 
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan ČukićC++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
corehard_by
 
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia KazakovaC++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
corehard_by
 
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон ПолухинC++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
corehard_by
 
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
corehard_by
 
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
corehard_by
 
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
corehard_by
 
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
corehard_by
 

More from corehard_by (20)

C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
 
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
 
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений ОхотниковC++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
 
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр ТитовC++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
 
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
 
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья ШишковC++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
 
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
 
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
 
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
 
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
 
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
 
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел ФилоновC++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
 
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan ČukićC++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
 
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia KazakovaC++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
 
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон ПолухинC++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
 
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
 
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
 
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
 
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

C++ and Assembly: Debugging and Reverse Engineering

  • 1. C++ and Assembly: Debugging and Reverse Engineering Mike Gelfand
  • 2. © 2017 SolarWinds MSP UK Ltd. All rights reserved. About me • Mike Gelfand • Principal developer at SolarWinds MSP • Used a handful of programming languages in the past 10+ years • Love cats
  • 3. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Agenda • What is the assembly language and how does it compare to C++? • How do we leverage assembly knowledge in everyday life?
  • 4. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Assembly Language, whatever that is
  • 5. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Typical use in modern age •Operating systems (bootloaders, hardware setup) •Compilers (intermediate language, inline assembler) •Performance-critical code (encryption, graphics, scientific simulations) •Reverse engineering •Debugging
  • 6. leal -12(%ecx, %eax, 8), %edi movzbl %ah, %ebp fsub %st, %st(3) (AT&T) © 2017 SolarWinds MSP UK Ltd. All rights reserved. Just how bad could it be? CAN I HAZ CLARITY?!
  • 7. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Just how bad could it be? leal -12(%ecx, %eax, 8), %edi movzbl %ah, %ebp fsub %st, %st(3) (AT&T) lea edi, [ecx + eax * 8 - 12] movzx ebp, ah fsub st(3), st (Intel)
  • 8. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Switching between Intel and AT&T flavors Switch to Intel: (gdb) set disassembly-flavor intel (lldb) settings set target.x86-disassembly-flavor intel Switch to AT&T (but why?): (gdb) set disassembly-flavor att (lldb) settings set target.x86-disassembly-flavor att
  • 9. © 2017 SolarWinds MSP UK Ltd. All rights reserved. x86 registers overview © Wikipedia
  • 10. © 2017 SolarWinds MSP UK Ltd. All rights reserved. General-purpose registers in the wild Register Name Meaning [Extra] Use RAX, EAX, AX Accumulator Result of multiplication or division RBX, EBX, BX Base index Array index RCX, ECX, CX Counter Number of iterations left in the loop or string operation RDX, EDX, DX Data Multiplication result or dividend upper bits RSP, ESP, SP Stack pointer Address of the top of the stack RBP, EBP, BP Stack base pointer Address of the current stack frame RSI, ESI, SI Source index Address of the current source operand of string operations RDI, EDI, DI Destination index Address of the current destination operand of string operations RIP, EIP Instruction pointer Address of the current instruction being executed
  • 11. © 2017 SolarWinds MSP UK Ltd. All rights reserved. C++ vs. Assembly: Basic stuff C++ int a = 5; a += 7; int b = a - 4; a |= b; bool c = a & 7; a *= b; b = *(int*)(a + b); Assembly (AT&T) mov $5, %eax add $7, %eax lea -4(%eax), %ebx or %ebx, %eax test $7, %eax imul %ebx mov (%eax, %ebx), %ebx Assembly (Intel) mov eax, 5 add eax, 7 lea ebx, [eax - 4] or eax, ebx test eax, 7 imul ebx mov ebx, [eax + ebx]
  • 12. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Flags register Flag Meaning Category Use CF Carry Status Carry or borrow indication (addition, subtraction, shift) PF Parity Status Floating-point C2 flag check (e.g. FUCOM with NaN value) AF Adjust Status Same as CF but just for the lower nibble (think BCD) ZF Zero Status Result is zero/non-zero SF Sign Status Result is negative/positive OF Overflow Status Sign bit changed when adding two numbers of same sign, or subtracting two numbers of different signs DF Direction Control Specifies string processing direction
  • 13. © 2017 SolarWinds MSP UK Ltd. All rights reserved. C++ vs. Assembly: Branching C++ int a = 10; while (a > 0) { if (a % 2 == 0) a -= 3; else a /= 2; } Assembly (compiler) [0x1f73] <+3>: mov ecx, 10 [0x1f76] <+6>: test ecx, ecx [0x1f78] <+8>: jle 0x1f93 ; <+35> [0x1f7a] <+10>: nop word ptr [eax + eax] [0x1f80] <+16>: lea edx, [ecx - 0x3] [0x1f83] <+19>: mov eax, ecx [0x1f85] <+21>: shr eax [0x1f87] <+23>: test cl, 0x1 [0x1f8a] <+26>: cmove eax, edx [0x1f8d] <+29>: test eax, eax [0x1f8f] <+31>: mov ecx, eax [0x1f91] <+33>: jg 0x1f80 ; <+16> [0x1f93] <+35>: Assembly (human) mov eax, 10 loop_start: cmp eax, 0 jle finish test eax, 1 jnz divide sub eax, 3 jmp loop_start divide: sar eax, 1 jmp loop_start finish:
  • 14. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Calling conventions • Where parameters and results reside • In which order parameters are passed • Who cleans up after the call • What registers are preserved and who does it • etc. Currently in wide use: • x86: cdecl, stdcall • x64: MS, System V
  • 15. © 2017 SolarWinds MSP UK Ltd. All rights reserved. C++ vs. Assembly: Calling functions (non-virtual, cdecl) int f(int a, int b) { return a + b; } int g() { return f(2, 3) + 4; } f(int, int): mov eax, DWORD PTR [esp + 0x8] add eax, DWORD PTR [esp + 0x4] ret g(): push 0x3 push 0x2 call 0x8048520 <f(int, int)> pop edx add eax, 0x4 pop ecx ret
  • 16. © 2017 SolarWinds MSP UK Ltd. All rights reserved. C++ vs. Assembly: Calling functions (virtual, cdecl) struct I { virtual int f(int a, int b) = 0; }; struct A : public I { int f(int a, int b) override { return a + b; } }; int g(I& x) { return x.f(2, 3) + 4; } A::f(int, int): mov eax, DWORD PTR [esp + 0xc] add eax, DWORD PTR [esp + 0x8] ret g(I&): sub esp, 0x10 mov eax, DWORD PTR [esp + 0x14] mov edx, DWORD PTR [eax] push 0x3 push 0x2 push eax call DWORD PTR [edx] add esp, 0x1c add eax, 0x4 ret
  • 17. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Assembly & Disassember The Rescue Rangers
  • 18. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #1: Waiting in kernel mode // In a header far, far away ULONG const TimeoutMs = 30000; // Waiting up to 30 seconds for event to happen LARGE_INTEGER timeout; timeout.QuadPart = -1 * TimeoutMs * 10 * 1000; NTSTATUS const waitResult = KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, &timeout); mov eax, dword ptr [TimeoutMs] lea rcx, [rsp + 0x48] ; 1st arg imul eax, eax, 0xFFFFD8F0 xor r9d, r9d ; 4th arg xor r8d, r8d ; 3rd arg xor edx, edx ; 2nd arg mov qword ptr [rsp + 0x40], rax lea rax, [rsp + 0x40] mov qword ptr [rsp + 0x20], rax ; 5th arg call qword ptr [_imp_KeWaitForSingleObject]
  • 19. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #1: Waiting in kernel mode // In a header far, far away LONG const TimeoutMs = 30000; // Waiting up to 30 seconds for event to happen LARGE_INTEGER timeout; timeout.QuadPart = -1 * TimeoutMs * 10 * 1000; NTSTATUS const waitResult = KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, &timeout); mov eax, dword ptr [TimeoutMs] lea rcx, [rsp + 0x48] ; 1st arg imul eax, eax, 0xFFFFD8F0 xor r9d, r9d ; 4th arg xor r8d, r8d ; 3rd arg xor edx, edx ; 2nd arg cdqe mov qword ptr [rsp + 0x40], rax lea rax, [rsp + 0x40] mov qword ptr [rsp + 0x20], rax ; 5th arg call qword ptr [_imp_KeWaitForSingleObject]
  • 20. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #2: Magic statics struct Data { int x; Data() : x(123) {} }; Data& GetData() { static Data data; return data; }
  • 21. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #2: Magic statics GCC 4.2.1 (released 10 years ago) 0x08048560 <_Z7GetDatav+0>: push ebp 0x08048561 <_Z7GetDatav+1>: mov ebp,esp 0x08048563 <_Z7GetDatav+3>: sub esp,0x8 0x08048566 <_Z7GetDatav+6>: cmp BYTE PTR ds:0x8049790,0x0 0x0804856d <_Z7GetDatav+13>: je 0x8048576 <_Z7GetDatav+22> 0x0804856f <_Z7GetDatav+15>: leave 0x08048570 <_Z7GetDatav+16>: mov eax,0x8049798 0x08048575 <_Z7GetDatav+21>: ret 0x08048576 <_Z7GetDatav+22>: mov DWORD PTR [esp],0x8049790 0x0804857d <_Z7GetDatav+29>: call 0x80483e4 <__cxa_guard_acquire@plt> 0x08048582 <_Z7GetDatav+34>: test eax,eax 0x08048584 <_Z7GetDatav+36>: je 0x804856f <_Z7GetDatav+15> 0x08048586 <_Z7GetDatav+38>: mov DWORD PTR [esp],0x8049798 0x0804858d <_Z7GetDatav+45>: call 0x80485e0 <Data> 0x08048592 <_Z7GetDatav+50>: mov DWORD PTR [esp],0x8049790 0x08048599 <_Z7GetDatav+57>: call 0x8048414 <__cxa_guard_release@plt> 0x0804859e <_Z7GetDatav+62>: mov eax,0x8049798 0x080485a3 <_Z7GetDatav+67>: leave 0x080485a4 <_Z7GetDatav+68>: ret
  • 22. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #2: Magic statics MSVC 12 (Visual Studio 2013) example!GetData [example.cpp @ 14]: 14 00e61040 a14485e800 mov eax,dword ptr [example!$S1 (00e88544)] 15 00e61045 a801 test al,1 15 00e61047 7512 jne example!GetData+0x1b (00e6105b) example!GetData+0x9 [example.cpp @ 15]: 15 00e61049 83c801 or eax,1 15 00e6104c b94085e800 mov ecx,offset example!data (00e88540) 15 00e61051 a34485e800 mov dword ptr [example!$S1 (00e88544)],eax 15 00e61056 e8aaffffff call example!ILT+0(??0DataQAEXZ) (00e61005) example!GetData+0x1b [example.cpp @ 16]: 16 00e6105b b84085e800 mov eax,offset example!data (00e88540) 17 00e61060 c3 ret
  • 23. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #2: Magic statics MSVC 15 (Visual Studio 2017) example!GetData [example.cpp @ 14]: 14 010765a0 64a12c000000 mov eax,dword ptr fs:[0000002Ch] 15 010765a6 8b0d80fc0c01 mov ecx,dword ptr [example!_tls_index (010cfc80)] 15 010765ac 8b0c88 mov ecx,dword ptr [eax+ecx*4] 15 010765af a14cfc0c01 mov eax,dword ptr [example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c)] 15 010765b4 3b8104010000 cmp eax,dword ptr [ecx+104h] 15 010765ba 7f06 jg example!GetData+0x22 (010765c2) example!GetData+0x1c [example.cpp @ 16]: 16 010765bc b848fc0c01 mov eax,offset example!data (010cfc48) 17 010765c1 c3 ret example!GetData+0x22 [example.cpp @ 15]: 15 010765c2 684cfc0c01 push offset example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c) 15 010765c7 e8d9afffff call example!ILT+1440(__Init_thread_header) (010715a5) 15 010765cc 83c404 add esp,4 15 010765cf 833d4cfc0c01ff cmp dword ptr [example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c)],0FFFFFFFFh 15 010765d6 75e4 jne example!GetData+0x1c (010765bc) example!GetData+0x38 [example.cpp @ 15]: 15 010765d8 b948fc0c01 mov ecx,offset example!data (010cfc48) 15 010765dd e857c1ffff call example!ILT+5940(??0DataQAEXZ) (01072739) 15 010765e2 684cfc0c01 push offset example!type_info `RTTI Type Descriptor'+0x128 (010cfc4c) 15 010765e7 e89eb6ffff call example!ILT+3205(__Init_thread_footer) (01071c8a) 15 010765ec 83c404 add esp,4 15 010765ef ebcb jmp example!GetData+0x1c (010765bc)
  • 24. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #3: Code obfuscation push edx push 0x4920 mov dword ptr [esp], ecx mov dword ptr [esp], edi mov edi, 0x16BC2A97 push eax mov eax, 0x7C4B60CD add dword ptr [esp + 8], eax mov eax, dword ptr [esp] add esp, 4 add dword ptr [esp + 4], edi sub dword ptr [esp + 4], 0x7C4B60CD pop edi push dword ptr [esp] pop eax push esi mov esi, esp add esi, 4 add esi, 4 xchg dword ptr [esp], esi pop esp push ebp mov ebp, 0x16BC2A97 sub eax, ebp pop ebp mov edx, dword ptr [esp] add esp, 4 void f(x86_regs32_t& regs, std::vector<std::uint32_t>& stack) { stack.push_back(regs.edx); stack.push_back(0x4920); stack[stack.size() - 1 - 0] = regs.ecx; stack[stack.size() - 1 - 0] = regs.edi; regs.edi = 0x16BC2A97; stack.push_back(regs.eax); regs.eax = 0x7C4B60CD; stack[stack.size() - 1 - 2] += regs.eax; regs.eax = stack[stack.size() - 1 - 0]; stack.pop_back(); stack[stack.size() - 1 - 1] += regs.edi; stack[stack.size() - 1 - 1] -= 0x7C4B60CD; regs.edi = stack[stack.size() - 1 - 0]; stack.pop_back(); stack.push_back(stack[stack.size() - 1 - 0]); regs.eax = stack[stack.size() - 1 - 0]; stack.pop_back(); stack.push_back(regs.esi); regs.esi = 0; regs.esi += 1; regs.esi += 1; std::swap(stack[stack.size() - 1 - 0], regs.esi); stack.resize(stack.size() - stack[stack.size() - 1 - 0] + 1); stack.push_back(regs.ebp); regs.ebp = 0x16BC2A97; regs.eax -= regs.ebp; regs.ebp = stack[stack.size() - 1 - 0]; stack.pop_back(); regs.edx = stack[stack.size() - 1 - 0]; stack.pop_back(); }
  • 25. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Example #3: Code obfuscation mov eax, edx add edx, 0x16BC2A97 void f(std::uint32_t& eax, std::uint32_t& edx) { regs.eax = regs.edx; regs.edx += 0x16BC2A97; }
  • 26. © 2017 SolarWinds MSP UK Ltd. All rights reserved. The Stuff in case you’re interested
  • 27. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Want to learn assembly and contribute at the same time? • FASM — modern and fast assembler written in assembly http://flatassembler.net/ • Menuet OS, Kolibri OS, BareMetal, and whole lot more http://wiki.osdev.org/Projects • KOL & MCK by Vladimir Kladov (achtung: Delphi) http://kolmck.ru/
  • 28. © 2017 SolarWinds MSP UK Ltd. All rights reserved. Questions? mike.gelfand@solarwinds.com mikedld@mikedld.com
  • 29. The SolarWinds and SolarWinds MSP trademarks are the exclusive property of SolarWinds MSP UK Ltd. or its affiliates and may be registered or pending registration with the U.S. Patent and Trademark Office and in other countries. All other SolarWinds MSP UK and SolarWinds trademarks, service marks, and logos may be common law marks or are registered or pending registration. All other trademarks mentioned herein are used for identification purposes only and are trademarks (and may be registered trademarks) of their respective companies.