flat assembler
Message board for the users of flat assembler.
Index
> Windows > HexEncode & HexDecode |
Author |
|
bzdashek 07 Jul 2012, 09:44
Converted to FASM syntax, now compiles, don't know if works.
Code: proc HexEncode uses edi esi ebx,pBuff:dword,dwLen:dword,pOutBuff:dword ;--------------------------------------- mov ebx, [dwLen] mov edi, [pOutBuff] test ebx, ebx mov esi, [pBuff] jz @F .repeat: movzx eax, byte[esi] mov ecx, eax add edi, 2 shr ecx, 4 and eax, 1111b and ecx, 1111b cmp eax, 10 sbb edx, edx adc eax, 0 lea eax, [eax+edx*8+'7'] cmp ecx, 10 sbb edx, edx adc ecx, 0 shl eax, 8 lea ecx, [ecx+edx*8+'7'] or eax, ecx inc esi mov [edi-2], ax dec ebx jnz .repeat @@: mov eax, edi mov byte[edi], 0 sub eax, [pOutBuff] ret ;--------------------------------------- endp ; Author: Jake Commander ; Copyright The GeneSys Development System proc HexDecode 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[esi] 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 mov [edi], al movzx edx, byte[esi] cmp edx, 40h sbb ebx, ebx sub edx, 37h and ebx, 7 inc esi add ebx, edx jns @B @@: ret ;--------------------------------------- endp |
|||
07 Jul 2012, 09:44 |
|
jochenvnltn 07 Jul 2012, 15:37
bzdashek wrote: Converted to FASM syntax, now compiles, don't know if works. Dear friend bzdashek Thank you a 1000000 times !! Not only it compiles, but it also works like a charm ! I like this forum alot ! If im gona be helped like this all the time, im gona have a great journey learning the 'Fasm' format PE GUI 4.0 include 'C:\Users\X-Ray Cat\Downloads\fasmw17002\INCLUDE\win32ax.inc' section '.data' data readable writeable HexBuff db '4A6F6368656E',0 ; This HexString is my name --> Jochen szBuff db ? section '.code' data readable writeable main: push szBuff push HexBuff call HexDecode invoke MessageBox,0,szBuff, 'Fasm',MB_OK invoke ExitProcess, 0 .end main ; Author: Jake Commander ; Copyright The GeneSys Development System proc HexDecode 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[esi] 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 mov [edi], al movzx edx, byte[esi] cmp edx, 40h sbb ebx, ebx sub edx, 37h and ebx, 7 inc esi add ebx, edx jns @B @@: ret ;--------------------------------------- endp |
|||
07 Jul 2012, 15:37 |
|
Enko 07 Jul 2012, 15:54
You can use sprintf from the c runtime.
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ You will need to import it from mvcrt and use cinvoke insted of inovke. |
|||
07 Jul 2012, 15:54 |
|
bzdashek 07 Jul 2012, 20:33
You're welcome, comrade!
Also, instead of Code: push szBuff push HexBuff call HexDecode you can just write Code: stdcall HexDecode,HexBuff,szBuff There's one think in your programme that needs to be corrected. If "szBuff db ? " is buffer, then it would be better if you specify the size of it, for example, to statically define a buffer for 80 chars, you write: Code: szBuff db 80 dup (?) or FASM way: Code:
szBuff rb 80
where "rb" means that it's an array of bytes. Take a look in FASM\EXAMPLES, there are lot's of interesting and helpful examples. Also, it is advised to take a look at FASM\FASM.PDF, many useful things can be found there. This thread is great when you start learning asm: http://board.flatassembler.net/topic.php?t=2527 |
|||
07 Jul 2012, 20:33 |
|
jochenvnltn 07 Jul 2012, 21:54
Comrade Bzdashek,
Thank you alot for all the new information. It's stored in my memory. Im sure gona read up on all the usefull links you gave me ! до свидания ! Jochen |
|||
07 Jul 2012, 21:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.