HRESULT WINAPI HookSHGetSpecialFolderLocation(HWND hwndOwner, int nFolder, LPITEMIDLIST *ppidl) { int folder = nFolder & 0xff; if ( CSIDL_APPDATA == folder || CSIDL_LOCAL_APPDATA == folder ) { LPITEMIDLIST pidlnew = NULL; HRESULT result = 0L; if ( appdata_path[0] == L'\0' ) { return TrueSHGetSpecialFolderLocation(hwndOwner, nFolder, ppidl); } if (CSIDL_LOCAL_APPDATA == folder) { result = SHILCreateFromPath( localdata_path, &pidlnew, NULL); } else { result = SHILCreateFromPath(appdata_path, &pidlnew, NULL); } if (result == S_OK) { *ppidl = pidlnew; return result; } } return TrueSHGetSpecialFolderLocation(hwndOwner, nFolder, ppidl); }
ItemIDList ItemIDList::FromPath(const wchar_t* path) { ItemIDList result; if (FAILED(SHILCreateFromPath(path, &result, NULL))) throw std::invalid_argument("Failed to convert the specified path"); return result; }
EXPORT HRESULT WINAPI SHGetSpecialFolderLocationStub(HWND, int, PIDLIST_ABSOLUTE *ppidl) { return SHILCreateFromPath(g_wBuf, ppidl, nullptr); }