diff -urN wine-20050628/ANNOUNCE wine-20050725/ANNOUNCE --- wine-20050628/ANNOUNCE 2005-06-28 16:39:19.000000000 +0200 +++ wine-20050725/ANNOUNCE 2005-07-25 14:22:04.000000000 +0200 @@ -1,14 +1,15 @@ -This is release 20050628 of Wine, a free implementation of Windows on +This is release 20050725 of Wine, a free implementation of Windows on Unix. This is still a developers only release. There are many bugs and unimplemented features. Most applications still do not work correctly. -WHAT'S NEW with Wine-20050628: (see ChangeLog for details) - - Configuration settings moved to the registry. - - Graphical Wine configuration tool is now enabled. - - More MSI and OLE improvements. - - Reorganisation of the DirectDraw directory. - - Initial support for webcams. +WHAT'S NEW with Wine-20050725: (see ChangeLog for details) + - Beginnings of theme support in common controls. + - Many MSHTML improvements. + - A bunch of OLE fixes for InstallShield installers. + - Many Direct3D fixes and improvements. + - Beginnings of LDAP support. + - Various cleanups after removal of the config file. - Lots of bug fixes. See the README file in the distribution for installation instructions. @@ -17,8 +18,8 @@ the release is available at the ftp sites. The sources will be available from the following locations: - http://www.ibiblio.org/pub/Linux/ALPHA/wine/development/Wine-20050628.tar.gz - http://prdownloads.sourceforge.net/wine/Wine-20050628.tar.gz + http://www.ibiblio.org/pub/Linux/ALPHA/wine/development/Wine-20050725.tar.gz + http://prdownloads.sourceforge.net/wine/Wine-20050725.tar.gz It should also be available from any other site that mirrors ibiblio.org. These locations also hold pre-built documentation packages in various diff -urN wine-20050628/ChangeLog wine-20050725/ChangeLog --- wine-20050628/ChangeLog 2005-06-28 16:39:19.000000000 +0200 +++ wine-20050725/ChangeLog 2005-07-25 14:22:04.000000000 +0200 @@ -1,4 +1,2567 @@ ---------------------------------------------------------------- +2005-07-25 Alexandre Julliard + + * dlls/comctl32/updown.c: Frank Richter + Add theming for the up/down control. + + * configure, configure.ac: + Anderson Lizardo + Fixed "broken OpenGL setup" configure check, which used to report + false errors on some systems. + + * dlls/wldap32/init.c, dlls/wldap32/search.c, + dlls/wldap32/winldap_private.h, dlls/wldap32/wldap32.spec: + Hans Leidekker + Implement ldap_search_ext* and ldap_start_tls_s* functions. + + * dlls/comctl32/listview.c: Frank Richter + Use theming for the ListView non-client area. + + * dlls/comctl32/header.c: Frank Richter + Add theming support for header controls. + + * dlls/user/mdi.c: Dmitry Timoshkov + Take into account CS_NOCLOSE window class style and SC_CLOSE system + menu item state while adding MDI system menu buttons and generating + WM_SYSCOMMAND messages. + + * dlls/x11drv/event.c: Dmitry Timoshkov + Take into account CS_NOCLOSE window class style and SC_CLOSE system + menu item state while handling WM_X11DRV_DELETE_WINDOW request. + + * dlls/kernel/Makefile.in, dlls/kernel/kernel32.spec, + dlls/kernel/lzexpand.c, dlls/lzexpand/lz32.spec, + dlls/lzexpand/lzexpand_main.c: + Steven Edwards + Move and forward lz32 functions to kernel32. + + * dlls/kernel/tests/thread.c: + Felix Nawothnig + Fix thread tests on WinME. + +2005-07-24 Alexandre Julliard + + * dlls/shell32/tests/string.c: Paul Vriens + Skip test that crashes on W2K/WinXP/W2K. + + * dlls/ole32/storage32.c, dlls/rpcrt4/rpc_binding.c, + dlls/rpcrt4/rpc_message.c, dlls/rpcrt4/rpc_message.h: + Stefan Huehner + Fix some missing-declarations warnings. + + * dlls/wined3d/directx.c, dlls/wined3d/drawprim.c, + dlls/wined3d/vertexbuffer.c, dlls/wined3d/wined3d_main.c, + dlls/wined3d/wined3d_private.h: + Raphael Junqueira + - add a new settings for vbo support + - use a struct to handle wined3d settings + - prepare VBO using some abstraction APIs + + * dlls/uxtheme/system.c: Frank Richter + OpenThemeData() now always sets the window theme to the handle + returned (even if that is NULL) - previously, it could happen that + when no theme was active or the theme data could not be opened that + the window theme remained became then-dangling (and hence subsequent + calls to GetWindowTheme() would return that bogus theme). + + * dlls/wldap32/bind.c, dlls/wldap32/winldap_private.h, + dlls/wldap32/wldap32.spec: + Hans Leidekker + Implement ldap_sasl_bind* functions. + + * dlls/x11drv/clipboard.c, dlls/x11drv/desktop.c, dlls/x11drv/dib.c: + Stefan Huehner + Fix missing-declarations warnings. + + * include/odbcinst.h: Matthew Davison + Added some definitions to odbcinst.h. + + * dlls/uxtheme/draw.c: Frank Richter + GetThemeBackgroundContentRect() does not use the content margins + alone, it also falls back to the border size or sizing margins, and if + it can't find any possible margins at all, it returns the original + rectangle. + + * tools/winapi/winapi_parser.pm: + Vincent Béron + Make winapi_check learn to parse some constructs with some rarely used + keywords. + + * dlls/shell32/tests/.cvsignore, dlls/shell32/tests/Makefile.in, + dlls/shell32/tests/shell32_test.h, dlls/shell32/tests/shelllink.c, + dlls/shell32/tests/shlexec.c: + Francois Gouget + Get started testing ShellExecute(). + + * dlls/riched20/editor.c, dlls/riched20/editor.h, + dlls/riched20/editstr.h, dlls/riched20/paint.c, + dlls/riched20/style.c: + Phil Krylov + Added EM_GETZOOM and EM_SETZOOM RichEdit message handlers. + + * dlls/commdlg/cdlg16.h, dlls/ddraw/ddraw_private.h, + dlls/kernel/toolhelp.h, dlls/shell32/undocshell.h, include/msi.h, + include/objbase.h, include/ole2.h, include/oleauto.h, + include/winbase.h, include/wininet.h: + Vincent Béron + Remove multiple declarations of the same function, keeping the public + one as reference. + + * dlls/ole32/compobj.spec, dlls/ole32/memlockbytes16.c, + dlls/ole32/ole16.c, dlls/ole32/ole2_16.c: + Marcus Meissner + Implemented IsValidInterface16, CoMemAlloc. + Added debug to HGLOBALLockBytes16_QueryInterface. + + * dlls/ntdll/file.c: Vincent Béron + Use proper macro for using IOKit includes. + + * tools/winapi/winapi_parser.pm: + Vincent Béron + Remove old stuff from winapi_check. + +2005-07-22 Alexandre Julliard + + * dlls/wldap32/wldap32.spec: Francois Gouget + Fix the ldap_search_s prototypes (reported by winapi_check). + + * dlls/comctl32/toolbar.c: Robert Shearman + - Call SetBkMode with the correct value from the NMTBCUSTOMDRAW + structure. + - Don't fill the NMTBCUSTOMDRAW structure in again for + CDDS_POSTPAINT. + - Remove redundant bBtnTransprnt value. + + * dlls/comctl32/toolbar.c: Robert Shearman + - Height is now calculated based on the number of rows, not on the + bounding rect. + - Only call CalcToolbar in AutoSize if it has TBSTYLE_WRAPABLE or + TBSTYLE_EX_UNDOC1 set. + - Remove a bad test in SetButtonWidth that fixes a regression from the + above change in IE. + - Remove unnecessary nHeight data. + - Remove duplicated code in Size by calling AutoSize. + - Remove unnecessary bAutoSize value because SetWindowPos doesn't + generate WM_SIZE when there is nothing to do on both Windows and + Wine. + + * dlls/comctl32/toolbar.c: Robert Shearman + TBSTATE_INDETERMINATE only takes effect if the button is enabled, + otherwise it should just appear like any other disabled button. + + * dlls/comctl32/toolbar.c: Robert Shearman + Native autosizes on inserting/adding buttons, so we should too. + + * dlls/kernel/relay16.c, dlls/ntdll/relay.c: + Added small assembly wrapper to call entry points without having to + worry about their calling convention. + + * dlls/wow32/wow_main.c, include/wownt32.h: + Francois Gouget + Tweak some prototypes to be closer to the PSDK. + + * tools/winapi/win32.api: Francois Gouget + Update win32.api to match the current sources. + + * dlls/ntdll/tests/info.c: Paul Vriens + Use current process if assigned process cannot be opened. + + * dlls/comctl32/toolbar.c: Robert Shearman + The IsValidImageList test is not needed because if it isn't a valid + image list we will have set the bitmap width and height to 1 and it + does the wrong thing when no buttons are present. + + * dlls/wldap32/winldap_private.h, dlls/wldap32/wldap32.h: + Hans Leidekker + Add helper functions for converting LDAPControl structures. + + * dlls/user/winpos.c: + Store the SysIP property using a string to avoid trouble with 16-bit + apps that don't expect an atom. + + * dlls/user/property.c: + Fixed get_window_properties to correctly specify the output buffer in + the server request (spotted by Marcus Meissner). + + * dlls/setupapi/parser.c: + Preserve the spaces before an opening quote in the middle of a token + (reported by Matthew Davison). + + * dlls/ole32/ole2.spec, dlls/ole32/ole2_16.c: + Marcus Meissner + Added OleSetMenuDescriptor16 stub. + + * dlls/ole32/ole2.c, dlls/ole32/ole32.spec: + Marcus Meissner + OleInitializeWOW gets 2 arguments. + + * dlls/comctl32/toolbar.c: Robert Shearman + The calculated button height should include the text height when no + buttons are present. + + * dlls/winspool/info.c, dlls/winspool/winspool.drv.spec, + include/winspool.h: + Huw Davies + Implement the undocumented StartDocDlg[A|W]. These will be used by + StartDoc. + + * dlls/msi/appsearch.c: Aric Stewart + Bail out if the reg key is empty. This prevents us from writing + garbage to the property table. + + * dlls/riched20/run.c: Phil Krylov + Fixed EM_GETCHARFORMAT for selection containing a single character. + + * dlls/riched20/writer.c: Phil Krylov + Fixed an off-by-one error in EM_STREAMOUT handler for non-Unicode + plain text output. + + * dlls/wined3d/drawprim.c: Gerald Pfeifer + Remove unused variable in primitiveConvertToStridedData(). + + * dlls/riched20/editor.c: Phil Krylov + Added some missing but useful items to the TODO list. + + * dlls/ole32/memlockbytes16.c: Marcus Meissner + 16bit COM interfaces are cdecl, not WINAPI. + + * dlls/wined3d/wined3d_main.c: + Raphael Junqueira + - cleanup wined3d settings init (now closing opened registry keys) + - support per application settings + + * libs/unicode/wctomb.c: + Faster implementation of wcstombs that handles overlapping buffers + properly (based on a patch by Dmitry Timoshkov). + + * dlls/wow32/wow32.spec, dlls/wow32/wow_main.c: + We cannot use forwards anymore now that kernel functions are only + exported by ordinal (reported by Marcus Meissner). + + * dlls/kernel/tests/module.c, dlls/wined3d/device.c, + dlls/wined3d/surface.c, dlls/wined3d/wined3d_private.h: + Francois Gouget + Assorted spelling fixes. + + * dlls/dinput/joystick_linuxinput.c: + Daniel Remenak + Correct dinput handling of sliders and non-zero-based axes through the + linux input system. + + * dlls/x11drv/opengl.c: Oliver Stieber + Allow running opengl and DirectX applications without stencil support, + an earlier patch assumed that stencil support was available, but it + isn't in all cases. + + * include/shellapi.h: Francois Gouget + Add some missing SEE_MASK_* flags. + + * dlls/winspool/info.c: Francois Gouget + Make the unistd.h include conditional. + + * dlls/rpcrt4/rpcrt4.spec: Francois Gouget + Fix the NdrVaryingArrayUnmarshall prototype (reported by + winapi_check). + + * dlls/ole32/ifs.h, dlls/ole32/ole16.c, dlls/ole32/storage.c: + Marcus Meissner + 16bit interfaces are cdecl, so drop the WINAPI. + + * dlls/kernel/ne_module.c: + Felix Nawothnig + Convert long to short path in GetModuleFileName16. + + * dlls/wldap32/Makefile.in, dlls/wldap32/search.c, + dlls/wldap32/winldap_private.h, dlls/wldap32/wldap32.spec: + Hans Leidekker + Implement ldap_search* functions. + +2005-07-21 Alexandre Julliard + + * dlls/riched20/writer.c, dlls/wineps/download.c, tools/widl/parser.y: + Stefan Huehner + Change some char* to const char* to fix warnigns. + + * tools/winedump/le.c, tools/winedump/minidump.c: + Stefan Huehner + Fix some -Wsign-compare warnings. + + * dlls/riched20/editor.c: Phil Krylov + Added some useful TRACEs. + + * configure, configure.ac, dlls/Makefile.in, dlls/midimap/.cvsignore, + dlls/midimap/Makefile.in, dlls/midimap/midimap.c, + dlls/midimap/midimap.spec, dlls/winmm/winemm.h, + tools/winapi/win32.api: + Rémi Assailly + Moved midimap to the top-level dlls directory. + + * dlls/riched20/editor.c: Phil Krylov + Allow NULL parameter for WM_SETTEXT in RichEdit. + + * dlls/kernel/relay16.c: + Register functions with no arguments should still be called as stdcall + because of the extra CONTEXT arg. + + * dlls/wldap32/Makefile.in, dlls/wldap32/init.c, + dlls/wldap32/winldap_private.h, dlls/wldap32/wldap32.spec: + Hans Leidekker + Implement ldap_init* and ldap_open* functions. + + * dlls/riched20/editor.c: Phil Krylov + Implemented EM_LINELENGTH RichEdit message. + + * dlls/wldap32/wldap32.h: Hans Leidekker + Add helper functions for converting string arrays into different + encodings. + + * dlls/wined3d/drawprim.c: Oliver Stieber + Correct a problem with the way that FVF vertex arrays containing + blends or orthographic is calculated. + + * dlls/shell32/shfldr_unixfs.c: Troy Rollo + Return attributes for the correct file in the unixfs ParseDisplayName. + + * dlls/msvcrtd/Makefile.in, dlls/msvcrtd/debug.c, + dlls/msvcrtd/tests/debug.c, include/msvcrt/crtdbg.h: + Saulius Krasuckas + - Declare implemented functions inside #ifndef _DEBUG block. + - Make MSVCRTD_operator_new_dbg recognize types of memory blocks. + + * dlls/riched20/caret.c, dlls/riched20/editor.c, + dlls/riched20/editstr.h, dlls/riched20/para.c, dlls/riched20/run.c, + dlls/riched20/writer.c: + Phil Krylov + Added emulation of RichEdit 1.0 behaviour when the 1.0 window class is + being used. This emulation (introduced in M$ RichEdit 3.0) counts + paragraph endings as 2 characters (CR+LF) instead of 1 (CR). + + * include/mshtmhst.idl: James Hawkins + Define the DOCHOSTUIDBLCLK enumeration. + + * dlls/wined3d/drawprim.c: Oliver Stieber + Fixed regression that occurred because changes to texture loading were + committed before changes to textures and states to support the change + were committed. + + * dlls/msi/files.c: Aric Stewart + Use SOURCEDIR instead of PackagePath. Because the PackagePath may be + local, while SOURCEDIR is more proper and will be a full directory. + +2005-07-20 Alexandre Julliard + + * configure, configure.ac, dlls/Makefile.in, + dlls/stdole2.tlb/.cvsignore, dlls/stdole2.tlb/Makefile.in, + dlls/stdole2.tlb/rsrc.rc, dlls/stdole2.tlb/std_ole_v2.idl, + dlls/stdole2.tlb/stdole2.tlb.spec: + Huw Davies + Implement stdole2.tlb. + + * dlls/winspool/info.c: Huw Davies + Lookup the port in the spooler registry key and map it to a unix + filename or a pipe like OpenJob16 does. + + * Make.rules.in, fonts/.cvsignore, fonts/Makefile.in, fonts/genttf.ff: + Robert Shearman + ttf files for bitmap fonts should be generated with an extension of + just "." to work around a quirk in fontforge (with thanks to George + Williams for helping me fix this). + + * dlls/wldap32/bind.c, dlls/wldap32/winldap_private.h, + dlls/wldap32/wldap32.spec: + Hans Leidekker + Implement ldap_simple_bind* and ldap_unbind* functions. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Initial support for the IPersistFolder3 interface. + + * dlls/oleaut32/olepicture.c, dlls/user/cursoricon.c, + dlls/user/exticon.c, dlls/user/user16.c, dlls/user/user_private.h, + include/cursoricon.h: + Get rid of cursoricon.h. + + * dlls/ole32/stubmanager.c: Robert Shearman + Hack around broken state management so InstallShield works. + + * programs/winhelp/En.rc: Daniel Remenak + Changed winhelp file->exit accelerator key from "e" to "x". + + * dlls/version/info.c, dlls/version/tests/info.c: + Paul Vriens + Add tests for VerQueryValue[AW]. + Don't convert the struct to a win16 one in GetFileVersionInfoA. + Convert the struct to win16 in VerQueryValueA (for now). + + * dlls/shell32/shlfolder.c: Michael Jung + Only initialize shell folders via the IPersistFolder3 interface in + SHELL32_CoCreateInitSF if the pidl which specifies the child is of + type 'Folder'. Otherwise fall back to IPersistFolder. + + * dlls/riched20/editor.c, include/richedit.h: + Daniel Remenak + Basic handling of EM_SETTEXTEX. + + * dlls/ntdll/cdrom.c: Vitaliy Margolen + Fix IOCTL_CDROM_RAW_READ ioctl. + +2005-07-19 Alexandre Julliard + + * dlls/wldap32/Makefile.in, dlls/wldap32/bind.c, + dlls/wldap32/winldap_private.h, dlls/wldap32/wldap32.h, + dlls/wldap32/wldap32.spec: + Hans Leidekker + Implement ldap_bind* functions. + + * dlls/oleaut32/typelib.c: Robert Shearman + - Fix VT_BYREF|VT_UNKNOWN return values by comparing the correct value + with VT_UNKNOWN and VT_DISPATCH. + - Better tracing. + + * dlls/oleaut32/typelib.c: Robert Shearman + Return DISP_E_EXCEPTION from ITypeInfo_Invoke on an error in the + called function. + + * dlls/oleaut32/tmarshal.c: Robert Shearman + - IRpcStubBuffer_Disconnect can be called multiple times. + - Release TypeLib when freeing stub buffer. + + * dlls/ole32/marshal.c, dlls/ole32/stubmanager.c: + Robert Shearman + - Always query for the correct stub interface, otherwise we will be + pointing to the completely wrong object when a proxy does a + queryinterface. + - Remove assumption that the stub buffer will handle the lifetime of + the object. + + * server/class.c: + Create the desktop class when needed without requiring a client + request. + + * dlls/oleaut32/oleaut.c, dlls/oleaut32/regsvr.c: + Robert Shearman + Activate ITypeLib, ITypeInfo and IEnumVARIANT Marshalers. + + * dlls/oleaut32/typelib.c: Robert Shearman + Remove RegisterTypeLib hack. + + * dlls/ole32/oleproxy.c: Robert Shearman + Marshal return value from IRemUnknown_RemQueryInterface. + + * dlls/oleaut32/tmarshal.c: Robert Shearman + Fix confusion between number of characters and number of bytes in + unmarshaling BSTRs. Convert it all to characters for consistency with + the BSTR_User* routines. + + * dlls/ole32/rpc.c, dlls/ole32/stubmanager.c: + Robert Shearman + Silence now noisy error messages caused by changes in the way we call + ipid_to_stubmanager. Move the error message to the one place it is + needed. + + * dlls/user/message.c: + Save the scope window for mouse events before overwriting it. + + * dlls/oleaut32/typelib.c: Robert Shearman + Support VT_BYREF|VT_I4 in _copy_arg. + + * dlls/oleaut32/tmarshal.c: Robert Shearman + Marshal and unmarshal TKIND_ENUM and TKIND_ALIAS. + + * dlls/ole32/oleproxy.c: Robert Shearman + - We should be starting with 1 reference. + - IRpcStubBuffer_Disconnect can be called more than once. + + * dlls/rpcrt4/cstub.c: Robert Shearman + IRpcStubBuffer_Disconnect can be called more than once. + + * dlls/ole32/rpc.c, dlls/ole32/tests/marshal.c: + Robert Shearman + By-pass the RPC runtime if possible when calling an STA by posting a + message directly to the apartment window for it to process. Fixes a + deadlock in InstallShield caused by having to create a thread when + freeing an object that comes from an STA apartment. Added tests that + fail without this fix. + + * dlls/ole32/stubmanager.c: Robert Shearman + Delete the stub manager outside of the apartment critical section + because the deletion may require the object to re-enter the + apartment. + + * dlls/winspool/info.c: Huw Davies + Printer handles referring to the same printer should have the same job + queue. + + * dlls/user/controls.h, dlls/user/menu.c, dlls/user/user_main.c, + dlls/user/win.c: + Initialize the various menu global variables on demand instead of at + startup time. + + * tools/winedump/pe.c: Kevin Koltzau + Add support for dumping 64bit PE files. + + * dlls/ntdll/loader.c, include/winnt.h: Kevin Koltzau + Define 64bit PE structures. + + * dlls/x11drv/window.c: + Don't set win gravity, the default should work fine. + + * dlls/shell32/shfldr_unixfs.c: Troy Rollo + When using PATHMODE_UNIX, all files are in the file system. + + * dlls/ole32/compobj.c: Alex Villacís Lasso + Initialize RegisteredClass properly in CoRegisterClassObject to + prevent crash in CoRevokeClassObject when accessing (uninitialized) + pMarshalledData. + + * dlls/wined3d/device.c, dlls/wined3d/wined3d_private.h: + Oliver Stieber + Implement the use of PBuffers for offscreen textures. + + * dlls/oleaut32/olepicture.c: + Alex Villacís Lasso + Fix GIF palette allocation, by relying on ColorCount instead of + SColorResolution. + + * dlls/oleaut32/tests/vartype.c, dlls/oleaut32/vartype.c: + Alex Villacís Lasso + Ensure that underflowing negative float is represented as a positive + 0, just as native oleaut32. + +2005-07-18 Alexandre Julliard + + * dlls/gdi/tests/gdiobj.c: Huw Davies + Test to show that the height returned by GetTextExtentPoint is the + same as tmHeight. + + * dlls/wldap32/Makefile.in, dlls/wldap32/ber.c, + dlls/wldap32/wldap32.spec: + Hans Leidekker + Implement ber_* functions. + + * include/wincrypt.h: Juan Lang + Added a bunch more definitions. + + * dlls/user/controls.h, dlls/user/dialog.c, dlls/user/dialog16.c, + dlls/user/menu.c: + Robert Shearman + Replace calls to DIALOG_GetCharSize with code to do the equivalent + using GdiGetCharDimensions. + + * dlls/gdi/font.c, dlls/gdi/gdi32.spec, dlls/gdi/tests/gdiobj.c, + include/wingdi.h: + Robert Shearman + Implement and test GdiGetCharDimensions. + + * dlls/ttydrv/Makefile.in, dlls/ttydrv/user.c, + dlls/ttydrv/winetty.drv.spec: + Remove some no longer needed stub functions. + + * dlls/user/Makefile.in, dlls/user/clipboard.c, dlls/user/cursoricon.c, + dlls/user/defwnd.c, dlls/user/display.c, dlls/user/driver.c, + dlls/user/focus.c, dlls/user/input.c, dlls/user/message.c, + dlls/user/nonclient.c, dlls/user/painting.c, dlls/user/sysparams.c, + dlls/user/user_main.c, dlls/user/user_private.h, dlls/user/win.c, + dlls/user/winpos.c: + Load the USER driver on demand instead of at user32 load time. + Provide a fallback implementation for all the functions to avoid + having to check for NULL functions everywhere. + + * dlls/mscms/handle.c, dlls/mscms/icc.c, dlls/mscms/mscms_priv.h, + dlls/mscms/profile.c, dlls/mscms/transform.c: + Hans Leidekker + Make lcms support depend on headers _and_ libraries, not just the + headers. + + * dlls/advapi32/advapi32.spec, dlls/advapi32/registry.c, + include/winreg.h: + Felix Nawothnig + Implement RegGetValueA/W. + + * dlls/ntdll/nt.c, include/wine/server_protocol.h, server/protocol.def, + server/registry.c, server/request.h, server/security.h, + server/token.c, server/trace.c: + Robert Shearman + - Change the default user SID to match what was previously returned by + NtQueryInformationToken. + - Implement TokenUser for NtQueryInformationToken. + - Add a function for getting the user's registry path from a SID. + + * dlls/user/sysparams.c, dlls/user/user_main.c, + dlls/user/user_private.h, dlls/x11drv/clipboard.c, dlls/x11drv/dce.c, + dlls/x11drv/settings.c, dlls/x11drv/window.c, + dlls/x11drv/winex11.drv.spec: + Fixed a few prototypes in the USER driver. + + * dlls/rpcrt4/ndr_marshall.c, dlls/rpcrt4/rpcrt4.spec: + Robert Shearman + Add stubs for most of the NDR marshaling functions. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Use CP_UNIXCP instead of CP_ACP when converting paths (Pointed out by + Troy Rollo). + + * dlls/winspool/info.c: Huw Davies + Partial implementation of GetJob. + + * dlls/shell32/classes.c: Michael Jung + Release shell folders only if they were successfully acquired. + + * dlls/oleaut32/tests/vartype.c: + Alex Villacís Lasso + Test for behavior of negative underflow formatting. + + * dlls/wined3d/device.c: Oliver Stieber + Implemented a tidied up IWineD3Device_ColorFill. + + * dlls/comctl32/Makefile.in, dlls/comctl32/propsheet.c: + Frank Richter + Enabled "tab" dialog texture for property sheet pages. + + * dlls/advapi32/tests/registry.c: + Felix Nawothnig + Rewrote the RegGetValue tests for REG_SZ / REG_EXPAND_SZ. + + * dlls/user/sysparams.c: + Load system metrics on demand instead of initializing everything at + user32 load time. + + * dlls/mshtml/Makefile.in, dlls/mshtml/mshtml_private.h, + dlls/mshtml/oleobj.c, dlls/mshtml/olewnd.c, + dlls/mshtml/tests/htmldoc.c, dlls/mshtml/view.c: + Jacek Caban + - Added more tests. + - Make tests pass under Wine. + + * dlls/user/user32.spec, dlls/user/win.c: + Felix Nawothnig + Add stub for SetLayeredWindowAttributes. + + * include/odbcinst.h: Hans Leidekker + Fix some -Wmissing-declarations warnings. + + * dlls/shell32/shfldr.h, dlls/shell32/shfldr_fs.c, + dlls/shell32/shfldr_unixfs.c: + Michael Jung + Append filename extension if necessary in IShellFolder::SetNameOf. + + * libs/port/interlocked.c: Kevin Koltzau + Add x86_64 interlocked functions. + + * include/basetsd.h, include/winnt.h: Kevin Koltzau + Define x86_64 context. + + * dlls/secur32/secur32.c, dlls/secur32/secur32.spec, + include/ntsecapi.h: + Hans Leidekker + Stub implementations for GetUserNameEx{A,W}, TranslateName{A,W}, + LsaCallAuthenticationPackage, LsaConnectUntrusted and + LsaDeregisterLogonProcess. + + * dlls/tapi32/line.c, include/tapi.h: Hans Leidekker + Fix pointer signedness and missing declarations warnings. + + * dlls/comctl32/listview.c: Dimi Paun + Silence uninitialized warnings. + + * include/mscat.h, include/winspool.h: Hans Leidekker + Fix some -Wmissing-declarations warnings. + + * dlls/wsock32/service.c, dlls/wsock32/wsock32.spec, include/nspapi.h: + Hans Leidekker + Stubs for GetAddressByName{A,W}. + + * programs/winetest/Makefile.in: Hans Leidekker + Include the mshtml test. + + * dlls/user/tests/winstation.c: Paul Vriens + Don't run tests on platforms that don't support WindowStation calls. + + * dlls/mscms/tests/profile.c: Paul Vriens + Set size before calling pSetColorProfileElement. + + * dlls/advapi32/tests/registry.c: + Felix Nawothnig + Fix registry tests on Win95. + + * dlls/urlmon/umon.c: Felix Nawothnig + Fix misuse of UrlCombineW. + + * dlls/advapi32/crypt.c, include/wincrypt.h: + Juan Lang + Add/correct a couple definitions, allow hashing nothing. + + * dlls/wined3d/basetexture.c, dlls/wined3d/drawprim.c: + Oliver Stieber + Set mipmap levels correctly (even with ATI's buggy drivers). + + * dlls/wined3d/device.c: Oliver Stieber + Dirty the surface (instead of the texture) when a render targets is + send and endscene is called to make sure that the correct surface is + updated. + + * dlls/mshtml/tests/protocol.c: + Felix Nawothnig + Skip futile tests if CoGetClassObject fails. + +2005-07-15 Alexandre Julliard + + * configure, configure.ac, dlls/wldap32/Makefile.in, + include/config.h.in: + Hans Leidekker + Configure checks for OpenLDAP headers and libraries. + + * dlls/user/sysparams.c: + Added a bunch of utility functions to factor out a lot of the repeated + code in SystemParametersInfoW. + + * dlls/dsound/tests/ds3d.c, dlls/dsound/tests/dsound8.c, + dlls/x11drv/xrender.c: + Stefan Huehner + Fix some sign-compare warnings by choosing correct datatypes. + + * dlls/winmm/winenas/audio.c, dlls/x11drv/scroll.c: + Stefan Huehner + Add some consts to fix discard-qual warnings. + + * dlls/kernel/tests/codepage.c: + Dmitry Timoshkov + Add a test for handling overlapped buffers by WideCharToMultiByte. + + * dlls/version/tests/info.c: Paul Vriens + Added a test, specifically for NT/W2K/XP/W2K3. + + * dlls/uxtheme/draw.c, dlls/uxtheme/system.c: + Frank Richter + Make dialog theme texture setting non-global (ie a per-window + setting). + + * dlls/wined3d/device.c: Oliver Stieber + Fixed a division by 0 in setup_light that occurs with range is zero. + + * dlls/user/nonclient.c, include/wingdi.h: + Frank Richter + Add support for drawing gradient captions. + + * dlls/ntdll/heap.c: Dmitry Timoshkov + Avoid unnecessary casts. + + * include/winuser.h: + Sort the SPI_* constants and remove some duplicates. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Add file type column in detailed shell view. + Make the order of shell view columns 'prefix-compatible' with + shfldr_fs. + Don't remove filename extensions for path pidls in GetDisplayNameOf. + + * dlls/ntdll/ntdll_misc.h, dlls/ntdll/virtual.c: + Dmitry Timoshkov + Make VIRTUAL_HandleFault return an NTSTATUS. + + * dlls/comctl32/listview.c: Kevin Koltzau + Forward some header notifications to parent of listview. + + * dlls/comctl32/propsheet.c: + Thomas Weidenmueller + Support PSM_IDTOINDEX. + + * configure, configure.ac, dlls/mscms/Makefile.in, dlls/mscms/icc.c, + dlls/mscms/lcms_api.h, dlls/mscms/mscms_main.c, dlls/mscms/profile.c, + dlls/mscms/tests/profile.c, dlls/mscms/transform.c, + include/config.h.in: + Hans Leidekker + Link directly to liblcms. + Fix typo in test. + + * dlls/kernel/virtual.c, dlls/ntdll/heap.c, dlls/ntdll/process.c, + dlls/ntdll/virtual.c, include/winnt.h, include/winternl.h: + Dmitry Timoshkov + Use SIZE_T type for size variables in NTDLL when appropriate. + + * dlls/comctl32/comctl_Cn.rc, dlls/comctl32/comctl_Cs.rc, + dlls/comctl32/comctl_De.rc, dlls/comctl32/comctl_En.rc, + dlls/comctl32/comctl_Es.rc, dlls/comctl32/comctl_Fr.rc, + dlls/comctl32/comctl_It.rc, dlls/comctl32/comctl_Ja.rc, + dlls/comctl32/comctl_Ko.rc, dlls/comctl32/comctl_Nl.rc, + dlls/comctl32/comctl_Pl.rc, dlls/comctl32/comctl_Pt.rc, + dlls/comctl32/comctl_Ru.rc, dlls/comctl32/comctl_Si.rc, + dlls/comctl32/comctl_Sv.rc, dlls/comctl32/comctl_Th.rc, + dlls/comctl32/comctl_Uk.rc, dlls/comctl32/propsheet.c: + Thomas Weidenmueller + - Support PSH_WIZARDHASFINISH in wizards. + - Correct tab order of the wizard buttons. + + * dlls/dsound/dsound.c, dlls/dsound/tests/ds3d.c, + dlls/winsock/tests/sock.c, programs/rundll32/rundll32.c: + Stefan Huehner + Fix some write-strings warnings. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Do filename postprocessing in GetDisplayNameOf (Hide filename + extensions if appropriate). + + * dlls/wined3d/device.c: Oliver Stieber + Correct a missplaced #if in IWineD3DDeviceImpl_CleanRender. + + * dlls/comctl32/toolbar.c: Aric Stewart + When adding an image copy the full previous buffer. + Implement replacing an icon with one from a resource. + + * include/wintrust.h: Paul Vriens + Add missing member to WINTRUST_DATA struct. + + * dlls/wininet/internet.c: Robert Shearman + Fix return value of InternetQueryDataAvailable. + + * dlls/winmm/driver.c, dlls/winmm/lolvldrv.c: + Eric Pouech + Get rid of HeapValidate as it's not properly handled by some memory + management tools (Microquill for example). + + * programs/wcmd/wcmdmain.c: Eric Pouech + Ensure msvcrt's io block is passed down from wcmd's parent process to + child process. + + * dlls/gdi/tests/metafile.c: + Felix Nawothnig + Fix the EnumEnhMetaFile tests. + + * dlls/winspool/info.c: Huw Davies + Set the default doc title to that of Windows. + Pass cups the doc title. + + * dlls/wined3d/resource.c, dlls/wined3d/wined3d_private.h: + Oliver Stieber + Implemented Get/Set/Free private data in resource. + + * dlls/wintrust/wintrust_main.c: Paul Vriens + Return TRUST_E_PROVIDER_UNKNOWN until implemented. + +2005-07-14 Alexandre Julliard + + * programs/rundll32/rundll32.c: Detlef Riekenberg + Space is valid between module name and entry point. + + * dlls/kernel/process.c, dlls/ntdll/loader.c, dlls/ntdll/ntdll_misc.h, + dlls/ntdll/path.c, dlls/ntdll/thread.c: + Moved initialization of the default user process parameters to ntdll. + + * dlls/wined3d/cubetexture.c: + Oliver Stieber + Fixed a bug in Preload caused be a missing brace around a for loop, + slightly improved the way that errors are handled by passing back hr + from some function calls. + + * dlls/d3d8/device.c, dlls/d3d8/drawprim.c, dlls/wined3d/device.c, + dlls/wined3d/drawprim.c: + Stefan Huehner + Fix some missing-declarations warnings. + + * dlls/mshtml/oleobj.c, dlls/mshtml/tests/Makefile.in, + dlls/mshtml/tests/htmldoc.c: + Jacek Caban + - Added more tests. + - Make tests pass under Wine. + + * tools/widl/typelib.c: Stefan Huehner + Fix a -Wsign-compare warning. + + * dlls/mshtml/main.c, dlls/mshtml/mshtml.inf, include/mshtml.idl: + Jacek Caban + Added MSHTML library declaration. + + * server/fd.c, server/file.h, server/mailslot.c: + Robert Shearman + Make mailslots use as much of the default async fd implementation as + possible. + + * dlls/kernel/kernel_main.c, dlls/kernel/process.c, dlls/ntdll/nt.c, + dlls/ntdll/ntdll_misc.h, dlls/ntdll/server.c, dlls/ntdll/time.c, + include/wine/server_protocol.h, server/object.h, server/process.c, + server/protocol.def, server/request.c, server/request.h, + server/thread.c, server/trace.c: + Moved the server start time to the init_thread request and got rid of + the init_process request (based on a patch by Felix Nawothnig). + + * dlls/comctl32/imagelist.c: Robert Shearman + Handle CopyImage and other functions failing by not adding the icon + and notifying the caller. + + * dlls/gdi/dib.c: Juan Lang + Release DC in error condition on StretchDIBits. + + * include/richedit.h: Kevin Koltzau + Define GCM_RIGHTMOUSEDROP. + + * programs/winecfg/Nl.rc: Paul Vriens + Update the Dutch translations. + + * programs/winedbg/stack.c: Robert Shearman + Remove additional current process tracking in backtrace_all as it can + refer to freed memory. + + * dlls/mshtml/htmldoc.c, dlls/mshtml/mshtml_private.h, + dlls/mshtml/olewnd.c, dlls/mshtml/view.c: + Jacek Caban + - Better handling of UI and InPlace active state. + - Implemented InPlaceDeactivate. + - THIS macros cleanup. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + Encode/decode certs, with tests. + +2005-07-13 Alexandre Julliard + + * dlls/kernel/process.c, dlls/ntdll/loader.c, dlls/ntdll/ntdll_misc.h, + dlls/ntdll/server.c, dlls/ntdll/thread.c, + include/wine/server_protocol.h, server/process.c, server/process.h, + server/protocol.def, server/thread.c, server/trace.c: + Return the startup info size in the init_thread request, and allocate + the process parameters structure in ntdll instead of kernel. + + * dlls/wined3d/directx.c, dlls/wined3d/utils.c, + dlls/wined3d/wined3d_private.h: + Oliver Stieber + Correct a few formats that were incorrect. + + * include/wincrypt.h: Juan Lang + Add more missing definitions. + + * programs/winecfg/Fr.rc: Jonathan Ernst + Updated winecfg French resources. + + * server/security.h, server/token.c: + Robert Shearman + Store the default DACL in the token. + + * dlls/uuid/uuid.c, include/.cvsignore, include/Makefile.in, + include/downloadmgr.idl: + Jacek Caban + Added downloadmgr.idl. + + * dlls/ntdll/loader.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/relay.c: + Initialize relay debugging earlier on now that the registry is loaded + by the server. + + * dlls/kernel/process.c, include/wine/server_protocol.h, + server/protocol.def, server/request.h, server/thread.c, + server/trace.c: + Get rid of the boot_done request. + + * dlls/wined3d/basetexture.c, dlls/wined3d/cubetexture.c, + dlls/wined3d/device.c, dlls/wined3d/directx.c, + dlls/wined3d/drawprim.c, dlls/wined3d/indexbuffer.c, + dlls/wined3d/resource.c, dlls/wined3d/stateblock.c, + dlls/wined3d/surface.c, dlls/wined3d/swapchain.c, + dlls/wined3d/texture.c, dlls/wined3d/utils.c, + dlls/wined3d/vertexbuffer.c, dlls/wined3d/vertexdeclaration.c, + dlls/wined3d/vertexshader.c, dlls/wined3d/volume.c, + dlls/wined3d/volumetexture.c, dlls/wined3d/wined3d_main.c: + Oliver Stieber + Tidy up some comments and formatting. + + * dlls/winspool/info.c: Huw Davies + Partial implementation of SetJobW. + Set the document title in StartDocPrinter. + + * dlls/kernel/process.c, dlls/ntdll/server.c, + include/wine/server_protocol.h, server/process.c, server/process.h, + server/protocol.def, server/thread.c, server/trace.c: + Already initialize the process in the first init_thread request + instead of waiting for the init_process request. + + * server/handle.c: + Avoid potential crashes when there is no handle table. + + * dlls/msi/action.c, dlls/msi/files.c, dlls/msi/msi.c, + dlls/msi/source.c, dlls/msi/upgrade.c, include/msi.h: + Use the official names for the Unicode string constants. + + * dlls/dplayx/dplay.c, dlls/dplayx/dplay_global.h, dlls/itss/itss.c, + dlls/itss/moniker.c, dlls/itss/storage.c, dlls/qcap/pin.h, + dlls/quartz/enumfilters.c, dlls/quartz/enumregfilters.c, + dlls/quartz/filesource.c, dlls/quartz/filtermapper.c, + dlls/quartz/pin.h, dlls/rpcrt4/rpc_binding.h, + dlls/rpcrt4/rpc_server.c, dlls/shdocvw/shdocvw.h, + dlls/shdocvw/shdocvw_main.c, dlls/shlwapi/tests/clist.c, + dlls/urlmon/tests/url.c, dlls/wininet/internet.c, + dlls/winmm/mciavi/private_mciavi.h, dlls/winmm/mciwave/mciwave.c, + dlls/winmm/playsound.c, dlls/winmm/winealsa/audio.c, + dlls/winmm/winemm.h, dlls/winmm/wineoss/dscapture.c: + Mike McCormack + Interlocked LONG* gcc warning fixes. + + * DEVELOPERS-HINTS, configure, configure.ac, dlls/Makefile.in, + dlls/wldap32/.cvsignore, dlls/wldap32/Makefile.in, + dlls/wldap32/main.c, dlls/wldap32/wldap32.spec: + Hans Leidekker + Beginnings of WLDAP32. + + * tools/winebuild/import.c: Steve Zellers + Fixed leftover import table name in output_import_thunk. + + * dlls/ntdll/critsection.c: Ignore high bit of spin count. + + * dlls/wined3d/device.c, dlls/wined3d/resource.c, + dlls/wined3d/surface.c, dlls/wined3d/vertexbuffer.c, + dlls/wined3d/wined3d_main.c, dlls/wined3d/wined3d_private.h, + include/wine/wined3d_gl.h: + Oliver Stieber + Added basic memory management and tracking to wined3d. + + * include/Makefile.in, include/winldap.h: + Hans Leidekker + Added winldap.h header. + + * dlls/mshtml/mshtml_private.h, dlls/mshtml/olewnd.c: + Jacek Caban + THIS macros cleanup. + + * dlls/mshtml/view.c: Jacek Caban + Call ShowUI and HideUI in UIActivate. + + * dlls/winspool/De.rc, dlls/winspool/winspool.rc, + programs/winecfg/De.rc: + Henning Gerhardt + - Added German winspool resource file. + - Updated German winecfg resource file. + + * tools/widl/write_msft.c: Stefan Huehner + Fix some -Wsign-compare warnings. + +2005-07-12 Alexandre Julliard + + * configure, configure.ac, programs/Makefile.in, + programs/hh/.cvsignore, programs/hh/Makefile.in, programs/hh/main.c: + Jacek Caban + Added hh.exe. + + * dlls/kernel/process.c, include/wine/server_protocol.h, + server/console.c, server/process.c, server/process.h, + server/protocol.def, server/trace.c: + Moved the fields that depends on startup info from the init_process + request to get_startup_info. + + * dlls/user/cursoricon.c: Mike McCormack + Clean up CURSORICON_Load. + + * dlls/ntdll/tests/string.c: Aric Stewart + Both wcschr and wcsrchr should be able to find the terminating + character. + + * include/wine/unicode.h: + Fixed strchrW and strrchrW for a null character (spotted by Aric + Stewart). + + * dlls/dmusic/dmusic_private.h, dlls/dplayx/dpclassfactory.c, + dlls/dplayx/dplaysp.c, dlls/dplayx/dplobby.c, dlls/dplayx/lobbysp.c, + dlls/dpnet/dpnet_main.c, dlls/dpnet/dpnet_private.h, + dlls/dsound/dsound_private.h, dlls/dswave/dswave_private.h, + dlls/itss/itss.c, dlls/itss/moniker.c, dlls/mlang/mlang.c, + dlls/msdmo/dmoreg.c, dlls/netapi32/netbios.c, + dlls/qcap/capturegraph.c, dlls/qcap/enummedia.c, + dlls/qcap/enumpins.c, dlls/qcap/qcap_main.c, dlls/qcap/vfwcapture.c, + dlls/quartz/dsoundrender.c, dlls/quartz/enummedia.c, + dlls/quartz/enumpins.c, dlls/quartz/filtergraph.c, + dlls/quartz/main.c, dlls/quartz/memallocator.c, dlls/quartz/parser.h, + dlls/quartz/systemclock.c, dlls/quartz/transform.h, + dlls/quartz/videorenderer.c: + Mike McCormack + Interlocked LONG* gcc warning fixes. + + * dlls/winspool/info.c: Huw Davies + Forward SetJobA -> SetJobW. + + * dlls/msi/custom.c: Aric Stewart + Further testing shows that when CustomActionData needs to be blank it + is an empty string not ' '. + + * dlls/user/cursoricon.c: Mike McCormack + Remove CURSORICON_SimulateLoadingFromResourceW. + + * dlls/user/cursoricon.c: Mike McCormack + Modify CURSORICON_FindBestIcon/Cursor to use enumerator functions. + + * dlls/user/listbox.c: Robert Shearman + Call SetLastError on errors. + + * dlls/user/text.c: Robert Shearman + - Support right-aligned text in TabbedTextOut. + - Add documentation. + + * programs/winecfg/En.rc, programs/winecfg/Fr.rc, + programs/winecfg/resource.h, programs/winecfg/x11drvdlg.c: + Raphael Junqueira + - add direct3d configuration on winecfg graphics panel + - resync Fr libraries dialog (based on En.rc) + + * dlls/ntdll/wcstring.c: Use the unicode.h functions where possible. + + * dlls/msi/msi.c: Aric Stewart + Use the SourceList functions to get the source path in + ConfigureProductExW. + + * dlls/msi/files.c: Aric Stewart + When working toward install on demand support we need to reset all the + constant values so that multiple install process do not get confused + by leftover values from the previous install. + + * include/commctrl.h: Frank Richter + Added WC_STATIC. + + * dlls/user/listbox.c: Robert Shearman + - Implement LB_SETLOCALE. + - Remove incorrect FIXMEs for LB_USETABSTOPS. + + * dlls/uxtheme/draw.c: Frank Richter + Better viewport origin in DrawThemeParentBackground(). + + * dlls/d3dxof/d3dxof_private.h, dlls/d3dxof/main.c, + dlls/dinput/device_private.h, dlls/dinput/joystick_linuxinput.c, + dlls/dmband/dmband_private.h, dlls/dmcompos/dmcompos_private.h, + dlls/dmime/dmime_private.h, dlls/dmscript/dmscript_private.h, + dlls/dmstyle/dmstyle_private.h, dlls/dmsynth/dmsynth_private.h: + Mike McCormack + Interlocked LONG* gcc warning fixes. + + * dlls/wined3d/device.c, dlls/wined3d/drawprim.c, + dlls/wined3d/surface.c: + Oliver Stieber + Implement UpdateTexture and UpdateSurface in wined3d. + Allow NULL members of WINED3DSURFACE_DESC to be set to Surface_GetDesc + so that the whole structure doesn't have to be filled just to get back + one value. + + * dlls/winspool/.cvsignore, dlls/winspool/En.rc, + dlls/winspool/Makefile.in, dlls/winspool/info.c, + dlls/winspool/winspool.rc, dlls/winspool/wspool.c, + dlls/winspool/wspool.h: + Huw Davies + ScheduleJob for 'file' ports. + + * dlls/msi/dialog.c: Mike McCormack + Display icons in buttons that have them. + + * dlls/mshtml/htmldoc.c, dlls/mshtml/mshtml_private.h, + dlls/mshtml/oleobj.c, dlls/mshtml/olewnd.c, dlls/mshtml/persist.c, + dlls/mshtml/protocol.c, dlls/mshtml/service.c, dlls/mshtml/view.c: + Jacek Caban + - Added stub implementation of IOleCommandTarget. + - Store IDocHostUIHandler in HTMLDocument. + - ActivateMe should be called even if GetContainer failed. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Don't cache child pidls in UnixFolder, but create them on the fly. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + - encode/decode CERT_INFO, with tests + - a few more tests and bugfixes + + * dlls/uxtheme/draw.c: Frank Richter + Correct border rectangle drawing. + + * dlls/uxtheme/system.c: Frank Richter + Don't crash if NULL is passed as the class list to OpenThemeData(). + +2005-07-11 Alexandre Julliard + + * dlls/kernel/oldconfig.c, include/wine/server_protocol.h, + server/protocol.def, server/registry.c, server/request.h, + server/trace.c: + Load the HKEY_CURRENT_USER branch at server startup too. + + * dlls/ntdll/reg.c, dlls/ntdll/sec.c: + Use an SID instead of the user name for the path of the + HKEY_CURRENT_USER key (based on an old patch by Juan Lang). + + * dlls/d3d9/cubetexture.c, dlls/d3d9/surface.c, dlls/d3d9/texture.c, + dlls/wined3d/cubetexture.c, dlls/wined3d/device.c, + dlls/wined3d/surface.c, dlls/wined3d/texture.c, + dlls/wined3d/wined3d_private.h, include/wine/wined3d_interface.h, + include/wine/wined3d_types.h: + Oliver Stieber + Move parameters relating to opengl on the surface structure on to a + glDesciption member. + Removed Level and Target from LoadTexture, and reduced the dependency + on surface->device. + Fixed a couple of compiler warnings in d3d9. + + * dlls/msi/registry.c: Aric Stewart + Properly resize the buffer based on ERROR_MORE_DATA. + Also remember to free the allocated buffer. + + * dlls/kernel/tests/module.c: Paul Vriens + Basic tests for LoadLibraryA and GetProcAddress. + + * dlls/kernel/module.c: + A NULL module handle means 'main exe' in GetProcAddress too. + + * server/hook.c, server/request.c, server/user.h, server/winstation.c: + Store the global hooks table in the desktop object. + + * dlls/shell32/shell32.spec, dlls/shell32/shell32_main.c: + Detlef Riekenberg + Printers_RegisterWindowW / Printers_UnregisterWindow implemented as + stub. + Show the FIXME in Printer_LoadIconsW only when needed. + + * dlls/advpack/advpack.c, dlls/advpack/advpack.spec, include/advpub.h: + Stefan Leichter + Added stubs for ExecuteCab and TranslateInfString. + + * dlls/msi/action.c, dlls/msi/msi.c, dlls/msi/upgrade.c: + Aric Stewart + Use the strings defined in msi.h. + + * dlls/msi/source.c: Aric Stewart + Correct an error where I was not properly advancing a pointer. + + * dlls/mshtml/mshtml.inf: Jacek Caban + - Remove licence header. + - Fix typos. + + * include/msi.h: Aric Stewart + Remove some duplicate prototypes and reformat the SourceList APIs a + bit more to fit with the style of the rest of the file. + + * include/commctrl.h: Frank Richter + Added BST_HOT, WC_BUTTON. + + * dlls/dinput/tests/joystick.c: Francois Gouget + Only print the joystick state when it changes so the user does not get + 300 lines of traces. + + * dlls/gdi/gdi32.spec: + Make GetKerningPairs an alias for GetKerningPairsA. + + * dlls/wined3d/device.c, dlls/wined3d/drawprim.c, + dlls/wined3d/surface.c, dlls/wined3d/wined3d_private.h: + Oliver Stieber + Implemented basic non-power 2 texture in wined3d. + Also fixed a typo in drawprim that was causing vertex declarations to + crash. + + * dlls/amstream/amstream.c, dlls/amstream/main.c, dlls/atl/registrar.c, + dlls/comcat/comcat_main.c, dlls/comcat/comcat_private.h, + dlls/comcat/information.c, dlls/devenum/devenum_private.h, + dlls/devenum/mediacatenum.c: + Mike McCormack + Interlocked LONG* gcc warning fixes. + + * dlls/dinput/tests/joystick.c, dlls/dinput/tests/keyboard.c, + dlls/dinput/tests/mouse.c: + Francois Gouget + Remove unnecessary STRICT defines. + + * dlls/kernel/file.c: + Uwe Bonnes + STATUS_TIMEOUT is no error for Read|WriteFile. + + * dlls/ntdll/file.c: + Uwe Bonnes + Wait for the object multiple times until TIMEOUT is met. + + * dlls/user/listbox.c: Robert Shearman + The units passed into LB_SETTABSTOPS are dialog units, not logical + units. + + * dlls/msi/package.c: Aric Stewart + If MsiGetProperty(A/W) is called with a NULL for the value buffer but + a value in the size for the value buffer, then Msi fills in the size + of the value into the pointer for size. This is tested and confirmed + with native MSI. + + * dlls/msvcrt/locale.c: Vijay Kiran Kamuju + Fix _setmbcp behavior for unreal codepages. + + * server/queue.c, server/user.h, server/window.c, server/winstation.c: + Tie windows and thread input structures to a specific desktop. + Support multiple desktop windows (one per desktop object). + Use the window desktop to find the window station to use for property + atoms. + + * dlls/ntdll/loadorder.c: + Also look for the plain module specification in WINEDLLOVERRIDES for + modules that contain a path, for better consistency with the registry + entries. + + * dlls/msi/files.c, dlls/msi/source.c, include/msi.h: + Aric Stewart + Add the string constants located in msi.h and make use of them in + files.c and source.c. + + * dlls/winspool/info.c: Huw Davies + ScheduleJob for (as yet unused) 'cups' ports. + + * dlls/user/cursoricon.c: Mike McCormack + Replace CURSORICON_CreateFromResource by CreateIconFromResourceEx. + + * dlls/d3d8/d3d8_private.h, dlls/d3dx8/d3dx8core_private.h, + dlls/ddraw/d3d_private.h, dlls/ddraw/ddraw_private.h, + dlls/ddraw/main.c: + Mike McCormack + Interlocked LONG* gcc warning fixes. + + * dlls/kernel/tests/heap.c, dlls/ntdll/heap.c: + Robert Shearman + - Make the value returned from HeapSize always match the requested + size passed into HeapAllocate/HeapReAllocate. + - Add a test for this behaviour. + + * dlls/advapi32/lsa.c, dlls/comctl32/tests/dpa.c, dlls/d3d8/device.c, + dlls/d3d9/stateblock.c, dlls/ddraw/surface_dib.c, + dlls/dmime/tempotrack.c, dlls/shell32/shlexec.c, + dlls/shell32/tests/shlfolder.c, dlls/wined3d/device.c, + dlls/wined3d/directx.c, dlls/wined3d/drawprim.c, + dlls/wined3d/stateblock.c, dlls/wined3d/surface.c, + dlls/wined3d/swapchain.c, dlls/wined3d/vertexdeclaration.c, + programs/winedbg/winedbg.man: + Francois Gouget + Assorted spelling fixes. + + * tools/winapi/win32.api: Francois Gouget + Add missing types to win32.api. + + * dlls/mshtml/oleobj.c, dlls/mshtml/tests/htmldoc.c: + Jacek Caban + - Added test of IOleObject::[SG]etClientSite. + - Fix IOleObject_SetClientSite to pass tests. + + * dlls/user/cursoricon.c: Mike McCormack + Remove unused function args. + + * server/atom.c, server/clipboard.c, server/user.h, + server/winstation.c: + Export the winstation and desktop structures to avoid having to write + too many accessor functions. + + * dlls/oleaut32/connpt.c, dlls/oleaut32/dispatch.c, + dlls/oleaut32/olefont.c, dlls/oleaut32/olepicture.c, + dlls/oleaut32/recinfo.c, dlls/oleaut32/tmarshal.c, + dlls/oleaut32/typelib.c, dlls/oleaut32/typelib2.c: + Mike McCormack + Interlocked LONG* gcc warning fixes. + + * programs/winecfg/En.rc, programs/winecfg/Fr.rc, + programs/winecfg/audio.c, programs/winecfg/resource.h: + Raphael Junqueira + Add some basic dsound configuration on Audio panel. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Don't use unix filesystem specific attributes in UnixFolder's pidls. + + * dlls/shell32/shfldr_fs.c, dlls/shell32/shfldr_mycomp.c: + Michael Jung + Release parent shell folder in GetAttributesOf. + + * programs/wcmd/builtins.c: Detlef Riekenberg + Do not print an error message when deleting a nonexistent variable. + + * dlls/urlmon/umon.c: + Uwe Bonnes + URLMonikerImpl_BindToStorage: Don't use a HeapAllocated pointer for + other purposes. + + * dlls/riched20/editor.c: Felix Nawothnig + Check structure size and fix return values in EM_GETCHARFORMAT. + +2005-07-10 Alexandre Julliard + + * dlls/setupapi/queue.c, dlls/setupapi/setupapi.spec: + Detlef Riekenberg + SetupSetFileQueueAlternatePlatform{AW} implemented as stub. + + * dlls/wined3d/device.c: Oliver Stieber + Check to see if the vertex declaration is null before trying to + reference it. + + * dlls/kernel/kernel32.spec: + The ordinal functions should not be exported by name. + + * dlls/d3d8/shader.c: Marcus Meissner + Fixed signedness issues. + + * dlls/wined3d/directx.c, include/wine/wined3d_gl.h: + Oliver Stieber + Tidy up the way caps are managed in GetDeviceCaps and FillGlCaps. + + * dlls/urlmon/umon.c: + Uwe Bonnes + URLMonikerImpl_BindToStorage: Escape special characters. + + * dlls/cabinet/fci.c: + Gerold Jens Wucherpfennig + The fci_get_little_endian... and fci_set_little_endian... functions + don't really set and unset little endianes, they do the same thing: + merely swapping bytes from one endianes to the other. + + * dlls/msvcrt/file.c: Felix Nawothnig + Allow reading 0 bytes in fread. + + * libs/wine/loader.c, tools/winebuild/res16.c, tools/winebuild/res32.c, + tools/wrc/dumpres.c, tools/wrc/genres.c: + Marcus Meissner + Fixed signedness warnings. + + * dlls/user/button.c: Felix Nawothnig + Fix a typo. + + * dlls/ntdll/env.c: Detlef Riekenberg + Fixed traces. + + * programs/winecfg/En.rc: Brian Vincent + Describe tabs being linked together. + + * include/winternl.h: Mike McCormack + Define the remaining Nt* functions. + + * configure, configure.ac, dlls/ntdll/cdrom.c, include/config.h.in: + Gerald Pfeifer + Add a configure check for struct request_sense. Use this in + CDROM_ScsiPassThroughDir() and CDROM_ScsiPassThrough() to unbreak the + build on FreeBSD. + + * dlls/setupapi/diskspace.c: + Thomas Weidenmueller + Fixed enumerating the drive strings. + + * dlls/msi/install.c, dlls/msi/msi.spec: + Aric Stewart + Implement MsiGetLanguage. + + * dlls/winspool/info.c: Huw Davies + ScheduleJob for 'lpr' ports. + +2005-07-08 Alexandre Julliard + + * server/atom.c, server/class.c, server/object.h, server/window.c: + Explicitly pass the winstation to the atom functions so that they can + be used even when current is not set. + + * dlls/winspool/info.c: Huw Davies + Implement {Start,End}DocPrinter and WritePrinter. + {Start,End}PagePrinter are still stubs but return TRUE. + + * dlls/msi/action.c, dlls/msi/package.c: + Aric Stewart + InstallShield does a number of actions using DoAction before the + Install starts so the PackageCode needs to be loaded on OpenPackage + instead of the beginning of the install process. + + * dlls/shell32/pidl.c: Michael Jung + Fail in SHGetDataFromIDList when called on special folder. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Partially implemented UnixFolder's ISFHelper::CopyItems method. + + * dlls/user/user_main.c, dlls/user/user_private.h, dlls/user/win.c, + dlls/user/winstation.c, include/win.h, + include/wine/server_protocol.h, server/protocol.def, + server/request.h, server/trace.c, server/user.h, server/window.c: + Put in place the basic infrastructure to allow supporting multiple + desktop windows. + + * dlls/user/dde_client.c, dlls/user/dde_misc.c, + dlls/user/dde_private.h, dlls/user/dde_server.c, dlls/user/ddeml16.c, + dlls/user/tests/dde.c: + Dmitry Timoshkov + Add DDE transaction test, make it pass under Wine. + + * dlls/commdlg/cdlg_De.rc, programs/cmdlgtst/De.rc, + programs/winecfg/De.rc: + Henning Gerhardt + Update German resource files. + + * dlls/setupapi/Pl.rc, dlls/setupapi/setupapi.rc: + Sebastian Gasiorek + Added Polish resources. + + * include/msvcrt/mbctype.h: Vijay Kiran Kamuju + Add _MB_CP_* defines. + + * dlls/psapi/psapi_main.c, dlls/psapi/tests/psapi_main.c: + Felix Nawothnig + Make GetProcessMemoryInfo fail if the passed buffer is too small. + + * include/wincrypt.h: Juan Lang + Add a few more missing defines. + + * dlls/user/sysparams.c: Frank Richter + Always zero destination buffer in SYSPARAMS_LoadRaw(). Remove + now-superfluous memory zeroing in some other places. + + * dlls/comctl32/dpa.c, dlls/comctl32/tests/dpa.c: + Felix Nawothnig + Fix some DPA functions so they pass the new tests. + + * dlls/shell32/shfldr_unixfs.c, dlls/shell32/tests/shlfolder.c: + Michael Jung + Return correct HRESULT code in UnixFolder's IEnumIDList::Next. + Corresponding test. + + * dlls/msi/msi.c: Robert Shearman + In MsiLocateComponent pcchBuf can be NULL so don't try to dereference + it. + + * include/textserv.h: Maarten Lankhorst + ITextServices_OnTxInplaceDeactivate does not take a parameter. + + * dlls/d3d9/d3d9_private.h, dlls/d3d9/pixelshader.c: + Oliver Stieber + Relay all the pixel shader calls from d3d9 to wined3d. + +2005-07-07 Alexandre Julliard + + * dlls/d3d9/vertexdeclaration.c, dlls/wined3d/device.c, + dlls/wined3d/drawprim.c, dlls/wined3d/vertexdeclaration.c, + include/wine/wined3d_interface.h: + Oliver Stieber + Added support for vertex declarations to wined3d, it's the last patch + to give wined3d basic functionality. + + * dlls/d3d9/device.c, dlls/wined3d/device.c, dlls/wined3d/directx.c, + dlls/wined3d/surface.c, dlls/wined3d/utils.c, + dlls/wined3d/wined3d_private.h: + Oliver Stieber + Implement render targets using either textures, swapchains or + standalone surfaces. + + * dlls/ttydrv/winetty.drv.spec, dlls/ttydrv/wnd.c, + dlls/user/user_main.c, dlls/user/user_private.h, dlls/user/win.c, + dlls/x11drv/window.c, dlls/x11drv/winex11.drv.spec, + dlls/x11drv/winpos.c: + Moved initialization of the desktop window in the graphics driver to a + separate CreateDesktopWindow entry point instead of overloading + CreateWindow. + + * dlls/user/menu.c: + Removed creation of the no longer used shading brush. + + * dlls/crypt32/cert.c, dlls/crypt32/crypt32.spec, + dlls/crypt32/tests/main.c: + Juan Lang + Implement a few utility functions, with tests. + + * include/wincrypt.h: Juan Lang + Correct a typo. + + * programs/winefile/winefile.c: Martin Fuchs + - move ID_ABOUT_WINE into #ifdef __WINE__ + - support for refresh in shell namespace windows + + * dlls/msi/action.c, dlls/msi/helpers.c: + Aric Stewart + Fill and use the ProductCode part of the MSIPACKAGE structure. + + * dlls/netapi32/access.c, dlls/netapi32/netapi32.spec: + Detlef Riekenberg + NetUserAdd + NetUserDel implemented as stub. + Made some FIXME more informative. + Marked some FIXME as stub. + Added comments before some functions. + + * dlls/ntdll/loadorder.c: + Use the same defaults for modules with and without an explicit path. + + * dlls/user/sysparams.c: Frank Richter + Add support for proper saving of the "FLATMENU" and "GRADIENTCAPION" + system parameters to the registry. + + * dlls/user/uitools.c: Frank Richter + Wine has now a Marlett font, hence the window buttons can now be drawn + using that and not some polylines. + + * fonts/wine_marlett.sfd: Frank Richter + Added a real "window restore" glyph to Wine Marlett. + + * dlls/commdlg/cdlg_En.rc, dlls/commdlg/cdlg_Ru.rc, + dlls/commdlg/printdlg.c: + Eugeny Gorelov + Implement most functionality of PageSetupDlg function. + + * programs/cmdlgtst/En.rc, programs/cmdlgtst/Ru.rc, + programs/cmdlgtst/cmdlgtst.c, programs/cmdlgtst/cmdlgtst.h: + Eugeny Gorelov + Added PageSetupDlg test. + + * dlls/x11drv/window.c, dlls/x11drv/x11drv_main.c: + Moved most initializations out of the create_desktop function and into + process_attach. + + * dlls/user/win.c, dlls/user/winpos.c, include/winpos.h: + Delay creation of the internal pos atom until needed. + + * dlls/mscms/tests/Makefile.in, dlls/mscms/tests/profile.c: + Hans Leidekker + Dynamically load mscms. + + * programs/winecfg/De.rc: Frank Richter + Update German translation for changes to the DLL overrides UI. + + * include/commdlg.h: Eugeny Gorelov + Added PSD_NONETWORKBUTTON define. + + * dlls/ole32/memlockbytes.c, dlls/ole32/storage32.c: + Vitaly Lipatov + Added some documentation. + + * dlls/msi/dialog.c: Mike McCormack + Use LoadImage to load bitmaps and icons. + + * dlls/user/tests/msg.c: Dmitry Timoshkov + Add a MsgWaitForMultipleObjects test. + + * dlls/advapi32/registry.c, dlls/advapi32/tests/crypt.c, + dlls/devenum/mediacatenum.c, dlls/dmusic/dmusic.c, + dlls/dplayx/dplay.c, dlls/dplayx/dplobby.c, + dlls/dsound/dsound_main.c, dlls/iphlpapi/iphlpapi_main.c, + dlls/mpr/pwcache.c, dlls/netapi32/nbt.c, dlls/oledlg/insobjdlg.c, + dlls/powrprof/powrprof.c, dlls/setupapi/virtcopy.c, + dlls/shlwapi/reg.c, dlls/tapi32/line.c, dlls/uxtheme/system.c, + dlls/wininet/urlcache.c, dlls/winmm/winealsa/audio.c, + programs/regedit/edit.c, programs/winebrowser/main.c, + programs/winedbg/winedbg.c: + Mike McCormack + gcc 4.0 -Wpointer-sign fixes (Reg* functions). + + * server/mapping.c: Convert the shared mapping list to a standard list. + + * dlls/dbghelp/elf_module.c: + We no longer have thunks in the data section. + + * dlls/user/win.c, include/wine/server_protocol.h, server/protocol.def, + server/trace.c, server/window.c: + Dmitry Timoshkov + Make IsWindowUnicode work in the case when window belongs to another + process. + + * programs/winefile/Makefile.in, programs/winefile/winefile.c, + programs/winefile/winefile.h: + Martin Fuchs + - remove and header usage by switching to WIN32 + API string manipulation functions as far as possible + - switch to UNICODE compilaton + - remove launch_fileA() and tcscpyn + - don't crash in set_curdir() for NULL in the 'entry' pointer + + * programs/winecfg/Nl.rc: Paul Vriens + Update the Dutch translations. + + * server/atom.c, server/object.h, server/request.c, server/user.h, + server/winstation.c: + Store the global atom table in the process window station. + + * include/winternl.h: Mike McCormack + Add more Nt* functions. + + * dlls/user/combo.c: Felix Nawothnig + Update TODO list. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + Encode/decode CERT_PUBLIC_KEY_INFO, with tests. + + * dlls/comctl32/tests/dpa.c: + Felix Nawothnig + Add another failing DPA test. + +2005-07-06 Alexandre Julliard + + * dlls/winaspi/aspi.c: Gerald Pfeifer + SCSI_Linux_CheckDevices() is Linux-only as well. + + * dlls/mscms/mscms_main.c: Hans Leidekker + Fail loading when compiled without lcms support. + + * dlls/advapi32/crypt.c, dlls/advapi32/service.c, + dlls/advapi32/tests/registry.c, dlls/d3d8/d3d8_main.c, + dlls/msvideo/msvideo16.c, dlls/oleaut32/tmarshal.c, + dlls/oleaut32/typelib16.c, dlls/opengl32/wgl.c, + dlls/setupapi/setupx_main.c, dlls/shell32/classes.c, + dlls/shell32/dialogs.c, dlls/user/tests/sysparams.c, + dlls/winaspi/aspi.c, dlls/winaspi/winaspi16.c, dlls/wineps/init.c, + dlls/x11drv/x11drv_main.c, dlls/x11drv/xfont.c, + programs/wineconsole/registry.c: + Mike McCormack + gcc 4.0 -Wpointer-sign fixes (Reg* functions). + + * programs/winecfg/En.rc, programs/winecfg/libraries.c, + programs/winecfg/resource.h: + Felix Nawothnig + Changed layout of libraries tab, moved load-order setting into extra + dialog. + + * dlls/comctl32/propsheet.c: + Felix Nawothnig + Don't invalidate the whole propsheet when the page is switched. + + * dlls/user/menu.c: Rein Klazes + - when sending the WM_DRAWITEM message in case of a menu item with + hbmpItem = HBMMENU_CALLBACK, move the drawing origin to the top left + of the item rectangle + - at the same time also make sure that the itemState field of the + DRAWITEMSTRUCT is properly initialized + - do the drawing of the check mark before sending the WM_DRAWITEM + message, some application likes to "overdraw" the checkmark. + + * dlls/wined3d/drawprim.c: Oliver Stieber + Change all references to updateStateBlock to references to stateBlock + in drawprim. + + * dlls/riched20/paint.c, dlls/riched20/wrap.c, dlls/twain/capability.c, + dlls/x11drv/xfont.c, dlls/x11drv/xrandr.c: + Stefan Huehner + Make functions static to fix -Wmissing-declarations warnings. + + * dlls/user/painting.c, dlls/user/tests/dce.c: + Restore the clip region after GetDCEx in send_erase as if it had been + a BeginPaint. + + * programs/winemenubuilder/winemenubuilder.c: + Moved the configuration key to HKCU\Software\Wine\WineMenuBuilder. + + * dlls/comctl32/tests/treeview.c, dlls/dinput/tests/joystick.c, + dlls/ntdll/tests/info.c, dlls/oleaut32/tests/vartest.c, + dlls/psapi/tests/psapi_main.c, dlls/user/tests/menu.c, + dlls/user/tests/win.c: + Francois Gouget + Add trailing '\n's to ok() calls. + + * dlls/msi/action.c: Mike McCormack + Stop the install when cancelling from a modeless dialog. + + * include/winternl.h: Mike McCormack + Add more Nt* functions. + + * dlls/winspool/Makefile.in, dlls/winspool/info.c: + Huw Davies + Add an implementation of AddJob and a partial one of ScheduleJob. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Implemented UnixFolder's ISFHelper::DeleteItems interface. + + * include/winuser.h: Frank Richter + Add missing DC_GRADIENT and DC_BUTTONS, as used by DrawCaption. + + * dlls/riched20/editor.c, dlls/riched20/editor.h, dlls/riched20/row.c: + Phil Krylov + Fixed EM_LINEINDEX handler and added EM_LINEFROMCHAR handler. + + * dlls/msi/events.c: Mike McCormack + Don't crash when cancelling out of a modeless dialog. + + * dlls/user/sysparams.c: Felix Nawothnig + Clear buffer before querying the registry in SYSPARAMS_Load. + + * dlls/shell32/shfldr_unixfs.c: Michael Lin + Michael Jung + Implemented UnixFolder's ISFHelper::AddFolder. + + * dlls/advapi32/Makefile.in, dlls/advapi32/lsa.c, + dlls/advapi32/security.c: + James Hawkins + Branch the LSA functions from security.c to lsa.c. + + * dlls/user/dde_client.c, dlls/user/dde_misc.c, dlls/user/defwnd.c, + dlls/user/driver16.c, dlls/user/hook.c, dlls/user/hook16.c, + dlls/user/message.c, dlls/user/spy.c, dlls/user/sysparams.c, + dlls/user/text.c, dlls/user/user_main.c, dlls/user/winproc.c: + Mike McCormack + -Wpointer-sign fixes for gcc 4.0. + + * dlls/msi/action.c, dlls/msi/msipriv.h, dlls/msi/string.c, + dlls/msi/suminfo.c: + Mike McCormack + gcc 4.0 -Wpointer-sign fixes. + + * dlls/mshtml/main.c, dlls/mshtml/mshtml_private.h, + dlls/mshtml/protocol.c: + Mike McCormack + Fix gcc 4.0 -Wpointer-sign warnings. + + * dlls/riched20/editor.c, dlls/riched20/editor.h, dlls/riched20/row.c: + Phil Krylov + Implemented EM_EXLINEFROMCHAR, EM_LINEINDEX, EM_FINDTEXT, + EM_FINDTEXTW, EM_FINDTEXTEX, and EM_FINDTEXTEXW messages. + + * include/winnt.h: Mike McCormack + Define PVOID64 and FILE_SEGMENT_ELEMENT. + + * dlls/uxtheme/system.c: Frank Richter + Every window needs to receive WM_THEMECHANGED (esp. controls), so also + send it to child windows. + + * dlls/comctl32/Makefile.in, dlls/comctl32/comctl32undoc.c, + dlls/comctl32/dpa.c, dlls/comctl32/dsa.c: + Felix Nawothnig + Move DPA and DSA functions out of comctl32undoc.c as they are + documented by now. + +2005-07-05 Alexandre Julliard + + * tools/winebuild/relay.c: Don't depend on ELF features for PIC code. + A couple of optimizations. + + * dlls/msi/Makefile.in, dlls/msi/files.c, dlls/msi/msipriv.h, + dlls/msi/source.c, include/msi.h: + Aric Stewart + Add source.c to start handling the various MsiSourceList apis used in + v3 of MSI, and now internally. + Update files.c to use the MsiSourceList apis to make sure our + SourceList keys in the registry are included and correct. + + * dlls/shell32/shell32.spec, dlls/shell32/shell32_main.c: + Detlef Riekenberg + Printer_LoadIconsW: implemented minimal version. + + * dlls/riched20/wrap.c: Phil Krylov + Fixed an off-by-one error in EM_GETLINECOUNT handler. + + * dlls/riched20/writer.c: Phil Krylov + Fixed another couple of EM_STREAMOUT bugs. + + * include/textserv.h: Paul Vriens + Fixed typo. + + * dlls/shell32/shfldr_unixfs.c: Michael Lin + Michael Jung + ISFHelper interface support for UnixFolder (currently only stubs). + + * dlls/avifil32/acmstream.c, dlls/avifil32/avifile.c, + dlls/avifil32/editstream.c, dlls/avifil32/getframe.c, + dlls/avifil32/icmstream.c, dlls/avifil32/tmpfile.c, + dlls/avifil32/wavfile.c: + Mike McCormack + gcc 4.0 -Wpointer-sign fixes. + + * dlls/msi/dialog.c: Mike McCormack + Set the initial focus on the control specified by Control_First in the + Dialog table. + + * dlls/riched20/writer.c: Phil Krylov + Removed junk from UTF-8 RTF output. + + * include/textserv.h: Maarten Lankhorst + Added txtbit declarations. + + * programs/winecfg/libraries.c: Hajime Segawa + Fix for debug message buffer overflow in library tab. + + * dlls/shell32/shfldr_unixfs.c: Michael Lin + Michael Jung + Implemented UnixFolder's IShellFolder::SetNameOf. + + * dlls/d3d9/d3d9_private.h, dlls/d3d9/pixelshader.c, + dlls/d3d9/stateblock.c, dlls/d3d9/vertexshader.c: + Oliver Stieber + Strip out stateblocks from d3d9 and relay all stateblock calls to + wined3d. + + * tools/sfnt2fnt.c, tools/winebuild/spec16.c, tools/winedump/le.c, + tools/winedump/lnk.c, tools/winedump/ne.c, tools/winedump/winedump.h, + tools/wrc/readres.c, dlls/commdlg/filedlg.c, + dlls/commdlg/filedlgbrowser.c, dlls/commdlg/fontdlg.c, + dlls/commdlg/fontdlg16.c, dlls/commdlg/printdlg.c, + dlls/commdlg/printdlg16.c: + Mike McCormack + gcc 4.0 -Wpointer-sign fixes. + + * include/msxml.idl: Vijay Kiran Kamuju + Add IXMLElementNotificationSink definition for IE4 compatibility. + + * dlls/msvcrt/process.c: Eric Pouech + Fixed erroneous file flag in _popen. + + * dlls/urlmon/.cvsignore, dlls/urlmon/Makefile.in, + dlls/urlmon/regsvr.c, dlls/urlmon/rsrc.rc, dlls/urlmon/urlmon.inf, + dlls/urlmon/urlmon_main.h: + Jacek Caban + Register protocols. + + * dlls/ntdll/process.c, dlls/ntdll/virtual.c: + Felix Nawothnig + Replace stubs for information classes in NtQueryVirtualMemory and + NtQueryInformationProcess by more descriptive messages. + + * dlls/uxtheme/draw.c: Frank Richter + UXTHEME_LoadImage(): Set default image count to 1 to avoid division by + zero in case image count property is not given. Properly support 0 + state IDs. + + * dlls/wined3d/device.c, dlls/wined3d/drawprim.c, + dlls/wined3d/stateblock.c, dlls/wined3d/wined3d_private.h, + include/wine/wined3d_interface.h: + Oliver Stieber + Implemented stateblocks in wined3d. + + * dlls/user/edit.c, dlls/user/tests/edit.c: + Vitaliy Margolen + Fix some failing tests. + + * tools/winebuild/build.h, tools/winebuild/main.c, + tools/winebuild/spec32.c: + Get rid of the global debugging flag. + + * dlls/kernel/kernel16_private.h, dlls/kernel/ne_module.c, + dlls/kernel/relay16.c, tools/winebuild/relay.c: + Intercept functions for 16-bit relay debugging by patching the + CALLFROM16 table instead of having the wine_call_from_16 functions + call out the relay functions explicitly. + + * dlls/dplayx/dplay.c, dlls/dplayx/dplayx_global.c, + dlls/dplayx/name_server.c, dlls/gdi/enhmetafile.c, + dlls/msvidc32/msvideo1.c, dlls/netapi32/access.c, + dlls/riched20/editor.c, dlls/rpcrt4/ndr_ole.c, + dlls/uxtheme/msstyles.c: + Stefan Huehner + Fix -Wmissing-declarations warnings. + + * dlls/ole32/antimoniker.c, dlls/ole32/bindctx.c, + dlls/ole32/clipboard.c, dlls/ole32/compobj_private.h, + dlls/ole32/compositemoniker.c, dlls/ole32/datacache.c, + dlls/ole32/defaulthandler.c, dlls/ole32/errorinfo.c, + dlls/ole32/filemoniker.c, dlls/ole32/ftmarshal.c, + dlls/ole32/hglobalstream.c, dlls/ole32/ifs.c, + dlls/ole32/itemmoniker.c, dlls/ole32/marshal.c, + dlls/ole32/memlockbytes.c, dlls/ole32/memlockbytes16.c, + dlls/ole32/moniker.c, dlls/ole32/ole16.c, dlls/ole32/ole2.c, + dlls/ole32/oleobj.c, dlls/ole32/oleproxy.c, dlls/ole32/rpc.c, + dlls/ole32/stg_prop.c, dlls/ole32/storage.c, dlls/ole32/storage32.h, + dlls/ole32/stubmanager.c: + Mike McCormack + Fix gcc 4.0 -Wpointer-sign warnings. + + * dlls/user/cursoricon.c: Detlef Riekenberg + LoadImageW: Fix type of TRACE parameter. + + * include/.cvsignore, include/Makefile.in, include/mimeinfo.idl: + Vijay Kiran Kamuju + Added declaration for IMimeInfo interface. + + * dlls/kernel/relay16.c, include/wine/winbase16.h, + tools/winebuild/relay.c, tools/winebuild/spec16.c: + Added vararg argument type so that the relay code can distinguish from + a normal cdecl function. + Don't rely on the relay thunk preserving the stack pointer. + + * dlls/ntdll/tests/info.c: Paul Vriens + Added some tests for other information classes. + Correct comment for test 0x3. + + * dlls/ntdll/nt.c: Paul Vriens + Improved stubs to show the correct behavior. + + * programs/winecfg/En.rc: Huw Davies + Add an English neutral version of the graphics tab. + + * dlls/kernel/toolhelp.c: Mike McCormack + Fix some gcc 4.0 warnings. + + * dlls/uxtheme/msstyles.c, dlls/uxtheme/msstyles.h: + Frank Richter + Opening some theme class data now also increases the reference count + of the theme file, so as long as theme class data is still opened + somewhere, the theme file won't get freed. Otherwise, it could happen + that invalid class data was used, which could lead to problems. + + * dlls/uxtheme/draw.c: Frank Richter + Changed the default transparent color in case none was explicitly + specified from the upper left pixel color to magenta. Empirically + gives better results. + + * dlls/user/menu.c: Frank Richter + Add support for drawing menus in "flat" style. + + * dlls/advapi32/crypt.c, dlls/cabinet/fdi.c, + dlls/dinput/joystick_linux.c, dlls/iphlpapi/tests/iphlpapi.c, + dlls/msvcrt/tests/headers.c, dlls/oleaut32/typelib.c, + dlls/setupapi/virtcopy.c, dlls/winaspi/aspi.c, + dlls/winedos/soundblaster.c, dlls/winedos/vga.c, + dlls/winsock/socket.c: + Stefan Huehner + Fix some more -Wmissing-declarations warnings. + + * dlls/dmloader/dmloader_main.c, dlls/dmloader/dmloader_private.h, + dlls/dmloader/loader.c: + Mike McCormack + Fix gcc 4.0 -Wpointer-sign warnings. + + * dlls/gdi/driver.c, dlls/gdi/freetype.c, dlls/gdi/printdrv.c: + Mike McCormack + -Wpointer-sign fixes for gcc 4.0. + + * dlls/oleaut32/oleaut.c, dlls/oleaut32/variant.c: + Robert Shearman + Document active object and variant functions. + + * dlls/comctl32/tests/dpa.c: + Felix Nawothnig + Fix DPA tests on Win95. + + * include/winternl.h: Paul Vriens + Removed 4 bytes from the SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION + struct. + Changed some dwSpare into liKernelTime and liUserTime. + + * include/textserv.h: Maarten Lankhorst + Added missing declaration for ITextServices->OnTxInPlaceDeactivate. + + * dlls/commdlg/cdlg_En.rc: Huw Davies + Add English neutral version of IDS_COLOR_GRAY. + + * programs/winefile/Fr.rc: Jonathan Ernst + Updated winefile French resources. + + * programs/winecfg/Fr.rc, programs/winecfg/winecfg.rc: + Jonathan Ernst + - Updated winecfg French resources. + - Fixed control size and placement. + + * dlls/winspool/info.c: Huw Davies + Add one more level of indirection to the printer handle array to allow + more information than just the name to be stored. + Wrap accesses to the printer handle array in a critsec. + + * dlls/user/tests/win.c: Dmitry Timoshkov + Add a test case for IsWindowUnicode. + + * dlls/shell32/shell32_Pt.rc: Marcelo Duarte + Update shell32 resources for Portuguese. + + * programs/winemine/Pl.rc: Marcelo Duarte + Remove double SEPARATOR. + + * dlls/x11drv/opengl.c: Oliver Stieber + Make sure that the OpenGL visual created for a window has a stencil + buffer. + + * tools/wineinstall: Vincent Béron + Clean wineinstall from config file references. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Return correct attributes in ParseDisplayName. + + * dlls/kernel/version.c: Mike McCormack + Fix gcc 4.0 warnings. + + * dlls/comctl32/propsheet.c: Frank Richter + Let property sheets update the cached system colors upon receiving + WM_SYSCOLORCHANGE. + + * dlls/uxtheme/system.c: Frank Richter + Write WCHAR strings to registry with correct size. + + * dlls/mscms/profile.c, dlls/mscms/tests/profile.c: + Hans Leidekker + Fix color directory handling. + + * dlls/uxtheme/draw.c, dlls/uxtheme/uxtheme.spec, include/uxtheme.h: + Thomas Weidenmueller + IsThemeDialogTextureEnabled should have one parameter to match the + prototype in the official headers. + + * dlls/user/sysparams.c: Frank Richter + Add support for SPI_[SG]ETFLATMENU in SystemParametersInfo (although + without saving of the setting). + + * dlls/uxtheme/msstyles.c: Frank Richter + Enable/disable "flat menus" based on the setting from the active + theme. + +2005-07-03 Alexandre Julliard + + * dlls/urlmon/sec_mgr.c, dlls/urlmon/umon.c, dlls/urlmon/umstream.c, + dlls/urlmon/urlmon_main.c, dlls/urlmon/urlmon_main.h: + Mike McCormack + Fix -Wpointer-sign warnings. + + * dlls/shell32/autocomplete.c, dlls/shell32/classes.c, + dlls/shell32/cpanelfolder.c, dlls/shell32/dataobject.c, + dlls/shell32/dde.c, dlls/shell32/dragdrophelper.c, + dlls/shell32/enumidlist.c, dlls/shell32/folders.c, + dlls/shell32/pidl.c, dlls/shell32/pidl.h, + dlls/shell32/shell32_main.h, dlls/shell32/shelllink.c, + dlls/shell32/shellole.c, dlls/shell32/shfldr_desktop.c, + dlls/shell32/shfldr_fs.c, dlls/shell32/shfldr_mycomp.c, + dlls/shell32/shfldr_unixfs.c, dlls/shell32/shlfsbind.c, + dlls/shell32/shlview.c, dlls/shell32/shv_bg_cmenu.c, + dlls/shell32/shv_item_cmenu.c: + Mike McCormack + -Wpointer-sign fixes. + + * dlls/comctl32/tests/Makefile.in, dlls/comctl32/tests/dpa.c: + Felix Nawothnig + Rewrote the DPA testsuite. + + * include/winternl.h: Mike McCormack + Define more Nt* functions. + + * dlls/kernel/kernel16_private.h, dlls/kernel/syslevel.c, + dlls/kernel/wowthunk.c, tools/winebuild/relay.c: + Moved all 16-bit relay code to the text section. + Changed a few symbol names for better consistency. + + * libs/wine/ldt.c: Added error message for missing LDT support on i386. + + * dlls/ntdll/signal_i386.c: Some fixes for the Darwin build. + + * dlls/winmm/wineoss/audio.c, dlls/winmm/wineoss/dsrender.c: + Vitaliy Margolen + Change messages about config file to registry. + + * dlls/gdi/tests/generated.c, dlls/kernel/tests/generated.c, + dlls/ntdll/tests/generated.c, dlls/rpcrt4/tests/generated.c, + dlls/shell32/tests/generated.c, dlls/shlwapi/tests/generated.c, + dlls/urlmon/tests/generated.c, dlls/user/tests/generated.c, + dlls/wininet/tests/generated.c, tools/winapi/winapi_test: + Mike McCormack + Avoid warnings in generated tests by casting sizeof(x) to an int. + + * dlls/mshtml/Makefile.in, dlls/mshtml/htmldoc.c, + dlls/mshtml/mshtml_private.h, dlls/mshtml/service.c: + Jacek Caban + Added stub implementation of IServiceProvider. + + * DEVELOPERS-HINTS: Mike McCormack + Fix DEVELOPER_HINTS to reflect make configure doesn't run autoconf. + + * dlls/ddraw/device_opengl.c: Marcus Meissner + Make check fails in dlls/ddraw/tests/d3d, because a heap allocate is + fed to wrong size. (sizeof(BOOLEAN) is 1 , but ative_lights is a DWORD + array). + + * dlls/x11drv/desktop.c: Lionel Ulmer + Add some resolutions to what Desktop mode supports. + + * include/winternl.h: Felix Nawothnig + Add some values to the PROCESS_INFORMATION_CLASS enumeration. + + * dlls/urlmon/umon.c: Jacek Caban + Fix handling of pmkContext in CreateURLMoniker. + + * programs/winemine/main.c, programs/winemine/main.h: + Jacek Caban + Make registry compatible with winmine. + + * include/commctrl.h: Frank Richter + Add missing NMBCHOTITEM struct. + + * dlls/msvcrt/wcs.c: Marcus Meissner + char pointer must be 11 byte to fit 10 characters + \0. + + * dlls/advapi32/tests/registry.c, include/winreg.h: + Felix Nawothnig + Added unit tests for RegGetValue. + +2005-07-02 Alexandre Julliard + + * dlls/ntdll/virtual.c, server/mapping.c: + Vitaliy Margolen + Load all dll sections no matter what attributes say. + + * dlls/urlmon/sec_mgr.c, dlls/urlmon/umon.c, dlls/urlmon/urlmon_main.c: + Jacek Caban + Better module locking. + + * dlls/avifil32/Makefile.in, dlls/avifil32/api.c: + Marcus Meissner + Use CoCreateInstance instead of SHCoCreateInstance, drop shell32 from + imports. + Call OleInitialize() on AVIFileInit. + + * dlls/mshtml/main.c, include/mshtmhst.idl: + Jacek Caban + - Added more definitions. + - Fixed RunHTMLApplication declaration. + + * include/msxml.idl: Vijay Kiran Kamuju + Add missing declarations for IXMLDocument2 and IXMLElement2. + +2005-07-01 Alexandre Julliard + + * server/registry.c: Don't bother loading the config file anymore. + + * tools/winedump/ne.c: Added dumping of NE segments and relocations. + + * tools/winebuild/import.c: + Don't use the full 32 bits of %esp when called from 16-bit code. + + * dlls/user/ddeml.spec: Andreas Mohr + HCONV and HCONVLIST are 32bit handles. + + * programs/winecfg/De.rc, programs/winefile/De.rc: + Henning Gerhardt + Update German resource files. + + * dlls/d3d9/device.c: Oliver Stieber + Check for a null surface returned from CreateSurface. + Relay GetCreationParameters call to wined3d. + + * configure, configure.ac, dlls/ntdll/cdrom.c, include/config.h.in: + Phil Krylov + Fixed dlls/ntdll/cdrom.c compilation in Darwin by adding HAVE_IOKit + detection to configure and defining SENSEBUFLEN as kSenseDefaultSize + (which is corresponding IOKit enum value). + + * include/Makefile.in, include/textserv.h: + Mike McCormack + Added textserv.h. + + * dlls/kernel/kernel16_private.h, dlls/kernel/thunk.c, + dlls/kernel/wowthunk.c, tools/winebuild/relay.c: + Moved most of the implementation of CALL32_CBClient(Ex) to the C + code. + + * tools/winebuild/import.c, tools/winebuild/main.c, + tools/winebuild/winebuild.man.in: + Added a --target option to allow cross-compilation. + + * dlls/x11drv/window.c: + Set the class resource name to the name of the main binary (suggested + by Rasterman). + + * include/.cvsignore, include/Makefile.in, include/xmldso.idl, + include/xmldsodid.h: + Vijay Kiran Kamuju + Added xmldso.idl. + + * dlls/ntdll/relay.c, tools/winebuild/import.c: + Improve a bit the assembly generated for import thunks. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + - implement encoding/decoding of cert extensions + - remove some unnecessary parameters to internal functions + - tests for cert extensions + + * dlls/cabinet/cabextract.c, dlls/riched20/caret.c, + dlls/uxtheme/draw.c, dlls/uxtheme/uxini.c: + Stefan Huehner + Make some function static. + + * programs/winecfg/drivedetect.c: + Michael Jung + Added binfmt_misc to the filesystem blacklist. + + * dlls/uxtheme/msstyles.c: Frank Richter + Have the theme INI file parsed upon theme activation and not just when + the first theme data is requested; that way, the themed system colors + are set correctly from the start, and not just after some theme data + was requested. + + * include/wincrypt.h: Juan Lang + - add more prototypes + - rearrange prototypes according to the DLL they're in, to make + comments correct + + * dlls/user/dialog.c, dlls/user/tests/dialog.c: + Robert Shearman + GetDlgItemText should always try to NULL terminate the string. + +2005-06-30 Alexandre Julliard + + * include/wine/test.h, include/winsock.h: + Attempt at a better fix for the winsock.h problems on Darwin. + + * programs/winecfg/Nl.rc: Paul Vriens + Update the Dutch translations. + + * dlls/mshtml/protocol.c, dlls/mshtml/rsrc.rc: + Use proper symbols instead of magic number 23 for HTML resource type. + + * tools/wrc/genres.c, tools/wrc/newstruc.c, tools/wrc/newstruc.h, + tools/wrc/parser.l, tools/wrc/parser.y, tools/wrc/wrctypes.h: + Added support for HTML resource type. + + * dlls/wininet/tests/http.c: Added missing LGPL header. + + * include/.cvsignore, include/Makefile.in, include/msxml.idl, + include/msxml2.idl: + Vijay Kiran Kamuju + Added msxml2.idl. + + * configure, configure.ac: Vitaliy Margolen + Fix test for arts. + + * dlls/shell32/Makefile.in, dlls/shell32/dde.c, + dlls/shell32/shell32_main.c: + Robert Shearman + Implement ShellDDEInit. + + * dlls/msi/action.c, dlls/msi/action.h, dlls/msi/custom.c, + dlls/msi/helpers.c, dlls/msi/upgrade.c: + Aric Stewart + Keep track of what sequence we are in and register unique + actions. This allows us to make sure actions and custom actions + flagged to run only once, actually run only once. + Also clean up some of the numeric constants in custom.c using the + defined values from msidefs.h. + + * configure, configure.ac, include/config.h.in: + Removed some no longer used asm checks. + + * dlls/cabinet/fci.c, dlls/d3d8/directx.c, dlls/rpcrt4/rpcrt4_main.c, + dlls/shlwapi/ordinal.c, dlls/wined3d/device.c, + dlls/wined3d/directx.c, dlls/wined3d/wined3d_private.h, + documentation/PACKAGING, tools/winedump/README, + tools/winedump/winedump.h, tools/winedump/winedump.man: + Francois Gouget + Assorted spelling fixes. + + * dlls/user/sysparams.c, dlls/user/tests/sysparams.c: + Revert SPI_SETMOUSEBUTTONSWAP changes. + + * dlls/mshtml/tests/.cvsignore, dlls/mshtml/tests/Makefile.in, + dlls/mshtml/tests/protocol.c: + Jacek Caban + Added res protocol test. + + * dlls/user/dde_misc.c: Dmitry Timoshkov + Fix a typo in ReuseDDElParam: GlobalLock supposed to be GlobalUnlock. + + * dlls/comctl32/header.c: Vitaliy Margolen + Send CDDS_ITEMPOSTERASE | CDDS_PREPAINT notify. + + * dlls/winspool/info.c: Huw Davies + Forward StartDocPrinterA to StartDocPrinterW. + Improve trace in the unicode version. + + * dlls/mshtml/rsrc.rc: Jacek Caban + Fix blank.htm resources. + + * dlls/riched20/editor.c, dlls/riched20/editstr.h, + dlls/riched20/wrap.c: + Phil Krylov + Implemented EM_GETLINECOUNT RichEdit message. + + * tools/wrc/genres.c, tools/wrc/genres.h, tools/wrc/wrctypes.h, + tools/wrc/writeres.c: + Stefan Huehner + Fix some -Wsign-compare warnings. + + * tools/wrc/parser.l: Jacek Caban + '.' is a valid char of tIDENT. + + * programs/winedbg/winedbg.c: Francois Gouget + Improve the winedbg usage. + + * programs/winecfg/audio.c: Francois Gouget + Remove unneeded casts. + + * dlls/kernel/tests/directory.c: + Francois Gouget for Mandriva + Test the behavior of CreateDirectory() when it has one or two trailing + dots or spaces. + Tweak the previous CreateDirectory() tests so we get more information + in case of a failure. + + * tools/winapi/win32.api: Francois Gouget + Update win32.api to match current sources. + + * tools/winebuild/utils.c: Phil Krylov + Fixed winebuild operation in Darwin. + + * dlls/shell32/regsvr.c: Michael Jung + Register unixfs at desktop level in DllRegisterServer. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Fix two more corner cases in UNIXFS_get_unix_path and UNIXFS_path_to_pidl. + + * dlls/msi/dialog.c: Mike McCormack + Move to the next mask edit field when the current one becomes full. + + * include/wincrypt.h: Juan Lang + Add more missing OIDs. + + * dlls/shell32/tests/shlfolder.c: + Saulius Krasuckas + Prepare for adding new tests. + - Put OleInitialize and OleUninitialize in the main block. + - Move test_BindToObject before test_EnumObjects_and_CompareIDs. + + * dlls/mshtml/protocol.c: Jacek Caban + Implemented res protocol. + + * dlls/msi/dialog.c: Mike McCormack + Make the tab order in msi dialogs right. + + * dlls/ntdll/cdrom.c: Gerald Pfeifer + Avoid unused variable warnings in CDROM_ScsiPassThroughDir() and + CDROM_ScsiPassThrough(). + + * programs/winemenubuilder/winemenubuilder.c: + Sven Paschukat + Repaired extraction of icons when config file is missing. + + * dlls/wininet/internet.c: Robert Shearman + Add stubs for some InternetSetOption options. + +2005-06-29 Alexandre Julliard + + * tools/winebuild/build.h, tools/winebuild/spec32.c, + tools/winebuild/utils.c: + Replace configure macros by explicit platform checks (probably not + correct on all platforms yet). + + * dlls/oleaut32/oleaut.c, dlls/oleaut32/oleaut32.spec, + dlls/oleaut32/regsvr.c: + Robert Shearman + Rename OLEAUT32_Dll* Functions to Dll*. + + * dlls/oleaut32/tests/vartype.c, dlls/oleaut32/variant.c: + Robert Shearman for Mandriva + - Conversions between variants types of the same size should ignore + overflows. + - Tests for this behaviour. + + * dlls/oleaut32/typelib.c: + Robert Shearman for Mandriva + Add a generic TYPEDESC VT to VARIANT VT mapper so we can use the + standard Variant* routines. Use this new function to properly copy & + de-reference the return value. + + * dlls/advapi32/tests/security.c, dlls/ntdll/sec.c: + James Hawkins + - Fix calculation of generic pointers. + - Minor cleanups. + + * dlls/winmm/winealsa/audio.c: + Vitaliy Margolen + Sync comments with configuration location changes. + + * server/clipboard.c, server/user.h, server/winstation.c: + Make the clipboard information local to the process window station. + + * server/process.c: + Clear the process handle table before releasing it to avoid potential + problems with destructors trying to access handles. + + * dlls/x11drv/init.c, dlls/x11drv/opengl.c, dlls/x11drv/x11drv.h, + dlls/x11drv/x11drv_main.c: + Delay OpenGL and GDI initialization until they are needed. + + * dlls/kernel/oldconfig.c: Get rid of the old config conversion code. + + * dlls/riched20/editor.c: Aric Stewart + Implementation for EM_GETTEXTEX. + + * include/Makefile.in, include/msxml2did.h: + Vijay Kiran Kamuju + Added defines for XMLDOM stuff. + + * dlls/msi/action.h, dlls/msi/files.c, dlls/msi/helpers.c: + Aric Stewart + Handle installs off multiple volumes and properly pull the prompt + string from the error table. + + * dlls/ntdll/cdrom.c: Mike Hearn + Fix GCC4 warning. + + * tools/widl/typelib_struct.h, tools/widl/write_msft.c: + Huw Davies for Mandriva + Update the import table code to eliminate a few magic constants. + + * dlls/oleaut32/typelib.c, dlls/oleaut32/typelib.h, + dlls/oleaut32/typelib2.c: + Huw Davies for Mandriva + Cope with the index in a import table entry being a typeinfo index + rather than a guid offset. + + * dlls/cabinet/fci.c: + Gerold Jens Wucherpfennig + Support for big-endian systems. + + * programs/regedit/listview.c: Gerald Pfeifer + Avoid compiler warning in AddEntryToList(). + + * dlls/shell32/shell32_main.h, dlls/shell32/shfldr_desktop.c, + dlls/shell32/shfldr_unixfs.c: + Michael Jung + If the unixfs is rooted at the Desktop folder, forward + ParseDisplayName calls to it instead of to MyComputer. + + * include/Makefile.in, include/basetyps.h: + Steven Edwards + Add basetyps.h based on the public domain mingw header by Anders + Norlander. + + * include/wincrypt.h: Paul Vriens + Correct some OIDs. + + * dlls/shell32/tests/shlfolder.c: + Vitaliy Margolen + ILFree is not available on all versions. + + * dlls/ntdll/cdrom.c: Dmitry Timoshkov + A workaround for missing struct request_sense on FreeBSD. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + - fix decoding of long-form data lengths + - use exception handling in decoding + - tests for these changes + + * programs/winetest/Makefile.in: Jacek Caban + Added mshtml test. + +2005-06-28 Alexandre Julliard + + * tools/Makefile.in: Run make clean in the winapi subdir too. + + * dlls/user/tests/winstation.c, server/hook.c, server/thread.c, + server/thread.h, server/window.c, server/winstation.c: + Keep track of the windows and hooks used by a thread to properly + refuse to change the thread desktop when it's in use. + + * dlls/commdlg/cdlg16.h, dlls/commdlg/colordlg.c, + dlls/commdlg/colordlg16.c, dlls/commdlg/filedlg.c, + dlls/commdlg/filedlg16.c, dlls/commdlg/filedlg31.c, + dlls/commdlg/filedlgbrowser.c, dlls/commdlg/filetitle.c, + dlls/commdlg/finddlg.c, dlls/commdlg/fontdlg.c: + Mike McCormack + Fix declarations. + + * documentation/Makefile.in: The samples subdirectory no longer exists. + + * dlls/gdi/freetype.c: + Fixed HKLM/HKCU mixup for the external fonts key. + + * dlls/msi/action.c, dlls/msi/helpers.c, dlls/msi/msi.c, + dlls/msi/msipriv.h, dlls/msi/package.c: + Aric Stewart + Relocate the msi file to prevent cd locking, corrected to properly not + try to relocated #nnnn handles as files. + + * dlls/commdlg/Makefile.in, dlls/commdlg/filedlg.c: + Michael Jung + Don't expand MyComputer in the file dialogs without user interaction, + if unixfs is rooted at desktop. + + * programs/winecfg/En.rc, programs/winecfg/Makefile.in, + programs/winecfg/audio.c, programs/winecfg/resource.h: + Robert Reif + - Add an audio configure button with code to display the selected + audio driver's configure dialog. + - Add an audio control panel launch button. + + * dlls/riched20/editor.c: Phil Krylov + Fixed a comment about EM_STREAMIN. + + * VERSION, configure, ANNOUNCE, ChangeLog: Release 20050628. + +---------------------------------------------------------------- 2005-06-28 Alexandre Julliard * dlls/gdi/printdrv.c: diff -urN wine-20050628/DEVELOPERS-HINTS wine-20050725/DEVELOPERS-HINTS --- wine-20050628/DEVELOPERS-HINTS 2005-06-09 12:07:04.000000000 +0200 +++ wine-20050725/DEVELOPERS-HINTS 2005-07-13 13:56:15.000000000 +0200 @@ -172,6 +172,7 @@ winspool/ - Printing & Print Spooler wintab32/ - Tablet device interface wintrust/ - Trust verification interface + wldap32/ - LDAP support wow32/ - WOW subsystem wsock32/ - Sockets 1.1 (networking) wtsapi32/ - Terminal Services @@ -339,7 +340,7 @@ 4. Run ./make_dlls in the dlls directory to update Makefile.in in that directory. -5. You can now regenerate ./configure file (with 'make configure') +5. You can now regenerate ./configure file (with 'autoconf') and the various Makefiles (with 'configure; make depend') (run from the top of Wine's tree). You should now have a Makefile file in ./dlls// diff -urN wine-20050628/Make.rules.in wine-20050725/Make.rules.in --- wine-20050628/Make.rules.in 2005-05-07 14:39:58.000000000 +0200 +++ wine-20050725/Make.rules.in 2005-07-20 19:48:26.000000000 +0200 @@ -147,7 +147,7 @@ $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@ .sfd.ttf: - $(FONTFORGE) -script $(TOPSRCDIR)/fonts/genttf.ff $< + $(FONTFORGE) -script $(TOPSRCDIR)/fonts/genttf.ff $< $@ # 'all' target first in case the enclosing Makefile didn't define any target diff -urN wine-20050628/VERSION wine-20050725/VERSION --- wine-20050628/VERSION 2005-06-28 16:39:20.000000000 +0200 +++ wine-20050725/VERSION 2005-07-25 14:22:05.000000000 +0200 @@ -1 +1 @@ -Wine version 20050628 +Wine version 20050725 diff -urN wine-20050628/configure wine-20050725/configure --- wine-20050628/configure 2005-06-28 16:39:20.000000000 +0200 +++ wine-20050725/configure 2005-07-25 14:22:05.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for Wine 20050628. +# Generated by GNU Autoconf 2.59 for Wine 20050725. # # Report bugs to . # @@ -269,8 +269,8 @@ # Identity of this package. PACKAGE_NAME='Wine' PACKAGE_TARNAME='wine' -PACKAGE_VERSION='20050628' -PACKAGE_STRING='Wine 20050628' +PACKAGE_VERSION='20050725' +PACKAGE_STRING='Wine 20050725' PACKAGE_BUGREPORT='wine-devel@winehq.org' ac_unique_file="server/atom.c" @@ -311,7 +311,7 @@ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS DLLDEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os WIN16_FILES WIN16_INSTALL SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPPBIN ac_ct_CPPBIN TOOLSDIR CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LEX LEXLIB LEX_OUTPUT_ROOT XLEX BISON AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN EGREP LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS FONTFORGE LIBPTHREAD XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS GLUT_LIBS GLUT32FILES NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS ft_devel ft_devel2 FREETYPELIBS FREETYPEINCL FONTSSUBDIRS ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLLFLAGS LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS LDLIBWINEFLAGS COREFOUNDATIONLIB IOKITLIB CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS SOCKETLIBS WINE_BINARIES MAIN_BINARY LDD ALLOCA LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS DLLDEFS build build_cpu build_vendor build_os host host_cpu host_vendor host_os WIN16_FILES WIN16_INSTALL SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPPBIN ac_ct_CPPBIN TOOLSDIR CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LEX LEXLIB LEX_OUTPUT_ROOT XLEX BISON AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN EGREP LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS FONTFORGE LIBPTHREAD XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS GLUT_LIBS GLUT32FILES NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS LCMSLIBS LDAPLIBS ft_devel ft_devel2 FREETYPELIBS FREETYPEINCL FONTSSUBDIRS ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLLFLAGS LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS LDLIBWINEFLAGS COREFOUNDATIONLIB IOKITLIB CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS SOCKETLIBS WINE_BINARIES MAIN_BINARY LDD ALLOCA LIBOBJS LTLIBOBJS' ac_subst_files='MAKE_RULES MAKE_DLL_RULES MAKE_TEST_RULES MAKE_LIB_RULES MAKE_PROG_RULES' # Initialize some variables set by options. @@ -788,7 +788,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Wine 20050628 to adapt to many kinds of systems. +\`configure' configures Wine 20050725 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -853,7 +853,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Wine 20050628:";; + short | recursive ) echo "Configuration of Wine 20050725:";; esac cat <<\_ACEOF @@ -984,7 +984,7 @@ test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -Wine configure 20050628 +Wine configure 20050725 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -998,7 +998,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Wine $as_me 20050628, which was +It was created by Wine $as_me 20050725, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -7110,7 +7110,11 @@ + + + for ac_header in \ + IOKit/IOKitLib.h \ arpa/inet.h \ arpa/nameser.h \ asm/types.h \ @@ -7125,8 +7129,10 @@ io.h \ jack/jack.h \ jpeglib.h \ + lber.h \ lcms/lcms.h \ lcms.h \ + ldap.h \ link.h \ linux/cdrom.h \ linux/compiler.h \ @@ -8150,15 +8156,6 @@ if test "x$with_opengl" != "xno" then - if test -f /usr/X11R6/lib/libGL.a -a ! -f /usr/X11R6/lib/libGL.so -a ! -f /usr/X11R6/lib/libGL.dylib - then - { { echo "$as_me:$LINENO: error: /usr/X11R6/lib/libGL.a is present on your system. -This prevents linking to OpenGL. Delete the file and restart configure." >&5 -echo "$as_me: error: /usr/X11R6/lib/libGL.a is present on your system. -This prevents linking to OpenGL. Delete the file and restart configure." >&2;} - { (exit 1); exit 1; }; } - fi - for ac_header in GL/gl.h GL/glx.h @@ -8505,7 +8502,17 @@ #define HAVE_OPENGL 1 _ACEOF + else + if test -f /usr/X11R6/lib/libGL.a + then + { { echo "$as_me:$LINENO: error: /usr/X11R6/lib/libGL.a is present on your system. +This prevents linking to OpenGL. Delete the file and restart configure." >&5 +echo "$as_me: error: /usr/X11R6/lib/libGL.a is present on your system. +This prevents linking to OpenGL. Delete the file and restart configure." >&2;} + { (exit 1); exit 1; }; } + fi fi + echo "$as_me:$LINENO: checking for gluLookAt in -lGLU" >&5 echo $ECHO_N "checking for gluLookAt in -lGLU... $ECHO_C" >&6 if test "${ac_cv_lib_GLU_gluLookAt+set}" = set; then @@ -9874,6 +9881,228 @@ LIBS="$saved_libs" fi +LCMSLIBS="" + +if test "$ac_cv_header_lcms_h" = "yes" -o "$ac_cv_header_lcms_lcms_h" = "yes" +then + echo "$as_me:$LINENO: checking for cmsOpenProfileFromFile in -llcms" >&5 +echo $ECHO_N "checking for cmsOpenProfileFromFile in -llcms... $ECHO_C" >&6 +if test "${ac_cv_lib_lcms_cmsOpenProfileFromFile+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-llcms $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char cmsOpenProfileFromFile (); +int +main () +{ +cmsOpenProfileFromFile (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_lcms_cmsOpenProfileFromFile=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_lcms_cmsOpenProfileFromFile=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_lcms_cmsOpenProfileFromFile" >&5 +echo "${ECHO_T}$ac_cv_lib_lcms_cmsOpenProfileFromFile" >&6 +if test $ac_cv_lib_lcms_cmsOpenProfileFromFile = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LCMS 1 +_ACEOF + + LCMSLIBS="-llcms" +fi + +fi + +LDAPLIBS="" + +if test "$ac_cv_header_ldap_h" = "yes" -a "$ac_cv_header_lber_h" = "yes" +then + echo "$as_me:$LINENO: checking for ldap_init in -lldap" >&5 +echo $ECHO_N "checking for ldap_init in -lldap... $ECHO_C" >&6 +if test "${ac_cv_lib_ldap_ldap_init+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lldap $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char ldap_init (); +int +main () +{ +ldap_init (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ldap_ldap_init=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_ldap_ldap_init=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_ldap_ldap_init" >&5 +echo "${ECHO_T}$ac_cv_lib_ldap_ldap_init" >&6 +if test $ac_cv_lib_ldap_ldap_init = yes; then + echo "$as_me:$LINENO: checking for ber_init in -llber" >&5 +echo $ECHO_N "checking for ber_init in -llber... $ECHO_C" >&6 +if test "${ac_cv_lib_lber_ber_init+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-llber $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char ber_init (); +int +main () +{ +ber_init (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_lber_ber_init=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_lber_ber_init=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_lber_ber_init" >&5 +echo "${ECHO_T}$ac_cv_lib_lber_ber_init" >&6 +if test $ac_cv_lib_lber_ber_init = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LDAP 1 +_ACEOF + + LDAPLIBS="-lldap -llber" +fi + +fi + +fi + echo "$as_me:$LINENO: checking for FT_Init_FreeType in -lfreetype" >&5 echo $ECHO_N "checking for FT_Init_FreeType in -lfreetype... $ECHO_C" >&6 if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then @@ -11043,7 +11272,7 @@ echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lartsc $LIBS" +LIBS="-lartsc $ARTSC_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -12724,343 +12953,15 @@ fi -echo "$as_me:$LINENO: checking for assembler keyword for ASCII strings" >&5 -echo $ECHO_N "checking for assembler keyword for ASCII strings... $ECHO_C" >&6 -if test "${ac_cv_c_asm_string+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -void ac_asm(void) { asm(".data\\n\\t.string \\"test\\"\\n\\t.text"); } +DLLEXT="" -int -main () -{ +DLLFLAGS="-D_REENTRANT" - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_asm_string=".string" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +DLLIBS="" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -void ac_asm(void) { asm(".data\\n\\t.asciz \\"test\\"\\n\\t.text"); } +LDSHARED="" -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_asm_string=".asciz" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -void ac_asm(void) { asm(".data\\n\\t.ascii \\"test\\"\\n\\t.text"); } - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_asm_string=".ascii" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: could not discover how to produce C strings with assembler." >&5 -echo "$as_me: error: could not discover how to produce C strings with assembler." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_asm_string" >&5 -echo "${ECHO_T}$ac_cv_c_asm_string" >&6 - - -cat >>confdefs.h <<_ACEOF -#define __ASM_STRING "$ac_cv_c_asm_string" -_ACEOF - - - -echo "$as_me:$LINENO: checking for assembler keyword for word values" >&5 -echo $ECHO_N "checking for assembler keyword for word values... $ECHO_C" >&6 -if test "${ac_cv_c_asm_short+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -void ac_asm(void) { asm(".data\\n\\t.short 1\\n\\t.text"); } - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_asm_short=".short" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -void ac_asm(void) { asm(".data\\n\\t.half 1\\n\\t.text"); } - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_asm_short=".half" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: could not discover how to specify word values with assembler." >&5 -echo "$as_me: error: could not discover how to specify word values with assembler." >&2;} - { (exit 1); exit 1; }; } -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_asm_short" >&5 -echo "${ECHO_T}$ac_cv_c_asm_short" >&6 - - -cat >>confdefs.h <<_ACEOF -#define __ASM_SHORT "$ac_cv_c_asm_short" -_ACEOF - - - -echo "$as_me:$LINENO: checking for .size in assembler" >&5 -echo $ECHO_N "checking for .size in assembler... $ECHO_C" >&6 -if test "${ac_cv_c_asm_size+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -void ac_asm(void) { asm(".globl _ac_test\n.size _ac_test, . - _ac_test"); } - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_c_asm_size="yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_c_asm_size="no" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_c_asm_size" >&5 -echo "${ECHO_T}$ac_cv_c_asm_size" >&6 - -if test "$ac_cv_c_asm_size" = "yes" -then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_ASM_DOT_SIZE 1 -_ACEOF - -fi - - -DLLEXT="" - -DLLFLAGS="-D_REENTRANT" - -DLLIBS="" - -LDSHARED="" - -LDDLLFLAGS="" +LDDLLFLAGS="" LIBEXT="so" @@ -15667,80 +15568,6 @@ _ACEOF fi -echo "$as_me:$LINENO: checking for -llcms soname" >&5 -echo $ECHO_N "checking for -llcms soname... $ECHO_C" >&6 -if test "${ac_cv_lib_soname_lcms+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_get_soname_save_LIBS=$LIBS -LIBS="-llcms $LIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char cmsOpenProfileFromFile (); -int -main () -{ -cmsOpenProfileFromFile (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_lib_soname_lcms=`$ac_cv_path_LDD conftest$ac_exeext | grep liblcms\\.$LIBEXT | sed "s/^.*\(liblcms\.$LIBEXT[^ ]*\).*$/\1/"` - if test "x$ac_cv_lib_soname_lcms" = "x" - then - ac_cv_lib_soname_lcms="liblcms.$LIBEXT" - fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_lib_soname_lcms="liblcms.$LIBEXT" -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS=$ac_get_soname_save_LIBS -fi -echo "$as_me:$LINENO: result: $ac_cv_lib_soname_lcms" >&5 -echo "${ECHO_T}$ac_cv_lib_soname_lcms" >&6 -if test "x$ac_cv_lib_soname_lcms" != xNONE -then -cat >>confdefs.h <<_ACEOF -#define SONAME_LIBLCMS "$ac_cv_lib_soname_lcms" -_ACEOF -fi - echo "$as_me:$LINENO: checking for -lcapi20 soname" >&5 echo $ECHO_N "checking for -lcapi20 soname... $ECHO_C" >&6 if test "${ac_cv_lib_soname_capi20+set}" = set; then @@ -17613,6 +17440,71 @@ fi +echo "$as_me:$LINENO: checking for request_sense" >&5 +echo $ECHO_N "checking for request_sense... $ECHO_C" >&6 +if test "${ac_cv_type_request_sense+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +if ((request_sense *) 0) + return 0; +if (sizeof (request_sense)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_request_sense=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_request_sense=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_request_sense" >&5 +echo "${ECHO_T}$ac_cv_type_request_sense" >&6 +if test $ac_cv_type_request_sense = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_REQUEST_SENSE 1 +_ACEOF + + +fi + echo "$as_me:$LINENO: checking whether linux/input.h is for real" >&5 echo $ECHO_N "checking whether linux/input.h is for real... $ECHO_C" >&6 @@ -20312,7 +20204,7 @@ MAKE_PROG_RULES=programs/Makeprog.rules - ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" + ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/midimap/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole2.tlb/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wldap32/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/hh/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" cat >confcache <<\_ACEOF @@ -20677,7 +20569,7 @@ } >&5 cat >&5 <<_CSEOF -This file was extended by Wine $as_me 20050628, which was +This file was extended by Wine $as_me 20050725, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20740,7 +20632,7 @@ cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -Wine config.status 20050628 +Wine config.status 20050725 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -20925,6 +20817,7 @@ "dlls/lzexpand/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/lzexpand/tests/Makefile" ;; "dlls/mapi32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mapi32/Makefile" ;; "dlls/mapi32/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mapi32/tests/Makefile" ;; + "dlls/midimap/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/midimap/Makefile" ;; "dlls/mlang/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mlang/Makefile" ;; "dlls/mlang/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mlang/tests/Makefile" ;; "dlls/mmdevldr.vxd/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mmdevldr.vxd/Makefile" ;; @@ -20999,6 +20892,7 @@ "dlls/shlwapi/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/shlwapi/Makefile" ;; "dlls/shlwapi/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/shlwapi/tests/Makefile" ;; "dlls/snmpapi/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/snmpapi/Makefile" ;; + "dlls/stdole2.tlb/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/stdole2.tlb/Makefile" ;; "dlls/stdole32.tlb/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/stdole32.tlb/Makefile" ;; "dlls/sti/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/sti/Makefile" ;; "dlls/strmiids/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/strmiids/Makefile" ;; @@ -21036,7 +20930,6 @@ "dlls/winmm/mcicda/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/mcicda/Makefile" ;; "dlls/winmm/mciseq/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/mciseq/Makefile" ;; "dlls/winmm/mciwave/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/mciwave/Makefile" ;; - "dlls/winmm/midimap/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/midimap/Makefile" ;; "dlls/winmm/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/tests/Makefile" ;; "dlls/winmm/wavemap/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/wavemap/Makefile" ;; "dlls/winmm/winealsa/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winmm/winealsa/Makefile" ;; @@ -21052,6 +20945,7 @@ "dlls/winspool/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/winspool/tests/Makefile" ;; "dlls/wintab32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wintab32/Makefile" ;; "dlls/wintrust/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wintrust/Makefile" ;; + "dlls/wldap32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wldap32/Makefile" ;; "dlls/wow32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wow32/Makefile" ;; "dlls/wsock32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wsock32/Makefile" ;; "dlls/wtsapi32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/wtsapi32/Makefile" ;; @@ -21071,6 +20965,7 @@ "programs/cmdlgtst/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/cmdlgtst/Makefile" ;; "programs/control/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/control/Makefile" ;; "programs/expand/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/expand/Makefile" ;; + "programs/hh/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/hh/Makefile" ;; "programs/msiexec/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/msiexec/Makefile" ;; "programs/notepad/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/notepad/Makefile" ;; "programs/progman/Makefile" ) CONFIG_FILES="$CONFIG_FILES programs/progman/Makefile" ;; @@ -21269,6 +21164,8 @@ s,@SANELIBS@,$SANELIBS,;t t s,@SANEINCL@,$SANEINCL,;t t s,@ICULIBS@,$ICULIBS,;t t +s,@LCMSLIBS@,$LCMSLIBS,;t t +s,@LDAPLIBS@,$LDAPLIBS,;t t s,@ft_devel@,$ft_devel,;t t s,@ft_devel2@,$ft_devel2,;t t s,@FREETYPELIBS@,$FREETYPELIBS,;t t diff -urN wine-20050628/configure.ac wine-20050725/configure.ac --- wine-20050628/configure.ac 2005-06-27 14:07:49.000000000 +0200 +++ wine-20050725/configure.ac 2005-07-25 13:12:11.000000000 +0200 @@ -171,6 +171,7 @@ dnl **** Check for header files **** AC_CHECK_HEADERS(\ + IOKit/IOKitLib.h \ arpa/inet.h \ arpa/nameser.h \ asm/types.h \ @@ -185,8 +186,10 @@ io.h \ jack/jack.h \ jpeglib.h \ + lber.h \ lcms/lcms.h \ lcms.h \ + ldap.h \ link.h \ linux/cdrom.h \ linux/compiler.h \ @@ -353,12 +356,6 @@ dnl Check for the presence of OpenGL if test "x$with_opengl" != "xno" then - if test -f /usr/X11R6/lib/libGL.a -a ! -f /usr/X11R6/lib/libGL.so -a ! -f /usr/X11R6/lib/libGL.dylib - then - AC_MSG_ERROR([/usr/X11R6/lib/libGL.a is present on your system. -This prevents linking to OpenGL. Delete the file and restart configure.]) - fi - AC_CHECK_HEADERS(GL/gl.h GL/glx.h) if test "$ac_cv_header_GL_gl_h" = "yes" -a "$ac_cv_header_GL_glx_h" = "yes" then @@ -385,7 +382,14 @@ then OPENGLFILES='$(OPENGLFILES)' AC_DEFINE(HAVE_OPENGL, 1, [Define if OpenGL is present on the system]) + else + if test -f /usr/X11R6/lib/libGL.a + then + AC_MSG_ERROR([/usr/X11R6/lib/libGL.a is present on your system. +This prevents linking to OpenGL. Delete the file and restart configure.]) + fi fi + dnl Check for GLU32 library. AC_CHECK_LIB(GLU,gluLookAt, [OPENGL_LIBS="$OPENGL_LIBS -lGLU" @@ -479,6 +483,25 @@ LIBS="$saved_libs" fi +dnl **** Check for LittleCMS *** +AC_SUBST(LCMSLIBS,"") +if test "$ac_cv_header_lcms_h" = "yes" -o "$ac_cv_header_lcms_lcms_h" = "yes" +then + AC_CHECK_LIB(lcms, cmsOpenProfileFromFile, + [AC_DEFINE(HAVE_LCMS, 1, [Define if you have the LittleCMS development environment]) + LCMSLIBS="-llcms"]) +fi + +dnl **** Check for OpenLDAP *** +AC_SUBST(LDAPLIBS,"") +if test "$ac_cv_header_ldap_h" = "yes" -a "$ac_cv_header_lber_h" = "yes" +then + AC_CHECK_LIB(ldap, ldap_init, + [AC_CHECK_LIB(lber, ber_init, + [AC_DEFINE(HAVE_LDAP, 1, [Define if you have the OpenLDAP development environment]) + LDAPLIBS="-lldap -llber"])]) +fi + dnl **** Check for FreeType 2 **** AC_CHECK_LIB(freetype,FT_Init_FreeType,ft_lib=yes,ft_lib=no,$X_LIBS) if test "$ft_lib" = "no" @@ -684,7 +707,8 @@ [AC_TRY_COMPILE([#include ],[arts_stream_t stream;], [AC_SUBST(ARTSLIBS, $ARTSC_LIBS) AC_SUBST(ARTSINCL, $ARTSC_CFLAGS) - AC_DEFINE(HAVE_ARTS, 1, [Define if you have ARTS sound server])])],) + AC_DEFINE(HAVE_ARTS, 1, [Define if you have ARTS sound server])])],, + $ARTSC_LIBS) CFLAGS="$save_CFLAGS" fi @@ -878,38 +902,6 @@ AC_DEFINE([__ASM_NAME(name)], [name]) fi -dnl **** Check how to do strings in assembler **** - -AC_CACHE_CHECK([for assembler keyword for ASCII strings], ac_cv_c_asm_string, - WINE_TRY_ASM_LINK([".data\\n\\t.string \\"test\\"\\n\\t.text"],,,ac_cv_c_asm_string=".string", - WINE_TRY_ASM_LINK([".data\\n\\t.asciz \\"test\\"\\n\\t.text"],,,ac_cv_c_asm_string=".asciz", - WINE_TRY_ASM_LINK([".data\\n\\t.ascii \\"test\\"\\n\\t.text"],,,ac_cv_c_asm_string=".ascii", - AC_MSG_ERROR([could not discover how to produce C strings with assembler.]))))) - -AC_DEFINE_UNQUOTED(__ASM_STRING, ["$ac_cv_c_asm_string"], - [Define to the assembler keyword used to specify an ASCII string]) - -dnl **** Check for .short in assembler **** - -AC_CACHE_CHECK([for assembler keyword for word values], ac_cv_c_asm_short, - WINE_TRY_ASM_LINK([".data\\n\\t.short 1\\n\\t.text"],,,ac_cv_c_asm_short=".short", - WINE_TRY_ASM_LINK([".data\\n\\t.half 1\\n\\t.text"],,,ac_cv_c_asm_short=".half", - AC_MSG_ERROR([could not discover how to specify word values with assembler.])))) - -AC_DEFINE_UNQUOTED(__ASM_SHORT, ["$ac_cv_c_asm_short"], - [Define to the assembler keyword used to specify a word value]) - -dnl **** Check for .size in assembler **** - -AC_CACHE_CHECK([for .size in assembler], ac_cv_c_asm_size, - WINE_TRY_ASM_LINK([".globl _ac_test\n.size _ac_test, . - _ac_test"],,, - ac_cv_c_asm_size="yes",ac_cv_c_asm_size="no")) - -if test "$ac_cv_c_asm_size" = "yes" -then - AC_DEFINE(HAVE_ASM_DOT_SIZE, 1, [Define if the assembler keyword .size is accepted]) -fi - dnl **** Check for working dll **** AC_SUBST(DLLEXT,"") @@ -1122,7 +1114,6 @@ WINE_GET_SONAME(jpeg,jpeg_start_decompress) WINE_GET_SONAME(ungif,DGifOpen) WINE_GET_SONAME(gif,DGifOpen) - WINE_GET_SONAME(lcms,cmsOpenProfileFromFile) WINE_GET_SONAME(capi20,capi20_isinstalled) fi @@ -1276,6 +1267,7 @@ AC_C_INLINE AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t, long long, fsblkcnt_t, fsfilcnt_t]) AC_CHECK_TYPES([sigset_t],,,[#include ]) +AC_CHECK_TYPES([request_sense],,,[#include ]) AC_CACHE_CHECK([whether linux/input.h is for real], wine_cv_linux_input_h, @@ -1621,6 +1613,7 @@ dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile +dlls/midimap/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile @@ -1695,6 +1688,7 @@ dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile +dlls/stdole2.tlb/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile @@ -1732,7 +1726,6 @@ dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile -dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile @@ -1748,6 +1741,7 @@ dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile +dlls/wldap32/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile @@ -1767,6 +1761,7 @@ programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile +programs/hh/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile diff -urN wine-20050628/dlls/Makefile.in wine-20050725/dlls/Makefile.in --- wine-20050628/dlls/Makefile.in 2005-06-13 13:47:46.000000000 +0200 +++ wine-20050725/dlls/Makefile.in 2005-07-21 13:31:56.000000000 +0200 @@ -70,6 +70,7 @@ kernel \ lzexpand \ mapi32 \ + midimap \ mlang \ mmdevldr.vxd \ monodebg.vxd \ @@ -125,6 +126,7 @@ shfolder \ shlwapi \ snmpapi \ + stdole2.tlb \ stdole32.tlb \ sti \ tapi32 \ @@ -155,7 +157,6 @@ winmm/mcicda \ winmm/mciseq \ winmm/mciwave \ - winmm/midimap \ winmm/wavemap \ winmm/winealsa \ winmm/winearts \ @@ -168,6 +169,7 @@ winspool \ wintab32 \ wintrust \ + wldap32 \ wow32 \ wsock32 \ wtsapi32 @@ -317,7 +319,7 @@ mcicda.drv.so \ mciseq.drv.so \ mciwave.drv.so \ - midimap.drv.so \ + midimap.dll.so \ mlang.dll.so \ mmdevldr.vxd.so \ monodebg.vxd.so \ @@ -372,6 +374,7 @@ shfolder.dll.so \ shlwapi.dll.so \ snmpapi.dll.so \ + stdole2.tlb.so \ stdole32.tlb.so \ sti.dll.so \ tapi32.dll.so \ @@ -406,6 +409,7 @@ winspool.drv.so \ wintab32.dll.so \ wintrust.dll.so \ + wldap32.dll.so \ wnaspi32.dll.so \ wow32.dll.so \ ws2_32.dll.so \ @@ -652,8 +656,8 @@ mciwave.drv.so: winmm/mciwave/mciwave.drv.so $(RM) $@ && $(LN_S) winmm/mciwave/mciwave.drv.so $@ -midimap.drv.so: winmm/midimap/midimap.drv.so - $(RM) $@ && $(LN_S) winmm/midimap/midimap.drv.so $@ +midimap.dll.so: midimap/midimap.dll.so + $(RM) $@ && $(LN_S) midimap/midimap.dll.so $@ mlang.dll.so: mlang/mlang.dll.so $(RM) $@ && $(LN_S) mlang/mlang.dll.so $@ @@ -849,6 +853,9 @@ snmpapi.dll.so: snmpapi/snmpapi.dll.so $(RM) $@ && $(LN_S) snmpapi/snmpapi.dll.so $@ +stdole2.tlb.so: stdole2.tlb/stdole2.tlb.so + $(RM) $@ && $(LN_S) stdole2.tlb/stdole2.tlb.so $@ + stdole32.tlb.so: stdole32.tlb/stdole32.tlb.so $(RM) $@ && $(LN_S) stdole32.tlb/stdole32.tlb.so $@ @@ -985,6 +992,9 @@ wintrust.dll.so: wintrust/wintrust.dll.so $(RM) $@ && $(LN_S) wintrust/wintrust.dll.so $@ +wldap32.dll.so: wldap32/wldap32.dll.so + $(RM) $@ && $(LN_S) wldap32/wldap32.dll.so $@ + wnaspi32.dll.so: winaspi/wnaspi32.dll.so $(RM) $@ && $(LN_S) winaspi/wnaspi32.dll.so $@ @@ -1179,6 +1189,7 @@ winspool/libwinspool.$(IMPLIBEXT) \ wintab32/libwintab32.$(IMPLIBEXT) \ wintrust/libwintrust.$(IMPLIBEXT) \ + wldap32/libwldap32.$(IMPLIBEXT) \ winaspi/libwnaspi32.$(IMPLIBEXT) \ wow32/libwow32.$(IMPLIBEXT) \ winsock/libws2_32.$(IMPLIBEXT) \ @@ -1568,6 +1579,9 @@ wintrust/libwintrust.$(IMPLIBEXT): wintrust/wintrust.spec $(WINEBUILD) @cd wintrust && $(MAKE) libwintrust.$(IMPLIBEXT) +wldap32/libwldap32.$(IMPLIBEXT): wldap32/wldap32.spec $(WINEBUILD) + @cd wldap32 && $(MAKE) libwldap32.$(IMPLIBEXT) + winaspi/libwnaspi32.$(IMPLIBEXT): winaspi/wnaspi32.spec $(WINEBUILD) @cd winaspi && $(MAKE) libwnaspi32.$(IMPLIBEXT) @@ -1706,7 +1720,7 @@ winmm/mcicda/mcicda.drv.so: winmm/mcicda winmm/mciseq/mciseq.drv.so: winmm/mciseq winmm/mciwave/mciwave.drv.so: winmm/mciwave -winmm/midimap/midimap.drv.so: winmm/midimap +midimap/midimap.dll.so: midimap mlang/mlang.dll.so: mlang mmdevldr.vxd/mmdevldr.vxd.so: mmdevldr.vxd monodebg.vxd/monodebg.vxd.so: monodebg.vxd @@ -1762,6 +1776,7 @@ shfolder/shfolder.dll.so: shfolder shlwapi/shlwapi.dll.so: shlwapi snmpapi/snmpapi.dll.so: snmpapi +stdole2.tlb/stdole2.tlb.so: stdole2.tlb stdole32.tlb/stdole32.tlb.so: stdole32.tlb sti/sti.dll.so: sti tapi32/tapi32.dll.so: tapi32 @@ -1798,6 +1813,7 @@ winspool/winspool.drv.so: winspool wintab32/wintab32.dll.so: wintab32 wintrust/wintrust.dll.so: wintrust +wldap32/wldap32.dll.so: wldap32 winaspi/wnaspi32.dll.so: winaspi wow32/wow32.dll.so: wow32 winsock/ws2_32.dll.so: winsock @@ -1838,7 +1854,7 @@ -rmdir $(dlldir) clean:: - $(RM) $(IMPORT_SYMLINKS) *.$(IMPLIBEXT) + $(RM) $(IMPORT_SYMLINKS) check test:: $(BUILDSUBDIRS:%=%/__test__) diff -urN wine-20050628/dlls/advapi32/Makefile.in wine-20050725/dlls/advapi32/Makefile.in --- wine-20050628/dlls/advapi32/Makefile.in 2005-05-09 16:42:36.000000000 +0200 +++ wine-20050725/dlls/advapi32/Makefile.in 2005-07-06 12:37:50.000000000 +0200 @@ -17,6 +17,7 @@ crypt_md5.c \ crypt_sha.c \ eventlog.c \ + lsa.c \ registry.c \ security.c \ service.c diff -urN wine-20050628/dlls/advapi32/advapi32.spec wine-20050725/dlls/advapi32/advapi32.spec --- wine-20050628/dlls/advapi32/advapi32.spec 2005-06-23 13:40:57.000000000 +0200 +++ wine-20050725/dlls/advapi32/advapi32.spec 2005-07-18 17:10:22.000000000 +0200 @@ -286,6 +286,8 @@ @ stdcall RegEnumValueW(long long ptr ptr ptr ptr ptr ptr) @ stdcall RegFlushKey(long) @ stdcall RegGetKeySecurity(long long ptr ptr) +@ stdcall RegGetValueA(long str str long ptr ptr ptr) +@ stdcall RegGetValueW(long wstr wstr long ptr ptr ptr) @ stdcall RegLoadKeyA(long str str) @ stdcall RegLoadKeyW(long wstr wstr) @ stdcall RegNotifyChangeKeyValue(long long long long long) diff -urN wine-20050628/dlls/advapi32/crypt.c wine-20050725/dlls/advapi32/crypt.c --- wine-20050628/dlls/advapi32/crypt.c 2005-06-17 22:56:02.000000000 +0200 +++ wine-20050725/dlls/advapi32/crypt.c 2005-07-18 11:07:57.000000000 +0200 @@ -174,7 +174,7 @@ if ( !(provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)) ) goto error #define CRYPT_GetProvFuncOpt(name) \ provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name) -PCRYPTPROV CRYPT_LoadProvider(PSTR pImage) +static PCRYPTPROV CRYPT_LoadProvider(PSTR pImage) { PCRYPTPROV provider; DWORD errorcode = ERROR_NOT_ENOUGH_MEMORY; @@ -326,7 +326,7 @@ SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto error; } - r = RegQueryValueExA(key, "Name", NULL, NULL, provname, &len); + r = RegQueryValueExA(key, "Name", NULL, NULL, (LPBYTE)provname, &len); if( r != ERROR_SUCCESS ) { TRACE("error %ld reading 'Name' from registry\n", r ); @@ -380,7 +380,7 @@ SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto error; } - r = RegQueryValueExA(key, "Image Path", NULL, NULL, temp, &len); + r = RegQueryValueExA(key, "Image Path", NULL, NULL, (LPBYTE)temp, &len); if( r != ERROR_SUCCESS ) { TRACE("error %ld reading 'Image Path' from registry\n", r ); @@ -1097,7 +1097,7 @@ *pdwProvType += (*(--ch) - '0') * 100; CRYPT_Free(keyname); - result = RegQueryValueExA(hSubkey, "TypeName", NULL, &dwType, pszTypeName, pcbTypeName); + result = RegQueryValueExA(hSubkey, "TypeName", NULL, &dwType, (LPBYTE)pszTypeName, pcbTypeName); if (result) CRYPT_ReturnLastError(result); @@ -1254,7 +1254,7 @@ } CRYPT_Free(keyname); - result = RegQueryValueExA(hKey, "Name", NULL, NULL, pszProvName, pcbProvName); + result = RegQueryValueExA(hKey, "Name", NULL, NULL, (LPBYTE)pszProvName, pcbProvName); if (result) { if (result != ERROR_MORE_DATA) @@ -1455,7 +1455,7 @@ * Success: TRUE * Failure: FALSE */ -BOOL WINAPI CryptHashData (HCRYPTHASH hHash, BYTE *pbData, DWORD dwDataLen, DWORD dwFlags) +BOOL WINAPI CryptHashData (HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags) { PCRYPTHASH hash = (PCRYPTHASH)hHash; PCRYPTPROV prov; @@ -1464,7 +1464,7 @@ if (!hash) CRYPT_ReturnLastError(ERROR_INVALID_HANDLE); - if (!pbData || !dwDataLen || !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV) + if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV) CRYPT_ReturnLastError(ERROR_INVALID_PARAMETER); prov = hash->pProvider; @@ -1754,7 +1754,7 @@ } CRYPT_Free(keyname); - if (RegSetValueExA(hTypeKey, "Name", 0, REG_SZ, pszProvName, strlen(pszProvName) + 1)) + if (RegSetValueExA(hTypeKey, "Name", 0, REG_SZ, (LPBYTE)pszProvName, strlen(pszProvName) + 1)) { RegCloseKey(hTypeKey); RegCloseKey(hProvKey); diff -urN wine-20050628/dlls/advapi32/lsa.c wine-20050725/dlls/advapi32/lsa.c --- wine-20050628/dlls/advapi32/lsa.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/advapi32/lsa.c 2005-07-11 12:59:42.000000000 +0200 @@ -0,0 +1,438 @@ +/* + * Implementation of the Local Security Authority API + * + * Copyright 1999 Juergen Schmied + * Copyright 2002 Andriy Palamarchuk + * Copyright 2004 Mike McCormack + * Copyright 2005 Hans Leidekker + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "windef.h" +#include "winbase.h" +#include "winreg.h" +#include "winternl.h" +#include "ntstatus.h" +#include "ntsecapi.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(advapi); + +#define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \ + if (!ADVAPI_IsLocalComputer(ServerName)) \ +{ \ + FIXME("Action Implemented for local computer only. " \ + "Requested for server %s\n", debugstr_w(ServerName)); \ + return FailureCode; \ +} + +static void dumpLsaAttributes(PLSA_OBJECT_ATTRIBUTES oa) +{ + if (oa) + { + TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n", + oa->Length, oa->RootDirectory, + oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null", + oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService); + } +} + +/************************************************************ + * ADVAPI_IsLocalComputer + * + * Checks whether the server name indicates local machine. + */ +static BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName) +{ + DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; + BOOL Result; + LPWSTR buf; + + if (!ServerName || !ServerName[0]) + return TRUE; + + buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR)); + Result = GetComputerNameW(buf, &dwSize); + if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\')) + ServerName += 2; + Result = Result && !lstrcmpW(ServerName, buf); + HeapFree(GetProcessHeap(), 0, buf); + + return Result; +} + +/****************************************************************************** + * LsaClose [ADVAPI32.@] + * + * Closes a handle to a Policy or TrustedDomain. + * + * PARAMS + * ObjectHandle [I] Handle to a Policy or TrustedDomain. + * + * RETURNS + * Success: STATUS_SUCCESS. + * Failure: NTSTATUS code. + */ +NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle) +{ + FIXME("(%p) stub\n", ObjectHandle); + return 0xc0000000; +} + +/****************************************************************************** + * LsaEnumerateTrustedDomains [ADVAPI32.@] + * + * Returns the names and SIDs of trusted domains. + * + * PARAMS + * PolicyHandle [I] Handle to a Policy object. + * EnumerationContext [I] Pointer to an enumeration handle. + * Buffer [O] Contains the names and SIDs of trusted domains. + * PreferredMaximumLength[I] Preferred maximum size in bytes of Buffer. + * CountReturned [O] Number of elements in Buffer. + * + * RETURNS + * Success: STATUS_SUCCESS, + * STATUS_MORE_ENTRIES, + * STATUS_NO_MORE_ENTRIES + * Failure: NTSTATUS code. + * + * NOTES + * LsaEnumerateTrustedDomains can be called multiple times to enumerate + * all trusted domains. + */ +NTSTATUS WINAPI LsaEnumerateTrustedDomains( + IN LSA_HANDLE PolicyHandle, + IN PLSA_ENUMERATION_HANDLE EnumerationContext, + OUT PVOID* Buffer, + IN ULONG PreferredMaximumLength, + OUT PULONG CountReturned) +{ + FIXME("(%p,%p,%p,0x%08lx,%p) stub\n", PolicyHandle, EnumerationContext, + Buffer, PreferredMaximumLength, CountReturned); + + if (CountReturned) *CountReturned = 0; + return STATUS_SUCCESS; +} + +/****************************************************************************** + * LsaFreeMemory [ADVAPI32.@] + * + * Frees memory allocated by a LSA function. + * + * PARAMS + * Buffer [I] Memory buffer to free. + * + * RETURNS + * Success: STATUS_SUCCESS. + * Failure: NTSTATUS code. + */ +NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer) +{ + TRACE("(%p)\n", Buffer); + return HeapFree(GetProcessHeap(), 0, Buffer); +} + +/****************************************************************************** + * LsaLookupNames [ADVAPI32.@] + * + * Returns the SIDs of an array of user, group, or local group names. + * + * PARAMS + * PolicyHandle [I] Handle to a Policy object. + * Count [I] Number of names in Names. + * Names [I] Array of names to lookup. + * ReferencedDomains [O] Array of domains where the names were found. + * Sids [O] Array of SIDs corresponding to Names. + * + * RETURNS + * Success: STATUS_SUCCESS, + * STATUS_SOME_NOT_MAPPED + * Failure: STATUS_NONE_MAPPED or NTSTATUS code. + */ +NTSTATUS WINAPI LsaLookupNames( + IN LSA_HANDLE PolicyHandle, + IN ULONG Count, + IN PLSA_UNICODE_STRING Names, + OUT PLSA_REFERENCED_DOMAIN_LIST* ReferencedDomains, + OUT PLSA_TRANSLATED_SID* Sids) +{ + FIXME("(%p,0x%08lx,%p,%p,%p) stub\n", PolicyHandle, Count, Names, + ReferencedDomains, Sids); + + return STATUS_NONE_MAPPED; +} + +/****************************************************************************** + * LsaLookupSids [ADVAPI32.@] + * + * Looks up the names that correspond to an array of SIDs. + * + * PARAMS + * PolicyHandle [I] Handle to a Policy object. + * Count [I] Number of SIDs in the Sids array. + * Sids [I] Array of SIDs to lookup. + * ReferencedDomains [O] Array of domains where the sids were found. + * Names [O] Array of names corresponding to Sids. + * + * RETURNS + * Success: STATUS_SUCCESS, + * STATUS_SOME_NOT_MAPPED + * Failure: STATUS_NONE_MAPPED or NTSTATUS code. + */ +NTSTATUS WINAPI LsaLookupSids( + IN LSA_HANDLE PolicyHandle, + IN ULONG Count, + IN PSID *Sids, + OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains, + OUT PLSA_TRANSLATED_NAME *Names ) +{ + FIXME("(%p,%lu,%p,%p,%p) stub\n", PolicyHandle, Count, Sids, + ReferencedDomains, Names); + + return FALSE; +} + +/****************************************************************************** + * LsaNtStatusToWinError [ADVAPI32.@] + * + * Converts an LSA NTSTATUS code to a Windows error code. + * + * PARAMS + * Status [I] NTSTATUS code. + * + * RETURNS + * Success: Corresponding Windows error code. + * Failure: ERROR_MR_MID_NOT_FOUND. + */ +ULONG WINAPI LsaNtStatusToWinError(NTSTATUS Status) +{ + return RtlNtStatusToDosError(Status); +} + +/****************************************************************************** + * LsaOpenPolicy [ADVAPI32.@] + * + * Opens a handle to the Policy object on a local or remote system. + * + * PARAMS + * SystemName [I] Name of the target system. + * ObjectAttributes [I] Connection attributes. + * DesiredAccess [I] Requested access rights. + * PolicyHandle [I/O] Handle to the Policy object. + * + * RETURNS + * Success: STATUS_SUCCESS. + * Failure: NTSTATUS code. + * + * NOTES + * Set SystemName to NULL to open the local Policy object. + */ +NTSTATUS WINAPI LsaOpenPolicy( + IN PLSA_UNICODE_STRING SystemName, + IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, + IN ACCESS_MASK DesiredAccess, + IN OUT PLSA_HANDLE PolicyHandle) +{ + FIXME("(%s,%p,0x%08lx,%p) stub\n", + SystemName?debugstr_w(SystemName->Buffer):"(null)", + ObjectAttributes, DesiredAccess, PolicyHandle); + + ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL, + STATUS_ACCESS_VIOLATION); + dumpLsaAttributes(ObjectAttributes); + + if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe; + return STATUS_SUCCESS; +} + +/****************************************************************************** + * LsaQueryInformationPolicy [ADVAPI32.@] + * + * Returns information about a Policy object. + * + * PARAMS + * PolicyHandle [I] Handle to a Policy object. + * InformationClass [I] Type of information to retrieve. + * Buffer [O] Pointer to the requested information. + * + * RETURNS + * Success: STATUS_SUCCESS. + * Failure: NTSTATUS code. + */ +NTSTATUS WINAPI LsaQueryInformationPolicy( + IN LSA_HANDLE PolicyHandle, + IN POLICY_INFORMATION_CLASS InformationClass, + OUT PVOID *Buffer) +{ + FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle, InformationClass, Buffer); + + if(!Buffer) return FALSE; + switch (InformationClass) + { + case PolicyAuditEventsInformation: /* 2 */ + { + PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(POLICY_AUDIT_EVENTS_INFO)); + p->AuditingMode = FALSE; /* no auditing */ + *Buffer = p; + } + break; + case PolicyPrimaryDomainInformation: /* 3 */ + case PolicyAccountDomainInformation: /* 5 */ + { + struct di + { + POLICY_PRIMARY_DOMAIN_INFO ppdi; + SID sid; + }; + + SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY}; + + struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi)); + HKEY key; + BOOL useDefault = TRUE; + LONG ret; + + if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0, + KEY_READ, &key)) == ERROR_SUCCESS) + { + DWORD size = 0; + static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 }; + + ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size); + if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS) + { + xdi->ppdi.Name.Buffer = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, size); + + if ((ret = RegQueryValueExW(key, wg, NULL, NULL, + (LPBYTE)xdi->ppdi.Name.Buffer, &size)) == ERROR_SUCCESS) + { + xdi->ppdi.Name.Length = (USHORT)size; + useDefault = FALSE; + } + else + { + HeapFree(GetProcessHeap(), 0, xdi->ppdi.Name.Buffer); + xdi->ppdi.Name.Buffer = NULL; + } + } + RegCloseKey(key); + } + if (useDefault) + RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN"); + + TRACE("setting domain to %s\n", debugstr_w(xdi->ppdi.Name.Buffer)); + + xdi->ppdi.Sid = &(xdi->sid); + xdi->sid.Revision = SID_REVISION; + xdi->sid.SubAuthorityCount = 1; + xdi->sid.IdentifierAuthority = localSidAuthority; + xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID; + *Buffer = xdi; + } + break; + case PolicyAuditLogInformation: + case PolicyPdAccountInformation: + case PolicyLsaServerRoleInformation: + case PolicyReplicaSourceInformation: + case PolicyDefaultQuotaInformation: + case PolicyModificationInformation: + case PolicyAuditFullSetInformation: + case PolicyAuditFullQueryInformation: + case PolicyDnsDomainInformation: + { + FIXME("category not implemented\n"); + return FALSE; + } + } + return TRUE; +} + +/****************************************************************************** + * LsaRetrievePrivateData [ADVAPI32.@] + * + * Retrieves data stored by LsaStorePrivateData. + * + * PARAMS + * PolicyHandle [I] Handle to a Policy object. + * KeyName [I] Name of the key where the data is stored. + * PrivateData [O] Pointer to the private data. + * + * RETURNS + * Success: STATUS_SUCCESS. + * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code. + */ +NTSTATUS WINAPI LsaRetrievePrivateData( + IN LSA_HANDLE PolicyHandle, + IN PLSA_UNICODE_STRING KeyName, + OUT PLSA_UNICODE_STRING* PrivateData) +{ + FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData); + return STATUS_OBJECT_NAME_NOT_FOUND; +} + +/****************************************************************************** + * LsaSetInformationPolicy [ADVAPI32.@] + * + * Modifies information in a Policy object. + * + * PARAMS + * PolicyHandle [I] Handle to a Policy object. + * InformationClass [I] Type of information to set. + * Buffer [I] Pointer to the information to set. + * + * RETURNS + * Success: STATUS_SUCCESS. + * Failure: NTSTATUS code. + */ +NTSTATUS WINAPI LsaSetInformationPolicy( + IN LSA_HANDLE PolicyHandle, + IN POLICY_INFORMATION_CLASS InformationClass, + IN PVOID Buffer) +{ + FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle, InformationClass, Buffer); + + return STATUS_UNSUCCESSFUL; +} + +/****************************************************************************** + * LsaStorePrivateData [ADVAPI32.@] + * + * Stores or deletes a Policy object's data under the specified reg key. + * + * PARAMS + * PolicyHandle [I] Handle to a Policy object. + * KeyName [I] Name of the key where the data will be stored. + * PrivateData [O] Pointer to the private data. + * + * RETURNS + * Success: STATUS_SUCCESS. + * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code. + */ +NTSTATUS WINAPI LsaStorePrivateData( + IN LSA_HANDLE PolicyHandle, + IN PLSA_UNICODE_STRING KeyName, + IN PLSA_UNICODE_STRING PrivateData) +{ + FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData); + return STATUS_OBJECT_NAME_NOT_FOUND; +} diff -urN wine-20050628/dlls/advapi32/registry.c wine-20050725/dlls/advapi32/registry.c --- wine-20050628/dlls/advapi32/registry.c 2005-06-17 15:58:35.000000000 +0200 +++ wine-20050725/dlls/advapi32/registry.c 2005-07-18 17:10:22.000000000 +0200 @@ -694,7 +694,7 @@ if(lpValueBuf != NULL && *ldwTotsize + val_list[i].ve_valuelen <= maxBytes) { status = RegQueryValueExA(hkey, val_list[i].ve_valuename, NULL, &val_list[i].ve_type, - bufptr, &val_list[i].ve_valuelen); + (LPBYTE)bufptr, &val_list[i].ve_valuelen); if(status != ERROR_SUCCESS) { return status; @@ -739,7 +739,7 @@ if(lpValueBuf != NULL && *ldwTotsize + val_list[i].ve_valuelen <= maxBytes) { status = RegQueryValueExW(hkey, val_list[i].ve_valuename, NULL, &val_list[i].ve_type, - bufptr, &val_list[i].ve_valuelen); + (LPBYTE)bufptr, &val_list[i].ve_valuelen); if(status != ERROR_SUCCESS) { return status; @@ -1328,6 +1328,256 @@ /****************************************************************************** + * ADVAPI_ApplyRestrictions [internal] + * + * Helper function for RegGetValueA/W. + */ +VOID ADVAPI_ApplyRestrictions( DWORD dwFlags, DWORD dwType, DWORD cbData, + PLONG ret ) +{ + /* Check if the type is restricted by the passed flags */ + if (*ret == ERROR_SUCCESS || *ret == ERROR_MORE_DATA) + { + DWORD dwMask = 0; + + switch (dwType) + { + case REG_NONE: dwMask = RRF_RT_REG_NONE; break; + case REG_SZ: dwMask = RRF_RT_REG_SZ; break; + case REG_EXPAND_SZ: dwMask = RRF_RT_REG_EXPAND_SZ; break; + case REG_MULTI_SZ: dwMask = RRF_RT_REG_MULTI_SZ; break; + case REG_BINARY: dwMask = RRF_RT_REG_BINARY; break; + case REG_DWORD: dwMask = RRF_RT_REG_DWORD; break; + case REG_QWORD: dwMask = RRF_RT_REG_QWORD; break; + } + + if (dwFlags & dwMask) + { + /* Type is not restricted, check for size mismatch */ + if (dwType == REG_BINARY) + { + DWORD cbExpect = 0; + + if ((dwFlags & RRF_RT_DWORD) == RRF_RT_DWORD) + cbExpect = 4; + else if ((dwFlags & RRF_RT_DWORD) == RRF_RT_QWORD) + cbExpect = 8; + + if (cbExpect && cbData != cbExpect) + *ret = ERROR_DATATYPE_MISMATCH; + } + } + else *ret = ERROR_UNSUPPORTED_TYPE; + } +} + + +/****************************************************************************** + * RegGetValueW [ADVAPI32.@] + * + * Retrieves the type and data for a value name associated with a key + * optionally expanding it's content and restricting it's type. + * + * PARAMS + * hKey [I] Handle to an open key. + * pszSubKey [I] Name of the subkey of hKey. + * pszValue [I] Name of value under hKey/szSubKey to query. + * dwFlags [I] Flags restricting the value type to retrieve. + * pdwType [O] Destination for the values type, may be NULL. + * pvData [O] Destination for the values content, may be NULL. + * pcbData [I/O] Size of pvData, updated with the size required to + * retrieve the whole content. + * + * RETURNS + * Success: ERROR_SUCCESS + * Failure: nonzero error code from Winerror.h + * + * NOTES + * - Unless RRF_NOEXPAND is specified REG_EXPAND_SZ is automatically expanded + * and REG_SZ is retrieved instead. + * - Restrictions are applied after expanding, using RRF_RT_REG_EXPAND_SZ + * without RRF_NOEXPAND is thus not allowed. + */ +LONG WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, + DWORD dwFlags, LPDWORD pdwType, PVOID pvData, + LPDWORD pcbData ) +{ + DWORD dwType, cbData = pcbData ? *pcbData : 0; + PVOID pvBuf = NULL; + LONG ret; + + TRACE("(%p,%s,%s,%ld,%p,%p,%p=%ld)\n", + hKey, debugstr_w(pszSubKey), debugstr_w(pszValue), dwFlags, pdwType, + pvData, pcbData, cbData); + + if ((dwFlags & RRF_RT_REG_EXPAND_SZ) && !(dwFlags & RRF_NOEXPAND)) + return ERROR_INVALID_PARAMETER; + + if (pszSubKey && pszSubKey[0]) + { + ret = RegOpenKeyExW(hKey, pszSubKey, 0, KEY_QUERY_VALUE, &hKey); + if (ret != ERROR_SUCCESS) return ret; + } + + ret = RegQueryValueExW(hKey, pszValue, NULL, &dwType, pvData, &cbData); + + /* If we are going to expand we need to read in the whole the value even + * if the passed buffer was too small as the expanded string might be + * smaller than the unexpanded one and could fit into cbData bytes. */ + if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && + (dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND))) + { + do { + if (pvBuf) HeapFree(GetProcessHeap(), 0, pvBuf); + + pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData); + if (!pvBuf) + { + ret = ERROR_NOT_ENOUGH_MEMORY; + break; + } + + if (ret == ERROR_MORE_DATA) + ret = RegQueryValueExW(hKey, pszValue, NULL, + &dwType, pvBuf, &cbData); + else + { + /* Even if cbData was large enough we have to copy the + * string since ExpandEnvironmentStrings can't handle + * overlapping buffers. */ + CopyMemory(pvBuf, pvData, cbData); + } + + /* Both the type or the value itself could have been modified in + * between so we have to keep retrying until the buffer is large + * enough or we no longer have to expand the value. */ + } while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA); + + if (ret == ERROR_SUCCESS) + { + if (dwType == REG_EXPAND_SZ) + { + cbData = ExpandEnvironmentStringsW(pvBuf, pvData, + pcbData ? *pcbData : 0); + dwType = REG_SZ; + if(pcbData && cbData > *pcbData) + ret = ERROR_MORE_DATA; + } + else if (pcbData) + CopyMemory(pvData, pvBuf, *pcbData); + } + + if (pvBuf) HeapFree(GetProcessHeap(), 0, pvBuf); + } + + if (pszSubKey && pszSubKey[0]) + RegCloseKey(hKey); + + ADVAPI_ApplyRestrictions(dwFlags, dwType, cbData, &ret); + + if (pcbData && ret != ERROR_SUCCESS && (dwFlags & RRF_ZEROONFAILURE)) + ZeroMemory(pvData, *pcbData); + + if (pdwType) *pdwType = dwType; + if (pcbData) *pcbData = cbData; + + return ret; +} + + +/****************************************************************************** + * RegGetValueA [ADVAPI32.@] + * + * See RegGetValueW. + */ +LONG WINAPI RegGetValueA( HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, + DWORD dwFlags, LPDWORD pdwType, PVOID pvData, + LPDWORD pcbData ) +{ + DWORD dwType, cbData = pcbData ? *pcbData : 0; + PVOID pvBuf = NULL; + LONG ret; + + TRACE("(%p,%s,%s,%ld,%p,%p,%p=%ld)\n", + hKey, pszSubKey, pszValue, dwFlags, pdwType, pvData, pcbData, + cbData); + + if ((dwFlags & RRF_RT_REG_EXPAND_SZ) && !(dwFlags & RRF_NOEXPAND)) + return ERROR_INVALID_PARAMETER; + + if (pszSubKey && pszSubKey[0]) + { + ret = RegOpenKeyExA(hKey, pszSubKey, 0, KEY_QUERY_VALUE, &hKey); + if (ret != ERROR_SUCCESS) return ret; + } + + ret = RegQueryValueExA(hKey, pszValue, NULL, &dwType, pvData, &cbData); + + /* If we are going to expand we need to read in the whole the value even + * if the passed buffer was too small as the expanded string might be + * smaller than the unexpanded one and could fit into cbData bytes. */ + if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) && + (dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND))) + { + do { + if (pvBuf) HeapFree(GetProcessHeap(), 0, pvBuf); + + pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData); + if (!pvBuf) + { + ret = ERROR_NOT_ENOUGH_MEMORY; + break; + } + + if (ret == ERROR_MORE_DATA) + ret = RegQueryValueExA(hKey, pszValue, NULL, + &dwType, pvBuf, &cbData); + else + { + /* Even if cbData was large enough we have to copy the + * string since ExpandEnvironmentStrings can't handle + * overlapping buffers. */ + CopyMemory(pvBuf, pvData, cbData); + } + + /* Both the type or the value itself could have been modified in + * between so we have to keep retrying until the buffer is large + * enough or we no longer have to expand the value. */ + } while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA); + + if (ret == ERROR_SUCCESS) + { + if (dwType == REG_EXPAND_SZ) + { + cbData = ExpandEnvironmentStringsA(pvBuf, pvData, + pcbData ? *pcbData : 0); + dwType = REG_SZ; + if(pcbData && cbData > *pcbData) + ret = ERROR_MORE_DATA; + } + else if (pcbData) + CopyMemory(pvData, pvBuf, *pcbData); + } + + if (pvBuf) HeapFree(GetProcessHeap(), 0, pvBuf); + } + + if (pszSubKey && pszSubKey[0]) + RegCloseKey(hKey); + + ADVAPI_ApplyRestrictions(dwFlags, dwType, cbData, &ret); + + if (pcbData && ret != ERROR_SUCCESS && (dwFlags & RRF_ZEROONFAILURE)) + ZeroMemory(pvData, *pcbData); + + if (pdwType) *pdwType = dwType; + if (pcbData) *pcbData = cbData; + + return ret; +} + + +/****************************************************************************** * RegEnumValueW [ADVAPI32.@] * * PARAMS diff -urN wine-20050628/dlls/advapi32/security.c wine-20050725/dlls/advapi32/security.c --- wine-20050628/dlls/advapi32/security.c 2005-06-24 13:54:15.000000000 +0200 +++ wine-20050725/dlls/advapi32/security.c 2005-07-06 12:37:50.000000000 +0200 @@ -103,17 +103,6 @@ return !status; } -static void dumpLsaAttributes( PLSA_OBJECT_ATTRIBUTES oa ) -{ - if (oa) - { - TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n", - oa->Length, oa->RootDirectory, - oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null", - oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService); - } -} - #define WINE_SIZE_OF_WORLD_ACCESS_ACL (sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD)) static void GetWorldAccessACL(PACL pACL) @@ -157,14 +146,6 @@ return Result; } -#define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \ - if (!ADVAPI_IsLocalComputer(ServerName)) \ - { \ - FIXME("Action Implemented for local computer only. " \ - "Requested for server %s\n", debugstr_w(ServerName)); \ - return FailureCode; \ - } - /* ############################## ###### TOKEN FUNCTIONS ###### ############################## @@ -1616,233 +1597,6 @@ return TRUE; } -NTSTATUS WINAPI -LsaEnumerateTrustedDomains( - LSA_HANDLE PolicyHandle, - PLSA_ENUMERATION_HANDLE EnumerationContext, - PVOID* Buffer, - ULONG PreferedMaximumLength, - PULONG CountReturned) -{ - FIXME("(%p,%p,%p,0x%08lx,%p):stub\n", PolicyHandle, EnumerationContext, - Buffer, PreferedMaximumLength, CountReturned); - - if (CountReturned) *CountReturned = 0; - return STATUS_SUCCESS; -} - -NTSTATUS WINAPI -LsaLookupNames( - LSA_HANDLE PolicyHandle, - ULONG Count, - PLSA_UNICODE_STRING Names, - PLSA_REFERENCED_DOMAIN_LIST* ReferencedDomains, - PLSA_TRANSLATED_SID* Sids) -{ - FIXME("(%p,0x%08lx,%p,%p,%p):stub\n", PolicyHandle, Count, Names, - ReferencedDomains, Sids); - - return STATUS_NONE_MAPPED; -} - -/****************************************************************************** - * LsaOpenPolicy [ADVAPI32.@] - * - * PARAMS - * SystemName [I] - * ObjectAttributes [I] - * DesiredAccess [I] - * PolicyHandle [I/O] - */ -NTSTATUS WINAPI -LsaOpenPolicy( - IN PLSA_UNICODE_STRING SystemName, - IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, - IN ACCESS_MASK DesiredAccess, - IN OUT PLSA_HANDLE PolicyHandle) -{ - FIXME("(%s,%p,0x%08lx,%p):stub\n", - SystemName?debugstr_w(SystemName->Buffer):"null", - ObjectAttributes, DesiredAccess, PolicyHandle); - ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL, - STATUS_ACCESS_VIOLATION); - dumpLsaAttributes(ObjectAttributes); - if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe; - return STATUS_SUCCESS; -} - -/****************************************************************************** - * LsaQueryInformationPolicy [ADVAPI32.@] - */ -NTSTATUS WINAPI -LsaQueryInformationPolicy( - IN LSA_HANDLE PolicyHandle, - IN POLICY_INFORMATION_CLASS InformationClass, - OUT PVOID *Buffer) -{ - FIXME("(%p,0x%08x,%p):stub\n", - PolicyHandle, InformationClass, Buffer); - - if(!Buffer) return FALSE; - switch (InformationClass) - { - case PolicyAuditEventsInformation: /* 2 */ - { - PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POLICY_AUDIT_EVENTS_INFO)); - p->AuditingMode = FALSE; /* no auditing */ - *Buffer = p; - } - break; - case PolicyPrimaryDomainInformation: /* 3 */ - case PolicyAccountDomainInformation: /* 5 */ - { - struct di - { POLICY_PRIMARY_DOMAIN_INFO ppdi; - SID sid; - }; - SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY}; - - struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(xdi)); - HKEY key; - BOOL useDefault = TRUE; - LONG ret; - - if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0, - KEY_READ, &key)) == ERROR_SUCCESS) - { - DWORD size = 0; - static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 }; - - ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size); - if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS) - { - xdi->ppdi.Name.Buffer = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, size); - if ((ret = RegQueryValueExW(key, wg, NULL, NULL, - (LPBYTE)xdi->ppdi.Name.Buffer, &size)) == ERROR_SUCCESS) - { - xdi->ppdi.Name.Length = (USHORT)size; - useDefault = FALSE; - } - else - { - HeapFree(GetProcessHeap(), 0, xdi->ppdi.Name.Buffer); - xdi->ppdi.Name.Buffer = NULL; - } - } - RegCloseKey(key); - } - if (useDefault) - RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN"); - TRACE("setting domain to %s\n", debugstr_w(xdi->ppdi.Name.Buffer)); - - xdi->ppdi.Sid = &(xdi->sid); - xdi->sid.Revision = SID_REVISION; - xdi->sid.SubAuthorityCount = 1; - xdi->sid.IdentifierAuthority = localSidAuthority; - xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID; - *Buffer = xdi; - } - break; - case PolicyAuditLogInformation: - case PolicyPdAccountInformation: - case PolicyLsaServerRoleInformation: - case PolicyReplicaSourceInformation: - case PolicyDefaultQuotaInformation: - case PolicyModificationInformation: - case PolicyAuditFullSetInformation: - case PolicyAuditFullQueryInformation: - case PolicyDnsDomainInformation: - { - FIXME("category not implemented\n"); - return FALSE; - } - } - return TRUE; -} - -/****************************************************************************** - * LsaSetInformationPolicy [ADVAPI32.@] - */ -NTSTATUS WINAPI -LsaSetInformationPolicy( - LSA_HANDLE PolicyHandle, - POLICY_INFORMATION_CLASS InformationClass, - PVOID Buffer) -{ - FIXME("(%p,0x%08x,%p):stub\n", PolicyHandle, InformationClass, Buffer); - - return STATUS_UNSUCCESSFUL; -} - -/****************************************************************************** - * LsaLookupSids [ADVAPI32.@] - */ -NTSTATUS WINAPI -LsaLookupSids( - IN LSA_HANDLE PolicyHandle, - IN ULONG Count, - IN PSID *Sids, - OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains, - OUT PLSA_TRANSLATED_NAME *Names ) -{ - FIXME("%p %lu %p %p %p\n", - PolicyHandle, Count, Sids, ReferencedDomains, Names); - return FALSE; -} - -/****************************************************************************** - * LsaFreeMemory [ADVAPI32.@] - */ -NTSTATUS WINAPI -LsaFreeMemory(IN PVOID Buffer) -{ - TRACE("(%p)\n",Buffer); - return HeapFree(GetProcessHeap(), 0, Buffer); -} -/****************************************************************************** - * LsaClose [ADVAPI32.@] - */ -NTSTATUS WINAPI -LsaClose(IN LSA_HANDLE ObjectHandle) -{ - FIXME("(%p):stub\n",ObjectHandle); - return 0xc0000000; -} - -/****************************************************************************** - * LsaStorePrivateData [ADVAPI32.@] - */ -NTSTATUS WINAPI LsaStorePrivateData( LSA_HANDLE PolicyHandle, - PLSA_UNICODE_STRING KeyName, PLSA_UNICODE_STRING PrivateData) -{ - FIXME("%p %p %p\n", PolicyHandle, KeyName, PrivateData); - return STATUS_OBJECT_NAME_NOT_FOUND; -} - -/****************************************************************************** - * LsaRetrievePrivateData [ADVAPI32.@] - */ -NTSTATUS WINAPI LsaRetrievePrivateData( LSA_HANDLE PolicyHandle, - PLSA_UNICODE_STRING KeyName, PLSA_UNICODE_STRING* PrivateData) -{ - FIXME("%p %p %p\n", PolicyHandle, KeyName, PrivateData); - return STATUS_OBJECT_NAME_NOT_FOUND; -} - -/****************************************************************************** - * LsaNtStatusToWinError [ADVAPI32.@] - * - * PARAMS - * Status [I] - */ -ULONG WINAPI -LsaNtStatusToWinError(NTSTATUS Status) -{ - return RtlNtStatusToDosError(Status); -} - /****************************************************************************** * NotifyBootConfigStatus [ADVAPI32.@] * diff -urN wine-20050628/dlls/advapi32/service.c wine-20050725/dlls/advapi32/service.c --- wine-20050628/dlls/advapi32/service.c 2005-06-13 12:00:37.000000000 +0200 +++ wine-20050725/dlls/advapi32/service.c 2005-07-06 21:08:05.000000000 +0200 @@ -1654,7 +1654,7 @@ total = sizeof (QUERY_SERVICE_CONFIGA); sz = sizeof(str_buffer); - r = RegQueryValueExA( hKey, szImagePath, 0, &type, str_buffer, &sz ); + r = RegQueryValueExA( hKey, szImagePath, 0, &type, (LPBYTE)str_buffer, &sz ); if( ( r == ERROR_SUCCESS ) && ( type == REG_SZ || type == REG_EXPAND_SZ ) ) { sz = ExpandEnvironmentStringsA(str_buffer,NULL,0); @@ -1719,7 +1719,7 @@ n = total - sizeof (QUERY_SERVICE_CONFIGA); sz = sizeof(str_buffer); - r = RegQueryValueExA( hKey, szImagePath, 0, &type, str_buffer, &sz ); + r = RegQueryValueExA( hKey, szImagePath, 0, &type, (LPBYTE)str_buffer, &sz ); if( ( r == ERROR_SUCCESS ) && ( type == REG_SZ || type == REG_EXPAND_SZ ) ) { sz = ExpandEnvironmentStringsA(str_buffer, p, n); @@ -1736,7 +1736,7 @@ } sz = n; - r = RegQueryValueExA( hKey, szGroup, 0, &type, p, &sz ); + r = RegQueryValueExA( hKey, szGroup, 0, &type, (LPBYTE)p, &sz ); if( ( r == ERROR_SUCCESS ) || ( type == REG_SZ ) ) { lpServiceConfig->lpLoadOrderGroup = (LPSTR) p; @@ -1745,7 +1745,7 @@ } sz = n; - r = RegQueryValueExA( hKey, szDependencies, 0, &type, p, &sz ); + r = RegQueryValueExA( hKey, szDependencies, 0, &type, (LPBYTE)p, &sz ); if( ( r == ERROR_SUCCESS ) || ( type == REG_SZ ) ) { lpServiceConfig->lpDependencies = (LPSTR) p; diff -urN wine-20050628/dlls/advapi32/tests/crypt.c wine-20050725/dlls/advapi32/tests/crypt.c --- wine-20050628/dlls/advapi32/tests/crypt.c 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/advapi32/tests/crypt.c 2005-07-07 14:08:43.000000000 +0200 @@ -362,7 +362,7 @@ (*pcbProvName)++; RegOpenKey(hKey, *pszProvName, &subkey); - RegQueryValueEx(subkey, "Type", NULL, NULL, (BYTE*)pdwProvType, &size); + RegQueryValueEx(subkey, "Type", NULL, NULL, (LPBYTE)pdwProvType, &size); RegCloseKey(subkey); RegCloseKey(hKey); @@ -485,7 +485,7 @@ if (!(*pszTypeName = ((LPSTR)LocalAlloc(LMEM_ZEROINIT, *pcbTypeName)))) return FALSE; - if (RegQueryValueEx(hSubKey, "TypeName", NULL, NULL, *pszTypeName, pcbTypeName)) + if (RegQueryValueEx(hSubKey, "TypeName", NULL, NULL, (LPBYTE)*pszTypeName, pcbTypeName)) return FALSE; RegCloseKey(hSubKey); @@ -612,7 +612,7 @@ } LocalFree(keyname); - if (RegQueryValueEx(hKey, "Name", NULL, NULL, *pszProvName, pcbProvName)) + if (RegQueryValueEx(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName, pcbProvName)) { if (GetLastError() != ERROR_MORE_DATA) SetLastError(NTE_PROV_TYPE_ENTRY_BAD); @@ -622,7 +622,7 @@ if (!(*pszProvName = LocalAlloc(LMEM_ZEROINIT, *pcbProvName))) return FALSE; - if (RegQueryValueEx(hKey, "Name", NULL, NULL, *pszProvName, pcbProvName)) + if (RegQueryValueEx(hKey, "Name", NULL, NULL, (LPBYTE)*pszProvName, pcbProvName)) { if (GetLastError() != ERROR_MORE_DATA) SetLastError(NTE_PROV_TYPE_ENTRY_BAD); diff -urN wine-20050628/dlls/advapi32/tests/registry.c wine-20050725/dlls/advapi32/tests/registry.c --- wine-20050628/dlls/advapi32/tests/registry.c 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/advapi32/tests/registry.c 2005-07-18 12:30:51.000000000 +0200 @@ -61,14 +61,22 @@ static void create_test_entries(void) { + DWORD qw[2] = { 0x12345678, 0x87654321 }; + SetEnvironmentVariableA("LONGSYSTEMVAR", "bar"); SetEnvironmentVariableA("FOO", "ImARatherLongButIndeedNeededString"); - ok(!RegSetValueExA(hkey_main,"Test1",0,REG_EXPAND_SZ, sTestpath1, strlen(sTestpath1)+1), + ok(!RegSetValueExA(hkey_main,"TP1_EXP_SZ",0,REG_EXPAND_SZ, (LPBYTE)sTestpath1, strlen(sTestpath1)+1), + "RegSetValueExA failed\n"); + ok(!RegSetValueExA(hkey_main,"TP1_SZ",0,REG_SZ, (LPBYTE)sTestpath1, strlen(sTestpath1)+1), + "RegSetValueExA failed\n"); + ok(!RegSetValueExA(hkey_main,"TP2_EXP_SZ",0,REG_EXPAND_SZ, (LPBYTE)sTestpath2, strlen(sTestpath2)+1), "RegSetValueExA failed\n"); - ok(!RegSetValueExA(hkey_main,"Test2",0,REG_SZ, sTestpath1, strlen(sTestpath1)+1), + ok(!RegSetValueExA(hkey_main,"DWORD",0,REG_DWORD, (LPBYTE)qw, 4), "RegSetValueExA failed\n"); - ok(!RegSetValueExA(hkey_main,"Test3",0,REG_EXPAND_SZ, sTestpath2, strlen(sTestpath2)+1), + ok(!RegSetValueExA(hkey_main,"BIN32",0,REG_BINARY, (LPBYTE)qw, 4), + "RegSetValueExA failed\n"); + ok(!RegSetValueExA(hkey_main,"BIN64",0,REG_BINARY, (LPBYTE)qw, 8), "RegSetValueExA failed\n"); } @@ -107,7 +115,7 @@ type = 1234; strcpy( value, "xxxxxxxxxx" ); strcpy( data, "xxxxxxxxxx" ); - res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, data, &data_count ); + res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count ); ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res ); ok( val_count == 2, "val_count set to %ld\n", val_count ); ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count ); @@ -121,7 +129,7 @@ type = 1234; strcpy( value, "xxxxxxxxxx" ); strcpy( data, "xxxxxxxxxx" ); - res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, data, &data_count ); + res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count ); ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res ); /* Win9x returns 2 as specified by MSDN but NT returns 3... */ ok( val_count == 2 || val_count == 3, "val_count set to %ld\n", val_count ); @@ -139,7 +147,7 @@ type = 1234; strcpy( value, "xxxxxxxxxx" ); strcpy( data, "xxxxxxxxxx" ); - res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, data, &data_count ); + res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count ); ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res ); ok( val_count == 0, "val_count set to %ld\n", val_count ); ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count ); @@ -156,7 +164,7 @@ type = 1234; strcpy( value, "xxxxxxxxxx" ); strcpy( data, "xxxxxxxxxx" ); - res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, data, &data_count ); + res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count ); ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res ); ok( val_count == 20, "val_count set to %ld\n", val_count ); ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count ); @@ -170,7 +178,7 @@ type = 1234; strcpy( value, "xxxxxxxxxx" ); strcpy( data, "xxxxxxxxxx" ); - res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, data, &data_count ); + res = RegEnumValueA( test_key, 0, value, &val_count, NULL, &type, (LPBYTE)data, &data_count ); ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", res ); ok( val_count == 4, "val_count set to %ld instead of 4\n", val_count ); ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count ); @@ -249,12 +257,151 @@ DWORD size; DWORD type; - ret = RegQueryValueExA(hkey_main, "Test2", NULL, &type, NULL, &size); + ret = RegQueryValueExA(hkey_main, "TP1_SZ", NULL, &type, NULL, &size); ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); ok(size == strlen(sTestpath1) + 1, "(%ld,%ld)\n", (DWORD)strlen(sTestpath1) + 1, size); ok(type == REG_SZ, "type %ld is not REG_SZ\n", type); } +static void test_get_value(void) +{ + HMODULE hadvapi32; + DWORD (WINAPI *pRegGetValueA)(HKEY,LPCSTR,LPCSTR,DWORD,LPDWORD,PVOID,LPDWORD); + + DWORD ret; + DWORD size; + DWORD type; + DWORD dw, qw[2]; + CHAR buf[80]; + CHAR expanded[] = "bar\\subdir1"; + + /* This function was introduced with Windows 2003 SP1 */ + hadvapi32 = LoadLibraryA("advapi32.dll"); + if(!hadvapi32) + { + ok(0, "error=%ld\n", GetLastError()); + return; + } + pRegGetValueA = (PVOID)GetProcAddress(hadvapi32, "RegGetValueA"); + if(!pRegGetValueA) + return; + + /* Query REG_DWORD using RRF_RT_REG_DWORD (ok) */ + size = type = dw = 0xdeadbeef; + ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_DWORD, &type, &dw, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + ok(size == 4, "size=%ld\n", size); + ok(type == REG_DWORD, "type=%ld\n", type); + ok(dw == 0x12345678, "dw=%ld\n", dw); + + /* Query by subkey-name */ + ret = pRegGetValueA(HKEY_CURRENT_USER, "Software\\Wine\\Test", "DWORD", RRF_RT_REG_DWORD, NULL, NULL, NULL); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + + /* Query REG_DWORD using RRF_RT_REG_BINARY (restricted) */ + size = type = dw = 0xdeadbeef; + ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_BINARY, &type, &dw, &size); + ok(ret == ERROR_UNSUPPORTED_TYPE, "ret=%ld\n", ret); + /* Although the function failed all values are retrieved */ + ok(size == 4, "size=%ld\n", size); + ok(type == REG_DWORD, "type=%ld\n", type); + ok(dw == 0x12345678, "dw=%ld\n", dw); + + /* Test RRF_ZEROONFAILURE */ + type = dw = 0xdeadbeef; size = 4; + ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_REG_SZ|RRF_ZEROONFAILURE, &type, &dw, &size); + ok(ret == ERROR_UNSUPPORTED_TYPE, "ret=%ld\n", ret); + /* Again all values are retrieved ... */ + ok(size == 4, "size=%ld\n", size); + ok(type == REG_DWORD, "type=%ld\n", type); + /* ... except the buffer, which is zeroed out */ + ok(dw == 0, "dw=%ld\n", dw); + + /* Query REG_DWORD using RRF_RT_DWORD (ok) */ + size = type = dw = 0xdeadbeef; + ret = pRegGetValueA(hkey_main, NULL, "DWORD", RRF_RT_DWORD, &type, &dw, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + ok(size == 4, "size=%ld\n", size); + ok(type == REG_DWORD, "type=%ld\n", type); + ok(dw == 0x12345678, "dw=%ld\n", dw); + + /* Query 32-bit REG_BINARY using RRF_RT_DWORD (ok) */ + size = type = dw = 0xdeadbeef; + ret = pRegGetValueA(hkey_main, NULL, "BIN32", RRF_RT_DWORD, &type, &dw, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + ok(size == 4, "size=%ld\n", size); + ok(type == REG_BINARY, "type=%ld\n", type); + ok(dw == 0x12345678, "dw=%ld\n", dw); + + /* Query 64-bit REG_BINARY using RRF_RT_DWORD (type mismatch) */ + qw[0] = qw[1] = size = type = 0xdeadbeef; + ret = pRegGetValueA(hkey_main, NULL, "BIN64", RRF_RT_DWORD, &type, qw, &size); + ok(ret == ERROR_DATATYPE_MISMATCH, "ret=%ld\n", ret); + ok(size == 8, "size=%ld\n", size); + ok(type == REG_BINARY, "type=%ld\n", type); + ok(qw[0] == 0x12345678 && + qw[1] == 0x87654321, "qw={%ld,%ld}\n", qw[0], qw[1]); + + /* Query 64-bit REG_BINARY using 32-bit buffer (buffer too small) */ + type = dw = 0xdeadbeef; size = 4; + ret = pRegGetValueA(hkey_main, NULL, "BIN64", RRF_RT_REG_BINARY, &type, &dw, &size); + ok(ret == ERROR_MORE_DATA, "ret=%ld\n", ret); + ok(dw == 0xdeadbeef, "dw=%ld\n", dw); + ok(size == 8, "size=%ld\n", size); + + /* Query 64-bit REG_BINARY using RRF_RT_QWORD (ok) */ + qw[0] = qw[1] = size = type = 0xdeadbeef; + ret = pRegGetValueA(hkey_main, NULL, "BIN64", RRF_RT_QWORD, &type, qw, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + ok(size == 8, "size=%ld\n", size); + ok(type == REG_BINARY, "type=%ld\n", type); + ok(qw[0] == 0x12345678 && + qw[1] == 0x87654321, "qw={%ld,%ld}\n", qw[0], qw[1]); + + /* Query REG_SZ using RRF_RT_REG_SZ (ok) */ + buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf); + ret = pRegGetValueA(hkey_main, NULL, "TP1_SZ", RRF_RT_REG_SZ, &type, buf, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + ok(size == strlen(sTestpath1)+1, "strlen(sTestpath1)=%d size=%ld\n", strlen(sTestpath1), size); + ok(type == REG_SZ, "type=%ld\n", type); + ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf); + + /* Query REG_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (ok) */ + buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf); + ret = pRegGetValueA(hkey_main, NULL, "TP1_SZ", RRF_RT_REG_SZ|RRF_NOEXPAND, &type, buf, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + ok(size == strlen(sTestpath1)+1, "strlen(sTestpath1)=%d size=%ld\n", strlen(sTestpath1), size); + ok(type == REG_SZ, "type=%ld\n", type); + ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf); + + /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ (ok, expands) */ + buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf); + ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_SZ, &type, buf, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); +#if 0 + /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded length + 1 here. */ + ok(size == strlen(expanded)+1, "strlen(expanded)=%ld size=%ld\n", strlen(expanded), size); +#endif + ok(type == REG_SZ, "type=%ld\n", type); + ok(!strcmp(expanded, buf), "expanded=\"%s\" buf=\"%s\"\n", expanded, buf); + + /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND (ok, doesn't expand) */ + buf[0] = 0; type = 0xdeadbeef; size = sizeof(buf); + ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ|RRF_NOEXPAND, &type, buf, &size); + ok(ret == ERROR_SUCCESS, "ret=%ld\n", ret); + ok(size == strlen(sTestpath1)+1, "strlen(sTestpath1)=%d size=%ld\n", strlen(sTestpath1), size); + ok(type == REG_EXPAND_SZ, "type=%ld\n", type); + ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf); + + /* Query REG_EXPAND_SZ using RRF_RT_REG_SZ|RRF_NOEXPAND (type mismatch) */ + ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_SZ|RRF_NOEXPAND, NULL, NULL, NULL); + ok(ret == ERROR_UNSUPPORTED_TYPE, "ret=%ld\n", ret); + + /* Query REG_EXPAND_SZ using RRF_RT_REG_EXPAND_SZ (not allowed without RRF_NOEXPAND) */ + ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_EXPAND_SZ, NULL, NULL, NULL); + ok(ret == ERROR_INVALID_PARAMETER, "ret=%ld\n", ret); +} + static void test_reg_open_key(void) { DWORD ret = 0; @@ -374,8 +521,10 @@ DWORD ret; ret = RegDeleteKey(hkey_main, NULL); - ok(ret == ERROR_INVALID_PARAMETER || ret == ERROR_ACCESS_DENIED, - "expected ERROR_INVALID_PARAMETER or ERROR_ACCESS_DENIED, got %ld\n", ret); + ok(ret == ERROR_INVALID_PARAMETER || + ret == ERROR_ACCESS_DENIED || + ret == ERROR_BADKEY, /* Win95 */ + "ret=%ld\n", ret); } static void test_reg_save_key(void) @@ -450,6 +599,7 @@ create_test_entries(); test_enum_value(); test_query_value_ex(); + test_get_value(); test_reg_open_key(); test_reg_create_key(); test_reg_close_key(); diff -urN wine-20050628/dlls/advapi32/tests/security.c wine-20050725/dlls/advapi32/tests/security.c --- wine-20050628/dlls/advapi32/tests/security.c 2005-06-28 15:52:01.000000000 +0200 +++ wine-20050725/dlls/advapi32/tests/security.c 2005-06-29 22:14:16.000000000 +0200 @@ -518,14 +518,14 @@ ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping, PrivSet, &PrivSetLen, &Access, &AccessStatus); ok(ret, "AccessCheck failed with error %ld\n", GetLastError()); - todo_wine ok(AccessStatus && (Access == KEY_READ), + ok(AccessStatus && (Access == KEY_READ), "AccessCheck failed to grant access with error %ld\n", GetLastError()); ret = AccessCheck(SecurityDescriptor, Token, MAXIMUM_ALLOWED, &Mapping, PrivSet, &PrivSetLen, &Access, &AccessStatus); ok(ret, "AccessCheck failed with error %ld\n", GetLastError()); - todo_wine ok(AccessStatus, + ok(AccessStatus, "AccessCheck failed to grant any access with error %ld\n", GetLastError()); trace("AccessCheck with MAXIMUM_ALLOWED got Access 0x%08lx\n", Access); diff -urN wine-20050628/dlls/advpack/advpack.c wine-20050725/dlls/advpack/advpack.c --- wine-20050628/dlls/advpack/advpack.c 2005-04-27 11:37:25.000000000 +0200 +++ wine-20050725/dlls/advpack/advpack.c 2005-07-11 20:01:48.000000000 +0200 @@ -370,3 +370,32 @@ { FIXME("(%s): stub\n", debugstr_a(cmdline)); } + +/*********************************************************************** + * ExecuteCab (ADVPACK.@) + * + * BUGS + * Unimplemented + */ +HRESULT WINAPI ExecuteCab( HWND hwnd, PCABINFO pCab, LPVOID pReserved ) +{ + FIXME("(%p %p %p): stub\n", hwnd, pCab, pReserved); + return E_FAIL; +} + +/*********************************************************************** + * TranslateInfString (ADVPACK.@) + * + * BUGS + * Unimplemented + */ +HRESULT WINAPI TranslateInfString(PCSTR pszInfFilename, PCSTR pszInstallSection, + PCSTR pszTranslateSection, PCSTR pszTranslateKey, PSTR pszBuffer, + DWORD dwBufferSize, PDWORD pdwRequiredSize, PVOID pvReserved) +{ + FIXME("(%s %s %s %s %p %ld %p %p): stub\n", + debugstr_a(pszInfFilename), debugstr_a(pszInstallSection), + debugstr_a(pszTranslateSection), debugstr_a(pszTranslateKey), + pszBuffer, dwBufferSize,pdwRequiredSize, pvReserved); + return E_FAIL; +} diff -urN wine-20050628/dlls/advpack/advpack.spec wine-20050725/dlls/advpack/advpack.spec --- wine-20050628/dlls/advpack/advpack.spec 2005-04-18 11:51:53.000000000 +0200 +++ wine-20050725/dlls/advpack/advpack.spec 2005-07-11 20:01:48.000000000 +0200 @@ -5,7 +5,7 @@ @ stdcall DelNodeRunDLL32(ptr ptr str long) @ stdcall DllMain(long long ptr) @ stdcall DoInfInstall(ptr) -@ stub ExecuteCab +@ stdcall ExecuteCab(ptr ptr ptr) @ stub ExtractFiles @ stub FileSaveMarkNotExist @ stub FileSaveRestore @@ -26,7 +26,7 @@ @ stdcall RegisterOCX(ptr ptr str long) @ stdcall RunSetupCommand(long str str str str ptr long ptr) @ stub SetPerUserSecValues -@ stub TranslateInfString +@ stdcall TranslateInfString(str str str str ptr long ptr ptr) @ stub TranslateInfStringEx @ stub UserInstStubWrapper @ stub UserUnInstStubWrapper diff -urN wine-20050628/dlls/amstream/amstream.c wine-20050725/dlls/amstream/amstream.c --- wine-20050628/dlls/amstream/amstream.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/amstream/amstream.c 2005-07-11 16:24:53.000000000 +0200 @@ -36,7 +36,7 @@ typedef struct { IAMMultiMediaStream lpVtbl; - ULONG ref; + LONG ref; } IAMMultiMediaStreamImpl; static const struct IAMMultiMediaStreamVtbl AM_Vtbl; diff -urN wine-20050628/dlls/amstream/main.c wine-20050725/dlls/amstream/main.c --- wine-20050628/dlls/amstream/main.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/amstream/main.c 2005-07-11 16:24:53.000000000 +0200 @@ -64,7 +64,7 @@ typedef struct { IClassFactory ITF_IClassFactory; - DWORD ref; + LONG ref; HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); } IClassFactoryImpl; diff -urN wine-20050628/dlls/atl/registrar.c wine-20050725/dlls/atl/registrar.c --- wine-20050628/dlls/atl/registrar.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/atl/registrar.c 2005-07-11 16:24:53.000000000 +0200 @@ -37,7 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(atl); -ULONG dll_count = 0; +LONG dll_count = 0; /************************************************************** * ATLRegistrar implementation @@ -79,7 +79,7 @@ typedef struct { const IRegistrarVtbl *lpVtbl; - ULONG ref; + LONG ref; rep_list *rep; } Registrar; diff -urN wine-20050628/dlls/avifil32/Makefile.in wine-20050725/dlls/avifil32/Makefile.in --- wine-20050628/dlls/avifil32/Makefile.in 2005-05-09 16:42:36.000000000 +0200 +++ wine-20050725/dlls/avifil32/Makefile.in 2005-07-02 12:49:40.000000000 +0200 @@ -4,7 +4,7 @@ VPATH = @srcdir@ MODULE = avifil32.dll IMPORTLIB = libavifil32.$(IMPLIBEXT) -IMPORTS = msacm32 msvfw32 shell32 winmm ole32 user32 advapi32 kernel32 ntdll +IMPORTS = msacm32 msvfw32 winmm ole32 user32 advapi32 kernel32 ntdll EXTRALIBS = -luuid C_SRCS = \ diff -urN wine-20050628/dlls/avifil32/acmstream.c wine-20050725/dlls/avifil32/acmstream.c --- wine-20050628/dlls/avifil32/acmstream.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/avifil32/acmstream.c 2005-07-05 18:19:13.000000000 +0200 @@ -74,7 +74,7 @@ typedef struct _IAVIStreamImpl { /* IUnknown stuff */ const IAVIStreamVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IAVIStream stuff */ PAVISTREAM pStream; diff -urN wine-20050628/dlls/avifil32/api.c wine-20050725/dlls/avifil32/api.c --- wine-20050628/dlls/avifil32/api.c 2005-03-21 11:55:13.000000000 +0100 +++ wine-20050725/dlls/avifil32/api.c 2005-07-02 12:49:39.000000000 +0200 @@ -176,8 +176,7 @@ * AVIFileInit (AVIFILE.100) */ void WINAPI AVIFileInit(void) { - /* need to load ole32.dll if not already done and get some functions */ - FIXME("(): stub!\n"); + OleInitialize(NULL); } /*********************************************************************** @@ -186,6 +185,7 @@ */ void WINAPI AVIFileExit(void) { /* need to free ole32.dll if we are the last exit call */ + /* OleUnitialize() */ FIXME("(): stub!\n"); } @@ -253,8 +253,7 @@ memcpy(&clsidHandler, lpHandler, sizeof(clsidHandler)); /* create instance of handler */ - hr = SHCoCreateInstance(NULL, &clsidHandler, NULL, - &IID_IAVIFile, (LPVOID*)ppfile); + hr = CoCreateInstance(&clsidHandler, NULL, CLSCTX_INPROC, &IID_IAVIFile, (LPVOID*)ppfile); if (FAILED(hr) || *ppfile == NULL) return hr; @@ -493,8 +492,7 @@ if (pclsidHandler == NULL) return AVIERR_UNSUPPORTED; - hr = SHCoCreateInstance(NULL, pclsidHandler, NULL, - &IID_IAVIStream, (LPVOID*)ppavi); + hr = CoCreateInstance(pclsidHandler, NULL, CLSCTX_INPROC, &IID_IAVIStream, (LPVOID*)ppavi); if (FAILED(hr) || *ppavi == NULL) return hr; @@ -751,8 +749,7 @@ } else memcpy(&clsidHandler, pclsidHandler, sizeof(clsidHandler)); - hr = SHCoCreateInstance(NULL, &clsidHandler, NULL, - &IID_IAVIStream, (LPVOID*)ppsCompressed); + hr = CoCreateInstance(&clsidHandler, NULL, CLSCTX_INPROC, &IID_IAVIStream, (LPVOID*)ppsCompressed); if (FAILED(hr) || *ppsCompressed == NULL) return hr; diff -urN wine-20050628/dlls/avifil32/avifile.c wine-20050725/dlls/avifil32/avifile.c --- wine-20050628/dlls/avifil32/avifile.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/avifil32/avifile.c 2005-07-05 18:19:13.000000000 +0200 @@ -149,7 +149,7 @@ typedef struct _IAVIStreamImpl { /* IUnknown stuff */ const IAVIStreamVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IAVIStream stuff */ IAVIFileImpl *paf; @@ -178,7 +178,7 @@ struct _IAVIFileImpl { /* IUnknown stuff */ const IAVIFileVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IAVIFile stuff... */ IPersistFileImpl iPersistFile; diff -urN wine-20050628/dlls/avifil32/editstream.c wine-20050725/dlls/avifil32/editstream.c --- wine-20050628/dlls/avifil32/editstream.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/avifil32/editstream.c 2005-07-05 18:19:13.000000000 +0200 @@ -165,7 +165,7 @@ struct _IAVIEditStreamImpl { /* IUnknown stuff */ const IAVIEditStreamVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IAVIEditStream stuff */ IEditAVIStreamImpl iAVIStream; diff -urN wine-20050628/dlls/avifil32/getframe.c wine-20050725/dlls/avifil32/getframe.c --- wine-20050628/dlls/avifil32/getframe.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/avifil32/getframe.c 2005-07-05 18:19:13.000000000 +0200 @@ -67,7 +67,7 @@ typedef struct _IGetFrameImpl { /* IUnknown stuff */ const IGetFrameVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IGetFrame stuff */ BOOL bFixedStream; diff -urN wine-20050628/dlls/avifil32/icmstream.c wine-20050725/dlls/avifil32/icmstream.c --- wine-20050628/dlls/avifil32/icmstream.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/avifil32/icmstream.c 2005-07-05 18:19:13.000000000 +0200 @@ -77,7 +77,7 @@ typedef struct _IAVIStreamImpl { /* IUnknown stuff */ const IAVIStreamVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IAVIStream stuff */ PAVISTREAM pStream; diff -urN wine-20050628/dlls/avifil32/tmpfile.c wine-20050725/dlls/avifil32/tmpfile.c --- wine-20050628/dlls/avifil32/tmpfile.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/avifil32/tmpfile.c 2005-07-05 18:19:13.000000000 +0200 @@ -66,7 +66,7 @@ typedef struct _ITmpFileImpl { /* IUnknown stuff */ const IAVIFileVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IAVIFile stuff */ AVIFILEINFOW fInfo; diff -urN wine-20050628/dlls/avifil32/wavfile.c wine-20050725/dlls/avifil32/wavfile.c --- wine-20050628/dlls/avifil32/wavfile.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/avifil32/wavfile.c 2005-07-05 18:19:13.000000000 +0200 @@ -187,7 +187,7 @@ struct _IAVIFileImpl { /* IUnknown stuff */ const IAVIFileVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IAVIFile, IAVIStream stuff... */ IPersistFileImpl iPersistFile; diff -urN wine-20050628/dlls/cabinet/cabextract.c wine-20050725/dlls/cabinet/cabextract.c --- wine-20050628/dlls/cabinet/cabextract.c 2005-06-07 22:06:39.000000000 +0200 +++ wine-20050725/dlls/cabinet/cabextract.c 2005-07-01 17:40:24.000000000 +0200 @@ -51,7 +51,7 @@ */ /* try to open a cabinet file, returns success */ -BOOL cabinet_open(struct cabinet *cab) +static BOOL cabinet_open(struct cabinet *cab) { const char *name = cab->filename; HANDLE fh; @@ -89,7 +89,7 @@ * * close the file handle in a struct cabinet. */ -void cabinet_close(struct cabinet *cab) { +static void cabinet_close(struct cabinet *cab) { TRACE("(cab == ^%p)\n", cab); if (cab->fh) CloseHandle(cab->fh); cab->fh = 0; @@ -98,7 +98,7 @@ /******************************************************* * ensure_filepath2 (internal) */ -BOOL ensure_filepath2(char *path) { +static BOOL ensure_filepath2(char *path) { BOOL ret = TRUE; int len; char *new_path; @@ -147,7 +147,7 @@ * * ensure_filepath("a\b\c\d.txt") ensures a, a\b and a\b\c exist as dirs */ -BOOL ensure_filepath(char *path) { +static BOOL ensure_filepath(char *path) { char new_path[MAX_PATH]; int len, i, lastslashpos = -1; @@ -176,7 +176,7 @@ * * opens a file for output, returns success */ -BOOL file_open(struct cab_file *fi, BOOL lower, LPCSTR dir) +static BOOL file_open(struct cab_file *fi, BOOL lower, LPCSTR dir) { char c, *d, *name; BOOL ok = FALSE; @@ -239,7 +239,7 @@ * * closes a completed file */ -void file_close(struct cab_file *fi) +static void file_close(struct cab_file *fi) { TRACE("(fi == ^%p)\n", fi); @@ -255,7 +255,7 @@ * writes from buf to a file specified as a cab_file struct. * returns success/failure */ -BOOL file_write(struct cab_file *fi, cab_UBYTE *buf, cab_off_t length) +static BOOL file_write(struct cab_file *fi, cab_UBYTE *buf, cab_off_t length) { DWORD bytes_written; @@ -276,7 +276,7 @@ * advance the file pointer associated with the cab structure * by distance bytes */ -void cabinet_skip(struct cabinet *cab, cab_off_t distance) +static void cabinet_skip(struct cabinet *cab, cab_off_t distance) { TRACE("(cab == ^%p, distance == %u)\n", cab, distance); if (SetFilePointer(cab->fh, distance, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER) { @@ -290,7 +290,7 @@ * * seek to the specified absolute offset in a cab */ -void cabinet_seek(struct cabinet *cab, cab_off_t offset) { +static void cabinet_seek(struct cabinet *cab, cab_off_t offset) { TRACE("(cab == ^%p, offset == %u)\n", cab, offset); if (SetFilePointer(cab->fh, offset, NULL, FILE_BEGIN) != offset) ERR("%s seek failure\n", debugstr_a(cab->filename)); @@ -301,7 +301,7 @@ * * returns the file pointer position of a cab */ -cab_off_t cabinet_getoffset(struct cabinet *cab) +static cab_off_t cabinet_getoffset(struct cabinet *cab) { return SetFilePointer(cab->fh, 0, NULL, FILE_CURRENT); } @@ -311,7 +311,7 @@ * * read data from a cabinet, returns success */ -BOOL cabinet_read(struct cabinet *cab, cab_UBYTE *buf, cab_off_t length) +static BOOL cabinet_read(struct cabinet *cab, cab_UBYTE *buf, cab_off_t length) { DWORD bytes_read; cab_off_t avail = cab->filelen - cabinet_getoffset(cab); @@ -339,7 +339,7 @@ * * allocate and read an aribitrarily long string from the cabinet */ -char *cabinet_read_string(struct cabinet *cab) +static char *cabinet_read_string(struct cabinet *cab) { cab_off_t len=256, base = cabinet_getoffset(cab), maxlen = cab->filelen - base; BOOL ok = FALSE; @@ -387,7 +387,7 @@ * * reads the header and all folder and file entries in this cabinet */ -BOOL cabinet_read_entries(struct cabinet *cab) +static BOOL cabinet_read_entries(struct cabinet *cab) { int num_folders, num_files, header_resv, folder_resv = 0, i; struct cab_folder *fol, *linkfol = NULL; @@ -525,7 +525,7 @@ * file [name]. Returns a cabinet structure if successful, or NULL * otherwise. */ -struct cabinet *load_cab_offset(LPCSTR name, cab_off_t offset) +static struct cabinet *load_cab_offset(LPCSTR name, cab_off_t offset) { struct cabinet *cab = (struct cabinet *) calloc(1, sizeof(struct cabinet)); int ok; @@ -553,7 +553,7 @@ /******************************************************** * Ziphuft_free (internal) */ -void Ziphuft_free(struct Ziphuft *t) +static void Ziphuft_free(struct Ziphuft *t) { register struct Ziphuft *p, *q; @@ -570,7 +570,7 @@ /********************************************************* * Ziphuft_build (internal) */ -cab_LONG Ziphuft_build(cab_ULONG *b, cab_ULONG n, cab_ULONG s, cab_UWORD *d, cab_UWORD *e, +static cab_LONG Ziphuft_build(cab_ULONG *b, cab_ULONG n, cab_ULONG s, cab_UWORD *d, cab_UWORD *e, struct Ziphuft **t, cab_LONG *m, cab_decomp_state *decomp_state) { cab_ULONG a; /* counter for codes of length k */ @@ -750,7 +750,7 @@ /********************************************************* * Zipinflate_codes (internal) */ -cab_LONG Zipinflate_codes(struct Ziphuft *tl, struct Ziphuft *td, +static cab_LONG Zipinflate_codes(struct Ziphuft *tl, struct Ziphuft *td, cab_LONG bl, cab_LONG bd, cab_decomp_state *decomp_state) { register cab_ULONG e; /* table entry flag/number of extra bits */ @@ -833,7 +833,7 @@ /*********************************************************** * Zipinflate_stored (internal) */ -cab_LONG Zipinflate_stored(cab_decomp_state *decomp_state) +static cab_LONG Zipinflate_stored(cab_decomp_state *decomp_state) /* "decompress" an inflated type 0 (stored) block. */ { cab_ULONG n; /* number of bytes in block */ @@ -877,7 +877,7 @@ /****************************************************** * Zipinflate_fixed (internal) */ -cab_LONG Zipinflate_fixed(cab_decomp_state *decomp_state) +static cab_LONG Zipinflate_fixed(cab_decomp_state *decomp_state) { struct Ziphuft *fixed_tl; struct Ziphuft *fixed_td; @@ -923,7 +923,7 @@ /************************************************************** * Zipinflate_dynamic (internal) */ -cab_LONG Zipinflate_dynamic(cab_decomp_state *decomp_state) +static cab_LONG Zipinflate_dynamic(cab_decomp_state *decomp_state) /* decompress an inflated type 2 (dynamic Huffman codes) block. */ { cab_LONG i; /* temporary variables */ @@ -1058,7 +1058,7 @@ /***************************************************** * Zipinflate_block (internal) */ -cab_LONG Zipinflate_block(cab_LONG *e, cab_decomp_state *decomp_state) /* e == last block flag */ +static cab_LONG Zipinflate_block(cab_LONG *e, cab_decomp_state *decomp_state) /* e == last block flag */ { /* decompress an inflated block */ cab_ULONG t; /* block type */ register cab_ULONG b; /* bit buffer */ @@ -1096,7 +1096,7 @@ /**************************************************** * ZIPdecompress (internal) */ -int ZIPdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) +static int ZIPdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) { cab_LONG e; /* last block flag */ @@ -1132,7 +1132,7 @@ * * Initialise a model which decodes symbols from [s] to [s]+[n]-1 */ -void QTMinitmodel(struct QTMmodel *m, struct QTMmodelsym *sym, int n, int s) { +static void QTMinitmodel(struct QTMmodel *m, struct QTMmodelsym *sym, int n, int s) { int i; m->shiftsleft = 4; m->entries = n; @@ -1149,7 +1149,7 @@ /****************************************************************** * QTMinit (internal) */ -int QTMinit(int window, int level, cab_decomp_state *decomp_state) { +static int QTMinit(int window, int level, cab_decomp_state *decomp_state) { unsigned int wndsize = 1 << window; int msz = window * 2, i; cab_ULONG j; @@ -1256,7 +1256,7 @@ /******************************************************************* * QTMdecompress (internal) */ -int QTMdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) +static int QTMdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) { cab_UBYTE *inpos = CAB(inbuf); cab_UBYTE *window = QTM(window); @@ -1438,7 +1438,7 @@ /************************************************************ * LZXinit (internal) */ -int LZXinit(int window, cab_decomp_state *decomp_state) { +static int LZXinit(int window, cab_decomp_state *decomp_state) { cab_ULONG wndsize = 1 << window; int i, j, posn_slots; @@ -1579,7 +1579,7 @@ /************************************************************ * lzx_read_lens (internal) */ -int lzx_read_lens(cab_UBYTE *lens, cab_ULONG first, cab_ULONG last, struct lzx_bits *lb, +static int lzx_read_lens(cab_UBYTE *lens, cab_ULONG first, cab_ULONG last, struct lzx_bits *lb, cab_decomp_state *decomp_state) { cab_ULONG i,j, x,y; int z; @@ -1626,7 +1626,7 @@ /******************************************************* * LZXdecompress (internal) */ -int LZXdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) { +static int LZXdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) { cab_UBYTE *inpos = CAB(inbuf); cab_UBYTE *endinp = inpos + inlen; cab_UBYTE *window = LZX(window); @@ -1949,7 +1949,7 @@ /********************************************************* * find_cabs_in_file (internal) */ -struct cabinet *find_cabs_in_file(LPCSTR name, cab_UBYTE search_buf[]) +static struct cabinet *find_cabs_in_file(LPCSTR name, cab_UBYTE search_buf[]) { struct cabinet *cab, *cab2, *firstcab = NULL, *linkcab = NULL; cab_UBYTE *pstart = &search_buf[0], *pend, *p; @@ -2067,7 +2067,7 @@ * tries to find *cabname, from the directory path of origcab, correcting the * case of *cabname if necessary, If found, writes back to *cabname. */ -void find_cabinet_file(char **cabname, LPCSTR origcab) { +static void find_cabinet_file(char **cabname, LPCSTR origcab) { char *tail, *cab, *name, *nextpart, nametmp[MAX_PATH]; int found = 0; @@ -2156,7 +2156,7 @@ * in CAB.c) for an implementation of this that correctly frees the discarded * file entries. */ -struct cab_file *process_files(struct cabinet *basecab) { +static struct cab_file *process_files(struct cabinet *basecab) { struct cabinet *cab; struct cab_file *outfi = NULL, *linkfi = NULL, *nextfi, *fi, *cfi; struct cab_folder *fol, *firstfol, *lastfol = NULL, *predfol; @@ -2259,7 +2259,7 @@ * * FIXME: use a winapi to do this */ -int convertUTF(cab_UBYTE *in) { +static int convertUTF(cab_UBYTE *in) { cab_UBYTE c, *out = in, *end = in + strlen((char *) in) + 1; cab_ULONG x; @@ -2291,7 +2291,7 @@ /**************************************************** * NONEdecompress (internal) */ -int NONEdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) +static int NONEdecompress(int inlen, int outlen, cab_decomp_state *decomp_state) { if (inlen != outlen) return DECR_ILLEGALDATA; memcpy(CAB(outbuf), CAB(inbuf), (size_t) inlen); @@ -2322,7 +2322,7 @@ /********************************************************** * decompress (internal) */ -int decompress(struct cab_file *fi, int savemode, int fix, cab_decomp_state *decomp_state) +static int decompress(struct cab_file *fi, int savemode, int fix, cab_decomp_state *decomp_state) { cab_ULONG bytes = savemode ? fi->length : fi->offset - CAB(offset); struct cabinet *cab = CAB(current)->cab[CAB(split)]; @@ -2412,7 +2412,7 @@ * * workhorse to extract a particular file from a cab */ -void extract_file(struct cab_file *fi, int lower, int fix, LPCSTR dir, cab_decomp_state *decomp_state) +static void extract_file(struct cab_file *fi, int lower, int fix, LPCSTR dir, cab_decomp_state *decomp_state) { struct cab_folder *fol = fi->folder, *oldfol = CAB(current); cab_LONG err = DECR_OK; @@ -2523,7 +2523,7 @@ /********************************************************* * print_fileinfo (internal) */ -void print_fileinfo(struct cab_file *fi) { +static void print_fileinfo(struct cab_file *fi) { char *fname = NULL; if (fi->attribs & cffile_A_NAME_IS_UTF) { diff -urN wine-20050628/dlls/cabinet/fci.c wine-20050725/dlls/cabinet/fci.c --- wine-20050628/dlls/cabinet/fci.c 2005-06-24 14:16:37.000000000 +0200 +++ wine-20050725/dlls/cabinet/fci.c 2005-07-10 19:46:34.000000000 +0200 @@ -23,7 +23,6 @@ There is still some work to be done: -- currently no support for big-endian machines - the ERF error structure aren't used on error - no real compression yet - unknown behaviour if files>4GB or cabinet >4GB @@ -44,11 +43,22 @@ #include "windef.h" #include "winbase.h" #include "winerror.h" +#include "winternl.h" #include "fci.h" #include "cabinet.h" #include "wine/debug.h" + +#ifdef WORDS_BIGENDIAN +#define fci_endian_ulong(x) RtlUlongByteSwap(x) +#define fci_endian_uword(x) RtlUshortByteSwap(x) +#else +#define fci_endian_ulong(x) (x) +#define fci_endian_uword(x) (x) +#endif + + WINE_DEFAULT_DEBUG_CHANNEL(cabinet); typedef struct { @@ -556,7 +566,7 @@ read_result=pcfdata->cbData; /* Modify the size of the compressed data to store only a part of the */ /* data block into the current cabinet. This is done to prevent */ - /* that the maximum cabinet size will be exceeded. The remainer */ + /* that the maximum cabinet size will be exceeded. The remainder */ /* will be stored into the next following cabinet. */ /* The cabinet will be of size "p_fci_internal->oldCCAB.cb". */ @@ -599,12 +609,19 @@ return FALSE; } + /* set little endian */ + pcfdata->cbData=fci_endian_uword(pcfdata->cbData); + pcfdata->cbUncomp=fci_endian_uword(pcfdata->cbUncomp); + /* get checksum and write to cfdata.csum */ pcfdata->csum = fci_get_checksum( &(pcfdata->cbData), sizeof(CFDATA)+cbReserveCFData - sizeof(pcfdata->csum), fci_get_checksum( p_fci_internal->data_out, /*buffer*/ pcfdata->cbData, 0 ) ); + /* set little endian */ + pcfdata->csum=fci_endian_ulong(pcfdata->csum); + /* write cfdata with checksum to p_fci_internal->handleCFDATA2 */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */ buffer, /* memory buffer */ @@ -617,6 +634,11 @@ p_fci_internal->sizeFileCFDATA2 += sizeof(CFDATA)+cbReserveCFData; + /* reset little endian */ + pcfdata->cbData=fci_endian_uword(pcfdata->cbData); + pcfdata->cbUncomp=fci_endian_uword(pcfdata->cbUncomp); + pcfdata->csum=fci_endian_ulong(pcfdata->csum); + /* write compressed data into p_fci_internal->handleCFDATA2 */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */ p_fci_internal->data_out, /* memory buffer */ @@ -632,7 +654,7 @@ p_fci_internal->statusFolderCopied += pcfdata->cbData; (*payload)+=pcfdata->cbUncomp; /* if cabinet size too large and data has been split */ - /* write the remainer of the data block to the new CFDATA1 file */ + /* write the remainder of the data block to the new CFDATA1 file */ if( split_block ) { /* This does not include the */ /* abused one (just search for "abused" )*/ /* copy all CFDATA structures from handleCFDATA1 to handleCFDATA1new */ @@ -641,7 +663,7 @@ return FALSE; } - /* set cbData the size of the remainer of the data block */ + /* set cbData to the size of the remainder of the data block */ pcfdata->cbData = read_result - pcfdata->cbData; /*recover former value of cfdata.cbData; read_result will be the offset*/ read_result -= pcfdata->cbData; @@ -649,6 +671,7 @@ /* reset checksum, it will be computed later */ pcfdata->csum=0; + /* write cfdata WITHOUT checksum to handleCFDATA1new */ if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */ buffer, /* memory buffer */ @@ -657,7 +680,7 @@ /* TODO write error */ return FALSE; } - /* TODO error handling of err dont forget PFCI_FREE(hfci, reserved) */ + /* TODO error handling of err don't forget PFCI_FREE(hfci, reserved) */ *psizeFileCFDATA1new += sizeof(CFDATA)+cbReserveCFData; @@ -676,7 +699,7 @@ *psizeFileCFDATA1new += pcfdata->cbData; /* the two blocks of the split data block have been written */ - /* dont reset split_data yet, because it is still needed see below */ + /* don't reset split_data yet, because it is still needed see below */ } /* report status with pfnfcis about copied size of folder */ @@ -721,7 +744,7 @@ /* TODO read error */ return FALSE; } - /* TODO error handling of err dont forget PFCI_FREE(hfci, reserved) */ + /* TODO error handling of err don't forget PFCI_FREE(hfci, reserved) */ /* write cfdata with checksum to handleCFDATA1new */ if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */ @@ -731,7 +754,7 @@ /* TODO write error */ return FALSE; } - /* TODO error handling of err dont forget PFCI_FREE(hfci, reserved) */ + /* TODO error handling of err don't forget PFCI_FREE(hfci, reserved) */ *psizeFileCFDATA1new += sizeof(CFDATA)+cbReserveCFData; @@ -779,7 +802,7 @@ /* absolute offset cannot be set yet, because the size of cabinet header, */ /* the number of CFFOLDERs and the number of CFFILEs may change. */ /* Instead the size of all previous data blocks will be stored and */ - /* the remainer of the offset will be added when the cabinet will be */ + /* the remainder of the offset will be added when the cabinet will be */ /* flushed to disk. */ /* This is exactly the way the original CABINET.DLL works!!! */ cffolder.coffCabStart=sizeFileCFDATA2old; @@ -965,6 +988,14 @@ cffile.iFolder=cffileCONTINUED_TO_NEXT; } + /* set little endian */ + cffile.cbFile=fci_endian_ulong(cffile.cbFile); + cffile.uoffFolderStart=fci_endian_ulong(cffile.uoffFolderStart); + cffile.iFolder=fci_endian_uword(cffile.iFolder); + cffile.date=fci_endian_uword(cffile.date); + cffile.time=fci_endian_uword(cffile.time); + cffile.attribs=fci_endian_uword(cffile.attribs); + /* write cffile to p_fci_internal->handleCFFILE2 */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */ &cffile, /* memory buffer */ @@ -977,6 +1008,14 @@ p_fci_internal->sizeFileCFFILE2 += sizeof(cffile); + /* reset little endian */ + cffile.cbFile=fci_endian_ulong(cffile.cbFile); + cffile.uoffFolderStart=fci_endian_ulong(cffile.uoffFolderStart); + cffile.iFolder=fci_endian_uword(cffile.iFolder); + cffile.date=fci_endian_uword(cffile.date); + cffile.time=fci_endian_uword(cffile.time); + cffile.attribs=fci_endian_uword(cffile.attribs); + /* write file name to p_fci_internal->handleCFFILE2 */ if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */ p_fci_internal->data_out, /* memory buffer */ @@ -1580,6 +1619,18 @@ cfheader.iCabinet = p_fci_internal->pccab->iCab-1; } + /* set little endian */ + cfheader.reserved1=fci_endian_ulong(cfheader.reserved1); + cfheader.cbCabinet=fci_endian_ulong(cfheader.cbCabinet); + cfheader.reserved2=fci_endian_ulong(cfheader.reserved2); + cfheader.coffFiles=fci_endian_ulong(cfheader.coffFiles); + cfheader.reserved3=fci_endian_ulong(cfheader.reserved3); + cfheader.cFolders=fci_endian_uword(cfheader.cFolders); + cfheader.cFiles=fci_endian_uword(cfheader.cFiles); + cfheader.flags=fci_endian_uword(cfheader.flags); + cfheader.setID=fci_endian_uword(cfheader.setID); + cfheader.iCabinet=fci_endian_uword(cfheader.iCabinet); + /* write CFHEADER into cabinet file */ if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ &cfheader, /* memory buffer */ @@ -1590,6 +1641,18 @@ } /* TODO error handling of err */ + /* reset little endian */ + cfheader.reserved1=fci_endian_ulong(cfheader.reserved1); + cfheader.cbCabinet=fci_endian_ulong(cfheader.cbCabinet); + cfheader.reserved2=fci_endian_ulong(cfheader.reserved2); + cfheader.coffFiles=fci_endian_ulong(cfheader.coffFiles); + cfheader.reserved3=fci_endian_ulong(cfheader.reserved3); + cfheader.cFolders=fci_endian_uword(cfheader.cFolders); + cfheader.cFiles=fci_endian_uword(cfheader.cFiles); + cfheader.flags=fci_endian_uword(cfheader.flags); + cfheader.setID=fci_endian_uword(cfheader.setID); + cfheader.iCabinet=fci_endian_uword(cfheader.iCabinet); + if( cfheader.flags & cfheadRESERVE_PRESENT ) { /* NOTE: No checks for maximum value overflows as designed by MS!!! */ cfreserved.cbCFHeader = cbReserveCFHeader; @@ -1600,6 +1663,10 @@ } else { cfreserved.cbCFData = p_fci_internal->pccab->cbReserveCFData; } + + /* set little endian */ + cfreserved.cbCFHeader=fci_endian_uword(cfreserved.cbCFHeader); + /* write reserved info into cabinet file */ if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ &cfreserved, /* memory buffer */ @@ -1609,6 +1676,9 @@ return FALSE; } /* TODO error handling of err */ + + /* reset little endian */ + cfreserved.cbCFHeader=fci_endian_uword(cfreserved.cbCFHeader); } /* add optional reserved area */ @@ -1735,6 +1805,11 @@ } } + /* set little endian */ + cffolder.coffCabStart=fci_endian_ulong(cffolder.coffCabStart); + cffolder.cCFData=fci_endian_uword(cffolder.cCFData); + cffolder.typeCompress=fci_endian_uword(cffolder.typeCompress); + /* write cffolder to cabinet file */ if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ &cffolder, /* memory buffer */ @@ -1745,6 +1820,11 @@ } /* TODO error handling of err */ + /* reset little endian */ + cffolder.coffCabStart=fci_endian_ulong(cffolder.coffCabStart); + cffolder.cCFData=fci_endian_uword(cffolder.cCFData); + cffolder.typeCompress=fci_endian_uword(cffolder.typeCompress); + /* add optional reserved area */ /* This allocation and freeing at each CFFolder block is a bit */ diff -urN wine-20050628/dlls/cabinet/fdi.c wine-20050725/dlls/cabinet/fdi.c --- wine-20050628/dlls/cabinet/fdi.c 2004-12-06 17:09:37.000000000 +0100 +++ wine-20050725/dlls/cabinet/fdi.c 2005-07-05 13:05:51.000000000 +0200 @@ -243,7 +243,7 @@ * * returns the file pointer position of a file handle. */ -long FDI_getoffset(HFDI hfdi, INT_PTR hf) +static long FDI_getoffset(HFDI hfdi, INT_PTR hf) { return PFDI_SEEK(hfdi, hf, 0L, SEEK_CUR); } @@ -254,7 +254,7 @@ * we can't use _msize; the user might not be using malloc, so we require * an explicit specification of the previous size. inefficient. */ -void *FDI_realloc(HFDI hfdi, void *mem, size_t prevsize, size_t newsize) +static void *FDI_realloc(HFDI hfdi, void *mem, size_t prevsize, size_t newsize) { void *rslt = NULL; char *irslt, *imem; @@ -273,7 +273,7 @@ * * allocate and read an arbitrarily long string from the cabinet */ -char *FDI_read_string(HFDI hfdi, INT_PTR hf, long cabsize) +static char *FDI_read_string(HFDI hfdi, INT_PTR hf, long cabsize) { size_t len=256, oldlen = 0, @@ -326,7 +326,7 @@ * process the cabinet header in the style of FDIIsCabinet, but * without the sanity checks (and bug) */ -BOOL FDI_read_entries( +static BOOL FDI_read_entries( HFDI hfdi, INT_PTR hf, PFDICABINETINFO pfdici, @@ -632,7 +632,7 @@ * * Initialize a model which decodes symbols from [s] to [s]+[n]-1 */ -void QTMfdi_initmodel(struct QTMmodel *m, struct QTMmodelsym *sym, int n, int s) { +static void QTMfdi_initmodel(struct QTMmodel *m, struct QTMmodelsym *sym, int n, int s) { int i; m->shiftsleft = 4; m->entries = n; @@ -649,7 +649,7 @@ /****************************************************************** * QTMfdi_init (internal) */ -int QTMfdi_init(int window, int level, fdi_decomp_state *decomp_state) { +static int QTMfdi_init(int window, int level, fdi_decomp_state *decomp_state) { unsigned int wndsize = 1 << window; int msz = window * 2, i; cab_ULONG j; @@ -701,7 +701,7 @@ /************************************************************ * LZXfdi_init (internal) */ -int LZXfdi_init(int window, fdi_decomp_state *decomp_state) { +static int LZXfdi_init(int window, fdi_decomp_state *decomp_state) { cab_ULONG wndsize = 1 << window; int i, j, posn_slots; @@ -755,7 +755,7 @@ /**************************************************** * NONEfdi_decomp(internal) */ -int NONEfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) +static int NONEfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) { if (inlen != outlen) return DECR_ILLEGALDATA; memcpy(CAB(outbuf), CAB(inbuf), (size_t) inlen); @@ -765,7 +765,7 @@ /******************************************************** * Ziphuft_free (internal) */ -void fdi_Ziphuft_free(HFDI hfdi, struct Ziphuft *t) +static void fdi_Ziphuft_free(HFDI hfdi, struct Ziphuft *t) { register struct Ziphuft *p, *q; @@ -782,7 +782,7 @@ /********************************************************* * fdi_Ziphuft_build (internal) */ -cab_LONG fdi_Ziphuft_build(cab_ULONG *b, cab_ULONG n, cab_ULONG s, cab_UWORD *d, cab_UWORD *e, +static cab_LONG fdi_Ziphuft_build(cab_ULONG *b, cab_ULONG n, cab_ULONG s, cab_UWORD *d, cab_UWORD *e, struct Ziphuft **t, cab_LONG *m, fdi_decomp_state *decomp_state) { cab_ULONG a; /* counter for codes of length k */ @@ -1045,7 +1045,7 @@ /*********************************************************** * Zipinflate_stored (internal) */ -cab_LONG fdi_Zipinflate_stored(fdi_decomp_state *decomp_state) +static cab_LONG fdi_Zipinflate_stored(fdi_decomp_state *decomp_state) /* "decompress" an inflated type 0 (stored) block. */ { cab_ULONG n; /* number of bytes in block */ @@ -1089,7 +1089,7 @@ /****************************************************** * fdi_Zipinflate_fixed (internal) */ -cab_LONG fdi_Zipinflate_fixed(fdi_decomp_state *decomp_state) +static cab_LONG fdi_Zipinflate_fixed(fdi_decomp_state *decomp_state) { struct Ziphuft *fixed_tl; struct Ziphuft *fixed_td; @@ -1135,7 +1135,7 @@ /************************************************************** * fdi_Zipinflate_dynamic (internal) */ -cab_LONG fdi_Zipinflate_dynamic(fdi_decomp_state *decomp_state) +static cab_LONG fdi_Zipinflate_dynamic(fdi_decomp_state *decomp_state) /* decompress an inflated type 2 (dynamic Huffman codes) block. */ { cab_LONG i; /* temporary variables */ @@ -1270,7 +1270,7 @@ /***************************************************** * fdi_Zipinflate_block (internal) */ -cab_LONG fdi_Zipinflate_block(cab_LONG *e, fdi_decomp_state *decomp_state) /* e == last block flag */ +static cab_LONG fdi_Zipinflate_block(cab_LONG *e, fdi_decomp_state *decomp_state) /* e == last block flag */ { /* decompress an inflated block */ cab_ULONG t; /* block type */ register cab_ULONG b; /* bit buffer */ @@ -1308,7 +1308,7 @@ /**************************************************** * ZIPfdi_decomp(internal) */ -int ZIPfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) +static int ZIPfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) { cab_LONG e; /* last block flag */ @@ -1336,7 +1336,7 @@ /******************************************************************* * QTMfdi_decomp(internal) */ -int QTMfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) +static int QTMfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) { cab_UBYTE *inpos = CAB(inbuf); cab_UBYTE *window = QTM(window); @@ -1462,7 +1462,7 @@ /************************************************************ * fdi_lzx_read_lens (internal) */ -int fdi_lzx_read_lens(cab_UBYTE *lens, cab_ULONG first, cab_ULONG last, struct lzx_bits *lb, +static int fdi_lzx_read_lens(cab_UBYTE *lens, cab_ULONG first, cab_ULONG last, struct lzx_bits *lb, fdi_decomp_state *decomp_state) { cab_ULONG i,j, x,y; int z; @@ -1509,7 +1509,7 @@ /******************************************************* * LZXfdi_decomp(internal) */ -int LZXfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) { +static int LZXfdi_decomp(int inlen, int outlen, fdi_decomp_state *decomp_state) { cab_UBYTE *inpos = CAB(inbuf); cab_UBYTE *endinp = inpos + inlen; cab_UBYTE *window = LZX(window); @@ -1841,7 +1841,7 @@ * is also where we jump to additional cabinets in the case of split * cab's, and provide (some of) the NEXT_CABINET notification semantics. */ -int fdi_decomp(struct fdi_file *fi, int savemode, fdi_decomp_state *decomp_state, +static int fdi_decomp(struct fdi_file *fi, int savemode, fdi_decomp_state *decomp_state, char *pszCabPath, PFNFDINOTIFY pfnfdin, void *pvUser) { cab_ULONG bytes = savemode ? fi->length : fi->offset - CAB(offset); diff -urN wine-20050628/dlls/comcat/comcat_main.c wine-20050725/dlls/comcat/comcat_main.c --- wine-20050628/dlls/comcat/comcat_main.c 2004-11-30 18:40:51.000000000 +0100 +++ wine-20050725/dlls/comcat/comcat_main.c 2005-07-11 16:24:53.000000000 +0200 @@ -24,7 +24,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); -DWORD dll_ref = 0; +LONG dll_ref = 0; /*********************************************************************** * Global string constant definitions diff -urN wine-20050628/dlls/comcat/comcat_private.h wine-20050725/dlls/comcat/comcat_private.h --- wine-20050628/dlls/comcat/comcat_private.h 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/comcat/comcat_private.h 2005-07-11 16:24:53.000000000 +0200 @@ -38,7 +38,7 @@ /********************************************************************** * Dll lifetime tracking declaration for comcat.dll */ -extern DWORD dll_ref; +extern LONG dll_ref; /********************************************************************** * ClassFactory declaration for comcat.dll @@ -47,7 +47,7 @@ { /* IUnknown fields */ const IClassFactoryVtbl *lpVtbl; - DWORD ref; + LONG ref; } ClassFactoryImpl; extern ClassFactoryImpl COMCAT_ClassFactory; @@ -61,7 +61,7 @@ const IUnknownVtbl *unkVtbl; const ICatRegisterVtbl *regVtbl; const ICatInformationVtbl *infVtbl; - DWORD ref; + LONG ref; } ComCatMgrImpl; extern const ComCatMgrImpl COMCAT_ComCatMgr; diff -urN wine-20050628/dlls/comcat/information.c wine-20050725/dlls/comcat/information.c --- wine-20050628/dlls/comcat/information.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/comcat/information.c 2005-07-11 16:24:53.000000000 +0200 @@ -298,7 +298,7 @@ typedef struct { const IEnumCATEGORYINFOVtbl *lpVtbl; - DWORD ref; + LONG ref; LCID lcid; HKEY key; DWORD next_index; @@ -602,7 +602,7 @@ typedef struct { const IEnumGUIDVtbl *lpVtbl; - DWORD ref; + LONG ref; const struct class_categories *categories; HKEY key; DWORD next_index; @@ -795,7 +795,7 @@ typedef struct { const IEnumGUIDVtbl *lpVtbl; - DWORD ref; + LONG ref; WCHAR keyname[68]; HKEY key; DWORD next_index; diff -urN wine-20050628/dlls/comctl32/Makefile.in wine-20050725/dlls/comctl32/Makefile.in --- wine-20050628/dlls/comctl32/Makefile.in 2005-05-09 16:42:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/Makefile.in 2005-07-18 12:31:06.000000000 +0200 @@ -6,7 +6,7 @@ MODULE = comctl32.dll IMPORTLIB = libcomctl32.$(IMPLIBEXT) IMPORTS = user32 gdi32 advapi32 kernel32 -DELAYIMPORTS = winmm +DELAYIMPORTS = winmm uxtheme EXTRALIBS = $(LIBUNICODE) C_SRCS = \ @@ -15,7 +15,9 @@ comctl32undoc.c \ commctrl.c \ datetime.c \ + dpa.c \ draglist.c \ + dsa.c \ flatsb.c \ header.c \ hotkey.c \ diff -urN wine-20050628/dlls/comctl32/comctl32undoc.c wine-20050725/dlls/comctl32/comctl32undoc.c --- wine-20050628/dlls/comctl32/comctl32undoc.c 2005-05-06 17:44:32.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl32undoc.c 2005-07-06 12:32:18.000000000 +0200 @@ -55,314 +55,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(commctrl); -struct _DSA -{ - INT nItemCount; - LPVOID pData; - INT nMaxCount; - INT nItemSize; - INT nGrow; -}; - -struct _DPA -{ - INT nItemCount; - LPVOID *ptrs; - HANDLE hHeap; - INT nGrow; - INT nMaxCount; -}; - -typedef struct _STREAMDATA -{ - DWORD dwSize; - DWORD dwData2; - DWORD dwItems; -} STREAMDATA, *PSTREAMDATA; - -typedef struct _LOADDATA -{ - INT nCount; - PVOID ptr; -} LOADDATA, *LPLOADDATA; - -typedef HRESULT (CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM); - static const WCHAR strMRUList[] = { 'M','R','U','L','i','s','t',0 }; /************************************************************************** - * DPA_LoadStream [COMCTL32.9] - * - * Loads a dynamic pointer array from a stream - * - * PARAMS - * phDpa [O] pointer to a handle to a dynamic pointer array - * loadProc [I] pointer to a callback function - * pStream [I] pointer to a stream - * lParam [I] application specific value - * - * RETURNS - * Success: TRUE - * Failure: FALSE - * - * NOTES - * No more information available yet! - */ -HRESULT WINAPI DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, - IStream *pStream, LPARAM lParam) -{ - HRESULT errCode; - LARGE_INTEGER position; - ULARGE_INTEGER newPosition; - STREAMDATA streamData; - LOADDATA loadData; - ULONG ulRead; - HDPA hDpa; - PVOID *ptr; - - FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n", - phDpa, loadProc, pStream, lParam); - - if (!phDpa || !loadProc || !pStream) - return E_INVALIDARG; - - *phDpa = (HDPA)NULL; - - position.QuadPart = 0; - - /* - * Zero out our streamData - */ - memset(&streamData,0,sizeof(STREAMDATA)); - - errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition); - if (errCode != S_OK) - return errCode; - - errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead); - if (errCode != S_OK) - return errCode; - - FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n", - streamData.dwSize, streamData.dwData2, streamData.dwItems); - - if ( ulRead < sizeof(STREAMDATA) || - lParam < sizeof(STREAMDATA) || - streamData.dwSize < sizeof(STREAMDATA) || - streamData.dwData2 < 1) { - errCode = E_FAIL; - } - - if (streamData.dwItems > (UINT_MAX / 2 / sizeof(VOID*))) /* 536870911 */ - return E_OUTOFMEMORY; - - /* create the dpa */ - hDpa = DPA_Create (streamData.dwItems); - if (!hDpa) - return E_OUTOFMEMORY; - - if (!DPA_Grow (hDpa, streamData.dwItems)) - return E_OUTOFMEMORY; - - /* load data from the stream into the dpa */ - ptr = hDpa->ptrs; - for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) { - errCode = (loadProc)(&loadData, pStream, lParam); - if (errCode != S_OK) { - errCode = S_FALSE; - break; - } - - *ptr = loadData.ptr; - ptr++; - } - - /* set the number of items */ - hDpa->nItemCount = loadData.nCount; - - /* store the handle to the dpa */ - *phDpa = hDpa; - FIXME ("new hDpa=%p, errorcode=%lx\n", hDpa, errCode); - - return errCode; -} - - -/************************************************************************** - * DPA_SaveStream [COMCTL32.10] - * - * Saves a dynamic pointer array to a stream - * - * PARAMS - * hDpa [I] handle to a dynamic pointer array - * loadProc [I] pointer to a callback function - * pStream [I] pointer to a stream - * lParam [I] application specific value - * - * RETURNS - * Success: TRUE - * Failure: FALSE - * - * NOTES - * No more information available yet! - */ -HRESULT WINAPI DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, - IStream *pStream, LPARAM lParam) -{ - - FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n", - hDpa, loadProc, pStream, lParam); - - return E_FAIL; -} - - -/************************************************************************** - * DPA_Merge [COMCTL32.11] - * - * Merge two dynamic pointers arrays. - * - * PARAMS - * hdpa1 [I] handle to a dynamic pointer array - * hdpa2 [I] handle to a dynamic pointer array - * dwFlags [I] flags - * pfnCompare [I] pointer to sort function - * pfnMerge [I] pointer to merge function - * lParam [I] application specific value - * - * RETURNS - * Success: TRUE - * Failure: FALSE - * - * NOTES - * No more information available yet! - */ -BOOL WINAPI DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, - PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, - LPARAM lParam) -{ - INT nCount; - LPVOID *pWork1, *pWork2; - INT nResult, i; - INT nIndex; - - TRACE("%p %p %08lx %p %p %08lx)\n", - hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam); - - if (IsBadWritePtr (hdpa1, sizeof(*hdpa1))) - return FALSE; - - if (IsBadWritePtr (hdpa2, sizeof(*hdpa2))) - return FALSE; - - if (IsBadCodePtr ((FARPROC)pfnCompare)) - return FALSE; - - if (IsBadCodePtr ((FARPROC)pfnMerge)) - return FALSE; - - if (!(dwFlags & DPAM_NOSORT)) { - TRACE("sorting dpa's!\n"); - if (hdpa1->nItemCount > 0) - DPA_Sort (hdpa1, pfnCompare, lParam); - TRACE ("dpa 1 sorted!\n"); - if (hdpa2->nItemCount > 0) - DPA_Sort (hdpa2, pfnCompare, lParam); - TRACE ("dpa 2 sorted!\n"); - } - - if (hdpa2->nItemCount < 1) - return TRUE; - - TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n", - hdpa1->nItemCount, hdpa2->nItemCount); - - - /* working but untrusted implementation */ - - pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]); - pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]); - - nIndex = hdpa1->nItemCount - 1; - nCount = hdpa2->nItemCount - 1; - - do - { - if (nIndex < 0) { - if ((nCount >= 0) && (dwFlags & DPAM_INSERT)) { - /* Now insert the remaining new items into DPA 1 */ - TRACE("%d items to be inserted at start of DPA 1\n", - nCount+1); - for (i=nCount; i>=0; i--) { - PVOID ptr; - - ptr = (pfnMerge)(3, *pWork2, NULL, lParam); - if (!ptr) - return FALSE; - DPA_InsertPtr (hdpa1, 0, ptr); - pWork2--; - } - } - break; - } - nResult = (pfnCompare)(*pWork1, *pWork2, lParam); - TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n", - nResult, nIndex, nCount); - - if (nResult == 0) - { - PVOID ptr; - - ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam); - if (!ptr) - return FALSE; - - nCount--; - pWork2--; - *pWork1 = ptr; - nIndex--; - pWork1--; - } - else if (nResult > 0) - { - /* item in DPA 1 missing from DPA 2 */ - if (dwFlags & DPAM_DELETE) - { - /* Now delete the extra item in DPA1 */ - PVOID ptr; - - ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1); - - (pfnMerge)(2, ptr, NULL, lParam); - } - nIndex--; - pWork1--; - } - else - { - /* new item in DPA 2 */ - if (dwFlags & DPAM_INSERT) - { - /* Now insert the new item in DPA 1 */ - PVOID ptr; - - ptr = (pfnMerge)(3, *pWork2, NULL, lParam); - if (!ptr) - return FALSE; - DPA_InsertPtr (hdpa1, nIndex+1, ptr); - } - nCount--; - pWork2--; - } - - } - while (nCount >= 0); - - return TRUE; -} - - -/************************************************************************** * Alloc [COMCTL32.71] * * Allocates memory block from the dll's private heap @@ -1416,1035 +1111,129 @@ /************************************************************************** - * DSA_Create [COMCTL32.320] - * - * Creates a dynamic storage array - * - * PARAMS - * nSize [I] size of the array elements - * nGrow [I] number of elements by which the array grows when it is filled - * - * RETURNS - * Success: pointer to an array control structure. Use this like a handle. - * Failure: NULL - * - * NOTES - * The DSA_ functions can be used to create and manipulate arrays of - * fixed-size memory blocks. These arrays can store any kind of data - * (e.g. strings and icons). + * Notification functions */ -HDSA WINAPI DSA_Create (INT nSize, INT nGrow) -{ - HDSA hdsa; - - TRACE("(size=%d grow=%d)\n", nSize, nGrow); - - hdsa = Alloc (sizeof(*hdsa)); - if (hdsa) - { - hdsa->nItemCount = 0; - hdsa->pData = NULL; - hdsa->nMaxCount = 0; - hdsa->nItemSize = nSize; - hdsa->nGrow = max(1, nGrow); - } - - return hdsa; -} - -/************************************************************************** - * DSA_Destroy [COMCTL32.321] - * - * Destroys a dynamic storage array - * - * PARAMS - * hdsa [I] pointer to the array control structure - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DSA_Destroy (const HDSA hdsa) +typedef struct tagNOTIFYDATA { - TRACE("(%p)\n", hdsa); - - if (!hdsa) - return FALSE; - - if (hdsa->pData && (!Free (hdsa->pData))) - return FALSE; - - return Free (hdsa); -} + HWND hwndFrom; + HWND hwndTo; + DWORD dwParam3; + DWORD dwParam4; + DWORD dwParam5; + DWORD dwParam6; +} NOTIFYDATA, *LPNOTIFYDATA; /************************************************************************** - * DSA_GetItem [COMCTL32.322] - * - * Copies the specified item into a caller-supplied buffer. - * - * PARAMS - * hdsa [I] pointer to the array control structure - * nIndex [I] number of the Item to get - * pDest [O] destination buffer. Has to be >= dwElementSize. - * - * RETURNS - * Success: TRUE - * Failure: FALSE + * DoNotify [Internal] */ -BOOL WINAPI DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest) -{ - LPVOID pSrc; - - TRACE("(%p %d %p)\n", hdsa, nIndex, pDest); - if (!hdsa) - return FALSE; - if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) - return FALSE; - - pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); - memmove (pDest, pSrc, hdsa->nItemSize); - - return TRUE; -} - - -/************************************************************************** - * DSA_GetItemPtr [COMCTL32.323] - * - * Retrieves a pointer to the specified item. - * - * PARAMS - * hdsa [I] pointer to the array control structure - * nIndex [I] index of the desired item - * - * RETURNS - * Success: pointer to an item - * Failure: NULL - */ -LPVOID WINAPI DSA_GetItemPtr (const HDSA hdsa, INT nIndex) +static LRESULT DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr) { - LPVOID pSrc; - - TRACE("(%p %d)\n", hdsa, nIndex); - - if (!hdsa) - return NULL; - if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) - return NULL; - - pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); - - TRACE("-- ret=%p\n", pSrc); - - return pSrc; -} + NMHDR nmhdr; + LPNMHDR lpNmh = NULL; + UINT idFrom = 0; + TRACE("(%p %p %d %p 0x%08lx)\n", + lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr, + lpNotify->dwParam5); -/************************************************************************** - * DSA_SetItem [COMCTL32.325] - * - * Sets the contents of an item in the array. - * - * PARAMS - * hdsa [I] pointer to the array control structure - * nIndex [I] index for the item - * pSrc [I] pointer to the new item data - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) -{ - INT nSize, nNewItems; - LPVOID pDest, lpTemp; + if (!lpNotify->hwndTo) + return 0; - TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); + if (lpNotify->hwndFrom == (HWND)-1) { + lpNmh = lpHdr; + idFrom = lpHdr->idFrom; + } + else { + if (lpNotify->hwndFrom) + idFrom = GetDlgCtrlID (lpNotify->hwndFrom); - if ((!hdsa) || nIndex < 0) - return FALSE; + lpNmh = (lpHdr) ? lpHdr : &nmhdr; - if (hdsa->nItemCount <= nIndex) { - /* within the old array */ - if (hdsa->nMaxCount > nIndex) { - /* within the allocated space, set a new boundary */ - hdsa->nItemCount = nIndex + 1; - } - else { - /* resize the block of memory */ - nNewItems = - hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1); - nSize = hdsa->nItemSize * nNewItems; - - lpTemp = ReAlloc (hdsa->pData, nSize); - if (!lpTemp) - return FALSE; - - hdsa->nMaxCount = nNewItems; - hdsa->nItemCount = nIndex + 1; - hdsa->pData = lpTemp; - } + lpNmh->hwndFrom = lpNotify->hwndFrom; + lpNmh->idFrom = idFrom; + lpNmh->code = uCode; } - /* put the new entry in */ - pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); - TRACE("-- move dest=%p src=%p size=%d\n", - pDest, pSrc, hdsa->nItemSize); - memmove (pDest, pSrc, hdsa->nItemSize); - - return TRUE; + return SendMessageW (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh); } /************************************************************************** - * DSA_InsertItem [COMCTL32.324] + * SendNotify [COMCTL32.341] * - * Inserts an item into the array at the specified index. + * Sends a WM_NOTIFY message to the specified window. * * PARAMS - * hdsa [I] pointer to the array control structure - * nIndex [I] index for the new item - * pSrc [I] pointer to the element + * hwndTo [I] Window to receive the message + * hwndFrom [I] Window that the message is from (see notes) + * uCode [I] Notification code + * lpHdr [I] The NMHDR and any additional information to send or NULL * * RETURNS - * Success: position of the new item - * Failure: -1 + * Success: return value from notification + * Failure: 0 + * + * NOTES + * If hwndFrom is -1 then the identifier of the control sending the + * message is taken from the NMHDR structure. + * If hwndFrom is not -1 then lpHdr can be NULL. */ -INT WINAPI DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) +LRESULT WINAPI SendNotify (HWND hwndTo, HWND hwndFrom, UINT uCode, LPNMHDR lpHdr) { - INT nNewItems, nSize; - LPVOID lpTemp, lpDest; - - TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); - - if ((!hdsa) || nIndex < 0) - return -1; - - /* when nIndex >= nItemCount then append */ - if (nIndex >= hdsa->nItemCount) - nIndex = hdsa->nItemCount; - - /* do we need to resize ? */ - if (hdsa->nItemCount >= hdsa->nMaxCount) { - nNewItems = hdsa->nMaxCount + hdsa->nGrow; - nSize = hdsa->nItemSize * nNewItems; - - lpTemp = ReAlloc (hdsa->pData, nSize); - if (!lpTemp) - return -1; - - hdsa->nMaxCount = nNewItems; - hdsa->pData = lpTemp; - } + NOTIFYDATA notify; - /* do we need to move elements ? */ - if (nIndex < hdsa->nItemCount) { - lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); - lpDest = (char *) lpTemp + hdsa->nItemSize; - nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize; - TRACE("-- move dest=%p src=%p size=%d\n", - lpDest, lpTemp, nSize); - memmove (lpDest, lpTemp, nSize); - } + TRACE("(%p %p %d %p)\n", + hwndTo, hwndFrom, uCode, lpHdr); - /* ok, we can put the new Item in */ - hdsa->nItemCount++; - lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); - TRACE("-- move dest=%p src=%p size=%d\n", - lpDest, pSrc, hdsa->nItemSize); - memmove (lpDest, pSrc, hdsa->nItemSize); + notify.hwndFrom = hwndFrom; + notify.hwndTo = hwndTo; + notify.dwParam5 = 0; + notify.dwParam6 = 0; - return nIndex; + return DoNotify (¬ify, uCode, lpHdr); } /************************************************************************** - * DSA_DeleteItem [COMCTL32.326] + * SendNotifyEx [COMCTL32.342] * - * Deletes the specified item from the array. + * Sends a WM_NOTIFY message to the specified window. * * PARAMS - * hdsa [I] pointer to the array control structure - * nIndex [I] index for the element to delete + * hwndFrom [I] Window to receive the message + * hwndTo [I] Window that the message is from + * uCode [I] Notification code + * lpHdr [I] The NMHDR and any additional information to send or NULL + * dwParam5 [I] Unknown * * RETURNS - * Success: number of the deleted element - * Failure: -1 + * Success: return value from notification + * Failure: 0 + * + * NOTES + * If hwndFrom is -1 then the identifier of the control sending the + * message is taken from the NMHDR structure. + * If hwndFrom is not -1 then lpHdr can be NULL. */ -INT WINAPI DSA_DeleteItem (const HDSA hdsa, INT nIndex) +LRESULT WINAPI SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode, + LPNMHDR lpHdr, DWORD dwParam5) { - LPVOID lpDest,lpSrc; - INT nSize; - - TRACE("(%p %d)\n", hdsa, nIndex); + NOTIFYDATA notify; + HWND hwndNotify; - if (!hdsa) - return -1; - if (nIndex < 0 || nIndex >= hdsa->nItemCount) - return -1; + TRACE("(%p %p %d %p 0x%08lx)\n", + hwndFrom, hwndTo, uCode, lpHdr, dwParam5); - /* do we need to move ? */ - if (nIndex < hdsa->nItemCount - 1) { - lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); - lpSrc = (char *) lpDest + hdsa->nItemSize; - nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1); - TRACE("-- move dest=%p src=%p size=%d\n", - lpDest, lpSrc, nSize); - memmove (lpDest, lpSrc, nSize); - } - - hdsa->nItemCount--; - - /* free memory ? */ - if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) { - nSize = hdsa->nItemSize * hdsa->nItemCount; - - lpDest = ReAlloc (hdsa->pData, nSize); - if (!lpDest) - return -1; - - hdsa->nMaxCount = hdsa->nItemCount; - hdsa->pData = lpDest; - } - - return nIndex; -} - - -/************************************************************************** - * DSA_DeleteAllItems [COMCTL32.327] - * - * Removes all items and reinitializes the array. - * - * PARAMS - * hdsa [I] pointer to the array control structure - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DSA_DeleteAllItems (const HDSA hdsa) -{ - TRACE("(%p)\n", hdsa); - - if (!hdsa) - return FALSE; - if (hdsa->pData && (!Free (hdsa->pData))) - return FALSE; - - hdsa->nItemCount = 0; - hdsa->pData = NULL; - hdsa->nMaxCount = 0; - - return TRUE; -} - - -/************************************************************************** - * DPA_Destroy [COMCTL32.329] - * - * Destroys a dynamic pointer array - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DPA_Destroy (const HDPA hdpa) -{ - TRACE("(%p)\n", hdpa); - - if (!hdpa) - return FALSE; - - if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) - return FALSE; - - return HeapFree (hdpa->hHeap, 0, hdpa); -} - - -/************************************************************************** - * DPA_Grow [COMCTL32.330] - * - * Sets the growth amount. - * - * PARAMS - * hdpa [I] handle (pointer) to the existing (source) pointer array - * nGrow [I] number of items by which the array grows when it's too small - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DPA_Grow (const HDPA hdpa, INT nGrow) -{ - TRACE("(%p %d)\n", hdpa, nGrow); - - if (!hdpa) - return FALSE; - - hdpa->nGrow = max(8, nGrow); - - return TRUE; -} - - -/************************************************************************** - * DPA_Clone [COMCTL32.331] - * - * Copies a pointer array to an other one or creates a copy - * - * PARAMS - * hdpa [I] handle (pointer) to the existing (source) pointer array - * hdpaNew [O] handle (pointer) to the destination pointer array - * - * RETURNS - * Success: pointer to the destination pointer array. - * Failure: NULL - * - * NOTES - * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer - * array will be created and it's handle (pointer) is returned. - * - If 'hdpa' is a NULL-Pointer, the original implementation crashes, - * this implementation just returns NULL. - */ -HDPA WINAPI DPA_Clone (const HDPA hdpa, const HDPA hdpaNew) -{ - INT nNewItems, nSize; - HDPA hdpaTemp; - - if (!hdpa) - return NULL; - - TRACE("(%p %p)\n", hdpa, hdpaNew); - - if (!hdpaNew) { - /* create a new DPA */ - hdpaTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, - sizeof(*hdpaTemp)); - hdpaTemp->hHeap = hdpa->hHeap; - hdpaTemp->nGrow = hdpa->nGrow; - } - else - hdpaTemp = hdpaNew; - - if (hdpaTemp->ptrs) { - /* remove old pointer array */ - HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs); - hdpaTemp->ptrs = NULL; - hdpaTemp->nItemCount = 0; - hdpaTemp->nMaxCount = 0; - } - - /* create a new pointer array */ - nNewItems = hdpaTemp->nGrow * - ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1); - nSize = nNewItems * sizeof(LPVOID); - hdpaTemp->ptrs = HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize); - hdpaTemp->nMaxCount = nNewItems; - - /* clone the pointer array */ - hdpaTemp->nItemCount = hdpa->nItemCount; - memmove (hdpaTemp->ptrs, hdpa->ptrs, - hdpaTemp->nItemCount * sizeof(LPVOID)); - - return hdpaTemp; -} - - -/************************************************************************** - * DPA_GetPtr [COMCTL32.332] - * - * Retrieves a pointer from a dynamic pointer array - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * nIndex [I] array index of the desired pointer - * - * RETURNS - * Success: pointer - * Failure: NULL - */ -LPVOID WINAPI DPA_GetPtr (const HDPA hdpa, INT nIndex) -{ - TRACE("(%p %d)\n", hdpa, nIndex); - - if (!hdpa) - return NULL; - if (!hdpa->ptrs) { - WARN("no pointer array.\n"); - return NULL; - } - if ((nIndex < 0) || (nIndex >= hdpa->nItemCount)) { - WARN("not enough pointers in array (%d vs %d).\n",nIndex,hdpa->nItemCount); - return NULL; - } - - TRACE("-- %p\n", hdpa->ptrs[nIndex]); - - return hdpa->ptrs[nIndex]; -} - - -/************************************************************************** - * DPA_GetPtrIndex [COMCTL32.333] - * - * Retrieves the index of the specified pointer - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * p [I] pointer - * - * RETURNS - * Success: index of the specified pointer - * Failure: -1 - */ -INT WINAPI DPA_GetPtrIndex (const HDPA hdpa, LPVOID p) -{ - INT i; - - if (!hdpa || !hdpa->ptrs) - return -1; - - for (i = 0; i < hdpa->nItemCount; i++) { - if (hdpa->ptrs[i] == p) - return i; - } - - return -1; -} - - -/************************************************************************** - * DPA_InsertPtr [COMCTL32.334] - * - * Inserts a pointer into a dynamic pointer array - * - * PARAMS - * hdpa [I] handle (pointer) to the array - * i [I] array index - * p [I] pointer to insert - * - * RETURNS - * Success: index of the inserted pointer - * Failure: -1 - */ -INT WINAPI DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p) -{ - TRACE("(%p %d %p)\n", hdpa, i, p); - - if (!hdpa || i < 0) return -1; - - if (i >= 0x7fff) - i = hdpa->nItemCount; - - if (i >= hdpa->nItemCount) - return DPA_SetPtr(hdpa, i, p) ? i : -1; - - /* create empty spot at the end */ - if (!DPA_SetPtr(hdpa, hdpa->nItemCount, 0)) return -1; - memmove (hdpa->ptrs + i + 1, hdpa->ptrs + i, (hdpa->nItemCount - i - 1) * sizeof(LPVOID)); - hdpa->ptrs[i] = p; - return i; -} - -/************************************************************************** - * DPA_SetPtr [COMCTL32.335] - * - * Sets a pointer in the pointer array - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * i [I] index of the pointer that will be set - * p [I] pointer to be set - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p) -{ - LPVOID *lpTemp; - - TRACE("(%p %d %p)\n", hdpa, i, p); - - if (!hdpa || i < 0 || i > 0x7fff) - return FALSE; - - if (hdpa->nItemCount <= i) { - /* within the old array */ - if (hdpa->nMaxCount <= i) { - /* resize the block of memory */ - INT nNewItems = - hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1); - INT nSize = nNewItems * sizeof(LPVOID); - - if (hdpa->ptrs) - lpTemp = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->ptrs, nSize); - else - lpTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, nSize); - - if (!lpTemp) - return FALSE; - - hdpa->nMaxCount = nNewItems; - hdpa->ptrs = lpTemp; - } - hdpa->nItemCount = i+1; - } - - /* put the new entry in */ - hdpa->ptrs[i] = p; - - return TRUE; -} - - -/************************************************************************** - * DPA_DeletePtr [COMCTL32.336] - * - * Removes a pointer from the pointer array. - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * i [I] index of the pointer that will be deleted - * - * RETURNS - * Success: deleted pointer - * Failure: NULL - */ -LPVOID WINAPI DPA_DeletePtr (const HDPA hdpa, INT i) -{ - LPVOID *lpDest, *lpSrc, lpTemp = NULL; - INT nSize; - - TRACE("(%p %d)\n", hdpa, i); - - if ((!hdpa) || i < 0 || i >= hdpa->nItemCount) - return NULL; - - lpTemp = hdpa->ptrs[i]; - - /* do we need to move ?*/ - if (i < hdpa->nItemCount - 1) { - lpDest = hdpa->ptrs + i; - lpSrc = lpDest + 1; - nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID); - TRACE("-- move dest=%p src=%p size=%x\n", - lpDest, lpSrc, nSize); - memmove (lpDest, lpSrc, nSize); - } - - hdpa->nItemCount --; - - /* free memory ?*/ - if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) { - INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount); - nSize = nNewItems * sizeof(LPVOID); - lpDest = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, - hdpa->ptrs, nSize); - if (!lpDest) - return NULL; - - hdpa->nMaxCount = nNewItems; - hdpa->ptrs = (LPVOID*)lpDest; - } - - return lpTemp; -} - - -/************************************************************************** - * DPA_DeleteAllPtrs [COMCTL32.337] - * - * Removes all pointers and reinitializes the array. - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DPA_DeleteAllPtrs (const HDPA hdpa) -{ - TRACE("(%p)\n", hdpa); - - if (!hdpa) - return FALSE; - - if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) - return FALSE; - - hdpa->nItemCount = 0; - hdpa->nMaxCount = hdpa->nGrow * 2; - hdpa->ptrs = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, - hdpa->nMaxCount * sizeof(LPVOID)); - - return TRUE; -} - - -/************************************************************************** - * DPA_QuickSort [Internal] - * - * Ordinary quicksort (used by DPA_Sort). - * - * PARAMS - * lpPtrs [I] pointer to the pointer array - * l [I] index of the "left border" of the partition - * r [I] index of the "right border" of the partition - * pfnCompare [I] pointer to the compare function - * lParam [I] user defined value (3rd parameter in compare function) - * - * RETURNS - * NONE - */ -static VOID DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, - PFNDPACOMPARE pfnCompare, LPARAM lParam) -{ - INT m; - LPVOID t; - - TRACE("l=%i r=%i\n", l, r); - - if (l==r) /* one element is always sorted */ - return; - if (r0) - { - t = lpPtrs[m+1]; - memmove(&lpPtrs[l+1],&lpPtrs[l],(m-l+1)*sizeof(lpPtrs[l])); - lpPtrs[l] = t; - - m++; - } - l++; - } -} - - -/************************************************************************** - * DPA_Sort [COMCTL32.338] - * - * Sorts a pointer array using a user defined compare function - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * pfnCompare [I] pointer to the compare function - * lParam [I] user defined value (3rd parameter of compare function) - * - * RETURNS - * Success: TRUE - * Failure: FALSE - */ -BOOL WINAPI DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam) -{ - if (!hdpa || !pfnCompare) - return FALSE; - - TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam); - - if ((hdpa->nItemCount > 1) && (hdpa->ptrs)) - DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1, - pfnCompare, lParam); - - return TRUE; -} - - -/************************************************************************** - * DPA_Search [COMCTL32.339] - * - * Searches a pointer array for a specified pointer - * - * PARAMS - * hdpa [I] handle (pointer) to the pointer array - * pFind [I] pointer to search for - * nStart [I] start index - * pfnCompare [I] pointer to the compare function - * lParam [I] user defined value (3rd parameter of compare function) - * uOptions [I] search options - * - * RETURNS - * Success: index of the pointer in the array. - * Failure: -1 - * - * NOTES - * Binary search taken from R.Sedgewick "Algorithms in C"! - * Function is NOT tested! - * If something goes wrong, blame HIM not ME! (Eric Kohl) - */ -INT WINAPI DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, - PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions) -{ - if (!hdpa || !pfnCompare || !pFind) - return -1; - - TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n", - hdpa, pFind, nStart, pfnCompare, lParam, uOptions); - - if (uOptions & DPAS_SORTED) { - /* array is sorted --> use binary search */ - INT l, r, x, n; - LPVOID *lpPtr; - - TRACE("binary search\n"); - - l = (nStart == -1) ? 0 : nStart; - r = hdpa->nItemCount - 1; - lpPtr = hdpa->ptrs; - while (r >= l) { - x = (l + r) / 2; - n = (pfnCompare)(pFind, lpPtr[x], lParam); - if (n < 0) - r = x - 1; - else - l = x + 1; - if (n == 0) { - TRACE("-- ret=%d\n", n); - return n; - } - } - - if (uOptions & DPAS_INSERTBEFORE) { - if (r == -1) r = 0; - TRACE("-- ret=%d\n", r); - return r; - } - - if (uOptions & DPAS_INSERTAFTER) { - TRACE("-- ret=%d\n", l); - return l; - } - } - else { - /* array is not sorted --> use linear search */ - LPVOID *lpPtr; - INT nIndex; - - TRACE("linear search\n"); - - nIndex = (nStart == -1)? 0 : nStart; - lpPtr = hdpa->ptrs; - for (; nIndex < hdpa->nItemCount; nIndex++) { - if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) { - TRACE("-- ret=%d\n", nIndex); - return nIndex; - } - } - } - - TRACE("-- not found: ret=-1\n"); - return -1; -} - - -/************************************************************************** - * DPA_CreateEx [COMCTL32.340] - * - * Creates a dynamic pointer array using the specified size and heap. - * - * PARAMS - * nGrow [I] number of items by which the array grows when it is filled - * hHeap [I] handle to the heap where the array is stored - * - * RETURNS - * Success: handle (pointer) to the pointer array. - * Failure: NULL - * - * NOTES - * The DPA_ functions can be used to create and manipulate arrays of - * pointers. - */ -HDPA WINAPI DPA_CreateEx (INT nGrow, HANDLE hHeap) -{ - HDPA hdpa; - - TRACE("(%d %p)\n", nGrow, hHeap); - - if (hHeap) - hdpa = HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(*hdpa)); - else - hdpa = Alloc (sizeof(*hdpa)); - - if (hdpa) { - hdpa->nGrow = max(8, nGrow); - hdpa->hHeap = hHeap ? hHeap : GetProcessHeap(); - hdpa->nMaxCount = hdpa->nGrow * 2; - hdpa->ptrs = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, - hdpa->nMaxCount * sizeof(LPVOID)); - } - - TRACE("-- %p\n", hdpa); - - return hdpa; -} - - -/************************************************************************** - * DPA_Create [COMCTL32.328] - * - * Creates a dynamic pointer array. - * - * PARAMS - * nGrow [I] number of items by which the array grows when it is filled - * - * RETURNS - * Success: handle (pointer) to the pointer array. - * Failure: NULL - * - * NOTES - * The DPA_ functions can be used to create and manipulate arrays of - * pointers. - */ -HDPA WINAPI DPA_Create (INT nGrow) -{ - return DPA_CreateEx( nGrow, 0 ); -} - - -/************************************************************************** - * Notification functions - */ - -typedef struct tagNOTIFYDATA -{ - HWND hwndFrom; - HWND hwndTo; - DWORD dwParam3; - DWORD dwParam4; - DWORD dwParam5; - DWORD dwParam6; -} NOTIFYDATA, *LPNOTIFYDATA; - - -/************************************************************************** - * DoNotify [Internal] - */ - -static LRESULT DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr) -{ - NMHDR nmhdr; - LPNMHDR lpNmh = NULL; - UINT idFrom = 0; - - TRACE("(%p %p %d %p 0x%08lx)\n", - lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr, - lpNotify->dwParam5); - - if (!lpNotify->hwndTo) - return 0; - - if (lpNotify->hwndFrom == (HWND)-1) { - lpNmh = lpHdr; - idFrom = lpHdr->idFrom; - } - else { - if (lpNotify->hwndFrom) - idFrom = GetDlgCtrlID (lpNotify->hwndFrom); - - lpNmh = (lpHdr) ? lpHdr : &nmhdr; - - lpNmh->hwndFrom = lpNotify->hwndFrom; - lpNmh->idFrom = idFrom; - lpNmh->code = uCode; - } - - return SendMessageW (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh); -} - - -/************************************************************************** - * SendNotify [COMCTL32.341] - * - * Sends a WM_NOTIFY message to the specified window. - * - * PARAMS - * hwndTo [I] Window to receive the message - * hwndFrom [I] Window that the message is from (see notes) - * uCode [I] Notification code - * lpHdr [I] The NMHDR and any additional information to send or NULL - * - * RETURNS - * Success: return value from notification - * Failure: 0 - * - * NOTES - * If hwndFrom is -1 then the identifier of the control sending the - * message is taken from the NMHDR structure. - * If hwndFrom is not -1 then lpHdr can be NULL. - */ -LRESULT WINAPI SendNotify (HWND hwndTo, HWND hwndFrom, UINT uCode, LPNMHDR lpHdr) -{ - NOTIFYDATA notify; - - TRACE("(%p %p %d %p)\n", - hwndTo, hwndFrom, uCode, lpHdr); - - notify.hwndFrom = hwndFrom; - notify.hwndTo = hwndTo; - notify.dwParam5 = 0; - notify.dwParam6 = 0; - - return DoNotify (¬ify, uCode, lpHdr); -} - - -/************************************************************************** - * SendNotifyEx [COMCTL32.342] - * - * Sends a WM_NOTIFY message to the specified window. - * - * PARAMS - * hwndFrom [I] Window to receive the message - * hwndTo [I] Window that the message is from - * uCode [I] Notification code - * lpHdr [I] The NMHDR and any additional information to send or NULL - * dwParam5 [I] Unknown - * - * RETURNS - * Success: return value from notification - * Failure: 0 - * - * NOTES - * If hwndFrom is -1 then the identifier of the control sending the - * message is taken from the NMHDR structure. - * If hwndFrom is not -1 then lpHdr can be NULL. - */ -LRESULT WINAPI SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode, - LPNMHDR lpHdr, DWORD dwParam5) -{ - NOTIFYDATA notify; - HWND hwndNotify; - - TRACE("(%p %p %d %p 0x%08lx)\n", - hwndFrom, hwndTo, uCode, lpHdr, dwParam5); - - hwndNotify = hwndTo; - if (!hwndTo) { - if (IsWindow (hwndFrom)) { - hwndNotify = GetParent (hwndFrom); - if (!hwndNotify) - return 0; - } + hwndNotify = hwndTo; + if (!hwndTo) { + if (IsWindow (hwndFrom)) { + hwndNotify = GetParent (hwndFrom); + if (!hwndNotify) + return 0; + } } notify.hwndFrom = hwndFrom; @@ -2454,120 +1243,3 @@ return DoNotify (¬ify, uCode, lpHdr); } - - - - -/************************************************************************** - * DPA_EnumCallback [COMCTL32.385] - * - * Enumerates all items in a dynamic pointer array. - * - * PARAMS - * hdpa [I] handle to the dynamic pointer array - * enumProc [I] - * lParam [I] - * - * RETURNS - * none - */ -VOID WINAPI DPA_EnumCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, - LPVOID lParam) -{ - INT i; - - TRACE("(%p %p %p)\n", hdpa, enumProc, lParam); - - if (!hdpa) - return; - if (hdpa->nItemCount <= 0) - return; - - for (i = 0; i < hdpa->nItemCount; i++) { - if ((enumProc)(hdpa->ptrs[i], lParam) == 0) - return; - } - - return; -} - - -/************************************************************************** - * DPA_DestroyCallback [COMCTL32.386] - * - * Enumerates all items in a dynamic pointer array and destroys it. - * - * PARAMS - * hdpa [I] handle to the dynamic pointer array - * enumProc [I] - * lParam [I] - * - * RETURNS - * none - */ -void WINAPI DPA_DestroyCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, - LPVOID lParam) -{ - TRACE("(%p %p %p)\n", hdpa, enumProc, lParam); - - DPA_EnumCallback (hdpa, enumProc, lParam); - DPA_Destroy (hdpa); -} - - -/************************************************************************** - * DSA_EnumCallback [COMCTL32.387] - * - * Enumerates all items in a dynamic storage array. - * - * PARAMS - * hdsa [I] handle to the dynamic storage array - * enumProc [I] - * lParam [I] - * - * RETURNS - * none - */ -VOID WINAPI DSA_EnumCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, - LPVOID lParam) -{ - INT i; - - TRACE("(%p %p %p)\n", hdsa, enumProc, lParam); - - if (!hdsa) - return; - if (hdsa->nItemCount <= 0) - return; - - for (i = 0; i < hdsa->nItemCount; i++) { - LPVOID lpItem = DSA_GetItemPtr (hdsa, i); - if ((enumProc)(lpItem, lParam) == 0) - return; - } - - return; -} - - -/************************************************************************** - * DSA_DestroyCallback [COMCTL32.388] - * - * Enumerates all items in a dynamic storage array and destroys it. - * - * PARAMS - * hdsa [I] handle to the dynamic storage array - * enumProc [I] - * lParam [I] - * - * RETURNS - * none - */ -void WINAPI DSA_DestroyCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, - LPVOID lParam) -{ - TRACE("(%p %p %p)\n", hdsa, enumProc, lParam); - - DSA_EnumCallback (hdsa, enumProc, lParam); - DSA_Destroy (hdsa); -} diff -urN wine-20050628/dlls/comctl32/comctl_Cn.rc wine-20050725/dlls/comctl32/comctl_Cn.rc --- wine-20050628/dlls/comctl32/comctl_Cn.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Cn.rc 2005-07-15 11:59:04.000000000 +0200 @@ -37,9 +37,9 @@ CAPTION "Wizard" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "½áÊø", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "ÏÂÒ»²½(&N) >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< ÉÏÒ»²½(&B)", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "ÏÂÒ»²½(&N) >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "½áÊø", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "È¡Ïû", IDCANCEL,178,138,50,14 PUSHBUTTON "°ïÖú", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Cs.rc wine-20050725/dlls/comctl32/comctl_Cs.rc --- wine-20050628/dlls/comctl32/comctl_Cs.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Cs.rc 2005-07-15 11:59:04.000000000 +0200 @@ -39,9 +39,9 @@ CAPTION "Prùvodce" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Dokonèit", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Dal¹í >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Zpìt", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Dal¹í >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Dokonèit", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Storno", IDCANCEL,178,138,50,14 PUSHBUTTON "Nápovìda", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_De.rc wine-20050725/dlls/comctl32/comctl_De.rc --- wine-20050628/dlls/comctl32/comctl_De.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_De.rc 2005-07-15 11:59:04.000000000 +0200 @@ -57,9 +57,9 @@ CAPTION "Wizard" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "&Beenden", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Weiter >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Zurück", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Weiter >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "&Beenden", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Abbrechen", IDCANCEL,178,138,50,14 PUSHBUTTON "&Hilfe", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_En.rc wine-20050725/dlls/comctl32/comctl_En.rc --- wine-20050628/dlls/comctl32/comctl_En.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_En.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Wizard" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Finish", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Next >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Back", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Next >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Finish", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Cancel", IDCANCEL,178,138,50,14 PUSHBUTTON "Help", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Es.rc wine-20050725/dlls/comctl32/comctl_Es.rc --- wine-20050628/dlls/comctl32/comctl_Es.rc 2005-02-16 22:11:01.000000000 +0100 +++ wine-20050725/dlls/comctl32/comctl_Es.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Ayudante" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Terminar", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Siguiente >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Anterior", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Siguiente >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Terminar", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Cancelar", IDCANCEL,178,138,50,14 PUSHBUTTON "Ayuda", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Fr.rc wine-20050725/dlls/comctl32/comctl_Fr.rc --- wine-20050628/dlls/comctl32/comctl_Fr.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Fr.rc 2005-07-15 11:59:04.000000000 +0200 @@ -40,9 +40,9 @@ CAPTION "Assistant" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Terminer", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Suivant >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Précédent", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Suivant >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Terminer", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Annuler", IDCANCEL,178,138,50,14 PUSHBUTTON "Aide", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_It.rc wine-20050725/dlls/comctl32/comctl_It.rc --- wine-20050628/dlls/comctl32/comctl_It.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_It.rc 2005-07-15 11:59:04.000000000 +0200 @@ -37,9 +37,9 @@ CAPTION "Wizard" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Fine", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Avanti >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Indietro", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Avanti >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Fine", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Anulla", IDCANCEL,178,138,50,14 PUSHBUTTON "Aiuto", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Ja.rc wine-20050725/dlls/comctl32/comctl_Ja.rc --- wine-20050628/dlls/comctl32/comctl_Ja.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Ja.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Wizard" FONT 9, "MS UI Gothic" BEGIN - DEFPUSHBUTTON "Š®—¹", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "i‚Þ(&N) >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< –ß‚é(&B)", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "i‚Þ(&N) >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Š®—¹", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "ƒLƒƒƒ“ƒZƒ‹", IDCANCEL,178,138,50,14 PUSHBUTTON "ƒwƒ‹ƒv", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Ko.rc wine-20050725/dlls/comctl32/comctl_Ko.rc --- wine-20050628/dlls/comctl32/comctl_Ko.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Ko.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Wizard" FONT 9, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Á¾·á", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "´ÙÀ½(&N) >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< ÀÌÀü(&B)", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "´ÙÀ½(&N) >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Á¾·á", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Ãë¼Ò", IDCANCEL,178,138,50,14 PUSHBUTTON "µµ¿ò¸»", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Nl.rc wine-20050725/dlls/comctl32/comctl_Nl.rc --- wine-20050628/dlls/comctl32/comctl_Nl.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Nl.rc 2005-07-15 11:59:04.000000000 +0200 @@ -38,9 +38,9 @@ CAPTION "Assistent" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Beëindigen", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Volgende >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< V&orige", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Volgende >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Beëindigen", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Annuleren", IDCANCEL,178,138,50,14 PUSHBUTTON "Help", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Pl.rc wine-20050725/dlls/comctl32/comctl_Pl.rc --- wine-20050628/dlls/comctl32/comctl_Pl.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Pl.rc 2005-07-15 11:59:04.000000000 +0200 @@ -37,9 +37,9 @@ CAPTION "Kreator" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Zakoñcz", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Dalej >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Wstecz", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Dalej >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Zakoñcz", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Anuluj", IDCANCEL,178,138,50,14 PUSHBUTTON "Pomoc", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Pt.rc wine-20050725/dlls/comctl32/comctl_Pt.rc --- wine-20050628/dlls/comctl32/comctl_Pt.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Pt.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Assistente" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Finalizar", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Avançar >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Voltar", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Avançar >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Finalizar", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Cancelar", IDCANCEL,178,138,50,14 PUSHBUTTON "Ajuda", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Ru.rc wine-20050725/dlls/comctl32/comctl_Ru.rc --- wine-20050628/dlls/comctl32/comctl_Ru.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Ru.rc 2005-07-15 11:59:04.000000000 +0200 @@ -38,9 +38,9 @@ CAPTION "Ìàñòåð" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Çàâåðøèòü", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Äàëåå >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Íàçàä", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Äàëåå >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Çàâåðøèòü", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Îòìåíà", IDCANCEL,178,138,50,14 PUSHBUTTON "&Ñïðàâêà", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Si.rc wine-20050725/dlls/comctl32/comctl_Si.rc --- wine-20050628/dlls/comctl32/comctl_Si.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Si.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Èarovnik" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Dokonèaj", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "Naprej >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< Na&zaj", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "Naprej >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Dokonèaj", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Preklièi", IDCANCEL,178,138,50,14 PUSHBUTTON "Pomoè", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Sv.rc wine-20050725/dlls/comctl32/comctl_Sv.rc --- wine-20050628/dlls/comctl32/comctl_Sv.rc 2005-04-13 13:04:49.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Sv.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Guide" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "Slutför", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Nästa >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Föregående", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Nästa >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "Slutför", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "Avbryt", IDCANCEL,178,138,50,14 PUSHBUTTON "Hjälp", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Th.rc wine-20050725/dlls/comctl32/comctl_Th.rc --- wine-20050628/dlls/comctl32/comctl_Th.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Th.rc 2005-07-15 11:59:04.000000000 +0200 @@ -36,9 +36,9 @@ CAPTION "Wizard" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "·íÒãËéàÊÃç¨", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "µèÍä» >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< Âé͹¡ÅѺ", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "µèÍä» >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "·íÒãËéàÊÃç¨", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "¡àÅÔ¡", IDCANCEL,178,138,50,14 PUSHBUTTON "ªèÇÂàËÅÕÍ", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/comctl_Uk.rc wine-20050725/dlls/comctl32/comctl_Uk.rc --- wine-20050628/dlls/comctl32/comctl_Uk.rc 2004-09-20 21:13:36.000000000 +0200 +++ wine-20050725/dlls/comctl32/comctl_Uk.rc 2005-07-15 11:59:04.000000000 +0200 @@ -38,9 +38,9 @@ CAPTION "Ìàñòåð" FONT 8, "MS Shell Dlg" BEGIN - DEFPUSHBUTTON "&Çàâåðøèòè", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Äàë³ >", IDC_NEXT_BUTTON,121,138,50,14 PUSHBUTTON "< &Íàçàä", IDC_BACK_BUTTON,71,138,50,14 + DEFPUSHBUTTON "&Äàë³ >", IDC_NEXT_BUTTON,121,138,50,14 + DEFPUSHBUTTON "&Çàâåðøèòè", IDC_FINISH_BUTTON,121,138,50,14 PUSHBUTTON "&³äì³íà", IDCANCEL,178,138,50,14 PUSHBUTTON "&Äîâ³äêà", IDHELP,235,138,50,14,WS_GROUP LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN diff -urN wine-20050628/dlls/comctl32/dpa.c wine-20050725/dlls/comctl32/dpa.c --- wine-20050628/dlls/comctl32/dpa.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/comctl32/dpa.c 2005-07-08 13:30:28.000000000 +0200 @@ -0,0 +1,973 @@ +/* + * Dynamic pointer array (DPA) implementation + * + * Copyright 1998 Eric Kohl + * 1998 Juergen Schmied + * 2000 Eric Kohl for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * NOTES + * These functions were involuntarily documented by Microsoft in 2002 as + * the outcome of an anti-trust suit brought by various U.S. governments. + * As a result the specifications on MSDN are inaccurate, incomplete + * and misleading. A much more complete (unofficial) documentation is + * available at: + * + * http://members.ozemail.com.au/~geoffch/samples/win32/shell/comctl32 + */ + +#define COBJMACROS + +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "commctrl.h" +#include "objbase.h" + +#include "comctl32.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dpa); + +struct _DPA +{ + INT nItemCount; + LPVOID *ptrs; + HANDLE hHeap; + INT nGrow; + INT nMaxCount; +}; + +typedef struct _STREAMDATA +{ + DWORD dwSize; + DWORD dwData2; + DWORD dwItems; +} STREAMDATA, *PSTREAMDATA; + +typedef struct _LOADDATA +{ + INT nCount; + PVOID ptr; +} LOADDATA, *LPLOADDATA; + +typedef HRESULT (CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM); + + +/************************************************************************** + * DPA_LoadStream [COMCTL32.9] + * + * Loads a dynamic pointer array from a stream + * + * PARAMS + * phDpa [O] pointer to a handle to a dynamic pointer array + * loadProc [I] pointer to a callback function + * pStream [I] pointer to a stream + * lParam [I] application specific value + * + * RETURNS + * Success: TRUE + * Failure: FALSE + * + * NOTES + * No more information available yet! + */ +HRESULT WINAPI DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, + IStream *pStream, LPARAM lParam) +{ + HRESULT errCode; + LARGE_INTEGER position; + ULARGE_INTEGER newPosition; + STREAMDATA streamData; + LOADDATA loadData; + ULONG ulRead; + HDPA hDpa; + PVOID *ptr; + + FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n", + phDpa, loadProc, pStream, lParam); + + if (!phDpa || !loadProc || !pStream) + return E_INVALIDARG; + + *phDpa = (HDPA)NULL; + + position.QuadPart = 0; + + /* + * Zero out our streamData + */ + memset(&streamData,0,sizeof(STREAMDATA)); + + errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition); + if (errCode != S_OK) + return errCode; + + errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead); + if (errCode != S_OK) + return errCode; + + FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n", + streamData.dwSize, streamData.dwData2, streamData.dwItems); + + if ( ulRead < sizeof(STREAMDATA) || + lParam < sizeof(STREAMDATA) || + streamData.dwSize < sizeof(STREAMDATA) || + streamData.dwData2 < 1) { + errCode = E_FAIL; + } + + if (streamData.dwItems > (UINT_MAX / 2 / sizeof(VOID*))) /* 536870911 */ + return E_OUTOFMEMORY; + + /* create the dpa */ + hDpa = DPA_Create (streamData.dwItems); + if (!hDpa) + return E_OUTOFMEMORY; + + if (!DPA_Grow (hDpa, streamData.dwItems)) + return E_OUTOFMEMORY; + + /* load data from the stream into the dpa */ + ptr = hDpa->ptrs; + for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) { + errCode = (loadProc)(&loadData, pStream, lParam); + if (errCode != S_OK) { + errCode = S_FALSE; + break; + } + + *ptr = loadData.ptr; + ptr++; + } + + /* set the number of items */ + hDpa->nItemCount = loadData.nCount; + + /* store the handle to the dpa */ + *phDpa = hDpa; + FIXME ("new hDpa=%p, errorcode=%lx\n", hDpa, errCode); + + return errCode; +} + + +/************************************************************************** + * DPA_SaveStream [COMCTL32.10] + * + * Saves a dynamic pointer array to a stream + * + * PARAMS + * hDpa [I] handle to a dynamic pointer array + * loadProc [I] pointer to a callback function + * pStream [I] pointer to a stream + * lParam [I] application specific value + * + * RETURNS + * Success: TRUE + * Failure: FALSE + * + * NOTES + * No more information available yet! + */ +HRESULT WINAPI DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, + IStream *pStream, LPARAM lParam) +{ + + FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n", + hDpa, loadProc, pStream, lParam); + + return E_FAIL; +} + + +/************************************************************************** + * DPA_Merge [COMCTL32.11] + * + * Merge two dynamic pointers arrays. + * + * PARAMS + * hdpa1 [I] handle to a dynamic pointer array + * hdpa2 [I] handle to a dynamic pointer array + * dwFlags [I] flags + * pfnCompare [I] pointer to sort function + * pfnMerge [I] pointer to merge function + * lParam [I] application specific value + * + * RETURNS + * Success: TRUE + * Failure: FALSE + * + * NOTES + * No more information available yet! + */ +BOOL WINAPI DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, + PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, + LPARAM lParam) +{ + INT nCount; + LPVOID *pWork1, *pWork2; + INT nResult, i; + INT nIndex; + + TRACE("%p %p %08lx %p %p %08lx)\n", + hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam); + + if (IsBadWritePtr (hdpa1, sizeof(*hdpa1))) + return FALSE; + + if (IsBadWritePtr (hdpa2, sizeof(*hdpa2))) + return FALSE; + + if (IsBadCodePtr ((FARPROC)pfnCompare)) + return FALSE; + + if (IsBadCodePtr ((FARPROC)pfnMerge)) + return FALSE; + + if (!(dwFlags & DPAM_NOSORT)) { + TRACE("sorting dpa's!\n"); + if (hdpa1->nItemCount > 0) + DPA_Sort (hdpa1, pfnCompare, lParam); + TRACE ("dpa 1 sorted!\n"); + if (hdpa2->nItemCount > 0) + DPA_Sort (hdpa2, pfnCompare, lParam); + TRACE ("dpa 2 sorted!\n"); + } + + if (hdpa2->nItemCount < 1) + return TRUE; + + TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n", + hdpa1->nItemCount, hdpa2->nItemCount); + + + /* working but untrusted implementation */ + + pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]); + pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]); + + nIndex = hdpa1->nItemCount - 1; + nCount = hdpa2->nItemCount - 1; + + do + { + if (nIndex < 0) { + if ((nCount >= 0) && (dwFlags & DPAM_INSERT)) { + /* Now insert the remaining new items into DPA 1 */ + TRACE("%d items to be inserted at start of DPA 1\n", + nCount+1); + for (i=nCount; i>=0; i--) { + PVOID ptr; + + ptr = (pfnMerge)(3, *pWork2, NULL, lParam); + if (!ptr) + return FALSE; + DPA_InsertPtr (hdpa1, 0, ptr); + pWork2--; + } + } + break; + } + nResult = (pfnCompare)(*pWork1, *pWork2, lParam); + TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n", + nResult, nIndex, nCount); + + if (nResult == 0) + { + PVOID ptr; + + ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam); + if (!ptr) + return FALSE; + + nCount--; + pWork2--; + *pWork1 = ptr; + nIndex--; + pWork1--; + } + else if (nResult > 0) + { + /* item in DPA 1 missing from DPA 2 */ + if (dwFlags & DPAM_DELETE) + { + /* Now delete the extra item in DPA1 */ + PVOID ptr; + + ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1); + + (pfnMerge)(2, ptr, NULL, lParam); + } + nIndex--; + pWork1--; + } + else + { + /* new item in DPA 2 */ + if (dwFlags & DPAM_INSERT) + { + /* Now insert the new item in DPA 1 */ + PVOID ptr; + + ptr = (pfnMerge)(3, *pWork2, NULL, lParam); + if (!ptr) + return FALSE; + DPA_InsertPtr (hdpa1, nIndex+1, ptr); + } + nCount--; + pWork2--; + } + + } + while (nCount >= 0); + + return TRUE; +} + + +/************************************************************************** + * DPA_Destroy [COMCTL32.329] + * + * Destroys a dynamic pointer array + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DPA_Destroy (const HDPA hdpa) +{ + TRACE("(%p)\n", hdpa); + + if (!hdpa) + return FALSE; + + if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) + return FALSE; + + return HeapFree (hdpa->hHeap, 0, hdpa); +} + + +/************************************************************************** + * DPA_Grow [COMCTL32.330] + * + * Sets the growth amount. + * + * PARAMS + * hdpa [I] handle (pointer) to the existing (source) pointer array + * nGrow [I] number of items by which the array grows when it's too small + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DPA_Grow (const HDPA hdpa, INT nGrow) +{ + TRACE("(%p %d)\n", hdpa, nGrow); + + if (!hdpa) + return FALSE; + + hdpa->nGrow = max(8, nGrow); + + return TRUE; +} + + +/************************************************************************** + * DPA_Clone [COMCTL32.331] + * + * Copies a pointer array to an other one or creates a copy + * + * PARAMS + * hdpa [I] handle (pointer) to the existing (source) pointer array + * hdpaNew [O] handle (pointer) to the destination pointer array + * + * RETURNS + * Success: pointer to the destination pointer array. + * Failure: NULL + * + * NOTES + * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer + * array will be created and it's handle (pointer) is returned. + * - If 'hdpa' is a NULL-Pointer, the original implementation crashes, + * this implementation just returns NULL. + */ +HDPA WINAPI DPA_Clone (const HDPA hdpa, const HDPA hdpaNew) +{ + INT nNewItems, nSize; + HDPA hdpaTemp; + + if (!hdpa) + return NULL; + + TRACE("(%p %p)\n", hdpa, hdpaNew); + + if (!hdpaNew) { + /* create a new DPA */ + hdpaTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, + sizeof(*hdpaTemp)); + hdpaTemp->hHeap = hdpa->hHeap; + hdpaTemp->nGrow = hdpa->nGrow; + } + else + hdpaTemp = hdpaNew; + + if (hdpaTemp->ptrs) { + /* remove old pointer array */ + HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs); + hdpaTemp->ptrs = NULL; + hdpaTemp->nItemCount = 0; + hdpaTemp->nMaxCount = 0; + } + + /* create a new pointer array */ + nNewItems = hdpaTemp->nGrow * + ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1); + nSize = nNewItems * sizeof(LPVOID); + hdpaTemp->ptrs = HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize); + hdpaTemp->nMaxCount = nNewItems; + + /* clone the pointer array */ + hdpaTemp->nItemCount = hdpa->nItemCount; + memmove (hdpaTemp->ptrs, hdpa->ptrs, + hdpaTemp->nItemCount * sizeof(LPVOID)); + + return hdpaTemp; +} + + +/************************************************************************** + * DPA_GetPtr [COMCTL32.332] + * + * Retrieves a pointer from a dynamic pointer array + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * nIndex [I] array index of the desired pointer + * + * RETURNS + * Success: pointer + * Failure: NULL + */ +LPVOID WINAPI DPA_GetPtr (const HDPA hdpa, INT nIndex) +{ + TRACE("(%p %d)\n", hdpa, nIndex); + + if (!hdpa) + return NULL; + if (!hdpa->ptrs) { + WARN("no pointer array.\n"); + return NULL; + } + if ((nIndex < 0) || (nIndex >= hdpa->nItemCount)) { + WARN("not enough pointers in array (%d vs %d).\n",nIndex,hdpa->nItemCount); + return NULL; + } + + TRACE("-- %p\n", hdpa->ptrs[nIndex]); + + return hdpa->ptrs[nIndex]; +} + + +/************************************************************************** + * DPA_GetPtrIndex [COMCTL32.333] + * + * Retrieves the index of the specified pointer + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * p [I] pointer + * + * RETURNS + * Success: index of the specified pointer + * Failure: -1 + */ +INT WINAPI DPA_GetPtrIndex (const HDPA hdpa, LPVOID p) +{ + INT i; + + if (!hdpa || !hdpa->ptrs) + return -1; + + for (i = 0; i < hdpa->nItemCount; i++) { + if (hdpa->ptrs[i] == p) + return i; + } + + return -1; +} + + +/************************************************************************** + * DPA_InsertPtr [COMCTL32.334] + * + * Inserts a pointer into a dynamic pointer array + * + * PARAMS + * hdpa [I] handle (pointer) to the array + * i [I] array index + * p [I] pointer to insert + * + * RETURNS + * Success: index of the inserted pointer + * Failure: -1 + */ +INT WINAPI DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p) +{ + TRACE("(%p %d %p)\n", hdpa, i, p); + + if (!hdpa || i < 0) return -1; + + /* append item if index is out of bounds */ + i = min(hdpa->nItemCount, i); + + /* create empty spot at the end */ + if (!DPA_SetPtr(hdpa, hdpa->nItemCount, 0)) return -1; + + if (i != hdpa->nItemCount - 1) + memmove (hdpa->ptrs + i + 1, hdpa->ptrs + i, + (hdpa->nItemCount - i - 1) * sizeof(LPVOID)); + + hdpa->ptrs[i] = p; + return i; +} + + +/************************************************************************** + * DPA_SetPtr [COMCTL32.335] + * + * Sets a pointer in the pointer array + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * i [I] index of the pointer that will be set + * p [I] pointer to be set + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p) +{ + LPVOID *lpTemp; + + TRACE("(%p %d %p)\n", hdpa, i, p); + + if (!hdpa || i < 0) + return FALSE; + + if (hdpa->nItemCount <= i) { + /* within the old array */ + if (hdpa->nMaxCount <= i) { + /* resize the block of memory */ + INT nNewItems = + hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1); + INT nSize = nNewItems * sizeof(LPVOID); + + if (hdpa->ptrs) + lpTemp = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->ptrs, nSize); + else + lpTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, nSize); + + if (!lpTemp) + return FALSE; + + hdpa->nMaxCount = nNewItems; + hdpa->ptrs = lpTemp; + } + hdpa->nItemCount = i+1; + } + + /* put the new entry in */ + hdpa->ptrs[i] = p; + + return TRUE; +} + + +/************************************************************************** + * DPA_DeletePtr [COMCTL32.336] + * + * Removes a pointer from the pointer array. + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * i [I] index of the pointer that will be deleted + * + * RETURNS + * Success: deleted pointer + * Failure: NULL + */ +LPVOID WINAPI DPA_DeletePtr (const HDPA hdpa, INT i) +{ + LPVOID *lpDest, *lpSrc, lpTemp = NULL; + INT nSize; + + TRACE("(%p %d)\n", hdpa, i); + + if ((!hdpa) || i < 0 || i >= hdpa->nItemCount) + return NULL; + + lpTemp = hdpa->ptrs[i]; + + /* do we need to move ?*/ + if (i < hdpa->nItemCount - 1) { + lpDest = hdpa->ptrs + i; + lpSrc = lpDest + 1; + nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID); + TRACE("-- move dest=%p src=%p size=%x\n", + lpDest, lpSrc, nSize); + memmove (lpDest, lpSrc, nSize); + } + + hdpa->nItemCount --; + + /* free memory ?*/ + if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) { + INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount); + nSize = nNewItems * sizeof(LPVOID); + lpDest = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, + hdpa->ptrs, nSize); + if (!lpDest) + return NULL; + + hdpa->nMaxCount = nNewItems; + hdpa->ptrs = (LPVOID*)lpDest; + } + + return lpTemp; +} + + +/************************************************************************** + * DPA_DeleteAllPtrs [COMCTL32.337] + * + * Removes all pointers and reinitializes the array. + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DPA_DeleteAllPtrs (const HDPA hdpa) +{ + TRACE("(%p)\n", hdpa); + + if (!hdpa) + return FALSE; + + if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) + return FALSE; + + hdpa->nItemCount = 0; + hdpa->nMaxCount = hdpa->nGrow * 2; + hdpa->ptrs = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, + hdpa->nMaxCount * sizeof(LPVOID)); + + return TRUE; +} + + +/************************************************************************** + * DPA_QuickSort [Internal] + * + * Ordinary quicksort (used by DPA_Sort). + * + * PARAMS + * lpPtrs [I] pointer to the pointer array + * l [I] index of the "left border" of the partition + * r [I] index of the "right border" of the partition + * pfnCompare [I] pointer to the compare function + * lParam [I] user defined value (3rd parameter in compare function) + * + * RETURNS + * NONE + */ +static VOID DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, + PFNDPACOMPARE pfnCompare, LPARAM lParam) +{ + INT m; + LPVOID t; + + TRACE("l=%i r=%i\n", l, r); + + if (l==r) /* one element is always sorted */ + return; + if (r0) + { + t = lpPtrs[m+1]; + memmove(&lpPtrs[l+1],&lpPtrs[l],(m-l+1)*sizeof(lpPtrs[l])); + lpPtrs[l] = t; + + m++; + } + l++; + } +} + + +/************************************************************************** + * DPA_Sort [COMCTL32.338] + * + * Sorts a pointer array using a user defined compare function + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * pfnCompare [I] pointer to the compare function + * lParam [I] user defined value (3rd parameter of compare function) + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam) +{ + if (!hdpa || !pfnCompare) + return FALSE; + + TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam); + + if ((hdpa->nItemCount > 1) && (hdpa->ptrs)) + DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1, + pfnCompare, lParam); + + return TRUE; +} + + +/************************************************************************** + * DPA_Search [COMCTL32.339] + * + * Searches a pointer array for a specified pointer + * + * PARAMS + * hdpa [I] handle (pointer) to the pointer array + * pFind [I] pointer to search for + * nStart [I] start index + * pfnCompare [I] pointer to the compare function + * lParam [I] user defined value (3rd parameter of compare function) + * uOptions [I] search options + * + * RETURNS + * Success: index of the pointer in the array. + * Failure: -1 + * + * NOTES + * Binary search taken from R.Sedgewick "Algorithms in C"! + * Function is NOT tested! + * If something goes wrong, blame HIM not ME! (Eric Kohl) + */ +INT WINAPI DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, + PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions) +{ + if (!hdpa || !pfnCompare || !pFind) + return -1; + + TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n", + hdpa, pFind, nStart, pfnCompare, lParam, uOptions); + + if (uOptions & DPAS_SORTED) { + /* array is sorted --> use binary search */ + INT l, r, x, n; + LPVOID *lpPtr; + + TRACE("binary search\n"); + + l = (nStart == -1) ? 0 : nStart; + r = hdpa->nItemCount - 1; + lpPtr = hdpa->ptrs; + while (r >= l) { + x = (l + r) / 2; + n = (pfnCompare)(pFind, lpPtr[x], lParam); + if (n < 0) + r = x - 1; + else + l = x + 1; + if (n == 0) { + TRACE("-- ret=%d\n", n); + return n; + } + } + + if (uOptions & (DPAS_INSERTBEFORE | DPAS_INSERTAFTER)) { + TRACE("-- ret=%d\n", l); + return l; + } + } + else { + /* array is not sorted --> use linear search */ + LPVOID *lpPtr; + INT nIndex; + + TRACE("linear search\n"); + + nIndex = (nStart == -1)? 0 : nStart; + lpPtr = hdpa->ptrs; + for (; nIndex < hdpa->nItemCount; nIndex++) { + if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) { + TRACE("-- ret=%d\n", nIndex); + return nIndex; + } + } + } + + TRACE("-- not found: ret=-1\n"); + return -1; +} + + +/************************************************************************** + * DPA_CreateEx [COMCTL32.340] + * + * Creates a dynamic pointer array using the specified size and heap. + * + * PARAMS + * nGrow [I] number of items by which the array grows when it is filled + * hHeap [I] handle to the heap where the array is stored + * + * RETURNS + * Success: handle (pointer) to the pointer array. + * Failure: NULL + * + * NOTES + * The DPA_ functions can be used to create and manipulate arrays of + * pointers. + */ +HDPA WINAPI DPA_CreateEx (INT nGrow, HANDLE hHeap) +{ + HDPA hdpa; + + TRACE("(%d %p)\n", nGrow, hHeap); + + if (hHeap) + hdpa = HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(*hdpa)); + else + hdpa = Alloc (sizeof(*hdpa)); + + if (hdpa) { + hdpa->nGrow = max(8, nGrow); + hdpa->hHeap = hHeap ? hHeap : GetProcessHeap(); + hdpa->nMaxCount = hdpa->nGrow * 2; + hdpa->ptrs = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, + hdpa->nMaxCount * sizeof(LPVOID)); + } + + TRACE("-- %p\n", hdpa); + + return hdpa; +} + + +/************************************************************************** + * DPA_Create [COMCTL32.328] + * + * Creates a dynamic pointer array. + * + * PARAMS + * nGrow [I] number of items by which the array grows when it is filled + * + * RETURNS + * Success: handle (pointer) to the pointer array. + * Failure: NULL + * + * NOTES + * The DPA_ functions can be used to create and manipulate arrays of + * pointers. + */ +HDPA WINAPI DPA_Create (INT nGrow) +{ + return DPA_CreateEx( nGrow, 0 ); +} + + +/************************************************************************** + * DPA_EnumCallback [COMCTL32.385] + * + * Enumerates all items in a dynamic pointer array. + * + * PARAMS + * hdpa [I] handle to the dynamic pointer array + * enumProc [I] + * lParam [I] + * + * RETURNS + * none + */ +VOID WINAPI DPA_EnumCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, + LPVOID lParam) +{ + INT i; + + TRACE("(%p %p %p)\n", hdpa, enumProc, lParam); + + if (!hdpa) + return; + if (hdpa->nItemCount <= 0) + return; + + for (i = 0; i < hdpa->nItemCount; i++) { + if ((enumProc)(hdpa->ptrs[i], lParam) == 0) + return; + } + + return; +} + + +/************************************************************************** + * DPA_DestroyCallback [COMCTL32.386] + * + * Enumerates all items in a dynamic pointer array and destroys it. + * + * PARAMS + * hdpa [I] handle to the dynamic pointer array + * enumProc [I] + * lParam [I] + * + * RETURNS + * none + */ +void WINAPI DPA_DestroyCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, + LPVOID lParam) +{ + TRACE("(%p %p %p)\n", hdpa, enumProc, lParam); + + DPA_EnumCallback (hdpa, enumProc, lParam); + DPA_Destroy (hdpa); +} diff -urN wine-20050628/dlls/comctl32/dsa.c wine-20050725/dlls/comctl32/dsa.c --- wine-20050628/dlls/comctl32/dsa.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/comctl32/dsa.c 2005-07-06 12:32:18.000000000 +0200 @@ -0,0 +1,436 @@ +/* + * Dynamic structure array (DSA) implementation + * + * Copyright 1998 Eric Kohl + * 1998 Juergen Schmied + * 2000 Eric Kohl for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * NOTES + * These functions were involuntarily documented by Microsoft in 2002 as + * the outcome of an anti-trust suit brought by various U.S. governments. + * As a result the specifications on MSDN are inaccurate, incomplete + * and misleading. A much more complete (unofficial) documentation is + * available at: + * + * http://members.ozemail.com.au/~geoffch/samples/win32/shell/comctl32 + */ + +#include + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "commctrl.h" + +#include "comctl32.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(dsa); + +struct _DSA +{ + INT nItemCount; + LPVOID pData; + INT nMaxCount; + INT nItemSize; + INT nGrow; +}; + +/************************************************************************** + * DSA_Create [COMCTL32.320] + * + * Creates a dynamic storage array + * + * PARAMS + * nSize [I] size of the array elements + * nGrow [I] number of elements by which the array grows when it is filled + * + * RETURNS + * Success: pointer to an array control structure. Use this like a handle. + * Failure: NULL + * + * NOTES + * The DSA_ functions can be used to create and manipulate arrays of + * fixed-size memory blocks. These arrays can store any kind of data + * (e.g. strings and icons). + */ +HDSA WINAPI DSA_Create (INT nSize, INT nGrow) +{ + HDSA hdsa; + + TRACE("(size=%d grow=%d)\n", nSize, nGrow); + + hdsa = Alloc (sizeof(*hdsa)); + if (hdsa) + { + hdsa->nItemCount = 0; + hdsa->pData = NULL; + hdsa->nMaxCount = 0; + hdsa->nItemSize = nSize; + hdsa->nGrow = max(1, nGrow); + } + + return hdsa; +} + + +/************************************************************************** + * DSA_Destroy [COMCTL32.321] + * + * Destroys a dynamic storage array + * + * PARAMS + * hdsa [I] pointer to the array control structure + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DSA_Destroy (const HDSA hdsa) +{ + TRACE("(%p)\n", hdsa); + + if (!hdsa) + return FALSE; + + if (hdsa->pData && (!Free (hdsa->pData))) + return FALSE; + + return Free (hdsa); +} + + +/************************************************************************** + * DSA_GetItem [COMCTL32.322] + * + * Copies the specified item into a caller-supplied buffer. + * + * PARAMS + * hdsa [I] pointer to the array control structure + * nIndex [I] number of the Item to get + * pDest [O] destination buffer. Has to be >= dwElementSize. + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest) +{ + LPVOID pSrc; + + TRACE("(%p %d %p)\n", hdsa, nIndex, pDest); + + if (!hdsa) + return FALSE; + if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) + return FALSE; + + pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); + memmove (pDest, pSrc, hdsa->nItemSize); + + return TRUE; +} + + +/************************************************************************** + * DSA_GetItemPtr [COMCTL32.323] + * + * Retrieves a pointer to the specified item. + * + * PARAMS + * hdsa [I] pointer to the array control structure + * nIndex [I] index of the desired item + * + * RETURNS + * Success: pointer to an item + * Failure: NULL + */ +LPVOID WINAPI DSA_GetItemPtr (const HDSA hdsa, INT nIndex) +{ + LPVOID pSrc; + + TRACE("(%p %d)\n", hdsa, nIndex); + + if (!hdsa) + return NULL; + if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) + return NULL; + + pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); + + TRACE("-- ret=%p\n", pSrc); + + return pSrc; +} + + +/************************************************************************** + * DSA_SetItem [COMCTL32.325] + * + * Sets the contents of an item in the array. + * + * PARAMS + * hdsa [I] pointer to the array control structure + * nIndex [I] index for the item + * pSrc [I] pointer to the new item data + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) +{ + INT nSize, nNewItems; + LPVOID pDest, lpTemp; + + TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); + + if ((!hdsa) || nIndex < 0) + return FALSE; + + if (hdsa->nItemCount <= nIndex) { + /* within the old array */ + if (hdsa->nMaxCount > nIndex) { + /* within the allocated space, set a new boundary */ + hdsa->nItemCount = nIndex + 1; + } + else { + /* resize the block of memory */ + nNewItems = + hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1); + nSize = hdsa->nItemSize * nNewItems; + + lpTemp = ReAlloc (hdsa->pData, nSize); + if (!lpTemp) + return FALSE; + + hdsa->nMaxCount = nNewItems; + hdsa->nItemCount = nIndex + 1; + hdsa->pData = lpTemp; + } + } + + /* put the new entry in */ + pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); + TRACE("-- move dest=%p src=%p size=%d\n", + pDest, pSrc, hdsa->nItemSize); + memmove (pDest, pSrc, hdsa->nItemSize); + + return TRUE; +} + + +/************************************************************************** + * DSA_InsertItem [COMCTL32.324] + * + * Inserts an item into the array at the specified index. + * + * PARAMS + * hdsa [I] pointer to the array control structure + * nIndex [I] index for the new item + * pSrc [I] pointer to the element + * + * RETURNS + * Success: position of the new item + * Failure: -1 + */ +INT WINAPI DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) +{ + INT nNewItems, nSize; + LPVOID lpTemp, lpDest; + + TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); + + if ((!hdsa) || nIndex < 0) + return -1; + + /* when nIndex >= nItemCount then append */ + if (nIndex >= hdsa->nItemCount) + nIndex = hdsa->nItemCount; + + /* do we need to resize ? */ + if (hdsa->nItemCount >= hdsa->nMaxCount) { + nNewItems = hdsa->nMaxCount + hdsa->nGrow; + nSize = hdsa->nItemSize * nNewItems; + + lpTemp = ReAlloc (hdsa->pData, nSize); + if (!lpTemp) + return -1; + + hdsa->nMaxCount = nNewItems; + hdsa->pData = lpTemp; + } + + /* do we need to move elements ? */ + if (nIndex < hdsa->nItemCount) { + lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); + lpDest = (char *) lpTemp + hdsa->nItemSize; + nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize; + TRACE("-- move dest=%p src=%p size=%d\n", + lpDest, lpTemp, nSize); + memmove (lpDest, lpTemp, nSize); + } + + /* ok, we can put the new Item in */ + hdsa->nItemCount++; + lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); + TRACE("-- move dest=%p src=%p size=%d\n", + lpDest, pSrc, hdsa->nItemSize); + memmove (lpDest, pSrc, hdsa->nItemSize); + + return nIndex; +} + + +/************************************************************************** + * DSA_DeleteItem [COMCTL32.326] + * + * Deletes the specified item from the array. + * + * PARAMS + * hdsa [I] pointer to the array control structure + * nIndex [I] index for the element to delete + * + * RETURNS + * Success: number of the deleted element + * Failure: -1 + */ +INT WINAPI DSA_DeleteItem (const HDSA hdsa, INT nIndex) +{ + LPVOID lpDest,lpSrc; + INT nSize; + + TRACE("(%p %d)\n", hdsa, nIndex); + + if (!hdsa) + return -1; + if (nIndex < 0 || nIndex >= hdsa->nItemCount) + return -1; + + /* do we need to move ? */ + if (nIndex < hdsa->nItemCount - 1) { + lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); + lpSrc = (char *) lpDest + hdsa->nItemSize; + nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1); + TRACE("-- move dest=%p src=%p size=%d\n", + lpDest, lpSrc, nSize); + memmove (lpDest, lpSrc, nSize); + } + + hdsa->nItemCount--; + + /* free memory ? */ + if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) { + nSize = hdsa->nItemSize * hdsa->nItemCount; + + lpDest = ReAlloc (hdsa->pData, nSize); + if (!lpDest) + return -1; + + hdsa->nMaxCount = hdsa->nItemCount; + hdsa->pData = lpDest; + } + + return nIndex; +} + + +/************************************************************************** + * DSA_DeleteAllItems [COMCTL32.327] + * + * Removes all items and reinitializes the array. + * + * PARAMS + * hdsa [I] pointer to the array control structure + * + * RETURNS + * Success: TRUE + * Failure: FALSE + */ +BOOL WINAPI DSA_DeleteAllItems (const HDSA hdsa) +{ + TRACE("(%p)\n", hdsa); + + if (!hdsa) + return FALSE; + if (hdsa->pData && (!Free (hdsa->pData))) + return FALSE; + + hdsa->nItemCount = 0; + hdsa->pData = NULL; + hdsa->nMaxCount = 0; + + return TRUE; +} + + +/************************************************************************** + * DSA_EnumCallback [COMCTL32.387] + * + * Enumerates all items in a dynamic storage array. + * + * PARAMS + * hdsa [I] handle to the dynamic storage array + * enumProc [I] + * lParam [I] + * + * RETURNS + * none + */ +VOID WINAPI DSA_EnumCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, + LPVOID lParam) +{ + INT i; + + TRACE("(%p %p %p)\n", hdsa, enumProc, lParam); + + if (!hdsa) + return; + if (hdsa->nItemCount <= 0) + return; + + for (i = 0; i < hdsa->nItemCount; i++) { + LPVOID lpItem = DSA_GetItemPtr (hdsa, i); + if ((enumProc)(lpItem, lParam) == 0) + return; + } + + return; +} + + +/************************************************************************** + * DSA_DestroyCallback [COMCTL32.388] + * + * Enumerates all items in a dynamic storage array and destroys it. + * + * PARAMS + * hdsa [I] handle to the dynamic storage array + * enumProc [I] + * lParam [I] + * + * RETURNS + * none + */ +void WINAPI DSA_DestroyCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, + LPVOID lParam) +{ + TRACE("(%p %p %p)\n", hdsa, enumProc, lParam); + + DSA_EnumCallback (hdsa, enumProc, lParam); + DSA_Destroy (hdsa); +} diff -urN wine-20050628/dlls/comctl32/header.c wine-20050725/dlls/comctl32/header.c --- wine-20050628/dlls/comctl32/header.c 2005-05-14 13:03:17.000000000 +0200 +++ wine-20050725/dlls/comctl32/header.c 2005-07-25 13:09:09.000000000 +0200 @@ -43,6 +43,8 @@ #include "commctrl.h" #include "comctl32.h" #include "imagelist.h" +#include "tmschema.h" +#include "uxtheme.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(header); @@ -94,6 +96,8 @@ #define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO *)GetWindowLongPtrW(hwnd,0)) +static const WCHAR themeClass[] = {'H','e','a','d','e','r',0}; + inline static LRESULT HEADER_IndexToOrder (HWND hwnd, INT iItem) @@ -164,6 +168,7 @@ HEADER_ITEM *phdi = &infoPtr->items[iItem]; RECT r; INT oldBkMode, cxEdge = GetSystemMetrics(SM_CXEDGE); + HTHEME theme = GetWindowTheme (hwnd); TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, infoPtr->bUnicode); @@ -174,25 +179,52 @@ if (r.right - r.left == 0) return phdi->rect.right; - if (GetWindowLongW (hwnd, GWL_STYLE) & HDS_BUTTONS) { - if (phdi->bDown) { - DrawEdge (hdc, &r, BDR_RAISEDOUTER, - BF_RECT | BF_FLAT | BF_MIDDLE | BF_ADJUST); - r.left += 2; - r.top += 2; - } - else - DrawEdge (hdc, &r, EDGE_RAISED, - BF_RECT | BF_SOFT | BF_MIDDLE | BF_ADJUST); + if (theme != NULL) { + int state = (phdi->bDown) ? HIS_PRESSED : + (bHotTrack ? HIS_HOT : HIS_NORMAL); + DrawThemeBackground (theme, hdc, HP_HEADERITEM, state, + &r, NULL); + GetThemeBackgroundContentRect (theme, hdc, HP_HEADERITEM, state, + &r, &r); + } + else { + if (GetWindowLongW (hwnd, GWL_STYLE) & HDS_BUTTONS) { + if (phdi->bDown) { + DrawEdge (hdc, &r, BDR_RAISEDOUTER, + BF_RECT | BF_FLAT | BF_MIDDLE | BF_ADJUST); + } + else + DrawEdge (hdc, &r, EDGE_RAISED, + BF_RECT | BF_SOFT | BF_MIDDLE | BF_ADJUST); + } + else + DrawEdge (hdc, &r, EDGE_ETCHED, BF_BOTTOM | BF_RIGHT | BF_ADJUST); + } + if (phdi->bDown) { + r.left += 2; + r.top += 2; } - else - DrawEdge (hdc, &r, EDGE_ETCHED, BF_BOTTOM | BF_RIGHT | BF_ADJUST); r.left -= cxEdge; r.right += cxEdge; if (phdi->fmt & HDF_OWNERDRAW) { DRAWITEMSTRUCT dis; + NMCUSTOMDRAW nmcd; + + nmcd.hdr.hwndFrom = hwnd; + nmcd.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID); + nmcd.hdr.code = NM_CUSTOMDRAW; + nmcd.dwDrawStage = CDDS_PREPAINT | CDDS_ITEM | CDDS_ITEMPOSTERASE; + nmcd.hdc = hdc; + nmcd.dwItemSpec = iItem; + nmcd.rc = r; + nmcd.uItemState = phdi->bDown ? CDIS_SELECTED : 0; + nmcd.lItemlParam = phdi->lParam; + + SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, + (WPARAM)nmcd.hdr.idFrom, (LPARAM)&nmcd); + dis.CtlType = ODT_HEADER; dis.CtlID = GetWindowLongPtrW (hwnd, GWLP_ID); dis.itemID = iItem; @@ -315,7 +347,7 @@ HDF_BITMAP_ON_RIGHT|HDF_IMAGE)))) /* no explicit format specified? */ && (phdi->pszText)) { oldBkMode = SetBkMode(hdc, TRANSPARENT); - SetTextColor (hdc, (bHotTrack) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT); + SetTextColor (hdc, (bHotTrack && !theme) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT); r.left = tx; r.right = tx + tw; DrawTextW (hdc, phdi->pszText, -1, @@ -338,6 +370,7 @@ HBRUSH hbrBk; UINT i; INT x; + HTHEME theme = GetWindowTheme (hwnd); /* get rect for the bar, adjusted for the border */ GetClientRect (hwnd, &rect); @@ -346,20 +379,29 @@ hOldFont = SelectObject (hdc, hFont); /* draw Background */ - hbrBk = GetSysColorBrush(COLOR_3DFACE); - FillRect(hdc, &rect, hbrBk); + if (theme == NULL) { + hbrBk = GetSysColorBrush(COLOR_3DFACE); + FillRect(hdc, &rect, hbrBk); + } x = rect.left; for (i = 0; i < infoPtr->uNumItem; i++) { - x = HEADER_DrawItem (hwnd, hdc, HEADER_OrderToIndex(hwnd,i), FALSE); + x = HEADER_DrawItem (hwnd, hdc, HEADER_OrderToIndex(hwnd,i), + infoPtr->iHotItem == i); } if ((x <= rect.right) && (infoPtr->uNumItem > 0)) { rect.left = x; - if (GetWindowLongW (hwnd, GWL_STYLE) & HDS_BUTTONS) - DrawEdge (hdc, &rect, EDGE_RAISED, BF_TOP|BF_LEFT|BF_BOTTOM|BF_SOFT); - else - DrawEdge (hdc, &rect, EDGE_ETCHED, BF_BOTTOM); + if (theme != NULL) { + DrawThemeBackground (theme, hdc, HP_HEADERITEM, HIS_NORMAL, &rect, + NULL); + } + else { + if (GetWindowLongW (hwnd, GWL_STYLE) & HDS_BUTTONS) + DrawEdge (hdc, &rect, EDGE_RAISED, BF_TOP|BF_LEFT|BF_BOTTOM|BF_SOFT); + else + DrawEdge (hdc, &rect, EDGE_ETCHED, BF_BOTTOM); + } } SelectObject (hdc, hOldFont); @@ -1278,6 +1320,7 @@ TEXTMETRICW tm; HFONT hOldFont; HDC hdc; + BOOL themingActive = IsAppThemed() && IsThemeActive(); infoPtr = (HEADER_INFO *)Alloc (sizeof(HEADER_INFO)); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); @@ -1307,6 +1350,8 @@ SelectObject (hdc, hOldFont); ReleaseDC (0, hdc); + if (themingActive) OpenThemeData(hwnd, themeClass); + return 0; } @@ -1317,6 +1362,7 @@ HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd); HEADER_ITEM *lpItem; INT nItem; + HTHEME theme; if (infoPtr->items) { lpItem = infoPtr->items; @@ -1332,6 +1378,9 @@ SetWindowLongPtrW (hwnd, 0, 0); Free (infoPtr); + + theme = GetWindowTheme(hwnd); + CloseThemeData(theme); return 0; } @@ -1692,6 +1741,16 @@ return 0; } +/* Update the theme handle after a theme change */ +static LRESULT HEADER_ThemeChanged(HWND hwnd) +{ + HTHEME theme = GetWindowTheme(hwnd); + CloseThemeData(theme); + OpenThemeData(hwnd, themeClass); + InvalidateRect(hwnd, NULL, FALSE); + return 0; +} + static LRESULT WINAPI HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -1804,6 +1863,9 @@ case WM_SIZE: return HEADER_Size (hwnd, wParam); + case WM_THEMECHANGED: + return HEADER_ThemeChanged (hwnd); + case WM_PAINT: return HEADER_Paint (hwnd, wParam); diff -urN wine-20050628/dlls/comctl32/imagelist.c wine-20050725/dlls/comctl32/imagelist.c --- wine-20050628/dlls/comctl32/imagelist.c 2005-05-06 17:44:32.000000000 +0200 +++ wine-20050725/dlls/comctl32/imagelist.c 2005-07-14 12:15:59.000000000 +0200 @@ -2226,25 +2226,51 @@ HBITMAP hbmOldSrc; ICONINFO ii; BITMAP bmp; + BOOL ret; TRACE("(%p %d %p)\n", himl, i, hIcon); - if (!is_valid(himl)) - return -1; - if ((i >= himl->cMaxImage) || (i < -1)) - return -1; + if (!is_valid(himl)) { + ERR("invalid image list\n"); + return -1; + } + if ((i >= himl->cMaxImage) || (i < -1)) { + ERR("invalid image index %d / %d\n", i, himl->cMaxImage); + return -1; + } hBestFitIcon = CopyImage( hIcon, IMAGE_ICON, himl->cx, himl->cy, LR_COPYFROMRESOURCE); + /* the above will fail if the icon wasn't loaded from a resource, so try + * again without LR_COPYFROMRESOURCE flag */ + if (!hBestFitIcon) + hBestFitIcon = CopyImage( + hIcon, IMAGE_ICON, + himl->cx, himl->cy, + 0); + if (!hBestFitIcon) + return -1; + + ret = GetIconInfo (hBestFitIcon, &ii); + if (!ret) { + DestroyIcon(hBestFitIcon); + return -1; + } - GetIconInfo (hBestFitIcon, &ii); - if (ii.hbmMask == 0) - ERR("no mask!\n"); if (ii.hbmColor == 0) ERR("no color!\n"); - GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); + ret = GetObjectW (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); + if (!ret) { + ERR("couldn't get mask bitmap info\n"); + if (ii.hbmColor) + DeleteObject (ii.hbmColor); + if (ii.hbmMask) + DeleteObject (ii.hbmMask); + DestroyIcon(hBestFitIcon); + return -1; + } if (i == -1) { if (himl->cCurImage + 1 > himl->cMaxImage) @@ -2276,8 +2302,7 @@ SelectObject (hdcImage, hbmOldSrc); - if(hBestFitIcon) - DestroyIcon(hBestFitIcon); + DestroyIcon(hBestFitIcon); if (hdcImage) DeleteDC (hdcImage); if (ii.hbmColor) diff -urN wine-20050628/dlls/comctl32/listview.c wine-20050725/dlls/comctl32/listview.c --- wine-20050628/dlls/comctl32/listview.c 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/comctl32/listview.c 2005-07-25 13:09:38.000000000 +0200 @@ -184,6 +184,7 @@ #include "winnls.h" #include "commctrl.h" #include "comctl32.h" +#include "uxtheme.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -395,6 +396,8 @@ TRACE("hwndSelf=%p, rcList=%s\n", iP->hwndSelf, debugrect(&iP->rcList)); \ } while(0) +static const WCHAR themeClass[] = {'L','i','s','t','V','i','e','w',0}; + /* * forward declarations */ @@ -739,6 +742,12 @@ /******** Notification functions i************************************/ +static LRESULT notify_forward_header(LISTVIEW_INFO *infoPtr, const NMHEADERW *lpnmh) +{ + return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, + (WPARAM)lpnmh->hdr.idFrom, (LPARAM)lpnmh); +} + static LRESULT notify_hdr(LISTVIEW_INFO *infoPtr, INT code, LPNMHDR pnmh) { LRESULT result; @@ -1966,6 +1975,7 @@ if (lprcState) *lprcState = State; TRACE(" - state=%s\n", debugrect(&State)); } + else State.right = 0; /************************************************************/ /* compute ICON bounding box (ala LVM_GETITEMRECT) */ @@ -1988,7 +1998,7 @@ } else /* LVS_SMALLICON, LVS_LIST or LVS_REPORT */ { - Icon.left = State.right; + Icon.left = State.right; Icon.top = Box.top; Icon.right = Icon.left; if (infoPtr->himlSmall && @@ -2000,6 +2010,7 @@ if(lprcIcon) *lprcIcon = Icon; TRACE(" - icon=%s\n", debugrect(&Icon)); } + else Icon.right = 0; /************************************************************/ /* compute LABEL bounding box (ala LVM_GETITEMRECT) */ @@ -4810,6 +4821,7 @@ } bNearest = TRUE; } + else Destination.x = Destination.y = 0; /* if LVFI_PARAM is specified, all other flags are ignored */ if (lpFindInfo->flags & LVFI_PARAM) @@ -7442,6 +7454,25 @@ /*** * DESCRIPTION: + * Update theme handle after a theme change. + * + * PARAMETER(S): + * [I] infoPtr : valid pointer to the listview structure + * + * RETURN: + * SUCCESS : 0 + * FAILURE : something else + */ +static LRESULT LISTVIEW_ThemeChanged(LISTVIEW_INFO *infoPtr) +{ + HTHEME theme = GetWindowTheme(infoPtr->hwndSelf); + CloseThemeData(theme); + OpenThemeData(infoPtr->hwndSelf, themeClass); + return 0; +} + +/*** + * DESCRIPTION: * Updates an items or rearranges the listview control. * * PARAMETER(S): @@ -7485,6 +7516,7 @@ LISTVIEW_INFO *infoPtr; UINT uView = lpcs->style & LVS_TYPEMASK; LOGFONTW logFont; + BOOL themingActive = IsAppThemed() && IsThemeActive(); TRACE("(lpcs=%p)\n", lpcs); @@ -7567,6 +7599,8 @@ } } + if (themingActive) OpenThemeData(hwnd, themeClass); + return 0; fail: @@ -7582,6 +7616,24 @@ /*** * DESCRIPTION: + * Destroys the listview control. + * + * PARAMETER(S): + * [I] infoPtr : valid pointer to the listview structure + * + * RETURN: + * Success: 0 + * Failure: -1 + */ +static LRESULT LISTVIEW_Destroy(LISTVIEW_INFO *infoPtr) +{ + HTHEME theme = GetWindowTheme(infoPtr->hwndSelf); + CloseThemeData(theme); + return 0; +} + +/*** + * DESCRIPTION: * Enables the listview control. * * PARAMETER(S): @@ -8270,10 +8322,15 @@ switch (lpnmh->hdr.code) { - case HDN_TRACKW: - case HDN_TRACKA: + case HDN_ITEMCHANGINGW: + case HDN_ITEMCHANGINGA: + return notify_forward_header(infoPtr, lpnmh); case HDN_ITEMCHANGEDW: case HDN_ITEMCHANGEDA: + notify_forward_header(infoPtr, lpnmh); + /* Fall through */ + case HDN_TRACKW: + case HDN_TRACKA: { COLUMN_INFO *lpColumnInfo; INT dx, cxy; @@ -8345,6 +8402,53 @@ /*** * DESCRIPTION: + * Paint non-client area of control. + * + * PARAMETER(S): + * [I] infoPtr : valid pointer to the listview structureof the sender + * [I] region : update region + * + * RETURN: + * TRUE - frame was painted + * FALSE - call default window proc + */ +static BOOL LISTVIEW_NCPaint(LISTVIEW_INFO *infoPtr, HRGN region) +{ + HTHEME theme = GetWindowTheme (infoPtr->hwndSelf); + BOOL themingActive = IsAppThemed() && IsThemeActive(); + BOOL doTheming = themingActive && (theme != NULL); + HDC dc; + RECT r; + HRGN cliprgn; + int cxEdge = GetSystemMetrics (SM_CXEDGE), + cyEdge = GetSystemMetrics (SM_CYEDGE); + + if (!doTheming) return FALSE; + + GetWindowRect(infoPtr->hwndSelf, &r); + + cliprgn = CreateRectRgn (r.left + cxEdge, r.top + cyEdge, + r.right - cxEdge, r.bottom - cyEdge); + if (region != (HRGN)1) + CombineRgn (cliprgn, cliprgn, region, RGN_AND); + OffsetRect(&r, -r.left, -r.top); + + dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW|DCX_INTERSECTRGN); + OffsetRect(&r, -r.left, -r.top); + + if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0)) + DrawThemeParentBackground(infoPtr->hwndSelf, dc, &r); + DrawThemeBackground (theme, dc, 0, 0, &r, 0); + ReleaseDC(infoPtr->hwndSelf, dc); + + /* Call default proc to get the scrollbars etc. painted */ + DefWindowProcW (infoPtr->hwndSelf, WM_NCPAINT, (WPARAM)cliprgn, 0); + + return TRUE; +} + +/*** + * DESCRIPTION: * Determines the type of structure to use. * * PARAMETER(S): @@ -9240,6 +9344,9 @@ case WM_CREATE: return LISTVIEW_Create(hwnd, (LPCREATESTRUCTW)lParam); + case WM_DESTROY: + return LISTVIEW_Destroy(infoPtr); + case WM_ENABLE: return LISTVIEW_Enable(infoPtr, (BOOL)wParam); @@ -9279,6 +9386,11 @@ case WM_NCDESTROY: return LISTVIEW_NCDestroy(infoPtr); + case WM_NCPAINT: + if (LISTVIEW_NCPaint(infoPtr, (HRGN)wParam)) + return 0; + goto fwd_msg; + case WM_NOTIFY: if (lParam && ((LPNMHDR)lParam)->hwndFrom == infoPtr->hwndHeader) return LISTVIEW_HeaderNotification(infoPtr, (LPNMHEADERW)lParam); @@ -9327,6 +9439,8 @@ return 0; /* case WM_TIMER: */ + case WM_THEMECHANGED: + return LISTVIEW_ThemeChanged(infoPtr); case WM_VSCROLL: return LISTVIEW_VScroll(infoPtr, (INT)LOWORD(wParam), 0, (HWND)lParam); diff -urN wine-20050628/dlls/comctl32/propsheet.c wine-20050725/dlls/comctl32/propsheet.c --- wine-20050628/dlls/comctl32/propsheet.c 2005-06-15 21:12:57.000000000 +0200 +++ wine-20050725/dlls/comctl32/propsheet.c 2005-07-18 12:31:06.000000000 +0200 @@ -33,7 +33,6 @@ * - Enforcing of minimal wizard size * - Messages: * o PSM_GETRESULT - * o PSM_IDTOINDEX * o PSM_INSERTPAGE * o PSM_RECALCPAGESIZES * o PSM_SETHEADERSUBTITLE @@ -45,7 +44,6 @@ * o PSN_QUERYINITIALFOCUS * o PSN_TRANSLATEACCELERATOR * - Styles: - * o PSH_WIZARDHASFINISH * o PSH_RTLREADING * o PSH_STRETCHWATERMARK * o PSH_USEPAGELANG @@ -68,6 +66,7 @@ #include "commctrl.h" #include "prsht.h" #include "comctl32.h" +#include "uxtheme.h" #include "wine/debug.h" #include "wine/unicode.h" @@ -121,6 +120,7 @@ BOOL isModeless; BOOL hasHelp; BOOL hasApply; + BOOL hasFinish; BOOL useCallback; BOOL restartWindows; BOOL rebootSystem; @@ -233,13 +233,11 @@ /* * unhandled header flags: - * PSH_WIZARDHASFINISH 0x00000010 * PSH_RTLREADING 0x00000800 * PSH_STRETCHWATERMARK 0x00040000 * PSH_USEPAGELANG 0x00200000 */ - add_flag(PSH_WIZARDHASFINISH); add_flag(PSH_RTLREADING); add_flag(PSH_STRETCHWATERMARK); add_flag(PSH_USEPAGELANG); @@ -341,6 +339,7 @@ psInfo->hasHelp = dwFlags & PSH_HASHELP; psInfo->hasApply = !(dwFlags & PSH_NOAPPLYNOW); + psInfo->hasFinish = dwFlags & PSH_WIZARDHASFINISH; psInfo->useCallback = (dwFlags & PSH_USECALLBACK )&& (lppsh->pfnCallback); psInfo->isModeless = dwFlags & PSH_MODELESS; @@ -396,6 +395,7 @@ psInfo->hasHelp = dwFlags & PSH_HASHELP; psInfo->hasApply = !(dwFlags & PSH_NOAPPLYNOW); + psInfo->hasFinish = dwFlags & PSH_WIZARDHASFINISH; psInfo->useCallback = (dwFlags & PSH_USECALLBACK) && (lppsh->pfnCallback); psInfo->isModeless = dwFlags & PSH_MODELESS; @@ -1004,6 +1004,8 @@ if (psInfo->hasHelp) num_buttons++; + if (psInfo->hasFinish) + num_buttons++; /* * Obtain the size of the buttons. @@ -1024,40 +1026,47 @@ * All buttons will be at this y coordinate. */ y = rcSheet.bottom - (padding.y + buttonHeight); - + /* - * Position the Next and the Finish buttons. + * Position the Back button. */ - hwndButton = GetDlgItem(hwndParent, IDC_NEXT_BUTTON); + hwndButton = GetDlgItem(hwndParent, IDC_BACK_BUTTON); - x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1)); + x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1)) - buttonWidth; SetWindowPos(hwndButton, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - hwndButton = GetDlgItem(hwndParent, IDC_FINISH_BUTTON); - + /* + * Position the Next button. + */ + hwndButton = GetDlgItem(hwndParent, IDC_NEXT_BUTTON); + + x += buttonWidth; + SetWindowPos(hwndButton, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - ShowWindow(hwndButton, SW_HIDE); - /* - * Position the Back button. + * Position the Finish button. */ - hwndButton = GetDlgItem(hwndParent, IDC_BACK_BUTTON); - - x -= buttonWidth; + hwndButton = GetDlgItem(hwndParent, IDC_FINISH_BUTTON); + + if (psInfo->hasFinish) + x += padding.x + buttonWidth; SetWindowPos(hwndButton, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); + if (!psInfo->hasFinish) + ShowWindow(hwndButton, SW_HIDE); + /* * Position the Cancel button. */ hwndButton = GetDlgItem(hwndParent, IDCANCEL); - x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 2)); + x += padding.x + buttonWidth; SetWindowPos(hwndButton, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); @@ -1069,7 +1078,7 @@ if (psInfo->hasHelp) { - x = rcSheet.right - (padding.x + buttonWidth); + x += padding.x + buttonWidth; SetWindowPos(hwndButton, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); @@ -1533,6 +1542,8 @@ SetWindowSubclass(hwndPage, PROPSHEET_WizardSubclassProc, 1, (DWORD_PTR)ppshpage); } + if (!(psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD)) + EnableThemeDialogTexture (hwndPage, ETDT_ENABLETAB); return TRUE; } @@ -1623,9 +1634,6 @@ ShowWindow(hwndLineHeader, SW_SHOW); } - InvalidateRgn(hwndDlg, NULL, TRUE); - UpdateWindow(hwndDlg); - return TRUE; } @@ -2196,6 +2204,7 @@ */ static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText) { + PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr); HWND hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON); TRACE("'%s'\n", lpszText); @@ -2211,9 +2220,12 @@ hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON); ShowWindow(hwndButton, SW_HIDE); - /* Hide Next button */ - hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); - ShowWindow(hwndButton, SW_HIDE); + if (!psInfo->hasFinish) + { + /* Hide Next button */ + hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); + ShowWindow(hwndButton, SW_HIDE); + } } /****************************************************************************** @@ -2221,6 +2233,7 @@ */ static void PROPSHEET_SetFinishTextW(HWND hwndDlg, LPCWSTR lpszText) { + PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr); HWND hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON); TRACE("'%s'\n", debugstr_w(lpszText)); @@ -2236,9 +2249,12 @@ hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON); ShowWindow(hwndButton, SW_HIDE); - /* Hide Next button */ - hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); - ShowWindow(hwndButton, SW_HIDE); + if (!psInfo->hasFinish) + { + /* Hide Next button */ + hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); + ShowWindow(hwndButton, SW_HIDE); + } } /****************************************************************************** @@ -2439,6 +2455,8 @@ */ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags) { + PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, + PropSheetInfoStr); HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON); HWND hwndNext = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON); HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON); @@ -2454,8 +2472,11 @@ if (dwFlags & PSWIZB_NEXT) { - /* Hide the Finish button */ - ShowWindow(hwndFinish, SW_HIDE); + if (!psInfo->hasFinish) + { + /* Hide the Finish button */ + ShowWindow(hwndFinish, SW_HIDE); + } /* Show and enable the Next button */ ShowWindow(hwndNext, SW_SHOW); @@ -2465,20 +2486,27 @@ SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0); } - if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH)) + if (!psInfo->hasFinish) { - /* Hide the Next button */ - ShowWindow(hwndNext, SW_HIDE); - - /* Show the Finish button */ - ShowWindow(hwndFinish, SW_SHOW); + if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH)) + { + /* Hide the Next button */ + ShowWindow(hwndNext, SW_HIDE); + + /* Show the Finish button */ + ShowWindow(hwndFinish, SW_SHOW); - if (dwFlags & PSWIZB_FINISH) - EnableWindow(hwndFinish, TRUE); + if (!(dwFlags & PSWIZB_DISABLEDFINISH)) + { + EnableWindow(hwndFinish, TRUE); - /* Set the Finish button as the default pushbutton */ - SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); + /* Set the Finish button as the default pushbutton */ + SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); + } + } } + else if (!(dwFlags & PSWIZB_DISABLEDFINISH)) + EnableWindow(hwndFinish, TRUE); } /****************************************************************************** @@ -2596,7 +2624,17 @@ */ static LRESULT PROPSHEET_IdToIndex(HWND hwndDlg, int iPageId) { - FIXME("(%p, %d): stub\n", hwndDlg, iPageId); + int index; + LPCPROPSHEETPAGEW psp; + PropSheetInfo * psInfo = (PropSheetInfo*) GetPropW(hwndDlg, + PropSheetInfoStr); + TRACE("(%p, %d)\n", hwndDlg, iPageId); + for (index = 0; index < psInfo->nPages; index++) { + psp = (LPCPROPSHEETPAGEW)psInfo->proppage[index].hpage; + if (psp->u.pszTemplate == (LPCWSTR)iPageId) + return index; + } + return -1; } @@ -3473,6 +3511,10 @@ return FALSE; } + + case WM_SYSCOLORCHANGE: + COMCTL32_RefreshSysColors(); + return FALSE; case PSM_GETCURRENTPAGEHWND: { diff -urN wine-20050628/dlls/comctl32/tests/Makefile.in wine-20050725/dlls/comctl32/tests/Makefile.in --- wine-20050628/dlls/comctl32/tests/Makefile.in 2005-06-13 14:23:01.000000000 +0200 +++ wine-20050725/dlls/comctl32/tests/Makefile.in 2005-07-03 14:02:10.000000000 +0200 @@ -3,7 +3,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = comctl32.dll -IMPORTS = comctl32 shlwapi user32 gdi32 advapi32 +IMPORTS = comctl32 ole32 shlwapi user32 gdi32 advapi32 CTESTS = \ dpa.c \ diff -urN wine-20050628/dlls/comctl32/tests/dpa.c wine-20050725/dlls/comctl32/tests/dpa.c --- wine-20050628/dlls/comctl32/tests/dpa.c 2005-06-09 11:50:56.000000000 +0200 +++ wine-20050725/dlls/comctl32/tests/dpa.c 2005-07-11 12:59:42.000000000 +0200 @@ -2,6 +2,7 @@ * Unit tests for DPA functions * * Copyright 2003 Uwe Bonnes + * Copyright 2005 Felix Nawothnig * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,64 +19,419 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define COBJMACROS + #include #include "windef.h" #include "winbase.h" #include "winuser.h" #include "commctrl.h" +#include "objidl.h" #include "wine/test.h" -static HDPA (WINAPI *pDPA_Create)(int); -static BOOL (WINAPI *pDPA_Grow)(const HDPA hdpa, INT nGrow); -static BOOL (WINAPI *pDPA_Destroy)(const HDPA hdpa); -static INT (WINAPI *pDPA_Search)(HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT); -static BOOL (WINAPI *pDPA_SetPtr)(const HDPA hdpa, INT i, LPVOID p); - -static INT CALLBACK dpa_strcmp(LPVOID pvstr1, LPVOID pvstr2, LPARAM flags) -{ - LPCSTR str1 = (LPCSTR)pvstr1; - LPCSTR str2 = (LPCSTR)pvstr2; - - return lstrcmpA (str1, str2); -} - -static void DPA_test(void) -{ - HDPA dpa_ret; - INT int_ret; - CHAR test_str0[]="test0"; - - if (!pDPA_Create) - return; - - dpa_ret = pDPA_Create(0); - ok((dpa_ret !=0), "DPA_Create failed\n"); - int_ret = pDPA_Search(dpa_ret,test_str0,0, dpa_strcmp,0, DPAS_SORTED); - ok((int_ret == -1), "DPA_Search found invalid item\n"); - int_ret = pDPA_Search(dpa_ret,test_str0,0, dpa_strcmp,0, DPAS_SORTED|DPAS_INSERTBEFORE); - ok((int_ret == 0), "DPA_Search proposed bad item\n"); - int_ret = pDPA_Search(dpa_ret,test_str0,0, dpa_strcmp,0, DPAS_SORTED|DPAS_INSERTAFTER); - ok((int_ret == 0), "DPA_Search proposed bad item\n"); - int_ret = pDPA_Grow(dpa_ret,0); - ok(int_ret != 0, "DPA_Grow failed\n"); - int_ret = pDPA_SetPtr(dpa_ret, 0, (void*)0xdeadbeef); - ok(int_ret != 0, "DPA_SetPtr failed\n"); - int_ret = pDPA_Destroy(dpa_ret); - ok(int_ret != 0, "DPA_Destory failed\n"); +#define DPAM_NOSORT 0x1 +#define DPAM_INSERT 0x4 +#define DPAM_DELETE 0x8 + +typedef struct _ITEMDATA +{ + INT iPos; + PVOID pvData; +} ITEMDATA, *LPITEMDATA; + +typedef PVOID (CALLBACK *PFNDPAMERGE)(UINT,PVOID,PVOID,LPARAM); +typedef HRESULT (CALLBACK *PFNDPASTM)(LPITEMDATA,IStream*,LPARAM); + +static HDPA (WINAPI *pDPA_Clone)(const HDPA,const HDPA); +static HDPA (WINAPI *pDPA_Create)(INT); +static HDPA (WINAPI *pDPA_CreateEx)(INT,HANDLE); +static PVOID (WINAPI *pDPA_DeleteAllPtrs)(const HDPA); +static PVOID (WINAPI *pDPA_DeletePtr)(const HDPA,INT); +static BOOL (WINAPI *pDPA_Destroy)(const HDPA); +static VOID (WINAPI *pDPA_DestroyCallback)(HDPA,PFNDPAENUMCALLBACK,PVOID); +static VOID (WINAPI *pDPA_EnumCallback)(HDPA,PFNDPAENUMCALLBACK,PVOID); +static INT (WINAPI *pDPA_GetPtr)(const HDPA,INT); +static INT (WINAPI *pDPA_GetPtrIndex)(const HDPA,PVOID); +static BOOL (WINAPI *pDPA_Grow)(HDPA,INT); +static INT (WINAPI *pDPA_InsertPtr)(const HDPA,INT,PVOID); +static HRESULT (WINAPI *pDPA_LoadStream)(HDPA*,PFNDPASTM,IStream*,LPARAM); +static BOOL (WINAPI *pDPA_Merge)(const HDPA,const HDPA,DWORD,PFNDPACOMPARE,PFNDPAMERGE,LPARAM); +static HRESULT (WINAPI *pDPA_SaveStream)(HDPA,PFNDPASTM,IStream*,LPARAM); +static INT (WINAPI *pDPA_Search)(HDPA,PVOID,INT,PFNDPACOMPARE,LPARAM,UINT); +static BOOL (WINAPI *pDPA_SetPtr)(const HDPA,INT,PVOID); +static BOOL (WINAPI *pDPA_Sort)(const HDPA,PFNDPACOMPARE,LPARAM); + +#define COMCTL32_GET_PROC(func, ord) \ + ((p ## func = (PVOID)GetProcAddress(hcomctl32,(LPCSTR)ord)) ? 1 \ + : (trace( #func " not exported\n"), 0)) + +static BOOL InitFunctionPtrs(HMODULE hcomctl32) +{ + /* 4.00+ */ + if(COMCTL32_GET_PROC(DPA_Clone, 331) && + COMCTL32_GET_PROC(DPA_Create, 328) && + COMCTL32_GET_PROC(DPA_CreateEx, 340) && + COMCTL32_GET_PROC(DPA_DeleteAllPtrs, 337) && + COMCTL32_GET_PROC(DPA_DeletePtr, 336) && + COMCTL32_GET_PROC(DPA_Destroy, 329) && + COMCTL32_GET_PROC(DPA_GetPtr, 332) && + COMCTL32_GET_PROC(DPA_GetPtrIndex, 333) && + COMCTL32_GET_PROC(DPA_Grow, 330) && + COMCTL32_GET_PROC(DPA_InsertPtr, 334) && + COMCTL32_GET_PROC(DPA_Search, 339) && + COMCTL32_GET_PROC(DPA_SetPtr, 335) && + COMCTL32_GET_PROC(DPA_Sort, 338)) + { + /* 4.71+ */ + COMCTL32_GET_PROC(DPA_DestroyCallback, 386) && + COMCTL32_GET_PROC(DPA_EnumCallback, 385) && + COMCTL32_GET_PROC(DPA_LoadStream, 9) && + COMCTL32_GET_PROC(DPA_Merge, 11) && + COMCTL32_GET_PROC(DPA_SaveStream, 10); + + return TRUE; + } + + return FALSE; +} + +/* Callbacks */ +static INT CALLBACK CB_CmpLT(PVOID p1, PVOID p2, LPARAM lp) +{ + ok(lp == 0xdeadbeef, "lp=%ld\n", lp); + return p1 < p2 ? -1 : p1 > p2 ? 1 : 0; +} + +static INT CALLBACK CB_CmpGT(PVOID p1, PVOID p2, LPARAM lp) +{ + ok(lp == 0xdeadbeef, "lp=%ld\n", lp); + return p1 > p2 ? -1 : p1 < p2 ? 1 : 0; +} + +static PVOID CALLBACK CB_MergeInsertSrc(UINT op, PVOID p1, PVOID p2, LPARAM lp) +{ + ok(lp == 0xdeadbeef, "lp=%ld\n", lp); + return p1; +} + +static PVOID CALLBACK CB_MergeDeleteOddSrc(UINT op, PVOID p1, PVOID p2, LPARAM lp) +{ + ok(lp == 0xdeadbeef, "lp=%ld\n", lp); + return ((PCHAR)p2)+1; +} + +static INT nEnum; + +static INT CALLBACK CB_EnumFirstThree(PVOID pItem, PVOID lp) +{ + INT i; + + i = pDPA_GetPtrIndex(lp, pItem); + ok(i == nEnum, "i=%d nEnum=%d\n", i, nEnum); + nEnum++; + pDPA_SetPtr(lp, i, (PVOID)7); + return pItem != (PVOID)3; +} + +static HRESULT CALLBACK CB_Save(LPITEMDATA pInfo, IStream *pStm, LPARAM lp) +{ + HRESULT hRes; + + ok(lp == 0xdeadbeef, "lp=%ld\n", lp); + hRes = IStream_Write(pStm, &pInfo->iPos, sizeof(INT), NULL); + ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + hRes = IStream_Write(pStm, &pInfo->pvData, sizeof(PVOID), NULL); + ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + return S_OK; +} + +static HRESULT CALLBACK CB_Load(LPITEMDATA pInfo, IStream *pStm, LPARAM lp) +{ + HRESULT hRes; + INT iOldPos; + + iOldPos = pInfo->iPos; + ok(lp == 0xdeadbeef, "lp=%ld\n", lp); + hRes = IStream_Read(pStm, &pInfo->iPos, sizeof(INT), NULL); + ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + ok(pInfo->iPos == iOldPos, "iPos=%d iOldPos=%d\n", pInfo->iPos, iOldPos); + hRes = IStream_Read(pStm, &pInfo->pvData, sizeof(PVOID), NULL); + ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + return S_OK; +} + +static BOOL CheckDPA(HDPA dpa, DWORD dwIn, PDWORD pdwOut) +{ + DWORD dwOut = 0; + INT i; + + for(i = 0; i < 8;) + { + ULONG_PTR ulItem = (ULONG_PTR)pDPA_GetPtr(dpa, i++); + if(!ulItem) break; + dwOut = dwOut << 4 | (ulItem & 0xf); + } + + *pdwOut = dwOut; + + if(dwOut != dwIn) + { + pDPA_DeleteAllPtrs(dpa); + + do + { + pDPA_InsertPtr(dpa, 0, (PVOID)(dwIn & 0xf)); + dwIn >>= 4; + } + while(dwIn); + + return FALSE; + } + + return TRUE; +} + +static void test_dpa(void) +{ + SYSTEM_INFO si; + HANDLE hHeap; + HDPA dpa, dpa2, dpa3; + INT ret, i; + PVOID p; + DWORD dw, dw2, dw3; + HRESULT hRes; + + GetSystemInfo(&si); + hHeap = HeapCreate(0, 1, 2); + ok(hHeap != NULL, "error=%ld\n", GetLastError()); + dpa3 = pDPA_CreateEx(0, hHeap); + ok(dpa3 != NULL, "\n"); + ret = pDPA_Grow(dpa3, si.dwPageSize + 1); + todo_wine ok(!ret && GetLastError() == ERROR_NOT_ENOUGH_MEMORY, + "ret=%d error=%ld\n", ret, GetLastError()); + + dpa = pDPA_Create(0); + ok(dpa != NULL, "\n"); + + /* Set item with out of bound index */ + ok(pDPA_SetPtr(dpa, 1, (PVOID)6), "\n"); + /* Fill the greated gap */ + ok(pDPA_SetPtr(dpa, 0, (PVOID)5), "\n"); + ok(CheckDPA(dpa, 0x56, &dw), "dw=0x%lx\n", dw); + + /* Prepend item */ + ret = pDPA_InsertPtr(dpa, 1, (PVOID)1); + ok(ret == 1, "ret=%d\n", ret); + /* Append item using correct index */ + ret = pDPA_InsertPtr(dpa, 3, (PVOID)3); + ok(ret == 3, "ret=%d\n", ret); + /* Append item using out of bound index */ + ret = pDPA_InsertPtr(dpa, 5, (PVOID)2); + ok(ret == 4, "ret=%d\n", ret); + /* Append item using DPA_APPEND */ + ret = pDPA_InsertPtr(dpa, DPA_APPEND, (PVOID)4); + ok(ret == 5, "ret=%d\n", ret); + + ok(CheckDPA(dpa, 0x516324, &dw), "dw=0x%lx\n", dw); + + for(i = 1; i <= 6; i++) + { + INT j, k; + k = pDPA_GetPtrIndex(dpa, (PVOID)i); + /* Linear searches should work on unsorted DPAs */ + j = pDPA_Search(dpa, (PVOID)i, 0, CB_CmpLT, 0xdeadbeef, 0); + ok(j == k, "j=%d k=%d\n", j, k); + } + + /* Sort DPA */ + ok(pDPA_Sort(dpa, CB_CmpGT, 0xdeadbeef), "\n"); + ok(CheckDPA(dpa, 0x654321, &dw), "dw=0x%lx\n", dw); + + /* Clone into a new DPA */ + dpa2 = pDPA_Clone(dpa, NULL); + ok(dpa2 != NULL, "\n"); + /* The old data should have been preserved */ + ok(CheckDPA(dpa2, 0x654321, &dw2), "dw=0x%lx\n", dw2); + ok(pDPA_Sort(dpa, CB_CmpLT, 0xdeadbeef), "\n"); + + /* Test if the DPA itself was really copied */ + ok(CheckDPA(dpa, 0x123456, &dw), "dw=0x%lx\n", dw ); + ok(CheckDPA(dpa2, 0x654321, &dw2), "dw2=0x%lx\n", dw2); + + /* Clone into an old DPA */ + p = NULL; SetLastError(ERROR_SUCCESS); + p = pDPA_Clone(dpa, dpa3); + ok(p == dpa3, "p=%p\n", p); + ok(CheckDPA(dpa3, 0x123456, &dw3), "dw3=0x%lx\n", dw3); + + for(i = 1; i <= 6; i++) + { + INT j; + + /* The array is in order so ptr == index+1 */ + j = pDPA_GetPtrIndex(dpa, (PVOID)i); + ok(j+1 == i, "j=%d i=%d\n", j, i); + j = pDPA_Search(dpa, (PVOID)i, 0, CB_CmpLT, 0xdeadbeef, DPAS_SORTED); + if(i > 1) todo_wine ok(j+1 == i, "j=%d i=%d\n", j, i); + + /* Linear searches respect iStart ... */ + j = pDPA_Search(dpa, (PVOID)i, i+1, CB_CmpLT, 0xdeadbeef, 0); + ok(j == DPA_ERR, "j=%d\n", j); + /* ... but for a binary search it's ignored */ + j = pDPA_Search(dpa, (PVOID)i, i+1, CB_CmpLT, 0xdeadbeef, DPAS_SORTED); + todo_wine ok(j+1 == i, "j=%d i=%d\n", j, i); + } + + /* Try to get the index of a nonexistent item */ + i = pDPA_GetPtrIndex(dpa, (PVOID)7); + ok(i == DPA_ERR, "i=%d\n", i); + + /* Try to delete out of bound indexes */ + p = pDPA_DeletePtr(dpa, -1); + ok(p == NULL, "p=%p\n", p); + p = pDPA_DeletePtr(dpa, 6); + ok(p == NULL, "p=%p\n", p); + + /* Delete the third item */ + p = pDPA_DeletePtr(dpa, 2); + ok(p == (PVOID)3, "p=%p\n", p); + ok(CheckDPA(dpa, 0x12456, &dw), "dw=0x%lx\n", dw); + + /* Check where to re-insert the deleted item */ + i = pDPA_Search(dpa, (PVOID)3, 0, + CB_CmpLT, 0xdeadbeef, DPAS_SORTED|DPAS_INSERTAFTER); + ok(i == 2, "i=%d\n", i); + /* DPAS_INSERTBEFORE works just like DPAS_INSERTAFTER */ + i = pDPA_Search(dpa, (PVOID)3, 0, + CB_CmpLT, 0xdeadbeef, DPAS_SORTED|DPAS_INSERTBEFORE); + ok(i == 2, "i=%d\n", i); + + /* Re-insert the item */ + ret = pDPA_InsertPtr(dpa, 2, (PVOID)3); + ok(ret == 2, "ret=%d i=%d\n", ret, 2); + ok(CheckDPA(dpa, 0x123456, &dw), "dw=0x%lx\n", dw); + + /* When doing a binary search while claiming reverse order all indexes + * should be bogus */ + for(i = 0; i < 6; i++) + { + INT j = pDPA_Search(dpa, (PVOID)i, 0, CB_CmpGT, 0xdeadbeef, + DPAS_SORTED|DPAS_INSERTBEFORE); + ok(j != i, "i=%d\n", i); + } + + if(pDPA_Merge) + { + /* Delete all even entries from dpa */ + p = pDPA_DeletePtr(dpa, 1); + p = pDPA_DeletePtr(dpa, 2); + p = pDPA_DeletePtr(dpa, 3); + ok(CheckDPA(dpa, 0x135, &dw), "dw=0x%lx\n", dw); + + /* Delete all odd entries from dpa2 */ + pDPA_Merge(dpa2, dpa, DPAM_DELETE, + CB_CmpLT, CB_MergeDeleteOddSrc, 0xdeadbeef); + todo_wine ok(CheckDPA(dpa2, 0x246, &dw2), "dw=0x%lx\n", dw2); + + /* Merge dpa3 into dpa2 and dpa */ + pDPA_Merge(dpa, dpa3, DPAM_INSERT|DPAM_NOSORT, + CB_CmpLT, CB_MergeInsertSrc, 0xdeadbeef); + pDPA_Merge(dpa2, dpa3, DPAM_INSERT|DPAM_NOSORT, + CB_CmpLT, CB_MergeInsertSrc, 0xdeadbeef); + + ok(CheckDPA(dpa, 0x123456, &dw ), "dw=0x%lx\n", dw); + ok(CheckDPA(dpa2, 0x123456, &dw2), "dw2=0x%lx\n", dw2); + ok(CheckDPA(dpa3, 0x123456, &dw3), "dw3=0x%lx\n", dw3); + } + + if(pDPA_EnumCallback) + { + nEnum = 0; + pDPA_EnumCallback(dpa2, CB_EnumFirstThree, (PVOID)dpa2); + ok(CheckDPA(dpa2, 0x777456, &dw2), "dw=0x%lx\n", dw2); + ok(nEnum == 3, "nEnum=%d\n", nEnum); + } + + /* Setting item with huge index should work */ + ok(pDPA_SetPtr(dpa2, 0x12345, (PVOID)0xdeadbeef), "\n"); + ret = pDPA_GetPtrIndex(dpa2, (PVOID)0xdeadbeef); + ok(ret == 0x12345, "ret=%d\n", ret); + + pDPA_DeleteAllPtrs(dpa2); + ok(CheckDPA(dpa2, 0, &dw2), "dw2=0x%lx\n", dw2); + pDPA_Destroy(dpa2); + + if(pDPA_DestroyCallback) + { + nEnum = 0; + pDPA_DestroyCallback(dpa3, CB_EnumFirstThree, dpa3); + ok(nEnum == 3, "nEnum=%d\n", nEnum); + } + else pDPA_Destroy(dpa3); + + if(!pDPA_SaveStream) + goto skip_stream_tests; + + hRes = CoInitialize(NULL); + if(hRes == S_OK) + { + static const WCHAR szStg[] = { 'S','t','g',0 }; + IStorage* pStg = NULL; + IStream* pStm = NULL; + LARGE_INTEGER liZero; + DWORD dwMode; + liZero.QuadPart = 0; + + dwMode = STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE; + hRes = StgCreateDocfile(NULL, dwMode|STGM_DELETEONRELEASE, 0, &pStg); + ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + + hRes = IStorage_CreateStream(pStg, szStg, dwMode, 0, 0, &pStm); + ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + + hRes = pDPA_SaveStream(dpa, CB_Save, pStm, 0xdeadbeef); + todo_wine ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + pDPA_Destroy(dpa); + + hRes = IStream_Seek(pStm, liZero, STREAM_SEEK_SET, NULL); + ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + hRes = pDPA_LoadStream(&dpa, CB_Load, pStm, 0xdeadbeef); + todo_wine ok(hRes == S_OK, "hRes=0x%lx\n", hRes); + todo_wine ok(CheckDPA(dpa, 0x123456, &dw), "dw=0x%lx\n", dw); + pDPA_Destroy(dpa); + + ret = IStream_Release(pStm); + ok(!ret, "ret=%d\n", ret); + + ret = IStorage_Release(pStg); + ok(!ret, "ret=%d\n", ret); + + CoUninitialize(); + } + else ok(0, "hResult: %ld\n", hRes); + +skip_stream_tests: + pDPA_Destroy(dpa); } START_TEST(dpa) { - HMODULE hdll; + HMODULE hcomctl32; + + hcomctl32 = GetModuleHandleA("comctl32.dll"); - hdll=GetModuleHandleA("comctl32.dll"); - pDPA_Create=(void*)GetProcAddress(hdll,(LPCSTR)328); - pDPA_Destroy=(void*)GetProcAddress(hdll,(LPCSTR)329); - pDPA_Grow=(void*)GetProcAddress(hdll,(LPCSTR)330); - pDPA_Search=(void*)GetProcAddress(hdll,(LPCSTR)339); - pDPA_SetPtr=(void*)GetProcAddress(hdll,(LPCSTR)335); + if(!hcomctl32) + { + ok(0, "error=%ld\n", GetLastError()); + return; + } + + if(InitFunctionPtrs(hcomctl32)) + test_dpa(); + else + trace("skipping tests\n"); - DPA_test(); + FreeLibrary(hcomctl32); } diff -urN wine-20050628/dlls/comctl32/tests/treeview.c wine-20050725/dlls/comctl32/tests/treeview.c --- wine-20050628/dlls/comctl32/tests/treeview.c 2005-06-16 17:52:44.000000000 +0200 +++ wine-20050725/dlls/comctl32/tests/treeview.c 2005-07-06 17:46:47.000000000 +0200 @@ -89,7 +89,7 @@ assert(hChild); AddItem('.'); - ok(!strcmp(sequence, "AB."), "Item creation"); + ok(!strcmp(sequence, "AB."), "Item creation\n"); } static void DoTest1(void) @@ -107,7 +107,7 @@ AddItem('5'); TreeView_SelectItem(hTree, hRoot); AddItem('.'); - ok(!strcmp(sequence, "1(nR)nR23(Rn)Rn45(nR)nR."), "root-none select test"); + ok(!strcmp(sequence, "1(nR)nR23(Rn)Rn45(nR)nR."), "root-none select test\n"); } static void DoTest2(void) @@ -125,7 +125,7 @@ AddItem('5'); TreeView_SelectItem(hTree, hRoot); AddItem('.'); - ok(!strcmp(sequence, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test"); + ok(!strcmp(sequence, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test\n"); } LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) diff -urN wine-20050628/dlls/comctl32/toolbar.c wine-20050725/dlls/comctl32/toolbar.c --- wine-20050628/dlls/comctl32/toolbar.c 2005-06-25 19:55:40.000000000 +0200 +++ wine-20050725/dlls/comctl32/toolbar.c 2005-07-22 21:57:44.000000000 +0200 @@ -118,7 +118,6 @@ typedef struct { DWORD dwStructSize; /* size of TBBUTTON struct */ - INT nHeight; /* height of the toolbar */ INT nWidth; /* width of the toolbar */ RECT client_rect; RECT rcBound; /* bounding rectangle */ @@ -156,8 +155,6 @@ HWND hwndToolTip; /* handle to tool tip control */ HWND hwndNotify; /* handle to the window that gets notifications */ HWND hwndSelf; /* my own handle */ - BOOL bBtnTranspnt; /* button transparency flag */ - BOOL bAutoSize; /* auto size deadlock indicator */ BOOL bAnchor; /* anchor highlight enabled */ BOOL bDoRedraw; /* Redraw status */ BOOL bDragOutSent; /* has TBN_DRAGOUT notification been sent for this drag? */ @@ -249,6 +246,7 @@ static HIMAGELIST TOOLBAR_InsertImageList(PIMLENTRY **pies, INT *cies, HIMAGELIST himl, INT id); static LRESULT TOOLBAR_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam); static void TOOLBAR_SetHotItemEx (TOOLBAR_INFO *infoPtr, INT nHit, DWORD dwReason); +static LRESULT TOOLBAR_AutoSize(HWND hwnd); static LRESULT TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam); @@ -580,7 +578,7 @@ else if ((state & CDIS_MARKED) && !(infoPtr->dwItemCDFlag & TBCDRF_NOMARK)) { clrOld = SetTextColor (hdc, tbcd->clrTextHighlight); clrOldBk = SetBkColor (hdc, tbcd->clrMark); - oldBkMode = SetBkMode (hdc, OPAQUE); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */ + oldBkMode = SetBkMode (hdc, tbcd->nHLStringBkMode); } else { clrOld = SetTextColor (hdc, tbcd->clrText); @@ -671,7 +669,7 @@ retstate |= (btnPtr->fsState & TBSTATE_ENABLED) ? 0 : CDIS_DISABLED; retstate |= (btnPtr->fsState & TBSTATE_MARKED ) ? CDIS_MARKED : 0; retstate |= (btnPtr->bHot ) ? CDIS_HOT : 0; - retstate |= (btnPtr->fsState & TBSTATE_INDETERMINATE) ? CDIS_INDETERMINATE : 0; + retstate |= ((btnPtr->fsState & (TBSTATE_ENABLED|TBSTATE_INDETERMINATE)) == (TBSTATE_ENABLED|TBSTATE_INDETERMINATE)) ? CDIS_INDETERMINATE : 0; /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */ return retstate; } @@ -815,6 +813,7 @@ NMTBCUSTOMDRAW tbcd; DWORD ntfret; INT offset; + INT oldBkMode; rc = btnPtr->rect; CopyRect (&rcArrow, &rc); @@ -894,8 +893,8 @@ tbcd.clrBtnHighlight = comctl32_color.clrBtnHighlight; tbcd.clrMark = comctl32_color.clrHighlight; tbcd.clrHighlightHotTrack = 0; - tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; - tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; + tbcd.nStringBkMode = TRANSPARENT; + tbcd.nHLStringBkMode = OPAQUE; /* MSDN says that this is the text rectangle. * But (why always a but) tracing of v5.7 of native shows * that this is really a *relative* rectangle based on the @@ -983,8 +982,10 @@ if (drawSepDropDownArrow) TOOLBAR_DrawSepDDArrow(infoPtr, &tbcd, &rcArrow, btnPtr->bDropDownPressed); + oldBkMode = SetBkMode (hdc, tbcd.nStringBkMode); if (!(infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) || (btnPtr->fsStyle & BTNS_SHOWTEXT)) TOOLBAR_DrawString (infoPtr, &rcText, lpText, &tbcd); + SetBkMode (hdc, oldBkMode); TOOLBAR_DrawImage(infoPtr, btnPtr, rcBitmap.left, rcBitmap.top, &tbcd); @@ -1007,16 +1008,8 @@ FINALNOTIFY: if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT) { - tbcd.nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT; - tbcd.nmcd.hdc = hdc; - tbcd.nmcd.rc = rc; - tbcd.nmcd.dwItemSpec = btnPtr->idCommand; - tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr); - tbcd.nmcd.lItemlParam = btnPtr->dwData; - tbcd.rcText = rcText; - tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; - tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; - ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); + tbcd.nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT; + TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); } } @@ -1027,7 +1020,7 @@ { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); TBUTTON_INFO *btnPtr; - INT i, oldBKmode = 0; + INT i; RECT rcTemp, rcClient; NMTBCUSTOMDRAW tbcd; DWORD ntfret; @@ -1055,9 +1048,6 @@ ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); infoPtr->dwBaseCustDraw = ntfret & 0xffff; - if (infoPtr->bBtnTranspnt) - oldBKmode = SetBkMode (hdc, TRANSPARENT); - GetClientRect(hwnd, &rcClient); /* redraw necessary buttons */ @@ -1092,9 +1082,6 @@ COMCTL32_DrawInsertMark(hdc, &rcInsertMark, infoPtr->clrInsertMark, FALSE); } - if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT)) - SetBkMode (hdc, oldBKmode); - if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTPAINT) { ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); @@ -1175,12 +1162,20 @@ lpSize->cx = 0; lpSize->cy = 0; - if(infoPtr->nMaxTextRows == 0) + if (infoPtr->nMaxTextRows == 0) return; hdc = GetDC (hwnd); hOldFont = SelectObject (hdc, infoPtr->hFont); + if (infoPtr->nNumButtons == 0) + { + TEXTMETRICW tm; + + GetTextMetricsW(hdc, &tm); + lpSize->cy = tm.tmHeight; + } + btnPtr = infoPtr->buttons; for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { if(TOOLBAR_HasText(infoPtr, btnPtr)) @@ -1557,7 +1552,6 @@ INT x, y, cx, cy; SIZE sizeString, sizeButton; BOOL bWrap; - BOOL usesBitmaps = FALSE; BOOL validImageList = FALSE; BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle); @@ -1565,14 +1559,9 @@ TOOLBAR_DumpToolbar (infoPtr, __LINE__); - for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++) - { - if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap)) - usesBitmaps = TRUE; - } if (TOOLBAR_IsValidImageList(infoPtr, 0)) validImageList = TRUE; - sizeButton = TOOLBAR_MeasureButton(infoPtr, sizeString, usesBitmaps, validImageList); + sizeButton = TOOLBAR_MeasureButton(infoPtr, sizeString, TRUE, validImageList); infoPtr->nButtonWidth = sizeButton.cx; infoPtr->nButtonHeight = sizeButton.cy; @@ -1584,14 +1573,14 @@ TOOLBAR_WrapToolbar( hwnd, dwStyle ); x = infoPtr->nIndent; - y = 0; + if (infoPtr->dwStyle & TBSTYLE_FLAT) + y = 0; + else + y = TOP_BORDER; /* from above, minimum is a button, and possible text */ cx = infoPtr->nButtonWidth; - - infoPtr->nHeight = infoPtr->nButtonHeight; - - cy = infoPtr->nHeight; + cy = infoPtr->nButtonHeight; nRows = nSepRows = 0; @@ -1613,7 +1602,7 @@ continue; } - cy = infoPtr->nHeight; + cy = infoPtr->nButtonHeight; /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ /* it is the actual width of the separator. This is used for */ @@ -1728,27 +1717,7 @@ /* infoPtr->nRows is the number of rows on the toolbar */ infoPtr->nRows = nRows + nSepRows + 1; -#if 0 - /******************************************************************** - * The following while interesting, does not match the values * - * created above for the button rectangles, nor the rcBound rect. * - * We will comment it out and remove it later. * - * * - * The problem showed up as heights in the pager control that was * - * wrong. * - ********************************************************************/ - - /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */ - /* the last row. */ - infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + - nSepRows * (SEPARATOR_WIDTH * 2 / 3) + - nSepRows * (infoPtr->nBitmapHeight + 1) + - BOTTOM_BORDER; -#endif - - infoPtr->nHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top; - - TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth); + TRACE("toolbar button width %d\n", infoPtr->nButtonWidth); } @@ -2731,7 +2700,7 @@ { TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps; infoPtr->bitmaps = Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO)); - memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos); + memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos * sizeof(TBITMAP_INFO)); } infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nButtons = nButtons; @@ -2821,6 +2790,7 @@ } TOOLBAR_CalcToolbar (hwnd); + TOOLBAR_AutoSize (hwnd); TOOLBAR_DumpToolbar (infoPtr, __LINE__); @@ -2889,6 +2859,7 @@ } TOOLBAR_CalcToolbar (hwnd); + TOOLBAR_AutoSize (hwnd); TOOLBAR_DumpToolbar (infoPtr, __LINE__); @@ -3082,66 +3053,66 @@ { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); RECT parent_rect; - RECT window_rect; HWND parent; INT x, y; INT cx, cy; - UINT uPosFlags = SWP_NOZORDER; - TRACE("resize forced, style=%lx!\n", infoPtr->dwStyle); + TRACE("auto sizing, style=%lx!\n", infoPtr->dwStyle); parent = GetParent (hwnd); + + if (!parent || !infoPtr->bDoRedraw) + return 0; + GetClientRect(parent, &parent_rect); x = parent_rect.left; y = parent_rect.top; - /* FIXME: we should be able to early out if nothing */ - /* has changed with nWidth != parent_rect width */ + TRACE("nRows: %d, infoPtr->nButtonHeight: %d\n", infoPtr->nRows, infoPtr->nButtonHeight); - if (infoPtr->dwStyle & CCS_NORESIZE) { - uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); - cx = 0; - cy = 0; - TOOLBAR_CalcToolbar (hwnd); + cy = TOP_BORDER + infoPtr->nRows * infoPtr->nButtonHeight + BOTTOM_BORDER; + cx = parent_rect.right - parent_rect.left; + + if ((infoPtr->dwStyle & TBSTYLE_WRAPABLE) || (infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1)) + { + TOOLBAR_CalcToolbar(hwnd); + InvalidateRect( hwnd, NULL, TRUE ); } - else { - infoPtr->nWidth = parent_rect.right - parent_rect.left; - TOOLBAR_CalcToolbar (hwnd); - InvalidateRect( hwnd, NULL, TRUE ); - cy = infoPtr->nHeight; - cx = infoPtr->nWidth; - - if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) { - GetWindowRect(hwnd, &window_rect); - ScreenToClient(parent, (LPPOINT)&window_rect.left); - y = window_rect.top; - } - if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_BOTTOM) { + + if (!(infoPtr->dwStyle & CCS_NORESIZE)) + { + RECT window_rect; + UINT uPosFlags = SWP_NOZORDER; + + if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) + { + GetWindowRect(hwnd, &window_rect); + ScreenToClient(parent, (LPPOINT)&window_rect.left); + y = window_rect.top; + } + if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_BOTTOM) + { GetWindowRect(hwnd, &window_rect); y = parent_rect.bottom - ( window_rect.bottom - window_rect.top); } - } - if (infoPtr->dwStyle & CCS_NOPARENTALIGN) - uPosFlags |= SWP_NOMOVE; + if (infoPtr->dwStyle & CCS_NOPARENTALIGN) + uPosFlags |= SWP_NOMOVE; + + if (!(infoPtr->dwStyle & CCS_NODIVIDER)) + cy += GetSystemMetrics(SM_CYEDGE); - if (!(infoPtr->dwStyle & CCS_NODIVIDER)) - cy += GetSystemMetrics(SM_CYEDGE); + if (infoPtr->dwStyle & WS_BORDER) + { + x = y = 1; /* FIXME: this looks wrong */ + cy += GetSystemMetrics(SM_CYEDGE); + cx += GetSystemMetrics(SM_CXEDGE); + } - if (infoPtr->dwStyle & WS_BORDER) - { - x = y = 1; - cy += GetSystemMetrics(SM_CYEDGE); - cx += GetSystemMetrics(SM_CXEDGE); + SetWindowPos(hwnd, NULL, x, y, cx, cy, uPosFlags); } - infoPtr->bAutoSize = TRUE; - SetWindowPos (hwnd, HWND_TOP, x, y, cx, cy, uPosFlags); - /* The following line makes sure that the infoPtr->bAutoSize is turned off - * after the setwindowpos calls */ - infoPtr->bAutoSize = FALSE; - return 0; } @@ -3985,6 +3956,7 @@ Free (oldButtons); TOOLBAR_CalcToolbar (hwnd); + TOOLBAR_AutoSize (hwnd); InvalidateRect (hwnd, NULL, TRUE); @@ -4085,6 +4057,7 @@ Free (oldButtons); TOOLBAR_CalcToolbar (hwnd); + TOOLBAR_AutoSize (hwnd); InvalidateRect (hwnd, NULL, TRUE); @@ -4330,6 +4303,7 @@ } TOOLBAR_CalcToolbar(hwnd); + TOOLBAR_AutoSize(hwnd); InvalidateRect(hwnd, NULL, TRUE); return TRUE; @@ -4369,6 +4343,7 @@ TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam; HBITMAP hBitmap; + HBITMAP hbmLoad = NULL; int i = 0, nOldButtons = 0, pos = 0; int nOldBitmaps, nNewBitmaps = 0; HIMAGELIST himlDef = 0; @@ -4383,9 +4358,12 @@ return FALSE; } else if (lpReplace->hInstOld != 0) - { FIXME("resources not in the current module not implemented\n"); - return FALSE; + + if (lpReplace->hInstNew) + { + hbmLoad = LoadBitmapW(lpReplace->hInstNew,(LPWSTR)lpReplace->nIDNew); + hBitmap = hbmLoad; } else { @@ -4412,6 +4390,8 @@ if (nOldButtons == 0) { WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld); + if (hbmLoad) + DeleteObject (hbmLoad); return FALSE; } @@ -4463,6 +4443,8 @@ InvalidateRect(hwnd, NULL, TRUE); + if (hbmLoad) + DeleteObject (hbmLoad); return TRUE; } @@ -4864,12 +4846,6 @@ infoPtr->cxMin = (INT)LOWORD(lParam); infoPtr->cxMax = (INT)HIWORD(lParam); - /* if both values are 0 then we are done */ - if (lParam == 0) { - TRACE("setting both min and max to 0, norecalc\n"); - return TRUE; - } - /* otherwise we need to recalc the toolbar and in some cases recalc the bounding rectangle (does DrawText w/ DT_CALCRECT which doesn't actually draw - GA). */ @@ -5530,7 +5506,6 @@ break; case 1: lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top; - /* lpsize->cy = infoPtr->nHeight; */ break; default: ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n", @@ -5566,7 +5541,6 @@ infoPtr->nBitmapHeight = 15; infoPtr->nBitmapWidth = 16; - infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER; infoPtr->nMaxTextRows = 1; infoPtr->cxMin = -1; infoPtr->cxMax = -1; @@ -5579,7 +5553,6 @@ infoPtr->nOldHit = -1; infoPtr->nHotItem = -1; infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; - infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST)); infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS: DT_CENTER | DT_END_ELLIPSIS; infoPtr->bAnchor = FALSE; /* no anchor highlighting */ infoPtr->bDragOutSent = FALSE; @@ -6641,131 +6614,50 @@ TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - DWORD dwStyle = infoPtr->dwStyle; - RECT parent_rect; - RECT window_rect; - HWND parent; - INT x, y; - INT cx, cy; - INT flags; - UINT uPosFlags = 0; - - /* Resize deadlock check */ - if (infoPtr->bAutoSize) { - infoPtr->bAutoSize = FALSE; - return 0; - } - - /* FIXME: optimize to only update size if the new size doesn't */ - /* match the current size */ - - flags = (INT) wParam; - - /* FIXME for flags = - * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED - */ TRACE("sizing toolbar!\n"); - if (flags == SIZE_RESTORED) { - /* width and height don't apply */ - parent = GetParent (hwnd); - GetClientRect(parent, &parent_rect); - x = parent_rect.left; - y = parent_rect.top; - - if (dwStyle & CCS_NORESIZE) { - uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); - - /* - * this sets the working width of the toolbar, and - * Calc Toolbar will not adjust it, only the height - */ - infoPtr->nWidth = parent_rect.right - parent_rect.left; - cy = infoPtr->nHeight; - cx = infoPtr->nWidth; - TOOLBAR_CalcToolbar (hwnd); - infoPtr->nWidth = cx; - infoPtr->nHeight = cy; - } - else { - infoPtr->nWidth = parent_rect.right - parent_rect.left; - TOOLBAR_CalcToolbar (hwnd); - cy = infoPtr->nHeight; - cx = infoPtr->nWidth; - - if ((dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) { - GetWindowRect(hwnd, &window_rect); - ScreenToClient(parent, (LPPOINT)&window_rect.left); - y = window_rect.top; - } - if ((dwStyle & CCS_BOTTOM) == CCS_BOTTOM) { - GetWindowRect(hwnd, &window_rect); - y = parent_rect.bottom - - ( window_rect.bottom - window_rect.top); - } - } - - if (dwStyle & CCS_NOPARENTALIGN) { - uPosFlags |= SWP_NOMOVE; - cy = infoPtr->nHeight; - cx = infoPtr->nWidth; - } - - if (!(dwStyle & CCS_NODIVIDER)) - cy += GetSystemMetrics(SM_CYEDGE); - - if (dwStyle & WS_BORDER) - { - x = y = 1; - cy += GetSystemMetrics(SM_CYEDGE); - cx += GetSystemMetrics(SM_CXEDGE); - } + if (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) + { + RECT delta_width, delta_height, client, dummy; + DWORD min_x, max_x, min_y, max_y; + TBUTTON_INFO *btnPtr; + INT i; - if(infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) + GetClientRect(hwnd, &client); + if(client.right > infoPtr->client_rect.right) { - RECT delta_width, delta_height, client, dummy; - DWORD min_x, max_x, min_y, max_y; - TBUTTON_INFO *btnPtr; - INT i; - - GetClientRect(hwnd, &client); - if(client.right > infoPtr->client_rect.right) - { - min_x = infoPtr->client_rect.right; - max_x = client.right; - } - else - { - max_x = infoPtr->client_rect.right; - min_x = client.right; - } - if(client.bottom > infoPtr->client_rect.bottom) - { - min_y = infoPtr->client_rect.bottom; - max_y = client.bottom; - } - else - { - max_y = infoPtr->client_rect.bottom; - min_y = client.bottom; - } - - SetRect(&delta_width, min_x, 0, max_x, min_y); - SetRect(&delta_height, 0, min_y, max_x, max_y); - - TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width), wine_dbgstr_rect(&delta_height)); - btnPtr = infoPtr->buttons; - for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) - if(IntersectRect(&dummy, &delta_width, &btnPtr->rect) || - IntersectRect(&dummy, &delta_height, &btnPtr->rect)) - InvalidateRect(hwnd, &btnPtr->rect, TRUE); + min_x = infoPtr->client_rect.right; + max_x = client.right; + } + else + { + max_x = infoPtr->client_rect.right; + min_x = client.right; + } + if(client.bottom > infoPtr->client_rect.bottom) + { + min_y = infoPtr->client_rect.bottom; + max_y = client.bottom; + } + else + { + max_y = infoPtr->client_rect.bottom; + min_y = client.bottom; } - if((uPosFlags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE)) - SetWindowPos (hwnd, 0, x, y, cx, cy, uPosFlags | SWP_NOZORDER); + SetRect(&delta_width, min_x, 0, max_x, min_y); + SetRect(&delta_height, 0, min_y, max_x, max_y); + + TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width), wine_dbgstr_rect(&delta_height)); + btnPtr = infoPtr->buttons; + for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) + if(IntersectRect(&dummy, &delta_width, &btnPtr->rect) || + IntersectRect(&dummy, &delta_height, &btnPtr->rect)) + InvalidateRect(hwnd, &btnPtr->rect, TRUE); } GetClientRect(hwnd, &infoPtr->client_rect); + TOOLBAR_AutoSize(hwnd); return 0; } @@ -6782,8 +6674,6 @@ else infoPtr->dwDTFlags = DT_CENTER | DT_END_ELLIPSIS; - infoPtr->bBtnTranspnt = (lpStyle->styleNew & - (TBSTYLE_FLAT | TBSTYLE_LIST)); TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew); TRACE("new style 0x%08lx\n", lpStyle->styleNew); diff -urN wine-20050628/dlls/comctl32/updown.c wine-20050725/dlls/comctl32/updown.c --- wine-20050628/dlls/comctl32/updown.c 2005-06-16 17:52:44.000000000 +0200 +++ wine-20050725/dlls/comctl32/updown.c 2005-07-25 13:23:42.000000000 +0200 @@ -40,6 +40,8 @@ #include "winnls.h" #include "commctrl.h" #include "comctl32.h" +#include "uxtheme.h" +#include "tmschema.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -75,7 +77,8 @@ #define DEFAULT_ADDBOT 0 /* amount to extend below the buddy window */ #define DEFAULT_BUDDYBORDER 2 /* Width/height of the buddy border */ #define DEFAULT_BUDDYSPACER 2 /* Spacer between the buddy and the ctrl */ - +#define DEFAULT_BUDDYBORDER_THEMED 1 /* buddy border when theming is enabled */ +#define DEFAULT_BUDDYSPACER_THEMED 0 /* buddy spacer when theming is enabled */ /* Work constants */ @@ -175,6 +178,9 @@ */ static void UPDOWN_GetArrowRect (UPDOWN_INFO* infoPtr, RECT *rect, int arrow) { + HTHEME theme = GetWindowTheme (infoPtr->Self); + const int border = theme ? DEFAULT_BUDDYBORDER_THEMED : DEFAULT_BUDDYBORDER; + const int spacer = theme ? DEFAULT_BUDDYSPACER_THEMED : DEFAULT_BUDDYSPACER; GetClientRect (infoPtr->Self, rect); /* @@ -183,17 +189,17 @@ */ if (UPDOWN_HasBuddyBorder(infoPtr)) { if (infoPtr->dwStyle & UDS_ALIGNLEFT) - rect->left += DEFAULT_BUDDYBORDER; + rect->left += border; else - rect->right -= DEFAULT_BUDDYBORDER; + rect->right -= border; - InflateRect(rect, 0, -DEFAULT_BUDDYBORDER); + InflateRect(rect, 0, -border); } /* now figure out if we need a space away from the buddy */ - if ( IsWindow(infoPtr->Buddy) ) { - if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->right -= DEFAULT_BUDDYSPACER; - else rect->left += DEFAULT_BUDDYSPACER; + if (IsWindow(infoPtr->Buddy) ) { + if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->right -= spacer; + else rect->left += spacer; } /* @@ -206,11 +212,11 @@ if (arrow & FLAG_INCR) rect->left = rect->left + len/2; if (arrow & FLAG_DECR) - rect->right = rect->left + len/2 - 1; + rect->right = rect->left + len/2 - (theme ? 0 : 1); } else { int len = rect->bottom - rect->top + 1; /* compute the height */ if (arrow & FLAG_INCR) - rect->bottom = rect->top + len/2 - 1; + rect->bottom = rect->top + len/2 - (theme ? 0 : 1); if (arrow & FLAG_DECR) rect->top = rect->top + len/2; } @@ -219,10 +225,10 @@ /*********************************************************************** * UPDOWN_GetArrowFromPoint * Returns the rectagle (for the up or down arrow) that contains pt. - * If it returns the up rect, it returns TRUE. - * If it returns the down rect, it returns FALSE. + * If it returns the up rect, it returns FLAG_INCR. + * If it returns the down rect, it returns FLAG_DECR. */ -static BOOL UPDOWN_GetArrowFromPoint (UPDOWN_INFO* infoPtr, RECT *rect, POINT pt) +static INT UPDOWN_GetArrowFromPoint (UPDOWN_INFO* infoPtr, RECT *rect, POINT pt) { UPDOWN_GetArrowRect (infoPtr, rect, FLAG_INCR); if(PtInRect(rect, pt)) return FLAG_INCR; @@ -342,42 +348,85 @@ } /*********************************************************************** + * UPDOWN_DrawBuddyBackground + * + * Draw buddy background for visual integration. + */ +static BOOL UPDOWN_DrawBuddyBackground (UPDOWN_INFO *infoPtr, HDC hdc) +{ + RECT br; + HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy); + if (!buddyTheme) return FALSE; + + GetClientRect (infoPtr->Buddy, &br); + MapWindowPoints (infoPtr->Buddy, infoPtr->Self, (POINT*)&br, 2); + /* FIXME: take disabled etc. into account */ + DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL); + return TRUE; +} + +/*********************************************************************** * UPDOWN_Draw * * Draw the arrows. The background need not be erased. */ static LRESULT UPDOWN_Draw (UPDOWN_INFO *infoPtr, HDC hdc) { - BOOL pressed, hot; + BOOL uPressed, uHot, dPressed, dHot; RECT rect; + HTHEME theme = GetWindowTheme (infoPtr->Self); + int uPart = 0, uState = 0, dPart = 0, dState = 0; + BOOL needBuddyBg = FALSE; + + uPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR); + uHot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN); + dPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR); + dHot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN); + if (theme) { + uPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_UPHORZ : SPNP_UP; + uState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED + : (uPressed ? DNS_PRESSED : (uHot ? DNS_HOT : DNS_NORMAL)); + dPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_DOWNHORZ : SPNP_DOWN; + dState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED + : (dPressed ? DNS_PRESSED : (dHot ? DNS_HOT : DNS_NORMAL)); + needBuddyBg = IsWindow (infoPtr->Buddy) + && (IsThemeBackgroundPartiallyTransparent (theme, uPart, uState) + || IsThemeBackgroundPartiallyTransparent (theme, dPart, dState)); + } /* Draw the common border between ourselves and our buddy */ - if (UPDOWN_HasBuddyBorder(infoPtr)) { - GetClientRect(infoPtr->Self, &rect); - DrawEdge(hdc, &rect, EDGE_SUNKEN, - BF_BOTTOM | BF_TOP | - (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT)); + if (UPDOWN_HasBuddyBorder(infoPtr) || needBuddyBg) { + if (!theme || !UPDOWN_DrawBuddyBackground (infoPtr, hdc)) { + GetClientRect(infoPtr->Self, &rect); + DrawEdge(hdc, &rect, EDGE_SUNKEN, + BF_BOTTOM | BF_TOP | + (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT)); + } } /* Draw the incr button */ UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR); - pressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR); - hot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN); - DrawFrameControl(hdc, &rect, DFC_SCROLL, - (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) | - ((infoPtr->dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) | - (pressed ? DFCS_PUSHED : 0) | - (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); + if (theme) { + DrawThemeBackground(theme, hdc, uPart, uState, &rect, NULL); + } else { + DrawFrameControl(hdc, &rect, DFC_SCROLL, + (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) | + ((infoPtr->dwStyle & UDS_HOTTRACK) && uHot ? DFCS_HOT : 0) | + (uPressed ? DFCS_PUSHED : 0) | + (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); + } /* Draw the decr button */ UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR); - pressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR); - hot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN); - DrawFrameControl(hdc, &rect, DFC_SCROLL, - (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) | - ((infoPtr->dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) | - (pressed ? DFCS_PUSHED : 0) | - (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); + if (theme) { + DrawThemeBackground(theme, hdc, dPart, dState, &rect, NULL); + } else { + DrawFrameControl(hdc, &rect, DFC_SCROLL, + (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) | + ((infoPtr->dwStyle & UDS_HOTTRACK) && dHot ? DFCS_HOT : 0) | + (dPressed ? DFCS_PUSHED : 0) | + (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); + } return 0; } @@ -653,6 +702,7 @@ POINT pt = { x, y }; RECT rect; int temp, arrow; + TRACKMOUSEEVENT tme; TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt)); @@ -713,7 +763,19 @@ /* If state changed, redraw the control */ if(temp != infoPtr->Flags) - InvalidateRect (infoPtr->Self, &rect, FALSE); + InvalidateRect (infoPtr->Self, NULL, FALSE); + + /* Set up tracking so the mousein flags can be reset when the + * mouse leaves the control */ + tme.cbSize = sizeof( tme ); + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = infoPtr->Self; + TrackMouseEvent (&tme); + + break; + case WM_MOUSELEAVE: + infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW); + InvalidateRect (infoPtr->Self, NULL, FALSE); break; default: @@ -729,6 +791,8 @@ { UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); int temp; + static const WCHAR themeClass[] = {'S','p','i','n',0}; + HTHEME theme; TRACE("hwnd=%p msg=%04x wparam=%08x lparam=%08lx\n", hwnd, message, wParam, lParam); @@ -761,6 +825,8 @@ if (infoPtr->dwStyle & UDS_AUTOBUDDY) UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV)); + OpenThemeData (hwnd, themeClass); + TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd); break; @@ -771,6 +837,8 @@ Free (infoPtr); SetWindowLongPtrW (hwnd, 0, 0); + theme = GetWindowTheme (hwnd); + CloseThemeData (theme); TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd); break; @@ -791,6 +859,13 @@ } break; + case WM_THEMECHANGED: + theme = GetWindowTheme (hwnd); + CloseThemeData (theme); + OpenThemeData (hwnd, themeClass); + InvalidateRect (hwnd, NULL, FALSE); + break; + case WM_TIMER: /* is this the auto-press timer? */ if(wParam == TIMER_AUTOPRESS) { @@ -849,6 +924,7 @@ case WM_LBUTTONDOWN: case WM_MOUSEMOVE: + case WM_MOUSELEAVE: if(UPDOWN_IsEnabled(infoPtr)) UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); break; diff -urN wine-20050628/dlls/commdlg/Makefile.in wine-20050725/dlls/commdlg/Makefile.in --- wine-20050628/dlls/commdlg/Makefile.in 2005-05-23 12:00:27.000000000 +0200 +++ wine-20050725/dlls/commdlg/Makefile.in 2005-06-28 21:14:03.000000000 +0200 @@ -4,7 +4,7 @@ VPATH = @srcdir@ MODULE = comdlg32.dll IMPORTLIB = libcomdlg32.$(IMPLIBEXT) -IMPORTS = shell32 shlwapi comctl32 winspool user32 gdi32 kernel32 ntdll +IMPORTS = shell32 shlwapi comctl32 winspool user32 gdi32 advapi32 kernel32 ntdll EXTRALIBS = -luuid C_SRCS = \ diff -urN wine-20050628/dlls/commdlg/cdlg16.h wine-20050725/dlls/commdlg/cdlg16.h --- wine-20050628/dlls/commdlg/cdlg16.h 2003-12-12 07:09:13.000000000 +0100 +++ wine-20050725/dlls/commdlg/cdlg16.h 2005-07-24 18:17:29.000000000 +0200 @@ -143,12 +143,20 @@ BOOL16 WINAPI ChooseColor16(LPCHOOSECOLOR16 lpChCol); HWND16 WINAPI FindText16( SEGPTR find); -INT16 WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf); BOOL16 WINAPI GetOpenFileName16(SEGPTR ofn); BOOL16 WINAPI GetSaveFileName16(SEGPTR ofn); BOOL16 WINAPI PrintDlg16( LPPRINTDLG16 print); HWND16 WINAPI ReplaceText16( SEGPTR find); BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16); +BOOL16 CALLBACK ColorDlgProc16( HWND16 hDlg16, UINT16 message, WPARAM16 wParam, LONG lParam ); +BOOL16 CALLBACK FileSaveDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam); +BOOL16 CALLBACK FileOpenDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam); +INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics, UINT16 nFontType, LPARAM lParam ); +INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics, UINT16 nFontType, LPARAM lParam); +BOOL16 CALLBACK FormatCharDlgProc16(HWND16 hDlg16, UINT16 message, WPARAM16 wParam, LPARAM lParam); +short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf); +BOOL16 CALLBACK PrintDlgProc16(HWND16 hDlg16, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam); +BOOL16 CALLBACK PrintSetupDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam); #include "poppack.h" diff -urN wine-20050628/dlls/commdlg/cdlg_De.rc wine-20050725/dlls/commdlg/cdlg_De.rc --- wine-20050628/dlls/commdlg/cdlg_De.rc 2005-01-17 14:43:16.000000000 +0100 +++ wine-20050725/dlls/commdlg/cdlg_De.rc 2005-07-08 13:32:14.000000000 +0200 @@ -1,6 +1,6 @@ /* * Copyright 1994 Martin von Loewis - * Copyright 2004 Henning Gerhardt + * Copyright 2004,2005 Henning Gerhardt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -133,13 +133,13 @@ AUTORADIOBUTTON "&Querformat", rad2, 16, 190, 52, 12, BS_AUTORADIOBUTTON GROUPBOX "Ränder", grp4, 80, 156, 152, 56, BS_GROUPBOX LTEXT "&Links:", stc15, 88, 172, 21, 8 - EDITTEXT edt4, 111, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt4, 111, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER LTEXT "&Rechts:", stc16, 159, 172, 27, 8 - EDITTEXT edt6, 187, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt6, 187, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER LTEXT "&Oben:", stc17, 88, 192, 21, 8 - EDITTEXT edt5, 111, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt5, 111, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER LTEXT "&Unten:", stc18, 159, 192, 23, 8 - EDITTEXT edt7, 187, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt7, 187, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER DEFPUSHBUTTON "OK", IDOK, 71, 220, 50, 14, BS_PUSHBUTTON PUSHBUTTON "Abbrechen", IDCANCEL, 126, 220, 50, 14 PUSHBUTTON "&Drucker...", psh3, 184, 220, 48, 14 diff -urN wine-20050628/dlls/commdlg/cdlg_En.rc wine-20050725/dlls/commdlg/cdlg_En.rc --- wine-20050628/dlls/commdlg/cdlg_En.rc 2005-02-14 12:12:30.000000000 +0100 +++ wine-20050725/dlls/commdlg/cdlg_En.rc 2005-07-07 20:23:45.000000000 +0200 @@ -313,13 +313,13 @@ AUTORADIOBUTTON "&Landscape", rad2, 16, 190, 52, 12, BS_AUTORADIOBUTTON GROUPBOX "Borders", grp4, 80, 156, 152, 56, BS_GROUPBOX LTEXT "L&eft:", stc15, 88, 172, 21, 8 - EDITTEXT edt4, 111, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt4, 111, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER LTEXT "&Right:", stc16, 159, 172, 27, 8 - EDITTEXT edt6, 187, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt6, 187, 170, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER LTEXT "T&op:", stc17, 88, 192, 21, 8 - EDITTEXT edt5, 111, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt5, 111, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER LTEXT "&Bottom:", stc18, 159, 192, 23, 8 - EDITTEXT edt7, 187, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER + EDITTEXT edt7, 187, 190, 39, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER DEFPUSHBUTTON "OK", IDOK, 71, 220, 50, 14, BS_PUSHBUTTON PUSHBUTTON "Cancel", IDCANCEL, 126, 220, 50, 14 PUSHBUTTON "P&rinter...", psh3, 184, 220, 48, 14 @@ -541,3 +541,23 @@ PUSHBUTTON "&Define Custom Colours >>", 719/*1025*/, 4, 150, 142, 14, WS_GROUP | WS_TABSTOP PUSHBUTTON "&i",713,300,200,4,14 /* just a dummy: 'i' is like &i in "sol&id" */ } + +STRINGTABLE DISCARDABLE /* Color names */ +{ + IDS_COLOR_BLACK "Black" + IDS_COLOR_MAROON "Maroon" + IDS_COLOR_GREEN "Green" + IDS_COLOR_OLIVE "Olive" + IDS_COLOR_NAVY "Navy" + IDS_COLOR_PURPLE "Purple" + IDS_COLOR_TEAL "Teal" + IDS_COLOR_GRAY "Grey" + IDS_COLOR_SILVER "Silver" + IDS_COLOR_RED "Red" + IDS_COLOR_LIME "Lime" + IDS_COLOR_YELLOW "Yellow" + IDS_COLOR_BLUE "Blue" + IDS_COLOR_FUCHSIA "Fuchsia" + IDS_COLOR_AQUA "Aqua" + IDS_COLOR_WHITE "White" +} diff -urN wine-20050628/dlls/commdlg/cdlg_Ru.rc wine-20050725/dlls/commdlg/cdlg_Ru.rc --- wine-20050628/dlls/commdlg/cdlg_Ru.rc 2005-01-20 20:56:37.000000000 +0100 +++ wine-20050725/dlls/commdlg/cdlg_Ru.rc 2005-07-07 20:23:45.000000000 +0200 @@ -294,6 +294,37 @@ CONTROL "Ë&àíäøàôò", rad2,"Button",BS_AUTORADIOBUTTON,224,126,52,12 END +PAGESETUPDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 32, 32, 240, 240 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Ïàðàìåòðû ñòðàíèöû" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", rct1, "Static", SS_WHITERECT, 80, 8, 80, 80 + CONTROL "", rct2, "Static", SS_GRAYRECT, 160, 12, 4, 80 + CONTROL "", rct3, "Static", SS_GRAYRECT, 84, 88, 80, 4 + GROUPBOX "Áóìàãà", grp2, 8, 96, 224, 56, BS_GROUPBOX + LTEXT "&Ðàçìåð:", stc2, 16, 112, 36, 8 + COMBOBOX cmb2, 64, 110, 160, 160, CBS_SIMPLE|CBS_DROPDOWN|CBS_SORT|WS_GROUP|WS_TABSTOP|WS_VSCROLL + LTEXT "Ïîäà&÷à:", stc3, 16, 132, 36, 8 + COMBOBOX cmb3, 64, 130, 160, 160, CBS_SIMPLE|CBS_DROPDOWN|CBS_SORT|WS_GROUP|WS_TABSTOP|WS_VSCROLL + GROUPBOX "Îðèåíòàöèÿ", grp1, 8, 156, 64, 56, BS_GROUPBOX + AUTORADIOBUTTON "Ê&íèæíàÿ", rad1, 16, 170, 52, 12, BS_AUTORADIOBUTTON + AUTORADIOBUTTON "Àëü&áîìíàÿ", rad2, 16, 190, 52, 12, BS_AUTORADIOBUTTON + GROUPBOX "Ïîëÿ", grp4, 80, 156, 152, 56, BS_GROUPBOX + LTEXT "&Ñëåâà:", stc15, 88, 172, 31, 8 + EDITTEXT edt4, 121, 170, 29, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER + LTEXT "Ñ&âåðõó:", stc16, 159, 172, 27, 8 + EDITTEXT edt6, 187, 170, 29, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER + LTEXT "Ñïð&àâà:", stc17, 88, 192, 31, 8 + EDITTEXT edt5, 121, 190, 29, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER + LTEXT "Ñíè&çó:", stc18, 159, 192, 23, 8 + EDITTEXT edt7, 187, 190, 29, 12, WS_TABSTOP|WS_GROUP|WS_BORDER|ES_NUMBER + DEFPUSHBUTTON "ÎÊ", IDOK, 71, 220, 50, 14, BS_PUSHBUTTON + PUSHBUTTON "Îòìåíà", IDCANCEL, 126, 220, 50, 14 + PUSHBUTTON "&Ïðèíòåð...", psh3, 184, 220, 48, 14 +END + + NEWFILEOPENORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 280, 164 STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN CAPTION "Îòêðûòü" diff -urN wine-20050628/dlls/commdlg/colordlg.c wine-20050725/dlls/commdlg/colordlg.c --- wine-20050628/dlls/commdlg/colordlg.c 2005-03-23 14:15:20.000000000 +0100 +++ wine-20050725/dlls/commdlg/colordlg.c 2005-06-28 21:19:07.000000000 +0200 @@ -203,7 +203,7 @@ /*********************************************************************** * CC_DrawCurrentFocusRect [internal] */ -void CC_DrawCurrentFocusRect( LCCPRIV lpp ) +static void CC_DrawCurrentFocusRect( LCCPRIV lpp ) { if (lpp->hwndFocus) { @@ -216,7 +216,7 @@ /*********************************************************************** * CC_DrawFocusRect [internal] */ -void CC_DrawFocusRect( LCCPRIV lpp, HWND hwnd, int x, int y, int rows, int cols) +static void CC_DrawFocusRect( LCCPRIV lpp, HWND hwnd, int x, int y, int rows, int cols) { RECT rect; int dx, dy; @@ -822,7 +822,7 @@ /*********************************************************************** * CC_WMInitDialog [internal] */ -LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam ) +static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam ) { int i, res; int r, g, b; diff -urN wine-20050628/dlls/commdlg/colordlg16.c wine-20050725/dlls/commdlg/colordlg16.c --- wine-20050628/dlls/commdlg/colordlg16.c 2005-03-23 14:15:20.000000000 +0100 +++ wine-20050725/dlls/commdlg/colordlg16.c 2005-06-28 21:19:07.000000000 +0200 @@ -71,7 +71,7 @@ /*********************************************************************** * CC_WMInitDialog16 [internal] */ -LONG CC_WMInitDialog16( HWND hDlg, WPARAM wParam, LPARAM lParam ) +static LONG CC_WMInitDialog16( HWND hDlg, WPARAM wParam, LPARAM lParam ) { int i, res; int r, g, b; @@ -190,7 +190,7 @@ /*********************************************************************** * CC_WMCommand16 [internal] */ -LRESULT CC_WMCommand16( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) +static LRESULT CC_WMCommand16( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl ) { int r, g, b, i, xx; UINT cokmsg; diff -urN wine-20050628/dlls/commdlg/filedlg.c wine-20050725/dlls/commdlg/filedlg.c --- wine-20050628/dlls/commdlg/filedlg.c 2005-06-07 22:03:30.000000000 +0200 +++ wine-20050725/dlls/commdlg/filedlg.c 2005-07-05 16:11:04.000000000 +0200 @@ -67,6 +67,7 @@ #include "wine/unicode.h" #include "wingdi.h" #include "winuser.h" +#include "winreg.h" #include "commdlg.h" #include "dlgs.h" #include "cdlg.h" @@ -712,7 +713,7 @@ 0, 0, rectChild.right, rectChild.bottom, SWP_NOACTIVATE); } -INT_PTR CALLBACK FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: @@ -721,7 +722,7 @@ return FALSE; } -HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd) +static HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd) { LPCVOID template; HRSRC hRes; @@ -849,7 +850,7 @@ static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer) { - INT_PTR sizeUsed = 0, n, total; + UINT sizeUsed = 0, n, total; LPWSTR lpstrFileList = NULL; WCHAR lpstrCurrentDir[MAX_PATH]; FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); @@ -911,7 +912,7 @@ static INT_PTR FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer) { - INT_PTR sizeUsed = 0; + UINT sizeUsed = 0; LPWSTR lpstrFileList = NULL; FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); @@ -2486,6 +2487,27 @@ * * Initialisation of the look in combo box */ + +/* Small helper function, to determine if the unixfs shell extension is rooted + * at the desktop. Copied from dlls/shell32/shfldr_unixfs.c. + */ +static inline BOOL FILEDLG95_unixfs_is_rooted_at_desktop(void) { + HKEY hKey; + const static WCHAR wszRootedAtDesktop[] = { 'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', + 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', + 'E','x','p','l','o','r','e','r','\\','D','e','s','k','t','o','p','\\', + 'N','a','m','e','S','p','a','c','e','\\','{','9','D','2','0','A','A','E','8', + '-','0','6','2','5','-','4','4','B','0','-','9','C','A','7','-', + '7','1','8','8','9','C','2','2','5','4','D','9','}',0 }; + + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRootedAtDesktop, 0, KEY_READ, &hKey) != ERROR_SUCCESS) + return FALSE; + + RegCloseKey(hKey); + return TRUE; +} + static void FILEDLG95_LOOKIN_Init(HWND hwndCombo) { IShellFolder *psfRoot, *psfDrives; @@ -2525,26 +2547,31 @@ { FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND); - /* special handling for CSIDL_DRIVES */ - if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives)) + /* If the unixfs extension is rooted, we don't expand the drives by default */ + if (!FILEDLG95_unixfs_is_rooted_at_desktop()) { - if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives))) + /* special handling for CSIDL_DRIVES */ + if (COMDLG32_PIDL_ILIsEqual(pidlTmp, pidlDrives)) { - /* enumerate the drives */ - if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives))) + if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives))) { - while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL)) + /* enumerate the drives */ + if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives))) { - pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1); - FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND); - COMDLG32_SHFree(pidlAbsTmp); - COMDLG32_SHFree(pidlTmp1); + while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL)) + { + pidlAbsTmp = COMDLG32_PIDL_ILCombine(pidlTmp, pidlTmp1); + FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND); + COMDLG32_SHFree(pidlAbsTmp); + COMDLG32_SHFree(pidlTmp1); + } + IEnumIDList_Release(lpeDrives); } - IEnumIDList_Release(lpeDrives); + IShellFolder_Release(psfDrives); } - IShellFolder_Release(psfDrives); } } + COMDLG32_SHFree(pidlTmp); } IEnumIDList_Release(lpeRoot); @@ -3500,7 +3527,7 @@ * * called from the common 16/32 code to call the appropriate hook */ -BOOL CALLBACK FD32_CallWindowProc(PFD31_DATA lfs, UINT wMsg, WPARAM wParam, +static BOOL CALLBACK FD32_CallWindowProc(PFD31_DATA lfs, UINT wMsg, WPARAM wParam, LPARAM lParam) { BOOL ret; diff -urN wine-20050628/dlls/commdlg/filedlg16.c wine-20050725/dlls/commdlg/filedlg16.c --- wine-20050628/dlls/commdlg/filedlg16.c 2005-02-10 18:10:01.000000000 +0100 +++ wine-20050725/dlls/commdlg/filedlg16.c 2005-06-28 21:19:07.000000000 +0200 @@ -46,7 +46,7 @@ * FD16_MapOfnStruct16 [internal] * map a 16 bits structure to an Unicode one */ -void FD16_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open) +static void FD16_MapOfnStruct16(LPOPENFILENAME16 ofn16, LPOPENFILENAMEW ofnW, BOOL open) { OPENFILENAMEA ofnA; /* first convert to linear pointers */ @@ -85,7 +85,7 @@ * by a 16 bits application * */ -BOOL FD16_GetTemplate(PFD31_DATA lfs) +static BOOL FD16_GetTemplate(PFD31_DATA lfs) { PFD16_PRIVATE priv = (PFD16_PRIVATE) lfs->private1632; LPOPENFILENAME16 ofn16 = priv->ofn16; @@ -183,7 +183,7 @@ * * called from the common 16/32 code to call the appropriate hook */ -BOOL CALLBACK FD16_CallWindowProc(PFD31_DATA lfs, UINT wMsg, WPARAM wParam, +static BOOL CALLBACK FD16_CallWindowProc(PFD31_DATA lfs, UINT wMsg, WPARAM wParam, LPARAM lParam) { PFD16_PRIVATE priv = (PFD16_PRIVATE) lfs->private1632; diff -urN wine-20050628/dlls/commdlg/filedlg31.c wine-20050725/dlls/commdlg/filedlg31.c --- wine-20050628/dlls/commdlg/filedlg31.c 2005-02-03 20:39:26.000000000 +0100 +++ wine-20050725/dlls/commdlg/filedlg31.c 2005-06-28 21:19:07.000000000 +0200 @@ -303,7 +303,7 @@ * FD31_UpdateResult [internal] * update the displayed file name (with path) */ -void FD31_UpdateResult(PFD31_DATA lfs, WCHAR *tmpstr) +static void FD31_UpdateResult(PFD31_DATA lfs, WCHAR *tmpstr) { int lenstr2; LPOPENFILENAMEW ofnW = lfs->ofnW; @@ -341,7 +341,7 @@ * FD31_UpdateFileTitle [internal] * update the displayed file name (without path) */ -void FD31_UpdateFileTitle(PFD31_DATA lfs) +static void FD31_UpdateFileTitle(PFD31_DATA lfs) { LONG lRet; LPOPENFILENAMEW ofnW = lfs->ofnW; diff -urN wine-20050628/dlls/commdlg/filedlgbrowser.c wine-20050725/dlls/commdlg/filedlgbrowser.c --- wine-20050628/dlls/commdlg/filedlgbrowser.c 2005-06-07 22:03:30.000000000 +0200 +++ wine-20050725/dlls/commdlg/filedlgbrowser.c 2005-07-05 16:11:04.000000000 +0200 @@ -50,7 +50,7 @@ const IShellBrowserVtbl *lpVtbl; const ICommDlgBrowserVtbl *lpVtblCommDlgBrowser; const IServiceProviderVtbl *lpVtblServiceProvider; - DWORD ref; /* Reference counter */ + LONG ref; /* Reference counter */ HWND hwndOwner; /* Owner dialog of the interface */ } IShellBrowserImpl; @@ -66,10 +66,7 @@ * Local Prototypes */ -HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv); -#if 0 -LPITEMIDLIST GetSelectedPidl(IShellView *ppshv); -#endif +static HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv); /************************************************************************** * External Prototypes @@ -223,7 +220,7 @@ /*************************************************************************** * IShellBrowserImpl_QueryInterface */ -HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_QueryInterface(IShellBrowser *iface, REFIID riid, LPVOID *ppvObj) { @@ -263,7 +260,7 @@ /************************************************************************** * IShellBrowser::AddRef */ -ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface) +static ULONG WINAPI IShellBrowserImpl_AddRef(IShellBrowser * iface) { IShellBrowserImpl *This = (IShellBrowserImpl *)iface; ULONG ref = InterlockedIncrement(&This->ref); @@ -276,7 +273,7 @@ /************************************************************************** * IShellBrowserImpl_Release */ -ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface) +static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface) { IShellBrowserImpl *This = (IShellBrowserImpl *)iface; ULONG ref = InterlockedDecrement(&This->ref); @@ -306,7 +303,7 @@ * Note : We will never be window less in the File Open dialog * */ -HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, +static HRESULT WINAPI IShellBrowserImpl_GetWindow(IShellBrowser * iface, HWND * phwnd) { IShellBrowserImpl *This = (IShellBrowserImpl *)iface; @@ -325,7 +322,7 @@ /************************************************************************** * IShellBrowserImpl_ContextSensitiveHelp */ -HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface, +static HRESULT WINAPI IShellBrowserImpl_ContextSensitiveHelp(IShellBrowser * iface, BOOL fEnterMode) { IShellBrowserImpl *This = (IShellBrowserImpl *)iface; @@ -348,7 +345,7 @@ * This function will override user specified flags and will always * use SBSP_DEFBROWSER and SBSP_DEFMODE. */ -HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_BrowseObject(IShellBrowser *iface, LPCITEMIDLIST pidl, UINT wFlags) { @@ -485,7 +482,7 @@ /************************************************************************** * IShellBrowserImpl_EnableModelessSB */ -HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_EnableModelessSB(IShellBrowser *iface, BOOL fEnable) { @@ -500,7 +497,7 @@ /************************************************************************** * IShellBrowserImpl_GetControlWindow */ -HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_GetControlWindow(IShellBrowser *iface, UINT id, HWND *lphwnd) @@ -512,10 +509,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_GetViewStateStream */ -HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_GetViewStateStream(IShellBrowser *iface, DWORD grfMode, LPSTREAM *ppStrm) @@ -527,10 +525,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_InsertMenusSB */ -HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_InsertMenusSB(IShellBrowser *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths) @@ -542,10 +541,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_OnViewWindowActive */ -HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_OnViewWindowActive(IShellBrowser *iface, IShellView *ppshv) { @@ -556,10 +556,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_QueryActiveShellView */ -HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_QueryActiveShellView(IShellBrowser *iface, IShellView **ppshv) { @@ -578,10 +579,11 @@ IShellView_AddRef(fodInfos->Shell.FOIShellView); return NOERROR; } + /************************************************************************** * IShellBrowserImpl_RemoveMenusSB */ -HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_RemoveMenusSB(IShellBrowser *iface, HMENU hmenuShared) { @@ -592,10 +594,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_SendControlMsg */ -HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_SendControlMsg(IShellBrowser *iface, UINT id, UINT uMsg, WPARAM wParam, @@ -620,10 +623,11 @@ if (pret) *pret = lres; return S_OK; } + /************************************************************************** * IShellBrowserImpl_SetMenuSB */ -HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_SetMenuSB(IShellBrowser *iface, HMENU hmenuShared, HOLEMENU holemenuReserved, HWND hwndActiveObject) @@ -636,10 +640,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_SetStatusTextSB */ -HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_SetStatusTextSB(IShellBrowser *iface, LPCOLESTR lpszStatusText) { @@ -650,10 +655,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_SetToolbarItems */ -HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_SetToolbarItems(IShellBrowser *iface, LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags) @@ -666,10 +672,11 @@ /* Feature not implemented */ return E_NOTIMPL; } + /************************************************************************** * IShellBrowserImpl_TranslateAcceleratorSB */ -HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_TranslateAcceleratorSB(IShellBrowser *iface, LPMSG lpmsg, WORD wID) @@ -716,7 +723,7 @@ /*************************************************************************** * IShellBrowserImpl_ICommDlgBrowser_QueryInterface */ -HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface( +static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_QueryInterface( ICommDlgBrowser *iface, REFIID riid, LPVOID *ppvObj) @@ -731,7 +738,7 @@ /************************************************************************** * IShellBrowserImpl_ICommDlgBrowser_AddRef */ -ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface) +static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_AddRef(ICommDlgBrowser * iface) { _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface); @@ -743,7 +750,7 @@ /************************************************************************** * IShellBrowserImpl_ICommDlgBrowser_Release */ -ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface) +static ULONG WINAPI IShellBrowserImpl_ICommDlgBrowser_Release(ICommDlgBrowser * iface) { _ICOM_THIS_FromICommDlgBrowser(IShellBrowser,iface); @@ -751,12 +758,13 @@ return IShellBrowserImpl_Release(This); } + /************************************************************************** * IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand * * Called when a user double-clicks in the view or presses the ENTER key */ -HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDlgBrowser *iface, IShellView *ppshv) { LPITEMIDLIST pidl; @@ -799,7 +807,7 @@ /************************************************************************** * IShellBrowserImpl_ICommDlgBrowser_OnStateChange */ -HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnStateChange(ICommDlgBrowser *iface, IShellView *ppshv, ULONG uChange) { @@ -838,7 +846,7 @@ /************************************************************************** * IShellBrowserImpl_ICommDlgBrowser_IncludeObject */ -HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, +static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBrowser *iface, IShellView * ppshv, LPCITEMIDLIST pidl) { @@ -883,7 +891,7 @@ /************************************************************************** * IShellBrowserImpl_ICommDlgBrowser_OnSelChange */ -HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv) +static HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *iface, IShellView *ppshv) { FileOpenDlgInfos *fodInfos; @@ -929,7 +937,7 @@ /*************************************************************************** * IShellBrowserImpl_IServiceProvider_QueryInterface */ -HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface( +static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryInterface( IServiceProvider *iface, REFIID riid, LPVOID *ppvObj) @@ -944,7 +952,7 @@ /************************************************************************** * IShellBrowserImpl_IServiceProvider_AddRef */ -ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface) +static ULONG WINAPI IShellBrowserImpl_IServiceProvider_AddRef(IServiceProvider * iface) { _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface); @@ -956,7 +964,7 @@ /************************************************************************** * IShellBrowserImpl_IServiceProvider_Release */ -ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface) +static ULONG WINAPI IShellBrowserImpl_IServiceProvider_Release(IServiceProvider * iface) { _ICOM_THIS_FromIServiceProvider(IShellBrowser,iface); @@ -976,7 +984,7 @@ * this is a hack! */ -HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService( +static HRESULT WINAPI IShellBrowserImpl_IServiceProvider_QueryService( IServiceProvider * iface, REFGUID guidService, REFIID riid, diff -urN wine-20050628/dlls/commdlg/filetitle.c wine-20050725/dlls/commdlg/filetitle.c --- wine-20050628/dlls/commdlg/filetitle.c 2004-03-12 02:52:11.000000000 +0100 +++ wine-20050725/dlls/commdlg/filetitle.c 2005-06-28 21:19:07.000000000 +0200 @@ -31,6 +31,7 @@ #include "winuser.h" #include "commdlg.h" #include "cdlg.h" +#include "cdlg16.h" #include "wine/unicode.h" #include "wine/debug.h" diff -urN wine-20050628/dlls/commdlg/finddlg.c wine-20050725/dlls/commdlg/finddlg.c --- wine-20050628/dlls/commdlg/finddlg.c 2005-02-15 22:51:07.000000000 +0100 +++ wine-20050725/dlls/commdlg/finddlg.c 2005-06-28 21:19:07.000000000 +0200 @@ -62,7 +62,7 @@ * by a 16 bits application * FIXME : no test was done for the user-provided template cases */ -BOOL FINDDLG_Get16BitsTemplate(LFRPRIVATE lfr) +static BOOL FINDDLG_Get16BitsTemplate(LFRPRIVATE lfr) { LPFINDREPLACE16 fr16 = lfr->fr16; @@ -150,7 +150,7 @@ * * Free resources allocated */ -void FINDDLG_FreeResources(LFRPRIVATE lfr) +static void FINDDLG_FreeResources(LFRPRIVATE lfr) { /* free resources */ if (lfr->fr16->Flags & FR_ENABLETEMPLATEHANDLE) diff -urN wine-20050628/dlls/commdlg/fontdlg.c wine-20050725/dlls/commdlg/fontdlg.c --- wine-20050628/dlls/commdlg/fontdlg.c 2005-05-13 19:50:26.000000000 +0200 +++ wine-20050725/dlls/commdlg/fontdlg.c 2005-07-05 16:11:04.000000000 +0200 @@ -427,7 +427,7 @@ /************************************************************************* * CFn_GetDC [internal] */ -inline HDC CFn_GetDC(LPCHOOSEFONTW lpcf) +static inline HDC CFn_GetDC(LPCHOOSEFONTW lpcf) { HDC ret = ((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC) ? lpcf->hDC : @@ -439,7 +439,7 @@ /************************************************************************* * CFn_ReleaseDC [internal] */ -inline void CFn_ReleaseDC(LPCHOOSEFONTW lpcf, HDC hdc) +static inline void CFn_ReleaseDC(LPCHOOSEFONTW lpcf, HDC hdc) { if(!((lpcf->Flags & CF_PRINTERFONTS) && lpcf->hDC)) ReleaseDC(0, hdc); @@ -722,11 +722,13 @@ HFONT hfontprev; TEXTMETRICW tm; LPMEASUREITEMSTRUCT lpmi=(LPMEASUREITEMSTRUCT)lParam; + INT height = 0; + if (!himlTT) himlTT = ImageList_LoadImageW( COMDLG32_hInstance, MAKEINTRESOURCEW(38), TTBITMAP_XSIZE, 0, CLR_DEFAULT, IMAGE_BITMAP, 0); - ImageList_GetIconSize( himlTT, 0, &lpmi->itemHeight); - lpmi->itemHeight += 2; + ImageList_GetIconSize( himlTT, 0, &height); + lpmi->itemHeight = height + 2; /* use MAX of bitmap height and tm.tmHeight .*/ hdc=GetDC(hDlg); if(!hdc) return 0; @@ -1021,7 +1023,7 @@ return(FALSE); } -LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam, LPCHOOSEFONTW lpcfw) +static LRESULT CFn_WMDestroy(HWND hwnd, WPARAM wParam, LPARAM lParam, LPCHOOSEFONTW lpcfw) { LPCHOOSEFONTA lpcfa; LPSTR lpszStyle; diff -urN wine-20050628/dlls/commdlg/fontdlg16.c wine-20050725/dlls/commdlg/fontdlg16.c --- wine-20050628/dlls/commdlg/fontdlg16.c 2005-02-15 22:51:07.000000000 +0100 +++ wine-20050725/dlls/commdlg/fontdlg16.c 2005-07-05 16:11:04.000000000 +0200 @@ -74,14 +74,14 @@ int len; if(chf16->lpTemplateName) { - len = MultiByteToWideChar(CP_ACP, 0, (LPBYTE)chf16->lpTemplateName, -1, NULL, 0); + len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)chf16->lpTemplateName, -1, NULL, 0); chf32w->lpTemplateName = HeapAlloc(GetProcessHeap(), 0,len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, (LPSTR)MapSL(chf16->lpTemplateName), -1, (LPWSTR)chf32w->lpTemplateName, len); } if(chf16->lpszStyle) { - len = MultiByteToWideChar(CP_ACP, 0, (LPBYTE)chf16->lpszStyle, -1, NULL, 0); + len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)chf16->lpszStyle, -1, NULL, 0); chf32w->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, (LPSTR)MapSL(chf16->lpTemplateName), -1, chf32w->lpszStyle, len); diff -urN wine-20050628/dlls/commdlg/printdlg.c wine-20050725/dlls/commdlg/printdlg.c --- wine-20050628/dlls/commdlg/printdlg.c 2005-06-23 18:45:39.000000000 +0200 +++ wine-20050725/dlls/commdlg/printdlg.c 2005-07-07 20:23:45.000000000 +0200 @@ -120,6 +120,8 @@ EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)pi, needed, &needed, &num); + SendDlgItemMessageA(hDlg, id, CB_RESETCONTENT, 0, 0); + for(i = 0; i < num; i++) { SendDlgItemMessageA(hDlg, id, CB_ADDSTRING, 0, (LPARAM)pi[i].pPrinterName ); @@ -432,14 +434,14 @@ } static BOOL PRINTDLG_PaperSizeA( - PRINTDLGA *pdlga,const char *PaperSize,LPPOINT size + PRINTDLGA *pdlga,const WORD PaperSize,LPPOINT size ) { DEVNAMES *dn; DEVMODEA *dm; LPSTR devname,portname; int i; INT NrOfEntries,ret; - char *Names = NULL; + WORD *Words = NULL; POINT *points = NULL; BOOL retval = FALSE; @@ -459,21 +461,21 @@ goto out; } - Names = HeapAlloc(GetProcessHeap(),0,NrOfEntries*64); - if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,Names,dm))) { + Words = HeapAlloc(GetProcessHeap(),0,NrOfEntries*sizeof(WORD)); + if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERS,(LPSTR)Words,dm))) { FIXME("Number of returned vals %d is not %d\n",NrOfEntries,ret); goto out; } for (i=0;ihDevNames); GlobalUnlock(pdlga->hDevMode); - HeapFree(GetProcessHeap(),0,Names); + HeapFree(GetProcessHeap(),0,Words); HeapFree(GetProcessHeap(),0,points); return retval; } @@ -898,7 +900,7 @@ dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL, DM_OUT_BUFFER); if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) && - !strcmp(lpdm->dmDeviceName, + !lstrcmpA(lpdm->dmDeviceName, PrintStructures->lpDevMode->dmDeviceName)) { /* Supplied devicemode matches current printer so try to use it */ DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm, @@ -1241,7 +1243,7 @@ if(pdn) name = (char*)pdn + pdn->wDeviceOffset; else if(pdm) - name = pdm->dmDeviceName; + name = (char*)pdm->dmDeviceName; PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name); if(pdm) GlobalUnlock(lppd->hDevMode); if(pdn) GlobalUnlock(lppd->hDevNames); @@ -1936,20 +1938,21 @@ * * Displays the the PRINT dialog box, which enables the user to specify * specific properties of the print job. - * + * + * PARAMS + * lppd [IO] ptr to PRINTDLG32 struct + * * RETURNS * nonzero if the user pressed the OK button * zero if the user cancelled the window or an error occurred - * + * * BUGS * PrintDlg: * * The Collate Icons do not display, even though they are in the code. * * The Properties Button(s) should call DocumentPropertiesA(). */ -BOOL WINAPI PrintDlgA( - LPPRINTDLGA lppd /* [in/out] ptr to PRINTDLG32 struct */ - ) +BOOL WINAPI PrintDlgA(LPPRINTDLGA lppd) { BOOL bRet = FALSE; LPVOID ptr; @@ -2272,8 +2275,11 @@ */ typedef struct { - LPPAGESETUPDLGA dlga; + LPPAGESETUPDLGA dlga; /* Handler to user defined struct */ PRINTDLGA pdlg; + HWND hDlg; /* Page Setup dialog handler */ + PAGESETUPDLGA curdlg; /* Struct means cerrent dialog state */ + RECT rtDrawRect; /* Drawing rect for page */ } PageSetupDataA; typedef struct { @@ -2281,11 +2287,12 @@ PRINTDLGW pdlg; } PageSetupDataW; + static HGLOBAL PRINTDLG_GetPGSTemplateA(PAGESETUPDLGA *lppd) { HRSRC hResInfo; HGLOBAL hDlgTmpl; - + if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATEHANDLE) { hDlgTmpl = lppd->hPageSetupTemplate; } else if(lppd->Flags & PSD_ENABLEPAGESETUPTEMPLATE) { @@ -2320,7 +2327,7 @@ static DWORD _c_10mm2size(PAGESETUPDLGA *dlga,DWORD size) { if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) - return 10*size*10/25.4; + return 10*size*100/254; /* If we don't have a flag, we can choose one. Use millimeters * to avoid confusing me */ @@ -2334,27 +2341,27 @@ if (dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) return size; if (dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) - return (size*254)/10; + return (size*254)/100; /* if we don't have a flag, we can choose one. Use millimeters * to avoid confusing me */ dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; - return (size*254)/10; + return (size*254)/100; } static void _c_size2strA(PageSetupDataA *pda,DWORD size,LPSTR strout) { strcpy(strout,""); if (pda->dlga->Flags & PSD_INHUNDREDTHSOFMILLIMETERS) { - sprintf(strout,"%.2fmm",(size*1.0)/100.0); + sprintf(strout,"%ld",(size)/100); return; } if (pda->dlga->Flags & PSD_INTHOUSANDTHSOFINCHES) { - sprintf(strout,"%.2fin",(size*1.0)/1000.0); + sprintf(strout,"%ldin",(size)/1000); return; } pda->dlga->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS; - sprintf(strout,"%.2fmm",(size*1.0)/100.0); + sprintf(strout,"%ld",(size)/100); return; } static void @@ -2427,47 +2434,46 @@ } -/* - * This is called on finish and will update the output fields of the - * struct. +/**************************************************************************** + * PRINTDLG_PS_UpdateDlgStructA + * + * Updates pda->dlga structure + * Function calls when user presses OK button + * + * PARAMS + * hDlg [in] main window dialog HANDLE + * pda [in/out] ptr to PageSetupDataA structere + * + * RETURNS + * TRUE */ static BOOL PRINTDLG_PS_UpdateDlgStructA(HWND hDlg, PageSetupDataA *pda) { DEVNAMES *dn; DEVMODEA *dm; - LPSTR devname,portname; - char papername[64]; - char buf[200]; + DWORD paperword; + memcpy(pda->dlga, &pda->curdlg, sizeof(pda->curdlg)); + pda->dlga->hDevMode = pda->pdlg.hDevMode; + pda->dlga->hDevNames = pda->pdlg.hDevNames; + dn = GlobalLock(pda->pdlg.hDevNames); dm = GlobalLock(pda->pdlg.hDevMode); - devname = ((char*)dn)+dn->wDeviceOffset; - portname = ((char*)dn)+dn->wOutputOffset; - PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb2,devname,portname,dm); - PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb3,devname,portname,dm); - - if (GetDlgItemTextA(hDlg,cmb2,papername,sizeof(papername))>0) { - PRINTDLG_PaperSizeA(&(pda->pdlg),papername,&(pda->dlga->ptPaperSize)); - pda->dlga->ptPaperSize.x = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.x); - pda->dlga->ptPaperSize.y = _c_10mm2size(pda->dlga,pda->dlga->ptPaperSize.y); - } else + if(pda->curdlg.ptPaperSize.x > pda->curdlg.ptPaperSize.y) + dm->u1.s1.dmOrientation = DMORIENT_LANDSCAPE; + else + dm->u1.s1.dmOrientation = DMORIENT_PORTRAIT; + + paperword = SendDlgItemMessageA(hDlg,cmb2,CB_GETITEMDATA, + SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0), 0); + if (paperword != CB_ERR) + dm->u1.s1.dmPaperSize = paperword; + else FIXME("could not get dialog text for papersize cmbbox?\n"); -#define GETVAL(id,val) if (GetDlgItemTextA(hDlg,id,buf,sizeof(buf))>0) { val = _c_str2sizeA(pda->dlga,buf); } else { FIXME("could not get dlgitemtexta for %x\n",id); } - GETVAL(edt4,pda->dlga->rtMargin.left); - GETVAL(edt5,pda->dlga->rtMargin.top); - GETVAL(edt6,pda->dlga->rtMargin.right); - GETVAL(edt7,pda->dlga->rtMargin.bottom); -#undef GETVAL - - /* If we are in landscape, swap x and y of page size */ - if (IsDlgButtonChecked(hDlg, rad2)) { - DWORD tmp; - tmp = pda->dlga->ptPaperSize.x; - pda->dlga->ptPaperSize.x = pda->dlga->ptPaperSize.y; - pda->dlga->ptPaperSize.y = tmp; - } + GlobalUnlock(pda->pdlg.hDevNames); GlobalUnlock(pda->pdlg.hDevMode); + return TRUE; } @@ -2511,19 +2517,87 @@ return TRUE; } -/* - * This is called after returning from PrintDlg(). +/********************************************************************************************** + * PRINTDLG_PS_ChangeActivePrinerA + * + * Redefines hDevMode and hDevNames HANDLES and initialises it. + * + * PARAMS + * name [in] Name of a printer for activation + * pda [in/out] ptr to PageSetupDataA structure + * + * RETURN + * TRUE if success + * FALSE if fail + */ +static BOOL +PRINTDLG_PS_ChangeActivePrinterA(LPSTR name, PageSetupDataA *pda){ + HANDLE hprn; + DWORD needed; + LPPRINTER_INFO_2A lpPrinterInfo; + LPDRIVER_INFO_3A lpDriverInfo; + DEVMODEA *pDevMode, *dm; + + if(!OpenPrinterA(name, &hprn, NULL)){ + ERR("Can't open printer %s\n", name); + return FALSE; + } + GetPrinterA(hprn, 2, NULL, 0, &needed); + lpPrinterInfo = HeapAlloc(GetProcessHeap(), 0, needed); + GetPrinterA(hprn, 2, (LPBYTE)lpPrinterInfo, needed, &needed); + GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed); + lpDriverInfo = HeapAlloc(GetProcessHeap(), 0, needed); + if(!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)lpDriverInfo, needed, &needed)) { + ERR("GetPrinterDriverA failed for %s, fix your config!\n", lpPrinterInfo->pPrinterName); + return FALSE; + } + ClosePrinter(hprn); + + needed = DocumentPropertiesA(0, 0, name, NULL, NULL, 0); + if(needed == -1) { + ERR("DocumentProperties fails on %s\n", debugstr_a(name)); + return FALSE; + } + pDevMode = HeapAlloc(GetProcessHeap(), 0, needed); + DocumentPropertiesA(0, 0, name, pDevMode, NULL, DM_OUT_BUFFER); + + pda->pdlg.hDevMode = GlobalReAlloc(pda->pdlg.hDevMode, + pDevMode->dmSize + pDevMode->dmDriverExtra, + GMEM_MOVEABLE); + dm = GlobalLock(pda->pdlg.hDevMode); + memcpy(dm, pDevMode, pDevMode->dmSize + pDevMode->dmDriverExtra); + + PRINTDLG_CreateDevNames(&(pda->pdlg.hDevNames), + lpDriverInfo->pDriverPath, + lpPrinterInfo->pPrinterName, + lpPrinterInfo->pPortName); + + GlobalUnlock(pda->pdlg.hDevMode); + HeapFree(GetProcessHeap(), 0, pDevMode); + HeapFree(GetProcessHeap(), 0, lpPrinterInfo); + HeapFree(GetProcessHeap(), 0, lpDriverInfo); + return TRUE; +} + +/**************************************************************************************** + * PRINTDLG_PS_ChangePrinterA + * + * Fills Printers, Paper and Source combo + * + * RETURNS + * TRUE */ static BOOL PRINTDLG_PS_ChangePrinterA(HWND hDlg, PageSetupDataA *pda) { DEVNAMES *dn; DEVMODEA *dm; LPSTR devname,portname; - + dn = GlobalLock(pda->pdlg.hDevNames); dm = GlobalLock(pda->pdlg.hDevMode); - devname = ((char*)dn)+dn->wDeviceOffset; + devname = ((char*)dn)+dn->wDeviceOffset; portname = ((char*)dn)+dn->wOutputOffset; + PRINTDLG_SetUpPrinterListComboA(hDlg, cmb1, devname); PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb2,devname,portname,dm); PRINTDLG_SetUpPaperComboBoxA(hDlg,cmb3,devname,portname,dm); GlobalUnlock(pda->pdlg.hDevNames); @@ -2548,13 +2622,79 @@ return TRUE; } +/****************************************************************************************** + * PRINTDLG_PS_ChangePaperPrev + * + * Changes paper preview size / position + * + * PARAMS: + * pda [i] Pointer for current PageSetupDataA structure + * + * RETURNS: + * always - TRUE + */ +static BOOL +PRINTDLG_PS_ChangePaperPrev(PageSetupDataA *pda) +{ + LONG width, height, x, y; + RECT rtTmp; + + if(pda->curdlg.ptPaperSize.x > pda->curdlg.ptPaperSize.y) { + width = pda->rtDrawRect.right - pda->rtDrawRect.left; + height = pda->curdlg.ptPaperSize.y * width / pda->curdlg.ptPaperSize.x; + } else { + height = pda->rtDrawRect.bottom - pda->rtDrawRect.top; + width = pda->curdlg.ptPaperSize.x * height / pda->curdlg.ptPaperSize.y; + } + x = (pda->rtDrawRect.right + pda->rtDrawRect.left - width) / 2; + y = (pda->rtDrawRect.bottom + pda->rtDrawRect.top - height) / 2; + TRACE("rtDrawRect(%ld, %ld, %ld, %ld) x=%ld, y=%ld, w=%ld, h=%ld", + pda->rtDrawRect.left, pda->rtDrawRect.top, pda->rtDrawRect.right, pda->rtDrawRect.bottom, + x, y, width, height); + +#define SHADOW 4 + MoveWindow(GetDlgItem(pda->hDlg, rct2), x+width, y+SHADOW, SHADOW, height, FALSE); + MoveWindow(GetDlgItem(pda->hDlg, rct3), x+SHADOW, y+height, width, SHADOW, FALSE); + MoveWindow(GetDlgItem(pda->hDlg, rct1), x, y, width, height, FALSE); + memcpy(&rtTmp, &pda->rtDrawRect, sizeof(RECT)); + rtTmp.right += SHADOW; + rtTmp.bottom += SHADOW; +#undef SHADOW + + InvalidateRect(pda->hDlg, &rtTmp, TRUE); + return TRUE; +} + +#define GETVAL(idc,val) \ +if(msg == EN_CHANGE){ \ + if (GetDlgItemTextA(hDlg,idc,buf,sizeof(buf)) > 0)\ + val = _c_str2sizeA(pda->dlga,buf); \ + else\ + FIXME("could not get dlgitemtexta for %x\n",id); \ +} + +/******************************************************************************** + * PRINTDLG_PS_WMCommandA + * process WM_COMMAND message for PageSetupDlgA + * + * PARAMS + * hDlg [in] Main dialog HANDLE + * wParam [in] WM_COMMAND wParam + * lParam [in] WM_COMMAND lParam + * pda [in/out] ptr to PageSetupDataA + */ + static BOOL PRINTDLG_PS_WMCommandA( HWND hDlg, WPARAM wParam, LPARAM lParam, PageSetupDataA *pda ) { + WORD msg = HIWORD(wParam); + WORD id = LOWORD(wParam); + char buf[200]; + TRACE("loword (lparam) %d, wparam 0x%x, lparam %08lx\n", LOWORD(lParam),wParam,lParam); - switch (LOWORD(wParam)) { + switch (id) { case IDOK: if (!PRINTDLG_PS_UpdateDlgStructA(hDlg, pda)) return(FALSE); @@ -2570,11 +2710,121 @@ pda->pdlg.hwndOwner = hDlg; if (PrintDlgA(&(pda->pdlg))) PRINTDLG_PS_ChangePrinterA(hDlg,pda); + } return TRUE; + case rad1: + if (pda->curdlg.ptPaperSize.x > pda->curdlg.ptPaperSize.y){ + DWORD tmp = pda->curdlg.ptPaperSize.x; + pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y; + pda->curdlg.ptPaperSize.y = tmp; + } + PRINTDLG_PS_ChangePaperPrev(pda); + break; + case rad2: + if (pda->curdlg.ptPaperSize.y > pda->curdlg.ptPaperSize.x){ + DWORD tmp = pda->curdlg.ptPaperSize.x; + pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y; + pda->curdlg.ptPaperSize.y = tmp; + } + PRINTDLG_PS_ChangePaperPrev(pda); + break; + case cmb1: /* Printer combo */ + if(msg == CBN_SELCHANGE){ + char crPrinterName[256]; + GetDlgItemTextA(hDlg, id, crPrinterName, 255); + PRINTDLG_PS_ChangeActivePrinterA(crPrinterName, pda); + PRINTDLG_PS_ChangePrinterA(hDlg, pda); + } + break; + case cmb2: /* Paper combo */ + if(msg == CBN_SELCHANGE){ + DWORD paperword = SendDlgItemMessageA(hDlg,cmb2,CB_GETITEMDATA, + SendDlgItemMessageA(hDlg, cmb2, CB_GETCURSEL, 0, 0), 0); + if (paperword != CB_ERR) { + PRINTDLG_PaperSizeA(&(pda->pdlg), paperword,&(pda->curdlg.ptPaperSize)); + pda->curdlg.ptPaperSize.x = _c_10mm2size(pda->dlga,pda->curdlg.ptPaperSize.x); + pda->curdlg.ptPaperSize.y = _c_10mm2size(pda->dlga,pda->curdlg.ptPaperSize.y); + + if (IsDlgButtonChecked(hDlg, rad2)) { + DWORD tmp = pda->curdlg.ptPaperSize.x; + pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y; + pda->curdlg.ptPaperSize.y = tmp; + } + PRINTDLG_PS_ChangePaperPrev(pda); + } else + FIXME("could not get dialog text for papersize cmbbox?\n"); + } + break; + case cmb3: + if(msg == CBN_SELCHANGE){ + DEVMODEA *dm = GlobalLock(pda->pdlg.hDevMode); + dm->dmDefaultSource = SendDlgItemMessageA(hDlg, cmb3,CB_GETITEMDATA, + SendDlgItemMessageA(hDlg, cmb3, CB_GETCURSEL, 0, 0), 0); + GlobalUnlock(pda->pdlg.hDevMode); + } + break; + case psh2: /* Printer Properties button */ + { + HANDLE hPrinter; + char PrinterName[256]; + DEVMODEA *dm; + LRESULT count; + int i; + + GetDlgItemTextA(hDlg, cmb1, PrinterName, 255); + if (!OpenPrinterA(PrinterName, &hPrinter, NULL)) { + FIXME("Call to OpenPrinter did not succeed!\n"); + break; + } + dm = GlobalLock(pda->pdlg.hDevMode); + DocumentPropertiesA(hDlg, hPrinter, PrinterName, dm, dm, + DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT); + ClosePrinter(hPrinter); + /* Changing paper */ + PRINTDLG_PaperSizeA(&(pda->pdlg), dm->u1.s1.dmPaperSize, &(pda->curdlg.ptPaperSize)); + pda->curdlg.ptPaperSize.x = _c_10mm2size(pda->dlga, pda->curdlg.ptPaperSize.x); + pda->curdlg.ptPaperSize.y = _c_10mm2size(pda->dlga, pda->curdlg.ptPaperSize.y); + if (dm->u1.s1.dmOrientation == DMORIENT_LANDSCAPE){ + DWORD tmp = pda->curdlg.ptPaperSize.x; + pda->curdlg.ptPaperSize.x = pda->curdlg.ptPaperSize.y; + pda->curdlg.ptPaperSize.y = tmp; + CheckRadioButton(hDlg, rad1, rad2, rad2); + } + else + CheckRadioButton(hDlg, rad1, rad2, rad1); + /* Changing paper preview */ + PRINTDLG_PS_ChangePaperPrev(pda); + /* Selecting paper in combo */ + count = SendDlgItemMessageA(hDlg, cmb2, CB_GETCOUNT, 0, 0); + if(count != CB_ERR){ + for(i=0; iu1.s1.dmPaperSize) { + SendDlgItemMessageA(hDlg, cmb2, CB_SETCURSEL, i, 0); + break; + } + } + } + + GlobalUnlock(pda->pdlg.hDevMode); + break; + } + case edt4: + GETVAL(id, pda->curdlg.rtMargin.left); + break; + case edt5: + GETVAL(id, pda->curdlg.rtMargin.right); + break; + case edt6: + GETVAL(id, pda->curdlg.rtMargin.top); + break; + case edt7: + GETVAL(id, pda->curdlg.rtMargin.bottom); + break; } - } + InvalidateRect(GetDlgItem(hDlg, rct1), NULL, TRUE); return FALSE; } +#undef GETVAL static BOOL PRINTDLG_PS_WMCommandW( @@ -2621,7 +2871,6 @@ HFONT hfont, holdfont; INT oldbkmode; TRACE("uMsg: WM_USER+%d\n",uMsg-WM_USER); - /* Call user paint hook if enable */ if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) if (pda->dlga->lpfnPagePaintHook(hwndDlg, uMsg, wParam, lParam)) @@ -2643,8 +2892,6 @@ Rectangle(hdc, lprc->left, lprc->top, lprc->right, lprc->bottom); DeleteObject(SelectObject(hdc, holdpen)); return TRUE; - - /* Draw the fake document */ case WM_PSD_GREEKTEXTRECT: /* select a nice scalable font, because we want the text really small */ @@ -2710,6 +2957,8 @@ * FALSE if all done correctly * */ + + static LRESULT CALLBACK PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -2720,7 +2969,7 @@ HBRUSH hbrush, holdbrush; PageSetupDataA *pda; int papersize=0, orientation=0; /* FIXME: set this values */ - + double scalx, scaly; #define CALLPAINTHOOK(msg,lprc) PRINTDLG_DefaultPagePaintHook( hWnd, msg, (WPARAM)hdc, (LPARAM)lprc, pda) if (uMsg != WM_PAINT) @@ -2737,14 +2986,16 @@ hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &rcClient); - - /* FIXME: use real margin values */ + + scalx = rcClient.right / (double)pda->curdlg.ptPaperSize.x; + scaly = rcClient.bottom / (double)pda->curdlg.ptPaperSize.y; rcMargin = rcClient; - rcMargin.left += 5; - rcMargin.top += 5; - rcMargin.right -= 5; - rcMargin.bottom -= 5; - + + rcMargin.left += (LONG)pda->curdlg.rtMargin.left * scalx; + rcMargin.top += (LONG)pda->curdlg.rtMargin.top * scalx; + rcMargin.right -= (LONG)pda->curdlg.rtMargin.right * scaly; + rcMargin.bottom -= (LONG)pda->curdlg.rtMargin.bottom * scaly; + /* if the space is too small then we make sure to not draw anything */ rcMargin.left = min(rcMargin.left, rcMargin.right); rcMargin.top = min(rcMargin.top, rcMargin.bottom); @@ -2759,7 +3010,6 @@ hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); holdpen = SelectObject(hdc, hpen); - /* paint left edge */ MoveToEx(hdc, rcClient.left, rcClient.top, NULL); @@ -2783,10 +3033,8 @@ DeleteObject(SelectObject(hdc, holdpen)); DeleteObject(SelectObject(hdc, holdbrush)); - CALLPAINTHOOK(WM_PSD_MARGINRECT, &rcMargin); - /* give text a bit of a space from the frame */ rcMargin.left += 2; rcMargin.top += 2; @@ -2807,23 +3055,34 @@ /*********************************************************************** * PRINTDLG_PageDlgProcA - * Message handler + * Message handler for PageSetupDlgA */ static INT_PTR CALLBACK PRINTDLG_PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + DEVMODEA *dm; PageSetupDataA *pda; INT_PTR res = FALSE; + HWND hDrawWnd; - if (uMsg == WM_INITDIALOG) { + if (uMsg == WM_INITDIALOG) { /*Init dialog*/ pda = (PageSetupDataA*)lParam; + pda->hDlg = hDlg; /* saving handle to main window to PageSetupDataA structure */ + memcpy(&pda->curdlg, pda->dlga, sizeof(pda->curdlg)); + + hDrawWnd = GetDlgItem(hDlg, rct1); TRACE("set property to %p", pda); - SetPropA(hDlg, "__WINE_PAGESETUPDLGDATA", pda); - SetPropA(GetDlgItem(hDlg, rct1), "__WINE_PAGESETUPDLGDATA", pda); + SetPropA(hDlg, "__WINE_PAGESETUPDLGDATA", pda); + SetPropA(hDrawWnd, "__WINE_PAGESETUPDLGDATA", pda); + GetWindowRect(hDrawWnd, &pda->rtDrawRect); /* Calculating rect in client coordinates where paper draws */ + ScreenToClient(hDlg, (LPPOINT)&pda->rtDrawRect); + ScreenToClient(hDlg, (LPPOINT)(&pda->rtDrawRect.right)); lpfnStaticWndProc = (WNDPROC)SetWindowLongPtrW( - GetDlgItem(hDlg, rct1), + hDrawWnd, GWLP_WNDPROC, (ULONG_PTR)PRINTDLG_PagePaintProc); + + /* FIXME: Paint hook. Must it be at begin of initializtion or at end? */ res = TRUE; if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,(LPARAM)pda->dlga); @@ -2833,8 +3092,10 @@ } } + /* if printer button disabled */ if (pda->dlga->Flags & PSD_DISABLEPRINTER) EnableWindow(GetDlgItem(hDlg, psh3), FALSE); + /* if margin edit boxes disabled */ if (pda->dlga->Flags & PSD_DISABLEMARGINS) { EnableWindow(GetDlgItem(hDlg, edt4), FALSE); EnableWindow(GetDlgItem(hDlg, edt5), FALSE); @@ -2846,6 +3107,7 @@ CheckRadioButton(hDlg, rad1, rad2, rad2); else /* this is default if papersize is not set */ CheckRadioButton(hDlg, rad1, rad2, rad1); + /* if orientation disabled */ if (pda->dlga->Flags & PSD_DISABLEORIENTATION) { EnableWindow(GetDlgItem(hDlg,rad1),FALSE); EnableWindow(GetDlgItem(hDlg,rad2),FALSE); @@ -2870,12 +3132,29 @@ SetDlgItemTextA(hDlg,edt5,str); SetDlgItemTextA(hDlg,edt6,str); SetDlgItemTextA(hDlg,edt7,str); + pda->curdlg.rtMargin.left = size; + pda->curdlg.rtMargin.top = size; + pda->curdlg.rtMargin.right = size; + pda->curdlg.rtMargin.bottom = size; } - PRINTDLG_PS_ChangePrinterA(hDlg,pda); + /* if paper disabled */ if (pda->dlga->Flags & PSD_DISABLEPAPER) { EnableWindow(GetDlgItem(hDlg,cmb2),FALSE); EnableWindow(GetDlgItem(hDlg,cmb3),FALSE); } + /* filling combos: printer, paper, source. selecting current printer (from DEVMODEA) */ + PRINTDLG_PS_ChangePrinterA(hDlg, pda); + dm = GlobalLock(pda->pdlg.hDevMode); + if(dm){ + dm->dmDefaultSource = 15; /*FIXME: Automatic select. Does it always 15 at start? */ + PRINTDLG_PaperSizeA(&(pda->pdlg), dm->u1.s1.dmPaperSize, &pda->curdlg.ptPaperSize); + GlobalUnlock(pda->pdlg.hDevMode); + pda->curdlg.ptPaperSize.x = _c_10mm2size(pda->dlga, pda->curdlg.ptPaperSize.x); + pda->curdlg.ptPaperSize.y = _c_10mm2size(pda->dlga, pda->curdlg.ptPaperSize.y); + } else + WARN("GlobalLock(pda->pdlg.hDevMode) fail? hDevMode=%ld", (DWORD)pda->pdlg.hDevMode); + /* Drawing paper prev */ + PRINTDLG_PS_ChangePaperPrev(pda); return TRUE; } else { pda = (PageSetupDataA*)GetPropA(hDlg,"__WINE_PAGESETUPDLGDATA"); @@ -2915,6 +3194,7 @@ res = TRUE; } } + if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) { FIXME("PagePaintHook not yet implemented!\n"); } @@ -2961,6 +3241,7 @@ EnableWindow(GetDlgItem(hDlg,cmb2),FALSE); EnableWindow(GetDlgItem(hDlg,cmb3),FALSE); } + return TRUE; } else { pda = (PageSetupDataW*)GetPropW(hDlg, __WINE_PAGESETUPDLGDATA); @@ -2988,7 +3269,7 @@ * size, source, orientation and the width of the page margins. * * PARAMS - * setupdlg [in] PAGESETUPDLGA struct + * setupdlg [IO] PAGESETUPDLGA struct * * RETURNS * TRUE if the user pressed the OK button @@ -2997,12 +3278,7 @@ * NOTES * The values of hDevMode and hDevNames are filled on output and can be * changed in PAGESETUPDLG when they are passed in PageSetupDlg. - * BUGS - * PrintSetupDlg: - * * The Paper Orientation Icons are not implemented yet. - * * The Properties Button(s) should call DocumentPropertiesA(). - * * Settings are not yet taken from a provided DevMode or - * default printer settings. + * */ BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) { @@ -3012,6 +3288,7 @@ PageSetupDataA *pda; PRINTDLGA pdlg; + /* TRACE */ if(TRACE_ON(commdlg)) { char flagstr[1000] = ""; struct pd_flags *pflag = psd_flags; @@ -3027,8 +3304,17 @@ setupdlg->hDevNames, setupdlg->hInstance, setupdlg->Flags, flagstr); } - if (setupdlg->Flags & PSD_ENABLEPAGEPAINTHOOK) - if (setupdlg->lpfnPagePaintHook == NULL) { + /* Checking setupdlg structure */ + if (setupdlg == NULL) { + COMDLG32_SetCommDlgExtendedError(CDERR_INITIALIZATION); + return FALSE; + } + if(setupdlg->lStructSize != sizeof(PAGESETUPDLGA)) { + COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE); + return FALSE; + } + if ((setupdlg->Flags & PSD_ENABLEPAGEPAINTHOOK) && + (setupdlg->lpfnPagePaintHook == NULL)) { COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK); return FALSE; } @@ -3038,18 +3324,28 @@ pdlg.lStructSize = sizeof(pdlg); pdlg.Flags = PD_RETURNDEFAULT; bRet = PrintDlgA(&pdlg); - if (!bRet) return FALSE; - + if (!bRet){ + if(!(setupdlg->Flags & PSD_NOWARNING)){ + char errstr[256]; + LoadStringA(COMDLG32_hInstance, PD32_NO_DEFAULT_PRINTER, errstr, 255); + MessageBoxA(setupdlg->hwndOwner, errstr, 0, MB_OK | MB_ICONERROR); + } + return FALSE; + } + /* short cut exit, just return default values */ if (setupdlg->Flags & PSD_RETURNDEFAULT) { - setupdlg->hDevMode = pdlg.hDevMode; - setupdlg->hDevNames = pdlg.hDevNames; - /* FIXME: Just return "A4" for now. */ - PRINTDLG_PaperSizeA(&pdlg,"A4",&setupdlg->ptPaperSize); + DEVMODEA *dm; + + dm = GlobalLock(pdlg.hDevMode); + PRINTDLG_PaperSizeA(&pdlg, dm->u1.s1.dmPaperSize, &setupdlg->ptPaperSize); + GlobalUnlock(pdlg.hDevMode); setupdlg->ptPaperSize.x=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.x); setupdlg->ptPaperSize.y=_c_10mm2size(setupdlg,setupdlg->ptPaperSize.y); return TRUE; } + + /* get dialog template */ hDlgTmpl = PRINTDLG_GetPGSTemplateA(setupdlg); if (!hDlgTmpl) { COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); @@ -3060,6 +3356,7 @@ COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE); return FALSE; } + pda = HeapAlloc(GetProcessHeap(),0,sizeof(*pda)); pda->dlga = setupdlg; memcpy(&pda->pdlg,&pdlg,sizeof(pdlg)); @@ -3071,6 +3368,8 @@ PRINTDLG_PageDlgProcA, (LPARAM)pda) ); + + HeapFree(GetProcessHeap(),0,pda); return bRet; } /*********************************************************************** @@ -3082,6 +3381,7 @@ BOOL bRet; PageSetupDataW *pdw; PRINTDLGW pdlg; + FIXME("Unicode implementation is not done yet\n"); if(TRACE_ON(commdlg)) { char flagstr[1000] = ""; diff -urN wine-20050628/dlls/commdlg/printdlg16.c wine-20050725/dlls/commdlg/printdlg16.c --- wine-20050628/dlls/commdlg/printdlg16.c 2005-03-24 22:01:39.000000000 +0100 +++ wine-20050725/dlls/commdlg/printdlg16.c 2005-07-05 16:11:04.000000000 +0200 @@ -192,7 +192,7 @@ if(pdn) name = (char*)pdn + pdn->wDeviceOffset; else if(pdm) - name = pdm->dmDeviceName; + name = (char*)pdm->dmDeviceName; PRINTDLG_SetUpPrinterListComboA(hDlg, comboID, name); if(pdm) GlobalUnlock16(lppd->hDevMode); if(pdn) GlobalUnlock16(lppd->hDevNames); diff -urN wine-20050628/dlls/crypt32/cert.c wine-20050725/dlls/crypt32/cert.c --- wine-20050628/dlls/crypt32/cert.c 2005-06-03 13:25:38.000000000 +0200 +++ wine-20050725/dlls/crypt32/cert.c 2005-07-07 22:27:55.000000000 +0200 @@ -178,3 +178,92 @@ SetLastError(CRYPT_E_NOT_FOUND); return NULL; } + +PCRYPT_ATTRIBUTE WINAPI CertFindAttribute(LPCSTR pszObjId, DWORD cAttr, + CRYPT_ATTRIBUTE rgAttr[]) +{ + PCRYPT_ATTRIBUTE ret = NULL; + DWORD i; + + TRACE("%s %ld %p\n", debugstr_a(pszObjId), cAttr, rgAttr); + + if (!cAttr) + return NULL; + if (!pszObjId) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + for (i = 0; !ret && i < cAttr; i++) + if (rgAttr[i].pszObjId && !strcmp(pszObjId, rgAttr[i].pszObjId)) + ret = &rgAttr[i]; + return ret; +} + +PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions, + CERT_EXTENSION rgExtensions[]) +{ + PCERT_EXTENSION ret = NULL; + DWORD i; + + TRACE("%s %ld %p\n", debugstr_a(pszObjId), cExtensions, rgExtensions); + + if (!cExtensions) + return NULL; + if (!pszObjId) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + for (i = 0; !ret && i < cExtensions; i++) + if (rgExtensions[i].pszObjId && !strcmp(pszObjId, + rgExtensions[i].pszObjId)) + ret = &rgExtensions[i]; + return ret; +} + +PCERT_RDN_ATTR WINAPI CertFindRDNAttr(LPCSTR pszObjId, PCERT_NAME_INFO pName) +{ + PCERT_RDN_ATTR ret = NULL; + DWORD i, j; + + TRACE("%s %p\n", debugstr_a(pszObjId), pName); + + if (!pszObjId) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + for (i = 0; !ret && i < pName->cRDN; i++) + for (j = 0; !ret && j < pName->rgRDN[i].cRDNAttr; j++) + if (pName->rgRDN[i].rgRDNAttr[j].pszObjId && !strcmp(pszObjId, + pName->rgRDN[i].rgRDNAttr[j].pszObjId)) + ret = &pName->rgRDN[i].rgRDNAttr[j]; + return ret; +} + +LONG WINAPI CertVerifyTimeValidity(LPFILETIME pTimeToVerify, + PCERT_INFO pCertInfo) +{ + FILETIME fileTime; + LONG ret; + + if (!pTimeToVerify) + { + SYSTEMTIME sysTime; + + GetSystemTime(&sysTime); + SystemTimeToFileTime(&sysTime, &fileTime); + pTimeToVerify = &fileTime; + } + if ((ret = CompareFileTime(pTimeToVerify, &pCertInfo->NotBefore)) >= 0) + { + ret = CompareFileTime(pTimeToVerify, &pCertInfo->NotAfter); + if (ret < 0) + ret = 0; + } + return ret; +} diff -urN wine-20050628/dlls/crypt32/crypt32.spec wine-20050725/dlls/crypt32/crypt32.spec --- wine-20050628/dlls/crypt32/crypt32.spec 2005-06-22 20:38:24.000000000 +0200 +++ wine-20050725/dlls/crypt32/crypt32.spec 2005-07-07 22:27:55.000000000 +0200 @@ -32,11 +32,11 @@ @ stub CertEnumCTLsInStore @ stub CertEnumCertificateContextProperties @ stdcall CertEnumCertificatesInStore(long ptr) -@ stub CertFindAttribute +@ stdcall CertFindAttribute(str long ptr) @ stub CertFindCTLInStore @ stdcall CertFindCertificateInStore(long long long long ptr ptr) -@ stub CertFindExtension -@ stub CertFindRDNAttr +@ stdcall CertFindExtension(str long ptr) +@ stdcall CertFindRDNAttr(str ptr) @ stub CertFindSubjectInCTL @ stdcall CertFreeCRLContext(ptr) @ stub CertFreeCTLContext @@ -78,7 +78,7 @@ @ stub CertVerifyCTLUsage @ stub CertVerifyRevocation @ stub CertVerifySubjectCertificateContext -@ stub CertVerifyTimeValidity +@ stdcall CertVerifyTimeValidity(ptr ptr) @ stub CertVerifyValidityNesting @ stub CreateFileU @ stub CryptAcquireContextU diff -urN wine-20050628/dlls/crypt32/encode.c wine-20050725/dlls/crypt32/encode.c --- wine-20050628/dlls/crypt32/encode.c 2005-06-27 21:48:24.000000000 +0200 +++ wine-20050725/dlls/crypt32/encode.c 2005-07-14 12:14:22.000000000 +0200 @@ -31,6 +31,7 @@ * MSDN, especially: * http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cryptencodeobject_and_cryptdecodeobject.asp */ +#include #include #include #include @@ -43,6 +44,9 @@ #include "wine/debug.h" #include "wine/exception.h" +/* This is a bit arbitrary, but to set some limit: */ +#define MAX_ENCODED_LEN 0x02000000 + /* a few asn.1 tags we need */ #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) @@ -59,16 +63,95 @@ static const WCHAR szDllName[] = { 'D','l','l',0 }; +typedef BOOL (WINAPI *CryptEncodeObjectFunc)(DWORD, LPCSTR, const void *, + BYTE *, DWORD *); +typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *, + DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *); +typedef BOOL (WINAPI *CryptDecodeObjectFunc)(DWORD, LPCSTR, const BYTE *, + DWORD, DWORD, void *, DWORD *); +typedef BOOL (WINAPI *CryptDecodeObjectExFunc)(DWORD, LPCSTR, const BYTE *, + DWORD, DWORD, PCRYPT_DECODE_PARA, void *, DWORD *); + +/* Prototypes for built-in encoders/decoders. They follow the Ex style + * prototypes. The dwCertEncodingType and lpszStructType are ignored by the + * built-in functions, but the parameters are retained to simplify + * CryptEncodeObjectEx/CryptDecodeObjectEx, since they must call functions in + * external DLLs that follow these signatures. + * FIXME: some built-in functions are suitable to be called directly by + * CryptEncodeObjectEx/CryptDecodeObjectEx (they implement exception handling + * and memory allocation if requested), others are only suitable to be called + * internally. Comment which are which. + */ +static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodeExtensions(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodeBool(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodeBits(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodeBitsSwapBytes(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); static BOOL WINAPI CRYPT_AsnEncodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); static BOOL WINAPI CRYPT_AsnEncodeInteger(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodeChoiceOfTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); + +static BOOL WINAPI CRYPT_AsnDecodeChoiceOfTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +static BOOL WINAPI CRYPT_AsnDecodePubKeyInfo(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +static BOOL WINAPI CRYPT_AsnDecodeExtensions(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +static BOOL WINAPI CRYPT_AsnDecodeOid(const BYTE *pbEncoded, DWORD cbEncoded, + DWORD dwFlags, LPSTR pszObjId, DWORD *pcbObjId); +/* Assumes algo->Parameters.pbData is set ahead of time */ +static BOOL WINAPI CRYPT_AsnDecodeAlgorithmId(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +static BOOL WINAPI CRYPT_AsnDecodeBool(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +/* Like CRYPT_AsnDecodeBits, but assumes the CRYPT_INTEGER_BLOB's pbData + * member has been initialized, doesn't do exception handling, and doesn't do + * memory allocation. + */ +static BOOL WINAPI CRYPT_AsnDecodeBitsInternal(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +static BOOL WINAPI CRYPT_AsnDecodeBits(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); -static BOOL WINAPI CRYPT_AsnDecodeInteger(DWORD dwCertEncodingType, +/* Like CRYPT_AsnDecodeInteger, but assumes the CRYPT_INTEGER_BLOB's pbData + * member has been initialized, doesn't do exception handling, and doesn't do + * memory allocation. + */ +static BOOL WINAPI CRYPT_AsnDecodeIntegerInternal(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); @@ -329,9 +412,6 @@ return ret; } -typedef BOOL (WINAPI *CryptEncodeObjectFunc)(DWORD, LPCSTR, const void *, - BYTE *, DWORD *); - BOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded) { @@ -441,307 +521,210 @@ return TRUE; } -static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, - LPCSTR pszObjId, BYTE *pbEncoded, DWORD *pcbEncoded) +struct AsnEncodeSequenceItem { - DWORD bytesNeeded = 0, lenBytes; - BOOL ret = TRUE; - int firstPos = 0; - BYTE firstByte = 0; + const void *pvStructInfo; + CryptEncodeObjectExFunc encodeFunc; + DWORD size; /* used during encoding, not for your use */ +}; - if (pszObjId) +static BOOL WINAPI CRYPT_AsnEncodeSequence(DWORD dwCertEncodingType, + struct AsnEncodeSequenceItem items[], DWORD cItem, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + DWORD i, dataLen = 0; + + TRACE("%p, %ld, %08lx, %p, %p, %ld\n", items, cItem, dwFlags, pEncodePara, + pbEncoded, *pcbEncoded); + for (i = 0, ret = TRUE; ret && i < cItem; i++) + { + ret = items[i].encodeFunc(dwCertEncodingType, NULL, + items[i].pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, + NULL, &items[i].size); + dataLen += items[i].size; + } + if (ret) { - const char *ptr; - int val1, val2; + DWORD lenBytes, bytesNeeded; - if (sscanf(pszObjId, "%d.%d.%n", &val1, &val2, &firstPos) != 2) - { - SetLastError(CRYPT_E_ASN1_ERROR); - return FALSE; - } - bytesNeeded++; - firstByte = val1 * 40 + val2; - ptr = pszObjId + firstPos; - while (ret && *ptr) + CRYPT_EncodeLen(dataLen, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + dataLen; + if (!pbEncoded) + *pcbEncoded = bytesNeeded; + else { - int pos; - - /* note I assume each component is at most 32-bits long in base 2 */ - if (sscanf(ptr, "%d%n", &val1, &pos) == 1) - { - if (val1 >= 0x10000000) - bytesNeeded += 5; - else if (val1 >= 0x200000) - bytesNeeded += 4; - else if (val1 >= 0x4000) - bytesNeeded += 3; - else if (val1 >= 0x80) - bytesNeeded += 2; - else - bytesNeeded += 1; - ptr += pos; - if (*ptr == '.') - ptr++; - } - else + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded))) { - SetLastError(CRYPT_E_ASN1_ERROR); - return FALSE; + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_SEQUENCE; + CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + for (i = 0; ret && i < cItem; i++) + { + ret = items[i].encodeFunc(dwCertEncodingType, NULL, + items[i].pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, + NULL, pbEncoded, &items[i].size); + pbEncoded += items[i].size; + } } } - CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); } - else - lenBytes = 1; - bytesNeeded += 1 + lenBytes; - if (pbEncoded) + TRACE("returning %d (%08lx)\n", ret, GetLastError()); + return ret; +} + +struct AsnConstructedItem +{ + BYTE tag; + const void *pvStructInfo; + CryptEncodeObjectExFunc encodeFunc; +}; + +static BOOL WINAPI CRYPT_AsnEncodeConstructed(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + const struct AsnConstructedItem *item = + (const struct AsnConstructedItem *)pvStructInfo; + DWORD len; + + if ((ret = item->encodeFunc(dwCertEncodingType, lpszStructType, + item->pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, NULL, &len))) { - if (*pbEncoded < bytesNeeded) + DWORD dataLen, bytesNeeded; + + CRYPT_EncodeLen(len, NULL, &dataLen); + bytesNeeded = 1 + dataLen + len; + if (!pbEncoded) + *pcbEncoded = bytesNeeded; + else if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, + pbEncoded, pcbEncoded, bytesNeeded))) { - SetLastError(ERROR_MORE_DATA); - ret = FALSE; + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_CONTEXT | ASN_CONSTRUCTOR | item->tag; + CRYPT_EncodeLen(len, pbEncoded, &dataLen); + pbEncoded += dataLen; + ret = item->encodeFunc(dwCertEncodingType, lpszStructType, + item->pvStructInfo, dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, + pbEncoded, &len); } - else - { - *pbEncoded++ = ASN_OBJECTIDENTIFIER; - CRYPT_EncodeLen(bytesNeeded - 1 - lenBytes, pbEncoded, &lenBytes); - pbEncoded += lenBytes; - if (pszObjId) - { - const char *ptr; - int val, pos; + } + return ret; +} - *pbEncoded++ = firstByte; - ptr = pszObjId + firstPos; - while (ret && *ptr) - { - sscanf(ptr, "%d%n", &val, &pos); - { - unsigned char outBytes[5]; - int numBytes, i; +static BOOL WINAPI CRYPT_AsnEncodeCertVersion(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + const DWORD *ver = (const DWORD *)pvStructInfo; + BOOL ret; - if (val >= 0x10000000) - numBytes = 5; - else if (val >= 0x200000) - numBytes = 4; - else if (val >= 0x4000) - numBytes = 3; - else if (val >= 0x80) - numBytes = 2; - else - numBytes = 1; - for (i = numBytes; i > 0; i--) - { - outBytes[i - 1] = val & 0x7f; - val >>= 7; - } - for (i = 0; i < numBytes - 1; i++) - *pbEncoded++ = outBytes[i] | 0x80; - *pbEncoded++ = outBytes[i]; - ptr += pos; - if (*ptr == '.') - ptr++; - } - } - } - } + /* CERT_V1 is not encoded */ + if (*ver == CERT_V1) + { + *pcbEncoded = 0; + ret = TRUE; + } + else + { + struct AsnConstructedItem item = { 0, ver, CRYPT_AsnEncodeInt }; + + ret = CRYPT_AsnEncodeConstructed(dwCertEncodingType, X509_INTEGER, + &item, dwFlags, pEncodePara, pbEncoded, pcbEncoded); } - *pcbEncoded = bytesNeeded; return ret; } -static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType, - CERT_NAME_VALUE *value, BYTE *pbEncoded, DWORD *pcbEncoded) +static BOOL WINAPI CRYPT_CopyEncodedBlob(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { - BYTE tag; - DWORD bytesNeeded, lenBytes, encodedLen; - BOOL ret = TRUE; + const CRYPT_DER_BLOB *blob = (const CRYPT_DER_BLOB *)pvStructInfo; + BOOL ret; - switch (value->dwValueType) + if (!pbEncoded) { - case CERT_RDN_NUMERIC_STRING: - tag = ASN_NUMERICSTRING; - encodedLen = value->Value.cbData; - break; - case CERT_RDN_PRINTABLE_STRING: - tag = ASN_PRINTABLESTRING; - encodedLen = value->Value.cbData; - break; - case CERT_RDN_IA5_STRING: - tag = ASN_IA5STRING; - encodedLen = value->Value.cbData; - break; - case CERT_RDN_ANY_TYPE: - /* explicitly disallowed */ - SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)); - return FALSE; - default: - FIXME("String type %ld unimplemented\n", value->dwValueType); - return FALSE; + *pcbEncoded = blob->cbData; + ret = TRUE; } - CRYPT_EncodeLen(encodedLen, NULL, &lenBytes); - bytesNeeded = 1 + lenBytes + encodedLen; - if (pbEncoded) + else if (*pcbEncoded < blob->cbData) { - if (*pcbEncoded < bytesNeeded) - { - SetLastError(ERROR_MORE_DATA); - ret = FALSE; - } - else - { - *pbEncoded++ = tag; - CRYPT_EncodeLen(encodedLen, pbEncoded, &lenBytes); - pbEncoded += lenBytes; - switch (value->dwValueType) - { - case CERT_RDN_NUMERIC_STRING: - case CERT_RDN_PRINTABLE_STRING: - case CERT_RDN_IA5_STRING: - memcpy(pbEncoded, value->Value.pbData, value->Value.cbData); - } - } + *pcbEncoded = blob->cbData; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + if (blob->cbData) + memcpy(pbEncoded, blob->pbData, blob->cbData); + *pcbEncoded = blob->cbData; + ret = TRUE; } - *pcbEncoded = bytesNeeded; return ret; } -static BOOL WINAPI CRYPT_AsnEncodeRdnAttr(DWORD dwCertEncodingType, - CERT_RDN_ATTR *attr, BYTE *pbEncoded, DWORD *pcbEncoded) +static BOOL WINAPI CRYPT_AsnEncodeValidity(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { - DWORD bytesNeeded = 0, lenBytes, size; BOOL ret; + /* This has two filetimes in a row, a NotBefore and a NotAfter */ + const FILETIME *timePtr = (const FILETIME *)pvStructInfo; + struct AsnEncodeSequenceItem items[] = { + { timePtr++, CRYPT_AsnEncodeChoiceOfTime, 0 }, + { timePtr, CRYPT_AsnEncodeChoiceOfTime, 0 }, + }; - ret = CRYPT_AsnEncodeOid(dwCertEncodingType, attr->pszObjId, NULL, &size); - if (ret) - { - bytesNeeded += size; - /* hack: a CERT_RDN_ATTR is identical to a CERT_NAME_VALUE beginning - * with dwValueType, so "cast" it to get its encoded size - */ - ret = CRYPT_AsnEncodeNameValue(dwCertEncodingType, - (CERT_NAME_VALUE *)&attr->dwValueType, NULL, &size); - if (ret) - { - bytesNeeded += size; - CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); - bytesNeeded += 1 + lenBytes; - if (pbEncoded) - { - if (*pcbEncoded < bytesNeeded) - { - SetLastError(ERROR_MORE_DATA); - ret = FALSE; - } - else - { - *pbEncoded++ = ASN_CONSTRUCTOR | ASN_SEQUENCE; - CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, - &lenBytes); - pbEncoded += lenBytes; - size = bytesNeeded - 1 - lenBytes; - ret = CRYPT_AsnEncodeOid(dwCertEncodingType, attr->pszObjId, - pbEncoded, &size); - if (ret) - { - pbEncoded += size; - size = bytesNeeded - 1 - lenBytes - size; - ret = CRYPT_AsnEncodeNameValue(dwCertEncodingType, - (CERT_NAME_VALUE *)&attr->dwValueType, pbEncoded, - &size); - } - } - } - *pcbEncoded = bytesNeeded; - } - } + ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, + pcbEncoded); return ret; } -static int BLOBComp(const void *l, const void *r) +static BOOL WINAPI CRYPT_AsnEncodeAlgorithmId( + DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, + DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, + DWORD *pcbEncoded) { - CRYPT_DER_BLOB *a = (CRYPT_DER_BLOB *)l, *b = (CRYPT_DER_BLOB *)r; - int ret; + const CRYPT_ALGORITHM_IDENTIFIER *algo = + (const CRYPT_ALGORITHM_IDENTIFIER *)pvStructInfo; + BOOL ret; + struct AsnEncodeSequenceItem items[] = { + { algo->pszObjId, CRYPT_AsnEncodeOid, 0 }, + { &algo->Parameters, CRYPT_CopyEncodedBlob, 0 }, + }; - if (!(ret = memcmp(a->pbData, b->pbData, min(a->cbData, b->cbData)))) - ret = a->cbData - b->cbData; + ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, + pcbEncoded); return ret; } -/* This encodes as a SET OF, which in DER must be lexicographically sorted. - */ -static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn, - BYTE *pbEncoded, DWORD *pcbEncoded) +static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { BOOL ret; - CRYPT_DER_BLOB *blobs = NULL; - + __TRY { - DWORD bytesNeeded = 0, lenBytes, i; - - ret = TRUE; - if (rdn->cRDNAttr) - { - blobs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - rdn->cRDNAttr * sizeof(CRYPT_DER_BLOB)); - if (!blobs) - ret = FALSE; - } - for (i = 0; ret && i < rdn->cRDNAttr; i++) - { - ret = CRYPT_AsnEncodeRdnAttr(dwCertEncodingType, &rdn->rgRDNAttr[i], - NULL, &blobs[i].cbData); - if (ret) - bytesNeeded += blobs[i].cbData; - } - if (ret) - { - CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); - bytesNeeded += 1 + lenBytes; - if (pbEncoded) - { - if (*pcbEncoded < bytesNeeded) - { - SetLastError(ERROR_MORE_DATA); - ret = FALSE; - } - else - { - for (i = 0; ret && i < rdn->cRDNAttr; i++) - { - blobs[i].pbData = HeapAlloc(GetProcessHeap(), 0, - blobs[i].cbData); - if (!blobs[i].pbData) - ret = FALSE; - else - ret = CRYPT_AsnEncodeRdnAttr(dwCertEncodingType, - &rdn->rgRDNAttr[i], blobs[i].pbData, - &blobs[i].cbData); - } - if (ret) - { - qsort(blobs, rdn->cRDNAttr, sizeof(CRYPT_DER_BLOB), - BLOBComp); - *pbEncoded++ = ASN_CONSTRUCTOR | ASN_SETOF; - CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, - &lenBytes); - pbEncoded += lenBytes; - for (i = 0; ret && i < rdn->cRDNAttr; i++) - { - memcpy(pbEncoded, blobs[i].pbData, blobs[i].cbData); - pbEncoded += blobs[i].cbData; - } - } - } - } - *pcbEncoded = bytesNeeded; - } - if (blobs) - { - for (i = 0; i < rdn->cRDNAttr; i++) - HeapFree(GetProcessHeap(), 0, blobs[i].pbData); - } + const CERT_PUBLIC_KEY_INFO *info = + (const CERT_PUBLIC_KEY_INFO *)pvStructInfo; + struct AsnEncodeSequenceItem items[] = { + { &info->Algorithm, CRYPT_AsnEncodeAlgorithmId, 0 }, + { &info->PublicKey, CRYPT_AsnEncodeBits, 0 }, + }; + + TRACE("Encoding public key with OID %s\n", + debugstr_a(info->Algorithm.pszObjId)); + ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, + pcbEncoded); } __EXCEPT(page_fault) { @@ -749,11 +732,10 @@ ret = FALSE; } __ENDTRY - HeapFree(GetProcessHeap(), 0, blobs); return ret; } -static BOOL WINAPI CRYPT_AsnEncodeName(DWORD dwCertEncodingType, +static BOOL WINAPI CRYPT_AsnEncodeCert(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { @@ -761,49 +743,19 @@ __TRY { - CERT_NAME_INFO *info = (CERT_NAME_INFO *)pvStructInfo; - DWORD bytesNeeded = 0, lenBytes, size, i; - - TRACE("encoding name with %ld RDNs\n", info->cRDN); - ret = TRUE; - for (i = 0; ret && i < info->cRDN; i++) - { - ret = CRYPT_AsnEncodeRdn(dwCertEncodingType, &info->rgRDN[i], NULL, - &size); - if (ret) - bytesNeeded += size; - } - CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); - bytesNeeded += 1 + lenBytes; - if (ret) - { - if (!pbEncoded) - *pcbEncoded = bytesNeeded; - else - { - if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, - pbEncoded, pcbEncoded, bytesNeeded))) - { - if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) - pbEncoded = *(BYTE **)pbEncoded; - *pbEncoded++ = ASN_SEQUENCEOF; - CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, - &lenBytes); - pbEncoded += lenBytes; - for (i = 0; ret && i < info->cRDN; i++) - { - size = bytesNeeded; - ret = CRYPT_AsnEncodeRdn(dwCertEncodingType, - &info->rgRDN[i], pbEncoded, &size); - if (ret) - { - pbEncoded += size; - bytesNeeded -= size; - } - } - } - } - } + const CERT_SIGNED_CONTENT_INFO *info = + (const CERT_SIGNED_CONTENT_INFO *)pvStructInfo; + struct AsnEncodeSequenceItem items[] = { + { &info->ToBeSigned, CRYPT_CopyEncodedBlob, 0 }, + { &info->SignatureAlgorithm, CRYPT_AsnEncodeAlgorithmId, 0 }, + { &info->Signature, CRYPT_AsnEncodeBitsSwapBytes, 0 }, + }; + + if (dwFlags & CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG) + items[2].encodeFunc = CRYPT_AsnEncodeBits; + ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, + pcbEncoded); } __EXCEPT(page_fault) { @@ -814,27 +766,11 @@ return ret; } -static BOOL CRYPT_EncodeBool(BOOL val, BYTE *pbEncoded, DWORD *pcbEncoded) -{ - if (!pbEncoded) - { - *pcbEncoded = 3; - return TRUE; - } - if (*pcbEncoded < 3) - { - *pcbEncoded = 3; - SetLastError(ERROR_MORE_DATA); - return FALSE; - } - *pcbEncoded = 3; - *pbEncoded++ = ASN_BOOL; - *pbEncoded++ = 1; - *pbEncoded++ = val ? 0xff : 0; - return TRUE; -} - -static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints2(DWORD dwCertEncodingType, +/* Like in Windows, this blithely ignores the validity of the passed-in + * CERT_INFO, and just encodes it as-is. The resulting encoded data may not + * decode properly, see CRYPT_AsnDecodeCertInfo. + */ +static BOOL WINAPI CRYPT_AsnEncodeCertInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { @@ -842,59 +778,53 @@ __TRY { - CERT_BASIC_CONSTRAINTS2_INFO *info = - (CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; - DWORD bytesNeeded = 0, lenBytes, caLen = 0, pathConstraintLen = 0; - - ret = TRUE; - if (info->fCA) - { - ret = CRYPT_EncodeBool(TRUE, NULL, &caLen); - if (ret) - bytesNeeded += caLen; - } - if (info->fPathLenConstraint) - { - ret = CRYPT_AsnEncodeInt(dwCertEncodingType, X509_INTEGER, - &info->dwPathLenConstraint, 0, NULL, NULL, &pathConstraintLen); - if (ret) - bytesNeeded += pathConstraintLen; - } - if (ret) - { - CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); - bytesNeeded += 1 + lenBytes; - if (!pbEncoded) - { - *pcbEncoded = bytesNeeded; - ret = TRUE; - } - else - { - if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, - pbEncoded, pcbEncoded, bytesNeeded))) - { - if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) - pbEncoded = *(BYTE **)pbEncoded; - *pbEncoded++ = ASN_SEQUENCE; - CRYPT_EncodeLen(bytesNeeded - 1 - lenBytes, pbEncoded, - &lenBytes); - pbEncoded += lenBytes; - if (info->fCA) - { - ret = CRYPT_EncodeBool(TRUE, pbEncoded, &caLen); - if (ret) - pbEncoded += caLen; - } - if (info->fPathLenConstraint) - { - ret = CRYPT_AsnEncodeInt(dwCertEncodingType, - X509_INTEGER, &info->dwPathLenConstraint, 0, NULL, - pbEncoded, &pathConstraintLen); - } - } - } + const CERT_INFO *info = (const CERT_INFO *)pvStructInfo; + struct AsnEncodeSequenceItem items[10] = { + { &info->dwVersion, CRYPT_AsnEncodeCertVersion, 0 }, + { &info->SerialNumber, CRYPT_AsnEncodeInteger, 0 }, + { &info->SignatureAlgorithm, CRYPT_AsnEncodeAlgorithmId, 0 }, + { &info->Issuer, CRYPT_CopyEncodedBlob, 0 }, + { &info->NotBefore, CRYPT_AsnEncodeValidity, 0 }, + { &info->Subject, CRYPT_CopyEncodedBlob, 0 }, + { &info->SubjectPublicKeyInfo, CRYPT_AsnEncodePubKeyInfo, 0 }, + { 0 } + }; + struct AsnConstructedItem constructed[3] = { { 0 } }; + DWORD cItem = 7, cConstructed = 0; + + if (info->IssuerUniqueId.cbData) + { + constructed[cConstructed].tag = 1; + constructed[cConstructed].pvStructInfo = &info->IssuerUniqueId; + constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeBits; + items[cItem].pvStructInfo = &constructed[cConstructed]; + items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed; + cConstructed++; + cItem++; + } + if (info->SubjectUniqueId.cbData) + { + constructed[cConstructed].tag = 2; + constructed[cConstructed].pvStructInfo = &info->SubjectUniqueId; + constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeBits; + items[cItem].pvStructInfo = &constructed[cConstructed]; + items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed; + cConstructed++; + cItem++; + } + if (info->cExtension) + { + constructed[cConstructed].tag = 3; + constructed[cConstructed].pvStructInfo = &info->cExtension; + constructed[cConstructed].encodeFunc = CRYPT_AsnEncodeExtensions; + items[cItem].pvStructInfo = &constructed[cConstructed]; + items[cItem].encodeFunc = CRYPT_AsnEncodeConstructed; + cConstructed++; + cItem++; } + + ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem, + dwFlags, pEncodePara, pbEncoded, pcbEncoded); } __EXCEPT(page_fault) { @@ -905,7 +835,36 @@ return ret; } -static BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType, +static BOOL CRYPT_AsnEncodeExtension(CERT_EXTENSION *ext, BYTE *pbEncoded, + DWORD *pcbEncoded) +{ + BOOL ret; + struct AsnEncodeSequenceItem items[3] = { + { ext->pszObjId, CRYPT_AsnEncodeOid, 0 }, + { NULL, NULL, 0 }, + { NULL, NULL, 0 }, + }; + DWORD cItem = 1; + + TRACE("%p, %p, %ld\n", ext, pbEncoded, *pcbEncoded); + + if (ext->fCritical) + { + items[cItem].pvStructInfo = &ext->fCritical; + items[cItem].encodeFunc = CRYPT_AsnEncodeBool; + cItem++; + } + items[cItem].pvStructInfo = &ext->Value; + items[cItem].encodeFunc = CRYPT_AsnEncodeOctets; + cItem++; + + ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, cItem, 0, NULL, + pbEncoded, pcbEncoded); + TRACE("returning %d (%08lx)\n", ret, GetLastError()); + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeExtensions(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { @@ -913,16 +872,22 @@ __TRY { - CRYPT_DATA_BLOB *blob = (CRYPT_DATA_BLOB *)pvStructInfo; - DWORD bytesNeeded, lenBytes; + DWORD bytesNeeded, dataLen, lenBytes, i; + const CERT_EXTENSIONS *exts = (const CERT_EXTENSIONS *)pvStructInfo; - CRYPT_EncodeLen(blob->cbData, NULL, &lenBytes); - bytesNeeded = 1 + lenBytes + blob->cbData; - if (!pbEncoded) + ret = TRUE; + for (i = 0, dataLen = 0; ret && i < exts->cExtension; i++) { - *pcbEncoded = bytesNeeded; - ret = TRUE; + DWORD size; + + ret = CRYPT_AsnEncodeExtension(&exts->rgExtension[i], NULL, &size); + if (ret) + dataLen += size; } + CRYPT_EncodeLen(dataLen, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + dataLen; + if (!pbEncoded) + *pcbEncoded = bytesNeeded; else { if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, @@ -930,11 +895,18 @@ { if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) pbEncoded = *(BYTE **)pbEncoded; - *pbEncoded++ = ASN_OCTETSTRING; - CRYPT_EncodeLen(blob->cbData, pbEncoded, &lenBytes); + *pbEncoded++ = ASN_SEQUENCEOF; + CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes); pbEncoded += lenBytes; - if (blob->cbData) - memcpy(pbEncoded, blob->pbData, blob->cbData); + for (i = 0; i < exts->cExtension; i++) + { + DWORD size = dataLen; + + ret = CRYPT_AsnEncodeExtension(&exts->rgExtension[i], + pbEncoded, &size); + pbEncoded += size; + dataLen -= size; + } } } } @@ -947,20 +919,517 @@ return ret; } -static BOOL WINAPI CRYPT_AsnEncodeBits(DWORD dwCertEncodingType, +static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { - BOOL ret; + LPCSTR pszObjId = (LPCSTR)pvStructInfo; + DWORD bytesNeeded = 0, lenBytes; + BOOL ret = TRUE; + int firstPos = 0; + BYTE firstByte = 0; - __TRY - { - CRYPT_BIT_BLOB *blob = (CRYPT_BIT_BLOB *)pvStructInfo; + TRACE("%s\n", debugstr_a(pszObjId)); + + if (pszObjId) + { + const char *ptr; + int val1, val2; + + if (sscanf(pszObjId, "%d.%d.%n", &val1, &val2, &firstPos) != 2) + { + SetLastError(CRYPT_E_ASN1_ERROR); + return FALSE; + } + bytesNeeded++; + firstByte = val1 * 40 + val2; + ptr = pszObjId + firstPos; + while (ret && *ptr) + { + int pos; + + /* note I assume each component is at most 32-bits long in base 2 */ + if (sscanf(ptr, "%d%n", &val1, &pos) == 1) + { + if (val1 >= 0x10000000) + bytesNeeded += 5; + else if (val1 >= 0x200000) + bytesNeeded += 4; + else if (val1 >= 0x4000) + bytesNeeded += 3; + else if (val1 >= 0x80) + bytesNeeded += 2; + else + bytesNeeded += 1; + ptr += pos; + if (*ptr == '.') + ptr++; + } + else + { + SetLastError(CRYPT_E_ASN1_ERROR); + return FALSE; + } + } + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + } + else + lenBytes = 1; + bytesNeeded += 1 + lenBytes; + if (pbEncoded) + { + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pbEncoded++ = ASN_OBJECTIDENTIFIER; + CRYPT_EncodeLen(bytesNeeded - 1 - lenBytes, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + if (pszObjId) + { + const char *ptr; + int val, pos; + + *pbEncoded++ = firstByte; + ptr = pszObjId + firstPos; + while (ret && *ptr) + { + sscanf(ptr, "%d%n", &val, &pos); + { + unsigned char outBytes[5]; + int numBytes, i; + + if (val >= 0x10000000) + numBytes = 5; + else if (val >= 0x200000) + numBytes = 4; + else if (val >= 0x4000) + numBytes = 3; + else if (val >= 0x80) + numBytes = 2; + else + numBytes = 1; + for (i = numBytes; i > 0; i--) + { + outBytes[i - 1] = val & 0x7f; + val >>= 7; + } + for (i = 0; i < numBytes - 1; i++) + *pbEncoded++ = outBytes[i] | 0x80; + *pbEncoded++ = outBytes[i]; + ptr += pos; + if (*ptr == '.') + ptr++; + } + } + } + } + } + *pcbEncoded = bytesNeeded; + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType, + CERT_NAME_VALUE *value, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BYTE tag; + DWORD bytesNeeded, lenBytes, encodedLen; + BOOL ret = TRUE; + + switch (value->dwValueType) + { + case CERT_RDN_NUMERIC_STRING: + tag = ASN_NUMERICSTRING; + encodedLen = value->Value.cbData; + break; + case CERT_RDN_PRINTABLE_STRING: + tag = ASN_PRINTABLESTRING; + encodedLen = value->Value.cbData; + break; + case CERT_RDN_IA5_STRING: + tag = ASN_IA5STRING; + encodedLen = value->Value.cbData; + break; + case CERT_RDN_ANY_TYPE: + /* explicitly disallowed */ + SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)); + return FALSE; + default: + FIXME("String type %ld unimplemented\n", value->dwValueType); + return FALSE; + } + CRYPT_EncodeLen(encodedLen, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + encodedLen; + if (pbEncoded) + { + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pbEncoded++ = tag; + CRYPT_EncodeLen(encodedLen, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + switch (value->dwValueType) + { + case CERT_RDN_NUMERIC_STRING: + case CERT_RDN_PRINTABLE_STRING: + case CERT_RDN_IA5_STRING: + memcpy(pbEncoded, value->Value.pbData, value->Value.cbData); + } + } + } + *pcbEncoded = bytesNeeded; + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeRdnAttr(DWORD dwCertEncodingType, + CERT_RDN_ATTR *attr, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + DWORD bytesNeeded = 0, lenBytes, size; + BOOL ret; + + ret = CRYPT_AsnEncodeOid(dwCertEncodingType, NULL, attr->pszObjId, + 0, NULL, NULL, &size); + if (ret) + { + bytesNeeded += size; + /* hack: a CERT_RDN_ATTR is identical to a CERT_NAME_VALUE beginning + * with dwValueType, so "cast" it to get its encoded size + */ + ret = CRYPT_AsnEncodeNameValue(dwCertEncodingType, + (CERT_NAME_VALUE *)&attr->dwValueType, NULL, &size); + if (ret) + { + bytesNeeded += size; + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (pbEncoded) + { + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pbEncoded++ = ASN_CONSTRUCTOR | ASN_SEQUENCE; + CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, + &lenBytes); + pbEncoded += lenBytes; + size = bytesNeeded - 1 - lenBytes; + ret = CRYPT_AsnEncodeOid(dwCertEncodingType, NULL, + attr->pszObjId, 0, NULL, pbEncoded, &size); + if (ret) + { + pbEncoded += size; + size = bytesNeeded - 1 - lenBytes - size; + ret = CRYPT_AsnEncodeNameValue(dwCertEncodingType, + (CERT_NAME_VALUE *)&attr->dwValueType, pbEncoded, + &size); + } + } + } + *pcbEncoded = bytesNeeded; + } + } + return ret; +} + +static int BLOBComp(const void *l, const void *r) +{ + CRYPT_DER_BLOB *a = (CRYPT_DER_BLOB *)l, *b = (CRYPT_DER_BLOB *)r; + int ret; + + if (!(ret = memcmp(a->pbData, b->pbData, min(a->cbData, b->cbData)))) + ret = a->cbData - b->cbData; + return ret; +} + +/* This encodes as a SET OF, which in DER must be lexicographically sorted. + */ +static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn, + BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + CRYPT_DER_BLOB *blobs = NULL; + + __TRY + { + DWORD bytesNeeded = 0, lenBytes, i; + + ret = TRUE; + if (rdn->cRDNAttr) + { + blobs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + rdn->cRDNAttr * sizeof(CRYPT_DER_BLOB)); + if (!blobs) + ret = FALSE; + } + for (i = 0; ret && i < rdn->cRDNAttr; i++) + { + ret = CRYPT_AsnEncodeRdnAttr(dwCertEncodingType, &rdn->rgRDNAttr[i], + NULL, &blobs[i].cbData); + if (ret) + bytesNeeded += blobs[i].cbData; + } + if (ret) + { + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (pbEncoded) + { + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + for (i = 0; ret && i < rdn->cRDNAttr; i++) + { + blobs[i].pbData = HeapAlloc(GetProcessHeap(), 0, + blobs[i].cbData); + if (!blobs[i].pbData) + ret = FALSE; + else + ret = CRYPT_AsnEncodeRdnAttr(dwCertEncodingType, + &rdn->rgRDNAttr[i], blobs[i].pbData, + &blobs[i].cbData); + } + if (ret) + { + qsort(blobs, rdn->cRDNAttr, sizeof(CRYPT_DER_BLOB), + BLOBComp); + *pbEncoded++ = ASN_CONSTRUCTOR | ASN_SETOF; + CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, + &lenBytes); + pbEncoded += lenBytes; + for (i = 0; ret && i < rdn->cRDNAttr; i++) + { + memcpy(pbEncoded, blobs[i].pbData, blobs[i].cbData); + pbEncoded += blobs[i].cbData; + } + } + } + } + *pcbEncoded = bytesNeeded; + } + if (blobs) + { + for (i = 0; i < rdn->cRDNAttr; i++) + HeapFree(GetProcessHeap(), 0, blobs[i].pbData); + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + HeapFree(GetProcessHeap(), 0, blobs); + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeName(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + const CERT_NAME_INFO *info = (const CERT_NAME_INFO *)pvStructInfo; + DWORD bytesNeeded = 0, lenBytes, size, i; + + TRACE("encoding name with %ld RDNs\n", info->cRDN); + ret = TRUE; + for (i = 0; ret && i < info->cRDN; i++) + { + ret = CRYPT_AsnEncodeRdn(dwCertEncodingType, &info->rgRDN[i], NULL, + &size); + if (ret) + bytesNeeded += size; + } + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (ret) + { + if (!pbEncoded) + *pcbEncoded = bytesNeeded; + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, + pbEncoded, pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_SEQUENCEOF; + CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, + &lenBytes); + pbEncoded += lenBytes; + for (i = 0; ret && i < info->cRDN; i++) + { + size = bytesNeeded; + ret = CRYPT_AsnEncodeRdn(dwCertEncodingType, + &info->rgRDN[i], pbEncoded, &size); + if (ret) + { + pbEncoded += size; + bytesNeeded -= size; + } + } + } + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeBool(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL val = *(const BOOL *)pvStructInfo, ret; + + TRACE("%d\n", val); + + if (!pbEncoded) + { + *pcbEncoded = 3; + ret = TRUE; + } + else if (*pcbEncoded < 3) + { + *pcbEncoded = 3; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pcbEncoded = 3; + *pbEncoded++ = ASN_BOOL; + *pbEncoded++ = 1; + *pbEncoded++ = val ? 0xff : 0; + ret = TRUE; + } + TRACE("returning %d (%08lx)\n", ret, GetLastError()); + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints2(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + const CERT_BASIC_CONSTRAINTS2_INFO *info = + (const CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; + struct AsnEncodeSequenceItem items[2] = { { 0 } }; + DWORD cItem = 0; + + if (info->fCA) + { + items[cItem].pvStructInfo = &info->fCA; + items[cItem].encodeFunc = CRYPT_AsnEncodeBool; + cItem++; + } + if (info->fPathLenConstraint) + { + items[cItem].pvStructInfo = &info->dwPathLenConstraint; + items[cItem].encodeFunc = CRYPT_AsnEncodeInt; + cItem++; + } + ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem, + dwFlags, pEncodePara, pbEncoded, pcbEncoded); + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + const CRYPT_DATA_BLOB *blob = (const CRYPT_DATA_BLOB *)pvStructInfo; + DWORD bytesNeeded, lenBytes; + + TRACE("(%ld, %p), %08lx, %p, %p, %ld\n", blob->cbData, blob->pbData, + dwFlags, pEncodePara, pbEncoded, *pcbEncoded); + + CRYPT_EncodeLen(blob->cbData, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + blob->cbData; + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_OCTETSTRING; + CRYPT_EncodeLen(blob->cbData, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + if (blob->cbData) + memcpy(pbEncoded, blob->pbData, blob->cbData); + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + TRACE("returning %d (%08lx)\n", ret, GetLastError()); + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeBits(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo; DWORD bytesNeeded, lenBytes, dataBytes; BYTE unusedBits; /* yep, MS allows cUnusedBits to be >= 8 */ - if (blob->cbData * 8 > blob->cUnusedBits) + if (!blob->cUnusedBits) + { + dataBytes = blob->cbData; + unusedBits = 0; + } + else if (blob->cbData * 8 > blob->cUnusedBits) { dataBytes = (blob->cbData * 8 - blob->cUnusedBits) / 8 + 1; unusedBits = blob->cUnusedBits >= 8 ? blob->cUnusedBits / 8 : @@ -1012,6 +1481,45 @@ return ret; } +static BOOL WINAPI CRYPT_AsnEncodeBitsSwapBytes(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo; + CRYPT_BIT_BLOB newBlob = { blob->cbData, NULL, blob->cUnusedBits }; + + ret = TRUE; + if (newBlob.cbData) + { + newBlob.pbData = HeapAlloc(GetProcessHeap(), 0, newBlob.cbData); + if (newBlob.pbData) + { + DWORD i; + + for (i = 0; i < newBlob.cbData; i++) + newBlob.pbData[newBlob.cbData - i - 1] = blob->pbData[i]; + } + else + ret = FALSE; + } + if (ret) + ret = CRYPT_AsnEncodeBits(dwCertEncodingType, lpszStructType, + &newBlob, dwFlags, pEncodePara, pbEncoded, pcbEncoded); + HeapFree(GetProcessHeap(), 0, newBlob.pbData); + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + static BOOL WINAPI CRYPT_AsnEncodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) @@ -1033,7 +1541,8 @@ DWORD significantBytes, lenBytes; BYTE padByte = 0, bytesNeeded; BOOL pad = FALSE; - CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + const CRYPT_INTEGER_BLOB *blob = + (const CRYPT_INTEGER_BLOB *)pvStructInfo; significantBytes = blob->cbData; if (significantBytes) @@ -1121,7 +1630,8 @@ DWORD significantBytes, lenBytes; BYTE bytesNeeded; BOOL pad = FALSE; - CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + const CRYPT_INTEGER_BLOB *blob = + (const CRYPT_INTEGER_BLOB *)pvStructInfo; significantBytes = blob->cbData; if (significantBytes) @@ -1347,7 +1857,8 @@ __TRY { DWORD bytesNeeded, dataLen, lenBytes, i; - CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)pvStructInfo; + const CRYPT_SEQUENCE_OF_ANY *seq = + (const CRYPT_SEQUENCE_OF_ANY *)pvStructInfo; for (i = 0, dataLen = 0; i < seq->cValue; i++) dataLen += seq->rgValue[i].cbData; @@ -1386,9 +1897,6 @@ return ret; } -typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *, - DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *); - BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, void *pvEncoded, DWORD *pcbEncoded) @@ -1421,9 +1929,21 @@ { switch (LOWORD(lpszStructType)) { + case (WORD)X509_CERT: + encodeFunc = CRYPT_AsnEncodeCert; + break; + case (WORD)X509_CERT_TO_BE_SIGNED: + encodeFunc = CRYPT_AsnEncodeCertInfo; + break; + case (WORD)X509_EXTENSIONS: + encodeFunc = CRYPT_AsnEncodeExtensions; + break; case (WORD)X509_NAME: encodeFunc = CRYPT_AsnEncodeName; break; + case (WORD)X509_PUBLIC_KEY_INFO: + encodeFunc = CRYPT_AsnEncodePubKeyInfo; + break; case (WORD)X509_BASIC_CONSTRAINTS2: encodeFunc = CRYPT_AsnEncodeBasicConstraints2; break; @@ -1459,6 +1979,8 @@ FIXME("%d: unimplemented\n", LOWORD(lpszStructType)); } } + else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS)) + encodeFunc = CRYPT_AsnEncodeExtensions; else if (!strcmp(lpszStructType, szOID_RSA_signingTime)) encodeFunc = CRYPT_AsnEncodeUtcTime; else if (!strcmp(lpszStructType, szOID_CRL_REASON_CODE)) @@ -1485,9 +2007,6 @@ return ret; } -typedef BOOL (WINAPI *CryptDecodeObjectFunc)(DWORD, LPCSTR, const BYTE *, - DWORD, DWORD, void *, DWORD *); - BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo) @@ -1541,7 +2060,7 @@ if (cbEncoded <= 1) { - SetLastError(CRYPT_E_ASN1_EOD); + SetLastError(CRYPT_E_ASN1_CORRUPT); ret = FALSE; } else if (pbEncoded[1] <= 0x7f) @@ -1553,7 +2072,7 @@ { BYTE lenLen = GET_LEN_BYTES(pbEncoded[1]); - if (lenLen > sizeof(DWORD)) + if (lenLen > sizeof(DWORD) + 1) { SetLastError(CRYPT_E_ASN1_LARGE); ret = FALSE; @@ -1565,150 +2084,747 @@ } else { - DWORD out = 0; + DWORD out = 0; + + pbEncoded += 2; + while (--lenLen) + { + out <<= 8; + out |= *pbEncoded++; + } + if (out + lenLen + 1 > cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } + else + { + *len = out; + ret = TRUE; + } + } + } + return ret; +} + +/* Helper function to check *pcbStructInfo, set it to the required size, and + * optionally to allocate memory. Assumes pvStructInfo is not NULL. + * If CRYPT_DECODE_ALLOC_FLAG is set in dwFlags, *pvStructInfo will be set to a + * pointer to the newly allocated memory. + */ +static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo, + DWORD bytesNeeded) +{ + BOOL ret = TRUE; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + { + if (pDecodePara && pDecodePara->pfnAlloc) + *(BYTE **)pvStructInfo = pDecodePara->pfnAlloc(bytesNeeded); + else + *(BYTE **)pvStructInfo = LocalAlloc(0, bytesNeeded); + if (!*(BYTE **)pvStructInfo) + ret = FALSE; + else + *pcbStructInfo = bytesNeeded; + } + else if (*pcbStructInfo < bytesNeeded) + { + *pcbStructInfo = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + return ret; +} + +/* A few of the members need explanation: + * offset: + * A sequence is decoded into a struct. The offset member is the + * offset of this item within that struct. + * minSize: + * The minimum amount of space occupied after decoding. You must set this. + * hasPointer, pointerOffset, minSize: + * If the item has dynamic data, set hasPointer to TRUE, pointerOffset to + * the offset within the (outer) struct of the data pointer (or to the + * first data pointer, if more than one exist). + * size: + * Used by CRYPT_AsnDecodeSequence, not for your use. + */ +struct AsnDecodeSequenceItem +{ + DWORD offset; + CryptDecodeObjectExFunc decodeFunc; + DWORD minSize; + BOOL optional; + BOOL hasPointer; + DWORD pointerOffset; + DWORD size; +}; + +/* This decodes an arbitrary sequence into a contiguous block of memory + * (basically, a struct.) Each element being decoded is described by a struct + * AsnDecodeSequenceItem, see above. + * Each item decoder is never called with CRYPT_DECODE_ALLOC_FLAG set. + * If any undecoded data are left over, fails with CRYPT_E_ASN1_CORRUPT. + * FIXME: use to decode more sequences. + */ +static BOOL CRYPT_AsnDecodeSequence(DWORD dwCertEncodingType, + struct AsnDecodeSequenceItem items[], DWORD cItem, const BYTE *pbEncoded, + DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, + void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + + if (pbEncoded[0] == ASN_SEQUENCE) + { + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + DWORD i, bytesNeeded = 0, minSize = 0; + const BYTE *ptr; + + ptr = pbEncoded + 1 + lenBytes; + for (i = 0; ret && i < cItem; i++) + { + DWORD nextItemLen; + + minSize += items[i].minSize; + if (cbEncoded - (ptr - pbEncoded) != 0) + { + if ((ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &nextItemLen))) + { + BYTE nextItemLenBytes = GET_LEN_BYTES(ptr[1]); + + ret = items[i].decodeFunc(dwCertEncodingType, NULL, + ptr, 1 + nextItemLenBytes + nextItemLen, + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, NULL, + &items[i].size); + if (ret) + { + /* Account for alignment padding */ + bytesNeeded += items[i].size; + if (items[i].size % sizeof(DWORD)) + bytesNeeded += sizeof(DWORD) - + items[i].size % sizeof(DWORD); + ptr += 1 + nextItemLenBytes + nextItemLen; + } + else if (items[i].optional && + GetLastError() == CRYPT_E_ASN1_BADTAG) + { + bytesNeeded += items[i].minSize; + SetLastError(NOERROR); + ret = TRUE; + } + } + } + else if (items[i].optional) + bytesNeeded += items[i].minSize; + else + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + } + if (ret) + { + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded))) + { + BYTE *nextData; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + nextData = (BYTE *)pvStructInfo + minSize; + memset(pvStructInfo, 0, minSize); + ptr = pbEncoded + 1 + lenBytes; + for (i = 0; ret && i < cItem; i++) + { + if (cbEncoded - (ptr - pbEncoded) != 0) + { + DWORD nextItemLen; + BYTE nextItemLenBytes = GET_LEN_BYTES(ptr[1]); + + CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &nextItemLen); + if (items[i].hasPointer) + *(BYTE **)((BYTE *)pvStructInfo + + items[i].pointerOffset) = nextData; + ret = items[i].decodeFunc(dwCertEncodingType, NULL, + ptr, 1 + nextItemLenBytes + nextItemLen, + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, + (BYTE *)pvStructInfo + items[i].offset, + &items[i].size); + if (ret) + { + if (items[i].hasPointer && + items[i].size > items[i].minSize) + { + nextData += items[i].size - + items[i].minSize; + /* align nextData to DWORD boundaries */ + if (items[i].size % sizeof(DWORD)) + nextData += sizeof(DWORD) - + items[i].size % sizeof(DWORD); + } + ptr += 1 + nextItemLenBytes + nextItemLen; + } + else if (items[i].optional && + GetLastError() == CRYPT_E_ASN1_BADTAG) + { + SetLastError(NOERROR); + ret = TRUE; + } + } + else if (!items[i].optional) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + } + } + } + } + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } + return ret; +} + +/* Decodes a DER-encoded BLOB into a CRYPT_DER_BLOB struct pointed to by + * pvStructInfo. The BLOB must be non-empty, otherwise the last error is set + * to CRYPT_E_ASN1_CORRUPT. + * Warning: assumes the CRYPT_DER_BLOB pointed to by pvStructInfo has pbData + * set! + */ +static BOOL WINAPI CRYPT_AsnDecodeDerBlob(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + DWORD bytesNeeded = sizeof(CRYPT_DER_BLOB); + + if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) + bytesNeeded += 1 + lenBytes + dataLen; + + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, bytesNeeded))) + { + CRYPT_DER_BLOB *blob = (CRYPT_DER_BLOB *)pvStructInfo; + + blob->cbData = 1 + lenBytes + dataLen; + if (blob->cbData) + { + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + blob->pbData = (BYTE *)pbEncoded; + else + { + assert(blob->pbData); + memcpy(blob->pbData, pbEncoded, blob->cbData); + } + } + else + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + } + } + return ret; +} + +/* Like CRYPT_AsnDecodeBitsInternal, but swaps the bytes */ +static BOOL WINAPI CRYPT_AsnDecodeBitsSwapBytes(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + + ret = CRYPT_AsnDecodeBitsInternal(dwCertEncodingType, lpszStructType, + pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo); + if (ret && pvStructInfo) + { + CRYPT_BIT_BLOB *blob = (CRYPT_BIT_BLOB *)pvStructInfo; + DWORD i; + BYTE temp; + + for (i = 0; i < blob->cbData / 2; i++) + { + temp = blob->pbData[i]; + blob->pbData[i] = blob->pbData[blob->cbData - i - 1]; + blob->pbData[blob->cbData - i - 1] = temp; + } + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeCert(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret = TRUE; + + __TRY + { + struct AsnDecodeSequenceItem items[] = { + { offsetof(CERT_SIGNED_CONTENT_INFO, ToBeSigned), + CRYPT_AsnDecodeDerBlob, sizeof(CRYPT_DER_BLOB), FALSE, TRUE, + offsetof(CERT_SIGNED_CONTENT_INFO, ToBeSigned.pbData), 0 }, + { offsetof(CERT_SIGNED_CONTENT_INFO, SignatureAlgorithm), + CRYPT_AsnDecodeAlgorithmId, sizeof(CRYPT_ALGORITHM_IDENTIFIER), + FALSE, TRUE, offsetof(CERT_SIGNED_CONTENT_INFO, + SignatureAlgorithm.Parameters.pbData), 0 }, + { offsetof(CERT_SIGNED_CONTENT_INFO, Signature), + CRYPT_AsnDecodeBitsSwapBytes, sizeof(CRYPT_BIT_BLOB), FALSE, TRUE, + offsetof(CERT_SIGNED_CONTENT_INFO, Signature.pbData), 0 }, + }; + + if (dwFlags & CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG) + items[2].decodeFunc = CRYPT_AsnDecodeBitsInternal; + ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo); + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeCertVersion(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + + if (pbEncoded[0] == (ASN_CONTEXT | ASN_CONSTRUCTOR)) + { + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + ret = CRYPT_AsnDecodeInt(dwCertEncodingType, X509_INTEGER, + pbEncoded + 1 + lenBytes, dataLen, dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo); + } + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeValidity(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + + struct AsnDecodeSequenceItem items[] = { + { offsetof(CERT_PRIVATE_KEY_VALIDITY, NotBefore), + CRYPT_AsnDecodeChoiceOfTime, sizeof(FILETIME), FALSE, FALSE, 0 }, + { offsetof(CERT_PRIVATE_KEY_VALIDITY, NotAfter), + CRYPT_AsnDecodeChoiceOfTime, sizeof(FILETIME), FALSE, FALSE, 0 }, + }; + + ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo); + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeCertInfo(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret = TRUE; + + __TRY + { + struct AsnDecodeSequenceItem items[] = { + { offsetof(CERT_INFO, dwVersion), CRYPT_AsnDecodeCertVersion, + sizeof(DWORD), TRUE, FALSE, 0, 0 }, + { offsetof(CERT_INFO, SerialNumber), CRYPT_AsnDecodeIntegerInternal, + sizeof(CRYPT_INTEGER_BLOB), FALSE, TRUE, offsetof(CERT_INFO, + SerialNumber.pbData), 0 }, + { offsetof(CERT_INFO, SignatureAlgorithm), CRYPT_AsnDecodeAlgorithmId, + sizeof(CRYPT_ALGORITHM_IDENTIFIER), FALSE, TRUE, offsetof(CERT_INFO, + SignatureAlgorithm.Parameters.pbData), 0 }, + { offsetof(CERT_INFO, Issuer), CRYPT_AsnDecodeDerBlob, + sizeof(CRYPT_DER_BLOB), FALSE, TRUE, offsetof(CERT_INFO, + Issuer.pbData) }, + { offsetof(CERT_INFO, NotBefore), CRYPT_AsnDecodeValidity, + sizeof(CERT_PRIVATE_KEY_VALIDITY), FALSE, FALSE, 0 }, + { offsetof(CERT_INFO, Subject), CRYPT_AsnDecodeDerBlob, + sizeof(CRYPT_DER_BLOB), FALSE, TRUE, offsetof(CERT_INFO, + Subject.pbData) }, + { offsetof(CERT_INFO, SubjectPublicKeyInfo), CRYPT_AsnDecodePubKeyInfo, + sizeof(CERT_PUBLIC_KEY_INFO), FALSE, TRUE, offsetof(CERT_INFO, + SubjectPublicKeyInfo.Algorithm.Parameters.pbData), 0 }, + { offsetof(CERT_INFO, IssuerUniqueId), CRYPT_AsnDecodeBitsInternal, + sizeof(CRYPT_BIT_BLOB), TRUE, TRUE, offsetof(CERT_INFO, + IssuerUniqueId.pbData), 0 }, + { offsetof(CERT_INFO, SubjectUniqueId), CRYPT_AsnDecodeBitsInternal, + sizeof(CRYPT_BIT_BLOB), TRUE, TRUE, offsetof(CERT_INFO, + SubjectUniqueId.pbData), 0 }, + { offsetof(CERT_INFO, cExtension), CRYPT_AsnDecodeExtensions, + sizeof(CERT_EXTENSIONS), TRUE, TRUE, offsetof(CERT_INFO, + rgExtension), 0 }, + }; + + ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo); + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +/* Warning: assumes ext->Value.pbData is set ahead of time! */ +static BOOL CRYPT_AsnDecodeExtension(const BYTE *pbEncoded, DWORD cbEncoded, + DWORD dwFlags, CERT_EXTENSION *ext, DWORD *pcbExt) +{ + BOOL ret = TRUE; + + if (pbEncoded[0] == ASN_SEQUENCE) + { + DWORD dataLen, bytesNeeded; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]), oidLenBytes = 0; - pbEncoded += 2; - while (lenLen--) + bytesNeeded = sizeof(CERT_EXTENSION); + if (dataLen) { - out <<= 8; - out |= *pbEncoded++; + const BYTE *ptr = pbEncoded + 1 + lenBytes; + DWORD encodedOidLen, oidLen; + + CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &encodedOidLen); + oidLenBytes = GET_LEN_BYTES(ptr[1]); + ret = CRYPT_AsnDecodeOid(ptr, cbEncoded - (ptr - pbEncoded), + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &oidLen); + if (ret) + { + bytesNeeded += oidLen; + ptr += 1 + encodedOidLen + oidLenBytes; + if (*ptr == ASN_BOOL) + ptr += 3; + ret = CRYPT_AsnDecodeOctets(X509_ASN_ENCODING, + X509_OCTET_STRING, ptr, cbEncoded - (ptr - pbEncoded), + 0, NULL, NULL, &dataLen); + bytesNeeded += dataLen; + if (ret) + { + if (!ext) + *pcbExt = bytesNeeded; + else if (*pcbExt < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + ptr = pbEncoded + 2 + lenBytes + encodedOidLen + + oidLenBytes; + if (*ptr == ASN_BOOL) + { + DWORD size = sizeof(BOOL); + + CRYPT_AsnDecodeBool(X509_ASN_ENCODING, NULL, + ptr, cbEncoded - (ptr - pbEncoded), + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, + &ext->fCritical, &size); + ptr += 3; + } + else + ext->fCritical = FALSE; + ret = CRYPT_AsnDecodeOctets(X509_ASN_ENCODING, + X509_OCTET_STRING, ptr, + cbEncoded - (ptr - pbEncoded), + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, + &ext->Value, &dataLen); + if (ret) + { + ext->pszObjId = ext->Value.pbData + + ext->Value.cbData; + ptr = pbEncoded + 1 + lenBytes; + ret = CRYPT_AsnDecodeOid(ptr, + cbEncoded - (ptr - pbEncoded), + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, + ext->pszObjId, &oidLen); + } + } + } + } } - if (out + lenLen + 1 > cbEncoded) + else { SetLastError(CRYPT_E_ASN1_EOD); ret = FALSE; } - else - { - *len = out; - ret = TRUE; - } } } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } return ret; } -/* Helper function to check *pcbStructInfo, set it to the required size, and - * optionally to allocate memory. Assumes pvStructInfo is not NULL. - * If CRYPT_DECODE_ALLOC_FLAG is set in dwFlags, *pvStructInfo will be set to a - * pointer to the newly allocated memory. - */ -static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags, - PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo, - DWORD bytesNeeded) +static BOOL WINAPI CRYPT_AsnDecodeExtensions(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { BOOL ret = TRUE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + __TRY { - if (pDecodePara && pDecodePara->pfnAlloc) - *(BYTE **)pvStructInfo = pDecodePara->pfnAlloc(bytesNeeded); + if (pbEncoded[0] == ASN_SEQUENCEOF) + { + DWORD dataLen, bytesNeeded; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + DWORD cExtension = 0; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + bytesNeeded = sizeof(CERT_EXTENSIONS); + if (dataLen) + { + const BYTE *ptr; + DWORD size; + + for (ptr = pbEncoded + 1 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + ret = CRYPT_AsnDecodeExtension(ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, NULL, &size); + if (ret) + { + DWORD nextLen; + + cExtension++; + bytesNeeded += size; + ret = CRYPT_GetLen(ptr, + cbEncoded - (ptr - pbEncoded), &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } + if (ret) + { + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded))) + { + DWORD size, i; + BYTE *nextData; + const BYTE *ptr; + CERT_EXTENSIONS *exts; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + *pcbStructInfo = bytesNeeded; + exts = (CERT_EXTENSIONS *)pvStructInfo; + exts->cExtension = cExtension; + exts->rgExtension = (CERT_EXTENSION *)((BYTE *)exts + + sizeof(CERT_EXTENSIONS)); + nextData = (BYTE *)exts->rgExtension + + exts->cExtension * sizeof(CERT_EXTENSION); + for (i = 0, ptr = pbEncoded + 1 + lenBytes; ret && + i < cExtension && ptr - pbEncoded - 1 - lenBytes < + dataLen; i++) + { + exts->rgExtension[i].Value.pbData = nextData; + size = bytesNeeded; + ret = CRYPT_AsnDecodeExtension(ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, + &exts->rgExtension[i], &size); + if (ret) + { + DWORD nextLen; + + bytesNeeded -= size; + /* If dwFlags & CRYPT_DECODE_NOCOPY_FLAG, the + * data may not have been copied. + */ + if (exts->rgExtension[i].Value.pbData == + nextData) + nextData += + exts->rgExtension[i].Value.cbData; + /* Ugly: the OID, if copied, is stored in + * memory after the value, so increment by its + * string length if it's set and points here. + */ + if ((const BYTE *)exts->rgExtension[i].pszObjId + == nextData) + nextData += strlen( + exts->rgExtension[i].pszObjId) + 1; + ret = CRYPT_GetLen(ptr, + cbEncoded - (ptr - pbEncoded), &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } + } + } + } else - *(BYTE **)pvStructInfo = LocalAlloc(0, bytesNeeded); - if (!*(BYTE **)pvStructInfo) + { + SetLastError(CRYPT_E_ASN1_BADTAG); ret = FALSE; - else - *pcbStructInfo = bytesNeeded; + } } - else if (*pcbStructInfo < bytesNeeded) + __EXCEPT(page_fault) { - *pcbStructInfo = bytesNeeded; - SetLastError(ERROR_MORE_DATA); + SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } + __ENDTRY return ret; } -/* FIXME: honor the CRYPT_DECODE_SHARE_OID_FLAG. */ -static BOOL WINAPI CRYPT_AsnDecodeOid(DWORD dwCertEncodingType, - const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, LPSTR pszObjId, - DWORD *pcbObjId) +/* FIXME: honor the CRYPT_DECODE_SHARE_OID_STRING_FLAG. */ +static BOOL WINAPI CRYPT_AsnDecodeOid(const BYTE *pbEncoded, DWORD cbEncoded, + DWORD dwFlags, LPSTR pszObjId, DWORD *pcbObjId) { BOOL ret = TRUE; - DWORD bytesNeeded, dataLen; - BYTE lenBytes; - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - if (pbEncoded[0] != ASN_OBJECTIDENTIFIER) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - if (dataLen) + __TRY { - /* The largest possible string for the first two components is 2.175 - * (= 2 * 40 + 175 = 255), so this is big enough. - */ - char firstTwo[6]; - const BYTE *ptr; - - snprintf(firstTwo, sizeof(firstTwo), "%d.%d", - pbEncoded[1 + lenBytes] / 40, - pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / 40) * 40); - bytesNeeded = strlen(firstTwo) + 1; - for (ptr = pbEncoded + 2 + lenBytes; ret && - ptr - pbEncoded - 1 - lenBytes < dataLen; ) - { - /* large enough for ".4000000" */ - char str[9]; - int val = 0; - - while (ptr - pbEncoded - 1 - lenBytes < dataLen && (*ptr & 0x80)) - { - val <<= 7; - val |= *ptr & 0x7f; - ptr++; - } - if (ptr - pbEncoded - 1 - lenBytes >= dataLen || (*ptr & 0x80)) - { - SetLastError(CRYPT_E_ASN1_CORRUPT); - ret = FALSE; - } - else - { - val <<= 7; - val |= *ptr++; - snprintf(str, sizeof(str), ".%d", val); - bytesNeeded += strlen(str); - } - } - if (!pszObjId) - *pcbObjId = bytesNeeded; - else if (*pcbObjId < bytesNeeded) - { - *pcbObjId = bytesNeeded; - SetLastError(ERROR_MORE_DATA); - ret = FALSE; - } - else + if (pbEncoded[0] == ASN_OBJECTIDENTIFIER) { - sprintf(pszObjId, "%d.%d", pbEncoded[1 + lenBytes] / 40, - pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / 40) * 40); - pszObjId += strlen(pszObjId); - for (ptr = pbEncoded + 2 + lenBytes; ret && - ptr - pbEncoded - 1 - lenBytes < dataLen; ) + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - int val = 0; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + DWORD bytesNeeded; - while (ptr - pbEncoded - 1 - lenBytes < dataLen && - (*ptr & 0x80)) + if (dataLen) { - val <<= 7; - val |= *ptr & 0x7f; - ptr++; + /* The largest possible string for the first two components + * is 2.175 (= 2 * 40 + 175 = 255), so this is big enough. + */ + char firstTwo[6]; + const BYTE *ptr; + + snprintf(firstTwo, sizeof(firstTwo), "%d.%d", + pbEncoded[1 + lenBytes] / 40, + pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / 40) + * 40); + bytesNeeded = strlen(firstTwo) + 1; + for (ptr = pbEncoded + 2 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + /* large enough for ".4000000" */ + char str[9]; + int val = 0; + + while (ptr - pbEncoded - 1 - lenBytes < dataLen && + (*ptr & 0x80)) + { + val <<= 7; + val |= *ptr & 0x7f; + ptr++; + } + if (ptr - pbEncoded - 1 - lenBytes >= dataLen || + (*ptr & 0x80)) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + val <<= 7; + val |= *ptr++; + snprintf(str, sizeof(str), ".%d", val); + bytesNeeded += strlen(str); + } + } + if (!pszObjId) + *pcbObjId = bytesNeeded; + else if (*pcbObjId < bytesNeeded) + { + *pcbObjId = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + sprintf(pszObjId, "%d.%d", pbEncoded[1 + lenBytes] / 40, + pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / + 40) * 40); + pszObjId += strlen(pszObjId); + for (ptr = pbEncoded + 2 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + int val = 0; + + while (ptr - pbEncoded - 1 - lenBytes < dataLen && + (*ptr & 0x80)) + { + val <<= 7; + val |= *ptr & 0x7f; + ptr++; + } + val <<= 7; + val |= *ptr++; + sprintf(pszObjId, ".%d", val); + pszObjId += strlen(pszObjId); + } + } } - val <<= 7; - val |= *ptr++; - sprintf(pszObjId, ".%d", val); - pszObjId += strlen(pszObjId); + else + bytesNeeded = 0; + *pcbObjId = bytesNeeded; } } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } } - else - bytesNeeded = 0; - *pcbObjId = bytesNeeded; + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY return ret; } @@ -1716,398 +2832,601 @@ * order to avoid overwriting memory. (In some cases, it may change it, if it * doesn't copy anything to memory.) Be sure to set it correctly! */ -static BOOL WINAPI CRYPT_AsnDecodeNameValue(DWORD dwCertEncodingType, - const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, CERT_NAME_VALUE *value, - DWORD *pcbValue) +static BOOL WINAPI CRYPT_AsnDecodeNameValue(const BYTE *pbEncoded, + DWORD cbEncoded, DWORD dwFlags, CERT_NAME_VALUE *value, DWORD *pcbValue) { - DWORD bytesNeeded, dataLen; BOOL ret = TRUE; - BYTE lenBytes; - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - switch (pbEncoded[0]) - { - case ASN_NUMERICSTRING: - case ASN_PRINTABLESTRING: - case ASN_IA5STRING: - break; - default: - FIXME("Unimplemented string type %02x\n", pbEncoded[0]); - SetLastError(OSS_UNIMPLEMENTED); - return FALSE; - } - bytesNeeded = sizeof(CERT_NAME_VALUE); - if (dataLen) + __TRY { - switch (pbEncoded[0]) + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - case ASN_NUMERICSTRING: - case ASN_PRINTABLESTRING: - case ASN_IA5STRING: - if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) - bytesNeeded += dataLen; - break; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + case ASN_PRINTABLESTRING: + case ASN_IA5STRING: + break; + default: + FIXME("Unimplemented string type %02x\n", pbEncoded[0]); + SetLastError(OSS_UNIMPLEMENTED); + ret = FALSE; + } + if (ret) + { + DWORD bytesNeeded = sizeof(CERT_NAME_VALUE); + + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + case ASN_PRINTABLESTRING: + case ASN_IA5STRING: + if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) + bytesNeeded += dataLen; + break; + } + if (!value) + *pcbValue = bytesNeeded; + else if (*pcbValue < bytesNeeded) + { + *pcbValue = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pcbValue = bytesNeeded; + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + value->dwValueType = CERT_RDN_NUMERIC_STRING; + break; + case ASN_PRINTABLESTRING: + value->dwValueType = CERT_RDN_PRINTABLE_STRING; + break; + case ASN_IA5STRING: + value->dwValueType = CERT_RDN_IA5_STRING; + break; + } + if (dataLen) + { + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + case ASN_PRINTABLESTRING: + case ASN_IA5STRING: + value->Value.cbData = dataLen; + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + value->Value.pbData = (BYTE *)pbEncoded + 1 + + lenBytes; + else + { + assert(value->Value.pbData); + memcpy(value->Value.pbData, + pbEncoded + 1 + lenBytes, dataLen); + } + break; + } + } + else + { + value->Value.cbData = 0; + value->Value.pbData = NULL; + } + } + } } } - if (!value) + __EXCEPT(page_fault) { - *pcbValue = bytesNeeded; - return TRUE; + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } - if (*pcbValue < bytesNeeded) + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeRdnAttr(const BYTE *pbEncoded, + DWORD cbEncoded, DWORD dwFlags, CERT_RDN_ATTR *attr, DWORD *pcbAttr) +{ + BOOL ret; + + __TRY { - *pcbValue = bytesNeeded; - SetLastError(ERROR_MORE_DATA); - return FALSE; + if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCE)) + { + DWORD bytesNeeded, dataLen, size; + BYTE lenBytes; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + /* The data length must be at least 4, two for the tag and + * length for the OID, and two for the string (assuming both + * have short-form lengths.) + */ + if (dataLen < 4) + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } + else + { + bytesNeeded = sizeof(CERT_RDN_ATTR); + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + ret = CRYPT_AsnDecodeOid(pbEncoded + 1 + lenBytes, + cbEncoded - 1 - lenBytes, dwFlags, NULL, &size); + if (ret) + { + /* ugly: need to know the size of the next element of + * the sequence, so get it directly + */ + DWORD objIdOfset = 1 + lenBytes, objIdLen, + nameValueOffset = 0; + + ret = CRYPT_GetLen(pbEncoded + objIdOfset, + cbEncoded - objIdOfset, &objIdLen); + bytesNeeded += size; + /* hack: like encoding, this takes advantage of the + * fact that the rest of the structure is identical to + * a CERT_NAME_VALUE. + */ + if (ret) + { + nameValueOffset = objIdOfset + objIdLen + 1 + + GET_LEN_BYTES(pbEncoded[objIdOfset]); + ret = CRYPT_AsnDecodeNameValue( + pbEncoded + nameValueOffset, + cbEncoded - nameValueOffset, dwFlags, NULL, &size); + } + if (ret) + { + bytesNeeded += size; + if (!attr) + *pcbAttr = bytesNeeded; + else if (*pcbAttr < bytesNeeded) + { + *pcbAttr = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + BYTE *originalData = attr->Value.pbData; + + *pcbAttr = bytesNeeded; + /* strange: decode the value first, because it + * has a counted size, and we can store the OID + * after it. Keep track of the original data + * pointer, we'll need to know whether it was + * changed. + */ + size = bytesNeeded; + ret = CRYPT_AsnDecodeNameValue( + pbEncoded + nameValueOffset, + cbEncoded - nameValueOffset, dwFlags, + (CERT_NAME_VALUE *)&attr->dwValueType, &size); + if (ret) + { + if (objIdLen) + { + /* if the data were copied to the + * original location, the OID goes + * after. Otherwise it goes in the + * spot originally reserved for the + * data. + */ + if (attr->Value.pbData == originalData) + attr->pszObjId = + (LPSTR)(attr->Value.pbData + + attr->Value.cbData); + else + attr->pszObjId = originalData; + size = bytesNeeded - size; + ret = CRYPT_AsnDecodeOid( + pbEncoded + objIdOfset, + cbEncoded - objIdOfset, + dwFlags, attr->pszObjId, &size); + } + else + attr->pszObjId = NULL; + } + } + } + } + } + } + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } } - *pcbValue = bytesNeeded; - switch (pbEncoded[0]) + __EXCEPT(page_fault) { - case ASN_NUMERICSTRING: - value->dwValueType = CERT_RDN_NUMERIC_STRING; - break; - case ASN_PRINTABLESTRING: - value->dwValueType = CERT_RDN_PRINTABLE_STRING; - break; - case ASN_IA5STRING: - value->dwValueType = CERT_RDN_IA5_STRING; - break; + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } - if (dataLen) + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeRdn(const BYTE *pbEncoded, DWORD cbEncoded, + DWORD dwFlags, CERT_RDN *rdn, DWORD *pcbRdn) +{ + BOOL ret = TRUE; + + __TRY { - switch (pbEncoded[0]) + if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SETOF)) { - case ASN_NUMERICSTRING: - case ASN_PRINTABLESTRING: - case ASN_IA5STRING: - value->Value.cbData = dataLen; - if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) - value->Value.pbData = (BYTE *)pbEncoded + 1 + lenBytes; - else + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - if (!value->Value.pbData) + DWORD bytesNeeded, cRDNAttr = 0; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + bytesNeeded = sizeof(CERT_RDN); + if (dataLen) { - SetLastError(CRYPT_E_ASN1_INTERNAL); - ret = FALSE; + const BYTE *ptr; + DWORD size; + + for (ptr = pbEncoded + 1 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + ret = CRYPT_AsnDecodeRdnAttr(ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, NULL, &size); + if (ret) + { + DWORD nextLen; + + cRDNAttr++; + bytesNeeded += size; + ret = CRYPT_GetLen(ptr, + cbEncoded - (ptr - pbEncoded), &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } + if (ret) + { + if (!rdn) + *pcbRdn = bytesNeeded; + else if (*pcbRdn < bytesNeeded) + { + *pcbRdn = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + DWORD size, i; + BYTE *nextData; + const BYTE *ptr; + + *pcbRdn = bytesNeeded; + rdn->cRDNAttr = cRDNAttr; + rdn->rgRDNAttr = (CERT_RDN_ATTR *)((BYTE *)rdn + + sizeof(CERT_RDN)); + nextData = (BYTE *)rdn->rgRDNAttr + + rdn->cRDNAttr * sizeof(CERT_RDN_ATTR); + for (i = 0, ptr = pbEncoded + 1 + lenBytes; ret && + i < cRDNAttr && ptr - pbEncoded - 1 - lenBytes < + dataLen; i++) + { + rdn->rgRDNAttr[i].Value.pbData = nextData; + size = bytesNeeded; + ret = CRYPT_AsnDecodeRdnAttr(ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, + &rdn->rgRDNAttr[i], &size); + if (ret) + { + DWORD nextLen; + + bytesNeeded -= size; + /* If dwFlags & CRYPT_DECODE_NOCOPY_FLAG, the + * data may not have been copied. + */ + if (rdn->rgRDNAttr[i].Value.pbData == nextData) + nextData += + rdn->rgRDNAttr[i].Value.cbData; + /* Ugly: the OID, if copied, is stored in + * memory after the value, so increment by its + * string length if it's set and points here. + */ + if ((const BYTE *)rdn->rgRDNAttr[i].pszObjId + == nextData) + nextData += strlen( + rdn->rgRDNAttr[i].pszObjId) + 1; + ret = CRYPT_GetLen(ptr, + cbEncoded - (ptr - pbEncoded), &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } } - else - memcpy(value->Value.pbData, pbEncoded + 1 + lenBytes, - dataLen); } - break; + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; } } - else + __EXCEPT(page_fault) { - value->Value.cbData = 0; - value->Value.pbData = NULL; + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } + __ENDTRY return ret; } -static BOOL WINAPI CRYPT_AsnDecodeRdnAttr(DWORD dwCertEncodingType, - const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, CERT_RDN_ATTR *attr, - DWORD *pcbAttr) +static BOOL WINAPI CRYPT_AsnDecodeName(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { BOOL ret = TRUE; - DWORD bytesNeeded, dataLen, size; - BYTE lenBytes; - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - /* The data length must be at least 4, two for the tag and length for the - * OID, and two for the string (assuming both have short-form lengths.) - */ - if (dataLen < 4) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (pbEncoded[0] != (ASN_CONSTRUCTOR | ASN_SEQUENCE)) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - bytesNeeded = sizeof(CERT_RDN_ATTR); - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - ret = CRYPT_AsnDecodeOid(dwCertEncodingType, pbEncoded + 1 + lenBytes, - cbEncoded - 1 - lenBytes, dwFlags, NULL, &size); - if (ret) + __TRY { - /* ugly: need to know the size of the next element of the sequence, - * so get it directly - */ - DWORD objIdOfset = 1 + lenBytes, objIdLen, nameValueOffset = 0; - - ret = CRYPT_GetLen(pbEncoded + objIdOfset, cbEncoded - objIdOfset, - &objIdLen); - bytesNeeded += size; - /* hack: like encoding, this takes advantage of the fact that the rest - * of the structure is identical to a CERT_NAME_VALUE. - */ - if (ret) - { - nameValueOffset = objIdOfset + objIdLen + 1 + - GET_LEN_BYTES(pbEncoded[objIdOfset]); - ret = CRYPT_AsnDecodeNameValue(dwCertEncodingType, - pbEncoded + nameValueOffset, cbEncoded - nameValueOffset, dwFlags, - NULL, &size); - } - if (ret) + if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCEOF)) { - bytesNeeded += size; - if (!attr) - *pcbAttr = bytesNeeded; - else if (*pcbAttr < bytesNeeded) - { - *pcbAttr = bytesNeeded; - SetLastError(ERROR_MORE_DATA); - ret = FALSE; - } - else + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - BYTE *originalData = attr->Value.pbData; + DWORD bytesNeeded, cRDN = 0; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); - *pcbAttr = bytesNeeded; - /* strange: decode the value first, because it has a counted - * size, and we can store the OID after it. Keep track of the - * original data pointer, we'll need to know whether it was - * changed. - */ - size = bytesNeeded; - ret = CRYPT_AsnDecodeNameValue(dwCertEncodingType, - pbEncoded + nameValueOffset, cbEncoded - nameValueOffset, - dwFlags, (CERT_NAME_VALUE *)&attr->dwValueType, &size); + bytesNeeded = sizeof(CERT_NAME_INFO); + if (dataLen) + { + const BYTE *ptr; + + for (ptr = pbEncoded + 1 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + DWORD size; + + ret = CRYPT_AsnDecodeRdn(ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, NULL, &size); + if (ret) + { + DWORD nextLen; + + cRDN++; + bytesNeeded += size; + ret = CRYPT_GetLen(ptr, + cbEncoded - (ptr - pbEncoded), &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } if (ret) { - if (objIdLen) + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded))) { - /* if the data were copied to the original location, - * the OID goes after. Otherwise it goes in the - * spot originally reserved for the data. - */ - if (attr->Value.pbData == originalData) - attr->pszObjId = (LPSTR)(attr->Value.pbData + - attr->Value.cbData); + CERT_NAME_INFO *info; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + info = (CERT_NAME_INFO *)pvStructInfo; + info->cRDN = cRDN; + if (info->cRDN == 0) + info->rgRDN = NULL; else - attr->pszObjId = originalData; - size = bytesNeeded - size; - ret = CRYPT_AsnDecodeOid(dwCertEncodingType, - pbEncoded + objIdOfset, cbEncoded - objIdOfset, - dwFlags, attr->pszObjId, &size); + { + DWORD size, i; + BYTE *nextData; + const BYTE *ptr; + + info->rgRDN = (CERT_RDN *)((BYTE *)pvStructInfo + + sizeof(CERT_NAME_INFO)); + nextData = (BYTE *)info->rgRDN + + info->cRDN * sizeof(CERT_RDN); + for (i = 0, ptr = pbEncoded + 1 + lenBytes; ret && + i < cRDN && ptr - pbEncoded - 1 - lenBytes < + dataLen; i++) + { + info->rgRDN[i].rgRDNAttr = + (CERT_RDN_ATTR *)nextData; + size = bytesNeeded; + ret = CRYPT_AsnDecodeRdn(ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, + &info->rgRDN[i], &size); + if (ret) + { + DWORD nextLen; + + nextData += size; + bytesNeeded -= size; + ret = CRYPT_GetLen(ptr, + cbEncoded - (ptr - pbEncoded), &nextLen); + if (ret) + ptr += nextLen + 1 + + GET_LEN_BYTES(ptr[1]); + } + } + } } - else - attr->pszObjId = NULL; } } } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } + __ENDTRY return ret; } -static BOOL WINAPI CRYPT_AsnDecodeRdn(DWORD dwCertEncodingType, - const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, CERT_RDN *rdn, - DWORD *pcbRdn) +static BOOL WINAPI CRYPT_AsnDecodeAlgorithmId(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { + CRYPT_ALGORITHM_IDENTIFIER *algo = + (CRYPT_ALGORITHM_IDENTIFIER *)pvStructInfo; BOOL ret = TRUE; - DWORD bytesNeeded, dataLen, cRDNAttr = 0; - BYTE lenBytes; - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - if (pbEncoded[0] != (ASN_CONSTRUCTOR | ASN_SETOF)) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - bytesNeeded = sizeof(CERT_RDN); - if (dataLen) + if (pbEncoded[0] == ASN_SEQUENCE) { - const BYTE *ptr; - DWORD size; + DWORD dataLen, bytesNeeded; - for (ptr = pbEncoded + 1 + lenBytes; ret && - ptr - pbEncoded - 1 - lenBytes < dataLen; ) + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - ret = CRYPT_AsnDecodeRdnAttr(dwCertEncodingType, ptr, - cbEncoded - (ptr - pbEncoded), dwFlags, NULL, &size); - if (ret) - { - DWORD nextLen; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); - cRDNAttr++; - bytesNeeded += size; - ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), - &nextLen); - if (ret) - ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); - } - } - } - if (ret) - { - if (!rdn) - { - *pcbRdn = bytesNeeded; - return TRUE; - } - if (*pcbRdn < bytesNeeded) - { - *pcbRdn = bytesNeeded; - SetLastError(ERROR_MORE_DATA); - return FALSE; - } - *pcbRdn = bytesNeeded; - rdn->cRDNAttr = cRDNAttr; - if (rdn->cRDNAttr == 0) - rdn->rgRDNAttr = NULL; - else - { - DWORD size, i; - BYTE *nextData; - const BYTE *ptr; + bytesNeeded = sizeof(CRYPT_ALGORITHM_IDENTIFIER); + if (dataLen) + { + const BYTE *ptr = pbEncoded + 1 + lenBytes; + BYTE oidLenBytes; + DWORD encodedOidLen, oidLen; - rdn->rgRDNAttr = (CERT_RDN_ATTR *)((BYTE *)rdn + sizeof(CERT_RDN)); - nextData = (BYTE *)rdn->rgRDNAttr + - rdn->cRDNAttr * sizeof(CERT_RDN_ATTR); - for (i = 0, ptr = pbEncoded + 1 + lenBytes; ret && i < cRDNAttr && - ptr - pbEncoded - 1 - lenBytes < dataLen; i++) - { - rdn->rgRDNAttr[i].Value.pbData = nextData; - size = bytesNeeded; - ret = CRYPT_AsnDecodeRdnAttr(dwCertEncodingType, ptr, - cbEncoded - (ptr - pbEncoded), dwFlags, &rdn->rgRDNAttr[i], - &size); + CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &encodedOidLen); + oidLenBytes = GET_LEN_BYTES(ptr[1]); + ret = CRYPT_AsnDecodeOid(ptr, cbEncoded - (ptr - pbEncoded), + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &oidLen); if (ret) { - DWORD nextLen; - - bytesNeeded -= size; - /* If dwFlags & CRYPT_DECODE_NOCOPY_FLAG, the data may not - * have been copied. - */ - if (rdn->rgRDNAttr[i].Value.pbData == nextData) - nextData += rdn->rgRDNAttr[i].Value.cbData; - /* Ugly: the OID, if copied, is stored in memory after the - * value, so increment by its string length if it's set and - * points here. + bytesNeeded += oidLen; + ptr += 1 + encodedOidLen + oidLenBytes; + /* The remaining bytes are just copied as-is, no decoding + * is done. */ - if ((const BYTE *)rdn->rgRDNAttr[i].pszObjId == nextData) - nextData += strlen(rdn->rgRDNAttr[i].pszObjId) + 1; - ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), - &nextLen); - if (ret) - ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) + bytesNeeded += cbEncoded - (ptr - pbEncoded); + if (!algo) + *pcbStructInfo = bytesNeeded; + else if (*pcbStructInfo < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + /* Get and sanity-check parameter length first */ + if (dataLen - 1 - oidLenBytes - encodedOidLen != 0) + { + DWORD paramsLen; + + if ((ret = CRYPT_GetLen(ptr, cbEncoded - + (ptr - pbEncoded), ¶msLen))) + { + BYTE paramsLenBytes = GET_LEN_BYTES(ptr[1]); + + if (paramsLen != dataLen - encodedOidLen - 1 - + oidLenBytes - 1 - paramsLenBytes) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + } + } + if (ret) + { + *pcbStructInfo = bytesNeeded; + algo->Parameters.cbData = dataLen - 1 - + oidLenBytes - encodedOidLen; + if (algo->Parameters.cbData) + { + if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) + { + memcpy(algo->Parameters.pbData, ptr, + algo->Parameters.cbData); + algo->pszObjId = algo->Parameters.pbData + + algo->Parameters.cbData; + } + else + { + algo->Parameters.pbData = (BYTE *)ptr; + algo->pszObjId = algo->Parameters.pbData; + } + } + else + algo->pszObjId = algo->Parameters.pbData; + ptr = pbEncoded + 1 + lenBytes; + ret = CRYPT_AsnDecodeOid(ptr, + cbEncoded - (ptr - pbEncoded), + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, + algo->pszObjId, &oidLen); + } + } } } + else + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } } } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } return ret; } -static BOOL WINAPI CRYPT_AsnDecodeName(DWORD dwCertEncodingType, +static BOOL WINAPI CRYPT_AsnDecodePubKeyInfo(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { BOOL ret = TRUE; - DWORD bytesNeeded, dataLen, cRDN = 0; - BYTE lenBytes; - if (!pbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - if (pbEncoded[0] != (ASN_CONSTRUCTOR | ASN_SEQUENCEOF)) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - bytesNeeded = sizeof(CERT_NAME_INFO); - if (dataLen) + __TRY { - const BYTE *ptr; - DWORD size; - - for (ptr = pbEncoded + 1 + lenBytes; ret && ptr - pbEncoded - 1 - - lenBytes < dataLen; ) - { - ret = CRYPT_AsnDecodeRdn(dwCertEncodingType, ptr, - cbEncoded - (ptr - pbEncoded), dwFlags, NULL, &size); - if (ret) - { - DWORD nextLen; - - cRDN++; - bytesNeeded += size; - ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), - &nextLen); - if (ret) - ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); - } - } + struct AsnDecodeSequenceItem items[] = { + { offsetof(CERT_PUBLIC_KEY_INFO, Algorithm), + CRYPT_AsnDecodeAlgorithmId, sizeof(CRYPT_ALGORITHM_IDENTIFIER), + FALSE, TRUE, offsetof(CERT_PUBLIC_KEY_INFO, + Algorithm.Parameters.pbData) }, + { offsetof(CERT_PUBLIC_KEY_INFO, PublicKey), + CRYPT_AsnDecodeBitsInternal, sizeof(CRYPT_BIT_BLOB), FALSE, TRUE, + offsetof(CERT_PUBLIC_KEY_INFO, PublicKey.pbData) }, + }; + + ret = CRYPT_AsnDecodeSequence(dwCertEncodingType, items, + sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo); } - if (ret) + __EXCEPT(page_fault) { - CERT_NAME_INFO *info; - - if (!pvStructInfo) - { - *pcbStructInfo = bytesNeeded; - return TRUE; - } - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, bytesNeeded)) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - info = (CERT_NAME_INFO *)pvStructInfo; - info->cRDN = cRDN; - if (info->cRDN == 0) - info->rgRDN = NULL; - else - { - DWORD size, i; - BYTE *nextData; - const BYTE *ptr; - - info->rgRDN = (CERT_RDN *)((BYTE *)pvStructInfo + - sizeof(CERT_NAME_INFO)); - nextData = (BYTE *)info->rgRDN + info->cRDN * sizeof(CERT_RDN); - for (i = 0, ptr = pbEncoded + 1 + lenBytes; ret && i < cRDN && - ptr - pbEncoded - 1 - lenBytes < dataLen; i++) - { - info->rgRDN[i].rgRDNAttr = (CERT_RDN_ATTR *)nextData; - size = bytesNeeded; - ret = CRYPT_AsnDecodeRdn(dwCertEncodingType, ptr, - cbEncoded - (ptr - pbEncoded), dwFlags, &info->rgRDN[i], - &size); - if (ret) - { - DWORD nextLen; - - nextData += size; - bytesNeeded -= size; - ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), - &nextLen); - if (ret) - ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); - } - } - } + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } + __ENDTRY return ret; } -static BOOL WINAPI CRYPT_DecodeBool(const BYTE *pbEncoded, DWORD cbEncoded, - BOOL *val) +static BOOL WINAPI CRYPT_AsnDecodeBool(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { + BOOL ret; + if (cbEncoded < 3) { SetLastError(CRYPT_E_ASN1_CORRUPT); @@ -2128,244 +3447,395 @@ SetLastError(CRYPT_E_ASN1_CORRUPT); return FALSE; } - *val = pbEncoded[2] ? TRUE : FALSE; - return TRUE; + if (!pvStructInfo) + { + *pcbStructInfo = sizeof(BOOL); + ret = TRUE; + } + else if (*pcbStructInfo < sizeof(BOOL)) + { + *pcbStructInfo = sizeof(BOOL); + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *(BOOL *)pvStructInfo = pbEncoded[2] ? TRUE : FALSE; + ret = TRUE; + } + return ret; } static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints2(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - DWORD bytesNeeded, dataLen; - BYTE lenBytes; - CERT_BASIC_CONSTRAINTS2_INFO info = { 0 }; - BOOL ret = TRUE; + BOOL ret; + + __TRY + { + if (pbEncoded[0] == ASN_SEQUENCE) + { + DWORD dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + /* sanity-check length, space enough for 7 bytes of integer and + * 3 bytes of bool + */ + if (dataLen > 10) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + DWORD bytesNeeded = sizeof(CERT_BASIC_CONSTRAINTS2_INFO); + + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else + { + BYTE lenBytes; + CERT_BASIC_CONSTRAINTS2_INFO info = { 0 }; + + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + pbEncoded += 1 + lenBytes; + cbEncoded -= 1 + lenBytes; + if (cbEncoded) + { + DWORD size; + + if (pbEncoded[0] == ASN_BOOL) + { + size = sizeof(BOOL); + ret = CRYPT_AsnDecodeBool(dwCertEncodingType, + NULL, pbEncoded, cbEncoded, + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, + &info.fCA, &size); + if (ret) + { + cbEncoded -= 2 + pbEncoded[1]; + pbEncoded += 2 + pbEncoded[1]; + } + } + if (ret && cbEncoded && pbEncoded[0] == ASN_INTEGER) + { + size = sizeof(info.dwPathLenConstraint); + ret = CRYPT_AsnDecodeInt(dwCertEncodingType, + X509_INTEGER, pbEncoded, cbEncoded, 0, NULL, + &info.dwPathLenConstraint, &size); + if (ret) + { + cbEncoded -= 2 + pbEncoded[1]; + pbEncoded += 2 + pbEncoded[1]; + if (cbEncoded) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + info.fPathLenConstraint = TRUE; + } + } + } + if (ret) + { + if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo, + bytesNeeded))) + { + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + memcpy(pvStructInfo, &info, + sizeof(CERT_BASIC_CONSTRAINTS2_INFO)); + } + } + } + } + } + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + + __TRY + { + if (pbEncoded[0] == ASN_OCTETSTRING) + { + DWORD bytesNeeded, dataLen; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + bytesNeeded = sizeof(CRYPT_DATA_BLOB); + else + bytesNeeded = dataLen + sizeof(CRYPT_DATA_BLOB); + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, bytesNeeded))) + { + CRYPT_DATA_BLOB *blob; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_DATA_BLOB *)pvStructInfo; + blob->cbData = dataLen; + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + blob->pbData = (BYTE *)pbEncoded + 1 + lenBytes; + else + { + blob->pbData = (BYTE *)pvStructInfo + + sizeof(CRYPT_DATA_BLOB); + if (blob->cbData) + memcpy(blob->pbData, pbEncoded + 1 + lenBytes, + blob->cbData); + } + } + } + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeBitsInternal(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; - if (!pbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - /* sanity-check length, space enough for 7 bytes of integer and 3 bytes of - * bool - */ - if (dataLen > 10) - { - SetLastError(CRYPT_E_ASN1_CORRUPT); - return FALSE; - } - if (pbEncoded[0] != ASN_SEQUENCE) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - bytesNeeded = sizeof(CERT_BASIC_CONSTRAINTS2_INFO); - if (!pvStructInfo) - { - *pcbStructInfo = bytesNeeded; - return TRUE; - } - pbEncoded += 1 + lenBytes; - cbEncoded -= 1 + lenBytes; - if (cbEncoded) + TRACE("(%p, %ld, 0x%08lx, %p, %p, %p)\n", pbEncoded, cbEncoded, dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo); + + if (pbEncoded[0] == ASN_BITSTRING) { - DWORD size; + DWORD bytesNeeded, dataLen; - if (pbEncoded[0] == ASN_BOOL) + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - ret = CRYPT_DecodeBool(pbEncoded, cbEncoded, &info.fCA); - if (ret) + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + bytesNeeded = sizeof(CRYPT_BIT_BLOB); + else + bytesNeeded = dataLen - 1 + sizeof(CRYPT_BIT_BLOB); + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if (*pcbStructInfo < bytesNeeded) { - cbEncoded -= 2 + pbEncoded[1]; - pbEncoded += 2 + pbEncoded[1]; + *pcbStructInfo = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; } - } - if (ret && cbEncoded && pbEncoded[0] == ASN_INTEGER) - { - size = sizeof(info.dwPathLenConstraint); - ret = CRYPT_AsnDecodeInt(dwCertEncodingType, X509_INTEGER, - pbEncoded, cbEncoded, 0, NULL, &info.dwPathLenConstraint, - &size); - if (ret) + else { - cbEncoded -= 2 + pbEncoded[1]; - pbEncoded += 2 + pbEncoded[1]; - if (cbEncoded) + CRYPT_BIT_BLOB *blob; + + blob = (CRYPT_BIT_BLOB *)pvStructInfo; + blob->cbData = dataLen - 1; + blob->cUnusedBits = *(pbEncoded + 1 + + GET_LEN_BYTES(pbEncoded[1])); + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) { - SetLastError(CRYPT_E_ASN1_CORRUPT); - ret = FALSE; + blob->pbData = (BYTE *)pbEncoded + 2 + + GET_LEN_BYTES(pbEncoded[1]); } else - info.fPathLenConstraint = TRUE; + { + assert(blob->pbData); + if (blob->cbData) + { + BYTE mask = 0xff << blob->cUnusedBits; + + memcpy(blob->pbData, pbEncoded + 2 + + GET_LEN_BYTES(pbEncoded[1]), blob->cbData); + blob->pbData[blob->cbData - 1] &= mask; + } + } } } } - if (ret) + else { - CERT_BASIC_CONSTRAINTS2_INFO *out; - - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, bytesNeeded)) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - out = (CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; - memcpy(out, &info, sizeof(*out)); + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; } return ret; } -static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, +static BOOL WINAPI CRYPT_AsnDecodeBits(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - CRYPT_DATA_BLOB *blob; - DWORD bytesNeeded, dataLen; + BOOL ret; - if (!pbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - if (pbEncoded[0] != ASN_OCTETSTRING) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) - bytesNeeded = sizeof(CRYPT_DATA_BLOB); - else - bytesNeeded = dataLen + sizeof(CRYPT_DATA_BLOB); - if (!pvStructInfo) + TRACE("(%p, %ld, 0x%08lx, %p, %p, %p)\n", pbEncoded, cbEncoded, dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo); + + __TRY { - *pcbStructInfo = bytesNeeded; - return TRUE; + DWORD bytesNeeded; + + if ((ret = CRYPT_AsnDecodeBitsInternal(dwCertEncodingType, + lpszStructType, pbEncoded, cbEncoded, + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, NULL, &bytesNeeded))) + { + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, bytesNeeded))) + { + CRYPT_BIT_BLOB *blob; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_BIT_BLOB *)pvStructInfo; + blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_BIT_BLOB); + ret = CRYPT_AsnDecodeBitsInternal(dwCertEncodingType, + lpszStructType, pbEncoded, cbEncoded, + dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, pvStructInfo, + &bytesNeeded); + } + } } - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, bytesNeeded)) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - blob = (CRYPT_DATA_BLOB *)pvStructInfo; - blob->cbData = dataLen; - if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) - blob->pbData = (BYTE *)pbEncoded + 1 + GET_LEN_BYTES(pbEncoded[1]); - else + __EXCEPT(page_fault) { - blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_DATA_BLOB); - if (blob->cbData) - memcpy(blob->pbData, pbEncoded + 1 + GET_LEN_BYTES(pbEncoded[1]), - blob->cbData); + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } - return TRUE; + __ENDTRY + return ret; } -static BOOL WINAPI CRYPT_AsnDecodeBits(DWORD dwCertEncodingType, +static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - CRYPT_BIT_BLOB *blob; - DWORD bytesNeeded, dataLen; + BOOL ret; - if (!pbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - if (pbEncoded[0] != ASN_BITSTRING) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) - bytesNeeded = sizeof(CRYPT_BIT_BLOB); - else - bytesNeeded = dataLen - 1 + sizeof(CRYPT_BIT_BLOB); if (!pvStructInfo) { - *pcbStructInfo = bytesNeeded; + *pcbStructInfo = sizeof(int); return TRUE; } - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, bytesNeeded)) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - blob = (CRYPT_BIT_BLOB *)pvStructInfo; - blob->cbData = dataLen - 1; - blob->cUnusedBits = *(pbEncoded + 1 + GET_LEN_BYTES(pbEncoded[1])); - if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) - blob->pbData = (BYTE *)pbEncoded + 2 + GET_LEN_BYTES(pbEncoded[1]); - else + __TRY { - blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_BIT_BLOB); - if (blob->cbData) + BYTE buf[sizeof(CRYPT_INTEGER_BLOB) + sizeof(int)]; + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; + DWORD size = sizeof(buf); + + blob->pbData = buf + sizeof(CRYPT_INTEGER_BLOB); + ret = CRYPT_AsnDecodeIntegerInternal(dwCertEncodingType, + X509_MULTI_BYTE_INTEGER, pbEncoded, cbEncoded, 0, NULL, &buf, &size); + if (ret) { - BYTE mask = 0xff << blob->cUnusedBits; + if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, sizeof(int)))) + { + int val, i; - memcpy(blob->pbData, pbEncoded + 2 + GET_LEN_BYTES(pbEncoded[1]), - blob->cbData); - blob->pbData[blob->cbData - 1] &= mask; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + if (blob->pbData[blob->cbData - 1] & 0x80) + { + /* initialize to a negative value to sign-extend */ + val = -1; + } + else + val = 0; + for (i = 0; i < blob->cbData; i++) + { + val <<= 8; + val |= blob->pbData[blob->cbData - i - 1]; + } + memcpy(pvStructInfo, &val, sizeof(int)); + } } + else if (GetLastError() == ERROR_MORE_DATA) + SetLastError(CRYPT_E_ASN1_LARGE); } - return TRUE; + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; } -static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, +static BOOL WINAPI CRYPT_AsnDecodeIntegerInternal(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - BYTE buf[sizeof(CRYPT_INTEGER_BLOB) + sizeof(int)]; - DWORD size = sizeof(buf); BOOL ret; - if (!pbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (!pvStructInfo) + if (pbEncoded[0] == ASN_INTEGER) { - *pcbStructInfo = sizeof(int); - return TRUE; - } - ret = CRYPT_AsnDecodeInteger(dwCertEncodingType, X509_MULTI_BYTE_INTEGER, - pbEncoded, cbEncoded, 0, NULL, &buf, &size); - if (ret) - { - CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; + DWORD bytesNeeded, dataLen; - if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, - pvStructInfo, pcbStructInfo, sizeof(int)))) + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) { - int val, i; + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - if (blob->pbData[blob->cbData - 1] & 0x80) + bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if (*pcbStructInfo < bytesNeeded) { - /* initialize to a negative value to sign-extend */ - val = -1; + *pcbStructInfo = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; } else - val = 0; - for (i = 0; i < blob->cbData; i++) { - val <<= 8; - val |= blob->pbData[blob->cbData - i - 1]; + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + + blob->cbData = dataLen; + assert(blob->pbData); + if (blob->cbData) + { + DWORD i; + + for (i = 0; i < blob->cbData; i++) + blob->pbData[i] = *(pbEncoded + 1 + lenBytes + + dataLen - i - 1); + } } - memcpy(pvStructInfo, &val, sizeof(int)); } } - else if (GetLastError() == ERROR_MORE_DATA) - SetLastError(CRYPT_E_ASN1_LARGE); + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } return ret; } @@ -2373,153 +3843,176 @@ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - DWORD bytesNeeded, dataLen; - BYTE lenBytes; - CRYPT_INTEGER_BLOB *blob; + BOOL ret; - if (!pbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - if (pbEncoded[0] != ASN_INTEGER) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); - if (!pvStructInfo) + __TRY { - *pcbStructInfo = bytesNeeded; - return TRUE; + DWORD bytesNeeded; + + if ((ret = CRYPT_AsnDecodeIntegerInternal(dwCertEncodingType, + lpszStructType, pbEncoded, cbEncoded, + dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, NULL, &bytesNeeded))) + { + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, bytesNeeded))) + { + CRYPT_INTEGER_BLOB *blob; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + blob->pbData = (BYTE *)pvStructInfo + + sizeof(CRYPT_INTEGER_BLOB); + ret = CRYPT_AsnDecodeIntegerInternal(dwCertEncodingType, + lpszStructType, pbEncoded, cbEncoded, + dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, pvStructInfo, + &bytesNeeded); + } + } } - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, bytesNeeded)) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; - blob->cbData = dataLen; - blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_INTEGER_BLOB); - if (blob->cbData) + __EXCEPT(page_fault) { - DWORD i; - - for (i = 0; i < blob->cbData; i++) - blob->pbData[i] = *(pbEncoded + 1 + lenBytes + dataLen - i - 1); + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } - return TRUE; + __ENDTRY + return ret; } static BOOL WINAPI CRYPT_AsnDecodeUnsignedInteger(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - DWORD bytesNeeded, dataLen; - BYTE lenBytes; - CRYPT_INTEGER_BLOB *blob; + BOOL ret; - if (!pbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - if (pbEncoded[0] != ASN_INTEGER) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); - if (!pvStructInfo) - { - *pcbStructInfo = bytesNeeded; - return TRUE; - } - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, bytesNeeded)) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; - blob->cbData = dataLen; - blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_INTEGER_BLOB); - /* remove leading zero byte if it exists */ - if (blob->cbData && *(pbEncoded + 1 + lenBytes) == 0) + __TRY { - blob->cbData--; - blob->pbData++; + if (pbEncoded[0] == ASN_INTEGER) + { + DWORD bytesNeeded, dataLen; + CRYPT_INTEGER_BLOB *blob; + + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); + if (!pvStructInfo) + *pcbStructInfo = bytesNeeded; + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, bytesNeeded))) + { + BYTE lenBytes = GET_LEN_BYTES(pbEncoded[1]); + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + blob->cbData = dataLen; + blob->pbData = (BYTE *)pvStructInfo + + sizeof(CRYPT_INTEGER_BLOB); + /* remove leading zero byte if it exists */ + if (blob->cbData && *(pbEncoded + 1 + lenBytes) == 0) + { + blob->cbData--; + blob->pbData++; + } + if (blob->cbData) + { + DWORD i; + + for (i = 0; i < blob->cbData; i++) + blob->pbData[i] = *(pbEncoded + 1 + lenBytes + + pbEncoded[1] - i - 1); + } + } + } + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } } - if (blob->cbData) + __EXCEPT(page_fault) { - DWORD i; - - for (i = 0; i < blob->cbData; i++) - blob->pbData[i] = *(pbEncoded + 1 + lenBytes + pbEncoded[1] - i - - 1); + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } - return TRUE; + __ENDTRY + return ret; } static BOOL WINAPI CRYPT_AsnDecodeEnumerated(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - unsigned int val = 0, i; + BOOL ret; - if (!pbEncoded || !cbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } if (!pvStructInfo) { *pcbStructInfo = sizeof(int); return TRUE; } - if (pbEncoded[0] != ASN_ENUMERATED) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - if (cbEncoded <= 1) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (pbEncoded[1] == 0) - { - SetLastError(CRYPT_E_ASN1_CORRUPT); - return FALSE; - } - /* A little strange looking, but we have to accept a sign byte: 0xffffffff - * gets encoded as 0a 05 00 ff ff ff ff. Also, assuming a small length is - * okay here, it has to be in short form. - */ - if (pbEncoded[1] > sizeof(unsigned int) + 1) + __TRY { - SetLastError(CRYPT_E_ASN1_LARGE); - return FALSE; + if (pbEncoded[0] == ASN_ENUMERATED) + { + unsigned int val = 0, i; + + if (cbEncoded <= 1) + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } + else if (pbEncoded[1] == 0) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + /* A little strange looking, but we have to accept a sign byte: + * 0xffffffff gets encoded as 0a 05 00 ff ff ff ff. Also, + * assuming a small length is okay here, it has to be in short + * form. + */ + if (pbEncoded[1] > sizeof(unsigned int) + 1) + { + SetLastError(CRYPT_E_ASN1_LARGE); + return FALSE; + } + for (i = 0; i < pbEncoded[1]; i++) + { + val <<= 8; + val |= pbEncoded[2 + i]; + } + if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, sizeof(unsigned int)))) + { + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + memcpy(pvStructInfo, &val, sizeof(unsigned int)); + } + } + } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } } - for (i = 0; i < pbEncoded[1]; i++) + __EXCEPT(page_fault) { - val <<= 8; - val |= pbEncoded[2 + i]; + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, sizeof(unsigned int))) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - memcpy(pvStructInfo, &val, sizeof(unsigned int)); - return TRUE; + __ENDTRY + return ret; } +/* Modifies word, pbEncoded, and len, and magically sets a value ret to FALSE + * if it fails. + */ #define CRYPT_TIME_GET_DIGITS(pbEncoded, len, numDigits, word) \ do { \ BYTE i; \ @@ -2530,10 +4023,13 @@ if (!isdigit(*(pbEncoded))) \ { \ SetLastError(CRYPT_E_ASN1_CORRUPT); \ - return FALSE; \ + ret = FALSE; \ + } \ + else \ + { \ + (word) *= 10; \ + (word) += *(pbEncoded)++ - '0'; \ } \ - (word) *= 10; \ - (word) += *(pbEncoded)++ - '0'; \ } \ } while (0) @@ -2542,53 +4038,62 @@ { BOOL ret = TRUE; - if (len >= 3 && (*pbEncoded == '+' || *pbEncoded == '-')) + __TRY { - WORD hours, minutes = 0; - BYTE sign = *pbEncoded++; - - len--; - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, hours); - if (hours >= 24) - { - SetLastError(CRYPT_E_ASN1_CORRUPT); - ret = FALSE; - goto end; - } - if (len >= 2) + if (len >= 3 && (*pbEncoded == '+' || *pbEncoded == '-')) { - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, minutes); - if (minutes >= 60) + WORD hours, minutes = 0; + BYTE sign = *pbEncoded++; + + len--; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, hours); + if (ret && hours >= 24) { SetLastError(CRYPT_E_ASN1_CORRUPT); ret = FALSE; - goto end; } - } - if (sign == '+') - { - sysTime->wHour += hours; - sysTime->wMinute += minutes; - } - else - { - if (hours > sysTime->wHour) + else if (len >= 2) { - sysTime->wDay--; - sysTime->wHour = 24 - (hours - sysTime->wHour); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, minutes); + if (ret && minutes >= 60) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } } - else - sysTime->wHour -= hours; - if (minutes > sysTime->wMinute) + if (ret) { - sysTime->wHour--; - sysTime->wMinute = 60 - (minutes - sysTime->wMinute); + if (sign == '+') + { + sysTime->wHour += hours; + sysTime->wMinute += minutes; + } + else + { + if (hours > sysTime->wHour) + { + sysTime->wDay--; + sysTime->wHour = 24 - (hours - sysTime->wHour); + } + else + sysTime->wHour -= hours; + if (minutes > sysTime->wMinute) + { + sysTime->wHour--; + sysTime->wMinute = 60 - (minutes - sysTime->wMinute); + } + else + sysTime->wMinute -= minutes; + } } - else - sysTime->wMinute -= minutes; } } -end: + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY return ret; } @@ -2598,72 +4103,87 @@ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - SYSTEMTIME sysTime = { 0 }; - BYTE len; BOOL ret = TRUE; - if (!pbEncoded || !cbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } if (!pvStructInfo) { *pcbStructInfo = sizeof(FILETIME); return TRUE; } - if (pbEncoded[0] != ASN_UTCTIME) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - if (cbEncoded <= 1) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (pbEncoded[1] > 0x7f) - { - /* long-form date strings really can't be valid */ - SetLastError(CRYPT_E_ASN1_CORRUPT); - return FALSE; - } - len = pbEncoded[1]; - if (len < MIN_ENCODED_TIME_LENGTH) - { - SetLastError(CRYPT_E_ASN1_CORRUPT); - return FALSE; - } - pbEncoded += 2; - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wYear); - if (sysTime.wYear >= 50) - sysTime.wYear += 1900; - else - sysTime.wYear += 2000; - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMonth); - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wDay); - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wHour); - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMinute); - if (len > 0) - { - if (len >= 2 && isdigit(*pbEncoded) && isdigit(*(pbEncoded + 1))) - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wSecond); - else if (isdigit(*pbEncoded)) - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 1, sysTime.wSecond); - ret = CRYPT_AsnDecodeTimeZone(pbEncoded, len, &sysTime); - } - if (ret) + __TRY { - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, sizeof(FILETIME))) - ret = FALSE; + if (pbEncoded[0] == ASN_UTCTIME) + { + if (cbEncoded <= 1) + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } + else if (pbEncoded[1] > 0x7f) + { + /* long-form date strings really can't be valid */ + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + SYSTEMTIME sysTime = { 0 }; + BYTE len = pbEncoded[1]; + + if (len < MIN_ENCODED_TIME_LENGTH) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + pbEncoded += 2; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wYear); + if (sysTime.wYear >= 50) + sysTime.wYear += 1900; + else + sysTime.wYear += 2000; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMonth); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wDay); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wHour); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMinute); + if (ret && len > 0) + { + if (len >= 2 && isdigit(*pbEncoded) && + isdigit(*(pbEncoded + 1))) + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, + sysTime.wSecond); + else if (isdigit(*pbEncoded)) + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 1, + sysTime.wSecond); + if (ret) + ret = CRYPT_AsnDecodeTimeZone(pbEncoded, len, + &sysTime); + } + if (ret && (ret = CRYPT_DecodeEnsureSpace(dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo, + sizeof(FILETIME)))) + { + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + ret = SystemTimeToFileTime(&sysTime, + (FILETIME *)pvStructInfo); + } + } + } + } else { - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - ret = SystemTimeToFileTime(&sysTime, (FILETIME *)pvStructInfo); + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; } } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY return ret; } @@ -2671,76 +4191,93 @@ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - SYSTEMTIME sysTime = { 0 }; - BYTE len; BOOL ret = TRUE; - if (!pbEncoded || !cbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } if (!pvStructInfo) { *pcbStructInfo = sizeof(FILETIME); return TRUE; } - if (pbEncoded[0] != ASN_GENERALTIME) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - if (cbEncoded <= 1) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (pbEncoded[1] > 0x7f) - { - /* long-form date strings really can't be valid */ - SetLastError(CRYPT_E_ASN1_CORRUPT); - return FALSE; - } - len = pbEncoded[1]; - if (len < MIN_ENCODED_TIME_LENGTH) + __TRY { - SetLastError(CRYPT_E_ASN1_CORRUPT); - return FALSE; - } - pbEncoded += 2; - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 4, sysTime.wYear); - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMonth); - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wDay); - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wHour); - if (len > 0) - { - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMinute); - if (len > 0) - CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wSecond); - if (len > 0 && (*pbEncoded == '.' || *pbEncoded == ',')) + if (pbEncoded[0] == ASN_GENERALTIME) { - BYTE digits; + if (cbEncoded <= 1) + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } + else if (pbEncoded[1] > 0x7f) + { + /* long-form date strings really can't be valid */ + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + BYTE len = pbEncoded[1]; - pbEncoded++; - len--; - digits = min(len, 3); /* workaround macro weirdness */ - CRYPT_TIME_GET_DIGITS(pbEncoded, len, digits, - sysTime.wMilliseconds); + if (len < MIN_ENCODED_TIME_LENGTH) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + SYSTEMTIME sysTime = { 0 }; + + pbEncoded += 2; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 4, sysTime.wYear); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMonth); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wDay); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wHour); + if (ret && len > 0) + { + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, + sysTime.wMinute); + if (ret && len > 0) + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, + sysTime.wSecond); + if (ret && len > 0 && (*pbEncoded == '.' || + *pbEncoded == ',')) + { + BYTE digits; + + pbEncoded++; + len--; + /* workaround macro weirdness */ + digits = min(len, 3); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, digits, + sysTime.wMilliseconds); + } + if (ret) + ret = CRYPT_AsnDecodeTimeZone(pbEncoded, len, + &sysTime); + } + if (ret && (ret = CRYPT_DecodeEnsureSpace(dwFlags, + pDecodePara, pvStructInfo, pcbStructInfo, + sizeof(FILETIME)))) + { + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + ret = SystemTimeToFileTime(&sysTime, + (FILETIME *)pvStructInfo); + } + } + } } - ret = CRYPT_AsnDecodeTimeZone(pbEncoded, len, &sysTime); - } - if (ret) - { - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, sizeof(FILETIME))) - ret = FALSE; else { - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - ret = SystemTimeToFileTime(&sysTime, (FILETIME *)pvStructInfo); + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; } } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY return ret; } @@ -2750,30 +4287,34 @@ { BOOL ret; - if (!pbEncoded || !cbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } if (!pvStructInfo) { *pcbStructInfo = sizeof(FILETIME); return TRUE; } - if (pbEncoded[0] == ASN_UTCTIME) - ret = CRYPT_AsnDecodeUtcTime(dwCertEncodingType, lpszStructType, - pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo); - else if (pbEncoded[0] == ASN_GENERALTIME) - ret = CRYPT_AsnDecodeGeneralizedTime(dwCertEncodingType, - lpszStructType, pbEncoded, cbEncoded, dwFlags, pDecodePara, - pvStructInfo, pcbStructInfo); - else + __TRY { - SetLastError(CRYPT_E_ASN1_BADTAG); + if (pbEncoded[0] == ASN_UTCTIME) + ret = CRYPT_AsnDecodeUtcTime(dwCertEncodingType, lpszStructType, + pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo); + else if (pbEncoded[0] == ASN_GENERALTIME) + ret = CRYPT_AsnDecodeGeneralizedTime(dwCertEncodingType, + lpszStructType, pbEncoded, cbEncoded, dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo); + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } + __ENDTRY return ret; } @@ -2781,93 +4322,105 @@ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { - DWORD bytesNeeded, dataLen, remainingLen, cValue; - BYTE lenBytes; BOOL ret = TRUE; - const BYTE *ptr; - if (!pbEncoded || !cbEncoded) - { - SetLastError(CRYPT_E_ASN1_EOD); - return FALSE; - } - if (pbEncoded[0] != ASN_SEQUENCEOF) - { - SetLastError(CRYPT_E_ASN1_BADTAG); - return FALSE; - } - if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) - return FALSE; - lenBytes = GET_LEN_BYTES(pbEncoded[1]); - bytesNeeded = sizeof(CRYPT_SEQUENCE_OF_ANY); - cValue = 0; - ptr = pbEncoded + 1 + lenBytes; - remainingLen = dataLen; - while (ret && remainingLen) + __TRY { - DWORD nextLen; - - ret = CRYPT_GetLen(ptr, remainingLen, &nextLen); - if (ret) + if (pbEncoded[0] == ASN_SEQUENCEOF) { - DWORD nextLenBytes = GET_LEN_BYTES(ptr[1]); + DWORD bytesNeeded, dataLen, remainingLen, cValue; - remainingLen -= 1 + nextLenBytes + nextLen; - ptr += 1 + nextLenBytes + nextLen; - bytesNeeded += sizeof(CRYPT_DER_BLOB); - if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) - bytesNeeded += 1 + nextLenBytes + nextLen; - cValue++; - } - } - if (ret) - { - CRYPT_SEQUENCE_OF_ANY *seq; - BYTE *nextPtr; - DWORD i; + if ((ret = CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen))) + { + BYTE lenBytes; + const BYTE *ptr; - if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, - pcbStructInfo, bytesNeeded)) - return FALSE; - if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) - pvStructInfo = *(BYTE **)pvStructInfo; - seq = (CRYPT_SEQUENCE_OF_ANY *)pvStructInfo; - seq->cValue = cValue; - seq->rgValue = (CRYPT_DER_BLOB *)((BYTE *)seq + sizeof(*seq)); - nextPtr = (BYTE *)seq->rgValue + cValue * sizeof(CRYPT_DER_BLOB); - ptr = pbEncoded + 1 + lenBytes; - remainingLen = dataLen; - i = 0; - while (ret && remainingLen) - { - DWORD nextLen; + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + bytesNeeded = sizeof(CRYPT_SEQUENCE_OF_ANY); + cValue = 0; + ptr = pbEncoded + 1 + lenBytes; + remainingLen = dataLen; + while (ret && remainingLen) + { + DWORD nextLen; - ret = CRYPT_GetLen(ptr, remainingLen, &nextLen); - if (ret) - { - DWORD nextLenBytes = GET_LEN_BYTES(ptr[1]); + ret = CRYPT_GetLen(ptr, remainingLen, &nextLen); + if (ret) + { + DWORD nextLenBytes = GET_LEN_BYTES(ptr[1]); - seq->rgValue[i].cbData = 1 + nextLenBytes + nextLen; - if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) - seq->rgValue[i].pbData = (BYTE *)ptr; - else + remainingLen -= 1 + nextLenBytes + nextLen; + ptr += 1 + nextLenBytes + nextLen; + bytesNeeded += sizeof(CRYPT_DER_BLOB); + if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) + bytesNeeded += 1 + nextLenBytes + nextLen; + cValue++; + } + } + if (ret) { - seq->rgValue[i].pbData = nextPtr; - memcpy(nextPtr, ptr, 1 + nextLenBytes + nextLen); - nextPtr += 1 + nextLenBytes + nextLen; - } - remainingLen -= 1 + nextLenBytes + nextLen; - ptr += 1 + nextLenBytes + nextLen; - i++; + CRYPT_SEQUENCE_OF_ANY *seq; + BYTE *nextPtr; + DWORD i; + + if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, bytesNeeded))) + { + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + seq = (CRYPT_SEQUENCE_OF_ANY *)pvStructInfo; + seq->cValue = cValue; + seq->rgValue = (CRYPT_DER_BLOB *)((BYTE *)seq + + sizeof(*seq)); + nextPtr = (BYTE *)seq->rgValue + + cValue * sizeof(CRYPT_DER_BLOB); + ptr = pbEncoded + 1 + lenBytes; + remainingLen = dataLen; + i = 0; + while (ret && remainingLen) + { + DWORD nextLen; + + ret = CRYPT_GetLen(ptr, remainingLen, &nextLen); + if (ret) + { + DWORD nextLenBytes = GET_LEN_BYTES(ptr[1]); + + seq->rgValue[i].cbData = 1 + nextLenBytes + + nextLen; + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + seq->rgValue[i].pbData = (BYTE *)ptr; + else + { + seq->rgValue[i].pbData = nextPtr; + memcpy(nextPtr, ptr, 1 + nextLenBytes + + nextLen); + nextPtr += 1 + nextLenBytes + nextLen; + } + remainingLen -= 1 + nextLenBytes + nextLen; + ptr += 1 + nextLenBytes + nextLen; + i++; + } + } + } + } } } + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; } + __ENDTRY return ret; } -typedef BOOL (WINAPI *CryptDecodeObjectExFunc)(DWORD, LPCSTR, const BYTE *, - DWORD, DWORD, PCRYPT_DECODE_PARA, void *, DWORD *); - BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) @@ -2892,6 +4445,16 @@ SetLastError(ERROR_FILE_NOT_FOUND); return FALSE; } + if (!cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (cbEncoded > MAX_ENCODED_LEN) + { + SetLastError(CRYPT_E_ASN1_LARGE); + return FALSE; + } SetLastError(NOERROR); if (dwFlags & CRYPT_DECODE_ALLOC_FLAG && pvStructInfo) @@ -2900,9 +4463,21 @@ { switch (LOWORD(lpszStructType)) { + case (WORD)X509_CERT: + decodeFunc = CRYPT_AsnDecodeCert; + break; + case (WORD)X509_CERT_TO_BE_SIGNED: + decodeFunc = CRYPT_AsnDecodeCertInfo; + break; + case (WORD)X509_EXTENSIONS: + decodeFunc = CRYPT_AsnDecodeExtensions; + break; case (WORD)X509_NAME: decodeFunc = CRYPT_AsnDecodeName; break; + case (WORD)X509_PUBLIC_KEY_INFO: + decodeFunc = CRYPT_AsnDecodePubKeyInfo; + break; case (WORD)X509_BASIC_CONSTRAINTS2: decodeFunc = CRYPT_AsnDecodeBasicConstraints2; break; @@ -2938,6 +4513,8 @@ FIXME("%d: unimplemented\n", LOWORD(lpszStructType)); } } + else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS)) + decodeFunc = CRYPT_AsnDecodeExtensions; else if (!strcmp(lpszStructType, szOID_RSA_signingTime)) decodeFunc = CRYPT_AsnDecodeUtcTime; else if (!strcmp(lpszStructType, szOID_CRL_REASON_CODE)) diff -urN wine-20050628/dlls/crypt32/tests/encode.c wine-20050725/dlls/crypt32/tests/encode.c --- wine-20050628/dlls/crypt32/tests/encode.c 2005-06-27 11:42:15.000000000 +0200 +++ wine-20050725/dlls/crypt32/tests/encode.c 2005-07-14 12:14:22.000000000 +0200 @@ -29,7 +29,7 @@ struct encodedInt { int val; - BYTE *encoded; + const BYTE *encoded; }; static const struct encodedInt ints[] = { @@ -44,9 +44,9 @@ struct encodedBigInt { - BYTE *val; - BYTE *encoded; - BYTE *decoded; + const BYTE *val; + const BYTE *encoded; + const BYTE *decoded; }; static const struct encodedBigInt bigInts[] = { @@ -103,6 +103,8 @@ { ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", buf[0]); + ok(buf[1] == ints[i].encoded[1], "Got length %d, expected %d\n", + buf[1], ints[i].encoded[1]); ok(!memcmp(buf + 1, ints[i].encoded + 1, ints[i].encoded[1] + 1), "Encoded value of 0x%08x didn't match expected\n", ints[i].val); LocalFree(buf); @@ -181,6 +183,9 @@ { static const char bigInt[] = { 2, 5, 0xff, 0xfe, 0xff, 0xfe, 0xff }; static const char testStr[] = { 0x16, 4, 't', 'e', 's', 't' }; + static const BYTE longForm[] = { 2, 0x81, 0x01, 0x01 }; + static const BYTE tooBig[] = { 0x02, 0x84, 0xff, 0xff, 0xff, 0xff }; + static const BYTE bigBogus[] = { 0x02, 0x84, 0x01, 0xff, 0xff, 0xf9 }; BYTE *buf = NULL; DWORD bufSize = 0; int i; @@ -287,6 +292,33 @@ LocalFree(buf); } } + /* Decode the value 1 with long-form length */ + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm, + sizeof(longForm), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(*(int *)buf == 1, "Expected 1, got %d\n", *(int *)buf); + LocalFree(buf); + } + /* Try to decode some bogus large items */ + /* The buffer size is smaller than the encoded length, so this should fail + * with CRYPT_E_ASN1_EOD if it's being decoded. It's failing with + * CRYPT_E_ASN1_LARGE, meaning there's a limit on the size decoded. + * The magic limit under XP seems to be 0x061a8000 bytes--more than this + * fails with CRYPT_E_ASN1_LARGE. + */ + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig, + 0x7fffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, + "Expected CRYPT_E_ASN1_LARGE, got %08lx\n", GetLastError()); + /* This will try to decode the buffer and overflow it, check that it's + * caught. + */ + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus, + 0x01ffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); } /* These are always encoded unsigned, and aren't constrained to be any @@ -516,7 +548,7 @@ struct EncodedName { CERT_RDN_ATTR attr; - BYTE *encoded; + const BYTE *encoded; }; static const char commonName[] = "Juan Lang"; @@ -804,8 +836,8 @@ struct encodedOctets { - BYTE *val; - BYTE *encoded; + const BYTE *val; + const BYTE *encoded; }; static const struct encodedOctets octets[] = { @@ -878,13 +910,14 @@ struct encodedBits { DWORD cUnusedBits; - BYTE *encoded; + const BYTE *encoded; DWORD cbDecoded; - BYTE *decoded; + const BYTE *decoded; }; static const struct encodedBits bits[] = { - /* normal test case */ + /* normal test cases */ + { 0, "\x03\x03\x00\xff\xff", 2, "\xff\xff" }, { 1, "\x03\x03\x01\xff\xfe", 2, "\xff\xfe" }, /* strange test case, showing cUnusedBits >= 8 is allowed */ { 9, "\x03\x02\x01\xfe", 1, "\xfe" }, @@ -1101,7 +1134,7 @@ for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) { blobs[i].cbData = ints[i].encoded[1] + 2; - blobs[i].pbData = ints[i].encoded; + blobs[i].pbData = (BYTE *)ints[i].encoded; } seq.cValue = sizeof(ints) / sizeof(ints[0]); seq.rgValue = blobs; @@ -1182,6 +1215,487 @@ } } +struct encodedExtensions +{ + CERT_EXTENSIONS exts; + const BYTE *encoded; +}; + +static CERT_EXTENSION criticalExt = + { szOID_BASIC_CONSTRAINTS2, TRUE, { 8, "\x30\x06\x01\x01\xff\x02\x01\x01" } }; +static CERT_EXTENSION nonCriticalExt = + { szOID_BASIC_CONSTRAINTS2, FALSE, { 8, "\x30\x06\x01\x01\xff\x02\x01\x01" } }; + +static const struct encodedExtensions exts[] = { + { { 0, NULL }, "\x30\x00" }, + { { 1, &criticalExt }, "\x30\x14\x30\x12\x06\x03\x55\x1d\x13\x01\x01\xff" + "\x04\x08\x30\x06\x01\x01\xff\x02\x01\x01" }, + { { 1, &nonCriticalExt }, "\x30\x11\x30\x0f\x06\x03\x55\x1d\x13" + "\x04\x08\x30\x06\x01\x01\xff\x02\x01\x01" }, +}; + +static void test_encodeExtensions(DWORD dwEncoding) +{ + DWORD i; + + for (i = 0; i < sizeof(exts) / sizeof(exts[i]); i++) + { + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + ret = CryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(bufSize == exts[i].encoded[1] + 2, + "Expected %d bytes, got %ld\n", exts[i].encoded[1] + 2, bufSize); + ok(!memcmp(buf, exts[i].encoded, exts[i].encoded[1] + 2), + "Unexpected value\n"); + LocalFree(buf); + } + } +} + +static void test_decodeExtensions(DWORD dwEncoding) +{ + DWORD i; + + for (i = 0; i < sizeof(exts) / sizeof(exts[i]); i++) + { + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + exts[i].encoded, exts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, + NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CERT_EXTENSIONS *ext = (CERT_EXTENSIONS *)buf; + DWORD j; + + ok(ext->cExtension == exts[i].exts.cExtension, + "Expected %ld extensions, see %ld\n", exts[i].exts.cExtension, + ext->cExtension); + for (j = 0; j < min(ext->cExtension, exts[i].exts.cExtension); j++) + { + ok(!strcmp(ext->rgExtension[j].pszObjId, + exts[i].exts.rgExtension[j].pszObjId), + "Expected OID %s, got %s\n", + exts[i].exts.rgExtension[j].pszObjId, + ext->rgExtension[j].pszObjId); + ok(!memcmp(ext->rgExtension[j].Value.pbData, + exts[i].exts.rgExtension[j].Value.pbData, + exts[i].exts.rgExtension[j].Value.cbData), + "Unexpected value\n"); + } + LocalFree(buf); + } + } +} + +/* MS encodes public key info with a NULL if the algorithm identifier's + * parameters are empty. However, when encoding an algorithm in a CERT_INFO, + * it encodes them by omitting the algorithm parameters. This latter approach + * seems more correct, so accept either form. + */ +struct encodedPublicKey +{ + CERT_PUBLIC_KEY_INFO info; + const BYTE *encoded; + const BYTE *encodedNoNull; + CERT_PUBLIC_KEY_INFO decoded; +}; + +static const BYTE aKey[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, + 0xe, 0xf }; +static const BYTE params[] = { 0x02, 0x01, 0x01 }; + +static const struct encodedPublicKey pubKeys[] = { + /* with a bogus OID */ + { { { "1.2.3", { 0, NULL } }, { 0, NULL, 0 } }, + "\x30\x0b\x30\x06\x06\x02\x2a\x03\x05\x00\x03\x01\x00", + "\x30\x09\x30\x04\x06\x02\x2a\x03\x03\x01\x00", + { { "1.2.3", { 2, "\x05\x00" } }, { 0, NULL, 0 } } }, + /* some normal keys */ + { { { szOID_RSA, { 0, NULL } }, { 0, NULL, 0} }, + "\x30\x0f\x30\x0a\x06\x06\x2a\x86\x48\x86\xf7\x0d\x05\x00\x03\x01\x00", + "\x30\x0d\x30\x08\x06\x06\x2a\x86\x48\x86\xf7\x0d\x03\x01\x00", + { { szOID_RSA, { 2, "\x05\x00" } }, { 0, NULL, 0 } } }, + { { { szOID_RSA, { 0, NULL } }, { sizeof(aKey), (BYTE *)aKey, 0} }, + "\x30\x1f\x30\x0a\x06\x06\x2a\x86\x48\x86\xf7\x0d\x05\x00\x03\x11\x00\x00\x01" + "\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + "\x30\x1d\x30\x08\x06\x06\x2a\x86\x48\x86\xf7\x0d\x03\x11\x00\x00\x01" + "\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + { { szOID_RSA, { 2, "\x05\x00" } }, { sizeof(aKey), (BYTE *)aKey, 0} } }, + /* with add'l parameters--note they must be DER-encoded */ + { { { szOID_RSA, { sizeof(params), (BYTE *)params } }, { sizeof(aKey), + (BYTE *)aKey, 0 } }, + "\x30\x20\x30\x0b\x06\x06\x2a\x86\x48\x86\xf7\x0d\x02\x01\x01" + "\x03\x11\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e" + "\x0f", + "\x30\x20\x30\x0b\x06\x06\x2a\x86\x48\x86\xf7\x0d\x02\x01\x01" + "\x03\x11\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e" + "\x0f", + { { szOID_RSA, { sizeof(params), (BYTE *)params } }, { sizeof(aKey), + (BYTE *)aKey, 0 } } }, +}; + +static void test_encodePublicKeyInfo(DWORD dwEncoding) +{ + DWORD i; + + for (i = 0; i < sizeof(pubKeys) / sizeof(pubKeys[0]); i++) + { + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + ret = CryptEncodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + &pubKeys[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, + &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(bufSize == pubKeys[i].encoded[1] + 2 || + bufSize == pubKeys[i].encodedNoNull[1] + 2, + "Expected %d or %d bytes, got %ld\n", pubKeys[i].encoded[1] + 2, + pubKeys[i].encodedNoNull[1] + 2, bufSize); + if (bufSize == pubKeys[i].encoded[1] + 2) + ok(!memcmp(buf, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2), + "Unexpected value\n"); + else if (bufSize == pubKeys[i].encodedNoNull[1] + 2) + ok(!memcmp(buf, pubKeys[i].encodedNoNull, + pubKeys[i].encodedNoNull[1] + 2), "Unexpected value\n"); + LocalFree(buf); + } + } +} + +static void comparePublicKeyInfo(const CERT_PUBLIC_KEY_INFO *expected, + const CERT_PUBLIC_KEY_INFO *got) +{ + ok(!strcmp(expected->Algorithm.pszObjId, got->Algorithm.pszObjId), + "Expected OID %s, got %s\n", expected->Algorithm.pszObjId, + got->Algorithm.pszObjId); + ok(expected->Algorithm.Parameters.cbData == + got->Algorithm.Parameters.cbData, + "Expected parameters of %ld bytes, got %ld\n", + expected->Algorithm.Parameters.cbData, got->Algorithm.Parameters.cbData); + if (expected->Algorithm.Parameters.cbData) + ok(!memcmp(expected->Algorithm.Parameters.pbData, + got->Algorithm.Parameters.pbData, got->Algorithm.Parameters.cbData), + "Unexpected algorithm parameters\n"); + ok(expected->PublicKey.cbData == got->PublicKey.cbData, + "Expected public key of %ld bytes, got %ld\n", + expected->PublicKey.cbData, got->PublicKey.cbData); + if (expected->PublicKey.cbData) + ok(!memcmp(expected->PublicKey.pbData, got->PublicKey.pbData, + got->PublicKey.cbData), "Unexpected public key value\n"); +} + +static void test_decodePublicKeyInfo(DWORD dwEncoding) +{ + static const BYTE bogusPubKeyInfo[] = + "\x30\x22\x30\x0d\x06\x06\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x01\x01" + "\x03\x11\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e" + "\x0f"; + DWORD i; + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + for (i = 0; i < sizeof(pubKeys) / sizeof(pubKeys[0]); i++) + { + /* The NULL form decodes to the decoded member */ + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + pubKeys[i].encoded, pubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, + NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + comparePublicKeyInfo(&pubKeys[i].decoded, + (CERT_PUBLIC_KEY_INFO *)buf); + LocalFree(buf); + } + /* The non-NULL form decodes to the original */ + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + pubKeys[i].encodedNoNull, pubKeys[i].encodedNoNull[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + comparePublicKeyInfo(&pubKeys[i].info, (CERT_PUBLIC_KEY_INFO *)buf); + LocalFree(buf); + } + } + /* Test with bogus (not valid DER) parameters */ + ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + bogusPubKeyInfo, bogusPubKeyInfo[1] + 2, CRYPT_DECODE_ALLOC_FLAG, + NULL, (BYTE *)&buf, &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); +} + +static const BYTE v1Cert[] = "\x30\x33\x02\x00\x30\x02\x06\x00\x30\x22\x18" + "\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a\x18\x0f\x31" + "\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a\x30\x07\x30\x02\x06" + "\x00\x03\x01\x00"; +static const BYTE v2Cert[] = "\x30\x38\xa0\x03\x02\x01\x01\x02\x00\x30\x02\x06" + "\x00\x30\x22\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30" + "\x5a\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a\x30" + "\x07\x30\x02\x06\x00\x03\x01\x00"; +static const BYTE v3Cert[] = "\x30\x38\xa0\x03\x02\x01\x02\x02\x00\x30\x02\x06" + "\x00\x30\x22\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30" + "\x5a\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a\x30" + "\x07\x30\x02\x06\x00\x03\x01\x00"; +static const BYTE v1CertWithConstraints[] = "\x30\x4b\x02\x00\x30\x02\x06\x00" + "\x30\x22\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a" + "\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a\x30\x07" + "\x30\x02\x06\x00\x03\x01\x00\xa3\x16\x30\x14\x30\x12\x06\x03\x55\x1d\x13\x01" + "\x01\xff\x04\x08\x30\x06\x01\x01\xff\x02\x01\x01"; +static const BYTE v1CertWithSerial[] = "\x30\x4c\x02\x01\x01\x30\x02\x06\x00" + "\x30\x22\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a" + "\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30\x30\x5a\x30\x07" + "\x30\x02\x06\x00\x03\x01\x00\xa3\x16\x30\x14\x30\x12\x06\x03\x55\x1d\x13\x01" + "\x01\xff\x04\x08\x30\x06\x01\x01\xff\x02\x01\x01"; +static const BYTE bigCert[] = "\x30\x7a\x02\x01\x01\x30\x02\x06\x00" + "\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0a\x4a\x75\x61\x6e\x20\x4c" + "\x61\x6e\x67\x00\x30\x22\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30" + "\x30\x30\x30\x5a\x18\x0f\x31\x36\x30\x31\x30\x31\x30\x31\x30\x30\x30\x30\x30" + "\x30\x5a\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0a\x4a\x75\x61\x6e" + "\x20\x4c\x61\x6e\x67\x00\x30\x07\x30\x02\x06\x00\x03\x01\x00\xa3\x16\x30\x14" + "\x30\x12\x06\x03\x55\x1d\x13\x01\x01\xff\x04\x08\x30\x06\x01\x01\xff\x02\x01" + "\x01"; +/* This is the encoded form of the printable string "Juan Lang" */ +static const BYTE encodedCommonName[] = { 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, + 0x61, 0x6e, 0x67, 0x00 }; +static const BYTE serialNum[] = { 0x01 }; + +static void test_encodeCertToBeSigned(DWORD dwEncoding) +{ + BOOL ret; + BYTE *buf = NULL; + DWORD size = 0; + CERT_INFO info = { 0 }; + + /* Test with NULL pvStructInfo */ + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with a V1 cert */ + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(size == v1Cert[1] + 2, "Expected size %d, got %ld\n", + v1Cert[1] + 2, size); + ok(!memcmp(buf, v1Cert, size), "Got unexpected value\n"); + LocalFree(buf); + } + /* Test v2 cert */ + info.dwVersion = CERT_V2; + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(size == v2Cert[1] + 2, "Expected size %d, got %ld\n", + v3Cert[1] + 2, size); + ok(!memcmp(buf, v2Cert, size), "Got unexpected value\n"); + LocalFree(buf); + } + /* Test v3 cert */ + info.dwVersion = CERT_V3; + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(size == v3Cert[1] + 2, "Expected size %d, got %ld\n", + v3Cert[1] + 2, size); + ok(!memcmp(buf, v3Cert, size), "Got unexpected value\n"); + LocalFree(buf); + } + /* see if a V1 cert can have basic constraints set (RFC3280 says no, but + * API doesn't prevent it) + */ + info.dwVersion = CERT_V1; + info.cExtension = 1; + info.rgExtension = &criticalExt; + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(size == v1CertWithConstraints[1] + 2, "Expected size %d, got %ld\n", + v1CertWithConstraints[1] + 2, size); + ok(!memcmp(buf, v1CertWithConstraints, size), "Got unexpected value\n"); + LocalFree(buf); + } + /* test v1 cert with a serial number */ + info.SerialNumber.cbData = sizeof(serialNum); + info.SerialNumber.pbData = (BYTE *)serialNum; + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + if (buf) + { + ok(size == v1CertWithSerial[1] + 2, "Expected size %d, got %ld\n", + v1CertWithSerial[1] + 2, size); + ok(!memcmp(buf, v1CertWithSerial, size), "Got unexpected value\n"); + LocalFree(buf); + } + /* Test v1 cert with an issuer name, a subject name, and a serial number */ + info.Issuer.cbData = sizeof(encodedCommonName); + info.Issuer.pbData = (BYTE *)encodedCommonName; + info.Subject.cbData = sizeof(encodedCommonName); + info.Subject.pbData = (BYTE *)encodedCommonName; + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + if (buf) + { + ok(size == bigCert[1] + 2, "Expected size %d, got %ld\n", + bigCert[1] + 2, size); + ok(!memcmp(buf, bigCert, size), "Got unexpected value\n"); + LocalFree(buf); + } + /* for now, I let more interesting tests be done for each subcomponent, + * rather than retesting them all here. + */ +} + +static void test_decodeCertToBeSigned(DWORD dwEncoding) +{ + static const BYTE *corruptCerts[] = { v1Cert, v2Cert, v3Cert, + v1CertWithConstraints, v1CertWithSerial }; + BOOL ret; + BYTE *buf = NULL; + DWORD size = 0, i; + + /* Test with NULL pbEncoded */ + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 0, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* The following certs all fail with CRYPT_E_ASN1_CORRUPT, because at a + * minimum a cert must have a non-zero serial number, an issuer, and a + * subject. + */ + for (i = 0; i < sizeof(corruptCerts) / sizeof(corruptCerts[0]); i++) + { + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + corruptCerts[i], corruptCerts[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, + (BYTE *)&buf, &size); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); + } + /* Now check with serial number, subject and issuer specified */ + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert, + bigCert[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CERT_INFO *info = (CERT_INFO *)buf; + + ok(size >= sizeof(CERT_INFO), "Expected size at least %d, got %ld\n", + sizeof(CERT_INFO), size); + ok(info->SerialNumber.cbData == 1, + "Expected serial number size 1, got %ld\n", info->SerialNumber.cbData); + ok(*info->SerialNumber.pbData == *serialNum, + "Expected serial number %d, got %d\n", *serialNum, + *info->SerialNumber.pbData); + ok(info->Issuer.cbData == sizeof(encodedCommonName), + "Expected issuer of %d bytes, got %ld\n", sizeof(encodedCommonName), + info->Issuer.cbData); + ok(!memcmp(info->Issuer.pbData, encodedCommonName, info->Issuer.cbData), + "Unexpected issuer\n"); + ok(info->Subject.cbData == sizeof(encodedCommonName), + "Expected subject of %d bytes, got %ld\n", sizeof(encodedCommonName), + info->Subject.cbData); + ok(!memcmp(info->Subject.pbData, encodedCommonName, + info->Subject.cbData), "Unexpected subject\n"); + LocalFree(buf); + } +} + +static const BYTE hash[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, + 0xe, 0xf }; + +static const BYTE signedBigCert[] = { + 0x30, 0x81, 0x93, 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x00, 0x30, + 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, + 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22, 0x18, 0x0f, + 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x5a, 0x18, 0x0f, 0x31, 0x36, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, + 0x6e, 0x67, 0x00, 0x30, 0x07, 0x30, 0x02, 0x06, 0x00, 0x03, 0x01, 0x00, 0xa3, + 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, + 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, + 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, + 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }; + +static void test_encodeCert(DWORD dwEncoding) +{ + /* Note the SignatureAlgorithm must match that in the encoded cert. Note + * also that bigCert is a NULL-terminated string, so don't count its + * last byte (otherwise the signed cert won't decode.) + */ + CERT_SIGNED_CONTENT_INFO info = { { sizeof(bigCert) - 1, (BYTE *)bigCert }, + { NULL, { 0, NULL } }, { sizeof(hash), (BYTE *)hash, 0 } }; + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + ret = CryptEncodeObjectEx(dwEncoding, X509_CERT, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(bufSize == sizeof(signedBigCert), "Expected size %d, got %ld\n", + sizeof(signedBigCert), bufSize); + ok(!memcmp(buf, signedBigCert, bufSize), "Unexpected cert\n"); + LocalFree(buf); + } +} + +static void test_decodeCert(DWORD dwEncoding) +{ + BOOL ret; + BYTE *buf = NULL; + DWORD size = 0; + + ret = CryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert, + sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CERT_SIGNED_CONTENT_INFO *info = (CERT_SIGNED_CONTENT_INFO *)buf; + + ok(info->ToBeSigned.cbData == sizeof(bigCert) - 1, + "Expected cert to be %d bytes, got %ld\n", sizeof(bigCert) - 1, + info->ToBeSigned.cbData); + ok(!memcmp(info->ToBeSigned.pbData, bigCert, info->ToBeSigned.cbData), + "Unexpected cert\n"); + ok(info->Signature.cbData == sizeof(hash), + "Expected signature size %d, got %ld\n", sizeof(hash), + info->Signature.cbData); + ok(!memcmp(info->Signature.pbData, hash, info->Signature.cbData), + "Unexpected signature\n"); + LocalFree(buf); + } +} + static void test_registerOIDFunction(void) { static const WCHAR bogusDll[] = { 'b','o','g','u','s','.','d','l','l',0 }; @@ -1260,6 +1774,14 @@ test_decodeBasicConstraints(encodings[i]); test_encodeSequenceOfAny(encodings[i]); test_decodeSequenceOfAny(encodings[i]); + test_encodeExtensions(encodings[i]); + test_decodeExtensions(encodings[i]); + test_encodePublicKeyInfo(encodings[i]); + test_decodePublicKeyInfo(encodings[i]); + test_encodeCertToBeSigned(encodings[i]); + test_decodeCertToBeSigned(encodings[i]); + test_encodeCert(encodings[i]); + test_decodeCert(encodings[i]); } test_registerOIDFunction(); } diff -urN wine-20050628/dlls/crypt32/tests/main.c wine-20050725/dlls/crypt32/tests/main.c --- wine-20050628/dlls/crypt32/tests/main.c 2005-06-14 13:38:36.000000000 +0200 +++ wine-20050725/dlls/crypt32/tests/main.c 2005-07-07 22:27:55.000000000 +0200 @@ -113,8 +113,159 @@ } } +static void test_findAttribute(void) +{ + PCRYPT_ATTRIBUTE ret; + CRYPT_ATTR_BLOB blobs[] = { + { 3, "\x02\x01\x01" }, + }; + CRYPT_ATTRIBUTE attr = { "1.2.3", sizeof(blobs) / sizeof(blobs[0]), blobs }; + + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindAttribute(NULL, 0, NULL); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* crashes + SetLastError(0xdeadbeef); + ret = CertFindAttribute(NULL, 1, NULL); + */ + /* returns NULL, last error is ERROR_INVALID_PARAMETER */ + SetLastError(0xdeadbeef); + ret = CertFindAttribute(NULL, 1, &attr); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(), + GetLastError()); + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindAttribute("bogus", 1, &attr); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindAttribute("1.2.4", 1, &attr); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* succeeds, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindAttribute("1.2.3", 1, &attr); + ok(ret != NULL, "CertFindAttribute failed: %08lx\n", GetLastError()); +} + +static void test_findExtension(void) +{ + PCERT_EXTENSION ret; + CERT_EXTENSION ext = { "1.2.3", TRUE, { 3, "\x02\x01\x01" } }; + + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindExtension(NULL, 0, NULL); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* crashes + SetLastError(0xdeadbeef); + ret = CertFindExtension(NULL, 1, NULL); + */ + /* returns NULL, last error is ERROR_INVALID_PARAMETER */ + SetLastError(0xdeadbeef); + ret = CertFindExtension(NULL, 1, &ext); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(), + GetLastError()); + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindExtension("bogus", 1, &ext); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindExtension("1.2.4", 1, &ext); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* succeeds, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindExtension("1.2.3", 1, &ext); + ok(ret != NULL, "CertFindExtension failed: %08lx\n", GetLastError()); +} + +static void test_findRDNAttr(void) +{ + PCERT_RDN_ATTR ret; + CERT_RDN_ATTR attrs[] = { + { "1.2.3", CERT_RDN_IA5_STRING, { 11, "\x16\x09Juan Lang" } }, + }; + CERT_RDN rdns[] = { + { sizeof(attrs) / sizeof(attrs[0]), attrs }, + }; + CERT_NAME_INFO nameInfo = { sizeof(rdns) / sizeof(rdns[0]), rdns }; + + /* crashes + SetLastError(0xdeadbeef); + ret = CertFindRDNAttr(NULL, NULL); + */ + /* returns NULL, last error is ERROR_INVALID_PARAMETER */ + SetLastError(0xdeadbeef); + ret = CertFindRDNAttr(NULL, &nameInfo); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(), + GetLastError()); + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindRDNAttr("bogus", &nameInfo); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* returns NULL, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindRDNAttr("1.2.4", &nameInfo); + ok(ret == NULL, "Expected failure\n"); + ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n", + GetLastError()); + /* succeeds, last error not set */ + SetLastError(0xdeadbeef); + ret = CertFindRDNAttr("1.2.3", &nameInfo); + ok(ret != NULL, "CertFindRDNAttr failed: %08lx\n", GetLastError()); +} + +static void test_verifyTimeValidity(void) +{ + SYSTEMTIME sysTime; + FILETIME fileTime; + CERT_INFO info = { 0 }; + LONG ret; + + GetSystemTime(&sysTime); + SystemTimeToFileTime(&sysTime, &fileTime); + /* crashes + ret = CertVerifyTimeValidity(NULL, NULL); + ret = CertVerifyTimeValidity(&fileTime, NULL); + */ + /* Check with 0 NotBefore and NotAfter */ + ret = CertVerifyTimeValidity(&fileTime, &info); + ok(ret == 1, "Expected 1, got %ld\n", ret); + memcpy(&info.NotAfter, &fileTime, sizeof(info.NotAfter)); + /* Check with NotAfter equal to comparison time */ + ret = CertVerifyTimeValidity(&fileTime, &info); + ok(ret == 0, "Expected 0, got %ld\n", ret); + /* Check with NotBefore after comparison time */ + memcpy(&info.NotBefore, &fileTime, sizeof(info.NotBefore)); + info.NotBefore.dwLowDateTime += 5000; + ret = CertVerifyTimeValidity(&fileTime, &info); + ok(ret == -1, "Expected -1, got %ld\n", ret); +} + START_TEST(main) { testOIDToAlgID(); testAlgIDToOID(); + test_findAttribute(); + test_findExtension(); + test_findRDNAttr(); + test_verifyTimeValidity(); } diff -urN wine-20050628/dlls/d3d8/d3d8_main.c wine-20050725/dlls/d3d8/d3d8_main.c --- wine-20050628/dlls/d3d8/d3d8_main.c 2005-06-20 18:04:32.000000000 +0200 +++ wine-20050725/dlls/d3d8/d3d8_main.c 2005-07-06 21:08:05.000000000 +0200 @@ -85,7 +85,7 @@ /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */ if ( !RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey) ) { - if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, buffer, &size) ) + if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, (LPBYTE) buffer, &size) ) { if (!strcmp(buffer,"none")) { @@ -98,7 +98,7 @@ vs_mode = VS_SW; } } - if ( !RegQueryValueExA( hkey, "PixelShaderMode", 0, NULL, buffer, &size) ) + if ( !RegQueryValueExA( hkey, "PixelShaderMode", 0, NULL, (LPBYTE) buffer, &size) ) { if (!strcmp(buffer,"enabled")) { diff -urN wine-20050628/dlls/d3d8/d3d8_private.h wine-20050725/dlls/d3d8/d3d8_private.h --- wine-20050628/dlls/d3d8/d3d8_private.h 2005-06-23 13:05:25.000000000 +0200 +++ wine-20050725/dlls/d3d8/d3d8_private.h 2005-07-11 15:21:17.000000000 +0200 @@ -342,7 +342,7 @@ { /* IUnknown fields */ const IDirect3D8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* The WineD3D device */ IWineD3D *WineD3D; @@ -395,7 +395,7 @@ { /* IUnknown fields */ const IDirect3DDevice8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DDevice8 fields */ IDirect3D8Impl *direct3d8; @@ -590,7 +590,7 @@ { /* IUnknown fields */ const IDirect3DVolume8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DVolume8 fields */ IDirect3DDevice8Impl *Device; @@ -644,7 +644,7 @@ { /* IUnknown fields */ const IDirect3DSwapChain8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DSwapChain8 fields */ IDirect3DSurface8Impl *frontBuffer; @@ -686,7 +686,7 @@ { /* IUnknown fields */ const IDirect3DSurface8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DSurface8 fields */ IDirect3DDevice8Impl *Device; @@ -746,7 +746,7 @@ { /* IUnknown fields */ const IDirect3DResource8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; @@ -788,7 +788,7 @@ { /* IUnknown fields */ const IDirect3DVertexBuffer8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; @@ -836,7 +836,7 @@ { /* IUnknown fields */ const IDirect3DIndexBuffer8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; @@ -879,7 +879,7 @@ { /* IUnknown fields */ const IDirect3DBaseTexture8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; @@ -936,7 +936,7 @@ { /* IUnknown fields */ const IDirect3DCubeTexture8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; @@ -998,7 +998,7 @@ { /* IUnknown fields */ const IDirect3DTexture8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DResourc8 fields */ IDirect3DDevice8Impl *Device; @@ -1061,7 +1061,7 @@ { /* IUnknown fields */ const IDirect3DVolumeTexture8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirect3DResource8 fields */ IDirect3DDevice8Impl *Device; @@ -1149,7 +1149,7 @@ struct IDirect3DStateBlockImpl { /* IUnknown fields */ /*const IDirect3DStateBlock9Vtbl *lpVtbl;*/ - DWORD ref; + LONG ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ IDirect3DDevice8Impl* device; @@ -1238,7 +1238,7 @@ struct IDirect3DVertexShaderDeclarationImpl { /* IUnknown fields */ /*const IDirect3DVertexShaderDeclaration9Vtbl *lpVtbl;*/ - DWORD ref; + LONG ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ IDirect3DDevice8Impl* device; @@ -1274,7 +1274,7 @@ */ struct IDirect3DVertexShaderImpl { /*const IDirect3DVertexShader9Vtbl *lpVtbl;*/ - DWORD ref; + LONG ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ IDirect3DDevice8Impl* device; @@ -1323,7 +1323,7 @@ */ struct IDirect3DPixelShaderImpl { /*const IDirect3DPixelShader9Vtbl *lpVtbl;*/ - DWORD ref; + LONG ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ IDirect3DDevice8Impl* device; diff -urN wine-20050628/dlls/d3d8/device.c wine-20050725/dlls/d3d8/device.c --- wine-20050628/dlls/d3d8/device.c 2005-05-27 22:17:37.000000000 +0200 +++ wine-20050725/dlls/d3d8/device.c 2005-07-14 14:19:53.000000000 +0200 @@ -150,7 +150,7 @@ } /* Convert the D3DLIGHT8 properties into equivalent gl lights */ -void setup_light(LPDIRECT3DDEVICE8 iface, LONG Index, PLIGHTINFOEL *lightInfo) { +static void setup_light(LPDIRECT3DDEVICE8 iface, LONG Index, PLIGHTINFOEL *lightInfo) { float quad_att; float colRGBA[] = {0.0, 0.0, 0.0, 0.0}; @@ -4608,7 +4608,7 @@ vcheckGLcall("glFlush"); #ifdef EXTRA_TRACES - /** very very usefull debug code */ + /** very very useful debug code */ glXSwapBuffers(This->display, This->drawable); printf("Hit Enter to get next frame ...\n"); getchar(); diff -urN wine-20050628/dlls/d3d8/directx.c wine-20050725/dlls/d3d8/directx.c --- wine-20050628/dlls/d3d8/directx.c 2005-06-23 13:05:25.000000000 +0200 +++ wine-20050725/dlls/d3d8/directx.c 2005-06-30 20:19:33.000000000 +0200 @@ -621,7 +621,7 @@ *pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat; *pPresentationParameters->BackBufferCount = localParameters.BackBufferCount; *pPresentationParameters->MultiSampleType = localParameters.MultiSampleType; -/* *pPresentationParameters->MultiSampleQuality leave alone incase wineD3D set something internally */ +/* *pPresentationParameters->MultiSampleQuality leave alone in case wined3d set something internally */ *pPresentationParameters->SwapEffect = localParameters.SwapEffect; *pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow; *pPresentationParameters->Windowed = localParameters.Windowed; @@ -629,7 +629,7 @@ *pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat; *pPresentationParameters->Flags = localParameters.Flags; *pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz; -/* *pPresentationParameters->PresentationInterval leave alone incase wineD3D set something internally */ +/* *pPresentationParameters->PresentationInterval leave alone in case wined3d set something internally */ return res; } diff -urN wine-20050628/dlls/d3d8/drawprim.c wine-20050725/dlls/d3d8/drawprim.c --- wine-20050628/dlls/d3d8/drawprim.c 2005-04-27 10:12:23.000000000 +0200 +++ wine-20050725/dlls/d3d8/drawprim.c 2005-07-14 14:19:53.000000000 +0200 @@ -56,7 +56,7 @@ a vertex shader will be in use. Note the fvf bits returned may be split over multiple streams only if the vertex shader was created, otherwise it all relates to stream 0 */ -BOOL initializeFVF(LPDIRECT3DDEVICE8 iface, +static BOOL initializeFVF(LPDIRECT3DDEVICE8 iface, DWORD *FVFbits, /* What to expect in the FVF across all streams */ BOOL *useVertexShaderFunction) /* Should we use the vertex shader */ { @@ -109,7 +109,7 @@ } /* Issues the glBegin call for gl given the primitive type and count */ -DWORD primitiveToGl(D3DPRIMITIVETYPE PrimitiveType, +static DWORD primitiveToGl(D3DPRIMITIVETYPE PrimitiveType, DWORD NumPrimitives, GLenum *primType) { @@ -162,7 +162,7 @@ /* Ensure the appropriate material states are set up - only change state if really required */ -void init_materials(LPDIRECT3DDEVICE8 iface, BOOL isDiffuseSupplied) { +static void init_materials(LPDIRECT3DDEVICE8 iface, BOOL isDiffuseSupplied) { BOOL requires_material_reset = FALSE; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; @@ -227,7 +227,7 @@ /* Setup views - Transformed & lit if RHW, else untransformed. Only unlit if Normals are supplied Returns: Whether to restore lighting afterwards */ -BOOL primitiveInitState(LPDIRECT3DDEVICE8 iface, BOOL vtx_transformed, BOOL vtx_lit, BOOL useVS) { +static BOOL primitiveInitState(LPDIRECT3DDEVICE8 iface, BOOL vtx_transformed, BOOL vtx_lit, BOOL useVS) { BOOL isLightingOn = FALSE; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; @@ -357,7 +357,7 @@ return isLightingOn; } -void primitiveConvertToStridedData(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *strided, LONG BaseVertexIndex) { +static void primitiveConvertToStridedData(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *strided, LONG BaseVertexIndex) { short LoopThroughTo = 0; short nStream; @@ -513,7 +513,7 @@ } /* Draw a single vertex using this information */ -void draw_vertex(LPDIRECT3DDEVICE8 iface, /* interface */ +static void draw_vertex(LPDIRECT3DDEVICE8 iface, /* interface */ BOOL isXYZ, float x, float y, float z, float rhw, /* xyzn position*/ BOOL isNormal, float nx, float ny, float nz, /* normal */ BOOL isDiffuse, float *dRGBA, /* 1st colors */ @@ -662,7 +662,7 @@ * Faster GL version using pointers to data, harder to debug though * Note does not handle vertex shaders yet */ -void drawStridedFast(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, +static void drawStridedFast(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, int PrimitiveType, ULONG NumPrimitives, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { unsigned int textureNo = 0; @@ -923,7 +923,7 @@ * Actually draw using the supplied information. * Slower GL version which extracts info about each vertex in turn */ -void drawStridedSlow(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, +static void drawStridedSlow(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, int PrimitiveType, ULONG NumPrimitives, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { @@ -1233,7 +1233,7 @@ * Note: strided data is uninitialized, as we need to pass the vertex * shader directly as ordering irs yet */ -void drawStridedSoftwareVS(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, +static void drawStridedSoftwareVS(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, int PrimitiveType, ULONG NumPrimitives, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { @@ -1368,7 +1368,7 @@ checkGLcall("glEnd and previous calls"); } -void drawStridedHardwareVS(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, +static void drawStridedHardwareVS(LPDIRECT3DDEVICE8 iface, Direct3DVertexStridedData *sd, int PrimitiveType, ULONG NumPrimitives, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { diff -urN wine-20050628/dlls/d3d8/shader.c wine-20050725/dlls/d3d8/shader.c --- wine-20050628/dlls/d3d8/shader.c 2005-01-24 12:29:44.000000000 +0100 +++ wine-20050725/dlls/d3d8/shader.c 2005-07-10 19:48:20.000000000 +0200 @@ -1619,7 +1619,7 @@ } } -inline static void addline(int* lineNum, char* pgm, char* line) +inline static void addline(unsigned int* lineNum, char* pgm, char* line) { ++(*lineNum); TRACE_(d3d_hw_shader)("GL HW (%u, %u) : %s\n", *lineNum, strlen(pgm), line); diff -urN wine-20050628/dlls/d3d9/cubetexture.c wine-20050725/dlls/d3d9/cubetexture.c --- wine-20050628/dlls/d3d9/cubetexture.c 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3d9/cubetexture.c 2005-07-11 22:38:27.000000000 +0200 @@ -160,7 +160,7 @@ TRACE("(%p) Relay\n", This); /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */ - wined3ddesc.Format = &pDesc->Format; + wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format; wined3ddesc.Type = &pDesc->Type; wined3ddesc.Usage = &pDesc->Usage; wined3ddesc.Pool = &pDesc->Pool; diff -urN wine-20050628/dlls/d3d9/d3d9_private.h wine-20050725/dlls/d3d9/d3d9_private.h --- wine-20050628/dlls/d3d9/d3d9_private.h 2005-06-23 13:05:24.000000000 +0200 +++ wine-20050725/dlls/d3d9/d3d9_private.h 2005-07-08 13:29:21.000000000 +0200 @@ -186,9 +186,7 @@ typedef struct IDirect3DSurface9Impl IDirect3DSurface9Impl; typedef struct IDirect3DResource9Impl IDirect3DResource9Impl; typedef struct IDirect3DVolume9Impl IDirect3DVolume9Impl; -typedef struct IDirect3DStateBlock9Impl IDirect3DStateBlock9Impl; typedef struct IDirect3DVertexShader9Impl IDirect3DVertexShader9Impl; -typedef struct IDirect3DPixelShader9Impl IDirect3DPixelShader9Impl; typedef struct IDirect3DVertexDeclaration9Impl IDirect3DVertexDeclaration9Impl; @@ -215,30 +213,6 @@ (vec)[2] = D3DCOLOR_B(dw); \ (vec)[3] = D3DCOLOR_A(dw); -/** - * State Block for Begin/End/Capture/Create/Apply State Block - * Note: Very long winded but I do not believe gl Lists will - * resolve everything we need, so doing it manually for now - */ -typedef struct SAVEDSTATES { - BOOL lightEnable[MAX_ACTIVE_LIGHTS]; - BOOL Indices; - BOOL lights[MAX_ACTIVE_LIGHTS]; - BOOL material; - BOOL stream_source[MAX_STREAMS]; - BOOL textures[8]; - BOOL transform[HIGHEST_TRANSFORMSTATE]; - BOOL viewport; - BOOL vertexShader; - BOOL vertexShaderConstant; - BOOL vertexShaderDecl; - BOOL pixelShader; - BOOL pixelShaderConstant; - BOOL renderstate[HIGHEST_RENDER_STATE]; - BOOL texture_state[8][HIGHEST_TEXTURE_STATE]; - BOOL clipplane[MAX_CLIPPLANES]; -} SAVEDSTATES; - typedef struct D3DSHADERVECTORF { float x; float y; @@ -321,7 +295,6 @@ DWORD ref; /* IDirect3DDevice9 fields */ - IDirect3D9Impl *direct3d; IWineD3DDevice *WineD3DDevice; /* FIXME: To be sorted out during move */ @@ -331,58 +304,6 @@ IDirect3DSurface9Impl *renderTarget; IDirect3DSurface9Impl *stencilBufferTarget; - - D3DPRESENT_PARAMETERS PresentParms; - D3DDEVICE_CREATION_PARAMETERS CreateParms; - - UINT adapterNo; - D3DDEVTYPE devType; - - UINT srcBlend; - UINT dstBlend; - UINT alphafunc; - UINT stencilfunc; - - /* State block related */ - BOOL isRecordingState; - IDirect3DStateBlock9Impl *StateBlock; - IDirect3DStateBlock9Impl *UpdateStateBlock; - - /* Other required values */ - float lightPosn[MAX_ACTIVE_LIGHTS][4]; - float lightDirn[MAX_ACTIVE_LIGHTS][4]; - - /* palettes texture management */ - PALETTEENTRY palettes[MAX_PALETTES][256]; - UINT currentPalette; - - /* Optimization */ - D3DMATRIX lastProj; - D3DMATRIX lastView; - D3DMATRIX lastWorld0; - D3DMATRIX lastTexTrans[8]; - - /* OpenGL related */ - /* - GLXContext glCtx; - XVisualInfo *visInfo; - Display *display; - GLXContext render_ctx; - Drawable drawable; - Window win; - */ - HWND win_handle; - - /* OpenGL Extension related */ - - /* Cursor management */ - BOOL bCursorVisible; - UINT xHotSpot; - UINT yHotSpot; - UINT xScreenSpace; - UINT yScreenSpace; - - UINT dummyTextureName[8]; }; /* IUnknown: */ @@ -958,90 +879,14 @@ /***************************************************************************** * IDirect3DStateBlock9 implementation structure */ -struct IDirect3DStateBlock9Impl { +typedef struct IDirect3DStateBlock9Impl { /* IUnknown fields */ const IDirect3DStateBlock9Vtbl *lpVtbl; DWORD ref; /* IDirect3DStateBlock9 fields */ - IDirect3DDevice9Impl* Device; - - D3DSTATEBLOCKTYPE blockType; - - SAVEDSTATES Changed; - SAVEDSTATES Set; - - /* Light Enable */ - BOOL lightEnable[MAX_ACTIVE_LIGHTS]; - - /* ClipPlane */ - double clipplane[MAX_CLIPPLANES][4]; - - /* Stream Source */ - UINT stream_stride[MAX_STREAMS]; - IDirect3DVertexBuffer9* stream_source[MAX_STREAMS]; - BOOL streamIsUP; - - /* Indices */ - IDirect3DIndexBuffer9* pIndexData; - UINT baseVertexIndex; - - /* Texture */ - IDirect3DBaseTexture9* textures[8]; - int textureDimensions[8]; - /* Texture State Stage */ - DWORD texture_state[8][HIGHEST_TEXTURE_STATE]; - - /* RenderState */ - DWORD renderstate[HIGHEST_RENDER_STATE]; - - /* Transform */ - D3DMATRIX transforms[HIGHEST_TRANSFORMSTATE]; - - - /* ViewPort */ - D3DVIEWPORT9 viewport; - - /* Lights */ - D3DLIGHT9 lights[MAX_ACTIVE_LIGHTS]; - - /* Material */ - D3DMATERIAL9 material; - - DWORD FVF; - - /* Vertex Shader */ - IDirect3DVertexShader9* VertexShader; - - /* Vertex Shader Declaration */ - IDirect3DVertexDeclaration9Impl* vertexDecl; - - /* Pixel Shader */ - IDirect3DPixelShader9* PixelShader; - - /* Indexed Vertex Blending */ - D3DVERTEXBLENDFLAGS vertex_blend; - FLOAT tween_factor; - - /* Vertex Shader Constant */ - D3DSHADERVECTORF vertexShaderConstantF[D3D_VSHADER_MAX_CONSTANTS]; - D3DSHADERVECTORI vertexShaderConstantI[D3D_VSHADER_MAX_CONSTANTS]; - BOOL vertexShaderConstantB[D3D_VSHADER_MAX_CONSTANTS]; - /* Pixel Shader Constant */ - D3DSHADERVECTORF pixelShaderConstantF[D3D_PSHADER_MAX_CONSTANTS]; - D3DSHADERVECTORI pixelShaderConstantI[D3D_PSHADER_MAX_CONSTANTS]; - BOOL pixelShaderConstantB[D3D_PSHADER_MAX_CONSTANTS]; -}; - -/* IUnknown: */ -extern HRESULT WINAPI IDirect3DStateBlock9Impl_QueryInterface(LPDIRECT3DSTATEBLOCK9 iface, REFIID refiid, LPVOID* obj); -extern ULONG WINAPI IDirect3DStateBlock9Impl_AddRef(LPDIRECT3DSTATEBLOCK9 iface); -extern ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface); - -/* IDirect3DStateBlock9: */ -extern HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 iface, IDirect3DDevice9** ppDevice); -extern HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface); -extern HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface); + IWineD3DStateBlock *wineD3DStateBlock; +} IDirect3DStateBlock9Impl; /* --------------------------- */ @@ -1129,34 +974,15 @@ /***************************************************************************** * IDirect3DPixelShader implementation structure */ -struct IDirect3DPixelShader9Impl { +typedef struct IDirect3DPixelShader9Impl { /* IUnknown fields */ - const IDirect3DPixelShader9Vtbl *lpVtbl; - DWORD ref; - - /* IDirect3DPixelShader9 fields */ - IDirect3DDevice9Impl* Device; + const IDirect3DPixelShader9Vtbl *lpVtbl; + DWORD ref; - DWORD* function; - UINT functionLength; - DWORD version; - /* run time datas */ - /* - PSHADERDATA* data; - PSHADERINPUTDATA input; - PSHADEROUTPUTDATA output; - */ -}; - -/* IUnknown: */ -extern HRESULT WINAPI IDirect3DPixelShader9Impl_QueryInterface(LPDIRECT3DPIXELSHADER9 iface, REFIID refiid, LPVOID* obj); -extern ULONG WINAPI IDirect3DPixelShader9Impl_AddRef(LPDIRECT3DPIXELSHADER9 iface); -extern ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 iface); - -/* IDirect3DPixelShader9: */ -extern HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice); -extern HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData); + /* IDirect3DPixelShader9 fields */ + IWineD3DPixelShader *wineD3DPixelShader; +} IDirect3DPixelShader9Impl; /* --------------- */ /* IDirect3DQuery9 */ diff -urN wine-20050628/dlls/d3d9/device.c wine-20050725/dlls/d3d9/device.c --- wine-20050628/dlls/d3d9/device.c 2005-06-27 11:53:47.000000000 +0200 +++ wine-20050725/dlls/d3d9/device.c 2005-07-07 22:35:05.000000000 +0200 @@ -81,7 +81,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEVICE9 iface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : relay\n", This); + TRACE("(%p) : Relay\n", This); return IWineD3DDevice_EvictManagedResources(This->WineD3DDevice); } @@ -137,9 +137,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) copying to %p\n", This, pParameters); - memcpy(pParameters, &This->CreateParms, sizeof(D3DDEVICE_CREATION_PARAMETERS)); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, pParameters); } HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) { @@ -272,9 +271,9 @@ hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, Format, Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage, Pool,MultiSample,MultisampleQuality,pSharedHandle,(IUnknown *)object); - if (hrc != D3D_OK) { + if (hrc != D3D_OK || NULL == object->wineD3DSurface) { /* free up object */ - FIXME("(%p) call to IWineD3DDevice_CreateRenderTarget failed\n", This); + FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This); HeapFree(GetProcessHeap(), 0, object); *ppSurface = NULL; } else { @@ -375,53 +374,61 @@ /* TODO: move to wineD3D */ HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - HRESULT hr = S_OK; + IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget; + TRACE("(%p) Relay\n" , This); + return IWineD3DDevice_SetRenderTarget(This->WineD3DDevice,RenderTargetIndex,(IWineD3DSurface*)pSurface->wineD3DSurface); +} - /* If pRenderTarget == NULL, it seems to default to back buffer */ - if (pRenderTarget == NULL) pRenderTarget = (IDirect3DSurface9*) This->backBuffer; - - /* If we are trying to set what we already have, don't bother */ - if ((IDirect3DSurface9Impl*) pRenderTarget == This->renderTarget) { - TRACE("Trying to do a NOP SetRenderTarget operation\n"); - } else { - /* Otherwise, set the render target up */ - TRACE("(%p) : newRender@%p (default is backbuffer=(%p))\n", This, pRenderTarget, This->backBuffer); - hr = E_FAIL; /* not supported yet */ +HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) { + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hr = D3D_OK; + IWineD3DSurface *pRenderTarget; + + TRACE("(%p) Relay\n" , This); + + if (ppRenderTarget == NULL) { + return D3DERR_INVALIDCALL; } + hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget); - return hr; + if (hr == D3D_OK && pRenderTarget != NULL) { + IWineD3DResource_GetParent((IWineD3DResource *)pRenderTarget,(IUnknown**)ppRenderTarget); + IWineD3DResource_Release((IWineD3DResource *)pRenderTarget); + } else { + FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n"); + *ppRenderTarget = NULL; + } + return hr; } -/* TODO: move to wineD3D */ -HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) { +HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p)->returning (%p) default is backbuffer=(%p)\n", This, This->renderTarget, This->backBuffer); - *ppRenderTarget = (LPDIRECT3DSURFACE9) This->renderTarget; - IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppRenderTarget); - return D3D_OK; + IDirect3DSurface9Impl *pSurface; + + TRACE("(%p) Relay\n" , This); + + pSurface = (IDirect3DSurface9Impl*)pZStencilSurface; + return IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice,NULL==pSurface?NULL:(IWineD3DSurface*)pSurface->wineD3DSurface); } -/* TODO: move to wineD3D */ -HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) { +HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9 **ppZStencilSurface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - HRESULT hr = S_OK; - /* If we are trying to set what we already have, don't bother */ - if ((IDirect3DSurface9Impl*) pZStencilSurface == This->stencilBufferTarget) { - TRACE("Trying to do a NOP SetDepthStencilSurface operation\n"); - } else { - /* Otherwise, set the target up */ - TRACE("(%p) : newDepthStencil@%p (default is stencilbuffer=(%p))\n", This, pZStencilSurface, This->depthStencilBuffer); - hr = E_FAIL; /* not supported yet */ + HRESULT hr = D3D_OK; + IWineD3DSurface *pZStencilSurface; + + TRACE("(%p) Relay\n" , This); + if(ppZStencilSurface == NULL){ + return D3DERR_INVALIDCALL; } - return D3D_OK; -} -/* TODO: move to wineD3D */ -HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9** ppZStencilSurface) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p)->returning (%p) default is stencilbuffer=(%p)\n", This, This->stencilBufferTarget, This->depthStencilBuffer); - *ppZStencilSurface = (LPDIRECT3DSURFACE9) This->stencilBufferTarget; - if (NULL != *ppZStencilSurface) IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppZStencilSurface); + hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface); + if(hr == D3D_OK && pZStencilSurface != NULL){ + IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface); + IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface); + }else{ + FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n"); + *ppZStencilSurface = NULL; + } return D3D_OK; } diff -urN wine-20050628/dlls/d3d9/pixelshader.c wine-20050725/dlls/d3d9/pixelshader.c --- wine-20050628/dlls/d3d9/pixelshader.c 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3d9/pixelshader.c 2005-07-08 13:29:21.000000000 +0200 @@ -30,7 +30,7 @@ if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3DPixelShader9)) { - IDirect3DPixelShader9Impl_AddRef(iface); + IUnknown_AddRef(iface); *ppobj = This; return D3D_OK; } @@ -55,6 +55,7 @@ TRACE("(%p) : ReleaseRef to %ld\n", This, ref); if (ref == 0) { + IWineD3DPixelShader_Release(This->wineD3DPixelShader); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -63,16 +64,21 @@ /* IDirect3DPixelShader9 Interface follow: */ HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9 iface, IDirect3DDevice9** ppDevice) { IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface; - TRACE("(%p) : returning %p\n", This, This->Device); - *ppDevice = (LPDIRECT3DDEVICE9) This->Device; - IDirect3DDevice9Impl_AddRef(*ppDevice); + IWineD3DDevice *myDevice = NULL; + + TRACE("(%p) : Relay\n", This); + + IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice); + IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice); + IWineD3DDevice_Release(myDevice); + TRACE("(%p) returing (%p)", This, *ppDevice); return D3D_OK; } HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADER9 iface, VOID* pData, UINT* pSizeOfData) { IDirect3DPixelShader9Impl *This = (IDirect3DPixelShader9Impl *)iface; - FIXME("(%p): stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData); } @@ -89,148 +95,100 @@ /* IDirect3DDevice9 IDirect3DPixelShader9 Methods follow: */ HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9 iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); + IDirect3DPixelShader9Impl *object; + HRESULT hrc = D3D_OK; + + FIXME("(%p) Relay (disabled)\n", This); + *ppShader = NULL; return D3D_OK; + if(ppShader == NULL){ + TRACE("(%p) Invalid call\n", This); + return D3DERR_INVALIDCALL; + } + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + + if(NULL == object){ + return E_OUTOFMEMORY; + }else{ + + object->ref = 1; + object->lpVtbl = &Direct3DPixelShader9_Vtbl; + hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, &object->wineD3DPixelShader , (IUnknown *)object); + if(hrc != D3D_OK){ + FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This); + HeapFree(GetProcessHeap(), 0 , object); + *ppShader = NULL; + }else{ + *ppShader = (IDirect3DPixelShader9*) object; + } + + } + + TRACE("(%p) : returning %p\n", This, *ppShader); + return hrc; } HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9* pShader) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - - This->UpdateStateBlock->PixelShader = pShader; - This->UpdateStateBlock->Changed.pixelShader = TRUE; - This->UpdateStateBlock->Set.pixelShader = TRUE; - - /* Handle recording of state blocks */ - if (This->isRecordingState) { - TRACE("Recording... not performing anything\n"); - return D3D_OK; - } - /** - * TODO: merge HAL shaders context switching from prototype - */ + IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader; + TRACE("(%p) Relay\n", This); + IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader); return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9 iface, IDirect3DPixelShader9** ppShader) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : GetPixelShader returning %p\n", This, This->StateBlock->PixelShader); - *ppShader = This->StateBlock->PixelShader; - IDirect3DPixelShader9Impl_AddRef(*ppShader); - return D3D_OK; + IWineD3DPixelShader *object; + + HRESULT hrc = D3D_OK; + TRACE("(%p) Relay\n", This); + if(ppShader == NULL){ + TRACE("(%p) Invalid call\n", This); + return D3DERR_INVALIDCALL; + } + + hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object); + if(hrc == D3D_OK && object != NULL){ + hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader); + IWineD3DPixelShader_Release(object); + } + + TRACE("(%p) : returning %p\n", This, *ppShader); + return hrc; } HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - - if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) { - ERR("(%p) : SetPixelShaderConstant C[%u] invalid\n", This, Register); - return D3DERR_INVALIDCALL; - } - if (NULL == pConstantData) { - return D3DERR_INVALIDCALL; - } - if (Vector4fCount > 1) { - CONST FLOAT* f = pConstantData; - UINT i; - TRACE("(%p) : SetPixelShaderConstant C[%u..%u]=\n", This, Register, Register + Vector4fCount - 1); - for (i = 0; i < Vector4fCount; ++i) { - TRACE("{%f, %f, %f, %f}\n", f[0], f[1], f[2], f[3]); - f += 4; - } - } else { - const FLOAT* f = (const FLOAT*) pConstantData; - TRACE("(%p) : SetPixelShaderConstant, C[%u]={%f, %f, %f, %f}\n", This, Register, f[0], f[1], f[2], f[3]); - } - This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE; - memcpy(&This->UpdateStateBlock->pixelShaderConstantF[Register], pConstantData, Vector4fCount * 4 * sizeof(FLOAT)); - return D3D_OK; + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount); } HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - - TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4fCount); - if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) { - return D3DERR_INVALIDCALL; - } - if (NULL == pConstantData) { - return D3DERR_INVALIDCALL; - } - memcpy(pConstantData, &This->UpdateStateBlock->pixelShaderConstantF[Register], Vector4fCount * 4 * sizeof(FLOAT)); - return D3D_OK; + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount); } HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - - if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) { - ERR("(%p) : SetPixelShaderConstantI C[%u] invalid\n", This, Register); - return D3DERR_INVALIDCALL; - } - if (NULL == pConstantData) { - return D3DERR_INVALIDCALL; - } - if (Vector4iCount > 1) { - CONST int* f = pConstantData; - UINT i; - TRACE("(%p) : SetPixelShaderConstantI C[%u..%u]=\n", This, Register, Register + Vector4iCount - 1); - for (i = 0; i < Vector4iCount; ++i) { - TRACE("{%d, %d, %d, %d}\n", f[0], f[1], f[2], f[3]); - f += 4; - } - } else { - CONST int* f = pConstantData; - TRACE("(%p) : SetPixelShaderConstantI, C[%u]={%i, %i, %i, %i}\n", This, Register, f[0], f[1], f[2], f[3]); - } - This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE; - memcpy(&This->UpdateStateBlock->pixelShaderConstantI[Register], pConstantData, Vector4iCount * 4 * sizeof(int)); - return D3D_OK; + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount); } HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - - TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4iCount); - if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) { - return D3DERR_INVALIDCALL; - } - if (NULL == pConstantData) { - return D3DERR_INVALIDCALL; - } - memcpy(pConstantData, &This->UpdateStateBlock->pixelShaderConstantI[Register], Vector4iCount * 4 * sizeof(FLOAT)); - return D3D_OK; + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount); } HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - UINT i; - - if (Register + BoolCount > D3D_VSHADER_MAX_CONSTANTS) { - ERR("(%p) : SetPixelShaderConstantB C[%u] invalid\n", This, Register); - return D3DERR_INVALIDCALL; - } - if (NULL == pConstantData) { - return D3DERR_INVALIDCALL; - } - if (BoolCount > 1) { - CONST BOOL* f = pConstantData; - TRACE("(%p) : SetPixelShaderConstantB C[%u..%u]=\n", This, Register, Register + BoolCount - 1); - for (i = 0; i < BoolCount; ++i) { - TRACE("{%u}\n", f[i]); - } - } else { - CONST BOOL* f = pConstantData; - TRACE("(%p) : SetPixelShaderConstantB, C[%u]={%u}\n", This, Register, f[0]); - } - This->UpdateStateBlock->Changed.pixelShaderConstant = TRUE; - for (i = 0; i < BoolCount; ++i) { - This->UpdateStateBlock->pixelShaderConstantB[Register] = pConstantData[i]; - } - return D3D_OK; + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount); } HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, BOOL* pConstantData, UINT BoolCount) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount); } diff -urN wine-20050628/dlls/d3d9/stateblock.c wine-20050725/dlls/d3d9/stateblock.c --- wine-20050628/dlls/d3d9/stateblock.c 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3d9/stateblock.c 2005-07-11 12:59:41.000000000 +0200 @@ -2,7 +2,8 @@ * IDirect3DStateBlock9 implementation * * Copyright 2002-2003 Raphael Junqueira - * Jason Edmeades + * Copyright 2002-2003 Jason Edmeades + * Copyright 2005 Oliver Stieber * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,7 +31,7 @@ if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3DStateBlock9)) { - IDirect3DStateBlock9Impl_AddRef(iface); + IUnknown_AddRef(iface); *ppobj = This; return D3D_OK; } @@ -55,6 +56,7 @@ TRACE("(%p) : ReleaseRef to %ld\n", This, ref); if (ref == 0) { + IWineD3DStateBlock_Release(This->wineD3DStateBlock); HeapFree(GetProcessHeap(), 0, This); } return ref; @@ -63,30 +65,30 @@ /* IDirect3DStateBlock9 Interface follow: */ HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 iface, IDirect3DDevice9** ppDevice) { IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface; - TRACE("(%p) : returning %p\n", This, This->Device); - *ppDevice = (LPDIRECT3DDEVICE9) This->Device; - IDirect3DDevice9Impl_AddRef(*ppDevice); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice); } HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 iface) { IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DStateBlock_Capture(This->wineD3DStateBlock); } HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface) { IDirect3DStateBlock9Impl *This = (IDirect3DStateBlock9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DStateBlock_Apply(This->wineD3DStateBlock); } const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl = { + /* IUnknown */ IDirect3DStateBlock9Impl_QueryInterface, IDirect3DStateBlock9Impl_AddRef, IDirect3DStateBlock9Impl_Release, + /* IDirect3DStateBlock9 */ IDirect3DStateBlock9Impl_GetDevice, IDirect3DStateBlock9Impl_Capture, IDirect3DStateBlock9Impl_Apply @@ -94,20 +96,64 @@ /* IDirect3DDevice9 IDirect3DStateBlock9 Methods follow: */ -HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; +HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9 iface, D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppStateBlock) { + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + IDirect3DStateBlock9Impl* object; + HRESULT hrc = D3D_OK; + + TRACE("(%p) Relay\n", This); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DStateBlock9Impl)); + if (NULL == object) { + FIXME("(%p) Failed to allocate %d bytes\n", This, sizeof(IDirect3DStateBlock9Impl)); + *ppStateBlock = NULL; + return E_OUTOFMEMORY; + } + object->lpVtbl = &Direct3DStateBlock9_Vtbl; + object->ref = 1; + + hrc=IWineD3DDevice_CreateStateBlock(This->WineD3DDevice,Type,&object->wineD3DStateBlock,(IUnknown*)object); + if(hrc != D3D_OK){ + FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppStateBlock = NULL; + } else { + *ppStateBlock = (IDirect3DStateBlock9*)object; + } + TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, object); + return hrc; } HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9 iface) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_BeginStateBlock(This->WineD3DDevice); } HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9 iface, IDirect3DStateBlock9** ppSB) { - IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); + IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hr; + IWineD3DStateBlock* wineD3DStateBlock; + IDirect3DStateBlock9Impl* object; + + TRACE("(%p) Relay\n", This); + + /* Tell wineD3D to endstatablock before anything else (in case we run out + * of memory later and cause locking problems) + */ + hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock); + if(hr!= D3D_OK){ + FIXME("IWineD3DDevice_EndStateBlock returned an error\n"); + return hr; + } + /* allocate a new IDirectD3DStateBlock */ + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY ,sizeof(IDirect3DStateBlock9Impl)); + object->ref = 1; + object->lpVtbl = &Direct3DStateBlock9_Vtbl; + + object->wineD3DStateBlock=wineD3DStateBlock; + + *ppSB=(IDirect3DStateBlock9*)object; + TRACE("(%p)Returning %p %p\n", This, *ppSB, wineD3DStateBlock); return D3D_OK; } diff -urN wine-20050628/dlls/d3d9/surface.c wine-20050725/dlls/d3d9/surface.c --- wine-20050628/dlls/d3d9/surface.c 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3d9/surface.c 2005-07-11 22:38:27.000000000 +0200 @@ -165,7 +165,7 @@ TRACE("(%p) Relay\n", This); /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */ - wined3ddesc.Format = &pDesc->Format; + wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format; wined3ddesc.Type = &pDesc->Type; wined3ddesc.Usage = &pDesc->Usage; wined3ddesc.Pool = &pDesc->Pool; diff -urN wine-20050628/dlls/d3d9/texture.c wine-20050725/dlls/d3d9/texture.c --- wine-20050628/dlls/d3d9/texture.c 2005-06-16 22:36:12.000000000 +0200 +++ wine-20050725/dlls/d3d9/texture.c 2005-07-11 22:38:27.000000000 +0200 @@ -159,7 +159,7 @@ TRACE("(%p) Relay\n", This); /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */ - wined3ddesc.Format = &pDesc->Format; + wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format; wined3ddesc.Type = &pDesc->Type; wined3ddesc.Usage = &pDesc->Usage; wined3ddesc.Pool = &pDesc->Pool; diff -urN wine-20050628/dlls/d3d9/vertexdeclaration.c wine-20050725/dlls/d3d9/vertexdeclaration.c --- wine-20050628/dlls/d3d9/vertexdeclaration.c 2005-06-16 22:37:22.000000000 +0200 +++ wine-20050725/dlls/d3d9/vertexdeclaration.c 2005-07-07 22:45:39.000000000 +0200 @@ -22,7 +22,7 @@ #include "config.h" #include "d3d9_private.h" -WINE_DEFAULT_DEBUG_CHANNEL(d3d); +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); /* IDirect3DVertexDeclaration9 IUnknown parts follow: */ HRESULT WINAPI IDirect3DVertexDeclaration9Impl_QueryInterface(LPDIRECT3DVERTEXDECLARATION9 iface, REFIID riid, LPVOID* ppobj) { @@ -30,7 +30,7 @@ if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration9)) { - IDirect3DVertexDeclaration9Impl_AddRef(iface); + IUnknown_AddRef(iface); *ppobj = This; return D3D_OK; } @@ -65,23 +65,36 @@ HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEXDECLARATION9 iface, IDirect3DDevice9** ppDevice) { IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface; IWineD3DDevice *myDevice = NULL; - IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice); - IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice); - IWineD3DDevice_Release(myDevice); - return D3D_OK; + HRESULT hr = D3D_OK; + + TRACE("(%p) : Relay\n", iface); + + hr = IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice); + if (hr == D3D_OK && myDevice != NULL) { + hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice); + IWineD3DDevice_Release(myDevice); + } + return hr; } HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDeclaration(LPDIRECT3DVERTEXDECLARATION9 iface, D3DVERTEXELEMENT9* pDecl, UINT* pNumElements) { IDirect3DVertexDeclaration9Impl *This = (IDirect3DVertexDeclaration9Impl *)iface; - return IWineD3DVertexDeclaration_GetDeclaration(This->wineD3DVertexDeclaration, 9, pDecl, (DWORD*) pNumElements); -} + DWORD NumElements; + HRESULT hr; + TRACE("(%p) : Relay\n", iface); + hr = IWineD3DVertexDeclaration_GetDeclaration(This->wineD3DVertexDeclaration, pDecl, &NumElements); + *pNumElements = NumElements; + return hr; +} const IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl = { + /* IUnknown */ IDirect3DVertexDeclaration9Impl_QueryInterface, IDirect3DVertexDeclaration9Impl_AddRef, IDirect3DVertexDeclaration9Impl_Release, + /* IDirect3DVertexDeclaration9 */ IDirect3DVertexDeclaration9Impl_GetDevice, IDirect3DVertexDeclaration9Impl_GetDeclaration }; @@ -93,7 +106,8 @@ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DVertexDeclaration9Impl *object = NULL; HRESULT hr = D3D_OK; - + + TRACE("(%p) : Relay\n", iface); if (NULL == ppDecl) { return D3DERR_INVALIDCALL; } @@ -123,30 +137,34 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9* pDecl) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DVertexDeclaration9Impl *pDeclImpl = (IDirect3DVertexDeclaration9Impl *)pDecl; - HRESULT hr = S_OK; - /* TODO: implement stateblocks */ - FIXME("Disabled\n"); - return D3DERR_INVALIDCALL; - if (NULL != pDecl) { - hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl->wineD3DVertexDeclaration); - } + HRESULT hr = D3D_OK; + + TRACE("(%p) : Relay\n", iface); + + hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl == NULL ? NULL : pDeclImpl->wineD3DVertexDeclaration); + return hr; } HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9 iface, IDirect3DVertexDeclaration9** ppDecl) { IDirect3DDevice9Impl* This = (IDirect3DDevice9Impl*) iface; IWineD3DVertexDeclaration* pTest = NULL; - HRESULT hr = S_OK; - FIXME("Disabled\n"); - return D3DERR_INVALIDCALL; + HRESULT hr = D3D_OK; + + TRACE("(%p) : Relay+\n", iface); if (NULL == ppDecl) { return D3DERR_INVALIDCALL; } + *ppDecl = NULL; hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest); - if (SUCCEEDED(hr)) { - *ppDecl = NULL; + if (hr == D3D_OK && NULL != pTest) { + IWineD3DResource_GetParent(pTest, (IUnknown **)ppDecl); + IWineD3DResource_Release(pTest); + } else { + *ppDecl = NULL; } + TRACE("(%p) : returning %p\n", This, *ppDecl); return hr; } diff -urN wine-20050628/dlls/d3d9/vertexshader.c wine-20050725/dlls/d3d9/vertexshader.c --- wine-20050628/dlls/d3d9/vertexshader.c 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3d9/vertexshader.c 2005-07-05 18:17:31.000000000 +0200 @@ -95,16 +95,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9* pShader) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - - This->UpdateStateBlock->VertexShader = pShader; - This->UpdateStateBlock->Changed.vertexShader = TRUE; - This->UpdateStateBlock->Set.vertexShader = TRUE; + /* TODO: implement stateblocks */ + FIXME("Disabled %p\n", This); /* Handle recording of state blocks */ - if (This->isRecordingState) { - TRACE("Recording... not performing anything\n"); - return D3D_OK; - } /** * TODO: merge HAL shaders context switching from prototype */ @@ -113,15 +107,14 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9 iface, IDirect3DVertexShader9** ppShader) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : GetVertexShader returning %p\n", This, This->StateBlock->VertexShader); - *ppShader = This->StateBlock->VertexShader; - IDirect3DVertexShader9Impl_AddRef(*ppShader); + TRACE("(%p) : GetVertexShader returning\n", This); + *ppShader = NULL; return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, CONST float* pConstantData, UINT Vector4fCount) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - +#if 0 if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) { ERR("(%p) : SetVertexShaderConstant C[%u] invalid\n", This, Register); return D3DERR_INVALIDCALL; @@ -143,12 +136,14 @@ } This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE; memcpy(&This->UpdateStateBlock->vertexShaderConstantF[Register], pConstantData, Vector4fCount * 4 * sizeof(FLOAT)); +#endif + FIXME("(%p) : stub\n", This); return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9 iface, UINT Register, float* pConstantData, UINT Vector4fCount) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - +#if 0 TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4fCount); if (Register + Vector4fCount > D3D_VSHADER_MAX_CONSTANTS) { return D3DERR_INVALIDCALL; @@ -157,12 +152,14 @@ return D3DERR_INVALIDCALL; } memcpy(pConstantData, &This->UpdateStateBlock->vertexShaderConstantF[Register], Vector4fCount * 4 * sizeof(FLOAT)); +#endif + FIXME("(%p) : stub\n", This); return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, CONST int* pConstantData, UINT Vector4iCount) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - +#if 0 if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) { ERR("(%p) : SetVertexShaderConstantI C[%u] invalid\n", This, Register); return D3DERR_INVALIDCALL; @@ -184,12 +181,14 @@ } This->UpdateStateBlock->Changed.vertexShaderConstant = TRUE; memcpy(&This->UpdateStateBlock->vertexShaderConstantI[Register], pConstantData, Vector4iCount * 4 * sizeof(int)); +#endif + FIXME("(%p) : stub\n", This); return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9 iface, UINT Register, int* pConstantData, UINT Vector4iCount) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - +#if 0 TRACE("(%p) : C[%u] count=%u\n", This, Register, Vector4iCount); if (Register + Vector4iCount > D3D_VSHADER_MAX_CONSTANTS) { return D3DERR_INVALIDCALL; @@ -198,11 +197,14 @@ return D3DERR_INVALIDCALL; } memcpy(pConstantData, &This->UpdateStateBlock->vertexShaderConstantI[Register], Vector4iCount * 4 * sizeof(FLOAT)); +#endif + FIXME("(%p) : stub\n", This); return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9 iface, UINT Register, CONST BOOL* pConstantData, UINT BoolCount) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; +#if 0 UINT i; if (Register + BoolCount > D3D_VSHADER_MAX_CONSTANTS) { @@ -226,6 +228,8 @@ for (i = 0; i < BoolCount; ++i) { This->UpdateStateBlock->vertexShaderConstantB[Register] = pConstantData[i]; } +#endif + FIXME("(%p) : stub\n", This); return D3D_OK; } diff -urN wine-20050628/dlls/d3dx8/d3dx8core_private.h wine-20050725/dlls/d3dx8/d3dx8core_private.h --- wine-20050628/dlls/d3dx8/d3dx8core_private.h 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3dx8/d3dx8core_private.h 2005-07-11 15:21:17.000000000 +0200 @@ -47,7 +47,7 @@ { /* IUnknown fields */ const ID3DXBufferVtbl *lpVtbl; - DWORD ref; + LONG ref; /* ID3DXBuffer fields */ DWORD *buffer; @@ -79,7 +79,7 @@ { /* IUnknown fields */ const ID3DXFontVtbl *lpVtbl; - DWORD ref; + LONG ref; /* ID3DXFont fields */ }; diff -urN wine-20050628/dlls/d3dxof/d3dxof_private.h wine-20050725/dlls/d3dxof/d3dxof_private.h --- wine-20050628/dlls/d3dxof/d3dxof_private.h 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3dxof/d3dxof_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -37,37 +37,37 @@ typedef struct { IDirectXFile lpVtbl; - ULONG ref; + LONG ref; } IDirectXFileImpl; typedef struct { IDirectXFileBinary lpVtbl; - ULONG ref; + LONG ref; } IDirectXFileBinaryImpl; typedef struct { IDirectXFileData lpVtbl; - ULONG ref; + LONG ref; } IDirectXFileDataImpl; typedef struct { IDirectXFileDataReference lpVtbl; - ULONG ref; + LONG ref; } IDirectXFileDataReferenceImpl; typedef struct { IDirectXFileObject lpVtbl; - ULONG ref; + LONG ref; } IDirectXFileObjectImpl; typedef struct { IDirectXFileEnumObject lpVtbl; - ULONG ref; + LONG ref; } IDirectXFileEnumObjectImpl; typedef struct { IDirectXFileSaveObject lpVtbl; - ULONG ref; + LONG ref; } IDirectXFileSaveObjectImpl; HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj); diff -urN wine-20050628/dlls/d3dxof/main.c wine-20050725/dlls/d3dxof/main.c --- wine-20050628/dlls/d3dxof/main.c 2005-05-27 22:17:36.000000000 +0200 +++ wine-20050725/dlls/d3dxof/main.c 2005-07-12 19:03:19.000000000 +0200 @@ -43,7 +43,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dxof); -static DWORD dll_ref = 0; +static LONG dll_ref = 0; /* For the moment, do nothing here. */ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) @@ -64,7 +64,7 @@ typedef struct { IClassFactory ITF_IClassFactory; - DWORD ref; + LONG ref; HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); } IClassFactoryImpl; diff -urN wine-20050628/dlls/dbghelp/elf_module.c wine-20050725/dlls/dbghelp/elf_module.c --- wine-20050628/dlls/dbghelp/elf_module.c 2005-05-17 16:32:55.000000000 +0200 +++ wine-20050725/dlls/dbghelp/elf_module.c 2005-07-07 14:03:57.000000000 +0200 @@ -786,9 +786,7 @@ {"__wine_spec_delayed_import_thunks", THUNK_ORDINAL_LOAD, 0, 0}, /* delayed inter DLL calls */ {"__wine_delay_load", THUNK_ORDINAL_LOAD, 0, 0}, /* delayed inter DLL calls */ {"__wine_spec_thunk_text_16", -16, 0, 0}, /* 16 => 32 thunks */ - {"__wine_spec_thunk_data_16", -16, 0, 0}, /* 16 => 32 thunks */ {"__wine_spec_thunk_text_32", -32, 0, 0}, /* 32 => 16 thunks */ - {"__wine_spec_thunk_data_32", -32, 0, 0}, /* 32 => 16 thunks */ {NULL, 0, 0, 0} }; diff -urN wine-20050628/dlls/ddraw/d3d_private.h wine-20050725/dlls/ddraw/d3d_private.h --- wine-20050628/dlls/ddraw/d3d_private.h 2005-06-12 12:43:11.000000000 +0200 +++ wine-20050725/dlls/ddraw/d3d_private.h 2005-07-11 15:21:17.000000000 +0200 @@ -67,7 +67,7 @@ struct IDirect3DLightImpl { ICOM_VFIELD_MULTI(IDirect3DLight); - DWORD ref; + LONG ref; /* IDirect3DLight fields */ IDirectDrawImpl *d3d; /* If this light is active for one viewport, put the viewport here */ @@ -95,7 +95,7 @@ ICOM_VFIELD_MULTI(IDirect3DMaterial3); ICOM_VFIELD_MULTI(IDirect3DMaterial2); ICOM_VFIELD_MULTI(IDirect3DMaterial); - DWORD ref; + LONG ref; /* IDirect3DMaterial2 fields */ IDirectDrawImpl *d3d; IDirect3DDeviceImpl *active_device; @@ -111,7 +111,7 @@ struct IDirect3DViewportImpl { ICOM_VFIELD_MULTI(IDirect3DViewport3); - DWORD ref; + LONG ref; /* IDirect3DViewport fields */ IDirectDrawImpl *d3d; /* If this viewport is active for one device, put the device here */ @@ -145,7 +145,7 @@ struct IDirect3DExecuteBufferImpl { ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer); - DWORD ref; + LONG ref; /* IDirect3DExecuteBuffer fields */ IDirectDrawImpl *d3d; IDirect3DDeviceImpl* d3ddev; @@ -195,7 +195,7 @@ ICOM_VFIELD_MULTI(IDirect3DDevice3); ICOM_VFIELD_MULTI(IDirect3DDevice2); ICOM_VFIELD_MULTI(IDirect3DDevice); - DWORD ref; + LONG ref; /* Version of the Direct3D object from which the device has been created */ DWORD version; @@ -260,7 +260,7 @@ { ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7); ICOM_VFIELD_MULTI(IDirect3DVertexBuffer); - DWORD ref; + LONG ref; IDirectDrawImpl *d3d; D3DVERTEXBUFFERDESC desc; LPVOID *vertices; diff -urN wine-20050628/dlls/ddraw/ddraw_private.h wine-20050725/dlls/ddraw/ddraw_private.h --- wine-20050628/dlls/ddraw/ddraw_private.h 2005-06-02 12:33:07.000000000 +0200 +++ wine-20050725/dlls/ddraw/ddraw_private.h 2005-07-24 18:17:29.000000000 +0200 @@ -86,7 +86,7 @@ ICOM_VFIELD_MULTI(IDirect3D2); ICOM_VFIELD_MULTI(IDirect3D); - DWORD ref; + LONG ref; /* TRUE if created via DirectDrawCreateEx or CoCreateInstance, * FALSE if created via DirectDrawCreate. */ @@ -198,7 +198,7 @@ { /* IUnknown fields */ ICOM_VFIELD_MULTI(IDirectDrawPalette); - DWORD ref; + LONG ref; DDRAWI_DDRAWPALETTE_LCL local; DDRAWI_DDRAWPALETTE_GBL global; @@ -226,7 +226,7 @@ { /* IUnknown fields */ ICOM_VFIELD_MULTI(IDirectDrawClipper); - DWORD ref; + LONG ref; /* IDirectDrawClipper fields */ HWND hWnd; @@ -248,7 +248,7 @@ ICOM_VFIELD_MULTI(IDirectDrawGammaControl); ICOM_VFIELD_MULTI(IDirect3DTexture2); ICOM_VFIELD_MULTI(IDirect3DTexture); - DWORD ref; + LONG ref; struct IDirectDrawSurfaceImpl* attached; /* attached surfaces */ @@ -448,9 +448,6 @@ /***************************************************************************** * IDirectDrawClipper declarations */ -HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, - LPDIRECTDRAWCLIPPER* ppClipper, - LPUNKNOWN pUnkOuter); HRESULT DDRAW_CreateClipper(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppObj); void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This); diff -urN wine-20050628/dlls/ddraw/device_opengl.c wine-20050725/dlls/ddraw/device_opengl.c --- wine-20050628/dlls/ddraw/device_opengl.c 2005-06-12 12:43:11.000000000 +0200 +++ wine-20050725/dlls/ddraw/device_opengl.c 2005-07-03 13:21:32.000000000 +0200 @@ -4094,7 +4094,7 @@ object->max_active_lights = opengl_device_caps.dwMaxActiveLights; object->light_parameters = NULL; object->active_lights = HeapAlloc(GetProcessHeap(), 0, - object->max_active_lights * sizeof(BOOLEAN)); + object->max_active_lights * sizeof(object->active_lights[0])); /* Fill the active light array with ~0, which is used to indicate an invalid light index. We don't use 0, because it's a valid light index. */ for (light=0; light < object->max_active_lights; light++) diff -urN wine-20050628/dlls/ddraw/main.c wine-20050725/dlls/ddraw/main.c --- wine-20050628/dlls/ddraw/main.c 2005-06-06 17:51:50.000000000 +0200 +++ wine-20050725/dlls/ddraw/main.c 2005-07-11 15:21:17.000000000 +0200 @@ -450,7 +450,7 @@ typedef struct { ICOM_VFIELD_MULTI(IClassFactory); - DWORD ref; + LONG ref; HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj); } IClassFactoryImpl; diff -urN wine-20050628/dlls/ddraw/surface_dib.c wine-20050725/dlls/ddraw/surface_dib.c --- wine-20050628/dlls/ddraw/surface_dib.c 2005-06-05 19:50:49.000000000 +0200 +++ wine-20050725/dlls/ddraw/surface_dib.c 2005-07-11 12:59:41.000000000 +0200 @@ -476,7 +476,7 @@ *((DWORD*)(dst+y*pitch+x*(is16?2:4))) = pixel; } } -#if 0 /* Usefull for debugging */ +#if 0 /* Useful for debugging */ { static int idx; char texname[255]; diff -urN wine-20050628/dlls/devenum/devenum_private.h wine-20050725/dlls/devenum/devenum_private.h --- wine-20050628/dlls/devenum/devenum_private.h 2005-05-30 12:01:11.000000000 +0200 +++ wine-20050725/dlls/devenum/devenum_private.h 2005-07-11 16:24:53.000000000 +0200 @@ -69,7 +69,7 @@ typedef struct { const IEnumMonikerVtbl *lpVtbl; - DWORD ref; + LONG ref; DWORD index; HKEY hkey; } EnumMonikerImpl; @@ -77,7 +77,7 @@ typedef struct { const IMonikerVtbl *lpVtbl; - ULONG ref; + LONG ref; HKEY hkey; } MediaCatMoniker; diff -urN wine-20050628/dlls/devenum/mediacatenum.c wine-20050725/dlls/devenum/mediacatenum.c --- wine-20050628/dlls/devenum/mediacatenum.c 2005-05-30 12:01:11.000000000 +0200 +++ wine-20050725/dlls/devenum/mediacatenum.c 2005-07-11 16:24:53.000000000 +0200 @@ -41,7 +41,7 @@ typedef struct { const IPropertyBagVtbl *lpVtbl; - DWORD ref; + LONG ref; HKEY hkey; } RegPropBagImpl; @@ -105,7 +105,7 @@ IErrorLog* pErrorLog) { LPVOID pData = NULL; - LONG received; + DWORD received; DWORD type = 0; RegPropBagImpl *This = (RegPropBagImpl *)iface; HRESULT res = S_OK; @@ -124,7 +124,7 @@ pData = HeapAlloc(GetProcessHeap(), 0, received); /* work around a GCC bug that occurs here unless we use the reswin32 variable as well */ - reswin32 = RegQueryValueExW(This->hkey, pszPropName, NULL, &type, pData, &received); + reswin32 = RegQueryValueExW(This->hkey, pszPropName, NULL, &type, (LPBYTE)pData, &received); res = HRESULT_FROM_WIN32(reswin32); } diff -urN wine-20050628/dlls/dinput/device_private.h wine-20050725/dlls/dinput/device_private.h --- wine-20050628/dlls/dinput/device_private.h 2005-05-30 12:01:11.000000000 +0200 +++ wine-20050725/dlls/dinput/device_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -31,7 +31,7 @@ struct IDirectInputDevice2AImpl { const IDirectInputDevice2AVtbl *lpVtbl; - DWORD ref; + LONG ref; GUID guid; }; diff -urN wine-20050628/dlls/dinput/joystick_linux.c wine-20050725/dlls/dinput/joystick_linux.c --- wine-20050628/dlls/dinput/joystick_linux.c 2005-06-14 14:34:33.000000000 +0200 +++ wine-20050725/dlls/dinput/joystick_linux.c 2005-07-05 13:05:51.000000000 +0200 @@ -385,7 +385,7 @@ return DI_OK; } -void calculate_ids(JoystickImpl* device) +static void calculate_ids(JoystickImpl* device) { int i; int axis = 0; @@ -830,7 +830,7 @@ return DI_NOEFFECT; } -LONG map_axis(JoystickImpl * This, short val, short index) +static LONG map_axis(JoystickImpl * This, short val, short index) { double fval = val; double fmin = This->props[index].lMin; @@ -848,7 +848,7 @@ } /* convert wine format offset to user format object index */ -int offset_to_object(JoystickImpl *This, int offset) +static int offset_to_object(JoystickImpl *This, int offset) { int i; @@ -1093,7 +1093,7 @@ return hr; } -int find_property(JoystickImpl * This, LPCDIPROPHEADER ph) +static int find_property(JoystickImpl * This, LPCDIPROPHEADER ph) { int i; if (ph->dwHow == DIPH_BYOFFSET) { diff -urN wine-20050628/dlls/dinput/joystick_linuxinput.c wine-20050725/dlls/dinput/joystick_linuxinput.c --- wine-20050628/dlls/dinput/joystick_linuxinput.c 2005-05-30 12:01:11.000000000 +0200 +++ wine-20050725/dlls/dinput/joystick_linuxinput.c 2005-07-22 11:05:19.000000000 +0200 @@ -71,7 +71,7 @@ struct JoystickImpl { const void *lpVtbl; - DWORD ref; + LONG ref; GUID guid; @@ -468,7 +468,9 @@ if (xmin == xmax) return val; /* map the value from the hmin-hmax range into the wmin-wmax range */ - ret = (val * (wmax-wmin)) / (hmax-hmin) + wmin; + ret = ((val-hmin) * (wmax-wmin)) / (hmax-hmin) + wmin; + + TRACE("xmin=%d xmax=%d hmin=%d hmax=%d wmin=%d wmax=%d val=%d ret=%d\n", xmin, xmax, hmin, hmax, wmin, wmax, val, ret); #if 0 /* deadzone doesn't work comfortably enough right now. needs more testing*/ @@ -492,6 +494,8 @@ ji->js.lRx = map_axis(ji, ABS_RX, ji->axes[ABS_RX][AXE_ABS]); ji->js.lRy = map_axis(ji, ABS_RY, ji->axes[ABS_RY][AXE_ABS]); ji->js.lRz = map_axis(ji, ABS_RZ, ji->axes[ABS_RZ][AXE_ABS]); + ji->js.rglSlider[0] = map_axis(ji, ABS_THROTTLE, ji->axes[ABS_THROTTLE][AXE_ABS]); + ji->js.rglSlider[1] = map_axis(ji, ABS_RUDDER, ji->axes[ABS_RUDDER ][AXE_ABS]); } static void joy_polldev(JoystickImpl *This) { @@ -613,6 +617,14 @@ This->js.lRz = map_axis(This,ABS_RZ,ie.value); GEN_EVENT(DIJOFS_RZ,This->js.lRz,ie.time.tv_usec,(This->dinput->evsequence)++); break; + case ABS_THROTTLE: + This->js.rglSlider[0] = map_axis(This,ABS_THROTTLE,ie.value); + GEN_EVENT(DIJOFS_SLIDER(0),This->js.rglSlider[0],ie.time.tv_usec,(This->dinput->evsequence)++); + break; + case ABS_RUDDER: + This->js.rglSlider[1] = map_axis(This,ABS_RUDDER,ie.value); + GEN_EVENT(DIJOFS_SLIDER(1),This->js.rglSlider[1],ie.time.tv_usec,(This->dinput->evsequence)++); + break; default: FIXME("unhandled joystick axe event (code %d, value %d)\n",ie.code,ie.value); break; @@ -701,6 +713,8 @@ case 12: /* Rx */ case 16: /* Ry */ case 20: /* Rz */ + case 24: /* Slider 0 -> Throttle */ + case 28: /* Slider 1 -> Rudder */ This->wantmin[ph->dwObj/4] = pr->lMin; This->wantmax[ph->dwObj/4] = pr->lMax; break; @@ -846,6 +860,10 @@ ddoi.guidType = GUID_Slider; ddoi.dwOfs = DIJOFS_SLIDER(0); break; + case ABS_RUDDER: + ddoi.guidType = GUID_Slider; + ddoi.dwOfs = DIJOFS_SLIDER(1); + break; default: FIXME("unhandled abs axis %d, ignoring!\n",i); } diff -urN wine-20050628/dlls/dinput/tests/joystick.c wine-20050725/dlls/dinput/tests/joystick.c --- wine-20050628/dlls/dinput/tests/joystick.c 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/dinput/tests/joystick.c 2005-07-11 19:58:52.000000000 +0200 @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define STRICT #define DIRECTINPUT_VERSION 0x0700 #define NONAMELESSSTRUCT @@ -24,6 +23,7 @@ #include #include +#include #include #include "wine/test.h" @@ -139,6 +139,7 @@ DIDEVICEINSTANCE inst; DIDEVICEINSTANCE_DX3 inst3; HWND hWnd = get_hwnd(); + char oldstate[248], curstate[248]; ok(data->version > 0x0300, "Joysticks not supported in version 0x%04lx\n", data->version); @@ -262,15 +263,16 @@ count = 1; trace("\n"); + oldstate[0]='\0'; for (i = 0; i < count; i++) { hr = IDirectInputDevice_GetDeviceState(pJoystick, sizeof(DIJOYSTATE2), &js); ok(hr==DI_OK,"IDirectInputDevice_GetDeviceState() failed: %s\n", DXGetErrorString8(hr)); if (hr != DI_OK) break; - trace("X%5ld Y%5ld Z%5ld Rx%5ld Ry%5ld Rz%5ld " + sprintf(curstate, "X%5ld Y%5ld Z%5ld Rx%5ld Ry%5ld Rz%5ld " "S0%5ld S1%5ld POV0%5ld POV1%5ld POV2%5ld POV3%5ld " - "B %d %d %d %d %d %d %d %d %d %d %d %d\r", + "B %d %d %d %d %d %d %d %d %d %d %d %d\n", js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz, js.rglSlider[0], js.rglSlider[1], js.rgdwPOV[0], js.rgdwPOV[1], js.rgdwPOV[2], js.rgdwPOV[3], @@ -278,6 +280,11 @@ js.rgbButtons[3]>>7, js.rgbButtons[4]>>7, js.rgbButtons[5]>>7, js.rgbButtons[6]>>7, js.rgbButtons[7]>>7, js.rgbButtons[8]>>7, js.rgbButtons[9]>>7, js.rgbButtons[10]>>7, js.rgbButtons[11]>>7); + if (strcmp(oldstate, curstate) != 0) + { + trace(curstate); + strcpy(oldstate, curstate); + } Sleep(100); } trace("\n"); diff -urN wine-20050628/dlls/dinput/tests/keyboard.c wine-20050725/dlls/dinput/tests/keyboard.c --- wine-20050628/dlls/dinput/tests/keyboard.c 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/dinput/tests/keyboard.c 2005-07-11 16:24:17.000000000 +0200 @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define STRICT #define DIRECTINPUT_VERSION 0x0700 #define NONAMELESSSTRUCT diff -urN wine-20050628/dlls/dinput/tests/mouse.c wine-20050725/dlls/dinput/tests/mouse.c --- wine-20050628/dlls/dinput/tests/mouse.c 2005-06-21 22:53:14.000000000 +0200 +++ wine-20050725/dlls/dinput/tests/mouse.c 2005-07-11 16:24:17.000000000 +0200 @@ -16,7 +16,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define STRICT #define DIRECTINPUT_VERSION 0x0700 #define NONAMELESSSTRUCT diff -urN wine-20050628/dlls/dmband/dmband_private.h wine-20050725/dlls/dmband/dmband_private.h --- wine-20050628/dlls/dmband/dmband_private.h 2005-06-22 14:01:39.000000000 +0200 +++ wine-20050725/dlls/dmband/dmband_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -92,7 +92,7 @@ const IDirectMusicBandVtbl *BandVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicBandImpl fields */ LPDMUS_OBJECTDESC pDesc; @@ -108,7 +108,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicBandTrack fields */ LPDMUS_OBJECTDESC pDesc; diff -urN wine-20050628/dlls/dmcompos/dmcompos_private.h wine-20050725/dlls/dmcompos/dmcompos_private.h --- wine-20050628/dlls/dmcompos/dmcompos_private.h 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/dmcompos/dmcompos_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -67,7 +67,7 @@ const IDirectMusicChordMapVtbl *ChordMapVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicChordMapImpl fields */ LPDMUS_OBJECTDESC pDesc; @@ -89,7 +89,7 @@ struct IDirectMusicComposerImpl { /* IUnknown fields */ const IDirectMusicComposerVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicComposerImpl fields */ }; @@ -106,7 +106,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicChordMapTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -127,7 +127,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSignPostTrack fields */ LPDMUS_OBJECTDESC pDesc; diff -urN wine-20050628/dlls/dmime/dmime_private.h wine-20050725/dlls/dmime/dmime_private.h --- wine-20050628/dlls/dmime/dmime_private.h 2005-06-21 11:44:28.000000000 +0200 +++ wine-20050725/dlls/dmime/dmime_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -132,7 +132,7 @@ struct IDirectMusicPerformance8Impl { /* IUnknown fields */ const IDirectMusicPerformance8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicPerformanceImpl fields */ IDirectMusic8* pDirectMusic; @@ -176,7 +176,7 @@ const IDirectMusicSegment8Vtbl *SegmentVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSegment8Impl fields */ LPDMUS_OBJECTDESC pDesc; @@ -191,7 +191,7 @@ struct IDirectMusicSegmentState8Impl { /* IUnknown fields */ const IDirectMusicSegmentState8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSegmentState8Impl fields */ }; @@ -205,7 +205,7 @@ const IDirectMusicGraphVtbl *GraphVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicGraphImpl fields */ LPDMUS_OBJECTDESC pDesc; @@ -222,7 +222,7 @@ const IDirectMusicAudioPathVtbl *AudioPathVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicAudioPathImpl fields */ LPDMUS_OBJECTDESC pDesc; @@ -241,7 +241,7 @@ struct IDirectMusicTool8Impl { /* IUnknown fields */ const IDirectMusicTool8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicTool8Impl fields */ }; @@ -252,7 +252,7 @@ struct IDirectMusicPatternTrackImpl { /* IUnknown fields */ const IDirectMusicPatternTrackVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicPatternTrackImpl fields */ }; @@ -266,7 +266,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicLyricsTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -280,7 +280,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicMarkerTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -294,7 +294,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicParamControlTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -308,7 +308,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSegTriggerTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -324,7 +324,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSeqTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -338,7 +338,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSysExTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -352,7 +352,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicTempoTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -368,7 +368,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicTimeSigTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -382,7 +382,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicWaveTrack fields */ LPDMUS_OBJECTDESC pDesc; diff -urN wine-20050628/dlls/dmime/tempotrack.c wine-20050725/dlls/dmime/tempotrack.c --- wine-20050628/dlls/dmime/tempotrack.c 2005-06-21 11:44:28.000000000 +0200 +++ wine-20050725/dlls/dmime/tempotrack.c 2005-07-11 12:59:41.000000000 +0200 @@ -117,7 +117,7 @@ ERR(": no more memory\n"); return E_OUTOFMEMORY; } - /** TODO real fill usefull datas */ + /** TODO real fill useful datas */ pState->dummy = 0; *ppStateData = pState; return S_OK; diff -urN wine-20050628/dlls/dmloader/dmloader_main.c wine-20050725/dlls/dmloader/dmloader_main.c --- wine-20050628/dlls/dmloader/dmloader_main.c 2004-05-13 02:00:22.000000000 +0200 +++ wine-20050725/dlls/dmloader/dmloader_main.c 2005-07-05 13:02:54.000000000 +0200 @@ -21,8 +21,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmloader); -DWORD dwDirectMusicContainer = 0; -DWORD dwDirectMusicLoader = 0; +LONG dwDirectMusicContainer = 0; +LONG dwDirectMusicLoader = 0; /****************************************************************** * DllMain diff -urN wine-20050628/dlls/dmloader/dmloader_private.h wine-20050725/dlls/dmloader/dmloader_private.h --- wine-20050628/dlls/dmloader/dmloader_private.h 2005-05-30 12:01:10.000000000 +0200 +++ wine-20050725/dlls/dmloader/dmloader_private.h 2005-07-05 13:02:54.000000000 +0200 @@ -45,8 +45,8 @@ #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field)) /* dmloader.dll global (for DllCanUnloadNow) */ -extern DWORD dwDirectMusicLoader; /* number of DirectMusicLoader(CF) instances */ -extern DWORD dwDirectMusicContainer; /* number of DirectMusicContainer(CF) instances */ +extern LONG dwDirectMusicLoader; /* number of DirectMusicLoader(CF) instances */ +extern LONG dwDirectMusicContainer; /* number of DirectMusicContainer(CF) instances */ /***************************************************************************** * Interfaces @@ -87,7 +87,7 @@ struct IDirectMusicLoaderCF { /* IUnknown fields */ const IClassFactoryVtbl *lpVtbl; - DWORD dwRef; + LONG dwRef; }; /* IUnknown / IClassFactory: */ @@ -100,7 +100,7 @@ struct IDirectMusicContainerCF { /* IUnknown fields */ const IClassFactoryVtbl *lpVtbl; - DWORD dwRef; + LONG dwRef; }; /* IUnknown / IClassFactory: */ @@ -130,7 +130,7 @@ /* VTABLEs */ const IDirectMusicLoader8Vtbl *LoaderVtbl; /* reference counter */ - DWORD dwRef; + LONG dwRef; /* simple cache (linked list) */ struct list *pObjects; /* settings for certain object classes */ @@ -162,7 +162,7 @@ const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; /* reference counter */ - DWORD dwRef; + LONG dwRef; /* stream */ LPSTREAM pStream; /* header */ @@ -191,7 +191,7 @@ const IStreamVtbl *StreamVtbl; const IDirectMusicGetLoaderVtbl *GetLoaderVtbl; /* reference counter */ - DWORD dwRef; + LONG dwRef; /* file */ WCHAR wzFileName[MAX_PATH]; /* for clone */ HANDLE hFile; @@ -217,7 +217,7 @@ const IStreamVtbl *StreamVtbl; const IDirectMusicGetLoaderVtbl *GetLoaderVtbl; /* reference counter */ - DWORD dwRef; + LONG dwRef; /* data */ LPBYTE pbMemData; LONGLONG llMemLength; @@ -245,7 +245,7 @@ const IStreamVtbl *StreamVtbl; const IDirectMusicGetLoaderVtbl *GetLoaderVtbl; /* reference counter */ - DWORD dwRef; + LONG dwRef; /* stream */ LPSTREAM pStream; /* loader */ diff -urN wine-20050628/dlls/dmloader/loader.c wine-20050725/dlls/dmloader/loader.c --- wine-20050628/dlls/dmloader/loader.c 2005-05-30 12:01:10.000000000 +0200 +++ wine-20050725/dlls/dmloader/loader.c 2005-07-05 13:02:54.000000000 +0200 @@ -827,7 +827,7 @@ char szPath[MAX_PATH]; if ((RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic" , 0, KEY_READ, &hkDM) != ERROR_SUCCESS) || - (RegQueryValueExA (hkDM, "GMFilePath", NULL, &returnType, szPath, &sizeOfReturnBuffer) != ERROR_SUCCESS)) { + (RegQueryValueExA (hkDM, "GMFilePath", NULL, &returnType, (LPBYTE) szPath, &sizeOfReturnBuffer) != ERROR_SUCCESS)) { WARN(": registry entry missing\n" ); return E_FAIL; } diff -urN wine-20050628/dlls/dmscript/dmscript_private.h wine-20050725/dlls/dmscript/dmscript_private.h --- wine-20050628/dlls/dmscript/dmscript_private.h 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/dmscript/dmscript_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -65,7 +65,7 @@ const IDirectMusicScriptVtbl *ScriptVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicScriptImpl fields */ IDirectMusicPerformance* pPerformance; @@ -94,7 +94,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicScriptTrack fields */ LPDMUS_OBJECTDESC pDesc; diff -urN wine-20050628/dlls/dmstyle/dmstyle_private.h wine-20050725/dlls/dmstyle/dmstyle_private.h --- wine-20050628/dlls/dmstyle/dmstyle_private.h 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/dmstyle/dmstyle_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -109,7 +109,7 @@ const IDirectMusicStyle8Vtbl *StyleVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicStyle8Impl fields */ LPDMUS_OBJECTDESC pDesc; @@ -138,7 +138,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicAuditionTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -160,7 +160,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicChordTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -189,7 +189,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicCommandTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -213,7 +213,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicMelodyFormulationTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -235,7 +235,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicMotifTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -257,7 +257,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicMuteTrack fields */ LPDMUS_OBJECTDESC pDesc; @@ -279,7 +279,7 @@ const IUnknownVtbl *UnknownVtbl; const IDirectMusicTrack8Vtbl *TrackVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicStyleTrack fields */ LPDMUS_OBJECTDESC pDesc; diff -urN wine-20050628/dlls/dmsynth/dmsynth_private.h wine-20050725/dlls/dmsynth/dmsynth_private.h --- wine-20050628/dlls/dmsynth/dmsynth_private.h 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/dmsynth/dmsynth_private.h 2005-07-12 19:03:19.000000000 +0200 @@ -58,7 +58,7 @@ struct IDirectMusicSynth8Impl { /* IUnknown fields */ const IDirectMusicSynth8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSynth8 fields */ DMUS_PORTCAPS pCaps; @@ -77,7 +77,7 @@ struct IDirectMusicSynthSinkImpl { /* IUnknown fields */ const IDirectMusicSynthSinkVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicSynthSinkImpl fields */ }; diff -urN wine-20050628/dlls/dmusic/dmusic.c wine-20050725/dlls/dmusic/dmusic.c --- wine-20050628/dlls/dmusic/dmusic.c 2005-06-01 21:57:43.000000000 +0200 +++ wine-20050725/dlls/dmusic/dmusic.c 2005-07-07 14:08:43.000000000 +0200 @@ -214,7 +214,7 @@ TRACE("(%p, %p)\n", This, pguidPort); if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\DirectMusic\\Defaults" , 0, KEY_READ, &hkGUID) != ERROR_SUCCESS) || - (RegQueryValueExA(hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS)) + (RegQueryValueExA(hkGUID, "DefaultOutputPort", NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer) != ERROR_SUCCESS)) { WARN(": registry entry missing\n" ); *pguidPort = CLSID_DirectMusicSynth; diff -urN wine-20050628/dlls/dmusic/dmusic_private.h wine-20050725/dlls/dmusic/dmusic_private.h --- wine-20050628/dlls/dmusic/dmusic_private.h 2005-06-20 16:18:05.000000000 +0200 +++ wine-20050725/dlls/dmusic/dmusic_private.h 2005-07-12 21:21:37.000000000 +0200 @@ -95,7 +95,7 @@ struct IDirectMusic8Impl { /* IUnknown fields */ const IDirectMusic8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicImpl fields */ IReferenceClockImpl* pMasterClock; @@ -112,7 +112,7 @@ struct IDirectMusicBufferImpl { /* IUnknown fields */ const IDirectMusicBufferVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicBufferImpl fields */ }; @@ -126,7 +126,7 @@ struct IDirectMusicDownloadedInstrumentImpl { /* IUnknown fields */ const IDirectMusicDownloadedInstrumentVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicDownloadedInstrumentImpl fields */ }; @@ -142,7 +142,7 @@ struct IDirectMusicDownloadImpl { /* IUnknown fields */ const IDirectMusicDownloadVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicDownloadImpl fields */ }; @@ -156,7 +156,7 @@ struct IDirectMusicPortDownloadImpl { /* IUnknown fields */ const IDirectMusicPortDownloadVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicPortDownloadImpl fields */ }; @@ -170,7 +170,7 @@ struct IDirectMusicPortImpl { /* IUnknown fields */ const IDirectMusicPortVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicPortImpl fields */ IDirectSound* pDirectSound; @@ -191,7 +191,7 @@ struct IDirectMusicThruImpl { /* IUnknown fields */ const IDirectMusicThruVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectMusicThruImpl fields */ }; @@ -205,7 +205,7 @@ struct IReferenceClockImpl { /* IUnknown fields */ const IReferenceClockVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IReferenceClockImpl fields */ REFERENCE_TIME rtTime; @@ -233,7 +233,7 @@ const IDirectMusicCollectionVtbl *CollectionVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicCollectionImpl fields */ IStream *pStm; /* stream from which we load collection and later instruments */ @@ -265,7 +265,7 @@ /* IUnknown fields */ const IUnknownVtbl *UnknownVtbl; const IDirectMusicInstrumentVtbl *InstrumentVtbl; - DWORD ref; + LONG ref; /* IDirectMusicInstrumentImpl fields */ LARGE_INTEGER liInstrumentPosition; /* offset in a stream where instrument chunk can be found */ diff -urN wine-20050628/dlls/dplayx/dpclassfactory.c wine-20050725/dlls/dplayx/dpclassfactory.c --- wine-20050628/dlls/dplayx/dpclassfactory.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dplayx/dpclassfactory.c 2005-07-12 21:21:37.000000000 +0200 @@ -40,7 +40,7 @@ { /* IUnknown fields */ const IClassFactoryVtbl *lpVtbl; - DWORD ref; + LONG ref; } IClassFactoryImpl; static HRESULT WINAPI diff -urN wine-20050628/dlls/dplayx/dplay.c wine-20050725/dlls/dplayx/dplay.c --- wine-20050628/dlls/dplayx/dplay.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dplayx/dplay.c 2005-07-13 13:59:15.000000000 +0200 @@ -227,7 +227,7 @@ /* Strip out all dwFlags values for CREATEPLAYER msg */ #define DPMSG_CREATEPLAYER_DWFLAGS(x) 0 -static DWORD kludgePlayerGroupId = 1000; +static LONG kludgePlayerGroupId = 1000; /* ------------------------------------------------------------------ */ @@ -3707,7 +3707,7 @@ } if( RegQueryValueExA( hkServiceProvider, guidDataSubKey, - NULL, &returnTypeGUID, returnBuffer, + NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing GUID registry data members\n" ); @@ -3802,7 +3802,7 @@ } if( RegQueryValueExA( hkServiceProvider, guidDataSubKey, - NULL, &returnTypeGUID, returnBuffer, + NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing GUID registry data members\n" ); @@ -3953,7 +3953,7 @@ return DP_OK; } -BOOL CALLBACK DP_GetSpLpGuidFromCompoundAddress( +static BOOL CALLBACK DP_GetSpLpGuidFromCompoundAddress( REFGUID guidDataType, DWORD dwDataSize, LPCVOID lpData, @@ -4043,7 +4043,7 @@ } if( RegQueryValueExA( hkServiceProvider, guidDataSubKey, - NULL, &returnType, returnBuffer, + NULL, &returnType, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing GUID registry data members\n" ); @@ -4072,7 +4072,7 @@ /* Get dwReserved1 */ if( RegQueryValueExA( hkServiceProvider, majVerDataSubKey, - NULL, &returnType, returnBuffer, + NULL, &returnType, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing dwReserved1 registry data members\n") ; @@ -4086,7 +4086,7 @@ /* Get dwReserved2 */ if( RegQueryValueExA( hkServiceProvider, minVerDataSubKey, - NULL, &returnType, returnBuffer, + NULL, &returnType, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing dwReserved1 registry data members\n") ; @@ -4100,7 +4100,7 @@ /* Get the path for this service provider */ if( ( dwTemp = RegQueryValueExA( hkServiceProvider, pathSubKey, - NULL, NULL, returnBuffer, + NULL, NULL, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) ) != ERROR_SUCCESS ) { ERR(": missing PATH registry data members: 0x%08lx\n", dwTemp ); diff -urN wine-20050628/dlls/dplayx/dplay_global.h wine-20050725/dlls/dplayx/dplay_global.h --- wine-20050628/dlls/dplayx/dplay_global.h 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dplayx/dplay_global.h 2005-07-13 13:59:15.000000000 +0200 @@ -45,7 +45,7 @@ typedef struct tagDirectPlayIUnknownData { - ULONG ulObjRef; + LONG ulObjRef; CRITICAL_SECTION DP_lock; } DirectPlayIUnknownData; @@ -207,7 +207,7 @@ } DirectPlay4Data; #define DP_IMPL_FIELDS \ - ULONG ulInterfaceRef; \ + LONG ulInterfaceRef; \ DirectPlayIUnknownData* unk; \ DirectPlay2Data* dp2; \ DirectPlay3Data* dp3; \ diff -urN wine-20050628/dlls/dplayx/dplaysp.c wine-20050725/dlls/dplayx/dplaysp.c --- wine-20050628/dlls/dplayx/dplaysp.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dplayx/dplaysp.c 2005-07-12 21:21:37.000000000 +0200 @@ -45,7 +45,7 @@ typedef struct tagDirectPlaySPIUnknownData { - ULONG ulObjRef; + LONG ulObjRef; CRITICAL_SECTION DPSP_lock; } DirectPlaySPIUnknownData; @@ -62,7 +62,7 @@ } DirectPlaySPData; #define DPSP_IMPL_FIELDS \ - ULONG ulInterfaceRef; \ + LONG ulInterfaceRef; \ DirectPlaySPIUnknownData* unk; \ DirectPlaySPData* sp; diff -urN wine-20050628/dlls/dplayx/dplayx_global.c wine-20050725/dlls/dplayx/dplayx_global.c --- wine-20050628/dlls/dplayx/dplayx_global.c 2005-03-24 22:01:39.000000000 +0100 +++ wine-20050725/dlls/dplayx/dplayx_global.c 2005-07-05 14:49:14.000000000 +0200 @@ -1061,7 +1061,7 @@ -LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateSessionDesc2A( LPCDPSESSIONDESC2 lpSessionSrc ) +static LPDPSESSIONDESC2 DPLAYX_CopyAndAllocateSessionDesc2A( LPCDPSESSIONDESC2 lpSessionSrc ) { LPDPSESSIONDESC2 lpSessionDest = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *lpSessionSrc ) ); diff -urN wine-20050628/dlls/dplayx/dplobby.c wine-20050725/dlls/dplayx/dplobby.c --- wine-20050628/dlls/dplayx/dplobby.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dplayx/dplobby.c 2005-07-12 21:21:37.000000000 +0200 @@ -88,7 +88,7 @@ typedef struct tagDirectPlayLobbyIUnknownData { - ULONG ulObjRef; + LONG ulObjRef; CRITICAL_SECTION DPL_lock; } DirectPlayLobbyIUnknownData; @@ -110,7 +110,7 @@ } DirectPlayLobby3Data; #define DPL_IMPL_FIELDS \ - ULONG ulInterfaceRef; \ + LONG ulInterfaceRef; \ DirectPlayLobbyIUnknownData* unk; \ DirectPlayLobbyData* dpl; \ DirectPlayLobby2Data* dpl2; \ @@ -783,7 +783,7 @@ } if( RegQueryValueExA( hkServiceProvider, guidDataSubKey, - NULL, &returnTypeGUID, returnBuffer, + NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing GUID registry data members\n" ); @@ -928,7 +928,7 @@ } if( RegQueryValueExA( hkServiceProvider, guidDataSubKey, - NULL, &returnTypeGUID, returnBuffer, + NULL, &returnTypeGUID, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR(": missing GUID registry data members\n" ); @@ -1084,7 +1084,7 @@ /* Get all the appropriate data from the registry */ if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, clSubKey, - NULL, &returnType, returnBuffer, + NULL, &returnType, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR( ": missing CommandLine registry data member\n" ); @@ -1098,7 +1098,7 @@ sizeOfReturnBuffer = 200; if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, cdSubKey, - NULL, &returnType, returnBuffer, + NULL, &returnType, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR( ": missing CurrentDirectory registry data member\n" ); @@ -1112,7 +1112,7 @@ sizeOfReturnBuffer = 200; if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, fileSubKey, - NULL, &returnType, returnBuffer, + NULL, &returnType, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR( ": missing File registry data member\n" ); @@ -1126,7 +1126,7 @@ sizeOfReturnBuffer = 200; if( RegQueryValueExA( lpData->This->dpl->hkCallbackKeyHack, pathSubKey, - NULL, &returnType, returnBuffer, + NULL, &returnType, (LPBYTE)returnBuffer, &sizeOfReturnBuffer ) != ERROR_SUCCESS ) { ERR( ": missing Path registry data member\n" ); diff -urN wine-20050628/dlls/dplayx/lobbysp.c wine-20050725/dlls/dplayx/lobbysp.c --- wine-20050628/dlls/dplayx/lobbysp.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dplayx/lobbysp.c 2005-07-12 21:21:37.000000000 +0200 @@ -39,7 +39,7 @@ typedef struct tagDPLobbySPIUnknownData { - ULONG ulObjRef; + LONG ulObjRef; CRITICAL_SECTION DPLSP_lock; } DPLobbySPIUnknownData; @@ -49,7 +49,7 @@ } DPLobbySPData; #define DPLSP_IMPL_FIELDS \ - ULONG ulInterfaceRef; \ + LONG ulInterfaceRef; \ DPLobbySPIUnknownData* unk; \ DPLobbySPData* sp; diff -urN wine-20050628/dlls/dplayx/name_server.c wine-20050725/dlls/dplayx/name_server.c --- wine-20050628/dlls/dplayx/name_server.c 2005-03-24 22:01:39.000000000 +0100 +++ wine-20050725/dlls/dplayx/name_server.c 2005-07-05 14:49:14.000000000 +0200 @@ -90,7 +90,7 @@ lpCache->bNsIsLocal = FALSE; } -DPQ_DECL_COMPARECB( cbUglyPig, GUID ) +static DPQ_DECL_COMPARECB( cbUglyPig, GUID ) { return IsEqualGUID( elem1, elem2 ); } diff -urN wine-20050628/dlls/dpnet/dpnet_main.c wine-20050725/dlls/dpnet/dpnet_main.c --- wine-20050628/dlls/dpnet/dpnet_main.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dpnet/dpnet_main.c 2005-07-12 21:21:37.000000000 +0200 @@ -66,7 +66,7 @@ { /* IUnknown fields */ const IClassFactoryVtbl *lpVtbl; - DWORD ref; + LONG ref; REFCLSID rclsid; HRESULT (*pfnCreateInstanceFactory)(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj); } IClassFactoryImpl; diff -urN wine-20050628/dlls/dpnet/dpnet_private.h wine-20050725/dlls/dpnet/dpnet_private.h --- wine-20050628/dlls/dpnet/dpnet_private.h 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dpnet/dpnet_private.h 2005-07-12 21:21:37.000000000 +0200 @@ -46,7 +46,7 @@ { /* IUnknown fields */ const IDirectPlay8ClientVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectPlay8Client fields */ }; @@ -64,7 +64,7 @@ { /* IUnknown fields */ const IDirectPlay8AddressVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectPlay8Address fields */ GUID SP_guid; const WCHAR *url; diff -urN wine-20050628/dlls/dsound/dsound.c wine-20050725/dlls/dsound/dsound.c --- wine-20050628/dlls/dsound/dsound.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/dsound/dsound.c 2005-07-15 11:58:36.000000000 +0200 @@ -65,7 +65,7 @@ static void _dump_DSCAPS(DWORD xmask) { struct { DWORD mask; - char *name; + const char *name; } flags[] = { #define FE(x) { x, #x }, FE(DSCAPS_PRIMARYMONO) @@ -91,7 +91,7 @@ static void _dump_DSBCAPS(DWORD xmask) { struct { DWORD mask; - char *name; + const char *name; } flags[] = { #define FE(x) { x, #x }, FE(DSBCAPS_PRIMARYBUFFER) diff -urN wine-20050628/dlls/dsound/dsound_main.c wine-20050725/dlls/dsound/dsound_main.c --- wine-20050628/dlls/dsound/dsound_main.c 2005-06-17 22:58:33.000000000 +0200 +++ wine-20050725/dlls/dsound/dsound_main.c 2005-07-07 14:08:43.000000000 +0200 @@ -115,8 +115,8 @@ inline static DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size ) { - if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, buffer, &size )) return 0; - if (defkey && !RegQueryValueExA( defkey, name, 0, NULL, buffer, &size )) return 0; + if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE)buffer, &size )) return 0; + if (defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE)buffer, &size )) return 0; return ERROR_FILE_NOT_FOUND; } diff -urN wine-20050628/dlls/dsound/dsound_private.h wine-20050725/dlls/dsound/dsound_private.h --- wine-20050628/dlls/dsound/dsound_private.h 2005-06-04 11:38:14.000000000 +0200 +++ wine-20050725/dlls/dsound/dsound_private.h 2005-07-12 21:21:37.000000000 +0200 @@ -73,7 +73,7 @@ { /* IUnknown fields */ const IDirectSound8Vtbl *lpVtbl; - DWORD ref; + LONG ref; DirectSoundDevice *device; LPUNKNOWN pUnknown; @@ -83,7 +83,7 @@ struct DirectSoundDevice { - DWORD ref; + LONG ref; GUID guid; PIDSDRIVER driver; @@ -118,7 +118,7 @@ /* reference counted buffer memory for duplicated buffer memory */ typedef struct BufferMemory { - DWORD ref; + LONG ref; LPBYTE memory; } BufferMemory; @@ -138,7 +138,7 @@ */ struct IDirectSound_IUnknown { const IUnknownVtbl *lpVtbl; - DWORD ref; + LONG ref; LPDIRECTSOUND8 pds; }; @@ -148,7 +148,7 @@ struct IDirectSound_IDirectSound { const IDirectSoundVtbl *lpVtbl; - DWORD ref; + LONG ref; LPDIRECTSOUND8 pds; }; @@ -161,7 +161,7 @@ */ struct IDirectSound8_IUnknown { const IUnknownVtbl *lpVtbl; - DWORD ref; + LONG ref; LPDIRECTSOUND8 pds; }; @@ -171,7 +171,7 @@ struct IDirectSound8_IDirectSound { const IDirectSoundVtbl *lpVtbl; - DWORD ref; + LONG ref; LPDIRECTSOUND8 pds; }; @@ -181,7 +181,7 @@ struct IDirectSound8_IDirectSound8 { const IDirectSound8Vtbl *lpVtbl; - DWORD ref; + LONG ref; LPDIRECTSOUND8 pds; }; @@ -197,7 +197,7 @@ /* FIXME: document */ /* IUnknown fields */ const IDirectSoundBuffer8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectSoundBufferImpl fields */ SecondaryBufferImpl* dsb; IDirectSoundImpl* dsound; @@ -247,7 +247,7 @@ struct SecondaryBufferImpl { const IDirectSoundBuffer8Vtbl *lpVtbl; - DWORD ref; + LONG ref; IDirectSoundBufferImpl* dsb; }; @@ -263,7 +263,7 @@ struct PrimaryBufferImpl { const IDirectSoundBuffer8Vtbl *lpVtbl; - DWORD ref; + LONG ref; IDirectSoundImpl* dsound; }; @@ -279,7 +279,7 @@ { /* IUnknown fields */ const IDirectSoundCaptureVtbl *lpVtbl; - DWORD ref; + LONG ref; DirectSoundCaptureDevice *device; }; @@ -288,7 +288,7 @@ { /* IDirectSoundCaptureImpl fields */ GUID guid; - DWORD ref; + LONG ref; /* DirectSound driver stuff */ PIDSCDRIVER driver; @@ -332,7 +332,7 @@ { /* IUnknown fields */ const IDirectSoundCaptureBuffer8Vtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectSoundCaptureBufferImpl fields */ IDirectSoundCaptureImpl* dsound; @@ -354,7 +354,7 @@ { /* IUnknown fields */ const IDirectSoundFullDuplexVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectSoundFullDuplexImpl fields */ CRITICAL_SECTION lock; @@ -367,7 +367,7 @@ { /* IUnknown fields */ const IDirectSoundNotifyVtbl *lpVtbl; - DWORD ref; + LONG ref; IDirectSoundBufferImpl* dsb; }; @@ -384,7 +384,7 @@ { /* IUnknown fields */ const IDirectSoundNotifyVtbl *lpVtbl; - DWORD ref; + LONG ref; IDirectSoundCaptureBufferImpl* dscb; }; @@ -399,7 +399,7 @@ { /* IUnknown fields */ const IDirectSound3DListenerVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectSound3DListenerImpl fields */ IDirectSoundImpl* dsound; }; @@ -415,7 +415,7 @@ { /* IUnknown fields */ const IKsPropertySetVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IKsPropertySetImpl fields */ IDirectSoundBufferImpl* dsb; }; @@ -433,7 +433,7 @@ { /* IUnknown fields */ const IKsPropertySetVtbl *lpVtbl; - DWORD ref; + LONG ref; }; HRESULT WINAPI IKsPrivatePropertySetImpl_Create( @@ -446,7 +446,7 @@ { /* IUnknown fields */ const IDirectSound3DBufferVtbl *lpVtbl; - DWORD ref; + LONG ref; /* IDirectSound3DBufferImpl fields */ IDirectSoundBufferImpl* dsb; }; @@ -464,7 +464,7 @@ { /* IUnknown fields */ const IClassFactoryVtbl *lpVtbl; - DWORD ref; + LONG ref; }; extern IClassFactoryImpl DSOUND_CAPTURE_CF; diff -urN wine-20050628/dlls/dsound/tests/ds3d.c wine-20050725/dlls/dsound/tests/ds3d.c --- wine-20050628/dlls/dsound/tests/ds3d.c 2005-06-20 16:18:04.000000000 +0200 +++ wine-20050725/dlls/dsound/tests/ds3d.c 2005-07-15 18:34:04.000000000 +0200 @@ -71,7 +71,7 @@ const char * getDSBCAPS(DWORD xmask) { static struct { DWORD mask; - char *name; + const char *name; } flags[] = { #define FE(x) { x, #x }, FE(DSBCAPS_PRIMARYBUFFER) @@ -90,7 +90,7 @@ #undef FE }; static char buffer[512]; - int i; + unsigned int i; BOOL first = TRUE; buffer[0] = 0; diff -urN wine-20050628/dlls/dsound/tests/dsound8.c wine-20050725/dlls/dsound/tests/dsound8.c --- wine-20050628/dlls/dsound/tests/dsound8.c 2005-06-20 16:18:04.000000000 +0200 +++ wine-20050725/dlls/dsound/tests/dsound8.c 2005-07-15 18:34:04.000000000 +0200 @@ -527,7 +527,8 @@ DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx2; - int f,ref; + int ref; + unsigned int f; /* Create the DirectSound object */ rc=pDirectSoundCreate8(lpGuid,&dso,NULL); diff -urN wine-20050628/dlls/dswave/dswave_private.h wine-20050725/dlls/dswave/dswave_private.h --- wine-20050628/dlls/dswave/dswave_private.h 2005-06-20 16:18:04.000000000 +0200 +++ wine-20050725/dlls/dswave/dswave_private.h 2005-07-12 21:21:37.000000000 +0200 @@ -60,7 +60,7 @@ const IDirectMusicSegment8Vtbl *SegmentVtbl; const IDirectMusicObjectVtbl *ObjectVtbl; const IPersistStreamVtbl *PersistStreamVtbl; - DWORD ref; + LONG ref; /* IDirectMusicWaveImpl fields */ LPDMUS_OBJECTDESC pDesc; diff -urN wine-20050628/dlls/gdi/dib.c wine-20050725/dlls/gdi/dib.c --- wine-20050628/dlls/gdi/dib.c 2005-06-17 15:56:25.000000000 +0200 +++ wine-20050725/dlls/gdi/dib.c 2005-07-14 12:15:42.000000000 +0200 @@ -233,6 +233,8 @@ WORD planes, bpp; DWORD compr, size; + GDI_ReleaseObj( hdc ); + if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height, &planes, &bpp, &compr, &size ) == -1) { ERR("Invalid bitmap\n"); @@ -245,7 +247,6 @@ return 0; } - GDI_ReleaseObj( hdc ); hdcMem = CreateCompatibleDC( hdc ); hBitmap = CreateCompatibleBitmap(hdc, width, height); hOldBitmap = SelectObject( hdcMem, hBitmap ); diff -urN wine-20050628/dlls/gdi/driver.c wine-20050725/dlls/gdi/driver.c --- wine-20050628/dlls/gdi/driver.c 2005-06-20 18:04:32.000000000 +0200 +++ wine-20050725/dlls/gdi/driver.c 2005-07-05 13:02:37.000000000 +0200 @@ -226,7 +226,7 @@ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey )) { DWORD type, count = sizeof(buffer); - RegQueryValueExA( hkey, "Graphics", 0, &type, buffer, &count ); + RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count ); RegCloseKey( hkey ); } diff -urN wine-20050628/dlls/gdi/enhmetafile.c wine-20050725/dlls/gdi/enhmetafile.c --- wine-20050628/dlls/gdi/enhmetafile.c 2005-04-13 12:57:59.000000000 +0200 +++ wine-20050725/dlls/gdi/enhmetafile.c 2005-07-05 14:49:14.000000000 +0200 @@ -510,7 +510,7 @@ #define IS_WIN9X() (GetVersion()&0x80000000) -void EMF_Update_MF_Xform(HDC hdc, enum_emh_data *info) +static void EMF_Update_MF_Xform(HDC hdc, enum_emh_data *info) { XFORM mapping_mode_trans, final_trans; FLOAT scaleX, scaleY; @@ -533,7 +533,7 @@ } } -void EMF_SetMapMode(HDC hdc, enum_emh_data *info) +static void EMF_SetMapMode(HDC hdc, enum_emh_data *info) { INT horzSize = GetDeviceCaps( hdc, HORZSIZE ); INT vertSize = GetDeviceCaps( hdc, VERTSIZE ); @@ -2434,7 +2434,7 @@ * * NOTE: To be used by GetEnhMetaFilePaletteEntries only! */ -INT CALLBACK cbEnhPaletteCopy( HDC a, +static INT CALLBACK cbEnhPaletteCopy( HDC a, HANDLETABLE *b, const ENHMETARECORD *lpEMR, INT c, diff -urN wine-20050628/dlls/gdi/font.c wine-20050725/dlls/gdi/font.c --- wine-20050628/dlls/gdi/font.c 2005-04-18 12:30:56.000000000 +0200 +++ wine-20050725/dlls/gdi/font.c 2005-07-18 20:05:04.000000000 +0200 @@ -2517,3 +2517,43 @@ memset(fs, 0, sizeof(FONTSIGNATURE)); return ret; } + +/*********************************************************************** + * GdiGetCharDimensions (GDI32.@) + * + * Gets the average width of the characters in the English alphabet. + * + * PARAMS + * hdc [I] Handle to the device context to measure on. + * lptm [O] Pointer to memory to store the text metrics into. + * height [O] On exit, the maximum height of characters in the English alphabet. + * + * RETURNS + * The average width of characters in the English alphabet. + * + * NOTES + * This function is used by the dialog manager to get the size of a dialog + * unit. It should also be used by other pieces of code that need to know + * the size of a dialog unit in logical units without having access to the + * window handle of the dialog. + * Windows caches the font metrics from this function, but we don't and + * there doesn't appear to be an immediate advantage to do so. + * + * SEE ALSO + * GetTextExtentPointW, GetTextMetricsW, MapDialogRect. + */ +LONG WINAPI GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height) +{ + SIZE sz; + static const WCHAR alphabet[] = { + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q', + 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H', + 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0}; + + if(lptm && !GetTextMetricsW(hdc, lptm)) return 0; + + if(!GetTextExtentPointW(hdc, alphabet, 52, &sz)) return 0; + + if (height) *height = sz.cy; + return (sz.cx / 26 + 1) / 2; +} diff -urN wine-20050628/dlls/gdi/freetype.c wine-20050725/dlls/gdi/freetype.c --- wine-20050628/dlls/gdi/freetype.c 2005-06-14 14:33:19.000000000 +0200 +++ wine-20050725/dlls/gdi/freetype.c 2005-07-05 13:02:37.000000000 +0200 @@ -985,9 +985,9 @@ /* Delete the old external fonts key */ RegCloseKey(externalkey); externalkey = 0; - RegDeleteKeyW(HKEY_LOCAL_MACHINE, external_fonts_reg_key); + RegDeleteKeyW(HKEY_CURRENT_USER, external_fonts_reg_key); - if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, external_fonts_reg_key, + if(RegCreateKeyExW(HKEY_CURRENT_USER, external_fonts_reg_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &externalkey, NULL) != ERROR_SUCCESS) { ERR("Can't create external font reg key\n"); goto end; @@ -2209,7 +2209,7 @@ { if(font->ft_face->charmap->encoding == FT_ENCODING_NONE) { WCHAR wc = (WCHAR)glyph; - unsigned char buf; + char buf; WideCharToMultiByte(font->codepage, 0, &wc, 1, &buf, sizeof(buf), 0, 0); return pFT_Get_Char_Index(font->ft_face, buf); } diff -urN wine-20050628/dlls/gdi/gdi32.spec wine-20050725/dlls/gdi/gdi32.spec --- wine-20050628/dlls/gdi/gdi32.spec 2005-05-25 11:55:55.000000000 +0200 +++ wine-20050725/dlls/gdi/gdi32.spec 2005-07-18 20:05:04.000000000 +0200 @@ -155,6 +155,7 @@ @ stub GdiDllInitialize @ stdcall GdiFlush() @ stdcall GdiGetBatchLimit() +@ stdcall GdiGetCharDimensions(ptr ptr ptr) @ stub GdiGetLocalBitmap @ stub GdiGetLocalBrush @ stub GdiGetLocalDC @@ -230,7 +231,7 @@ @ stdcall GetGraphicsMode(long) @ stdcall GetICMProfileA(long ptr str) @ stdcall GetICMProfileW(long ptr wstr) -@ stub GetKerningPairs +@ stdcall GetKerningPairs(long long ptr) GetKerningPairsA @ stdcall GetKerningPairsA(long long ptr) @ stdcall GetKerningPairsW(long long ptr) @ stdcall GetLayout(long) diff -urN wine-20050628/dlls/gdi/printdrv.c wine-20050725/dlls/gdi/printdrv.c --- wine-20050628/dlls/gdi/printdrv.c 2005-06-28 15:55:02.000000000 +0200 +++ wine-20050725/dlls/gdi/printdrv.c 2005-07-05 13:02:37.000000000 +0200 @@ -465,7 +465,7 @@ if(!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Printing\\Spooler", &hkey)) { DWORD type, count = sizeof(psCmd); - RegQueryValueExA(hkey, pszOutput, 0, &type, psCmd, &count); + RegQueryValueExA(hkey, pszOutput, 0, &type, (LPBYTE)psCmd, &count); RegCloseKey(hkey); } if (!psCmd[0] && !strncmp("LPR:",pszOutput,4)) diff -urN wine-20050628/dlls/gdi/tests/gdiobj.c wine-20050725/dlls/gdi/tests/gdiobj.c --- wine-20050628/dlls/gdi/tests/gdiobj.c 2005-05-20 20:58:19.000000000 +0200 +++ wine-20050725/dlls/gdi/tests/gdiobj.c 2005-07-18 20:08:30.000000000 +0200 @@ -266,9 +266,70 @@ ReleaseDC(NULL, hdc); } +static void test_GdiGetCharDimensions(void) +{ + HDC hdc; + TEXTMETRICW tm; + LONG ret; + SIZE size; + LONG avgwidth, height; + static const char szAlphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + typedef LONG (WINAPI *fnGdiGetCharDimensions)(HDC hdc, LPTEXTMETRICW lptm, LONG *height); + fnGdiGetCharDimensions GdiGetCharDimensions = (fnGdiGetCharDimensions)GetProcAddress(LoadLibrary("gdi32"), "GdiGetCharDimensions"); + if (!GdiGetCharDimensions) return; + + hdc = CreateCompatibleDC(NULL); + + GetTextExtentPoint(hdc, szAlphabet, strlen(szAlphabet), &size); + avgwidth = ((size.cx / 26) + 1) / 2; + + ret = GdiGetCharDimensions(hdc, &tm, &height); + ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret); + ok(height == tm.tmHeight, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", tm.tmHeight, height); + + ret = GdiGetCharDimensions(hdc, &tm, NULL); + ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret); + + ret = GdiGetCharDimensions(hdc, NULL, NULL); + ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret); + + height = 0; + ret = GdiGetCharDimensions(hdc, NULL, &height); + ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret); + ok(height == size.cy, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", size.cy, height); + + DeleteDC(hdc); +} + +static void test_text_extents(void) +{ + LOGFONTA lf; + TEXTMETRICA tm; + HDC hdc; + HFONT hfont; + SIZE sz; + + memset(&lf, 0, sizeof(lf)); + strcpy(lf.lfFaceName, "Arial"); + lf.lfHeight = 20; + + hfont = CreateFontIndirectA(&lf); + hdc = GetDC(0); + hfont = SelectObject(hdc, hfont); + GetTextMetricsA(hdc, &tm); + GetTextExtentPointA(hdc, "o", 1, &sz); + ok(sz.cy == tm.tmHeight, "cy %ld tmHeight %ld\n", sz.cy, tm.tmHeight); + + SelectObject(hdc, hfont); + DeleteObject(hfont); + ReleaseDC(NULL, hdc); +} + START_TEST(gdiobj) { test_logfont(); test_bitmap_font(); test_gdi_objects(); + test_GdiGetCharDimensions(); + test_text_extents(); } diff -urN wine-20050628/dlls/gdi/tests/generated.c wine-20050725/dlls/gdi/tests/generated.c --- wine-20050628/dlls/gdi/tests/generated.c 2004-09-07 22:27:34.000000000 +0200 +++ wine-20050725/dlls/gdi/tests/generated.c 2005-07-03 13:23:30.000000000 +0200 @@ -63,7 +63,7 @@ # define TEST_FIELD_ALIGNMENT(type, field, align) \ ok(FIELD_ALIGNMENT(type, field) == align, \ "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \ - FIELD_ALIGNMENT(type, field)) + (int)FIELD_ALIGNMENT(type, field)) #else # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0) #endif @@ -71,24 +71,24 @@ #define TEST_FIELD_OFFSET(type, field, offset) \ ok(FIELD_OFFSET(type, field) == offset, \ "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")\n", \ - FIELD_OFFSET(type, field)) + (long int)FIELD_OFFSET(type, field)) #ifdef _TYPE_ALIGNMENT #define TEST__TYPE_ALIGNMENT(type, align) \ - ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", _TYPE_ALIGNMENT(type)) + ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)_TYPE_ALIGNMENT(type)) #else # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0) #endif #ifdef TYPE_ALIGNMENT #define TEST_TYPE_ALIGNMENT(type, align) \ - ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", TYPE_ALIGNMENT(type)) + ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)TYPE_ALIGNMENT(type)) #else # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0) #endif #define TEST_TYPE_SIZE(type, size) \ - ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", sizeof(type)) + ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", ((int) sizeof(type))) /*********************************************************************** * Test macros diff -urN wine-20050628/dlls/gdi/tests/metafile.c wine-20050725/dlls/gdi/tests/metafile.c --- wine-20050628/dlls/gdi/tests/metafile.c 2005-06-22 20:03:19.000000000 +0200 +++ wine-20050725/dlls/gdi/tests/metafile.c 2005-07-15 11:55:33.000000000 +0200 @@ -443,43 +443,39 @@ HeapFree (GetProcessHeap(), 0, orig_lb); } -static INT CALLBACK EmfMmTextEnumProc(HDC hdc, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, INT nObj, LPARAM lpData) +static INT CALLBACK EmfEnumProc(HDC hdc, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, INT nObj, LPARAM lpData) { + LPMETAFILEPICT lpMFP = (LPMETAFILEPICT)lpData; POINT mapping[2] = { { 0, 0 }, { 10, 10 } }; - LPtoDP(hdc, mapping, 2); - trace("Meta record: iType = %ld, (%ld,%ld)-(%ld,%ld)\n", lpEMFR->iType, mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y); - if (lpEMFR->iType == EMR_LINETO) - { - INT x0 = 0; - INT y0 = 0; - INT x1 = (INT)floor(10 * 100.0 / LINE_X + 0.5); - INT y1 = (INT)floor(10 * 100.0 / LINE_Y + 0.5); - ok(mapping[0].x == x0 && mapping[0].y == y0 && mapping[1].x == x1 && mapping[1].y == y1, - "(%ld,%ld)->(%ld,%ld), expected (%d,%d)->(%d,%d)\n", - mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y, - x0, y0, x1, y1); - } + /* When using MM_TEXT Win9x does not update the mapping mode + * until a record is played which actually outputs something */ PlayEnhMetaFileRecord(hdc, lpHTable, lpEMFR, nObj); - return TRUE; -} - -static INT CALLBACK EmfMmAnisotropicEnumProc(HDC hdc, HANDLETABLE *lpHTable, const ENHMETARECORD *lpEMFR, INT nObj, LPARAM lpData) -{ - POINT mapping[2] = { { 0, 0 }, { 10, 10 } }; LPtoDP(hdc, mapping, 2); trace("Meta record: iType = %ld, (%ld,%ld)-(%ld,%ld)\n", lpEMFR->iType, mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y); if (lpEMFR->iType == EMR_LINETO) { - INT x0 = MulDiv(0, GetDeviceCaps(hdc, HORZSIZE) * 100, GetDeviceCaps(hdc, HORZRES)); - INT y0 = MulDiv(0, GetDeviceCaps(hdc, VERTSIZE) * 100, GetDeviceCaps(hdc, VERTRES)); - INT x1 = MulDiv(10, GetDeviceCaps(hdc, HORZSIZE) * 100, GetDeviceCaps(hdc, HORZRES)); - INT y1 = MulDiv(10, GetDeviceCaps(hdc, VERTSIZE) * 100, GetDeviceCaps(hdc, VERTRES)); + INT x0, y0, x1, y1; + if (!lpMFP || lpMFP->mm == MM_TEXT) + { + x0 = 0; + y0 = 0; + x1 = (INT)floor(10 * 100.0 / LINE_X + 0.5); + y1 = (INT)floor(10 * 100.0 / LINE_Y + 0.5); + } + else + { + ok(lpMFP->mm == MM_ANISOTROPIC, "mm=%ld\n", lpMFP->mm); + + x0 = MulDiv(0, GetDeviceCaps(hdc, HORZSIZE) * 100, GetDeviceCaps(hdc, HORZRES)); + y0 = MulDiv(0, GetDeviceCaps(hdc, VERTSIZE) * 100, GetDeviceCaps(hdc, VERTRES)); + x1 = MulDiv(10, GetDeviceCaps(hdc, HORZSIZE) * 100, GetDeviceCaps(hdc, HORZRES)); + y1 = MulDiv(10, GetDeviceCaps(hdc, VERTSIZE) * 100, GetDeviceCaps(hdc, VERTRES)); + } ok(mapping[0].x == x0 && mapping[0].y == y0 && mapping[1].x == x1 && mapping[1].y == y1, "(%ld,%ld)->(%ld,%ld), expected (%d,%d)->(%d,%d)\n", mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y, x0, y0, x1, y1); } - PlayEnhMetaFileRecord(hdc, lpHTable, lpEMFR, nObj); return TRUE; } @@ -518,7 +514,7 @@ mfp.yExt = 100; mfp.hMF = NULL; hemf = create_converted_emf(&mfp); - EnumEnhMetaFile(hdcOffscreen, hemf, EmfMmAnisotropicEnumProc, NULL, &rect); + EnumEnhMetaFile(hdcOffscreen, hemf, EmfEnumProc, &mfp, &rect); DeleteEnhMetaFile(hemf); DeleteDC(hdcOffscreen); } @@ -534,7 +530,7 @@ mfp.yExt = 0; mfp.hMF = NULL; hemf = create_converted_emf(&mfp); - EnumEnhMetaFile(hdcOffscreen, hemf, EmfMmTextEnumProc, NULL, &rect); + EnumEnhMetaFile(hdcOffscreen, hemf, EmfEnumProc, &mfp, &rect); DeleteEnhMetaFile(hemf); DeleteDC(hdcOffscreen); } @@ -545,7 +541,7 @@ HENHMETAFILE hemf; RECT rect = { 0, 0, 100, 100 }; hemf = create_converted_emf(NULL); - EnumEnhMetaFile(hdcOffscreen, hemf, EmfMmTextEnumProc, NULL, &rect); + EnumEnhMetaFile(hdcOffscreen, hemf, EmfEnumProc, NULL, &rect); DeleteEnhMetaFile(hemf); DeleteDC(hdcOffscreen); } diff -urN wine-20050628/dlls/iphlpapi/iphlpapi_main.c wine-20050725/dlls/iphlpapi/iphlpapi_main.c --- wine-20050628/dlls/iphlpapi/iphlpapi_main.c 2005-06-27 11:53:47.000000000 +0200 +++ wine-20050725/dlls/iphlpapi/iphlpapi_main.c 2005-07-07 14:08:43.000000000 +0200 @@ -625,13 +625,13 @@ unsigned long addr; RegQueryValueExA(hKey, "WinsServer", NULL, NULL, - primaryWINS.String, &size); + (LPBYTE)primaryWINS.String, &size); addr = inet_addr(primaryWINS.String); if (addr != INADDR_NONE && addr != INADDR_ANY) winsEnabled = TRUE; size = sizeof(secondaryWINS.String); RegQueryValueExA(hKey, "BackupWinsServer", NULL, NULL, - secondaryWINS.String, &size); + (LPBYTE)secondaryWINS.String, &size); addr = inet_addr(secondaryWINS.String); if (addr != INADDR_NONE && addr != INADDR_ANY) winsEnabled = TRUE; @@ -1385,7 +1385,7 @@ { DWORD size = sizeof(pFixedInfo->ScopeId); - RegQueryValueExA(hKey, "ScopeID", NULL, NULL, pFixedInfo->ScopeId, &size); + RegQueryValueExA(hKey, "ScopeID", NULL, NULL, (LPBYTE)pFixedInfo->ScopeId, &size); RegCloseKey(hKey); } diff -urN wine-20050628/dlls/iphlpapi/tests/iphlpapi.c wine-20050725/dlls/iphlpapi/tests/iphlpapi.c --- wine-20050628/dlls/iphlpapi/tests/iphlpapi.c 2005-06-20 17:35:54.000000000 +0200 +++ wine-20050725/dlls/iphlpapi/tests/iphlpapi.c 2005-07-05 13:05:50.000000000 +0200 @@ -146,7 +146,7 @@ still-to-be-tested 98-only functions: GetUniDirectionalAdapterInfo */ -void testWin98OnlyFunctions(void) +static void testWin98OnlyFunctions(void) { } diff -urN wine-20050628/dlls/itss/itss.c wine-20050725/dlls/itss/itss.c --- wine-20050628/dlls/itss/itss.c 2005-06-23 18:44:28.000000000 +0200 +++ wine-20050725/dlls/itss/itss.c 2005-07-13 13:59:15.000000000 +0200 @@ -51,7 +51,7 @@ static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj); -ULONG dll_count = 0; +LONG dll_count = 0; BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) { @@ -71,7 +71,7 @@ typedef struct { IClassFactory ITF_IClassFactory; - DWORD ref; + LONG ref; HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); } IClassFactoryImpl; @@ -214,7 +214,7 @@ typedef struct { const IITStorageVtbl *vtbl_IITStorage; - DWORD ref; + LONG ref; } ITStorageImpl; diff -urN wine-20050628/dlls/itss/moniker.c wine-20050725/dlls/itss/moniker.c --- wine-20050628/dlls/itss/moniker.c 2005-06-01 21:57:42.000000000 +0200 +++ wine-20050725/dlls/itss/moniker.c 2005-07-13 13:59:15.000000000 +0200 @@ -44,13 +44,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(itss); -extern ULONG dll_count; +extern LONG dll_count; /*****************************************************************************/ typedef struct { const IMonikerVtbl *vtbl_ITS_IMoniker; - DWORD ref; + LONG ref; LPWSTR szHtml; WCHAR szFile[1]; } ITS_IMonikerImpl; @@ -378,7 +378,7 @@ typedef struct { const IParseDisplayNameVtbl *vtbl_ITS_IParseDisplayName; - DWORD ref; + LONG ref; } ITS_IParseDisplayNameImpl; static HRESULT WINAPI ITS_IParseDisplayNameImpl_QueryInterface( diff -urN wine-20050628/dlls/itss/storage.c wine-20050725/dlls/itss/storage.c --- wine-20050628/dlls/itss/storage.c 2005-06-20 12:30:15.000000000 +0200 +++ wine-20050725/dlls/itss/storage.c 2005-07-13 13:59:15.000000000 +0200 @@ -45,14 +45,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(itss); -extern ULONG dll_count; +extern LONG dll_count; /************************************************************************/ typedef struct _ITSS_IStorageImpl { const IStorageVtbl *vtbl_IStorage; - DWORD ref; + LONG ref; struct chmFile *chmfile; WCHAR dir[1]; } ITSS_IStorageImpl; @@ -66,14 +66,14 @@ typedef struct _IEnumSTATSTG_Impl { const IEnumSTATSTGVtbl *vtbl_IEnumSTATSTG; - DWORD ref; + LONG ref; struct enum_info *first, *last, *current; } IEnumSTATSTG_Impl; typedef struct _IStream_Impl { const IStreamVtbl *vtbl_IStream; - DWORD ref; + LONG ref; ITSS_IStorageImpl *stg; ULONGLONG addr; struct chmUnitInfo ui; diff -urN wine-20050628/dlls/kernel/Makefile.in wine-20050725/dlls/kernel/Makefile.in --- wine-20050628/dlls/kernel/Makefile.in 2005-05-24 12:12:06.000000000 +0200 +++ wine-20050725/dlls/kernel/Makefile.in 2005-07-25 13:08:31.000000000 +0200 @@ -41,6 +41,7 @@ lcformat.c \ local16.c \ locale.c \ + lzexpand.c \ module.c \ ne_module.c \ ne_segment.c \ diff -urN wine-20050628/dlls/kernel/file.c wine-20050725/dlls/kernel/file.c --- wine-20050628/dlls/kernel/file.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/file.c 2005-07-11 16:23:46.000000000 +0200 @@ -377,7 +377,7 @@ if (status != STATUS_PENDING && bytesRead) *bytesRead = io_status->Information; - if (status && status != STATUS_END_OF_FILE) + if (status && status != STATUS_END_OF_FILE && status != STATUS_TIMEOUT) { SetLastError( RtlNtStatusToDosError(status) ); return FALSE; @@ -463,7 +463,7 @@ if (status != STATUS_PENDING && bytesWritten) *bytesWritten = piosb->Information; - if (status) + if (status && status != STATUS_TIMEOUT) { SetLastError( RtlNtStatusToDosError(status) ); return FALSE; diff -urN wine-20050628/dlls/kernel/kernel16_private.h wine-20050725/dlls/kernel/kernel16_private.h --- wine-20050628/dlls/kernel/kernel16_private.h 2005-06-25 20:34:00.000000000 +0200 +++ wine-20050725/dlls/kernel/kernel16_private.h 2005-07-05 14:52:08.000000000 +0200 @@ -210,6 +210,9 @@ #define IS_SELECTOR_32BIT(sel) \ (wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT)) +/* relay16.c */ +extern int relay_call_from_16( void *entry_point, unsigned char *args16, CONTEXT86 *context ); + /* snoop16.c */ extern void SNOOP16_RegisterDLL(HMODULE16,LPCSTR); extern FARPROC16 SNOOP16_GetProcAddress16(HMODULE16,DWORD,FARPROC16); @@ -224,4 +227,9 @@ extern TDB *TASK_GetCurrent(void); extern void TASK_InstallTHHook( THHOOK *pNewThook ); +extern DWORD CallTo16_DataSelector; +extern DWORD CallTo16_TebSelector; +extern SEGPTR CALL32_CBClient_RetAddr; +extern SEGPTR CALL32_CBClientEx_RetAddr; + #endif /* __WINE_KERNEL16_PRIVATE_H */ diff -urN wine-20050628/dlls/kernel/kernel32.spec wine-20050725/dlls/kernel/kernel32.spec --- wine-20050628/dlls/kernel/kernel32.spec 2005-06-23 11:57:11.000000000 +0200 +++ wine-20050725/dlls/kernel/kernel32.spec 2005-07-25 13:08:31.000000000 +0200 @@ -8,104 +8,104 @@ # - code generated by the MS Thunk Compiler # - symbols exported by the Oct 94 beta version of kernel32.dll - 1 stdcall -i386 VxDCall0(long) VxDCall - 2 stdcall -i386 VxDCall1(long) VxDCall - 3 stdcall -i386 VxDCall2(long) VxDCall - 4 stdcall -i386 VxDCall3(long) VxDCall - 5 stdcall -i386 VxDCall4(long) VxDCall - 6 stdcall -i386 VxDCall5(long) VxDCall - 7 stdcall -i386 VxDCall6(long) VxDCall - 8 stdcall -i386 VxDCall7(long) VxDCall - 9 stdcall -i386 VxDCall8(long) VxDCall - 10 stdcall k32CharToOemA(str ptr) - 11 stdcall k32CharToOemBuffA(str ptr long) - 12 stdcall k32OemToCharA(ptr ptr) - 13 stdcall k32OemToCharBuffA(ptr ptr long) - 14 stdcall k32LoadStringA(long long ptr long) - 15 varargs k32wsprintfA(str str) - 16 stdcall k32wvsprintfA(ptr str ptr) - 17 stdcall -i386 CommonUnimpStub() - 18 stdcall GetProcessDword(long long) - 19 stub ThunkTheTemplateHandle - 20 stdcall DosFileHandleToWin32Handle(long) - 21 stdcall Win32HandleToDosFileHandle(long) - 22 stdcall DisposeLZ32Handle(long) - 23 stub GDIReallyCares - 24 stdcall GlobalAlloc16(long long) - 25 stdcall GlobalLock16(long) - 26 stdcall GlobalUnlock16(long) - 27 stdcall GlobalFix16(long) - 28 stdcall GlobalUnfix16(long) - 29 stdcall GlobalWire16(long) - 30 stdcall GlobalUnWire16(long) - 31 stdcall GlobalFree16(long) - 32 stdcall GlobalSize16(long) - 33 stdcall HouseCleanLogicallyDeadHandles() - 34 stdcall GetWin16DOSEnv() - 35 stdcall LoadLibrary16(str) - 36 stdcall FreeLibrary16(long) - 37 stdcall GetProcAddress16(long str) WIN32_GetProcAddress16 - 38 stdcall -i386 AllocMappedBuffer() - 39 stdcall -i386 FreeMappedBuffer() - 40 stdcall -i386 OT_32ThkLSF() - 41 stdcall ThunkInitLSF(long str long str str) - 42 stdcall -i386 LogApiThkLSF(str) - 43 stdcall ThunkInitLS(long str long str str) - 44 stdcall -i386 LogApiThkSL(str) - 45 stdcall -i386 Common32ThkLS() - 46 stdcall ThunkInitSL(long str long str str) - 47 stdcall -i386 LogCBThkSL(str) - 48 stdcall ReleaseThunkLock(ptr) - 49 stdcall RestoreThunkLock(long) + 1 stdcall -noname -i386 VxDCall0(long) VxDCall + 2 stdcall -noname -i386 VxDCall1(long) VxDCall + 3 stdcall -noname -i386 VxDCall2(long) VxDCall + 4 stdcall -noname -i386 VxDCall3(long) VxDCall + 5 stdcall -noname -i386 VxDCall4(long) VxDCall + 6 stdcall -noname -i386 VxDCall5(long) VxDCall + 7 stdcall -noname -i386 VxDCall6(long) VxDCall + 8 stdcall -noname -i386 VxDCall7(long) VxDCall + 9 stdcall -noname -i386 VxDCall8(long) VxDCall + 10 stdcall -noname k32CharToOemA(str ptr) + 11 stdcall -noname k32CharToOemBuffA(str ptr long) + 12 stdcall -noname k32OemToCharA(ptr ptr) + 13 stdcall -noname k32OemToCharBuffA(ptr ptr long) + 14 stdcall -noname k32LoadStringA(long long ptr long) + 15 varargs -noname k32wsprintfA(str str) + 16 stdcall -noname k32wvsprintfA(ptr str ptr) + 17 stdcall -noname -i386 CommonUnimpStub() + 18 stdcall -noname GetProcessDword(long long) + 19 stub -noname ThunkTheTemplateHandle + 20 stdcall -noname DosFileHandleToWin32Handle(long) + 21 stdcall -noname Win32HandleToDosFileHandle(long) + 22 stdcall -noname DisposeLZ32Handle(long) + 23 stub -noname GDIReallyCares + 24 stdcall -noname GlobalAlloc16(long long) + 25 stdcall -noname GlobalLock16(long) + 26 stdcall -noname GlobalUnlock16(long) + 27 stdcall -noname GlobalFix16(long) + 28 stdcall -noname GlobalUnfix16(long) + 29 stdcall -noname GlobalWire16(long) + 30 stdcall -noname GlobalUnWire16(long) + 31 stdcall -noname GlobalFree16(long) + 32 stdcall -noname GlobalSize16(long) + 33 stdcall -noname HouseCleanLogicallyDeadHandles() + 34 stdcall -noname GetWin16DOSEnv() + 35 stdcall -noname LoadLibrary16(str) + 36 stdcall -noname FreeLibrary16(long) + 37 stdcall -noname GetProcAddress16(long str) WIN32_GetProcAddress16 + 38 stdcall -noname -i386 AllocMappedBuffer() + 39 stdcall -noname -i386 FreeMappedBuffer() + 40 stdcall -noname -i386 OT_32ThkLSF() + 41 stdcall -noname ThunkInitLSF(long str long str str) + 42 stdcall -noname -i386 LogApiThkLSF(str) + 43 stdcall -noname ThunkInitLS(long str long str str) + 44 stdcall -noname -i386 LogApiThkSL(str) + 45 stdcall -noname -i386 Common32ThkLS() + 46 stdcall -noname ThunkInitSL(long str long str str) + 47 stdcall -noname -i386 LogCBThkSL(str) + 48 stdcall -noname ReleaseThunkLock(ptr) + 49 stdcall -noname RestoreThunkLock(long) - 51 stdcall -i386 W32S_BackTo32() - 52 stdcall GetThunkBuff() - 53 stdcall GetThunkStuff(str str) - 54 stdcall K32WOWCallback16(long long) - 55 stdcall K32WOWCallback16Ex(ptr long long ptr ptr) - 56 stdcall K32WOWGetVDMPointer(long long long) - 57 stdcall K32WOWHandle32(long long) - 58 stdcall K32WOWHandle16(long long) - 59 stdcall K32WOWGlobalAlloc16(long long) - 60 stdcall K32WOWGlobalLock16(long) - 61 stdcall K32WOWGlobalUnlock16(long) - 62 stdcall K32WOWGlobalFree16(long) - 63 stdcall K32WOWGlobalAllocLock16(long long ptr) - 64 stdcall K32WOWGlobalUnlockFree16(long) - 65 stdcall K32WOWGlobalLockSize16(long ptr) - 66 stdcall K32WOWYield16() - 67 stdcall K32WOWDirectedYield16(long) - 68 stdcall K32WOWGetVDMPointerFix(long long long) - 69 stdcall K32WOWGetVDMPointerUnfix(long) - 70 stdcall K32WOWGetDescriptor(long long) - 71 stub IsThreadId - 72 stdcall -ret64 K32RtlLargeIntegerAdd(long long long long) ntdll.RtlLargeIntegerAdd - 73 stdcall -ret64 K32RtlEnlargedIntegerMultiply(long long) ntdll.RtlEnlargedIntegerMultiply - 74 stdcall -ret64 K32RtlEnlargedUnsignedMultiply(long long) ntdll.RtlEnlargedUnsignedMultiply - 75 stdcall K32RtlEnlargedUnsignedDivide(long long long ptr) ntdll.RtlEnlargedUnsignedDivide - 76 stdcall -ret64 K32RtlExtendedLargeIntegerDivide(long long long ptr) ntdll.RtlExtendedLargeIntegerDivide - 77 stdcall -ret64 K32RtlExtendedMagicDivide(long long long long long) ntdll.RtlExtendedMagicDivide - 78 stdcall -ret64 K32RtlExtendedIntegerMultiply(long long long) ntdll.RtlExtendedIntegerMultiply - 79 stdcall -ret64 K32RtlLargeIntegerShiftLeft(long long long) ntdll.RtlLargeIntegerShiftLeft - 80 stdcall -ret64 K32RtlLargeIntegerShiftRight(long long long) ntdll.RtlLargeIntegerShiftRight - 81 stdcall -ret64 K32RtlLargeIntegerArithmeticShift(long long long) ntdll.RtlLargeIntegerArithmeticShift - 82 stdcall -ret64 K32RtlLargeIntegerNegate(long long) ntdll.RtlLargeIntegerNegate - 83 stdcall -ret64 K32RtlLargeIntegerSubtract(long long long long) ntdll.RtlLargeIntegerSubtract - 84 stdcall -ret64 K32RtlConvertLongToLargeInteger(long) ntdll.RtlConvertLongToLargeInteger - 85 stdcall -ret64 K32RtlConvertUlongToLargeInteger(long) ntdll.RtlConvertUlongToLargeInteger + 51 stdcall -noname -i386 W32S_BackTo32() + 52 stdcall -noname GetThunkBuff() + 53 stdcall -noname GetThunkStuff(str str) + 54 stdcall -noname K32WOWCallback16(long long) + 55 stdcall -noname K32WOWCallback16Ex(ptr long long ptr ptr) + 56 stdcall -noname K32WOWGetVDMPointer(long long long) + 57 stdcall -noname K32WOWHandle32(long long) + 58 stdcall -noname K32WOWHandle16(long long) + 59 stdcall -noname K32WOWGlobalAlloc16(long long) + 60 stdcall -noname K32WOWGlobalLock16(long) + 61 stdcall -noname K32WOWGlobalUnlock16(long) + 62 stdcall -noname K32WOWGlobalFree16(long) + 63 stdcall -noname K32WOWGlobalAllocLock16(long long ptr) + 64 stdcall -noname K32WOWGlobalUnlockFree16(long) + 65 stdcall -noname K32WOWGlobalLockSize16(long ptr) + 66 stdcall -noname K32WOWYield16() + 67 stdcall -noname K32WOWDirectedYield16(long) + 68 stdcall -noname K32WOWGetVDMPointerFix(long long long) + 69 stdcall -noname K32WOWGetVDMPointerUnfix(long) + 70 stdcall -noname K32WOWGetDescriptor(long long) + 71 stub -noname IsThreadId + 72 stdcall -noname -ret64 K32RtlLargeIntegerAdd(long long long long) ntdll.RtlLargeIntegerAdd + 73 stdcall -noname -ret64 K32RtlEnlargedIntegerMultiply(long long) ntdll.RtlEnlargedIntegerMultiply + 74 stdcall -noname -ret64 K32RtlEnlargedUnsignedMultiply(long long) ntdll.RtlEnlargedUnsignedMultiply + 75 stdcall -noname K32RtlEnlargedUnsignedDivide(long long long ptr) ntdll.RtlEnlargedUnsignedDivide + 76 stdcall -noname -ret64 K32RtlExtendedLargeIntegerDivide(long long long ptr) ntdll.RtlExtendedLargeIntegerDivide + 77 stdcall -noname -ret64 K32RtlExtendedMagicDivide(long long long long long) ntdll.RtlExtendedMagicDivide + 78 stdcall -noname -ret64 K32RtlExtendedIntegerMultiply(long long long) ntdll.RtlExtendedIntegerMultiply + 79 stdcall -noname -ret64 K32RtlLargeIntegerShiftLeft(long long long) ntdll.RtlLargeIntegerShiftLeft + 80 stdcall -noname -ret64 K32RtlLargeIntegerShiftRight(long long long) ntdll.RtlLargeIntegerShiftRight + 81 stdcall -noname -ret64 K32RtlLargeIntegerArithmeticShift(long long long) ntdll.RtlLargeIntegerArithmeticShift + 82 stdcall -noname -ret64 K32RtlLargeIntegerNegate(long long) ntdll.RtlLargeIntegerNegate + 83 stdcall -noname -ret64 K32RtlLargeIntegerSubtract(long long long long) ntdll.RtlLargeIntegerSubtract + 84 stdcall -noname -ret64 K32RtlConvertLongToLargeInteger(long) ntdll.RtlConvertLongToLargeInteger + 85 stdcall -noname -ret64 K32RtlConvertUlongToLargeInteger(long) ntdll.RtlConvertUlongToLargeInteger 86 stdcall @(ptr) _KERNEL32_86 - 87 stdcall SSOnBigStack() - 88 varargs SSCall(long long ptr) - 89 stdcall -i386 FT_PrologPrime() - 90 stdcall -i386 QT_ThunkPrime() - 91 stdcall PK16FNF(ptr) - 92 stdcall GetPK16SysVar() - 93 stdcall GetpWin16Lock(ptr) - 94 stdcall _CheckNotSysLevel(ptr) - 95 stdcall _ConfirmSysLevel(ptr) - 96 stdcall _ConfirmWin16Lock() - 97 stdcall _EnterSysLevel(ptr) - 98 stdcall _LeaveSysLevel(ptr) + 87 stdcall -noname SSOnBigStack() + 88 varargs -noname SSCall(long long ptr) + 89 stdcall -noname -i386 FT_PrologPrime() + 90 stdcall -noname -i386 QT_ThunkPrime() + 91 stdcall -noname PK16FNF(ptr) + 92 stdcall -noname GetPK16SysVar() + 93 stdcall -noname GetpWin16Lock(ptr) + 94 stdcall -noname _CheckNotSysLevel(ptr) + 95 stdcall -noname _ConfirmSysLevel(ptr) + 96 stdcall -noname _ConfirmWin16Lock() + 97 stdcall -noname _EnterSysLevel(ptr) + 98 stdcall -noname _LeaveSysLevel(ptr) 99 stdcall @(long) _KERNEL32_99 100 stdcall @(long long long) _KERNEL32_100 101 stub @ @@ -214,6 +214,7 @@ @ stdcall CopyFileExA (str str ptr ptr ptr long) @ stdcall CopyFileExW (wstr wstr ptr ptr ptr long) @ stdcall CopyFileW(wstr wstr long) +@ stdcall CopyLZFile(long long) @ stdcall CreateActCtxA(ptr) @ stdcall CreateActCtxW(ptr) @ stdcall CreateConsoleScreenBuffer(long long ptr long ptr) @@ -484,6 +485,8 @@ @ stub GetErrorMode @ stdcall GetExitCodeProcess(long ptr) @ stdcall GetExitCodeThread(long ptr) +@ stdcall GetExpandedNameA(str ptr) +@ stdcall GetExpandedNameW(wstr ptr) @ stdcall GetFileAttributesA(str) @ stdcall GetFileAttributesExA(str long ptr) @ stdcall GetFileAttributesExW(wstr long ptr) @@ -714,6 +717,15 @@ @ stdcall LockFile(long long long long long) @ stdcall LockFileEx(long long long long long ptr) @ stdcall LockResource(long) +@ stdcall LZClose(long) +@ stdcall LZCopy(long long) +@ stdcall LZDone() +@ stdcall LZInit(long) +@ stdcall LZOpenFileA(str ptr long) +@ stdcall LZOpenFileW(wstr ptr long) +@ stdcall LZRead(long ptr long) +@ stdcall LZSeek(long long long) +@ stdcall LZStart() @ stdcall MakeCriticalSectionGlobal(ptr) @ stdcall -i386 MapHInstLS() @ stdcall -i386 MapHInstLS_PN() diff -urN wine-20050628/dlls/kernel/kernel_main.c wine-20050725/dlls/kernel/kernel_main.c --- wine-20050628/dlls/kernel/kernel_main.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/kernel_main.c 2005-07-14 12:32:46.000000000 +0200 @@ -28,6 +28,10 @@ #ifdef HAVE_SYS_STAT_H # include #endif +#include +#ifdef HAVE_SYS_TIME_H +# include +#endif #include #include "windef.h" @@ -56,6 +60,8 @@ }; static CRITICAL_SECTION ldt_section = { &critsect_debug, -1, 0, 0, 0, 0 }; +static DWORD server_start_time; + /*********************************************************************** * locking for LDT routines */ @@ -102,6 +108,10 @@ { HMODULE16 hModule; SYSTEM_INFO si; + SYSTEM_TIMEOFDAY_INFORMATION sti; + + NtQuerySystemInformation( SystemTimeOfDayInformation, &sti, sizeof(sti), NULL ); + RtlTimeToSecondsSince1970( &sti.liKeBootTime, &server_start_time ); /* FIXME: should probably be done in ntdll */ GetSystemInfo( &si ); @@ -263,3 +273,28 @@ if ((ret > 2147483647) || (ret < -2147483647)) return -1; return ret; } + + +/*********************************************************************** + * GetSystemMSecCount (SYSTEM.6) + * GetTickCount (KERNEL32.@) + * + * Get the number of milliseconds the system has been running. + * + * PARAMS + * None. + * + * RETURNS + * The current tick count. + * + * NOTES + * -The value returned will wrap arounf every 2^32 milliseconds. + * -Under Windows, tick 0 is the moment at which the system is rebooted. + * Under Wine, tick 0 begins at the moment the wineserver process is started, + */ +DWORD WINAPI GetTickCount(void) +{ + struct timeval t; + gettimeofday( &t, NULL ); + return ((t.tv_sec - server_start_time) * 1000) + (t.tv_usec / 1000); +} diff -urN wine-20050628/dlls/kernel/lzexpand.c wine-20050725/dlls/kernel/lzexpand.c --- wine-20050628/dlls/kernel/lzexpand.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/kernel/lzexpand.c 2005-07-25 13:08:31.000000000 +0200 @@ -0,0 +1,598 @@ +/* + * LZ Decompression functions + * + * Copyright 1996 Marcus Meissner + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * NOTES + * + * The LZ (Lempel Ziv) decompression was used in win16 installation programs. + * It is a simple tabledriven decompression engine, the algorithm is not + * documented as far as I know. WINE does not contain a compressor for + * this format. + * + * The implementation is complete and there have been no reports of failures + * for some time. + * + * TODO: + * + * o Check whether the return values are correct + * + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif + +#include "windef.h" +#include "winbase.h" +#include "lzexpand.h" + +#include "wine/unicode.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(file); + +/* The readahead length of the decompressor. Reading single bytes + * using _lread() would be SLOW. + */ +#define GETLEN 2048 + +/* Format of first 14 byte of LZ compressed file */ +struct lzfileheader { + BYTE magic[8]; + BYTE compressiontype; + CHAR lastchar; + DWORD reallength; +}; +static BYTE LZMagic[8]={'S','Z','D','D',0x88,0xf0,0x27,0x33}; + +struct lzstate { + HFILE realfd; /* the real filedescriptor */ + CHAR lastchar; /* the last char of the filename */ + + DWORD reallength; /* the decompressed length of the file */ + DWORD realcurrent; /* the position the decompressor currently is */ + DWORD realwanted; /* the position the user wants to read from */ + + BYTE table[0x1000]; /* the rotating LZ table */ + UINT curtabent; /* CURrent TABle ENTry */ + + BYTE stringlen; /* length and position of current string */ + DWORD stringpos; /* from stringtable */ + + + WORD bytetype; /* bitmask within blocks */ + + BYTE *get; /* GETLEN bytes */ + DWORD getcur; /* current read */ + DWORD getlen; /* length last got */ +}; + +#define MAX_LZSTATES 16 +static struct lzstate *lzstates[MAX_LZSTATES]; + +#define IS_LZ_HANDLE(h) (((h) >= 0x400) && ((h) < 0x400+MAX_LZSTATES)) +#define GET_LZ_STATE(h) (IS_LZ_HANDLE(h) ? lzstates[(h)-0x400] : NULL) + +/* reads one compressed byte, including buffering */ +#define GET(lzs,b) _lzget(lzs,&b) +#define GET_FLUSH(lzs) lzs->getcur=lzs->getlen; + +static int +_lzget(struct lzstate *lzs,BYTE *b) { + if (lzs->getcurgetlen) { + *b = lzs->get[lzs->getcur++]; + return 1; + } else { + int ret = _lread(lzs->realfd,lzs->get,GETLEN); + if (ret==HFILE_ERROR) + return HFILE_ERROR; + if (ret==0) + return 0; + lzs->getlen = ret; + lzs->getcur = 1; + *b = *(lzs->get); + return 1; + } +} +/* internal function, reads lzheader + * returns BADINHANDLE for non filedescriptors + * return 0 for file not compressed using LZ + * return UNKNOWNALG for unknown algorithm + * returns lzfileheader in *head + */ +static INT read_header(HFILE fd,struct lzfileheader *head) +{ + BYTE buf[14]; + + if (_llseek(fd,0,SEEK_SET)==-1) + return LZERROR_BADINHANDLE; + + /* We can't directly read the lzfileheader struct due to + * structure element alignment + */ + if (_lread(fd,buf,14)<14) + return 0; + memcpy(head->magic,buf,8); + memcpy(&(head->compressiontype),buf+8,1); + memcpy(&(head->lastchar),buf+9,1); + + /* FIXME: consider endianess on non-intel architectures */ + memcpy(&(head->reallength),buf+10,4); + + if (memcmp(head->magic,LZMagic,8)) + return 0; + if (head->compressiontype!='A') + return LZERROR_UNKNOWNALG; + return 1; +} + + +/*********************************************************************** + * LZStart (LZ32.@) + */ +INT WINAPI LZStart(void) +{ + TRACE("(void)\n"); + return 1; +} + + +/*********************************************************************** + * LZInit (LZ32.@) + * + * initializes internal decompression buffers, returns lzfiledescriptor. + * (return value the same as hfSrc, if hfSrc is not compressed) + * on failure, returns error code <0 + * lzfiledescriptors range from 0x400 to 0x410 (only 16 open files per process) + * + * since _llseek uses the same types as libc.lseek, we just use the macros of + * libc + */ +HFILE WINAPI LZInit( HFILE hfSrc ) +{ + + struct lzfileheader head; + struct lzstate *lzs; + DWORD ret; + int i; + + TRACE("(%d)\n",hfSrc); + ret=read_header(hfSrc,&head); + if (ret<=0) { + _llseek(hfSrc,0,SEEK_SET); + return ret?ret:hfSrc; + } + for (i = 0; i < MAX_LZSTATES; i++) if (!lzstates[i]) break; + if (i == MAX_LZSTATES) return LZERROR_GLOBALLOC; + lzstates[i] = lzs = HeapAlloc( GetProcessHeap(), 0, sizeof(struct lzstate) ); + if(lzs == NULL) return LZERROR_GLOBALLOC; + + memset(lzs,'\0',sizeof(*lzs)); + lzs->realfd = hfSrc; + lzs->lastchar = head.lastchar; + lzs->reallength = head.reallength; + + lzs->get = HeapAlloc( GetProcessHeap(), 0, GETLEN ); + lzs->getlen = 0; + lzs->getcur = 0; + + if(lzs->get == NULL) { + HeapFree(GetProcessHeap(), 0, lzs); + lzstates[i] = NULL; + return LZERROR_GLOBALLOC; + } + + /* Yes, preinitialize with spaces */ + memset(lzs->table,' ',0x1000); + /* Yes, start 16 byte from the END of the table */ + lzs->curtabent = 0xff0; + return 0x400 + i; +} + + +/*********************************************************************** + * LZDone (LZEXPAND.9) + * LZDone (LZ32.@) + */ +void WINAPI LZDone(void) +{ + TRACE("(void)\n"); +} + + +/*********************************************************************** + * GetExpandedNameA (LZ32.@) + * + * gets the full filename of the compressed file 'in' by opening it + * and reading the header + * + * "file." is being translated to "file" + * "file.bl_" (with lastchar 'a') is being translated to "file.bla" + * "FILE.BL_" (with lastchar 'a') is being translated to "FILE.BLA" + */ + +INT WINAPI GetExpandedNameA( LPSTR in, LPSTR out ) +{ + struct lzfileheader head; + HFILE fd; + OFSTRUCT ofs; + INT fnislowercased,ret,len; + LPSTR s,t; + + TRACE("(%s)\n",in); + fd=OpenFile(in,&ofs,OF_READ); + if (fd==HFILE_ERROR) + return (INT)(INT16)LZERROR_BADINHANDLE; + strcpy(out,in); + ret=read_header(fd,&head); + if (ret<=0) { + /* not a LZ compressed file, so the expanded name is the same + * as the input name */ + _lclose(fd); + return 1; + } + + + /* look for directory prefix and skip it. */ + s=out; + while (NULL!=(t=strpbrk(s,"/\\:"))) + s=t+1; + + /* now mangle the basename */ + if (!*s) { + /* FIXME: hmm. shouldn't happen? */ + WARN("Specified a directory or what? (%s)\n",in); + _lclose(fd); + return 1; + } + /* see if we should use lowercase or uppercase on the last char */ + fnislowercased=1; + t=s+strlen(s)-1; + while (t>=out) { + if (!isalpha(*t)) { + t--; + continue; + } + fnislowercased=islower(*t); + break; + } + if (isalpha(head.lastchar)) { + if (fnislowercased) + head.lastchar=tolower(head.lastchar); + else + head.lastchar=toupper(head.lastchar); + } + + /* now look where to replace the last character */ + if (NULL!=(t=strchr(s,'.'))) { + if (t[1]=='\0') { + t[0]='\0'; + } else { + len=strlen(t)-1; + if (t[len]=='_') + t[len]=head.lastchar; + } + } /* else no modification necessary */ + _lclose(fd); + return 1; +} + + +/*********************************************************************** + * GetExpandedNameW (LZ32.@) + */ +INT WINAPI GetExpandedNameW( LPWSTR in, LPWSTR out ) +{ + INT ret; + DWORD len = WideCharToMultiByte( CP_ACP, 0, in, -1, NULL, 0, NULL, NULL ); + char *xin = HeapAlloc( GetProcessHeap(), 0, len ); + char *xout = HeapAlloc( GetProcessHeap(), 0, len+3 ); + WideCharToMultiByte( CP_ACP, 0, in, -1, xin, len, NULL, NULL ); + if ((ret = GetExpandedNameA( xin, xout )) > 0) + MultiByteToWideChar( CP_ACP, 0, xout, -1, out, strlenW(in)+4 ); + HeapFree( GetProcessHeap(), 0, xin ); + HeapFree( GetProcessHeap(), 0, xout ); + return ret; +} + + +/*********************************************************************** + * LZRead (LZ32.@) + */ +INT WINAPI LZRead( HFILE fd, LPSTR vbuf, INT toread ) +{ + int howmuch; + BYTE b,*buf; + struct lzstate *lzs; + + buf=(LPBYTE)vbuf; + TRACE("(%d,%p,%d)\n",fd,buf,toread); + howmuch=toread; + if (!(lzs = GET_LZ_STATE(fd))) return _lread(fd,buf,toread); + +/* The decompressor itself is in a define, cause we need it twice + * in this function. (the decompressed byte will be in b) + */ +#define DECOMPRESS_ONE_BYTE \ + if (lzs->stringlen) { \ + b = lzs->table[lzs->stringpos]; \ + lzs->stringpos = (lzs->stringpos+1)&0xFFF; \ + lzs->stringlen--; \ + } else { \ + if (!(lzs->bytetype&0x100)) { \ + if (1!=GET(lzs,b)) \ + return toread-howmuch; \ + lzs->bytetype = b|0xFF00; \ + } \ + if (lzs->bytetype & 1) { \ + if (1!=GET(lzs,b)) \ + return toread-howmuch; \ + } else { \ + BYTE b1,b2; \ + \ + if (1!=GET(lzs,b1)) \ + return toread-howmuch; \ + if (1!=GET(lzs,b2)) \ + return toread-howmuch; \ + /* Format: \ + * b1 b2 \ + * AB CD \ + * where CAB is the stringoffset in the table\ + * and D+3 is the len of the string \ + */ \ + lzs->stringpos = b1|((b2&0xf0)<<4); \ + lzs->stringlen = (b2&0xf)+2; \ + /* 3, but we use a byte already below ... */\ + b = lzs->table[lzs->stringpos];\ + lzs->stringpos = (lzs->stringpos+1)&0xFFF;\ + } \ + lzs->bytetype>>=1; \ + } \ + /* store b in table */ \ + lzs->table[lzs->curtabent++]= b; \ + lzs->curtabent &= 0xFFF; \ + lzs->realcurrent++; + + /* if someone has seeked, we have to bring the decompressor + * to that position + */ + if (lzs->realcurrent!=lzs->realwanted) { + /* if the wanted position is before the current position + * I see no easy way to unroll ... We have to restart at + * the beginning. *sigh* + */ + if (lzs->realcurrent>lzs->realwanted) { + /* flush decompressor state */ + _llseek(lzs->realfd,14,SEEK_SET); + GET_FLUSH(lzs); + lzs->realcurrent= 0; + lzs->bytetype = 0; + lzs->stringlen = 0; + memset(lzs->table,' ',0x1000); + lzs->curtabent = 0xFF0; + } + while (lzs->realcurrentrealwanted) { + DECOMPRESS_ONE_BYTE; + } + } + + while (howmuch) { + DECOMPRESS_ONE_BYTE; + lzs->realwanted++; + *buf++ = b; + howmuch--; + } + return toread; +#undef DECOMPRESS_ONE_BYTE +} + + +/*********************************************************************** + * LZSeek (LZ32.@) + */ +LONG WINAPI LZSeek( HFILE fd, LONG off, INT type ) +{ + struct lzstate *lzs; + LONG newwanted; + + TRACE("(%d,%ld,%d)\n",fd,off,type); + /* not compressed? just use normal _llseek() */ + if (!(lzs = GET_LZ_STATE(fd))) return _llseek(fd,off,type); + newwanted = lzs->realwanted; + switch (type) { + case 1: /* SEEK_CUR */ + newwanted += off; + break; + case 2: /* SEEK_END */ + newwanted = lzs->reallength-off; + break; + default:/* SEEK_SET */ + newwanted = off; + break; + } + if (newwanted>lzs->reallength) + return LZERROR_BADVALUE; + if (newwanted<0) + return LZERROR_BADVALUE; + lzs->realwanted = newwanted; + return newwanted; +} + + +/*********************************************************************** + * LZCopy (LZ32.@) + * + * Copies everything from src to dest + * if src is a LZ compressed file, it will be uncompressed. + * will return the number of bytes written to dest or errors. + */ +LONG WINAPI LZCopy( HFILE src, HFILE dest ) +{ + int usedlzinit = 0, ret, wret; + LONG len; + HFILE oldsrc = src, srcfd; + FILETIME filetime; + struct lzstate *lzs; +#define BUFLEN 1000 + BYTE buf[BUFLEN]; + /* we need that weird typedef, for i can't seem to get function pointer + * casts right. (Or they probably just do not like WINAPI in general) + */ + typedef UINT (WINAPI *_readfun)(HFILE,LPVOID,UINT); + + _readfun xread; + + TRACE("(%d,%d)\n",src,dest); + if (!IS_LZ_HANDLE(src)) { + src = LZInit(src); + if ((INT)src <= 0) return 0; + if (src != oldsrc) usedlzinit=1; + } + + /* not compressed? just copy */ + if (!IS_LZ_HANDLE(src)) + xread=_lread; + else + xread=(_readfun)LZRead; + len=0; + while (1) { + ret=xread(src,buf,BUFLEN); + if (ret<=0) { + if (ret==0) + break; + if (ret==-1) + return LZERROR_READ; + return ret; + } + len += ret; + wret = _lwrite(dest,buf,ret); + if (wret!=ret) + return LZERROR_WRITE; + } + + /* Maintain the timestamp of source file to destination file */ + srcfd = (!(lzs = GET_LZ_STATE(src))) ? src : lzs->realfd; + GetFileTime((HANDLE)srcfd, NULL, NULL, &filetime); + SetFileTime((HANDLE)dest, NULL, NULL, &filetime); + + /* close handle */ + if (usedlzinit) + LZClose(src); + return len; +#undef BUFLEN +} + +/* reverses GetExpandedPathname */ +static LPSTR LZEXPAND_MangleName( LPCSTR fn ) +{ + char *p; + char *mfn = HeapAlloc( GetProcessHeap(), 0, strlen(fn) + 3 ); /* "._" and \0 */ + if(mfn == NULL) return NULL; + strcpy( mfn, fn ); + if (!(p = strrchr( mfn, '\\' ))) p = mfn; + if ((p = strchr( p, '.' ))) + { + p++; + if (strlen(p) < 3) strcat( p, "_" ); /* append '_' */ + else p[strlen(p)-1] = '_'; /* replace last character */ + } + else strcat( mfn, "._" ); /* append "._" */ + return mfn; +} + + +/*********************************************************************** + * LZOpenFileA (LZ32.@) + * + * Opens a file. If not compressed, open it as a normal file. + */ +HFILE WINAPI LZOpenFileA( LPSTR fn, LPOFSTRUCT ofs, WORD mode ) +{ + HFILE fd,cfd; + + TRACE("(%s,%p,%d)\n",fn,ofs,mode); + /* 0x70 represents all OF_SHARE_* flags, ignore them for the check */ + fd=OpenFile(fn,ofs,mode); + if (fd==HFILE_ERROR) + { + LPSTR mfn = LZEXPAND_MangleName(fn); + fd = OpenFile(mfn,ofs,mode); + HeapFree( GetProcessHeap(), 0, mfn ); + } + if ((mode&~0x70)!=OF_READ) + return fd; + if (fd==HFILE_ERROR) + return HFILE_ERROR; + cfd=LZInit(fd); + if ((INT)cfd <= 0) return fd; + return cfd; +} + + +/*********************************************************************** + * LZOpenFileW (LZ32.@) + */ +HFILE WINAPI LZOpenFileW( LPWSTR fn, LPOFSTRUCT ofs, WORD mode ) +{ + HFILE ret; + DWORD len = WideCharToMultiByte( CP_ACP, 0, fn, -1, NULL, 0, NULL, NULL ); + LPSTR xfn = HeapAlloc( GetProcessHeap(), 0, len ); + WideCharToMultiByte( CP_ACP, 0, fn, -1, xfn, len, NULL, NULL ); + ret = LZOpenFileA(xfn,ofs,mode); + HeapFree( GetProcessHeap(), 0, xfn ); + return ret; +} + + +/*********************************************************************** + * LZClose (LZ32.@) + */ +void WINAPI LZClose( HFILE fd ) +{ + struct lzstate *lzs; + + TRACE("(%d)\n",fd); + if (!(lzs = GET_LZ_STATE(fd))) _lclose(fd); + else + { + HeapFree( GetProcessHeap(), 0, lzs->get ); + CloseHandle((HANDLE)lzs->realfd); + lzstates[fd - 0x400] = NULL; + HeapFree( GetProcessHeap(), 0, lzs ); + } +} + + +/*********************************************************************** + * CopyLZFile (LZ32.@) + * + * Copy src to dest (including uncompressing src). + * NOTE: Yes. This is exactly the same function as LZCopy. + */ +LONG WINAPI CopyLZFile( HFILE src, HFILE dest ) +{ + TRACE("(%d,%d)\n",src,dest); + return LZCopy(src,dest); +} diff -urN wine-20050628/dlls/kernel/module.c wine-20050725/dlls/kernel/module.c --- wine-20050628/dlls/kernel/module.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/module.c 2005-07-11 20:39:49.000000000 +0200 @@ -810,6 +810,8 @@ NTSTATUS nts; FARPROC fp; + if (!hModule) hModule = NtCurrentTeb()->Peb->ImageBaseAddress; + if (HIWORD(function)) { ANSI_STRING str; diff -urN wine-20050628/dlls/kernel/ne_module.c wine-20050725/dlls/kernel/ne_module.c --- wine-20050628/dlls/kernel/ne_module.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/ne_module.c 2005-07-22 11:03:14.000000000 +0200 @@ -45,6 +45,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(module); WINE_DECLARE_DEBUG_CHANNEL(loaddll); +WINE_DECLARE_DEBUG_CHANNEL(relay); #include "pshpack1.h" typedef struct _GPHANDLERDEF @@ -103,21 +104,19 @@ { #ifdef __i386__ int i; + CALLFROM16 *call; SEGTABLEENTRY *pSeg = NE_SEG_TABLE( pModule ); for (i = 0; i < pModule->ne_cseg; i++, pSeg++) - { - if (!(pSeg->flags & NE_SEGFLAGS_DATA)) /* found the code segment */ - { - CALLFROM16 *call = GlobalLock16( pSeg->hSeg ); - if (call->flatcs == wine_get_cs()) return; /* nothing to patch */ - while (call->pushl == 0x68) - { - call->flatcs = wine_get_cs(); - call++; - } - } - } + if (!(pSeg->flags & NE_SEGFLAGS_DATA)) break; /* found the code segment */ + + call = GlobalLock16( pSeg->hSeg ); + + if (call->flatcs != wine_get_cs()) /* need to patch cs values */ + for (i = 0; call[i].pushl == 0x68; i++) call[i].flatcs = wine_get_cs(); + + if (TRACE_ON(relay)) /* patch relay functions to all point to relay_call_from_16 */ + for (i = 0; call[i].pushl == 0x68; i++) call[i].relay = relay_call_from_16; #endif } @@ -1597,8 +1596,8 @@ if (!(pModule = NE_GetPtr( hModule ))) return 0; lstrcpynA( lpFileName, NE_MODULE_NAME(pModule), nSize ); - if (pModule->ne_expver >= 0x400) - GetLongPathNameA(NE_MODULE_NAME(pModule), lpFileName, nSize); + if (pModule->ne_expver < 0x400) + GetShortPathNameA(NE_MODULE_NAME(pModule), lpFileName, nSize); TRACE("%04x -> '%s'\n", hModule, lpFileName ); return strlen(lpFileName); } diff -urN wine-20050628/dlls/kernel/oldconfig.c wine-20050725/dlls/kernel/oldconfig.c --- wine-20050628/dlls/kernel/oldconfig.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/oldconfig.c 2005-07-11 22:44:59.000000000 +0200 @@ -56,426 +56,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(reg); -/* create symlinks for the DOS drives; helper for create_dos_devices */ -static int create_drives( int devices_only ) -{ - static const WCHAR PathW[] = {'P','a','t','h',0}; - static const WCHAR DeviceW[] = {'D','e','v','i','c','e',0}; - WCHAR driveW[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\', - 'W','i','n','e','\\','W','i','n','e','\\', - 'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0}; - const char *config_dir = wine_get_config_dir(); - OBJECT_ATTRIBUTES attr; - UNICODE_STRING nameW; - char tmp[1024*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)]; - char dest[1024]; - char *buffer; - WCHAR *p, name[3]; - HANDLE hkey; - DWORD dummy; - int i, count = 0; - - attr.Length = sizeof(attr); - attr.RootDirectory = 0; - attr.ObjectName = &nameW; - attr.Attributes = 0; - attr.SecurityDescriptor = NULL; - attr.SecurityQualityOfService = NULL; - - /* create symlinks for the drive roots */ - - if (!devices_only) for (i = 0; i < 26; i++) - { - RtlInitUnicodeString( &nameW, driveW ); - nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i; - /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */ - if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue; - - RtlInitUnicodeString( &nameW, PathW ); - if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy )) - { - WCHAR path[1024]; - WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data; - ExpandEnvironmentStringsW( data, path, sizeof(path)/sizeof(WCHAR) ); - - p = path + strlenW(path) - 1; - while ((p > path) && (*p == '/')) *p-- = '\0'; - - name[0] = 'a' + i; - name[1] = ':'; - name[2] = 0; - - if (path[0] != '/') - { - /* relative paths are relative to config dir */ - memmove( path + 3, path, (strlenW(path) + 1) * sizeof(WCHAR) ); - path[0] = '.'; - path[1] = '.'; - path[2] = '/'; - } - if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, name, path )) - { - WideCharToMultiByte(CP_UNIXCP, 0, path, -1, dest, sizeof(dest), NULL, NULL); - MESSAGE( "Created symlink %s/dosdevices/%c: -> %s\n", - wine_get_config_dir(), 'a' + i, dest ); - count++; - } - } - NtClose( hkey ); - } - - /* create symlinks for the drive devices */ - - buffer = HeapAlloc( GetProcessHeap(), 0, - strlen(config_dir) + sizeof("/dosdevices/a::") ); - strcpy( buffer, config_dir ); - strcat( buffer, "/dosdevices/a::" ); - - for (i = 0; i < 26; i++) - { - RtlInitUnicodeString( &nameW, driveW ); - nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i; - /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */ - if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue; - - RtlInitUnicodeString( &nameW, DeviceW ); - if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy )) - { - WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data; - WideCharToMultiByte(CP_UNIXCP, 0, data, -1, dest, sizeof(dest), NULL, NULL); - - buffer[strlen(buffer) - 3] = 'a' + i; - if (!symlink( dest, buffer )) - { - MESSAGE( "Created symlink %s/dosdevices/%c:: -> %s\n", - wine_get_config_dir(), 'a' + i, dest ); - count++; - } - } - NtClose( hkey ); - } - HeapFree( GetProcessHeap(), 0, buffer ); - - return count; -} - - -/* create the device files for the new device naming scheme */ -static void create_dos_devices(void) -{ - const char *config_dir = wine_get_config_dir(); - char *buffer; - int i, count = 0; - - if (!(buffer = HeapAlloc( GetProcessHeap(), 0, - strlen(config_dir) + sizeof("/dosdevices/a::") ))) - return; - - strcpy( buffer, config_dir ); - strcat( buffer, "/dosdevices" ); - - if (!mkdir( buffer, 0777 )) /* we created it, so now create the devices */ - { - HANDLE hkey; - DWORD dummy; - OBJECT_ATTRIBUTES attr; - UNICODE_STRING nameW; - WCHAR *p, *devnameW; - char tmp[128]; - WCHAR com[5] = {'C','O','M','1',0}; - WCHAR lpt[5] = {'L','P','T','1',0}; - - static const WCHAR serialportsW[] = {'M','a','c','h','i','n','e','\\', - 'S','o','f','t','w','a','r','e','\\', - 'W','i','n','e','\\','W','i','n','e','\\', - 'C','o','n','f','i','g','\\', - 'S','e','r','i','a','l','P','o','r','t','s',0}; - static const WCHAR parallelportsW[] = {'M','a','c','h','i','n','e','\\', - 'S','o','f','t','w','a','r','e','\\', - 'W','i','n','e','\\','W','i','n','e','\\', - 'C','o','n','f','i','g','\\', - 'P','a','r','a','l','l','e','l','P','o','r','t','s',0}; - - attr.Length = sizeof(attr); - attr.RootDirectory = 0; - attr.ObjectName = &nameW; - attr.Attributes = 0; - attr.SecurityDescriptor = NULL; - attr.SecurityQualityOfService = NULL; - RtlInitUnicodeString( &nameW, serialportsW ); - - /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\SerialPorts */ - if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) - { - RtlInitUnicodeString( &nameW, com ); - for (i = 1; i <= 9; i++) - { - com[3] = '0' + i; - if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, - tmp, sizeof(tmp), &dummy )) - { - devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data; - if ((p = strchrW( devnameW, ',' ))) *p = 0; - if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, com, devnameW )) - { - char devname[32]; - WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1, - devname, sizeof(devname), NULL, NULL); - MESSAGE( "Created symlink %s/dosdevices/com%d -> %s\n", config_dir, i, devname ); - count++; - } - } - } - NtClose( hkey ); - } - - /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\ParallelPorts */ - RtlInitUnicodeString( &nameW, parallelportsW ); - if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) - { - RtlInitUnicodeString( &nameW, lpt ); - for (i = 1; i <= 9; i++) - { - lpt[3] = '0' + i; - if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, - tmp, sizeof(tmp), &dummy )) - { - devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data; - if ((p = strchrW( devnameW, ',' ))) *p = 0; - if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, lpt, devnameW )) - { - char devname[32]; - WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1, - devname, sizeof(devname), NULL, NULL); - MESSAGE( "Created symlink %s/dosdevices/lpt%d -> %s\n", config_dir, i, devname ); - count++; - } - } - } - NtClose( hkey ); - } - count += create_drives( FALSE ); - } - else - { - struct stat st; - int i; - - /* it is possible that the serial/parallel devices have been created but */ - /* not the drives; check for at least one drive symlink to catch that case */ - strcat( buffer, "/a:" ); - for (i = 0; i < 26; i++) - { - buffer[strlen(buffer)-2] = 'a' + i; - if (!lstat( buffer, &st )) break; - } - if (i == 26) count += create_drives( FALSE ); - else - { - strcat( buffer, ":" ); - for (i = 0; i < 26; i++) - { - buffer[strlen(buffer)-3] = 'a' + i; - if (!lstat( buffer, &st )) break; - } - if (i == 26) count += create_drives( TRUE ); - } - } - - if (count) - MESSAGE( "\nYou can now remove the [SerialPorts], [ParallelPorts], and [Drive] sections\n" - "in your configuration file, they are replaced by the above symlinks.\n\n" ); - - HeapFree( GetProcessHeap(), 0, buffer ); -} - - -/* convert the drive type entries from the old format to the new one */ -static void convert_drive_types(void) -{ - static const WCHAR TypeW[] = {'T','y','p','e',0}; - static const WCHAR drive_types_keyW[] = {'M','a','c','h','i','n','e','\\', - 'S','o','f','t','w','a','r','e','\\', - 'W','i','n','e','\\', - 'D','r','i','v','e','s',0 }; - WCHAR driveW[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\', - 'W','i','n','e','\\','W','i','n','e','\\', - 'C','o','n','f','i','g','\\','D','r','i','v','e',' ','A',0}; - char tmp[32*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)]; - OBJECT_ATTRIBUTES attr; - UNICODE_STRING nameW; - DWORD dummy; - ULONG disp; - HANDLE hkey_old, hkey_new; - int i; - - attr.Length = sizeof(attr); - attr.RootDirectory = 0; - attr.ObjectName = &nameW; - attr.Attributes = 0; - attr.SecurityDescriptor = NULL; - attr.SecurityQualityOfService = NULL; - RtlInitUnicodeString( &nameW, drive_types_keyW ); - - /* @@ Wine registry key: HKLM\Software\Wine\Drives */ - if (NtCreateKey( &hkey_new, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp )) return; - if (disp != REG_CREATED_NEW_KEY) - { - NtClose( hkey_new ); - return; - } - - for (i = 0; i < 26; i++) - { - RtlInitUnicodeString( &nameW, driveW ); - nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i; - /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */ - if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue; - RtlInitUnicodeString( &nameW, TypeW ); - if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy )) - { - WCHAR valueW[] = {'A',':',0}; - WCHAR *type = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data; - - valueW[0] = 'A' + i; - RtlInitUnicodeString( &nameW, valueW ); - NtSetValueKey( hkey_new, &nameW, 0, REG_SZ, type, (strlenW(type) + 1) * sizeof(WCHAR) ); - MESSAGE( "Converted drive type to new entry HKLM\\Software\\Wine\\Drives \"%c:\" = %s\n", - 'A' + i, debugstr_w(type) ); - } - NtClose( hkey_old ); - } - NtClose( hkey_new ); -} - - -/* convert the environment variable entries from the old format to the new one */ -static void convert_environment( HANDLE hkey_current_user ) -{ - static const WCHAR wineW[] = {'M','a','c','h','i','n','e','\\', - 'S','o','f','t','w','a','r','e','\\', - 'W','i','n','e','\\','W','i','n','e','\\', - 'C','o','n','f','i','g','\\','W','i','n','e',0}; - static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0}; - static const WCHAR systemW[] = {'s','y','s','t','e','m',0}; - static const WCHAR windirW[] = {'w','i','n','d','i','r',0}; - static const WCHAR systemrootW[] = {'S','y','s','t','e','m','r','o','o','t',0}; - static const WCHAR winsysdirW[] = {'w','i','n','s','y','s','d','i','r',0}; - static const WCHAR envW[] = {'E','n','v','i','r','o','n','m','e','n','t',0}; - static const WCHAR tempW[] = {'T','E','M','P',0}; - static const WCHAR tmpW[] = {'T','M','P',0}; - static const WCHAR pathW[] = {'P','A','T','H',0}; - static const WCHAR profileW[] = {'p','r','o','f','i','l','e',0}; - static const WCHAR userprofileW[] = {'U','S','E','R','P','R','O','F','I','L','E',0}; - - char buffer[1024*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)]; - KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer; - OBJECT_ATTRIBUTES attr; - UNICODE_STRING nameW; - DWORD dummy; - ULONG disp; - HANDLE hkey_old, hkey_env; - - attr.Length = sizeof(attr); - attr.RootDirectory = 0; - attr.ObjectName = &nameW; - attr.Attributes = 0; - attr.SecurityDescriptor = NULL; - attr.SecurityQualityOfService = NULL; - RtlInitUnicodeString( &nameW, wineW ); - - /* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Wine */ - if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) return; - - attr.RootDirectory = hkey_current_user; - RtlInitUnicodeString( &nameW, envW ); - if (NtCreateKey( &hkey_env, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp )) - { - NtClose( hkey_old ); - return; - } - - /* Test for existence of TEMP */ - RtlInitUnicodeString( &nameW, tempW ); - if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - /* convert TEMP */ - RtlInitUnicodeString( &nameW, tempW ); - if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength ); - RtlInitUnicodeString( &nameW, tmpW ); - NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength ); - MESSAGE( "Converted temp dir to new entry HKCU\\Environment \"TEMP\" = %s\n", - debugstr_w( (WCHAR*)info->Data ) ); - } - } - - /* Test for existence of PATH */ - RtlInitUnicodeString( &nameW, pathW ); - if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - /* convert PATH */ - RtlInitUnicodeString( &nameW, pathW ); - if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength ); - MESSAGE( "Converted path dir to new entry HKCU\\Environment \"PATH\" = %s\n", - debugstr_w( (WCHAR*)info->Data ) ); - } - } - - /* Test for existence of USERPROFILE */ - RtlInitUnicodeString( &nameW, userprofileW ); - if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - /* convert USERPROFILE */ - RtlInitUnicodeString( &nameW, profileW ); - if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - RtlInitUnicodeString( &nameW, userprofileW ); - NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength ); - MESSAGE( "Converted profile dir to new entry HKCU\\Environment \"USERPROFILE\" = %s\n", - debugstr_w( (WCHAR*)info->Data ) ); - } - } - - /* Test for existence of windir */ - RtlInitUnicodeString( &nameW, windirW ); - if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - /* convert windir */ - RtlInitUnicodeString( &nameW, windowsW ); - if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - RtlInitUnicodeString( &nameW, windirW ); - NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength ); - RtlInitUnicodeString( &nameW, systemrootW ); - NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength ); - MESSAGE( "Converted windows dir to new entry HKCU\\Environment \"windir\" = %s\n", - debugstr_w( (WCHAR*)info->Data ) ); - } - } - - /* Test for existence of winsysdir */ - RtlInitUnicodeString( &nameW, winsysdirW ); - if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - /* convert winsysdir */ - RtlInitUnicodeString( &nameW, systemW ); - if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy )) - { - RtlInitUnicodeString( &nameW, winsysdirW ); - NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength ); - MESSAGE( "Converted system dir to new entry HKCU\\Environment \"winsysdir\" = %s\n", - debugstr_w( (WCHAR*)info->Data ) ); - } - } - NtClose( hkey_old ); - NtClose( hkey_env ); -} - - /* registry initialisation, allocates some default keys. */ static ULONG allocate_default_keys(void) { @@ -673,28 +253,9 @@ */ void convert_old_config(void) { - HANDLE hkey_current_user; - if (allocate_default_keys() == REG_OPENED_EXISTING_KEY) return; /* someone else already loaded the registry */ - RtlOpenCurrentUser( KEY_ALL_ACCESS, &hkey_current_user ); - - /* load the user registry (FIXME: should be done at server init time) */ - SERVER_START_REQ( load_user_registries ) - { - req->hkey = hkey_current_user; - wine_server_call( req ); - } - SERVER_END_REQ; - - /* convert old configuration */ - create_dos_devices(); - convert_drive_types(); - convert_environment( hkey_current_user ); - /* create some hardware keys (FIXME: should not be done here) */ create_hardware_branch(); - - NtClose( hkey_current_user ); } diff -urN wine-20050628/dlls/kernel/process.c wine-20050725/dlls/kernel/process.c --- wine-20050628/dlls/kernel/process.c 2005-06-27 13:12:11.000000000 +0200 +++ wine-20050725/dlls/kernel/process.c 2005-07-14 14:33:30.000000000 +0200 @@ -47,7 +47,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(process); WINE_DECLARE_DEBUG_CHANNEL(file); -WINE_DECLARE_DEBUG_CHANNEL(server); WINE_DECLARE_DEBUG_CHANNEL(relay); typedef struct @@ -65,7 +64,6 @@ static DWORD shutdown_priority = 0x280; static DWORD process_dword; -static unsigned int server_startticks; int main_create_flags = 0; HMODULE kernel32_handle = 0; @@ -737,27 +735,32 @@ * * Fill the RTL_USER_PROCESS_PARAMETERS structure from the server. */ -static RTL_USER_PROCESS_PARAMETERS *init_user_process_params( size_t info_size ) +static BOOL init_user_process_params( RTL_USER_PROCESS_PARAMETERS *params ) { + BOOL ret; void *ptr; - DWORD size, env_size; - RTL_USER_PROCESS_PARAMETERS *params; + DWORD size, env_size, info_size; + HANDLE hstdin, hstdout, hstderr; - size = info_size; - ptr = NULL; - if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &size, - MEM_COMMIT, PAGE_READWRITE ) != STATUS_SUCCESS) - return NULL; + size = info_size = params->AllocationSize; + if (!size) return TRUE; /* no parameters received from parent */ SERVER_START_REQ( get_startup_info ) { - wine_server_set_reply( req, ptr, info_size ); - wine_server_call( req ); - info_size = wine_server_reply_size( reply ); + wine_server_set_reply( req, params, size ); + if ((ret = !wine_server_call( req ))) + { + info_size = wine_server_reply_size( reply ); + main_create_flags = reply->create_flags; + main_exe_file = reply->exe_file; + hstdin = reply->hstdin; + hstdout = reply->hstdout; + hstderr = reply->hstderr; + } } SERVER_END_REQ; + if (!ret) return ret; - params = ptr; params->AllocationSize = size; if (params->Size > info_size) params->Size = info_size; @@ -777,11 +780,35 @@ ptr = NULL; if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &env_size, MEM_COMMIT, PAGE_READWRITE ) != STATUS_SUCCESS) - return NULL; + return FALSE; memcpy( ptr, (char *)params + params->Size, info_size - params->Size ); params->Environment = ptr; - return RtlNormalizeProcessParams( params ); + /* convert value from server: + * + 0 => INVALID_HANDLE_VALUE + * + console handle needs to be mapped + */ + if (!hstdin) + hstdin = INVALID_HANDLE_VALUE; + else if (VerifyConsoleIoHandle(console_handle_map(hstdin))) + hstdin = console_handle_map(hstdin); + + if (!hstdout) + hstdout = INVALID_HANDLE_VALUE; + else if (VerifyConsoleIoHandle(console_handle_map(hstdout))) + hstdout = console_handle_map(hstdout); + + if (!hstderr) + hstderr = INVALID_HANDLE_VALUE; + else if (VerifyConsoleIoHandle(console_handle_map(hstderr))) + hstderr = console_handle_map(hstderr); + + params->hStdInput = hstdin; + params->hStdOutput = hstdout; + params->hStdError = hstderr; + + RtlNormalizeProcessParams( params ); + return TRUE; } @@ -906,11 +933,7 @@ static BOOL process_init(void) { static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0}; - BOOL ret; - size_t info_size = 0; - RTL_USER_PROCESS_PARAMETERS *params; PEB *peb = NtCurrentTeb()->Peb; - HANDLE hstdin, hstdout, hstderr; extern void __wine_dbg_kernel32_init(void); PTHREAD_Init(); @@ -921,75 +944,13 @@ setbuf(stderr,NULL); setlocale(LC_CTYPE,""); - /* Retrieve startup info from the server */ - SERVER_START_REQ( init_process ) - { - req->peb = peb; - req->ldt_copy = &wine_ldt_copy; - if ((ret = !wine_server_call_err( req ))) - { - main_exe_file = reply->exe_file; - main_create_flags = reply->create_flags; - info_size = reply->info_size; - server_startticks = reply->server_start; - hstdin = reply->hstdin; - hstdout = reply->hstdout; - hstderr = reply->hstderr; - } - } - SERVER_END_REQ; - if (!ret) return FALSE; - - if (info_size == 0) - { - params = peb->ProcessParameters; - - /* This is wine specific: we have no parent (we're started from unix) - * so, create a simple console with bare handles to unix stdio - * input & output streams (aka simple console) - */ - wine_server_fd_to_handle( 0, GENERIC_READ|SYNCHRONIZE, TRUE, ¶ms->hStdInput ); - wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, TRUE, ¶ms->hStdOutput ); - wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, TRUE, ¶ms->hStdError ); - - params->CurrentDirectory.DosPath.Length = 0; - params->CurrentDirectory.DosPath.MaximumLength = RtlGetLongestNtPathLength() * sizeof(WCHAR); - params->CurrentDirectory.DosPath.Buffer = RtlAllocateHeap( GetProcessHeap(), 0, params->CurrentDirectory.DosPath.MaximumLength); - } - else - { - if (!(params = init_user_process_params( info_size ))) return FALSE; - peb->ProcessParameters = params; - - /* convert value from server: - * + 0 => INVALID_HANDLE_VALUE - * + console handle need to be mapped - */ - if (!hstdin) - hstdin = INVALID_HANDLE_VALUE; - else if (VerifyConsoleIoHandle(console_handle_map(hstdin))) - hstdin = console_handle_map(hstdin); - - if (!hstdout) - hstdout = INVALID_HANDLE_VALUE; - else if (VerifyConsoleIoHandle(console_handle_map(hstdout))) - hstdout = console_handle_map(hstdout); - - if (!hstderr) - hstderr = INVALID_HANDLE_VALUE; - else if (VerifyConsoleIoHandle(console_handle_map(hstderr))) - hstderr = console_handle_map(hstderr); - - params->hStdInput = hstdin; - params->hStdOutput = hstdout; - params->hStdError = hstderr; - } + if (!init_user_process_params( peb->ProcessParameters )) return FALSE; kernel32_handle = GetModuleHandleW(kernel32W); LOCALE_Init(); - if (!info_size) + if (!peb->ProcessParameters->Environment) { /* Copy the parent environment */ if (!build_initial_environment( __wine_main_environ )) return FALSE; @@ -997,19 +958,11 @@ /* convert old configuration to new format */ convert_old_config(); - /* global boot finished, the rest is process-local */ - SERVER_START_REQ( boot_done ) - { - req->debug_level = TRACE_ON(server); - wine_server_call( req ); - } - SERVER_END_REQ; - set_registry_environment(); } init_windows_dirs(); - init_current_directory( ¶ms->CurrentDirectory ); + init_current_directory( &peb->ProcessParameters->CurrentDirectory ); return TRUE; } @@ -2908,31 +2861,6 @@ /*********************************************************************** - * GetSystemMSecCount (SYSTEM.6) - * GetTickCount (KERNEL32.@) - * - * Get the number of milliseconds the system has been running. - * - * PARANS - * None. - * - * RETURNS - * The current tick count. - * - * NOTES - * -The value returned will wrap arounf every 2^32 milliseconds. - * -Under Windows, tick 0 is the moment at which the system is rebooted. - * Under Wine, tick 0 begins at the moment the wineserver process is started, - */ -DWORD WINAPI GetTickCount(void) -{ - struct timeval t; - gettimeofday( &t, NULL ); - return ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - server_startticks; -} - - -/*********************************************************************** * GetCurrentProcess (KERNEL32.@) * * Get a handle to the current process. diff -urN wine-20050628/dlls/kernel/relay16.c wine-20050725/dlls/kernel/relay16.c --- wine-20050628/dlls/kernel/relay16.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/relay16.c 2005-07-22 21:50:13.000000000 +0200 @@ -281,29 +281,134 @@ } +extern int call_entry_point( void *func, int nb_args, const int *args ); +__ASM_GLOBAL_FUNC( call_entry_point, + "\tpushl %ebp\n" + "\tmovl %esp,%ebp\n" + "\tmovl 12(%ebp),%ecx\n" + "\tmovl 16(%ebp),%edx\n" + "\tjecxz 1f\n" + "2:\tpushl -4(%edx,%ecx,4)\n" + "\tloop 2b\n" + "1:\tcall *8(%ebp)\n" + "\tmovl %ebp,%esp\n" + "\tleave\n" + "\tret" ); + + +/*********************************************************************** + * relay_call_from_16_no_debug + * + * Same as relay_call_from_16 but doesn't print any debug information. + */ +static int relay_call_from_16_no_debug( void *entry_point, unsigned char *args16, CONTEXT86 *context, + const CALLFROM16 *call ) +{ + int i, nb_args, args32[20]; + + nb_args = 0; + if (call->lret == 0xcb66) /* cdecl */ + { + for (i = 0; i < 20; i++, nb_args++) + { + int type = (call->arg_types[i / 10] >> (3 * (i % 10))) & 7; + + if (type == ARG_NONE) break; + switch(type) + { + case ARG_WORD: + args32[nb_args] = *(WORD *)args16; + args16 += sizeof(WORD); + break; + case ARG_SWORD: + args32[nb_args] = *(short *)args16; + args16 += sizeof(WORD); + break; + case ARG_LONG: + case ARG_SEGSTR: + args32[nb_args] = *(int *)args16; + args16 += sizeof(int); + break; + case ARG_PTR: + case ARG_STR: + args32[nb_args] = (int)MapSL( *(SEGPTR *)args16 ); + args16 += sizeof(SEGPTR); + break; + case ARG_VARARG: + args32[nb_args] = (int)args16; + break; + default: + break; + } + } + } + else /* not cdecl */ + { + /* Start with the last arg */ + args16 += call->nArgs; + for (i = 0; i < 20; i++, nb_args++) + { + int type = (call->arg_types[i / 10] >> (3 * (i % 10))) & 7; + + if (type == ARG_NONE) break; + switch(type) + { + case ARG_WORD: + args16 -= sizeof(WORD); + args32[nb_args] = *(WORD *)args16; + break; + case ARG_SWORD: + args16 -= sizeof(WORD); + args32[nb_args] = *(short *)args16; + break; + case ARG_LONG: + case ARG_SEGSTR: + args16 -= sizeof(int); + args32[nb_args] = *(int *)args16; + break; + case ARG_PTR: + case ARG_STR: + args16 -= sizeof(SEGPTR); + args32[nb_args] = (int)MapSL( *(SEGPTR *)args16 ); + break; + default: + break; + } + } + } + + if (call->arg_types[0] & ARG_REGISTER) args32[nb_args++] = (int)context; + + SYSLEVEL_CheckNotLevel( 2 ); + + return call_entry_point( entry_point, nb_args, args32 ); +} + + /*********************************************************************** - * RELAY_DebugCallFrom16 + * relay_call_from_16 + * + * Replacement for the 16-bit relay functions when relay debugging is on. */ -void RELAY_DebugCallFrom16( CONTEXT86 *context ) +int relay_call_from_16( void *entry_point, unsigned char *args16, CONTEXT86 *context ) { STACK16FRAME *frame; WORD ordinal; - char *args16, module[10], func[64]; + int i, ret_val, nb_args, args32[20]; + char module[10], func[64]; const CALLFROM16 *call; - int i; - - if (!TRACE_ON(relay)) return; frame = CURRENT_STACK16; call = get_entry_point( frame, module, func, &ordinal ); - if (!call) return; /* happens for the two snoop register relays */ - if (!RELAY_ShowDebugmsgRelay( module, ordinal, func )) return; + if (!TRACE_ON(relay) || !RELAY_ShowDebugmsgRelay( module, ordinal, func )) + return relay_call_from_16_no_debug( entry_point, args16, context, call ); + DPRINTF( "%04lx:Call %s.%d: %s(",GetCurrentThreadId(), module, ordinal, func ); - args16 = (char *)(frame + 1); + nb_args = 0; if (call->lret == 0xcb66) /* cdecl */ { - for (i = 0; i < 20; i++) + for (i = 0; i < 20; i++, nb_args++) { int type = (call->arg_types[i / 10] >> (3 * (i % 10))) & 7; @@ -312,28 +417,41 @@ switch(type) { case ARG_WORD: + DPRINTF( "%04x", *(WORD *)args16 ); + args32[nb_args] = *(WORD *)args16; + args16 += sizeof(WORD); + break; case ARG_SWORD: DPRINTF( "%04x", *(WORD *)args16 ); + args32[nb_args] = *(short *)args16; args16 += sizeof(WORD); break; case ARG_LONG: DPRINTF( "%08x", *(int *)args16 ); + args32[nb_args] = *(int *)args16; args16 += sizeof(int); break; case ARG_PTR: DPRINTF( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 ); + args32[nb_args] = (int)MapSL( *(SEGPTR *)args16 ); args16 += sizeof(SEGPTR); break; case ARG_STR: DPRINTF( "%08x %s", *(int *)args16, debugstr_a( MapSL(*(SEGPTR *)args16 ))); + args32[nb_args] = (int)MapSL( *(SEGPTR *)args16 ); args16 += sizeof(int); break; case ARG_SEGSTR: DPRINTF( "%04x:%04x %s", *(WORD *)(args16+2), *(WORD *)args16, debugstr_a( MapSL(*(SEGPTR *)args16 )) ); + args32[nb_args] = *(SEGPTR *)args16; args16 += sizeof(SEGPTR); break; + case ARG_VARARG: + DPRINTF( "..." ); + args32[nb_args] = (int)args16; + break; default: break; } @@ -343,7 +461,7 @@ { /* Start with the last arg */ args16 += call->nArgs; - for (i = 0; i < 20; i++) + for (i = 0; i < 20; i++, nb_args++) { int type = (call->arg_types[i / 10] >> (3 * (i % 10))) & 7; @@ -352,28 +470,41 @@ switch(type) { case ARG_WORD: + args16 -= sizeof(WORD); + args32[nb_args] = *(WORD *)args16; + DPRINTF( "%04x", *(WORD *)args16 ); + break; case ARG_SWORD: args16 -= sizeof(WORD); + args32[nb_args] = *(short *)args16; DPRINTF( "%04x", *(WORD *)args16 ); break; case ARG_LONG: args16 -= sizeof(int); + args32[nb_args] = *(int *)args16; DPRINTF( "%08x", *(int *)args16 ); break; case ARG_PTR: args16 -= sizeof(SEGPTR); + args32[nb_args] = (int)MapSL( *(SEGPTR *)args16 ); DPRINTF( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 ); break; case ARG_STR: args16 -= sizeof(int); + args32[nb_args] = (int)MapSL( *(SEGPTR *)args16 ); DPRINTF( "%08x %s", *(int *)args16, debugstr_a( MapSL(*(SEGPTR *)args16 ))); break; case ARG_SEGSTR: args16 -= sizeof(SEGPTR); + args32[nb_args] = *(SEGPTR *)args16; DPRINTF( "%04x:%04x %s", *(WORD *)(args16+2), *(WORD *)args16, debugstr_a( MapSL(*(SEGPTR *)args16 )) ); break; + case ARG_VARARG: + DPRINTF( "..." ); + args32[nb_args] = (int)args16; + break; default: break; } @@ -383,32 +514,21 @@ DPRINTF( ") ret=%04x:%04x ds=%04x\n", frame->cs, frame->ip, frame->ds ); if (call->arg_types[0] & ARG_REGISTER) + { + args32[nb_args++] = (int)context; DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n", (WORD)context->Eax, (WORD)context->Ebx, (WORD)context->Ecx, (WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi, (WORD)context->SegEs, context->EFlags ); + } SYSLEVEL_CheckNotLevel( 2 ); -} - -/*********************************************************************** - * RELAY_DebugCallFrom16Ret - */ -void RELAY_DebugCallFrom16Ret( CONTEXT86 *context, int ret_val ) -{ - STACK16FRAME *frame; - WORD ordinal; - char module[10], func[64]; - const CALLFROM16 *call; + ret_val = call_entry_point( entry_point, nb_args, args32 ); - if (!TRACE_ON(relay)) return; - frame = CURRENT_STACK16; - call = get_entry_point( frame, module, func, &ordinal ); - if (!call) return; - if (!RELAY_ShowDebugmsgRelay( module, ordinal, func )) return; - DPRINTF( "%04lx:Ret %s.%d: %s() ", GetCurrentThreadId(), module, ordinal, func ); + SYSLEVEL_CheckNotLevel( 2 ); + DPRINTF( "%04lx:Ret %s.%d: %s() ",GetCurrentThreadId(), module, ordinal, func ); if (call->arg_types[0] & ARG_REGISTER) { DPRINTF("retval=none ret=%04x:%04x ds=%04x\n", @@ -418,17 +538,17 @@ (WORD)context->Edx, (WORD)context->Esi, (WORD)context->Edi, (WORD)context->SegEs, context->EFlags ); } - else if (call->arg_types[0] & ARG_RET16) - { - DPRINTF( "retval=%04x ret=%04x:%04x ds=%04x\n", - ret_val & 0xffff, frame->cs, frame->ip, frame->ds ); - } else { - DPRINTF( "retval=%08x ret=%04x:%04x ds=%04x\n", - ret_val, frame->cs, frame->ip, frame->ds ); + frame = CURRENT_STACK16; /* might have be changed by the entry point */ + if (call->arg_types[0] & ARG_RET16) + DPRINTF( "retval=%04x ret=%04x:%04x ds=%04x\n", + ret_val & 0xffff, frame->cs, frame->ip, frame->ds ); + else + DPRINTF( "retval=%08x ret=%04x:%04x ds=%04x\n", + ret_val, frame->cs, frame->ip, frame->ds ); } - SYSLEVEL_CheckNotLevel( 2 ); + return ret_val; } #else /* __i386__ */ diff -urN wine-20050628/dlls/kernel/syslevel.c wine-20050725/dlls/kernel/syslevel.c --- wine-20050628/dlls/kernel/syslevel.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/syslevel.c 2005-07-03 13:28:44.000000000 +0200 @@ -30,6 +30,7 @@ #include "winternl.h" #include "wine/winbase16.h" #include "kernel_private.h" +#include "kernel16_private.h" #include "wine/library.h" #include "wine/debug.h" @@ -44,10 +45,6 @@ }; static SYSLEVEL Win16Mutex = { { &critsect_debug, -1, 0, 0, 0, 0 }, 1 }; -#ifdef __i386__ -extern unsigned int CallTo16_TebSelector; -#endif - /************************************************************************ * GetpWin16Lock (KERNEL32.93) diff -urN wine-20050628/dlls/kernel/tests/codepage.c wine-20050725/dlls/kernel/tests/codepage.c --- wine-20050628/dlls/kernel/tests/codepage.c 2004-01-23 03:10:33.000000000 +0100 +++ wine-20050725/dlls/kernel/tests/codepage.c 2005-07-15 18:33:10.000000000 +0200 @@ -56,7 +56,21 @@ "MultiByteToWideChar(-2002): len=%d error=%ld\n",len,GetLastError()); } +static void test_overlapped_buffers(void) +{ + static const WCHAR strW[] = {'j','u','s','t',' ','a',' ','t','e','s','t',0}; + static const char strA[] = "just a test"; + char buf[256]; + int ret; + + lstrcpyW((WCHAR *)(buf + 1), strW); + ret = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(buf + 1), -1, buf, sizeof(buf), NULL, NULL); + ok(ret == sizeof(strA), "unexpected ret %d != %d\n", ret, sizeof(strA)); + ok(!memcmp(buf, strA, sizeof(strA)), "conversion failed: %s\n", buf); +} + START_TEST(codepage) { test_negative_source_length(); + test_overlapped_buffers(); } diff -urN wine-20050628/dlls/kernel/tests/directory.c wine-20050725/dlls/kernel/tests/directory.c --- wine-20050628/dlls/kernel/tests/directory.c 2005-02-10 20:19:36.000000000 +0100 +++ wine-20050725/dlls/kernel/tests/directory.c 2005-06-30 20:08:44.000000000 +0200 @@ -156,12 +156,12 @@ ret = CreateDirectoryA(NULL, NULL); ok(ret == FALSE && (GetLastError() == ERROR_PATH_NOT_FOUND || GetLastError() == ERROR_INVALID_PARAMETER), - "CreateDirectoryA(NULL,NULL): ret=%d error=%ld\n",ret,GetLastError()); + "CreateDirectoryA(NULL): ret=%d err=%ld\n", ret, GetLastError()); ret = CreateDirectoryA("", NULL); ok(ret == FALSE && (GetLastError() == ERROR_BAD_PATHNAME || GetLastError() == ERROR_PATH_NOT_FOUND), - "CreateDirectoryA(\"\",NULL): ret=%d error=%ld\n",ret,GetLastError()); + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); ret = GetSystemDirectoryA(tmpdir, MAX_PATH); ok(ret < MAX_PATH, "System directory should fit into MAX_PATH\n"); @@ -170,52 +170,159 @@ ok(ret == TRUE, "could not chdir to the System directory\n"); ret = CreateDirectoryA(".", NULL); - ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n"); + ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); + ret = CreateDirectoryA("..", NULL); - ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n"); + ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); GetTempPathA(MAX_PATH, tmpdir); tmpdir[3] = 0; /* truncate the path */ ret = CreateDirectoryA(tmpdir, NULL); ok(ret == FALSE && (GetLastError() == ERROR_ALREADY_EXISTS || GetLastError() == ERROR_ACCESS_DENIED), - "CreateDirectoryA(drive_root): ret=%d error=%ld\n",ret,GetLastError()); + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); GetTempPathA(MAX_PATH, tmpdir); lstrcatA(tmpdir, "Please Remove Me"); ret = CreateDirectoryA(tmpdir, NULL); - ok(ret == TRUE, "CreateDirectoryA should always succeed\n"); + ok(ret == TRUE, "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); ret = CreateDirectoryA(tmpdir, NULL); - ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, "should not create existing path\n"); + ok(ret == FALSE && GetLastError() == ERROR_ALREADY_EXISTS, + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); ret = RemoveDirectoryA(tmpdir); - ok(ret == TRUE, "RemoveDirectoryA should always succeed\n"); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + lstrcatA(tmpdir, "?"); ret = CreateDirectoryA(tmpdir, NULL); ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME || GetLastError() == ERROR_PATH_NOT_FOUND), - "CreateDirectoryA with ? wildcard name should fail, ret=%s error=%ld\n", - ret ? " True" : "False", GetLastError()); - ret = RemoveDirectoryA(tmpdir); + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); + RemoveDirectoryA(tmpdir); tmpdir[lstrlenA(tmpdir) - 1] = '*'; ret = CreateDirectoryA(tmpdir, NULL); ok(ret == FALSE && (GetLastError() == ERROR_INVALID_NAME || GetLastError() == ERROR_PATH_NOT_FOUND), - "CreateDirectoryA with * wildcard name should fail, ret=%s error=%ld\n", - ret ? " True" : "False", GetLastError()); - ret = RemoveDirectoryA(tmpdir); - + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); + RemoveDirectoryA(tmpdir); + GetTempPathA(MAX_PATH, tmpdir); lstrcatA(tmpdir, "Please Remove Me/Please Remove Me"); ret = CreateDirectoryA(tmpdir, NULL); ok(ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND, - "CreateDirectoryA with multiple nonexistent directories in path should fail\n"); + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); + RemoveDirectoryA(tmpdir); + + /* Test behavior with a trailing dot. + * The directory should be created without the dot. + */ + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me."); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE, + "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + lstrcatA(tmpdir, "/Please Remove Me"); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE, + "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); ret = RemoveDirectoryA(tmpdir); - + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me"); + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + /* Test behavior with two trailing dots. + * The directory should be created without the trailing dots. + */ + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me.."); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE, + "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + lstrcatA(tmpdir, "/Please Remove Me"); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE || /* On Win98 */ + (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */ + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); + if (ret == TRUE) + { + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + } + + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me"); + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + /* Test behavior with a trailing space. + * The directory should be created without the trailing space. + */ + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me "); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE, + "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + lstrcatA(tmpdir, "/Please Remove Me"); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE || /* On Win98 */ + (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */ + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); + if (ret == TRUE) + { + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + } + + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me"); + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + /* Test behavior with a trailing space. + * The directory should be created without the trailing spaces. + */ + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me "); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE, + "CreateDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + + lstrcatA(tmpdir, "/Please Remove Me"); + ret = CreateDirectoryA(tmpdir, NULL); + ok(ret == TRUE || /* On Win98 */ + (ret == FALSE && GetLastError() == ERROR_PATH_NOT_FOUND), /* On NT! */ + "CreateDirectoryA(%s): ret=%d err=%ld\n", tmpdir, ret, GetLastError()); + if (ret == TRUE) + { + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); + } + + GetTempPathA(MAX_PATH, tmpdir); + lstrcatA(tmpdir, "Please Remove Me"); + ret = RemoveDirectoryA(tmpdir); + ok(ret == TRUE, + "RemoveDirectoryA(%s) failed err=%ld\n", tmpdir, GetLastError()); } static void test_CreateDirectoryW(void) diff -urN wine-20050628/dlls/kernel/tests/generated.c wine-20050725/dlls/kernel/tests/generated.c --- wine-20050628/dlls/kernel/tests/generated.c 2005-03-17 20:00:09.000000000 +0100 +++ wine-20050725/dlls/kernel/tests/generated.c 2005-07-03 13:23:30.000000000 +0200 @@ -63,7 +63,7 @@ # define TEST_FIELD_ALIGNMENT(type, field, align) \ ok(FIELD_ALIGNMENT(type, field) == align, \ "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \ - FIELD_ALIGNMENT(type, field)) + (int)FIELD_ALIGNMENT(type, field)) #else # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0) #endif @@ -71,24 +71,24 @@ #define TEST_FIELD_OFFSET(type, field, offset) \ ok(FIELD_OFFSET(type, field) == offset, \ "FIELD_OFFSET(" #type ", " #field ") == %ld (expected " #offset ")\n", \ - FIELD_OFFSET(type, field)) + (long int)FIELD_OFFSET(type, field)) #ifdef _TYPE_ALIGNMENT #define TEST__TYPE_ALIGNMENT(type, align) \ - ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", _TYPE_ALIGNMENT(type)) + ok(_TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)_TYPE_ALIGNMENT(type)) #else # define TEST__TYPE_ALIGNMENT(type, align) do { } while (0) #endif #ifdef TYPE_ALIGNMENT #define TEST_TYPE_ALIGNMENT(type, align) \ - ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", TYPE_ALIGNMENT(type)) + ok(TYPE_ALIGNMENT(type) == align, "TYPE_ALIGNMENT(" #type ") == %d (expected " #align ")\n", (int)TYPE_ALIGNMENT(type)) #else # define TEST_TYPE_ALIGNMENT(type, align) do { } while (0) #endif #define TEST_TYPE_SIZE(type, size) \ - ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", sizeof(type)) + ok(sizeof(type) == size, "sizeof(" #type ") == %d (expected " #size ")\n", ((int) sizeof(type))) /*********************************************************************** * Test macros diff -urN wine-20050628/dlls/kernel/tests/heap.c wine-20050725/dlls/kernel/tests/heap.c --- wine-20050628/dlls/kernel/tests/heap.c 2005-03-17 21:53:38.000000000 +0100 +++ wine-20050725/dlls/kernel/tests/heap.c 2005-07-11 15:20:40.000000000 +0200 @@ -38,6 +38,15 @@ mem = HeapReAlloc(GetProcessHeap(), 0, NULL, 10); ok(mem == NULL, "memory allocated by HeapReAlloc\n"); + for (size = 0; size <= 256; size++) + { + SIZE_T heap_size; + mem = HeapAlloc(GetProcessHeap(), 0, size); + heap_size = HeapSize(GetProcessHeap(), 0, mem); + ok(size == heap_size, "HeapSize returned %lu instead of %lu\n", heap_size, size); + HeapFree(GetProcessHeap(), 0, mem); + } + /* Global*() functions */ gbl = GlobalAlloc(GMEM_MOVEABLE, 0); ok(gbl != NULL, "global memory not allocated for size 0\n"); diff -urN wine-20050628/dlls/kernel/tests/module.c wine-20050725/dlls/kernel/tests/module.c --- wine-20050628/dlls/kernel/tests/module.c 2004-05-20 03:19:05.000000000 +0200 +++ wine-20050725/dlls/kernel/tests/module.c 2005-07-22 11:06:03.000000000 +0200 @@ -78,9 +78,57 @@ ok(bufA[0] == '*', "When failing, buffer shouldn't be written to\n"); } +static void testLoadLibraryA(void) +{ + HMODULE hModule; + FARPROC fp; + + SetLastError(0xdeadbeef); + hModule = LoadLibraryA("ntdll.dll"); + ok( hModule != NULL, "ntdll.dll should be loadable\n"); + ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %08lx\n", GetLastError()); + + fp = GetProcAddress(hModule, "LdrLoadDll"); + ok( fp != NULL, "Call should be there\n"); + ok( GetLastError() == 0xdeadbeef, "GetLastError should be 0xdeadbeef but is %08lx\n", GetLastError()); + + FreeLibrary(hModule); +} + +static void testLoadLibraryA_Wrong(void) +{ + HMODULE hModule; + + /* Try to load a nonexistent dll */ + SetLastError(0xdeadbeef); + hModule = LoadLibraryA("non_ex_pv.dll"); + ok( !hModule, "non_ex_pv.dll should be not loadable\n"); + ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %08lx\n", GetLastError()); + + /* Just in case */ + FreeLibrary(hModule); +} + +static void testGetProcAddress_Wrong(void) +{ + FARPROC fp; + + SetLastError(0xdeadbeef); + fp = GetProcAddress(NULL, "non_ex_call"); + ok( !fp, "non_ex_call should not be found\n"); + ok( GetLastError() == ERROR_PROC_NOT_FOUND, "Expected ERROR_PROC_NOT_FOUND, got %08lx\n", GetLastError()); + fp = GetProcAddress((HMODULE)0xdeadbeef, "non_ex_call"); + ok( !fp, "non_ex_call should not be found\n"); + ok( GetLastError() == ERROR_MOD_NOT_FOUND, "Expected ERROR_MOD_NOT_FOUND, got %08lx\n", GetLastError()); +} + START_TEST(module) { testGetModuleFileName(NULL); testGetModuleFileName("kernel32.dll"); testGetModuleFileName_Wrong(); + + testLoadLibraryA(); + testLoadLibraryA_Wrong(); + testGetProcAddress_Wrong(); } diff -urN wine-20050628/dlls/kernel/tests/thread.c wine-20050725/dlls/kernel/tests/thread.c --- wine-20050628/dlls/kernel/tests/thread.c 2005-06-14 13:40:04.000000000 +0200 +++ wine-20050725/dlls/kernel/tests/thread.c 2005-07-25 13:07:54.000000000 +0200 @@ -82,6 +82,20 @@ DWORD *threadmem; } t1Struct; +/* WinME supports OpenThread but doesn't know about access restrictions so + we require them to be either completly ignored or always obeyed. +*/ +INT obeying_ars = 0; /* -1 == no, 0 == dunno yet, 1 == yes */ +#define obey_ar(x) \ + (obeying_ars == 0 \ + ? ((x) \ + ? (obeying_ars = +1) \ + : ((obeying_ars = -1), \ + trace("not restricted, assuming consistent behaviour\n"))) \ + : (obeying_ars < 0) \ + ? ok(!(x), "access restrictions obeyed\n") \ + : ok( (x), "access restrictions not obeyed\n")) + /* Basic test that simulatneous threads can access shared memory, that the thread local storage routines work correctly, and that threads actually run concurrently @@ -276,10 +290,8 @@ 0,threadId); ok(access_thread!=NULL,"OpenThread returned an invalid handle\n"); if (access_thread!=NULL) { - ok(SuspendThread(access_thread)==~0UL, - "SuspendThread did not obey access restrictions\n"); - ok(ResumeThread(access_thread)==~0UL, - "ResumeThread did not obey access restrictions\n"); + obey_ar(SuspendThread(access_thread)==~0UL); + obey_ar(ResumeThread(access_thread)==~0UL); ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n"); } } @@ -324,8 +336,7 @@ 0,threadId); ok(access_thread!=NULL,"OpenThread returned an invalid handle\n"); if (access_thread!=NULL) { - ok(TerminateThread(access_thread,99)==0, - "TerminateThread did not obey access restrictions\n"); + obey_ar(TerminateThread(access_thread,99)==0); ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n"); } } @@ -395,18 +406,13 @@ 0,curthreadId); ok(access_thread!=NULL,"OpenThread returned an invalid handle\n"); if (access_thread!=NULL) { - ok(SetThreadPriority(access_thread,1)==0, - "SetThreadPriority did not obey access restrictions\n"); - ok(GetThreadPriority(access_thread)==THREAD_PRIORITY_ERROR_RETURN, - "GetThreadPriority did not obey access restrictions\n"); + obey_ar(SetThreadPriority(access_thread,1)==0); + obey_ar(GetThreadPriority(access_thread)==THREAD_PRIORITY_ERROR_RETURN); if (pSetThreadPriorityBoost) - ok(pSetThreadPriorityBoost(access_thread,1)==0, - "SetThreadPriorityBoost did not obey access restrictions\n"); + obey_ar(pSetThreadPriorityBoost(access_thread,1)==0); if (pGetThreadPriorityBoost) - ok(pGetThreadPriorityBoost(access_thread,&disabled)==0, - "GetThreadPriorityBoost did not obey access restrictions\n"); - ok(GetExitCodeThread(access_thread,&exitCode)==0, - "GetExitCodeThread did not obey access restrictions\n"); + obey_ar(pGetThreadPriorityBoost(access_thread,&disabled)==0); + obey_ar(GetExitCodeThread(access_thread,&exitCode)==0); ok(CloseHandle(access_thread),"Error Closing thread handle\n"); } #if USE_EXTENDED_PRIORITIES @@ -479,7 +485,7 @@ if(access_thread!=NULL) { error=GetThreadTimes(access_thread,&creationTime,&exitTime, &kernelTime,&userTime); - ok(error==0, "GetThreadTimes did not obey access restrictions\n"); + obey_ar(error==0); ok(CloseHandle(access_thread)!=0,"CloseHandle Failed\n"); } creationTime.dwLowDateTime=99; creationTime.dwHighDateTime=99; diff -urN wine-20050628/dlls/kernel/thunk.c wine-20050725/dlls/kernel/thunk.c --- wine-20050628/dlls/kernel/thunk.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/thunk.c 2005-07-01 18:24:32.000000000 +0200 @@ -144,6 +144,9 @@ DWORD errorReturnValue; }; +SEGPTR CALL32_CBClient_RetAddr = 0; +SEGPTR CALL32_CBClientEx_RetAddr = 0; + #ifdef __i386__ extern void __wine_call_from_16_thunk(); #else @@ -1997,7 +2000,7 @@ /*********************************************************************** * CBClientThunkSL (KERNEL.620) */ -extern DWORD CALL32_CBClient( FARPROC proc, LPWORD args, DWORD *esi ); +extern DWORD CALL32_CBClient( FARPROC proc, LPWORD args, WORD *stackLin, DWORD *esi ); void WINAPI CBClientThunkSL( CONTEXT86 *context ) { /* Call 32-bit relay code */ @@ -2005,13 +2008,24 @@ LPWORD args = MapSL( MAKESEGPTR( context->SegSs, LOWORD(context->Ebp) ) ); FARPROC proc = CBClientRelay32[ args[2] ][ args[1] ]; - context->Eax = CALL32_CBClient( proc, args, &context->Esi ); + /* fill temporary area for the asm code (see comments in winebuild) */ + SEGPTR stack = stack16_push( 12 ); + LPWORD stackLin = MapSL(stack); + /* stackLin[0] and stackLin[1] reserved for the 32-bit stack ptr */ + stackLin[2] = wine_get_ss(); + stackLin[3] = 0; + stackLin[4] = OFFSETOF(stack) + 12; + stackLin[5] = SELECTOROF(stack); + stackLin[6] = OFFSETOF(CALL32_CBClientEx_RetAddr); /* overwrite return address */ + stackLin[7] = SELECTOROF(CALL32_CBClientEx_RetAddr); + context->Eax = CALL32_CBClient( proc, args, stackLin + 4, &context->Esi ); + stack16_pop( 12 ); } /*********************************************************************** * CBClientThunkSLEx (KERNEL.621) */ -extern DWORD CALL32_CBClientEx( FARPROC proc, LPWORD args, DWORD *esi, INT *nArgs ); +extern DWORD CALL32_CBClientEx( FARPROC proc, LPWORD args, WORD *stackLin, DWORD *esi, INT *nArgs ); void WINAPI CBClientThunkSLEx( CONTEXT86 *context ) { /* Call 32-bit relay code */ @@ -2021,7 +2035,21 @@ INT nArgs; LPWORD stackLin; - context->Eax = CALL32_CBClientEx( proc, args, &context->Esi, &nArgs ); + /* fill temporary area for the asm code (see comments in winebuild) */ + SEGPTR stack = stack16_push( 24 ); + stackLin = MapSL(stack); + stackLin[0] = OFFSETOF(stack) + 4; + stackLin[1] = SELECTOROF(stack); + stackLin[2] = wine_get_ds(); + stackLin[5] = OFFSETOF(stack) + 24; + /* stackLin[6] and stackLin[7] reserved for the 32-bit stack ptr */ + stackLin[8] = wine_get_ss(); + stackLin[9] = 0; + stackLin[10] = OFFSETOF(CALL32_CBClientEx_RetAddr); + stackLin[11] = SELECTOROF(CALL32_CBClientEx_RetAddr); + + context->Eax = CALL32_CBClientEx( proc, args, stackLin, &context->Esi, &nArgs ); + stack16_pop( 24 ); /* Restore registers saved by CBClientGlueSL */ stackLin = (LPWORD)((LPBYTE)CURRENT_STACK16 + sizeof(STACK16FRAME) - 4); diff -urN wine-20050628/dlls/kernel/toolhelp.c wine-20050725/dlls/kernel/toolhelp.c --- wine-20050628/dlls/kernel/toolhelp.c 2005-05-24 12:12:06.000000000 +0200 +++ wine-20050725/dlls/kernel/toolhelp.c 2005-07-05 13:46:09.000000000 +0200 @@ -86,7 +86,7 @@ if (lpte->dwSize < sizeof(THREADENTRY32)) { SetLastError( ERROR_INSUFFICIENT_BUFFER ); - ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(THREADENTRY32), lpte->dwSize); + ERR("Result buffer too small (%ld)\n", lpte->dwSize); return FALSE; } SERVER_START_REQ( next_thread ) @@ -138,26 +138,16 @@ { BOOL ret; WCHAR exe[MAX_PATH-1]; - DWORD len; + DWORD len, sz; - if (unicode) - { - if (lppe->dwSize < sizeof(PROCESSENTRY32W)) - { - SetLastError( ERROR_INSUFFICIENT_BUFFER ); - ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32W), lppe->dwSize); - return FALSE; - } - } - else + sz = unicode ? sizeof(PROCESSENTRY32W) : sizeof(PROCESSENTRY32); + if (lppe->dwSize < sz) { - if (lppe->dwSize < sizeof(PROCESSENTRY32)) - { - SetLastError( ERROR_INSUFFICIENT_BUFFER ); - ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32), lppe->dwSize); - return FALSE; - } + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + ERR("Result buffer too small (req: %ld, was: %ld)\n", sz, lppe->dwSize); + return FALSE; } + SERVER_START_REQ( next_process ) { req->handle = handle; diff -urN wine-20050628/dlls/kernel/toolhelp.h wine-20050725/dlls/kernel/toolhelp.h --- wine-20050628/dlls/kernel/toolhelp.h 2004-02-12 01:00:55.000000000 +0100 +++ wine-20050725/dlls/kernel/toolhelp.h 2005-07-24 18:17:29.000000000 +0200 @@ -95,7 +95,6 @@ /* wFlags values */ #define GF_PDB_OWNER 0x0100 /* Low byte is KERNEL flags */ -WORD WINAPI GlobalHandleToSel16( HGLOBAL16 handle ); BOOL16 WINAPI GlobalInfo16( GLOBALINFO *pInfo ); BOOL16 WINAPI GlobalFirst16( GLOBALENTRY *pGlobal, WORD wFlags ); BOOL16 WINAPI GlobalNext16( GLOBALENTRY *pGlobal, WORD wFlags) ; diff -urN wine-20050628/dlls/kernel/version.c wine-20050725/dlls/kernel/version.c --- wine-20050628/dlls/kernel/version.c 2005-06-16 11:47:17.000000000 +0200 +++ wine-20050725/dlls/kernel/version.c 2005-07-05 12:57:47.000000000 +0200 @@ -155,9 +155,8 @@ if (v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA) && v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXA)) { - WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n", - v->dwOSVersionInfoSize, sizeof(OSVERSIONINFOA), - sizeof(OSVERSIONINFOEXA)); + WARN("wrong OSVERSIONINFO size from app (got: %ld)\n", + v->dwOSVersionInfoSize ); return FALSE; } @@ -191,9 +190,8 @@ if (info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) && info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW)) { - WARN("wrong OSVERSIONINFO size from app (got: %ld, expected: %d or %d)\n", - info->dwOSVersionInfoSize, sizeof(OSVERSIONINFOW), - sizeof(OSVERSIONINFOEXW)); + WARN("wrong OSVERSIONINFO size from app (got: %ld)\n", + info->dwOSVersionInfoSize); return FALSE; } return (RtlGetVersion( (RTL_OSVERSIONINFOEXW *)info ) == STATUS_SUCCESS); diff -urN wine-20050628/dlls/kernel/virtual.c wine-20050725/dlls/kernel/virtual.c --- wine-20050628/dlls/kernel/virtual.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/virtual.c 2005-07-15 12:01:31.000000000 +0200 @@ -242,7 +242,7 @@ PMEMORY_BASIC_INFORMATION info, /* [out] Address of info buffer */ SIZE_T len /* [in] Size of buffer */ ) { - DWORD ret; + SIZE_T ret; NTSTATUS status; if ((status = NtQueryVirtualMemory( process, addr, MemoryBasicInformation, info, len, &ret ))) diff -urN wine-20050628/dlls/kernel/wowthunk.c wine-20050725/dlls/kernel/wowthunk.c --- wine-20050628/dlls/kernel/wowthunk.c 2005-06-20 12:40:37.000000000 +0200 +++ wine-20050725/dlls/kernel/wowthunk.c 2005-07-03 13:28:44.000000000 +0200 @@ -76,24 +76,19 @@ /* symbols exported from relay16.s */ extern DWORD WINAPI wine_call_to_16( FARPROC16 target, DWORD cbArgs, PEXCEPTION_HANDLER handler ); extern void WINAPI wine_call_to_16_regs( CONTEXT86 *context, DWORD cbArgs, PEXCEPTION_HANDLER handler ); -extern void Call16_Ret_Start(); -extern void Call16_Ret_End(); -extern void CallTo16_Ret(); +extern void __wine_call_to_16_ret(void); extern void CALL32_CBClient_Ret(); extern void CALL32_CBClientEx_Ret(); extern void DPMI_PendingEventCheck(); extern void DPMI_PendingEventCheck_Cleanup(); extern void DPMI_PendingEventCheck_Return(); -extern DWORD CallTo16_DataSelector; -extern SEGPTR CALL32_CBClient_RetAddr; -extern SEGPTR CALL32_CBClientEx_RetAddr; -extern BYTE Call16_Start; -extern BYTE Call16_End; +extern BYTE __wine_call16_start[]; +extern BYTE __wine_call16_end[]; extern void RELAY16_InitDebugLists(void); static LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs ); -static SEGPTR call16_ret_addr; /* segptr to CallTo16_Ret routine */ +static SEGPTR call16_ret_addr; /* segptr to __wine_call_to_16_ret routine */ static WORD dpmi_checker_selector; static DWORD dpmi_checker_offset_call; @@ -106,28 +101,29 @@ BOOL WOWTHUNK_Init(void) { /* allocate the code selector for CallTo16 routines */ - WORD codesel = SELECTOR_AllocBlock( (void *)Call16_Ret_Start, - (char *)Call16_Ret_End - (char *)Call16_Ret_Start, - WINE_LDT_FLAGS_CODE | WINE_LDT_FLAGS_32BIT ); + LDT_ENTRY entry; + WORD codesel = wine_ldt_alloc_entries(1); + if (!codesel) return FALSE; + wine_ldt_set_base( &entry, __wine_call16_start ); + wine_ldt_set_limit( &entry, (BYTE *)(&CallTo16_TebSelector + 1) - __wine_call16_start - 1 ); + wine_ldt_set_flags( &entry, WINE_LDT_FLAGS_CODE | WINE_LDT_FLAGS_32BIT ); + wine_ldt_set_entry( codesel, &entry ); /* Patch the return addresses for CallTo16 routines */ CallTo16_DataSelector = wine_get_ds(); - call16_ret_addr = MAKESEGPTR( codesel, (char*)CallTo16_Ret - (char*)Call16_Ret_Start ); + call16_ret_addr = MAKESEGPTR( codesel, (BYTE *)__wine_call_to_16_ret - __wine_call16_start ); CALL32_CBClient_RetAddr = - MAKESEGPTR( codesel, (char*)CALL32_CBClient_Ret - (char*)Call16_Ret_Start ); + MAKESEGPTR( codesel, (BYTE *)CALL32_CBClient_Ret - __wine_call16_start ); CALL32_CBClientEx_RetAddr = - MAKESEGPTR( codesel, (char*)CALL32_CBClientEx_Ret - (char*)Call16_Ret_Start ); + MAKESEGPTR( codesel, (BYTE *)CALL32_CBClientEx_Ret - __wine_call16_start ); /* Prepare selector and offsets for DPMI event checking. */ dpmi_checker_selector = codesel; - dpmi_checker_offset_call = - (char*)DPMI_PendingEventCheck - (char*)Call16_Ret_Start; - dpmi_checker_offset_cleanup = - (char*)DPMI_PendingEventCheck_Cleanup - (char*)Call16_Ret_Start; - dpmi_checker_offset_return = - (char*)DPMI_PendingEventCheck_Return - (char*)Call16_Ret_Start; + dpmi_checker_offset_call = (BYTE *)DPMI_PendingEventCheck - __wine_call16_start; + dpmi_checker_offset_cleanup = (BYTE *)DPMI_PendingEventCheck_Cleanup - __wine_call16_start; + dpmi_checker_offset_return = (BYTE *)DPMI_PendingEventCheck_Return - __wine_call16_start; if (TRACE_ON(relay) || TRACE_ON(snoop)) RELAY16_InitDebugLists(); @@ -148,7 +144,7 @@ WORD *stack; BYTE *instr = (BYTE *)context->Eip; - if (instr < &Call16_Start || instr >= &Call16_End) return FALSE; + if (instr < __wine_call16_start || instr >= __wine_call16_end) return FALSE; /* skip prefixes */ while (*instr == 0x66 || *instr == 0x67) instr++; diff -urN wine-20050628/dlls/lzexpand/lz32.spec wine-20050725/dlls/lzexpand/lz32.spec --- wine-20050628/dlls/lzexpand/lz32.spec 2003-03-20 04:53:14.000000000 +0100 +++ wine-20050725/dlls/lzexpand/lz32.spec 2005-07-25 13:08:30.000000000 +0200 @@ -1,12 +1,12 @@ -@ stdcall CopyLZFile(long long) -@ stdcall GetExpandedNameA(str ptr) -@ stdcall GetExpandedNameW(wstr ptr) -@ stdcall LZClose(long) -@ stdcall LZCopy(long long) -@ stdcall LZDone() -@ stdcall LZInit(long) -@ stdcall LZOpenFileA(str ptr long) -@ stdcall LZOpenFileW(wstr ptr long) -@ stdcall LZRead(long ptr long) -@ stdcall LZSeek(long long long) -@ stdcall LZStart() +@ stdcall CopyLZFile(long long) kernel32.CopyLZFile +@ stdcall GetExpandedNameA(str ptr) kernel32.GetExpandedNameA +@ stdcall GetExpandedNameW(wstr ptr) kernel32.GetExpandedNameW +@ stdcall LZClose(long) kernel32.LZClose +@ stdcall LZCopy(long long) kernel32.LZCopy +@ stdcall LZDone() kernel32.LZDone +@ stdcall LZInit(long) kernel32.LZInit +@ stdcall LZOpenFileA(str ptr long) kernel32.LZOpenFileA +@ stdcall LZOpenFileW(wstr ptr long) kernel32.LZOpenFileW +@ stdcall LZRead(long ptr long) kernel32.LZRead +@ stdcall LZSeek(long long long) kernel32.LZSeek +@ stdcall LZStart() kernel32.LZStart diff -urN wine-20050628/dlls/lzexpand/lzexpand_main.c wine-20050725/dlls/lzexpand/lzexpand_main.c --- wine-20050628/dlls/lzexpand/lzexpand_main.c 2005-03-24 22:01:38.000000000 +0100 +++ wine-20050725/dlls/lzexpand/lzexpand_main.c 2005-07-25 13:08:30.000000000 +0200 @@ -1,598 +1 @@ -/* - * LZ Decompression functions - * - * Copyright 1996 Marcus Meissner - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * NOTES - * - * The LZ (Lempel Ziv) decompression was used in win16 installation programs. - * It is a simple tabledriven decompression engine, the algorithm is not - * documented as far as I know. WINE does not contain a compressor for - * this format. - * - * The implementation is complete and there have been no reports of failures - * for some time. - * - * TODO: - * - * o Check whether the return values are correct - * - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#ifdef HAVE_UNISTD_H -# include -#endif - -#include "windef.h" -#include "winbase.h" -#include "lzexpand.h" - -#include "wine/unicode.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(file); - -/* The readahead length of the decompressor. Reading single bytes - * using _lread() would be SLOW. - */ -#define GETLEN 2048 - -/* Format of first 14 byte of LZ compressed file */ -struct lzfileheader { - BYTE magic[8]; - BYTE compressiontype; - CHAR lastchar; - DWORD reallength; -}; -static BYTE LZMagic[8]={'S','Z','D','D',0x88,0xf0,0x27,0x33}; - -struct lzstate { - HFILE realfd; /* the real filedescriptor */ - CHAR lastchar; /* the last char of the filename */ - - DWORD reallength; /* the decompressed length of the file */ - DWORD realcurrent; /* the position the decompressor currently is */ - DWORD realwanted; /* the position the user wants to read from */ - - BYTE table[0x1000]; /* the rotating LZ table */ - UINT curtabent; /* CURrent TABle ENTry */ - - BYTE stringlen; /* length and position of current string */ - DWORD stringpos; /* from stringtable */ - - - WORD bytetype; /* bitmask within blocks */ - - BYTE *get; /* GETLEN bytes */ - DWORD getcur; /* current read */ - DWORD getlen; /* length last got */ -}; - -#define MAX_LZSTATES 16 -static struct lzstate *lzstates[MAX_LZSTATES]; - -#define IS_LZ_HANDLE(h) (((h) >= 0x400) && ((h) < 0x400+MAX_LZSTATES)) -#define GET_LZ_STATE(h) (IS_LZ_HANDLE(h) ? lzstates[(h)-0x400] : NULL) - -/* reads one compressed byte, including buffering */ -#define GET(lzs,b) _lzget(lzs,&b) -#define GET_FLUSH(lzs) lzs->getcur=lzs->getlen; - -static int -_lzget(struct lzstate *lzs,BYTE *b) { - if (lzs->getcurgetlen) { - *b = lzs->get[lzs->getcur++]; - return 1; - } else { - int ret = _lread(lzs->realfd,lzs->get,GETLEN); - if (ret==HFILE_ERROR) - return HFILE_ERROR; - if (ret==0) - return 0; - lzs->getlen = ret; - lzs->getcur = 1; - *b = *(lzs->get); - return 1; - } -} -/* internal function, reads lzheader - * returns BADINHANDLE for non filedescriptors - * return 0 for file not compressed using LZ - * return UNKNOWNALG for unknown algorithm - * returns lzfileheader in *head - */ -static INT read_header(HFILE fd,struct lzfileheader *head) -{ - BYTE buf[14]; - - if (_llseek(fd,0,SEEK_SET)==-1) - return LZERROR_BADINHANDLE; - - /* We can't directly read the lzfileheader struct due to - * structure element alignment - */ - if (_lread(fd,buf,14)<14) - return 0; - memcpy(head->magic,buf,8); - memcpy(&(head->compressiontype),buf+8,1); - memcpy(&(head->lastchar),buf+9,1); - - /* FIXME: consider endianess on non-intel architectures */ - memcpy(&(head->reallength),buf+10,4); - - if (memcmp(head->magic,LZMagic,8)) - return 0; - if (head->compressiontype!='A') - return LZERROR_UNKNOWNALG; - return 1; -} - - -/*********************************************************************** - * LZStart (LZ32.@) - */ -INT WINAPI LZStart(void) -{ - TRACE("(void)\n"); - return 1; -} - - -/*********************************************************************** - * LZInit (LZ32.@) - * - * initializes internal decompression buffers, returns lzfiledescriptor. - * (return value the same as hfSrc, if hfSrc is not compressed) - * on failure, returns error code <0 - * lzfiledescriptors range from 0x400 to 0x410 (only 16 open files per process) - * - * since _llseek uses the same types as libc.lseek, we just use the macros of - * libc - */ -HFILE WINAPI LZInit( HFILE hfSrc ) -{ - - struct lzfileheader head; - struct lzstate *lzs; - DWORD ret; - int i; - - TRACE("(%d)\n",hfSrc); - ret=read_header(hfSrc,&head); - if (ret<=0) { - _llseek(hfSrc,0,SEEK_SET); - return ret?ret:hfSrc; - } - for (i = 0; i < MAX_LZSTATES; i++) if (!lzstates[i]) break; - if (i == MAX_LZSTATES) return LZERROR_GLOBALLOC; - lzstates[i] = lzs = HeapAlloc( GetProcessHeap(), 0, sizeof(struct lzstate) ); - if(lzs == NULL) return LZERROR_GLOBALLOC; - - memset(lzs,'\0',sizeof(*lzs)); - lzs->realfd = hfSrc; - lzs->lastchar = head.lastchar; - lzs->reallength = head.reallength; - - lzs->get = HeapAlloc( GetProcessHeap(), 0, GETLEN ); - lzs->getlen = 0; - lzs->getcur = 0; - - if(lzs->get == NULL) { - HeapFree(GetProcessHeap(), 0, lzs); - lzstates[i] = NULL; - return LZERROR_GLOBALLOC; - } - - /* Yes, preinitialize with spaces */ - memset(lzs->table,' ',0x1000); - /* Yes, start 16 byte from the END of the table */ - lzs->curtabent = 0xff0; - return 0x400 + i; -} - - -/*********************************************************************** - * LZDone (LZEXPAND.9) - * LZDone (LZ32.@) - */ -void WINAPI LZDone(void) -{ - TRACE("(void)\n"); -} - - -/*********************************************************************** - * GetExpandedNameA (LZ32.@) - * - * gets the full filename of the compressed file 'in' by opening it - * and reading the header - * - * "file." is being translated to "file" - * "file.bl_" (with lastchar 'a') is being translated to "file.bla" - * "FILE.BL_" (with lastchar 'a') is being translated to "FILE.BLA" - */ - -INT WINAPI GetExpandedNameA( LPSTR in, LPSTR out ) -{ - struct lzfileheader head; - HFILE fd; - OFSTRUCT ofs; - INT fnislowercased,ret,len; - LPSTR s,t; - - TRACE("(%s)\n",in); - fd=OpenFile(in,&ofs,OF_READ); - if (fd==HFILE_ERROR) - return (INT)(INT16)LZERROR_BADINHANDLE; - strcpy(out,in); - ret=read_header(fd,&head); - if (ret<=0) { - /* not a LZ compressed file, so the expanded name is the same - * as the input name */ - _lclose(fd); - return 1; - } - - - /* look for directory prefix and skip it. */ - s=out; - while (NULL!=(t=strpbrk(s,"/\\:"))) - s=t+1; - - /* now mangle the basename */ - if (!*s) { - /* FIXME: hmm. shouldn't happen? */ - WARN("Specified a directory or what? (%s)\n",in); - _lclose(fd); - return 1; - } - /* see if we should use lowercase or uppercase on the last char */ - fnislowercased=1; - t=s+strlen(s)-1; - while (t>=out) { - if (!isalpha(*t)) { - t--; - continue; - } - fnislowercased=islower(*t); - break; - } - if (isalpha(head.lastchar)) { - if (fnislowercased) - head.lastchar=tolower(head.lastchar); - else - head.lastchar=toupper(head.lastchar); - } - - /* now look where to replace the last character */ - if (NULL!=(t=strchr(s,'.'))) { - if (t[1]=='\0') { - t[0]='\0'; - } else { - len=strlen(t)-1; - if (t[len]=='_') - t[len]=head.lastchar; - } - } /* else no modification necessary */ - _lclose(fd); - return 1; -} - - -/*********************************************************************** - * GetExpandedNameW (LZ32.@) - */ -INT WINAPI GetExpandedNameW( LPWSTR in, LPWSTR out ) -{ - INT ret; - DWORD len = WideCharToMultiByte( CP_ACP, 0, in, -1, NULL, 0, NULL, NULL ); - char *xin = HeapAlloc( GetProcessHeap(), 0, len ); - char *xout = HeapAlloc( GetProcessHeap(), 0, len+3 ); - WideCharToMultiByte( CP_ACP, 0, in, -1, xin, len, NULL, NULL ); - if ((ret = GetExpandedNameA( xin, xout )) > 0) - MultiByteToWideChar( CP_ACP, 0, xout, -1, out, strlenW(in)+4 ); - HeapFree( GetProcessHeap(), 0, xin ); - HeapFree( GetProcessHeap(), 0, xout ); - return ret; -} - - -/*********************************************************************** - * LZRead (LZ32.@) - */ -INT WINAPI LZRead( HFILE fd, LPSTR vbuf, INT toread ) -{ - int howmuch; - BYTE b,*buf; - struct lzstate *lzs; - - buf=(LPBYTE)vbuf; - TRACE("(%d,%p,%d)\n",fd,buf,toread); - howmuch=toread; - if (!(lzs = GET_LZ_STATE(fd))) return _lread(fd,buf,toread); - -/* The decompressor itself is in a define, cause we need it twice - * in this function. (the decompressed byte will be in b) - */ -#define DECOMPRESS_ONE_BYTE \ - if (lzs->stringlen) { \ - b = lzs->table[lzs->stringpos]; \ - lzs->stringpos = (lzs->stringpos+1)&0xFFF; \ - lzs->stringlen--; \ - } else { \ - if (!(lzs->bytetype&0x100)) { \ - if (1!=GET(lzs,b)) \ - return toread-howmuch; \ - lzs->bytetype = b|0xFF00; \ - } \ - if (lzs->bytetype & 1) { \ - if (1!=GET(lzs,b)) \ - return toread-howmuch; \ - } else { \ - BYTE b1,b2; \ - \ - if (1!=GET(lzs,b1)) \ - return toread-howmuch; \ - if (1!=GET(lzs,b2)) \ - return toread-howmuch; \ - /* Format: \ - * b1 b2 \ - * AB CD \ - * where CAB is the stringoffset in the table\ - * and D+3 is the len of the string \ - */ \ - lzs->stringpos = b1|((b2&0xf0)<<4); \ - lzs->stringlen = (b2&0xf)+2; \ - /* 3, but we use a byte already below ... */\ - b = lzs->table[lzs->stringpos];\ - lzs->stringpos = (lzs->stringpos+1)&0xFFF;\ - } \ - lzs->bytetype>>=1; \ - } \ - /* store b in table */ \ - lzs->table[lzs->curtabent++]= b; \ - lzs->curtabent &= 0xFFF; \ - lzs->realcurrent++; - - /* if someone has seeked, we have to bring the decompressor - * to that position - */ - if (lzs->realcurrent!=lzs->realwanted) { - /* if the wanted position is before the current position - * I see no easy way to unroll ... We have to restart at - * the beginning. *sigh* - */ - if (lzs->realcurrent>lzs->realwanted) { - /* flush decompressor state */ - _llseek(lzs->realfd,14,SEEK_SET); - GET_FLUSH(lzs); - lzs->realcurrent= 0; - lzs->bytetype = 0; - lzs->stringlen = 0; - memset(lzs->table,' ',0x1000); - lzs->curtabent = 0xFF0; - } - while (lzs->realcurrentrealwanted) { - DECOMPRESS_ONE_BYTE; - } - } - - while (howmuch) { - DECOMPRESS_ONE_BYTE; - lzs->realwanted++; - *buf++ = b; - howmuch--; - } - return toread; -#undef DECOMPRESS_ONE_BYTE -} - - -/*********************************************************************** - * LZSeek (LZ32.@) - */ -LONG WINAPI LZSeek( HFILE fd, LONG off, INT type ) -{ - struct lzstate *lzs; - LONG newwanted; - - TRACE("(%d,%ld,%d)\n",fd,off,type); - /* not compressed? just use normal _llseek() */ - if (!(lzs = GET_LZ_STATE(fd))) return _llseek(fd,off,type); - newwanted = lzs->realwanted; - switch (type) { - case 1: /* SEEK_CUR */ - newwanted += off; - break; - case 2: /* SEEK_END */ - newwanted = lzs->reallength-off; - break; - default:/* SEEK_SET */ - newwanted = off; - break; - } - if (newwanted>lzs->reallength) - return LZERROR_BADVALUE; - if (newwanted<0) - return LZERROR_BADVALUE; - lzs->realwanted = newwanted; - return newwanted; -} - - -/*********************************************************************** - * LZCopy (LZ32.@) - * - * Copies everything from src to dest - * if src is a LZ compressed file, it will be uncompressed. - * will return the number of bytes written to dest or errors. - */ -LONG WINAPI LZCopy( HFILE src, HFILE dest ) -{ - int usedlzinit = 0, ret, wret; - LONG len; - HFILE oldsrc = src, srcfd; - FILETIME filetime; - struct lzstate *lzs; -#define BUFLEN 1000 - BYTE buf[BUFLEN]; - /* we need that weird typedef, for i can't seem to get function pointer - * casts right. (Or they probably just do not like WINAPI in general) - */ - typedef UINT (WINAPI *_readfun)(HFILE,LPVOID,UINT); - - _readfun xread; - - TRACE("(%d,%d)\n",src,dest); - if (!IS_LZ_HANDLE(src)) { - src = LZInit(src); - if ((INT)src <= 0) return 0; - if (src != oldsrc) usedlzinit=1; - } - - /* not compressed? just copy */ - if (!IS_LZ_HANDLE(src)) - xread=_lread; - else - xread=(_readfun)LZRead; - len=0; - while (1) { - ret=xread(src,buf,BUFLEN); - if (ret<=0) { - if (ret==0) - break; - if (ret==-1) - return LZERROR_READ; - return ret; - } - len += ret; - wret = _lwrite(dest,buf,ret); - if (wret!=ret) - return LZERROR_WRITE; - } - - /* Maintain the timestamp of source file to destination file */ - srcfd = (!(lzs = GET_LZ_STATE(src))) ? src : lzs->realfd; - GetFileTime((HANDLE)srcfd, NULL, NULL, &filetime); - SetFileTime((HANDLE)dest, NULL, NULL, &filetime); - - /* close handle */ - if (usedlzinit) - LZClose(src); - return len; -#undef BUFLEN -} - -/* reverses GetExpandedPathname */ -static LPSTR LZEXPAND_MangleName( LPCSTR fn ) -{ - char *p; - char *mfn = HeapAlloc( GetProcessHeap(), 0, strlen(fn) + 3 ); /* "._" and \0 */ - if(mfn == NULL) return NULL; - strcpy( mfn, fn ); - if (!(p = strrchr( mfn, '\\' ))) p = mfn; - if ((p = strchr( p, '.' ))) - { - p++; - if (strlen(p) < 3) strcat( p, "_" ); /* append '_' */ - else p[strlen(p)-1] = '_'; /* replace last character */ - } - else strcat( mfn, "._" ); /* append "._" */ - return mfn; -} - - -/*********************************************************************** - * LZOpenFileA (LZ32.@) - * - * Opens a file. If not compressed, open it as a normal file. - */ -HFILE WINAPI LZOpenFileA( LPSTR fn, LPOFSTRUCT ofs, WORD mode ) -{ - HFILE fd,cfd; - - TRACE("(%s,%p,%d)\n",fn,ofs,mode); - /* 0x70 represents all OF_SHARE_* flags, ignore them for the check */ - fd=OpenFile(fn,ofs,mode); - if (fd==HFILE_ERROR) - { - LPSTR mfn = LZEXPAND_MangleName(fn); - fd = OpenFile(mfn,ofs,mode); - HeapFree( GetProcessHeap(), 0, mfn ); - } - if ((mode&~0x70)!=OF_READ) - return fd; - if (fd==HFILE_ERROR) - return HFILE_ERROR; - cfd=LZInit(fd); - if ((INT)cfd <= 0) return fd; - return cfd; -} - - -/*********************************************************************** - * LZOpenFileW (LZ32.@) - */ -HFILE WINAPI LZOpenFileW( LPWSTR fn, LPOFSTRUCT ofs, WORD mode ) -{ - HFILE ret; - DWORD len = WideCharToMultiByte( CP_ACP, 0, fn, -1, NULL, 0, NULL, NULL ); - LPSTR xfn = HeapAlloc( GetProcessHeap(), 0, len ); - WideCharToMultiByte( CP_ACP, 0, fn, -1, xfn, len, NULL, NULL ); - ret = LZOpenFileA(xfn,ofs,mode); - HeapFree( GetProcessHeap(), 0, xfn ); - return ret; -} - - -/*********************************************************************** - * LZClose (LZ32.@) - */ -void WINAPI LZClose( HFILE fd ) -{ - struct lzstate *lzs; - - TRACE("(%d)\n",fd); - if (!(lzs = GET_LZ_STATE(fd))) _lclose(fd); - else - { - HeapFree( GetProcessHeap(), 0, lzs->get ); - CloseHandle((HANDLE)lzs->realfd); - lzstates[fd - 0x400] = NULL; - HeapFree( GetProcessHeap(), 0, lzs ); - } -} - - -/*********************************************************************** - * CopyLZFile (LZ32.@) - * - * Copy src to dest (including uncompressing src). - * NOTE: Yes. This is exactly the same function as LZCopy. - */ -LONG WINAPI CopyLZFile( HFILE src, HFILE dest ) -{ - TRACE("(%d,%d)\n",src,dest); - return LZCopy(src,dest); -} +/* Nothing here - See lzexpand.c in kernel32 */ diff -urN wine-20050628/dlls/midimap/.cvsignore wine-20050725/dlls/midimap/.cvsignore --- wine-20050628/dlls/midimap/.cvsignore 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/midimap/.cvsignore 2005-07-21 13:31:56.000000000 +0200 @@ -0,0 +1,2 @@ +Makefile +midimap.dll.dbg.c diff -urN wine-20050628/dlls/midimap/Makefile.in wine-20050725/dlls/midimap/Makefile.in --- wine-20050628/dlls/midimap/Makefile.in 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/midimap/Makefile.in 2005-07-21 13:31:56.000000000 +0200 @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = midimap.dll +IMPORTS = winmm user32 advapi32 kernel32 + +C_SRCS = \ + midimap.c + +@MAKE_DLL_RULES@ + +### Dependencies: diff -urN wine-20050628/dlls/midimap/midimap.c wine-20050725/dlls/midimap/midimap.c --- wine-20050628/dlls/midimap/midimap.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/midimap/midimap.c 2005-07-21 13:31:56.000000000 +0200 @@ -0,0 +1,563 @@ +/* + * Wine MIDI mapper driver + * + * Copyright 1999, 2000, 2001 Eric Pouech + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * TODO: + * notification has to be implemented + * IDF file loading + */ + +#include +#include +#include +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "mmddk.h" +#include "winreg.h" +#include "wine/unicode.h" +#include "wine/debug.h" + +/* + * Here's how Windows stores the midiOut mapping information. + * + * Full form (in HKU) is: + * + * [Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap] 988836060 + * "AutoScheme"=dword:00000000 + * "ConfigureCount"=dword:00000004 + * "CurrentInstrument"="Wine OSS midi" + * "CurrentScheme"="epp" + * "DriverList"="" + * "UseScheme"=dword:00000000 + * + * AutoScheme: ? + * CurrentInstrument: name of midiOut device to use when UseScheme is 0. Wine uses an extension + * of the form #n to link to n'th midiOut device of the system + * CurrentScheme: when UseScheme is non null, it's the scheme to use (see below) + * DriverList: ? + * UseScheme: trigger for simple/complex mapping + * + * A scheme is defined (in HKLM) as: + * + * [System\\CurrentControlSet\\Control\\MediaProperties\\PrivateProperties\\Midi\\Schemes\\] + * : one key for each defined scheme (system wide) + * under each one of these keys, there's: + * [...\\\\] + * "Channels"="" + * (the default value of this key also refers to the name of the device). + * + * this defines, for each midiOut device (identified by its index in ), which + * channels have to be mapped onto it. The defines the channels (from 0 to 15) + * will be mapped (mapping occurs for channel if bit is set in + * + * Further mapping information can also be defined in: + * [System\\CurrentControlSet\\Control\\MediaProperties\\PrivateProperties\\Midi\\Ports\\\\Instruments\\] + * "Definition"="<.idf file>" + * "FriendlyName"="#for .idx file#" + * "Port"="" + * + * This last part isn't implemented (.idf file support). + */ + +WINE_DEFAULT_DEBUG_CHANNEL(msacm); + +typedef struct tagMIDIOUTPORT +{ + WCHAR name[MAXPNAMELEN]; + int loaded; + HMIDIOUT hMidi; + unsigned short uDevID; + LPBYTE lpbPatch; + unsigned int aChn[16]; +} MIDIOUTPORT; + +typedef struct tagMIDIMAPDATA +{ + struct tagMIDIMAPDATA* self; + MIDIOUTPORT* ChannelMap[16]; +} MIDIMAPDATA; + +static MIDIOUTPORT* midiOutPorts; +static unsigned numMidiOutPorts; + +static BOOL MIDIMAP_IsBadData(MIDIMAPDATA* mm) +{ + if (!IsBadReadPtr(mm, sizeof(MIDIMAPDATA)) && mm->self == mm) + return FALSE; + TRACE("Bad midimap data (%p)\n", mm); + return TRUE; +} + +static BOOL MIDIMAP_FindPort(const WCHAR* name, unsigned* dev) +{ + for (*dev = 0; *dev < numMidiOutPorts; (*dev)++) + { + TRACE("%s\n", wine_dbgstr_w(midiOutPorts[*dev].name)); + if (strcmpW(midiOutPorts[*dev].name, name) == 0) + return TRUE; + } + /* try the form #nnn */ + if (*name == '#' && isdigit(name[1])) + { + const WCHAR* ptr = name + 1; + *dev = 0; + do + { + *dev = *dev * 10 + *ptr - '0'; + } while (isdigit(*++ptr)); + if (*dev < numMidiOutPorts) + return TRUE; + } + return FALSE; +} + +static BOOL MIDIMAP_LoadSettingsDefault(MIDIMAPDATA* mom, const WCHAR* port) +{ + unsigned i, dev = 0; + + if (port != NULL && !MIDIMAP_FindPort(port, &dev)) + { + ERR("Registry glitch: couldn't find midi out (%s)\n", wine_dbgstr_w(port)); + dev = 0; + } + + /* this is necessary when no midi out ports are present */ + if (dev >= numMidiOutPorts) + return FALSE; + /* sets default */ + for (i = 0; i < 16; i++) mom->ChannelMap[i] = &midiOutPorts[dev]; + + return TRUE; +} + +static BOOL MIDIMAP_LoadSettingsScheme(MIDIMAPDATA* mom, const WCHAR* scheme) +{ + HKEY hSchemesKey, hKey, hPortKey; + unsigned i, idx, dev; + WCHAR buffer[256], port[256]; + DWORD type, size, mask; + + for (i = 0; i < 16; i++) mom->ChannelMap[i] = NULL; + + if (RegOpenKeyA(HKEY_LOCAL_MACHINE, + "System\\CurrentControlSet\\Control\\MediaProperties\\PrivateProperties\\Midi\\Schemes", + &hSchemesKey)) + { + return FALSE; + } + if (RegOpenKeyW(hSchemesKey, scheme, &hKey)) + { + RegCloseKey(hSchemesKey); + return FALSE; + } + + for (idx = 0; !RegEnumKeyW(hKey, idx, buffer, sizeof(buffer)); idx++) + { + if (RegOpenKeyW(hKey, buffer, &hPortKey)) continue; + + size = sizeof(port); + if (RegQueryValueExW(hPortKey, NULL, 0, &type, (void*)port, &size)) continue; + + if (!MIDIMAP_FindPort(port, &dev)) continue; + + size = sizeof(mask); + if (RegQueryValueExA(hPortKey, "Channels", 0, &type, (void*)&mask, &size)) + continue; + + for (i = 0; i < 16; i++) + { + if (mask & (1 << i)) + { + if (mom->ChannelMap[i]) + ERR("Quirks in registry, channel %u is mapped twice\n", i); + mom->ChannelMap[i] = &midiOutPorts[dev]; + } + } + } + + RegCloseKey(hSchemesKey); + RegCloseKey(hKey); + + return TRUE; +} + +static BOOL MIDIMAP_LoadSettings(MIDIMAPDATA* mom) +{ + HKEY hKey; + BOOL ret; + + if (RegOpenKeyA(HKEY_CURRENT_USER, + "Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap", &hKey)) + { + ret = MIDIMAP_LoadSettingsDefault(mom, NULL); + } + else + { + DWORD type, size, out; + WCHAR buffer[256]; + + ret = 2; + size = sizeof(out); + if (!RegQueryValueExA(hKey, "UseScheme", 0, &type, (void*)&out, &size) && out) + { + static const WCHAR cs[] = {'C','u','r','r','e','n','t','S','c','h','e','m','e',0}; + size = sizeof(buffer); + if (!RegQueryValueExW(hKey, cs, 0, &type, (void*)buffer, &size)) + { + if (!(ret = MIDIMAP_LoadSettingsScheme(mom, buffer))) + ret = MIDIMAP_LoadSettingsDefault(mom, NULL); + } + else + { + ERR("Wrong registry: UseScheme is active, but no CurrentScheme found\n"); + } + } + if (ret == 2) + { + static const WCHAR ci[] = {'C','u','r','r','e','n','t','I','n','s','t','r','u','m','e','n','t',0}; + size = sizeof(buffer); + if (!RegQueryValueExW(hKey, ci, 0, &type, (void*)buffer, &size) && *buffer) + { + ret = MIDIMAP_LoadSettingsDefault(mom, buffer); + } + else + { + ret = MIDIMAP_LoadSettingsDefault(mom, NULL); + } + } + } + RegCloseKey(hKey); + + if (ret && TRACE_ON(msacm)) + { + unsigned i; + + for (i = 0; i < 16; i++) + { + TRACE("chnMap[%2d] => %d\n", + i, mom->ChannelMap[i] ? mom->ChannelMap[i]->uDevID : -1); + } + } + return ret; +} + +static DWORD modOpen(LPDWORD lpdwUser, LPMIDIOPENDESC lpDesc, DWORD dwFlags) +{ + MIDIMAPDATA* mom = HeapAlloc(GetProcessHeap(), 0, sizeof(MIDIMAPDATA)); + + TRACE("(%p %p %08lx)\n", lpdwUser, lpDesc, dwFlags); + + if (!mom) return MMSYSERR_NOMEM; + + if (MIDIMAP_LoadSettings(mom)) + { + *lpdwUser = (DWORD)mom; + mom->self = mom; + + return MMSYSERR_NOERROR; + } + HeapFree(GetProcessHeap(), 0, mom); + return MIDIERR_INVALIDSETUP; +} + +static DWORD modClose(MIDIMAPDATA* mom) +{ + UINT i; + DWORD ret = MMSYSERR_NOERROR; + + if (MIDIMAP_IsBadData(mom)) return MMSYSERR_ERROR; + + for (i = 0; i < 16; i++) + { + DWORD t; + if (mom->ChannelMap[i] && mom->ChannelMap[i]->loaded > 0) + { + t = midiOutClose(mom->ChannelMap[i]->hMidi); + if (t == MMSYSERR_NOERROR) + { + mom->ChannelMap[i]->loaded = 0; + mom->ChannelMap[i]->hMidi = 0; + } + else if (ret == MMSYSERR_NOERROR) + ret = t; + } + } + if (ret == MMSYSERR_NOERROR) + HeapFree(GetProcessHeap(), 0, mom); + return ret; +} + +static DWORD modLongData(MIDIMAPDATA* mom, LPMIDIHDR lpMidiHdr, DWORD dwParam2) +{ + WORD chn; + DWORD ret = MMSYSERR_NOERROR; + MIDIHDR mh; + + if (MIDIMAP_IsBadData(mom)) + return MMSYSERR_ERROR; + + mh = *lpMidiHdr; + for (chn = 0; chn < 16; chn++) + { + if (mom->ChannelMap[chn] && mom->ChannelMap[chn]->loaded > 0) + { + mh.dwFlags = 0; + midiOutPrepareHeader(mom->ChannelMap[chn]->hMidi, &mh, sizeof(mh)); + ret = midiOutLongMsg(mom->ChannelMap[chn]->hMidi, &mh, sizeof(mh)); + midiOutUnprepareHeader(mom->ChannelMap[chn]->hMidi, &mh, sizeof(mh)); + if (ret != MMSYSERR_NOERROR) break; + } + } + return ret; +} + +static DWORD modData(MIDIMAPDATA* mom, DWORD dwParam) +{ + BYTE lb = LOBYTE(LOWORD(dwParam)); + WORD chn = lb & 0x0F; + DWORD ret = MMSYSERR_NOERROR; + + if (MIDIMAP_IsBadData(mom)) + return MMSYSERR_ERROR; + + if (!mom->ChannelMap[chn]) return MMSYSERR_NOERROR; + + switch (lb & 0xF0) + { + case 0x80: + case 0x90: + case 0xA0: + case 0xB0: + case 0xC0: + case 0xD0: + case 0xE0: + if (mom->ChannelMap[chn]->loaded == 0) + { + if (midiOutOpen(&mom->ChannelMap[chn]->hMidi, mom->ChannelMap[chn]->uDevID, + 0L, 0L, CALLBACK_NULL) == MMSYSERR_NOERROR) + mom->ChannelMap[chn]->loaded = 1; + else + mom->ChannelMap[chn]->loaded = -1; + /* FIXME: should load here the IDF midi data... and allow channel and + * patch mappings + */ + } + if (mom->ChannelMap[chn]->loaded > 0) + { + /* change channel */ + dwParam &= ~0x0F; + dwParam |= mom->ChannelMap[chn]->aChn[chn]; + + if ((LOBYTE(LOWORD(dwParam)) & 0xF0) == 0xC0 /* program change */ && + mom->ChannelMap[chn]->lpbPatch) + { + BYTE patch = HIBYTE(LOWORD(dwParam)); + + /* change patch */ + dwParam &= ~0x0000FF00; + dwParam |= mom->ChannelMap[chn]->lpbPatch[patch]; + } + ret = midiOutShortMsg(mom->ChannelMap[chn]->hMidi, dwParam); + } + break; + case 0xF0: + for (chn = 0; chn < 16; chn++) + { + if (mom->ChannelMap[chn]->loaded > 0) + ret = midiOutShortMsg(mom->ChannelMap[chn]->hMidi, dwParam); + } + break; + default: + FIXME("ooch %lu\n", dwParam); + } + + return ret; +} + +static DWORD modPrepare(MIDIMAPDATA* mom, LPMIDIHDR lpMidiHdr, DWORD dwParam2) +{ + if (MIDIMAP_IsBadData(mom)) return MMSYSERR_ERROR; + if (lpMidiHdr->dwFlags & (MHDR_ISSTRM|MHDR_PREPARED)) + return MMSYSERR_INVALPARAM; + + lpMidiHdr->dwFlags |= MHDR_PREPARED; + return MMSYSERR_NOERROR; +} + +static DWORD modUnprepare(MIDIMAPDATA* mom, LPMIDIHDR lpMidiHdr, DWORD dwParam2) +{ + if (MIDIMAP_IsBadData(mom)) return MMSYSERR_ERROR; + if ((lpMidiHdr->dwFlags & MHDR_ISSTRM) || !(lpMidiHdr->dwFlags & MHDR_PREPARED)) + return MMSYSERR_INVALPARAM; + + lpMidiHdr->dwFlags &= ~MHDR_PREPARED; + return MMSYSERR_NOERROR; +} + +static DWORD modGetDevCaps(UINT wDevID, MIDIMAPDATA* mom, LPMIDIOUTCAPSW lpMidiCaps, DWORD size) +{ + static const WCHAR name[] = {'W','i','n','e',' ','m','i','d','i',' ','m','a','p','p','e','r',0}; + lpMidiCaps->wMid = 0x00FF; + lpMidiCaps->wPid = 0x0001; + lpMidiCaps->vDriverVersion = 0x0100; + lstrcpyW(lpMidiCaps->szPname, name); + lpMidiCaps->wTechnology = MOD_MAPPER; + lpMidiCaps->wVoices = 0; + lpMidiCaps->wNotes = 0; + lpMidiCaps->wChannelMask = 0xFFFF; + lpMidiCaps->dwSupport = 0L; + + return MMSYSERR_NOERROR; +} + +static DWORD modReset(MIDIMAPDATA* mom) +{ + WORD chn; + DWORD ret = MMSYSERR_NOERROR; + + if (MIDIMAP_IsBadData(mom)) + return MMSYSERR_ERROR; + + for (chn = 0; chn < 16; chn++) + { + if (mom->ChannelMap[chn] && mom->ChannelMap[chn]->loaded > 0) + { + ret = midiOutReset(mom->ChannelMap[chn]->hMidi); + if (ret != MMSYSERR_NOERROR) break; + } + } + return ret; +} + +/************************************************************************** + * modMessage (MIDIMAP.@) + */ +DWORD WINAPI MIDIMAP_modMessage(UINT wDevID, UINT wMsg, DWORD dwUser, + DWORD dwParam1, DWORD dwParam2) +{ + TRACE("(%u, %04X, %08lX, %08lX, %08lX);\n", + wDevID, wMsg, dwUser, dwParam1, dwParam2); + + switch (wMsg) + { + case DRVM_INIT: + case DRVM_EXIT: + case DRVM_ENABLE: + case DRVM_DISABLE: + /* FIXME: Pretend this is supported */ + return 0; + + case MODM_OPEN: return modOpen ((LPDWORD)dwUser, (LPMIDIOPENDESC)dwParam1,dwParam2); + case MODM_CLOSE: return modClose ((MIDIMAPDATA*)dwUser); + + case MODM_DATA: return modData ((MIDIMAPDATA*)dwUser, dwParam1); + case MODM_LONGDATA: return modLongData ((MIDIMAPDATA*)dwUser, (LPMIDIHDR)dwParam1, dwParam2); + case MODM_PREPARE: return modPrepare ((MIDIMAPDATA*)dwUser, (LPMIDIHDR)dwParam1, dwParam2); + case MODM_UNPREPARE: return modUnprepare ((MIDIMAPDATA*)dwUser, (LPMIDIHDR)dwParam1, dwParam2); + case MODM_RESET: return modReset ((MIDIMAPDATA*)dwUser); + + case MODM_GETDEVCAPS: return modGetDevCaps (wDevID, (MIDIMAPDATA*)dwUser, (LPMIDIOUTCAPSW)dwParam1,dwParam2); + case MODM_GETNUMDEVS: return 1; + case MODM_GETVOLUME: return MMSYSERR_NOTSUPPORTED; + case MODM_SETVOLUME: return MMSYSERR_NOTSUPPORTED; + default: + FIXME("unknown message %d!\n", wMsg); + } + return MMSYSERR_NOTSUPPORTED; +} + +/*======================================================================* + * Driver part * + *======================================================================*/ + +/************************************************************************** + * MIDIMAP_drvOpen [internal] + */ +static DWORD MIDIMAP_drvOpen(LPSTR str) +{ + MIDIOUTCAPSW moc; + unsigned dev, i; + + if (midiOutPorts) + return 0; + + numMidiOutPorts = midiOutGetNumDevs(); + midiOutPorts = HeapAlloc(GetProcessHeap(), 0, + numMidiOutPorts * sizeof(MIDIOUTPORT)); + for (dev = 0; dev < numMidiOutPorts; dev++) + { + if (midiOutGetDevCapsW(dev, &moc, sizeof(moc)) == 0L) + { + strcpyW(midiOutPorts[dev].name, moc.szPname); + midiOutPorts[dev].loaded = 0; + midiOutPorts[dev].hMidi = 0; + midiOutPorts[dev].uDevID = dev; + midiOutPorts[dev].lpbPatch = NULL; + for (i = 0; i < 16; i++) + midiOutPorts[dev].aChn[i] = i; + } + else + { + midiOutPorts[dev].loaded = -1; + } + } + + return 1; +} + +/************************************************************************** + * MIDIMAP_drvClose [internal] + */ +static DWORD MIDIMAP_drvClose(DWORD dwDevID) +{ + if (midiOutPorts) + { + HeapFree(GetProcessHeap(), 0, midiOutPorts); + midiOutPorts = NULL; + return 1; + } + return 0; +} + +/************************************************************************** + * DriverProc (MIDIMAP.@) + */ +LONG CALLBACK MIDIMAP_DriverProc(DWORD dwDevID, HDRVR hDriv, DWORD wMsg, + DWORD dwParam1, DWORD dwParam2) +{ +/* EPP TRACE("(%08lX, %04X, %08lX, %08lX, %08lX)\n", */ +/* EPP dwDevID, hDriv, wMsg, dwParam1, dwParam2); */ + + switch (wMsg) + { + case DRV_LOAD: return 1; + case DRV_FREE: return 1; + case DRV_OPEN: return MIDIMAP_drvOpen((LPSTR)dwParam1); + case DRV_CLOSE: return MIDIMAP_drvClose(dwDevID); + case DRV_ENABLE: return 1; + case DRV_DISABLE: return 1; + case DRV_QUERYCONFIGURE: return 1; + case DRV_CONFIGURE: MessageBoxA(0, "MIDIMAP MultiMedia Driver !", "OSS Driver", MB_OK); return 1; + case DRV_INSTALL: return DRVCNF_RESTART; + case DRV_REMOVE: return DRVCNF_RESTART; + default: + return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2); + } +} diff -urN wine-20050628/dlls/midimap/midimap.spec wine-20050725/dlls/midimap/midimap.spec --- wine-20050628/dlls/midimap/midimap.spec 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050725/dlls/midimap/midimap.spec 2005-07-21 13:31:56.000000000 +0200 @@ -0,0 +1,3 @@ +@ stdcall DriverProc(long long long long long) MIDIMAP_DriverProc +@ stdcall modMessage(long long long long long) MIDIMAP_modMessage +@ stub modmCallback diff -urN wine-20050628/dlls/mlang/mlang.c wine-20050725/dlls/mlang/mlang.c --- wine-20050628/dlls/mlang/mlang.c 2005-06-27 13:10:16.000000000 +0200 +++ wine-20050725/dlls/mlang/mlang.c 2005-07-12 21:21:37.000000000 +0200 @@ -654,7 +654,7 @@ typedef struct { IClassFactory ITF_IClassFactory; - DWORD ref; + LONG ref; HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); } IClassFactoryImpl; @@ -793,7 +793,7 @@ const IMLangFontLinkVtbl *vtbl_IMLangFontLink; const IMultiLanguageVtbl *vtbl_IMultiLanguage; const IMultiLanguage2Vtbl *vtbl_IMultiLanguage2; - DWORD ref; + LONG ref; DWORD total_cp, total_scripts; } MLang_impl; @@ -858,7 +858,7 @@ typedef struct tagEnumCodePage_impl { const IEnumCodePageVtbl *vtbl_IEnumCodePage; - DWORD ref; + LONG ref; MIMECPINFO *cpinfo; DWORD total, pos; } EnumCodePage_impl; @@ -1044,7 +1044,7 @@ typedef struct tagEnumScript_impl { const IEnumScriptVtbl *vtbl_IEnumScript; - DWORD ref; + LONG ref; SCRIPTINFO *script_info; DWORD total, pos; } EnumScript_impl; diff -urN wine-20050628/dlls/mpr/pwcache.c wine-20050725/dlls/mpr/pwcache.c --- wine-20050628/dlls/mpr/pwcache.c 2005-06-13 20:56:01.000000000 +0200 +++ wine-20050725/dlls/mpr/pwcache.c 2005-07-07 14:08:43.000000000 +0200 @@ -108,7 +108,7 @@ if( valname ) { r = RegSetValueExA( hkey, valname, 0, REG_BINARY, - pbPassword, cbPassword ); + (LPBYTE)pbPassword, cbPassword ); if( r ) r = WN_CANCEL; else @@ -202,7 +202,7 @@ if( valname ) { sz = *pcbPassword; - r = RegQueryValueExA( hkey, valname, 0, &type, pbPassword, &sz ); + r = RegQueryValueExA( hkey, valname, 0, &type, (LPBYTE)pbPassword, &sz ); *pcbPassword = sz; if( r ) r = WN_CANCEL; diff -urN wine-20050628/dlls/mscms/Makefile.in wine-20050725/dlls/mscms/Makefile.in --- wine-20050628/dlls/mscms/Makefile.in 2005-05-09 16:42:33.000000000 +0200 +++ wine-20050725/dlls/mscms/Makefile.in 2005-07-15 12:09:43.000000000 +0200 @@ -5,6 +5,7 @@ MODULE = mscms.dll IMPORTLIB = libmscms.$(IMPLIBEXT) IMPORTS = kernel32 ntdll +EXTRALIBS = @LCMSLIBS@ C_SRCS = \ handle.c \ diff -urN wine-20050628/dlls/mscms/handle.c wine-20050725/dlls/mscms/handle.c --- wine-20050628/dlls/mscms/handle.c 2005-02-21 19:38:15.000000000 +0100 +++ wine-20050725/dlls/mscms/handle.c 2005-07-18 17:10:37.000000000 +0200 @@ -29,7 +29,7 @@ #include "mscms_priv.h" -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS static CRITICAL_SECTION MSCMS_handle_cs; static CRITICAL_SECTION_DEBUG MSCMS_handle_cs_debug = @@ -284,4 +284,4 @@ } } -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ diff -urN wine-20050628/dlls/mscms/icc.c wine-20050725/dlls/mscms/icc.c --- wine-20050628/dlls/mscms/icc.c 2005-02-14 21:53:59.000000000 +0100 +++ wine-20050725/dlls/mscms/icc.c 2005-07-18 17:10:36.000000000 +0200 @@ -32,13 +32,11 @@ #include "winternl.h" #include "icm.h" -#define LCMS_API_FUNCTION(f) extern typeof(f) * p##f; -#include "lcms_api.h" -#undef LCMS_API_FUNCTION +#include "mscms_priv.h" WINE_DEFAULT_DEBUG_CHANNEL(mscms); -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS static inline void MSCMS_adjust_endianess32( ULONG *ptr ) { @@ -109,4 +107,4 @@ return size; } -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ diff -urN wine-20050628/dlls/mscms/lcms_api.h wine-20050725/dlls/mscms/lcms_api.h --- wine-20050628/dlls/mscms/lcms_api.h 2005-03-08 20:00:14.000000000 +0100 +++ wine-20050725/dlls/mscms/lcms_api.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,47 +0,0 @@ -/* - * MSCMS - Color Management System for Wine - * - * Copyright 2004, 2005 Hans Leidekker - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mscms_priv.h" - -#ifndef LCMS_API_FUNCTION -#error "This file should be included with LCMS_API_FUNCTION defined!" -#endif - -#ifdef HAVE_LCMS_H - -LCMS_API_FUNCTION(cmsCloseProfile) -LCMS_API_FUNCTION(cmsCreate_sRGBProfile) -LCMS_API_FUNCTION(cmsCreateMultiprofileTransform) -LCMS_API_FUNCTION(cmsCreateTransform) -LCMS_API_FUNCTION(cmsDeleteTransform) -LCMS_API_FUNCTION(cmsDoTransform) -LCMS_API_FUNCTION(cmsOpenProfileFromMem) - -#ifndef LCMS_API_NO_REDEFINE -#define cmsCloseProfile pcmsCloseProfile -#define cmsCreate_sRGBProfile pcmsCreate_sRGBProfile -#define cmsCreateMultiprofileTransform pcmsCreateMultiprofileTransform -#define cmsCreateTransform pcmsCreateTransform -#define cmsDeleteTransform pcmsDeleteTransform -#define cmsDoTransform pcmsDoTransform -#define cmsOpenProfileFromMem pcmsOpenProfileFromMem -#endif /* LCMS_API_NO_REDEFINE */ - -#endif /* HAVE_LCMS_H */ diff -urN wine-20050628/dlls/mscms/mscms_main.c wine-20050725/dlls/mscms/mscms_main.c --- wine-20050628/dlls/mscms/mscms_main.c 2005-06-21 22:53:14.000000000 +0200 +++ wine-20050725/dlls/mscms/mscms_main.c 2005-07-15 12:09:43.000000000 +0200 @@ -32,92 +32,8 @@ #include "winuser.h" #include "icm.h" -#define LCMS_API_NO_REDEFINE -#define LCMS_API_FUNCTION(f) typeof(f) * p##f; -#include "lcms_api.h" -#undef LCMS_API_FUNCTION - WINE_DEFAULT_DEBUG_CHANNEL(mscms); -#ifdef HAVE_LCMS_H -#ifndef SONAME_LIBLCMS -#define SONAME_LIBLCMS "liblcms.so" -#endif - -static void *lcmshandle = NULL; -#endif /* HAVE_LCMS_H */ - -static BOOL MSCMS_init_lcms(void) -{ -#ifdef HAVE_LCMS_H - /* dynamically load lcms if not yet loaded */ - if (!lcmshandle) - { - lcmshandle = wine_dlopen( SONAME_LIBLCMS, RTLD_NOW, NULL, 0 ); - - /* We can't really do anything useful without liblcms */ - if (!lcmshandle) - { - WINE_MESSAGE( - "Wine cannot find the LittleCMS library. To enable Wine to use color\n" - "management functions please install a version of LittleCMS greater\n" - "than or equal to 1.13.\n" - "http://www.littlecms.com\n" ); - - return FALSE; - } - } - -#define LOAD_FUNCPTR(f) \ - if ((p##f = wine_dlsym( lcmshandle, #f, NULL, 0 )) == NULL) \ - goto sym_not_found; - - LOAD_FUNCPTR(cmsCloseProfile); - LOAD_FUNCPTR(cmsCreate_sRGBProfile); - LOAD_FUNCPTR(cmsCreateMultiprofileTransform); - LOAD_FUNCPTR(cmsCreateTransform); - LOAD_FUNCPTR(cmsDeleteTransform); - LOAD_FUNCPTR(cmsDoTransform); - LOAD_FUNCPTR(cmsOpenProfileFromMem); - #undef LOAD_FUNCPTR - -return TRUE; - -sym_not_found: - WINE_MESSAGE( - "Wine cannot find certain functions that it needs inside the LittleCMS\n" - "library. To enable Wine to use LittleCMS for color management please\n" - "upgrade liblcms to at least version 1.13.\n" - "http://www.littlecms.com\n" ); - - wine_dlclose( lcmshandle, NULL, 0 ); - lcmshandle = NULL; - - return FALSE; - -#endif /* HAVE_LCMS_H */ - WINE_MESSAGE( - "This version of Wine was compiled without support for color management\n" - "functions. This means many color functions are empty stubs and you should\n" - "expect your application to fail. To enable Wine to use LittleCMS for color\n" - "management please install a liblcms development package version 1.13 or\n" - "higher and rebuild Wine.\n" - "http://www.littlecms.com\n" ); - - return TRUE; -} - -static void MSCMS_deinit_lcms(void) -{ -#ifdef HAVE_LCMS_H - if (lcmshandle) - { - wine_dlclose( lcmshandle, NULL, 0 ); - lcmshandle = NULL; - } -#endif /* HAVE_LCMS_H */ -} - BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) { TRACE( "(%p, 0x%08lx, %p)\n", hinst, reason, reserved ); @@ -126,10 +42,8 @@ { case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls( hinst ); - return MSCMS_init_lcms(); - + break; case DLL_PROCESS_DETACH: - MSCMS_deinit_lcms(); break; } return TRUE; diff -urN wine-20050628/dlls/mscms/mscms_priv.h wine-20050725/dlls/mscms/mscms_priv.h --- wine-20050628/dlls/mscms/mscms_priv.h 2005-02-21 19:38:15.000000000 +0100 +++ wine-20050725/dlls/mscms/mscms_priv.h 2005-07-18 17:10:36.000000000 +0200 @@ -18,11 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef HAVE_LCMS_LCMS_H -#define HAVE_LCMS_H 1 -#endif - -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS /* These basic Windows types are defined in lcms.h when compiling on * a non-Windows platform (why?), so they would normally not conflict @@ -92,4 +88,4 @@ extern void MSCMS_set_profile_header( icProfile *iccprofile, PROFILEHEADER *header ); extern DWORD MSCMS_get_profile_size( icProfile *iccprofile ); -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ diff -urN wine-20050628/dlls/mscms/profile.c wine-20050725/dlls/mscms/profile.c --- wine-20050628/dlls/mscms/profile.c 2005-04-11 20:49:40.000000000 +0200 +++ wine-20050725/dlls/mscms/profile.c 2005-07-18 17:10:36.000000000 +0200 @@ -30,9 +30,7 @@ #include "winuser.h" #include "icm.h" -#define LCMS_API_FUNCTION(f) extern typeof(f) * p##f; -#include "lcms_api.h" -#undef LCMS_API_FUNCTION +#include "mscms_priv.h" #define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/') @@ -44,11 +42,6 @@ lstrcpyW( name, &path[i] ); } -/* FIXME: Get this directory from the registry? */ -static const WCHAR colorsubdir[] = { '\\','s','y','s','t','e','m','3','2', - '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s', - '\\','c','o','l','o','r',0 }; - WINE_DEFAULT_DEBUG_CHANNEL(mscms); /****************************************************************************** @@ -109,13 +102,14 @@ BOOL WINAPI GetColorDirectoryW( PCWSTR machine, PWSTR buffer, PDWORD size ) { WCHAR colordir[MAX_PATH]; + static const WCHAR colorsubdir[] = { '\\','c','o','l','o','r',0 }; DWORD len; TRACE( "( %p, %p )\n", buffer, size ); if (machine || !size) return FALSE; - GetWindowsDirectoryW( colordir, sizeof(colordir) / sizeof(WCHAR) ); + GetSystemDirectoryW( colordir, sizeof(colordir) / sizeof(WCHAR) ); lstrcatW( colordir, colorsubdir ); len = lstrlenW( colordir ) * sizeof(WCHAR); @@ -154,7 +148,7 @@ PVOID buffer, PBOOL ref ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); DWORD i, count; icTag tag; @@ -183,7 +177,7 @@ } } -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -208,7 +202,7 @@ BOOL WINAPI GetColorProfileElementTag( HPROFILE profile, DWORD index, PTAGTYPE type ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); DWORD count; icTag tag; @@ -225,7 +219,7 @@ ret = TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -250,7 +244,7 @@ BOOL WINAPI GetColorProfileFromHandle( HPROFILE profile, PBYTE buffer, PDWORD size ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); PROFILEHEADER header; @@ -271,7 +265,7 @@ *size = header.phSize; ret = TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -294,7 +288,7 @@ BOOL WINAPI GetColorProfileHeader( HPROFILE profile, PPROFILEHEADER header ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); TRACE( "( %p, %p )\n", profile, header ); @@ -304,7 +298,7 @@ MSCMS_get_profile_header( iccprofile, header ); return TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -325,7 +319,7 @@ BOOL WINAPI GetCountColorProfileElements( HPROFILE profile, PDWORD count ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); TRACE( "( %p, %p )\n", profile, count ); @@ -334,7 +328,7 @@ *count = MSCMS_get_tag_count( iccprofile ); ret = TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -399,23 +393,22 @@ */ BOOL WINAPI GetStandardColorSpaceProfileW( PCWSTR machine, DWORD id, PWSTR profile, PDWORD size ) { - static const WCHAR rgbprofilefile[] = { '\\','s','r','g','b',' ','c','o','l','o','r',' ', - 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 }; + static const WCHAR rgbprofilefile[] = + { '\\','s','r','g','b',' ','c','o','l','o','r',' ', + 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 }; WCHAR rgbprofile[MAX_PATH]; - DWORD len; + DWORD len = sizeof(rgbprofile); TRACE( "( 0x%08lx, %p, %p )\n", id, profile, size ); if (machine || !size) return FALSE; + GetColorDirectoryW( machine, rgbprofile, &len ); switch (id) { case 0x52474220: /* 'RGB ' */ - GetWindowsDirectoryW( rgbprofile, sizeof( rgbprofile ) / sizeof( WCHAR ) ); - lstrcatW( rgbprofile, colorsubdir ); lstrcatW( rgbprofile, rgbprofilefile ); - - len = lstrlenW( rgbprofile ) * sizeof( WCHAR ); + len = lstrlenW( rgbprofile ) * sizeof(WCHAR); if (*size < len || !profile) { @@ -429,7 +422,6 @@ default: return FALSE; } - return TRUE; } @@ -516,7 +508,7 @@ BOOL WINAPI IsColorProfileTagPresent( HPROFILE profile, TAGTYPE type, PBOOL present ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); DWORD i, count; icTag tag; @@ -538,7 +530,7 @@ } } -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -559,7 +551,7 @@ BOOL WINAPI IsColorProfileValid( HPROFILE profile, PBOOL valid ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); TRACE( "( %p, %p )\n", profile, valid ); @@ -567,7 +559,7 @@ if (!valid) return FALSE; if (iccprofile) return *valid = TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -592,7 +584,7 @@ PVOID buffer ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); DWORD i, count, access = MSCMS_hprofile2access( profile ); icTag tag; @@ -617,7 +609,7 @@ } } -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -637,7 +629,7 @@ BOOL WINAPI SetColorProfileHeader( HPROFILE profile, PPROFILEHEADER header ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); DWORD access = MSCMS_hprofile2access( profile ); @@ -649,7 +641,7 @@ MSCMS_set_profile_header( iccprofile, header ); return TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -771,7 +763,7 @@ */ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation ) { -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS cmsHPROFILE cmsprofile = NULL; icProfile *iccprofile = NULL; HANDLE handle = NULL; @@ -839,7 +831,7 @@ if (cmsprofile) return MSCMS_create_hprofile_handle( handle, iccprofile, cmsprofile, access ); -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return NULL; } @@ -858,7 +850,7 @@ BOOL WINAPI CloseColorProfile( HPROFILE profile ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile ); HANDLE file = MSCMS_hprofile2handle( profile ); DWORD access = MSCMS_hprofile2access( profile ); @@ -880,6 +872,6 @@ CloseHandle( MSCMS_hprofile2handle( profile ) ); MSCMS_destroy_hprofile_handle( profile ); -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } diff -urN wine-20050628/dlls/mscms/tests/Makefile.in wine-20050725/dlls/mscms/tests/Makefile.in --- wine-20050628/dlls/mscms/tests/Makefile.in 2004-10-07 21:12:41.000000000 +0200 +++ wine-20050725/dlls/mscms/tests/Makefile.in 2005-07-07 19:22:47.000000000 +0200 @@ -3,7 +3,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = mscms.dll -IMPORTS = mscms kernel32 +IMPORTS = kernel32 CTESTS = \ profile.c diff -urN wine-20050628/dlls/mscms/tests/profile.c wine-20050725/dlls/mscms/tests/profile.c --- wine-20050628/dlls/mscms/tests/profile.c 2005-06-20 16:18:04.000000000 +0200 +++ wine-20050725/dlls/mscms/tests/profile.c 2005-07-18 11:08:43.000000000 +0200 @@ -29,6 +29,60 @@ #include "wine/test.h" +HMODULE hmscms; + +static BOOL (WINAPI *pCloseColorProfile)(HPROFILE); +static BOOL (WINAPI *pGetColorDirectoryA)(PCHAR,PCHAR,PDWORD); +static BOOL (WINAPI *pGetColorDirectoryW)(PWCHAR,PWCHAR,PDWORD); +static BOOL (WINAPI *pGetColorProfileElement)(HPROFILE,TAGTYPE,DWORD,PDWORD,PVOID,PBOOL); +static BOOL (WINAPI *pGetColorProfileElementTag)(HPROFILE,DWORD,PTAGTYPE); +static BOOL (WINAPI *pGetColorProfileFromHandle)(HPROFILE,PBYTE,PDWORD); +static BOOL (WINAPI *pGetColorProfileHeader)(HPROFILE,PPROFILEHEADER); +static BOOL (WINAPI *pGetCountColorProfileElements)(HPROFILE,PDWORD); +static BOOL (WINAPI *pGetStandardColorSpaceProfileA)(PCSTR,DWORD,PSTR,PDWORD); +static BOOL (WINAPI *pGetStandardColorSpaceProfileW)(PCWSTR,DWORD,PWSTR,PDWORD); +static BOOL (WINAPI *pInstallColorProfileA)(PCSTR,PCSTR); +static BOOL (WINAPI *pInstallColorProfileW)(PCWSTR,PCWSTR); +static BOOL (WINAPI *pIsColorProfileTagPresent)(HPROFILE,TAGTYPE,PBOOL); +static HPROFILE (WINAPI *pOpenColorProfileA)(PPROFILE,DWORD,DWORD,DWORD); +static HPROFILE (WINAPI *pOpenColorProfileW)(PPROFILE,DWORD,DWORD,DWORD); +static BOOL (WINAPI *pSetColorProfileElement)(HPROFILE,TAGTYPE,DWORD,PDWORD,PVOID); +static BOOL (WINAPI *pSetColorProfileHeader)(HPROFILE,PPROFILEHEADER); +static BOOL (WINAPI *pSetStandardColorSpaceProfileA)(PCSTR,DWORD,PSTR); +static BOOL (WINAPI *pSetStandardColorSpaceProfileW)(PCWSTR,DWORD,PWSTR); +static BOOL (WINAPI *pUninstallColorProfileA)(PCSTR,PCSTR,BOOL); +static BOOL (WINAPI *pUninstallColorProfileW)(PCWSTR,PCWSTR,BOOL); + +#define GETFUNCPTR(func) p##func = (void *)GetProcAddress( hmscms, #func ); \ + if (!p##func) return FALSE; + +static BOOL init_function_ptrs( void ) +{ + GETFUNCPTR( CloseColorProfile ) + GETFUNCPTR( GetColorDirectoryA ) + GETFUNCPTR( GetColorDirectoryW ) + GETFUNCPTR( GetColorProfileElement ) + GETFUNCPTR( GetColorProfileElementTag ) + GETFUNCPTR( GetColorProfileFromHandle ) + GETFUNCPTR( GetColorProfileHeader ) + GETFUNCPTR( GetCountColorProfileElements ) + GETFUNCPTR( GetStandardColorSpaceProfileA ) + GETFUNCPTR( GetStandardColorSpaceProfileW ) + GETFUNCPTR( InstallColorProfileA ) + GETFUNCPTR( InstallColorProfileW ) + GETFUNCPTR( IsColorProfileTagPresent ) + GETFUNCPTR( OpenColorProfileA ) + GETFUNCPTR( OpenColorProfileW ) + GETFUNCPTR( SetColorProfileElement ) + GETFUNCPTR( SetColorProfileHeader ) + GETFUNCPTR( SetStandardColorSpaceProfileA ) + GETFUNCPTR( SetStandardColorSpaceProfileW ) + GETFUNCPTR( UninstallColorProfileA ) + GETFUNCPTR( UninstallColorProfileW ) + + return TRUE; +} + static const char machine[] = "dummy"; static const WCHAR machineW[] = { 'd','u','m','m','y',0 }; @@ -41,18 +95,21 @@ * http://download.microsoft.com/download/whistler/hwdev1/1.0/wxp/en-us/ColorProfile.exe */ -/* Two common places to find the standard color space profile */ -static const char profilefile[] = +/* Two common places to find the standard color space profile, relative + * to the system directory. + */ +static const char profile1[] = "\\color\\srgb color space profile.icm"; -static const char profilesubdir[] = -"\\system32\\spool\\drivers"; +static const char profile2[] = +"\\spool\\drivers\\color\\srgb color space profile.icm"; -static const WCHAR profilefileW[] = +static const WCHAR profile1W[] = { '\\','c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ', 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 }; -static const WCHAR profilesubdirW[] = -{ '\\', 's','y','s','t','e','m','3','2','\\','s','p','o','o','l', - '\\','d','r','i','v','e','r','s',0 }; +static const WCHAR profile2W[] = +{ '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\', + 'c','o','l','o','r','\\','s','r','g','b',' ','c','o','l','o','r',' ', + 's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 }; static const unsigned char rgbheader[] = { 0x48, 0x0c, 0x00, 0x00, 0x6f, 0x6e, 0x69, 0x4c, 0x00, 0x00, 0x10, 0x02, @@ -95,29 +152,29 @@ /* Parameter checks */ - ret = GetColorDirectoryA( NULL, NULL, NULL ); + ret = pGetColorDirectoryA( NULL, NULL, NULL ); ok( !ret, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() ); size = 0; - ret = GetColorDirectoryA( NULL, NULL, &size ); + ret = pGetColorDirectoryA( NULL, NULL, &size ); ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() ); size = 0; - ret = GetColorDirectoryA( NULL, buffer, &size ); + ret = pGetColorDirectoryA( NULL, buffer, &size ); ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() ); size = 1; - ret = GetColorDirectoryA( NULL, buffer, &size ); + ret = pGetColorDirectoryA( NULL, buffer, &size ); ok( !ret && size > 0, "GetColorDirectoryA() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ size = sizeof(buffer); - ret = GetColorDirectoryA( NULL, buffer, &size ); + ret = pGetColorDirectoryA( NULL, buffer, &size ); ok( ret && size > 0, "GetColorDirectoryA() failed (%ld)\n", GetLastError() ); } @@ -131,31 +188,31 @@ /* This one crashes win2k - ret = GetColorDirectoryW( NULL, NULL, NULL ); + ret = pGetColorDirectoryW( NULL, NULL, NULL ); ok( !ret, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() ); */ size = 0; - ret = GetColorDirectoryW( NULL, NULL, &size ); + ret = pGetColorDirectoryW( NULL, NULL, &size ); ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() ); size = 0; - ret = GetColorDirectoryW( NULL, buffer, &size ); + ret = pGetColorDirectoryW( NULL, buffer, &size ); ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() ); size = 1; - ret = GetColorDirectoryW( NULL, buffer, &size ); + ret = pGetColorDirectoryW( NULL, buffer, &size ); ok( !ret && size > 0, "GetColorDirectoryW() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ size = sizeof(buffer); - ret = GetColorDirectoryW( NULL, buffer, &size ); + ret = pGetColorDirectoryW( NULL, buffer, &size ); ok( ret && size > 0, "GetColorDirectoryW() failed (%ld)\n", GetLastError() ); } @@ -180,32 +237,32 @@ profile.pProfileData = standardprofile; profile.cbDataSize = strlen(standardprofile); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); /* Parameter checks */ - ret = GetColorProfileElement( handle, tag, 0, NULL, NULL, &ref ); + ret = pGetColorProfileElement( handle, tag, 0, NULL, NULL, &ref ); ok( !ret, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() ); - ret = GetColorProfileElement( handle, tag, 0, &size, NULL, NULL ); + ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, NULL ); ok( !ret, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() ); size = 0; - ret = GetColorProfileElement( handle, tag, 0, &size, NULL, &ref ); + ret = pGetColorProfileElement( handle, tag, 0, &size, NULL, &ref ); ok( !ret && size > 0, "GetColorProfileElement() succeeded (%ld)\n", GetLastError() ); size = sizeof(buffer); /* Functional checks */ - ret = GetColorProfileElement( handle, tag, 0, &size, buffer, &ref ); + ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref ); ok( ret && size > 0, "GetColorProfileElement() failed (%ld)\n", GetLastError() ); ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected tag data\n" ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -223,30 +280,30 @@ profile.pProfileData = standardprofile; profile.cbDataSize = strlen(standardprofile); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); /* Parameter checks */ - ret = GetColorProfileElementTag( NULL, index, &tag ); + ret = pGetColorProfileElementTag( NULL, index, &tag ); ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() ); - ret = GetColorProfileElementTag( handle, 0, &tag ); + ret = pGetColorProfileElementTag( handle, 0, &tag ); ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() ); - ret = GetColorProfileElementTag( handle, index, NULL ); + ret = pGetColorProfileElementTag( handle, index, NULL ); ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() ); - ret = GetColorProfileElementTag( handle, 18, NULL ); + ret = pGetColorProfileElementTag( handle, 18, NULL ); ok( !ret, "GetColorProfileElementTag() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ - ret = GetColorProfileElementTag( handle, index, &tag ); + ret = pGetColorProfileElementTag( handle, index, &tag ); ok( ret && tag == expect, "GetColorProfileElementTag() failed (%ld)\n", GetLastError() ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -274,29 +331,29 @@ profile.pProfileData = testprofile; profile.cbDataSize = strlen(testprofile); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); /* Parameter checks */ size = 0; - ret = GetColorProfileFromHandle( handle, NULL, &size ); + ret = pGetColorProfileFromHandle( handle, NULL, &size ); ok( !ret && size > 0, "GetColorProfileFromHandle() failed (%ld)\n", GetLastError() ); buffer = HeapAlloc( GetProcessHeap(), 0, size ); if (buffer) { - ret = GetColorProfileFromHandle( NULL, buffer, &size ); + ret = pGetColorProfileFromHandle( NULL, buffer, &size ); ok( !ret, "GetColorProfileFromHandle() succeeded (%ld)\n", GetLastError() ); - ret = GetColorProfileFromHandle( handle, buffer, NULL ); + ret = pGetColorProfileFromHandle( handle, buffer, NULL ); ok( !ret, "GetColorProfileFromHandle() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ - ret = GetColorProfileFromHandle( handle, buffer, &size ); + ret = pGetColorProfileFromHandle( handle, buffer, &size ); ok( ret && size > 0, "GetColorProfileFromHandle() failed (%ld)\n", GetLastError() ); ok( !memcmp( buffer, expect, sizeof(expect) ), "Unexpected header data\n" ); @@ -304,7 +361,7 @@ HeapFree( GetProcessHeap(), 0, buffer ); } - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -321,28 +378,28 @@ profile.pProfileData = testprofile; profile.cbDataSize = strlen(testprofile); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); /* Parameter checks */ - ret = GetColorProfileHeader( NULL, NULL ); + ret = pGetColorProfileHeader( NULL, NULL ); ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() ); - ret = GetColorProfileHeader( NULL, &header ); + ret = pGetColorProfileHeader( NULL, &header ); ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() ); - ret = GetColorProfileHeader( handle, NULL ); + ret = pGetColorProfileHeader( handle, NULL ); ok( !ret, "GetColorProfileHeader() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ - ret = GetColorProfileHeader( handle, &header ); + ret = pGetColorProfileHeader( handle, &header ); ok( ret, "GetColorProfileHeader() failed (%ld)\n", GetLastError() ); ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -359,26 +416,26 @@ profile.pProfileData = standardprofile; profile.cbDataSize = strlen(standardprofile); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); /* Parameter checks */ - ret = GetCountColorProfileElements( NULL, &count ); + ret = pGetCountColorProfileElements( NULL, &count ); ok( !ret, "GetCountColorProfileElements() succeeded (%ld)\n", GetLastError() ); - ret = GetCountColorProfileElements( handle, NULL ); + ret = pGetCountColorProfileElements( handle, NULL ); ok( !ret, "GetCountColorProfileElements() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ - ret = GetCountColorProfileElements( handle, &count ); + ret = pGetCountColorProfileElements( handle, &count ); ok( ret && count == expect, "GetCountColorProfileElements() failed (%ld)\n", GetLastError() ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -391,20 +448,20 @@ /* Parameter checks */ - ret = GetStandardColorSpaceProfileA( NULL, 0, newprofile, NULL ); + ret = pGetStandardColorSpaceProfileA( NULL, 0, newprofile, NULL ); ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() ); - ret = GetStandardColorSpaceProfileA( machine, 0, newprofile, &size ); + ret = pGetStandardColorSpaceProfileA( machine, 0, newprofile, &size ); ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() ); size = 0; - ret = GetStandardColorSpaceProfileA( NULL, 0, NULL, &size ); + ret = pGetStandardColorSpaceProfileA( NULL, 0, NULL, &size ); ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() ); size = sizeof(newprofile); - ret = GetStandardColorSpaceProfileA( NULL, 0, newprofile, &size ); + ret = pGetStandardColorSpaceProfileA( NULL, 0, newprofile, &size ); ok( !ret, "GetStandardColorSpaceProfileA() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ @@ -413,20 +470,20 @@ { size = sizeof(oldprofile); - ret = GetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile, &size ); + ret = pGetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile, &size ); ok( ret, "GetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() ); - ret = SetStandardColorSpaceProfileA( NULL, SPACE_RGB, standardprofile ); + ret = pSetStandardColorSpaceProfileA( NULL, SPACE_RGB, standardprofile ); ok( ret, "SetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() ); size = sizeof(newprofile); - ret = GetStandardColorSpaceProfileA( NULL, SPACE_RGB, newprofile, &size ); + ret = pGetStandardColorSpaceProfileA( NULL, SPACE_RGB, newprofile, &size ); ok( ret, "GetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() ); ok( !lstrcmpiA( (LPSTR)&newprofile, standardprofile ), "Unexpected profile\n" ); - ret = SetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile ); + ret = pSetStandardColorSpaceProfileA( NULL, SPACE_RGB, oldprofile ); ok( ret, "SetStandardColorSpaceProfileA() failed (%ld)\n", GetLastError() ); } } @@ -440,20 +497,20 @@ /* Parameter checks */ - ret = GetStandardColorSpaceProfileW( NULL, 0, newprofile, NULL ); + ret = pGetStandardColorSpaceProfileW( NULL, 0, newprofile, NULL ); ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() ); - ret = GetStandardColorSpaceProfileW( machineW, 0, newprofile, &size ); + ret = pGetStandardColorSpaceProfileW( machineW, 0, newprofile, &size ); ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() ); size = 0; - ret = GetStandardColorSpaceProfileW( NULL, 0, NULL, &size ); + ret = pGetStandardColorSpaceProfileW( NULL, 0, NULL, &size ); ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() ); size = sizeof(newprofile); - ret = GetStandardColorSpaceProfileW( NULL, 0, newprofile, &size ); + ret = pGetStandardColorSpaceProfileW( NULL, 0, newprofile, &size ); ok( !ret, "GetStandardColorSpaceProfileW() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ @@ -462,20 +519,20 @@ { size = sizeof(oldprofile); - ret = GetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile, &size ); + ret = pGetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile, &size ); ok( ret, "GetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() ); - ret = SetStandardColorSpaceProfileW( NULL, SPACE_RGB, standardprofileW ); + ret = pSetStandardColorSpaceProfileW( NULL, SPACE_RGB, standardprofileW ); ok( ret, "SetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() ); size = sizeof(newprofile); - ret = GetStandardColorSpaceProfileW( NULL, SPACE_RGB, newprofile, &size ); + ret = pGetStandardColorSpaceProfileW( NULL, SPACE_RGB, newprofile, &size ); ok( ret, "GetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() ); ok( !lstrcmpiW( (LPWSTR)&newprofile, standardprofileW ), "Unexpected profile\n" ); - ret = SetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile ); + ret = pSetStandardColorSpaceProfileW( NULL, SPACE_RGB, oldprofile ); ok( ret, "SetStandardColorSpaceProfileW() failed (%ld)\n", GetLastError() ); } } @@ -486,18 +543,18 @@ /* Parameter checks */ - ret = InstallColorProfileA( NULL, NULL ); + ret = pInstallColorProfileA( NULL, NULL ); ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() ); - ret = InstallColorProfileA( machine, NULL ); + ret = pInstallColorProfileA( machine, NULL ); ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() ); - ret = InstallColorProfileA( NULL, machine ); + ret = pInstallColorProfileA( NULL, machine ); ok( !ret, "InstallColorProfileA() succeeded (%ld)\n", GetLastError() ); if (standardprofile) { - ret = InstallColorProfileA( NULL, standardprofile ); + ret = pInstallColorProfileA( NULL, standardprofile ); ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() ); } @@ -510,23 +567,23 @@ CHAR slash[] = "\\"; HANDLE handle; - ret = InstallColorProfileA( NULL, testprofile ); + ret = pInstallColorProfileA( NULL, testprofile ); ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() ); - ret = GetColorDirectoryA( NULL, dest, &size ); + ret = pGetColorDirectoryA( NULL, dest, &size ); ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() ); MSCMS_basenameA( testprofile, base ); - strcat( dest, slash ); - strcat( dest, base ); + lstrcatA( dest, slash ); + lstrcatA( dest, base ); /* Check if the profile is really there */ handle = CreateFileA( dest, 0 , 0, NULL, OPEN_EXISTING, 0, NULL ); ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() ); CloseHandle( handle ); - ret = UninstallColorProfileA( NULL, dest, TRUE ); + ret = pUninstallColorProfileA( NULL, dest, TRUE ); ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() ); } } @@ -537,18 +594,18 @@ /* Parameter checks */ - ret = InstallColorProfileW( NULL, NULL ); + ret = pInstallColorProfileW( NULL, NULL ); ok( !ret, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() ); - ret = InstallColorProfileW( machineW, NULL ); + ret = pInstallColorProfileW( machineW, NULL ); ok( !ret, "InstallColorProfileW() succeeded (%ld)\n", GetLastError() ); - ret = InstallColorProfileW( NULL, machineW ); + ret = pInstallColorProfileW( NULL, machineW ); ok( !ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() ); if (standardprofileW) { - ret = InstallColorProfileW( NULL, standardprofileW ); + ret = pInstallColorProfileW( NULL, standardprofileW ); ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() ); } @@ -561,10 +618,10 @@ WCHAR slash[] = { '\\', 0 }; HANDLE handle; - ret = InstallColorProfileW( NULL, testprofileW ); + ret = pInstallColorProfileW( NULL, testprofileW ); ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() ); - ret = GetColorDirectoryW( NULL, dest, &size ); + ret = pGetColorDirectoryW( NULL, dest, &size ); ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() ); MSCMS_basenameW( testprofileW, base ); @@ -577,7 +634,7 @@ ok( handle != INVALID_HANDLE_VALUE, "Couldn't find the profile (%ld)\n", GetLastError() ); CloseHandle( handle ); - ret = UninstallColorProfileW( NULL, dest, TRUE ); + ret = pUninstallColorProfileW( NULL, dest, TRUE ); ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() ); } } @@ -595,30 +652,30 @@ profile.pProfileData = standardprofile; profile.cbDataSize = strlen(standardprofile); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); /* Parameter checks */ tag = 0; - ret = IsColorProfileTagPresent( handle, tag, &present ); + ret = pIsColorProfileTagPresent( handle, tag, &present ); ok( !(ret && present), "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() ); tag = 0x63707274; /* 'cprt' */ - ret = IsColorProfileTagPresent( NULL, tag, &present ); + ret = pIsColorProfileTagPresent( NULL, tag, &present ); ok( !ret, "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() ); - ret = IsColorProfileTagPresent( handle, tag, NULL ); + ret = pIsColorProfileTagPresent( handle, tag, NULL ); ok( !ret, "IsColorProfileTagPresent() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ - ret = IsColorProfileTagPresent( handle, tag, &present ); + ret = pIsColorProfileTagPresent( handle, tag, &present ); ok( ret && present, "IsColorProfileTagPresent() failed (%ld)\n", GetLastError() ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -634,40 +691,40 @@ /* Parameter checks */ - handle = OpenColorProfileA( NULL, 0, 0, 0 ); + handle = pOpenColorProfileA( NULL, 0, 0, 0 ); ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileA( &profile, 0, 0, 0 ); + handle = pOpenColorProfileA( &profile, 0, 0, 0 ); ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, 0 ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 ); ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileA( &profile, PROFILE_READWRITE, 0, 0 ); + handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, 0 ); ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - ok ( !CloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" ); + ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" ); if (standardprofile) { profile.pProfileData = standardprofile; profile.cbDataSize = strlen(standardprofile); - handle = OpenColorProfileA( &profile, 0, 0, 0 ); + handle = pOpenColorProfileA( &profile, 0, 0, 0 ); ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, 0 ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, 0 ); ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileA( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 ); + handle = pOpenColorProfileA( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 ); ok( handle == NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); /* Functional checks */ - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - ret = CloseColorProfile( handle ); + ret = pCloseColorProfile( handle ); ok( ret, "CloseColorProfile() failed (%ld)\n", GetLastError() ); } } @@ -684,40 +741,40 @@ /* Parameter checks */ - handle = OpenColorProfileW( NULL, 0, 0, 0 ); + handle = pOpenColorProfileW( NULL, 0, 0, 0 ); ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileW( &profile, 0, 0, 0 ); + handle = pOpenColorProfileW( &profile, 0, 0, 0 ); ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileW( &profile, PROFILE_READ, 0, 0 ); + handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 ); ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileW( &profile, PROFILE_READWRITE, 0, 0 ); + handle = pOpenColorProfileW( &profile, PROFILE_READWRITE, 0, 0 ); ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); - ok ( !CloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" ); + ok ( !pCloseColorProfile( NULL ), "CloseColorProfile() succeeded\n" ); if (standardprofileW) { profile.pProfileData = standardprofileW; profile.cbDataSize = lstrlenW(standardprofileW) * sizeof(WCHAR); - handle = OpenColorProfileW( &profile, 0, 0, 0 ); + handle = pOpenColorProfileW( &profile, 0, 0, 0 ); ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileW( &profile, PROFILE_READ, 0, 0 ); + handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, 0 ); ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); - handle = OpenColorProfileW( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 ); + handle = pOpenColorProfileW( &profile, PROFILE_READ|PROFILE_READWRITE, 0, 0 ); ok( handle == NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); /* Functional checks */ - handle = OpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileW( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileW() failed (%ld)\n", GetLastError() ); - ret = CloseColorProfile( handle ); + ret = pCloseColorProfile( handle ); ok( ret, "CloseColorProfile() failed (%ld)\n", GetLastError() ); } } @@ -741,42 +798,46 @@ /* Parameter checks */ - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - ret = SetColorProfileElement( handle, tag, 0, &size, data ); + ret = pSetColorProfileElement( handle, tag, 0, &size, data ); ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); - handle = OpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - ret = SetColorProfileElement( NULL, 0, 0, NULL, NULL ); + ret = pSetColorProfileElement( NULL, 0, 0, NULL, NULL ); ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() ); - ret = SetColorProfileElement( handle, 0, 0, NULL, NULL ); + ret = pSetColorProfileElement( handle, 0, 0, NULL, NULL ); ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() ); - ret = SetColorProfileElement( handle, tag, 0, NULL, NULL ); + ret = pSetColorProfileElement( handle, tag, 0, NULL, NULL ); ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() ); - ret = SetColorProfileElement( handle, tag, 0, &size, NULL ); + ret = pSetColorProfileElement( handle, tag, 0, &size, NULL ); ok( !ret, "SetColorProfileElement() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ - ret = SetColorProfileElement( handle, tag, 0, &size, data ); + size = sizeof(data); + + ret = pSetColorProfileElement( handle, tag, 0, &size, data ); ok( ret, "SetColorProfileElement() failed (%ld)\n", GetLastError() ); size = sizeof(buffer); - ret = GetColorProfileElement( handle, tag, 0, &size, buffer, &ref ); + ret = pGetColorProfileElement( handle, tag, 0, &size, buffer, &ref ); ok( ret && size > 0, "GetColorProfileElement() failed (%ld)\n", GetLastError() ); - ok( !memcmp( data, buffer, sizeof(data) ), "Unexpected tag data\n" ); + ok( !memcmp( data, buffer, sizeof(data) ), + "Unexpected tag data, expected %s, got %s (%ld)\n", + data, buffer, GetLastError() ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -817,37 +878,37 @@ /* Parameter checks */ - handle = OpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READ, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - ret = SetColorProfileHeader( handle, &header ); + ret = pSetColorProfileHeader( handle, &header ); ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); - handle = OpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING ); + handle = pOpenColorProfileA( &profile, PROFILE_READWRITE, 0, OPEN_EXISTING ); ok( handle != NULL, "OpenColorProfileA() failed (%ld)\n", GetLastError() ); - ret = SetColorProfileHeader( NULL, NULL ); + ret = pSetColorProfileHeader( NULL, NULL ); ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() ); - ret = SetColorProfileHeader( handle, NULL ); + ret = pSetColorProfileHeader( handle, NULL ); ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() ); - ret = SetColorProfileHeader( NULL, &header ); + ret = pSetColorProfileHeader( NULL, &header ); ok( !ret, "SetColorProfileHeader() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ - ret = SetColorProfileHeader( handle, &header ); + ret = pSetColorProfileHeader( handle, &header ); ok( ret, "SetColorProfileHeader() failed (%ld)\n", GetLastError() ); - ret = GetColorProfileHeader( handle, &header ); + ret = pGetColorProfileHeader( handle, &header ); ok( ret, "GetColorProfileHeader() failed (%ld)\n", GetLastError() ); ok( !memcmp( &header, rgbheader, sizeof(rgbheader) ), "Unexpected header data\n" ); - CloseColorProfile( handle ); + pCloseColorProfile( handle ); } } @@ -857,10 +918,10 @@ /* Parameter checks */ - ret = UninstallColorProfileA( NULL, NULL, FALSE ); + ret = pUninstallColorProfileA( NULL, NULL, FALSE ); ok( !ret, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() ); - ret = UninstallColorProfileA( machine, NULL, FALSE ); + ret = pUninstallColorProfileA( machine, NULL, FALSE ); ok( !ret, "UninstallColorProfileA() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ @@ -872,18 +933,18 @@ CHAR slash[] = "\\"; HANDLE handle; - ret = InstallColorProfileA( NULL, testprofile ); + ret = pInstallColorProfileA( NULL, testprofile ); ok( ret, "InstallColorProfileA() failed (%ld)\n", GetLastError() ); - ret = GetColorDirectoryA( NULL, dest, &size ); + ret = pGetColorDirectoryA( NULL, dest, &size ); ok( ret, "GetColorDirectoryA() failed (%ld)\n", GetLastError() ); MSCMS_basenameA( testprofile, base ); - strcat( dest, slash ); - strcat( dest, base ); + lstrcatA( dest, slash ); + lstrcatA( dest, base ); - ret = UninstallColorProfileA( NULL, dest, TRUE ); + ret = pUninstallColorProfileA( NULL, dest, TRUE ); ok( ret, "UninstallColorProfileA() failed (%ld)\n", GetLastError() ); /* Check if the profile is really gone */ @@ -899,10 +960,10 @@ /* Parameter checks */ - ret = UninstallColorProfileW( NULL, NULL, FALSE ); + ret = pUninstallColorProfileW( NULL, NULL, FALSE ); ok( !ret, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() ); - ret = UninstallColorProfileW( machineW, NULL, FALSE ); + ret = pUninstallColorProfileW( machineW, NULL, FALSE ); ok( !ret, "UninstallColorProfileW() succeeded (%ld)\n", GetLastError() ); /* Functional checks */ @@ -914,10 +975,10 @@ WCHAR slash[] = { '\\', 0 }; HANDLE handle; - ret = InstallColorProfileW( NULL, testprofileW ); + ret = pInstallColorProfileW( NULL, testprofileW ); ok( ret, "InstallColorProfileW() failed (%ld)\n", GetLastError() ); - ret = GetColorDirectoryW( NULL, dest, &size ); + ret = pGetColorDirectoryW( NULL, dest, &size ); ok( ret, "GetColorDirectoryW() failed (%ld)\n", GetLastError() ); MSCMS_basenameW( testprofileW, base ); @@ -925,7 +986,7 @@ lstrcatW( dest, slash ); lstrcatW( dest, base ); - ret = UninstallColorProfileW( NULL, dest, TRUE ); + ret = pUninstallColorProfileW( NULL, dest, TRUE ); ok( ret, "UninstallColorProfileW() failed (%ld)\n", GetLastError() ); /* Check if the profile is really gone */ @@ -940,36 +1001,43 @@ UINT len; HANDLE handle; char path[MAX_PATH], file[MAX_PATH]; - char profile1[MAX_PATH], profile2[MAX_PATH]; - WCHAR profile1W[MAX_PATH], profile2W[MAX_PATH]; + char profilefile1[MAX_PATH], profilefile2[MAX_PATH]; + WCHAR profilefile1W[MAX_PATH], profilefile2W[MAX_PATH]; WCHAR fileW[MAX_PATH]; + hmscms = LoadLibraryA( "mscms.dll" ); + if (!hmscms) return; + + if (!init_function_ptrs()) + { + FreeLibrary( hmscms ); + return; + } + /* See if we can find the standard color profile */ - GetSystemDirectoryA( profile1, sizeof(profile1) ); - GetSystemDirectoryW( profile1W, sizeof(profile1W) / sizeof(WCHAR) ); - strcat( profile1, profilefile ); - lstrcatW( profile1W, profilefileW ); - handle = CreateFileA( profile1, 0 , 0, NULL, OPEN_EXISTING, 0, NULL ); + GetSystemDirectoryA( profilefile1, sizeof(profilefile1) ); + GetSystemDirectoryW( profilefile1W, sizeof(profilefile1W) / sizeof(WCHAR) ); + lstrcatA( profilefile1, profile1 ); + lstrcatW( profilefile1W, profile1W ); + handle = CreateFileA( profilefile1, 0 , 0, NULL, OPEN_EXISTING, 0, NULL ); if (handle != INVALID_HANDLE_VALUE) { - standardprofile = profile1; - standardprofileW = profile1W; + standardprofile = profilefile1; + standardprofileW = profilefile1W; CloseHandle( handle ); } - GetWindowsDirectoryA( profile2, sizeof(profile2) ); - GetWindowsDirectoryW( profile2W, sizeof(profile2W) / sizeof(WCHAR) ); - strcat( profile2, profilesubdir ); - lstrcatW( profile2W, profilesubdirW ); - strcat( profile2, profilefile ); - lstrcatW( profile2W, profilefileW ); - handle = CreateFileA( profile2, 0 , 0, NULL, OPEN_EXISTING, 0, NULL ); + GetSystemDirectoryA( profilefile2, sizeof(profilefile2) ); + GetSystemDirectoryW( profilefile2W, sizeof(profilefile2W) / sizeof(WCHAR) ); + lstrcatA( profilefile2, profile2 ); + lstrcatW( profilefile2W, profile2W ); + handle = CreateFileA( profilefile2, 0 , 0, NULL, OPEN_EXISTING, 0, NULL ); if (handle != INVALID_HANDLE_VALUE) { - standardprofile = profile2; - standardprofileW = profile2W; + standardprofile = profilefile2; + standardprofileW = profilefile2W; CloseHandle( handle ); } @@ -1021,4 +1089,6 @@ /* Clean up */ if (testprofile) DeleteFileA( testprofile ); + + FreeLibrary( hmscms ); } diff -urN wine-20050628/dlls/mscms/transform.c wine-20050725/dlls/mscms/transform.c --- wine-20050628/dlls/mscms/transform.c 2005-03-08 20:00:14.000000000 +0100 +++ wine-20050725/dlls/mscms/transform.c 2005-07-18 17:10:36.000000000 +0200 @@ -30,9 +30,7 @@ #include "winuser.h" #include "icm.h" -#define LCMS_API_FUNCTION(f) extern typeof(f) * p##f; -#include "lcms_api.h" -#undef LCMS_API_FUNCTION +#include "mscms_priv.h" WINE_DEFAULT_DEBUG_CHANNEL(mscms); @@ -59,7 +57,7 @@ HPROFILE target, DWORD flags ) { HTRANSFORM ret = NULL; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS cmsHTRANSFORM cmstransform; cmsHPROFILE cmsprofiles[3]; int intent; @@ -86,7 +84,7 @@ } ret = MSCMS_create_htransform_handle( cmstransform ); -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -94,7 +92,7 @@ PDWORD intents, DWORD nintents, DWORD flags, DWORD cmm ) { HTRANSFORM ret = NULL; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS cmsHPROFILE *cmsprofiles; cmsHTRANSFORM cmstransform; DWORD i; @@ -117,14 +115,14 @@ HeapFree( GetProcessHeap(), 0, cmsprofiles ); ret = MSCMS_create_htransform_handle( cmstransform ); -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } BOOL WINAPI DeleteColorTransform( HTRANSFORM transform ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS cmsHTRANSFORM cmstransform; TRACE( "( %p )\n", transform ); @@ -135,7 +133,7 @@ MSCMS_destroy_htransform_handle( transform ); ret = TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } @@ -144,7 +142,7 @@ DWORD outputstride, PBMCALLBACKFN callback, ULONG data ) { BOOL ret = FALSE; -#ifdef HAVE_LCMS_H +#ifdef HAVE_LCMS cmsHTRANSFORM cmstransform; TRACE( "( %p, %p, 0x%08x, 0x%08lx, 0x%08lx, 0x%08lx, %p, 0x%08x, 0x%08lx, %p, 0x%08lx )\n", @@ -156,6 +154,6 @@ cmsDoTransform( cmstransform, srcbits, destbits, width * height ); ret = TRUE; -#endif /* HAVE_LCMS_H */ +#endif /* HAVE_LCMS */ return ret; } diff -urN wine-20050628/dlls/msdmo/dmoreg.c wine-20050725/dlls/msdmo/dmoreg.c --- wine-20050628/dlls/msdmo/dmoreg.c 2005-06-02 21:43:47.000000000 +0200 +++ wine-20050725/dlls/msdmo/dmoreg.c 2005-07-12 21:21:37.000000000 +0200 @@ -80,7 +80,7 @@ typedef struct { const IEnumDMOVtbl *lpVtbl; - DWORD ref; + LONG ref; DWORD index; const GUID* guidCategory; DWORD dwFlags; diff -urN wine-20050628/dlls/mshtml/Makefile.in wine-20050725/dlls/mshtml/Makefile.in --- wine-20050628/dlls/mshtml/Makefile.in 2005-06-28 12:53:42.000000000 +0200 +++ wine-20050725/dlls/mshtml/Makefile.in 2005-07-18 11:13:32.000000000 +0200 @@ -4,7 +4,7 @@ VPATH = @srcdir@ MODULE = mshtml.dll IMPORTLIB = libmshtml.$(IMPLIBEXT) -IMPORTS = user32 gdi32 advapi32 kernel32 ntdll +IMPORTS = ole32 user32 gdi32 advapi32 kernel32 ntdll EXTRALIBS = $(LIBUNICODE) -lstrmiids -luuid EXTRADEFS = -DCOM_NO_WINDOWS_H @@ -15,6 +15,7 @@ olewnd.c \ persist.c \ protocol.c \ + service.c \ view.c RC_SRCS = rsrc.rc diff -urN wine-20050628/dlls/mshtml/htmldoc.c wine-20050725/dlls/mshtml/htmldoc.c --- wine-20050628/dlls/mshtml/htmldoc.c 2005-06-28 12:53:42.000000000 +0200 +++ wine-20050725/dlls/mshtml/htmldoc.c 2005-07-14 12:14:33.000000000 +0200 @@ -30,7 +30,7 @@ #include "docobj.h" #include "mshtml.h" -#include "mshtmdid.h" +#include "mshtmhst.h" #include "wine/debug.h" @@ -94,6 +94,12 @@ }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) { TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject); *ppvObject = INPLACEWIN(This); + }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { + TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject); + *ppvObject = SERVPROV(This); + }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) { + TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject); + *ppvObject = CMDTARGET(This); } if(*ppvObject) { @@ -122,11 +128,13 @@ if(!ref) { if(This->client) - IOleClientSite_Release(This->client); + IOleObject_SetClientSite(OLEOBJ(This), NULL); + if(This->in_place_active) + IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This)); if(This->ipsite) - IOleInPlaceSite_Release(This->ipsite); - if(This->frame) - IOleInPlaceFrame_Release(This->frame); + IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL); + if(This->hwnd) + DestroyWindow(This->hwnd); HeapFree(GetProcessHeap(), 0, This); } @@ -969,6 +977,7 @@ HTMLDocument_OleObj_Init(ret); HTMLDocument_View_Init(ret); HTMLDocument_Window_Init(ret); + HTMLDocument_Service_Init(ret); return hres; } diff -urN wine-20050628/dlls/mshtml/main.c wine-20050725/dlls/mshtml/main.c --- wine-20050628/dlls/mshtml/main.c 2005-06-27 11:50:56.000000000 +0200 +++ wine-20050725/dlls/mshtml/main.c 2005-07-14 14:18:30.000000000 +0200 @@ -37,6 +37,7 @@ #include "advpub.h" #include "mshtml.h" +#include "mshtmhst.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -108,7 +109,7 @@ if(!hMozCtl) ERR("Can't load the Mozilla ActiveX control\n"); }else { - TRACE("Not found Mozilla ActiveX Control. HTML rendering will be disabled."); + TRACE("Not found Mozilla ActiveX Control. HTML rendering will be disabled.\n"); } hInst = hInstDLL; break; @@ -126,7 +127,7 @@ typedef HRESULT (*CreateInstanceFunc)(IUnknown*,REFIID,void**); typedef struct { const IClassFactoryVtbl *lpVtbl; - ULONG ref; + LONG ref; CreateInstanceFunc fnCreateInstance; } ClassFactory; @@ -266,8 +267,8 @@ * * Appears to have the same prototype as WinMain. */ -INT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst, - LPCSTR szCmdLine, INT nCmdShow ) +HRESULT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst, + LPSTR szCmdLine, INT nCmdShow ) { FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow ); return 0; @@ -311,9 +312,11 @@ DEFINE_GUID(CLSID_Scriptlet, 0xAE24FDAE, 0x03C6, 0x11D1, 0x8B,0x76, 0x00,0x80,0xC7,0x44,0xF3,0x89); DEFINE_GUID(CLSID_TridentAPI, 0x429AF92C, 0xA51F, 0x11D2, 0x86,0x1E, 0x00,0xC0,0x4F,0xA3,0x5C,0x89); -#define INF_SET_CLSID(clsid) \ - pse[i].pszName = "CLSID_" #clsid; \ - clsids[i++] = &CLSID_ ## clsid; +#define INF_SET_ID(id) \ + pse[i].pszName = #id; \ + clsids[i++] = &id; + +#define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid) static HRESULT register_server(BOOL do_register) { @@ -321,8 +324,8 @@ HMODULE hAdvpack; typeof(RegInstall) *pRegInstall; STRTABLE strtable; - STRENTRY pse[34]; - static CLSID const *clsids[34]; + STRENTRY pse[35]; + static CLSID const *clsids[35]; int i = 0; static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0}; @@ -363,6 +366,7 @@ INF_SET_CLSID(Scriptlet); INF_SET_CLSID(SysimageProtocol); INF_SET_CLSID(TridentAPI); + INF_SET_ID(LIBID_MSHTML); for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++) { pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39); diff -urN wine-20050628/dlls/mshtml/mshtml.inf wine-20050725/dlls/mshtml/mshtml.inf --- wine-20050628/dlls/mshtml/mshtml.inf 2005-06-25 19:58:35.000000000 +0200 +++ wine-20050725/dlls/mshtml/mshtml.inf 2005-07-14 14:18:30.000000000 +0200 @@ -1,21 +1,3 @@ -;; -;; Copyright (C) 2004 Jacek Caban -;; -;; This library is free software; you can redistribute it and/or -;; modify it under the terms of the GNU Lesser General Public -;; License as published by the Free Software Foundation; either -;; version 2.1 of the License, or (at your option) any later version. -;; -;; This library is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; Lesser General Public License for more details. -;; -;; You should have received a copy of the GNU Lesser General Public -;; License along with this library; if not, write to the Free Software -;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -;; - [version] Signature="$CHICAGO$" @@ -255,7 +237,7 @@ HKCR,"CLSID\%CLSID_Scriptlet%\ProgID",,,"ScriptBridge.ScriptBridge.1" HKCR,"CLSID\%CLSID_Scriptlet%\Programmable" ;; HKCR,"CLSID\%CLSID_Scriptlet%\ToolboxBitmap32",,,"%IEXPLORE%,1" -HKCR,"CLSID\%CLSID_Scriptlet%\TypeLib",,,"{3050f1c5-98b5-11cf-bb82-00aa00bdce0b}" +HKCR,"CLSID\%CLSID_Scriptlet%\TypeLib",,,"%LIBID_MSHTML%" HKCR,"CLSID\%CLSID_Scriptlet%\Version",,,"4.0" HKCR,"CLSID\%CLSID_Scriptlet%\VersionIndependentProgID",,,"ScriptBridge.ScriptBridge" HKCR,"MIME\Database\Content Type\text/x-scriptlet","CLSID",,"%CLSID_Scriptlet%" @@ -332,7 +314,7 @@ HKCR,"InternetShortcut\shell\printto\command",,0x00020000,"rundll32.exe mshtml.dll,PrintHTML ""%%1"" ""%%2"" ""%%3"" ""%%4""" HKCR,"htmlfile\shell\print\command",,0x00020000,"rundll32.exe mshtml.dll,PrintHTML ""%%1""" HKCR,"htmlfile\shell\printto\command",,0x00020000,"rundll32.exe mshtml.dll,PrintHTML ""%%1"" ""%%2"" ""%%3"" ""%%4""" -hkCR,"htmlfile",,,"HTML Document" +HKCR,"htmlfile",,,"HTML Document" HKCR,"htmlfile\BrowseInPlace",,,"" HKCR,"htmlfile\CLSID",,,"%CLSID_HTMLDocument%" ;; HKCR,"htmlfile\DefaultIcon",,0x00020000,"%IEXPLORE%,1" @@ -421,7 +403,7 @@ HKCR,"pngfile\shell\open\ddeexec\Topic",,,"WWW_OpenURL" ;; HKCR,"pngfile\DefaultIcon",,,"%IEXPLORE%,9" -;; TXR +;; TXT HKCR,"MIME\Database\Content Type\text/plain","CLSID",,"%CLSID_HTMLDocument%" HKCR,"MIME\Database\Content Type\text/plain","Extension",,".txt" HKCR,"MIME\Database\Content Type\text/plain","Encoding",1,07,00,00,00 diff -urN wine-20050628/dlls/mshtml/mshtml_private.h wine-20050725/dlls/mshtml/mshtml_private.h --- wine-20050628/dlls/mshtml/mshtml_private.h 2005-06-28 12:53:42.000000000 +0200 +++ wine-20050725/dlls/mshtml/mshtml_private.h 2005-07-18 11:13:32.000000000 +0200 @@ -27,14 +27,21 @@ const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl; const IViewObject2Vtbl *lpViewObject2Vtbl; const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl; + const IServiceProviderVtbl *lpServiceProviderVtbl; + const IOleCommandTargetVtbl *lpOleCommandTargetVtbl; - ULONG ref; + LONG ref; IOleClientSite *client; + IDocHostUIHandler *hostui; IOleInPlaceSite *ipsite; IOleInPlaceFrame *frame; HWND hwnd; + + BOOL in_place_active; + BOOL ui_active; + BOOL has_key_path; } HTMLDocument; #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl) @@ -51,8 +58,10 @@ #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl) #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl) #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl) +#define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl) +#define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl) -#define DEFINE_THIS(cls,ifc) cls* const This=(cls*)((char*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)); +#define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl))) HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**); @@ -60,6 +69,7 @@ void HTMLDocument_OleObj_Init(HTMLDocument*); void HTMLDocument_View_Init(HTMLDocument*); void HTMLDocument_Window_Init(HTMLDocument*); +void HTMLDocument_Service_Init(HTMLDocument*); HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**); diff -urN wine-20050628/dlls/mshtml/oleobj.c wine-20050725/dlls/mshtml/oleobj.c --- wine-20050628/dlls/mshtml/oleobj.c 2005-06-28 12:53:42.000000000 +0200 +++ wine-20050725/dlls/mshtml/oleobj.c 2005-07-18 11:13:32.000000000 +0200 @@ -30,6 +30,7 @@ #include "docobj.h" #include "mshtml.h" +#include "mshtmhst.h" #include "wine/debug.h" @@ -41,44 +42,111 @@ * IOleObject implementation */ -#define OLEOBJ_THIS \ - HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleObjectVtbl)); +#define OLEOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleObject, iface) static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppvObject) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); } static ULONG WINAPI OleObject_AddRef(IOleObject *iface) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); return IHTMLDocument2_AddRef(HTMLDOC(This)); } static ULONG WINAPI OleObject_Release(IOleObject *iface) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); return IHTMLDocument2_Release(HTMLDOC(This)); } static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); + IDocHostUIHandler *pDocHostUIHandler = NULL; + HRESULT hres; + TRACE("(%p)->(%p)\n", This, pClientSite); if(This->client) IOleClientSite_Release(This->client); - if(pClientSite) - IOleClientSite_AddRef(pClientSite); + + if(This->hostui) + IDocHostUIHandler_Release(This->hostui); + + if(!pClientSite) { + This->client = NULL; + return S_OK; + } + + hres = IOleObject_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&pDocHostUIHandler); + if(SUCCEEDED(hres)) { + DOCHOSTUIINFO hostinfo; + LPOLESTR key_path = NULL, override_key_path = NULL; + IDocHostUIHandler2 *pDocHostUIHandler2; + + memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO)); + hostinfo.cbSize = sizeof(DOCHOSTUIINFO); + hres = IDocHostUIHandler_GetHostInfo(pDocHostUIHandler, &hostinfo); + if(SUCCEEDED(hres)) + /* FIXME: use hostinfo */ + TRACE("hostinfo = {%lu %08lx %08lx %s %s}\n", + hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick, + debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS)); + + if(!This->has_key_path) { + hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0); + if(hres == S_OK && key_path) { + if(key_path[0]) { + /* FIXME: use key_path */ + TRACE("key_path = %s\n", debugstr_w(key_path)); + } + CoTaskMemFree(key_path); + } + + hres = IDocHostUIHandler_QueryInterface(pDocHostUIHandler, &IID_IDocHostUIHandler2, + (void**)&pDocHostUIHandler2); + if(SUCCEEDED(hres)) { + hres = IDocHostUIHandler2_GetOverrideKeyPath(pDocHostUIHandler2, &override_key_path, 0); + if(hres == S_OK && override_key_path && override_key_path[0]) { + if(override_key_path[0]) { + /*FIXME: use override_key_path */ + TRACE("override_key_path = %s\n", debugstr_w(override_key_path)); + } + CoTaskMemFree(override_key_path); + } + } + + This->has_key_path = TRUE; + } + } + + /* Native calls here GetWindow. What is it for? + * We don't have anything to do with it here (yet). */ + if(pClientSite) { + IOleWindow *pOleWindow = NULL; + HWND hwnd; + + hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleWindow, (void**)&pOleWindow); + if(SUCCEEDED(hres)) { + IOleWindow_GetWindow(pOleWindow, &hwnd); + IOleWindow_Release(pOleWindow); + } + } + + IOleClientSite_AddRef(pClientSite); This->client = pClientSite; + This->hostui = pDocHostUIHandler; return S_OK; } static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); + TRACE("(%p)->(%p)\n", This, ppClientSite); if(!ppClientSite) @@ -93,28 +161,40 @@ static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj)); return E_NOTIMPL; } static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); + HRESULT hres; + FIXME("(%p)->(%08lx)\n", This, dwSaveOption); - return E_NOTIMPL; + + if(This->client) { + IOleContainer *container; + hres = IOleClientSite_GetContainer(This->client, &container); + if(SUCCEEDED(hres)) { + IOleContainer_LockContainer(container, FALSE); + IOleContainer_Release(container); + } + } + + return S_OK; } static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p %ld %p)->()\n", This, dwWhichMoniker, pmk); return E_NOTIMPL; } static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk); return E_NOTIMPL; } @@ -122,14 +202,14 @@ static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%p %x %ld)\n", This, pDataObject, fCreation, dwReserved); return E_NOTIMPL; } static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%ld %p)\n", This, dwReserved, ppDataObject); return E_NOTIMPL; } @@ -137,7 +217,7 @@ static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex, HWND hwndParent, LPCRECT lprcPosRect) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); IOleDocumentSite *pDocSite; HRESULT hres; @@ -157,10 +237,10 @@ hres = IOleClientSite_GetContainer(pActiveSite, &pContainer); if(SUCCEEDED(hres)) { IOleContainer_LockContainer(pContainer, TRUE); - /* FIXME: Create new IOleDocumentView. See CreateView for more info. */ - hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This)); IOleContainer_Release(pContainer); } + /* FIXME: Create new IOleDocumentView. See CreateView for more info. */ + hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This)); IOleDocumentSite_Release(pDocSite); }else { hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE); @@ -179,28 +259,29 @@ static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%p)\n", This, ppEnumOleVerb); return E_NOTIMPL; } static HRESULT WINAPI OleObject_Update(IOleObject *iface) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)\n", This); return E_NOTIMPL; } static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); + TRACE("(%p)->(%p)\n", This, pClsid); if(!pClsid) @@ -212,60 +293,62 @@ static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%ld %p)\n", This, dwFormOfType, pszUserType); return E_NOTIMPL; } static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel); return E_NOTIMPL; } static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel); return E_NOTIMPL; } static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection); return E_NOTIMPL; } static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%ld)\n", This, dwConnection); return E_NOTIMPL; } static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%p)\n", This, ppenumAdvise); return E_NOTIMPL; } static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%ld %p)\n", This, dwAspect, pdwStatus); return E_NOTIMPL; } static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal) { - OLEOBJ_THIS + HTMLDocument *This = OLEOBJ_THIS(iface); FIXME("(%p)->(%p)\n", This, pLogpal); return E_NOTIMPL; } +#undef OLEPBJ_THIS + static const IOleObjectVtbl OleObjectVtbl = { OleObject_QueryInterface, OleObject_AddRef, @@ -297,31 +380,30 @@ * IOleDocument implementation */ -#define OLEDOC_THIS \ - HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleDocumentVtbl)); +#define OLEDOC_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocument, iface) static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppvObject) { - OLEDOC_THIS + HTMLDocument *This = OLEDOC_THIS(iface); return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject); } static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface) { - OLEDOC_THIS + HTMLDocument *This = OLEDOC_THIS(iface); return IHTMLDocument2_AddRef(HTMLDOC(This)); } static ULONG WINAPI OleDocument_Release(IOleDocument *iface) { - OLEDOC_THIS + HTMLDocument *This = OLEDOC_THIS(iface); return IHTMLDocument2_Release(HTMLDOC(This)); } static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm, DWORD dwReserved, IOleDocumentView **ppView) { - OLEDOC_THIS + HTMLDocument *This = OLEDOC_THIS(iface); HRESULT hres; TRACE("(%p)->(%p %p %ld %p)\n", This, pIPSite, pstm, dwReserved, ppView); @@ -352,7 +434,7 @@ static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus) { - OLEDOC_THIS + HTMLDocument *This = OLEDOC_THIS(iface); FIXME("(%p)->(%p)\n", This, pdwStatus); return E_NOTIMPL; } @@ -360,11 +442,13 @@ static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum, IOleDocumentView **ppView) { - OLEDOC_THIS + HTMLDocument *This = OLEDOC_THIS(iface); FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView); return E_NOTIMPL; } +#undef OLEDOC_THIS + static const IOleDocumentVtbl OleDocumentVtbl = { OleDocument_QueryInterface, OleDocument_AddRef, @@ -374,10 +458,63 @@ OleDocument_EnumViews }; +/********************************************************** + * IOleCommandTarget implementation + */ + +#define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface) + +static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv) +{ + HTMLDocument *This = CMDTARGET_THIS(iface); + return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv); +} + +static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface) +{ + HTMLDocument *This = CMDTARGET_THIS(iface); + return IHTMLDocument2_AddRef(HTMLDOC(This)); +} + +static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface) +{ +