Okay here is the code but even when I enter the right key it still displays the wrong message and closes everything. I want it to open another window and close itself once the right password has been entered. Here is the data sections/.const section:



include windows.inc
include user32.inc
include kernel32.inc
include gdi32.inc
include shell32.inc
include Comctl32.inc
include comdlg32.inc
include advapi32.inc
include masm32.INC

includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
includelib shell32.lib
includelib Comctl32.lib
includelib comdlg32.lib
includelib advapi32.lib
INCLUDELIB crc32.lib
includelib C:\masm32\LIB\masm32.lib

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
PDlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
crc32 PROTO STDCALL :DWORD, :DWORD



.const

IDD_DLG1 equ 1000

IDC_BTN1 equ 1001
IDC_BTN2 equ 1002
IDC_BTN3 equ 1003
IDC_BTN4 equ 1006
IDC_BTN5 equ 1007
IDC_BTN6 equ 1008
IDC_BTN7 equ 1009
IDC_BTN8 equ 1010
IDC_BTN9 equ 1011
IDC_BTN10 equ 1012
IDC_BTN11 equ 1013
IDC_BTN12 equ 1014
IDC_BTN13 equ 1015

IDC_STATUS equ 1018

IDC_EDT1 equ 1019
IDC_EDT5 equ 1021
IDC_EDT4 equ 1020

.data
goodtxt db "Registration Successful!",0
goodcap db "Congrats!",0
badtxt db "Sorry Wrong Reg Key/Name",0
badcap db "Failure!",0

.data?
hInstance dd ?
CommandLine dd ?
hWnd dd ?
phandle dd ?
dwprocessid dd ?
hwndStatus dd ?
hPlg dd ?
g_lpTranslated DD ?
g_dbBuffer Dd ?


and here is the actual code:




.686
.model flat,stdcall
option casemap:none

include winter.inc

.code
INCLUDE crc32.ash
start:

invoke CreateDialogParam,hInstance,IDD_DLG1,0,addr PDlgProc,FALSE

call PDlgProc


@@hmm:
invoke CreateDialogParam,hInstance,addr DlgName,NULL,addr WndProc,NULL
Invoke FindWindowEx,NULL,NULL,NULL,addr nameofwindow

invoke GetWindowThreadProcessId,eax,offset dwprocessid
invoke OpenProcess,PROCESS_ALL_ACCESS,NULL,dwprocessid
mov thecess,eax
.if eax==FALSE
Invoke MessageBox,hInstance,offset StartErrorMessage,offset StartErrorCaption,MB_OK
ret
.endif

invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
invoke InitCommonControls
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG

mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc

invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret

WinMain endp
PDlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
.if eax==WM_INITDIALOG
mov eax,hWin
mov hPlg,eax
.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.endif
.IF wParam==1015
invoke GetDlgItemText,hPlg, IDC_EDT4, offset g_dbBuffer, sizeof g_dbBuffer
invoke GetDlgItemInt,hPlg,IDC_EDT5,offset g_lpTranslated,FALSE
invoke lstrlen, OFFSET g_dbBuffer
invoke crc32, OFFSET g_dbBuffer,eax

add eax,956874599
sub eax,8
add eax,20
add eax,956874599
add eax,956874599

.if eax==g_lpTranslated
invoke MessageBox,0,addr goodtxt,addr goodcap,MB_OK
jmp @@hmm
.else
invoke MessageBox,0,addr badtxt,addr badcap,MB_OK
jmp @@duh

.endif




.endif






; .elseif eax==WM_SIZE
.if eax==WM_CLOSE
mov hPlg,0
invoke EndDialog,hWin,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

@@duh:
invoke DestroyWindow,hPlg
invoke PostQuitMessage,NULL
ret

PDlgProc endp


WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
.if eax==WM_INITDIALOG
blah blah blah


See what I do is if the reg code is right I jump to @@hmm and if its wrong i jump to @@duh.. Whats wrong here?? I think it may be something to do with CRC reading the wrong dialog controls but i may be wrong..
Posted on 2002-08-08 21:49:28 by resistance_is_futile
invoke  GetDlgItemInt,hPlg,IDC_EDT5,offset g_lpTranslated,FALSE

invoke lstrlen, OFFSET g_dbBuffer
invoke crc32, OFFSET g_dbBuffer,eax

add eax,956874599
sub eax,8
add eax,20
add eax,956874599
add eax,956874599

.if eax==g_lpTranslated
invoke MessageBox,0,addr goodtxt,addr goodcap,MB_OK
jmp @@hmm
.else
invoke MessageBox,0,addr badtxt,addr badcap,MB_OK
jmp @@duh

.endif
lpTranslated from psdk
lpTranslated
Pointer to a variable that receives a success or failure value (TRUE indicates success, FALSE indicates failure).
If this parameter is NULL, the function returns no information about success or failure.
If you read further on the return values remarks
If the function succeeds, the variable pointed to by lpTranslated is set to TRUE, and the return value is the translated value of the control text.

If the function fails, the variable pointed to by lpTranslated is set to FALSE, and the return value is zero. Note that, since zero is a possible translated value, a return value of zero does not by itself indicate failure.

If lpTranslated is NULL, the function returns no information about success or failure.

If the bSigned parameter is TRUE, specifying that the value to be retrieved is a signed integer value, cast the return value to an int type. To get extended error information, call GetLastError.
In short lpTranslated holds either TRUE or FALSE that will determine if the function was a success or not. If it was, the return value will be in eax not on lpTranslated.
Posted on 2002-08-08 23:01:13 by stryker
"g_lpTranslated"

Thats why the g is in front of that right? This worked fine when it was by itself because i programmed the registry program seperate from the main program which I shouldnt have but i did lol. Now im trying to combine them and ever since i tried it doesnt work :mad:
Posted on 2002-08-08 23:24:50 by resistance_is_futile
g_XXXXX means global variable its a hungarian notation used to determine what type/kind of variable being declared.

lp == long pointer
Posted on 2002-08-08 23:31:33 by stryker
ahh I see.. lol it was working so well as i left it a single file..Now I have to add another buffer at least i think :rolleyes:
Posted on 2002-08-09 00:44:21 by resistance_is_futile