From b187c92a85cc036bd5405eb9ec22184184509add Mon Sep 17 00:00:00 2001 From: Sergey Khodych Date: Sat, 7 May 2011 21:12:15 +0300 Subject: [PATCH] mshtml: Add BITMAPFILEHEADER to bitmap resources. --- dlls/mshtml/protocol.c | 40 ++++++++++++++++++++++++++++++++-------- 1 files changed, 32 insertions(+), 8 deletions(-) diff --git a/dlls/mshtml/protocol.c b/dlls/mshtml/protocol.c index 456c3fd..e810427 100644 --- a/dlls/mshtml/protocol.c +++ b/dlls/mshtml/protocol.c @@ -591,10 +591,12 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, ResProtocol *This = ResProtocol_from_IInternetProtocol(iface); DWORD grfBINDF = 0, len; BINDINFO bindinfo; - LPWSTR url_dll, url_file, url, mime, res_type = (LPWSTR)RT_HTML; + LPWSTR url_dll, url_file, url, mime, url_res_type; HMODULE hdll; HRSRC src; HRESULT hres; + DWORD res_size; + ULONG res_type = RT_HTML; static const WCHAR wszRes[] = {'r','e','s',':','/','/'}; @@ -634,13 +636,15 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, *url_file++ = 0; hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE); if(!hdll) { - if (!(res_type = strrchrW(url_dll, '/'))) { + if (!(url_res_type = strrchrW(url_dll, '/'))) { WARN("Could not open dll: %s\n", debugstr_w(url_dll)); IInternetProtocolSink_ReportResult(pOIProtSink, HRESULT_FROM_WIN32(GetLastError()), 0, NULL); heap_free(url); return HRESULT_FROM_WIN32(GetLastError()); } - *res_type++ = 0; + *url_res_type++ = 0; + + res_type = strtolW(url_res_type + 1, NULL, 10); hdll = LoadLibraryExW(url_dll, NULL, LOAD_LIBRARY_AS_DATAFILE); if(!hdll) { @@ -651,11 +655,12 @@ 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)); + TRACE("trying to find resource type %s, name %s\n", debugstr_w(MAKEINTRESOURCEW(res_type)), debugstr_w(url_file)); - src = FindResourceW(hdll, url_file, res_type); + src = FindResourceW(hdll, url_file, MAKEINTRESOURCEW(res_type)); if(!src) { LPWSTR endpoint = NULL; + res_type = RT_HTML; DWORD file_id = strtolW(url_file, &endpoint, 10); if(endpoint == url_file+strlenW(url_file)) src = FindResourceW(hdll, MAKEINTRESOURCEW(file_id), MAKEINTRESOURCEW(RT_HTML)); @@ -674,9 +679,28 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, heap_free(This->data); } - This->data_len = SizeofResource(hdll, src); - This->data = heap_alloc(This->data_len); - memcpy(This->data, LoadResource(hdll, src), This->data_len); + res_size = SizeofResource(hdll, src); + + if ( RT_BITMAP == res_type) + { + /* Gecko engine expects BITMAPFILEHEADER at the beginning of bitmap data*/ + This->data_len += res_size + sizeof(BITMAPFILEHEADER); + This->data = heap_alloc(This->data_len); + memcpy(This->data + sizeof(BITMAPFILEHEADER), LockResource(LoadResource(hdll, src)), res_size); + + BITMAPFILEHEADER *bmFileHeader = (BITMAPFILEHEADER*)This->data; + bmFileHeader->bfType = 0x4D42; + bmFileHeader->bfSize = This->data_len; + bmFileHeader->bfReserved1 = 0; + bmFileHeader->bfReserved2 = 0; + bmFileHeader->bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + } + else + { + This->data_len += res_size; + This->data = heap_alloc(This->data_len); + memcpy(This->data, LockResource(LoadResource(hdll, src)), This->data_len); + } This->cur = 0; FreeLibrary(hdll); -- 1.7.4.rc1