From af16e43eeeea6365ec8f5cf8c47451cfdf1a7e90 Mon Sep 17 00:00:00 2001 From: Jan Zerebecki Date: Sat, 1 Dec 2007 00:07:53 +0100 Subject: [PATCH] push 0f15bbd80d260bbd8adf052e820484a405c49375 --- ANNOUNCE | 1209 ++++++++++---------- ChangeLog | 2044 ++++++++++++++++++++++++++++++++++ VERSION | 2 +- configure | 26 +- configure.ac | 1 + dlls/advapi32/Makefile.in | 1 + dlls/advapi32/advapi32.spec | 2 +- dlls/advapi32/cred.c | 772 +++++++++++-- dlls/advapi32/registry.c | 2 +- dlls/advapi32/security.c | 15 + dlls/comctl32/commctrl.c | 2 +- dlls/comctl32/theme_combo.c | 2 +- dlls/comdlg32/filedlgbrowser.c | 4 +- dlls/credui/tests/credui.c | 3 +- dlls/crypt32/cert.c | 11 + dlls/crypt32/store.c | 16 + dlls/ctapi32/ctapi32.c | 2 +- dlls/d3d9/tests/visual.c | 561 +++++++++- dlls/d3dx8/d3dx8.spec | 14 +- dlls/d3dx8/math.c | 223 ++++ dlls/d3dx8/tests/math.c | 176 ++- dlls/dinput/effect_linuxinput.c | 2 +- dlls/dinput/joystick_linuxinput.c | 25 +- dlls/dnsapi/dnsapi.h | 26 +- dlls/dnsapi/name.c | 8 +- dlls/dnsapi/query.c | 24 +- dlls/dnsapi/record.c | 40 +- dlls/gdi32/dc.c | 2 +- dlls/gdi32/font.c | 5 +- dlls/inetcomm/internettransport.c | 7 +- dlls/inetcomm/mimeole.c | 484 +++++++- dlls/inetcomm/regsvr.c | 4 +- dlls/inetcomm/tests/Makefile.in | 2 +- dlls/inetcomm/tests/mimeole.c | 66 ++ dlls/itss/chm_lib.c | 2 +- dlls/kernel32/kernel32.spec | 2 +- dlls/kernel32/local16.c | 1 + dlls/kernel32/tests/actctx.c | 2 +- dlls/kernel32/tests/virtual.c | 3 + dlls/kernel32/volume.c | 124 ++- dlls/mshtml/Makefile.in | 1 + dlls/mshtml/htmldoc.c | 2 +- dlls/mshtml/htmlelem.c | 3 + dlls/mshtml/htmlstylesheet.c | 48 +- dlls/mshtml/htmltable.c | 557 +++++++++ dlls/mshtml/mshtml_private.h | 3 +- dlls/mshtml/nsiface.idl | 33 +- dlls/mshtml/txtrange.c | 59 + dlls/msi/action.c | 37 + dlls/msi/appsearch.c | 7 +- dlls/msi/custom.c | 2 +- dlls/msi/dialog.c | 2 +- dlls/msi/files.c | 38 +- dlls/msi/format.c | 2 +- dlls/msi/msi.c | 6 + dlls/msi/msipriv.h | 1 + dlls/msi/source.c | 4 +- dlls/msi/tests/install.c | 35 +- dlls/msi/tests/msi.c | 124 ++- dlls/msi/where.c | 2 +- dlls/msvcrt/heap.c | 56 +- dlls/msvcrt/tests/heap.c | 79 ++ dlls/netapi32/tests/apibuf.c | 3 +- dlls/ntdll/actctx.c | 56 +- dlls/ntdll/heap.c | 19 +- dlls/ntdll/reg.c | 12 +- dlls/ntdll/sec.c | 2 +- dlls/ole32/marshal.c | 13 +- dlls/ole32/ole32.spec | 8 +- dlls/ole32/rpc.c | 55 +- dlls/ole32/tests/usrmarshal.c | 112 ++ dlls/ole32/usrmarshal.c | 94 ++ dlls/oleaut32/oleaut.c | 8 + dlls/oleaut32/tests/vartype.c | 3 + dlls/oleaut32/typelib.c | 39 +- dlls/oleaut32/typelib2.c | 4 +- dlls/rpcrt4/ndr_marshall.c | 419 ++++--- dlls/rpcrt4/rpc_message.c | 14 +- dlls/rpcrt4/rpc_transport.c | 4 +- dlls/rpcrt4/tests/ndr_marshall.c | 11 +- dlls/rpcrt4/tests/server.c | 1 - dlls/rsaenh/rsaenh.c | 49 +- dlls/shdocvw/events.c | 10 +- dlls/shdocvw/ie.c | 2 +- dlls/shdocvw/iexplore.c | 4 +- dlls/shdocvw/navigate.c | 8 +- dlls/shdocvw/shdocvw.h | 6 +- dlls/shdocvw/shlinstobj.c | 14 +- dlls/shdocvw/tests/webbrowser.c | 10 + dlls/shdocvw/webbrowser.c | 12 +- dlls/shell32/shell32_main.c | 2 +- dlls/urlmon/bindctx.c | 8 +- dlls/urlmon/binding.c | 36 +- dlls/urlmon/bindprot.c | 4 +- dlls/urlmon/file.c | 12 +- dlls/urlmon/format.c | 8 +- dlls/urlmon/ftp.c | 4 +- dlls/urlmon/http.c | 35 +- dlls/urlmon/mk.c | 12 +- dlls/urlmon/regsvr.c | 4 +- dlls/urlmon/sec_mgr.c | 22 +- dlls/urlmon/session.c | 12 +- dlls/urlmon/umon.c | 50 +- dlls/urlmon/umstream.c | 82 +- dlls/urlmon/urlmon_main.h | 20 + dlls/user32/combo.c | 2 +- dlls/user32/cursoricon.c | 2 +- dlls/user32/exticon.c | 2 +- dlls/user32/menu.c | 6 +- dlls/user32/scroll.c | 4 +- dlls/user32/sysparams.c | 8 +- dlls/user32/tests/cursoricon.c | 47 + dlls/winecoreaudio.drv/audio.c | 24 + dlls/winecoreaudio.drv/mixer.c | 5 + dlls/wined3d/arb_program_shader.c | 21 +- dlls/wined3d/baseshader.c | 4 + dlls/wined3d/basetexture.c | 26 +- dlls/wined3d/context.c | 7 +- dlls/wined3d/device.c | 57 +- dlls/wined3d/directx.c | 29 +- dlls/wined3d/glsl_shader.c | 104 +- dlls/wined3d/pixelshader.c | 80 +- dlls/wined3d/state.c | 56 +- dlls/wined3d/surface.c | 235 ++-- dlls/wined3d/texture.c | 2 +- dlls/wined3d/utils.c | 188 ++-- dlls/wined3d/vertexdeclaration.c | 2 +- dlls/wined3d/vertexshader.c | 2 +- dlls/wined3d/wined3d_private.h | 9 +- dlls/winedos/int21.c | 39 +- dlls/wininet/http.c | 13 +- dlls/wininet/tests/http.c | 5 +- dlls/winmm/winmm.c | 3 +- include/Makefile.in | 3 + include/d3dx8math.h | 7 + include/d3dx9.h | 27 + include/{d3dx8math.h => d3dx9math.h} | 23 +- include/d3dx9math.inl | 1268 +++++++++++++++++++++ include/mshtmdid.h | 47 + include/mshtml.idl | 426 +++++++ include/wincrypt.h | 130 +++ include/wine/wined3d_gl.h | 17 +- libs/wine/loader.c | 19 + programs/msiexec/msiexec.c | 2 +- programs/winedbg/info.c | 5 +- server/queue.c | 2 +- tools/wine.inf | 2 +- 147 files changed, 9525 insertions(+), 1756 deletions(-) rewrite ANNOUNCE (95%) create mode 100644 dlls/mshtml/htmltable.c create mode 100644 include/d3dx9.h copy include/{d3dx8math.h => d3dx9math.h} (92%) create mode 100644 include/d3dx9math.inl diff --git a/ANNOUNCE b/ANNOUNCE dissimilarity index 95% index bac6affb29d..c781ad3e9f2 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,603 +1,606 @@ -This is release 0.9.49 of Wine, a free implementation of Windows on Unix. - -What's new in this release: - - Many copy protection fixes. - - GLSL is now the default for Direct3D. - - Lots of memory errors fixed thanks to Valgrind. - - Support for TOPMOST windows. - - Beginnings of an inetcomm dll implementation. - - Lots of bug fixes. - -Because of lags created by using mirrors, this message may reach you -before the release is available at the public sites. The sources will -be available from the following locations: - - http://ibiblio.org/pub/linux/system/emulators/wine/wine-0.9.49.tar.bz2 - http://prdownloads.sourceforge.net/wine/wine-0.9.49.tar.bz2 - -Binary packages for various distributions will be available from: - - http://www.winehq.org/site/download - -You will find documentation on - - http://www.winehq.org/site/documentation - -You can also get the current source directly from the git or CVS -repositories. Check respectively http://www.winehq.org/site/git or -http://www.winehq.org/site/cvs for details. - -If you fix something, please submit a patch; instructions on how to do -this can be found at http://www.winehq.org/site/sending_patches - -Wine is available thanks to the work of many people. See the file -AUTHORS in the distribution for the complete list. - ----------------------------------------------------------------- - -Changes since 0.9.48: - -Alex Villacís Lasso (7): - riched20: Fix test crash on WinXP-SP2. - riched20: Allow for Win98 behavior for return value of EM_REPLACESEL. - riched20: Fix detection of CFE_LINK on WinXP-SP2. - riched20: EM_GETMODIFY should not report modification after WM_SETTEXT (fixes todo_wine). - user32: Fix LB_ITEMFROMPOINT tests for listbox control. - user32: Fix for failing tests of LB_GETTEXT on listbox on Win98. - riched20: Fix test failure in test_WM_PASTE. - -Alexander Dorofeyev (2): - comctl32: Pass command id of button in wParam. - comctl32: Fix broken detection of non-empty string. - -Alexander Nicolaysen Sørnes (2): - mscat32: Add stub dll. - shell32: Update Norwegian Bokmål translation. - -Alexandre Julliard (45): - winealsa.drv: Avoid the alsa alloca macros that cause compiler warnings. - oleaut32: Properly initialize the result variant in VarImp. - mscat32: Forward calls to wintrust where possible. - server: Remove failed ioctls from the queue as soon as the result is set. - pdh: Fix a couple of race conditions in the thread handling. - user32: Fix a slightly incorrect assert. - server: Add the generated files missing from the last commit. - msvcrt: Silence FIXME about an unknown parameter that isn't used. - server: Also return the new extended style in the set_window_pos request. - user32: Don't allow changing the WS_EX_TOPMOST style with SetWindowLong. - user32: SetParent should not make the window topmost. - server: Fix get_next/prev_window behavior for unlinked windows. - server: Added support for HWND_TOPMOST and HWND_NOTOPMOST. - winex11.drv: Set the WM_STATE_ABOVE hint on topmost windows. - user32: Store the builtin class names in Unicode. - server: Allow to send a name instead of an atom when creating a window class. - server: Support using a name to destroy a window class too. - user32: Properly handle integer atoms specified as strings in class names. - user32: Cache the window class name on the client side. - user32/tests: Don't test the contents of uninitialized buffers. - server: Allow to specify the class name instead of the atom to create a window. - server: Allow to specify the class name instead of the atom to find a window. - user32: Fixed A<->W translations of CREATESTRUCTs that contain atoms. - Make some variables static. - Include objbase.h where need to get the DllRegisterServer prototype. - comctl32/tests: Flush pending events before progress repaint tests. - include: Moved AttachThreadInput prototype to winuser.h where it belongs. - kernel32: Add spec entries for LocaleNameToLCID and LCIDToLocaleName. - include: Add WINUSERAPI to the exported user32 functions. - include: Add WINGDIAPI to the exported gdi32 functions. - include: Add WINADVAPI to the exported advapi32 functions. - include: Add WINBASEAPI to the exported kernel32 functions. - include: Add NTSYSAPI to the exported ntdll functions. - include: Only use DECLSPEC_IMPORT for Windows compilers in unicode.h. - include: Mark imported functions with hidden visibility. - wine.inf: Add APPDATA and LOCALAPPDATA environment variables. - gdi32: Make all internal gdi functions hidden. - user32: Make all internal user32 functions and variables hidden. - user32: Removed unused NC_DrawGrayButton function. - winebuild: Add a few nops to stub entry points to make Safedisc happy. - libwine: Refuse to use a WINEPREFIX dir owned by a different user. - wldap32: Always return WLDAP32 error values instead of redefining the ldap.h ones. - server: Don't drop mouse messages that should go to a different thread input. - ntdll: Increase the signal stack size to avoid crashes on nested signals. - user32/tests: Fix access to an uninitialized variable. - -Alistair Leslie-Hughes (2): - msxml: Fix a memory leak. - msxml3: Fix memory leak. - -Andrew Talbot (10): - shell32: Constify some variables. - shell32: Constify some variables. - shell32: Constify some variables. - shell32: Constify some variables. - shell32: Constify some variables. - shell32: Constify some variables. - snmpapi: Constify a variable. - twain_32: Constify a variable. - urlmon: Constify some variables. - user32: Constify some variables. - -Aric Stewart (1): - msdmo: Fix to DMOEnum to properly enumerate the keys and properly respect the flag. - -Chris Robinson (3): - mshtml: Set IE version when installing wine gecko. - mshtml: Fix hkey leak. - setupapi: Add stub for SetupInstallServicesFromInfSectionW. - -Chris Wulff (4): - shdocvw: Implement OLEIVERB_HIDE. - shdocvw: Add IPersistMemory interface stub. - kernel32: Added a stub for FindVolumeMountPointClose. - hal: Added stubs for KfAquireSpinLock, KfReleaseSpinLock, KfLowerIrql, KfRaiseIrql. - -Christian Eggers (1): - ctapi32: Added wrapper dll for ctapi (CardTerminal API). - -Dan Hipschman (7): - widl: Fix ExprEvalRoutines output. - widl: Add a --local-stubs option. - rpcrt4/tests: Initialize memory in the get_name test. - rpcrt4: Initialize allocated pointers to NULL in PointerUnmarshall. - widl: Handle pointers to conformant arrays (e.g., "[size_is(, n)] int **p; "). - widl: Don't output a void conformance for NdrClearOutParameters. - widl: Don't rely on type_memsize to return 0 for all conformant arrays. - -Dan Kegel (5): - advapi32/tests: Fix undefined memory references in registry.c. - ntdll: NtAccessCheck: Only send used bytes to server. - cabinet: FCIAddFile: Set defaults in case callback doesn't set some fields. - cabinet: FCICreate: Initialize oldCCAB. - msvcrt: Fix two buglets in heap test. - -David Adam (35): - d3dx8: Implement D3DX*Normalize. - d3dx8: Implement D3DX*BaryCentric. - d3dx8: Implement D3DX*Hermite. - d3dx8: Implement D3DX*CatmullRom. - d3dx8: Test the function D3DXVec3Cross really. - d3dx8: Implement D3DX*Transform. - d3dx8: Implement D3DX*TransformCoord. - d3dx8: Implement D3DXTransformNormal. - d3dx8: Implement D3DX*Vec4Cross. - d3dx8: Fix the condition in D3DXMatrixIsIdentity. - d3dx8: Implement D3DXMatrixfDeterminant. - d3dx8: Implement D3DXMatrixMultiply. - d3dx8: Implement D3DXMatrixTranspose. - d3dx8: Implement D3DXMatrixScaling. - d3dx8: Implement D3DXMatrixTranslation. - d3dx8: Implement D3DXMatrixRotationX. - d3dx8: Implement D3DXMatrixRotationY. - d3dx8: Implement D3DXMatrixRotationZ. - d3dx8: Implement D3DXMatrixRotationAxis. - d3dx8: Implement D3DXMatrixRotationQuaternion. - d3dx8: Implement D3DXMatrixRotationYawPitchRoll. - d3dx8: Implement D3DXMatrixLookAtRH. - d3dx8: Implement D3DXMatrixLookAtLH. - d3dx8: Implement D3DXMatrixPerspectiveRH. - d3dx8: Implement D3DXMatrixPerspectiveLH. - d3dx8: Implement D3DXMatrixPerspectiveFovRH. - d3dx8: Implement D3DXMatrixPerspectiveFovLH. - d3dx8: Implement D3DXMatrixPerspectiveOffCenterRH. - d3dx8: Implement D3DXMatrixPerspectiveOffCenterLH. - d3dx8: Implement D3DXMatrixPerspectiveOrthoRH. - d3dx8: Implement D3DXMatrixPerspectiveOrthoLH. - d3dx8: Fix the number and the type of variables in d3dx8.spec. - d3dx8: Uniformize the matrix format in the tests. - d3dx8: Implement D3DXMatrixOrthoOffCenterRH. - d3dx8: Implement D3DXMatrixOrthoOffCenterLH. - -Detlef Riekenberg (6): - include/winbase: Fix a typo. - kernel32: Fix description for SetDefaultCommConfig. - acledit: Add a stub for FMExtensionProcW. - shdocvw: Print the unsupported args in a FIXME. - winspool: Error check in add_printer_driver() was to strict. - winspool: Use unsigned type to avoid a compiler warning. - -Dmitry Timoshkov (7): - shlwapi: Fix a typo in the previous patch. Spotted by Francois Gouget. - include: Synchronize DEVMODE layout with PSDK. - user32: Initialize more fields in the DEVMODE structure. - winex11.drv: Add support for saving/reading display settings. - version: Use GetModuleHandleEx to increment the module ref count. - winex11.drv: Initialize buffer size. - user32: Simplify some code. - -EA Durbin (4): - wininet: Return true for case INTERNET_OPTION_SECURITY_FLAGS. - d3dxof: Fix some return values. - ntoskrnl.exe: Add stub Implementation of IoAllocateWorkItem. - ntoskrnl.exe: Add stub Implementation of IoAllocateMdl. - -Francois Gouget (18): - shell32: Pass the shutdown reason to ExitWindowsEx(). - wineboot: Make sure 'Cancel' has the focus and is the default button in the 'Do you want to kill all your applications' dialog. - wineboot: Add a reminder that EWX_FORCEIFHUNG is not implemented. - winetest: Add an option that shuts Windows down once the tests have completed. - cryptnet: Fix compilation on systems that don't support nameless structs. - crypt32: Better match the PSDK types and update win32.api to fix the winapi_check warnings. - shlwapi: Fix the DeleteMenuWrap() forward. - tapi32: Add prototypes for lineInitializeExA/W(). - d3dx8: Fix compilation on systems that don't support nameless unions. - d3dx8: Make sure d3dx8math.inl compiles fine, whether nameless unions are supported or not. - user32: Fix compilation on systems that don't support either nameless unions or nameless structs. - winex11: Fix compilation on systems that don't support either nameless unions or nameless structs. - kernel32: Fix the image size in a test to avoid a BSOD on Windows XP SP1. - d3dx8: Fix compilation on systems that don't support nameless unions. - gdi32/tests: Dynamically load GdiAlphaBlend() so the test runs on Win9x. - user32/tests: Skip some tests when DdeClientTransaction() returns NULL. This avoids some crashes on Win9x. - Assorted spelling fixes. - winex11: Add C alternatives to the assembly bits in X11DRV_DIB_SetImageBits_8(). - -Gerald Pfeifer (8): - shlwapi/tests: Remove overly aggressive const declaration for TEST_URL_UNESCAPE. - oleaut32: Use -0.0 directly in test_VarBstrFromR4(). - shell32: Remove useless comparison >= 0 for unsigned variables. - comctl32: Make parameters of expect_band_content() match the corresponding types of REBARBANDINFO and fix one format string. - wined3d: Fix type of loop variable in IWineD3DCubeTextureImpl_Destroy(). - user32: Don't check unsigned types for >= 0. - shell32: Avoid checking for <0 for unsigned variables. - dinput: Fix type of loop variable in alloc_device(). - -Hans Leidekker (18): - snmpapi: Fix memory allocation in SnmpUtilVarBindListCpy. - wininet: Always return an error when a transfer is in progress. - wininet: Always close the data connection before receiving a server response. - wininet: Always send a content length header, even if there is no content. - wininet: Use a single connection for all ftp tests. - wininet: Don't release the parent object in FTP_Connect, the caller will do that. - pdh: Remove or fix tests that fail on Windows. - wininet: Correct several ftp server response to error code mappings. - wininet: Implement and test FtpCommand{A, W}. - ntdll: Fix calculation of tape position offsets. - wldap32: Fix build against latest OpenLDAP release. - mlang: Release EnumRfc1766 object. - mlang: Free SCRIPTINFO structure embedded in EnumScript object. - mlang: Fix buffer size calculation. - usp10: Fix a memory leak. - usp10: Fully initialize LOGFONT structure. - usp10: Fix a test to not rely on uninitialized memory. - usp10: Fix some more memory leaks. - -Huw Davies (7): - inetcomm: Add self-registration code. - include: Add a few defines and fill out IMimeMessageCallback. - inetcomm: Add a stub for MimeOleCreateVirtualStream. - inetcomm: Add two missing member functions. - include: Add a couple more interfaces. - inetcomm: Add a test for MimeOleCreateVirtualStream. - inetcomm: Add a stub implementation of the MimeSecurity object. - -Hwang YunSong(황윤성) (4): - credui: Updated Korean resource. - progman: Updated Korean resource. - user32: Updated Korean resource. - winemine: Update Korean resource. - -Jacek Caban (13): - itss: Fixed tests on old IE. - msimtf: Fixed typos. - shdocvw: Move registration code to .inf file. - mshtml: More test fixes. - mshtml: AsyncOpen code clean up. - iexplore: Added self-registration code. - urlmon: Added https protocol class factory stub implementation. - shdocvw: Fixed typos. - mshtml: Store HTMLDocument pointer in BSCallback object. - mshtml: More range tests and fixes. - mshtml: Call Exec(CGID_ShellDocView, 84) in start_binding. - mshtml: Added AcceptLanguage handling. - mshtml: Added IDM_SETDIRTY implementation. - -James Hawkins (39): - msi: Test the MoveFiles standard action. - msi: Implement the MoveFiles standard action. - msi: Remove a duplicated function. - msi: Properly register and unregister components. - msi: Properly register features. - msi: Only unpublish the features if the entire product is being uninstalled. - msi: A feature's requested action does not depend on its installed state. - msi: do_query is supposed to fail, so don't release a handle that is never initialized. - msi: Implement MsiSourceListAddSourceExA. - msi: Don't create the product source key when adding a source. - msi: Add tests for MsiSourceListAddSourceEx. - msi: Return the error from OpenSourceKey. - msi: Validate the product code. - msi: Append a slash to network and url sources. - msi: An empty source is an invalid parameter. - msi: The options must include a source type. - msi: Reimplement MsiSourceListAddSourceEx to handle reordering the source list. - msi: Handle the MSIINSTALLCONTEXT_USERMANAGED context. - msi: szUserSid must be NULL if context is MSIINSTALLCONTEXT_MACHINE. - msi: Fix the location used to read machine context source list info. - msi: Initialize a handle in case MsiGetSummaryInformation fails. - msi: Test and implement the MSIMODIFY_DELETE command. - msi: Remove a legacy error check. - msi: Fix the sign of an index variable. - msi: Remove an unused parameter. - msi: Remove an unused parameter. - msi: MsiViewGetError returns MSIDBERROR, not UINT. - msi: MsiQueryFeatureState and MsiUseFeatureEx return INSTALLSTATE, not UINT. - msi: MsiQueryProductState returns INSTALLSTATE, not UINT. - msi: Use a magic constant to silence signedness comparison warnings. - msi: Remove an unused parameter. - msi: Fix the location used to write the user's environment variables. - msi: Don't update a table entry when applying a transform if the string value is the same. - msi: Explicitly check the returned value against -1 as the variable is unsigned. - msi: Implement the CCPSearch standard action. - msi: Add a missing struct initialization. - msi: Test the install states of removed features. - msi: Process the ADDSOURCE property when setting feature states. - msi: Test that the install state is dependent on the feature and component registration. - -Juan Lang (52): - crypt32: Fix a leak in the tests. - crypt32: Fix another leak in the tests. - crypt32: Get rid of an unneeded variable. - crypt32: Set size when calling CryptDecodeObjectEx without CRYPT_DECODE_ALLOC_FLAG set. - crypt32: Fix a leak during chain creation. - crypt32: Fix leaked chains creating the root store. - crypt32: Fix a leak building an alternate chain. - crypt32: Use memmove rather than memcpy when addresses might overlap. - crypt32: Initialize a variable. - crypt32: Don't leak buffer when a unicode string contains an invalid character. - crypt32: Fix a leaked key. - crypt32: Set last error on alloc failure. - crypt32: Free memory on all paths. - crypt32: Use consistent error checking. - url: Fix prototype of FileProtocolHandlerA. - crypt32: Initialize a variable. - crypt32: Don't store a redundant copy of data in the message store. - crypt32: Don't define function pointers that are NULL (and unused). - comdlg32: Implement OFN_CREATEPROMPT checking. - comdlg32: Grammar fixes. - wsock32: Correctly handle the case where a table size is 0 in IP_MIB_TABLE_ENTRY_ID. - wsock32: Don't use HEAP_ZERO_MEMORY for memory that's fully initialized anyway. - setupapi: Fix a leak. - setupapi: Correct a return value. - setupapi: Downgrade an ERR to a WARN. - setupapi: Don't convert strings past NULL-terminator. - wsock32: Check return value rather than returned size for error. - rsaenh: Use helper function to persist keys. - rsaenh: Use helper function to create a container's registry key. - rsaenh: Use helper function to open a key container's registry key. - rsaenh: Use helper function to delete a key container's registry key. - rsaenh: Use helper function to read key pairs from registry. - rsaenh: Use LocalFree to free memory return by Crypt(Un)ProtectData. - rsaenh: Fix a comment. - crypt32: Describe CryptProtectData data format more accurately. - crypt32: Save alg IDs in CryptProtectData output. - crypt32: Use SHA1 rather than MD5 to protect data. - crypt32: Use the enhanced provider rather than the default (base) provider. - crypt32: Pass key length to CryptDeriveKey. - crypt32: Set correct bit lengths for algorithms. - crypt32: Use 3DES to encrypt data. - crypt32: Fix a leak. - crypt32: Fail decoding a CRL entry if the serial number is empty. - setupapi: Add stubs for CM_Get_Device_IDA and CM_Get_Device_ID_Size. - cfgmgr32: Forward cfgmgr32 functions to setupapi. - wininet: Fix typo. - wininet: Fix another typo. - wininet: Don't use HEAP_ZERO_MEMORY on memory that's fully initialized. - crypt32: Fix a couple leaks in test. - crypt32: Fix another leak in tests. - crypt32: If a decoding function failed, free the memory allocated for it. - wininet: Initialize length of values that aren't being requested. - -Kai Blin (2): - netapi32: Fix valgrind warnings. - ws2_32: Map SO_REUSEADDR. - -Klaus Layer (1): - ntdll: Add missing FIXMEs for incomplete info classes in NtQuerySystemInformation. - -Kovács András (1): - dwmapi: Add DwmEnableComposition stub. - -Laurent Vromman (2): - gdi32: Add a test for CloseFigure. - gdi32: Correct a test where the tested function was not called. - -Lei Zhang (13): - comctl32: Move tab test's createParentWindow() into START_TEST(). - comctl32: Add tab insert item / get focus test. - comctl32: Add tab delete item / get focus test. - comctl32: Set tab focus correctly. - comctl32: Datetime should close its monthcal when the monthcal loses focus. - comctl32: Fix uninitialized, unused variables. - comctl32: Fix typo in rebar. - wininet: Initialize ftp sockets. - wininet: Skip strcmp() in a test if the returned value/len is wrong. - sane.ds: Get number of options only once. - sane.ds: Check return value from sane_control_option(). - sane.ds: Check return value from sane_get_option_descriptor(). - sane.ds: Fix a memory leak. - -Lionel Debroux (2): - mshtml: Fix memory leak (found by Smatch). - credui: Fix memory leak (found by Smatch). - -Maarten Lankhorst (6): - include: Add a few speaker defines to ksmedia.h. - dsound: Add support for WAVEFORMATEXTENSIBLE format. - dsound: Add conformance tests for 24/32 bits buffers and waveformatextensible. - dsound: Add support for 24/32 bits input sound buffers. - dsound: Add mixing and normalization functions. - dsound: Use a 2 stage mixing/normalization for sound. - -Marcel Partap (1): - include: Add winddiui.h header. - -Marcus Meissner (1): - winalsa.drv: Explicitly include assert.h. - -Michael Stefaniuc (1): - pdh: Fix two missing LeaveCriticalSection() on error paths. - -Mikolaj Zalewski (2): - msvcrt/tests: Loosen the mbctype test to pass under Windows 9x and NT 4.0. - user32: Better fix how to handle GetWindowLongPtr[AW](..., GWLP_WNDPROC) for builtin winprocs. - -Nigel Liang (1): - wininet: Release object in HttpSendRequestExW before return on error. - -Paul Millar (1): - widl: Add support for overriding recorded time, allowing binary-identical compilation. - -Paul Vriens (3): - ntdll: Report FIXME only once. - advapi32/tests: Make tests run on win98 again. - dsound/tests: Fix test failures on WinXP and 2003. - -Rob Shearman (36): - urlmon: Add tests for BindToObject for URL monikers based on the existing tests for BindToStorage. - server: Add the name length to the object_attributes structure so that other variable length data can be present after object_attributes. - server: Pass the security descriptor into create_file, if one is specified, and set the initial mode for the file appropriately. - advapi32: Implement CredWriteW. - advapi32: Implement CredReadW and CredFree. - advapi32: Implement CredDeleteW. - advapi32: Implement CredEnumerateW. - advapi32: Implement ANSI credential management functions. - advapi32: Add tests for credential management functions. - advapi32: Implement filter matching for CredEnumerate. - server: Make sure to always initialise req_sd.owner_len and req_sd.group_len in the handler for the get_security_object call. - ole32: Improve the error reporting in the marshal test when CreateProcess fails. - ole32: Add tests for CoGetObjectContext. - ole32: Implement CoGetObjectContext. - ole32: Remove an incorrect comment. - setupapi: Make the setupapi tests load on systems < Vista by providing a private implementation of RegDeleteTreeW. - rpcrt4: Add a test for the pointers in [in,out] pointer structs not changing when the pointers aren't NULL. - inetcomm: Add stub implementation of inetcomm.dll. - include: Add imnact.idl and imnxport.idl. - inetcomm: Add a framework for connecting to a server and sending/receiving data asynchronously with callbacks being called in the context of the original thread, using window messages. - inetcomm: Use InternetTransport_ChangeStatus in InternetTransport_DropConnection so that the callback gets called. - inetcomm: Call InternetTransport_RegisterClass and UnregisterClass on process attach and detach respectively, to register a window class and initialize Winsock. - inetcomm: Add stubs for MimeOleSetCompatMode and MimeOleCreateMessage. - include: Add mimeole.idl. - inetcomm: Include mimeole.h and fix the type of MimeOleCreateMessage. - inetcomm: Add a stub implementation of the IMimeMessage object returned from MimeOleCreateMessage. - include: Take care to not declare CtxtHandle and PCtxtHandle more than once when including both sspi.h and wincred.h. - rpcrt4: Add a small bit of documentation as to what NdrStubCall2 does. - rpcrt4: Move some type definitions from ndr_stubless.c to ndr_stubless.h. - rpcrt4: Factorise out the argument processing from NdrStubCall2 into two functions. - include: Add a new header file: midles.h. - include: Fix a typo in midles.h. - rpcrt4: Handle FC_IGNORE in the base type functions. - server: Don't do access checks on the security descriptors of newly created objects. - rpcrt4: Add a stub for RpcErrorStartEnumeration. - rpcrt4: Add stubs for RpcMgmtSetCancelTimeout and RpcCancelThread. - -Roderick Colenbrander (14): - wined3d: Use native shader limits instead of the maximum the driver can handle in software. - wined3d: Add proper PS2.0 detection for older cards with GLSL support. - wined3d: Print the correct pixel/vertex shader version in a debug trace. - wined3d: Fix the amount of texture memory in the debug traces. - wined3d: Detect vertex shader 2.0 support using a pixel shader 2.0 limit. - wined3d: Default to GLSL. This is safe because we now have proper ps2.0/vs2.0 detection. - wined3d: Fix glsl detection bug. - wined3d: Fix LockedRect regression. - wined3d: Only use p8 conversion on render targets. - wined3d: UnlockRect regression fix. - wined3d: Rewrite the draw buffer selection code. - wined3d: Make sure the format of the render target is P8 too. - wined3d: Make sure SFLAG_LOCKED is set at the start of LockRect as various functions called from LockRect depend on it (e.g. LoadTexture if called from LoadLocation). - wined3d: Make sure the p8 shader is set to 0 after destroying the main render target. - -Rok Mandeljc (6): - wnaspi32: Print error when device cannot be opened. - wnaspi32: Degrade ERR of not finding registry entry for a device to TRACE. - wnaspi32: Call ASPI_GetNumControllers() only once. - wnaspi32: Do the command dumping only after device has been verified. - wnaspi32: Fix Controller -> H/C mapping. - wnaspi32: Fix controller number validation. - -Stefan Dösinger (58): - wined3d: Move drawable->sysmem reading to UpdateLocation. - wined3d: Add a comment explaining what LoadLocation does. - wined3d: Move sysmem->drawable copying to LoadLocation. - wined3d: Move texture loading to LoadLocation. - wined3d: Honor pbos when downloading a compressed texture. - wined3d: Move texture -> drawable blits to LoadLocation. - wined3d: Move memory allocation into a separate function. - wined3d: Reenable render target unlocking via textures. - wined3d: Move a part of LockRect to the base class. - wined3d: Allocate memory for default pool resources too. - wined3d: Disconnect allocatedMemory and Heap allocation. - wined3d: Make resource memory 32 byte aligned. - d3d9: Silence a FIXME. - wined3d: Remove an unneeded check. - wined3d: Remove a wrong return. - wined3d: Move sysmem->drawable specific blit code out of LoadLocation. - wined3d: Move drawable->sysmem specific code to its special function. - wined3d: Move texture->sysmem specific code into its special function. - d3d8: Initialize the vertex decl when allocating it. - wined3d: Don't test D3DDEVICE surfaces in dsurface tests. - wined3d: Only glBindAttribLocation used attributes. - wined3d: Make pixel shader input an array. - wined3d: Pixel Shader varying indexing. - wined3d: Add a max varyings member to the gl info structure. - wined3d: Handle ps 3.0 varyings in a different way. - wined3d: Shader Model 3.0 varying tests. - wined3d: Set the main hwnd before setting up the screen. - wined3d: Set the display mode before creating the context. - wined3d: Refuse to create volumes and volume textures if not supported. - d3d9: Use HAL devices in some tests. - ddraw: Be less picky about float precision. - ddraw: Fix a test for Vista. - d3d9: Remove some spamy debug traces from the texture test. - wined3d: Install a varying map. - wined3d: Implement the varying map. - d3d9: Initialize the test rectangle correctly. - wined3d: Free the backbuffer array. - wined3d: Fix the varying number comparison. - wined3d: Remove the conditional from texdepth. - wined3d: Relative addressing offsets are limited to [-64; 63] in arb. - wined3d: Get rid of the conditionals in the glsl lit implementation. - wined3d: mov to a0.x does a floor(), not a round to nearest. - wined3d: Replace the position fixup mul-add-add with a MAD. - wined3d: Avoid NOP additions. - wined3d: Honor the driver's min point size. - wined3d: Take care for client storage and pbos. - wined3d: Get rid of the conditionals in shader_glsl_compare. - d3d9: Be less picky in the D3DFMT_X8L8V8U8 test. - wined3d: Pass surface dirtification to the container. - wined3d: Implement a detection for the MacOS OpenGL implementation. - wined3d: Fix for MacOS'es incomplete glsl uniform truth. - wined3d: Hide NP2 textures support on R500 and earlier cards. - wined3d: Store the special uniforms' locations in the linked program. - wined3d: Store integer uniform locations. - wined3d: Load GLSL sampler uniforms at shader link time. - wined3d: Reinstall the projected texture disabling for generated coords. - d3d9: Release the window after the visual tests. - wined3d: Actually store the PS's vertex processing flag. - -Stefan Leichter (3): - advpack/tests: Print the unexpected result in function check_ini_contents. - d3dx8: Fix number of parameter of functions D3DXVec4Cross and D3DXVec?CatmullRom. - browseui: Print 64bit integers with wine_dbgstr_longlong. - -Thomas Weidenmueller (1): - shell32: Use SHStrDupW in IShellFolder2::GetDetailsOf to allocate returned string. - -Tim Schwartz (2): - netapi32: Add stub for NetUseEnum(). - net.exe: Lists existing NetUse connections. - -Tom Brus (1): - ntdll: Serial/COM code misinterpreted XON/XOFF direction. - -Vijay Kiran Kamuju (1): - include: Add missing defines for RC5, SHA and AES in wincrypt.h. - -Vincent Hardy (1): - oleaut32: Add TypeLib version for W2K, WXP, and Vista. - -Vitaliy Margolen (3): - dbghelp: Fix detection of ELF libs by their name. - kernel32: Implement GetProcessHandleCount. - dinput: Add stub for DIPROP_AUTOCENTER property. - --- -Alexandre Julliard -julliard@winehq.org +This is release 0.9.50 of Wine, a free implementation of Windows on Unix. + +What's new in this release: + - Completed I/O completion. + - Improved user credentials management, including Mac Keychain support. + - More Valgrinding. + - Lots of bug fixes. + +Because of lags created by using mirrors, this message may reach you +before the release is available at the public sites. The sources will +be available from the following locations: + + http://ibiblio.org/pub/linux/system/emulators/wine/wine-0.9.50.tar.bz2 + http://prdownloads.sourceforge.net/wine/wine-0.9.50.tar.bz2 + +Binary packages for various distributions will be available from: + + http://www.winehq.org/site/download + +You will find documentation on + + http://www.winehq.org/site/documentation + +You can also get the current source directly from the git or CVS +repositories. Check respectively http://www.winehq.org/site/git or +http://www.winehq.org/site/cvs for details. + +If you fix something, please submit a patch; instructions on how to do +this can be found at http://www.winehq.org/site/sending_patches + +Wine is available thanks to the work of many people. See the file +AUTHORS in the distribution for the complete list. + +---------------------------------------------------------------- + +Changes since 0.9.49: + +Alex Villacís Lasso (6): + user32: Fix returned value of LB_DIR. + user32: LB_DIR with standalone DDL_DRIVES implies DDL_EXCLUSIVE. + user32: DlgDirSelect tacks on a period on filenames without ext. + user32: Conformance tests for LB_DIR on listboxes. + user32: DlgDirList converts path specification to uppercase. + user32: Conformance tests for DlgDirList and DlgDirSelectEx. + +Alexander Nicolaysen Sørnes (5): + wordpad: Refer to main menu using IDM_MAINMENU. + wordpad: Fix print preview bar. + wordpad: Move printing functions to a separate file. + user32: Change to modern Windows colours. + winecfg: Some fixes for Norwegian translation. + +Alexandre Julliard (19): + oleaut32: Fixed asm proxys to support more than 128 methods. + user32: Remove a few traces that only duplicate the relay information. + include: Added definition for SEE_MASK_NOASYNC. + shell32: Pass some of the ShellExecute flags through InvokeCommand. + shell32: Don't wait for the command to terminate in ShellLink_InvokeCommand. + winedbg: Print a backtrace in --auto mode. + comctl32: Fixed handling of monochrome icons in image lists. + wine.inf: Some dlls need to be registered before the others. + wine.inf: Register inetcomm.dll. + ntdll: Initialize the PEB LoaderLock pointer. + ntdll: Send the exit code to the server on failed initialization. + ntdll: Unblock signals in process init only after the dlls have been imported. + libport: Work around Mac OS execve() breakage. + kernel32/tests: Don't crash the test if GetThreadContext fails. + winex11.drv: Make sure to erase the dragging frame before moving the window. + wsock32: Forward AcceptEx and GetAcceptExSockaddrs to mswsock. + server: When merging mouse messages ignore the window if it isn't set. + wined3d: Add printf format checking to the shader_addline function and fix resulting warnings. + libwine: Work around the Mac OS dynamic loader support for PE files. + +Alistair Leslie-Hughes (10): + clusapi: Corrected value in GetNodeClusterState. + msxml3: Return E_INVALIDARG on bad parameter. + msxml3: Enable test for bad argument / fix memory leak. + msxml: Allow insertBefore to have a NULL output parameter. + msxml: Test for insertBefore with a NULL output parameter. + msxml: Added test for get_text. + msxml: Always return a string in get_text. + msxml: Implement createTextNode. + msxml: Tests for createTextNode. + urlmon: The callback parameter can be null, check pointer before using. + +Anatoly Lyutin (1): + msi: Fix invalid SQL query. + +Andrew Talbot (12): + user32: Constify some variables. + user32: Constify a variable. + user32: Constify a variable. + user32: Constify some variables. + user32: Constify some variables. + user32: Constify some variables. + comctl32: Fix a typo. + user32: Fix a typo. + comdlg32: Use logical OR not bitwise OR. + dinput: Use bitwise NOT not logical NOT. + gdi32: Fix a typo. + advapi32: Fix a typo. + +Andrey Turkin (5): + ntdll: Add some I/O completion tests. + server: Allow async i/o operations to send completion messages. + ws2_32: Make certain winsock functions generate i/o completion messages. + ntdll: Make async i/o functions generate completion messages. + server: Pass Information field from async I/O APCs. + +Aric Stewart (3): + winecoreaudio: Implement WIDM_GETPOS. + winmm: Correct check for MIXER_GETLINECONTROLSF_ONEBYTYPE in mixerGetLineControlsA. + coreaudio: Verify valid lineId in MIXER_GETLINECONTROLSF_ONEBYTYPE. + +Bang Jun-young (1): + olecli32: Fix invalid syntax. + +Dan Kegel (2): + advapi32: Fix buffer overrun in tests/registry.c:wine_debugstr_wn(). + user32: Implement return value for DdeClientTransaction for XTYP_EXECUTE. + +David Adam (27): + d3dx8: Implement D3XMatrixInverse. + d3dx8: Implement D3XMatrixMultiplyTranspose. + d3dx8: Implement D3XMatrixVec3Project. + d3dx8: Implement D3DXVec3Unproject. + d3dx8: Implement D3DXMatrixAffine Transformation. + d3dx8: Implement D3DXPlaneNormalize. + d3dx8: Implement D3DXPlaneIntersectLine. + d3dx8: Implement D3DXMatrixShadow. + d3dx8: Implement D3DXMatrixReflect. + d3dx8: Implement D3DXPlaneFromPointNormal. + d3dx8: Implement D3DXPlaneFromPoints. + d3dx8: Implement D3DXPlaneTransform. + d3dx8: Implement D3DXColorAdjustSaturation. + d3dx8: Implement D3DXColorAdjustContrast. + d3dx8: Implement D3DXQuaternionMultiply. + d3dx8: Implement D3DXQuaternionInverse. + d3dx8: Implement D3DXQuaternionSlerp. + d3dx8: Implement D3DXQuaternionSquad. + d3dx8: Implement D3DXQuaternionBaryCentric. + d3dx8: Implement D3DXQuaternionToAxisAngle. + d3dx8: Implement D3DXQuaternionRotationAxis. + d3dx8: Implement D3DXQuaternionRotationMatrix. + d3dx8: Implement D3DXQuaternionRotationYawPitchRoll. + d3dx8: Implement D3DXQuaternionLn. + d3dx8: Implement D3DXQuaternionExp. + d3dx8: Implement D3DXMatrixTransformation. + include: Header files for d3dx9_xx. + +Detlef Riekenberg (2): + shell32: Some undocumented defines and functions are now in the PSDK. + comctl32: Fix a typo in a debug message. + +Divan Burger (3): + user32: Fix colours to match exactly with Windows 2000. + user32: Change the desktop colour and pattern to match win2k. + user32, wine.inf: Enable title bar gradients and match colours with win2k. + +Dmitry Timoshkov (5): + winex11.drv: Get rid of unused variables. + server: Make timer id allocation algorithm conform to the Windows one. + kernel32: Set last error to ERROR_ALREADY_EXISTS if CreateFile succeeds and file existed before for CREATE_ALWAYS and OPEN_ALWAYS. + kernel32: Mask out FILE_ATTRIBUTE_NOT_CONTENT_INDEXED to prevent a test failure under Windows. + winex11.drv: Use display device guid managed by explorer. + +EA Durbin (4): + kernel32: Add stub implementation of GetConsoleInputExeNameA. + kernel32: Add stub implementation of GetConsoleInputExeNameW. + kernel32: Add stub implementation of GetConsoleKeyboardLayoutNameA. + kernel32: Add stub for GetConsoleKeyboardLayoutNameW. + +Francois Gouget (17): + wined3d: Add trailing '\n's to two shader_addline() calls. + ntoskrnl: Remove trailing spaces in Wine traces. + acledit: Add wfext.h. + d3dx8: Make d3dx8math.h C++ compatible. + rpcrt4: Add an API documentation stub to make winapi_check happy. + cfgmgr32: Flesh out cfgmgr32.h a bit more and fix the corresponding functions. + ctapi32: Use quotes to include our headers. Fixes winapi_check warnings. + user32/tests/msg: Don't mess up lParam as it is passed on to DefWindowProcA(). + advpack: Skip some tests if not in interactive mode because they pop up dialogs. + rpcrt4: Add some missing prototypes and better match the PSDK types. + kernel32/tests: Fix a signed/unsigned warning. + winex11: Add the trailing '\n' to a Wine trace. + d3d9/tests: Fix the trailing '\n' in an ok() call. + user32/tests: Add the trailing '\n' to an ok() call. + ntdll/tests: Fix compilation on systems that don't support nameless unions. + crypt32/tests: Get the tests running on Windows 98. + d3dx8/tests: Fix compilation on systems that don't support nameless unions. + +Gerald Pfeifer (21): + ws2_32/tests: Fix error checking. + comctl32: Remove check which never triggers. + taskmgr: Move out-of-domain checking into PerfDataGetProcessorUsage() and PerfDataGetProcessorSystemUsage(). + winedbg: Fix type of loop variable in types_udt_find_element(). + rsaenh/tests: Fix const-ness of parameters to printBytes(). + configure: Fix typos in warning messages. + advapi32: Remove untriggerable check. + user32: Fix variable type in SCROLL_HandleScrollEvent(). Remove useless check in SCROLL_SetScrollInfo(). + oleaut32: Simplify two conditions based on the fact that unsigned variables cannot be negative. + oleaut32: Simplify two conditions based on the fact that unsigned variables cannot be negative. + ntdll: Simplify condition in RtlGetAce() based on variable (un)signedness. + netapi32: Remove one tests and simplify another based on the limited range of unsigned. + winedos: Use DWORD instead of long for return values of SetFilePointer. + itss: Avoid checking an unsigned value for < 0. + wined3d: Rewrite condition in vshader_program_add_param() to actually distinguish between two cases. + inetcomm: Fix error check in InternetTransport_Connect(). + ntdll: Fix computation in enumerate_key(). + kernel32: Handle default case in Local32_FromHandle(). + winedbg: Warning fixes. + user32: Reduce scope of variable in ICO_ExtractIconExW() and initialize it. + gdi32: Fix the type of two loop variables. + +Hans Leidekker (8): + pdh: Make two tests pass on Vista. + snmpapi: Make a test pass on Vista. + wininet: Fix two handle leaks in the test. + kernel32: Loosen requirements on what QueryDosDevice returns. + wininet: Fix a number of problems with InternetSetCookie. + wininet: Fix a number of problems with InternetGetCookie. + wininet: Initialize path buffer in InternetSetCookie. + kernel32: Add stub implementations for FindFirstVolume{A, W}. + +Huw Davies (12): + inetcomm: Register a couple more classes. + inetcomm: Add a stub MimeBody implementation. + inetcomm: Add a class factory for MimeBody. + inetcomm: Add a test for MimeBody. + msxml3: Don't leak an interface on failure. + inetcomm: Copy RFC822 headers into a memory block for later parsing. + inetcomm: Parse headers into a list. + inetcomm: Unfold headers. + inetcomm: Store a header's parameters as a list. + inetcomm: Implement IMimeBody:IsContentType. + inetcomm: Implement IMimeBody:[G|S]etCurrentEncoding. + inetcomm: Implement IMimeBody:SetData. + +Jacek Caban (34): + mshtml: Reset focus after loading the page in edit mode. + mshtml: Remove nsIWebBrowserFocus_Activate useless call. + hlink.idl: Added Hlink[Get|Set]SpecialReference declaration. + shlwapi: Added SHPackDispParamsV implementation. + shlwapi: Added SHPackDispParams implementation. + shlwapi: Added SHPackDispParams test. + shlwapi: Reimplement IUnknown_CPContainerInvokeParam on top of SHPackDispParams. + shlwapi: Fixed SHPackDispParamsV spec declaration. + hlink: Added HlinkGetSpecialReference implementation. + include: Added isguids.h. + shdocvw: Register CLSID_InternetShortcut. + shdocvw: Set default home and search page. + mshtml: Fixed handling channels without container and necko channel. + shdocvw: Added WebBrowser::get_Application implementation. + shdocvw: Return correct error from WebBrowser::Quit. + mshtml: Move IOleInPlaceFrame::SetActiveObject call to separated function. + mshtml: Use call_set_active_object in exec_editmode. + mshtml: Always initialize output in exec_fontname. + mshtml: Reload page in exec_editmode if available. + mshtml: Added more loading tests. + mshtml: Change FIXME that is usually invalid to TRACE. + hlink: Added HlinkUpdateStackItem stub. + hlink: Move common includes and function declarations to header file. + hlink: Wrap heap functions. + hlink: Added HlinkCreateExtensionServices implementation. + hlink: Added HlinkCreateExtensionServices tests. + urlmon: Wrap heap functions. + mshtml: Store nsIDOMCSSStyleSheet in HTMLStyleSheet object if available. + mshtml: Added IHTMLStyleSheetsCollection::item implementation. + mshtml: Added IOleCommandTarget implementation to HTMLTxtRange. + kernel32: Terminate child process in virtual tests. + shdocvw: Silence common invalid QueryInterface FIXMEs. + mshtml.idl: Added IHTMLTable declaration. + mshtml: Added IHTMLTable interface stub implementation. + +James Hawkins (25): + msi: Test the default tables added by MsiOpenDatabase. + msi: Create the _Tables table when creating a database. + msi: Return a remote interface to the database in a custom action. + msi: Delete the uninstall key when the product is removed. + msi: Test the Uninstall registry entries. + msi: Implement the VolumeSelectCombo control. + msi: Set the file to NULL when running the directory search. + msi: Fix the condition for checking a drive. + msi: Simplify ready_media. + msi: Add tests for situations involving missing cabinets. + msi: Only check the presence of the cabinet if the file is compressed. + msi: Don't ignore the error returned by ready_media. + msi: Don't check for a cabinet's existence if it's embedded in the package. + msi: Check the cabinet's full path for existence, not just the cabinet name. + msi: Add tests for MsiGetFileHash and clean up the existing tests. + msi: Verify the szFilePath parameter of MsiGetFileHash. + msi: Set the file contents of the file hash test file explicitly. + msi: Check the destination file's hash and skip that file if the hash matches. + msi: Only check the volume label if it's different than the first media's volume label. + msi: Downgrade a FIXME to a WARN. + msi: Downgrade an ERR to a WARN. + msi: Fix the condition of a FIXME. + msi: Downgrade an ERR to a WARN. + msi: Make sure attr is valid before checking for the directory bit. + msi: Don't check for the media or cabinet if the cabinet is internal. + +Jonathan Ernst (12): + shell32: Updated French translation. + cmd: Updated French translation. + regedit: Updated French translation. + credui: Updated French translation. + localui: Updated French translation. + net: Updated French translation. + xcopy: Updated French translation. + avifil32: Updated French translation. + wine.desktop: Updated French translation. + wordpad: Updated French translation. + cmd: Updated French translation. + credui: Updated French translation. + +José Manuel Ferrer Ortiz (1): + winefile: Spanish resource file updated. + +Juan Lang (32): + rsaenh: Check pad bytes for consistency when decrypting. + iphlpapi: Default to a default gateway when choosing the best route. + iphlpapi: Don't override return value from getTcpTable. + iphlpapi: Don't allocate gobs of memory when the TCP entry table is empty. + iphlpapi: Don't allocate gobs of memory when the route table is empty. + iphlpapi: Don't allocate gobs of memory when the ARP table is empty. + iphlpapi: Don't allocate gobs of memory if the UDP table is empty. + iphlpapi: Don't allocate gobs of memory if interface table is empty. + iphlpapi: Don't allocate gobs of memory if the IP address table is empty. + iphlpapi: Don't allocate gobs of memory if there are no non-loopback interfaces. + iphlpapi: Avoid HEAP_ZERO_MEMORY where it isn't needed. + iphlpapi: Correct copy/paste error in GetTcpTable. + iphlpapi: Correct confusing indentation in GetTcpTable. + shell32: Dynamically allocate buffer for command parameters. + shell32: Use a helper function for executing a class. + shell32: Use helper function to translate ID list. + shell32: Dynamically allocate directory buffer. + shell32: Use a helper function for executing a found executable. + shell32: Dynamically allocate buffer for quoted command. + shell32: Don't overwrite the caller's buffer when doing a dde connection. + shell32: Constify some parameters. + shell32: Dynamically allocate buffer for command. + shell32: Use helper function to execute a URL. + shell32: Dynamically allocate memory for executing an URL. + shell32: Use more restricted registry rights when quering values. + shell32: Remove a bad comment. + crypt32: Implement finding an existing certificate in a store. + crypt32: Add CERT_STORE_ADD_NEWER support to CertAddCertificateContextToStore. + rsaenh: Empty container names are allowed for CRYPT_VERIFYCONTEXT contexts. + wincrypt.h: Add values for KP_PADDING key param. + crypt32: Support getting and setting the KP_PADDING key param. + crypt32: Support setting the salt value through KP_SALT_EX. + +Kai Blin (1): + ws2_32: Cope with buggy apps passing setsockopt optval as a value instead of a pointer. + +Kirill K. Smirnov (1): + wineconsole: Do not show "Apply" button - it is not used anyway. + +Lauris Kaplinski (1): + wined3d: Fixed potential reference of freed backBuffer array in IWineD3DDeviceImpl_SetFrontBackBuffers. + +Lei Zhang (4): + shell32: rename My Video to My Videos. + shell32: Don't crash if $HOME is not set. + shell32: Perform copy in UnixFolder_ISFHelper_CopyItems. + shell32: Only notify immediate parent. + +Lionel Debroux (4): + msvcrt: Fix memory leak (found by Smatch). + ntdll: Trace arena magics (may help debugging some heap corruptions). + msvcrt: Fix _Aligned_offset_realloc (move correct block of memory); add a comment to explain why. + msvcrt: Test more offsets for _aligned_offset_realloc (especially offset > alignment). + +Louis Lenders (1): + advapi32: Add stub for CreateProcessWithLogonW. + +Maarten Lankhorst (4): + dsound: Implement AngleBetweenVectorsDeg as a call to AngleBetweenVectorsRad. + dsound: Make AngleBetweenVectorsRad when vectors have no magnitude. + dsound: Reassign pointers back to null when destroying structure. + dsound: Return primary_done when no mixing needs to be done instead of 0. + +Marco Schuster (1): + wined3d: Added a card ID for a 8600 Mobile GT. + +Marcus Meissner (1): + shell32: GetModuleFileNameW gets number of WCHARs not bytes. + +Michael Stefaniuc (17): + msvcrt/tests: Remove redundant NULL check before free(). Found by Smatch. + netapi32: Remove redundant NULL check before HeapFree(). Found by Smatch. + localspl/tests: Use ANSI function declarations. + shell32: Fix a mem leak on an error path. Found by Smatch. + qcap: Fix a mem leak on an error path. Found by Smatch. + quartz: Fix memory leaks on error paths. Found by Smatch. + comdlg32: Remove duplicate includes. + ntdll: Remove duplicate includes. + kernel32: Remove duplicate includes. + setupapi: Remove duplicate includes. + dlls: Remove duplicate includes. + tools: Remove duplicate includes. + wininet/tests: Do not compare the return value of socket() with 0. Use INVALID_SOCKET instead. + rpcrt4: socket() returns -1 on error so check the return value against that. + shdocvw: Rename the wrappers around HeapAlloc() &Co to use the new standard naming. + dnsapi: Rename the wrappers around HeapAlloc() &Co to use the new standard naming. + urlmon: Rename the wrappers around HeapAlloc() &Co to use the new standard naming. + +Misha Koshelev (6): + urlmon: Release IInternetProtocolSink and BindInfo on request handle closure, not on first handle closure. + urlmon: Fix PROTOCOLDATA message passing in IInternetProtocolSink interface of Binding. + msi: automation: Fix automation object reference counts when objects are created. + msi/tests: Close opened service handles. + msi/tests: automation: Add missing VariantClear. + msi: automation: Fix ITypeInfo leak. + +Patrick Moran (1): + msiexec: Fix atou() return value mistake. + +Paul Millar (1): + libwine: Fix naked getuid() to allow compilation under MinGW. + +Paul Vriens (3): + dsound/tests: Fix tests after addition of 24/32 bits buffer tests. + dsound/tests: Fix test failures on WinXP. + dsound/tests: Better check to see if class is not available. + +Peter Beutner (2): + ntdll: Don't try to handle kill(SIGTRAP). + ntdll: Better trap exception handling. + +Rob Shearman (85): + ole32: Add a missing IStream_Release to test_CoMarshalInterThreadInterfaceInStream. + ole32: Add a missing IStream_Release to test_same_apartment_unmarshal_failure. + ole32: Fix memory leak in ItemMonikerImpl_Save. + ole32: Add a missing IMoniker_Release to test_MkParseDisplayName. + ole32: Store the InterfaceList object in the IEnumMoniker object. + ole32: Fix a memory leak in get_moniker_comparison_data. + ole32: Fix a leak of the IBindCtx object in FileMonikerImpl_IsEqual. + ole32: Fix a memory leak of moniker in RunningObjectTableImpl_Register. + ole32: Fix a memory leak in DataCacheEntry_Save. + ole32: Fix a leak of a moniker object in test_default_handler. + ole32: Initialise data_cf in DataCacheEntry's to zero to indicate no data present on creation. + ole32: Free the memory associated with the open DLL list on unloading of ole32. + shell32: Fix the length calculation of the pidl in ILSaveToStream by using the helper function ILGetSize. + shell32: Fix a memory leak in Stream_WriteLocationInfo. + ole32: Disconnect the IRemUnknown stub buffer before destroying it to release the reference on the IRemUnknown object. + oleaut32: Handle non-byref safe arrays in VARIANT_UserFree. + server: In set_user_object_info len is in bytes, not WCHARs. + ntdll: Initialise the part of the buffer to be written to a file in the file test. + kernel32: Implement GetThreadId. + ole32: Fail before constructing an object in CreateStreamOnHGlobal to avoid a memory leak. + ole32: Release the stream in COM_RevokeRegisteredClassObject. + ole32: Fix a memory leak in the HGLOBAL stream tests by telling CreateStreamOnHGlobal to free the memory it allocates, as we don't free it ourselves in this test. + ole32: Fix the condition in HMETAFILEPICT_UserFree to match that in METAFILEPICT_UserMarshal. + ole32: Use asynchronous I/O for the named pipe server for local servers. + ole32: Wait forever on the ready_event in the local server tests. + rpcrt4: Implement RpcCancelThread for the ncacn_ip_tcp protocol sequence. + ole32: Validate the parameters to DataCache_Cache. + ole32: Release the correct pointer in test_MkParseDisplayName. + rpcrt4: Fix a copy and paste mistake in declaring threaddata_cs_debug. + msxml3: Fix some memory leaks of name in test_xmldoc. + msxml3: Don't leak node in xmldoc_createElement in the wrong type was specified. + ole32: Intialise some out parameters in ProxyCliSec_QueryBlanket. + mapi32: Add a stub for DllGetClassObject. + include: Add definitions used for AllowSetForegroundWindow and LockSetForegroundWindow. + credui: Add support for saving the credentials input using CredUIPromptForCredentials by calling CredWriteW. + credui: Split CredDialogProc out into separate functions. + credui: Increase the dropped-down size of the username combo box. + credui: Enumerate saved credentials and use these to populate the combo box. + credui: Check for and don't add duplicates when filling the username combo box. + credui: Ensure that the foreground window doesn't get changed while the user is typing in their password. + credui: Make sure not to leave the password in memory when no longer in use. + shell32: Add a stub for LinkWindow_RegisterClass. + shell32: Add a stub for LinkWindow_UnregisterClass. + rpcrt4: Hold the thread-data's critical section while cancelling a call. + credui: Override the default banner if the caller specifies one to CredUIPromptForCredentialsW. + comctl32: Unify the implementation of TOOLTIPS_Show and TOOLTIPS_TrackShow to give tracked tooltips balloon support. + comctl32: Fix the tooltips behaviour when TTF_ABSOLUTE isn't specified. + comctl32: Forward the WM_GETTEXTLENGTH message from ComboEx controls to its edit control. + explorer: Add a fixme to show when applications are trying to show a balloon tip in the taskbar notification area. + urlmon: Fix a reference count leak in RegisterBindStatusCallback. + credui: Show a balloon tip in the credential dialog if CREDUI_FLAGS_INCORRECT_PASSWORD was specified. + credui: Display a warning balloon if the user has Caps Lock on. + server: Change the get_dll_info server request to allow retrieving the image file name of a process. + server: Fix a typo in the enumeration of the ACE's in sd_to_mode. + server: Fix incorrect translation of the World SID to and from Unix file permissions. + rpcrt4: Raise an exception if a NULL ref-pointer is passed in to PointerMarshall or PointerBufferSize. + ole32: Fix a race in find_proxy_manager. + comctl32: Update the version in the created version to the highest current version present on XP. + ntdll: Shared manifests should have a less-strict version check performed when loading them as dependencies. + kernel32: Change the shared manifest test to depend on a build number that isn't currently published on at least XP, showing that assemblies with higher build numbers can be used. + advapi32: Move credential registry reading code to separate functions. + advapi32: Fix a typo in CredEnumerateW. + ole32: Store the dispatch parameters in the message state structure to allow them to be initialised earlier in the sequence of IRpcChannelBuffer calls. + ole32: Clean up properly in ClientRpcChannelBuffer_SendReceive in the case where PostMessageW fails. + ole32: Add tests for WdtpInterfacePointer_* functions. + advapi32: Add support for using the Mac Keychain services as a backend for the credential functions instead of the registry. + credui: Fix a test failure on Windows XP. + rpcrt4: Fix the tests for up_enum16. + wininet: Don't clear the auth data for Basic authentication in HTTP_InsertAuthorizationForHeader. + oleaut32: Free the correct custom data inside ITypeInfo_fnRelease. + oleaut32: Introduce a new helper function, TLB_FreeCustData, for freeing custom data. + oleaut32: Handle integer overflow of len in SysReAllocStringLen and SysAllocStringByteLen. + advapi32: Use the open_for_write parameter to open_cred_mgr_key and fix get_cred_mgr_encryption_key to not need KEY_WRITE access to the key passed in. + advapi32: Make the credential registry key stay around if a persist value longer than session is specified. + rpcrt4: Check for integer overflows when increasing the buffer length. + rpcrt4: Check there is enough space in the buffer and that the size doesn't cause an overflow when copying data to it. + rpcrt4: Fix some more potential buffer overflows. + rpcrt4: Fix an integer overflow in NdrConformantStructMarshall and NdrConformantStructUnmarshall. + ole32: Fix description of what is being test in ok calls in the WdtpInterfacePointer tests. + ole32: Fix a test in the WdtpInterfacePointer tests. + rpcrt4: Errors in sending or receiving packets should result in RPC_S_CALL_FAILED being returned, not RPC_S_PROTOCOL_ERROR. + rpcrt4: EmbeddedPointerUnmarshall doesn't need to change the address of the allocated memory, so reduce the level of indirection of the memory parameter by one. + rpcrt4: Move forcing of fMustAlloc to NULL to the callers of EmbeddedPointerUnmarshall. + rpcrt4: Improve PointerUnmarshall to cope with keeping the non-NULL source pointer of a client unmarshall. + rpcrt4: Fix NdrSimpleStructUnmarshall to cope with [in, out] embedded pointers. + +Roderick Colenbrander (3): + wined3d: Flush GL calls after drawing to the drawable. This fixes apps that use multiple GL contexts. + wined3d: Prevent unneeded context switches. + wgl: Add wglCopyContext support. + +Stefan Dösinger (51): + wined3d: Align the gl function table. + wined3d: Load extension functions after finding the supported extensions. + wined3d: Extend the gl extension function loading table with ext info. + wined3d: Load GL functions from core if needed. + wined3d: Mark extensions supported which are included in the gl core. + wined3d: Load GL_EXT_texture3D from gl 1.2 if the extension is not there. + wined3d: Hardcode local constants into the shader if possible. + wined3d: Get rid of a few Nvidiaisms in glsl shaders. + wined3d: Partially revert "Get rid of the conditionals in shader_glsl". + wined3d: Depth stencil fixes. + wined3d: Read the framebuffer size from the surface, not the window. + wined3d: Apply matrices when switching from transformed vertices to shaders. + wined3d: Non power of two texture fixes. + wined3d: Fix ATI video memory detection typo. + wined3d: Do not call PreLoad in surface_download_data. + wined3d: Remove a hack that slipped in. + wined3d: Destroy GL contexts before changing the screen resolution. + msvcrt: Implement strcpy_s. + msvcrt: Implement strcat_s. + msvcrt: Implement _mbsnbcpy_s. + d3d8: Release the vertex declarations array when destroying the device. + wined3d: Move IUnknown functions to IWineD3DBaseShader. + wined3d: Free the shader function when freeing the shader. + wined3d: Use standard wine lists for the resource list. + d3d8: Destroy the window after the visual test. + d3d9: Free the converted declaration data after creating the declaration. + wined3d: Do not cap fragment samplers to 8. + wined3d: Move destroying the glsl vshader into a separate function. + wined3d: Move glsl shader destruction to the glsl shader backend. + wined3d: Track vertex declaration changes on vertex shaders. + wined3d: Bool constants aren't vectors. + d3d9: Add a test for vertex shader input matching. + wined3d: Make SRGB write correction working with 1.x shaders in arb. + wined3d: Fog is applied after sRGB correction. + wined3d: Downgrade an ERR to a WARN. + wined3d: Correctly handle the y offset with offscreen rendering. + wined3d: Inform the texture about filtering changes. + wined3d: Work around nvidia beta driver bug. + wined3d: Add some missing checkGLcall calls. + wined3d: Do not try to disable unsupported texture units. + wined3d: Report some more geforce 7 cards as geforce 7. + wined3d: Allow using a different internal format for fbos. + wined3d: Fix a sign mistake in the code creating the sorted attrib. + wined3d: Disable GL_TEXTURE_2D in the standard blit setup. + wined3d: Avoid hardcoding GL_TEXTURE_2D. + wined3d: Add GL_ARB_texture_rectangles to our opengl extensions. + wined3d: Make the code aware of GL_ARB_texture_rectangle. + wined3d: Refuse to create a mipmapped conditional np2 texture. + wined3d: Activate GL_ARB_texture_rectangle. + wined3d: Remove the X channel fixup in render target unlocking. + user32: Destroying the current cursor results in an error. + +Stefan Leichter (2): + d3dx8: Add WINAPI to the prototypes of D3DXMatrixTransformation. + kernel32: Added stub for FindVolumeClose. + +Sven Paschukat (1): + ctapi32: Added null terminator to library name. + +Thomas Weidenmueller (1): + comctl32: Fix handling of CB_RESETCONTENT in ComboBoxEx. + +Tony Wasserka (7): + d3dx8: Implement the C++ stuff of the D3DXVECTOR2 structure. + d3dx8: Implement the C++ stuff of the D3DXVECTOR3 structure. + d3dx8: Implement the C++ stuff of the D3DXVECTOR4 structure. + d3dx8: Implement the C++ stuff of the D3DXMATRIX structure. + d3dx8: Implement the C++ stuff of the D3DXQUATERNION structure. + d3dx8: Implement the C++ stuff of the D3DXPLANE structure. + d3dx8: Implement the C++ stuff of the D3DXCOLOR structure. + +Vijay Kiran Kamuju (4): + rsaenh: Add a few more tests which check the decryption strings. + rsaenh: Add tests for RSA_AES provider. + rsaenh: Add implementation of Enhanced RSA AES Provider. + include: Add missing definitions for DSS in wincrypt.h. + +Vitaliy Margolen (1): + dinput: Fix dead zone handling. + +-- +Alexandre Julliard +julliard@winehq.org diff --git a/ChangeLog b/ChangeLog index e7e3c721eab..4f434719658 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,2047 @@ +2007-11-30 Jacek Caban + + * dlls/mshtml/Makefile.in, dlls/mshtml/htmlelem.c, + dlls/mshtml/htmltable.c, dlls/mshtml/mshtml_private.h: + mshtml: Added IHTMLTable interface stub implementation. + + * include/mshtmdid.h, include/mshtml.idl: + mshtml.idl: Added IHTMLTable declaration. + +2007-11-30 Francois Gouget + + * dlls/d3dx8/tests/math.c: + d3dx8/tests: Fix compilation on systems that don't support nameless unions. + +2007-11-29 Stefan Dösinger + + * dlls/user32/cursoricon.c, dlls/user32/tests/cursoricon.c: + user32: Destroying the current cursor results in an error. + +2007-11-28 Stefan Dösinger + + * dlls/wined3d/surface.c: + wined3d: Remove the X channel fixup in render target unlocking. + +2007-11-29 Stefan Leichter + + * dlls/kernel32/kernel32.spec, dlls/kernel32/volume.c: + kernel32: Added stub for FindVolumeClose. + +2007-11-29 Michael Stefaniuc + + * dlls/urlmon/bindctx.c, dlls/urlmon/binding.c, dlls/urlmon/bindprot.c, + dlls/urlmon/file.c, dlls/urlmon/format.c, dlls/urlmon/ftp.c, + dlls/urlmon/http.c, dlls/urlmon/mk.c, dlls/urlmon/regsvr.c, + dlls/urlmon/sec_mgr.c, dlls/urlmon/session.c, dlls/urlmon/umon.c, + dlls/urlmon/umstream.c, dlls/urlmon/urlmon_main.h: + urlmon: Rename the wrappers around HeapAlloc() &Co to use the new standard + naming. + +2007-11-29 Sven Paschukat + + * dlls/ctapi32/ctapi32.c: + ctapi32: Added null terminator to library name. + +2007-11-29 Rob Shearman + + * dlls/rpcrt4/ndr_marshall.c, dlls/rpcrt4/tests/server.c: + rpcrt4: Fix NdrSimpleStructUnmarshall to cope with [in, out] embedded pointers. + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: Improve PointerUnmarshall to cope with keeping the non-NULL source + pointer of a client unmarshall. + This will enable various types with embedded pointers to handle [in,out] + parameters correctly by keeping the existing memory. + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: Move forcing of fMustAlloc to NULL to the callers of + EmbeddedPointerUnmarshall. + This will enable them to be individually fixed up to use memory if it + was provided by the caller. + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: EmbeddedPointerUnmarshall doesn't need to change the address of the + allocated memory, so reduce the level of indirection of the memory parameter + by one. + + * dlls/rpcrt4/rpc_message.c: + rpcrt4: Errors in sending or receiving packets should result in RPC_S_CALL_FAILED + being returned, not RPC_S_PROTOCOL_ERROR. + +2007-11-27 Louis Lenders + + * dlls/advapi32/advapi32.spec, dlls/advapi32/security.c: + advapi32: Add stub for CreateProcessWithLogonW. + +2007-11-28 Gerald Pfeifer + + * dlls/gdi32/font.c: + gdi32: Fix the type of two loop variables. + +2007-11-28 Gerald Pfeifer + + * dlls/user32/exticon.c: + user32: Reduce scope of variable in ICO_ExtractIconExW() and initialize it. + +2007-11-29 Gerald Pfeifer + + * programs/winedbg/info.c: + winedbg: Warning fixes. + +2007-11-28 Gerald Pfeifer + + * dlls/kernel32/local16.c: + kernel32: Handle default case in Local32_FromHandle(). + +2007-11-29 Alexandre Julliard + + * libs/wine/loader.c: + libwine: Work around the Mac OS dynamic loader support for PE files. + +2007-11-29 Aric Stewart + + * dlls/winecoreaudio.drv/mixer.c: + coreaudio: Verify valid lineId in MIXER_GETLINECONTROLSF_ONEBYTYPE. + + * dlls/winmm/winmm.c: + winmm: Correct check for MIXER_GETLINECONTROLSF_ONEBYTYPE in + mixerGetLineControlsA. + +2007-11-28 Marco Schuster + + * dlls/wined3d/directx.c, include/wine/wined3d_gl.h: + wined3d: Added a card ID for a 8600 Mobile GT. + +2007-11-28 Andrew Talbot + + * dlls/advapi32/registry.c: + advapi32: Fix a typo. + +2007-11-28 James Hawkins + + * dlls/msi/files.c: + msi: Don't check for the media or cabinet if the cabinet is internal. + + * dlls/msi/appsearch.c: + msi: Make sure attr is valid before checking for the directory bit. + +2007-11-28 Stefan Dösinger + + * dlls/wined3d/device.c, dlls/wined3d/surface.c, dlls/wined3d/texture.c, + dlls/wined3d/wined3d_private.h: + wined3d: Activate GL_ARB_texture_rectangle. + + * dlls/wined3d/device.c: + wined3d: Refuse to create a mipmapped conditional np2 texture. + +2007-11-27 Stefan Dösinger + + * dlls/wined3d/arb_program_shader.c, dlls/wined3d/baseshader.c, + dlls/wined3d/basetexture.c, dlls/wined3d/device.c, + dlls/wined3d/glsl_shader.c, dlls/wined3d/pixelshader.c, + dlls/wined3d/state.c, dlls/wined3d/surface.c, dlls/wined3d/utils.c: + wined3d: Make the code aware of GL_ARB_texture_rectangle. + +2007-11-26 Stefan Dösinger + + * dlls/wined3d/directx.c, include/wine/wined3d_gl.h: + wined3d: Add GL_ARB_texture_rectangles to our opengl extensions. + + * dlls/wined3d/surface.c: + wined3d: Avoid hardcoding GL_TEXTURE_2D. + + * dlls/wined3d/context.c, dlls/wined3d/surface.c: + wined3d: Disable GL_TEXTURE_2D in the standard blit setup. + +2007-11-28 Rob Shearman + + * dlls/ole32/tests/usrmarshal.c: + ole32: Fix a test in the WdtpInterfacePointer tests. + + * dlls/ole32/tests/usrmarshal.c: + ole32: Fix description of what is being test in ok calls in the + WdtpInterfacePointer tests. + +2007-11-28 Juan Lang + + * dlls/rsaenh/rsaenh.c: + crypt32: Support setting the salt value through KP_SALT_EX. + + * dlls/rsaenh/rsaenh.c: + crypt32: Support getting and setting the KP_PADDING key param. + + * include/wincrypt.h: + wincrypt.h: Add values for KP_PADDING key param. + +2007-11-28 Rob Shearman + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: Fix an integer overflow in NdrConformantStructMarshall and + NdrConformantStructUnmarshall. + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: Fix some more potential buffer overflows. + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: Check there is enough space in the buffer and that the size doesn't + cause an overflow when copying data to it. + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: Check for integer overflows when increasing the buffer length. + Rename safe_buffer_copy to safe_copy_from_buffer. + +2007-11-25 Lionel Debroux + + * dlls/msvcrt/tests/heap.c: + msvcrt: Test more offsets for _aligned_offset_realloc (especially offset > + alignment). + +2007-11-28 Lionel Debroux + + * dlls/msvcrt/heap.c: + msvcrt: Fix _Aligned_offset_realloc (move correct block of memory); add a + comment to explain why. + +2007-11-22 Divan Burger + + * dlls/user32/sysparams.c, tools/wine.inf: + user32, wine.inf: Enable title bar gradients and match colours with win2k. + +2007-11-28 Alistair Leslie-Hughes + + * dlls/urlmon/umstream.c: + urlmon: The callback parameter can be null, check pointer before using. + +2007-11-28 Aric Stewart + + * dlls/winecoreaudio.drv/audio.c: + winecoreaudio: Implement WIDM_GETPOS. + +2007-11-28 Alexandre Julliard + + * dlls/wined3d/arb_program_shader.c, dlls/wined3d/glsl_shader.c, + dlls/wined3d/wined3d_private.h: + wined3d: Add printf format checking to the shader_addline function and fix + resulting warnings. + +2007-11-26 Stefan Dösinger + + * dlls/wined3d/vertexdeclaration.c, dlls/wined3d/vertexshader.c: + wined3d: Fix a sign mistake in the code creating the sorted attrib. + +2007-11-23 Stefan Dösinger + + * dlls/wined3d/surface.c, dlls/wined3d/utils.c, include/wine/wined3d_gl.h: + wined3d: Allow using a different internal format for fbos. + OpenGL drivers do not support some low precision internal formats + like GL_RGB5 for fbo color targets. Direct3D application depend on them, + so provide a fallback format for render targets if the requested format + itself is not supported. + + * dlls/wined3d/directx.c, include/wine/wined3d_gl.h: + wined3d: Report some more geforce 7 cards as geforce 7. + +2007-11-28 Stefan Dösinger + + * dlls/wined3d/state.c: + wined3d: Do not try to disable unsupported texture units. + +2007-11-23 Stefan Dösinger + + * dlls/wined3d/state.c: + wined3d: Add some missing checkGLcall calls. + +2007-11-22 Stefan Dösinger + + * dlls/wined3d/glsl_shader.c: + wined3d: Work around nvidia beta driver bug. + +2007-11-27 Stefan Dösinger + + * dlls/wined3d/surface.c: + wined3d: Inform the texture about filtering changes. + The surface_blt_to_drawable function changes the filtering settings of + the texture object, but without informing the container about this + change. This patch makes sure that the basetexture knows about this and + reapplies the changed states to the settings chosen by the app. + +2007-11-28 Rob Shearman + + * dlls/advapi32/cred.c: + advapi32: Make the credential registry key stay around if a persist value + longer than session is specified. + + * dlls/advapi32/cred.c: + advapi32: Use the open_for_write parameter to open_cred_mgr_key and fix + get_cred_mgr_encryption_key to not need KEY_WRITE access to the key passed in. + +2007-11-27 Juan Lang + + * dlls/rsaenh/rsaenh.c: + rsaenh: Empty container names are allowed for CRYPT_VERIFYCONTEXT contexts. + +2007-11-26 Juan Lang + + * dlls/crypt32/store.c: + crypt32: Add CERT_STORE_ADD_NEWER support to CertAddCertificateContextToStore. + + * dlls/crypt32/cert.c: + crypt32: Implement finding an existing certificate in a store. + +2007-11-28 Michael Stefaniuc + + * dlls/dnsapi/dnsapi.h, dlls/dnsapi/name.c, dlls/dnsapi/query.c, + dlls/dnsapi/record.c: + dnsapi: Rename the wrappers around HeapAlloc() &Co to use the new standard + naming. + + * dlls/shdocvw/events.c, dlls/shdocvw/ie.c, dlls/shdocvw/iexplore.c, + dlls/shdocvw/navigate.c, dlls/shdocvw/shdocvw.h, + dlls/shdocvw/shlinstobj.c, dlls/shdocvw/webbrowser.c: + shdocvw: Rename the wrappers around HeapAlloc() &Co to use the new standard + naming. + +2007-11-27 Rob Shearman + + * dlls/oleaut32/oleaut.c, dlls/oleaut32/tests/vartype.c: + oleaut32: Handle integer overflow of len in SysReAllocStringLen and + SysAllocStringByteLen. + +2007-11-25 Lionel Debroux + + * dlls/ntdll/heap.c: + ntdll: Trace arena magics (may help debugging some heap corruptions). + +2007-11-27 Stefan Leichter + + * dlls/d3dx8/math.c, include/d3dx8math.h, include/d3dx9math.h: + d3dx8: Add WINAPI to the prototypes of D3DXMatrixTransformation. + +2007-11-27 Anatoly Lyutin + + * dlls/msi/dialog.c: + msi: Fix invalid SQL query. + +2007-11-27 Rob Shearman + + * dlls/oleaut32/typelib.c: + oleaut32: Introduce a new helper function, TLB_FreeCustData, for freeing + custom data. + Fix memory leaks caused by the variable and interface custom data not + being freed properly. + + * dlls/oleaut32/typelib.c: + oleaut32: Free the correct custom data inside ITypeInfo_fnRelease. + Since the code is inside the loop for function data, it should be + freeing the function's custom data, not the interface's. + +2007-11-27 Alexandre Julliard + + * server/queue.c: + server: When merging mouse messages ignore the window if it isn't set. + +2007-11-27 Rob Shearman + + * dlls/wininet/http.c: + wininet: Don't clear the auth data for Basic authentication in + HTTP_InsertAuthorizationForHeader. + It isn't tracked per connection, unlike NTLM authentication, and so the + server will return a 401 error and try to get us to authenticate again. + However, this doesn't work as the authentication information is assumed + by the code to be valid for the whole connection. + + * dlls/rpcrt4/tests/ndr_marshall.c: + rpcrt4: Fix the tests for up_enum16. + It is different to the other base types as it has a different size on + the wire to in memory, so it can't just be set to the buffer when + unmarshalling. + + * dlls/credui/tests/credui.c: + credui: Fix a test failure on Windows XP. + +2007-11-27 David Adam + + * include/Makefile.in, include/d3dx9.h, include/d3dx9math.h, + include/d3dx9math.inl: + include: Header files for d3dx9_xx. + +2007-11-21 Stefan Dösinger + + * dlls/wined3d/state.c: + wined3d: Correctly handle the y offset with offscreen rendering. + This fixes a regression introduced with the MAD patch. + +2007-11-20 Stefan Dösinger + + * dlls/wined3d/device.c: + wined3d: Downgrade an ERR to a WARN. + + * dlls/d3d9/tests/visual.c, dlls/wined3d/pixelshader.c: + wined3d: Fog is applied after sRGB correction. + + * dlls/wined3d/pixelshader.c: + wined3d: Make SRGB write correction working with 1.x shaders in arb. + +2007-11-21 Stefan Dösinger + + * dlls/d3d9/tests/visual.c: + d3d9: Add a test for vertex shader input matching. + +2007-11-25 Lauris Kaplinski + + * dlls/wined3d/device.c: + wined3d: Fixed potential reference of freed backBuffer array in + IWineD3DDeviceImpl_SetFrontBackBuffers. + +2007-11-26 Andrew Talbot + + * dlls/gdi32/dc.c: + gdi32: Fix a typo. + + * dlls/dinput/effect_linuxinput.c: + dinput: Use bitwise NOT not logical NOT. + +2007-11-26 Michael Stefaniuc + + * dlls/rpcrt4/rpc_transport.c: + rpcrt4: socket() returns -1 on error so check the return value against that. + + * dlls/wininet/tests/http.c: + wininet/tests: Do not compare the return value of socket() with 0. Use + INVALID_SOCKET instead. + +2007-11-26 Rob Shearman + + * configure, configure.ac, dlls/advapi32/Makefile.in, + dlls/advapi32/cred.c: + advapi32: Add support for using the Mac Keychain services as a backend for + the credential functions instead of the registry. + + * dlls/ole32/ole32.spec, dlls/ole32/tests/usrmarshal.c, + dlls/ole32/usrmarshal.c: + ole32: Add tests for WdtpInterfacePointer_* functions. + Add stubs for these so that the tests link. + + * dlls/ole32/rpc.c: + ole32: Clean up properly in ClientRpcChannelBuffer_SendReceive in the case + where PostMessageW fails. + + * dlls/ole32/rpc.c: + ole32: Store the dispatch parameters in the message state structure to allow + them to be initialised earlier in the sequence of IRpcChannelBuffer calls. + + * dlls/advapi32/cred.c: + advapi32: Fix a typo in CredEnumerateW. + + * dlls/advapi32/cred.c: + advapi32: Move credential registry reading code to separate functions. + +2007-11-26 Huw Davies + + * dlls/inetcomm/mimeole.c, dlls/inetcomm/regsvr.c, + dlls/inetcomm/tests/Makefile.in, dlls/inetcomm/tests/mimeole.c: + inetcomm: Implement IMimeBody:SetData. + + * dlls/inetcomm/mimeole.c, dlls/inetcomm/tests/mimeole.c: + inetcomm: Implement IMimeBody:[G|S]etCurrentEncoding. + + * dlls/inetcomm/mimeole.c, dlls/inetcomm/tests/mimeole.c: + inetcomm: Implement IMimeBody:IsContentType. + + * dlls/inetcomm/mimeole.c: + inetcomm: Store a header's parameters as a list. + + * dlls/inetcomm/mimeole.c: + inetcomm: Unfold headers. + + * dlls/inetcomm/mimeole.c: + inetcomm: Parse headers into a list. + + * dlls/inetcomm/mimeole.c, dlls/inetcomm/tests/mimeole.c: + inetcomm: Copy RFC822 headers into a memory block for later parsing. + +2007-11-21 Vijay Kiran Kamuju + + * include/wincrypt.h: + include: Add missing definitions for DSS in wincrypt.h. + +2007-11-22 Marcus Meissner + + * dlls/shell32/shell32_main.c: + shell32: GetModuleFileNameW gets number of WCHARs not bytes. + +2007-11-22 Gerald Pfeifer + + * dlls/ntdll/reg.c: + ntdll: Fix computation in enumerate_key(). + +2007-11-23 Gerald Pfeifer + + * dlls/inetcomm/internettransport.c: + inetcomm: Fix error check in InternetTransport_Connect(). + +2007-11-22 Gerald Pfeifer + + * dlls/wined3d/arb_program_shader.c: + wined3d: Rewrite condition in vshader_program_add_param() to actually distinguish + between two cases. + + * dlls/itss/chm_lib.c: + itss: Avoid checking an unsigned value for < 0. + + * dlls/winedos/int21.c: + winedos: Use DWORD instead of long for return values of SetFilePointer. + Adjust type of loop variable in INT21_Ioctl_Char(). + + * dlls/netapi32/tests/apibuf.c: + netapi32: Remove one tests and simplify another based on the limited range + of unsigned. + + * dlls/ntdll/sec.c: + ntdll: Simplify condition in RtlGetAce() based on variable (un)signedness. + + * dlls/oleaut32/typelib.c: + oleaut32: Simplify two conditions based on the fact that unsigned variables + cannot be negative. + + * dlls/oleaut32/typelib2.c: + oleaut32: Simplify two conditions based on the fact that unsigned variables + cannot be negative. + +2007-11-21 Gerald Pfeifer + + * dlls/user32/scroll.c: + user32: Fix variable type in SCROLL_HandleScrollEvent(). Remove useless check + in SCROLL_SetScrollInfo(). + +2007-11-25 Patrick Moran + + * programs/msiexec/msiexec.c: + msiexec: Fix atou() return value mistake. + +2007-11-21 Lionel Debroux + + * dlls/msvcrt/tests/heap.c: + msvcrt: Fix memory leak (found by Smatch). + +2007-11-21 David Adam + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXMatrixTransformation. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionExp. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionLn. + +2007-11-20 David Adam + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionRotationYawPitchRoll. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionRotationMatrix. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionRotationAxis. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionToAxisAngle. + +2007-11-25 Jacek Caban + + * dlls/shdocvw/tests/webbrowser.c, dlls/shdocvw/webbrowser.c: + shdocvw: Silence common invalid QueryInterface FIXMEs. + + * dlls/kernel32/tests/virtual.c: + kernel32: Terminate child process in virtual tests. + + * dlls/mshtml/txtrange.c: + mshtml: Added IOleCommandTarget implementation to HTMLTxtRange. + + * dlls/mshtml/htmlstylesheet.c: + mshtml: Added IHTMLStyleSheetsCollection::item implementation. + + * dlls/mshtml/htmldoc.c, dlls/mshtml/htmlstylesheet.c, + dlls/mshtml/mshtml_private.h, dlls/mshtml/nsiface.idl: + mshtml: Store nsIDOMCSSStyleSheet in HTMLStyleSheet object if available. + + * dlls/urlmon/bindctx.c, dlls/urlmon/binding.c, dlls/urlmon/bindprot.c, + dlls/urlmon/file.c, dlls/urlmon/format.c, dlls/urlmon/ftp.c, + dlls/urlmon/http.c, dlls/urlmon/mk.c, dlls/urlmon/regsvr.c, + dlls/urlmon/sec_mgr.c, dlls/urlmon/session.c, dlls/urlmon/umon.c, + dlls/urlmon/umstream.c, dlls/urlmon/urlmon_main.h: + urlmon: Wrap heap functions. + +2007-11-25 James Hawkins + + * dlls/msi/where.c: + msi: Downgrade an ERR to a WARN. + + * dlls/msi/source.c: + msi: Fix the condition of a FIXME. + + * dlls/msi/format.c: + msi: Downgrade an ERR to a WARN. + + * dlls/msi/custom.c: + msi: Downgrade a FIXME to a WARN. + + * dlls/msi/files.c: + msi: Only check the volume label if it's different than the first media's + volume label. + + * dlls/msi/action.c, dlls/msi/files.c, dlls/msi/msipriv.h, + dlls/msi/tests/install.c: + msi: Check the destination file's hash and skip that file if the hash matches. + + * dlls/msi/tests/install.c: + msi: Set the file contents of the file hash test file explicitly. + + * dlls/msi/msi.c, dlls/msi/tests/msi.c: + msi: Verify the szFilePath parameter of MsiGetFileHash. + + * dlls/msi/tests/msi.c: + msi: Add tests for MsiGetFileHash and clean up the existing tests. + +2007-11-25 Vitaliy Margolen + + * dlls/dinput/joystick_linuxinput.c: + dinput: Fix dead zone handling. + +2007-11-22 Andrew Talbot + + * dlls/comdlg32/filedlgbrowser.c: + comdlg32: Use logical OR not bitwise OR. + + * dlls/user32/combo.c: + user32: Fix a typo. + + * dlls/comctl32/theme_combo.c: + comctl32: Fix a typo. + +2007-11-21 Andrew Talbot + + * dlls/user32/menu.c: + user32: Constify some variables. + +2007-11-22 Rob Shearman + + * dlls/kernel32/tests/actctx.c: + kernel32: Change the shared manifest test to depend on a build number that + isn't currently published on at least XP, showing that assemblies with higher + build numbers can be used. + +2007-11-20 Rob Shearman + + * dlls/ntdll/actctx.c: + ntdll: Shared manifests should have a less-strict version check performed when + loading them as dependencies. + +2007-11-22 Rob Shearman + + * dlls/comctl32/commctrl.c: + comctl32: Update the version in the created version to the highest current + version present on XP. + We don't need to create more than one because application dependencies + can be resolved using shared assemblies with higher build and revision + numbers. + + * dlls/ole32/marshal.c: + ole32: Fix a race in find_proxy_manager. + +2007-11-20 Andrew Talbot + + * dlls/user32/listbox.c: + user32: Constify some variables. + +2007-11-21 Alexandre Julliard + + * dlls/wsock32/Makefile.in, dlls/wsock32/wsock32.spec: + wsock32: Forward AcceptEx and GetAcceptExSockaddrs to mswsock. + + * dlls/winex11.drv/winpos.c: + winex11.drv: Make sure to erase the dragging frame before moving the window. + +2007-11-21 Divan Burger + + * dlls/user32/sysparams.c: + user32: Change the desktop colour and pattern to match win2k. + + * dlls/user32/sysparams.c: + user32: Fix colours to match exactly with Windows 2000. + +2007-11-20 Vijay Kiran Kamuju + + * dlls/rsaenh/Makefile.in, dlls/rsaenh/aes.c, dlls/rsaenh/implglue.c, + dlls/rsaenh/implglue.h, dlls/rsaenh/rsaenh.c, + dlls/rsaenh/tests/rsaenh.c, dlls/rsaenh/tomcrypt.h: + rsaenh: Add implementation of Enhanced RSA AES Provider. + + * dlls/rsaenh/tests/rsaenh.c: + rsaenh: Add tests for RSA_AES provider. + +2007-11-16 Alistair Leslie-Hughes + + * dlls/msxml3/tests/domdoc.c: + msxml: Tests for createTextNode. + + * dlls/msxml3/domdoc.c: + msxml: Implement createTextNode. + +2007-11-20 Alistair Leslie-Hughes + + * dlls/msxml3/node.c: + msxml: Always return a string in get_text. + + * dlls/msxml3/tests/domdoc.c: + msxml: Added test for get_text. + +2007-11-21 Jacek Caban + + * dlls/hlink/tests/hlink.c: + hlink: Added HlinkCreateExtensionServices tests. + + * dlls/hlink/Makefile.in, dlls/hlink/extserv.c, dlls/hlink/hlink_main.c: + hlink: Added HlinkCreateExtensionServices implementation. + + * dlls/hlink/browse_ctx.c, dlls/hlink/hlink_main.c, + dlls/hlink/hlink_private.h, dlls/hlink/link.c: + hlink: Wrap heap functions. + + * dlls/hlink/browse_ctx.c, dlls/hlink/hlink_main.c, + dlls/hlink/hlink_private.h, dlls/hlink/link.c: + hlink: Move common includes and function declarations to header file. + + * dlls/hlink/hlink.spec, dlls/hlink/hlink_main.c: + hlink: Added HlinkUpdateStackItem stub. + +2007-11-18 Stefan Dösinger + + * dlls/wined3d/glsl_shader.c: + wined3d: Bool constants aren't vectors. + +2007-11-20 Stefan Dösinger + + * dlls/wined3d/vertexdeclaration.c, dlls/wined3d/vertexshader.c, + dlls/wined3d/wined3d_private.h: + wined3d: Track vertex declaration changes on vertex shaders. + If an attribute has type D3DDECLTYPE_D3DCOLOR, the red and blue channels + are swizzled in the shader. Since the attribute is stored in the vertex + declaration and not the vertex shader, it can change by setting a new + vertex declaration. If this happens, we have to recompile the shader + with the swizzling of that specific attribute turned on or off. + + * dlls/wined3d/arb_program_shader.c, dlls/wined3d/baseshader.c, + dlls/wined3d/glsl_shader.c, dlls/wined3d/pixelshader.c, + dlls/wined3d/vertexshader.c, dlls/wined3d/wined3d_private.h: + wined3d: Move glsl shader destruction to the glsl shader backend. + + * dlls/wined3d/vertexshader.c: + wined3d: Move destroying the glsl vshader into a separate function. + +2007-11-17 Stefan Dösinger + + * dlls/wined3d/directx.c: + wined3d: Do not cap fragment samplers to 8. + +2007-11-21 Alexander Nicolaysen Sørnes + + * programs/winecfg/No.rc: + winecfg: Some fixes for Norwegian translation. + +2007-11-20 José Manuel Ferrer Ortiz + + * programs/winefile/Es.rc: + winefile: Spanish resource file updated. + +2007-11-20 Lei Zhang + + * dlls/shell32/changenotify.c: + shell32: Only notify immediate parent. + + * dlls/shell32/shfldr_unixfs.c: + shell32: Perform copy in UnixFolder_ISFHelper_CopyItems. + +2007-11-20 Rob Shearman + + * dlls/rpcrt4/ndr_marshall.c: + rpcrt4: Raise an exception if a NULL ref-pointer is passed in to PointerMarshall + or PointerBufferSize. + + * server/file.c: + server: Fix incorrect translation of the World SID to and from Unix file + permissions. + The World SID now maps to user|group|other instead of just other. + +2007-11-20 Jonathan Ernst + + * dlls/credui/credui_Fr.rc: + credui: Updated French translation. + + * programs/cmd/Fr.rc: + cmd: Updated French translation. + +2007-11-20 Alexandre Julliard + + * dlls/kernel32/tests/thread.c: + kernel32/tests: Don't crash the test if GetThreadContext fails. + +2007-11-20 Alexander Nicolaysen Sørnes + + * dlls/user32/resources/display.rc, dlls/user32/sysparams.c: + user32: Change to modern Windows colours. + +2007-11-20 Francois Gouget + + * dlls/crypt32/tests/cert.c, dlls/crypt32/tests/chain.c, + dlls/crypt32/tests/crl.c, dlls/crypt32/tests/encode.c, + dlls/crypt32/tests/oid.c, dlls/crypt32/tests/protectdata.c, + dlls/crypt32/tests/store.c: + crypt32/tests: Get the tests running on Windows 98. + + * dlls/ntdll/tests/file.c: + ntdll/tests: Fix compilation on systems that don't support nameless unions. + + * dlls/user32/tests/listbox.c: + user32/tests: Add the trailing '\n' to an ok() call. + +2007-11-19 David Adam + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionBaryCentric. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionSquad. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionSlerp. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionInverse. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXQuaternionMultiply. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXColorAdjustContrast. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXColorAdjustSaturation. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXPlaneTransform. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXPlaneFromPoints. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXPlaneFromPointNormal. + +2007-11-18 Misha Koshelev + + * dlls/msi/automation.c: + msi: automation: Fix ITypeInfo leak. + + * dlls/msi/tests/automation.c: + msi/tests: automation: Add missing VariantClear. + + * dlls/msi/tests/automation.c, dlls/msi/tests/install.c: + msi/tests: Close opened service handles. + + * dlls/msi/automation.c, dlls/msi/script.c: + msi: automation: Fix automation object reference counts when objects are created. + +2007-11-11 Alexander Nicolaysen Sørnes + + * programs/wordpad/Makefile.in, programs/wordpad/print.c, + programs/wordpad/resource.h, programs/wordpad/rsrc.rc, + programs/wordpad/wordpad.c, programs/wordpad/wordpad.h: + wordpad: Move printing functions to a separate file. + +2007-11-19 Alexander Nicolaysen Sørnes + + * programs/wordpad/wordpad.c: + wordpad: Fix print preview bar. + +2007-11-04 Alexander Nicolaysen Sørnes + + * programs/wordpad/De.rc, programs/wordpad/En.rc, programs/wordpad/Fr.rc, + programs/wordpad/Hu.rc, programs/wordpad/Ko.rc, + programs/wordpad/Nl.rc, programs/wordpad/No.rc, + programs/wordpad/Pl.rc, programs/wordpad/Ru.rc, + programs/wordpad/Tr.rc, programs/wordpad/resource.h, + programs/wordpad/wordpad.c: + wordpad: Refer to main menu using IDM_MAINMENU. + +2007-11-20 Rob Shearman + + * server/file.c: + server: Fix a typo in the enumeration of the ACE's in sd_to_mode. + This caused only the first ACE to be examined, causing permissions to + always be set to ----???---. + + * dlls/ntdll/process.c, dlls/ntdll/tests/info.c, + include/wine/server_protocol.h, server/process.c, + server/protocol.def, server/trace.c: + server: Change the get_dll_info server request to allow retrieving the image + file name of a process. + Implement NtQueryInformationProcess(ProcessImageFileName). + +2007-11-20 Jacek Caban + + * dlls/mshtml/navigate.c: + mshtml: Change FIXME that is usually invalid to TRACE. + + * dlls/mshtml/tests/htmldoc.c: + mshtml: Added more loading tests. + + * dlls/mshtml/olecmd.c: + mshtml: Reload page in exec_editmode if available. + + * dlls/mshtml/editor.c: + mshtml: Always initialize output in exec_fontname. + + * dlls/mshtml/olecmd.c: + mshtml: Use call_set_active_object in exec_editmode. + + * dlls/mshtml/mshtml_private.h, dlls/mshtml/view.c: + mshtml: Move IOleInPlaceFrame::SetActiveObject call to separated function. + +2007-11-16 Stefan Dösinger + + * dlls/d3d9/device.c: + d3d9: Free the converted declaration data after creating the declaration. + + * dlls/d3d8/tests/visual.c: + d3d8: Destroy the window after the visual test. + + * dlls/wined3d/device.c, dlls/wined3d/directx.c, dlls/wined3d/palette.c, + dlls/wined3d/resource.c, dlls/wined3d/wined3d_private.h: + wined3d: Use standard wine lists for the resource list. + + * dlls/wined3d/baseshader.c, dlls/wined3d/wined3d_private.h: + wined3d: Free the shader function when freeing the shader. + + * dlls/wined3d/baseshader.c, dlls/wined3d/device.c, + dlls/wined3d/pixelshader.c, dlls/wined3d/vertexshader.c, + dlls/wined3d/wined3d_private.h: + wined3d: Move IUnknown functions to IWineD3DBaseShader. + + * dlls/d3d8/device.c: + d3d8: Release the vertex declarations array when destroying the device. + +2007-11-20 Jacek Caban + + * dlls/shdocvw/tests/webbrowser.c, dlls/shdocvw/webbrowser.c: + shdocvw: Return correct error from WebBrowser::Quit. + + * dlls/shdocvw/tests/webbrowser.c, dlls/shdocvw/webbrowser.c: + shdocvw: Added WebBrowser::get_Application implementation. + +2007-11-19 James Hawkins + + * dlls/msi/files.c: + msi: Check the cabinet's full path for existence, not just the cabinet name. + +2007-11-19 Andrew Talbot + + * dlls/user32/edit.c: + user32: Constify some variables. + +2007-11-19 Rob Shearman + + * dlls/credui/credui_En.rc, dlls/credui/credui_main.c, + dlls/credui/credui_resources.h: + credui: Display a warning balloon if the user has Caps Lock on. + + * dlls/credui/credui_En.rc, dlls/credui/credui_main.c, + dlls/credui/credui_resources.h: + credui: Show a balloon tip in the credential dialog if + CREDUI_FLAGS_INCORRECT_PASSWORD was specified. + + * dlls/urlmon/bindctx.c: + urlmon: Fix a reference count leak in RegisterBindStatusCallback. + + * programs/explorer/systray.c: + explorer: Add a fixme to show when applications are trying to show a balloon + tip in the taskbar notification area. + + * dlls/comctl32/comboex.c: + comctl32: Forward the WM_GETTEXTLENGTH message from ComboEx controls to its + edit control. + + * dlls/comctl32/tooltips.c: + comctl32: Fix the tooltips behaviour when TTF_ABSOLUTE isn't specified. + This does not mean to use the current cursor position. Instead, it means + that the left hand edge of balloon tips doesn't have to be exactly the + co-ordinate passed in (i.e. the stem can be as vertical as possible) and + it means non-balloon tips can use smart placement. + + * dlls/comctl32/tooltips.c: + comctl32: Unify the implementation of TOOLTIPS_Show and TOOLTIPS_TrackShow to + give tracked tooltips balloon support. + +2007-11-19 Jacek Caban + + * dlls/mshtml/nsio.c: + mshtml: Fixed handling channels without container and necko channel. + +2007-11-19 Bang Jun-young + + * dlls/olecli32/olecli_main.c: + olecli32: Fix invalid syntax. + +2007-11-16 Dmitry Timoshkov + + * dlls/winex11.drv/settings.c, programs/explorer/Makefile.in, + programs/explorer/desktop.c: + winex11.drv: Use display device guid managed by explorer. + +2007-11-19 Alexandre Julliard + + * libs/port/spawn.c: + libport: Work around Mac OS execve() breakage. + + * dlls/ntdll/loader.c, dlls/ntdll/server.c: + ntdll: Unblock signals in process init only after the dlls have been imported. + + * dlls/ntdll/loader.c: + ntdll: Send the exit code to the server on failed initialization. + + * dlls/ntdll/loader.c: + ntdll: Initialize the PEB LoaderLock pointer. + +2007-11-19 Michael Stefaniuc + + * tools/widl/server.c, tools/widl/typegen.c, tools/widl/utils.c, + tools/wrc/utils.c: + tools: Remove duplicate includes. + + * dlls/atl/atl_ax.c, dlls/dinput/joystick_linux.c, dlls/dnsapi/ns_name.c, + dlls/quartz/avidec.c, dlls/shell32/shfldr_unixfs.c, + dlls/user32/winpos.c, dlls/uuid/uuid.c, dlls/winmm/mci.c: + dlls: Remove duplicate includes. + + * dlls/setupapi/setupcab.c, dlls/setupapi/setupx_main.c: + setupapi: Remove duplicate includes. + + * dlls/kernel32/kernel_main.c, dlls/kernel32/tests/toolhelp.c: + kernel32: Remove duplicate includes. + + * dlls/ntdll/heap.c, dlls/ntdll/serial.c, dlls/ntdll/signal_powerpc.c: + ntdll: Remove duplicate includes. + + * dlls/comdlg32/filedlg.c, dlls/comdlg32/tests/printdlg.c: + comdlg32: Remove duplicate includes. + + * dlls/quartz/dsoundrender.c, dlls/quartz/filesource.c, + dlls/quartz/parser.c, dlls/quartz/pin.c, dlls/quartz/transform.c, + dlls/quartz/videorenderer.c: + quartz: Fix memory leaks on error paths. Found by Smatch. + + * dlls/qcap/vfwcapture.c: + qcap: Fix a mem leak on an error path. Found by Smatch. + + * dlls/shell32/shfldr_mycomp.c: + shell32: Fix a mem leak on an error path. Found by Smatch. + + * dlls/localspl/tests/localmon.c: + localspl/tests: Use ANSI function declarations. + +2007-11-18 Rob Shearman + + * dlls/credui/credui_main.c: + credui: Override the default banner if the caller specifies one to + CredUIPromptForCredentialsW. + + * dlls/rpcrt4/rpcrt4_main.c: + rpcrt4: Hold the thread-data's critical section while cancelling a call. + Check that there is a connection before trying to cancel it. + +2007-11-18 Hans Leidekker + + * dlls/kernel32/kernel32.spec, dlls/kernel32/volume.c: + kernel32: Add stub implementations for FindFirstVolume{A, W}. + + * dlls/wininet/cookie.c: + wininet: Initialize path buffer in InternetSetCookie. + +2007-11-18 Gerald Pfeifer + + * dlls/advapi32/service.c: + advapi32: Remove untriggerable check. + +2007-11-17 Gerald Pfeifer + + * configure, configure.ac: + configure: Fix typos in warning messages. + + * dlls/rsaenh/tests/rsaenh.c: + rsaenh/tests: Fix const-ness of parameters to printBytes(). + +2007-11-17 Jacek Caban + + * dlls/hlink/tests/hlink.c, dlls/shdocvw/shdocvw.inf: + shdocvw: Set default home and search page. + + * dlls/shdocvw/factory.c, dlls/shdocvw/shdocvw.inf: + shdocvw: Register CLSID_InternetShortcut. + + * dlls/uuid/uuid.c, include/Makefile.in, include/isguids.h: + include: Added isguids.h. + +2007-11-17 Michael Stefaniuc + + * dlls/netapi32/access.c: + netapi32: Remove redundant NULL check before HeapFree(). Found by Smatch. + + * dlls/msvcrt/tests/heap.c: + msvcrt/tests: Remove redundant NULL check before free(). Found by Smatch. + +2007-11-17 Rob Shearman + + * dlls/shell32/shell32.spec, dlls/shell32/shellord.c: + shell32: Add a stub for LinkWindow_UnregisterClass. + + * dlls/shell32/shell32.spec, dlls/shell32/shellord.c: + shell32: Add a stub for LinkWindow_RegisterClass. + + * dlls/credui/credui_main.c: + credui: Make sure not to leave the password in memory when no longer in use. + + * dlls/credui/credui_main.c: + credui: Ensure that the foreground window doesn't get changed while the user + is typing in their password. + This doesn't currently work on Wine as LockSetForegroundWindow isn't + implemented, but when it does it should work nicely. + + * dlls/credui/credui_main.c: + credui: Check for and don't add duplicates when filling the username combo box. + + * dlls/credui/credui_main.c: + credui: Enumerate saved credentials and use these to populate the combo box. + + * dlls/credui/credui_De.rc, dlls/credui/credui_En.rc, + dlls/credui/credui_Ko.rc, dlls/credui/credui_No.rc, + dlls/credui/credui_Pl.rc, dlls/credui/credui_Sv.rc: + credui: Increase the dropped-down size of the username combo box. + + * dlls/credui/credui_main.c: + credui: Split CredDialogProc out into separate functions. + + * dlls/credui/Makefile.in, dlls/credui/credui_main.c: + credui: Add support for saving the credentials input using + CredUIPromptForCredentials by calling CredWriteW. + + * include/winuser.h: + include: Add definitions used for AllowSetForegroundWindow and + LockSetForegroundWindow. + +2007-11-16 James Hawkins + + * dlls/msi/files.c: + msi: Don't check for a cabinet's existence if it's embedded in the package. + +2007-11-16 Thomas Weidenmueller + + * dlls/comctl32/comboex.c: + comctl32: Fix handling of CB_RESETCONTENT in ComboBoxEx. + +2007-11-16 Juan Lang + + * dlls/shell32/shlexec.c: + shell32: Remove a bad comment. + + * dlls/shell32/classes.c: + shell32: Use more restricted registry rights when quering values. + + * dlls/shell32/shlexec.c: + shell32: Dynamically allocate memory for executing an URL. + + * dlls/shell32/shlexec.c: + shell32: Use helper function to execute a URL. + + * dlls/shell32/shlexec.c: + shell32: Dynamically allocate buffer for command. + + * dlls/shell32/shlexec.c: + shell32: Constify some parameters. + + * dlls/shell32/shlexec.c: + shell32: Don't overwrite the caller's buffer when doing a dde connection. + + * dlls/shell32/shlexec.c: + shell32: Dynamically allocate buffer for quoted command. + + * dlls/shell32/shlexec.c: + shell32: Use a helper function for executing a found executable. + + * dlls/shell32/shlexec.c: + shell32: Dynamically allocate directory buffer. + + * dlls/shell32/shlexec.c: + shell32: Use helper function to translate ID list. + + * dlls/shell32/shlexec.c: + shell32: Use a helper function for executing a class. + + * dlls/shell32/shlexec.c: + shell32: Dynamically allocate buffer for command parameters. + + * dlls/iphlpapi/iphlpapi_main.c: + iphlpapi: Correct confusing indentation in GetTcpTable. + + * dlls/iphlpapi/iphlpapi_main.c: + iphlpapi: Correct copy/paste error in GetTcpTable. + +2007-11-15 Stefan Dösinger + + * dlls/msvcrt/mbcs.c, dlls/msvcrt/msvcrt.spec, dlls/msvcrt/tests/string.c: + msvcrt: Implement _mbsnbcpy_s. + +2007-11-16 Stefan Dösinger + + * dlls/msvcrt/msvcrt.spec, dlls/msvcrt/string.c, + dlls/msvcrt/tests/string.c: + msvcrt: Implement strcat_s. + +2007-11-15 Stefan Dösinger + + * dlls/msvcrt/msvcrt.spec, dlls/msvcrt/string.c, + dlls/msvcrt/tests/string.c: + msvcrt: Implement strcpy_s. + +2007-11-15 Gerald Pfeifer + + * programs/winedbg/types.c: + winedbg: Fix type of loop variable in types_udt_find_element(). + +2007-11-15 Vijay Kiran Kamuju + + * dlls/rsaenh/tests/rsaenh.c: + rsaenh: Add a few more tests which check the decryption strings. + +2007-11-14 Stefan Dösinger + + * dlls/wined3d/swapchain.c: + wined3d: Destroy GL contexts before changing the screen resolution. + + * dlls/wined3d/vertexshader.c: + wined3d: Remove a hack that slipped in. + +2007-11-15 Stefan Dösinger + + * dlls/wined3d/surface.c, dlls/wined3d/surface_base.c, + dlls/wined3d/surface_gdi.c, dlls/wined3d/wined3d_private.h, + include/wine/wined3d_interface.h: + wined3d: Do not call PreLoad in surface_download_data. + +2007-11-15 Rob Shearman + + * dlls/mapi32/mapi32.spec, dlls/mapi32/mapi32_main.c: + mapi32: Add a stub for DllGetClassObject. + +2007-11-15 Francois Gouget + + * dlls/d3d9/tests/visual.c: + d3d9/tests: Fix the trailing '\n' in an ok() call. + + * dlls/winex11.drv/opengl.c: + winex11: Add the trailing '\n' to a Wine trace. + +2007-11-15 Juan Lang + + * dlls/iphlpapi/ifenum.c: + iphlpapi: Avoid HEAP_ZERO_MEMORY where it isn't needed. + + * dlls/iphlpapi/ifenum.c: + iphlpapi: Don't allocate gobs of memory if there are no non-loopback interfaces. + + * dlls/iphlpapi/ifenum.c, dlls/iphlpapi/iphlpapi_main.c: + iphlpapi: Don't allocate gobs of memory if the IP address table is empty. + + * dlls/iphlpapi/ifenum.c, dlls/iphlpapi/iphlpapi_main.c: + iphlpapi: Don't allocate gobs of memory if interface table is empty. + + * dlls/iphlpapi/iphlpapi_main.c, dlls/iphlpapi/ipstats.c: + iphlpapi: Don't allocate gobs of memory if the UDP table is empty. + + * dlls/iphlpapi/iphlpapi_main.c, dlls/iphlpapi/ipstats.c: + iphlpapi: Don't allocate gobs of memory when the ARP table is empty. + + * dlls/iphlpapi/iphlpapi_main.c, dlls/iphlpapi/ipstats.c: + iphlpapi: Don't allocate gobs of memory when the route table is empty. + + * dlls/iphlpapi/iphlpapi_main.c, dlls/iphlpapi/ipstats.c: + iphlpapi: Don't allocate gobs of memory when the TCP entry table is empty. + + * dlls/iphlpapi/iphlpapi_main.c: + iphlpapi: Don't override return value from getTcpTable. + + * dlls/iphlpapi/iphlpapi_main.c: + iphlpapi: Default to a default gateway when choosing the best route. + +2007-11-15 David Adam + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXMatrixReflect. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXMatrixShadow. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXPlaneIntersectLine. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXPlaneNormalize. + +2007-11-15 Dmitry Timoshkov + + * dlls/kernel32/tests/file.c: + kernel32: Mask out FILE_ATTRIBUTE_NOT_CONTENT_INDEXED to prevent a test failure + under Windows. + + * dlls/kernel32/file.c, dlls/kernel32/tests/file.c: + kernel32: Set last error to ERROR_ALREADY_EXISTS if CreateFile succeeds and + file existed before for CREATE_ALWAYS and OPEN_ALWAYS. + +2007-11-15 Huw Davies + + * dlls/msxml3/factory.c: + msxml3: Don't leak an interface on failure. + +2007-11-15 Gerald Pfeifer + + * programs/taskmgr/perfdata.c, programs/taskmgr/perfpage.c: + taskmgr: Move out-of-domain checking into PerfDataGetProcessorUsage() and + PerfDataGetProcessorSystemUsage(). + +2007-11-10 Andrey Turkin + + * dlls/ntdll/directory.c, dlls/ntdll/file.c, dlls/ntdll/sync.c, + dlls/ntdll/tests/file.c, dlls/ws2_32/socket.c, + include/wine/server_protocol.h, server/async.c, server/file.h, + server/protocol.def, server/thread.c: + server: Pass Information field from async I/O APCs. + + * dlls/ntdll/directory.c, dlls/ntdll/file.c, dlls/ntdll/ntdll_misc.h, + dlls/ntdll/sync.c, dlls/ntdll/tests/file.c: + ntdll: Make async i/o functions generate completion messages. + + * dlls/ws2_32/socket.c, include/wine/server_protocol.h, server/fd.c, + server/protocol.def, server/request.h, server/trace.c: + ws2_32: Make certain winsock functions generate i/o completion messages. + + * dlls/ntdll/directory.c, dlls/ntdll/file.c, dlls/ws2_32/socket.c, + include/wine/server_protocol.h, server/async.c, server/completion.c, + server/fd.c, server/file.h, server/protocol.def: + server: Allow async i/o operations to send completion messages. + + * dlls/ntdll/tests/file.c: + ntdll: Add some I/O completion tests. + +2007-11-14 Gerald Pfeifer + + * dlls/comctl32/imagelist.c: + comctl32: Remove check which never triggers. + +2007-11-13 Jonathan Ernst + + * programs/wordpad/Fr.rc: + wordpad: Updated French translation. + +2007-11-15 James Hawkins + + * dlls/msi/files.c, dlls/msi/tests/install.c: + msi: Don't ignore the error returned by ready_media. + + * dlls/msi/files.c, dlls/msi/tests/install.c: + msi: Only check the presence of the cabinet if the file is compressed. + + * dlls/msi/tests/install.c: + msi: Add tests for situations involving missing cabinets. + + * dlls/msi/files.c: + msi: Simplify ready_media. + +2007-11-15 Alexandre Julliard + + * tools/wine.inf: + wine.inf: Register inetcomm.dll. + + * tools/wine.inf: + wine.inf: Some dlls need to be registered before the others. + +2007-11-14 Alistair Leslie-Hughes + + * dlls/msxml3/tests/domdoc.c: + msxml: Test for insertBefore with a NULL output parameter. + + * dlls/msxml3/node.c: + msxml: Allow insertBefore to have a NULL output parameter. + +2007-11-14 Andrew Talbot + + * dlls/user32/dde_misc.c, dlls/user32/dde_private.h: + user32: Constify a variable. + +2007-11-10 Alex Villacís Lasso + + * dlls/user32/tests/listbox.c: + user32: Conformance tests for DlgDirList and DlgDirSelectEx. + +2007-11-14 Alex Villacís Lasso + + * dlls/user32/dialog.c: + user32: DlgDirList converts path specification to uppercase. + +2007-11-14 Rob Shearman + + * dlls/ole32/marshal.c: + ole32: Intialise some out parameters in ProxyCliSec_QueryBlanket. + +2007-11-14 Huw Davies + + * dlls/inetcomm/tests/mimeole.c: + inetcomm: Add a test for MimeBody. + + * dlls/inetcomm/inetcomm_main.c: + inetcomm: Add a class factory for MimeBody. + + * dlls/inetcomm/inetcomm_private.h, dlls/inetcomm/mimeole.c: + inetcomm: Add a stub MimeBody implementation. + + * dlls/inetcomm/regsvr.c: + inetcomm: Register a couple more classes. + +2007-11-14 Kirill K. Smirnov + + * programs/wineconsole/dialog.c: + wineconsole: Do not show "Apply" button - it is not used anyway. + +2007-11-14 Hans Leidekker + + * dlls/wininet/cookie.c, dlls/wininet/tests/internet.c: + wininet: Fix a number of problems with InternetGetCookie. + This version incorporates Lei Zhang's changes to the test, with his consent. + + * dlls/wininet/cookie.c, dlls/wininet/tests/internet.c: + wininet: Fix a number of problems with InternetSetCookie. + +2007-11-14 Rob Shearman + + * dlls/msxml3/xmldoc.c: + msxml3: Don't leak node in xmldoc_createElement in the wrong type was specified. + + * dlls/msxml3/tests/xmldoc.c: + msxml3: Fix some memory leaks of name in test_xmldoc. + +2007-11-10 Alex Villacís Lasso + + * dlls/user32/tests/listbox.c: + user32: Conformance tests for LB_DIR on listboxes. + + * dlls/user32/dialog.c: + user32: DlgDirSelect tacks on a period on filenames without ext. + + * dlls/user32/dialog.c: + user32: LB_DIR with standalone DDL_DRIVES implies DDL_EXCLUSIVE. + + * dlls/user32/listbox.c: + user32: Fix returned value of LB_DIR. + +2007-11-14 Alexandre Julliard + + * dlls/comctl32/imagelist.c: + comctl32: Fixed handling of monochrome icons in image lists. + +2007-11-13 Gerald Pfeifer + + * dlls/ws2_32/tests/sock.c: + ws2_32/tests: Fix error checking. + +2007-11-11 Stefan Dösinger + + * dlls/wined3d/directx.c: + wined3d: Fix ATI video memory detection typo. + +2007-11-13 Stefan Dösinger + + * dlls/wined3d/cubetexture.c, dlls/wined3d/device.c, dlls/wined3d/state.c, + dlls/wined3d/texture.c, dlls/wined3d/wined3d_private.h: + wined3d: Non power of two texture fixes. + +2007-11-11 Stefan Dösinger + + * dlls/wined3d/state.c: + wined3d: Apply matrices when switching from transformed vertices to shaders. + +2007-11-10 Stefan Dösinger + + * dlls/wined3d/state.c: + wined3d: Read the framebuffer size from the surface, not the window. + + * dlls/d3d9/device.c, dlls/d3d9/tests/device.c, dlls/wined3d/device.c, + dlls/wined3d/drawprim.c, dlls/wined3d/state.c, + dlls/wined3d/stateblock.c, dlls/wined3d/wined3d_private.h: + wined3d: Depth stencil fixes. + +2007-11-09 Stefan Dösinger + + * dlls/d3d9/tests/visual.c, dlls/wined3d/glsl_shader.c: + wined3d: Partially revert "Get rid of the conditionals in shader_glsl". + + * dlls/wined3d/glsl_shader.c: + wined3d: Get rid of a few Nvidiaisms in glsl shaders. + + * dlls/wined3d/baseshader.c, dlls/wined3d/glsl_shader.c, + dlls/wined3d/pixelshader.c, dlls/wined3d/vertexshader.c, + dlls/wined3d/wined3d_private.h: + wined3d: Hardcode local constants into the shader if possible. + +2007-11-13 Andrew Talbot + + * dlls/user32/dde_client.c: + user32: Constify a variable. + +2007-11-13 Detlef Riekenberg + + * dlls/comctl32/listview.c: + comctl32: Fix a typo in a debug message. + +2007-11-13 Francois Gouget + + * dlls/kernel32/tests/actctx.c: + kernel32/tests: Fix a signed/unsigned warning. + + * dlls/rpcrt4/rpcrt4_main.c, include/rpcdce.h, include/rpcdcep.h: + rpcrt4: Add some missing prototypes and better match the PSDK types. + + * dlls/advpack/tests/install.c: + advpack: Skip some tests if not in interactive mode because they pop up dialogs. + + * dlls/user32/tests/msg.c: + user32/tests/msg: Don't mess up lParam as it is passed on to DefWindowProcA(). + +2007-11-13 Rob Shearman + + * dlls/rpcrt4/rpcrt4_main.c: + rpcrt4: Fix a copy and paste mistake in declaring threaddata_cs_debug. + Reported by Hans Leidekker. + + * dlls/ole32/tests/moniker.c: + ole32: Release the correct pointer in test_MkParseDisplayName. + Reported by Dan Kegel. + + * dlls/ole32/datacache.c, dlls/ole32/tests/ole2.c: + ole32: Validate the parameters to DataCache_Cache. + +2007-11-13 Jonathan Ernst + + * tools/wine.desktop: + wine.desktop: Updated French translation. + + * dlls/avifil32/avifile_Fr.rc: + avifil32: Updated French translation. + + * programs/xcopy/Fr.rc, programs/xcopy/rsrc.rc: + xcopy: Updated French translation. + + * programs/net/Fr.rc, programs/net/rsrc.rc: + net: Updated French translation. + + * dlls/localui/localui.rc, dlls/localui/ui_Fr.rc: + localui: Updated French translation. + + * dlls/credui/credui.rc, dlls/credui/credui_Fr.rc: + credui: Updated French translation. + + * programs/regedit/Fr.rc: + regedit: Updated French translation. + + * programs/cmd/Fr.rc: + cmd: Updated French translation. + + * dlls/shell32/shell32_Fr.rc: + shell32: Updated French translation. + +2007-11-13 Dmitry Timoshkov + + * server/queue.c: + server: Make timer id allocation algorithm conform to the Windows one. + +2007-11-13 Alexandre Julliard + + * programs/winedbg/tgt_active.c: + winedbg: Print a backtrace in --auto mode. + + * dlls/shell32/shelllink.c: + shell32: Don't wait for the command to terminate in ShellLink_InvokeCommand. + + * dlls/shell32/shelllink.c, dlls/shell32/shlexec.c: + shell32: Pass some of the ShellExecute flags through InvokeCommand. + + * include/shellapi.h: + include: Added definition for SEE_MASK_NOASYNC. + +2007-11-11 EA Durbin + + * dlls/kernel32/console.c, dlls/kernel32/kernel32.spec: + kernel32: Add stub for GetConsoleKeyboardLayoutNameW. + + * dlls/kernel32/console.c, dlls/kernel32/kernel32.spec: + kernel32: Add stub implementation of GetConsoleKeyboardLayoutNameA. + + * dlls/kernel32/console.c, dlls/kernel32/kernel32.spec: + kernel32: Add stub implementation of GetConsoleInputExeNameW. + + * dlls/kernel32/console.c, dlls/kernel32/kernel32.spec: + kernel32: Add stub implementation of GetConsoleInputExeNameA. + +2007-11-11 Alistair Leslie-Hughes + + * dlls/msxml3/tests/domdoc.c: + msxml3: Enable test for bad argument / fix memory leak. + + * dlls/msxml3/domdoc.c: + msxml3: Return E_INVALIDARG on bad parameter. + +2007-11-13 Francois Gouget + + * dlls/ctapi32/ctapi32.c: + ctapi32: Use quotes to include our headers. Fixes winapi_check warnings. + + * dlls/setupapi/stubs.c, include/cfgmgr32.h: + cfgmgr32: Flesh out cfgmgr32.h a bit more and fix the corresponding functions. + + * dlls/rpcrt4/ndr_stubless.c: + rpcrt4: Add an API documentation stub to make winapi_check happy. + + * include/d3dx8math.h: + d3dx8: Make d3dx8math.h C++ compatible. + + * dlls/acledit/main.c, include/Makefile.in, include/wfext.h: + acledit: Add wfext.h. + + * dlls/ntoskrnl.exe/ntoskrnl.c: + ntoskrnl: Remove trailing spaces in Wine traces. + + * dlls/wined3d/vertexshader.c: + wined3d: Add trailing '\n's to two shader_addline() calls. + +2007-11-13 James Hawkins + + * dlls/msi/appsearch.c: + msi: Fix the condition for checking a drive. + + * dlls/msi/appsearch.c: + msi: Set the file to NULL when running the directory search. + + * dlls/msi/dialog.c: + msi: Implement the VolumeSelectCombo control. + + * dlls/msi/tests/install.c: + msi: Test the Uninstall registry entries. + + * dlls/msi/action.c, dlls/msi/msipriv.h, dlls/msi/registry.c: + msi: Delete the uninstall key when the product is removed. + +2007-11-12 David Adam + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXMatrixAffine Transformation. + +2007-11-12 Rob Shearman + + * dlls/rpcrt4/rpc_binding.h, dlls/rpcrt4/rpc_message.c, + dlls/rpcrt4/rpc_transport.c, dlls/rpcrt4/rpcrt4_main.c: + rpcrt4: Implement RpcCancelThread for the ncacn_ip_tcp protocol sequence. + +2007-11-12 Lei Zhang + + * dlls/shell32/shellpath.c: + shell32: Don't crash if $HOME is not set. + + * dlls/shell32/shell32_En.rc, dlls/shell32/shellpath.c: + shell32: rename My Video to My Videos. + +2007-11-12 Rob Shearman + + * dlls/ole32/tests/marshal.c: + ole32: Wait forever on the ready_event in the local server tests. + + * dlls/ole32/rpc.c: + ole32: Use asynchronous I/O for the named pipe server for local servers. + + * dlls/ole32/usrmarshal.c: + ole32: Fix the condition in HMETAFILEPICT_UserFree to match that in + METAFILEPICT_UserMarshal. + Actually free the memory. + + * dlls/ole32/tests/hglobalstream.c: + ole32: Fix a memory leak in the HGLOBAL stream tests by telling + CreateStreamOnHGlobal to free the memory it allocates, as we don't free it + ourselves in this test. + + * dlls/ole32/compobj.c: + ole32: Release the stream in COM_RevokeRegisteredClassObject. + + * dlls/ole32/hglobalstream.c: + ole32: Fail before constructing an object in CreateStreamOnHGlobal to avoid + a memory leak. + + * dlls/kernel32/kernel32.spec, dlls/kernel32/thread.c, include/winbase.h: + kernel32: Implement GetThreadId. + +2007-11-12 Jacek Caban + + * dlls/hlink/hlink_main.c, dlls/hlink/tests/hlink.c: + hlink: Added HlinkGetSpecialReference implementation. + + * dlls/shlwapi/shlwapi.spec: + shlwapi: Fixed SHPackDispParamsV spec declaration. + +2007-11-12 Paul Vriens + + * dlls/dsound/tests/propset.c: + dsound/tests: Better check to see if class is not available. + + * dlls/dsound/tests/ds3d8.c: + dsound/tests: Fix test failures on WinXP. + +2007-11-06 Stefan Dösinger + + * dlls/wined3d/directx.c, include/wine/wined3d_gl.h: + wined3d: Load GL_EXT_texture3D from gl 1.2 if the extension is not there. + + * dlls/wined3d/directx.c: + wined3d: Mark extensions supported which are included in the gl core. + +2007-11-11 Stefan Dösinger + + * dlls/wined3d/directx.c: + wined3d: Load GL functions from core if needed. + +2007-11-06 Stefan Dösinger + + * dlls/wined3d/directx.c, include/wine/wined3d_gl.h: + wined3d: Extend the gl extension function loading table with ext info. + + * dlls/wined3d/directx.c: + wined3d: Load extension functions after finding the supported extensions. + + * include/wine/wined3d_gl.h: + wined3d: Align the gl function table. + +2007-11-11 Roderick Colenbrander + + * dlls/gdi32/gdi32.spec, dlls/gdi32/gdi_private.h, dlls/gdi32/opengl.c, + dlls/opengl32/make_opengl, dlls/opengl32/opengl32.spec, + dlls/opengl32/wgl.c, dlls/winex11.drv/opengl.c, + dlls/winex11.drv/winex11.drv.spec: + wgl: Add wglCopyContext support. + +2007-11-09 Peter Beutner + + * dlls/ntdll/signal_i386.c, dlls/ntdll/tests/exception.c: + ntdll: Better trap exception handling. + + * dlls/ntdll/signal_i386.c: + ntdll: Don't try to handle kill(SIGTRAP). + +2007-11-09 Roderick Colenbrander + + * dlls/wined3d/context.c: + wined3d: Prevent unneeded context switches. + +2007-11-08 Roderick Colenbrander + + * dlls/wined3d/surface.c: + wined3d: Flush GL calls after drawing to the drawable. This fixes apps that + use multiple GL contexts. + +2007-11-09 Dan Kegel + + * dlls/user32/dde_client.c, dlls/user32/tests/dde.c: + user32: Implement return value for DdeClientTransaction for XTYP_EXECUTE. + +2007-11-12 Alexandre Julliard + + * dlls/user32/class.c, dlls/user32/dde_client.c, dlls/user32/dde_misc.c, + dlls/user32/hook.c, dlls/user32/input.c, dlls/user32/menu.c, + dlls/user32/message.c, dlls/user32/scroll.c: + user32: Remove a few traces that only duplicate the relay information. + + * dlls/oleaut32/tmarshal.c: + oleaut32: Fixed asm proxys to support more than 128 methods. + Reported by Martin Kochanski. + +2007-11-12 Kai Blin + + * dlls/ws2_32/socket.c, dlls/ws2_32/tests/sock.c: + ws2_32: Cope with buggy apps passing setsockopt optval as a value instead of + a pointer. + +2007-11-12 Alistair Leslie-Hughes + + * dlls/clusapi/clusapi.c: + clusapi: Corrected value in GetNodeClusterState. + +2007-11-11 David Adam + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3DXVec3Unproject. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3XMatrixVec3Project. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3XMatrixMultiplyTranspose. + + * dlls/d3dx8/d3dx8.spec, dlls/d3dx8/math.c, dlls/d3dx8/tests/math.c, + include/d3dx8math.h: + d3dx8: Implement D3XMatrixInverse. + +2007-11-11 Juan Lang + + * dlls/rsaenh/rsaenh.c: + rsaenh: Check pad bytes for consistency when decrypting. + +2007-11-11 Detlef Riekenberg + + * dlls/shell32/undocshell.h, include/shlobj.h: + shell32: Some undocumented defines and functions are now in the PSDK. + +2007-11-11 Hans Leidekker + + * dlls/kernel32/tests/volume.c: + kernel32: Loosen requirements on what QueryDosDevice returns. + +2007-11-10 Maarten Lankhorst + + * dlls/dsound/mixer.c: + dsound: Return primary_done when no mixing needs to be done instead of 0. + +2007-11-11 Maarten Lankhorst + + * dlls/dsound/dsound.c: + dsound: Reassign pointers back to null when destroying structure. + +2007-11-11 Dan Kegel + + * dlls/advapi32/tests/registry.c: + advapi32: Fix buffer overrun in tests/registry.c:wine_debugstr_wn(). + +2007-11-11 Rob Shearman + + * dlls/ntdll/tests/file.c: + ntdll: Initialise the part of the buffer to be written to a file in the + file test. + + * server/winstation.c: + server: In set_user_object_info len is in bytes, not WCHARs. + + * dlls/oleaut32/usrmarshal.c: + oleaut32: Handle non-byref safe arrays in VARIANT_UserFree. + + * dlls/ole32/oleproxy.c: + ole32: Disconnect the IRemUnknown stub buffer before destroying it to release + the reference on the IRemUnknown object. + + * dlls/shell32/shelllink.c: + shell32: Fix a memory leak in Stream_WriteLocationInfo. + + * dlls/shell32/pidl.c: + shell32: Fix the length calculation of the pidl in ILSaveToStream by using + the helper function ILGetSize. + +2007-11-11 Misha Koshelev + + * dlls/urlmon/binding.c: + urlmon: Fix PROTOCOLDATA message passing in IInternetProtocolSink interface + of Binding. + + * dlls/urlmon/http.c: + urlmon: Release IInternetProtocolSink and BindInfo on request handle closure, + not on first handle closure. + +2007-11-10 Tony Wasserka + + * include/d3dx8math.h, include/d3dx8math.inl: + d3dx8: Implement the C++ stuff of the D3DXCOLOR structure. + + * include/d3dx8math.h, include/d3dx8math.inl: + d3dx8: Implement the C++ stuff of the D3DXPLANE structure. + + * include/d3dx8math.h, include/d3dx8math.inl: + d3dx8: Implement the C++ stuff of the D3DXQUATERNION structure. + + * include/d3dx8math.h, include/d3dx8math.inl: + d3dx8: Implement the C++ stuff of the D3DXMATRIX structure. + +2007-11-09 Tony Wasserka + + * include/d3dx8math.h, include/d3dx8math.inl: + d3dx8: Implement the C++ stuff of the D3DXVECTOR4 structure. + + * include/d3dx8math.h, include/d3dx8math.inl: + d3dx8: Implement the C++ stuff of the D3DXVECTOR3 structure. + + * include/d3dx8math.h, include/d3dx8math.inl: + d3dx8: Implement the C++ stuff of the D3DXVECTOR2 structure. + +2007-11-12 Dmitry Timoshkov + + * dlls/winex11.drv/keyboard.c: + winex11.drv: Get rid of unused variables. + +2007-11-12 Jacek Caban + + * dlls/shlwapi/ordinal.c: + shlwapi: Reimplement IUnknown_CPContainerInvokeParam on top of SHPackDispParams. + + * dlls/shlwapi/tests/ordinal.c: + shlwapi: Added SHPackDispParams test. + + * dlls/shlwapi/ordinal.c, dlls/shlwapi/shlwapi.spec: + shlwapi: Added SHPackDispParams implementation. + + * dlls/shlwapi/ordinal.c: + shlwapi: Added SHPackDispParamsV implementation. + + * include/hlink.idl: + hlink.idl: Added Hlink[Get|Set]SpecialReference declaration. + + * dlls/mshtml/olewnd.c: + mshtml: Remove nsIWebBrowserFocus_Activate useless call. + + * dlls/mshtml/editor.c, dlls/mshtml/mshtml_private.h, + dlls/mshtml/nsembed.c, dlls/mshtml/nsevents.c: + mshtml: Reset focus after loading the page in edit mode. + +2007-11-11 James Hawkins + + * dlls/msi/database.c, dlls/msi/msipriv.h, dlls/msi/msiquery.c, + dlls/msi/msiserver.idl, dlls/msi/package.c, dlls/msi/preview.c, + dlls/msi/suminfo.c: + msi: Return a remote interface to the database in a custom action. + + * dlls/msi/database.c, dlls/msi/tests/db.c: + msi: Create the _Tables table when creating a database. + + * dlls/msi/tests/db.c: + msi: Test the default tables added by MsiOpenDatabase. + +2007-11-10 Rob Shearman + + * dlls/ole32/compobj.c: + ole32: Free the memory associated with the open DLL list on unloading of ole32. + + * dlls/ole32/datacache.c: + ole32: Initialise data_cf in DataCacheEntry's to zero to indicate no data + present on creation. + + * dlls/ole32/tests/ole2.c: + ole32: Fix a leak of a moniker object in test_default_handler. + + * dlls/ole32/datacache.c: + ole32: Fix a memory leak in DataCacheEntry_Save. + + * dlls/ole32/moniker.c: + ole32: Fix a memory leak of moniker in RunningObjectTableImpl_Register. + + * dlls/ole32/filemoniker.c: + ole32: Fix a leak of the IBindCtx object in FileMonikerImpl_IsEqual. + + * dlls/ole32/moniker.c: + ole32: Fix a memory leak in get_moniker_comparison_data. + + * dlls/ole32/moniker.c: + ole32: Store the InterfaceList object in the IEnumMoniker object. + This is because the IEnumMoniker object is supposed to free the memory + passed to it, but the array of InterfaceData pointers is inside the + InterfaceList memory block. + + * dlls/ole32/tests/moniker.c: + ole32: Add a missing IMoniker_Release to test_MkParseDisplayName. + + * dlls/ole32/itemmoniker.c: + ole32: Fix memory leak in ItemMonikerImpl_Save. + + * dlls/ole32/tests/marshal.c: + ole32: Add a missing IStream_Release to test_same_apartment_unmarshal_failure. + + * dlls/ole32/tests/compobj.c: + ole32: Add a missing IStream_Release to + test_CoMarshalInterThreadInterfaceInStream. + +2007-11-11 Andrew Talbot + + * dlls/user32/comm16.c: + user32: Constify some variables. + +2007-11-11 Hans Leidekker + + * dlls/wininet/tests/http.c: + wininet: Fix two handle leaks in the test. + + * dlls/snmpapi/tests/util.c: + snmpapi: Make a test pass on Vista. + + * dlls/pdh/tests/pdh.c: + pdh: Make two tests pass on Vista. + +2007-11-10 Paul Vriens + + * dlls/dsound/tests/capture.c: + dsound/tests: Fix tests after addition of 24/32 bits buffer tests. + +2007-11-09 Maarten Lankhorst + + * dlls/dsound/sound3d.c: + dsound: Make AngleBetweenVectorsRad when vectors have no magnitude. + + * dlls/dsound/sound3d.c: + dsound: Implement AngleBetweenVectorsDeg as a call to AngleBetweenVectorsRad. + +2007-11-09 Paul Millar + + * libs/wine/config.c: + libwine: Fix naked getuid() to allow compilation under MinGW. + +2007-11-09 Alexandre Julliard + + * ANNOUNCE, ChangeLog, VERSION, configure: + Release 0.9.49. + +---------------------------------------------------------------- 2007-11-09 Alexandre Julliard * dlls/user32/tests/dde.c: diff --git a/VERSION b/VERSION index 47be02b18f7..45ba353fc75 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Wine version 0.9.49 +Wine version 0.9.50 diff --git a/configure b/configure index de3508e84e2..20656cefea7 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for Wine 0.9.49. +# Generated by GNU Autoconf 2.61 for Wine 0.9.50. # # Report bugs to . # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='Wine' PACKAGE_TARNAME='wine' -PACKAGE_VERSION='0.9.49' -PACKAGE_STRING='Wine 0.9.49' +PACKAGE_VERSION='0.9.50' +PACKAGE_STRING='Wine 0.9.50' PACKAGE_BUGREPORT='wine-devel@winehq.org' ac_unique_file="server/atom.c" @@ -724,6 +724,7 @@ LDD DLLTOOL DLLWRAP MINGWAR +SECURITYLIB COREFOUNDATIONLIB IOKITLIB LDEXECFLAGS @@ -1290,7 +1291,7 @@ if test "$ac_init_help" = "long"; then # 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 0.9.49 to adapt to many kinds of systems. +\`configure' configures Wine 0.9.50 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1359,7 +1360,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Wine 0.9.49:";; + short | recursive ) echo "Configuration of Wine 0.9.50:";; esac cat <<\_ACEOF @@ -1455,7 +1456,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Wine configure 0.9.49 +Wine configure 0.9.50 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1469,7 +1470,7 @@ cat >config.log <<_ACEOF 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 0.9.49, which was +It was created by Wine $as_me 0.9.50, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -8114,7 +8115,9 @@ fi LDSHARED="\$(CC) -dynamiclib" STRIP="$STRIP -x" LDRPATH_LOCAL="&& install_name_tool -change @executable_path/\`\$(RELPATH) \$(bindir) \$(libdir)\`/libwine.1.dylib @executable_path/\$(TOPOBJDIR)/libs/wine/libwine.1.dylib \$@ || \$(RM) \$@" - COREFOUNDATIONLIB="-framework CoreFoundation" + SECURITYLIB="-framework Security -framework CoreFoundation" + + COREFOUNDATIONLIB="-framework CoreFoundation" IOKITLIB="-framework IOKit -framework CoreFoundation" @@ -21662,7 +21665,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Wine $as_me 0.9.49, which was +This file was extended by Wine $as_me 0.9.50, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21715,7 +21718,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -Wine config.status 0.9.49 +Wine config.status 0.9.50 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" @@ -22437,6 +22440,7 @@ LDD!$LDD$ac_delim DLLTOOL!$DLLTOOL$ac_delim DLLWRAP!$DLLWRAP$ac_delim MINGWAR!$MINGWAR$ac_delim +SECURITYLIB!$SECURITYLIB$ac_delim COREFOUNDATIONLIB!$COREFOUNDATIONLIB$ac_delim IOKITLIB!$IOKITLIB$ac_delim LDEXECFLAGS!$LDEXECFLAGS$ac_delim @@ -22485,7 +22489,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 73; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 74; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.ac b/configure.ac index f84720916a3..80c3f6d7b28 100644 --- a/configure.ac +++ b/configure.ac @@ -399,6 +399,7 @@ case $host_os in STRIP="$STRIP -x" LDRPATH_LOCAL="&& install_name_tool -change @executable_path/\`\$(RELPATH) \$(bindir) \$(libdir)\`/libwine.1.dylib @executable_path/\$(TOPOBJDIR)/libs/wine/libwine.1.dylib \$@ || \$(RM) \$@" dnl declare needed frameworks + AC_SUBST(SECURITYLIB,"-framework Security -framework CoreFoundation") AC_SUBST(COREFOUNDATIONLIB,"-framework CoreFoundation") AC_SUBST(IOKITLIB,"-framework IOKit -framework CoreFoundation") AC_SUBST(LDEXECFLAGS,["-image_base 0x7bf00000 -Wl,-segaddr,WINE_DOS,0x00000000,-segaddr,WINE_SHARED_HEAP,0x7f000000"]) diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in index 77d53dcca09..2c68895449d 100644 --- a/dlls/advapi32/Makefile.in +++ b/dlls/advapi32/Makefile.in @@ -6,6 +6,7 @@ VPATH = @srcdir@ MODULE = advapi32.dll IMPORTLIB = libadvapi32.$(IMPLIBEXT) IMPORTS = kernel32 ntdll +EXTRALIBS = @SECURITYLIB@ C_SRCS = \ advapi.c \ diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index 97241132ae7..1a346b5a105 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -96,7 +96,7 @@ @ stdcall CreateProcessAsUserA(long str str ptr ptr long long ptr str ptr ptr) # @ stub CreateProcessAsUserSecure @ stdcall CreateProcessAsUserW(long str str ptr ptr long long ptr str ptr ptr) -# @ stub CreateProcessWithLogonW +@ stdcall CreateProcessWithLogonW(wstr wstr wstr long wstr wstr long ptr wstr ptr ptr) # @ stub CreateRestrictedToken @ stdcall CreateServiceA(long ptr ptr long long long long ptr ptr ptr ptr ptr ptr) @ stdcall CreateServiceW (long ptr ptr long long long long ptr ptr ptr ptr ptr ptr) diff --git a/dlls/advapi32/cred.c b/dlls/advapi32/cred.c index d15141259c8..b5c99f64829 100644 --- a/dlls/advapi32/cred.c +++ b/dlls/advapi32/cred.c @@ -19,6 +19,7 @@ */ #include +#include #include "windef.h" #include "winbase.h" @@ -26,6 +27,12 @@ #include "wincred.h" #include "winternl.h" +#ifdef __APPLE__ +# include +# include +# include +#endif + #include "crypt.h" #include "wine/unicode.h" @@ -85,8 +92,9 @@ static DWORD read_credential_blob(HKEY hkey, const BYTE key_data[KEY_SIZE], return ERROR_SUCCESS; } -static DWORD read_credential(HKEY hkey, PCREDENTIALW credential, - const BYTE key_data[KEY_SIZE], char *buffer, DWORD *len) +static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW credential, + const BYTE key_data[KEY_SIZE], + char *buffer, DWORD *len) { DWORD type; DWORD ret; @@ -231,6 +239,200 @@ static DWORD read_credential(HKEY hkey, PCREDENTIALW credential, return ret; } +#ifdef __APPLE__ +static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require_password, + PCREDENTIALW credential, char *buffer, + DWORD *len) +{ + OSStatus status; + UInt32 i; + UInt32 cred_blob_len; + void *cred_blob; + LPWSTR domain = NULL; + LPWSTR user = NULL; + SecKeychainAttributeInfo info; + SecKeychainAttributeList *attr_list; + UInt32 info_tags[] = { kSecServerItemAttr, kSecSecurityDomainItemAttr, kSecAccountItemAttr, + kSecCommentItemAttr, kSecCreationDateItemAttr }; + info.count = sizeof(info_tags)/sizeof(info_tags[0]); + info.tag = info_tags; + info.format = NULL; + status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, &cred_blob_len, &cred_blob); + if (status == errSecAuthFailed && !require_password) + { + cred_blob_len = 0; + cred_blob = NULL; + status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, &cred_blob_len, NULL); + } + if (status != noErr) + { + WARN("SecKeychainItemCopyAttributesAndData returned status %ld\n", status); + return ERROR_NOT_FOUND; + } + if (buffer) + { + credential->Flags = 0; + credential->Type = CRED_TYPE_DOMAIN_PASSWORD; + credential->TargetName = NULL; + credential->Comment = NULL; + memset(&credential->LastWritten, 0, sizeof(credential->LastWritten)); + credential->CredentialBlobSize = 0; + credential->CredentialBlob = NULL; + credential->Persist = CRED_PERSIST_LOCAL_MACHINE; + credential->AttributeCount = 0; + credential->Attributes = NULL; + credential->TargetAlias = NULL; + credential->UserName = NULL; + } + for (i = 0; i < attr_list->count; i++) + { + switch (attr_list->attr[i].tag) + { + case kSecServerItemAttr: + TRACE("kSecServerItemAttr: %.*s\n", (int)attr_list->attr[i].length, + (char *)attr_list->attr[i].data); + if (!attr_list->attr[i].data) continue; + if (buffer) + { + INT str_len; + credential->TargetName = (LPWSTR)buffer; + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, (LPWSTR)buffer, 0xffff); + credential->TargetName[str_len] = '\0'; + buffer += (str_len + 1) * sizeof(WCHAR); + *len += (str_len + 1) * sizeof(WCHAR); + } + else + { + INT str_len; + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, NULL, 0); + *len += (str_len + 1) * sizeof(WCHAR); + } + break; + case kSecAccountItemAttr: + { + INT str_len; + TRACE("kSecAccountItemAttr: %.*s\n", (int)attr_list->attr[i].length, + (char *)attr_list->attr[i].data); + if (!attr_list->attr[i].data) continue; + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, NULL, 0); + user = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, user, str_len); + user[str_len] = '\0'; + break; + } + case kSecCommentItemAttr: + TRACE("kSecCommentItemAttr: %.*s\n", (int)attr_list->attr[i].length, + (char *)attr_list->attr[i].data); + if (!attr_list->attr[i].data) continue; + if (buffer) + { + INT str_len; + credential->Comment = (LPWSTR)buffer; + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, (LPWSTR)buffer, 0xffff); + credential->Comment[str_len] = '\0'; + buffer += (str_len + 1) * sizeof(WCHAR); + *len += (str_len + 1) * sizeof(WCHAR); + } + else + { + INT str_len; + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, NULL, 0); + *len += (str_len + 1) * sizeof(WCHAR); + } + break; + case kSecSecurityDomainItemAttr: + { + INT str_len; + TRACE("kSecSecurityDomainItemAttr: %.*s\n", (int)attr_list->attr[i].length, + (char *)attr_list->attr[i].data); + if (!attr_list->attr[i].data) continue; + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, NULL, 0); + domain = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, + attr_list->attr[i].length, domain, str_len); + domain[str_len] = '\0'; + break; + } + case kSecCreationDateItemAttr: + TRACE("kSecCreationDateItemAttr: %.*s\n", (int)attr_list->attr[i].length, + (char *)attr_list->attr[i].data); + if (buffer) + { + LARGE_INTEGER win_time; + struct tm tm; + time_t time; + memset(&tm, 0, sizeof(tm)); + strptime(attr_list->attr[i].data, "%Y%m%d%H%M%SZ", &tm); + time = mktime(&tm); + RtlSecondsSince1970ToTime(time, &win_time); + credential->LastWritten.dwLowDateTime = win_time.u.LowPart; + credential->LastWritten.dwHighDateTime = win_time.u.HighPart; + } + break; + } + } + + if (user) + { + INT str_len; + if (buffer) + credential->UserName = (LPWSTR)buffer; + if (domain) + { + str_len = strlenW(domain); + *len += (str_len + 1) * sizeof(WCHAR); + if (buffer) + { + memcpy(credential->UserName, domain, str_len * sizeof(WCHAR)); + /* FIXME: figure out when to use an '@' */ + credential->UserName[str_len] = '\\'; + buffer += (str_len + 1) * sizeof(WCHAR); + } + } + str_len = strlenW(user); + *len += (str_len + 1) * sizeof(WCHAR); + if (buffer) + { + memcpy(buffer, user, (str_len + 1) * sizeof(WCHAR)); + buffer += (str_len + 1) * sizeof(WCHAR); + TRACE("UserName = %s\n", debugstr_w(credential->UserName)); + } + } + HeapFree(GetProcessHeap(), 0, user); + HeapFree(GetProcessHeap(), 0, domain); + + if (cred_blob) + { + if (buffer) + { + INT str_len; + credential->CredentialBlob = (BYTE *)buffer; + str_len = MultiByteToWideChar(CP_UTF8, 0, cred_blob, cred_blob_len, + (LPWSTR)buffer, 0xffff); + credential->CredentialBlobSize = str_len * sizeof(WCHAR); + buffer += str_len * sizeof(WCHAR); + *len += str_len * sizeof(WCHAR); + } + else + { + INT str_len; + str_len = MultiByteToWideChar(CP_UTF8, 0, cred_blob, cred_blob_len, + NULL, 0); + *len += str_len * sizeof(WCHAR); + } + } + SecKeychainItemFreeAttributesAndData(attr_list, cred_blob); + return ERROR_SUCCESS; +} +#endif + static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type, const BYTE key_data[KEY_SIZE], const BYTE *credential_blob, DWORD credential_blob_size) @@ -257,8 +459,8 @@ static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type, return ret; } -static DWORD write_credential(HKEY hkey, const CREDENTIALW *credential, - const BYTE key_data[KEY_SIZE], BOOL preserve_blob) +static DWORD registry_write_credential(HKEY hkey, const CREDENTIALW *credential, + const BYTE key_data[KEY_SIZE], BOOL preserve_blob) { DWORD ret; FILETIME LastWritten; @@ -308,11 +510,121 @@ static DWORD write_credential(HKEY hkey, const CREDENTIALW *credential, return ret; } +#ifdef __APPLE__ +static DWORD mac_write_credential(const CREDENTIALW *credential, BOOL preserve_blob) +{ + OSStatus status; + SecKeychainItemRef keychain_item; + char *username; + char *domain = NULL; + char *password; + char *servername; + UInt32 userlen; + UInt32 domainlen = 0; + UInt32 pwlen; + UInt32 serverlen; + LPCWSTR p; + SecKeychainAttribute attrs[1]; + SecKeychainAttributeList attr_list; + + if (credential->Flags) + FIXME("Flags 0x%x not written\n", credential->Flags); + if (credential->Type != CRED_TYPE_DOMAIN_PASSWORD) + FIXME("credential type of %d not supported\n", credential->Type); + if (credential->Persist != CRED_PERSIST_LOCAL_MACHINE) + FIXME("persist value of %d not supported\n", credential->Persist); + if (credential->AttributeCount) + FIXME("custom attributes not supported\n"); + + p = strchrW(credential->UserName, '\\'); + if (p) + { + domainlen = WideCharToMultiByte(CP_UTF8, 0, credential->UserName, + p - credential->UserName, NULL, 0, NULL, NULL); + domain = HeapAlloc(GetProcessHeap(), 0, (domainlen + 1) * sizeof(*domain)); + WideCharToMultiByte(CP_UTF8, 0, credential->UserName, p - credential->UserName, + domain, domainlen, NULL, NULL); + domain[domainlen] = '\0'; + p++; + } + else + p = credential->UserName; + userlen = WideCharToMultiByte(CP_UTF8, 0, p, -1, NULL, 0, NULL, NULL); + username = HeapAlloc(GetProcessHeap(), 0, userlen * sizeof(*username)); + WideCharToMultiByte(CP_UTF8, 0, p, -1, username, userlen, NULL, NULL); + + serverlen = WideCharToMultiByte(CP_UTF8, 0, credential->TargetName, -1, NULL, 0, NULL, NULL); + servername = HeapAlloc(GetProcessHeap(), 0, serverlen * sizeof(*servername)); + WideCharToMultiByte(CP_UTF8, 0, credential->TargetName, -1, servername, serverlen, NULL, NULL); + pwlen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)credential->CredentialBlob, + credential->CredentialBlobSize / sizeof(WCHAR), NULL, 0, NULL, NULL); + password = HeapAlloc(GetProcessHeap(), 0, pwlen * sizeof(*domain)); + WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)credential->CredentialBlob, + credential->CredentialBlobSize / sizeof(WCHAR), password, pwlen, NULL, NULL); + + TRACE("adding server %s, domain %s, username %s using Keychain\n", servername, domain, username); + status = SecKeychainAddInternetPassword(NULL, strlen(servername), servername, + strlen(domain), domain, strlen(username), + username, 0, NULL, 0, + 0 /* no protocol */, + kSecAuthenticationTypeDefault, + strlen(password), password, &keychain_item); + if (status != noErr) + ERR("SecKeychainAddInternetPassword returned %ld\n", status); + if (status == errSecDuplicateItem) + { + SecKeychainItemRef keychain_item; + + status = SecKeychainFindInternetPassword(NULL, strlen(servername), servername, + strlen(domain), domain, + strlen(username), username, + 0, NULL /* any path */, 0, + 0 /* any protocol */, + 0 /* any authentication type */, + 0, NULL, &keychain_item); + if (status != noErr) + ERR("SecKeychainFindInternetPassword returned %ld\n", status); + } + HeapFree(GetProcessHeap(), 0, domain); + HeapFree(GetProcessHeap(), 0, username); + HeapFree(GetProcessHeap(), 0, servername); + if (status != noErr) + { + HeapFree(GetProcessHeap(), 0, password); + return ERROR_GEN_FAILURE; + } + if (credential->Comment) + { + attr_list.count = 1; + attr_list.attr = attrs; + attrs[0].tag = kSecCommentItemAttr; + attrs[0].length = WideCharToMultiByte(CP_UTF8, 0, credential->Comment, -1, NULL, 0, NULL, NULL); + if (attrs[0].length) attrs[0].length--; + attrs[0].data = HeapAlloc(GetProcessHeap(), 0, attrs[0].length); + WideCharToMultiByte(CP_UTF8, 0, credential->Comment, -1, attrs[0].data, attrs[0].length, NULL, NULL); + } + else + { + attr_list.count = 0; + attr_list.attr = NULL; + } + status = SecKeychainItemModifyAttributesAndData(keychain_item, &attr_list, + preserve_blob ? 0 : strlen(password), + preserve_blob ? NULL : password); + if (credential->Comment) + HeapFree(GetProcessHeap(), 0, attrs[0].data); + HeapFree(GetProcessHeap(), 0, password); + /* FIXME: set TargetAlias attribute */ + CFRelease(keychain_item); + return ERROR_SUCCESS; +} +#endif + static DWORD open_cred_mgr_key(HKEY *hkey, BOOL open_for_write) { return RegCreateKeyExW(HKEY_CURRENT_USER, wszCredentialManagerKey, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ | KEY_WRITE, NULL, hkey, NULL); + KEY_READ | (open_for_write ? KEY_WRITE : 0), NULL, hkey, NULL); } static DWORD get_cred_mgr_encryption_key(HKEY hkeyMgr, BYTE key_data[KEY_SIZE]) @@ -348,8 +660,19 @@ static DWORD get_cred_mgr_encryption_key(HKEY hkeyMgr, BYTE key_data[KEY_SIZE]) value = RtlUniform(&seed); *(DWORD *)(key_data + 4) = value; - return RegSetValueExW(hkeyMgr, wszEncryptionKeyValue, 0, REG_BINARY, - (LPVOID)key_data, KEY_SIZE); + ret = RegSetValueExW(hkeyMgr, wszEncryptionKeyValue, 0, REG_BINARY, + (LPVOID)key_data, KEY_SIZE); + if (ret == ERROR_ACCESS_DENIED) + { + ret = open_cred_mgr_key(&hkeyMgr, TRUE); + if (ret == ERROR_SUCCESS) + { + ret = RegSetValueExW(hkeyMgr, wszEncryptionKeyValue, 0, REG_BINARY, + (LPVOID)key_data, KEY_SIZE); + RegCloseKey(hkeyMgr); + } + } + return ret; } static LPWSTR get_key_name_for_target(LPCWSTR target_name, DWORD type) @@ -384,6 +707,210 @@ static LPWSTR get_key_name_for_target(LPCWSTR target_name, DWORD type) return key_name; } +static BOOL credential_matches_filter(HKEY hkeyCred, LPCWSTR filter) +{ + LPWSTR target_name; + DWORD ret; + DWORD type; + DWORD count; + LPCWSTR p; + + if (!filter) return TRUE; + + ret = RegQueryValueExW(hkeyCred, NULL, 0, &type, NULL, &count); + if (ret != ERROR_SUCCESS) + return FALSE; + else if (type != REG_SZ) + return FALSE; + + target_name = HeapAlloc(GetProcessHeap(), 0, count); + if (!target_name) + return FALSE; + ret = RegQueryValueExW(hkeyCred, NULL, 0, &type, (LPVOID)target_name, &count); + if (ret != ERROR_SUCCESS || type != REG_SZ) + { + HeapFree(GetProcessHeap(), 0, target_name); + return FALSE; + } + + TRACE("comparing filter %s to target name %s\n", debugstr_w(filter), + debugstr_w(target_name)); + + p = strchrW(filter, '*'); + ret = CompareStringW(GetThreadLocale(), 0, filter, + (p && !p[1] ? p - filter : -1), target_name, + (p && !p[1] ? p - filter : -1)) == CSTR_EQUAL; + + HeapFree(GetProcessHeap(), 0, target_name); + return ret; +} + +static DWORD registry_enumerate_credentials(HKEY hkeyMgr, LPCWSTR filter, + LPWSTR target_name, + DWORD target_name_len, BYTE key_data[KEY_SIZE], + PCREDENTIALW *credentials, char **buffer, + DWORD *len, DWORD *count) +{ + DWORD i; + DWORD ret; + for (i = 0;; i++) + { + HKEY hkeyCred; + ret = RegEnumKeyW(hkeyMgr, i, target_name, target_name_len+1); + if (ret == ERROR_NO_MORE_ITEMS) + { + ret = ERROR_SUCCESS; + break; + } + else if (ret != ERROR_SUCCESS) + { + ret = ERROR_SUCCESS; + continue; + } + TRACE("target_name = %s\n", debugstr_w(target_name)); + ret = RegOpenKeyExW(hkeyMgr, target_name, 0, KEY_QUERY_VALUE, &hkeyCred); + if (ret != ERROR_SUCCESS) + { + ret = ERROR_SUCCESS; + continue; + } + if (!credential_matches_filter(hkeyCred, filter)) + { + RegCloseKey(hkeyCred); + continue; + } + if (buffer) + { + *len = sizeof(CREDENTIALW); + credentials[*count] = (PCREDENTIALW)*buffer; + } + else + *len += sizeof(CREDENTIALW); + ret = registry_read_credential(hkeyCred, buffer ? credentials[*count] : NULL, + key_data, buffer ? *buffer + sizeof(CREDENTIALW) : NULL, + len); + RegCloseKey(hkeyCred); + if (ret != ERROR_SUCCESS) break; + if (buffer) *buffer += *len; + (*count)++; + } + return ret; +} + +#ifdef __APPLE__ +static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW *credentials, + char *buffer, DWORD *len, DWORD *count) +{ + SecKeychainSearchRef search; + SecKeychainItemRef item; + OSStatus status; + Boolean saved_user_interaction_allowed; + DWORD ret; + + SecKeychainGetUserInteractionAllowed(&saved_user_interaction_allowed); + SecKeychainSetUserInteractionAllowed(false); + + status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search); + if (status == noErr) + { + while (SecKeychainSearchCopyNext(search, &item) == noErr) + { + SecKeychainAttributeInfo info; + SecKeychainAttributeList *attr_list; + UInt32 info_tags[] = { kSecServerItemAttr }; + info.count = sizeof(info_tags)/sizeof(info_tags[0]); + info.tag = info_tags; + info.format = NULL; + status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, NULL, NULL); + if (status != noErr) + { + WARN("SecKeychainItemCopyAttributesAndData returned status %ld\n", status); + continue; + } + if (buffer) + { + *len = sizeof(CREDENTIALW); + credentials[*count] = (PCREDENTIALW)buffer; + } + else + *len += sizeof(CREDENTIALW); + if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServerItemAttr) continue; + TRACE("server item: %.*s\n", (int)attr_list->attr[0].length, (char *)attr_list->attr[0].data); + /* FIXME: filter based on attr_list->attr[0].data */ + SecKeychainItemFreeAttributesAndData(attr_list, NULL); + ret = mac_read_credential_from_item(item, FALSE, + buffer ? credentials[*count] : NULL, + buffer ? buffer + sizeof(CREDENTIALW) : NULL, + len); + CFRelease(item); + if (ret == ERROR_SUCCESS) + { + (*count)++; + if (buffer) buffer += *len; + } + } + CFRelease(search); + } + else + ERR("SecKeychainSearchCreateFromAttributes returned status %ld\n", status); + SecKeychainSetUserInteractionAllowed(saved_user_interaction_allowed); + return ERROR_SUCCESS; +} + +static DWORD mac_delete_credential(LPCWSTR TargetName) +{ + OSStatus status; + SecKeychainSearchRef search; + status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search); + if (status == noErr) + { + SecKeychainItemRef item; + while (SecKeychainSearchCopyNext(search, &item) == noErr) + { + SecKeychainAttributeInfo info; + SecKeychainAttributeList *attr_list; + UInt32 info_tags[] = { kSecServerItemAttr }; + LPWSTR target_name; + INT str_len; + info.count = sizeof(info_tags)/sizeof(info_tags[0]); + info.tag = info_tags; + info.format = NULL; + status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, NULL, NULL); + if (status != noErr) + { + WARN("SecKeychainItemCopyAttributesAndData returned status %ld\n", status); + continue; + } + if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServerItemAttr) + { + CFRelease(item); + continue; + } + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, NULL, 0); + target_name = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, target_name, str_len); + /* nul terminate */ + target_name[str_len] = '\0'; + if (strcmpiW(TargetName, target_name)) + { + CFRelease(item); + HeapFree(GetProcessHeap(), 0, target_name); + continue; + } + HeapFree(GetProcessHeap(), 0, target_name); + SecKeychainItemFreeAttributesAndData(attr_list, NULL); + SecKeychainItemDelete(item); + CFRelease(item); + CFRelease(search); + + return ERROR_SUCCESS; + } + CFRelease(search); + } + return ERROR_NOT_FOUND; +} +#endif + static void convert_PCREDENTIALW_to_PCREDENTIALA(const CREDENTIALW *CredentialW, PCREDENTIALA CredentialA, DWORD *len) { char *buffer = (char *)CredentialA + sizeof(CREDENTIALA); @@ -592,6 +1119,15 @@ BOOL WINAPI CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags) return FALSE; } +#ifdef __APPLE__ + if (Type == CRED_TYPE_DOMAIN_PASSWORD) + { + ret = mac_delete_credential(TargetName); + if (ret == ERROR_SUCCESS) + return TRUE; + } +#endif + ret = open_cred_mgr_key(&hkeyMgr, TRUE); if (ret != ERROR_SUCCESS) { @@ -674,44 +1210,6 @@ BOOL WINAPI CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count, return TRUE; } -static BOOL credential_matches_filter(HKEY hkeyCred, LPCWSTR filter) -{ - LPWSTR target_name; - DWORD ret; - DWORD type; - DWORD count; - LPCWSTR p; - - if (!filter) return TRUE; - - ret = RegQueryValueExW(hkeyCred, NULL, 0, &type, NULL, &count); - if (ret != ERROR_SUCCESS) - return FALSE; - else if (type != REG_SZ) - return FALSE; - - target_name = HeapAlloc(GetProcessHeap(), 0, count); - if (!target_name) - return FALSE; - ret = RegQueryValueExW(hkeyCred, NULL, 0, &type, (LPVOID)target_name, &count); - if (ret != ERROR_SUCCESS || type != REG_SZ) - { - HeapFree(GetProcessHeap(), 0, target_name); - return FALSE; - } - - TRACE("comparing filter %s to target name %s\n", debugstr_w(filter), - debugstr_w(target_name)); - - p = strchrW(filter, '*'); - ret = CompareStringW(GetThreadLocale(), 0, filter, - (p && !p[1] ? p - filter : -1), target_name, - (p && !p[1] ? p - filter : -1)) == CSTR_EQUAL; - - HeapFree(GetProcessHeap(), 0, target_name); - return ret; -} - /****************************************************************************** * CredEnumerateW [ADVAPI32.@] */ @@ -719,13 +1217,11 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIALW **Credentials) { HKEY hkeyMgr; - HKEY hkeyCred; DWORD ret; LPWSTR target_name; DWORD target_name_len; DWORD len; char *buffer; - DWORD i; BYTE key_data[KEY_SIZE]; TRACE("(%s, 0x%x, %p, %p)\n", debugstr_w(Filter), Flags, Count, Credentials); @@ -770,36 +1266,12 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, *Count = 0; len = 0; - for (i = 0;; i++) - { - ret = RegEnumKeyW(hkeyMgr, i, target_name, target_name_len+1); - if (ret == ERROR_NO_MORE_ITEMS) - { - ret = ERROR_SUCCESS; - break; - } - else if (ret != ERROR_SUCCESS) - { - ret = ERROR_SUCCESS; - continue; - } - ret = RegOpenKeyExW(hkeyMgr, target_name, 0, KEY_QUERY_VALUE, &hkeyCred); - if (ret != ERROR_SUCCESS) - { - ret = ERROR_SUCCESS; - continue; - } - if (!credential_matches_filter(hkeyCred, Filter)) - { - RegCloseKey(hkeyCred); - continue; - } - len += sizeof(CREDENTIALW); - ret = read_credential(hkeyCred, NULL, key_data, NULL, &len); - RegCloseKey(hkeyCred); - if (ret != ERROR_SUCCESS) break; - (*Count)++; - } + ret = registry_enumerate_credentials(hkeyMgr, Filter, target_name, target_name_len, + key_data, NULL, NULL, &len, Count); +#ifdef __APPLE__ + if (ret == ERROR_SUCCESS) + ret = mac_enumerate_credentials(Filter, NULL, NULL, &len, Count); +#endif if (ret == ERROR_SUCCESS && *Count == 0) ret = ERROR_NOT_FOUND; if (ret != ERROR_SUCCESS) @@ -809,7 +1281,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, SetLastError(ret); return FALSE; } - len += *Count + sizeof(PCREDENTIALW); + len += *Count * sizeof(PCREDENTIALW); if (ret == ERROR_SUCCESS) { @@ -819,41 +1291,15 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, { buffer += *Count * sizeof(PCREDENTIALW); *Count = 0; - for (i = 0;; i++) - { - ret = RegEnumKeyW(hkeyMgr, i, target_name, target_name_len+1); - if (ret == ERROR_NO_MORE_ITEMS) - { - ret = ERROR_SUCCESS; - break; - } - else if (ret != ERROR_SUCCESS) - { - ret = ERROR_SUCCESS; - continue; - } - TRACE("target_name = %s\n", debugstr_w(target_name)); - ret = RegOpenKeyExW(hkeyMgr, target_name, 0, KEY_QUERY_VALUE, &hkeyCred); - if (ret != ERROR_SUCCESS) - { - ret = ERROR_SUCCESS; - continue; - } - if (!credential_matches_filter(hkeyCred, Filter)) - { - RegCloseKey(hkeyCred); - continue; - } - len = sizeof(CREDENTIALW); - (*Credentials)[*Count] = (PCREDENTIALW)buffer; - ret = read_credential(hkeyCred, (*Credentials)[*Count], - key_data, - buffer + sizeof(CREDENTIALW), &len); - RegCloseKey(hkeyCred); - if (ret != ERROR_SUCCESS) break; - buffer += len; - (*Count)++; - } + ret = registry_enumerate_credentials(hkeyMgr, Filter, target_name, + target_name_len, key_data, + *Credentials, &buffer, &len, + Count); +#ifdef __APPLE__ + if (ret == ERROR_SUCCESS) + ret = mac_enumerate_credentials(Filter, *Credentials, + buffer, &len, Count); +#endif } else ret = ERROR_OUTOFMEMORY; @@ -961,6 +1407,78 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW return FALSE; } +#ifdef __APPLE__ + if (Type == CRED_TYPE_DOMAIN_PASSWORD) + { + OSStatus status; + SecKeychainSearchRef search; + status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search); + if (status == noErr) + { + SecKeychainItemRef item; + while (SecKeychainSearchCopyNext(search, &item) == noErr) + { + SecKeychainAttributeInfo info; + SecKeychainAttributeList *attr_list; + UInt32 info_tags[] = { kSecServerItemAttr }; + LPWSTR target_name; + INT str_len; + info.count = sizeof(info_tags)/sizeof(info_tags[0]); + info.tag = info_tags; + info.format = NULL; + status = SecKeychainItemCopyAttributesAndData(item, &info, NULL, &attr_list, NULL, NULL); + len = sizeof(**Credential); + if (status != noErr) + { + WARN("SecKeychainItemCopyAttributesAndData returned status %ld\n", status); + continue; + } + if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServerItemAttr) + { + CFRelease(item); + continue; + } + str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, NULL, 0); + target_name = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, target_name, str_len); + /* nul terminate */ + target_name[str_len] = '\0'; + if (strcmpiW(TargetName, target_name)) + { + CFRelease(item); + HeapFree(GetProcessHeap(), 0, target_name); + continue; + } + HeapFree(GetProcessHeap(), 0, target_name); + SecKeychainItemFreeAttributesAndData(attr_list, NULL); + ret = mac_read_credential_from_item(item, TRUE, NULL, NULL, &len); + if (ret == ERROR_SUCCESS) + { + *Credential = HeapAlloc(GetProcessHeap(), 0, len); + if (*Credential) + { + len = sizeof(**Credential); + ret = mac_read_credential_from_item(item, TRUE, *Credential, + (char *)(*Credential + 1), &len); + } + else + ret = ERROR_OUTOFMEMORY; + CFRelease(item); + CFRelease(search); + if (ret != ERROR_SUCCESS) + { + SetLastError(ret); + return FALSE; + } + return TRUE; + } + CFRelease(item); + } + CFRelease(search); + } + } +#endif + ret = open_cred_mgr_key(&hkeyMgr, FALSE); if (ret != ERROR_SUCCESS) { @@ -988,15 +1506,15 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW } len = sizeof(**Credential); - ret = read_credential(hkeyCred, NULL, key_data, NULL, &len); + ret = registry_read_credential(hkeyCred, NULL, key_data, NULL, &len); if (ret == ERROR_SUCCESS) { *Credential = HeapAlloc(GetProcessHeap(), 0, len); if (*Credential) { len = sizeof(**Credential); - ret = read_credential(hkeyCred, *Credential, key_data, - (char *)(*Credential + 1), &len); + ret = registry_read_credential(hkeyCred, *Credential, key_data, + (char *)(*Credential + 1), &len); } else ret = ERROR_OUTOFMEMORY; @@ -1095,6 +1613,21 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags) } } +#ifdef __APPLE__ + if (!Credential->AttributeCount && + Credential->Type == CRED_TYPE_DOMAIN_PASSWORD && + (Credential->Persist == CRED_PERSIST_LOCAL_MACHINE || Credential->Persist == CRED_PERSIST_ENTERPRISE)) + { + ret = mac_write_credential(Credential, Flags & CRED_PRESERVE_CREDENTIAL_BLOB); + if (ret != ERROR_SUCCESS) + { + SetLastError(ret); + return FALSE; + } + return TRUE; + } +#endif + ret = open_cred_mgr_key(&hkeyMgr, FALSE); if (ret != ERROR_SUCCESS) { @@ -1112,7 +1645,8 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags) } key_name = get_key_name_for_target(Credential->TargetName, Credential->Type); - ret = RegCreateKeyExW(hkeyMgr, key_name, 0, NULL, REG_OPTION_VOLATILE, + ret = RegCreateKeyExW(hkeyMgr, key_name, 0, NULL, + Credential->Persist == CRED_PERSIST_SESSION ? REG_OPTION_VOLATILE : REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE, NULL, &hkeyCred, NULL); HeapFree(GetProcessHeap(), 0, key_name); if (ret != ERROR_SUCCESS) @@ -1123,8 +1657,8 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags) return FALSE; } - ret = write_credential(hkeyCred, Credential, key_data, - Flags & CRED_PRESERVE_CREDENTIAL_BLOB); + ret = registry_write_credential(hkeyCred, Credential, key_data, + Flags & CRED_PRESERVE_CREDENTIAL_BLOB); RegCloseKey(hkeyCred); RegCloseKey(hkeyMgr); diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index 030dfa82e35..4b9f29d29a0 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -1401,7 +1401,7 @@ static VOID ADVAPI_ApplyRestrictions( DWORD dwFlags, DWORD dwType, if ((dwFlags & RRF_RT_DWORD) == RRF_RT_DWORD) cbExpect = 4; - else if ((dwFlags & RRF_RT_DWORD) == RRF_RT_QWORD) + else if ((dwFlags & RRF_RT_QWORD) == RRF_RT_QWORD) cbExpect = 8; if (cbExpect && cbData != cbExpect) diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index 4fdbb54eb0d..9b32fdd49a4 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -4253,6 +4253,21 @@ BOOL WINAPI CreateProcessAsUserW( } /****************************************************************************** + * CreateProcessWithLogonW + */ +BOOL WINAPI CreateProcessWithLogonW( LPCWSTR lpUsername, LPCWSTR lpDomain, LPCWSTR lpPassword, DWORD dwLogonFlags, + LPCWSTR lpApplicationName, LPWSTR lpCommandLine, DWORD dwCreationFlags, LPVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation ) +{ + FIXME("%s %s %s 0x%08x %s %s 0x%08x %p %s %p %p stub\n", debugstr_w(lpUsername), debugstr_w(lpDomain), + debugstr_w(lpPassword), dwLogonFlags, debugstr_w(lpApplicationName), + debugstr_w(lpCommandLine), dwCreationFlags, lpEnvironment, debugstr_w(lpCurrentDirectory), + lpStartupInfo, lpProcessInformation); + + return FALSE; +} + +/****************************************************************************** * DuplicateTokenEx [ADVAPI32.@] */ BOOL WINAPI DuplicateTokenEx( diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index 0f8ad1913a2..4604c0ec7ac 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -74,7 +74,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commctrl); #define NAME "microsoft.windows.common-controls" #define FILE "comctl32.dll" -#define VERSION "6.0.0.0" +#define VERSION "6.0.2600.2982" #define PUBLIC_KEY "6595b64144ccf1df" #ifdef __i386__ diff --git a/dlls/comctl32/theme_combo.c b/dlls/comctl32/theme_combo.c index af6eee8dbb7..477138e1792 100644 --- a/dlls/comctl32/theme_combo.c +++ b/dlls/comctl32/theme_combo.c @@ -106,7 +106,7 @@ static void paint_text (HWND hwnd, HDC hdc, DWORD dwStyle, const COMBOBOXINFO *c clipRegion=NULL; } - if (!IsWindowEnabled(hwnd) & WS_DISABLED) itemState |= ODS_DISABLED; + if (!IsWindowEnabled(hwnd)) itemState |= ODS_DISABLED; dis.CtlType = ODT_COMBOBOX; dis.CtlID = ctlid; diff --git a/dlls/comdlg32/filedlgbrowser.c b/dlls/comdlg32/filedlgbrowser.c index 11608f04323..55ef65b482c 100644 --- a/dlls/comdlg32/filedlgbrowser.c +++ b/dlls/comdlg32/filedlgbrowser.c @@ -868,8 +868,8 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBr ulAttr = SFGAO_HIDDEN | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR | SFGAO_LINK; IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, &pidl, &ulAttr); - if( (ulAttr & SFGAO_HIDDEN) /* hidden */ - | !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */ + if( (ulAttr & SFGAO_HIDDEN) || /* hidden */ + !(ulAttr & (SFGAO_FILESYSTEM | SFGAO_FILESYSANCESTOR))) /* special folder */ return S_FALSE; /* always include directories and links */ diff --git a/dlls/credui/tests/credui.c b/dlls/credui/tests/credui.c index 692e586b57f..969b096a766 100644 --- a/dlls/credui/tests/credui.c +++ b/dlls/credui/tests/credui.c @@ -41,7 +41,8 @@ static void test_CredUIPromptForCredentials(void) credui_info.hbmBanner = NULL; ret = CredUIConfirmCredentialsW(NULL, TRUE); - ok(ret == ERROR_INVALID_PARAMETER, "CredUIConfirmCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret); + ok(ret == ERROR_INVALID_PARAMETER /* 2003 + */ || ret == ERROR_NOT_FOUND /* XP */, + "CredUIConfirmCredentials should have returned ERROR_INVALID_PARAMETER or ERROR_NOT_FOUND instead of %d\n", ret); ret = CredUIConfirmCredentialsW(wszServerName, TRUE); ok(ret == ERROR_NOT_FOUND, "CredUIConfirmCredentials should have returned ERROR_NOT_FOUND instead of %d\n", ret); diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index b3808ff55cc..97f9360307b 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -1084,6 +1084,14 @@ static BOOL compare_cert_by_issuer(PCCERT_CONTEXT pCertContext, DWORD dwType, return ret; } +static BOOL compare_existing_cert(PCCERT_CONTEXT pCertContext, DWORD dwType, + DWORD dwFlags, const void *pvPara) +{ + PCCERT_CONTEXT toCompare = (PCCERT_CONTEXT)pvPara; + return CertCompareCertificate(pCertContext->dwCertEncodingType, + pCertContext->pCertInfo, toCompare->pCertInfo); +} + PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, DWORD dwCertEncodingType, DWORD dwFlags, DWORD dwType, const void *pvPara, PCCERT_CONTEXT pPrevCertContext) @@ -1117,6 +1125,9 @@ PCCERT_CONTEXT WINAPI CertFindCertificateInStore(HCERTSTORE hCertStore, case CERT_COMPARE_ISSUER_OF: compare = compare_cert_by_issuer; break; + case CERT_COMPARE_EXISTING: + compare = compare_existing_cert; + break; default: FIXME("find type %08x unimplemented\n", dwType); compare = NULL; diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 7f79ec9b553..1158febfdc0 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -837,6 +837,22 @@ BOOL WINAPI CertAddCertificateContextToStore(HCERTSTORE hCertStore, else toAdd = CertDuplicateCertificateContext(pCertContext); break; + case CERT_STORE_ADD_NEWER: + if (existing) + { + if (CompareFileTime(&existing->pCertInfo->NotBefore, + &pCertContext->pCertInfo->NotBefore) >= 0) + { + TRACE("existing certificate is newer, not adding\n"); + SetLastError(CRYPT_E_EXISTS); + ret = FALSE; + } + else + toAdd = CertDuplicateCertificateContext(pCertContext); + } + else + toAdd = CertDuplicateCertificateContext(pCertContext); + break; default: FIXME("Unimplemented add disposition %d\n", dwAddDisposition); ret = FALSE; diff --git a/dlls/ctapi32/ctapi32.c b/dlls/ctapi32/ctapi32.c index 2af4632611a..5c330bdffc7 100644 --- a/dlls/ctapi32/ctapi32.c +++ b/dlls/ctapi32/ctapi32.c @@ -66,7 +66,7 @@ static int load_functions(void) { buffer_w[size / sizeof(WCHAR)] = '\0'; len = WideCharToMultiByte(CP_UNIXCP, 0, buffer_w, -1, buffer, sizeof(buffer), NULL, NULL); if (len) - memcpy(soname, buffer, len - 1); + memcpy(soname, buffer, len); } RegCloseKey(key_handle); } diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 8b9a4619dd5..545f441c270 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -4439,6 +4439,556 @@ void test_compare_instructions(IDirect3DDevice9 *device) IDirect3DVertexShader9_Release(shader_slt_scalar); } +void test_vshader_input(IDirect3DDevice9 *device) +{ + DWORD swapped_shader_code_3[] = { + 0xfffe0300, /* vs_3_0 */ + 0x0200001f, 0x80000000, 0xe00f0000, /* dcl_position o0 */ + 0x0200001f, 0x8000000a, 0xe00f0001, /* dcl_color o1 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x80000005, 0x900f0001, /* dcl_texcoord0 v1 */ + 0x0200001f, 0x80010005, 0x900f0002, /* dcl_texcoord1 v2 */ + 0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */ + 0x02000001, 0x800f0001, 0x90e40001, /* mov r1, v1 */ + 0x03000002, 0xe00f0001, 0x80e40001, 0x91e40002, /* sub o1, r1, v2 */ + 0x0000ffff /* end */ + }; + DWORD swapped_shader_code_1[] = { + 0xfffe0101, /* vs_1_1 */ + 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0000001f, 0x80000005, 0x900f0001, /* dcl_texcoord0 v1 */ + 0x0000001f, 0x80010005, 0x900f0002, /* dcl_texcoord1 v2 */ + 0x00000001, 0xc00f0000, 0x90e40000, /* mov o0, v0 */ + 0x00000001, 0x800f0001, 0x90e40001, /* mov r1, v1 */ + 0x00000002, 0xd00f0000, 0x80e40001, 0x91e40002, /* sub o1, r1, v2 */ + 0x0000ffff /* end */ + }; + DWORD swapped_shader_code_2[] = { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x80000005, 0x900f0001, /* dcl_texcoord0 v1 */ + 0x0200001f, 0x80010005, 0x900f0002, /* dcl_texcoord1 v2 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov o0, v0 */ + 0x02000001, 0x800f0001, 0x90e40001, /* mov r1, v1 */ + 0x03000002, 0xd00f0000, 0x80e40001, 0x91e40002, /* sub o1, r1, v2 */ + 0x0000ffff /* end */ + }; + DWORD texcoord_color_shader_code_3[] = { + 0xfffe0300, /* vs_3_0 */ + 0x0200001f, 0x80000000, 0xe00f0000, /* dcl_position o0 */ + 0x0200001f, 0x8000000a, 0xe00f0001, /* dcl_color o1 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x80000005, 0x900f0001, /* dcl_texcoord v1 */ + 0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */ + 0x02000001, 0xe00f0001, 0x90e40001, /* mov o1, v1 */ + 0x0000ffff /* end */ + }; + DWORD texcoord_color_shader_code_2[] = { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x80000005, 0x900f0001, /* dcl_texcoord v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x02000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */ + 0x0000ffff /* end */ + }; + DWORD texcoord_color_shader_code_1[] = { + 0xfffe0101, /* vs_1_1 */ + 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0000001f, 0x80000005, 0x900f0001, /* dcl_texcoord v1 */ + 0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x00000001, 0xd00f0000, 0x90e40001, /* mov oD0, v1 */ + 0x0000ffff /* end */ + }; + DWORD color_color_shader_code_3[] = { + 0xfffe0300, /* vs_3_0 */ + 0x0200001f, 0x80000000, 0xe00f0000, /* dcl_position o0 */ + 0x0200001f, 0x8000000a, 0xe00f0001, /* dcl_color o1 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x8000000a, 0x900f0001, /* dcl_color v1 */ + 0x02000001, 0xe00f0000, 0x90e40000, /* mov o0, v0 */ + 0x03000005, 0xe00f0001, 0xa0e40000, 0x90e40001, /* mul o1, c0, v1 */ + 0x0000ffff /* end */ + }; + DWORD color_color_shader_code_2[] = { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0200001f, 0x8000000a, 0x900f0001, /* dcl_color v1 */ + 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x03000005, 0xd00f0000, 0xa0e40000, 0x90e40001, /* mul oD0, c0, v1 */ + 0x0000ffff /* end */ + }; + DWORD color_color_shader_code_1[] = { + 0xfffe0101, /* vs_1_1 */ + 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x0000001f, 0x8000000a, 0x900f0001, /* dcl_color v1 */ + 0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x00000005, 0xd00f0000, 0xa0e40000, 0x90e40001, /* mul oD0, c0, v1 */ + 0x0000ffff /* end */ + }; + IDirect3DVertexShader9 *swapped_shader, *texcoord_color_shader, *color_color_shader; + HRESULT hr; + DWORD color, r, g, b; + float quad1[] = { + -1.0, -1.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + 0.0, -1.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + -1.0, 0.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + 0.0, 0.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + }; + float quad2[] = { + 0.0, -1.0, 0.1, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 1.0, -1.0, 0.1, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.1, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 0.0, 0.1, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + }; + float quad3[] = { + -1.0, 0.0, 0.1, -1.0, 0.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, + 0.0, 0.0, 0.1, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, + -1.0, 1.0, 0.1, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 1.0, 0.0, + 0.0, 1.0, 0.1, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, + }; + float quad4[] = { + 0.0, 0.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + 1.0, 0.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + 0.0, 1.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + 1.0, 1.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.0, + }; + static const D3DVERTEXELEMENT9 decl_elements_twotexcrd[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, + {0, 28, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, + D3DDECL_END() + }; + static const D3DVERTEXELEMENT9 decl_elements_twotexcrd_rightorder[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, + {0, 28, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, + D3DDECL_END() + }; + static const D3DVERTEXELEMENT9 decl_elements_onetexcrd[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, + D3DDECL_END() + }; + static const D3DVERTEXELEMENT9 decl_elements_twotexcrd_wrongidx[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1}, + {0, 28, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2}, + D3DDECL_END() + }; + static const D3DVERTEXELEMENT9 decl_elements_texcoord_color[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, + D3DDECL_END() + }; + static const D3DVERTEXELEMENT9 decl_elements_color_color[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + D3DDECL_END() + }; + static const D3DVERTEXELEMENT9 decl_elements_color_ubyte[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + D3DDECL_END() + }; + static const D3DVERTEXELEMENT9 decl_elements_color_float[] = { + {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, + {0, 12, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, + D3DDECL_END() + }; + IDirect3DVertexDeclaration9 *decl_twotexcrd, *decl_onetexcrd, *decl_twotex_wrongidx, *decl_twotexcrd_rightorder; + IDirect3DVertexDeclaration9 *decl_texcoord_color, *decl_color_color, *decl_color_ubyte, *decl_color_float; + unsigned int i; + float normalize[4] = {1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0}; + float no_normalize[4] = {1.0, 1.0, 1.0, 1.0}; + + struct vertex quad1_color[] = { + {-1.0, -1.0, 0.1, 0x00ff8040}, + { 0.0, -1.0, 0.1, 0x00ff8040}, + {-1.0, 0.0, 0.1, 0x00ff8040}, + { 0.0, 0.0, 0.1, 0x00ff8040} + }; + struct vertex quad2_color[] = { + { 0.0, -1.0, 0.1, 0x00ff8040}, + { 1.0, -1.0, 0.1, 0x00ff8040}, + { 0.0, 0.0, 0.1, 0x00ff8040}, + { 1.0, 0.0, 0.1, 0x00ff8040} + }; + struct vertex quad3_color[] = { + {-1.0, 0.0, 0.1, 0x00ff8040}, + { 0.0, 0.0, 0.1, 0x00ff8040}, + {-1.0, 1.0, 0.1, 0x00ff8040}, + { 0.0, 1.0, 0.1, 0x00ff8040} + }; + float quad4_color[] = { + 0.0, 0.0, 0.1, 1.0, 1.0, 0.0, 0.0, + 1.0, 0.0, 0.1, 1.0, 1.0, 0.0, 1.0, + 0.0, 1.0, 0.1, 1.0, 1.0, 0.0, 0.0, + 1.0, 1.0, 0.1, 1.0, 1.0, 0.0, 1.0, + }; + + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_twotexcrd, &decl_twotexcrd); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_onetexcrd, &decl_onetexcrd); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_twotexcrd_wrongidx, &decl_twotex_wrongidx); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_twotexcrd_rightorder, &decl_twotexcrd_rightorder); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_texcoord_color, &decl_texcoord_color); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_color_color, &decl_color_color); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_color_ubyte, &decl_color_ubyte); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements_color_float, &decl_color_float); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + + for(i = 1; i <= 3; i++) { + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + if(i == 3) { + hr = IDirect3DDevice9_CreateVertexShader(device, swapped_shader_code_3, &swapped_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + } else if(i == 2){ + hr = IDirect3DDevice9_CreateVertexShader(device, swapped_shader_code_2, &swapped_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + } else if(i == 1) { + hr = IDirect3DDevice9_CreateVertexShader(device, swapped_shader_code_1, &swapped_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + } + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene returned %s\n", DXGetErrorString9(hr)); + if(SUCCEEDED(hr)) + { + hr = IDirect3DDevice9_SetVertexShader(device, swapped_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotexcrd); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1, sizeof(float) * 11); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_onetexcrd); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(float) * 11); + if(i == 3 || i == 2) { + ok(hr == D3D_OK, "DrawPrimitiveUP returned (%08x) i = %d\n", hr, i); + } else if(i == 1) { + /* Succeeds or fails, depending on SW or HW vertex processing */ + ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "DrawPrimitiveUP returned (%08x), i = 1\n", hr); + } + + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotexcrd_rightorder); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4, sizeof(float) * 11); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotex_wrongidx); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(float) * 11); + if(i == 3 || i == 2) { + ok(hr == D3D_OK, "DrawPrimitiveUP returned (%08x) i = %d\n", hr, i); + } else if(i == 1) { + ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "DrawPrimitiveUP returned (%08x) i = 1\n", hr); + } + + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %s\n", DXGetErrorString9(hr)); + } + + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr)); + + if(i == 3 || i == 2) { + color = getPixelColor(device, 160, 360); + ok(color == 0x00FFFF80 || color == 0x00FFFF7f || color == 0x00FFFF81, + "Input test: Quad 1(2crd) returned color 0x%08x, expected 0x00FFFF80\n", color); + + /* The last value of the read but undefined stream is used */ + color = getPixelColor(device, 480, 360); + ok(color == 0x00FFFF00, "Input test: Quad 2(1crd) returned color 0x%08x, expected 0x00FFFF00\n", color); + color = getPixelColor(device, 160, 120); + ok(color == 0x00FF0080 || color == 0x00FF007f || color == 0x00FF0081, + "Input test: Quad 3(2crd-wrongidx) returned color 0x%08x, expected 0x00FF0080\n", color); + + color = getPixelColor(device, 480, 160); + ok(color == 0x00000000, "Input test: Quad 4(2crd-rightorder) returned color 0x%08x, expected 0x00000000\n", color); + } else if(i == 1) { + color = getPixelColor(device, 160, 360); + ok(color == 0x00FFFF80 || color == 0x00FFFF7f || color == 0x00FFFF81, + "Input test: Quad 1(2crd) returned color 0x%08x, expected 0x00FFFF80\n", color); + color = getPixelColor(device, 480, 360); + /* Accept the clear color as well in this case, since SW VP returns an error */ + ok(color == 0x00FFFF00 || color == 0x00FF0000, "Input test: Quad 2(1crd) returned color 0x%08x, expected 0x00FFFF00\n", color); + color = getPixelColor(device, 160, 120); + ok(color == 0x00FF0080 || color == 0x00FF0000 || color == 0x00FF007f || color == 0x00FF0081, + "Input test: Quad 3(2crd-wrongidx) returned color 0x%08x, expected 0x00FF0080\n", color); + color = getPixelColor(device, 480, 160); + ok(color == 0x00000000, "Input test: Quad 4(2crd-rightorder) returned color 0x%08x, expected 0x00000000\n", color); + } + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff808080, 0.0, 0); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %s\n", DXGetErrorString9(hr)); + + /* Now find out if the whole streams are re-read, or just the last active value for the + * vertices is used. + */ + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene returned %s\n", DXGetErrorString9(hr)); + if(SUCCEEDED(hr)) + { + float quad1_modified[] = { + -1.0, -1.0, 0.1, 1.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, + 0.0, -1.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0, + -1.0, 0.0, 0.1, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, + 0.0, 0.0, 0.1, 1.0, 0.0, 1.0, 0.0, -1.0, -1.0, -1.0, 0.0, + }; + float quad2_modified[] = { + 0.0, -1.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 1.0, -1.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + }; + + hr = IDirect3DDevice9_SetVertexShader(device, swapped_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotexcrd); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 3, quad1_modified, sizeof(float) * 11); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_onetexcrd); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2_modified, sizeof(float) * 11); + if(i == 3 || i == 2) { + ok(hr == D3D_OK, "DrawPrimitiveUP returned (%08x) i = %d\n", hr, i); + } else if(i == 1) { + /* Succeeds or fails, depending on SW or HW vertex processing */ + ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "DrawPrimitiveUP returned (%08x), i = 1\n", hr); + } + + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %s\n", DXGetErrorString9(hr)); + } + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr)); + + color = getPixelColor(device, 480, 360); + /* vs_1_1 may fail, accept the clear color */ + ok(color == 0x000000FF || color == 0x00808080, + "Input test: Quad 2(different colors) returned color 0x%08x, expected 0x000000FF\n", color); + color = getPixelColor(device, 160, 120); + + IDirect3DDevice9_SetVertexShader(device, NULL); + IDirect3DDevice9_SetVertexDeclaration(device, NULL); + + IDirect3DVertexShader9_Release(swapped_shader); + } + + for(i = 1; i <= 3; i++) { + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0); + if(i == 3) { + hr = IDirect3DDevice9_CreateVertexShader(device, texcoord_color_shader_code_3, &texcoord_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexShader(device, color_color_shader_code_3, &color_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + } else if(i == 2){ + hr = IDirect3DDevice9_CreateVertexShader(device, texcoord_color_shader_code_2, &texcoord_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexShader(device, color_color_shader_code_2, &color_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + } else if(i == 1) { + hr = IDirect3DDevice9_CreateVertexShader(device, texcoord_color_shader_code_1, &texcoord_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreateVertexShader(device, color_color_shader_code_1, &color_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + } + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene returned %s\n", DXGetErrorString9(hr)); + if(SUCCEEDED(hr)) + { + hr = IDirect3DDevice9_SetVertexShader(device, texcoord_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_texcoord_color); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad1_color, sizeof(quad1_color[0])); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_SetVertexShader(device, color_color_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, normalize, 1); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_color_ubyte); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2_color, sizeof(quad2_color[0])); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, no_normalize, 1); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_color_color); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3_color, sizeof(quad3_color[0])); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_color_float); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexDeclaration returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad4_color, sizeof(float) * 7); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %s\n", DXGetErrorString9(hr)); + } + IDirect3DDevice9_SetVertexShader(device, NULL); + IDirect3DDevice9_SetVertexDeclaration(device, NULL); + + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr)); + + color = getPixelColor(device, 160, 360); + r = (color & 0x00ff0000) >> 16; + g = (color & 0x0000ff00) >> 8; + b = (color & 0x000000ff) >> 0; + ok(r >= 0xfe && r <= 0xff && g >= 0x7f && g <= 0x81 && b >= 0x3f && b <= 0x41, + "Input test: Quad 1(color-texcoord) returned color 0x%08x, expected 0x00ff8040\n", color); + color = getPixelColor(device, 480, 360); + r = (color & 0x00ff0000) >> 16; + g = (color & 0x0000ff00) >> 8; + b = (color & 0x000000ff) >> 0; + ok(r >= 0x3f && r <= 0x41 && g >= 0x7f && g <= 0x81 && b >= 0xfe && b <= 0xff, + "Input test: Quad 2(color-ubyte) returned color 0x%08x, expected 0x004080ff\n", color); + color = getPixelColor(device, 160, 120); + r = (color & 0x00ff0000) >> 16; + g = (color & 0x0000ff00) >> 8; + b = (color & 0x000000ff) >> 0; + ok(r >= 0xfe && r <= 0xff && g >= 0x7f && g <= 0x81 && b >= 0x3f && b <= 0x41, + "Input test: Quad 3(color-color) returned color 0x%08x, expected 0x00ff8040\n", color); + color = getPixelColor(device, 480, 160); + r = (color & 0x00ff0000) >> 16; + g = (color & 0x0000ff00) >> 8; + b = (color & 0x000000ff) >> 0; + ok(r >= 0xfe && r <= 0xff && g >= 0xfe && g <= 0xff && b >= 0x00 && b <= 0x01, + "Input test: Quad 4(color-float) returned color 0x%08x, expected 0x00FFFF00\n", color); + + IDirect3DVertexShader9_Release(texcoord_color_shader); + IDirect3DVertexShader9_Release(color_color_shader); + } + + IDirect3DVertexDeclaration9_Release(decl_twotexcrd); + IDirect3DVertexDeclaration9_Release(decl_onetexcrd); + IDirect3DVertexDeclaration9_Release(decl_twotex_wrongidx); + IDirect3DVertexDeclaration9_Release(decl_twotexcrd_rightorder); + + IDirect3DVertexDeclaration9_Release(decl_texcoord_color); + IDirect3DVertexDeclaration9_Release(decl_color_color); + IDirect3DVertexDeclaration9_Release(decl_color_ubyte); + IDirect3DVertexDeclaration9_Release(decl_color_float); +} + +static void fog_srgbwrite_test(IDirect3DDevice9 *device) +{ + /* Draw a black quad, half fogged with white fog -> grey color. Enable sRGB writing. + * if sRGB writing is applied before fogging, the 0.0 will be multiplied with ~ 12.92, so still + * stay 0.0. After that the fog gives 0.5. If sRGB writing is applied after fogging, the + * 0.5 will run through the alternative path(0^5 ^ 0.41666 * 1.055 - 0.055), resulting in approx. + * 0.73 + * + * At the time of this writing, wined3d could not apply sRGB correction to fixed function rendering, + * so use shaders for this task + */ + IDirect3DPixelShader9 *pshader; + IDirect3DVertexShader9 *vshader; + IDirect3D9 *d3d; + DWORD vshader_code[] = { + 0xfffe0101, /* vs_1_1 */ + 0x0000001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x00000051, 0xa00f0000, 0x3f000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.5, 0.0, 0.0, 0.0 */ + 0x00000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ + 0x00000001, 0xc00f0001, 0xa0000000, /* mov oFog, c0.x */ + 0x0000ffff /* end */ + }; + DWORD pshader_code[] = { + 0xffff0101, /* ps_1_1 */ + 0x00000051, 0xa00f0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, /* def c0, 0.0, 0.0, 0.0, 0.0 */ + 0x00000001, 0x800f0000, 0xa0e40000, /* mov r0, c0 */ + 0x0000ffff /* end */ + }; + const float quad[] = { + -1.0, -1.0, 0.1, + 1.0, -1.0, 0.1, + -1.0, 1.0, 0.1, + 1.0, 1.0, 0.1 + }; + HRESULT hr; + DWORD color; + + IDirect3DDevice9_GetDirect3D(device, &d3d); + if(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, + D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_SRGBWRITE, + D3DRTYPE_SURFACE, D3DFMT_A8R8G8B8) != D3D_OK) { + skip("No SRGBWRITEENABLE support on D3DFMT_X8R8G8B8\n"); + IDirect3D9_Release(d3d); + return; + } + IDirect3D9_Release(d3d); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffff00, 0.0, 0); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, TRUE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGTABLEMODE, D3DFOG_NONE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGCOLOR, 0xffffffff); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, TRUE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_CreateVertexShader(device, vshader_code, &vshader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreateVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_CreatePixelShader(device, pshader_code, &pshader); + ok(hr == D3D_OK, "IDirect3DDevice9_CreatePixelShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); + ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetVertexShader(device, vshader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetPixelShader(device, pshader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene returned %s\n", DXGetErrorString9(hr)); + if(SUCCEEDED(hr)) { + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float) * 3); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %s\n", DXGetErrorString9(hr)); + } + + hr = IDirect3DDevice9_SetVertexShader(device, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetPixelShader(device, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader returned %s\n", DXGetErrorString9(hr)); + IDirect3DPixelShader9_Release(pshader); + IDirect3DVertexShader9_Release(vshader); + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_FOGENABLE, FALSE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr)); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_SRGBWRITEENABLE, FALSE); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr)); + + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr)); + color = getPixelColor(device, 160, 360); + ok(color == 0x00808080 || color == 0x007f7f7f || color == 0x00818181, + "Fog with D3DRS_SRGBWRITEENABLE returned color 0x%08x, expected 0x00808080\n", color); +} + START_TEST(visual) { IDirect3DDevice9 *device_ptr; @@ -4528,12 +5078,18 @@ START_TEST(visual) if (caps.VertexShaderVersion >= D3DVS_VERSION(2, 0)) { test_mova(device_ptr); + if (caps.VertexShaderVersion >= D3DVS_VERSION(3, 0)) { + test_vshader_input(device_ptr); + } else { + skip("No vs_3_0 support\n"); + } } else skip("No vs_2_0 support\n"); if (caps.VertexShaderVersion >= D3DVS_VERSION(1, 1) && caps.PixelShaderVersion >= D3DPS_VERSION(1, 1)) { fog_with_shader_test(device_ptr); + fog_srgbwrite_test(device_ptr); } else skip("No vs_1_1 and ps_1_1 support\n"); @@ -4564,12 +5120,15 @@ START_TEST(visual) cleanup: if(device_ptr) { + ULONG ref; + D3DPRESENT_PARAMETERS present_parameters; IDirect3DSwapChain9 *swapchain; IDirect3DDevice9_GetSwapChain(device_ptr, 0, &swapchain); IDirect3DSwapChain9_GetPresentParameters(swapchain, &present_parameters); IDirect3DSwapChain9_Release(swapchain); - IDirect3DDevice9_Release(device_ptr); + ref = IDirect3DDevice9_Release(device_ptr); DestroyWindow(present_parameters.hDeviceWindow); + ok(ref == 0, "The device was not properly freed: refcount %u\n", ref); } } diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec index af78fb26d8b..28b772e688c 100644 --- a/dlls/d3dx8/d3dx8.spec +++ b/dlls/d3dx8/d3dx8.spec @@ -33,7 +33,7 @@ @ stdcall D3DXMatrixRotationAxis(ptr ptr long) @ stdcall D3DXMatrixRotationQuaternion(ptr ptr) @ stdcall D3DXMatrixRotationYawPitchRoll(ptr long long long) -@ stub D3DXMatrixTransformation +@ stdcall D3DXMatrixTransformation(ptr ptr ptr ptr ptr ptr ptr) @ stdcall D3DXMatrixAffineTransformation(ptr long ptr ptr ptr) @ stdcall D3DXMatrixLookAtRH(ptr ptr ptr ptr) @ stdcall D3DXMatrixLookAtLH(ptr ptr ptr ptr) @@ -49,15 +49,15 @@ @ stdcall D3DXMatrixOrthoOffCenterLH(ptr long long long long long long) @ stdcall D3DXMatrixShadow(ptr ptr ptr) @ stdcall D3DXMatrixReflect(ptr ptr) -@ stub D3DXQuaternionToAxisAngle -@ stub D3DXQuaternionRotationMatrix -@ stub D3DXQuaternionRotationAxis -@ stub D3DXQuaternionRotationYawPitchRoll +@ stdcall D3DXQuaternionToAxisAngle(ptr ptr ptr) +@ stdcall D3DXQuaternionRotationMatrix(ptr ptr) +@ stdcall D3DXQuaternionRotationAxis(ptr ptr long) +@ stdcall D3DXQuaternionRotationYawPitchRoll(ptr long long long) @ stdcall D3DXQuaternionMultiply(ptr ptr ptr) @ stdcall D3DXQuaternionNormalize(ptr ptr) @ stdcall D3DXQuaternionInverse(ptr ptr) -@ stub D3DXQuaternionLn -@ stub D3DXQuaternionExp +@ stdcall D3DXQuaternionLn(ptr ptr) +@ stdcall D3DXQuaternionExp(ptr ptr) @ stdcall D3DXQuaternionSlerp(ptr ptr ptr long) @ stdcall D3DXQuaternionSquad(ptr ptr ptr ptr ptr long) @ stdcall D3DXQuaternionBaryCentric(ptr ptr ptr ptr long long) diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c index e907be14022..55da2d955b5 100644 --- a/dlls/d3dx8/math.c +++ b/dlls/d3dx8/math.c @@ -480,6 +480,86 @@ D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, return pout; } +D3DXMATRIX* WINAPI D3DXMatrixTransformation(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pscalingcenter, CONST D3DXQUATERNION *pscalingrotation, CONST D3DXVECTOR3 *pscaling, CONST D3DXVECTOR3 *protationcenter, CONST D3DXQUATERNION *protation, CONST D3DXVECTOR3 *ptranslation) +{ + D3DXMATRIX m1, m2, m3, m4, m5, m6, m7, p1, p2, p3, p4, p5; + D3DXQUATERNION prc; + D3DXVECTOR3 psc, pt; + + if ( !pscalingcenter ) + { + psc.x = 0.0f; + psc.y = 0.0f; + psc.z = 0.0f; + } + else + { + psc.x = pscalingcenter->x; + psc.y = pscalingcenter->y; + psc.z = pscalingcenter->z; + } + if ( !protationcenter ) + { + prc.x = 0.0f; + prc.y = 0.0f; + prc.z = 0.0f; + } + else + { + prc.x = protationcenter->x; + prc.y = protationcenter->y; + prc.z = protationcenter->z; + } + if ( !ptranslation ) + { + pt.x = 0.0f; + pt.y = 0.0f; + pt.z = 0.0f; + } + else + { + pt.x = ptranslation->x; + pt.y = ptranslation->y; + pt.z = ptranslation->z; + } + D3DXMatrixTranslation(&m1, -psc.x, -psc.y, -psc.z); + if ( !pscalingrotation ) + { + D3DXMatrixIdentity(&m2); + D3DXMatrixIdentity(&m4); + } + else + { + D3DXMatrixRotationQuaternion(&m4, pscalingrotation); + D3DXMatrixInverse(&m2, NULL, &m4); + } + if ( !pscaling ) + { + D3DXMatrixIdentity(&m3); + } + else + { + D3DXMatrixScaling(&m3, pscaling->x, pscaling->y, pscaling->z); + } + if ( !protation ) + { + D3DXMatrixIdentity(&m6); + } + else + { + D3DXMatrixRotationQuaternion(&m6, protation); + } + D3DXMatrixTranslation(&m5, psc.x - prc.x, psc.y - prc.y, psc.z - prc.z); + D3DXMatrixTranslation(&m7, prc.x + pt.x, prc.y + pt.y, prc.z + pt.z); + D3DXMatrixMultiply(&p1, &m1, &m2); + D3DXMatrixMultiply(&p2, &p1, &m3); + D3DXMatrixMultiply(&p3, &p2, &m4); + D3DXMatrixMultiply(&p4, &p3, &m5); + D3DXMatrixMultiply(&p5, &p4, &m6); + D3DXMatrixMultiply(pout, &p5, &m7); + return pout; +} + D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z) { D3DXMatrixIdentity(pout); @@ -588,6 +668,28 @@ D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3D return pout; } +D3DXQUATERNION* WINAPI D3DXQuaternionExp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) +{ + FLOAT norm; + + norm = sqrt(pq->x * pq->x + pq->y * pq->y + pq->z * pq->z); + if (norm ) + { + pout->x = sin(norm) * pq->x / norm; + pout->y = sin(norm) * pq->y / norm; + pout->z = sin(norm) * pq->z / norm; + pout->w = cos(norm); + } + else + { + pout->x = 0.0f; + pout->y = 0.0f; + pout->z = 0.0f; + pout->w = 1.0f; + } + return pout; +} + D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) { D3DXQUATERNION temp; @@ -612,6 +714,34 @@ D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUA return pout; } +D3DXQUATERNION* WINAPI D3DXQuaternionLn(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) +{ + FLOAT norm, normvec, theta; + + norm = D3DXQuaternionLengthSq(pq); + if ( norm > 1.0001f ) + { + pout->x = pq->x; + pout->y = pq->y; + pout->z = pq->z; + pout->w = 0.0f; + } + else if( norm > 0.99999f) + { + normvec = sqrt( pq->x * pq->x + pq->y * pq->y + pq->z * pq->z ); + theta = atan2(normvec, pq->w) / normvec; + pout->x = theta * pq->x; + pout->y = theta * pq->y; + pout->z = theta * pq->z; + pout->w = 0.0f; + } + else + { + FIXME("The quaternion (%f, %f, %f, %f) has a norm <1. This should not happen. Windows returns a result anyway. This case is not implemented yet.\n", pq->x, pq->y, pq->z, pq->w); + } + return pout; +} + D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2) { pout->x = pq2->w * pq1->x + pq2->x * pq1->w + pq2->y * pq1->z - pq2->z * pq1->y; @@ -643,6 +773,78 @@ D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQ return pout; } +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle) +{ + D3DXVECTOR3 temp; + + D3DXVec3Normalize(&temp, pv); + pout->x = sin( angle / 2.0f ) * temp.x; + pout->y = sin( angle / 2.0f ) * temp.y; + pout->z = sin( angle / 2.0f ) * temp.z; + pout->w = cos( angle / 2.0f ); + return pout; +} + +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix(D3DXQUATERNION *pout, CONST D3DXMATRIX *pm) +{ + int i, maxi; + FLOAT maxdiag, S, trace; + + trace = pm->u.m[0][0] + pm->u.m[1][1] + pm->u.m[2][2] + 1.0f; + if ( trace > 0.0f) + { + pout->x = ( pm->u.m[1][2] - pm->u.m[2][1] ) / ( 2.0f * sqrt(trace) ); + pout->y = ( pm->u.m[2][0] - pm->u.m[0][2] ) / ( 2.0f * sqrt(trace) ); + pout->z = ( pm->u.m[0][1] - pm->u.m[1][0] ) / ( 2.0f * sqrt(trace) ); + pout->w = sqrt(trace) / 2.0f; + return pout; + } + maxi = 0; + maxdiag = pm->u.m[0][0]; + for (i=1; i<3; i++) + { + if ( pm->u.m[i][i] > maxdiag ) + { + maxi = i; + maxdiag = pm->u.m[i][i]; + } + } + switch( maxi ) + { + case 0: + S = 2.0f * sqrt(1.0f + pm->u.m[0][0] - pm->u.m[1][1] - pm->u.m[2][2]); + pout->x = 0.25f * S; + pout->y = ( pm->u.m[0][1] + pm->u.m[1][0] ) / S; + pout->z = ( pm->u.m[0][2] + pm->u.m[2][0] ) / S; + pout->w = ( pm->u.m[1][2] - pm->u.m[2][1] ) / S; + break; + case 1: + S = 2.0f * sqrt(1.0f + pm->u.m[1][1] - pm->u.m[0][0] - pm->u.m[2][2]); + pout->x = ( pm->u.m[0][1] + pm->u.m[1][0] ) / S; + pout->y = 0.25f * S; + pout->z = ( pm->u.m[1][2] + pm->u.m[2][1] ) / S; + pout->w = ( pm->u.m[2][0] - pm->u.m[0][2] ) / S; + break; + case 2: + S = 2.0f * sqrt(1.0f + pm->u.m[2][2] - pm->u.m[0][0] - pm->u.m[1][1]); + pout->x = ( pm->u.m[0][2] + pm->u.m[2][0] ) / S; + pout->y = ( pm->u.m[1][2] + pm->u.m[2][1] ) / S; + pout->z = 0.25f * S; + pout->w = ( pm->u.m[0][1] - pm->u.m[1][0] ) / S; + break; + } + return pout; +} + +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *pout, FLOAT yaw, FLOAT pitch, FLOAT roll) +{ + pout->x = sin( yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) + cos(yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f); + pout->y = sin( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) - cos(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 2.0f); + pout->z = cos(yaw / 2.0f) * cos(pitch / 2.0f) * sin(roll / 2.0f) - sin( yaw / 2.0f) * sin(pitch / 2.0f) * cos(roll / 2.0f); + pout->w = cos( yaw / 2.0f) * cos(pitch / 2.0f) * cos(roll / 2.0f) + sin(yaw / 2.0f) * sin(pitch / 2.0f) * sin(roll / 2.0f); + return pout; +} + D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t) { FLOAT dot, epsilon; @@ -665,6 +867,27 @@ D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATE return pout; } +void WINAPI D3DXQuaternionToAxisAngle(CONST D3DXQUATERNION *pq, D3DXVECTOR3 *paxis, FLOAT *pangle) +{ + FLOAT norm; + + *pangle = 0.0f; + norm = D3DXQuaternionLength(pq); + if ( norm ) + { + paxis->x = pq->x / norm; + paxis->y = pq->y / norm; + paxis->z = pq->z / norm; + if ( fabs( pq->w ) <= 1.0f ) *pangle = 2.0f * acos(pq->w); + } + else + { + paxis->x = 1.0f; + paxis->y = 0.0f; + paxis->z = 0.0f; + } +} + /*_________________D3DXVec2_____________________*/ D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g) diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index 229d0b7dc61..a8471b3a9ed 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -164,8 +164,8 @@ static void D3DXMatrixTest(void) D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3; LPD3DXMATRIX funcpointer; D3DXPLANE plane; - D3DXQUATERNION q; - D3DXVECTOR3 at, axis, eye; + D3DXQUATERNION q, r; + D3DXVECTOR3 at, axis, eye, last, scaling; D3DXVECTOR4 light; BOOL expected, got; FLOAT angle, determinant, expectedfloat, gotfloat; @@ -187,27 +187,30 @@ static void D3DXMatrixTest(void) plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f; q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f; + r.x = 0.87f; r.y = 0.65f; r.z =0.43f; r.w= 0.21f; at.x = -2.0f; at.y = 13.0f; at.z = -9.0f; axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f; eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f; + last.x = 9.7f; last.y = -8.6; last.z = 1.3f; + scaling.x = 0.03f; scaling.y =0.05f; scaling.z = 0.06f; light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3; angle = D3DX_PI/3.0f; /*____________D3DXMatrixAffineTransformation______*/ - expectedmat.m[0][0] = -459.239990f; expectedmat.m[0][1] = -576.719971f; expectedmat.m[0][2] = -263.440002f; expectedmat.m[0][3] = 0.0f; - expectedmat.m[1][0] = 519.760010f; expectedmat.m[1][1] = -352.440002f; expectedmat.m[1][2] = -277.679993f; expectedmat.m[1][3] = 0.0f; - expectedmat.m[2][0] = 363.119995f; expectedmat.m[2][1] = -121.040001f; expectedmat.m[2][2] = -117.479996f; expectedmat.m[2][3] = 0.0f; - expectedmat.m[3][0] = -1239.0f; expectedmat.m[3][1] = 667.0f; expectedmat.m[3][2] = 567.0f; expectedmat.m[3][3] = 1.0f; + U(expectedmat).m[0][0] = -459.239990f; U(expectedmat).m[0][1] = -576.719971f; U(expectedmat).m[0][2] = -263.440002f; U(expectedmat).m[0][3] = 0.0f; + U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f; + U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f; + U(expectedmat).m[3][0] = -1239.0f; U(expectedmat).m[3][1] = 667.0f; U(expectedmat).m[3][2] = 567.0f; U(expectedmat).m[3][3] = 1.0f; D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis); expect_mat(expectedmat,gotmat); /* Test the NULL case */ - expectedmat.m[0][0] = -459.239990f; expectedmat.m[0][1] = -576.719971f; expectedmat.m[0][2] = -263.440002f; expectedmat.m[0][3] = 0.0f; - expectedmat.m[1][0] = 519.760010f; expectedmat.m[1][1] = -352.440002f; expectedmat.m[1][2] = -277.679993f; expectedmat.m[1][3] = 0.0f; - expectedmat.m[2][0] = 363.119995f; expectedmat.m[2][1] = -121.040001f; expectedmat.m[2][2] = -117.479996f; expectedmat.m[2][3] = 0.0f; - expectedmat.m[3][0] = 1.0f; expectedmat.m[3][1] = -3.0f; expectedmat.m[3][2] = 7.0f; expectedmat.m[3][3] = 1.0f; + U(expectedmat).m[0][0] = -459.239990f; U(expectedmat).m[0][1] = -576.719971f; U(expectedmat).m[0][2] = -263.440002f; U(expectedmat).m[0][3] = 0.0f; + U(expectedmat).m[1][0] = 519.760010f; U(expectedmat).m[1][1] = -352.440002f; U(expectedmat).m[1][2] = -277.679993f; U(expectedmat).m[1][3] = 0.0f; + U(expectedmat).m[2][0] = 363.119995f; U(expectedmat).m[2][1] = -121.040001f; U(expectedmat).m[2][2] = -117.479996f; U(expectedmat).m[2][3] = 0.0f; + U(expectedmat).m[3][0] = 1.0f; U(expectedmat).m[3][1] = -3.0f; U(expectedmat).m[3][2] = 7.0f; U(expectedmat).m[3][3] = 1.0f; D3DXMatrixAffineTransformation(&gotmat,3.56f,NULL,&q,&axis); expect_mat(expectedmat,gotmat); @@ -217,10 +220,10 @@ static void D3DXMatrixTest(void) ok(fabs( gotfloat - expectedfloat ) < admitted_error, "Expected: %f, Got: %f\n", expectedfloat, gotfloat); /*____________D3DXMatrixInverse______________*/ - expectedmat.m[0][0] = 16067.0f/73944.0f; expectedmat.m[0][1] = -10165.0f/147888.0f; expectedmat.m[0][2] = -2729.0f/147888.0f; expectedmat.m[0][3] = -1631.0f/49296.0f; - expectedmat.m[1][0] = -565.0f/36972.0f; expectedmat.m[1][1] = 2723.0f/73944.0f; expectedmat.m[1][2] = -1073.0f/73944.0f; expectedmat.m[1][3] = 289.0f/24648.0f; - expectedmat.m[2][0] = -389.0f/2054.0f; expectedmat.m[2][1] = 337.0f/4108.0f; expectedmat.m[2][2] = 181.0f/4108.0f; expectedmat.m[2][3] = 317.0f/4108.0f; - expectedmat.m[3][0] = 163.0f/5688.0f; expectedmat.m[3][1] = -101.0f/11376.0f; expectedmat.m[3][2] = -73.0f/11376.0f; expectedmat.m[3][3] = -127.0f/3792.0f; + U(expectedmat).m[0][0] = 16067.0f/73944.0f; U(expectedmat).m[0][1] = -10165.0f/147888.0f; U(expectedmat).m[0][2] = -2729.0f/147888.0f; U(expectedmat).m[0][3] = -1631.0f/49296.0f; + U(expectedmat).m[1][0] = -565.0f/36972.0f; U(expectedmat).m[1][1] = 2723.0f/73944.0f; U(expectedmat).m[1][2] = -1073.0f/73944.0f; U(expectedmat).m[1][3] = 289.0f/24648.0f; + U(expectedmat).m[2][0] = -389.0f/2054.0f; U(expectedmat).m[2][1] = 337.0f/4108.0f; U(expectedmat).m[2][2] = 181.0f/4108.0f; U(expectedmat).m[2][3] = 317.0f/4108.0f; + U(expectedmat).m[3][0] = 163.0f/5688.0f; U(expectedmat).m[3][1] = -101.0f/11376.0f; U(expectedmat).m[3][2] = -73.0f/11376.0f; U(expectedmat).m[3][3] = -127.0f/3792.0f; expectedfloat = -147888.0f; D3DXMatrixInverse(&gotmat,&determinant,&mat); expect_mat(expectedmat,gotmat); @@ -270,10 +273,10 @@ static void D3DXMatrixTest(void) expect_mat(expectedmat,gotmat); /*____________D3DXMatrixMultiplyTranspose____*/ - expectedmat.m[0][0] = 73.0f; expectedmat.m[0][1] = 231.0f; expectedmat.m[0][2] = 239.0f; expectedmat.m[0][3] = -164.0f; - expectedmat.m[1][0] = 193.0f; expectedmat.m[1][1] = 551.0f; expectedmat.m[1][2] = 523.0f; expectedmat.m[1][3] = -320.0; - expectedmat.m[2][0] = -197.0f; expectedmat.m[2][1] = -489.0f; expectedmat.m[2][2] = -400.0f; expectedmat.m[2][3] = 187.0f; - expectedmat.m[3][0] = -77.0f; expectedmat.m[3][1] = -169.0f; expectedmat.m[3][2] = -116.0f; expectedmat.m[3][3] = 31.0f; + U(expectedmat).m[0][0] = 73.0f; U(expectedmat).m[0][1] = 231.0f; U(expectedmat).m[0][2] = 239.0f; U(expectedmat).m[0][3] = -164.0f; + U(expectedmat).m[1][0] = 193.0f; U(expectedmat).m[1][1] = 551.0f; U(expectedmat).m[1][2] = 523.0f; U(expectedmat).m[1][3] = -320.0; + U(expectedmat).m[2][0] = -197.0f; U(expectedmat).m[2][1] = -489.0f; U(expectedmat).m[2][2] = -400.0f; U(expectedmat).m[2][3] = 187.0f; + U(expectedmat).m[3][0] = -77.0f; U(expectedmat).m[3][1] = -169.0f; U(expectedmat).m[3][2] = -116.0f; U(expectedmat).m[3][3] = 31.0f; D3DXMatrixMultiplyTranspose(&gotmat,&mat,&mat2); expect_mat(expectedmat,gotmat); @@ -364,6 +367,7 @@ static void D3DXMatrixTest(void) U(expectedmat).m[3][0] = 1.615385f; U(expectedmat).m[3][1] = 0.538462f; U(expectedmat).m[3][2] = -2.153846f; U(expectedmat).m[3][3] = 1.0f; D3DXMatrixReflect(&gotmat,&plane); expect_mat(expectedmat,gotmat); + /*____________D3DXMatrixRotationAxis_____*/ U(expectedmat).m[0][0] = 0.508475f; U(expectedmat).m[0][1] = 0.763805f; U(expectedmat).m[0][2] = 0.397563f; U(expectedmat).m[0][3] = 0.0f; U(expectedmat).m[1][0] = -0.814652f; U(expectedmat).m[1][1] = 0.576271f; U(expectedmat).m[1][2] = -0.065219f; U(expectedmat).m[1][3] = 0.0f; @@ -428,6 +432,14 @@ static void D3DXMatrixTest(void) D3DXMatrixShadow(&gotmat,&light,&plane); expect_mat(expectedmat,gotmat); +/*____________D3DXMatrixTransformation______________*/ + U(expectedmat).m[0][0] = -0.2148f; U(expectedmat).m[0][1] = 1.3116f; U(expectedmat).m[0][2] = 0.4752f; U(expectedmat).m[0][3] = 0.0f; + U(expectedmat).m[1][0] = 0.9504f; U(expectedmat).m[1][1] = -0.8836f; U(expectedmat).m[1][2] = 0.9244f; U(expectedmat).m[1][3] = 0.0f; + U(expectedmat).m[2][0] = 1.0212f; U(expectedmat).m[2][1] = 0.1936f; U(expectedmat).m[2][2] = -1.3588f; U(expectedmat).m[2][3] = 0.0f; + U(expectedmat).m[3][0] = 18.2985f; U(expectedmat).m[3][1] = -29.624001f; U(expectedmat).m[3][2] = 15.683499f; U(expectedmat).m[3][3] = 1.0f; + D3DXMatrixTransformation(&gotmat,&at,&q,NULL,&eye,&r,&last); + expect_mat(expectedmat,gotmat); + /*____________D3DXMatrixTranslation______________*/ U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f; U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f; @@ -552,9 +564,11 @@ static void D3DXPlaneTest(void) static void D3X8QuaternionTest(void) { - D3DXQUATERNION expectedquat, gotquat, nul, q, r, s, t, u; + D3DXMATRIX mat; + D3DXQUATERNION expectedquat, gotquat, Nq, Nq1, nul, q, r, s, t, u; LPD3DXQUATERNION funcpointer; - FLOAT expected, got, scale, scale2; + D3DXVECTOR3 axis, expectedvec; + FLOAT angle, expected, got, scale, scale2; BOOL expectedbool, gotbool; nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f; @@ -593,6 +607,20 @@ static void D3X8QuaternionTest(void) got = D3DXQuaternionDot(NULL,NULL); ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got); +/*_______________D3DXQuaternionExp______________________________*/ + expectedquat.x = -0.216382f; expectedquat.y = -0.432764f; expectedquat.z = -0.8655270f; expectedquat.w = -0.129449f; + D3DXQuaternionExp(&gotquat,&q); + expect_vec4(expectedquat,gotquat); + /* Test the null quaternion */ + expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f; + D3DXQuaternionExp(&gotquat,&nul); + expect_vec4(expectedquat,gotquat); + /* Test the case where the norm of the quaternion is <1 */ + Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f; + expectedquat.x = 0.195366; expectedquat.y = 0.097683f; expectedquat.z = 0.293049f; expectedquat.w = 0.930813f; + D3DXQuaternionExp(&gotquat,&Nq1); + expect_vec4(expectedquat,gotquat); + /*_______________D3DXQuaternionIdentity________________*/ expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 1.0f; D3DXQuaternionIdentity(&gotquat); @@ -641,6 +669,23 @@ static void D3X8QuaternionTest(void) got = D3DXQuaternionLengthSq(NULL); ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got); +/*_______________D3DXQuaternionLn______________________________*/ + expectedquat.x = 1.0f; expectedquat.y = 2.0f; expectedquat.z = 4.0f; expectedquat.w = 0.0f; + D3DXQuaternionLn(&gotquat,&q); + expect_vec4(expectedquat,gotquat); + expectedquat.x = -3.0f; expectedquat.y = 4.0f; expectedquat.z = -5.0f; expectedquat.w = 0.0f; + D3DXQuaternionLn(&gotquat,&r); + expect_vec4(expectedquat,gotquat); + Nq.x = 1.0f/11.0f; Nq.y = 2.0f/11.0f; Nq.z = 4.0f/11.0f; Nq.w=10.0f/11.0f; + expectedquat.x = 0.093768f; expectedquat.y = 0.187536f; expectedquat.z = 0.375073f; expectedquat.w = 0.0f; + D3DXQuaternionLn(&gotquat,&Nq); + expect_vec4(expectedquat,gotquat); + /* Test the cas where the norm of the quaternion is <1 */ + Nq1.x = 0.2f; Nq1.y = 0.1f; Nq1.z = 0.3; Nq1.w= 0.9f; + expectedquat.x = 0.206945f; expectedquat.y = 0.103473f; expectedquat.z = 0.310418f; expectedquat.w = 0.0f; + D3DXQuaternionLn(&gotquat,&Nq1); + todo_wine{ expect_vec4(expectedquat,gotquat) }; + /*_______________D3DXQuaternionMultiply________________________*/ expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f; D3DXQuaternionMultiply(&gotquat,&q,&r); @@ -655,6 +700,55 @@ static void D3X8QuaternionTest(void) D3DXQuaternionNormalize(&gotquat,&nul); expect_vec4(expectedquat,gotquat); +/*_______________D3DXQuaternionRotationAxis___________________*/ + axis.x = 2.0f; axis.y = 7.0; axis.z = 13.0f; + angle = D3DX_PI/3.0f; + expectedquat.x = 0.067116; expectedquat.y = 0.234905f; expectedquat.z = 0.436251f; expectedquat.w = 0.866025f; + D3DXQuaternionRotationAxis(&gotquat,&axis,angle); + expect_vec4(expectedquat,gotquat); + /* Test the nul quaternion */ + axis.x = 0.0f; axis.y = 0.0; axis.z = 0.0f; + expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.866025f; + D3DXQuaternionRotationAxis(&gotquat,&axis,angle); + expect_vec4(expectedquat,gotquat); + +/*_______________D3DXQuaternionRotationMatrix___________________*/ + /* test when the trace is >0 */ + U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f; + U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f; + U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f; + U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f; + U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f; + U(mat).m[3][3] = 48.0f; + expectedquat.x = 2.368682f; expectedquat.y = 0.768221f; expectedquat.z = -0.384111f; expectedquat.w = 3.905125f; + D3DXQuaternionRotationMatrix(&gotquat,&mat); + expect_vec4(expectedquat,gotquat); + /* test the case when the greater element is (2,2) */ + U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f; + U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f; + U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f; + U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f; + U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = -60.0f; U(mat).m[2][2] = 40.0f; + U(mat).m[3][3] = 48.0f; + expectedquat.x = 1.233905f; expectedquat.y = -0.237290f; expectedquat.z = 5.267827f; expectedquat.w = -0.284747f; + D3DXQuaternionRotationMatrix(&gotquat,&mat); + expect_vec4(expectedquat,gotquat); + /* test the case when the greater element is (1,1) */ + U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f; + U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f; + U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f; + U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f; + U(mat).m[0][0] = -10.0f; U(mat).m[1][1] = 60.0f; U(mat).m[2][2] = -80.0f; + U(mat).m[3][3] = 48.0f; + expectedquat.x = 0.651031f; expectedquat.y = 6.144103f; expectedquat.z = -0.203447f; expectedquat.w = 0.488273f; + D3DXQuaternionRotationMatrix(&gotquat,&mat); + expect_vec4(expectedquat,gotquat); + +/*_______________D3DXQuaternionRotationYawPitchRoll__________*/ + expectedquat.x = 0.303261f; expectedquat.y = 0.262299f; expectedquat.z = 0.410073f; expectedquat.w = 0.819190f; + D3DXQuaternionRotationYawPitchRoll(&gotquat,D3DX_PI/4.0f,D3DX_PI/11.0f,D3DX_PI/3.0f); + expect_vec4(expectedquat,gotquat); + /*_______________D3DXQuaternionSlerp________________________*/ expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f; D3DXQuaternionSlerp(&gotquat,&q,&r,scale); @@ -667,6 +761,26 @@ static void D3X8QuaternionTest(void) expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f; D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale); expect_vec4(expectedquat,gotquat); + +/*_______________D3DXQuaternionToAxisAngle__________________*/ + Nq.x = 1.0f/22.0f; Nq.y = 2.0f/22.0f; Nq.z = 4.0f/22.0f; Nq.w = 10.0f/22.0f; + expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; + expected = 2.197869f; + D3DXQuaternionToAxisAngle(&Nq,&axis,&angle); + expect_vec3(expectedvec,axis); + ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle); + /* Test if |w|>1.0f */ + expectedvec.x = 1.0f/11.0f; expectedvec.y = 2.0f/11.0f; expectedvec.z = 4.0f/11.0f; + expected = 0.0f; + D3DXQuaternionToAxisAngle(&q,&axis,&angle); + expect_vec3(expectedvec,axis); + ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle); + /* Test the null quaternion */ + expectedvec.x = 1.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f; + expected = 0.0f; + D3DXQuaternionToAxisAngle(&nul,&axis,&angle); + expect_vec3(expectedvec,axis); + ok(fabs( angle - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, angle); } static void D3X8Vector2Test(void) @@ -861,17 +975,17 @@ static void D3X8Vector3Test(void) U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f; U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f; - view.m[0][1] = 5.0f; view.m[0][2] = 7.0f; view.m[0][3] = 8.0f; - view.m[1][0] = 11.0f; view.m[1][2] = 16.0f; view.m[1][3] = 33.0f; - view.m[2][0] = 19.0f; view.m[2][1] = -21.0f; view.m[2][3] = 43.0f; - view.m[3][0] = 2.0f; view.m[3][1] = 3.0f; view.m[3][2] = -4.0f; - view.m[0][0] = 10.0f; view.m[1][1] = 20.0f; view.m[2][2] = 30.0f; - view.m[3][3] = -40.0f; - - world.m[0][0] = 21.0f; world.m[0][1] = 2.0f; world.m[0][2] = 3.0f; world.m[0][3] = 4.0; - world.m[1][0] = 5.0f; world.m[1][1] = 23.0f; world.m[1][2] = 7.0f; world.m[1][3] = 8.0f; - world.m[2][0] = -8.0f; world.m[2][1] = -7.0f; world.m[2][2] = 25.0f; world.m[2][3] = -5.0f; - world.m[3][0] = -4.0f; world.m[3][1] = -3.0f; world.m[3][2] = -2.0f; world.m[3][3] = 27.0f; + U(view).m[0][1] = 5.0f; U(view).m[0][2] = 7.0f; U(view).m[0][3] = 8.0f; + U(view).m[1][0] = 11.0f; U(view).m[1][2] = 16.0f; U(view).m[1][3] = 33.0f; + U(view).m[2][0] = 19.0f; U(view).m[2][1] = -21.0f; U(view).m[2][3] = 43.0f; + U(view).m[3][0] = 2.0f; U(view).m[3][1] = 3.0f; U(view).m[3][2] = -4.0f; + U(view).m[0][0] = 10.0f; U(view).m[1][1] = 20.0f; U(view).m[2][2] = 30.0f; + U(view).m[3][3] = -40.0f; + + U(world).m[0][0] = 21.0f; U(world).m[0][1] = 2.0f; U(world).m[0][2] = 3.0f; U(world).m[0][3] = 4.0; + U(world).m[1][0] = 5.0f; U(world).m[1][1] = 23.0f; U(world).m[1][2] = 7.0f; U(world).m[1][3] = 8.0f; + U(world).m[2][0] = -8.0f; U(world).m[2][1] = -7.0f; U(world).m[2][2] = 25.0f; U(world).m[2][3] = -5.0f; + U(world).m[3][0] = -4.0f; U(world).m[3][1] = -3.0f; U(world).m[3][2] = -2.0f; U(world).m[3][3] = 27.0f; coeff1 = 2.0f; coeff2 = 5.0f; scale = -6.5f; diff --git a/dlls/dinput/effect_linuxinput.c b/dlls/dinput/effect_linuxinput.c index f5851fc678c..37af31f5f19 100644 --- a/dlls/dinput/effect_linuxinput.c +++ b/dlls/dinput/effect_linuxinput.c @@ -540,7 +540,7 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters( _dump_DIEFFECT(peff, &This->guid); - if ((dwFlags & !DIEP_NORESTART & !DIEP_NODOWNLOAD & !DIEP_START) == 0) { + if ((dwFlags & ~DIEP_NORESTART & ~DIEP_NODOWNLOAD & ~DIEP_START) == 0) { /* set everything */ dwFlags = DIEP_AXES | DIEP_DIRECTION | DIEP_DURATION | DIEP_ENVELOPE | DIEP_GAIN | DIEP_SAMPLEPERIOD | DIEP_STARTDELAY | DIEP_TRIGGERBUTTON | diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 18417fb1c97..13e413b204d 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -88,23 +88,30 @@ DWORD joystick_map_pov(POINTL *p) /* * This maps the read value (from the input event) to a value in the * 'wanted' range. + * Notes: + * Dead zone is in % multiplied by a 100 (range 0..10000) */ LONG joystick_map_axis(ObjProps *props, int val) { LONG ret; - LONG center = (props->lMax - props->lMin) / 2; + LONG dead_zone = MulDiv( props->lDeadZone, props->lDevMax - props->lDevMin, 10000 ); + LONG dev_range = props->lDevMax - props->lDevMin - dead_zone; - /* map the value from the hmin-hmax range into the wmin-wmax range */ - ret = MulDiv( val - props->lDevMin, props->lMax - props->lMin, - props->lDevMax - props->lDevMin ); + /* Center input */ + val -= (props->lDevMin + props->lDevMax) / 2; - if (abs( ret - center ) <= props->lDeadZone / 2 ) - ret = center; + /* Remove dead zone */ + if (abs( val ) <= dead_zone / 2) + val = 0; + else + val = val < 0 ? val + dead_zone / 2 : val - dead_zone / 2; - ret += props->lMin; + /* Scale and map the value from the device range into the required range */ + ret = MulDiv( val, props->lMax - props->lMin, dev_range ) + + (props->lMin + props->lMax) / 2; - TRACE( "(%d %d) -> (%d <%d> %d): val=%d ret=%d\n", - props->lDevMin, props->lDevMax, + TRACE( "(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d\n", + props->lDevMin, dead_zone, props->lDevMax, props->lMin, props->lDeadZone, props->lMax, val, ret ); diff --git a/dlls/dnsapi/dnsapi.h b/dlls/dnsapi/dnsapi.h index 2060a475b35..e617012778f 100644 --- a/dlls/dnsapi/dnsapi.h +++ b/dlls/dnsapi/dnsapi.h @@ -19,19 +19,19 @@ */ -static inline void *dns_alloc( SIZE_T size ) +static inline void *heap_alloc( SIZE_T size ) { return HeapAlloc( GetProcessHeap(), 0, size ); } -static inline void *dns_zero_alloc( SIZE_T size ) +static inline void *heap_alloc_zero( SIZE_T size ) { return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size ); } -static inline void dns_free( LPVOID mem ) +static inline BOOL heap_free( LPVOID mem ) { - HeapFree( GetProcessHeap(), 0, mem ); + return HeapFree( GetProcessHeap(), 0, mem ); } static inline LPSTR dns_strdup_a( LPCSTR src ) @@ -39,7 +39,7 @@ static inline LPSTR dns_strdup_a( LPCSTR src ) LPSTR dst; if (!src) return NULL; - dst = dns_alloc( (lstrlenA( src ) + 1) * sizeof(char) ); + dst = heap_alloc( (lstrlenA( src ) + 1) * sizeof(char) ); if (dst) lstrcpyA( dst, src ); return dst; } @@ -49,7 +49,7 @@ static inline char *dns_strdup_u( const char *src ) char *dst; if (!src) return NULL; - dst = dns_alloc( (strlen( src ) + 1) * sizeof(char) ); + dst = heap_alloc( (strlen( src ) + 1) * sizeof(char) ); if (dst) strcpy( dst, src ); return dst; } @@ -59,7 +59,7 @@ static inline LPWSTR dns_strdup_w( LPCWSTR src ) LPWSTR dst; if (!src) return NULL; - dst = dns_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) ); + dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) ); if (dst) lstrcpyW( dst, src ); return dst; } @@ -70,7 +70,7 @@ static inline LPWSTR dns_strdup_aw( LPCSTR str ) if (str) { DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); - if ((ret = dns_alloc( len * sizeof(WCHAR) ))) + if ((ret = heap_alloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); } return ret; @@ -82,7 +82,7 @@ static inline LPWSTR dns_strdup_uw( const char *str ) if (str) { DWORD len = MultiByteToWideChar( CP_UTF8, 0, str, -1, NULL, 0 ); - if ((ret = dns_alloc( len * sizeof(WCHAR) ))) + if ((ret = heap_alloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_UTF8, 0, str, -1, ret, len ); } return ret; @@ -94,7 +94,7 @@ static inline LPSTR dns_strdup_wa( LPCWSTR str ) if (str) { DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); - if ((ret = dns_alloc( len ))) + if ((ret = heap_alloc( len ))) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); } return ret; @@ -106,7 +106,7 @@ static inline char *dns_strdup_wu( LPCWSTR str ) if (str) { DWORD len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL ); - if ((ret = dns_alloc( len ))) + if ((ret = heap_alloc( len ))) WideCharToMultiByte( CP_UTF8, 0, str, -1, ret, len, NULL, NULL ); } return ret; @@ -120,7 +120,7 @@ static inline char *dns_strdup_au( LPCSTR src ) if (ret) { dst = dns_strdup_wu( ret ); - dns_free( ret ); + heap_free( ret ); } return dst; } @@ -133,7 +133,7 @@ static inline LPSTR dns_strdup_ua( const char *src ) if (ret) { dst = dns_strdup_wa( ret ); - dns_free( ret ); + heap_free( ret ); } return dst; } diff --git a/dlls/dnsapi/name.c b/dlls/dnsapi/name.c index 514fec90ae3..32620506fa2 100644 --- a/dlls/dnsapi/name.c +++ b/dlls/dnsapi/name.c @@ -63,8 +63,8 @@ BOOL WINAPI DnsNameCompare_A( PCSTR name1, PCSTR name2 ) ret = DnsNameCompare_W( name1W, name2W ); - dns_free( name1W ); - dns_free( name2W ); + heap_free( name1W ); + heap_free( name2W ); return ret; } @@ -115,7 +115,7 @@ DNS_STATUS WINAPI DnsValidateName_A( PCSTR name, DNS_NAME_FORMAT format ) nameW = dns_strdup_aw( name ); ret = DnsValidateName_W( nameW, format ); - dns_free( nameW ); + heap_free( nameW ); return ret; } @@ -133,7 +133,7 @@ DNS_STATUS WINAPI DnsValidateName_UTF8( PCSTR name, DNS_NAME_FORMAT format ) nameW = dns_strdup_uw( name ); ret = DnsValidateName_W( nameW, format ); - dns_free( nameW ); + heap_free( nameW ); return ret; } diff --git a/dlls/dnsapi/query.c b/dlls/dnsapi/query.c index 8fe7714fd5c..60e74563d96 100644 --- a/dlls/dnsapi/query.c +++ b/dlls/dnsapi/query.c @@ -180,7 +180,7 @@ static char *dns_dname_from_msg( ns_msg msg, const unsigned char *pos ) pos, dname, sizeof(dname) ); len = strlen( dname ); - str = dns_alloc( len + 1 ); + str = heap_alloc( len + 1 ); if (str) strcpy( str, dname ); return str; } @@ -190,7 +190,7 @@ static char *dns_str_from_rdata( const unsigned char *rdata ) char *str; unsigned int len = rdata[0]; - str = dns_alloc( len + 1 ); + str = heap_alloc( len + 1 ); if (str) { memcpy( str, ++rdata, len ); @@ -302,7 +302,7 @@ static DNS_STATUS dns_copy_rdata( ns_msg msg, const ns_rr *rr, DNS_RECORDA *r, W r->Data.MINFO.pNameErrorsMailbox = dns_dname_from_msg( msg, pos ); if (!r->Data.MINFO.pNameErrorsMailbox) { - dns_free( r->Data.MINFO.pNameMailbox ); + heap_free( r->Data.MINFO.pNameMailbox ); return ERROR_NOT_ENOUGH_MEMORY; } @@ -379,7 +379,7 @@ static DNS_STATUS dns_copy_rdata( ns_msg msg, const ns_rr *rr, DNS_RECORDA *r, W r->Data.SOA.pNameAdministrator = dns_dname_from_msg( msg, pos ); if (!r->Data.SOA.pNameAdministrator) { - dns_free( r->Data.SOA.pNamePrimaryServer ); + heap_free( r->Data.SOA.pNamePrimaryServer ); return ERROR_NOT_ENOUGH_MEMORY; } @@ -418,7 +418,7 @@ static DNS_STATUS dns_copy_rdata( ns_msg msg, const ns_rr *rr, DNS_RECORDA *r, W r->Data.TXT.pStringArray[i] = dns_str_from_rdata( pos ); if (!r->Data.TXT.pStringArray[i]) { - while (i > 0) dns_free( r->Data.TXT.pStringArray[--i] ); + while (i > 0) heap_free( r->Data.TXT.pStringArray[--i] ); return ERROR_NOT_ENOUGH_MEMORY; } i++; @@ -455,13 +455,13 @@ static DNS_STATUS dns_copy_record( ns_msg msg, ns_sect section, if (dns_ns_parserr( &msg, section, num, &rr ) < 0) return DNS_ERROR_BAD_PACKET; - if (!(record = dns_zero_alloc( dns_get_record_size( &rr ) ))) + if (!(record = heap_alloc_zero( dns_get_record_size( &rr ) ))) return ERROR_NOT_ENOUGH_MEMORY; record->pName = dns_strdup_u( rr.name ); if (!record->pName) { - dns_free( record ); + heap_free( record ); return ERROR_NOT_ENOUGH_MEMORY; } @@ -472,8 +472,8 @@ static DNS_STATUS dns_copy_record( ns_msg msg, ns_sect section, if ((ret = dns_copy_rdata( msg, &rr, record, &dlen ))) { - dns_free( record->pName ); - dns_free( record ); + heap_free( record->pName ); + heap_free( record ); return ret; } record->wDataLength = dlen; @@ -517,7 +517,7 @@ static DNS_STATUS dns_do_query_netbios( PCSTR name, DNS_RECORDA **recp ) for (i = 0; i < header->node_count; i++) { - record = dns_zero_alloc( sizeof(DNS_RECORDA) ); + record = heap_alloc_zero( sizeof(DNS_RECORDA) ); if (!record) { status = ERROR_NOT_ENOUGH_MEMORY; @@ -687,7 +687,7 @@ DNS_STATUS WINAPI DnsQuery_A( PCSTR name, WORD type, DWORD options, PVOID server DnsRecordListFree( (DNS_RECORD *)resultW, DnsFreeRecordList ); } - dns_free( nameW ); + heap_free( nameW ); return status; } @@ -764,7 +764,7 @@ DNS_STATUS WINAPI DnsQuery_W( PCWSTR name, WORD type, DWORD options, PVOID serve DnsRecordListFree( (DNS_RECORD *)resultA, DnsFreeRecordList ); } - dns_free( nameU ); + heap_free( nameU ); return status; } diff --git a/dlls/dnsapi/record.c b/dlls/dnsapi/record.c index 7c5366f73d2..d84275abfee 100644 --- a/dlls/dnsapi/record.c +++ b/dlls/dnsapi/record.c @@ -416,7 +416,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET TRACE( "(%p,%d,%d)\n", src, in, out ); size = FIELD_OFFSET(DNS_RECORD, Data) + src->wDataLength; - dst = dns_zero_alloc( size ); + dst = heap_alloc_zero( size ); if (!dst) return NULL; memcpy( dst, src, size ); @@ -443,7 +443,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET if (!dst->Data.TXT.pStringArray[i]) { - while (i > 0) dns_free( dst->Data.TXT.pStringArray[--i] ); + while (i > 0) heap_free( dst->Data.TXT.pStringArray[--i] ); goto error; } } @@ -460,7 +460,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET dns_strcpyX( src->Data.MINFO.pNameErrorsMailbox, in, out ); if (!dst->Data.MINFO.pNameErrorsMailbox) { - dns_free( dst->Data.MINFO.pNameMailbox ); + heap_free( dst->Data.MINFO.pNameMailbox ); goto error; } break; @@ -512,7 +512,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET dns_strcpyX( src->Data.SOA.pNameAdministrator, in, out ); if (!dst->Data.SOA.pNameAdministrator) { - dns_free( dst->Data.SOA.pNamePrimaryServer ); + heap_free( dst->Data.SOA.pNamePrimaryServer ); goto error; } break; @@ -530,8 +530,8 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET return dst; error: - dns_free( dst->pName ); - dns_free( dst ); + heap_free( dst->pName ); + heap_free( dst ); return NULL; } @@ -554,7 +554,7 @@ VOID WINAPI DnsRecordListFree( PDNS_RECORD list, DNS_FREE_TYPE type ) { for (r = list; (list = r); r = next) { - dns_free( r->pName ); + heap_free( r->pName ); switch (r->wType) { @@ -564,27 +564,27 @@ VOID WINAPI DnsRecordListFree( PDNS_RECORD list, DNS_FREE_TYPE type ) case DNS_TYPE_X25: { for (i = 0; i < r->Data.TXT.dwStringCount; i++) - dns_free( r->Data.TXT.pStringArray[i] ); + heap_free( r->Data.TXT.pStringArray[i] ); break; } case DNS_TYPE_MINFO: case DNS_TYPE_RP: { - dns_free( r->Data.MINFO.pNameMailbox ); - dns_free( r->Data.MINFO.pNameErrorsMailbox ); + heap_free( r->Data.MINFO.pNameMailbox ); + heap_free( r->Data.MINFO.pNameErrorsMailbox ); break; } case DNS_TYPE_AFSDB: case DNS_TYPE_RT: case DNS_TYPE_MX: { - dns_free( r->Data.MX.pNameExchange ); + heap_free( r->Data.MX.pNameExchange ); break; } case DNS_TYPE_NXT: { - dns_free( r->Data.NXT.pNameNext ); + heap_free( r->Data.NXT.pNameNext ); break; } case DNS_TYPE_CNAME: @@ -596,23 +596,23 @@ VOID WINAPI DnsRecordListFree( PDNS_RECORD list, DNS_FREE_TYPE type ) case DNS_TYPE_NS: case DNS_TYPE_PTR: { - dns_free( r->Data.PTR.pNameHost ); + heap_free( r->Data.PTR.pNameHost ); break; } case DNS_TYPE_SIG: { - dns_free( r->Data.SIG.pNameSigner ); + heap_free( r->Data.SIG.pNameSigner ); break; } case DNS_TYPE_SOA: { - dns_free( r->Data.SOA.pNamePrimaryServer ); - dns_free( r->Data.SOA.pNameAdministrator ); + heap_free( r->Data.SOA.pNamePrimaryServer ); + heap_free( r->Data.SOA.pNameAdministrator ); break; } case DNS_TYPE_SRV: { - dns_free( r->Data.SRV.pNameTarget ); + heap_free( r->Data.SRV.pNameTarget ); break; } default: @@ -620,7 +620,7 @@ VOID WINAPI DnsRecordListFree( PDNS_RECORD list, DNS_FREE_TYPE type ) } next = r->pNext; - dns_free( r ); + heap_free( r ); } break; } @@ -680,7 +680,7 @@ BOOL WINAPI DnsRecordSetCompare( PDNS_RECORD set1, PDNS_RECORD set2, DNS_RRSET_ADD( rr1, u ); ret = FALSE; } - else dns_free( u ); + else heap_free( u ); } } @@ -696,7 +696,7 @@ BOOL WINAPI DnsRecordSetCompare( PDNS_RECORD set1, PDNS_RECORD set2, DNS_RRSET_ADD( rr2, u ); ret = FALSE; } - else dns_free( u ); + else heap_free( u ); } } diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 705d263f84d..161e0df0bc6 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -472,7 +472,7 @@ void WINAPI SetDCState( HDC hdc, HDC hdcs ) release_dc_ptr( dc ); return; } - if (!dcs->flags & DC_SAVED) + if (!(dcs->flags & DC_SAVED)) { release_dc_ptr( dc ); release_dc_ptr( dcs ); diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 3b6ec3b553f..1b80df199e8 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -2128,7 +2128,8 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, { HFONT orig_font = dc->hFont, cur_font; UINT glyph; - INT span = 0, *offsets = NULL, i; + INT span = 0, *offsets = NULL; + unsigned int i; glyphs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WORD)); for(i = 0; i < count; i++) @@ -2138,7 +2139,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags, { if(!offsets) { - int j; + unsigned int j; offsets = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*deltas)); offsets[0] = 0; if(!deltas) diff --git a/dlls/inetcomm/internettransport.c b/dlls/inetcomm/internettransport.c index a056201fc15..19fed54aad9 100644 --- a/dlls/inetcomm/internettransport.c +++ b/dlls/inetcomm/internettransport.c @@ -110,6 +110,8 @@ HRESULT InternetTransport_Connect(InternetTransport *This, for (ai_cur = ai; ai_cur; ai_cur = ai->ai_next) { + int so; + if (TRACE_ON(inetcomm)) { char host[256]; @@ -122,12 +124,13 @@ HRESULT InternetTransport_Connect(InternetTransport *This, InternetTransport_ChangeStatus(This, IXP_CONNECTING); - This->Socket = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol); - if (This->Socket < 0) + so = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol); + if (so == -1) { WARN("socket() failed\n"); continue; } + This->Socket = so; /* FIXME: set to async */ diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index 56ee5d95748..16fe3f425d5 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -2,6 +2,7 @@ * MIME OLE Interfaces * * Copyright 2006 Robert Shearman for CodeWeavers + * Copyright 2007 Huw Davies for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,18 +31,81 @@ #include "ole2.h" #include "mimeole.h" +#include "wine/list.h" #include "wine/debug.h" #include "inetcomm_private.h" WINE_DEFAULT_DEBUG_CHANNEL(inetcomm); +typedef struct +{ + LPCSTR name; + DWORD id; + DWORD flags; /* MIMEPROPFLAGS */ + VARTYPE default_vt; +} property_t; + +typedef struct +{ + struct list entry; + property_t prop; +} property_list_entry_t; + +static const property_t default_props[] = +{ + {"References", PID_HDR_REFS, 0, VT_LPSTR}, + {"Subject", PID_HDR_SUBJECT, 0, VT_LPSTR}, + {"From", PID_HDR_FROM, MPF_ADDRESS, VT_LPSTR}, + {"Message-ID", PID_HDR_MESSAGEID, 0, VT_LPSTR}, + {"Return-Path", PID_HDR_RETURNPATH, MPF_ADDRESS, VT_LPSTR}, + {"Date", PID_HDR_DATE, 0, VT_LPSTR}, + {"Received", PID_HDR_RECEIVED, 0, VT_LPSTR}, + {"Reply-To", PID_HDR_REPLYTO, MPF_ADDRESS, VT_LPSTR}, + {"X-Mailer", PID_HDR_XMAILER, 0, VT_LPSTR}, + {"Bcc", PID_HDR_BCC, MPF_ADDRESS, VT_LPSTR}, + {"MIME-Version", PID_HDR_MIMEVER, MPF_MIME, VT_LPSTR}, + {"Content-Type", PID_HDR_CNTTYPE, MPF_MIME | MPF_HASPARAMS, VT_LPSTR}, + {"Content-Transfer-Encoding", PID_HDR_CNTXFER, MPF_MIME, VT_LPSTR}, + {"Content-ID", PID_HDR_CNTID, MPF_MIME, VT_LPSTR}, + {"Content-Disposition", PID_HDR_CNTDISP, MPF_MIME, VT_LPSTR}, + {"To", PID_HDR_TO, MPF_ADDRESS, VT_LPSTR}, + {"Cc", PID_HDR_CC, MPF_ADDRESS, VT_LPSTR}, + {"Sender", PID_HDR_SENDER, MPF_ADDRESS, VT_LPSTR}, + {"In-Reply-To", PID_HDR_INREPLYTO, 0, VT_LPSTR}, + {NULL, 0, 0, 0} +}; + +typedef struct +{ + struct list entry; + char *name; + char *value; +} param_t; + +typedef struct +{ + struct list entry; + const property_t *prop; + PROPVARIANT value; + struct list params; +} header_t; + typedef struct MimeBody { const IMimeBodyVtbl *lpVtbl; LONG refs; HBODY handle; + + struct list headers; + struct list new_props; /* FIXME: This should be in a PropertySchema */ + DWORD next_prop_id; + char *content_pri_type; + char *content_sub_type; + ENCODINGTYPE encoding; + void *data; + IID data_iid; } MimeBody; static inline MimeBody *impl_from_IMimeBody( IMimeBody *iface ) @@ -49,6 +113,336 @@ static inline MimeBody *impl_from_IMimeBody( IMimeBody *iface ) return (MimeBody *)((char*)iface - FIELD_OFFSET(MimeBody, lpVtbl)); } +static LPSTR strdupA(LPCSTR str) +{ + char *ret; + int len = strlen(str); + ret = HeapAlloc(GetProcessHeap(), 0, len + 1); + memcpy(ret, str, len + 1); + return ret; +} + +#define PARSER_BUF_SIZE 1024 + +/***************************************************** + * copy_headers_to_buf [internal] + * + * Copies the headers into a '\0' terminated memory block and leave + * the stream's current position set to after the blank line. + */ +static HRESULT copy_headers_to_buf(IStream *stm, char **ptr) +{ + char *buf = NULL; + DWORD size = PARSER_BUF_SIZE, offset = 0, last_end = 0; + HRESULT hr; + int done = 0; + + *ptr = NULL; + + do + { + char *end; + DWORD read; + + if(!buf) + buf = HeapAlloc(GetProcessHeap(), 0, size + 1); + else + { + size *= 2; + buf = HeapReAlloc(GetProcessHeap(), 0, buf, size + 1); + } + if(!buf) + { + hr = E_OUTOFMEMORY; + goto fail; + } + + hr = IStream_Read(stm, buf + offset, size - offset, &read); + if(FAILED(hr)) goto fail; + + offset += read; + buf[offset] = '\0'; + + if(read == 0) done = 1; + + while(!done && (end = strstr(buf + last_end, "\r\n"))) + { + DWORD new_end = end - buf + 2; + if(new_end - last_end == 2) + { + LARGE_INTEGER off; + off.QuadPart = new_end; + IStream_Seek(stm, off, STREAM_SEEK_SET, NULL); + buf[new_end] = '\0'; + done = 1; + } + else + last_end = new_end; + } + } while(!done); + + *ptr = buf; + return S_OK; + +fail: + HeapFree(GetProcessHeap(), 0, buf); + return hr; +} + +static header_t *read_prop(MimeBody *body, char **ptr) +{ + char *colon = strchr(*ptr, ':'); + const property_t *prop; + header_t *ret; + + if(!colon) return NULL; + + *colon = '\0'; + + for(prop = default_props; prop->name; prop++) + { + if(!strcasecmp(*ptr, prop->name)) + { + TRACE("%s: found match with default property id %d\n", *ptr, prop->id); + break; + } + } + + if(!prop->name) + { + property_list_entry_t *prop_entry; + LIST_FOR_EACH_ENTRY(prop_entry, &body->new_props, property_list_entry_t, entry) + { + if(!strcasecmp(*ptr, prop_entry->prop.name)) + { + TRACE("%s: found match with already added new property id %d\n", *ptr, prop_entry->prop.id); + prop = &prop_entry->prop; + break; + } + } + if(!prop->name) + { + prop_entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*prop_entry)); + prop_entry->prop.name = strdupA(*ptr); + prop_entry->prop.id = body->next_prop_id++; + prop_entry->prop.flags = 0; + prop_entry->prop.default_vt = VT_LPSTR; + list_add_tail(&body->new_props, &prop_entry->entry); + prop = &prop_entry->prop; + TRACE("%s: allocating new prop id %d\n", *ptr, prop_entry->prop.id); + } + } + + ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret)); + ret->prop = prop; + PropVariantInit(&ret->value); + list_init(&ret->params); + *ptr = colon + 1; + + return ret; +} + +static void unfold_header(char *header, int len) +{ + char *start = header, *cp = header; + + do { + while(*cp == ' ' || *cp == '\t') + { + cp++; + len--; + } + if(cp != start) + memmove(start, cp, len + 1); + + cp = strstr(start, "\r\n"); + len -= (cp - start); + start = cp; + *start = ' '; + start++; + len--; + cp += 2; + } while(*cp == ' ' || *cp == '\t'); + + *(start - 1) = '\0'; +} + +static void add_param(header_t *header, const char *p) +{ + const char *key = p, *value, *cp = p; + param_t *param; + char *name; + + TRACE("got param %s\n", p); + + while (*key == ' ' || *key == '\t' ) key++; + + cp = strchr(key, '='); + if(!cp) + { + WARN("malformed parameter - skipping\n"); + return; + } + + name = HeapAlloc(GetProcessHeap(), 0, cp - key + 1); + memcpy(name, key, cp - key); + name[cp - key] = '\0'; + + value = cp + 1; + + param = HeapAlloc(GetProcessHeap(), 0, sizeof(*param)); + param->name = name; + param->value = strdupA(value); + list_add_tail(&header->params, ¶m->entry); +} + +static void split_params(header_t *header, char *value) +{ + char *cp = value, *start = value; + int in_quote = 0; + int done_value = 0; + + while(*cp) + { + if(!in_quote && *cp == ';') + { + *cp = '\0'; + if(done_value) add_param(header, start); + done_value = 1; + start = cp + 1; + } + else if(*cp == '"') + in_quote = !in_quote; + cp++; + } + if(done_value) add_param(header, start); +} + +static void read_value(header_t *header, char **cur) +{ + char *end = *cur, *value; + DWORD len; + + do { + end = strstr(end, "\r\n"); + end += 2; + } while(*end == ' ' || *end == '\t'); + + len = end - *cur; + value = HeapAlloc(GetProcessHeap(), 0, len + 1); + memcpy(value, *cur, len); + value[len] = '\0'; + + unfold_header(value, len); + TRACE("value %s\n", debugstr_a(value)); + + if(header->prop->flags & MPF_HASPARAMS) + { + split_params(header, value); + TRACE("value w/o params %s\n", debugstr_a(value)); + } + + header->value.vt = VT_LPSTR; + header->value.pszVal = value; + + *cur = end; +} + +static void init_content_type(MimeBody *body, header_t *header) +{ + char *slash; + DWORD len; + + if(header->prop->id != PID_HDR_CNTTYPE) + { + ERR("called with header %s\n", header->prop->name); + return; + } + + slash = strchr(header->value.pszVal, '/'); + if(!slash) + { + WARN("malformed context type value\n"); + return; + } + len = slash - header->value.pszVal; + body->content_pri_type = HeapAlloc(GetProcessHeap(), 0, len + 1); + memcpy(body->content_pri_type, header->value.pszVal, len); + body->content_pri_type[len] = '\0'; + body->content_sub_type = strdupA(slash + 1); +} + +static HRESULT parse_headers(MimeBody *body, IStream *stm) +{ + char *header_buf, *cur_header_ptr; + HRESULT hr; + header_t *header; + + hr = copy_headers_to_buf(stm, &header_buf); + if(FAILED(hr)) return hr; + + cur_header_ptr = header_buf; + while((header = read_prop(body, &cur_header_ptr))) + { + read_value(header, &cur_header_ptr); + list_add_tail(&body->headers, &header->entry); + + if(header->prop->id == PID_HDR_CNTTYPE) + init_content_type(body, header); + } + + HeapFree(GetProcessHeap(), 0, header_buf); + return hr; +} + +static void emptry_param_list(struct list *list) +{ + param_t *param, *cursor2; + + LIST_FOR_EACH_ENTRY_SAFE(param, cursor2, list, param_t, entry) + { + list_remove(¶m->entry); + HeapFree(GetProcessHeap(), 0, param->name); + HeapFree(GetProcessHeap(), 0, param->value); + HeapFree(GetProcessHeap(), 0, param); + } +} + +static void empty_header_list(struct list *list) +{ + header_t *header, *cursor2; + + LIST_FOR_EACH_ENTRY_SAFE(header, cursor2, list, header_t, entry) + { + list_remove(&header->entry); + PropVariantClear(&header->value); + emptry_param_list(&header->params); + HeapFree(GetProcessHeap(), 0, header); + } +} + +static void empty_new_prop_list(struct list *list) +{ + property_list_entry_t *prop, *cursor2; + + LIST_FOR_EACH_ENTRY_SAFE(prop, cursor2, list, property_list_entry_t, entry) + { + list_remove(&prop->entry); + HeapFree(GetProcessHeap(), 0, (char *)prop->prop.name); + HeapFree(GetProcessHeap(), 0, prop); + } +} + +static void release_data(REFIID riid, void *data) +{ + if(!data) return; + + if(IsEqualIID(riid, &IID_IStream)) + IStream_Release((IStream *)data); + else + FIXME("Unhandled data format %s\n", debugstr_guid(riid)); +} + static HRESULT WINAPI MimeBody_QueryInterface(IMimeBody* iface, REFIID riid, void** ppvObject) @@ -93,6 +487,14 @@ static ULONG WINAPI MimeBody_Release(IMimeBody* iface) refs = InterlockedDecrement(&This->refs); if (!refs) { + empty_header_list(&This->headers); + empty_new_prop_list(&This->new_props); + + HeapFree(GetProcessHeap(), 0, This->content_pri_type); + HeapFree(GetProcessHeap(), 0, This->content_sub_type); + + release_data(&This->data_iid, This->data); + HeapFree(GetProcessHeap(), 0, This); } @@ -119,8 +521,9 @@ static HRESULT WINAPI MimeBody_Load( IMimeBody* iface, LPSTREAM pStm) { - FIXME("(%p)->(%p): stub\n", iface, pStm); - return E_NOTIMPL; + MimeBody *This = impl_from_IMimeBody(iface); + TRACE("(%p)->(%p)\n", iface, pStm); + return parse_headers(This, pStm); } static HRESULT WINAPI MimeBody_Save( @@ -143,8 +546,8 @@ static HRESULT WINAPI MimeBody_GetSizeMax( static HRESULT WINAPI MimeBody_InitNew( IMimeBody* iface) { - FIXME("stub\n"); - return E_NOTIMPL; + TRACE("%p->()\n", iface); + return S_OK; } static HRESULT WINAPI MimeBody_GetPropInfo( @@ -275,8 +678,24 @@ static HRESULT WINAPI MimeBody_IsContentType( LPCSTR pszPriType, LPCSTR pszSubType) { - FIXME("stub\n"); - return E_NOTIMPL; + MimeBody *This = impl_from_IMimeBody(iface); + + TRACE("(%p)->(%s, %s)\n", This, debugstr_a(pszPriType), debugstr_a(pszSubType)); + if(pszPriType) + { + const char *pri = This->content_pri_type; + if(!pri) pri = "text"; + if(strcasecmp(pri, pszPriType)) return S_FALSE; + } + + if(pszSubType) + { + const char *sub = This->content_sub_type; + if(!sub) sub = "plain"; + if(strcasecmp(sub, pszSubType)) return S_FALSE; + } + + return S_OK; } static HRESULT WINAPI MimeBody_BindToObject( @@ -359,16 +778,24 @@ static HRESULT WINAPI MimeBody_GetCurrentEncoding( IMimeBody* iface, ENCODINGTYPE* pietEncoding) { - FIXME("stub\n"); - return E_NOTIMPL; + MimeBody *This = impl_from_IMimeBody(iface); + + TRACE("(%p)->(%p)\n", This, pietEncoding); + + *pietEncoding = This->encoding; + return S_OK; } static HRESULT WINAPI MimeBody_SetCurrentEncoding( IMimeBody* iface, ENCODINGTYPE ietEncoding) { - FIXME("stub\n"); - return E_NOTIMPL; + MimeBody *This = impl_from_IMimeBody(iface); + + TRACE("(%p)->(%d)\n", This, ietEncoding); + + This->encoding = ietEncoding; + return S_OK; } static HRESULT WINAPI MimeBody_GetEstimatedSize( @@ -406,8 +833,31 @@ static HRESULT WINAPI MimeBody_SetData( REFIID riid, LPVOID pvObject) { - FIXME("stub\n"); - return E_NOTIMPL; + MimeBody *This = impl_from_IMimeBody(iface); + TRACE("(%p)->(%d, %s, %s, %s %p)\n", This, ietEncoding, debugstr_a(pszPriType), debugstr_a(pszSubType), + debugstr_guid(riid), pvObject); + + if(IsEqualIID(riid, &IID_IStream)) + IStream_AddRef((IStream *)pvObject); + else + { + FIXME("Unhandled object type %s\n", debugstr_guid(riid)); + return E_INVALIDARG; + } + + if(This->data) + FIXME("release old data\n"); + + This->data_iid = *riid; + This->data = pvObject; + + IMimeBody_SetCurrentEncoding(iface, ietEncoding); + + /* FIXME: Update the content type. + If pszPriType == NULL use 'application' + If pszSubType == NULL use 'octet-stream' */ + + return S_OK; } static HRESULT WINAPI MimeBody_EmptyData( @@ -500,6 +950,8 @@ static IMimeBodyVtbl body_vtbl = MimeBody_GetHandle }; +#define FIRST_CUSTOM_PROP_ID 0x100 + HRESULT MimeBody_create(IUnknown *outer, void **obj) { MimeBody *This; @@ -514,6 +966,14 @@ HRESULT MimeBody_create(IUnknown *outer, void **obj) This->lpVtbl = &body_vtbl; This->refs = 1; This->handle = NULL; + list_init(&This->headers); + list_init(&This->new_props); + This->next_prop_id = FIRST_CUSTOM_PROP_ID; + This->content_pri_type = NULL; + This->content_sub_type = NULL; + This->encoding = IET_7BIT; + This->data = NULL; + This->data_iid = IID_NULL; *obj = (IMimeBody *)&This->lpVtbl; return S_OK; diff --git a/dlls/inetcomm/regsvr.c b/dlls/inetcomm/regsvr.c index 9bd9930dc55..97759fc2e3e 100644 --- a/dlls/inetcomm/regsvr.c +++ b/dlls/inetcomm/regsvr.c @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define INITGUID #include #include @@ -28,7 +27,10 @@ #include "winuser.h" #include "winreg.h" #include "winerror.h" +#include "objbase.h" +#include "ocidl.h" +#include "initguid.h" #include "inetcomm_private.h" #include "mimeole.h" diff --git a/dlls/inetcomm/tests/Makefile.in b/dlls/inetcomm/tests/Makefile.in index 93e8b3bf1f4..9c001cc5eeb 100644 --- a/dlls/inetcomm/tests/Makefile.in +++ b/dlls/inetcomm/tests/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = inetcomm.dll IMPORTS = inetcomm ole32 kernel32 -EXTRALIBS = +EXTRALIBS = -luuid CTESTS = \ mimeole.c diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c index 156884efcb8..c425c214c20 100644 --- a/dlls/inetcomm/tests/mimeole.c +++ b/dlls/inetcomm/tests/mimeole.c @@ -32,6 +32,32 @@ #include "wine/test.h" +static char msg1[] = + "MIME-Version: 1.0\r\n" + "Content-Type: multipart/mixed;\r\n" + " boundary=\"------------1.5.0.6\";\r\n" + " stuff=\"du;nno\"\r\n" + "foo: bar\r\n" + "From: Huw Davies \r\n" + "From: Me \r\n" + "To: wine-patches \r\n" + "Cc: Huw Davies ,\r\n" + " \"Fred Bloggs\" \r\n" + "foo: baz\r\n" + "bar: fum\r\n" + "\r\n" + "This is a multi-part message in MIME format.\r\n" + "--------------1.5.0.6\r\n" + "Content-Type: text/plain; format=fixed; charset=UTF-8\r\n" + "Content-Transfer-Encoding: 8bit\r\n" + "\r\n" + "Stuff\r\n" + "--------------1.5.0.6\r\n" + "Content-Type: text/plain; charset=\"us-ascii\"\r\n" + "Content-Transfer-Encoding: 7bit\r\n" + "\r\n" + "More stuff\r\n" + "--------------1.5.0.6--\r\n"; static void test_CreateVirtualStream(void) { @@ -60,6 +86,10 @@ static void test_CreateBody(void) HRESULT hr; IMimeBody *body; HBODY handle = (void *)0xdeadbeef; + IStream *in; + LARGE_INTEGER off; + ULARGE_INTEGER pos; + ENCODINGTYPE enc; hr = CoCreateInstance(&CLSID_IMimeBody, NULL, CLSCTX_INPROC_SERVER, &IID_IMimeBody, (void**)&body); ok(hr == S_OK, "ret %08x\n", hr); @@ -68,6 +98,42 @@ static void test_CreateBody(void) ok(hr == MIME_E_NO_DATA, "ret %08x\n", hr); ok(handle == NULL, "handle %p\n", handle); + hr = CreateStreamOnHGlobal(NULL, TRUE, &in); + ok(hr == S_OK, "ret %08x\n", hr); + IStream_Write(in, msg1, sizeof(msg1) - 1, NULL); + off.QuadPart = 0; + IStream_Seek(in, off, STREAM_SEEK_SET, NULL); + + /* Need to call InitNew before Load otherwise Load crashes with native inetcomm */ + hr = IMimeBody_InitNew(body); + ok(hr == S_OK, "ret %08x\n", hr); + + hr = IMimeBody_GetCurrentEncoding(body, &enc); + ok(hr == S_OK, "ret %08x\n", hr); + ok(enc == IET_7BIT, "encoding %d\n", enc); + + hr = IMimeBody_Load(body, in); + ok(hr == S_OK, "ret %08x\n", hr); + off.QuadPart = 0; + IStream_Seek(in, off, STREAM_SEEK_CUR, &pos); + ok(pos.LowPart == 328, "pos %u\n", pos.LowPart); + + hr = IMimeBody_IsContentType(body, "multipart", "mixed"); + ok(hr == S_OK, "ret %08x\n", hr); + hr = IMimeBody_IsContentType(body, "text", "plain"); + ok(hr == S_FALSE, "ret %08x\n", hr); + hr = IMimeBody_IsContentType(body, NULL, "mixed"); + ok(hr == S_OK, "ret %08x\n", hr); + + hr = IMimeBody_SetData(body, IET_8BIT, "text", "plain", &IID_IStream, in); + ok(hr == S_OK, "ret %08x\n", hr); + hr = IMimeBody_IsContentType(body, "text", "plain"); + todo_wine + ok(hr == S_OK, "ret %08x\n", hr); + hr = IMimeBody_GetCurrentEncoding(body, &enc); + ok(hr == S_OK, "ret %08x\n", hr); + ok(enc == IET_8BIT, "encoding %d\n", enc); + IMimeBody_Release(body); } diff --git a/dlls/itss/chm_lib.c b/dlls/itss/chm_lib.c index 67954ac894e..c41c42312f0 100644 --- a/dlls/itss/chm_lib.c +++ b/dlls/itss/chm_lib.c @@ -1326,7 +1326,7 @@ LONGINT64 chm_retrieve_object(struct chmFile *h, return (Int64)0; /* starting address must be in correct range */ - if (addr < 0 || addr >= ui->length) + if (addr >= ui->length) return (Int64)0; /* clip length */ diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index bc3ba3aa106..7bc5db34fdb 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -386,7 +386,7 @@ @ stdcall FindResourceExA(long str str long) @ stdcall FindResourceExW(long wstr wstr long) @ stdcall FindResourceW(long wstr wstr) -@ stub FindVolumeClose +@ stdcall FindVolumeClose(ptr) @ stdcall FindVolumeMountPointClose(ptr) @ stdcall FlushConsoleInputBuffer(long) @ stdcall FlushFileBuffers(long) diff --git a/dlls/kernel32/local16.c b/dlls/kernel32/local16.c index 87f11edbfaa..36bd7740492 100644 --- a/dlls/kernel32/local16.c +++ b/dlls/kernel32/local16.c @@ -1930,6 +1930,7 @@ static VOID Local32_ToHandle( LOCAL32HEADER *header, INT16 type, static VOID Local32_FromHandle( LOCAL32HEADER *header, INT16 type, DWORD *addr, LPDWORD handle, LPBYTE ptr ) { + *addr = 0; switch (type) { case -2: /* 16:16 pointer */ diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index 643128d2623..40f8b6e353f 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -75,7 +75,7 @@ static const char manifest4[] = "" "" "" + "version=\"6.0.1.0\" processorArchitecture=\"x86\" publicKeyToken=\"6595b64144ccf1df\">" "" "" "" diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 712ddf3996f..54918cfa580 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -557,6 +557,9 @@ static void test_NtMapViewOfSection(void) CloseHandle( mapping ); CloseHandle( file ); DeleteFileA( testfile ); + + TerminateProcess(hProcess, 0); + CloseHandle(hProcess); } static void test_BadPtr(void) diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c index 5ebe91f64d5..655fda15411 100644 --- a/dlls/kernel32/volume.c +++ b/dlls/kernel32/volume.c @@ -58,11 +58,14 @@ enum fs_type { FS_ERROR, /* error accessing the device */ FS_UNKNOWN, /* unknown file system */ + FS_PLACEHOLDER, /* Wine placeholder for drive device */ FS_FAT1216, FS_FAT32, FS_ISO9660 }; +static const char wine_placeholder[] = "Wine device placeholder"; + static const WCHAR drive_types[][8] = { { 0 }, /* DRIVE_UNKNOWN */ @@ -161,6 +164,52 @@ static BOOL open_device_root( LPCWSTR root, HANDLE *handle ) return TRUE; } +/* get the label by reading it from a file at the root of the filesystem */ +static void get_filesystem_label( const WCHAR *device, WCHAR *label, DWORD len ) +{ + HANDLE handle; + WCHAR labelW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','l','a','b','e','l',0}; + + labelW[0] = device[4]; + handle = CreateFileW( labelW, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, 0 ); + if (handle != INVALID_HANDLE_VALUE) + { + char buffer[256], *p; + DWORD size; + + if (!ReadFile( handle, buffer, sizeof(buffer)-1, &size, NULL )) size = 0; + CloseHandle( handle ); + p = buffer + size; + while (p > buffer && (p[-1] == ' ' || p[-1] == '\r' || p[-1] == '\n')) p--; + *p = 0; + if (!MultiByteToWideChar( CP_UNIXCP, 0, buffer, -1, label, len )) + label[len-1] = 0; + } + else label[0] = 0; +} + +/* get the serial number by reading it from a file at the root of the filesystem */ +static DWORD get_filesystem_serial( const WCHAR *device ) +{ + HANDLE handle; + WCHAR serialW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','s','e','r','i','a','l',0}; + + serialW[0] = device[4]; + handle = CreateFileW( serialW, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, 0 ); + if (handle != INVALID_HANDLE_VALUE) + { + char buffer[32]; + DWORD size; + + if (!ReadFile( handle, buffer, sizeof(buffer)-1, &size, NULL )) size = 0; + CloseHandle( handle ); + buffer[size] = 0; + return strtoul( buffer, NULL, 16 ); + } + else return 0; +} /* fetch the type of a drive from the registry */ static UINT get_registry_drive_type( const WCHAR *root ) @@ -256,10 +305,15 @@ static enum fs_type VOLUME_ReadFATSuperblock( HANDLE handle, BYTE *buff ) /* try a fixed disk, with a FAT partition */ if (SetFilePointer( handle, 0, NULL, FILE_BEGIN ) != 0 || - !ReadFile( handle, buff, SUPERBLOCK_SIZE, &size, NULL ) || - size != SUPERBLOCK_SIZE) + !ReadFile( handle, buff, SUPERBLOCK_SIZE, &size, NULL )) return FS_ERROR; + if (size >= sizeof(wine_placeholder)-1 && + !memcmp( buff, wine_placeholder, sizeof(wine_placeholder)-1 )) + return FS_PLACEHOLDER; + + if (size != SUPERBLOCK_SIZE) return FS_ERROR; + /* FIXME: do really all FAT have their name beginning with * "FAT" ? (At least FAT12, FAT16 and FAT32 have :) */ @@ -332,7 +386,7 @@ static enum fs_type VOLUME_ReadCDSuperblock( HANDLE handle, BYTE *buff ) /************************************************************************** * VOLUME_GetSuperblockLabel */ -static void VOLUME_GetSuperblockLabel( enum fs_type type, const BYTE *superblock, +static void VOLUME_GetSuperblockLabel( const WCHAR *device, enum fs_type type, const BYTE *superblock, WCHAR *label, DWORD len ) { const BYTE *label_ptr = NULL; @@ -344,6 +398,9 @@ static void VOLUME_GetSuperblockLabel( enum fs_type type, const BYTE *superblock case FS_UNKNOWN: label_len = 0; break; + case FS_PLACEHOLDER: + get_filesystem_label( device, label, len ); + break; case FS_FAT1216: label_ptr = superblock + 0x2b; label_len = 11; @@ -384,13 +441,15 @@ static void VOLUME_GetSuperblockLabel( enum fs_type type, const BYTE *superblock /************************************************************************** * VOLUME_GetSuperblockSerial */ -static DWORD VOLUME_GetSuperblockSerial( enum fs_type type, const BYTE *superblock ) +static DWORD VOLUME_GetSuperblockSerial( const WCHAR *device, enum fs_type type, const BYTE *superblock ) { switch(type) { case FS_ERROR: case FS_UNKNOWN: break; + case FS_PLACEHOLDER: + return get_filesystem_serial( device ); case FS_FAT1216: return GETLONG( superblock, 0x27 ); case FS_FAT32: @@ -519,8 +578,8 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len, TRACE( "%s: found fs type %d\n", debugstr_w(device), type ); if (type == FS_ERROR) return FALSE; - if (label && label_len) VOLUME_GetSuperblockLabel( type, superblock, label, label_len ); - if (serial) *serial = VOLUME_GetSuperblockSerial( type, superblock ); + if (label && label_len) VOLUME_GetSuperblockLabel( device, type, superblock, label, label_len ); + if (serial) *serial = VOLUME_GetSuperblockSerial( device, type, superblock ); goto fill_fs_info; } else TRACE( "cannot open device %s: err %d\n", debugstr_w(device), GetLastError() ); @@ -544,47 +603,8 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len, break; } - if (label && label_len) - { - WCHAR labelW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','l','a','b','e','l',0}; - - labelW[0] = device[4]; - handle = CreateFileW( labelW, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, 0, 0 ); - if (handle != INVALID_HANDLE_VALUE) - { - char buffer[256], *p; - DWORD size; - - if (!ReadFile( handle, buffer, sizeof(buffer)-1, &size, NULL )) size = 0; - CloseHandle( handle ); - p = buffer + size; - while (p > buffer && (p[-1] == ' ' || p[-1] == '\r' || p[-1] == '\n')) p--; - *p = 0; - if (!MultiByteToWideChar( CP_UNIXCP, 0, buffer, -1, label, label_len )) - label[label_len-1] = 0; - } - else label[0] = 0; - } - if (serial) - { - WCHAR serialW[] = {'A',':','\\','.','w','i','n','d','o','w','s','-','s','e','r','i','a','l',0}; - - serialW[0] = device[4]; - handle = CreateFileW( serialW, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, 0, 0 ); - if (handle != INVALID_HANDLE_VALUE) - { - char buffer[32]; - DWORD size; - - if (!ReadFile( handle, buffer, sizeof(buffer)-1, &size, NULL )) size = 0; - CloseHandle( handle ); - buffer[size] = 0; - *serial = strtoul( buffer, NULL, 16 ); - } - else *serial = 0; - } + if (label && label_len) get_filesystem_label( device, label, label_len ); + if (serial) *serial = get_filesystem_serial( device ); fill_fs_info: /* now fill in the information that depends on the file system type */ @@ -1428,6 +1448,16 @@ HANDLE WINAPI FindFirstVolumeMountPointW(LPCWSTR root, LPWSTR mount_point, DWORD } /*********************************************************************** + * FindVolumeClose (KERNEL32.@) + */ +BOOL WINAPI FindVolumeClose(HANDLE handle) +{ + FIXME("(%p), stub!\n", handle); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +/*********************************************************************** * FindVolumeMountPointClose (KERNEL32.@) */ BOOL WINAPI FindVolumeMountPointClose(HANDLE h) diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index cddcb3846bb..c8da454bf7d 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -25,6 +25,7 @@ C_SRCS = \ htmlselect.c \ htmlstyle.c \ htmlstylesheet.c \ + htmltable.c \ htmltextcont.c \ htmltextarea.c \ htmlwindow.c \ diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index e9df70e505f..6ad153a031c 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1046,7 +1046,7 @@ static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR FIXME("(%p)->(%s %ld %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet); - *ppnewStyleSheet = HTMLStyleSheet_Create(); + *ppnewStyleSheet = HTMLStyleSheet_Create(NULL); return S_OK; } diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 1ee755d4c41..cbe9bfd81db 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1293,6 +1293,7 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) static const WCHAR wszINPUT[] = {'I','N','P','U','T',0}; static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0}; static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0}; + static const WCHAR wszTABLE[] = {'T','A','B','L','E',0}; static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0}; nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem); @@ -1314,6 +1315,8 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) ret = HTMLOptionElement_Create(nselem); else if(!strcmpW(class_name, wszSELECT)) ret = HTMLSelectElement_Create(nselem); + else if(!strcmpW(class_name, wszTABLE)) + ret = HTMLTable_Create(nselem); else if(!strcmpW(class_name, wszTEXTAREA)) ret = HTMLTextAreaElement_Create(nselem); diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c index 30be0798016..30c25cee571 100644 --- a/dlls/mshtml/htmlstylesheet.c +++ b/dlls/mshtml/htmlstylesheet.c @@ -38,7 +38,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); typedef struct { const IHTMLStyleSheetVtbl *lpHTMLStyleSheetVtbl; + LONG ref; + + nsIDOMCSSStyleSheet *nsstylesheet; } HTMLStyleSheet; typedef struct { @@ -167,8 +170,38 @@ static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection VARIANT *pvarIndex, VARIANT *pvarResult) { HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface); - FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult); - return E_NOTIMPL; + + TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult); + + switch(V_VT(pvarIndex)) { + case VT_I4: { + nsIDOMStyleSheet *nsstylesheet; + nsresult nsres; + + TRACE("index=%d\n", V_I4(pvarIndex)); + + nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet); + if(NS_FAILED(nsres) || !nsstylesheet) { + WARN("Item failed: %08x\n", nsres); + V_VT(pvarResult) = VT_EMPTY; + return E_INVALIDARG; + } + + V_VT(pvarResult) = VT_DISPATCH; + V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet); + + return S_OK; + } + + case VT_BSTR: + FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult))); + return E_NOTIMPL; + + default: + WARN("Invalid vt=%d\n", V_VT(pvarIndex)); + } + + return E_INVALIDARG; } #undef HTMLSTYLESHEETSCOL_THIS @@ -470,12 +503,21 @@ static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = { HTMLStyleSheet_get_rules }; -IHTMLStyleSheet *HTMLStyleSheet_Create(void) +IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet) { HTMLStyleSheet *ret = mshtml_alloc(sizeof(HTMLStyleSheet)); + nsresult nsres; ret->lpHTMLStyleSheetVtbl = &HTMLStyleSheetVtbl; ret->ref = 1; + ret->nsstylesheet = NULL; + + if(nsstylesheet) { + nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet, + (void**)&ret->nsstylesheet); + if(NS_FAILED(nsres)) + ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres); + } return HTMLSTYLESHEET(ret); } diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c new file mode 100644 index 00000000000..373ffacea53 --- /dev/null +++ b/dlls/mshtml/htmltable.c @@ -0,0 +1,557 @@ +/* + * Copyright 2007 Jacek Caban 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" + +#include +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winnls.h" +#include "ole2.h" + +#include "wine/debug.h" + +#include "mshtml_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +typedef struct { + HTMLElement element; + + const IHTMLTableVtbl *lpHTMLTableVtbl; +} HTMLTable; + +#define HTMLTABLE(x) ((IHTMLTable*) &(x)->lpHTMLTableVtbl) + +#define HTMLTABLE_THIS(iface) DEFINE_THIS(HTMLTable, HTMLTable, iface) + +static HRESULT WINAPI HTMLTable_QueryInterface(IHTMLTable *iface, + REFIID riid, void **ppv) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv); +} + +static ULONG WINAPI HTMLTable_AddRef(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node)); +} + +static ULONG WINAPI HTMLTable_Release(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node)); +} + +static HRESULT WINAPI HTMLTable_GetTypeInfoCount(IHTMLTable *iface, UINT *pctinfo) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, pctinfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_GetTypeInfo(IHTMLTable *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_GetIDsOfNames(IHTMLTable *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, + lcid, rgDispId); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_Invoke(IHTMLTable *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_cols(IHTMLTable *iface, long v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%ld)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_cols(IHTMLTable *iface, long *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_border(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_border(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_frame(IHTMLTable *iface, BSTR v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_frame(IHTMLTable *iface, BSTR *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_rules(IHTMLTable *iface, BSTR v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_rules(IHTMLTable *iface, BSTR *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_cellSpacing(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_cellSpacing(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_cellPadding(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_cellPadding(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_background(IHTMLTable *iface, BSTR v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_background(IHTMLTable *iface, BSTR *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_bgColor(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_bgColor(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_borderColor(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_borderColor(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_borderColorLight(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_borderColorLight(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_borderColorDark(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_borderColorDark(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_align(IHTMLTable *iface, BSTR v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_align(IHTMLTable *iface, BSTR *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_refresh(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_rows(IHTMLTable *iface, IHTMLElementCollection **p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_width(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_width(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_height(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_height(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_dataPageSize(IHTMLTable *iface, long v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%ld)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_dataPageSize(IHTMLTable *iface, long *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_nextPage(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_previousPage(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_tHead(IHTMLTable *iface, IHTMLTableSection **p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_tFoot(IHTMLTable *iface, IHTMLTableSection **p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_tBodies(IHTMLTable *iface, IHTMLElementCollection **p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_caption(IHTMLTable *iface, IHTMLTableCaption **p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_createTHead(IHTMLTable *iface, IDispatch **head) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, head); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_deleteTHead(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_createTFoot(IHTMLTable *iface, IDispatch **foot) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, foot); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_deleteTFoot(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_createCaption(IHTMLTable *iface, IHTMLTableCaption **caption) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, caption); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_deleteCaption(IHTMLTable *iface) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_insertRow(IHTMLTable *iface, long index, IDispatch **row) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%ld %p)\n", This, index, row); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_deleteRow(IHTMLTable *iface, long index) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%ld)\n", This, index); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_readyState(IHTMLTable *iface, BSTR *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_put_onreadystatechange(IHTMLTable *iface, VARIANT v) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTable_get_onreadystatechange(IHTMLTable *iface, VARIANT *p) +{ + HTMLTable *This = HTMLTABLE_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +#undef HTMLTABLE_THIS + +static const IHTMLTableVtbl HTMLTableVtbl = { + HTMLTable_QueryInterface, + HTMLTable_AddRef, + HTMLTable_Release, + HTMLTable_GetTypeInfoCount, + HTMLTable_GetTypeInfo, + HTMLTable_GetIDsOfNames, + HTMLTable_Invoke, + HTMLTable_put_cols, + HTMLTable_get_cols, + HTMLTable_put_border, + HTMLTable_get_border, + HTMLTable_put_frame, + HTMLTable_get_frame, + HTMLTable_put_rules, + HTMLTable_get_rules, + HTMLTable_put_cellSpacing, + HTMLTable_get_cellSpacing, + HTMLTable_put_cellPadding, + HTMLTable_get_cellPadding, + HTMLTable_put_background, + HTMLTable_get_background, + HTMLTable_put_bgColor, + HTMLTable_get_bgColor, + HTMLTable_put_borderColor, + HTMLTable_get_borderColor, + HTMLTable_put_borderColorLight, + HTMLTable_get_borderColorLight, + HTMLTable_put_borderColorDark, + HTMLTable_get_borderColorDark, + HTMLTable_put_align, + HTMLTable_get_align, + HTMLTable_refresh, + HTMLTable_get_rows, + HTMLTable_put_width, + HTMLTable_get_width, + HTMLTable_put_height, + HTMLTable_get_height, + HTMLTable_put_dataPageSize, + HTMLTable_get_dataPageSize, + HTMLTable_nextPage, + HTMLTable_previousPage, + HTMLTable_get_tHead, + HTMLTable_get_tFoot, + HTMLTable_get_tBodies, + HTMLTable_get_caption, + HTMLTable_createTHead, + HTMLTable_deleteTHead, + HTMLTable_createTFoot, + HTMLTable_deleteTFoot, + HTMLTable_createCaption, + HTMLTable_deleteCaption, + HTMLTable_insertRow, + HTMLTable_deleteRow, + HTMLTable_get_readyState, + HTMLTable_put_onreadystatechange, + HTMLTable_get_onreadystatechange +}; + +#define HTMLTABLE_NODE_THIS(iface) DEFINE_THIS2(HTMLTable, element.node, iface) + +static HRESULT HTMLTable_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLTable *This = HTMLTABLE_NODE_THIS(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = HTMLTABLE(This); + }else if(IsEqualGUID(&IID_IDispatch, riid)) { + TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); + *ppv = HTMLTABLE(This); + }else if(IsEqualGUID(&IID_IHTMLTable, riid)) { + TRACE("(%p)->(IID_IHTMLTable %p)\n", This, ppv); + *ppv = HTMLTABLE(This); + } + + if(*ppv) { + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; + } + + return HTMLElement_QI(&This->element.node, riid, ppv); +} + +static void HTMLTable_destructor(HTMLDOMNode *iface) +{ + HTMLTable *This = HTMLTABLE_NODE_THIS(iface); + HTMLElement_destructor(&This->element.node); +} + +#undef HTMLTABLE_NODE_THIS + +static const NodeImplVtbl HTMLTableImplVtbl = { + HTMLTable_QI, + HTMLTable_destructor +}; + +HTMLElement *HTMLTable_Create(nsIDOMHTMLElement *nselem) +{ + HTMLTable *ret = mshtml_alloc(sizeof(HTMLTable)); + + ret->element.node.vtbl = &HTMLTableImplVtbl; + ret->lpHTMLTableVtbl = &HTMLTableVtbl; + + return &ret->element; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 2bf926b3e25..55d1a91da4d 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -430,7 +430,7 @@ void set_current_mon(HTMLDocument*,IMoniker*); IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*); IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*); IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*); -IHTMLStyleSheet *HTMLStyleSheet_Create(void); +IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*); IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*); void detach_selection(HTMLDocument*); @@ -442,6 +442,7 @@ HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*); +HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*); HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*); void HTMLElement2_Init(HTMLElement*); diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index aac9a879606..8f2876c2dee 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -123,7 +123,8 @@ typedef nsISupports nsIPrincipal; typedef nsISupports nsIAtom; typedef nsISupports nsISupportsArray; typedef nsISupports nsIContentFilter; -typedef nsISupports nsIDOMStyleSheet; +typedef nsISupports nsIDOMMediaList; +typedef nsISupports nsIDOMCSSRuleList; [ object, @@ -572,6 +573,36 @@ interface nsIDOMCSSStyleDeclaration : nsISupports [ object, + uuid(a6cf9080-15b3-11d2-932e-00805f8add32) + /* FROZEN */ +] +interface nsIDOMStyleSheet : nsISupports +{ + nsresult GetType(nsAString *aType); + nsresult GetDisabled(PRBool *aDisabled); + nsresult SetDisabled(PRBool aDisabled); + nsresult GetOwnerNode(nsIDOMNode **aOwnerNode); + nsresult GetParentStyleSheet(nsIDOMStyleSheet **aParentStyleSheet); + nsresult GetHref(nsAString *aHref); + nsresult GetTitle(nsAString *aTitle); + nsresult GetMedia(nsIDOMMediaList **aMedia); +} + +[ + object, + uuid(a6cf90c2-15b3-11d2-932e-00805f8add32) + /* FROZEN */ +] +interface nsIDOMCSSStyleSheet : nsIDOMStyleSheet +{ + nsresult GetOwnerRule(nsIDOMCSSRule **aOwnerRule); + nsresult GetCssRules(nsIDOMCSSRuleList **aCssRules); + nsresult InsertRule(const nsAString *rule, PRUint32 index, PRUint32 *_retval); + nsresult DeleteRule(PRUint32 index); +} + +[ + object, uuid(a6cf9081-15b3-11d2-932e-00805f8add32) /* FROZEN */ ] diff --git a/dlls/mshtml/txtrange.c b/dlls/mshtml/txtrange.c index 0ad3621e0f1..1d8d2cb65f8 100644 --- a/dlls/mshtml/txtrange.c +++ b/dlls/mshtml/txtrange.c @@ -40,6 +40,7 @@ static const WCHAR brW[] = {'b','r',0}; typedef struct { const IHTMLTxtRangeVtbl *lpHTMLTxtRangeVtbl; + const IOleCommandTargetVtbl *lpOleCommandTargetVtbl; LONG ref; @@ -942,6 +943,9 @@ static HRESULT WINAPI HTMLTxtRange_QueryInterface(IHTMLTxtRange *iface, REFIID r }else if(IsEqualGUID(&IID_IHTMLTxtRange, riid)) { TRACE("(%p)->(IID_IHTMLTxtRange %p)\n", This, ppv); *ppv = HTMLTXTRANGE(This); + }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) { + TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv); + *ppv = CMDTARGET(This); } if(*ppv) { @@ -1697,11 +1701,66 @@ static const IHTMLTxtRangeVtbl HTMLTxtRangeVtbl = { HTMLTxtRange_execCommandShowHelp }; +#define OLECMDTRG_THIS(iface) DEFINE_THIS(HTMLTxtRange, OleCommandTarget, iface) + +static HRESULT WINAPI RangeCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv) +{ + HTMLTxtRange *This = OLECMDTRG_THIS(iface); + return IHTMLTxtRange_QueryInterface(HTMLTXTRANGE(This), riid, ppv); +} + +static ULONG WINAPI RangeCommandTarget_AddRef(IOleCommandTarget *iface) +{ + HTMLTxtRange *This = OLECMDTRG_THIS(iface); + return IHTMLTxtRange_AddRef(HTMLTXTRANGE(This)); +} + +static ULONG WINAPI RangeCommandTarget_Release(IOleCommandTarget *iface) +{ + HTMLTxtRange *This = OLECMDTRG_THIS(iface); + return IHTMLTxtRange_Release(HTMLTXTRANGE(This)); +} + +static HRESULT WINAPI RangeCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup, + ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText) +{ + HTMLTxtRange *This = OLECMDTRG_THIS(iface); + FIXME("(%p)->(%s %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText); + return E_NOTIMPL; +} + +static HRESULT WINAPI RangeCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup, + DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) +{ + HTMLTxtRange *This = OLECMDTRG_THIS(iface); + TRACE("(%p)->(%s %d %x %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, + nCmdexecopt, pvaIn, pvaOut); + + if(pguidCmdGroup && IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) { + FIXME("Unsupported cmdid %d of CGID_MSHTML\n", nCmdID); + }else { + FIXME("Unsupported cmd %d of group %s\n", nCmdID, debugstr_guid(pguidCmdGroup)); + } + + return E_NOTIMPL; +} + +#undef OLECMDTRG_THIS + +static const IOleCommandTargetVtbl OleCommandTargetVtbl = { + RangeCommandTarget_QueryInterface, + RangeCommandTarget_AddRef, + RangeCommandTarget_Release, + RangeCommandTarget_QueryStatus, + RangeCommandTarget_Exec +}; + IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument *doc, nsIDOMRange *nsrange) { HTMLTxtRange *ret = mshtml_alloc(sizeof(HTMLTxtRange)); ret->lpHTMLTxtRangeVtbl = &HTMLTxtRangeVtbl; + ret->lpOleCommandTargetVtbl = &OleCommandTargetVtbl; ret->ref = 1; if(nsrange) diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 30663085e29..89f7bd7b6bc 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -1394,6 +1394,41 @@ static LPWSTR folder_split_path(LPWSTR p, WCHAR ch) return p+1; } +static UINT load_file_hash(MSIPACKAGE *package, MSIFILE *file) +{ + static const WCHAR query[] = { + 'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ', + '`','M','s','i','F','i','l','e','H','a','s','h','`',' ', + 'W','H','E','R','E',' ','`','F','i','l','e','_','`',' ','=',' ','\'','%','s','\'',0}; + MSIQUERY *view = NULL; + MSIRECORD *row; + UINT r; + + TRACE("%s\n", debugstr_w(file->File)); + + r = MSI_OpenQuery(package->db, &view, query, file->File); + if (r != ERROR_SUCCESS) + goto done; + + r = MSI_ViewExecute(view, NULL); + if (r != ERROR_SUCCESS) + goto done; + + r = MSI_ViewFetch(view, &row); + if (r != ERROR_SUCCESS) + goto done; + + file->hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO); + file->hash.dwData[0] = MSI_RecordGetInteger(row, 3); + file->hash.dwData[1] = MSI_RecordGetInteger(row, 4); + file->hash.dwData[2] = MSI_RecordGetInteger(row, 5); + file->hash.dwData[3] = MSI_RecordGetInteger(row, 6); + +done: + if (view) msiobj_release(&view->hdr); + return r; +} + static UINT load_file(MSIRECORD *row, LPVOID param) { MSIPACKAGE* package = (MSIPACKAGE*)param; @@ -1444,6 +1479,8 @@ static UINT load_file(MSIRECORD *row, LPVOID param) file->IsCompressed = package->WordCount & MSIWORDCOUNT_COMPRESSED; } + load_file_hash(package, file); + TRACE("File Loaded (%s)\n",debugstr_w(file->File)); list_add_tail( &package->files, &file->entry ); diff --git a/dlls/msi/appsearch.c b/dlls/msi/appsearch.c index 5baaa768541..64b2d485862 100644 --- a/dlls/msi/appsearch.c +++ b/dlls/msi/appsearch.c @@ -677,14 +677,15 @@ static UINT ACTION_RecurseSearchDirectory(MSIPACKAGE *package, LPWSTR *appValue, static UINT ACTION_CheckDirectory(MSIPACKAGE *package, LPCWSTR dir, LPWSTR *appValue) { - UINT rc = ERROR_SUCCESS; + DWORD attr = GetFileAttributesW(dir); - if (GetFileAttributesW(dir) & FILE_ATTRIBUTE_DIRECTORY) + if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY)) { TRACE("directory exists, returning %s\n", debugstr_w(dir)); *appValue = strdupW(dir); } - return rc; + + return ERROR_SUCCESS; } static BOOL ACTION_IsFullPath(LPCWSTR path) diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c index a44b918f485..269aa3af02f 100644 --- a/dlls/msi/custom.c +++ b/dlls/msi/custom.c @@ -226,7 +226,7 @@ UINT ACTION_CustomAction(MSIPACKAGE *package, LPCWSTR action, UINT script, BOOL if (type & msidbCustomActionTypeInScript) { if (type & msidbCustomActionTypeNoImpersonate) - FIXME("msidbCustomActionTypeNoImpersonate not handled\n"); + WARN("msidbCustomActionTypeNoImpersonate not handled\n"); if (type & msidbCustomActionTypeRollback) { diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c index 9241a668dc0..d0e91cded13 100644 --- a/dlls/msi/dialog.c +++ b/dlls/msi/dialog.c @@ -810,7 +810,7 @@ static LPWSTR msi_get_checkbox_value( msi_dialog *dialog, LPCWSTR prop ) { static const WCHAR query[] = { 'S','E','L','E','C','T',' ','*',' ', - 'F','R','O','M',' ','`','C','h','e','c','k','B','o','x',' ','`', + 'F','R','O','M',' ','`','C','h','e','c','k','B','o','x','`',' ', 'W','H','E','R','E',' ', '`','P','r','o','p','e','r','t','y','`',' ','=',' ', '\'','%','s','\'',0 diff --git a/dlls/msi/files.c b/dlls/msi/files.c index c50e4200a4b..8d5321c9df2 100644 --- a/dlls/msi/files.c +++ b/dlls/msi/files.c @@ -62,6 +62,7 @@ struct media_info { UINT last_sequence; LPWSTR disk_prompt; LPWSTR cabinet; + LPWSTR first_volume; LPWSTR volume_label; BOOL is_continuous; BOOL is_extracted; @@ -284,6 +285,9 @@ static UINT msi_media_get_disk_info( MSIPACKAGE *package, struct media_info *mi mi->cabinet = strdupW(MSI_RecordGetString(row, 4)); mi->volume_label = strdupW(MSI_RecordGetString(row, 5)); + if (!mi->first_volume) + mi->first_volume = strdupW(mi->volume_label); + ptr = strrchrW(mi->source, '\\') + 1; lstrcpyW(ptr, mi->cabinet); msiobj_release(&row->hdr); @@ -491,6 +495,7 @@ static void free_media_info( struct media_info *mi ) msi_free( mi->disk_prompt ); msi_free( mi->cabinet ); msi_free( mi->volume_label ); + msi_free( mi->first_volume ); msi_free( mi ); } @@ -563,6 +568,9 @@ static UINT load_media_info(MSIPACKAGE *package, MSIFILE *file, struct media_inf mi->volume_label = strdupW(MSI_RecordGetString(row, 5)); msiobj_release(&row->hdr); + if (!mi->first_volume) + mi->first_volume = strdupW(mi->volume_label); + source_dir = msi_dup_property(package, cszSourceDir); if (mi->cabinet && mi->cabinet[0] == '#') @@ -609,6 +617,10 @@ static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *m return ERROR_FUNCTION_FAILED; } + /* cabinet is internal, no checks needed */ + if (!mi->cabinet || mi->cabinet[0] == '#') + return ERROR_SUCCESS; + /* package should be downloaded */ if (file->IsCompressed && GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES && @@ -618,7 +630,8 @@ static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *m } /* check volume matches, change media if not */ - if (mi->volume_label && mi->disk_id > 1) + if (mi->volume_label && mi->disk_id > 1 && + lstrcmpW(mi->first_volume, mi->volume_label)) { LPWSTR source = msi_dup_property(package, cszSourceDir); BOOL matches; @@ -638,7 +651,6 @@ static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *m } if (file->IsCompressed && - mi->cabinet && mi->cabinet[0] != '#' && GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES) { ERR("Cabinet not found: %s\n", debugstr_w(mi->source)); @@ -733,6 +745,22 @@ static UINT copy_install_file(MSIFILE *file) return gle; } +static BOOL check_dest_hash_matches(MSIFILE *file) +{ + MSIFILEHASHINFO hash; + UINT r; + + if (!file->hash.dwFileHashInfoSize) + return FALSE; + + hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO); + r = MsiGetFileHashW(file->TargetPath, 0, &hash); + if (r != ERROR_SUCCESS) + return FALSE; + + return !memcmp(&hash, &file->hash, sizeof(MSIFILEHASHINFO)); +} + /* * ACTION_InstallFiles() * @@ -776,6 +804,12 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) if (file->state != msifs_missing && !mi->is_continuous && file->state != msifs_overwrite) continue; + if (check_dest_hash_matches(file)) + { + TRACE("File hashes match, not overwriting\n"); + continue; + } + if (file->Sequence > mi->last_sequence || mi->is_continuous || (file->IsCompressed && !mi->is_extracted)) { diff --git a/dlls/msi/format.c b/dlls/msi/format.c index 41d4a473edd..4cc5ed41d87 100644 --- a/dlls/msi/format.c +++ b/dlls/msi/format.c @@ -192,7 +192,7 @@ static LPWSTR deformat_environment(MSIPACKAGE* package, LPCWSTR key, } else { - ERR("Unknown environment variable %s\n", debugstr_w(key)); + WARN("Unknown environment variable %s\n", debugstr_w(key)); *chunk = 0; value = NULL; } diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index 7faccaf3afd..72e52afa87b 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -2277,6 +2277,12 @@ UINT WINAPI MsiGetFileHashW( LPCWSTR szFilePath, DWORD dwOptions, TRACE("%s %08x %p\n", debugstr_w(szFilePath), dwOptions, pHash ); + if (!szFilePath) + return ERROR_INVALID_PARAMETER; + + if (!*szFilePath) + return ERROR_PATH_NOT_FOUND; + if (dwOptions) return ERROR_INVALID_PARAMETER; if (!pHash) diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 4c7565bcb31..d5412608a65 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -424,6 +424,7 @@ typedef struct tagMSIFILE LPWSTR SourcePath; LPWSTR TargetPath; BOOL IsCompressed; + MSIFILEHASHINFO hash; } MSIFILE; typedef struct tagMSITEMPFILE diff --git a/dlls/msi/source.c b/dlls/msi/source.c index e6e1de5727a..68f94b549cc 100644 --- a/dlls/msi/source.c +++ b/dlls/msi/source.c @@ -240,8 +240,8 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid, if (szUserSid) FIXME("Unhandled UserSid %s\n",debugstr_w(szUserSid)); - if (dwContext == MSIINSTALLCONTEXT_USERUNMANAGED) - FIXME("Unknown context MSIINSTALLCONTEXT_USERUNMANAGED\n"); + if (dwContext != MSIINSTALLCONTEXT_USERUNMANAGED) + FIXME("Unhandled context %d\n", dwContext); rc = OpenSourceKey(szProduct, &sourcekey, dwOptions, dwContext, FALSE); if (rc != ERROR_SUCCESS) diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index b8817d9ab34..fd8184be313 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -557,7 +557,7 @@ static const CHAR mc_media_dat[] = "DiskId\tLastSequence\tDiskPrompt\tCabinet\tV static const CHAR mc_file_hash_dat[] = "File_\tOptions\tHashPart1\tHashPart2\tHashPart3\tHashPart4\n" "s72\ti2\ti4\ti4\ti4\ti4\n" "MsiFileHash\tFile_\n" - "caesar\t0\t1477005400\t-2141257985\t284379198\t21485139"; + "caesar\t0\t850433704\t-241429251\t675791761\t-1221108824"; typedef struct _msi_table { @@ -1100,24 +1100,26 @@ static BOOL get_program_files_dir(LPSTR buf, LPSTR buf2) return TRUE; } -static void create_file(const CHAR *name, DWORD size) +static void create_file_data(LPCSTR name, LPCSTR data, DWORD size) { HANDLE file; - DWORD written, left; + DWORD written; file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name); - WriteFile(file, name, strlen(name), &written, NULL); - WriteFile(file, "\n", strlen("\n"), &written, NULL); + WriteFile(file, data, strlen(data), &written, NULL); - left = size - lstrlen(name) - 1; + if (size) + { + SetFilePointer(file, size, NULL, FILE_BEGIN); + SetEndOfFile(file); + } - SetFilePointer(file, left, NULL, FILE_CURRENT); - SetEndOfFile(file); - CloseHandle(file); } +#define create_file(name, size) create_file_data(name, name, size) + static void create_test_files(void) { CreateDirectoryA("msitest", NULL); @@ -3286,7 +3288,7 @@ static void test_adminprops(void) RemoveDirectory("msitest"); } -static void create_pf(LPCSTR file, BOOL is_file) +static void create_pf_data(LPCSTR file, LPCSTR data, BOOL is_file) { CHAR path[MAX_PATH]; @@ -3295,11 +3297,13 @@ static void create_pf(LPCSTR file, BOOL is_file) lstrcatA(path, file); if (is_file) - create_file(path, 500); + create_file_data(path, data, 500); else CreateDirectoryA(path, NULL); } +#define create_pf(file, is_file) create_pf_data(file, file, is_file) + static void test_removefiles(void) { UINT r; @@ -3533,13 +3537,10 @@ static void test_missingcab(void) create_cab_file("test1.cab", MEDIA_SIZE, "maximus\0"); create_pf("msitest", FALSE); - create_pf("msitest\\caesar", TRUE); + create_pf_data("msitest\\caesar", "abcdefgh", TRUE); r = MsiInstallProductA(msifile, NULL); - todo_wine - { - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); - } + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); ok(delete_pf("msitest\\augustus", TRUE), "File not installed\n"); ok(delete_pf("msitest\\caesar", TRUE), "File not installed\n"); ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n"); @@ -3547,7 +3548,7 @@ static void test_missingcab(void) ok(delete_pf("msitest", FALSE), "File not installed\n"); create_pf("msitest", FALSE); - create_pf("msitest\\caesar", TRUE); + create_pf_data("msitest\\caesar", "abcdefgh", TRUE); create_pf("msitest\\gaius", TRUE); r = MsiInstallProductA(msifile, "GAIUS=1"); diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c index 446f497a5b9..2e5dc85ec46 100644 --- a/dlls/msi/tests/msi.c +++ b/dlls/msi/tests/msi.c @@ -28,17 +28,12 @@ #include "wine/test.h" -typedef struct test_MSIFILEHASHINFO { - ULONG dwFileHashInfoSize; - ULONG dwData[4]; -} test_MSIFILEHASHINFO, *test_PMSIFILEHASHINFO; - static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); static INSTALLSTATE (WINAPI *pMsiGetComponentPathA) (LPCSTR, LPCSTR, LPSTR, DWORD*); static UINT (WINAPI *pMsiGetFileHashA) - (LPCSTR, DWORD, test_PMSIFILEHASHINFO); + (LPCSTR, DWORD, PMSIFILEHASHINFO); static UINT (WINAPI *pMsiOpenPackageExA) (LPCSTR, DWORD, MSIHANDLE*); static UINT (WINAPI *pMsiOpenPackageExW) @@ -229,58 +224,105 @@ static void test_getcomponentpath(void) ok( r == INSTALLSTATE_UNKNOWN, "wrong return value\n"); } -static void test_filehash(void) +static void create_file(LPCSTR name, LPCSTR data, DWORD size) +{ + HANDLE file; + DWORD written; + + file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name); + WriteFile(file, data, strlen(data), &written, NULL); + + if (size) + { + SetFilePointer(file, size, NULL, FILE_BEGIN); + SetEndOfFile(file); + } + + CloseHandle(file); +} + +#define HASHSIZE sizeof(MSIFILEHASHINFO) + +static const struct +{ + LPCSTR data; + DWORD size; + MSIFILEHASHINFO hash; +} hash_data[] = +{ + { "abc", 0, + { HASHSIZE, + { 0x98500190, 0xb04fd23c, 0x7d3f96d6, 0x727fe128 }, + }, + }, + + { "C:\\Program Files\\msitest\\caesar\n", 0, + { HASHSIZE, + { 0x2b566794, 0xfd42181b, 0x2514d6e4, 0x5768b4e2 }, + }, + }, + + { "C:\\Program Files\\msitest\\caesar\n", 500, + { HASHSIZE, + { 0x58095058, 0x805efeff, 0x10f3483e, 0x0147d653 }, + }, + }, +}; + +static void test_MsiGetFileHash(void) { const char name[] = "msitest.bin"; - const char data[] = {'a','b','c'}; - HANDLE handle; UINT r; - test_MSIFILEHASHINFO hash; - DWORD count = 0; + MSIFILEHASHINFO hash; + DWORD i; if (!pMsiGetFileHashA) + { + skip("MsiGetFileHash not implemented."); return; + } - DeleteFile(name); + hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO); - memset(&hash, 0, sizeof hash); - r = pMsiGetFileHashA(name, 0, &hash); - ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r); + /* szFilePath is NULL */ + r = pMsiGetFileHashA(NULL, 0, &hash); + ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - r = pMsiGetFileHashA(name, 0, NULL); - ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r); + /* szFilePath is empty */ + r = pMsiGetFileHashA("", 0, &hash); + ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %d\n", r); - memset(&hash, 0, sizeof hash); - hash.dwFileHashInfoSize = sizeof hash; + /* szFilePath is nonexistent */ r = pMsiGetFileHashA(name, 0, &hash); - ok( r == ERROR_FILE_NOT_FOUND, "wrong error %d\n", r); + ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r); - handle = CreateFile(name, GENERIC_READ|GENERIC_WRITE, 0, NULL, - CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL); - ok(handle != INVALID_HANDLE_VALUE, "failed to create file\n"); - - WriteFile(handle, data, sizeof data, &count, NULL); - CloseHandle(handle); + /* dwOptions is non-zero */ + r = pMsiGetFileHashA(name, 1, &hash); + ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - memset(&hash, 0, sizeof hash); + /* pHash.dwFileHashInfoSize is not correct */ + hash.dwFileHashInfoSize = 0; r = pMsiGetFileHashA(name, 0, &hash); - ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r); + ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - memset(&hash, 0, sizeof hash); - hash.dwFileHashInfoSize = sizeof hash; - r = pMsiGetFileHashA(name, 1, &hash); - ok( r == ERROR_INVALID_PARAMETER, "wrong error %d\n", r); + /* pHash is NULL */ + r = pMsiGetFileHashA(name, 0, NULL); + ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); - r = pMsiGetFileHashA(name, 0, &hash); - ok( r == ERROR_SUCCESS, "wrong error %d\n", r); + for (i = 0; i < sizeof(hash_data) / sizeof(hash_data[0]); i++) + { + create_file(name, hash_data[i].data, hash_data[i].size); - ok(hash.dwFileHashInfoSize == sizeof hash, "hash size changed\n"); - ok(hash.dwData[0] == 0x98500190 && - hash.dwData[1] == 0xb04fd23c && - hash.dwData[2] == 0x7d3f96d6 && - hash.dwData[3] == 0x727fe128, "hash of abc incorrect\n"); + memset(&hash, 0, sizeof(MSIFILEHASHINFO)); + hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO); - DeleteFile(name); + r = pMsiGetFileHashA(name, 0, &hash); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(!memcmp(&hash, &hash_data[i].hash, HASHSIZE), "Hash incorrect\n"); + + DeleteFile(name); + } } /* copied from dlls/msi/registry.c */ @@ -941,7 +983,7 @@ START_TEST(msi) test_usefeature(); test_null(); test_getcomponentpath(); - test_filehash(); + test_MsiGetFileHash(); test_MsiQueryProductState(); test_MsiQueryFeatureState(); test_MsiQueryComponentState(); diff --git a/dlls/msi/where.c b/dlls/msi/where.c index ecca17aa732..26e4c8f2b7f 100644 --- a/dlls/msi/where.c +++ b/dlls/msi/where.c @@ -505,7 +505,7 @@ static UINT WHERE_VerifyCondition( MSIDATABASE *db, MSIVIEW *table, struct expr else { *valid = 0; - ERR("Couldn't find column %s\n", debugstr_w( cond->u.column ) ); + WARN("Couldn't find column %s\n", debugstr_w( cond->u.column ) ); } break; case EXPR_COMPLEX: diff --git a/dlls/msvcrt/heap.c b/dlls/msvcrt/heap.c index 78739d5bcb1..06c9d56205b 100644 --- a/dlls/msvcrt/heap.c +++ b/dlls/msvcrt/heap.c @@ -396,7 +396,7 @@ void * CDECL _aligned_offset_realloc(void *memblock, MSVCRT_size_t size, MSVCRT_size_t alignment, MSVCRT_size_t offset) { void * temp, **saved; - MSVCRT_size_t old_padding, new_padding; + MSVCRT_size_t old_padding, new_padding, old_size; TRACE("(%p, %u, %u, %u)\n", memblock, size, alignment, offset); if (!memblock) @@ -434,7 +434,22 @@ void * CDECL _aligned_offset_realloc(void *memblock, MSVCRT_size_t size, return NULL; } - old_padding = (char *)*saved - (char *)memblock; + old_padding = (char *)memblock - (char *)*saved; + + /* Get previous size of block */ + old_size = _msize(*saved); + if (old_size == -1) + { + /* It seems this function was called with an invalid pointer. Bail out. */ + return NULL; + } + /* Adjust old_size to get amount of actual data in old block. */ + old_size -= old_padding; + if (old_size < 0) + { + /* Shouldn't happen. Something's weird, so bail out. */ + return NULL; + } temp = MSVCRT_realloc(*saved, size + alignment + sizeof(void *)); @@ -448,11 +463,40 @@ void * CDECL _aligned_offset_realloc(void *memblock, MSVCRT_size_t size, /* so it can be found later to free. */ saved = SAVED_PTR(memblock); - /* a new start address may require different padding to get the */ - /* proper alignment */ - new_padding = (char *)temp - (char *)memblock; + new_padding = (char *)memblock - (char *)temp; + +/* + Memory layout of old block is as follows: + +-------+---------------------+-+--------------------------+-----------+ + | ... | "old_padding" bytes | | ... "old_size" bytes ... | ... | + +-------+---------------------+-+--------------------------+-----------+ + ^ ^ ^ + | | | + *saved saved memblock + + Memory layout of new block is as follows: + +-------+-----------------------------+-+----------------------+-------+ + | ... | "new_padding" bytes | | ... "size" bytes ... | ... | + +-------+-----------------------------+-+----------------------+-------+ + ^ ^ ^ + | | | + temp saved memblock + + However, in the new block, actual data is still written as follows + (because it was copied by MSVCRT_realloc): + +-------+---------------------+--------------------------------+-------+ + | ... | "old_padding" bytes | ... "old_size" bytes ... | ... | + +-------+---------------------+--------------------------------+-------+ + ^ ^ ^ + | | | + temp saved memblock + + Therefore, min(old_size,size) bytes of actual data have to be moved + from the offset they were at in the old block (temp + old_padding), + to the offset they have to be in the new block (temp + new_padding == memblock). +*/ if (new_padding != old_padding) - memmove((char *)memblock + old_padding, (char *)memblock + new_padding, size); + memmove((char *)memblock, (char *)temp + old_padding, (old_size < size) ? old_size : size); *saved = temp; diff --git a/dlls/msvcrt/tests/heap.c b/dlls/msvcrt/tests/heap.c index afea53fc23f..ae98e3b8975 100644 --- a/dlls/msvcrt/tests/heap.c +++ b/dlls/msvcrt/tests/heap.c @@ -334,6 +334,84 @@ static void test_aligned(void) test_aligned_offset_realloc(256, 128, 32, 4); test_aligned_offset_realloc(256, 512, 64, 4); test_aligned_offset_realloc(256, 128, 64, 4); + + test_aligned_offset_realloc(256, 512, 0, 8); + test_aligned_offset_realloc(256, 128, 0, 8); + test_aligned_offset_realloc(256, 512, 4, 8); + test_aligned_offset_realloc(256, 128, 4, 8); + test_aligned_offset_realloc(256, 512, 8, 8); + test_aligned_offset_realloc(256, 128, 8, 8); + test_aligned_offset_realloc(256, 512, 16, 8); + test_aligned_offset_realloc(256, 128, 16, 8); + test_aligned_offset_realloc(256, 512, 32, 8); + test_aligned_offset_realloc(256, 128, 32, 8); + test_aligned_offset_realloc(256, 512, 64, 8); + test_aligned_offset_realloc(256, 128, 64, 8); + + test_aligned_offset_realloc(256, 512, 0, 16); + test_aligned_offset_realloc(256, 128, 0, 16); + test_aligned_offset_realloc(256, 512, 4, 16); + test_aligned_offset_realloc(256, 128, 4, 16); + test_aligned_offset_realloc(256, 512, 8, 16); + test_aligned_offset_realloc(256, 128, 8, 16); + test_aligned_offset_realloc(256, 512, 16, 16); + test_aligned_offset_realloc(256, 128, 16, 16); + test_aligned_offset_realloc(256, 512, 32, 16); + test_aligned_offset_realloc(256, 128, 32, 16); + test_aligned_offset_realloc(256, 512, 64, 16); + test_aligned_offset_realloc(256, 128, 64, 16); + + test_aligned_offset_realloc(256, 512, 0, 32); + test_aligned_offset_realloc(256, 128, 0, 32); + test_aligned_offset_realloc(256, 512, 4, 32); + test_aligned_offset_realloc(256, 128, 4, 32); + test_aligned_offset_realloc(256, 512, 8, 32); + test_aligned_offset_realloc(256, 128, 8, 32); + test_aligned_offset_realloc(256, 512, 16, 32); + test_aligned_offset_realloc(256, 128, 16, 32); + test_aligned_offset_realloc(256, 512, 32, 32); + test_aligned_offset_realloc(256, 128, 32, 32); + test_aligned_offset_realloc(256, 512, 64, 32); + test_aligned_offset_realloc(256, 128, 64, 32); + + test_aligned_offset_realloc(256, 512, 0, 64); + test_aligned_offset_realloc(256, 128, 0, 64); + test_aligned_offset_realloc(256, 512, 4, 64); + test_aligned_offset_realloc(256, 128, 4, 64); + test_aligned_offset_realloc(256, 512, 8, 64); + test_aligned_offset_realloc(256, 128, 8, 64); + test_aligned_offset_realloc(256, 512, 16, 64); + test_aligned_offset_realloc(256, 128, 16, 64); + test_aligned_offset_realloc(256, 512, 32, 64); + test_aligned_offset_realloc(256, 128, 32, 64); + test_aligned_offset_realloc(256, 512, 64, 64); + test_aligned_offset_realloc(256, 128, 64, 64); + + test_aligned_offset_realloc(256, 512, 0, 96); + test_aligned_offset_realloc(256, 128, 0, 96); + test_aligned_offset_realloc(256, 512, 4, 96); + test_aligned_offset_realloc(256, 128, 4, 96); + test_aligned_offset_realloc(256, 512, 8, 96); + test_aligned_offset_realloc(256, 128, 8, 96); + test_aligned_offset_realloc(256, 512, 16, 96); + test_aligned_offset_realloc(256, 128, 16, 96); + test_aligned_offset_realloc(256, 512, 32, 96); + test_aligned_offset_realloc(256, 128, 32, 96); + test_aligned_offset_realloc(256, 512, 64, 96); + test_aligned_offset_realloc(256, 128, 64, 96); + + test_aligned_offset_realloc(256, 512, 0, 112); + test_aligned_offset_realloc(256, 128, 0, 112); + test_aligned_offset_realloc(256, 512, 4, 112); + test_aligned_offset_realloc(256, 128, 4, 112); + test_aligned_offset_realloc(256, 512, 8, 112); + test_aligned_offset_realloc(256, 128, 8, 112); + test_aligned_offset_realloc(256, 512, 16, 112); + test_aligned_offset_realloc(256, 128, 16, 112); + test_aligned_offset_realloc(256, 512, 32, 112); + test_aligned_offset_realloc(256, 128, 32, 112); + test_aligned_offset_realloc(256, 512, 64, 112); + test_aligned_offset_realloc(256, 128, 64, 112); } START_TEST(heap) @@ -342,6 +420,7 @@ START_TEST(heap) mem = malloc(0); ok(mem != NULL, "memory not allocated for size 0\n"); + free(mem); mem = realloc(NULL, 10); ok(mem != NULL, "memory not allocated\n"); diff --git a/dlls/netapi32/tests/apibuf.c b/dlls/netapi32/tests/apibuf.c index 751081e9b52..920be6ae05e 100644 --- a/dlls/netapi32/tests/apibuf.c +++ b/dlls/netapi32/tests/apibuf.c @@ -58,7 +58,6 @@ static void run_apibuf_tests(void) ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n"); ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); - ok(dwSize >= 0, "The size\n"); ok(pNetApiBufferSize(NULL, &dwSize) == ERROR_INVALID_PARAMETER, "Error for NULL pointer\n"); /* border reallocate cases */ @@ -72,7 +71,7 @@ static void run_apibuf_tests(void) ok(pNetApiBufferAllocate(0, (LPVOID *)&p) == NERR_Success, "Reserved memory\n"); ok(pNetApiBufferSize(p, &dwSize) == NERR_Success, "Got size\n"); - ok((dwSize >= 0) && (dwSize < 0xFFFFFFFF),"The size of the 0-length buffer\n"); + ok(dwSize < 0xFFFFFFFF, "The size of the 0-length buffer\n"); ok(pNetApiBufferFree(p) == NERR_Success, "Freed\n"); /* NULL-Pointer */ diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index fe83be63b82..60128bcc1e1 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -144,7 +144,8 @@ struct dll_redirect enum assembly_type { APPLICATION_MANIFEST, - ASSEMBLY_MANIFEST + ASSEMBLY_MANIFEST, + ASSEMBLY_SHARED_MANIFEST, }; struct assembly @@ -1379,7 +1380,8 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, if (!parse_noinheritable_elem(xmlbuf) || !next_xml_elem(xmlbuf, &elem)) return FALSE; } - else if (assembly->type == ASSEMBLY_MANIFEST && assembly->no_inherit) + else if ((assembly->type == ASSEMBLY_MANIFEST || assembly->type == ASSEMBLY_SHARED_MANIFEST) && + assembly->no_inherit) return FALSE; if (xmlstr_cmp(&elem, assemblyIdentityW)) @@ -1393,7 +1395,17 @@ static BOOL parse_assembly_elem(xmlbuf_t* xmlbuf, struct actctx_loader* acl, if (assembly->type == ASSEMBLY_MANIFEST && memcmp(&assembly->id.version, &expected_ai->version, sizeof(assembly->id.version))) { - FIXME("wrong version\n"); + FIXME("wrong version for assembly manifest\n"); + return FALSE; + } + else if (assembly->type == ASSEMBLY_SHARED_MANIFEST && + (assembly->id.version.major != expected_ai->version.major || + assembly->id.version.minor != expected_ai->version.minor || + assembly->id.version.build < expected_ai->version.build || + (assembly->id.version.build == expected_ai->version.build && + assembly->id.version.revision < expected_ai->version.revision))) + { + FIXME("wrong version for shared assembly manifest\n"); return FALSE; } } @@ -1479,7 +1491,8 @@ static NTSTATUS parse_manifest_buffer( struct actctx_loader* acl, struct assembl } static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_identity* ai, - LPCWSTR filename, LPCWSTR directory, const void *buffer, SIZE_T size ) + LPCWSTR filename, LPCWSTR directory, BOOL shared, + const void *buffer, SIZE_T size ) { xmlbuf_t xmlbuf; NTSTATUS status; @@ -1488,7 +1501,7 @@ static NTSTATUS parse_manifest( struct actctx_loader* acl, struct assembly_ident TRACE( "parsing manifest loaded from %s base dir %s\n", debugstr_w(filename), debugstr_w(directory) ); - if (!(assembly = add_assembly(acl->actctx, ASSEMBLY_MANIFEST))) + if (!(assembly = add_assembly(acl->actctx, shared ? ASSEMBLY_SHARED_MANIFEST : ASSEMBLY_MANIFEST))) return STATUS_SXS_CANT_GEN_ACTCTX; if (directory && !(assembly->directory = strdupW(directory))) @@ -1580,8 +1593,8 @@ static NTSTATUS get_module_filename( HMODULE module, UNICODE_STRING *str, unsign } static NTSTATUS get_manifest_in_module( struct actctx_loader* acl, struct assembly_identity* ai, - LPCWSTR filename, LPCWSTR directory, HANDLE hModule, - LPCWSTR resname, ULONG lang ) + LPCWSTR filename, LPCWSTR directory, BOOL shared, + HANDLE hModule, LPCWSTR resname, ULONG lang ) { NTSTATUS status; UNICODE_STRING nameW; @@ -1630,14 +1643,14 @@ static NTSTATUS get_manifest_in_module( struct actctx_loader* acl, struct assemb if (status == STATUS_SUCCESS) status = LdrAccessResource(hModule, entry, &ptr, NULL); if (status == STATUS_SUCCESS) - status = parse_manifest(acl, ai, filename, directory, ptr, entry->Size); + status = parse_manifest(acl, ai, filename, directory, shared, ptr, entry->Size); return status; } static NTSTATUS get_manifest_in_pe_file( struct actctx_loader* acl, struct assembly_identity* ai, - LPCWSTR filename, LPCWSTR directory, HANDLE file, - LPCWSTR resname, ULONG lang ) + LPCWSTR filename, LPCWSTR directory, BOOL shared, + HANDLE file, LPCWSTR resname, ULONG lang ) { HANDLE mapping; OBJECT_ATTRIBUTES attr; @@ -1672,7 +1685,7 @@ static NTSTATUS get_manifest_in_pe_file( struct actctx_loader* acl, struct assem if (RtlImageNtHeader(base)) /* we got a PE file */ { HANDLE module = (HMODULE)((ULONG_PTR)base | 1); /* make it a LOAD_LIBRARY_AS_DATAFILE handle */ - status = get_manifest_in_module( acl, ai, filename, directory, module, resname, lang ); + status = get_manifest_in_module( acl, ai, filename, directory, shared, module, resname, lang ); } else status = STATUS_INVALID_IMAGE_FORMAT; @@ -1681,7 +1694,7 @@ static NTSTATUS get_manifest_in_pe_file( struct actctx_loader* acl, struct assem } static NTSTATUS get_manifest_in_manifest_file( struct actctx_loader* acl, struct assembly_identity* ai, - LPCWSTR filename, LPCWSTR directory, HANDLE file ) + LPCWSTR filename, LPCWSTR directory, BOOL shared, HANDLE file ) { FILE_END_OF_FILE_INFORMATION info; IO_STATUS_BLOCK io; @@ -1717,7 +1730,7 @@ static NTSTATUS get_manifest_in_manifest_file( struct actctx_loader* acl, struct status = NtQueryInformationFile( file, &io, &info, sizeof(info), FileEndOfFileInformation ); if (status == STATUS_SUCCESS) - status = parse_manifest(acl, ai, filename, directory, base, info.EndOfFile.QuadPart); + status = parse_manifest(acl, ai, filename, directory, shared, base, info.EndOfFile.QuadPart); NtUnmapViewOfSection( GetCurrentProcess(), base ); return status; @@ -1765,7 +1778,7 @@ static NTSTATUS get_manifest_in_associated_manifest( struct actctx_loader* acl, if (!open_nt_file( &file, &nameW )) { - status = get_manifest_in_manifest_file( acl, ai, nameW.Buffer, directory, file ); + status = get_manifest_in_manifest_file( acl, ai, nameW.Buffer, directory, FALSE, file ); NtClose( file ); } else status = STATUS_RESOURCE_DATA_NOT_FOUND; @@ -1905,7 +1918,7 @@ static NTSTATUS lookup_winsxs(struct actctx_loader* acl, struct assembly_identit if (!open_nt_file( &handle, &path_us )) { - io.u.Status = get_manifest_in_manifest_file(acl, &sxs_ai, path_us.Buffer, file, handle); + io.u.Status = get_manifest_in_manifest_file(acl, &sxs_ai, path_us.Buffer, file, TRUE, handle); NtClose( handle ); } else io.u.Status = STATUS_NO_SUCH_FILE; @@ -1962,7 +1975,7 @@ static NTSTATUS lookup_assembly(struct actctx_loader* acl, status = open_nt_file( &file, &nameW ); if (!status) { - status = get_manifest_in_pe_file( acl, ai, nameW.Buffer, directory, file, + status = get_manifest_in_pe_file( acl, ai, nameW.Buffer, directory, FALSE, file, (LPCWSTR)CREATEPROCESS_MANIFEST_RESOURCE_ID, 0 ); NtClose( file ); break; @@ -1976,7 +1989,7 @@ static NTSTATUS lookup_assembly(struct actctx_loader* acl, status = open_nt_file( &file, &nameW ); if (!status) { - status = get_manifest_in_manifest_file( acl, ai, nameW.Buffer, directory, file ); + status = get_manifest_in_manifest_file( acl, ai, nameW.Buffer, directory, FALSE, file ); NtClose( file ); break; } @@ -2230,7 +2243,7 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, const void *ptr ) /* if we have a resource it's a PE file */ if (pActCtx->dwFlags & ACTCTX_FLAG_HMODULE_VALID) { - status = get_manifest_in_module( &acl, NULL, NULL, directory, pActCtx->hModule, + status = get_manifest_in_module( &acl, NULL, NULL, directory, FALSE, pActCtx->hModule, pActCtx->lpResourceName, lang ); if (status && status != STATUS_SXS_CANT_GEN_ACTCTX) /* FIXME: what to do if pActCtx->lpSource is set */ @@ -2239,7 +2252,7 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, const void *ptr ) } else if (pActCtx->lpSource) { - status = get_manifest_in_pe_file( &acl, NULL, nameW.Buffer, directory, + status = get_manifest_in_pe_file( &acl, NULL, nameW.Buffer, directory, FALSE, file, pActCtx->lpResourceName, lang ); if (status && status != STATUS_SXS_CANT_GEN_ACTCTX) status = get_manifest_in_associated_manifest( &acl, NULL, nameW.Buffer, directory, @@ -2249,7 +2262,7 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, const void *ptr ) } else { - status = get_manifest_in_manifest_file( &acl, NULL, nameW.Buffer, directory, file ); + status = get_manifest_in_manifest_file( &acl, NULL, nameW.Buffer, directory, FALSE, file ); } if (file) NtClose( file ); @@ -2502,7 +2515,8 @@ NTSTATUS WINAPI RtlQueryInformationActivationContext( ULONG flags, HANDLE handle id_len = strlenW(assembly_id) + 1; if (assembly->directory) ad_len = strlenW(assembly->directory) + 1; - if (assembly->manifest.info && assembly->type == ASSEMBLY_MANIFEST) + if (assembly->manifest.info && + (assembly->type == ASSEMBLY_MANIFEST || assembly->type == ASSEMBLY_SHARED_MANIFEST)) path_len = strlenW(assembly->manifest.info) + 1; len = sizeof(*afdi) + (id_len + ad_len + path_len) * sizeof(WCHAR); diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index a68acf3105e..2ba2bf0f930 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -244,15 +244,16 @@ static void HEAP_Dump( HEAP *heap ) DPRINTF( "\n\nSub-heap %p: base=%p size=%08lx committed=%08lx\n", subheap, subheap->base, subheap->size, subheap->commitSize ); - DPRINTF( "\n Block Stat Size Id\n" ); + DPRINTF( "\n Block Arena Stat Size Id\n" ); ptr = (char *)subheap->base + subheap->headerSize; while (ptr < (char *)subheap->base + subheap->size) { if (*(DWORD *)ptr & ARENA_FLAG_FREE) { ARENA_FREE *pArena = (ARENA_FREE *)ptr; - DPRINTF( "%p free %08x prev=%p next=%p\n", - pArena, pArena->size & ARENA_SIZE_MASK, + DPRINTF( "%p %08x free %08x prev=%p next=%p\n", + pArena, pArena->magic, + pArena->size & ARENA_SIZE_MASK, LIST_ENTRY( pArena->entry.prev, ARENA_FREE, entry ), LIST_ENTRY( pArena->entry.next, ARENA_FREE, entry ) ); ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK); @@ -262,8 +263,8 @@ static void HEAP_Dump( HEAP *heap ) else if (*(DWORD *)ptr & ARENA_FLAG_PREV_FREE) { ARENA_INUSE *pArena = (ARENA_INUSE *)ptr; - DPRINTF( "%p Used %08x back=%p\n", - pArena, pArena->size & ARENA_SIZE_MASK, *((ARENA_FREE **)pArena - 1) ); + DPRINTF( "%p %08x Used %08x back=%p\n", + pArena, pArena->magic, pArena->size & ARENA_SIZE_MASK, *((ARENA_FREE **)pArena - 1) ); ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK); arenaSize += sizeof(ARENA_INUSE); usedSize += pArena->size & ARENA_SIZE_MASK; @@ -271,7 +272,7 @@ static void HEAP_Dump( HEAP *heap ) else { ARENA_INUSE *pArena = (ARENA_INUSE *)ptr; - DPRINTF( "%p used %08x\n", pArena, pArena->size & ARENA_SIZE_MASK ); + DPRINTF( "%p %08x used %08x\n", pArena, pArena->magic, pArena->size & ARENA_SIZE_MASK ); ptr += sizeof(*pArena) + (pArena->size & ARENA_SIZE_MASK); arenaSize += sizeof(ARENA_INUSE); usedSize += pArena->size & ARENA_SIZE_MASK; @@ -816,7 +817,7 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) /* Check magic number */ if (pArena->magic != ARENA_FREE_MAGIC) { - ERR("Heap %p: invalid free arena magic for %p\n", subheap->heap, pArena ); + ERR("Heap %p: invalid free arena magic %08x for %p\n", subheap->heap, pArena->magic, pArena ); return FALSE; } /* Check size flags */ @@ -919,11 +920,11 @@ static BOOL HEAP_ValidateInUseArena( const SUBHEAP *subheap, const ARENA_INUSE * if (pArena->magic != ARENA_INUSE_MAGIC) { if (quiet == NOISY) { - ERR("Heap %p: invalid in-use arena magic for %p\n", subheap->heap, pArena ); + ERR("Heap %p: invalid in-use arena magic %08x for %p\n", subheap->heap, pArena->magic, pArena ); if (TRACE_ON(heap)) HEAP_Dump( subheap->heap ); } else if (WARN_ON(heap)) { - WARN("Heap %p: invalid in-use arena magic for %p\n", subheap->heap, pArena ); + WARN("Heap %p: invalid in-use arena magic %08x for %p\n", subheap->heap, pArena->magic, pArena ); if (TRACE_ON(heap)) HEAP_Dump( subheap->heap ); } diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index 85297e3a376..8b724ec4b48 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -271,8 +271,16 @@ static NTSTATUS enumerate_key( HANDLE handle, int index, KEY_INFORMATION_CLASS i fixed_size = (char *)keyinfo.Name - (char *)&keyinfo; keyinfo.LastWriteTime = modif; keyinfo.TitleIndex = 0; - keyinfo.ClassLength = max( 0, wine_server_reply_size(reply) - reply->namelen ); - keyinfo.ClassOffset = keyinfo.ClassLength ? fixed_size + reply->namelen : -1; + if (reply->namelen < wine_server_reply_size(reply)) + { + keyinfo.ClassLength = wine_server_reply_size(reply) - reply->namelen; + keyinfo.ClassOffset = fixed_size + reply->namelen; + } + else + { + keyinfo.ClassLength = 0; + keyinfo.ClassOffset = -1; + } keyinfo.NameLength = reply->namelen; memcpy( info, &keyinfo, min( length, fixed_size ) ); } diff --git a/dlls/ntdll/sec.c b/dlls/ntdll/sec.c index 28158388836..fd5ed7a7601 100644 --- a/dlls/ntdll/sec.c +++ b/dlls/ntdll/sec.c @@ -1341,7 +1341,7 @@ NTSTATUS WINAPI RtlGetAce(PACL pAcl,DWORD dwAceIndex,LPVOID *pAce ) TRACE("(%p,%d,%p)\n",pAcl,dwAceIndex,pAce); - if ((dwAceIndex < 0) || (dwAceIndex > pAcl->AceCount)) + if (dwAceIndex > pAcl->AceCount) return STATUS_INVALID_PARAMETER; ace = (PACE_HEADER)(pAcl + 1); diff --git a/dlls/ole32/marshal.c b/dlls/ole32/marshal.c index fcfbd648a31..fde189a690f 100644 --- a/dlls/ole32/marshal.c +++ b/dlls/ole32/marshal.c @@ -1097,10 +1097,15 @@ static BOOL find_proxy_manager(APARTMENT * apt, OXID oxid, OID oid, struct proxy struct proxy_manager * proxy = LIST_ENTRY(cursor, struct proxy_manager, entry); if ((oxid == proxy->oxid) && (oid == proxy->oid)) { - *proxy_found = proxy; - ClientIdentity_AddRef((IMultiQI *)&proxy->lpVtbl); - found = TRUE; - break; + /* be careful of a race with ClientIdentity_Release, which would + * cause us to return a proxy which is in the process of being + * destroyed */ + if (ClientIdentity_AddRef((IMultiQI *)&proxy->lpVtbl) != 0) + { + *proxy_found = proxy; + found = TRUE; + break; + } } } LeaveCriticalSection(&apt->cs); diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index 1643484a227..25a195587bc 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -267,10 +267,10 @@ @ stub UtConvertDvtd32toDvtd16 @ stub UtGetDvtd16Info @ stub UtGetDvtd32Info -@ stub WdtpInterfacePointer_UserFree -@ stub WdtpInterfacePointer_UserMarshal -@ stub WdtpInterfacePointer_UserSize -@ stub WdtpInterfacePointer_UserUnmarshal +@ stdcall WdtpInterfacePointer_UserFree(ptr) +@ stdcall WdtpInterfacePointer_UserMarshal(ptr long ptr ptr ptr) +@ stdcall WdtpInterfacePointer_UserSize(ptr long ptr long ptr) +@ stdcall WdtpInterfacePointer_UserUnmarshal(ptr ptr ptr ptr) @ stdcall WriteClassStg(ptr ptr) @ stdcall WriteClassStm(ptr ptr) @ stdcall WriteFmtUserTypeStg(ptr long ptr) diff --git a/dlls/ole32/rpc.c b/dlls/ole32/rpc.c index 57570c1eb97..40330d4e255 100644 --- a/dlls/ole32/rpc.c +++ b/dlls/ole32/rpc.c @@ -127,6 +127,9 @@ struct message_state RPC_BINDING_HANDLE binding_handle; ULONG prefix_data_len; SChannelHookCallInfo channel_hook_info; + + /* client only */ + struct dispatch_params params; }; typedef struct @@ -600,6 +603,7 @@ static HRESULT WINAPI ClientRpcChannelBuffer_GetBuffer(LPRPCCHANNELBUFFER iface, message_state->channel_hook_info.dwServerPid = This->server_pid; message_state->channel_hook_info.iMethod = msg->ProcNum; message_state->channel_hook_info.pObject = NULL; /* only present on server-side */ + memset(&message_state->params, 0, sizeof(message_state->params)); extensions_size = ChannelHooks_ClientGetSize(&message_state->channel_hook_info, &channel_hook_data, &channel_hook_count, &extension_count); @@ -731,7 +735,6 @@ static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER ifac RPC_MESSAGE *msg = (RPC_MESSAGE *)olemsg; RPC_STATUS status; DWORD index; - struct dispatch_params *params; APARTMENT *apt = NULL; IPID ipid; struct message_state *message_state; @@ -762,18 +765,15 @@ static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER ifac return RPC_E_CANTCALLOUT_ININPUTSYNCCALL; } - params = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*params)); - if (!params) return E_OUTOFMEMORY; - message_state = (struct message_state *)msg->Handle; /* restore the binding handle and the real start of data */ msg->Handle = message_state->binding_handle; msg->Buffer = (char *)msg->Buffer - message_state->prefix_data_len; msg->BufferLength += message_state->prefix_data_len; - params->msg = olemsg; - params->status = RPC_S_OK; - params->hr = S_OK; + message_state->params.msg = olemsg; + message_state->params.status = RPC_S_OK; + message_state->params.hr = S_OK; /* Note: this is an optimization in the Microsoft OLE runtime that we need * to copy, as shown by the test_no_couninitialize_client test. without @@ -783,16 +783,27 @@ static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER ifac * from DllMain */ RpcBindingInqObject(message_state->binding_handle, &ipid); - hr = ipid_get_dispatch_params(&ipid, &apt, ¶ms->stub, ¶ms->chan, - ¶ms->iid, ¶ms->iface); - params->handle = ClientRpcChannelBuffer_GetEventHandle(This); + hr = ipid_get_dispatch_params(&ipid, &apt, &message_state->params.stub, + &message_state->params.chan, + &message_state->params.iid, + &message_state->params.iface); + message_state->params.handle = ClientRpcChannelBuffer_GetEventHandle(This); if ((hr == S_OK) && !apt->multi_threaded) { TRACE("Calling apartment thread 0x%08x...\n", apt->tid); - if (!PostMessageW(apartment_getwindow(apt), DM_EXECUTERPC, 0, (LPARAM)params)) + if (!PostMessageW(apartment_getwindow(apt), DM_EXECUTERPC, 0, + (LPARAM)&message_state->params)) { ERR("PostMessage failed with error %u\n", GetLastError()); + + IRpcStubBuffer_Release(message_state->params.stub); + message_state->params.stub = NULL; + IRpcChannelBuffer_Release(message_state->params.chan); + message_state->params.chan = NULL; + /* Note: message_state->params.iface doesn't have a reference and + * so doesn't need to be released */ + hr = HRESULT_FROM_WIN32(GetLastError()); } } @@ -802,10 +813,10 @@ static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER ifac { /* otherwise, we go via RPC runtime so the stub and channel aren't * needed here */ - IRpcStubBuffer_Release(params->stub); - params->stub = NULL; - IRpcChannelBuffer_Release(params->chan); - params->chan = NULL; + IRpcStubBuffer_Release(message_state->params.stub); + message_state->params.stub = NULL; + IRpcChannelBuffer_Release(message_state->params.chan); + message_state->params.chan = NULL; } /* we use a separate thread here because we need to be able to @@ -814,7 +825,7 @@ static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER ifac * and re-enter this STA from an incoming server thread will * deadlock. InstallShield is an example of that. */ - if (!QueueUserWorkItem(rpc_sendreceive_thread, params, WT_EXECUTEDEFAULT)) + if (!QueueUserWorkItem(rpc_sendreceive_thread, &message_state->params, WT_EXECUTEDEFAULT)) { ERR("QueueUserWorkItem failed with error %u\n", GetLastError()); hr = E_UNEXPECTED; @@ -826,22 +837,20 @@ static HRESULT WINAPI ClientRpcChannelBuffer_SendReceive(LPRPCCHANNELBUFFER ifac if (hr == S_OK) { - if (WaitForSingleObject(params->handle, 0)) + if (WaitForSingleObject(message_state->params.handle, 0)) { COM_CurrentInfo()->pending_call_count_client++; - hr = CoWaitForMultipleHandles(0, INFINITE, 1, ¶ms->handle, &index); + hr = CoWaitForMultipleHandles(0, INFINITE, 1, &message_state->params.handle, &index); COM_CurrentInfo()->pending_call_count_client--; } } - ClientRpcChannelBuffer_ReleaseEventHandle(This, params->handle); + ClientRpcChannelBuffer_ReleaseEventHandle(This, message_state->params.handle); /* for WM shortcut, faults are returned in params->hr */ if (hr == S_OK) - hrFault = params->hr; + hrFault = message_state->params.hr; - status = params->status; - HeapFree(GetProcessHeap(), 0, params); - params = NULL; + status = message_state->params.status; orpcthat.flags = ORPCF_NULL; orpcthat.extensions = NULL; diff --git a/dlls/ole32/tests/usrmarshal.c b/dlls/ole32/tests/usrmarshal.c index 28c66871085..d6fd7ee2f15 100644 --- a/dlls/ole32/tests/usrmarshal.c +++ b/dlls/ole32/tests/usrmarshal.c @@ -366,6 +366,117 @@ static void test_marshal_HMETAFILEPICT(void) HMETAFILEPICT_UserFree(&flags, &hmfp2); } +static HRESULT WINAPI Test_IUnknown_QueryInterface( + LPUNKNOWN iface, + REFIID riid, + LPVOID *ppvObj) +{ + if (ppvObj == NULL) return E_POINTER; + + if (IsEqualGUID(riid, &IID_IUnknown)) + { + *ppvObj = (LPVOID)iface; + IUnknown_AddRef(iface); + return S_OK; + } + + *ppvObj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI Test_IUnknown_AddRef(LPUNKNOWN iface) +{ + return 2; /* non-heap-based object */ +} + +static ULONG WINAPI Test_IUnknown_Release(LPUNKNOWN iface) +{ + return 1; /* non-heap-based object */ +} + +static const IUnknownVtbl TestUnknown_Vtbl = +{ + Test_IUnknown_QueryInterface, + Test_IUnknown_AddRef, + Test_IUnknown_Release, +}; + +static IUnknown Test_Unknown = { &TestUnknown_Vtbl }; + +ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *, ULONG, ULONG, IUnknown *, REFIID); +unsigned char * __RPC_USER WdtpInterfacePointer_UserMarshal(ULONG *, ULONG, unsigned char *, IUnknown *, REFIID); +unsigned char * __RPC_USER WdtpInterfacePointer_UserUnmarshal(ULONG *, unsigned char *, IUnknown **, REFIID); +void __RPC_USER WdtpInterfacePointer_UserFree(IUnknown *); + +static void test_marshal_WdtpInterfacePointer(void) +{ + unsigned char *buffer, *buffer_end; + ULONG size; + MIDL_STUB_MESSAGE stubmsg; + USER_MARSHAL_CB umcb; + IUnknown *unk; + IUnknown *unk2; + unsigned char *wireip; + const IID *iid; + + memset(&stubmsg, 0xcc, sizeof(stubmsg)); + stubmsg.dwDestContext = MSHCTX_INPROC; + stubmsg.pvDestContext = NULL; + + memset(&umcb, 0xcc, sizeof(umcb)); + umcb.Flags = MAKELONG(MSHCTX_INPROC, NDR_LOCAL_DATA_REPRESENTATION); + umcb.pStubMsg = &stubmsg; + + /* shows that the WdtpInterfacePointer functions don't marshal anything for + * NULL pointers, so code using these functions must handle that case + * itself */ + unk = NULL; + size = WdtpInterfacePointer_UserSize(&umcb.Flags, umcb.Flags, 0, unk, &IID_IUnknown); + ok(size == 0, "size should be 0 bytes, not %d\n", size); + buffer = HeapAlloc(GetProcessHeap(), 0, size); + buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, umcb.Flags, buffer, unk, &IID_IUnknown); + wireip = buffer; + HeapFree(GetProcessHeap(), 0, buffer); + + unk = &Test_Unknown; + size = WdtpInterfacePointer_UserSize(&umcb.Flags, umcb.Flags, 0, unk, &IID_IUnknown); + todo_wine + ok(size == 108, "size should be 108 bytes, not %d\n", size); + buffer = HeapAlloc(GetProcessHeap(), 0, size); + buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, umcb.Flags, buffer, unk, &IID_IUnknown); + wireip = buffer; + if (size >= 28) + { + ok(*(DWORD *)wireip == 0x44, "wireip + 0x0 should be 0x44 instead of 0x%08x\n", *(DWORD *)wireip); + wireip += sizeof(DWORD); + ok(*(DWORD *)wireip == 0x44, "wireip + 0x4 should be 0x44 instead of 0x%08x\n", *(DWORD *)wireip); + wireip += sizeof(DWORD); + ok(*(DWORD *)wireip == 0x574f454d /* 'MEOW' */, "wireip + 0x8 should be 0x574f454d instead of 0x%08x\n", *(DWORD *)wireip); + wireip += sizeof(DWORD); + ok(*(DWORD *)wireip == 0x1, "wireip + 0xc should be 0x1 instead of 0x%08x\n", *(DWORD *)wireip); + wireip += sizeof(DWORD); + iid = (const IID *)wireip; + ok(IsEqualIID(iid, &IID_IUnknown), + "wireip + 0x10 should be IID_IUnknown instead of {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", + iid->Data1, iid->Data2, iid->Data3, + iid->Data4[0], iid->Data4[1], iid->Data4[2], iid->Data4[3], + iid->Data4[4], iid->Data4[5], iid->Data4[6], iid->Data4[7]); + wireip += sizeof(IID); + ok(*(DWORD *)wireip == 0, "wireip + 0x1c should be 0 instead of 0x%08x\n", *(DWORD *)wireip); + wireip += sizeof(DWORD); + ok(*(DWORD *)wireip == 5, "wireip + 0x20 should be 5 instead of %d\n", *(DWORD *)wireip); + wireip += sizeof(DWORD); + /* the rest is dynamic so can't really be tested */ + } + + unk2 = NULL; + WdtpInterfacePointer_UserUnmarshal(&umcb.Flags, buffer, &unk2, &IID_IUnknown); + todo_wine + ok(unk2 != NULL, "IUnknown object didn't unmarshal properly\n"); + HeapFree(GetProcessHeap(), 0, buffer); + WdtpInterfacePointer_UserFree(unk2); +} + START_TEST(usrmarshal) { CoInitialize(NULL); @@ -376,6 +487,7 @@ START_TEST(usrmarshal) test_marshal_HENHMETAFILE(); test_marshal_HMETAFILE(); test_marshal_HMETAFILEPICT(); + test_marshal_WdtpInterfacePointer(); CoUninitialize(); } diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c index a1e1d890ace..c25b86a4d91 100644 --- a/dlls/ole32/usrmarshal.c +++ b/dlls/ole32/usrmarshal.c @@ -1434,6 +1434,100 @@ void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp) } /****************************************************************************** + * WdtpInterfacePointer_UserSize [OLE32.@] + * + * Calculates the buffer size required to marshal an interface pointer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * RealFlags [I] The MSHCTX to use when marshaling the interface. + * punk [I] Interface pointer to size. + * StartingSize [I] Starting size of the buffer. This value is added on to + * the buffer size required for the clip format. + * riid [I] ID of interface to size. + * + * RETURNS + * The buffer size required to marshal an interface pointer plus the starting size. + * + * NOTES + * Even though the function is documented to take a pointer to a ULONG in + * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which + * the first parameter is a ULONG. + */ +ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, IUnknown *punk, ULONG StartingSize, REFIID riid) +{ + FIXME("(%s, 0%x, %p, %d, %s): stub\n", debugstr_user_flags(pFlags), RealFlags, punk, StartingSize, debugstr_guid(riid)); + return 0; +} + +/****************************************************************************** + * WdtpInterfacePointer_UserMarshal [OLE32.@] + * + * Marshals an interface pointer into a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * RealFlags [I] The MSHCTX to use when marshaling the interface. + * pBuffer [I] Buffer to marshal the clip format into. + * punk [I] Interface pointer to marshal. + * riid [I] ID of interface to marshal. + * + * RETURNS + * The end of the marshaled data in the buffer. + * + * NOTES + * Even though the function is documented to take a pointer to a ULONG in + * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which + * the first parameter is a ULONG. + */ +unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid) +{ + FIXME("(%s, 0x%x, %p, &%p, %s): stub\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid)); + return NULL; +} + +/****************************************************************************** + * WdtpInterfacePointer_UserUnmarshal [OLE32.@] + * + * Unmarshals an interface pointer from a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * pBuffer [I] Buffer to marshal the clip format from. + * ppunk [I/O] Address that receives the unmarshaled interface pointer. + * riid [I] ID of interface to unmarshal. + * + * RETURNS + * The end of the marshaled data in the buffer. + * + * NOTES + * Even though the function is documented to take a pointer to an ULONG in + * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which + * the first parameter is an ULONG. + */ +unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid) +{ + FIXME("(%s, %p, %p, %s): stub\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid)); + return NULL; +} + +/****************************************************************************** + * WdtpInterfacePointer_UserFree [OLE32.@] + * + * Frees an unmarshaled interface pointer. + * + * PARAMS + * punk [I] Interface pointer to free. + * + * RETURNS + * Nothing. + */ +void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk) +{ + FIXME("(%p): stub\n", punk); +} + +/****************************************************************************** * STGMEDIUM_UserSize [OLE32.@] * * Calculates the buffer size required to marshal an STGMEDIUM. diff --git a/dlls/oleaut32/oleaut.c b/dlls/oleaut32/oleaut.c index f756d83a4ed..a6774080b1b 100644 --- a/dlls/oleaut32/oleaut.c +++ b/dlls/oleaut32/oleaut.c @@ -291,6 +291,10 @@ BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len) */ int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len) { + /* Detect integer overflow. */ + if (len >= ((UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))/sizeof(WCHAR))) + return 0; + if (*old!=NULL) { DWORD newbytelen = len*sizeof(WCHAR); DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD)); @@ -340,6 +344,10 @@ BSTR WINAPI SysAllocStringByteLen(LPCSTR str, UINT len) DWORD* newBuffer; char* stringBuffer; + /* Detect integer overflow. */ + if (len >= (UINT_MAX-sizeof(WCHAR)-sizeof(DWORD))) + return NULL; + /* * Allocate a new buffer to hold the string. * don't forget to keep an empty spot at the beginning of the diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c index b0335aacbed..2292036027f 100644 --- a/dlls/oleaut32/tests/vartype.c +++ b/dlls/oleaut32/tests/vartype.c @@ -5068,6 +5068,9 @@ static void test_SysAllocStringByteLen(void) str = SysAllocStringByteLen(szTestA, 0x80000000); ok (str == NULL, "Expected NULL, got %p\n", str); + str = SysAllocStringByteLen(szTestA, 0xffffffff); + ok (str == NULL, "Expected NULL, got %p\n", str); + str = SysAllocStringByteLen(NULL, 0); ok (str != NULL, "Expected non-NULL\n"); if (str) diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 62fe5575ff0..ae4df69bab2 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -1421,6 +1421,19 @@ static void *TLB_CopyTypeDesc( TYPEDESC *dest, const TYPEDESC *src, void *buffer return buffer; } +/* free custom data allocated by MSFT_CustData */ +static inline void TLB_FreeCustData(TLBCustData *pCustData) +{ + TLBCustData *pCustDataNext; + for (; pCustData; pCustData = pCustDataNext) + { + VariantClear(&pCustData->data); + + pCustDataNext = pCustData->next; + TLB_Free(pCustData); + } +} + /********************************************************************** * * Functions for reading MSFT typelibs (those created by CreateTypeLib2) @@ -3758,7 +3771,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoType( int i; ITypeInfoImpl *pTInfo = This->pTypeInfo; - if ((ITypeLib2_fnGetTypeInfoCount(iface) < index + 1) || (index < 0)) + if (ITypeLib2_fnGetTypeInfoCount(iface) < index + 1) return TYPE_E_ELEMENTNOTFOUND; TRACE("(%p) index %d\n", This, index); @@ -4474,7 +4487,6 @@ static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface) TLBFuncDesc *pFInfo, *pFInfoNext; TLBVarDesc *pVInfo, *pVInfoNext; TLBImplType *pImpl, *pImplNext; - TLBCustData *pCustData, *pCustDataNext; TRACE("destroying ITypeInfo(%p)\n",This); @@ -4514,13 +4526,7 @@ static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface) } TLB_Free(pFInfo->funcdesc.lprgelemdescParam); TLB_Free(pFInfo->pParamDesc); - for (pCustData = This->pCustData; pCustData; pCustData = pCustDataNext) - { - VariantClear(&pCustData->data); - - pCustDataNext = pCustData->next; - TLB_Free(pCustData); - } + TLB_FreeCustData(pFInfo->pCustData); if (HIWORD(pFInfo->Entry) != 0 && pFInfo->Entry != (BSTR)-1) SysFreeString(pFInfo->Entry); SysFreeString(pFInfo->HelpString); @@ -4536,23 +4542,18 @@ static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface) VariantClear(pVInfo->vardesc.u.lpvarValue); TLB_Free(pVInfo->vardesc.u.lpvarValue); } + TLB_FreeCustData(pVInfo->pCustData); SysFreeString(pVInfo->Name); pVInfoNext = pVInfo->next; TLB_Free(pVInfo); } for(pImpl = This->impltypelist; pImpl; pImpl = pImplNext) { - for (pCustData = pImpl->pCustData; pCustData; pCustData = pCustDataNext) - { - VariantClear(&pCustData->data); - - pCustDataNext = pCustData->next; - TLB_Free(pCustData); - } + TLB_FreeCustData(pImpl->pCustData); pImplNext = pImpl->next; TLB_Free(pImpl); } - TLB_Free(This->pCustData); + TLB_FreeCustData(This->pCustData); finish_free: if (This->next) @@ -6647,7 +6648,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetParamCustData( for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++,pFDesc=pFDesc->next); - if(pFDesc && indexParam >=0 && indexParamfuncdesc.cParams) + if(pFDesc && indexParamfuncdesc.cParams) for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData; pCData = pCData->next) if( IsEqualIID(guid, &pCData->guid)) break; @@ -6880,7 +6881,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetAllParamCustData( ITypeInfo2 * iface, for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++, pFDesc=pFDesc->next) ; - if(pFDesc && indexParam >=0 && indexParamfuncdesc.cParams){ + if(pFDesc && indexParamfuncdesc.cParams){ pCustData->prgCustData = TLB_Alloc(pFDesc->pParamDesc[indexParam].ctCustData * sizeof(CUSTDATAITEM)); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 41ee8e69df4..7464b0c9eac 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -3493,7 +3493,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfo( TRACE("(%p,%d,%p)\n", iface, index, ppTInfo); - if ((index < 0) || (index >= This->typelib_header.nrtypeinfos)) { + if (index >= This->typelib_header.nrtypeinfos) { return TYPE_E_ELEMENTNOTFOUND; } @@ -3514,7 +3514,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoType( TRACE("(%p,%d,%p)\n", iface, index, pTKind); - if ((index < 0) || (index >= This->typelib_header.nrtypeinfos)) { + if (index >= This->typelib_header.nrtypeinfos) { return TYPE_E_ELEMENTNOTFOUND; } diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index 57a442c06c3..8300b640e11 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -400,6 +400,8 @@ done: static inline void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg) { ALIGN_POINTER(pStubMsg->Buffer, 4); + if (pStubMsg->Buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) + RpcRaiseException(RPC_X_BAD_STUB_DATA); NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->MaxCount); pStubMsg->Buffer += 4; } @@ -408,6 +410,8 @@ static inline void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg) static inline void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg) { ALIGN_POINTER(pStubMsg->Buffer, 4); + if (pStubMsg->Buffer + 8 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) + RpcRaiseException(RPC_X_BAD_STUB_DATA); NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->Offset); pStubMsg->Buffer += 4; NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->ActualCount); @@ -418,6 +422,8 @@ static inline void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg) static inline void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg) { ALIGN_LENGTH(pStubMsg->BufferLength, 4); + if (pStubMsg->BufferLength + 4 < pStubMsg->BufferLength) + RpcRaiseException(RPC_X_BAD_STUB_DATA); pStubMsg->BufferLength += 4; } @@ -425,6 +431,8 @@ static inline void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg) static inline void SizeVariance(MIDL_STUB_MESSAGE *pStubMsg) { ALIGN_LENGTH(pStubMsg->BufferLength, 4); + if (pStubMsg->BufferLength + 8 < pStubMsg->BufferLength) + RpcRaiseException(RPC_X_BAD_STUB_DATA); pStubMsg->BufferLength += 8; } @@ -577,14 +585,25 @@ static inline ULONG safe_multiply(ULONG a, ULONG b) static inline void safe_buffer_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size) { if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */ - (pStubMsg->Buffer + size > pStubMsg->BufferEnd)) + (pStubMsg->Buffer + size > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)) RpcRaiseException(RPC_X_BAD_STUB_DATA); pStubMsg->Buffer += size; } +static inline void safe_buffer_length_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size) +{ + if (pStubMsg->BufferLength + size < pStubMsg->BufferLength) /* integer overflow of pStubMsg->BufferSize */ + { + ERR("buffer length overflow - BufferLength = %u, size = %u\n", + pStubMsg->BufferLength, size); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + pStubMsg->BufferLength += size; +} + /* copies data from the buffer, checking that there is enough data in the buffer * to do so */ -static inline void safe_buffer_copy(MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG size) +static inline void safe_copy_from_buffer(MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG size) { if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */ (pStubMsg->Buffer + size > pStubMsg->BufferEnd)) @@ -593,6 +612,21 @@ static inline void safe_buffer_copy(MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG pStubMsg->Buffer += size; } +/* copies data to the buffer, checking that there is enough space to do so */ +static inline void safe_copy_to_buffer(MIDL_STUB_MESSAGE *pStubMsg, const void *p, ULONG size) +{ + if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */ + (pStubMsg->Buffer + size > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)) + { + ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %u\n", + pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength, + size); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + memcpy(pStubMsg->Buffer, p, size); + pStubMsg->Buffer += size; +} + /* * NdrConformantString: * @@ -645,10 +679,7 @@ unsigned char *WINAPI NdrConformantStringMarshall(MIDL_STUB_MESSAGE *pStubMsg, WriteVariance(pStubMsg); size = safe_multiply(esize, pStubMsg->ActualCount); - memcpy(pStubMsg->Buffer, pszMessage, size); /* the string itself */ - pStubMsg->Buffer += size; - - STD_OVERFLOW_CHECK(pStubMsg); + safe_copy_to_buffer(pStubMsg, pszMessage, size); /* the string itself */ /* success */ return NULL; /* is this always right? */ @@ -688,7 +719,7 @@ void WINAPI NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, else pStubMsg->MaxCount = pStubMsg->ActualCount; - pStubMsg->BufferLength += safe_multiply(esize, pStubMsg->ActualCount); + safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount)); } /************************************************************************ @@ -779,7 +810,7 @@ unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg if (fMustAlloc || !*ppMemory) *ppMemory = NdrAllocate(pStubMsg, memsize); - safe_buffer_copy(pStubMsg, *ppMemory, bufsize); + safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize); if (*pFormat == RPC_FC_C_CSTRING) { TRACE("string=%s\n", debugstr_a((char*)*ppMemory)); @@ -921,6 +952,7 @@ static void PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, unsigned char **pPointer, + unsigned char *pSrcPointer, PFORMAT_STRING pFormat, unsigned char fMustAlloc) { @@ -930,7 +962,7 @@ static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, DWORD pointer_id = 0; int pointer_needs_unmarshaling; - TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pFormat, fMustAlloc); + TRACE("(%p,%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pSrcPointer, pFormat, fMustAlloc); TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr); pFormat += 2; if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat; @@ -953,10 +985,10 @@ static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_OP: /* object pointer - we must free data before overwriting it */ pointer_id = NDR_LOCAL_UINT32_READ(Buffer); TRACE("pointer_id is 0x%08x\n", pointer_id); - if (!fMustAlloc && *pPointer) + if (!fMustAlloc && pSrcPointer) { - FIXME("free object pointer %p\n", *pPointer); - *pPointer = NULL; + FIXME("free object pointer %p\n", pSrcPointer); + pSrcPointer = NULL; } if (pointer_id) pointer_needs_unmarshaling = 1; @@ -976,21 +1008,61 @@ static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, } if (pointer_needs_unmarshaling) { - if (attr & RPC_FC_P_DEREF) { - if (!*pPointer || fMustAlloc) { - *pPointer = NdrAllocate(pStubMsg, sizeof(void *)); - *(unsigned char**) *pPointer = NULL; + unsigned char *base_ptr_val = *pPointer; + unsigned char **current_ptr = pPointer; + if (pStubMsg->IsClient) { + TRACE("client\n"); + /* if we aren't forcing allocation of memory then try to use the existing + * (source) pointer to unmarshall the data into so that [in,out] + * parameters behave correctly. it doesn't matter if the parameter is + * [out] only since in that case the pointer will be NULL. we force + * allocation when the source pointer is NULL here instead of in the type + * unmarshalling routine for the benefit of the deref code below */ + if (!fMustAlloc) { + if (pSrcPointer) { + TRACE("pSrcPointer = %p\n", pSrcPointer); + base_ptr_val = pSrcPointer; + } else + fMustAlloc = TRUE; + } + } else { + TRACE("server\n"); + /* the memory in a stub is never initialised, so we have to work out here + * whether we have to initialise it so we can use the optimisation of + * setting the pointer to the buffer, if possible, or set fMustAlloc to + * TRUE. As there is no space used in the buffer for pointers when using + * reference pointers we must allocate memory in this case */ + if (type == RPC_FC_RP || attr & RPC_FC_P_DEREF) { + fMustAlloc = TRUE; + base_ptr_val = NULL; + } else { + base_ptr_val = NULL; + *current_ptr = NULL; } - pPointer = *(unsigned char***)pPointer; - TRACE("deref => %p\n", pPointer); + } + + if (attr & RPC_FC_P_DEREF) { + if (fMustAlloc) { + base_ptr_val = NdrAllocate(pStubMsg, sizeof(void *)); + current_ptr = (unsigned char **)base_ptr_val; + } else + current_ptr = *(unsigned char***)current_ptr; + TRACE("deref => %p\n", current_ptr); + if (!fMustAlloc && !*current_ptr) fMustAlloc = TRUE; } m = NdrUnmarshaller[*desc & NDR_TABLE_MASK]; - if (m) m(pStubMsg, pPointer, desc, fMustAlloc); + if (m) m(pStubMsg, current_ptr, desc, fMustAlloc); else FIXME("no unmarshaller for data type=%02x\n", *desc); if (type == RPC_FC_FP) NdrFullPointerInsertRefId(pStubMsg->FullPtrXlatTables, pointer_id, - *pPointer); + base_ptr_val); + + /* this must be done after the call to the unmarshaller, since when we are + * unmarshalling reference pointers on the server side *pPointer will be + * pointing to valid data */ + if (base_ptr_val && (!fMustAlloc || attr & RPC_FC_P_DEREF)) + *pPointer = base_ptr_val; } TRACE("pointer=%p\n", *pPointer); @@ -1237,7 +1309,8 @@ static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, * EmbeddedPointerUnmarshall */ static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, - unsigned char **ppMemory, + unsigned char *pDstMemoryPtrs, + unsigned char *pSrcMemoryPtrs, PFORMAT_STRING pFormat, unsigned char fMustAlloc) { @@ -1246,7 +1319,7 @@ static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned i; unsigned char *saved_buffer = NULL; - TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); + TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, pDstMemoryPtrs, pSrcMemoryPtrs, pFormat, fMustAlloc); if (*pFormat != RPC_FC_PP) return NULL; pFormat += 2; @@ -1284,14 +1357,16 @@ static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, } for (i = 0; i < rep; i++) { PFORMAT_STRING info = pFormat; - unsigned char *membase = *ppMemory + (i * stride); + unsigned char *memdstbase = pDstMemoryPtrs + (i * stride); + unsigned char *memsrcbase = pSrcMemoryPtrs + (i * stride); unsigned char *bufbase = Mark + (i * stride); unsigned u; for (u=0; uBuffer, 4); Buffer = pStubMsg->Buffer; - pStubMsg->Buffer += 4; + safe_buffer_increment(pStubMsg, 4); } else Buffer = pStubMsg->Buffer; PointerMarshall(pStubMsg, Buffer, pMemory, pFormat); - STD_OVERFLOW_CHECK(pStubMsg); - return NULL; } @@ -1545,7 +1618,7 @@ unsigned char * WINAPI NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, else Buffer = pStubMsg->Buffer; - PointerUnmarshall(pStubMsg, Buffer, ppMemory, pFormat, fMustAlloc); + PointerUnmarshall(pStubMsg, Buffer, ppMemory, *ppMemory, pFormat, fMustAlloc); return NULL; } @@ -1565,7 +1638,7 @@ void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, if (*pFormat != RPC_FC_RP) { ALIGN_LENGTH(pStubMsg->BufferLength, 4); - pStubMsg->BufferLength += 4; + safe_buffer_length_increment(pStubMsg, 4); } PointerBufferSize(pStubMsg, pMemory, pFormat); @@ -1624,15 +1697,12 @@ unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1); - memcpy(pStubMsg->Buffer, pMemory, size); pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += size; + safe_copy_to_buffer(pStubMsg, pMemory, size); if (pFormat[0] != RPC_FC_STRUCT) EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4); - STD_OVERFLOW_CHECK(pStubMsg); - return NULL; } @@ -1645,27 +1715,28 @@ unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char fMustAlloc) { unsigned size = *(const WORD*)(pFormat+2); + unsigned char *saved_buffer; TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1); - if (fMustAlloc) { + if (fMustAlloc) *ppMemory = NdrAllocate(pStubMsg, size); - memcpy(*ppMemory, pStubMsg->Buffer, size); - } else { + else + { if (!pStubMsg->IsClient && !*ppMemory) /* for servers, we just point straight into the RPC buffer */ *ppMemory = pStubMsg->Buffer; - else - /* for clients, memory should be provided by caller */ - memcpy(*ppMemory, pStubMsg->Buffer, size); } - pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += size; + saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer; + safe_buffer_increment(pStubMsg, size); + if (pFormat[0] == RPC_FC_PSTRUCT) + EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat+4, fMustAlloc); - if (pFormat[0] != RPC_FC_STRUCT) - EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat+4, fMustAlloc); + TRACE("copying %p to %p\n", saved_buffer, *ppMemory); + if (*ppMemory != saved_buffer) + memcpy(*ppMemory, saved_buffer, size); return NULL; } @@ -1682,7 +1753,7 @@ void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1); - pStubMsg->BufferLength += size; + safe_buffer_length_increment(pStubMsg, size); if (pFormat[0] != RPC_FC_STRUCT) EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4); } @@ -1699,7 +1770,7 @@ ULONG WINAPI NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1); pStubMsg->MemorySize += size; - pStubMsg->Buffer += size; + safe_buffer_increment(pStubMsg, size); if (pFormat[0] != RPC_FC_STRUCT) EmbeddedPointerMemorySize(pStubMsg, pFormat+4); @@ -1781,30 +1852,26 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_SMALL: case RPC_FC_USMALL: TRACE("byte=%d <= %p\n", *(WORD*)pMemory, pMemory); - memcpy(pStubMsg->Buffer, pMemory, 1); - pStubMsg->Buffer += 1; + safe_copy_to_buffer(pStubMsg, pMemory, 1); pMemory += 1; break; case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory); - memcpy(pStubMsg->Buffer, pMemory, 2); - pStubMsg->Buffer += 2; + safe_copy_to_buffer(pStubMsg, pMemory, 2); pMemory += 2; break; case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: TRACE("long=%d <= %p\n", *(DWORD*)pMemory, pMemory); - memcpy(pStubMsg->Buffer, pMemory, 4); - pStubMsg->Buffer += 4; + safe_copy_to_buffer(pStubMsg, pMemory, 4); pMemory += 4; break; case RPC_FC_HYPER: TRACE("longlong=%s <= %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory); - memcpy(pStubMsg->Buffer, pMemory, 8); - pStubMsg->Buffer += 8; + safe_copy_to_buffer(pStubMsg, pMemory, 8); pMemory += 8; break; case RPC_FC_POINTER: @@ -1820,12 +1887,18 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, pointer_buffer_mark_set = 1; } else - pStubMsg->Buffer += 4; /* for pointer ID */ + safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ PointerMarshall(pStubMsg, saved_buffer, *(unsigned char**)pMemory, pPointer); if (pointer_buffer_mark_set) { STD_OVERFLOW_CHECK(pStubMsg); pStubMsg->PointerBufferMark = pStubMsg->Buffer; + if (saved_buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) + { + ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n", + saved_buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } pStubMsg->Buffer = saved_buffer + 4; } pPointer += 4; @@ -1895,26 +1968,26 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_CHAR: case RPC_FC_SMALL: case RPC_FC_USMALL: - safe_buffer_copy(pStubMsg, pMemory, 1); + safe_copy_from_buffer(pStubMsg, pMemory, 1); TRACE("byte=%d => %p\n", *(WORD*)pMemory, pMemory); pMemory += 1; break; case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: - safe_buffer_copy(pStubMsg, pMemory, 2); + safe_copy_from_buffer(pStubMsg, pMemory, 2); TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory); pMemory += 2; break; case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: - safe_buffer_copy(pStubMsg, pMemory, 4); + safe_copy_from_buffer(pStubMsg, pMemory, 4); TRACE("long=%d => %p\n", *(DWORD*)pMemory, pMemory); pMemory += 4; break; case RPC_FC_HYPER: - safe_buffer_copy(pStubMsg, pMemory, 8); + safe_copy_from_buffer(pStubMsg, pMemory, 8); TRACE("longlong=%s => %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory); pMemory += 8; break; @@ -1932,13 +2005,19 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, pointer_buffer_mark_set = 1; } else - pStubMsg->Buffer += 4; /* for pointer ID */ + safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ - PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, pPointer, TRUE); + PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, *(unsigned char**)pMemory, pPointer, TRUE); if (pointer_buffer_mark_set) { STD_OVERFLOW_CHECK(pStubMsg); pStubMsg->PointerBufferMark = pStubMsg->Buffer; + if (saved_buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) + { + ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n", + saved_buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } pStubMsg->Buffer = saved_buffer + 4; } pPointer += 4; @@ -2009,23 +2088,23 @@ static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_CHAR: case RPC_FC_SMALL: case RPC_FC_USMALL: - pStubMsg->BufferLength += 1; + safe_buffer_length_increment(pStubMsg, 1); pMemory += 1; break; case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: - pStubMsg->BufferLength += 2; + safe_buffer_length_increment(pStubMsg, 2); pMemory += 2; break; case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: - pStubMsg->BufferLength += 4; + safe_buffer_length_increment(pStubMsg, 4); pMemory += 4; break; case RPC_FC_HYPER: - pStubMsg->BufferLength += 8; + safe_buffer_length_increment(pStubMsg, 8); pMemory += 8; break; case RPC_FC_POINTER: @@ -2040,7 +2119,7 @@ static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg, pStubMsg->PointerLength = pStubMsg->BufferLength; pStubMsg->BufferLength = saved_buffer_length; } - pStubMsg->BufferLength += 4; + safe_buffer_length_increment(pStubMsg, 4); pPointer += 4; pMemory += 4; break; @@ -2186,27 +2265,27 @@ static unsigned long ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_SMALL: case RPC_FC_USMALL: size += 1; - pStubMsg->Buffer += 1; + safe_buffer_increment(pStubMsg, 1); break; case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: size += 2; - pStubMsg->Buffer += 2; + safe_buffer_increment(pStubMsg, 2); break; case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: size += 4; - pStubMsg->Buffer += 4; + safe_buffer_increment(pStubMsg, 4); break; case RPC_FC_HYPER: size += 8; - pStubMsg->Buffer += 8; + safe_buffer_increment(pStubMsg, 8); break; case RPC_FC_POINTER: size += 4; - pStubMsg->Buffer += 4; + safe_buffer_increment(pStubMsg, 4); if (!pStubMsg->IgnoreEmbeddedPointers) FIXME("embedded pointers\n"); break; @@ -2510,14 +2589,11 @@ unsigned char * WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, alignment); size = safe_multiply(esize, pStubMsg->MaxCount); - memcpy(pStubMsg->Buffer, pMemory, size); pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += size; + safe_copy_to_buffer(pStubMsg, pMemory, size); EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat); - STD_OVERFLOW_CHECK(pStubMsg); - return NULL; } @@ -2545,9 +2621,9 @@ unsigned char * WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, alignment); pStubMsg->BufferMark = pStubMsg->Buffer; - safe_buffer_copy(pStubMsg, *ppMemory, size); + safe_copy_from_buffer(pStubMsg, *ppMemory, size); - EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc); + EmbeddedPointerUnmarshall(pStubMsg, *ppMemory, *ppMemory, pFormat, TRUE /* FIXME */); return NULL; } @@ -2573,7 +2649,7 @@ void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, size = safe_multiply(esize, pStubMsg->MaxCount); /* conformance value plus array */ - pStubMsg->BufferLength += size; + safe_buffer_length_increment(pStubMsg, size); EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat); } @@ -2596,7 +2672,7 @@ ULONG WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, alignment); pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += size; + safe_buffer_increment(pStubMsg, size); EmbeddedPointerMemorySize(pStubMsg, pFormat); @@ -2649,14 +2725,11 @@ unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStu bufsize = safe_multiply(esize, pStubMsg->ActualCount); - memcpy(pStubMsg->Buffer, pMemory + pStubMsg->Offset, bufsize); pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += bufsize; + safe_copy_to_buffer(pStubMsg, pMemory + pStubMsg->Offset, bufsize); EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat); - STD_OVERFLOW_CHECK(pStubMsg); - return NULL; } @@ -2692,9 +2765,9 @@ unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pS if (!*ppMemory || fMustAlloc) *ppMemory = NdrAllocate(pStubMsg, memsize); - safe_buffer_copy(pStubMsg, *ppMemory + pStubMsg->Offset, bufsize); + safe_copy_from_buffer(pStubMsg, *ppMemory + pStubMsg->Offset, bufsize); - EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc); + EmbeddedPointerUnmarshall(pStubMsg, *ppMemory, *ppMemory, pFormat, TRUE /* FIXME */); return NULL; } @@ -2751,7 +2824,7 @@ void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg, ALIGN_LENGTH(pStubMsg->BufferLength, alignment); - pStubMsg->BufferLength += safe_multiply(esize, pStubMsg->ActualCount); + safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount)); EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat); } @@ -3204,7 +3277,7 @@ void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg, { ALIGN_LENGTH(pStubMsg->BufferLength, 4); /* skip pointer prefix */ - pStubMsg->BufferLength += 4; + safe_buffer_length_increment(pStubMsg, 4); if (pStubMsg->IgnoreEmbeddedPointers) return; if (pStubMsg->PointerLength) @@ -3220,7 +3293,7 @@ void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg, if (bufsize) { TRACE("size=%d\n", bufsize); - pStubMsg->BufferLength += bufsize; + safe_buffer_length_increment(pStubMsg, bufsize); } else pStubMsg->BufferLength = @@ -3370,16 +3443,19 @@ unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, TRACE("memory_size = %d\n", pCStructFormat->memory_size); bufsize = safe_multiply(esize, pStubMsg->MaxCount); + if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */ + { + ERR("integer overflow of memory_size %u with bufsize %u\n", + pCStructFormat->memory_size, bufsize); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } /* copy constant sized part of struct */ pStubMsg->BufferMark = pStubMsg->Buffer; - memcpy(pStubMsg->Buffer, pMemory, pCStructFormat->memory_size + bufsize); - pStubMsg->Buffer += pCStructFormat->memory_size + bufsize; + safe_copy_to_buffer(pStubMsg, pMemory, pCStructFormat->memory_size + bufsize); if (pCStructFormat->type == RPC_FC_CPSTRUCT) EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat); - STD_OVERFLOW_CHECK(pStubMsg); - return NULL; } @@ -3421,6 +3497,12 @@ unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMs TRACE("memory_size = %d\n", pCStructFormat->memory_size); bufsize = safe_multiply(esize, pStubMsg->MaxCount); + if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */ + { + ERR("integer overflow of memory_size %u with bufsize %u\n", + pCStructFormat->memory_size, bufsize); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } /* work out how much memory to allocate if we need to do so */ if (!*ppMemory || fMustAlloc) { @@ -3430,10 +3512,10 @@ unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMs /* now copy the data */ pStubMsg->BufferMark = pStubMsg->Buffer; - safe_buffer_copy(pStubMsg, *ppMemory, pCStructFormat->memory_size + bufsize); + safe_copy_from_buffer(pStubMsg, *ppMemory, pCStructFormat->memory_size + bufsize); if (pCStructFormat->type == RPC_FC_CPSTRUCT) - EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc); + EmbeddedPointerUnmarshall(pStubMsg, *ppMemory, *ppMemory, pFormat, TRUE /* FIXME */); return NULL; } @@ -3475,8 +3557,8 @@ void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, TRACE("memory_size = %d\n", pCStructFormat->memory_size); - pStubMsg->BufferLength += pCStructFormat->memory_size + - safe_multiply(pStubMsg->MaxCount, esize); + safe_buffer_length_increment(pStubMsg, pCStructFormat->memory_size); + safe_buffer_length_increment(pStubMsg, safe_multiply(pStubMsg->MaxCount, esize)); if (pCStructFormat->type == RPC_FC_CPSTRUCT) EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat); @@ -3569,21 +3651,17 @@ unsigned char * WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pS /* write constant sized part */ pStubMsg->BufferMark = pStubMsg->Buffer; - memcpy(pStubMsg->Buffer, pMemory, pCVStructFormat->memory_size); - pStubMsg->Buffer += pCVStructFormat->memory_size; + safe_copy_to_buffer(pStubMsg, pMemory, pCVStructFormat->memory_size); WriteVariance(pStubMsg); bufsize = safe_multiply(esize, pStubMsg->ActualCount); /* write array part */ - memcpy(pStubMsg->Buffer, pMemory + pCVStructFormat->memory_size, bufsize); - pStubMsg->Buffer += bufsize; + safe_copy_to_buffer(pStubMsg, pMemory + pCVStructFormat->memory_size, bufsize); EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat); - STD_OVERFLOW_CHECK(pStubMsg); - return NULL; } @@ -3652,7 +3730,7 @@ unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE /* copy the constant data */ pStubMsg->BufferMark = pStubMsg->Buffer; - safe_buffer_copy(pStubMsg, *ppMemory, pCVStructFormat->memory_size); + safe_copy_from_buffer(pStubMsg, *ppMemory, pCVStructFormat->memory_size); pCVArrayFormat = ReadVariance(pStubMsg, pCVArrayFormat, pStubMsg->MaxCount); @@ -3680,14 +3758,14 @@ unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE } /* copy the array data */ - safe_buffer_copy(pStubMsg, *ppMemory + pCVStructFormat->memory_size, bufsize); + safe_copy_from_buffer(pStubMsg, *ppMemory + pCVStructFormat->memory_size, bufsize); if (cvarray_type == RPC_FC_C_CSTRING) TRACE("string=%s\n", debugstr_a((char *)(*ppMemory + pCVStructFormat->memory_size))); else if (cvarray_type == RPC_FC_C_WSTRING) TRACE("string=%s\n", debugstr_w((WCHAR *)(*ppMemory + pCVStructFormat->memory_size))); - EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc); + EmbeddedPointerUnmarshall(pStubMsg, *ppMemory, *ppMemory, pFormat, TRUE /* FIXME */); return NULL; } @@ -3757,9 +3835,9 @@ void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, TRACE("memory_size = %d\n", pCVStructFormat->memory_size); - pStubMsg->BufferLength += pCVStructFormat->memory_size; + safe_buffer_length_increment(pStubMsg, pCVStructFormat->memory_size); SizeVariance(pStubMsg); - pStubMsg->BufferLength += safe_multiply(pStubMsg->MaxCount, esize); + safe_buffer_length_increment(pStubMsg, safe_multiply(pStubMsg->MaxCount, esize)); EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat); } @@ -3818,9 +3896,9 @@ ULONG WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, TRACE("memory_size = %d\n", pCVStructFormat->memory_size); - pStubMsg->Buffer += pCVStructFormat->memory_size; + safe_buffer_increment(pStubMsg, pCVStructFormat->memory_size); pCVArrayFormat = ReadVariance(pStubMsg, pCVArrayFormat, pStubMsg->MaxCount); - pStubMsg->Buffer += pCVStructFormat->memory_size + safe_multiply(esize, pStubMsg->ActualCount); + safe_buffer_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount)); pStubMsg->MemorySize += pCVStructFormat->memory_size + safe_multiply(esize, pStubMsg->MaxCount); @@ -3943,9 +4021,8 @@ unsigned char * WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, pFormat = (const unsigned char *)(pLgFArrayFormat + 1); } - memcpy(pStubMsg->Buffer, pMemory, total_size); pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += total_size; + safe_copy_to_buffer(pStubMsg, pMemory, total_size); pFormat = EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat); @@ -3990,9 +4067,9 @@ unsigned char * WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, if (fMustAlloc || !*ppMemory) *ppMemory = NdrAllocate(pStubMsg, total_size); pStubMsg->BufferMark = pStubMsg->Buffer; - safe_buffer_copy(pStubMsg, *ppMemory, total_size); + safe_copy_from_buffer(pStubMsg, *ppMemory, total_size); - pFormat = EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc); + pFormat = EmbeddedPointerUnmarshall(pStubMsg, *ppMemory, *ppMemory, pFormat, TRUE /* FIXME */); return NULL; } @@ -4030,7 +4107,7 @@ void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, total_size = pLgFArrayFormat->total_size; pFormat = (const unsigned char *)(pLgFArrayFormat + 1); } - pStubMsg->BufferLength += total_size; + safe_buffer_length_increment(pStubMsg, total_size); EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat); } @@ -4068,7 +4145,7 @@ ULONG WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, pFormat = (const unsigned char *)(pLgFArrayFormat + 1); } pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += total_size; + safe_buffer_increment(pStubMsg, total_size); pStubMsg->MemorySize += total_size; EmbeddedPointerMemorySize(pStubMsg, pFormat); @@ -4160,14 +4237,11 @@ unsigned char * WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, alignment); bufsize = safe_multiply(esize, pStubMsg->ActualCount); - memcpy(pStubMsg->Buffer, pMemory + pStubMsg->Offset, bufsize); pStubMsg->BufferMark = pStubMsg->Buffer; - pStubMsg->Buffer += bufsize; + safe_copy_to_buffer(pStubMsg, pMemory + pStubMsg->Offset, bufsize); EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat); - STD_OVERFLOW_CHECK(pStubMsg); - return NULL; } @@ -4223,9 +4297,9 @@ unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, if (!*ppMemory || fMustAlloc) *ppMemory = NdrAllocate(pStubMsg, size); - safe_buffer_copy(pStubMsg, *ppMemory + pStubMsg->Offset, bufsize); + safe_copy_from_buffer(pStubMsg, *ppMemory + pStubMsg->Offset, bufsize); - EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc); + EmbeddedPointerUnmarshall(pStubMsg, *ppMemory, *ppMemory, pFormat, TRUE /* FIXME */); return NULL; } @@ -4282,7 +4356,7 @@ void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_LENGTH(pStubMsg->BufferLength, alignment); - pStubMsg->BufferLength += safe_multiply(esize, pStubMsg->ActualCount); + safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount)); EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat); } @@ -4332,7 +4406,7 @@ ULONG WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, alignment); - pStubMsg->Buffer += safe_multiply(esize, pStubMsg->ActualCount); + safe_buffer_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount)); pStubMsg->MemorySize += size; EmbeddedPointerMemorySize(pStubMsg, pFormat); @@ -4490,13 +4564,19 @@ static unsigned char *union_arm_marshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned c pointer_buffer_mark_set = 1; } else - pStubMsg->Buffer += 4; /* for pointer ID */ + safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ PointerMarshall(pStubMsg, saved_buffer, *(unsigned char **)pMemory, desc); if (pointer_buffer_mark_set) { STD_OVERFLOW_CHECK(pStubMsg); pStubMsg->PointerBufferMark = pStubMsg->Buffer; + if (saved_buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) + { + ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n", + saved_buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } pStubMsg->Buffer = saved_buffer + 4; } break; @@ -4556,9 +4636,13 @@ static unsigned char *union_arm_unmarshall(PMIDL_STUB_MESSAGE pStubMsg, pStubMsg->Buffer += 4; /* for pointer ID */ if (saved_buffer + 4 > pStubMsg->BufferEnd) + { + ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n", + saved_buffer, pStubMsg->BufferEnd); RpcRaiseException(RPC_X_BAD_STUB_DATA); + } - PointerUnmarshall(pStubMsg, saved_buffer, *(unsigned char ***)ppMemory, desc, fMustAlloc); + PointerUnmarshall(pStubMsg, saved_buffer, *(unsigned char ***)ppMemory, **(unsigned char ***)ppMemory, desc, fMustAlloc); if (pointer_buffer_mark_set) { STD_OVERFLOW_CHECK(pStubMsg); @@ -4607,7 +4691,7 @@ static void union_arm_buffer_size(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_OP: case RPC_FC_FP: ALIGN_LENGTH(pStubMsg->BufferLength, 4); - pStubMsg->BufferLength += 4; /* for pointer ID */ + safe_buffer_length_increment(pStubMsg, 4); /* for pointer ID */ if (!pStubMsg->IgnoreEmbeddedPointers) { int saved_buffer_length = pStubMsg->BufferLength; @@ -4662,7 +4746,7 @@ static ULONG union_arm_memory_size(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_FP: ALIGN_POINTER(pStubMsg->Buffer, 4); saved_buffer = pStubMsg->Buffer; - pStubMsg->Buffer += 4; + safe_buffer_increment(pStubMsg, 4); ALIGN_LENGTH(pStubMsg->MemorySize, 4); pStubMsg->MemorySize += 4; if (!pStubMsg->IgnoreEmbeddedPointers) @@ -4893,7 +4977,7 @@ static long unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_USMALL: { UCHAR d; - safe_buffer_copy(pStubMsg, &d, sizeof(d)); + safe_copy_from_buffer(pStubMsg, &d, sizeof(d)); discriminant = d; break; } @@ -4903,7 +4987,7 @@ static long unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg, { USHORT d; ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); - safe_buffer_copy(pStubMsg, &d, sizeof(d)); + safe_copy_from_buffer(pStubMsg, &d, sizeof(d)); discriminant = d; break; } @@ -4912,7 +4996,7 @@ static long unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg, { ULONG d; ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG)); - safe_buffer_copy(pStubMsg, &d, sizeof(d)); + safe_copy_from_buffer(pStubMsg, &d, sizeof(d)); discriminant = d; break; } @@ -5184,6 +5268,12 @@ unsigned char *WINAPI NdrRangeUnmarshall( ALIGN_POINTER(pStubMsg->Buffer, sizeof(type)); \ if (fMustAlloc || !*ppMemory) \ *ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \ + if (pStubMsg->Buffer + sizeof(type) > pStubMsg->BufferEnd) \ + { \ + ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n", \ + pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); \ + RpcRaiseException(RPC_X_BAD_STUB_DATA); \ + } \ if ((*(type *)pStubMsg->Buffer < (type)pRange->low_value) || \ (*(type *)pStubMsg->Buffer > (type)pRange->high_value)) \ { \ @@ -5315,16 +5405,14 @@ static unsigned char *WINAPI NdrBaseTypeMarshall( case RPC_FC_CHAR: case RPC_FC_SMALL: case RPC_FC_USMALL: - *(UCHAR *)pStubMsg->Buffer = *(UCHAR *)pMemory; - pStubMsg->Buffer += sizeof(UCHAR); + safe_copy_to_buffer(pStubMsg, pMemory, sizeof(UCHAR)); TRACE("value: 0x%02x\n", *(UCHAR *)pMemory); break; case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); - *(USHORT *)pStubMsg->Buffer = *(USHORT *)pMemory; - pStubMsg->Buffer += sizeof(USHORT); + safe_copy_to_buffer(pStubMsg, pMemory, sizeof(USHORT)); TRACE("value: 0x%04x\n", *(USHORT *)pMemory); break; case RPC_FC_LONG: @@ -5332,24 +5420,20 @@ static unsigned char *WINAPI NdrBaseTypeMarshall( case RPC_FC_ERROR_STATUS_T: case RPC_FC_ENUM32: ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG)); - *(ULONG *)pStubMsg->Buffer = *(ULONG *)pMemory; - pStubMsg->Buffer += sizeof(ULONG); + safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONG)); TRACE("value: 0x%08x\n", *(ULONG *)pMemory); break; case RPC_FC_FLOAT: ALIGN_POINTER(pStubMsg->Buffer, sizeof(float)); - *(float *)pStubMsg->Buffer = *(float *)pMemory; - pStubMsg->Buffer += sizeof(float); + safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float)); break; case RPC_FC_DOUBLE: ALIGN_POINTER(pStubMsg->Buffer, sizeof(double)); - *(double *)pStubMsg->Buffer = *(double *)pMemory; - pStubMsg->Buffer += sizeof(double); + safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double)); break; case RPC_FC_HYPER: ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONGLONG)); - *(ULONGLONG *)pStubMsg->Buffer = *(ULONGLONG *)pMemory; - pStubMsg->Buffer += sizeof(ULONGLONG); + safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONGLONG)); TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory)); break; case RPC_FC_ENUM16: @@ -5357,6 +5441,8 @@ static unsigned char *WINAPI NdrBaseTypeMarshall( if (*(UINT *)pMemory > SHRT_MAX) RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE); ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); + if (pStubMsg->Buffer + sizeof(USHORT) > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) + RpcRaiseException(RPC_X_BAD_STUB_DATA); *(USHORT *)pStubMsg->Buffer = *(UINT *)pMemory; pStubMsg->Buffer += sizeof(USHORT); TRACE("value: 0x%04x\n", *(UINT *)pMemory); @@ -5367,8 +5453,6 @@ static unsigned char *WINAPI NdrBaseTypeMarshall( FIXME("Unhandled base type: 0x%02x\n", *pFormat); } - STD_OVERFLOW_CHECK(pStubMsg); - /* FIXME: what is the correct return value? */ return NULL; } @@ -5430,6 +5514,8 @@ static unsigned char *WINAPI NdrBaseTypeUnmarshall( ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); if (fMustAlloc || !*ppMemory) *ppMemory = NdrAllocate(pStubMsg, sizeof(UINT)); + if (pStubMsg->Buffer + sizeof(USHORT) > pStubMsg->BufferEnd) + RpcRaiseException(RPC_X_BAD_STUB_DATA); TRACE("*ppMemory: %p\n", *ppMemory); /* 16-bits on the wire, but int in memory */ **(UINT **)ppMemory = *(USHORT *)pStubMsg->Buffer; @@ -5464,36 +5550,36 @@ static void WINAPI NdrBaseTypeBufferSize( case RPC_FC_CHAR: case RPC_FC_SMALL: case RPC_FC_USMALL: - pStubMsg->BufferLength += sizeof(UCHAR); + safe_buffer_length_increment(pStubMsg, sizeof(UCHAR)); break; case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: case RPC_FC_ENUM16: ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(USHORT)); - pStubMsg->BufferLength += sizeof(USHORT); + safe_buffer_length_increment(pStubMsg, sizeof(USHORT)); break; case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(ULONG)); - pStubMsg->BufferLength += sizeof(ULONG); + safe_buffer_length_increment(pStubMsg, sizeof(ULONG)); break; case RPC_FC_FLOAT: ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(float)); - pStubMsg->BufferLength += sizeof(float); + safe_buffer_length_increment(pStubMsg, sizeof(float)); break; case RPC_FC_DOUBLE: ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(double)); - pStubMsg->BufferLength += sizeof(double); + safe_buffer_length_increment(pStubMsg, sizeof(double)); break; case RPC_FC_HYPER: ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(ULONGLONG)); - pStubMsg->BufferLength += sizeof(ULONGLONG); + safe_buffer_length_increment(pStubMsg, sizeof(ULONGLONG)); break; case RPC_FC_ERROR_STATUS_T: ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(error_status_t)); - pStubMsg->BufferLength += sizeof(error_status_t); + safe_buffer_length_increment(pStubMsg, sizeof(error_status_t)); break; case RPC_FC_IGNORE: break; @@ -5515,41 +5601,41 @@ static ULONG WINAPI NdrBaseTypeMemorySize( case RPC_FC_CHAR: case RPC_FC_SMALL: case RPC_FC_USMALL: - pStubMsg->Buffer += sizeof(UCHAR); + safe_buffer_increment(pStubMsg, sizeof(UCHAR)); pStubMsg->MemorySize += sizeof(UCHAR); return sizeof(UCHAR); case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: - pStubMsg->Buffer += sizeof(USHORT); + safe_buffer_increment(pStubMsg, sizeof(USHORT)); pStubMsg->MemorySize += sizeof(USHORT); return sizeof(USHORT); case RPC_FC_LONG: case RPC_FC_ULONG: - pStubMsg->Buffer += sizeof(ULONG); + case RPC_FC_ENUM32: + safe_buffer_increment(pStubMsg, sizeof(ULONG)); pStubMsg->MemorySize += sizeof(ULONG); return sizeof(ULONG); case RPC_FC_FLOAT: - pStubMsg->Buffer += sizeof(float); + safe_buffer_increment(pStubMsg, sizeof(float)); pStubMsg->MemorySize += sizeof(float); return sizeof(float); case RPC_FC_DOUBLE: - pStubMsg->Buffer += sizeof(double); + safe_buffer_increment(pStubMsg, sizeof(double)); pStubMsg->MemorySize += sizeof(double); return sizeof(double); case RPC_FC_HYPER: - pStubMsg->Buffer += sizeof(ULONGLONG); + safe_buffer_increment(pStubMsg, sizeof(ULONGLONG)); pStubMsg->MemorySize += sizeof(ULONGLONG); return sizeof(ULONGLONG); case RPC_FC_ERROR_STATUS_T: - pStubMsg->Buffer += sizeof(error_status_t); + safe_buffer_increment(pStubMsg, sizeof(error_status_t)); pStubMsg->MemorySize += sizeof(error_status_t); return sizeof(error_status_t); case RPC_FC_ENUM16: - case RPC_FC_ENUM32: - pStubMsg->Buffer += sizeof(INT); - pStubMsg->MemorySize += sizeof(INT); - return sizeof(INT); + safe_buffer_increment(pStubMsg, sizeof(USHORT)); + pStubMsg->MemorySize += sizeof(UINT); + return sizeof(UINT); case RPC_FC_IGNORE: pStubMsg->MemorySize += sizeof(void *); return sizeof(void *); @@ -5587,7 +5673,7 @@ static void WINAPI NdrContextHandleBufferSize( RpcRaiseException(RPC_S_INTERNAL_ERROR); } ALIGN_LENGTH(pStubMsg->BufferLength, 4); - pStubMsg->BufferLength += cbNDRContext; + safe_buffer_length_increment(pStubMsg, cbNDRContext); } /*********************************************************************** @@ -5646,6 +5732,13 @@ void WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg, ALIGN_POINTER(pStubMsg->Buffer, 4); + if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) + { + ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n", + pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); + RpcRaiseException(RPC_X_BAD_STUB_DATA); + } + /* FIXME: what does fCheck do? */ NDRCContextMarshall(ContextHandle, pStubMsg->Buffer); diff --git a/dlls/rpcrt4/rpc_message.c b/dlls/rpcrt4/rpc_message.c index 91572b17326..5b4d30e58a4 100644 --- a/dlls/rpcrt4/rpc_message.c +++ b/dlls/rpcrt4/rpc_message.c @@ -532,7 +532,7 @@ write: if (count<0) { WARN("rpcrt4_conn_write failed (auth)\n"); RPCRT4_SetThreadCurrentConnection(NULL); - return RPC_S_PROTOCOL_ERROR; + return RPC_S_CALL_FAILED; } buffer_pos += Header->common.frag_len - hdr_size - alen - auth_pad_len; @@ -708,7 +708,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, dwRead = rpcrt4_conn_read(Connection, &common_hdr, sizeof(common_hdr)); if (dwRead != sizeof(common_hdr)) { WARN("Short read of header, %d bytes\n", dwRead); - status = RPC_S_PROTOCOL_ERROR; + status = RPC_S_CALL_FAILED; goto fail; } @@ -734,7 +734,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, dwRead = rpcrt4_conn_read(Connection, &(*Header)->common + 1, hdr_length - sizeof(common_hdr)); if (dwRead != hdr_length - sizeof(common_hdr)) { WARN("bad header length, %d bytes, hdr_length %d\n", dwRead, hdr_length); - status = RPC_S_PROTOCOL_ERROR; + status = RPC_S_CALL_FAILED; goto fail; } @@ -760,7 +760,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, if (auth_length) { auth_data = HeapAlloc(GetProcessHeap(), 0, RPC_AUTH_VERIFIER_LEN(&common_hdr)); if (!auth_data) { - status = RPC_S_PROTOCOL_ERROR; + status = RPC_S_OUT_OF_RESOURCES; goto fail; } } @@ -806,7 +806,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, (unsigned char *)pMsg->Buffer + buffer_length, data_length); if (dwRead != data_length) { WARN("bad data length, %d/%ld\n", dwRead, data_length); - status = RPC_S_PROTOCOL_ERROR; + status = RPC_S_CALL_FAILED; goto fail; } @@ -826,7 +826,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, if (dwRead != header_auth_len) { WARN("bad authentication data length, %d/%d\n", dwRead, header_auth_len); - status = RPC_S_PROTOCOL_ERROR; + status = RPC_S_CALL_FAILED; goto fail; } @@ -854,7 +854,7 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, dwRead = rpcrt4_conn_read(Connection, *Header, hdr_length); if (dwRead != hdr_length) { WARN("invalid packet header size (%d)\n", dwRead); - status = RPC_S_PROTOCOL_ERROR; + status = RPC_S_CALL_FAILED; goto fail; } diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c index dfb7eceebe4..40cc613a6ad 100644 --- a/dlls/rpcrt4/rpc_transport.c +++ b/dlls/rpcrt4/rpc_transport.c @@ -773,7 +773,7 @@ static RPC_STATUS rpcrt4_ncacn_ip_tcp_open(RpcConnection* Connection) } sock = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol); - if (sock < 0) + if (sock == -1) { WARN("socket() failed: %s\n", strerror(errno)); continue; @@ -850,7 +850,7 @@ static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *pr } sock = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol); - if (sock < 0) + if (sock == -1) { WARN("socket() failed: %s\n", strerror(errno)); status = RPC_S_CANT_CREATE_ENDPOINT; diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c index f64c7668a91..06b7b5198f6 100644 --- a/dlls/rpcrt4/tests/ndr_marshall.c +++ b/dlls/rpcrt4/tests/ndr_marshall.c @@ -247,16 +247,21 @@ todo_wine { StubMsg.IsClient = 0; ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 ); ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); + if (formattypes[2] == 0xd /* FC_ENUM16 */) + ok(mem != StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem points to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); + else todo_wine { - ok(mem == StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem doesn't point to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); + ok(mem == StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem doesn't point to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); } ok(!cmp(mem, memsrc, size), "%s: incorrecly unmarshaled\n", msgpfx); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + if (formattypes[2] != 0xd /* FC_ENUM16 */) { todo_wine { - ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); - my_alloc_called = 0; + ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); + my_alloc_called = 0; } + } } HeapFree(GetProcessHeap(), 0, mem_orig); HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index ad0dd73c560..20e6033fe66 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -876,7 +876,6 @@ pointer_tests(void) name.size = 10; name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size); get_name(&name); - todo_wine ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer); HeapFree(GetProcessHeap(), 0, name.name); diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c index fcf3dcf6861..29e072c31c1 100644 --- a/dlls/rsaenh/rsaenh.c +++ b/dlls/rsaenh/rsaenh.c @@ -1583,8 +1583,8 @@ BOOL WINAPI RSAENH_CPAcquireContext(HCRYPTPROV *phProv, LPSTR pszContainer, case CRYPT_VERIFYCONTEXT|CRYPT_NEWKEYSET: case CRYPT_VERIFYCONTEXT: - if (pszContainer) { - TRACE("pszContainer should be NULL\n"); + if (pszContainer && *pszContainer) { + TRACE("pszContainer should be empty\n"); SetLastError(NTE_BAD_FLAGS); return FALSE; } @@ -2798,6 +2798,14 @@ BOOL WINAPI RSAENH_CPSetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam } switch (dwParam) { + case KP_PADDING: + /* The MS providers only support PKCS5_PADDING */ + if (*(DWORD *)pbData != PKCS5_PADDING) { + SetLastError(NTE_BAD_DATA); + return FALSE; + } + return TRUE; + case KP_MODE: pCryptKey->dwMode = *(DWORD*)pbData; return TRUE; @@ -2815,6 +2823,23 @@ BOOL WINAPI RSAENH_CPSetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam setup_key(pCryptKey); return TRUE; + case KP_SALT_EX: + { + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pbData; + + /* salt length can't be greater than 128 bits = 16 bytes */ + if (blob->cbData > 16) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + memcpy(pCryptKey->abKeyValue + pCryptKey->dwKeyLen, blob->pbData, + blob->cbData); + pCryptKey->dwSaltLen = blob->cbData; + setup_key(pCryptKey); + return TRUE; + } + case KP_EFFECTIVE_KEYLEN: switch (pCryptKey->aiAlgid) { case CALG_RC2: @@ -2901,7 +2926,7 @@ BOOL WINAPI RSAENH_CPGetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam DWORD *pdwDataLen, DWORD dwFlags) { CRYPTKEY *pCryptKey; - DWORD dwBitLen; + DWORD dwValue; TRACE("(hProv=%08lx, hKey=%08lx, dwParam=%08x, pbData=%p, pdwDataLen=%p dwFlags=%08x)\n", hProv, hKey, dwParam, pbData, pdwDataLen, dwFlags); @@ -2933,20 +2958,24 @@ BOOL WINAPI RSAENH_CPGetKeyParam(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam return copy_param(pbData, pdwDataLen, (CONST BYTE*)&pCryptKey->abKeyValue[pCryptKey->dwKeyLen], pCryptKey->dwSaltLen); + case KP_PADDING: + dwValue = PKCS5_PADDING; + return copy_param(pbData, pdwDataLen, (CONST BYTE*)&dwValue, sizeof(DWORD)); + case KP_KEYLEN: - dwBitLen = pCryptKey->dwKeyLen << 3; - return copy_param(pbData, pdwDataLen, (CONST BYTE*)&dwBitLen, sizeof(DWORD)); + dwValue = pCryptKey->dwKeyLen << 3; + return copy_param(pbData, pdwDataLen, (CONST BYTE*)&dwValue, sizeof(DWORD)); case KP_EFFECTIVE_KEYLEN: if (pCryptKey->dwEffectiveKeyLen) - dwBitLen = pCryptKey->dwEffectiveKeyLen; + dwValue = pCryptKey->dwEffectiveKeyLen; else - dwBitLen = pCryptKey->dwKeyLen << 3; - return copy_param(pbData, pdwDataLen, (CONST BYTE*)&dwBitLen, sizeof(DWORD)); + dwValue = pCryptKey->dwKeyLen << 3; + return copy_param(pbData, pdwDataLen, (CONST BYTE*)&dwValue, sizeof(DWORD)); case KP_BLOCKLEN: - dwBitLen = pCryptKey->dwBlockLen << 3; - return copy_param(pbData, pdwDataLen, (CONST BYTE*)&dwBitLen, sizeof(DWORD)); + dwValue = pCryptKey->dwBlockLen << 3; + return copy_param(pbData, pdwDataLen, (CONST BYTE*)&dwValue, sizeof(DWORD)); case KP_MODE: return copy_param(pbData, pdwDataLen, (CONST BYTE*)&pCryptKey->dwMode, sizeof(DWORD)); diff --git a/dlls/shdocvw/events.c b/dlls/shdocvw/events.c index be531dbfceb..f12ff950832 100644 --- a/dlls/shdocvw/events.c +++ b/dlls/shdocvw/events.c @@ -206,10 +206,10 @@ static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown * } if(i == This->sinks_size) - This->sinks = shdocvw_realloc(This->sinks, + This->sinks = heap_realloc(This->sinks, (++This->sinks_size)*sizeof(*This->sinks)); }else { - This->sinks = shdocvw_alloc(sizeof(*This->sinks)); + This->sinks = heap_alloc(sizeof(*This->sinks)); This->sinks_size = 1; i = 0; } @@ -271,7 +271,7 @@ void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams) static void ConnectionPoint_Create(REFIID riid, ConnectionPoint **cp, IConnectionPointContainer *container) { - ConnectionPoint *ret = shdocvw_alloc(sizeof(ConnectionPoint)); + ConnectionPoint *ret = heap_alloc(sizeof(ConnectionPoint)); ret->lpConnectionPointVtbl = &ConnectionPointVtbl; @@ -293,8 +293,8 @@ static void ConnectionPoint_Destroy(ConnectionPoint *This) IDispatch_Release(This->sinks[i]); } - shdocvw_free(This->sinks); - shdocvw_free(This); + heap_free(This->sinks); + heap_free(This); } void ConnectionPointContainer_Init(ConnectionPointContainer *This, IUnknown *impl) diff --git a/dlls/shdocvw/ie.c b/dlls/shdocvw/ie.c index 7627691efb5..493e7537f2a 100644 --- a/dlls/shdocvw/ie.c +++ b/dlls/shdocvw/ie.c @@ -75,7 +75,7 @@ static ULONG WINAPI InternetExplorer_Release(IWebBrowser2 *iface) if(!ref) { DocHost_Release(&This->doc_host); - shdocvw_free(This); + heap_free(This); } return ref; diff --git a/dlls/shdocvw/iexplore.c b/dlls/shdocvw/iexplore.c index c8fa61d9231..e6387d50937 100644 --- a/dlls/shdocvw/iexplore.c +++ b/dlls/shdocvw/iexplore.c @@ -161,7 +161,7 @@ HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv) TRACE("(%p %s %p)\n", pOuter, debugstr_guid(riid), ppv); - ret = shdocvw_alloc(sizeof(InternetExplorer)); + ret = heap_alloc(sizeof(InternetExplorer)); ret->ref = 0; ret->doc_host.disp = (IDispatch*)WEBBROWSER2(ret); @@ -174,7 +174,7 @@ HRESULT InternetExplorer_Create(IUnknown *pOuter, REFIID riid, void **ppv) hres = IWebBrowser2_QueryInterface(WEBBROWSER2(ret), riid, ppv); if(FAILED(hres)) { - shdocvw_free(ret); + heap_free(ret); return hres; } diff --git a/dlls/shdocvw/navigate.c b/dlls/shdocvw/navigate.c index fce2bb96499..429a71e52a4 100644 --- a/dlls/shdocvw/navigate.c +++ b/dlls/shdocvw/navigate.c @@ -137,8 +137,8 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface) if(!ref) { if(This->post_data) GlobalFree(This->post_data); - shdocvw_free(This->headers); - shdocvw_free(This); + heap_free(This->headers); + heap_free(This); } return ref; @@ -293,7 +293,7 @@ static const IHttpNegotiateVtbl HttpNegotiateVtbl = { static IBindStatusCallback *create_callback(DocHost *This, PBYTE post_data, ULONG post_data_len, LPWSTR headers, VARIANT_BOOL *cancel) { - BindStatusCallback *ret = shdocvw_alloc(sizeof(BindStatusCallback)); + BindStatusCallback *ret = heap_alloc(sizeof(BindStatusCallback)); ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl; ret->lpHttpNegotiateVtbl = &HttpNegotiateVtbl; @@ -310,7 +310,7 @@ static IBindStatusCallback *create_callback(DocHost *This, PBYTE post_data, if(headers) { int size = (strlenW(headers)+1)*sizeof(WCHAR); - ret->headers = shdocvw_alloc(size); + ret->headers = heap_alloc(size); memcpy(ret->headers, headers, size); } diff --git a/dlls/shdocvw/shdocvw.h b/dlls/shdocvw/shdocvw.h index 0b048eb1a34..494bae9cbdc 100644 --- a/dlls/shdocvw/shdocvw.h +++ b/dlls/shdocvw/shdocvw.h @@ -226,17 +226,17 @@ DWORD register_iexplore(BOOL); /* memory allocation functions */ -static inline void *shdocvw_alloc(size_t len) +static inline void *heap_alloc(size_t len) { return HeapAlloc(GetProcessHeap(), 0, len); } -static inline void *shdocvw_realloc(void *mem, size_t len) +static inline void *heap_realloc(void *mem, size_t len) { return HeapReAlloc(GetProcessHeap(), 0, mem, len); } -static inline BOOL shdocvw_free(void *mem) +static inline BOOL heap_free(void *mem) { return HeapFree(GetProcessHeap(), 0, mem); } diff --git a/dlls/shdocvw/shlinstobj.c b/dlls/shdocvw/shlinstobj.c index a69791871c3..eaca590ca33 100644 --- a/dlls/shdocvw/shlinstobj.c +++ b/dlls/shdocvw/shlinstobj.c @@ -59,7 +59,7 @@ static void RegistryPropertyBag_Destroy(RegistryPropertyBag *This) { TRACE("This=%p)\n", This); RegCloseKey(This->m_hInitPropertyBagKey); - shdocvw_free(This); + heap_free(This); } static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_QueryInterface(IPropertyBag *iface, @@ -130,20 +130,20 @@ static HRESULT WINAPI RegistryPropertyBag_IPropertyBag_Read(IPropertyBag *iface, if (res != ERROR_SUCCESS) return E_INVALIDARG; - pwszValue = shdocvw_alloc(cbData); + pwszValue = heap_alloc(cbData); if (!pwszValue) return E_OUTOFMEMORY; res = RegQueryValueExW(This->m_hInitPropertyBagKey, pwszPropName, NULL, &dwType, (LPBYTE)pwszValue, &cbData); if (res != ERROR_SUCCESS) { - shdocvw_free(pwszValue); + heap_free(pwszValue); return E_INVALIDARG; } V_VT(pVar) = VT_BSTR; V_BSTR(pVar) = SysAllocString(pwszValue); - shdocvw_free(pwszValue); + heap_free(pwszValue); if (vtDst != VT_BSTR) { hr = VariantChangeTypeEx(pVar, pVar, LOCALE_SYSTEM_DEFAULT, 0, vtDst); @@ -176,7 +176,7 @@ static HRESULT RegistryPropertyBag_Constructor(HKEY hInitPropertyBagKey, REFIID TRACE("(hInitPropertyBagKey=%p, riid=%s, ppvObject=%p)\n", hInitPropertyBagKey, debugstr_guid(riid), ppvObject); - pRegistryPropertyBag = shdocvw_alloc(sizeof(RegistryPropertyBag)); + pRegistryPropertyBag = heap_alloc(sizeof(RegistryPropertyBag)); if (pRegistryPropertyBag) { pRegistryPropertyBag->lpIPropertyBagVtbl = &RegistryPropertyBag_IPropertyBagVtbl; pRegistryPropertyBag->m_cRef = 0; @@ -206,7 +206,7 @@ typedef struct _InstanceObjectFactory { static void InstanceObjectFactory_Destroy(InstanceObjectFactory *This) { IPropertyBag_Release(This->m_pPropertyBag); - shdocvw_free(This); + heap_free(This); } static HRESULT WINAPI InstanceObjectFactory_IClassFactory_QueryInterface(IClassFactory *iface, @@ -322,7 +322,7 @@ static HRESULT InstanceObjectFactory_Constructor(REFCLSID rclsid, IPropertyBag * TRACE("(RegistryPropertyBag=%p, riid=%s, ppvObject=%p)\n", pPropertyBag, debugstr_guid(riid), ppvObject); - pInstanceObjectFactory = shdocvw_alloc(sizeof(InstanceObjectFactory)); + pInstanceObjectFactory = heap_alloc(sizeof(InstanceObjectFactory)); if (pInstanceObjectFactory) { pInstanceObjectFactory->lpIClassFactoryVtbl = &InstanceObjectFactory_IClassFactoryVtbl; pInstanceObjectFactory->m_cRef = 0; diff --git a/dlls/shdocvw/tests/webbrowser.c b/dlls/shdocvw/tests/webbrowser.c index 2659bc4456b..8e457fc241c 100644 --- a/dlls/shdocvw/tests/webbrowser.c +++ b/dlls/shdocvw/tests/webbrowser.c @@ -1412,6 +1412,8 @@ static void test_QueryInterface(IUnknown *unk) { IQuickActivate *qa = (IQuickActivate*)0xdeadbeef; IRunnableObject *runnable = (IRunnableObject*)0xdeadbeef; + IPerPropertyBrowsing *propbrowse = (void*)0xdeadbeef; + IOleCache *cache = (void*)0xdeadbeef; HRESULT hres; hres = IUnknown_QueryInterface(unk, &IID_IQuickActivate, (void**)&qa); @@ -1421,6 +1423,14 @@ static void test_QueryInterface(IUnknown *unk) hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&runnable); ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); ok(runnable == NULL, "runnable=%p, ezpected NULL\n", runnable); + + hres = IUnknown_QueryInterface(unk, &IID_IPerPropertyBrowsing, (void**)&propbrowse); + ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); + ok(runnable == NULL, "runnable=%p, ezpected NULL\n", runnable); + + hres = IUnknown_QueryInterface(unk, &IID_IOleCache, (void**)&cache); + ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres); + ok(cache == NULL, "runnable=%p, ezpected NULL\n", runnable); } static void test_WebBrowser(void) diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c index 79ae4a1f8f2..e2b79ae05d9 100644 --- a/dlls/shdocvw/webbrowser.c +++ b/dlls/shdocvw/webbrowser.c @@ -108,6 +108,12 @@ static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid }else if(IsEqualGUID(&IID_IRunnableObject, riid)) { TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv); return E_NOINTERFACE; + }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) { + TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv); + return E_NOINTERFACE; + }else if(IsEqualGUID(&IID_IOleCache, riid)) { + TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv); + return E_NOINTERFACE; } if(*ppv) { @@ -142,7 +148,7 @@ static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface) WebBrowser_OleObject_Destroy(This); - shdocvw_free(This); + heap_free(This); SHDOCVW_UnlockModule(); } @@ -939,7 +945,7 @@ static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, voi TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version); - ret = shdocvw_alloc(sizeof(WebBrowser)); + ret = heap_alloc(sizeof(WebBrowser)); ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl; ret->ref = 0; @@ -964,7 +970,7 @@ static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, voi if(SUCCEEDED(hres)) { SHDOCVW_LockModule(); }else { - shdocvw_free(ret); + heap_free(ret); return hres; } diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c index 63f81f39b8f..0b7a8f325bb 100644 --- a/dlls/shell32/shell32_main.c +++ b/dlls/shell32/shell32_main.c @@ -101,7 +101,7 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs) argv=GlobalLock(hargv); for (;;) { - len = GetModuleFileNameW(0, (LPWSTR)(argv+1), size-sizeof(LPWSTR)); + len = GetModuleFileNameW(0, (LPWSTR)(argv+1), (size-sizeof(LPWSTR))/sizeof(WCHAR)); if (!len) { GlobalFree(hargv); diff --git a/dlls/urlmon/bindctx.c b/dlls/urlmon/bindctx.c index 13dd9876ea5..e1b48c3e77d 100644 --- a/dlls/urlmon/bindctx.c +++ b/dlls/urlmon/bindctx.c @@ -132,7 +132,7 @@ static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface) if(This->authenticate) IAuthenticate_Release(This->authenticate); IBindStatusCallback_Release(This->callback); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); } return ref; @@ -455,7 +455,7 @@ static const IAuthenticateVtbl BSCAuthenticateVtbl = { static IBindStatusCallback *create_bsc(IBindStatusCallback *bsc) { - BindStatusCallback *ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BindStatusCallback)); + BindStatusCallback *ret = heap_alloc_zero(sizeof(BindStatusCallback)); ret->lpBindStatusCallbackVtbl = &BindStatusCallbackVtbl; ret->lpServiceProviderVtbl = &BSCServiceProviderVtbl; @@ -640,7 +640,7 @@ static ULONG WINAPI AsyncBindCtx_Release(IBindCtx *iface) if(!ref) { IBindCtx_Release(This->bindctx); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); } return ref; @@ -837,7 +837,7 @@ HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options, if(FAILED(hres)) return hres; - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(AsyncBindCtx)); + ret = heap_alloc(sizeof(AsyncBindCtx)); ret->lpBindCtxVtbl = &AsyncBindCtxVtbl; ret->ref = 1; diff --git a/dlls/urlmon/binding.c b/dlls/urlmon/binding.c index d3951bbdc02..8f1ed4f1ac6 100644 --- a/dlls/urlmon/binding.c +++ b/dlls/urlmon/binding.c @@ -299,7 +299,7 @@ static ULONG WINAPI ProtocolStream_Release(IStream *iface) if(!ref) { IInternetProtocol_Release(This->protocol); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -451,7 +451,7 @@ static const IStreamVtbl ProtocolStreamVtbl = { static ProtocolStream *create_stream(IInternetProtocol *protocol) { - ProtocolStream *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ProtocolStream)); + ProtocolStream *ret = heap_alloc(sizeof(ProtocolStream)); ret->lpStreamVtbl = &ProtocolStreamVtbl; ret->ref = 1; @@ -531,10 +531,10 @@ static ULONG WINAPI Binding_Release(IBinding *iface) ReleaseBindInfo(&This->bindinfo); This->section.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->section); - HeapFree(GetProcessHeap(), 0, This->mime); - HeapFree(GetProcessHeap(), 0, This->url); + heap_free(This->mime); + heap_free(This->url); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -631,7 +631,7 @@ static void switch_proc(Binding *binding, task_header_t *t) IInternetProtocol_Continue(binding->protocol, &task->data); - HeapFree(GetProcessHeap(), 0, task); + heap_free(task); } static HRESULT WINAPI InternetProtocolSink_Switch(IInternetProtocolSink *iface, @@ -642,7 +642,7 @@ static HRESULT WINAPI InternetProtocolSink_Switch(IInternetProtocolSink *iface, TRACE("(%p)->(%p)\n", This, pProtocolData); - task = HeapAlloc(GetProcessHeap(), 0, sizeof(switch_task_t)); + task = heap_alloc(sizeof(switch_task_t)); memcpy(&task->data, pProtocolData, sizeof(PROTOCOLDATA)); push_task(This, &task->header, switch_proc); @@ -670,8 +670,8 @@ static void on_progress_proc(Binding *binding, task_header_t *t) IBindStatusCallback_OnProgress(binding->callback, task->progress, task->progress_max, task->status_code, task->status_text); - HeapFree(GetProcessHeap(), 0, task->status_text); - HeapFree(GetProcessHeap(), 0, task); + heap_free(task->status_text); + heap_free(task); } static void on_progress(Binding *This, ULONG progress, ULONG progress_max, @@ -685,7 +685,7 @@ static void on_progress(Binding *This, ULONG progress, ULONG progress_max, return; } - task = HeapAlloc(GetProcessHeap(), 0, sizeof(on_progress_task_t)); + task = heap_alloc(sizeof(on_progress_task_t)); task->progress = progress; task->progress_max = progress_max; @@ -694,7 +694,7 @@ static void on_progress(Binding *This, ULONG progress, ULONG progress_max, if(status_text) { DWORD size = (strlenW(status_text)+1)*sizeof(WCHAR); - task->status_text = HeapAlloc(GetProcessHeap(), 0, size); + task->status_text = heap_alloc(size); memcpy(task->status_text, status_text, size); }else { task->status_text = NULL; @@ -727,7 +727,7 @@ static HRESULT WINAPI InternetProtocolSink_ReportProgress(IInternetProtocolSink break; case BINDSTATUS_MIMETYPEAVAILABLE: { int len = strlenW(szStatusText)+1; - This->mime = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + This->mime = heap_alloc(len*sizeof(WCHAR)); memcpy(This->mime, szStatusText, len*sizeof(WCHAR)); break; } @@ -822,7 +822,7 @@ static void report_data_proc(Binding *binding, task_header_t *t) report_data(binding, task->bscf, task->progress, task->progress_max); - HeapFree(GetProcessHeap(), 0, task); + heap_free(task); } static HRESULT WINAPI InternetProtocolSink_ReportData(IInternetProtocolSink *iface, @@ -836,7 +836,7 @@ static HRESULT WINAPI InternetProtocolSink_ReportData(IInternetProtocolSink *ifa FIXME("called from worked hread\n"); if(This->continue_call) { - report_data_task_t *task = HeapAlloc(GetProcessHeap(), 0, sizeof(report_data_task_t)); + report_data_task_t *task = heap_alloc(sizeof(report_data_task_t)); task->bscf = grfBSCF; task->progress = ulProgress; task->progress_max = ulProgressMax; @@ -858,7 +858,7 @@ static void report_result_proc(Binding *binding, task_header_t *t) binding->request_locked = FALSE; } - HeapFree(GetProcessHeap(), 0, t); + heap_free(t); } static HRESULT WINAPI InternetProtocolSink_ReportResult(IInternetProtocolSink *iface, @@ -871,7 +871,7 @@ static HRESULT WINAPI InternetProtocolSink_ReportResult(IInternetProtocolSink *i if(GetCurrentThreadId() == This->apartment_thread && !This->continue_call) { IInternetProtocol_Terminate(This->protocol, 0); }else { - task_header_t *task = HeapAlloc(GetProcessHeap(), 0, sizeof(task_header_t)); + task_header_t *task = heap_alloc(sizeof(task_header_t)); push_task(This, task, report_result_proc); } @@ -1123,7 +1123,7 @@ static HRESULT Binding_Create(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding * URLMON_LockModule(); - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(Binding)); + ret = heap_alloc(sizeof(Binding)); ret->lpBindingVtbl = &BindingVtbl; ret->lpInternetProtocolSinkVtbl = &InternetProtocolSinkVtbl; @@ -1185,7 +1185,7 @@ static HRESULT Binding_Create(LPCWSTR url, IBindCtx *pbc, REFIID riid, Binding * ret->bindf |= BINDF_NEEDFILE; len = strlenW(url)+1; - ret->url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + ret->url = heap_alloc(len*sizeof(WCHAR)); memcpy(ret->url, url, len*sizeof(WCHAR)); ret->stream = create_stream(ret->protocol); diff --git a/dlls/urlmon/bindprot.c b/dlls/urlmon/bindprot.c index 6b175f630c6..5ee8df8cb54 100644 --- a/dlls/urlmon/bindprot.c +++ b/dlls/urlmon/bindprot.c @@ -114,7 +114,7 @@ static ULONG WINAPI BindProtocol_Release(IInternetProtocol *iface) if(This->protocol_sink) IInternetProtocolSink_Release(This->protocol_sink); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -480,7 +480,7 @@ static const IInternetProtocolSinkVtbl InternetProtocolSinkVtbl = { HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol) { - BindProtocol *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(BindProtocol)); + BindProtocol *ret = heap_alloc(sizeof(BindProtocol)); ret->lpInternetProtocolVtbl = &BindProtocolVtbl; ret->lpInternetBindInfoVtbl = &InternetBindInfoVtbl; diff --git a/dlls/urlmon/file.c b/dlls/urlmon/file.c index 8d7b444b9d6..0a020848f7e 100644 --- a/dlls/urlmon/file.c +++ b/dlls/urlmon/file.c @@ -92,7 +92,7 @@ static ULONG WINAPI FileProtocol_Release(IInternetProtocol *iface) if(!ref) { if(This->file) CloseHandle(This->file); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -135,10 +135,10 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl return MK_E_SYNTAX; len = lstrlenW(szUrl)+16; - url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + url = heap_alloc(len*sizeof(WCHAR)); hres = CoInternetParseUrl(szUrl, PARSE_ENCODE, 0, url, len, &len, 0); if(FAILED(hres)) { - HeapFree(GetProcessHeap(), 0, url); + heap_free(url); return hres; } @@ -163,7 +163,7 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl This->file = NULL; IInternetProtocolSink_ReportResult(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, GetLastError(), NULL); - HeapFree(GetProcessHeap(), 0, url); + heap_free(url); return INET_E_RESOURCE_NOT_FOUND; } @@ -180,7 +180,7 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl } } - HeapFree(GetProcessHeap(), 0, url); + heap_free(url); if(GetFileSizeEx(This->file, &size)) IInternetProtocolSink_ReportData(pOIProtSink, @@ -353,7 +353,7 @@ HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) URLMON_LockModule(); - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(FileProtocol)); + ret = heap_alloc(sizeof(FileProtocol)); ret->lpInternetProtocolVtbl = &FileProtocolVtbl; ret->lpInternetPriorityVtbl = &FilePriorityVtbl; diff --git a/dlls/urlmon/format.c b/dlls/urlmon/format.c index fdc00835422..ca909127703 100644 --- a/dlls/urlmon/format.c +++ b/dlls/urlmon/format.c @@ -78,8 +78,8 @@ static ULONG WINAPI EnumFORMATETC_Release(IEnumFORMATETC *iface) TRACE("(%p) ref=%d\n", This, ref); if(!ref) { - HeapFree(GetProcessHeap(), 0, This->fetc); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This->fetc); + heap_free(This); URLMON_UnlockModule(); } @@ -160,7 +160,7 @@ static const IEnumFORMATETCVtbl EnumFORMATETCVtbl = { static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmtetc, UINT it) { - EnumFORMATETC *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumFORMATETC)); + EnumFORMATETC *ret = heap_alloc(sizeof(EnumFORMATETC)); URLMON_LockModule(); @@ -169,7 +169,7 @@ static IEnumFORMATETC *EnumFORMATETC_Create(UINT cfmtetc, const FORMATETC *rgfmt ret->it = it; ret->fetc_cnt = cfmtetc; - ret->fetc = HeapAlloc(GetProcessHeap(), 0, cfmtetc*sizeof(FORMATETC)); + ret->fetc = heap_alloc(cfmtetc*sizeof(FORMATETC)); memcpy(ret->fetc, rgfmtetc, cfmtetc*sizeof(FORMATETC)); return (IEnumFORMATETC*)ret; diff --git a/dlls/urlmon/ftp.c b/dlls/urlmon/ftp.c index 6db8fe5af0a..b921293b141 100644 --- a/dlls/urlmon/ftp.c +++ b/dlls/urlmon/ftp.c @@ -81,7 +81,7 @@ static ULONG WINAPI FtpProtocol_Release(IInternetProtocol *iface) TRACE("(%p) ref=%d\n", This, ref); if(!ref) { - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -191,7 +191,7 @@ HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) URLMON_LockModule(); - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(FtpProtocol)); + ret = heap_alloc(sizeof(FtpProtocol)); ret->lpInternetProtocolVtbl = &FtpProtocolVtbl; ret->ref = 1; diff --git a/dlls/urlmon/http.c b/dlls/urlmon/http.c index a8e5c16ffb4..fa759ebe254 100644 --- a/dlls/urlmon/http.c +++ b/dlls/urlmon/http.c @@ -159,7 +159,7 @@ static void HTTPPROTOCOL_Close(HttpProtocol *This) if (This->full_header) { if (This->full_header != wszHeaders) - HeapFree(GetProcessHeap(), 0, This->full_header); + heap_free(This->full_header); This->full_header = 0; } This->flags = 0; @@ -234,7 +234,7 @@ static inline LPWSTR strndupW(LPCWSTR string, int len) { LPWSTR ret = NULL; if (string && - (ret = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR))) != NULL) + (ret = heap_alloc((len+1)*sizeof(WCHAR))) != NULL) { memcpy(ret, string, len*sizeof(WCHAR)); ret[len] = 0; @@ -296,7 +296,7 @@ static ULONG WINAPI HttpProtocol_Release(IInternetProtocol *iface) if(!ref) { HTTPPROTOCOL_Close(This); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -378,7 +378,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl { WARN("ObtainUserAgentString failed: %08x\n", hres); } - else if (!(user_agenta = HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR)))) + else if (!(user_agenta = heap_alloc(len*sizeof(CHAR)))) { WARN("Out of memory\n"); } @@ -393,7 +393,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl else MultiByteToWideChar(CP_ACP, 0, user_agenta, -1, user_agent, len*sizeof(WCHAR)); } - HeapFree(GetProcessHeap(), 0, user_agenta); + heap_free(user_agenta); } This->internet = InternetOpenW(user_agent, 0, NULL, NULL, INTERNET_FLAG_ASYNC); @@ -472,8 +472,7 @@ static HRESULT WINAPI HttpProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl else { int len_addl_header = lstrlenW(addl_header); - This->full_header = HeapAlloc(GetProcessHeap(), 0, - len_addl_header*sizeof(WCHAR)+sizeof(wszHeaders)); + This->full_header = heap_alloc(len_addl_header*sizeof(WCHAR)+sizeof(wszHeaders)); if (!This->full_header) { WARN("Out of memory\n"); @@ -557,10 +556,10 @@ done: CoTaskMemFree(accept_mimes[num++]); CoTaskMemFree(user_agent); - HeapFree(GetProcessHeap(), 0, pass); - HeapFree(GetProcessHeap(), 0, user); - HeapFree(GetProcessHeap(), 0, path); - HeapFree(GetProcessHeap(), 0, host); + heap_free(pass); + heap_free(user); + heap_free(path); + heap_free(host); return hres; } @@ -610,7 +609,7 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA if ((!HttpQueryInfoW(This->request, HTTP_QUERY_RAW_HEADERS_CRLF, response_headers, &len, NULL) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) || - !(response_headers = HeapAlloc(GetProcessHeap(), 0, len)) || + !(response_headers = heap_alloc(len)) || !HttpQueryInfoW(This->request, HTTP_QUERY_RAW_HEADERS_CRLF, response_headers, &len, NULL)) { @@ -631,7 +630,7 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA len = 0; if ((!HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_TYPE, content_type, &len, NULL) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) || - !(content_type = HeapAlloc(GetProcessHeap(), 0, len)) || + !(content_type = heap_alloc(len)) || !HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_TYPE, content_type, &len, NULL)) { WARN("HttpQueryInfo failed: %d\n", GetLastError()); @@ -657,7 +656,7 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA len = 0; if ((!HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_LENGTH, content_length, &len, NULL) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) || - !(content_length = HeapAlloc(GetProcessHeap(), 0, len)) || + !(content_length = heap_alloc(len)) || !HttpQueryInfoW(This->request, HTTP_QUERY_CONTENT_LENGTH, content_length, &len, NULL)) { WARN("HttpQueryInfo failed: %d\n", GetLastError()); @@ -694,9 +693,9 @@ static HRESULT WINAPI HttpProtocol_Continue(IInternetProtocol *iface, PROTOCOLDA } done: - HeapFree(GetProcessHeap(), 0, response_headers); - HeapFree(GetProcessHeap(), 0, content_type); - HeapFree(GetProcessHeap(), 0, content_length); + heap_free(response_headers); + heap_free(content_type); + heap_free(content_length); /* Returns S_OK on native */ return S_OK; @@ -926,7 +925,7 @@ HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) URLMON_LockModule(); - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HttpProtocol)); + ret = heap_alloc(sizeof(HttpProtocol)); ret->lpInternetProtocolVtbl = &HttpProtocolVtbl; ret->lpInternetPriorityVtbl = &HttpPriorityVtbl; diff --git a/dlls/urlmon/mk.c b/dlls/urlmon/mk.c index 2ae76ed9587..031224a93e6 100644 --- a/dlls/urlmon/mk.c +++ b/dlls/urlmon/mk.c @@ -88,7 +88,7 @@ static ULONG WINAPI MkProtocol_Release(IInternetProtocol *iface) if(This->stream) IStream_Release(This->stream); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -153,11 +153,11 @@ static HRESULT WINAPI MkProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, if(!ptr) return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, ERROR_INVALID_PARAMETER); - progid = HeapAlloc(GetProcessHeap(), 0, (ptr-ptr2+1)*sizeof(WCHAR)); + progid = heap_alloc((ptr-ptr2+1)*sizeof(WCHAR)); memcpy(progid, ptr2, (ptr-ptr2)*sizeof(WCHAR)); progid[ptr-ptr2] = 0; hres = CLSIDFromProgID(progid, &clsid); - HeapFree(GetProcessHeap(), 0, progid); + heap_free(progid); if(FAILED(hres)) return report_result(pOIProtSink, INET_E_RESOURCE_NOT_FOUND, ERROR_INVALID_PARAMETER); @@ -169,10 +169,10 @@ static HRESULT WINAPI MkProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, } len = strlenW(--ptr2); - display_name = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)); + display_name = heap_alloc((len+1)*sizeof(WCHAR)); memcpy(display_name, ptr2, (len+1)*sizeof(WCHAR)); hres = IParseDisplayName_ParseDisplayName(pdn, NULL /* FIXME */, display_name, &eaten, &mon); - HeapFree(GetProcessHeap(), 0, display_name); + heap_free(display_name); IParseDisplayName_Release(pdn); if(FAILED(hres)) { WARN("ParseDisplayName failed: %08x\n", hres); @@ -307,7 +307,7 @@ HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) URLMON_LockModule(); - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(MkProtocol)); + ret = heap_alloc(sizeof(MkProtocol)); ret->lpInternetProtocolVtbl = &MkProtocolVtbl; ret->ref = 1; diff --git a/dlls/urlmon/regsvr.c b/dlls/urlmon/regsvr.c index e9893233086..c4c4188834b 100644 --- a/dlls/urlmon/regsvr.c +++ b/dlls/urlmon/regsvr.c @@ -550,7 +550,7 @@ static HRESULT register_inf(BOOL doregister) INF_SET_CLSID(MkProtocol); for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) { - pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39); + pse[i].pszValue = heap_alloc(39); sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0], clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4], @@ -566,7 +566,7 @@ static HRESULT register_inf(BOOL doregister) hres = pRegInstall(URLMON_hInstance, doregister ? "RegisterDll" : "UnregisterDll", &strtable); for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++) - HeapFree(GetProcessHeap(), 0, pse[i].pszValue); + heap_free(pse[i].pszValue); return hres; } diff --git a/dlls/urlmon/sec_mgr.c b/dlls/urlmon/sec_mgr.c index 6330906ea58..83c21832d91 100644 --- a/dlls/urlmon/sec_mgr.c +++ b/dlls/urlmon/sec_mgr.c @@ -173,7 +173,7 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface) if(This->custom_manager) IInternetSecurityManager_Release(This->custom_manager); - HeapFree(GetProcessHeap(),0,This); + heap_free(This); URLMON_UnlockModule(); } @@ -260,7 +260,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac FIXME("not supported flags: %08x\n", dwFlags); size = (strlenW(pwszUrl)+16) * sizeof(WCHAR); - url = HeapAlloc(GetProcessHeap(), 0, size); + url = heap_alloc(size); hres = CoInternetParseUrl(pwszUrl, PARSE_SECURITY_URL, 0, url, size/sizeof(WCHAR), &size, 0); if(FAILED(hres)) @@ -268,7 +268,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac hres = map_url_to_zone(url, pdwZone); - HeapFree(GetProcessHeap(), 0, url); + heap_free(url); return hres; } @@ -300,7 +300,7 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa FIXME("dwReserved is not supported\n"); len = strlenW(pwszUrl)+1; - buf = HeapAlloc(GetProcessHeap(), 0, (len+16)*sizeof(WCHAR)); + buf = heap_alloc((len+16)*sizeof(WCHAR)); hres = CoInternetParseUrl(pwszUrl, PARSE_SECURITY_URL, 0, buf, len, &size, 0); if(FAILED(hres)) @@ -308,7 +308,7 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa hres = map_url_to_zone(buf, &zone); if(FAILED(hres)) { - HeapFree(GetProcessHeap(), 0, buf); + heap_free(buf); return hres == 0x80041001 ? E_INVALIDARG : hres; } @@ -318,7 +318,7 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa static const BYTE secidFile[] = {'f','i','l','e',':'}; - HeapFree(GetProcessHeap(), 0, buf); + heap_free(buf); if(*pcbSecurityId < sizeof(secidFile)+sizeof(zone)) return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); @@ -344,12 +344,12 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *ifa len = WideCharToMultiByte(CP_ACP, 0, buf, -1, NULL, 0, NULL, NULL)-1; if(len+sizeof(DWORD) > *pcbSecurityId) { - HeapFree(GetProcessHeap(), 0, buf); + heap_free(buf); return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); } WideCharToMultiByte(CP_ACP, 0, buf, -1, (LPSTR)pbSecurityId, -1, NULL, NULL); - HeapFree(GetProcessHeap(), 0, buf); + heap_free(buf); *(DWORD*)(pbSecurityId+len) = zone; @@ -464,7 +464,7 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) SecManagerImpl *This; TRACE("(%p,%p)\n",pUnkOuter,ppobj); - This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); + This = heap_alloc(sizeof(*This)); /* Initialize the virtual function table. */ This->lpInternetSecurityManagerVtbl = &VT_SecManagerImpl; @@ -577,7 +577,7 @@ static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface) TRACE("(%p)->(ref before=%u)\n",This, refCount + 1); if(!refCount) { - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -790,7 +790,7 @@ static const IInternetZoneManagerVtbl ZoneMgrImplVtbl = { HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj) { - ZoneMgrImpl* ret = HeapAlloc(GetProcessHeap(), 0, sizeof(ZoneMgrImpl)); + ZoneMgrImpl* ret = heap_alloc(sizeof(ZoneMgrImpl)); TRACE("(%p %p)\n", pUnkOuter, ppobj); ret->lpVtbl = &ZoneMgrImplVtbl; diff --git a/dlls/urlmon/session.c b/dlls/urlmon/session.c index a57a8dce82e..5c24aecec7c 100644 --- a/dlls/urlmon/session.c +++ b/dlls/urlmon/session.c @@ -68,12 +68,12 @@ static HRESULT get_protocol_cf(LPCWSTR schema, DWORD schema_len, CLSID *pclsid, {'P','R','O','T','O','C','O','L','S','\\','H','a','n','d','l','e','r','\\'}; static const WCHAR wszCLSID[] = {'C','L','S','I','D',0}; - wszKey = HeapAlloc(GetProcessHeap(), 0, sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR)); + wszKey = heap_alloc(sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR)); memcpy(wszKey, wszProtocolsKey, sizeof(wszProtocolsKey)); memcpy(wszKey + sizeof(wszProtocolsKey)/sizeof(WCHAR), schema, (schema_len+1)*sizeof(WCHAR)); res = RegOpenKeyW(HKEY_CLASSES_ROOT, wszKey, &hkey); - HeapFree(GetProcessHeap(), 0, wszKey); + heap_free(wszKey); if(res != ERROR_SUCCESS) { TRACE("Could not open protocol handler key\n"); return E_FAIL; @@ -207,10 +207,10 @@ static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface, if(!pCF || !pwzProtocol) return E_INVALIDARG; - new_name_space = HeapAlloc(GetProcessHeap(), 0, sizeof(name_space)); + new_name_space = heap_alloc(sizeof(name_space)); size = (strlenW(pwzProtocol)+1)*sizeof(WCHAR); - new_name_space->protocol = HeapAlloc(GetProcessHeap(), 0, size); + new_name_space->protocol = heap_alloc(size); memcpy(new_name_space->protocol, pwzProtocol, size); IClassFactory_AddRef(pCF); @@ -247,8 +247,8 @@ static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *ifac name_space_list = iter->next; IClassFactory_Release(iter->cf); - HeapFree(GetProcessHeap(), 0, iter->protocol); - HeapFree(GetProcessHeap(), 0, iter); + heap_free(iter->protocol); + heap_free(iter); return S_OK; } diff --git a/dlls/urlmon/umon.c b/dlls/urlmon/umon.c index 9cf1af3997f..e8aae03f98b 100644 --- a/dlls/urlmon/umon.c +++ b/dlls/urlmon/umon.c @@ -101,7 +101,7 @@ static ULONG WINAPI Binding_Release(IBinding* iface) TRACE("(%p) ref=%d\n",This, ref); if(!ref) { - HeapFree(GetProcessHeap(), 0, This->URLName); + heap_free(This->URLName); if (This->hCacheFile) CloseHandle(This->hCacheFile); if (This->pstrCache) @@ -112,7 +112,7 @@ static ULONG WINAPI Binding_Release(IBinding* iface) if (This->pbscb) IBindStatusCallback_Release(This->pbscb); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This); URLMON_UnlockModule(); } @@ -356,8 +356,8 @@ static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface) /* destroy the object if there's no more reference on it */ if (!refCount) { - HeapFree(GetProcessHeap(),0,This->URLName); - HeapFree(GetProcessHeap(),0,This); + heap_free(This->URLName); + heap_free(This); URLMON_UnlockModule(); } @@ -420,8 +420,8 @@ static HRESULT WINAPI URLMonikerImpl_Load(IMoniker* iface,IStream* pStm) res = IStream_Read(pStm, &size, sizeof(ULONG), &got); if(SUCCEEDED(res)) { if(got == sizeof(ULONG)) { - HeapFree(GetProcessHeap(), 0, This->URLName); - This->URLName=HeapAlloc(GetProcessHeap(),0,size); + heap_free(This->URLName); + This->URLName = heap_alloc(size); if(!This->URLName) res = E_OUTOFMEMORY; else { @@ -517,13 +517,13 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName, return E_NOTIMPL; } - bind = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Binding)); + bind = heap_alloc_zero(sizeof(Binding)); bind->lpVtbl = &BindingVtbl; bind->ref = 1; URLMON_LockModule(); len = lstrlenW(URLName)+1; - bind->URLName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + bind->URLName = heap_alloc(len*sizeof(WCHAR)); memcpy(bind->URLName, URLName, len*sizeof(WCHAR)); hres = UMCreateStreamOnCacheFile(bind->URLName, 0, szFileName, &bind->hCacheFile, &bind->pstrCache); @@ -561,15 +561,15 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName, url.dwStructSize = sizeof(url); url.dwSchemeLength = url.dwHostNameLength = url.dwUrlPathLength = url.dwUserNameLength = url.dwPasswordLength = 1; InternetCrackUrlW(URLName, 0, ICU_ESCAPE, &url); - host = HeapAlloc(GetProcessHeap(), 0, (url.dwHostNameLength + 1) * sizeof(WCHAR)); + host = heap_alloc((url.dwHostNameLength + 1) * sizeof(WCHAR)); memcpy(host, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR)); host[url.dwHostNameLength] = '\0'; - path = HeapAlloc(GetProcessHeap(), 0, (url.dwUrlPathLength + 1) * sizeof(WCHAR)); + path = heap_alloc((url.dwUrlPathLength + 1) * sizeof(WCHAR)); memcpy(path, url.lpszUrlPath, url.dwUrlPathLength * sizeof(WCHAR)); path[url.dwUrlPathLength] = '\0'; if (url.dwUserNameLength) { - user = HeapAlloc(GetProcessHeap(), 0, ((url.dwUserNameLength + 1) * sizeof(WCHAR))); + user = heap_alloc(((url.dwUserNameLength + 1) * sizeof(WCHAR))); memcpy(user, url.lpszUserName, url.dwUserNameLength * sizeof(WCHAR)); user[url.dwUserNameLength] = 0; } @@ -579,7 +579,7 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName, } if (url.dwPasswordLength) { - pass = HeapAlloc(GetProcessHeap(), 0, ((url.dwPasswordLength + 1) * sizeof(WCHAR))); + pass = heap_alloc(((url.dwPasswordLength + 1) * sizeof(WCHAR))); memcpy(pass, url.lpszPassword, url.dwPasswordLength * sizeof(WCHAR)); pass[url.dwPasswordLength] = 0; } @@ -711,10 +711,10 @@ static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName, Binding_FinishedDownload(bind, hres); Binding_CloseCacheDownload(bind); - HeapFree(GetProcessHeap(), 0, user); - HeapFree(GetProcessHeap(), 0, pass); - HeapFree(GetProcessHeap(), 0, path); - HeapFree(GetProcessHeap(), 0, host); + heap_free(user); + heap_free(pass); + heap_free(path); + heap_free(host); } } } @@ -1042,7 +1042,7 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeft This->lpvtbl = &VT_URLMonikerImpl; This->ref = 0; - This->URLName = HeapAlloc(GetProcessHeap(), 0, INTERNET_MAX_URL_LENGTH*sizeof(WCHAR)); + This->URLName = heap_alloc(INTERNET_MAX_URL_LENGTH*sizeof(WCHAR)); if(lpszLeftURLName) hres = CoInternetCombineUrl(lpszLeftURLName, lpszURLName, URL_FILE_USE_PATHURL, @@ -1052,14 +1052,14 @@ static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeft This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0); if(FAILED(hres)) { - HeapFree(GetProcessHeap(), 0, This->URLName); + heap_free(This->URLName); return hres; } URLMON_LockModule(); if(sizeStr != INTERNET_MAX_URL_LENGTH) - This->URLName = HeapReAlloc(GetProcessHeap(), 0, This->URLName, (sizeStr+1)*sizeof(WCHAR)); + This->URLName = heap_realloc(This->URLName, (sizeStr+1)*sizeof(WCHAR)); TRACE("URLName = %s\n", debugstr_w(This->URLName)); @@ -1092,7 +1092,7 @@ HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker if (dwFlags & URL_MK_UNIFORM) FIXME("ignoring flag URL_MK_UNIFORM\n"); - if(!(obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj)))) + if(!(obj = heap_alloc(sizeof(*obj)))) return E_OUTOFMEMORY; if(pmkContext) { @@ -1111,7 +1111,7 @@ HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker if(SUCCEEDED(hres)) hres = URLMonikerImpl_QueryInterface((IMoniker*)obj, &IID_IMoniker, (void**)ppmk); else - HeapFree(GetProcessHeap(), 0, obj); + heap_free(obj); return hres; } @@ -1437,12 +1437,12 @@ HRESULT WINAPI URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller, LPCSTR szURL, LPST if(szURL) { len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0); - url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); + url = heap_alloc(len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, szURL, -1, url, -1); } if(szFileName) - file_name = HeapAlloc(GetProcessHeap(), 0, dwBufLength*sizeof(WCHAR)); + file_name = heap_alloc(dwBufLength*sizeof(WCHAR)); hres = URLDownloadToCacheFileW(lpUnkCaller, url, file_name, dwBufLength*sizeof(WCHAR), dwReserved, pBSC); @@ -1450,8 +1450,8 @@ HRESULT WINAPI URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller, LPCSTR szURL, LPST if(SUCCEEDED(hres) && file_name) WideCharToMultiByte(CP_ACP, 0, file_name, -1, szFileName, dwBufLength, NULL, NULL); - HeapFree(GetProcessHeap(), 0, url); - HeapFree(GetProcessHeap(), 0, file_name); + heap_free(url); + heap_free(file_name); return hres; } diff --git a/dlls/urlmon/umstream.c b/dlls/urlmon/umstream.c index 213608fb59b..b70a2cd4701 100644 --- a/dlls/urlmon/umstream.c +++ b/dlls/urlmon/umstream.c @@ -54,7 +54,7 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL, HRESULT hr; size = (strlenW(pszURL)+1)*sizeof(WCHAR); - url = HeapAlloc(GetProcessHeap(), 0, size); + url = heap_alloc(size); memcpy(url, pszURL, size); for (c = url; *c && *c != '#' && *c != '?'; ++c) @@ -72,7 +72,7 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL, else hr = 0; - HeapFree(GetProcessHeap(), 0, url); + heap_free(url); if (hr) return hr; @@ -99,17 +99,13 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL, } } - ucstr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(IUMCacheStream)); - if(ucstr ) + ucstr = heap_alloc_zero(sizeof(IUMCacheStream)); + if(ucstr) { - ucstr->pszURL = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - sizeof(WCHAR) * (lstrlenW(pszURL) + 1)); + ucstr->pszURL = heap_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszURL) + 1)); if (ucstr->pszURL) { - ucstr->pszFileName = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - sizeof(WCHAR) * (lstrlenW(pszFileName) + 1)); + ucstr->pszFileName = heap_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszFileName) + 1)); if (ucstr->pszFileName) { ucstr->lpVtbl=&stvt; @@ -123,9 +119,9 @@ HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL, return S_OK; } - HeapFree(GetProcessHeap(), 0, ucstr->pszURL); + heap_free(ucstr->pszURL); } - HeapFree(GetProcessHeap(), 0, ucstr); + heap_free(ucstr); } CloseHandle(handle); if (phfile) @@ -211,9 +207,9 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface) TRACE(" destroying UMCacheStream (%p)\n",This); UMCloseCacheFileStream(This); CloseHandle(This->handle); - HeapFree(GetProcessHeap(), 0, This->pszFileName); - HeapFree(GetProcessHeap(), 0, This->pszURL); - HeapFree(GetProcessHeap(),0,This); + heap_free(This->pszFileName); + heap_free(This->pszURL); + heap_free(This); } return refCount; } @@ -414,54 +410,86 @@ static HRESULT WINAPI ProxyBindStatusCallback_OnStartBinding(IBindStatusCallback IBinding *pib) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_OnStartBinding(This->pBSC, dwReserved, pib); + + if(This->pBSC) + return IBindStatusCallback_OnStartBinding(This->pBSC, dwReserved, pib); + + return S_OK; } static HRESULT WINAPI ProxyBindStatusCallback_GetPriority(IBindStatusCallback *iface, LONG *pnPriority) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_GetPriority(This->pBSC, pnPriority); + + if(This->pBSC) + return IBindStatusCallback_GetPriority(This->pBSC, pnPriority); + + return S_OK; } static HRESULT WINAPI ProxyBindStatusCallback_OnLowResource(IBindStatusCallback *iface, DWORD reserved) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_OnLowResource(This->pBSC, reserved); + + if(This->pBSC) + return IBindStatusCallback_OnLowResource(This->pBSC, reserved); + + return S_OK; } static HRESULT WINAPI ProxyBindStatusCallback_OnProgress(IBindStatusCallback *iface, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_OnProgress(This->pBSC, ulProgress, + + if(This->pBSC) + return IBindStatusCallback_OnProgress(This->pBSC, ulProgress, ulProgressMax, ulStatusCode, szStatusText); + + return S_OK; } static HRESULT WINAPI ProxyBindStatusCallback_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_OnStopBinding(This->pBSC, hresult, szError); + + if(This->pBSC) + return IBindStatusCallback_OnStopBinding(This->pBSC, hresult, szError); + + return S_OK; } static HRESULT WINAPI ProxyBindStatusCallback_GetBindInfo(IBindStatusCallback *iface, DWORD *grfBINDF, BINDINFO *pbindinfo) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_GetBindInfo(This->pBSC, grfBINDF, pbindinfo); + + if(This->pBSC) + return IBindStatusCallback_GetBindInfo(This->pBSC, grfBINDF, pbindinfo); + + return E_INVALIDARG; } static HRESULT WINAPI ProxyBindStatusCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_OnDataAvailable(This->pBSC, grfBSCF, dwSize, + + if(This->pBSC) + return IBindStatusCallback_OnDataAvailable(This->pBSC, grfBSCF, dwSize, pformatetc, pstgmed); + + return S_OK; } static HRESULT WINAPI ProxyBindStatusCallback_OnObjectAvailable(IBindStatusCallback *iface, REFIID riid, IUnknown *punk) { ProxyBindStatusCallback *This = (ProxyBindStatusCallback *)iface; - return IBindStatusCallback_OnObjectAvailable(This->pBSC, riid, punk); + + if(This->pBSC) + return IBindStatusCallback_OnObjectAvailable(This->pBSC, riid, punk); + + return S_OK; } static HRESULT WINAPI BlockingBindStatusCallback_OnDataAvailable(IBindStatusCallback *iface, DWORD grfBSCF, @@ -563,7 +591,7 @@ HRESULT WINAPI URLOpenBlockingStreamA(LPUNKNOWN pCaller, LPCSTR szURL, return E_INVALIDARG; len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0); - szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + szURLW = heap_alloc(len * sizeof(WCHAR)); if (!szURLW) { *ppStream = NULL; @@ -573,7 +601,7 @@ HRESULT WINAPI URLOpenBlockingStreamA(LPUNKNOWN pCaller, LPCSTR szURL, hr = URLOpenBlockingStreamW(pCaller, szURLW, ppStream, dwReserved, lpfnCB); - HeapFree(GetProcessHeap(), 0, szURLW); + heap_free(szURLW); return hr; } @@ -615,14 +643,14 @@ HRESULT WINAPI URLOpenStreamA(LPUNKNOWN pCaller, LPCSTR szURL, DWORD dwReserved, return E_INVALIDARG; len = MultiByteToWideChar(CP_ACP, 0, szURL, -1, NULL, 0); - szURLW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + szURLW = heap_alloc(len * sizeof(WCHAR)); if (!szURLW) return E_OUTOFMEMORY; MultiByteToWideChar(CP_ACP, 0, szURL, -1, szURLW, len); hr = URLOpenStreamW(pCaller, szURLW, dwReserved, lpfnCB); - HeapFree(GetProcessHeap(), 0, szURLW); + heap_free(szURLW); return hr; } diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index 6c2887e57c7..9f31fb9ca3b 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -63,4 +63,24 @@ HRESULT start_binding(LPCWSTR url, IBindCtx *pbc, REFIID riid, void **ppv); HRESULT create_binding_protocol(LPCWSTR url, IInternetProtocol **protocol); +static inline void *heap_alloc(size_t len) +{ + return HeapAlloc(GetProcessHeap(), 0, len); +} + +static inline void *heap_alloc_zero(size_t len) +{ + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); +} + +static inline void *heap_realloc(void *mem, size_t len) +{ + return HeapReAlloc(GetProcessHeap(), 0, mem, len); +} + +static inline BOOL heap_free(void *mem) +{ + return HeapFree(GetProcessHeap(), 0, mem); +} + #endif /* __WINE_URLMON_MAIN_H */ diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 1709f282c28..b8466184163 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -774,7 +774,7 @@ static void CBPaintText( clipRegion=NULL; } - if (!IsWindowEnabled(lphc->self) & WS_DISABLED) itemState |= ODS_DISABLED; + if (!IsWindowEnabled(lphc->self)) itemState |= ODS_DISABLED; dis.CtlType = ODT_COMBOBOX; dis.CtlID = ctlid; diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index d3ea93227de..3d8ec5f0a6c 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1981,7 +1981,7 @@ WORD WINAPI DestroyIcon32( HGLOBAL16 handle, UINT16 flags ) if ( get_user_thread_info()->cursor == HICON_32(handle) ) { WARN_(cursor)("Destroying active cursor!\n" ); - SetCursor( 0 ); + return FALSE; } /* Try shared cursor/icon first */ diff --git a/dlls/user32/exticon.c b/dlls/user32/exticon.c index 8b703099f90..2b54df4dbfe 100644 --- a/dlls/user32/exticon.c +++ b/dlls/user32/exticon.c @@ -338,7 +338,6 @@ static UINT ICO_ExtractIconExW( UINT16 iconDirCount = 0,iconCount = 0; LPBYTE peimage; HANDLE fmapping; - ULONG uSize; DWORD fsizeh,fsizel; WCHAR szExePath[MAX_PATH]; DWORD dwSearchReturn; @@ -420,6 +419,7 @@ static UINT ICO_ExtractIconExW( NE_NAMEINFO *pIconStorage = NULL; NE_NAMEINFO *pIconDir = NULL; LPicoICONDIR lpiID = NULL; + ULONG uSize = 0; TRACE("-- OS2/icon Signature (0x%08x)\n", sig); diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 3a931219738..cb60ffcf80f 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -216,7 +216,7 @@ const struct builtin_class_descr MENU_builtin_class = if (flags & (bit)) { flags &= ~(bit); MENUOUT ((text)); } \ } while (0) -static void do_debug_print_menuitem(const char *prefix, MENUITEM * mp, +static void do_debug_print_menuitem(const char *prefix, const MENUITEM *mp, const char *postfix) { static const char * const hbmmenus[] = { "HBMMENU_CALLBACK", "", "HBMMENU_SYSTEM", @@ -1095,7 +1095,7 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner, * MENU_GetMaxPopupHeight */ static UINT -MENU_GetMaxPopupHeight(LPPOPUPMENU lppop) +MENU_GetMaxPopupHeight(const POPUPMENU *lppop) { if (lppop->cyMax) return lppop->cyMax; @@ -1268,7 +1268,7 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect, * Draw scroll arrows. */ static void -MENU_DrawScrollArrows(LPPOPUPMENU lppop, HDC hdc) +MENU_DrawScrollArrows(const POPUPMENU *lppop, HDC hdc) { HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hOrigBitmap; diff --git a/dlls/user32/scroll.c b/dlls/user32/scroll.c index f07bf75828b..78564b04a89 100644 --- a/dlls/user32/scroll.c +++ b/dlls/user32/scroll.c @@ -961,7 +961,7 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) } else /* WM_MOUSEMOVE */ { - UINT pos; + INT pos; if (!SCROLL_PtInRectEx( &rect, pt, vertical )) pos = lastClickPos; else @@ -1621,7 +1621,7 @@ static INT SCROLL_SetScrollInfo( HWND hwnd, INT nBar, LPCSCROLLINFO info, BOOL b if (info->fMask & SIF_PAGE) { - if( infoPtr->page != info->nPage && info->nPage >= 0) + if( infoPtr->page != info->nPage ) { infoPtr->page = info->nPage; action |= SA_SSI_REFRESH; diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index d5acd0bda92..dba5dd6e769 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -88,8 +88,8 @@ enum spi_index static const char * const DefSysColors[] = { "Scrollbar", "212 208 200", /* COLOR_SCROLLBAR */ - "Background", "58 110 165", /* COLOR_BACKGROUND */ - "ActiveTitle", "0 0 128", /* COLOR_ACTIVECAPTION */ + "Background", "58 110 165", /* COLOR_BACKGROUND */ + "ActiveTitle", "10 36 106", /* COLOR_ACTIVECAPTION */ "InactiveTitle", "128 128 128", /* COLOR_INACTIVECAPTION */ "Menu", "212 208 200", /* COLOR_MENU */ "Window", "255 255 255", /* COLOR_WINDOW */ @@ -114,8 +114,8 @@ static const char * const DefSysColors[] = "InfoWindow", "255 255 225", /* COLOR_INFOBK */ "ButtonAlternateFace", "180 180 180", /* COLOR_ALTERNATEBTNFACE */ "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */ - "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */ - "GradientInactiveTitle", "181 181 181", /* COLOR_GRADIENTINACTIVECAPTION */ + "GradientActiveTitle", "166 202 240", /* COLOR_GRADIENTACTIVECAPTION */ + "GradientInactiveTitle", "192 192 192", /* COLOR_GRADIENTINACTIVECAPTION */ "MenuHilight", "0 0 0", /* COLOR_MENUHILIGHT */ "MenuBar", "212 208 200" /* COLOR_MENUBAR */ }; diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index 84b9fe3e528..9858e327f7b 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -373,6 +373,52 @@ static void test_CreateIcon(void) DeleteObject(hbmColor); } +static void test_DestroyCursor(void) +{ + static const BYTE bmp_bits[4096]; + ICONINFO cursorInfo; + HCURSOR cursor, cursor2; + BOOL ret; + DWORD error; + UINT display_bpp; + HDC hdc; + + hdc = GetDC(0); + display_bpp = GetDeviceCaps(hdc, BITSPIXEL); + ReleaseDC(0, hdc); + + cursorInfo.fIcon = FALSE; + cursorInfo.xHotspot = 0; + cursorInfo.yHotspot = 0; + cursorInfo.hbmMask = CreateBitmap(32, 32, 1, 1, bmp_bits); + cursorInfo.hbmColor = CreateBitmap(32, 32, 1, display_bpp, bmp_bits); + + cursor = CreateIconIndirect(&cursorInfo); + ok(cursor != NULL, "CreateIconIndirect returned %p\n", cursor); + if(!cursor) { + return; + } + SetCursor(cursor); + + SetLastError(0xdeadbeef); + ret = DestroyCursor(cursor); + ok(!ret, "DestroyCursor on the active cursor succeeded\n"); + error = GetLastError(); + ok(error == 0xdeadbeef, "Last error: %u\n", error); + + cursor2 = GetCursor(); + ok(cursor2 == cursor, "Active was set to %p when trying to destroy it\n", cursor2); + + SetCursor(NULL); + + /* Trying to destroy the cursor properly fails now for some reason with ERROR_INVALID_CURSOR_HANDLE */ + ret = DestroyCursor(cursor); + /* ok(ret, "DestroyCursor failed, GetLastError=%d\n", GetLastError()); */ + + DeleteObject(cursorInfo.hbmMask); + DeleteObject(cursorInfo.hbmColor); +} + START_TEST(cursoricon) { test_CopyImage_Bitmap(1); @@ -382,4 +428,5 @@ START_TEST(cursoricon) test_CopyImage_Bitmap(24); test_CopyImage_Bitmap(32); test_CreateIcon(); + test_DestroyCursor(); } diff --git a/dlls/winecoreaudio.drv/audio.c b/dlls/winecoreaudio.drv/audio.c index a831bf775d5..ee089ab99fd 100644 --- a/dlls/winecoreaudio.drv/audio.c +++ b/dlls/winecoreaudio.drv/audio.c @@ -2129,6 +2129,29 @@ static DWORD widStop(WORD wDevID) return ret; } +/************************************************************************** + * widGetPos [internal] + */ +static DWORD widGetPos(WORD wDevID, LPMMTIME lpTime, UINT size) +{ + DWORD val; + WINE_WAVEIN* wwi; + + TRACE("(%u);\n", wDevID); + if (wDevID >= MAX_WAVEINDRV) + { + WARN("invalid device ID\n"); + return MMSYSERR_INVALHANDLE; + } + + wwi = &WInDev[wDevID]; + + OSSpinLockLock(&WInDev[wDevID].lock); + val = wwi->dwTotalRecorded; + OSSpinLockUnlock(&WInDev[wDevID].lock); + + return bytes_to_mmtime(lpTime, val, &wwi->format); +} /************************************************************************** * widReset [internal] @@ -2283,6 +2306,7 @@ DWORD WINAPI CoreAudio_widMessage(WORD wDevID, WORD wMsg, DWORD dwUser, case WIDM_RESET: return widReset (wDevID); case WIDM_START: return widStart (wDevID); case WIDM_STOP: return widStop (wDevID); + case WIDM_GETPOS: return widGetPos (wDevID, (LPMMTIME)dwParam1, (UINT)dwParam2 ); case DRV_QUERYDEVICEINTERFACESIZE: return widDevInterfaceSize (wDevID, (LPDWORD)dwParam1); case DRV_QUERYDEVICEINTERFACE: return widDevInterface (wDevID, (PWCHAR)dwParam1, dwParam2); case DRV_QUERYDSOUNDIFACE: return widDsCreate (wDevID, (PIDSCDRIVER*)dwParam1); diff --git a/dlls/winecoreaudio.drv/mixer.c b/dlls/winecoreaudio.drv/mixer.c index 25f3d55a776..66db8cb3742 100644 --- a/dlls/winecoreaudio.drv/mixer.c +++ b/dlls/winecoreaudio.drv/mixer.c @@ -760,6 +760,11 @@ static DWORD MIX_GetLineControls(WORD wDevID, LPMIXERLINECONTROLSW lpMlc, DWORD_ break; case MIXER_GETLINECONTROLSF_ONEBYTYPE: TRACE("dwLineID=%d MIXER_GETLINECONTROLSF_ONEBYTYPE (%s)\n", lpMlc->dwLineID, getControlType(lpMlc->u.dwControlType)); + if ( (lpMlc->dwLineID < 0) || (lpMlc->dwLineID >= mixer.caps.cDestinations) ) + { + ret = MIXERR_INVALLINE; + break; + } if (lpMlc->u.dwControlType == MIXERCONTROL_CONTROLTYPE_VOLUME) { ctrl = (lpMlc->dwLineID * ControlsPerLine) + IDControlVolume; diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 4a08f7013c3..aad28653920 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -468,7 +468,7 @@ static void vshader_program_add_param(SHADER_OPCODE_ARG *arg, const DWORD param, break; case WINED3DSPR_CONST: if(param & WINED3DSHADER_ADDRMODE_RELATIVE) { - if(reg - This->rel_offset >= 0) { + if(reg >= This->rel_offset) { sprintf(tmpReg, "C[A0.x + %u]", reg - This->rel_offset); } else { sprintf(tmpReg, "C[A0.x - %u]", -reg + This->rel_offset); @@ -525,8 +525,17 @@ static void shader_hw_sample(SHADER_OPCODE_ARG* arg, DWORD sampler_idx, const ch break; case WINED3DSTT_2D: - tex_type = "2D"; + { + IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) arg->shader; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; + if(device->stateBlock->textures[sampler_idx] && + IWineD3DBaseTexture_GetTextureDimensions(device->stateBlock->textures[sampler_idx]) == GL_TEXTURE_RECTANGLE_ARB) { + tex_type = "RECT"; + } else { + tex_type = "2D"; + } break; + } case WINED3DSTT_VOLUME: tex_type = "3D"; @@ -1020,8 +1029,8 @@ void pshader_hw_texkill(SHADER_OPCODE_ARG* arg) { * copy the register into our general purpose TMP variable, overwrite .w and pass TMP to KIL */ shader_addline(buffer, "MOV TMP, %s;\n", reg_dest); - shader_addline(buffer, "MOV TMP.w, one.w;\n", reg_dest); - shader_addline(buffer, "KIL TMP;\n", reg_dest); + shader_addline(buffer, "MOV TMP.w, one.w;\n"); + shader_addline(buffer, "KIL TMP;\n"); } } @@ -1374,8 +1383,8 @@ void pshader_hw_texdepth(SHADER_OPCODE_ARG* arg) { */ shader_addline(buffer, "RCP %s.g, %s.g;\n", dst_name, dst_name); shader_addline(buffer, "MUL TMP.x, %s.r, %s.g;\n", dst_name, dst_name); - shader_addline(buffer, "MIN TMP.x, TMP.x, one.r;\n", dst_name, dst_name); - shader_addline(buffer, "MAX result.depth, TMP.x, 0.0;\n", dst_name, dst_name); + shader_addline(buffer, "MIN TMP.x, TMP.x, one.r;\n"); + shader_addline(buffer, "MAX result.depth, TMP.x, 0.0;\n"); } /** Process the WINED3DSIO_TEXDP3TEX instruction in ARB: diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c index 638db902f08..5f94a29cbd6 100644 --- a/dlls/wined3d/baseshader.c +++ b/dlls/wined3d/baseshader.c @@ -349,6 +349,10 @@ HRESULT shader_get_registers_used( } else { int texType = IWineD3DBaseTexture_GetTextureDimensions(stateBlock->textures[sampler_code]); switch(texType) { + /* We have to select between texture rectangles and 2D textures later because 2.0 and + * 3.0 shaders only have WINED3DSTT_2D as well + */ + case GL_TEXTURE_RECTANGLE_ARB: case GL_TEXTURE_2D: reg_maps->samplers[sampler_code] = (0x1 << 31) | WINED3DSTT_2D; break; diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c index a1290f869ce..d17a4f477f1 100644 --- a/dlls/wined3d/basetexture.c +++ b/dlls/wined3d/basetexture.c @@ -285,11 +285,15 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) { checkGLcall("glBindTexture"); if (isNewTexture) { /* For a new texture we have to set the textures levels after binding the texture. - * In theory this is all we should ever have to do, but because ATI's drivers are broken, we - * also need to set the texture dimensions before the texture is set */ - TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1); - glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1); - checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)"); + * In theory this is all we should ever have to do, but because ATI's drivers are broken, we + * also need to set the texture dimensions before the texture is set + * Beware that texture rectangles do not support mipmapping. + */ + if(textureDimensions != GL_TEXTURE_RECTANGLE_ARB) { + TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1); + glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1); + checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)"); + } if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) { /* Cubemaps are always set to clamp, regardeless of the sampler state. */ glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -413,15 +417,17 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue); glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue); /* We need to reset the Aniotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentataion to see how it should be switched off. */ - if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state) { + if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state && + textureDimensions != GL_TEXTURE_RECTANGLE_ARB) { glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]); } This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = state; } - if(samplerStates[WINED3DSAMP_MINFILTER] != This->baseTexture.states[WINED3DTEXSTA_MINFILTER] || - samplerStates[WINED3DSAMP_MIPFILTER] != This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] || - samplerStates[WINED3DSAMP_MAXMIPLEVEL] != This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL]) { + if(textureDimensions != GL_TEXTURE_RECTANGLE_ARB && + (samplerStates[WINED3DSAMP_MINFILTER] != This->baseTexture.states[WINED3DTEXSTA_MINFILTER] || + samplerStates[WINED3DSAMP_MIPFILTER] != This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] || + samplerStates[WINED3DSAMP_MAXMIPLEVEL] != This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL])) { GLint glValue; This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER]; @@ -458,7 +464,7 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface } if(samplerStates[WINED3DSAMP_MAXANISOTROPY] != This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY]) { - if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) { + if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && textureDimensions != GL_TEXTURE_RECTANGLE_ARB) { glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]); checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ..."); } else { diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 32d75b60835..5e1bdc6d810 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -473,8 +473,7 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) { * SetupForBlit * * Sets up a context for DirectDraw blitting. - * All texture units are disabled, except unit 0 - * Texture unit 0 is activted where GL_TEXTURE_2D is activated + * All texture units are disabled, texture unit 0 is set as current unit * fog, lighting, blending, alpha test, z test, scissor test, culling diabled * color writing enabled for all channels * register combiners disabled, shaders disabled @@ -544,8 +543,8 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex } glDisable(GL_TEXTURE_3D); checkGLcall("glDisable GL_TEXTURE_3D"); - glEnable(GL_TEXTURE_2D); - checkGLcall("glEnable GL_TEXTURE_2D"); + glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable GL_TEXTURE_2D"); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 659b8bf8d69..f9b399d503d 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -876,14 +876,35 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U pow2Width = pow2Height = 1; while (pow2Width < Width) pow2Width <<= 1; while (pow2Height < Height) pow2Height <<= 1; + + if(pow2Width != Width || pow2Height != Height) { + if(Levels > 1) { + WARN("Attempted to create a mipmapped np2 texture without unconditional np2 support\n"); + HeapFree(GetProcessHeap(), 0, object); + *ppTexture = NULL; + return WINED3DERR_INVALIDCALL; + } else { + Levels = 1; + } + } } /** FIXME: add support for real non-power-two if it's provided by the video card **/ /* Precalculated scaling for 'faked' non power of two texture coords */ - object->baseTexture.pow2Matrix[0] = (((float)Width) / ((float)pow2Width)); - object->baseTexture.pow2Matrix[5] = (((float)Height) / ((float)pow2Height)); - object->baseTexture.pow2Matrix[10] = 1.0; - object->baseTexture.pow2Matrix[15] = 1.0; + if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE) && + (Width != pow2Width || Height != pow2Height)) { + object->baseTexture.pow2Matrix[0] = (float)Width; + object->baseTexture.pow2Matrix[5] = (float)Height; + object->baseTexture.pow2Matrix[10] = 1.0; + object->baseTexture.pow2Matrix[15] = 1.0; + object->target = GL_TEXTURE_RECTANGLE_ARB; + } else { + object->baseTexture.pow2Matrix[0] = (((float)Width) / ((float)pow2Width)); + object->baseTexture.pow2Matrix[5] = (((float)Height) / ((float)pow2Height)); + object->baseTexture.pow2Matrix[10] = 1.0; + object->baseTexture.pow2Matrix[15] = 1.0; + object->target = GL_TEXTURE_2D; + } TRACE(" xf(%f) yf(%f)\n", object->baseTexture.pow2Matrix[0], object->baseTexture.pow2Matrix[5]); /* Calculate levels for mip mapping */ @@ -5739,8 +5760,16 @@ static void attach_surface_fbo(IWineD3DDeviceImpl *This, GLenum fbo_target, DWOR GLint old_binding; texttarget = surface_impl->glDescription.target; - target = texttarget == GL_TEXTURE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP_ARB; - glGetIntegerv(texttarget == GL_TEXTURE_2D ? GL_TEXTURE_BINDING_2D : GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding); + if(texttarget == GL_TEXTURE_2D) { + target = GL_TEXTURE_2D; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding); + } else if(texttarget == GL_TEXTURE_RECTANGLE_ARB) { + target = GL_TEXTURE_RECTANGLE_ARB; + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding); + } else { + target = GL_TEXTURE_CUBE_MAP_ARB; + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding); + } IWineD3DSurface_PreLoad(surface); @@ -6047,6 +6076,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *ifa IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], (IWineD3DBase *) Swapchain); } else { HeapFree(GetProcessHeap(), 0, Swapchain->backBuffer); + Swapchain->backBuffer = NULL; } } @@ -6085,8 +6115,16 @@ static void set_depth_stencil_fbo(IWineD3DDevice *iface, IWineD3DSurface *depth_ GLint old_binding = 0; texttarget = depth_stencil_impl->glDescription.target; - target = texttarget == GL_TEXTURE_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP_ARB; - glGetIntegerv(texttarget == GL_TEXTURE_2D ? GL_TEXTURE_BINDING_2D : GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding); + if(texttarget == GL_TEXTURE_2D) { + target = GL_TEXTURE_2D; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding); + } else if(texttarget == GL_TEXTURE_RECTANGLE_ARB) { + target = GL_TEXTURE_RECTANGLE_ARB; + glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding); + } else { + target = GL_TEXTURE_CUBE_MAP_ARB; + glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding); + } IWineD3DSurface_PreLoad(depth_stencil); @@ -6339,7 +6377,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, TRACE("(%p) : Setting rendertarget %d to %p\n", This, RenderTargetIndex, pRenderTarget); if (RenderTargetIndex >= GL_LIMITS(buffers)) { - ERR("(%p) : Only %d render targets are supported.\n", This, GL_LIMITS(buffers)); + WARN("(%p) : Unsupported target %u set, returning WINED3DERR_INVALIDCALL(only %u supported)\n", + This, RenderTargetIndex, GL_LIMITS(buffers)); return WINED3DERR_INVALIDCALL; } diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 36d7ebcfe8b..e4b5bdf46db 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -75,6 +75,7 @@ static const struct { {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT, 0 }, {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 }, {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, 0 }, + {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 }, {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 }, {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 }, {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 }, @@ -870,6 +871,12 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { } else if (gl_info->supported[NV_FRAGMENT_PROGRAM]) { gl_info->ps_nv_version = PS_VERSION_20; } + if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]) { + /* If we have full NP2 texture support, disable GL_ARB_texture_rectangle because we will never use it. + * This saves a few redundant glDisable calls + */ + gl_info->supported[ARB_TEXTURE_RECTANGLE] = FALSE; + } } checkGLcall("extension detection\n"); @@ -950,6 +957,11 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { gl_info->gl_card = CARD_NVIDIA_GEFORCE_8600GT; vidmem = 256; } + /* Geforce8 - midend mobile */ + else if(strstr(gl_info->gl_renderer, "8600 M")) { + gl_info->gl_card = CARD_NVIDIA_GEFORCE_8600MGT; + vidmem = 512; + } /* Geforce8 - lowend */ else if(strstr(gl_info->gl_renderer, "8300") || strstr(gl_info->gl_renderer, "8400") || @@ -968,10 +980,18 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { gl_info->gl_card = CARD_NVIDIA_GEFORCE_7800GT; vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */ } - /* Geforce7 midend / Geforce6 highend */ - else if(strstr(gl_info->gl_renderer, "6800") || - strstr(gl_info->gl_renderer, "7600") || - strstr(gl_info->gl_renderer, "7700")) + /* Geforce7 midend */ + else if(strstr(gl_info->gl_renderer, "7600") || + strstr(gl_info->gl_renderer, "7700")) { + gl_info->gl_card = CARD_NVIDIA_GEFORCE_7600; + vidmem = 256; /* The 7600 uses 256-512MB */ + /* Geforce7 lower medium */ + } else if(strstr(gl_info->gl_renderer, "7400")) { + gl_info->gl_card = CARD_NVIDIA_GEFORCE_7400; + vidmem = 256; /* The 7400 uses 256-512MB */ + } + /* Geforce6 highend */ + else if(strstr(gl_info->gl_renderer, "6800")) { gl_info->gl_card = CARD_NVIDIA_GEFORCE_6800; vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */ @@ -2829,6 +2849,7 @@ static void fixup_extensions(WineD3D_GL_Info *gl_info) { gl_info->gl_card == CARD_ATI_RADEON_7200 || gl_info->gl_card == CARD_ATI_RAGE_128PRO) { TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing\n"); gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = FALSE; + gl_info->supported[ARB_TEXTURE_RECTANGLE] = TRUE; } } } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index d9e525bb5aa..dd18709b0a4 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -478,7 +478,7 @@ void shader_generate_glsl_declarations( /* Prototype the subroutines */ for (i = 0; i < This->baseShader.limits.label; i++) { if (reg_maps->labels[i]) - shader_addline(buffer, "void subroutine%lu();\n", i); + shader_addline(buffer, "void subroutine%u();\n", i); } /* Declare the constants (aka uniforms) */ @@ -573,19 +573,24 @@ void shader_generate_glsl_declarations( switch (stype) { case WINED3DSTT_1D: - shader_addline(buffer, "uniform sampler1D %csampler%lu;\n", prefix, i); + shader_addline(buffer, "uniform sampler1D %csampler%u;\n", prefix, i); break; case WINED3DSTT_2D: - shader_addline(buffer, "uniform sampler2D %csampler%lu;\n", prefix, i); + if(device->stateBlock->textures[i] && + IWineD3DBaseTexture_GetTextureDimensions(device->stateBlock->textures[i]) == GL_TEXTURE_RECTANGLE_ARB) { + shader_addline(buffer, "uniform sampler2DRect %csampler%u;\n", prefix, i); + } else { + shader_addline(buffer, "uniform sampler2D %csampler%u;\n", prefix, i); + } break; case WINED3DSTT_CUBE: - shader_addline(buffer, "uniform samplerCube %csampler%lu;\n", prefix, i); + shader_addline(buffer, "uniform samplerCube %csampler%u;\n", prefix, i); break; case WINED3DSTT_VOLUME: - shader_addline(buffer, "uniform sampler3D %csampler%lu;\n", prefix, i); + shader_addline(buffer, "uniform sampler3D %csampler%u;\n", prefix, i); break; default: - shader_addline(buffer, "uniform unsupported_sampler %csampler%lu;\n", prefix, i); + shader_addline(buffer, "uniform unsupported_sampler %csampler%u;\n", prefix, i); FIXME("Unrecognized sampler type: %#x\n", stype); break; } @@ -601,7 +606,7 @@ void shader_generate_glsl_declarations( /* Declare texture coordinate temporaries and initialize them */ for (i = 0; i < This->baseShader.limits.texcoord; i++) { if (reg_maps->texcoord[i]) - shader_addline(buffer, "vec4 T%lu = gl_TexCoord[%lu];\n", i, i); + shader_addline(buffer, "vec4 T%u = gl_TexCoord[%u];\n", i, i); } /* Declare input register varyings. Only pixel shader, vertex shaders have that declared in the @@ -609,25 +614,25 @@ void shader_generate_glsl_declarations( */ if(pshader && This->baseShader.hex_version >= WINED3DVS_VERSION(3, 0)) { if(use_vs(device)) { - shader_addline(buffer, "varying vec4 IN[%lu];\n", GL_LIMITS(glsl_varyings) / 4); + shader_addline(buffer, "varying vec4 IN[%u];\n", GL_LIMITS(glsl_varyings) / 4); } else { /* TODO: Write a replacement shader for the fixed function vertex pipeline, so this isn't needed. * For fixed function vertex processing + 3.0 pixel shader we need a separate function in the * pixel shader that reads the fixed function color into the packed input registers. */ - shader_addline(buffer, "vec4 IN[%lu];\n", GL_LIMITS(glsl_varyings) / 4); + shader_addline(buffer, "vec4 IN[%u];\n", GL_LIMITS(glsl_varyings) / 4); } } /* Declare output register temporaries */ if(This->baseShader.limits.packed_output) { - shader_addline(buffer, "vec4 OUT[%lu];\n", This->baseShader.limits.packed_output); + shader_addline(buffer, "vec4 OUT[%u];\n", This->baseShader.limits.packed_output); } /* Declare temporary variables */ for(i = 0; i < This->baseShader.limits.temporary; i++) { if (reg_maps->temporary[i]) - shader_addline(buffer, "vec4 R%lu;\n", i); + shader_addline(buffer, "vec4 R%u;\n", i); } /* Declare attributes */ @@ -1081,7 +1086,7 @@ static inline const char* shader_get_comp_op( } } -static void shader_glsl_get_sample_function(DWORD sampler_type, BOOL projected, glsl_sample_function_t *sample_function) { +static void shader_glsl_get_sample_function(DWORD sampler_type, BOOL projected, BOOL texrect, glsl_sample_function_t *sample_function) { /* Note that there's no such thing as a projected cube texture. */ switch(sampler_type) { case WINED3DSTT_1D: @@ -1089,7 +1094,11 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, BOOL projected, sample_function->coord_mask = WINED3DSP_WRITEMASK_0; break; case WINED3DSTT_2D: - sample_function->name = projected ? "texture2DProj" : "texture2D"; + if(texrect) { + sample_function->name = projected ? "texture2DRectProj" : "texture2DRect"; + } else { + sample_function->name = projected ? "texture2DProj" : "texture2D"; + } sample_function->coord_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1; break; case WINED3DSTT_CUBE: @@ -2009,12 +2018,12 @@ void shader_glsl_label(SHADER_OPCODE_ARG* arg) { DWORD snum = (arg->src[0]) & WINED3DSP_REGNUM_MASK; shader_addline(arg->buffer, "}\n"); - shader_addline(arg->buffer, "void subroutine%lu () {\n", snum); + shader_addline(arg->buffer, "void subroutine%u () {\n", snum); } void shader_glsl_call(SHADER_OPCODE_ARG* arg) { DWORD snum = (arg->src[0]) & WINED3DSP_REGNUM_MASK; - shader_addline(arg->buffer, "subroutine%lu();\n", snum); + shader_addline(arg->buffer, "subroutine%u();\n", snum); } void shader_glsl_callnz(SHADER_OPCODE_ARG* arg) { @@ -2022,7 +2031,7 @@ void shader_glsl_callnz(SHADER_OPCODE_ARG* arg) { DWORD snum = (arg->src[0]) & WINED3DSP_REGNUM_MASK; shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], WINED3DSP_WRITEMASK_0, &src1_param); - shader_addline(arg->buffer, "if (%s) subroutine%lu();\n", src1_param.param_str, snum); + shader_addline(arg->buffer, "if (%s) subroutine%u();\n", src1_param.param_str, snum); } /********************************************* @@ -2036,7 +2045,7 @@ void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) { glsl_sample_function_t sample_function; DWORD sampler_type; DWORD sampler_idx; - BOOL projected; + BOOL projected, texrect = FALSE; DWORD mask = 0; /* All versions have a destination register */ @@ -2086,8 +2095,13 @@ void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) { } } + if(deviceImpl->stateBlock->textures[sampler_idx] && + IWineD3DBaseTexture_GetTextureDimensions(deviceImpl->stateBlock->textures[sampler_idx]) == GL_TEXTURE_RECTANGLE_ARB) { + texrect = TRUE; + } + sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK; - shader_glsl_get_sample_function(sampler_type, projected, &sample_function); + shader_glsl_get_sample_function(sampler_type, projected, texrect, &sample_function); mask |= sample_function.coord_mask; if (hex_version < WINED3DPS_VERSION(2,0)) { @@ -2122,19 +2136,24 @@ void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) { void shader_glsl_texldl(SHADER_OPCODE_ARG* arg) { IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*)arg->shader; + IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; glsl_sample_function_t sample_function; glsl_src_param_t coord_param, lod_param; char dst_swizzle[6]; DWORD sampler_type; DWORD sampler_idx; + BOOL texrect = FALSE; shader_glsl_append_dst(arg->buffer, arg); shader_glsl_get_swizzle(arg->src[1], FALSE, arg->dst, dst_swizzle); sampler_idx = arg->src[1] & WINED3DSP_REGNUM_MASK; sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK; - shader_glsl_get_sample_function(sampler_type, FALSE, &sample_function); - shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], sample_function.coord_mask, &coord_param); + if(deviceImpl->stateBlock->textures[sampler_idx] && + IWineD3DBaseTexture_GetTextureDimensions(deviceImpl->stateBlock->textures[sampler_idx]) == GL_TEXTURE_RECTANGLE_ARB) { + texrect = TRUE; + } + shader_glsl_get_sample_function(sampler_type, FALSE, texrect, &sample_function); shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], sample_function.coord_mask, &coord_param); shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], WINED3DSP_WRITEMASK_3, &lod_param); @@ -2216,9 +2235,11 @@ void pshader_glsl_texdp3tex(SHADER_OPCODE_ARG* arg) { shader_glsl_get_write_mask(arg->dst, dst_mask); /* Do I have to take care about the projected bit? I don't think so, since the dp3 returns only one - * scalar, and projected sampling would require 4 + * scalar, and projected sampling would require 4. + * + * It is a dependent read - not valid with conditional NP2 textures */ - shader_glsl_get_sample_function(sampler_type, FALSE, &sample_function); + shader_glsl_get_sample_function(sampler_type, FALSE, FALSE, &sample_function); switch(count_bits(sample_function.coord_mask)) { case 1: @@ -2273,7 +2294,7 @@ void pshader_glsl_texdepth(SHADER_OPCODE_ARG* arg) { * too is irrelevant, since if x = 0, any y value < 1.0 (and > 1.0 is not allowed) results in a result * >= 1.0 or < 0.0 */ - shader_addline(arg->buffer, "gl_FragDepth = clamp((%s.x / min(%s.y, 1.0)), 0.0, 1.0);\n", dst_param.reg_name, dst_param.reg_name, dst_param.reg_name); + shader_addline(arg->buffer, "gl_FragDepth = clamp((%s.x / min(%s.y, 1.0)), 0.0, 1.0);\n", dst_param.reg_name, dst_param.reg_name); } /** Process the WINED3DSIO_TEXM3X2DEPTH instruction in GLSL: @@ -2354,7 +2375,8 @@ void pshader_glsl_texm3x3tex(SHADER_OPCODE_ARG* arg) { shader_glsl_append_dst(arg->buffer, arg); shader_glsl_get_write_mask(arg->dst, dst_mask); - shader_glsl_get_sample_function(sampler_type, FALSE, &sample_function); + /* Dependent read, not valid with conditional NP2 */ + shader_glsl_get_sample_function(sampler_type, FALSE, FALSE, &sample_function); /* Sample the texture using the calculated coordinates */ shader_addline(arg->buffer, "%s(Psampler%u, tmp0.xyz)%s);\n", sample_function.name, reg, dst_mask); @@ -2406,7 +2428,8 @@ void pshader_glsl_texm3x3spec(SHADER_OPCODE_ARG* arg) { shader_glsl_append_dst(buffer, arg); shader_glsl_get_write_mask(arg->dst, dst_mask); - shader_glsl_get_sample_function(stype, FALSE, &sample_function); + /* Dependent read, not valid with conditional NP2 */ + shader_glsl_get_sample_function(stype, FALSE, FALSE, &sample_function); /* Sample the texture */ shader_addline(buffer, "%s(Psampler%u, tmp0.xyz)%s);\n", sample_function.name, reg, dst_mask); @@ -2440,7 +2463,8 @@ void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg) { shader_glsl_append_dst(buffer, arg); shader_glsl_get_write_mask(arg->dst, dst_mask); - shader_glsl_get_sample_function(sampler_type, FALSE, &sample_function); + /* Dependent read, not valid with conditional NP2 */ + shader_glsl_get_sample_function(sampler_type, FALSE, FALSE, &sample_function); /* Sample the texture using the calculated coordinates */ shader_addline(buffer, "%s(Psampler%u, tmp0.xyz)%s);\n", sample_function.name, reg, dst_mask); @@ -2468,7 +2492,8 @@ void pshader_glsl_texbem(SHADER_OPCODE_ARG* arg) { flags = deviceImpl->stateBlock->textureState[sampler_idx][WINED3DTSS_TEXTURETRANSFORMFLAGS]; sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK; - shader_glsl_get_sample_function(sampler_type, FALSE, &sample_function); + /* Dependent read, not valid with conditional NP2 */ + shader_glsl_get_sample_function(sampler_type, FALSE, FALSE, &sample_function); mask = sample_function.coord_mask; shader_glsl_get_write_mask(arg->dst, dst_swizzle); @@ -2557,7 +2582,8 @@ void pshader_glsl_texreg2rgb(SHADER_OPCODE_ARG* arg) { shader_glsl_append_dst(arg->buffer, arg); shader_glsl_get_write_mask(arg->dst, dst_mask); - shader_glsl_get_sample_function(sampler_type, FALSE, &sample_function); + /* Dependent read, not valid with conditional NP2 */ + shader_glsl_get_sample_function(sampler_type, FALSE, FALSE, &sample_function); shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], sample_function.coord_mask, &src0_param); shader_addline(arg->buffer, "%s(Psampler%u, %s)%s);\n", sample_function.name, sampler_idx, src0_param.param_str, dst_mask); @@ -2901,7 +2927,7 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs semantics_in = ps->semantics_in; /* This one is tricky: a 3.0 pixel shader reads from a 3.0 vertex shader */ - shader_addline(&buffer, "varying vec4 IN[%lu];\n", GL_LIMITS(glsl_varyings) / 4); + shader_addline(&buffer, "varying vec4 IN[%u];\n", GL_LIMITS(glsl_varyings) / 4); shader_addline(&buffer, "void order_ps_input(in vec4 OUT[%u]) {\n", MAX_REG_OUTPUT); /* First, sort out position and point size. Those are not passed to the pixel shader */ @@ -2935,7 +2961,7 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs } else if(ps_major >= 3 && vs_major < 3) { semantics_in = ps->semantics_in; - shader_addline(&buffer, "varying vec4 IN[%lu];\n", GL_LIMITS(glsl_varyings) / 4); + shader_addline(&buffer, "varying vec4 IN[%u];\n", GL_LIMITS(glsl_varyings) / 4); shader_addline(&buffer, "void order_ps_input() {\n"); /* The vertex shader wrote to the builtin varyings. There is no need to figure out position and * point size, but we depend on the optimizers kindness to find out that the pixel shader doesn't @@ -3005,6 +3031,15 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use int max_attribs = 16; /* TODO: Will this always be the case? It is at the moment... */ char tmp_name[10]; + reorder_shader_id = generate_param_reorder_function(vshader, pshader, gl_info); + TRACE("Attaching GLSL shader object %u to program %u\n", reorder_shader_id, programId); + GL_EXTCALL(glAttachObjectARB(programId, reorder_shader_id)); + checkGLcall("glAttachObjectARB"); + /* Flag the reorder function for deletion, then it will be freed automatically when the program + * is destroyed + */ + GL_EXTCALL(glDeleteObjectARB(reorder_shader_id)); + TRACE("Attaching GLSL shader object %u to program %u\n", vshader_id, programId); GL_EXTCALL(glAttachObjectARB(programId, vshader_id)); checkGLcall("glAttachObjectARB"); @@ -3027,15 +3062,6 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use checkGLcall("glBindAttribLocationARB"); list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry); - - reorder_shader_id = generate_param_reorder_function(vshader, pshader, gl_info); - TRACE("Attaching GLSL shader object %u to program %u\n", reorder_shader_id, programId); - GL_EXTCALL(glAttachObjectARB(programId, reorder_shader_id)); - checkGLcall("glAttachObjectARB"); - /* Flag the reorder function for deletion, then it will be freed automatically when the program - * is destroyed - */ - GL_EXTCALL(glDeleteObjectARB(reorder_shader_id)); } /* Attach GLSL pshader */ diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c index b9fbd75482d..7981501f786 100644 --- a/dlls/wined3d/pixelshader.c +++ b/dlls/wined3d/pixelshader.c @@ -286,6 +286,7 @@ static inline VOID IWineD3DPixelShaderImpl_GenerateShader( IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; SHADER_BUFFER buffer; + const char *fragcolor; #if 0 /* FIXME: Use the buffer that is held by the device, this is ok since fixups will be skipped for software shaders it also requires entering a critical section but cuts down the runtime footprint of wined3d and any memory fragmentation that may occur... */ @@ -311,6 +312,12 @@ static inline VOID IWineD3DPixelShaderImpl_GenerateShader( if (GL_SUPPORT(ARB_DRAW_BUFFERS)) { shader_addline(&buffer, "#extension GL_ARB_draw_buffers : enable\n"); } + if (GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + /* The spec says that it doesn't have to be explicitly enabled, but the nvidia + * drivers write a warning if we don't do so + */ + shader_addline(&buffer, "#extension GL_ARB_texture_rectangle : enable\n"); + } /* Base Declarations */ shader_generate_glsl_declarations( (IWineD3DBaseShader*) This, reg_maps, &buffer, &GLINFO_LOCATION); @@ -341,27 +348,12 @@ static inline VOID IWineD3DPixelShaderImpl_GenerateShader( shader_addline(&buffer, "gl_FragColor = R0;\n"); } - /* Pixel shader < 3.0 do not replace the fog stage. - * This implements linear fog computation and blending. - * TODO: non linear fog - * NOTE: gl_Fog.start and gl_Fog.end don't hold fog start s and end e but - * -1/(e-s) and e/(e-s) respectively. - */ - if(This->baseShader.hex_version < WINED3DPS_VERSION(3,0)) { - shader_addline(&buffer, "float Fog = clamp(gl_FogFragCoord * gl_Fog.start + gl_Fog.end, 0.0, 1.0);\n"); - if(GL_SUPPORT(ARB_DRAW_BUFFERS)) - shader_addline(&buffer, "gl_FragData[0].xyz = mix(gl_Fog.color.xyz, gl_FragData[0].xyz, Fog);\n"); - else - shader_addline(&buffer, "gl_FragColor.xyz = mix(gl_Fog.color.xyz, gl_FragColor.xyz, Fog);\n"); + if(GL_SUPPORT(ARB_DRAW_BUFFERS)) { + fragcolor = "gl_FragData[0]"; + } else { + fragcolor = "gl_FragColor"; } if(This->srgb_enabled) { - const char *fragcolor; - - if(GL_SUPPORT(ARB_DRAW_BUFFERS)) { - fragcolor = "gl_FragData[0]"; - } else { - fragcolor = "gl_FragColor"; - } shader_addline(&buffer, "tmp0.xyz = pow(%s.xyz, vec3(%f, %f, %f)) * vec3(%f, %f, %f) - vec3(%f, %f, %f);\n", fragcolor, srgb_pow, srgb_pow, srgb_pow, srgb_mul_high, srgb_mul_high, srgb_mul_high, srgb_sub_high, srgb_sub_high, srgb_sub_high); @@ -371,6 +363,16 @@ static inline VOID IWineD3DPixelShaderImpl_GenerateShader( shader_addline(&buffer, "%s.z = %s.z < srgb_comparison.z ? tmp1.z : tmp0.z;\n", fragcolor, fragcolor); shader_addline(&buffer, "%s = clamp(%s, 0.0, 1.0);\n", fragcolor, fragcolor); } + /* Pixel shader < 3.0 do not replace the fog stage. + * This implements linear fog computation and blending. + * TODO: non linear fog + * NOTE: gl_Fog.start and gl_Fog.end don't hold fog start s and end e but + * -1/(e-s) and e/(e-s) respectively. + */ + if(This->baseShader.hex_version < WINED3DPS_VERSION(3,0)) { + shader_addline(&buffer, "float Fog = clamp(gl_FogFragCoord * gl_Fog.start + gl_Fog.end, 0.0, 1.0);\n"); + shader_addline(&buffer, "%s.xyz = mix(gl_Fog.color.xyz, %s.xyz, Fog);\n", fragcolor, fragcolor); + } shader_addline(&buffer, "}\n"); @@ -413,40 +415,34 @@ static inline VOID IWineD3DPixelShaderImpl_GenerateShader( */ shader_addline(&buffer, "MAD_SAT TMP_FOG, fragment.fogcoord, state.fog.params.y, state.fog.params.z;\n"); + if (This->baseShader.hex_version < WINED3DPS_VERSION(2,0)) { + fragcolor = "R0"; + } else { + fragcolor = "TMP_COLOR"; + } if(This->srgb_enabled) { - if (This->baseShader.hex_version < WINED3DPS_VERSION(2,0)) { - shader_addline(&buffer, "LRP TMP_COLOR.rgb, TMP_FOG.x, R0, state.fog.color;\n"); - shader_addline(&buffer, "MOV result.color.a, R0.a;\n"); - } else { - shader_addline(&buffer, "LRP TMP_COLOR.rgb, TMP_FOG.x, TMP_COLOR, state.fog.color;\n"); - shader_addline(&buffer, "MOV result.color.a, TMP_COLOR.a;\n"); - } /* Perform sRGB write correction. See GLX_EXT_framebuffer_sRGB */ /* Calculate the > 0.0031308 case */ - shader_addline(&buffer, "POW TMP.x, TMP_COLOR.x, srgb_pow.x;\n"); - shader_addline(&buffer, "POW TMP.y, TMP_COLOR.y, srgb_pow.y;\n"); - shader_addline(&buffer, "POW TMP.z, TMP_COLOR.z, srgb_pow.z;\n"); + shader_addline(&buffer, "POW TMP.x, %s.x, srgb_pow.x;\n", fragcolor); + shader_addline(&buffer, "POW TMP.y, %s.y, srgb_pow.y;\n", fragcolor); + shader_addline(&buffer, "POW TMP.z, %s.z, srgb_pow.z;\n", fragcolor); shader_addline(&buffer, "MUL TMP, TMP, srgb_mul_hi;\n"); shader_addline(&buffer, "SUB TMP, TMP, srgb_sub_hi;\n"); /* Calculate the < case */ - shader_addline(&buffer, "MUL TMP2, srgb_mul_low, TMP_COLOR;\n"); + shader_addline(&buffer, "MUL TMP2, srgb_mul_low, %s;\n", fragcolor); /* Get 1.0 / 0.0 masks for > 0.0031308 and < 0.0031308 */ - shader_addline(&buffer, "SLT TA, srgb_comparison, TMP_COLOR;\n"); - shader_addline(&buffer, "SGE TB, srgb_comparison, TMP_COLOR;\n"); + shader_addline(&buffer, "SLT TA, srgb_comparison, %s;\n", fragcolor); + shader_addline(&buffer, "SGE TB, srgb_comparison, %s;\n", fragcolor); /* Store the components > 0.0031308 in the destination */ - shader_addline(&buffer, "MUL TMP_COLOR, TMP, TA;\n"); + shader_addline(&buffer, "MUL %s, TMP, TA;\n", fragcolor); /* Add the components that are < 0.0031308 */ - shader_addline(&buffer, "MAD result.color.xyz, TMP2, TB, TMP_COLOR;\n"); + shader_addline(&buffer, "MAD result.color.xyz, TMP2, TB, %s;\n", fragcolor); /* [0.0;1.0] clamping. Not needed, this is done implicitly */ - } else { - if (This->baseShader.hex_version < WINED3DPS_VERSION(2,0)) { - shader_addline(&buffer, "LRP result.color.rgb, TMP_FOG.x, R0, state.fog.color;\n"); - shader_addline(&buffer, "MOV result.color.a, R0.a;\n"); - } else { - shader_addline(&buffer, "LRP result.color.rgb, TMP_FOG.x, TMP_COLOR, state.fog.color;\n"); - shader_addline(&buffer, "MOV result.color.a, TMP_COLOR.a;\n"); - } + } + if (This->baseShader.hex_version < WINED3DPS_VERSION(3,0)) { + shader_addline(&buffer, "LRP result.color.rgb, TMP_FOG.x, %s, state.fog.color;\n", fragcolor); + shader_addline(&buffer, "MOV result.color.a, %s.a;\n", fragcolor); } shader_addline(&buffer, "END\n"); diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index d5bf9924daf..787f3ead71b 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -354,7 +354,9 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha * in case it finds some texture+colorkeyenable combination which needs extra care. */ - if(stateblock->textures[0] && stateblock->textureDimensions[0] == GL_TEXTURE_2D) { + if(stateblock->textures[0] && ( + stateblock->textureDimensions[0] == GL_TEXTURE_2D || + stateblock->textureDimensions[0] == GL_TEXTURE_RECTANGLE_ARB)) { surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)stateblock->textures[0])->surfaces[0]; if(surf->CKeyFlags & WINEDDSD_CKSRCBLT) { @@ -1688,6 +1690,7 @@ static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, case GL_TEXTURE_2D: if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D); + checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)"); } else { glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); @@ -1695,18 +1698,44 @@ static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } + if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } glEnable(GL_TEXTURE_2D); checkGLcall("glEnable(GL_TEXTURE_2D)"); } break; + case GL_TEXTURE_RECTANGLE_ARB: + if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { + glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)"); + } else { + glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable(GL_TEXTURE_2D)"); + glDisable(GL_TEXTURE_3D); + checkGLcall("glDisable(GL_TEXTURE_3D)"); + if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + glDisable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + } + glEnable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)"); + } + break; case GL_TEXTURE_3D: if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D); + checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D)"); } else { if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } + if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); glEnable(GL_TEXTURE_3D); @@ -1716,11 +1745,16 @@ static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, case GL_TEXTURE_CUBE_MAP_ARB: if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB)"); } else { glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); + if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } glEnable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)"); } @@ -1729,6 +1763,7 @@ static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, } else { if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE); + checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE)"); } else { glEnable(GL_TEXTURE_2D); checkGLcall("glEnable(GL_TEXTURE_2D)"); @@ -1738,6 +1773,10 @@ static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } + if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } /* Binding textures is done by samplers. A dummy texture will be bound */ } } @@ -1792,6 +1831,10 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } + if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); + } if(GL_SUPPORT(NV_TEXTURE_SHADER2) && mapped_stage < GL_LIMITS(textures)) { glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE); } @@ -1869,7 +1912,8 @@ static void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D arg0 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG0]; if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && stage == 0 && - stateblock->textures[0] && stateblock->textureDimensions[0] == GL_TEXTURE_2D) { + stateblock->textures[0] && + (stateblock->textureDimensions[0] == GL_TEXTURE_2D || stateblock->textureDimensions[0] == GL_TEXTURE_RECTANGLE_ARB)) { IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0]; if(surf->CKeyFlags & WINEDDSD_CKSRCBLT && @@ -2298,7 +2342,8 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont * scaling is reapplied or removed, the texture matrix has to be reapplied */ if(!GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) && sampler < MAX_TEXTURES) { - if(stateblock->textureDimensions[sampler] == GL_TEXTURE_2D) { + if(stateblock->textureDimensions[sampler] == GL_TEXTURE_2D || + stateblock->textureDimensions[sampler] == GL_TEXTURE_RECTANGLE_ARB) { if(((IWineD3DTextureImpl *) stateblock->textures[sampler])->baseTexture.pow2Matrix[0] != 1.0 || ((IWineD3DTextureImpl *) stateblock->textures[sampler])->baseTexture.pow2Matrix[5] != 1.0 ) { texIsPow2 = TRUE; @@ -2349,7 +2394,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont state_alpha(WINED3DRS_COLORKEYENABLE, stateblock, context); } } - } else if(sampler < GL_LIMITS(texture_stages)) { + } else if(mapped_stage < GL_LIMITS(textures)) { if(sampler < stateblock->lowest_disabled_stage) { /* TODO: What should I do with pixel shaders here ??? */ if(!isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) { @@ -3373,6 +3418,7 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, W */ if (useVertexShaderFunction) { device->posFixup[1] = device->render_offscreen ? -1.0 : 1.0; + device->posFixup[3] = -device->posFixup[1] / stateblock->viewport.Height; } } @@ -3496,7 +3542,7 @@ static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon checkGLcall("glViewport"); stateblock->wineD3DDevice->posFixup[2] = 1.0 / stateblock->viewport.Width; - stateblock->wineD3DDevice->posFixup[3] = -1.0 / stateblock->viewport.Height; + stateblock->wineD3DDevice->posFixup[3] = -stateblock->wineD3DDevice->posFixup[1] / stateblock->viewport.Height; if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) { transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context); } diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index df617dd1f45..0ff1bc7cf8e 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -964,9 +964,6 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This) { IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain); } - glDisable(GL_TEXTURE_2D); - vcheckGLcall("glDisable(GL_TEXTURE_2D)"); - glFlush(); vcheckGLcall("glFlush"); glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store); @@ -1005,64 +1002,23 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This) { case WINED3DFMT_R5G6B5: case WINED3DFMT_A1R5G5B5: case WINED3DFMT_R8G8B8: - type = This->glDescription.glType; - fmt = This->glDescription.glFormat; - mem = This->resource.allocatedMemory; - bpp = This->bytesPerPixel; - break; - case WINED3DFMT_X4R4G4B4: - { - int size; - unsigned short *data; - data = (unsigned short *)This->resource.allocatedMemory; - size = (This->lockedRect.bottom - This->lockedRect.top) * (This->lockedRect.right - This->lockedRect.left); - while(size > 0) { - *data |= 0xF000; - data++; - size--; - } - type = This->glDescription.glType; - fmt = This->glDescription.glFormat; - mem = This->resource.allocatedMemory; - bpp = This->bytesPerPixel; - } - break; - case WINED3DFMT_X1R5G5B5: - { - int size; - unsigned short *data; - data = (unsigned short *)This->resource.allocatedMemory; - size = (This->lockedRect.bottom - This->lockedRect.top) * (This->lockedRect.right - This->lockedRect.left); - while(size > 0) { - *data |= 0x8000; - data++; - size--; - } type = This->glDescription.glType; fmt = This->glDescription.glFormat; mem = This->resource.allocatedMemory; bpp = This->bytesPerPixel; - } - break; + break; + /* In the past times we used to set the X channel of X8R8G8B8 and the above formats to + * 1.0 because it happened to fix the intro movie in Pirates. However, this seems wrong. + * If the game uses an X8R8G8B8 back buffer the GL alpha channel should not make any differences, + * and the bug must be somewhere else. If we really have to set the alpha channel to 1.0 in + * this case do it by clearing it after the draw instead of fixing it up in the CPU. Blending + * is disabled via CTXUSAGE_BLIT context setup, so in the glDrawPixels call it does not + * have any effects + */ case WINED3DFMT_X8R8G8B8: - { - /* make sure the X byte is set to alpha on, since it - could be any random value. This fixes the intro movie in Pirates! */ - int size; - unsigned int *data; - data = (unsigned int *)This->resource.allocatedMemory; - size = (This->lockedRect.bottom - This->lockedRect.top) * (This->lockedRect.right - This->lockedRect.left); - while(size > 0) { - *data |= 0xFF000000; - data++; - size--; - } - } - /* Fall through */ - case WINED3DFMT_A8R8G8B8: { glPixelStorei(GL_PACK_SWAP_BYTES, TRUE); @@ -1153,12 +1109,6 @@ cleanup: vcheckGLcall("glPixelStorei GL_PACK_SWAP_BYTES"); } - /* Blitting environment requires that 2D texturing is enabled. It was turned off before, - * turn it on again - */ - glEnable(GL_TEXTURE_2D); - checkGLcall("glEnable(GL_TEXTURE_2D)"); - if(memory_allocated) HeapFree(GetProcessHeap(), 0, mem); if(!swapchain) { @@ -1238,8 +1188,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) { glGenTextures(1, &This->glDescription.textureName); checkGLcall("glGenTextures"); } - glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName); - checkGLcall("glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName);"); + glBindTexture(This->glDescription.target, This->glDescription.textureName); + checkGLcall("glBindTexture(This->glDescription.target, This->glDescription.textureName)"); LEAVE_GL(); IWineD3DSurface_LoadLocation(iface, SFLAG_INTEXTURE, NULL /* partial texture loading not supported yet */); /* drop through */ @@ -1414,11 +1364,18 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ /* Default values: From the surface */ *format = glDesc->glFormat; - *internal = srgb_mode?glDesc->glGammaInternal:glDesc->glInternal; *type = glDesc->glType; *convert = NO_CONVERSION; *target_bpp = This->bytesPerPixel; + if(srgb_mode) { + *internal = glDesc->glGammaInternal; + } else if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) { + *internal = glDesc->rtInternal; + } else { + *internal = glDesc->glInternal; + } + /* Ok, now look if we have to do any conversion */ switch(This->resource.format) { case WINED3DFMT_P8: @@ -2022,7 +1979,7 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve if(GL_SUPPORT(EXT_PALETTED_TEXTURE)) { TRACE("Using GL_EXT_PALETTED_TEXTURE for 8-bit paletted texture support\n"); - GL_EXTCALL(glColorTableEXT(GL_TEXTURE_2D,GL_RGBA,256,GL_RGBA,GL_UNSIGNED_BYTE, table)); + GL_EXTCALL(glColorTableEXT(This->glDescription.target,GL_RGBA,256,GL_RGBA,GL_UNSIGNED_BYTE, table)); } else { @@ -2528,8 +2485,12 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D ENTER_GL(); IWineD3DSurface_PreLoad((IWineD3DSurface *) This); + /* TODO: Do we need GL_TEXTURE_2D enabled fpr copyteximage? */ + glEnable(This->glDescription.target); + checkGLcall("glEnable(This->glDescription.target)"); + /* Bind the target texture */ - glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName); + glBindTexture(This->glDescription.target, This->glDescription.textureName); checkGLcall("glBindTexture"); if(!swapchain) { glReadBuffer(myDevice->offscreenBuffer); @@ -2593,8 +2554,12 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D } } } - vcheckGLcall("glCopyTexSubImage2D"); + + /* Leave the opengl state valid for blitting */ + glDisable(This->glDescription.target); + checkGLcall("glDisable(This->glDescription.target)"); + LEAVE_GL(); } @@ -2607,11 +2572,13 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine UINT fbwidth = Src->currentDesc.Width; UINT fbheight = Src->currentDesc.Height; GLenum drawBuffer = GL_BACK; + GLenum texture_target; TRACE("Using hwstretch blit\n"); /* Activate the Proper context for reading from the source surface, set it up for blitting */ ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT); ENTER_GL(); + IWineD3DSurface_PreLoad((IWineD3DSurface *) This); /* Try to use an aux buffer for drawing the rectangle. This way it doesn't need restoring. @@ -2630,6 +2597,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine checkGLcall("glGenTextures\n"); glBindTexture(GL_TEXTURE_2D, backup); checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)"); + texture_target = GL_TEXTURE_2D; } else { /* Backup the back buffer and copy the source buffer into a texture to draw an upside down stretched quad. If * we are reading from the back buffer, the backup can be used as source texture @@ -2638,8 +2606,11 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine /* Get it a description */ IWineD3DSurface_PreLoad(SrcSurface); } - glBindTexture(GL_TEXTURE_2D, Src->glDescription.textureName); - checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)"); + texture_target = Src->glDescription.target; + glBindTexture(texture_target, Src->glDescription.textureName); + checkGLcall("glBindTexture(texture_target, Src->glDescription.textureName)"); + glEnable(texture_target); + checkGLcall("glEnable(texture_target)"); /* For now invalidate the texture copy of the back buffer. Drawable and sysmem copy are untouched */ Src->Flags &= ~SFLAG_INTEXTURE; @@ -2649,7 +2620,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine checkGLcall("glReadBuffer(GL_BACK)"); /* TODO: Only back up the part that will be overwritten */ - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, + glCopyTexSubImage2D(texture_target, 0, 0, 0 /* read offsets */, 0, 0, fbwidth, @@ -2658,10 +2629,10 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine checkGLcall("glCopyTexSubImage2D"); /* No issue with overriding these - the sampler is dirty due to blit usage */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + glTexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, stateLookup[WINELOOKUP_MAGFILTER][Filter - minLookup[WINELOOKUP_MAGFILTER]]); checkGLcall("glTexParameteri"); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, minMipLookup[Filter][WINED3DTEXF_NONE]); checkGLcall("glTexParameteri"); @@ -2695,6 +2666,12 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine glReadBuffer(GL_BACK); checkGLcall("glReadBuffer(GL_BACK)"); + + if(texture_target != GL_TEXTURE_2D) { + glDisable(texture_target); + glEnable(GL_TEXTURE_2D); + texture_target = GL_TEXTURE_2D; + } } checkGLcall("glEnd and previous"); @@ -2710,8 +2687,8 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine } /* draw the source texture stretched and upside down. The correct surface is bound already */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP); glDrawBuffer(drawBuffer); glReadBuffer(drawBuffer); @@ -2735,21 +2712,42 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine glEnd(); checkGLcall("glEnd and previous"); + if(texture_target != This->glDescription.target) { + glDisable(texture_target); + glEnable(This->glDescription.target); + texture_target = This->glDescription.target; + } + /* Now read the stretched and upside down image into the destination texture */ - glBindTexture(This->glDescription.target, This->glDescription.textureName); + glBindTexture(texture_target, This->glDescription.textureName); checkGLcall("glBindTexture"); - glCopyTexSubImage2D(This->glDescription.target, + glCopyTexSubImage2D(texture_target, 0, drect->x1, drect->y1, /* xoffset, yoffset */ 0, 0, /* We blitted the image to the origin */ drect->x2 - drect->x1, drect->y2 - drect->y1); checkGLcall("glCopyTexSubImage2D"); - /* Write the back buffer backup back */ - glBindTexture(GL_TEXTURE_2D, backup ? backup : Src->glDescription.textureName); - checkGLcall("glBindTexture(GL_TEXTURE_2D, Src->glDescription.textureName)"); - if(drawBuffer == GL_BACK) { + /* Write the back buffer backup back */ + if(backup) { + if(texture_target != GL_TEXTURE_2D) { + glDisable(texture_target); + glEnable(GL_TEXTURE_2D); + texture_target = GL_TEXTURE_2D; + } + glBindTexture(GL_TEXTURE_2D, backup); + checkGLcall("glBindTexture(GL_TEXTURE_2D, backup)"); + } else { + if(texture_target != Src->glDescription.target) { + glDisable(texture_target); + glEnable(Src->glDescription.target); + texture_target = Src->glDescription.target; + } + glBindTexture(Src->glDescription.target, Src->glDescription.textureName); + checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)"); + } + glBegin(GL_QUADS); /* top left */ glTexCoord2f(0.0, (float) fbheight / (float) Src->pow2Height); @@ -2771,6 +2769,8 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine /* Restore the old draw buffer */ glDrawBuffer(GL_BACK); } + glDisable(texture_target); + checkGLcall("glDisable(texture_target)"); /* Cleanup */ if(src != Src->glDescription.textureName && src != backup) { @@ -2781,6 +2781,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine glDeleteTextures(1, &backup); checkGLcall("glDeleteTextures(1, &backup)"); } + LEAVE_GL(); } @@ -3087,6 +3088,9 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT * ActivateContext(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT); ENTER_GL(); + glEnable(Src->glDescription.target); + checkGLcall("glEnable(Src->glDescription.target)"); + if(!dstSwapchain) { TRACE("Drawing to offscreen buffer\n"); glDrawBuffer(myDevice->offscreenBuffer); @@ -3099,18 +3103,18 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT * } /* Bind the texture */ - glBindTexture(GL_TEXTURE_2D, Src->glDescription.textureName); + glBindTexture(Src->glDescription.target, Src->glDescription.textureName); checkGLcall("glBindTexture"); /* Filtering for StretchRect */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + glTexParameteri(Src->glDescription.target, GL_TEXTURE_MAG_FILTER, stateLookup[WINELOOKUP_MAGFILTER][Filter - minLookup[WINELOOKUP_MAGFILTER]]); checkGLcall("glTexParameteri"); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER, minMipLookup[Filter][WINED3DTEXF_NONE]); checkGLcall("glTexParameteri"); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); checkGLcall("glTexEnvi"); @@ -3159,9 +3163,11 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT * if(dstSwapchain && (dstSwapchain->num_contexts >= 2)) glFlush(); - /* Unbind the texture */ - glBindTexture(GL_TEXTURE_2D, 0); - checkGLcall("glEnable glBindTexture"); + glBindTexture(Src->glDescription.target, 0); + checkGLcall("glBindTexture(Src->glDescription.target, 0)"); + /* Leave the opengl state valid for blitting */ + glDisable(Src->glDescription.target); + checkGLcall("glDisable(Src->glDescription.target)"); /* The draw buffer should only need to be restored if we were drawing to the front buffer, and there is a back buffer. * otherwise the context manager should choose between GL_BACK / offscreenDrawBuffer @@ -3458,6 +3464,14 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) { This->glRect.right = 0; This->glRect.bottom = 0; } else { + /* Check this after the oversize check - do not make an oversized surface a texture_rectangle one */ + if(This->Flags & SFLAG_NONPOW2 && GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + This->glDescription.target = GL_TEXTURE_RECTANGLE_ARB; + This->pow2Width = This->currentDesc.Width; + This->pow2Height = This->currentDesc.Height; + This->Flags &= ~SFLAG_NONPOW2; + } + /* No oversize, gl rect is the full texture size */ This->Flags &= ~SFLAG_OVERSIZE; This->glRect.left = 0; @@ -3510,6 +3524,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT struct coords coords[4]; RECT rect; IWineD3DSwapChain *swapchain = NULL; + IWineD3DBaseTexture *texture = NULL; HRESULT hr; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; @@ -3525,7 +3540,35 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT ActivateContext(device, device->render_targets[0], CTXUSAGE_BLIT); ENTER_GL(); - if(This->glDescription.target == GL_TEXTURE_2D) { + if(This->glDescription.target == GL_TEXTURE_RECTANGLE_ARB) { + glEnable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)"); + glBindTexture(GL_TEXTURE_RECTANGLE_ARB, This->glDescription.textureName); + checkGLcall("GL_TEXTURE_RECTANGLE_ARB, This->glDescription.textureName)"); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + checkGLcall("glTexParameteri"); + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + checkGLcall("glTexParameteri"); + + coords[0].x = rect.left; + coords[0].z = 0; + + coords[1].x = rect.left; + coords[1].z = 0; + + coords[2].x = rect.right; + coords[2].z = 0; + + coords[3].x = rect.right; + coords[3].z = 0; + + coords[0].y = rect.top; + coords[1].y = rect.bottom; + coords[2].y = rect.bottom; + coords[3].y = rect.top; + } else if(This->glDescription.target == GL_TEXTURE_2D) { + glEnable(GL_TEXTURE_2D); + checkGLcall("glEnable(GL_TEXTURE_2D)"); glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName); checkGLcall("GL_TEXTURE_2D, This->glDescription.textureName)"); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -3551,8 +3594,6 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT coords[3].y = rect.top / This->pow2Height; } else { /* Must be a cube map */ - glDisable(GL_TEXTURE_2D); - checkGLcall("glDisable(GL_TEXTURE_2D)"); glEnable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)"); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->glDescription.textureName); @@ -3627,10 +3668,11 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT checkGLcall("glEnd"); if(This->glDescription.target != GL_TEXTURE_2D) { - glEnable(GL_TEXTURE_2D); - checkGLcall("glEnable(GL_TEXTURE_2D)"); glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + } else { + glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable(GL_TEXTURE_2D)"); } hr = IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DSwapChain, (void **) &swapchain); @@ -3640,6 +3682,17 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT glFlush(); IWineD3DSwapChain_Release(swapchain); + } else { + /* We changed the filtering settings on the texture. Inform the container about this to get the filters + * reset properly next draw + */ + hr = IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DBaseTexture, (void **) &texture); + if(hr == WINED3D_OK && texture) { + ((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT; + ((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; + ((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE; + IWineD3DBaseTexture_Release(texture); + } } LEAVE_GL(); } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 1bdd6640647..c96d35dded9 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -207,7 +207,7 @@ static UINT WINAPI IWineD3DTextureImpl_GetTextureDimensions(IWineD3DTexture *ifa IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; TRACE("(%p)\n", This); - return GL_TEXTURE_2D; + return This->target; } static void WINAPI IWineD3DTextureImpl_ApplyStateChanges(IWineD3DTexture *iface, diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index e108fca3078..15b37eac160 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -107,7 +107,7 @@ static const StaticPixelFormatDesc formats[] = { typedef struct { WINED3DFORMAT fmt; - GLint glInternal, glGammaInternal, glFormat, glType; + GLint glInternal, glGammaInternal, rtInternal, glFormat, glType; } GlPixelFormatDescTemplate; /***************************************************************************** @@ -117,78 +117,78 @@ typedef struct { * table. */ static const GlPixelFormatDescTemplate gl_formats_template[] = { - /*{ internal ,srgbInternal ,format ,type }*/ - {WINED3DFMT_UNKNOWN ,0 ,0 ,0 ,0 }, + /*{ internal ,srgbInternal , rtInternal, format ,type }*/ + {WINED3DFMT_UNKNOWN ,0 ,0 , 0, 0 ,0 }, /* FourCC formats */ - {WINED3DFMT_UYVY ,0 ,0 ,0 ,0 }, - {WINED3DFMT_YUY2 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_DXT1 ,GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT ,GL_RGBA ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_DXT2 ,GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT ,GL_RGBA ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_DXT3 ,GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT ,GL_RGBA ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_DXT4 ,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT ,GL_RGBA ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_DXT5 ,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT ,GL_RGBA ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_MULTI2_ARGB8 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_G8R8_G8B8 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_R8G8_B8G8 ,0 ,0 ,0 ,0 }, + {WINED3DFMT_UYVY ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_YUY2 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_DXT1 ,GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT , 0, GL_RGBA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_DXT2 ,GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT , 0, GL_RGBA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_DXT3 ,GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT , 0, GL_RGBA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_DXT4 ,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT , 0, GL_RGBA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_DXT5 ,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT , 0, GL_RGBA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_MULTI2_ARGB8 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_G8R8_G8B8 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_R8G8_B8G8 ,0 ,0 , 0, 0 ,0 }, /* IEEE formats */ - {WINED3DFMT_R32F ,GL_RGB32F_ARB ,GL_RGB32F_ARB ,GL_RED ,GL_FLOAT }, - {WINED3DFMT_G32R32F ,0 ,0 ,0 ,0 }, - {WINED3DFMT_A32B32G32R32F ,GL_RGBA32F_ARB ,GL_RGBA32F_ARB ,GL_RGBA ,GL_FLOAT }, + {WINED3DFMT_R32F ,GL_RGB32F_ARB ,GL_RGB32F_ARB , 0, GL_RED ,GL_FLOAT }, + {WINED3DFMT_G32R32F ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_A32B32G32R32F ,GL_RGBA32F_ARB ,GL_RGBA32F_ARB , 0, GL_RGBA ,GL_FLOAT }, /* Hmm? */ - {WINED3DFMT_CxV8U8 ,0 ,0 ,0 ,0 }, + {WINED3DFMT_CxV8U8 ,0 ,0 , 0, 0 ,0 }, /* Float */ - {WINED3DFMT_R16F ,GL_RGB16F_ARB ,GL_RGB16F_ARB ,GL_RED ,GL_HALF_FLOAT_ARB }, - {WINED3DFMT_G16R16F ,0 ,0 ,0 ,0 }, - {WINED3DFMT_A16B16G16R16F ,GL_RGBA16F_ARB ,GL_RGBA16F_ARB ,GL_RGBA ,GL_HALF_FLOAT_ARB }, + {WINED3DFMT_R16F ,GL_RGB16F_ARB ,GL_RGB16F_ARB , 0, GL_RED ,GL_HALF_FLOAT_ARB }, + {WINED3DFMT_G16R16F ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_A16B16G16R16F ,GL_RGBA16F_ARB ,GL_RGBA16F_ARB , 0, GL_RGBA ,GL_HALF_FLOAT_ARB }, /* Palettized formats */ - {WINED3DFMT_A8P8, 0 ,0 ,0 ,0 }, - {WINED3DFMT_P8, GL_COLOR_INDEX8_EXT ,GL_COLOR_INDEX8_EXT ,GL_COLOR_INDEX ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_A8P8, 0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_P8, GL_COLOR_INDEX8_EXT ,GL_COLOR_INDEX8_EXT , 0, GL_COLOR_INDEX ,GL_UNSIGNED_BYTE }, /* Standard ARGB formats */ - {WINED3DFMT_R8G8B8 ,GL_RGB8 ,GL_RGB8 ,GL_BGR ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_A8R8G8B8 ,GL_RGBA8 ,GL_SRGB8_ALPHA8_EXT ,GL_BGRA ,GL_UNSIGNED_INT_8_8_8_8_REV }, - {WINED3DFMT_X8R8G8B8 ,GL_RGB8 ,GL_SRGB8_EXT ,GL_BGRA ,GL_UNSIGNED_INT_8_8_8_8_REV }, - {WINED3DFMT_R5G6B5 ,GL_RGB5 ,GL_RGB5 ,GL_RGB ,GL_UNSIGNED_SHORT_5_6_5 }, - {WINED3DFMT_X1R5G5B5 ,GL_RGB5 ,GL_RGB5_A1 ,GL_BGRA ,GL_UNSIGNED_SHORT_1_5_5_5_REV }, - {WINED3DFMT_A1R5G5B5 ,GL_RGB5_A1 ,GL_RGB5_A1 ,GL_BGRA ,GL_UNSIGNED_SHORT_1_5_5_5_REV }, - {WINED3DFMT_A4R4G4B4 ,GL_RGBA4 ,GL_SRGB8_ALPHA8_EXT ,GL_BGRA ,GL_UNSIGNED_SHORT_4_4_4_4_REV }, - {WINED3DFMT_R3G3B2 ,GL_R3_G3_B2 ,GL_R3_G3_B2 ,GL_RGB ,GL_UNSIGNED_BYTE_3_3_2 }, - {WINED3DFMT_A8 ,GL_ALPHA8 ,GL_ALPHA8 ,GL_ALPHA ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_A8R3G3B2 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_X4R4G4B4 ,GL_RGB4 ,GL_RGB4 ,GL_BGRA ,GL_UNSIGNED_SHORT_4_4_4_4_REV }, - {WINED3DFMT_A2B10G10R10 ,GL_RGBA ,GL_RGBA ,GL_RGBA ,GL_UNSIGNED_INT_2_10_10_10_REV }, - {WINED3DFMT_A8B8G8R8 ,GL_RGBA8 ,GL_RGBA8 ,GL_RGBA ,GL_UNSIGNED_INT_8_8_8_8_REV }, - {WINED3DFMT_X8B8G8R8 ,GL_RGB8 ,GL_RGB8 ,GL_RGBA ,GL_UNSIGNED_INT_8_8_8_8_REV }, - {WINED3DFMT_G16R16 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_A2R10G10B10 ,GL_RGBA ,GL_RGBA ,GL_BGRA ,GL_UNSIGNED_INT_2_10_10_10_REV }, - {WINED3DFMT_A16B16G16R16 ,GL_RGBA16_EXT ,GL_RGBA16_EXT ,GL_RGBA ,GL_UNSIGNED_SHORT }, + {WINED3DFMT_R8G8B8 ,GL_RGB8 ,GL_RGB8 , 0, GL_BGR ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_A8R8G8B8 ,GL_RGBA8 ,GL_SRGB8_ALPHA8_EXT , 0, GL_BGRA ,GL_UNSIGNED_INT_8_8_8_8_REV }, + {WINED3DFMT_X8R8G8B8 ,GL_RGB8 ,GL_SRGB8_EXT , 0, GL_BGRA ,GL_UNSIGNED_INT_8_8_8_8_REV }, + {WINED3DFMT_R5G6B5 ,GL_RGB5 ,GL_RGB5 , GL_RGB8, GL_RGB ,GL_UNSIGNED_SHORT_5_6_5 }, + {WINED3DFMT_X1R5G5B5 ,GL_RGB5 ,GL_RGB5_A1 , 0, GL_BGRA ,GL_UNSIGNED_SHORT_1_5_5_5_REV }, + {WINED3DFMT_A1R5G5B5 ,GL_RGB5_A1 ,GL_RGB5_A1 , 0, GL_BGRA ,GL_UNSIGNED_SHORT_1_5_5_5_REV }, + {WINED3DFMT_A4R4G4B4 ,GL_RGBA4 ,GL_SRGB8_ALPHA8_EXT , 0, GL_BGRA ,GL_UNSIGNED_SHORT_4_4_4_4_REV }, + {WINED3DFMT_R3G3B2 ,GL_R3_G3_B2 ,GL_R3_G3_B2 , 0, GL_RGB ,GL_UNSIGNED_BYTE_3_3_2 }, + {WINED3DFMT_A8 ,GL_ALPHA8 ,GL_ALPHA8 , 0, GL_ALPHA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_A8R3G3B2 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_X4R4G4B4 ,GL_RGB4 ,GL_RGB4 , 0, GL_BGRA ,GL_UNSIGNED_SHORT_4_4_4_4_REV }, + {WINED3DFMT_A2B10G10R10 ,GL_RGBA ,GL_RGBA , 0, GL_RGBA ,GL_UNSIGNED_INT_2_10_10_10_REV }, + {WINED3DFMT_A8B8G8R8 ,GL_RGBA8 ,GL_RGBA8 , 0, GL_RGBA ,GL_UNSIGNED_INT_8_8_8_8_REV }, + {WINED3DFMT_X8B8G8R8 ,GL_RGB8 ,GL_RGB8 , 0, GL_RGBA ,GL_UNSIGNED_INT_8_8_8_8_REV }, + {WINED3DFMT_G16R16 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_A2R10G10B10 ,GL_RGBA ,GL_RGBA , 0, GL_BGRA ,GL_UNSIGNED_INT_2_10_10_10_REV }, + {WINED3DFMT_A16B16G16R16 ,GL_RGBA16_EXT ,GL_RGBA16_EXT , 0, GL_RGBA ,GL_UNSIGNED_SHORT }, /* Luminance */ - {WINED3DFMT_L8 ,GL_LUMINANCE8 ,GL_SLUMINANCE8_EXT ,GL_LUMINANCE ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_A8L8 ,GL_LUMINANCE8_ALPHA8 ,GL_SLUMINANCE8_ALPHA8_EXT ,GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE }, - {WINED3DFMT_A4L4 ,GL_LUMINANCE4_ALPHA4 ,GL_LUMINANCE4_ALPHA4 ,GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_L8 ,GL_LUMINANCE8 ,GL_SLUMINANCE8_EXT , 0, GL_LUMINANCE ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_A8L8 ,GL_LUMINANCE8_ALPHA8 ,GL_SLUMINANCE8_ALPHA8_EXT , 0, GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE }, + {WINED3DFMT_A4L4 ,GL_LUMINANCE4_ALPHA4 ,GL_LUMINANCE4_ALPHA4 , 0, GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE }, /* Bump mapping stuff */ - {WINED3DFMT_V8U8 ,GL_DSDT8_NV ,GL_DSDT8_NV ,GL_DSDT_NV ,GL_BYTE }, - {WINED3DFMT_L6V5U5 ,GL_DSDT8_MAG8_NV ,GL_DSDT8_MAG8_NV ,GL_DSDT_MAG_NV ,GL_BYTE }, - {WINED3DFMT_X8L8V8U8 ,GL_DSDT8_MAG8_INTENSITY8_NV ,GL_DSDT8_MAG8_INTENSITY8_NV ,GL_DSDT_MAG_VIB_NV ,GL_UNSIGNED_INT_8_8_S8_S8_REV_NV}, - {WINED3DFMT_Q8W8V8U8 ,GL_SIGNED_RGBA8_NV ,GL_SIGNED_RGBA8_NV ,GL_RGBA ,GL_BYTE }, - {WINED3DFMT_V16U16 ,GL_SIGNED_HILO16_NV ,GL_SIGNED_HILO16_NV ,GL_HILO_NV ,GL_SHORT }, - {WINED3DFMT_W11V11U10 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_A2W10V10U10 ,0 ,0 ,0 ,0 }, + {WINED3DFMT_V8U8 ,GL_DSDT8_NV ,GL_DSDT8_NV , 0, GL_DSDT_NV ,GL_BYTE }, + {WINED3DFMT_L6V5U5 ,GL_DSDT8_MAG8_NV ,GL_DSDT8_MAG8_NV , 0, GL_DSDT_MAG_NV ,GL_BYTE }, + {WINED3DFMT_X8L8V8U8 ,GL_DSDT8_MAG8_INTENSITY8_NV ,GL_DSDT8_MAG8_INTENSITY8_NV , 0, GL_DSDT_MAG_VIB_NV ,GL_UNSIGNED_INT_8_8_S8_S8_REV_NV}, + {WINED3DFMT_Q8W8V8U8 ,GL_SIGNED_RGBA8_NV ,GL_SIGNED_RGBA8_NV , 0, GL_RGBA ,GL_BYTE }, + {WINED3DFMT_V16U16 ,GL_SIGNED_HILO16_NV ,GL_SIGNED_HILO16_NV , 0, GL_HILO_NV ,GL_SHORT }, + {WINED3DFMT_W11V11U10 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_A2W10V10U10 ,0 ,0 , 0, 0 ,0 }, /* Depth stencil formats */ - {WINED3DFMT_D16_LOCKABLE ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT ,GL_UNSIGNED_SHORT }, - {WINED3DFMT_D32 ,GL_DEPTH_COMPONENT32_ARB ,GL_DEPTH_COMPONENT32_ARB ,GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, - {WINED3DFMT_D15S1 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT ,GL_UNSIGNED_SHORT }, - {WINED3DFMT_D24S8 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, - {WINED3DFMT_D24X8 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, - {WINED3DFMT_D24X4S4 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, - {WINED3DFMT_D16 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT ,GL_UNSIGNED_SHORT }, - {WINED3DFMT_L16 ,GL_LUMINANCE16_EXT ,GL_LUMINANCE16_EXT ,GL_LUMINANCE ,GL_UNSIGNED_SHORT }, - {WINED3DFMT_D32F_LOCKABLE ,GL_DEPTH_COMPONENT32_ARB ,GL_DEPTH_COMPONENT32_ARB ,GL_DEPTH_COMPONENT ,GL_FLOAT }, - {WINED3DFMT_D24FS8 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT ,GL_FLOAT }, + {WINED3DFMT_D16_LOCKABLE ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB , 0, GL_DEPTH_COMPONENT ,GL_UNSIGNED_SHORT }, + {WINED3DFMT_D32 ,GL_DEPTH_COMPONENT32_ARB ,GL_DEPTH_COMPONENT32_ARB , 0, GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, + {WINED3DFMT_D15S1 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB , 0, GL_DEPTH_COMPONENT ,GL_UNSIGNED_SHORT }, + {WINED3DFMT_D24S8 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB , 0, GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, + {WINED3DFMT_D24X8 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB , 0, GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, + {WINED3DFMT_D24X4S4 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB , 0, GL_DEPTH_COMPONENT ,GL_UNSIGNED_INT }, + {WINED3DFMT_D16 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB , 0, GL_DEPTH_COMPONENT ,GL_UNSIGNED_SHORT }, + {WINED3DFMT_L16 ,GL_LUMINANCE16_EXT ,GL_LUMINANCE16_EXT , 0, GL_LUMINANCE ,GL_UNSIGNED_SHORT }, + {WINED3DFMT_D32F_LOCKABLE ,GL_DEPTH_COMPONENT32_ARB ,GL_DEPTH_COMPONENT32_ARB , 0, GL_DEPTH_COMPONENT ,GL_FLOAT }, + {WINED3DFMT_D24FS8 ,GL_DEPTH_COMPONENT24_ARB ,GL_DEPTH_COMPONENT24_ARB , 0, GL_DEPTH_COMPONENT ,GL_FLOAT }, /* Is this a vertex buffer? */ - {WINED3DFMT_VERTEXDATA ,0 ,0 ,0 ,0 }, - {WINED3DFMT_INDEX16 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_INDEX32 ,0 ,0 ,0 ,0 }, - {WINED3DFMT_Q16W16V16U16 ,GL_COLOR_INDEX ,GL_COLOR_INDEX ,GL_COLOR_INDEX ,GL_UNSIGNED_SHORT } + {WINED3DFMT_VERTEXDATA ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_INDEX16 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_INDEX32 ,0 ,0 , 0, 0 ,0 }, + {WINED3DFMT_Q16W16V16U16 ,GL_COLOR_INDEX ,GL_COLOR_INDEX , 0, GL_COLOR_INDEX ,GL_UNSIGNED_SHORT } }; static inline int getFmtIdx(WINED3DFORMAT fmt) { @@ -228,6 +228,46 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info) gl_info->gl_formats[dst].glFormat = gl_formats_template[src].glFormat; gl_info->gl_formats[dst].glType = gl_formats_template[src].glType; gl_info->gl_formats[dst].conversion_group= WINED3DFMT_UNKNOWN; + + if(wined3d_settings.offscreen_rendering_mode == ORM_FBO && + gl_formats_template[src].rtInternal != 0) { + GLuint tex, fb; + GLenum status; + + /* Check if the default internal format is supported as a frame buffer target, otherwise + * fall back to the render target internal. + * + * Try to stick to the standard format if possible, this limits precision differences + */ + while(glGetError()); + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexImage2D(GL_TEXTURE_2D, 0, gl_formats_template[src].glInternal, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + + GL_EXTCALL(glGenFramebuffersEXT(1, &fb)); + GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb)); + GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, tex, 0)); + + status = GL_EXTCALL(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)); + GL_EXTCALL(glDeleteFramebuffersEXT(1, &fb)); + glDeleteTextures(1, &tex); + + checkGLcall("Framebuffer format check"); + + if(status != GL_FRAMEBUFFER_COMPLETE_EXT) { + TRACE("Internal format of %s not supported as frame buffer target, using render target internal instead\n", + debug_d3dformat(gl_formats_template[src].fmt)); + gl_info->gl_formats[dst].rtInternal = gl_formats_template[src].rtInternal; + } else { + TRACE("Format %s is supported as fbo target\n", debug_d3dformat(gl_formats_template[src].fmt)); + gl_info->gl_formats[dst].rtInternal = gl_formats_template[src].glInternal; + } + + } else { + gl_info->gl_formats[dst].rtInternal = gl_formats_template[src].glInternal; + } } /* V8U8 is supported natively by GL_ATI_envmap_bumpmap and GL_NV_texture_shader. @@ -2464,7 +2504,7 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP /* After all the extensions, if still unhandled, report fixme */ FIXME("Unhandled texture operation %s\n", debug_d3dtop(op)); - #undef GLINFO_LOCATION +#undef GLINFO_LOCATION } #endif @@ -2757,10 +2797,17 @@ BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4] /* No oversized texture? This is easy */ if(!(This->Flags & SFLAG_OVERSIZE)) { /* Which rect from the texture do I need? */ - glTexCoord[0] = (float) Rect->left / (float) This->pow2Width; - glTexCoord[2] = (float) Rect->top / (float) This->pow2Height; - glTexCoord[1] = (float) Rect->right / (float) This->pow2Width; - glTexCoord[3] = (float) Rect->bottom / (float) This->pow2Height; + if(This->glDescription.target == GL_TEXTURE_RECTANGLE_ARB) { + glTexCoord[0] = (float) Rect->left; + glTexCoord[2] = (float) Rect->top; + glTexCoord[1] = (float) Rect->right; + glTexCoord[3] = (float) Rect->bottom; + } else { + glTexCoord[0] = (float) Rect->left / (float) This->pow2Width; + glTexCoord[2] = (float) Rect->top / (float) This->pow2Height; + glTexCoord[1] = (float) Rect->right / (float) This->pow2Width; + glTexCoord[3] = (float) Rect->bottom / (float) This->pow2Height; + } return TRUE; } else { @@ -2837,7 +2884,10 @@ BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4] Rect->bottom -= This->glRect.top; /* Get the gl coordinates. The gl rectangle is a power of 2, eigher the max size, - * or the pow2Width / pow2Height of the surface + * or the pow2Width / pow2Height of the surface. + * + * Can never be GL_TEXTURE_RECTANGLE_ARB because oversized surfaces are always set up + * as regular GL_TEXTURE_2D. */ glTexCoord[0] = (float) Rect->left / (float) (This->glRect.right - This->glRect.left); glTexCoord[2] = (float) Rect->top / (float) (This->glRect.bottom - This->glRect.top); diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index 924db6a1c4f..a62ac0116dc 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -175,7 +175,7 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte (This->swizzled_attribs[j].usage == This->pDeclarationWine[i].Usage && This->swizzled_attribs[j].idx > This->pDeclarationWine[i].UsageIndex)) { memmove(&This->swizzled_attribs[j + 1], &This->swizzled_attribs[j], - sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j - 1))); + sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j + 1))); break; } } diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c index bd4c2c11aa0..37a3705c7f5 100644 --- a/dlls/wined3d/vertexshader.c +++ b/dlls/wined3d/vertexshader.c @@ -336,7 +336,7 @@ static inline void find_swizzled_attribs(IWineD3DVertexDeclaration *declaration, oldswizzles[i].usage == This->swizzled_attribs[j].usage && oldswizzles[i].idx > This->swizzled_attribs[j].idx)) { memmove(&This->swizzled_attribs[j + 1], &This->swizzled_attribs[j], - sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j - 1))); + sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j + 1))); break; } } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 37908a70f43..a06083d0f0d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -948,6 +948,7 @@ typedef struct IWineD3DTextureImpl UINT width; UINT height; + UINT target; } IWineD3DTextureImpl; @@ -1745,11 +1746,17 @@ typedef struct SHADER_PARSE_STATE { DWORD texcoord_w[2]; } SHADER_PARSE_STATE; +#ifdef __GNUC__ +#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args))) +#else +#define PRINTF_ATTR(fmt,args) +#endif + /* Base Shader utility functions. * (may move callers into the same file in the future) */ extern int shader_addline( SHADER_BUFFER* buffer, - const char* fmt, ...); + const char* fmt, ...) PRINTF_ATTR(2,3); extern const SHADER_OPCODE* shader_get_opcode( IWineD3DBaseShader *iface, diff --git a/dlls/winedos/int21.c b/dlls/winedos/int21.c index 7e080e0d033..75aeb1cc4ff 100644 --- a/dlls/winedos/int21.c +++ b/dlls/winedos/int21.c @@ -1385,7 +1385,7 @@ static void INT21_SequentialReadFromFCB( CONTEXT86 *context ) struct XFCB *xfcb; HANDLE handle; DWORD record_number; - long position; + DWORD position; BYTE *disk_transfer_area; UINT bytes_read; BYTE AL_result; @@ -1405,7 +1405,7 @@ static void INT21_SequentialReadFromFCB( CONTEXT86 *context ) record_number = 128 * fcb->current_block_number + fcb->record_within_current_block; position = SetFilePointer(handle, record_number * fcb->logical_record_size, NULL, 0); if (position != record_number * fcb->logical_record_size) { - TRACE("seek(%d, %d, 0) failed with %ld\n", + TRACE("seek(%d, %d, 0) failed with %u\n", fcb->file_number, record_number * fcb->logical_record_size, position); AL_result = 0x01; /* end of file, no data read */ } else { @@ -1421,7 +1421,7 @@ static void INT21_SequentialReadFromFCB( CONTEXT86 *context ) AL_result = 0x03; /* end of file, partial record read */ } /* if */ } else { - TRACE("successful read %d bytes from record %d (position %ld) of file %d (handle %p)\n", + TRACE("successful read %d bytes from record %d (position %u) of file %d (handle %p)\n", bytes_read, record_number, position, fcb->file_number, handle); AL_result = 0x00; /* successful */ } /* if */ @@ -1465,7 +1465,7 @@ static void INT21_SequentialWriteToFCB( CONTEXT86 *context ) struct XFCB *xfcb; HANDLE handle; DWORD record_number; - long position; + DWORD position; BYTE *disk_transfer_area; UINT bytes_written; BYTE AL_result; @@ -1485,7 +1485,7 @@ static void INT21_SequentialWriteToFCB( CONTEXT86 *context ) record_number = 128 * fcb->current_block_number + fcb->record_within_current_block; position = SetFilePointer(handle, record_number * fcb->logical_record_size, NULL, 0); if (position != record_number * fcb->logical_record_size) { - TRACE("seek(%d, %d, 0) failed with %ld\n", + TRACE("seek(%d, %d, 0) failed with %u\n", fcb->file_number, record_number * fcb->logical_record_size, position); AL_result = 0x01; /* disk full */ } else { @@ -1496,7 +1496,7 @@ static void INT21_SequentialWriteToFCB( CONTEXT86 *context ) fcb->file_number, disk_transfer_area, fcb->logical_record_size, bytes_written); AL_result = 0x01; /* disk full */ } else { - TRACE("successful written %d bytes from record %d (position %ld) of file %d (handle %p)\n", + TRACE("successful written %d bytes from record %d (position %u) of file %d (handle %p)\n", bytes_written, record_number, position, fcb->file_number, handle); AL_result = 0x00; /* successful */ } /* if */ @@ -1541,7 +1541,7 @@ static void INT21_ReadRandomRecordFromFCB( CONTEXT86 *context ) struct XFCB *xfcb; HANDLE handle; DWORD record_number; - long position; + DWORD position; BYTE *disk_transfer_area; UINT bytes_read; BYTE AL_result; @@ -1561,7 +1561,7 @@ static void INT21_ReadRandomRecordFromFCB( CONTEXT86 *context ) } else { position = SetFilePointer(handle, record_number * fcb->logical_record_size, NULL, 0); if (position != record_number * fcb->logical_record_size) { - TRACE("seek(%d, %d, 0) failed with %ld\n", + TRACE("seek(%d, %d, 0) failed with %u\n", fcb->file_number, record_number * fcb->logical_record_size, position); AL_result = 0x01; /* end of file, no data read */ } else { @@ -1577,7 +1577,7 @@ static void INT21_ReadRandomRecordFromFCB( CONTEXT86 *context ) AL_result = 0x03; /* end of file, partial record read */ } /* if */ } else { - TRACE("successful read %d bytes from record %d (position %ld) of file %d (handle %p)\n", + TRACE("successful read %d bytes from record %d (position %u) of file %d (handle %p)\n", bytes_read, record_number, position, fcb->file_number, handle); AL_result = 0x00; /* successful */ } /* if */ @@ -1614,7 +1614,7 @@ static void INT21_WriteRandomRecordToFCB( CONTEXT86 *context ) struct XFCB *xfcb; HANDLE handle; DWORD record_number; - long position; + DWORD position; BYTE *disk_transfer_area; UINT bytes_written; BYTE AL_result; @@ -1634,7 +1634,7 @@ static void INT21_WriteRandomRecordToFCB( CONTEXT86 *context ) } else { position = SetFilePointer(handle, record_number * fcb->logical_record_size, NULL, 0); if (position != record_number * fcb->logical_record_size) { - TRACE("seek(%d, %d, 0) failed with %ld\n", + TRACE("seek(%d, %d, 0) failed with %u\n", fcb->file_number, record_number * fcb->logical_record_size, position); AL_result = 0x01; /* disk full */ } else { @@ -1645,7 +1645,7 @@ static void INT21_WriteRandomRecordToFCB( CONTEXT86 *context ) fcb->file_number, disk_transfer_area, fcb->logical_record_size, bytes_written); AL_result = 0x01; /* disk full */ } else { - TRACE("successful written %d bytes from record %d (position %ld) of file %d (handle %p)\n", + TRACE("successful written %d bytes from record %d (position %u) of file %d (handle %p)\n", bytes_written, record_number, position, fcb->file_number, handle); AL_result = 0x00; /* successful */ } /* if */ @@ -1689,7 +1689,7 @@ static void INT21_RandomBlockReadFromFCB( CONTEXT86 *context ) struct XFCB *xfcb; HANDLE handle; DWORD record_number; - long position; + DWORD position; BYTE *disk_transfer_area; UINT records_requested; UINT bytes_requested; @@ -1713,7 +1713,7 @@ static void INT21_RandomBlockReadFromFCB( CONTEXT86 *context ) } else { position = SetFilePointer(handle, record_number * fcb->logical_record_size, NULL, 0); if (position != record_number * fcb->logical_record_size) { - TRACE("seek(%d, %d, 0) failed with %ld\n", + TRACE("seek(%d, %d, 0) failed with %u\n", fcb->file_number, record_number * fcb->logical_record_size, position); records_read = 0; AL_result = 0x01; /* end of file, no data read */ @@ -1734,7 +1734,7 @@ static void INT21_RandomBlockReadFromFCB( CONTEXT86 *context ) AL_result = 0x03; /* end of file, partial record read */ } /* if */ } else { - TRACE("successful read %d bytes from record %d (position %ld) of file %d (handle %p)\n", + TRACE("successful read %d bytes from record %d (position %u) of file %d (handle %p)\n", bytes_read, record_number, position, fcb->file_number, handle); records_read = records_requested; AL_result = 0x00; /* successful */ @@ -1780,7 +1780,7 @@ static void INT21_RandomBlockWriteToFCB( CONTEXT86 *context ) struct XFCB *xfcb; HANDLE handle; DWORD record_number; - long position; + DWORD position; BYTE *disk_transfer_area; UINT records_requested; UINT bytes_requested; @@ -1804,7 +1804,7 @@ static void INT21_RandomBlockWriteToFCB( CONTEXT86 *context ) } else { position = SetFilePointer(handle, record_number * fcb->logical_record_size, NULL, 0); if (position != record_number * fcb->logical_record_size) { - TRACE("seek(%d, %d, 0) failed with %ld\n", + TRACE("seek(%d, %d, 0) failed with %u\n", fcb->file_number, record_number * fcb->logical_record_size, position); records_written = 0; AL_result = 0x01; /* disk full */ @@ -1819,7 +1819,7 @@ static void INT21_RandomBlockWriteToFCB( CONTEXT86 *context ) records_written = bytes_written / fcb->logical_record_size; AL_result = 0x01; /* disk full */ } else { - TRACE("successful write %d bytes from record %d (position %ld) of file %d (handle %p)\n", + TRACE("successful write %d bytes from record %d (position %u) of file %d (handle %p)\n", bytes_written, record_number, position, fcb->file_number, handle); records_written = records_requested; AL_result = 0x00; /* successful */ @@ -2733,7 +2733,7 @@ static void INT21_IoctlHPScanHandler( CONTEXT86 *context ) */ static void INT21_Ioctl_Char( CONTEXT86 *context ) { - int status, i; + int status; int IsConsoleIOHandle = 0; IO_STATUS_BLOCK io; FILE_INTERNAL_INFORMATION info; @@ -2750,6 +2750,7 @@ static void INT21_Ioctl_Char( CONTEXT86 *context ) return; } } else { + UINT i; for (i = 0; i < NB_MAGIC_DEVICES; i++) { if (!magic_devices[i].handle) continue; diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 5f27bd2d68b..68458832caa 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -1193,6 +1193,7 @@ static BOOL HTTP_InsertAuthorizationForHeader( LPWININETHTTPREQW lpwhr, struct H if (pAuthInfo && pAuthInfo->auth_data_len) { static const WCHAR wszSpace[] = {' ',0}; + static const WCHAR wszBasic[] = {'B','a','s','i','c',0}; unsigned int len; /* scheme + space + base64 encoded data (3/2/1 bytes data -> 4 bytes of characters) */ @@ -1208,10 +1209,14 @@ static BOOL HTTP_InsertAuthorizationForHeader( LPWININETHTTPREQW lpwhr, struct H authorization+strlenW(authorization)); /* clear the data as it isn't valid now that it has been sent to the - * server */ - HeapFree(GetProcessHeap(), 0, pAuthInfo->auth_data); - pAuthInfo->auth_data = NULL; - pAuthInfo->auth_data_len = 0; + * server, unless it's Basic authentication which doesn't do + * connection tracking */ + if (strcmpiW(pAuthInfo->scheme, wszBasic)) + { + HeapFree(GetProcessHeap(), 0, pAuthInfo->auth_data); + pAuthInfo->auth_data = NULL; + pAuthInfo->auth_data_len = 0; + } } TRACE("Inserting authorization: %s\n", debugstr_w(authorization)); diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 4a28db95ac6..ec2df72d988 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -1228,7 +1228,8 @@ struct server_info { static DWORD CALLBACK server_thread(LPVOID param) { struct server_info *si = param; - int r, s, c, i, on; + int r, c, i, on; + SOCKET s; struct sockaddr_in sa; char buffer[0x100]; WSADATA wsaData; @@ -1237,7 +1238,7 @@ static DWORD CALLBACK server_thread(LPVOID param) WSAStartup(MAKEWORD(1,1), &wsaData); s = socket(AF_INET, SOCK_STREAM, 0); - if (s<0) + if (s == INVALID_SOCKET) return 1; on = 1; diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index 6ead1073c6a..1f3602c192c 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -521,7 +521,7 @@ UINT WINAPI mixerGetLineControlsA(HMIXEROBJ hmix, LPMIXERLINECONTROLSA lpmlcA, /* Debugging on Windows shows for MIXER_GETLINECONTROLSF_ONEBYTYPE only, the control count is assumed to be 1 - This is relied upon by a game, "Dynomite Deluze" */ - if (MIXER_GETLINECONTROLSF_ONEBYTYPE == fdwControls) { + if (MIXER_GETLINECONTROLSF_ONEBYTYPE == (fdwControls & MIXER_GETLINECONTROLSF_QUERYMASK)) { mlcW.cControls = 1; } else { mlcW.cControls = lpmlcA->cControls; @@ -536,7 +536,6 @@ UINT WINAPI mixerGetLineControlsA(HMIXEROBJ hmix, LPMIXERLINECONTROLSA lpmlcA, lpmlcA->dwLineID = mlcW.dwLineID; lpmlcA->u.dwControlID = mlcW.u.dwControlID; lpmlcA->u.dwControlType = mlcW.u.dwControlType; - lpmlcA->cControls = mlcW.cControls; for (i = 0; i < mlcW.cControls; i++) { lpmlcA->pamxctrl[i].cbStruct = sizeof(MIXERCONTROLA); diff --git a/include/Makefile.in b/include/Makefile.in index e1d53dac5cf..c4468101bdc 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -112,6 +112,9 @@ SRCDIR_INCLUDES = \ d3dx8core.h \ d3dx8math.h \ d3dx8math.inl \ + d3dx9.h \ + d3dx9math.h \ + d3dx9math.inl \ dbghelp.h \ dbinit.idl \ dbprop.idl \ diff --git a/include/d3dx8math.h b/include/d3dx8math.h index 3e5581ebebe..1863ac0a040 100644 --- a/include/d3dx8math.h +++ b/include/d3dx8math.h @@ -293,6 +293,7 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT yaw, F D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle); D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT sz); D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, CONST D3DXPLANE *pPlane); +D3DXMATRIX* WINAPI D3DXMatrixTransformation(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pscalingcenter, CONST D3DXQUATERNION *pscalingrotation, CONST D3DXVECTOR3 *pscaling, CONST D3DXVECTOR3 *protationcenter, CONST D3DXQUATERNION *protation, CONST D3DXVECTOR3 *ptranslation); D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z); D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm); @@ -303,11 +304,17 @@ D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp); D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *pplane, CONST D3DXMATRIX *pm); D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, FLOAT f, FLOAT g); +D3DXQUATERNION* WINAPI D3DXQuaternionExp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); +D3DXQUATERNION* WINAPI D3DXQuaternionLn(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2); D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle); +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix(D3DXQUATERNION *pout, CONST D3DXMATRIX *pm); +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *pout, FLOAT yaw, FLOAT pitch, FLOAT roll); D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t); D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, CONST D3DXQUATERNION *pq4, FLOAT t); +void WINAPI D3DXQuaternionToAxisAngle(CONST D3DXQUATERNION *pq, D3DXVECTOR3 *paxis, FLOAT *pangle); D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g); D3DXVECTOR2* WINAPI D3DXVec2CatmullRom(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv0, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT s); diff --git a/include/d3dx9.h b/include/d3dx9.h new file mode 100644 index 00000000000..f1f2228ca09 --- /dev/null +++ b/include/d3dx9.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2007 David Adam + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __D3DX9_H__ +#define __D3DX9_H__ + +#include + +#include "d3d9.h" +#include "d3dx9math.h" + +#endif diff --git a/include/d3dx8math.h b/include/d3dx9math.h similarity index 92% copy from include/d3dx8math.h copy to include/d3dx9math.h index 3e5581ebebe..d4bd3795fd0 100644 --- a/include/d3dx8math.h +++ b/include/d3dx9math.h @@ -17,10 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include -#ifndef __D3DX8MATH_H__ -#define __D3DX8MATH_H__ +#ifndef __D3DX9MATH_H__ +#define __D3DX9MATH_H__ #include @@ -267,7 +267,7 @@ D3DXCOLOR* WINAPI D3DXColorAdjustContrast(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, D3DXCOLOR* WINAPI D3DXColorAdjustSaturation(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, FLOAT s); D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *pout, float scaling, D3DXVECTOR3 *rotationcenter, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation); -FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm); +FLOAT WINAPI D3DXMatrixDeterminant(CONST D3DXMATRIX *pm); D3DXMATRIX* WINAPI D3DXMatrixInverse(D3DXMATRIX *pout, FLOAT *pdeterminant, CONST D3DXMATRIX *pm); D3DXMATRIX* WINAPI D3DXMatrixLookAtLH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup); D3DXMATRIX* WINAPI D3DXMatrixLookAtRH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup); @@ -293,6 +293,7 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT yaw, F D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle); D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT sz); D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, CONST D3DXPLANE *pPlane); +D3DXMATRIX* WINAPI D3DXMatrixTransformation(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pscalingcenter, CONST D3DXQUATERNION *pscalingrotation, CONST D3DXVECTOR3 *pscaling, CONST D3DXVECTOR3 *protationcenter, CONST D3DXQUATERNION *protation, CONST D3DXVECTOR3 *ptranslation); D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z); D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm); @@ -303,11 +304,17 @@ D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp); D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *pplane, CONST D3DXMATRIX *pm); D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, FLOAT f, FLOAT g); +D3DXQUATERNION* WINAPI D3DXQuaternionExp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); +D3DXQUATERNION* WINAPI D3DXQuaternionLn(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2); D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis(D3DXQUATERNION *pout, CONST D3DXVECTOR3 *pv, FLOAT angle); +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix(D3DXQUATERNION *pout, CONST D3DXMATRIX *pm); +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll(D3DXQUATERNION *pout, FLOAT yaw, FLOAT pitch, FLOAT roll); D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t); D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, CONST D3DXQUATERNION *pq4, FLOAT t); +void WINAPI D3DXQuaternionToAxisAngle(CONST D3DXQUATERNION *pq, D3DXVECTOR3 *paxis, FLOAT *pangle); D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g); D3DXVECTOR2* WINAPI D3DXVec2CatmullRom(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv0, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT s); @@ -321,11 +328,11 @@ D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv D3DXVECTOR3* WINAPI D3DXVec3CatmullRom( D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv0, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT s); D3DXVECTOR3* WINAPI D3DXVec3Hermite(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pt1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pt2, FLOAT s); D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv); -D3DXVECTOR3* WINAPI D3DXVec3Project(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT8 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld); +D3DXVECTOR3* WINAPI D3DXVec3Project(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT9 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld); D3DXVECTOR4* WINAPI D3DXVec3Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm); D3DXVECTOR3* WINAPI D3DXVec3TransformCoord(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm); D3DXVECTOR3* WINAPI D3DXVec3TransformNormal(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm); -D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT8 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld); +D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT9 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld); D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g); D3DXVECTOR4* WINAPI D3DXVec4CatmullRom(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv0, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT s); @@ -338,6 +345,6 @@ D3DXVECTOR4* WINAPI D3DXVec4Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv, } #endif -#include +#include -#endif /* __D3DX8MATH_H__ */ +#endif /* __D3DX9MATH_H__ */ diff --git a/include/d3dx9math.inl b/include/d3dx9math.inl new file mode 100644 index 00000000000..3cd078aca71 --- /dev/null +++ b/include/d3dx9math.inl @@ -0,0 +1,1268 @@ +/* + * Copyright (C) 2007 David Adam + * Copyright (C) 2007 Tony Wasserka + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __D3DX9MATH_INL__ +#define __D3DX9MATH_INL__ + +/* constructors & operators */ +#ifdef __cplusplus + +inline D3DXVECTOR2::D3DXVECTOR2() +{ +} + +inline D3DXVECTOR2::D3DXVECTOR2(CONST FLOAT *pf) +{ + if(!pf) return; + x = pf[0]; + y = pf[1]; +} + +inline D3DXVECTOR2::D3DXVECTOR2(FLOAT fx, FLOAT fy) +{ + x = fx; + y = fy; +} + +inline D3DXVECTOR2::operator FLOAT* () +{ + return (FLOAT*)&x; +} + +inline D3DXVECTOR2::operator CONST FLOAT* () const +{ + return (CONST FLOAT*)&x; +} + +inline D3DXVECTOR2& D3DXVECTOR2::operator += (CONST D3DXVECTOR2& v) +{ + x += v.x; + y += v.y; + return *this; +} + +inline D3DXVECTOR2& D3DXVECTOR2::operator -= (CONST D3DXVECTOR2& v) +{ + x -= v.x; + y -= v.y; + return *this; +} + +inline D3DXVECTOR2& D3DXVECTOR2::operator *= (FLOAT f) +{ + x *= f; + y *= f; + return *this; +} + +inline D3DXVECTOR2& D3DXVECTOR2::operator /= (FLOAT f) +{ + x /= f; + y /= f; + return *this; +} + +inline D3DXVECTOR2 D3DXVECTOR2::operator + () const +{ + return *this; +} + +inline D3DXVECTOR2 D3DXVECTOR2::operator - () const +{ + return D3DXVECTOR2(-x, -y); +} + +inline D3DXVECTOR2 D3DXVECTOR2::operator + (CONST D3DXVECTOR2& v) const +{ + return D3DXVECTOR2(x + v.x, y + v.y); +} + +inline D3DXVECTOR2 D3DXVECTOR2::operator - (CONST D3DXVECTOR2& v) const +{ + return D3DXVECTOR2(x - v.x, y - v.y); +} + +inline D3DXVECTOR2 D3DXVECTOR2::operator * (FLOAT f) const +{ + return D3DXVECTOR2(x * f, y * f); +} + +inline D3DXVECTOR2 D3DXVECTOR2::operator / (FLOAT f) const +{ + return D3DXVECTOR2(x / f, y / f); +} + +inline D3DXVECTOR2 operator * (FLOAT f, CONST D3DXVECTOR2& v) +{ + return D3DXVECTOR2(f * v.x, f * v.y); +} + +inline BOOL D3DXVECTOR2::operator == (CONST D3DXVECTOR2& v) const +{ + return x == v.x && y == v.y; +} + +inline BOOL D3DXVECTOR2::operator != (CONST D3DXVECTOR2& v) const +{ + return x != v.x || y != v.y; +} + +inline D3DXVECTOR3::D3DXVECTOR3() +{ +} + +inline D3DXVECTOR3::D3DXVECTOR3(CONST FLOAT *pf) +{ + if(!pf) return; + x = pf[0]; + y = pf[1]; + z = pf[2]; +} + +inline D3DXVECTOR3::D3DXVECTOR3(CONST D3DVECTOR& v) +{ + x = v.x; + y = v.y; + z = v.z; +} + +inline D3DXVECTOR3::D3DXVECTOR3(FLOAT fx, FLOAT fy, FLOAT fz) +{ + x = fx; + y = fy; + z = fz; +} + +inline D3DXVECTOR3::operator FLOAT* () +{ + return (FLOAT*)&x; +} + +inline D3DXVECTOR3::operator CONST FLOAT* () const +{ + return (CONST FLOAT*)&x; +} + +inline D3DXVECTOR3& D3DXVECTOR3::operator += (CONST D3DXVECTOR3& v) +{ + x += v.x; + y += v.y; + z += v.z; + return *this; +} + +inline D3DXVECTOR3& D3DXVECTOR3::operator -= (CONST D3DXVECTOR3& v) +{ + x -= v.x; + y -= v.y; + z -= v.z; + return *this; +} + +inline D3DXVECTOR3& D3DXVECTOR3::operator *= (FLOAT f) +{ + x *= f; + y *= f; + z *= f; + return *this; +} + +inline D3DXVECTOR3& D3DXVECTOR3::operator /= (FLOAT f) +{ + x /= f; + y /= f; + z /= f; + return *this; +} + +inline D3DXVECTOR3 D3DXVECTOR3::operator + () const +{ + return *this; +} + +inline D3DXVECTOR3 D3DXVECTOR3::operator - () const +{ + return D3DXVECTOR3(-x, -y, -z); +} + +inline D3DXVECTOR3 D3DXVECTOR3::operator + (CONST D3DXVECTOR3& v) const +{ + return D3DXVECTOR3(x + v.x, y + v.y, z + v.z); +} + +inline D3DXVECTOR3 D3DXVECTOR3::operator - (CONST D3DXVECTOR3& v) const +{ + return D3DXVECTOR3(x - v.x, y - v.y, z - v.z); +} + +inline D3DXVECTOR3 D3DXVECTOR3::operator * (FLOAT f) const +{ + return D3DXVECTOR3(x * f, y * f, z * f); +} + +inline D3DXVECTOR3 D3DXVECTOR3::operator / (FLOAT f) const +{ + return D3DXVECTOR3(x / f, y / f, z / f); +} + +inline D3DXVECTOR3 operator * (FLOAT f, CONST D3DXVECTOR3& v) +{ + return D3DXVECTOR3(f * v.x, f * v.y, f * v.z); +} + +inline BOOL D3DXVECTOR3::operator == (CONST D3DXVECTOR3& v) const +{ + return x == v.x && y == v.y && z == v.z; +} + +inline BOOL D3DXVECTOR3::operator != (CONST D3DXVECTOR3& v) const +{ + return x != v.x || y != v.y || z != v.z; +} + +inline D3DXVECTOR4::D3DXVECTOR4() +{ +} + +inline D3DXVECTOR4::D3DXVECTOR4(CONST FLOAT *pf) +{ + if(!pf) return; + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +inline D3DXVECTOR4::D3DXVECTOR4(FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + +inline D3DXVECTOR4::operator FLOAT* () +{ + return (FLOAT*)&x; +} + +inline D3DXVECTOR4::operator CONST FLOAT* () const +{ + return (CONST FLOAT*)&x; +} + +inline D3DXVECTOR4& D3DXVECTOR4::operator += (CONST D3DXVECTOR4& v) +{ + x += v.x; + y += v.y; + z += v.z; + w += v.w; + return *this; +} + +inline D3DXVECTOR4& D3DXVECTOR4::operator -= (CONST D3DXVECTOR4& v) +{ + x -= v.x; + y -= v.y; + z -= v.z; + w -= v.w; + return *this; +} + +inline D3DXVECTOR4& D3DXVECTOR4::operator *= (FLOAT f) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +inline D3DXVECTOR4& D3DXVECTOR4::operator /= (FLOAT f) +{ + x /= f; + y /= f; + z /= f; + w /= f; + return *this; +} + +inline D3DXVECTOR4 D3DXVECTOR4::operator + () const +{ + return *this; +} + +inline D3DXVECTOR4 D3DXVECTOR4::operator - () const +{ + return D3DXVECTOR4(-x, -y, -z, -w); +} + +inline D3DXVECTOR4 D3DXVECTOR4::operator + (CONST D3DXVECTOR4& v) const +{ + return D3DXVECTOR4(x + v.x, y + v.y, z + v.z, w + v.w); +} + +inline D3DXVECTOR4 D3DXVECTOR4::operator - (CONST D3DXVECTOR4& v) const +{ + return D3DXVECTOR4(x - v.x, y - v.y, z - v.z, w - v.w); +} + +inline D3DXVECTOR4 D3DXVECTOR4::operator * (FLOAT f) const +{ + return D3DXVECTOR4(x * f, y * f, z * f, w * f); +} + +inline D3DXVECTOR4 D3DXVECTOR4::operator / (FLOAT f) const +{ + return D3DXVECTOR4(x / f, y / f, z / f, w / f); +} + +inline D3DXVECTOR4 operator * (FLOAT f, CONST D3DXVECTOR4& v) +{ + return D3DXVECTOR4(f * v.x, f * v.y, f * v.z, f * v.w); +} + +inline BOOL D3DXVECTOR4::operator == (CONST D3DXVECTOR4& v) const +{ + return x == v.x && y == v.y && z == v.z && w == v.w; +} + +inline BOOL D3DXVECTOR4::operator != (CONST D3DXVECTOR4& v) const +{ + return x != v.x || y != v.y || z != v.z || w != v.w; +} + +inline D3DXMATRIX::D3DXMATRIX() +{ +} + +inline D3DXMATRIX::D3DXMATRIX(CONST FLOAT *pf) +{ + if(!pf) return; + memcpy(&_11, pf, sizeof(D3DXMATRIX)); +} + +inline D3DXMATRIX::D3DXMATRIX(CONST D3DMATRIX& mat) +{ + memcpy(&_11, &mat, sizeof(D3DXMATRIX)); +} + +inline D3DXMATRIX::D3DXMATRIX(FLOAT f11, FLOAT f12, FLOAT f13, FLOAT f14, + FLOAT f21, FLOAT f22, FLOAT f23, FLOAT f24, + FLOAT f31, FLOAT f32, FLOAT f33, FLOAT f34, + FLOAT f41, FLOAT f42, FLOAT f43, FLOAT f44) +{ + _11 = f11; _12 = f12; _13 = f13; _14 = f14; + _21 = f21; _22 = f22; _23 = f23; _24 = f24; + _31 = f31; _32 = f32; _33 = f33; _34 = f34; + _41 = f41; _42 = f42; _43 = f43; _44 = f44; +} + +inline FLOAT& D3DXMATRIX::operator () (UINT row, UINT col) +{ + return m[row][col]; +} + +inline FLOAT D3DXMATRIX::operator () (UINT row, UINT col) const +{ + return m[row][col]; +} + +inline D3DXMATRIX::operator FLOAT* () +{ + return (FLOAT*)&_11; +} + +inline D3DXMATRIX::operator CONST FLOAT* () const +{ + return (CONST FLOAT*)&_11; +} + +inline D3DXMATRIX& D3DXMATRIX::operator *= (CONST D3DXMATRIX& mat) +{ + D3DXMatrixMultiply(this, this, &mat); + return *this; +} + +inline D3DXMATRIX& D3DXMATRIX::operator += (CONST D3DXMATRIX& mat) +{ + _11 += mat._11; _12 += mat._12; _13 += mat._13; _14 += mat._14; + _21 += mat._21; _22 += mat._22; _23 += mat._23; _24 += mat._24; + _31 += mat._31; _32 += mat._32; _33 += mat._33; _34 += mat._34; + _41 += mat._41; _42 += mat._42; _43 += mat._43; _44 += mat._44; + return *this; +} + +inline D3DXMATRIX& D3DXMATRIX::operator -= (CONST D3DXMATRIX& mat) +{ + _11 -= mat._11; _12 -= mat._12; _13 -= mat._13; _14 -= mat._14; + _21 -= mat._21; _22 -= mat._22; _23 -= mat._23; _24 -= mat._24; + _31 -= mat._31; _32 -= mat._32; _33 -= mat._33; _34 -= mat._34; + _41 -= mat._41; _42 -= mat._42; _43 -= mat._43; _44 -= mat._44; + return *this; +} + +inline D3DXMATRIX& D3DXMATRIX::operator *= (FLOAT f) +{ + _11 *= f; _12 *= f; _13 *= f; _14 *= f; + _21 *= f; _22 *= f; _23 *= f; _24 *= f; + _31 *= f; _32 *= f; _33 *= f; _34 *= f; + _41 *= f; _42 *= f; _43 *= f; _44 *= f; + return *this; +} + +inline D3DXMATRIX& D3DXMATRIX::operator /= (FLOAT f) +{ + FLOAT inv = 1.0f / f; + _11 *= inv; _12 *= inv; _13 *= inv; _14 *= inv; + _21 *= inv; _22 *= inv; _23 *= inv; _24 *= inv; + _31 *= inv; _32 *= inv; _33 *= inv; _34 *= inv; + _41 *= inv; _42 *= inv; _43 *= inv; _44 *= inv; + return *this; +} + +inline D3DXMATRIX D3DXMATRIX::operator + () const +{ + return *this; +} + +inline D3DXMATRIX D3DXMATRIX::operator - () const +{ + return D3DXMATRIX(-_11, -_12, -_13, -_14, + -_21, -_22, -_23, -_24, + -_31, -_32, -_33, -_34, + -_41, -_42, -_43, -_44); +} + +inline D3DXMATRIX D3DXMATRIX::operator * (CONST D3DXMATRIX& mat) const +{ + D3DXMATRIX buf; + D3DXMatrixMultiply(&buf, this, &mat); + return buf; +} + +inline D3DXMATRIX D3DXMATRIX::operator + (CONST D3DXMATRIX& mat) const +{ + return D3DXMATRIX(_11 + mat._11, _12 + mat._12, _13 + mat._13, _14 + mat._14, + _21 + mat._21, _22 + mat._22, _23 + mat._23, _24 + mat._24, + _31 + mat._31, _32 + mat._32, _33 + mat._33, _34 + mat._34, + _41 + mat._41, _42 + mat._42, _43 + mat._43, _44 + mat._44); +} + +inline D3DXMATRIX D3DXMATRIX::operator - (CONST D3DXMATRIX& mat) const +{ + return D3DXMATRIX(_11 - mat._11, _12 - mat._12, _13 - mat._13, _14 - mat._14, + _21 - mat._21, _22 - mat._22, _23 - mat._23, _24 - mat._24, + _31 - mat._31, _32 - mat._32, _33 - mat._33, _34 - mat._34, + _41 - mat._41, _42 - mat._42, _43 - mat._43, _44 - mat._44); +} + +inline D3DXMATRIX D3DXMATRIX::operator * (FLOAT f) const +{ + return D3DXMATRIX(_11 * f, _12 * f, _13 * f, _14 * f, + _21 * f, _22 * f, _23 * f, _24 * f, + _31 * f, _32 * f, _33 * f, _34 * f, + _41 * f, _42 * f, _43 * f, _44 * f); +} + +inline D3DXMATRIX D3DXMATRIX::operator / (FLOAT f) const +{ + FLOAT inv = 1.0f / f; + return D3DXMATRIX(_11 * inv, _12 * inv, _13 * inv, _14 * inv, + _21 * inv, _22 * inv, _23 * inv, _24 * inv, + _31 * inv, _32 * inv, _33 * inv, _34 * inv, + _41 * inv, _42 * inv, _43 * inv, _44 * inv); +} + +inline D3DXMATRIX operator * (FLOAT f, CONST D3DXMATRIX& mat) +{ + return D3DXMATRIX(f * mat._11, f * mat._12, f * mat._13, f * mat._14, + f * mat._21, f * mat._22, f * mat._23, f * mat._24, + f * mat._31, f * mat._32, f * mat._33, f * mat._34, + f * mat._41, f * mat._42, f * mat._43, f * mat._44); +} + +inline BOOL D3DXMATRIX::operator == (CONST D3DXMATRIX& mat) const +{ + return (memcmp(this, &mat, sizeof(D3DXMATRIX)) == 0); +} + +inline BOOL D3DXMATRIX::operator != (CONST D3DXMATRIX& mat) const +{ + return (memcmp(this, &mat, sizeof(D3DXMATRIX)) != 0); +} + +inline D3DXQUATERNION::D3DXQUATERNION() +{ +} + +inline D3DXQUATERNION::D3DXQUATERNION(CONST FLOAT *pf) +{ + if(!pf) return; + x = pf[0]; + y = pf[1]; + z = pf[2]; + w = pf[3]; +} + +inline D3DXQUATERNION::D3DXQUATERNION(FLOAT fx, FLOAT fy, FLOAT fz, FLOAT fw) +{ + x = fx; + y = fy; + z = fz; + w = fw; +} + +inline D3DXQUATERNION::operator FLOAT* () +{ + return (FLOAT*)&x; +} + +inline D3DXQUATERNION::operator CONST FLOAT* () const +{ + return (CONST FLOAT*)&x; +} + +inline D3DXQUATERNION& D3DXQUATERNION::operator += (CONST D3DXQUATERNION& quat) +{ + x += quat.x; + y += quat.y; + z += quat.z; + w += quat.w; + return *this; +} + +inline D3DXQUATERNION& D3DXQUATERNION::operator -= (CONST D3DXQUATERNION& quat) +{ + x -= quat.x; + y -= quat.y; + z -= quat.z; + w -= quat.w; + return *this; +} + +/* TODO: uncomment this when D3DXQuaternionMultiply has been implemented +inline D3DXQUATERNION& D3DXQUATERNION::operator *= (CONST D3DXQUATERNION& quat) +{ + D3DXQuaternionMultiply(this, this, &quat); + return *this; +} +*/ + +inline D3DXQUATERNION& D3DXQUATERNION::operator *= (FLOAT f) +{ + x *= f; + y *= f; + z *= f; + w *= f; + return *this; +} + +inline D3DXQUATERNION& D3DXQUATERNION::operator /= (FLOAT f) +{ + FLOAT inv = 1.0f / f; + x *= inv; + y *= inv; + z *= inv; + w *= inv; + return *this; +} + +inline D3DXQUATERNION D3DXQUATERNION::operator + () const +{ + return *this; +} + +inline D3DXQUATERNION D3DXQUATERNION::operator - () const +{ + return D3DXQUATERNION(-x, -y, -z, -w); +} + +inline D3DXQUATERNION D3DXQUATERNION::operator + (CONST D3DXQUATERNION& quat) const +{ + return D3DXQUATERNION(x + quat.x, y + quat.y, z + quat.z, w + quat.w); +} + +inline D3DXQUATERNION D3DXQUATERNION::operator - (CONST D3DXQUATERNION& quat) const +{ + return D3DXQUATERNION(x - quat.x, y - quat.y, z - quat.z, w - quat.w); +} + +/* TODO: uncomment this when D3DXQuaternionMultiply has been implemented +inline D3DXQUATERNION D3DXQUATERNION::operator * (CONST D3DXQUATERNION& quat) const +{ + D3DXQUATERNION buf; + D3DXQuaternionMultiply(&buf, this, &quat); + return buf; +} +*/ + +inline D3DXQUATERNION D3DXQUATERNION::operator * (FLOAT f) const +{ + return D3DXQUATERNION(x * f, y * f, z * f, w * f); +} + +inline D3DXQUATERNION D3DXQUATERNION::operator / (FLOAT f) const +{ + FLOAT inv = 1.0f / f; + return D3DXQUATERNION(x * inv, y * inv, z * inv, w * inv); +} + +inline D3DXQUATERNION operator * (FLOAT f, CONST D3DXQUATERNION& quat) +{ + return D3DXQUATERNION(f * quat.x, f * quat.y, f * quat.z, f * quat.w); +} + +inline BOOL D3DXQUATERNION::operator == (CONST D3DXQUATERNION& quat) const +{ + return x == quat.x && y == quat.y && z == quat.z && w == quat.w; +} + +inline BOOL D3DXQUATERNION::operator != (CONST D3DXQUATERNION& quat) const +{ + return x != quat.x || y != quat.y || z != quat.z || w != quat.w; +} + +inline D3DXPLANE::D3DXPLANE() +{ +} + +inline D3DXPLANE::D3DXPLANE(CONST FLOAT *pf) +{ + if(!pf) return; + a = pf[0]; + b = pf[1]; + c = pf[2]; + d = pf[3]; +} + +inline D3DXPLANE::D3DXPLANE(FLOAT fa, FLOAT fb, FLOAT fc, FLOAT fd) +{ + a = fa; + b = fb; + c = fc; + d = fd; +} + +inline D3DXPLANE::operator FLOAT* () +{ + return (FLOAT*)&a; +} + +inline D3DXPLANE::operator CONST FLOAT* () const +{ + return (CONST FLOAT*)&a; +} + +inline D3DXPLANE D3DXPLANE::operator + () const +{ + return *this; +} + +inline D3DXPLANE D3DXPLANE::operator - () const +{ + return D3DXPLANE(-a, -b, -c, -d); +} + +inline BOOL D3DXPLANE::operator == (CONST D3DXPLANE& pl) const +{ + return a == pl.a && b == pl.b && c == pl.c && d == pl.d; +} + +inline BOOL D3DXPLANE::operator != (CONST D3DXPLANE& pl) const +{ + return a != pl.a || b != pl.b || c != pl.c || d != pl.d; +} + +inline D3DXCOLOR::D3DXCOLOR() +{ +} + +inline D3DXCOLOR::D3DXCOLOR(DWORD col) +{ + CONST FLOAT f = 1.0f / 255.0f; + r = f * (FLOAT)(unsigned char)(col >> 16); + g = f * (FLOAT)(unsigned char)(col >> 8); + b = f * (FLOAT)(unsigned char)col; + a = f * (FLOAT)(unsigned char)(col >> 24); +} + +inline D3DXCOLOR::D3DXCOLOR(CONST FLOAT *pf) +{ + if(!pf) return; + r = pf[0]; + g = pf[1]; + b = pf[2]; + a = pf[3]; +} + +inline D3DXCOLOR::D3DXCOLOR(CONST D3DCOLORVALUE& col) +{ + r = col.r; + g = col.g; + b = col.b; + a = col.a; +} + +inline D3DXCOLOR::D3DXCOLOR(FLOAT fr, FLOAT fg, FLOAT fb, FLOAT fa) +{ + r = fr; + g = fg; + b = fb; + a = fa; +} + +inline D3DXCOLOR::operator DWORD () const +{ + DWORD _r = r >= 1.0f ? 0xff : r <= 0.0f ? 0x00 : (DWORD)(r * 255.0f + 0.5f); + DWORD _g = g >= 1.0f ? 0xff : g <= 0.0f ? 0x00 : (DWORD)(g * 255.0f + 0.5f); + DWORD _b = b >= 1.0f ? 0xff : b <= 0.0f ? 0x00 : (DWORD)(b * 255.0f + 0.5f); + DWORD _a = a >= 1.0f ? 0xff : a <= 0.0f ? 0x00 : (DWORD)(a * 255.0f + 0.5f); + + return (_a << 24) | (_r << 16) | (_g << 8) | _b; +} + +inline D3DXCOLOR::operator FLOAT * () +{ + return (FLOAT*)&r; +} + +inline D3DXCOLOR::operator CONST FLOAT * () const +{ + return (CONST FLOAT*)&r; +} + +inline D3DXCOLOR::operator D3DCOLORVALUE * () +{ + return (D3DCOLORVALUE*)&r; +} + +inline D3DXCOLOR::operator CONST D3DCOLORVALUE * () const +{ + return (CONST D3DCOLORVALUE*)&r; +} + +inline D3DXCOLOR::operator D3DCOLORVALUE& () +{ + return *((D3DCOLORVALUE*)&r); +} + +inline D3DXCOLOR::operator CONST D3DCOLORVALUE& () const +{ + return *((CONST D3DCOLORVALUE*)&r); +} + +inline D3DXCOLOR& D3DXCOLOR::operator += (CONST D3DXCOLOR& col) +{ + r += col.r; + g += col.g; + b += col.b; + a += col.a; + return *this; +} + +inline D3DXCOLOR& D3DXCOLOR::operator -= (CONST D3DXCOLOR& col) +{ + r -= col.r; + g -= col.g; + b -= col.b; + a -= col.a; + return *this; +} + +inline D3DXCOLOR& D3DXCOLOR::operator *= (FLOAT f) +{ + r *= f; + g *= f; + b *= f; + a *= f; + return *this; +} + +inline D3DXCOLOR& D3DXCOLOR::operator /= (FLOAT f) +{ + FLOAT inv = 1.0f / f; + r *= inv; + g *= inv; + b *= inv; + a *= inv; + return *this; +} + +inline D3DXCOLOR D3DXCOLOR::operator + () const +{ + return *this; +} + +inline D3DXCOLOR D3DXCOLOR::operator - () const +{ + return D3DXCOLOR(-r, -g, -b, -a); +} + +inline D3DXCOLOR D3DXCOLOR::operator + (CONST D3DXCOLOR& col) const +{ + return D3DXCOLOR(r + col.r, g + col.g, b + col.b, a + col.a); +} + +inline D3DXCOLOR D3DXCOLOR::operator - (CONST D3DXCOLOR& col) const +{ + return D3DXCOLOR(r - col.r, g - col.g, b - col.b, a - col.a); +} + +inline D3DXCOLOR D3DXCOLOR::operator * (FLOAT f) const +{ + return D3DXCOLOR(r * f, g * f, b * f, a * f); +} + +inline D3DXCOLOR D3DXCOLOR::operator / (FLOAT f) const +{ + FLOAT inv = 1.0f / f; + return D3DXCOLOR(r * inv, g * inv, b * inv, a * inv); +} + +inline D3DXCOLOR operator * (FLOAT f, CONST D3DXCOLOR& col) +{ + return D3DXCOLOR(f * col.r, f * col.g, f * col.b, f * col.a); +} + +inline BOOL D3DXCOLOR::operator == (CONST D3DXCOLOR& col) const +{ + return r == col.r && g == col.g && b == col.b && a == col.a; +} + +inline BOOL D3DXCOLOR::operator != (CONST D3DXCOLOR& col) const +{ + return r != col.r || g != col.g || b != col.b || a != col.a; +} + +#endif /* __cplusplus */ + +/*_______________D3DXCOLOR_____________________*/ + +static inline D3DXCOLOR* D3DXColorAdd(D3DXCOLOR *pout, CONST D3DXCOLOR *pc1, CONST D3DXCOLOR *pc2) +{ + if ( !pout || !pc1 || !pc2 ) return NULL; + pout->r = (pc1->r) + (pc2->r); + pout->g = (pc1->g) + (pc2->g); + pout->b = (pc1->b) + (pc2->b); + pout->a = (pc1->a) + (pc2->a); + return pout; +} + +static inline D3DXCOLOR* D3DXColorLerp(D3DXCOLOR *pout, CONST D3DXCOLOR *pc1, CONST D3DXCOLOR *pc2, FLOAT s) +{ + if ( !pout || !pc1 || !pc2 ) return NULL; + pout->r = (1-s) * (pc1->r) + s *(pc2->r); + pout->g = (1-s) * (pc1->g) + s *(pc2->g); + pout->b = (1-s) * (pc1->b) + s *(pc2->b); + pout->a = (1-s) * (pc1->a) + s *(pc2->a); + return pout; +} + +static inline D3DXCOLOR* D3DXColorModulate(D3DXCOLOR *pout, CONST D3DXCOLOR *pc1, CONST D3DXCOLOR *pc2) +{ + if ( !pout || !pc1 || !pc2 ) return NULL; + pout->r = (pc1->r) * (pc2->r); + pout->g = (pc1->g) * (pc2->g); + pout->b = (pc1->b) * (pc2->b); + pout->a = (pc1->a) * (pc2->a); + return pout; +} + +static inline D3DXCOLOR* D3DXColorNegative(D3DXCOLOR *pout, CONST D3DXCOLOR *pc) +{ + if ( !pout || !pc ) return NULL; + pout->r = 1.0f - pc->r; + pout->g = 1.0f - pc->g; + pout->b = 1.0f - pc->b; + pout->a = pc->a; + return pout; +} + +static inline D3DXCOLOR* D3DXColorScale(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, FLOAT s) +{ + if ( !pout || !pc ) return NULL; + pout->r = s* (pc->r); + pout->g = s* (pc->g); + pout->b = s* (pc->b); + pout->a = s* (pc->a); + return pout; +} + +static inline D3DXCOLOR* D3DXColorSubtract(D3DXCOLOR *pout, CONST D3DXCOLOR *pc1, CONST D3DXCOLOR *pc2) +{ + if ( !pout || !pc1 || !pc2 ) return NULL; + pout->r = (pc1->r) - (pc2->r); + pout->g = (pc1->g) - (pc2->g); + pout->b = (pc1->b) - (pc2->b); + pout->a = (pc1->a) - (pc2->a); + return pout; +} + +/*_______________D3DXVECTOR2________________________*/ + +static inline D3DXVECTOR2* D3DXVec2Add(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = pv1->x + pv2->x; + pout->y = pv1->y + pv2->y; + return pout; +} + +static inline FLOAT D3DXVec2CCW(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2) +{ + if ( !pv1 || !pv2) return 0.0f; + return ( (pv1->x) * (pv2->y) - (pv1->y) * (pv2->x) ); +} + +static inline FLOAT D3DXVec2Dot(CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2) +{ + if ( !pv1 || !pv2) return 0.0f; + return ( (pv1->x * pv2->x + pv1->y * pv2->y) ); +} + +static inline FLOAT D3DXVec2Length(CONST D3DXVECTOR2 *pv) +{ + if (!pv) return 0.0f; + return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) ); +} + +static inline FLOAT D3DXVec2LengthSq(CONST D3DXVECTOR2 *pv) +{ + if (!pv) return 0.0f; + return( (pv->x) * (pv->x) + (pv->y) * (pv->y) ); +} + +static inline D3DXVECTOR2* D3DXVec2Lerp(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, FLOAT s) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = (1-s) * (pv1->x) + s * (pv2->x); + pout->y = (1-s) * (pv1->y) + s * (pv2->y); + return pout; +} + +static inline D3DXVECTOR2* D3DXVec2Maximize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = max(pv1->x , pv2->x); + pout->y = max(pv1->y , pv2->y); + return pout; +} + +static inline D3DXVECTOR2* D3DXVec2Minimize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = min(pv1->x , pv2->x); + pout->y = min(pv1->y , pv2->y); + return pout; +} + +static inline D3DXVECTOR2* D3DXVec2Scale(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, FLOAT s) +{ + if ( !pout || !pv) return NULL; + pout->x = s * (pv->x); + pout->y = s * (pv->y); + return pout; +} + +static inline D3DXVECTOR2* D3DXVec2Subtract(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = pv1->x - pv2->x; + pout->y = pv1->y - pv2->y; + return pout; +} + +/*__________________D3DXVECTOR3_______________________*/ + +static inline D3DXVECTOR3* D3DXVec3Add(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = pv1->x + pv2->x; + pout->y = pv1->y + pv2->y; + pout->z = pv1->z + pv2->z; + return pout; +} + +static inline D3DXVECTOR3* D3DXVec3Cross(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = (pv1->y) * (pv2->z) - (pv1->z) * (pv2->y); + pout->y = (pv1->z) * (pv2->x) - (pv1->x) * (pv2->z); + pout->z = (pv1->x) * (pv2->y) - (pv1->y) * (pv2->x); + return pout; +} + +static inline FLOAT D3DXVec3Dot(CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2) +{ + if ( !pv1 || !pv2 ) return 0.0f; + return (pv1->x) * (pv2->x) + (pv1->y) * (pv2->y) + (pv1->z) * (pv2->z); +} + +static inline FLOAT D3DXVec3Length(CONST D3DXVECTOR3 *pv) +{ + if (!pv) return 0.0f; + return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) ); +} + +static inline FLOAT D3DXVec3LengthSq(CONST D3DXVECTOR3 *pv) +{ + if (!pv) return 0.0f; + return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z); +} + +static inline D3DXVECTOR3* D3DXVec3Lerp(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, FLOAT s) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = (1-s) * (pv1->x) + s * (pv2->x); + pout->y = (1-s) * (pv1->y) + s * (pv2->y); + pout->z = (1-s) * (pv1->z) + s * (pv2->z); + return pout; +} + +static inline D3DXVECTOR3* D3DXVec3Maximize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = max(pv1->x , pv2->x); + pout->y = max(pv1->y , pv2->y); + pout->z = max(pv1->z , pv2->z); + return pout; +} + +static inline D3DXVECTOR3* D3DXVec3Minimize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = min(pv1->x , pv2->x); + pout->y = min(pv1->y , pv2->y); + pout->z = min(pv1->z , pv2->z); + return pout; +} + +static inline D3DXVECTOR3* D3DXVec3Scale(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, FLOAT s) +{ + if ( !pout || !pv) return NULL; + pout->x = s * (pv->x); + pout->y = s * (pv->y); + pout->z = s * (pv->z); + return pout; +} + +static inline D3DXVECTOR3* D3DXVec3Subtract(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = pv1->x - pv2->x; + pout->y = pv1->y - pv2->y; + pout->z = pv1->z - pv2->z; + return pout; +} +/*__________________D3DXVECTOR4_______________________*/ + +static inline D3DXVECTOR4* D3DXVec4Add(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = pv1->x + pv2->x; + pout->y = pv1->y + pv2->y; + pout->z = pv1->z + pv2->z; + pout->w = pv1->w + pv2->w; + return pout; +} + +static inline FLOAT D3DXVec4Dot(CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2) +{ + if (!pv1 || !pv2 ) return 0.0f; + return (pv1->x) * (pv2->x) + (pv1->y) * (pv2->y) + (pv1->z) * (pv2->z) + (pv1->w) * (pv2->w); +} + +static inline FLOAT D3DXVec4Length(CONST D3DXVECTOR4 *pv) +{ + if (!pv) return 0.0f; + return sqrt( (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w) ); +} + +static inline FLOAT D3DXVec4LengthSq(CONST D3DXVECTOR4 *pv) +{ + if (!pv) return 0.0f; + return (pv->x) * (pv->x) + (pv->y) * (pv->y) + (pv->z) * (pv->z) + (pv->w) * (pv->w); +} + +static inline D3DXVECTOR4* D3DXVec4Lerp(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, FLOAT s) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = (1-s) * (pv1->x) + s * (pv2->x); + pout->y = (1-s) * (pv1->y) + s * (pv2->y); + pout->z = (1-s) * (pv1->z) + s * (pv2->z); + pout->w = (1-s) * (pv1->w) + s * (pv2->w); + return pout; +} + + +static inline D3DXVECTOR4* D3DXVec4Maximize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = max(pv1->x , pv2->x); + pout->y = max(pv1->y , pv2->y); + pout->z = max(pv1->z , pv2->z); + pout->w = max(pv1->w , pv2->w); + return pout; +} + +static inline D3DXVECTOR4* D3DXVec4Minimize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = min(pv1->x , pv2->x); + pout->y = min(pv1->y , pv2->y); + pout->z = min(pv1->z , pv2->z); + pout->w = min(pv1->w , pv2->w); + return pout; +} + +static inline D3DXVECTOR4* D3DXVec4Scale(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv, FLOAT s) +{ + if ( !pout || !pv) return NULL; + pout->x = s * (pv->x); + pout->y = s * (pv->y); + pout->z = s * (pv->z); + pout->w = s * (pv->w); + return pout; +} + +static inline D3DXVECTOR4* D3DXVec4Subtract(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2) +{ + if ( !pout || !pv1 || !pv2) return NULL; + pout->x = pv1->x - pv2->x; + pout->y = pv1->y - pv2->y; + pout->z = pv1->z - pv2->z; + pout->w = pv1->w - pv2->w; + return pout; +} + +/*__________________D3DXMatrix____________________*/ +#ifdef NONAMELESSUNION +# define D3DX_U(x) (x).u +#else +# define D3DX_U(x) (x) +#endif + +static inline D3DXMATRIX* D3DXMatrixIdentity(D3DXMATRIX *pout) +{ + if ( !pout ) return NULL; + D3DX_U(*pout).m[0][1] = 0.0f; + D3DX_U(*pout).m[0][2] = 0.0f; + D3DX_U(*pout).m[0][3] = 0.0f; + D3DX_U(*pout).m[1][0] = 0.0f; + D3DX_U(*pout).m[1][2] = 0.0f; + D3DX_U(*pout).m[1][3] = 0.0f; + D3DX_U(*pout).m[2][0] = 0.0f; + D3DX_U(*pout).m[2][1] = 0.0f; + D3DX_U(*pout).m[2][3] = 0.0f; + D3DX_U(*pout).m[3][0] = 0.0f; + D3DX_U(*pout).m[3][1] = 0.0f; + D3DX_U(*pout).m[3][2] = 0.0f; + D3DX_U(*pout).m[0][0] = 1.0f; + D3DX_U(*pout).m[1][1] = 1.0f; + D3DX_U(*pout).m[2][2] = 1.0f; + D3DX_U(*pout).m[3][3] = 1.0f; + return pout; +} + +static inline BOOL D3DXMatrixIsIdentity(D3DXMATRIX *pm) +{ + int i,j; + D3DXMATRIX testmatrix; + + if ( !pm ) return FALSE; + D3DXMatrixIdentity(&testmatrix); + for (i=0; i<4; i++) + { + for (j=0; j<4; j++) + { + if ( D3DX_U(*pm).m[i][j] != D3DX_U(testmatrix).m[i][j] ) return FALSE; + } + } + return TRUE; +} +#undef D3DX_U + +/*__________________D3DXPLANE____________________*/ + +static inline FLOAT D3DXPlaneDot(CONST D3DXPLANE *pp, CONST D3DXVECTOR4 *pv) +{ + if ( !pp || !pv ) return 0.0f; + return ( (pp->a) * (pv->x) + (pp->b) * (pv->y) + (pp->c) * (pv->z) + (pp->d) * (pv->w) ); +} + +static inline FLOAT D3DXPlaneDotCoord(CONST D3DXPLANE *pp, CONST D3DXVECTOR4 *pv) +{ + if ( !pp || !pv ) return 0.0f; + return ( (pp->a) * (pv->x) + (pp->b) * (pv->y) + (pp->c) * (pv->z) + (pp->d) ); +} + +static inline FLOAT D3DXPlaneDotNormal(CONST D3DXPLANE *pp, CONST D3DXVECTOR4 *pv) +{ + if ( !pp || !pv ) return 0.0f; + return ( (pp->a) * (pv->x) + (pp->b) * (pv->y) + (pp->c) * (pv->z) ); +} + +/*__________________D3DXQUATERNION____________________*/ + +static inline D3DXQUATERNION* D3DXQuaternionConjugate(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) +{ + if ( !pout || !pq) return NULL; + pout->x = -pq->x; + pout->y = -pq->y; + pout->z = -pq->z; + pout->w = pq->w; + return pout; +} + +static inline FLOAT D3DXQuaternionDot(CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2) +{ + if ( !pq1 || !pq2 ) return 0.0f; + return (pq1->x) * (pq2->x) + (pq1->y) * (pq2->y) + (pq1->z) * (pq2->z) + (pq1->w) * (pq2->w); +} + +static inline D3DXQUATERNION* D3DXQuaternionIdentity(D3DXQUATERNION *pout) +{ + if ( !pout) return NULL; + pout->x = 0.0f; + pout->y = 0.0f; + pout->z = 0.0f; + pout->w = 1.0f; + return pout; +} + +static inline BOOL D3DXQuaternionIsIdentity(D3DXQUATERNION *pq) +{ + if ( !pq) return FALSE; + return ( (pq->x == 0.0f) && (pq->y == 0.0f) && (pq->z == 0.0f) && (pq->w == 1.0f) ); +} + +static inline FLOAT D3DXQuaternionLength(CONST D3DXQUATERNION *pq) +{ + if (!pq) return 0.0f; + return sqrt( (pq->x) * (pq->x) + (pq->y) * (pq->y) + (pq->z) * (pq->z) + (pq->w) * (pq->w) ); +} + +static inline FLOAT D3DXQuaternionLengthSq(CONST D3DXQUATERNION *pq) +{ + if (!pq) return 0.0f; + return (pq->x) * (pq->x) + (pq->y) * (pq->y) + (pq->z) * (pq->z) + (pq->w) * (pq->w); +} + +#endif diff --git a/include/mshtmdid.h b/include/mshtmdid.h index 9a5e2e9a9c9..589b18f6fb9 100644 --- a/include/mshtmdid.h +++ b/include/mshtmdid.h @@ -1946,6 +1946,53 @@ #define DISPID_IHTMLTEXTCONTAINER_SCROLLLEFT DISPID_TEXTSITE+5 #define DISPID_IHTMLTEXTCONTAINER_ONSCROLL DISPID_EVPROP_ONSCROLL +/* IHTMLTableCaption */ +#define DISPID_IHTMLTABLECAPTION_ALIGN STDPROPID_XOBJ_BLOCKALIGN +#define DISPID_IHTMLTABLECAPTION_VALIGN DISPID_A_TABLEVALIGN + +/* IHTMLTable */ +#define DISPID_IHTMLTABLE_COLS DISPID_TABLE+1 +#define DISPID_IHTMLTABLE_BORDER DISPID_TABLE+2 +#define DISPID_IHTMLTABLE_FRAME DISPID_TABLE+4 +#define DISPID_IHTMLTABLE_RULES DISPID_TABLE+3 +#define DISPID_IHTMLTABLE_CELLSPACING DISPID_TABLE+5 +#define DISPID_IHTMLTABLE_CELLPADDING DISPID_TABLE+6 +#define DISPID_IHTMLTABLE_BACKGROUND DISPID_A_BACKGROUNDIMAGE +#define DISPID_IHTMLTABLE_BGCOLOR DISPID_BACKCOLOR +#define DISPID_IHTMLTABLE_BORDERCOLOR DISPID_A_TABLEBORDERCOLOR +#define DISPID_IHTMLTABLE_BORDERCOLORLIGHT DISPID_A_TABLEBORDERCOLORLIGHT +#define DISPID_IHTMLTABLE_BORDERCOLORDARK DISPID_A_TABLEBORDERCOLORDARK +#define DISPID_IHTMLTABLE_ALIGN STDPROPID_XOBJ_CONTROLALIGN +#define DISPID_IHTMLTABLE_REFRESH DISPID_TABLE+15 +#define DISPID_IHTMLTABLE_ROWS DISPID_TABLE+16 +#define DISPID_IHTMLTABLE_WIDTH STDPROPID_XOBJ_WIDTH +#define DISPID_IHTMLTABLE_HEIGHT STDPROPID_XOBJ_HEIGHT +#define DISPID_IHTMLTABLE_DATAPAGESIZE DISPID_TABLE+17 +#define DISPID_IHTMLTABLE_NEXTPAGE DISPID_TABLE+18 +#define DISPID_IHTMLTABLE_PREVIOUSPAGE DISPID_TABLE+19 +#define DISPID_IHTMLTABLE_THEAD DISPID_TABLE+20 +#define DISPID_IHTMLTABLE_TFOOT DISPID_TABLE+21 +#define DISPID_IHTMLTABLE_TBODIES DISPID_TABLE+24 +#define DISPID_IHTMLTABLE_CAPTION DISPID_TABLE+25 +#define DISPID_IHTMLTABLE_CREATETHEAD DISPID_TABLE+26 +#define DISPID_IHTMLTABLE_DELETETHEAD DISPID_TABLE+27 +#define DISPID_IHTMLTABLE_CREATETFOOT DISPID_TABLE+28 +#define DISPID_IHTMLTABLE_DELETETFOOT DISPID_TABLE+29 +#define DISPID_IHTMLTABLE_CREATECAPTION DISPID_TABLE+30 +#define DISPID_IHTMLTABLE_DELETECAPTION DISPID_TABLE+31 +#define DISPID_IHTMLTABLE_INSERTROW DISPID_TABLE+32 +#define DISPID_IHTMLTABLE_DELETEROW DISPID_TABLE+33 +#define DISPID_IHTMLTABLE_READYSTATE DISPID_A_READYSTATE +#define DISPID_IHTMLTABLE_ONREADYSTATECHANGE DISPID_EVPROP_ONREADYSTATECHANGE + +/* IHTMLTableSection */ +#define DISPID_IHTMLTABLESECTION_ALIGN STDPROPID_XOBJ_BLOCKALIGN +#define DISPID_IHTMLTABLESECTION_VALIGN DISPID_A_TABLEVALIGN +#define DISPID_IHTMLTABLESECTION_BGCOLOR DISPID_BACKCOLOR +#define DISPID_IHTMLTABLESECTION_ROWS DISPID_TABLESECTION +#define DISPID_IHTMLTABLESECTION_INSERTROW DISPID_TABLESECTION+1 +#define DISPID_IHTMLTABLESECTION_DELETEROW DISPID_TABLESECTION+2 + /* IHTMLFrameBase2 */ #define DISPID_IHTMLFRAMEBASE2_CONTENTWINDOW DISPID_FRAMESITE+9 #define DISPID_IHTMLFRAMEBASE2_ONLOAD DISPID_EVPROP_ONLOAD diff --git a/include/mshtml.idl b/include/mshtml.idl index b25c5e42c72..067bf387d8b 100644 --- a/include/mshtml.idl +++ b/include/mshtml.idl @@ -6237,6 +6237,432 @@ coclass HTMLDocument } /***************************************************************************** + * HTMLTableEvents dispinterface + */ +[ + hidden, + uuid(3050f407-98b5-11cf-bb82-00aa00bdce0b) +] +dispinterface HTMLTableEvents +{ +properties: +methods: + [id(DISPID_HTMLELEMENTEVENTS_ONHELP)] + VARIANT_BOOL onhelp(); + + [id(DISPID_HTMLELEMENTEVENTS_ONCLICK)] + VARIANT_BOOL onclick(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDBLCLICK)] + VARIANT_BOOL ondblclick(); + + [id(DISPID_HTMLELEMENTEVENTS_ONKEYPRESS)] + VARIANT_BOOL onkeypress(); + + [id(DISPID_HTMLELEMENTEVENTS_ONKEYDOWN)] + void onkeydown(); + + [id(DISPID_HTMLELEMENTEVENTS_ONKEYUP)] + void onkeyup(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEOUT)] + void onmouseout(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEOVER)] + void onmouseover(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEMOVE)] + void onmousemove(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEDOWN)] + void onmousedown(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEUP)] + void onmouseup(); + + [id(DISPID_HTMLELEMENTEVENTS_ONSELECTSTART)] + VARIANT_BOOL onselectstart(); + + [id(DISPID_HTMLELEMENTEVENTS_ONFILTERCHANGE)] + void onfilterchange(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDRAGSTART)] + VARIANT_BOOL ondragstart(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREUPDATE)] + VARIANT_BOOL onbeforeupdate(); + + [id(DISPID_HTMLELEMENTEVENTS_ONAFTERUPDATE)] + void onafterupdate(); + + [id(DISPID_HTMLELEMENTEVENTS_ONERRORUPDATE)] + VARIANT_BOOL onerrorupdate(); + + [id(DISPID_HTMLELEMENTEVENTS_ONROWEXIT)] + VARIANT_BOOL onrowexit(); + + [id(DISPID_HTMLELEMENTEVENTS_ONROWENTER)] + void onrowenter(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDATASETCHANGED)] + void ondatasetchanged(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDATAAVAILABLE)] + void ondataavailable(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDATASETCOMPLETE)] + void ondatasetcomplete(); + + [id(DISPID_HTMLELEMENTEVENTS_ONLOSECAPTURE)] + void onlosecapture(); + + [id(DISPID_HTMLELEMENTEVENTS_ONPROPERTYCHANGE)] + void onpropertychange(); + + [id(DISPID_HTMLELEMENTEVENTS_ONSCROLL)] + void onscroll(); + + [id(DISPID_HTMLELEMENTEVENTS_ONFOCUS)] + void onfocus(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBLUR)] + void onblur(); + + [id(DISPID_HTMLELEMENTEVENTS_ONRESIZE)] + void onresize(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDRAG)] + VARIANT_BOOL ondrag(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDRAGEND)] + void ondragend(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDRAGENTER)] + VARIANT_BOOL ondragenter(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDRAGOVER)] + VARIANT_BOOL ondragover(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDRAGLEAVE)] + void ondragleave(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDROP)] + VARIANT_BOOL ondrop(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBEFORECUT)] + VARIANT_BOOL onbeforecut(); + + [id(DISPID_HTMLELEMENTEVENTS_ONCUT)] + VARIANT_BOOL oncut(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBEFORECOPY)] + VARIANT_BOOL onbeforecopy(); + + [id(DISPID_HTMLELEMENTEVENTS_ONCOPY)] + VARIANT_BOOL oncopy(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREPASTE)] + VARIANT_BOOL onbeforepaste(); + + [id(DISPID_HTMLELEMENTEVENTS_ONPASTE)] + VARIANT_BOOL onpaste(); + + [id(DISPID_HTMLELEMENTEVENTS_ONCONTEXTMENU)] + VARIANT_BOOL oncontextmenu(); + + [id(DISPID_HTMLELEMENTEVENTS_ONROWSDELETE)] + void onrowsdelete(); + + [id(DISPID_HTMLELEMENTEVENTS_ONROWSINSERTED)] + void onrowsinserted(); + + [id(DISPID_HTMLELEMENTEVENTS_ONCELLCHANGE)] + void oncellchange(); + + [id(DISPID_HTMLELEMENTEVENTS_ONREADYSTATECHANGE)] + void onreadystatechange(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREEDITFOCUS)] + void onbeforeeditfocus(); + + [id(DISPID_HTMLELEMENTEVENTS_ONLAYOUTCOMPLETE)] + void onlayoutcomplete(); + + [id(DISPID_HTMLELEMENTEVENTS_ONPAGE)] + void onpage(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREDEACTIVATE)] + VARIANT_BOOL onbeforedeactivate(); + + [id(DISPID_HTMLELEMENTEVENTS_ONBEFOREACTIVATE)] + VARIANT_BOOL onbeforeactivate(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOVE)] + void onmove(); + + [id(DISPID_HTMLELEMENTEVENTS_ONCONTROLSELECT)] + VARIANT_BOOL oncontrolselect(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOVESTART)] + VARIANT_BOOL onmovestart(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOVEEND)] + void onmoveend(); + + [id(DISPID_HTMLELEMENTEVENTS_ONRESIZESTART)] + VARIANT_BOOL onresizestart(); + + [id(DISPID_HTMLELEMENTEVENTS_ONRESIZEEND)] + void onresizeend(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEENTER)] + void onmouseenter(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSELEAVE)] + void onmouseleave(); + + [id(DISPID_HTMLELEMENTEVENTS_ONMOUSEWHEEL)] + VARIANT_BOOL onmousewheel(); + + [id(DISPID_HTMLELEMENTEVENTS_ONACTIVATE)] + void onactivate(); + + [id(DISPID_HTMLELEMENTEVENTS_ONDEACTIVATE)] + void ondeactivate(); + + [id(DISPID_HTMLELEMENTEVENTS_ONFOCUSIN)] + void onfocusin(); + + [id(DISPID_HTMLELEMENTEVENTS_ONFOCUSOUT)] + void onfocusout(); +} + +/***************************************************************************** + * IHTMLTableCaption interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f2eb-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLTableCaption : IDispatch +{ + [propput, id(DISPID_IHTMLTABLECAPTION_ALIGN)] + HRESULT align([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLECAPTION_ALIGN)] + HRESULT align([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLTABLECAPTION_VALIGN)] + HRESULT vAlign([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLECAPTION_VALIGN)] + HRESULT vAlign([retval, out] BSTR *p); +} + +interface IHTMLTableSection; + +/***************************************************************************** + * IHTMLTable interface + */ +[ + odl, + oleautomation, + dual, + uuid(3050f21e-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLTable : IDispatch +{ + [propput, id(DISPID_IHTMLTABLE_COLS)] + HRESULT cols([in] long v); + + [propget, id(DISPID_IHTMLTABLE_COLS)] + HRESULT cols([retval, out] long *p); + + [propput, id(DISPID_IHTMLTABLE_BORDER)] + HRESULT border([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_BORDER)] + HRESULT border([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_FRAME)] + HRESULT frame([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLE_FRAME)] + HRESULT frame([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLTABLE_RULES)] + HRESULT rules([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLE_RULES)] + HRESULT rules([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLTABLE_CELLSPACING)] + HRESULT cellSpacing([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_CELLSPACING)] + HRESULT cellSpacing([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_CELLPADDING)] + HRESULT cellPadding([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_CELLPADDING)] + HRESULT cellPadding([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_BACKGROUND)] + HRESULT background([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLE_BACKGROUND)] + HRESULT background([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLTABLE_BGCOLOR)] + HRESULT bgColor([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_BGCOLOR)] + HRESULT bgColor([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_BORDERCOLOR)] + HRESULT borderColor([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_BORDERCOLOR)] + HRESULT borderColor([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_BORDERCOLORLIGHT)] + HRESULT borderColorLight([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_BORDERCOLORLIGHT)] + HRESULT borderColorLight([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_BORDERCOLORDARK)] + HRESULT borderColorDark([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_BORDERCOLORDARK)] + HRESULT borderColorDark([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_ALIGN)] + HRESULT align([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLE_ALIGN)] + HRESULT align([retval, out] BSTR * p); + + [id(DISPID_IHTMLTABLE_REFRESH)] + HRESULT refresh(); + + [propget, id(DISPID_IHTMLTABLE_ROWS)] + HRESULT rows([retval, out] IHTMLElementCollection **p); + + [propput, id(DISPID_IHTMLTABLE_WIDTH)] + HRESULT width([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_WIDTH)] + HRESULT width([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_HEIGHT)] + HRESULT height([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_HEIGHT)] + HRESULT height([retval, out] VARIANT *p); + + [propput, id(DISPID_IHTMLTABLE_DATAPAGESIZE)] + HRESULT dataPageSize([in] long v); + + [propget, id(DISPID_IHTMLTABLE_DATAPAGESIZE)] + HRESULT dataPageSize([retval, out] long *p); + + [id(DISPID_IHTMLTABLE_NEXTPAGE)] + HRESULT nextPage(); + + [id(DISPID_IHTMLTABLE_PREVIOUSPAGE)] + HRESULT previousPage(); + + [propget, id(DISPID_IHTMLTABLE_THEAD)] + HRESULT tHead([retval, out] IHTMLTableSection **p); + + [propget, id(DISPID_IHTMLTABLE_TFOOT)] + HRESULT tFoot([retval, out] IHTMLTableSection **p); + + [propget, id(DISPID_IHTMLTABLE_TBODIES)] + HRESULT tBodies([retval, out] IHTMLElementCollection **p); + + [propget, id(DISPID_IHTMLTABLE_CAPTION)] + HRESULT caption([retval, out] IHTMLTableCaption **p); + + [id(DISPID_IHTMLTABLE_CREATETHEAD)] + HRESULT createTHead([retval, out] IDispatch **head); + + [id(DISPID_IHTMLTABLE_DELETETHEAD)] + HRESULT deleteTHead(); + + [id(DISPID_IHTMLTABLE_CREATETFOOT)] + HRESULT createTFoot([retval, out] IDispatch **foot); + + [id(DISPID_IHTMLTABLE_DELETETFOOT)] + HRESULT deleteTFoot(); + + [id(DISPID_IHTMLTABLE_CREATECAPTION)] + HRESULT createCaption([retval, out] IHTMLTableCaption **caption); + + [id(DISPID_IHTMLTABLE_DELETECAPTION)] + HRESULT deleteCaption(); + + [id(DISPID_IHTMLTABLE_INSERTROW)] + HRESULT insertRow( + [defaultvalue(-1), in] long index, + [retval, out] IDispatch **row); + + [id(DISPID_IHTMLTABLE_DELETEROW)] + HRESULT deleteRow([defaultvalue(-1), in] long index); + + [propget, id(DISPID_IHTMLTABLE_READYSTATE)] + HRESULT readyState([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLTABLE_ONREADYSTATECHANGE), displaybind, bindable] + HRESULT onreadystatechange([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLE_ONREADYSTATECHANGE), displaybind, bindable] + HRESULT onreadystatechange([retval, out] VARIANT *p); +} + +[ + odl, + oleautomation, + dual, + uuid(3050f23b-98b5-11cf-bb82-00aa00bdce0b) +] +interface IHTMLTableSection : IDispatch +{ + [propput, id(DISPID_IHTMLTABLESECTION_ALIGN)] + HRESULT align([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLESECTION_ALIGN)] + HRESULT align([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLTABLESECTION_VALIGN)] + HRESULT vAlign([in] BSTR v); + + [propget, id(DISPID_IHTMLTABLESECTION_VALIGN)] + HRESULT vAlign([retval, out] BSTR *p); + + [propput, id(DISPID_IHTMLTABLESECTION_BGCOLOR)] + HRESULT bgColor([in] VARIANT v); + + [propget, id(DISPID_IHTMLTABLESECTION_BGCOLOR)] + HRESULT bgColor([retval, out] VARIANT *p); + + [propget, id(DISPID_IHTMLTABLESECTION_ROWS)] + HRESULT rows([retval, out] IHTMLElementCollection **p); + + [id(DISPID_IHTMLTABLESECTION_INSERTROW)] + HRESULT insertRow( + [defaultvalue(-1), in] long index, + [retval, out] IDispatch **row); + + [id(DISPID_IHTMLTABLESECTION_DELETEROW)] + HRESULT deleteRow([defaultvalue(-1), in] long index); +} + +/***************************************************************************** * IHTMLFrameBase2 interface */ [ diff --git a/include/wincrypt.h b/include/wincrypt.h index aa6ae2e1678..bf15b9309f3 100644 --- a/include/wincrypt.h +++ b/include/wincrypt.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2002 Travis Michielsen * Copyright (C) 2004-2005 Juan Lang + * Copyright (C) 2007 Vijay Kiran Kamuju * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -134,6 +135,53 @@ typedef struct _RSAPUBKEY { DWORD pubexp; } RSAPUBKEY; +typedef struct _PUBKEY { + DWORD magic; + DWORD bitlen; +} DHPUBKEY, DSSPUBKEY, KEAPUBKEY, TEKPUBKEY; + +typedef struct _DSSSEED { + DWORD counter; + BYTE seed[20]; +} DSSSEED; + +typedef struct _PUBKEYVER3 { + DWORD magic; + DWORD bitlenP; + DWORD bitlenQ; + DWORD bitlenJ; + DSSSEED DSSSeed; +} DHPUBKEY_VER3, DSSPUBKEY_VER3; + +typedef struct _PRIVKEYVER3 { + DWORD magic; + DWORD bitlenP; + DWORD bitlenQ; + DWORD bitlenJ; + DWORD bitlenX; + DSSSEED DSSSeed; +} DHPRIVKEY_VER3, DSSPRIVKEY_VER3; + +typedef struct _KEY_TYPE_SUBTYPE { + DWORD dwKeySpec; + GUID Type; + GUID SubType; +} KEY_TYPE_SUBTYPE, *PKEY_TYPE_SUBTYPE; + +typedef struct _CERT_FORTEZZA_DATA_PROP { + unsigned char SerialNumber[8]; + int CertIndex; + unsigned char CertLabel[36]; +} CERT_FORTEZZA_DATA_PROP; + +typedef struct _CMS_DH_KEY_INFO { + DWORD dwVersion; + ALG_ID Algid; + LPSTR pszContentEncObjId; + CRYPT_DATA_BLOB PubInfo; + void *pReserved; +} CMS_DH_KEY_INFO, *PCMS_DH_KEY_INFO; + typedef struct _CRYPT_BIT_BLOB { DWORD cbData; BYTE *pbData; @@ -561,6 +609,75 @@ typedef struct _CRL_CONTEXT { } CRL_CONTEXT, *PCRL_CONTEXT; typedef const CRL_CONTEXT *PCCRL_CONTEXT; +#define SORTED_CTL_EXT_FLAGS_OFFSET (0*4) +#define SORTED_CTL_EXT_COUNT_OFFSET (1*4) +#define SORTED_CTL_EXT_MAX_COLLISION_OFFSET (2*4) +#define SORTED_CTL_EXT_HASH_BUCKET_OFFSET (3*4) + +#define SORTED_CTL_EXT_HASHED_SUBJECT_IDENTIFIER_FLAG 0x1 + +typedef struct _CERT_DSS_PARAMETERS { + CRYPT_UINT_BLOB p; + CRYPT_UINT_BLOB q; + CRYPT_UINT_BLOB g; +} CERT_DSS_PARAMETERS, *PCERT_DSS_PARAMETERS; + +#define CERT_DSS_R_LEN 20 +#define CERT_DSS_S_LEN 20 +#define CERT_DSS_SIGNATURE_LEN (CERT_DSS_R_LEN + CERT_DSS_S_LEN) + +#define CERT_MAX_ENCODED_DSS_SIGNATURE_LEN (2 + 2*(2 + 20 +1)) + +typedef struct _CERT_DH_PARAMETERS { + CRYPT_UINT_BLOB p; + CRYPT_UINT_BLOB g; +} CERT_DH_PARAMETERS, *PCERT_DH_PARAMETERS; + +typedef struct _CERT_X942_DH_VALIDATION_PARAMS { + CRYPT_BIT_BLOB seed; + DWORD pgenCounter; +} CERT_X942_DH_VALIDATION_PARAMS, *PCERT_X942_DH_VALIDATION_PARAMS; + +typedef struct _CERT_X942_DH_PARAMETERS { + CRYPT_UINT_BLOB p; + CRYPT_UINT_BLOB g; + CRYPT_UINT_BLOB q; + CRYPT_UINT_BLOB j; + PCERT_X942_DH_VALIDATION_PARAMS pValidationParams; +} CERT_X942_DH_PARAMETERS, *PCERT_X942_DH_PARAMETERS; + +#define CRYPT_X942_COUNTER_BYTE_LENGTH 4 +#define CRYPT_X942_KEY_LENGTH_BYTE_LENGTH 4 +#define CRYPT_X942_PUB_INFO_BYTE_LENGTH (512/8) + +typedef struct _CRYPT_X942_OTHER_INFO { + LPSTR pszContentEncryptionObjId; + BYTE rgbCounter[CRYPT_X942_COUNTER_BYTE_LENGTH]; + BYTE rgbKeyLength[CRYPT_X942_KEY_LENGTH_BYTE_LENGTH]; + CRYPT_DATA_BLOB PubInfo; +} CRYPT_X942_OTHER_INFO, *PCRYPT_X942_OTHER_INFO; + +typedef struct _CRYPT_RC2_CBC_PARAMETERS { + DWORD dwVersion; + BOOL fIV; + BYTE rgbIV[4]; +} CRYPT_RC2_CBC_PARAMETERS, *PCRYPT_RC2_CBC_PARAMETERS; + +#define CRYPT_RC2_40BIT_VERSION 160 +#define CRYPT_RC2_56BIT_VERSION 52 +#define CRYPT_RC2_64BIT_VERSION 120 +#define CRYPT_RC2_128BIT_VERSION 58 + +typedef struct _CRYPT_SMIME_CAPABILITY { + LPSTR pszObjId; + CRYPT_OBJID_BLOB Parameters; +} CRYPT_SMIME_CAPABILITY, *PCRYPT_SMIME_CAPABILITY; + +typedef struct _CRYPT_SMIME_CAPABILITIES { + DWORD cCapability; + CRYPT_SMIME_CAPABILITY rgCapability; +} CRYPT_SMIME_CAPABILITIES, *PCRYPT_SMIME_CAPABILITIES; + typedef struct _VTableProvStruc { DWORD Version; FARPROC pFuncVerifyImage; @@ -1804,6 +1921,19 @@ static const WCHAR MS_ENH_RSA_AES_PROV_W[] = { 'M','i','c','r','o','s' #define KP_KEYEXCHANGE_PIN 32 #define KP_SIGNATURE_PIN 33 #define KP_PREHASH 34 +#define KP_ROUNDS 35 +#define KP_OAEP_PARAMS 36 +#define KP_CMS_KEY_INFO 37 +#define KP_CMS_DH_KEY_INFO 38 +#define KP_PUB_PARAMS 39 +#define KP_VERIFY_PARAMS 40 +#define KP_HIGHEST_VERSION 41 +#define KP_GET_USE_COUNT 42 + +/* Values for KP_PADDING */ +#define PKCS5_PADDING 1 +#define RANDOM_PADDING 2 +#define ZERO_PADDING 3 /* CryptSignHash/CryptVerifySignature */ #define CRYPT_NOHASHOID 0x00000001 diff --git a/include/wine/wined3d_gl.h b/include/wine/wined3d_gl.h index b3460640d6d..ec2edaf1a5e 100644 --- a/include/wine/wined3d_gl.h +++ b/include/wine/wined3d_gl.h @@ -2866,6 +2866,17 @@ typedef void (WINE_GLAPI * PGLFNFINISHRENDERAPPLEPROC) (void); #define UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB #endif +/* GL_ARB_texture_rectangle */ +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#endif + /* GL_VERSION_2_0 */ #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 @@ -3102,9 +3113,12 @@ typedef enum _GL_Cards { CARD_NVIDIA_GEFORCE_6200 = 0x014f, CARD_NVIDIA_GEFORCE_6600GT = 0x0140, CARD_NVIDIA_GEFORCE_6800 = 0x0041, + CARD_NVIDIA_GEFORCE_7400 = 0x01d8, + CARD_NVIDIA_GEFORCE_7600 = 0x0391, CARD_NVIDIA_GEFORCE_7800GT = 0x0092, CARD_NVIDIA_GEFORCE_8300GS = 0x0423, CARD_NVIDIA_GEFORCE_8600GT = 0x0402, + CARD_NVIDIA_GEFORCE_8600MGT = 0x0407, CARD_NVIDIA_GEFORCE_8800GTS = 0x0193, CARD_INTEL_845G = 0x2562, @@ -3165,6 +3179,7 @@ typedef enum _GL_SupportedExt { ARB_TEXTURE_BORDER_CLAMP, ARB_TEXTURE_MIRRORED_REPEAT, ARB_TEXTURE_NON_POWER_OF_TWO, + ARB_TEXTURE_RECTANGLE, ARB_VERTEX_PROGRAM, ARB_VERTEX_BLEND, ARB_VERTEX_BUFFER_OBJECT, @@ -3614,7 +3629,7 @@ typedef BOOL (WINAPI * WINED3D_PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, ****************************************************/ typedef struct { - GLint glInternal, glGammaInternal, glFormat, glType; + GLint glInternal, glGammaInternal, rtInternal, glFormat, glType; WINED3DFORMAT conversion_group; } GlPixelFormatDesc; diff --git a/libs/wine/loader.c b/libs/wine/loader.c index 2f782484441..13eb84af39f 100644 --- a/libs/wine/loader.c +++ b/libs/wine/loader.c @@ -668,6 +668,25 @@ void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize #ifdef HAVE_DLOPEN void *ret; const char *s; + +#ifdef __APPLE__ + /* the Mac OS loader pretends to be able to load PE files, so avoid them here */ + unsigned char magic[2]; + int fd = open( filename, O_RDONLY ); + if (fd != -1) + { + if (pread( fd, magic, 2, 0 ) == 2 && magic[0] == 'M' && magic[1] == 'Z') + { + static const char msg[] = "MZ format"; + size_t len = min( errorsize, sizeof(msg) ); + memcpy( error, msg, len ); + error[len - 1] = 0; + close( fd ); + return NULL; + } + close( fd ); + } +#endif dlerror(); dlerror(); #ifdef __sun if (strchr( filename, ':' )) diff --git a/programs/msiexec/msiexec.c b/programs/msiexec/msiexec.c index bdb1b90817a..6577c789a6a 100644 --- a/programs/msiexec/msiexec.c +++ b/programs/msiexec/msiexec.c @@ -209,7 +209,7 @@ static DWORD msi_atou(LPCWSTR str) ret += (*str - '0'); str++; } - return 0; + return ret; } static LPWSTR msi_strdup(LPCWSTR str) diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index a71961ea456..2c56d8fdf91 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -201,7 +201,7 @@ static BOOL CALLBACK info_mod_cb(PCSTR mod_name, DWORD64 base, PVOID ctx) void info_win32_module(DWORD64 base) { struct info_module im; - int i, j, num_printed = 0; + UINT i, j, num_printed = 0; DWORD opt; if (!dbg_curr_process) @@ -388,7 +388,6 @@ void info_win32_window(HWND hWnd, BOOL detailed) char wndName[128]; RECT clientRect; RECT windowRect; - int i; WORD w; if (!IsWindow(hWnd)) hWnd = GetDesktopWindow(); @@ -434,6 +433,8 @@ void info_win32_window(HWND hWnd, BOOL detailed) if (GetClassLong(hWnd, GCL_CBWNDEXTRA)) { + UINT i; + dbg_printf("Extra bytes:"); for (i = 0; i < GetClassLong(hWnd, GCL_CBWNDEXTRA) / 2; i++) { diff --git a/server/queue.c b/server/queue.c index f6d6ca44433..320bdb09b1c 100644 --- a/server/queue.c +++ b/server/queue.c @@ -407,7 +407,7 @@ static int merge_message( struct thread_input *input, const struct message *msg if (!ptr) return 0; prev = LIST_ENTRY( ptr, struct message, entry ); if (prev->result) return 0; - if (prev->win != msg->win) return 0; + if (prev->win && msg->win && prev->win != msg->win) return 0; if (prev->msg != msg->msg) return 0; if (prev->type != msg->type) return 0; /* now we can merge it */ diff --git a/tools/wine.inf b/tools/wine.inf index e4afa308b54..d4b2bedf3e5 100644 --- a/tools/wine.inf +++ b/tools/wine.inf @@ -206,7 +206,7 @@ HKCU,Software\Wine\Debug,"RelayFromExclude",2,"winex11.drv;user32;gdi32;advapi32 HKCU,%Desktop%,"FontSmoothing",2,"0" HKCU,%Desktop%,"DragFullWindows",2,"0" HKCU,%Desktop%,"SmoothScroll",3,00,00,00,00 -HKCU,%Desktop%,"UserPreferencemask",3,00,00,00,00 +HKCU,%Desktop%,"UserPreferencemask",3,10,00,00,00 HKCU,%Desktop%,"LowPowerActive",,"0" [Metrics] -- 2.11.4.GIT