Skip to content

Instantly share code, notes, and snippets.

@H4niz
Created June 5, 2018 16:14
Show Gist options
  • Save H4niz/baab8982a492f208b7d309008a41074b to your computer and use it in GitHub Desktop.
Save H4niz/baab8982a492f208b7d309008a41074b to your computer and use it in GitHub Desktop.
.text:08048999 delete proc near ; CODE XREF: handler:loc_8048C41↓p
.text:08048999
.text:08048999 index = dword ptr -38h
.text:08048999 _cart = dword ptr -34h
.text:08048999 Item_Num = dword ptr -30h
.text:08048999 next_chunk = dword ptr -2Ch
.text:08048999 Prev_chunk = dword ptr -28h
.text:08048999 nptr = byte ptr -22h
.text:08048999 var_C = dword ptr -0Ch
.text:08048999
.text:08048999 ; __unwind {
.text:08048999 push ebp
.text:0804899A mov ebp, esp
.text:0804899C sub esp, 48h
.text:0804899F mov eax, large gs:14h
.text:080489A5 mov [ebp+var_C], eax
.text:080489A8 xor eax, eax
.text:080489AA mov [ebp+index], 1
.text:080489B1 mov eax, ds:Cart
.text:080489B6 mov [ebp+_cart], eax
.text:080489B9 mov dword ptr [esp], offset aItemNumber ; "Item Number> "
.text:080489C0 call _printf
.text:080489C5 mov eax, ds:stdout@@GLIBC_2_0
.text:080489CA mov [esp], eax ; stream
.text:080489CD call _fflush
.text:080489D2 mov dword ptr [esp+4], 15h ; nbytes
.text:080489DA lea eax, [ebp+nptr]
.text:080489DD mov [esp], eax ; buf
.text:080489E0 call my_read
.text:080489E5 lea eax, [ebp+nptr]
.text:080489E8 mov [esp], eax ; nptr
.text:080489EB call _atoi
.text:080489F0 mov [ebp+Item_Num], eax
.text:080489F3 jmp short loc_8048A58
.text:080489F5 ; ---------------------------------------------------------------------------
.text:080489F5
.text:080489F5 loc_80489F5: ; CODE XREF: delete+C3↓j
.text:080489F5 mov eax, [ebp+index]
.text:080489F8 cmp eax, [ebp+Item_Num]
.text:080489FB jnz short loc_8048A4B
.text:080489FD mov eax, [ebp+_cart]
.text:08048A00 mov eax, [eax+8]
.text:08048A03 mov [ebp+next_chunk], eax
.text:08048A06 mov eax, [ebp+_cart]
.text:08048A09 mov eax, [eax+0Ch]
.text:08048A0C mov [ebp+Prev_chunk], eax
.text:08048A0F cmp [ebp+Prev_chunk], 0
.text:08048A13 jz short loc_8048A1E
.text:08048A15 mov eax, [ebp+Prev_chunk]
.text:08048A18 mov edx, [ebp+next_chunk]
.text:08048A1B mov [eax+8], edx
.text:08048A1E
.text:08048A1E loc_8048A1E: ; CODE XREF: delete+7A↑j
.text:08048A1E cmp [ebp+next_chunk], 0
.text:08048A22 jz short loc_8048A2D
.text:08048A24 mov eax, [ebp+next_chunk]
.text:08048A27 mov edx, [ebp+Prev_chunk]
.text:08048A2A mov [eax+0Ch], edx
.text:08048A2D
.text:08048A2D loc_8048A2D: ; CODE XREF: delete+89↑j
.text:08048A2D mov eax, [ebp+_cart]
.text:08048A30 mov eax, [eax]
.text:08048A32 mov [esp+8], eax
.text:08048A36 mov eax, [ebp+index]
.text:08048A39 mov [esp+4], eax
.text:08048A3D mov dword ptr [esp], offset aRemoveDSFromYo ; "Remove %d:%s from your shopping cart.\n"
.text:08048A44 call _printf
.text:08048A49 jmp short loc_8048A5E
.text:08048A4B ; ---------------------------------------------------------------------------
.text:08048A4B
.text:08048A4B loc_8048A4B: ; CODE XREF: delete+62↑j
.text:08048A4B add [ebp+index], 1
.text:08048A4F mov eax, [ebp+_cart]
.text:08048A52 mov eax, [eax+8]
.text:08048A55 mov [ebp+_cart], eax
.text:08048A58
.text:08048A58 loc_8048A58: ; CODE XREF: delete+5A↑j
.text:08048A58 cmp [ebp+_cart], 0
.text:08048A5C jnz short loc_80489F5
.text:08048A5E
.text:08048A5E loc_8048A5E: ; CODE XREF: delete+B0↑j
.text:08048A5E mov eax, [ebp+var_C]
.text:08048A61 xor eax, large gs:14h
.text:08048A68 jz short locret_8048A6F
.text:08048A6A call ___stack_chk_fail
.text:08048A6F ; ---------------------------------------------------------------------------
.text:08048A6F
.text:08048A6F locret_8048A6F: ; CODE XREF: delete+CF↑j
.text:08048A6F leave
.text:08048A70 retn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment