flat assembler
Message board for the users of flat assembler.

Index > Windows > inifile without sections

Author
Thread Post new topic Reply to topic
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 30 Aug 2010, 17:45
a file %UserProfile%\SciTE.session has not sections.
Code:
# SciTE session file

position.left=0
position.top=0
position.width=1152 ; SM_CXSCREEN Smile
position.height=812
position.maximize=0 ; NULL
...
la-la-la...    


involke WritePrivateProfileString... don't help me now.
The way i see to write section [zzzz] and delete it after. Smile
But i don't know how to use search api in ascii text... (

Some exmple in script language
Quote:
#AutoIt3 Script
$sFile = @UserProfileDir & '\SciTE.session'

FileSetAttrib($sFile, '-R')

_IniWriteProperty($sFile, 'position.left', '0')
_IniWriteProperty($sFile, 'position.top', '0')
_IniWriteProperty($sFile, 'position.width', @DesktopWidth)
_IniWriteProperty($sFile, 'position.height', @DesktopHeight-52)
_IniWriteProperty($sFile, 'position.maximize', '0')

Func _IniWriteProperty($sIni, $sProperty, $sValue)
Local $sSection, $sContent, $hWrite

$sSection = 'Section'
$sContent = '[' & $sSection & ']' & @CRLF & FileRead($sIni)

$hWrite = FileOpen($sIni, 2)
FileWrite($hWrite, $sContent)
FileClose($hWrite)

IniWrite($sIni, $sSection, $sProperty, $sValue)
IniWrite($sIni, $sSection, $sProperty, $sValue)

$sContent = FileRead($sIni)

$hWrite = FileOpen($sIni, 2)
FileWrite($hWrite, StringRegExpReplace($sContent, '^\Q[' & $sSection & ']\E(\r\n)*', ''))
FileClose($hWrite)
EndFunc


offtop: it could be better the fasm has a support hi level language #includes like C++ etc.
Very Happy

_________________
Windows 9, FL Studio 19
Post 30 Aug 2010, 17:45
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 30 Aug 2010, 20:41
I guess that this topic may be interesting to you. Smile

You can also write some text parser by yourself eventually. Wink
Post 30 Aug 2010, 20:41
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 30 Aug 2010, 21:12
Post 30 Aug 2010, 21:12
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 30 Aug 2010, 21:26
Ну чтож... выбери наиболее подходящий вариант. Wink

Well... choose the solution most suitable to your needs. Wink
Post 30 Aug 2010, 21:26
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 31 Aug 2010, 10:27
Very Happy +1 english only available on the forum )))

Something i need above... I need to load strings per number from a file and keep string to buffer for compare it...
Something exist to loads strins? api or asm?...

invoke StringNumber,eax,5,NULL Razz Rolling Eyes
Post 31 Aug 2010, 10:27
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 31 Aug 2010, 11:04
fscanf from 'MSVCRT.DLL'. Razz
Post 31 Aug 2010, 11:04
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 31 Aug 2010, 14:22
Until I decided to create one hard to replace file.

Code:
        invoke ExpandEnvironmentStrings,'%UserProfile%\SciTE.session',bFile,MAX_PATH
        invoke CreateFile,bFile,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,NULL
        mov [hFile],eax
        invoke WriteFile,[hFile],p1,68,node,NULL

        invoke GetSystemMetrics,SM_CXSCREEN
        invoke wsprintf,x,'%d',eax
        invoke SetFilePointer,[hFile],68,NULL,NULL
        invoke WriteFile,[hFile],x,4,node,NULL

        invoke SetFilePointer,[hFile],72,NULL,NULL
        invoke WriteFile,[hFile],p2,17,node,NULL

        invoke GetSystemMetrics,SM_CYSCREEN
        sub eax,52
        invoke wsprintf,y,'%d',eax
        invoke SetFilePointer,[hFile],89,NULL,NULL
        invoke WriteFile,[hFile],y,3,node,NULL

        invoke SetFilePointer,[hFile],92,NULL,NULL
        invoke WriteFile,[hFile],p3,22,node,NULL
        invoke CloseHandle,[hFile]

section '.data' readable

        p1 db '# SciTE session file',10,10,'position.left=0',10,'position.top=0',10,'position.width='
        p2 db 10,'position.height='
        p3 db 10,'position.maximize=0',10,10

section '.data' readable writable
        bFile db ?
        hFile dd ?
        lpDir db ?
        node dd ?
        x dd ?
        y dd ?    


I found that '?' data must be into separated section that not be overlaped with constant data. I don't know it early. ))

1. what is need to say strongly size to node ?
I don't know SM_CXSCREEN realy width 800[] or 2048 returned

gluck:
Quote:
position.width=800[]


2. Is it possible to write GetSystemMetrics() ahead code and WriteFile() functions below? Something in eax > x i have losted...
Maybe this need to use locals .. endl ?
Smile

3. and this Mac stile 0a not 0d 0a!... Cool? ))


---
fscanf from 'MSVCRT.DLL'. This is great! Smile Thanks allways!
Post 31 Aug 2010, 14:22
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 31 Aug 2010, 17:24
wsprintf will return number of characters.
Code:
cinvoke wsprintf,y,'%d',eax
invoke WriteFile,[hFile],y,eax,node,NULL
.
.
.
y rb  1024 ; max buffer    


Last edited by bitRAKE on 02 Sep 2010, 01:45; edited 1 time in total
Post 31 Aug 2010, 17:24
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 31 Aug 2010, 20:37
Thanks!

Code:
..
        invoke GetSystemMetrics,SM_CYSCREEN
        sub eax,52 ; task bar size
        invoke wsprintf,y,'%d',eax ; y rb 1024 accepted!
        invoke SetFilePointer,[hFile],89,NULL,NULL
        invoke WriteFile,[hFile],y,eax,node,NULL

        add eax,89 ; correct text position
        invoke SetFilePointer,[hFile],eax,NULL,NULL
        invoke WriteFile,[hFile],p3,22,node,NULL
        invoke CloseHandle,[hFile]
...    

nothing good Confused
Post 31 Aug 2010, 20:37
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 31 Aug 2010, 20:55
offtop:

FasmDir\include\const.inc:
Code:
HKCU equ HKEY_CURRENT_USER
HKLM equ HKEY_LOCAL_MACHINE
@CR db 13
@LF db 10    


Where is i need to include this to win32ax.inc includes ?
I'm lazy to write it to every my program.

This is bug -
Code:
; Extended Win32 programming headers (ASCII)

include 'win32a.inc'
include 'const.inc'
include 'macro/if.inc'    

Why? Very Happy

I'm sorry for I try modify fasm original distributive!
Post 31 Aug 2010, 20:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 31 Aug 2010, 23:35
semiono wrote:
FasmDir\include\const.inc:
Code:
HKCU equ HKEY_CURRENT_USER
HKLM equ HKEY_LOCAL_MACHINE
@CR db 13
@LF db 10    


Where is i need to include this to win32ax.inc includes ?
I'm lazy to write it to every my program.

This is bug -
Code:
; Extended Win32 programming headers (ASCII)

include 'win32a.inc'
include 'const.inc'
include 'macro/if.inc'    

Why? Very Happy
You need to use =
Code:
@CR = 13
@LF = 10    
Post 31 Aug 2010, 23:35
View user's profile Send private message Visit poster's website Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 01 Sep 2010, 06:32
bitRAKE, did you mean to use cinvoke with wsprintf or to manually adjust the stack?
Post 01 Sep 2010, 06:32
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 01 Sep 2010, 22:51
today is really popular xml format, what is engine to invoked to software to set fields in file programly?
WritePrivateProfileString() for xml ?
Post 01 Sep 2010, 22:51
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 02 Sep 2010, 01:44
Alphonso wrote:
bitRAKE, did you mean to use cinvoke with wsprintf or to manually adjust the stack?
Yeah, cinvoke would be needed there - thanks for the correction.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 02 Sep 2010, 01:44
View user's profile Send private message Visit poster's website 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.