1
0
mirror of https://github.com/UzixLS/KernelEx.git synced 2025-07-18 23:11:19 +03:00

add SHPathPrepareForWrite()

This commit should help for some MMF games which throw following error:
"Cannot load extension DirectoryPacker.mfx".
This commit is contained in:
UzixLS
2018-11-03 16:43:33 +03:00
parent 824f38b281
commit 7a052106c3
4 changed files with 107 additions and 0 deletions

View File

@ -253,6 +253,10 @@ SOURCE=.\shell32\SHParseDisplayName.c
# End Source File
# Begin Source File
SOURCE=.\shell32\SHPathPrepareForWrite.c
# End Source File
# Begin Source File
SOURCE=.\shell32\unishell32.c
# End Source File
# End Group

View File

@ -0,0 +1,99 @@
/*
* KernelEx
* Copyright (C) 2018, Uzix
* Copyright (C) the Wine project
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#if defined(_WIN32_IE) && _WIN32_IE != 0x0601
#undef _WIN32_IE
#endif
#define _WIN32_IE 0x0601
#include <shlobj.h>
#include "common.h"
/* MAKE_EXPORT SHPathPrepareForWriteA_new=SHPathPrepareForWriteA */
HRESULT WINAPI SHPathPrepareForWriteA_new(HWND hwnd, IUnknown *punkEnableModless, LPCSTR pszPathA, DWORD dwFlags)
{
DWORD res;
DWORD err;
LPCSTR realpath;
int len;
CHAR* last_slash;
CHAR* temppath=NULL;
if (dwFlags & ~(SHPPFW_DIRCREATE|SHPPFW_ASKDIRCREATE|SHPPFW_IGNOREFILENAME)) {
/* FIXME: unimplemented flags */
}
/* cut off filename if necessary */
if (dwFlags & SHPPFW_IGNOREFILENAME)
{
last_slash = strrchr(pszPathA, '\\');
if (last_slash == NULL)
len = 1;
else
len = last_slash - pszPathA + 1;
temppath = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR));
if (!temppath)
return E_OUTOFMEMORY;
lstrcpynA(temppath, pszPathA, len);
realpath = temppath;
}
else
{
realpath = pszPathA;
}
/* try to create the directory if asked to */
if (dwFlags & (SHPPFW_DIRCREATE|SHPPFW_ASKDIRCREATE))
{
if (dwFlags & SHPPFW_ASKDIRCREATE) {
/* FIXME: treating SHPPFW_ASKDIRCREATE as SHPPFW_DIRCREATE */
}
SHCreateDirectoryExA(hwnd, realpath, NULL);
}
/* check if we can access the directory */
res = GetFileAttributesA(realpath);
HeapFree(GetProcessHeap(), 0, temppath);
if (res == INVALID_FILE_ATTRIBUTES)
{
err = GetLastError();
if (err == ERROR_FILE_NOT_FOUND)
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
return HRESULT_FROM_WIN32(err);
}
else if (res & FILE_ATTRIBUTE_DIRECTORY)
return S_OK;
else
return HRESULT_FROM_WIN32(ERROR_DIRECTORY);
}
/* MAKE_EXPORT SHPathPrepareForWriteW_new=SHPathPrepareForWriteW */
HRESULT WINAPI SHPathPrepareForWriteW_new(HWND hwnd, IUnknown *punkEnableModless, LPCWSTR pszPathW, DWORD dwFlags)
{
ALLOC_WtoA(pszPath);
return SHPathPrepareForWriteA_new(hwnd, punkEnableModless, pszPathA, dwFlags);
}

View File

@ -56,6 +56,8 @@ static const apilib_named_api shell32_named_apis[] =
DECL_API("SHGetSpecialFolderPathA", SHGetSpecialFolderPathA_new),
DECL_API("SHGetSpecialFolderPathW", SHGetSpecialFolderPathW_new),
DECL_API("SHParseDisplayName", SHParseDisplayName_new),
DECL_API("SHPathPrepareForWriteA", SHPathPrepareForWriteA_new),
DECL_API("SHPathPrepareForWriteW", SHPathPrepareForWriteW_new),
DECL_API("ShellAboutW", ShellAboutW_fwd),
DECL_API("ShellExecuteExW", ShellExecuteExW_fwd),
DECL_API("ShellExecuteW", ShellExecuteW_fwd),

View File

@ -41,6 +41,8 @@ HRESULT WINAPI SHGetSpecialFolderLocation_fix(HWND hwndOwner, int nFolder, LPVOI
BOOL WINAPI SHGetSpecialFolderPathA_new(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
BOOL WINAPI SHGetSpecialFolderPathW_new(HWND hwndOwner, LPWSTR lpszPathW, int nFolder, BOOL fCreate);
HRESULT WINAPI SHParseDisplayName_new(PCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut);
HRESULT WINAPI SHPathPrepareForWriteA_new(HWND hwnd, IUnknown *punkEnableModless, LPCSTR pszPathA, DWORD dwFlags);
HRESULT WINAPI SHPathPrepareForWriteW_new(HWND hwnd, IUnknown *punkEnableModless, LPCWSTR pszPathW, DWORD dwFlags);
FWDPROC ExtractIconExW_fwd;
FWDPROC ExtractIconW_fwd;
FWDPROC FindExecutableW_fwd;