mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 05:32:55 +00:00
[RSHELL]
* Implement skeleton shell dde parser. [SHELL32] * Copy over the skeleton from rshell, and fill in the handlers for ViewFolder and ExploreFolder, with rudimentary implementations. CORE-7552 svn path=/branches/shell-experiments/; revision=64395
This commit is contained in:
parent
42040abadc
commit
6aaa167a00
2 changed files with 544 additions and 78 deletions
|
@ -21,9 +21,21 @@
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include <ddeml.h>
|
#include <ddeml.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
|
#include <shlwapi_undoc.h>
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shelldde);
|
WINE_DEFAULT_DEBUG_CHANNEL(shelldde);
|
||||||
|
|
||||||
|
typedef DWORD(CALLBACK * pfnCommandHandler)(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS);
|
||||||
|
|
||||||
|
struct DDECommandHandler
|
||||||
|
{
|
||||||
|
WCHAR Command[32];
|
||||||
|
pfnCommandHandler Handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern DDECommandHandler HandlerList [];
|
||||||
|
extern const int HandlerListLength;
|
||||||
|
|
||||||
/* DDE Instance ID */
|
/* DDE Instance ID */
|
||||||
static DWORD dwDDEInst;
|
static DWORD dwDDEInst;
|
||||||
|
|
||||||
|
@ -34,6 +46,8 @@ static HSZ hszShell;
|
||||||
static HSZ hszAppProperties;
|
static HSZ hszAppProperties;
|
||||||
static HSZ hszFolders;
|
static HSZ hszFolders;
|
||||||
|
|
||||||
|
static BOOL bInitialized;
|
||||||
|
|
||||||
static BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService)
|
static BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService)
|
||||||
{
|
{
|
||||||
WCHAR szTopic[MAX_PATH];
|
WCHAR szTopic[MAX_PATH];
|
||||||
|
@ -54,7 +68,7 @@ static void Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService)
|
||||||
|
|
||||||
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
||||||
DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE);
|
DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE);
|
||||||
|
|
||||||
DbgPrint("Dde_OnConnectConfirm: hconv=%p, topic=%S, service=%S\n", hconv, szTopic, szService);
|
DbgPrint("Dde_OnConnectConfirm: hconv=%p, topic=%S, service=%S\n", hconv, szTopic, szService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +98,32 @@ static HDDEDATA Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic, HSZ hszItem)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LPITEMIDLIST _ILReadFromSharedMemory(PCWSTR strField)
|
||||||
|
{
|
||||||
|
LPITEMIDLIST ret = NULL;
|
||||||
|
|
||||||
|
// Ensure it really is an IDLIST-formatted parameter
|
||||||
|
// Format for IDLIST params: ":pid:shared"
|
||||||
|
if (*strField != L':')
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
HANDLE hData = (HANDLE) StrToIntW(strField + 1);
|
||||||
|
PWSTR strSecond = StrChrW(strField + 1, L':');
|
||||||
|
|
||||||
|
if (strSecond)
|
||||||
|
{
|
||||||
|
int pid = StrToIntW(strSecond + 1);
|
||||||
|
void* pvShared = SHLockShared(hData, pid);
|
||||||
|
if (pvShared)
|
||||||
|
{
|
||||||
|
ret = ILClone((LPCITEMIDLIST) pvShared);
|
||||||
|
SHUnlockShared(pvShared);
|
||||||
|
SHFreeShared(hData, pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
|
static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
|
||||||
{
|
{
|
||||||
WCHAR szTopic[MAX_PATH];
|
WCHAR szTopic[MAX_PATH];
|
||||||
|
@ -92,7 +132,7 @@ static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
|
||||||
|
|
||||||
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
||||||
|
|
||||||
pszCommand = (WCHAR*)DdeAccessData(hdata, NULL);
|
pszCommand = (WCHAR*) DdeAccessData(hdata, NULL);
|
||||||
if (!pszCommand)
|
if (!pszCommand)
|
||||||
return DDE_FNOTPROCESSED;
|
return DDE_FNOTPROCESSED;
|
||||||
|
|
||||||
|
@ -103,15 +143,139 @@ static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
|
||||||
DbgPrint("Dde_OnExecute: hconv=%p, topic=%S, command=%S\n", hconv, szTopic, pszCommand);
|
DbgPrint("Dde_OnExecute: hconv=%p, topic=%S, command=%S\n", hconv, szTopic, pszCommand);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
[ViewFolder("%l", %I, %S)] -- Open a folder in standard mode
|
[ViewFolder("%l", %I, %S)] -- Open a folder in standard mode
|
||||||
[ExploreFolder("%l", %I, %S)] -- Open a folder in "explore" mode (file tree is shown to the left by default)
|
[ExploreFolder("%l", %I, %S)] -- Open a folder in "explore" mode (file tree is shown to the left by default)
|
||||||
[FindFolder("%l", %I)] -- Open a folder in "find" mode (search panel is shown to the left by default)
|
[FindFolder("%l", %I)] -- Open a folder in "find" mode (search panel is shown to the left by default)
|
||||||
[ShellFile("%1","%1",%S)] -- Execute the contents of the specified .SCF file
|
[ShellFile("%1","%1",%S)] -- Execute the contents of the specified .SCF file
|
||||||
|
|
||||||
|
Approximate grammar (Upper names define rules, <lower> names define terminals, single-quotes are literals):
|
||||||
|
|
||||||
|
Rules
|
||||||
|
Command = ('[' Function ']') | Function
|
||||||
|
Function = <identifier> '(' Parameters ')'
|
||||||
|
Parameters = (<quoted-string> (',' <idlist> (',' <number>)?)?)?
|
||||||
|
|
||||||
|
Terminals
|
||||||
|
<identifier> = [a-zA-Z]+
|
||||||
|
<quoted-string> = \"([^\"]|\\.)\"
|
||||||
|
<idlist> = \:[0-9]+\:[0-9]+
|
||||||
|
<number> = [0-9]+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return DDE_FACK;
|
WCHAR Command[MAX_PATH] = L"";
|
||||||
|
WCHAR Path[MAX_PATH] = L"";
|
||||||
|
LPITEMIDLIST IdList = NULL;
|
||||||
|
INT UnknownParameter = 0;
|
||||||
|
|
||||||
|
// Simplified parsing (assumes the command will not be TOO broken):
|
||||||
|
|
||||||
|
PWSTR cmd = szCommand;
|
||||||
|
// 1. if starts with [, skip first char
|
||||||
|
if (*cmd == L'[')
|
||||||
|
cmd++;
|
||||||
|
|
||||||
|
if (*cmd == L']')
|
||||||
|
{
|
||||||
|
ERR("Empty command. Nothing to run.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read until first (, and take text before ( as command name
|
||||||
|
{
|
||||||
|
PWSTR cmdEnd = StrChrW(cmd, L'(');
|
||||||
|
|
||||||
|
if (!cmdEnd)
|
||||||
|
{
|
||||||
|
ERR("Could not find '('. Invalid command.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
*cmdEnd = 0;
|
||||||
|
|
||||||
|
StringCchCopy(Command, _countof(Command), cmd);
|
||||||
|
|
||||||
|
cmd = cmdEnd + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read first param after (, expecting quoted string
|
||||||
|
if (*cmd != L')')
|
||||||
|
{
|
||||||
|
// Copy unescaped string
|
||||||
|
PWSTR dst = Path;
|
||||||
|
BOOL isQuote = FALSE;
|
||||||
|
|
||||||
|
PWSTR arg = cmd;
|
||||||
|
|
||||||
|
while (*arg && (isQuote || *arg != L','))
|
||||||
|
{
|
||||||
|
if (*arg == L'"')
|
||||||
|
{
|
||||||
|
isQuote = !isQuote;
|
||||||
|
if (isQuote && arg != cmd) // do not copy the " at the beginning of the string
|
||||||
|
{
|
||||||
|
*(dst++) = L'"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(dst++) = *arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = arg + 1;
|
||||||
|
|
||||||
|
while (*cmd == L' ')
|
||||||
|
cmd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read second param, expecting an idlist in shared memory
|
||||||
|
if (*cmd != L')')
|
||||||
|
{
|
||||||
|
if (*cmd != ':')
|
||||||
|
{
|
||||||
|
ERR("Expected ':'. Invalid command.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
PWSTR idlistEnd = StrChrW(cmd, L',');
|
||||||
|
|
||||||
|
if (!idlistEnd)
|
||||||
|
idlistEnd = StrChrW(cmd, L')');
|
||||||
|
|
||||||
|
if (!idlistEnd)
|
||||||
|
{
|
||||||
|
ERR("Expected ',' or ')'. Invalid command.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
IdList = _ILReadFromSharedMemory(cmd);
|
||||||
|
|
||||||
|
cmd = idlistEnd + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read third param, expecting an integer
|
||||||
|
if (*cmd != L')')
|
||||||
|
{
|
||||||
|
UnknownParameter = StrToIntW(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
DbgPrint("Parse end: cmd=%S, S=%d, pidl=%p, path=%S\n", Command, UnknownParameter, IdList, Path);
|
||||||
|
|
||||||
|
// Find handler in list
|
||||||
|
for (int i = 0; i < HandlerListLength; i++)
|
||||||
|
{
|
||||||
|
DDECommandHandler & handler = HandlerList[i];
|
||||||
|
if (StrCmpW(handler.Command, Command) == 0)
|
||||||
|
{
|
||||||
|
return handler.Handler(Command, Path, IdList, UnknownParameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No handler found
|
||||||
|
ERR("Unknown command %S\n", Command);
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Dde_OnDisconnect(HCONV hconv)
|
static void Dde_OnDisconnect(HCONV hconv)
|
||||||
|
@ -132,26 +296,26 @@ static HDDEDATA CALLBACK DdeCallback(
|
||||||
switch (uType)
|
switch (uType)
|
||||||
{
|
{
|
||||||
case XTYP_CONNECT:
|
case XTYP_CONNECT:
|
||||||
return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2);
|
return (HDDEDATA) (DWORD_PTR) Dde_OnConnect(hsz1, hsz2);
|
||||||
case XTYP_CONNECT_CONFIRM:
|
case XTYP_CONNECT_CONFIRM:
|
||||||
Dde_OnConnectConfirm(hconv, hsz1, hsz2);
|
Dde_OnConnectConfirm(hconv, hsz1, hsz2);
|
||||||
return NULL;
|
return NULL;
|
||||||
case XTYP_WILDCONNECT:
|
case XTYP_WILDCONNECT:
|
||||||
return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2);
|
return (HDDEDATA) (DWORD_PTR) Dde_OnWildConnect(hsz1, hsz2);
|
||||||
case XTYP_REQUEST:
|
case XTYP_REQUEST:
|
||||||
return Dde_OnRequest(uFmt, hconv, hsz1, hsz2);
|
return Dde_OnRequest(uFmt, hconv, hsz1, hsz2);
|
||||||
case XTYP_EXECUTE:
|
case XTYP_EXECUTE:
|
||||||
return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata);
|
return (HDDEDATA) (DWORD_PTR) Dde_OnExecute(hconv, hsz1, hdata);
|
||||||
case XTYP_DISCONNECT:
|
case XTYP_DISCONNECT:
|
||||||
Dde_OnDisconnect(hconv);
|
Dde_OnDisconnect(hconv);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
case XTYP_REGISTER:
|
||||||
|
return NULL;
|
||||||
default:
|
default:
|
||||||
DbgPrint("DdeCallback: unknown uType=%d\n", uType);
|
DbgPrint("DdeCallback: unknown uType=%d\n", uType);
|
||||||
case XTYP_REGISTER:
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* ShellDDEInit (SHELL32.@)
|
* ShellDDEInit (SHELL32.@)
|
||||||
*
|
*
|
||||||
|
@ -168,7 +332,7 @@ EXTERN_C void WINAPI ShellDDEInit(BOOL bInit)
|
||||||
{
|
{
|
||||||
DbgPrint("ShellDDEInit bInit = %s\n", bInit ? "TRUE" : "FALSE");
|
DbgPrint("ShellDDEInit bInit = %s\n", bInit ? "TRUE" : "FALSE");
|
||||||
|
|
||||||
if (bInit)
|
if (bInit && !bInitialized)
|
||||||
{
|
{
|
||||||
DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0);
|
DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0);
|
||||||
|
|
||||||
|
@ -178,19 +342,67 @@ EXTERN_C void WINAPI ShellDDEInit(BOOL bInit)
|
||||||
hszAppProperties = DdeCreateStringHandleW(dwDDEInst, L"AppProperties", CP_WINUNICODE);
|
hszAppProperties = DdeCreateStringHandleW(dwDDEInst, L"AppProperties", CP_WINUNICODE);
|
||||||
hszFolders = DdeCreateStringHandleW(dwDDEInst, L"Folders", CP_WINUNICODE);
|
hszFolders = DdeCreateStringHandleW(dwDDEInst, L"Folders", CP_WINUNICODE);
|
||||||
|
|
||||||
DdeNameService(dwDDEInst, hszFolders, 0, DNS_FILTEROFF);
|
if (hszProgmanTopic && hszProgmanService &&
|
||||||
|
hszShell && hszAppProperties && hszFolders &&
|
||||||
|
DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER) &&
|
||||||
|
DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER) &&
|
||||||
|
DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER))
|
||||||
|
{
|
||||||
|
bInitialized = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (!bInit && bInitialized)
|
||||||
{
|
{
|
||||||
/* unregister all services */
|
/* unregister all services */
|
||||||
DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER);
|
DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER);
|
||||||
|
|
||||||
DdeFreeStringHandle(dwDDEInst, hszFolders);
|
if (hszFolders)
|
||||||
DdeFreeStringHandle(dwDDEInst, hszAppProperties);
|
DdeFreeStringHandle(dwDDEInst, hszFolders);
|
||||||
DdeFreeStringHandle(dwDDEInst, hszShell);
|
if (hszAppProperties)
|
||||||
DdeFreeStringHandle(dwDDEInst, hszProgmanService);
|
DdeFreeStringHandle(dwDDEInst, hszAppProperties);
|
||||||
DdeFreeStringHandle(dwDDEInst, hszProgmanTopic);
|
if (hszShell)
|
||||||
|
DdeFreeStringHandle(dwDDEInst, hszShell);
|
||||||
|
if (hszProgmanService)
|
||||||
|
DdeFreeStringHandle(dwDDEInst, hszProgmanService);
|
||||||
|
if (hszProgmanTopic)
|
||||||
|
DdeFreeStringHandle(dwDDEInst, hszProgmanTopic);
|
||||||
|
|
||||||
DdeUninitialize(dwDDEInst);
|
DdeUninitialize(dwDDEInst);
|
||||||
|
|
||||||
|
bInitialized = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDE_OnViewFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return DDE_FACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDW_OnExploreFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return DDE_FACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDE_OnFindFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDE_OnShellFile(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
DDECommandHandler HandlerList [] = {
|
||||||
|
|
||||||
|
{ L"ViewFolder", DDE_OnViewFolder },
|
||||||
|
{ L"ExploreFolder", DDW_OnExploreFolder },
|
||||||
|
{ L"FindFolder", DDE_OnFindFolder },
|
||||||
|
{ L"ShellFile", DDE_OnShellFile }
|
||||||
|
};
|
||||||
|
|
||||||
|
const int HandlerListLength = _countof(HandlerList);
|
||||||
|
|
|
@ -19,69 +19,268 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include <ddeml.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
#include <shlwapi_undoc.h>
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
WINE_DEFAULT_DEBUG_CHANNEL(shelldde);
|
||||||
|
|
||||||
|
typedef DWORD(CALLBACK * pfnCommandHandler)(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS);
|
||||||
|
|
||||||
|
struct DDECommandHandler
|
||||||
|
{
|
||||||
|
WCHAR Command[32];
|
||||||
|
pfnCommandHandler Handler;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern DDECommandHandler HandlerList [];
|
||||||
|
extern const int HandlerListLength;
|
||||||
|
|
||||||
|
/* DDE Instance ID */
|
||||||
|
static DWORD dwDDEInst;
|
||||||
|
|
||||||
/* String handles */
|
/* String handles */
|
||||||
static HSZ hszProgmanTopic;
|
static HSZ hszProgmanTopic;
|
||||||
static HSZ hszProgmanService;
|
static HSZ hszProgmanService;
|
||||||
static HSZ hszAsterisk;
|
|
||||||
static HSZ hszShell;
|
static HSZ hszShell;
|
||||||
static HSZ hszAppProperties;
|
static HSZ hszAppProperties;
|
||||||
static HSZ hszFolders;
|
static HSZ hszFolders;
|
||||||
/* DDE Instance ID */
|
|
||||||
static DWORD dwDDEInst;
|
|
||||||
|
|
||||||
|
static BOOL bInitialized;
|
||||||
|
|
||||||
static BOOL __inline Dde_OnConnect(HSZ hszTopic, HSZ hszService)
|
static BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService)
|
||||||
{
|
{
|
||||||
if ((hszTopic == hszProgmanTopic) && (hszService == hszProgmanService))
|
WCHAR szTopic[MAX_PATH];
|
||||||
return TRUE;
|
WCHAR szService[MAX_PATH];
|
||||||
if ((hszTopic == hszProgmanTopic) && (hszService == hszAppProperties))
|
|
||||||
return TRUE;
|
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
||||||
if ((hszTopic == hszShell) && (hszService == hszFolders))
|
DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE);
|
||||||
return TRUE;
|
|
||||||
if ((hszTopic == hszShell) && (hszService == hszAppProperties))
|
DbgPrint("Dde_OnConnect: topic=%S, service=%S\n", szTopic, szService);
|
||||||
return TRUE;
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService)
|
||||||
|
{
|
||||||
|
WCHAR szTopic[MAX_PATH];
|
||||||
|
WCHAR szService[MAX_PATH];
|
||||||
|
|
||||||
|
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
||||||
|
DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE);
|
||||||
|
|
||||||
|
DbgPrint("Dde_OnConnectConfirm: hconv=%p, topic=%S, service=%S\n", hconv, szTopic, szService);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL Dde_OnWildConnect(HSZ hszTopic, HSZ hszService)
|
||||||
|
{
|
||||||
|
WCHAR szTopic[MAX_PATH];
|
||||||
|
WCHAR szService[MAX_PATH];
|
||||||
|
|
||||||
|
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
||||||
|
DdeQueryStringW(dwDDEInst, hszService, szService, _countof(szService), CP_WINUNICODE);
|
||||||
|
|
||||||
|
DbgPrint("Dde_OnWildConnect: topic=%S, service=%S\n", szTopic, szService);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __inline Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService)
|
static HDDEDATA Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic, HSZ hszItem)
|
||||||
{
|
{
|
||||||
FIXME("stub\n");
|
WCHAR szTopic[MAX_PATH];
|
||||||
}
|
WCHAR szItem[MAX_PATH];
|
||||||
|
|
||||||
static BOOL __inline Dde_OnWildConnect(HSZ hszTopic, HSZ hszService)
|
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
||||||
{
|
DdeQueryStringW(dwDDEInst, hszItem, szItem, _countof(szItem), CP_WINUNICODE);
|
||||||
FIXME("stub\n");
|
|
||||||
return FALSE;
|
DbgPrint("Dde_OnRequest: uFmt=%d, hconv=%p, topic=%S, item=%S\n", hconv, szTopic, szItem);
|
||||||
}
|
|
||||||
|
|
||||||
static HDDEDATA __inline Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic,
|
|
||||||
HSZ hszItem)
|
|
||||||
{
|
|
||||||
FIXME("stub\n");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD __inline Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
|
static LPITEMIDLIST _ILReadFromSharedMemory(PCWSTR strField)
|
||||||
{
|
{
|
||||||
BYTE * pszCommand;
|
LPITEMIDLIST ret = NULL;
|
||||||
|
|
||||||
pszCommand = DdeAccessData(hdata, NULL);
|
// Ensure it really is an IDLIST-formatted parameter
|
||||||
|
// Format for IDLIST params: ":pid:shared"
|
||||||
|
if (*strField != L':')
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
HANDLE hData = (HANDLE) StrToIntW(strField + 1);
|
||||||
|
PWSTR strSecond = StrChrW(strField + 1, L':');
|
||||||
|
|
||||||
|
if (strSecond)
|
||||||
|
{
|
||||||
|
int pid = StrToIntW(strSecond + 1);
|
||||||
|
void* pvShared = SHLockShared(hData, pid);
|
||||||
|
if (pvShared)
|
||||||
|
{
|
||||||
|
ret = ILClone((LPCITEMIDLIST) pvShared);
|
||||||
|
SHUnlockShared(pvShared);
|
||||||
|
SHFreeShared(hData, pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
|
||||||
|
{
|
||||||
|
WCHAR szTopic[MAX_PATH];
|
||||||
|
WCHAR szCommand[MAX_PATH];
|
||||||
|
WCHAR *pszCommand;
|
||||||
|
|
||||||
|
DdeQueryStringW(dwDDEInst, hszTopic, szTopic, _countof(szTopic), CP_WINUNICODE);
|
||||||
|
|
||||||
|
pszCommand = (WCHAR*) DdeAccessData(hdata, NULL);
|
||||||
if (!pszCommand)
|
if (!pszCommand)
|
||||||
return DDE_FNOTPROCESSED;
|
return DDE_FNOTPROCESSED;
|
||||||
|
|
||||||
FIXME("stub: %s\n", pszCommand);
|
StringCchCopyW(szCommand, _countof(szCommand), pszCommand);
|
||||||
|
|
||||||
DdeUnaccessData(hdata);
|
DdeUnaccessData(hdata);
|
||||||
|
|
||||||
|
DbgPrint("Dde_OnExecute: hconv=%p, topic=%S, command=%S\n", hconv, szTopic, pszCommand);
|
||||||
|
|
||||||
|
/*
|
||||||
|
[ViewFolder("%l", %I, %S)] -- Open a folder in standard mode
|
||||||
|
[ExploreFolder("%l", %I, %S)] -- Open a folder in "explore" mode (file tree is shown to the left by default)
|
||||||
|
[FindFolder("%l", %I)] -- Open a folder in "find" mode (search panel is shown to the left by default)
|
||||||
|
[ShellFile("%1","%1",%S)] -- Execute the contents of the specified .SCF file
|
||||||
|
|
||||||
|
Approximate grammar (Upper names define rules, <lower> names define terminals, single-quotes are literals):
|
||||||
|
|
||||||
|
Rules
|
||||||
|
Command = ('[' Function ']') | Function
|
||||||
|
Function = <identifier> '(' Parameters ')'
|
||||||
|
Parameters = (<quoted-string> (',' <idlist> (',' <number>)?)?)?
|
||||||
|
|
||||||
|
Terminals
|
||||||
|
<identifier> = [a-zA-Z]+
|
||||||
|
<quoted-string> = \"([^\"]|\\.)\"
|
||||||
|
<idlist> = \:[0-9]+\:[0-9]+
|
||||||
|
<number> = [0-9]+
|
||||||
|
*/
|
||||||
|
|
||||||
|
WCHAR Command[MAX_PATH] = L"";
|
||||||
|
WCHAR Path[MAX_PATH] = L"";
|
||||||
|
LPITEMIDLIST IdList = NULL;
|
||||||
|
INT UnknownParameter = 0;
|
||||||
|
|
||||||
|
// Simplified parsing (assumes the command will not be TOO broken):
|
||||||
|
|
||||||
|
PWSTR cmd = szCommand;
|
||||||
|
// 1. if starts with [, skip first char
|
||||||
|
if (*cmd == L'[')
|
||||||
|
cmd++;
|
||||||
|
|
||||||
|
if (*cmd == L']')
|
||||||
|
{
|
||||||
|
ERR("Empty command. Nothing to run.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read until first (, and take text before ( as command name
|
||||||
|
{
|
||||||
|
PWSTR cmdEnd = StrChrW(cmd, L'(');
|
||||||
|
|
||||||
|
if (!cmdEnd)
|
||||||
|
{
|
||||||
|
ERR("Could not find '('. Invalid command.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
*cmdEnd = 0;
|
||||||
|
|
||||||
|
StringCchCopy(Command, _countof(Command), cmd);
|
||||||
|
|
||||||
|
cmd = cmdEnd + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read first param after (, expecting quoted string
|
||||||
|
if (*cmd != L')')
|
||||||
|
{
|
||||||
|
// Copy unescaped string
|
||||||
|
PWSTR dst = Path;
|
||||||
|
BOOL isQuote = FALSE;
|
||||||
|
|
||||||
|
PWSTR arg = cmd;
|
||||||
|
|
||||||
|
while (*arg && (isQuote || *arg != L','))
|
||||||
|
{
|
||||||
|
if (*arg == L'"')
|
||||||
|
{
|
||||||
|
isQuote = !isQuote;
|
||||||
|
if (isQuote && arg != cmd) // do not copy the " at the beginning of the string
|
||||||
|
{
|
||||||
|
*(dst++) = L'"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(dst++) = *arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
arg++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = arg + 1;
|
||||||
|
|
||||||
|
while (*cmd == L' ')
|
||||||
|
cmd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read second param, expecting an idlist in shared memory
|
||||||
|
if (*cmd != L')')
|
||||||
|
{
|
||||||
|
if (*cmd != ':')
|
||||||
|
{
|
||||||
|
ERR("Expected ':'. Invalid command.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
PWSTR idlistEnd = StrChrW(cmd, L',');
|
||||||
|
|
||||||
|
if (!idlistEnd)
|
||||||
|
idlistEnd = StrChrW(cmd, L')');
|
||||||
|
|
||||||
|
if (!idlistEnd)
|
||||||
|
{
|
||||||
|
ERR("Expected ',' or ')'. Invalid command.\n");
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
IdList = _ILReadFromSharedMemory(cmd);
|
||||||
|
|
||||||
|
cmd = idlistEnd + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read third param, expecting an integer
|
||||||
|
if (*cmd != L')')
|
||||||
|
{
|
||||||
|
UnknownParameter = StrToIntW(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
DbgPrint("Parse end: cmd=%S, S=%d, pidl=%p, path=%S\n", Command, UnknownParameter, IdList, Path);
|
||||||
|
|
||||||
|
// Find handler in list
|
||||||
|
for (int i = 0; i < HandlerListLength; i++)
|
||||||
|
{
|
||||||
|
DDECommandHandler & handler = HandlerList[i];
|
||||||
|
if (StrCmpW(handler.Command, Command) == 0)
|
||||||
|
{
|
||||||
|
return handler.Handler(Command, Path, IdList, UnknownParameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No handler found
|
||||||
|
ERR("Unknown command %S\n", Command);
|
||||||
return DDE_FNOTPROCESSED;
|
return DDE_FNOTPROCESSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __inline Dde_OnDisconnect(HCONV hconv)
|
static void Dde_OnDisconnect(HCONV hconv)
|
||||||
{
|
{
|
||||||
FIXME("stub\n");
|
DbgPrint("Dde_OnDisconnect: hconv=%p\n", hconv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HDDEDATA CALLBACK DdeCallback(
|
static HDDEDATA CALLBACK DdeCallback(
|
||||||
|
@ -97,24 +296,26 @@ static HDDEDATA CALLBACK DdeCallback(
|
||||||
switch (uType)
|
switch (uType)
|
||||||
{
|
{
|
||||||
case XTYP_CONNECT:
|
case XTYP_CONNECT:
|
||||||
return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2);
|
return (HDDEDATA) (DWORD_PTR) Dde_OnConnect(hsz1, hsz2);
|
||||||
case XTYP_CONNECT_CONFIRM:
|
case XTYP_CONNECT_CONFIRM:
|
||||||
Dde_OnConnectConfirm(hconv, hsz1, hsz2);
|
Dde_OnConnectConfirm(hconv, hsz1, hsz2);
|
||||||
return NULL;
|
return NULL;
|
||||||
case XTYP_WILDCONNECT:
|
case XTYP_WILDCONNECT:
|
||||||
return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2);
|
return (HDDEDATA) (DWORD_PTR) Dde_OnWildConnect(hsz1, hsz2);
|
||||||
case XTYP_REQUEST:
|
case XTYP_REQUEST:
|
||||||
return Dde_OnRequest(uFmt, hconv, hsz1, hsz2);
|
return Dde_OnRequest(uFmt, hconv, hsz1, hsz2);
|
||||||
case XTYP_EXECUTE:
|
case XTYP_EXECUTE:
|
||||||
return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata);
|
return (HDDEDATA) (DWORD_PTR) Dde_OnExecute(hconv, hsz1, hdata);
|
||||||
case XTYP_DISCONNECT:
|
case XTYP_DISCONNECT:
|
||||||
Dde_OnDisconnect(hconv);
|
Dde_OnDisconnect(hconv);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
case XTYP_REGISTER:
|
||||||
|
return NULL;
|
||||||
default:
|
default:
|
||||||
|
DbgPrint("DdeCallback: unknown uType=%d\n", uType);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* ShellDDEInit (SHELL32.@)
|
* ShellDDEInit (SHELL32.@)
|
||||||
*
|
*
|
||||||
|
@ -129,42 +330,95 @@ static HDDEDATA CALLBACK DdeCallback(
|
||||||
*/
|
*/
|
||||||
EXTERN_C void WINAPI ShellDDEInit(BOOL bInit)
|
EXTERN_C void WINAPI ShellDDEInit(BOOL bInit)
|
||||||
{
|
{
|
||||||
TRACE("bInit = %s\n", bInit ? "TRUE" : "FALSE");
|
DbgPrint("ShellDDEInit bInit = %s\n", bInit ? "TRUE" : "FALSE");
|
||||||
|
|
||||||
if (bInit)
|
if (bInit && !bInitialized)
|
||||||
{
|
{
|
||||||
static const WCHAR wszProgman[] = {'P','r','o','g','m','a','n',0};
|
|
||||||
static const WCHAR wszAsterisk[] = {'*',0};
|
|
||||||
static const WCHAR wszShell[] = {'S','h','e','l','l',0};
|
|
||||||
static const WCHAR wszAppProperties[] =
|
|
||||||
{'A','p','p','P','r','o','p','e','r','t','i','e','s',0};
|
|
||||||
static const WCHAR wszFolders[] = {'F','o','l','d','e','r','s',0};
|
|
||||||
|
|
||||||
DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0);
|
DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0);
|
||||||
|
|
||||||
hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE);
|
hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, L"Progman", CP_WINUNICODE);
|
||||||
hszProgmanService = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE);
|
hszProgmanService = DdeCreateStringHandleW(dwDDEInst, L"Progman", CP_WINUNICODE);
|
||||||
hszAsterisk = DdeCreateStringHandleW(dwDDEInst, wszAsterisk, CP_WINUNICODE);
|
hszShell = DdeCreateStringHandleW(dwDDEInst, L"Shell", CP_WINUNICODE);
|
||||||
hszShell = DdeCreateStringHandleW(dwDDEInst, wszShell, CP_WINUNICODE);
|
hszAppProperties = DdeCreateStringHandleW(dwDDEInst, L"AppProperties", CP_WINUNICODE);
|
||||||
hszAppProperties = DdeCreateStringHandleW(dwDDEInst, wszAppProperties, CP_WINUNICODE);
|
hszFolders = DdeCreateStringHandleW(dwDDEInst, L"Folders", CP_WINUNICODE);
|
||||||
hszFolders = DdeCreateStringHandleW(dwDDEInst, wszFolders, CP_WINUNICODE);
|
|
||||||
|
|
||||||
DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER);
|
if (hszProgmanTopic && hszProgmanService &&
|
||||||
DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER);
|
hszShell && hszAppProperties && hszFolders &&
|
||||||
DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER);
|
DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER) &&
|
||||||
|
DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER) &&
|
||||||
|
DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER))
|
||||||
|
{
|
||||||
|
bInitialized = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (!bInit && bInitialized)
|
||||||
{
|
{
|
||||||
/* unregister all services */
|
/* unregister all services */
|
||||||
DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER);
|
DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER);
|
||||||
|
|
||||||
DdeFreeStringHandle(dwDDEInst, hszFolders);
|
if (hszFolders)
|
||||||
DdeFreeStringHandle(dwDDEInst, hszAppProperties);
|
DdeFreeStringHandle(dwDDEInst, hszFolders);
|
||||||
DdeFreeStringHandle(dwDDEInst, hszShell);
|
if (hszAppProperties)
|
||||||
DdeFreeStringHandle(dwDDEInst, hszAsterisk);
|
DdeFreeStringHandle(dwDDEInst, hszAppProperties);
|
||||||
DdeFreeStringHandle(dwDDEInst, hszProgmanService);
|
if (hszShell)
|
||||||
DdeFreeStringHandle(dwDDEInst, hszProgmanTopic);
|
DdeFreeStringHandle(dwDDEInst, hszShell);
|
||||||
|
if (hszProgmanService)
|
||||||
|
DdeFreeStringHandle(dwDDEInst, hszProgmanService);
|
||||||
|
if (hszProgmanTopic)
|
||||||
|
DdeFreeStringHandle(dwDDEInst, hszProgmanTopic);
|
||||||
|
|
||||||
DdeUninitialize(dwDDEInst);
|
DdeUninitialize(dwDDEInst);
|
||||||
|
|
||||||
|
bInitialized = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDE_OnViewFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
if (!pidl)
|
||||||
|
pidl = ILCreateFromPathW(strPath);
|
||||||
|
|
||||||
|
if (!pidl)
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
|
||||||
|
if (FAILED(SHOpenNewFrame(pidl, NULL, 0, 0)))
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
|
||||||
|
return DDE_FACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDW_OnExploreFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
if (!pidl)
|
||||||
|
pidl = ILCreateFromPathW(strPath);
|
||||||
|
|
||||||
|
if (!pidl)
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
|
||||||
|
if (FAILED(SHOpenNewFrame(pidl, NULL, 0, SH_EXPLORER_CMDLINE_FLAG_E)))
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
|
||||||
|
return DDE_FACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDE_OnFindFolder(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD CALLBACK DDE_OnShellFile(PWSTR strCommand, PWSTR strPath, LPITEMIDLIST pidl, INT unkS)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return DDE_FNOTPROCESSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
DDECommandHandler HandlerList [] = {
|
||||||
|
|
||||||
|
{ L"ViewFolder", DDE_OnViewFolder },
|
||||||
|
{ L"ExploreFolder", DDW_OnExploreFolder },
|
||||||
|
{ L"FindFolder", DDE_OnFindFolder },
|
||||||
|
{ L"ShellFile", DDE_OnShellFile }
|
||||||
|
};
|
||||||
|
|
||||||
|
const int HandlerListLength = _countof(HandlerList);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue