ReactOS 0.4.16-dev-1214-gd663eb4
appbar.c File Reference
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <shellapi.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <undocshell.h>
#include <wine/debug.h>
#include <wine/unicode.h>
Include dependency graph for appbar.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (appbar)
 
static HANDLE AppBar_CopyIn (_In_ const VOID *pvSrc, _In_ SIZE_T dwSize, _In_ DWORD dwProcessId)
 
static BOOL AppBar_CopyOut (_In_ HANDLE hOutput, _Out_ PVOID pvDest, _In_ SIZE_T cbDest, _In_ DWORD dwProcessId)
 
UINT_PTR WINAPI SHAppBarMessage (_In_ DWORD dwMessage, _Inout_ PAPPBARDATA pData)
 

Function Documentation

◆ AppBar_CopyIn()

static HANDLE AppBar_CopyIn ( _In_ const VOID pvSrc,
_In_ SIZE_T  dwSize,
_In_ DWORD  dwProcessId 
)
static

Definition at line 23 of file appbar.c.

27{
28 HANDLE hMem = SHAllocShared(NULL, dwSize, dwProcessId);
29 if (!hMem)
30 return 0;
31
32 PVOID pvDest = SHLockShared(hMem, dwProcessId);
33 if (!pvDest)
34 {
35 SHFreeShared(hMem, dwProcessId);
36 return 0;
37 }
38
39 CopyMemory(pvDest, pvSrc, dwSize);
40 SHUnlockShared(pvDest);
41 return hMem;
42}
#define NULL
Definition: types.h:112
HANDLE WINAPI SHAllocShared(LPCVOID lpvData, DWORD dwSize, DWORD dwProcId)
Definition: ordinal.c:169
PVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
Definition: ordinal.c:259
BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
Definition: ordinal.c:315
BOOL WINAPI SHUnlockShared(LPVOID lpView)
Definition: ordinal.c:295
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define CopyMemory
Definition: winbase.h:1751

Referenced by SHAppBarMessage().

◆ AppBar_CopyOut()

static BOOL AppBar_CopyOut ( _In_ HANDLE  hOutput,
_Out_ PVOID  pvDest,
_In_ SIZE_T  cbDest,
_In_ DWORD  dwProcessId 
)
static

Definition at line 45 of file appbar.c.

50{
51 PVOID pvSrc = SHLockShared(hOutput, dwProcessId);
52 if (pvSrc)
53 {
54 CopyMemory(pvDest, pvSrc, cbDest);
55 SHUnlockShared(pvSrc);
56 }
57
58 SHFreeShared(hOutput, dwProcessId);
59 return pvSrc != NULL;
60}

Referenced by SHAppBarMessage().

◆ SHAppBarMessage()

UINT_PTR WINAPI SHAppBarMessage ( _In_ DWORD  dwMessage,
_Inout_ PAPPBARDATA  pData 
)

Definition at line 67 of file appbar.c.

70{
71 TRACE("dwMessage=%d, pData={cb=%d, hwnd=%p}\n", dwMessage, pData->cbSize, pData->hWnd);
72
73 HWND hTrayWnd = FindWindowW(L"Shell_TrayWnd", NULL);
74 if (!hTrayWnd || pData->cbSize > sizeof(*pData))
75 {
76 WARN("%p, %d\n", hTrayWnd, pData->cbSize);
77 return FALSE;
78 }
79
81 cmd.abd.cbSize = sizeof(cmd.abd);
82 cmd.abd.hWnd32 = HandleToUlong(pData->hWnd); // Truncated on x64, as on Windows!
83 cmd.abd.uCallbackMessage = pData->uCallbackMessage;
84 cmd.abd.uEdge = pData->uEdge;
85 cmd.abd.rc = pData->rc;
86 cmd.abd.lParam64 = pData->lParam;
87 cmd.dwMessage = dwMessage;
88 cmd.hOutput = (APPBAR_OUTPUT)NULL;
89 cmd.dwProcessId = GetCurrentProcessId();
90
91 /* Make output data if necessary */
92 switch (dwMessage)
93 {
94 case ABM_QUERYPOS:
95 case ABM_SETPOS:
97 cmd.hOutput = (APPBAR_OUTPUT)AppBar_CopyIn(&cmd.abd, sizeof(cmd.abd), cmd.dwProcessId);
98 if (!cmd.hOutput)
99 {
100 ERR("AppBar_CopyIn: %d\n", dwMessage);
101 return FALSE;
102 }
103 break;
104 default:
105 break;
106 }
107
108 /* Send WM_COPYDATA message */
109 COPYDATASTRUCT copyData = { TABDMC_APPBAR, sizeof(cmd), &cmd };
110 UINT_PTR ret = SendMessageW(hTrayWnd, WM_COPYDATA, (WPARAM)pData->hWnd, (LPARAM)&copyData);
111
112 /* Copy back output data */
113 if (cmd.hOutput)
114 {
115 if (!AppBar_CopyOut((HANDLE)cmd.hOutput, &cmd.abd, sizeof(cmd.abd), cmd.dwProcessId))
116 {
117 ERR("AppBar_CopyOut: %d\n", dwMessage);
118 return FALSE;
119 }
120 pData->hWnd = UlongToHandle(cmd.abd.hWnd32);
121 pData->uCallbackMessage = cmd.abd.uCallbackMessage;
122 pData->uEdge = cmd.abd.uEdge;
123 pData->rc = cmd.abd.rc;
124 pData->lParam = (LPARAM)cmd.abd.lParam64;
125 }
126
127 return ret;
128}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define HandleToUlong(h)
Definition: basetsd.h:79
#define FALSE
Definition: types.h:117
static HANDLE AppBar_CopyIn(_In_ const VOID *pvSrc, _In_ SIZE_T dwSize, _In_ DWORD dwProcessId)
Definition: appbar.c:23
static BOOL AppBar_CopyOut(_In_ HANDLE hOutput, _Out_ PVOID pvDest, _In_ SIZE_T cbDest, _In_ DWORD dwProcessId)
Definition: appbar.c:45
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define L(x)
Definition: ntvdm.h:50
#define ABM_GETTASKBARPOS
Definition: shellapi.h:66
#define ABM_SETPOS
Definition: shellapi.h:64
#define ABM_QUERYPOS
Definition: shellapi.h:63
#define TRACE(s)
Definition: solgame.cpp:4
Definition: ftp_var.h:139
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
HANDLE APPBAR_OUTPUT
Definition: undocshell.h:1248
#define TABDMC_APPBAR
Definition: undocshell.h:953
int ret
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_COPYDATA
Definition: winuser.h:1683
HWND WINAPI FindWindowW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by Window::AppBar_AutoHide(), Window::AppBar_NoAutoHide(), Window::AppBar_QueryPos(), Window::AppBar_QuerySetPos(), Window::AppBar_Register(), Window::AppBar_UnRegister(), DoAppBarStuff(), Window::OnActivate(), Window::OnWindowPosChanged(), test_appbarget(), test_setpos(), and testwindow_setpos().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( appbar  )