flat assembler
Message board for the users of flat assembler.
Index
> Windows > Need Registry Access Example |
Author |
|
Madis731 15 Mar 2004, 18:56
Why don't you use commands declared in advapi32.dll, or are you aiming to some 2k/Xp specific code in assembly
There are RegCloseKey RegCreateKey RegCreateKeyEx ...etc... |
|||
15 Mar 2004, 18:56 |
|
Rookie 16 Mar 2004, 21:16
This will create "HKEY_LOCAL_MACHINE\Software\Registry\Example" and store the exe path in the ExePath key:
Code: format PE GUI 4.0 include '%fasminc%\win32a.inc' Start: invoke GetProcessHeap mov [lpHeap],eax invoke HeapAlloc,[lpHeap],HEAP_ZERO_MEMORY,8000h mov [lpModName],eax invoke GetModuleFileName,NULL,[lpModName],8000h mov [lpModSize],eax mov eax,[lpModName] invoke CharLower,[lpModName] add eax,[lpModSize] @@: cmp byte [eax],5Ch je @f dec eax dec [lpModSize] jmp @b @@: inc [lpModSize] mov byte [eax],0 invoke RegCreateKeyEx,HKEY_LOCAL_MACHINE,lpSubKey,0,0,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0,phkResult,lpdwDisp cmp eax,0 jne IsNOk invoke RegSetValueEx,[phkResult],lpExePth,0,REG_SZ,[lpModName],[lpModSize] cmp eax,0 jne IsNOk invoke MessageBox,0,msgOk,caption,MB_ICONINFORMATION+MB_OK jmp exit IsNOk: invoke MessageBox,0,msgNOk,caption,MB_ICONERROR+MB_OK exit: invoke RegCloseKey,phkResult invoke HeapFree,[lpHeap],0,[lpModName] invoke ExitProcess,0 caption db 'Registry Example',0 msgOk db 'I may have been able to succesfully update the registry.',0 msgNOk db 'I''m sorry, but I have failed you. The registry was not set up correctly.',0 lpSubKey db 'Software\Registry\Example',0 lpExePth db 'ExePath',0 lpHeap dd ? lpModName dd ? lpModSize dd ? phkResult dd ? lpdwDisp dd ? data import library kernel32,'kernel32.dll',\ user32,'user32.dll',\ advapi32,'advapi32.dll' import kernel32,\ GetProcessHeap,'GetProcessHeap',\ HeapAlloc,'HeapAlloc',\ HeapFree,'HeapFree',\ GetModuleFileName,'GetModuleFileNameA',\ ExitProcess,'ExitProcess' import user32,\ CharLower,'CharLowerA',\ MessageBox,'MessageBoxA' import advapi32,\ RegCreateKeyEx,'RegCreateKeyExA',\ RegSetValueEx,'RegSetValueExA',\ RegCloseKey,'RegCloseKey' end data Hope you find it useful. _________________ This is who I choose to be. |
|||
16 Mar 2004, 21:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.