[SHLWAPI] Sync with Wine 3.0. CORE-14225

This commit is contained in:
Amine Khaldi 2018-01-20 13:15:19 +01:00
parent b2462dae72
commit b7250325e4
6 changed files with 36 additions and 250 deletions

View file

@ -89,174 +89,6 @@ HRESULT WINAPI AssocCreate(CLSID clsid, REFIID refiid, void **lpInterface)
return SHCoCreateInstance( NULL, &clsid, NULL, refiid, lpInterface );
}
struct AssocPerceivedInfo
{
PCWSTR Type;
PERCEIVED Perceived;
INT FlagHardcoded;
INT FlagSoftcoded;
PCWSTR Extensions;
};
static const WCHAR unspecified_exts[] = {
'.','l','n','k',0,
'.','s','e','a','r','c','h','-','m','s',0,
0
};
static const WCHAR image_exts[] = {
'.','b','m','p',0,
'.','d','i','b',0,
'.','e','m','f',0,
'.','g','i','f',0,
'.','i','c','o',0,
'.','j','f','i','f',0,
'.','j','p','e',0,
'.','j','p','e','g',0,
'.','j','p','g',0,
'.','p','n','g',0,
'.','r','l','e',0,
'.','t','i','f',0,
'.','t','i','f','f',0,
'.','w','m','f',0,
0
};
static const WCHAR audio_exts[] = {
'.','a','i','f',0,
'.','a','i','f','c',0,
'.','a','i','f','f',0,
'.','a','u',0,
'.','m','3','u',0,
'.','m','i','d',0,
'.','m','i','d','i',0,
#if _WIN32_WINNT > 0x602
'.','m','p','2',0,
#endif
'.','m','p','3',0,
'.','r','m','i',0,
'.','s','n','d',0,
'.','w','a','v',0,
'.','w','a','x',0,
'.','w','m','a',0,
0
};
static const WCHAR video_exts[] = {
'.','a','s','f',0,
'.','a','s','x',0,
'.','a','v','i',0,
'.','d','v','r','-','m','s',0,
'.','I','V','F',0,
'.','m','1','v',0,
#if _WIN32_WINNT <= 0x602
'.','m','p','2',0,
#endif
'.','m','p','2','v',0,
'.','m','p','a',0,
'.','m','p','e',0,
'.','m','p','e','g',0,
'.','m','p','g',0,
'.','m','p','v','2',0,
'.','w','m',0,
'.','w','m','v',0,
'.','w','m','x',0,
'.','w','v','x',0,
0
};
static const WCHAR compressed_exts[] = {
'.','z','i','p',0,
0
};
static const WCHAR document_exts[] = {
#if _WIN32_WINNT >= 0x600
'.','h','t','m',0,
'.','h','t','m','l',0,
#endif
'.','m','h','t',0,
0
};
static const WCHAR system_exts[] = {
'.','c','p','l',0,
0
};
static const WCHAR application_exts[] = {
'.','b','a','s',0,
'.','b','a','t',0,
'.','c','m','d',0,
'.','c','o','m',0,
'.','e','x','e',0,
'.','h','t','a',0,
'.','m','s','i',0,
'.','p','i','f',0,
'.','r','e','g',0,
'.','s','c','r',0,
'.','v','b',0,
0
};
const WCHAR type_text[] = {'t','e','x','t',0};
const WCHAR type_image[] = {'i','m','a','g','e',0};
const WCHAR type_audio[] = {'a','u','d','i','o',0};
const WCHAR type_video[] = {'v','i','d','e','o',0};
const WCHAR type_compressed[] = {'c','o','m','p','r','e','s','s','e','d',0};
const WCHAR type_document[] = {'d','o','c','u','m','e','n','t',0};
const WCHAR type_system[] = {'s','y','s','t','e','m',0};
const WCHAR type_application[] = {'a','p','p','l','i','c','a','t','i','o','n',0};
#define HARDCODED_NATIVE_WMSDK (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_WMSDK)
#define HARDCODED_NATIVE_GDIPLUS (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_GDIPLUS)
#define HARDCODED_NATIVE_ZIPFLDR (PERCEIVEDFLAG_HARDCODED | PERCEIVEDFLAG_NATIVESUPPORT | PERCEIVEDFLAG_ZIPFOLDER)
#define SOFTCODED_NATIVESUPPORT (PERCEIVEDFLAG_SOFTCODED | PERCEIVEDFLAG_NATIVESUPPORT)
static const struct AssocPerceivedInfo known_types[] = {
{ NULL, PERCEIVED_TYPE_UNSPECIFIED, PERCEIVEDFLAG_HARDCODED, PERCEIVEDFLAG_SOFTCODED, unspecified_exts },
{ type_text, PERCEIVED_TYPE_TEXT, PERCEIVEDFLAG_HARDCODED, SOFTCODED_NATIVESUPPORT, NULL },
{ type_image, PERCEIVED_TYPE_IMAGE, HARDCODED_NATIVE_GDIPLUS, PERCEIVEDFLAG_SOFTCODED, image_exts },
{ type_audio, PERCEIVED_TYPE_AUDIO, HARDCODED_NATIVE_WMSDK, PERCEIVEDFLAG_SOFTCODED, audio_exts },
{ type_video, PERCEIVED_TYPE_VIDEO, HARDCODED_NATIVE_WMSDK, PERCEIVEDFLAG_SOFTCODED, video_exts },
{ type_compressed, PERCEIVED_TYPE_COMPRESSED, HARDCODED_NATIVE_ZIPFLDR, PERCEIVEDFLAG_SOFTCODED, compressed_exts },
{ type_document, PERCEIVED_TYPE_DOCUMENT, PERCEIVEDFLAG_HARDCODED, PERCEIVEDFLAG_SOFTCODED, document_exts },
{ type_system, PERCEIVED_TYPE_SYSTEM, PERCEIVEDFLAG_HARDCODED, PERCEIVEDFLAG_SOFTCODED, system_exts },
{ type_application, PERCEIVED_TYPE_APPLICATION, PERCEIVEDFLAG_HARDCODED, PERCEIVEDFLAG_SOFTCODED, application_exts },
};
static const struct AssocPerceivedInfo* AssocFindByBuiltinExtension(LPCWSTR pszExt)
{
UINT n;
for (n = 0; n < sizeof(known_types) / sizeof(known_types[0]); ++n)
{
PCWSTR Ext = known_types[n].Extensions;
while (Ext && *Ext)
{
if (!StrCmpIW(Ext, pszExt))
return &known_types[n];
Ext += (strlenW(Ext) + 1);
}
}
return NULL;
}
static const struct AssocPerceivedInfo* AssocFindByType(LPCWSTR pszType)
{
UINT n;
for (n = 0; n < sizeof(known_types) / sizeof(known_types[0]); ++n)
{
if (known_types[n].Type)
{
if (!StrCmpIW(known_types[n].Type, pszType))
return &known_types[n];
}
}
return NULL;
}
/*************************************************************************
* AssocGetPerceivedType [SHLWAPI.@]
*
@ -278,64 +110,19 @@ static const struct AssocPerceivedInfo* AssocFindByType(LPCWSTR pszType)
* lppszType is optional and it can be NULL.
* if lpType or lpFlag are NULL, the function will crash.
* if lpszExt is NULL, an error is returned.
*
* BUGS
* Unimplemented.
*/
HRESULT WINAPI AssocGetPerceivedType(LPCWSTR lpszExt, PERCEIVED *lpType,
INT *lpFlag, LPWSTR *lppszType)
{
static const WCHAR PerceivedTypeKey[] = {'P','e','r','c','e','i','v','e','d','T','y','p','e',0};
static const WCHAR SystemFileAssociationsKey[] = {'S','y','s','t','e','m','F','i','l','e',
'A','s','s','o','c','i','a','t','i','o','n','s','\\','%','s',0};
const struct AssocPerceivedInfo *Info;
FIXME("(%s, %p, %p, %p) not supported\n", debugstr_w(lpszExt), lpType, lpFlag, lppszType);
TRACE("(%s,%p,%p,%p)\n", debugstr_w(lpszExt), lpType, lpFlag, lppszType);
Info = AssocFindByBuiltinExtension(lpszExt);
if (Info)
{
*lpType = Info->Perceived;
*lpFlag = Info->FlagHardcoded;
}
else
{
WCHAR Buffer[100] = { 0 };
DWORD Size = sizeof(Buffer);
if (RegGetValueW(HKEY_CLASSES_ROOT, lpszExt, PerceivedTypeKey,
RRF_RT_REG_SZ, NULL, Buffer, &Size) == ERROR_SUCCESS)
{
Info = AssocFindByType(Buffer);
}
if (!Info)
{
WCHAR KeyName[MAX_PATH] = { 0 };
snprintfW(KeyName, MAX_PATH, SystemFileAssociationsKey, lpszExt);
Size = sizeof(Buffer);
if (RegGetValueW(HKEY_CLASSES_ROOT, KeyName, PerceivedTypeKey,
RRF_RT_REG_SZ, NULL, Buffer, &Size) == ERROR_SUCCESS)
{
Info = AssocFindByType(Buffer);
}
}
if (Info)
{
*lpType = Info->Perceived;
*lpFlag = Info->FlagSoftcoded;
}
}
if (Info)
{
if (lppszType && Info->Type)
{
return SHStrDupW(Info->Type, lppszType);
}
return Info->Type ? S_OK : E_FAIL;
}
else
{
*lpType = PERCEIVED_TYPE_UNSPECIFIED;
*lpFlag = 0;
}
if (lpszExt == NULL)
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
return E_NOTIMPL;
}
/*************************************************************************

View file

@ -54,19 +54,19 @@ static inline LPDATABLOCK_HEADER NextItem(LPDBLIST lpList)
* the call returns S_OK but does not actually add the element.
* See SHWriteDataBlockList.
*/
BOOL WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem)
HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem)
{
LPDATABLOCK_HEADER lpInsertAt = NULL;
ULONG ulSize;
TRACE("(%p,%p)\n", lppList, lpNewItem);
if(!lppList || !lpNewItem)
return FALSE;
if(!lppList || !lpNewItem )
return E_INVALIDARG;
if (lpNewItem->cbSize < sizeof(DATABLOCK_HEADER) ||
lpNewItem->dwSignature == CLIST_ID_CONTAINER)
return FALSE;
return S_OK;
ulSize = lpNewItem->cbSize;
@ -123,9 +123,9 @@ BOOL WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem)
lpInsertAt = NextItem(lpInsertAt);
lpInsertAt->cbSize = 0;
return TRUE;
return lpNewItem->cbSize;
}
return FALSE;
return S_OK;
}
/*************************************************************************
@ -343,7 +343,7 @@ VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList)
*/
BOOL WINAPI SHRemoveDataBlock(LPDBLIST* lppList, DWORD dwSignature)
{
LPDATABLOCK_HEADER lpList = NULL;
LPDATABLOCK_HEADER lpList = 0;
LPDATABLOCK_HEADER lpItem = NULL;
LPDATABLOCK_HEADER lpNext;
ULONG ulNewSize;

View file

@ -78,12 +78,6 @@ HANDLE WINAPI SHMapHandle(HANDLE hShared, DWORD dwSrcProcId, DWORD dwDstProcId,
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();

View file

@ -527,17 +527,25 @@ int WINAPI PathGetDriveNumberA(LPCSTR lpszPath)
*
* See PathGetDriveNumberA.
*/
int WINAPI PathGetDriveNumberW(LPCWSTR lpszPath)
int WINAPI PathGetDriveNumberW(const WCHAR *path)
{
TRACE ("(%s)\n",debugstr_w(lpszPath));
WCHAR drive;
if (lpszPath)
{
WCHAR tl = tolowerW(lpszPath[0]);
if (tl >= 'a' && tl <= 'z' && lpszPath[1] == ':')
return tl - 'a';
}
return -1;
static const WCHAR nt_prefixW[] = {'\\','\\','?','\\'};
TRACE("(%s)\n", debugstr_w(path));
if (!path)
return -1;
if (!strncmpW(path, nt_prefixW, 4))
path += 4;
drive = tolowerW(path[0]);
if (drive < 'a' || drive > 'z' || path[1] != ':')
return -1;
return drive - 'a';
}
/*************************************************************************
@ -1643,7 +1651,7 @@ BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
* Although this function is prototyped as returning a BOOL, it returns
* FILE_ATTRIBUTE_DIRECTORY for success. This means that code such as:
*
*| if (PathIsDirectoryA("c:\\windows\\") != FALSE)
*| if (PathIsDirectoryA("c:\\windows\\") == TRUE)
*| ...
*
* will always fail.

View file

@ -154,7 +154,7 @@ HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
if(y->cbSize != sizeof(*y))
return E_INVALIDARG;
while(*ptr && (isalnum(*ptr) || *ptr == '-'))
while(*ptr && (isalnum(*ptr) || *ptr == '-' || *ptr == '+' || *ptr == '.'))
ptr++;
if (*ptr != ':' || ptr <= x+1) {
@ -188,7 +188,7 @@ HRESULT WINAPI ParseURLW(LPCWSTR x, PARSEDURLW *y)
if(y->cbSize != sizeof(*y))
return E_INVALIDARG;
while(*ptr && (isalnumW(*ptr) || *ptr == '-'))
while(*ptr && (isalnumW(*ptr) || *ptr == '-' || *ptr == '+' || *ptr == '.'))
ptr++;
if (*ptr != ':' || ptr <= x+1) {
@ -902,10 +902,7 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative,
work = preliminary + base.cchProtocol+1+base.cchSuffix - 1;
if (*work++ != '/')
*(work++) = '/';
if (relative.pszSuffix[0] == '.' && relative.pszSuffix[1] == 0)
*work = 0;
else
strcpyW(work, relative.pszSuffix);
strcpyW(work, relative.pszSuffix);
break;
default:

View file

@ -174,7 +174,7 @@ reactos/dll/win32/shdoclc # Synced to WineStaging-2.9
reactos/dll/win32/shdocvw # Synced to Wine-3.0
reactos/dll/win32/shell32 # Forked at Wine-20071011
reactos/dll/win32/shfolder # Synced to WineStaging-2.9
reactos/dll/win32/shlwapi # Synced to WineStaging-2.16
reactos/dll/win32/shlwapi # Synced to Wine-3.0
reactos/dll/win32/slbcsp # Synced to WineStaging-2.9
reactos/dll/win32/snmpapi # Synced to WineStaging-2.9
reactos/dll/win32/softpub # Synced to WineStaging-2.9