The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on November 12, 2008, 06:23:23 PM

Title: HexString To Dw with wildcards
Post by: ragdog on November 12, 2008, 06:23:23 PM
Hi

I have a next probelm    
how i can bypass the (*) in a hexstring to dword





    push offset hDestBuffer
    push offset sztest             ;54*4553*54  to T*ES*T
       call HexDecode
   
        invoke MessageBox,hWnd,addr hDestBuffer,0,MB_OK


HexDecode proc uses esi edi ebx pHexStr:dword,pOutBuffer:dword
;---------------------------------------
   mov    esi, pHexStr
   mov    edi, pOutBuffer
   jmp    @1
@@: and    ebx, 0Fh
   add    eax, ebx
   mov    [edi], al
   inc    edi
@1: movzx  edx, byte ptr[esi]
cmp edx,"*"
jz @Next
   cmp    edx, 40h
   sbb    ebx, ebx
   sub    edx, 37h
   and    ebx, 7
   
   inc    esi
   add    ebx, edx
   js      @F
   mov    eax, ebx
   shl    eax, 4
   @Next:
   mov    [edi], al
   movzx  edx, byte ptr [esi]
   cmp    edx, 40h
   sbb    ebx, ebx
   sub    edx, 37h
   and    ebx, 7
   inc    esi
   add    ebx, edx
   jns    @B
@@: ret
;---------------------------------------
HexDecode endp



Greets
Title: Re: HexString To Dw with wildcards
Post by: n00b! on November 12, 2008, 11:27:01 PM
Hi,
I do not know if this is exactly what you want since it's a totally noobish solution
(It could also be that I've misunderstood your request, if so I'm sorry):

@1:
   movzx edx, BYTE ptr [esi]
   cmp edx,"*"
   jnz @noasterisk
   inc esi
   ;Commented: String will be "TEST"
   ;Uncommented: String will be "T*ES*T"
   ;mov [edi], dl
   ;inc edi
   jmp @1
@noasterisk:
   cmp edx, 40h
Title: Re: HexString To Dw with wildcards
Post by: ragdog on November 14, 2008, 12:23:13 PM
Thanks noob :U

total simply mistake  :bdg

Greets