flat assembler
Message board for the users of flat assembler.
Index
> Main > Embedded Checksum |
Author |
|
Tomasz Grysztar 06 Jun 2005, 14:30
There is no such thing in general, though formatter for some output formats might generate some particular types of checksums, like for the PE format. However you can calculate the checksum yourself using "load" directive (and implement whatever checksum type you need), like:
Code: checksum = 0 repeat $ load a byte from %-1 checksum = (checksum + a) and 0FFFFFFFFh end repeat dd checksum This will actually work with raw output format only, with other formats the problem is a bit more complex. |
|||
06 Jun 2005, 14:30 |
|
smiddy 06 Jun 2005, 14:35
Thanks! You're the MAN!
Raw format is what I'm concerned with presently... |
|||
06 Jun 2005, 14:35 |
|
Madis731 07 Jun 2005, 18:52
I found this on the board a while ago and thought it was worth saving.
Haven't used it myself, now that I've translated MD5 to FASM(Win32|MeOS) See for yourself: Code: macro generate_crc starting_lbl, ending_lbl { __ptr = starting_lbl __lenght = ending_lbl-starting_lbl __times = (__lenght)shr 2 __timesleft = (__lenght)-(((__lenght)shr 2)shl 2) ; remaining 3 - 0 __timesleft2 =__timesleft shr 1 ; word __timesleft3 =__timesleft - (__timesleft2 shl 1) ; last byte __sum = 0 repeat __times load __tmp dword from __ptr __sum = __sum xor __tmp __ptr = __ptr + 4 end repeat if __timesleft2>0 ; word load __tmp word from __ptr __sum = __sum xor (__tmp and $ffff) __ptr = __ptr + 2 end if if __timesleft3>0 ; last byte load __tmp byte from __ptr __sum = __sum xor (__tmp and $ff) __ptr = __ptr + 1 end if dd __sum and 0xffffffff } ;it will store dword value that would be a sum of all dwords in the output code, between two given labels. Example: ;Code: begin: db "All data and..",0 MyCode: mov eax,ebx and edx,ebp je MyCode db "should be here " finish: db "CRC:" ;This should be left out - you just can see better with some hexviewer generate_crc begin,finish |
|||
07 Jun 2005, 18:52 |
|
smiddy 07 Jun 2005, 22:42
Hi Madis731,
I'll give it a whirl this evening, thanks! |
|||
07 Jun 2005, 22:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.