.text:0804A1E8 ; Decoder: (byte-level) .text:0804A1E8 ; Pn = Cn - Cn-1 - 0x17, for n > 0 .text:0804A1E8 ; Po = Co - 0x17 .text:0804A1E8 ; .text:0804A1E8 ; => Corresponding Encoder: .text:0804A1E8 ; => Co = Po + 0x17 .text:0804A1E8 ; => Cn = Pn + Cn-1 + 0x17, for n > 0 .text:0804A1E8 ; Attributes: bp-based frame .text:0804A1E8 .text:0804A1E8 Decoder proc near ; CODE XREF: MainMonster+1D8p .text:0804A1E8 .text:0804A1E8 var_10 = byte ptr -10h .text:0804A1E8 tmpBuf_Decoder = dword ptr -4 .text:0804A1E8 Length = dword ptr 8 .text:0804A1E8 Cipher = dword ptr 0Ch .text:0804A1E8 PlainText = dword ptr 10h .text:0804A1E8 .text:0804A1E8 push ebp .text:0804A1E9 mov ebp, esp .text:0804A1EB sub esp, 4 ; Integer Subtraction .text:0804A1EE push edi .text:0804A1EF push esi .text:0804A1F0 push ebx .text:0804A1F1 mov edi, [ebp+Length] .text:0804A1F4 lea ebx, [edi-1] ; EBX = PacketSize-1 .text:0804A1F7 lea eax, [edi+3] ; //Round up to Nearest 4 bytes .text:0804A1F7 ; EAX = PacketSize+3 .text:0804A1FA and al, 0FCh ; //Round up to Nearest 4 bytes .text:0804A1FA ; PacketSize - (PacketSize%4) .text:0804A1FC sub esp, eax ; Create Stack Space for Packet .text:0804A1FE mov [ebp+tmpBuf_Decoder], esp .text:0804A201 mov al, ds:gState1 .text:0804A207 mov esi, [ebp+PlainText] .text:0804A20A mov [esi], al ; 1st Byte of Output = AL .text:0804A20A ; = (0?) byte_80675E5 .text:0804A20C test ebx, ebx ; Logical Compare .text:0804A20E jl Exit_Decoder ; Jump if Less (SF!=OF) .text:0804A20E .text:0804A214 .text:0804A214 Processing_1: ; CODE XREF: Decoder+ADj .text:0804A214 lea edx, [ebx-1] ; EBX = n .text:0804A214 ; EDX = n-1 .text:0804A217 test ebx, ebx ; Logical Compare .text:0804A219 jz short Finished_Processing ; Jump if Zero (ZF=1) .text:0804A219 .text:0804A21B mov esi, [ebp+Cipher] .text:0804A21E movzx eax, byte ptr [ebx+esi] ; EAX = C(n) .text:0804A222 movzx edx, byte ptr [edx+esi] ; EDX = C(n-1) .text:0804A226 sub eax, edx ; EAX = C(n) - C(n-1) .text:0804A228 jmp short Processing_2 ; ECX = P(n) .text:0804A228 ; =C(n)-C(n-1)-0x17 .text:0804A228 .text:0804A228 ; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ .text:0804A22A align 4 .text:0804A22C .text:0804A22C Finished_Processing: ; CODE XREF: Decoder+31j .text:0804A22C mov esi, [ebp+Cipher] .text:0804A22F movzx eax, byte ptr [esi] ; Move with Zero-Extend .text:0804A232 .text:0804A232 Processing_2: ; CODE XREF: Decoder+40j .text:0804A232 lea ecx, [eax-17h] ; ECX = P(n) .text:0804A232 ; =C(n)-C(n-1)-0x17 .text:0804A235 test ecx, ecx ; Logical Compare .text:0804A237 jge short if_positive ; Jump if Greater or Equal (SF=OF) .text:0804A237 .text:0804A239 .text:0804A239 if_negative: ; NOP .text:0804A239 lea esi, [esi+0] .text:0804A23C .text:0804A23C until_positive: ; CODE XREF: Decoder+5Aj .text:0804A23C add ecx, 100h ; P(n) = P(n)%0x100 .text:0804A242 js short until_positive ; P(n) = P(n)%0x100 .text:0804A242 .text:0804A244 .text:0804A244 if_positive: ; CODE XREF: Decoder+4Fj .text:0804A244 xor edx, edx ; Logical Exclusive OR .text:0804A246 cmp edx, edi ; Is EDI = PacketSize = 0? .text:0804A248 jge short Decoder_Bytes ; Pn = Cn - Cn-1 - 0x17 .text:0804A248 .text:0804A24A .text:0804A24A Sure_Enter: ; NOP .text:0804A24A lea esi, [esi] .text:0804A24C .text:0804A24C Backup_OutBuf_to_LocalBuf: ; CODE XREF: Decoder+73j .text:0804A24C mov esi, [ebp+PlainText] .text:0804A24F mov al, [edx+esi] .text:0804A252 mov esi, [ebp+tmpBuf_Decoder] .text:0804A255 mov [edx+esi], al ; [pLocalBuf] = [pOutBuf] .text:0804A255 ; for PacketSize .text:0804A258 inc edx ; Increment by 1 .text:0804A259 cmp edx, edi ; Compare Two Operands .text:0804A25B jl short Backup_OutBuf_to_LocalBuf ; Jump if Less (SF!=OF) .text:0804A25B .text:0804A25D .text:0804A25D Decoder_Bytes: ; CODE XREF: Decoder+60j .text:0804A25D mov esi, [ebp+PlainText] ; Pn = Cn - Cn-1 - 0x17 .text:0804A260 mov [esi], cl ; CL = (Last Byte - 2nd-last Byte .text:0804A260 ; - 0x17 + 0x200) % 0x100 .text:0804A262 mov edx, 1 .text:0804A267 cmp edx, edi ; Compare Two Operands .text:0804A269 jge short Assign_PlainText_to_OutBuf ; Jump if Greater or Equal (SF=OF) .text:0804A269 .text:0804A26B .text:0804A26B Sure_Enter_2: ; No Operation .text:0804A26B nop .text:0804A26C .text:0804A26C Restore_LocalBuf_to_OutBuf_1: ; CODE XREF: Decoder+94j .text:0804A26C mov esi, [ebp+tmpBuf_Decoder] .text:0804A26F mov al, [edx+esi-1] ; EDX indexes pLocalBuf .text:0804A26F ; starts at pLocalBuf, then .text:0804A26F ; pLocalBuf+1, pLocalBuf+2,... .text:0804A273 mov esi, [ebp+PlainText] .text:0804A276 mov [edx+esi], al ; [OutputBuf]=[pLocalBuf-1] .text:0804A279 inc edx ; Increment by 1 .text:0804A27A cmp edx, edi ; Compare Two Operands .text:0804A27C jl short Restore_LocalBuf_to_OutBuf_1 ; Jump if Less (SF!=OF) .text:0804A27C .text:0804A27E .text:0804A27E Assign_PlainText_to_OutBuf: ; CODE XREF: Decoder+81j .text:0804A27E mov esi, [ebp+tmpBuf_Decoder] .text:0804A281 push esi .text:0804A282 push ecx .text:0804A283 push offset aCS ; "%c%s" .text:0804A288 mov esi, [ebp+PlainText] .text:0804A28B push esi .text:0804A28C call sprintf ; Call Procedure .text:0804A28C .text:0804A291 add esp, 10h ; Add .text:0804A294 dec ebx ; Decrement by 1 .text:0804A295 jns Processing_1 ; EBX = n .text:0804A295 ; EDX = n-1 .text:0804A295 .text:0804A29B .text:0804A29B Exit_Decoder: ; CODE XREF: Decoder+26j .text:0804A29B lea esp, [ebp-10h] ; Load Effective Address .text:0804A29E pop ebx .text:0804A29F pop esi .text:0804A2A0 pop edi .text:0804A2A1 mov esp, ebp .text:0804A2A3 pop ebp .text:0804A2A4 retn ; Return Near from Procedure .text:0804A2A4 .text:0804A2A4 Decoder endp