ReactOS  0.4.15-dev-1201-gb2cf5a4
shell32.cpp File Reference
#include "precomp.h"
#include "shell32_version.h"
Include dependency graph for shell32.cpp:

Go to the source code of this file.

Classes

struct  IDefClFImpl
 
class  CStartMenuDummy
 
class  CStartMenuDummy::_CreatorClass
 
class  CShell32Module
 

Typedefs

typedef HRESULT(CALLBACKLPFNCREATEINSTANCE) (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C LPWSTR WINAPI AddCommasW (DWORD lValue, LPWSTR lpNumber)
 
EXTERN_C BOOL WINAPI RegenerateUserEnvironment (LPVOID *lpEnvironment, BOOL bUpdateSelf)
 
HRESULT IDefClF_fnConstructor (LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, const IID *riidInst, IClassFactory **theFactory)
 
HRESULT WINAPI SHCreateDefClassObject (REFIID riid, LPVOID *ppv, LPFNCREATEINSTANCE lpfnCI, LPDWORD pcRefDll, REFIID riidInst)
 
STDAPI DllGetVersion (DLLVERSIONINFO *pdvi)
 
 STDAPI_ (BOOL) DllMain(HINSTANCE hInstance
 
 if (dwReason==DLL_PROCESS_ATTACH)
 
STDAPI DllCanUnloadNow ()
 
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
STDAPI DllRegisterServer ()
 
STDAPI DllUnregisterServer ()
 
HRESULT WINAPI DllInstall (BOOL bInstall, LPCWSTR cmdline)
 

Variables

CShell32Module gModule
 
HINSTANCE shell32_hInstance
 
DWORD dwReason
 
DWORD LPVOID fImpLoad
 
return TRUE
 

Typedef Documentation

◆ LPFNCREATEINSTANCE

typedef HRESULT(CALLBACK * LPFNCREATEINSTANCE) (IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObject)

Definition at line 111 of file shell32.cpp.

Function Documentation

◆ AddCommasW()

EXTERN_C LPWSTR WINAPI AddCommasW ( DWORD  lValue,
LPWSTR  lpNumber 
)

Definition at line 33 of file shell32.cpp.

34 {
35  WCHAR szValue[MAX_PATH], szSeparator[8 + 1];
36  NUMBERFMTW numFormat;
37 
40  szSeparator,
41  _countof(szSeparator));
42 
43  numFormat.NumDigits = 0;
44  numFormat.LeadingZero = 0;
45  numFormat.Grouping = 3; // FIXME! Use GetLocaleInfoW with LOCALE_SGROUPING and interpret the result.
46  numFormat.lpDecimalSep = szSeparator;
47  numFormat.lpThousandSep = szSeparator;
48  numFormat.NegativeOrder = 0;
49 
50  swprintf(szValue, L"%lu", lValue);
51 
53  0,
54  szValue,
55  &numFormat,
56  lpNumber,
57  MAX_PATH) != 0)
58  {
59  return lpNumber;
60  }
61 
62  wcscpy(lpNumber, szValue);
63  return lpNumber;
64 }
LPWSTR lpThousandSep
Definition: winnls.h:643
LPWSTR lpDecimalSep
Definition: winnls.h:642
#define LOCALE_USER_DEFAULT
UINT Grouping
Definition: winnls.h:641
UINT NegativeOrder
Definition: winnls.h:644
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_STHOUSAND
Definition: winnls.h:43
UINT NumDigits
Definition: winnls.h:639
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
UINT LeadingZero
Definition: winnls.h:640
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1198

Referenced by START_TEST().

◆ DllCanUnloadNow()

STDAPI DllCanUnloadNow ( void  )

Definition at line 405 of file shell32.cpp.

406 {
407  return gModule.DllCanUnloadNow();
408 }
HRESULT DllCanUnloadNow()
Definition: atlbase.h:928
CShell32Module gModule
Definition: shell32.cpp:305

◆ DllGetClassObject()

STDAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 414 of file shell32.cpp.

415 {
416  HRESULT hResult;
417 
418  TRACE("CLSID:%s,IID:%s\n", shdebugstr_guid(&rclsid), shdebugstr_guid(&riid));
419 
420  hResult = gModule.DllGetClassObject(rclsid, riid, ppv);
421  TRACE("-- pointer to class factory: %p\n", *ppv);
422  return hResult;
423 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
const char * shdebugstr_guid(const struct _GUID *id)
Definition: debughlp.cpp:414
HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: atlbase.h:935
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
CShell32Module gModule
Definition: shell32.cpp:305

◆ DllGetVersion()

STDAPI DllGetVersion ( DLLVERSIONINFO pdvi)

Definition at line 324 of file shell32.cpp.

325 {
326  /* FIXME: shouldn't these values come from the version resource? */
327  if (pdvi->cbSize == sizeof(DLLVERSIONINFO) ||
328  pdvi->cbSize == sizeof(DLLVERSIONINFO2))
329  {
334  if (pdvi->cbSize == sizeof(DLLVERSIONINFO2))
335  {
336  DLLVERSIONINFO2 *pdvi2 = (DLLVERSIONINFO2 *)pdvi;
337 
338  pdvi2->dwFlags = 0;
339  pdvi2->ullVersion = MAKEDLLVERULL(WINE_FILEVERSION_MAJOR,
343  }
344  TRACE("%u.%u.%u.%u\n",
345  pdvi->dwMajorVersion, pdvi->dwMinorVersion,
346  pdvi->dwBuildNumber, pdvi->dwPlatformID);
347  return S_OK;
348  }
349  else
350  {
351  WARN("wrong DLLVERSIONINFO size from app\n");
352  return E_INVALIDARG;
353  }
354 }
DWORD dwMinorVersion
Definition: shlwapi.h:1956
#define WINE_FILEVERSION_PLATFORMID
#define WARN(fmt,...)
Definition: debug.h:112
#define WINE_FILEVERSION_MAJOR
DWORD dwBuildNumber
Definition: shlwapi.h:1957
#define E_INVALIDARG
Definition: ddrawi.h:101
DWORD dwMajorVersion
Definition: shlwapi.h:1955
#define MAKEDLLVERULL(mjr, mnr, bld, qfe)
Definition: shlwapi.h:1982
#define TRACE(s)
Definition: solgame.cpp:4
#define WINE_FILEVERSION_MINOR
#define WINE_FILEVERSION_BUILD
DWORD dwPlatformID
Definition: shlwapi.h:1958
#define S_OK
Definition: intsafe.h:51

◆ DllInstall()

HRESULT WINAPI DllInstall ( BOOL  bInstall,
LPCWSTR  cmdline 
)

Definition at line 474 of file shell32.cpp.

475 {
476  FIXME("%s %s: stub\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
477  return S_OK; /* indicate success */
478 }
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define S_OK
Definition: intsafe.h:51

◆ DllRegisterServer()

STDAPI DllRegisterServer ( void  )

Definition at line 428 of file shell32.cpp.

429 {
430  HRESULT hr;
431 
433  if (FAILED(hr))
434  return hr;
435 
437  if (FAILED(hr))
438  return hr;
439 
441  if (FAILED(hr))
442  return hr;
443 
444  return S_OK;
445 }
HRESULT DllRegisterServer(BOOL bRegTypeLib=TRUE)
Definition: atlbase.h:940
HRESULT hr
Definition: shlfolder.c:183
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI UpdateRegistryFromResource(LPCTSTR lpszRes, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries=NULL)
Definition: atlbase.h:439
LONG HRESULT
Definition: typedefs.h:79
return TRUE
Definition: shell32.cpp:399
#define S_OK
Definition: intsafe.h:51
CShell32Module gModule
Definition: shell32.cpp:305
#define IDR_FOLDEROPTIONS
Definition: shresdef.h:825
HRESULT SHELL_RegisterShellFolders(void) DECLSPEC_HIDDEN
Definition: shellpath.c:2681

◆ DllUnregisterServer()

STDAPI DllUnregisterServer ( void  )

Definition at line 450 of file shell32.cpp.

451 {
452  HRESULT hr;
453 
455  if (FAILED(hr))
456  return hr;
457 
459  if (FAILED(hr))
460  return hr;
461 
462  return S_OK;
463 }
HRESULT hr
Definition: shlfolder.c:183
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI UpdateRegistryFromResource(LPCTSTR lpszRes, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries=NULL)
Definition: atlbase.h:439
LONG HRESULT
Definition: typedefs.h:79
return TRUE
Definition: shell32.cpp:399
#define S_OK
Definition: intsafe.h:51
CShell32Module gModule
Definition: shell32.cpp:305
#define IDR_FOLDEROPTIONS
Definition: shresdef.h:825
HRESULT DllUnregisterServer(BOOL bUnRegTypeLib=TRUE)
Definition: atlbase.h:945

◆ IDefClF_fnConstructor()

HRESULT IDefClF_fnConstructor ( LPFNCREATEINSTANCE  lpfnCI,
PLONG  pcRefDll,
const IID riidInst,
IClassFactory **  theFactory 
)

Definition at line 200 of file shell32.cpp.

201 {
202  return ShellObjectCreatorInit<IDefClFImpl>(lpfnCI, pcRefDll, riidInst, IID_PPV_ARG(IClassFactory, theFactory));
203 }
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
#define IID_PPV_ARG(Itype, ppType)

Referenced by SHCreateDefClassObject().

◆ if()

Definition at line 372 of file shell32.cpp.

373  {
375  gModule.Init(ObjectMap, hInstance, &LIBID_Shell32);
376 
378 
379  /* get full path to this DLL for IExtractIconW_fnGetIconLocation() */
381  swShell32Name[MAX_PATH - 1] = '\0';
382 
383  /* Initialize comctl32 */
384  INITCOMMONCONTROLSEX InitCtrls;
385  InitCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
387  InitCommonControlsEx(&InitCtrls);
388 
389  /* Bad idea, initialization in DllMain! */
391  }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
EXTERN_C void InitChangeNotifications(void)
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
HRESULT Init(_ATL_OBJMAP_ENTRY *p, HINSTANCE, const GUID *plibid)
Definition: atlbase.h:797
HINSTANCE hInstance
Definition: charmap.c:20
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
#define ICC_USEREX_CLASSES
Definition: commctrl.h:68
#define ICC_DATE_CLASSES
Definition: commctrl.h:67
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
CShell32Module gModule
Definition: shell32.cpp:305
HINSTANCE shell32_hInstance
Definition: shell32.cpp:361

◆ RegenerateUserEnvironment()

EXTERN_C BOOL WINAPI RegenerateUserEnvironment ( LPVOID lpEnvironment,
BOOL  bUpdateSelf 
)

Definition at line 71 of file shell32.cpp.

72 {
75  return FALSE;
76 
77  BOOL bResult = CreateEnvironmentBlock(lpEnvironment, hUserToken, TRUE);
78  if (!bResult || !lpEnvironment)
79  {
81  return FALSE;
82  }
83 
84  if (bUpdateSelf)
85  {
86  LPWSTR pszz = (LPWSTR)*lpEnvironment;
87  if (!pszz)
88  return FALSE;
89 
90  while (*pszz)
91  {
92  size_t cch = wcslen(pszz);
93  LPWSTR pchEqual = wcschr(pszz, L'=');
94  if (pchEqual)
95  {
96  CStringW strName(pszz, pchEqual - pszz);
97  SetEnvironmentVariableW(strName, pchEqual + 1);
98  }
99  pszz += cch + 1;
100  }
101  }
102 
104 
105  return bResult;
106 }
#define CloseHandle
Definition: compat.h:598
#define TOKEN_WRITE
Definition: setypes.h:899
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:505
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
HANDLE hUserToken
Definition: install.c:39
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
return TRUE
Definition: shell32.cpp:399
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
static const WCHAR L[]
Definition: oid.c:1250
#define TOKEN_READ
Definition: setypes.h:897
#define GetCurrentProcess()
Definition: compat.h:618
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by CDesktopBrowser::OnSettingChange().

◆ SHCreateDefClassObject()

HRESULT WINAPI SHCreateDefClassObject ( REFIID  riid,
LPVOID ppv,
LPFNCREATEINSTANCE  lpfnCI,
LPDWORD  pcRefDll,
REFIID  riidInst 
)

Definition at line 208 of file shell32.cpp.

214 {
215  IClassFactory *pcf;
216  HRESULT hResult;
217 
218  TRACE("%s %p %p %p %s\n", shdebugstr_guid(&riid), ppv, lpfnCI, pcRefDll, shdebugstr_guid(&riidInst));
219 
221  return E_NOINTERFACE;
222  hResult = IDefClF_fnConstructor(lpfnCI, (PLONG)pcRefDll, &riidInst, &pcf);
223  if (FAILED(hResult))
224  return hResult;
225  *ppv = pcf;
226  return S_OK;
227 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
const char * shdebugstr_guid(const struct _GUID *id)
Definition: debughlp.cpp:414
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51
HRESULT IDefClF_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, const IID *riidInst, IClassFactory **theFactory)
Definition: shell32.cpp:200
const GUID IID_IClassFactory
signed int * PLONG
Definition: retypes.h:5
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96

◆ STDAPI_()

STDAPI_ ( BOOL  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ dwReason

DWORD dwReason

Definition at line 369 of file shell32.cpp.

◆ fImpLoad

DWORD LPVOID fImpLoad
Initial value:
{
TRACE("%p 0x%x %p\n", hInstance, dwReason, fImpLoad)
HINSTANCE hInstance
Definition: charmap.c:20
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwReason
Definition: shell32.cpp:369
DWORD LPVOID fImpLoad
Definition: shell32.cpp:370

Definition at line 370 of file shell32.cpp.

◆ gModule

◆ shell32_hInstance

HINSTANCE shell32_hInstance

Definition at line 361 of file shell32.cpp.

Referenced by if(), and RegisterComponent().

◆ TRUE

return TRUE

Definition at line 399 of file shell32.cpp.

Referenced by DllRegisterServer(), DllUnregisterServer(), and RegenerateUserEnvironment().