[HEADERS] Move some helpers from undocshell.h to shellutils.h as they didn't cover anything undocumented. Merge traycmd.h in undocshell.h as both contain just undocumented shell definitions.

This commit is contained in:
Ioannis Adamopoulos 2019-08-25 12:17:42 +03:00
parent 121f0a5c50
commit e419195d37
14 changed files with 165 additions and 218 deletions

View file

@ -21,7 +21,6 @@
#include "precomp.h"
#include <commoncontrols.h>
#include <traycmd.h>
HRESULT TrayWindowCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu);

View file

@ -82,36 +82,6 @@ struct CCoInit
HRESULT hres;
};
EXTERN_C
inline ULONG
Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
{
char Buffer[512];
char* Current = Buffer;
size_t Length = _countof(Buffer);
const char* fname = strrchr(filename, '\\');
if (fname == NULL)
{
fname = strrchr(filename, '/');
if (fname != NULL)
fname++;
}
else
fname++;
if (fname == NULL)
fname = filename;
StringCchPrintfExA(Current, Length, &Current, &Length, STRSAFE_NULL_ON_FAILURE, "%s:%d: ", fname, line);
va_list ArgList;
va_start(ArgList, lpFormat);
StringCchVPrintfExA(Current, Length, &Current, &Length, STRSAFE_NULL_ON_FAILURE, lpFormat, ArgList);
va_end(ArgList);
OutputDebugStringA(Buffer);
return 0;
}
EXTERN_C
BOOL WINAPI GetExeFromLnk(PCWSTR pszLnk, PWSTR pszExe, size_t cchSize)
{

View file

@ -37,7 +37,6 @@ EXTERN_C const GUID CLSID_ZipFolderExtractAllCommand;
extern LONG g_ModuleRefCnt;
#define Win32DbgPrint(file, line, warn, func) DbgPrint("(%s:%d) " warn, file, line, func)
WCHAR* guid2string(REFCLSID iid);

View file

@ -8,7 +8,6 @@
#include "precomp.h"
#include "winsvc.h"
#include <traycmd.h> // tray commands
WINE_DEFAULT_DEBUG_CHANNEL(shell);

View file

@ -17,6 +17,7 @@
// Yes, gcc at it again, let's validate everything found inside unused templates!
ULONG DbgPrint(PCH Format,...);
#include <stdio.h>
#include <shellutils.h>
#include <shlwapi.h>
#include <strsafe.h>

View file

@ -9,6 +9,7 @@
#define NDEBUG
#include <debug.h>
#include <stdio.h>
#include <shellutils.h>
LPITEMIDLIST _CreateDummyPidl()

View file

@ -9,6 +9,7 @@
#define NDEBUG
#include <debug.h>
#include <stdio.h>
#include <shellutils.h>
#define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)

View file

@ -9,6 +9,7 @@
#include "shelltest.h"
#include <ndk/rtlfuncs.h>
#include <stdio.h>
#include <shellutils.h>
// We would normally use S_LESSTHAN and S_GREATERTHAN, but w2k3 returns numbers like 3 and -3...

View file

@ -9,6 +9,7 @@
#define NDEBUG
#include <debug.h>
#include <stdio.h>
#include <shellutils.h>
/* Test IShellLink::SetPath with environment-variables, existing, non-existing, ...*/

View file

@ -9,8 +9,7 @@
#include <wincon.h>
#include <wingdi.h>
ULONG DbgPrint(PCH Format,...);
#include <stdio.h>
#include <shellutils.h>
HRESULT (STDAPICALLTYPE *pSHCreateFileExtractIconW)(LPCWSTR pszFile, DWORD dwFileAttributes, REFIID riid, void **ppv);

View file

@ -8,6 +8,7 @@
#define NDEBUG
#include <debug.h>
#include <stdio.h>
#include <shellutils.h>
#include <strsafe.h>

View file

@ -23,6 +23,42 @@
extern "C" {
#endif /* defined(__cplusplus) */
static inline ULONG
Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
{
char szMsg[512];
char *szMsgStart;
const char *fname;
va_list vl;
ULONG uRet;
fname = strrchr(filename, '\\');
if (fname == NULL)
{
fname = strrchr(filename, '/');
if (fname != NULL)
fname++;
}
else
fname++;
if (fname == NULL)
fname = filename;
szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
va_start(vl, lpFormat);
uRet = (ULONG) vsprintf(szMsgStart, lpFormat, vl);
va_end(vl);
OutputDebugStringA(szMsg);
return uRet;
}
#define DbgPrint(fmt, ...) \
Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#ifdef __cplusplus
# define IID_PPV_ARG(Itype, ppType) IID_##Itype, reinterpret_cast<void**>((static_cast<Itype**>(ppType)))
# define IID_NULL_PPV_ARG(Itype, ppType) IID_##Itype, NULL, reinterpret_cast<void**>((static_cast<Itype**>(ppType)))
@ -372,6 +408,103 @@ HRESULT inline SHSetStrRet(LPSTRRET pStrRet, HINSTANCE hInstance, DWORD resId)
return SHSetStrRet(pStrRet, Buffer);
}
static inline void DbgDumpMenuInternal(HMENU hmenu, char* padding, int padlevel)
{
WCHAR label[128];
int i;
int count = GetMenuItemCount(hmenu);
padding[padlevel] = '.';
padding[padlevel + 1] = '.';
padding[padlevel + 2] = 0;
for (i = 0; i < count; i++)
{
MENUITEMINFOW mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU | MIIM_STATE | MIIM_ID;
mii.dwTypeData = label;
mii.cch = _countof(label);
GetMenuItemInfoW(hmenu, i, TRUE, &mii);
if (mii.fType & MFT_BITMAP)
DbgPrint("%s%2d - %08x: BITMAP %08p (state=%d, has submenu=%s)\n", padding, i, mii.wID, mii.hbmpItem, mii.fState, mii.hSubMenu ? "TRUE" : "FALSE");
else if (mii.fType & MFT_SEPARATOR)
DbgPrint("%s%2d - %08x ---SEPARATOR---\n", padding, i, mii.wID);
else
DbgPrint("%s%2d - %08x: %S (state=%d, has submenu=%s)\n", padding, i, mii.wID, mii.dwTypeData, mii.fState, mii.hSubMenu ? "TRUE" : "FALSE");
if (mii.hSubMenu)
DbgDumpMenuInternal(mii.hSubMenu, padding, padlevel + 2);
}
padding[padlevel] = 0;
}
static __inline void DbgDumpMenu(HMENU hmenu)
{
char padding[128];
DbgDumpMenuInternal(hmenu, padding, 0);
}
static inline
void DumpIdList(LPCITEMIDLIST pcidl)
{
DbgPrint("Begin IDList Dump\n");
for (; pcidl != NULL; pcidl = ILGetNext(pcidl))
{
int i;
int cb = pcidl->mkid.cb;
BYTE * sh = (BYTE*) &(pcidl->mkid);
if (cb == 0) // ITEMIDLISTs are terminatedwith a null SHITEMID.
break;
DbgPrint("Begin SHITEMID (cb=%d)\n", cb);
if ((cb & 3) != 0)
DbgPrint(" - WARNING: cb is not a multiple of 4\n");
for (i = 0; (i + 4) <= cb; i += 4)
{
DbgPrint(" - abID[%08x]: %02x %02x %02x %02x\n",
i,
sh[i + 0],
sh[i + 1],
sh[i + 2],
sh[i + 3]);
}
if (i < cb)
{
cb -= i;
if (cb == 3)
{
DbgPrint(" - abID[%08x]: %02x %02x %02x --\n",
i,
sh[i + 0],
sh[i + 1],
sh[i + 2]);
}
else if (cb == 2)
{
DbgPrint(" - abID[%08x]: %02x %02x -- --\n",
i,
sh[i + 0],
sh[i + 1]);
}
else if (cb == 1)
{
DbgPrint(" - abID[%08x]: %02x -- -- --\n",
i,
sh[i + 0]);
}
}
DbgPrint("End SHITEMID\n");
}
DbgPrint("End IDList Dump.\n");
}
#endif /* __cplusplus */
#define S_LESSTHAN 0xffff

View file

@ -1,49 +0,0 @@
/*
* Tray Commands
*
* Copyright 2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*
* this library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* this library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TRAYCMD_H_
#define TRAYCMD_H_
/* TODO: Add more and implement them */
#define TRAYCMD_STARTMENU 305 /* Same as IDMA_START. */
#define TRAYCMD_RUN_DIALOG 401 /* Implemented. Same as IDM_RUN. */
#define TRAYCMD_LOGOFF_DIALOG 402 /* Implemented. Same as IDM_LOGOFF. */
#define TRAYCMD_CASCADE 403 /* */
#define TRAYCMD_TILE_H 404 /* */
#define TRAYCMD_TILE_V 405 /* */
#define TRAYCMD_TOGGLE_DESKTOP 407 /* Implemented. */
#define TRAYCMD_DATE_AND_TIME 408 /* Implemented. */
#define TRAYCMD_TASKBAR_PROPERTIES 413 /* Implemented. Same as IDM_TASKBARANDSTARTMENU. */
#define TRAYCMD_MINIMIZE_ALL 415 /* Implemented. */
#define TRAYCMD_RESTORE_ALL 416 /* Implemented. Same as IDMA_RESTORE_OPEN. */
#define TRAYCMD_SHOW_DESKTOP 419 /* Implemented. */
#define TRAYCMD_SHOW_TASK_MGR 420 /* Implemented. */
#define TRAYCMD_CUSTOMIZE_TASKBAR 421 /* */
#define TRAYCMD_LOCK_TASKBAR 424 /* Implemented. */
#define TRAYCMD_HELP_AND_SUPPORT 503 /* Implemented. Same as IDM_HELPANDSUPPORT. */
#define TRAYCMD_CONTROL_PANEL 505 /* Same as IDM_CONTROLPANEL. */
#define TRAYCMD_SHUTDOWN_DIALOG 506 /* Implemented. Same as IDM_SHUTDOWN. */
#define TRAYCMD_PRINTERS_AND_FAXES 510 /* Same as IDM_PRINTERSANDFAXES. */
#define TRAYCMD_LOCK_DESKTOP 517 /* */
#define TRAYCMD_SWITCH_USER_DIALOG 5000 /* */
#define TRAYCMD_SEARCH_FILES 41093 /* Implemented. Same as IDMA_SEARCH. */
#define TRAYCMD_SEARCH_COMPUTERS 41094 /* Implemented. */
#endif /* ndef TRAYCMD_H_ */

View file

@ -618,140 +618,6 @@ BOOL WINAPI GUIDFromStringW(
_Out_ LPGUID pguid
);
static inline ULONG
Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
{
char szMsg[512];
char *szMsgStart;
const char *fname;
va_list vl;
ULONG uRet;
fname = strrchr(filename, '\\');
if (fname == NULL)
{
fname = strrchr(filename, '/');
if (fname != NULL)
fname++;
}
else
fname++;
if (fname == NULL)
fname = filename;
szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
va_start(vl, lpFormat);
uRet = (ULONG) vsprintf(szMsgStart, lpFormat, vl);
va_end(vl);
OutputDebugStringA(szMsg);
return uRet;
}
#define DbgPrint(fmt, ...) \
Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
static inline void DbgDumpMenuInternal(HMENU hmenu, char* padding, int padlevel)
{
WCHAR label[128];
int i;
int count = GetMenuItemCount(hmenu);
padding[padlevel] = '.';
padding[padlevel + 1] = '.';
padding[padlevel + 2] = 0;
for (i = 0; i < count; i++)
{
MENUITEMINFOW mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU | MIIM_STATE | MIIM_ID;
mii.dwTypeData = label;
mii.cch = _countof(label);
GetMenuItemInfoW(hmenu, i, TRUE, &mii);
if (mii.fType & MFT_BITMAP)
DbgPrint("%s%2d - %08x: BITMAP %08p (state=%d, has submenu=%s)\n", padding, i, mii.wID, mii.hbmpItem, mii.fState, mii.hSubMenu ? "TRUE" : "FALSE");
else if (mii.fType & MFT_SEPARATOR)
DbgPrint("%s%2d - %08x ---SEPARATOR---\n", padding, i, mii.wID);
else
DbgPrint("%s%2d - %08x: %S (state=%d, has submenu=%s)\n", padding, i, mii.wID, mii.dwTypeData, mii.fState, mii.hSubMenu ? "TRUE" : "FALSE");
if (mii.hSubMenu)
DbgDumpMenuInternal(mii.hSubMenu, padding, padlevel + 2);
}
padding[padlevel] = 0;
}
static __inline void DbgDumpMenu(HMENU hmenu)
{
char padding[128];
DbgDumpMenuInternal(hmenu, padding, 0);
}
static inline
void DumpIdList(LPCITEMIDLIST pcidl)
{
DbgPrint("Begin IDList Dump\n");
for (; pcidl != NULL; pcidl = ILGetNext(pcidl))
{
int i;
int cb = pcidl->mkid.cb;
BYTE * sh = (BYTE*) &(pcidl->mkid);
if (cb == 0) // ITEMIDLISTs are terminatedwith a null SHITEMID.
break;
DbgPrint("Begin SHITEMID (cb=%d)\n", cb);
if ((cb & 3) != 0)
DbgPrint(" - WARNING: cb is not a multiple of 4\n");
for (i = 0; (i + 4) <= cb; i += 4)
{
DbgPrint(" - abID[%08x]: %02x %02x %02x %02x\n",
i,
sh[i + 0],
sh[i + 1],
sh[i + 2],
sh[i + 3]);
}
if (i < cb)
{
cb -= i;
if (cb == 3)
{
DbgPrint(" - abID[%08x]: %02x %02x %02x --\n",
i,
sh[i + 0],
sh[i + 1],
sh[i + 2]);
}
else if (cb == 2)
{
DbgPrint(" - abID[%08x]: %02x %02x -- --\n",
i,
sh[i + 0],
sh[i + 1]);
}
else if (cb == 1)
{
DbgPrint(" - abID[%08x]: %02x -- -- --\n",
i,
sh[i + 0]);
}
}
DbgPrint("End SHITEMID\n");
}
DbgPrint("End IDList Dump.\n");
}
/*****************************************************************************
* Shell32 resources
*/
@ -785,6 +651,31 @@ void DumpIdList(LPCITEMIDLIST pcidl)
#define SMSET_UNKNOWN08 0x08
#define SMSET_UNKNOWN10 0x10
// explorer tray commands
#define TRAYCMD_STARTMENU 305
#define TRAYCMD_RUN_DIALOG 401
#define TRAYCMD_LOGOFF_DIALOG 402
#define TRAYCMD_CASCADE 403
#define TRAYCMD_TILE_H 404
#define TRAYCMD_TILE_V 405
#define TRAYCMD_TOGGLE_DESKTOP 407
#define TRAYCMD_DATE_AND_TIME 408
#define TRAYCMD_TASKBAR_PROPERTIES 413
#define TRAYCMD_MINIMIZE_ALL 415
#define TRAYCMD_RESTORE_ALL 416
#define TRAYCMD_SHOW_DESKTOP 419
#define TRAYCMD_SHOW_TASK_MGR 420
#define TRAYCMD_CUSTOMIZE_TASKBAR 421
#define TRAYCMD_LOCK_TASKBAR 424
#define TRAYCMD_HELP_AND_SUPPORT 503
#define TRAYCMD_CONTROL_PANEL 505
#define TRAYCMD_SHUTDOWN_DIALOG 506
#define TRAYCMD_PRINTERS_AND_FAXES 510
#define TRAYCMD_LOCK_DESKTOP 517
#define TRAYCMD_SWITCH_USER_DIALOG 5000
#define TRAYCMD_SEARCH_FILES 41093
#define TRAYCMD_SEARCH_COMPUTERS 41094
void WINAPI ShellDDEInit(BOOL bInit);
DWORD WINAPI WinList_Init(void);