well basically i want my program to read an ini file first it will get the section names...then it will get the keynames and then the string of each keyname.. but the problem is its gonna be an ini file that i wont know the keynames/sections beforehand
so im trying to figure a good procedure to grab the section names in a buffer <which are supposedly null terminated according to msdn> then ill pass each name to another procedure that gets the keynames in order to get their strings
so anyway this is what i got so far and its not working

INIname db ".\urls.ini",0
headBuffer db 256 dup(?)
invoke ReadINI
invoke ExitProcess,0

ReadINI proc
invoke GetPrivateProfileSectionNames,addr headBuffer,addr Len,ADDR INIname
lea esi, headBuffer
test al, al
jnz @b
mov al, BYTE PTR [esi]
test al, al
jz ListDone
invoke MessageBox,0, esi,addr INIname,0
jmp @b
ReadINI endp
end start

tell me why this ini function does not cycle through the ini names that get stored in the buffer
Posted on 2003-12-25 19:30:33 by illwill
Wrong second parameter GetPrivateProfileSectionNames. Need sizeof headBuffer.
Your code don't show first section name.
; console app

.model flat, stdcall
option casemap :none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

INIname db 'c:\winnt\w32dasm8.ini',0
szSmall db 'Buffer is not large enough to contain all the section names',13,10,0
szSectName db '[%s]',13,10,0

SimplePrintf proc C, pszFormat, param:VARARG
local buffer[2048]:byte
local hOutPut:dword
local bWritten:dword

invoke wvsprintf, addr buffer, pszFormat, addr param
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov hOutPut,eax
invoke lstrlen,addr buffer
mov ecx,eax
invoke WriteFile, hOutPut, addr buffer, ecx, addr bWritten, NULL
mov eax, bWritten
SimplePrintf endp

main proc
local headBuffer[1024]

invoke GetPrivateProfileSectionNames,addr headBuffer, sizeof headBuffer,\
offset INIname
add eax,2
.if eax == sizeof headBuffer
invoke SimplePrintf, offset szSmall
push ebx
lea ebx,headBuffer
.while byte ptr [ebx] != 0
invoke SimplePrintf, offset szSectName, ebx
invoke lstrlen, ebx
inc eax
add ebx,eax
pop ebx

main endp

invoke main
invoke ExitProcess,0

end _start
Posted on 2003-12-25 21:23:33 by P2M