mshtml: Support implicit RT_FILE resource type in res protocol.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47999
Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Damjan Jovanovic 2020-04-24 18:37:44 +02:00 committed by Alexandre Julliard
parent f9da9675f0
commit 3e8bca0eb4
3 changed files with 44 additions and 4 deletions

View File

@ -539,7 +539,7 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
DWORD grfPI, HANDLE_PTR dwReserved)
{
InternetProtocol *This = impl_from_IInternetProtocol(iface);
WCHAR *url_dll, *url_file, *url, *mime, *res_type = (LPWSTR)RT_HTML, *ptr;
WCHAR *url_dll, *url_file, *url, *mime, *res_type, *alt_res_type = NULL, *ptr;
DWORD grfBINDF = 0, len;
BINDINFO bindinfo;
HMODULE hdll;
@ -593,7 +593,8 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
res_type = MAKEINTRESOURCEW(res_type_id);
}else {
url_file = res_type;
res_type = (LPWSTR)RT_HTML;
res_type = MAKEINTRESOURCEW(RT_HTML);
alt_res_type = MAKEINTRESOURCEW(2110 /* RT_FILE */);
}
/* Ignore query and hash parts. */
@ -613,12 +614,16 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
TRACE("trying to find resource type %s, name %s\n", debugstr_w(res_type), debugstr_w(url_file));
src = FindResourceW(hdll, url_file, res_type);
if(!src && alt_res_type)
src = FindResourceW(hdll, url_file, alt_res_type);
if(!src) {
LPWSTR endpoint = NULL;
DWORD file_id = wcstol(url_file, &endpoint, 10);
if(endpoint == url_file+lstrlenW(url_file))
if(!*endpoint) {
src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), res_type);
if(!src && alt_res_type)
src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), alt_res_type);
}
if(!src) {
WARN("Could not find resource\n");
IInternetProtocolSink_ReportResult(pOIProtSink,

View File

@ -262,6 +262,30 @@ static void protocol_start(IInternetProtocol *protocol, const WCHAR *url)
CHECK_CALLED(ReportResult);
}
static void test_res_url_fail(const WCHAR *url_suffix)
{
WCHAR url[INTERNET_MAX_URL_LENGTH];
IInternetProtocol *protocol;
HRESULT hres;
wcscpy(url, res_url_base);
wcscat(url, url_suffix);
hres = CoCreateInstance(&CLSID_ResProtocol, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&protocol);
ok(hres == S_OK, "Could not create ResProtocol instance: %08x\n", hres);
SET_EXPECT(GetBindInfo);
SET_EXPECT(ReportResult);
expect_hr_win32err = TRUE;
hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
ok(HRESULT_FACILITY(hres) == FACILITY_WIN32,
"%s: expected win32 error, got: %08x\n", debugstr_w(url_suffix), hres);
CHECK_CALLED(GetBindInfo);
CHECK_CALLED(ReportResult);
IInternetProtocol_Release(protocol);
}
static void test_res_url(const char *url_suffix)
{
WCHAR url[INTERNET_MAX_URL_LENGTH];
@ -604,6 +628,14 @@ static void test_res_protocol(void)
test_res_url("/23/123");
test_res_url("/jstest.html");
test_res_url("/jstest-rtfile.html");
test_res_url("/#2110/jstest-rtfile.html");
test_res_url("/2110/jstest-rtfile.html");
test_res_url_fail(L"/doesntexist/jstest-rtfile.html");
test_res_url_fail(L"/2/jstest-rtfile.html");
test_res_url_fail(L"/23/jstest-rtfile.html"); /* no fallback from explicit RT_HTML */
test_res_url("/Test/res.html");
test_res_url("/test/dir/dir2/res.html");

View File

@ -28,6 +28,9 @@ asyncscriptload.js HTML "asyncscriptload.js"
/* @makedep: jstest.html */
jstest.html HTML "jstest.html"
/* @makedep: jstest.html */
jstest-rtfile.html 2110 "jstest.html"
/* @makedep: vbtest.html */
vbtest.html HTML "vbtest.html"