2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/list.h"
27 #include "wine/unicode.h"
35 #define GENERATE_MSHTML_NS_FAILURE(code) \
36 ((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
38 #define NS_OK ((nsresult)0x00000000L)
39 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
40 #define NS_NOINTERFACE ((nsresult)0x80004002L)
41 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
42 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
43 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
44 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
46 #define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
48 #define NS_FAILED(res) ((res) & 0x80000000)
49 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
53 #define MSHTML_E_NODOC 0x800a025c
55 typedef struct HTMLDOMNode HTMLDOMNode;
56 typedef struct ConnectionPoint ConnectionPoint;
57 typedef struct BSCallback BSCallback;
58 typedef struct nsChannelBSC nsChannelBSC;
59 typedef struct event_target_t event_target_t;
61 /* NOTE: make sure to keep in sync with dispex.c */
71 typedef struct dispex_data_t dispex_data_t;
76 const tid_t iface_tids[];
77 } dispex_static_data_t;
80 const IDispatchExVtbl *lpIDispatchExVtbl;
84 dispex_static_data_t *data;
87 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
91 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
92 const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
93 const IDispatchExVtbl *lpIDispatchExVtbl;
98 nsIDOMWindow *nswindow;
100 IHTMLEventObj *event;
112 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
114 ConnectionPoint *cp_list;
116 } ConnectionPointContainer;
118 struct ConnectionPoint {
119 const IConnectionPointVtbl *lpConnectionPointVtbl;
121 IConnectionPointContainer *container;
126 IPropertyNotifySink *propnotif;
132 ConnectionPoint *next;
136 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
144 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
149 } HTMLOptionElementFactory;
151 struct HTMLDocument {
152 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
153 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
154 const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
155 const IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
156 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
157 const IPersistFileVtbl *lpPersistFileVtbl;
158 const IMonikerPropVtbl *lpMonikerPropVtbl;
159 const IOleObjectVtbl *lpOleObjectVtbl;
160 const IOleDocumentVtbl *lpOleDocumentVtbl;
161 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
162 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
163 const IViewObject2Vtbl *lpViewObject2Vtbl;
164 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
165 const IServiceProviderVtbl *lpServiceProviderVtbl;
166 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
167 const IOleControlVtbl *lpOleControlVtbl;
168 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
169 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
170 const ICustomDocVtbl *lpCustomDocVtbl;
174 NSContainer *nscontainer;
177 IOleClientSite *client;
178 IDocHostUIHandler *hostui;
179 IOleInPlaceSite *ipsite;
180 IOleInPlaceFrame *frame;
181 IOleInPlaceUIWindow *ip_window;
183 IOleUndoManager *undomgr;
185 nsChannelBSC *bscallback;
188 struct list bindings;
190 struct list script_hosts;
195 DOCHOSTUIINFO hostinfo;
198 READYSTATE readystate;
199 BOOL in_place_active;
203 BOOL container_locked;
209 ConnectionPointContainer cp_container;
210 ConnectionPoint cp_htmldocevents;
211 ConnectionPoint cp_htmldocevents2;
212 ConnectionPoint cp_propnotif;
214 HTMLOptionElementFactory *option_factory;
215 HTMLLocation *location;
217 struct list selection_list;
218 struct list range_list;
224 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
229 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
230 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
231 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
232 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
233 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
234 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
235 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
236 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
238 nsEventListener blur_listener;
239 nsEventListener focus_listener;
240 nsEventListener keypress_listener;
241 nsEventListener load_listener;
242 nsEventListener node_insert_listener;
244 nsIWebBrowser *webbrowser;
245 nsIWebNavigation *navigation;
246 nsIBaseWindow *window;
247 nsIWebBrowserFocus *focus;
250 nsIController *editor_controller;
257 nsIURIContentListener *content_listener;
261 nsChannelBSC *bscallback; /* hack */
262 HWND reset_focus; /* hack */
266 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
267 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
272 nsIHttpChannel *http_channel;
274 nsIInputStream *post_data_stream;
275 nsILoadGroup *load_group;
276 nsIInterfaceRequestor *notif_callback;
277 nsLoadFlags load_flags;
278 nsIURI *original_uri;
284 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
285 void (*destructor)(HTMLDOMNode*);
289 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
290 const NodeImplVtbl *vtbl;
296 event_target_t *event_target;
303 ConnectionPointContainer cp_container;
305 const IHTMLElementVtbl *lpHTMLElementVtbl;
306 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
308 nsIDOMHTMLElement *nselem;
314 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
319 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
320 #define HTMLWINDOW3(x) ((IHTMLWindow3*) &(x)->lpHTMLWindow3Vtbl)
322 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
323 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
324 #define HTMLDOC4(x) ((IHTMLDocument4*) &(x)->lpHTMLDocument4Vtbl)
325 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
326 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
327 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
328 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
329 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
330 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
331 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
332 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
333 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
334 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
335 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
336 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
337 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
338 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
339 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
340 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
341 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
342 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
343 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
344 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
345 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
347 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
348 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
349 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
350 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
351 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
352 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
353 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
354 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
355 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
357 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
358 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
359 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
361 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
362 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
363 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
365 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
366 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
367 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
369 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
371 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
372 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
374 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
376 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
377 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
379 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
380 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
382 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
383 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
384 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
385 HTMLLocation *HTMLLocation_Create(HTMLDocument*);
386 IOmNavigator *OmNavigator_Create(void);
387 void setup_nswindow(HTMLWindow*);
389 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
390 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
391 void HTMLDocument_Persist_Init(HTMLDocument*);
392 void HTMLDocument_OleCmd_Init(HTMLDocument*);
393 void HTMLDocument_OleObj_Init(HTMLDocument*);
394 void HTMLDocument_View_Init(HTMLDocument*);
395 void HTMLDocument_Window_Init(HTMLDocument*);
396 void HTMLDocument_Service_Init(HTMLDocument*);
397 void HTMLDocument_Hlink_Init(HTMLDocument*);
399 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
400 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
401 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
403 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
404 void NSContainer_Release(NSContainer*);
406 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
407 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
408 void notif_focus(HTMLDocument*);
410 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
411 void hide_tooltip(HTMLDocument*);
412 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
414 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
416 BOOL load_gecko(BOOL);
417 void close_gecko(void);
418 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
419 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
420 BOOL install_wine_gecko(BOOL);
422 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
424 void call_property_onchanged(ConnectionPoint*,DISPID);
425 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
427 void *nsalloc(size_t);
430 void nsACString_Init(nsACString*,const char*);
431 void nsACString_SetData(nsACString*,const char*);
432 PRUint32 nsACString_GetData(const nsACString*,const char**);
433 void nsACString_Finish(nsACString*);
435 void nsAString_Init(nsAString*,const PRUnichar*);
436 void nsAString_SetData(nsAString*,const PRUnichar*);
437 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
438 void nsAString_Finish(nsAString*);
440 nsIInputStream *create_nsstream(const char*,PRInt32);
441 nsICommandParams *create_nscommand_params(void);
442 nsIMutableArray *create_nsarray(void);
443 nsIWritableVariant *create_nsvariant(void);
444 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
445 void get_editor_controller(NSContainer*);
446 void init_nsevents(NSContainer*);
447 nsresult get_nsinterface(nsISupports*,REFIID,void**);
454 void check_event_attr(HTMLDocument*,nsIDOMElement*);
455 void release_event_target(event_target_t*);
456 void fire_event(HTMLDocument*,eventid_t,nsIDOMNode*);
458 void set_document_bscallback(HTMLDocument*,nsChannelBSC*);
459 void set_current_mon(HTMLDocument*,IMoniker*);
460 HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*);
462 HRESULT bind_mon_to_buffer(HTMLDocument*,IMoniker*,void**,DWORD*);
464 nsChannelBSC *create_channelbsc(IMoniker*);
465 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
466 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
467 IMoniker *get_channelbsc_mon(nsChannelBSC*);
469 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
470 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
471 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
472 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
473 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
475 void detach_selection(HTMLDocument*);
476 void detach_ranges(HTMLDocument*);
478 HTMLElement *HTMLElement_Create(nsIDOMNode*);
479 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
480 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
481 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
482 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
483 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
484 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
485 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
486 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
488 void HTMLElement_Init(HTMLElement*);
489 void HTMLElement2_Init(HTMLElement*);
490 void HTMLTextContainer_Init(HTMLTextContainer*);
492 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
493 void HTMLDOMNode_destructor(HTMLDOMNode*);
495 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
496 void HTMLElement_destructor(HTMLDOMNode*);
498 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*,BOOL);
499 void release_nodes(HTMLDocument*);
501 void release_script_hosts(HTMLDocument*);
502 void connect_scripts(HTMLDocument*);
503 void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
504 IDispatch *script_parse_event(HTMLDocument*,LPCWSTR);
506 IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
511 HRESULT (*query)(HTMLDocument*,OLECMD*);
512 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
515 extern const cmdtable_t editmode_cmds[];
517 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
520 #define UPDATE_UI 0x0001
521 #define UPDATE_TITLE 0x0002
523 void update_doc(HTMLDocument *This, DWORD flags);
524 void update_title(HTMLDocument*);
527 void init_editor(HTMLDocument*);
528 void set_ns_editmode(NSContainer*);
529 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
530 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
531 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
532 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
533 void handle_edit_load(HTMLDocument*);
534 HRESULT editor_is_dirty(HTMLDocument*);
535 void set_dirty(HTMLDocument*,VARIANT_BOOL);
537 extern DWORD mshtml_tls;
539 typedef struct task_t {
543 TASK_SETDOWNLOADSTATE,
549 nsChannelBSC *bscallback;
556 task_t *task_queue_head;
557 task_t *task_queue_tail;
558 struct list timer_list;
561 thread_data_t *get_thread_data(BOOL);
562 HWND get_thread_hwnd(void);
563 void push_task(task_t*);
564 void remove_doc_tasks(const HTMLDocument*);
565 DWORD set_task_timer(HTMLDocument*,DWORD,IDispatch*);
567 HRESULT get_typeinfo(tid_t,ITypeInfo**);
568 void release_typelib(void);
569 void call_disp_func(HTMLDocument*,IDispatch*);
571 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
572 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
573 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
574 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
575 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
577 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
579 extern LONG module_ref;
580 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
581 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
583 /* memory allocation functions */
585 static inline void *heap_alloc(size_t len)
587 return HeapAlloc(GetProcessHeap(), 0, len);
590 static inline void *heap_alloc_zero(size_t len)
592 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
595 static inline void *heap_realloc(void *mem, size_t len)
597 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
600 static inline BOOL heap_free(void *mem)
602 return HeapFree(GetProcessHeap(), 0, mem);
605 static inline LPWSTR heap_strdupW(LPCWSTR str)
612 size = (strlenW(str)+1)*sizeof(WCHAR);
613 ret = heap_alloc(size);
614 memcpy(ret, str, size);
620 static inline char *heap_strdupA(const char *str)
627 size = strlen(str)+1;
628 ret = heap_alloc(size);
629 memcpy(ret, str, size);
635 static inline WCHAR *heap_strdupAtoW(const char *str)
642 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
643 ret = heap_alloc(len*sizeof(WCHAR));
644 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
650 static inline char *heap_strdupWtoA(LPCWSTR str)
655 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
656 ret = heap_alloc(size);
657 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
663 HINSTANCE get_shdoclc(void);
665 extern HINSTANCE hInst;