home *** CD-ROM | disk | FTP | other *** search
- extrn GetTickCount : PROC ; to get 'random' base information
-
- randseed dd 0 ; 64 bit random seed
-
- dd 0
-
- strcpys dd 0
-
- strcpyt dd 0
-
- cmpstr1 dd 0
-
- cmpstr2 dd 0
-
- cstrlen dd 0
-
- kgincd db 'keygen include v.2 (c) scut / blizzard'
-
-
- ; keygen include v.2, 980818
-
- ; (c) scut of blizzard 1998
-
- ; free use, as long as you give me credits
-
-
-
- comment ⌡
-
-
-
- numeric functions:
-
- print_hex_32b will print the number in eax to *edi, in hex, fixed len 8 bytes
-
- print_hex_16b will print the number in ax to *edi, in hex, fixed len 4 bytes
-
- print_dec_32b will print the number in eax to *edi, in dec., no fixed len
-
- print_dec_16b will print the number in ax to *edi, in dec, no ficed len
-
- read_dec_32b will read a decimal from *esi, returning it in eax
-
- read_dec_16b will read a decimal from *esi, returning it in ax
-
-
-
- string functions:
-
- strnlen will return the length of the string *esi in eax
-
- strcpy will copy *esi to *edi, if carry set len is eax, else asciiz
-
- strcmp will compare *esi to *edi, if carry set len is eax, else asciiz
-
- returns: clc = equal, stc = unequal
-
- strrmv will all chars same as al from *esi, returning in *edi,
-
- note: esi and edi can be the same, the string will be terminated
-
- strloc will lowercase an asciiz string in *esi
-
- strupc will uppercase an asciiz string in *esi
-
-
-
- random functions:
-
- randomize will initialize the random seeds, do this after a delay (user-input)
-
- random will return a pseudo-random number in eax, boundary by eax
-
- ⌡
-
-
-
- print_hex_32b proc
-
- mov ecx,8 ; 8 digits
-
- p2hl0: rol eax,4 ; rol left 4 bits
-
- mov bl,al
-
- and bl,1111b
-
- cmp bl,0ah
-
- jl p2hl0a
-
- add bl,7
-
- p2hl0a: add bl,'0'
-
- mov [edi],bl
-
- inc edi
-
- dec ecx
-
- jnz p2hl0
-
- ret
-
- endp print_hex_32b
-
- print_hex_16b proc
-
- mov ecx,4
-
- p6bl0: rol ax,4
-
- mov bl,al
-
- and bl,1111b
-
- cmp bl,0ah
- jl p6bl0a
-
- add bl,7
-
- p6bl0a: add bl,'0'
-
- mov [edi],bl
-
- inc edi
-
- dec ecx
-
- jnz p6bl0
-
- ret
-
- endp print_hex_16b
-
- print_dec_32b proc
-
- mov ebx,10
-
- xor ecx,ecx
-
- p2dl1: xor edx,edx
-
- div ebx
-
- push edx
-
- inc ecx
-
- or eax,eax
-
- jne p2dl1
-
- p2dl2: pop edx
-
- add dl,'0'
-
- mov al,dl
-
- stosb
-
- dec ecx
-
- jnz p2dl2
-
- xor al,al
-
- stosb
-
- ret
-
- print_dec_32b endp
-
- print_dec_16b proc
- mov bx,ax
-
- xor eax,eax
-
- mov ax,bx
-
- mov ebx,10
-
- xor ecx,ecx
-
- p6dl1: xor edx,edx
-
- div ebx
-
- push edx
-
- inc ecx
-
- or eax,eax
-
- jne p6dl1
-
- p6dl2: pop edx
-
- add dl,'0'
-
- mov al,dl
-
- stosb
-
- dec ecx
-
- jnz p6dl2
-
- xor al,al
-
- stosb
-
- ret
-
- print_dec_16b endp
-
- read_dec_32b proc
-
- mov edi,10
-
- mov ecx,10
-
- xor ebx,ebx
-
- xor edx,edx
-
- a2tl0: lodsb
-
- or al,al
-
- jz a2tle
-
- sub al,'0'
-
- xor ebx,ebx
-
- mov bl,al
-
- mov eax,edx
-
- mul ecx
-
- add eax,ebx
-
- mov edx,eax
-
- dec edi
-
- jnz a2tl0
-
- a2tle: mov eax,edx
-
- ret
-
- read_dec_32b endp
-
- read_dec_16b proc
-
- mov bx,ax
-
- xor eax,eax
-
- mov ax,bx
-
- mov edi,5
-
- mov ecx,10
-
- xor ebx,ebx
-
- xor edx,edx
-
- a6tl0: lodsb
-
- or al,al
-
- jz a6tle
-
- sub al,'0'
-
- xor ebx,ebx
-
- mov bl,al
- mov eax,edx
-
- mul ecx
-
- add eax,ebx
-
- mov edx,eax
-
- dec edi
-
- jnz a6tl0
-
- a6tle: mov eax,edx
-
- ret
-
- read_dec_16b endp
-
-
-
- strnlen proc
-
- xor ecx, ecx
-
- dec ecx
-
- strln0: lodsb
-
- inc ecx
-
- or al,al
-
- jnz strln0
-
- mov eax, ecx
-
- ret
-
- strnlen endp
-
- strcpy proc
-
- mov strcpys,esi
-
- mov strcpyt,edi
-
- jc strcl0
-
- mov ecx,512
-
- strcl2: lodsb
- dec ecx
-
- jz strcl1
-
- or al,al
-
- jnz strcl2
-
- sub esi,strcpys
-
- mov ecx,esi
-
- mov esi,strcpys
-
- jmp strcl3
-
- strcl1: stc
-
- ret
-
- strcl0: mov ecx,eax
-
- strcl3: rep movsb
- clc
-
- ret
-
- strcpy endp
-
- strcmp proc
-
- mov cmpstr1,esi
-
- mov cmpstr2,edi
-
- jc strl0
-
- mov edi,cmpstr1
-
- xor al,al
-
- mov ecx,512
-
- repne scasb
-
- or ecx,ecx
-
- jnz strl0b
-
- stc
-
- ret
-
- strl0b: sub edi,cmpstr1
-
- mov eax,edi
-
- strl0: mov cstrlen,eax
-
- mov ecx,cstrlen
-
- mov esi,cmpstr1
-
- mov edi,cmpstr2
-
- strl0a: lodsb
-
- mov bl,al
-
- mov al,es:[edi]
-
- inc edi
-
- cmp al,bl
-
- jne strl1
-
- dec ecx
-
- or ecx,ecx
-
- jnz strl0a
-
- clc
- ret
-
- strl1: stc
-
- ret
-
- strcmp endp
-
- strrmv proc
-
- mov bl,al
-
- rmvl0: lodsb ; get char
-
- or al,al ; end of string ?
-
- jz rmvle ; yes -> eop
-
- cmp al,bl ; strip char ?
-
- je rmvl0 ; yes -> next char
-
- stosb ; write char if not strip-char
-
- jmp rmvl0
-
- rmvle: stosb ; terminate *edi
-
- ret
-
- strrmv endp
-
- strloc proc
-
- mov edi,esi
- locl0: lodsb
-
- or al,al
-
- jz locl3
-
- cmp al,41h
-
- jl locl2
-
- cmp al,5ah
-
- jg locl2
-
- add al,'a'-'A'
-
- locl2: stosb
-
- jmp locl0
-
- locl3: stosb
-
- ret
-
- strloc endp
-
- strupc proc
-
- mov edi,esi
-
- upcl0: lodsb
-
- or al,al
-
- jz upcl3
-
- cmp al,'a'
-
- jl upcl2
-
- cmp al,'z'
-
- jg upcl2
-
- sub al,'a'-'A'
-
- upcl2: stosb
-
- jmp upcl0
-
- upcl3: stosb
-
- ret
-
- strupc endp
-
-
-
- randomize proc
-
- call GetTickCount
-
- mov ecx,eax
-
- and ecx,111b
-
- ror eax,cl
-
- mov ebx,eax
-
- call GetTickCount
-
- add eax,ebx
-
- mov dword ptr randseed,eax
-
- rol eax,4
-
- and eax,111b
-
- add eax,010b
-
- mov ecx,eax
-
- shl ecx,1
-
- rndzl0: call GetTickCount
-
- and eax,111b
-
- dec ecx
-
- jz rndzl1
-
- cmp eax,ebx
-
- jne rndzl0
-
- rndzl1: call GetTickCount
-
- mov ecx,eax
-
- and ecx,111b
-
- ror eax,cl
-
- mov ebx,eax
-
- call GetTickCount
-
- add eax,ebx
-
- mov dword ptr randseed+4,eax
-
- ret
-
- randomize endp
-
- random proc ; limit in eax, return in eax
-
- mov ecx,eax
-
- mov eax,dword ptr randseed+4
-
- mov ebx,dword ptr randseed
-
- mov esi,eax
-
- mov edi,ebx
-
- mov dx,ax
-
- shl eax,16
-
- mov ax,bx
-
- shl ebx,16
-
- xor bx,bx
-
- rcr dx,1
- rcr eax,1
-
- rcr ebx,1
-
- adc ebx,edi
-
- adc eax,esi
-
- add ebx,000062e9h
-
- adc eax,00003619h
-
- mov dword ptr randseed,ebx
-
- mov dword ptr randseed+4,eax
-
- xor edx,edx
-
- div ecx
-
- mov eax,edx
-
- ret
-
- random endp
-