flat assembler
Message board for the users of flat assembler.

Index > Windows > need help with registry

Author
Thread Post new topic Reply to topic
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 11 Aug 2004, 16:43
please help, why it won't work?

Code:
format PE GUI 4.0
entry start

include '%fasminc%\win32a.inc'

MAX_PATH                        = 104h
ERROR_SUCCESS                 = 0

section '.udata' readable writeable

   hKey         dd ?
   ofn          OPENFILENAME
   szGetFilename        rb MAX_PATH

section '.data' data readable writeable

   szExplorer       db "Software\Microsoft\Windows\CurrentVersion\Explorer",0
   szRun     db "Software\Microsoft\Windows\CurrentVersion\Run",0
   szReg  db "Registration",0
   szNero      db "NeroCDapi",0

   _filter    db "All Files",0,"*.*",0
                db 0

section '.code' code readable executable
   start:
     call    open_file
   invoke  RegCreateKeyEx,HKEY_CURRENT_USER,szExplorer,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,hKey,NULL
 cmp     eax,ERROR_SUCCESS
   jne     its_error

       invoke  RegSetValueEx,hKey,szReg,NULL,REG_SZ,szGetFilename,MAX_PATH
 invoke  RegCloseKey,hKey
    invoke  RegCreateKeyEx,HKEY_CURRENT_USER,szRun,NULL,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,hKey,NULL
      cmp     eax,ERROR_SUCCESS
   jne     its_error

       invoke  RegSetValueEx,hKey,szNero,NULL,REG_SZ,szGetFilename,MAX_PATH
        invoke  RegCloseKey,hKey

   its_error:

       invoke  ExitProcess,0

  open_file:
       mov     [ofn.lStructSize],sizeof.OPENFILENAME
       mov     [ofn.hwndOwner],HWND_DESKTOP
        mov     [ofn.lpstrFile],szGetFilename
       mov     [ofn.nMaxFile],MAX_PATH
     mov     [ofn.lpstrFilter],_filter
   mov     [ofn.nFilterIndex],1
        mov     [ofn.lpstrFileTitle],NULL
   mov     [ofn.nMaxFileTitle],NULL
    mov     [ofn.lpstrInitialDir],NULL
  mov     [ofn.Flags],OFN_EXPLORER+OFN_FILEMUSTEXIST+OFN_HIDEREADONLY

        ;mov     eax,[_inst]
        ;mov     [ofn.hInstance],eax
        ;mov     [ofn.lpstrCustomFilter],NULL
        ;mov     [szTargetFilePath],NULL
        ;mov     [ofn.lpstrTitle],NULL

  invoke  GetOpenFileName,ofn
 ret

data import
   library kernel32,'kernel32.dll',\
      advapi32,'advapi32.dll',\
        comdlg32,'comdlg32.dll'

   import kernel32,\
     ExitProcess,'ExitProcess'

   import advapi32,\
    RegCreateKeyEx,'RegCreateKeyExA',\
       RegCloseKey,'RegCloseKey',\
      RegFlushKey,'RegFlushKey',\
      RegSetValueEx,'RegSetValueExA'

   import comdlg32,\
       GetOpenFileName,'GetOpenFileNameA'

end data    

_________________
[not enough memory]
Post 11 Aug 2004, 16:43
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 11 Aug 2004, 16:56
change:
Code:
RegSetValueEx,hKey    

to:
Code:
RegSetValueEx,[hKey]    


same with RegCloseKey

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 11 Aug 2004, 16:56
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 11 Aug 2004, 18:01
thanks, it works, but whence these points (see included file)?


Description: dots here, why?
Filesize: 951 Bytes
Viewed: 2969 Time(s)

Image2.png



_________________
[not enough memory]
Post 11 Aug 2004, 18:01
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 11 Aug 2004, 21:15
These are because you are storing MAX_SIZE bytes to the registry key. You can use the lenght value provided by GetOpenFileName and then pass it to RegSetValueEx, or use strlen.
Post 11 Aug 2004, 21:15
View user's profile Send private message Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.