* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "precomp.h"
+#include "config.h"
+#include "wine/port.h"
+#include <stdarg.h>
#include <stdio.h>
-
-#include <winver.h>
-#include <winnetwk.h>
-#include <mmsystem.h>
-#include <shdeprecated.h>
-#include <shellapi.h>
-#include <commdlg.h>
-#include <mlang.h>
-#include <mshtmhst.h>
+#include <string.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winnls.h"
+#include "winreg.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winver.h"
+#include "winnetwk.h"
+#include "mmsystem.h"
+#include "objbase.h"
+#include "exdisp.h"
+#include "shdeprecated.h"
+#include "shlobj.h"
+#include "shlwapi.h"
+#include "shellapi.h"
+#include "commdlg.h"
+#include "mlang.h"
+#include "mshtmhst.h"
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+
+WINE_DEFAULT_DEBUG_CHANNEL(shell);
/* DLL handles for late bound calls */
extern HINSTANCE shlwapi_hInstance;
*/
/*************************************************************************
- * SHLWAPI_DupSharedHandle
+ * @ [SHLWAPI.11]
+ *
+ * Copy a sharable memory handle from one process to another.
+ *
+ * PARAMS
+ * hShared [I] Shared memory handle to duplicate
+ * dwSrcProcId [I] ID of the process owning hShared
+ * dwDstProcId [I] ID of the process wanting the duplicated handle
+ * dwAccess [I] Desired DuplicateHandle() access
+ * dwOptions [I] Desired DuplicateHandle() options
+ *
+ * RETURNS
+ * Success: A handle suitable for use by the dwDstProcId process.
+ * Failure: A NULL handle.
*
- * Internal implementation of SHLWAPI_11.
*/
-static HANDLE SHLWAPI_DupSharedHandle(HANDLE hShared, DWORD dwDstProcId,
- DWORD dwSrcProcId, DWORD dwAccess,
- DWORD dwOptions)
+HANDLE WINAPI SHMapHandle(HANDLE hShared, DWORD dwSrcProcId, DWORD dwDstProcId,
+ DWORD dwAccess, DWORD dwOptions)
{
HANDLE hDst, hSrc;
DWORD dwMyProcId = GetCurrentProcessId();
TRACE("(%p,%d,%d,%08x,%08x)\n", hShared, dwDstProcId, dwSrcProcId,
dwAccess, dwOptions);
+ if (!hShared)
+ {
+ TRACE("Returning handle NULL\n");
+ return NULL;
+ }
+
/* Get dest process handle */
if (dwDstProcId == dwMyProcId)
hDst = GetCurrentProcess();
if (hSrc)
{
/* Make handle available to dest process */
- if (!DuplicateHandle(hDst, hShared, hSrc, &hRet,
+ if (!DuplicateHandle(hSrc, hShared, hDst, &hRet,
dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
hRet = NULL;
/* Release view. All further views mapped will be opaque */
UnmapViewOfFile(pMapped);
- hRet = SHLWAPI_DupSharedHandle(hMap, dwProcId,
- GetCurrentProcessId(), FILE_MAP_ALL_ACCESS,
- DUPLICATE_SAME_ACCESS);
+ hRet = SHMapHandle(hMap, GetCurrentProcessId(), dwProcId,
+ FILE_MAP_ALL_ACCESS, DUPLICATE_SAME_ACCESS);
}
CloseHandle(hMap);
TRACE("(%p %d)\n", hShared, dwProcId);
/* Get handle to shared memory for current process */
- hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
- FILE_MAP_ALL_ACCESS, 0);
+ hDup = SHMapHandle(hShared, dwProcId, GetCurrentProcessId(), FILE_MAP_ALL_ACCESS, 0);
+
/* Get View */
pMapped = MapViewOfFile(hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
CloseHandle(hDup);
TRACE("(%p %d)\n", hShared, dwProcId);
+ if (!hShared)
+ return TRUE;
+
/* Get a copy of the handle for our process, closing the source handle */
- hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
- FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
+ hClose = SHMapHandle(hShared, dwProcId, GetCurrentProcessId(),
+ FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
/* Close local copy */
return CloseHandle(hClose);
}
-/*************************************************************************
- * @ [SHLWAPI.11]
- *
- * Copy a sharable memory handle from one process to another.
- *
- * PARAMS
- * hShared [I] Shared memory handle to duplicate
- * dwDstProcId [I] ID of the process wanting the duplicated handle
- * dwSrcProcId [I] ID of the process owning hShared
- * dwAccess [I] Desired DuplicateHandle() access
- * dwOptions [I] Desired DuplicateHandle() options
- *
- * RETURNS
- * Success: A handle suitable for use by the dwDstProcId process.
- * Failure: A NULL handle.
- *
- */
-HANDLE WINAPI SHMapHandle(HANDLE hShared, DWORD dwDstProcId, DWORD dwSrcProcId,
- DWORD dwAccess, DWORD dwOptions)
-{
- HANDLE hRet;
-
- hRet = SHLWAPI_DupSharedHandle(hShared, dwDstProcId, dwSrcProcId,
- dwAccess, dwOptions);
- return hRet;
-}
-
/*************************************************************************
* @ [SHLWAPI.13]
*
* Success: S_OK. langbuf is set to the language string found.
* Failure: E_FAIL, If any arguments are invalid, error occurred, or Explorer
* does not contain the setting.
- * HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), If the buffer is not big enough
+ * E_NOT_SUFFICIENT_BUFFER, If the buffer is not big enough
*/
HRESULT WINAPI GetAcceptLanguagesW( LPWSTR langbuf, LPDWORD buflen)
{
}
*buflen = 0;
- return __HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+ return E_NOT_SUFFICIENT_BUFFER;
}
/*************************************************************************
*
* PARAMS
* lpUnknown [I] Object supporting the IPersist interface
- * lpClassId [O] Destination for Class Id
+ * clsid [O] Destination for Class Id
*
* RETURNS
* Success: S_OK. lpClassId contains the Class Id requested.
* E_NOINTERFACE If lpUnknown does not support IPersist,
* Or an HRESULT error code.
*/
-HRESULT WINAPI IUnknown_GetClassID(IUnknown *lpUnknown, CLSID* lpClassId)
+HRESULT WINAPI IUnknown_GetClassID(IUnknown *lpUnknown, CLSID *clsid)
{
- IPersist* lpPersist;
- HRESULT hRet = E_FAIL;
+ IPersist *persist;
+ HRESULT hr;
- TRACE("(%p,%s)\n", lpUnknown, debugstr_guid(lpClassId));
+ TRACE("(%p, %p)\n", lpUnknown, clsid);
- if (lpUnknown)
- {
- hRet = IUnknown_QueryInterface(lpUnknown,&IID_IPersist,(void**)&lpPersist);
- if (SUCCEEDED(hRet))
+ if (!lpUnknown)
+ {
+ memset(clsid, 0, sizeof(*clsid));
+ return E_FAIL;
+ }
+
+ hr = IUnknown_QueryInterface(lpUnknown, &IID_IPersist, (void**)&persist);
+ if (hr != S_OK)
{
- IPersist_GetClassID(lpPersist, lpClassId);
- IPersist_Release(lpPersist);
+ hr = IUnknown_QueryInterface(lpUnknown, &IID_IPersistFolder, (void**)&persist);
+ if (hr != S_OK)
+ return hr;
}
- }
- return hRet;
+
+ hr = IPersist_GetClassID(persist, clsid);
+ IPersist_Release(persist);
+ return hr;
}
/*************************************************************************
* Success: The window handle of the newly created window.
* Failure: 0.
*/
-HWND WINAPI SHCreateWorkerWindowA(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
+HWND WINAPI SHCreateWorkerWindowA(WNDPROC wndProc, HWND hWndParent, DWORD dwExStyle,
DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra)
{
static const char szClass[] = "WorkerA";
WNDCLASSA wc;
HWND hWnd;
- TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08lx)\n",
+ TRACE("(%p, %p, 0x%08x, 0x%08x, %p, 0x%08lx)\n",
wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
/* Create Window class */
if (hWnd)
{
SetWindowLongPtrW(hWnd, 0, wnd_extra);
-
- if (wndProc) SetWindowLongPtrA(hWnd, GWLP_WNDPROC, wndProc);
+ if (wndProc) SetWindowLongPtrA(hWnd, GWLP_WNDPROC, (LONG_PTR)wndProc);
}
return hWnd;
*
* Unicode version of SHCreateWorkerWindowA.
*/
-HWND WINAPI SHCreateWorkerWindowW(LONG wndProc, HWND hWndParent, DWORD dwExStyle,
- DWORD dwStyle, HMENU hMenu, LONG msg_result)
+HWND WINAPI SHCreateWorkerWindowW(WNDPROC wndProc, HWND hWndParent, DWORD dwExStyle,
+ DWORD dwStyle, HMENU hMenu, LONG_PTR wnd_extra)
{
static const WCHAR szClass[] = { 'W', 'o', 'r', 'k', 'e', 'r', 'W', 0 };
WNDCLASSW wc;
HWND hWnd;
- TRACE("(0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x)\n",
- wndProc, hWndParent, dwExStyle, dwStyle, hMenu, msg_result);
+ TRACE("(%p, %p, 0x%08x, 0x%08x, %p, 0x%08lx)\n",
+ wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
/* If our OS is natively ANSI, use the ANSI version */
if (GetVersion() & 0x80000000) /* not NT */
{
TRACE("fallback to ANSI, ver 0x%08x\n", GetVersion());
- return SHCreateWorkerWindowA(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, msg_result);
+ return SHCreateWorkerWindowA(wndProc, hWndParent, dwExStyle, dwStyle, hMenu, wnd_extra);
}
/* Create Window class */
wc.style = 0;
wc.lpfnWndProc = DefWindowProcW;
wc.cbClsExtra = 0;
- wc.cbWndExtra = 4;
+ wc.cbWndExtra = sizeof(LONG_PTR);
wc.hInstance = shlwapi_hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
hWndParent, hMenu, shlwapi_hInstance, 0);
if (hWnd)
{
- SetWindowLongPtrW(hWnd, DWLP_MSGRESULT, msg_result);
-
- if (wndProc) SetWindowLongPtrW(hWnd, GWLP_WNDPROC, wndProc);
+ SetWindowLongPtrW(hWnd, 0, wnd_extra);
+ if (wndProc) SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)wndProc);
}
return hWnd;
cmIci.cbSize = sizeof(cmIci);
cmIci.fMask = CMIC_MASK_ASYNCOK;
cmIci.hwnd = hWnd;
+#ifdef __REACTOS__ /* r75561 */
+ cmIci.lpVerb = MAKEINTRESOURCEA(dwCommandId - 1);
+#else
cmIci.lpVerb = MAKEINTRESOURCEA(dwCommandId);
+#endif
cmIci.nShow = SW_SHOWNORMAL;
hRet = IContextMenu_InvokeCommand(iContext, &cmIci);
case OS_SMALLBUSINESSSERVER:
ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT)
case OS_TABLETPC:
- FIXME("(OS_TABLEPC) What should we return here?\n");
+ FIXME("(OS_TABLETPC) What should we return here?\n");
return FALSE;
case OS_SERVERADMINUI:
FIXME("(OS_SERVERADMINUI) What should we return here?\n");
* NOTES
* Call should free returned descriptor with LocalFree
*/
-PSECURITY_DESCRIPTOR WINAPI GetShellSecurityDescriptor(PSHELL_USER_PERMISSION *apUserPerm, int cUserPerm)
+PSECURITY_DESCRIPTOR WINAPI GetShellSecurityDescriptor(const PSHELL_USER_PERMISSION *apUserPerm, int cUserPerm)
{
PSID *sidlist;
PSID cur_user = NULL;
{
if ((fmt_flags & FDTF_LONGDATE) && (ret < size + 2))
{
- if (ret < size + 2)
- {
- lstrcatW(&buf[ret-1], sep1);
- ret += 2;
- }
+ lstrcatW(&buf[ret-1], sep1);
+ ret += 2;
}
else
{
* pValue: address to receive the property value as a 32-bit signed integer
*
* RETURNS
- * 0 for Success
+ * HRESULT codes
*/
-BOOL WINAPI SHPropertyBag_ReadLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LPLONG pValue)
+HRESULT WINAPI SHPropertyBag_ReadLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LPLONG pValue)
{
VARIANT var;
HRESULT hr;
return hr;
}
+#ifdef __REACTOS__
+/**************************************************************************
+ * SHPropertyBag_WriteLONG (SHLWAPI.497)
+ *
+ * This function asks a property bag to write a named property as a LONG.
+ *
+ * PARAMS
+ * ppb: a IPropertyBag interface
+ * pszPropName: Unicode string that names the property
+ * lValue: address to receive the property value as a 32-bit signed integer
+ *
+ * RETURNS
+ * HRESULT codes
+ */
+HRESULT WINAPI SHPropertyBag_WriteLONG(IPropertyBag *ppb, LPCWSTR pszPropName, LONG lValue)
+{
+ UNIMPLEMENTED;
+ return E_NOTIMPL;
+}
+
+/**************************************************************************
+ * SHPropertyBag_WriteStr (SHLWAPI.495)
+ *
+ * This function asks a property bag to write a string as the value of a named property.
+ *
+ * PARAMS
+ * ppb: a IPropertyBag interface
+ * pszPropName: Unicode string that names the property
+ * pValue: address to write the property value
+ *
+ * RETURNS
+ * HRESULT codes
+ */
+HRESULT WINAPI SHPropertyBag_WriteStr(IPropertyBag *ppb, LPCWSTR pszPropName, LPCWSTR pszValue)
+{
+ UNIMPLEMENTED;
+ return E_NOTIMPL;
+}
+#endif
+
/* return flags for SHGetObjectCompatFlags, names derived from registry value names */
#define OBJCOMPAT_OTNEEDSSFCACHE 0x00000001
#define OBJCOMPAT_NO_WEBVIEW 0x00000002