News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Crash using LVM_SETIEM

Started by Grincheux, September 01, 2013, 04:14:31 PM

Previous topic - Next topic

Grincheux

Here is my code


lea r9,_Lvi
lea rcx,_szTmpIndex
mov (LVITEM Ptr [r9]).imask,LVIF_DI_SETITEM or LVIF_TEXT or LVIF_STATE
mov (LVITEM Ptr [r9]).state,LVIS_SELECTED or LVIS_FOCUSED
mov (LVITEM Ptr [r9]).stateMask,LVIS_SELECTED or LVIS_FOCUSED
mov (LVITEM Ptr [r9]).iSubItem,0
mov (LVITEM Ptr [r9]).iItem,eax
mov (LVITEM Ptr [r9]).pszText,rcx
mov rcx,hLogLv
mov rdx,LVM_INSERTITEM
xor r8,r8
call SendMessage

lea r9,_Lvi
lea rcx,_szTmpDate
mov (LVITEM Ptr [r9]).imask,LVIF_TEXT or LVIF_STATE
mov (LVITEM Ptr [r9]).iItem,eax
mov (LVITEM Ptr [r9]).iSubItem,1
mov (LVITEM Ptr [r9]).pszText,rcx
mov (LVITEM Ptr [r9]).cchTextMax,0
mov (LVITEM Ptr [r9]).lParam,0
mov rcx,hLogLv
mov rdx,LVM_SETITEM
xor r8,r8
call SendMessage


I don't understand. The LVM_INSERTITEM works fine and returns the new item value. When I call the second SendMessage (LVM_SETITEM) the program crashes. I don't use UNICODE and it seems that Windows changes my text in UNICODE. See memory dump below.
0x0000000000091E30  30 00 31 00 2f 00 30 00 39 00 2f 00 32 00 30 00 31 00 33 00 00 00 ab ab ab ab ab ab ab ab ab ab ab ab ab ab  0.1./.0.9./.2.0.1.3...««««««««««««««
LVM_SETITEM is defined with the 6 value.
Here is my LVITEM structure definition :

LV_ITEM STRUCT 8
imask DWord ?
iItem DWord ?
iSubItem DWord ?
state DWord ?
stateMask DWord ?
pszText LPSTR ?
cchTextMax DWord ?
iImage DWord ?
lParam LPARAM ?
iIndent DWord ?
iGroupId DWord ?
cColumns DWord ?
puColumns DWord ?
piColFmt DWord ?
iGroup DWord ?
LV_ITEM ENDS


LVITEM  equ  <LV_ITEM>


LPLV_ITEM Typedef PTR LV_ITEM
LPLVITEM Typedef PTR LV_ITEM




Please help me.

japheth

Quote from: Grincheux on September 01, 2013, 04:14:31 PM
When I call the second SendMessage (LVM_SETITEM) the program crashes.

If the program does really crash, then it's very likely that the pszText member is the problem. As a first step you should verify that pszText causes the problem by trying to use LVM_SETITEM without LVIF_TEXT flag ( perhaps just using LVIF_LPARAM, because I'm not sure if LVIF_STATE is ok to use with subitems ).

Quote
Here is my LVITEM structure definition :

LV_ITEM STRUCT 8
imask DWord ?
iItem DWord ?
iSubItem DWord ?
state DWord ?
stateMask DWord ?
pszText LPSTR ?
cchTextMax DWord ?
iImage DWord ?
lParam LPARAM ?
iIndent DWord ?
iGroupId DWord ?
cColumns DWord ?
puColumns DWord ?
piColFmt DWord ?
iGroup DWord ?
LV_ITEM ENDS



Note that members puColumns and piColFmt are pointers - they should be defined as QWord instead of DWord in 64-bit. I understand that the online MSDN tells differently ( http://msdn.microsoft.com/en-us/library/windows/desktop/bb774760%28v=vs.85%29.aspx ), but it's wrong - the qualitiy of the MS Windows documentation is definitely declining.