diff -urN wine-20050524/ANNOUNCE wine-20050628/ANNOUNCE --- wine-20050524/ANNOUNCE 2005-05-24 16:16:16.000000000 +0200 +++ wine-20050628/ANNOUNCE 2005-06-28 16:39:19.000000000 +0200 @@ -1,14 +1,14 @@ -This is release 20050524 of Wine, a free implementation of Windows on +This is release 20050628 of Wine, a free implementation of Windows on Unix. This is still a developers only release. There are many bugs and unimplemented features. Most applications still do not work correctly. -WHAT'S NEW with Wine-20050524: (see ChangeLog for details) - - Many MSI improvements. - - More features in the file manager. - - Better compatibility for Winelib import libraries. - - SGML documentation moved out of the source tree. - - Header files cleanups. +WHAT'S NEW with Wine-20050628: (see ChangeLog for details) + - Configuration settings moved to the registry. + - Graphical Wine configuration tool is now enabled. + - More MSI and OLE improvements. + - Reorganisation of the DirectDraw directory. + - Initial support for webcams. - Lots of bug fixes. See the README file in the distribution for installation instructions. @@ -17,13 +17,13 @@ the release is available at the ftp sites. The sources will be available from the following locations: - http://www.ibiblio.org/pub/Linux/ALPHA/wine/development/Wine-20050524.tar.gz - http://prdownloads.sourceforge.net/wine/Wine-20050524.tar.gz + http://www.ibiblio.org/pub/Linux/ALPHA/wine/development/Wine-20050628.tar.gz + http://prdownloads.sourceforge.net/wine/Wine-20050628.tar.gz It should also be available from any other site that mirrors ibiblio.org. These locations also hold pre-built documentation packages in various -formats: wine-doc-html.tar.gz, wine-doc-txt.tar.gz, -wine-doc-pdf.tar.gz and wine-doc-ps.tar.gz. +formats: wine-doc-en-html.tar.gz, wine-doc-en-txt.tar.gz, +wine-doc-en-pdf.tar.gz and wine-doc-en-ps.tar.gz. You can also get the current source directly from the CVS tree. Check http://www.winehq.org/cvs for details. diff -urN wine-20050524/ChangeLog wine-20050628/ChangeLog --- wine-20050524/ChangeLog 2005-05-24 16:16:16.000000000 +0200 +++ wine-20050628/ChangeLog 2005-06-28 16:39:19.000000000 +0200 @@ -1,4 +1,3349 @@ ---------------------------------------------------------------- +2005-06-28 Alexandre Julliard + + * dlls/gdi/printdrv.c: + Moved spooler configuration to HKCU\Software\Wine\Printing\Spooler. + + * dlls/oleaut32/typelib.h, tools/widl/typelib_struct.h: + Huw Davies + Add comments describing the first DWORD in an import table entry. + + * dlls/advapi32/tests/security.c: + Mark as todo a couple of tests that currently fail. + + * dlls/riched20/caret.c, dlls/riched20/editor.c, + dlls/riched20/editor.h: + Phil Krylov + Implemented EM_GETTEXTLENGTHEX RichEdit message. + + * dlls/wineps/init.c, dlls/winspool/info.c: + Moved ppd file configuration to HKCU\Software\Wine\Printing\PPD Files. + + * dlls/ntdll/sec.c: James Hawkins + Forward RtlAddAccess* to add_access_ace. + + * tools/winapi/win32.api: James Hawkins + Add some missing types to win32.api. + + * dlls/oleaut32/variant.c: Michael Stefaniuc + - VarCmp: handle comparision of VT_EMPTY with an integer + - small comment fix + + * dlls/mshtml/Makefile.in, dlls/mshtml/htmldoc.c, + dlls/mshtml/mshtml_private.h, dlls/mshtml/oleobj.c, + dlls/mshtml/olewnd.c: + Jacek Caban + Added stub implementation of IOleInPlaceObjectWindowless. + + * include/winternl.h: Mike McCormack + Declare some Nt* functions. + +2005-06-27 Alexandre Julliard + + * dlls/winmm/lolvldrv.c: + Get rid of the WaveMapper and MidiMapper options, the defaults should + be good enough in all cases. + + * dlls/kernel/tests/comm.c: + Uwe Bonnes + Added test cases. However most added tests need a loopback plug and + need to be enabled in the code. + + * dlls/advapi32/tests/security.c: Robert Shearman + Test ACCESS_SYSTEM_SECURITY AccessCheck behaviour. + + * dlls/crypt32/encode.c: Juan Lang + - use exception handling in encoding + - consolidate integer encoders + + * dlls/mshtml/Makefile.in, dlls/mshtml/blank.htm, dlls/mshtml/rsrc.rc: + Jacek Caban + Added blank.htm. + + * dlls/psapi/tests/.cvsignore, dlls/psapi/tests/Makefile.in, + dlls/psapi/tests/module.c, dlls/psapi/tests/psapi_main.c: + Felix Nawothnig + Rewrote the psapi test suite. + + * tools/winebuild/build.h, tools/winebuild/import.c, + tools/winebuild/relay.c, tools/winebuild/spec32.c, + tools/winebuild/utils.c: + Replaced all uses of the __ASM_NAME macro by the asm_name function to + allow run-time determination of the correct format. + + * dlls/wineps/type1afm.c: + Moved AFM dirs configuration to a single AFMPath key under + HKCU\Software\Wine\Fonts. + + * dlls/winedos/ppdev.c: + Moved port configuration to HKCU\Software\Wine\VDM\ppdev. + + * dlls/winedos/ioports.c: + Moved I/O port configuration to HKCU\Software\Wine\VDM\Ports. + + * dlls/shell32/brsfolder.c: Aric Stewart + Fix the BrowseForFolder dialog so that when it does the callbacks it + uses the correct message instead of always sending BEFM_INITIALIZED. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Precisely compute the necessary pidl length in UNIXFS_path_to_pidl. + + * dlls/msi/dialog.c: Mike McCormack + Repaint the area behind the "transparent" text control when it + changes. + + * configure, configure.ac, dlls/ntdll/cdrom.c, include/config.h.in: + Dmitry Timoshkov + Add a check for sg_io_hdr_t and (not tested) check for scsireq_t + presence. + + * dlls/itss/itss.spec: Jacek Caban + Export DllMain as native does. + + * dlls/kernel/thread.c: Eric Pouech + Implemented OpenThread on top of NtOpenThread. + + * tools/winebuild/build.h, tools/winebuild/import.c, + tools/winebuild/main.c, tools/winebuild/parser.c, + tools/winebuild/relay.c, tools/winebuild/spec32.c, + tools/winebuild/utils.c: + Beginnings of an infrastructure to allow specifying the target CPU and + platform at run-time. + + * configure, configure.ac, dlls/mshtml/Makefile.in, + dlls/mshtml/tests/.cvsignore, dlls/mshtml/tests/Makefile.in, + dlls/mshtml/tests/htmldoc.c: + Jacek Caban + Added tests. + + * dlls/kernel/process.c, dlls/ntdll/ntdll.spec, dlls/ntdll/process.c, + include/winternl.h: + Eric Pouech + Implemented OpenProcess on top of NtOpenProcess. + + * dlls/mlang/mlang.c, dlls/mlang/mlang.spec, include/mlang.idl: + Vitaly Lipatov + Changes stub to FIXME for GetGlobalFontLinkObject. + + * dlls/gdi/tests/bitmap.c: + Felix Nawothnig + Report a todo and skip DIB tests when they fail at a non-truecolor + screen depth. + + * include/winnt.h: Mike McCormack + Add pointer types for token structures. + + * dlls/msvcrt/tests/time.c, dlls/ntdll/tests/path.c, + dlls/ntdll/tests/string.c, dlls/oleaut32/tests/olepicture.c, + dlls/shlwapi/tests/string.c, dlls/urlmon/tests/url.c, + dlls/user/tests/menu.c, programs/start/start.c: + Stefan Huehner + Fix some -Wstrict-prototypes warnings. + + * dlls/kernel/console.c, dlls/kernel/tests/process.c, + dlls/msvcrt/console.c: + Eric Pouech + - OpenConsole: try to open the Unix console if we fail with wineserver + - kernel32: simplifying code for opening a console handle + - msvcrt: now correctly initializing the handles to the Windows + console + + * dlls/d3d9/device.c, dlls/dbghelp/dwarf.c, + dlls/dmstyle/commandtrack.c, dlls/iphlpapi/iphlpapi_main.c, + dlls/ole32/stg_prop.c, dlls/user/win.c, dlls/winsock/socket.c, + dlls/x11drv/dib.c, libs/unicode/cptable.c, tools/wrc/parser.y: + Eric Pouech + Const correctness fixes. + + * dlls/mshtml/Makefile.in, dlls/mshtml/main.c, + dlls/mshtml/mshtml_private.h, dlls/mshtml/protocol.c: + Jacek Caban + Added stub implementation of about and res protocols. + + * include/basetsd.h: Mike McCormack + Define KAFFINITY. + + * dlls/rasapi32/rasapi.c, include/ras.h: + Mike McCormack + Declare and fix function prototypes. + + * dlls/kernel/tests/file.c: Jacek Caban + Fix test on NT 4. + + * programs/wcmd/builtins.c, programs/wcmd/wcmdmain.c: + Andreas Mohr + Constify wcmd. + + * programs/winecfg/appdefaults.c, programs/winecfg/audio.c, + programs/winecfg/drivedetect.c, programs/winecfg/properties.c, + programs/winecfg/properties.h: + Andreas Mohr + Constify all needlessly non-const winecfg structs. + + * dlls/opengl32/make_opengl, dlls/opengl32/opengl_ext.c, + dlls/opengl32/opengl_norm.c: + Eric Pouech + Now generating argument-less functions as (void) instead of (). + + * dlls/winmm/mciavi/wnd.c: Eric Pouech + Fixed window size computation for non child windows. + + * include/winternl.h: Mike McCormack + Declare some Nt* functions. + + * include/winbase.h, include/winnt.h: + Mike McCormack + DUPLICATE_* flags should be defined in winnt.h. + + * dlls/shdocvw/shdocvw_main.c: cjacek + Fix typo in comment about Wine registry key. + + * programs/winemine/main.c: Jacek Caban + Added winemine debug channel. + + * dlls/user/edit.c: Jacek Caban + Better notify macro + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + - implement encode and decode of BasicConstraints2, sequence of any + - fix encoding of integer value 0 + - more tests + + * dlls/shell32/tests/shlfolder.c: + Saulius Krasuckas + Additional test cases for IShellFolder_BindToObject. + +2005-06-25 Alexandre Julliard + + * dlls/winsock/async.c, dlls/winsock/protocol.c, dlls/winsock/socket.c, + include/ws2spi.h: + Hans Leidekker + Fix some -Wmissing-declarations warnings. + "errno" is not a good choice for a parameter name. + + * dlls/kernel/kernel16_private.h, tools/winebuild/spec16.c: + Remove some i386 ifdefs for 16-bit entry points since they are no + longer used by default on other platforms anyway. + + * dlls/user/ddeml.spec: Andreas Mohr + Fix some 16-bit return values. + + * dlls/shell32/shlfolder.c: Michael Jung + Fix a lurking infinite loop in SHGetPathFromIDList. + + * dlls/user/edit.c, dlls/user/tests/edit.c: + Michael Kaufmann + - Remove the old margins from the format rectangle before adding the + new margins. + - Adjust the format rectangle and repaint the control after the + margins have been set. + - New tests. + + * dlls/ntdll/critsection.c: Mike McCormack + - use STATUS_TIMEOUT instead of WAIT_TIMEOUT + - add RTL_ to one more CRITICAL_SECTION_DEBUG + + * dlls/ntdll/rtl.c: Mike McCormack + - NtWaitForSingleObject doesn't return WAIT_FAILED. + - Use STATUS_WAIT_0 not WAIT_OBJECT_0. + + * dlls/ntdll/exception.c: Mike McCormack + Use NT status codes for exceptions. + + * dlls/mshtml/main.c: Jacek Caban + Changed message about Mozilla ActiveX Control. + + * dlls/ntdll/cdrom.c, dlls/ntdll/directory.c, dlls/ntdll/exception.c, + dlls/ntdll/heap.c, dlls/ntdll/loader.c, dlls/ntdll/ntdll_misc.h, + dlls/ntdll/rtl.c, dlls/ntdll/time.c, dlls/ntdll/virtual.c: + Mike McCormack + Use RTL_CRITICAL_SECTION instead of CRITICAL_SECTION. + + * tools/wine.inf: Jacek Caban + Added mshtml.dll registration to wine.inf. + Removed keys that are registered by mshtml.dll. + + * dlls/mshtml/.cvsignore, dlls/mshtml/Makefile.in, dlls/mshtml/main.c, + dlls/mshtml/mshtml.inf, dlls/mshtml/mshtml.spec, dlls/mshtml/rsrc.rc: + Jacek Caban + Implemented Dll[Un]RegisterServer. + + * dlls/msvcrt/file.c, dlls/msvcrt/tests/file.c: + Paul Rupe + Make ungetc(EOF) a no-op. + + * include/wine/server.h: Mike McCormack + Don't include winreg.h. + + * dlls/psapi/psapi_main.c: + Felix Nawothnig + Don't dump content of output buffers. + + * include/wincrypt.h: Juan Lang + Add more missing definitions. + + * dlls/shell32/regsvr.c, dlls/shell32/shfldr_unixfs.c: + Michael Jung + Use the CallForAttributes registry value, instead of promoting the + root folder's SFGAO_FILESYSTEM flag to the registry. + + * dlls/shell32/classes.c, dlls/shell32/shell32_main.h, + dlls/shell32/shlfolder.c: + Michael Jung + Support for shellfolder's CallForAttributes registry value. + + * dlls/comctl32/toolbar.c: Robert Shearman + - Document how the native lays out the internal components of + buttons. + - Fix control to follow these rules. + - Don't redraw disabled buttons. + - Padding is never less that GetSystemMetrics(SM_{CX,CY}EDGE). + - Change default iListGap value to 4 to match native. + + * dlls/comctl32/pager.c: Robert Shearman + Fix a regression in IE where the Favourites menu didn't appear + correctly because the height and width were swapped in the pager + control. + +2005-06-24 Alexandre Julliard + + * dlls/ntdll/sec.c: James Hawkins + Implement RtlAddAuditAccessAce. + + * dlls/cabinet/cabinet.h, dlls/cabinet/fci.c: + Gerold Jens Wucherpfennig + Some FCI work. + + * dlls/msi/action.c: Aric Stewart + Perform ExecuteAction at UILevel 2. + + * dlls/msi/files.c: Aric Stewart + Redo how we extract files from a cabinet in order to dramatically + improve performance, especially if picking and choosing files out of + the cabinet. + + * dlls/msi/action.c: Aric Stewart + Rework CreateShortcuts to use MSI_IterateRecords. + + * dlls/ntdll/path.c, dlls/ntdll/tests/path.c: + RtlGetFullPathName_U should remove the trailing dot on directory + names. + + * dlls/advapi32/security.c, include/winioctl.h: + James Hawkins + - Define FSCTL_PIPE_IMPERSONATE. + - Implement ImpersonateNamedPipeClient. + + * dlls/wined3d/basetexture.c, dlls/wined3d/device.c, + dlls/wined3d/directx.c, dlls/wined3d/resource.c, + dlls/wined3d/utils.c, dlls/wined3d/wined3d_private.h, + include/wine/wined3d_gl.h, include/wine/wined3d_interface.h, + include/wine/wined3d_types.h: + Oliver Stieber + Add support for samplers. + Switch from using d3d9 constants to wined3d constants so that there's + no recursive dependencies. + + * dlls/msi/action.c: Aric Stewart + Properly handle -1 as a registry key root. + + * dlls/ntdll/ntdll.spec: Paul Vriens + Correct the entries for [Nt|Zw]OpenSymbolicLinkObject. + + * dlls/msi/dialog.c: Mike McCormack + Implement transparency in the text control. + + * dlls/ntdll/reg.c, include/winternl.h: + Mike McCormack + Add prototype and fix RtlpNtCreateKey. + + * tools/make_ctests.c: Pierre d'Herbemont + Change headers to in order to prevent a compilation + failure with generated files on Darwin. + + * dlls/shell32/tests/shlfolder.c: + Michael Jung + Added tests for ShellFolder's CallForAttributes value. + + * dlls/user/edit.c: Michael Kaufmann + Paint the background with the correct color if WS_BORDER. + + * dlls/msi/action.c: Aric Stewart + Rework SelfRegModules to use MSI_IterateRecords. + +2005-06-23 Alexandre Julliard + + * tools/winebuild/parser.c: + Allocate ordinals in the order of the declarations in the spec file. + + * dlls/commdlg/printdlg.c: Vitaly Lipatov + - Add some descriptions for PageSetupDlg functions. + - Implement user paint hook support and PSD_ENABLEPAGEPAINTHOOK + checking. + + * dlls/mshtml/htmldoc.c, dlls/mshtml/mshtml_private.h, dlls/mshtml/view.c: + Jacek Caban + Added stub implementation of IViewObject[2] interface. + + * dlls/itss/itss.c, dlls/itss/itss.idl: + Jacek Caban + Use GUIDs from itss.idl. + + * dlls/wined3d/basetexture.c, dlls/wined3d/device.c, + dlls/wined3d/texture.c: + Oliver Stieber + Make all newly created surfces dirty, so that they are loaded properly + the first time around. + Replace some calls to cubetexture in basetexture to calls to + basetexture. + Check that the level isn't out of bounds in calls to texture. + + * dlls/msi/Makefile.in, dlls/msi/dialog.c, dlls/msi/msipriv.h, + dlls/msi/record.c: + Mike McCormack + Make the MSI icon control work. + + * dlls/msi/action.c: Aric Stewart + Rework component, feature and file loading to use MSI_IterateRecords. + + * include/msidefs.h: Mike McCormack + Define the msidbControlAttributes enumeration. + + * programs/winecfg/appdefaults.c, programs/winecfg/audio.c, + programs/winecfg/driveui.c, programs/winecfg/libraries.c, + programs/winecfg/winecfg.c, programs/winecfg/winecfg.h, + programs/winecfg/x11drvdlg.c: + Michael Jung + Made the registry cache more general. + + * dlls/psapi/psapi_main.c: + Felix Nawothnig + - Replaced server requests by native APIs in EnumProcessModules, + GetModuleBaseNameW, GetModuleFileNameExW and GetModuleInformation. + - Make EnumProcessModules return modules in load order + - Set ERROR_INSUFFICIENT_BUFFER in GetModuleInformation when failing + due to (cb < sizeof(MODULEINFO)). + + * dlls/advapi32/advapi32.spec, dlls/advapi32/security.c: + James Hawkins + Add stub implementations for BuildSecurityDescriptorA/W. + + * dlls/d3d8/d3d8_private.h, dlls/d3d8/directx.c, + dlls/d3d9/d3d9_private.h, dlls/d3d9/device.c, dlls/d3d9/directx.c, + dlls/d3d9/swapchain.c, dlls/wined3d/Makefile.in, + dlls/wined3d/device.c, dlls/wined3d/directx.c, + dlls/wined3d/swapchain.c, dlls/wined3d/wined3d_private.h, + include/wine/wined3d_interface.h: + Oliver Stieber + Implement swapchains. + + * dlls/msi/action.c: Aric Stewart + Rework RegisterFonts to use MSI_IterateRecords. + + * dlls/advapi32/security.c: James Hawkins + Forward AddAuditAccessAce to its Rtl counterpart. + + * dlls/ntdll/ntdll.spec, dlls/ntdll/sec.c, include/winternl.h: + James Hawkins + Add stub implementation of RtlAddAuditAccessAce. + + * dlls/d3dim/d3dim.spec, dlls/dbghelp/dbghelp.spec, + dlls/icmp/icmp.spec, dlls/imagehlp/imagehlp.spec, + dlls/kernel/kernel32.spec, dlls/mpr/mpr.spec, + dlls/msacm/msacm32.spec, dlls/netapi32/netapi32.spec, + dlls/rpcrt4/rpcrt4.spec, dlls/shdocvw/shdocvw.spec, + dlls/shell32/shell32.spec, dlls/shlwapi/shlwapi.spec, + dlls/user/user32.spec: + Sort entry points in the same order as Windows. + + * tools/winedump/emf.c, tools/winedump/lnk.c: + Mike McCormack + Fix declarations. + + * dlls/oleaut32/tests/vartest.c, dlls/oleaut32/varformat.c: + Michael Stefaniuc + - more VarFormat fixes for number formats (exponent, mixed '#' and '0' + in formats, rounding, etc). Simplify the code. + - previous VarFormat todo_wine tests pass now + add more tests + + * dlls/ntdll/tests/info.c: Paul Vriens + NT4 doesn't support ProcessIoCounters. + + * programs/regedit/regedit.c: Steven Edwards + Remove an outdated comment in the command line options. + + * dlls/ntdll/om.c: Paul Vriens + Return STATUS_OBJECT_NAME_NOT_FOUND in NtOpenSymbolicLinkObject (until + implemented). + + * dlls/msi/action.c: Aric Stewart + Rework WriteIniValues to use MSI_IterateRecords. + +2005-06-22 Alexandre Julliard + + * dlls/msi/action.c: Aric Stewart + Rework PublishProduct to use MSI_IterateRecords. + + * dlls/advapi32/advapi32.spec, dlls/cards/cards.spec, + dlls/crypt32/crypt32.spec, dlls/d3dim/d3dim.spec, + dlls/d3dx8/d3dx8.spec, dlls/ddraw/ddraw.spec, + dlls/dinput/dinput.spec, dlls/glu32/glu32.spec, + dlls/glut32/glut32.spec, dlls/imm32/imm32.spec, + dlls/msvcrtd/msvcrtd.spec, dlls/ntdll/ntdll.spec, + dlls/ole32/ole32.spec, dlls/opengl32/opengl32.spec, + dlls/setupapi/setupapi.spec, dlls/tapi32/tapi32.spec, + dlls/wininet/wininet.spec, dlls/winmm/winealsa/winealsa.drv.spec, + dlls/winmm/winearts/winearts.drv.spec, + dlls/winmm/winejack/winejack.drv.spec, dlls/winmm/winmm.spec, + dlls/winspool/winspool.drv.spec, dlls/wintrust/wintrust.spec: + Sort entry points alphabetically. + + * dlls/wined3d/directx.c: Oliver Stieber + Correct GetDeviceCaps so that it uses wined3dcaps as required by the + earlier device caps patch. + + * include/msxml.idl: Vijay Kiran Kamuju + Add definition for IXMLAttribute. + + * dlls/msi/action.c: Aric Stewart + Rework RegisterTypeLibraries to use MSI_IterateRecords. + + * dlls/msvcrtd/msvcrtd.spec, dlls/msvcrt/locale.c, + dlls/msvcrt/msvcrt.spec: + Fix duplication of _Getnames and _Gettnames, only the latter actually + exists. + + * dlls/user/clipboard.c, dlls/user/listbox.c, dlls/user/msgbox.c, + dlls/user/sysparams.c: + Mike McCormack + Fix declarations, remove unused code. + + * include/msxml.idl: Vijay Kiran Kamuju + Add missing guids and declarations. + + * dlls/shell32/tests/shlfolder.c: + Saulius Krasuckas + - Move test init code back to START_TEST(shlfolder). + - Move creation and cleanup of a test-folders nearer to + test_EnumObjects. + + * dlls/gdi/tests/metafile.c: + Felix Nawothnig + - Use smaller numbers as coordinates for mapping tests to avoid + rounding-errors. + - Simplify calculation of mapped coordinates for MM_TEXT. + + * dlls/msi/action.c: Aric Stewart + Rework LaunchConditions to use MSI_IterateRecords. + + * dlls/x11drv/xfont.c: + Moved font settings to HKCU\Software\Wine\X11 Driver\Fonts. + + * dlls/dmband/band.c, dlls/dmband/bandtrack.c, + dlls/dmband/dmband_private.h, dlls/dmband/dmutils.c: + Mike McCormack + Fix up declarations. + + * dlls/ntdll/rtlstr.c, include/winternl.h: + Mike McCormack + Declare RtlGUIDFromString and RtlStringFromGUID. + + * programs/regedit/regproc.c, programs/regedit/regproc.h: + Stefan Huehner + Remove some more -Wstrict-prototypes warnings. + + * dlls/atl/atlbase.h: Mike McCormack + Add some missing declarations. + + * dlls/advapi32/tests/security.c: + Felix Nawothnig + Skip ACL tests on Win9x. + + * dlls/winmm/lolvldrv.c: Mike McCormack + Make a function static. + + * include/winbase.h: Mike McCormack + Declare ProcessIdToSessionId. + + * tools/wrc/translation.c, tools/wrc/wrc.c, tools/wrc/wrc.h: + Mike McCormack + Move function prototypes to header. + +2005-06-21 Alexandre Julliard + + * dlls/ntdll/heap.c: + Don't require execute permission on the process heap. + + * dlls/comctl32/tests/subclass.c, dlls/dinput/tests/dinput_test.h, + dlls/dinput/tests/mouse.c, dlls/dsound/tests/capture.c, + dlls/gdi/tests/metafile.c, dlls/msacm/tests/msacm.c, + dlls/mscms/mscms_main.c, dlls/msvcrt/tests/time.c, + dlls/ole32/oleobj.c, dlls/ole32/tests/moniker.c, + dlls/oleaut32/typelib.c, dlls/riched20/editor.c, + dlls/riched20/editor.h, dlls/shlwapi/path.c, + dlls/shlwapi/tests/ordinal.c, dlls/urlmon/urlmon_main.h, + dlls/user/static.c, dlls/user/tests/msg.c, dlls/uxtheme/system.c, + dlls/winedos/devices.c, dlls/winmm/tests/capture.c: + Stefan Huehner + Fix some more -Wstrict-prototypes warnings. + + * dlls/msi/action.c: Aric Stewart + Rework CostFinalize to use MSI_IterateRecords. + + * dlls/advapi32/security.c: James Hawkins + Implement IsTokenRestricted. + + * dlls/ntdll/virtual.c: + Add PAGE_GUARD flag to the returned protection of guard pages. + + * dlls/ntdll/process.c, dlls/ntdll/tests/info.c: + Paul Vriens + Change ProcessBasicInformation to the same behavior as the rest. + Use KERNEL_USER_TIMES for ProcessTimes. + Add tests for vm, io, times and handlecount info classes. + Fixes for -Wstrict-prototypes warnings. + + * dlls/dsound/tests/capture.c: + Felix Nawothnig + Accept DSERR_NODRIVER from IDirectSoundCapture_CreateCaptureBuffer. + + * dlls/msi/helpers.c: Aric Stewart + Fix situations where TARGETDIR is set to a non \ terminated + path. Fixes a few installers. + + * dlls/msi/action.c: Aric Stewart + Rework WriteRegistryValues to use MSI_IterateRecords. + + * include/amstream.idl: Vijay Kiran Kamuju + Add definitions for AMMSF_STOPIFNOSAMPLES and AMMSF_NOSTALL. + + * dlls/advapi32/advapi32.spec, dlls/advapi32/security.c: + James Hawkins + Implement GetTrustee* functions. + + * dlls/shell32/tests/shlfolder.c: + Saulius Krasuckas + Cleanup the shlfolder test a bit more. + + * dlls/d3d9/device.c: Oliver Stieber + Call wined3d for GetDirect3D instead of using the ->direct3D instance, + which is no longer valid. + + * dlls/msi/action.c: Aric Stewart + Rework CreateFolders to use MSI_IterateRecords. + + * dlls/msi/files.c: Aric Stewart + Duplicate files should not fail if unable to get Destination + Directory. + + * dlls/opengl32/wgl.c: Vitaly Lipatov + Initialize extensions after correct context is created. + + * dlls/user/sysparams.c: Rein Klazes + In reg_get_logfont: + - handle the case that the registry value is a LOGFONT16; + - if the lfHeight field is positive, it represents the font's point + size and must be converted to logical units. + + * dlls/wininet/http.c: Maarten Lankhorst + Changed setting default port number from HTTP_Connect to + HttpOpenRequestW. + + * dlls/wininet/internet.c, include/wininet.h: + Maarten Lankhorst + - Added new INTERNET_OPTION* defines. + - Fixed InternetSetOptionW unknown option handling, and added + INTERNET_OPTION_DISABLE_PASSPORT_AUTH. + + * dlls/kernel/fiber.c, dlls/kernel/thread.c, dlls/ntdll/thread.c: + Don't require execute permission for thread stacks. + + * dlls/ntdll/atom.c, dlls/ntdll/cdrom.c, dlls/ntdll/critsection.c, + dlls/ntdll/debugbuffer.c, dlls/ntdll/debugtools.c, + dlls/ntdll/directory.c, dlls/ntdll/env.c, dlls/ntdll/error.c, + dlls/ntdll/exception.c, dlls/ntdll/handletable.c, dlls/ntdll/heap.c, + dlls/ntdll/large_int.c, dlls/ntdll/loader.c, dlls/ntdll/loadorder.c, + dlls/ntdll/nt.c, dlls/ntdll/om.c, dlls/ntdll/path.c, + dlls/ntdll/process.c, dlls/ntdll/reg.c, dlls/ntdll/relay.c, + dlls/ntdll/resource.c, dlls/ntdll/rtl.c, dlls/ntdll/rtlbitmap.c, + dlls/ntdll/rtlstr.c, dlls/ntdll/sec.c, dlls/ntdll/server.c, + dlls/ntdll/signal_i386.c, dlls/ntdll/signal_powerpc.c, + dlls/ntdll/signal_sparc.c, dlls/ntdll/string.c, dlls/ntdll/sync.c, + dlls/ntdll/version.c, dlls/ntdll/virtual.c, dlls/ntdll/wcstring.c: + Mike McCormack + Don't include winbase.h or winerror.h when not necessary. + + * server/context_i386.c, server/context_powerpc.c, + server/context_sparc.c, server/debugger.c, server/fd.c, + server/file.c, server/handle.c, server/mailslot.c, server/mapping.c, + server/named_pipe.c, server/process.c, server/registry.c, + server/serial.c, server/sock.c, server/thread.c: + Mike McCormack + Don't include winbase.h when it's not necessary. + + * dlls/urlmon/urlmon_main.c: + Maarten Lankhorst + Improved ObtainUserAgentString stub. + + * dlls/dmime/audiopath.c, dlls/dmime/dmime_private.h, + dlls/dmime/graph.c, dlls/dmime/lyricstrack.c, + dlls/dmime/markertrack.c, dlls/dmime/paramcontroltrack.c, + dlls/dmime/patterntrack.c, dlls/dmime/performance.c, + dlls/dmime/segment.c, dlls/dmime/segmentstate.c, + dlls/dmime/segtriggertrack.c, dlls/dmime/seqtrack.c, + dlls/dmime/sysextrack.c, dlls/dmime/tempotrack.c, + dlls/dmime/timesigtrack.c, dlls/dmime/tool.c, dlls/dmime/wavetrack.c: + Mike McCormack + - use interfaces rather than internal functions + - remove declaration of AddRef and QueryInterface functions from + headers + + * include/wine/test.h: Pierre d'Herbemont + Fix winsock.h and stdlib.h collision by including windows.h instead + of the previous headers. + + * dlls/dsound/mixer.c: Robert Reif + Fix a typo. + + * include/winternl.h: Paul Vriens + Added KERNEL_USER_TIMES struct. + + * programs/winecfg/Nl.rc, programs/winecfg/winecfg.rc: + Paul Vriens + Update Dutch resource file. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Propagate the root folder's attributes to the registry. + +2005-06-20 Alexandre Julliard + + * programs/winefile/license.c, programs/winefile/splitpath.c: + Martin Fuchs + Remove superfluous include statements. + + * dlls/quartz/control.c, dlls/quartz/enummedia.c, + dlls/quartz/enummoniker.c, dlls/quartz/filesource.c, + dlls/quartz/transform.c: + Mike McCormack + Make functions static, fix declarations. + + * dlls/kernel/time.c, dlls/ntdll/time.c, include/winternl.h: + Mike McCormack + - avoid winternl.h depending on winbase.h + - define RTL versions of TIME_ZONE_INFORMATION and SYSTEMTIME + + * dlls/winmm/lolvldrv.c, dlls/winmm/winemm.h, programs/winecfg/audio.c, + programs/winecfg/properties.c: + Moved the audio driver configuration to HKCU\Software\Wine\Drivers and + changed it a bit to follow the model of the graphics driver. + + * dlls/d3d8/d3d8_main.c, dlls/gdi/driver.c, + dlls/shdocvw/shdocvw_main.c, dlls/user/user_main.c, + dlls/wined3d/wined3d_main.c: + Moved a few registry keys from HKLM\Software\Wine to + HKCU\Software\Wine for consistency. + + * dlls/winmm/winealsa/audio.c: + Moved configuration data to HKCU\Software\Wine\Alsa Driver. + + * dlls/dmime/audiopath.c, dlls/dmime/dmutils.c, dlls/dmime/graph.c, + dlls/dmime/lyricstrack.c, dlls/dmime/markertrack.c, + dlls/dmime/paramcontroltrack.c, dlls/dmime/patterntrack.c, + dlls/dmime/performance.c, dlls/dmime/segment.c, + dlls/dmime/segmentstate.c, dlls/dmime/segtriggertrack.c, + dlls/dmime/seqtrack.c, dlls/dmime/sysextrack.c, + dlls/dmime/tempotrack.c, dlls/dmime/timesigtrack.c, + dlls/dmime/tool.c, dlls/dmime/wavetrack.c: + Mike McCormack + Make functions static. + + * configure, configure.ac: Pierre d'Herbemont + Also check for /usr/X11R6/lib/libGL.dylib. + + * dlls/user/sysparams.c, dlls/user/tests/sysparams.c: + Vitaly Lipatov + Fix returned value for SPI_SETMOUSEBUTTONSWAP. + + * dlls/ddraw/tests/ddrawmodes.c, dlls/iphlpapi/tests/iphlpapi.c, + dlls/kernel/tests/pipe.c, dlls/msvcrt/tests/headers.c, + dlls/msvcrtd/tests/debug.c, dlls/netapi32/tests/access.c, + dlls/netapi32/tests/apibuf.c, dlls/rpcrt4/tests/rpc.c: + Stefan Huehner + Make some function static. + + * dlls/winmm/winealsa/audio.c, include/mmsystem.h: + Jeremy White + Revamp the initialization for Alsa. + + * dlls/shell32/shellord.c, include/shellapi.h: + Vitaly Lipatov + - Realize DoEnvironmentSubstA via ExpandEnvironmentStringsA. + - Fix types and return values. + - Add prototype into shellapi.h. + + * dlls/msi/files.c: Aric Stewart + Use MSI_IterateRecords for DuplicateFiles. + + * dlls/msi/action.c: Aric Stewart + Use MSI_IterateRecords for processing actions. + Some whitespace cleanup and replace a comment block I did not want to + remove. + + * dlls/advapi32/tests/crypt.c, dlls/advapi32/tests/crypt_lmhash.c, + dlls/advapi32/tests/registry.c, dlls/advpack/tests/advpack.c, + dlls/comctl32/listview.c, dlls/comctl32/tests/imagelist.c, + dlls/ddraw/tests/d3d.c, dlls/ddraw/tests/ddrawmodes.c, + dlls/ddraw/tests/dsurface.c, dlls/dinput/tests/joystick.c, + dlls/dinput/tests/keyboard.c, dlls/dmband/dmband_private.h, + dlls/dmcompos/dmcompos_private.h, dlls/dmime/dmime_private.h, + dlls/dmscript/dmscript_private.h, dlls/dmstyle/dmstyle_private.h, + dlls/dmsynth/dmsynth_private.h, dlls/dmusic/dmusic_private.h, + dlls/dsound/tests/ds3d.c, dlls/dsound/tests/ds3d8.c, + dlls/dsound/tests/dsound.c, dlls/dsound/tests/dsound8.c, + dlls/dsound/tests/propset.c, dlls/dswave/dswave_private.h, + dlls/dxdiagn/dxdiag_private.h, dlls/gdi/tests/brush.c, + dlls/kernel/tests/environ.c, dlls/kernel/tests/file.c, + dlls/kernel/tests/locale.c, dlls/kernel/tests/mailslot.c, + dlls/mscms/tests/profile.c, dlls/msi/action.c, dlls/msi/tests/db.c, + dlls/msvcrt/tests/headers.c, dlls/ntdll/tests/large_int.c, + dlls/ntdll/tests/reg.c, dlls/ole32/compobj.c, dlls/ole32/ifs.c, + dlls/ole32/tests/marshal.c, dlls/ole32/tests/propvariant.c, + dlls/oleaut32/tests/safearray.c, dlls/qcap/qcap_main.c, + dlls/quartz/tests/filtergraph.c, dlls/shdocvw/shdocvw.h, + dlls/shdocvw/shdocvw_main.c, dlls/shell32/tests/shelllink.c, + dlls/shlwapi/tests/clist.c, dlls/shlwapi/tests/shreg.c, + dlls/user/combo.c, dlls/user/tests/edit.c, dlls/wineps/afm.c, + dlls/winsock/tests/protocol.c, dlls/winspool/info.c, + dlls/wintab32/context.c, programs/notepad/dialog.h, + programs/progman/grpfile.c, tools/winegcc/winegcc.c: + Stefan Huehner + Fix more -Wstrict-prototypes warnings. + + * dlls/user/menu.c, dlls/user/tests/menu.c: + Rein Klazes + Owner drawn menu item size calculation fixes: + - Correct width calculation of owner drawn menu items; + - Set the height value in the MEASUREITEM struct to the same value as + Windows (NT/2k/XP) does (problem debugged by Felix Nawothnig); + - Add tests for the fixes above; + - Also add tests for menu bars with owner drawn items. + + * dlls/dsound/mixer.c: Robert Reif + Fix roundoff error to prevent negative length. + + * dlls/msi/dialog.c: Mike McCormack + Make tabs work in msi dialogs. + + * tools/winebuild/import.c, tools/winebuild/relay.c: + Wolfgang Thaller + Use __ASM_NAME and HAVE_ASM_DOT_SIZE in a few places in winebuild + where they have been missing (needed for Darwin/x86). + + * dlls/ntdll/thread.c, include/wine/server_protocol.h, + server/protocol.def, server/security.h, server/thread.c, + server/token.c, server/trace.c: + Robert Shearman + Add support for impersonating a token. + + * dlls/ole32/compobj.c, dlls/ole32/ole16.c, dlls/ole32/ole2.c: + Robert Shearman + Convert some registry helper functions to use unicode versions of + CLSID & registry functions (untested). + + * dlls/gdi/tests/bitmap.c: Lauri Tulmin + - add some tests for {Get|Set}Pixel + - skip tests that fail in win9x + + * programs/winefile/Cs.rc, programs/winefile/De.rc, + programs/winefile/En.rc, programs/winefile/Es.rc, + programs/winefile/Fr.rc, programs/winefile/Hu.rc, + programs/winefile/It.rc, programs/winefile/Nl.rc, + programs/winefile/Pl.rc, programs/winefile/Pt.rc, + programs/winefile/Ru.rc, programs/winefile/Si.rc, + programs/winefile/Sv.rc, programs/winefile/Zh.rc, + programs/winefile/resource.h, programs/winefile/winefile.h: + Martin Fuchs + - Sync with ReactOS repository, re-indent and remove tabs in resource + scripts and header files. + - Add #ifdef __WINE__ for the Wine About dialog. + + * dlls/user/menu.c, dlls/user/user32.spec, include/winuser.h: + Hans Leidekker + Stub implementation for GetMenuBarInfo. + + * dlls/advapi32/security.c, dlls/ntdll/sec.c, include/winternl.h: + Robert Shearman + Implement RtlImpersonateSelf, RevertToSelf and MapGenericMask. + + * dlls/winmm/mci.c, dlls/winmm/message16.c, dlls/winmm/winemm.h: + Rein Klazes + In MCI_(Un)MapMsg16To32W with wMsg == MCI_OPEN(_DRIVER) only do + strdupAtoW on those parameters that are flagged to be a string. + + * libs/wine/mmap.c: Wolfgang Thaller + Implement try_mmap_fixed for Darwin. + + * tools/winebuild/spec32.c, tools/winebuild/utils.c: + Wolfgang Thaller + Winebuild darwin/x86-specific fixes: + - Assembler interprets .align as power-of-two + - Add .weak_reference to output where gcc 3.3 swallows it + + * dlls/riched20/editor.c: Vitaly Lipatov + Allow null pointers for EM_GETSEL message (as MSDN says). + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Use stat's dev/inode to compare paths instead of comparing the + strings. Defer building a folder's children SHITEMIDS until explicitly + asked for. + + * dlls/ntdll/process.c: Paul Vriens + Stub implementations for ProcessVmCounters, ProcessTimes and + ProcessHandleCount. + Changed ProcessIoCounters to match windows behavior. + + * dlls/kernel/change.c, dlls/kernel/computername.c, dlls/kernel/cpu.c, + dlls/kernel/dosmem.c, dlls/kernel/except.c, dlls/kernel/fiber.c, + dlls/kernel/file.c, dlls/kernel/file16.c, dlls/kernel/format_msg.c, + dlls/kernel/global16.c, dlls/kernel/heap.c, + dlls/kernel/kernel_main.c, dlls/kernel/lcformat.c, + dlls/kernel/local16.c, dlls/kernel/locale.c, dlls/kernel/module.c, + dlls/kernel/ne_module.c, dlls/kernel/ne_segment.c, + dlls/kernel/oldconfig.c, dlls/kernel/path.c, dlls/kernel/process.c, + dlls/kernel/profile.c, dlls/kernel/pthread.c, dlls/kernel/relay16.c, + dlls/kernel/resource.c, dlls/kernel/snoop16.c, dlls/kernel/sync.c, + dlls/kernel/syslevel.c, dlls/kernel/system.c, dlls/kernel/thunk.c, + dlls/kernel/time.c, dlls/kernel/utthunk.c, dlls/kernel/virtual.c, + dlls/kernel/volume.c, dlls/kernel/vxd.c, dlls/kernel/wowthunk.c: + Mike McCormack + - don't include winreg.h + - include kernel_private.h to get declaration for convert_old_config() + + * server/fd.c, server/file.c, server/named_pipe.c, server/registry.c, + server/serial.c, server/trace.c: + Mike McCormack + Remove unnecessary includes. + + * dlls/ntdll/ntdll.spec, dlls/ntdll/sec.c, include/winternl.h: + James Hawkins + Implement RtlCopySecurityDescriptor. + + * dlls/ole32/rpc.c: Robert Shearman + Change the RPC code to use the unicode versions of the CLSID & + registry functions. + + * dlls/ole32/compobj.c, dlls/ole32/compobj_private.h, + dlls/ole32/tests/.cvsignore, dlls/ole32/tests/Makefile.in, + dlls/ole32/tests/compobj.c: + Robert Shearman + - Change some of the registry helper functions to use the unicode + versions of the CLSID & registry functions. + - Reindent CoGetClassObject and output an error message if the class + isn't registered. + - Add tests for the touched functions. + + * dlls/user/scroll.c: Rein Klazes + In SCROLL_DrawScrollbar allocate the internal info if needed. + + * include/winnt.h: Marcus Meissner + Added PF_NX_ENABLED definition. + + * include/wingdi.h: Dmitry Timoshkov + Enable MAKEPOINTS usage in Wine. + + * dlls/riched20/writer.c: Krzysztof Foltman + - Fix a warning caused by the TAB patch. + - Initialize *pcb to a large value before calling the stream-out + callback (to make applications that don't set *pcb at all happy). + - Don't flush the output stream when error condition is set. + + * dlls/shell32/tests/shlfolder.c: + Stefan Leichter + Make shell32 tests loadable on NT4. + + * dlls/ntdll/file.c: Pierre d'Herbemont + Move the (Mac OS X) IOKit headers to the top of the file to prevent a + compilation failure. + + * dlls/winsock/socket.c: Troy Rollo + Change WS_bind to accept an sa_family of 0 as "don't care". + + * tools/winapi/msvcmaker: + Saulius Krasuckas + Sync msvcmaker with make_ctests to generate valid code. + + * dlls/iccvid/iccvid.c, dlls/itss/storage.c, dlls/shell32/shlmenu.c, + dlls/shell32/systray.c, dlls/shell32/tests/shlfileop.c, + dlls/winmm/tests/timer.c: + Mike McCormack + Make functions static. + +2005-06-17 Alexandre Julliard + + * tools/winapi/win16.api, tools/winapi/win32.api: + Francois Gouget + Update the win(16|32).api files to match the current sources. + + * dlls/msi/events.c, dlls/msi/msipriv.h, dlls/msi/preview.c: + Aric Stewart + Allow control events to return codes to halt the processing of event. + Needed for the SetTargetPath Event. + + * dlls/crypt32/crypt32.spec, dlls/crypt32/encode.c, include/wincrypt.h: + Francois Gouget + Fix the CryptEncodeObjectEx() prototype. + Fixes winapi_check warnings. + + * dlls/odbccp32/odbccp32.c, dlls/odbccp32/odbccp32.spec, + include/odbcinst.h, tools/winapi/win32.api: + Francois Gouget + Fix the prototypes of SQLCreateDataSource*(), SQLGetPrivateProfileString*(). + Fix the return type of SQLInstallerError*() and + SQLPostInstallerError*(). + Fix the SQLInstallDriver() and SQLInstallDriverEx() prototypes in the + spec file. + Add an odbccp32 section to win32.api for winapi_check. + + * dlls/msi/install.c: Aric Stewart + A long overdue fix to MSI_SetTargetPath. This should fix an error with + some installers that where unable to change the target path. + + * dlls/msi/action.c: Aric Stewart + Flesh out the remaining keys in RegisterProduct. + + * programs/winecfg/appdefaults.c, programs/winecfg/driveui.c, + programs/winecfg/winecfg.c: + Updated paths of ShowDirSymlinks, ShowDotFiles and Version options. + + * dlls/ntdll/directory.c: + Moved directory options to HKCU\Software\Wine. + + * dlls/ntdll/version.c: Moved version key to HKCU\Software\Wine. + + * dlls/user/tests/msg.c, dlls/x11drv/winpos.c: + Vitaliy Margolen + Deactivate active window in ShowWindow(,SW_HIDE). + + * dlls/ddraw/tests/dsurface.c, dlls/oleaut32/tests/olepicture.c, + dlls/oleaut32/variant.c, dlls/qcap/v4l.c, + dlls/shell32/tests/shlfolder.c: + Francois Gouget + Assorted spelling fixes. + + * dlls/dmcompos/dmcompos_main.c, dlls/dmime/dmime_main.c, + dlls/dmstyle/dmstyle_main.c, dlls/dsound/dsound_main.c, + dlls/olepro32/olepro32stubs.c, dlls/shell32/iconcache.c, + dlls/winmm/mmsystem.c: + Francois Gouget + Fix winapi_check documentation warnings. + + * dlls/user/defwnd.c, dlls/user/win.c: + Vitaliy Margolen + ShowOwnedPopups and WM_SHOWWINDOW should handle non-WS_POPUP style + windows as well. + + * dlls/msi/Makefile.in, dlls/msi/action.c, dlls/msi/action.h, + dlls/msi/files.c: + Aric Stewart + Break out all the file related actions and helper functions into + files.c + + * dlls/activeds/activeds_main.c, tools/winapi/win32.api: + Francois Gouget + Fix the FreeADsMem() prototype. + Add an activeds section to win32.api for winapi_check. + Fix a documentation warning. + + * dlls/advapi32/crypt.c, dlls/shell32/shfldr_unixfs.c: + Francois Gouget + Protect the unistd.h and sys/stat.h includes. + Include config.h. + Fixes warnings reported by winapi_check. + + * dlls/ntdll/tests/info.c: Francois Gouget + Remove an unneeded variable in test_query_timeofday(). + Rename a variable to 'is_nt' to make its meaning clearer. + + * dlls/quartz/videorenderer.c: Francois Gouget + Remove unneeded NULL cast. + + * tools/winapi/config.pm: Francois Gouget + Remove a check for obsolete directory and file special cases. + + * tools/winapi/winapi_check: Francois Gouget + We should set the global $all_modules variable otherwise there's no + point. + + * dlls/msi/dialog.c: Marcus Meissner + Use a simpler expression for the "RichEdit20W" string to workaround + compiler bug. + + * dlls/kernel/cpu.c: Marcus Meissner + Specify enough buffer for id[] (20 chars are not enough). + + * dlls/advapi32/registry.c, dlls/kernel/computername.c, + dlls/kernel/cpu.c, dlls/kernel/except.c, dlls/kernel/locale.c, + dlls/kernel/oldconfig.c, dlls/kernel/path.c, dlls/kernel/process.c, + dlls/kernel/relay16.c, dlls/kernel/volume.c, dlls/ntdll/cdrom.c, + dlls/ntdll/critsection.c, dlls/ntdll/debugbuffer.c, + dlls/ntdll/debugtools.c, dlls/ntdll/directory.c, dlls/ntdll/env.c, + dlls/ntdll/error.c, dlls/ntdll/exception.c, dlls/ntdll/handletable.c, + dlls/ntdll/heap.c, dlls/ntdll/large_int.c, dlls/ntdll/loader.c, + dlls/ntdll/loadorder.c, dlls/ntdll/nt.c, dlls/ntdll/om.c, + dlls/ntdll/process.c, dlls/ntdll/reg.c, dlls/ntdll/relay.c, + dlls/ntdll/resource.c, dlls/ntdll/rtl.c, dlls/ntdll/rtlbitmap.c, + dlls/ntdll/rtlstr.c, dlls/ntdll/sec.c, dlls/ntdll/signal_powerpc.c, + dlls/ntdll/signal_sparc.c, dlls/ntdll/string.c, dlls/ntdll/time.c, + dlls/ntdll/version.c, dlls/ntdll/virtual.c, dlls/ntdll/wcstring.c, + dlls/winedos/ioports.c, dlls/winedos/ppdev.c, include/winternl.h: + Mike McCormack + Use HANDLE instead of HKEY in the NT API. + + * dlls/gdi/dib.c: Michael Kaufmann + Initialize more structure members, including biSizeImage if bits == + NULL and biBitCount != 0. + + * dlls/ntdll/thread.c: The TEB doesn't need execute permissions. + + * dlls/user/user32.spec: Dmitry Timoshkov + DdeCreateStringHandleA/W takes a pointer to a const string, + accordingly fix the spec entries. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Remove trailing backslash from DOS paths in GetDisplayNameOf. + + * programs/winefile/Cs.rc: Martin Fuchs + Corrections of Czech translation by Denzil. + + * dlls/ntdll/om.c, include/winternl.h: + Mike McCormack + Declare Nt directory functions. + + * configure, configure.ac, loader/Makefile.in: + Move the loader a bit higher in memory to leave more space for ntdll + and kernel32. + + * dlls/oleaut32/tests/vartype.c, dlls/urlmon/tests/url.c, + dlls/user/tests/win.c, dlls/winedos/soundblaster.c, + dlls/winmm/tests/timer.c, dlls/winmm/tests/wave.c, + dlls/winsock/tests/sock.c, dlls/wintab32/wintab32.c, + dlls/x11drv/xim.c, programs/winefile/winefile.c: + Stefan Huehner + Remove some -Wstrict-prototypes warnings. + + * dlls/d3d8/d3d8_private.h, dlls/d3d8/directx.c, + dlls/d3d9/d3d9_private.h, dlls/d3d9/device.c, dlls/d3d9/directx.c, + dlls/wined3d/device.c, include/wine/wined3d_interface.h, + include/wine/wined3d_types.h: + Oliver Stieber + Change the way caps are sent between d3d9/d3d8 and wined3d to make it + easier for wined3d to support additional versions of Direct3D. + + * dlls/shell32/iconcache.c: Marcus Meissner + ExtractAssociatedIconA needs to allocate enough space to have EAIW + fill in lpIconPathW. + + * dlls/msi/action.h: Marcus Meissner + Remove cszbs from msi/action.h. + + * dlls/advapi32/security.c: James Hawkins + Forward GetPrivate/KernelObjectSecurity to NtQuerySecurityObject. + + * include/windef.h: Dmitry Timoshkov + Fixed POINTS definition for WORDS_BIGENDIAN case. + + * dlls/crypt32/encode.c: Juan Lang + Add a few traces and comments. + + * include/wincrypt.h: Juan Lang + Add more missing defs. + +2005-06-16 Alexandre Julliard + + * dlls/ntdll/relay.c, tools/winebuild/import.c: + Make import thunks position-independent to avoid text relocations. + + * dlls/wineps/truetype.c: + Use the standard font path to look for TrueType fonts. + + * dlls/wined3d/directx.c, include/d3d9caps.h: + Oliver Stieber + Rename _D3DCAPS9.MaxPixelShaderValue to the correct + _D3DCAPS9.PixelShader1xMaxValue. + + * dlls/msi/Makefile.in, dlls/msi/action.c, dlls/msi/install.c: + Aric Stewart + Break out all the top level apis into install.c. + + * programs/winecfg/driveui.c: Paul Vriens + Hide <-> Show Advanced. + + * dlls/msi/dialog.c: Mike McCormack + Added support for the MSI MaskEdit control. + + * dlls/d3d9/vertexdeclaration.c: + Oliver Stieber + Disable the creation of invalid vertex declarations in d3d9 preventing + some applications from crashing. + + * dlls/d3d9/texture.c: Oliver Stieber + Added relay tracing to texture. + + * include/d3d9types.h: Oliver Stieber + Define some more flags + + * dlls/advapi32/tests/registry.c, server/registry.c: + Robert Shearman + - All versions of Windows ignore the access rights of the passed in + parent handle to RegCreateKey(Ex). + - Add a test that shows this. + + * dlls/msi/custom.c: Aric Stewart + A simple cleanup to only track the temp file if we need to have it + laying around because the action is going on asynchronously. Otherwise + clean up the temp file as the action finishes. + + * programs/winecfg/winecfg.c: + Use RegOpenKey instead of RegOpenKeyEx to avoid trouble with handle + access rights. + + * programs/winecfg/main.c, programs/winecfg/winecfg.c, + programs/winecfg/winecfg.h, programs/winecfg/x11drvdlg.c: + Fixed registry paths to edit the real config, and removed the startup + warning message. + + * dlls/x11drv/x11drv_main.c: + Moved configuration keys to HKCU\Software\Wine\X11 Driver. + + * dlls/ntdll/loadorder.c: + Moved configuration keys to HKCU\Software\Wine\DllOverrides. + + * dlls/msi/upgrade.c: Aric Stewart + Add UI messages to FindRelatedProducts. + Reduce unneeded includes. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + - implement encoding and decoding of enumerated types, unsigned + integers, octet strings, and bit strings + - correct length handling + - the usual tests + + * programs/wineboot/wineboot.c, programs/winecfg/drive.c, + programs/winecfg/drivedetect.c, programs/winecfg/winecfg.h: + Stefan Huehner + Fix some -Wstrict-prototypes warnings. + + * tools/winebuild/relay.c: + Generate proper PIC code for CALL32_CBClient. + + * dlls/msvcrt/cpp.c: + Store vtables in the data segment to avoid text relocations. + + * dlls/comctl32/tests/treeview.c, dlls/comctl32/updown.c, + dlls/mshtml/view.c, dlls/ntdll/tests/rtl.c, + dlls/ntdll/tests/rtlbitmap.c, dlls/rsabase/tests/rsabase.c, + dlls/rsaenh/tests/rsaenh.c: + Stefan Huehner + Fix some -Wstrict-prototypes warnings. + + * dlls/msi/Makefile.in, dlls/msi/action.c, dlls/msi/action.h, + dlls/msi/classes.c: + Aric Stewart + Break out all the class registration actions into classes.c. This + includes RegisterClassInfo, RegisterProgIds, RegisterExtensions and + RegisterMIMETypes. + + * include/wincrypt.h: Juan Lang + Define some more OID strings. + + * dlls/ntdll/relay.c, include/wine/port.h, tools/winebuild/relay.c: + Store a relative pointer for registry entry points to avoid some text + relocations. + + * dlls/ntdll/nt.c, dlls/ntdll/om.c, include/winternl.h: + Mike McCormack + Add/fix more NT native API declarations. + + * dlls/crypt32/tests/encode.c, dlls/ntdll/heap.c, + dlls/oleaut32/tests/typelib.c, dlls/winmm/tests/mixer.c, + dlls/winmm/winealsa/audio.c, libs/unicode/mbtowc.c, + programs/msiexec/msiexec.c, programs/winetest/util.c: + Mike McCormack + Fix some declaration and write string warnings. + + * dlls/shell32/shelllink.c: Mike McCormack + - forward AddRef, Release, QueryInterface and GetClassID to internal + implementations + - implement GetClassID properly + + * tools/winebuild/spec32.c: + Output the exported names as a C string so that they end up in the + correct section. + + * dlls/ntdll/relay.c: + Use the DEFINE_REGS_ENTRYPOINT macro to define register functions + instead of doing it by hand. + + * dlls/kernel/version.c: + Removed the DOS version option, specifying the Windows version should + be enough to achieve the same results. + + * dlls/shell32/Makefile.in, dlls/shell32/memorystream.c, + dlls/shell32/shell32_main.h: + Mike McCormack + SHCreateStreamOnFileW is implemented in shlwapi, so we don't need + another implementation in shell32. + + * dlls/shell32/shelllink.c, dlls/shlwapi/istream.c: + Mike McCormack + Switch IShellLink to use shlwapi.SHCreateStreamOnFileW. + + * include/winreg.h: Mike McCormack + Define RegOpenUserClassesRoot. + + * include/winnt.h: Steven Edwards + Removed duplicated ALPHA platform context definitions. + Added ARM context definitions. + + * dlls/shell32/tests/shlfolder.c: + Michael Jung + Test GetAttributesOf on the MyComputer shellfolder. + + * dlls/ntdll/nt.c: Paul Vriens + ProcessName should be without the path. + + * dlls/ntdll/tests/info.c: Paul Vriens + W2K3 returns STATUS_INVALID_HANDLE instead of STATUS_ACCESS_VIOLATION. + + * dlls/msvideo/msvideo_main.c: + Maarten Lankhorst + - Implemented ICSeqCompressFrame{Start,,End} + - Modified ICCompressorFree to properly free the initialized variables + from ICSeqCompressFrameStart. + + * tools/wine.inf: Maarten Lankhorst + Register qcap.dll on wine initialisation. + +2005-06-15 Alexandre Julliard + + * dlls/comctl32/propsheet.c: Huw Davies + For modal propsheets we should run our own message loop rather than + use a modal dialogbox just like Windows does. This helps apps that + subclass the propsheet's wndproc. + + * dlls/msi/Makefile.in, dlls/msi/action.c, dlls/msi/action.h, + dlls/msi/helpers.c: + Aric Stewart + Break out all the helper functions into helpers.c. + + * Makefile.in, documentation/Makefile.in: + Moved the API doc rules to the documentation makefile. + + * tools/bin2res.c, tools/sfnt2fnt.c, tools/widl/header.c, + tools/widl/proxy.c, tools/widl/server.c: + Stefan Huehner + Fix some -Wmissing-declarations by making functions static. + + * dlls/shell32/tests/shlfolder.c: + Michael Jung + Added tests for SHGetPathFromIDList. + + * dlls/shell32/classes.c: Huw Davies + Unquote the icon file path if it's quoted. + + * dlls/user/tests/win.c: Dmitry Timoshkov + Add a test case for WM_[L|R|M|X]BUTTONDBLCLK generation behaviour. + + * dlls/psapi/psapi_main.c: + Felix Nawothnig + - Replaced server requests in EnumProcesses by native APIs + - Fixed third parameter (should return the amount of used and not + needed memory). + + * documentation/.cvsignore, documentation/Makefile.in, + documentation/wine.man.in, loader/.cvsignore, loader/Makefile.in, + loader/wine.man.in: + Moved the wine manpage to the loader/ directory. + + * dlls/user/combo.c, include/winuser.h: + Robert Shearman + Implement GetComboBoxInfo and CB_GETCOMBOBOXINFO. + + * include/wine/test.h, tools/make_ctests.c: + Avoid static forward declaration that doesn't work on MSVC. + + * dlls/shell32/shelllink.c: Mike McCormack + Remove some uses of wine/unicode.h functions. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + Add encode/decode support for multi-byte integers. + + * dlls/user/tests/class.c, dlls/user/tests/edit.c, + dlls/user/tests/listbox.c, dlls/user/tests/sysparams.c, + dlls/user/tests/win.c, dlls/rsaenh/rsaenh.c, + dlls/rsaenh/tests/rsaenh.c: + Mike McCormack + Fix declarations. + + * dlls/ole32/tests/stg_prop.c, dlls/ole32/tests/storage32.c: + Mike McCormack + Fix declarations in the tests. + + * dlls/advapi32/security.c: Robert Shearman + MSDN states that DuplicateToken should create a new token with the + TOKEN_QUERY | TOKEN_IMPERSONATE rights, not 0. + + * dlls/shell32/pidl.c, dlls/shell32/pidl.h: + Michael Jung + Implement SHGetPathFromIDList based on GetDisplayNameOf. + + * dlls/ntdll/nt.c, dlls/ntdll/tests/info.c: + Paul Vriens + Only exact buffer size gives STATUS_SUCCESS. + +2005-06-14 Alexandre Julliard + + * documentation/Makefile.in, documentation/wine.conf.man, + documentation/wine.man.in: + Get rid of the wine.conf man page. + + * server/process.c: + Remove the process locks in process_killed, not process_destroy. + + * dlls/kernel/relay16.c, dlls/ntdll/relay.c, dlls/user/spy.c: + Moved debugging config options to HKCU\Software\Wine\Debug. + + * dlls/shell32/tests/shlfolder.c: + Michael Jung + Replace magic error constant. + + * dlls/mapi32/tests/prop.c: + Saulius Krasuckas + Avoid accessing uninitialized data on WinME (based on an old patch by + Ferenc Wagner). + + * dlls/user/nonclient.c, dlls/user/win.c: + Stefan Huehner + Remove include "cursoricon.h" from nonclient.c and win.c. + + * dlls/shell32/clipboard.c, dlls/shell32/shelllink.c, + dlls/shell32/shlexec.c: + Michael Jung + Use SHGetPathFromIDList instead of SHELL32_GetPathFromIDList. + + * server/handle.c: + Call the close_handle notification for all objects when releasing a + handle table. + + * server/token.c, server/trace.c: Robert Shearman + Fix size used to validate the sids in aces. + + * dlls/x11drv/init.c: Removed the check for the old Resolution option. + + * dlls/x11drv/palette.c, dlls/x11drv/x11drv.h, dlls/x11drv/x11drv_main.c: + Merged palette option processing into the main configuration code. + + * dlls/shell32/shfldr_desktop.c, dlls/shell32/tests/shlfolder.c: + Michael Jung + Return the correct attributes for the desktop folder. + Corresponding tests. + + * server/token.c: Robert Shearman + Add TokenType attribute to specify whether the token is a primary or + impersonation token. + + * dlls/user/sysparams.c: + Use a better location than HKCU\Wine for saving the temporary + parameters. + + * dlls/x11drv/xfont.c: + Avoid repeatedly opening the configuration registry key. + + * dlls/iphlpapi/iphlpapi_main.c, dlls/kernel/computername.c, + dlls/netapi32/nbt.c: + Moved network configuration parameters to HKCU\Software\Wine\Network. + + * dlls/shell32/tests/shlfolder.c: + Michael Jung + Added tests to compare SHGetPathFromIDList and GetDisplayNameOf. + + * dlls/shlwapi/tests/path.c, dlls/shlwapi/tests/string.c: + Mike McCormack + Fixes for -Wmissing-declaration and -Wwrite-string warnings. + + * dlls/dinput/joystick_linux.c: + Moved config parameters to HKCU\Software\Wine\DirectInput. + + * dlls/dsound/dsound_main.c: + Moved config parameters to HKCU\Software\Wine\DirectSound. + + * dlls/gdi/freetype.c: + Moved all font config parameters to HKCU\Software\Wine\Fonts. + Replaced the FontDirs key enumeration by a simple Path value. + + * dlls/ntdll/cdrom.c: Ivan Leo Puoti + Reimplement IOCTL_SCSI_PASS_THROUGH_DIRECT and + IOCTL_SCSI_PASS_THROUGH on top of the linux scsi driver. + + * dlls/oleaut32/tests/vartest.c: + Saulius Krasuckas + Change (long long) to (LONGLONG) to compile with MSVC. + + * dlls/ntdll/process.c, dlls/ntdll/tests/info.c: + Paul Vriens + Return STATUS_INVALID_INFO_CLASS for non-implemented classes. + Return STATUS_ACCESS_VIOLATION if no buffer given. + Added tests for ProcessBasicInformation. + + * dlls/user/edit.c, dlls/user/tests/edit.c: + Lauri Tulmin + - EM_CHARFROMPOS should return the closest char (clicking on the first + half of a character should return current char and clicking on the + second half should return next char) + - EM_POSFROMCHAR should return -1 if character index is greater or + equal to text length + + * dlls/gdi/gdiobj.c: Removed the Tweak.Fonts configuration hack. + + * dlls/x11drv/bitblt.c: + Get rid of the PerfectGraphics option, that's not really useful. + + * dlls/winedos/dosconf.c: + Hardcode the location of config.sys, no need for a config parameter + for that. + + * include/winbase.h: Mike McCormack + Add a couple of missing functions. + + * dlls/ntdll/nt.c, include/winternl.h: + Mike McCormack + Declare port functions and fix prototypes. + + * dlls/kernel/computername.c, dlls/kernel/console.c, + dlls/kernel/environ.c, dlls/kernel/kernel_main.c, + dlls/kernel/kernel_private.h, dlls/kernel/lcformat.c, + dlls/kernel/process.c, dlls/kernel/profile.c, dlls/kernel/thread.c, + dlls/kernel/version.c, dlls/kernel/win87em.c: + Mike McCormack + Fix warnings from -Wmissing-declarations. + + * server/file.h, server/handle.h, server/process.c: + Mike McCormack + Call remove_process_locks when a process ends, fix declarations. + + * dlls/kernel/tests/profile.c, dlls/kernel/tests/thread.c, + dlls/kernel/tests/time.c, dlls/kernel/tests/timer.c: + Mike McCormack + Fix declaration warnings in the test cases. + + * dlls/oleaut32/tests/vartest.c, dlls/oleaut32/varformat.c: + Michael Stefaniuc + - Fix VarFormat for formats that mix '0' and '#' in the whole number + part. + - Fix VarFormat for negative exponent formats. + - Add tests for the above + a couple of "todo_wine"'s. + + * dlls/shell32/shelllink.c: Mike McCormack + Add the IContextMenu interface to the ShellLink object. + + * dlls/crypt32/crypt32.spec, dlls/crypt32/main.c, + dlls/crypt32/tests/.cvsignore, dlls/crypt32/tests/Makefile.in, + dlls/crypt32/tests/main.c: + Juan Lang + Add CertAlgIdToOID and CertOIDToAlgId, with tests. + + * dlls/dmloader/loaderstream.c: + Alex Villacís Lasso + Avoid one more access to pcbRead. + +2005-06-13 Alexandre Julliard + + * dlls/wininet/ftp.c, dlls/wininet/http.c, dlls/wininet/internet.c, + dlls/wininet/internet.h, dlls/wininet/tests/http.c, + dlls/wininet/urlcache.c: + Mike McCormack + Fix some warnings. + + * dlls/dmloader/loaderstream.c: + Alex Villacís Lasso + Prevent crash on IDirectMusicLoaderResourceStream_IStream_Read. + + * dlls/msi/msi.c: Aric Stewart + A "1" is returned not a 1 for AssignmentType. Also as a bit more to + the FIXME message. + + * dlls/shell32/shelllink.c: Mike McCormack + Implement ShellLink's IShellExtInit::Initialize() method. + + * dlls/d3d8/d3d8_main.c, dlls/dinput/joystick_linux.c, + dlls/dsound/dsound_main.c, dlls/gdi/driver.c, dlls/gdi/freetype.c, + dlls/gdi/gdiobj.c, dlls/gdi/printdrv.c, + dlls/iphlpapi/iphlpapi_main.c, dlls/kernel/computername.c, + dlls/kernel/oldconfig.c, dlls/kernel/relay16.c, + dlls/kernel/version.c, dlls/kernel/volume.c, dlls/mpr/pwcache.c, + dlls/netapi32/nbt.c, dlls/ntdll/directory.c, dlls/ntdll/loadorder.c, + dlls/ntdll/relay.c, dlls/ntdll/version.c, dlls/rsaenh/rsaenh.c, + dlls/shdocvw/shdocvw_main.c, dlls/user/spy.c, dlls/user/sysparams.c, + dlls/user/user_main.c, dlls/wined3d/wined3d_main.c, + dlls/winedos/dosconf.c, dlls/winedos/ioports.c, dlls/winedos/ppdev.c, + dlls/wineps/init.c, dlls/wineps/truetype.c, dlls/wineps/type1afm.c, + dlls/winmm/lolvldrv.c, dlls/winmm/winealsa/audio.c, + dlls/winspool/info.c, dlls/x11drv/bitblt.c, dlls/x11drv/init.c, + dlls/x11drv/palette.c, dlls/x11drv/x11drv_main.c, + dlls/x11drv/xfont.c, programs/taskmgr/taskmgr.c, + programs/winebrowser/main.c, programs/winedbg/winedbg.c, + programs/winemenubuilder/winemenubuilder.c, programs/winemine/main.c: + Added magic comments to all Wine-specific registry accesses to make + them easier to grep. + + * programs/winecfg/appdefaults.c, programs/winecfg/audio.c, + programs/winecfg/driveui.c, programs/winecfg/libraries.c, + programs/winecfg/winecfg.c, programs/winecfg/winecfg.h, + programs/winecfg/x11drvdlg.c: + Changed registry access functions to use more meaningful names. + + * dlls/winedos/int11.c: + Removed references to obsolete configuration entries. + + * dlls/user/cursoricon.c: Huw Davies + When loading a bitmap we should stretch the image to the requested + size. + + * dlls/comctl32/tests/.cvsignore, dlls/comctl32/tests/Makefile.in, + dlls/comctl32/tests/treeview.c: + Krzysztof Foltman + Test when TVN_SELCHANGING and TVN_SELCHANGED are really sent. + + * dlls/ddraw/tests/d3d.c, dlls/ddraw/tests/ddrawmodes.c, + dlls/ddraw/tests/dsurface.c, dlls/kernel/tests/file.c, + dlls/ole32/tests/propvariant.c, dlls/ole32/tests/stg_prop.c, + dlls/oleaut32/tests/vartest.c, dlls/oleaut32/tests/vartype.c, + dlls/urlmon/tests/url.c, dlls/winmm/tests/mixer.c, + include/wine/test.h: + Moved the NONAMELESSUNION/STRUCT macros to wine/test.h so that they + can be used in all the test. + + * dlls/shell32/shelllink.c: Mike McCormack + - add the IShellExtInit interface to the ShellLink object + - use inline functions rather than macros to resolve the + implementation pointer from an interface pointer + + * configure, configure.ac, dlls/Makefile.in, dlls/activeds/.cvsignore, + dlls/activeds/Makefile.in, dlls/activeds/activeds.spec, + dlls/activeds/activeds_main.c: + Detlef Riekenberg + Added activeds.dll with some stubs to get the native printui.dll to + load. + + * programs/rpcss/epmap_server.c, programs/rpcss/np_server.c, + programs/winefile/license.c, programs/winefile/splitpath.c: + Mike McCormack + More warning fixes. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + - encode/decode X509_NAMEs for simple string encodings, with tests + - more tests and some fixes to other types + + * dlls/comctl32/treeview.c: Krzysztof Foltman + Don't send TVN_SELCHANGING nor TVN_SELCHANGED if the same item is + selected again. + + * programs/winefile/winefile.c: Martin Fuchs + Remove duplicate toolbar button. + + * dlls/quartz/Makefile.in, dlls/quartz/videorenderer.c: + Christian Costa + Added window support to the video renderer: + - replaced ddraw code by window code. + - implemented IBasicVideo and IVideoWindow interfaces. + + * dlls/ntdll/nt.c, dlls/ntdll/tests/info.c, include/winternl.h: + Paul Vriens + Fixed size of our SYSTEM_TIMEOFDAY_INFORMATION struct. + Fixed return codes and ReturnLength/buffer for + SystemTimeOfDayInformation. + Added tests for SystemTimeOfDayInformation. + + * dlls/ntdll/sec.c: James Hawkins + Implement RtlAbsoluteToSelfRelativeSD. + + * programs/winefile/winefile.c: Martin Fuchs + - use const parameter in find_entry_shell() + - rename ExecuteDialogWndProg() to ExecuteDialogDlgProc() + - remove old comment + - add missing call to CtxMenu_reset() + + * include/aclapi.h, include/ntsecapi.h, include/winbase.h, + include/winsvc.h, include/winuser.h: + Mike McCormack + Declare some missing functions. + + * dlls/ntdll/tests/rtl.c, dlls/ntdll/tests/rtlstr.c: + Mike McCormack + Fix warnings in tests, remove pointless comments. + + * dlls/ntdll/nt.c, dlls/ntdll/ntdll.spec, dlls/ntdll/sync.c, + include/winternl.h: + Mike McCormack + Add and fix function prototypes. + + * dlls/ole32/tests/propvariant.c: Robert Shearman + Fix PropVariant tests on Windows 2000 and above. + + * dlls/winmm/winealsa/audio.c: Robert Shearman + Remove needless call to Sleep. + + * dlls/ole32/regsvr.c: Robert Shearman + - Add registry entries for local-only OLE interfaces. + - Change IUnknown to local interface. + + * dlls/riched20/editor.c: Robert Shearman + Richedit classes should be global. + + * dlls/iphlpapi/ifenum.c: Robert Shearman + Fix size passed to lstrcpynA function - sizeof(string) == 4 not 16 as + needed. + + * include/wingdi.h: Mike McCormack + Correct GdiIsPlayMetafileDC prototype. + + * dlls/advapi32/service.c, dlls/advapi32/tests/crypt_md4.c, + dlls/advapi32/tests/crypt_md5.c: + Mike McCormack + Silence some -Wmissing-declarations warnings. + + * include/wincrypt.h: Juan Lang + Add/correct a few more definitions. + + * include/icm.h: Hans Leidekker + Declare missing functions. + + * dlls/oleaut32/typelib.c: Marcus Meissner + Corrected string length method in ITypeLib::IsName() and FindName() + for LPOLESTR type. + +2005-06-12 Alexandre Julliard + + * configure, configure.ac: Adrian Harvey + Added sys/types.h to configure check for videodev.h. + + * dlls/riched20/writer.c: Krzysztof Foltman + Emit \tx for user-defined TABs. + + * programs/winefile/winefile.c: Martin Fuchs + Remove unnecessary paint code. + + * dlls/opengl32/wgl_ext.c: Lionel Ulmer + Remove some FIXMEs and replace them with TRACEs. + + * programs/winefile/winefile.h: Martin Fuchs + Move __WINE__ ifdef directive. + + * dlls/ntdll/sec.c: James Hawkins + Remove stub status. + Check for correct revision value. + + * dlls/ntdll/ntdll.spec, include/winternl.h: + James Hawkins + Add RtlAnsiCharToUnicodeChar definition. + Correct stub status of RtlAnsiCharToUnicodeChar. + + * dlls/setupapi/queue.c, dlls/setupapi/setupapi.spec: + Matthew Davison + Stub out the error dialog functions. + Modify the default callbacks to call these for Delete and Rename + errors. + Modify the default callbacks to ignore file missing errors when + deleting files. + + * dlls/ntdll/ntdll.spec, dlls/ntdll/sec.c, include/winternl.h: + Eric Kohl + Implement RtlAdjustPrivilege. + + * programs/winefile/winefile.c: Martin Fuchs + Fix file size in property dialog by using _stprintf() instead of + wsprintf(). + + * dlls/riched20/editor.c, dlls/riched20/paint.c, dlls/riched20/style.c: + Krzysztof Foltman + - added support for \ulnone (turning underline off) + - support for basic subscript and superscript + - untested support for text offset + + * dlls/ddraw/d3d_private.h, dlls/ddraw/d3d_utils.c, + dlls/ddraw/device_opengl.c, dlls/ddraw/gl_api.h, + dlls/ddraw/gl_private.h, dlls/ddraw/opengl_private.h, + dlls/ddraw/vertexbuffer.c: + Lionel Ulmer + Support all possible texture coordinates sizes. + + * dlls/oleaut32/usrmarshal.c: Robert Shearman + - Don't print out cryptic message if IDispatch or IUnknown object is + just NULL. + - puArgErr is a ref pointer so we have to provide a dummy pointer if + it is NULL. + - Fail gracefully and notify caller if we ran out of memoy or if + variant copying failed. + + * dlls/advapi32/tests/registry.c: Robert Shearman + Fix registry test for Win9x by skipping a section that fails, but + succeeds on NT. + + * dlls/shdocvw/events.c, dlls/shdocvw/oleobject.c, dlls/shdocvw/shdocvw.h: + Marcus Meissner + Move static variables out of header file, also the local interface + implementations. + + * dlls/dsound/tests/capture.c: Robert Reif + Make dsound tests loadable on NT4. + + * dlls/x11drv/x11drv.h: Glenn Wurster + Add declaration of X11DRV_GetDIBColorTable to avoid compile warning. + + * dlls/kernel/path.c: Felix Nawothnig + Add a workaround for Win9x apps which pass the parameters for + GetCurrentDirectoryA in wrong order. + +2005-06-10 Alexandre Julliard + + * tools/winebuild/spec32.c: Pierre d'Herbemont + Use .mod_*_func sections on Mac OS X/i386 instead of the elf + constructor/destructor. + + * tools/winebuild/spec32.c: + Reuse output_dll_init for the constructor of debug files. + + * server/change.c, server/fd.c, server/mailslot.c, server/named_pipe.c, + server/registry.c, server/thread.c, server/token.c: + Robert Shearman + Change code style of form "if( x )" to "if (x)" for consistency. + + * include/setupapi.h: Matthew Davison + Added some definitions to setupapi. + + * dlls/ntdll/nt.c, dlls/ntdll/tests/info.c: + Paul Vriens + Fixed ReturnLength of SystemCpuInformation. + Added first test for SystemCpuInformation. + + * dlls/msi/msi.spec, dlls/msi/msiquery.c, include/msiquery.h: + Mike McCormack + Create a stub implementation for MsiViewGetError. + + * dlls/kernel/sync.c, dlls/ntdll/reg.c, dlls/ntdll/sync.c, + include/winternl.h: + Mike McCormack + Dependency fixes for winternl.h. + + * programs/regedit/listview.c, programs/taskmgr/perfpage.c, + programs/winebrowser/main.c, programs/winefile/winefile.c, + programs/winefile/winefile.h: + Mike McCormack + Fix more warnings. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Set the FILESYSANCESTOR and FILESYSTEM flags correctly in + GetAttributesOf. + + * dlls/oleaut32/typelib.c: Robert Shearman + Clear out parameters to stop bad pointers lying around in memory if + the function doesn't set them to anything. + + * dlls/x11drv/palette.c: Glenn Wurster + Adds support for the DIBINDEX type of COLORREF. + + * dlls/ntdll/rtlstr.c: James Hawkins + Implement RtlAnsiCharToUnicodeChar. + + * include/wininet.h: Mike McCormack + Include missing AW macro. + + * include/msiquery.h: Mike McCormack + Declare the MSIDBERROR enumeration. + + * dlls/urlmon/urlmon_main.c, include/urlmon.idl: + Mike McCormack + Declare functions and correct prototypes. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + Cryp{En|De}codeObjectEx should return success if the input buffer is + NULL, some MS sample programs depend on that. Fix functions and + tests. + +2005-06-09 Alexandre Julliard + + * dlls/user/edit.c: Lauri Tulmin + Bottom edge of the update region should be relative to the top edge of + the format rect. + + * dlls/ddraw/tests/d3d.c: Stefan Leichter + Make ddraw tests loadable on NT4. + + * server/registry.c: + Store the process along with the key handle in notifications. + + * dlls/ntdll/nt.c: Paul Vriens + Reduce our buffer by 1 SYSTEM_THREAD_INFORMATION per process. + Minimize some calculations. + + * dlls/user/edit.c, dlls/user/tests/edit.c: + Lauri Tulmin + Add more tests for text placement in single and multiline edit + controls. Some of the tests are marked as todo. + + * dlls/msi/action.c: Aric Stewart + Extending upon Mike McCormack's cleanup to use MSI_RecordGetString. + + * dlls/msi/action.c: Aric Stewart + Register the Product Version also. + Also help plug some memory leaks pointed out by Mike McCormack. + + * dlls/user/tests/winstation.c, server/atom.c, server/change.c, + server/console.c, server/debugger.c, server/event.c, server/fd.c, + server/file.c, server/handle.c, server/hook.c, server/mailslot.c, + server/mapping.c, server/mutex.c, server/named_pipe.c, + server/object.c, server/object.h, server/process.c, server/queue.c, + server/registry.c, server/request.c, server/semaphore.c, + server/serial.c, server/signal.c, server/snapshot.c, server/sock.c, + server/thread.c, server/timer.c, server/token.c, server/winstation.c: + Added a close_handle method to the object operations, and use it to + implement registry notifications and the strange behavior of + CloseHandle on winstation/desktop handles. + + * dlls/msi/action.c: Aric Stewart + Avoid a loop where a parent's parent refers to itself as its parent. + + * dlls/user/tests/winstation.c, server/handle.c, server/process.c, + server/process.h, server/thread.c, server/user.h, + server/winstation.c: + The desktop of a new thread should be set from the process initial + desktop, not from the parent thread. + Fixed a couple of bugs in the desktop name handling. + + * include/wininet.h: Mike McCormack + Declare some missing functions. + + * dlls/shell32/tests/shlfolder.c: + Saulius Krasuckas + Get current directory during tests on win9x too. + + * dlls/shell32/shelllink.c: Mike McCormack + Add the IShellLinkDataList interface to the ShellLink object. + + * dlls/msi/Makefile.in, dlls/msi/action.c, dlls/msi/action.h, + dlls/msi/upgrade.c, include/msidefs.h: + Aric Stewart + Added module upgrade.c and implemented FindRelatedProducts. + + * tools/winapi/config.pm, tools/winapi/msvcmaker, + tools/winapi/winapi_cleanup: + Fixed a number of references to removed directories. + + * configure, configure.ac, dlls/user/Makefile.in, + dlls/user/dde_client.c, dlls/user/dde_misc.c, + dlls/user/dde_private.h, dlls/user/dde_server.c, dlls/user/ddeml16.c: + Moved dde files to the main directory and got rid of the dlls/user/dde + subdirectory. + + * DEVELOPERS-HINTS, configure, configure.ac, dlls/user/Makefile.in, + dlls/user/misc.c: + Moved monitor functions to dlls/user/misc.c and finally got rid of the + windows/ directory. + + * dlls/ntdll/tests/info.c: Paul Vriens + Added test for SystemProcessInformation. + + * dlls/advapi32/tests/security.c: Robert Shearman + Added test for AccessCheck. + + * dlls/comctl32/comctl32.h, dlls/comctl32/commctrl.c, + dlls/comctl32/flatsb.c, dlls/comctl32/listview.c, + dlls/comctl32/monthcal.c, dlls/comctl32/propsheet.c, + dlls/comctl32/tests/dpa.c, dlls/comctl32/tests/tab.c, + dlls/comctl32/tests/updown.c: + Mike McCormack + Warning fixes for -Wmissing-declarations and -Wwrite-strings. + + * dlls/user/Makefile.in, dlls/user/driver16.c: + Moved windows/driver.c to dlls/user/driver16.c. + + * dlls/winmm/winealsa/audio.c: Jeremy White + Combine WINE_WAVEOUT and WINE_WAVEIN into a single structure. + + * include/objbase.h, include/ole2.h: + Mike McCormack + Added some function declarations. + + * dlls/advapi32/tests/crypt.c, dlls/advapi32/tests/security.c: + Mike McCormack + Fix some warnings. + + * tools/winedump/lnk.c: Mike McCormack + Dump out the msi information in more detail. + + * dlls/ole32/moniker.h: Marcus Meissner + Removed CLSID_CompositeMoniker (conflicting with static definition). + + * server/token.c: Robert Shearman + - Avoid evil signed bitfields. + - Fix bug with using wrong revision in security_sid_alloc. + - Add all builtin groups present in the Administrator token on Windows + to the default token. + + * dlls/wined3d/wined3d_private.h: + Marcus Meissner + Fixed definition/declaration mismatches of newly static vtables. + + * server/named_pipe.c: Robert Shearman + Fix a regression in the performance of named pipes by only making the + fd non-blocking when overlapped I/O is requested for the fd (reported + by Ivan Leo Puoti). + + * dlls/dbghelp/dwarf.c, dlls/dbghelp/storage.c: + Mike McCormack + Fix warnings exposed by -Wmissing-declarations and -Wwrite-strings. + + * dlls/shell32/shv_item_cmenu.c: Mike McCormack + Add a cast to get rid of a warning. + + * dlls/user/tests/winstation.c: + Dmitry Timoshkov + Added a couple of CloseHandle calls. + + * dlls/ole32/marshal.c, dlls/ole32/stubmanager.c: + Robert Shearman + IUnknown isn't a remotable interface so the stub manager shouldn't + need a marshaller for it. + + * dlls/ntdll/file.c: Robert Shearman + - Don't free the fileio object because it will be freed anyway in + fileio_terminate on error. + - Print out statuses in hex, rather than decimal. + + * tools/widl/typelib.c, tools/widl/write_msft.c: + Robert Shearman + Add more struct types for TLB generation. + + * dlls/advapi32/security.c: Mike McCormack + Make ADVAPI_IsLocalComputer static and simplify it a little. + + * dlls/advapi32/advapi.c: Mike McCormack + Include appmgmt.h where its functions are used. + + * dlls/dmcompos/chordmap.c, dlls/dmcompos/chordmaptrack.c, + dlls/dmcompos/composer.c, dlls/dmcompos/signposttrack.c: + Mike McCormack + Make interface methods static. + + * server/winstation.c: Mike McCormack + Include user.h in the new winstation.c to avoid a warning from + -Wmissing-declarations. + + * dlls/oleaut32/tmarshal.c: Robert Shearman + - The typelib marshaler should only free the memory it actually allocated. + - Add special cases for two lesser used types that aren't + sizeof(DWORD) sized. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Use shell icon cache instead of an own IExtractIcon implementation. + + * dlls/kernel/tests/drive.c: + Uwe Bonnes + Don't try to access floppy if it's not mounted. + + * dlls/comctl32/ipaddress.c: Alex Zorach + Fixed SetFocus behavior. + +2005-06-08 Alexandre Julliard + + * dlls/msi/action.c: Aric Stewart + Set the Preselected property if appropriate (relevant to + MigrateFeatureStates when implemented). + + * dlls/msi/action.c: Aric Stewart + Write out Product Language and Product Icon to the registry. + + * dlls/ntdll/file.c, include/wine/server_protocol.h, + server/named_pipe.c, server/protocol.def, server/trace.c: + Robert Shearman + Implement overlapped I/O with named pipes. + + * dlls/msi/action.c: Aric Stewart + Write out UpgradeCodes to the registry to allow for future upgrades. + + * dlls/user/Makefile.in, dlls/user/misc.c, dlls/user/tests/.cvsignore, + dlls/user/tests/Makefile.in, dlls/user/tests/winstation.c, + dlls/user/user32.spec, dlls/user/winstation.c, + include/wine/server_protocol.h, include/winuser.h, + server/Makefile.in, server/object.c, server/object.h, + server/process.c, server/process.h, server/protocol.def, + server/request.h, server/thread.c, server/thread.h, server/trace.c, + server/user.h, server/winstation.c: + Beginnings of support for window stations and desktops. + + * dlls/msi/msi.c: Aric Stewart + Add Language to the values we can query with MsiGetProductInfo. + + * dlls/wined3d/device.c, dlls/wined3d/directx.c: + Felix Nawothnig + - Output a FIXME when a surface with dimensions not being a power of + two is requested. + - Fail gracefully when IWineD3DImpl_CreateDevice fails to create the + front- or backbuffer. + + * dlls/user/sysparams.c: Huw Davies + Read the entire logfont from the registry if it exists. + + * dlls/msi/action.c: Mike McCormack + Use MSI_RecordGetString in more actions. + + * dlls/oleaut32/varformat.c: Michael Stefaniuc + - implement handling of exponents (e+,e-,E+,E-) when parsing number + formats + - fix a small cut'n'paste error in the comments + + * dlls/rpcrt4/rpc_server.c: Robert Shearman + Fix an RPC server startup race introduced by me. + + * dlls/dsound/dsound_main.c: Michael Jung + Fixed confusing indentation. + + * dlls/oleaut32/typelib.c: Marcus Meissner + Fixed IType::Invoke in regards to handling propertyget variables + longer than 4 bytes (like VT_DATE). + + * dlls/rpcrt4/rpc_binding.c: Robert Shearman + - Don't pass the PROFILE_SERVER flag in to CreateNamedPipe as it is + bogus. + - Call FlushFileBuffers to make sure the other end of the pipe doesn't + get cut off prematurely. + - Don't call CancelIo as we should never have async I/O pending. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + Implement asn.1 encoding/decoding of times, with tests. + +2005-06-07 Alexandre Julliard + + * dlls/ddraw/tests/.cvsignore, dlls/ddraw/tests/Makefile.in, + dlls/ddraw/tests/d3d.c: + Antoine Chavasse + Test cases for the direct3d7 light api. + + * dlls/ddraw/d3d_private.h, dlls/ddraw/device_main.c, + dlls/ddraw/device_opengl.c: + Antoine Chavasse + Rewrote the light management API to allow for an unlimited amount of + lights to be set, and only a subset of them to be enabled. + + * dlls/msi/action.c: Mike McCormack + Use MSI_RecordGetString where possible. + + * dlls/shell32/debughlp.c, dlls/shell32/shell32_main.h, + dlls/shell32/shfldr_fs.c, dlls/shell32/shlview.c, + dlls/shell32/shv_item_cmenu.c, dlls/shell32/tests/shlfolder.c: + Mike McCormack + Warning fixes for -Wmissing-declarations and -Wwrite-strings. + + * dlls/msi/dialog.c: Mike McCormack + Use a richedit control for license text. + + * dlls/msi/action.c, dlls/msi/action.h, dlls/msi/msipriv.h: + Mike McCormack + Fixes for -Wmissing-declarations and -Wwrite-strings warnings. + + * dlls/quartz/avidec.c, dlls/quartz/parser.c, + dlls/quartz/videorenderer.c: + Christian Costa + Don't use fullscreen mode in video renderer for now and improve error + handling a bit. + Improved a bit Run/Pause/Stop methods of parser template. + + * dlls/user/tests/msg.c: Dmitry Timoshkov + Add a test for window state when a window receives WM_ENABLE message. + + * dlls/user/win.c: + Still send a message in SetWindowText for the inter-process case even + though it's not fully correct (reported by Jason Campbell). + + * server/fd.c, server/file.c, server/file.h: + Robert Shearman + - Add a default asynchronous I/O implementation. + - Make file objects use it. + + * dlls/setupapi/devinst.c, include/setupapi.h: + Mike McCormack + Declare some functions. + + * dlls/rpcrt4/ndr_ole.c: Robert Shearman + Make NdrInterfacePointer* more reliable. + + * programs/winefile/Cs.rc, programs/winefile/De.rc, + programs/winefile/En.rc, programs/winefile/Es.rc, + programs/winefile/Fr.rc, programs/winefile/Hu.rc, + programs/winefile/It.rc, programs/winefile/Nl.rc, + programs/winefile/Pl.rc, programs/winefile/Pt.rc, + programs/winefile/Ru.rc, programs/winefile/Si.rc, + programs/winefile/Sv.rc, programs/winefile/Zh.rc: + Martin Fuchs + Synchronize resource scripts IDs of the different languages and adjust + INFO entries. + + * dlls/cabinet/cabextract.c, dlls/cabinet/cabinet_main.c: + Thomas Weidenmueller + Removed local variables only used in TRACE statements. + + * include/aclapi.h: Mike McCormack + Define GetExplicitEntriesFromAcl. + + * include/winbase.h: Mike McCormack + Added some security related functions to winbase.h. + + * include/Makefile.in, include/appmgmt.h: + Mike McCormack + Added the appmgmt.h header. + + * dlls/msi/dialog.c: Mike McCormack + Fix radio button groups. Don't add the WS_GROUP style to every + window. + + * include/olectl.h: Mike McCormack + Declare OleLoadPictureEx. + + * dlls/shell32/shlfolder.c: Juan Lang + Const-ify a mask. + + * dlls/commdlg/filedlg.c, dlls/commdlg/filedlgbrowser.c, + dlls/commdlg/filedlgbrowser.h: + Juan Lang + Fix return code abuse (don't use HRESULT when it isn't meant), make + functions static where possible, remove unused prototypes. + + * dlls/msi/msipriv.h, dlls/msi/registry.c: + Aric Stewart + Add functions to add the User UpgradeCodes. + + * dlls/msi/msi.c: Aric Stewart + Correct a crash if the length buffer is NULL. + + * dlls/ntdll/nt.c: Paul Vriens + Fixed typo. + Zero the thread information before use. + + * include/winternl.h: Paul Vriens + Add another (unknown) member to SYSTEM_THREAD_INFORMATION. + +2005-06-06 Alexandre Julliard + + * dlls/kernel/console.c, dlls/kernel/environ.c, dlls/kernel/except.c, + dlls/kernel/fiber.c, dlls/kernel/heap.c, dlls/kernel/process.c, + dlls/ntdll/error.c, dlls/ntdll/exception.c, dlls/ntdll/heap.c, + dlls/ntdll/resource.c, dlls/ntdll/virtual.c, dlls/winedos/relay.c: + Removed some unnecessary inclusions of thread.h + + * dlls/ntdll/debugtools.c, dlls/ntdll/ntdll_misc.h, + dlls/ntdll/server.c, dlls/ntdll/signal_i386.c, dlls/ntdll/sync.c, + dlls/ntdll/thread.c, include/thread.h, include/winternl.h: + Moved the ntdll per-thread data out of the TEB into a private + structure stored in TEB.SystemReserved2. + + * dlls/kernel/change.c, dlls/kernel/global16.c, + dlls/kernel/kernel_main.c, dlls/kernel/kernel_private.h, + dlls/kernel/local16.c, dlls/kernel/locale.c, dlls/kernel/ne_module.c, + dlls/kernel/ne_segment.c, dlls/kernel/pthread.c, + dlls/kernel/relay16.c, dlls/kernel/snoop16.c, dlls/kernel/syslevel.c, + dlls/kernel/system.c, dlls/kernel/task.c, dlls/kernel/vxd.c: + Moved the kernel per-thread data out of the TEB into a private + structure stored in TEB.SystemReserved1. + + * dlls/kernel/thunk.c: + Fetch the stack selector to use from the previous stackframe instead + of the TEB. + + * dlls/ole32/antimoniker.c, dlls/ole32/bindctx.c, + dlls/ole32/clipboard.c, dlls/ole32/compositemoniker.c, + dlls/ole32/datacache.c, dlls/ole32/defaulthandler.c, + dlls/ole32/errorinfo.c, dlls/ole32/filemoniker.c, + dlls/ole32/ftmarshal.c, dlls/ole32/git.c, dlls/ole32/hglobalstream.c, + dlls/ole32/ifs.c, dlls/ole32/itemmoniker.c, + dlls/ole32/memlockbytes.c, dlls/ole32/memlockbytes16.c, + dlls/ole32/moniker.c, dlls/ole32/ole16.c, dlls/ole32/oleobj.c, + dlls/ole32/oleproxy.c, dlls/ole32/regsvr.c, dlls/ole32/stg_prop.c, + dlls/ole32/stg_stream.c, dlls/ole32/storage.c, + dlls/ole32/storage32.c, dlls/ole32/storage32.h, + dlls/ole32/tests/marshal.c, dlls/oleaut32/connpt.c, + dlls/oleaut32/dispatch.c, dlls/oleaut32/oaidl_p.c, + dlls/oleaut32/olefont.c, dlls/oleaut32/olepicture.c, + dlls/oleaut32/recinfo.c, dlls/oleaut32/tests/safearray.c, + dlls/oleaut32/tests/vartype.c, dlls/oleaut32/tmarshal.c, + dlls/oleaut32/typelib.c, dlls/oleaut32/typelib2.c, + dlls/olecli/olecli16.c, dlls/olecli/olecli_main.c, + dlls/olesvr/olesvr_main.c, dlls/qcap/qcap_main.c, + dlls/qcap/vfwcapture.c, dlls/quartz/enummoniker.c, + dlls/quartz/filesource.c, dlls/quartz/filtergraph.c, + dlls/quartz/filtermapper.c, dlls/quartz/main.c, + dlls/quartz/memallocator.c, dlls/quartz/parser.c, dlls/quartz/pin.c, + dlls/quartz/systemclock.c, dlls/quartz/videorenderer.c, + dlls/riched20/richole.c, dlls/rpcrt4/cproxy.c, dlls/rpcrt4/cpsf.c, + dlls/rpcrt4/ndr_ole.c, dlls/shdocvw/classinfo.c, + dlls/shdocvw/events.c, dlls/shdocvw/factory.c, dlls/shdocvw/misc.c, + dlls/shdocvw/oleobject.c, dlls/shdocvw/persist.c, + dlls/shdocvw/shdocvw.h, dlls/shdocvw/shdocvw_main.c, + dlls/shdocvw/webbrowser.c, dlls/shell32/autocomplete.c, + dlls/shell32/cpanelfolder.c, dlls/shell32/dataobject.c, + dlls/shell32/dragdrophelper.c, dlls/shell32/enumidlist.c, + dlls/shell32/folders.c, dlls/shell32/shelllink.c, + dlls/shell32/shellole.c, dlls/shell32/shfldr_desktop.c, + dlls/shell32/shfldr_fs.c, dlls/shell32/shfldr_mycomp.c, + dlls/shell32/shlfsbind.c, dlls/shell32/shlview.c, + dlls/shell32/shv_bg_cmenu.c, dlls/shell32/shv_item_cmenu.c, + dlls/shell32/tests/shellpath.c, dlls/shlwapi/assoc.c, + dlls/shlwapi/istream.c, dlls/shlwapi/regstream.c, + dlls/urlmon/sec_mgr.c, dlls/urlmon/tests/url.c, dlls/urlmon/umon.c, + dlls/urlmon/urlmon_main.c, dlls/wined3d/basetexture.c, + dlls/wined3d/cubetexture.c, dlls/wined3d/device.c, + dlls/wined3d/directx.c, dlls/wined3d/indexbuffer.c, + dlls/wined3d/query.c, dlls/wined3d/resource.c, + dlls/wined3d/stateblock.c, dlls/wined3d/surface.c, + dlls/wined3d/texture.c, dlls/wined3d/vertexbuffer.c, + dlls/wined3d/vertexdeclaration.c, dlls/wined3d/vertexshader.c, + dlls/wined3d/volume.c, dlls/wined3d/volumetexture.c, + dlls/wined3d/wined3d_private.h, dlls/winmm/winealsa/audio.c, + dlls/winmm/wineaudioio/audio.c, dlls/winmm/winejack/audio.c, + dlls/winmm/wineoss/dscapture.c, dlls/winmm/wineoss/dsrender.c: + Dmitry Timoshkov + Make remaining OLE interface vtables const. + + * dlls/shell32/shfldr_unixfs.c: + Michael Jung + Allow for unixfs folders to be rooted at desktop level. + Moved dos->unix path conversion into canonicalize_path. + Fail in BindToObject, if called with empty pidl. + + * tools/winebuild/build.h, tools/winebuild/import.c, + tools/winebuild/spec16.c, tools/winebuild/spec32.c: + Moved all assembly code to the end of the generated C files to avoid + conflicting with the compiler over section changes. + + * configure, configure.ac, dlls/ddraw/Makefile.in, + dlls/ddraw/d3d_utils.c, dlls/ddraw/d3dcommon.c, + dlls/ddraw/d3dexecutebuffer.c, dlls/ddraw/d3dlight.c, + dlls/ddraw/d3dmaterial.c, dlls/ddraw/d3dtexture.c, + dlls/ddraw/d3dvertexbuffer.c, dlls/ddraw/d3dviewport.c, + dlls/ddraw/ddraw_main.c, dlls/ddraw/device_main.c, + dlls/ddraw/device_opengl.c, dlls/ddraw/direct3d_main.c, + dlls/ddraw/direct3d_opengl.c, dlls/ddraw/executebuffer.c, + dlls/ddraw/light.c, dlls/ddraw/main.c, dlls/ddraw/material.c, + dlls/ddraw/mesa.c, dlls/ddraw/mesa_private.h, + dlls/ddraw/opengl_private.h, dlls/ddraw/opengl_utils.c, + dlls/ddraw/surface_main.c, dlls/ddraw/texture.c, + dlls/ddraw/vertexbuffer.c, dlls/ddraw/viewport.c: + Christian Costa + Moved d3ddevice and direct3d objects files to ddraw root dir. + Renamed all remaining files. + + * dlls/ntdll/nt.c, include/winternl.h: + Felix Nawothnig + Make SYSTEM_THREAD_INFORMATION.pszProcessName a UNICODE_STRING. + + * dlls/msi/dialog.c, dlls/msi/events.c, dlls/msi/msipriv.h, + dlls/msi/package.c: + Mike McCormack + Use standard lists in the event subscription code. + + * dlls/msi/action.c: Aric Stewart + Don't get caught in loops on parent progids. + + * include/wincrypt.h: Mike McCormack + Define some Cert* functions. + + * dlls/ntdll/version.c: Mike Hearn + Delete version sniffing logic. + + * dlls/shell32/brsfolder.c, dlls/shell32/shlfolder.c, + dlls/shell32/tests/shlfolder.c: + Michael Jung + Let BindToObject fail, if called with empty relative pidl. + Tests to show that it should do so. + Fix SHBrowseForFolder to not pass an empty pidl to BindToObject. + + * dlls/oleaut32/olepicture.c, dlls/oleaut32/tests/.cvsignore, + dlls/oleaut32/tests/Makefile.in, dlls/oleaut32/tests/olepicture.c: + Marcus Meissner + Added testcases for OLE Picture handling. + Implemented PICTYPE_NONE loading. + Cleaned up stream loading, handle "lt" magic. + Fixed some small problems exposed by tests against native. + + * dlls/winmm/winealsa/audio.c: Robert Reif + Don't open device if already open. + Don't need opened device to get/set volume. + + * dlls/comctl32/tab.c: James Hawkins + Audit the Tab control. + + * programs/winefile/De.rc, programs/winefile/En.rc, + programs/winefile/Makefile.in, programs/winefile/resource.h, + programs/winefile/resource.rc, programs/winefile/winefile.c: + Martin Fuchs + Implement file properties dialog (partly based on Rob D.'s winfile + code). + +2005-06-05 Alexandre Julliard + + * tools/winebuild/import.c, tools/winebuild/spec32.c: + Switch back to .data at the end of asm sections to work around an + optimization in recent gcc versions. + + * dlls/rpcrt4/ndr_midl.c: Mike Hearn + Initialize DataRepresentation in NdrClientInitializeNew, not + NdrSendReceive. + + * dlls/wininet/internet.c: Mike Hearn + - Don't return NULL for proxy details if there is no proxy. + - Remove stub message, it seems to be complete. + + * dlls/ole32/marshal.c: Rob Shearman + Don't disconnect proxies flagged with SORFP_NOLIFETIMEMGMT. It makes + no sense and only causes trouble for proxies that depend on these + proxies being available. + + * dlls/user/edit.c, dlls/user/tests/edit.c: + Lauri Tulmin + Don't truncate text on WM_SETTEXT and send EN_MAXTEXT. + + * dlls/winmm/winealsa/audio.c: Robert Reif + Fix a problem where actual sample rate doesn't exactly match + requested. + + * dlls/quartz/acmwrapper.c, dlls/quartz/enummedia.c, + dlls/quartz/filesource.c, dlls/quartz/parser.c, dlls/quartz/pin.c, + dlls/quartz/transform.c: + Christian Costa + Fixed clock release in transform template. + AddRef pUnk in CopyMediaType. + Added CreateMediaType helper function and use it. + Replaced some DeleteMediaType calls to FreeMediaType to be in line + with recent changes. + Fixed IEnumMediaTypesImpl_Next. + Clear media type when initializing pins. + Added some AddRef/Release traces. + + * programs/winefile/winefile.c: Martin Fuchs + Refresh window content after context menu popups only if any command + has been executed. + + * dlls/kernel/thread.c, dlls/ntdll/ntdll.spec, dlls/ntdll/server.c, + include/wine/server.h: + Moved the server part of the ExitThread functionality to ntdll. + + * tools/winebuild/res32.c, tools/winebuild/spec32.c: + Generate the resource data directly inside the resource directory. + + * dlls/kernel/except.c: + Don't bother looking for a resource directory in free memory areas. + + * dlls/kernel/task.c, dlls/ntdll/thread.c: + Avoid accessing the htask16 TEB field from ntdll. + + * dlls/ntdll/loader.c: + Allocate the system view for builtin modules earlier in + load_builtin_callback so that we also create one for the main + executable. + + * include/winuser.h: Vitaliy Margolen + Match names for WM_SHOWWINDOW status codes to MSDN. + + * dlls/ole32/oleproxy.c: Mike Hearn + Add some tracing to the IRemUnknown RpcProxyBuffer implementation. + + * dlls/winmm/winealsa/audio.c: Robert Reif + Return proper error code. + Change ERR to WARN for failed requests. + + * dlls/oleaut32/tests/typelib.c: Jacek Caban + Test only stdole32.tlb as we don't have olepro32.dll in Wine. + + * dlls/kernel/sync.c: Mike Hearn + Suppress the noisy SetNamedPipeHandleState fixme. + + * programs/winefile/winefile.c, programs/winefile/winefile.h: + Martin Fuchs + Sync winefile's header between WINE and ReactOS. + + * dlls/kernel/tests/pipe.c: + Uwe Bonnes + Added more pipe tests. + + * dlls/dsound/tests/ds3d.c, dlls/dsound/tests/ds3d8.c, + dlls/dsound/tests/dsound.c, dlls/dsound/tests/dsound8.c: + Robert Reif + Fix tests to work with drivers that don't support a primary buffer. + + * dlls/wintrust/wintrust.spec, dlls/wintrust/wintrust_main.c: + Paul Vriens + Added a stub for CryptCATAdminCalcHashFromFileHandle. + + * include/winerror.h: Paul Vriens + Added some error codes. + + * configure, configure.ac, dlls/ddraw/Makefile.in, + dlls/ddraw/surface_dib.c, dlls/ddraw/surface_fakezbuffer.c, + dlls/ddraw/surface_gamma.c, dlls/ddraw/surface_hal.c, + dlls/ddraw/surface_main.c, dlls/ddraw/surface_thunks.c, + dlls/ddraw/surface_user.c, dlls/ddraw/surface_wndproc.c: + Christian Costa + Moved dsurface object files to ddraw root dir. + + * dlls/dsound/capture.c, dlls/dsound/tests/capture.c: + Robert Reif + Add tests to check DirectSoundCapture creation. + Fix dsound/capture.c to pass tests. + +2005-06-04 Alexandre Julliard + + * programs/cmdlgtst/cmdlgtst.c, programs/regedit/edit.c, + programs/regedit/framewnd.c, programs/regedit/listview.c, + programs/regedit/main.c, programs/regedit/regedit.c, + programs/regedit/regproc.c, programs/regedit/regproc.h, + programs/regedit/treeview.c, programs/regsvr32/regsvr32.c, + programs/rpcss/rpcss_main.c, programs/winedbg/dbg.y, + programs/winetest/main.c, programs/winetest/send.c: + Mike McCormack + Fixes for -Wmissing-declarations and -Wwrite-strings warnings. + + * dlls/commdlg/filedlg.c: Huw Davies + If a folder is selected on Open then browse into it, otherwise we + should return the path in the edit box whether that be a folder or a + file. + Don't add extensions to a folder. + + * dlls/comctl32/listview.c: + Felix Nawothnig + Fix some missed invalidations after column resize. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/encode.c: + Juan Lang + Implement asn.1 decoding of integers, with tests. + + * dlls/commdlg/filedlg.c: Huw Davies + Use DWLP_MSGRESULT to return values from the dialog proc. + + * dlls/qcap/Makefile.in, dlls/qcap/capture.h, dlls/qcap/v4l.c, + dlls/qcap/vfwcapture.c: + Maarten Lankhorst + Implemented VfwCapture interface. + + * dlls/msi/action.h, dlls/msi/dialog.c: + Aric Stewart + Mike McCormack + Allow dialog controls to subscribe to installer events. + + * dlls/dsound/capture.c, dlls/dsound/dsound.spec, + dlls/dsound/dsound_main.c, dlls/dsound/dsound_private.h, + dlls/dsound/propset.c, include/dsound.h: + Robert Reif + Finish DirectSoundCapture/DirectSoundCapture8 split. + Add tests to verify split. + + * dlls/quartz/videorenderer.c: Christian Costa + Release clock only when one is set. + + * dlls/comctl32/tab.c: James Hawkins + - Factor out common text shifting logic. + - Shift selected tab text up instead of down. + + * include/winerror.h: Juan Lang + Added a bunch of crypto error codes. + + * dlls/msi/format.c: Aric Stewart + Make sure the TRACE statements do not spew garbage by using + debugstr_wn. + + * dlls/commdlg/filedlg.c: Huw Davies + Send CDN_FOLDERCHANGE whenever we change folder. + + * dlls/mlang/tests/Makefile.in: Hans Leidekker + Remove ntdll from imports. + + * dlls/msi/dialog.c: Mike McCormack + Take the dialog frame into account when calculating the dialog size. + + * dlls/msi/action.c: Aric Stewart + Since multiple progids can refer to 1 class we need to check if that + class is isntalled instead of just relying on having it set the + InstallMe variable. + + * configure, configure.ac, dlls/ddraw/Makefile.in, + dlls/ddraw/ddraw_hal.c, dlls/ddraw/ddraw_main.c, + dlls/ddraw/ddraw_thunks.c, dlls/ddraw/ddraw_user.c: + Christian Costa + Moved ddraw object files to ddraw root dir. + +2005-06-03 Alexandre Julliard + + * configure, configure.ac, dlls/ddraw/Makefile.in, + dlls/ddraw/clipper.c, dlls/ddraw/palette_hal.c, + dlls/ddraw/palette_main.c: + Christian Costa + Moved clipper and palette objects files to ddraw root dir. + + * tools/wine.inf: Lionel Ulmer + Added keys to install all known DPlay service providers. + + * dlls/capi2032/capi2032.spec: Troy Rollo + Remove CR characters. + + * dlls/crypt32/cert.c: Juan Lang + Get rid of a magic number, and improve stubs of + CertOpenSystemStoreA/W. + + * dlls/crypt32/encode.c: Juan Lang + Rearrange Crypt{De|En}codeObjectEx to make error handling more + natural. + + * programs/winefile/winefile.c: Martin Fuchs + Fix position of column header labels. + + * dlls/msi/msi.c: Aric Stewart + Locate where a buffer size is not being set and correctly handle the + buffer size conversion from W to A (with help from Robert Shearman). + + * dlls/ntdll/nt.c, include/winternl.h: + Paul Vriens + Change SYSTEM_PROCESS_INFORMATION to reflect W2K/WinXP/W2K3 structure. + + * dlls/msi/action.c: Aric Stewart + Add install_on_demand for Extension servers also. currently defaulting + to TRUE. + Extension need to have 1 verb to mark the given progid to be + installed. + +2005-06-02 Alexandre Julliard + + * dlls/ole32/tests/moniker.c: Richard Cohen + - Don't assume the ROT is already empty. + - Test that IEnum::Clone doesn't also do a Reset. + + * dlls/ole32/moniker.c: Richard Cohen + IEnum::Clone shouldn't do a Reset. + + * dlls/msi/action.c, dlls/msi/action.h: + Aric Stewart + Do not loop if a ProgId's Parent Index it itself. + Add a VersionIndIndex for tracking version independent fields for the + ProgIds properly. + + * dlls/msdmo/dmoreg.c: Marcus Meissner + Drop duplicate definition of IID_IEnumDMO. + + * dlls/ole32/tests/moniker.c: Richard Cohen + Added tests for file monikers. + + * dlls/ole32/filemoniker.c: Richard Cohen + - Base FileMonikerImpl_Save() on XP. + - Correct handling of Unicode strings & multibyte locales. + - More error checking. + - Change ERR to WARN. + - Match Windows quick & dirty estimate for GetSizeMax(). + + * dlls/msi/dialog.c: Mike McCormack + Use MSI_QueryGetRecord in one more place. + + * include/wincrypt.h: Juan Lang + Added a couple missing prototypes. + + * dlls/msi/action.c: Aric Stewart + Print a message for skipped actions in ProcessExecSequence like in the + UISequence. + + * dlls/shell32/shellpath.c, dlls/shell32/tests/shellpath.c: + Juan Lang + Set default for "My Documents" to $HOME, and "Desktop" to ~/Desktop. + + * dlls/msi/action.c: Aric Stewart + Do not change a features state to Advertise if it explicitly disallows + it. + + * dlls/msi/action.c: Aric Stewart + For typelibs index 1 do not add \\1 to the path. This cleans up + registry diffs with native MSI. + + * programs/winecfg/appdefaults.c, programs/winecfg/audio.c, + programs/winecfg/drive.c, programs/winecfg/drivedetect.c, + programs/winecfg/driveui.c, programs/winecfg/libraries.c, + programs/winecfg/main.c, programs/winecfg/winecfg.c, + programs/winecfg/winecfg.h, programs/winecfg/x11drvdlg.c, + programs/winemenubuilder/winemenubuilder.c, programs/winemine/main.c, + programs/winetest/gui.c, programs/winhelp/macro.c: + Mike McCormack + Fixes for -Wmissing-declarations and -Wwrite-strings warnings. + + * dlls/msi/action.c: Aric Stewart + Register the FileType and correct short vs long path problems with + InprocServer32. Also add install_on_demand boolean for future + expansion. + + * programs/winecfg/De.rc, programs/winecfg/winecfg.rc, + programs/winefile/De.rc: + Henning Gerhardt + Update German resource files. + + * dlls/user/message.c: Dmitry Timoshkov + Update internal state only if the message is being removed. + + * dlls/Makefile.in: + Temp hack to clean up .def files and hopefully avoid more bug + reports about failed builds. + + * dlls/crypt32/encode.c, dlls/crypt32/tests/.cvsignore, + dlls/crypt32/tests/Makefile.in, dlls/crypt32/tests/encode.c, + include/wincrypt.h: + Juan Lang + - add some tests for OID functions + - implement encoding integers + + * dlls/ddraw/ddraw_private.h: Christian Costa + Merged remaining header files in DirectDraw objects folders into + ddraw_private.h. + + * dlls/kernel/tests/locale.c: Mike McCormack + Make sure that unused code gets compiled to avoid warnings. + + * dlls/kernel/kernel32.spec, dlls/kernel/volume.c: + Marcus Meissner + Added stubs for GetVolumePathName(A,W). + + * loader/preloader.c: Marcus Meissner + Elf32_auxv_t.a_un.a_ptr no longer exists in HEAD glibc CVS, use + a_val. + + * dlls/msi/action.c, dlls/msi/custom.c: + Mike McCormack + Use the new helper function MSI_QueryGetRecord. + + * dlls/msi/dialog.c, dlls/msi/msipriv.h, dlls/msi/msiquery.c: + Mike McCormack + Create a helper function to fetch a single record from a query. + + * programs/wineboot/wineboot.c: Juan Lang + Print command that fails to make error message a little more + comprehensible. + + * dlls/dsound/Makefile.in, dlls/dsound/capture.c, dlls/dsound/duplex.c: + Robert Reif + Move FullDuplex code from capture.c to duplex.c. + + * include/Makefile.in, include/snmp.h: Juan Lang + Added snmp.h. + +2005-06-01 Alexandre Julliard + + * dlls/win32s/w32skernel.c: Avoid dependency on thread.h. + + * dlls/dsound/propset.c: Robert Reif + Fix property set description for more than one capture device bug. + Add better traces messages. + + * dlls/dmsynth/dmsynth_main.c, dlls/dmsynth/dmsynth_private.h, + dlls/dmsynth/synth.c, dlls/dmsynth/synthsink.c, dlls/dmusic/buffer.c, + dlls/dmusic/clock.c, dlls/dmusic/collection.c, dlls/dmusic/dmusic.c, + dlls/dmusic/dmusic_main.c, dlls/dmusic/dmusic_private.h, + dlls/dmusic/download.c, dlls/dmusic/downloadedinstrument.c, + dlls/dmusic/instrument.c, dlls/dmusic/port.c, + dlls/dmusic/portdownload.c, dlls/dmusic/thru.c, + dlls/dplayx/dpclassfactory.c, dlls/dplayx/dplay.c, + dlls/dplayx/dplay_global.h, dlls/dplayx/dplaysp.c, + dlls/dplayx/dplobby.c, dlls/dplayx/lobbysp.c, dlls/dpnet/address.c, + dlls/dpnet/client.c, dlls/dpnet/dpnet_main.c, + dlls/dpnet/dpnet_private.h, dlls/dsound/buffer.c, + dlls/dsound/capture.c, dlls/dsound/dsound.c, + dlls/dsound/dsound_main.c, dlls/dsound/dsound_private.h, + dlls/dsound/primary.c, dlls/dsound/propset.c, dlls/dsound/sound3d.c, + dlls/dswave/dswave.c, dlls/dswave/dswave_main.c, + dlls/dswave/dswave_private.h, dlls/dxdiagn/container.c, + dlls/dxdiagn/dxdiag_main.c, dlls/dxdiagn/dxdiag_private.h, + dlls/dxdiagn/provider.c, dlls/itss/itss.c, dlls/itss/moniker.c, + dlls/itss/storage.c, dlls/mapi32/prop.c, dlls/mlang/mlang.c, + dlls/msdmo/dmoreg.c, dlls/mshtml/htmldoc.c, + dlls/mshtml/mshtml_private.h, dlls/mshtml/oleobj.c, + dlls/mshtml/persist.c, dlls/mshtml/view.c, dlls/msi/msi.c: + Dmitry Timoshkov + Make more of the OLE interface vtables const. + + * dlls/ddraw/d3d_private.h: Christian Costa + Merged d3ddevice/main.h and direct3d/main.h into d3d_private.h. + Fixed Thunk_IDirect3DImpl_2_CreateViewport. + + * include/commctrl.h: Dimi Paun + Minor formattting fixes. + + * include/winuser.h: Dimi Paun + Add definitions for IDTRYAGAIN and IDCONTINUE. + + * dlls/wintrust/wintrust.spec, dlls/wintrust/wintrust_main.c: + Mike McCormack + Add stubs and stub implementations. + + * include/wintrust.h: Mike McCormack + Define some functions and structures. + + * dlls/msi/dialog.c: Aric Stewart + Mike McCormack + Fix handling of checkbox properties. + + * dlls/x11drv/desktop.c, dlls/x11drv/event.c, dlls/x11drv/init.c, + dlls/x11drv/x11drv.h, dlls/x11drv/x11drv_main.c: + Use standard TLS functions instead of a TEB internal field to access + per-thread data. + + * dlls/gdi/gdi_main.c: Always load 16-bit gdi.exe at init time. + + * dlls/setupapi/parser.c: + Revert previous change, it shouldn't be necessary (reported by Rob + Shearman). + + * dlls/shell32/tests/shelllink.c, dlls/shell32/tests/shlfileop.c, + dlls/shell32/tests/shlfolder.c: + Mike McCormack + Eliminate some -Wwrite-strings warnings. + + * dlls/rpcrt4/ndr_marshall.c: Robert Shearman + - Improve tracing. + - Implement FC_UP and partially FC_OP. + - Don't needlessly marshal 4 bytes in NdrPointer*. + + * dlls/oleaut32/tmarshal.c: Robert Shearman + If we are accessing a method from a superclass then we need to use the + superclass's ITypeInfo otherwise we could get errors when accessing + hreftypes that aren't present in the subclass. + + * dlls/oleaut32/typelib.c: Robert Shearman + - Fix the return values from QueryPathOfRegTypeLib. + - Open registry key with least access rights necessary. + - Documentation updates. + + * dlls/oleaut32/dispatch.c: Robert Shearman + DispInvoke is correct so there is no need to print a fixme. + + * dlls/msi/format.c: Mike McCormack + Clean up headers and make some functions static. + + * dlls/msvideo/drawdib.c: Richard Cohen + - Add static, const. + - Don't change the passed in bitmap header. + + * dlls/msi/msipriv.h: Mike McCormack + - avoid unicode.h + - add a missing function prototype + +2005-05-31 Alexandre Julliard + + * dlls/user/tests/win.c: Jason Edmeades + Added test case for infinite loops on RDW_REDRAWNOW. + + * dlls/user/painting.c, include/wine/server_protocol.h, + server/protocol.def, server/trace.c, server/window.c: + Added a from_child parameter to the get_update_region request to allow + restarting the search from a given child, in order to avoid looping + forever on windows that don't repaint correctly. + + * dlls/setupapi/parser.c: Skip the Unicode signature if present. + + * dlls/kernel/instr.c: Ivan Leo Puoti + Added IDT emulation. + + * dlls/ntdll/directory.c: Detlef Riekenberg + Mark links to dir with FILE_ATTRIBUTE_REPARSE_POINT, so modern + applications can use this additional information. + + * dlls/advapi32/advapi.c, dlls/advapi32/advapi32.spec, + dlls/kernel/profile.c, dlls/ntdll/rtlstr.c, include/winbase.h, + include/winternl.h: + Fixed RtlIsTextUnicode prototype, and made it properly take into + account the results of the tests to determine the return value. + + * include/commctrl.h: Andreas Mohr + TV_ITEM is the old name of TVITEM, shouldn't be used any more. + + * dlls/msi/action.c, dlls/msi/query.h: + Mike McCormack + Remove some unused code. + + * dlls/winspool/Makefile.in: Remove import lib on make clean. + + * dlls/wineps/Makefile.in: + Fixed install rule (reported by Vincent Béron). + + * dlls/version/tests/.cvsignore, dlls/version/tests/Makefile.in, + dlls/version/tests/info.c, dlls/version/tests/version.rc: + Stefan Leichter + Test GetFileVersionInfoSizeA with executables. + + * dlls/ddraw/Makefile.in, dlls/ddraw/convert.c, + dlls/ddraw/ddraw_utils.c, dlls/ddraw/helper.c, + dlls/ddraw/struct_convert.c: + Christian Costa + Merged convert.c, struct_convert.c and helper.c into ddraw_utils.c. + + * dlls/ntdll/sec.c: Evan Deaubl + Robert Shearman + - Implement RtlGetControlSecurityDescriptor. + - Fix NtAccessCheck so it works with relative SECURITY_DESCRIPTORs. + + * dlls/crypt32/crypt32.spec, dlls/crypt32/encode.c, + dlls/crypt32/main.c: + Juan Lang + - implement Crypt{Get|Set}OIDFunctionValue + - fix bug and memory leak in last patch + + * dlls/dsound/buffer.c, dlls/dsound/dsound.c, + dlls/dsound/dsound_main.c, dlls/dsound/dsound_private.h, + dlls/dsound/mixer.c, dlls/dsound/primary.c, dlls/dsound/sound3d.c: + Robert Reif + Add multiple DIRECTSOUND object support (multiple sound cards can play + at the same time). + Fix CoCreateInstance when no sound card is present. + Fix create bug found by Mike Hearn. + + * dlls/kernel/tests/drive.c, dlls/kernel/tests/format_msg.c, + dlls/kernel/tests/locale.c, dlls/kernel/tests/path.c: + Mike McCormack + Some warning fixes for the regression tests. + + * dlls/msi/database.c, dlls/msi/dialog.c, dlls/msi/events.c, + dlls/msi/msipriv.h, dlls/msi/msiquery.c, dlls/msi/package.c, + dlls/msi/record.c, dlls/msi/table.c: + Mike McCormack + More -Wmissing-declarations and -Wwrite-strings warning fixes. + + * dlls/msi/sql.y: Mike McCormack + Improve number parsing and avoid unicode.h. + +2005-05-30 Alexandre Julliard + + * dlls/ntdll/directory.c: Francois Gouget + On some systems (linux 2.6.8) AFS fails to set d_reclen to 0 or does + not support VFAT_IOCTL_READDIR_BOTH but returns 0 (success) anyway. So + set d_reclen to 65535 (an impossible value) before the ioctl() and + check it afterwards to work around this bug. + + * dlls/msi/insert.c, dlls/msi/query.h, dlls/msi/sql.y: + Mike McCormack + Remove more types from the parser. + + * dlls/msi/msi.c, dlls/msi/suminfo.c, include/msi.h, + include/msiquery.h: + Mike McCormack + Add and correct some function declarations. + + * dlls/winmm/wineoss/audio.c, dlls/winmm/wineoss/audio.h: + Robert Reif + Add support for more than 2 audio channels. + + * dlls/ddraw/tests/.cvsignore, dlls/ddraw/tests/Makefile.in, + dlls/ddraw/tests/dsurface.c: + Antoine Chavasse + - Implemented the implicit creation of mipmaps for surfaces that have + DDSCAPS_COMPLEX, DDSCAPS_MIPMAP and for which the mipmap count is + not specified. + - Implemented test cases for mipmap textures creation. + + * dlls/comctl32/listview.c: Kouji Sasaki + Added the feature to change row height in owner draw controls. + + * dlls/user/edit.c: Kouji Sasaki + Corrected the determination of capturing inside EDIT_WM_MouseMove + function. + + * dlls/devenum/createdevenum.c, dlls/devenum/devenum_private.h, + dlls/devenum/factory.c, dlls/devenum/mediacatenum.c, + dlls/devenum/parsedisplayname.c, dlls/dinput/device_private.h, + dlls/dinput/dinput_main.c, dlls/dinput/dinput_private.h, + dlls/dinput/joystick_linux.c, dlls/dinput/joystick_linuxinput.c, + dlls/dinput/keyboard.c, dlls/dinput/mouse.c, dlls/dmband/band.c, + dlls/dmband/bandtrack.c, dlls/dmband/dmband_main.c, + dlls/dmband/dmband_private.h, dlls/dmcompos/chordmap.c, + dlls/dmcompos/chordmaptrack.c, dlls/dmcompos/composer.c, + dlls/dmcompos/dmcompos_main.c, dlls/dmcompos/dmcompos_private.h, + dlls/dmcompos/signposttrack.c, dlls/dmime/audiopath.c, + dlls/dmime/dmime_main.c, dlls/dmime/dmime_private.h, + dlls/dmime/graph.c, dlls/dmime/lyricstrack.c, + dlls/dmime/markertrack.c, dlls/dmime/paramcontroltrack.c, + dlls/dmime/patterntrack.c, dlls/dmime/performance.c, + dlls/dmime/segment.c, dlls/dmime/segmentstate.c, + dlls/dmime/segtriggertrack.c, dlls/dmime/seqtrack.c, + dlls/dmime/sysextrack.c, dlls/dmime/tempotrack.c, + dlls/dmime/timesigtrack.c, dlls/dmime/tool.c, dlls/dmime/wavetrack.c, + dlls/dmloader/classfactory.c, dlls/dmloader/container.c, + dlls/dmloader/dmloader_private.h, dlls/dmloader/loader.c, + dlls/dmloader/loaderstream.c, dlls/dmscript/dmscript_main.c, + dlls/dmscript/dmscript_private.h, dlls/dmscript/script.c, + dlls/dmscript/scripttrack.c, dlls/dmstyle/auditiontrack.c, + dlls/dmstyle/chordtrack.c, dlls/dmstyle/commandtrack.c, + dlls/dmstyle/dmstyle_main.c, dlls/dmstyle/dmstyle_private.h, + dlls/dmstyle/motiftrack.c, dlls/dmstyle/mutetrack.c, + dlls/dmstyle/style.c, dlls/dmstyle/styletrack.c: + Dmitry Timoshkov + Make more of the OLE interface vtables const. + + * dlls/comctl32/monthcal.c, dlls/crypt32/protectdata.c, + dlls/msi/action.h, dlls/opengl32/make_opengl, + dlls/wined3d/vertexdeclaration.c, dlls/winmm/winmm_En.rc: + Francois Gouget + Assorted spelling fixes. + + * programs/msiexec/version.rc: + Stefan Leichter + Update version resource of msiexec.exe to current version shipped from + Windows Update. + + * programs/winefile/Cs.rc, programs/winefile/De.rc, + programs/winefile/En.rc, programs/winefile/Es.rc, + programs/winefile/Fr.rc, programs/winefile/Hu.rc, + programs/winefile/It.rc, programs/winefile/Nl.rc, + programs/winefile/Pl.rc, programs/winefile/Pt.rc, + programs/winefile/Ru.rc, programs/winefile/Si.rc, + programs/winefile/Sv.rc, programs/winefile/Zh.rc, + programs/winefile/resource.h, programs/winefile/resource.rc, + programs/winefile/winefile.c: + Martin Fuchs + - implement commands 'copy' and 'delete' + - fix 'move' command for the left pane + +2005-05-29 Alexandre Julliard + + * dlls/oleaut32/oleaut32.spec, dlls/oleaut32/varformat.c: + Marcus Meissner + Added VarMonthName() implementation. + + * dlls/msi/create.c, dlls/msi/insert.c, dlls/msi/order.c, + dlls/msi/query.h, dlls/msi/select.c, dlls/msi/sql.y, + dlls/msi/update.c: + Mike McCormack + Get rid of some redundant parser types. + + * programs/winefile/winefile.c: Martin Fuchs + Refresh display after executing a context menu command. + + * dlls/msi/cond.y, dlls/msi/format.c, dlls/msi/tests/db.c, + dlls/msi/tests/record.c, dlls/msi/tokenize.c, dlls/msi/where.c: + Mike McCormack + -Wmissing-declarations and -Wwrite-strings warning fixes. + + * programs/winefile/Cs.rc, programs/winefile/De.rc, + programs/winefile/En.rc, programs/winefile/Es.rc, + programs/winefile/Fr.rc, programs/winefile/Hu.rc, + programs/winefile/It.rc, programs/winefile/Makefile.in, + programs/winefile/Nl.rc, programs/winefile/Pl.rc, + programs/winefile/Pt.rc, programs/winefile/Ru.rc, + programs/winefile/Si.rc, programs/winefile/Sv.rc, + programs/winefile/Zh.rc, programs/winefile/resource.h, + programs/winefile/winefile.c: + Martin Fuchs + Implement file filtering (matching of file name patterns and file + types). + + * dlls/msvcrt/dir.c, dlls/msvcrt/msvcrt.spec: + Eric Pouech + _findclose() exists on MinGW, so prefix it. + + * programs/winedbg/gdbproxy.c: Eric Pouech + Reindented parts to be conform to the rest of the code. + + * programs/winedbg/stack.c: Eric Pouech + Rewrote all stack backtrace code (more code sharing, easier to follow, + and less bugs). + + * include/winbase.h: Mike McCormack + - always declare the lstr* functions, even if they're inline + - add prototype for ReadDirectoryChangesW + + * dlls/winmm/winealsa/alsa.h: Marcus Meissner + #undef interface before including alsa headers. + + * dlls/winmm/wineoss/audio.c: Robert Reif + Fix a multiple sound card interface bug. + Add better error messages. + + * dlls/dbghelp/dbghelp.spec, dlls/dbghelp/module.c: + Paul Vriens + Add SymLoadModule64. + + * dlls/comctl32/listview.c: + Felix Nawothnig + Pass the right hwnd to ReleaseDC(). + + * dlls/winmm/winealsa/audio.c: Robert Reif + Fix volume control. + + * dlls/d3d8/d3d8_private.h: + Kristiaan Lenaerts + gcc 4.0 compile fix. + + * dlls/x11drv/keyboard.c: Dmitry Timoshkov + Fix Estonian keyboard layout to better match the X11 one. + + * dlls/qcap/dllsetup.c: Francois Gouget + Remove unneeded cast. + + * dlls/oleaut32/tests/vartest.c: + Michael Stefaniuc + Tests for VarAdd. + + * dlls/oleaut32/variant.c: Michael Stefaniuc + - Reimplement VarAdd, had missing functionality and wrong behaviour. + - Fix a typo in VarMul. + + * dlls/kernel/local16.c: Dimi Paun + Fix indentation. + + * programs/winetest/Makefile.in: + Stefan Leichter + Include crypt32 tests into winetest. + + * dlls/crypt32/encode.c: Juan Lang + Use registered DLLs for encode/decode. + + * include/wincrypt.h: Juan Lang + Add a few missing defines. + +2005-05-27 Alexandre Julliard + + * dlls/amstream/amstream.c, dlls/amstream/main.c, dlls/atl/registrar.c, + dlls/avifil32/acmstream.c, dlls/avifil32/avifile.c, + dlls/avifil32/editstream.c, dlls/avifil32/factory.c, + dlls/avifil32/getframe.c, dlls/avifil32/icmstream.c, + dlls/avifil32/tmpfile.c, dlls/avifil32/wavfile.c, + dlls/comcat/comcat_private.h, dlls/comcat/factory.c, + dlls/comcat/information.c, dlls/comcat/manager.c, + dlls/comcat/register.c, dlls/commdlg/filedlgbrowser.c, + dlls/d3d8/basetexture.c, dlls/d3d8/cubetexture.c, + dlls/d3d8/d3d8_private.h, dlls/d3d8/device.c, dlls/d3d8/directx.c, + dlls/d3d8/indexbuffer.c, dlls/d3d8/resource.c, dlls/d3d8/surface.c, + dlls/d3d8/swapchain.c, dlls/d3d8/texture.c, dlls/d3d8/vertexbuffer.c, + dlls/d3d8/volume.c, dlls/d3d8/volumetexture.c, + dlls/d3d9/basetexture.c, dlls/d3d9/cubetexture.c, + dlls/d3d9/d3d9_private.h, dlls/d3d9/device.c, dlls/d3d9/directx.c, + dlls/d3d9/indexbuffer.c, dlls/d3d9/pixelshader.c, dlls/d3d9/query.c, + dlls/d3d9/resource.c, dlls/d3d9/stateblock.c, dlls/d3d9/surface.c, + dlls/d3d9/swapchain.c, dlls/d3d9/texture.c, dlls/d3d9/vertexbuffer.c, + dlls/d3d9/vertexdeclaration.c, dlls/d3d9/vertexshader.c, + dlls/d3d9/volume.c, dlls/d3d9/volumetexture.c, + dlls/d3dx8/d3dx8core_private.h, dlls/d3dx8/d3dxbuffer.c, + dlls/d3dxof/d3dxof.c, dlls/d3dxof/d3dxof_private.h, + dlls/d3dxof/main.c, dlls/ddraw/d3dexecutebuffer.c, + dlls/ddraw/d3dlight.c, dlls/ddraw/d3dmaterial.c, + dlls/ddraw/d3dtexture.c, dlls/ddraw/d3dvertexbuffer.c, + dlls/ddraw/d3dviewport.c, dlls/ddraw/main.c, include/objbase.h: + Dmitry Timoshkov + Make some of the OLE interface vtables const. + + * include/wine/test.h, programs/winetest/main.c: + Added --list option to the tests and use that in winetest. + + * dlls/kernel/instr.c: Ivan Leo Puoti + Added some privileged instructions emulation. + + * dlls/gdi/gdiobj.c, programs/winevdm/winevdm.c: + Dimi Paun + Move remaining GDI objects to the large heap. + + * dlls/ntdll/loadorder.c, dlls/user/msgbox.c, dlls/user/nonclient.c, + dlls/user/text.c: + Richard Cohen + Fix some obsolete comments + + * dlls/msi/tests/.cvsignore, dlls/msi/tests/Makefile.in, + dlls/msi/tests/db.c, dlls/msi/tests/format.c: + Mike McCormack + Aric Stewart + Add format record tests. + + * dlls/msi/action.c, dlls/msi/action.h, dlls/msi/custom.c, + dlls/msi/events.c, dlls/msi/msipriv.h: + Aric Stewart + Introduce really basic scripting of actions. This is primarily to get + the order of execution of the action correct since some custom actions + can be scripted and others are run during the script building phase. + + * dlls/msi/format.c: Aric Stewart + Restrict deformating of nested index keys [[1]]. + Introduce the beginning of group deformating {}. + + * dlls/rsaenh/Makefile.in, dlls/rsaenh/rsaenh.c: + Michael Jung + Use the Data Protection API to protect the users private keys. + + * dlls/crypt32/protectdata.c: Michael Jung + It's sufficienct for Crypt[Un]ProtectData to acquire the crypto + context with the CRYPT_VERIFY_CONTEXT flag set. + + * dlls/qcap/Makefile.in, dlls/qcap/capture.h, dlls/qcap/qcap_main.c, + dlls/qcap/vfwcapture.c: + Maarten Lankhorst + Implemented VfwCapture interface. + + * dlls/rsaenh/implglue.c: Michael Jung + Use SystemFunction036 to generate random bytes. + + * include/vfw.h: Rolf Kalbermatter + Add declarations for AVICAP and SDK part of Video Capture Driver + Interface. + + * dlls/msi/record.c, dlls/msi/tests/record.c: + Mike McCormack + Test and fix the size of stream fields in a record. + + * dlls/msi/Makefile.in, dlls/msi/action.c, dlls/msi/action.h, + dlls/msi/events.c, dlls/msi/msipriv.h: + Aric Stewart + Mike McCormack + Implement dialog events and hook up the dialog code. + + * dlls/uuid/uuid.c: Mike McCormack + Add xmldom guids. + + * dlls/amstream/amstream.c: Peter Oberndorfer + Use proper return values in amstream stub functions. + +2005-05-26 Alexandre Julliard + + * dlls/shell32/shfldr_desktop.c, dlls/shell32/shfldr_fs.c, + dlls/shell32/shfldr_mycomp.c: + Stefan Dösinger + *Handle cidl==0 in shfldr_desktop, shfldr_fs and shfldr_mycomp. + *Remove the dwAttributes member from the IGenericSFImpl class, it's + not needed and can't be initialised in Initialize and InitializeEx. + + * dlls/msi/action.c, dlls/msi/action.h: + Aric Stewart + First pass at writing out CurVer keys for ProgIds. Also print a + message for the actions we skip. Lines up with native MSI output logs + for ease of comparison. + + * dlls/odbccp32/odbccp32.c, dlls/odbccp32/odbccp32.spec, + include/odbcinst.h: + Rein Klazes + Add a stub for ODBCCPlApplet. + + * dlls/powrprof/powrprof.c, dlls/powrprof/powrprof.spec: + Rein Klazes + Add a stub for IsAdminOverrideActive. + + * dlls/ntdll/file.c: + Uwe Bonnes + Call fileio_terminate for FILE_AsyncWriteService. + + * server/window.c: + Crop the update region to the new window rectangle when resizing a + window. + + * dlls/user/spy.c: + Don't fetch the window class name if it's not needed to compute the + message name. + + * dlls/msi/action.c, dlls/msi/action.h, dlls/msi/msipriv.h: + Aric Stewart + A big rewrite of the whole RegisterClass, RegisterProgId, + RegisterExtension and RegisterMIME actions. We now handle verbs + properly, handle dependancies and such properly and keep track of what + we need to register and what we do not properly. + + * dlls/commdlg/filedlg.c, dlls/commdlg/filedlgbrowser.c: + Michael Jung + Use IShellFolder::GetDisplayNameOf instead of SHGetPathFromIDList to + be able to browse shell namespace extensions. + + * dlls/comctl32/listview.c: Kouji Sasaki + Added the callback item processing for LISTVIEW_EndEditLabelT + function. + + * include/.cvsignore, include/Makefile.in, include/xmldom.idl, + include/xmldomdid.h: + Mike McCormack + Added some idl definitions. + + * tools/widl/parser.y: + Workaround to allow using the async keyword as method name. + +2005-05-25 Alexandre Julliard + + * dlls/user/Makefile.in, dlls/user/cursoricon.c, dlls/user/misc.c, + dlls/user/sysparams.c, dlls/user/user_main.c: + Moved functions from windows/user.c to more appropriate places, and + get rid of that file. + + * server/console.c, server/fd.c, server/file.c, server/mailslot.c, + server/main.c, server/named_pipe.c, server/process.c, server/queue.c, + server/region.c, server/registry.c, server/request.c, + server/signal.c, server/snapshot.c, server/sock.c, server/timer.c: + Robert Shearman + - Use NULL instead of 0 for all non-handle pointers. + - Fix non-ANSI function declarations. + - Make a function static. + + * dlls/user/user16.c: + Moved a couple of 16-bit functions to dlls/user/user16.c. + + * dlls/user/sysparams.c: Rein Klazes + Use the screen resolution to convert from twips (1440 twips is one + inch) to pixels. + + * dlls/user/Makefile.in, dlls/user/sysparams.c, dlls/user/user16.c, + dlls/user/user_private.h: + Moved the syscolor functions to dlls/user/sysparams.c. + + * dlls/msi/format.c: Aric Stewart + Implement the [!file] format to produce the short filename. + + * include/winbase.h: + Uwe Bonnes + Fix small typo. + + * include/Makefile.in, include/idispids.h, include/xmldomdid.h: + Mike McCormack + Add some more headers. + + * include/wine/test.h, tools/make_ctests.c: + Better support for building stand-alone tests. + + * dlls/gdi/gdi32.spec, dlls/gdi/gdiobj.c: Dimi Paun + Turn a GDI object into a system object via an explicit Wine extension + rather then through magical pokes in memory. + + * dlls/kernel/tests/mailslot.c, dlls/kernel/tests/pipe.c, + dlls/lzexpand/tests/lzexpand_main.c: + Removed STANDALONE ifdefs. + + * dlls/urlmon/umon.c, dlls/urlmon/urlmon.spec: + Mike McCormack + Stub implementation for GetSoftwareUpdateInfo. + + * server/trace.c: Robert Shearman + - Print commas between ACE's. + - Dump access masks from all ACE's. + + * dlls/comctl32/listview.c: Kouji Sasaki + Corrected the priority of operators for LISTVIEW_GetNextItem + function. + +2005-05-24 Alexandre Julliard + + * ANNOUNCE, ChangeLog, VERSION, configure: Release 20050524. + +---------------------------------------------------------------- 2005-05-24 Alexandre Julliard * dlls/qcap/Makefile.in, dlls/qcap/qcap_main.h, dlls/qcap/yuv.c: diff -urN wine-20050524/DEVELOPERS-HINTS wine-20050628/DEVELOPERS-HINTS --- wine-20050524/DEVELOPERS-HINTS 2005-04-20 21:15:31.000000000 +0200 +++ wine-20050628/DEVELOPERS-HINTS 2005-06-09 12:07:04.000000000 +0200 @@ -242,15 +242,6 @@ tools/wrc/ - the resource compiler -Miscellaneous: --------------- - -Note: these directories will ultimately get moved into their -respective dlls. - - windows/ - USER window management - - IMPLEMENTING NEW API CALLS ========================== diff -urN wine-20050524/Makefile.in wine-20050628/Makefile.in --- wine-20050524/Makefile.in 2005-03-02 13:18:55.000000000 +0100 +++ wine-20050628/Makefile.in 2005-06-15 20:12:15.000000000 +0200 @@ -42,7 +42,6 @@ # Sub-directories to install for install-lib INSTALLLIBSUBDIRS = \ - documentation \ $(FONTSSUBDIRS) \ loader \ programs \ @@ -141,17 +140,8 @@ tags ctags: find $(TOPSRCDIR) -name '*.[ch]' -a -not -name '*.spec.c' -a -not -name '*.dbg.c' -print | ctags --c-types=+px -L - -manpages: - $(MKINSTALLDIRS) $(TOPOBJDIR)/documentation/man3w - cd dlls && $(MAKE) man - -htmlpages: - $(MKINSTALLDIRS) $(TOPOBJDIR)/documentation/html - cd dlls && $(MAKE) doc-html - -sgmlpages: - $(MKINSTALLDIRS) $(TOPOBJDIR)/documentation/api-guide - cd dlls && $(MAKE) doc-sgml +manpages htmlpages sgmlpages: + cd documentation && $(MAKE) $@ clean:: $(RM) wine @@ -161,6 +151,6 @@ $(RM) -r autom4te.cache $(RM) `find . \( -name Makefile -o -size 0 \) -print` -.PHONY: manpages htmlpages distclean +.PHONY: manpages htmlpages sgmlpages distclean ### Dependencies: diff -urN wine-20050524/VERSION wine-20050628/VERSION --- wine-20050524/VERSION 2005-05-24 16:16:16.000000000 +0200 +++ wine-20050628/VERSION 2005-06-28 16:39:20.000000000 +0200 @@ -1 +1 @@ -Wine version 20050524 +Wine version 20050628 diff -urN wine-20050524/configure wine-20050628/configure --- wine-20050524/configure 2005-05-24 16:16:16.000000000 +0200 +++ wine-20050628/configure 2005-06-28 16:39:20.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for Wine 20050524. +# Generated by GNU Autoconf 2.59 for Wine 20050628. # # Report bugs to . # @@ -269,8 +269,8 @@ # Identity of this package. PACKAGE_NAME='Wine' PACKAGE_TARNAME='wine' -PACKAGE_VERSION='20050524' -PACKAGE_STRING='Wine 20050524' +PACKAGE_VERSION='20050628' +PACKAGE_STRING='Wine 20050628' PACKAGE_BUGREPORT='wine-devel@winehq.org' ac_unique_file="server/atom.c" @@ -788,7 +788,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Wine 20050524 to adapt to many kinds of systems. +\`configure' configures Wine 20050628 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -853,7 +853,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Wine 20050524:";; + short | recursive ) echo "Configuration of Wine 20050628:";; esac cat <<\_ACEOF @@ -984,7 +984,7 @@ test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -Wine configure 20050524 +Wine configure 20050628 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -998,7 +998,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Wine $as_me 20050524, which was +It was created by Wine $as_me 20050628, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -8150,7 +8150,7 @@ if test "x$with_opengl" != "xno" then - if test -f /usr/X11R6/lib/libGL.a -a ! -f /usr/X11R6/lib/libGL.so + if test -f /usr/X11R6/lib/libGL.a -a ! -f /usr/X11R6/lib/libGL.so -a ! -f /usr/X11R6/lib/libGL.dylib then { { echo "$as_me:$LINENO: error: /usr/X11R6/lib/libGL.a is present on your system. This prevents linking to OpenGL. Delete the file and restart configure." >&5 @@ -13867,13 +13867,13 @@ case $host_cpu in *i[3456789]86*) - echo "$as_me:$LINENO: checking whether we can relocate the executable to 0x77f00000" >&5 -echo $ECHO_N "checking whether we can relocate the executable to 0x77f00000... $ECHO_C" >&6 + echo "$as_me:$LINENO: checking whether we can relocate the executable to 0x7bf00000" >&5 +echo $ECHO_N "checking whether we can relocate the executable to 0x7bf00000... $ECHO_C" >&6 if test "${ac_cv_ld_reloc_exec+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_wine_try_cflags_saved=$CFLAGS -CFLAGS="$CFLAGS -Wl,--section-start,.interp=0x77f00400" +CFLAGS="$CFLAGS -Wl,--section-start,.interp=0x7bf00400" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -13925,7 +13925,7 @@ echo "${ECHO_T}$ac_cv_ld_reloc_exec" >&6 if test "$ac_cv_ld_reloc_exec" = "yes" then - LDEXECFLAGS="$LDEXECFLAGS -Wl,--section-start,.interp=0x77f00400" + LDEXECFLAGS="$LDEXECFLAGS -Wl,--section-start,.interp=0x7bf00400" fi ;; esac @@ -16680,6 +16680,7 @@ #ifdef HAVE_SYS_TIME_H #include #endif +#include #ifdef HAVE_ASM_TYPES_H #include #endif @@ -19425,6 +19426,238 @@ fi +echo "$as_me:$LINENO: checking for scsireq_t.cmd" >&5 +echo $ECHO_N "checking for scsireq_t.cmd... $ECHO_C" >&6 +if test "${ac_cv_member_scsireq_t_cmd+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SCSI_SG_H +#include +#endif + +int +main () +{ +static scsireq_t ac_aggr; +if (ac_aggr.cmd) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_scsireq_t_cmd=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SCSI_SG_H +#include +#endif + +int +main () +{ +static scsireq_t ac_aggr; +if (sizeof ac_aggr.cmd) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_scsireq_t_cmd=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_scsireq_t_cmd=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_scsireq_t_cmd" >&5 +echo "${ECHO_T}$ac_cv_member_scsireq_t_cmd" >&6 +if test $ac_cv_member_scsireq_t_cmd = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_SCSIREQ_T_CMD 1 +_ACEOF + + +fi +echo "$as_me:$LINENO: checking for sg_io_hdr_t.interface_id" >&5 +echo $ECHO_N "checking for sg_io_hdr_t.interface_id... $ECHO_C" >&6 +if test "${ac_cv_member_sg_io_hdr_t_interface_id+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SCSI_SG_H +#include +#endif + +int +main () +{ +static sg_io_hdr_t ac_aggr; +if (ac_aggr.interface_id) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_sg_io_hdr_t_interface_id=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifdef HAVE_SCSI_SG_H +#include +#endif + +int +main () +{ +static sg_io_hdr_t ac_aggr; +if (sizeof ac_aggr.interface_id) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_sg_io_hdr_t_interface_id=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_sg_io_hdr_t_interface_id=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_sg_io_hdr_t_interface_id" >&5 +echo "${ECHO_T}$ac_cv_member_sg_io_hdr_t_interface_id" >&6 +if test $ac_cv_member_sg_io_hdr_t_interface_id = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_SG_IO_HDR_T_INTERFACE_ID 1 +_ACEOF + + +fi + + echo "$as_me:$LINENO: checking for siginfo_t.si_fd" >&5 echo $ECHO_N "checking for siginfo_t.si_fd... $ECHO_C" >&6 if test "${ac_cv_member_siginfo_t_si_fd+set}" = set; then @@ -20049,26 +20282,12 @@ - ac_config_commands="$ac_config_commands dlls/ddraw/d3ddevice" - - ac_config_commands="$ac_config_commands dlls/ddraw/dclipper" - - ac_config_commands="$ac_config_commands dlls/ddraw/ddraw" - - ac_config_commands="$ac_config_commands dlls/ddraw/direct3d" - - ac_config_commands="$ac_config_commands dlls/ddraw/dpalette" - - ac_config_commands="$ac_config_commands dlls/ddraw/dsurface" - ac_config_commands="$ac_config_commands dlls/gdi/enhmfdrv" ac_config_commands="$ac_config_commands dlls/gdi/mfdrv" ac_config_commands="$ac_config_commands dlls/kernel/messages" - ac_config_commands="$ac_config_commands dlls/user/dde" - ac_config_commands="$ac_config_commands dlls/user/resources" ac_config_commands="$ac_config_commands dlls/wineps/data" @@ -20077,8 +20296,6 @@ ac_config_commands="$ac_config_commands programs/regedit/tests" - ac_config_commands="$ac_config_commands windows" - MAKE_RULES=Make.rules @@ -20095,7 +20312,7 @@ MAKE_PROG_RULES=programs/Makeprog.rules - ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" + ac_config_files="$ac_config_files Make.rules dlls/Makedll.rules dlls/Maketest.rules libs/Makelib.rules programs/Makeprog.rules Makefile dlls/Makefile dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile dlls/advpack/tests/Makefile dlls/amstream/Makefile dlls/atl/Makefile dlls/avicap32/Makefile dlls/avifil32/Makefile dlls/cabinet/Makefile dlls/capi2032/Makefile dlls/cards/Makefile dlls/cfgmgr32/Makefile dlls/comcat/Makefile dlls/comctl32/Makefile dlls/comctl32/tests/Makefile dlls/commdlg/Makefile dlls/crtdll/Makefile dlls/crypt32/Makefile dlls/crypt32/tests/Makefile dlls/cryptdll/Makefile dlls/ctl3d/Makefile dlls/d3d8/Makefile dlls/d3d9/Makefile dlls/d3dim/Makefile dlls/d3drm/Makefile dlls/d3dx8/Makefile dlls/d3dxof/Makefile dlls/dbghelp/Makefile dlls/dciman32/Makefile dlls/ddraw/Makefile dlls/ddraw/tests/Makefile dlls/devenum/Makefile dlls/dinput/Makefile dlls/dinput/tests/Makefile dlls/dinput8/Makefile dlls/dmband/Makefile dlls/dmcompos/Makefile dlls/dmime/Makefile dlls/dmloader/Makefile dlls/dmscript/Makefile dlls/dmstyle/Makefile dlls/dmsynth/Makefile dlls/dmusic/Makefile dlls/dmusic32/Makefile dlls/dplay/Makefile dlls/dplayx/Makefile dlls/dpnet/Makefile dlls/dpnhpast/Makefile dlls/dsound/Makefile dlls/dsound/tests/Makefile dlls/dswave/Makefile dlls/dxdiagn/Makefile dlls/dxerr8/Makefile dlls/dxerr9/Makefile dlls/dxguid/Makefile dlls/gdi/Makefile dlls/gdi/tests/Makefile dlls/glu32/Makefile dlls/glut32/Makefile dlls/hhctrl.ocx/Makefile dlls/iccvid/Makefile dlls/icmp/Makefile dlls/ifsmgr.vxd/Makefile dlls/imagehlp/Makefile dlls/imm32/Makefile dlls/iphlpapi/Makefile dlls/iphlpapi/tests/Makefile dlls/itss/Makefile dlls/kernel/Makefile dlls/kernel/tests/Makefile dlls/lzexpand/Makefile dlls/lzexpand/tests/Makefile dlls/mapi32/Makefile dlls/mapi32/tests/Makefile dlls/mlang/Makefile dlls/mlang/tests/Makefile dlls/mmdevldr.vxd/Makefile dlls/monodebg.vxd/Makefile dlls/mpr/Makefile dlls/msacm/Makefile dlls/msacm/imaadp32/Makefile dlls/msacm/msadp32/Makefile dlls/msacm/msg711/Makefile dlls/msacm/winemp3/Makefile dlls/msacm/tests/Makefile dlls/mscms/Makefile dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile dlls/msisys/Makefile dlls/msnet32/Makefile dlls/msrle32/Makefile dlls/msvcrt/Makefile dlls/msvcrt/tests/Makefile dlls/msvcrt20/Makefile dlls/msvcrt40/Makefile dlls/msvcrtd/Makefile dlls/msvcrtd/tests/Makefile dlls/msvidc32/Makefile dlls/msvideo/Makefile dlls/mswsock/Makefile dlls/netapi32/Makefile dlls/netapi32/tests/Makefile dlls/newdev/Makefile dlls/ntdll/Makefile dlls/ntdll/tests/Makefile dlls/odbc32/Makefile dlls/odbccp32/Makefile dlls/ole32/Makefile dlls/ole32/tests/Makefile dlls/oleacc/Makefile dlls/oleaut32/Makefile dlls/oleaut32/tests/Makefile dlls/olecli/Makefile dlls/oledlg/Makefile dlls/olepro32/Makefile dlls/olesvr/Makefile dlls/opengl32/Makefile dlls/powrprof/Makefile dlls/psapi/Makefile dlls/psapi/tests/Makefile dlls/qcap/Makefile dlls/quartz/Makefile dlls/quartz/tests/Makefile dlls/rasapi32/Makefile dlls/riched20/Makefile dlls/richedit/Makefile dlls/rpcrt4/Makefile dlls/rpcrt4/tests/Makefile dlls/rsabase/Makefile dlls/rsabase/tests/Makefile dlls/rsaenh/Makefile dlls/rsaenh/tests/Makefile dlls/secur32/Makefile dlls/sensapi/Makefile dlls/serialui/Makefile dlls/setupapi/Makefile dlls/shdocvw/Makefile dlls/shell32/Makefile dlls/shell32/tests/Makefile dlls/shfolder/Makefile dlls/shlwapi/Makefile dlls/shlwapi/tests/Makefile dlls/snmpapi/Makefile dlls/stdole32.tlb/Makefile dlls/sti/Makefile dlls/strmiids/Makefile dlls/tapi32/Makefile dlls/ttydrv/Makefile dlls/twain/Makefile dlls/unicows/Makefile dlls/url/Makefile dlls/urlmon/Makefile dlls/urlmon/tests/Makefile dlls/user/Makefile dlls/user/tests/Makefile dlls/uuid/Makefile dlls/uxtheme/Makefile dlls/vdhcp.vxd/Makefile dlls/vdmdbg/Makefile dlls/version/Makefile dlls/version/tests/Makefile dlls/vmm.vxd/Makefile dlls/vnbt.vxd/Makefile dlls/vnetbios.vxd/Makefile dlls/vtdapi.vxd/Makefile dlls/vwin32.vxd/Makefile dlls/win32s/Makefile dlls/winaspi/Makefile dlls/wined3d/Makefile dlls/winedos/Makefile dlls/wineps/Makefile dlls/wininet/Makefile dlls/wininet/tests/Makefile dlls/winmm/Makefile dlls/winmm/joystick/Makefile dlls/winmm/mcianim/Makefile dlls/winmm/mciavi/Makefile dlls/winmm/mcicda/Makefile dlls/winmm/mciseq/Makefile dlls/winmm/mciwave/Makefile dlls/winmm/midimap/Makefile dlls/winmm/tests/Makefile dlls/winmm/wavemap/Makefile dlls/winmm/winealsa/Makefile dlls/winmm/winearts/Makefile dlls/winmm/wineaudioio/Makefile dlls/winmm/winejack/Makefile dlls/winmm/winenas/Makefile dlls/winmm/wineoss/Makefile dlls/winnls/Makefile dlls/winsock/Makefile dlls/winsock/tests/Makefile dlls/winspool/Makefile dlls/winspool/tests/Makefile dlls/wintab32/Makefile dlls/wintrust/Makefile dlls/wow32/Makefile dlls/wsock32/Makefile dlls/wtsapi32/Makefile dlls/x11drv/Makefile documentation/Makefile fonts/Makefile include/Makefile libs/Makefile libs/port/Makefile libs/unicode/Makefile libs/wine/Makefile libs/wpp/Makefile loader/Makefile programs/Makefile programs/avitools/Makefile programs/clock/Makefile programs/cmdlgtst/Makefile programs/control/Makefile programs/expand/Makefile programs/msiexec/Makefile programs/notepad/Makefile programs/progman/Makefile programs/regedit/Makefile programs/regsvr32/Makefile programs/rpcss/Makefile programs/rundll32/Makefile programs/start/Makefile programs/taskmgr/Makefile programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile programs/wineboot/Makefile programs/winebrowser/Makefile programs/winecfg/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile programs/winemenubuilder/Makefile programs/winemine/Makefile programs/winepath/Makefile programs/winetest/Makefile programs/winevdm/Makefile programs/winhelp/Makefile programs/winver/Makefile server/Makefile tools/Makefile tools/widl/Makefile tools/winapi/Makefile tools/winebuild/Makefile tools/winedump/Makefile tools/winegcc/Makefile tools/wmc/Makefile tools/wrc/Makefile" cat >confcache <<\_ACEOF @@ -20460,7 +20677,7 @@ } >&5 cat >&5 <<_CSEOF -This file was extended by Wine $as_me 20050524, which was +This file was extended by Wine $as_me 20050628, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20523,7 +20740,7 @@ cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -Wine config.status 20050524 +Wine config.status 20050628 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" @@ -20633,6 +20850,7 @@ "programs/Makeprog.rules" ) CONFIG_FILES="$CONFIG_FILES programs/Makeprog.rules" ;; "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "dlls/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/Makefile" ;; + "dlls/activeds/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/activeds/Makefile" ;; "dlls/advapi32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/advapi32/Makefile" ;; "dlls/advapi32/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/advapi32/tests/Makefile" ;; "dlls/advpack/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/advpack/Makefile" ;; @@ -20722,6 +20940,7 @@ "dlls/mscms/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mscms/tests/Makefile" ;; "dlls/msdmo/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/msdmo/Makefile" ;; "dlls/mshtml/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mshtml/Makefile" ;; + "dlls/mshtml/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/mshtml/tests/Makefile" ;; "dlls/msi/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/msi/Makefile" ;; "dlls/msi/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/msi/tests/Makefile" ;; "dlls/msimg32/Makefile" ) CONFIG_FILES="$CONFIG_FILES dlls/msimg32/Makefile" ;; @@ -20886,21 +21105,13 @@ "tools/winegcc/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/winegcc/Makefile" ;; "tools/wmc/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/wmc/Makefile" ;; "tools/wrc/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/wrc/Makefile" ;; - "dlls/ddraw/d3ddevice" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/ddraw/d3ddevice" ;; - "dlls/ddraw/dclipper" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/ddraw/dclipper" ;; - "dlls/ddraw/ddraw" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/ddraw/ddraw" ;; - "dlls/ddraw/direct3d" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/ddraw/direct3d" ;; - "dlls/ddraw/dpalette" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/ddraw/dpalette" ;; - "dlls/ddraw/dsurface" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/ddraw/dsurface" ;; "dlls/gdi/enhmfdrv" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/gdi/enhmfdrv" ;; "dlls/gdi/mfdrv" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/gdi/mfdrv" ;; "dlls/kernel/messages" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/kernel/messages" ;; - "dlls/user/dde" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/user/dde" ;; "dlls/user/resources" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/user/resources" ;; "dlls/wineps/data" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/wineps/data" ;; "include/wine" ) CONFIG_COMMANDS="$CONFIG_COMMANDS include/wine" ;; "programs/regedit/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS programs/regedit/tests" ;; - "windows" ) CONFIG_COMMANDS="$CONFIG_COMMANDS windows" ;; "include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} @@ -21682,26 +21893,12 @@ { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 echo "$as_me: executing $ac_dest commands" >&6;} case $ac_dest in - dlls/ddraw/d3ddevice ) test -d "dlls/ddraw/d3ddevice" || ({ echo "$as_me:$LINENO: creating dlls/ddraw/d3ddevice" >&5 -echo "$as_me: creating dlls/ddraw/d3ddevice" >&6;} && mkdir "dlls/ddraw/d3ddevice") ;; - dlls/ddraw/dclipper ) test -d "dlls/ddraw/dclipper" || ({ echo "$as_me:$LINENO: creating dlls/ddraw/dclipper" >&5 -echo "$as_me: creating dlls/ddraw/dclipper" >&6;} && mkdir "dlls/ddraw/dclipper") ;; - dlls/ddraw/ddraw ) test -d "dlls/ddraw/ddraw" || ({ echo "$as_me:$LINENO: creating dlls/ddraw/ddraw" >&5 -echo "$as_me: creating dlls/ddraw/ddraw" >&6;} && mkdir "dlls/ddraw/ddraw") ;; - dlls/ddraw/direct3d ) test -d "dlls/ddraw/direct3d" || ({ echo "$as_me:$LINENO: creating dlls/ddraw/direct3d" >&5 -echo "$as_me: creating dlls/ddraw/direct3d" >&6;} && mkdir "dlls/ddraw/direct3d") ;; - dlls/ddraw/dpalette ) test -d "dlls/ddraw/dpalette" || ({ echo "$as_me:$LINENO: creating dlls/ddraw/dpalette" >&5 -echo "$as_me: creating dlls/ddraw/dpalette" >&6;} && mkdir "dlls/ddraw/dpalette") ;; - dlls/ddraw/dsurface ) test -d "dlls/ddraw/dsurface" || ({ echo "$as_me:$LINENO: creating dlls/ddraw/dsurface" >&5 -echo "$as_me: creating dlls/ddraw/dsurface" >&6;} && mkdir "dlls/ddraw/dsurface") ;; dlls/gdi/enhmfdrv ) test -d "dlls/gdi/enhmfdrv" || ({ echo "$as_me:$LINENO: creating dlls/gdi/enhmfdrv" >&5 echo "$as_me: creating dlls/gdi/enhmfdrv" >&6;} && mkdir "dlls/gdi/enhmfdrv") ;; dlls/gdi/mfdrv ) test -d "dlls/gdi/mfdrv" || ({ echo "$as_me:$LINENO: creating dlls/gdi/mfdrv" >&5 echo "$as_me: creating dlls/gdi/mfdrv" >&6;} && mkdir "dlls/gdi/mfdrv") ;; dlls/kernel/messages ) test -d "dlls/kernel/messages" || ({ echo "$as_me:$LINENO: creating dlls/kernel/messages" >&5 echo "$as_me: creating dlls/kernel/messages" >&6;} && mkdir "dlls/kernel/messages") ;; - dlls/user/dde ) test -d "dlls/user/dde" || ({ echo "$as_me:$LINENO: creating dlls/user/dde" >&5 -echo "$as_me: creating dlls/user/dde" >&6;} && mkdir "dlls/user/dde") ;; dlls/user/resources ) test -d "dlls/user/resources" || ({ echo "$as_me:$LINENO: creating dlls/user/resources" >&5 echo "$as_me: creating dlls/user/resources" >&6;} && mkdir "dlls/user/resources") ;; dlls/wineps/data ) test -d "dlls/wineps/data" || ({ echo "$as_me:$LINENO: creating dlls/wineps/data" >&5 @@ -21710,8 +21907,6 @@ echo "$as_me: creating include/wine" >&6;} && mkdir "include/wine") ;; programs/regedit/tests ) test -d "programs/regedit/tests" || ({ echo "$as_me:$LINENO: creating programs/regedit/tests" >&5 echo "$as_me: creating programs/regedit/tests" >&6;} && mkdir "programs/regedit/tests") ;; - windows ) test -d "windows" || ({ echo "$as_me:$LINENO: creating windows" >&5 -echo "$as_me: creating windows" >&6;} && mkdir "windows") ;; esac done _ACEOF diff -urN wine-20050524/configure.ac wine-20050628/configure.ac --- wine-20050524/configure.ac 2005-05-24 13:52:46.000000000 +0200 +++ wine-20050628/configure.ac 2005-06-27 14:07:49.000000000 +0200 @@ -353,8 +353,8 @@ dnl Check for the presence of OpenGL if test "x$with_opengl" != "xno" then - if test -f /usr/X11R6/lib/libGL.a -a ! -f /usr/X11R6/lib/libGL.so - then + if test -f /usr/X11R6/lib/libGL.a -a ! -f /usr/X11R6/lib/libGL.so -a ! -f /usr/X11R6/lib/libGL.dylib + then AC_MSG_ERROR([/usr/X11R6/lib/libGL.a is present on your system. This prevents linking to OpenGL. Delete the file and restart configure.]) fi @@ -991,12 +991,12 @@ case $host_cpu in *i[[3456789]]86*) - AC_CACHE_CHECK([whether we can relocate the executable to 0x77f00000], ac_cv_ld_reloc_exec, - [WINE_TRY_CFLAGS([-Wl,--section-start,.interp=0x77f00400], + AC_CACHE_CHECK([whether we can relocate the executable to 0x7bf00000], ac_cv_ld_reloc_exec, + [WINE_TRY_CFLAGS([-Wl,--section-start,.interp=0x7bf00400], ac_cv_ld_reloc_exec="yes", ac_cv_ld_reloc_exec="no")]) if test "$ac_cv_ld_reloc_exec" = "yes" then - LDEXECFLAGS="$LDEXECFLAGS -Wl,--section-start,.interp=0x77f00400" + LDEXECFLAGS="$LDEXECFLAGS -Wl,--section-start,.interp=0x7bf00400" fi ;; esac @@ -1227,6 +1227,7 @@ [#ifdef HAVE_SYS_TIME_H #include #endif +#include #ifdef HAVE_ASM_TYPES_H #include #endif]) @@ -1462,6 +1463,13 @@ # include #endif]) +dnl Check for scsireq_t and sg_io_hdr_t members +AC_CHECK_MEMBERS([scsireq_t.cmd, sg_io_hdr_t.interface_id],,, +[#include +#ifdef HAVE_SCSI_SG_H +#include +#endif]) + dnl Check for siginfo_t members AC_CHECK_MEMBERS([siginfo_t.si_fd],,,[#include ]) @@ -1507,21 +1515,13 @@ AH_TOP([#define __WINE_CONFIG_H]) -WINE_CONFIG_EXTRA_DIR(dlls/ddraw/d3ddevice) -WINE_CONFIG_EXTRA_DIR(dlls/ddraw/dclipper) -WINE_CONFIG_EXTRA_DIR(dlls/ddraw/ddraw) -WINE_CONFIG_EXTRA_DIR(dlls/ddraw/direct3d) -WINE_CONFIG_EXTRA_DIR(dlls/ddraw/dpalette) -WINE_CONFIG_EXTRA_DIR(dlls/ddraw/dsurface) WINE_CONFIG_EXTRA_DIR(dlls/gdi/enhmfdrv) WINE_CONFIG_EXTRA_DIR(dlls/gdi/mfdrv) WINE_CONFIG_EXTRA_DIR(dlls/kernel/messages) -WINE_CONFIG_EXTRA_DIR(dlls/user/dde) WINE_CONFIG_EXTRA_DIR(dlls/user/resources) WINE_CONFIG_EXTRA_DIR(dlls/wineps/data) WINE_CONFIG_EXTRA_DIR(include/wine) WINE_CONFIG_EXTRA_DIR(programs/regedit/tests) -WINE_CONFIG_EXTRA_DIR(windows) MAKE_RULES=Make.rules AC_SUBST_FILE(MAKE_RULES) @@ -1546,6 +1546,7 @@ programs/Makeprog.rules Makefile dlls/Makefile +dlls/activeds/Makefile dlls/advapi32/Makefile dlls/advapi32/tests/Makefile dlls/advpack/Makefile @@ -1635,6 +1636,7 @@ dlls/mscms/tests/Makefile dlls/msdmo/Makefile dlls/mshtml/Makefile +dlls/mshtml/tests/Makefile dlls/msi/Makefile dlls/msi/tests/Makefile dlls/msimg32/Makefile diff -urN wine-20050524/dlls/Makefile.in wine-20050628/dlls/Makefile.in --- wine-20050524/dlls/Makefile.in 2005-05-19 23:18:53.000000000 +0200 +++ wine-20050628/dlls/Makefile.in 2005-06-13 13:47:46.000000000 +0200 @@ -16,6 +16,7 @@ # Subdir list BASEDIRS = \ + activeds \ advapi32 \ advpack \ amstream \ @@ -250,6 +251,7 @@ SYMLINKS_SO = \ $(EXTRADIRS:%=%.dll.so) \ @WIN16_FILES@ \ + activeds.dll.so \ advapi32.dll.so \ advpack.dll.so \ amstream.dll.so \ @@ -426,6 +428,9 @@ # Map symlink name to the corresponding library +activeds.dll.so: activeds/activeds.dll.so + $(RM) $@ && $(LN_S) activeds/activeds.dll.so $@ + advapi32.dll.so: advapi32/advapi32.dll.so $(RM) $@ && $(LN_S) advapi32/advapi32.dll.so $@ @@ -1047,6 +1052,7 @@ IMPORT_LIBS = \ $(IMPORT_SYMLINKS) \ + activeds/libactiveds.$(IMPLIBEXT) \ advapi32/libadvapi32.$(IMPLIBEXT) \ advpack/libadvpack.$(IMPLIBEXT) \ amstream/libamstream.$(IMPLIBEXT) \ @@ -1181,6 +1187,9 @@ implib: $(IMPORT_LIBS) +activeds/libactiveds.$(IMPLIBEXT): activeds/activeds.spec $(WINEBUILD) + @cd activeds && $(MAKE) libactiveds.$(IMPLIBEXT) + advapi32/libadvapi32.$(IMPLIBEXT): advapi32/advapi32.spec $(WINEBUILD) @cd advapi32 && $(MAKE) libadvapi32.$(IMPLIBEXT) @@ -1630,6 +1639,7 @@ # Map library name to the corresponding directory +activeds/activeds.dll.so: activeds advapi32/advapi32.dll.so: advapi32 advpack/advpack.dll.so: advpack amstream/amstream.dll.so: amstream @@ -1828,7 +1838,7 @@ -rmdir $(dlldir) clean:: - $(RM) $(IMPORT_SYMLINKS) + $(RM) $(IMPORT_SYMLINKS) *.$(IMPLIBEXT) check test:: $(BUILDSUBDIRS:%=%/__test__) diff -urN wine-20050524/dlls/activeds/.cvsignore wine-20050628/dlls/activeds/.cvsignore --- wine-20050524/dlls/activeds/.cvsignore 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/activeds/.cvsignore 2005-06-13 13:47:46.000000000 +0200 @@ -0,0 +1,3 @@ +Makefile +activeds.dll.dbg.c +libactiveds.def diff -urN wine-20050524/dlls/activeds/Makefile.in wine-20050628/dlls/activeds/Makefile.in --- wine-20050524/dlls/activeds/Makefile.in 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/activeds/Makefile.in 2005-06-13 13:47:46.000000000 +0200 @@ -0,0 +1,12 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = activeds.dll +IMPORTLIB = libactiveds.$(IMPLIBEXT) + +C_SRCS = activeds_main.c + +@MAKE_DLL_RULES@ + +### Dependencies: diff -urN wine-20050524/dlls/activeds/activeds.spec wine-20050628/dlls/activeds/activeds.spec --- wine-20050524/dlls/activeds/activeds.spec 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/activeds/activeds.spec 2005-06-13 13:47:46.000000000 +0200 @@ -0,0 +1,28 @@ +3 stdcall ADsGetObject(wstr ptr ptr) +4 stdcall ADsBuildEnumerator(ptr ptr) +5 stub ADsFreeEnumerator +6 stdcall ADsEnumerateNext(ptr long ptr ptr) +7 stub ADsBuildVarArrayStr +8 stub ADsBuildVarArrayInt +9 stdcall ADsOpenObject(wstr ptr ptr) +12 stub ADsSetLastError +13 stub ADsGetLastError +14 stub AllocADsMem +15 stdcall FreeADsMem(ptr) +16 stub ReallocADsMem +17 stub AllocADsStr +18 stub FreeADsStr +19 stub ReallocADsStr +20 stub ADsEncodeBinaryData +21 stub PropVariantToAdsType +22 stub AdsTypeToPropVariant +23 stub AdsFreeAdsValues +24 stub ADsDecodeBinaryData +25 stub AdsTypeToPropVariant2 +26 stub PropVariantToAdsType2 +27 stub ConvertSecDescriptorToVariant +28 stub ConvertSecurityDescriptorToSecDes +#@ stub DllCanUnloadNow +#@ stub DllGetClassObject +#@ stub DllRegisterServer +#@ stub DllUnregisterServer diff -urN wine-20050524/dlls/activeds/activeds_main.c wine-20050628/dlls/activeds/activeds_main.c --- wine-20050524/dlls/activeds/activeds_main.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/activeds/activeds_main.c 2005-06-17 22:56:21.000000000 +0200 @@ -0,0 +1,101 @@ +/* + * Implementation of the Active Directory Service Interface + * + * Copyright 2005 Detlef Riekenberg + * + * This file contains only stubs to get the printui.dll up and running + * activeds.dll is much much more than this + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#define COBJMACROS +#define NONAMELESSUNION + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winreg.h" +#include "winver.h" +#include "winnls.h" + +#include "wine/unicode.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(activeds); + +/***************************************************** + * DllMain + */ + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + TRACE("(%p, %ld, %p)\n",hinstDLL, fdwReason, lpvReserved); + /* For the moment, do nothing here. */ + return TRUE; +} + +/***************************************************** + * ADsGetObject [ACTIVEDS.3] + */ + +HRESULT WINAPI ADsGetObject(LPWSTR lpszPathName, REFIID riid, VOID** ppObject) +{ + FIXME("(%s)->(%s,%p)!stub\n",debugstr_w(lpszPathName), debugstr_guid(riid), ppObject); + return E_NOTIMPL; +} + +/***************************************************** + * ADsBuildEnumerator [ACTIVEDS.4] + */ + +/* HRESULT WINAPI ADsBuildEnumerator(IADsContainer * pADsContainer, IEnumVariant ** ppEnumVariant) */ +HRESULT WINAPI ADsBuildEnumerator(LPVOID * pADsContainer, LPVOID ** ppEnumVariant) +{ + FIXME("(%p)->(%p)!stub\n",pADsContainer, ppEnumVariant); + return E_NOTIMPL; +} + +/***************************************************** + * ADsEnumerateNext [ACTIVEDS.6] + */ + +/* HRESULT WINAPI ADsEnumerateNext(IEnumVariant * pEnumVariant, ULONG cElements, VARIANT * pvar, ULONG * pcElementsFetched) */ +HRESULT WINAPI ADsEnumerateNext(LPVOID * pEnumVariant, ULONG cElements, LPVOID * pvar, ULONG * pcElementsFetched) +{ + FIXME("(%p)->(%lu, %p, %p)!stub\n",pEnumVariant, cElements, pvar, pcElementsFetched); + return E_NOTIMPL; +} + +/***************************************************** + * ADsOpenObject [ACTIVEDS.9] + */ + +HRESULT WINAPI ADsOpenObject(LPWSTR lpszPathName, REFIID riid, VOID** ppObject) +{ + FIXME("(%s)->(%s,%p)!stub\n",debugstr_w(lpszPathName), debugstr_guid(riid), ppObject); + return E_NOTIMPL; +} + +/***************************************************** + * FreeADsMem [ACTIVEDS.15] + */ +BOOL WINAPI FreeADsMem(LPVOID pMem) +{ + FIXME("(%p)!stub\n",pMem); + return FALSE; +} diff -urN wine-20050524/dlls/advapi32/advapi.c wine-20050628/dlls/advapi32/advapi.c --- wine-20050524/dlls/advapi32/advapi.c 2005-01-03 18:12:51.000000000 +0100 +++ wine-20050628/dlls/advapi32/advapi.c 2005-06-09 11:44:26.000000000 +0200 @@ -30,7 +30,9 @@ #include "winbase.h" #include "winnls.h" #include "winreg.h" +#include "winternl.h" #include "winerror.h" +#include "appmgmt.h" #include "wine/library.h" #include "wine/debug.h" @@ -132,6 +134,23 @@ return FALSE; } + +/************************************************************************** + * IsTextUnicode (ADVAPI32.@) + * + * Attempt to guess whether a text buffer is Unicode. + * + * PARAMS + * buf [I] Text buffer to test + * len [I] Length of buf + * flags [O] Destination for test results + */ +BOOL WINAPI IsTextUnicode( LPCVOID buf, INT len, LPINT flags ) +{ + return RtlIsTextUnicode( buf, len, flags ); +} + + /****************************************************************************** * AbortSystemShutdownA [ADVAPI32.@] * diff -urN wine-20050524/dlls/advapi32/advapi32.spec wine-20050628/dlls/advapi32/advapi32.spec --- wine-20050524/dlls/advapi32/advapi32.spec 2005-05-23 14:08:00.000000000 +0200 +++ wine-20050628/dlls/advapi32/advapi32.spec 2005-06-23 13:40:57.000000000 +0200 @@ -23,6 +23,8 @@ @ stdcall BackupEventLogW (long wstr) @ stdcall BuildExplicitAccessWithNameA(ptr str long long long) @ stdcall BuildExplicitAccessWithNameW(ptr wstr long long long) +@ stdcall BuildSecurityDescriptorA(ptr ptr long ptr long ptr ptr ptr ptr) +@ stdcall BuildSecurityDescriptorW(ptr ptr long ptr long ptr ptr ptr ptr) @ stdcall BuildTrusteeWithNameA(ptr str) @ stdcall BuildTrusteeWithNameW(ptr wstr) @ stdcall BuildTrusteeWithObjectsAndNameA(ptr ptr long str str str) @@ -35,6 +37,7 @@ @ stdcall ChangeServiceConfig2W(long long ptr) @ stdcall ChangeServiceConfigA(long long long long wstr str ptr str str str str) @ stdcall ChangeServiceConfigW(long long long long wstr wstr ptr wstr wstr wstr wstr) +@ stdcall CheckTokenMembership(long ptr ptr) @ stdcall ClearEventLogA (long str) @ stdcall ClearEventLogW (long wstr) @ stdcall CloseEventLog (long) @@ -43,10 +46,10 @@ @ stdcall ControlService(long long ptr) @ stdcall ConvertSidToStringSidA(ptr ptr) @ stdcall ConvertSidToStringSidW(ptr ptr) -@ stdcall ConvertStringSidToSidA(ptr ptr) -@ stdcall ConvertStringSidToSidW(ptr ptr) @ stdcall ConvertStringSecurityDescriptorToSecurityDescriptorA(str long ptr ptr) @ stdcall ConvertStringSecurityDescriptorToSecurityDescriptorW(wstr long ptr ptr) +@ stdcall ConvertStringSidToSidA(ptr ptr) +@ stdcall ConvertStringSidToSidW(ptr ptr) @ stdcall CopySid(long ptr ptr) @ stdcall CreatePrivateObjectSecurity(ptr ptr ptr long long ptr) @ stdcall CreateProcessAsUserA(long str str ptr ptr long long ptr str ptr ptr) @@ -65,10 +68,10 @@ @ stdcall CryptDuplicateHash(long ptr long ptr) @ stdcall CryptDuplicateKey(long ptr long ptr) @ stdcall CryptEncrypt(long long long long ptr ptr long) -@ stdcall CryptEnumProvidersA(long ptr long ptr ptr ptr) -@ stdcall CryptEnumProvidersW(long ptr long ptr ptr ptr) @ stdcall CryptEnumProviderTypesA(long ptr long ptr ptr ptr) @ stdcall CryptEnumProviderTypesW(long ptr long ptr ptr ptr) +@ stdcall CryptEnumProvidersA(long ptr long ptr ptr ptr) +@ stdcall CryptEnumProvidersW(long ptr long ptr ptr ptr) @ stdcall CryptExportKey(long long long long ptr ptr) @ stdcall CryptGenKey(long long long ptr) @ stdcall CryptGenRandom(long long ptr) @@ -82,15 +85,15 @@ @ stdcall CryptHashSessionKey(long long long) @ stdcall CryptImportKey(long ptr long long long ptr) @ stdcall CryptReleaseContext(long long) -@ stdcall CryptSignHashA(long long ptr long ptr ptr) -@ stdcall CryptSignHashW(long long ptr long ptr ptr) @ stdcall CryptSetHashParam(long long ptr long) @ stdcall CryptSetKeyParam(long long ptr long) +@ stdcall CryptSetProvParam(long long ptr long) @ stdcall CryptSetProviderA(str long) -@ stdcall CryptSetProviderW(wstr long) @ stdcall CryptSetProviderExA(str long ptr long) @ stdcall CryptSetProviderExW(wstr long ptr long) -@ stdcall CryptSetProvParam(long long ptr long) +@ stdcall CryptSetProviderW(wstr long) +@ stdcall CryptSignHashA(long long ptr long ptr ptr) +@ stdcall CryptSignHashW(long long ptr long ptr ptr) @ stdcall CryptVerifySignatureA(long ptr long long ptr long) @ stdcall CryptVerifySignatureW(long ptr long long ptr long) @ stdcall DecryptFileA(str long) @@ -101,10 +104,16 @@ @ stdcall DestroyPrivateObjectSecurity(ptr) @ stdcall DuplicateToken(long long ptr) @ stdcall DuplicateTokenEx(long long ptr long long ptr) +@ stub ElfDeregisterEventSource +@ stub ElfDeregisterEventSourceW +@ stub ElfRegisterEventSourceW +@ stub ElfReportEventW @ stdcall EncryptFileA(str) @ stdcall EncryptFileW(wstr) @ stdcall EnumDependentServicesA(long long ptr long ptr ptr) @ stdcall EnumDependentServicesW(long long ptr long ptr ptr) +@ stub EnumServiceGroupA +@ stub EnumServiceGroupW @ stdcall EnumServicesStatusA (long long long ptr long ptr ptr ptr) @ stdcall EnumServicesStatusW (long long long ptr long ptr ptr ptr) @ stdcall EqualPrefixSid(ptr ptr) @@ -146,8 +155,16 @@ @ stdcall GetSidSubAuthorityCount(ptr) @ stub GetSiteSidFromToken @ stdcall GetTokenInformation(long long ptr long ptr) +@ stdcall GetTrusteeFormA(ptr) +@ stdcall GetTrusteeFormW(ptr) +@ stdcall GetTrusteeNameA(ptr) +@ stdcall GetTrusteeNameW(ptr) +@ stdcall GetTrusteeTypeA(ptr) +@ stdcall GetTrusteeTypeW(ptr) @ stdcall GetUserNameA(ptr ptr) @ stdcall GetUserNameW(ptr ptr) +@ stub I_ScSetServiceBit +@ stub I_ScSetServiceBitsA @ stdcall ImpersonateLoggedOnUser(long) @ stdcall ImpersonateNamedPipeClient(long) @ stdcall ImpersonateSelf(long) @@ -155,12 +172,12 @@ @ stdcall InitializeSecurityDescriptor(ptr long) @ stdcall InitializeSid(ptr ptr long) @ stdcall InitiateSystemShutdownA(str str long long long) -@ stdcall InitiateSystemShutdownW(str str long long long) @ stdcall InitiateSystemShutdownExA(str str long long long long) @ stdcall InitiateSystemShutdownExW(wstr wstr long long long long) +@ stdcall InitiateSystemShutdownW(str str long long long) @ stub InstallApplication @ stub IsProcessRestricted -@ stdcall IsTextUnicode(ptr long ptr) ntdll.RtlIsTextUnicode +@ stdcall IsTextUnicode(ptr long ptr) @ stdcall IsTokenRestricted(long) @ stdcall IsValidAcl(ptr) @ stdcall IsValidSecurityDescriptor(ptr) @@ -178,15 +195,47 @@ @ stdcall LookupPrivilegeNameW(wstr ptr ptr long) @ stdcall LookupPrivilegeValueA(ptr ptr ptr) @ stdcall LookupPrivilegeValueW(ptr ptr ptr) -@ stdcall MakeAbsoluteSD(ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr) -@ stdcall MakeSelfRelativeSD(ptr ptr ptr) -@ stdcall MapGenericMask(ptr ptr) +@ stub LsaAddPrivilegesToAccount +@ stdcall LsaClose(ptr) +@ stub LsaCreateAccount +@ stub LsaCreateSecret +@ stub LsaCreateTrustedDomain +@ stub LsaDelete +@ stub LsaEnumerateAccounts +@ stub LsaEnumeratePrivileges +@ stub LsaEnumeratePrivilegesOfAccount +@ stdcall LsaEnumerateTrustedDomains(long ptr ptr long ptr) +@ stdcall LsaFreeMemory(ptr) +@ stub LsaGetSystemAccessAccount +@ stub LsaICLookupNames +@ stub LsaICLookupSids +@ stdcall LsaLookupNames(long long ptr ptr ptr) +@ stub LsaLookupPrivilegeDisplayName +@ stdcall LsaLookupSids(ptr long ptr ptr ptr) +@ stdcall LsaNtStatusToWinError(long) +@ stub LsaOpenAccount +@ stdcall LsaOpenPolicy(long long long long) +@ stub LsaOpenSecret +@ stub LsaOpenTrustedDomain +@ stub LsaQueryInfoTrustedDomain +@ stdcall LsaQueryInformationPolicy(ptr long ptr) +@ stub LsaQuerySecret +@ stub LsaRemovePrivilegesFromAccount +@ stdcall LsaRetrievePrivateData(ptr ptr ptr) +@ stdcall LsaSetInformationPolicy(long long ptr) +@ stub LsaSetInformationTrustedDomain +@ stub LsaSetSecret +@ stub LsaSetSystemAccessAccount +@ stdcall LsaStorePrivateData(ptr ptr ptr) @ stdcall MD4Final(ptr) @ stdcall MD4Init(ptr) @ stdcall MD4Update(ptr ptr long) @ stdcall MD5Final(ptr) @ stdcall MD5Init(ptr) @ stdcall MD5Update(ptr ptr long) +@ stdcall MakeAbsoluteSD(ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr) +@ stdcall MakeSelfRelativeSD(ptr ptr ptr) +@ stdcall MapGenericMask(ptr ptr) @ stdcall NotifyBootConfigStatus(long) @ stdcall NotifyChangeEventLog (long long) @ stdcall ObjectCloseAuditAlarmA(str ptr long) @@ -215,6 +264,7 @@ @ stdcall QueryServiceObjectSecurity(long long ptr long ptr) @ stdcall QueryServiceStatus(long ptr) @ stdcall QueryServiceStatusEx (long long ptr long ptr) +@ stdcall QueryWindows31FilesMigration(long) @ stdcall ReadEventLogA (long long long ptr long ptr ptr) @ stdcall ReadEventLogW (long long long ptr long ptr ptr) @ stdcall RegCloseKey(long) @@ -300,14 +350,7 @@ @ stdcall StartServiceCtrlDispatcherA(ptr) @ stdcall StartServiceCtrlDispatcherW(ptr) @ stdcall StartServiceW(long long ptr) -@ stdcall UnlockServiceDatabase (ptr) -@ stdcall LsaOpenPolicy(long long long long) -@ stdcall LsaLookupSids(ptr long ptr ptr ptr) -@ stdcall LsaFreeMemory(ptr) -@ stdcall LsaQueryInformationPolicy(ptr long ptr) -@ stdcall LsaClose(ptr) -@ stdcall LsaSetInformationPolicy(long long ptr) -@ stdcall LsaLookupNames(long long ptr ptr ptr) +@ stdcall SynchronizeWindows31FilesAndWindowsNTRegistry(long long long long) @ stub SystemFunction001 @ stub SystemFunction002 @ stub SystemFunction003 @@ -350,45 +393,10 @@ @ stub TraceEventInstance @ stub TraceMessage @ stub TraceMessageVa +@ stdcall UnlockServiceDatabase (ptr) @ stub UnregisterTraceGuids @ stub UpdateTraceA @ stub UpdateTraceW -@ stub LsaQueryInfoTrustedDomain -@ stub LsaQuerySecret -@ stub LsaCreateSecret -@ stub LsaOpenSecret -@ stub LsaCreateTrustedDomain -@ stub LsaOpenTrustedDomain -@ stub LsaSetSecret -@ stub LsaCreateAccount -@ stub LsaAddPrivilegesToAccount -@ stub LsaRemovePrivilegesFromAccount -@ stub LsaDelete -@ stub LsaSetSystemAccessAccount -@ stub LsaEnumeratePrivilegesOfAccount -@ stub LsaEnumerateAccounts -@ stub LsaGetSystemAccessAccount -@ stub LsaSetInformationTrustedDomain -@ stdcall LsaEnumerateTrustedDomains(long ptr ptr long ptr) -@ stdcall LsaNtStatusToWinError(long) -@ stub LsaOpenAccount -@ stub LsaEnumeratePrivileges -@ stub LsaLookupPrivilegeDisplayName -@ stub LsaICLookupNames -@ stdcall LsaRetrievePrivateData(ptr ptr ptr) -@ stdcall LsaStorePrivateData(ptr ptr ptr) -@ stub ElfRegisterEventSourceW -@ stub ElfReportEventW -@ stub ElfDeregisterEventSource -@ stub ElfDeregisterEventSourceW -@ stub I_ScSetServiceBit -@ stdcall SynchronizeWindows31FilesAndWindowsNTRegistry(long long long long) -@ stdcall QueryWindows31FilesMigration(long) -@ stub LsaICLookupSids -@ stub I_ScSetServiceBitsA -@ stub EnumServiceGroupA -@ stub EnumServiceGroupW -@ stdcall CheckTokenMembership(long ptr ptr) @ stub WdmWmiServiceMain @ stub WmiCloseBlock @ stub WmiOpenBlock diff -urN wine-20050524/dlls/advapi32/crypt.c wine-20050628/dlls/advapi32/crypt.c --- wine-20050524/dlls/advapi32/crypt.c 2005-05-23 14:08:00.000000000 +0200 +++ wine-20050628/dlls/advapi32/crypt.c 2005-06-17 22:56:02.000000000 +0200 @@ -24,13 +24,19 @@ * - Thread-safing */ +#include "config.h" + #include #include #include #include -#include +#ifdef HAVE_SYS_STAT_H +# include +#endif #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include "crypt.h" #include "winnls.h" diff -urN wine-20050524/dlls/advapi32/registry.c wine-20050628/dlls/advapi32/registry.c --- wine-20050524/dlls/advapi32/registry.c 2005-05-16 16:08:11.000000000 +0200 +++ wine-20050628/dlls/advapi32/registry.c 2005-06-17 15:58:35.000000000 +0200 @@ -97,7 +97,7 @@ } /* create one of the HKEY_* special root keys */ -static HKEY create_special_root_hkey( HKEY hkey, DWORD access ) +static HKEY create_special_root_hkey( HANDLE hkey, DWORD access ) { HKEY ret = 0; int idx = (UINT)hkey - (UINT)HKEY_SPECIAL_ROOT_FIRST; @@ -167,7 +167,7 @@ RtlInitUnicodeString( &nameW, name ); RtlInitUnicodeString( &classW, class ); - return RtlNtStatusToDosError( NtCreateKey( retkey, access, &attr, 0, + return RtlNtStatusToDosError( NtCreateKey( (PHANDLE)retkey, access, &attr, 0, &classW, options, dispos ) ); } @@ -223,7 +223,7 @@ { if (!(status = RtlAnsiStringToUnicodeString( &classW, &classA, TRUE ))) { - status = NtCreateKey( retkey, access, &attr, 0, &classW, options, dispos ); + status = NtCreateKey( (PHANDLE)retkey, access, &attr, 0, &classW, options, dispos ); RtlFreeUnicodeString( &classW ); } } @@ -286,7 +286,7 @@ attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; RtlInitUnicodeString( &nameW, name ); - return RtlNtStatusToDosError( NtOpenKey( retkey, access, &attr ) ); + return RtlNtStatusToDosError( NtOpenKey( (PHANDLE)retkey, access, &attr ) ); } @@ -331,7 +331,7 @@ if (!(status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString, &nameA, FALSE ))) { - status = NtOpenKey( retkey, access, &attr ); + status = NtOpenKey( (PHANDLE)retkey, access, &attr ); } return RtlNtStatusToDosError( status ); } diff -urN wine-20050524/dlls/advapi32/security.c wine-20050628/dlls/advapi32/security.c --- wine-20050524/dlls/advapi32/security.c 2005-04-22 23:17:42.000000000 +0200 +++ wine-20050628/dlls/advapi32/security.c 2005-06-24 13:54:15.000000000 +0200 @@ -27,6 +27,7 @@ #include "rpcnterr.h" #include "winreg.h" #include "winternl.h" +#include "winioctl.h" #include "ntstatus.h" #include "ntsecapi.h" #include "accctrl.h" @@ -137,31 +138,23 @@ * * Checks whether the server name indicates local machine. */ -BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName) +static BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName) { - if (!ServerName) - { - return TRUE; - } - else if (!ServerName[0]) - { + DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; + BOOL Result; + LPWSTR buf; + + if (!ServerName || !ServerName[0]) return TRUE; - } - else - { - DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; - BOOL Result; - LPWSTR buf; - - buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR)); - Result = GetComputerNameW(buf, &dwSize); - if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\')) - ServerName += 2; - Result = Result && !lstrcmpW(ServerName, buf); - HeapFree(GetProcessHeap(), 0, buf); + + buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR)); + Result = GetComputerNameW(buf, &dwSize); + if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\')) + ServerName += 2; + Result = Result && !lstrcmpW(ServerName, buf); + HeapFree(GetProcessHeap(), 0, buf); - return Result; - } + return Result; } #define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \ @@ -475,9 +468,39 @@ BOOL WINAPI IsTokenRestricted( HANDLE TokenHandle ) { - FIXME("%p - stub\n", TokenHandle); + TOKEN_GROUPS *groups; + DWORD size; + NTSTATUS status; + BOOL restricted; - return FALSE; + TRACE("(%p)\n", TokenHandle); + + status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, NULL, 0, &size); + if (status != STATUS_BUFFER_TOO_SMALL) + return FALSE; + + groups = HeapAlloc(GetProcessHeap(), 0, size); + if (!groups) + { + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + + status = NtQueryInformationToken(TokenHandle, TokenRestrictedSids, groups, size, &size); + if (status != STATUS_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, groups); + return set_ntstatus(status); + } + + if (groups->GroupCount) + restricted = TRUE; + else + restricted = FALSE; + + HeapFree(GetProcessHeap(), 0, groups); + + return restricted; } /****************************************************************************** @@ -610,6 +633,63 @@ ############################################## */ + /****************************************************************************** + * BuildSecurityDescriptorA [ADVAPI32.@] + * + * Builds a SD from + * + * PARAMS + * pOwner [I] + * pGroup [I] + * cCountOfAccessEntries [I] + * pListOfAccessEntries [I] + * cCountOfAuditEntries [I] + * pListofAuditEntries [I] + * pOldSD [I] + * lpdwBufferLength [I/O] + * pNewSD [O] + */ +DWORD WINAPI BuildSecurityDescriptorA( + IN PTRUSTEE_A pOwner, + IN PTRUSTEE_A pGroup, + IN DWORD cCountOfAccessEntries, + IN PEXPLICIT_ACCESS_A pListOfAccessEntries, + IN DWORD cCountOfAuditEntries, + IN PEXPLICIT_ACCESS_A pListofAuditEntries, + IN PSECURITY_DESCRIPTOR pOldSD, + IN OUT PDWORD lpdwBufferLength, + OUT PSECURITY_DESCRIPTOR pNewSD) +{ + FIXME("(%p,%p,%ld,%p,%ld,%p,%p,%p,%p) stub!\n",pOwner,pGroup, + cCountOfAccessEntries,pListOfAccessEntries,cCountOfAuditEntries, + pListofAuditEntries,pOldSD,lpdwBufferLength,pNewSD); + + return ERROR_CALL_NOT_IMPLEMENTED; +} + +/****************************************************************************** + * BuildSecurityDescriptorW [ADVAPI32.@] + * + * See BuildSecurityDescriptorA. + */ +DWORD WINAPI BuildSecurityDescriptorW( + IN PTRUSTEE_W pOwner, + IN PTRUSTEE_W pGroup, + IN DWORD cCountOfAccessEntries, + IN PEXPLICIT_ACCESS_W pListOfAccessEntries, + IN DWORD cCountOfAuditEntries, + IN PEXPLICIT_ACCESS_W pListofAuditEntries, + IN PSECURITY_DESCRIPTOR pOldSD, + IN OUT PDWORD lpdwBufferLength, + OUT PSECURITY_DESCRIPTOR pNewSD) +{ + FIXME("(%p,%p,%ld,%p,%ld,%p,%p,%p,%p) stub!\n",pOwner,pGroup, + cCountOfAccessEntries,pListOfAccessEntries,cCountOfAuditEntries, + pListofAuditEntries,pOldSD,lpdwBufferLength,pNewSD); + + return ERROR_CALL_NOT_IMPLEMENTED; +} + /****************************************************************************** * InitializeSecurityDescriptor [ADVAPI32.@] * @@ -648,6 +728,9 @@ pPrimaryGroup, lpdwPrimaryGroupSize)); } +/****************************************************************************** + * GetKernelObjectSecurity [ADVAPI32.@] + */ BOOL WINAPI GetKernelObjectSecurity( HANDLE Handle, SECURITY_INFORMATION RequestedInformation, @@ -655,12 +738,16 @@ DWORD nLength, LPDWORD lpnLengthNeeded ) { - FIXME("%p 0x%08lx %p 0x%08lx %p - stub\n", Handle, RequestedInformation, + TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", Handle, RequestedInformation, pSecurityDescriptor, nLength, lpnLengthNeeded); - return FALSE; + return set_ntstatus( NtQuerySecurityObject(Handle, RequestedInformation, pSecurityDescriptor, + nLength, lpnLengthNeeded )); } +/****************************************************************************** + * GetPrivateObjectSecurity [ADVAPI32.@] + */ BOOL WINAPI GetPrivateObjectSecurity( PSECURITY_DESCRIPTOR ObjectDescriptor, SECURITY_INFORMATION SecurityInformation, @@ -668,10 +755,11 @@ DWORD DescriptorLength, PDWORD ReturnLength ) { - FIXME("%p 0x%08lx %p 0x%08lx %p - stub\n", ObjectDescriptor, SecurityInformation, + TRACE("(%p,0x%08lx,%p,0x%08lx,%p)\n", ObjectDescriptor, SecurityInformation, ResultantDescriptor, DescriptorLength, ReturnLength); - return FALSE; + return set_ntstatus( NtQuerySecurityObject(ObjectDescriptor, SecurityInformation, + ResultantDescriptor, DescriptorLength, ReturnLength )); } /****************************************************************************** @@ -841,9 +929,10 @@ BOOL WINAPI ImpersonateNamedPipeClient( HANDLE hNamedPipe ) { - FIXME("%p - stub\n", hNamedPipe); + TRACE("(%p)\n", hNamedPipe); - return FALSE; + return set_ntstatus( NtFsControlFile(hNamedPipe, NULL, NULL, NULL, NULL, + FSCTL_PIPE_IMPERSONATE, NULL, 0, NULL, 0) ); } /****************************************************************************** @@ -1770,23 +1859,40 @@ /****************************************************************************** * RevertToSelf [ADVAPI32.@] * + * Ends the impersonation of a user. + * * PARAMS * void [] + * + * RETURNS + * Success: TRUE. + * Failure: FALSE. */ BOOL WINAPI RevertToSelf( void ) { - FIXME("(), stub\n"); - return TRUE; + HANDLE Token = NULL; + return set_ntstatus( NtSetInformationThread( GetCurrentThread(), + ThreadImpersonationToken, &Token, sizeof(Token) ) ); } /****************************************************************************** * ImpersonateSelf [ADVAPI32.@] + * + * Makes an impersonation token that represents the process user and assigns + * to the current thread. + * + * PARAMS + * ImpersonationLevel [I] Level at which to impersonate. + * + * RETURNS + * Success: TRUE. + * Failure: FALSE. */ BOOL WINAPI ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL ImpersonationLevel) { - return RtlImpersonateSelf(ImpersonationLevel); + return set_ntstatus( RtlImpersonateSelf( ImpersonationLevel ) ); } /****************************************************************************** @@ -1844,14 +1950,22 @@ return !*AccessStatus; } +/****************************************************************************** + * MapGenericMask [ADVAPI32.@] + * + * Maps generic access rights into specific access rights according to the + * supplied mapping. + * + * PARAMS + * AccessMask [I/O] Access rights. + * GenericMapping [I] The mapping between generic and specific rights. + * + * RETURNS + * Nothing. + */ VOID WINAPI MapGenericMask( PDWORD AccessMask, PGENERIC_MAPPING GenericMapping ) { - FIXME("%p %p - stub\n", AccessMask, GenericMapping); - - *AccessMask |= GenericMapping->GenericRead; - *AccessMask |= GenericMapping->GenericWrite; - *AccessMask |= GenericMapping->GenericExecute; - *AccessMask |= GenericMapping->GenericAll; + RtlMapGenericMask( AccessMask, GenericMapping ); } /************************************************************************* @@ -1870,15 +1984,15 @@ * AddAuditAccessAce [ADVAPI32.@] */ BOOL WINAPI AddAuditAccessAce( - IN OUT PACL pAcl, - IN DWORD dwAceRevision, - IN DWORD dwAccessMask, - IN PSID pSid, - IN BOOL bAuditSuccess, - IN BOOL bAuditFailure) + IN OUT PACL pAcl, + IN DWORD dwAceRevision, + IN DWORD dwAccessMask, + IN PSID pSid, + IN BOOL bAuditSuccess, + IN BOOL bAuditFailure) { - FIXME("Stub\n"); - return TRUE; + return set_ntstatus( RtlAddAuditAccessAce(pAcl, dwAceRevision, dwAccessMask, pSid, + bAuditSuccess, bAuditFailure) ); } /****************************************************************************** @@ -2259,6 +2373,84 @@ pTrustee->ptstrName = name; } +/****************************************************************************** + * GetTrusteeFormA [ADVAPI32.@] + */ +TRUSTEE_FORM WINAPI GetTrusteeFormA(PTRUSTEEA pTrustee) +{ + TRACE("(%p)\n", pTrustee); + + if (!pTrustee) + return TRUSTEE_BAD_FORM; + + return pTrustee->TrusteeForm; +} + +/****************************************************************************** + * GetTrusteeFormW [ADVAPI32.@] + */ +TRUSTEE_FORM WINAPI GetTrusteeFormW(PTRUSTEEW pTrustee) +{ + TRACE("(%p)\n", pTrustee); + + if (!pTrustee) + return TRUSTEE_BAD_FORM; + + return pTrustee->TrusteeForm; +} + +/****************************************************************************** + * GetTrusteeNameA [ADVAPI32.@] + */ +LPSTR WINAPI GetTrusteeNameA(PTRUSTEEA pTrustee) +{ + TRACE("(%p)\n", pTrustee); + + if (!pTrustee) + return NULL; + + return pTrustee->ptstrName; +} + +/****************************************************************************** + * GetTrusteeNameW [ADVAPI32.@] + */ +LPWSTR WINAPI GetTrusteeNameW(PTRUSTEEW pTrustee) +{ + TRACE("(%p)\n", pTrustee); + + if (!pTrustee) + return NULL; + + return pTrustee->ptstrName; +} + +/****************************************************************************** + * GetTrusteeTypeA [ADVAPI32.@] + */ +TRUSTEE_TYPE WINAPI GetTrusteeTypeA(PTRUSTEEA pTrustee) +{ + TRACE("(%p)\n", pTrustee); + + if (!pTrustee) + return TRUSTEE_IS_UNKNOWN; + + return pTrustee->TrusteeType; +} + +/****************************************************************************** + * GetTrusteeTypeW [ADVAPI32.@] + */ +TRUSTEE_TYPE WINAPI GetTrusteeTypeW(PTRUSTEEW pTrustee) +{ + TRACE("(%p)\n", pTrustee); + + if (!pTrustee) + return TRUSTEE_IS_UNKNOWN; + + return pTrustee->TrusteeType; +} + BOOL WINAPI SetAclInformation( PACL pAcl, LPVOID pAclInformation, DWORD nAclInformationLength, ACL_INFORMATION_CLASS dwAclInformationClass ) @@ -3137,8 +3329,9 @@ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, PHANDLE DuplicateTokenHandle ) { - return DuplicateTokenEx( ExistingTokenHandle, 0, NULL, ImpersonationLevel, - TokenImpersonation, DuplicateTokenHandle ); + return DuplicateTokenEx( ExistingTokenHandle, TOKEN_IMPERSONATE | TOKEN_QUERY, + NULL, ImpersonationLevel, TokenImpersonation, + DuplicateTokenHandle ); } BOOL WINAPI EnumDependentServicesA( diff -urN wine-20050524/dlls/advapi32/service.c wine-20050628/dlls/advapi32/service.c --- wine-20050524/dlls/advapi32/service.c 2005-04-19 12:24:22.000000000 +0200 +++ wine-20050628/dlls/advapi32/service.c 2005-06-13 12:00:37.000000000 +0200 @@ -32,6 +32,8 @@ #include "wine/unicode.h" #include "wine/debug.h" #include "winternl.h" +#include "lmcons.h" +#include "lmserver.h" WINE_DEFAULT_DEBUG_CHANNEL(advapi); diff -urN wine-20050524/dlls/advapi32/tests/crypt.c wine-20050628/dlls/advapi32/tests/crypt.c --- wine-20050524/dlls/advapi32/tests/crypt.c 2005-04-23 21:05:03.000000000 +0200 +++ wine-20050628/dlls/advapi32/tests/crypt.c 2005-06-20 16:18:05.000000000 +0200 @@ -494,7 +494,7 @@ return TRUE; } -static void test_enum_provider_types() +static void test_enum_provider_types(void) { /* expected values */ DWORD dwProvType; @@ -591,13 +591,13 @@ PSTR ptr; DWORD user = dwFlags & CRYPT_USER_DEFAULT; - LPSTR MACHINESTR = "Software\\Microsoft\\Cryptography\\Defaults\\Provider Types\\Type XXX"; - LPSTR USERSTR = "Software\\Microsoft\\Cryptography\\Provider Type XXX"; + LPCSTR machinestr = "Software\\Microsoft\\Cryptography\\Defaults\\Provider Types\\Type XXX"; + LPCSTR userstr = "Software\\Microsoft\\Cryptography\\Provider Type XXX"; - keyname = LocalAlloc(LMEM_ZEROINIT, (user ? strlen(USERSTR) : strlen(MACHINESTR)) + 1); + keyname = LocalAlloc(LMEM_ZEROINIT, (user ? strlen(userstr) : strlen(machinestr)) + 1); if (keyname) { - user ? strcpy(keyname, USERSTR) : strcpy(keyname, MACHINESTR); + user ? strcpy(keyname, userstr) : strcpy(keyname, machinestr); ptr = keyname + strlen(keyname); *(--ptr) = (dwProvType % 10) + '0'; *(--ptr) = ((dwProvType / 10) % 10) + '0'; @@ -634,7 +634,7 @@ return TRUE; } -static void test_get_default_provider() +static void test_get_default_provider(void) { /* expected results */ DWORD dwProvType = PROV_RSA_FULL; @@ -708,7 +708,7 @@ LocalFree(provName); } -static void test_set_provider_ex() +static void test_set_provider_ex(void) { DWORD result; DWORD notNull = 5; diff -urN wine-20050524/dlls/advapi32/tests/crypt_lmhash.c wine-20050628/dlls/advapi32/tests/crypt_lmhash.c --- wine-20050524/dlls/advapi32/tests/crypt_lmhash.c 2004-10-04 22:42:05.000000000 +0200 +++ wine-20050628/dlls/advapi32/tests/crypt_lmhash.c 2005-06-20 16:18:05.000000000 +0200 @@ -27,7 +27,7 @@ typedef VOID (WINAPI *fnSystemFunction006)( PCSTR passwd, PSTR lmhash ); fnSystemFunction006 pSystemFunction006; -static void test_SystemFunction006() +static void test_SystemFunction006(void) { static unsigned char lmhash[16 + 1]; diff -urN wine-20050524/dlls/advapi32/tests/crypt_md4.c wine-20050628/dlls/advapi32/tests/crypt_md4.c --- wine-20050524/dlls/advapi32/tests/crypt_md4.c 2004-10-06 20:53:29.000000000 +0200 +++ wine-20050628/dlls/advapi32/tests/crypt_md4.c 2005-06-13 12:00:37.000000000 +0200 @@ -43,7 +43,7 @@ #define ctxcmp( a, b ) memcmp( (char*)a, (char*)b, FIELD_OFFSET( MD4_CTX, in ) ) -void test_md4_ctx() +static void test_md4_ctx(void) { static unsigned char message[] = "In our Life there's If" diff -urN wine-20050524/dlls/advapi32/tests/crypt_md5.c wine-20050628/dlls/advapi32/tests/crypt_md5.c --- wine-20050524/dlls/advapi32/tests/crypt_md5.c 2004-10-06 20:53:29.000000000 +0200 +++ wine-20050628/dlls/advapi32/tests/crypt_md5.c 2005-06-13 12:00:37.000000000 +0200 @@ -43,7 +43,7 @@ #define ctxcmp( a, b ) memcmp( (char*)a, (char*)b, FIELD_OFFSET( MD5_CTX, in ) ) -void test_md5_ctx() +static void test_md5_ctx(void) { static unsigned char message[] = "In our Life there's If" diff -urN wine-20050524/dlls/advapi32/tests/registry.c wine-20050628/dlls/advapi32/tests/registry.c --- wine-20050524/dlls/advapi32/tests/registry.c 2005-04-19 14:00:04.000000000 +0200 +++ wine-20050628/dlls/advapi32/tests/registry.c 2005-06-20 16:18:05.000000000 +0200 @@ -243,7 +243,7 @@ ok( !memcmp( dataW, foobarW, sizeof(foobarW) ), "data is not 'foobar'\n" ); } -static void test_query_value_ex() +static void test_query_value_ex(void) { DWORD ret; DWORD size; @@ -255,7 +255,7 @@ ok(type == REG_SZ, "type %ld is not REG_SZ\n", type); } -static void test_reg_open_key() +static void test_reg_open_key(void) { DWORD ret = 0; HKEY hkResult = NULL; @@ -267,48 +267,53 @@ ok(hkResult != NULL, "expected hkResult != NULL\n"); hkPreserve = hkResult; - /* open same key twice */ - ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkResult); - ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); - ok(hkResult != hkPreserve, "epxected hkResult != hkPreserve\n"); - ok(hkResult != NULL, "hkResult != NULL\n"); - RegCloseKey(hkResult); - - /* open nonexistent key - * check that hkResult is set to NULL - */ - hkResult = hkPreserve; - ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult); - ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld\n", ret); - ok(hkResult == NULL, "expected hkResult == NULL\n"); - - /* open the same nonexistent key again to make sure the key wasn't created */ - hkResult = hkPreserve; - ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult); - ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld\n", ret); - ok(hkResult == NULL, "expected hkResult == NULL\n"); - - /* send in NULL lpSubKey - * check that hkResult receives the value of hKey - */ - hkResult = hkPreserve; - ret = RegOpenKeyA(HKEY_CURRENT_USER, NULL, &hkResult); - ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); - ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n"); - - /* send empty-string in lpSubKey */ - hkResult = hkPreserve; - ret = RegOpenKeyA(HKEY_CURRENT_USER, "", &hkResult); - ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); - ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n"); - - /* send in NULL lpSubKey and NULL hKey - * hkResult is set to NULL - */ - hkResult = hkPreserve; - ret = RegOpenKeyA(NULL, NULL, &hkResult); - ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); - ok(hkResult == NULL, "expected hkResult == NULL\n"); + /* these tests fail on Win9x, but we want to be compatible with NT, so + * run them if we can */ + if (!(GetVersion() & 0x80000000)) + { + /* open same key twice */ + ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkResult); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + ok(hkResult != hkPreserve, "epxected hkResult != hkPreserve\n"); + ok(hkResult != NULL, "hkResult != NULL\n"); + RegCloseKey(hkResult); + + /* open nonexistent key + * check that hkResult is set to NULL + */ + hkResult = hkPreserve; + ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult); + ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld\n", ret); + ok(hkResult == NULL, "expected hkResult == NULL\n"); + + /* open the same nonexistent key again to make sure the key wasn't created */ + hkResult = hkPreserve; + ret = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Nonexistent", &hkResult); + ok(ret == ERROR_FILE_NOT_FOUND, "expected ERROR_FILE_NOT_FOUND, got %ld\n", ret); + ok(hkResult == NULL, "expected hkResult == NULL\n"); + + /* send in NULL lpSubKey + * check that hkResult receives the value of hKey + */ + hkResult = hkPreserve; + ret = RegOpenKeyA(HKEY_CURRENT_USER, NULL, &hkResult); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n"); + + /* send empty-string in lpSubKey */ + hkResult = hkPreserve; + ret = RegOpenKeyA(HKEY_CURRENT_USER, "", &hkResult); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + ok(hkResult == HKEY_CURRENT_USER, "expected hkResult == HKEY_CURRENT_USER\n"); + + /* send in NULL lpSubKey and NULL hKey + * hkResult is set to NULL + */ + hkResult = hkPreserve; + ret = RegOpenKeyA(NULL, NULL, &hkResult); + ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); + ok(hkResult == NULL, "expected hkResult == NULL\n"); + } /* only send NULL hKey * the value of hkResult remains unchanged @@ -325,7 +330,23 @@ ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", ret); } -static void test_reg_close_key() +static void test_reg_create_key(void) +{ + LONG ret; + HKEY hkey1, hkey2; + ret = RegCreateKeyExA(hkey_main, "Subkey1", 0, NULL, 0, KEY_NOTIFY, NULL, &hkey1, NULL); + ok(!ret, "RegCreateKeyExA failed with error %ld\n", ret); + /* should succeed: all versions of Windows ignore the access rights + * to the parent handle */ + ret = RegCreateKeyExA(hkey1, "Subkey2", 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey2, NULL); + ok(!ret, "RegCreateKeyExA failed with error %ld\n", ret); + + /* clean up */ + RegDeleteKey(hkey2, NULL); + RegDeleteKey(hkey1, NULL); +} + +static void test_reg_close_key(void) { DWORD ret = 0; HKEY hkHandle; @@ -348,7 +369,7 @@ "expected ERROR_INVALID_HANDLE or ERROR_BADKEY, got %ld\n", ret); } -static void test_reg_delete_key() +static void test_reg_delete_key(void) { DWORD ret; @@ -357,7 +378,7 @@ "expected ERROR_INVALID_PARAMETER or ERROR_ACCESS_DENIED, got %ld\n", ret); } -static void test_reg_save_key() +static void test_reg_save_key(void) { DWORD ret; @@ -365,7 +386,7 @@ ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", ret); } -static void test_reg_load_key() +static void test_reg_load_key(void) { DWORD ret; HKEY hkHandle; @@ -379,7 +400,7 @@ RegCloseKey(hkHandle); } -static void test_reg_unload_key() +static void test_reg_unload_key(void) { DWORD ret; @@ -430,6 +451,7 @@ test_enum_value(); test_query_value_ex(); test_reg_open_key(); + test_reg_create_key(); test_reg_close_key(); test_reg_delete_key(); diff -urN wine-20050524/dlls/advapi32/tests/security.c wine-20050628/dlls/advapi32/tests/security.c --- wine-20050524/dlls/advapi32/tests/security.c 2005-03-31 12:07:11.000000000 +0200 +++ wine-20050628/dlls/advapi32/tests/security.c 2005-06-28 15:52:01.000000000 +0200 @@ -33,6 +33,7 @@ typedef BOOL (WINAPI *fnConvertStringSidToSidA)( LPCSTR str, PSID pSid ); typedef BOOL (WINAPI *fnGetFileSecurityA)(LPCSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, LPDWORD); +typedef DWORD (WINAPI *fnRtlAdjustPrivilege)(ULONG,BOOLEAN,BOOLEAN,PBOOLEAN); static HMODULE hmod; @@ -41,6 +42,7 @@ fnConvertSidToStringSidA pConvertSidToStringSidA; fnConvertStringSidToSidA pConvertStringSidToSidA; fnGetFileSecurityA pGetFileSecurityA; +fnRtlAdjustPrivilege pRtlAdjustPrivilege; struct sidRef { @@ -53,7 +55,7 @@ hmod = GetModuleHandle("advapi32.dll"); } -void test_sid() +static void test_sid(void) { struct sidRef refs[] = { { { {0x00,0x00,0x33,0x44,0x55,0x66} }, "S-1-860116326-1" }, @@ -144,11 +146,11 @@ } } -void test_trustee() +static void test_trustee(void) { TRUSTEE trustee; PSID psid; - LPSTR str = "2jjj"; + char str[] = "2jjj"; SID_IDENTIFIER_AUTHORITY auth = { {0x11,0x22,0,0,0, 0} }; @@ -253,7 +255,7 @@ static void test_lookupPrivilegeName(void) { - BOOL (WINAPI *pLookupPrivilegeNameA)(LPSTR, PLUID, LPSTR, LPDWORD); + BOOL (WINAPI *pLookupPrivilegeNameA)(LPCSTR, PLUID, LPSTR, LPDWORD); char buf[MAX_PATH]; /* arbitrary, seems long enough */ DWORD cchName = sizeof(buf); LUID luid = { 0, 0 }; @@ -432,6 +434,141 @@ "expected, got %ld\n", GetLastError()); } +static void test_AccessCheck(void) +{ + PSID EveryoneSid = NULL, AdminSid = NULL, UsersSid = NULL; + PACL Acl = NULL; + SECURITY_DESCRIPTOR *SecurityDescriptor = NULL; + SID_IDENTIFIER_AUTHORITY SIDAuthWorld = { SECURITY_WORLD_SID_AUTHORITY }; + SID_IDENTIFIER_AUTHORITY SIDAuthNT = { SECURITY_NT_AUTHORITY }; + GENERIC_MAPPING Mapping = { KEY_READ, KEY_WRITE, KEY_EXECUTE, KEY_ALL_ACCESS }; + ACCESS_MASK Access; + BOOL AccessStatus; + HANDLE Token; + BOOL ret; + DWORD PrivSetLen; + PRIVILEGE_SET *PrivSet; + BOOL res; + HMODULE NtDllModule; + BOOLEAN Enabled; + + NtDllModule = GetModuleHandle("ntdll.dll"); + + if (!NtDllModule) + { + trace("not running on NT, skipping test\n"); + return; + } + pRtlAdjustPrivilege = (fnRtlAdjustPrivilege) + GetProcAddress(NtDllModule, "RtlAdjustPrivilege"); + if (!pRtlAdjustPrivilege) return; + + Acl = HeapAlloc(GetProcessHeap(), 0, 256); + res = InitializeAcl(Acl, 256, ACL_REVISION); + if(!res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + trace("ACLs not implemented - skipping tests\n"); + return; + } + ok(res, "InitializeAcl failed with error %ld\n", GetLastError()); + + res = AllocateAndInitializeSid( &SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &EveryoneSid); + ok(res, "AllocateAndInitializeSid failed with error %ld\n", GetLastError()); + + res = AllocateAndInitializeSid( &SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdminSid); + ok(res, "AllocateAndInitializeSid failed with error %ld\n", GetLastError()); + + res = AllocateAndInitializeSid( &SIDAuthNT, 2, SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_USERS, 0, 0, 0, 0, 0, 0, &UsersSid); + ok(res, "AllocateAndInitializeSid failed with error %ld\n", GetLastError()); + + res = AddAccessAllowedAce(Acl, ACL_REVISION, KEY_READ, EveryoneSid); + ok(res, "AddAccessAllowedAceEx failed with error %ld\n", GetLastError()); + + res = AddAccessAllowedAce(Acl, ACL_REVISION, KEY_ALL_ACCESS, AdminSid); + ok(res, "AddAccessAllowedAceEx failed with error %ld\n", GetLastError()); + + SecurityDescriptor = HeapAlloc(GetProcessHeap(), 0, SECURITY_DESCRIPTOR_MIN_LENGTH); + + res = InitializeSecurityDescriptor(SecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); + ok(res, "InitializeSecurityDescriptor failed with error %ld\n", GetLastError()); + + res = SetSecurityDescriptorDacl(SecurityDescriptor, TRUE, Acl, FALSE); + ok(res, "SetSecurityDescriptorDacl failed with error %ld\n", GetLastError()); + + res = SetSecurityDescriptorOwner(SecurityDescriptor, AdminSid, FALSE); + ok(res, "SetSecurityDescriptorOwner failed with error %ld\n", GetLastError()); + + res = SetSecurityDescriptorGroup(SecurityDescriptor, UsersSid, TRUE); + ok(res, "SetSecurityDescriptorGroup failed with error %ld\n", GetLastError()); + + PrivSetLen = FIELD_OFFSET(PRIVILEGE_SET, Privilege[16]); + PrivSet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, PrivSetLen); + PrivSet->PrivilegeCount = 16; + + ImpersonateSelf(SecurityImpersonation); + + pRtlAdjustPrivilege(SE_SECURITY_PRIVILEGE, FALSE, TRUE, &Enabled); + + ret = OpenThreadToken(GetCurrentThread(), + TOKEN_QUERY, TRUE, &Token); + ok(ret, "OpenThreadToken failed with error %ld\n", GetLastError()); + + ret = AccessCheck(SecurityDescriptor, Token, KEY_READ, &Mapping, + PrivSet, &PrivSetLen, &Access, &AccessStatus); + ok(ret, "AccessCheck failed with error %ld\n", GetLastError()); + todo_wine ok(AccessStatus && (Access == KEY_READ), + "AccessCheck failed to grant access with error %ld\n", + GetLastError()); + + ret = AccessCheck(SecurityDescriptor, Token, MAXIMUM_ALLOWED, &Mapping, + PrivSet, &PrivSetLen, &Access, &AccessStatus); + ok(ret, "AccessCheck failed with error %ld\n", GetLastError()); + todo_wine ok(AccessStatus, + "AccessCheck failed to grant any access with error %ld\n", + GetLastError()); + trace("AccessCheck with MAXIMUM_ALLOWED got Access 0x%08lx\n", Access); + + SetLastError(0); + PrivSet->PrivilegeCount = 16; + ret = AccessCheck(SecurityDescriptor, Token, ACCESS_SYSTEM_SECURITY, &Mapping, + PrivSet, &PrivSetLen, &Access, &AccessStatus); + ok(ret && !AccessStatus && GetLastError() == ERROR_PRIVILEGE_NOT_HELD, + "AccessCheck should have failed with ERROR_PRIVILEGE_NOT_HELD, instead of %ld\n", + GetLastError()); + + ret = pRtlAdjustPrivilege(SE_SECURITY_PRIVILEGE, TRUE, TRUE, &Enabled); + if (!ret) + { + SetLastError(0); + PrivSet->PrivilegeCount = 16; + ret = AccessCheck(SecurityDescriptor, Token, ACCESS_SYSTEM_SECURITY, &Mapping, + PrivSet, &PrivSetLen, &Access, &AccessStatus); + ok(ret && AccessStatus && GetLastError() == 0, + "AccessCheck should have succeeded, error %ld\n", + GetLastError()); + ok(Access == ACCESS_SYSTEM_SECURITY, + "Access should be equal to ACCESS_SYSTEM_SECURITY instead of 0x%08lx\n", + Access); + } + else + trace("Couldn't get SE_SECURITY_PRIVILEGE (0x%08x), skipping ACCESS_SYSTEM_SECURITY test\n", + ret); + + RevertToSelf(); + + if (EveryoneSid) + FreeSid(EveryoneSid); + if (AdminSid) + FreeSid(AdminSid); + if (UsersSid) + FreeSid(UsersSid); + HeapFree(GetProcessHeap(), 0, Acl); + HeapFree(GetProcessHeap(), 0, SecurityDescriptor); + HeapFree(GetProcessHeap(), 0, PrivSet); +} + START_TEST(security) { init(); @@ -440,4 +577,5 @@ test_trustee(); test_luid(); test_FileSecurity(); + test_AccessCheck(); } diff -urN wine-20050524/dlls/advpack/tests/advpack.c wine-20050628/dlls/advpack/tests/advpack.c --- wine-20050524/dlls/advpack/tests/advpack.c 2005-04-27 11:37:25.000000000 +0200 +++ wine-20050628/dlls/advpack/tests/advpack.c 2005-06-20 16:18:05.000000000 +0200 @@ -27,7 +27,7 @@ static HRESULT (WINAPI *pGetVersionFromFile)(LPSTR,LPDWORD,LPDWORD,BOOL); static HRESULT (WINAPI *pDelNode)(LPCSTR,DWORD); -static void version_test() +static void version_test(void) { HRESULT hr; DWORD major, minor; @@ -49,7 +49,7 @@ HIWORD(minor), LOWORD(minor)); } -static void delnode_test() +static void delnode_test(void) { HRESULT hr; HANDLE hn; diff -urN wine-20050524/dlls/amstream/amstream.c wine-20050628/dlls/amstream/amstream.c --- wine-20050524/dlls/amstream/amstream.c 2005-01-10 13:25:29.000000000 +0100 +++ wine-20050628/dlls/amstream/amstream.c 2005-05-27 22:17:37.000000000 +0200 @@ -39,7 +39,7 @@ ULONG ref; } IAMMultiMediaStreamImpl; -static struct IAMMultiMediaStreamVtbl AM_Vtbl; +static const struct IAMMultiMediaStreamVtbl AM_Vtbl; HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj) { @@ -107,7 +107,7 @@ FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, pdwFlags, pStreamType); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetMediaStream(IAMMultiMediaStream* iface, REFMSPID idPurpose, IMediaStream** ppMediaStream) @@ -116,7 +116,7 @@ FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, idPurpose, ppMediaStream); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_EnumMediaStreams(IAMMultiMediaStream* iface, long Index, IMediaStream** ppMediaStream) @@ -125,7 +125,7 @@ FIXME("(%p/%p)->(%ld,%p) stub!\n", This, iface, Index, ppMediaStream); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetState(IAMMultiMediaStream* iface, STREAM_STATE* pCurrentState) @@ -134,7 +134,7 @@ FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentState); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_SetState(IAMMultiMediaStream* iface, STREAM_STATE NewState) @@ -143,7 +143,7 @@ FIXME("(%p/%p)->() stub!\n", This, iface); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetTime(IAMMultiMediaStream* iface, STREAM_TIME* pCurrentTime) @@ -152,7 +152,7 @@ FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentTime); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetDuration(IAMMultiMediaStream* iface, STREAM_TIME* pDuration) @@ -161,7 +161,7 @@ FIXME("(%p/%p)->(%p) stub!\n", This, iface, pDuration); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_Seek(IAMMultiMediaStream* iface, STREAM_TIME SeekTime) @@ -170,7 +170,7 @@ FIXME("(%p/%p)->() stub!\n", This, iface); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetEndOfStream(IAMMultiMediaStream* iface, HANDLE* phEOS) @@ -179,7 +179,7 @@ FIXME("(%p/%p)->(%p) stub!\n", This, iface, phEOS); - return S_FALSE; + return E_NOTIMPL; } /*** IAMMultiMediaStream methods ***/ @@ -189,7 +189,7 @@ FIXME("(%p/%p)->(%lx,%lx,%p) stub!\n", This, iface, (DWORD)StreamType, dwFlags, pFilterGraph); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream* iface, IGraphBuilder** ppGraphBuilder) @@ -198,7 +198,7 @@ FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppGraphBuilder); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream* iface, IMediaStreamFilter** ppFilter) @@ -207,7 +207,7 @@ FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppFilter); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream* iface, IUnknown* pStreamObject, const MSPID* PurposeId, @@ -217,7 +217,7 @@ FIXME("(%p/%p)->(%p,%p,%lx,%p) stub!\n", This, iface, pStreamObject, PurposeId, dwFlags, ppNewStream); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* iface, LPCWSTR pszFileName, DWORD dwFlags) @@ -226,7 +226,7 @@ FIXME("(%p/%p)->(%p,%lx) stub!\n", This, iface, pszFileName, dwFlags); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenMoniker(IAMMultiMediaStream* iface, IBindCtx* pCtx, IMoniker* pMoniker, DWORD dwFlags) @@ -235,7 +235,7 @@ FIXME("(%p/%p)->(%p,%p,%lx) stub!\n", This, iface, pCtx, pMoniker, dwFlags); - return S_FALSE; + return E_NOTIMPL; } static HRESULT WINAPI IAMMultiMediaStreamImpl_Render(IAMMultiMediaStream* iface, DWORD dwFlags) @@ -244,10 +244,10 @@ FIXME("(%p/%p)->(%lx) stub!\n", This, iface, dwFlags); - return S_FALSE; + return E_NOTIMPL; } -static IAMMultiMediaStreamVtbl AM_Vtbl = +static const IAMMultiMediaStreamVtbl AM_Vtbl = { IAMMultiMediaStreamImpl_QueryInterface, IAMMultiMediaStreamImpl_AddRef, diff -urN wine-20050524/dlls/amstream/main.c wine-20050628/dlls/amstream/main.c --- wine-20050524/dlls/amstream/main.c 2004-10-07 05:06:51.000000000 +0200 +++ wine-20050628/dlls/amstream/main.c 2005-05-27 22:17:37.000000000 +0200 @@ -141,7 +141,7 @@ return S_OK; } -static IClassFactoryVtbl DSCF_Vtbl = +static const IClassFactoryVtbl DSCF_Vtbl = { AMCF_QueryInterface, AMCF_AddRef, diff -urN wine-20050524/dlls/atl/atlbase.h wine-20050628/dlls/atl/atlbase.h --- wine-20050524/dlls/atl/atlbase.h 2005-04-22 21:04:18.000000000 +0200 +++ wine-20050628/dlls/atl/atlbase.h 2005-06-22 14:00:12.000000000 +0200 @@ -18,6 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef __WINE_ATLBASE_H__ +#define __WINE_ATLBASE_H__ + +#define COBJMACROS + +#include "atliface.h" + typedef HRESULT (WINAPI _ATL_CREATORFUNC)(void* pv, REFIID riid, LPVOID* ppv); typedef HRESULT (WINAPI _ATL_CREATORARGFUNC)(void* pv, REFIID riid, LPVOID* ppv, DWORD dw); typedef HRESULT (WINAPI _ATL_MODULEFUNC)(DWORD dw); @@ -134,9 +141,18 @@ LPCOLESTR szData; }; +HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID * iid, LPDWORD dpw); +HRESULT WINAPI AtlFreeMarshalStream(IStream *pStream); +HRESULT WINAPI AtlInternalQueryInterface(LPVOID pThis, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, LPVOID* ppvObject); +HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **ppStream); HRESULT WINAPI AtlModuleInit(_ATL_MODULEA* pM, _ATL_OBJMAP_ENTRYA* p, HINSTANCE h); HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEA* pM, DWORD dwClsContext, DWORD dwFlags); +HRESULT WINAPI AtlModuleRegisterServer(_ATL_MODULEW* pM, BOOL bRegTypeLib, const CLSID* pCLSID); +HRESULT WINAPI AtlModuleUnregisterServer(_ATL_MODULEW* pM, const CLSID* pCLSID); +HRESULT WINAPI AtlModuleUpdateRegistryFromResourceD(_ATL_MODULEW *pM, LPCOLESTR lpszRes, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries, IRegistrar *pReg ); HRESULT WINAPI AtlModuleUnregisterServerEx(_ATL_MODULEA* pM, BOOL bUnRegTypeLib, const CLSID* pCLSID); HRESULT WINAPI AtlModuleTerm(_ATL_MODULEA* pM); -HRESULT WINAPI AtlInternalQueryInterface(LPVOID pThis, - const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, LPVOID* ppvObject); +HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID * iid, DWORD dw); +HRESULT WINAPI AtlUnmarshalPtr(IStream *pStream, const IID *iid, IUnknown **ppUnk); + +#endif /* __WINE_ATLBASE_H__ */ diff -urN wine-20050524/dlls/atl/registrar.c wine-20050628/dlls/atl/registrar.c --- wine-20050524/dlls/atl/registrar.c 2005-03-21 11:52:04.000000000 +0100 +++ wine-20050628/dlls/atl/registrar.c 2005-05-27 22:17:37.000000000 +0200 @@ -78,7 +78,7 @@ } rep_list; typedef struct { - IRegistrarVtbl *lpVtbl; + const IRegistrarVtbl *lpVtbl; ULONG ref; rep_list *rep; } Registrar; @@ -644,7 +644,7 @@ return resource_register(This, resFileName, (LPOLESTR)nID, szType, FALSE); } -static IRegistrarVtbl RegistrarVtbl = { +static const IRegistrarVtbl RegistrarVtbl = { Registrar_QueryInterface, Registrar_AddRef, Registrar_Release, diff -urN wine-20050524/dlls/avifil32/acmstream.c wine-20050628/dlls/avifil32/acmstream.c --- wine-20050524/dlls/avifil32/acmstream.c 2005-01-14 16:10:52.000000000 +0100 +++ wine-20050628/dlls/avifil32/acmstream.c 2005-05-27 22:17:37.000000000 +0200 @@ -54,7 +54,7 @@ static HRESULT WINAPI ACMStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size); static HRESULT WINAPI ACMStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); -struct IAVIStreamVtbl iacmst = { +static const struct IAVIStreamVtbl iacmst = { ACMStream_fnQueryInterface, ACMStream_fnAddRef, ACMStream_fnRelease, @@ -73,7 +73,7 @@ typedef struct _IAVIStreamImpl { /* IUnknown stuff */ - IAVIStreamVtbl *lpVtbl; + const IAVIStreamVtbl *lpVtbl; DWORD ref; /* IAVIStream stuff */ diff -urN wine-20050524/dlls/avifil32/avifile.c wine-20050628/dlls/avifil32/avifile.c --- wine-20050524/dlls/avifil32/avifile.c 2005-01-14 16:10:52.000000000 +0100 +++ wine-20050628/dlls/avifil32/avifile.c 2005-05-27 22:17:37.000000000 +0200 @@ -69,7 +69,7 @@ static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface); static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam); -struct IAVIFileVtbl iavift = { +static const struct IAVIFileVtbl iavift = { IAVIFile_fnQueryInterface, IAVIFile_fnAddRef, IAVIFile_fnRelease, @@ -92,7 +92,7 @@ static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile*iface,LPCOLESTR pszFileName); static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile*iface,LPOLESTR*ppszFileName); -struct IPersistFileVtbl ipersistft = { +static const struct IPersistFileVtbl ipersistft = { IPersistFile_fnQueryInterface, IPersistFile_fnAddRef, IPersistFile_fnRelease, @@ -119,7 +119,7 @@ static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size); static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); -struct IAVIStreamVtbl iavist = { +static const struct IAVIStreamVtbl iavist = { IAVIStream_fnQueryInterface, IAVIStream_fnAddRef, IAVIStream_fnRelease, @@ -140,7 +140,7 @@ typedef struct _IPersistFileImpl { /* IUnknown stuff */ - IPersistFileVtbl *lpVtbl; + const IPersistFileVtbl *lpVtbl; /* IPersistFile stuff */ IAVIFileImpl *paf; @@ -148,7 +148,7 @@ typedef struct _IAVIStreamImpl { /* IUnknown stuff */ - IAVIStreamVtbl *lpVtbl; + const IAVIStreamVtbl *lpVtbl; DWORD ref; /* IAVIStream stuff */ @@ -177,7 +177,7 @@ struct _IAVIFileImpl { /* IUnknown stuff */ - IAVIFileVtbl *lpVtbl; + const IAVIFileVtbl *lpVtbl; DWORD ref; /* IAVIFile stuff... */ diff -urN wine-20050524/dlls/avifil32/editstream.c wine-20050628/dlls/avifil32/editstream.c --- wine-20050524/dlls/avifil32/editstream.c 2005-01-14 16:10:52.000000000 +0100 +++ wine-20050628/dlls/avifil32/editstream.c 2005-05-27 22:17:37.000000000 +0200 @@ -80,7 +80,7 @@ static HRESULT WINAPI IAVIEditStream_fnSetInfo(IAVIEditStream*iface, LPAVISTREAMINFOW asi,LONG size); -struct IAVIEditStreamVtbl ieditstream = { +static const struct IAVIEditStreamVtbl ieditstream = { IAVIEditStream_fnQueryInterface, IAVIEditStream_fnAddRef, IAVIEditStream_fnRelease, @@ -115,7 +115,7 @@ LPVOID lp,LONG size); static HRESULT WINAPI IEditAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); -struct IAVIStreamVtbl ieditstast = { +static const struct IAVIStreamVtbl ieditstast = { IEditAVIStream_fnQueryInterface, IEditAVIStream_fnAddRef, IEditAVIStream_fnRelease, @@ -137,7 +137,7 @@ static ULONG WINAPI IEditStreamInternal_fnRelease(IEditStreamInternal*iface); static HRESULT WINAPI IEditStreamInternal_fnGetEditStreamImpl(IEditStreamInternal*iface,LPVOID*ppimpl); -struct IEditStreamInternalVtbl ieditstreaminternal = { +static const struct IEditStreamInternalVtbl ieditstreaminternal = { IEditStreamInternal_fnQueryInterface, IEditStreamInternal_fnAddRef, IEditStreamInternal_fnRelease, @@ -148,7 +148,7 @@ typedef struct _IEditAVIStreamImpl { /* IUnknown stuff */ - IAVIStreamVtbl *lpVtbl; + const IAVIStreamVtbl *lpVtbl; /* IAVIStream stuff */ IAVIEditStreamImpl *pae; @@ -156,7 +156,7 @@ typedef struct _IEditStreamInternalImpl { /* IUnknown stuff */ - IEditStreamInternalVtbl *lpVtbl; + const IEditStreamInternalVtbl *lpVtbl; /* IEditStreamInternal stuff */ IAVIEditStreamImpl *pae; @@ -164,7 +164,7 @@ struct _IAVIEditStreamImpl { /* IUnknown stuff */ - IAVIEditStreamVtbl *lpVtbl; + const IAVIEditStreamVtbl *lpVtbl; DWORD ref; /* IAVIEditStream stuff */ diff -urN wine-20050524/dlls/avifil32/factory.c wine-20050628/dlls/avifil32/factory.c --- wine-20050524/dlls/avifil32/factory.c 2004-10-07 05:06:51.000000000 +0200 +++ wine-20050628/dlls/avifil32/factory.c 2005-05-27 22:17:37.000000000 +0200 @@ -50,7 +50,7 @@ static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj); static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock); -static IClassFactoryVtbl iclassfact = { +static const IClassFactoryVtbl iclassfact = { IClassFactory_fnQueryInterface, IClassFactory_fnAddRef, IClassFactory_fnRelease, @@ -61,7 +61,7 @@ typedef struct { /* IUnknown fields */ - IClassFactoryVtbl *lpVtbl; + const IClassFactoryVtbl *lpVtbl; DWORD dwRef; CLSID clsid; diff -urN wine-20050524/dlls/avifil32/getframe.c wine-20050628/dlls/avifil32/getframe.c --- wine-20050524/dlls/avifil32/getframe.c 2005-01-14 16:10:52.000000000 +0100 +++ wine-20050628/dlls/avifil32/getframe.c 2005-05-27 22:17:37.000000000 +0200 @@ -54,7 +54,7 @@ LPVOID lpBits, INT x, INT y, INT dx, INT dy); -struct IGetFrameVtbl igetframeVtbl = { +static const struct IGetFrameVtbl igetframeVtbl = { IGetFrame_fnQueryInterface, IGetFrame_fnAddRef, IGetFrame_fnRelease, @@ -66,7 +66,7 @@ typedef struct _IGetFrameImpl { /* IUnknown stuff */ - IGetFrameVtbl *lpVtbl; + const IGetFrameVtbl *lpVtbl; DWORD ref; /* IGetFrame stuff */ diff -urN wine-20050524/dlls/avifil32/icmstream.c wine-20050628/dlls/avifil32/icmstream.c --- wine-20050524/dlls/avifil32/icmstream.c 2005-01-14 16:10:52.000000000 +0100 +++ wine-20050628/dlls/avifil32/icmstream.c 2005-05-27 22:17:37.000000000 +0200 @@ -57,7 +57,7 @@ static HRESULT WINAPI ICMStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size); static HRESULT WINAPI ICMStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); -struct IAVIStreamVtbl iicmst = { +static const struct IAVIStreamVtbl iicmst = { ICMStream_fnQueryInterface, ICMStream_fnAddRef, ICMStream_fnRelease, @@ -76,7 +76,7 @@ typedef struct _IAVIStreamImpl { /* IUnknown stuff */ - IAVIStreamVtbl *lpVtbl; + const IAVIStreamVtbl *lpVtbl; DWORD ref; /* IAVIStream stuff */ diff -urN wine-20050524/dlls/avifil32/tmpfile.c wine-20050628/dlls/avifil32/tmpfile.c --- wine-20050524/dlls/avifil32/tmpfile.c 2005-01-14 16:10:52.000000000 +0100 +++ wine-20050628/dlls/avifil32/tmpfile.c 2005-05-27 22:17:37.000000000 +0200 @@ -50,7 +50,7 @@ static HRESULT WINAPI ITmpFile_fnEndRecord(IAVIFile*iface); static HRESULT WINAPI ITmpFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam); -struct IAVIFileVtbl itmpft = { +static const struct IAVIFileVtbl itmpft = { ITmpFile_fnQueryInterface, ITmpFile_fnAddRef, ITmpFile_fnRelease, @@ -65,7 +65,7 @@ typedef struct _ITmpFileImpl { /* IUnknown stuff */ - IAVIFileVtbl *lpVtbl; + const IAVIFileVtbl *lpVtbl; DWORD ref; /* IAVIFile stuff */ diff -urN wine-20050524/dlls/avifil32/wavfile.c wine-20050628/dlls/avifil32/wavfile.c --- wine-20050524/dlls/avifil32/wavfile.c 2005-01-14 16:10:52.000000000 +0100 +++ wine-20050628/dlls/avifil32/wavfile.c 2005-05-27 22:17:37.000000000 +0200 @@ -99,7 +99,7 @@ static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface); static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam); -struct IAVIFileVtbl iwavft = { +static const struct IAVIFileVtbl iwavft = { IAVIFile_fnQueryInterface, IAVIFile_fnAddRef, IAVIFile_fnRelease, @@ -122,7 +122,7 @@ static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile*iface,LPCOLESTR pszFileName); static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile*iface,LPOLESTR*ppszFileName); -struct IPersistFileVtbl iwavpft = { +static const struct IPersistFileVtbl iwavpft = { IPersistFile_fnQueryInterface, IPersistFile_fnAddRef, IPersistFile_fnRelease, @@ -149,7 +149,7 @@ static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size); static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); -struct IAVIStreamVtbl iwavst = { +static const struct IAVIStreamVtbl iwavst = { IAVIStream_fnQueryInterface, IAVIStream_fnAddRef, IAVIStream_fnRelease, @@ -170,7 +170,7 @@ typedef struct _IPersistFileImpl { /* IUnknown stuff */ - IPersistFileVtbl *lpVtbl; + const IPersistFileVtbl *lpVtbl; /* IPersistFile stuff */ IAVIFileImpl *paf; @@ -178,7 +178,7 @@ typedef struct _IAVIStreamImpl { /* IUnknown stuff */ - IAVIStreamVtbl *lpVtbl; + const IAVIStreamVtbl *lpVtbl; /* IAVIStream stuff */ IAVIFileImpl *paf; @@ -186,7 +186,7 @@ struct _IAVIFileImpl { /* IUnknown stuff */ - IAVIFileVtbl *lpVtbl; + const IAVIFileVtbl *lpVtbl; DWORD ref; /* IAVIFile, IAVIStream stuff... */ diff -urN wine-20050524/dlls/cabinet/cabextract.c wine-20050628/dlls/cabinet/cabextract.c --- wine-20050524/dlls/cabinet/cabextract.c 2005-04-18 17:33:15.000000000 +0200 +++ wine-20050628/dlls/cabinet/cabextract.c 2005-06-07 22:06:39.000000000 +0200 @@ -31,6 +31,7 @@ #include #include #include +#include #include "windef.h" #include "winbase.h" @@ -2523,7 +2524,6 @@ * print_fileinfo (internal) */ void print_fileinfo(struct cab_file *fi) { - int d = fi->date, t = fi->time; char *fname = NULL; if (fi->attribs & cffile_A_NAME_IS_UTF) { @@ -2536,8 +2536,8 @@ TRACE("%9u | %02d.%02d.%04d %02d:%02d:%02d | %s\n", fi->length, - d & 0x1f, (d>>5) & 0xf, (d>>9) + 1980, - t >> 11, (t>>5) & 0x3f, (t << 1) & 0x3e, + fi->date & 0x1f, (fi->date>>5) & 0xf, (fi->date>>9) + 1980, + fi->time >> 11, (fi->time>>5) & 0x3f, (fi->time << 1) & 0x3e, fname ? fname : fi->filename ); diff -urN wine-20050524/dlls/cabinet/cabinet.h wine-20050628/dlls/cabinet/cabinet.h --- wine-20050524/dlls/cabinet/cabinet.h 2005-05-14 13:06:10.000000000 +0200 +++ wine-20050628/dlls/cabinet/cabinet.h 2005-06-24 14:16:37.000000000 +0200 @@ -305,7 +305,41 @@ PFNFCIDELETE pfndelete; PFNFCIGETTEMPFILE pfnfcigtf; PCCAB pccab; - void *pv; + BOOL fPrevCab; + BOOL fNextCab; + BOOL fSplitFolder; + cab_ULONG statusFolderCopied; + cab_ULONG statusFolderTotal; + BOOL fGetNextCabInVain; + void *pv; + char szPrevCab[CB_MAX_CABINET_NAME]; /* previous cabinet name */ + char szPrevDisk[CB_MAX_DISK_NAME]; /* disk name of previous cabinet */ + CCAB oldCCAB; + char* data_in; /* uncompressed data blocks */ + cab_UWORD cdata_in; + char* data_out; /* compressed data blocks */ + ULONG cCompressedBytesInFolder; + cab_UWORD cFolders; + cab_UWORD cFiles; + cab_ULONG cDataBlocks; + cab_ULONG cbFileRemainer; /* uncompressed, yet to be written data */ + /* of spanned file of a spanning folder of a spanning cabinet */ + cab_UBYTE szFileNameCFDATA1[CB_MAX_FILENAME]; + int handleCFDATA1; + cab_UBYTE szFileNameCFFILE1[CB_MAX_FILENAME]; + int handleCFFILE1; + cab_UBYTE szFileNameCFDATA2[CB_MAX_FILENAME]; + int handleCFDATA2; + cab_UBYTE szFileNameCFFILE2[CB_MAX_FILENAME]; + int handleCFFILE2; + cab_UBYTE szFileNameCFFOLDER[CB_MAX_FILENAME]; + int handleCFFOLDER; + cab_ULONG sizeFileCFDATA1; + cab_ULONG sizeFileCFFILE1; + cab_ULONG sizeFileCFDATA2; + cab_ULONG sizeFileCFFILE2; + cab_ULONG sizeFileCFFOLDER; + BOOL fNewPrevious; } FCI_Int, *PFCI_Int; typedef struct { @@ -326,6 +360,18 @@ /* cast an HFDI into a PFDI_Int */ #define PFDI_INT(hfdi) ((PFDI_Int)(hfdi)) +/* quick pfci method invokers */ +#define PFCI_ALLOC(hfdi, size) ((*PFCI_INT(hfdi)->pfnalloc) (size)) +#define PFCI_FREE(hfdi, ptr) ((*PFCI_INT(hfdi)->pfnfree) (ptr)) +#define PFCI_GETTEMPFILE(hfci,name,length) ((*PFCI_INT(hfci)->pfnfcigtf)(name,length,PFCI_INT(hfci)->pv)) +#define PFCI_DELETE(hfci,name,err,pv) ((*PFCI_INT(hfci)->pfndelete)(name,err,pv)) +#define PFCI_OPEN(hfci,name,oflag,pmode,err,pv) ((*PFCI_INT(hfci)->pfnopen)(name,oflag,pmode,err,pv)) +#define PFCI_READ(hfci,hf,memory,cb,err,pv)((*PFCI_INT(hfci)->pfnread)(hf,memory,cb,err,pv)) +#define PFCI_WRITE(hfci,hf,memory,cb,err,pv) ((*PFCI_INT(hfci)->pfnwrite)(hf,memory,cb,err,pv)) +#define PFCI_CLOSE(hfci,hf,err,pv) ((*PFCI_INT(hfci)->pfnclose)(hf,err,pv)) +#define PFCI_SEEK(hfci,hf,dist,seektype,err,pv)((*PFCI_INT(hfci)->pfnseek)(hf,dist,seektype,err,pv)) +#define PFCI_FILEPLACED(hfci,pccab,name,cb,cont,pv)((*PFCI_INT(hfci)->pfnfiledest)(pccab,name,cb,cont,pv)) + /* quickie pfdi method invokers */ #define PFDI_ALLOC(hfdi, size) ((*PFDI_INT(hfdi)->pfnalloc) (size)) #define PFDI_FREE(hfdi, ptr) ((*PFDI_INT(hfdi)->pfnfree) (ptr)) diff -urN wine-20050524/dlls/cabinet/cabinet_main.c wine-20050628/dlls/cabinet/cabinet_main.c --- wine-20050524/dlls/cabinet/cabinet_main.c 2004-12-14 12:38:50.000000000 +0100 +++ wine-20050628/dlls/cabinet/cabinet_main.c 2005-06-07 22:06:39.000000000 +0200 @@ -89,12 +89,12 @@ HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR what) { #define DUMPC(idx) idx >= sizeof(EXTRACTdest) ? ' ' : \ - ptr[idx] >= 0x20 ? ptr[idx] : '.' + ((unsigned char*) dest)[idx] >= 0x20 ? \ + ((unsigned char*) dest)[idx] : '.' -#define DUMPH(idx) idx >= sizeof(EXTRACTdest) ? 0x55 : ptr[idx] +#define DUMPH(idx) idx >= sizeof(EXTRACTdest) ? 0x55 : ((unsigned char*) dest)[idx] LPSTR dir; - unsigned char *ptr = (unsigned char*) dest; unsigned int i; TRACE("(dest == %0lx, what == %s)\n", (long) dest, debugstr_a(what)); diff -urN wine-20050524/dlls/cabinet/fci.c wine-20050628/dlls/cabinet/fci.c --- wine-20050524/dlls/cabinet/fci.c 2005-05-14 13:06:10.000000000 +0200 +++ wine-20050628/dlls/cabinet/fci.c 2005-06-24 14:16:37.000000000 +0200 @@ -19,9 +19,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* + +There is still some work to be done: + +- currently no support for big-endian machines +- the ERF error structure aren't used on error +- no real compression yet +- unknown behaviour if files>4GB or cabinet >4GB +- incorrect status information +- check if the maximum size for a cabinet is too small to store any data +- call pfnfcignc on exactly the same position as MS FCIAddFile in every case + +*/ + + + #include "config.h" #include +#include +#include #include "windef.h" #include "winbase.h" @@ -33,12 +51,56 @@ WINE_DEFAULT_DEBUG_CHANNEL(cabinet); +typedef struct { + cab_UBYTE signature[4]; /* !CAB for unfinished cabinets else MSCF */ + cab_ULONG reserved1; + cab_ULONG cbCabinet; /* size of the cabinet file in bytes*/ + cab_ULONG reserved2; + cab_ULONG coffFiles; /* offset to first CFFILE section */ + cab_ULONG reserved3; + cab_UBYTE versionMinor; /* 3 */ + cab_UBYTE versionMajor; /* 1 */ + cab_UWORD cFolders; /* number of CFFOLDER entries in the cabinet*/ + cab_UWORD cFiles; /* number of CFFILE entries in the cabinet*/ + cab_UWORD flags; /* 1=prev cab, 2=next cabinet, 4=reserved setions*/ + cab_UWORD setID; /* identification number of all cabinets in a set*/ + cab_UWORD iCabinet; /* number of the cabinet in a set */ + /* additional area if "flags" were set*/ +} CFHEADER; /* minimum 36 bytes */ + +typedef struct { + cab_ULONG coffCabStart; /* offset to the folder's first CFDATA section */ + cab_UWORD cCFData; /* number of this folder's CFDATA sections */ + cab_UWORD typeCompress; /* compression type of data in CFDATA section*/ + /* additional area if reserve flag was set */ +} CFFOLDER; /* minumum 8 bytes */ + +typedef struct { + cab_ULONG cbFile; /* size of the uncompressed file in bytes */ + cab_ULONG uoffFolderStart; /* offset of the uncompressed file in the folder */ + cab_UWORD iFolder; /* number of folder in the cabinet 0=first */ + /* for special values see below this structure*/ + cab_UWORD date; /* last modification date*/ + cab_UWORD time; /* last modification time*/ + cab_UWORD attribs; /* DOS fat attributes and UTF indicator */ + /* ... and a C string with the name of the file */ +} CFFILE; /* 16 bytes + name of file */ + + +typedef struct { + cab_ULONG csum; /* checksum of this entry*/ + cab_UWORD cbData; /* number of compressed bytes */ + cab_UWORD cbUncomp; /* number of bytes when data is uncompressed */ + /* optional reserved area */ + /* compressed data */ +} CFDATA; + + /*********************************************************************** * FCICreate (CABINET.10) * - * Provided with several callbacks, - * returns a handle which can be used to perform operations - * on cabinet files. + * FCICreate is provided with several callbacks and + * returns a handle which can be used to create cabinet files. * * PARAMS * perf [IO] A pointer to an ERF structure. When FCICreate @@ -54,7 +116,7 @@ * the same interface as _open. * pfnread [I] A pointer to a function which reads from a file into * a caller-provided buffer. Uses the same interface - * as _read + * as _read. * pfnwrite [I] A pointer to a function which writes to a file from * a caller-provided buffer. Uses the same interface * as _write. @@ -64,8 +126,8 @@ * Uses the same interface as _lseek. * pfndelete [I] A pointer to a function which deletes a file. * pfnfcigtf [I] A pointer to a function which gets the name of a - * temporary file; ignored in wine - * pccab [I] A pointer to an initialized CCAB structure + * temporary file. + * pccab [I] A pointer to an initialized CCAB structure. * pv [I] A pointer to an application-defined notification * function which will be passed to other FCI functions * as a parameter. @@ -94,9 +156,13 @@ PCCAB pccab, void *pv) { - HFCI rv; - - if ((!pfnalloc) || (!pfnfree)) { + HFCI hfci; + int err; + PFCI_Int p_fci_internal; + + if ((!perf) || (!pfnalloc) || (!pfnfree) || (!pfnopen) || (!pfnread) || + (!pfnwrite) || (!pfnclose) || (!pfnseek) || (!pfndelete) || + (!pfnfcigtf) || (!pccab)) { perf->erfOper = FCIERR_NONE; perf->erfType = ERROR_BAD_ARGUMENTS; perf->fError = TRUE; @@ -105,7 +171,7 @@ return NULL; } - if (!(rv = (HFCI) (*pfnalloc)(sizeof(FCI_Int)))) { + if (!((hfci = ((HFCI) (*pfnalloc)(sizeof(FCI_Int)))))) { perf->erfOper = FCIERR_ALLOC_FAIL; perf->erfType = ERROR_NOT_ENOUGH_MEMORY; perf->fError = TRUE; @@ -114,41 +180,1977 @@ return NULL; } - PFCI_INT(rv)->FCI_Intmagic = FCI_INT_MAGIC; - PFCI_INT(rv)->perf = perf; - PFCI_INT(rv)->pfnfiledest = pfnfiledest; - PFCI_INT(rv)->pfnalloc = pfnalloc; - PFCI_INT(rv)->pfnfree = pfnfree; - PFCI_INT(rv)->pfnopen = pfnopen; - PFCI_INT(rv)->pfnread = pfnread; - PFCI_INT(rv)->pfnwrite = pfnwrite; - PFCI_INT(rv)->pfnclose = pfnclose; - PFCI_INT(rv)->pfnseek = pfnseek; - PFCI_INT(rv)->pfndelete = pfndelete; - PFCI_INT(rv)->pfnfcigtf = pfnfcigtf; - PFCI_INT(rv)->pccab = pccab; - PFCI_INT(rv)->pv = pv; - - /* Still mark as incomplete, because of other missing FCI* APIs */ - - PFCI_INT(rv)->FCI_Intmagic = 0; - PFDI_FREE(rv, rv); - FIXME("(%p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p, %p): stub\n", - perf, pfnfiledest, pfnalloc, pfnfree, pfnopen, pfnread, pfnwrite, pfnclose, - pfnseek, pfndelete, pfnfcigtf, pccab, pv); - - perf->erfOper = FCIERR_NONE; - perf->erfType = 0; - perf->fError = TRUE; + p_fci_internal=((PFCI_Int)(hfci)); + p_fci_internal->FCI_Intmagic = FCI_INT_MAGIC; + p_fci_internal->perf = perf; + p_fci_internal->pfnfiledest = pfnfiledest; + p_fci_internal->pfnalloc = pfnalloc; + p_fci_internal->pfnfree = pfnfree; + p_fci_internal->pfnopen = pfnopen; + p_fci_internal->pfnread = pfnread; + p_fci_internal->pfnwrite = pfnwrite; + p_fci_internal->pfnclose = pfnclose; + p_fci_internal->pfnseek = pfnseek; + p_fci_internal->pfndelete = pfndelete; + p_fci_internal->pfnfcigtf = pfnfcigtf; + p_fci_internal->pccab = pccab; + p_fci_internal->fPrevCab = FALSE; + p_fci_internal->fNextCab = FALSE; + p_fci_internal->fSplitFolder = FALSE; + p_fci_internal->fGetNextCabInVain = FALSE; + p_fci_internal->pv = pv; + p_fci_internal->data_in = NULL; + p_fci_internal->cdata_in = 0; + p_fci_internal->data_out = NULL; + p_fci_internal->cCompressedBytesInFolder = 0; + p_fci_internal->cFolders = 0; + p_fci_internal->cFiles = 0; + p_fci_internal->cDataBlocks = 0; + p_fci_internal->sizeFileCFDATA1 = 0; + p_fci_internal->sizeFileCFFILE1 = 0; + p_fci_internal->sizeFileCFDATA2 = 0; + p_fci_internal->sizeFileCFFILE2 = 0; + p_fci_internal->sizeFileCFFOLDER = 0; + p_fci_internal->sizeFileCFFOLDER = 0; + p_fci_internal->fNewPrevious = FALSE; + + memcpy(p_fci_internal->szPrevCab, pccab->szCab, CB_MAX_CABINET_NAME); + memcpy(p_fci_internal->szPrevDisk, pccab->szDisk, CB_MAX_DISK_NAME); + + /* CFDATA */ + if( !PFCI_GETTEMPFILE(hfci,p_fci_internal->szFileNameCFDATA1, + CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFDATA1) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + + p_fci_internal->handleCFDATA1 = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFDATA1, 34050, 384, &err, pv); + /* TODO check handle */ + /* TODO error checking of err */ + + /* array of all CFFILE in a folder */ + if( !PFCI_GETTEMPFILE(hfci,p_fci_internal->szFileNameCFFILE1, + CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFFILE1) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + p_fci_internal->handleCFFILE1 = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFFILE1, 34050, 384, &err, pv); + /* TODO check handle */ + /* TODO error checking of err */ + + /* CFDATA with checksum and ready to be copied into cabinet */ + if( !PFCI_GETTEMPFILE(hfci,p_fci_internal->szFileNameCFDATA2, + CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFDATA2) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + p_fci_internal->handleCFDATA2 = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFDATA2, 34050, 384, &err, pv); + /* TODO check handle */ + /* TODO error checking of err */ + + /* array of all CFFILE in a folder, ready to be copied into cabinet */ + if( !PFCI_GETTEMPFILE(hfci,p_fci_internal->szFileNameCFFILE2, + CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFFILE2) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + p_fci_internal->handleCFFILE2 = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFFILE2, 34050, 384, &err, pv); + /* TODO check handle */ + /* TODO error checking of err */ + + /* array of all CFFILE in a folder, ready to be copied into cabinet */ + if( !PFCI_GETTEMPFILE(hfci,p_fci_internal->szFileNameCFFOLDER, + CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFFOLDER) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + p_fci_internal->handleCFFOLDER = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFFOLDER, 34050, 384, &err, pv); + + + /* TODO close and delete new files when return FALSE */ + + /* TODO check handle */ + /* TODO error checking of err */ + + return hfci; +} /* end of FCICreate */ + + + + + + +static BOOL fci_flush_data_block (HFCI hfci, int* err, + PFNFCISTATUS pfnfcis) { + + /* attention no hfci checks!!! */ + /* attention no checks if there is data available!!! */ + CFDATA data; + CFDATA* cfdata=&data; + char* reserved; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); + UINT cbReserveCFData=p_fci_internal->pccab->cbReserveCFData; + UINT i; + + /* TODO compress the data of p_fci_internal->data_in */ + /* and write it to p_fci_internal->data_out */ + memcpy(p_fci_internal->data_out, p_fci_internal->data_in, + p_fci_internal->cdata_in /* number of bytes to copy */); + + cfdata->csum=0; /* checksum has to be set later */ + /* TODO set realsize of compressed data */ + cfdata->cbData = p_fci_internal->cdata_in; + cfdata->cbUncomp = p_fci_internal->cdata_in; + + /* write cfdata to p_fci_internal->handleCFDATA1 */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA1, /* file handle */ + cfdata, sizeof(*cfdata), err, p_fci_internal->pv) + != sizeof(*cfdata) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFDATA1 += sizeof(*cfdata); + + /* add optional reserved area */ + + /* This allocation and freeing at each CFData block is a bit */ + /* inefficent, but it's harder to forget about freeing the buffer :-). */ + /* Reserved areas are used seldom besides that... */ + if (cbReserveCFData!=0) { + if(!(reserved = (char*)PFCI_ALLOC(hfci, cbReserveCFData))) { + p_fci_internal->perf->erfOper = FCIERR_ALLOC_FAIL; + p_fci_internal->perf->erfType = ERROR_NOT_ENOUGH_MEMORY; + p_fci_internal->perf->fError = TRUE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + for(i=0;ihandleCFDATA1, /* file handle */ + reserved, /* memory buffer */ + cbReserveCFData, /* number of bytes to copy */ + err, p_fci_internal->pv) != cbReserveCFData ) { + PFCI_FREE(hfci, reserved); + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err PFCI_FREE(hfci, reserved)*/ + + p_fci_internal->sizeFileCFDATA1 += cbReserveCFData; + PFCI_FREE(hfci, reserved); + } + + /* write p_fci_internal->data_out to p_fci_internal->handleCFDATA1 */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA1, /* file handle */ + p_fci_internal->data_out, /* memory buffer */ + cfdata->cbData, /* number of bytes to copy */ + err, p_fci_internal->pv) != cfdata->cbData) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFDATA1 += cfdata->cbData; + + /* reset the offset */ + p_fci_internal->cdata_in = 0; + p_fci_internal->cCompressedBytesInFolder += cfdata->cbData; + + /* report status with pfnfcis about uncompressed and compressed file data */ + if( (*pfnfcis)(statusFile, cfdata->cbData, cfdata->cbUncomp, + p_fci_internal->pv) == -1) { + /* TODO set error code and abort */ + return FALSE; + } + + ++(p_fci_internal->cDataBlocks); + + return TRUE; +} /* end of fci_flush_data_block */ + + + + + +static cab_ULONG fci_get_checksum(void *pv, UINT cb, CHECKSUM seed) +{ + cab_ULONG csum; + cab_ULONG ul; + int cUlong; + BYTE *pb; + + csum = seed; + cUlong = cb / 4; + pb = pv; + + while (cUlong-- > 0) { + ul = *pb++; + ul |= (((cab_ULONG)(*pb++)) << 8); + ul |= (((cab_ULONG)(*pb++)) << 16); + ul |= (((cab_ULONG)(*pb++)) << 24); + + csum ^= ul; + } + + ul = 0; + switch (cb % 4) { + case 3: + ul |= (((ULONG)(*pb++)) << 16); + case 2: + ul |= (((ULONG)(*pb++)) << 8); + case 1: + ul |= *pb++; + default: + break; + } + csum ^= ul; + + return csum; +} /* end of fci_get_checksum */ + + + + + +static BOOL fci_flushfolder_copy_cfdata(HFCI hfci, char* buffer, UINT cbReserveCFData, + PFNFCISTATUS pfnfcis, int* err, int handleCFDATA1new, + cab_ULONG* psizeFileCFDATA1new, cab_ULONG* payload) +{ + cab_ULONG read_result; + CFDATA* pcfdata=(CFDATA*)buffer; + BOOL split_block=FALSE; + cab_UWORD savedUncomp=0; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); + + *payload=0; + + /* while not all CFDATAs have been copied do */ + while(!FALSE) { + if( p_fci_internal->fNextCab ) { + if( split_block ) { + /* TODO internal error should never happen */ + return FALSE; + } + } + /* REUSE the variable read_result */ + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + read_result=4; + } else { + read_result=0; + } + if (p_fci_internal->fPrevCab) { + read_result+=strlen(p_fci_internal->szPrevCab)+1 + + strlen(p_fci_internal->szPrevDisk)+1; + } + /* No more CFDATA fits into the cabinet under construction */ + /* So don't try to store more data into it */ + if( p_fci_internal->fNextCab && + (p_fci_internal->oldCCAB.cb <= sizeof(CFDATA) + cbReserveCFData + + p_fci_internal->sizeFileCFFILE1 + p_fci_internal->sizeFileCFDATA2 + + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER + + sizeof(CFHEADER) + + read_result + + p_fci_internal->oldCCAB.cbReserveCFHeader + + sizeof(CFFOLDER) + + p_fci_internal->oldCCAB.cbReserveCFFolder + + strlen(p_fci_internal->pccab->szCab)+1 + + strlen(p_fci_internal->pccab->szDisk)+1 + )) { + /* This may never be run for the first time the while loop is entered. + Pray that the code that calls fci_flushfolder_copy_cfdata handles this.*/ + split_block=TRUE; /* In this case split_block is abused to store */ + /* the complete data block into the next cabinet and not into the */ + /* current one. Originally split_block is the indicator that a */ + /* data block has been splitted across different cabinets. */ + } else { + + /* read CFDATA from p_fci_internal->handleCFDATA1 to cfdata*/ + read_result= PFCI_READ(hfci, p_fci_internal->handleCFDATA1,/*file handle*/ + buffer, /* memory buffer */ + sizeof(CFDATA)+cbReserveCFData, /* number of bytes to copy */ + err, p_fci_internal->pv); + if (read_result!=sizeof(CFDATA)+cbReserveCFData) { + if (read_result==0) break; /* ALL DATA has been copied */ + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err */ + + /* REUSE buffer p_fci_internal->data_out !!! */ + /* read data from p_fci_internal->handleCFDATA1 to */ + /* p_fci_internal->data_out */ + if( PFCI_READ(hfci, p_fci_internal->handleCFDATA1 /* file handle */, + p_fci_internal->data_out /* memory buffer */, + pcfdata->cbData /* number of bytes to copy */, + err, p_fci_internal->pv) != pcfdata->cbData ) { + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err */ + + /* if cabinet size is too large */ + + /* REUSE the variable read_result */ + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + read_result=4; + } else { + read_result=0; + } + if (p_fci_internal->fPrevCab) { + read_result+=strlen(p_fci_internal->szPrevCab)+1 + + strlen(p_fci_internal->szPrevDisk)+1; + } + + /* Is cabinet with new CFDATA too large? Then data block has to be split */ + if( p_fci_internal->fNextCab && + (p_fci_internal->oldCCAB.cb < sizeof(CFDATA) + cbReserveCFData + + pcfdata->cbData + + p_fci_internal->sizeFileCFFILE1 + p_fci_internal->sizeFileCFDATA2 + + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER + + sizeof(CFHEADER) + + read_result + + p_fci_internal->oldCCAB.cbReserveCFHeader + + sizeof(CFFOLDER) + /* size of new CFFolder entry */ + p_fci_internal->oldCCAB.cbReserveCFFolder + + strlen(p_fci_internal->pccab->szCab)+1 + /* name of next cabinet */ + strlen(p_fci_internal->pccab->szDisk)+1 /* name of next disk */ + )) { + /* REUSE read_result to save the size of the compressed data */ + read_result=pcfdata->cbData; + /* Modify the size of the compressed data to store only a part of the */ + /* data block into the current cabinet. This is done to prevent */ + /* that the maximum cabinet size will be exceeded. The remainer */ + /* will be stored into the next following cabinet. */ + + /* The cabinet will be of size "p_fci_internal->oldCCAB.cb". */ + /* Substract everything except the size of the block of data */ + /* to get it's actual size */ + pcfdata->cbData = p_fci_internal->oldCCAB.cb - ( + sizeof(CFDATA) + cbReserveCFData + + p_fci_internal->sizeFileCFFILE1 + p_fci_internal->sizeFileCFDATA2 + + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER + + sizeof(CFHEADER) + + p_fci_internal->oldCCAB.cbReserveCFHeader + + sizeof(CFFOLDER) + /* set size of new CFFolder entry */ + p_fci_internal->oldCCAB.cbReserveCFFolder ); + /* substract the size of special header fields */ + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + pcfdata->cbData-=4; + } + if (p_fci_internal->fPrevCab) { + pcfdata->cbData-=strlen(p_fci_internal->szPrevCab)+1 + + strlen(p_fci_internal->szPrevDisk)+1; + } + pcfdata->cbData-=strlen(p_fci_internal->pccab->szCab)+1 + + strlen(p_fci_internal->pccab->szDisk)+1; + + savedUncomp = pcfdata->cbUncomp; + pcfdata->cbUncomp = 0; /* on splitted blocks of data this is zero */ + + /* if split_block==TRUE then the above while loop won't */ + /* be executed again */ + split_block=TRUE; /* split_block is the indicator that */ + /* a data block has been splitted across */ + /* diffentent cabinets.*/ + } + + /* This should never happen !!! */ + if (pcfdata->cbData==0) { + /* TODO set error */ + return FALSE; + } + + /* get checksum and write to cfdata.csum */ + pcfdata->csum = fci_get_checksum( &(pcfdata->cbData), + sizeof(CFDATA)+cbReserveCFData - + sizeof(pcfdata->csum), fci_get_checksum( p_fci_internal->data_out, /*buffer*/ + pcfdata->cbData, 0 ) ); + + /* write cfdata with checksum to p_fci_internal->handleCFDATA2 */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */ + buffer, /* memory buffer */ + sizeof(CFDATA)+cbReserveCFData, /* number of bytes to copy */ + err, p_fci_internal->pv) != sizeof(CFDATA)+cbReserveCFData ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFDATA2 += sizeof(CFDATA)+cbReserveCFData; + + /* write compressed data into p_fci_internal->handleCFDATA2 */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFDATA2, /* file handle */ + p_fci_internal->data_out, /* memory buffer */ + pcfdata->cbData, /* number of bytes to copy */ + err, p_fci_internal->pv) != pcfdata->cbData) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFDATA2 += pcfdata->cbData; + ++(p_fci_internal->cDataBlocks); + p_fci_internal->statusFolderCopied += pcfdata->cbData; + (*payload)+=pcfdata->cbUncomp; + /* if cabinet size too large and data has been split */ + /* write the remainer of the data block to the new CFDATA1 file */ + if( split_block ) { /* This does not include the */ + /* abused one (just search for "abused" )*/ + /* copy all CFDATA structures from handleCFDATA1 to handleCFDATA1new */ + if (p_fci_internal->fNextCab==FALSE ) { + /* TODO internal error */ + return FALSE; + } + + /* set cbData the size of the remainer of the data block */ + pcfdata->cbData = read_result - pcfdata->cbData; + /*recover former value of cfdata.cbData; read_result will be the offset*/ + read_result -= pcfdata->cbData; + pcfdata->cbUncomp = savedUncomp; + + /* reset checksum, it will be computed later */ + pcfdata->csum=0; + /* write cfdata WITHOUT checksum to handleCFDATA1new */ + if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */ + buffer, /* memory buffer */ + sizeof(CFDATA)+cbReserveCFData, /* number of bytes to copy */ + err, p_fci_internal->pv) != sizeof(CFDATA)+cbReserveCFData ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err dont forget PFCI_FREE(hfci, reserved) */ + + *psizeFileCFDATA1new += sizeof(CFDATA)+cbReserveCFData; + + /* write compressed data into handleCFDATA1new */ + if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */ + p_fci_internal->data_out + read_result, /* memory buffer + offset */ + /* to last part of split data */ + pcfdata->cbData, /* number of bytes to copy */ + err, p_fci_internal->pv) != pcfdata->cbData) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->statusFolderCopied += pcfdata->cbData; + + *psizeFileCFDATA1new += pcfdata->cbData; + /* the two blocks of the split data block have been written */ + /* dont reset split_data yet, because it is still needed see below */ + } + + /* report status with pfnfcis about copied size of folder */ + if( (*pfnfcis)(statusFolder, + p_fci_internal->statusFolderCopied, /*cfdata.cbData(+previous ones)*/ + p_fci_internal->statusFolderTotal, /* total folder size */ + p_fci_internal->pv) == -1) { + /* TODO set error code and abort */ + return FALSE; + } + } + + /* if cabinet size too large */ + /* write the remaining data blocks to the new CFDATA1 file */ + if ( split_block ) { /* This does include the */ + /* abused one (just search for "abused" )*/ + if (p_fci_internal->fNextCab==FALSE ) { + /* TODO internal error */ + return FALSE; + } + /* copy all CFDATA structures from handleCFDATA1 to handleCFDATA1new */ + while(!FALSE) { + /* read CFDATA from p_fci_internal->handleCFDATA1 to cfdata*/ + read_result= PFCI_READ(hfci, p_fci_internal->handleCFDATA1,/* handle */ + buffer, /* memory buffer */ + sizeof(CFDATA)+cbReserveCFData, /* number of bytes to copy */ + err, p_fci_internal->pv); + if (read_result!=sizeof(CFDATA)+cbReserveCFData) { + if (read_result==0) break; /* ALL DATA has been copied */ + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err */ + + /* REUSE buffer p_fci_internal->data_out !!! */ + /* read data from p_fci_internal->handleCFDATA1 to */ + /* p_fci_internal->data_out */ + if( PFCI_READ(hfci, p_fci_internal->handleCFDATA1 /* file handle */, + p_fci_internal->data_out /* memory buffer */, + pcfdata->cbData /* number of bytes to copy */, + err, p_fci_internal->pv) != pcfdata->cbData ) { + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err dont forget PFCI_FREE(hfci, reserved) */ + + /* write cfdata with checksum to handleCFDATA1new */ + if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */ + buffer, /* memory buffer */ + sizeof(CFDATA)+cbReserveCFData, /* number of bytes to copy */ + err, p_fci_internal->pv) != sizeof(CFDATA)+cbReserveCFData ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err dont forget PFCI_FREE(hfci, reserved) */ + + *psizeFileCFDATA1new += sizeof(CFDATA)+cbReserveCFData; + + /* write compressed data into handleCFDATA1new */ + if( PFCI_WRITE(hfci, handleCFDATA1new, /* file handle */ + p_fci_internal->data_out, /* memory buffer */ + pcfdata->cbData, /* number of bytes to copy */ + err, p_fci_internal->pv) != pcfdata->cbData) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + *psizeFileCFDATA1new += pcfdata->cbData; + p_fci_internal->statusFolderCopied += pcfdata->cbData; + + /* report status with pfnfcis about copied size of folder */ + if( (*pfnfcis)(statusFolder, + p_fci_internal->statusFolderCopied,/*cfdata.cbData(+revious ones)*/ + p_fci_internal->statusFolderTotal, /* total folder size */ + p_fci_internal->pv) == -1) { + /* TODO set error code and abort */ + return FALSE; + } + + } /* end of WHILE */ + break; /* jump out of the next while loop */ + } /* end of if( split_data ) */ + } /* end of WHILE */ + return TRUE; +} /* end of fci_flushfolder_copy_cfdata */ + + + + + +static BOOL fci_flushfolder_copy_cffolder(HFCI hfci, int* err, UINT cbReserveCFFolder, + cab_ULONG sizeFileCFDATA2old) +{ + CFFOLDER cffolder; + UINT i; + char* reserved; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); + + /* absolute offset cannot be set yet, because the size of cabinet header, */ + /* the number of CFFOLDERs and the number of CFFILEs may change. */ + /* Instead the size of all previous data blocks will be stored and */ + /* the remainer of the offset will be added when the cabinet will be */ + /* flushed to disk. */ + /* This is exactly the way the original CABINET.DLL works!!! */ + cffolder.coffCabStart=sizeFileCFDATA2old; + + /* set the number of this folder's CFDATA sections */ + cffolder.cCFData=p_fci_internal->cDataBlocks; + /* TODO set compression type */ + cffolder.typeCompress = tcompTYPE_NONE; + + /* write cffolder to p_fci_internal->handleCFFOLDER */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFFOLDER, /* file handle */ + &cffolder, /* memory buffer */ + sizeof(cffolder), /* number of bytes to copy */ + err, p_fci_internal->pv) != sizeof(cffolder) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFFOLDER += sizeof(cffolder); + + /* add optional reserved area */ + if (cbReserveCFFolder!=0) { + if(!(reserved = (char*)PFCI_ALLOC(hfci, cbReserveCFFolder))) { + p_fci_internal->perf->erfOper = FCIERR_ALLOC_FAIL; + p_fci_internal->perf->erfType = ERROR_NOT_ENOUGH_MEMORY; + p_fci_internal->perf->fError = TRUE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + for(i=0;ihandleCFFOLDER, /* file handle */ + reserved, /* memory buffer */ + cbReserveCFFolder, /* number of bytes to copy */ + err, p_fci_internal->pv) != cbReserveCFFolder ) { + PFCI_FREE(hfci, reserved); + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFFOLDER += cbReserveCFFolder; + + PFCI_FREE(hfci, reserved); + } + return TRUE; +} /* end of fci_flushfolder_copy_cffolder */ + + + + + +static BOOL fci_flushfolder_copy_cffile(HFCI hfci, int* err, int handleCFFILE1new, + cab_ULONG *psizeFileCFFILE1new, cab_ULONG payload) +{ + CFFILE cffile; + cab_ULONG read_result; + cab_ULONG seek=0; + cab_ULONG sizeOfFiles=0, sizeOfFilesPrev; + BOOL may_be_prev=TRUE; + cab_ULONG cbFileRemainer=0; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); + /* set seek of p_fci_internal->handleCFFILE1 to 0 */ + if( PFCI_SEEK(hfci,p_fci_internal->handleCFFILE1,0,SEEK_SET,err, + p_fci_internal->pv) !=0 ) { + /* TODO wrong return value */ + } + /* TODO error handling of err */ + + /* while not all CFFILE structures have been copied do */ + while(!FALSE) { + /* REUSE the variable read_result */ + /* read data from p_fci_internal->handleCFFILE1 to cffile */ + read_result = PFCI_READ(hfci,p_fci_internal->handleCFFILE1/* file handle */, + &cffile, /* memory buffer */ + sizeof(cffile), /* number of bytes to copy */ + err, p_fci_internal->pv); + if( read_result != sizeof(cffile) ) { + if( read_result == 0 ) break; /* ALL CFFILE structures have been copied */ + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err */ + + /* Microsoft's(R) CABINET.DLL would do a seek to the current! */ + /* position. I don't know why so I'll just omit it */ + + /* read the filename from p_fci_internal->handleCFFILE1 */ + /* REUSE the variable read_result AGAIN */ + /* REUSE the memory buffer PFCI(hfci)->data_out */ + if( PFCI_READ(hfci, p_fci_internal->handleCFFILE1 /*file handle*/, + p_fci_internal->data_out, /* memory buffer */ + CB_MAX_FILENAME, /* number of bytes to copy */ + err, p_fci_internal->pv) <2) { + /* TODO read error */ + return FALSE; + } + /* TODO maybe other checks of read_result */ + /* TODO error handling of err */ + + /* safety */ + if( strlen(p_fci_internal->data_out)>=CB_MAX_FILENAME ) { + /* TODO set error code internal error */ + return FALSE; + } + + seek+=sizeof(cffile) + strlen(p_fci_internal->data_out)+1; + + /* set seek of p_fci_internal->handleCFFILE1 to end of file name */ + /* i.e. seek to the next CFFILE area */ + if( PFCI_SEEK(hfci,p_fci_internal->handleCFFILE1, + seek, /* seek position*/ + SEEK_SET ,err, + p_fci_internal->pv) + != sizeof(cffile)+strlen(p_fci_internal->data_out)+1 ) { + /* TODO wrong return value */ + } + /* TODO error handling of err */ + + /* fnfilfnfildest: placed file on cabinet */ + if (p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain) { + PFCI_FILEPLACED( hfci, &(p_fci_internal->oldCCAB), + p_fci_internal->data_out, /* the file name*/ + cffile.cbFile, /* file size */ + (cffile.iFolder==cffileCONTINUED_FROM_PREV), + p_fci_internal->pv + ); + } else { + PFCI_FILEPLACED( hfci, p_fci_internal->pccab, + p_fci_internal->data_out, /* the file name*/ + cffile.cbFile, /* file size */ + (cffile.iFolder==cffileCONTINUED_FROM_PREV), + p_fci_internal->pv + ); + } + + /* Check special iFolder values */ + if( cffile.iFolder==cffileCONTINUED_FROM_PREV && + p_fci_internal->fPrevCab==FALSE ) { + /* THIS MAY NEVER HAPPEN */ + /* TODO set error code */ + return FALSE; + } + if( cffile.iFolder==cffileCONTINUED_PREV_AND_NEXT || + cffile.iFolder==cffileCONTINUED_TO_NEXT ) { + /* THIS MAY NEVER HAPPEN */ + /* TODO set error code */ + return FALSE; + } + if( may_be_prev && cffile.iFolder!=cffileCONTINUED_FROM_PREV ) { + may_be_prev=FALSE; + } + if( cffile.iFolder==cffileCONTINUED_FROM_PREV && may_be_prev==FALSE ) { + /* THIS MAY NEVER HAPPEN */ + /* TODO set error code */ + return FALSE; + } + if( cffile.iFolder!=cffileCONTINUED_FROM_PREV ) { + may_be_prev=FALSE; + } + + sizeOfFilesPrev=sizeOfFiles; + /* Set complete size of all processed files */ + if( cffile.iFolder==cffileCONTINUED_FROM_PREV && + p_fci_internal->cbFileRemainer!=0 + ) { + sizeOfFiles+=p_fci_internal->cbFileRemainer; + p_fci_internal->cbFileRemainer=0; + } else { + sizeOfFiles+=cffile.cbFile; + } + + /* Check if spanned file fits into this cabinet folder */ + if( cffile.iFolder==cffileCONTINUED_FROM_PREV && sizeOfFiles>payload ) { + cffile.iFolder=cffileCONTINUED_PREV_AND_NEXT; + } else + + /* Check if file doesn't fit into this cabinet folder */ + if( sizeOfFiles>payload ) { + cffile.iFolder=cffileCONTINUED_TO_NEXT; + } + + /* write cffile to p_fci_internal->handleCFFILE2 */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */ + &cffile, /* memory buffer */ + sizeof(cffile), /* number of bytes to copy */ + err, p_fci_internal->pv) != sizeof(cffile) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFFILE2 += sizeof(cffile); + + /* write file name to p_fci_internal->handleCFFILE2 */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE2, /* file handle */ + p_fci_internal->data_out, /* memory buffer */ + strlen(p_fci_internal->data_out)+1, /* number of bytes to copy */ + err, p_fci_internal->pv) != strlen(p_fci_internal->data_out)+1 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFFILE2 += strlen(p_fci_internal->data_out)+1; + + /* cFiles is used to count all files of a cabinet */ + ++(p_fci_internal->cFiles); + + /* This is only true for files which will be written into the */ + /* next cabinet of the spanning folder */ + if( sizeOfFiles>payload ) { + + /* Files which data will be partially written into the current cabinet */ + if( cffile.iFolder==cffileCONTINUED_PREV_AND_NEXT || + cffile.iFolder==cffileCONTINUED_TO_NEXT + ) { + if( sizeOfFilesPrev<=payload ) { + /* The size of the uncompressed, data of a spanning file in a */ + /* spanning data */ + cbFileRemainer=sizeOfFiles-payload; + } + cffile.iFolder=cffileCONTINUED_FROM_PREV; + } else { + cffile.iFolder=0; + } + + /* write cffile into handleCFFILE1new */ + if( PFCI_WRITE(hfci, handleCFFILE1new, /* file handle */ + &cffile, /* memory buffer */ + sizeof(cffile), /* number of bytes to copy */ + err, p_fci_internal->pv) != sizeof(cffile) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + *psizeFileCFFILE1new += sizeof(cffile); + /* write name of file into handleCFFILE1new */ + if( PFCI_WRITE(hfci, handleCFFILE1new, /* file handle */ + p_fci_internal->data_out, /* memory buffer */ + strlen(p_fci_internal->data_out)+1, /* number of bytes to copy */ + err, p_fci_internal->pv) != strlen(p_fci_internal->data_out)+1 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + *psizeFileCFFILE1new += strlen(p_fci_internal->data_out)+1; + } + + } /* END OF while */ + p_fci_internal->cbFileRemainer=cbFileRemainer; + return TRUE; +} /* end of fci_flushfolder_copy_cffile */ + + + + +static BOOL fci_flush_folder( + HFCI hfci, + BOOL fGetNextCab, + PFNFCIGETNEXTCABINET pfnfcignc, + PFNFCISTATUS pfnfcis) +{ + int err; + int handleCFDATA1new; /* handle for new temp file */ + char szFileNameCFDATA1new[CB_MAX_FILENAME]; /* name buffer for temp file */ + int handleCFFILE1new; /* handle for new temp file */ + char szFileNameCFFILE1new[CB_MAX_FILENAME]; /* name buffer for temp file */ + UINT cbReserveCFData, cbReserveCFFolder; + char* reserved; + cab_ULONG sizeFileCFDATA1new=0; + cab_ULONG sizeFileCFFILE1new=0; + cab_ULONG sizeFileCFDATA2old; + cab_ULONG payload; + cab_ULONG read_result; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); + + /* test hfci */ + if (!REALLY_IS_FCI(hfci)) { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if ((!pfnfcignc) || (!pfnfcis)) { + p_fci_internal->perf->erfOper = FCIERR_NONE; + p_fci_internal->perf->erfType = ERROR_BAD_ARGUMENTS; + p_fci_internal->perf->fError = TRUE; + + SetLastError(ERROR_BAD_ARGUMENTS); + return FALSE; + } + + if( p_fci_internal->fGetNextCabInVain && + p_fci_internal->fNextCab ){ + /* TODO internal error */ + return FALSE; + } + + /* If there was no FCIAddFile or FCIFlushFolder has already been called */ + /* this function will return TRUE */ + if( p_fci_internal->sizeFileCFFILE1 == 0 ) { + if ( p_fci_internal->sizeFileCFDATA1 != 0 ) { + /* TODO error handling */ + return FALSE; + } + return TRUE; + } + + if (p_fci_internal->data_in==NULL || p_fci_internal->data_out==NULL ) { + /* TODO error handling */ + return FALSE; + } + + /* FCIFlushFolder has already been called... */ + if (p_fci_internal->fSplitFolder && p_fci_internal->sizeFileCFFILE2!=0) { + if (p_fci_internal->sizeFileCFFILE2==0) { + /* TODO set error code */ + return FALSE; + } + return TRUE; + } + + /* TODO check what will happen when return FALSE later */ + /* and p_fci_internal->fSplitFolder is set to FALSE */ + p_fci_internal->fSplitFolder=FALSE; + + + if( p_fci_internal->fGetNextCabInVain || + p_fci_internal->fNextCab ){ + cbReserveCFData = p_fci_internal->oldCCAB.cbReserveCFData; + cbReserveCFFolder = p_fci_internal->oldCCAB.cbReserveCFFolder; + } else { + cbReserveCFData = p_fci_internal->pccab->cbReserveCFData; + cbReserveCFFolder = p_fci_internal->pccab->cbReserveCFFolder; + } + + /* START of COPY */ + /* if there is data in p_fci_internal->data_in */ + if (p_fci_internal->cdata_in!=0) { + + if( !fci_flush_data_block(hfci, &err, pfnfcis) ) return FALSE; + + } + /* reset to get the number of data blocks of this folder which are */ + /* actually in this cabinet ( at least partially ) */ + p_fci_internal->cDataBlocks=0; + + if ( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + read_result= p_fci_internal->oldCCAB.cbReserveCFHeader+ + p_fci_internal->oldCCAB.cbReserveCFFolder; + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + read_result+=4; + } + } else { + read_result= p_fci_internal->pccab->cbReserveCFHeader+ + p_fci_internal->pccab->cbReserveCFFolder; + if ( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + read_result+=4; + } + } + if (p_fci_internal->fPrevCab) { + read_result+=strlen(p_fci_internal->szPrevCab)+1 + + strlen(p_fci_internal->szPrevDisk)+1; + } + if (p_fci_internal->fNextCab) { + read_result+=strlen(p_fci_internal->pccab->szCab)+1 + + strlen(p_fci_internal->pccab->szDisk)+1; + } + + p_fci_internal->statusFolderTotal = sizeof(CFHEADER)+read_result+ + sizeof(CFFOLDER) + p_fci_internal->sizeFileCFFILE2+ + p_fci_internal->sizeFileCFDATA2 + p_fci_internal->sizeFileCFFILE1+ + p_fci_internal->sizeFileCFDATA1; + p_fci_internal->statusFolderCopied = 0; + + /* report status with pfnfcis about copied size of folder */ + if( (*pfnfcis)(statusFolder, p_fci_internal->statusFolderCopied, + p_fci_internal->statusFolderTotal, /* TODO total folder size */ + p_fci_internal->pv) == -1) { + /* TODO set error code and abort */ + return FALSE; + } + + /* get a new temp file */ + if(!PFCI_GETTEMPFILE(hfci,szFileNameCFDATA1new,CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(szFileNameCFDATA1new) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + handleCFDATA1new = PFCI_OPEN(hfci,szFileNameCFDATA1new,34050,384,&err, + p_fci_internal->pv); + + /* get a new temp file */ + if(!PFCI_GETTEMPFILE(hfci,szFileNameCFFILE1new,CB_MAX_FILENAME)) { + /* TODO error handling */ + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + return FALSE; + } + /* safety */ + if ( strlen(szFileNameCFFILE1new) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + return FALSE; + } + handleCFFILE1new = PFCI_OPEN(hfci,szFileNameCFFILE1new,34050,384,&err, + p_fci_internal->pv); + + /* USE the variable read_result */ + if ( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + read_result= p_fci_internal->oldCCAB.cbReserveCFHeader; + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + read_result+=4; + } + } else { + read_result= p_fci_internal->pccab->cbReserveCFHeader; + if ( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + read_result+=4; + } + } + if (p_fci_internal->fPrevCab) { + read_result+=strlen(p_fci_internal->szPrevCab)+1 + + strlen(p_fci_internal->szPrevDisk)+1; + } + read_result+= sizeof(CFHEADER) + p_fci_internal->sizeFileCFDATA2 + + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER; + + if(p_fci_internal->sizeFileCFFILE1!=0) { + read_result+= sizeof(CFFOLDER)+p_fci_internal->pccab->cbReserveCFFolder; + } + + /* Check if multiple cabinets have to be created. */ + + /* Might be too much data for the maximum allowed cabinet size.*/ + /* When any further data will be added later, it might not */ + /* be possible to flush the cabinet, because there might */ + /* not be enough space to store the name of the following */ + /* cabinet and name of the corresponding disk. */ + /* So take care of this and get the name of the next cabinet */ + if( p_fci_internal->fGetNextCabInVain==FALSE && + p_fci_internal->fNextCab==FALSE && + ( + ( + p_fci_internal->pccab->cb < read_result + + p_fci_internal->sizeFileCFDATA1 + + p_fci_internal->sizeFileCFFILE1 + + CB_MAX_CABINET_NAME + /* next cabinet name */ + CB_MAX_DISK_NAME /* next disk name */ + ) || fGetNextCab + ) + ) { + /* save CCAB */ + memcpy(&(p_fci_internal->oldCCAB), p_fci_internal->pccab, sizeof(CCAB)); + /* increment cabinet index */ + ++(p_fci_internal->pccab->iCab); + /* get name of next cabinet */ + if (!(*pfnfcignc)(p_fci_internal->pccab, 0, /* estimated size of cab */ + p_fci_internal->pv)) { + /* TODO error handling */ + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE(hfci,handleCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + return FALSE; + } + + /* Skip a few lines of code. This is catched by the next if. */ + p_fci_internal->fGetNextCabInVain=TRUE; + } + + /* too much data for cabinet */ + if( (p_fci_internal->fGetNextCabInVain || + p_fci_internal->fNextCab ) && + ( + ( + p_fci_internal->oldCCAB.cb < read_result + + p_fci_internal->sizeFileCFDATA1 + + p_fci_internal->sizeFileCFFILE1 + + strlen(p_fci_internal->pccab->szCab)+1 + /* next cabinet name */ + strlen(p_fci_internal->pccab->szDisk)+1 /* next disk name */ + ) || fGetNextCab + ) + ) { + p_fci_internal->fGetNextCabInVain=FALSE; + p_fci_internal->fNextCab=TRUE; + + /* return FALSE if there is not enough space left*/ + /* this should never happen */ + if (p_fci_internal->oldCCAB.cb <= + p_fci_internal->sizeFileCFFILE1 + + read_result + + strlen(p_fci_internal->pccab->szCab)+1 + /* next cabinet name */ + strlen(p_fci_internal->pccab->szDisk)+1 /* next disk name */ + ) { + + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,szFileNameCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + + /* close and delete p_fci_internal->handleCFFILE1 */ + PFCI_CLOSE(hfci,handleCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,szFileNameCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + + return FALSE; + } + + /* the folder will be split across cabinets */ + p_fci_internal->fSplitFolder=TRUE; + + } else { + /* this should never happen */ + if (p_fci_internal->fNextCab) { + /* TODO internal error */ + return FALSE; + } + } + + /* set seek of p_fci_internal->handleCFDATA1 to 0 */ + if( PFCI_SEEK(hfci,p_fci_internal->handleCFDATA1,0,SEEK_SET,&err, + p_fci_internal->pv) !=0 ) { + /* TODO wrong return value */ + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE(hfci,handleCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + return FALSE; + } + /* TODO error handling of err */ + + /* save size of file CFDATA2 - required for the folder's offset to data */ + sizeFileCFDATA2old = p_fci_internal->sizeFileCFDATA2; + + if(!(reserved = (char*)PFCI_ALLOC(hfci, cbReserveCFData+sizeof(CFDATA)))) { + p_fci_internal->perf->erfOper = FCIERR_ALLOC_FAIL; + p_fci_internal->perf->erfType = ERROR_NOT_ENOUGH_MEMORY; + p_fci_internal->perf->fError = TRUE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE(hfci,handleCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + return FALSE; + } + + if(!fci_flushfolder_copy_cfdata(hfci, reserved, cbReserveCFData, pfnfcis, &err, + handleCFDATA1new, &sizeFileCFDATA1new, &payload + )) { + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,szFileNameCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE(hfci,handleCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_FREE(hfci,reserved); + return FALSE; + } + + PFCI_FREE(hfci,reserved); + + if(!fci_flushfolder_copy_cffolder(hfci, &err, cbReserveCFFolder, + sizeFileCFDATA2old )) { + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,szFileNameCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE(hfci,handleCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + return FALSE; + } + + if(!fci_flushfolder_copy_cffile(hfci, &err, handleCFFILE1new, + &sizeFileCFFILE1new, payload)) { + PFCI_CLOSE(hfci,handleCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,szFileNameCFDATA1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE(hfci,handleCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,szFileNameCFFILE1new,&err,p_fci_internal->pv); + /* TODO error handling of err */ + return FALSE; + } + + /* close and delete p_fci_internal->handleCFDATA1 */ + PFCI_CLOSE(hfci,p_fci_internal->handleCFDATA1,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,p_fci_internal->szFileNameCFDATA1,&err,p_fci_internal->pv); + /* TODO error handling of err */ + + /* put new CFDATA1 into hfci */ + memcpy(p_fci_internal->szFileNameCFDATA1,szFileNameCFDATA1new, + CB_MAX_FILENAME); + + /* put CFDATA1 file handle */ + PFCI_INT(hfci)->handleCFDATA1 = handleCFDATA1new; + /* set file size */ + PFCI_INT(hfci)->sizeFileCFDATA1 = sizeFileCFDATA1new; + + /* close and delete PFCI_INT(hfci)->handleCFFILE1 */ + PFCI_CLOSE(hfci,p_fci_internal->handleCFFILE1,&err,PFCI_INT(hfci)->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci,p_fci_internal->szFileNameCFFILE1,&err,p_fci_internal->pv); + /* TODO error handling of err */ + + /* put new CFFILE1 into hfci */ + memcpy(p_fci_internal->szFileNameCFFILE1,szFileNameCFFILE1new, + CB_MAX_FILENAME); + + /* put CFFILE1 file handle */ + p_fci_internal->handleCFFILE1 = handleCFFILE1new; + /* set file size */ + p_fci_internal->sizeFileCFFILE1 = sizeFileCFFILE1new; + + ++(p_fci_internal->cFolders); + + /* reset CFFolder specific information */ + p_fci_internal->cDataBlocks=0; + p_fci_internal->cCompressedBytesInFolder=0; + + return TRUE; +} /* end of fci_flush_folder */ + + + + +static BOOL fci_flush_cabinet( + HFCI hfci, + BOOL fGetNextCab, + PFNFCIGETNEXTCABINET pfnfcignc, + PFNFCISTATUS pfnfcis) +{ + int err; + CFHEADER cfheader; + struct { + cab_UWORD cbCFHeader; + cab_UBYTE cbCFFolder; + cab_UBYTE cbCFData; + } cfreserved; + CFFOLDER cffolder; + cab_ULONG read_result; + int handleCABINET; /* file handle for cabinet */ + char pszFileNameCABINET[CB_MAX_CAB_PATH+CB_MAX_CABINET_NAME];/* name buffer */ + UINT cbReserveCFHeader, cbReserveCFFolder, i; + char* reserved; + BOOL returntrue=FALSE; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); + + /* TODO test if fci_flush_cabinet really aborts if there was no FCIAddFile */ + + /* when FCIFlushCabinet was or FCIAddFile wasn't called */ + if( p_fci_internal->sizeFileCFFILE1==0 && fGetNextCab ) { + returntrue=TRUE; + } + + if (!fci_flush_folder(hfci,fGetNextCab,pfnfcignc,pfnfcis)){ + /* TODO set error */ + return FALSE; + } + + if(returntrue) return TRUE; + + if (p_fci_internal->fSplitFolder && p_fci_internal->fNextCab==FALSE) { + /* TODO internal error */ + return FALSE; + } + + if( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + cbReserveCFFolder=p_fci_internal->oldCCAB.cbReserveCFFolder; + cbReserveCFHeader=p_fci_internal->oldCCAB.cbReserveCFHeader; + /* safety */ + if (strlen(p_fci_internal->oldCCAB.szCabPath)>=CB_MAX_CAB_PATH || + strlen(p_fci_internal->oldCCAB.szCab)>=CB_MAX_CABINET_NAME) { + /* TODO set error */ + return FALSE; + } + /* get the full name of the cabinet */ + memcpy(pszFileNameCABINET,p_fci_internal->oldCCAB.szCabPath, + CB_MAX_CAB_PATH); + memcpy(pszFileNameCABINET+strlen(pszFileNameCABINET), + p_fci_internal->oldCCAB.szCab, CB_MAX_CABINET_NAME); + } else { + cbReserveCFFolder=p_fci_internal->pccab->cbReserveCFFolder; + cbReserveCFHeader=p_fci_internal->pccab->cbReserveCFHeader; + /* safety */ + if (strlen(p_fci_internal->pccab->szCabPath)>=CB_MAX_CAB_PATH || + strlen(p_fci_internal->pccab->szCab)>=CB_MAX_CABINET_NAME) { + /* TODO set error */ + return FALSE; + } + /* get the full name of the cabinet */ + memcpy(pszFileNameCABINET,p_fci_internal->pccab->szCabPath, + CB_MAX_CAB_PATH); + memcpy(pszFileNameCABINET+strlen(pszFileNameCABINET), + p_fci_internal->pccab->szCab, CB_MAX_CABINET_NAME); + } + + /* create the cabinet */ + handleCABINET = PFCI_OPEN(hfci, pszFileNameCABINET, + 33538, 384, &err, p_fci_internal->pv ); + /* TODO check handle */ + /* TODO error checking of err */ + + memcpy(cfheader.signature,"!CAB",4); + cfheader.reserved1=0; + cfheader.cbCabinet= /* size of the cabinet file in bytes */ + sizeof(CFHEADER) + + p_fci_internal->sizeFileCFFOLDER + + p_fci_internal->sizeFileCFFILE2 + + p_fci_internal->sizeFileCFDATA2; + + if (p_fci_internal->fPrevCab) { + cfheader.cbCabinet+=strlen(p_fci_internal->szPrevCab)+1 + + strlen(p_fci_internal->szPrevDisk)+1; + } + if (p_fci_internal->fNextCab) { + cfheader.cbCabinet+=strlen(p_fci_internal->pccab->szCab)+1 + + strlen(p_fci_internal->pccab->szDisk)+1; + } + if( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + cfheader.cbCabinet+=p_fci_internal->oldCCAB.cbReserveCFHeader; + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + cfheader.cbCabinet+=4; + } + } else { + cfheader.cbCabinet+=p_fci_internal->pccab->cbReserveCFHeader; + if ( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + cfheader.cbCabinet+=4; + } + } + + cfheader.reserved2=0; + cfheader.coffFiles= /* offset to first CFFILE section */ + cfheader.cbCabinet - p_fci_internal->sizeFileCFFILE2 - + p_fci_internal->sizeFileCFDATA2; + + cfheader.reserved3=0; + cfheader.versionMinor=3; + cfheader.versionMajor=1; + /* number of CFFOLDER entries in the cabinet */ + cfheader.cFolders=p_fci_internal->cFolders; + /* number of CFFILE entries in the cabinet */ + cfheader.cFiles=p_fci_internal->cFiles; + cfheader.flags=0; /* 1=prev cab, 2=next cabinet, 4=reserved setions */ + + if( p_fci_internal->fPrevCab ) { + cfheader.flags = cfheadPREV_CABINET; + } + + if( p_fci_internal->fNextCab ) { + cfheader.flags |= cfheadNEXT_CABINET; + } + + if( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + if( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + cfheader.flags |= cfheadRESERVE_PRESENT; + } + cfheader.setID = p_fci_internal->oldCCAB.setID; + cfheader.iCabinet = p_fci_internal->oldCCAB.iCab-1; + } else { + if( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + cfheader.flags |= cfheadRESERVE_PRESENT; + } + cfheader.setID = p_fci_internal->pccab->setID; + cfheader.iCabinet = p_fci_internal->pccab->iCab-1; + } + + /* write CFHEADER into cabinet file */ + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + &cfheader, /* memory buffer */ + sizeof(cfheader), /* number of bytes to copy */ + &err, p_fci_internal->pv) != sizeof(cfheader) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + if( cfheader.flags & cfheadRESERVE_PRESENT ) { + /* NOTE: No checks for maximum value overflows as designed by MS!!! */ + cfreserved.cbCFHeader = cbReserveCFHeader; + cfreserved.cbCFFolder = cbReserveCFFolder; + if( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + cfreserved.cbCFData = p_fci_internal->oldCCAB.cbReserveCFData; + } else { + cfreserved.cbCFData = p_fci_internal->pccab->cbReserveCFData; + } + /* write reserved info into cabinet file */ + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + &cfreserved, /* memory buffer */ + sizeof(cfreserved), /* number of bytes to copy */ + &err, p_fci_internal->pv) != sizeof(cfreserved) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + } + + /* add optional reserved area */ + if (cbReserveCFHeader!=0) { + if(!(reserved = (char*)PFCI_ALLOC(hfci, cbReserveCFHeader))) { + p_fci_internal->perf->erfOper = FCIERR_ALLOC_FAIL; + p_fci_internal->perf->erfType = ERROR_NOT_ENOUGH_MEMORY; + p_fci_internal->perf->fError = TRUE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + for(i=0;ipv) != cbReserveCFHeader ) { + PFCI_FREE(hfci, reserved); + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + PFCI_FREE(hfci, reserved); + } + + if( cfheader.flags & cfheadPREV_CABINET ) { + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + p_fci_internal->szPrevCab, /* memory buffer */ + strlen(p_fci_internal->szPrevCab)+1, /* number of bytes to copy */ + &err, p_fci_internal->pv) != strlen(p_fci_internal->szPrevCab)+1 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + p_fci_internal->szPrevDisk, /* memory buffer */ + strlen(p_fci_internal->szPrevDisk)+1, /* number of bytes to copy */ + &err, p_fci_internal->pv) != strlen(p_fci_internal->szPrevDisk)+1 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + } + + if( cfheader.flags & cfheadNEXT_CABINET ) { + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + p_fci_internal->pccab->szCab, /* memory buffer */ + strlen(p_fci_internal->pccab->szCab)+1, /* number of bytes to copy */ + &err, p_fci_internal->pv) != strlen(p_fci_internal->pccab->szCab)+1 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + p_fci_internal->pccab->szDisk, /* memory buffer */ + strlen(p_fci_internal->pccab->szDisk)+1, /* number of bytes to copy */ + &err, p_fci_internal->pv) != strlen(p_fci_internal->pccab->szDisk)+1 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + } + + /* set seek of p_fci_internal->handleCFFOLDER to 0 */ + if( PFCI_SEEK(hfci,p_fci_internal->handleCFFOLDER, + 0, SEEK_SET, &err, p_fci_internal->pv) != 0 ) { + /* TODO wrong return value */ + } + /* TODO error handling of err */ + + /* while not all CFFOLDER structures have been copied into the cabinet do */ + while(!FALSE) { + /* use the variable read_result */ + /* read cffolder of p_fci_internal->handleCFFOLDER */ + read_result = PFCI_READ(hfci, p_fci_internal->handleCFFOLDER, /* handle */ + &cffolder, /* memory buffer */ + sizeof(cffolder), /* number of bytes to copy */ + &err, p_fci_internal->pv); + if( read_result != sizeof(cffolder) ) { + if( read_result == 0 ) break; /*ALL CFFOLDER structures have been copied*/ + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err */ + + /* add size of header size of all CFFOLDERs and size of all CFFILEs */ + cffolder.coffCabStart += + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER + + sizeof(CFHEADER); + if( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + cffolder.coffCabStart+=p_fci_internal->oldCCAB.cbReserveCFHeader; + } else { + cffolder.coffCabStart+=p_fci_internal->pccab->cbReserveCFHeader; + } + + if (p_fci_internal->fPrevCab) { + cffolder.coffCabStart += strlen(p_fci_internal->szPrevCab)+1 + + strlen(p_fci_internal->szPrevDisk)+1; + } + + if (p_fci_internal->fNextCab) { + cffolder.coffCabStart += strlen(p_fci_internal->oldCCAB.szCab)+1 + + strlen(p_fci_internal->oldCCAB.szDisk)+1; + } + + if( p_fci_internal->fNextCab || + p_fci_internal->fGetNextCabInVain ) { + cffolder.coffCabStart += p_fci_internal->oldCCAB.cbReserveCFHeader; + if( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + cffolder.coffCabStart += 4; + } + } else { + cffolder.coffCabStart += p_fci_internal->pccab->cbReserveCFHeader; + if( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + cffolder.coffCabStart += 4; + } + } + + /* write cffolder to cabinet file */ + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + &cffolder, /* memory buffer */ + sizeof(cffolder), /* number of bytes to copy */ + &err, p_fci_internal->pv) != sizeof(cffolder) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + /* add optional reserved area */ + + /* This allocation and freeing at each CFFolder block is a bit */ + /* inefficent, but it's harder to forget about freeing the buffer :-). */ + /* Reserved areas are used seldom besides that... */ + if (cbReserveCFFolder!=0) { + if(!(reserved = PFCI_ALLOC(hfci, cbReserveCFFolder))) { + p_fci_internal->perf->erfOper = FCIERR_ALLOC_FAIL; + p_fci_internal->perf->erfType = ERROR_NOT_ENOUGH_MEMORY; + p_fci_internal->perf->fError = TRUE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + if( PFCI_READ(hfci, p_fci_internal->handleCFFOLDER, /* file handle */ + reserved, /* memory buffer */ + cbReserveCFFolder, /* number of bytes to copy */ + &err, p_fci_internal->pv) != cbReserveCFFolder ) { + PFCI_FREE(hfci, reserved); + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err */ + + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + reserved, /* memory buffer */ + cbReserveCFFolder, /* number of bytes to copy */ + &err, p_fci_internal->pv) != cbReserveCFFolder ) { + PFCI_FREE(hfci, reserved); + /* TODO read error */ + return FALSE; + } + /* TODO error handling of err */ + + PFCI_FREE(hfci, reserved); + } + + } /* END OF while */ + + /* set seek of p_fci_internal->handleCFFILE2 to 0 */ + if( PFCI_SEEK(hfci,p_fci_internal->handleCFFILE2, + 0, SEEK_SET, &err, p_fci_internal->pv) != 0 ) { + /* TODO wrong return value */ + } + /* TODO error handling of err */ + + /* while not all CFFILE structures have been copied to the cabinet do */ + while(!FALSE) { + /* REUSE the variable read_result */ + /* REUSE the buffer p_fci_internal->data_out AGAIN */ + /* read a block from p_fci_internal->handleCFFILE2 */ + read_result = PFCI_READ(hfci, p_fci_internal->handleCFFILE2 /* handle */, + p_fci_internal->data_out, /* memory buffer */ + 32768, /* number of bytes to copy */ + &err, p_fci_internal->pv); + if( read_result == 0 ) break; /* ALL CFFILE structures have been copied */ + /* TODO error handling of err */ + + /* write the block to the cabinet file */ + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + p_fci_internal->data_out, /* memory buffer */ + read_result, /* number of bytes to copy */ + &err, p_fci_internal->pv) != read_result ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + if (p_fci_internal->fSplitFolder==FALSE) { + p_fci_internal->statusFolderCopied = 0; + p_fci_internal->statusFolderTotal = p_fci_internal->sizeFileCFDATA2+ + p_fci_internal->sizeFileCFFILE2; + } + p_fci_internal->statusFolderCopied += read_result; + +/* TODO is this correct */ + /* report status with pfnfcis about copied size of folder */ + if( (*pfnfcis)(statusFolder, + p_fci_internal->statusFolderCopied, /* length of copied blocks */ + p_fci_internal->statusFolderTotal, /* total size of folder */ + p_fci_internal->pv) == -1) { + /* TODO set error code and abort */ + return FALSE; + } + + } /* END OF while */ + + /* set seek of p_fci_internal->handleCFDATA2 to 0 */ + if( PFCI_SEEK(hfci,p_fci_internal->handleCFDATA2, + 0, SEEK_SET, &err, p_fci_internal->pv) != 0 ) { + /* TODO wrong return value */ + return FALSE; + } + /* TODO error handling of err */ + + /* reset the number of folders for the next cabinet */ + p_fci_internal->cFolders=0; + /* reset the number of files for the next cabinet */ + p_fci_internal->cFiles=0; + + /* while not all CFDATA structures have been copied to the cabinet do */ + while(!FALSE) { + /* REUSE the variable read_result AGAIN */ + /* REUSE the buffer p_fci_internal->data_out AGAIN */ + /* read a block from p_fci_internal->handleCFDATA2 */ + read_result = PFCI_READ(hfci, p_fci_internal->handleCFDATA2 /* handle */, + p_fci_internal->data_out, /* memory buffer */ + 32768, /* number of bytes to copy */ + &err, p_fci_internal->pv); + if( read_result == 0 ) break; /* ALL CFDATA structures have been copied */ + /* TODO error handling of err */ + + /* write the block to the cabinet file */ + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + p_fci_internal->data_out, /* memory buffer */ + read_result, /* number of bytes to copy */ + &err, p_fci_internal->pv) != read_result ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->statusFolderCopied += read_result; + /* report status with pfnfcis about copied size of folder */ + if( (*pfnfcis)(statusFolder, + p_fci_internal->statusFolderCopied, /* length of copied blocks */ + p_fci_internal->statusFolderTotal, /* total size of folder */ + p_fci_internal->pv) == -1) { + /* TODO set error code and abort */ + return FALSE; + } + } /* END OF while */ + + /* set seek of the cabinet file to 0 */ + if( PFCI_SEEK(hfci, handleCABINET, + 0, SEEK_SET, &err, p_fci_internal->pv) != 0 ) { + /* TODO wrong return value */ + } + /* TODO error handling of err */ + + /* write the signature "MSCF" into the cabinet file */ + memcpy( cfheader.signature, "MSCF", 4 ); + if( PFCI_WRITE(hfci, handleCABINET, /* file handle */ + &cfheader, /* memory buffer */ + 4, /* number of bytes to copy */ + &err, p_fci_internal->pv) != 4 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + /* close the cabinet file */ + PFCI_CLOSE(hfci,handleCABINET,&err,p_fci_internal->pv); + /* TODO error handling of err */ + + +/* COPIED FROM FCIDestroy */ + + PFCI_CLOSE (hfci, p_fci_internal->handleCFDATA2,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFDATA2, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE (hfci, p_fci_internal->handleCFFILE2,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFFILE2, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE (hfci, p_fci_internal->handleCFFOLDER,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFFOLDER, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + +/* END OF copied from FCIDestroy */ + + /* get 3 temporary files and open them */ + /* write names and handles to hfci */ + + + p_fci_internal->sizeFileCFDATA2 = 0; + p_fci_internal->sizeFileCFFILE2 = 0; + p_fci_internal->sizeFileCFFOLDER = 0; + +/* COPIED FROM FCICreate */ + + /* CFDATA with checksum and ready to be copied into cabinet */ + if( !PFCI_GETTEMPFILE(hfci, p_fci_internal->szFileNameCFDATA2, + CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFDATA2) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + p_fci_internal->handleCFDATA2 = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFDATA2, 34050, 384, &err, p_fci_internal->pv); + /* TODO check handle */ + /* TODO error checking of err */ + + /* array of all CFFILE in a folder, ready to be copied into cabinet */ + if( !PFCI_GETTEMPFILE(hfci,p_fci_internal->szFileNameCFFILE2, + CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFFILE2) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + p_fci_internal->handleCFFILE2 = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFFILE2, 34050, 384, &err, p_fci_internal->pv); + /* TODO check handle */ + /* TODO error checking of err */ + + /* array of all CFFILE in a folder, ready to be copied into cabinet */ + if (!PFCI_GETTEMPFILE(hfci,p_fci_internal->szFileNameCFFOLDER,CB_MAX_FILENAME)) { + /* TODO error handling */ + return FALSE; + } + /* safety */ + if ( strlen(p_fci_internal->szFileNameCFFOLDER) >= CB_MAX_FILENAME ) { + /* TODO set error code */ + return FALSE; + } + p_fci_internal->handleCFFOLDER = PFCI_OPEN(hfci, + p_fci_internal->szFileNameCFFOLDER, 34050, 384, &err, p_fci_internal->pv); + /* TODO check handle */ + /* TODO error checking of err */ + +/* END OF copied from FCICreate */ + + + /* TODO close and delete new files when return FALSE */ + + + /* report status with pfnfcis about copied size of folder */ + if( (*pfnfcis)(statusCabinet, p_fci_internal->statusFolderTotal, /* TODO estimated cabinet file size */ + cfheader.cbCabinet, /* real cabinet file size */ p_fci_internal->pv) == -1) { + /* TODO set error code and abort */ + return FALSE; + } + + p_fci_internal->fPrevCab=TRUE; + /* The sections szPrevCab and szPrevDisk are not being updated, because */ + /* MS CABINET.DLL always puts the first cabinet name and disk into them */ + + if (p_fci_internal->fNextCab) { + p_fci_internal->fNextCab=FALSE; + + if (p_fci_internal->sizeFileCFFILE1==0 && p_fci_internal->sizeFileCFDATA1!=0) { + /* THIS CAN NEVER HAPPEN */ + /* TODO set error code */ + return FALSE; + } + +/* COPIED FROM FCIAddFile and modified */ + + /* REUSE the variable read_result */ + if (p_fci_internal->fGetNextCabInVain) { + read_result=p_fci_internal->oldCCAB.cbReserveCFHeader; + if(p_fci_internal->sizeFileCFFILE1!=0) { + read_result+=p_fci_internal->oldCCAB.cbReserveCFFolder; + } + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + read_result+=4; + } + } else { + read_result=p_fci_internal->pccab->cbReserveCFHeader; + if(p_fci_internal->sizeFileCFFILE1!=0) { + read_result+=p_fci_internal->pccab->cbReserveCFFolder; + } + if ( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + read_result+=4; + } + } + if ( p_fci_internal->fPrevCab ) { + read_result+= strlen(p_fci_internal->szPrevCab)+1+ + strlen(p_fci_internal->szPrevDisk)+1; + } + read_result+= p_fci_internal->sizeFileCFDATA1 + + p_fci_internal->sizeFileCFFILE1 + p_fci_internal->sizeFileCFDATA2 + + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER + + sizeof(CFHEADER) + + sizeof(CFFOLDER); /* set size of new CFFolder entry */ + + if( p_fci_internal->fNewPrevious ) { + memcpy(p_fci_internal->szPrevCab, p_fci_internal->oldCCAB.szCab, + CB_MAX_CABINET_NAME); + memcpy(p_fci_internal->szPrevDisk, p_fci_internal->oldCCAB.szDisk, + CB_MAX_DISK_NAME); + p_fci_internal->fNewPrevious=FALSE; + } + + /* too much data for the maximum size of a cabinet */ + if( p_fci_internal->fGetNextCabInVain==FALSE && + p_fci_internal->pccab->cb < read_result ) { + return fci_flush_cabinet( hfci, FALSE, pfnfcignc, pfnfcis); + } + + /* Might be too much data for the maximum size of a cabinet.*/ + /* When any further data will be added later, it might not */ + /* be possible to flush the cabinet, because there might */ + /* not be enough space to store the name of the following */ + /* cabinet and name of the corresponding disk. */ + /* So take care of this and get the name of the next cabinet */ + if (p_fci_internal->fGetNextCabInVain==FALSE && ( + p_fci_internal->pccab->cb < read_result + + CB_MAX_CABINET_NAME + CB_MAX_DISK_NAME + )) { + /* save CCAB */ + memcpy(&(p_fci_internal->oldCCAB), p_fci_internal->pccab, sizeof(CCAB)); + /* increment cabinet index */ + ++(p_fci_internal->pccab->iCab); + /* get name of next cabinet */ + if (!(*pfnfcignc)(p_fci_internal->pccab, 0, /* estimated size of cab */ + p_fci_internal->pv)) { + /* TODO error handling */ + return FALSE; + } + /* Skip a few lines of code. This is catched by the next if. */ + p_fci_internal->fGetNextCabInVain=TRUE; + } + + /* too much data for cabinet */ + if (p_fci_internal->fGetNextCabInVain && ( + p_fci_internal->oldCCAB.cb < read_result + + strlen(p_fci_internal->oldCCAB.szCab)+1+ + strlen(p_fci_internal->oldCCAB.szDisk)+1 + )) { + p_fci_internal->fGetNextCabInVain=FALSE; + p_fci_internal->fNextCab=TRUE; + return fci_flush_cabinet( hfci, FALSE, pfnfcignc, pfnfcis); + } + + /* if the FolderThreshold has been reached flush the folder automatically */ + if( p_fci_internal->fGetNextCabInVain ) { + if( p_fci_internal->cCompressedBytesInFolder >= + p_fci_internal->oldCCAB.cbFolderThresh) { + return FCIFlushFolder(hfci, pfnfcignc, pfnfcis); + } + } else { + if( p_fci_internal->cCompressedBytesInFolder >= + p_fci_internal->pccab->cbFolderThresh) { + return FCIFlushFolder(hfci, pfnfcignc, pfnfcis); + } + } + +/* END OF COPIED FROM FCIAddFile and modified */ + + if( p_fci_internal->sizeFileCFFILE1>0 ) { + if( !FCIFlushFolder(hfci, pfnfcignc, pfnfcis) ) return FALSE; + p_fci_internal->fNewPrevious=TRUE; + } + } else { + p_fci_internal->fNewPrevious=FALSE; + if( p_fci_internal->sizeFileCFFILE1>0 || p_fci_internal->sizeFileCFDATA1) { + /* THIS MAY NEVER HAPPEN */ + /* TODO set error structures */ + return FALSE; + } + } + + return TRUE; +} /* end of fci_flush_cabinet */ + - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NULL; -} /*********************************************************************** * FCIAddFile (CABINET.11) + * + * FCIAddFile adds a file to the to be created cabinet file + * + * PARAMS + * hfci [I] An HFCI from FCICreate + * pszSourceFile [I] A pointer to a C string which contains the name and + * location of the file which will be added to the cabinet + * pszFileName [I] A pointer to a C string which contains the name under + * which the file will be stored in the cabinet + * fExecute [I] A boolean value which indicates if the file should be + * executed after extraction of self extracting + * executables + * pfnfcignc [I] A pointer to a function which gets information about + * the next cabinet + * pfnfcis [IO] A pointer to a function which will report status + * information about the compression process + * pfnfcioi [I] A pointer to a function which reports file attributes + * and time and date information + * typeCompress [I] Compression type + * + * RETURNS + * On success, returns TRUE + * On failure, returns FALSE + * + * INCLUDES + * fci.h + * */ BOOL __cdecl FCIAddFile( HFCI hfci, @@ -160,44 +2162,441 @@ PFNFCIGETOPENINFO pfnfcigoi, TCOMP typeCompress) { - FIXME("(%p, %p, %p, %d, %p, %p, %p, %hu): stub\n", hfci, pszSourceFile, - pszFileName, fExecute, pfnfcignc, pfnfcis, pfnfcigoi, typeCompress); + int err; + CFFILE cffile; + cab_ULONG read_result; + int file_handle; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); + + /* test hfci */ + if (!REALLY_IS_FCI(hfci)) { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if ((!pszSourceFile) || (!pszFileName) || (!pfnfcignc) || (!pfnfcis) || + (!pfnfcigoi) || strlen(pszFileName)>=CB_MAX_FILENAME) { + p_fci_internal->perf->erfOper = FCIERR_NONE; + p_fci_internal->perf->erfType = ERROR_BAD_ARGUMENTS; + p_fci_internal->perf->fError = TRUE; + + SetLastError(ERROR_BAD_ARGUMENTS); + return FALSE; + } + + /* TODO check if pszSourceFile??? */ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + if(p_fci_internal->fGetNextCabInVain && p_fci_internal->fNextCab) { + /* TODO internal error */ + return FALSE; + } + + if(p_fci_internal->fNextCab) { + /* TODO internal error */ + return FALSE; + } + + cffile.cbFile=0; /* size of the to be added file*/ + /* offset of the uncompressed file in the folder */ + cffile.uoffFolderStart=p_fci_internal->cDataBlocks*CAB_BLOCKMAX + p_fci_internal->cdata_in; + /* number of folder in the cabinet or special 0=first */ + cffile.iFolder = p_fci_internal->cFolders; + + /* allocation of memory */ + if (p_fci_internal->data_in==NULL) { + if (p_fci_internal->cdata_in!=0) { + /* TODO error handling */ + return FALSE; + } + if (p_fci_internal->data_out!=NULL) { + /* TODO error handling */ + return FALSE; + } + if(!(p_fci_internal->data_in = (char*)PFCI_ALLOC(hfci,CB_MAX_CHUNK))) { + p_fci_internal->perf->erfOper = FCIERR_ALLOC_FAIL; + p_fci_internal->perf->erfType = ERROR_NOT_ENOUGH_MEMORY; + p_fci_internal->perf->fError = TRUE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + if (p_fci_internal->data_out==NULL) { + if(!(p_fci_internal->data_out = PFCI_ALLOC(hfci, 2 * CB_MAX_CHUNK))){ + p_fci_internal->perf->erfOper = FCIERR_ALLOC_FAIL; + p_fci_internal->perf->erfType = ERROR_NOT_ENOUGH_MEMORY; + p_fci_internal->perf->fError = TRUE; + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + } + } + + if (p_fci_internal->data_out==NULL) { + PFCI_FREE(hfci,p_fci_internal->data_in); + /* TODO error handling */ + return FALSE; + } + + /* get information about the file */ + file_handle=(*pfnfcigoi)(pszSourceFile, &(cffile.date), &(cffile.time), + &(cffile.attribs), &err, p_fci_internal->pv); + /* TODO check file_handle */ + /* TODO error handling of err */ + + if (fExecute) { cffile.attribs |= _A_EXEC; } + + /* REUSE the variable read_result */ + if (p_fci_internal->fGetNextCabInVain) { + read_result=p_fci_internal->oldCCAB.cbReserveCFHeader + + p_fci_internal->oldCCAB.cbReserveCFFolder; + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + read_result+=4; + } + } else { + read_result=p_fci_internal->pccab->cbReserveCFHeader + + p_fci_internal->pccab->cbReserveCFFolder; + if ( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + read_result+=4; + } + } + if ( p_fci_internal->fPrevCab ) { + read_result+= strlen(p_fci_internal->szPrevCab)+1+ + strlen(p_fci_internal->szPrevDisk)+1; + } + if ( p_fci_internal->fNextCab ) { /* this is never the case */ + read_result+= strlen(p_fci_internal->pccab->szCab)+1+ + strlen(p_fci_internal->pccab->szDisk)+1; + } + + read_result+= sizeof(CFFILE) + strlen(pszFileName)+1 + + p_fci_internal->sizeFileCFFILE1 + p_fci_internal->sizeFileCFDATA2 + + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER + + sizeof(CFHEADER) + + sizeof(CFFOLDER); /* size of new CFFolder entry */ + + /* Might be too much data for the maximum size of a cabinet.*/ + /* When any further data will be added later, it might not */ + /* be possible to flush the cabinet, because there might */ + /* not be enough space to store the name of the following */ + /* cabinet and name of the corresponding disk. */ + /* So take care of this and get the name of the next cabinet */ + if( p_fci_internal->fGetNextCabInVain==FALSE && + p_fci_internal->fNextCab==FALSE && + ( p_fci_internal->pccab->cb < read_result + + CB_MAX_CABINET_NAME + CB_MAX_DISK_NAME + ) + ) { + /* save CCAB */ + memcpy(&(p_fci_internal->oldCCAB), p_fci_internal->pccab, sizeof(CCAB)); + /* increment cabinet index */ + ++(p_fci_internal->pccab->iCab); + /* get name of next cabinet */ + if (!(*pfnfcignc)(p_fci_internal->pccab, 0,/* TODO estimated size of cab */ + p_fci_internal->pv)) { + /* TODO error handling */ + return FALSE; + } + /* Skip a few lines of code. This is catched by the next if. */ + p_fci_internal->fGetNextCabInVain=TRUE; + } + + if( p_fci_internal->fGetNextCabInVain && + p_fci_internal->fNextCab + ) { + /* THIS CAN NEVER HAPPEN */ + /* TODO set error code*/ + return FALSE; + } + + /* too much data for cabinet */ + if( p_fci_internal->fGetNextCabInVain && + ( + p_fci_internal->oldCCAB.cb < read_result + + strlen(p_fci_internal->pccab->szCab)+1+ + strlen(p_fci_internal->pccab->szDisk)+1 + )) { + p_fci_internal->fGetNextCabInVain=FALSE; + p_fci_internal->fNextCab=TRUE; + if(!fci_flush_cabinet( hfci, FALSE, pfnfcignc, pfnfcis)) return FALSE; + } + + if( p_fci_internal->fNextCab ) { + /* THIS MAY NEVER HAPPEN */ + /* TODO set error code*/ + return FALSE; + } + + /* read the contents of the file blockwize*/ + while (!FALSE) { + if (p_fci_internal->cdata_in > CAB_BLOCKMAX) { + /* TODO internal error */ + return FALSE; + } + + read_result = PFCI_READ(hfci, file_handle /* file handle */, + (p_fci_internal->data_in + p_fci_internal->cdata_in) /* memory buffer */, + (CAB_BLOCKMAX - p_fci_internal->cdata_in) /* number of bytes to copy */, + &err, p_fci_internal->pv); + /* TODO error handling of err */ + + if( read_result==0 ) break; + + /* increment the block size */ + p_fci_internal->cdata_in += read_result; + + /* increment the file size */ + cffile.cbFile += read_result; + + + if ( p_fci_internal->cdata_in > CAB_BLOCKMAX ) { + /* TODO report internal error */ + return FALSE; + } + /* write a whole block */ + if ( p_fci_internal->cdata_in == CAB_BLOCKMAX ) { + + if( !fci_flush_data_block(hfci, &err, pfnfcis) ) return FALSE; + } + } + + /* close the file from FCIAddFile */ + PFCI_CLOSE(hfci,file_handle,&err,p_fci_internal->pv); + /* TODO error handling of err */ + + /* write cffile to p_fci_internal->handleCFFILE1 */ + if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE1, /* file handle */ + &cffile, sizeof(cffile),&err, p_fci_internal->pv) != sizeof(cffile) ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFFILE1 += sizeof(cffile); + + /* append the name of file*/ + if (strlen(pszFileName)>=CB_MAX_FILENAME) { + /* IMPOSSIBLE */ + /* TODO set error code */ + return FALSE; + } + if( PFCI_WRITE(hfci, p_fci_internal->handleCFFILE1, /* file handle */ + pszFileName, strlen(pszFileName)+1, &err, p_fci_internal->pv) + != strlen(pszFileName)+1 ) { + /* TODO write error */ + return FALSE; + } + /* TODO error handling of err */ + + p_fci_internal->sizeFileCFFILE1 += strlen(pszFileName)+1; + + /* REUSE the variable read_result */ + if (p_fci_internal->fGetNextCabInVain || + p_fci_internal->fNextCab + ) { + read_result=p_fci_internal->oldCCAB.cbReserveCFHeader + + p_fci_internal->oldCCAB.cbReserveCFFolder; + if ( p_fci_internal->oldCCAB.cbReserveCFHeader != 0 || + p_fci_internal->oldCCAB.cbReserveCFFolder != 0 || + p_fci_internal->oldCCAB.cbReserveCFData != 0 ) { + read_result+=4; + } + } else { + read_result=p_fci_internal->pccab->cbReserveCFHeader + + p_fci_internal->pccab->cbReserveCFFolder; + if ( p_fci_internal->pccab->cbReserveCFHeader != 0 || + p_fci_internal->pccab->cbReserveCFFolder != 0 || + p_fci_internal->pccab->cbReserveCFData != 0 ) { + read_result+=4; + } + } + if ( p_fci_internal->fPrevCab ) { + read_result+= strlen(p_fci_internal->szPrevCab)+1+ + strlen(p_fci_internal->szPrevDisk)+1; + } + if ( p_fci_internal->fNextCab ) { /* this is never the case */ + read_result+= strlen(p_fci_internal->pccab->szCab)+1+ + strlen(p_fci_internal->pccab->szDisk)+1; + } + read_result+= p_fci_internal->sizeFileCFDATA1 + + p_fci_internal->sizeFileCFFILE1 + p_fci_internal->sizeFileCFDATA2 + + p_fci_internal->sizeFileCFFILE2 + p_fci_internal->sizeFileCFFOLDER + + sizeof(CFHEADER) + + sizeof(CFFOLDER); /* set size of new CFFolder entry */ + + /* too much data for the maximum size of a cabinet */ + /* (ignoring the unflushed data block) */ + if( p_fci_internal->fGetNextCabInVain==FALSE && + p_fci_internal->fNextCab==FALSE && /* this is always the case */ + p_fci_internal->pccab->cb < read_result ) { + return fci_flush_cabinet( hfci, FALSE, pfnfcignc, pfnfcis); + } + + /* Might be too much data for the maximum size of a cabinet.*/ + /* When any further data will be added later, it might not */ + /* be possible to flush the cabinet, because there might */ + /* not be enough space to store the name of the following */ + /* cabinet and name of the corresponding disk. */ + /* So take care of this and get the name of the next cabinet */ + /* (ignoring the unflushed data block) */ + if( p_fci_internal->fGetNextCabInVain==FALSE && + p_fci_internal->fNextCab==FALSE && + ( p_fci_internal->pccab->cb < read_result + + CB_MAX_CABINET_NAME + CB_MAX_DISK_NAME + ) + ) { + /* save CCAB */ + memcpy(&(p_fci_internal->oldCCAB), p_fci_internal->pccab, sizeof(CCAB)); + /* increment cabinet index */ + ++(p_fci_internal->pccab->iCab); + /* get name of next cabinet */ + if (!(*pfnfcignc)(p_fci_internal->pccab, 0,/* TODO estimated size of cab */ + p_fci_internal->pv)) { + /* TODO error handling */ + return FALSE; + } + /* Skip a few lines of code. This is catched by the next if. */ + p_fci_internal->fGetNextCabInVain=TRUE; + } + + if( p_fci_internal->fGetNextCabInVain && + p_fci_internal->fNextCab + ) { + /* THIS CAN NEVER HAPPEN */ + /* TODO set error code*/ + return FALSE; + } + /* too much data for cabinet */ + if( (p_fci_internal->fGetNextCabInVain || + p_fci_internal->fNextCab) && ( + p_fci_internal->oldCCAB.cb < read_result + + strlen(p_fci_internal->pccab->szCab)+1+ + strlen(p_fci_internal->pccab->szDisk)+1 + )) { + + p_fci_internal->fGetNextCabInVain=FALSE; + p_fci_internal->fNextCab=TRUE; + return fci_flush_cabinet( hfci, FALSE, pfnfcignc, pfnfcis); + } + + if( p_fci_internal->fNextCab ) { + /* THIS MAY NEVER HAPPEN */ + /* TODO set error code*/ return FALSE; -} + } + + /* if the FolderThreshold has been reached flush the folder automatically */ + if( p_fci_internal->fGetNextCabInVain ) { + if( p_fci_internal->cCompressedBytesInFolder >= + p_fci_internal->oldCCAB.cbFolderThresh) { + return FCIFlushFolder(hfci, pfnfcignc, pfnfcis); + } + } else { + if( p_fci_internal->cCompressedBytesInFolder >= + p_fci_internal->pccab->cbFolderThresh) { + return FCIFlushFolder(hfci, pfnfcignc, pfnfcis); + } + } + + return TRUE; +} /* end of FCIAddFile */ + + + + /*********************************************************************** - * FCIFlushCabinet (CABINET.13) + * FCIFlushFolder (CABINET.12) + * + * FCIFlushFolder completes the CFFolder structure under construction. + * + * All further data which is added by FCIAddFile will be associateed to + * the next CFFolder structure. + * + * FCIFlushFolder will be called by FCIAddFile automatically if the + * threshold (stored in the member cbFolderThresh of the CCAB structure + * pccab passed to FCICreate) is exceeded. + * + * FCIFlushFolder will be called by FCIFlushFolder automatically before + * any data will be written into the cabinet file. + * + * PARAMS + * hfci [I] An HFCI from FCICreate + * pfnfcignc [I] A pointer to a function which gets information about + * the next cabinet + * pfnfcis [IO] A pointer to a function which will report status + * information about the compression process + * + * RETURNS + * On success, returns TRUE + * On failure, returns FALSE + * + * INCLUDES + * fci.h + * */ -BOOL __cdecl FCIFlushCabinet( +BOOL __cdecl FCIFlushFolder( HFCI hfci, - BOOL fGetNextCab, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis) { - FIXME("(%p, %d, %p, %p): stub\n", hfci, fGetNextCab, pfnfcignc, pfnfcis); + return fci_flush_folder(hfci,FALSE,pfnfcignc,pfnfcis); +} /* end of FCIFlushFolder */ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} /*********************************************************************** - * FCIFlushFolder (CABINET.12) + * FCIFlushCabinet (CABINET.13) + * + * FCIFlushCabinet stores the data which has been added by FCIAddFile + * into the cabinet file. If the maximum cabinet size (stored in the + * member cb of the CCAB structure pccab passed to FCICreate) has been + * exceeded FCIFlushCabinet will be called automatic by FCIAddFile. + * The remaining data still has to be flushed manually by calling + * FCIFlushCabinet. + * + * After FCIFlushCabinet has been called (manually) FCIAddFile must + * NOT be called again. Then hfci has to be released by FCIDestroy. + * + * PARAMS + * hfci [I] An HFCI from FCICreate + * fGetNextCab [I] Whether you want to add additional files to a + * cabinet set (TRUE) or whether you want to + * finalize it (FALSE) + * pfnfcignc [I] A pointer to a function which gets information about + * the next cabinet + * pfnfcis [IO] A pointer to a function which will report status + * information about the compression process + * + * RETURNS + * On success, returns TRUE + * On failure, returns FALSE + * + * INCLUDES + * fci.h + * */ -BOOL __cdecl FCIFlushFolder( +BOOL __cdecl FCIFlushCabinet( HFCI hfci, + BOOL fGetNextCab, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis) { - FIXME("(%p, %p, %p): stub\n", hfci, pfnfcignc, pfnfcis); + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + if(!fci_flush_cabinet(hfci,fGetNextCab,pfnfcignc,pfnfcis)) return FALSE; + + while( p_fci_internal->sizeFileCFFILE1>0 || + p_fci_internal->sizeFileCFFILE2>0 ) { + if(!fci_flush_cabinet(hfci,fGetNextCab,pfnfcignc,pfnfcis)) return FALSE; + } + + return TRUE; +} /* end of FCIFlushCabinet */ - return FALSE; -} /*********************************************************************** * FCIDestroy (CABINET.14) @@ -214,17 +2613,52 @@ */ BOOL __cdecl FCIDestroy(HFCI hfci) { + int err; + PFCI_Int p_fci_internal=((PFCI_Int)(hfci)); if (REALLY_IS_FCI(hfci)) { - PFCI_INT(hfci)->FCI_Intmagic = 0; - PFDI_FREE(hfci, hfci); - /*return TRUE; */ + + /* before hfci can be removed all temporary files must be closed */ + /* and deleted */ + p_fci_internal->FCI_Intmagic = 0; + + PFCI_CLOSE (hfci, p_fci_internal->handleCFDATA1,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFDATA1, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE (hfci, p_fci_internal->handleCFFILE1,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFFILE1, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE (hfci, p_fci_internal->handleCFDATA2,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFDATA2, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE (hfci, p_fci_internal->handleCFFILE2,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFFILE2, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_CLOSE (hfci, p_fci_internal->handleCFFOLDER,&err,p_fci_internal->pv); + /* TODO error handling of err */ + PFCI_DELETE(hfci, p_fci_internal->szFileNameCFFOLDER, &err, + p_fci_internal->pv); + /* TODO error handling of err */ + + /* data in and out buffers have to be removed */ + if (p_fci_internal->data_in!=NULL) + PFCI_FREE(hfci, p_fci_internal->data_in); + if (p_fci_internal->data_out!=NULL) + PFCI_FREE(hfci, p_fci_internal->data_out); + + /* hfci can now be removed */ + PFCI_FREE(hfci, hfci); + return TRUE; } else { SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - /* Still mark as incomplete, because of other missing FCI* APIs */ - FIXME("(%p): stub\n", hfci); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} +} /* end of FCIDestroy */ diff -urN wine-20050524/dlls/capi2032/capi2032.spec wine-20050628/dlls/capi2032/capi2032.spec --- wine-20050524/dlls/capi2032/capi2032.spec 2003-11-06 01:26:43.000000000 +0100 +++ wine-20050628/dlls/capi2032/capi2032.spec 2005-06-03 13:26:04.000000000 +0200 @@ -1,11 +1,11 @@ - 1 stdcall CAPI_REGISTER (long long long long ptr) wrapCAPI_REGISTER - 2 stdcall CAPI_RELEASE (long) wrapCAPI_RELEASE - 3 stdcall CAPI_PUT_MESSAGE (long ptr) wrapCAPI_PUT_MESSAGE - 4 stdcall CAPI_GET_MESSAGE (long ptr) wrapCAPI_GET_MESSAGE - 5 stdcall CAPI_WAIT_FOR_SIGNAL (long) wrapCAPI_WAIT_FOR_SIGNAL - 6 stdcall CAPI_GET_MANUFACTURER (str) wrapCAPI_GET_MANUFACTURER - 7 stdcall CAPI_GET_VERSION (ptr ptr ptr ptr) wrapCAPI_GET_VERSION - 8 stdcall CAPI_GET_SERIAL_NUMBER (str) wrapCAPI_GET_SERIAL_NUMBER - 9 stdcall CAPI_GET_PROFILE (ptr long) wrapCAPI_GET_PROFILE -10 stdcall CAPI_INSTALLED () wrapCAPI_INSTALLED -99 stdcall CAPI_MANUFACTURER (long long long ptr long) wrapCAPI_MANUFACTURER + 1 stdcall CAPI_REGISTER (long long long long ptr) wrapCAPI_REGISTER + 2 stdcall CAPI_RELEASE (long) wrapCAPI_RELEASE + 3 stdcall CAPI_PUT_MESSAGE (long ptr) wrapCAPI_PUT_MESSAGE + 4 stdcall CAPI_GET_MESSAGE (long ptr) wrapCAPI_GET_MESSAGE + 5 stdcall CAPI_WAIT_FOR_SIGNAL (long) wrapCAPI_WAIT_FOR_SIGNAL + 6 stdcall CAPI_GET_MANUFACTURER (str) wrapCAPI_GET_MANUFACTURER + 7 stdcall CAPI_GET_VERSION (ptr ptr ptr ptr) wrapCAPI_GET_VERSION + 8 stdcall CAPI_GET_SERIAL_NUMBER (str) wrapCAPI_GET_SERIAL_NUMBER + 9 stdcall CAPI_GET_PROFILE (ptr long) wrapCAPI_GET_PROFILE +10 stdcall CAPI_INSTALLED () wrapCAPI_INSTALLED +99 stdcall CAPI_MANUFACTURER (long long long ptr long) wrapCAPI_MANUFACTURER diff -urN wine-20050524/dlls/cards/cards.spec wine-20050628/dlls/cards/cards.spec --- wine-20050524/dlls/cards/cards.spec 2004-03-15 21:26:42.000000000 +0100 +++ wine-20050628/dlls/cards/cards.spec 2005-06-22 20:38:24.000000000 +0200 @@ -1,5 +1,5 @@ -@ stdcall cdtInit(ptr ptr) +@ stdcall cdtAnimate(long long long long long) @ stdcall cdtDraw(long long long long long long) @ stdcall cdtDrawExt(long long long long long long long long) -@ stdcall cdtAnimate(long long long long long) +@ stdcall cdtInit(ptr ptr) @ stdcall cdtTerm() diff -urN wine-20050524/dlls/comcat/comcat_private.h wine-20050628/dlls/comcat/comcat_private.h --- wine-20050524/dlls/comcat/comcat_private.h 2004-10-07 05:06:51.000000000 +0200 +++ wine-20050628/dlls/comcat/comcat_private.h 2005-05-27 22:17:37.000000000 +0200 @@ -46,7 +46,7 @@ typedef struct { /* IUnknown fields */ - IClassFactoryVtbl *lpVtbl; + const IClassFactoryVtbl *lpVtbl; DWORD ref; } ClassFactoryImpl; @@ -58,15 +58,15 @@ typedef struct { /* IUnknown fields */ - IUnknownVtbl *unkVtbl; - ICatRegisterVtbl *regVtbl; - ICatInformationVtbl *infVtbl; + const IUnknownVtbl *unkVtbl; + const ICatRegisterVtbl *regVtbl; + const ICatInformationVtbl *infVtbl; DWORD ref; } ComCatMgrImpl; -extern ComCatMgrImpl COMCAT_ComCatMgr; -extern ICatRegisterVtbl COMCAT_ICatRegister_Vtbl; -extern ICatInformationVtbl COMCAT_ICatInformation_Vtbl; +extern const ComCatMgrImpl COMCAT_ComCatMgr; +extern const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl; +extern const ICatInformationVtbl COMCAT_ICatInformation_Vtbl; /********************************************************************** * Global string constant declarations diff -urN wine-20050524/dlls/comcat/factory.c wine-20050628/dlls/comcat/factory.c --- wine-20050524/dlls/comcat/factory.c 2005-01-10 13:25:29.000000000 +0100 +++ wine-20050628/dlls/comcat/factory.c 2005-05-27 22:17:37.000000000 +0200 @@ -134,7 +134,7 @@ /********************************************************************** * IClassFactory_Vtbl */ -static IClassFactoryVtbl IClassFactory_Vtbl = +static const IClassFactoryVtbl IClassFactory_Vtbl = { COMCAT_IClassFactory_QueryInterface, COMCAT_IClassFactory_AddRef, diff -urN wine-20050524/dlls/comcat/information.c wine-20050628/dlls/comcat/information.c --- wine-20050524/dlls/comcat/information.c 2005-03-22 19:26:06.000000000 +0100 +++ wine-20050628/dlls/comcat/information.c 2005-05-27 22:17:37.000000000 +0200 @@ -236,7 +236,7 @@ LPENUMCATID *ppenumCATID) { /* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - WCHAR postfix[24] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e', + static const WCHAR postfix[24] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e', 'n', 't', 'e', 'd', ' ', 'C', 'a', 't', 'e', 'g', 'o', 'r', 'i', 'e', 's', 0 }; @@ -259,7 +259,7 @@ LPENUMCATID *ppenumCATID) { /* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */ - WCHAR postfix[21] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e', + static const WCHAR postfix[21] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e', 'd', ' ', 'C', 'a', 't', 'e', 'g', 'o', 'r', 'i', 'e', 's', 0 }; @@ -276,7 +276,7 @@ /********************************************************************** * COMCAT_ICatInformation_Vtbl */ -ICatInformationVtbl COMCAT_ICatInformation_Vtbl = +const ICatInformationVtbl COMCAT_ICatInformation_Vtbl = { COMCAT_ICatInformation_QueryInterface, COMCAT_ICatInformation_AddRef, @@ -297,7 +297,7 @@ */ typedef struct { - IEnumCATEGORYINFOVtbl *lpVtbl; + const IEnumCATEGORYINFOVtbl *lpVtbl; DWORD ref; LCID lcid; HKEY key; @@ -451,7 +451,7 @@ return S_OK; } -IEnumCATEGORYINFOVtbl COMCAT_IEnumCATEGORYINFO_Vtbl = +static const IEnumCATEGORYINFOVtbl COMCAT_IEnumCATEGORYINFO_Vtbl = { COMCAT_IEnumCATEGORYINFO_QueryInterface, COMCAT_IEnumCATEGORYINFO_AddRef, @@ -601,9 +601,9 @@ */ typedef struct { - IEnumGUIDVtbl *lpVtbl; + const IEnumGUIDVtbl *lpVtbl; DWORD ref; - struct class_categories const *categories; + const struct class_categories *categories; HKEY key; DWORD next_index; } CLSID_IEnumGUIDImpl; @@ -759,7 +759,7 @@ return S_OK; } -IEnumGUIDVtbl COMCAT_CLSID_IEnumGUID_Vtbl = +static const IEnumGUIDVtbl COMCAT_CLSID_IEnumGUID_Vtbl = { COMCAT_CLSID_IEnumGUID_QueryInterface, COMCAT_CLSID_IEnumGUID_AddRef, @@ -777,7 +777,7 @@ This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLSID_IEnumGUIDImpl)); if (This) { - WCHAR keyname[6] = { 'C', 'L', 'S', 'I', 'D', 0 }; + static const WCHAR keyname[] = { 'C', 'L', 'S', 'I', 'D', 0 }; This->lpVtbl = &COMCAT_CLSID_IEnumGUID_Vtbl; This->categories = categories; @@ -794,7 +794,7 @@ */ typedef struct { - IEnumGUIDVtbl *lpVtbl; + const IEnumGUIDVtbl *lpVtbl; DWORD ref; WCHAR keyname[68]; HKEY key; @@ -934,7 +934,7 @@ return S_OK; } -IEnumGUIDVtbl COMCAT_CATID_IEnumGUID_Vtbl = +static const IEnumGUIDVtbl COMCAT_CATID_IEnumGUID_Vtbl = { COMCAT_CATID_IEnumGUID_QueryInterface, COMCAT_CATID_IEnumGUID_AddRef, diff -urN wine-20050524/dlls/comcat/manager.c wine-20050628/dlls/comcat/manager.c --- wine-20050524/dlls/comcat/manager.c 2005-01-10 13:25:29.000000000 +0100 +++ wine-20050628/dlls/comcat/manager.c 2005-05-27 22:17:37.000000000 +0200 @@ -40,19 +40,19 @@ if (This == NULL || ppvObj == NULL) return E_POINTER; if (IsEqualGUID(riid, &IID_IUnknown)) { - *ppvObj = (LPVOID)&This->unkVtbl; + *ppvObj = &This->unkVtbl; COMCAT_IUnknown_AddRef(iface); return S_OK; } if (IsEqualGUID(riid, &IID_ICatRegister)) { - *ppvObj = (LPVOID)&This->regVtbl; + *ppvObj = &This->regVtbl; COMCAT_IUnknown_AddRef(iface); return S_OK; } if (IsEqualGUID(riid, &IID_ICatInformation)) { - *ppvObj = (LPVOID)&This->infVtbl; + *ppvObj = &This->infVtbl; COMCAT_IUnknown_AddRef(iface); return S_OK; } @@ -101,7 +101,7 @@ /********************************************************************** * COMCAT_IUnknown_Vtbl */ -static IUnknownVtbl COMCAT_IUnknown_Vtbl = +static const IUnknownVtbl COMCAT_IUnknown_Vtbl = { COMCAT_IUnknown_QueryInterface, COMCAT_IUnknown_AddRef, @@ -111,7 +111,7 @@ /********************************************************************** * static ComCatMgr instance */ -ComCatMgrImpl COMCAT_ComCatMgr = +const ComCatMgrImpl COMCAT_ComCatMgr = { &COMCAT_IUnknown_Vtbl, &COMCAT_ICatRegister_Vtbl, diff -urN wine-20050524/dlls/comcat/register.c wine-20050628/dlls/comcat/register.c --- wine-20050524/dlls/comcat/register.c 2004-08-23 21:40:04.000000000 +0200 +++ wine-20050628/dlls/comcat/register.c 2005-05-27 22:17:37.000000000 +0200 @@ -236,7 +236,7 @@ /********************************************************************** * COMCAT_ICatRegister_Vtbl */ -ICatRegisterVtbl COMCAT_ICatRegister_Vtbl = +const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl = { COMCAT_ICatRegister_QueryInterface, COMCAT_ICatRegister_AddRef, diff -urN wine-20050524/dlls/comctl32/comctl32.h wine-20050628/dlls/comctl32/comctl32.h --- wine-20050524/dlls/comctl32/comctl32.h 2004-10-20 00:59:59.000000000 +0200 +++ wine-20050628/dlls/comctl32/comctl32.h 2005-06-09 11:50:56.000000000 +0200 @@ -191,4 +191,62 @@ LRESULT WINAPI SetPathWordBreakProc(HWND hwnd, BOOL bSet); BOOL WINAPI MirrorIcon(HICON *phicon1, HICON *phicon2); +extern void ANIMATE_Register(void); +extern void ANIMATE_Unregister(void); +extern void COMBOEX_Register(void); +extern void COMBOEX_Unregister(void); +extern void DATETIME_Register(void); +extern void DATETIME_Unregister(void); +extern void FLATSB_Register(void); +extern void FLATSB_Unregister(void); +extern void HEADER_Register(void); +extern void HEADER_Unregister(void); +extern void HOTKEY_Register(void); +extern void HOTKEY_Unregister(void); +extern void IPADDRESS_Register(void); +extern void IPADDRESS_Unregister(void); +extern void LISTVIEW_Register(void); +extern void LISTVIEW_Unregister(void); +extern void MONTHCAL_Register(void); +extern void MONTHCAL_Unregister(void); +extern void NATIVEFONT_Register(void); +extern void NATIVEFONT_Unregister(void); +extern void PAGER_Register(void); +extern void PAGER_Unregister(void); +extern void PROGRESS_Register(void); +extern void PROGRESS_Unregister(void); +extern void REBAR_Register(void); +extern void REBAR_Unregister(void); +extern void STATUS_Register(void); +extern void STATUS_Unregister(void); +extern void SYSLINK_Register(void); +extern void SYSLINK_Unregister(void); +extern void TAB_Register(void); +extern void TAB_Unregister(void); +extern void TOOLBAR_Register(void); +extern void TOOLBAR_Unregister(void); +extern void TOOLTIPS_Register(void); +extern void TOOLTIPS_Unregister(void); +extern void TRACKBAR_Register(void); +extern void TRACKBAR_Unregister(void); +extern void TREEVIEW_Register(void); +extern void TREEVIEW_Unregister(void); +extern void UPDOWN_Register(void); +extern void UPDOWN_Unregister(void); + + +int MONTHCAL_MonthLength(int month, int year); + +static inline void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) +{ + to->wYear = from->wYear; + to->wMonth = from->wMonth; + to->wDayOfWeek = from->wDayOfWeek; + to->wDay = from->wDay; + to->wHour = from->wHour; + to->wMinute = from->wMinute; + to->wSecond = from->wSecond; + to->wMilliseconds = from->wMilliseconds; +} + #endif /* __WINE_COMCTL32_H */ diff -urN wine-20050524/dlls/comctl32/commctrl.c wine-20050628/dlls/comctl32/commctrl.c --- wine-20050524/dlls/comctl32/commctrl.c 2005-03-25 21:49:00.000000000 +0100 +++ wine-20050628/dlls/comctl32/commctrl.c 2005-06-09 11:50:56.000000000 +0200 @@ -73,49 +73,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(commctrl); -extern void ANIMATE_Register(void); -extern void ANIMATE_Unregister(void); -extern void COMBOEX_Register(void); -extern void COMBOEX_Unregister(void); -extern void DATETIME_Register(void); -extern void DATETIME_Unregister(void); -extern void FLATSB_Register(void); -extern void FLATSB_Unregister(void); -extern void HEADER_Register(void); -extern void HEADER_Unregister(void); -extern void HOTKEY_Register(void); -extern void HOTKEY_Unregister(void); -extern void IPADDRESS_Register(void); -extern void IPADDRESS_Unregister(void); -extern void LISTVIEW_Register(void); -extern void LISTVIEW_Unregister(void); -extern void MONTHCAL_Register(void); -extern void MONTHCAL_Unregister(void); -extern void NATIVEFONT_Register(void); -extern void NATIVEFONT_Unregister(void); -extern void PAGER_Register(void); -extern void PAGER_Unregister(void); -extern void PROGRESS_Register(void); -extern void PROGRESS_Unregister(void); -extern void REBAR_Register(void); -extern void REBAR_Unregister(void); -extern void STATUS_Register(void); -extern void STATUS_Unregister(void); -extern void SYSLINK_Register(void); -extern void SYSLINK_Unregister(void); -extern void TAB_Register(void); -extern void TAB_Unregister(void); -extern void TOOLBAR_Register(void); -extern void TOOLBAR_Unregister(void); -extern void TOOLTIPS_Register(void); -extern void TOOLTIPS_Unregister(void); -extern void TRACKBAR_Register(void); -extern void TRACKBAR_Unregister(void); -extern void TREEVIEW_Register(void); -extern void TREEVIEW_Unregister(void); -extern void UPDOWN_Register(void); -extern void UPDOWN_Unregister(void); - LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); LPWSTR COMCTL32_wSubclass = NULL; diff -urN wine-20050524/dlls/comctl32/flatsb.c wine-20050628/dlls/comctl32/flatsb.c --- wine-20050524/dlls/comctl32/flatsb.c 2005-03-23 11:22:52.000000000 +0100 +++ wine-20050628/dlls/comctl32/flatsb.c 2005-06-09 11:50:56.000000000 +0200 @@ -36,6 +36,7 @@ #include "winerror.h" #include "winuser.h" #include "commctrl.h" +#include "comctl32.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(commctrl); diff -urN wine-20050524/dlls/comctl32/ipaddress.c wine-20050628/dlls/comctl32/ipaddress.c --- wine-20050524/dlls/comctl32/ipaddress.c 2005-05-09 11:24:05.000000000 +0200 +++ wine-20050628/dlls/comctl32/ipaddress.c 2005-06-09 11:41:56.000000000 +0200 @@ -346,11 +346,7 @@ { TRACE("(index=%d)\n", index); - if (index > 3) { - for (index = 0; index < 4; index++) - if (!GetWindowTextLengthW(infoPtr->Part[index].EditHwnd)) break; - } - if (index < 9 || index > 3) index = 0; + if (index > 3 || index < 0) index=0; SetFocus (infoPtr->Part[index].EditHwnd); } diff -urN wine-20050524/dlls/comctl32/listview.c wine-20050628/dlls/comctl32/listview.c --- wine-20050524/dlls/comctl32/listview.c 2005-05-24 13:46:53.000000000 +0200 +++ wine-20050628/dlls/comctl32/listview.c 2005-06-20 16:18:05.000000000 +0200 @@ -276,7 +276,8 @@ HFONT hDefaultFont; HFONT hFont; INT ntmHeight; /* Some cached metrics of the font used */ - INT ntmAveCharWidth; /* by the listview to draw items */ + INT ntmMaxCharWidth; /* by the listview to draw items */ + INT nEllipsisWidth; BOOL bRedraw; /* Turns on/off repaints & invalidations */ BOOL bAutoarrange; /* Autoarrange flag when NOT in LVS_AUTOARRANGE */ BOOL bFocus; @@ -306,6 +307,7 @@ INT nSearchParamLength; WCHAR szSearchParam[ MAX_PATH ]; BOOL bIsDrawing; + INT nMeasureItemHeight; } LISTVIEW_INFO; /* @@ -547,7 +549,7 @@ return isW ? debugstr_wn(text, n) : debugstr_an((LPCSTR)text, n); } -static char* debug_getbuf() +static char* debug_getbuf(void) { static int index = 0; static char buffers[DEBUG_BUFFERS][DEBUG_BUFFER_SIZE]; @@ -2452,6 +2454,8 @@ nItemHeight = max(nItemHeight, infoPtr->iconSize.cy); if (infoPtr->himlState || infoPtr->himlSmall) nItemHeight += HEIGHT_PADDING; + if (infoPtr->nMeasureItemHeight > 0) + nItemHeight = infoPtr->nMeasureItemHeight; } return max(nItemHeight, 1); @@ -2489,12 +2493,17 @@ HFONT hFont = infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont; HFONT hOldFont = SelectObject(hdc, hFont); TEXTMETRICW tm; + SIZE sz; if (GetTextMetricsW(hdc, &tm)) { infoPtr->ntmHeight = tm.tmHeight; - infoPtr->ntmAveCharWidth = tm.tmAveCharWidth; + infoPtr->ntmMaxCharWidth = tm.tmMaxCharWidth; } + + if (GetTextExtentPoint32A(hdc, "...", 3, &sz)) + infoPtr->nEllipsisWidth = sz.cx; + SelectObject(hdc, hOldFont); ReleaseDC(infoPtr->hwndSelf, hdc); @@ -4266,6 +4275,7 @@ { COLUMN_INFO *lpColumnInfo; RECT rcOld, rcCol; + POINT ptOrigin; INT nCol; if (nColumn < 0 || DPA_GetPtrCount(infoPtr->hdpaColumns) < 1) return; @@ -4292,10 +4302,11 @@ infoPtr->nItemWidth += dx; LISTVIEW_UpdateScroll(infoPtr); + LISTVIEW_GetOrigin(infoPtr, &ptOrigin); /* scroll to cover the deleted column, and invalidate for redraw */ rcOld = infoPtr->rcList; - rcOld.left = rcCol.left; + rcOld.left = ptOrigin.x + rcCol.left + dx; ScrollWindowEx(infoPtr->hwndSelf, dx, 0, &rcOld, &rcOld, 0, 0, SW_ERASE | SW_INVALIDATE); /* we can restore focus now */ @@ -4560,6 +4571,17 @@ if (!notify_dispinfoT(infoPtr, LVN_ENDLABELEDITW, &dispInfo, isW)) return FALSE; if (!pszText) return TRUE; + if (!(infoPtr->dwStyle & LVS_OWNERDATA)) + { + HDPA hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, infoPtr->nEditLabelItem); + ITEM_INFO* lpItem = (ITEM_INFO *)DPA_GetPtr(hdpaSubItems, 0); + if (lpItem && lpItem->hdr.pszText == LPSTR_TEXTCALLBACKW) + { + LISTVIEW_InvalidateItem(infoPtr, infoPtr->nEditLabelItem); + return TRUE; + } + } + ZeroMemory(&dispInfo, sizeof(dispInfo)); dispInfo.item.mask = LVIF_TEXT; dispInfo.item.iItem = infoPtr->nEditLabelItem; @@ -5736,7 +5758,7 @@ * so it's worth optimizing */ if (uFlags & LVNI_FOCUSED) { - if (!(LISTVIEW_GetItemState(infoPtr, infoPtr->nFocusedItem, uMask) & uMask) == uMask) return -1; + if ((LISTVIEW_GetItemState(infoPtr, infoPtr->nFocusedItem, uMask) & uMask) != uMask) return -1; return (infoPtr->nFocusedItem == nItem) ? -1 : infoPtr->nFocusedItem; } @@ -6904,7 +6926,7 @@ return oldspacing; } -inline void set_icon_size(SIZE *size, HIMAGELIST himl, BOOL small) +static inline void set_icon_size(SIZE *size, HIMAGELIST himl, BOOL small) { INT cx, cy; @@ -7496,6 +7518,7 @@ infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING); infoPtr->nEditLabelItem = -1; infoPtr->dwHoverTime = -1; /* default system hover time */ + infoPtr->nMeasureItemHeight = 0; /* get default font (icon title) */ SystemParametersInfoW(SPI_GETICONTITLELOGFONT, 0, &logFont, 0); @@ -8271,21 +8294,27 @@ dx = cxy - (lpColumnInfo->rcHeader.right - lpColumnInfo->rcHeader.left); if (dx != 0) { - RECT rcCol = lpColumnInfo->rcHeader; - lpColumnInfo->rcHeader.right += dx; LISTVIEW_ScrollColumns(infoPtr, lpnmh->iItem + 1, dx); LISTVIEW_UpdateItemSize(infoPtr); if (uView == LVS_REPORT && is_redrawing(infoPtr)) { - /* this trick works for left aligned columns only */ + POINT ptOrigin; + RECT rcCol = lpColumnInfo->rcHeader; + + LISTVIEW_GetOrigin(infoPtr, &ptOrigin); + OffsetRect(&rcCol, ptOrigin.x, 0); + + rcCol.top = infoPtr->rcList.top; + rcCol.bottom = infoPtr->rcList.bottom; + + /* resizing left-aligned columns leaves most of the left side untouched */ if ((lpColumnInfo->fmt & LVCFMT_JUSTIFYMASK) == LVCFMT_LEFT) { - rcCol.right = min (rcCol.right, lpColumnInfo->rcHeader.right); - rcCol.left = max (rcCol.left, rcCol.right - 3 * infoPtr->ntmAveCharWidth); + INT nMaxDirty = infoPtr->nEllipsisWidth + infoPtr->ntmMaxCharWidth + dx; + rcCol.left = max (rcCol.left, rcCol.right - nMaxDirty); } - rcCol.top = infoPtr->rcList.top; - rcCol.bottom = infoPtr->rcList.bottom; + LISTVIEW_InvalidateRect(infoPtr, &rcCol); } } @@ -9310,8 +9339,24 @@ case WM_WINDOWPOSCHANGED: if (!(((WINDOWPOS *)lParam)->flags & SWP_NOSIZE)) { + UINT uView = infoPtr->dwStyle & LVS_TYPEMASK; SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE); + + if ((infoPtr->dwStyle & LVS_OWNERDRAWFIXED) && (uView == LVS_REPORT)) + { + MEASUREITEMSTRUCT mis; + mis.CtlType = ODT_LISTVIEW; + mis.CtlID = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); + mis.itemID = -1; + mis.itemWidth = 0; + mis.itemData = 0; + mis.itemHeight= infoPtr->nItemHeight; + SendMessageW(infoPtr->hwndNotify, WM_MEASUREITEM, mis.CtlID, (LPARAM)&mis); + if (infoPtr->nItemHeight != max(mis.itemHeight, 1)) + infoPtr->nMeasureItemHeight = infoPtr->nItemHeight = max(mis.itemHeight, 1); + } + LISTVIEW_UpdateSize(infoPtr); LISTVIEW_UpdateScroll(infoPtr); } @@ -9429,7 +9474,7 @@ if(hFont != 0) SelectObject(hdc, hOldFont); - ReleaseDC(infoPtr->hwndSelf, hdc); + ReleaseDC(infoPtr->hwndEdit, hdc); break; } diff -urN wine-20050524/dlls/comctl32/monthcal.c wine-20050628/dlls/comctl32/monthcal.c --- wine-20050524/dlls/comctl32/monthcal.c 2005-04-20 14:51:37.000000000 +0200 +++ wine-20050628/dlls/comctl32/monthcal.c 2005-06-09 11:50:56.000000000 +0200 @@ -134,7 +134,7 @@ /* january is 1, december is 12 */ int MONTHCAL_MonthLength(int month, int year) { -const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}; + const int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}; /*Wrap around, this eases handling*/ if(month == 0) month = 12; @@ -170,19 +170,6 @@ } -void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) -{ - to->wYear = from->wYear; - to->wMonth = from->wMonth; - to->wDayOfWeek = from->wDayOfWeek; - to->wDay = from->wDay; - to->wHour = from->wHour; - to->wMinute = from->wMinute; - to->wSecond = from->wSecond; - to->wMilliseconds = from->wMilliseconds; -} - - /* Note:Depending on DST, this may be offset by a day. Need to find out if we're on a DST place & adjust the clock accordingly. Above function assumes we have a valid data. @@ -212,7 +199,7 @@ GetClientRect(infoPtr->hwndSelf, &rcClient); /* if the point is outside the x bounds of the window put - it at the boundry */ + it at the boundary */ if (x > rcClient.right) x = rcClient.right; diff -urN wine-20050524/dlls/comctl32/pager.c wine-20050628/dlls/comctl32/pager.c --- wine-20050524/dlls/comctl32/pager.c 2005-03-25 11:25:45.000000000 +0100 +++ wine-20050628/dlls/comctl32/pager.c 2005-06-25 19:55:15.000000000 +0200 @@ -1227,9 +1227,9 @@ TRACE("[%p] %d,%d\n", infoPtr->hwndSelf, x, y); if (infoPtr->dwStyle & PGS_HORZ) - infoPtr->nHeight = x; + infoPtr->nHeight = y; else - infoPtr->nWidth = y; + infoPtr->nWidth = x; return PAGER_RecalcSize(infoPtr); } diff -urN wine-20050524/dlls/comctl32/propsheet.c wine-20050628/dlls/comctl32/propsheet.c --- wine-20050524/dlls/comctl32/propsheet.c 2005-03-25 21:49:00.000000000 +0100 +++ wine-20050628/dlls/comctl32/propsheet.c 2005-06-15 21:12:57.000000000 +0200 @@ -131,6 +131,7 @@ int width; int height; HIMAGELIST hImageList; + BOOL ended; } PropSheetInfo; typedef struct @@ -296,7 +297,7 @@ * * Find page index corresponding to page resource id. */ -INT PROPSHEET_FindPageByResId(PropSheetInfo * psInfo, LRESULT resId) +static INT PROPSHEET_FindPageByResId(PropSheetInfo * psInfo, LRESULT resId) { INT i; @@ -707,39 +708,21 @@ * -1 (error). */ if( psInfo->unicode ) { - if (!(psInfo->ppshheader.dwFlags & PSH_MODELESS)) - ret = DialogBoxIndirectParamW(psInfo->ppshheader.hInstance, - (LPDLGTEMPLATEW) temp, - psInfo->ppshheader.hwndParent, - PROPSHEET_DialogProc, - (LPARAM)psInfo); - else - { - ret = (int)CreateDialogIndirectParamW(psInfo->ppshheader.hInstance, - (LPDLGTEMPLATEW) temp, - psInfo->ppshheader.hwndParent, - PROPSHEET_DialogProc, - (LPARAM)psInfo); - if ( !ret ) ret = -1; - } + ret = (int)CreateDialogIndirectParamW(psInfo->ppshheader.hInstance, + (LPDLGTEMPLATEW) temp, + psInfo->ppshheader.hwndParent, + PROPSHEET_DialogProc, + (LPARAM)psInfo); + if ( !ret ) ret = -1; } else { - if (!(psInfo->ppshheader.dwFlags & PSH_MODELESS)) - ret = DialogBoxIndirectParamA(psInfo->ppshheader.hInstance, - (LPDLGTEMPLATEA) temp, - psInfo->ppshheader.hwndParent, - PROPSHEET_DialogProc, - (LPARAM)psInfo); - else - { - ret = (int)CreateDialogIndirectParamA(psInfo->ppshheader.hInstance, - (LPDLGTEMPLATEA) temp, - psInfo->ppshheader.hwndParent, - PROPSHEET_DialogProc, - (LPARAM)psInfo); - if ( !ret ) ret = -1; - } + ret = (int)CreateDialogIndirectParamA(psInfo->ppshheader.hInstance, + (LPDLGTEMPLATEA) temp, + psInfo->ppshheader.hwndParent, + PROPSHEET_DialogProc, + (LPARAM)psInfo); + if ( !ret ) ret = -1; } Free(temp); @@ -1265,7 +1248,7 @@ * Subclassing window procedure for wizard extrior pages to prevent drawing * background and so drawing above the watermark. */ -LRESULT CALLBACK +static LRESULT CALLBACK PROPSHEET_WizardSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uID, DWORD_PTR dwRef) { switch (uMsg) @@ -1757,7 +1740,7 @@ if (psInfo->isModeless) psInfo->activeValid = FALSE; else - EndDialog(hwndDlg, TRUE); + psInfo->ended = TRUE; return TRUE; } @@ -1870,7 +1853,7 @@ psInfo->activeValid = FALSE; } else - EndDialog(hwndDlg, FALSE); + psInfo->ended = TRUE; } /****************************************************************************** @@ -2396,7 +2379,7 @@ psInfo->active_page = -1; if (!psInfo->isModeless) { - EndDialog(hwndDlg, FALSE); + psInfo->ended = TRUE; return TRUE; } } @@ -2737,6 +2720,34 @@ GlobalFree((HGLOBAL)psInfo); } +static INT do_loop(PropSheetInfo *psInfo) +{ + MSG msg; + INT ret = -1; + HWND hwnd = psInfo->hwnd; + + while(IsWindow(hwnd) && !psInfo->ended && (ret = GetMessageW(&msg, NULL, 0, 0))) + { + if(ret == -1) + break; + + if(!IsDialogMessageW(hwnd, &msg)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + } + + if(ret == 0) + { + PostQuitMessage(msg.wParam); + ret = -1; + } + + DestroyWindow(hwnd); + return ret; +} + /****************************************************************************** * PropertySheet (COMCTL32.@) * PropertySheetA (COMCTL32.@) @@ -2787,7 +2798,11 @@ } psInfo->unicode = FALSE; + psInfo->ended = FALSE; + bRet = PROPSHEET_CreateDialog(psInfo); + if(!psInfo->isModeless) + bRet = do_loop(psInfo); return bRet; } @@ -2834,7 +2849,11 @@ } psInfo->unicode = TRUE; + psInfo->ended = FALSE; + bRet = PROPSHEET_CreateDialog(psInfo); + if(!psInfo->isModeless) + bRet = do_loop(psInfo); return bRet; } @@ -3039,7 +3058,7 @@ if (psInfo->isModeless) psInfo->activeValid = FALSE; else - EndDialog(hwnd, result); + psInfo->ended = TRUE; } else EnableWindow(hwndApplyBtn, FALSE); @@ -3424,6 +3443,17 @@ } return TRUE; + case WM_SYSCOMMAND: + switch(wParam & 0xfff0) + { + case SC_CLOSE: + PROPSHEET_Cancel(hwnd, 1); + return TRUE; + + default: + return FALSE; + } + case WM_NOTIFY: { NMHDR* pnmh = (LPNMHDR) lParam; diff -urN wine-20050524/dlls/comctl32/tab.c wine-20050628/dlls/comctl32/tab.c --- wine-20050524/dlls/comctl32/tab.c 2005-05-17 12:19:37.000000000 +0200 +++ wine-20050628/dlls/comctl32/tab.c 2005-06-06 12:03:03.000000000 +0200 @@ -20,17 +20,47 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * NOTES + * + * This code was audited for completeness against the documented features + * of Comctl32.dll version 6.0 on May. 20, 2005, by James Hawkins. + * + * Unless otherwise noted, we believe this code to be complete, as per + * the specification mentioned above. + * If you discover missing features, or bugs, please note them below. + * * TODO: * * Styles: + * TCS_MULTISELECT + * TCS_RIGHT + * TCS_RIGHTJUSTIFY + * TCS_SCROLLOPPOSITE + * TCS_SINGLELINE * TCIF_RTLREADING * + * Extended Styles: + * TCS_EX_FLATSEPARATORS + * TCS_EX_REGISTERDROP + * + * States: + * TCIS_BUTTONPRESSED + * + * Notifications: + * NM_RELEASEDCAPTURE + * TCN_FOCUSCHANGE + * TCN_GETOBJECT + * TCN_KEYDOWN + * * Messages: * TCM_REMOVEIMAGE * TCM_DESELECTALL * TCM_GETEXTENDEDSTYLE * TCM_SETEXTENDEDSTYLE * + * Macros: + * TabCtrl_AdjustRect + * */ #include @@ -1727,14 +1757,20 @@ else drawRect->bottom-=center_offset_h; - center_offset_v = ((drawRect->right - drawRect->left) - (rcText.bottom - rcText.top) + infoPtr->uVItemPadding) / 2; + center_offset_v = ((drawRect->right - drawRect->left) - (rcText.bottom - rcText.top)) / 2; } else { drawRect->left += center_offset_h; - center_offset_v = ((drawRect->bottom - drawRect->top) - (rcText.bottom - rcText.top) + infoPtr->uVItemPadding) / 2; + center_offset_v = ((drawRect->bottom - drawRect->top) - (rcText.bottom - rcText.top)) / 2; } + /* if an item is selected, the text is shifted up instead of down */ + if (iItem == infoPtr->iSelected) + center_offset_v -= infoPtr->uVItemPadding / 2; + else + center_offset_v += infoPtr->uVItemPadding / 2; + if (center_offset_v < 0) center_offset_v = 0; diff -urN wine-20050524/dlls/comctl32/tests/.cvsignore wine-20050628/dlls/comctl32/tests/.cvsignore --- wine-20050524/dlls/comctl32/tests/.cvsignore 2005-03-16 20:52:40.000000000 +0100 +++ wine-20050628/dlls/comctl32/tests/.cvsignore 2005-06-13 14:23:01.000000000 +0200 @@ -5,4 +5,5 @@ subclass.ok tab.ok testlist.c +treeview.ok updown.ok diff -urN wine-20050524/dlls/comctl32/tests/Makefile.in wine-20050628/dlls/comctl32/tests/Makefile.in --- wine-20050524/dlls/comctl32/tests/Makefile.in 2005-03-16 20:52:40.000000000 +0100 +++ wine-20050628/dlls/comctl32/tests/Makefile.in 2005-06-13 14:23:01.000000000 +0200 @@ -11,6 +11,7 @@ mru.c \ subclass.c \ tab.c \ + treeview.c \ updown.c @MAKE_TEST_RULES@ diff -urN wine-20050524/dlls/comctl32/tests/dpa.c wine-20050628/dlls/comctl32/tests/dpa.c --- wine-20050524/dlls/comctl32/tests/dpa.c 2005-04-22 23:18:12.000000000 +0200 +++ wine-20050628/dlls/comctl32/tests/dpa.c 2005-06-09 11:50:56.000000000 +0200 @@ -41,7 +41,7 @@ return lstrcmpA (str1, str2); } -void DPA_test() +static void DPA_test(void) { HDPA dpa_ret; INT int_ret; diff -urN wine-20050524/dlls/comctl32/tests/imagelist.c wine-20050628/dlls/comctl32/tests/imagelist.c --- wine-20050524/dlls/comctl32/tests/imagelist.c 2005-02-10 20:19:36.000000000 +0100 +++ wine-20050628/dlls/comctl32/tests/imagelist.c 2005-06-20 16:18:05.000000000 +0200 @@ -469,7 +469,7 @@ return TRUE; } -static void testMerge() +static void testMerge(void) { HIMAGELIST himl1, himl2, hmerge; HICON hicon1; diff -urN wine-20050524/dlls/comctl32/tests/subclass.c wine-20050628/dlls/comctl32/tests/subclass.c --- wine-20050524/dlls/comctl32/tests/subclass.c 2004-08-26 02:31:20.000000000 +0200 +++ wine-20050628/dlls/comctl32/tests/subclass.c 2005-06-21 22:53:14.000000000 +0200 @@ -134,7 +134,7 @@ sequence_cnt++; } -static void flush_sequence() +static void flush_sequence(void) { HeapFree(GetProcessHeap(), 0, sequence); sequence = 0; @@ -215,7 +215,7 @@ return pDefSubclassProc(hwnd, message, wParam, lParam); } -static void test_subclass() +static void test_subclass(void) { HWND hwnd = CreateWindowExA(0, "TestSubclass", "Test subclass", WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL); diff -urN wine-20050524/dlls/comctl32/tests/tab.c wine-20050628/dlls/comctl32/tests/tab.c --- wine-20050524/dlls/comctl32/tests/tab.c 2004-01-27 05:01:10.000000000 +0100 +++ wine-20050628/dlls/comctl32/tests/tab.c 2005-06-09 11:50:56.000000000 +0200 @@ -39,7 +39,7 @@ #define trace_tab(str) #endif -HWND +static HWND create_tabcontrol (DWORD style) { HWND handle; @@ -76,7 +76,7 @@ return handle; } -void CheckSize(HWND hwnd, INT width, INT height) +static void CheckSize(HWND hwnd, INT width, INT height) { RECT rTab, r1; @@ -95,7 +95,7 @@ "Expected [%d,%d] got [%ld,%ld]\n", width, height, rTab.right - rTab.left, rTab.bottom - rTab.top); } -void TabCheckSetSize(HWND hwnd, INT SetWidth, INT SetHeight, INT ExpWidth, INT ExpHeight) +static void TabCheckSetSize(HWND hwnd, INT SetWidth, INT SetHeight, INT ExpWidth, INT ExpHeight) { SendMessage (hwnd, TCM_SETITEMSIZE, 0, (LPARAM) MAKELPARAM((SetWidth >= 0) ? SetWidth:0, (SetHeight >= 0) ? SetHeight:0)); diff -urN wine-20050524/dlls/comctl32/tests/treeview.c wine-20050628/dlls/comctl32/tests/treeview.c --- wine-20050524/dlls/comctl32/tests/treeview.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/comctl32/tests/treeview.c 2005-06-16 17:52:44.000000000 +0200 @@ -0,0 +1,217 @@ +/* Unit tests for treeview. + * + * Copyright 2005 Krzysztof Foltman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winnls.h" +#include "winreg.h" +#include "commctrl.h" + +#include "wine/test.h" + +static HWND hMainWnd; + +static HWND hTree; +static HTREEITEM hRoot, hChild; + +static int pos = 0; +static char sequence[256]; + +static void Clear(void) +{ + pos = 0; + sequence[0] = '\0'; +} + +static void AddItem(char ch) +{ + sequence[pos++] = ch; + sequence[pos] = '\0'; +} + +static void IdentifyItem(HTREEITEM hItem) +{ + if (hItem == hRoot) { + AddItem('R'); + return; + } + if (hItem == hChild) { + AddItem('C'); + return; + } + if (hItem == NULL) { + AddItem('n'); + return; + } + AddItem('?'); +} + +static void FillRoot(void) +{ + TVINSERTSTRUCTA ins; + + Clear(); + AddItem('A'); + ins.hParent = TVI_ROOT; + ins.hInsertAfter = TVI_ROOT; + U(ins).item.mask = TVIF_TEXT; + U(ins).item.pszText = "Root"; + hRoot = TreeView_InsertItemA(hTree, &ins); + assert(hRoot); + + AddItem('B'); + ins.hParent = hRoot; + ins.hInsertAfter = TVI_FIRST; + U(ins).item.mask = TVIF_TEXT; + U(ins).item.pszText = "Child"; + hChild = TreeView_InsertItemA(hTree, &ins); + assert(hChild); + AddItem('.'); + + ok(!strcmp(sequence, "AB."), "Item creation"); +} + +static void DoTest1(void) +{ + TreeView_SelectItem(hTree, NULL); + Clear(); + AddItem('1'); + TreeView_SelectItem(hTree, hRoot); + AddItem('2'); + TreeView_SelectItem(hTree, hRoot); + AddItem('3'); + TreeView_SelectItem(hTree, NULL); + AddItem('4'); + TreeView_SelectItem(hTree, NULL); + AddItem('5'); + TreeView_SelectItem(hTree, hRoot); + AddItem('.'); + ok(!strcmp(sequence, "1(nR)nR23(Rn)Rn45(nR)nR."), "root-none select test"); +} + +static void DoTest2(void) +{ + TreeView_SelectItem(hTree, NULL); + Clear(); + AddItem('1'); + TreeView_SelectItem(hTree, hRoot); + AddItem('2'); + TreeView_SelectItem(hTree, hRoot); + AddItem('3'); + TreeView_SelectItem(hTree, hChild); + AddItem('4'); + TreeView_SelectItem(hTree, hChild); + AddItem('5'); + TreeView_SelectItem(hTree, hRoot); + AddItem('.'); + ok(!strcmp(sequence, "1(nR)nR23(RC)RC45(CR)CR."), "root-child select test"); +} + +LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + + case WM_CREATE: + { + hTree = CreateWindowExA(WS_EX_CLIENTEDGE, WC_TREEVIEWA, NULL, WS_CHILD|WS_VISIBLE| + TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS, + 0, 0, 300, 50, hWnd, (HMENU)100, GetModuleHandleA(0), 0); + + SetFocus(hTree); + return 0; + } + case WM_NOTIFY: + { + NMHDR *pHdr = (NMHDR *)lParam; + + if (pHdr->idFrom == 100) { + NMTREEVIEWA *pTreeView = (LPNMTREEVIEWA) lParam; + switch(pHdr->code) { + case TVN_SELCHANGINGA: + AddItem('('); + IdentifyItem(pTreeView->itemOld.hItem); + IdentifyItem(pTreeView->itemNew.hItem); + return 0; + case TVN_SELCHANGEDA: + AddItem(')'); + IdentifyItem(pTreeView->itemOld.hItem); + IdentifyItem(pTreeView->itemNew.hItem); + return 0; + } + } + return 0; + } + + case WM_SIZE: + MoveWindow(hTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProcA(hWnd, msg, wParam, lParam); + } + return 0L; +} + +START_TEST(treeview) +{ + WNDCLASSA wc; + MSG msg; + INITCOMMONCONTROLSEX icex; + RECT rc; + + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_TREEVIEW_CLASSES; + InitCommonControlsEx(&icex); + + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = GetModuleHandleA(NULL); + wc.hIcon = NULL; + wc.hCursor = LoadCursorA(NULL, MAKEINTRESOURCEA(IDC_IBEAM)); + wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW); + wc.lpszMenuName = NULL; + wc.lpszClassName = "MyTestWnd"; + wc.lpfnWndProc = MyWndProc; + RegisterClassA(&wc); + + + hMainWnd = CreateWindowExA(0, "MyTestWnd", "Blah", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0); + GetClientRect(hMainWnd, &rc); + + FillRoot(); + DoTest1(); + DoTest2(); + + PostMessageA(hMainWnd, WM_CLOSE, 0, 0); + while(GetMessageA(&msg,0,0,0)) { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } +} diff -urN wine-20050524/dlls/comctl32/tests/updown.c wine-20050628/dlls/comctl32/tests/updown.c --- wine-20050524/dlls/comctl32/tests/updown.c 2005-03-18 15:09:12.000000000 +0100 +++ wine-20050628/dlls/comctl32/tests/updown.c 2005-06-09 11:50:56.000000000 +0200 @@ -27,7 +27,7 @@ static HDC desktopDC; static HINSTANCE hinst; -HWND create_edit_control (DWORD style, DWORD exstyle) +static HWND create_edit_control (DWORD style, DWORD exstyle) { HWND handle; @@ -43,7 +43,7 @@ return handle; } -HWND create_updown_control (HWND hWndEdit) +static HWND create_updown_control (HWND hWndEdit) { HWND hWndUpDown; diff -urN wine-20050524/dlls/comctl32/toolbar.c wine-20050628/dlls/comctl32/toolbar.c --- wine-20050524/dlls/comctl32/toolbar.c 2005-05-06 17:44:32.000000000 +0200 +++ wine-20050628/dlls/comctl32/toolbar.c 2005-06-25 19:55:40.000000000 +0200 @@ -211,12 +211,13 @@ #define DEFPAD_CX 7 #define DEFPAD_CY 6 +#define DEFLISTGAP 4 + +/* vertical padding used in list mode when image is present */ +#define LISTPAD_CY 9 -/* gap between border of button and text/image */ -#define OFFSET_X 1 -#define OFFSET_Y 1 /* how wide to treat the bitmap if it isn't present */ -#define LIST_IMAGE_ABSENT_WIDTH 2 +#define NONLIST_NOTEXT_OFFSET 2 #define TOOLBAR_NOWHERE (-1) @@ -224,11 +225,6 @@ #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE) #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE) -static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO *infoPtr, INT iListGap) -{ - return GetSystemMetrics(SM_CXEDGE) + iListGap - infoPtr->szPadding.cx/2; -} - /* Used to find undocumented extended styles */ #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \ TBSTYLE_EX_UNDOC1 | \ @@ -396,6 +392,14 @@ } +static inline BOOL +TOOLBAR_IsValidImageList(TOOLBAR_INFO *infoPtr, INT index) +{ + HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr, index)); + return (himl != NULL) && (ImageList_GetImageCount(himl) > 0); +} + + /*********************************************************************** * TOOLBAR_GetImageListForDrawing * @@ -445,37 +449,6 @@ } -/*********************************************************************** -* TOOLBAR_TestImageExist -* -* This function is similar to TOOLBAR_GetImageListForDrawing, except it does not -* return the image list. The I_IMAGECALLBACK functionality is implemented. -*/ -static BOOL -TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl) -{ - INT index; - - if (!himl) return FALSE; - - if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { - if (btnPtr->iBitmap == I_IMAGENONE) return FALSE; - ERR("index %d is not valid, max %d\n", - btnPtr->iBitmap, infoPtr->nNumBitmaps); - return FALSE; - } - - if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) { - if ((index == I_IMAGECALLBACK) || - (index == I_IMAGENONE)) return FALSE; - ERR("TBN_GETDISPINFO returned invalid index %d\n", - index); - return FALSE; - } - return TRUE; -} - - static void TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr) { @@ -755,7 +728,7 @@ /* draws a blank frame for a toolbar button */ static void -TOOLBAR_DrawFrame(const TOOLBAR_INFO *infoPtr, BOOL flat, const NMTBCUSTOMDRAW *tbcd) +TOOLBAR_DrawFrame(const TOOLBAR_INFO *infoPtr, const NMTBCUSTOMDRAW *tbcd) { HDC hdc = tbcd->nmcd.hdc; RECT rc = tbcd->nmcd.rc; @@ -771,7 +744,7 @@ if (infoPtr->dwItemCDFlag & TBCDRF_NOEDGES) return; - if (flat) + if (infoPtr->dwStyle & TBSTYLE_FLAT) { if (pressed_look) DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT); @@ -845,7 +818,6 @@ rc = btnPtr->rect; CopyRect (&rcArrow, &rc); - CopyRect(&rcBitmap, &rc); /* get a pointer to the text */ lpText = TOOLBAR_GetText(infoPtr, btnPtr); @@ -865,47 +837,51 @@ rcArrow.left = right; } - /* copy text rect after adjusting for drop-down arrow - * so that text is centred in the rectangle not containing + /* copy text & bitmap rects after adjusting for drop-down arrow + * so that text & bitmap is centred in the rectangle not containing * the arrow */ CopyRect(&rcText, &rc); + CopyRect(&rcBitmap, &rc); /* Center the bitmap horizontally and vertically */ if (dwStyle & TBSTYLE_LIST) - rcBitmap.left += GetSystemMetrics(SM_CXEDGE); + { + if (lpText && + infoPtr->nMaxTextRows > 0 && + (!(infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) || + (btnPtr->fsStyle & BTNS_SHOWTEXT)) ) + rcBitmap.left += GetSystemMetrics(SM_CXEDGE) + infoPtr->szPadding.cx / 2; + else + rcBitmap.left += GetSystemMetrics(SM_CXEDGE) + infoPtr->iListGap / 2; + } else - rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2; + rcBitmap.left += (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2; - if(lpText) - rcBitmap.top+= GetSystemMetrics(SM_CYEDGE); - else - rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2; + rcBitmap.top += infoPtr->szPadding.cy / 2; - TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n", + TRACE("iBitmap=%d, start=(%ld,%ld) w=%d, h=%d\n", btnPtr->iBitmap, rcBitmap.left, rcBitmap.top, infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); - TRACE ("iString: %x\n", btnPtr->iString); - TRACE ("Stringtext: %s\n", debugstr_w(lpText)); + TRACE("Text=%s\n", debugstr_w(lpText)); + TRACE("iListGap=%d, padding = { %ld, %ld }\n", infoPtr->iListGap, infoPtr->szPadding.cx, infoPtr->szPadding.cy); - /* draw text */ - if (lpText) { - rcText.left += GetSystemMetrics(SM_CXEDGE) + OFFSET_X; - rcText.right -= GetSystemMetrics(SM_CXEDGE) + OFFSET_X; - if (GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr,btnPtr->iBitmap)) && - TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) + /* calculate text position */ + if (lpText) + { + rcText.left += GetSystemMetrics(SM_CXEDGE); + rcText.right -= GetSystemMetrics(SM_CXEDGE); + if (dwStyle & TBSTYLE_LIST) { - if (dwStyle & TBSTYLE_LIST) - rcText.left += infoPtr->nBitmapWidth + TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap); - else - rcText.top += GetSystemMetrics(SM_CYEDGE) + OFFSET_Y + infoPtr->nBitmapHeight + infoPtr->szPadding.cy/2; + if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) + rcText.left += infoPtr->nBitmapWidth + infoPtr->iListGap + 2; } else - if (dwStyle & TBSTYLE_LIST) - rcText.left += LIST_IMAGE_ABSENT_WIDTH + TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap); - - if (!(infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) && - (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))) - OffsetRect(&rcText, 1, 1); + { + if (ImageList_GetImageCount(GETDEFIMAGELIST(infoPtr, 0)) > 0) + rcText.top += infoPtr->szPadding.cy/2 + infoPtr->nBitmapHeight + 1; + else + rcText.top += infoPtr->szPadding.cy/2 + 2; + } } /* Initialize fields in all cases, because we use these later @@ -980,6 +956,10 @@ goto FINALNOTIFY; } + if (!(infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) && + (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))) + OffsetRect(&rcText, 1, 1); + if (!(tbcd.nmcd.uItemState & CDIS_HOT) && ((tbcd.nmcd.uItemState & CDIS_CHECKED) || (tbcd.nmcd.uItemState & CDIS_INDETERMINATE))) TOOLBAR_DrawPattern (&rc, &tbcd); @@ -998,7 +978,7 @@ } } - TOOLBAR_DrawFrame(infoPtr, dwStyle & TBSTYLE_FLAT, &tbcd); + TOOLBAR_DrawFrame(infoPtr, &tbcd); if (drawSepDropDownArrow) TOOLBAR_DrawSepDDArrow(infoPtr, &tbcd, &rcArrow, btnPtr->bDropDownPressed); @@ -1398,6 +1378,166 @@ /*********************************************************************** +* TOOLBAR_MeasureButton +* +* Calculates the width and height required for a button. Used in +* TOOLBAR_CalcToolbar to set the all-button width and height and also for +* the width of buttons that are autosized. +* +* Note that it would have been rather elegant to use one piece of code for +* both the laying out of the toolbar and for controlling where button parts +* are drawn, but the native control has inconsistencies between the two that +* prevent this from being effectively. These inconsistencies can be seen as +* artefacts where parts of the button appear outside of the bounding button +* rectangle. +* +* There are several cases for the calculation of the button dimensions and +* button part positioning: +* +* List +* ==== +* +* With Bitmap: +* +* +--------------------------------------------------------+ ^ +* | ^ ^ | | +* | | pad.cy / 2 | centred | | +* | pad.cx/2 + cxedge +--------------+ +------------+ | | DEFPAD_CY + +* |<----------------->| nBitmapWidth | | Text | | | max(nBitmapHeight, szText.cy) +* | |<------------>| | | | | +* | +--------------+ +------------+ | | +* |<-------------------------------------->| | | +* | cxedge + iListGap + nBitmapWidth + 2 |<-----------> | | +* | szText.cx | | +* +--------------------------------------------------------+ - +* <--------------------------------------------------------> +* 2*cxedge + nBitmapWidth + iListGap + szText.cx + pad.cx +* +* Without Bitmap (I_IMAGENONE): +* +* +-----------------------------------+ ^ +* | ^ | | +* | | centred | | LISTPAD_CY + +* | +------------+ | | szText.cy +* | | Text | | | +* | | | | | +* | +------------+ | | +* |<----------------->| | | +* | cxedge |<-----------> | | +* | szText.cx | | +* +-----------------------------------+ - +* <-----------------------------------> +* szText.cx + pad.cx +* +* Without text: +* +* +--------------------------------------+ ^ +* | ^ | | +* | | padding.cy/2 | | DEFPAD_CY + +* | +------------+ | | nBitmapHeight +* | | Bitmap | | | +* | | | | | +* | +------------+ | | +* |<------------------->| | | +* | cxedge + iListGap/2 |<-----------> | | +* | nBitmapWidth | | +* +--------------------------------------+ - +* <--------------------------------------> +* 2*cxedge + nBitmapWidth + iListGap +* +* Non-List +* ======== +* +* With bitmap: +* +* +-----------------------------------+ ^ +* | ^ | | +* | | pad.cy / 2 | | nBitmapHeight + +* | - | | szText.cy + +* | +------------+ | | DEFPAD_CY + 1 +* | centred | Bitmap | | | +* |<----------------->| | | | +* | +------------+ | | +* | ^ | | +* | 1 | | | +* | - | | +* | centred +---------------+ | | +* |<--------------->| Text | | | +* | +---------------+ | | +* +-----------------------------------+ - +* <-----------------------------------> +* pad.cx + max(nBitmapWidth, szText.cx) +* +* Without bitmaps (NULL imagelist or ImageList_GetImageCount() = 0): +* +* +---------------------------------------+ ^ +* | ^ | | +* | | 2 + pad.cy / 2 | | +* | - | | szText.cy + +* | centred +-----------------+ | | pad.cy + 2 +* |<--------------->| Text | | | +* | +-----------------+ | | +* | | | +* +---------------------------------------+ - +* <---------------------------------------> +* 2*cxedge + pad.cx + szText.cx +* +* Without text: +* As for with bitmaps, but with szText.cx zero. +*/ +static inline SIZE TOOLBAR_MeasureButton(TOOLBAR_INFO *infoPtr, SIZE sizeString, BOOL bHasBitmap, BOOL bValidImageList) +{ + SIZE sizeButton; + if (infoPtr->dwStyle & TBSTYLE_LIST) + { + /* set button height from bitmap / text height... */ + sizeButton.cy = max((bHasBitmap ? infoPtr->nBitmapHeight : 0), + sizeString.cy); + + /* ... add on the necessary padding */ + if (bValidImageList) + { + if (bHasBitmap) + sizeButton.cy += DEFPAD_CY; + else + sizeButton.cy += LISTPAD_CY; + } + else + sizeButton.cy += infoPtr->szPadding.cy; + + /* calculate button width */ + if (bHasBitmap) + { + sizeButton.cx = 2*GetSystemMetrics(SM_CXEDGE) + + infoPtr->nBitmapWidth + infoPtr->iListGap; + if (sizeString.cx > 0) + sizeButton.cx += sizeString.cx + infoPtr->szPadding.cx; + } + else + sizeButton.cx = sizeString.cx + infoPtr->szPadding.cx; + } + else + { + if (bHasBitmap) + { + sizeButton.cy = infoPtr->nBitmapHeight + 1 + + sizeString.cy + DEFPAD_CY; + sizeButton.cx = infoPtr->szPadding.cx + + max(sizeString.cx, infoPtr->nBitmapWidth); + } + else + { + sizeButton.cy = sizeString.cy + infoPtr->szPadding.cy + + NONLIST_NOTEXT_OFFSET; + sizeButton.cx = 2*GetSystemMetrics(SM_CXEDGE) + + infoPtr->szPadding.cx + sizeString.cx; + } + } + return sizeButton; +} + + +/*********************************************************************** * TOOLBAR_CalcToolbar * * This function calculates button and separator placement. It first @@ -1407,7 +1547,6 @@ * the tooltip window if appropriate. Finally, it updates the rcBound * rect and calculates the new required toolbar window height. */ - static void TOOLBAR_CalcToolbar (HWND hwnd) { @@ -1416,9 +1555,10 @@ TBUTTON_INFO *btnPtr; INT i, nRows, nSepRows; INT x, y, cx, cy; - SIZE sizeString; + SIZE sizeString, sizeButton; BOOL bWrap; BOOL usesBitmaps = FALSE; + BOOL validImageList = FALSE; BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle); TOOLBAR_CalcStrings (hwnd, &sizeString); @@ -1430,36 +1570,11 @@ if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap)) usesBitmaps = TRUE; } - if (dwStyle & TBSTYLE_LIST) - { - infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight : - 0, sizeString.cy) + infoPtr->szPadding.cy; - infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth : - LIST_IMAGE_ABSENT_WIDTH) + sizeString.cx + infoPtr->szPadding.cx; - if (sizeString.cx > 0) - infoPtr->nButtonWidth += TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap) + infoPtr->szPadding.cx/2; - TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n", - infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps, - infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); - } - else { - if (sizeString.cy > 0) - { - if (usesBitmaps) - infoPtr->nButtonHeight = sizeString.cy + - infoPtr->szPadding.cy/2 + /* this is the space to separate text from bitmap */ - infoPtr->nBitmapHeight + infoPtr->szPadding.cy; - else - infoPtr->nButtonHeight = sizeString.cy + infoPtr->szPadding.cy; - } - else - infoPtr->nButtonHeight = infoPtr->nBitmapHeight + infoPtr->szPadding.cy; - - if (sizeString.cx > infoPtr->nBitmapWidth) - infoPtr->nButtonWidth = sizeString.cx + infoPtr->szPadding.cx; - else - infoPtr->nButtonWidth = infoPtr->nBitmapWidth + infoPtr->szPadding.cx; - } + if (TOOLBAR_IsValidImageList(infoPtr, 0)) + validImageList = TRUE; + sizeButton = TOOLBAR_MeasureButton(infoPtr, sizeString, usesBitmaps, validImageList); + infoPtr->nButtonWidth = sizeButton.cx; + infoPtr->nButtonHeight = sizeButton.cy; if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin ) infoPtr->nButtonWidth = infoPtr->cxMin; @@ -1474,9 +1589,7 @@ /* from above, minimum is a button, and possible text */ cx = infoPtr->nButtonWidth; - /* cannot use just ButtonHeight, we may have no buttons! */ - if (infoPtr->nNumButtons > 0) - infoPtr->nHeight = infoPtr->nButtonHeight; + infoPtr->nHeight = infoPtr->nButtonHeight; cy = infoPtr->nHeight; @@ -1534,22 +1647,10 @@ SelectObject (hdc, hOldFont); ReleaseDC (hwnd, hdc); - /* add space on for button frame, etc */ - cx = sz.cx + infoPtr->szPadding.cx; - - /* add list padding */ - if ((dwStyle & TBSTYLE_LIST) && sz.cx > 0) - cx += TOOLBAR_GetListTextOffset(infoPtr, infoPtr->iListGap) + infoPtr->szPadding.cx/2; - - if (TOOLBAR_TestImageExist (infoPtr, btnPtr, GETDEFIMAGELIST(infoPtr,0))) - { - if (dwStyle & TBSTYLE_LIST) - cx += infoPtr->nBitmapWidth; - else if (cx < (infoPtr->nBitmapWidth+infoPtr->szPadding.cx)) - cx = infoPtr->nBitmapWidth+infoPtr->szPadding.cx; - } - else if (dwStyle & TBSTYLE_LIST) - cx += LIST_IMAGE_ABSENT_WIDTH; + sizeButton = TOOLBAR_MeasureButton(infoPtr, sz, + TOOLBAR_IsValidBitmapIndex(infoPtr, infoPtr->buttons[i].iBitmap), + validImageList); + cx = sizeButton.cx; } else cx = infoPtr->nButtonWidth; @@ -4934,10 +5035,11 @@ no_highlight = TOOLBAR_SendNotify(&nmhotitem.hdr, infoPtr, TBN_HOTITEMCHANGE); - /* now invalidate the old and new buttons so they will be painted */ - if (oldBtnPtr) + /* now invalidate the old and new buttons so they will be painted, + * but only if they are enabled - disabled buttons cannot become hot */ + if (oldBtnPtr && (oldBtnPtr->fsState & TBSTATE_ENABLED)) InvalidateRect(infoPtr->hwndSelf, &oldBtnPtr->rect, TRUE); - if (btnPtr && !no_highlight) + if (btnPtr && !no_highlight && (btnPtr->fsState & TBSTATE_ENABLED)) { btnPtr->bHot = TRUE; InvalidateRect(infoPtr->hwndSelf, &btnPtr->rect, TRUE); @@ -4990,8 +5092,8 @@ if (!ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth, &infoPtr->nBitmapHeight)) { - infoPtr->nBitmapWidth = 0; - infoPtr->nBitmapHeight = 0; + infoPtr->nBitmapWidth = 1; + infoPtr->nBitmapHeight = 1; } TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n", @@ -5089,6 +5191,7 @@ * to control the bottom and right borders [with the border being * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding * is shared evenly on both sides of the button. + * See blueprints in comments above TOOLBAR_MeasureButton for more info. */ static LRESULT TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam) @@ -5097,8 +5200,8 @@ DWORD oldPad; oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy); - infoPtr->szPadding.cx = LOWORD((DWORD)lParam); - infoPtr->szPadding.cy = HIWORD((DWORD)lParam); + infoPtr->szPadding.cx = min(LOWORD((DWORD)lParam), GetSystemMetrics(SM_CXEDGE)); + infoPtr->szPadding.cy = min(HIWORD((DWORD)lParam), GetSystemMetrics(SM_CYEDGE)); TRACE("cx=%ld, cy=%ld\n", infoPtr->szPadding.cx, infoPtr->szPadding.cy); return (LRESULT) oldPad; @@ -5487,7 +5590,7 @@ infoPtr->clrBtnShadow = CLR_DEFAULT; infoPtr->szPadding.cx = DEFPAD_CX; infoPtr->szPadding.cy = DEFPAD_CY; - infoPtr->iListGap = infoPtr->szPadding.cx / 2; + infoPtr->iListGap = DEFLISTGAP; infoPtr->dwStyle = dwStyle; infoPtr->tbim.iButton = -1; GetClientRect(hwnd, &infoPtr->client_rect); diff -urN wine-20050524/dlls/comctl32/treeview.c wine-20050628/dlls/comctl32/treeview.c --- wine-20050524/dlls/comctl32/treeview.c 2005-04-18 12:20:51.000000000 +0200 +++ wine-20050628/dlls/comctl32/treeview.c 2005-06-13 13:38:55.000000000 +0200 @@ -4221,6 +4221,11 @@ case TVGN_CARET: prevSelect = infoPtr->selectedItem; + if (prevSelect == newSelect) { + TREEVIEW_EnsureVisible(infoPtr, infoPtr->selectedItem, FALSE); + break; + } + if (TREEVIEW_SendTreeviewNotify(infoPtr, TVN_SELCHANGINGW, cause, diff -urN wine-20050524/dlls/comctl32/updown.c wine-20050628/dlls/comctl32/updown.c --- wine-20050524/dlls/comctl32/updown.c 2005-05-11 14:01:27.000000000 +0200 +++ wine-20050628/dlls/comctl32/updown.c 2005-06-16 17:52:44.000000000 +0200 @@ -238,7 +238,7 @@ * UPDOWN_GetThousandSep * Returns the thousand sep. If an error occurs, it returns ','. */ -static WCHAR UPDOWN_GetThousandSep() +static WCHAR UPDOWN_GetThousandSep(void) { WCHAR sep[2]; diff -urN wine-20050524/dlls/commdlg/filedlg.c wine-20050628/dlls/commdlg/filedlg.c --- wine-20050524/dlls/commdlg/filedlg.c 2005-05-09 21:33:24.000000000 +0200 +++ wine-20050628/dlls/commdlg/filedlg.c 2005-06-07 22:03:30.000000000 +0200 @@ -196,6 +196,9 @@ static void FILEDLG95_SHELL_Clean(HWND hwnd); static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd); +/* Functions used by the EDIT box */ +static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator); + /* Functions used by the filetype combo box */ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd); static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode); @@ -203,7 +206,7 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd); /* Functions used by the Look In combo box */ -static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo); +static void FILEDLG95_LOOKIN_Init(HWND hwndCombo); static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct); static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode); static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId); @@ -214,8 +217,7 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd); /* Miscellaneous tool functions */ -HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName); -HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName); +static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName); IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs); LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl); LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName); @@ -224,11 +226,10 @@ static void *MemAlloc(UINT size); static void MemFree(void *mem); -BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos); INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode); -HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed); +void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode); +static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed); static BOOL BrowseSelectedFolder(HWND hwnd); /*********************************************************************** @@ -241,7 +242,7 @@ * OUT : TRUE on success * FALSE on cancel, error, close or filename-does-not-fit-in-buffer. */ -BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos) +static BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos) { LRESULT lRes; @@ -511,6 +512,27 @@ return ret; } +/****************************************************************************** + * COMDLG32_GetDisplayNameOf [internal] + * + * Helper function to get the display name for a pidl. + */ +static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) { + LPSHELLFOLDER psfDesktop; + STRRET strret; + + if (FAILED(SHGetDesktopFolder(&psfDesktop))) + return FALSE; + + if (FAILED(IShellFolder_GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret))) { + IShellFolder_Release(psfDesktop); + return FALSE; + } + + IShellFolder_Release(psfDesktop); + return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH)); +} + /*********************************************************************** * ArrangeCtrlPositions [internal] * @@ -790,17 +812,16 @@ * Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog */ -HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode) +void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode) { FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr); TRACE("%p 0x%04x\n",hwndParentDlg, uCode); - if(!fodInfos) return 0; + if(!fodInfos) return; if(fodInfos->DlgInfos.hwndCustomDlg) { - HRESULT ret; TRACE("CALL NOTIFY for %x\n", uCode); if(fodInfos->unicode) { @@ -810,7 +831,7 @@ ofnNotify.hdr.code = uCode; ofnNotify.lpOFN = fodInfos->ofnInfos; ofnNotify.pszFile = NULL; - ret = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify); + SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify); } else { @@ -820,17 +841,15 @@ ofnNotify.hdr.code = uCode; ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos; ofnNotify.pszFile = NULL; - ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify); + SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify); } TRACE("RET NOTIFY\n"); - return ret; } - return TRUE; } -HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer) +static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer) { - UINT sizeUsed = 0, n, total; + INT_PTR sizeUsed = 0, n, total; LPWSTR lpstrFileList = NULL; WCHAR lpstrCurrentDir[MAX_PATH]; FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); @@ -841,7 +860,7 @@ return -1; /* get path and filenames */ - SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir); + COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrCurrentDir); n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' '); TRACE("path >%s< filespec >%s< %d files\n", @@ -890,9 +909,9 @@ return total; } -HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer) +static INT_PTR FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer) { - UINT sizeUsed = 0; + INT_PTR sizeUsed = 0; LPWSTR lpstrFileList = NULL; FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); @@ -922,37 +941,37 @@ * * Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages */ -HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); - if(!fodInfos) return -1; + WCHAR lpstrPath[MAX_PATH]; + INT_PTR retval; + + if(!fodInfos) return FALSE; switch(uMsg) { case CDM_GETFILEPATH: - return FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam); + retval = FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam); + break; case CDM_GETFOLDERPATH: TRACE("CDM_GETFOLDERPATH:\n"); - if( fodInfos->unicode ) + COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath); + if (lParam) { - WCHAR lpstrPath[MAX_PATH], *bufW = (LPWSTR)lParam; - SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath); - if (bufW) - lstrcpynW(bufW,lpstrPath,(int)wParam); - return strlenW(lpstrPath); - } - else - { - char lpstrPath[MAX_PATH], *bufA = (LPSTR)lParam; - SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath); - if (bufA) - lstrcpynA(bufA,lpstrPath,(int)wParam); - return strlen(lpstrPath); - } + if (fodInfos->unicode) + lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam); + else + WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1, + (LPSTR)lParam, (int)wParam, NULL, NULL); + } + retval = strlenW(lpstrPath); + break; case CDM_GETSPEC: - return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam); + retval = FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam); + break; case CDM_SETCONTROLTEXT: TRACE("CDM_SETCONTROLTEXT:\n"); @@ -963,13 +982,19 @@ else SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam ); } - return TRUE; + retval = TRUE; + break; case CDM_HIDECONTROL: case CDM_SETDEFEXT: FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n"); - return -1; + retval = -1; + break; + + default: + return FALSE; } + SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, retval); return TRUE; } @@ -1597,7 +1622,7 @@ ofn->lpstrFile[0] = '\0'; } - SHGetPathFromIDListW( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec ); + COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec ); if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) && ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) && @@ -1685,9 +1710,8 @@ * * If the function succeeds, the return value is nonzero. */ -#define ONOPEN_BROWSE 1 -#define ONOPEN_OPEN 2 -#define ONOPEN_SEARCH 3 +#define ONOPEN_OPEN 1 +#define ONOPEN_SEARCH 2 static void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText) { WCHAR strMsgTitle[MAX_PATH]; @@ -1714,15 +1738,15 @@ TRACE("hwnd=%p\n", hwnd); + if(BrowseSelectedFolder(hwnd)) + return FALSE; + /* get the files from the edit control */ nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, '\0'); /* try if the user selected a folder in the shellview */ if(nFileCount == 0) - { - BrowseSelectedFolder(hwnd); return FALSE; - } if(nFileCount > 1) { @@ -1742,14 +1766,10 @@ */ /* Get the current directory name */ - if (!SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile)) + if (!COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile)) { - /* we are in a special folder, default to desktop */ - if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile))) - { - /* last fallback */ - GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile); - } + /* last fallback */ + GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile); } PathAddBackslashW(lpstrPathAndFile); @@ -1787,7 +1807,7 @@ lpstrPathAndFile: cleaned up path */ - nOpenAction = ONOPEN_BROWSE; + nOpenAction = ONOPEN_OPEN; /* don't apply any checks with OFN_NOVALIDATE */ { @@ -1920,6 +1940,7 @@ int iPos; LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile); DWORD len; + IPersistFolder2 * ppf2; /* replace the current filter */ if(fodInfos->ShellInfos.lpstrCurrentFilter) @@ -1931,12 +1952,7 @@ /* set the filter cb to the extension when possible */ if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp))) CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, iPos); - } - /* fall through */ - case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */ - TRACE("ONOPEN_BROWSE\n"); - { - IPersistFolder2 * ppf2; + if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2))) { LPITEMIDLIST pidlCurrent; @@ -1946,10 +1962,11 @@ { IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE); } - else if( nOpenAction == ONOPEN_SEARCH ) + else { IShellView_Refresh(fodInfos->Shell.FOIShellView); } + SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE); COMDLG32_SHFree(pidlCurrent); } } @@ -1967,48 +1984,51 @@ fodInfos->ofnInfos->Flags &= ~OFN_READONLY; /* Attach the file extension with file name*/ - ext = PathFindExtensionW(lpstrPathAndFile); - if (! *ext) + + if(!PathIsDirectoryW(lpstrPathAndFile)) { - /* if no extension is specified with file name, then */ - /* attach the extension from file filter or default one */ + if((ext = PathFindExtensionW(lpstrPathAndFile)) == NULL) + { + /* if no extension is specified with file name, then */ + /* attach the extension from file filter or default one */ - WCHAR *filterExt = NULL; - LPWSTR lpstrFilter = NULL; - static const WCHAR szwDot[] = {'.',0}; - int PathLength = strlenW(lpstrPathAndFile); + WCHAR *filterExt = NULL; + LPWSTR lpstrFilter = NULL; + static const WCHAR szwDot[] = {'.',0}; + int PathLength = strlenW(lpstrPathAndFile); - /* Attach the dot*/ - strcatW(lpstrPathAndFile, szwDot); + /* Attach the dot*/ + strcatW(lpstrPathAndFile, szwDot); - /*Get the file extension from file type filter*/ - lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, - fodInfos->ofnInfos->nFilterIndex-1); - - if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */ - filterExt = PathFindExtensionW(lpstrFilter); - - if ( filterExt && *filterExt ) /* attach the file extension from file type filter*/ - strcatW(lpstrPathAndFile, filterExt + 1); - else if ( fodInfos->defext ) /* attach the default file extension*/ - strcatW(lpstrPathAndFile, fodInfos->defext); - - /* In Open dialog: if file does not exist try without extension */ - if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile)) - lpstrPathAndFile[PathLength] = '\0'; + /*Get the file extension from file type filter*/ + lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, + fodInfos->ofnInfos->nFilterIndex-1); + + if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */ + filterExt = PathFindExtensionW(lpstrFilter); + + if ( filterExt && *filterExt ) /* attach the file extension from file type filter*/ + strcatW(lpstrPathAndFile, filterExt + 1); + else if ( fodInfos->defext ) /* attach the default file extension*/ + strcatW(lpstrPathAndFile, fodInfos->defext); + + /* In Open dialog: if file does not exist try without extension */ + if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile)) + lpstrPathAndFile[PathLength] = '\0'; + } + + if (fodInfos->defext) /* add default extension */ + { + /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */ + if (*ext) + ext++; + if (!lstrcmpiW(fodInfos->defext, ext)) + fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT; + else + fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT; + } } - if (fodInfos->defext) /* add default extension */ - { - /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */ - if (*ext) - ext++; - if (!lstrcmpiW(fodInfos->defext, ext)) - fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT; - else - fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT; - } - /* In Save dialog: check if the file already exists */ if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG && fodInfos->ofnInfos->Flags & OFN_OVERWRITEPROMPT @@ -2208,6 +2228,7 @@ NULL, SBSP_PARENT))) { + SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE); return TRUE; } return FALSE; @@ -2229,6 +2250,7 @@ SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl); hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE); + SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE); COMDLG32_SHFree(pidl); return SUCCEEDED(hres); } @@ -2361,8 +2383,7 @@ } } else fodInfos->ofnInfos->nFilterIndex = 0; - - return NOERROR; + return S_OK; } /*********************************************************************** @@ -2465,7 +2486,7 @@ * * Initialisation of the look in combo box */ -static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo) +static void FILEDLG95_LOOKIN_Init(HWND hwndCombo) { IShellFolder *psfRoot, *psfDrives; IEnumIDList *lpeRoot, *lpeDrives; @@ -2532,7 +2553,6 @@ } COMDLG32_SHFree(pidlDrives); - return NOERROR; } /*********************************************************************** @@ -2680,6 +2700,7 @@ tmpFolder->pidlItem, SBSP_ABSOLUTE))) { + SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE); return TRUE; } break; @@ -3009,7 +3030,9 @@ } -/* copied from shell32 to avoid linking to it */ +/* copied from shell32 to avoid linking to it + * FIXME: why? shell32 is already linked + */ static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl) { switch (src->uType) @@ -3033,7 +3056,7 @@ { *(LPSTR)dest = '\0'; } - return(FALSE); + return(E_FAIL); } return S_OK; } @@ -3045,7 +3068,7 @@ * The delimiter is specified by the parameter 'separator', * usually either a space or a nul */ -int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator) +static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator) { FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr); UINT nStrCharCount = 0; /* index in src buffer */ @@ -3211,7 +3234,7 @@ * E_FAIL otherwise */ -HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName) +static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName) { STRRET str; HRESULT hRes; @@ -3351,8 +3374,8 @@ ' ','n','o','t',' ','e','x','i','s','t',0}; MessageBoxW( hwnd, notexist, fodInfos->title, MB_OK | MB_ICONEXCLAMATION ); } - - bBrowseSelFolder = TRUE; + bBrowseSelFolder = TRUE; + SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE); } COMDLG32_SHFree( pidlSelection ); } diff -urN wine-20050524/dlls/commdlg/filedlgbrowser.c wine-20050628/dlls/commdlg/filedlgbrowser.c --- wine-20050524/dlls/commdlg/filedlgbrowser.c 2005-05-12 11:56:17.000000000 +0200 +++ wine-20050628/dlls/commdlg/filedlgbrowser.c 2005-06-07 22:03:30.000000000 +0200 @@ -47,9 +47,9 @@ typedef struct { - IShellBrowserVtbl * lpVtbl; - ICommDlgBrowserVtbl * lpVtblCommDlgBrowser; - IServiceProviderVtbl* lpVtblServiceProvider; + const IShellBrowserVtbl *lpVtbl; + const ICommDlgBrowserVtbl *lpVtblCommDlgBrowser; + const IServiceProviderVtbl *lpVtblServiceProvider; DWORD ref; /* Reference counter */ HWND hwndOwner; /* Owner dialog of the interface */ @@ -58,9 +58,9 @@ /************************************************************************** * vtable */ -static IShellBrowserVtbl IShellBrowserImpl_Vtbl; -static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl; -static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl; +static const IShellBrowserVtbl IShellBrowserImpl_Vtbl; +static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl; +static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl; /************************************************************************** * Local Prototypes @@ -76,19 +76,12 @@ */ extern const char *FileOpenDlgInfosStr; -extern HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName); -extern HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName); extern IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs); extern LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl); extern LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPCSTR lpcstrFileName); -extern BOOL FILEDLG95_SHELL_FillIncludedItemList(HWND hwnd, - LPITEMIDLIST pidlCurrentFolder, - LPSTR lpstrMask); - extern int FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl); -extern BOOL FILEDLG95_OnOpen(HWND hwnd); -extern HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode); +extern void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode); /* @@ -140,11 +133,25 @@ static void COMDLG32_UpdateCurrentDir(FileOpenDlgInfos *fodInfos) { - char lpstrPath[MAX_PATH]; - if(SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath)) { - SetCurrentDirectoryA(lpstrPath); - TRACE("new current folder %s\n", lpstrPath); + LPSHELLFOLDER psfDesktop; + STRRET strret; + HRESULT res; + + res = SHGetDesktopFolder(&psfDesktop); + if (FAILED(res)) + return; + + res = IShellFolder_GetDisplayNameOf(psfDesktop, fodInfos->ShellInfos.pidlAbsCurrent, + SHGDN_FORPARSING, &strret); + if (SUCCEEDED(res)) { + WCHAR wszCurrentDir[MAX_PATH]; + + res = StrRetToBufW(&strret, fodInfos->ShellInfos.pidlAbsCurrent, wszCurrentDir, MAX_PATH); + if (SUCCEEDED(res)) + SetCurrentDirectoryW(wszCurrentDir); } + + IShellFolder_Release(psfDesktop); } /* copied from shell32 to avoid linking to it */ @@ -675,7 +682,7 @@ return E_NOTIMPL; } -static IShellBrowserVtbl IShellBrowserImpl_Vtbl = +static const IShellBrowserVtbl IShellBrowserImpl_Vtbl = { /* IUnknown */ IShellBrowserImpl_QueryInterface, @@ -900,7 +907,7 @@ return S_OK; } -static ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl = +static const ICommDlgBrowserVtbl IShellBrowserImpl_ICommDlgBrowser_Vtbl = { /* IUnknown */ IShellBrowserImpl_ICommDlgBrowser_QueryInterface, @@ -989,7 +996,7 @@ } -static IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl = +static const IServiceProviderVtbl IShellBrowserImpl_IServiceProvider_Vtbl = { /* IUnknown */ IShellBrowserImpl_IServiceProvider_QueryInterface, diff -urN wine-20050524/dlls/commdlg/filedlgbrowser.h wine-20050628/dlls/commdlg/filedlgbrowser.h --- wine-20050524/dlls/commdlg/filedlgbrowser.h 2005-01-10 14:22:35.000000000 +0100 +++ wine-20050628/dlls/commdlg/filedlgbrowser.h 2005-06-07 22:03:30.000000000 +0200 @@ -161,6 +161,5 @@ /* Functions used by the EDIT box */ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd); -int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator); #endif /*SHBROWSER_H*/ diff -urN wine-20050524/dlls/commdlg/printdlg.c wine-20050628/dlls/commdlg/printdlg.c --- wine-20050524/dlls/commdlg/printdlg.c 2005-04-18 12:01:07.000000000 +0200 +++ wine-20050628/dlls/commdlg/printdlg.c 2005-06-23 18:45:39.000000000 +0200 @@ -1945,11 +1945,6 @@ * PrintDlg: * * The Collate Icons do not display, even though they are in the code. * * The Properties Button(s) should call DocumentPropertiesA(). - * PrintSetupDlg: - * * The Paper Orientation Icons are not implemented yet. - * * The Properties Button(s) should call DocumentPropertiesA(). - * * Settings are not yet taken from a provided DevMode or - * default printer settings. */ BOOL WINAPI PrintDlgA( @@ -2266,6 +2261,7 @@ * PageSetupDlg * rad1 - portrait * rad2 - landscape + * cmb1 - printer select (not in standart dialog template) * cmb2 - paper size * cmb3 - source (tray?) * edt4 - border left @@ -2609,24 +2605,153 @@ } -static LRESULT CALLBACK -PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +/*********************************************************************** + * DefaultPagePaintHook + * Default hook paint procedure that receives WM_PSD_* messages from the dialog box + * whenever the sample page is redrawn. +*/ + +static UINT_PTR +PRINTDLG_DefaultPagePaintHook(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PageSetupDataA *pda) { - if (uMsg == WM_PAINT) - { - PAINTSTRUCT ps; - RECT rcClient; - HPEN hpen, holdpen; - HDC hdc; - HFONT hfont, holdfont; - LOGFONTW lf; - HBRUSH hbrush, holdbrush; - INT oldbkmode; + LPRECT lprc = (LPRECT) lParam; + HDC hdc = (HDC) wParam; + HPEN hpen, holdpen; + LOGFONTW lf; + HFONT hfont, holdfont; + INT oldbkmode; + TRACE("uMsg: WM_USER+%d\n",uMsg-WM_USER); + + /* Call user paint hook if enable */ + if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) + if (pda->dlga->lpfnPagePaintHook(hwndDlg, uMsg, wParam, lParam)) + return TRUE; + + switch (uMsg) { + /* LPPAGESETUPDLG in lParam */ + case WM_PSD_PAGESETUPDLG: + /* Inform about the sample page rectangle */ + case WM_PSD_FULLPAGERECT: + /* Inform about the margin rectangle */ + case WM_PSD_MINMARGINRECT: + return FALSE; + + /* Draw dashed rectangle showing margins */ + case WM_PSD_MARGINRECT: + hpen = CreatePen(PS_DASH, 1, GetSysColor(COLOR_3DSHADOW)); + holdpen = SelectObject(hdc, hpen); + Rectangle(hdc, lprc->left, lprc->top, lprc->right, lprc->bottom); + DeleteObject(SelectObject(hdc, holdpen)); + return TRUE; + + + /* Draw the fake document */ + case WM_PSD_GREEKTEXTRECT: + /* select a nice scalable font, because we want the text really small */ + SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0); + lf.lfHeight = 6; /* value chosen based on visual effect */ + hfont = CreateFontIndirectW(&lf); + holdfont = SelectObject(hdc, hfont); + + /* if text not loaded, then do so now */ + if (wszFakeDocumentText[0] == '\0') + LoadStringW(COMDLG32_hInstance, + IDS_FAKEDOCTEXT, + wszFakeDocumentText, + sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0])); - hdc = BeginPaint(hWnd, &ps); + oldbkmode = SetBkMode(hdc, TRANSPARENT); + DrawTextW(hdc, wszFakeDocumentText, -1, lprc, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK); + SetBkMode(hdc, oldbkmode); + + DeleteObject(SelectObject(hdc, holdfont)); + return TRUE; + + /* Envelope stamp */ + case WM_PSD_ENVSTAMPRECT: + /* Return address */ + case WM_PSD_YAFULLPAGERECT: + FIXME("envelope/stamp is not implemented\n"); + return FALSE; + default: + FIXME("Unknown message %x\n",uMsg); + return FALSE; + } + return TRUE; +} - GetClientRect(hWnd, &rcClient); +/*********************************************************************** + * PagePaintProc + * The main paint procedure for the PageSetupDlg function. + * The Page Setup dialog box includes an image of a sample page that shows how + * the user's selections affect the appearance of the printed output. + * The image consists of a rectangle that represents the selected paper + * or envelope type, with a dotted-line rectangle representing + * the current margins, and partial (Greek text) characters + * to show how text looks on the printed page. + * + * The following messages in the order sends to user hook procedure: + * WM_PSD_PAGESETUPDLG Draw the contents of the sample page + * WM_PSD_FULLPAGERECT Inform about the bounding rectangle + * WM_PSD_MINMARGINRECT Inform about the margin rectangle (min margin?) + * WM_PSD_MARGINRECT Draw the margin rectangle + * WM_PSD_GREEKTEXTRECT Draw the Greek text inside the margin rectangle + * If any of first three messages returns TRUE, painting done. + * + * PARAMS: + * hWnd [in] Handle to the Page Setup dialog box + * uMsg [in] Received message + * + * TODO: + * WM_PSD_ENVSTAMPRECT Draw in the envelope-stamp rectangle (for envelopes only) + * WM_PSD_YAFULLPAGERECT Draw the return address portion (for envelopes and other paper sizes) + * + * RETURNS: + * FALSE if all done correctly + * + */ +static LRESULT CALLBACK +PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT ps; + RECT rcClient, rcMargin; + HPEN hpen, holdpen; + HDC hdc; + HBRUSH hbrush, holdbrush; + PageSetupDataA *pda; + int papersize=0, orientation=0; /* FIXME: set this values */ + +#define CALLPAINTHOOK(msg,lprc) PRINTDLG_DefaultPagePaintHook( hWnd, msg, (WPARAM)hdc, (LPARAM)lprc, pda) + + if (uMsg != WM_PAINT) + return CallWindowProcA(lpfnStaticWndProc, hWnd, uMsg, wParam, lParam); + + /* Processing WM_PAINT message */ + pda = (PageSetupDataA*)GetPropA(hWnd, "__WINE_PAGESETUPDLGDATA"); + if (!pda) { + WARN("__WINE_PAGESETUPDLGDATA prop not set?\n"); + return FALSE; + } + if (PRINTDLG_DefaultPagePaintHook(hWnd, WM_PSD_PAGESETUPDLG, MAKELONG(papersize, orientation), (LPARAM)pda->dlga, pda)) + return FALSE; + + hdc = BeginPaint(hWnd, &ps); + GetClientRect(hWnd, &rcClient); + + /* FIXME: use real margin values */ + rcMargin = rcClient; + rcMargin.left += 5; + rcMargin.top += 5; + rcMargin.right -= 5; + rcMargin.bottom -= 5; + + /* if the space is too small then we make sure to not draw anything */ + rcMargin.left = min(rcMargin.left, rcMargin.right); + rcMargin.top = min(rcMargin.top, rcMargin.bottom); + if (!CALLPAINTHOOK(WM_PSD_FULLPAGERECT, &rcClient) && + !CALLPAINTHOOK(WM_PSD_MINMARGINRECT, &rcMargin) ) + { /* fill background */ hbrush = GetSysColorBrush(COLOR_3DHIGHLIGHT); FillRect(hdc, &rcClient, hbrush); @@ -2635,6 +2760,7 @@ hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW)); holdpen = SelectObject(hdc, hpen); + /* paint left edge */ MoveToEx(hdc, rcClient.left, rcClient.top, NULL); LineTo(hdc, rcClient.left, rcClient.bottom-1); @@ -2654,79 +2780,51 @@ MoveToEx(hdc, rcClient.left, rcClient.bottom-1, NULL); LineTo(hdc, rcClient.right, rcClient.bottom-1); - hpen = CreatePen(PS_DASH, 1, GetSysColor(COLOR_3DSHADOW)); - DeleteObject(SelectObject(hdc, hpen)); - - /* draw dashed rectangle showing margins */ - - /* FIXME: use real margin values */ - rcClient.left += 5; - rcClient.top += 5; - rcClient.right -= 5; - rcClient.bottom -= 5; - - /* if the space is too small then we make sure to not draw anything */ - rcClient.left = min(rcClient.left,rcClient.right); - rcClient.top = min(rcClient.top,rcClient.bottom); + DeleteObject(SelectObject(hdc, holdpen)); + DeleteObject(SelectObject(hdc, holdbrush)); - Rectangle(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); - DeleteObject(SelectObject(hdc, holdpen)); + CALLPAINTHOOK(WM_PSD_MARGINRECT, &rcMargin); - /* draw the fake document */ /* give text a bit of a space from the frame */ - rcClient.left += 2; - rcClient.top += 2; - rcClient.right -= 2; - rcClient.bottom -= 2; - + rcMargin.left += 2; + rcMargin.top += 2; + rcMargin.right -= 2; + rcMargin.bottom -= 2; + /* if the space is too small then we make sure to not draw anything */ - rcClient.left = min(rcClient.left,rcClient.right); - rcClient.top = min(rcClient.top,rcClient.bottom); - - /* select a nice scalable font, because we want the text really small */ - SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0); - lf.lfHeight = 6; /* value chosen based on visual effect */ - hfont = CreateFontIndirectW(&lf); - holdfont = SelectObject(hdc, hfont); - - /* if text not loaded, then do so now */ - if (wszFakeDocumentText[0] == '\0') - LoadStringW(COMDLG32_hInstance, - IDS_FAKEDOCTEXT, - wszFakeDocumentText, - sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0])); - - oldbkmode = SetBkMode(hdc, TRANSPARENT); - DrawTextW(hdc, wszFakeDocumentText, -1, &rcClient, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK); - SetBkMode(hdc, oldbkmode); + rcMargin.left = min(rcMargin.left, rcMargin.right); + rcMargin.top = min(rcMargin.top, rcMargin.bottom); - DeleteObject(SelectObject(hdc, holdfont)); - - SelectObject(hdc, holdbrush); - - EndPaint(hWnd, &ps); - return 0; + CALLPAINTHOOK(WM_PSD_GREEKTEXTRECT, &rcMargin); } - else - return CallWindowProcW(lpfnStaticWndProc, hWnd, uMsg, wParam, lParam); + + EndPaint(hWnd, &ps); + return FALSE; +#undef CALLPAINTHOOK } +/*********************************************************************** + * PRINTDLG_PageDlgProcA + * Message handler + */ static INT_PTR CALLBACK -PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +PRINTDLG_PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PageSetupDataA *pda; INT_PTR res = FALSE; - if (uMsg==WM_INITDIALOG) { + if (uMsg == WM_INITDIALOG) { + pda = (PageSetupDataA*)lParam; + TRACE("set property to %p", pda); + SetPropA(hDlg, "__WINE_PAGESETUPDLGDATA", pda); + SetPropA(GetDlgItem(hDlg, rct1), "__WINE_PAGESETUPDLGDATA", pda); lpfnStaticWndProc = (WNDPROC)SetWindowLongPtrW( GetDlgItem(hDlg, rct1), GWLP_WNDPROC, - (ULONG_PTR)PagePaintProc); + (ULONG_PTR)PRINTDLG_PagePaintProc); res = TRUE; - pda = (PageSetupDataA*)lParam; - SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",pda); if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) { res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,(LPARAM)pda->dlga); if (!res) { @@ -2734,9 +2832,7 @@ res = TRUE; } } - if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) { - FIXME("PagePaintHook not yet implemented!\n"); - } + if (pda->dlga->Flags & PSD_DISABLEPRINTER) EnableWindow(GetDlgItem(hDlg, psh3), FALSE); if (pda->dlga->Flags & PSD_DISABLEMARGINS) { @@ -2886,7 +2982,29 @@ /*********************************************************************** * PageSetupDlgA (COMDLG32.@) + * + * Displays the the PAGE SETUP dialog box, which enables the user to specify + * specific properties of a printed page such as + * size, source, orientation and the width of the page margins. + * + * PARAMS + * setupdlg [in] PAGESETUPDLGA struct + * + * RETURNS + * TRUE if the user pressed the OK button + * FALSE if the user cancelled the window or an error occurred + * + * NOTES + * The values of hDevMode and hDevNames are filled on output and can be + * changed in PAGESETUPDLG when they are passed in PageSetupDlg. + * BUGS + * PrintSetupDlg: + * * The Paper Orientation Icons are not implemented yet. + * * The Properties Button(s) should call DocumentPropertiesA(). + * * Settings are not yet taken from a provided DevMode or + * default printer settings. */ + BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) { HGLOBAL hDlgTmpl; LPVOID ptr; @@ -2909,6 +3027,11 @@ setupdlg->hDevNames, setupdlg->hInstance, setupdlg->Flags, flagstr); } + if (setupdlg->Flags & PSD_ENABLEPAGEPAINTHOOK) + if (setupdlg->lpfnPagePaintHook == NULL) { + COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK); + return FALSE; + } /* First get default printer data, we need it right after that. */ memset(&pdlg,0,sizeof(pdlg)); @@ -2945,7 +3068,7 @@ setupdlg->hInstance, ptr, setupdlg->hwndOwner, - PageDlgProcA, + PRINTDLG_PageDlgProcA, (LPARAM)pda) ); return bRet; @@ -2959,7 +3082,7 @@ BOOL bRet; PageSetupDataW *pdw; PRINTDLGW pdlg; - + FIXME("Unicode implementation is not done yet\n"); if(TRACE_ON(commdlg)) { char flagstr[1000] = ""; struct pd_flags *pflag = psd_flags; diff -urN wine-20050524/dlls/crypt32/cert.c wine-20050628/dlls/crypt32/cert.c --- wine-20050524/dlls/crypt32/cert.c 2004-11-10 02:31:50.000000000 +0100 +++ wine-20050628/dlls/crypt32/cert.c 2005-06-03 13:25:38.000000000 +0200 @@ -1,6 +1,6 @@ /* * Copyright 2002 Mike McCormack for CodeWeavers - * Copyright (C) 2004 Juan Lang + * Copyright 2004,2005 Juan Lang * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -54,10 +54,14 @@ FIXME("%s %08lx %08lx %08lx %p stub\n", debugstr_a(lpszStoreProvider), dwMsgAndCertEncodingType, hCryptProv, dwFlags, pvPara); - if( lpszStoreProvider == (LPCSTR) 0x0009 ) + if( lpszStoreProvider == CERT_STORE_PROV_SYSTEM_A ) { FIXME("pvPara = %s\n", debugstr_a( (LPCSTR) pvPara ) ); } + else if ( lpszStoreProvider == CERT_STORE_PROV_SYSTEM_W ) + { + FIXME("pvPara = %s\n", debugstr_w( (LPCWSTR) pvPara ) ); + } hcs = HeapAlloc( GetProcessHeap(), 0, sizeof (WINECRYPT_CERTSTORE) ); if( !hcs ) @@ -71,15 +75,17 @@ HCERTSTORE WINAPI CertOpenSystemStoreA(HCRYPTPROV hProv, LPCSTR szSubSystemProtocol) { - FIXME("(%ld, %s), stub\n", hProv, debugstr_a(szSubSystemProtocol)); - return (HCERTSTORE)1; + return CertOpenStore( CERT_STORE_PROV_SYSTEM_A, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER | CERT_SYSTEM_STORE_LOCAL_MACHINE | + CERT_SYSTEM_STORE_USERS, szSubSystemProtocol ); } HCERTSTORE WINAPI CertOpenSystemStoreW(HCRYPTPROV hProv, LPCWSTR szSubSystemProtocol) { - FIXME("(%ld, %s), stub\n", hProv, debugstr_w(szSubSystemProtocol)); - return (HCERTSTORE)1; + return CertOpenStore( CERT_STORE_PROV_SYSTEM_W, 0, 0, + CERT_SYSTEM_STORE_CURRENT_USER | CERT_SYSTEM_STORE_LOCAL_MACHINE | + CERT_SYSTEM_STORE_USERS, szSubSystemProtocol ); } PCCERT_CONTEXT WINAPI CertEnumCertificatesInStore(HCERTSTORE hCertStore, PCCERT_CONTEXT pPrev) @@ -142,10 +148,16 @@ BOOL WINAPI CertCloseStore( HCERTSTORE hCertStore, DWORD dwFlags ) { + WINECRYPT_CERTSTORE *hcs = (WINECRYPT_CERTSTORE *) hCertStore; + FIXME("%p %08lx\n", hCertStore, dwFlags ); if( ! hCertStore ) return FALSE; + if ( hcs->dwMagic != WINE_CRYPTCERTSTORE_MAGIC ) + return FALSE; + + hcs->dwMagic = 0; HeapFree( GetProcessHeap(), 0, hCertStore ); return TRUE; diff -urN wine-20050524/dlls/crypt32/crypt32.spec wine-20050628/dlls/crypt32/crypt32.spec --- wine-20050524/dlls/crypt32/crypt32.spec 2005-05-20 21:37:26.000000000 +0200 +++ wine-20050628/dlls/crypt32/crypt32.spec 2005-06-22 20:38:24.000000000 +0200 @@ -9,7 +9,7 @@ @ stub CertAddEnhancedKeyUsageIdentifier @ stub CertAddSerializedElementToStore @ stub CertAddStoreToCollection -@ stub CertAlgIdToOID +@ stdcall CertAlgIdToOID(long) @ stdcall CertCloseStore(ptr long) @ stub CertCompareCertificate @ stub CertCompareCertificateName @@ -46,17 +46,17 @@ @ stub CertGetCRLContextProperty @ stub CertGetCRLFromStore @ stub CertGetCTLContextProperty +@ stub CertGetCertificateChain @ stub CertGetCertificateContextProperty @ stub CertGetEnhancedKeyUsage @ stub CertGetIntendedKeyUsage @ stub CertGetIssuerCertificateFromStore @ stub CertGetPublicKeyLength -@ stub CertGetCertificateChain @ stub CertGetSubjectCertificateFromStore @ stub CertIsRDNAttrsInCertificateName @ stub CertNameToStrA @ stub CertNameToStrW -@ stub CertOIDToAlgId +@ stdcall CertOIDToAlgId(str) @ stdcall CertOpenStore(str long long long ptr) @ stdcall CertOpenSystemStoreA(long str) @ stdcall CertOpenSystemStoreW(long wstr) @@ -90,7 +90,7 @@ @ stub CryptDecryptAndVerifyMessageSignature @ stub CryptDecryptMessage @ stdcall CryptEncodeObject(long str ptr ptr ptr) -@ stdcall CryptEncodeObjectEx(long str ptr long ptr ptr) +@ stdcall CryptEncodeObjectEx(long str ptr long ptr ptr ptr) @ stub CryptEncryptMessage @ stub CryptEnumOIDFunction @ stub CryptEnumOIDInfo @@ -143,7 +143,7 @@ @ stdcall CryptSIPRemoveProvider(ptr) @ stdcall CryptSIPRetrieveSubjectGuid(wstr long ptr) @ stub CryptSetAsyncParam -@ stub CryptSetOIDFunctionValue +@ stdcall CryptSetOIDFunctionValue(long str str wstr long ptr long) @ stub CryptSetProviderU @ stub CryptSignAndEncodeCertificate @ stub CryptSignAndEncryptMessage diff -urN wine-20050524/dlls/crypt32/encode.c wine-20050628/dlls/crypt32/encode.c --- wine-20050524/dlls/crypt32/encode.c 2005-05-20 21:37:26.000000000 +0200 +++ wine-20050628/dlls/crypt32/encode.c 2005-06-27 21:48:24.000000000 +0200 @@ -15,17 +15,71 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * This file implements ASN.1 DER encoding and decoding of a limited set of + * types. It isn't a full ASN.1 implementation. Microsoft implements BER + * encoding of many of the basic types in msasn1.dll, but that interface is + * undocumented, so I implement them here. + * + * References: + * "A Layman's Guide to a Subset of ASN.1, BER, and DER", by Burton Kaliski + * (available online, look for a PDF copy as the HTML versions tend to have + * translation errors.) + * + * RFC3280, http://www.faqs.org/rfcs/rfc3280.html + * + * MSDN, especially: + * http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cryptencodeobject_and_cryptdecodeobject.asp */ #include #include +#include #include "windef.h" #include "winbase.h" +#include "excpt.h" #include "wincrypt.h" #include "winreg.h" +#include "snmp.h" #include "wine/debug.h" +#include "wine/exception.h" + +/* a few asn.1 tags we need */ +#define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) +#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) +#define ASN_OCTETSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04) +#define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a) +#define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11) +#define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12) +#define ASN_PRINTABLESTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x13) +#define ASN_IA5STRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x16) +#define ASN_UTCTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x17) +#define ASN_GENERALTIME (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x18) WINE_DEFAULT_DEBUG_CHANNEL(crypt); +static const WCHAR szDllName[] = { 'D','l','l',0 }; + +static BOOL WINAPI CRYPT_AsnEncodeInt(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnEncodeInteger(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded); +static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); +static BOOL WINAPI CRYPT_AsnDecodeInteger(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo); + +/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + static char *CRYPT_GetKeyName(DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID) { @@ -65,28 +119,28 @@ LPCSTR pszOID, LPCWSTR pwszDll, LPCSTR pszOverrideFuncName) { LONG r; - static const WCHAR szDllName[] = { 'D','l','l',0 }; HKEY hKey; LPSTR szKey; TRACE("%lx %s %s %s %s\n", dwEncodingType, pszFuncName, pszOID, debugstr_w(pwszDll), pszOverrideFuncName); - /* MSDN states dwEncodingType is a mask, but it isn't really treated as - * such. Values 65536 or greater are ignored. - */ - if (dwEncodingType >= PKCS_7_ASN_ENCODING) + /* This only registers functions for encoding certs, not messages */ + if (!GET_CERT_ENCODING_TYPE(dwEncodingType)) + return TRUE; + + /* Native does nothing pwszDll is NULL */ + if (!pwszDll) return TRUE; /* I'm not matching MS bug for bug here, because I doubt any app depends on * it: - * - native does nothing if pwszDll is NULL * - native "succeeds" if pszFuncName is NULL, but the nonsensical entry * it creates would never be used * - native returns an HRESULT rather than a Win32 error if pszOID is NULL. - * Instead I disallow all of these with ERROR_INVALID_PARAMETER. + * Instead I disallow both of these with ERROR_INVALID_PARAMETER. */ - if (!pszFuncName || !pszOID || !pwszDll) + if (!pszFuncName || !pszOID) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; @@ -122,7 +176,7 @@ TRACE("%lx %s %s\n", dwEncodingType, pszFuncName, pszOID); - if (dwEncodingType >= PKCS_7_ASN_ENCODING) + if (!GET_CERT_ENCODING_TYPE(dwEncodingType)) return TRUE; if (!pszFuncName || !pszOID) @@ -133,49 +187,2779 @@ szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID); rc = RegDeleteKeyA(HKEY_LOCAL_MACHINE, szKey); - if (!rc) + HeapFree(GetProcessHeap(), 0, szKey); + if (rc) + SetLastError(rc); + return rc ? FALSE : TRUE; +} + +BOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName, + LPCSTR pszOID, LPCWSTR pwszValueName, DWORD *pdwValueType, BYTE *pbValueData, + DWORD *pcbValueData) +{ + LPSTR szKey; + LONG rc; + HKEY hKey; + + TRACE("%lx %s %s %s %p %p %p\n", dwEncodingType, debugstr_a(pszFuncName), + debugstr_a(pszOID), debugstr_w(pwszValueName), pdwValueType, pbValueData, + pcbValueData); + + if (!GET_CERT_ENCODING_TYPE(dwEncodingType)) + return TRUE; + + if (!pszFuncName || !pszOID || !pwszValueName) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID); + rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey); + HeapFree(GetProcessHeap(), 0, szKey); + if (rc) + SetLastError(rc); + else + { + rc = RegQueryValueExW(hKey, pwszValueName, NULL, pdwValueType, + pbValueData, pcbValueData); + if (rc) + SetLastError(rc); + RegCloseKey(hKey); + } + return rc ? FALSE : TRUE; +} + +BOOL WINAPI CryptSetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName, + LPCSTR pszOID, LPCWSTR pwszValueName, DWORD dwValueType, + const BYTE *pbValueData, DWORD cbValueData) +{ + LPSTR szKey; + LONG rc; + HKEY hKey; + + TRACE("%lx %s %s %s %ld %p %ld\n", dwEncodingType, debugstr_a(pszFuncName), + debugstr_a(pszOID), debugstr_w(pwszValueName), dwValueType, pbValueData, + cbValueData); + + if (!GET_CERT_ENCODING_TYPE(dwEncodingType)) + return TRUE; + + if (!pszFuncName || !pszOID || !pwszValueName) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + szKey = CRYPT_GetKeyName(dwEncodingType, pszFuncName, pszOID); + rc = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey); + HeapFree(GetProcessHeap(), 0, szKey); + if (rc) SetLastError(rc); + else + { + rc = RegSetValueExW(hKey, pwszValueName, 0, dwValueType, pbValueData, + cbValueData); + if (rc) + SetLastError(rc); + RegCloseKey(hKey); + } return rc ? FALSE : TRUE; } +/* Gets the registered function named szFuncName for dwCertEncodingType and + * lpszStructType, or NULL if one could not be found. *lib will be set to the + * handle of the module it's in, or NULL if no module was loaded. If the + * return value is NULL, *lib will also be NULL, to simplify error handling. + */ +static void *CRYPT_GetFunc(DWORD dwCertEncodingType, LPCSTR lpszStructType, + LPCSTR szFuncName, HMODULE *lib) +{ + void *ret = NULL; + char *szKey = CRYPT_GetKeyName(dwCertEncodingType, szFuncName, + lpszStructType); + const char *funcName; + long r; + HKEY hKey; + DWORD type, size = 0; + + TRACE("(%08lx %s %s %p)\n", dwCertEncodingType, debugstr_a(lpszStructType), + debugstr_a(szFuncName), lib); + + *lib = NULL; + r = RegOpenKeyA(HKEY_LOCAL_MACHINE, szKey, &hKey); + HeapFree(GetProcessHeap(), 0, szKey); + if(r != ERROR_SUCCESS) + return NULL; + + RegQueryValueExA(hKey, "FuncName", NULL, &type, NULL, &size); + if (GetLastError() == ERROR_MORE_DATA && type == REG_SZ) + { + funcName = HeapAlloc(GetProcessHeap(), 0, size); + RegQueryValueExA(hKey, "FuncName", NULL, &type, (LPBYTE)funcName, + &size); + } + else + funcName = szFuncName; + RegQueryValueExW(hKey, szDllName, NULL, &type, NULL, &size); + if (GetLastError() == ERROR_MORE_DATA && type == REG_SZ) + { + LPWSTR dllName = HeapAlloc(GetProcessHeap(), 0, size); + + RegQueryValueExW(hKey, szDllName, NULL, &type, (LPBYTE)dllName, + &size); + *lib = LoadLibraryW(dllName); + if (*lib) + { + ret = GetProcAddress(*lib, funcName); + if (!ret) + { + /* Unload the library, the caller doesn't want to unload it + * when the return value is NULL. + */ + FreeLibrary(*lib); + *lib = NULL; + } + } + HeapFree(GetProcessHeap(), 0, dllName); + } + if (funcName != szFuncName) + HeapFree(GetProcessHeap(), 0, (char *)funcName); + TRACE("returning %p\n", ret); + return ret; +} + +typedef BOOL (WINAPI *CryptEncodeObjectFunc)(DWORD, LPCSTR, const void *, + BYTE *, DWORD *); + BOOL WINAPI CryptEncodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const void *pvStructInfo, BYTE *pbEncoded, DWORD *pcbEncoded) { - FIXME("(0x%08lx, %s, %p, %p, %p): stub\n", + BOOL ret = FALSE; + HMODULE lib; + CryptEncodeObjectFunc pCryptEncodeObject; + + TRACE("(0x%08lx, %s, %p, %p, %p)\n", dwCertEncodingType, HIWORD(lpszStructType) ? debugstr_a(lpszStructType) : "(integer value)", pvStructInfo, pbEncoded, pcbEncoded); - return FALSE; + + if (!pbEncoded && !pcbEncoded) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + /* Try registered DLL first.. */ + pCryptEncodeObject = + (CryptEncodeObjectFunc)CRYPT_GetFunc(dwCertEncodingType, + lpszStructType, "CryptEncodeObject", &lib); + if (pCryptEncodeObject) + { + ret = pCryptEncodeObject(dwCertEncodingType, lpszStructType, + pvStructInfo, pbEncoded, pcbEncoded); + FreeLibrary(lib); + } + else + { + /* If not, use CryptEncodeObjectEx */ + ret = CryptEncodeObjectEx(dwCertEncodingType, lpszStructType, + pvStructInfo, 0, NULL, pbEncoded, pcbEncoded); + } + return ret; } -BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, - const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, +/* Helper function to check *pcbEncoded, set it to the required size, and + * optionally to allocate memory. Assumes pbEncoded is not NULL. + * If CRYPT_ENCODE_ALLOC_FLAG is set in dwFlags, *pbEncoded will be set to a + * pointer to the newly allocated memory. + */ +static BOOL CRYPT_EncodeEnsureSpace(DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded, + DWORD bytesNeeded) +{ + BOOL ret = TRUE; + + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + { + if (pEncodePara && pEncodePara->pfnAlloc) + *(BYTE **)pbEncoded = pEncodePara->pfnAlloc(bytesNeeded); + else + *(BYTE **)pbEncoded = LocalAlloc(0, bytesNeeded); + if (!*(BYTE **)pbEncoded) + ret = FALSE; + else + *pcbEncoded = bytesNeeded; + } + else if (bytesNeeded > *pcbEncoded) + { + *pcbEncoded = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + return ret; +} + +static BOOL CRYPT_EncodeLen(DWORD len, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + DWORD bytesNeeded, significantBytes = 0; + + if (len <= 0x7f) + bytesNeeded = 1; + else + { + DWORD temp; + + for (temp = len, significantBytes = sizeof(temp); !(temp & 0xff000000); + temp <<= 8, significantBytes--) + ; + bytesNeeded = significantBytes + 1; + } + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + return TRUE; + } + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + return FALSE; + } + if (len <= 0x7f) + *pbEncoded = (BYTE)len; + else + { + DWORD i; + + *pbEncoded++ = significantBytes | 0x80; + for (i = 0; i < significantBytes; i++) + { + *(pbEncoded + significantBytes - i - 1) = (BYTE)(len & 0xff); + len >>= 8; + } + } + *pcbEncoded = bytesNeeded; + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType, + LPCSTR pszObjId, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + DWORD bytesNeeded = 0, lenBytes; + BOOL ret = TRUE; + int firstPos = 0; + BYTE firstByte = 0; + + if (pszObjId) + { + const char *ptr; + int val1, val2; + + if (sscanf(pszObjId, "%d.%d.%n", &val1, &val2, &firstPos) != 2) + { + SetLastError(CRYPT_E_ASN1_ERROR); + return FALSE; + } + bytesNeeded++; + firstByte = val1 * 40 + val2; + ptr = pszObjId + firstPos; + while (ret && *ptr) + { + int pos; + + /* note I assume each component is at most 32-bits long in base 2 */ + if (sscanf(ptr, "%d%n", &val1, &pos) == 1) + { + if (val1 >= 0x10000000) + bytesNeeded += 5; + else if (val1 >= 0x200000) + bytesNeeded += 4; + else if (val1 >= 0x4000) + bytesNeeded += 3; + else if (val1 >= 0x80) + bytesNeeded += 2; + else + bytesNeeded += 1; + ptr += pos; + if (*ptr == '.') + ptr++; + } + else + { + SetLastError(CRYPT_E_ASN1_ERROR); + return FALSE; + } + } + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + } + else + lenBytes = 1; + bytesNeeded += 1 + lenBytes; + if (pbEncoded) + { + if (*pbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pbEncoded++ = ASN_OBJECTIDENTIFIER; + CRYPT_EncodeLen(bytesNeeded - 1 - lenBytes, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + if (pszObjId) + { + const char *ptr; + int val, pos; + + *pbEncoded++ = firstByte; + ptr = pszObjId + firstPos; + while (ret && *ptr) + { + sscanf(ptr, "%d%n", &val, &pos); + { + unsigned char outBytes[5]; + int numBytes, i; + + if (val >= 0x10000000) + numBytes = 5; + else if (val >= 0x200000) + numBytes = 4; + else if (val >= 0x4000) + numBytes = 3; + else if (val >= 0x80) + numBytes = 2; + else + numBytes = 1; + for (i = numBytes; i > 0; i--) + { + outBytes[i - 1] = val & 0x7f; + val >>= 7; + } + for (i = 0; i < numBytes - 1; i++) + *pbEncoded++ = outBytes[i] | 0x80; + *pbEncoded++ = outBytes[i]; + ptr += pos; + if (*ptr == '.') + ptr++; + } + } + } + } + } + *pcbEncoded = bytesNeeded; + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeNameValue(DWORD dwCertEncodingType, + CERT_NAME_VALUE *value, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BYTE tag; + DWORD bytesNeeded, lenBytes, encodedLen; + BOOL ret = TRUE; + + switch (value->dwValueType) + { + case CERT_RDN_NUMERIC_STRING: + tag = ASN_NUMERICSTRING; + encodedLen = value->Value.cbData; + break; + case CERT_RDN_PRINTABLE_STRING: + tag = ASN_PRINTABLESTRING; + encodedLen = value->Value.cbData; + break; + case CERT_RDN_IA5_STRING: + tag = ASN_IA5STRING; + encodedLen = value->Value.cbData; + break; + case CERT_RDN_ANY_TYPE: + /* explicitly disallowed */ + SetLastError(HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)); + return FALSE; + default: + FIXME("String type %ld unimplemented\n", value->dwValueType); + return FALSE; + } + CRYPT_EncodeLen(encodedLen, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + encodedLen; + if (pbEncoded) + { + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pbEncoded++ = tag; + CRYPT_EncodeLen(encodedLen, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + switch (value->dwValueType) + { + case CERT_RDN_NUMERIC_STRING: + case CERT_RDN_PRINTABLE_STRING: + case CERT_RDN_IA5_STRING: + memcpy(pbEncoded, value->Value.pbData, value->Value.cbData); + } + } + } + *pcbEncoded = bytesNeeded; + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeRdnAttr(DWORD dwCertEncodingType, + CERT_RDN_ATTR *attr, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + DWORD bytesNeeded = 0, lenBytes, size; + BOOL ret; + + ret = CRYPT_AsnEncodeOid(dwCertEncodingType, attr->pszObjId, NULL, &size); + if (ret) + { + bytesNeeded += size; + /* hack: a CERT_RDN_ATTR is identical to a CERT_NAME_VALUE beginning + * with dwValueType, so "cast" it to get its encoded size + */ + ret = CRYPT_AsnEncodeNameValue(dwCertEncodingType, + (CERT_NAME_VALUE *)&attr->dwValueType, NULL, &size); + if (ret) + { + bytesNeeded += size; + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (pbEncoded) + { + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + *pbEncoded++ = ASN_CONSTRUCTOR | ASN_SEQUENCE; + CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, + &lenBytes); + pbEncoded += lenBytes; + size = bytesNeeded - 1 - lenBytes; + ret = CRYPT_AsnEncodeOid(dwCertEncodingType, attr->pszObjId, + pbEncoded, &size); + if (ret) + { + pbEncoded += size; + size = bytesNeeded - 1 - lenBytes - size; + ret = CRYPT_AsnEncodeNameValue(dwCertEncodingType, + (CERT_NAME_VALUE *)&attr->dwValueType, pbEncoded, + &size); + } + } + } + *pcbEncoded = bytesNeeded; + } + } + return ret; +} + +static int BLOBComp(const void *l, const void *r) +{ + CRYPT_DER_BLOB *a = (CRYPT_DER_BLOB *)l, *b = (CRYPT_DER_BLOB *)r; + int ret; + + if (!(ret = memcmp(a->pbData, b->pbData, min(a->cbData, b->cbData)))) + ret = a->cbData - b->cbData; + return ret; +} + +/* This encodes as a SET OF, which in DER must be lexicographically sorted. + */ +static BOOL WINAPI CRYPT_AsnEncodeRdn(DWORD dwCertEncodingType, CERT_RDN *rdn, BYTE *pbEncoded, DWORD *pcbEncoded) { - FIXME("(0x%08lx, %s, %p, 0x%08lx, %p, %p, %p): stub\n", - dwCertEncodingType, HIWORD(lpszStructType) ? debugstr_a(lpszStructType) : - "(integer value)", pvStructInfo, dwFlags, pEncodePara, pbEncoded, - pcbEncoded); - return FALSE; + BOOL ret; + CRYPT_DER_BLOB *blobs = NULL; + + __TRY + { + DWORD bytesNeeded = 0, lenBytes, i; + + ret = TRUE; + if (rdn->cRDNAttr) + { + blobs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + rdn->cRDNAttr * sizeof(CRYPT_DER_BLOB)); + if (!blobs) + ret = FALSE; + } + for (i = 0; ret && i < rdn->cRDNAttr; i++) + { + ret = CRYPT_AsnEncodeRdnAttr(dwCertEncodingType, &rdn->rgRDNAttr[i], + NULL, &blobs[i].cbData); + if (ret) + bytesNeeded += blobs[i].cbData; + } + if (ret) + { + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (pbEncoded) + { + if (*pcbEncoded < bytesNeeded) + { + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + for (i = 0; ret && i < rdn->cRDNAttr; i++) + { + blobs[i].pbData = HeapAlloc(GetProcessHeap(), 0, + blobs[i].cbData); + if (!blobs[i].pbData) + ret = FALSE; + else + ret = CRYPT_AsnEncodeRdnAttr(dwCertEncodingType, + &rdn->rgRDNAttr[i], blobs[i].pbData, + &blobs[i].cbData); + } + if (ret) + { + qsort(blobs, rdn->cRDNAttr, sizeof(CRYPT_DER_BLOB), + BLOBComp); + *pbEncoded++ = ASN_CONSTRUCTOR | ASN_SETOF; + CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, + &lenBytes); + pbEncoded += lenBytes; + for (i = 0; ret && i < rdn->cRDNAttr; i++) + { + memcpy(pbEncoded, blobs[i].pbData, blobs[i].cbData); + pbEncoded += blobs[i].cbData; + } + } + } + } + *pcbEncoded = bytesNeeded; + } + if (blobs) + { + for (i = 0; i < rdn->cRDNAttr; i++) + HeapFree(GetProcessHeap(), 0, blobs[i].pbData); + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + HeapFree(GetProcessHeap(), 0, blobs); + return ret; } -BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, - const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, - DWORD *pcbStructInfo) +static BOOL WINAPI CRYPT_AsnEncodeName(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) { - FIXME("(0x%08lx, %s, %p, %ld, 0x%08lx, %p, %p): stub\n", - dwCertEncodingType, HIWORD(lpszStructType) ? debugstr_a(lpszStructType) : - "(integer value)", pbEncoded, cbEncoded, dwFlags, pvStructInfo, - pcbStructInfo); - return FALSE; + BOOL ret; + + __TRY + { + CERT_NAME_INFO *info = (CERT_NAME_INFO *)pvStructInfo; + DWORD bytesNeeded = 0, lenBytes, size, i; + + TRACE("encoding name with %ld RDNs\n", info->cRDN); + ret = TRUE; + for (i = 0; ret && i < info->cRDN; i++) + { + ret = CRYPT_AsnEncodeRdn(dwCertEncodingType, &info->rgRDN[i], NULL, + &size); + if (ret) + bytesNeeded += size; + } + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (ret) + { + if (!pbEncoded) + *pcbEncoded = bytesNeeded; + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, + pbEncoded, pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_SEQUENCEOF; + CRYPT_EncodeLen(bytesNeeded - lenBytes - 1, pbEncoded, + &lenBytes); + pbEncoded += lenBytes; + for (i = 0; ret && i < info->cRDN; i++) + { + size = bytesNeeded; + ret = CRYPT_AsnEncodeRdn(dwCertEncodingType, + &info->rgRDN[i], pbEncoded, &size); + if (ret) + { + pbEncoded += size; + bytesNeeded -= size; + } + } + } + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; } -BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, - const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, - PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +static BOOL CRYPT_EncodeBool(BOOL val, BYTE *pbEncoded, DWORD *pcbEncoded) { - FIXME("(0x%08lx, %s, %p, %ld, 0x%08lx, %p, %p, %p): stub\n", - dwCertEncodingType, HIWORD(lpszStructType) ? debugstr_a(lpszStructType) : - "(integer value)", pbEncoded, cbEncoded, dwFlags, pDecodePara, - pvStructInfo, pcbStructInfo); - return FALSE; + if (!pbEncoded) + { + *pcbEncoded = 3; + return TRUE; + } + if (*pcbEncoded < 3) + { + *pcbEncoded = 3; + SetLastError(ERROR_MORE_DATA); + return FALSE; + } + *pcbEncoded = 3; + *pbEncoded++ = ASN_BOOL; + *pbEncoded++ = 1; + *pbEncoded++ = val ? 0xff : 0; + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnEncodeBasicConstraints2(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + CERT_BASIC_CONSTRAINTS2_INFO *info = + (CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; + DWORD bytesNeeded = 0, lenBytes, caLen = 0, pathConstraintLen = 0; + + ret = TRUE; + if (info->fCA) + { + ret = CRYPT_EncodeBool(TRUE, NULL, &caLen); + if (ret) + bytesNeeded += caLen; + } + if (info->fPathLenConstraint) + { + ret = CRYPT_AsnEncodeInt(dwCertEncodingType, X509_INTEGER, + &info->dwPathLenConstraint, 0, NULL, NULL, &pathConstraintLen); + if (ret) + bytesNeeded += pathConstraintLen; + } + if (ret) + { + CRYPT_EncodeLen(bytesNeeded, NULL, &lenBytes); + bytesNeeded += 1 + lenBytes; + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, + pbEncoded, pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_SEQUENCE; + CRYPT_EncodeLen(bytesNeeded - 1 - lenBytes, pbEncoded, + &lenBytes); + pbEncoded += lenBytes; + if (info->fCA) + { + ret = CRYPT_EncodeBool(TRUE, pbEncoded, &caLen); + if (ret) + pbEncoded += caLen; + } + if (info->fPathLenConstraint) + { + ret = CRYPT_AsnEncodeInt(dwCertEncodingType, + X509_INTEGER, &info->dwPathLenConstraint, 0, NULL, + pbEncoded, &pathConstraintLen); + } + } + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeOctets(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + CRYPT_DATA_BLOB *blob = (CRYPT_DATA_BLOB *)pvStructInfo; + DWORD bytesNeeded, lenBytes; + + CRYPT_EncodeLen(blob->cbData, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + blob->cbData; + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_OCTETSTRING; + CRYPT_EncodeLen(blob->cbData, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + if (blob->cbData) + memcpy(pbEncoded, blob->pbData, blob->cbData); + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeBits(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + CRYPT_BIT_BLOB *blob = (CRYPT_BIT_BLOB *)pvStructInfo; + DWORD bytesNeeded, lenBytes, dataBytes; + BYTE unusedBits; + + /* yep, MS allows cUnusedBits to be >= 8 */ + if (blob->cbData * 8 > blob->cUnusedBits) + { + dataBytes = (blob->cbData * 8 - blob->cUnusedBits) / 8 + 1; + unusedBits = blob->cUnusedBits >= 8 ? blob->cUnusedBits / 8 : + blob->cUnusedBits; + } + else + { + dataBytes = 0; + unusedBits = 0; + } + CRYPT_EncodeLen(dataBytes + 1, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + dataBytes + 1; + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_BITSTRING; + CRYPT_EncodeLen(dataBytes + 1, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + *pbEncoded++ = unusedBits; + if (dataBytes) + { + BYTE mask = 0xff << unusedBits; + + if (dataBytes > 1) + { + memcpy(pbEncoded, blob->pbData, dataBytes - 1); + pbEncoded += dataBytes - 1; + } + *pbEncoded = *(blob->pbData + dataBytes - 1) & mask; + } + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeInt(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + CRYPT_INTEGER_BLOB blob = { sizeof(INT), (BYTE *)pvStructInfo }; + + return CRYPT_AsnEncodeInteger(dwCertEncodingType, X509_MULTI_BYTE_INTEGER, + &blob, dwFlags, pEncodePara, pbEncoded, pcbEncoded); +} + +static BOOL WINAPI CRYPT_AsnEncodeInteger(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + DWORD significantBytes, lenBytes; + BYTE padByte = 0, bytesNeeded; + BOOL pad = FALSE; + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + + significantBytes = blob->cbData; + if (significantBytes) + { + if (blob->pbData[significantBytes - 1] & 0x80) + { + /* negative, lop off leading (little-endian) 0xffs */ + for (; significantBytes > 0 && + blob->pbData[significantBytes - 1] == 0xff; significantBytes--) + ; + if (blob->pbData[significantBytes - 1] < 0x80) + { + padByte = 0xff; + pad = TRUE; + } + } + else + { + /* positive, lop off leading (little-endian) zeroes */ + for (; significantBytes > 0 && + !blob->pbData[significantBytes - 1]; significantBytes--) + ; + if (significantBytes == 0) + significantBytes = 1; + if (blob->pbData[significantBytes - 1] > 0x7f) + { + padByte = 0; + pad = TRUE; + } + } + } + if (pad) + CRYPT_EncodeLen(significantBytes + 1, NULL, &lenBytes); + else + CRYPT_EncodeLen(significantBytes, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + significantBytes; + if (pad) + bytesNeeded++; + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_INTEGER; + if (pad) + { + CRYPT_EncodeLen(significantBytes + 1, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + *pbEncoded++ = padByte; + } + else + { + CRYPT_EncodeLen(significantBytes, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + } + for (; significantBytes > 0; significantBytes--) + *(pbEncoded++) = blob->pbData[significantBytes - 1]; + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeUnsignedInteger(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + DWORD significantBytes, lenBytes; + BYTE bytesNeeded; + BOOL pad = FALSE; + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + + significantBytes = blob->cbData; + if (significantBytes) + { + /* positive, lop off leading (little-endian) zeroes */ + for (; significantBytes > 0 && !blob->pbData[significantBytes - 1]; + significantBytes--) + ; + if (significantBytes == 0) + significantBytes = 1; + if (blob->pbData[significantBytes - 1] > 0x7f) + pad = TRUE; + } + if (pad) + CRYPT_EncodeLen(significantBytes + 1, NULL, &lenBytes); + else + CRYPT_EncodeLen(significantBytes, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + significantBytes; + if (pad) + bytesNeeded++; + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_INTEGER; + if (pad) + { + CRYPT_EncodeLen(significantBytes + 1, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + *pbEncoded++ = 0; + } + else + { + CRYPT_EncodeLen(significantBytes, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + } + for (; significantBytes > 0; significantBytes--) + *(pbEncoded++) = blob->pbData[significantBytes - 1]; + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeEnumerated(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + CRYPT_INTEGER_BLOB blob; + BOOL ret; + + /* Encode as an unsigned integer, then change the tag to enumerated */ + blob.cbData = sizeof(DWORD); + blob.pbData = (BYTE *)pvStructInfo; + ret = CRYPT_AsnEncodeUnsignedInteger(dwCertEncodingType, + X509_MULTI_BYTE_UINT, &blob, dwFlags, pEncodePara, pbEncoded, pcbEncoded); + if (ret && pbEncoded) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + pbEncoded[0] = ASN_ENUMERATED; + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeUtcTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + SYSTEMTIME sysTime; + /* sorry, magic number: enough for tag, len, YYMMDDHHMMSSZ\0. I use a + * temporary buffer because the output buffer is not NULL-terminated. + */ + char buf[16]; + static const DWORD bytesNeeded = sizeof(buf) - 1; + + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + /* Sanity check the year, this is a two-digit year format */ + ret = FileTimeToSystemTime((const FILETIME *)pvStructInfo, + &sysTime); + if (ret && (sysTime.wYear < 1950 || sysTime.wYear > 2050)) + { + SetLastError(CRYPT_E_BAD_ENCODE); + ret = FALSE; + } + if (ret) + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, + pbEncoded, pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + buf[0] = ASN_UTCTIME; + buf[1] = bytesNeeded - 2; + snprintf(buf + 2, sizeof(buf) - 2, + "%02d%02d%02d%02d%02d%02dZ", sysTime.wYear >= 2000 ? + sysTime.wYear - 2000 : sysTime.wYear - 1900, + sysTime.wDay, sysTime.wMonth, sysTime.wHour, + sysTime.wMinute, sysTime.wSecond); + memcpy(pbEncoded, buf, bytesNeeded); + } + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeGeneralizedTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + SYSTEMTIME sysTime; + /* sorry, magic number: enough for tag, len, YYYYMMDDHHMMSSZ\0. I use a + * temporary buffer because the output buffer is not NULL-terminated. + */ + char buf[18]; + static const DWORD bytesNeeded = sizeof(buf) - 1; + + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + ret = FileTimeToSystemTime((const FILETIME *)pvStructInfo, + &sysTime); + if (ret) + ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded); + if (ret) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + buf[0] = ASN_GENERALTIME; + buf[1] = bytesNeeded - 2; + snprintf(buf + 2, sizeof(buf) - 2, "%04d%02d%02d%02d%02d%02dZ", + sysTime.wYear, sysTime.wDay, sysTime.wMonth, sysTime.wHour, + sysTime.wMinute, sysTime.wSecond); + memcpy(pbEncoded, buf, bytesNeeded); + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeChoiceOfTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + SYSTEMTIME sysTime; + + /* Check the year, if it's in the UTCTime range call that encode func */ + if (!FileTimeToSystemTime((const FILETIME *)pvStructInfo, &sysTime)) + return FALSE; + if (sysTime.wYear >= 1950 && sysTime.wYear <= 2050) + ret = CRYPT_AsnEncodeUtcTime(dwCertEncodingType, lpszStructType, + pvStructInfo, dwFlags, pEncodePara, pbEncoded, pcbEncoded); + else + ret = CRYPT_AsnEncodeGeneralizedTime(dwCertEncodingType, + lpszStructType, pvStructInfo, dwFlags, pEncodePara, pbEncoded, + pcbEncoded); + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +static BOOL WINAPI CRYPT_AsnEncodeSequenceOfAny(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, + PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + + __TRY + { + DWORD bytesNeeded, dataLen, lenBytes, i; + CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)pvStructInfo; + + for (i = 0, dataLen = 0; i < seq->cValue; i++) + dataLen += seq->rgValue[i].cbData; + CRYPT_EncodeLen(dataLen, NULL, &lenBytes); + bytesNeeded = 1 + lenBytes + dataLen; + if (!pbEncoded) + { + *pcbEncoded = bytesNeeded; + ret = TRUE; + } + else + { + if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, + pcbEncoded, bytesNeeded))) + { + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) + pbEncoded = *(BYTE **)pbEncoded; + *pbEncoded++ = ASN_SEQUENCEOF; + CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes); + pbEncoded += lenBytes; + for (i = 0; i < seq->cValue; i++) + { + memcpy(pbEncoded, seq->rgValue[i].pbData, + seq->rgValue[i].cbData); + pbEncoded += seq->rgValue[i].cbData; + } + } + } + } + __EXCEPT(page_fault) + { + SetLastError(STATUS_ACCESS_VIOLATION); + ret = FALSE; + } + __ENDTRY + return ret; +} + +typedef BOOL (WINAPI *CryptEncodeObjectExFunc)(DWORD, LPCSTR, const void *, + DWORD, PCRYPT_ENCODE_PARA, BYTE *, DWORD *); + +BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, + const void *pvStructInfo, DWORD dwFlags, PCRYPT_ENCODE_PARA pEncodePara, + void *pvEncoded, DWORD *pcbEncoded) +{ + BOOL ret = FALSE; + HMODULE lib = NULL; + CryptEncodeObjectExFunc encodeFunc = NULL; + + TRACE("(0x%08lx, %s, %p, 0x%08lx, %p, %p, %p)\n", + dwCertEncodingType, HIWORD(lpszStructType) ? debugstr_a(lpszStructType) : + "(integer value)", pvStructInfo, dwFlags, pEncodePara, pvEncoded, + pcbEncoded); + + if (!pvEncoded && !pcbEncoded) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if ((dwCertEncodingType & CERT_ENCODING_TYPE_MASK) != X509_ASN_ENCODING + && (dwCertEncodingType & CMSG_ENCODING_TYPE_MASK) != PKCS_7_ASN_ENCODING) + { + SetLastError(ERROR_FILE_NOT_FOUND); + return FALSE; + } + + SetLastError(NOERROR); + if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG && pvEncoded) + *(BYTE **)pvEncoded = NULL; + if (!HIWORD(lpszStructType)) + { + switch (LOWORD(lpszStructType)) + { + case (WORD)X509_NAME: + encodeFunc = CRYPT_AsnEncodeName; + break; + case (WORD)X509_BASIC_CONSTRAINTS2: + encodeFunc = CRYPT_AsnEncodeBasicConstraints2; + break; + case (WORD)X509_OCTET_STRING: + encodeFunc = CRYPT_AsnEncodeOctets; + break; + case (WORD)X509_BITS: + case (WORD)X509_KEY_USAGE: + encodeFunc = CRYPT_AsnEncodeBits; + break; + case (WORD)X509_INTEGER: + encodeFunc = CRYPT_AsnEncodeInt; + break; + case (WORD)X509_MULTI_BYTE_INTEGER: + encodeFunc = CRYPT_AsnEncodeInteger; + break; + case (WORD)X509_MULTI_BYTE_UINT: + encodeFunc = CRYPT_AsnEncodeUnsignedInteger; + break; + case (WORD)X509_ENUMERATED: + encodeFunc = CRYPT_AsnEncodeEnumerated; + break; + case (WORD)X509_CHOICE_OF_TIME: + encodeFunc = CRYPT_AsnEncodeChoiceOfTime; + break; + case (WORD)X509_SEQUENCE_OF_ANY: + encodeFunc = CRYPT_AsnEncodeSequenceOfAny; + break; + case (WORD)PKCS_UTC_TIME: + encodeFunc = CRYPT_AsnEncodeUtcTime; + break; + default: + FIXME("%d: unimplemented\n", LOWORD(lpszStructType)); + } + } + else if (!strcmp(lpszStructType, szOID_RSA_signingTime)) + encodeFunc = CRYPT_AsnEncodeUtcTime; + else if (!strcmp(lpszStructType, szOID_CRL_REASON_CODE)) + encodeFunc = CRYPT_AsnEncodeEnumerated; + else if (!strcmp(lpszStructType, szOID_KEY_USAGE)) + encodeFunc = CRYPT_AsnEncodeBits; + else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER)) + encodeFunc = CRYPT_AsnEncodeOctets; + else if (!strcmp(lpszStructType, szOID_BASIC_CONSTRAINTS2)) + encodeFunc = CRYPT_AsnEncodeBasicConstraints2; + else + TRACE("OID %s not found or unimplemented, looking for DLL\n", + debugstr_a(lpszStructType)); + if (!encodeFunc) + encodeFunc = (CryptEncodeObjectExFunc)CRYPT_GetFunc(dwCertEncodingType, + lpszStructType, "CryptEncodeObjectEx", &lib); + if (encodeFunc) + ret = encodeFunc(dwCertEncodingType, lpszStructType, pvStructInfo, + dwFlags, pEncodePara, pvEncoded, pcbEncoded); + else + SetLastError(ERROR_FILE_NOT_FOUND); + if (lib) + FreeLibrary(lib); + return ret; +} + +typedef BOOL (WINAPI *CryptDecodeObjectFunc)(DWORD, LPCSTR, const BYTE *, + DWORD, DWORD, void *, DWORD *); + +BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, + const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, + DWORD *pcbStructInfo) +{ + BOOL ret = FALSE; + HMODULE lib; + CryptDecodeObjectFunc pCryptDecodeObject; + + TRACE("(0x%08lx, %s, %p, %ld, 0x%08lx, %p, %p)\n", + dwCertEncodingType, HIWORD(lpszStructType) ? debugstr_a(lpszStructType) : + "(integer value)", pbEncoded, cbEncoded, dwFlags, pvStructInfo, + pcbStructInfo); + + if (!pvStructInfo && !pcbStructInfo) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + /* Try registered DLL first.. */ + pCryptDecodeObject = + (CryptDecodeObjectFunc)CRYPT_GetFunc(dwCertEncodingType, + lpszStructType, "CryptDecodeObject", &lib); + if (pCryptDecodeObject) + { + ret = pCryptDecodeObject(dwCertEncodingType, lpszStructType, + pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo); + FreeLibrary(lib); + } + else + { + /* If not, use CryptDecodeObjectEx */ + ret = CryptDecodeObjectEx(dwCertEncodingType, lpszStructType, pbEncoded, + cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo); + } + return ret; +} + +/* Gets the number of length bytes from the given (leading) length byte */ +#define GET_LEN_BYTES(b) ((b) <= 0x7f ? 1 : 1 + ((b) & 0x7f)) + +/* Helper function to get the encoded length of the data starting at pbEncoded, + * where pbEncoded[0] is the tag. If the data are too short to contain a + * length or if the length is too large for cbEncoded, sets an appropriate + * error code and returns FALSE. + */ +static BOOL WINAPI CRYPT_GetLen(const BYTE *pbEncoded, DWORD cbEncoded, + DWORD *len) +{ + BOOL ret; + + if (cbEncoded <= 1) + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } + else if (pbEncoded[1] <= 0x7f) + { + *len = pbEncoded[1]; + ret = TRUE; + } + else + { + BYTE lenLen = GET_LEN_BYTES(pbEncoded[1]); + + if (lenLen > sizeof(DWORD)) + { + SetLastError(CRYPT_E_ASN1_LARGE); + ret = FALSE; + } + else if (lenLen + 2 > cbEncoded) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + DWORD out = 0; + + pbEncoded += 2; + while (lenLen--) + { + out <<= 8; + out |= *pbEncoded++; + } + if (out + lenLen + 1 > cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + ret = FALSE; + } + else + { + *len = out; + ret = TRUE; + } + } + } + return ret; +} + +/* Helper function to check *pcbStructInfo, set it to the required size, and + * optionally to allocate memory. Assumes pvStructInfo is not NULL. + * If CRYPT_DECODE_ALLOC_FLAG is set in dwFlags, *pvStructInfo will be set to a + * pointer to the newly allocated memory. + */ +static BOOL CRYPT_DecodeEnsureSpace(DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo, + DWORD bytesNeeded) +{ + BOOL ret = TRUE; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + { + if (pDecodePara && pDecodePara->pfnAlloc) + *(BYTE **)pvStructInfo = pDecodePara->pfnAlloc(bytesNeeded); + else + *(BYTE **)pvStructInfo = LocalAlloc(0, bytesNeeded); + if (!*(BYTE **)pvStructInfo) + ret = FALSE; + else + *pcbStructInfo = bytesNeeded; + } + else if (*pcbStructInfo < bytesNeeded) + { + *pcbStructInfo = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + return ret; +} + +/* FIXME: honor the CRYPT_DECODE_SHARE_OID_FLAG. */ +static BOOL WINAPI CRYPT_AsnDecodeOid(DWORD dwCertEncodingType, + const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, LPSTR pszObjId, + DWORD *pcbObjId) +{ + BOOL ret = TRUE; + DWORD bytesNeeded, dataLen; + BYTE lenBytes; + + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + if (pbEncoded[0] != ASN_OBJECTIDENTIFIER) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + if (dataLen) + { + /* The largest possible string for the first two components is 2.175 + * (= 2 * 40 + 175 = 255), so this is big enough. + */ + char firstTwo[6]; + const BYTE *ptr; + + snprintf(firstTwo, sizeof(firstTwo), "%d.%d", + pbEncoded[1 + lenBytes] / 40, + pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / 40) * 40); + bytesNeeded = strlen(firstTwo) + 1; + for (ptr = pbEncoded + 2 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + /* large enough for ".4000000" */ + char str[9]; + int val = 0; + + while (ptr - pbEncoded - 1 - lenBytes < dataLen && (*ptr & 0x80)) + { + val <<= 7; + val |= *ptr & 0x7f; + ptr++; + } + if (ptr - pbEncoded - 1 - lenBytes >= dataLen || (*ptr & 0x80)) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + { + val <<= 7; + val |= *ptr++; + snprintf(str, sizeof(str), ".%d", val); + bytesNeeded += strlen(str); + } + } + if (!pszObjId) + *pcbObjId = bytesNeeded; + else if (*pcbObjId < bytesNeeded) + { + *pcbObjId = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + sprintf(pszObjId, "%d.%d", pbEncoded[1 + lenBytes] / 40, + pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / 40) * 40); + pszObjId += strlen(pszObjId); + for (ptr = pbEncoded + 2 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + int val = 0; + + while (ptr - pbEncoded - 1 - lenBytes < dataLen && + (*ptr & 0x80)) + { + val <<= 7; + val |= *ptr & 0x7f; + ptr++; + } + val <<= 7; + val |= *ptr++; + sprintf(pszObjId, ".%d", val); + pszObjId += strlen(pszObjId); + } + } + } + else + bytesNeeded = 0; + *pcbObjId = bytesNeeded; + return ret; +} + +/* Warning: this assumes the address of value->Value.pbData is already set, in + * order to avoid overwriting memory. (In some cases, it may change it, if it + * doesn't copy anything to memory.) Be sure to set it correctly! + */ +static BOOL WINAPI CRYPT_AsnDecodeNameValue(DWORD dwCertEncodingType, + const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, CERT_NAME_VALUE *value, + DWORD *pcbValue) +{ + DWORD bytesNeeded, dataLen; + BOOL ret = TRUE; + BYTE lenBytes; + + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + case ASN_PRINTABLESTRING: + case ASN_IA5STRING: + break; + default: + FIXME("Unimplemented string type %02x\n", pbEncoded[0]); + SetLastError(OSS_UNIMPLEMENTED); + return FALSE; + } + bytesNeeded = sizeof(CERT_NAME_VALUE); + if (dataLen) + { + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + case ASN_PRINTABLESTRING: + case ASN_IA5STRING: + if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) + bytesNeeded += dataLen; + break; + } + } + if (!value) + { + *pcbValue = bytesNeeded; + return TRUE; + } + if (*pcbValue < bytesNeeded) + { + *pcbValue = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + return FALSE; + } + *pcbValue = bytesNeeded; + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + value->dwValueType = CERT_RDN_NUMERIC_STRING; + break; + case ASN_PRINTABLESTRING: + value->dwValueType = CERT_RDN_PRINTABLE_STRING; + break; + case ASN_IA5STRING: + value->dwValueType = CERT_RDN_IA5_STRING; + break; + } + if (dataLen) + { + switch (pbEncoded[0]) + { + case ASN_NUMERICSTRING: + case ASN_PRINTABLESTRING: + case ASN_IA5STRING: + value->Value.cbData = dataLen; + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + value->Value.pbData = (BYTE *)pbEncoded + 1 + lenBytes; + else + { + if (!value->Value.pbData) + { + SetLastError(CRYPT_E_ASN1_INTERNAL); + ret = FALSE; + } + else + memcpy(value->Value.pbData, pbEncoded + 1 + lenBytes, + dataLen); + } + break; + } + } + else + { + value->Value.cbData = 0; + value->Value.pbData = NULL; + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeRdnAttr(DWORD dwCertEncodingType, + const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, CERT_RDN_ATTR *attr, + DWORD *pcbAttr) +{ + BOOL ret = TRUE; + DWORD bytesNeeded, dataLen, size; + BYTE lenBytes; + + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + /* The data length must be at least 4, two for the tag and length for the + * OID, and two for the string (assuming both have short-form lengths.) + */ + if (dataLen < 4) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (pbEncoded[0] != (ASN_CONSTRUCTOR | ASN_SEQUENCE)) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + bytesNeeded = sizeof(CERT_RDN_ATTR); + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + ret = CRYPT_AsnDecodeOid(dwCertEncodingType, pbEncoded + 1 + lenBytes, + cbEncoded - 1 - lenBytes, dwFlags, NULL, &size); + if (ret) + { + /* ugly: need to know the size of the next element of the sequence, + * so get it directly + */ + DWORD objIdOfset = 1 + lenBytes, objIdLen, nameValueOffset = 0; + + ret = CRYPT_GetLen(pbEncoded + objIdOfset, cbEncoded - objIdOfset, + &objIdLen); + bytesNeeded += size; + /* hack: like encoding, this takes advantage of the fact that the rest + * of the structure is identical to a CERT_NAME_VALUE. + */ + if (ret) + { + nameValueOffset = objIdOfset + objIdLen + 1 + + GET_LEN_BYTES(pbEncoded[objIdOfset]); + ret = CRYPT_AsnDecodeNameValue(dwCertEncodingType, + pbEncoded + nameValueOffset, cbEncoded - nameValueOffset, dwFlags, + NULL, &size); + } + if (ret) + { + bytesNeeded += size; + if (!attr) + *pcbAttr = bytesNeeded; + else if (*pcbAttr < bytesNeeded) + { + *pcbAttr = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + ret = FALSE; + } + else + { + BYTE *originalData = attr->Value.pbData; + + *pcbAttr = bytesNeeded; + /* strange: decode the value first, because it has a counted + * size, and we can store the OID after it. Keep track of the + * original data pointer, we'll need to know whether it was + * changed. + */ + size = bytesNeeded; + ret = CRYPT_AsnDecodeNameValue(dwCertEncodingType, + pbEncoded + nameValueOffset, cbEncoded - nameValueOffset, + dwFlags, (CERT_NAME_VALUE *)&attr->dwValueType, &size); + if (ret) + { + if (objIdLen) + { + /* if the data were copied to the original location, + * the OID goes after. Otherwise it goes in the + * spot originally reserved for the data. + */ + if (attr->Value.pbData == originalData) + attr->pszObjId = (LPSTR)(attr->Value.pbData + + attr->Value.cbData); + else + attr->pszObjId = originalData; + size = bytesNeeded - size; + ret = CRYPT_AsnDecodeOid(dwCertEncodingType, + pbEncoded + objIdOfset, cbEncoded - objIdOfset, + dwFlags, attr->pszObjId, &size); + } + else + attr->pszObjId = NULL; + } + } + } + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeRdn(DWORD dwCertEncodingType, + const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, CERT_RDN *rdn, + DWORD *pcbRdn) +{ + BOOL ret = TRUE; + DWORD bytesNeeded, dataLen, cRDNAttr = 0; + BYTE lenBytes; + + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + if (pbEncoded[0] != (ASN_CONSTRUCTOR | ASN_SETOF)) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + bytesNeeded = sizeof(CERT_RDN); + if (dataLen) + { + const BYTE *ptr; + DWORD size; + + for (ptr = pbEncoded + 1 + lenBytes; ret && + ptr - pbEncoded - 1 - lenBytes < dataLen; ) + { + ret = CRYPT_AsnDecodeRdnAttr(dwCertEncodingType, ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, NULL, &size); + if (ret) + { + DWORD nextLen; + + cRDNAttr++; + bytesNeeded += size; + ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } + if (ret) + { + if (!rdn) + { + *pcbRdn = bytesNeeded; + return TRUE; + } + if (*pcbRdn < bytesNeeded) + { + *pcbRdn = bytesNeeded; + SetLastError(ERROR_MORE_DATA); + return FALSE; + } + *pcbRdn = bytesNeeded; + rdn->cRDNAttr = cRDNAttr; + if (rdn->cRDNAttr == 0) + rdn->rgRDNAttr = NULL; + else + { + DWORD size, i; + BYTE *nextData; + const BYTE *ptr; + + rdn->rgRDNAttr = (CERT_RDN_ATTR *)((BYTE *)rdn + sizeof(CERT_RDN)); + nextData = (BYTE *)rdn->rgRDNAttr + + rdn->cRDNAttr * sizeof(CERT_RDN_ATTR); + for (i = 0, ptr = pbEncoded + 1 + lenBytes; ret && i < cRDNAttr && + ptr - pbEncoded - 1 - lenBytes < dataLen; i++) + { + rdn->rgRDNAttr[i].Value.pbData = nextData; + size = bytesNeeded; + ret = CRYPT_AsnDecodeRdnAttr(dwCertEncodingType, ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, &rdn->rgRDNAttr[i], + &size); + if (ret) + { + DWORD nextLen; + + bytesNeeded -= size; + /* If dwFlags & CRYPT_DECODE_NOCOPY_FLAG, the data may not + * have been copied. + */ + if (rdn->rgRDNAttr[i].Value.pbData == nextData) + nextData += rdn->rgRDNAttr[i].Value.cbData; + /* Ugly: the OID, if copied, is stored in memory after the + * value, so increment by its string length if it's set and + * points here. + */ + if ((const BYTE *)rdn->rgRDNAttr[i].pszObjId == nextData) + nextData += strlen(rdn->rgRDNAttr[i].pszObjId) + 1; + ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeName(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret = TRUE; + DWORD bytesNeeded, dataLen, cRDN = 0; + BYTE lenBytes; + + if (!pbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + if (pbEncoded[0] != (ASN_CONSTRUCTOR | ASN_SEQUENCEOF)) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + bytesNeeded = sizeof(CERT_NAME_INFO); + if (dataLen) + { + const BYTE *ptr; + DWORD size; + + for (ptr = pbEncoded + 1 + lenBytes; ret && ptr - pbEncoded - 1 - + lenBytes < dataLen; ) + { + ret = CRYPT_AsnDecodeRdn(dwCertEncodingType, ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, NULL, &size); + if (ret) + { + DWORD nextLen; + + cRDN++; + bytesNeeded += size; + ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } + if (ret) + { + CERT_NAME_INFO *info; + + if (!pvStructInfo) + { + *pcbStructInfo = bytesNeeded; + return TRUE; + } + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, bytesNeeded)) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + info = (CERT_NAME_INFO *)pvStructInfo; + info->cRDN = cRDN; + if (info->cRDN == 0) + info->rgRDN = NULL; + else + { + DWORD size, i; + BYTE *nextData; + const BYTE *ptr; + + info->rgRDN = (CERT_RDN *)((BYTE *)pvStructInfo + + sizeof(CERT_NAME_INFO)); + nextData = (BYTE *)info->rgRDN + info->cRDN * sizeof(CERT_RDN); + for (i = 0, ptr = pbEncoded + 1 + lenBytes; ret && i < cRDN && + ptr - pbEncoded - 1 - lenBytes < dataLen; i++) + { + info->rgRDN[i].rgRDNAttr = (CERT_RDN_ATTR *)nextData; + size = bytesNeeded; + ret = CRYPT_AsnDecodeRdn(dwCertEncodingType, ptr, + cbEncoded - (ptr - pbEncoded), dwFlags, &info->rgRDN[i], + &size); + if (ret) + { + DWORD nextLen; + + nextData += size; + bytesNeeded -= size; + ret = CRYPT_GetLen(ptr, cbEncoded - (ptr - pbEncoded), + &nextLen); + if (ret) + ptr += nextLen + 1 + GET_LEN_BYTES(ptr[1]); + } + } + } + } + return ret; +} + +static BOOL WINAPI CRYPT_DecodeBool(const BYTE *pbEncoded, DWORD cbEncoded, + BOOL *val) +{ + if (cbEncoded < 3) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + if (pbEncoded[0] != ASN_BOOL) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + if (GET_LEN_BYTES(pbEncoded[1]) > 1) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + if (pbEncoded[1] > 1) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + *val = pbEncoded[2] ? TRUE : FALSE; + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints2(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + DWORD bytesNeeded, dataLen; + BYTE lenBytes; + CERT_BASIC_CONSTRAINTS2_INFO info = { 0 }; + BOOL ret = TRUE; + + if (!pbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + /* sanity-check length, space enough for 7 bytes of integer and 3 bytes of + * bool + */ + if (dataLen > 10) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + if (pbEncoded[0] != ASN_SEQUENCE) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + bytesNeeded = sizeof(CERT_BASIC_CONSTRAINTS2_INFO); + if (!pvStructInfo) + { + *pcbStructInfo = bytesNeeded; + return TRUE; + } + pbEncoded += 1 + lenBytes; + cbEncoded -= 1 + lenBytes; + if (cbEncoded) + { + DWORD size; + + if (pbEncoded[0] == ASN_BOOL) + { + ret = CRYPT_DecodeBool(pbEncoded, cbEncoded, &info.fCA); + if (ret) + { + cbEncoded -= 2 + pbEncoded[1]; + pbEncoded += 2 + pbEncoded[1]; + } + } + if (ret && cbEncoded && pbEncoded[0] == ASN_INTEGER) + { + size = sizeof(info.dwPathLenConstraint); + ret = CRYPT_AsnDecodeInt(dwCertEncodingType, X509_INTEGER, + pbEncoded, cbEncoded, 0, NULL, &info.dwPathLenConstraint, + &size); + if (ret) + { + cbEncoded -= 2 + pbEncoded[1]; + pbEncoded += 2 + pbEncoded[1]; + if (cbEncoded) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + } + else + info.fPathLenConstraint = TRUE; + } + } + } + if (ret) + { + CERT_BASIC_CONSTRAINTS2_INFO *out; + + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, bytesNeeded)) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + out = (CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; + memcpy(out, &info, sizeof(*out)); + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeOctets(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + CRYPT_DATA_BLOB *blob; + DWORD bytesNeeded, dataLen; + + if (!pbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + if (pbEncoded[0] != ASN_OCTETSTRING) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + bytesNeeded = sizeof(CRYPT_DATA_BLOB); + else + bytesNeeded = dataLen + sizeof(CRYPT_DATA_BLOB); + if (!pvStructInfo) + { + *pcbStructInfo = bytesNeeded; + return TRUE; + } + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, bytesNeeded)) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_DATA_BLOB *)pvStructInfo; + blob->cbData = dataLen; + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + blob->pbData = (BYTE *)pbEncoded + 1 + GET_LEN_BYTES(pbEncoded[1]); + else + { + blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_DATA_BLOB); + if (blob->cbData) + memcpy(blob->pbData, pbEncoded + 1 + GET_LEN_BYTES(pbEncoded[1]), + blob->cbData); + } + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnDecodeBits(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + CRYPT_BIT_BLOB *blob; + DWORD bytesNeeded, dataLen; + + if (!pbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + if (pbEncoded[0] != ASN_BITSTRING) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + bytesNeeded = sizeof(CRYPT_BIT_BLOB); + else + bytesNeeded = dataLen - 1 + sizeof(CRYPT_BIT_BLOB); + if (!pvStructInfo) + { + *pcbStructInfo = bytesNeeded; + return TRUE; + } + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, bytesNeeded)) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_BIT_BLOB *)pvStructInfo; + blob->cbData = dataLen - 1; + blob->cUnusedBits = *(pbEncoded + 1 + GET_LEN_BYTES(pbEncoded[1])); + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + blob->pbData = (BYTE *)pbEncoded + 2 + GET_LEN_BYTES(pbEncoded[1]); + else + { + blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_BIT_BLOB); + if (blob->cbData) + { + BYTE mask = 0xff << blob->cUnusedBits; + + memcpy(blob->pbData, pbEncoded + 2 + GET_LEN_BYTES(pbEncoded[1]), + blob->cbData); + blob->pbData[blob->cbData - 1] &= mask; + } + } + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnDecodeInt(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BYTE buf[sizeof(CRYPT_INTEGER_BLOB) + sizeof(int)]; + DWORD size = sizeof(buf); + BOOL ret; + + if (!pbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!pvStructInfo) + { + *pcbStructInfo = sizeof(int); + return TRUE; + } + ret = CRYPT_AsnDecodeInteger(dwCertEncodingType, X509_MULTI_BYTE_INTEGER, + pbEncoded, cbEncoded, 0, NULL, &buf, &size); + if (ret) + { + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; + + if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo, sizeof(int)))) + { + int val, i; + + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + if (blob->pbData[blob->cbData - 1] & 0x80) + { + /* initialize to a negative value to sign-extend */ + val = -1; + } + else + val = 0; + for (i = 0; i < blob->cbData; i++) + { + val <<= 8; + val |= blob->pbData[blob->cbData - i - 1]; + } + memcpy(pvStructInfo, &val, sizeof(int)); + } + } + else if (GetLastError() == ERROR_MORE_DATA) + SetLastError(CRYPT_E_ASN1_LARGE); + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeInteger(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + DWORD bytesNeeded, dataLen; + BYTE lenBytes; + CRYPT_INTEGER_BLOB *blob; + + if (!pbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + if (pbEncoded[0] != ASN_INTEGER) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); + if (!pvStructInfo) + { + *pcbStructInfo = bytesNeeded; + return TRUE; + } + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, bytesNeeded)) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + blob->cbData = dataLen; + blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_INTEGER_BLOB); + if (blob->cbData) + { + DWORD i; + + for (i = 0; i < blob->cbData; i++) + blob->pbData[i] = *(pbEncoded + 1 + lenBytes + dataLen - i - 1); + } + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnDecodeUnsignedInteger(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + DWORD bytesNeeded, dataLen; + BYTE lenBytes; + CRYPT_INTEGER_BLOB *blob; + + if (!pbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + if (pbEncoded[0] != ASN_INTEGER) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + bytesNeeded = dataLen + sizeof(CRYPT_INTEGER_BLOB); + if (!pvStructInfo) + { + *pcbStructInfo = bytesNeeded; + return TRUE; + } + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, bytesNeeded)) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + blob = (CRYPT_INTEGER_BLOB *)pvStructInfo; + blob->cbData = dataLen; + blob->pbData = (BYTE *)pvStructInfo + sizeof(CRYPT_INTEGER_BLOB); + /* remove leading zero byte if it exists */ + if (blob->cbData && *(pbEncoded + 1 + lenBytes) == 0) + { + blob->cbData--; + blob->pbData++; + } + if (blob->cbData) + { + DWORD i; + + for (i = 0; i < blob->cbData; i++) + blob->pbData[i] = *(pbEncoded + 1 + lenBytes + pbEncoded[1] - i - + 1); + } + return TRUE; +} + +static BOOL WINAPI CRYPT_AsnDecodeEnumerated(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + unsigned int val = 0, i; + + if (!pbEncoded || !cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!pvStructInfo) + { + *pcbStructInfo = sizeof(int); + return TRUE; + } + if (pbEncoded[0] != ASN_ENUMERATED) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + if (cbEncoded <= 1) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (pbEncoded[1] == 0) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + /* A little strange looking, but we have to accept a sign byte: 0xffffffff + * gets encoded as 0a 05 00 ff ff ff ff. Also, assuming a small length is + * okay here, it has to be in short form. + */ + if (pbEncoded[1] > sizeof(unsigned int) + 1) + { + SetLastError(CRYPT_E_ASN1_LARGE); + return FALSE; + } + for (i = 0; i < pbEncoded[1]; i++) + { + val <<= 8; + val |= pbEncoded[2 + i]; + } + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, sizeof(unsigned int))) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + memcpy(pvStructInfo, &val, sizeof(unsigned int)); + return TRUE; +} + +#define CRYPT_TIME_GET_DIGITS(pbEncoded, len, numDigits, word) \ + do { \ + BYTE i; \ + \ + (word) = 0; \ + for (i = 0; (len) > 0 && i < (numDigits); i++, (len)--) \ + { \ + if (!isdigit(*(pbEncoded))) \ + { \ + SetLastError(CRYPT_E_ASN1_CORRUPT); \ + return FALSE; \ + } \ + (word) *= 10; \ + (word) += *(pbEncoded)++ - '0'; \ + } \ + } while (0) + +static BOOL CRYPT_AsnDecodeTimeZone(const BYTE *pbEncoded, DWORD len, + SYSTEMTIME *sysTime) +{ + BOOL ret = TRUE; + + if (len >= 3 && (*pbEncoded == '+' || *pbEncoded == '-')) + { + WORD hours, minutes = 0; + BYTE sign = *pbEncoded++; + + len--; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, hours); + if (hours >= 24) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + goto end; + } + if (len >= 2) + { + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, minutes); + if (minutes >= 60) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + ret = FALSE; + goto end; + } + } + if (sign == '+') + { + sysTime->wHour += hours; + sysTime->wMinute += minutes; + } + else + { + if (hours > sysTime->wHour) + { + sysTime->wDay--; + sysTime->wHour = 24 - (hours - sysTime->wHour); + } + else + sysTime->wHour -= hours; + if (minutes > sysTime->wMinute) + { + sysTime->wHour--; + sysTime->wMinute = 60 - (minutes - sysTime->wMinute); + } + else + sysTime->wMinute -= minutes; + } + } +end: + return ret; +} + +#define MIN_ENCODED_TIME_LENGTH 10 + +static BOOL WINAPI CRYPT_AsnDecodeUtcTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + SYSTEMTIME sysTime = { 0 }; + BYTE len; + BOOL ret = TRUE; + + if (!pbEncoded || !cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!pvStructInfo) + { + *pcbStructInfo = sizeof(FILETIME); + return TRUE; + } + if (pbEncoded[0] != ASN_UTCTIME) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + if (cbEncoded <= 1) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (pbEncoded[1] > 0x7f) + { + /* long-form date strings really can't be valid */ + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + len = pbEncoded[1]; + if (len < MIN_ENCODED_TIME_LENGTH) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + pbEncoded += 2; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wYear); + if (sysTime.wYear >= 50) + sysTime.wYear += 1900; + else + sysTime.wYear += 2000; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMonth); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wDay); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wHour); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMinute); + if (len > 0) + { + if (len >= 2 && isdigit(*pbEncoded) && isdigit(*(pbEncoded + 1))) + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wSecond); + else if (isdigit(*pbEncoded)) + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 1, sysTime.wSecond); + ret = CRYPT_AsnDecodeTimeZone(pbEncoded, len, &sysTime); + } + if (ret) + { + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, sizeof(FILETIME))) + ret = FALSE; + else + { + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + ret = SystemTimeToFileTime(&sysTime, (FILETIME *)pvStructInfo); + } + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeGeneralizedTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + SYSTEMTIME sysTime = { 0 }; + BYTE len; + BOOL ret = TRUE; + + if (!pbEncoded || !cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!pvStructInfo) + { + *pcbStructInfo = sizeof(FILETIME); + return TRUE; + } + if (pbEncoded[0] != ASN_GENERALTIME) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + if (cbEncoded <= 1) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (pbEncoded[1] > 0x7f) + { + /* long-form date strings really can't be valid */ + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + len = pbEncoded[1]; + if (len < MIN_ENCODED_TIME_LENGTH) + { + SetLastError(CRYPT_E_ASN1_CORRUPT); + return FALSE; + } + pbEncoded += 2; + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 4, sysTime.wYear); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMonth); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wDay); + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wHour); + if (len > 0) + { + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wMinute); + if (len > 0) + CRYPT_TIME_GET_DIGITS(pbEncoded, len, 2, sysTime.wSecond); + if (len > 0 && (*pbEncoded == '.' || *pbEncoded == ',')) + { + BYTE digits; + + pbEncoded++; + len--; + digits = min(len, 3); /* workaround macro weirdness */ + CRYPT_TIME_GET_DIGITS(pbEncoded, len, digits, + sysTime.wMilliseconds); + } + ret = CRYPT_AsnDecodeTimeZone(pbEncoded, len, &sysTime); + } + if (ret) + { + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, sizeof(FILETIME))) + ret = FALSE; + else + { + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + ret = SystemTimeToFileTime(&sysTime, (FILETIME *)pvStructInfo); + } + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeChoiceOfTime(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret; + + if (!pbEncoded || !cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (!pvStructInfo) + { + *pcbStructInfo = sizeof(FILETIME); + return TRUE; + } + + if (pbEncoded[0] == ASN_UTCTIME) + ret = CRYPT_AsnDecodeUtcTime(dwCertEncodingType, lpszStructType, + pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo); + else if (pbEncoded[0] == ASN_GENERALTIME) + ret = CRYPT_AsnDecodeGeneralizedTime(dwCertEncodingType, + lpszStructType, pbEncoded, cbEncoded, dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo); + else + { + SetLastError(CRYPT_E_ASN1_BADTAG); + ret = FALSE; + } + return ret; +} + +static BOOL WINAPI CRYPT_AsnDecodeSequenceOfAny(DWORD dwCertEncodingType, + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + DWORD bytesNeeded, dataLen, remainingLen, cValue; + BYTE lenBytes; + BOOL ret = TRUE; + const BYTE *ptr; + + if (!pbEncoded || !cbEncoded) + { + SetLastError(CRYPT_E_ASN1_EOD); + return FALSE; + } + if (pbEncoded[0] != ASN_SEQUENCEOF) + { + SetLastError(CRYPT_E_ASN1_BADTAG); + return FALSE; + } + if (!CRYPT_GetLen(pbEncoded, cbEncoded, &dataLen)) + return FALSE; + lenBytes = GET_LEN_BYTES(pbEncoded[1]); + bytesNeeded = sizeof(CRYPT_SEQUENCE_OF_ANY); + cValue = 0; + ptr = pbEncoded + 1 + lenBytes; + remainingLen = dataLen; + while (ret && remainingLen) + { + DWORD nextLen; + + ret = CRYPT_GetLen(ptr, remainingLen, &nextLen); + if (ret) + { + DWORD nextLenBytes = GET_LEN_BYTES(ptr[1]); + + remainingLen -= 1 + nextLenBytes + nextLen; + ptr += 1 + nextLenBytes + nextLen; + bytesNeeded += sizeof(CRYPT_DER_BLOB); + if (!(dwFlags & CRYPT_DECODE_NOCOPY_FLAG)) + bytesNeeded += 1 + nextLenBytes + nextLen; + cValue++; + } + } + if (ret) + { + CRYPT_SEQUENCE_OF_ANY *seq; + BYTE *nextPtr; + DWORD i; + + if (!CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, + pcbStructInfo, bytesNeeded)) + return FALSE; + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG) + pvStructInfo = *(BYTE **)pvStructInfo; + seq = (CRYPT_SEQUENCE_OF_ANY *)pvStructInfo; + seq->cValue = cValue; + seq->rgValue = (CRYPT_DER_BLOB *)((BYTE *)seq + sizeof(*seq)); + nextPtr = (BYTE *)seq->rgValue + cValue * sizeof(CRYPT_DER_BLOB); + ptr = pbEncoded + 1 + lenBytes; + remainingLen = dataLen; + i = 0; + while (ret && remainingLen) + { + DWORD nextLen; + + ret = CRYPT_GetLen(ptr, remainingLen, &nextLen); + if (ret) + { + DWORD nextLenBytes = GET_LEN_BYTES(ptr[1]); + + seq->rgValue[i].cbData = 1 + nextLenBytes + nextLen; + if (dwFlags & CRYPT_DECODE_NOCOPY_FLAG) + seq->rgValue[i].pbData = (BYTE *)ptr; + else + { + seq->rgValue[i].pbData = nextPtr; + memcpy(nextPtr, ptr, 1 + nextLenBytes + nextLen); + nextPtr += 1 + nextLenBytes + nextLen; + } + remainingLen -= 1 + nextLenBytes + nextLen; + ptr += 1 + nextLenBytes + nextLen; + i++; + } + } + } + return ret; +} + +typedef BOOL (WINAPI *CryptDecodeObjectExFunc)(DWORD, LPCSTR, const BYTE *, + DWORD, DWORD, PCRYPT_DECODE_PARA, void *, DWORD *); + +BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType, + const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, + PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) +{ + BOOL ret = FALSE; + HMODULE lib = NULL; + CryptDecodeObjectExFunc decodeFunc = NULL; + + TRACE("(0x%08lx, %s, %p, %ld, 0x%08lx, %p, %p, %p)\n", + dwCertEncodingType, HIWORD(lpszStructType) ? debugstr_a(lpszStructType) : + "(integer value)", pbEncoded, cbEncoded, dwFlags, pDecodePara, + pvStructInfo, pcbStructInfo); + + if (!pvStructInfo && !pcbStructInfo) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if ((dwCertEncodingType & CERT_ENCODING_TYPE_MASK) != X509_ASN_ENCODING + && (dwCertEncodingType & CMSG_ENCODING_TYPE_MASK) != PKCS_7_ASN_ENCODING) + { + SetLastError(ERROR_FILE_NOT_FOUND); + return FALSE; + } + + SetLastError(NOERROR); + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG && pvStructInfo) + *(BYTE **)pvStructInfo = NULL; + if (!HIWORD(lpszStructType)) + { + switch (LOWORD(lpszStructType)) + { + case (WORD)X509_NAME: + decodeFunc = CRYPT_AsnDecodeName; + break; + case (WORD)X509_BASIC_CONSTRAINTS2: + decodeFunc = CRYPT_AsnDecodeBasicConstraints2; + break; + case (WORD)X509_OCTET_STRING: + decodeFunc = CRYPT_AsnDecodeOctets; + break; + case (WORD)X509_BITS: + case (WORD)X509_KEY_USAGE: + decodeFunc = CRYPT_AsnDecodeBits; + break; + case (WORD)X509_INTEGER: + decodeFunc = CRYPT_AsnDecodeInt; + break; + case (WORD)X509_MULTI_BYTE_INTEGER: + decodeFunc = CRYPT_AsnDecodeInteger; + break; + case (WORD)X509_MULTI_BYTE_UINT: + decodeFunc = CRYPT_AsnDecodeUnsignedInteger; + break; + case (WORD)X509_ENUMERATED: + decodeFunc = CRYPT_AsnDecodeEnumerated; + break; + case (WORD)X509_CHOICE_OF_TIME: + decodeFunc = CRYPT_AsnDecodeChoiceOfTime; + break; + case (WORD)X509_SEQUENCE_OF_ANY: + decodeFunc = CRYPT_AsnDecodeSequenceOfAny; + break; + case (WORD)PKCS_UTC_TIME: + decodeFunc = CRYPT_AsnDecodeUtcTime; + break; + default: + FIXME("%d: unimplemented\n", LOWORD(lpszStructType)); + } + } + else if (!strcmp(lpszStructType, szOID_RSA_signingTime)) + decodeFunc = CRYPT_AsnDecodeUtcTime; + else if (!strcmp(lpszStructType, szOID_CRL_REASON_CODE)) + decodeFunc = CRYPT_AsnDecodeEnumerated; + else if (!strcmp(lpszStructType, szOID_KEY_USAGE)) + decodeFunc = CRYPT_AsnDecodeBits; + else if (!strcmp(lpszStructType, szOID_SUBJECT_KEY_IDENTIFIER)) + decodeFunc = CRYPT_AsnDecodeOctets; + else if (!strcmp(lpszStructType, szOID_BASIC_CONSTRAINTS2)) + decodeFunc = CRYPT_AsnDecodeBasicConstraints2; + else + TRACE("OID %s not found or unimplemented, looking for DLL\n", + debugstr_a(lpszStructType)); + if (!decodeFunc) + decodeFunc = (CryptDecodeObjectExFunc)CRYPT_GetFunc(dwCertEncodingType, + lpszStructType, "CryptDecodeObjectEx", &lib); + if (decodeFunc) + ret = decodeFunc(dwCertEncodingType, lpszStructType, pbEncoded, + cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo); + else + SetLastError(ERROR_FILE_NOT_FOUND); + if (lib) + FreeLibrary(lib); + return ret; } diff -urN wine-20050524/dlls/crypt32/main.c wine-20050628/dlls/crypt32/main.c --- wine-20050524/dlls/crypt32/main.c 2005-05-20 21:37:26.000000000 +0200 +++ wine-20050628/dlls/crypt32/main.c 2005-06-14 13:38:36.000000000 +0200 @@ -1,5 +1,6 @@ /* * Copyright 2002 Mike McCormack for CodeWeavers + * Copyright 2005 Juan Lang * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -183,16 +184,6 @@ return FALSE; } -BOOL WINAPI CryptGetOIDFunctionValue(DWORD dwEncodingType, LPCSTR pszFuncName, - LPCSTR pszOID, LPCWSTR pwszValueName, - DWORD *pdwValueType, BYTE *pbValueData, - DWORD *pcbValueData) -{ - FIXME("(%lx,%s,%s,%s,%p,%p,%p) stub!\n", dwEncodingType, pszFuncName, pszOID, - debugstr_w(pwszValueName), pdwValueType, pbValueData, pcbValueData); - return FALSE; -} - BOOL WINAPI CryptRegisterDefaultOIDFunction(DWORD dwEncodingType, LPCSTR pszFuncName, DWORD dwIndex, LPCWSTR pwszDll) @@ -201,3 +192,90 @@ debugstr_w(pwszDll)); return FALSE; } + +struct OIDToAlgID +{ + LPCSTR oid; + DWORD algID; +}; + +static const struct OIDToAlgID oidToAlgID[] = { + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_MD2RSA, CALG_MD2 }, + { szOID_RSA_MD4RSA, CALG_MD4 }, + { szOID_RSA_MD5RSA, CALG_MD5 }, + { szOID_RSA_SHA1RSA, CALG_SHA }, + { szOID_RSA_DH, CALG_DH_SF }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES }, + { szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2 }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_X957_SHA1DSA, CALG_SHA }, + { szOID_OIWSEC_md4RSA, CALG_MD4 }, + { szOID_OIWSEC_md5RSA, CALG_MD5 }, + { szOID_OIWSEC_md4RSA2, CALG_MD4 }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_dsa, CALG_DSS_SIGN }, + { szOID_OIWSEC_shaDSA, CALG_SHA }, + { szOID_OIWSEC_shaRSA, CALG_SHA }, + { szOID_OIWSEC_sha, CALG_SHA }, + { szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX }, + { szOID_OIWSEC_sha1, CALG_SHA }, + { szOID_OIWSEC_dsaSHA1, CALG_SHA }, + { szOID_OIWSEC_sha1RSASign, CALG_SHA }, + { szOID_OIWDIR_md2RSA, CALG_MD2 }, + { szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA }, + { szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN }, +}; + +LPCSTR WINAPI CertAlgIdToOID(DWORD dwAlgId) +{ + switch (dwAlgId) + { + case CALG_RSA_KEYX: + return szOID_RSA_RSA; + case CALG_DH_EPHEM: + return szOID_RSA_SMIMEalgESDH; + case CALG_MD2: + return szOID_RSA_MD2; + case CALG_MD4: + return szOID_RSA_MD4; + case CALG_MD5: + return szOID_RSA_MD5; + case CALG_RC2: + return szOID_RSA_RC2CBC; + case CALG_RC4: + return szOID_RSA_RC4; + case CALG_3DES: + return szOID_RSA_DES_EDE3_CBC; + case CALG_DH_SF: + return szOID_ANSI_X942_DH; + case CALG_DSS_SIGN: + return szOID_X957_DSA; + case CALG_DES: + return szOID_OIWSEC_desCBC; + case CALG_SHA: + return szOID_OIWSEC_sha1; + default: + return NULL; + } +} + +DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId) +{ + int i; + + for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++) + { + if (!strcmp(pszObjId, oidToAlgID[i].oid)) + return oidToAlgID[i].algID; + } + return 0; +} diff -urN wine-20050524/dlls/crypt32/protectdata.c wine-20050628/dlls/crypt32/protectdata.c --- wine-20050524/dlls/crypt32/protectdata.c 2005-05-23 11:50:26.000000000 +0200 +++ wine-20050628/dlls/crypt32/protectdata.c 2005-05-30 11:56:57.000000000 +0200 @@ -861,8 +861,7 @@ szDataDescr=(WCHAR[]){'\0'}; /* get crypt context */ - if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,0) && - !CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_NEWKEYSET)) + if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_VERIFYCONTEXT)) { ERR("CryptAcquireContextW failed\n"); goto finished; @@ -947,7 +946,7 @@ free_context: CryptReleaseContext(hProv,0); finished: - /* If some error occured, and no error code was set, force one. */ + /* If some error occurred, and no error code was set, force one. */ if (!rc && GetLastError()==ERROR_SUCCESS) { SetLastError(ERROR_INVALID_DATA); @@ -1043,8 +1042,7 @@ } /* get a crypt context */ - if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,0) && - !CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_NEWKEYSET)) + if (!CryptAcquireContextW(&hProv,NULL,NULL,CRYPT32_PROTECTDATA_PROV,CRYPT_VERIFYCONTEXT)) { ERR("CryptAcquireContextW failed\n"); goto free_protect_data; @@ -1114,7 +1112,7 @@ free_protect_data: free_protect_data(&protect_data); finished: - /* If some error occured, and no error code was set, force one. */ + /* If some error occurred, and no error code was set, force one. */ if (!rc && GetLastError()==ERROR_SUCCESS) { SetLastError(ERROR_INVALID_DATA); diff -urN wine-20050524/dlls/crypt32/tests/.cvsignore wine-20050628/dlls/crypt32/tests/.cvsignore --- wine-20050524/dlls/crypt32/tests/.cvsignore 2005-05-24 11:58:26.000000000 +0200 +++ wine-20050628/dlls/crypt32/tests/.cvsignore 2005-06-14 13:38:36.000000000 +0200 @@ -1,3 +1,5 @@ Makefile +encode.ok +main.ok protectdata.ok testlist.c diff -urN wine-20050524/dlls/crypt32/tests/Makefile.in wine-20050628/dlls/crypt32/tests/Makefile.in --- wine-20050524/dlls/crypt32/tests/Makefile.in 2005-05-24 11:58:26.000000000 +0200 +++ wine-20050628/dlls/crypt32/tests/Makefile.in 2005-06-14 13:38:36.000000000 +0200 @@ -6,6 +6,8 @@ IMPORTS = crypt32 CTESTS = \ + encode.c \ + main.c \ protectdata.c @MAKE_TEST_RULES@ diff -urN wine-20050524/dlls/crypt32/tests/encode.c wine-20050628/dlls/crypt32/tests/encode.c --- wine-20050524/dlls/crypt32/tests/encode.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/crypt32/tests/encode.c 2005-06-27 11:42:15.000000000 +0200 @@ -0,0 +1,1265 @@ +/* + * Unit test suite for crypt32.dll's CryptEncodeObjectEx/CryptDecodeObjectEx + * + * Copyright 2005 Juan Lang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include + +#include "wine/test.h" + +struct encodedInt +{ + int val; + BYTE *encoded; +}; + +static const struct encodedInt ints[] = { + { 1, "\x02\x01\x01" }, + { 127, "\x02\x01\x7f" }, + { 128, "\x02\x02\x00\x80" }, + { 256, "\x02\x02\x01\x00" }, + { -128, "\x02\x01\x80" }, + { -129, "\x02\x02\xff\x7f" }, + { 0xbaddf00d, "\x02\x04\xba\xdd\xf0\x0d" }, +}; + +struct encodedBigInt +{ + BYTE *val; + BYTE *encoded; + BYTE *decoded; +}; + +static const struct encodedBigInt bigInts[] = { + { "\xff\xff\x01\x02\x03\x04\x05\x06\x07\x08", + "\x02\x0a\x08\x07\x06\x05\x04\x03\x02\x01\xff\xff", + "\xff\xff\x01\x02\x03\x04\x05\x06\x07\x08" }, + { "\x08\x07\x06\x05\x04\x03\x02\x01\xff\xff\xff", + "\x02\x09\xff\x01\x02\x03\x04\x05\x06\x07\x08", + "\x08\x07\x06\x05\x04\x03\x02\x01\xff" }, +}; + +/* Decoded is the same as original, so don't bother storing a separate copy */ +static const struct encodedBigInt bigUInts[] = { + { "\xff\xff\x01\x02\x03\x04\x05\x06\x07\x08", + "\x02\x0a\x08\x07\x06\x05\x04\x03\x02\x01\xff\xff", NULL }, + { "\x08\x07\x06\x05\x04\x03\x02\x01\xff\xff\xff", + "\x02\x0c\x00\xff\xff\xff\x01\x02\x03\x04\x05\x06\x07\x08", NULL }, +}; + +static void test_encodeInt(DWORD dwEncoding) +{ + DWORD bufSize = 0; + int i; + BOOL ret; + CRYPT_INTEGER_BLOB blob; + BYTE *buf = NULL; + + /* CryptEncodeObjectEx with NULL bufSize crashes.. + ret = CryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + NULL); + */ + /* check bogus encoding */ + ret = CryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + &bufSize); + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); + /* check with NULL integer buffer. Windows XP incorrectly returns an + * NTSTATUS. + */ + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL, + &bufSize); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) + { + /* encode as normal integer */ + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, + NULL, NULL, &bufSize); + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); + if (buf) + { + ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", + buf[0]); + ok(!memcmp(buf + 1, ints[i].encoded + 1, ints[i].encoded[1] + 1), + "Encoded value of 0x%08x didn't match expected\n", ints[i].val); + LocalFree(buf); + } + /* encode as multibyte integer */ + blob.cbData = sizeof(ints[i].val); + blob.pbData = (BYTE *)&ints[i].val; + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + 0, NULL, NULL, &bufSize); + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); + if (buf) + { + ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", + buf[0]); + ok(buf[1] == ints[i].encoded[1], "Got length %d, expected %d\n", + buf[1], ints[i].encoded[1]); + ok(!memcmp(buf + 1, ints[i].encoded + 1, ints[i].encoded[1] + 1), + "Encoded value of 0x%08x didn't match expected\n", ints[i].val); + LocalFree(buf); + } + } + /* encode a couple bigger ints, just to show it's little-endian and leading + * sign bytes are dropped + */ + for (i = 0; i < sizeof(bigInts) / sizeof(bigInts[0]); i++) + { + blob.cbData = strlen(bigInts[i].val); + blob.pbData = (BYTE *)bigInts[i].val; + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + 0, NULL, NULL, &bufSize); + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); + if (buf) + { + ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", + buf[0]); + ok(buf[1] == bigInts[i].encoded[1], "Got length %d, expected %d\n", + buf[1], bigInts[i].encoded[1]); + ok(!memcmp(buf + 1, bigInts[i].encoded + 1, + bigInts[i].encoded[1] + 1), + "Encoded value didn't match expected\n"); + LocalFree(buf); + } + } + /* and, encode some uints */ + for (i = 0; i < sizeof(bigUInts) / sizeof(bigUInts[0]); i++) + { + blob.cbData = strlen(bigUInts[i].val); + blob.pbData = (BYTE *)bigUInts[i].val; + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + 0, NULL, NULL, &bufSize); + ok(ret, "Expected success, got %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); + if (buf) + { + ok(buf[0] == 2, "Got unexpected type %d for integer (expected 2)\n", + buf[0]); + ok(buf[1] == bigUInts[i].encoded[1], "Got length %d, expected %d\n", + buf[1], bigUInts[i].encoded[1]); + ok(!memcmp(buf + 1, bigUInts[i].encoded + 1, + bigUInts[i].encoded[1] + 1), + "Encoded value didn't match expected\n"); + LocalFree(buf); + } + } +} + +static void test_decodeInt(DWORD dwEncoding) +{ + static const char bigInt[] = { 2, 5, 0xff, 0xfe, 0xff, 0xfe, 0xff }; + static const char testStr[] = { 0x16, 4, 't', 'e', 's', 't' }; + BYTE *buf = NULL; + DWORD bufSize = 0; + int i; + BOOL ret; + + /* CryptDecodeObjectEx with NULL bufSize crashes.. + ret = CryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded, + ints[0].encoded[1] + 2, 0, NULL, NULL, NULL); + */ + /* check bogus encoding */ + ret = CryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded, + ints[0].encoded[1] + 2, 0, NULL, NULL, &bufSize); + ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, + "Expected ERROR_FILE_NOT_FOUND, got %ld\n", GetLastError()); + /* check with NULL integer buffer */ + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL, + &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, + "Expected CRYPT_E_ASN1_EOD, got %08lx\n", GetLastError()); + /* check with a valid, but too large, integer */ + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, + "Expected CRYPT_E_ASN1_LARGE, got %ld\n", GetLastError()); + /* check with a DER-encoded string */ + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got %ld\n", GetLastError()); + for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) + { + /* When the output buffer is NULL, this always succeeds */ + SetLastError(0xdeadbeef); + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, + (BYTE *)ints[i].encoded, ints[i].encoded[1] + 2, 0, NULL, NULL, + &bufSize); + ok(ret && GetLastError() == NOERROR, + "Expected success and NOERROR, got %ld\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, + (BYTE *)ints[i].encoded, ints[i].encoded[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); + ok(bufSize == sizeof(int), "Expected size %d, got %ld\n", sizeof(int), + bufSize); + ok(buf != NULL, "Expected allocated buffer\n"); + if (buf) + { + ok(!memcmp(buf, &ints[i].val, bufSize), "Expected %d, got %d\n", + ints[i].val, *(int *)buf); + LocalFree(buf); + } + } + for (i = 0; i < sizeof(bigInts) / sizeof(bigInts[0]); i++) + { + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + (BYTE *)bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL, + &bufSize); + ok(ret && GetLastError() == NOERROR, + "Expected success and NOERROR, got %ld\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + (BYTE *)bigInts[i].encoded, bigInts[i].encoded[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); + ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), + "Expected size at least %d, got %ld\n", sizeof(CRYPT_INTEGER_BLOB), + bufSize); + ok(buf != NULL, "Expected allocated buffer\n"); + if (buf) + { + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; + + ok(blob->cbData == strlen(bigInts[i].decoded), + "Expected len %d, got %ld\n", strlen(bigInts[i].decoded), + blob->cbData); + ok(!memcmp(blob->pbData, bigInts[i].decoded, blob->cbData), + "Unexpected value\n"); + LocalFree(buf); + } + } + for (i = 0; i < sizeof(bigUInts) / sizeof(bigUInts[0]); i++) + { + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + (BYTE *)bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL, + &bufSize); + ok(ret && GetLastError() == NOERROR, + "Expected success and NOERROR, got %ld\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + (BYTE *)bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %ld\n", GetLastError()); + ok(bufSize >= sizeof(CRYPT_INTEGER_BLOB), + "Expected size at least %d, got %ld\n", sizeof(CRYPT_INTEGER_BLOB), + bufSize); + ok(buf != NULL, "Expected allocated buffer\n"); + if (buf) + { + CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; + + ok(blob->cbData == strlen(bigUInts[i].val), + "Expected len %d, got %ld\n", strlen(bigUInts[i].val), + blob->cbData); + ok(!memcmp(blob->pbData, bigUInts[i].val, blob->cbData), + "Unexpected value\n"); + LocalFree(buf); + } + } +} + +/* These are always encoded unsigned, and aren't constrained to be any + * particular value + */ +static const struct encodedInt enums[] = { + { 1, "\x0a\x01\x01" }, + { -128, "\x0a\x05\x00\xff\xff\xff\x80" }, +}; + +/* X509_CRL_REASON_CODE is also an enumerated type, but it's #defined to + * X509_ENUMERATED. + */ +static const LPCSTR enumeratedTypes[] = { X509_ENUMERATED, + szOID_CRL_REASON_CODE }; + +static void test_encodeEnumerated(DWORD dwEncoding) +{ + DWORD i, j; + + for (i = 0; i < sizeof(enumeratedTypes) / sizeof(enumeratedTypes[0]); i++) + { + for (j = 0; j < sizeof(enums) / sizeof(enums[0]); j++) + { + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + ret = CryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], + &enums[j].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, + &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); + if (buf) + { + ok(buf[0] == 0xa, + "Got unexpected type %d for enumerated (expected 0xa)\n", + buf[0]); + ok(buf[1] == enums[j].encoded[1], + "Got length %d, expected %d\n", buf[1], enums[j].encoded[1]); + ok(!memcmp(buf + 1, enums[j].encoded + 1, + enums[j].encoded[1] + 1), + "Encoded value of 0x%08x didn't match expected\n", + enums[j].val); + LocalFree(buf); + } + } + } +} + +static void test_decodeEnumerated(DWORD dwEncoding) +{ + DWORD i, j; + + for (i = 0; i < sizeof(enumeratedTypes) / sizeof(enumeratedTypes[0]); i++) + { + for (j = 0; j < sizeof(enums) / sizeof(enums[0]); j++) + { + BOOL ret; + DWORD bufSize = sizeof(int); + int val; + + ret = CryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], + enums[j].encoded, enums[j].encoded[1] + 2, 0, NULL, + (BYTE *)&val, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + ok(bufSize == sizeof(int), + "Got unexpected size %ld for enumerated (expected %d)\n", + bufSize, sizeof(int)); + ok(val == enums[j].val, "Unexpected value %d, expected %d\n", + val, enums[j].val); + } + } +} + +struct encodedFiletime +{ + SYSTEMTIME sysTime; + const BYTE *encodedTime; +}; + +static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, + const struct encodedFiletime *time) +{ + FILETIME ft = { 0 }; + BYTE *buf = NULL; + DWORD bufSize = 0; + BOOL ret; + + ret = SystemTimeToFileTime(&time->sysTime, &ft); + ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError()); + ret = CryptEncodeObjectEx(dwEncoding, structType, &ft, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + /* years other than 1950-2050 are not allowed for encodings other than + * X509_CHOICE_OF_TIME. + */ + if (structType == X509_CHOICE_OF_TIME || + (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050)) + { + ok(ret, "CryptEncodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(), + GetLastError()); + ok(buf != NULL, "Expected an allocated buffer\n"); + if (buf) + { + ok(buf[0] == time->encodedTime[0], + "Expected type 0x%02x, got 0x%02x\n", time->encodedTime[0], + buf[0]); + ok(buf[1] == time->encodedTime[1], "Expected %d bytes, got %ld\n", + time->encodedTime[1], bufSize); + ok(!memcmp(time->encodedTime + 2, buf + 2, time->encodedTime[1]), + "Got unexpected value for time encoding\n"); + LocalFree(buf); + } + } + else + ok(!ret && GetLastError() == CRYPT_E_BAD_ENCODE, + "Expected CRYPT_E_BAD_ENCODE, got 0x%08lx\n", GetLastError()); +} + +static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, + const struct encodedFiletime *time) +{ + FILETIME ft1 = { 0 }, ft2 = { 0 }; + DWORD size = sizeof(ft2); + BOOL ret; + + ret = SystemTimeToFileTime(&time->sysTime, &ft1); + ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, + time->encodedTime[1] + 2, 0, NULL, &ft2, &size); + /* years other than 1950-2050 are not allowed for encodings other than + * X509_CHOICE_OF_TIME. + */ + if (structType == X509_CHOICE_OF_TIME || + (time->sysTime.wYear >= 1950 && time->sysTime.wYear <= 2050)) + { + ok(ret, "CryptDecodeObjectEx failed: %ld (0x%08lx)\n", GetLastError(), + GetLastError()); + ok(!memcmp(&ft1, &ft2, sizeof(ft1)), + "Got unexpected value for time decoding\n"); + } + else + ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, + "Expected CRYPT_E_ASN1_BADTAG, got 0x%08lx\n", GetLastError()); +} + +static const struct encodedFiletime times[] = { + { { 2005, 6, 1, 6, 16, 10, 0, 0 }, "\x17" "\x0d" "050606161000Z" }, + { { 1945, 6, 1, 6, 16, 10, 0, 0 }, "\x18" "\x0f" "19450606161000Z" }, + { { 2145, 6, 1, 6, 16, 10, 0, 0 }, "\x18" "\x0f" "21450606161000Z" }, +}; + +static void test_encodeFiletime(DWORD dwEncoding) +{ + DWORD i; + + for (i = 0; i < sizeof(times) / sizeof(times[0]); i++) + { + testTimeEncoding(dwEncoding, X509_CHOICE_OF_TIME, ×[i]); + testTimeEncoding(dwEncoding, PKCS_UTC_TIME, ×[i]); + testTimeEncoding(dwEncoding, szOID_RSA_signingTime, ×[i]); + } +} + +static void test_decodeFiletime(DWORD dwEncoding) +{ + static const struct encodedFiletime otherTimes[] = { + { { 1945, 6, 1, 6, 16, 10, 0, 0 }, "\x18" "\x13" "19450606161000.000Z" }, + { { 1945, 6, 1, 6, 16, 10, 0, 999 }, "\x18" "\x13" "19450606161000.999Z" }, + { { 1945, 6, 1, 6, 17, 10, 0, 0 }, "\x18" "\x13" "19450606161000+0100" }, + { { 1945, 6, 1, 6, 15, 10, 0, 0 }, "\x18" "\x13" "19450606161000-0100" }, + { { 1945, 6, 1, 6, 14, 55, 0, 0 }, "\x18" "\x13" "19450606161000-0115" }, + { { 2145, 6, 1, 6, 16, 0, 0, 0 }, "\x18" "\x0a" "2145060616" }, + { { 2045, 6, 1, 6, 16, 10, 0, 0 }, "\x17" "\x0a" "4506061610" }, + { { 2045, 6, 1, 6, 16, 10, 0, 0 }, "\x17" "\x0b" "4506061610Z" }, + { { 2045, 6, 1, 6, 17, 10, 0, 0 }, "\x17" "\x0d" "4506061610+01" }, + { { 2045, 6, 1, 6, 15, 10, 0, 0 }, "\x17" "\x0d" "4506061610-01" }, + { { 2045, 6, 1, 6, 17, 10, 0, 0 }, "\x17" "\x0f" "4506061610+0100" }, + { { 2045, 6, 1, 6, 15, 10, 0, 0 }, "\x17" "\x0f" "4506061610-0100" }, + }; + /* An oddball case that succeeds in Windows, but doesn't seem correct + { { 2145, 6, 1, 2, 11, 31, 0, 0 }, "\x18" "\x13" "21450606161000-9999" }, + */ + static const char *bogusTimes[] = { + /* oddly, this succeeds on Windows, with year 2765 + "\x18" "\x0f" "21r50606161000Z", + */ + "\x17" "\x08" "45060616", + "\x18" "\x0f" "aaaaaaaaaaaaaaZ", + "\x18" "\x04" "2145", + "\x18" "\x08" "21450606", + }; + DWORD i, size; + FILETIME ft1 = { 0 }, ft2 = { 0 }; + BOOL ret; + + /* Check bogus length with non-NULL buffer */ + ret = SystemTimeToFileTime(×[0].sysTime, &ft1); + ok(ret, "SystemTimeToFileTime failed: %ld\n", GetLastError()); + size = 1; + ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + times[0].encodedTime, times[0].encodedTime[1] + 2, 0, NULL, &ft2, &size); + ok(!ret && GetLastError() == ERROR_MORE_DATA, + "Expected ERROR_MORE_DATA, got %ld\n", GetLastError()); + /* Normal tests */ + for (i = 0; i < sizeof(times) / sizeof(times[0]); i++) + { + testTimeDecoding(dwEncoding, X509_CHOICE_OF_TIME, ×[i]); + testTimeDecoding(dwEncoding, PKCS_UTC_TIME, ×[i]); + testTimeDecoding(dwEncoding, szOID_RSA_signingTime, ×[i]); + } + for (i = 0; i < sizeof(otherTimes) / sizeof(otherTimes[0]); i++) + { + testTimeDecoding(dwEncoding, X509_CHOICE_OF_TIME, &otherTimes[i]); + testTimeDecoding(dwEncoding, PKCS_UTC_TIME, &otherTimes[i]); + testTimeDecoding(dwEncoding, szOID_RSA_signingTime, &otherTimes[i]); + } + for (i = 0; i < sizeof(bogusTimes) / sizeof(bogusTimes[0]); i++) + { + size = sizeof(ft1); + ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + bogusTimes[i], bogusTimes[i][1] + 2, 0, NULL, &ft1, &size); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); + } +} + +struct EncodedName +{ + CERT_RDN_ATTR attr; + BYTE *encoded; +}; + +static const char commonName[] = "Juan Lang"; +static const char surName[] = "Lang"; +static const char bogusIA5[] = "\x80"; +static const char bogusPrintable[] = "~"; +static const char bogusNumeric[] = "A"; +static const struct EncodedName names[] = { + { { szOID_COMMON_NAME, CERT_RDN_PRINTABLE_STRING, + { sizeof(commonName), (BYTE *)commonName } }, + "\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x13\x0aJuan Lang" }, + { { szOID_COMMON_NAME, CERT_RDN_IA5_STRING, + { sizeof(commonName), (BYTE *)commonName } }, + "\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x16\x0aJuan Lang" }, + { { szOID_SUR_NAME, CERT_RDN_IA5_STRING, + { sizeof(surName), (BYTE *)surName } }, + "\x30\x10\x31\x0e\x30\x0c\x06\x03\x55\x04\x04\x16\x05Lang" }, + { { NULL, CERT_RDN_PRINTABLE_STRING, + { sizeof(commonName), (BYTE *)commonName } }, + "\x30\x12\x31\x10\x30\x0e\x06\x00\x13\x0aJuan Lang" }, +/* The following test isn't a very good one, because it doesn't encode any + * Japanese characters. I'm leaving it out for now. + { { szOID_COMMON_NAME, CERT_RDN_T61_STRING, + { sizeof(commonName), (BYTE *)commonName } }, + "\x30\x15\x31\x13\x30\x11\x06\x03\x55\x04\x03\x14\x0aJuan Lang" }, + */ + /* The following tests succeed under Windows, but really should fail, + * they contain characters that are illegal for the encoding. I'm + * including them to justify my lazy encoding. + */ + { { szOID_COMMON_NAME, CERT_RDN_IA5_STRING, + { sizeof(bogusIA5), (BYTE *)bogusIA5 } }, + "\x30\x0d\x31\x0b\x30\x09\x06\x03\x55\x04\x03\x16\x02\x80" }, + { { szOID_COMMON_NAME, CERT_RDN_PRINTABLE_STRING, + { sizeof(bogusPrintable), (BYTE *)bogusPrintable } }, + "\x30\x0d\x31\x0b\x30\x09\x06\x03\x55\x04\x03\x13\x02\x7e" }, + { { szOID_COMMON_NAME, CERT_RDN_NUMERIC_STRING, + { sizeof(bogusNumeric), (BYTE *)bogusNumeric } }, + "\x30\x0d\x31\x0b\x30\x09\x06\x03\x55\x04\x03\x12\x02\x41" }, +}; + +static const BYTE emptyName[] = { 0x30, 0 }; +static const BYTE emptyRDNs[] = { 0x30, 0x02, 0x31, 0 }; +static const BYTE twoRDNs[] = "\x30\x23\x31\x21\x30\x0c\x06\x03\x55\x04\x04" + "\x13\x05\x4c\x61\x6e\x67\x00\x30\x11\x06\x03\x55\x04\x03" + "\x13\x0a\x4a\x75\x61\x6e\x20\x4c\x61\x6e\x67"; + +static void test_encodeName(DWORD dwEncoding) +{ + CERT_RDN_ATTR attrs[2]; + CERT_RDN rdn; + CERT_NAME_INFO info; + BYTE *buf = NULL; + DWORD size = 0, i; + BOOL ret; + + /* Test with NULL pvStructInfo */ + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, NULL, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_NAME_INFO */ + info.cRDN = 0; + info.rgRDN = NULL; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(!memcmp(buf, emptyName, sizeof(emptyName)), + "Got unexpected encoding for empty name\n"); + LocalFree(buf); + } + /* Test with bogus CERT_RDN */ + info.cRDN = 1; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* Test with empty CERT_RDN */ + rdn.cRDNAttr = 0; + rdn.rgRDNAttr = NULL; + info.cRDN = 1; + info.rgRDN = &rdn; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(!memcmp(buf, emptyRDNs, sizeof(emptyRDNs)), + "Got unexpected encoding for empty RDN array\n"); + LocalFree(buf); + } + /* Test with bogus attr array */ + rdn.cRDNAttr = 1; + rdn.rgRDNAttr = NULL; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, + "Expected STATUS_ACCESS_VIOLATION, got %08lx\n", GetLastError()); + /* oddly, a bogus OID is accepted by Windows XP; not testing. + attrs[0].pszObjId = "bogus"; + attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; + attrs[0].Value.cbData = sizeof(commonName); + attrs[0].Value.pbData = (BYTE *)commonName; + rdn.cRDNAttr = 1; + rdn.rgRDNAttr = attrs; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret, "Expected failure, got success\n"); + */ + /* Check with two CERT_RDN_ATTRs. Note DER encoding forces the order of + * the encoded attributes to be swapped. + */ + attrs[0].pszObjId = szOID_COMMON_NAME; + attrs[0].dwValueType = CERT_RDN_PRINTABLE_STRING; + attrs[0].Value.cbData = sizeof(commonName); + attrs[0].Value.pbData = (BYTE *)commonName; + attrs[1].pszObjId = szOID_SUR_NAME; + attrs[1].dwValueType = CERT_RDN_PRINTABLE_STRING; + attrs[1].Value.cbData = sizeof(surName); + attrs[1].Value.pbData = (BYTE *)surName; + rdn.cRDNAttr = 2; + rdn.rgRDNAttr = attrs; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(!memcmp(buf, twoRDNs, sizeof(twoRDNs)), + "Got unexpected encoding for two RDN array\n"); + LocalFree(buf); + } + /* CERT_RDN_ANY_TYPE is too vague for X509_NAMEs, check the return */ + rdn.cRDNAttr = 1; + attrs[0].dwValueType = CERT_RDN_ANY_TYPE; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(!ret && GetLastError() == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), + "Expected ERROR_INVALID_PARAMETER, got %08lx\n", GetLastError()); + for (i = 0; i < sizeof(names) / sizeof(names[0]); i++) + { + rdn.cRDNAttr = 1; + rdn.rgRDNAttr = (CERT_RDN_ATTR *)&names[i].attr; + ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(size == names[i].encoded[1] + 2, "Expected size %d, got %ld\n", + names[i].encoded[1] + 2, size); + ok(!memcmp(buf, names[i].encoded, names[i].encoded[1] + 2), + "Got unexpected encoding\n"); + LocalFree(buf); + } + } +} + +static void compareNames(const CERT_NAME_INFO *expected, + const CERT_NAME_INFO *got) +{ + ok(got->cRDN == expected->cRDN, "Expected %ld RDNs, got %ld\n", + expected->cRDN, got->cRDN); + if (expected->cRDN) + { + ok(got->rgRDN[0].cRDNAttr == expected->rgRDN[0].cRDNAttr, + "Expected %ld RDN attrs, got %ld\n", expected->rgRDN[0].cRDNAttr, + got->rgRDN[0].cRDNAttr); + if (expected->rgRDN[0].cRDNAttr) + { + if (expected->rgRDN[0].rgRDNAttr[0].pszObjId && + strlen(expected->rgRDN[0].rgRDNAttr[0].pszObjId)) + { + ok(got->rgRDN[0].rgRDNAttr[0].pszObjId != NULL, + "Expected OID %s, got NULL\n", + expected->rgRDN[0].rgRDNAttr[0].pszObjId); + if (got->rgRDN[0].rgRDNAttr[0].pszObjId) + ok(!strcmp(got->rgRDN[0].rgRDNAttr[0].pszObjId, + expected->rgRDN[0].rgRDNAttr[0].pszObjId), + "Got unexpected OID %s, expected %s\n", + got->rgRDN[0].rgRDNAttr[0].pszObjId, + expected->rgRDN[0].rgRDNAttr[0].pszObjId); + } + ok(got->rgRDN[0].rgRDNAttr[0].Value.cbData == + expected->rgRDN[0].rgRDNAttr[0].Value.cbData, + "Unexpected data size, got %ld, expected %ld\n", + got->rgRDN[0].rgRDNAttr[0].Value.cbData, + expected->rgRDN[0].rgRDNAttr[0].Value.cbData); + if (expected->rgRDN[0].rgRDNAttr[0].Value.pbData) + ok(!memcmp(got->rgRDN[0].rgRDNAttr[0].Value.pbData, + expected->rgRDN[0].rgRDNAttr[0].Value.pbData, + expected->rgRDN[0].rgRDNAttr[0].Value.cbData), + "Unexpected value\n"); + } + } +} + +static void test_decodeName(DWORD dwEncoding) +{ + int i; + BYTE *buf = NULL; + DWORD bufSize = 0; + BOOL ret; + CERT_RDN rdn; + CERT_NAME_INFO info = { 1, &rdn }; + + for (i = 0; i < sizeof(names) / sizeof(names[0]); i++) + { + /* When the output buffer is NULL, this always succeeds */ + SetLastError(0xdeadbeef); + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, names[i].encoded, + names[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); + ok(ret && GetLastError() == NOERROR, + "Expected success and NOERROR, got %08lx\n", GetLastError()); + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, names[i].encoded, + names[i].encoded[1] + 2, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, + (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + rdn.cRDNAttr = 1; + rdn.rgRDNAttr = (CERT_RDN_ATTR *)&names[i].attr; + if (buf) + { + compareNames((CERT_NAME_INFO *)buf, &info); + LocalFree(buf); + } + } + /* test empty name */ + bufSize = 0; + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyName, + emptyName[1] + 2, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, + (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + /* Interestingly, in Windows, if cRDN is 0, rgRGN may not be NULL. My + * decoder works the same way, so only test the count. + */ + if (buf) + { + ok(bufSize == sizeof(CERT_NAME_INFO), + "Expected bufSize %d, got %ld\n", sizeof(CERT_NAME_INFO), bufSize); + ok(((CERT_NAME_INFO *)buf)->cRDN == 0, + "Expected 0 RDNs in empty info, got %ld\n", + ((CERT_NAME_INFO *)buf)->cRDN); + LocalFree(buf); + } + /* test empty RDN */ + bufSize = 0; + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyRDNs, + emptyRDNs[1] + 2, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, + (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CERT_NAME_INFO *info = (CERT_NAME_INFO *)buf; + + ok(bufSize == sizeof(CERT_NAME_INFO) + sizeof(CERT_RDN) && + info->cRDN == 1 && info->rgRDN && info->rgRDN[0].cRDNAttr == 0, + "Got unexpected value for empty RDN\n"); + LocalFree(buf); + } + /* test two RDN attrs */ + bufSize = 0; + ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNs, + twoRDNs[1] + 2, + CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, + (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CERT_RDN_ATTR attrs[] = { + { szOID_SUR_NAME, CERT_RDN_PRINTABLE_STRING, { sizeof(surName), + (BYTE *)surName } }, + { szOID_COMMON_NAME, CERT_RDN_PRINTABLE_STRING, { sizeof(commonName), + (BYTE *)commonName } }, + }; + + rdn.cRDNAttr = sizeof(attrs) / sizeof(attrs[0]); + rdn.rgRDNAttr = attrs; + compareNames((CERT_NAME_INFO *)buf, &info); + LocalFree(buf); + } +} + +struct encodedOctets +{ + BYTE *val; + BYTE *encoded; +}; + +static const struct encodedOctets octets[] = { + { "hi", "\x04\x02hi" }, + { "somelong\xffstring", "\x04\x0fsomelong\xffstring" }, + { "", "\x04\x00" }, +}; + +static void test_encodeOctets(DWORD dwEncoding) +{ + CRYPT_DATA_BLOB blob; + DWORD i; + + for (i = 0; i < sizeof(octets) / sizeof(octets[0]); i++) + { + BYTE *buf = NULL; + BOOL ret; + DWORD bufSize = 0; + + blob.cbData = strlen(octets[i].val); + blob.pbData = (BYTE *)octets[i].val; + ret = CryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %ld\n", GetLastError()); + if (buf) + { + ok(buf[0] == 4, + "Got unexpected type %d for octet string (expected 4)\n", buf[0]); + ok(buf[1] == octets[i].encoded[1], "Got length %d, expected %d\n", + buf[1], octets[i].encoded[1]); + ok(!memcmp(buf + 1, octets[i].encoded + 1, + octets[i].encoded[1] + 1), "Got unexpected value\n"); + LocalFree(buf); + } + } +} + +static void test_decodeOctets(DWORD dwEncoding) +{ + DWORD i; + + for (i = 0; i < sizeof(octets) / sizeof(octets[0]); i++) + { + BYTE *buf = NULL; + BOOL ret; + DWORD bufSize = 0; + + ret = CryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, + (BYTE *)octets[i].encoded, octets[i].encoded[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + ok(bufSize >= sizeof(CRYPT_DATA_BLOB) + octets[i].encoded[1], + "Expected size >= %d, got %ld\n", + sizeof(CRYPT_DATA_BLOB) + octets[i].encoded[1], bufSize); + ok(buf != NULL, "Expected allocated buffer\n"); + if (buf) + { + CRYPT_DATA_BLOB *blob = (CRYPT_DATA_BLOB *)buf; + + if (blob->cbData) + ok(!memcmp(blob->pbData, octets[i].val, blob->cbData), + "Unexpected value\n"); + LocalFree(buf); + } + } +} + +static const BYTE bytesToEncode[] = { 0xff, 0xff }; + +struct encodedBits +{ + DWORD cUnusedBits; + BYTE *encoded; + DWORD cbDecoded; + BYTE *decoded; +}; + +static const struct encodedBits bits[] = { + /* normal test case */ + { 1, "\x03\x03\x01\xff\xfe", 2, "\xff\xfe" }, + /* strange test case, showing cUnusedBits >= 8 is allowed */ + { 9, "\x03\x02\x01\xfe", 1, "\xfe" }, + /* even stranger test case, showing cUnusedBits > cbData * 8 is allowed */ + { 17, "\x03\x01\x00", 0, NULL }, +}; + +static void test_encodeBits(DWORD dwEncoding) +{ + DWORD i; + + for (i = 0; i < sizeof(bits) / sizeof(bits[0]); i++) + { + CRYPT_BIT_BLOB blob; + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + blob.cbData = sizeof(bytesToEncode); + blob.pbData = (BYTE *)bytesToEncode; + blob.cUnusedBits = bits[i].cUnusedBits; + ret = CryptEncodeObjectEx(dwEncoding, X509_BITS, &blob, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(bufSize == bits[i].encoded[1] + 2, + "Got unexpected size %ld, expected %d\n", bufSize, + bits[i].encoded[1] + 2); + ok(!memcmp(buf, bits[i].encoded, bits[i].encoded[1] + 2), + "Unexpected value\n"); + LocalFree(buf); + } + } +} + +static void test_decodeBits(DWORD dwEncoding) +{ + static const BYTE ber[] = "\x03\x02\x01\xff"; + static const BYTE berDecoded = 0xfe; + DWORD i; + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + /* normal cases */ + for (i = 0; i < sizeof(bits) / sizeof(bits[0]); i++) + { + ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, + bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, + &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CRYPT_BIT_BLOB *blob; + + ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + bits[i].cbDecoded, + "Got unexpected size %ld, expected >= %ld\n", bufSize, + sizeof(CRYPT_BIT_BLOB) + bits[i].cbDecoded); + blob = (CRYPT_BIT_BLOB *)buf; + ok(blob->cbData == bits[i].cbDecoded, + "Got unexpected length %ld, expected %ld\n", blob->cbData, + bits[i].cbDecoded); + if (blob->cbData && bits[i].cbDecoded) + ok(!memcmp(blob->pbData, bits[i].decoded, bits[i].cbDecoded), + "Unexpected value\n"); + LocalFree(buf); + } + } + /* special case: check that something that's valid in BER but not in DER + * decodes successfully + */ + ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CRYPT_BIT_BLOB *blob; + + ok(bufSize >= sizeof(CRYPT_BIT_BLOB) + sizeof(berDecoded), + "Got unexpected size %ld, expected >= %d\n", bufSize, + sizeof(CRYPT_BIT_BLOB) + berDecoded); + blob = (CRYPT_BIT_BLOB *)buf; + ok(blob->cbData == sizeof(berDecoded), + "Got unexpected length %ld, expected %d\n", blob->cbData, + sizeof(berDecoded)); + if (blob->cbData) + ok(*blob->pbData == berDecoded, "Unexpected value\n"); + LocalFree(buf); + } +} + +struct Constraints2 +{ + CERT_BASIC_CONSTRAINTS2_INFO info; + const BYTE *encoded; +}; + +static const struct Constraints2 constraints2[] = { + /* empty constraints */ + { { FALSE, FALSE, 0}, "\x30\x00" }, + /* can be a CA */ + { { TRUE, FALSE, 0}, "\x30\x03\x01\x01\xff" }, + /* has path length constraints set (MSDN implies fCA needs to be TRUE as well, + * but that's not the case + */ + { { FALSE, TRUE, 0}, "\x30\x03\x02\x01\x00" }, + /* can be a CA and has path length constraints set */ + { { TRUE, TRUE, 1}, "\x30\x06\x01\x01\xff\x02\x01\x01" }, +}; + +static void test_encodeBasicConstraints(DWORD dwEncoding) +{ + DWORD i; + + /* First test with the simpler info2 */ + for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++) + { + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + &constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, + &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(bufSize == constraints2[i].encoded[1] + 2, + "Expected %d bytes, got %ld\n", constraints2[i].encoded[1] + 2, + bufSize); + ok(!memcmp(buf, constraints2[i].encoded, + constraints2[i].encoded[1] + 2), "Unexpected value\n"); + LocalFree(buf); + } + } +} + +static void test_decodeBasicConstraints(DWORD dwEncoding) +{ + static const BYTE inverted[] = "\x30\x06\x02\x01\x01\x01\x01\xff"; + static const struct Constraints2 badBool = { { TRUE, TRUE, 1 }, + "\x30\x06\x01\x01\x01\x02\x01\x01" }; + DWORD i; + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + /* First test with simpler info2 */ + for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++) + { + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + constraints2[i].encoded, constraints2[i].encoded[1] + 2, + CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CERT_BASIC_CONSTRAINTS2_INFO *info = + (CERT_BASIC_CONSTRAINTS2_INFO *)buf; + + ok(!memcmp(info, &constraints2[i].info, sizeof(*info)), + "Unexpected value\n"); + LocalFree(buf); + } + } + /* Check with the order of encoded elements inverted */ + buf = (PBYTE)1; + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + inverted, inverted[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, + &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); + ok(!buf, "Expected buf to be set to NULL\n"); + /* Check with a non-DER bool */ + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + badBool.encoded, badBool.encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, + (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CERT_BASIC_CONSTRAINTS2_INFO *info = + (CERT_BASIC_CONSTRAINTS2_INFO *)buf; + + ok(!memcmp(info, &badBool.info, sizeof(*info)), "Unexpected value\n"); + LocalFree(buf); + } + /* Check with a non-basic constraints value */ + ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + names[0].encoded, names[0].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, + (BYTE *)&buf, &bufSize); + ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, + "Expected CRYPT_E_ASN1_CORRUPT, got %08lx\n", GetLastError()); +} + +static const BYTE intSequence[] = { 0x30, 0x1b, 0x02, 0x01, 0x01, 0x02, 0x01, + 0x7f, 0x02, 0x02, 0x00, 0x80, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x80, 0x02, + 0x02, 0xff, 0x7f, 0x02, 0x04, 0xba, 0xdd, 0xf0, 0x0d }; + +static const BYTE mixedSequence[] = { 0x30, 0x27, 0x17, 0x0d, 0x30, 0x35, 0x30, + 0x36, 0x30, 0x36, 0x31, 0x36, 0x31, 0x30, 0x30, 0x30, 0x5a, 0x02, 0x01, 0x7f, + 0x02, 0x02, 0x00, 0x80, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x80, 0x02, 0x02, + 0xff, 0x7f, 0x02, 0x04, 0xba, 0xdd, 0xf0, 0x0d }; + +static void test_encodeSequenceOfAny(DWORD dwEncoding) +{ + CRYPT_DER_BLOB blobs[sizeof(ints) / sizeof(ints[0])]; + CRYPT_SEQUENCE_OF_ANY seq; + DWORD i; + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + /* Encode a homogenous sequence */ + for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) + { + blobs[i].cbData = ints[i].encoded[1] + 2; + blobs[i].pbData = ints[i].encoded; + } + seq.cValue = sizeof(ints) / sizeof(ints[0]); + seq.rgValue = blobs; + + ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(bufSize == sizeof(intSequence), "Expected %d bytes, got %ld\n", + sizeof(intSequence), bufSize); + ok(!memcmp(buf, intSequence, intSequence[1] + 2), "Unexpected value\n"); + LocalFree(buf); + } + /* Change the type of the first element in the sequence, and give it + * another go + */ + blobs[0].cbData = times[0].encodedTime[1] + 2; + blobs[0].pbData = (BYTE *)times[0].encodedTime; + ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + ok(bufSize == sizeof(mixedSequence), "Expected %d bytes, got %ld\n", + sizeof(mixedSequence), bufSize); + ok(!memcmp(buf, mixedSequence, mixedSequence[1] + 2), + "Unexpected value\n"); + LocalFree(buf); + } +} + +static void test_decodeSequenceOfAny(DWORD dwEncoding) +{ + BOOL ret; + BYTE *buf = NULL; + DWORD bufSize = 0; + + ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence, + intSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf; + DWORD i; + + ok(seq->cValue == sizeof(ints) / sizeof(ints[0]), + "Expected %d elements, got %ld\n", sizeof(ints) / sizeof(ints[0]), + seq->cValue); + for (i = 0; i < min(seq->cValue, sizeof(ints) / sizeof(ints[0])); i++) + { + ok(seq->rgValue[i].cbData == ints[i].encoded[1] + 2, + "Expected %d bytes, got %ld\n", ints[i].encoded[1] + 2, + seq->rgValue[i].cbData); + ok(!memcmp(seq->rgValue[i].pbData, ints[i].encoded, + ints[i].encoded[1] + 2), "Unexpected value\n"); + } + LocalFree(buf); + } + ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence, + mixedSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, + &bufSize); + ok(ret, "CryptDecodeObjectEx failed: %08lx\n", GetLastError()); + if (buf) + { + CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf; + + ok(seq->cValue == sizeof(ints) / sizeof(ints[0]), + "Expected %d elements, got %ld\n", sizeof(ints) / sizeof(ints[0]), + seq->cValue); + /* Just check the first element since it's all that changed */ + ok(seq->rgValue[0].cbData == times[0].encodedTime[1] + 2, + "Expected %d bytes, got %ld\n", times[0].encodedTime[1] + 2, + seq->rgValue[0].cbData); + ok(!memcmp(seq->rgValue[0].pbData, times[0].encodedTime, + times[0].encodedTime[1] + 2), "Unexpected value\n"); + LocalFree(buf); + } +} + +static void test_registerOIDFunction(void) +{ + static const WCHAR bogusDll[] = { 'b','o','g','u','s','.','d','l','l',0 }; + BOOL ret; + + /* oddly, this succeeds under WinXP; the function name key is merely + * omitted. This may be a side effect of the registry code, I don't know. + * I don't check it because I doubt anyone would depend on it. + ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, NULL, + "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + */ + /* On windows XP, GetLastError is incorrectly being set with an HRESULT, + * HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER) + */ + ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", NULL, bogusDll, + NULL); + ok(!ret && (GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == + HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER)), + "Expected ERROR_INVALID_PARAMETER: %ld\n", GetLastError()); + /* This has no effect, but "succeeds" on XP */ + ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "foo", + "1.2.3.4.5.6.7.8.9.10", NULL, NULL); + ok(ret, "Expected pseudo-success, got %ld\n", GetLastError()); + ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject", + "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); + ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "CryptDllEncodeObject", + "1.2.3.4.5.6.7.8.9.10"); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); + ret = CryptRegisterOIDFunction(X509_ASN_ENCODING, "bogus", + "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); + ret = CryptUnregisterOIDFunction(X509_ASN_ENCODING, "bogus", + "1.2.3.4.5.6.7.8.9.10"); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); + /* This has no effect */ + ret = CryptRegisterOIDFunction(PKCS_7_ASN_ENCODING, "CryptDllEncodeObject", + "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); + /* Check with bogus encoding type: */ + ret = CryptRegisterOIDFunction(0, "CryptDllEncodeObject", + "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); + /* This is written with value 3 verbatim. Thus, the encoding type isn't + * (for now) treated as a mask. + */ + ret = CryptRegisterOIDFunction(3, "CryptDllEncodeObject", + "1.2.3.4.5.6.7.8.9.10", bogusDll, NULL); + ok(ret, "CryptRegisterOIDFunction failed: %ld\n", GetLastError()); + ret = CryptUnregisterOIDFunction(3, "CryptDllEncodeObject", + "1.2.3.4.5.6.7.8.9.10"); + ok(ret, "CryptUnregisterOIDFunction failed: %ld\n", GetLastError()); +} + +START_TEST(encode) +{ + static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING, + X509_ASN_ENCODING | PKCS_7_ASN_ENCODING }; + DWORD i; + + for (i = 0; i < sizeof(encodings) / sizeof(encodings[0]); i++) + { + test_encodeInt(encodings[i]); + test_decodeInt(encodings[i]); + test_encodeEnumerated(encodings[i]); + test_decodeEnumerated(encodings[i]); + test_encodeFiletime(encodings[i]); + test_decodeFiletime(encodings[i]); + test_encodeName(encodings[i]); + test_decodeName(encodings[i]); + test_encodeOctets(encodings[i]); + test_decodeOctets(encodings[i]); + test_encodeBits(encodings[i]); + test_decodeBits(encodings[i]); + test_encodeBasicConstraints(encodings[i]); + test_decodeBasicConstraints(encodings[i]); + test_encodeSequenceOfAny(encodings[i]); + test_decodeSequenceOfAny(encodings[i]); + } + test_registerOIDFunction(); +} diff -urN wine-20050524/dlls/crypt32/tests/main.c wine-20050628/dlls/crypt32/tests/main.c --- wine-20050524/dlls/crypt32/tests/main.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/crypt32/tests/main.c 2005-06-14 13:38:36.000000000 +0200 @@ -0,0 +1,120 @@ +/* + * Miscellaneous crypt32 tests + * + * Copyright 2005 Juan Lang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include + +#include "wine/test.h" + +struct OIDToAlgID +{ + LPCSTR oid; + DWORD algID; +}; + +static const struct OIDToAlgID oidToAlgID[] = { + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_MD2RSA, CALG_MD2 }, + { szOID_RSA_MD4RSA, CALG_MD4 }, + { szOID_RSA_MD5RSA, CALG_MD5 }, + { szOID_RSA_SHA1RSA, CALG_SHA }, + { szOID_RSA_DH, CALG_DH_SF }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES }, + { szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2 }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_X957_SHA1DSA, CALG_SHA }, + { szOID_OIWSEC_md4RSA, CALG_MD4 }, + { szOID_OIWSEC_md5RSA, CALG_MD5 }, + { szOID_OIWSEC_md4RSA2, CALG_MD4 }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_dsa, CALG_DSS_SIGN }, + { szOID_OIWSEC_shaDSA, CALG_SHA }, + { szOID_OIWSEC_shaRSA, CALG_SHA }, + { szOID_OIWSEC_sha, CALG_SHA }, + { szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX }, + { szOID_OIWSEC_sha1, CALG_SHA }, + { szOID_OIWSEC_dsaSHA1, CALG_SHA }, + { szOID_OIWSEC_sha1RSASign, CALG_SHA }, + { szOID_OIWDIR_md2RSA, CALG_MD2 }, + { szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA }, + { szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN }, +}; + +static const struct OIDToAlgID algIDToOID[] = { + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_sha1, CALG_SHA }, +}; + +static void testOIDToAlgID(void) +{ + int i; + + for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++) + { + DWORD alg = CertOIDToAlgId(oidToAlgID[i].oid); + + ok(alg == oidToAlgID[i].algID, + "Expected %ld, got %ld\n", oidToAlgID[i].algID, alg); + } +} + +static void testAlgIDToOID(void) +{ + int i; + + for (i = 0; i < sizeof(algIDToOID) / sizeof(algIDToOID[0]); i++) + { + LPCSTR oid = CertAlgIdToOID(algIDToOID[i].algID); + + if ((!oid || !algIDToOID[i].oid) && oid != algIDToOID[i].oid && + algIDToOID[i].algID) + printf("Expected %s, got %s\n", algIDToOID[i].oid, oid); + else if (oid && algIDToOID[i].oid && strcmp(oid, algIDToOID[i].oid)) + printf("Expected %s, got %s\n", algIDToOID[i].oid, oid); + } +} + +START_TEST(main) +{ + testOIDToAlgID(); + testAlgIDToOID(); +} diff -urN wine-20050524/dlls/d3d8/basetexture.c wine-20050628/dlls/d3d8/basetexture.c --- wine-20050524/dlls/d3d8/basetexture.c 2005-01-24 13:43:26.000000000 +0100 +++ wine-20050628/dlls/d3d8/basetexture.c 2005-05-27 22:17:37.000000000 +0200 @@ -130,7 +130,7 @@ return This->levels; } -IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl = +static const IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl = { IDirect3DBaseTexture8Impl_QueryInterface, IDirect3DBaseTexture8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/cubetexture.c wine-20050628/dlls/d3d8/cubetexture.c --- wine-20050524/dlls/d3d8/cubetexture.c 2005-01-24 13:43:26.000000000 +0100 +++ wine-20050628/dlls/d3d8/cubetexture.c 2005-05-27 22:17:37.000000000 +0200 @@ -279,7 +279,7 @@ } -IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl = +const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl = { IDirect3DCubeTexture8Impl_QueryInterface, IDirect3DCubeTexture8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/d3d8_main.c wine-20050628/dlls/d3d8/d3d8_main.c --- wine-20050524/dlls/d3d8/d3d8_main.c 2005-05-06 21:38:50.000000000 +0200 +++ wine-20050628/dlls/d3d8/d3d8_main.c 2005-06-20 18:04:32.000000000 +0200 @@ -82,7 +82,8 @@ wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" ); wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); } - if ( !RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Direct3D", &hkey) ) + /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */ + if ( !RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey) ) { if ( !RegQueryValueExA( hkey, "VertexShaderMode", 0, NULL, buffer, &size) ) { diff -urN wine-20050524/dlls/d3d8/d3d8_private.h wine-20050628/dlls/d3d8/d3d8_private.h --- wine-20050524/dlls/d3d8/d3d8_private.h 2005-03-23 14:15:20.000000000 +0100 +++ wine-20050628/dlls/d3d8/d3d8_private.h 2005-06-23 13:05:25.000000000 +0200 @@ -102,6 +102,65 @@ #define PIXEL_SHADER(Handle) \ ((Handle <= VS_HIGHESTFIXEDFXF) ? ((Handle >= sizeof(PixelShaders) / sizeof(IDirect3DPixelShaderImpl*)) ? NULL : PixelShaders[Handle]) : PixelShaders[Handle - VS_HIGHESTFIXEDFXF]) +/* =========================================================================== + Macros + =========================================================================== */ +/* Not nice, but it lets wined3d support different versions of directx */ +#define D3D8CAPSTOWINECAPS(_pD3D8Caps, _pWineCaps) \ + _pWineCaps->DeviceType = &_pD3D8Caps->DeviceType; \ + _pWineCaps->AdapterOrdinal = &_pD3D8Caps->AdapterOrdinal; \ + _pWineCaps->Caps = &_pD3D8Caps->Caps; \ + _pWineCaps->Caps2 = &_pD3D8Caps->Caps2; \ + _pWineCaps->Caps3 = &_pD3D8Caps->Caps3; \ + _pWineCaps->PresentationIntervals = &_pD3D8Caps->PresentationIntervals; \ + _pWineCaps->CursorCaps = &_pD3D8Caps->CursorCaps; \ + _pWineCaps->DevCaps = &_pD3D8Caps->DevCaps; \ + _pWineCaps->PrimitiveMiscCaps = &_pD3D8Caps->PrimitiveMiscCaps; \ + _pWineCaps->RasterCaps = &_pD3D8Caps->RasterCaps; \ + _pWineCaps->ZCmpCaps = &_pD3D8Caps->ZCmpCaps; \ + _pWineCaps->SrcBlendCaps = &_pD3D8Caps->SrcBlendCaps; \ + _pWineCaps->DestBlendCaps = &_pD3D8Caps->DestBlendCaps; \ + _pWineCaps->AlphaCmpCaps = &_pD3D8Caps->AlphaCmpCaps; \ + _pWineCaps->ShadeCaps = &_pD3D8Caps->ShadeCaps; \ + _pWineCaps->TextureCaps = &_pD3D8Caps->TextureCaps; \ + _pWineCaps->TextureFilterCaps = &_pD3D8Caps->TextureFilterCaps; \ + _pWineCaps->CubeTextureFilterCaps = &_pD3D8Caps->CubeTextureFilterCaps; \ + _pWineCaps->VolumeTextureFilterCaps = &_pD3D8Caps->VolumeTextureFilterCaps; \ + _pWineCaps->TextureAddressCaps = &_pD3D8Caps->TextureAddressCaps; \ + _pWineCaps->VolumeTextureAddressCaps = &_pD3D8Caps->VolumeTextureAddressCaps; \ + _pWineCaps->LineCaps = &_pD3D8Caps->LineCaps; \ + _pWineCaps->MaxTextureWidth = &_pD3D8Caps->MaxTextureWidth; \ + _pWineCaps->MaxTextureHeight = &_pD3D8Caps->MaxTextureHeight; \ + _pWineCaps->MaxVolumeExtent = &_pD3D8Caps->MaxVolumeExtent; \ + _pWineCaps->MaxTextureRepeat = &_pD3D8Caps->MaxTextureRepeat; \ + _pWineCaps->MaxTextureAspectRatio = &_pD3D8Caps->MaxTextureAspectRatio; \ + _pWineCaps->MaxAnisotropy = &_pD3D8Caps->MaxAnisotropy; \ + _pWineCaps->MaxVertexW = &_pD3D8Caps->MaxVertexW; \ + _pWineCaps->GuardBandLeft = &_pD3D8Caps->GuardBandLeft; \ + _pWineCaps->GuardBandTop = &_pD3D8Caps->GuardBandTop; \ + _pWineCaps->GuardBandRight = &_pD3D8Caps->GuardBandRight; \ + _pWineCaps->GuardBandBottom = &_pD3D8Caps->GuardBandBottom; \ + _pWineCaps->ExtentsAdjust = &_pD3D8Caps->ExtentsAdjust; \ + _pWineCaps->StencilCaps = &_pD3D8Caps->StencilCaps; \ + _pWineCaps->FVFCaps = &_pD3D8Caps->FVFCaps; \ + _pWineCaps->TextureOpCaps = &_pD3D8Caps->TextureOpCaps; \ + _pWineCaps->MaxTextureBlendStages = &_pD3D8Caps->MaxTextureBlendStages; \ + _pWineCaps->MaxSimultaneousTextures = &_pD3D8Caps->MaxSimultaneousTextures; \ + _pWineCaps->VertexProcessingCaps = &_pD3D8Caps->VertexProcessingCaps; \ + _pWineCaps->MaxActiveLights = &_pD3D8Caps->MaxActiveLights; \ + _pWineCaps->MaxUserClipPlanes = &_pD3D8Caps->MaxUserClipPlanes; \ + _pWineCaps->MaxVertexBlendMatrices = &_pD3D8Caps->MaxVertexBlendMatrices; \ + _pWineCaps->MaxVertexBlendMatrixIndex = &_pD3D8Caps->MaxVertexBlendMatrixIndex; \ + _pWineCaps->MaxPointSize = &_pD3D8Caps->MaxPointSize; \ + _pWineCaps->MaxPrimitiveCount = &_pD3D8Caps->MaxPrimitiveCount; \ + _pWineCaps->MaxVertexIndex = &_pD3D8Caps->MaxVertexIndex; \ + _pWineCaps->MaxStreams = &_pD3D8Caps->MaxStreams; \ + _pWineCaps->MaxStreamStride = &_pD3D8Caps->MaxStreamStride; \ + _pWineCaps->VertexShaderVersion = &_pD3D8Caps->VertexShaderVersion; \ + _pWineCaps->MaxVertexShaderConst = &_pD3D8Caps->MaxVertexShaderConst; \ + _pWineCaps->PixelShaderVersion = &_pD3D8Caps->PixelShaderVersion; \ + _pWineCaps->PixelShader1xMaxValue = &_pD3D8Caps->MaxPixelShaderValue; + /* Direct3D8 Interfaces: */ typedef struct IDirect3DBaseTexture8Impl IDirect3DBaseTexture8Impl; typedef struct IDirect3DVolumeTexture8Impl IDirect3DVolumeTexture8Impl; @@ -274,7 +333,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3D8Vtbl Direct3D8_Vtbl; +extern const IDirect3D8Vtbl Direct3D8_Vtbl; /***************************************************************************** * IDirect3D implementation structure @@ -282,7 +341,7 @@ struct IDirect3D8Impl { /* IUnknown fields */ - IDirect3D8Vtbl *lpVtbl; + const IDirect3D8Vtbl *lpVtbl; DWORD ref; /* The WineD3D device */ @@ -327,7 +386,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl; +extern const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl; /***************************************************************************** * IDirect3DDevice8 implementation structure @@ -335,7 +394,7 @@ struct IDirect3DDevice8Impl { /* IUnknown fields */ - IDirect3DDevice8Vtbl *lpVtbl; + const IDirect3DDevice8Vtbl *lpVtbl; DWORD ref; /* IDirect3DDevice8 fields */ @@ -522,7 +581,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl; +extern const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl; /***************************************************************************** * IDirect3DVolume8 implementation structure @@ -530,7 +589,7 @@ struct IDirect3DVolume8Impl { /* IUnknown fields */ - IDirect3DVolume8Vtbl *lpVtbl; + const IDirect3DVolume8Vtbl *lpVtbl; DWORD ref; /* IDirect3DVolume8 fields */ @@ -576,7 +635,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl; +extern const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl; /***************************************************************************** * IDirect3DSwapChain8 implementation structure @@ -584,7 +643,7 @@ struct IDirect3DSwapChain8Impl { /* IUnknown fields */ - IDirect3DSwapChain8Vtbl *lpVtbl; + const IDirect3DSwapChain8Vtbl *lpVtbl; DWORD ref; /* IDirect3DSwapChain8 fields */ @@ -596,6 +655,9 @@ /* OpenGL/GLX related */ GLXContext swap_ctx; Drawable swap_drawable; + + /* ready for when we move over to wined3d */ + IWineD3DSwapChain *wineD3DSwapChain; }; /* IUnknown: */ @@ -615,7 +677,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl; +extern const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl; /***************************************************************************** * IDirect3DSurface8 implementation structure @@ -623,7 +685,7 @@ struct IDirect3DSurface8Impl { /* IUnknown fields */ - IDirect3DSurface8Vtbl *lpVtbl; + const IDirect3DSurface8Vtbl *lpVtbl; DWORD ref; /* IDirect3DSurface8 fields */ @@ -675,7 +737,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DResource8Vtbl Direct3DResource8_Vtbl; +extern const IDirect3DResource8Vtbl Direct3DResource8_Vtbl; /***************************************************************************** * IDirect3DResource8 implementation structure @@ -683,7 +745,7 @@ struct IDirect3DResource8Impl { /* IUnknown fields */ - IDirect3DResource8Vtbl *lpVtbl; + const IDirect3DResource8Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource8 fields */ @@ -717,7 +779,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl; +extern const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl; /***************************************************************************** * IDirect3DVertexBuffer8 implementation structure @@ -725,7 +787,7 @@ struct IDirect3DVertexBuffer8Impl { /* IUnknown fields */ - IDirect3DVertexBuffer8Vtbl *lpVtbl; + const IDirect3DVertexBuffer8Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource8 fields */ @@ -765,7 +827,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl; +extern const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl; /***************************************************************************** * IDirect3DIndexBuffer8 implementation structure @@ -773,7 +835,7 @@ struct IDirect3DIndexBuffer8Impl { /* IUnknown fields */ - IDirect3DIndexBuffer8Vtbl *lpVtbl; + const IDirect3DIndexBuffer8Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource8 fields */ @@ -811,17 +873,12 @@ /* --------------------- */ /***************************************************************************** - * Predeclare the interface implementation structures - */ -extern IDirect3DBaseTexture8Vtbl Direct3DBaseTexture8_Vtbl; - -/***************************************************************************** * IDirect3DBaseTexture8 implementation structure */ struct IDirect3DBaseTexture8Impl { /* IUnknown fields */ - IDirect3DBaseTexture8Vtbl *lpVtbl; + const IDirect3DBaseTexture8Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource8 fields */ @@ -870,7 +927,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl; +extern const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl; /***************************************************************************** * IDirect3DCubeTexture8 implementation structure @@ -878,7 +935,7 @@ struct IDirect3DCubeTexture8Impl { /* IUnknown fields */ - IDirect3DCubeTexture8Vtbl *lpVtbl; + const IDirect3DCubeTexture8Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource8 fields */ @@ -932,7 +989,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl; +extern const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl; /***************************************************************************** * IDirect3DTexture8 implementation structure @@ -940,7 +997,7 @@ struct IDirect3DTexture8Impl { /* IUnknown fields */ - IDirect3DTexture8Vtbl *lpVtbl; + const IDirect3DTexture8Vtbl *lpVtbl; DWORD ref; /* IDirect3DResourc8 fields */ @@ -995,7 +1052,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl; +extern const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl; /***************************************************************************** * IDirect3DVolumeTexture8 implementation structure @@ -1003,7 +1060,7 @@ struct IDirect3DVolumeTexture8Impl { /* IUnknown fields */ - IDirect3DVolumeTexture8Vtbl *lpVtbl; + const IDirect3DVolumeTexture8Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource8 fields */ @@ -1084,14 +1141,14 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -/*extern IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl;*/ +/*extern const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl;*/ /***************************************************************************** * IDirect3DStateBlock implementation structure */ struct IDirect3DStateBlockImpl { /* IUnknown fields */ - /*IDirect3DStateBlock9Vtbl *lpVtbl;*/ + /*const IDirect3DStateBlock9Vtbl *lpVtbl;*/ DWORD ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ @@ -1173,14 +1230,14 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -/*extern IDirect3DVertexShaderDeclaration9Vtbl Direct3DVertexShaderDeclaration9_Vtbl;*/ +/*extern const IDirect3DVertexShaderDeclaration9Vtbl Direct3DVertexShaderDeclaration9_Vtbl;*/ /***************************************************************************** * IDirect3DVertexShaderDeclaration implementation structure */ struct IDirect3DVertexShaderDeclarationImpl { /* IUnknown fields */ - /*IDirect3DVertexShaderDeclaration9Vtbl *lpVtbl;*/ + /*const IDirect3DVertexShaderDeclaration9Vtbl *lpVtbl;*/ DWORD ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ @@ -1210,13 +1267,13 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -/*extern IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl;*/ +/*extern const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl;*/ /***************************************************************************** * IDirect3DVertexShader implementation structure */ struct IDirect3DVertexShaderImpl { - /*IDirect3DVertexShader9Vtbl *lpVtbl;*/ + /*const IDirect3DVertexShader9Vtbl *lpVtbl;*/ DWORD ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ @@ -1259,13 +1316,13 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -/*extern IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl;*/ +/*extern const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl;*/ /***************************************************************************** * IDirect3DPixelShader implementation structure */ struct IDirect3DPixelShaderImpl { - /*IDirect3DPixelShader9Vtbl *lpVtbl;*/ + /*const IDirect3DPixelShader9Vtbl *lpVtbl;*/ DWORD ref; /* The device, to be replaced by an IDirect3DDeviceImpl */ diff -urN wine-20050524/dlls/d3d8/device.c wine-20050628/dlls/d3d8/device.c --- wine-20050524/dlls/d3d8/device.c 2005-03-23 14:15:20.000000000 +0100 +++ wine-20050628/dlls/d3d8/device.c 2005-05-27 22:17:37.000000000 +0200 @@ -4349,7 +4349,7 @@ } -IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl = +const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl = { IDirect3DDevice8Impl_QueryInterface, IDirect3DDevice8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/directx.c wine-20050628/dlls/d3d8/directx.c --- wine-20050524/dlls/d3d8/directx.c 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d8/directx.c 2005-06-23 13:05:25.000000000 +0200 @@ -192,7 +192,23 @@ HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) { IDirect3D8Impl *This = (IDirect3D8Impl *)iface; - return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (void *)pCaps); + HRESULT hrc = D3D_OK; + WINED3DCAPS *pWineCaps; + + TRACE("(%p) Relay %d %u %p \n", This, Adapter, DeviceType, pCaps); + + if(NULL == pCaps){ + return D3DERR_INVALIDCALL; + } + pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS)); + if(pWineCaps == NULL){ + return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/ + } + D3D8CAPSTOWINECAPS(pCaps, pWineCaps) + hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps); + HeapFree(GetProcessHeap(), 0, pWineCaps); + TRACE("(%p) returning %p\n", This, pCaps); + return hrc; } HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) { @@ -563,6 +579,61 @@ return res; } +/* Callback for creating the inplicite swapchain when the device is created */ +HRESULT WINAPI D3D8CB_CreateAdditionalSwapChain(IUnknown *device, + WINED3DPRESENT_PARAMETERS* pPresentationParameters, + IWineD3DSwapChain ** ppSwapChain){ + HRESULT res = D3D_OK; + IDirect3DSwapChain8Impl *d3dSwapChain = NULL; + /* We have to pass the presentation parameters back and forth */ + D3DPRESENT_PARAMETERS localParameters; + localParameters.BackBufferWidth = *(pPresentationParameters->BackBufferWidth); + localParameters.BackBufferHeight = *(pPresentationParameters->BackBufferHeight); + localParameters.BackBufferFormat = *(pPresentationParameters->BackBufferFormat); + localParameters.BackBufferCount = *(pPresentationParameters->BackBufferCount); + localParameters.MultiSampleType = *(pPresentationParameters->MultiSampleType); + /* d3d9 only */ + /* localParameters.MultiSampleQuality = *(pPresentationParameters->MultiSampleQuality); */ + localParameters.SwapEffect = *(pPresentationParameters->SwapEffect); + localParameters.hDeviceWindow = *(pPresentationParameters->hDeviceWindow); + localParameters.Windowed = *(pPresentationParameters->Windowed); + localParameters.EnableAutoDepthStencil = *(pPresentationParameters->EnableAutoDepthStencil); + localParameters.AutoDepthStencilFormat = *(pPresentationParameters->AutoDepthStencilFormat); + localParameters.Flags = *(pPresentationParameters->Flags); + localParameters.FullScreen_RefreshRateInHz = *(pPresentationParameters->FullScreen_RefreshRateInHz); +/* not in d3d8 */ +/* localParameters.PresentationInterval = *(pPresentationParameters->PresentationInterval); */ + + TRACE("(%p) rellaying\n", device); + /*copy the presentation parameters*/ + res = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)device, &localParameters, (IDirect3DSwapChain8 **)&d3dSwapChain); + + if (res == D3D_OK){ + *ppSwapChain = d3dSwapChain->wineD3DSwapChain; + } else { + FIXME("failed to create additional swap chain\n"); + *ppSwapChain = NULL; + } + /* Copy back the presentation parameters */ + TRACE("(%p) setting up return parameters\n", device); + *pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; + *pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight; + *pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat; + *pPresentationParameters->BackBufferCount = localParameters.BackBufferCount; + *pPresentationParameters->MultiSampleType = localParameters.MultiSampleType; +/* *pPresentationParameters->MultiSampleQuality leave alone incase wineD3D set something internally */ + *pPresentationParameters->SwapEffect = localParameters.SwapEffect; + *pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow; + *pPresentationParameters->Windowed = localParameters.Windowed; + *pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil; + *pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat; + *pPresentationParameters->Flags = localParameters.Flags; + *pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz; +/* *pPresentationParameters->PresentationInterval leave alone incase wineD3D set something internally */ + + return res; +} + HRESULT WINAPI IDirect3D8Impl_CreateDevice (LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, @@ -608,7 +679,7 @@ localParameters.Flags = &pPresentationParameters->Flags; localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz; localParameters.PresentationInterval = &pPresentationParameters->FullScreen_PresentationInterval; /* Renamed in dx9 */ - IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D8CB_CreateRenderTarget); + IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D8CB_CreateAdditionalSwapChain); /** use StateBlock Factory here, for creating the startup stateBlock */ object->StateBlock = NULL; @@ -828,7 +899,7 @@ return D3D_OK; } -IDirect3D8Vtbl Direct3D8_Vtbl = +const IDirect3D8Vtbl Direct3D8_Vtbl = { IDirect3D8Impl_QueryInterface, IDirect3D8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/indexbuffer.c wine-20050628/dlls/d3d8/indexbuffer.c --- wine-20050524/dlls/d3d8/indexbuffer.c 2005-01-24 13:43:25.000000000 +0100 +++ wine-20050628/dlls/d3d8/indexbuffer.c 2005-05-27 22:17:36.000000000 +0200 @@ -130,7 +130,7 @@ return D3D_OK; } -IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl = +const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl = { IDirect3DIndexBuffer8Impl_QueryInterface, IDirect3DIndexBuffer8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/resource.c wine-20050628/dlls/d3d8/resource.c --- wine-20050524/dlls/d3d8/resource.c 2005-01-24 13:43:25.000000000 +0100 +++ wine-20050628/dlls/d3d8/resource.c 2005-05-27 22:17:36.000000000 +0200 @@ -132,7 +132,7 @@ } } -IDirect3DResource8Vtbl Direct3DResource8_Vtbl = +const IDirect3DResource8Vtbl Direct3DResource8_Vtbl = { IDirect3DResource8Impl_QueryInterface, IDirect3DResource8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/surface.c wine-20050628/dlls/d3d8/surface.c --- wine-20050524/dlls/d3d8/surface.c 2005-03-24 22:01:39.000000000 +0100 +++ wine-20050628/dlls/d3d8/surface.c 2005-05-27 22:17:36.000000000 +0200 @@ -468,7 +468,7 @@ } -IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl = +const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl = { IDirect3DSurface8Impl_QueryInterface, IDirect3DSurface8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/swapchain.c wine-20050628/dlls/d3d8/swapchain.c --- wine-20050524/dlls/d3d8/swapchain.c 2005-01-24 13:43:25.000000000 +0100 +++ wine-20050628/dlls/d3d8/swapchain.c 2005-05-27 22:17:36.000000000 +0200 @@ -91,7 +91,7 @@ return D3D_OK; } -IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl = +const IDirect3DSwapChain8Vtbl Direct3DSwapChain8_Vtbl = { IDirect3DSwapChain8Impl_QueryInterface, IDirect3DSwapChain8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/texture.c wine-20050628/dlls/d3d8/texture.c --- wine-20050524/dlls/d3d8/texture.c 2005-01-24 13:43:25.000000000 +0100 +++ wine-20050628/dlls/d3d8/texture.c 2005-05-27 22:17:36.000000000 +0200 @@ -235,7 +235,7 @@ } -IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl = +const IDirect3DTexture8Vtbl Direct3DTexture8_Vtbl = { IDirect3DTexture8Impl_QueryInterface, IDirect3DTexture8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/vertexbuffer.c wine-20050628/dlls/d3d8/vertexbuffer.c --- wine-20050524/dlls/d3d8/vertexbuffer.c 2005-01-24 13:43:25.000000000 +0100 +++ wine-20050628/dlls/d3d8/vertexbuffer.c 2005-05-27 22:17:36.000000000 +0200 @@ -135,7 +135,7 @@ return D3D_OK; } -IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl = +const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl = { IDirect3DVertexBuffer8Impl_QueryInterface, IDirect3DVertexBuffer8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/volume.c wine-20050628/dlls/d3d8/volume.c --- wine-20050524/dlls/d3d8/volume.c 2005-01-24 13:43:25.000000000 +0100 +++ wine-20050628/dlls/d3d8/volume.c 2005-05-27 22:17:36.000000000 +0200 @@ -192,7 +192,7 @@ } -IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl = +const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl = { IDirect3DVolume8Impl_QueryInterface, IDirect3DVolume8Impl_AddRef, diff -urN wine-20050524/dlls/d3d8/volumetexture.c wine-20050628/dlls/d3d8/volumetexture.c --- wine-20050524/dlls/d3d8/volumetexture.c 2005-01-24 13:43:25.000000000 +0100 +++ wine-20050628/dlls/d3d8/volumetexture.c 2005-05-27 22:17:36.000000000 +0200 @@ -261,7 +261,7 @@ } -IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl = +const IDirect3DVolumeTexture8Vtbl Direct3DVolumeTexture8_Vtbl = { IDirect3DVolumeTexture8Impl_QueryInterface, IDirect3DVolumeTexture8Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/basetexture.c wine-20050628/dlls/d3d9/basetexture.c --- wine-20050524/dlls/d3d9/basetexture.c 2005-03-11 11:25:30.000000000 +0100 +++ wine-20050628/dlls/d3d9/basetexture.c 2005-05-27 22:17:36.000000000 +0200 @@ -149,7 +149,7 @@ return IWineD3DBaseTexture_GenerateMipSubLevels(This->wineD3DBaseTexture); } -IDirect3DBaseTexture9Vtbl Direct3DBaseTexture9_Vtbl = +const IDirect3DBaseTexture9Vtbl Direct3DBaseTexture9_Vtbl = { IDirect3DBaseTexture9Impl_QueryInterface, IDirect3DBaseTexture9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/cubetexture.c wine-20050628/dlls/d3d9/cubetexture.c --- wine-20050524/dlls/d3d9/cubetexture.c 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d9/cubetexture.c 2005-05-27 22:17:36.000000000 +0200 @@ -207,7 +207,7 @@ } -IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl = +const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl = { IDirect3DCubeTexture9Impl_QueryInterface, IDirect3DCubeTexture9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/d3d9_private.h wine-20050628/dlls/d3d9/d3d9_private.h --- wine-20050524/dlls/d3d9/d3d9_private.h 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d9/d3d9_private.h 2005-06-23 13:05:24.000000000 +0200 @@ -92,6 +92,88 @@ #define D3D_VSHADER_MAX_CONSTANTS 96 #define D3D_PSHADER_MAX_CONSTANTS 32 +/* =========================================================================== + Macros + =========================================================================== */ +/* Not nice, but it lets wined3d support different versions of directx */ +#define D3D9CAPSTOWINECAPS(_pD3D9Caps, _pWineCaps) \ + _pWineCaps->DeviceType = &_pD3D9Caps->DeviceType; \ + _pWineCaps->AdapterOrdinal = &_pD3D9Caps->AdapterOrdinal; \ + _pWineCaps->Caps = &_pD3D9Caps->Caps; \ + _pWineCaps->Caps2 = &_pD3D9Caps->Caps2; \ + _pWineCaps->Caps3 = &_pD3D9Caps->Caps3; \ + _pWineCaps->PresentationIntervals = &_pD3D9Caps->PresentationIntervals; \ + _pWineCaps->CursorCaps = &_pD3D9Caps->CursorCaps; \ + _pWineCaps->DevCaps = &_pD3D9Caps->DevCaps; \ + _pWineCaps->PrimitiveMiscCaps = &_pD3D9Caps->PrimitiveMiscCaps; \ + _pWineCaps->RasterCaps = &_pD3D9Caps->RasterCaps; \ + _pWineCaps->ZCmpCaps = &_pD3D9Caps->ZCmpCaps; \ + _pWineCaps->SrcBlendCaps = &_pD3D9Caps->SrcBlendCaps; \ + _pWineCaps->DestBlendCaps = &_pD3D9Caps->DestBlendCaps; \ + _pWineCaps->AlphaCmpCaps = &_pD3D9Caps->AlphaCmpCaps; \ + _pWineCaps->ShadeCaps = &_pD3D9Caps->ShadeCaps; \ + _pWineCaps->TextureCaps = &_pD3D9Caps->TextureCaps; \ + _pWineCaps->TextureFilterCaps = &_pD3D9Caps->TextureFilterCaps; \ + _pWineCaps->CubeTextureFilterCaps = &_pD3D9Caps->CubeTextureFilterCaps; \ + _pWineCaps->VolumeTextureFilterCaps = &_pD3D9Caps->VolumeTextureFilterCaps; \ + _pWineCaps->TextureAddressCaps = &_pD3D9Caps->TextureAddressCaps; \ + _pWineCaps->VolumeTextureAddressCaps = &_pD3D9Caps->VolumeTextureAddressCaps; \ + _pWineCaps->LineCaps = &_pD3D9Caps->LineCaps; \ + _pWineCaps->MaxTextureWidth = &_pD3D9Caps->MaxTextureWidth; \ + _pWineCaps->MaxTextureHeight = &_pD3D9Caps->MaxTextureHeight; \ + _pWineCaps->MaxVolumeExtent = &_pD3D9Caps->MaxVolumeExtent; \ + _pWineCaps->MaxTextureRepeat = &_pD3D9Caps->MaxTextureRepeat; \ + _pWineCaps->MaxTextureAspectRatio = &_pD3D9Caps->MaxTextureAspectRatio; \ + _pWineCaps->MaxAnisotropy = &_pD3D9Caps->MaxAnisotropy; \ + _pWineCaps->MaxVertexW = &_pD3D9Caps->MaxVertexW; \ + _pWineCaps->GuardBandLeft = &_pD3D9Caps->GuardBandLeft; \ + _pWineCaps->GuardBandTop = &_pD3D9Caps->GuardBandTop; \ + _pWineCaps->GuardBandRight = &_pD3D9Caps->GuardBandRight; \ + _pWineCaps->GuardBandBottom = &_pD3D9Caps->GuardBandBottom; \ + _pWineCaps->ExtentsAdjust = &_pD3D9Caps->ExtentsAdjust; \ + _pWineCaps->StencilCaps = &_pD3D9Caps->StencilCaps; \ + _pWineCaps->FVFCaps = &_pD3D9Caps->FVFCaps; \ + _pWineCaps->TextureOpCaps = &_pD3D9Caps->TextureOpCaps; \ + _pWineCaps->MaxTextureBlendStages = &_pD3D9Caps->MaxTextureBlendStages; \ + _pWineCaps->MaxSimultaneousTextures = &_pD3D9Caps->MaxSimultaneousTextures; \ + _pWineCaps->VertexProcessingCaps = &_pD3D9Caps->VertexProcessingCaps; \ + _pWineCaps->MaxActiveLights = &_pD3D9Caps->MaxActiveLights; \ + _pWineCaps->MaxUserClipPlanes = &_pD3D9Caps->MaxUserClipPlanes; \ + _pWineCaps->MaxVertexBlendMatrices = &_pD3D9Caps->MaxVertexBlendMatrices; \ + _pWineCaps->MaxVertexBlendMatrixIndex = &_pD3D9Caps->MaxVertexBlendMatrixIndex; \ + _pWineCaps->MaxPointSize = &_pD3D9Caps->MaxPointSize; \ + _pWineCaps->MaxPrimitiveCount = &_pD3D9Caps->MaxPrimitiveCount; \ + _pWineCaps->MaxVertexIndex = &_pD3D9Caps->MaxVertexIndex; \ + _pWineCaps->MaxStreams = &_pD3D9Caps->MaxStreams; \ + _pWineCaps->MaxStreamStride = &_pD3D9Caps->MaxStreamStride; \ + _pWineCaps->VertexShaderVersion = &_pD3D9Caps->VertexShaderVersion; \ + _pWineCaps->MaxVertexShaderConst = &_pD3D9Caps->MaxVertexShaderConst; \ + _pWineCaps->PixelShaderVersion = &_pD3D9Caps->PixelShaderVersion; \ + _pWineCaps->PixelShader1xMaxValue = &_pD3D9Caps->PixelShader1xMaxValue; \ + _pWineCaps->DevCaps2 = &_pD3D9Caps->DevCaps2; \ + _pWineCaps->MaxNpatchTessellationLevel = &_pD3D9Caps->MaxNpatchTessellationLevel; \ + _pWineCaps->MasterAdapterOrdinal = &_pD3D9Caps->MasterAdapterOrdinal; \ + _pWineCaps->AdapterOrdinalInGroup = &_pD3D9Caps->AdapterOrdinalInGroup; \ + _pWineCaps->NumberOfAdaptersInGroup = &_pD3D9Caps->NumberOfAdaptersInGroup; \ + _pWineCaps->DeclTypes = &_pD3D9Caps->DeclTypes; \ + _pWineCaps->NumSimultaneousRTs = &_pD3D9Caps->NumSimultaneousRTs; \ + _pWineCaps->StretchRectFilterCaps = &_pD3D9Caps->StretchRectFilterCaps; \ + _pWineCaps->VS20Caps.Caps = &_pD3D9Caps->VS20Caps.Caps; \ + _pWineCaps->VS20Caps.DynamicFlowControlDepth = &_pD3D9Caps->VS20Caps.DynamicFlowControlDepth; \ + _pWineCaps->VS20Caps.NumTemps = &_pD3D9Caps->VS20Caps.NumTemps; \ + _pWineCaps->VS20Caps.NumTemps = &_pD3D9Caps->VS20Caps.NumTemps; \ + _pWineCaps->VS20Caps.StaticFlowControlDepth = &_pD3D9Caps->VS20Caps.StaticFlowControlDepth; \ + _pWineCaps->PS20Caps.Caps = &_pD3D9Caps->PS20Caps.Caps; \ + _pWineCaps->PS20Caps.DynamicFlowControlDepth = &_pD3D9Caps->PS20Caps.DynamicFlowControlDepth; \ + _pWineCaps->PS20Caps.NumTemps = &_pD3D9Caps->PS20Caps.NumTemps; \ + _pWineCaps->PS20Caps.StaticFlowControlDepth = &_pD3D9Caps->PS20Caps.StaticFlowControlDepth; \ + _pWineCaps->PS20Caps.NumInstructionSlots = &_pD3D9Caps->PS20Caps.NumInstructionSlots; \ + _pWineCaps->VertexTextureFilterCaps = &_pD3D9Caps->VertexTextureFilterCaps; \ + _pWineCaps->MaxVShaderInstructionsExecuted = &_pD3D9Caps->MaxVShaderInstructionsExecuted; \ + _pWineCaps->MaxPShaderInstructionsExecuted = &_pD3D9Caps->MaxPShaderInstructionsExecuted; \ + _pWineCaps->MaxVertexShader30InstructionSlots = &_pD3D9Caps->MaxVertexShader30InstructionSlots; \ + _pWineCaps->MaxPixelShader30InstructionSlots = &_pD3D9Caps->MaxPixelShader30InstructionSlots; + /* Direct3D9 Interfaces: */ typedef struct IDirect3D9Impl IDirect3D9Impl; typedef struct IDirect3DDevice9Impl IDirect3DDevice9Impl; @@ -102,7 +184,6 @@ typedef struct IDirect3DVertexBuffer9Impl IDirect3DVertexBuffer9Impl; typedef struct IDirect3DIndexBuffer9Impl IDirect3DIndexBuffer9Impl; typedef struct IDirect3DSurface9Impl IDirect3DSurface9Impl; -typedef struct IDirect3DSwapChain9Impl IDirect3DSwapChain9Impl; typedef struct IDirect3DResource9Impl IDirect3DResource9Impl; typedef struct IDirect3DVolume9Impl IDirect3DVolume9Impl; typedef struct IDirect3DStateBlock9Impl IDirect3DStateBlock9Impl; @@ -183,7 +264,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3D9Vtbl Direct3D9_Vtbl; +extern const IDirect3D9Vtbl Direct3D9_Vtbl; /***************************************************************************** * IDirect3D implementation structure @@ -191,7 +272,7 @@ struct IDirect3D9Impl { /* IUnknown fields */ - IDirect3D9Vtbl *lpVtbl; + const IDirect3D9Vtbl *lpVtbl; DWORD ref; /* The WineD3D device */ @@ -228,7 +309,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl; +extern const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl; /***************************************************************************** * IDirect3DDevice9 implementation structure @@ -236,7 +317,7 @@ struct IDirect3DDevice9Impl { /* IUnknown fields */ - IDirect3DDevice9Vtbl *lpVtbl; + const IDirect3DDevice9Vtbl *lpVtbl; DWORD ref; /* IDirect3DDevice9 fields */ @@ -435,7 +516,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl; +extern const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl; /***************************************************************************** * IDirect3DVolume9 implementation structure @@ -443,7 +524,7 @@ struct IDirect3DVolume9Impl { /* IUnknown fields */ - IDirect3DVolume9Vtbl *lpVtbl; + const IDirect3DVolume9Vtbl *lpVtbl; DWORD ref; /* IDirect3DVolume9 fields */ @@ -473,39 +554,20 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl; +extern const IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl; /***************************************************************************** * IDirect3DSwapChain9 implementation structure */ -struct IDirect3DSwapChain9Impl +typedef struct IDirect3DSwapChain9Impl { /* IUnknown fields */ - IDirect3DSwapChain9Vtbl *lpVtbl; + const IDirect3DSwapChain9Vtbl *lpVtbl; DWORD ref; /* IDirect3DSwapChain9 fields */ - IDirect3DDevice9Impl *Device; - IDirect3DSurface9Impl *frontBuffer; - IDirect3DSurface9Impl *backBuffer; - IDirect3DSurface9Impl *depthStencilBuffer; - D3DPRESENT_PARAMETERS PresentParms; -}; - -/* IUnknown: */ -extern HRESULT WINAPI IDirect3DSwapChain9Impl_QueryInterface(LPDIRECT3DSWAPCHAIN9 iface, REFIID refiid, LPVOID* obj); -extern ULONG WINAPI IDirect3DSwapChain9Impl_AddRef(LPDIRECT3DSWAPCHAIN9 iface); -extern ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface); - -/* IDirect3DSwapChain9: */ -extern HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags); -extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9* pDestSurface); -extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer); -extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS* pRasterStatus); -extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE* pMode); -extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9** ppDevice); -extern HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters); - + IWineD3DSwapChain *wineD3DSwapChain; +} IDirect3DSwapChain9Impl; /* ------------------ */ /* IDirect3DResource9 */ @@ -514,7 +576,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DResource9Vtbl Direct3DResource9_Vtbl; +extern const IDirect3DResource9Vtbl Direct3DResource9_Vtbl; /***************************************************************************** * IDirect3DResource9 implementation structure @@ -522,7 +584,7 @@ struct IDirect3DResource9Impl { /* IUnknown fields */ - IDirect3DResource9Vtbl *lpVtbl; + const IDirect3DResource9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -552,7 +614,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl; +extern const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl; /***************************************************************************** * IDirect3DSurface9 implementation structure @@ -560,7 +622,7 @@ struct IDirect3DSurface9Impl { /* IUnknown fields */ - IDirect3DSurface9Vtbl *lpVtbl; + const IDirect3DSurface9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -599,7 +661,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl; +extern const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl; /***************************************************************************** * IDirect3DVertexBuffer9 implementation structure @@ -607,7 +669,7 @@ struct IDirect3DVertexBuffer9Impl { /* IUnknown fields */ - IDirect3DVertexBuffer9Vtbl *lpVtbl; + const IDirect3DVertexBuffer9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -642,7 +704,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl; +extern const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl; /***************************************************************************** * IDirect3DIndexBuffer9 implementation structure @@ -650,7 +712,7 @@ struct IDirect3DIndexBuffer9Impl { /* IUnknown fields */ - IDirect3DIndexBuffer9Vtbl *lpVtbl; + const IDirect3DIndexBuffer9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -685,7 +747,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DBaseTexture9Vtbl Direct3DBaseTexture9_Vtbl; +extern const IDirect3DBaseTexture9Vtbl Direct3DBaseTexture9_Vtbl; /***************************************************************************** * IDirect3DBaseTexture9 implementation structure @@ -693,7 +755,7 @@ struct IDirect3DBaseTexture9Impl { /* IUnknown fields */ - IDirect3DBaseTexture9Vtbl *lpVtbl; + const IDirect3DBaseTexture9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -731,7 +793,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl; +extern const IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl; /***************************************************************************** * IDirect3DCubeTexture9 implementation structure @@ -739,7 +801,7 @@ struct IDirect3DCubeTexture9Impl { /* IUnknown fields */ - IDirect3DCubeTexture9Vtbl *lpVtbl; + const IDirect3DCubeTexture9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -784,7 +846,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl; +extern const IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl; /***************************************************************************** * IDirect3DTexture9 implementation structure @@ -792,7 +854,7 @@ struct IDirect3DTexture9Impl { /* IUnknown fields */ - IDirect3DTexture9Vtbl *lpVtbl; + const IDirect3DTexture9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -838,7 +900,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl; +extern const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl; /***************************************************************************** * IDirect3DVolumeTexture9 implementation structure @@ -846,7 +908,7 @@ struct IDirect3DVolumeTexture9Impl { /* IUnknown fields */ - IDirect3DVolumeTexture9Vtbl *lpVtbl; + const IDirect3DVolumeTexture9Vtbl *lpVtbl; DWORD ref; /* IDirect3DResource9 fields */ @@ -891,14 +953,14 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl; +extern const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl; /***************************************************************************** * IDirect3DStateBlock9 implementation structure */ struct IDirect3DStateBlock9Impl { /* IUnknown fields */ - IDirect3DStateBlock9Vtbl *lpVtbl; + const IDirect3DStateBlock9Vtbl *lpVtbl; DWORD ref; /* IDirect3DStateBlock9 fields */ @@ -989,14 +1051,14 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl; +extern const IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl; /***************************************************************************** * IDirect3DVertexShaderDeclaration implementation structure */ struct IDirect3DVertexDeclaration9Impl { /* IUnknown fields */ - IDirect3DVertexDeclaration9Vtbl *lpVtbl; + const IDirect3DVertexDeclaration9Vtbl *lpVtbl; DWORD ref; /* IDirect3DVertexDeclaration9 fields */ @@ -1020,14 +1082,14 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl; +extern const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl; /***************************************************************************** * IDirect3DVertexShader implementation structure */ struct IDirect3DVertexShader9Impl { /* IUnknown fields */ - IDirect3DVertexShader9Vtbl *lpVtbl; + const IDirect3DVertexShader9Vtbl *lpVtbl; DWORD ref; /* IDirect3DVertexDeclaration9 fields */ @@ -1062,14 +1124,14 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl; +extern const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl; /***************************************************************************** * IDirect3DPixelShader implementation structure */ struct IDirect3DPixelShader9Impl { /* IUnknown fields */ - IDirect3DPixelShader9Vtbl *lpVtbl; + const IDirect3DPixelShader9Vtbl *lpVtbl; DWORD ref; /* IDirect3DPixelShader9 fields */ @@ -1103,14 +1165,14 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl; +extern const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl; /***************************************************************************** * IDirect3DPixelShader implementation structure */ typedef struct IDirect3DQuery9Impl { /* IUnknown fields */ - IDirect3DQuery9Vtbl *lpVtbl; + const IDirect3DQuery9Vtbl *lpVtbl; DWORD ref; /* IDirect3DQuery9 fields */ @@ -1128,4 +1190,14 @@ IWineD3DVolume **ppVolume, HANDLE * pSharedHandle); +extern HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, UINT Width, UINT Height, + WINED3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, + DWORD MultisampleQuality, BOOL Discard, + IWineD3DSurface** ppSurface, HANDLE* pSharedHandle); + +extern HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Height, + WINED3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, + DWORD MultisampleQuality, BOOL Lockable, + IWineD3DSurface** ppSurface, HANDLE* pSharedHandle); + #endif /* __WINE_D3D9_PRIVATE_H */ diff -urN wine-20050524/dlls/d3d9/device.c wine-20050628/dlls/d3d9/device.c --- wine-20050524/dlls/d3d9/device.c 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d9/device.c 2005-06-27 11:53:47.000000000 +0200 @@ -57,7 +57,6 @@ TRACE("(%p) : ReleaseRef to %ld\n", This, ref); if (ref == 0) { - IDirect3D9_Release((LPDIRECT3D9) This->direct3d); IWineD3DDevice_Release(This->WineD3DDevice); HeapFree(GetProcessHeap(), 0, This); } @@ -88,16 +87,46 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : returning %p\n", This, This->direct3d); - /* Inc ref count */ - *ppD3D9 = (IDirect3D9*) This->direct3d; - IDirect3D9_AddRef(*ppD3D9); - return D3D_OK; + HRESULT hr = D3D_OK; + IWineD3D* pWineD3D; + + TRACE("(%p) Relay\n", This); + + if (NULL == ppD3D9) { + return D3DERR_INVALIDCALL; + } + hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D); + if (hr == D3D_OK && pWineD3D != NULL) + { + IWineD3DResource_GetParent((IWineD3DResource *)pWineD3D,(IUnknown **)ppD3D9); + IWineD3DResource_Release((IWineD3DResource *)pWineD3D); + } else { + FIXME("Call to IWineD3DDevice_GetDirect3D failed\n"); + *ppD3D9 = NULL; + } + TRACE("(%p) returning %p\b",This , *ppD3D9); + return hr; } HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - return IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pCaps); + HRESULT hrc = D3D_OK; + WINED3DCAPS *pWineCaps; + + TRACE("(%p) : Relay pCaps %p \n", This, pCaps); + if(NULL == pCaps){ + return D3DERR_INVALIDCALL; + } + pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS)); + if(pWineCaps == NULL){ + return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */ + } + + D3D9CAPSTOWINECAPS(pCaps, pWineCaps) + hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps); + HeapFree(GetProcessHeap(), 0, pWineCaps); + TRACE("Returning %p %p\n", This, pCaps); + return hrc; } HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) { @@ -436,7 +465,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9 iface, CONST D3DVIEWPORT9* pViewport) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport); + return IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport); } HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface, D3DVIEWPORT9* pViewport) { @@ -448,7 +477,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial); + return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial); } HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial) { @@ -460,7 +489,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight); + return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight); } HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight) { @@ -508,7 +537,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9 iface, CONST D3DCLIPSTATUS9* pClipStatus) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); - return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus); + return IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus); } HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3DCLIPSTATUS9* pClipStatus) { @@ -775,7 +804,7 @@ return IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle); } -IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl = +const IDirect3DDevice9Vtbl Direct3DDevice9_Vtbl = { IDirect3DDevice9Impl_QueryInterface, IDirect3DDevice9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/directx.c wine-20050628/dlls/d3d9/directx.c --- wine-20050524/dlls/d3d9/directx.c 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d9/directx.c 2005-06-23 13:05:24.000000000 +0200 @@ -2,6 +2,7 @@ * IDirect3D9 implementation * * Copyright 2002 Jason Edmeades + * Copyright 2005 Oliver Stieber * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -149,7 +150,23 @@ HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) { IDirect3D9Impl *This = (IDirect3D9Impl *)iface; - return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (WINED3DCAPS *)pCaps); + HRESULT hrc = D3D_OK; + WINED3DCAPS *pWineCaps; + + TRACE("(%p) Relay %d %u %p \n", This, Adapter, DeviceType, pCaps); + + if(NULL == pCaps){ + return D3DERR_INVALIDCALL; + } + pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS)); + if(pWineCaps == NULL){ + return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/ + } + D3D9CAPSTOWINECAPS(pCaps, pWineCaps) + hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps); + HeapFree(GetProcessHeap(), 0, pWineCaps); + TRACE("(%p) returning %p\n", This, pCaps); + return hrc; } HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) { @@ -158,38 +175,103 @@ } /* Internal function called back during the CreateDevice to create a render target */ -HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Height, - WINED3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, - DWORD MultisampleQuality, BOOL Lockable, +HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Height, + WINED3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, + DWORD MultisampleQuality, BOOL Lockable, IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) { HRESULT res = D3D_OK; IDirect3DSurface9Impl *d3dSurface = NULL; - IDirect3DDevice9Impl* pDeviceImpl = (IDirect3DDevice9Impl*) device; - + TRACE("(%p) call back\n", device); res = IDirect3DDevice9_CreateRenderTarget((IDirect3DDevice9 *)device, Width, Height, - (D3DFORMAT) Format, MultiSample, MultisampleQuality, Lockable, + (D3DFORMAT)Format, MultiSample, MultisampleQuality, Lockable, (IDirect3DSurface9 **)&d3dSurface, pSharedHandle); if (SUCCEEDED(res)) { *ppSurface = d3dSurface->wineD3DSurface; - if (NULL == pDeviceImpl->backBuffer) { - pDeviceImpl->backBuffer = d3dSurface; - pDeviceImpl->renderTarget = d3dSurface; - IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) pDeviceImpl->renderTarget); - } } else { *ppSurface = NULL; } return res; } +HRESULT WINAPI D3D9CB_CreateAdditionalSwapChain(IUnknown *device, + WINED3DPRESENT_PARAMETERS* pPresentationParameters, + IWineD3DSwapChain ** ppSwapChain) { + HRESULT res = D3D_OK; + IDirect3DSwapChain9Impl *d3dSwapChain = NULL; + D3DPRESENT_PARAMETERS localParameters; + TRACE("(%p) call back\n", device); + + localParameters.BackBufferWidth = *(pPresentationParameters->BackBufferWidth); + localParameters.BackBufferHeight = *(pPresentationParameters->BackBufferHeight); + localParameters.BackBufferFormat = *(pPresentationParameters->BackBufferFormat); + localParameters.BackBufferCount = *(pPresentationParameters->BackBufferCount); + localParameters.MultiSampleType = *(pPresentationParameters->MultiSampleType); + localParameters.MultiSampleQuality = *(pPresentationParameters->MultiSampleQuality); + localParameters.SwapEffect = *(pPresentationParameters->SwapEffect); + localParameters.hDeviceWindow = *(pPresentationParameters->hDeviceWindow); + localParameters.Windowed = *(pPresentationParameters->Windowed); + localParameters.EnableAutoDepthStencil = *(pPresentationParameters->EnableAutoDepthStencil); + localParameters.AutoDepthStencilFormat = *(pPresentationParameters->AutoDepthStencilFormat); + localParameters.Flags = *(pPresentationParameters->Flags); + localParameters.FullScreen_RefreshRateInHz = *(pPresentationParameters->FullScreen_RefreshRateInHz); + localParameters.PresentationInterval = *(pPresentationParameters->PresentationInterval); + + /*copy the presentation parameters*/ + res = IDirect3DDevice9_CreateAdditionalSwapChain((IDirect3DDevice9 *)device, &localParameters, (IDirect3DSwapChain9 **)&d3dSwapChain); + + if (res == D3D_OK && d3dSwapChain != NULL) { + *ppSwapChain = d3dSwapChain->wineD3DSwapChain; + } else { + *ppSwapChain = NULL; + } + /*Copy back the presentation parameters*/ + *pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; + *pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight; + *pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat; + *pPresentationParameters->BackBufferCount = localParameters.BackBufferCount; + *pPresentationParameters->MultiSampleType = localParameters.MultiSampleType; + *pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality; + *pPresentationParameters->SwapEffect = localParameters.SwapEffect; + *pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow; + *pPresentationParameters->Windowed = localParameters.Windowed; + *pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil; + *pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat; + *pPresentationParameters->Flags = localParameters.Flags; + *pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz; + *pPresentationParameters->PresentationInterval = localParameters.PresentationInterval; + + return res; +} + +/* Internal function called back during the CreateDevice to create a render target */ +HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, UINT Width, UINT Height, + WINED3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, + DWORD MultisampleQuality, BOOL Discard, + IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) { + HRESULT res = D3D_OK; + IDirect3DSurface9Impl *d3dSurface = NULL; + TRACE("(%p) call back\n", device); + + res = IDirect3DDevice9_CreateDepthStencilSurface((IDirect3DDevice9 *)device, Width, Height, + (D3DFORMAT)Format, MultiSample, MultisampleQuality, Discard, + (IDirect3DSurface9 **)&d3dSurface, pSharedHandle); + if (res == D3D_OK) { + *ppSurface = d3dSurface->wineD3DSurface; + } + return res; +} + + HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, - DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, - IDirect3DDevice9** ppReturnedDeviceInterface) { + DWORD BehaviourFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, + IDirect3DDevice9** ppReturnedDeviceInterface) { IDirect3D9Impl *This = (IDirect3D9Impl *)iface; IDirect3DDevice9Impl *object = NULL; WINED3DPRESENT_PARAMETERS localParameters; + HRESULT hr; + TRACE("(%p) Relay \n", This); /* Check the validity range of the adapter parameter */ if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) { @@ -207,29 +289,39 @@ object->lpVtbl = &Direct3DDevice9_Vtbl; object->ref = 1; - object->direct3d = This; - IDirect3D9_AddRef((LPDIRECT3D9) object->direct3d); *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object; - + /* Allocate an associated WineD3DDevice object */ localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth; - localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight; - localParameters.BackBufferFormat = &pPresentationParameters->BackBufferFormat; - localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount; - localParameters.MultiSampleType = &pPresentationParameters->MultiSampleType; - localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality; - localParameters.SwapEffect = &pPresentationParameters->SwapEffect; - localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow; - localParameters.Windowed = &pPresentationParameters->Windowed; - localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil; - localParameters.AutoDepthStencilFormat = &pPresentationParameters->AutoDepthStencilFormat; - localParameters.Flags = &pPresentationParameters->Flags; + localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight; + localParameters.BackBufferFormat = &pPresentationParameters->BackBufferFormat; + localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount; + localParameters.MultiSampleType = &pPresentationParameters->MultiSampleType; + localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality; + localParameters.SwapEffect = &pPresentationParameters->SwapEffect; + localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow; + localParameters.Windowed = &pPresentationParameters->Windowed; + localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil; + localParameters.AutoDepthStencilFormat = &pPresentationParameters->AutoDepthStencilFormat; + localParameters.Flags = &pPresentationParameters->Flags; localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz; - localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval; - return IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D9CB_CreateRenderTarget); + localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval; + + hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D9CB_CreateAdditionalSwapChain); + + if (hr == D3D_OK) { + + TRACE("(%p) : Created Device %p\n", This, object); + } else { + HeapFree(GetProcessHeap(), 0, object); + *ppReturnedDeviceInterface = NULL; + } + return hr; } -IDirect3D9Vtbl Direct3D9_Vtbl = + + +const IDirect3D9Vtbl Direct3D9_Vtbl = { IDirect3D9Impl_QueryInterface, IDirect3D9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/indexbuffer.c wine-20050628/dlls/d3d9/indexbuffer.c --- wine-20050524/dlls/d3d9/indexbuffer.c 2005-03-11 11:25:30.000000000 +0100 +++ wine-20050628/dlls/d3d9/indexbuffer.c 2005-05-27 22:17:36.000000000 +0200 @@ -131,7 +131,7 @@ } -IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl = +const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl = { IDirect3DIndexBuffer9Impl_QueryInterface, IDirect3DIndexBuffer9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/pixelshader.c wine-20050628/dlls/d3d9/pixelshader.c --- wine-20050524/dlls/d3d9/pixelshader.c 2005-01-24 13:44:01.000000000 +0100 +++ wine-20050628/dlls/d3d9/pixelshader.c 2005-05-27 22:17:36.000000000 +0200 @@ -76,7 +76,7 @@ } -IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl = +const IDirect3DPixelShader9Vtbl Direct3DPixelShader9_Vtbl = { IDirect3DPixelShader9Impl_QueryInterface, IDirect3DPixelShader9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/query.c wine-20050628/dlls/d3d9/query.c --- wine-20050524/dlls/d3d9/query.c 2005-03-03 14:57:15.000000000 +0100 +++ wine-20050628/dlls/d3d9/query.c 2005-05-27 22:17:36.000000000 +0200 @@ -104,7 +104,7 @@ } -IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl = +const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl = { IDirect3DQuery9Impl_QueryInterface, IDirect3DQuery9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/resource.c wine-20050628/dlls/d3d9/resource.c --- wine-20050524/dlls/d3d9/resource.c 2005-03-11 11:25:30.000000000 +0100 +++ wine-20050628/dlls/d3d9/resource.c 2005-05-27 22:17:36.000000000 +0200 @@ -118,7 +118,7 @@ } -IDirect3DResource9Vtbl Direct3DResource9_Vtbl = +const IDirect3DResource9Vtbl Direct3DResource9_Vtbl = { IDirect3DResource9Impl_QueryInterface, IDirect3DResource9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/stateblock.c wine-20050628/dlls/d3d9/stateblock.c --- wine-20050524/dlls/d3d9/stateblock.c 2005-01-24 13:44:01.000000000 +0100 +++ wine-20050628/dlls/d3d9/stateblock.c 2005-05-27 22:17:36.000000000 +0200 @@ -82,7 +82,7 @@ } -IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl = +const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl = { IDirect3DStateBlock9Impl_QueryInterface, IDirect3DStateBlock9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/surface.c wine-20050628/dlls/d3d9/surface.c --- wine-20050524/dlls/d3d9/surface.c 2005-03-23 14:15:20.000000000 +0100 +++ wine-20050628/dlls/d3d9/surface.c 2005-05-27 22:17:36.000000000 +0200 @@ -204,7 +204,7 @@ } -IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl = +const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl = { IDirect3DSurface9Impl_QueryInterface, IDirect3DSurface9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/swapchain.c wine-20050628/dlls/d3d9/swapchain.c --- wine-20050524/dlls/d3d9/swapchain.c 2005-01-24 13:44:01.000000000 +0100 +++ wine-20050628/dlls/d3d9/swapchain.c 2005-06-23 13:05:24.000000000 +0200 @@ -3,6 +3,7 @@ * * Copyright 2002-2003 Jason Edmeades * Raphael Junqueira + * Copyright 2005 Oliver Stieber * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,7 +23,7 @@ #include "config.h" #include "d3d9_private.h" -WINE_DEFAULT_DEBUG_CHANNEL(d3d); +WINE_DEFAULT_DEBUG_CHANNEL(d3d9); /* IDirect3DSwapChain IUnknown parts follow: */ HRESULT WINAPI IDirect3DSwapChain9Impl_QueryInterface(LPDIRECT3DSWAPCHAIN9 iface, REFIID riid, LPVOID* ppobj) @@ -31,8 +32,8 @@ if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3DSwapChain9)) { - IDirect3DSwapChain9Impl_AddRef(iface); - *ppobj = This; + IUnknown_AddRef(iface); + *ppobj = This; return D3D_OK; } @@ -64,54 +65,66 @@ /* IDirect3DSwapChain9 parts follow: */ HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion, DWORD dwFlags) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags); } HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9* pDestSurface) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface); } HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9 iface, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + HRESULT hrc = D3D_OK; + IWineD3DSurface *mySurface = NULL; + + TRACE("(%p) Relay\n", This); + + hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, Type, &mySurface); + if (hrc == D3D_OK && NULL != mySurface) { + IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer); + IWineD3DSurface_Release(mySurface); + } + return hrc; } HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAIN9 iface, D3DRASTER_STATUS* pRasterStatus) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, pRasterStatus); } HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN9 iface, D3DDISPLAYMODE* pMode) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + TRACE("(%p) Relay\n", This); + return IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, pMode); } HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DDevice9** ppDevice) { - IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; - TRACE("(%p) : returning %p\n", This, This->Device); - *ppDevice = (LPDIRECT3DDEVICE9) This->Device; - - /* Note Calling this method will increase the internal reference count - on the IDirect3DDevice9 interface. */ - IDirect3DDevice9Impl_AddRef(*ppDevice); - return D3D_OK; + IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; + HRESULT hrc = D3D_OK; + IWineD3DDevice *device = NULL; + + TRACE("(%p) Relay\n", This); + + hrc = IWineD3DSwapChain_GetDevice(This->wineD3DSwapChain, &device); + if (hrc == D3D_OK && NULL != device) { + IWineD3DDevice_GetParent(device, (IUnknown **)ppDevice); + IWineD3DDevice_Release(device); + } + return hrc; } HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWAPCHAIN9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) { IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface; - FIXME("(%p) : copy\n", This); - memcpy(pPresentationParameters, &This->PresentParms, sizeof(D3DPRESENT_PARAMETERS)); - return D3D_OK; + FIXME("(%p) : inplement using WINED3DPRESENT_PARAMERS\n", This); + return IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, pPresentationParameters); } -IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl = +const IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl = { IDirect3DSwapChain9Impl_QueryInterface, IDirect3DSwapChain9Impl_AddRef, @@ -129,18 +142,67 @@ /* IDirect3DDevice9 IDirect3DSwapChain9 Methods follow: */ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); + IDirect3DSwapChain9Impl* object; + HRESULT hrc = D3D_OK; + WINED3DPRESENT_PARAMETERS localParameters; + + TRACE("(%p) Relay\n", This); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *pSwapChain = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->ref = 1; + object->lpVtbl = &Direct3DSwapChain9_Vtbl; + + /* Allocate an associated WineD3DDevice object */ + localParameters.BackBufferWidth = &pPresentationParameters->BackBufferWidth; + localParameters.BackBufferHeight = &pPresentationParameters->BackBufferHeight; + localParameters.BackBufferFormat = &pPresentationParameters->BackBufferFormat; + localParameters.BackBufferCount = &pPresentationParameters->BackBufferCount; + localParameters.MultiSampleType = &pPresentationParameters->MultiSampleType; + localParameters.MultiSampleQuality = &pPresentationParameters->MultiSampleQuality; + localParameters.SwapEffect = &pPresentationParameters->SwapEffect; + localParameters.hDeviceWindow = &pPresentationParameters->hDeviceWindow; + localParameters.Windowed = &pPresentationParameters->Windowed; + localParameters.EnableAutoDepthStencil = &pPresentationParameters->EnableAutoDepthStencil; + localParameters.AutoDepthStencilFormat = &pPresentationParameters->AutoDepthStencilFormat; + localParameters.Flags = &pPresentationParameters->Flags; + localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz; + localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval; + + + hrc = IWineD3DDevice_CreateAdditionalSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D9CB_CreateRenderTarget, D3D9CB_CreateDepthStencilSurface); + if (hrc != D3D_OK) { + FIXME("(%p) call to IWineD3DDevice_CreateAdditionalSwapChain failed\n", This); + HeapFree(GetProcessHeap(), 0 , object); + *pSwapChain = NULL; + }else{ + *pSwapChain = (IDirect3DSwapChain9 *)object; + } + TRACE("(%p) returning %p\n", This, *pSwapChain); return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + HRESULT hrc = D3D_OK; + IWineD3DSwapChain *swapchain = NULL; + + TRACE("(%p) Relay\n", This); + + hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain); + if (hrc == D3D_OK && NULL != swapchain) { + IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain); + IWineD3DSwapChain_Release(swapchain); + } + return hrc; } UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); - return 1; + TRACE("(%p) Relay\n", This); + return IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice); } diff -urN wine-20050524/dlls/d3d9/texture.c wine-20050628/dlls/d3d9/texture.c --- wine-20050524/dlls/d3d9/texture.c 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d9/texture.c 2005-06-16 22:36:12.000000000 +0200 @@ -67,72 +67,86 @@ /* IDirect3DTexture9 IDirect3DResource9 Interface follow: */ HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface, IDirect3DDevice9** ppDevice) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice); } HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags); } HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData); } HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 iface, REFGUID refguid) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid); } DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface, DWORD PriorityNew) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew); } DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_GetPriority(This->wineD3DTexture); } void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_PreLoad(This->wineD3DTexture); } D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_GetType(This->wineD3DTexture); } /* IDirect3DTexture9 IDirect3DBaseTexture9 Interface follow: */ DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD LODNew) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew); } DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_GetLOD(This->wineD3DTexture); } DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_GetLevelCount(This->wineD3DTexture); } HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface, D3DTEXTUREFILTERTYPE FilterType) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_SetAutoGenFilterType(This->wineD3DTexture, FilterType); } D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LPDIRECT3DTEXTURE9 iface) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_GetAutoGenFilterType(This->wineD3DTexture); } void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9 iface) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_GenerateMipSubLevels(This->wineD3DTexture); } @@ -142,6 +156,7 @@ WINED3DSURFACE_DESC wined3ddesc; UINT tmpInt = -1; + TRACE("(%p) Relay\n", This); /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */ wined3ddesc.Format = &pDesc->Format; @@ -160,8 +175,9 @@ HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, UINT Level, IDirect3DSurface9** ppSurfaceLevel) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; HRESULT hrc = D3D_OK; - IWineD3DSurface *mySurface = NULL; + + TRACE("(%p) Relay\n", This); hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface); if (hrc == D3D_OK && NULL != ppSurfaceLevel) { IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel); @@ -172,20 +188,23 @@ HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_LockRect(This->wineD3DTexture, Level, pLockedRect, pRect, Flags); } HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface, UINT Level) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level); } HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 iface, CONST RECT* pDirtyRect) { IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface; + TRACE("(%p) Relay\n", This); return IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect); } -IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl = +const IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl = { IDirect3DTexture9Impl_QueryInterface, IDirect3DTexture9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/vertexbuffer.c wine-20050628/dlls/d3d9/vertexbuffer.c --- wine-20050524/dlls/d3d9/vertexbuffer.c 2005-03-11 11:25:30.000000000 +0100 +++ wine-20050628/dlls/d3d9/vertexbuffer.c 2005-05-27 22:17:36.000000000 +0200 @@ -132,7 +132,7 @@ return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, pDesc); } -IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl = +const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl = { IDirect3DVertexBuffer9Impl_QueryInterface, IDirect3DVertexBuffer9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/vertexdeclaration.c wine-20050628/dlls/d3d9/vertexdeclaration.c --- wine-20050524/dlls/d3d9/vertexdeclaration.c 2005-03-02 13:16:11.000000000 +0100 +++ wine-20050628/dlls/d3d9/vertexdeclaration.c 2005-06-16 22:37:22.000000000 +0200 @@ -77,7 +77,7 @@ } -IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl = +const IDirect3DVertexDeclaration9Vtbl Direct3DVertexDeclaration9_Vtbl = { IDirect3DVertexDeclaration9Impl_QueryInterface, IDirect3DVertexDeclaration9Impl_AddRef, @@ -124,13 +124,11 @@ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DVertexDeclaration9Impl *pDeclImpl = (IDirect3DVertexDeclaration9Impl *)pDecl; HRESULT hr = S_OK; - - This->UpdateStateBlock->vertexDecl = NULL; + /* TODO: implement stateblocks */ + FIXME("Disabled\n"); + return D3DERR_INVALIDCALL; if (NULL != pDecl) { hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl->wineD3DVertexDeclaration); - if (SUCCEEDED(hr)) { - This->UpdateStateBlock->vertexDecl = (IDirect3DVertexDeclaration9Impl*) pDecl; - } } return hr; } @@ -139,15 +137,16 @@ IDirect3DDevice9Impl* This = (IDirect3DDevice9Impl*) iface; IWineD3DVertexDeclaration* pTest = NULL; HRESULT hr = S_OK; - IDirect3DVertexDeclaration9Impl* pCur = This->StateBlock->vertexDecl; + FIXME("Disabled\n"); + return D3DERR_INVALIDCALL; if (NULL == ppDecl) { return D3DERR_INVALIDCALL; } *ppDecl = NULL; hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest); - if (SUCCEEDED(hr) && (NULL == pCur || pCur->wineD3DVertexDeclaration == pTest)) { - *ppDecl = (IDirect3DVertexDeclaration9*) pCur; + if (SUCCEEDED(hr)) { + *ppDecl = NULL; } return hr; } diff -urN wine-20050524/dlls/d3d9/vertexshader.c wine-20050628/dlls/d3d9/vertexshader.c --- wine-20050524/dlls/d3d9/vertexshader.c 2005-01-24 13:44:01.000000000 +0100 +++ wine-20050628/dlls/d3d9/vertexshader.c 2005-05-27 22:17:36.000000000 +0200 @@ -76,7 +76,7 @@ } -IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl = +const IDirect3DVertexShader9Vtbl Direct3DVertexShader9_Vtbl = { IDirect3DVertexShader9Impl_QueryInterface, IDirect3DVertexShader9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/volume.c wine-20050628/dlls/d3d9/volume.c --- wine-20050524/dlls/d3d9/volume.c 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d9/volume.c 2005-05-27 22:17:36.000000000 +0200 @@ -139,7 +139,7 @@ return IWineD3DVolume_UnlockBox(This->wineD3DVolume); } -IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl = +const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl = { IDirect3DVolume9Impl_QueryInterface, IDirect3DVolume9Impl_AddRef, diff -urN wine-20050524/dlls/d3d9/volumetexture.c wine-20050628/dlls/d3d9/volumetexture.c --- wine-20050524/dlls/d3d9/volumetexture.c 2005-03-29 21:01:00.000000000 +0200 +++ wine-20050628/dlls/d3d9/volumetexture.c 2005-05-27 22:17:36.000000000 +0200 @@ -204,7 +204,7 @@ } -IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl = +const IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl = { IDirect3DVolumeTexture9Impl_QueryInterface, IDirect3DVolumeTexture9Impl_AddRef, diff -urN wine-20050524/dlls/d3dim/d3dim.spec wine-20050628/dlls/d3dim/d3dim.spec --- wine-20050524/dlls/d3dim/d3dim.spec 2003-01-24 02:08:15.000000000 +0100 +++ wine-20050628/dlls/d3dim/d3dim.spec 2005-06-23 11:57:11.000000000 +0200 @@ -1,10 +1,10 @@ @ stub D3DFree @ stub D3DMalloc @ stub D3DRealloc +@ stub Direct3DCreate @ stub Direct3DCreateDevice @ stub Direct3DCreateTexture @ stub Direct3DGetSWRastZPixFmts -@ stub Direct3DCreate @ stub Direct3D_HALCleanUp @ stub FlushD3DDevices2 @ stub FlushD3DDevices diff -urN wine-20050524/dlls/d3dx8/d3dx8.spec wine-20050628/dlls/d3dx8/d3dx8.spec --- wine-20050524/dlls/d3dx8/d3dx8.spec 2003-03-20 04:53:15.000000000 +0100 +++ wine-20050628/dlls/d3dx8/d3dx8.spec 2005-06-22 20:38:24.000000000 +0200 @@ -1,6 +1,6 @@ -@ stdcall D3DXCreateBuffer(long ptr) -@ stdcall D3DXCreateFont(ptr ptr ptr) -@ stdcall D3DXGetFVFVertexSize(long) @ stdcall D3DXAssembleShader(ptr long long ptr ptr ptr) @ stdcall D3DXAssembleShaderFromFileA(ptr long ptr ptr ptr) @ stdcall D3DXAssembleShaderFromFileW(ptr long ptr ptr ptr) +@ stdcall D3DXCreateBuffer(long ptr) +@ stdcall D3DXCreateFont(ptr ptr ptr) +@ stdcall D3DXGetFVFVertexSize(long) diff -urN wine-20050524/dlls/d3dx8/d3dx8core_private.h wine-20050628/dlls/d3dx8/d3dx8core_private.h --- wine-20050524/dlls/d3dx8/d3dx8core_private.h 2004-08-13 01:01:06.000000000 +0200 +++ wine-20050628/dlls/d3dx8/d3dx8core_private.h 2005-05-27 22:17:36.000000000 +0200 @@ -38,7 +38,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern ID3DXBufferVtbl D3DXBuffer_Vtbl; +extern const ID3DXBufferVtbl D3DXBuffer_Vtbl; /***************************************************************************** * ID3DXBufferImpl implementation structure @@ -46,7 +46,7 @@ struct ID3DXBufferImpl { /* IUnknown fields */ - ID3DXBufferVtbl *lpVtbl; + const ID3DXBufferVtbl *lpVtbl; DWORD ref; /* ID3DXBuffer fields */ @@ -70,7 +70,7 @@ /***************************************************************************** * Predeclare the interface implementation structures */ -extern ID3DXFontVtbl D3DXFont_Vtbl; +extern const ID3DXFontVtbl D3DXFont_Vtbl; /***************************************************************************** * ID3DXFontImpl implementation structure @@ -78,7 +78,7 @@ struct ID3DXFontImpl { /* IUnknown fields */ - ID3DXFontVtbl *lpVtbl; + const ID3DXFontVtbl *lpVtbl; DWORD ref; /* ID3DXFont fields */ diff -urN wine-20050524/dlls/d3dx8/d3dxbuffer.c wine-20050628/dlls/d3dx8/d3dxbuffer.c --- wine-20050524/dlls/d3dx8/d3dxbuffer.c 2005-01-21 11:18:16.000000000 +0100 +++ wine-20050628/dlls/d3dx8/d3dxbuffer.c 2005-05-27 22:17:36.000000000 +0200 @@ -82,7 +82,7 @@ return This->bufferSize; } -ID3DXBufferVtbl D3DXBuffer_Vtbl = +const ID3DXBufferVtbl D3DXBuffer_Vtbl = { ID3DXBufferImpl_QueryInterface, ID3DXBufferImpl_AddRef, diff -urN wine-20050524/dlls/d3dxof/d3dxof.c wine-20050628/dlls/d3dxof/d3dxof.c --- wine-20050524/dlls/d3dxof/d3dxof.c 2005-01-20 11:53:56.000000000 +0100 +++ wine-20050628/dlls/d3dxof/d3dxof.c 2005-05-27 22:17:36.000000000 +0200 @@ -34,13 +34,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dxof); -static struct IDirectXFileVtbl IDirectXFile_Vtbl; -static struct IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl; -static struct IDirectXFileDataVtbl IDirectXFileData_Vtbl; -static struct IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl; -static struct IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl; -static struct IDirectXFileObjectVtbl IDirectXFileObject_Vtbl; -static struct IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl; +static const struct IDirectXFileVtbl IDirectXFile_Vtbl; +static const struct IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl; +static const struct IDirectXFileDataVtbl IDirectXFileData_Vtbl; +static const struct IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl; +static const struct IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl; +static const struct IDirectXFileObjectVtbl IDirectXFileObject_Vtbl; +static const struct IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl; HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj) { @@ -142,7 +142,7 @@ return S_FALSE; } -static IDirectXFileVtbl IDirectXFile_Vtbl = +static const IDirectXFileVtbl IDirectXFile_Vtbl = { IDirectXFileImpl_QueryInterface, IDirectXFileImpl_AddRef, @@ -259,7 +259,7 @@ return S_FALSE; } -static IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl = +static const IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl = { IDirectXFileBinaryImpl_QueryInterface, IDirectXFileBinaryImpl_AddRef, @@ -405,7 +405,7 @@ return S_FALSE; } -static IDirectXFileDataVtbl IDirectXFileData_Vtbl = +static const IDirectXFileDataVtbl IDirectXFileData_Vtbl = { IDirectXFileDataImpl_QueryInterface, IDirectXFileDataImpl_AddRef, @@ -508,7 +508,7 @@ return S_FALSE; } -static IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl = +static const IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl = { IDirectXFileDataReferenceImpl_QueryInterface, IDirectXFileDataReferenceImpl_AddRef, @@ -612,7 +612,7 @@ return S_FALSE; } -static IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl = +static const IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl = { IDirectXFileEnumObjectImpl_QueryInterface, IDirectXFileEnumObjectImpl_AddRef, @@ -699,7 +699,7 @@ return S_FALSE; } -static IDirectXFileObjectVtbl IDirectXFileObject_Vtbl = +static const IDirectXFileObjectVtbl IDirectXFileObject_Vtbl = { IDirectXFileObjectImpl_QueryInterface, IDirectXFileObjectImpl_AddRef, @@ -793,7 +793,7 @@ return S_FALSE; } -static IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl = +static const IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl = { IDirectXFileSaveObjectImpl_QueryInterface, IDirectXFileSaveObjectImpl_AddRef, diff -urN wine-20050524/dlls/d3dxof/d3dxof_private.h wine-20050628/dlls/d3dxof/d3dxof_private.h --- wine-20050524/dlls/d3dxof/d3dxof_private.h 2005-01-20 11:53:56.000000000 +0100 +++ wine-20050628/dlls/d3dxof/d3dxof_private.h 2005-05-27 22:17:36.000000000 +0200 @@ -24,6 +24,8 @@ #ifndef __D3DXOF_PRIVATE_INCLUDED__ #define __D3DXOF_PRIVATE_INCLUDED__ +#define CONST_VTABLE + #include #include "windef.h" diff -urN wine-20050524/dlls/d3dxof/main.c wine-20050628/dlls/d3dxof/main.c --- wine-20050524/dlls/d3dxof/main.c 2004-11-30 18:40:51.000000000 +0100 +++ wine-20050628/dlls/d3dxof/main.c 2005-05-27 22:17:36.000000000 +0200 @@ -137,7 +137,7 @@ return S_OK; } -static IClassFactoryVtbl XFCF_Vtbl = +static const IClassFactoryVtbl XFCF_Vtbl = { XFCF_QueryInterface, XFCF_AddRef, diff -urN wine-20050524/dlls/dbghelp/dbghelp.spec wine-20050628/dlls/dbghelp/dbghelp.spec --- wine-20050524/dlls/dbghelp/dbghelp.spec 2005-03-07 12:03:21.000000000 +0100 +++ wine-20050628/dlls/dbghelp/dbghelp.spec 2005-06-23 11:57:11.000000000 +0200 @@ -1,8 +1,8 @@ @ stub DbgHelpCreateUserDump @ stub DbgHelpCreateUserDumpW @ stdcall EnumDirTree(long str str ptr ptr ptr) -@ stdcall EnumerateLoadedModules(long ptr ptr) @ stub EnumerateLoadedModules64 +@ stdcall EnumerateLoadedModules(long ptr ptr) @ stub ExtensionApiVersion @ stdcall FindDebugInfoFile(str str ptr) @ stdcall FindDebugInfoFileEx(str str ptr ptr ptr) @@ -23,69 +23,69 @@ @ stdcall MiniDumpReadDumpStream(ptr long ptr ptr ptr) @ stdcall MiniDumpWriteDump(ptr long ptr long long long long) @ stdcall SearchTreeForFile(str str str) -@ stdcall StackWalk(long long long ptr ptr ptr ptr ptr ptr) @ stub StackWalk64 +@ stdcall StackWalk(long long long ptr ptr ptr ptr ptr ptr) @ stdcall SymCleanup(long) @ stdcall SymEnumSourceFiles(ptr long long str ptr ptr) @ stub SymEnumSym @ stdcall SymEnumSymbols(ptr long long str ptr ptr) @ stdcall SymEnumTypes(ptr long long ptr ptr) -@ stdcall SymEnumerateModules(long ptr ptr) @ stub SymEnumerateModules64 -@ stdcall SymEnumerateSymbols(long long ptr ptr) +@ stdcall SymEnumerateModules(long ptr ptr) @ stub SymEnumerateSymbols64 -@ stub SymEnumerateSymbolsW +@ stdcall SymEnumerateSymbols(long long ptr ptr) @ stub SymEnumerateSymbolsW64 +@ stub SymEnumerateSymbolsW @ stdcall SymFindFileInPath(long str str ptr long long long ptr ptr ptr) @ stdcall SymFromAddr(ptr long long ptr ptr) @ stdcall SymFromName(long str ptr) -@ stdcall SymFunctionTableAccess(long long) @ stub SymFunctionTableAccess64 +@ stdcall SymFunctionTableAccess(long long) @ stub SymGetFileLineOffsets64 -@ stdcall SymGetLineFromAddr(long long ptr ptr) @ stub SymGetLineFromAddr64 -@ stub SymGetLineFromName +@ stdcall SymGetLineFromAddr(long long ptr ptr) @ stub SymGetLineFromName64 -@ stdcall SymGetLineNext(long ptr) +@ stub SymGetLineFromName @ stub SymGetLineNext64 -@ stdcall SymGetLinePrev(long ptr) +@ stdcall SymGetLineNext(long ptr) @ stub SymGetLinePrev64 -@ stdcall SymGetModuleBase(long long) +@ stdcall SymGetLinePrev(long ptr) @ stub SymGetModuleBase64 -@ stdcall SymGetModuleInfo(long long ptr) +@ stdcall SymGetModuleBase(long long) @ stub SymGetModuleInfo64 -@ stub SymGetModuleInfoW +@ stdcall SymGetModuleInfo(long long ptr) @ stub SymGetModuleInfoW64 +@ stub SymGetModuleInfoW @ stdcall SymGetOptions() @ stdcall SymGetSearchPath(long str long) -@ stdcall SymGetSymFromAddr(long long ptr ptr) @ stub SymGetSymFromAddr64 -@ stdcall SymGetSymFromName(long str ptr) +@ stdcall SymGetSymFromAddr(long long ptr ptr) @ stub SymGetSymFromName64 -@ stdcall SymGetSymNext(long ptr) +@ stdcall SymGetSymFromName(long str ptr) @ stub SymGetSymNext64 -@ stdcall SymGetSymPrev(long ptr) +@ stdcall SymGetSymNext(long ptr) @ stub SymGetSymPrev64 +@ stdcall SymGetSymPrev(long ptr) @ stdcall SymGetTypeFromName(ptr long long str ptr) @ stdcall SymGetTypeInfo(ptr long long long long ptr) @ stdcall SymInitialize(long str long) +@ stdcall SymLoadModule64(long long str str long long long) @ stdcall SymLoadModule(long long str str long long) -@ stub SymLoadModule64 @ stub SymLoadModuleEx @ stdcall SymMatchFileName(str str ptr ptr) @ stub SymMatchString -@ stdcall SymRegisterCallback(long ptr ptr) @ stub SymRegisterCallback64 -@ stub SymRegisterFunctionEntryCallback +@ stdcall SymRegisterCallback(long ptr ptr) @ stub SymRegisterFunctionEntryCallback64 +@ stub SymRegisterFunctionEntryCallback @ stdcall SymSetContext(long ptr ptr) @ stdcall SymSetOptions(long) @ stdcall SymSetSearchPath(long str) @ stub SymSetSymWithAddr64 -@ stdcall SymUnDName(ptr str long) @ stub SymUnDName64 -@ stdcall SymUnloadModule(long long) +@ stdcall SymUnDName(ptr str long) @ stub SymUnloadModule64 +@ stdcall SymUnloadModule(long long) @ stdcall UnDecorateSymbolName(str str long long) @ stdcall UnmapDebugInformation(ptr) @ stub WinDbgExtensionDllInit diff -urN wine-20050524/dlls/dbghelp/dwarf.c wine-20050628/dlls/dbghelp/dwarf.c --- wine-20050524/dlls/dbghelp/dwarf.c 2005-05-23 11:50:15.000000000 +0200 +++ wine-20050628/dlls/dbghelp/dwarf.c 2005-06-27 11:53:47.000000000 +0200 @@ -480,21 +480,21 @@ static unsigned char dwarf2_parse_byte(dwarf2_parse_context_t* ctx) { - unsigned char uvalue = *(unsigned char*) ctx->data; + unsigned char uvalue = *(const unsigned char*) ctx->data; ctx->data += 1; return uvalue; } static unsigned short dwarf2_parse_u2(dwarf2_parse_context_t* ctx) { - unsigned short uvalue = *(unsigned short*) ctx->data; + unsigned short uvalue = *(const unsigned short*) ctx->data; ctx->data += 2; return uvalue; } static unsigned long dwarf2_parse_u4(dwarf2_parse_context_t* ctx) { - unsigned long uvalue = *(unsigned int*) ctx->data; + unsigned long uvalue = *(const unsigned int*) ctx->data; ctx->data += 4; return uvalue; } @@ -541,12 +541,12 @@ return ret; } -const char* dwarf2_debug_ctx(dwarf2_parse_context_t* ctx) +static const char* dwarf2_debug_ctx(dwarf2_parse_context_t* ctx) { /*return wine_dbg_sprintf("ctx(0x%x,%u)", ctx->data - ctx->start_data, ctx->level); */ return wine_dbg_sprintf("ctx(0x%x,%u)", ctx->data - ctx->data_stream, ctx->level); } -const char* dwarf2_debug_attr(dwarf2_abbrev_entry_attr_t* attr) +static const char* dwarf2_debug_attr(dwarf2_abbrev_entry_attr_t* attr) { return wine_dbg_sprintf("attr(attr:0x%lx,form:0x%lx)", attr->attribute, attr->form); } @@ -563,7 +563,7 @@ } -dwarf2_abbrev_entry_attr_t* dwarf2_abbrev_entry_add_attr(dwarf2_abbrev_entry_t* abbrev_entry, unsigned long attribute, unsigned long form) +static dwarf2_abbrev_entry_attr_t* dwarf2_abbrev_entry_add_attr(dwarf2_abbrev_entry_t* abbrev_entry, unsigned long attribute, unsigned long form) { dwarf2_abbrev_entry_attr_t* ret = NULL; dwarf2_abbrev_entry_attr_t* it = NULL; @@ -585,7 +585,7 @@ return ret; } -dwarf2_abbrev_entry_t* dwarf2_abbrev_table_add_entry(dwarf2_abbrev_table_t* abbrev_table, unsigned long entry_code, unsigned long tag, unsigned char have_child) +static dwarf2_abbrev_entry_t* dwarf2_abbrev_table_add_entry(dwarf2_abbrev_table_t* abbrev_table, unsigned long entry_code, unsigned long tag, unsigned char have_child) { dwarf2_abbrev_entry_t* ret = NULL; @@ -606,7 +606,7 @@ return ret; } -dwarf2_abbrev_entry_t* dwarf2_abbrev_table_find_entry(dwarf2_abbrev_table_t* abbrev_table, unsigned long entry_code) +static dwarf2_abbrev_entry_t* dwarf2_abbrev_table_find_entry(dwarf2_abbrev_table_t* abbrev_table, unsigned long entry_code) { dwarf2_abbrev_entry_t* ret = NULL; @@ -617,7 +617,7 @@ return ret; } -void dwarf2_abbrev_table_free(dwarf2_abbrev_table_t* abbrev_table) +static void dwarf2_abbrev_table_free(dwarf2_abbrev_table_t* abbrev_table) { dwarf2_abbrev_entry_t* entry = NULL; dwarf2_abbrev_entry_t* next_entry = NULL; @@ -636,7 +636,7 @@ abbrev_table->n_entries = 0; } -dwarf2_abbrev_table_t* dwarf2_parse_abbrev_set(dwarf2_parse_context_t* abbrev_ctx) +static dwarf2_abbrev_table_t* dwarf2_parse_abbrev_set(dwarf2_parse_context_t* abbrev_ctx) { dwarf2_abbrev_table_t* abbrev_table = NULL; @@ -706,7 +706,7 @@ unsigned long offset = 0; switch (ctx->word_size) { case 4: - offset = *(unsigned int*) ctx->data; + offset = *(const unsigned int*) ctx->data; break; case 8: default: @@ -867,13 +867,13 @@ } } -struct symt* dwarf2_find_symt_by_ref(struct module* module, unsigned long ref) +static struct symt* dwarf2_find_symt_by_ref(struct module* module, unsigned long ref) { TRACE("want ref<0x%lx>\n", ref); return NULL; } -struct symt* dwarf2_add_symt_ref(struct module* module, unsigned long ref, struct symt* symt) +static struct symt* dwarf2_add_symt_ref(struct module* module, unsigned long ref, struct symt* symt) { if (NULL != symt) return NULL; return NULL; @@ -1941,7 +1941,7 @@ return func_type; } -static void dwarf2_parse_compiland_content(struct module* module, dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx, struct symt_compiland* compiland) +static void dwarf2_parse_compiland_content(struct module* module, const dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx, struct symt_compiland* compiland) { if (entry->have_child) { /** any interest to not have child ? */ ++ctx->level; @@ -2044,7 +2044,7 @@ } } -static struct symt_compiland* dwarf2_parse_compiland(struct module* module, dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx) +static struct symt_compiland* dwarf2_parse_compiland(struct module* module, const dwarf2_abbrev_entry_t* entry, dwarf2_parse_context_t* ctx) { struct symt_compiland* compiland = NULL; const char* name = NULL; @@ -2086,13 +2086,13 @@ while (comp_unit_cursor < end_debug) { dwarf2_abbrev_table_t* abbrev_table; - dwarf2_comp_unit_stream_t* comp_unit_stream; + const dwarf2_comp_unit_stream_t* comp_unit_stream; dwarf2_comp_unit_t comp_unit; dwarf2_parse_context_t ctx; dwarf2_parse_context_t abbrev_ctx; struct symt_compiland* compiland = NULL; - comp_unit_stream = (dwarf2_comp_unit_stream_t*) comp_unit_cursor; + comp_unit_stream = (const dwarf2_comp_unit_stream_t*) comp_unit_cursor; comp_unit.length = *(unsigned long*) comp_unit_stream->length; comp_unit.version = *(unsigned short*) comp_unit_stream->version; @@ -2131,7 +2131,7 @@ ctx.abbrev_table = abbrev_table; while (ctx.data < ctx.end_data) { - dwarf2_abbrev_entry_t* entry = NULL; + const dwarf2_abbrev_entry_t* entry = NULL; unsigned long entry_code; unsigned long entry_ref = 0; @@ -2172,9 +2172,3 @@ } return bRet; } - -BOOL dwarf2_parse_lines(struct module* module, unsigned long load_offset, - const unsigned char* debug_line, unsigned int debug_line_size) -{ - return FALSE; -} diff -urN wine-20050524/dlls/dbghelp/module.c wine-20050628/dlls/dbghelp/module.c --- wine-20050524/dlls/dbghelp/module.c 2005-04-18 17:33:31.000000000 +0200 +++ wine-20050628/dlls/dbghelp/module.c 2005-05-29 22:02:42.000000000 +0200 @@ -374,6 +374,17 @@ return module->module.BaseOfImage; } +/*********************************************************************** + * SymLoadModule64 (DBGHELP.@) + */ +DWORD WINAPI SymLoadModule64(HANDLE hProcess, HANDLE hFile, char* ImageName, + char* ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll) +{ + FIXME("SymLoadModule should probably reference SymLoadModule64 instead of this way\n"); + + return SymLoadModule(hProcess, hFile, ImageName, ModuleName, (DWORD)BaseOfDll, SizeOfDll); +} + /****************************************************************** * module_remove * diff -urN wine-20050524/dlls/dbghelp/storage.c wine-20050628/dlls/dbghelp/storage.c --- wine-20050524/dlls/dbghelp/storage.c 2004-05-18 23:29:09.000000000 +0200 +++ wine-20050628/dlls/dbghelp/storage.c 2005-06-09 11:46:39.000000000 +0200 @@ -112,7 +112,7 @@ return NULL; } -void* pool_realloc(struct pool* pool, void* p, unsigned old_size, unsigned new_size) +static void* pool_realloc(struct pool* pool, void* p, unsigned old_size, unsigned new_size) { struct pool_arena* arena; void* new; diff -urN wine-20050524/dlls/ddraw/Makefile.in wine-20050628/dlls/ddraw/Makefile.in --- wine-20050524/dlls/ddraw/Makefile.in 2005-05-09 16:42:35.000000000 +0200 +++ wine-20050628/dlls/ddraw/Makefile.in 2005-06-06 17:51:50.000000000 +0200 @@ -9,54 +9,44 @@ EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ OPENGLFILES = \ - d3dcommon.c \ - d3ddevice/main.c \ - d3ddevice/mesa.c \ - d3dexecutebuffer.c \ - d3dlight.c \ - d3dmaterial.c \ - d3dtexture.c \ - d3dvertexbuffer.c \ - d3dviewport.c \ - direct3d/main.c \ - direct3d/mesa.c \ - mesa.c + d3d_utils.c \ + device_main.c \ + device_opengl.c \ + direct3d_main.c \ + direct3d_opengl.c \ + executebuffer.c \ + light.c \ + material.c \ + opengl_utils.c \ + texture.c \ + vertexbuffer.c \ + viewport.c C_SRCS = \ @OPENGLFILES@ \ - convert.c \ - dclipper/main.c \ - ddraw/hal.c \ - ddraw/main.c \ - ddraw/thunks.c \ - ddraw/user.c \ - dpalette/hal.c \ - dpalette/main.c \ - dsurface/dib.c \ - dsurface/fakezbuffer.c \ - dsurface/gamma.c \ - dsurface/hal.c \ - dsurface/main.c \ - dsurface/thunks.c \ - dsurface/user.c \ - dsurface/wndproc.c \ - helper.c \ + clipper.c \ + ddraw_hal.c \ + ddraw_main.c \ + ddraw_thunks.c \ + ddraw_user.c \ + ddraw_utils.c \ main.c \ + palette_hal.c \ + palette_main.c \ regsvr.c \ - struct_convert.c + surface_dib.c \ + surface_fakezbuffer.c \ + surface_gamma.c \ + surface_hal.c \ + surface_main.c \ + surface_thunks.c \ + surface_user.c \ + surface_wndproc.c RC_SRCS = version.rc SUBDIRS = tests -EXTRASUBDIRS = \ - d3ddevice \ - dclipper \ - ddraw \ - direct3d \ - dpalette \ - dsurface - @MAKE_DLL_RULES@ ### Dependencies: diff -urN wine-20050524/dlls/ddraw/clipper.c wine-20050628/dlls/ddraw/clipper.c --- wine-20050524/dlls/ddraw/clipper.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/ddraw/clipper.c 2005-06-03 13:30:11.000000000 +0200 @@ -0,0 +1,285 @@ +/* DirectDrawClipper implementation + * + * Copyright 2000 Marcus Meissner + * Copyright 2000 TransGaming Technologies Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include +#include +#include + +#define CONST_VTABLE + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "ddraw.h" +#include "winerror.h" + +#include "ddraw_private.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); + +/****************************************************************************** + * DirectDrawCreateClipper (DDRAW.@) + */ + +static const IDirectDrawClipperVtbl DDRAW_Clipper_VTable; + +HRESULT WINAPI DirectDrawCreateClipper( + DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter +) { + IDirectDrawClipperImpl* This; + TRACE("(%08lx,%p,%p)\n", dwFlags, lplpDDClipper, pUnkOuter); + + if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION; + + This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(IDirectDrawClipperImpl)); + if (This == NULL) return E_OUTOFMEMORY; + + ICOM_INIT_INTERFACE(This, IDirectDrawClipper, DDRAW_Clipper_VTable); + This->ref = 1; + This->hWnd = 0; + This->ddraw_owner = NULL; + + *lplpDDClipper = ICOM_INTERFACE(This, IDirectDrawClipper); + return DD_OK; +} + +/* This is the classfactory implementation. */ +HRESULT DDRAW_CreateDirectDrawClipper(IUnknown* pUnkOuter, REFIID riid, + LPVOID* ppObj) +{ + HRESULT hr; + LPDIRECTDRAWCLIPPER pClip; + + hr = DirectDrawCreateClipper(0, &pClip, pUnkOuter); + if (FAILED(hr)) return hr; + + hr = IDirectDrawClipper_QueryInterface(pClip, riid, ppObj); + IDirectDrawClipper_Release(pClip); + return hr; +} + +/****************************************************************************** + * IDirectDrawClipper + */ +HRESULT WINAPI Main_DirectDrawClipper_SetHwnd( + LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd +) { + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + + TRACE("(%p)->(0x%08lx,0x%08lx)\n", This, dwFlags, (DWORD)hWnd); + if( dwFlags ) { + FIXME("dwFlags = 0x%08lx, not supported.\n",dwFlags); + return DDERR_INVALIDPARAMS; + } + + This->hWnd = hWnd; + return DD_OK; +} + +static void Main_DirectDrawClipper_Destroy(IDirectDrawClipperImpl* This) +{ + if (This->ddraw_owner != NULL) + Main_DirectDraw_RemoveClipper(This->ddraw_owner, This); + + HeapFree(GetProcessHeap(), 0 ,This); +} + +void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This) +{ + WARN("deleting clipper %p with refcnt %lu\n", This, This->ref); + Main_DirectDrawClipper_Destroy(This); +} + +ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface) { + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1); + + if (ref == 0) + { + Main_DirectDrawClipper_Destroy(This); + return 0; + } + else return ref; +} + +/*********************************************************************** +* IDirectDrawClipper::GetClipList +* +* Retrieve a copy of the clip list +* +* PARAMS +* lpRect Rectangle to be used to clip the clip list or NULL for the +* entire clip list +* lpClipList structure for the resulting copy of the clip list. + If NULL, fills lpdwSize up to the number of bytes necessary to hold + the entire clip. +* lpdwSize Size of resulting clip list; size of the buffer at lpClipList + or, if lpClipList is NULL, receives the required size of the buffer + in bytes +* RETURNS +* Either DD_OK or DDERR_* +*/ +HRESULT WINAPI Main_DirectDrawClipper_GetClipList( + LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList, + LPDWORD lpdwSize) +{ + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + + TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize); + + if (This->hWnd) + { + HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW); + if (hDC) + { + HRGN hRgn = CreateRectRgn(0,0,0,0); + if (GetRandomRgn(hDC, hRgn, SYSRGN)) + { + if (lpRect) + { + HRGN hRgnClip = CreateRectRgn(lpRect->left, lpRect->top, + lpRect->right, lpRect->bottom); + CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND); + DeleteObject(hRgnClip); + } + *lpdwSize = GetRegionData(hRgn, *lpdwSize, lpClipList); + } + DeleteObject(hRgn); + ReleaseDC(This->hWnd, hDC); + } + return DD_OK; + } + else + { + static int warned = 0; + if (warned++ < 10) + FIXME("(%p,%p,%p,%p),stub!\n",This,lpRect,lpClipList,lpdwSize); + if (lpdwSize) *lpdwSize=0; + return DDERR_NOCLIPLIST; + } +} + +/*********************************************************************** +* IDirectDrawClipper::SetClipList +* +* Sets or deletes (if lprgn is NULL) the clip list +* +* PARAMS +* lprgn Pointer to a LRGNDATA structure or NULL +* dwFlags not used, must be 0 +* RETURNS +* Either DD_OK or DDERR_* +*/ +HRESULT WINAPI Main_DirectDrawClipper_SetClipList( + LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag +) { + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + static int warned = 0; + if (warned++ < 10 || lprgn == NULL) + FIXME("(%p,%p,%ld),stub!\n",This,lprgn,dwFlag); + return DD_OK; +} + +HRESULT WINAPI Main_DirectDrawClipper_QueryInterface( + LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj +) { + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + + if (IsEqualGUID(&IID_IUnknown, riid) + || IsEqualGUID(&IID_IDirectDrawClipper, riid)) + { + *ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper); + InterlockedIncrement(&This->ref); + return S_OK; + } + else + { + return E_NOINTERFACE; + } +} + +ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface ) +{ + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1); + + return ref; +} + +HRESULT WINAPI Main_DirectDrawClipper_GetHWnd( + LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr +) { + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + TRACE("(%p)->(%p)\n", This, hWndPtr); + + *hWndPtr = This->hWnd; + + return DD_OK; +} + +HRESULT WINAPI Main_DirectDrawClipper_Initialize( + LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags +) { + IDirectDrawImpl* pOwner; + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + TRACE("(%p)->(%p,0x%08lx)\n", This, lpDD, dwFlags); + + if (This->ddraw_owner != NULL) return DDERR_ALREADYINITIALIZED; + + pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD); + This->ddraw_owner = pOwner; + Main_DirectDraw_AddClipper(pOwner, This); + + return DD_OK; +} + +HRESULT WINAPI Main_DirectDrawClipper_IsClipListChanged( + LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged +) { + IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + FIXME("(%p)->(%p),stub!\n",This,lpbChanged); + + /* XXX What is safest? */ + *lpbChanged = FALSE; + + return DD_OK; +} + +static const IDirectDrawClipperVtbl DDRAW_Clipper_VTable = +{ + Main_DirectDrawClipper_QueryInterface, + Main_DirectDrawClipper_AddRef, + Main_DirectDrawClipper_Release, + Main_DirectDrawClipper_GetClipList, + Main_DirectDrawClipper_GetHWnd, + Main_DirectDrawClipper_Initialize, + Main_DirectDrawClipper_IsClipListChanged, + Main_DirectDrawClipper_SetClipList, + Main_DirectDrawClipper_SetHwnd +}; diff -urN wine-20050524/dlls/ddraw/convert.c wine-20050628/dlls/ddraw/convert.c --- wine-20050524/dlls/ddraw/convert.c 2004-09-08 03:37:25.000000000 +0200 +++ wine-20050628/dlls/ddraw/convert.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,278 +0,0 @@ -/* - * Copyright 2000 Marcus Meissner - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include "ddraw_private.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ddraw); - -/* ************************************* - 16 / 15 bpp to palettized 8 bpp - ************************************* */ -static void pixel_convert_16_to_8(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette) { - unsigned char *c_src = (unsigned char *) src; - unsigned short *c_dst = (unsigned short *) dst; - int y; - - if (palette != NULL) { - const unsigned int * pal = (unsigned int *) palette->screen_palents; - - for (y = height; y--; ) { -#if defined(__i386__) && defined(__GNUC__) - /* gcc generates slightly inefficient code for the the copy/lookup, - * it generates one excess memory access (to pal) per pixel. Since - * we know that pal is not modified by the memory write we can - * put it into a register and reduce the number of memory accesses - * from 4 to 3 pp. There are two xor eax,eax to avoid pipeline - * stalls. (This is not guaranteed to be the fastest method.) - */ - __asm__ __volatile__( - "xor %%eax,%%eax\n" - "1:\n" - " lodsb\n" - " movw (%%edx,%%eax,4),%%ax\n" - " stosw\n" - " xor %%eax,%%eax\n" - " loop 1b\n" - : "=S" (c_src), "=D" (c_dst) - : "S" (c_src), "D" (c_dst) , "c" (width), "d" (pal) - : "eax", "cc", "memory" - ); - c_src+=(pitch-width); -#else - unsigned char * srclineend = c_src+width; - while (c_src < srclineend) - *c_dst++ = pal[*c_src++]; - c_src+=(pitch-width); -#endif - } - } else { - FIXME("No palette set...\n"); - memset(dst, 0, width * height * 2); - } -} -static void palette_convert_16_to_8( - LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count -) { - unsigned int i; - unsigned int *pal = (unsigned int *) screen_palette; - - for (i = 0; i < count; i++) - pal[start + i] = (((((unsigned short) palent[i].peRed) & 0xF8) << 8) | - ((((unsigned short) palent[i].peBlue) & 0xF8) >> 3) | - ((((unsigned short) palent[i].peGreen) & 0xFC) << 3)); -} - -static void palette_convert_15_to_8( - LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count -) { - unsigned int i; - unsigned int *pal = (unsigned int *) screen_palette; - - for (i = 0; i < count; i++) - pal[start + i] = (((((unsigned short) palent[i].peRed) & 0xF8) << 7) | - ((((unsigned short) palent[i].peBlue) & 0xF8) >> 3) | - ((((unsigned short) palent[i].peGreen) & 0xF8) << 2)); -} - -/* ************************************* - 24 to palettized 8 bpp - ************************************* */ -static void pixel_convert_24_to_8( - void *src, void *dst, DWORD width, DWORD height, LONG pitch, - IDirectDrawPaletteImpl* palette -) { - unsigned char *c_src = (unsigned char *) src; - unsigned char *c_dst = (unsigned char *) dst; - int y; - - if (palette != NULL) { - const unsigned int *pal = (unsigned int *) palette->screen_palents; - - for (y = height; y--; ) { - unsigned char * srclineend = c_src+width; - while (c_src < srclineend ) { - register long pixel = pal[*c_src++]; - *c_dst++ = pixel; - *c_dst++ = pixel>>8; - *c_dst++ = pixel>>16; - } - c_src+=(pitch-width); - } - } else { - FIXME("No palette set...\n"); - memset(dst, 0, width * height * 3); - } -} - -/* ************************************* - 32 bpp to palettized 8 bpp - ************************************* */ -static void pixel_convert_32_to_8( - void *src, void *dst, DWORD width, DWORD height, LONG pitch, - IDirectDrawPaletteImpl* palette -) { - unsigned char *c_src = (unsigned char *) src; - unsigned int *c_dst = (unsigned int *) dst; - int y; - - if (palette != NULL) { - const unsigned int *pal = (unsigned int *) palette->screen_palents; - - for (y = height; y--; ) { -#if defined(__i386__) && defined(__GNUC__) - /* See comment in pixel_convert_16_to_8 */ - __asm__ __volatile__( - "xor %%eax,%%eax\n" - "1:\n" - " lodsb\n" - " movl (%%edx,%%eax,4),%%eax\n" - " stosl\n" - " xor %%eax,%%eax\n" - " loop 1b\n" - : "=S" (c_src), "=D" (c_dst) - : "S" (c_src), "D" (c_dst) , "c" (width), "d" (pal) - : "eax", "cc", "memory" - ); - c_src+=(pitch-width); -#else - unsigned char * srclineend = c_src+width; - while (c_src < srclineend ) - *c_dst++ = pal[*c_src++]; - c_src+=(pitch-width); -#endif - } - } else { - FIXME("No palette set...\n"); - memset(dst, 0, width * height * 4); - } -} - -static void palette_convert_24_to_8( - LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count -) { - unsigned int i; - unsigned int *pal = (unsigned int *) screen_palette; - - for (i = 0; i < count; i++) - pal[start + i] = ((((unsigned int) palent[i].peRed) << 16) | - (((unsigned int) palent[i].peGreen) << 8) | - ((unsigned int) palent[i].peBlue)); -} - -/* ************************************* - 16 bpp to 15 bpp - ************************************* */ -static void pixel_convert_15_to_16( - void *src, void *dst, DWORD width, DWORD height, LONG pitch, - IDirectDrawPaletteImpl* palette -) { - unsigned short *c_src = (unsigned short *) src; - unsigned short *c_dst = (unsigned short *) dst; - int y; - - for (y = height; y--; ) { - unsigned short * srclineend = c_src+width; - while (c_src < srclineend ) { - unsigned short val = *c_src++; - *c_dst++=((val&0xFFC0)>>1)|(val&0x001f); - } - c_src+=((pitch/2)-width); - } -} - -/* ************************************* - 32 bpp to 16 bpp - ************************************* */ -static void pixel_convert_32_to_16( - void *src, void *dst, DWORD width, DWORD height, LONG pitch, - IDirectDrawPaletteImpl* palette -) { - unsigned short *c_src = (unsigned short *) src; - unsigned int *c_dst = (unsigned int *) dst; - int y; - - for (y = height; y--; ) { - unsigned short * srclineend = c_src+width; - while (c_src < srclineend ) { - *c_dst++ = (((*c_src & 0xF800) << 8) | - ((*c_src & 0x07E0) << 5) | - ((*c_src & 0x001F) << 3)); - c_src++; - } - c_src+=((pitch/2)-width); - } -} - -/* ************************************* - 32 bpp to 24 bpp - ************************************* */ -static void pixel_convert_32_to_24( - void *src, void *dst, DWORD width, DWORD height, LONG pitch, - IDirectDrawPaletteImpl* palette -) { - unsigned char *c_src = (unsigned char *) src; - unsigned int *c_dst = (unsigned int *) dst; - int y; - - for (y = height; y--; ) { - unsigned char * srclineend = c_src+width*3; - while (c_src < srclineend ) { - /* FIXME: wrong for big endian */ - memcpy(c_dst,c_src,3); - c_src+=3; - c_dst++; - } - c_src+=pitch-width*3; - } -} - -/* ************************************* - 16 bpp to 32 bpp - ************************************* */ -static void pixel_convert_16_to_32( - void *src, void *dst, DWORD width, DWORD height, LONG pitch, - IDirectDrawPaletteImpl* palette -) { - unsigned int *c_src = (unsigned int *) src; - unsigned short *c_dst = (unsigned short *) dst; - int y; - - for (y = height; y--; ) { - unsigned int * srclineend = c_src+width; - while (c_src < srclineend ) { - *c_dst++ = (((*c_src & 0xF80000) >> 8) | - ((*c_src & 0x00FC00) >> 5) | - ((*c_src & 0x0000F8) >> 3)); - c_src++; - } - c_src+=((pitch/4)-width); - } -} - -Convert ModeEmulations[8] = { - { { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 24, 24, 0xFF0000, 0x00FF00, 0x0000FF }, { pixel_convert_32_to_24, NULL } }, - { { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 16, 16, 0xF800, 0x07E0, 0x001F }, { pixel_convert_32_to_16, NULL } }, - { { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_32_to_8, palette_convert_24_to_8 } }, - { { 24, 24, 0xFF0000, 0x00FF00, 0x0000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_24_to_8, palette_convert_24_to_8 } }, - { { 16, 15, 0x7C00, 0x03E0, 0x001F }, { 16,16, 0xf800, 0x07e0, 0x001f }, { pixel_convert_15_to_16, NULL } }, - { { 16, 16, 0xF800, 0x07E0, 0x001F }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_16_to_8, palette_convert_16_to_8 } }, - { { 16, 15, 0x7C00, 0x03E0, 0x001F }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_16_to_8, palette_convert_15_to_8 } }, - { { 16, 16, 0xF800, 0x07E0, 0x001F }, { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { pixel_convert_16_to_32, NULL } } -}; diff -urN wine-20050524/dlls/ddraw/d3d_private.h wine-20050628/dlls/ddraw/d3d_private.h --- wine-20050524/dlls/ddraw/d3d_private.h 2005-02-14 12:09:47.000000000 +0100 +++ wine-20050628/dlls/ddraw/d3d_private.h 2005-06-12 12:43:11.000000000 +0200 @@ -225,8 +225,10 @@ DWORD material; /* Light parameters */ - DWORD active_lights, set_lights; - D3DLIGHT7 light_parameters[MAX_LIGHTS]; + DWORD num_set_lights; + DWORD max_active_lights; + LPD3DLIGHT7 light_parameters; + DWORD *active_lights; /* clipping planes */ DWORD max_clipping_planes; @@ -268,6 +270,12 @@ }; /* Various dump and helper functions */ +#define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \ + (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT) + +#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \ + (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1) + extern const char *_get_renderstate(D3DRENDERSTATETYPE type); extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat); extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol); @@ -281,7 +289,935 @@ extern void dump_D3DVOP(DWORD dwVertexOp); extern void dump_D3DPV(DWORD dwFlags); extern void multiply_matrix(LPD3DMATRIX,LPD3DMATRIX,LPD3DMATRIX); +extern void InitDefaultStateBlock(STATEBLOCK* lpStateBlock, int version); extern const float id_mat[16]; +/***************************************************************************** + * IDirect3D object methods + */ +HRESULT WINAPI +Main_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface, + LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, + LPVOID lpUserArg); + +HRESULT WINAPI +Main_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface, + REFCLSID rclsid, + LPDIRECTDRAWSURFACE7 lpDDS, + LPDIRECT3DDEVICE7* lplpD3DDevice); + +HRESULT WINAPI +Main_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface, + LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, + LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface, + REFCLSID riidDevice, + LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, + LPVOID lpContext); + +HRESULT WINAPI +Main_IDirect3DImpl_7_3T_EvictManagedTextures(LPDIRECT3D7 iface); + +HRESULT WINAPI +Main_IDirect3DImpl_3_2T_1T_EnumDevices(LPDIRECT3D3 iface, + LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, + LPVOID lpUserArg); + +HRESULT WINAPI +Main_IDirect3DImpl_3_2T_1T_CreateLight(LPDIRECT3D3 iface, + LPDIRECT3DLIGHT* lplpDirect3DLight, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Main_IDirect3DImpl_3_2T_1T_CreateMaterial(LPDIRECT3D3 iface, + LPDIRECT3DMATERIAL3* lplpDirect3DMaterial3, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Main_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface, + LPDIRECT3DVIEWPORT3* lplpD3DViewport3, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Main_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface, + LPD3DFINDDEVICESEARCH lpD3DDFS, + LPD3DFINDDEVICERESULT lpD3DFDR); + +HRESULT WINAPI +Main_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface, + REFCLSID rclsid, + LPDIRECTDRAWSURFACE4 lpDDS, + LPDIRECT3DDEVICE3* lplpD3DDevice3, + LPUNKNOWN lpUnk); + +HRESULT WINAPI +Thunk_IDirect3DImpl_3_CreateVertexBuffer(LPDIRECT3D3 iface, + LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, + LPDIRECT3DVERTEXBUFFER* lplpD3DVertBuf, + DWORD dwFlags, + LPUNKNOWN lpUnk); + +HRESULT WINAPI +Thunk_IDirect3DImpl_2_CreateMaterial(LPDIRECT3D2 iface, + LPDIRECT3DMATERIAL2* lplpDirect3DMaterial2, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Thunk_IDirect3DImpl_2_CreateViewport(LPDIRECT3D2 iface, + LPDIRECT3DVIEWPORT2* lplpD3DViewport2, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Main_IDirect3DImpl_2_CreateDevice(LPDIRECT3D2 iface, + REFCLSID rclsid, + LPDIRECTDRAWSURFACE lpDDS, + LPDIRECT3DDEVICE2* lplpD3DDevice2); + +HRESULT WINAPI +Main_IDirect3DImpl_1_Initialize(LPDIRECT3D iface, + REFIID riid); + +HRESULT WINAPI +Thunk_IDirect3DImpl_1_CreateMaterial(LPDIRECT3D iface, + LPDIRECT3DMATERIAL* lplpDirect3DMaterial, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Thunk_IDirect3DImpl_1_CreateViewport(LPDIRECT3D iface, + LPDIRECT3DVIEWPORT* lplpD3DViewport, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Main_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface, + LPD3DFINDDEVICESEARCH lpD3DDFS, + LPD3DFINDDEVICERESULT lplpD3DDevice); + +HRESULT WINAPI +Thunk_IDirect3DImpl_7_QueryInterface(LPDIRECT3D7 iface, + REFIID riid, + LPVOID* obp); + +HRESULT WINAPI +Thunk_IDirect3DImpl_3_QueryInterface(LPDIRECT3D3 iface, + REFIID riid, + LPVOID* obp); + +HRESULT WINAPI +Thunk_IDirect3DImpl_2_QueryInterface(LPDIRECT3D2 iface, + REFIID riid, + LPVOID* obp); + +HRESULT WINAPI +Thunk_IDirect3DImpl_1_QueryInterface(LPDIRECT3D iface, + REFIID riid, + LPVOID* obp); + +ULONG WINAPI +Thunk_IDirect3DImpl_7_AddRef(LPDIRECT3D7 iface); + +ULONG WINAPI +Thunk_IDirect3DImpl_3_AddRef(LPDIRECT3D3 iface); + +ULONG WINAPI +Thunk_IDirect3DImpl_2_AddRef(LPDIRECT3D2 iface); + +ULONG WINAPI +Thunk_IDirect3DImpl_1_AddRef(LPDIRECT3D iface); + +ULONG WINAPI +Thunk_IDirect3DImpl_7_Release(LPDIRECT3D7 iface); + +ULONG WINAPI +Thunk_IDirect3DImpl_3_Release(LPDIRECT3D3 iface); + +ULONG WINAPI +Thunk_IDirect3DImpl_2_Release(LPDIRECT3D2 iface); + +ULONG WINAPI +Thunk_IDirect3DImpl_1_Release(LPDIRECT3D iface); + +HRESULT WINAPI +Thunk_IDirect3DImpl_3_EnumZBufferFormats(LPDIRECT3D3 iface, + REFCLSID riidDevice, + LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback, + LPVOID lpContext); + +HRESULT WINAPI +Thunk_IDirect3DImpl_3_EvictManagedTextures(LPDIRECT3D3 iface); + +HRESULT WINAPI +Thunk_IDirect3DImpl_2_EnumDevices(LPDIRECT3D2 iface, + LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, + LPVOID lpUserArg); + +HRESULT WINAPI +Thunk_IDirect3DImpl_1_EnumDevices(LPDIRECT3D iface, + LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback, + LPVOID lpUserArg); + +HRESULT WINAPI +Thunk_IDirect3DImpl_2_CreateLight(LPDIRECT3D2 iface, + LPDIRECT3DLIGHT* lplpDirect3DLight, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Thunk_IDirect3DImpl_1_CreateLight(LPDIRECT3D iface, + LPDIRECT3DLIGHT* lplpDirect3DLight, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Thunk_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface, + LPD3DFINDDEVICESEARCH lpD3DDFS, + LPD3DFINDDEVICERESULT lplpD3DDevice); + +HRESULT WINAPI +Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface, + LPD3DFINDDEVICESEARCH lpD3DDFS, + LPD3DFINDDEVICERESULT lpD3DFDR); + +/***************************************************************************** + * IDirect3DDevice object methods + */ +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface, + REFIID riid, + LPVOID* obp); + +ULONG WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_1T_AddRef(LPDIRECT3DDEVICE7 iface); + +ULONG WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_GetCaps(LPDIRECT3DDEVICE7 iface, + LPD3DDEVICEDESC7 lpD3DHELDevDesc); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_EnumTextureFormats(LPDIRECT3DDEVICE7 iface, + LPD3DENUMPIXELFORMATSCALLBACK lpD3DEnumPixelProc, + LPVOID lpArg); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_1T_BeginScene(LPDIRECT3DDEVICE7 iface); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_1T_EndScene(LPDIRECT3DDEVICE7 iface); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_1T_GetDirect3D(LPDIRECT3DDEVICE7 iface, + LPDIRECT3D7* lplpDirect3D3); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderTarget(LPDIRECT3DDEVICE7 iface, + LPDIRECTDRAWSURFACE7 lpNewRenderTarget, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderTarget(LPDIRECT3DDEVICE7 iface, + LPDIRECTDRAWSURFACE7* lplpRenderTarget); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_Clear(LPDIRECT3DDEVICE7 iface, + DWORD dwCount, + LPD3DRECT lpRects, + DWORD dwFlags, + D3DCOLOR dwColor, + D3DVALUE dvZ, + DWORD dwStencil); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_SetTransform(LPDIRECT3DDEVICE7 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform(LPDIRECT3DDEVICE7 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_SetViewport(LPDIRECT3DDEVICE7 iface, + LPD3DVIEWPORT7 lpData); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform(LPDIRECT3DDEVICE7 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_GetViewport(LPDIRECT3DDEVICE7 iface, + LPD3DVIEWPORT7 lpData); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_SetMaterial(LPDIRECT3DDEVICE7 iface, + LPD3DMATERIAL7 lpMat); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_GetMaterial(LPDIRECT3DDEVICE7 iface, + LPD3DMATERIAL7 lpMat); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_SetLight(LPDIRECT3DDEVICE7 iface, + DWORD dwLightIndex, + LPD3DLIGHT7 lpLight); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_GetLight(LPDIRECT3DDEVICE7 iface, + DWORD dwLightIndex, + LPD3DLIGHT7 lpLight); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderState(LPDIRECT3DDEVICE7 iface, + D3DRENDERSTATETYPE dwRenderStateType, + DWORD dwRenderState); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderState(LPDIRECT3DDEVICE7 iface, + D3DRENDERSTATETYPE dwRenderStateType, + LPDWORD lpdwRenderState); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_BeginStateBlock(LPDIRECT3DDEVICE7 iface); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_EndStateBlock(LPDIRECT3DDEVICE7 iface, + LPDWORD lpdwBlockHandle); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_PreLoad(LPDIRECT3DDEVICE7 iface, + LPDIRECTDRAWSURFACE7 lpddsTexture); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_DrawPrimitive(LPDIRECT3DDEVICE7 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwVertexCount, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitive(LPDIRECT3DDEVICE7 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwVertexCount, + LPWORD dwIndices, + DWORD dwIndexCount, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_SetClipStatus(LPDIRECT3DDEVICE7 iface, + LPD3DCLIPSTATUS lpD3DClipStatus); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_2T_GetClipStatus(LPDIRECT3DDEVICE7 iface, + LPD3DCLIPSTATUS lpD3DClipStatus); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_DrawPrimitiveStrided(LPDIRECT3DDEVICE7 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD dwVertexType, + LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, + DWORD dwVertexCount, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE7 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD dwVertexType, + LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, + DWORD dwVertexCount, + LPWORD lpIndex, + DWORD dwIndexCount, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_DrawPrimitiveVB(LPDIRECT3DDEVICE7 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, + DWORD dwStartVertex, + DWORD dwNumVertices, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE7 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, + DWORD dwStartVertex, + DWORD dwNumVertices, + LPWORD lpwIndices, + DWORD dwIndexCount, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_ComputeSphereVisibility(LPDIRECT3DDEVICE7 iface, + LPD3DVECTOR lpCenters, + LPD3DVALUE lpRadii, + DWORD dwNumSpheres, + DWORD dwFlags, + LPDWORD lpdwReturnValues); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_GetTexture(LPDIRECT3DDEVICE7 iface, + DWORD dwStage, + LPDIRECTDRAWSURFACE7* lpTexture); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_SetTexture(LPDIRECT3DDEVICE7 iface, + DWORD dwStage, + LPDIRECTDRAWSURFACE7 lpTexture); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_GetTextureStageState(LPDIRECT3DDEVICE7 iface, + DWORD dwStage, + D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, + LPDWORD lpdwState); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_SetTextureStageState(LPDIRECT3DDEVICE7 iface, + DWORD dwStage, + D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, + DWORD dwState); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_3T_ValidateDevice(LPDIRECT3DDEVICE7 iface, + LPDWORD lpdwPasses); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_ApplyStateBlock(LPDIRECT3DDEVICE7 iface, + DWORD dwBlockHandle); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_CaptureStateBlock(LPDIRECT3DDEVICE7 iface, + DWORD dwBlockHandle); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_DeleteStateBlock(LPDIRECT3DDEVICE7 iface, + DWORD dwBlockHandle); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_CreateStateBlock(LPDIRECT3DDEVICE7 iface, + D3DSTATEBLOCKTYPE d3dsbType, + LPDWORD lpdwBlockHandle); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_Load(LPDIRECT3DDEVICE7 iface, + LPDIRECTDRAWSURFACE7 lpDestTex, + LPPOINT lpDestPoint, + LPDIRECTDRAWSURFACE7 lpSrcTex, + LPRECT lprcSrcRect, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_LightEnable(LPDIRECT3DDEVICE7 iface, + DWORD dwLightIndex, + BOOL bEnable); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_GetLightEnable(LPDIRECT3DDEVICE7 iface, + DWORD dwLightIndex, + BOOL* pbEnable); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_SetClipPlane(LPDIRECT3DDEVICE7 iface, + DWORD dwIndex, + D3DVALUE* pPlaneEquation); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_GetClipPlane(LPDIRECT3DDEVICE7 iface, + DWORD dwIndex, + D3DVALUE* pPlaneEquation); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_7_GetInfo(LPDIRECT3DDEVICE7 iface, + DWORD dwDevInfoID, + LPVOID pDevInfoStruct, + DWORD dwSize); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_1T_GetCaps(LPDIRECT3DDEVICE3 iface, + LPD3DDEVICEDESC lpD3DHWDevDesc, + LPD3DDEVICEDESC lpD3DHELDevDesc); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_1T_GetStats(LPDIRECT3DDEVICE3 iface, + LPD3DSTATS lpD3DStats); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_1T_AddViewport(LPDIRECT3DDEVICE3 iface, + LPDIRECT3DVIEWPORT3 lpDirect3DViewport3); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_1T_DeleteViewport(LPDIRECT3DDEVICE3 iface, + LPDIRECT3DVIEWPORT3 lpDirect3DViewport3); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_1T_NextViewport(LPDIRECT3DDEVICE3 iface, + LPDIRECT3DVIEWPORT3 lpDirect3DViewport3, + LPDIRECT3DVIEWPORT3* lplpDirect3DViewport3, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_SetCurrentViewport(LPDIRECT3DDEVICE3 iface, + LPDIRECT3DVIEWPORT3 lpDirect3DViewport3); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_GetCurrentViewport(LPDIRECT3DDEVICE3 iface, + LPDIRECT3DVIEWPORT3* lplpDirect3DViewport3); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_Begin(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD dwVertexTypeDesc, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_BeginIndexed(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwNumVertices, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_Vertex(LPDIRECT3DDEVICE3 iface, + LPVOID lpVertexType); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_Index(LPDIRECT3DDEVICE3 iface, + WORD wVertexIndex); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_End(LPDIRECT3DDEVICE3 iface, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_GetLightState(LPDIRECT3DDEVICE3 iface, + D3DLIGHTSTATETYPE dwLightStateType, + LPDWORD lpdwLightState); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface, + D3DLIGHTSTATETYPE dwLightStateType, + DWORD dwLightState); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_2_1T_SwapTextureHandles(LPDIRECT3DDEVICE2 iface, + LPDIRECT3DTEXTURE2 lpD3DTex1, + LPDIRECT3DTEXTURE2 lpD3DTex2); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_2_1T_EnumTextureFormats(LPDIRECT3DDEVICE2 iface, + LPD3DENUMTEXTUREFORMATSCALLBACK lpD3DEnumTextureProc, + LPVOID lpArg); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_2_Begin(LPDIRECT3DDEVICE2 iface, + D3DPRIMITIVETYPE d3dpt, + D3DVERTEXTYPE dwVertexTypeDesc, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_2_BeginIndexed(LPDIRECT3DDEVICE2 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + D3DVERTEXTYPE d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwNumVertices, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_2_DrawPrimitive(LPDIRECT3DDEVICE2 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + D3DVERTEXTYPE d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwVertexCount, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(LPDIRECT3DDEVICE2 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + D3DVERTEXTYPE d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwVertexCount, + LPWORD dwIndices, + DWORD dwIndexCount, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_Initialize(LPDIRECT3DDEVICE iface, + LPDIRECT3D lpDirect3D, + LPGUID lpGUID, + LPD3DDEVICEDESC lpD3DDVDesc); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_CreateExecuteBuffer(LPDIRECT3DDEVICE iface, + LPD3DEXECUTEBUFFERDESC lpDesc, + LPDIRECT3DEXECUTEBUFFER* lplpDirect3DExecuteBuffer, + IUnknown* pUnkOuter); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_Execute(LPDIRECT3DDEVICE iface, + LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, + LPDIRECT3DVIEWPORT lpDirect3DViewport, + DWORD dwFlags); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_Pick(LPDIRECT3DDEVICE iface, + LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, + LPDIRECT3DVIEWPORT lpDirect3DViewport, + DWORD dwFlags, + LPD3DRECT lpRect); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_GetPickRecords(LPDIRECT3DDEVICE iface, + LPDWORD lpCount, + LPD3DPICKRECORD lpD3DPickRec); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_CreateMatrix(LPDIRECT3DDEVICE iface, + LPD3DMATRIXHANDLE lpD3DMatHandle); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_SetMatrix(LPDIRECT3DDEVICE iface, + D3DMATRIXHANDLE D3DMatHandle, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_GetMatrix(LPDIRECT3DDEVICE iface, + D3DMATRIXHANDLE D3DMatHandle, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Main_IDirect3DDeviceImpl_1_DeleteMatrix(LPDIRECT3DDEVICE iface, + D3DMATRIXHANDLE D3DMatHandle); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_QueryInterface(LPDIRECT3DDEVICE3 iface, + REFIID riid, + LPVOID* obp); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_QueryInterface(LPDIRECT3DDEVICE2 iface, + REFIID riid, + LPVOID* obp); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_QueryInterface(LPDIRECT3DDEVICE iface, + REFIID riid, + LPVOID* obp); + +ULONG WINAPI +Thunk_IDirect3DDeviceImpl_3_AddRef(LPDIRECT3DDEVICE3 iface); + +ULONG WINAPI +Thunk_IDirect3DDeviceImpl_2_AddRef(LPDIRECT3DDEVICE2 iface); + +ULONG WINAPI +Thunk_IDirect3DDeviceImpl_1_AddRef(LPDIRECT3DDEVICE iface); + +ULONG WINAPI +Thunk_IDirect3DDeviceImpl_3_Release(LPDIRECT3DDEVICE3 iface); + +ULONG WINAPI +Thunk_IDirect3DDeviceImpl_2_Release(LPDIRECT3DDEVICE2 iface); + +ULONG WINAPI +Thunk_IDirect3DDeviceImpl_1_Release(LPDIRECT3DDEVICE iface); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_AddViewport(LPDIRECT3DDEVICE2 iface, + LPDIRECT3DVIEWPORT2 lpDirect3DViewport2); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_AddViewport(LPDIRECT3DDEVICE iface, + LPDIRECT3DVIEWPORT lpDirect3DViewport); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_DeleteViewport(LPDIRECT3DDEVICE2 iface, + LPDIRECT3DVIEWPORT2 lpDirect3DViewport2); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_DeleteViewport(LPDIRECT3DDEVICE iface, + LPDIRECT3DVIEWPORT lpDirect3DViewport); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_NextViewport(LPDIRECT3DDEVICE3 iface, + LPDIRECT3DVIEWPORT2 lpDirect3DViewport2, + LPDIRECT3DVIEWPORT2* lplpDirect3DViewport2, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_NextViewport(LPDIRECT3DDEVICE3 iface, + LPDIRECT3DVIEWPORT lpDirect3DViewport, + LPDIRECT3DVIEWPORT* lplpDirect3DViewport, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_GetDirect3D(LPDIRECT3DDEVICE3 iface, + LPDIRECT3D3* lplpDirect3D3); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetDirect3D(LPDIRECT3DDEVICE2 iface, + LPDIRECT3D2* lplpDirect3D2); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_GetDirect3D(LPDIRECT3DDEVICE iface, + LPDIRECT3D* lplpDirect3D); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(LPDIRECT3DDEVICE2 iface, + LPDIRECT3DVIEWPORT2 lpDirect3DViewport2); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(LPDIRECT3DDEVICE2 iface, + LPDIRECT3DVIEWPORT2* lpDirect3DViewport2); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(LPDIRECT3DDEVICE3 iface, + LPD3DENUMPIXELFORMATSCALLBACK lpD3DEnumPixelProc, + LPVOID lpArg); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_BeginScene(LPDIRECT3DDEVICE3 iface); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_BeginScene(LPDIRECT3DDEVICE2 iface); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_BeginScene(LPDIRECT3DDEVICE iface); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_EndScene(LPDIRECT3DDEVICE3 iface); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_EndScene(LPDIRECT3DDEVICE2 iface); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_EndScene(LPDIRECT3DDEVICE iface); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_SetTransform(LPDIRECT3DDEVICE3 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_SetTransform(LPDIRECT3DDEVICE2 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_GetTransform(LPDIRECT3DDEVICE3 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetTransform(LPDIRECT3DDEVICE2 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(LPDIRECT3DDEVICE3 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(LPDIRECT3DDEVICE2 iface, + D3DTRANSFORMSTATETYPE dtstTransformStateType, + LPD3DMATRIX lpD3DMatrix); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_SetRenderState(LPDIRECT3DDEVICE3 iface, + D3DRENDERSTATETYPE dwRenderStateType, + DWORD dwRenderState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_SetRenderState(LPDIRECT3DDEVICE2 iface, + D3DRENDERSTATETYPE dwRenderStateType, + DWORD dwRenderState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_GetRenderState(LPDIRECT3DDEVICE3 iface, + D3DRENDERSTATETYPE dwRenderStateType, + LPDWORD lpdwRenderState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetRenderState(LPDIRECT3DDEVICE2 iface, + D3DRENDERSTATETYPE dwRenderStateType, + LPDWORD lpdwRenderState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwVertexCount, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD d3dvtVertexType, + LPVOID lpvVertices, + DWORD dwVertexCount, + LPWORD dwIndices, + DWORD dwIndexCount, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_SetClipStatus(LPDIRECT3DDEVICE3 iface, + LPD3DCLIPSTATUS lpD3DClipStatus); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_SetClipStatus(LPDIRECT3DDEVICE2 iface, + LPD3DCLIPSTATUS lpD3DClipStatus); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_GetClipStatus(LPDIRECT3DDEVICE3 iface, + LPD3DCLIPSTATUS lpD3DClipStatus); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetClipStatus(LPDIRECT3DDEVICE2 iface, + LPD3DCLIPSTATUS lpD3DClipStatus); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD dwVertexType, + LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, + DWORD dwVertexCount, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + DWORD dwVertexType, + LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, + DWORD dwVertexCount, + LPWORD lpIndex, + DWORD dwIndexCount, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(LPDIRECT3DDEVICE3 iface, + LPD3DVECTOR lpCenters, + LPD3DVALUE lpRadii, + DWORD dwNumSpheres, + DWORD dwFlags, + LPDWORD lpdwReturnValues); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(LPDIRECT3DDEVICE3 iface, + DWORD dwStage, + D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, + LPDWORD lpdwState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(LPDIRECT3DDEVICE3 iface, + DWORD dwStage, + D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, + DWORD dwState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_ValidateDevice(LPDIRECT3DDEVICE3 iface, + LPDWORD lpdwPasses); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetCaps(LPDIRECT3DDEVICE2 iface, + LPD3DDEVICEDESC lpD3DHWDevDesc, + LPD3DDEVICEDESC lpD3DHELDevDesc); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_GetCaps(LPDIRECT3DDEVICE iface, + LPD3DDEVICEDESC lpD3DHWDevDesc, + LPD3DDEVICEDESC lpD3DHELDevDesc); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(LPDIRECT3DDEVICE iface, + LPDIRECT3DTEXTURE lpD3Dtex1, + LPDIRECT3DTEXTURE lpD3DTex2); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetStats(LPDIRECT3DDEVICE2 iface, + LPD3DSTATS lpD3DStats); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_GetStats(LPDIRECT3DDEVICE iface, + LPD3DSTATS lpD3DStats); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(LPDIRECT3DDEVICE3 iface, + LPDIRECTDRAWSURFACE4 lpNewRenderTarget, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(LPDIRECT3DDEVICE3 iface, + LPDIRECTDRAWSURFACE4* lplpRenderTarget); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(LPDIRECT3DDEVICE2 iface, + LPDIRECTDRAWSURFACE lpNewRenderTarget, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(LPDIRECT3DDEVICE2 iface, + LPDIRECTDRAWSURFACE* lplpRenderTarget); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_Vertex(LPDIRECT3DDEVICE2 iface, + LPVOID lpVertexType); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_Index(LPDIRECT3DDEVICE2 iface, + WORD wVertexIndex); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_End(LPDIRECT3DDEVICE2 iface, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_GetLightState(LPDIRECT3DDEVICE2 iface, + D3DLIGHTSTATETYPE dwLightStateType, + LPDWORD lpdwLightState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_2_SetLightState(LPDIRECT3DDEVICE2 iface, + D3DLIGHTSTATETYPE dwLightStateType, + DWORD dwLightState); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(LPDIRECT3DDEVICE iface, + LPD3DENUMTEXTUREFORMATSCALLBACK lpD3DEnumTextureProc, + LPVOID lpArg); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_SetTexture(LPDIRECT3DDEVICE3 iface, + DWORD dwStage, + LPDIRECT3DTEXTURE2 lpTexture2); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + LPDIRECT3DVERTEXBUFFER lpD3DVertexBuf, + DWORD dwStartVertex, + DWORD dwNumVertices, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE3 iface, + D3DPRIMITIVETYPE d3dptPrimitiveType, + LPDIRECT3DVERTEXBUFFER lpD3DVertexBuf, + LPWORD lpwIndices, + DWORD dwIndexCount, + DWORD dwFlags); + +HRESULT WINAPI +Thunk_IDirect3DDeviceImpl_3_GetTexture(LPDIRECT3DDEVICE3 iface, + DWORD dwStage, + LPDIRECT3DTEXTURE2* lplpTexture2); + #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */ diff -urN wine-20050524/dlls/ddraw/d3d_utils.c wine-20050628/dlls/ddraw/d3d_utils.c --- wine-20050524/dlls/ddraw/d3d_utils.c 1970-01-01 01:00:00.000000000 +0100 +++ wine-20050628/dlls/ddraw/d3d_utils.c 2005-06-12 12:43:11.000000000 +0200 @@ -0,0 +1,391 @@ +/* Direct3D Common functions + * Copyright (c) 1998 Lionel ULMER + * + * This file contains all common miscellaneous code that spans + * different 'objects' + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT +#include "windef.h" +#include "winbase.h" +#include "objbase.h" +#include "wingdi.h" +#include "ddraw.h" +#include "d3d.h" +#include "wine/debug.h" + +#include "d3d_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(ddraw); + +const char *_get_renderstate(D3DRENDERSTATETYPE type) { + static const char * const states[] = { + "ERR", + "D3DRENDERSTATE_TEXTUREHANDLE", + "D3DRENDERSTATE_ANTIALIAS", + "D3DRENDERSTATE_TEXTUREADDRESS", + "D3DRENDERSTATE_TEXTUREPERSPECTIVE", + "D3DRENDERSTATE_WRAPU", + "D3DRENDERSTATE_WRAPV", + "D3DRENDERSTATE_ZENABLE", + "D3DRENDERSTATE_FILLMODE", + "D3DRENDERSTATE_SHADEMODE", + "D3DRENDERSTATE_LINEPATTERN", + "D3DRENDERSTATE_MONOENABLE", + "D3DRENDERSTATE_ROP2", + "D3DRENDERSTATE_PLANEMASK", + "D3DRENDERSTATE_ZWRITEENABLE", + "D3DRENDERSTATE_ALPHATESTENABLE", + "D3DRENDERSTATE_LASTPIXEL", + "D3DRENDERSTATE_TEXTUREMAG", + "D3DRENDERSTATE_TEXTUREMIN", + "D3DRENDERSTATE_SRCBLEND", + "D3DRENDERSTATE_DESTBLEND", + "D3DRENDERSTATE_TEXTUREMAPBLEND", + "D3DRENDERSTATE_CULLMODE", + "D3DRENDERSTATE_ZFUNC", + "D3DRENDERSTATE_ALPHAREF", + "D3DRENDERSTATE_ALPHAFUNC", + "D3DRENDERSTATE_DITHERENABLE", + "D3DRENDERSTATE_ALPHABLENDENABLE", + "D3DRENDERSTATE_FOGENABLE", + "D3DRENDERSTATE_SPECULARENABLE", + "D3DRENDERSTATE_ZVISIBLE", + "D3DRENDERSTATE_SUBPIXEL", + "D3DRENDERSTATE_SUBPIXELX", + "D3DRENDERSTATE_STIPPLEDALPHA", + "D3DRENDERSTATE_FOGCOLOR", + "D3DRENDERSTATE_FOGTABLEMODE", + "D3DRENDERSTATE_FOGTABLESTART", + "D3DRENDERSTATE_FOGTABLEEND", + "D3DRENDERSTATE_FOGTABLEDENSITY", + "D3DRENDERSTATE_STIPPLEENABLE", + "D3DRENDERSTATE_EDGEANTIALIAS", + "D3DRENDERSTATE_COLORKEYENABLE", + "ERR", + "D3DRENDERSTATE_BORDERCOLOR", + "D3DRENDERSTATE_TEXTUREADDRESSU", + "D3DRENDERSTATE_TEXTUREADDRESSV", + "D3DRENDERSTATE_MIPMAPLODBIAS", + "D3DRENDERSTATE_ZBIAS", + "D3DRENDERSTATE_RANGEFOGENABLE", + "D3DRENDERSTATE_ANISOTROPY", + "D3DRENDERSTATE_FLUSHBATCH", + "D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT", + "D3DRENDERSTATE_STENCILENABLE", + "D3DRENDERSTATE_STENCILFAIL", + "D3DRENDERSTATE_STENCILZFAIL", + "D3DRENDERSTATE_STENCILPASS", + "D3DRENDERSTATE_STENCILFUNC", + "D3DRENDERSTATE_STENCILREF", + "D3DRENDERSTATE_STENCILMASK", + "D3DRENDERSTATE_STENCILWRITEMASK", + "D3DRENDERSTATE_TEXTUREFACTOR", + "ERR", + "ERR", + "ERR", + "D3DRENDERSTATE_STIPPLEPATTERN00", + "D3DRENDERSTATE_STIPPLEPATTERN01", + "D3DRENDERSTATE_STIPPLEPATTERN02", + "D3DRENDERSTATE_STIPPLEPATTERN03", + "D3DRENDERSTATE_STIPPLEPATTERN04", + "D3DRENDERSTATE_STIPPLEPATTERN05", + "D3DRENDERSTATE_STIPPLEPATTERN06", + "D3DRENDERSTATE_STIPPLEPATTERN07", + "D3DRENDERSTATE_STIPPLEPATTERN08", + "D3DRENDERSTATE_STIPPLEPATTERN09", + "D3DRENDERSTATE_STIPPLEPATTERN10", + "D3DRENDERSTATE_STIPPLEPATTERN11", + "D3DRENDERSTATE_STIPPLEPATTERN12", + "D3DRENDERSTATE_STIPPLEPATTERN13", + "D3DRENDERSTATE_STIPPLEPATTERN14", + "D3DRENDERSTATE_STIPPLEPATTERN15", + "D3DRENDERSTATE_STIPPLEPATTERN16", + "D3DRENDERSTATE_STIPPLEPATTERN17", + "D3DRENDERSTATE_STIPPLEPATTERN18", + "D3DRENDERSTATE_STIPPLEPATTERN19", + "D3DRENDERSTATE_STIPPLEPATTERN20", + "D3DRENDERSTATE_STIPPLEPATTERN21", + "D3DRENDERSTATE_STIPPLEPATTERN22", + "D3DRENDERSTATE_STIPPLEPATTERN23", + "D3DRENDERSTATE_STIPPLEPATTERN24", + "D3DRENDERSTATE_STIPPLEPATTERN25", + "D3DRENDERSTATE_STIPPLEPATTERN26", + "D3DRENDERSTATE_STIPPLEPATTERN27", + "D3DRENDERSTATE_STIPPLEPATTERN28", + "D3DRENDERSTATE_STIPPLEPATTERN29", + "D3DRENDERSTATE_STIPPLEPATTERN30", + "D3DRENDERSTATE_STIPPLEPATTERN31" + }; + static const char * const states_2[] = { + "D3DRENDERSTATE_WRAP0", + "D3DRENDERSTATE_WRAP1", + "D3DRENDERSTATE_WRAP2", + "D3DRENDERSTATE_WRAP3", + "D3DRENDERSTATE_WRAP4", + "D3DRENDERSTATE_WRAP5", + "D3DRENDERSTATE_WRAP6", + "D3DRENDERSTATE_WRAP7", + "D3DRENDERSTATE_CLIPPING", + "D3DRENDERSTATE_LIGHTING", + "D3DRENDERSTATE_EXTENTS", + "D3DRENDERSTATE_AMBIENT", + "D3DRENDERSTATE_FOGVERTEXMODE", + "D3DRENDERSTATE_COLORVERTEX", + "D3DRENDERSTATE_LOCALVIEWER", + "D3DRENDERSTATE_NORMALIZENORMALS", + "D3DRENDERSTATE_COLORKEYBLENDENABLE", + "D3DRENDERSTATE_DIFFUSEMATERIALSOURCE", + "D3DRENDERSTATE_SPECULARMATERIALSOURCE", + "D3DRENDERSTATE_AMBIENTMATERIALSOURCE", + "D3DRENDERSTATE_EMISSIVEMATERIALSOURCE", + "ERR", + "ERR", + "D3DRENDERSTATE_VERTEXBLEND", + "D3DRENDERSTATE_CLIPPLANEENABLE", + }; + if (type >= D3DRENDERSTATE_WRAP0) { + type -= D3DRENDERSTATE_WRAP0; + if (type >= (sizeof(states_2) / sizeof(states_2[0]))) return "ERR"; + return states_2[type]; + } + if (type >= (sizeof(states) / sizeof(states[0]))) return "ERR"; + return states[type]; +} + +void +dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol) +{ + DPRINTF("%f %f %f %f", lpCol->u1.r, lpCol->u2.g, lpCol->u3.b, lpCol->u4.a); +} + +void +dump_D3DVECTOR(D3DVECTOR *lpVec) +{ + DPRINTF("%f %f %f", lpVec->u1.x, lpVec->u2.y, lpVec->u3.z); +} + +void +dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat) +{ + DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(lpMat->u.diffuse)); DPRINTF("\n"); + DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(lpMat->u1.ambient)); DPRINTF("\n"); + DPRINTF(" - specular : "); dump_D3DCOLORVALUE(&(lpMat->u2.specular)); DPRINTF("\n"); + DPRINTF(" - emissive : "); dump_D3DCOLORVALUE(&(lpMat->u3.emissive)); DPRINTF("\n"); + DPRINTF(" - power : %f\n", lpMat->u4.power); +} + +void +dump_D3DLIGHT7(LPD3DLIGHT7 lpLight) +{ + DPRINTF(" - light type : %s\n", (lpLight->dltType == D3DLIGHT_POINT ? "D3DLIGHT_POINT" : + (lpLight->dltType == D3DLIGHT_SPOT ? "D3DLIGHT_SPOT" : + (lpLight->dltType == D3DLIGHT_DIRECTIONAL ? "D3DLIGHT_DIRECTIONAL" : + "UNSUPPORTED")))); + DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(lpLight->dcvDiffuse)); DPRINTF("\n"); + DPRINTF(" - specular : "); dump_D3DCOLORVALUE(&(lpLight->dcvSpecular)); DPRINTF("\n"); + DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(lpLight->dcvAmbient)); DPRINTF("\n"); + DPRINTF(" - position : "); dump_D3DVECTOR(&(lpLight->dvPosition)); DPRINTF("\n"); + DPRINTF(" - direction : "); dump_D3DVECTOR(&(lpLight->dvDirection)); DPRINTF("\n"); + DPRINTF(" - dvRange : %f\n", lpLight->dvRange); + DPRINTF(" - dvFalloff : %f\n", lpLight->dvFalloff); + DPRINTF(" - dvAttenuation : %f %f %f\n", lpLight->dvAttenuation0, lpLight->dvAttenuation1, lpLight->dvAttenuation2); + DPRINTF(" - dvTheta : %f\n", lpLight->dvTheta); + DPRINTF(" - dvPhi : %f\n", lpLight->dvPhi); +} + +void +dump_DPFLAGS(DWORD dwFlags) +{ + static const flag_info flags[] = + { + FE(D3DDP_WAIT), + FE(D3DDP_OUTOFORDER), + FE(D3DDP_DONOTCLIP), + FE(D3DDP_DONOTUPDATEEXTENTS), + FE(D3DDP_DONOTLIGHT) + }; + + DDRAW_dump_flags(dwFlags, flags, sizeof(flags)/sizeof(flags[0])); +} + +void +dump_D3DMATRIX(D3DMATRIX *mat) +{ + DPRINTF(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14); + DPRINTF(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24); + DPRINTF(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34); + DPRINTF(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44); +} + +DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) +{ + DWORD size = 0; + int i; + + if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE); + if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD); + if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD); + if (d3dvtVertexType & D3DFVF_RESERVED1) size += sizeof(DWORD); + switch (d3dvtVertexType & D3DFVF_POSITION_MASK) { + case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break; + case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break; + default: TRACE(" matrix weighting not handled yet...\n"); + } + for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++) { + size += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i) * sizeof(D3DVALUE); + } + + return size; +} + +void dump_flexible_vertex(DWORD d3dvtVertexType) +{ + static const flag_info flags[] = { + FE(D3DFVF_NORMAL), + FE(D3DFVF_RESERVED1), + FE(D3DFVF_DIFFUSE), + FE(D3DFVF_SPECULAR) + }; + unsigned int i; + + if (d3dvtVertexType & D3DFVF_RESERVED0) DPRINTF("D3DFVF_RESERVED0 "); + switch (d3dvtVertexType & D3DFVF_POSITION_MASK) { +#define GEN_CASE(a) case a: DPRINTF(#a " "); break + GEN_CASE(D3DFVF_XYZ); + GEN_CASE(D3DFVF_XYZRHW); + GEN_CASE(D3DFVF_XYZB1); + GEN_CASE(D3DFVF_XYZB2); + GEN_CASE(D3DFVF_XYZB3); + GEN_CASE(D3DFVF_XYZB4); + GEN_CASE(D3DFVF_XYZB5); + } + DDRAW_dump_flags_(d3dvtVertexType, flags, sizeof(flags)/sizeof(flags[0]), FALSE); + switch (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) { + GEN_CASE(D3DFVF_TEX0); + GEN_CASE(D3DFVF_TEX1); + GEN_CASE(D3DFVF_TEX2); + GEN_CASE(D3DFVF_TEX3); + GEN_CASE(D3DFVF_TEX4); + GEN_CASE(D3DFVF_TEX5); + GEN_CASE(D3DFVF_TEX6); + GEN_CASE(D3DFVF_TEX7); + GEN_CASE(D3DFVF_TEX8); + } +#undef GEN_CASE + for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++) { + DPRINTF(" T%d-s%ld", i + 1, GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i)); + } + DPRINTF("\n"); +} + +void +convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided, DWORD dwStartVertex) +{ + int current_offset = 0; + unsigned int tex_index; + int size = get_flexible_vertex_size(d3dvtVertexType); + + lpvVertices = ((BYTE *) lpvVertices) + (size * dwStartVertex); + + if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) { + strided->position.lpvData = lpvVertices; + current_offset += 3 * sizeof(D3DVALUE); + } else { + strided->position.lpvData = lpvVertices; + current_offset += 4 * sizeof(D3DVALUE); + } + if (d3dvtVertexType & D3DFVF_RESERVED1) { + current_offset += sizeof(DWORD); + } + if (d3dvtVertexType & D3DFVF_NORMAL) { + strided->normal.lpvData = ((char *) lpvVertices) + current_offset; + current_offset += 3 * sizeof(D3DVALUE); + } + if (d3dvtVertexType & D3DFVF_DIFFUSE) { + strided->diffuse.lpvData = ((char *) lpvVertices) + current_offset; + current_offset += sizeof(DWORD); + } + if (d3dvtVertexType & D3DFVF_SPECULAR) { + strided->specular.lpvData = ((char *) lpvVertices) + current_offset; + current_offset += sizeof(DWORD); + } + for (tex_index = 0; tex_index < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); tex_index++) { + strided->textureCoords[tex_index].lpvData = ((char *) lpvVertices) + current_offset; + current_offset += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_index) * sizeof(D3DVALUE); + } + strided->position.dwStride = current_offset; + strided->normal.dwStride = current_offset; + strided->diffuse.dwStride = current_offset; + strided->specular.dwStride = current_offset; + for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) + strided->textureCoords[tex_index].dwStride = current_offset; +} + +void +dump_D3DVOP(DWORD dwVertexOp) +{ + static const flag_info flags[] = + { + FE(D3DVOP_LIGHT), + FE(D3DVOP_CLIP), + FE(D3DVOP_EXTENTS), + FE(D3DVOP_TRANSFORM) + }; + DDRAW_dump_flags(dwVertexOp, flags, sizeof(flags)/sizeof(flags[0])); +} + +void +dump_D3DPV(DWORD dwFlags) +{ + if (dwFlags == D3DPV_DONOTCOPYDATA) DPRINTF("D3DPV_DONOTCOPYDATA\n"); + else if (dwFlags != 0) DPRINTF("Unknown !!!\n"); + else DPRINTF("\n"); +} + +void multiply_matrix(LPD3DMATRIX dest, LPD3DMATRIX src1, LPD3DMATRIX src2) +{ + D3DMATRIX temp; + + /* Now do the multiplication 'by hand'. + I know that all this could be optimised, but this will be done later :-) */ + temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14); + temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24); + temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34); + temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44); + + temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14); + temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24); + temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34); + temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44); + + temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14); + temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24); + temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34); + temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44); + + temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14); + temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24); + temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34); + temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44); + + /* And copy the new matrix in the good storage.. */ + memcpy(dest, &temp, 16 * sizeof(D3DVALUE)); +} diff -urN wine-20050524/dlls/ddraw/d3dcommon.c wine-20050628/dlls/ddraw/d3dcommon.c --- wine-20050524/dlls/ddraw/d3dcommon.c 2004-09-08 03:37:25.000000000 +0200 +++ wine-20050628/dlls/ddraw/d3dcommon.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,389 +0,0 @@ -/* Direct3D Common functions - * Copyright (c) 1998 Lionel ULMER - * - * This file contains all common miscellaneous code that spans - * different 'objects' - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define NONAMELESSUNION -#define NONAMELESSSTRUCT -#include "windef.h" -#include "winbase.h" -#include "objbase.h" -#include "wingdi.h" -#include "ddraw.h" -#include "d3d.h" -#include "wine/debug.h" - -#include "d3d_private.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ddraw); - -const char *_get_renderstate(D3DRENDERSTATETYPE type) { - static const char * const states[] = { - "ERR", - "D3DRENDERSTATE_TEXTUREHANDLE", - "D3DRENDERSTATE_ANTIALIAS", - "D3DRENDERSTATE_TEXTUREADDRESS", - "D3DRENDERSTATE_TEXTUREPERSPECTIVE", - "D3DRENDERSTATE_WRAPU", - "D3DRENDERSTATE_WRAPV", - "D3DRENDERSTATE_ZENABLE", - "D3DRENDERSTATE_FILLMODE", - "D3DRENDERSTATE_SHADEMODE", - "D3DRENDERSTATE_LINEPATTERN", - "D3DRENDERSTATE_MONOENABLE", - "D3DRENDERSTATE_ROP2", - "D3DRENDERSTATE_PLANEMASK", - "D3DRENDERSTATE_ZWRITEENABLE", - "D3DRENDERSTATE_ALPHATESTENABLE", - "D3DRENDERSTATE_LASTPIXEL", - "D3DRENDERSTATE_TEXTUREMAG", - "D3DRENDERSTATE_TEXTUREMIN", - "D3DRENDERSTATE_SRCBLEND", - "D3DRENDERSTATE_DESTBLEND", - "D3DRENDERSTATE_TEXTUREMAPBLEND", - "D3DRENDERSTATE_CULLMODE", - "D3DRENDERSTATE_ZFUNC", - "D3DRENDERSTATE_ALPHAREF", - "D3DRENDERSTATE_ALPHAFUNC", - "D3DRENDERSTATE_DITHERENABLE", - "D3DRENDERSTATE_ALPHABLENDENABLE", - "D3DRENDERSTATE_FOGENABLE", - "D3DRENDERSTATE_SPECULARENABLE", - "D3DRENDERSTATE_ZVISIBLE", - "D3DRENDERSTATE_SUBPIXEL", - "D3DRENDERSTATE_SUBPIXELX", - "D3DRENDERSTATE_STIPPLEDALPHA", - "D3DRENDERSTATE_FOGCOLOR", - "D3DRENDERSTATE_FOGTABLEMODE", - "D3DRENDERSTATE_FOGTABLESTART", - "D3DRENDERSTATE_FOGTABLEEND", - "D3DRENDERSTATE_FOGTABLEDENSITY", - "D3DRENDERSTATE_STIPPLEENABLE", - "D3DRENDERSTATE_EDGEANTIALIAS", - "D3DRENDERSTATE_COLORKEYENABLE", - "ERR", - "D3DRENDERSTATE_BORDERCOLOR", - "D3DRENDERSTATE_TEXTUREADDRESSU", - "D3DRENDERSTATE_TEXTUREADDRESSV", - "D3DRENDERSTATE_MIPMAPLODBIAS", - "D3DRENDERSTATE_ZBIAS", - "D3DRENDERSTATE_RANGEFOGENABLE", - "D3DRENDERSTATE_ANISOTROPY", - "D3DRENDERSTATE_FLUSHBATCH", - "D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT", - "D3DRENDERSTATE_STENCILENABLE", - "D3DRENDERSTATE_STENCILFAIL", - "D3DRENDERSTATE_STENCILZFAIL", - "D3DRENDERSTATE_STENCILPASS", - "D3DRENDERSTATE_STENCILFUNC", - "D3DRENDERSTATE_STENCILREF", - "D3DRENDERSTATE_STENCILMASK", - "D3DRENDERSTATE_STENCILWRITEMASK", - "D3DRENDERSTATE_TEXTUREFACTOR", - "ERR", - "ERR", - "ERR", - "D3DRENDERSTATE_STIPPLEPATTERN00", - "D3DRENDERSTATE_STIPPLEPATTERN01", - "D3DRENDERSTATE_STIPPLEPATTERN02", - "D3DRENDERSTATE_STIPPLEPATTERN03", - "D3DRENDERSTATE_STIPPLEPATTERN04", - "D3DRENDERSTATE_STIPPLEPATTERN05", - "D3DRENDERSTATE_STIPPLEPATTERN06", - "D3DRENDERSTATE_STIPPLEPATTERN07", - "D3DRENDERSTATE_STIPPLEPATTERN08", - "D3DRENDERSTATE_STIPPLEPATTERN09", - "D3DRENDERSTATE_STIPPLEPATTERN10", - "D3DRENDERSTATE_STIPPLEPATTERN11", - "D3DRENDERSTATE_STIPPLEPATTERN12", - "D3DRENDERSTATE_STIPPLEPATTERN13", - "D3DRENDERSTATE_STIPPLEPATTERN14", - "D3DRENDERSTATE_STIPPLEPATTERN15", - "D3DRENDERSTATE_STIPPLEPATTERN16", - "D3DRENDERSTATE_STIPPLEPATTERN17", - "D3DRENDERSTATE_STIPPLEPATTERN18", - "D3DRENDERSTATE_STIPPLEPATTERN19", - "D3DRENDERSTATE_STIPPLEPATTERN20", - "D3DRENDERSTATE_STIPPLEPATTERN21", - "D3DRENDERSTATE_STIPPLEPATTERN22", - "D3DRENDERSTATE_STIPPLEPATTERN23", - "D3DRENDERSTATE_STIPPLEPATTERN24", - "D3DRENDERSTATE_STIPPLEPATTERN25", - "D3DRENDERSTATE_STIPPLEPATTERN26", - "D3DRENDERSTATE_STIPPLEPATTERN27", - "D3DRENDERSTATE_STIPPLEPATTERN28", - "D3DRENDERSTATE_STIPPLEPATTERN29", - "D3DRENDERSTATE_STIPPLEPATTERN30", - "D3DRENDERSTATE_STIPPLEPATTERN31" - }; - static const char * const states_2[] = { - "D3DRENDERSTATE_WRAP0", - "D3DRENDERSTATE_WRAP1", - "D3DRENDERSTATE_WRAP2", - "D3DRENDERSTATE_WRAP3", - "D3DRENDERSTATE_WRAP4", - "D3DRENDERSTATE_WRAP5", - "D3DRENDERSTATE_WRAP6", - "D3DRENDERSTATE_WRAP7", - "D3DRENDERSTATE_CLIPPING", - "D3DRENDERSTATE_LIGHTING", - "D3DRENDERSTATE_EXTENTS", - "D3DRENDERSTATE_AMBIENT", - "D3DRENDERSTATE_FOGVERTEXMODE", - "D3DRENDERSTATE_COLORVERTEX", - "D3DRENDERSTATE_LOCALVIEWER", - "D3DRENDERSTATE_NORMALIZENORMALS", - "D3DRENDERSTATE_COLORKEYBLENDENABLE", - "D3DRENDERSTATE_DIFFUSEMATERIALSOURCE", - "D3DRENDERSTATE_SPECULARMATERIALSOURCE", - "D3DRENDERSTATE_AMBIENTMATERIALSOURCE", - "D3DRENDERSTATE_EMISSIVEMATERIALSOURCE", - "ERR", - "ERR", - "D3DRENDERSTATE_VERTEXBLEND", - "D3DRENDERSTATE_CLIPPLANEENABLE", - }; - if (type >= D3DRENDERSTATE_WRAP0) { - type -= D3DRENDERSTATE_WRAP0; - if (type >= (sizeof(states_2) / sizeof(states_2[0]))) return "ERR"; - return states_2[type]; - } - if (type >= (sizeof(states) / sizeof(states[0]))) return "ERR"; - return states[type]; -} - -void -dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol) -{ - DPRINTF("%f %f %f %f", lpCol->u1.r, lpCol->u2.g, lpCol->u3.b, lpCol->u4.a); -} - -void -dump_D3DVECTOR(D3DVECTOR *lpVec) -{ - DPRINTF("%f %f %f", lpVec->u1.x, lpVec->u2.y, lpVec->u3.z); -} - -void -dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat) -{ - DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(lpMat->u.diffuse)); DPRINTF("\n"); - DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(lpMat->u1.ambient)); DPRINTF("\n"); - DPRINTF(" - specular : "); dump_D3DCOLORVALUE(&(lpMat->u2.specular)); DPRINTF("\n"); - DPRINTF(" - emissive : "); dump_D3DCOLORVALUE(&(lpMat->u3.emissive)); DPRINTF("\n"); - DPRINTF(" - power : %f\n", lpMat->u4.power); -} - -void -dump_D3DLIGHT7(LPD3DLIGHT7 lpLight) -{ - DPRINTF(" - light type : %s\n", (lpLight->dltType == D3DLIGHT_POINT ? "D3DLIGHT_POINT" : - (lpLight->dltType == D3DLIGHT_SPOT ? "D3DLIGHT_SPOT" : - (lpLight->dltType == D3DLIGHT_DIRECTIONAL ? "D3DLIGHT_DIRECTIONAL" : - "UNSUPPORTED")))); - DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(lpLight->dcvDiffuse)); DPRINTF("\n"); - DPRINTF(" - specular : "); dump_D3DCOLORVALUE(&(lpLight->dcvSpecular)); DPRINTF("\n"); - DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(lpLight->dcvAmbient)); DPRINTF("\n"); - DPRINTF(" - position : "); dump_D3DVECTOR(&(lpLight->dvPosition)); DPRINTF("\n"); - DPRINTF(" - direction : "); dump_D3DVECTOR(&(lpLight->dvDirection)); DPRINTF("\n"); - DPRINTF(" - dvRange : %f\n", lpLight->dvRange); - DPRINTF(" - dvFalloff : %f\n", lpLight->dvFalloff); - DPRINTF(" - dvAttenuation : %f %f %f\n", lpLight->dvAttenuation0, lpLight->dvAttenuation1, lpLight->dvAttenuation2); - DPRINTF(" - dvTheta : %f\n", lpLight->dvTheta); - DPRINTF(" - dvPhi : %f\n", lpLight->dvPhi); -} - -void -dump_DPFLAGS(DWORD dwFlags) -{ - static const flag_info flags[] = - { - FE(D3DDP_WAIT), - FE(D3DDP_OUTOFORDER), - FE(D3DDP_DONOTCLIP), - FE(D3DDP_DONOTUPDATEEXTENTS), - FE(D3DDP_DONOTLIGHT) - }; - - DDRAW_dump_flags(dwFlags, flags, sizeof(flags)/sizeof(flags[0])); -} - -void -dump_D3DMATRIX(D3DMATRIX *mat) -{ - DPRINTF(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14); - DPRINTF(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24); - DPRINTF(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34); - DPRINTF(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44); -} - - -DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) -{ - DWORD size = 0; - - if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE); - if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD); - if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD); - if (d3dvtVertexType & D3DFVF_RESERVED1) size += sizeof(DWORD); - switch (d3dvtVertexType & D3DFVF_POSITION_MASK) { - case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break; - case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break; - default: TRACE(" matrix weighting not handled yet...\n"); - } - size += 2 * sizeof(D3DVALUE) * ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); - - return size; -} - -void dump_flexible_vertex(DWORD d3dvtVertexType) -{ - static const flag_info flags[] = { - FE(D3DFVF_NORMAL), - FE(D3DFVF_RESERVED1), - FE(D3DFVF_DIFFUSE), - FE(D3DFVF_SPECULAR) - }; - unsigned int i; - - if (d3dvtVertexType & D3DFVF_RESERVED0) DPRINTF("D3DFVF_RESERVED0 "); - switch (d3dvtVertexType & D3DFVF_POSITION_MASK) { -#define GEN_CASE(a) case a: DPRINTF(#a " "); break - GEN_CASE(D3DFVF_XYZ); - GEN_CASE(D3DFVF_XYZRHW); - GEN_CASE(D3DFVF_XYZB1); - GEN_CASE(D3DFVF_XYZB2); - GEN_CASE(D3DFVF_XYZB3); - GEN_CASE(D3DFVF_XYZB4); - GEN_CASE(D3DFVF_XYZB5); - } - DDRAW_dump_flags_(d3dvtVertexType, flags, sizeof(flags)/sizeof(flags[0]), FALSE); - switch (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) { - GEN_CASE(D3DFVF_TEX0); - GEN_CASE(D3DFVF_TEX1); - GEN_CASE(D3DFVF_TEX2); - GEN_CASE(D3DFVF_TEX3); - GEN_CASE(D3DFVF_TEX4); - GEN_CASE(D3DFVF_TEX5); - GEN_CASE(D3DFVF_TEX6); - GEN_CASE(D3DFVF_TEX7); - GEN_CASE(D3DFVF_TEX8); - } -#undef GEN_CASE - for (i = 0; i < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); i++) { - DPRINTF(" T%d-s%ld", i + 1, (((d3dvtVertexType >> (16 + (2 * i))) + 1) & 0x03) + 1); - } - DPRINTF("\n"); -} - -void -convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided, DWORD dwStartVertex) -{ - int current_offset = 0; - unsigned int tex_index; - int size = get_flexible_vertex_size(d3dvtVertexType); - - lpvVertices = ((BYTE *) lpvVertices) + (size * dwStartVertex); - - if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) { - strided->position.lpvData = lpvVertices; - current_offset += 3 * sizeof(D3DVALUE); - } else { - strided->position.lpvData = lpvVertices; - current_offset += 4 * sizeof(D3DVALUE); - } - if (d3dvtVertexType & D3DFVF_RESERVED1) { - current_offset += sizeof(DWORD); - } - if (d3dvtVertexType & D3DFVF_NORMAL) { - strided->normal.lpvData = ((char *) lpvVertices) + current_offset; - current_offset += 3 * sizeof(D3DVALUE); - } - if (d3dvtVertexType & D3DFVF_DIFFUSE) { - strided->diffuse.lpvData = ((char *) lpvVertices) + current_offset; - current_offset += sizeof(DWORD); - } - if (d3dvtVertexType & D3DFVF_SPECULAR) { - strided->specular.lpvData = ((char *) lpvVertices) + current_offset; - current_offset += sizeof(DWORD); - } - for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) { - strided->textureCoords[tex_index].lpvData = ((char *) lpvVertices) + current_offset; - current_offset += 2 * sizeof(D3DVALUE); - } - strided->position.dwStride = current_offset; - strided->normal.dwStride = current_offset; - strided->diffuse.dwStride = current_offset; - strided->specular.dwStride = current_offset; - for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) - strided->textureCoords[tex_index].dwStride = current_offset; -} - -void -dump_D3DVOP(DWORD dwVertexOp) -{ - static const flag_info flags[] = - { - FE(D3DVOP_LIGHT), - FE(D3DVOP_CLIP), - FE(D3DVOP_EXTENTS), - FE(D3DVOP_TRANSFORM) - }; - DDRAW_dump_flags(dwVertexOp, flags, sizeof(flags)/sizeof(flags[0])); -} - -void -dump_D3DPV(DWORD dwFlags) -{ - if (dwFlags == D3DPV_DONOTCOPYDATA) DPRINTF("D3DPV_DONOTCOPYDATA\n"); - else if (dwFlags != 0) DPRINTF("Unknown !!!\n"); - else DPRINTF("\n"); -} - -void multiply_matrix(LPD3DMATRIX dest, LPD3DMATRIX src1, LPD3DMATRIX src2) -{ - D3DMATRIX temp; - - /* Now do the multiplication 'by hand'. - I know that all this could be optimised, but this will be done later :-) */ - temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14); - temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24); - temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34); - temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44); - - temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14); - temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24); - temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34); - temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44); - - temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14); - temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24); - temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34); - temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44); - - temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14); - temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24); - temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34); - temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44); - - /* And copy the new matrix in the good storage.. */ - memcpy(dest, &temp, 16 * sizeof(D3DVALUE)); -} diff -urN wine-20050524/dlls/ddraw/d3ddevice/main.c wine-20050628/dlls/ddraw/d3ddevice/main.c --- wine-20050524/dlls/ddraw/d3ddevice/main.c 2005-02-14 12:09:47.000000000 +0100 +++ wine-20050628/dlls/ddraw/d3ddevice/main.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,2193 +0,0 @@ -/* Direct3D Device - * Copyright (c) 1998-2004 Lionel ULMER - * Copyright (c) 2002-2004 Christian Costa - * - * This file contains all the common stuff for D3D devices. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#include -#include - -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "objbase.h" -#include "wingdi.h" -#include "ddraw.h" -#include "d3d.h" -#include "wine/debug.h" - -#include "d3d_private.h" -#include "main.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ddraw); - -DWORD InitRenderStateTab[] = { - D3DRENDERSTATE_TEXTUREHANDLE, (DWORD)NULL, - D3DRENDERSTATE_ANTIALIAS, D3DANTIALIAS_NONE, - /* FIXME: D3DRENDERSTATE_TEXTUREADDRESS */ - D3DRENDERSTATE_TEXTUREPERSPECTIVE, TRUE, - /* FIXME: D3DRENDERSTATE_WRAPU */ - /* FIXME: D3DRENDERSTATE_WRAPV */ - D3DRENDERSTATE_ZENABLE, D3DZB_TRUE, /* This needs to be set differently according to the Z buffer status */ - D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID, - D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD, - D3DRENDERSTATE_LINEPATTERN, 0, - D3DRENDERSTATE_MONOENABLE, FALSE, - D3DRENDERSTATE_ROP2, R2_COPYPEN, - D3DRENDERSTATE_PLANEMASK, 0xFFFFFFFF, - D3DRENDERSTATE_ZWRITEENABLE, TRUE, - D3DRENDERSTATE_ALPHATESTENABLE, FALSE, - D3DRENDERSTATE_LASTPIXEL, TRUE, - D3DRENDERSTATE_TEXTUREMAG, D3DFILTER_NEAREST, - D3DRENDERSTATE_TEXTUREMIN, D3DFILTER_NEAREST, - D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE, - D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO, - D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE, - D3DRENDERSTATE_CULLMODE, D3DCULL_CCW, - D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL, - D3DRENDERSTATE_ALPHAREF, 0, - D3DRENDERSTATE_ALPHAFUNC, D3DCMP_ALWAYS, - D3DRENDERSTATE_DITHERENABLE, FALSE, - D3DRENDERSTATE_ALPHABLENDENABLE, FALSE, - D3DRENDERSTATE_FOGENABLE, FALSE, - D3DRENDERSTATE_SPECULARENABLE, FALSE, - D3DRENDERSTATE_ZVISIBLE, FALSE, - D3DRENDERSTATE_SUBPIXEL, FALSE, - D3DRENDERSTATE_SUBPIXELX, FALSE, - D3DRENDERSTATE_STIPPLEDALPHA, FALSE, - D3DRENDERSTATE_FOGCOLOR, D3DRGBA(0,0,0,0), - D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE, - /* FIXME: D3DRENDERSTATE_FOGTABLESTART (same as D3DRENDERSTATE_FOGSTART) */ - /* FIXME: D3DRENDERSTATE_FOGTABLEEND (same as D3DRENDERSTATE_FOGEND) */ - D3DRENDERSTATE_FOGTABLEDENSITY, 0x3F80000, /* 1.0f (same as D3DRENDERSTATE_FOGDENSITY) */ - /* FIXME: D3DRENDERSTATE_STIPPLEENABLE */ - D3DRENDERSTATE_EDGEANTIALIAS, FALSE, - D3DRENDERSTATE_COLORKEYENABLE, FALSE, - /* FIXME: D3DRENDERSTATE_BORDERCOLOR */ - D3DRENDERSTATE_TEXTUREADDRESSU, D3DTADDRESS_WRAP, - D3DRENDERSTATE_TEXTUREADDRESSV, D3DTADDRESS_WRAP, - D3DRENDERSTATE_MIPMAPLODBIAS, 0x00000000, /* 0.0f */ - D3DRENDERSTATE_ZBIAS, 0, - D3DRENDERSTATE_RANGEFOGENABLE, FALSE, - /* FIXME: D3DRENDERSTATE_ANISOTROPY */ - /* FIXME: D3DRENDERSTATE_FLUSHBATCH */ - /* FIXME: D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT */ - D3DRENDERSTATE_STENCILENABLE, FALSE, - D3DRENDERSTATE_STENCILFAIL, D3DSTENCILOP_KEEP, - D3DRENDERSTATE_STENCILZFAIL, D3DSTENCILOP_KEEP, - D3DRENDERSTATE_STENCILPASS, D3DSTENCILOP_KEEP, - D3DRENDERSTATE_STENCILFUNC, D3DCMP_ALWAYS, - D3DRENDERSTATE_STENCILREF, 0, - D3DRENDERSTATE_STENCILMASK, 0xFFFFFFFF, - D3DRENDERSTATE_STENCILWRITEMASK, 0xFFFFFFFF, - /* FIXME: D3DRENDERSTATE_TEXTUREFACTOR */ - /* FIXME: D3DRENDERSTATE_STIPPLEPATTERN00..31 */ - D3DRENDERSTATE_WRAP0, 0, - D3DRENDERSTATE_WRAP1, 0, - D3DRENDERSTATE_WRAP2, 0, - D3DRENDERSTATE_WRAP3, 0, - D3DRENDERSTATE_WRAP4, 0, - D3DRENDERSTATE_WRAP5, 0, - D3DRENDERSTATE_WRAP6, 0, - D3DRENDERSTATE_WRAP7, 0, - D3DRENDERSTATE_CLIPPING, FALSE, - D3DRENDERSTATE_LIGHTING, TRUE, - D3DRENDERSTATE_EXTENTS, FALSE, - D3DRENDERSTATE_AMBIENT, D3DRGBA(0,0,0,0), - D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE, - D3DRENDERSTATE_COLORVERTEX, TRUE, - D3DRENDERSTATE_LOCALVIEWER, TRUE, - D3DRENDERSTATE_NORMALIZENORMALS, FALSE, - /* FIXME: D3DRENDER_STATE_COLORKEYBLENDENABLE */ - D3DRENDERSTATE_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1, - D3DRENDERSTATE_SPECULARMATERIALSOURCE, D3DMCS_COLOR2, - D3DRENDERSTATE_AMBIENTMATERIALSOURCE, D3DMCS_COLOR2, - D3DRENDERSTATE_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL, - D3DRENDERSTATE_VERTEXBLEND, D3DVBLEND_DISABLE, - D3DRENDERSTATE_CLIPPLANEENABLE, 0 -}; - -DWORD InitLightStateTab[] = { - D3DLIGHTSTATE_MATERIAL, (DWORD)NULL, - D3DLIGHTSTATE_AMBIENT, D3DRGBA(0,0,0,0), - D3DLIGHTSTATE_COLORMODEL, D3DCOLOR_RGB, - D3DLIGHTSTATE_FOGMODE, D3DFOG_NONE, - D3DLIGHTSTATE_FOGSTART, 0x3F80000, /* 1.0f */ - D3DLIGHTSTATE_FOGEND, 0x42C8000, /* 100.0f */ - D3DLIGHTSTATE_FOGDENSITY, 0x3F80000 /* 1.0f */ - /* FIXME: D3DLIGHTSTATE_COLORVERTEX */ -}; - -DWORD InitTextureStageStateTab[] = { - D3DTSS_COLOROP, D3DTOP_DISABLE, /* Note, it's manually set for stage 0 */ - D3DTSS_COLORARG1, D3DTA_TEXTURE, - D3DTSS_COLORARG2, D3DTA_CURRENT, - D3DTSS_ALPHAOP, D3DTOP_DISABLE, /* Note, it's manually set for stage 0 */ - D3DTSS_ALPHAARG1, D3DTA_TEXTURE, - D3DTSS_ALPHAARG2, D3DTA_CURRENT, - /* FIXME: D3DTSS_BUMPENVMAT00,01,10,11 */ - /* D3DTSS_TEXCOORDINDEX is set manually */ - D3DTSS_ADDRESS, D3DTADDRESS_WRAP, - D3DTSS_ADDRESSU, D3DTADDRESS_WRAP, - D3DTSS_ADDRESSV, D3DTADDRESS_WRAP, - D3DTSS_BORDERCOLOR, 0x00000000, - D3DTSS_MAGFILTER, D3DTFG_POINT, - D3DTSS_MINFILTER, D3DTFN_POINT, - D3DTSS_MIPFILTER, D3DTFP_NONE, - D3DTSS_MIPMAPLODBIAS, 0x00000000, /* 0.0f */ - D3DTSS_MAXMIPLEVEL, 0, - /* D3DTSS_MAXANISOTROPY, 1, */ /* This is to prevent warnings :-) */ - /* FIXME: D3DTSS_BUMPENVLSCALE */ - /* FIXME: D3DTSS_NUMPENVLOFFSET */ - /* FIXME: D3DTSS_TEXTURETRANSFORMFLAGS */ -}; - - -void InitDefaultStateBlock(STATEBLOCK* lpStateBlock, int version) -{ - unsigned int i, j; - TRACE("(%p,%d)\n", lpStateBlock, version); - memset(lpStateBlock, 0, sizeof(STATEBLOCK)); - - /* Initialize render states */ - for (i = 0; i < sizeof(InitRenderStateTab) / sizeof(InitRenderStateTab[0]); i += 2) - { - lpStateBlock->render_state[InitRenderStateTab[i] - 1] = InitRenderStateTab[i + 1]; - lpStateBlock->set_flags.render_state[InitRenderStateTab[i] - 1] = TRUE; - } - - /* Initialize texture stages states */ - for (i = 0; i < MAX_TEXTURES; i++) - { - for (j = 0; j < sizeof(InitTextureStageStateTab) / sizeof(InitTextureStageStateTab[0]); j += 2) - { - lpStateBlock->texture_stage_state[i][InitTextureStageStateTab[j] - 1] = InitTextureStageStateTab[j + 1]; - lpStateBlock->set_flags.texture_stage_state[i][InitTextureStageStateTab[j] - 1] = TRUE; - } - /* Map texture coords 0 to stage 0, 1 to stage 1, etc... */ - lpStateBlock->texture_stage_state[i][D3DTSS_TEXCOORDINDEX - 1] = i; - lpStateBlock->set_flags.texture_stage_state[i][D3DTSS_TEXCOORDINDEX - 1] = TRUE; - } - - /* The first texture is particular, update it consequently */ - lpStateBlock->texture_stage_state[0][D3DTSS_COLOROP - 1] = D3DTOP_MODULATE; - lpStateBlock->texture_stage_state[0][D3DTSS_ALPHAOP - 1] = D3DTOP_SELECTARG1; - lpStateBlock->texture_stage_state[0][D3DTSS_COLORARG2 - 1] = D3DTA_DIFFUSE; - lpStateBlock->texture_stage_state[0][D3DTSS_ALPHAARG2 - 1] = D3DTA_DIFFUSE; - - /* Updates for particular versions */ - if ((version == 1) || (version==2)) - lpStateBlock->render_state[D3DRENDERSTATE_SPECULARENABLE - 1] = TRUE; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface, - REFIID riid, - LPVOID* obp) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obp); - - *obp = NULL; - - /* Note: We cannot get an interface whose version is higher than the - * Direct3D object that created the device */ - - if ( IsEqualGUID( &IID_IUnknown, riid ) ) { - IDirect3DDevice7_AddRef(ICOM_INTERFACE(This, IDirect3DDevice7)); - *obp = iface; - TRACE(" Creating IUnknown interface at %p.\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3DDevice, riid ) ) { - IDirect3DDevice7_AddRef(ICOM_INTERFACE(This, IDirect3DDevice7)); - *obp = ICOM_INTERFACE(This, IDirect3DDevice); - TRACE(" Creating IDirect3DDevice interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3DDevice2, riid ) && (This->version >= 2)) { - IDirect3DDevice7_AddRef(ICOM_INTERFACE(This, IDirect3DDevice7)); - *obp = ICOM_INTERFACE(This, IDirect3DDevice2); - TRACE(" Creating IDirect3DDevice2 interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3DDevice3, riid ) && (This->version >= 3)) { - IDirect3DDevice7_AddRef(ICOM_INTERFACE(This, IDirect3DDevice7)); - *obp = ICOM_INTERFACE(This, IDirect3DDevice3); - TRACE(" Creating IDirect3DDevice3 interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirect3DDevice7, riid ) && (This->version >= 7)) { - IDirect3DDevice7_AddRef(ICOM_INTERFACE(This, IDirect3DDevice7)); - *obp = ICOM_INTERFACE(This, IDirect3DDevice7); - TRACE(" Creating IDirect3DDevice7 interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirectDrawSurface, riid ) || - IsEqualGUID( &IID_IDirectDrawSurface2, riid ) || - IsEqualGUID( &IID_IDirectDrawSurface3, riid ) ) { - IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This->surface, IDirectDrawSurface7)); - *obp = ICOM_INTERFACE(This->surface, IDirectDrawSurface3); - TRACE(" Return IDirectDrawSurface3 interface %p\n", *obp); - return S_OK; - } - if ( IsEqualGUID( &IID_IDirectDrawSurface4, riid ) || - IsEqualGUID( &IID_IDirectDrawSurface7, riid ) ) { - IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This->surface, IDirectDrawSurface7)); - *obp = ICOM_INTERFACE(This->surface, IDirectDrawSurface7); - TRACE(" Return IDirectDrawSurface7 interface %p\n", *obp); - return S_OK; - } - FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid)); - return OLE_E_ENUM_NOMORE; -} - -ULONG WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_AddRef(LPDIRECT3DDEVICE7 iface) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p/%p)->() incrementing from %lu.\n", This, iface, ref - 1); - - return ref; -} - -ULONG WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1); - - if (!ref) { - int i; - /* Release texture associated with the device */ - for (i = 0; i < MAX_TEXTURES; i++) { - if (This->current_texture[i] != NULL) - IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[i], IDirect3DTexture2)); - } - - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return ref; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetCaps(LPDIRECT3DDEVICE7 iface, - LPD3DDEVICEDESC7 lpD3DHELDevDesc) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpD3DHELDevDesc); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_EnumTextureFormats(LPDIRECT3DDEVICE7 iface, - LPD3DENUMPIXELFORMATSCALLBACK lpD3DEnumPixelProc, - LPVOID lpArg) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DEnumPixelProc, lpArg); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_BeginScene(LPDIRECT3DDEVICE7 iface) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->()\n", This, iface); - /* Nothing to do */ - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_EndScene(LPDIRECT3DDEVICE7 iface) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->()\n", This, iface); - /* Nothing to do */ - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_GetDirect3D(LPDIRECT3DDEVICE7 iface, - LPDIRECT3D7* lplpDirect3D7) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lplpDirect3D7); - - *lplpDirect3D7 = ICOM_INTERFACE(This->d3d, IDirect3D7); - IDirect3D7_AddRef(ICOM_INTERFACE(This->d3d, IDirect3D7)); - - TRACE(" returning interface %p\n", *lplpDirect3D7); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderTarget(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7 lpNewRenderTarget, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - IDirectDrawSurfaceImpl *target_impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, lpNewRenderTarget); - - TRACE("(%p/%p)->(%p,%08lx)\n", This, iface, lpNewRenderTarget, dwFlags); - if (target_impl != This->surface) { - WARN(" Change of rendering target not handled yet !\n"); - } - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderTarget(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7* lplpRenderTarget) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lplpRenderTarget); - - *lplpRenderTarget = ICOM_INTERFACE(This->surface, IDirectDrawSurface7); - IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This->surface, IDirectDrawSurface7)); - - TRACE(" returning surface at %p.\n", *lplpRenderTarget); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_Clear(LPDIRECT3DDEVICE7 iface, - DWORD dwCount, - LPD3DRECT lpRects, - DWORD dwFlags, - D3DCOLOR dwColor, - D3DVALUE dvZ, - DWORD dwStencil) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This, iface, dwCount, lpRects, dwFlags, (DWORD) dwColor, dvZ, dwStencil); - return This->clear(This, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetTransform(LPDIRECT3DDEVICE7 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - DWORD matrix_changed = 0x00000000; - - TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dtstTransformStateType, lpD3DMatrix); - - switch (dtstTransformStateType) { - case D3DTRANSFORMSTATE_WORLD: { - if (TRACE_ON(ddraw)) { - TRACE(" D3DTRANSFORMSTATE_WORLD :\n"); dump_D3DMATRIX(lpD3DMatrix); - } - memcpy(This->world_mat, lpD3DMatrix, 16 * sizeof(float)); - matrix_changed = WORLDMAT_CHANGED; - } break; - - case D3DTRANSFORMSTATE_VIEW: { - if (TRACE_ON(ddraw)) { - TRACE(" D3DTRANSFORMSTATE_VIEW :\n"); dump_D3DMATRIX(lpD3DMatrix); - } - memcpy(This->view_mat, lpD3DMatrix, 16 * sizeof(float)); - matrix_changed = VIEWMAT_CHANGED; - } break; - - case D3DTRANSFORMSTATE_PROJECTION: { - if (TRACE_ON(ddraw)) { - TRACE(" D3DTRANSFORMSTATE_PROJECTION :\n"); dump_D3DMATRIX(lpD3DMatrix); - } - memcpy(This->proj_mat, lpD3DMatrix, 16 * sizeof(float)); - matrix_changed = PROJMAT_CHANGED; - } break; - - case D3DTRANSFORMSTATE_TEXTURE0: - case D3DTRANSFORMSTATE_TEXTURE1: - case D3DTRANSFORMSTATE_TEXTURE2: - case D3DTRANSFORMSTATE_TEXTURE3: - case D3DTRANSFORMSTATE_TEXTURE4: - case D3DTRANSFORMSTATE_TEXTURE5: - case D3DTRANSFORMSTATE_TEXTURE6: - case D3DTRANSFORMSTATE_TEXTURE7: { - DWORD mat_num = dtstTransformStateType - D3DTRANSFORMSTATE_TEXTURE0; - if (TRACE_ON(ddraw)) { - TRACE(" D3DTRANSFORMSTATE_TEXTURE%ld :\n", mat_num); dump_D3DMATRIX(lpD3DMatrix); - } - memcpy(This->tex_mat[mat_num], lpD3DMatrix, 16 * sizeof(float)); - matrix_changed = TEXMAT0_CHANGED << mat_num; - } break; - - default: - ERR("Unknown transform type %08x !!!\n", dtstTransformStateType); - break; - } - - if (matrix_changed != 0x00000000) This->matrices_updated(This, matrix_changed); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform(LPDIRECT3DDEVICE7 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dtstTransformStateType, lpD3DMatrix); - - switch (dtstTransformStateType) { - case D3DTRANSFORMSTATE_WORLD: { - memcpy(lpD3DMatrix, This->world_mat, 16 * sizeof(D3DVALUE)); - if (TRACE_ON(ddraw)) { - TRACE(" returning D3DTRANSFORMSTATE_WORLD :\n"); - dump_D3DMATRIX(lpD3DMatrix); - } - } break; - - case D3DTRANSFORMSTATE_VIEW: { - memcpy(lpD3DMatrix, This->view_mat, 16 * sizeof(D3DVALUE)); - if (TRACE_ON(ddraw)) { - TRACE(" returning D3DTRANSFORMSTATE_VIEW :\n"); - dump_D3DMATRIX(lpD3DMatrix); - } - } break; - - case D3DTRANSFORMSTATE_PROJECTION: { - memcpy(lpD3DMatrix, This->proj_mat, 16 * sizeof(D3DVALUE)); - if (TRACE_ON(ddraw)) { - TRACE(" returning D3DTRANSFORMSTATE_PROJECTION :\n"); - dump_D3DMATRIX(lpD3DMatrix); - } - } break; - - case D3DTRANSFORMSTATE_TEXTURE0: - case D3DTRANSFORMSTATE_TEXTURE1: - case D3DTRANSFORMSTATE_TEXTURE2: - case D3DTRANSFORMSTATE_TEXTURE3: - case D3DTRANSFORMSTATE_TEXTURE4: - case D3DTRANSFORMSTATE_TEXTURE5: - case D3DTRANSFORMSTATE_TEXTURE6: - case D3DTRANSFORMSTATE_TEXTURE7: { - DWORD mat_num = dtstTransformStateType - D3DTRANSFORMSTATE_TEXTURE0; - memcpy(lpD3DMatrix, This->tex_mat[mat_num], 16 * sizeof(D3DVALUE)); - if (TRACE_ON(ddraw)) { - TRACE(" returning D3DTRANSFORMSTATE_TEXTURE%ld :\n", mat_num); - dump_D3DMATRIX(lpD3DMatrix); - } - } break; - - default: - ERR("Unknown transform type %08x !!!\n", dtstTransformStateType); - return DDERR_INVALIDPARAMS; - } - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform(LPDIRECT3DDEVICE7 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - LPD3DMATRIX mat; - DWORD matrix_changed = 0x00000000; - - TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dtstTransformStateType, lpD3DMatrix); - - if (TRACE_ON(ddraw)) { - TRACE(" Multiplying by :\n"); dump_D3DMATRIX(lpD3DMatrix); - } - - switch (dtstTransformStateType) { - case D3DTRANSFORMSTATE_WORLD: { - if (TRACE_ON(ddraw)) { - TRACE(" Resulting D3DTRANSFORMSTATE_WORLD matrix is :\n"); - } - mat = This->world_mat; - matrix_changed = WORLDMAT_CHANGED; - } break; - - case D3DTRANSFORMSTATE_VIEW: { - if (TRACE_ON(ddraw)) { - TRACE(" Resulting D3DTRANSFORMSTATE_VIEW matrix is :\n"); - } - mat = This->view_mat; - matrix_changed = VIEWMAT_CHANGED; - } break; - - case D3DTRANSFORMSTATE_PROJECTION: { - if (TRACE_ON(ddraw)) { - TRACE(" Resulting D3DTRANSFORMSTATE_PROJECTION matrix is :\n"); - } - mat = This->proj_mat; - matrix_changed = PROJMAT_CHANGED; - } break; - - case D3DTRANSFORMSTATE_TEXTURE0: - case D3DTRANSFORMSTATE_TEXTURE1: - case D3DTRANSFORMSTATE_TEXTURE2: - case D3DTRANSFORMSTATE_TEXTURE3: - case D3DTRANSFORMSTATE_TEXTURE4: - case D3DTRANSFORMSTATE_TEXTURE5: - case D3DTRANSFORMSTATE_TEXTURE6: - case D3DTRANSFORMSTATE_TEXTURE7: { - DWORD mat_num = dtstTransformStateType - D3DTRANSFORMSTATE_TEXTURE0; - if (TRACE_ON(ddraw)) { - TRACE(" Resulting D3DTRANSFORMSTATE_TEXTURE%ld matrix is :\n", mat_num); - } - mat = This->tex_mat[mat_num]; - matrix_changed = TEXMAT0_CHANGED << mat_num; - } break; - - default: - ERR("Unknown transform type %08x !!!\n", dtstTransformStateType); - return DDERR_INVALIDPARAMS; - } - - multiply_matrix(mat,mat,lpD3DMatrix); - - if (TRACE_ON(ddraw)) { - dump_D3DMATRIX(mat); - } - - if (matrix_changed != 0x00000000) This->matrices_updated(This, matrix_changed); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetViewport(LPDIRECT3DDEVICE7 iface, - LPD3DVIEWPORT7 lpData) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lpData); - - *lpData = This->active_viewport; - - if (TRACE_ON(ddraw)) { - TRACE(" returning viewport : \n"); - TRACE(" - dwX = %ld dwY = %ld\n", - lpData->dwX, lpData->dwY); - TRACE(" - dwWidth = %ld dwHeight = %ld\n", - lpData->dwWidth, lpData->dwHeight); - TRACE(" - dvMinZ = %f dvMaxZ = %f\n", - lpData->dvMinZ, lpData->dvMaxZ); - } - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_SetMaterial(LPDIRECT3DDEVICE7 iface, - LPD3DMATERIAL7 lpMat) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpMat); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetMaterial(LPDIRECT3DDEVICE7 iface, - LPD3DMATERIAL7 lpMat) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lpMat); - - *lpMat = This->current_material; - - if (TRACE_ON(ddraw)) { - TRACE(" returning material : \n"); - dump_D3DMATERIAL7(lpMat); - } - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_SetLight(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - LPD3DLIGHT7 lpLight) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx,%p): stub!\n", This, iface, dwLightIndex, lpLight); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetLight(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - LPD3DLIGHT7 lpLight) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwLightIndex, lpLight); - - if (dwLightIndex > MAX_LIGHTS) return DDERR_INVALIDPARAMS; - *lpLight = This->light_parameters[dwLightIndex]; - - if (TRACE_ON(ddraw)) { - TRACE(" returning light : \n"); - dump_D3DLIGHT7(lpLight); - } - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderState(LPDIRECT3DDEVICE7 iface, - D3DRENDERSTATETYPE dwRenderStateType, - DWORD dwRenderState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%08lx): stub!\n", This, iface, dwRenderStateType, dwRenderState); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderState(LPDIRECT3DDEVICE7 iface, - D3DRENDERSTATETYPE dwRenderStateType, - LPDWORD lpdwRenderState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%p): stub!\n", This, iface, dwRenderStateType, lpdwRenderState); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_BeginStateBlock(LPDIRECT3DDEVICE7 iface) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(): stub!\n", This, iface); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_EndStateBlock(LPDIRECT3DDEVICE7 iface, - LPDWORD lpdwBlockHandle) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpdwBlockHandle); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_PreLoad(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7 lpddsTexture) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpddsTexture); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawPrimitive(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitive(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetClipStatus(LPDIRECT3DDEVICE7 iface, - LPD3DCLIPSTATUS lpD3DClipStatus) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpD3DClipStatus); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetClipStatus(LPDIRECT3DDEVICE7 iface, - LPD3DCLIPSTATUS lpD3DClipStatus) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpD3DClipStatus); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawPrimitiveStrided(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - LPWORD lpIndex, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, lpIndex, dwIndexCount, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawPrimitiveVB(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%p,%08lx,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - LPWORD lpwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%p,%08lx,%08lx,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, lpwIndices, dwIndexCount, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_ComputeSphereVisibility(LPDIRECT3DDEVICE7 iface, - LPD3DVECTOR lpCenters, - LPD3DVALUE lpRadii, - DWORD dwNumSpheres, - DWORD dwFlags, - LPDWORD lpdwReturnValues) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p,%p,%08lx,%08lx,%p): stub!\n", This, iface, lpCenters, lpRadii, dwNumSpheres, dwFlags, lpdwReturnValues); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_GetTexture(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - LPDIRECTDRAWSURFACE7* lpTexture) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwStage, lpTexture); - - if (This->current_texture[dwStage] != NULL) { - *lpTexture = ICOM_INTERFACE(This->current_texture[dwStage], IDirectDrawSurface7); - IDirectDrawSurface7_AddRef(*lpTexture); - } else { - *lpTexture = NULL; - } - - TRACE(" returning interface at %p (for implementation at %p).\n", *lpTexture, This->current_texture[dwStage]); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_SetTexture(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - LPDIRECTDRAWSURFACE7 lpTexture) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx,%p): stub!\n", This, iface, dwStage, lpTexture); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_GetTextureStageState(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - LPDWORD lpdwState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08lx,%08x,%p)\n", This, iface, dwStage, d3dTexStageStateType, lpdwState); - if (lpdwState && (dwStage < 8) && d3dTexStageStateType && (d3dTexStageStateType <= HIGHEST_TEXTURE_STAGE_STATE) ) { - *lpdwState = This->state_block.texture_stage_state[dwStage][d3dTexStageStateType-1]; - return DD_OK; - } - return DDERR_INVALIDPARAMS; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_SetTextureStageState(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - DWORD dwState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx,%08x,%08lx): stub!\n", This, iface, dwStage, d3dTexStageStateType, dwState); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_ValidateDevice(LPDIRECT3DDEVICE7 iface, - LPDWORD lpdwPasses) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p): semi-stub!\n", This, iface, lpdwPasses); - - /* For the moment, we have a VERY good hardware which does everything in one pass :-) */ - *lpdwPasses = 1; - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_ApplyStateBlock(LPDIRECT3DDEVICE7 iface, - DWORD dwBlockHandle) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx): stub!\n", This, iface, dwBlockHandle); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_CaptureStateBlock(LPDIRECT3DDEVICE7 iface, - DWORD dwBlockHandle) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx): stub!\n", This, iface, dwBlockHandle); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_DeleteStateBlock(LPDIRECT3DDEVICE7 iface, - DWORD dwBlockHandle) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx): stub!\n", This, iface, dwBlockHandle); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_CreateStateBlock(LPDIRECT3DDEVICE7 iface, - D3DSTATEBLOCKTYPE d3dsbType, - LPDWORD lpdwBlockHandle) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08x,%p): stub!\n", This, iface, d3dsbType, lpdwBlockHandle); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_Load(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7 lpDestTex, - LPPOINT lpDestPoint, - LPDIRECTDRAWSURFACE7 lpSrcTex, - LPRECT lprcSrcRect, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%p,%p,%p,%p,%08lx): Partially Implemented!\n", This, iface, lpDestTex, lpDestPoint, lpSrcTex, lprcSrcRect, dwFlags); - IDirect3DTexture2_Load(COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirect3DTexture2, lpDestTex), - COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirect3DTexture2, lpSrcTex)); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_LightEnable(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - BOOL bEnable) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx,%d): stub!\n", This, iface, dwLightIndex, bEnable); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetLightEnable(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - BOOL* pbEnable) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwLightIndex, pbEnable); - - if (dwLightIndex > MAX_LIGHTS) *pbEnable = 0; - else *pbEnable = ((0x00000001 << dwLightIndex) & This->active_lights) != 0; - - TRACE(" returning %d.\n", *pbEnable); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_SetClipPlane(LPDIRECT3DDEVICE7 iface, - DWORD dwIndex, - D3DVALUE* pPlaneEquation) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - FIXME("(%p/%p)->(%08lx,%p): stub!\n", This, iface, dwIndex, pPlaneEquation); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetClipPlane(LPDIRECT3DDEVICE7 iface, DWORD dwIndex, D3DVALUE* pPlaneEquation) -{ - IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; - - TRACE("(%p)->(%ld,%p)\n", This, dwIndex, pPlaneEquation); - - if (dwIndex>=This->max_clipping_planes) { - return DDERR_INVALIDPARAMS; - } - - memcpy( pPlaneEquation, This->clipping_planes[dwIndex].plane, sizeof(D3DVALUE[4])); - - return D3D_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetInfo(LPDIRECT3DDEVICE7 iface, - DWORD dwDevInfoID, - LPVOID pDevInfoStruct, - DWORD dwSize) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08lx,%p,%08lx)\n", This, iface, dwDevInfoID, pDevInfoStruct, dwSize); - - if (TRACE_ON(ddraw)) { - TRACE(" info requested : "); - switch (dwDevInfoID) { - case D3DDEVINFOID_TEXTUREMANAGER: TRACE("D3DDEVINFOID_TEXTUREMANAGER\n"); break; - case D3DDEVINFOID_D3DTEXTUREMANAGER: TRACE("D3DDEVINFOID_D3DTEXTUREMANAGER\n"); break; - case D3DDEVINFOID_TEXTURING: TRACE("D3DDEVINFOID_TEXTURING\n"); break; - default: ERR(" invalid flag !!!\n"); return DDERR_INVALIDPARAMS; - } - } - - return S_FALSE; /* According to MSDN, this is valid for a non-debug driver */ -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_GetCaps(LPDIRECT3DDEVICE3 iface, - LPD3DDEVICEDESC lpD3DHWDevDesc, - LPD3DDEVICEDESC lpD3DHELDevDesc) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DHWDevDesc, lpD3DHELDevDesc); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_GetStats(LPDIRECT3DDEVICE3 iface, - LPD3DSTATS lpD3DStats) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpD3DStats); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_AddViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - IDirect3DViewportImpl *lpDirect3DViewportImpl = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport3); - - TRACE("(%p/%p)->(%p)\n", This, iface, lpDirect3DViewport3); - - lpDirect3DViewportImpl->next = This->viewport_list; - This->viewport_list = lpDirect3DViewportImpl; - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_DeleteViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - IDirect3DViewportImpl *lpDirect3DViewportImpl = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport3); - IDirect3DViewportImpl *cur_viewport, *prev_viewport = NULL; - - TRACE("(%p/%p)->(%p)\n", This, iface, lpDirect3DViewport3); - - cur_viewport = This->viewport_list; - while (cur_viewport != NULL) { - if (cur_viewport == lpDirect3DViewportImpl) { - if (prev_viewport == NULL) This->viewport_list = cur_viewport->next; - else prev_viewport->next = cur_viewport->next; - /* TODO : add desactivate of the viewport and all associated lights... */ - return DD_OK; - } - prev_viewport = cur_viewport; - cur_viewport = cur_viewport->next; - } - - return DDERR_INVALIDPARAMS; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_NextViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3, - LPDIRECT3DVIEWPORT3* lplpDirect3DViewport3, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - IDirect3DViewportImpl *res = NULL; - - TRACE("(%p/%p)->(%p,%p,%08lx)\n", This, iface, lpDirect3DViewport3, lplpDirect3DViewport3, dwFlags); - - switch (dwFlags) { - case D3DNEXT_NEXT: { - IDirect3DViewportImpl *lpDirect3DViewportImpl = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport3); - res = lpDirect3DViewportImpl->next; - } break; - case D3DNEXT_HEAD: { - res = This->viewport_list; - } break; - case D3DNEXT_TAIL: { - IDirect3DViewportImpl *cur_viewport = This->viewport_list; - if (cur_viewport != NULL) { - while (cur_viewport->next != NULL) cur_viewport = cur_viewport->next; - } - res = cur_viewport; - } break; - default: - *lplpDirect3DViewport3 = NULL; - return DDERR_INVALIDPARAMS; - } - *lplpDirect3DViewport3 = ICOM_INTERFACE(res, IDirect3DViewport3); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_SetCurrentViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lpDirect3DViewport3); - - /* Do nothing if the specified viewport is the same as the current one */ - if (This->current_viewport == ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport3)) - return DD_OK; - - /* Should check if the viewport was added or not */ - - /* Release previous viewport and AddRef the new one */ - if (This->current_viewport) - IDirect3DViewport3_Release(ICOM_INTERFACE(This->current_viewport, IDirect3DViewport3)); - IDirect3DViewport3_AddRef(lpDirect3DViewport3); - - /* Set this viewport as the current viewport */ - This->current_viewport = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport3); - - /* Activate this viewport */ - This->current_viewport->active_device = This; - This->current_viewport->activate(This->current_viewport); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_GetCurrentViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3* lplpDirect3DViewport3) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lplpDirect3DViewport3); - - *lplpDirect3DViewport3 = ICOM_INTERFACE(This->current_viewport, IDirect3DViewport3); - - /* AddRef the returned viewport */ - IDirect3DViewport3_AddRef(*lplpDirect3DViewport3); - - TRACE(" returning interface %p\n", *lplpDirect3DViewport3); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_Begin(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexTypeDesc, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%08x,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, dwVertexTypeDesc, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_BeginIndexed(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwNumVertices, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwNumVertices, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_Vertex(LPDIRECT3DDEVICE3 iface, - LPVOID lpVertexType) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpVertexType); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_Index(LPDIRECT3DDEVICE3 iface, - WORD wVertexIndex) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%04x): stub!\n", This, iface, wVertexIndex); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_End(LPDIRECT3DDEVICE3 iface, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%08lx): stub!\n", This, iface, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_GetLightState(LPDIRECT3DDEVICE3 iface, - D3DLIGHTSTATETYPE dwLightStateType, - LPDWORD lpdwLightState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%08x,%p): stub !\n", This, iface, dwLightStateType, lpdwLightState); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface, - D3DLIGHTSTATETYPE dwLightStateType, - DWORD dwLightState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - FIXME("(%p/%p)->(%08x,%08lx): stub!\n", This, iface, dwLightStateType, dwLightState); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_1T_SwapTextureHandles(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DTEXTURE2 lpD3DTex1, - LPDIRECT3DTEXTURE2 lpD3DTex2) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - IDirectDrawSurfaceImpl tmp,*surf1,*surf2; - TRACE("(%p/%p)->(%p,%p):\n", This, iface, lpD3DTex1, lpD3DTex2); - - surf1 = ICOM_OBJECT(IDirectDrawSurfaceImpl,IDirect3DTexture2,lpD3DTex1); - surf2 = ICOM_OBJECT(IDirectDrawSurfaceImpl,IDirect3DTexture2,lpD3DTex2); - tmp = *surf1; - *surf1 = *surf2; - *surf2 = tmp; - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_NextViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2, - LPDIRECT3DVIEWPORT2* lplpDirect3DViewport2, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - FIXME("(%p/%p)->(%p,%p,%08lx): stub!\n", This, iface, lpDirect3DViewport2, lplpDirect3DViewport2, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_1T_EnumTextureFormats(LPDIRECT3DDEVICE2 iface, - LPD3DENUMTEXTUREFORMATSCALLBACK lpD3DEnumTextureProc, - LPVOID lpArg) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DEnumTextureProc, lpArg); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_Begin(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dpt, - D3DVERTEXTYPE dwVertexTypeDesc, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - FIXME("(%p/%p)->(%08x,%08x,%08lx): stub!\n", This, iface, d3dpt, dwVertexTypeDesc, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_BeginIndexed(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwNumVertices, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - FIXME("(%p/%p)->(%08x,%08x,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwNumVertices, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_DrawPrimitive(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - FIXME("(%p/%p)->(%08x,%08x,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - FIXME("(%p/%p)->(%08x,%08x,%p,%08lx,%p,%08lx,%08lx): stub!\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_Initialize(LPDIRECT3DDEVICE iface, - LPDIRECT3D lpDirect3D, - LPGUID lpGUID, - LPD3DDEVICEDESC lpD3DDVDesc) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - FIXME("(%p/%p)->(%p,%p,%p): stub!\n", This, iface, lpDirect3D, lpGUID, lpD3DDVDesc); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_CreateExecuteBuffer(LPDIRECT3DDEVICE iface, - LPD3DEXECUTEBUFFERDESC lpDesc, - LPDIRECT3DEXECUTEBUFFER* lplpDirect3DExecuteBuffer, - IUnknown* pUnkOuter) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - FIXME("(%p/%p)->(%p,%p,%p): stub!\n", This, iface, lpDesc, lplpDirect3DExecuteBuffer, pUnkOuter); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_Execute(LPDIRECT3DDEVICE iface, - LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, - LPDIRECT3DVIEWPORT lpDirect3DViewport, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - IDirect3DExecuteBufferImpl *lpDirect3DExecuteBufferImpl = ICOM_OBJECT(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, lpDirect3DExecuteBuffer); - IDirect3DViewportImpl *lpDirect3DViewportImpl = ICOM_OBJECT(IDirect3DViewportImpl, IDirect3DViewport3, lpDirect3DViewport); - - TRACE("(%p/%p)->(%p,%p,%08lx)\n", This, iface, lpDirect3DExecuteBuffer, lpDirect3DViewport, dwFlags); - - /* Put this as the default context */ - - /* Execute... */ - lpDirect3DExecuteBufferImpl->execute(lpDirect3DExecuteBufferImpl, This, lpDirect3DViewportImpl); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_NextViewport(LPDIRECT3DDEVICE iface, - LPDIRECT3DVIEWPORT lpDirect3DViewport, - LPDIRECT3DVIEWPORT* lplpDirect3DViewport, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - FIXME("(%p/%p)->(%p,%p,%08lx): stub!\n", This, iface, lpDirect3DViewport, lplpDirect3DViewport, dwFlags); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_Pick(LPDIRECT3DDEVICE iface, - LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, - LPDIRECT3DVIEWPORT lpDirect3DViewport, - DWORD dwFlags, - LPD3DRECT lpRect) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - FIXME("(%p/%p)->(%p,%p,%08lx,%p): stub!\n", This, iface, lpDirect3DExecuteBuffer, lpDirect3DViewport, dwFlags, lpRect); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_GetPickRecords(LPDIRECT3DDEVICE iface, - LPDWORD lpCount, - LPD3DPICKRECORD lpD3DPickRec) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpCount, lpD3DPickRec); - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_CreateMatrix(LPDIRECT3DDEVICE iface, - LPD3DMATRIXHANDLE lpD3DMatHandle) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lpD3DMatHandle); - - *lpD3DMatHandle = (D3DMATRIXHANDLE) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(D3DMATRIX)); - TRACE(" returning matrix handle %p\n", (void *) *lpD3DMatHandle); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_SetMatrix(LPDIRECT3DDEVICE iface, - D3DMATRIXHANDLE D3DMatHandle, - LPD3DMATRIX lpD3DMatrix) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, (DWORD) D3DMatHandle, lpD3DMatrix); - - if (TRACE_ON(ddraw)) { - dump_D3DMATRIX(lpD3DMatrix); - } - *((D3DMATRIX *) D3DMatHandle) = *lpD3DMatrix; - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_GetMatrix(LPDIRECT3DDEVICE iface, - D3DMATRIXHANDLE D3DMatHandle, - LPD3DMATRIX lpD3DMatrix) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, (DWORD) D3DMatHandle, lpD3DMatrix); - - *lpD3DMatrix = *((D3DMATRIX *) D3DMatHandle); - - return DD_OK; -} - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_DeleteMatrix(LPDIRECT3DDEVICE iface, - D3DMATRIXHANDLE D3DMatHandle) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) D3DMatHandle); - - HeapFree(GetProcessHeap(), 0, (void *) D3DMatHandle); - - return DD_OK; -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_QueryInterface(LPDIRECT3DDEVICE3 iface, - REFIID riid, - LPVOID* obp) -{ - TRACE("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", iface, debugstr_guid(riid), obp); - return IDirect3DDevice7_QueryInterface(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - riid, - obp); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_QueryInterface(LPDIRECT3DDEVICE2 iface, - REFIID riid, - LPVOID* obp) -{ - TRACE("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", iface, debugstr_guid(riid), obp); - return IDirect3DDevice7_QueryInterface(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - riid, - obp); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_QueryInterface(LPDIRECT3DDEVICE iface, - REFIID riid, - LPVOID* obp) -{ - TRACE("(%p)->(%s,%p) thunking to IDirect3DDevice7 interface.\n", iface, debugstr_guid(riid), obp); - return IDirect3DDevice7_QueryInterface(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface), - riid, - obp); -} - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_3_AddRef(LPDIRECT3DDEVICE3 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_AddRef(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface)); -} - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_2_AddRef(LPDIRECT3DDEVICE2 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_AddRef(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface)); -} - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_1_AddRef(LPDIRECT3DDEVICE iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_AddRef(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface)); -} - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_3_Release(LPDIRECT3DDEVICE3 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_Release(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface)); -} - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_2_Release(LPDIRECT3DDEVICE2 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_Release(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface)); -} - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_1_Release(LPDIRECT3DDEVICE iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_Release(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_AddViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpDirect3DViewport2); - return IDirect3DDevice3_AddViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3) lpDirect3DViewport2 /* No need to cast here as all interfaces are equivalent */); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_AddViewport(LPDIRECT3DDEVICE iface, - LPDIRECT3DVIEWPORT lpDirect3DViewport) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpDirect3DViewport); - return IDirect3DDevice3_AddViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3) lpDirect3DViewport /* No need to cast here as all interfaces are equivalent */); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_DeleteViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpDirect3DViewport2); - return IDirect3DDevice3_DeleteViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3) lpDirect3DViewport2 /* No need to cast here as all interfaces are equivalent */); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_DeleteViewport(LPDIRECT3DDEVICE iface, - LPDIRECT3DVIEWPORT lpDirect3DViewport) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpDirect3DViewport); - return IDirect3DDevice3_DeleteViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3) lpDirect3DViewport /* No need to cast here as all interfaces are equivalent */); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_NextViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2, - LPDIRECT3DVIEWPORT2* lplpDirect3DViewport2, - DWORD dwFlags) -{ - TRACE("(%p)->(%p,%p,%08lx) thunking to IDirect3DDevice3 interface.\n", iface, lpDirect3DViewport2, lplpDirect3DViewport2, dwFlags); - return IDirect3DDevice3_NextViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3) lpDirect3DViewport2 /* No need to cast here as all interfaces are equivalent */, - (LPDIRECT3DVIEWPORT3*) lplpDirect3DViewport2, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_NextViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT lpDirect3DViewport, - LPDIRECT3DVIEWPORT* lplpDirect3DViewport, - DWORD dwFlags) -{ - TRACE("(%p)->(%p,%p,%08lx) thunking to IDirect3DDevice3 interface.\n", iface, lpDirect3DViewport, lplpDirect3DViewport, dwFlags); - return IDirect3DDevice3_NextViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3) lpDirect3DViewport /* No need to cast here as all interfaces are equivalent */, - (LPDIRECT3DVIEWPORT3*) lplpDirect3DViewport, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetDirect3D(LPDIRECT3DDEVICE3 iface, - LPDIRECT3D3* lplpDirect3D3) -{ - HRESULT ret; - LPDIRECT3D7 ret_ptr; - - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpDirect3D3); - ret = IDirect3DDevice7_GetDirect3D(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - &ret_ptr); - *lplpDirect3D3 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D3, ret_ptr); - TRACE(" returning interface %p\n", *lplpDirect3D3); - return ret; -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetDirect3D(LPDIRECT3DDEVICE2 iface, - LPDIRECT3D2* lplpDirect3D2) -{ - HRESULT ret; - LPDIRECT3D7 ret_ptr; - - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpDirect3D2); - ret = IDirect3DDevice7_GetDirect3D(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - &ret_ptr); - *lplpDirect3D2 = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D2, ret_ptr); - TRACE(" returning interface %p\n", *lplpDirect3D2); - return ret; -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_GetDirect3D(LPDIRECT3DDEVICE iface, - LPDIRECT3D* lplpDirect3D) -{ - HRESULT ret; - LPDIRECT3D7 ret_ptr; - - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpDirect3D); - ret = IDirect3DDevice7_GetDirect3D(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface), - &ret_ptr); - *lplpDirect3D = COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirect3D, ret_ptr); - TRACE(" returning interface %p\n", *lplpDirect3D); - return ret; -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpDirect3DViewport2); - return IDirect3DDevice3_SetCurrentViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3) lpDirect3DViewport2 /* No need to cast here as all interfaces are equivalent */); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2* lplpDirect3DViewport2) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lplpDirect3DViewport2); - return IDirect3DDevice3_GetCurrentViewport(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - (LPDIRECT3DVIEWPORT3*) lplpDirect3DViewport2 /* No need to cast here as all interfaces are equivalent */); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(LPDIRECT3DDEVICE3 iface, - LPD3DENUMPIXELFORMATSCALLBACK lpD3DEnumPixelProc, - LPVOID lpArg) -{ - TRACE("(%p)->(%p,%p) thunking to IDirect3DDevice7 interface.\n", iface, lpD3DEnumPixelProc, lpArg); - return IDirect3DDevice7_EnumTextureFormats(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - lpD3DEnumPixelProc, - lpArg); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_BeginScene(LPDIRECT3DDEVICE3 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_BeginScene(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_BeginScene(LPDIRECT3DDEVICE2 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_BeginScene(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_BeginScene(LPDIRECT3DDEVICE iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_BeginScene(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_EndScene(LPDIRECT3DDEVICE3 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_EndScene(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_EndScene(LPDIRECT3DDEVICE2 iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_EndScene(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_EndScene(LPDIRECT3DDEVICE iface) -{ - TRACE("(%p)->() thunking to IDirect3DDevice7 interface.\n", iface); - return IDirect3DDevice7_EndScene(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice7, iface)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetTransform(LPDIRECT3DDEVICE3 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dtstTransformStateType, lpD3DMatrix); - return IDirect3DDevice7_SetTransform(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dtstTransformStateType, - lpD3DMatrix); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetTransform(LPDIRECT3DDEVICE2 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dtstTransformStateType, lpD3DMatrix); - return IDirect3DDevice7_SetTransform(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - dtstTransformStateType, - lpD3DMatrix); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetTransform(LPDIRECT3DDEVICE3 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dtstTransformStateType, lpD3DMatrix); - return IDirect3DDevice7_GetTransform(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dtstTransformStateType, - lpD3DMatrix); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetTransform(LPDIRECT3DDEVICE2 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dtstTransformStateType, lpD3DMatrix); - return IDirect3DDevice7_GetTransform(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - dtstTransformStateType, - lpD3DMatrix); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(LPDIRECT3DDEVICE3 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dtstTransformStateType, lpD3DMatrix); - return IDirect3DDevice7_MultiplyTransform(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dtstTransformStateType, - lpD3DMatrix); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(LPDIRECT3DDEVICE2 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dtstTransformStateType, lpD3DMatrix); - return IDirect3DDevice7_MultiplyTransform(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - dtstTransformStateType, - lpD3DMatrix); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetRenderState(LPDIRECT3DDEVICE3 iface, - D3DRENDERSTATETYPE dwRenderStateType, - DWORD dwRenderState) -{ - TRACE("(%p)->(%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, dwRenderStateType, dwRenderState); - return IDirect3DDevice7_SetRenderState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dwRenderStateType, - dwRenderState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetRenderState(LPDIRECT3DDEVICE2 iface, - D3DRENDERSTATETYPE dwRenderStateType, - DWORD dwRenderState) -{ - TRACE("(%p)->(%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, dwRenderStateType, dwRenderState); - return IDirect3DDevice7_SetRenderState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - dwRenderStateType, - dwRenderState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetRenderState(LPDIRECT3DDEVICE3 iface, - D3DRENDERSTATETYPE dwRenderStateType, - LPDWORD lpdwRenderState) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dwRenderStateType, lpdwRenderState); - return IDirect3DDevice7_GetRenderState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dwRenderStateType, - lpdwRenderState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetRenderState(LPDIRECT3DDEVICE2 iface, - D3DRENDERSTATETYPE dwRenderStateType, - LPDWORD lpdwRenderState) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dwRenderStateType, lpdwRenderState); - return IDirect3DDevice7_GetRenderState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - dwRenderStateType, - lpdwRenderState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags) -{ - TRACE("(%p)->(%08x,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); - return IDirect3DDevice7_DrawPrimitive(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - d3dptPrimitiveType, - d3dvtVertexType, - lpvVertices, - dwVertexCount, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - TRACE("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags); - return IDirect3DDevice7_DrawIndexedPrimitive(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - d3dptPrimitiveType, - d3dvtVertexType, - lpvVertices, - dwVertexCount, - dwIndices, - dwIndexCount, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetClipStatus(LPDIRECT3DDEVICE3 iface, - LPD3DCLIPSTATUS lpD3DClipStatus) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lpD3DClipStatus); - return IDirect3DDevice7_SetClipStatus(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - lpD3DClipStatus); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetClipStatus(LPDIRECT3DDEVICE2 iface, - LPD3DCLIPSTATUS lpD3DClipStatus) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lpD3DClipStatus); - return IDirect3DDevice7_SetClipStatus(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - lpD3DClipStatus); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetClipStatus(LPDIRECT3DDEVICE3 iface, - LPD3DCLIPSTATUS lpD3DClipStatus) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lpD3DClipStatus); - return IDirect3DDevice7_GetClipStatus(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - lpD3DClipStatus); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetClipStatus(LPDIRECT3DDEVICE2 iface, - LPD3DCLIPSTATUS lpD3DClipStatus) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lpD3DClipStatus); - return IDirect3DDevice7_GetClipStatus(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - lpD3DClipStatus); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - DWORD dwFlags) -{ - TRACE("(%p)->(%08x,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, dwFlags); - return IDirect3DDevice7_DrawPrimitiveStrided(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - d3dptPrimitiveType, - dwVertexType, - lpD3DDrawPrimStrideData, - dwVertexCount, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - LPWORD lpIndex, - DWORD dwIndexCount, - DWORD dwFlags) -{ - TRACE("(%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, lpIndex, dwIndexCount, dwFlags); - return IDirect3DDevice7_DrawIndexedPrimitiveStrided(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - d3dptPrimitiveType, - dwVertexType, - lpD3DDrawPrimStrideData, - dwVertexCount, - lpIndex, - dwIndexCount, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(LPDIRECT3DDEVICE3 iface, - LPD3DVECTOR lpCenters, - LPD3DVALUE lpRadii, - DWORD dwNumSpheres, - DWORD dwFlags, - LPDWORD lpdwReturnValues) -{ - TRACE("(%p)->(%p,%p,%08lx,%08lx,%p) thunking to IDirect3DDevice7 interface.\n", iface, lpCenters, lpRadii, dwNumSpheres, dwFlags, lpdwReturnValues); - return IDirect3DDevice7_ComputeSphereVisibility(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - lpCenters, - lpRadii, - dwNumSpheres, - dwFlags, - lpdwReturnValues); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - LPDWORD lpdwState) -{ - TRACE("(%p)->(%08lx,%08x,%p) thunking to IDirect3DDevice7 interface.\n", iface, dwStage, d3dTexStageStateType, lpdwState); - return IDirect3DDevice7_GetTextureStageState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dwStage, - d3dTexStageStateType, - lpdwState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - DWORD dwState) -{ - TRACE("(%p)->(%08lx,%08x,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, dwStage, d3dTexStageStateType, dwState); - return IDirect3DDevice7_SetTextureStageState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dwStage, - d3dTexStageStateType, - dwState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_ValidateDevice(LPDIRECT3DDEVICE3 iface, - LPDWORD lpdwPasses) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lpdwPasses); - return IDirect3DDevice7_ValidateDevice(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - lpdwPasses); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetCaps(LPDIRECT3DDEVICE2 iface, - LPD3DDEVICEDESC lpD3DHWDevDesc, - LPD3DDEVICEDESC lpD3DHELDevDesc) -{ - TRACE("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", iface, lpD3DHWDevDesc, lpD3DHELDevDesc); - return IDirect3DDevice3_GetCaps(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - lpD3DHWDevDesc, - lpD3DHELDevDesc); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_GetCaps(LPDIRECT3DDEVICE iface, - LPD3DDEVICEDESC lpD3DHWDevDesc, - LPD3DDEVICEDESC lpD3DHELDevDesc) -{ - TRACE("(%p)->(%p,%p) thunking to IDirect3DDevice3 interface.\n", iface, lpD3DHWDevDesc, lpD3DHELDevDesc); - return IDirect3DDevice3_GetCaps(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, iface), - lpD3DHWDevDesc, - lpD3DHELDevDesc); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(LPDIRECT3DDEVICE iface, - LPDIRECT3DTEXTURE lpD3DTex1, - LPDIRECT3DTEXTURE lpD3DTex2) -{ - TRACE("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", iface, lpD3DTex1, lpD3DTex2); - return IDirect3DDevice2_SwapTextureHandles(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice2, iface), - COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirect3DTexture2, lpD3DTex1), - COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture, IDirect3DTexture2, lpD3DTex2)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetStats(LPDIRECT3DDEVICE2 iface, - LPD3DSTATS lpD3DStats) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpD3DStats); - return IDirect3DDevice3_GetStats(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - lpD3DStats); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_GetStats(LPDIRECT3DDEVICE iface, - LPD3DSTATS lpD3DStats) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpD3DStats); - return IDirect3DDevice3_GetStats(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, iface), - lpD3DStats); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(LPDIRECT3DDEVICE3 iface, - LPDIRECTDRAWSURFACE4 lpNewRenderTarget, - DWORD dwFlags) -{ - TRACE("(%p)->(%p,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, lpNewRenderTarget, dwFlags); - return IDirect3DDevice7_SetRenderTarget(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - (LPDIRECTDRAWSURFACE7) lpNewRenderTarget /* No cast needed as DSurf4 == DSurf7 */, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(LPDIRECT3DDEVICE3 iface, - LPDIRECTDRAWSURFACE4* lplpRenderTarget) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpRenderTarget); - return IDirect3DDevice7_GetRenderTarget(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - (LPDIRECTDRAWSURFACE7*) lplpRenderTarget /* No cast needed as DSurf4 == DSurf7 */); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(LPDIRECT3DDEVICE2 iface, - LPDIRECTDRAWSURFACE lpNewRenderTarget, - DWORD dwFlags) -{ - TRACE("(%p)->(%p,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, lpNewRenderTarget, dwFlags); - return IDirect3DDevice7_SetRenderTarget(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface3, IDirectDrawSurface7, lpNewRenderTarget), - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(LPDIRECT3DDEVICE2 iface, - LPDIRECTDRAWSURFACE* lplpRenderTarget) -{ - HRESULT ret; - LPDIRECTDRAWSURFACE7 ret_val; - - TRACE("(%p)->(%p) thunking to IDirect3DDevice7 interface.\n", iface, lplpRenderTarget); - ret = IDirect3DDevice7_GetRenderTarget(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice7, iface), - &ret_val); - *lplpRenderTarget = (LPDIRECTDRAWSURFACE) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirectDrawSurface3, ret_val); - TRACE(" returning interface %p\n", *lplpRenderTarget); - return ret; -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_Vertex(LPDIRECT3DDEVICE2 iface, - LPVOID lpVertexType) -{ - TRACE("(%p)->(%p) thunking to IDirect3DDevice3 interface.\n", iface, lpVertexType); - return IDirect3DDevice3_Vertex(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - lpVertexType); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_Index(LPDIRECT3DDEVICE2 iface, - WORD wVertexIndex) -{ - TRACE("(%p)->(%04x) thunking to IDirect3DDevice3 interface.\n", iface, wVertexIndex); - return IDirect3DDevice3_Index(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - wVertexIndex); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_End(LPDIRECT3DDEVICE2 iface, - DWORD dwFlags) -{ - TRACE("(%p)->(%08lx) thunking to IDirect3DDevice3 interface.\n", iface, dwFlags); - return IDirect3DDevice3_End(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetLightState(LPDIRECT3DDEVICE2 iface, - D3DLIGHTSTATETYPE dwLightStateType, - LPDWORD lpdwLightState) -{ - TRACE("(%p)->(%08x,%p) thunking to IDirect3DDevice3 interface.\n", iface, dwLightStateType, lpdwLightState); - return IDirect3DDevice3_GetLightState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - dwLightStateType, - lpdwLightState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetLightState(LPDIRECT3DDEVICE2 iface, - D3DLIGHTSTATETYPE dwLightStateType, - DWORD dwLightState) -{ - TRACE("(%p)->(%08x,%08lx) thunking to IDirect3DDevice3 interface.\n", iface, dwLightStateType, dwLightState); - return IDirect3DDevice3_SetLightState(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, iface), - dwLightStateType, - dwLightState); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(LPDIRECT3DDEVICE iface, - LPD3DENUMTEXTUREFORMATSCALLBACK lpD3DEnumTextureProc, - LPVOID lpArg) -{ - TRACE("(%p)->(%p,%p) thunking to IDirect3DDevice2 interface.\n", iface, lpD3DEnumTextureProc, lpArg); - return IDirect3DDevice2_EnumTextureFormats(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice2, iface), - lpD3DEnumTextureProc, - lpArg); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetTexture(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - LPDIRECT3DTEXTURE2 lpTexture2) -{ - TRACE("(%p)->(%ld,%p) thunking to IDirect3DDevice7 interface.\n", iface, dwStage, lpTexture2); - return IDirect3DDevice7_SetTexture(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dwStage, - COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirect3DTexture2, IDirectDrawSurface7, lpTexture2)); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - DWORD dwFlags) -{ - TRACE("(%p)->(%08x,%p,%08lx,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, - d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, dwFlags); - return IDirect3DDevice7_DrawPrimitiveVB(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - d3dptPrimitiveType, - COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, lpD3DVertexBuf), - dwStartVertex, - dwNumVertices, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER lpD3DVertexBuf, - LPWORD lpwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - TRACE("(%p)->(%08x,%p,%p,%08lx,%08lx) thunking to IDirect3DDevice7 interface.\n", iface, - d3dptPrimitiveType, lpD3DVertexBuf, lpwIndices, dwIndexCount, dwFlags); - return IDirect3DDevice7_DrawIndexedPrimitiveVB(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - d3dptPrimitiveType, - COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, lpD3DVertexBuf), - 0, - dwIndexCount, - lpwIndices, - dwIndexCount, - dwFlags); -} - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetTexture(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - LPDIRECT3DTEXTURE2* lplpTexture2) -{ - HRESULT ret; - LPDIRECTDRAWSURFACE7 ret_val; - - TRACE("(%p)->(%ld,%p) thunking to IDirect3DDevice7 interface.\n", iface, dwStage, lplpTexture2); - ret = IDirect3DDevice7_GetTexture(COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, iface), - dwStage, - &ret_val); - - *lplpTexture2 = COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, IDirectDrawSurface7, IDirect3DTexture2, ret_val); - - TRACE(" returning interface %p.\n", *lplpTexture2); - - return ret; -} diff -urN wine-20050524/dlls/ddraw/d3ddevice/main.h wine-20050628/dlls/ddraw/d3ddevice/main.h --- wine-20050524/dlls/ddraw/d3ddevice/main.h 2003-04-12 02:06:42.000000000 +0200 +++ wine-20050628/dlls/ddraw/d3ddevice/main.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,759 +0,0 @@ -/* - * Copyright 2002 Lionel Ulmer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* This is defined here so as to be able to put them in 'drivers' */ - -void InitDefaultStateBlock(STATEBLOCK* lpStateBlock, int version); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3DDEVICE7 iface, - REFIID riid, - LPVOID* obp); - -ULONG WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_AddRef(LPDIRECT3DDEVICE7 iface); - -ULONG WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetCaps(LPDIRECT3DDEVICE7 iface, - LPD3DDEVICEDESC7 lpD3DHELDevDesc); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_EnumTextureFormats(LPDIRECT3DDEVICE7 iface, - LPD3DENUMPIXELFORMATSCALLBACK lpD3DEnumPixelProc, - LPVOID lpArg); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_BeginScene(LPDIRECT3DDEVICE7 iface); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_EndScene(LPDIRECT3DDEVICE7 iface); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_1T_GetDirect3D(LPDIRECT3DDEVICE7 iface, - LPDIRECT3D7* lplpDirect3D3); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderTarget(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7 lpNewRenderTarget, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderTarget(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7* lplpRenderTarget); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_Clear(LPDIRECT3DDEVICE7 iface, - DWORD dwCount, - LPD3DRECT lpRects, - DWORD dwFlags, - D3DCOLOR dwColor, - D3DVALUE dvZ, - DWORD dwStencil); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetTransform(LPDIRECT3DDEVICE7 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform(LPDIRECT3DDEVICE7 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_SetViewport(LPDIRECT3DDEVICE7 iface, - LPD3DVIEWPORT7 lpData); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform(LPDIRECT3DDEVICE7 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetViewport(LPDIRECT3DDEVICE7 iface, - LPD3DVIEWPORT7 lpData); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_SetMaterial(LPDIRECT3DDEVICE7 iface, - LPD3DMATERIAL7 lpMat); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetMaterial(LPDIRECT3DDEVICE7 iface, - LPD3DMATERIAL7 lpMat); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_SetLight(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - LPD3DLIGHT7 lpLight); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetLight(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - LPD3DLIGHT7 lpLight); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderState(LPDIRECT3DDEVICE7 iface, - D3DRENDERSTATETYPE dwRenderStateType, - DWORD dwRenderState); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderState(LPDIRECT3DDEVICE7 iface, - D3DRENDERSTATETYPE dwRenderStateType, - LPDWORD lpdwRenderState); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_BeginStateBlock(LPDIRECT3DDEVICE7 iface); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_EndStateBlock(LPDIRECT3DDEVICE7 iface, - LPDWORD lpdwBlockHandle); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_PreLoad(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7 lpddsTexture); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawPrimitive(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitive(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_SetClipStatus(LPDIRECT3DDEVICE7 iface, - LPD3DCLIPSTATUS lpD3DClipStatus); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_2T_GetClipStatus(LPDIRECT3DDEVICE7 iface, - LPD3DCLIPSTATUS lpD3DClipStatus); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawPrimitiveStrided(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - LPWORD lpIndex, - DWORD dwIndexCount, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawPrimitiveVB(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - LPWORD lpwIndices, - DWORD dwIndexCount, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_ComputeSphereVisibility(LPDIRECT3DDEVICE7 iface, - LPD3DVECTOR lpCenters, - LPD3DVALUE lpRadii, - DWORD dwNumSpheres, - DWORD dwFlags, - LPDWORD lpdwReturnValues); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_GetTexture(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - LPDIRECTDRAWSURFACE7* lpTexture); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_SetTexture(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - LPDIRECTDRAWSURFACE7 lpTexture); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_GetTextureStageState(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - LPDWORD lpdwState); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_SetTextureStageState(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - DWORD dwState); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_3T_ValidateDevice(LPDIRECT3DDEVICE7 iface, - LPDWORD lpdwPasses); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_ApplyStateBlock(LPDIRECT3DDEVICE7 iface, - DWORD dwBlockHandle); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_CaptureStateBlock(LPDIRECT3DDEVICE7 iface, - DWORD dwBlockHandle); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_DeleteStateBlock(LPDIRECT3DDEVICE7 iface, - DWORD dwBlockHandle); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_CreateStateBlock(LPDIRECT3DDEVICE7 iface, - D3DSTATEBLOCKTYPE d3dsbType, - LPDWORD lpdwBlockHandle); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_Load(LPDIRECT3DDEVICE7 iface, - LPDIRECTDRAWSURFACE7 lpDestTex, - LPPOINT lpDestPoint, - LPDIRECTDRAWSURFACE7 lpSrcTex, - LPRECT lprcSrcRect, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_LightEnable(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - BOOL bEnable); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetLightEnable(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - BOOL* pbEnable); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_SetClipPlane(LPDIRECT3DDEVICE7 iface, - DWORD dwIndex, - D3DVALUE* pPlaneEquation); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetClipPlane(LPDIRECT3DDEVICE7 iface, - DWORD dwIndex, - D3DVALUE* pPlaneEquation); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_7_GetInfo(LPDIRECT3DDEVICE7 iface, - DWORD dwDevInfoID, - LPVOID pDevInfoStruct, - DWORD dwSize); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_GetCaps(LPDIRECT3DDEVICE3 iface, - LPD3DDEVICEDESC lpD3DHWDevDesc, - LPD3DDEVICEDESC lpD3DHELDevDesc); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_GetStats(LPDIRECT3DDEVICE3 iface, - LPD3DSTATS lpD3DStats); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_AddViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_DeleteViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_1T_NextViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3, - LPDIRECT3DVIEWPORT3* lplpDirect3DViewport3, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_SetCurrentViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3 lpDirect3DViewport3); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_GetCurrentViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT3* lplpDirect3DViewport3); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_Begin(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexTypeDesc, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_BeginIndexed(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwNumVertices, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_Vertex(LPDIRECT3DDEVICE3 iface, - LPVOID lpVertexType); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_Index(LPDIRECT3DDEVICE3 iface, - WORD wVertexIndex); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_End(LPDIRECT3DDEVICE3 iface, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_GetLightState(LPDIRECT3DDEVICE3 iface, - D3DLIGHTSTATETYPE dwLightStateType, - LPDWORD lpdwLightState); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface, - D3DLIGHTSTATETYPE dwLightStateType, - DWORD dwLightState); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_1T_SwapTextureHandles(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DTEXTURE2 lpD3DTex1, - LPDIRECT3DTEXTURE2 lpD3DTex2); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_1T_EnumTextureFormats(LPDIRECT3DDEVICE2 iface, - LPD3DENUMTEXTUREFORMATSCALLBACK lpD3DEnumTextureProc, - LPVOID lpArg); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_Begin(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dpt, - D3DVERTEXTYPE dwVertexTypeDesc, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_BeginIndexed(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwNumVertices, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_DrawPrimitive(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_Initialize(LPDIRECT3DDEVICE iface, - LPDIRECT3D lpDirect3D, - LPGUID lpGUID, - LPD3DDEVICEDESC lpD3DDVDesc); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_CreateExecuteBuffer(LPDIRECT3DDEVICE iface, - LPD3DEXECUTEBUFFERDESC lpDesc, - LPDIRECT3DEXECUTEBUFFER* lplpDirect3DExecuteBuffer, - IUnknown* pUnkOuter); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_Execute(LPDIRECT3DDEVICE iface, - LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, - LPDIRECT3DVIEWPORT lpDirect3DViewport, - DWORD dwFlags); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_Pick(LPDIRECT3DDEVICE iface, - LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, - LPDIRECT3DVIEWPORT lpDirect3DViewport, - DWORD dwFlags, - LPD3DRECT lpRect); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_GetPickRecords(LPDIRECT3DDEVICE iface, - LPDWORD lpCount, - LPD3DPICKRECORD lpD3DPickRec); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_CreateMatrix(LPDIRECT3DDEVICE iface, - LPD3DMATRIXHANDLE lpD3DMatHandle); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_SetMatrix(LPDIRECT3DDEVICE iface, - D3DMATRIXHANDLE D3DMatHandle, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_GetMatrix(LPDIRECT3DDEVICE iface, - D3DMATRIXHANDLE D3DMatHandle, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Main_IDirect3DDeviceImpl_1_DeleteMatrix(LPDIRECT3DDEVICE iface, - D3DMATRIXHANDLE D3DMatHandle); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_QueryInterface(LPDIRECT3DDEVICE3 iface, - REFIID riid, - LPVOID* obp); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_QueryInterface(LPDIRECT3DDEVICE2 iface, - REFIID riid, - LPVOID* obp); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_QueryInterface(LPDIRECT3DDEVICE iface, - REFIID riid, - LPVOID* obp); - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_3_AddRef(LPDIRECT3DDEVICE3 iface); - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_2_AddRef(LPDIRECT3DDEVICE2 iface); - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_1_AddRef(LPDIRECT3DDEVICE iface); - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_3_Release(LPDIRECT3DDEVICE3 iface); - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_2_Release(LPDIRECT3DDEVICE2 iface); - -ULONG WINAPI -Thunk_IDirect3DDeviceImpl_1_Release(LPDIRECT3DDEVICE iface); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_AddViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_AddViewport(LPDIRECT3DDEVICE iface, - LPDIRECT3DVIEWPORT lpDirect3DViewport); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_DeleteViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_DeleteViewport(LPDIRECT3DDEVICE iface, - LPDIRECT3DVIEWPORT lpDirect3DViewport); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_NextViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2, - LPDIRECT3DVIEWPORT2* lplpDirect3DViewport2, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_NextViewport(LPDIRECT3DDEVICE3 iface, - LPDIRECT3DVIEWPORT lpDirect3DViewport, - LPDIRECT3DVIEWPORT* lplpDirect3DViewport, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetDirect3D(LPDIRECT3DDEVICE3 iface, - LPDIRECT3D3* lplpDirect3D3); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetDirect3D(LPDIRECT3DDEVICE2 iface, - LPDIRECT3D2* lplpDirect3D2); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_GetDirect3D(LPDIRECT3DDEVICE iface, - LPDIRECT3D* lplpDirect3D); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2 lpDirect3DViewport2); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport(LPDIRECT3DDEVICE2 iface, - LPDIRECT3DVIEWPORT2* lpDirect3DViewport2); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats(LPDIRECT3DDEVICE3 iface, - LPD3DENUMPIXELFORMATSCALLBACK lpD3DEnumPixelProc, - LPVOID lpArg); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_BeginScene(LPDIRECT3DDEVICE3 iface); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_BeginScene(LPDIRECT3DDEVICE2 iface); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_BeginScene(LPDIRECT3DDEVICE iface); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_EndScene(LPDIRECT3DDEVICE3 iface); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_EndScene(LPDIRECT3DDEVICE2 iface); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_EndScene(LPDIRECT3DDEVICE iface); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetTransform(LPDIRECT3DDEVICE3 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetTransform(LPDIRECT3DDEVICE2 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetTransform(LPDIRECT3DDEVICE3 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetTransform(LPDIRECT3DDEVICE2 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_MultiplyTransform(LPDIRECT3DDEVICE3 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_MultiplyTransform(LPDIRECT3DDEVICE2 iface, - D3DTRANSFORMSTATETYPE dtstTransformStateType, - LPD3DMATRIX lpD3DMatrix); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetRenderState(LPDIRECT3DDEVICE3 iface, - D3DRENDERSTATETYPE dwRenderStateType, - DWORD dwRenderState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetRenderState(LPDIRECT3DDEVICE2 iface, - D3DRENDERSTATETYPE dwRenderStateType, - DWORD dwRenderState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetRenderState(LPDIRECT3DDEVICE3 iface, - D3DRENDERSTATETYPE dwRenderStateType, - LPDWORD lpdwRenderState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetRenderState(LPDIRECT3DDEVICE2 iface, - D3DRENDERSTATETYPE dwRenderStateType, - LPDWORD lpdwRenderState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawPrimitive(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetClipStatus(LPDIRECT3DDEVICE3 iface, - LPD3DCLIPSTATUS lpD3DClipStatus); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetClipStatus(LPDIRECT3DDEVICE2 iface, - LPD3DCLIPSTATUS lpD3DClipStatus); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetClipStatus(LPDIRECT3DDEVICE3 iface, - LPD3DCLIPSTATUS lpD3DClipStatus); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetClipStatus(LPDIRECT3DDEVICE2 iface, - LPD3DCLIPSTATUS lpD3DClipStatus); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - LPWORD lpIndex, - DWORD dwIndexCount, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility(LPDIRECT3DDEVICE3 iface, - LPD3DVECTOR lpCenters, - LPD3DVALUE lpRadii, - DWORD dwNumSpheres, - DWORD dwFlags, - LPDWORD lpdwReturnValues); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetTextureStageState(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - LPDWORD lpdwState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetTextureStageState(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - DWORD dwState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_ValidateDevice(LPDIRECT3DDEVICE3 iface, - LPDWORD lpdwPasses); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetCaps(LPDIRECT3DDEVICE2 iface, - LPD3DDEVICEDESC lpD3DHWDevDesc, - LPD3DDEVICEDESC lpD3DHELDevDesc); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_GetCaps(LPDIRECT3DDEVICE iface, - LPD3DDEVICEDESC lpD3DHWDevDesc, - LPD3DDEVICEDESC lpD3DHELDevDesc); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles(LPDIRECT3DDEVICE iface, - LPDIRECT3DTEXTURE lpD3Dtex1, - LPDIRECT3DTEXTURE lpD3DTex2); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetStats(LPDIRECT3DDEVICE2 iface, - LPD3DSTATS lpD3DStats); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_GetStats(LPDIRECT3DDEVICE iface, - LPD3DSTATS lpD3DStats); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetRenderTarget(LPDIRECT3DDEVICE3 iface, - LPDIRECTDRAWSURFACE4 lpNewRenderTarget, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetRenderTarget(LPDIRECT3DDEVICE3 iface, - LPDIRECTDRAWSURFACE4* lplpRenderTarget); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetRenderTarget(LPDIRECT3DDEVICE2 iface, - LPDIRECTDRAWSURFACE lpNewRenderTarget, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetRenderTarget(LPDIRECT3DDEVICE2 iface, - LPDIRECTDRAWSURFACE* lplpRenderTarget); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_Vertex(LPDIRECT3DDEVICE2 iface, - LPVOID lpVertexType); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_Index(LPDIRECT3DDEVICE2 iface, - WORD wVertexIndex); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_End(LPDIRECT3DDEVICE2 iface, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_GetLightState(LPDIRECT3DDEVICE2 iface, - D3DLIGHTSTATETYPE dwLightStateType, - LPDWORD lpdwLightState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_2_SetLightState(LPDIRECT3DDEVICE2 iface, - D3DLIGHTSTATETYPE dwLightStateType, - DWORD dwLightState); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats(LPDIRECT3DDEVICE iface, - LPD3DENUMTEXTUREFORMATSCALLBACK lpD3DEnumTextureProc, - LPVOID lpArg); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_SetTexture(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - LPDIRECT3DTEXTURE2 lpTexture2); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE3 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER lpD3DVertexBuf, - LPWORD lpwIndices, - DWORD dwIndexCount, - DWORD dwFlags); - -HRESULT WINAPI -Thunk_IDirect3DDeviceImpl_3_GetTexture(LPDIRECT3DDEVICE3 iface, - DWORD dwStage, - LPDIRECT3DTEXTURE2* lplpTexture2); diff -urN wine-20050524/dlls/ddraw/d3ddevice/mesa.c wine-20050628/dlls/ddraw/d3ddevice/mesa.c --- wine-20050524/dlls/ddraw/d3ddevice/mesa.c 2005-04-11 14:51:22.000000000 +0200 +++ wine-20050628/dlls/ddraw/d3ddevice/mesa.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,4328 +0,0 @@ -/* Direct3D Device - * Copyright (c) 1998-2004 Lionel ULMER - * Copyright (c) 2002-2004 Christian Costa - * - * This file contains the MESA implementation of all the D3D devices that - * Wine supports. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" -#include "wine/port.h" - -#include -#include -#include - -#define NONAMELESSUNION -#define NONAMELESSSTRUCT -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "objbase.h" -#include "wingdi.h" -#include "ddraw.h" -#include "d3d.h" -#include "wine/debug.h" -#include "wine/library.h" - -#include "mesa_private.h" -#include "main.h" - -WINE_DEFAULT_DEBUG_CHANNEL(ddraw); -WINE_DECLARE_DEBUG_CHANNEL(ddraw_geom); - -/* x11drv GDI escapes */ -#define X11DRV_ESCAPE 6789 -enum x11drv_escape_codes -{ - X11DRV_GET_DISPLAY, /* get X11 display for a DC */ - X11DRV_GET_DRAWABLE, /* get current drawable for a DC */ - X11DRV_GET_FONT, /* get current X font for a DC */ -}; - -/* They are non-static as they are used by Direct3D in the creation function */ -const GUID IID_D3DDEVICE_OpenGL = { - 0x31416d44, - 0x86ae, - 0x11d2, - { 0x82,0x2d,0xa8,0xd5,0x31,0x87,0xca,0xfa } -}; - -const float id_mat[16] = { - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0 -}; - -/* This is filled at DLL loading time */ -static D3DDEVICEDESC7 opengl_device_caps; -GL_EXTENSIONS_LIST GL_extensions; - -static void draw_primitive_strided(IDirect3DDeviceImpl *This, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags) ; - -static DWORD draw_primitive_handle_textures(IDirect3DDeviceImpl *This); - -/* retrieve the X display to use on a given DC */ -inline static Display *get_display( HDC hdc ) -{ - Display *display; - enum x11drv_escape_codes escape = X11DRV_GET_DISPLAY; - - if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, - sizeof(display), (LPSTR)&display )) display = NULL; - - return display; -} - -#define UNLOCK_TEX_SIZE 256 - -#define DEPTH_RANGE_BIT (0x00000001 << 0) -#define VIEWPORT_BIT (0x00000001 << 1) - -static DWORD d3ddevice_set_state_for_flush(IDirect3DDeviceImpl *d3d_dev, LPCRECT pRect, BOOLEAN use_alpha, BOOLEAN *initial) { - IDirect3DDeviceGLImpl* gl_d3d_dev = (IDirect3DDeviceGLImpl*) d3d_dev; - DWORD opt_bitmap = 0x00000000; - - if ((gl_d3d_dev->current_bound_texture[1] != NULL) && - ((d3d_dev->state_block.texture_stage_state[1][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE))) { - if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE1_WINE) { - GL_extensions.glActiveTexture(GL_TEXTURE1_WINE); - gl_d3d_dev->current_active_tex_unit = GL_TEXTURE1_WINE; - } - /* Disable multi-texturing for level 1 to disable all others */ - glDisable(GL_TEXTURE_2D); - } - if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE0_WINE) { - GL_extensions.glActiveTexture(GL_TEXTURE0_WINE); - gl_d3d_dev->current_active_tex_unit = GL_TEXTURE0_WINE; - } - if ((gl_d3d_dev->current_bound_texture[0] == NULL) || - (d3d_dev->state_block.texture_stage_state[0][D3DTSS_COLOROP - 1] == D3DTOP_DISABLE)) - glEnable(GL_TEXTURE_2D); - if (gl_d3d_dev->unlock_tex == 0) { - glGenTextures(1, &gl_d3d_dev->unlock_tex); - glBindTexture(GL_TEXTURE_2D, gl_d3d_dev->unlock_tex); - *initial = TRUE; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - } else { - glBindTexture(GL_TEXTURE_2D, gl_d3d_dev->unlock_tex); - *initial = FALSE; - } - if (d3d_dev->tex_mat_is_identity[0] == FALSE) { - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - } - - if (gl_d3d_dev->transform_state != GL_TRANSFORM_ORTHO) { - gl_d3d_dev->transform_state = GL_TRANSFORM_ORTHO; - d3ddevice_set_ortho(d3d_dev); - } - - if (gl_d3d_dev->depth_test != FALSE) glDisable(GL_DEPTH_TEST); - glEnable(GL_SCISSOR_TEST); - if ((d3d_dev->active_viewport.dvMinZ != 0.0) || - (d3d_dev->active_viewport.dvMaxZ != 1.0)) { - glDepthRange(0.0, 1.0); - opt_bitmap |= DEPTH_RANGE_BIT; - } - if ((d3d_dev->active_viewport.dwX != 0) || - (d3d_dev->active_viewport.dwY != 0) || - (d3d_dev->active_viewport.dwWidth != d3d_dev->surface->surface_desc.dwWidth) || - (d3d_dev->active_viewport.dwHeight != d3d_dev->surface->surface_desc.dwHeight)) { - glViewport(0, 0, d3d_dev->surface->surface_desc.dwWidth, d3d_dev->surface->surface_desc.dwHeight); - opt_bitmap |= VIEWPORT_BIT; - } - glScissor(pRect->left, d3d_dev->surface->surface_desc.dwHeight - pRect->bottom, - pRect->right - pRect->left, pRect->bottom - pRect->top); - if (gl_d3d_dev->lighting != FALSE) glDisable(GL_LIGHTING); - if (gl_d3d_dev->cull_face != FALSE) glDisable(GL_CULL_FACE); - if (use_alpha) { - if (gl_d3d_dev->alpha_test == FALSE) glEnable(GL_ALPHA_TEST); - if ((gl_d3d_dev->current_alpha_test_func != GL_NOTEQUAL) || (gl_d3d_dev->current_alpha_test_ref != 0.0)) - glAlphaFunc(GL_NOTEQUAL, 0.0); - } else { - if (gl_d3d_dev->alpha_test != FALSE) glDisable(GL_ALPHA_TEST); - } - if (gl_d3d_dev->stencil_test != FALSE) glDisable(GL_STENCIL_TEST); - if (gl_d3d_dev->blending != FALSE) glDisable(GL_BLEND); - if (gl_d3d_dev->fogging != FALSE) glDisable(GL_FOG); - if (gl_d3d_dev->current_tex_env != GL_REPLACE) - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - return opt_bitmap; -} - -static void d3ddevice_restore_state_after_flush(IDirect3DDeviceImpl *d3d_dev, DWORD opt_bitmap, BOOLEAN use_alpha) { - IDirect3DDeviceGLImpl* gl_d3d_dev = (IDirect3DDeviceGLImpl*) d3d_dev; - - /* And restore all the various states modified by this code */ - if (gl_d3d_dev->depth_test != 0) glEnable(GL_DEPTH_TEST); - if (gl_d3d_dev->lighting != 0) glEnable(GL_LIGHTING); - if ((gl_d3d_dev->alpha_test != 0) && (use_alpha == 0)) - glEnable(GL_ALPHA_TEST); - else if ((gl_d3d_dev->alpha_test == 0) && (use_alpha != 0)) - glDisable(GL_ALPHA_TEST); - if (use_alpha) { - if ((gl_d3d_dev->current_alpha_test_func != GL_NOTEQUAL) || (gl_d3d_dev->current_alpha_test_ref != 0.0)) - glAlphaFunc(gl_d3d_dev->current_alpha_test_func, gl_d3d_dev->current_alpha_test_ref); - } - if (gl_d3d_dev->stencil_test != 0) glEnable(GL_STENCIL_TEST); - if (gl_d3d_dev->cull_face != 0) glEnable(GL_CULL_FACE); - if (gl_d3d_dev->blending != 0) glEnable(GL_BLEND); - if (gl_d3d_dev->fogging != 0) glEnable(GL_FOG); - glDisable(GL_SCISSOR_TEST); - if (opt_bitmap & DEPTH_RANGE_BIT) { - glDepthRange(d3d_dev->active_viewport.dvMinZ, d3d_dev->active_viewport.dvMaxZ); - } - if (opt_bitmap & VIEWPORT_BIT) { - glViewport(d3d_dev->active_viewport.dwX, - d3d_dev->surface->surface_desc.dwHeight - (d3d_dev->active_viewport.dwHeight + d3d_dev->active_viewport.dwY), - d3d_dev->active_viewport.dwWidth, d3d_dev->active_viewport.dwHeight); - } - if (d3d_dev->tex_mat_is_identity[0] == FALSE) { - d3d_dev->matrices_updated(d3d_dev, TEXMAT0_CHANGED); - } - - if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE0_WINE) { - GL_extensions.glActiveTexture(GL_TEXTURE0_WINE); - gl_d3d_dev->current_active_tex_unit = GL_TEXTURE0_WINE; - } - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, gl_d3d_dev->current_tex_env); - /* Note that here we could directly re-bind the previous texture... But it would in some case be a spurious - bind if ever the game changes the texture just after. - - So choose 0x00000001 to postpone the binding to the next time we draw something on screen. */ - gl_d3d_dev->current_bound_texture[0] = (IDirectDrawSurfaceImpl *) 0x00000001; - if (d3d_dev->state_block.texture_stage_state[0][D3DTSS_COLOROP - 1] == D3DTOP_DISABLE) glDisable(GL_TEXTURE_2D); - - /* And re-enabled if needed texture level 1 */ - if ((gl_d3d_dev->current_bound_texture[1] != NULL) && - (d3d_dev->state_block.texture_stage_state[1][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE)) { - if (gl_d3d_dev->current_active_tex_unit != GL_TEXTURE1_WINE) { - GL_extensions.glActiveTexture(GL_TEXTURE1_WINE); - gl_d3d_dev->current_active_tex_unit = GL_TEXTURE1_WINE; - } - glEnable(GL_TEXTURE_2D); - } -} - -/* retrieve the X drawable to use on a given DC */ -inline static Drawable get_drawable( HDC hdc ) -{ - Drawable drawable; - enum x11drv_escape_codes escape = X11DRV_GET_DRAWABLE; - - if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, - sizeof(drawable), (LPSTR)&drawable )) drawable = 0; - - return drawable; -} - -static BOOL opengl_flip( LPVOID dev, LPVOID drawable) -{ - IDirect3DDeviceImpl *d3d_dev = (IDirect3DDeviceImpl *) dev; - IDirect3DDeviceGLImpl *gl_d3d_dev = (IDirect3DDeviceGLImpl *) dev; - - TRACE("(%p, %ld)\n", gl_d3d_dev->display,(Drawable)drawable); - ENTER_GL(); - if (gl_d3d_dev->state[WINE_GL_BUFFER_BACK] == SURFACE_MEMORY_DIRTY) { - d3d_dev->flush_to_framebuffer(d3d_dev, &(gl_d3d_dev->lock_rect[WINE_GL_BUFFER_BACK]), gl_d3d_dev->lock_surf[WINE_GL_BUFFER_BACK]); - } - gl_d3d_dev->state[WINE_GL_BUFFER_BACK] = SURFACE_GL; - gl_d3d_dev->state[WINE_GL_BUFFER_FRONT] = SURFACE_GL; - glXSwapBuffers(gl_d3d_dev->display, (Drawable)drawable); - LEAVE_GL(); - - return TRUE; -} - - -/******************************************************************************* - * OpenGL static functions - */ -static void set_context(IDirect3DDeviceImpl* This) -{ - IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This; - - TRACE("glxMakeCurrent %p, %ld, %p\n",glThis->display,glThis->drawable, glThis->gl_context); - ENTER_GL(); - if (glXMakeCurrent(glThis->display, glThis->drawable, glThis->gl_context) == False) { - ERR("Error in setting current context (context %p drawable %ld)!\n", - glThis->gl_context, glThis->drawable); - } - LEAVE_GL(); -} - -static void fill_opengl_caps(D3DDEVICEDESC *d1) -{ - d1->dwSize = sizeof(*d1); - d1->dwFlags = D3DDD_COLORMODEL | D3DDD_DEVCAPS | D3DDD_TRANSFORMCAPS | D3DDD_BCLIPPING | D3DDD_LIGHTINGCAPS | - D3DDD_LINECAPS | D3DDD_TRICAPS | D3DDD_DEVICERENDERBITDEPTH | D3DDD_DEVICEZBUFFERBITDEPTH | - D3DDD_MAXBUFFERSIZE | D3DDD_MAXVERTEXCOUNT; - d1->dcmColorModel = D3DCOLOR_RGB; - d1->dwDevCaps = opengl_device_caps.dwDevCaps; - d1->dtcTransformCaps.dwSize = sizeof(D3DTRANSFORMCAPS); - d1->dtcTransformCaps.dwCaps = D3DTRANSFORMCAPS_CLIP; - d1->bClipping = TRUE; - d1->dlcLightingCaps.dwSize = sizeof(D3DLIGHTINGCAPS); - d1->dlcLightingCaps.dwCaps = D3DLIGHTCAPS_DIRECTIONAL | D3DLIGHTCAPS_PARALLELPOINT | D3DLIGHTCAPS_POINT | D3DLIGHTCAPS_SPOT; - d1->dlcLightingCaps.dwLightingModel = D3DLIGHTINGMODEL_RGB; - d1->dlcLightingCaps.dwNumLights = opengl_device_caps.dwMaxActiveLights; - d1->dpcLineCaps = opengl_device_caps.dpcLineCaps; - d1->dpcTriCaps = opengl_device_caps.dpcTriCaps; - d1->dwDeviceRenderBitDepth = opengl_device_caps.dwDeviceRenderBitDepth; - d1->dwDeviceZBufferBitDepth = opengl_device_caps.dwDeviceZBufferBitDepth; - d1->dwMaxBufferSize = 0; - d1->dwMaxVertexCount = 65536; - d1->dwMinTextureWidth = opengl_device_caps.dwMinTextureWidth; - d1->dwMinTextureHeight = opengl_device_caps.dwMinTextureHeight; - d1->dwMaxTextureWidth = opengl_device_caps.dwMaxTextureWidth; - d1->dwMaxTextureHeight = opengl_device_caps.dwMaxTextureHeight; - d1->dwMinStippleWidth = 1; - d1->dwMinStippleHeight = 1; - d1->dwMaxStippleWidth = 32; - d1->dwMaxStippleHeight = 32; - d1->dwMaxTextureRepeat = opengl_device_caps.dwMaxTextureRepeat; - d1->dwMaxTextureAspectRatio = opengl_device_caps.dwMaxTextureAspectRatio; - d1->dwMaxAnisotropy = opengl_device_caps.dwMaxAnisotropy; - d1->dvGuardBandLeft = opengl_device_caps.dvGuardBandLeft; - d1->dvGuardBandRight = opengl_device_caps.dvGuardBandRight; - d1->dvGuardBandTop = opengl_device_caps.dvGuardBandTop; - d1->dvGuardBandBottom = opengl_device_caps.dvGuardBandBottom; - d1->dvExtentsAdjust = opengl_device_caps.dvExtentsAdjust; - d1->dwStencilCaps = opengl_device_caps.dwStencilCaps; - d1->dwFVFCaps = opengl_device_caps.dwFVFCaps; - d1->dwTextureOpCaps = opengl_device_caps.dwTextureOpCaps; - d1->wMaxTextureBlendStages = opengl_device_caps.wMaxTextureBlendStages; - d1->wMaxSimultaneousTextures = opengl_device_caps.wMaxSimultaneousTextures; -} - -static void fill_opengl_caps_7(D3DDEVICEDESC7 *d) -{ - *d = opengl_device_caps; -} - -HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) -{ - D3DDEVICEDESC dref, d1, d2; - HRESULT ret_value; - - /* Some games (Motoracer 2 demo) have the bad idea to modify the device name string. - Let's put the string in a sufficiently sized array in writable memory. */ - char device_name[50]; - strcpy(device_name,"direct3d"); - - fill_opengl_caps(&dref); - - if (version > 1) { - /* It seems that enumerating the reference IID on Direct3D 1 games (AvP / Motoracer2) breaks them */ - char interface_name[] = "WINE Reference Direct3DX using OpenGL"; - TRACE(" enumerating OpenGL D3DDevice interface using reference IID (IID %s).\n", debugstr_guid(&IID_IDirect3DRefDevice)); - d1 = dref; - d2 = dref; - ret_value = cb((LPIID) &IID_IDirect3DRefDevice, interface_name, device_name, &d1, &d2, context); - if (ret_value != D3DENUMRET_OK) - return ret_value; - } - - { - char interface_name[] = "WINE Direct3DX using OpenGL"; - TRACE(" enumerating OpenGL D3DDevice interface (IID %s).\n", debugstr_guid(&IID_D3DDEVICE_OpenGL)); - d1 = dref; - d2 = dref; - ret_value = cb((LPIID) &IID_D3DDEVICE_OpenGL, interface_name, device_name, &d1, &d2, context); - if (ret_value != D3DENUMRET_OK) - return ret_value; - } - - return D3DENUMRET_OK; -} - -HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) -{ - D3DDEVICEDESC7 ddesc; - char interface_name[] = "WINE Direct3D7 using OpenGL"; - char device_name[] = "Wine D3D7 device"; - - fill_opengl_caps_7(&ddesc); - - TRACE(" enumerating OpenGL D3DDevice7 interface.\n"); - - return cb(interface_name, device_name, &ddesc, context); -} - -ULONG WINAPI -GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This; - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1); - - if (!ref) { - int i; - IDirectDrawSurfaceImpl *surface = This->surface, *surf; - - /* Release texture associated with the device */ - for (i = 0; i < MAX_TEXTURES; i++) { - if (This->current_texture[i] != NULL) - IDirectDrawSurface7_Release(ICOM_INTERFACE(This->current_texture[i], IDirectDrawSurface7)); - HeapFree(GetProcessHeap(), 0, This->tex_mat[i]); - } - - /* Look for the front buffer and override its surface's Flip method (if in double buffering) */ - for (surf = surface; surf != NULL; surf = surf->surface_owner) { - if ((surf->surface_desc.ddsCaps.dwCaps&(DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER)) == (DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER)) { - surf->aux_ctx = NULL; - surf->aux_data = NULL; - surf->aux_flip = NULL; - break; - } - } - for (surf = surface; surf != NULL; surf = surf->surface_owner) { - IDirectDrawSurfaceImpl *surf2; - for (surf2 = surf; surf2->prev_attached != NULL; surf2 = surf2->prev_attached) ; - for (; surf2 != NULL; surf2 = surf2->next_attached) { - if (((surf2->surface_desc.ddsCaps.dwCaps & (DDSCAPS_3DDEVICE)) == (DDSCAPS_3DDEVICE)) && - ((surf2->surface_desc.ddsCaps.dwCaps & (DDSCAPS_ZBUFFER)) != (DDSCAPS_ZBUFFER))) { - /* Override the Lock / Unlock function for all these surfaces */ - surf2->lock_update = surf2->lock_update_prev; - surf2->unlock_update = surf2->unlock_update_prev; - /* And install also the blt / bltfast overrides */ - surf2->aux_blt = NULL; - surf2->aux_bltfast = NULL; - } - surf2->d3ddevice = NULL; - } - } - - /* And warn the D3D object that this device is no longer active... */ - This->d3d->d3d_removed_device(This->d3d, This); - - HeapFree(GetProcessHeap(), 0, This->world_mat); - HeapFree(GetProcessHeap(), 0, This->view_mat); - HeapFree(GetProcessHeap(), 0, This->proj_mat); - - if (glThis->surface_ptr) - HeapFree(GetProcessHeap(), 0, glThis->surface_ptr); - - DeleteCriticalSection(&(This->crit)); - - ENTER_GL(); - if (glThis->unlock_tex) - glDeleteTextures(1, &(glThis->unlock_tex)); - glXDestroyContext(glThis->display, glThis->gl_context); - LEAVE_GL(); - HeapFree(GetProcessHeap(), 0, This->clipping_planes); - - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return ref; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_3_2T_1T_GetCaps(LPDIRECT3DDEVICE3 iface, - LPD3DDEVICEDESC lpD3DHWDevDesc, - LPD3DDEVICEDESC lpD3DHELDevDesc) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - D3DDEVICEDESC desc; - DWORD dwSize; - - TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DHWDevDesc, lpD3DHELDevDesc); - - fill_opengl_caps(&desc); - dwSize = lpD3DHWDevDesc->dwSize; - memset(lpD3DHWDevDesc, 0, dwSize); - memcpy(lpD3DHWDevDesc, &desc, (dwSize <= desc.dwSize ? dwSize : desc.dwSize)); - - dwSize = lpD3DHELDevDesc->dwSize; - memset(lpD3DHELDevDesc, 0, dwSize); - memcpy(lpD3DHELDevDesc, &desc, (dwSize <= desc.dwSize ? dwSize : desc.dwSize)); - - TRACE(" returning caps : (no dump function yet)\n"); - - return DD_OK; -} - -static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1, - LPD3DENUMPIXELFORMATSCALLBACK cb_2, - LPVOID context, int version) -{ - DDSURFACEDESC sdesc; - LPDDPIXELFORMAT pformat; - - /* Do the texture enumeration */ - sdesc.dwSize = sizeof(DDSURFACEDESC); - sdesc.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS; - sdesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE; - pformat = &(sdesc.ddpfPixelFormat); - pformat->dwSize = sizeof(DDPIXELFORMAT); - pformat->dwFourCC = 0; - - TRACE("Enumerating GL_RGBA unpacked (32)\n"); - pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; - pformat->u1.dwRGBBitCount = 32; - pformat->u2.dwRBitMask = 0x00FF0000; - pformat->u3.dwGBitMask = 0x0000FF00; - pformat->u4.dwBBitMask = 0x000000FF; - pformat->u5.dwRGBAlphaBitMask = 0xFF000000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating GL_RGB unpacked (32)\n"); - pformat->dwFlags = DDPF_RGB; - pformat->u1.dwRGBBitCount = 32; - pformat->u2.dwRBitMask = 0x00FF0000; - pformat->u3.dwGBitMask = 0x0000FF00; - pformat->u4.dwBBitMask = 0x000000FF; - pformat->u5.dwRGBAlphaBitMask = 0x00000000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating GL_RGB unpacked (24)\n"); - pformat->dwFlags = DDPF_RGB; - pformat->u1.dwRGBBitCount = 24; - pformat->u2.dwRBitMask = 0x00FF0000; - pformat->u3.dwGBitMask = 0x0000FF00; - pformat->u4.dwBBitMask = 0x000000FF; - pformat->u5.dwRGBAlphaBitMask = 0x00000000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - /* Note : even if this is an 'emulated' texture format, it needs to be first - as some dumb applications seem to rely on that. */ - TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_1_5_5_5 (ARGB) (16)\n"); - pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; - pformat->u1.dwRGBBitCount = 16; - pformat->u2.dwRBitMask = 0x00007C00; - pformat->u3.dwGBitMask = 0x000003E0; - pformat->u4.dwBBitMask = 0x0000001F; - pformat->u5.dwRGBAlphaBitMask = 0x00008000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (ARGB) (16)\n"); - pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; - pformat->u1.dwRGBBitCount = 16; - pformat->u2.dwRBitMask = 0x00000F00; - pformat->u3.dwGBitMask = 0x000000F0; - pformat->u4.dwBBitMask = 0x0000000F; - pformat->u5.dwRGBAlphaBitMask = 0x0000F000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating GL_RGB packed GL_UNSIGNED_SHORT_5_6_5 (16)\n"); - pformat->dwFlags = DDPF_RGB; - pformat->u1.dwRGBBitCount = 16; - pformat->u2.dwRBitMask = 0x0000F800; - pformat->u3.dwGBitMask = 0x000007E0; - pformat->u4.dwBBitMask = 0x0000001F; - pformat->u5.dwRGBAlphaBitMask = 0x00000000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating GL_RGB packed GL_UNSIGNED_SHORT_5_5_5 (16)\n"); - pformat->dwFlags = DDPF_RGB; - pformat->u1.dwRGBBitCount = 16; - pformat->u2.dwRBitMask = 0x00007C00; - pformat->u3.dwGBitMask = 0x000003E0; - pformat->u4.dwBBitMask = 0x0000001F; - pformat->u5.dwRGBAlphaBitMask = 0x00000000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - -#if 0 - /* This is a compromise : some games choose the first 16 bit texture format with alpha they - find enumerated, others the last one. And both want to have the ARGB one. - - So basically, forget our OpenGL roots and do not even enumerate our RGBA ones. - */ - /* See argument about the RGBA format for 'packed' texture formats */ - TRACE("Enumerating GL_RGBA unpacked (32)\n"); - pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; - pformat->u1.dwRGBBitCount = 32; - pformat->u2.dwRBitMask = 0xFF000000; - pformat->u3.dwGBitMask = 0x00FF0000; - pformat->u4.dwBBitMask = 0x0000FF00; - pformat->u5.dwRGBAlphaBitMask = 0x000000FF; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (16)\n"); - pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; - pformat->u1.dwRGBBitCount = 16; - pformat->u2.dwRBitMask = 0x0000F000; - pformat->u3.dwGBitMask = 0x00000F00; - pformat->u4.dwBBitMask = 0x000000F0; - pformat->u5.dwRGBAlphaBitMask = 0x0000000F; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_5_5_5_1 (16)\n"); - pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS; - pformat->u1.dwRGBBitCount = 16; - pformat->u2.dwRBitMask = 0x0000F800; - pformat->u3.dwGBitMask = 0x000007C0; - pformat->u4.dwBBitMask = 0x0000003E; - pformat->u5.dwRGBAlphaBitMask = 0x00000001; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; -#endif - - TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n"); - pformat->dwFlags = DDPF_RGB; - pformat->u1.dwRGBBitCount = 8; - pformat->u2.dwRBitMask = 0x000000E0; - pformat->u3.dwGBitMask = 0x0000001C; - pformat->u4.dwBBitMask = 0x00000003; - pformat->u5.dwRGBAlphaBitMask = 0x00000000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating Paletted (8)\n"); - pformat->dwFlags = DDPF_PALETTEINDEXED8; - pformat->u1.dwRGBBitCount = 8; - pformat->u2.dwRBitMask = 0x00000000; - pformat->u3.dwGBitMask = 0x00000000; - pformat->u4.dwBBitMask = 0x00000000; - pformat->u5.dwRGBAlphaBitMask = 0x00000000; - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - /* DXT textures only exist for devices created from IDirect3D3 and above */ - if ((version >= 3) && GL_extensions.s3tc_compressed_texture) { - TRACE("Enumerating DXT1\n"); - pformat->dwFlags = DDPF_FOURCC; - pformat->dwFourCC = MAKE_FOURCC('D','X','T','1'); - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating DXT3\n"); - pformat->dwFlags = DDPF_FOURCC; - pformat->dwFourCC = MAKE_FOURCC('D','X','T','3'); - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - - TRACE("Enumerating DXT5\n"); - pformat->dwFlags = DDPF_FOURCC; - pformat->dwFourCC = MAKE_FOURCC('D','X','T','5'); - if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK; - if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK; - } - - TRACE("End of enumeration\n"); - return DD_OK; -} - - -HRESULT -d3ddevice_find(IDirectDrawImpl *d3d, - LPD3DFINDDEVICESEARCH lpD3DDFS, - LPD3DFINDDEVICERESULT lplpD3DDevice) -{ - D3DDEVICEDESC desc; - - if ((lpD3DDFS->dwFlags & D3DFDS_COLORMODEL) && - (lpD3DDFS->dcmColorModel != D3DCOLOR_RGB)) { - TRACE(" trying to request a non-RGB D3D color model. Not supported.\n"); - return DDERR_INVALIDPARAMS; /* No real idea what to return here :-) */ - } - if (lpD3DDFS->dwFlags & D3DFDS_GUID) { - TRACE(" trying to match guid %s.\n", debugstr_guid(&(lpD3DDFS->guid))); - if ((IsEqualGUID(&IID_D3DDEVICE_OpenGL, &(lpD3DDFS->guid)) == 0) && - (IsEqualGUID(&IID_IDirect3DHALDevice, &(lpD3DDFS->guid)) == 0) && - (IsEqualGUID(&IID_IDirect3DRefDevice, &(lpD3DDFS->guid)) == 0)) { - TRACE(" no match for this GUID.\n"); - return DDERR_INVALIDPARAMS; - } - } - - /* Now return our own GUID */ - lplpD3DDevice->guid = IID_D3DDEVICE_OpenGL; - fill_opengl_caps(&desc); - lplpD3DDevice->ddHwDesc = desc; - lplpD3DDevice->ddSwDesc = desc; - - TRACE(" returning Wine's OpenGL device with (undumped) capabilities\n"); - - return D3D_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_2_1T_EnumTextureFormats(LPDIRECT3DDEVICE2 iface, - LPD3DENUMTEXTUREFORMATSCALLBACK lpD3DEnumTextureProc, - LPVOID lpArg) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DEnumTextureProc, lpArg); - return enum_texture_format_OpenGL(lpD3DEnumTextureProc, NULL, lpArg, This->version); -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_EnumTextureFormats(LPDIRECT3DDEVICE7 iface, - LPD3DENUMPIXELFORMATSCALLBACK lpD3DEnumPixelProc, - LPVOID lpArg) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DEnumPixelProc, lpArg); - return enum_texture_format_OpenGL(NULL, lpD3DEnumPixelProc, lpArg, This->version); -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_2T_SetRenderState(LPDIRECT3DDEVICE7 iface, - D3DRENDERSTATETYPE dwRenderStateType, - DWORD dwRenderState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08x,%08lx)\n", This, iface, dwRenderStateType, dwRenderState); - - /* Call the render state functions */ - store_render_state(This, dwRenderStateType, dwRenderState, &This->state_block); - set_render_state(This, dwRenderStateType, &This->state_block); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_2T_GetRenderState(LPDIRECT3DDEVICE7 iface, - D3DRENDERSTATETYPE dwRenderStateType, - LPDWORD lpdwRenderState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dwRenderStateType, lpdwRenderState); - - /* Call the render state functions */ - get_render_state(This, dwRenderStateType, lpdwRenderState, &This->state_block); - - TRACE(" - asked for rendering state : %s, returning value %08lx.\n", _get_renderstate(dwRenderStateType), *lpdwRenderState); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_3_2T_GetLightState(LPDIRECT3DDEVICE3 iface, - D3DLIGHTSTATETYPE dwLightStateType, - LPDWORD lpdwLightState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - - TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dwLightStateType, lpdwLightState); - - if (!dwLightStateType && (dwLightStateType > D3DLIGHTSTATE_COLORVERTEX)) { - TRACE("Unexpected Light State Type\n"); - return DDERR_INVALIDPARAMS; - } - - if (dwLightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */) { - *lpdwLightState = This->material; - } else if (dwLightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */) { - *lpdwLightState = D3DCOLOR_RGB; - } else { - D3DRENDERSTATETYPE rs; - switch (dwLightStateType) { - case D3DLIGHTSTATE_AMBIENT: /* 2 */ - rs = D3DRENDERSTATE_AMBIENT; - break; - case D3DLIGHTSTATE_FOGMODE: /* 4 */ - rs = D3DRENDERSTATE_FOGVERTEXMODE; - break; - case D3DLIGHTSTATE_FOGSTART: /* 5 */ - rs = D3DRENDERSTATE_FOGSTART; - break; - case D3DLIGHTSTATE_FOGEND: /* 6 */ - rs = D3DRENDERSTATE_FOGEND; - break; - case D3DLIGHTSTATE_FOGDENSITY: /* 7 */ - rs = D3DRENDERSTATE_FOGDENSITY; - break; - case D3DLIGHTSTATE_COLORVERTEX: /* 8 */ - rs = D3DRENDERSTATE_COLORVERTEX; - break; - default: - ERR("Unknown D3DLIGHTSTATETYPE %d.\n", dwLightStateType); - return DDERR_INVALIDPARAMS; - } - - IDirect3DDevice7_GetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7), - rs,lpdwLightState); - } - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_3_2T_SetLightState(LPDIRECT3DDEVICE3 iface, - D3DLIGHTSTATETYPE dwLightStateType, - DWORD dwLightState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface); - - TRACE("(%p/%p)->(%08x,%08lx)\n", This, iface, dwLightStateType, dwLightState); - - if (!dwLightStateType && (dwLightStateType > D3DLIGHTSTATE_COLORVERTEX)) { - TRACE("Unexpected Light State Type\n"); - return DDERR_INVALIDPARAMS; - } - - if (dwLightStateType == D3DLIGHTSTATE_MATERIAL /* 1 */) { - IDirect3DMaterialImpl *mat = (IDirect3DMaterialImpl *) dwLightState; - - if (mat != NULL) { - TRACE(" activating material %p.\n", mat); - mat->activate(mat); - } else { - FIXME(" D3DLIGHTSTATE_MATERIAL called with NULL material !!!\n"); - } - This->material = dwLightState; - } else if (dwLightStateType == D3DLIGHTSTATE_COLORMODEL /* 3 */) { - switch (dwLightState) { - case D3DCOLOR_MONO: - ERR("DDCOLOR_MONO should not happen!\n"); - break; - case D3DCOLOR_RGB: - /* We are already in this mode */ - TRACE("Setting color model to RGB (no-op).\n"); - break; - default: - ERR("Unknown color model!\n"); - return DDERR_INVALIDPARAMS; - } - } else { - D3DRENDERSTATETYPE rs; - switch (dwLightStateType) { - case D3DLIGHTSTATE_AMBIENT: /* 2 */ - rs = D3DRENDERSTATE_AMBIENT; - break; - case D3DLIGHTSTATE_FOGMODE: /* 4 */ - rs = D3DRENDERSTATE_FOGVERTEXMODE; - break; - case D3DLIGHTSTATE_FOGSTART: /* 5 */ - rs = D3DRENDERSTATE_FOGSTART; - break; - case D3DLIGHTSTATE_FOGEND: /* 6 */ - rs = D3DRENDERSTATE_FOGEND; - break; - case D3DLIGHTSTATE_FOGDENSITY: /* 7 */ - rs = D3DRENDERSTATE_FOGDENSITY; - break; - case D3DLIGHTSTATE_COLORVERTEX: /* 8 */ - rs = D3DRENDERSTATE_COLORVERTEX; - break; - default: - ERR("Unknown D3DLIGHTSTATETYPE %d.\n", dwLightStateType); - return DDERR_INVALIDPARAMS; - } - - IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(This, IDirect3DDevice7), - rs,dwLightState); - } - - return DD_OK; -} - -static GLenum convert_D3D_ptype_to_GL(D3DPRIMITIVETYPE d3dpt) -{ - switch (d3dpt) { - case D3DPT_POINTLIST: - TRACE(" primitive type is POINTS\n"); - return GL_POINTS; - - case D3DPT_LINELIST: - TRACE(" primitive type is LINES\n"); - return GL_LINES; - - case D3DPT_LINESTRIP: - TRACE(" primitive type is LINE_STRIP\n"); - return GL_LINE_STRIP; - - case D3DPT_TRIANGLELIST: - TRACE(" primitive type is TRIANGLES\n"); - return GL_TRIANGLES; - - case D3DPT_TRIANGLESTRIP: - TRACE(" primitive type is TRIANGLE_STRIP\n"); - return GL_TRIANGLE_STRIP; - - case D3DPT_TRIANGLEFAN: - TRACE(" primitive type is TRIANGLE_FAN\n"); - return GL_TRIANGLE_FAN; - - default: - FIXME("Unhandled primitive %08x\n", d3dpt); - return GL_POINTS; - } -} - -/* This function calculate the Z coordinate from Zproj */ -static float ZfromZproj(IDirect3DDeviceImpl *This, D3DVALUE Zproj) -{ - float a,b,c,d; - /* Assume that X = Y = 0 and W = 1 */ - a = This->proj_mat->_33; - b = This->proj_mat->_34; - c = This->proj_mat->_43; - d = This->proj_mat->_44; - /* We have in homogenous coordinates Z' = a * Z + c and W' = b * Z + d - * So in non homogenous coordinates we have Zproj = (a * Z + c) / (b * Z + d) - * And finally Z = (d * Zproj - c) / (a - b * Zproj) - */ - return (d*Zproj - c) / (a - b*Zproj); -} - -static void build_fog_table(BYTE *fog_table, DWORD fog_color) { - int i; - - TRACE(" rebuilding fog table (%06lx)...\n", fog_color & 0x00FFFFFF); - - for (i = 0; i < 3; i++) { - BYTE fog_color_component = (fog_color >> (8 * i)) & 0xFF; - DWORD elt; - for (elt = 0; elt < 0x10000; elt++) { - /* We apply the fog transformation and cache the result */ - DWORD fog_intensity = elt & 0xFF; - DWORD vertex_color = (elt >> 8) & 0xFF; - fog_table[(i * 0x10000) + elt] = ((fog_intensity * vertex_color) + ((0xFF - fog_intensity) * fog_color_component)) / 0xFF; - } - } -} - -static void draw_primitive_handle_GL_state(IDirect3DDeviceImpl *This, - BOOLEAN vertex_transformed, - BOOLEAN vertex_lit) { - IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This; - - /* Puts GL in the correct lighting / transformation mode */ - if ((vertex_transformed == FALSE) && - (glThis->transform_state != GL_TRANSFORM_NORMAL)) { - /* Need to put the correct transformation again if we go from Transformed - vertices to non-transformed ones. - */ - This->set_matrices(This, VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED, - This->world_mat, This->view_mat, This->proj_mat); - glThis->transform_state = GL_TRANSFORM_NORMAL; - - } else if (vertex_transformed && - (glThis->transform_state != GL_TRANSFORM_ORTHO)) { - /* Set our orthographic projection */ - if (glThis->transform_state != GL_TRANSFORM_ORTHO) { - glThis->transform_state = GL_TRANSFORM_ORTHO; - d3ddevice_set_ortho(This); - } - } - - /* TODO: optimize this to not always reset all the fog stuff on all DrawPrimitive call - if no fogging state change occurred */ - if (This->state_block.render_state[D3DRENDERSTATE_FOGENABLE - 1]) { - if (vertex_transformed) { - if (glThis->fogging != 0) { - glDisable(GL_FOG); - glThis->fogging = 0; - } - /* Now check if our fog_table still corresponds to the current vertex color. - Element '0x..00' is always the fog color as it corresponds to maximum fog intensity */ - if ((glThis->fog_table[0 * 0x10000 + 0x0000] != ((This->state_block.render_state[D3DRENDERSTATE_FOGCOLOR - 1] >> 0) & 0xFF)) || - (glThis->fog_table[1 * 0x10000 + 0x0000] != ((This->state_block.render_state[D3DRENDERSTATE_FOGCOLOR - 1] >> 8) & 0xFF)) || - (glThis->fog_table[2 * 0x10000 + 0x0000] != ((This->state_block.render_state[D3DRENDERSTATE_FOGCOLOR - 1] >> 16) & 0xFF))) { - /* We need to rebuild our fog table.... */ - build_fog_table(glThis->fog_table, This->state_block.render_state[D3DRENDERSTATE_FOGCOLOR - 1]); - } - } else { - if (This->state_block.render_state[D3DRENDERSTATE_FOGTABLEMODE - 1] != D3DFOG_NONE) { - switch (This->state_block.render_state[D3DRENDERSTATE_FOGTABLEMODE - 1]) { - case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); break; - case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); break; - case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); break; - } - if (vertex_lit == FALSE) { - glFogf(GL_FOG_START, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1]); - glFogf(GL_FOG_END, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1]); - } else { - /* Special case of 'pixel fog' */ - glFogf(GL_FOG_START, ZfromZproj(This, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1])); - glFogf(GL_FOG_END, ZfromZproj(This, *(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1])); - } - if (glThis->fogging == 0) { - glEnable(GL_FOG); - glThis->fogging = 1; - } - } else { - if (glThis->fogging != 0) { - glDisable(GL_FOG); - glThis->fogging = 0; - } - } - } - } else { - if (glThis->fogging != 0) { - glDisable(GL_FOG); - glThis->fogging = 0; - } - } - - /* Handle the 'no-normal' case */ - if ((vertex_lit == FALSE) && This->state_block.render_state[D3DRENDERSTATE_LIGHTING - 1]) { - if (glThis->lighting == 0) { - glEnable(GL_LIGHTING); - glThis->lighting = 1; - } - } else { - if (glThis->lighting != 0) { - glDisable(GL_LIGHTING); - glThis->lighting = 0; - } - } - - /* Handle the code for pre-vertex material properties */ - if (vertex_transformed == FALSE) { - if (This->state_block.render_state[D3DRENDERSTATE_LIGHTING - 1] && - This->state_block.render_state[D3DRENDERSTATE_COLORVERTEX - 1]) { - if ((This->state_block.render_state[D3DRENDERSTATE_DIFFUSEMATERIALSOURCE - 1] != D3DMCS_MATERIAL) || - (This->state_block.render_state[D3DRENDERSTATE_AMBIENTMATERIALSOURCE - 1] != D3DMCS_MATERIAL) || - (This->state_block.render_state[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE - 1] != D3DMCS_MATERIAL) || - (This->state_block.render_state[D3DRENDERSTATE_SPECULARMATERIALSOURCE - 1] != D3DMCS_MATERIAL)) { - glEnable(GL_COLOR_MATERIAL); - } - } - } -} - - -inline static void draw_primitive(IDirect3DDeviceImpl *This, DWORD maxvert, WORD *index, - D3DVERTEXTYPE d3dvt, D3DPRIMITIVETYPE d3dpt, void *lpvertex) -{ - D3DDRAWPRIMITIVESTRIDEDDATA strided; - - switch (d3dvt) { - case D3DVT_VERTEX: { - strided.position.lpvData = &((D3DVERTEX *) lpvertex)->u1.x; - strided.position.dwStride = sizeof(D3DVERTEX); - strided.normal.lpvData = &((D3DVERTEX *) lpvertex)->u4.nx; - strided.normal.dwStride = sizeof(D3DVERTEX); - strided.textureCoords[0].lpvData = &((D3DVERTEX *) lpvertex)->u7.tu; - strided.textureCoords[0].dwStride = sizeof(D3DVERTEX); - draw_primitive_strided(This, d3dpt, D3DFVF_VERTEX, &strided, 0 /* Unused */, index, maxvert, 0 /* Unused */); - } break; - - case D3DVT_LVERTEX: { - strided.position.lpvData = &((D3DLVERTEX *) lpvertex)->u1.x; - strided.position.dwStride = sizeof(D3DLVERTEX); - strided.diffuse.lpvData = &((D3DLVERTEX *) lpvertex)->u4.color; - strided.diffuse.dwStride = sizeof(D3DLVERTEX); - strided.specular.lpvData = &((D3DLVERTEX *) lpvertex)->u5.specular; - strided.specular.dwStride = sizeof(D3DLVERTEX); - strided.textureCoords[0].lpvData = &((D3DLVERTEX *) lpvertex)->u6.tu; - strided.textureCoords[0].dwStride = sizeof(D3DLVERTEX); - draw_primitive_strided(This, d3dpt, D3DFVF_LVERTEX, &strided, 0 /* Unused */, index, maxvert, 0 /* Unused */); - } break; - - case D3DVT_TLVERTEX: { - strided.position.lpvData = &((D3DTLVERTEX *) lpvertex)->u1.sx; - strided.position.dwStride = sizeof(D3DTLVERTEX); - strided.diffuse.lpvData = &((D3DTLVERTEX *) lpvertex)->u5.color; - strided.diffuse.dwStride = sizeof(D3DTLVERTEX); - strided.specular.lpvData = &((D3DTLVERTEX *) lpvertex)->u6.specular; - strided.specular.dwStride = sizeof(D3DTLVERTEX); - strided.textureCoords[0].lpvData = &((D3DTLVERTEX *) lpvertex)->u7.tu; - strided.textureCoords[0].dwStride = sizeof(D3DTLVERTEX); - draw_primitive_strided(This, d3dpt, D3DFVF_TLVERTEX, &strided, 0 /* Unused */, index, maxvert, 0 /* Unused */); - } break; - - default: - FIXME("Unhandled vertex type %08x\n", d3dvt); - break; - } -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_2_DrawPrimitive(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - - TRACE("(%p/%p)->(%08x,%08x,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - - draw_primitive(This, dwVertexCount, NULL, d3dvtVertexType, d3dptPrimitiveType, lpvVertices); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_2_DrawIndexedPrimitive(LPDIRECT3DDEVICE2 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - D3DVERTEXTYPE d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice2, iface); - TRACE("(%p/%p)->(%08x,%08x,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - - draw_primitive(This, dwIndexCount, dwIndices, d3dvtVertexType, d3dptPrimitiveType, lpvVertices); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_1_CreateExecuteBuffer(LPDIRECT3DDEVICE iface, - LPD3DEXECUTEBUFFERDESC lpDesc, - LPDIRECT3DEXECUTEBUFFER* lplpDirect3DExecuteBuffer, - IUnknown* pUnkOuter) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice, iface); - IDirect3DExecuteBufferImpl *ret; - HRESULT ret_value; - - TRACE("(%p/%p)->(%p,%p,%p)\n", This, iface, lpDesc, lplpDirect3DExecuteBuffer, pUnkOuter); - - ret_value = d3dexecutebuffer_create(&ret, This->d3d, This, lpDesc); - *lplpDirect3DExecuteBuffer = ICOM_INTERFACE(ret, IDirect3DExecuteBuffer); - - TRACE(" returning %p.\n", *lplpDirect3DExecuteBuffer); - - return ret_value; -} - -static void flush_zbuffer_to_GL(IDirect3DDeviceImpl *d3d_dev, LPCRECT pRect, IDirectDrawSurfaceImpl *surf) { - static BOOLEAN first = TRUE; - IDirect3DDeviceGLImpl* gl_d3d_dev = (IDirect3DDeviceGLImpl*) d3d_dev; - unsigned int row; - GLenum type; - - if (first) { - MESSAGE("Warning : application does direct locking of ZBuffer - expect slowdowns on many GL implementations :-)\n"); - first = FALSE; - } - - TRACE("flushing ZBuffer back to GL\n"); - - if (gl_d3d_dev->transform_state != GL_TRANSFORM_ORTHO) { - gl_d3d_dev->transform_state = GL_TRANSFORM_ORTHO; - d3ddevice_set_ortho(d3d_dev); - } - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - if (gl_d3d_dev->depth_test == 0) glEnable(GL_DEPTH_TEST); - if (d3d_dev->state_block.render_state[D3DRENDERSTATE_ZFUNC - 1] != D3DCMP_ALWAYS) glDepthFunc(GL_ALWAYS); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - - /* This loop here is to prevent using PixelZoom that may be unoptimized for the 1.0 / -1.0 case - in some drivers... - */ - switch (surf->surface_desc.u4.ddpfPixelFormat.u1.dwZBufferBitDepth) { - case 16: type = GL_UNSIGNED_SHORT; break; - case 32: type = GL_UNSIGNED_INT; break; - default: FIXME("Unhandled ZBuffer format !\n"); goto restore_state; - } - - for (row = 0; row < surf->surface_desc.dwHeight; row++) { - /* glRasterPos3d(0.0, row + 1.0, 0.5); */ - glRasterPos2i(0, row + 1); - glDrawPixels(surf->surface_desc.dwWidth, 1, GL_DEPTH_COMPONENT, type, - ((unsigned char *) surf->surface_desc.lpSurface) + (row * surf->surface_desc.u1.lPitch)); - } - - restore_state: - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - if (d3d_dev->state_block.render_state[D3DRENDERSTATE_ZFUNC - 1] != D3DCMP_ALWAYS) - glDepthFunc(convert_D3D_compare_to_GL(d3d_dev->state_block.render_state[D3DRENDERSTATE_ZFUNC - 1])); - if (gl_d3d_dev->depth_test == 0) glDisable(GL_DEPTH_TEST); -} - -/* These are the various handler used in the generic path */ -inline static void handle_xyz(D3DVALUE *coords) { - glVertex3fv(coords); -} -inline static void handle_xyzrhw(D3DVALUE *coords) { - if ((coords[3] < 1e-8) && (coords[3] > -1e-8)) - glVertex3fv(coords); - else { - GLfloat w = 1.0 / coords[3]; - - glVertex4f(coords[0] * w, - coords[1] * w, - coords[2] * w, - w); - } -} -inline static void handle_normal(D3DVALUE *coords) { - glNormal3fv(coords); -} - -inline static void handle_diffuse_base(STATEBLOCK *sb, DWORD *color) { - if (sb->render_state[D3DRENDERSTATE_ALPHATESTENABLE - 1] || - sb->render_state[D3DRENDERSTATE_ALPHABLENDENABLE - 1]) { - glColor4ub((*color >> 16) & 0xFF, - (*color >> 8) & 0xFF, - (*color >> 0) & 0xFF, - (*color >> 24) & 0xFF); - } else { - glColor3ub((*color >> 16) & 0xFF, - (*color >> 8) & 0xFF, - (*color >> 0) & 0xFF); - } -} - -inline static void handle_specular_base(STATEBLOCK *sb, DWORD *color) { - glColor4ub((*color >> 16) & 0xFF, - (*color >> 8) & 0xFF, - (*color >> 0) & 0xFF, - (*color >> 24) & 0xFF); /* No idea if the alpha field is really used.. */ -} - -inline static void handle_diffuse(STATEBLOCK *sb, DWORD *color, BOOLEAN lighted) { - if ((lighted == FALSE) && - sb->render_state[D3DRENDERSTATE_LIGHTING - 1] && - sb->render_state[D3DRENDERSTATE_COLORVERTEX - 1]) { - if (sb->render_state[D3DRENDERSTATE_DIFFUSEMATERIALSOURCE - 1] == D3DMCS_COLOR1) { - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - handle_diffuse_base(sb, color); - } - if (sb->render_state[D3DRENDERSTATE_AMBIENTMATERIALSOURCE - 1] == D3DMCS_COLOR1) { - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); - handle_diffuse_base(sb, color); - } - if ((sb->render_state[D3DRENDERSTATE_SPECULARMATERIALSOURCE - 1] == D3DMCS_COLOR1) && - sb->render_state[D3DRENDERSTATE_SPECULARENABLE - 1]) { - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - handle_diffuse_base(sb, color); - } - if (sb->render_state[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE - 1] == D3DMCS_COLOR1) { - glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); - handle_diffuse_base(sb, color); - } - } else { - handle_diffuse_base(sb, color); - } -} - -inline static void handle_specular(STATEBLOCK *sb, DWORD *color, BOOLEAN lighted) { - if ((lighted == FALSE) && - sb->render_state[D3DRENDERSTATE_LIGHTING - 1] && - sb->render_state[D3DRENDERSTATE_COLORVERTEX - 1]) { - if (sb->render_state[D3DRENDERSTATE_DIFFUSEMATERIALSOURCE - 1] == D3DMCS_COLOR2) { - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - handle_specular_base(sb, color); - } - if (sb->render_state[D3DRENDERSTATE_AMBIENTMATERIALSOURCE - 1] == D3DMCS_COLOR2) { - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); - handle_specular_base(sb, color); - } - if ((sb->render_state[D3DRENDERSTATE_SPECULARMATERIALSOURCE - 1] == D3DMCS_COLOR2) && - sb->render_state[D3DRENDERSTATE_SPECULARENABLE - 1]) { - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - handle_specular_base(sb, color); - } - if (sb->render_state[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE - 1] == D3DMCS_COLOR2) { - glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); - handle_specular_base(sb, color); - } - } - /* No else here as we do not know how to handle 'specular' on its own in any case.. */ -} - -inline static void handle_diffuse_and_specular(STATEBLOCK *sb, BYTE *fog_table, DWORD *color_d, DWORD *color_s, BOOLEAN lighted) { - if (lighted) { - DWORD color = *color_d; - if (sb->render_state[D3DRENDERSTATE_FOGENABLE - 1]) { - /* Special case where the specular value is used to do fogging */ - BYTE fog_intensity = *color_s >> 24; /* The alpha value of the specular component is the fog 'intensity' for this vertex */ - color &= 0xFF000000; /* Only keep the alpha component */ - color |= fog_table[((*color_d >> 0) & 0xFF) << 8 | fog_intensity] << 0; - color |= fog_table[((*color_d >> 8) & 0xFF) << 8 | fog_intensity] << 8; - color |= fog_table[((*color_d >> 16) & 0xFF) << 8 | fog_intensity] << 16; - } - if (sb->render_state[D3DRENDERSTATE_SPECULARENABLE - 1]) { - /* Standard specular value in transformed mode. TODO */ - } - handle_diffuse_base(sb, &color); - } else { - if (sb->render_state[D3DRENDERSTATE_LIGHTING - 1]) { - handle_diffuse(sb, color_d, FALSE); - handle_specular(sb, color_s, FALSE); - } else { - /* In that case, only put the diffuse color... */ - handle_diffuse_base(sb, color_d); - } - } -} - -inline static void handle_texture(D3DVALUE *coords) { - glTexCoord2fv(coords); -} -inline static void handle_textures(const D3DVALUE *coords, int tex_stage) { - if (GL_extensions.glMultiTexCoord2fv) { - GL_extensions.glMultiTexCoord2fv(GL_TEXTURE0_WINE + tex_stage, coords); - } else { - if (tex_stage == 0) glTexCoord2fv(coords); - } -} - -static void draw_primitive_strided(IDirect3DDeviceImpl *This, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - BOOLEAN vertex_lighted = FALSE; - IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This; - int num_active_stages = 0; - int num_tex_index = ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); - - /* I put the trace before the various locks... So as to better understand where locks occur :-) */ - if (TRACE_ON(ddraw)) { - TRACE(" Vertex format : "); dump_flexible_vertex(d3dvtVertexType); - } - - /* This is to prevent 'thread contention' between a thread locking the device and another - doing 3D display on it... */ - EnterCriticalSection(&(This->crit)); - - ENTER_GL(); - if (glThis->state[WINE_GL_BUFFER_BACK] == SURFACE_MEMORY_DIRTY) { - This->flush_to_framebuffer(This, &(glThis->lock_rect[WINE_GL_BUFFER_BACK]), glThis->lock_surf[WINE_GL_BUFFER_BACK]); - } - glThis->state[WINE_GL_BUFFER_BACK] = SURFACE_GL; - - if (This->current_zbuffer == NULL) { - /* Search for an attached ZBuffer */ - static const DDSCAPS2 zbuf_caps = { DDSCAPS_ZBUFFER, 0, 0, 0 }; - LPDIRECTDRAWSURFACE7 zbuf; - HRESULT hr; - - hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(This->surface, IDirectDrawSurface7), - (DDSCAPS2 *) &zbuf_caps, &zbuf); - if (!FAILED(hr)) { - This->current_zbuffer = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, zbuf); - IDirectDrawSurface7_Release(zbuf); - } - } - if (This->current_zbuffer != NULL) { - if (This->current_zbuffer->get_dirty_status(This->current_zbuffer, NULL)) { - flush_zbuffer_to_GL(This, NULL, This->current_zbuffer); - } - } - - if ( ((d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) || - ((d3dvtVertexType & D3DFVF_NORMAL) == 0) ) - vertex_lighted = TRUE; - - /* Compute the number of active texture stages and set the various texture parameters */ - num_active_stages = draw_primitive_handle_textures(This); - - /* And restore to handle '0' in the case we use glTexCoord calls */ - if (glThis->current_active_tex_unit != GL_TEXTURE0_WINE) { - GL_extensions.glActiveTexture(GL_TEXTURE0_WINE); - glThis->current_active_tex_unit = GL_TEXTURE0_WINE; - } - - draw_primitive_handle_GL_state(This, - (d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ, - vertex_lighted); - - /* First, see if we can use the OpenGL vertex arrays... This is very limited - for now to some 'special' cases where we can do a direct mapping between D3D - types and GL types. - - Note: in the future all calls will go through vertex arrays but the arrays - will be generated by this function. - - Note2: colours cannot be mapped directly because they are stored as BGRA in memory - (ie not as an array of R, G, B, A as OpenGL does it but as a LWORD 0xAARRGGBB - which, as we are little indian, gives a B, G, R, A storage in memory. - */ - if (((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) && /* Standard XYZ vertices */ - ((d3dvtVertexType & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) == 0)) { - int tex_stage; - TRACE(" using GL vertex arrays for performance !\n"); - /* First, the vertices (we are sure we have some :-) */ - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, lpD3DDrawPrimStrideData->position.dwStride, lpD3DDrawPrimStrideData->position.lpvData); - /* Then the normals */ - if (d3dvtVertexType & D3DFVF_NORMAL) { - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, lpD3DDrawPrimStrideData->normal.dwStride, lpD3DDrawPrimStrideData->normal.lpvData); - } - /* Then the diffuse colour */ - if (d3dvtVertexType & D3DFVF_DIFFUSE) { - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(3, GL_UNSIGNED_BYTE, lpD3DDrawPrimStrideData->normal.dwStride, - ((char *) lpD3DDrawPrimStrideData->diffuse.lpvData)); - } - /* Then the various textures */ - for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) { - int tex_index = This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXCOORDINDEX - 1] & 0x0000FFFF; - if (tex_index >= num_tex_index) { - WARN("Default texture coordinate not handled in the vertex array path !!!\n"); - tex_index = num_tex_index - 1; - } - if (GL_extensions.glClientActiveTexture) { - GL_extensions.glClientActiveTexture(GL_TEXTURE0_WINE + tex_stage); - } - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2, GL_FLOAT, lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride, - lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData); - } - if (dwIndices != NULL) { - glDrawElements(convert_D3D_ptype_to_GL(d3dptPrimitiveType), dwIndexCount, GL_UNSIGNED_SHORT, dwIndices); - } else { - glDrawArrays(convert_D3D_ptype_to_GL(d3dptPrimitiveType), 0, dwIndexCount); - } - glDisableClientState(GL_VERTEX_ARRAY); - if (d3dvtVertexType & D3DFVF_NORMAL) { - glDisableClientState(GL_NORMAL_ARRAY); - } - if (d3dvtVertexType & D3DFVF_DIFFUSE) { - glDisableClientState(GL_COLOR_ARRAY); - } - for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) { - if (GL_extensions.glClientActiveTexture) { - GL_extensions.glClientActiveTexture(GL_TEXTURE0_WINE + tex_stage); - } - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - } else { - glBegin(convert_D3D_ptype_to_GL(d3dptPrimitiveType)); - - /* Some fast paths first before the generic case.... */ - if ((d3dvtVertexType == D3DFVF_VERTEX) && (num_active_stages <= 1)) { - unsigned int index; - - for (index = 0; index < dwIndexCount; index++) { - int i = (dwIndices == NULL) ? index : dwIndices[index]; - D3DVALUE *normal = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride); - D3DVALUE *tex_coord = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride); - D3DVALUE *position = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride); - - handle_normal(normal); - handle_texture(tex_coord); - handle_xyz(position); - - TRACE_(ddraw_geom)(" %f %f %f / %f %f %f (%f %f)\n", - position[0], position[1], position[2], - normal[0], normal[1], normal[2], - tex_coord[0], tex_coord[1]); - } - } else if ((d3dvtVertexType == D3DFVF_TLVERTEX) && (num_active_stages <= 1)) { - unsigned int index; - - for (index = 0; index < dwIndexCount; index++) { - int i = (dwIndices == NULL) ? index : dwIndices[index]; - DWORD *color_d = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride); - DWORD *color_s = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride); - D3DVALUE *tex_coord = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride); - D3DVALUE *position = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride); - - handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, TRUE); - handle_texture(tex_coord); - handle_xyzrhw(position); - - TRACE_(ddraw_geom)(" %f %f %f %f / %02lx %02lx %02lx %02lx - %02lx %02lx %02lx %02lx (%f %f)\n", - position[0], position[1], position[2], position[3], - (*color_d >> 16) & 0xFF, - (*color_d >> 8) & 0xFF, - (*color_d >> 0) & 0xFF, - (*color_d >> 24) & 0xFF, - (*color_s >> 16) & 0xFF, - (*color_s >> 8) & 0xFF, - (*color_s >> 0) & 0xFF, - (*color_s >> 24) & 0xFF, - tex_coord[0], tex_coord[1]); - } - } else if (((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) || - ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)) { - /* This is the 'slow path' but that should support all possible vertex formats out there... - Note that people should write a fast path for all vertex formats out there... - */ - unsigned int index; - static const D3DVALUE no_index[] = { 0.0, 0.0, 0.0, 0.0 }; - - for (index = 0; index < dwIndexCount; index++) { - int i = (dwIndices == NULL) ? index : dwIndices[index]; - int tex_stage; - - if (d3dvtVertexType & D3DFVF_NORMAL) { - D3DVALUE *normal = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride); - handle_normal(normal); - } - if ((d3dvtVertexType & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) == (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) { - DWORD *color_d = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride); - DWORD *color_s = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride); - handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, vertex_lighted); - } else { - if (d3dvtVertexType & D3DFVF_SPECULAR) { - DWORD *color_s = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride); - handle_specular(&(This->state_block), color_s, vertex_lighted); - } else if (d3dvtVertexType & D3DFVF_DIFFUSE) { - DWORD *color_d = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride); - handle_diffuse(&(This->state_block), color_d, vertex_lighted); - } - } - - for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) { - int tex_index = This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXCOORDINDEX - 1] & 0x0000FFFF; - if (tex_index >= num_tex_index) { - handle_textures((const D3DVALUE *) no_index, tex_stage); - } else { - D3DVALUE *tex_coord = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) + - i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride); - handle_textures(tex_coord, tex_stage); - } - } - - if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) { - D3DVALUE *position = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride); - handle_xyz(position); - } else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) { - D3DVALUE *position = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride); - handle_xyzrhw(position); - } - - if (TRACE_ON(ddraw_geom)) { - unsigned int tex_index; - - if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) { - D3DVALUE *position = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride); - TRACE_(ddraw_geom)(" %f %f %f", position[0], position[1], position[2]); - } else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) { - D3DVALUE *position = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride); - TRACE_(ddraw_geom)(" %f %f %f %f", position[0], position[1], position[2], position[3]); - } - if (d3dvtVertexType & D3DFVF_NORMAL) { - D3DVALUE *normal = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride); - TRACE_(ddraw_geom)(" / %f %f %f", normal[0], normal[1], normal[2]); - } - if (d3dvtVertexType & D3DFVF_DIFFUSE) { - DWORD *color_d = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride); - TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx", - (*color_d >> 16) & 0xFF, - (*color_d >> 8) & 0xFF, - (*color_d >> 0) & 0xFF, - (*color_d >> 24) & 0xFF); - } - if (d3dvtVertexType & D3DFVF_SPECULAR) { - DWORD *color_s = - (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride); - TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx", - (*color_s >> 16) & 0xFF, - (*color_s >> 8) & 0xFF, - (*color_s >> 0) & 0xFF, - (*color_s >> 24) & 0xFF); - } - for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) { - D3DVALUE *tex_coord = - (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) + - i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride); - TRACE_(ddraw_geom)(" / %f %f", tex_coord[0], tex_coord[1]); - } - TRACE_(ddraw_geom)("\n"); - } - } - } else { - ERR(" matrix weighting not handled yet....\n"); - } - - glEnd(); - } - - /* Whatever the case, disable the color material stuff */ - glDisable(GL_COLOR_MATERIAL); - - LEAVE_GL(); - TRACE("End\n"); - - LeaveCriticalSection(&(This->crit)); -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_DrawPrimitive(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - D3DDRAWPRIMITIVESTRIDEDDATA strided; - - TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - - convert_FVF_to_strided_data(d3dvtVertexType, lpvVertices, &strided, 0); - draw_primitive_strided(This, d3dptPrimitiveType, d3dvtVertexType, &strided, dwVertexCount, NULL, dwVertexCount, dwFlags); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitive(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD d3dvtVertexType, - LPVOID lpvVertices, - DWORD dwVertexCount, - LPWORD dwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - D3DDRAWPRIMITIVESTRIDEDDATA strided; - - TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - - convert_FVF_to_strided_data(d3dvtVertexType, lpvVertices, &strided, 0); - draw_primitive_strided(This, d3dptPrimitiveType, d3dvtVertexType, &strided, dwVertexCount, dwIndices, dwIndexCount, dwFlags); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveStrided(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - - TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - draw_primitive_strided(This, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, NULL, dwVertexCount, dwFlags); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - DWORD dwVertexType, - LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData, - DWORD dwVertexCount, - LPWORD lpIndex, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - - TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, lpIndex, dwIndexCount, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - - draw_primitive_strided(This, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, lpIndex, dwIndexCount, dwFlags); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveVB(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - IDirect3DVertexBufferImpl *vb_impl = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, lpD3DVertexBuf); - D3DDRAWPRIMITIVESTRIDEDDATA strided; - - TRACE("(%p/%p)->(%08x,%p,%08lx,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - - if (vb_impl->processed) { - IDirect3DVertexBufferGLImpl *vb_glimp = (IDirect3DVertexBufferGLImpl *) vb_impl; - IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This; - - glThis->transform_state = GL_TRANSFORM_VERTEXBUFFER; - This->set_matrices(This, VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED, - &(vb_glimp->world_mat), &(vb_glimp->view_mat), &(vb_glimp->proj_mat)); - - convert_FVF_to_strided_data(vb_glimp->dwVertexTypeDesc, vb_glimp->vertices, &strided, dwStartVertex); - draw_primitive_strided(This, d3dptPrimitiveType, vb_glimp->dwVertexTypeDesc, &strided, dwNumVertices, NULL, dwNumVertices, dwFlags); - - } else { - convert_FVF_to_strided_data(vb_impl->desc.dwFVF, vb_impl->vertices, &strided, dwStartVertex); - draw_primitive_strided(This, d3dptPrimitiveType, vb_impl->desc.dwFVF, &strided, dwNumVertices, NULL, dwNumVertices, dwFlags); - } - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE7 iface, - D3DPRIMITIVETYPE d3dptPrimitiveType, - LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf, - DWORD dwStartVertex, - DWORD dwNumVertices, - LPWORD lpwIndices, - DWORD dwIndexCount, - DWORD dwFlags) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - IDirect3DVertexBufferImpl *vb_impl = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, lpD3DVertexBuf); - D3DDRAWPRIMITIVESTRIDEDDATA strided; - - TRACE("(%p/%p)->(%08x,%p,%08lx,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, lpwIndices, dwIndexCount, dwFlags); - if (TRACE_ON(ddraw)) { - TRACE(" - flags : "); dump_DPFLAGS(dwFlags); - } - - if (vb_impl->processed) { - IDirect3DVertexBufferGLImpl *vb_glimp = (IDirect3DVertexBufferGLImpl *) vb_impl; - IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This; - - glThis->transform_state = GL_TRANSFORM_VERTEXBUFFER; - This->set_matrices(This, VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED, - &(vb_glimp->world_mat), &(vb_glimp->view_mat), &(vb_glimp->proj_mat)); - - convert_FVF_to_strided_data(vb_glimp->dwVertexTypeDesc, vb_glimp->vertices, &strided, dwStartVertex); - draw_primitive_strided(This, d3dptPrimitiveType, vb_glimp->dwVertexTypeDesc, &strided, dwNumVertices, lpwIndices, dwIndexCount, dwFlags); - - } else { - convert_FVF_to_strided_data(vb_impl->desc.dwFVF, vb_impl->vertices, &strided, dwStartVertex); - draw_primitive_strided(This, d3dptPrimitiveType, vb_impl->desc.dwFVF, &strided, dwNumVertices, lpwIndices, dwIndexCount, dwFlags); - } - - return DD_OK; -} - -/* We need a static function for that to handle the 'special' case of 'SELECT_ARG2' */ -static BOOLEAN -handle_color_alpha_args(IDirect3DDeviceImpl *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, DWORD dwState, D3DTEXTUREOP tex_op) -{ - BOOLEAN is_complement = FALSE; - BOOLEAN is_alpha_replicate = FALSE; - BOOLEAN handled = TRUE; - GLenum src; - BOOLEAN is_color = ((d3dTexStageStateType == D3DTSS_COLORARG1) || (d3dTexStageStateType == D3DTSS_COLORARG2)); - int num; - - if (is_color) { - if (d3dTexStageStateType == D3DTSS_COLORARG1) num = 0; - else if (d3dTexStageStateType == D3DTSS_COLORARG2) num = 1; - else { - handled = FALSE; - num = 0; - } - if (tex_op == D3DTOP_SELECTARG2) { - num = 1 - num; - } - } else { - if (d3dTexStageStateType == D3DTSS_ALPHAARG1) num = 0; - else if (d3dTexStageStateType == D3DTSS_ALPHAARG2) num = 1; - else { - handled = FALSE; - num = 0; - } - if (tex_op == D3DTOP_SELECTARG2) { - num = 1 - num; - } - } - - if (dwState & D3DTA_COMPLEMENT) { - is_complement = TRUE; - } - if (dwState & D3DTA_ALPHAREPLICATE) { - is_alpha_replicate = TRUE; - } - dwState &= D3DTA_SELECTMASK; - if ((dwStage == 0) && (dwState == D3DTA_CURRENT)) { - dwState = D3DTA_DIFFUSE; - } - - switch (dwState) { - case D3DTA_CURRENT: src = GL_PREVIOUS_EXT; break; - case D3DTA_DIFFUSE: src = GL_PRIMARY_COLOR_EXT; break; - case D3DTA_TEXTURE: src = GL_TEXTURE; break; - case D3DTA_TFACTOR: { - /* Get the constant value from the current rendering state */ - GLfloat color[4]; - DWORD col = This->state_block.render_state[D3DRENDERSTATE_TEXTUREFACTOR - 1]; - - color[0] = ((col >> 16) & 0xFF) / 255.0f; - color[1] = ((col >> 8) & 0xFF) / 255.0f; - color[2] = ((col >> 0) & 0xFF) / 255.0f; - color[3] = ((col >> 24) & 0xFF) / 255.0f; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color); - - src = GL_CONSTANT_EXT; - } break; - default: src = GL_TEXTURE; handled = FALSE; break; - } - - if (is_color) { - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT + num, src); - if (is_alpha_replicate) { - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT + num, is_complement ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA); - } else { - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT + num, is_complement ? GL_ONE_MINUS_SRC_COLOR : GL_SRC_COLOR); - } - } else { - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT + num, src); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT + num, is_complement ? GL_ONE_MINUS_SRC_ALPHA : GL_SRC_ALPHA); - } - - return handled; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_SetTextureStageState(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - D3DTEXTURESTAGESTATETYPE d3dTexStageStateType, - DWORD dwState) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This; - const char *type; - DWORD prev_state; - GLenum unit; - - TRACE("(%p/%p)->(%08lx,%08x,%08lx)\n", This, iface, dwStage, d3dTexStageStateType, dwState); - - if (((GL_extensions.max_texture_units == 0) && (dwStage > 0)) || - ((GL_extensions.max_texture_units != 0) && (dwStage >= GL_extensions.max_texture_units))) { - return DD_OK; - } - - unit = GL_TEXTURE0_WINE + dwStage; - if (unit != glThis->current_active_tex_unit) { - GL_extensions.glActiveTexture(unit); - glThis->current_active_tex_unit = unit; - } - - switch (d3dTexStageStateType) { -#define GEN_CASE(a) case a: type = #a; break - GEN_CASE(D3DTSS_COLOROP); - GEN_CASE(D3DTSS_COLORARG1); - GEN_CASE(D3DTSS_COLORARG2); - GEN_CASE(D3DTSS_ALPHAOP); - GEN_CASE(D3DTSS_ALPHAARG1); - GEN_CASE(D3DTSS_ALPHAARG2); - GEN_CASE(D3DTSS_BUMPENVMAT00); - GEN_CASE(D3DTSS_BUMPENVMAT01); - GEN_CASE(D3DTSS_BUMPENVMAT10); - GEN_CASE(D3DTSS_BUMPENVMAT11); - GEN_CASE(D3DTSS_TEXCOORDINDEX); - GEN_CASE(D3DTSS_ADDRESS); - GEN_CASE(D3DTSS_ADDRESSU); - GEN_CASE(D3DTSS_ADDRESSV); - GEN_CASE(D3DTSS_BORDERCOLOR); - GEN_CASE(D3DTSS_MAGFILTER); - GEN_CASE(D3DTSS_MINFILTER); - GEN_CASE(D3DTSS_MIPFILTER); - GEN_CASE(D3DTSS_MIPMAPLODBIAS); - GEN_CASE(D3DTSS_MAXMIPLEVEL); - GEN_CASE(D3DTSS_MAXANISOTROPY); - GEN_CASE(D3DTSS_BUMPENVLSCALE); - GEN_CASE(D3DTSS_BUMPENVLOFFSET); - GEN_CASE(D3DTSS_TEXTURETRANSFORMFLAGS); -#undef GEN_CASE - default: type = "UNKNOWN"; - } - - /* Store the values in the state array */ - prev_state = This->state_block.texture_stage_state[dwStage][d3dTexStageStateType - 1]; - This->state_block.texture_stage_state[dwStage][d3dTexStageStateType - 1] = dwState; - /* Some special cases when one state modifies more than one... */ - if (d3dTexStageStateType == D3DTSS_ADDRESS) { - This->state_block.texture_stage_state[dwStage][D3DTSS_ADDRESSU - 1] = dwState; - This->state_block.texture_stage_state[dwStage][D3DTSS_ADDRESSV - 1] = dwState; - } - - ENTER_GL(); - - switch (d3dTexStageStateType) { - case D3DTSS_MINFILTER: - case D3DTSS_MIPFILTER: - if (TRACE_ON(ddraw)) { - if (d3dTexStageStateType == D3DTSS_MINFILTER) { - switch ((D3DTEXTUREMINFILTER) dwState) { - case D3DTFN_POINT: TRACE(" Stage type is : D3DTSS_MINFILTER => D3DTFN_POINT\n"); break; - case D3DTFN_LINEAR: TRACE(" Stage type is : D3DTSS_MINFILTER => D3DTFN_LINEAR\n"); break; - default: FIXME(" Unhandled stage type : D3DTSS_MINFILTER => %08lx\n", dwState); break; - } - } else { - switch ((D3DTEXTUREMIPFILTER) dwState) { - case D3DTFP_NONE: TRACE(" Stage type is : D3DTSS_MIPFILTER => D3DTFP_NONE\n"); break; - case D3DTFP_POINT: TRACE(" Stage type is : D3DTSS_MIPFILTER => D3DTFP_POINT\n"); break; - case D3DTFP_LINEAR: TRACE(" Stage type is : D3DTSS_MIPFILTER => D3DTFP_LINEAR\n"); break; - default: FIXME(" Unhandled stage type : D3DTSS_MIPFILTER => %08lx\n", dwState); break; - } - } - } - break; - - case D3DTSS_MAGFILTER: - if (TRACE_ON(ddraw)) { - switch ((D3DTEXTUREMAGFILTER) dwState) { - case D3DTFG_POINT: TRACE(" Stage type is : D3DTSS_MAGFILTER => D3DTFG_POINT\n"); break; - case D3DTFG_LINEAR: TRACE(" Stage type is : D3DTSS_MAGFILTER => D3DTFG_LINEAR\n"); break; - default: FIXME(" Unhandled stage type : D3DTSS_MAGFILTER => %08lx\n", dwState); break; - } - } - break; - - case D3DTSS_ADDRESS: - case D3DTSS_ADDRESSU: - case D3DTSS_ADDRESSV: { - switch ((D3DTEXTUREADDRESS) dwState) { - case D3DTADDRESS_WRAP: TRACE(" Stage type is : %s => D3DTADDRESS_WRAP\n", type); break; - case D3DTADDRESS_CLAMP: TRACE(" Stage type is : %s => D3DTADDRESS_CLAMP\n", type); break; - case D3DTADDRESS_BORDER: TRACE(" Stage type is : %s => D3DTADDRESS_BORDER\n", type); break; - case D3DTADDRESS_MIRROR: - if (GL_extensions.mirrored_repeat) { - TRACE(" Stage type is : %s => D3DTADDRESS_MIRROR\n", type); - } else { - FIXME(" Stage type is : %s => D3DTADDRESS_MIRROR - not supported by GL !\n", type); - } - break; - default: FIXME(" Unhandled stage type : %s => %08lx\n", type, dwState); break; - } - } break; - - case D3DTSS_ALPHAOP: - case D3DTSS_COLOROP: { - int scale = 1; - GLenum parm = (d3dTexStageStateType == D3DTSS_ALPHAOP) ? GL_COMBINE_ALPHA_EXT : GL_COMBINE_RGB_EXT; - const char *value; - int handled = 1; - - switch (dwState) { -#define GEN_CASE(a) case a: value = #a; break - GEN_CASE(D3DTOP_DISABLE); - GEN_CASE(D3DTOP_SELECTARG1); - GEN_CASE(D3DTOP_SELECTARG2); - GEN_CASE(D3DTOP_MODULATE); - GEN_CASE(D3DTOP_MODULATE2X); - GEN_CASE(D3DTOP_MODULATE4X); - GEN_CASE(D3DTOP_ADD); - GEN_CASE(D3DTOP_ADDSIGNED); - GEN_CASE(D3DTOP_ADDSIGNED2X); - GEN_CASE(D3DTOP_SUBTRACT); - GEN_CASE(D3DTOP_ADDSMOOTH); - GEN_CASE(D3DTOP_BLENDDIFFUSEALPHA); - GEN_CASE(D3DTOP_BLENDTEXTUREALPHA); - GEN_CASE(D3DTOP_BLENDFACTORALPHA); - GEN_CASE(D3DTOP_BLENDTEXTUREALPHAPM); - GEN_CASE(D3DTOP_BLENDCURRENTALPHA); - GEN_CASE(D3DTOP_PREMODULATE); - GEN_CASE(D3DTOP_MODULATEALPHA_ADDCOLOR); - GEN_CASE(D3DTOP_MODULATECOLOR_ADDALPHA); - GEN_CASE(D3DTOP_MODULATEINVALPHA_ADDCOLOR); - GEN_CASE(D3DTOP_MODULATEINVCOLOR_ADDALPHA); - GEN_CASE(D3DTOP_BUMPENVMAP); - GEN_CASE(D3DTOP_BUMPENVMAPLUMINANCE); - GEN_CASE(D3DTOP_DOTPRODUCT3); - GEN_CASE(D3DTOP_FORCE_DWORD); -#undef GEN_CASE - default: value = "UNKNOWN"; - } - - if ((d3dTexStageStateType == D3DTSS_COLOROP) && (dwState == D3DTOP_DISABLE)) { - glDisable(GL_TEXTURE_2D); - TRACE(" disabling 2D texturing.\n"); - } else { - /* Re-enable texturing only if COLOROP was not already disabled... */ - if ((glThis->current_bound_texture[dwStage] != NULL) && - (This->state_block.texture_stage_state[dwStage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE)) { - glEnable(GL_TEXTURE_2D); - TRACE(" enabling 2D texturing.\n"); - } - - /* Re-Enable GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT */ - if ((dwState != D3DTOP_DISABLE) && - (This->state_block.texture_stage_state[dwStage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE)) { - if (glThis->current_tex_env != GL_COMBINE_EXT) { - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); - glThis->current_tex_env = GL_COMBINE_EXT; - } - } - - /* Now set up the operand correctly */ - switch (dwState) { - case D3DTOP_DISABLE: - /* Contrary to the docs, alpha can be disabled when colorop is enabled - and it works, so ignore this op */ - TRACE(" Note : disable ALPHAOP but COLOROP enabled!\n"); - break; - - case D3DTOP_SELECTARG1: - case D3DTOP_SELECTARG2: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_REPLACE); - break; - - case D3DTOP_MODULATE4X: - scale = scale * 2; /* Drop through */ - case D3DTOP_MODULATE2X: - scale = scale * 2; /* Drop through */ - case D3DTOP_MODULATE: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_MODULATE); - break; - - case D3DTOP_ADD: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_ADD); - break; - - case D3DTOP_ADDSIGNED2X: - scale = scale * 2; /* Drop through */ - case D3DTOP_ADDSIGNED: - glTexEnvi(GL_TEXTURE_ENV, parm, GL_ADD_SIGNED_EXT); - break; - - /* For the four blending modes, use the Arg2 parameter */ - case D3DTOP_BLENDDIFFUSEALPHA: - case D3DTOP_BLENDTEXTUREALPHA: - case D3DTOP_BLENDFACTORALPHA: - case D3DTOP_BLENDCURRENTALPHA: { - GLenum src = GL_PRIMARY_COLOR_EXT; /* Just to prevent a compiler warning.. */ - - switch (dwState) { - case D3DTOP_BLENDDIFFUSEALPHA: src = GL_PRIMARY_COLOR_EXT; - case D3DTOP_BLENDTEXTUREALPHA: src = GL_TEXTURE; - case D3DTOP_BLENDFACTORALPHA: src = GL_CONSTANT_EXT; - case D3DTOP_BLENDCURRENTALPHA: src = GL_PREVIOUS_EXT; - } - - glTexEnvi(GL_TEXTURE_ENV, parm, GL_INTERPOLATE_EXT); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, src); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, src); - glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA); - } break; - - default: - handled = FALSE; - break; - } - } - - if (((prev_state == D3DTOP_SELECTARG2) && (dwState != D3DTOP_SELECTARG2)) || - ((dwState == D3DTOP_SELECTARG2) && (prev_state != D3DTOP_SELECTARG2))) { - /* Switch the arguments if needed... */ - if (d3dTexStageStateType == D3DTSS_COLOROP) { - handle_color_alpha_args(This, dwStage, D3DTSS_COLORARG1, - This->state_block.texture_stage_state[dwStage][D3DTSS_COLORARG1 - 1], - dwState); - handle_color_alpha_args(This, dwStage, D3DTSS_COLORARG2, - This->state_block.texture_stage_state[dwStage][D3DTSS_COLORARG2 - 1], - dwState); - } else { - handle_color_alpha_args(This, dwStage, D3DTSS_ALPHAARG1, - This->state_block.texture_stage_state[dwStage][D3DTSS_ALPHAARG1 - 1], - dwState); - handle_color_alpha_args(This, dwStage, D3DTSS_ALPHAARG2, - This->state_block.texture_stage_state[dwStage][D3DTSS_ALPHAARG2 - 1], - dwState); - } - } - - if (handled) { - if (d3dTexStageStateType == D3DTSS_ALPHAOP) { - glTexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale); - } else { - glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, scale); - } - TRACE(" Stage type is : %s => %s\n", type, value); - } else { - FIXME(" Unhandled stage type is : %s => %s\n", type, value); - } - } break; - - case D3DTSS_COLORARG1: - case D3DTSS_COLORARG2: - case D3DTSS_ALPHAARG1: - case D3DTSS_ALPHAARG2: { - const char *value, *value_comp = "", *value_alpha = ""; - BOOLEAN handled; - D3DTEXTUREOP tex_op; - - switch (dwState & D3DTA_SELECTMASK) { -#define GEN_CASE(a) case a: value = #a; break - GEN_CASE(D3DTA_DIFFUSE); - GEN_CASE(D3DTA_CURRENT); - GEN_CASE(D3DTA_TEXTURE); - GEN_CASE(D3DTA_TFACTOR); - GEN_CASE(D3DTA_SPECULAR); -#undef GEN_CASE - default: value = "UNKNOWN"; - } - if (dwState & D3DTA_COMPLEMENT) { - value_comp = " | D3DTA_COMPLEMENT"; - } - if (dwState & D3DTA_ALPHAREPLICATE) { - value_alpha = " | D3DTA_ALPHAREPLICATE"; - } - - if ((d3dTexStageStateType == D3DTSS_COLORARG1) || (d3dTexStageStateType == D3DTSS_COLORARG2)) { - tex_op = This->state_block.texture_stage_state[dwStage][D3DTSS_COLOROP - 1]; - } else { - tex_op = This->state_block.texture_stage_state[dwStage][D3DTSS_ALPHAOP - 1]; - } - - handled = handle_color_alpha_args(This, dwStage, d3dTexStageStateType, dwState, tex_op); - - if (handled) { - TRACE(" Stage type : %s => %s%s%s\n", type, value, value_comp, value_alpha); - } else { - FIXME(" Unhandled stage type : %s => %s%s%s\n", type, value, value_comp, value_alpha); - } - } break; - - case D3DTSS_MIPMAPLODBIAS: { - D3DVALUE value = *((D3DVALUE *) &dwState); - BOOLEAN handled = TRUE; - - if ((value != 0.0) && (GL_extensions.mipmap_lodbias == FALSE)) - handled = FALSE; - - if (handled) { - TRACE(" Stage type : D3DTSS_MIPMAPLODBIAS => %f\n", value); - glTexEnvf(GL_TEXTURE_FILTER_CONTROL_WINE, GL_TEXTURE_LOD_BIAS_WINE, value); - } else { - FIXME(" Unhandled stage type : D3DTSS_MIPMAPLODBIAS => %f\n", value); - } - } break; - - case D3DTSS_MAXMIPLEVEL: - TRACE(" Stage type : D3DTSS_MAXMIPLEVEL => %ld\n", dwState); - break; - - case D3DTSS_BORDERCOLOR: - TRACE(" Stage type : D3DTSS_BORDERCOLOR => %02lx %02lx %02lx %02lx (RGBA)\n", - ((dwState >> 16) & 0xFF), - ((dwState >> 8) & 0xFF), - ((dwState >> 0) & 0xFF), - ((dwState >> 24) & 0xFF)); - break; - - case D3DTSS_TEXCOORDINDEX: { - BOOLEAN handled = TRUE; - const char *value; - - switch (dwState & 0xFFFF0000) { -#define GEN_CASE(a) case a: value = #a; break - GEN_CASE(D3DTSS_TCI_PASSTHRU); - GEN_CASE(D3DTSS_TCI_CAMERASPACENORMAL); - GEN_CASE(D3DTSS_TCI_CAMERASPACEPOSITION); - GEN_CASE(D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); -#undef GEN_CASE - default: value = "UNKNOWN"; - } - if ((dwState & 0xFFFF0000) != D3DTSS_TCI_PASSTHRU) - handled = FALSE; - - if (handled) { - TRACE(" Stage type : D3DTSS_TEXCOORDINDEX => %ld | %s\n", dwState & 0x0000FFFF, value); - } else { - FIXME(" Unhandled stage type : D3DTSS_TEXCOORDINDEX => %ld | %s\n", dwState & 0x0000FFFF, value); - } - } break; - - case D3DTSS_TEXTURETRANSFORMFLAGS: { - const char *projected = "", *value; - BOOLEAN handled = TRUE; - switch (dwState & 0xFF) { -#define GEN_CASE(a) case a: value = #a; break - GEN_CASE(D3DTTFF_DISABLE); - GEN_CASE(D3DTTFF_COUNT1); - GEN_CASE(D3DTTFF_COUNT2); - GEN_CASE(D3DTTFF_COUNT3); - GEN_CASE(D3DTTFF_COUNT4); -#undef GEN_CASE - default: value = "UNKNOWN"; - } - if (dwState & D3DTTFF_PROJECTED) { - projected = " | D3DTTFF_PROJECTED"; - handled = FALSE; - } - - if ((dwState & 0xFF) != D3DTTFF_DISABLE) { - This->matrices_updated(This, TEXMAT0_CHANGED << dwStage); - } - - if (handled) { - TRACE(" Stage type : D3DTSS_TEXTURETRANSFORMFLAGS => %s%s\n", value, projected); - } else { - FIXME(" Unhandled stage type : D3DTSS_TEXTURETRANSFORMFLAGS => %s%s\n", value, projected); - } - } break; - - default: - FIXME(" Unhandled stage type : %s => %08lx\n", type, dwState); - break; - } - - LEAVE_GL(); - - return DD_OK; -} - -static DWORD -draw_primitive_handle_textures(IDirect3DDeviceImpl *This) -{ - IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This; - DWORD stage; - BOOLEAN enable_colorkey = FALSE; - - for (stage = 0; stage < MAX_TEXTURES; stage++) { - IDirectDrawSurfaceImpl *surf_ptr = This->current_texture[stage]; - GLenum unit; - - /* If this stage is disabled, no need to go further... */ - if (This->state_block.texture_stage_state[stage][D3DTSS_COLOROP - 1] == D3DTOP_DISABLE) - break; - - /* First check if we need to bind any other texture for this stage */ - if (This->current_texture[stage] != glThis->current_bound_texture[stage]) { - if (This->current_texture[stage] == NULL) { - TRACE(" disabling 2D texturing for stage %ld.\n", stage); - - unit = GL_TEXTURE0_WINE + stage; - if (unit != glThis->current_active_tex_unit) { - GL_extensions.glActiveTexture(unit); - glThis->current_active_tex_unit = unit; - } - glBindTexture(GL_TEXTURE_2D, 0); - glDisable(GL_TEXTURE_2D); - } else { - GLenum tex_name = gltex_get_tex_name(surf_ptr); - - unit = GL_TEXTURE0_WINE + stage; - if (unit != glThis->current_active_tex_unit) { - GL_extensions.glActiveTexture(unit); - glThis->current_active_tex_unit = unit; - } - - if (glThis->current_bound_texture[stage] == NULL) { - if (This->state_block.texture_stage_state[stage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE) { - TRACE(" enabling 2D texturing and"); - glEnable(GL_TEXTURE_2D); - } - } - TRACE(" activating OpenGL texture id %d for stage %ld.\n", tex_name, stage); - glBindTexture(GL_TEXTURE_2D, tex_name); - } - - glThis->current_bound_texture[stage] = This->current_texture[stage]; - } else { - if (glThis->current_bound_texture[stage] == NULL) { - TRACE(" displaying without texturing activated for stage %ld.\n", stage); - } else { - TRACE(" using already bound texture id %d for stage %ld.\n", - ((IDirect3DTextureGLImpl *) (glThis->current_bound_texture[stage])->tex_private)->tex_name, stage); - } - } - - /* If no texure valid for this stage, go out of the loop */ - if (This->current_texture[stage] == NULL) break; - - /* Then check if we need to flush this texture to GL or not (ie did it change) ?. - This will also update the various texture parameters if needed. - */ - gltex_upload_texture(surf_ptr, This, stage); - - /* And finally check for color-keying (only on first stage) */ - if (This->current_texture[stage]->surface_desc.dwFlags & DDSD_CKSRCBLT) { - if (stage == 0) { - enable_colorkey = TRUE; - } else { - static BOOL warn = FALSE; - if (warn == FALSE) { - warn = TRUE; - WARN(" Surface has color keying on stage different from 0 (%ld) !", stage); - } - } - } else { - if (stage == 0) { - enable_colorkey = FALSE; - } - } - } - - /* Apparently, whatever the state of BLEND, color keying is always activated for 'old' D3D versions */ - if (((This->state_block.render_state[D3DRENDERSTATE_COLORKEYENABLE - 1]) || - (glThis->parent.version == 1)) && - (enable_colorkey)) { - TRACE(" colorkey activated.\n"); - - if (glThis->alpha_test == FALSE) { - glEnable(GL_ALPHA_TEST); - glThis->alpha_test = TRUE; - } - if ((glThis->current_alpha_test_func != GL_NOTEQUAL) || (glThis->current_alpha_test_ref != 0.0)) { - if (This->state_block.render_state[D3DRENDERSTATE_ALPHATESTENABLE - 1]) { - static BOOL warn = FALSE; - if (warn == FALSE) { - warn = TRUE; - WARN(" Overriding application-given alpha test values - some graphical glitches may appear !\n"); - } - } - glThis->current_alpha_test_func = GL_NOTEQUAL; - glThis->current_alpha_test_ref = 0.0; - glAlphaFunc(GL_NOTEQUAL, 0.0); - } - /* Some sanity checks should be added here if a game mixes alphatest + color keying... - Only one has been found for now, and the ALPHAFUNC is 'Always' so it works :-) */ - } else { - if (This->state_block.render_state[D3DRENDERSTATE_ALPHATESTENABLE - 1] == FALSE) { - glDisable(GL_ALPHA_TEST); - glThis->alpha_test = FALSE; - } - /* Maybe we should restore here the application-given alpha test states ? */ - } - - return stage; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_3T_SetTexture(LPDIRECT3DDEVICE7 iface, - DWORD dwStage, - LPDIRECTDRAWSURFACE7 lpTexture2) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - - TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwStage, lpTexture2); - - if (((GL_extensions.max_texture_units == 0) && (dwStage > 0)) || - ((GL_extensions.max_texture_units != 0) && (dwStage >= GL_extensions.max_texture_units))) { - if (lpTexture2 != NULL) { - WARN(" setting a texture to a non-supported texture stage !\n"); - } - return DD_OK; - } - - if (This->current_texture[dwStage] != NULL) { - IDirectDrawSurface7_Release(ICOM_INTERFACE(This->current_texture[dwStage], IDirectDrawSurface7)); - } - - if (lpTexture2 == NULL) { - This->current_texture[dwStage] = NULL; - } else { - IDirectDrawSurfaceImpl *tex_impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, lpTexture2); - IDirectDrawSurface7_AddRef(ICOM_INTERFACE(tex_impl, IDirectDrawSurface7)); - This->current_texture[dwStage] = tex_impl; - } - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_GetCaps(LPDIRECT3DDEVICE7 iface, - LPD3DDEVICEDESC7 lpD3DHELDevDesc) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lpD3DHELDevDesc); - - fill_opengl_caps_7(lpD3DHELDevDesc); - - TRACE(" returning caps : no dump function yet.\n"); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_SetMaterial(LPDIRECT3DDEVICE7 iface, - LPD3DMATERIAL7 lpMat) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lpMat); - - if (TRACE_ON(ddraw)) { - TRACE(" material is : \n"); - dump_D3DMATERIAL7(lpMat); - } - - This->current_material = *lpMat; - - ENTER_GL(); - glMaterialfv(GL_FRONT_AND_BACK, - GL_DIFFUSE, - (float *) &(This->current_material.u.diffuse)); - glMaterialfv(GL_FRONT_AND_BACK, - GL_AMBIENT, - (float *) &(This->current_material.u1.ambient)); - glMaterialfv(GL_FRONT_AND_BACK, - GL_SPECULAR, - (float *) &(This->current_material.u2.specular)); - glMaterialfv(GL_FRONT_AND_BACK, - GL_EMISSION, - (float *) &(This->current_material.u3.emissive)); - glMaterialf(GL_FRONT_AND_BACK, - GL_SHININESS, - This->current_material.u4.power); /* Not sure about this... */ - LEAVE_GL(); - - return DD_OK; -} - - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_SetLight(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - LPD3DLIGHT7 lpLight) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This; - TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwLightIndex, lpLight); - - if (TRACE_ON(ddraw)) { - TRACE(" setting light : \n"); - dump_D3DLIGHT7(lpLight); - } - - if (dwLightIndex >= MAX_LIGHTS) return DDERR_INVALIDPARAMS; - This->set_lights |= 0x00000001 << dwLightIndex; - This->light_parameters[dwLightIndex] = *lpLight; - - /* Some checks to print out nice warnings :-) */ - switch (lpLight->dltType) { - case D3DLIGHT_DIRECTIONAL: - case D3DLIGHT_POINT: - /* These are handled properly... */ - break; - - case D3DLIGHT_SPOT: - if ((lpLight->dvTheta != 0.0) || - (lpLight->dvTheta != lpLight->dvPhi)) { - ERR("dvTheta not fully supported yet !\n"); - } - break; - - default: - ERR("Light type not handled yet : %08x !\n", lpLight->dltType); - } - - /* This will force the Light setting on next drawing of primitives */ - glThis->transform_state = GL_TRANSFORM_NONE; - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_LightEnable(LPDIRECT3DDEVICE7 iface, - DWORD dwLightIndex, - BOOL bEnable) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%08lx,%d)\n", This, iface, dwLightIndex, bEnable); - - if (dwLightIndex >= MAX_LIGHTS) return DDERR_INVALIDPARAMS; - - ENTER_GL(); - if (bEnable) { - if (((0x00000001 << dwLightIndex) & This->set_lights) == 0) { - /* Set the default parameters.. */ - TRACE(" setting default light parameters...\n"); - GL_IDirect3DDeviceImpl_7_SetLight(iface, dwLightIndex, &(This->light_parameters[dwLightIndex])); - } - glEnable(GL_LIGHT0 + dwLightIndex); - if ((This->active_lights & (0x00000001 << dwLightIndex)) == 0) { - /* This light gets active... Need to update its parameters to GL before the next drawing */ - IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This; - - This->active_lights |= 0x00000001 << dwLightIndex; - glThis->transform_state = GL_TRANSFORM_NONE; - } - } else { - glDisable(GL_LIGHT0 + dwLightIndex); - This->active_lights &= ~(0x00000001 << dwLightIndex); - } - LEAVE_GL(); - - return DD_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_SetClipPlane(LPDIRECT3DDEVICE7 iface, DWORD dwIndex, CONST D3DVALUE* pPlaneEquation) -{ - IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface; - IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This; - - TRACE("(%p)->(%ld,%p)\n", This, dwIndex, pPlaneEquation); - - if (dwIndex >= This->max_clipping_planes) { - return DDERR_INVALIDPARAMS; - } - - TRACE(" clip plane %ld : %f %f %f %f\n", dwIndex, pPlaneEquation[0], pPlaneEquation[1], pPlaneEquation[2], pPlaneEquation[3] ); - - memcpy(This->clipping_planes[dwIndex].plane, pPlaneEquation, sizeof(D3DVALUE[4])); - - /* This is to force the reset of the transformation matrices on the next drawing. - * This is needed to use the correct matrices for the various clipping planes. - */ - glThis->transform_state = GL_TRANSFORM_NONE; - - return D3D_OK; -} - -HRESULT WINAPI -GL_IDirect3DDeviceImpl_7_SetViewport(LPDIRECT3DDEVICE7 iface, - LPD3DVIEWPORT7 lpData) -{ - ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); - TRACE("(%p/%p)->(%p)\n", This, iface, lpData); - - if (TRACE_ON(ddraw)) { - TRACE(" viewport is : \n"); - TRACE(" - dwX = %ld dwY = %ld\n", - lpData->dwX, lpData->dwY); - TRACE(" - dwWidth = %ld dwHeight = %ld\n", - lpData->dwWidth, lpData->dwHeight); - TRACE(" - dvMinZ = %f dvMaxZ = %f\n", - lpData->dvMinZ, lpData->dvMaxZ); - } - ENTER_GL(); - - /* Set the viewport */ - if ((lpData->dvMinZ != This->active_viewport.dvMinZ) || - (lpData->dvMaxZ != This->active_viewport.dvMaxZ)) { - glDepthRange(lpData->dvMinZ, lpData->dvMaxZ); - } - if ((lpData->dwX != This->active_viewport.dwX) || - (lpData->dwY != This->active_viewport.dwY) || - (lpData->dwWidth != This->active_viewport.dwWidth) || - (lpData->dwHeight != This->active_viewport.dwHeight)) { - glViewport(lpData->dwX, - This->surface->surface_desc.dwHeight - (lpData->dwHeight + lpData->dwY), - lpData->dwWidth, lpData->dwHeight); - } - - LEAVE_GL(); - - This->active_viewport = *lpData; - - return DD_OK; -} - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -# define XCAST(fun) (typeof(VTABLE_IDirect3DDevice7.fun)) -#else -# define XCAST(fun) (void*) -#endif - -IDirect3DDevice7Vtbl VTABLE_IDirect3DDevice7 = -{ - XCAST(QueryInterface) Main_IDirect3DDeviceImpl_7_3T_2T_1T_QueryInterface, - XCAST(AddRef) Main_IDirect3DDeviceImpl_7_3T_2T_1T_AddRef, - XCAST(Release) GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release, - XCAST(GetCaps) GL_IDirect3DDeviceImpl_7_GetCaps, - XCAST(EnumTextureFormats) GL_IDirect3DDeviceImpl_7_3T_EnumTextureFormats, - XCAST(BeginScene) Main_IDirect3DDeviceImpl_7_3T_2T_1T_BeginScene, - XCAST(EndScene) Main_IDirect3DDeviceImpl_7_3T_2T_1T_EndScene, - XCAST(GetDirect3D) Main_IDirect3DDeviceImpl_7_3T_2T_1T_GetDirect3D, - XCAST(SetRenderTarget) Main_IDirect3DDeviceImpl_7_3T_2T_SetRenderTarget, - XCAST(GetRenderTarget) Main_IDirect3DDeviceImpl_7_3T_2T_GetRenderTarget, - XCAST(Clear) Main_IDirect3DDeviceImpl_7_Clear, - XCAST(SetTransform) Main_IDirect3DDeviceImpl_7_3T_2T_SetTransform, - XCAST(GetTransform) Main_IDirect3DDeviceImpl_7_3T_2T_GetTransform, - XCAST(SetViewport) GL_IDirect3DDeviceImpl_7_SetViewport, - XCAST(MultiplyTransform) Main_IDirect3DDeviceImpl_7_3T_2T_MultiplyTransform, - XCAST(GetViewport) Main_IDirect3DDeviceImpl_7_GetViewport, - XCAST(SetMaterial) GL_IDirect3DDeviceImpl_7_SetMaterial, - XCAST(GetMaterial) Main_IDirect3DDeviceImpl_7_GetMaterial, - XCAST(SetLight) GL_IDirect3DDeviceImpl_7_SetLight, - XCAST(GetLight) Main_IDirect3DDeviceImpl_7_GetLight, - XCAST(SetRenderState) GL_IDirect3DDeviceImpl_7_3T_2T_SetRenderState, - XCAST(GetRenderState) GL_IDirect3DDeviceImpl_7_3T_2T_GetRenderState, - XCAST(BeginStateBlock) Main_IDirect3DDeviceImpl_7_BeginStateBlock, - XCAST(EndStateBlock) Main_IDirect3DDeviceImpl_7_EndStateBlock, - XCAST(PreLoad) Main_IDirect3DDeviceImpl_7_PreLoad, - XCAST(DrawPrimitive) GL_IDirect3DDeviceImpl_7_3T_DrawPrimitive, - XCAST(DrawIndexedPrimitive) GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitive, - XCAST(SetClipStatus) Main_IDirect3DDeviceImpl_7_3T_2T_SetClipStatus, - XCAST(GetClipStatus) Main_IDirect3DDeviceImpl_7_3T_2T_GetClipStatus, - XCAST(DrawPrimitiveStrided) GL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveStrided, - XCAST(DrawIndexedPrimitiveStrided) GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveStrided, - XCAST(DrawPrimitiveVB) GL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveVB, - XCAST(DrawIndexedPrimitiveVB) GL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveVB, - XCAST(ComputeSphereVisibility) Main_IDirect3DDeviceImpl_7_3T_ComputeSphereVisibility, - XCAST(GetTexture) Main_IDirect3DDeviceImpl_7_3T_GetTexture, - XCAST(SetTexture) GL_IDirect3DDeviceImpl_7_3T_SetTexture, - XCAST(GetTextureStageState) Main_IDirect3DDeviceImpl_7_3T_GetTextureStageState, - XCAST(SetTextureStageState) GL_IDirect3DDeviceImpl_7_3T_SetTextureStageState, - XCAST(ValidateDevice) Main_IDirect3DDeviceImpl_7_3T_ValidateDevice, - XCAST(ApplyStateBlock) Main_IDirect3DDeviceImpl_7_ApplyStateBlock, - XCAST(CaptureStateBlock) Main_IDirect3DDeviceImpl_7_CaptureStateBlock, - XCAST(DeleteStateBlock) Main_IDirect3DDeviceImpl_7_DeleteStateBlock, - XCAST(CreateStateBlock) Main_IDirect3DDeviceImpl_7_CreateStateBlock, - XCAST(Load) Main_IDirect3DDeviceImpl_7_Load, - XCAST(LightEnable) GL_IDirect3DDeviceImpl_7_LightEnable, - XCAST(GetLightEnable) Main_IDirect3DDeviceImpl_7_GetLightEnable, - XCAST(SetClipPlane) GL_IDirect3DDeviceImpl_7_SetClipPlane, - XCAST(GetClipPlane) Main_IDirect3DDeviceImpl_7_GetClipPlane, - XCAST(GetInfo) Main_IDirect3DDeviceImpl_7_GetInfo, -}; - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -#undef XCAST -#endif - - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -# define XCAST(fun) (typeof(VTABLE_IDirect3DDevice3.fun)) -#else -# define XCAST(fun) (void*) -#endif - -IDirect3DDevice3Vtbl VTABLE_IDirect3DDevice3 = -{ - XCAST(QueryInterface) Thunk_IDirect3DDeviceImpl_3_QueryInterface, - XCAST(AddRef) Thunk_IDirect3DDeviceImpl_3_AddRef, - XCAST(Release) Thunk_IDirect3DDeviceImpl_3_Release, - XCAST(GetCaps) GL_IDirect3DDeviceImpl_3_2T_1T_GetCaps, - XCAST(GetStats) Main_IDirect3DDeviceImpl_3_2T_1T_GetStats, - XCAST(AddViewport) Main_IDirect3DDeviceImpl_3_2T_1T_AddViewport, - XCAST(DeleteViewport) Main_IDirect3DDeviceImpl_3_2T_1T_DeleteViewport, - XCAST(NextViewport) Main_IDirect3DDeviceImpl_3_2T_1T_NextViewport, - XCAST(EnumTextureFormats) Thunk_IDirect3DDeviceImpl_3_EnumTextureFormats, - XCAST(BeginScene) Thunk_IDirect3DDeviceImpl_3_BeginScene, - XCAST(EndScene) Thunk_IDirect3DDeviceImpl_3_EndScene, - XCAST(GetDirect3D) Thunk_IDirect3DDeviceImpl_3_GetDirect3D, - XCAST(SetCurrentViewport) Main_IDirect3DDeviceImpl_3_2T_SetCurrentViewport, - XCAST(GetCurrentViewport) Main_IDirect3DDeviceImpl_3_2T_GetCurrentViewport, - XCAST(SetRenderTarget) Thunk_IDirect3DDeviceImpl_3_SetRenderTarget, - XCAST(GetRenderTarget) Thunk_IDirect3DDeviceImpl_3_GetRenderTarget, - XCAST(Begin) Main_IDirect3DDeviceImpl_3_Begin, - XCAST(BeginIndexed) Main_IDirect3DDeviceImpl_3_BeginIndexed, - XCAST(Vertex) Main_IDirect3DDeviceImpl_3_2T_Vertex, - XCAST(Index) Main_IDirect3DDeviceImpl_3_2T_Index, - XCAST(End) Main_IDirect3DDeviceImpl_3_2T_End, - XCAST(GetRenderState) Thunk_IDirect3DDeviceImpl_3_GetRenderState, - XCAST(SetRenderState) Thunk_IDirect3DDeviceImpl_3_SetRenderState, - XCAST(GetLightState) GL_IDirect3DDeviceImpl_3_2T_GetLightState, - XCAST(SetLightState) GL_IDirect3DDeviceImpl_3_2T_SetLightState, - XCAST(SetTransform) Thunk_IDirect3DDeviceImpl_3_SetTransform, - XCAST(GetTransform) Thunk_IDirect3DDeviceImpl_3_GetTransform, - XCAST(MultiplyTransform) Thunk_IDirect3DDeviceImpl_3_MultiplyTransform, - XCAST(DrawPrimitive) Thunk_IDirect3DDeviceImpl_3_DrawPrimitive, - XCAST(DrawIndexedPrimitive) Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitive, - XCAST(SetClipStatus) Thunk_IDirect3DDeviceImpl_3_SetClipStatus, - XCAST(GetClipStatus) Thunk_IDirect3DDeviceImpl_3_GetClipStatus, - XCAST(DrawPrimitiveStrided) Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveStrided, - XCAST(DrawIndexedPrimitiveStrided) Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveStrided, - XCAST(DrawPrimitiveVB) Thunk_IDirect3DDeviceImpl_3_DrawPrimitiveVB, - XCAST(DrawIndexedPrimitiveVB) Thunk_IDirect3DDeviceImpl_3_DrawIndexedPrimitiveVB, - XCAST(ComputeSphereVisibility) Thunk_IDirect3DDeviceImpl_3_ComputeSphereVisibility, - XCAST(GetTexture) Thunk_IDirect3DDeviceImpl_3_GetTexture, - XCAST(SetTexture) Thunk_IDirect3DDeviceImpl_3_SetTexture, - XCAST(GetTextureStageState) Thunk_IDirect3DDeviceImpl_3_GetTextureStageState, - XCAST(SetTextureStageState) Thunk_IDirect3DDeviceImpl_3_SetTextureStageState, - XCAST(ValidateDevice) Thunk_IDirect3DDeviceImpl_3_ValidateDevice, -}; - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -#undef XCAST -#endif - - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -# define XCAST(fun) (typeof(VTABLE_IDirect3DDevice2.fun)) -#else -# define XCAST(fun) (void*) -#endif - -IDirect3DDevice2Vtbl VTABLE_IDirect3DDevice2 = -{ - XCAST(QueryInterface) Thunk_IDirect3DDeviceImpl_2_QueryInterface, - XCAST(AddRef) Thunk_IDirect3DDeviceImpl_2_AddRef, - XCAST(Release) Thunk_IDirect3DDeviceImpl_2_Release, - XCAST(GetCaps) Thunk_IDirect3DDeviceImpl_2_GetCaps, - XCAST(SwapTextureHandles) Main_IDirect3DDeviceImpl_2_1T_SwapTextureHandles, - XCAST(GetStats) Thunk_IDirect3DDeviceImpl_2_GetStats, - XCAST(AddViewport) Thunk_IDirect3DDeviceImpl_2_AddViewport, - XCAST(DeleteViewport) Thunk_IDirect3DDeviceImpl_2_DeleteViewport, - XCAST(NextViewport) Thunk_IDirect3DDeviceImpl_2_NextViewport, - XCAST(EnumTextureFormats) GL_IDirect3DDeviceImpl_2_1T_EnumTextureFormats, - XCAST(BeginScene) Thunk_IDirect3DDeviceImpl_2_BeginScene, - XCAST(EndScene) Thunk_IDirect3DDeviceImpl_2_EndScene, - XCAST(GetDirect3D) Thunk_IDirect3DDeviceImpl_2_GetDirect3D, - XCAST(SetCurrentViewport) Thunk_IDirect3DDeviceImpl_2_SetCurrentViewport, - XCAST(GetCurrentViewport) Thunk_IDirect3DDeviceImpl_2_GetCurrentViewport, - XCAST(SetRenderTarget) Thunk_IDirect3DDeviceImpl_2_SetRenderTarget, - XCAST(GetRenderTarget) Thunk_IDirect3DDeviceImpl_2_GetRenderTarget, - XCAST(Begin) Main_IDirect3DDeviceImpl_2_Begin, - XCAST(BeginIndexed) Main_IDirect3DDeviceImpl_2_BeginIndexed, - XCAST(Vertex) Thunk_IDirect3DDeviceImpl_2_Vertex, - XCAST(Index) Thunk_IDirect3DDeviceImpl_2_Index, - XCAST(End) Thunk_IDirect3DDeviceImpl_2_End, - XCAST(GetRenderState) Thunk_IDirect3DDeviceImpl_2_GetRenderState, - XCAST(SetRenderState) Thunk_IDirect3DDeviceImpl_2_SetRenderState, - XCAST(GetLightState) Thunk_IDirect3DDeviceImpl_2_GetLightState, - XCAST(SetLightState) Thunk_IDirect3DDeviceImpl_2_SetLightState, - XCAST(SetTransform) Thunk_IDirect3DDeviceImpl_2_SetTransform, - XCAST(GetTransform) Thunk_IDirect3DDeviceImpl_2_GetTransform, - XCAST(MultiplyTransform) Thunk_IDirect3DDeviceImpl_2_MultiplyTransform, - XCAST(DrawPrimitive) GL_IDirect3DDeviceImpl_2_DrawPrimitive, - XCAST(DrawIndexedPrimitive) GL_IDirect3DDeviceImpl_2_DrawIndexedPrimitive, - XCAST(SetClipStatus) Thunk_IDirect3DDeviceImpl_2_SetClipStatus, - XCAST(GetClipStatus) Thunk_IDirect3DDeviceImpl_2_GetClipStatus, -}; - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -#undef XCAST -#endif - - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -# define XCAST(fun) (typeof(VTABLE_IDirect3DDevice.fun)) -#else -# define XCAST(fun) (void*) -#endif - -IDirect3DDeviceVtbl VTABLE_IDirect3DDevice = -{ - XCAST(QueryInterface) Thunk_IDirect3DDeviceImpl_1_QueryInterface, - XCAST(AddRef) Thunk_IDirect3DDeviceImpl_1_AddRef, - XCAST(Release) Thunk_IDirect3DDeviceImpl_1_Release, - XCAST(Initialize) Main_IDirect3DDeviceImpl_1_Initialize, - XCAST(GetCaps) Thunk_IDirect3DDeviceImpl_1_GetCaps, - XCAST(SwapTextureHandles) Thunk_IDirect3DDeviceImpl_1_SwapTextureHandles, - XCAST(CreateExecuteBuffer) GL_IDirect3DDeviceImpl_1_CreateExecuteBuffer, - XCAST(GetStats) Thunk_IDirect3DDeviceImpl_1_GetStats, - XCAST(Execute) Main_IDirect3DDeviceImpl_1_Execute, - XCAST(AddViewport) Thunk_IDirect3DDeviceImpl_1_AddViewport, - XCAST(DeleteViewport) Thunk_IDirect3DDeviceImpl_1_DeleteViewport, - XCAST(NextViewport) Thunk_IDirect3DDeviceImpl_1_NextViewport, - XCAST(Pick) Main_IDirect3DDeviceImpl_1_Pick, - XCAST(GetPickRecords) Main_IDirect3DDeviceImpl_1_GetPickRecords, - XCAST(EnumTextureFormats) Thunk_IDirect3DDeviceImpl_1_EnumTextureFormats, - XCAST(CreateMatrix) Main_IDirect3DDeviceImpl_1_CreateMatrix, - XCAST(SetMatrix) Main_IDirect3DDeviceImpl_1_SetMatrix, - XCAST(GetMatrix) Main_IDirect3DDeviceImpl_1_GetMatrix, - XCAST(DeleteMatrix) Main_IDirect3DDeviceImpl_1_DeleteMatrix, - XCAST(BeginScene) Thunk_IDirect3DDeviceImpl_1_BeginScene, - XCAST(EndScene) Thunk_IDirect3DDeviceImpl_1_EndScene, - XCAST(GetDirect3D) Thunk_IDirect3DDeviceImpl_1_GetDirect3D, -}; - -#if !defined(__STRICT_ANSI__) && defined(__GNUC__) -#undef XCAST -#endif - -static HRESULT d3ddevice_clear(IDirect3DDeviceImpl *This, - WINE_GL_BUFFER_TYPE buffer_type, - DWORD dwCount, - L