flat assembler
Message board for the users of flat assembler.

Index > Windows > Windows 10 combobox exit from my program.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 15 Dec 2020, 08:35
This code work on Windows 7 32 bit program

But in Win 10 my program 64 bit close.

I create combobox
Code:
ComboUserTxt dq 0
invoke CreateWindowEx,0,'combobox',0,dword WS_VISIBLE+WS_VSCROLL+WS_CHILD+CBS_DROPDOWN+CBS_HASSTRINGS,\
          dword 4,dword 670,dword 310,dword 230,[hwnd],dword 22,0,NULL 
mov  [ComboUserTxt],rax ;i get ComboHndl and see combobox
    

And in loop peekmessage i get text from combobox.
This code close my program , but get text fine !
Code:
invoke SendMessage,[ComboUserTxt],dword WM_GETTEXT,dword 10,Status22+2000
    

If i comment SendMessage my program work fine and work fine combobox.


Last edited by Roman on 15 Dec 2020, 09:14; edited 2 times in total
Post 15 Dec 2020, 08:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 15 Dec 2020, 08:46
Using SendMessage will place a new message into the queue. So if your loop keeps sending itself messages then the stack eventually overflows and problems happen.
Post 15 Dec 2020, 08:46
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 15 Dec 2020, 08:50
How i do peekmessage
Code:
.1: invoke PeekMessage,msg, 0, 0, 0, PM_REMOVE
     test   eax,eax
     jz     .2
     invoke  TranslateMessage,  msg
     invoke  DispatchMessage,  msg 
.2:  IfPressedKey VK_F6,.3  ;if not pressed jmp .3
     invoke SendMessage,[ComboUserTxt],dword WM_GETTEXT,dword 10,Status22+2000
     invoke MessageBoxA,0,Status22+2000,0,0 ;i see text from combobox
.3:
     invoke Sleep,10
     jmp .1
    


I not SendMessage always , only if VK_F6 key pressed !
But one pressed VK_F6 and my prograg after MessageBox close.
Post 15 Dec 2020, 08:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 15 Dec 2020, 09:04
Try using PostMessage instead.
Post 15 Dec 2020, 09:04
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 15 Dec 2020, 09:14
invoke PostMessage,[ComboUserTxt],dword WM_GETTEXT,dword 20,Status22+2000
as like SendMessage close my program too.
Post 15 Dec 2020, 09:14
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 15 Dec 2020, 09:17
Hm ?! Maybe i write wrong MSG struct (32 bits ) ?
Code:
struct MSG 32 bits
  hwnd    dd ?
  message dd ?
  wParam  dd ?
  lParam  dd ?
  time    dd ?
  pt      POINT
ends
struct MSG 64 bits
  hwnd    dq ?
  message dd ?,?
  wParam  dq ?
  lParam  dq ?
  time    dd ?
  pt      POINT
          dd ?
ends
    

Not help.
Post 15 Dec 2020, 09:17
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 15 Dec 2020, 09:38
I using FEDIT.dll
without FEDIT window my program not close !

Strange ?

I try without FEDIT window ,but some time my program work fine and some times close.
Post 15 Dec 2020, 09:38
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 15 Dec 2020, 11:06
I found my problem in IDA Pro 64 bits !
SendMessage change stack values !
And after SendMessage i do my cominvk Direct2D !
And Direct2D drawBitmap crash on stack !
I fix.
Clear stack
Code:
mov     qword [rsp+40h-20h+8],0    

And do Direct2D drawBitmap.
Now all work fine !


PS: I am scared, and already thought its problem Windows 10.
Post 15 Dec 2020, 11:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 15 Dec 2020, 11:19
Roman wrote:
SendMessage change stack values !
That seems unlikely. It violates the call standard. If true, then that is a very serious bug and MS should fix it. But how come no one else has seen the problem? I suspect the root of the problem is actually somewhere else in your code.
Post 15 Dec 2020, 11:19
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 15 Dec 2020, 14:44
Quote:

I suspect the root of the problem is actually somewhere else in your code.

Yes. You right. Its my mistake.
Post 15 Dec 2020, 14:44
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 716
Ali.Z 16 Dec 2020, 03:21
Roman wrote:
Code:
 invoke Sleep,10
    


instead use WaitMessage function, as for getting notified for key presses just register a hotkey and make a CALLBACK procedure then do whatever you wish there.

this way you can keep your message loop clean and you should not experience delay in messages when your application under heavy load.

_________________
Asm For Wise Humans
Post 16 Dec 2020, 03:21
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 16 Dec 2020, 15:35
revolution wrote:
Using SendMessage will place a new message into the queue. So if your loop keeps sending itself messages then the stack eventually overflows and problems happen.
FWIW, SendMessage does not post a message to any queues if same thread. It technically does post to a queue if you send it cross-thread or cross-process, but it's not retrieved by Get/PeekMessage, so it might as well not be (that's an implementation detail).

Note that GetMessage will actually process the SendMessage queue (sent from another thread), but it won't return it as a message, so it happens "behind the scenes", unlike messages posted by PostMessage (which you'll have to dispatch after with DispatchMessage or simply inspect/drop them).

What it does is it calls the respective window proc with the message, waiting for it to return and all. When it's cross-thread/process, it still waits for result (via synchronization) but then the target thread needs to be processing messages.

tl;dr: Assume SendMessage doesn't work with queues. Microsoft clearly tried to make it seem this way.
Post 16 Dec 2020, 15:35
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 716
Ali.Z 17 Dec 2020, 00:25
basically same as what Furs said regarding SendMessage.

WIN32.HLP wrote:
If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, Windows switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message.


but to be honest, i dont believe most documentation as a result with microsoft windows the expectation based on documents is not identical to the reality when using those functions.

_________________
Asm For Wise Humans
Post 17 Dec 2020, 00:25
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 17 Dec 2020, 16:50
Yeah it's good to be cautious like that. In this case, though, it's true, since Wine implements it that way as well, and it has a lot of unit tests to test the actual behavior of the Windows API (rather than blindly trust the docs, which are sometimes wrong).
Post 17 Dec 2020, 16:50
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.