hi all, i need tu use the same buffer more then one time and for diferent strings:
example:
i have the buffer-
szBigBuffer dd " ",0
and i have 4 textboxes to fill with registry values-
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
invoke SetDlgItemText,hWnd,1007,addr szBigBuffer
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey3, addr dwBBufLength
invoke SetDlgItemText,hWnd,1008,addr szBigBuffer
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey4, addr dwBBufLength
invoke SetDlgItemText,hWnd,1009,addr szBigBuffer
the values in the 3 textboxes are always the subkey2(textbox ID_1007), it's possible reset the buffer and reuse'it to the second GetRegKeysz, or i have to create diferent buffers for each operation?
bye...
Assuming you're dealing with REG_SZ type, there is no need to reset the buffer or whatever, because \0 terminator does that for you, and you don't need to fill buffer with spaces before using the API, and of course you can reuse your buffer as many times as you want.
hi ramguru something rong hapend to me...
i have this in code.inc
szBigBuffer db " ",0
szBigBuffer2 db " ",0
dwBBufLength DWORD SIZEOF szBigBuffer + 1
and this in code.asm
.386
.model flat,stdcall
option casemap:none
include code.inc
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke DialogBoxParam, hInstance, IDD_MAINDLG, NULL, addr DlgProc, NULL
invoke ExitProcess,eax
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg==WM_INITDIALOG
invoke SendMessage,hWnd,WM_SETICON,1,eax
.elseif uMsg==WM_COMMAND
mov eax,wParam
.if eax==1002
invoke SendMessage,hWnd,WM_CLOSE,0,0
.elseif eax==1005
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
invoke SetDlgItemText,hWnd,1007,addr szBigBuffer
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
invoke SetDlgItemText,hWnd,1008,addr szBigBuffer
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
invoke SetDlgItemText,hWnd,1009,addr szBigBuffer
.endif
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,0
.endif
xor eax,eax
ret
DlgProc endp
GetRegKeysz PROC lpszBuffer:DWORD, lpszKeyName:DWORD, lpszValueName:DWORD, dwStringLength:DWORD
LOCAL TType :DWORD
LOCAL pKey :DWORD
mov TType, REG_SZ
invoke RegCreateKeyEx, HKEY_CURRENT_USER,lpszKeyName, NULL, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL,addr pKey, addr TType
.if eax == ERROR_SUCCESS
mov eax, REG_DWORD
mov TType, eax
invoke RegQueryValueEx, pKey, lpszValueName,NULL, ADDR TType, lpszBuffer, dwStringLength
invoke RegCloseKey, pKey
.endif
ret
GetRegKeysz ENDP
End start
and the text for the 3 textboxes are the same as the first(1007)... do you know why???
First of all:
Quote from: 5k3l3t0r on July 30, 2007, 10:24:58 AM
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
invoke SetDlgItemText,hWnd,1007,addr szBigBuffer
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
invoke SetDlgItemText,hWnd,1008,addr szBigBuffer
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
invoke SetDlgItemText,hWnd,1009,addr szBigBuffer
I see nothing different in these three statements: subkey2 subkey2 subkey2
shouldn't it be like: subkey1 subkey2 subkey3
And also I don't have whole picture of your code: ADDR key? ADDR subkey2?
hi, you are right, ===I see nothing different in these three statements: subkey2 subkey2 subkey2
shouldn't it be like: subkey1 subkey2 subkey3=====
i made this now in my office in a .txt and scape that, i don,t have the source here...but every thing is fine with the reg keys, because for experience i create diferent buffers for each one and work fine...
if you want i can give to you the entire project in RadAsm, but after lunch... for me... i don't know what time is it in yor country, i'm in Portugal and here 11.47 AM....
No need...btw 1:50pm here
:dazzled: 1.50 PM ????? night??
ok, but i need your help... :( , can you give me some??
am would be night, I thought you're having lunch and giving me some time to make conclusion :bg
lol, sry here whe don't use AM,PM Whe use 12/24 24.00= 00.00
ok, but you don't need the project? or just the .inc and .asm?
bye and sry if i,m borrow you...
OK what can be wrong with your code in spite of: subkeys duplication
are:
invoke RegCreateKeyEx, HKEY_CURRENT_USER, lpszKeyName, NULL, NULL, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,addr pKey, addr TType
.if eax == ERROR_SUCCESS
mov eax, REG_DWORD :!!!!!!!!!!!!!
mov TType, eax
invoke RegQueryValueEx, pKey, lpszValueName,NULL, ADDR TType, lpszBuffer, dwStringLength
invoke RegCloseKey, pKey
.endif
1. The type REG_DWORD: if you want to retrieve a number you should change your code accordingly, like:
.elseif eax==1005
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
mov ecx, DWORD PTR [szBigBuffer]
invoke dwtoa, ecx, ADDR buf ; masm32.lib function, buf is some local buffer like LOCAL buf[32]:BYTE
invoke SetDlgItemText,hWnd,1007,addr buf
...
2. Change REG_DWORD to REG_SZ if that value is string & everything should work fine
ok tkyou, i will try in my lunch time and then i tell you smething, ok?
bye...
sure don't worry, I'm here 18hours a day
Hi again...
i can't put this code works... i define as comments some part of code to simplify my experiences, but nothing, it return some strange values... the values i want is IPAddres,SubnetMask,Gatway... values like those...
.386
.model flat,stdcall
option casemap:none
include Bruno.inc
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke DialogBoxParam, hInstance, IDD_MAINDLG, NULL, addr DlgProc, NULL
invoke ExitProcess,eax
DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL buf[32]:BYTE
.if uMsg==WM_INITDIALOG
invoke SendMessage,hWnd,WM_SETICON,1,eax
;FILL COMBOBOX====================================
; invoke SetDlgItemText,hWnd,1016,addr cbtitle
; invoke GetRegKeysz , addr szBigBuffer, addr keyprofile1, addr subkey5, addr dwBBufLength
; invoke lstrlen,addr szBigBuffer
; cmp eax,1Ch
; je actual
; invoke SendDlgItemMessage,hWnd,1016,CB_ADDSTRING,0,addr szBigBuffer
; invoke GetRegKeysz , addr szBigBuffer2, addr keyprofile2, addr subkey5, addr dwBBufLength2
; invoke lstrlen,addr szBigBuffer2
; cmp eax,1Ch
; je actual
; invoke SendDlgItemMessage,hWnd,1016,CB_ADDSTRING,0,addr szBigBuffer2
; invoke GetRegKeysz , addr szBigBuffer3, addr keyprofile3, addr subkey5, addr dwBBufLength3
; invoke lstrlen,addr szBigBuffer3
; cmp eax,1Ch
; je actual
; invoke SendDlgItemMessage,hWnd,1016,CB_ADDSTRING,0,addr szBigBuffer3
; invoke GetRegKeysz , addr szBigBuffer4, addr keyprofile4, addr subkey5, addr dwBBufLength4
; invoke lstrlen,addr szBigBuffer4
; cmp eax,1Ch
; je actual
; invoke SendDlgItemMessage,hWnd,1016,CB_ADDSTRING,0,addr szBigBuffer4
; invoke GetRegKeysz , addr szBigBuffer5, addr keyprofile5, addr subkey5, addr dwBBufLength5
; invoke lstrlen,addr szBigBuffer5
; cmp eax,1Ch
; je actual
; invoke SendDlgItemMessage,hWnd,1016,CB_ADDSTRING,0,addr szBigBuffer5
actual:
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey1, addr dwBBufLength
mov ecx, DWORD PTR [szBigBuffer]
invoke dwtoa, ecx, ADDR buf
invoke SetDlgItemText,hWnd,1003,addr buf
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
mov ecx, DWORD PTR [szBigBuffer]
invoke dwtoa, ecx, ADDR buf
invoke SetDlgItemText,hWnd,1002,addr buf
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey3, addr dwBBufLength
mov ecx, DWORD PTR [szBigBuffer]
invoke dwtoa, ecx, ADDR buf
invoke SetDlgItemText,hWnd,1004,addr buf
.elseif uMsg==WM_COMMAND
mov eax,wParam
.if eax==1021
invoke SendMessage,hWnd,WM_CLOSE,0,0
.elseif word ptr [wParam]==1016
;.elseif word ptr [wParam+2] ==1
invoke SendDlgItemMessage, hWnd, 1016, CB_GETCURSEL, 0,0
.if eax==1
; invoke GetRegKeysz , addr szBigBuffer, addr keyprofile1, addr subkey4, addr dwBBufLength
; invoke SetDlgItemText,hWnd,1003,addr szBigBuffer
; invoke GetRegKeysz , addr szBigBuffer2, addr keyprofile1, addr subkey1, addr dwBBufLength2
; invoke SetDlgItemText,hWnd,1002,addr szBigBuffer2
; invoke GetRegKeysz , addr szBigBuffer3, addr keyprofile1, addr subkey3, addr dwBBufLength3
; invoke SetDlgItemText,hWnd,1004,addr szBigBuffer3
.else
.endif
.elseif eax==1023
jmp actual
.endif
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,0
.endif
xor eax,eax
ret
DlgProc endp
SetRegKeysz PROC lpszString:DWORD, lpszKeyName:DWORD, lpszValueName:DWORD, dwStringLength
LOCAL Disp :DWORD
LOCAL pKey :DWORD
invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE, lpszKeyName, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, addr pKey, addr Disp
.if eax == ERROR_SUCCESS
invoke RegSetValueEx, pKey, lpszValueName, NULL, REG_SZ, lpszString, dwStringLength
invoke RegCloseKey, pKey
.endif
ret
SetRegKeysz ENDP
GetRegKeysz PROC lpszBuffer:DWORD, lpszKeyName:DWORD, lpszValueName:DWORD, dwStringLength:DWORD
LOCAL TType :DWORD
LOCAL pKey :DWORD
mov TType, REG_SZ
invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE,lpszKeyName, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,addr pKey, addr TType
.if eax == ERROR_SUCCESS
mov eax, REG_DWORD
mov TType, eax
invoke RegQueryValueEx, pKey, lpszValueName,NULL, ADDR TType, lpszBuffer, dwStringLength
invoke RegCloseKey, pKey
.endif
ret
GetRegKeysz ENDP
End start
can you correct this code, or helpme to correct'it?
how do these values look in registry, are you sure they are DWORD values, not strings ?
they are all----REG_MULTI_SZ... what i have to modifi?
This will take a while ... apparently you have to change REG_DWORD to REG_MULTI_SZ and no need for dwtoa...
OK I have some code now:
.elseif eax==1005
invoke GetRegKeysz , addr szBigBuffer, addr key, addr subkey2, addr dwBBufLength
mov esi, OFFSET szBigBuffer
invoke SetDlgItemText,hWnd,1007,addr szBigBuffer
@@:
inc esi
cmp BYTE PTR [esi],0
jnz @B
inc esi
invoke SetDlgItemText,hWnd,1008,esi
@@:
inc esi
cmp BYTE PTR [esi],0
jnz @B
inc esi
invoke SetDlgItemText,hWnd,1009,esi
.endif
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,0
.endif
xor eax,eax
ret
DlgProc endp
GetRegKeysz PROC lpszBuffer:DWORD, lpszKeyName:DWORD, lpszValueName:DWORD, dwStringLength:DWORD
LOCAL TType :DWORD
LOCAL pKey :DWORD
mov TType, REG_SZ
invoke RegCreateKeyEx, HKEY_CURRENT_USER, lpszKeyName, NULL, NULL, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,addr pKey, addr TType
.if eax == ERROR_SUCCESS
mov eax, REG_MULTI_SZ
mov TType, eax
invoke RegQueryValueEx, pKey, lpszValueName,NULL, ADDR TType, lpszBuffer, dwStringLength
invoke RegCloseKey, pKey
.endif
ret
GetRegKeysz ENDP
Now it's obvious that you need only one call to get all values (if these are in one multi_string)