flat assembler
Message board for the users of flat assembler.

Index > Windows > Help combining two codes

Goto page 1, 2, 3, 4, 5, 6  Next
Author
Thread Post new topic Reply to topic
peet



Joined: 13 Dec 2011
Posts: 63
peet 14 Dec 2011, 22:26
Hi,
i tried to combine a the small miniPAD (from fasm download package) and the transparency example, which would give a nice notepad. Here is the code i used, but same mistunderstanding i may have, anyone may tell me where i did went wrong?

IDM_NEW = 101 ; <- how to interpret? pointing where?

;---------------------------------------------------
I did mark the imported sections from the transparent window example
;---------------------------------------------------

Code:

; Simple text editor - fasm example program

format PE GUI 4.0
entry start
;---------------------------------------------------
ID_SCROLLBAR = 1000
ID_STATIC = 1001
;---------------------------------------------------
include 'win32a.inc'

IDM_NEW   = 101 ; <- how to interpret? pointing where?
IDM_EXIT  = 102
IDM_ABOUT = 901

section '.text' code readable executable

  start:
        invoke  GetModuleHandle,0
        mov     [wc.hInstance],eax
        invoke  LoadIcon,eax,17
        mov     [wc.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],eax
        invoke  RegisterClass,wc
        test    eax,eax
        jz      error

        invoke  LoadMenu,[wc.hInstance],37
        invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_OVERLAPPEDWINDOW,144,128,768,512,NULL,eax,[wc.hInstance],NULL
        test    eax,eax
        jz      error

  msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        cmp     eax,1
        jb      end_loop
        jne     msg_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  error:
        invoke  MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK

  end_loop:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc hwnd,wmsg,wparam,lparam
;---------------------------------------------------
        push    ebx esi edi
        cmp     [wmsg],WM_HSCROLL
        je      .wmhscroll
;---------------------------------------------------
        cmp     [wmsg],WM_CREATE
        je      .wmcreate
        cmp     [wmsg],WM_SIZE
        je      .wmsize
        cmp     [wmsg],WM_SETFOCUS
        je      .wmsetfocus
        cmp     [wmsg],WM_COMMAND
        je      .wmcommand
        cmp     [wmsg],WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     .finish
;---------------------------------------------------
  .wmhscroll:
        mov     eax,[wparam]
        cmp     ax,SB_thumbposition                      ;received when thumb stops dragging
        je      .thumbposition
        cmp     ax,SB_THUMBTRACK                         ;received while thumb is dragging
        je      .thumbposition
        cmp     ax,SB_lineleft                           ;left arrow clicked
        je      .lineleft
        cmp     ax,SB_lineright                          ;right arrow clicked
        je      .lineright
        cmp     ax,SB_pageleft                           ;left space between arrow and thumb clicked
        je      .pageleft
        cmp     ax,SB_pageright                          ;right space between arrow and thumb clicked
        je      .pageright
        jmp     defwndproc
  .thumbposition:                                         ;for our purposes we'll handle both drag/stop events here
        mov     [lpsi.fMask],SIF_TRACKPOS
        invoke  GetScrollInfo,[hwndscroll],SB_CTL,lpsi
        push    [lpsi.nTrackPos]
        pop     [lpsi.nPos]
        mov     [lpsi.fMask],SIF_ALL
        jmp     .update_window
  .lineleft:
        cmp     [lpsi.nPos],6                           ;transparency under 5 will make window invisible/useless
        jb      defwndproc
        dec     [lpsi.nPos]
        jmp     .update_window
  .lineright:
        cmp     [lpsi.nPos],254                         ;transparency over 255 will make window invisible/useless
        jg      defwndproc
        inc     [lpsi.nPos]
        jmp     .update_window
  .pageleft:
        mov     eax,[lpsi.nPage]
        sub     [lpsi.nPos],eax
        jmp     .update_window
  .pageright:
        mov     eax,[lpsi.nPage]
        add     [lpsi.nPos],eax
  .update_window:
        mov     ecx,[lpsi.nPos]
        push    ecx
        cinvoke wsprintf,buffer,_conv,ecx
        invoke  SendMessage,[hwndstatic],WM_SETTEXT,0,buffer
        pop     ecx
        invoke  SetLayeredWindowAttributes,[hwnd],0,ecx,LWA_ALPHA
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,1
        xor     eax,eax
        jmp     finish
;---------------------------------------------------
  .wmcreate:
        invoke  GetClientRect,[hwnd],client
        invoke  CreateWindowEx,WS_EX_CLIENTEDGE,_edit,0,WS_VISIBLE+WS_CHILD+WS_HSCROLL+WS_VSCROLL+ES_AUTOHSCROLL+ES_AUTOVSCROLL+ES_MULTILINE,[client.left],[client.top],[client.right],[client.bottom],[hwnd],0,[wc.hInstance],NULL
        or      eax,eax
        jz      .failed
        mov     [edithwnd],eax
;---------------------------------------------------
        invoke  CreateWindowEx,0,_scrollbar,NULL,WS_VISIBLE+WS_CHILD+SBS_HORZ,25,5,195,15,[hwnd],ID_SCROLLBAR,[wc.hInstance],NULL
        mov     [hwndscroll],eax
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,0
        invoke  SetLayeredWindowAttributes,[hwnd],0,255,LWA_ALPHA
;---------------------------------------------------
        invoke  CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL
        or      eax,eax
        jz      .failed
        mov     [editfont],eax
        invoke  SendMessage,[edithwnd],WM_SETFONT,eax,FALSE
        xor     eax,eax
        jmp     .finish
      .failed:
        or      eax,-1
        jmp     .finish
  .wmsize:
        invoke  GetClientRect,[hwnd],client
        invoke  MoveWindow,[edithwnd],[client.left],[client.top],[client.right],[client.bottom],TRUE
        xor     eax,eax
        jmp     .finish
  .wmsetfocus:
        invoke  SetFocus,[edithwnd]
        xor     eax,eax
        jmp     .finish
  .wmcommand:
        mov     eax,[wparam]
        and     eax,0FFFFh
        cmp     eax,IDM_NEW
        je      .new
        cmp     eax,IDM_ABOUT
        je      .about
        cmp     eax,IDM_EXIT
        je      .wmdestroy
        jmp     .defwndproc
      .new:
        invoke  SendMessage,[edithwnd],WM_SETTEXT,0,0
        jmp     .finish
      .about:
        invoke  MessageBox,[hwnd],_about_text,_about_title,MB_OK
        jmp     .finish
  .wmdestroy:
        invoke  DeleteObject,[editfont]
        invoke  PostQuitMessage,0
        xor     eax,eax
  .finish:
        pop     edi esi ebx
        ret
endp

section '.data' data readable writeable

  _title TCHAR 'miniPad',0
  _about_title TCHAR 'About miniPad',0
  _about_text TCHAR 'This is assembler mini pad...',0
  _error TCHAR 'Startup failed.',0

;---------------------------------------------------
  _signame TCHAR 'visibility',0
  _scrollbar TCHAR 'scrollbar',0
  _static TCHAR 'static',0
  _conv TCHAR '%i',0
;---------------------------------------------------

  _class TCHAR 'miniPAD32',0
  _edit TCHAR 'EDIT',0

  wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class

  edithwnd dd ?
  editfont dd ?

;---------------------------------------------------
  hwndstatic dd ?
  hwndscroll dd ?

  buffer rb 32

  lpsi SCROLLINFO sizeof.SCROLLINFO,SIF_ALL,5,255,1,255,0
;---------------------------------------------------


  msg MSG
  client RECT

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL',\
          gdi,'GDI32.DLL'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

  import user,\
         RegisterClass,'RegisterClassA',\
         CreateWindowEx,'CreateWindowExA',\
         DefWindowProc,'DefWindowProcA',\
         SetWindowLong,'SetWindowLongA',\
         RedrawWindow,'RedrawWindow',\
         GetMessage,'GetMessageA',\
         TranslateMessage,'TranslateMessage',\
         DispatchMessage,'DispatchMessageA',\
         SendMessage,'SendMessageA',\
         LoadCursor,'LoadCursorA',\
         LoadIcon,'LoadIconA',\
         LoadMenu,'LoadMenuA',\
         GetClientRect,'GetClientRect',\
         MoveWindow,'MoveWindow',\
         SetFocus,'SetFocus',\
         MessageBox,'MessageBoxA',\
         PostQuitMessage,'PostQuitMessage'

  import gdi,\
         CreateFont,'CreateFontA',\
         DeleteObject,'DeleteObject'

section '.rsrc' resource data readable

  ; resource directory

  directory RT_MENU,menus,\
            RT_ICON,icons,\
            RT_GROUP_ICON,group_icons,\
            RT_VERSION,versions

  ; resource subdirectories

  resource menus,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu

  resource icons,\
           1,LANG_NEUTRAL,icon_data

  resource group_icons,\
           17,LANG_NEUTRAL,main_icon

  resource versions,\
           1,LANG_NEUTRAL,version

  menu main_menu
       menuitem '&File',0,MFR_POPUP
                menuitem '&Clear',IDM_NEW
                menuseparator
                menuitem '&Grab',IDM_NEW
                menuseparator
                menuitem 'E&xit',IDM_EXIT,MFR_END
       menuitem '?',0,MFR_POPUP + MFR_END
                menuitem 'About...',IDM_ABOUT,MFR_END

  icon main_icon,icon_data,'minipad.ico'

  versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
              'FileDescription','miniPad',\
              'LegalCopyright','OpenSource - No rights reserved.',\
              'FileVersion','1.0',\
              'ProductVersion','1.0',\
              'OriginalFilename','miniPad.EXE'
    


Too i wanted to integrate the CTRL+A keyshortcut, therefore i did add a Grab under Filemenu, but am not shure how to do this by now.

Anyone to help me please?

Kind regards
peet


Last edited by peet on 15 Dec 2011, 21:36; edited 1 time in total
Post 14 Dec 2011, 22:26
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 15 Dec 2011, 08:35
IDM_NEW is not a pointer. It is an unique identifier, that identifies the menu item "New". It is named constant and have value of 101.
Actually the value is not important you can choose whatever value you like. The only important is to be unique.
Below in the source you can see the line: "menuitem '&Clear',IDM_NEW" where the menu item is created with ID= IDM_NEW.
Also, you can check the line in WM_COMMAND handler: "cmp eax,IDM_NEW" - here the program check whether the user choose "New" menu item or not.
Post 15 Dec 2011, 08:35
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 15 Dec 2011, 19:53
hi john,

thanks for your answer.

But what for is this identifier as it is not used in the code, am i right that instead of the "menuitem '&Clear',IDM_NEW" i could write "menuitem '&Clear',101" ?

How can i pull the actual array in the pad to get a CTRL+A copy all, or is there a function i could call therefor?
regards
peet
Post 15 Dec 2011, 19:53
View user's profile Send private message Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 15 Dec 2011, 19:59
Code:
; Simple text editor - fasm example program

format PE GUI 4.0
entry start
;---------------------------------------------------
ID_SCROLLBAR = 1000
ID_STATIC = 1001
;---------------------------------------------------
include 'win32a.inc'

IDM_NEW   = 101
IDM_EXIT  = 102
IDM_ABOUT = 901

section '.text' code readable executable

  start:
        invoke  GetModuleHandle,0
        mov     [wc.hInstance],eax
        invoke  LoadIcon,eax,17
        mov     [wc.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],eax
        invoke  RegisterClass,wc
        test    eax,eax
        jz      error

        invoke  LoadMenu,[wc.hInstance],37
        invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_OVERLAPPEDWINDOW,144,128,768,512,NULL,eax,[wc.hInstance],NULL
        test    eax,eax
        jz      error

  msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        cmp     eax,1
        jb      end_loop
        jne     msg_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  error:
        invoke  MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK

  end_loop:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc hwnd,wmsg,wparam,lparam
;---------------------------------------------------
        push    ebx esi edi 
        cmp     [wmsg],WM_HSCROLL 
        je      .wmhscroll 
;--------------------------------------------------- 
        cmp     [wmsg],WM_CREATE 
        je      .wmcreate 
        cmp     [wmsg],WM_SIZE 
        je      .wmsize 
        cmp     [wmsg],WM_SETFOCUS 
        je      .wmsetfocus 
        cmp     [wmsg],WM_COMMAND 
        je      .wmcommand 
        cmp     [wmsg],WM_DESTROY 
        je      .wmdestroy 
  .defwndproc: 
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] 
        jmp     .finish 
;--------------------------------------------------- 
  .wmhscroll: 
        mov     eax,[wparam]
        cmp     ax,SB_THUMBPOSITION                      ;received when thumb stops dragging
        je      .thumbposition
        cmp     ax,SB_THUMBTRACK                         ;received while thumb is dragging
        je      .thumbposition
        cmp     ax,SB_LINELEFT                           ;left arrow clicked
        je      .lineleft
        cmp     ax,SB_LINERIGHT                          ;right arrow clicked
        je      .lineright
        cmp     ax,SB_PAGELEFT                           ;left space between arrow and thumb clicked
        je      .pageleft
        cmp     ax,SB_PAGERIGHT                          ;right space between arrow and thumb clicked
        je      .pageright
        jmp     .defwndproc
  .thumbposition:                                         ;for our purposes we'll handle both drag/stop events here 
        mov     [lpsi.fMask],SIF_TRACKPOS 
        invoke  GetScrollInfo,[hwndscroll],SB_CTL,lpsi
        push    [lpsi.nTrackPos] 
        pop     [lpsi.nPos] 
        mov     [lpsi.fMask],SIF_ALL 
        jmp     .update_window 
  .lineleft: 
        cmp     [lpsi.nPos],6                           ;transparency under 5 will make window invisible/useless 
        jb      defwndproc 
        dec     [lpsi.nPos] 
        jmp     .update_window 
  .lineright: 
        cmp     [lpsi.nPos],254                         ;transparency over 255 will make window invisible/useless 
        jg      defwndproc 
        inc     [lpsi.nPos] 
        jmp     .update_window 
  .pageleft: 
        mov     eax,[lpsi.nPage] 
        sub     [lpsi.nPos],eax 
        jmp     .update_window 
  .pageright: 
        mov     eax,[lpsi.nPage] 
        add     [lpsi.nPos],eax 
  .update_window:
        mov     ecx,[lpsi.nPos]
        push    ecx
        cinvoke wsprintf,buffer,_conv,ecx
        invoke  SendMessage,[hwndstatic],WM_SETTEXT,0,buffer
        pop     ecx
        invoke  SetLayeredWindowAttributes,[hwnd],0,ecx,LWA_ALPHA
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,1
        xor     eax,eax
        jmp     finish
;---------------------------------------------------
  .wmcreate:
        invoke  GetClientRect,[hwnd],client
        invoke  CreateWindowEx,WS_EX_CLIENTEDGE,_edit,0,WS_VISIBLE+WS_CHILD+WS_HSCROLL+WS_VSCROLL+ES_AUTOHSCROLL+ES_AUTOVSCROLL+ES_MULTILINE,[client.left],[client.top],[client.right],[client.bottom],[hwnd],0,[wc.hInstance],NULL
        or      eax,eax
        jz      .failed
        mov     [edithwnd],eax
;---------------------------------------------------
        invoke  CreateWindowEx,0,_scrollbar,NULL,WS_VISIBLE+WS_CHILD+SBS_HORZ,25,5,195,15,[hwnd],ID_SCROLLBAR,[wc.hInstance],NULL
        mov     [hwndscroll],eax
        invoke  SetScrollInfo,[hwndscroll],SB_CTL,lpsi,0
        invoke  SetLayeredWindowAttributes,[hwnd],0,255,LWA_ALPHA
;---------------------------------------------------
        invoke  CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL
        or      eax,eax
        jz      .failed
        mov     [editfont],eax
        invoke  SendMessage,[edithwnd],WM_SETFONT,eax,FALSE
        xor     eax,eax
        jmp     .finish
      .failed:
        or      eax,-1
        jmp     .finish
  .wmsize:
        invoke  GetClientRect,[hwnd],client
        invoke  MoveWindow,[edithwnd],[client.left],[client.top],[client.right],[client.bottom],TRUE
        xor     eax,eax
        jmp     .finish
  .wmsetfocus:
        invoke  SetFocus,[edithwnd]
        xor     eax,eax
        jmp     .finish
  .wmcommand:
        mov     eax,[wparam]
        and     eax,0FFFFh
        cmp     eax,IDM_NEW
        je      .new
        cmp     eax,IDM_ABOUT
        je      .about
        cmp     eax,IDM_EXIT
        je      .wmdestroy
        jmp     .defwndproc
      .new:
        invoke  SendMessage,[edithwnd],WM_SETTEXT,0,0
        jmp     .finish
      .about:
        invoke  MessageBox,[hwnd],_about_text,_about_title,MB_OK
        jmp     .finish
  .wmdestroy:
        invoke  DeleteObject,[editfont]
        invoke  PostQuitMessage,0
        xor     eax,eax
  .finish:
        pop     edi esi ebx
        ret
endp

section '.data' data readable writeable

  _title TCHAR '=] miniPad [=',0
  _about_title TCHAR 'About miniPad',0
  _about_text TCHAR 'This is assembler pad for mini =o]',0
  _error TCHAR 'Startup failed.',0

;---------------------------------------------------
  _signame TCHAR 'visibility',0
  _scrollbar TCHAR 'scrollbar',0
  _static TCHAR 'static',0
  _conv TCHAR '%i',0
;---------------------------------------------------

  _class TCHAR 'miniPAD32',0
  _edit TCHAR 'EDIT',0

  wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class

  edithwnd dd ?
  editfont dd ?

;---------------------------------------------------
  hwndstatic dd ?
  hwndscroll dd ?

  buffer rb 32

  lpsi SCROLLINFO sizeof.SCROLLINFO,SIF_ALL,5,255,1,255,0
;---------------------------------------------------


  msg MSG
  client RECT

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL',\
          gdi,'GDI32.DLL'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

  import user,\
         RegisterClass,'RegisterClassA',\
         CreateWindowEx,'CreateWindowExA',\
         DefWindowProc,'DefWindowProcA',\
         SetWindowLong,'SetWindowLongA',\
         RedrawWindow,'RedrawWindow',\
         GetMessage,'GetMessageA',\
         TranslateMessage,'TranslateMessage',\
         DispatchMessage,'DispatchMessageA',\
         SendMessage,'SendMessageA',\
         LoadCursor,'LoadCursorA',\
         LoadIcon,'LoadIconA',\
         LoadMenu,'LoadMenuA',\
         GetClientRect,'GetClientRect',\
         MoveWindow,'MoveWindow',\
         SetFocus,'SetFocus',\
         MessageBox,'MessageBoxA',\
         PostQuitMessage,'PostQuitMessage'

  import gdi,\
         CreateFont,'CreateFontA',\
         DeleteObject,'DeleteObject'

section '.rsrc' resource data readable

  ; resource directory

  directory RT_MENU,menus,\
            RT_ICON,icons,\
            RT_GROUP_ICON,group_icons,\
            RT_VERSION,versions

  ; resource subdirectories

  resource menus,\
           37,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu

  resource icons,\
           1,LANG_NEUTRAL,icon_data

  resource group_icons,\
           17,LANG_NEUTRAL,main_icon

  resource versions,\
           1,LANG_NEUTRAL,version

  menu main_menu
       menuitem '&File',0,MFR_POPUP
                menuitem '&Clear',IDM_NEW
                menuseparator
                menuitem '&Grab',IDM_NEW
                menuseparator
                menuitem 'E&xit',IDM_EXIT,MFR_END
       menuitem '?',0,MFR_POPUP + MFR_END
                menuitem 'About...',IDM_ABOUT,MFR_END

  icon main_icon,icon_data,'minipad.ico'

  versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
              'FileDescription','miniPad',\
              'LegalCopyright','OpenSource - No rights reserved.',\
              'FileVersion','1.0',\
              'ProductVersion','1.0',\
              'OriginalFilename','miniPad.EXE'
    


compiling produces error - undefined symbol in asm file compiler marks: call[GetScrollInfo]
and in proc32.inc the last line of invoke proc: call [proc] }

while in original code same order of code works.?

Anyone could help me please?

kind regards
peet
Post 15 Dec 2011, 19:59
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 15 Dec 2011, 22:18
peet wrote:
But what for is this identifier as it is not used in the code, am i right that instead of the "menuitem '&Clear',IDM_NEW" i could write "menuitem '&Clear',101" ?


Yes, you can write the constant directly. The reason to use named constant is that it makes the code more readable and if you need to change the value, you have to change it in one place, not in many.

How it works? When you create menu item (calling windows API functions), you pass this ID number for the given menu item. (btw, it is the same for buttons for example).
Then, when the user clicks on the menu item, Windows generates message WM_COMMAND and post it to the message queue of your application. The main message loop of the application reads these messages from the queue and dispatches them to the message handlers of the different

So, when you process WM_COMMAND message you can distinguish exactly what event caused the message - button click, some menu item or other. Read WM_COMMAND reference for details.
Post 15 Dec 2011, 22:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 15 Dec 2011, 22:34
thats cool, so the statement IDM_NEW=101 is more likely used for backward recognizion of own code invoked messages from os and i guess this makes if then else a lot simpler.

do you have an idea why in my last code the proc is not present at time of call?
Post 15 Dec 2011, 22:34
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 15 Dec 2011, 23:19
Maybe you forgot to import this function? Smile
Post 15 Dec 2011, 23:19
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
bdo1964



Joined: 18 Sep 2011
Posts: 7
bdo1964 16 Dec 2011, 03:33
peet...

think of:

IDM_NEW = 101

as a constant [actually it's more like a global variable]

so let's consider a different constant...

we will call it:

CURRENT_YEAR = 2011

now say that you want to use this number CURRENT_YEAR

all throughout your code...

you are correct
these instructions both produce the same result:

Code:
mov     eax,2011
mov eax,CURRENT_YEAR
    


now say that you end up using the number
2011 hundreds of times in your code!!

what happens in 2012????

well...

you could change 2011 to 2012 hundreds of times in your code!!

or you could change:

Code:
CURRENT_YEAR  = 2011
to
CURRENT_YEAR    = 2012
    
Post 16 Dec 2011, 03:33
View user's profile Send private message Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 16 Dec 2011, 06:45
but the sence behind this constant is to provide the function IDM_NEW with a shorter payload of call? only to save bits, right?

in your example the content of the constant is the sence (2011/2012...) in the code we discuss not the number 101 is the sence for IDM_NEW, it's just a shorter call of IDM_NEW function?! right?
Post 16 Dec 2011, 06:45
View user's profile Send private message Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 16 Dec 2011, 06:55
JohnFound wrote:
Maybe you forgot to import this function? :)


got me, did not recognize w instead of a in import line, lol, tnx

but now i stuck with kernel.inc where compiler tells me: SYSTEM_INFO.wProcessorArchitecture dw ?

?
Post 16 Dec 2011, 06:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 16 Dec 2011, 06:57
@peet: IDM_NEW is not a function. It is just a number, nothing else. You could make IDM_NEW any value you please from 0 to 2^32-1. Your choice. The only thing you have to make sure of is that it is unique and different from the other constants (IDM_EXIT and IDM_ABOUT). And to further generalise, all three of those constants can be any number you like, just make sure they are different from each other.
Post 16 Dec 2011, 06:57
View user's profile Send private message Visit poster's website Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 16 Dec 2011, 07:07
revolution wrote:
@peet: IDM_NEW is not a function. It is just a number, nothing else. You could make IDM_NEW any value you please from 0 to 2^32-1. Your choice. The only thing you have to make sure of is that it is unique and different from the other constants (IDM_EXIT and IDM_ABOUT). And to further generalise, all three of those constants can be any number you like, just make sure they are different from each other.


not a function of the code but a "function" provided by the OS, and the code IDM_NEW does invoke a reset of the application window called through the 101 in the example. so the compiler set the 101 == IDM_NEW and compiles code where 101 is used as the call of IDM_NEW right?

so in daus sight of code it would easier to understand if there would be written

101 = IDM_NEW

and if i would define another 723 = .thumbposition i could use 723 instad of abcdcall (.thumbposition,...) -> abcdcall (723,...)
Post 16 Dec 2011, 07:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 16 Dec 2011, 07:30
IDM_NEW is not a "function provided by the OS". It is just a number. The OS does not interpret the number in any way. The OS will just return the number back to your code so your code can identify which control was clicked/activated/altered. You never use IDM_NEW as a call address. 101 would be in the unaccessable address space below 4kB so if you did use it as a call destination your app would crash.
Post 16 Dec 2011, 07:30
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 16 Dec 2011, 14:44
@revolution:
The command IDs for WM_COMMAND are 16-bit sized in range [0001h .. FFFFh]

@peet:
What exactly your code is doing with miniPAD and transparency?
Can you explain what you trying to do?
Post 16 Dec 2011, 14:44
View user's profile Send private message Send e-mail Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 16 Dec 2011, 19:07
@revolution: but IDM_NEW is nowhere defined with code to execute, so it's a function provided by the compiler, inc or what else?
so if in the gui the item is clicked, the os send the constants number, so our code knows the os wants us to do an IDM_NEW. Am i right that using 786374683274628345 instead of 101 would make no sence as it is a lot more bytes then IDM_NEW, as for reading a IDM_NEW is more handy then 101 (but longer).?

@AsmGuru: i like the small pad a lot, because i often need temorary data on remote servers to work with, but i don't want those data saved. When i swa the transparent window i had the idea to make that miniPAD fading, this would make it easy fpr me to place pad over script and check syntax or content by a look. the more i wanted to make the ctrl+a keycut possible to select whole content of pad by a key.

i got some more ideas like a menuitem to send selected chars directly to local cmd. i like the idea of a small adminsPAD with some very special functions, as long as it keeps small and simple. guess a lot of us out there would like a small payload and only temporary living pad.


Last edited by peet on 16 Dec 2011, 19:15; edited 1 time in total
Post 16 Dec 2011, 19:07
View user's profile Send private message Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 16 Dec 2011, 19:12
the more i think about it the more i get shure to spend my days off over christmas with this. and shure i guess there is something out there, but i am too shure that it will be a 20MB hammer with millions of functions. No i want a small (open source to check code and be save) and simple tool. only weird nowhere seen functions and only transient existing.

feed me :) i want to code at least to arrange code, lol
Post 16 Dec 2011, 19:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 17 Dec 2011, 00:58
peet wrote:
@revolution: but IDM_NEW is nowhere defined with code to execute, so it's a function provided by the compiler, inc or what else?
It is not a function. In just the same way that "peet" is not a function. It exists as a convenient way for you to identify which control is being used.
peet wrote:
so if in the gui the item is clicked, the os send the constants number, so our code knows the os wants us to do an IDM_NEW. Am i right that using 786374683274628345 instead of 101 would make no sence as it is a lot more bytes then IDM_NEW, as for reading a IDM_NEW is more handy then 101 (but longer).?
Well your number is too big anyway (and thanks AsmGuru62 for your correction), you can have numbers in the range 0 to 2^16-1. And the reason to make it 101 was never to save bytes, but simply because whoever first wrote the code decided that 101 seemed logical for their purposes. It could just have easily have been 0x101, or 0xffff, or 0x1369 ... it doesn't matter which. But I think you are getting the point, you are correct to say that the OS sends you the number, but the OS gets that number from you first when you initialised the control. You first told the OS you wanted to use 101 as the reference number and later the OS said control with reference number 101 was activated.
Post 17 Dec 2011, 00:58
View user's profile Send private message Visit poster's website Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 17 Dec 2011, 01:42
@revolution: hm, yes me seems to got to eat that first,lol. so where is defined what IDM_NEW is doing?
Post 17 Dec 2011, 01:42
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 17 Dec 2011, 02:59
Assuming you originated from the High Language universe. That is equivalent to this:

Code:

in resource.h

#define IDC_NEW 1001

in main.c

#include "resource.h"

switch(uMsg)
{
  case IDC_NEW: DoSomething(); break;
  case WM_xxxx: DoSomething(); break;
}

in resource.rc

#include "resource.h"

200 MENU 
{
 MENUITEM "&New...\tCtrl+N", IDC_NEW;
}

    



I hope you are familiar with that
Post 17 Dec 2011, 02:59
View user's profile Send private message Reply with quote
peet



Joined: 13 Dec 2011
Posts: 63
peet 17 Dec 2011, 03:25
yes that helped, think i gonna better go to bed now lol, it late here, or early ;)

so i found the IDM_NEW in FASMW.ASM, but nowhere a link (include) to that file, is this defined in compiler anywhere maybe?
Post 17 Dec 2011, 03:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3, 4, 5, 6  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.