Author Topic: maybe i catch a bug  (Read 5475 times)

dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: maybe i catch a bug
« Reply #15 on: January 14, 2015, 01:58:25 AM »
the manifest file is primarily for common controls
under XP, you can add a manifest and call InitCommonControlsEx to get later version buttons, etc

but - adding a manifest and a version control block also help prevent AV false positives   :P
i generally add them to all my projects

the value returned in EAX is critical
your code design should allow for different messages to return different values

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645469%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645417%28v=vs.85%29.aspx

what happens is - if you return some value other than a null brush handle, windows thinks it's a brush (or an indication to use the default brush) and draws a background on top of the image you just painted   :biggrin:

dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: maybe i catch a bug
« Reply #16 on: January 14, 2015, 02:17:57 AM »
Code: [Select]
    mov     eax,uMsg
    .if eax==WM_INITDIALOG

    .elseif eax==WM_CTLCOLORDLG

    .elseif eax==WM_SIZE

    .elseif eax==WM_COMMAND

    .elseif eax==WM_CLOSE

    .else
        mov     eax,FALSE
        ret                           ;bad design to use multiple RET's
    .endif
    mov     eax,TRUE     ;oops - overwrites any value in EAX
    ret

i prefer this method, although not all forum members agree with me - lol
Code: [Select]
    mov     eax,uMsg
    .if eax==WM_INITDIALOG
        ;init dialog code
        mov     eax,TRUE         ;return TRUE - see WM_INITDIALOG documentation
    .elseif eax==WM_CTLCOLORDLG
        ;paint background code
        mov     eax,hbrNull        ;null brush handle - see WM_CTLCOLORDLG documentation
    .elseif eax==WM_SIZE
        ;size code
        mov     eax,TRUE        ;standard for most handled messages - see DialogProc documentation
    .elseif eax==WM_COMMAND
        ;command code
        mov     eax,TRUE        ;standard for most handled messages - see DialogProc documentation
    .elseif eax==WM_CLOSE
        ;close code
        mov     eax,TRUE        ;standard for most handled messages - see DialogProc documentation
    .else
        mov     eax,FALSE        ;standard for un-handled messages - see DialogProc documentation
    .endif
    ret

A-new

  • Regular Member
  • *
  • Posts: 6
Re: maybe i catch a bug
« Reply #17 on: January 14, 2015, 03:10:54 PM »
I checked every line of code, and finally found the reason
At the end of the Dialog function
Code: [Select]
.else
xor eax,eax ;return FALSE
ret
.endif
; mov eax,TRUE ;I should comment the trip, but this is Radasm template code,so not notice before
ret
DlgProc endp

end start
maybe we should suggest KetilO modify the template code

A-new

  • Regular Member
  • *
  • Posts: 6
Re: maybe i catch a bug
« Reply #18 on: January 14, 2015, 08:22:55 PM »
I read the template code again, most Msg should return TRUE ,so add
Code: [Select]
mov eax,TRUE in the end before  the last
Code: [Select]
ret,we  will not need to add the same code in each message,when requires special return values add a
Code: [Select]
retwell ok.and this can reduce the number of code volume and reducing program volume


dedndave

  • Member
  • *****
  • Posts: 8789
  • Still using Abacus 2.0
    • DednDave
Re: maybe i catch a bug
« Reply #19 on: January 15, 2015, 04:25:45 AM »
re-read my last 2 posts   :P