;diablo2oo2's Keygen Template
.586p
.mmx
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shell32.inc
include \masm32\include\advapi32.inc
include \masm32\include\gdi32.inc
include \masm32\include\comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\masm32.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\advapi32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\masm32.lib
DialogProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
.const
DIALOG_1 equ 1
IDC_APPNAME equ 1001
IDC_NAME equ 1002
IDC_SERIAL equ 1003
BTN_EXIT equ 1004
BTN_GENERATE equ 1005
.data
namebuffer dd 255 dup (00) ;buffer for entered name
finalserial dd 255 dup (00) ;buffer for finalserial
.data?
hInstance dd ? ;handle of our Module
handle dd ? ;handle of our Dialog
.code
main :
invoke GetModuleHandleA,NULL
mov hInstance ,eax
invoke DialogBoxParamA,eax,DIALOG_1,NULL,ADDR DialogProc,NULL
invoke ExitProcess,NULL
DialogProc Proc hwnd:dword,message:dword,wParam:dword,lParam:dword
;:::::::::::::::::::::::::::::::::::::::::Dialog Box::::::::::::::::::::::::::::::::::::::::::
pushad
mov eax,hwnd
mov handle,eax ;save dialogbox handle,so we can use it in other procedures
.IF message==WM_INITDIALOG
invoke SetDlgItemTextA,handle,IDC_APPNAME,chr$("Appname 1.0") ;show the appname in dialog
.ELSEIF message==WM_COMMAND
mov eax,wParam
.IF ax==BTN_GENERATE
;---run keygen algo if 'generate' button pressed---
call keygen_routine
.ELSEIF ax==BTN_EXIT
jmp @close
.ELSEIF ax==IDC_NAME
;---run keygen algo if key pressed in name dialogbox---
call keygen_routine
.ENDIF
.ELSEIF message==WM_CLOSE
@close:
invoke EndDialog,handle,NULL
popad
xor eax,eax
ret
.ELSE
popad
mov eax,FALSE
ret
.ENDIF
popad
xor eax,eax
ret
DialogProc endp
keygen_routine proc
;:::::::::::::::::::::::::::::::::::::::::KeyGen Routine::::::::::::::::::::::::::::::::::::::::::
pushad ;save all registers
;---get the name and check lenght---
invoke GetDlgItemTextA,handle,IDC_NAME,ADDR namebuffer,255
.if eax == 0
invoke SetDlgItemTextA,handle,IDC_SERIAL,chr$("No Name entered")
jmp @finish
.elseif eax > 40
invoke SetDlgItemTextA,handle,IDC_SERIAL,chr$("Long name!")
jmp @finish
.elseif eax < 3
invoke SetDlgItemTextA,handle,IDC_SERIAL,chr$("Short name!")
jmp @finish
.endif
@letsgo:
mov esi,offset namebuffer ;move adress (offset) of our namebuffer to esi
mov edi,offset finalserial ;same...with serialbuffer
.while eax != 0 ;loop while eax is not zero
mov bl,byte ptr[esi] ;mov current char to bl (bl is part of ebx)
inc bl ;increase bl ... for example:"A"-->"B"
mov byte ptr[edi],bl ;save bl to finalserial buffer
inc esi ;increase esi (esi holds the adress of our namebuffer)
inc edi ;same...
dec eax ;decrease eax
.endw
;---Show Serial--
invoke SetDlgItemTextA,handle,IDC_SERIAL,ADDR finalserial
@finish:
;---clean some buffers---
invoke RtlZeroMemory,addr finalserial,SIZEOF finalserial
invoke RtlZeroMemory,addr namebuffer,SIZEOF namebuffer
popad ;restore all registers
ret ;leave this procedure
keygen_routine endp
end main
;:::::::::::::::::::::::::::::::::::::::::Usefull Stuff::::::::::::::::::::::::::::::::::::::::::
;invoke CharUpperA,addr namebuffer ;make all chars upper
;invoke RtlZeroMemory,addr finalserial,255 ;Fill Memory with Zeros
;invoke RtlMoveMemory,destination,source,lenght ;Move Bytes
;invoke lstrcat,ADDR md5buffer1,ADDR md5buffer3 ;connect 2 Strings
;invoke lstrlenA,ADDR serial_4 ;get a stringlenght