flat assembler
Message board for the users of flat assembler.


Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/privalov/sites/board.flatassembler.net/attach_mod/displaying.php on line 626
Index > Windows > WritePrivateProfileString not work!, whats wrong?

Author
Thread Post new topic Reply to topic
vagination



Joined: 27 Dec 2012
Posts: 3
vagination
Update.ini is already created in the same directory

Update.ini
Quote:
[Download]
File=


Code:
Code:
Format PE GUI
Entry start

    include 'win32ax.inc'

section '.data' data readable writeable

         Seccion  db 'Download', 0
         Key      db 'File', 0
         String   db 'program.exe',0

         Config   db "Update.ini",0

section '.text' code readable executable

  start:

        push  Config
        push  String
        push  Key
        push  Seccion
        call [WritePrivateProfileStringA]

        push  0
        call [ExitProcess]


section '.idata' import data readable
library kernel32,'KERNEL32.DLL',\
        user32,'USER32.DLL'

 import kernel32,\
          WritePrivateProfileStringA,'WritePrivateProfileStringA',\
          ExitProcess,'ExitProcess'

section '.reloc' fixups data readable discardable     


WritePrivateProfileString not work!, whats wrong?

Regards.
Post 05 Jan 2013, 19:58
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
vagination,

When in doubt, RTFM.
MSDN wrote:
If the lpFileName parameter does not contain a full path and file name for the file, WritePrivateProfileString searches the Windows directory for the file. If the file does not exist, this function creates the file in the Windows directory.
Post 05 Jan 2013, 20:22
View user's profile Send private message Reply with quote
vagination



Joined: 27 Dec 2012
Posts: 3
vagination
Solucion using GetFullPathNameA.

GetPrivateProfileString confused me because it does not need the full path.

Code:
Code:
Format PE GUI
Entry start

    include "win32ax.inc"

section '.data' data readable writeable

         Seccion  db 'Download', 0
         Key      db 'File', 0
         String   db 'program.exe',0

         Config   db "Update.ini",0
         Path     db 256h DUP (0)



section '.text' code readable executable

  start:

        push  0
        push  Path
        push  256h
        push  Config
        call [GetFullPathNameA]

        push  Path
        push  String
        push  Key
        push  Seccion
        call [WritePrivateProfileStringA]

        push  0
        call [ExitProcess]


section '.idata' import data readable
library kernel32,'KERNEL32.DLL',\
        user32,'USER32.DLL'

 import kernel32,\
          WritePrivateProfileStringA,'WritePrivateProfileStringA',\
          ExitProcess,'ExitProcess',\
          GetFullPathNameA,'GetFullPathNameA'

section '.reloc' fixups data readable discardable
    


Regards.
Post 05 Jan 2013, 23:52
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
vagination,

256h seems too arbitrary, you may use MAX_PATH instead. And those bytes don't have to be initialized.

It always makes me curious why somebody would include "win32ax.inc" and not use its features, like enhanced invoke and automatic API imports. Relocations for PE .EXE with default base look suspicious too.
Post 06 Jan 2013, 05:59
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
vagination?
Post 06 Jan 2013, 16:02
View user's profile Send private message Reply with quote
vagination



Joined: 27 Dec 2012
Posts: 3
vagination
typedef: hahahaa ! xD

baldr: Now use MAX_PATH... include "win32ax.inc" , is habit ;P
Post 09 Jan 2013, 21:11
View user's profile Send private message 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-2020, Tomasz Grysztar.

Powered by rwasa.