Commit 38bed060 authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

Implement a bunch of shlwapi functions, add some new stubs.

parent 103712f1
......@@ -3,13 +3,20 @@
*/
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "winreg.h"
#include "debugtools.h"
#include "shlwapi.h"
#include "wine/unicode.h"
DEFAULT_DEBUG_CHANNEL(shell);
static const char *lpszContentTypeA = "Content Type";
static const WCHAR lpszContentTypeW[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0'};
/*************************************************************************
* SHRegGetUSValueA [SHLWAPI.@]
*
......@@ -134,13 +141,13 @@ DWORD WINAPI SHGetValueA(
{
HKEY hSubKey;
DWORD res;
TRACE("(%s %s)\n", pSubKey, pValue);
if((res = RegOpenKeyA(hkey, pSubKey, &hSubKey))) return res;
res = RegQueryValueExA(hSubKey, pValue, 0, pwType, pvData, pbData);
RegCloseKey( hSubKey );
return res;
}
......@@ -159,13 +166,13 @@ DWORD WINAPI SHGetValueW(
{
HKEY hSubKey;
DWORD res;
TRACE("(%s %s)\n", debugstr_w(pSubKey), debugstr_w(pValue));
if((res = RegOpenKeyW(hkey, pSubKey, &hSubKey))) return res;
res = RegQueryValueExW(hSubKey, pValue, 0, pwType, pvData, pbData);
RegCloseKey( hSubKey );
return res;
}
......@@ -235,7 +242,7 @@ HRESULT WINAPI SHQueryValueExA(
*
* FIXME
* if the datatype REG_EXPAND_SZ then expand the string and change
* *pdwType to REG_SZ.
* *pdwType to REG_SZ.
*/
HRESULT WINAPI SHQueryValueExW (
HKEY hkey,
......@@ -277,7 +284,7 @@ HRESULT WINAPI SHDeleteKeyA(
/* find how many subkeys there are */
dwKeyCount = 0;
dwMaxSubkeyLen = 0;
r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
&dwMaxSubkeyLen, NULL, NULL, NULL, NULL, NULL, NULL);
if(r != ERROR_SUCCESS)
{
......@@ -389,7 +396,7 @@ DWORD WINAPI SHDeleteEmptyKeyA(HKEY hKey, LPCSTR lpszSubKey)
return r;
dwKeyCount = 0;
r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
r = RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &dwKeyCount,
NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if(r != ERROR_SUCCESS)
return r;
......@@ -419,3 +426,75 @@ DWORD WINAPI SHDeleteEmptyKeyW(HKEY hKey, LPCWSTR lpszSubKey)
return 0;
}
/*************************************************************************
* SHLWAPI_205 [SHLWAPI.205]
*
* Wrapper for SHGetValueA in case machine is in safe mode.
*/
DWORD WINAPI SHLWAPI_205(HKEY hkey, LPCSTR pSubKey, LPCSTR pValue,
LPDWORD pwType, LPVOID pvData, LPDWORD pbData)
{
if (GetSystemMetrics(SM_CLEANBOOT))
return ERROR_INVALID_FUNCTION;
return SHGetValueA(hkey, pSubKey, pValue, pwType, pvData, pbData);
}
/*************************************************************************
* SHLWAPI_206 [SHLWAPI.206]
*
* Unicode version of SHLWAPI_205.
*/
DWORD WINAPI SHLWAPI_206(HKEY hkey, LPCWSTR pSubKey, LPCWSTR pValue,
LPDWORD pwType, LPVOID pvData, LPDWORD pbData)
{
if (GetSystemMetrics(SM_CLEANBOOT))
return ERROR_INVALID_FUNCTION;
return SHGetValueW(hkey, pSubKey, pValue, pwType, pvData, pbData);
}
/*************************************************************************
* SHLWAPI_320 [SHLWAPI.320]
*
*/
BOOL WINAPI SHLWAPI_320(LPCSTR lpszSubKey, LPCSTR lpszValue)
{
DWORD dwLen = strlen(lpszValue);
HRESULT ret = SHSetValueA(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeA,
REG_SZ, lpszValue, dwLen);
return ret ? FALSE : TRUE;
}
/*************************************************************************
* SHLWAPI_321 [SHLWAPI.321]
*
* Unicode version of SHLWAPI_320.
*/
BOOL WINAPI SHLWAPI_321(LPCWSTR lpszSubKey, LPCWSTR lpszValue)
{
DWORD dwLen = strlenW(lpszValue);
HRESULT ret = SHSetValueW(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeW,
REG_SZ, lpszValue, dwLen);
return ret ? FALSE : TRUE;
}
/*************************************************************************
* SHLWAPI_322 [SHLWAPI.322]
*
*/
BOOL WINAPI SHLWAPI_322(LPCSTR lpszSubKey)
{
HRESULT ret = SHDeleteValueA(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeA);
return ret ? FALSE : TRUE;
}
/*************************************************************************
* SHLWAPI_323 [SHLWAPI.323]
*
* Unicode version of SHLWAPI_322.
*/
BOOL WINAPI SHLWAPI_323(LPCWSTR lpszSubKey)
{
HRESULT ret = SHDeleteValueW(HKEY_CLASSES_ROOT, lpszSubKey, lpszContentTypeW);
return ret ? FALSE : TRUE;
}
......@@ -13,6 +13,11 @@
DEFAULT_DEBUG_CHANNEL(shell);
HINSTANCE shlwapi_hInstance = 0;
HMODULE SHLWAPI_hshell32 = 0;
HMODULE SHLWAPI_hwinmm = 0;
HMODULE SHLWAPI_hcomdlg32 = 0;
HMODULE SHLWAPI_hmpr = 0;
HMODULE SHLWAPI_hmlang = 0;
/*************************************************************************
* SHLWAPI LibMain
......@@ -28,6 +33,13 @@ BOOL WINAPI SHLWAPI_LibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad
case DLL_PROCESS_ATTACH:
shlwapi_hInstance = hinstDLL;
break;
case DLL_PROCESS_DETACH:
if (SHLWAPI_hshell32) FreeLibrary(SHLWAPI_hshell32);
if (SHLWAPI_hwinmm) FreeLibrary(SHLWAPI_hwinmm);
if (SHLWAPI_hcomdlg32) FreeLibrary(SHLWAPI_hcomdlg32);
if (SHLWAPI_hmpr) FreeLibrary(SHLWAPI_hmpr);
if (SHLWAPI_hmlang) FreeLibrary(SHLWAPI_hmlang);
break;
}
return TRUE;
}
......
......@@ -13,6 +13,28 @@
DEFAULT_DEBUG_CHANNEL(shell);
static const unsigned char HashDataLookup[256] = {
0x01, 0x0E, 0x6E, 0x19, 0x61, 0xAE, 0x84, 0x77, 0x8A, 0xAA, 0x7D, 0x76, 0x1B,
0xE9, 0x8C, 0x33, 0x57, 0xC5, 0xB1, 0x6B, 0xEA, 0xA9, 0x38, 0x44, 0x1E, 0x07,
0xAD, 0x49, 0xBC, 0x28, 0x24, 0x41, 0x31, 0xD5, 0x68, 0xBE, 0x39, 0xD3, 0x94,
0xDF, 0x30, 0x73, 0x0F, 0x02, 0x43, 0xBA, 0xD2, 0x1C, 0x0C, 0xB5, 0x67, 0x46,
0x16, 0x3A, 0x4B, 0x4E, 0xB7, 0xA7, 0xEE, 0x9D, 0x7C, 0x93, 0xAC, 0x90, 0xB0,
0xA1, 0x8D, 0x56, 0x3C, 0x42, 0x80, 0x53, 0x9C, 0xF1, 0x4F, 0x2E, 0xA8, 0xC6,
0x29, 0xFE, 0xB2, 0x55, 0xFD, 0xED, 0xFA, 0x9A, 0x85, 0x58, 0x23, 0xCE, 0x5F,
0x74, 0xFC, 0xC0, 0x36, 0xDD, 0x66, 0xDA, 0xFF, 0xF0, 0x52, 0x6A, 0x9E, 0xC9,
0x3D, 0x03, 0x59, 0x09, 0x2A, 0x9B, 0x9F, 0x5D, 0xA6, 0x50, 0x32, 0x22, 0xAF,
0xC3, 0x64, 0x63, 0x1A, 0x96, 0x10, 0x91, 0x04, 0x21, 0x08, 0xBD, 0x79, 0x40,
0x4D, 0x48, 0xD0, 0xF5, 0x82, 0x7A, 0x8F, 0x37, 0x69, 0x86, 0x1D, 0xA4, 0xB9,
0xC2, 0xC1, 0xEF, 0x65, 0xF2, 0x05, 0xAB, 0x7E, 0x0B, 0x4A, 0x3B, 0x89, 0xE4,
0x6C, 0xBF, 0xE8, 0x8B, 0x06, 0x18, 0x51, 0x14, 0x7F, 0x11, 0x5B, 0x5C, 0xFB,
0x97, 0xE1, 0xCF, 0x15, 0x62, 0x71, 0x70, 0x54, 0xE2, 0x12, 0xD6, 0xC7, 0xBB,
0x0D, 0x20, 0x5E, 0xDC, 0xE0, 0xD4, 0xF7, 0xCC, 0xC4, 0x2B, 0xF9, 0xEC, 0x2D,
0xF4, 0x6F, 0xB6, 0x99, 0x88, 0x81, 0x5A, 0xD9, 0xCA, 0x13, 0xA5, 0xE7, 0x47,
0xE6, 0x8E, 0x60, 0xE3, 0x3E, 0xB3, 0xF6, 0x72, 0xA2, 0x35, 0xA0, 0xD7, 0xCD,
0xB4, 0x2F, 0x6D, 0x2C, 0x26, 0x1F, 0x95, 0x87, 0x00, 0xD8, 0x34, 0x3F, 0x17,
0x25, 0x45, 0x27, 0x75, 0x92, 0xB8, 0xA3, 0xC8, 0xDE, 0xEB, 0xF8, 0xF3, 0xDB,
0x0A, 0x98, 0x83, 0x7B, 0xE5, 0xCB, 0x4C, 0x78, 0xD1 };
static BOOL URL_NeedEscape(CHAR ch, DWORD dwFlags)
{
......@@ -27,7 +49,7 @@ static BOOL URL_NeedEscape(CHAR ch, DWORD dwFlags)
}
if (ch <= 31 || ch >= 127)
return TRUE;
return TRUE;
else {
switch (ch) {
......@@ -55,7 +77,7 @@ static BOOL URL_NeedEscape(CHAR ch, DWORD dwFlags)
/*************************************************************************
* UrlCanonicalizeA [SHLWAPI]
*/
HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
LPDWORD pcchCanonicalized, DWORD dwFlags)
{
HRESULT hr = S_OK;
......@@ -68,7 +90,7 @@ HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
nLen = strlen(pszUrl);
lpszUrlCpy = HeapAlloc(GetProcessHeap(), 0, nLen + 1);
if (dwFlags & URL_DONT_SIMPLIFY)
memcpy(lpszUrlCpy, pszUrl, nLen + 1);
else {
......@@ -203,7 +225,7 @@ HRESULT WINAPI UrlEscapeW(
FIXME("(%s %p %p 0x%08lx): stub\n",debugstr_w(pszUrl),
pszEscaped, pcchEscaped, dwFlags);
return E_NOTIMPL;
}
}
/*************************************************************************
......@@ -290,3 +312,51 @@ HRESULT WINAPI UrlUnescapeW(
pcchUnescaped, dwFlags);
return E_NOTIMPL;
}
/*************************************************************************
* HashData [SHLWAPI]
*
* Hash an input block into a variable sized digest.
*/
BOOL WINAPI HashData(const unsigned char *lpSrc, INT nSrcLen,
unsigned char *lpDest, INT nDestLen)
{
INT srcCount = nSrcLen - 1, destCount = nDestLen - 1;
if (IsBadReadPtr(lpSrc, nSrcLen) ||
IsBadWritePtr(lpDest, nDestLen))
return FALSE;
while (destCount >= 0)
{
lpDest[destCount] = (destCount & 0xff);
destCount--;
}
while (srcCount >= 0)
{
destCount = nDestLen - 1;
while (destCount >= 0)
{
lpDest[destCount] = HashDataLookup[lpSrc[srcCount] ^ lpDest[destCount]];
destCount--;
}
srcCount--;
}
return TRUE;
}
/*************************************************************************
* UrlHashA [SHLWAPI]
*
* Hash an ASCII URL.
*/
HRESULT WINAPI UrlHashA(LPCSTR pszUrl, unsigned char *lpDest, INT nDestLen)
{
if (IsBadStringPtrA(pszUrl, -1) || IsBadWritePtr(lpDest, nDestLen))
return E_INVALIDARG;
HashData(pszUrl, strlen(pszUrl), lpDest, nDestLen);
return NOERROR;
}
%long
BOOL
COLORREF
DWORD
INT
LONG
HANDLE
HDC
HDROP
HICON
HINSTANCE
HKEY
HMENU
HMODULE
HPALETTE
HRESULT
HWND
LPARAM
LRESULT
UCHAR
UINT
WCHAR
WORD
WPARAM
%long # --forbidden
......@@ -22,19 +30,34 @@ int
%ptr
BOOL *
DLLVERSIONINFO *
HICON *
IStream *
ITEMIDLIST *
IUnknown *
LPBROWSEINFOW
LPBYTE
LPCITEMIDLIST
LPCLSID
LPCVOID
LPDWORD
LPINT
LPITEMIDLIST
LPOPENFILENAMEW
LPPAGESETUPDLGW
LPPRINTDLGW
LPSHELLEXECUTEINFOW
LPSHFILEOPSTRUCTW
LPSTRRET
LPUNKNOWN *
LPVOID
REFIID
REFGUID
SHFILEINFOW *
unsigned char *
void *
WNDCLASSA *
%ptr --extension
......@@ -53,4 +76,5 @@ void
%wstr
LPCWSTR
LPWSTR
\ No newline at end of file
LPWSTR
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment