All pastes #254009 Raw Edit

Miscellany

public text v1 · immutable
#254009 ·published 2006-11-21 11:05 UTC
rendered paste body
.text:00401472 ; Modifies the data pointed to by argument 1
.text:00401472 ; Modifies the data based on the 'value string'
.text:00401472 ; Returns 1 on success, and leaves modified
.text:00401472 ; data as is...
.text:00401472 ; Attributes: bp-based frame
.text:00401472 
.text:00401472 ModifyData      proc near               ; CODE XREF: ModifyDataEx+2Ap
.text:00401472 
.text:00401472 Output          = dword ptr  8
.text:00401472 OutputLength    = dword ptr  0Ch
.text:00401472 ValueString     = dword ptr  10h
.text:00401472 ValueStringLength= dword ptr  14h
.text:00401472 
.text:00401472                 push    ebp
.text:00401473                 mov     ebp, esp
.text:00401475                 push    ebx
.text:00401476                 push    esi
.text:00401477                 mov     esi, [ebp+Output] ; Initializer ptr to data
.text:0040147A                 xor     edx, edx        ; Null EDX
.text:0040147C                 cmp     [ebp+ValueStringLength], edx ; Make sure length isn't null
.text:0040147F                 push    edi             ; Save register
.text:00401480                 jbe     short loc_4014E9 ; Jump not taken
.text:00401482 
.text:00401482 loc_401482:                             ; CODE XREF: ModifyData+75j
.text:00401482                 xor     bl, bl          ; Nullify BL
.text:00401484                 xor     edi, edi        ; Nullify EDI
.text:00401486                 test    edx, edx
.text:00401488                 jbe     short loc_4014B4 ; Loop 1 - Jump taken
.text:00401488                                         ; Loop 2 - Jump not taken
.text:0040148A 
.text:0040148A loc_40148A:                             ; CODE XREF: ModifyData+33j
.text:0040148A                 mov     cl, [edi+esi]   ; Loop 1 - Set last byte of ECX to last byte of 'value string'
.text:0040148D                 call    sub_401585
.text:00401492                 movzx   eax, ax
.text:00401495                 movzx   ecx, bl
.text:00401498                 add     eax, ecx
.text:0040149A                 mov     [edi+esi], al
.text:0040149D                 shr     eax, 8
.text:004014A0                 inc     edi
.text:004014A1                 cmp     edi, edx
.text:004014A3                 mov     bl, al
.text:004014A5                 jb      short loc_40148A
.text:004014A7                 test    bl, bl
.text:004014A9                 jbe     short loc_4014B4
.text:004014AB                 cmp     edx, [ebp+OutputLength]
.text:004014AE                 jnb     short loc_401508
.text:004014B0                 mov     [edx+esi], bl
.text:004014B3                 inc     edx
.text:004014B4 
.text:004014B4 loc_4014B4:                             ; CODE XREF: ModifyData+16j
.text:004014B4                                         ; ModifyData+37j
.text:004014B4                 mov     ecx, [ebp+ValueStringLength] ; Loop 1 - 16
.text:004014B4                                         ; Loop 2 - 15
.text:004014B7                 mov     eax, [ebp+ValueString] ; Pointer to the 'value string' on the heap in EAX
.text:004014BA                 mov     al, [eax+ecx-1] ; Change last byte of ptr addr to
.text:004014BA                                         ; the last byte of 'value string'
.text:004014BE                 dec     al              ; Reduce last byte of ptr addr by 1h
.text:004014C0                 push    0
.text:004014C2                 pop     ecx             ; Nullify ECX
.text:004014C3                 jz      short loc_4014D7 ; Loop 1 - Jump is not taken
.text:004014C5 
.text:004014C5 loc_4014C5:                             ; CODE XREF: ModifyData+63j
.text:004014C5                 cmp     ecx, edx
.text:004014C7                 jnb     short loc_4014D7 ; Jump if ECX >= 0 (EDX)
.text:004014C9                 add     [ecx+esi], al
.text:004014CC                 cmp     [ecx+esi], al
.text:004014CF                 inc     ecx
.text:004014D0                 setb    al
.text:004014D3                 test    al, al
.text:004014D5                 jnz     short loc_4014C5
.text:004014D7 
.text:004014D7 loc_4014D7:                             ; CODE XREF: ModifyData+51j
.text:004014D7                                         ; ModifyData+55j
.text:004014D7                 test    al, al          ; Make sure last byte of ptr addr is
.text:004014D7                                         ; not null
.text:004014D9                 jbe     short loc_4014E4 ; Loop 1 - Jump is not taken
.text:004014DB                 cmp     edx, [ebp+OutputLength] ; Jump if EDX is >= 10
.text:004014DE                 jnb     short loc_401508 ; Loop 1 - Jump is not taken
.text:004014E0                 mov     [edx+esi], al   ; Move last byte of ptr addr to
.text:004014E0                                         ; the location pointed to by
.text:004014E0                                         ; the data ptr arg
.text:004014E3                 inc     edx             ; Loop 1 - EDX++ = 1
.text:004014E4 
.text:004014E4 loc_4014E4:                             ; CODE XREF: ModifyData+67j
.text:004014E4                 dec     [ebp+ValueStringLength] ; Loop 1 - Length-- = 15
.text:004014E7                 jnz     short loc_401482
.text:004014E9 
.text:004014E9 loc_4014E9:                             ; CODE XREF: ModifyData+Ej
.text:004014E9                 mov     eax, [ebp+OutputLength]
.text:004014EC                 cmp     edx, eax
.text:004014EE                 jnb     short loc_401500
.text:004014F0                 sub     eax, edx
.text:004014F2                 push    eax
.text:004014F3                 add     edx, esi
.text:004014F5                 push    0
.text:004014F7                 push    edx
.text:004014F8                 call    RtlFillMemoryEx
.text:004014FD                 add     esp, 0Ch
.text:00401500 
.text:00401500 loc_401500:                             ; CODE XREF: ModifyData+7Cj
.text:00401500                 xor     eax, eax
.text:00401502                 inc     eax
.text:00401503 
.text:00401503 loc_401503:                             ; CODE XREF: ModifyData+98j
.text:00401503                 pop     edi
.text:00401504                 pop     esi
.text:00401505                 pop     ebx
.text:00401506                 pop     ebp
.text:00401507                 retn
.text:00401508 ; ---------------------------------------------------------------------------
.text:00401508 
.text:00401508 loc_401508:                             ; CODE XREF: ModifyData+3Cj
.text:00401508                                         ; ModifyData+6Cj
.text:00401508                 xor     eax, eax
.text:0040150A                 jmp     short loc_401503
.text:0040150A ModifyData      endp