ReactOS 0.4.16-dev-816-g135a9a9
COpenWithMenu.cpp File Reference
#include "precomp.h"
Include dependency graph for COpenWithMenu.cpp:

Go to the source code of this file.

Classes

class  COpenWithList
 
struct  COpenWithList::SApp
 
struct  COpenWithList::_LANGANDCODEPAGE
 
class  COpenWithDialog
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C BOOL PathIsExeW (LPCWSTR lpszPath)
 
static SIZE_T PathGetAppFromCommandLine (LPCWSTR pszIn, LPWSTR pszOut, SIZE_T cchMax)
 
HRESULT SHELL32_GetDllFromRundll32CommandLine (LPCWSTR pszCmd, LPWSTR pszOut, SIZE_T cchMax)
 
HRESULT WINAPI SHOpenWithDialog (HWND hwndParent, const OPENASINFO *poainfo)
 

Variables

static const CMVERBMAP g_VerbMap []
 

Function Documentation

◆ PathGetAppFromCommandLine()

static SIZE_T PathGetAppFromCommandLine ( LPCWSTR  pszIn,
LPWSTR  pszOut,
SIZE_T  cchMax 
)
static

Definition at line 34 of file COpenWithMenu.cpp.

35{
36 SIZE_T count = 0;
37 WCHAR stop = ' ';
38 if (pszIn[0] == '"')
39 stop = *(pszIn++);
40
41 for (LPCWSTR pwszSrc = pszIn; *pwszSrc && *pwszSrc != stop; ++pwszSrc)
42 {
43 if (++count >= cchMax)
44 return 0;
45 *(pszOut++) = *pwszSrc;
46 }
47 *pszOut = UNICODE_NULL;
48 return count;
49}
UINT cchMax
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define UNICODE_NULL
ULONG_PTR SIZE_T
Definition: typedefs.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by COpenWithList::GetPathFromCmd(), and SHELL32_GetDllFromRundll32CommandLine().

◆ PathIsExeW()

EXTERN_C BOOL PathIsExeW ( LPCWSTR  lpszPath)

Definition at line 539 of file shellpath.c.

540{
541 LPCWSTR lpszExtension = PathGetExtensionW(lpszPath);
542 int i;
543 static const WCHAR lpszExtensions[][4] =
544 {L"exe", L"com", L"pif", L"cmd", L"bat", L"scf", L"scr", L"" };
545
546 TRACE("path=%s\n",debugstr_w(lpszPath));
547
548 for(i=0; lpszExtensions[i][0]; i++)
549 if (!wcsicmp(lpszExtension,lpszExtensions[i])) return TRUE;
550
551 return FALSE;
552}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define wcsicmp
Definition: compat.h:15
static LPWSTR PathGetExtensionW(LPCWSTR lpszPath)
Definition: shellpath.c:434
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
#define L(x)
Definition: ntvdm.h:50
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by CFileDefExt::InitGeneralPage(), and COpenWithMenu::Initialize().

◆ SHELL32_GetDllFromRundll32CommandLine()

HRESULT SHELL32_GetDllFromRundll32CommandLine ( LPCWSTR  pszCmd,
LPWSTR  pszOut,
SIZE_T  cchMax 
)

Definition at line 51 of file COpenWithMenu.cpp.

52{
53 WCHAR szDll[MAX_PATH + 100];
54 if (!PathGetAppFromCommandLine(pszCmd, szDll, _countof(szDll)))
56
57 PWSTR pszName = PathFindFileNameW(szDll);
58 if (_wcsicmp(pszName, L"rundll32") && _wcsicmp(pszName, L"rundll32.exe"))
59 return E_UNEXPECTED;
60
61 PCWSTR pszDllStart = pszCmd + (pszName - szDll) + lstrlenW(pszName);
62
63 if (*pszDllStart == '\"')
64 ++pszDllStart; // Skip possible end quote of ..\rundll32.exe" foo.dll,func
65 while (*pszDllStart <= ' ' && *pszDllStart)
66 ++pszDllStart;
67 if (PathGetAppFromCommandLine(pszDllStart, szDll, _countof(szDll)))
68 {
69 BOOL quoted = *pszDllStart == '\"';
70 PWSTR pszComma = szDll + lstrlenW(szDll);
71 while (!quoted && pszComma > szDll && *pszComma != ',' && *pszComma != '\\' && *pszComma != '/')
72 --pszComma;
73 SIZE_T cch = pszComma - szDll;
74 if (cch <= cchMax && (quoted || *pszComma == ','))
75 {
76 *pszComma = UNICODE_NULL;
77 lstrcpynW(pszOut, szDll, cchMax);
78 return S_OK;
79 }
80 }
82}
static SIZE_T PathGetAppFromCommandLine(LPCWSTR pszIn, LPWSTR pszOut, SIZE_T cchMax)
#define MAX_PATH
Definition: compat.h:34
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_OK
Definition: intsafe.h:52
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define _countof(array)
Definition: sndvol32.h:70
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define E_UNEXPECTED
Definition: winerror.h:2456
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by COpenWithList::GetPathFromCmd(), and CFileDefExt::InitOpensWithField().

◆ SHOpenWithDialog()

HRESULT WINAPI SHOpenWithDialog ( HWND  hwndParent,
const OPENASINFO poainfo 
)

Definition at line 1509 of file COpenWithMenu.cpp.

1510{
1511 INT_PTR ret;
1512
1513 TRACE("SHOpenWithDialog hwndParent %p poainfo %p\n", hwndParent, poainfo);
1514
1516
1517 if (poainfo->pcszClass == NULL && poainfo->pcszFile == NULL)
1518 return E_FAIL;
1519
1520 COpenWithDialog pDialog(poainfo);
1521
1522 if (pDialog.IsNoOpen(hwndParent))
1523 return S_OK;
1524
1527
1528 if (ret == (INT_PTR)-1)
1529 {
1530 ERR("Failed to create dialog: %u\n", GetLastError());
1531 return E_FAIL;
1532 }
1533
1534 return S_OK;
1535}
#define shell32_hInstance
#define ERR(fmt,...)
Definition: precomp.h:57
static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:870
static HWND hwndParent
Definition: cryptui.c:300
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define IDD_OPEN_WITH
Definition: shresdef.h:522
LPCWSTR pcszFile
Definition: shlobj.h:2693
LPCWSTR pcszClass
Definition: shlobj.h:2694
int32_t INT_PTR
Definition: typedefs.h:64
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEINTRESOURCE
Definition: winuser.h:591
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by FolderOptionsFileTypesDlg(), CFileDefExt::GeneralPageProc(), COpenWithMenu::InvokeCommand(), and OpenAs_RunDLLW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ g_VerbMap

const CMVERBMAP g_VerbMap[]
static
Initial value:
=
{
{ "openas", 0 },
{ NULL }
}

Definition at line 1300 of file COpenWithMenu.cpp.