static HRESULT WINAPI Gstreamer_YUV_QueryConnect(TransformFilter *iface, const AM_MEDIA_TYPE *amt) { GstTfImpl *This = (GstTfImpl*)iface; TRACE("%p %p\n", This, amt); dump_AM_MEDIA_TYPE(amt); if (!IsEqualGUID(&amt->majortype, &MEDIATYPE_Video) || (!IsEqualGUID(&amt->formattype, &FORMAT_VideoInfo) && !IsEqualGUID(&amt->formattype, &FORMAT_VideoInfo2))) return S_FALSE; if (memcmp(&amt->subtype.Data2, &MEDIATYPE_Video.Data2, sizeof(GUID) - sizeof(amt->subtype.Data1))) return S_FALSE; switch (amt->subtype.Data1) { case mmioFOURCC('I','4','2','0'): case mmioFOURCC('Y','V','1','2'): case mmioFOURCC('N','V','1','2'): case mmioFOURCC('N','V','2','1'): case mmioFOURCC('Y','U','Y','2'): case mmioFOURCC('Y','V','Y','U'): return S_OK; default: WARN("Unhandled fourcc %s\n", debugstr_an((char*)&amt->subtype.Data1, 4)); return S_FALSE; } }
static int apply_GSUB_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, WORD *pwOutGlyphs, int write_dir, INT* pcGlyphs, INT cChars, const char* feat, WORD *pwLogClust ) { int i; if (psc->GSUB_Table) { const GSUB_Feature *feature; feature = load_GSUB_feature(hdc, psa, psc, feat); if (!feature) return GSUB_E_NOFEATURE; i = 0; TRACE("applying feature %s\n",debugstr_an(feat,4)); while(i < *pcGlyphs) { INT nextIndex; INT prevCount = *pcGlyphs; nextIndex = GSUB_apply_feature(psc->GSUB_Table, feature, pwOutGlyphs, i, write_dir, pcGlyphs); if (nextIndex > GSUB_E_NOGLYPH) { UpdateClusters(nextIndex, *pcGlyphs - prevCount, write_dir, cChars, pwLogClust); i = nextIndex; } else i++; } return *pcGlyphs; } return GSUB_E_NOFEATURE; }
static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *ctx) { struct d3d_shader_info *shader_info = ctx; HRESULT hr; switch (tag) { case TAG_ISGN: if (FAILED(hr = shader_parse_signature(data, data_size, shader_info->input_signature))) return hr; break; case TAG_OSGN: if (FAILED(hr = shader_parse_signature(data, data_size, shader_info->output_signature))) return hr; break; case TAG_SHDR: shader_info->shader_code = (const DWORD *)data; break; default: FIXME("Unhandled chunk %s\n", debugstr_an((const char *)&tag, 4)); break; } return S_OK; }
/************************************************************************** * mmioCreateChunk [WINMM.@] */ MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO* lpck, UINT uFlags) { DWORD dwOldPos; LONG size; LONG ix; TRACE("(%p, %p, %04X);\n", hmmio, lpck, uFlags); dwOldPos = mmioSeek(hmmio, 0, SEEK_CUR); TRACE("dwOldPos=%d\n", dwOldPos); if (uFlags == MMIO_CREATELIST) lpck->ckid = FOURCC_LIST; else if (uFlags == MMIO_CREATERIFF) lpck->ckid = FOURCC_RIFF; TRACE("ckid=%s\n", debugstr_an((LPSTR)&lpck->ckid, 4)); size = 2 * sizeof(DWORD); lpck->dwDataOffset = dwOldPos + size; if (lpck->ckid == FOURCC_RIFF || lpck->ckid == FOURCC_LIST) size += sizeof(DWORD); lpck->dwFlags = MMIO_DIRTY; ix = mmioWrite(hmmio, (LPSTR)lpck, size); TRACE("after mmioWrite ix = %d req = %d, errno = %d\n", ix, size, errno); if (ix < size) { mmioSeek(hmmio, dwOldPos, SEEK_SET); WARN("return CannotWrite\n"); return MMIOERR_CANNOTWRITE; } return MMSYSERR_NOERROR; }
/****************************************************************** * macho_accum_segs_range * * Callback for macho_enum_load_commands. Accumulates the address * range covered by the segments of a Mach-O file. All commands * are expected to be of LC_SEGMENT type. */ static int macho_accum_segs_range(struct macho_file_map* fmap, const struct load_command* lc, void* user) { const struct segment_command* sc = (const struct segment_command*)lc; unsigned tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1; TRACE("(%p/%d, %p, %p) before: 0x%08x - 0x%08x\n", fmap, fmap->fd, lc, user, (unsigned)fmap->segs_start, (unsigned)fmap->segs_size); TRACE("Segment command vm: 0x%08x - 0x%08x\n", (unsigned)sc->vmaddr, (unsigned)sc->vmaddr + sc->vmsize); if (!strncmp(sc->segname, "WINE_", 5)) { TRACE("Ignoring special Wine segment %s\n", debugstr_an(sc->segname, sizeof(sc->segname))); return 0; } /* If this segment starts before previously-known earliest, record * new earliest. */ if (sc->vmaddr < fmap->segs_start) fmap->segs_start = sc->vmaddr; /* If this segment extends beyond previously-known furthest, record * new furthest. */ tmp = (sc->vmaddr + sc->vmsize + page_mask) & ~page_mask; if (fmap->segs_size < tmp) fmap->segs_size = tmp; TRACE("after: 0x%08x - 0x%08x\n", (unsigned)fmap->segs_start, (unsigned)fmap->segs_size); return 0; }
static BOOL check_blob_strip(DWORD tag, UINT flags) { BOOL add = TRUE; if (flags & D3DCOMPILER_STRIP_TEST_BLOBS) FIXME("Unhandled flag D3DCOMPILER_STRIP_TEST_BLOBS.\n"); switch(tag) { case TAG_RDEF: case TAG_STAT: if (flags & D3DCOMPILER_STRIP_REFLECTION_DATA) add = FALSE; break; case TAG_SDBG: if (flags & D3DCOMPILER_STRIP_DEBUG_INFO) add = FALSE; break; default: break; } TRACE("%s tag %s\n", add ? "Add" : "Skip", debugstr_an((const char *)&tag, 4)); return add; }
/************************************************************ * get_format_info * * Returns information about the specified format. * If the format is unsupported, it's filled with the D3DFMT_UNKNOWN desc. * * PARAMS * format [I] format whose description is queried * */ const struct pixel_format_desc *get_format_info(D3DFORMAT format) { unsigned int i = 0; while(formats[i].format != format && formats[i].format != D3DFMT_UNKNOWN) i++; if (formats[i].format == D3DFMT_UNKNOWN) FIXME("Unknown format %#x (as FOURCC %s).\n", format, debugstr_an((const char *)&format, 4)); return &formats[i]; }
static HRESULT WINAPI IDirectMusicLoaderFileStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten) { ICOM_THIS_MULTI(IDirectMusicLoaderFileStream, StreamVtbl, iface); ULONG cbWrite; TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p)\n", This, pv, cb, pcbWritten); if (This->hFile == INVALID_HANDLE_VALUE) return E_FAIL; if (pcbWritten == NULL) pcbWritten = &cbWrite; if (!WriteFile (This->hFile, pv, cb, pcbWritten, NULL) || *pcbWritten != cb) return E_FAIL; TRACE_(dmfileraw)(": data (size = 0x%08lX): '%s'\n", *pcbWritten, debugstr_an(pv, *pcbWritten)); return S_OK; }
static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size) { AM_MEDIA_TYPE amt; HRESULT hr = S_OK; DDSURFACEDESC sdesc; BITMAPINFOHEADER *bmiHeader; TRACE("(%p)->(%p, %d)\n", This, data, size); sdesc.dwSize = sizeof(sdesc); hr = IPin_ConnectionMediaType(&This->renderer.pInputPin->pin.IPin_iface, &amt); if (FAILED(hr)) { ERR("Unable to retrieve media type\n"); return hr; } if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo)) { bmiHeader = &((VIDEOINFOHEADER *)amt.pbFormat)->bmiHeader; } else if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo2)) { bmiHeader = &((VIDEOINFOHEADER2 *)amt.pbFormat)->bmiHeader; } else { FIXME("Unknown type %s\n", debugstr_guid(&amt.subtype)); return VFW_E_RUNTIME_ERROR; } TRACE("biSize = %d\n", bmiHeader->biSize); TRACE("biWidth = %d\n", bmiHeader->biWidth); TRACE("biHeight = %d\n", bmiHeader->biHeight); TRACE("biPlanes = %d\n", bmiHeader->biPlanes); TRACE("biBitCount = %d\n", bmiHeader->biBitCount); TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(bmiHeader->biCompression), 4)); TRACE("biSizeImage = %d\n", bmiHeader->biSizeImage); if (!This->baseControlWindow.baseWindow.hDC) { ERR("Cannot get DC from window!\n"); return E_FAIL; } TRACE("Src Rect: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom); TRACE("Dst Rect: %d %d %d %d\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom); StretchDIBits(This->baseControlWindow.baseWindow.hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left, This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top, This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top, data, (BITMAPINFO *)bmiHeader, DIB_RGB_COLORS, SRCCOPY); return S_OK; }
static BOOL check_blob_part(DWORD tag, D3D_BLOB_PART part) { BOOL add = FALSE; switch(part) { case D3D_BLOB_INPUT_SIGNATURE_BLOB: if (tag == TAG_ISGN) add = TRUE; break; case D3D_BLOB_OUTPUT_SIGNATURE_BLOB: if (tag == TAG_OSGN) add = TRUE; break; case D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB: if (tag == TAG_ISGN || tag == TAG_OSGN) add = TRUE; break; case D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB: if (tag == TAG_PCSG) add = TRUE; break; case D3D_BLOB_ALL_SIGNATURE_BLOB: if (tag == TAG_ISGN || tag == TAG_OSGN || tag == TAG_PCSG) add = TRUE; break; case D3D_BLOB_DEBUG_INFO: if (tag == TAG_SDBG) add = TRUE; break; case D3D_BLOB_LEGACY_SHADER: if (tag == TAG_Aon9) add = TRUE; break; case D3D_BLOB_XNA_PREPASS_SHADER: if (tag == TAG_XNAP) add = TRUE; break; case D3D_BLOB_XNA_SHADER: if (tag == TAG_XNAS) add = TRUE; break; default: FIXME("Unhandled D3D_BLOB_PART %s.\n", debug_d3dcompiler_d3d_blob_part(part)); break; } TRACE("%s tag %s\n", add ? "Add" : "Skip", debugstr_an((const char *)&tag, 4)); return add; }
static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx) { struct wined3d_shader_signature *is = ctx; switch(tag) { case TAG_ISGN: return shader_parse_signature(data, data_size, is); default: FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4)); return S_OK; } }
HRESULT parse_dxbc(const char *data, SIZE_T data_size, HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) { const char *ptr = data; HRESULT hr = S_OK; DWORD chunk_count; DWORD total_size; unsigned int i; DWORD tag; read_dword(&ptr, &tag); TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4)); if (tag != TAG_DXBC) { WARN("Wrong tag.\n"); return E_INVALIDARG; } /* checksum? */ skip_dword_unknown(&ptr, 4); skip_dword_unknown(&ptr, 1); read_dword(&ptr, &total_size); TRACE("total size: %#x\n", total_size); read_dword(&ptr, &chunk_count); TRACE("chunk count: %#x\n", chunk_count); for (i = 0; i < chunk_count; ++i) { DWORD chunk_tag, chunk_size; const char *chunk_ptr; DWORD chunk_offset; read_dword(&ptr, &chunk_offset); TRACE("chunk %u at offset %#x\n", i, chunk_offset); chunk_ptr = data + chunk_offset; read_dword(&chunk_ptr, &chunk_tag); read_dword(&chunk_ptr, &chunk_size); hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx); if (FAILED(hr)) break; } return hr; }
static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page) { const char *ptr; LPWSTR *param, merge; int len; ptr = get_attr(text, "name", &len); if(!ptr) { WARN("name attr not found\n"); return; } if(!strncasecmp("name", ptr, len)) { param = &item->name; }else if(!strncasecmp("merge", ptr, len)) { param = &merge; }else if(!strncasecmp("local", ptr, len)) { param = &item->local; }else { WARN("unhandled param %s\n", debugstr_an(ptr, len)); return; } ptr = get_attr(text, "value", &len); if(!ptr) { WARN("value attr not found\n"); return; } /* * "merge" parameter data (referencing another CHM file) can be incorporated into the "local" parameter * by specifying the filename in the format: * MS-ITS:file.chm::/local_path.htm */ if(param == &item->local && strstr(ptr, "::")) { const char *local = strstr(ptr, "::")+2; int local_len = len-(local-ptr); item->local = decode_html(local, local_len, code_page); param = &merge; } *param = decode_html(ptr, len, code_page); if(param == &merge) { SetChmPath(&item->merge, hhc_root->merge.chm_file, merge); heap_free(merge); } }
static LPCVOID load_GSUB_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, const char* feat) { const GSUB_Feature *feature; int i; for (i = 0; i < psc->feature_count; i++) if (strncmp(psc->features[i].tag,feat,4)==0) return psc->features[i].feature; feature = NULL; if (psc->GSUB_Table) { const GSUB_Script *script; const GSUB_LangSys *language; script = GSUB_get_script_table(psc->GSUB_Table, get_opentype_script(hdc,psa)); if (script) { language = GSUB_get_lang_table(script, "xxxx"); /* Need to get Lang tag */ if (language) feature = GSUB_get_feature(psc->GSUB_Table, language, feat); } /* try in the default (latin) table */ if (!feature) { script = GSUB_get_script_table(psc->GSUB_Table, "latn"); if (script) { language = GSUB_get_lang_table(script, "xxxx"); /* Need to get Lang tag */ if (language) feature = GSUB_get_feature(psc->GSUB_Table, language, feat); } } } TRACE("Feature %s located at %p\n",debugstr_an(feat,4),feature); psc->feature_count++; if (psc->features) psc->features = HeapReAlloc(GetProcessHeap(), 0, psc->features, psc->feature_count * sizeof(LoadedFeature)); else psc->features = HeapAlloc(GetProcessHeap(), 0, psc->feature_count * sizeof(LoadedFeature)); lstrcpynA(psc->features[psc->feature_count - 1].tag, feat, 5); psc->features[psc->feature_count - 1].feature = feature; return feature; }
/***************************************************************************** * ReadComm (USER.204) */ INT16 WINAPI ReadComm16(INT16 cid,LPSTR lpvBuf,INT16 cbRead) { int status, length; struct DosDeviceStruct *ptr; LPSTR orgBuf = lpvBuf; TRACE("cid %d, ptr %p, length %d\n", cid, lpvBuf, cbRead); if ((ptr = GetDeviceStruct(cid)) == NULL) { FIXME("no handle for cid = %0x!\n",cid); return -1; } if (ptr->suspended) { ptr->commerror = IE_HARDWARE; return -1; } if(0==comm_inbuf(ptr)) SleepEx(1,TRUE); /* read unget character */ if (ptr->unget>=0) { *lpvBuf++ = ptr->unget; ptr->unget = -1; length = 1; } else length = 0; /* read from receive buffer */ while (length < cbRead) { status = ((ptr->ibuf_head < ptr->ibuf_tail) ? ptr->ibuf_size : ptr->ibuf_head) - ptr->ibuf_tail; if (!status) break; if ((cbRead - length) < status) status = cbRead - length; memcpy(lpvBuf, ptr->inbuf + ptr->ibuf_tail, status); ptr->ibuf_tail += status; if (ptr->ibuf_tail >= ptr->ibuf_size) ptr->ibuf_tail = 0; lpvBuf += status; length += status; } TRACE("%s\n", debugstr_an( orgBuf, length )); ptr->commerror = 0; return length; }
/***************************************************************************** * WriteComm (USER.205) */ INT16 WINAPI WriteComm16(INT16 cid, LPSTR lpvBuf, INT16 cbWrite) { int status, length; struct DosDeviceStruct *ptr; TRACE("cid %d, ptr %p, length %d\n", cid, lpvBuf, cbWrite); if ((ptr = GetDeviceStruct(cid)) == NULL) { FIXME("no handle for cid = %0x!\n",cid); return -1; } if (ptr->suspended) { ptr->commerror = IE_HARDWARE; return -1; } TRACE("%s\n", debugstr_an( lpvBuf, cbWrite )); length = 0; while (length < cbWrite) { if ((ptr->obuf_head == ptr->obuf_tail) && (ptr->xmit < 0)) { /* no data queued, try to write directly */ status = COMM16_WriteFile(ptr->handle, lpvBuf, cbWrite - length); if (status > 0) { lpvBuf += status; length += status; continue; } } /* can't write directly, put into transmit buffer */ status = ((ptr->obuf_tail > ptr->obuf_head) ? (ptr->obuf_tail-1) : ptr->obuf_size) - ptr->obuf_head; if (!status) break; if ((cbWrite - length) < status) status = cbWrite - length; memcpy(lpvBuf, ptr->outbuf + ptr->obuf_head, status); ptr->obuf_head += status; if (ptr->obuf_head >= ptr->obuf_size) ptr->obuf_head = 0; lpvBuf += status; length += status; comm_waitwrite(ptr); } ptr->commerror = 0; return length; }
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages) { FIXME("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s,\n" "target %s, sflags %#x, eflags %#x, shader %p, error_messages %p stub!\n", data, data_size, debugstr_a(filename), defines, include, debugstr_a(entrypoint), debugstr_a(target), sflags, eflags, shader, error_messages); TRACE("Shader source:\n%s\n", debugstr_an(data, data_size)); if (error_messages) D3DCreateBlob(1, error_messages); /* zero fill used as string end */ return D3DERR_INVALIDCALL; }
/****************************************************************************** * NtConnectPort [NTDLL.@] * ZwConnectPort [NTDLL.@] */ NTSTATUS WINAPI NtConnectPort( PHANDLE PortHandle, PUNICODE_STRING PortName, PSECURITY_QUALITY_OF_SERVICE SecurityQos, PLPC_SECTION_WRITE WriteSection, PLPC_SECTION_READ ReadSection, PULONG MaximumMessageLength, PVOID ConnectInfo, PULONG pConnectInfoLength) { FIXME("(%p,%s,%p,%p,%p,%p,%p,%p),stub!\n", PortHandle,debugstr_w(PortName->Buffer),SecurityQos, WriteSection,ReadSection,MaximumMessageLength,ConnectInfo, pConnectInfoLength); if (ConnectInfo && pConnectInfoLength) TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength)); return STATUS_NOT_IMPLEMENTED; }
/* Parse the attributes correspond to a list item, including sub-topics. * * Each list item has, at minimum, a param of type "keyword" and two * parameters corresponding to a "sub-topic." For each sub-topic there * must be a "name" param and a "local" param, if there is only one * sub-topic then there isn't really a sub-topic, the index will jump * directly to the requested item. */ static void parse_index_obj_node_param(IndexItem *item, const char *text, UINT code_page) { const char *ptr; LPWSTR *param; int len; ptr = get_attr(text, "name", &len); if(!ptr) { WARN("name attr not found\n"); return; } /* Allocate a new sub-item, either on the first run or whenever a * sub-topic has filled out both the "name" and "local" params. */ if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len))) item_realloc(item, item->nItems+1); if(!strncasecmp("keyword", ptr, len)) { param = &item->keyword; }else if(!item->keyword && !strncasecmp("name", ptr, len)) { /* Some HTML Help index files use an additional "name" parameter * rather than the "keyword" parameter. In this case, the first * occurrence of the "name" parameter is the keyword. */ param = &item->keyword; }else if(!strncasecmp("name", ptr, len)) { item->itemFlags |= 0x01; param = &item->items[item->nItems-1].name; }else if(!strncasecmp("local", ptr, len)) { item->itemFlags |= 0x10; param = &item->items[item->nItems-1].local; }else { WARN("unhandled param %s\n", debugstr_an(ptr, len)); return; } ptr = get_attr(text, "value", &len); if(!ptr) { WARN("value attr not found\n"); return; } *param = decode_html(ptr, len, code_page); }
/************************************************************************** * mmioStringToFOURCCA [WINMM.@] */ FOURCC WINAPI mmioStringToFOURCCA(LPCSTR sz, UINT uFlags) { CHAR cc[4]; int i = 0; for (i = 0; i < 4 && sz[i]; i++) { if (uFlags & MMIO_TOUPPER) { cc[i] = toupper(sz[i]); } else { cc[i] = sz[i]; } } /* Pad with spaces */ while (i < 4) cc[i++] = ' '; TRACE("Got %s\n",debugstr_an(cc,4)); return mmioFOURCC(cc[0],cc[1],cc[2],cc[3]); }
static HRESULT WINAPI IDirectMusicLoaderResourceStream_IStream_Read (LPSTREAM iface, void* pv, ULONG cb, ULONG* pcbRead) { LPBYTE pByte; ICOM_THIS_MULTI(IDirectMusicLoaderResourceStream, StreamVtbl, iface); TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p)\n", This, pv, cb, pcbRead); if ((This->llPos + cb) > This->llMemLength) { WARN_(dmfileraw)(": requested size out of range\n"); return E_FAIL; } pByte = &This->pbMemData[This->llPos]; memcpy (pv, pByte, cb); This->llPos += cb; /* move pointer */ /* FIXME: error checking would be nice */ if (pcbRead) *pcbRead = cb; TRACE_(dmfileraw)(": data (size = 0x%08lX): '%s'\n", cb, debugstr_an(pv, cb)); return S_OK; }
/************************************************************************** * UrlMkSetSessionOption (URLMON.@) */ HRESULT WINAPI UrlMkSetSessionOption(DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD Reserved) { TRACE("(%x %p %x)\n", dwOption, pBuffer, dwBufferLength); switch(dwOption) { case URLMON_OPTION_USERAGENT: { LPWSTR new_user_agent; char *buf = pBuffer; DWORD len, size; if(!pBuffer || !dwBufferLength) return E_INVALIDARG; for(len=0; len<dwBufferLength && buf[len]; len++); TRACE("Setting user agent %s\n", debugstr_an(buf, len)); size = MultiByteToWideChar(CP_ACP, 0, buf, len, NULL, 0); new_user_agent = heap_alloc((size+1)*sizeof(WCHAR)); if(!new_user_agent) return E_OUTOFMEMORY; MultiByteToWideChar(CP_ACP, 0, buf, len, new_user_agent, size); new_user_agent[size] = 0; EnterCriticalSection(&session_cs); heap_free(user_agent); user_agent = new_user_agent; LeaveCriticalSection(&session_cs); break; } default: FIXME("Unknown option %x\n", dwOption); return E_INVALIDARG; } return S_OK; }
/****************************************************************************** * NtRequestWaitReplyPort [NTDLL.@] * ZwRequestWaitReplyPort [NTDLL.@] */ NTSTATUS WINAPI NtRequestWaitReplyPort( HANDLE PortHandle, PLPC_MESSAGE pLpcMessageIn, PLPC_MESSAGE pLpcMessageOut) { FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut); if(pLpcMessageIn) { TRACE("Message to send:\n"); TRACE("\tDataSize = %u\n",pLpcMessageIn->DataSize); TRACE("\tMessageSize = %u\n",pLpcMessageIn->MessageSize); TRACE("\tMessageType = %u\n",pLpcMessageIn->MessageType); TRACE("\tVirtualRangesOffset = %u\n",pLpcMessageIn->VirtualRangesOffset); TRACE("\tClientId.UniqueProcess = %p\n",pLpcMessageIn->ClientId.UniqueProcess); TRACE("\tClientId.UniqueThread = %p\n",pLpcMessageIn->ClientId.UniqueThread); TRACE("\tMessageId = %lu\n",pLpcMessageIn->MessageId); TRACE("\tSectionSize = %lu\n",pLpcMessageIn->SectionSize); TRACE("\tData = %s\n", debugstr_an((const char*)pLpcMessageIn->Data,pLpcMessageIn->DataSize)); } return STATUS_NOT_IMPLEMENTED; }
static HRESULT find_mime_from_buffer(const BYTE *buf, DWORD size, const WCHAR *proposed_mime, WCHAR **ret_mime) { LPCWSTR ret = NULL; DWORD len, i; static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0}; static const WCHAR text_richtextW[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0}; static const WCHAR audio_basicW[] = {'a','u','d','i','o','/','b','a','s','i','c',0}; static const WCHAR audio_wavW[] = {'a','u','d','i','o','/','w','a','v',0}; static const WCHAR image_gifW[] = {'i','m','a','g','e','/','g','i','f',0}; static const WCHAR image_pjpegW[] = {'i','m','a','g','e','/','p','j','p','e','g',0}; static const WCHAR image_tiffW[] = {'i','m','a','g','e','/','t','i','f','f',0}; static const WCHAR image_xpngW[] = {'i','m','a','g','e','/','x','-','p','n','g',0}; static const WCHAR image_bmpW[] = {'i','m','a','g','e','/','b','m','p',0}; static const WCHAR video_aviW[] = {'v','i','d','e','o','/','a','v','i',0}; static const WCHAR video_mpegW[] = {'v','i','d','e','o','/','m','p','e','g',0}; static const WCHAR app_postscriptW[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0}; static const WCHAR app_pdfW[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0}; static const WCHAR app_xzipW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0}; static const WCHAR app_xgzipW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0}; static const WCHAR app_javaW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', 'j','a','v','a',0}; static const WCHAR app_xmsdownloadW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', 'x','-','m','s','d','o','w','n','l','o','a','d',0}; static const WCHAR text_plainW[] = {'t','e','x','t','/','p','l','a','i','n','\0'}; static const WCHAR app_octetstreamW[] = {'a','p','p','l','i','c','a','t','i','o','n','/', 'o','c','t','e','t','-','s','t','r','e','a','m','\0'}; static const struct { LPCWSTR mime; BOOL (*filter)(const BYTE *,DWORD); } mime_filters[] = { {text_htmlW, text_html_filter}, {text_richtextW, text_richtext_filter}, /* {audio_xaiffW, audio_xaiff_filter}, */ {audio_basicW, audio_basic_filter}, {audio_wavW, audio_wav_filter}, {image_gifW, image_gif_filter}, {image_pjpegW, image_pjpeg_filter}, {image_tiffW, image_tiff_filter}, {image_xpngW, image_xpng_filter}, /* {image_xbitmapW, image_xbitmap_filter}, */ {image_bmpW, image_bmp_filter}, /* {image_xjgW, image_xjg_filter}, */ /* {image_xemfW, image_xemf_filter}, */ /* {image_xwmfW, image_xwmf_filter}, */ {video_aviW, video_avi_filter}, {video_mpegW, video_mpeg_filter}, {app_postscriptW, application_postscript_filter}, /* {app_base64W, application_base64_filter}, */ /* {app_macbinhex40W, application_macbinhex40_filter}, */ {app_pdfW, application_pdf_filter}, /* {app_zcompressedW, application_xcompressed_filter}, */ {app_xzipW, application_xzip_filter}, {app_xgzipW, application_xgzip_filter}, {app_javaW, application_java_filter}, {app_xmsdownloadW, application_xmsdownload}, {text_plainW, text_plain_filter}, {app_octetstreamW, application_octet_stream_filter} }; if(!buf || !size) { if(!proposed_mime) return E_FAIL; len = strlenW(proposed_mime)+1; *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); if(!*ret_mime) return E_OUTOFMEMORY; memcpy(*ret_mime, proposed_mime, len*sizeof(WCHAR)); return S_OK; } if(proposed_mime && strcmpW(proposed_mime, app_octetstreamW)) { for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) { if(!strcmpW(proposed_mime, mime_filters[i].mime)) break; } if(i == sizeof(mime_filters)/sizeof(*mime_filters) || mime_filters[i].filter(buf, size)) { len = strlenW(proposed_mime)+1; *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); if(!*ret_mime) return E_OUTOFMEMORY; memcpy(*ret_mime, proposed_mime, len*sizeof(WCHAR)); return S_OK; } } i=0; while(!ret) { if(mime_filters[i].filter(buf, size)) ret = mime_filters[i].mime; i++; } TRACE("found %s for %s\n", debugstr_w(ret), debugstr_an((const char*)buf, min(32, size))); if(proposed_mime) { if(i == sizeof(mime_filters)/sizeof(*mime_filters)) ret = proposed_mime; /* text/html is a special case */ if(!strcmpW(proposed_mime, text_htmlW) && !strcmpW(ret, text_plainW)) ret = text_htmlW; } len = strlenW(ret)+1; *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); if(!*ret_mime) return E_OUTOFMEMORY; memcpy(*ret_mime, ret, len*sizeof(WCHAR)); return S_OK; }
static HRESULT WINAPI AVIDec_SetMediaType(TransformFilter *tf, PIN_DIRECTION dir, const AM_MEDIA_TYPE * pmt) { AVIDecImpl* This = (AVIDecImpl*)tf; HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED; TRACE("(%p)->(%p)\n", This, pmt); if (dir != PINDIR_INPUT) return S_OK; /* Check root (GUID w/o FOURCC) */ if ((IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) && (!memcmp(((const char *)&pmt->subtype)+4, ((const char *)&MEDIATYPE_Video)+4, sizeof(GUID)-4))) { VIDEOINFOHEADER *format1 = (VIDEOINFOHEADER *)pmt->pbFormat; VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)pmt->pbFormat; BITMAPINFOHEADER *bmi; if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) bmi = &format1->bmiHeader; else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) bmi = &format2->bmiHeader; else goto failed; TRACE("Fourcc: %s\n", debugstr_an((const char *)&pmt->subtype.Data1, 4)); This->hvid = ICLocate(pmt->majortype.Data1, pmt->subtype.Data1, bmi, NULL, ICMODE_DECOMPRESS); if (This->hvid) { AM_MEDIA_TYPE* outpmt = &This->tf.pmt; const CLSID* outsubtype; DWORD bih_size; DWORD output_depth = bmi->biBitCount; DWORD result; FreeMediaType(outpmt); switch(bmi->biBitCount) { case 32: outsubtype = &MEDIASUBTYPE_RGB32; break; case 24: outsubtype = &MEDIASUBTYPE_RGB24; break; case 16: outsubtype = &MEDIASUBTYPE_RGB565; break; case 8: outsubtype = &MEDIASUBTYPE_RGB8; break; default: WARN("Non standard input depth %d, forced output depth to 32\n", bmi->biBitCount); outsubtype = &MEDIASUBTYPE_RGB32; output_depth = 32; break; } /* Copy bitmap header from media type to 1 for input and 1 for output */ bih_size = bmi->biSize + bmi->biClrUsed * 4; This->pBihIn = CoTaskMemAlloc(bih_size); if (!This->pBihIn) { hr = E_OUTOFMEMORY; goto failed; } This->pBihOut = CoTaskMemAlloc(bih_size); if (!This->pBihOut) { hr = E_OUTOFMEMORY; goto failed; } memcpy(This->pBihIn, bmi, bih_size); memcpy(This->pBihOut, bmi, bih_size); /* Update output format as non compressed bitmap */ This->pBihOut->biCompression = 0; This->pBihOut->biBitCount = output_depth; This->pBihOut->biSizeImage = This->pBihOut->biWidth * This->pBihOut->biHeight * This->pBihOut->biBitCount / 8; TRACE("Size: %u\n", This->pBihIn->biSize); result = ICDecompressQuery(This->hvid, This->pBihIn, This->pBihOut); if (result != ICERR_OK) { ERR("Unable to found a suitable output format (%d)\n", result); goto failed; } /* Update output media type */ CopyMediaType(outpmt, pmt); outpmt->subtype = *outsubtype; if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) memcpy(&(((VIDEOINFOHEADER *)outpmt->pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize); else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) memcpy(&(((VIDEOINFOHEADER2 *)outpmt->pbFormat)->bmiHeader), This->pBihOut, This->pBihOut->biSize); else assert(0); TRACE("Connection accepted\n"); return S_OK; } TRACE("Unable to find a suitable VFW decompressor\n"); } failed: TRACE("Connection refused\n"); return hr; }
/************************************************************************* * StrToOleStrN [SHELL32.79] * lpMulti, nMulti, nWide [IN] * lpWide [OUT] */ static BOOL StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr) { TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr); return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide); }
static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **error_messages) { int ret; HRESULT hr = S_OK; const D3D_SHADER_MACRO *def = defines; static const struct wpp_callbacks wpp_callbacks = { wpp_lookup_mem, wpp_open_mem, wpp_close_mem, wpp_read_mem, wpp_write_mem, wpp_error, wpp_warning, }; if (def != NULL) { while (def->Name != NULL) { wpp_add_define(def->Name, def->Definition); def++; } } current_include = include; includes_size = 0; wpp_output_size = wpp_output_capacity = 0; wpp_output = NULL; wpp_set_callbacks(&wpp_callbacks); wpp_messages_size = wpp_messages_capacity = 0; wpp_messages = NULL; current_shader.buffer = data; current_shader.size = data_size; initial_filename = filename ? filename : ""; ret = wpp_parse(initial_filename, NULL); if (!wpp_close_output()) ret = 1; if (ret) { TRACE("Error during shader preprocessing\n"); if (wpp_messages) { int size; ID3DBlob *buffer; TRACE("Preprocessor messages:\n%s\n", debugstr_a(wpp_messages)); if (error_messages) { size = strlen(wpp_messages) + 1; hr = D3DCreateBlob(size, &buffer); if (FAILED(hr)) goto cleanup; CopyMemory(ID3D10Blob_GetBufferPointer(buffer), wpp_messages, size); *error_messages = buffer; } } if (data) TRACE("Shader source:\n%s\n", debugstr_an(data, data_size)); hr = E_FAIL; } cleanup: /* Remove the previously added defines */ if (defines != NULL) { while (defines->Name != NULL) { wpp_del_define(defines->Name); defines++; } } HeapFree(GetProcessHeap(), 0, wpp_messages); return hr; }
static HRESULT find_mime_from_buffer(const BYTE *buf, DWORD size, const WCHAR *proposed_mime, const WCHAR *url, WCHAR **ret_mime) { int len, i, any_pos_mime = -1; const WCHAR *ret = NULL; if(!buf || !size) { if(!proposed_mime) return E_FAIL; len = strlenW(proposed_mime)+1; *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); if(!*ret_mime) return E_OUTOFMEMORY; memcpy(*ret_mime, proposed_mime, len*sizeof(WCHAR)); return S_OK; } if(proposed_mime && (!strcmpW(proposed_mime, app_octetstreamW) || !strcmpW(proposed_mime, text_plainW))) proposed_mime = NULL; if(proposed_mime) { ret = proposed_mime; for(i=0; i < sizeof(mime_filters_any_pos)/sizeof(*mime_filters_any_pos); i++) { if(!strcmpW(proposed_mime, mime_filters_any_pos[i].mime)) { any_pos_mime = i; for(len=size; len>0; len--) { if(mime_filters_any_pos[i].filter(buf+size-len, len)) break; } if(!len) ret = NULL; break; } } if(i == sizeof(mime_filters_any_pos)/sizeof(*mime_filters_any_pos)) { for(i=0; i < sizeof(mime_filters)/sizeof(*mime_filters); i++) { if(!strcmpW(proposed_mime, mime_filters[i].mime)) { if(!mime_filters[i].filter(buf, size)) ret = NULL; break; } } } } /* Looks like a bug in native implementation, html and xml mimes * are not looked for if none of them was proposed */ if(!proposed_mime || any_pos_mime!=-1) { for(len=size; !ret && len>0; len--) { for(i=0; i<sizeof(mime_filters_any_pos)/sizeof(*mime_filters_any_pos); i++) { if(mime_filters_any_pos[i].filter(buf+size-len, len)) { ret = mime_filters_any_pos[i].mime; break; } } } } i=0; while(!ret) { if(mime_filters[i].filter(buf, size)) ret = mime_filters[i].mime; i++; } if(any_pos_mime!=-1 && ret==text_plainW) ret = mime_filters_any_pos[any_pos_mime].mime; else if(proposed_mime && ret==app_octetstreamW) { for(len=size; ret==app_octetstreamW && len>0; len--) { if(!is_text_plain_char(buf[size-len])) break; for(i=0; i<sizeof(mime_filters_any_pos)/sizeof(*mime_filters_any_pos); i++) { if(mime_filters_any_pos[i].filter(buf+size-len, len)) { ret = text_plainW; break; } } } if(ret == app_octetstreamW) ret = proposed_mime; } if(url && (ret == app_octetstreamW || ret == text_plainW)) { WCHAR *url_mime; HRESULT hres; hres = find_mime_from_url(url, &url_mime); if(SUCCEEDED(hres)) { if(!is_known_mime_type(url_mime)) { *ret_mime = url_mime; return hres; } CoTaskMemFree(url_mime); } } TRACE("found %s for %s\n", debugstr_w(ret), debugstr_an((const char*)buf, min(32, size))); len = strlenW(ret)+1; *ret_mime = CoTaskMemAlloc(len*sizeof(WCHAR)); if(!*ret_mime) return E_OUTOFMEMORY; memcpy(*ret_mime, ret, len*sizeof(WCHAR)); return S_OK; }
/**************************************************************************** * get_download_name */ static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str) { int len; char *p; DWORD size; size = GetFontData(dev->hdc, MS_MAKE_TAG('n','a','m','e'), 0, NULL, 0); if(size != 0 && size != GDI_ERROR) { BYTE *name = HeapAlloc(GetProcessHeap(), 0, size); if(name) { USHORT count, i; BYTE *strings; struct { USHORT platform_id; USHORT encoding_id; USHORT language_id; USHORT name_id; USHORT length; USHORT offset; } *name_record; GetFontData(dev->hdc, MS_MAKE_TAG('n','a','m','e'), 0, name, size); count = GET_BE_WORD(name + 2); strings = name + GET_BE_WORD(name + 4); name_record = (typeof(name_record))(name + 6); for(i = 0; i < count; i++, name_record++) { name_record->platform_id = GET_BE_WORD(&name_record->platform_id); name_record->encoding_id = GET_BE_WORD(&name_record->encoding_id); name_record->language_id = GET_BE_WORD(&name_record->language_id); name_record->name_id = GET_BE_WORD(&name_record->name_id); name_record->length = GET_BE_WORD(&name_record->length); name_record->offset = GET_BE_WORD(&name_record->offset); if(name_record->platform_id == 1 && name_record->encoding_id == 0 && name_record->language_id == 0 && name_record->name_id == 6) { TRACE("Got Mac PS name %s\n", debugstr_an((char*)strings + name_record->offset, name_record->length)); *str = HeapAlloc(GetProcessHeap(), 0, name_record->length + 1); memcpy(*str, strings + name_record->offset, name_record->length); *(*str + name_record->length) = '\0'; HeapFree(GetProcessHeap(), 0, name); return; } if(name_record->platform_id == 3 && name_record->encoding_id == 1 && name_record->language_id == 0x409 && name_record->name_id == 6) { WCHAR *unicode = HeapAlloc(GetProcessHeap(), 0, name_record->length + 2); DWORD len; int c; for(c = 0; c < name_record->length / 2; c++) unicode[c] = GET_BE_WORD(strings + name_record->offset + c * 2); unicode[c] = 0; TRACE("Got Windows PS name %s\n", debugstr_w(unicode)); len = WideCharToMultiByte(1252, 0, unicode, -1, NULL, 0, NULL, NULL); *str = HeapAlloc(GetProcessHeap(), 0, len); WideCharToMultiByte(1252, 0, unicode, -1, *str, len, NULL, NULL); HeapFree(GetProcessHeap(), 0, unicode); HeapFree(GetProcessHeap(), 0, name); return; } } TRACE("Unable to find PostScript name\n"); HeapFree(GetProcessHeap(), 0, name); } } len = strlen((char*)potm + (ptrdiff_t)potm->otmpFullName) + 1; *str = HeapAlloc(GetProcessHeap(),0,len); strcpy(*str, (char*)potm + (ptrdiff_t)potm->otmpFullName); p = *str; while((p = strchr(p, ' '))) *p = '_'; return; }
/****************************************************************************** * URLMoniker_BindToStorage ******************************************************************************/ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName, IBindCtx* pbc, VOID** ppvObject) { HRESULT hres; BINDINFO bi; DWORD bindf; WCHAR szFileName[MAX_PATH + 1]; Binding *bind; int len; WARN("(%s %p %p)\n", debugstr_w(URLName), pbc, ppvObject); bind = heap_alloc_zero(sizeof(Binding)); bind->lpVtbl = &BindingVtbl; bind->ref = 1; URLMON_LockModule(); len = lstrlenW(URLName)+1; bind->URLName = heap_alloc(len*sizeof(WCHAR)); memcpy(bind->URLName, URLName, len*sizeof(WCHAR)); hres = UMCreateStreamOnCacheFile(bind->URLName, 0, szFileName, &bind->hCacheFile, &bind->pstrCache); if(SUCCEEDED(hres)) { TRACE("Created stream...\n"); *ppvObject = (void *) bind->pstrCache; IStream_AddRef((IStream *) bind->pstrCache); hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&bind->pbscb); if(SUCCEEDED(hres)) { TRACE("Got IBindStatusCallback...\n"); memset(&bi, 0, sizeof(bi)); bi.cbSize = sizeof(bi); bindf = 0; hres = IBindStatusCallback_GetBindInfo(bind->pbscb, &bindf, &bi); if(SUCCEEDED(hres)) { URL_COMPONENTSW url; WCHAR *host, *path, *user, *pass; DWORD dwService = 0; BOOL bSuccess; TRACE("got bindinfo. bindf = %08x extrainfo = %s bindinfof = %08x bindverb = %08x iid %s\n", bindf, debugstr_w(bi.szExtraInfo), bi.grfBindInfoF, bi.dwBindVerb, debugstr_guid(&bi.iid)); hres = IBindStatusCallback_OnStartBinding(bind->pbscb, 0, (IBinding*)bind); TRACE("OnStartBinding rets %08x\n", hres); bind->expected_size = 0; bind->total_read = 0; memset(&url, 0, sizeof(url)); url.dwStructSize = sizeof(url); url.dwSchemeLength = url.dwHostNameLength = url.dwUrlPathLength = url.dwUserNameLength = url.dwPasswordLength = 1; InternetCrackUrlW(URLName, 0, ICU_ESCAPE, &url); host = heap_alloc((url.dwHostNameLength + 1) * sizeof(WCHAR)); memcpy(host, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR)); host[url.dwHostNameLength] = '\0'; path = heap_alloc((url.dwUrlPathLength + 1) * sizeof(WCHAR)); memcpy(path, url.lpszUrlPath, url.dwUrlPathLength * sizeof(WCHAR)); path[url.dwUrlPathLength] = '\0'; if (url.dwUserNameLength) { user = heap_alloc(((url.dwUserNameLength + 1) * sizeof(WCHAR))); memcpy(user, url.lpszUserName, url.dwUserNameLength * sizeof(WCHAR)); user[url.dwUserNameLength] = 0; } else { user = 0; } if (url.dwPasswordLength) { pass = heap_alloc(((url.dwPasswordLength + 1) * sizeof(WCHAR))); memcpy(pass, url.lpszPassword, url.dwPasswordLength * sizeof(WCHAR)); pass[url.dwPasswordLength] = 0; } else { pass = 0; } do { bind->hinternet = InternetOpenA("User Agent", 0, NULL, NULL, 0); if (!bind->hinternet) { hres = HRESULT_FROM_WIN32(GetLastError()); break; } switch ((DWORD) url.nScheme) { case INTERNET_SCHEME_FTP: if (!url.nPort) url.nPort = INTERNET_DEFAULT_FTP_PORT; dwService = INTERNET_SERVICE_FTP; break; case INTERNET_SCHEME_GOPHER: if (!url.nPort) url.nPort = INTERNET_DEFAULT_GOPHER_PORT; dwService = INTERNET_SERVICE_GOPHER; break; } bind->hconnect = InternetConnectW(bind->hinternet, host, url.nPort, user, pass, dwService, 0, (DWORD_PTR)bind); if (!bind->hconnect) { hres = HRESULT_FROM_WIN32(GetLastError()); CloseHandle(bind->hinternet); break; } hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, 0x22, NULL); hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL); hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_CONNECTING, NULL); hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_SENDINGREQUEST, NULL); bSuccess = FALSE; switch (dwService) { case INTERNET_SERVICE_GOPHER: bind->hrequest = GopherOpenFileW(bind->hconnect, path, 0, INTERNET_FLAG_RELOAD, 0); if (bind->hrequest) bSuccess = TRUE; else hres = HRESULT_FROM_WIN32(GetLastError()); break; case INTERNET_SERVICE_FTP: bind->hrequest = FtpOpenFileW(bind->hconnect, path, GENERIC_READ, FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD, 0); if (bind->hrequest) bSuccess = TRUE; else hres = HRESULT_FROM_WIN32(GetLastError()); break; } if(bSuccess) { TRACE("res = %d gle = %u url len = %d\n", hres, GetLastError(), bind->expected_size); IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_CACHEFILENAMEAVAILABLE, szFileName); while(1) { char buf[4096]; DWORD bufread; if(InternetReadFile(bind->hrequest, buf, sizeof(buf), &bufread)) { TRACE("read %d bytes %s...\n", bufread, debugstr_an(buf, 10)); if(bufread == 0) break; hres = Binding_MoreCacheData(bind, buf, bufread); } else break; } InternetCloseHandle(bind->hrequest); hres = S_OK; } InternetCloseHandle(bind->hconnect); InternetCloseHandle(bind->hinternet); } while(0); Binding_FinishedDownload(bind, hres); Binding_CloseCacheDownload(bind); heap_free(user); heap_free(pass); heap_free(path); heap_free(host); } } } IBinding_Release((IBinding*)bind); return hres; }