flat assembler
Message board for the users of flat assembler.

Index > Windows > Please help translate iczeleon example to fasm.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1852
Roman 18 Jul 2018, 12:03
Code:
.elseif uMsg==WM_NOTIFY
                push esi
                mov esi,lParam
                assume esi:ptr NMHDR
                .if [esi].code==EN_MSGFILTER
                        assume esi:ptr MSGFILTER
                        .if [esi].msg==WM_RBUTTONDOWN    


How i understood:
Code:
mov esi,[lParam]
cmp [esi+8], EN_MSGFILTER
cmp [esi+4], WM_RBUTTONDOWN
    
Post 18 Jul 2018, 12:03
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 806
Location: Russian Federation, Sochi
ProMiNick 18 Jul 2018, 13:39
Code:
.wmnotify:
   push esi
   mov esi,[lParam]
   virtual at esi
      mfltr MSGFILTER
   end virtual
   cmp [mfltr.nmhdr.code],EN_MSGFILTER ; or cmp [esi+8],EN_MSGFILTER
   jne .exit
   cmp [mfltr.msg],WM_RBUTTONDOWN  ; or cmp [esi+12],WM_RBUTTONDOWN    

or
Code:
.wmnotify:
   push esi
   mov esi,[lParam]
   cmp [esi +MSGFILTER.nmhdr.code],EN_MSGFILTER
   jne .exit
   cmp [esi +MSGFILTER.msg],WM_RBUTTONDOWN  ; or cmp [esi+12],WM_RBUTTONDOWN    



Code:
struct NMHDR
  hwndFrom  dd ?
  idFrom    dd ?
  code dd ?
ends

struct MSGFILTER
  nmhdr  NMHDR
  msg    dd ?
  wParam dd ?
  lParam dd ?
ends    
Post 18 Jul 2018, 13:39
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1852
Roman 18 Jul 2018, 13:59
Thanks ! Now Work !

But why [esi+12] (cmp [esi +MSGFILTER.msg],WM_RBUTTONDOWN) ?!

MSGFILTER its struct and msg have offset + 4 !

O ! Sh..t i understood ! MSGFILTER its two structs in one !

I made a mistake ! I think nmhdr NMHDR is a pointer like dd .

Поспешишь, людей насмешишь Smile
Post 18 Jul 2018, 13:59
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 19 Jul 2018, 07:51
If you use fasm's extended headers you can retain the ".if" syntax:
Code:
.if [esi+MSGFILTER.nmhdr.code]=EN_MSGFILTER    

If you prefer to stick to basic headers, you can still just do:
Code:
include 'macro\if.inc'    
to enable these macros.
Post 19 Jul 2018, 07:51
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1852
Roman 21 Jul 2018, 17:01
Thanks !
Post 21 Jul 2018, 17:01
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 806
Location: Russian Federation, Sochi
ProMiNick 21 Jul 2018, 18:56
to Roman and anybody else who want to adapt any tutorials to fasm syntax (especially x64 tuts).
Is Iczeleon tutes have examples of using comctrls?
I would be very appreciate if you share ones tutorials in fasm syntax where common controls (rebar and/or property sheet) used.
I interest in correctnes of structures that described in "comctrl32.inc" - to test different versions of that structures on different windows versions. And later adapt them to x64 and find complement version sizes of such structures in x64.

how my comctl.inc look like (structures are crossversion x32-x64):
Code:
struct PROPSHEETPAGE
  dwSize        dd ?
  dwFlags       dd ?
  hInstance     HNDL
  union
    pszTemplate ptr *string
    pResource   ptr *resID
  ends
  union
    hIcon       HNDL
    pszIcon     ptr *string
  ends
  pszTitle      ptr *string
  pfnDlgProc    ptr *proc
  lParam        dd ?
                align
  pfnCallback   ptr *proc
  pcRefParent   ptr *uint
ends

struct PROPSHEETPAGE_V2
  dwSize        dd ?
  dwFlags       dd ?
  hInstance     HNDL
  union
    pszTemplate ptr *string
    pResource   ptr *resID
  ends
  union
    hIcon       HNDL
    pszIcon     ptr *string
  ends
  pszTitle      ptr *string
  pfnDlgProc    ptr *proc
  lParam        dd ?
                align
  pfnCallback   ptr *proc
  pcRefParent   ptr *uint
  pszHeaderTitle ptr *string
  pszHeaderSubTitle ptr *string
ends

struct PROPSHEETPAGE_V3
  dwSize        dd ?
  dwFlags       dd ?
  hInstance     HNDL
  union
    pszTemplate ptr *string
    pResource   ptr *resID
  ends
  union
    hIcon       HNDL
    pszIcon     ptr *string
  ends
  pszTitle      ptr *string
  pfnDlgProc    ptr *proc
  lParam        dd ?
                align
  pfnCallback   ptr *proc
  pcRefParent   ptr *uint
  pszHeaderTitle ptr *string
  pszHeaderSubTitle ptr *string
  hActCtx       HNDL
ends

struct PROPSHEETHEADER
  dwSize        dd ?
  dwFlags       dd ?
  hwndParent    HNDL
  hInstance     HNDL
  union
    hIcon       HNDL
    pszIcon     ptr *string
  ends
  pszCaption    ptr *string
  nPages        dd ?
                align
  union
    pStartPage  ptr *string or ptr *resID
    nStartPage  dd ?
  ends
  ppsp          ptr *PROPSHEETPAGE[]
  pfnCallback   ptr *proc
ends

struct IMAGEINFO
  hbmImage HNDL
  hbmMask  HNDL
  Unused1  dd ?
  Unused2  dd ?
  rcImage  RECT
ends

struct HD_ITEM
  mask       dd ?
  cxy        dd ?
  pszText    ptr *string
  hbm        HNDL
  cchTextMax dd ?
  fmt        dd ?
  lParam     dd ?
ends

struct HD_LAYOUT
  prc   ptr *RECT
  pwpos ptr *WINDOWPOS
ends

struct HD_HITTESTINFO
  pt    POINT
  flags dd ?
  iItem dd ?
ends

struct HD_NOTIFY
  hdr     NMHDR
  iItem   dd ?
  iButton dd ?
  pitem   ptr *HD_ITEM
ends

struct TBBUTTON
  iBitmap   dd ?
  idCommand dd ?
  fsState   db ?
  fsStyle   db ?
            align
  dwData    integer ?
  iString   ptr *string or zero-based index
ends

struct COLORMAP
  from dd ?
  to   dd ?
ends

struct TBADDBITMAP
  hInst HNDL
  nID   dd ?
        align
ends

struct TBSAVEPARAMS
  hkr          HNDL
  pszSubKey    ptr *string
  pszValueName ptr *string
ends

struct TBREPLACEBITMAP
  hInstOld HNDL
  nIDOld   ptr *string or resID
  hInstNew HNDL
  nIDNew   ptr *string or resID
  nButtons integer ?
ends

struct NMTOOLBAR
  hdr      NMHDR
  iItem    dd ?
  tbButton TBBUTTON
  cchText  dd ?
  pszText  ptr *string
ends

struct REBARINFO
  cbSize dd ?
  fMask  dd ?
  himl   HNDL
ends

struct REBARBANDINFO
  cbSize      dd ?
  fMask       dd ?
  fStyle      dd ?
  clrFore     dd ?
  clrBack     dd ?
              align
  lpText      ptr *string
  cch         dd ?
  iImage      dd ?
  hwndChild   HNDL
  cxMinChild  dd ?
  cyMinChild  dd ?
  cx          dd ?
             ;align or not???????
  hbmBack     HNDL ; unknown aligned or not !!!!!!!!!!!!!!
  wID         dd ?
ends

struct TOOLINFO
  cbSize     dd ?
  uFlags     dd ?
  hwnd       HNDL
  uId        ptr *VOID
  rect       RECT
  hInst      HNDL
  lpszText   ptr *string
  lParam     ptr *VOID
  lpReserved ptr *VOID
ends

struct TTHITTESTINFO
  hwnd HNDL ; dq aligned
  pt   POINT
  ti   TOOLINFO
ends

struct TOOLTIPTEXT
  hdr      NMHDR
  lpszText ptr *string
  szText   db 80 dup (?)
  hinst    HNDL
  uFlags   dd ?
ends

struct UDACCEL
  nSec dd ?
  nInc dd ?
ends

struct NM_UPDOWN
  hdr    NMHDR
  iPos   dd ?
  iDelta dd ?
ends

struct LV_ITEM
  mask       dd ?
  iItem      dd ?
  iSubItem   dd ?
  state      dd ?
  stateMask  dd ?
             align
  pszText    ptr *string
  cchTextMax dd ?
  iImage     dd ?
  lParam     dd ?
  iIndent    dd ?
ends

struct LV_FINDINFO
  flags       dd ?
              align
  psz         ptr *string
  lParam      ptr *VOID
  pt          POINT
  vkDirection dd ?
ends

struct LV_HITTESTINFO
  pt    POINT
  flags dd ?
  iItem dd ?
ends

struct LV_COLUMN
  mask       dd ?
  fmt        dd ?
  cx         dd ?
             align
  pszText    ptr *string
  cchTextMax dd ?
  iSubItem   dd ?
ends

struct NM_LISTVIEW
  hdr       NMHDR
  iItem     dd ?
  iSubItem  dd ?
  uNewState dd ?
  uOldState dd ?
  uChanged  dd ?
  ptAction  POINT
            align
  lParam    ptr *VOID
ends

struct NM_CACHEHINT
  hdr   NMHDR
  iFrom dd ?
  iTo   dd ?
ends

struct NM_FINDITEM
  hdr    NMHDR
  iStart dd ?
  lvfi   LV_FINDINFO
ends

struct LV_DISPINFO
  hdr  NMHDR
  item LV_ITEM
ends

struct LV_KEYDOWN
  hdr   NMHDR
  wVKey dw ?
  flags dd ?
ends

struct TV_ITEM
  mask           dd ?
                 align
  hItem          HNDL
  state          dd ?
  stateMask      dd ?
  pszText        ptr *string
  cchTextMax     dd ?
  iImage         dd ?
  iSelectedImage dd ?
  cChildren      dd ?
  lParam         dd ?
ends

struct TV_INSERTSTRUCT
  hParent      HNDL
  hInsertAfter HNDL
  item         TV_ITEM
ends

struct TV_HITTESTINFO
  pt    POINT
  flags dd ?
        align
  hItem HNDL
ends

struct TV_SORTCB
  hParent     HNDL
  lpfnCompare ptr *proc
  lParam      ptr *VOID
ends

struct NM_TREEVIEW
  hdr     NMHDR
  action  dd ?
  itemOld TV_ITEM
  itemNew TV_ITEM
  ptDrag  POINT
ends

struct TV_DISPINFO
  hdr  NMHDR
  item TV_ITEM
ends

struct TV_KEYDOWN
  hdr   NMHDR
  wVKey dw ?
  flags dd ?
ends

struct TC_ITEMHEADER
  mask        dd ?
  lpReserved1 dd ?
  lpReserved2 dd ?
              align
  pszText     ptr *string
  cchTextMax  dd ?
  iImage      dd ?
ends

struct TC_ITEM
  mask        dd ?
  lpReserved1 dd ?
  lpReserved2 dd ?
              align
  pszText     ptr *string
  cchTextMax  dd ?
  iImage      dd ?
  lParam      dd ?
ends

struct TC_HITTESTINFO
  pt    POINT
  flags dd ?
ends

struct TC_KEYDOWN
  hdr   NMHDR
  wVKey dw ?
  flags dd ?
ends

struct MC_HITTESTINFO
  cbSize dd ?
  pt     POINT
  uHit   dd ?
  st     SYSTEMTIME
ends

struct NM_SELCHANGE
  nmhdr      NMHDR
  stSelStart SYSTEMTIME
  stSelEnd   SYSTEMTIME
ends

struct NM_DAYSTATE
  nmhdr       NMHDR
  stStart     SYSTEMTIME
  cDayState   dd ?
  prgDayState dd ?
ends

struct NM_DATETIMECHANGE
  nmhdr   NMHDR
  dwFlags dd ?
  st      SYSTEMTIME
ends

struct NM_DATETIMESTRING
  nmhdr         NMHDR
  pszUserString ptr *string
  st            SYSTEMTIME
  dwFlags       dd ?
ends

struct NM_DATETIMEWMKEYDOWN
  nmhdr     NMHDR
  nVirtKey  dd ?
            align
  pszFormat ptr *string
  st        SYSTEMTIME
ends

struct NM_DATETIMEFORMAT
  nmhdr      NMHDR
  pszFormat  ptr *string
  st         SYSTEMTIME
  pszDisplay ptr *string
  szDisplay  db 64 dup (?)
ends

struct NM_DATETIMEFORMATQUERY
  nmhdr     NMHDR
  pszFormat ptr *string
  szMax     SIZE
ends

struct INITCOMMONCONTROLSEX
  dwSize dd ?
  dwICC  dd ?
ends     
I`m not sured in size correctness of their variant for x64
without definitions under you could determine structures like they in pseudocode (but with definitions it became workable code)

crossversion x32-x64 definitions:
x32 variant
Code:
struc ptr [val] { common . dd ? }
macro ptr [val] {   dd ? }

struc HNDL [val] { common . dd ? }
macro HNDL [val] {   dd ? }

struc integer [val]
{
  common  label . dword at $
  forward dd val
}

macro integer [val]
{
  forward dd val
}

struc align val
{
  if val eq
    align 4
  else
    align val
  end if
}    
x64 variant
Code:
struc ptr [val] { common . dq ? }
macro ptr [val] {   dq ? }

struc HNDL [val] { common . dq ? }
macro HNDL [val] {   dq ? }

struc integer [val]
{
  common  label . qword at $
  forward dq val
}

macro integer [val]
{
  forward dq val
}

struc align val
{
  if val eq
    align 4
  else
    align val
  end if
}        
and little patched struct
Code:
macro rt count \{ \local anonymous
                     define field@struct anonymous,dt,count dup (?) \}
   macro align    \{ \local anonymous ; added align in it
                     define field@struct anonymous,align, \}
   macro union \{ field@struct equ ,union,<
                  sub@struct equ union \}     

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 21 Jul 2018, 18:56
View user's profile Send private message Send e-mail Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 143
Location: Russian Federation, Irkutsk
Mikl___ 22 Jul 2018, 00:14
Привет, Roman!
  1. Уроки Iczelion'а х64 на русском языке Сказки дядюшки Римуса
  2. Iczelion tutorial x64 in masm Examples for Win64 Iczelion tutorial
  3. in FASM Iczelion's tutorials by Sulaiman Chang
Post 22 Jul 2018, 00:14
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1852
Roman 26 Jul 2018, 05:57
ProMiNick
Why need write 64 bit examples ?!
32 bit dll enough !

Msdn: You can only load a 32bit DLL into a 64 bit process when you are loading the dll as a datafile.
See Revolution post https://board.flatassembler.net/topic.php?p=141331
Use KERNEL32.DLL in 64 bit example.

DLL more powerfull and more flexible. One time write and use allway !


Rewriting examples for 64 bits will complicate your life Wink
Post 26 Jul 2018, 05:57
View user's profile Send private message Reply with quote
Mikl___



Joined: 30 Dec 2014
Posts: 143
Location: Russian Federation, Irkutsk
Mikl___ 26 Jul 2018, 06:43
Hi, Roman!
Quote:
Rewriting examples for 64 bits will complicate your life

Really? Or should there be "sarcasm" tags here? Image
Post 26 Jul 2018, 06:43
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 806
Location: Russian Federation, Sochi
ProMiNick 26 Jul 2018, 07:57
Roman
If you writing exe-file it is dosn`t matter what bitness it has because windows can run both. And in most of all cases 32 apps faster then 64 bit ones.
But all changed when you trying to write dll (if you want someone later could use it in exes of different bitness) - you have to realize it in both bitness.
MSDN well documented 32 bit structures, but with 64 bit ones it is not clear where structure member stayed 32 bit, where it is aligned for 64 bit (before member & after member), and what members extended to 64 bit.
It is clear only that members that are pointers and handles extended to 64 bit, and they forced to be aligned within structure by 8 byte border (even if structure itself started unaligned to 8 byte boundary). Structure size is mystery in 64 bitness too, when size isn`t module of 8 it is aligned et end, isn`t it (because in large range of MS structures first member is structure size - so size is very significant).
Post 26 Jul 2018, 07:57
View user's profile Send private message Send e-mail 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.