Assembly Journey
2020. 10. 6. 21:59ㆍ0x03 Reversing Theory
728x90
/*
|1| Implementation about memcpy
|2| Implementation about strlen
|3| Implementation about memset
*/
const char* source = "assembly";
char* destination;
void Implement_memcpy()
{
__asm
{
// loop count is 10
// movsd is 4 count
// therefore, the memory has 40bytes.
push 0xA
pop ecx
mov esi, offset source
mov edi, offset destination
rep movsd
}
}
void Implement_strlen()
{
__asm
{
mov ecx, 0xFFFFFFFF
xor al, al
mov edi, source
mov ebx, edi
repne scasb; repeat will not Equal
; the scas is must be compare EDI to EAX
; if edi is not \x00, edi count will increment
sub edi, ebx
dec edi; substract '\x00' (null)
}
}
void Implement_memset()
{
__asm {
xor eax, eax
push 9
pop ecx; count
mov edi, esi
rep stosd
; the stos is EAX value will store in EDI
; (d)is dword 4byte
; Therefore, above instruction is initialize 9X4(36) bytes
}
}
'0x03 Reversing Theory' 카테고리의 다른 글
64bit Randomized Base Address Disable (0) | 2020.10.23 |
---|---|
User Account Control Summary (0) | 2019.12.20 |
User Account Control Agenda (0) | 2019.12.20 |
리버싱 기초 문제 (0) | 2019.01.16 |
MIPS 구축 (0) | 2018.08.15 |