News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Calculating checksum value

Started by Vortex, January 15, 2005, 02:39:12 PM

Previous topic - Next topic

Vortex

Here is an algo to calculate the MS checksum value of a PE, it was presented by f0dder at Harold's forum:

MicrosoftCheckSum2 PROC C uses esi, buf:dword, len:dword
mov ecx, [len]           
mov edx, [buf]           
shr  ecx, 1               
xor  eax, eax             
clc                                 
@@theLoop:
adc ax, [edx + (ecx * 2) - 2]
dec ecx
jnz @@theLoop
adc eax, [len]
ret
MicrosoftCheckSum2 ENDP

Mirno

That code?
I originally wrote that on Hiro's original forum!

BTW the clc isn't needed, the XOR does it.

Mirno

Vortex

Hi Mirno,

Yes, I checked it, you are right.

Kindly, please accept my apologies.