News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

TB_GETRECT

Started by bomz, May 04, 2011, 08:21:43 PM

Previous topic - Next topic

bomz

Quote
.386

.model flat, stdcall
option casemap :none

   include \masm32\include\windows.inc

   include \masm32\include\user32.inc
   include \masm32\include\kernel32.inc
   include \masm32\include\shell32.inc
   include \masm32\include\masm32.inc

   includelib \masm32\lib\user32.lib
   includelib \masm32\lib\kernel32.lib
   includelib \masm32\lib\shell32.lib
   includelib \masm32\lib\masm32.lib


EXTRADATA struct
        Wnd dd ?
        uID dd ?
EXTRADATA ends

.data
mestitle   db "RECT",0
form      db "ID process: %d", 9,"TOP: %d", 9,"LEFT: %d", 9,"BOTTOM: %d", 9,"RIGHT: %d",  0
Class1      db 'Shell_TrayWnd',0
Class2      db 'TrayNotifyWnd',0
Class3      db 'SysPager',0
Class4      db 'ToolbarWindow32',0

.data?
extra      EXTRADATA <>
button      TBBUTTON <>
rect1      RECT <>
rect      RECT <>
buffer      db 512 dup(?)
hWnd      HWND ?
ProcId      dd ?
hProcess   dd ?
lpData      dd ?
IconNumber   dd ?
BytesRead   dd ?
ProcTrayId   dd ?

.code
start:

   invoke FindWindow,addr Class1, NULL
   mov hWnd, eax
   invoke FindWindowEx,hWnd,NULL,addr Class2, NULL
   mov hWnd, eax
   invoke FindWindowEx,hWnd,NULL,addr Class3, NULL
   mov hWnd, eax
   invoke FindWindowEx,hWnd,NULL,addr Class4, NULL
   mov hWnd, eax
   invoke GetWindowRect, hWnd,addr rect
   invoke  SendMessage,hWnd,TB_BUTTONCOUNT,0,0
   mov IconNumber, eax
   invoke  GetWindowThreadProcessId,hWnd,addr ProcId
   invoke  OpenProcess,PROCESS_ALL_ACCESS,FALSE,ProcId
   mov hProcess,eax
   invoke  VirtualAllocEx,hProcess,NULL,sizeof button,MEM_COMMIT,PAGE_READWRITE
         mov lpData, eax
NEXT:
;   dec IconNumber
   mov IconNumber, 0 ;Mozilla Firefox

   invoke  SendMessage,hWnd,TB_GETBUTTON,IconNumber,lpData
   invoke  ReadProcessMemory, hProcess, lpData,addr button, sizeof button, addr BytesRead
   invoke  ReadProcessMemory,hProcess,button.dwData,addr extra, sizeof extra,addr BytesRead
   invoke  GetWindowThreadProcessId, extra.Wnd,addr ProcTrayId

;   invoke  SendMessage,hWnd,TB_GETRECT, button.idCommand, addr rect1 ;FATAL SYSTEM CRASH

   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect1.top, rect1.left,  rect1.bottom, rect1.right
   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK
   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect.top, rect.left, rect.bottom, rect.right
   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK

;cmp IconNumber,0
;jnz NEXT
   invoke  VirtualFreeEx,ProcId,lpData,0,MEM_RELEASE
   invoke  CloseHandle,ProcId
   invoke ExitProcess,0

end start

qWord

Quoteaddr rect1
:snooty:
FPU in a trice: SmplMath
It's that simple!

bomz

Quote
   invoke  VirtualAllocEx,hProcess,NULL,sizeof button,MEM_COMMIT,PAGE_READWRITE
         mov lpData, eax   
   invoke  VirtualAllocEx,hProcess,NULL,sizeof rect1,MEM_COMMIT,PAGE_READWRITE
         mov lpData1, eax
   mov IconNumber, 0

   invoke  SendMessage,hWnd,TB_GETBUTTON,IconNumber,lpData
   invoke  ReadProcessMemory, hProcess, lpData,addr button, sizeof button, addr BytesRead
   invoke  ReadProcessMemory,hProcess,button.dwData,addr extra, sizeof extra,addr BytesRead
   invoke  GetWindowThreadProcessId, extra.Wnd,addr ProcTrayId

   invoke  SendMessage,hWnd,TB_GETRECT, button.idCommand, lpData1
   invoke  ReadProcessMemory, hProcess, lpData1,addr rect1, sizeof rect1, addr BytesRead


   mov eax, rect1.top
   inc eax
   add rect.top, eax
   mov eax, rect1.left
   inc eax
   add rect.left, eax
   mov eax, rect1.right
   dec eax
   add rect.right, eax
   mov eax, rect1.bottom
   dec eax
   add rect.bottom, eax


;   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect1.top, rect1.left,  rect1.bottom, rect1.right
;   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK
   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect.top, rect.left, rect.bottom, rect.right
   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK

May be so - no fatal error but I can't understand what I get

qWord

Quote from: bomz on May 04, 2011, 08:55:08 PMMay be so - no fatal error but I can't understand what I get
so? What is your question?
FPU in a trice: SmplMath
It's that simple!

bomz

at first - is it right? second may I get tray icon position?

baltoro

I have two suggestions:

  • Tell us briefly what you are attempting to do. It is not apparent from the code you posted.
  • Zip you source code and add it to your post as an attachment, so that we can look over the entire thing.

Click on the Additional Option link just under the reply box to see how to attach a file (they must be zipped).
Baltoro

bomz

#6
find position of icon in system tray


baltoro

bomz,
Hi. I did a Google search. And, I found a number of things which you might find useful:
Why Do Some People Call the Taskbar the "Tray"?
Should All Windows Appear in the Taskbar?
The Taskbar, MSDN
Notification Area MSDN
Windows Shell MSDN
Also, here is an article for C++ programmers about the, Shell_NotifyIcon function: Basic Use of Shell_NotifyIcon in Win32.
Here is the MSDN documentation for the: Shell_NotifyIcon Function
I hope this helps. I don't know anything about it, sorry,...but, I'm guessing that you are not approaching the problem in the correct way. I don't think calling FindWindowEx repeatedly with the "class names" listed in your code above is going to work.
Baltoro

bomz

The problem in correct manipulate with explorer memory

qWord

what is the purpose of knowing the icons postion? - what should be the result of all your efforts?
FPU in a trice: SmplMath
It's that simple!

bomz

balon popup apear from icon. see picture

bomz

Is it possible free system memory application use. For example application use invoke GetOpenFileName, addr ofn, at this moment system add 3 mb of memory to application , after close GetOpenFileName this memory don't free

baltoro

You seem to be a minimalist in terms of providing us with details about your application. This is why the forum members are reluctant to help you.
I have to suspect that maybe English is not your native language.
So,...the obvious questions are: to which application does this icon with the balloon belong ??? Is this an access problem ???
Also, which Windows version of the Operating System is installed on the computer that this application will run on ??? (I ask this because, the security characteristics of the various versions are different.) Do you understand this ???
ReadProcessMemory will fail for numerous reasons,...but, typically, it is an access denied error. And, I notice in the little code that posted above,...you don't even check the return value to see if the function actually succeeded. This makes no sense,...
Baltoro

bomz

Quote from: baltoro on May 05, 2011, 03:58:12 PM
You seem to be a minimalist in terms of providing us with details about your application. This is why the forum members are reluctant to help you.
I have to suspect that maybe English is not your native language.
So,...the obvious questions are: to which application does this icon with the balloon belong ??? Is this an access problem ???
Also, which Windows version of the Operating System is installed on the computer that this application will run on ??? (I ask this because, the security characteristics of the various versions are different.) Do you understand this ???
ReadProcessMemory will fail for numerous reasons,...but, typically, it is an access denied error. And, I notice in the little code that posted above,...you don't even check the return value to see if the function actually succeeded. This makes no sense,...
My application 40 kb long - this code in post - test. In future this part of code I would use in all my application
No native - I try to limit by emotions. MASM for all nonative
Windows XP but this code must work Windows 7, lazy for verify - it's need to repack W7 from Acronis Archive.
No error for text limit

baltoro

Well,...OK,...then,...that's that,...
Baltoro