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 ;(http://smiles.kolobok.us/standart/not_i.gif)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
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
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?
at first - is it right? second may I get tray icon position?
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).
find position of icon in system tray
(http://s39.radikal.ru/i083/1105/4d/518bf5e67430.png)
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"? (http://blogs.msdn.com/b/oldnewthing/archive/2003/09/10/54831.aspx)
Should All Windows Appear in the Taskbar? (http://blogs.msdn.com/b/oldnewthing/archive/2007/01/17/1483974.aspx)
The Taskbar, MSDN (http://msdn.microsoft.com/en-us/library/cc144179(v=vs.85).aspx)
Notification Area MSDN (http://msdn.microsoft.com/en-us/library/aa511448.aspx)
Windows Shell MSDN (http://msdn.microsoft.com/en-us/library/bb773177(v=VS.85).aspx)
Also, here is an article for C++ programmers about the, Shell_NotifyIcon function: Basic Use of Shell_NotifyIcon in Win32 (http://www.codeproject.com/KB/shell/StealthDialog.aspx).
Here is the MSDN documentation for the: Shell_NotifyIcon Function (http://msdn.microsoft.com/en-us/library/bb762159(v=vs.85).aspx)
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.
The problem in correct manipulate with explorer memory
what is the purpose of knowing the icons postion? - what should be the result of all your efforts?
balon popup apear from icon. see picture
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
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,...
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
Well,...OK,...then,...that's that,...
(http://i058.radikal.ru/1105/ba/ba8988401b14.gif)
I want this - but it was vary hard to do because system fatal crashes after each examination. and now I want be shure that all OK
YOU'RE RUSSIAN ! Why didn't you say so ???
We have a Russian-speaking programmer here on the Forum,...and, he is alot better at this than I am,...
For assigning an ToolTip to the task bar, it's probably needed to to inject a DLL in Explorers process. For an general solution this also implies, that you must at least create two DLLs: 32Bit and 64Bit.
However, DLL injection is an topic, that's not allowed to discuss in this forum.
i think i can understand why he wants the icon position
the fact that he is Russian makes it hard for him to verbalize it, is all :P
Thank God you guys showed up,...I'm afraid I've badly misled the guy,... :green
...And, to be perfectly honest,...I'm quite confused about the whole thing,...
From what I understand you are just trying to get the rect for the icon. The function for that is Shell_NotifyIconGetRect (http://msdn.microsoft.com/en-us/library/dd378426%28v=vs.85%29.aspx). Win7 and above though.
You guys worry me ::)
Tedd, he was talking about adding an ToolTip to the Icon of Mozilla Firefox (AFAIKS)
...Ya know,...I didn't quite get it either,...he has the phrase 'Mozilla Firefox' in his code, but, it doesn't make sense.
Also, one of his responses was:
Quote from: BOMZ...The problem in correct manipulate with explorer memory,...
which confused the hell out of me. I don't think he knew himself. But, he didn't approach the problem by calling Shell functions,...which is what I would have done,...instead, he calls FindWindowEx using a Hwnd that is probably Null,...hell, we don't even know that,...
...And, I didn't recognize the names he listed in his original code for the Window Class Names as registered system names,...
Class1 db 'Shell_TrayWnd',0
Class2 db 'TrayNotifyWnd',0
Class3 db 'SysPager',0
Class4 db 'ToolbarWindow32',0
I actually googled those phrases, and I found several forum references to them in various places,...but, one was a NET type, one was VB,..
BOMZ,...are you out there ???
I am talking about - why error in this string, I don't say anything what I am doing. Mozilla I signed to show that this icon realy exist and it's not antivirus.
NEXT:
; dec IconNumber
mov IconNumber, 0 ;Mozilla Firefox
;cmp IconNumber,0
;jnz NEXT
I don't understand that memory must be double readed
But, you are referring to the Windows desktop and not Internet Explorer ???
Yes. any IE
You see level of my English: "memory context" - this may be understood very different
System crashes, after 2 hour I hope for help
Yes,...I can see it is difficult for you. Well, thank God, you aren't trying to decipher my Russian,...because,...it would be alot worse.
So, my next question is: How can you be sure you have the correct Window handle for the running Internet Explorer instance ???
as I understand you right - for My process (application) I do this by HWND, for IE need ID of process with name iexplorere.exe
Quote
PopupProc PROTO :DWORD,:DWORD
EXTRADATA struct
Wnd dd ?
uID dd ?
EXTRADATA ends
............................................................
Class1 db 'Shell_TrayWnd',0
Class2 db 'TrayNotifyWnd',0 ; область уведомлений
Class3 db 'SysPager',0
Class4 db 'ToolbarWindow32',0
TOOLTIPS_CLASS db "tooltips_class32",0
...............................................
invoke PopupProc, MsgPopup, hWnd
...............................................
PopupProc proc PopupText:DWORD, HWnD:HWND
LOCAL rect:RECT
LOCAL toolinfo:TOOLINFO
LOCAL extra:EXTRADATA
LOCAL button:TBBUTTON
LOCAL rect1:RECT
LOCAL ToolbarHandle:HWND
LOCAL ProcId:DWORD
LOCAL hProcess:DWORD
LOCAL lpData:DWORD
LOCAL lpData1:DWORD
LOCAL IconNumber:DWORD
LOCAL ProcTrayId:DWORD
LOCAL ButtonID:DWORD
invoke FindWindow,addr Class1, NULL
test eax, eax
jz NoHandle
mov ToolbarHandle, eax
invoke FindWindowEx,eax,NULL,addr Class2, NULL
test eax, eax
jz NoHandle
mov ToolbarHandle, eax
invoke FindWindowEx,eax,NULL,addr Class3, NULL
test eax, eax
jz NoHandle
mov ToolbarHandle, eax
invoke FindWindowEx,eax,NULL,addr Class4, NULL
test eax, eax
jz NoHandle
mov ToolbarHandle, eax
invoke SendMessage,ToolbarHandle,TB_BUTTONCOUNT,0,0
test eax, eax
jz NoHandle
mov IconNumber, eax
invoke GetWindowThreadProcessId,ToolbarHandle,addr ProcId
test eax, eax
jz NoHandle
invoke OpenProcess,PROCESS_ALL_ACCESS,FALSE,ProcId
test eax, eax
jz NoHandle
mov hProcess,eax
invoke VirtualAllocEx,hProcess,NULL,sizeof button,MEM_COMMIT,PAGE_READWRITE
test eax, eax
jz NoMemory
mov lpData, eax
invoke VirtualAllocEx,hProcess,NULL,sizeof rect1,MEM_COMMIT,PAGE_READWRITE
test eax, eax
jz NoMemory1
mov lpData1, eax
NEXT:
dec IconNumber
invoke SendMessage,ToolbarHandle,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
mov eax, extra.Wnd
cmp eax, HWnD
je found10
cmp IconNumber,0
jnz NEXT
jmp NoFound
found10:
invoke SendMessage,ToolbarHandle,TB_GETRECT, button.idCommand, lpData1
invoke ReadProcessMemory, hProcess, lpData1,addr rect1, sizeof rect1, addr bytesRead
NoFound:
invoke VirtualFreeEx,ProcId,lpData1,0,MEM_RELEASE
NoMemory1:
invoke VirtualFreeEx,ProcId,lpData,0,MEM_RELEASE
NoMemory:
invoke CloseHandle,ProcId
NoHandle:
invoke GetWindowRect, ToolbarHandle,addr rect
mov eax, rect1.top
inc eax
add rect.top, eax
mov eax, rect1.left
inc eax
add rect.left, eax
invoke sndPlaySound, addr SoundPopup, SND_SYNC
invoke WindowFromPoint,rect.right,rect.top
push eax
invoke CreateWindowEx,WS_EX_TOPMOST,ADDR TOOLTIPS_CLASS,NULL,\
TTS_ALWAYSTIP or TTS_BALLOON,CW_USEDEFAULT, CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,HWnD,NULL,hInstance,NULL
mov hToolTips,eax
mov toolinfo.cbSize,sizeof TOOLINFO
mov toolinfo.uFlags,TTF_IDISHWND or TTF_TRACK
mov toolinfo.hWnd,NULL
pop toolinfo.uId
mov toolinfo.hInst,NULL
push PopupText
pop toolinfo.lpszText
invoke SendMessage,hToolTips,TTM_ADDTOOL,0,addr toolinfo
invoke SendMessage,hToolTips,TTM_SETMAXTIPWIDTH,0,500
invoke SendMessage,hToolTips,TTM_SETTITLE,1,addr ToolTipsCaption
mov ecx,rect.top
shl ecx,10h
mov eax,rect.left
or ecx,eax
invoke SendMessage,hToolTips,TTM_TRACKPOSITION,0,ecx
invoke SendMessage,hToolTips,TTM_TRACKACTIVATE,TRUE,addr toolinfo
ret
PopupProc endp
...Ah,...you are testing for a valid handle now,...much better. Does it work?
The reason I ask that question is that, the HWND you obtain from FindWindowEx can only be used by that process.
invoke GetWindowThreadProcessId,extra.Wnd,IEID
Yes it work OK.
Ok,...well, then, I must be confusing you at this point.
You run this app with Administrative Privileges ???
yes administrator - my computer
invoke RtlAdjustPrivilege,13h,1h,0h,esp - ??????????????? need
first create USER - not administrator on my PC. my application absolutly not working. (http://smiles.kolobok.us/standart/black_eye.gif)
as for determine tray icon position - this work OK
PS problem was with access to file from old adminidtrator USER directory . all work OK. (http://smiles.kolobok.us/standart/dance2.gif)
Are there any legitimate reasons for making a tooltip/balloon/notification appear as though it came from a program other than your own?
The only ones I can think of involve a trojan spoofing information to the effect of "fake update available, click here to download and install your new malware" or similar.
Tray Icon - this is button of explorer, other application
hey Bomz
I found This i Hope it help
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; FileName: TrayIcon.asm
; Function: Demo the way to enum the icons in system tray
; Author: Purple Endurer | 紫郢剑侠㊣ (PurpleEndurer@163.com)
; DevEnv: Win2000 pro SP4, MASM32 v8
;
; log
; ----------------------------------------------------------------------------------
; 2007-09-29 Can run under Win XP
; 2007-09-22 Created!
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
GetSysTrayToolBarHandle proto
EnumSubCtl proto :HWND, :LPARAM
GetSysTrayIconCount proto
EnumSysTrayIcon proto
.data
g_szAppName db "EnumSysTrayIcon", 0
g_szTaskBarCls db "Shell_TrayWnd", 0
g_szSysPagerCls db "SysPager", 0 ;WinXP need!
g_szTrayNotifyWndCls db "TrayNotifyWnd", 0
g_szToolbarWindow32Cls db "ToolbarWindow32", 0
g_szFailGetSysTray db "Fail to get system tray!", 0
g_hSysTray HANDLE ?
g_dwTrayIconCount dword ?
g_stTbButton TBBUTTON <>
g_szIconText db MAX_PATH dup (?)
.code
start:
invoke GetSysTrayToolBarHandle
test eax, eax ; .if eax==NULL
.if ZERO?
invoke MessageBox, NULL, addr g_szFailGetSysTray, addr g_szAppName, MB_ICONERROR
.else
mov g_hSysTray, eax
invoke EnumSysTrayIcon
.endif
invoke ExitProcess,NULL
;////////////////////////////////////////////////////////////////////////////////
; Function: Get the handle ToolbarWindow32 of in system tray
; Shell_TrayWnd -> TrayNotifyWnd -> (WinXP:SysPager) -> ToolbarWindow32
; Onput: if fail eax=NULL, else eax = handle
;/////////////////////////////////////////////////////////////////////////////////
GetSysTrayToolBarHandle proc
;--- Get the handle of task bar
invoke FindWindow, addr g_szTaskBarCls, NULL
cmp eax, NULL
je @GetSysTrayToolBarHandleRet ; fail
; HWND FindWindowEx(
; HWND hwndParent, // handle to parent window
; HWND hwndChildAfter, // handle to a child window
; LPCTSTR lpszClass, // pointer to class name
; LPCTSTR lpszWindow // pointer to window name
; );
;--- Get the handle of TrayNotifyWnd in task bar
invoke FindWindowEx, eax, NULL, addr g_szTrayNotifyWndCls, NULL
cmp eax, NULL
je @GetSysTrayToolBarHandleRet
;--- (WinXP Only) Get the handle of g_szSysPager in TrayNotifyWnd
push eax
invoke FindWindowEx, eax, NULL, addr g_szSysPagerCls, NULL
.if (eax==NULL)
pop eax
.else
pop edi
.endif
;--- Get the handle of ToolbarWindow32 in TrayNotifyWnd
invoke FindWindowEx, eax, NULL, addr g_szToolbarWindow32Cls, NULL
@GetSysTrayToolBarHandleRet:
ret
GetSysTrayToolBarHandle endp
;/////////////////////////////////////////////////////////////////////////////////
; Function: Enum the Child window in task bar
;/////////////////////////////////////////////////////////////////////////////////
EnumSubCtl proc proc hWnd: HWND, lParam: LPARAM
invoke GetClassName, hWnd, addr g_szIconText, sizeof g_szIconText
invoke MessageBox, NULL, addr g_szIconText, addr g_szIconText, MB_OK
mov eax, TRUE
ret
EnumSubCtl endp
;/////////////////////////////////////////////////////////////////////////////////
; Function: Get the count of icon in system tray
;/////////////////////////////////////////////////////////////////////////////////
GetSysTrayIconCount proc
invoke SendMessage,g_hSysTray, TB_BUTTONCOUNT, 0, 0
mov g_dwTrayIconCount, eax
ret
GetSysTrayIconCount endp
;///////////////////////////////////////////////////////////////////////
; Function: Enum the icon in system tray
;///////////////////////////////////////////////////////////////////////
EnumSysTrayIcon proc
local dwProcID, dwReaded: dword
local hProcess: HANDLE
local pMem: dword
invoke GetSysTrayIconCount
invoke GetWindowThreadProcessId, g_hSysTray, addr dwProcID
invoke OpenProcess, PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE, FALSE, dwProcID
mov hProcess, eax
invoke VirtualAllocEx, hProcess, NULL, 1024, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE
mov pMem, eax
xor eax, eax
.while (eax < g_dwTrayIconCount)
push eax
invoke SendMessage, g_hSysTray, TB_GETBUTTON, eax, pMem
invoke ReadProcessMemory, hProcess, pMem, addr g_stTbButton, sizeof g_stTbButton, addr dwReaded
invoke SendMessage, g_hSysTray, TB_GETBUTTONTEXT, g_stTbButton.idCommand, pMem
inc eax ; If fail, the return value is -1
jz @F ; Fail, skip
invoke ReadProcessMemory, hProcess, pMem, addr g_szIconText, sizeof g_szIconText, addr dwReaded
invoke MessageBox, NULL, addr g_szIconText, addr g_szAppName, NULL
@@:
pop eax
inc eax
.endw
invoke VirtualFreeEx, hProcess, pMem, 0, MEM_RELEASE
invoke CloseHandle, hProcess
ret
EnumSysTrayIcon endp
end start
Thanks, the example or code much effectively for understanding, than Microsoft English
I have this found by search Toolbar examples for my project :8)
I have not read all your post of this Thread, i hope you want an example to get the tray icon text
Need you an other example for manipulate the icons tell me i have found a good c++ tutorial
Greets,
(http://s60.radikal.ru/i167/1105/e7/746ca23b1c9e.gif)
...I've got to learn Russian,..
May be somebody know - ToolBar, Tray, TrayIcon handles may changes only if explorer reboot? or something else?