From ef8c807315e21815e42281efe984955f6290df45 Mon Sep 17 00:00:00 2001 From: Jan Zerebecki Date: Fri, 29 May 2009 19:41:12 +0200 Subject: [PATCH] push 0a0aa53cd365a71ca6121b6df157ca635450378f --- configure | 238 +++++- configure.ac | 13 + dlls/advapi32/security.c | 1 + dlls/avifil32/avifile.c | 4 +- dlls/cabinet/fdi.c | 2 +- dlls/comctl32/comboex.c | 8 +- dlls/comctl32/comctl32undoc.c | 4 +- dlls/comctl32/hotkey.c | 3 +- dlls/comctl32/listview.c | 110 +-- dlls/comctl32/tests/ipaddress.c | 7 +- dlls/comctl32/tests/listview.c | 270 ++++++- dlls/comctl32/tests/mru.c | 112 ++- dlls/comctl32/tests/tooltips.c | 104 ++- dlls/comctl32/tests/treeview.c | 17 +- dlls/comctl32/toolbar.c | 2 +- dlls/comctl32/tooltips.c | 624 +++++++-------- dlls/comdlg32/cdlg_De.rc | 46 +- dlls/comdlg32/tests/printdlg.c | 5 + dlls/cryptui/cryptui.rc | 1 + dlls/cryptui/cryptui_Nl.rc | 461 +++++++++++ dlls/d3d10core/d3d10core_private.h | 3 + dlls/d3d10core/device.c | 35 +- dlls/d3d10core/shader.c | 2 + dlls/d3d8/device.c | 7 +- dlls/d3d9/device.c | 19 +- dlls/d3d9/tests/device.c | 51 ++ dlls/d3d9/tests/visual.c | 77 ++ dlls/d3d9/vertexshader.c | 3 +- dlls/d3dx9_36/Makefile.in | 3 +- dlls/d3dx9_36/d3dx9_36.spec | 10 +- dlls/d3dx9_36/surface.c | 69 ++ dlls/dbghelp/dwarf.c | 2 + dlls/dplayx/dplayx_global.c | 43 -- dlls/dplayx/dplayx_global.h | 2 - dlls/dplayx/name_server.c | 4 - dlls/dsound/capture.c | 2 +- dlls/gdiplus/gdiplus.spec | 2 +- dlls/gdiplus/image.c | 7 + dlls/gphoto2.ds/ds_image.c | 2 +- dlls/gphoto2.ds/gphoto2_main.c | 2 + dlls/imm32/imm.c | 2 +- dlls/jscript/lex.c | 26 +- dlls/jscript/math.c | 184 ++++- dlls/jscript/regexp.c | 2 +- dlls/jscript/tests/api.js | 300 ++++++++ dlls/jscript/tests/lang.js | 2 + dlls/kernel32/heap.c | 3 + dlls/kernel32/kernel.rc | 1 + dlls/kernel32/module.c | 6 - dlls/kernel32/nls/dea.nls | 32 +- dlls/kernel32/nls/dec.nls | 32 +- dlls/kernel32/nls/del.nls | 32 +- dlls/kernel32/nls/des.nls | 32 +- dlls/kernel32/nls/deu.nls | 2 +- dlls/kernel32/powermgnt.c | 17 +- dlls/kernel32/tests/file.c | 7 +- dlls/kernel32/tests/heap.c | 49 ++ dlls/kernel32/tests/module.c | 28 +- dlls/kernel32/tests/volume.c | 14 +- dlls/kernel32/volume.c | 126 ++- dlls/mlang/mlang.c | 7 +- dlls/mlang/tests/Makefile.in | 2 +- dlls/mlang/tests/mlang.c | 98 ++- dlls/msacm32/format.c | 2 +- dlls/msctf/context.c | 104 ++- dlls/msctf/range.c | 17 +- dlls/msctf/tests/inputprocessor.c | 37 +- dlls/mshtml/htmlnode.c | 5 + dlls/mshtml/main.c | 4 +- dlls/mshtml/task.c | 16 +- dlls/mshtml/tests/dom.c | 30 +- dlls/msi/action.c | 2 +- dlls/msi/alter.c | 5 +- dlls/msi/create.c | 10 +- dlls/msi/database.c | 385 ++++++++-- dlls/msi/drop.c | 5 +- dlls/msi/join.c | 5 +- dlls/msi/msipriv.h | 2 + dlls/msi/query.h | 2 +- dlls/msi/record.c | 5 +- dlls/msi/sql.y | 27 +- dlls/msi/storages.c | 4 +- dlls/msi/streams.c | 3 + dlls/msi/table.c | 285 +++++-- dlls/msi/tests/db.c | 237 +++++- dlls/msi/tests/install.c | 49 +- dlls/msi/tests/package.c | 44 +- dlls/msi/update.c | 3 + dlls/msvcrt/cpp.c | 2 +- dlls/msvcrt/data.c | 2 +- dlls/msvcrt/errno.c | 4 +- dlls/msvcrt/file.c | 157 +++- dlls/msvcrt/locale.c | 2 +- dlls/msvcrt/math.c | 14 +- dlls/msvcrt/mbcs.c | 12 +- dlls/msvcrt/misc.c | 4 +- dlls/msvcrt/msvcrt.h | 231 +++--- dlls/msvcrt/msvcrt.spec | 28 +- dlls/msvcrt/process.c | 4 +- dlls/msvcrt/tests/cpp.c | 16 +- dlls/msvcrt/tests/data.c | 6 +- dlls/msvcrt/tests/file.c | 48 +- dlls/msvcrt/tests/headers.c | 81 +- dlls/msvcrt/tests/heap.c | 10 +- dlls/msvcrt/tests/printf.c | 6 +- dlls/msvcrt/tests/string.c | 12 +- dlls/msvcrt/time.c | 251 +++++- dlls/msvcrt/undname.c | 22 +- dlls/msvcrtd/debug.c | 15 +- dlls/msvcrtd/tests/debug.c | 2 +- dlls/msvfw32/drawdib.c | 2 +- dlls/ntdll/virtual.c | 2 +- dlls/ole32/tests/clipboard.c | 2 +- dlls/ole32/tests/compobj.c | 18 +- dlls/ole32/tests/usrmarshal.c | 2 +- dlls/ole32/usrmarshal.c | 2 +- dlls/oleaut32/Makefile.in | 1 + dlls/oleaut32/tests/typelib.c | 4 +- dlls/oleaut32/tests/vartest.c | 10 +- dlls/oleaut32/variant.c | 2 +- dlls/opengl32/make_opengl | 56 +- dlls/opengl32/opengl_ext.c | 4 +- dlls/quartz/control.c | 2 + dlls/riched20/caret.c | 2 +- dlls/riched20/editor.c | 6 +- dlls/riched20/editor.h | 3 - dlls/riched20/reader.c | 145 ---- dlls/riched20/rtf.h | 10 - dlls/riched20/run.c | 12 - dlls/rpcrt4/cproxy.c | 27 +- dlls/rpcrt4/cpsf.h | 33 +- dlls/rpcrt4/cstub.c | 26 +- dlls/rpcrt4/ndr_marshall.c | 41 +- dlls/rpcrt4/rpc_transport.c | 2 +- dlls/rpcrt4/tests/cstub.c | 69 ++ dlls/rpcrt4/tests/ndr_marshall.c | 430 +++++------ dlls/rpcrt4/tests/server.c | 51 +- dlls/rsaenh/mpi.c | 55 +- dlls/rsaenh/tomcrypt.h | 46 -- dlls/sane.ds/ds_image.c | 2 +- dlls/secur32/schannel.c | 6 +- dlls/shell32/shell32_Ko.rc | 6 +- dlls/urlmon/urlmon_main.c | 13 +- dlls/user32/hook.c | 3 +- dlls/user32/misc.c | 11 + dlls/user32/tests/input.c | 2 +- dlls/user32/tests/menu.c | 4 +- dlls/user32/tests/text.c | 3 +- dlls/user32/user32.spec | 2 +- dlls/uuid/uuid.c | 9 + dlls/wined3d/arb_program_shader.c | 1023 ++++++++++++++++++------- dlls/wined3d/baseshader.c | 141 ++-- dlls/wined3d/context.c | 33 +- dlls/wined3d/device.c | 71 +- dlls/wined3d/directx.c | 9 +- dlls/wined3d/drawprim.c | 2 - dlls/wined3d/glsl_shader.c | 1144 +++++++++++++++++----------- dlls/wined3d/pixelshader.c | 77 +- dlls/wined3d/resource.c | 11 +- dlls/wined3d/surface.c | 143 ++-- dlls/wined3d/utils.c | 34 +- dlls/wined3d/vertexshader.c | 141 +--- dlls/wined3d/wined3d_private.h | 61 +- dlls/winex11.drv/desktop.c | 42 + dlls/winex11.drv/keyboard.c | 3 +- dlls/winex11.drv/opengl.c | 19 +- dlls/winex11.drv/x11drv.h | 1 + dlls/winex11.drv/x11drv_main.c | 1 + dlls/wininet/http.c | 91 ++- dlls/wininet/internet.h | 6 +- dlls/winmm/tests/wave.c | 2 +- include/commctrl.h | 5 + include/msctf.idl | 36 + include/msvcrt/conio.h | 4 +- include/msvcrt/crtdbg.h | 10 +- include/msvcrt/crtdefs.h | 23 +- include/msvcrt/direct.h | 2 +- include/msvcrt/float.h | 2 +- include/msvcrt/io.h | 22 +- include/msvcrt/stddef.h | 4 +- include/msvcrt/stdio.h | 4 +- include/msvcrt/stdlib.h | 48 +- include/msvcrt/sys/timeb.h | 22 +- include/msvcrt/sys/types.h | 2 +- include/msvcrt/sys/utime.h | 29 +- include/msvcrt/time.h | 59 +- include/msvcrt/wchar.h | 33 +- include/rpcndr.h | 2 - include/schannel.h | 4 +- include/wincrypt.h | 1 + include/wine/wined3d.idl | 8 +- include/wininet.h | 5 +- programs/notepad/dialog.c | 38 +- programs/notepad/main.c | 14 +- programs/notepad/main.h | 2 +- programs/reg/Ko.rc | 10 +- programs/regedit/Ko.rc | 3 +- programs/wineboot/wineboot.c | 10 +- programs/winedbg/rsrc.rc | 1 + programs/winedbg/rsrc_Ru.rc | 53 ++ programs/winemenubuilder/Makefile.in | 3 +- programs/winemenubuilder/winemenubuilder.c | 263 ++++++- programs/winetest/send.c | 222 +++++- tools/config.guess | 85 ++- tools/config.sub | 100 ++- tools/make_requests | 2 +- tools/winapi/winapi_cleanup | 231 ------ tools/winapi/winapi_cleanup_options.pm | 55 -- tools/winapi/winapi_fixup | 232 ------ tools/winapi/winapi_fixup_documentation.pm | 402 ---------- tools/winapi/winapi_fixup_editor.pm | 407 ---------- tools/winapi/winapi_fixup_options.pm | 68 -- tools/winapi/winapi_fixup_statements.pm | 337 -------- tools/winedump/pe.c | 2 +- 214 files changed, 7707 insertions(+), 4937 deletions(-) create mode 100644 dlls/cryptui/cryptui_Nl.rc create mode 100644 dlls/d3dx9_36/surface.c create mode 100644 programs/winedbg/rsrc_Ru.rc delete mode 100755 tools/winapi/winapi_cleanup delete mode 100644 tools/winapi/winapi_cleanup_options.pm delete mode 100755 tools/winapi/winapi_fixup delete mode 100644 tools/winapi/winapi_fixup_documentation.pm delete mode 100644 tools/winapi/winapi_fixup_editor.pm delete mode 100644 tools/winapi/winapi_fixup_options.pm delete mode 100644 tools/winapi/winapi_fixup_statements.pm diff --git a/configure b/configure index 9ef255a6c6d..9ef6442be78 100755 --- a/configure +++ b/configure @@ -762,6 +762,7 @@ ALSALIBS AUDIOIOLIBS CUPSINCL FONTCONFIGINCL +PNGINCL LIBKSTAT EXTRACFLAGS BUILTINFLAG @@ -16401,6 +16402,240 @@ _ACEOF fi +elif test -n "$X_CFLAGS" -a "x$with_png" != "xno" +then + ac_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $X_CFLAGS" + $as_unset ac_cv_header_png_h + +for ac_header in png.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&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); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 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); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ------------------------------------ ## +## Report this to wine-devel@winehq.org ## +## ------------------------------------ ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + CPPFLAGS="$ac_save_CPPFLAGS" + if test "$ac_cv_header_png_h" = "yes" + then + PNGINCL="$X_CFLAGS" + + { echo "$as_me:$LINENO: checking for -lpng" >&5 +echo $ECHO_N "checking for -lpng... $ECHO_C" >&6; } +if test "${ac_cv_lib_soname_png+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_soname_save_LIBS=$LIBS +LIBS="-lpng $X_LIBS -lm -lz $LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char png_create_read_struct (); +int +main () +{ +return png_create_read_struct (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + case "$LIBEXT" in + dll) ;; + dylib) ac_cv_lib_soname_png=`otool -L conftest$ac_exeext | grep "libpng[0-9]*\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libpng[0-9]*\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;; + *) ac_cv_lib_soname_png=`$ac_cv_path_LDD conftest$ac_exeext | grep "libpng[0-9]*\\.$LIBEXT" | sed -e "s/^.*\(libpng[0-9]*\.$LIBEXT[^ ]*\).*$/\1/"';2,$d'` ;; + esac +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + LIBS=$ac_check_soname_save_LIBS +fi +if test "x$ac_cv_lib_soname_png" = "x"; then + { echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6; } + +else + { echo "$as_me:$LINENO: result: $ac_cv_lib_soname_png" >&5 +echo "${ECHO_T}$ac_cv_lib_soname_png" >&6; } + +cat >>confdefs.h <<_ACEOF +#define SONAME_LIBPNG "$ac_cv_lib_soname_png" +_ACEOF + + +fi + + fi fi if test "x$ac_cv_lib_soname_png" = "x"; then case "x$with_png" in @@ -28429,6 +28664,7 @@ ALSALIBS!$ALSALIBS$ac_delim AUDIOIOLIBS!$AUDIOIOLIBS$ac_delim CUPSINCL!$CUPSINCL$ac_delim FONTCONFIGINCL!$FONTCONFIGINCL$ac_delim +PNGINCL!$PNGINCL$ac_delim LIBKSTAT!$LIBKSTAT$ac_delim EXTRACFLAGS!$EXTRACFLAGS$ac_delim BUILTINFLAG!$BUILTINFLAG$ac_delim @@ -28455,7 +28691,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 90; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.ac b/configure.ac index 6a686a1986e..4b127c0a540 100644 --- a/configure.ac +++ b/configure.ac @@ -1318,6 +1318,19 @@ dnl **** Check for libpng **** if test "$ac_cv_header_png_h" = "yes" then WINE_CHECK_SONAME(png,png_create_read_struct,,,-lm -lz,[[libpng[[0-9]]*]]) +elif test -n "$X_CFLAGS" -a "x$with_png" != "xno" +then + dnl libpng is in the X directory on Mac OS X + ac_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $X_CFLAGS" + $as_unset ac_cv_header_png_h + AC_CHECK_HEADERS([png.h]) + CPPFLAGS="$ac_save_CPPFLAGS" + if test "$ac_cv_header_png_h" = "yes" + then + AC_SUBST(PNGINCL,"$X_CFLAGS") + WINE_CHECK_SONAME(png,png_create_read_struct,,,[$X_LIBS -lm -lz],[[libpng[[0-9]]*]]) + fi fi WINE_WARNING_WITH(png,[test "x$ac_cv_lib_soname_png" = "x"], [libpng ${notice_platform}development files not found, PNG won't be supported.]) diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index efe34f42653..0aa92ce319e 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -2761,6 +2761,7 @@ BOOL WINAPI LookupAccountNameW( LPCWSTR lpSystemName, LPCWSTR lpAccountName, PSI SetLastError(ERROR_NONE_MAPPED); ret = FALSE; } + nameLen = UNLEN + 1; } if (GetUserNameW(userName, &nameLen) && !strcmpW(lpAccountNamePtr, userName)) diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c index 1719031394c..49e141ff389 100644 --- a/dlls/avifil32/avifile.c +++ b/dlls/avifil32/avifile.c @@ -226,7 +226,7 @@ static ULONG AVIFILE_SearchStream(const IAVIFileImpl *This, DWORD fccType, LONG lSkip); static void AVIFILE_UpdateInfo(IAVIFileImpl *This); static HRESULT AVIFILE_WriteBlock(IAVIStreamImpl *This, DWORD block, - FOURCC ckid, DWORD flags, LPVOID buffer, + FOURCC ckid, DWORD flags, LPCVOID buffer, LONG size); HRESULT AVIFILE_CreateAVIFile(REFIID riid, LPVOID *ppv) @@ -2543,7 +2543,7 @@ static void AVIFILE_UpdateInfo(IAVIFileImpl *This) } static HRESULT AVIFILE_WriteBlock(IAVIStreamImpl *This, DWORD block, - FOURCC ckid, DWORD flags, LPVOID buffer, + FOURCC ckid, DWORD flags, LPCVOID buffer, LONG size) { MMCKINFO ck; diff --git a/dlls/cabinet/fdi.c b/dlls/cabinet/fdi.c index c7749eb66a3..81328183ac8 100644 --- a/dlls/cabinet/fdi.c +++ b/dlls/cabinet/fdi.c @@ -2260,7 +2260,7 @@ static int fdi_decomp(const struct fdi_file *fi, int savemode, fdi_decomp_state return DECR_OK; } -static void free_decompression_temps(HFDI hfdi, struct fdi_folder *fol, +static void free_decompression_temps(HFDI hfdi, const struct fdi_folder *fol, fdi_decomp_state *decomp_state) { switch (fol->comp_type & cffoldCOMPTYPE_MASK) { diff --git a/dlls/comctl32/comboex.c b/dlls/comctl32/comboex.c index 04464fd94a8..8a0652cdd1f 100644 --- a/dlls/comctl32/comboex.c +++ b/dlls/comctl32/comboex.c @@ -356,7 +356,7 @@ static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) } -static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) +static void COMBOEX_CopyItem (const CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) { if (cit->mask & CBEIF_TEXT) { /* @@ -467,7 +467,7 @@ static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) } -static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT_PTR index) +static CBE_ITEMDATA * COMBOEX_FindItem(const COMBOEX_INFO *infoPtr, INT_PTR index) { CBE_ITEMDATA *item; INT i; @@ -542,7 +542,7 @@ static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT_PTR index) } -static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) +static BOOL COMBOEX_GetItemW (const COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) { INT_PTR index = cit->iItem; CBE_ITEMDATA *item; @@ -563,7 +563,7 @@ static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) } -static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) +static BOOL COMBOEX_GetItemA (const COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) { COMBOBOXEXITEMW tmpcit; diff --git a/dlls/comctl32/comctl32undoc.c b/dlls/comctl32/comctl32undoc.c index 789906822f6..194efe5e4f8 100644 --- a/dlls/comctl32/comctl32undoc.c +++ b/dlls/comctl32/comctl32undoc.c @@ -385,7 +385,7 @@ INT WINAPI FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, UINT i; LPSTR dataA = NULL; - if (!mp->extview.lpfnCompare) + if (!mp || !mp->extview.lpfnCompare) return -1; if(!(mp->extview.dwFlags & MRUF_BINARY_LIST) && !mp->isUnicode) { @@ -834,6 +834,7 @@ INT WINAPI EnumMRUListW (HANDLE hList, INT nItemPos, LPVOID lpBuffer, const WINEMRUITEM *witem; INT desired, datasize; + if (!mp) return -1; if ((nItemPos < 0) || !lpBuffer) return mp->cursize; if (nItemPos >= mp->cursize) return -1; desired = mp->realMRU[nItemPos]; @@ -860,6 +861,7 @@ INT WINAPI EnumMRUListA (HANDLE hList, INT nItemPos, LPVOID lpBuffer, INT desired, datasize; DWORD lenA; + if (!mp) return -1; if ((nItemPos < 0) || !lpBuffer) return mp->cursize; if (nItemPos >= mp->cursize) return -1; desired = mp->realMRU[nItemPos]; diff --git a/dlls/comctl32/hotkey.c b/dlls/comctl32/hotkey.c index 165d95dad7b..a72b48752ec 100644 --- a/dlls/comctl32/hotkey.c +++ b/dlls/comctl32/hotkey.c @@ -239,10 +239,9 @@ HOTKEY_Create (HOTKEY_INFO *infoPtr, const CREATESTRUCTW *lpcs) static LRESULT HOTKEY_Destroy (HOTKEY_INFO *infoPtr) { - HWND hwnd = infoPtr->hwndSelf; /* free hotkey info data */ + SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0); Free (infoPtr); - SetWindowLongPtrW (hwnd, 0, 0); return 0; } diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 8ddaf3d405a..1c84f0272db 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -137,7 +137,6 @@ * -- LVM_SORTGROUPS * * Macros: - * -- ListView_GetCheckSate, ListView_SetCheckState * -- ListView_GetHoverTime, ListView_SetHoverTime * -- ListView_GetISearchString * -- ListView_GetNumberOfWorkAreas @@ -776,20 +775,20 @@ static inline LRESULT notify_listview(const LISTVIEW_INFO *infoPtr, INT code, LP static BOOL notify_click(const LISTVIEW_INFO *infoPtr, INT code, const LVHITTESTINFO *lvht) { - NMLISTVIEW nmlv; + NMITEMACTIVATE nmia; LVITEMW item; HWND hwnd = infoPtr->hwndSelf; TRACE("code=%d, lvht=%s\n", code, debuglvhittestinfo(lvht)); - ZeroMemory(&nmlv, sizeof(nmlv)); - nmlv.iItem = lvht->iItem; - nmlv.iSubItem = lvht->iSubItem; - nmlv.ptAction = lvht->pt; + ZeroMemory(&nmia, sizeof(nmia)); + nmia.iItem = lvht->iItem; + nmia.iSubItem = lvht->iSubItem; + nmia.ptAction = lvht->pt; item.mask = LVIF_PARAM; item.iItem = lvht->iItem; item.iSubItem = 0; - if (LISTVIEW_GetItemT(infoPtr, &item, TRUE)) nmlv.lParam = item.lParam; - notify_listview(infoPtr, code, &nmlv); + if (LISTVIEW_GetItemT(infoPtr, &item, TRUE)) nmia.lParam = item.lParam; + notify_hdr(infoPtr, code, (LPNMHDR)&nmia); return IsWindow(hwnd); } @@ -1817,7 +1816,7 @@ static void LISTVIEW_ShowFocusRect(const LISTVIEW_INFO *infoPtr, BOOL fShow) if (infoPtr->nFocusedItem < 0) return; /* we need some gymnastics in ICON mode to handle large items */ - if ( (infoPtr->dwStyle & LVS_TYPEMASK) == LVS_ICON ) + if (uView == LVS_ICON) { RECT rcBox; @@ -1921,7 +1920,10 @@ static void LISTVIEW_GetItemOrigin(const LISTVIEW_INFO *infoPtr, INT nItem, LPPO } else /* LVS_REPORT */ { - lpptPosition->x = 0; + lpptPosition->x = REPORT_MARGINX; + /* item is always at zero indexed column */ + if (DPA_GetPtrCount(infoPtr->hdpaColumns) > 0) + lpptPosition->x += LISTVIEW_GetColumnInfo(infoPtr, 0)->rcHeader.left; lpptPosition->y = nItem * infoPtr->nItemHeight; } } @@ -2042,7 +2044,7 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW { Icon.left = Box.left + state_width; - if (uView == LVS_REPORT) + if (uView == LVS_REPORT && lpLVItem->iSubItem == 0) Icon.left += REPORT_MARGINX; Icon.top = Box.top; @@ -2143,7 +2145,7 @@ calc_label: Label.right = lpColumnInfo->rcHeader.right; Label.bottom = Label.top + infoPtr->nItemHeight; } - else /* LVS_SMALLICON, LVS_LIST or LVS_REPORT */ + else /* LVS_SMALLICON or LVS_LIST */ { Label.left = Icon.right; Label.top = Box.top; @@ -2373,6 +2375,7 @@ static BOOL LISTVIEW_Arrange(LISTVIEW_INFO *infoPtr, INT nAlignCode) /*** * DESCRIPTION: * Retrieves the bounding rectangle of all the items, not offset by Origin. + * For LVS_REPORT always returns empty rectangle. * * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure @@ -2413,11 +2416,6 @@ static void LISTVIEW_GetAreaRect(const LISTVIEW_INFO *infoPtr, LPRECT lprcView) lprcView->right = x * infoPtr->nItemWidth; lprcView->bottom = y * infoPtr->nItemHeight; break; - - case LVS_REPORT: - lprcView->right = infoPtr->nItemWidth; - lprcView->bottom = infoPtr->nItemCount * infoPtr->nItemHeight; - break; } } @@ -2440,10 +2438,14 @@ static BOOL LISTVIEW_GetViewRect(const LISTVIEW_INFO *infoPtr, LPRECT lprcView) TRACE("(lprcView=%p)\n", lprcView); if (!lprcView) return FALSE; - - LISTVIEW_GetOrigin(infoPtr, &ptOrigin); - LISTVIEW_GetAreaRect(infoPtr, lprcView); - OffsetRect(lprcView, ptOrigin.x, ptOrigin.y); + + LISTVIEW_GetAreaRect(infoPtr, lprcView); + + if ((infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) + { + LISTVIEW_GetOrigin(infoPtr, &ptOrigin); + OffsetRect(lprcView, ptOrigin.x, ptOrigin.y); + } TRACE("lprcView=%s\n", wine_dbgstr_rect(lprcView)); @@ -3269,18 +3271,14 @@ static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem, BOOL space) TRACE("nItem=%d, wShift=%d, wCtrl=%d\n", nItem, wShift, wCtrl); if ((nItem >= 0) && (nItem < infoPtr->nItemCount)) { - if (infoPtr->dwStyle & LVS_SINGLESEL) - { - bResult = TRUE; + bResult = TRUE; + + if (infoPtr->dwStyle & LVS_SINGLESEL || (wShift == 0 && wCtrl == 0)) LISTVIEW_SetSelection(infoPtr, nItem); - } else { if (wShift) - { - bResult = TRUE; LISTVIEW_SetGroupSelection(infoPtr, nItem); - } else if (wCtrl) { LVITEMW lvItem; @@ -3294,11 +3292,6 @@ static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem, BOOL space) } bResult = LISTVIEW_SetItemFocus(infoPtr, nItem); } - else - { - bResult = TRUE; - LISTVIEW_SetSelection(infoPtr, nItem); - } } LISTVIEW_EnsureVisible(infoPtr, nItem, FALSE); } @@ -3410,8 +3403,6 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN if (!PtInRect(&rect, tmp)) { - NMLISTVIEW nmlv; - /* this path covers the following: 1. WM_LBUTTONDOWN over selected item (sets focus on it) 2. change focus with keys @@ -3428,15 +3419,17 @@ static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, IN infoPtr->nLButtonDownItem = -1; } - lvHitTestInfo.pt = infoPtr->ptClickPos; - LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE); - - ZeroMemory(&nmlv, sizeof(nmlv)); - nmlv.iItem = lvHitTestInfo.iItem; - nmlv.ptAction = infoPtr->ptClickPos; - if (!infoPtr->bDragging) { + NMLISTVIEW nmlv; + + lvHitTestInfo.pt = infoPtr->ptClickPos; + LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE); + + ZeroMemory(&nmlv, sizeof(nmlv)); + nmlv.iItem = lvHitTestInfo.iItem; + nmlv.ptAction = infoPtr->ptClickPos; + notify_listview(infoPtr, LVN_BEGINDRAG, &nmlv); infoPtr->bDragging = TRUE; } @@ -4134,13 +4127,13 @@ static void LISTVIEW_RefreshReport(LISTVIEW_INFO *infoPtr, ITERATOR *i, HDC hdc, /* iterate through the invalidated rows */ while(iterator_next(i)) { + LISTVIEW_GetItemOrigin(infoPtr, i->nItem, &Position); + Position.x += Origin.x; + Position.y += Origin.y; + /* iterate through the invalidated columns */ while(iterator_next(&j)) { - LISTVIEW_GetItemOrigin(infoPtr, i->nItem, &Position); - Position.x += Origin.x; - Position.y += Origin.y; - if (rgntype == COMPLEXREGION && !((infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT) && j.nItem == 0)) { LISTVIEW_GetHeaderRect(infoPtr, j.nItem, &rcItem); @@ -4305,6 +4298,7 @@ static void LISTVIEW_Refresh(LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *prcEra ITERATOR i; HDC hdcOrig = hdc; HBITMAP hbmp = NULL; + RANGE range; LISTVIEW_DUMP(infoPtr); @@ -4370,11 +4364,11 @@ static void LISTVIEW_Refresh(LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *prcEra /* figure out what we need to draw */ iterator_visibleitems(&i, infoPtr, hdc); - + range = iterator_range(&i); + /* send cache hint notification */ if (infoPtr->dwStyle & LVS_OWNERDATA) { - RANGE range = iterator_range(&i); NMLVCACHEHINT nmlv; ZeroMemory(&nmlv, sizeof(NMLVCACHEHINT)); @@ -4392,8 +4386,9 @@ static void LISTVIEW_Refresh(LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *prcEra else /* LVS_LIST, LVS_ICON or LVS_SMALLICON */ LISTVIEW_RefreshList(infoPtr, &i, hdc, cdmode); - /* if we have a focus rect, draw it */ - if (infoPtr->bFocus) + /* if we have a focus rect and it's visible, draw it */ + if (infoPtr->bFocus && range.lower <= infoPtr->nFocusedItem && + (range.upper - 1) >= infoPtr->nFocusedItem) LISTVIEW_DrawFocusRect(infoPtr, hdc); } iterator_destroy(&i); @@ -5933,6 +5928,7 @@ static BOOL LISTVIEW_GetItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPRECT BOOL doLabel = TRUE, oversizedBox = FALSE; POINT Position, Origin; LVITEMW lvItem; + INT type; TRACE("(hwnd=%p, nItem=%d, lprc=%p)\n", infoPtr->hwndSelf, nItem, lprc); @@ -5967,6 +5963,7 @@ static BOOL LISTVIEW_GetItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPRECT lvItem.state = (oversizedBox ? LVIS_FOCUSED : 0); } + type = lprc->left; if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT) && lprc->left == LVIR_SELECTBOUNDS) lprc->left = LVIR_BOUNDS; switch(lprc->left) @@ -5992,7 +5989,10 @@ static BOOL LISTVIEW_GetItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPRECT return FALSE; } - OffsetRect(lprc, Position.x + Origin.x, Position.y + Origin.y); + if ((uView == LVS_REPORT) && (type == LVIR_BOUNDS)) + OffsetRect(lprc, Origin.x, Position.y + Origin.y); + else + OffsetRect(lprc, Position.x + Origin.x, Position.y + Origin.y); TRACE(" rect=%s\n", wine_dbgstr_rect(lprc)); @@ -6077,7 +6077,7 @@ static BOOL LISTVIEW_GetSubItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPR return FALSE; } - OffsetRect(lprc, Position.x, Position.y); + OffsetRect(lprc, 0, Position.y); return TRUE; } @@ -6543,7 +6543,7 @@ static INT LISTVIEW_HitTest(const LISTVIEW_INFO *infoPtr, LPLVHITTESTINFO lpht, INT j; /* for top/bottom only */ - bounds.left = 0; + bounds.left = LVIR_BOUNDS; LISTVIEW_GetItemRect(infoPtr, iItem, &bounds); for (j = 0; j < DPA_GetPtrCount(infoPtr->hdpaColumns); j++) @@ -6591,7 +6591,7 @@ static INT LISTVIEW_HitTest(const LISTVIEW_INFO *infoPtr, LPLVHITTESTINFO lpht, lpht->flags |= LVHT_ONITEMICON; else if (PtInRect(&rcLabel, opt)) lpht->flags |= LVHT_ONITEMLABEL; - else if (infoPtr->himlState && STATEIMAGEINDEX(lvItem.state) && PtInRect(&rcState, opt)) + else if (infoPtr->himlState && PtInRect(&rcState, opt)) lpht->flags |= LVHT_ONITEMSTATEICON; /* special case for LVS_EX_FULLROWSELECT */ if (uView == LVS_REPORT && infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT && @@ -9629,7 +9629,7 @@ static void LISTVIEW_UpdateSize(LISTVIEW_INFO *infoPtr) * The "2" is there to mimic the native control. I think it may be * related to either padding or edges. (GLA 7/2002) */ - if (!(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_HSCROLL)) + if (!(infoPtr->dwStyle & WS_HSCROLL)) infoPtr->rcList.bottom -= GetSystemMetrics(SM_CYHSCROLL); infoPtr->rcList.bottom = max (infoPtr->rcList.bottom - 2, 0); } diff --git a/dlls/comctl32/tests/ipaddress.c b/dlls/comctl32/tests/ipaddress.c index d04223cb4fc..85f92b1d582 100644 --- a/dlls/comctl32/tests/ipaddress.c +++ b/dlls/comctl32/tests/ipaddress.c @@ -33,8 +33,6 @@ static HWND create_ipaddress_control (void) handle = CreateWindowEx(0, WC_IPADDRESS, NULL, WS_BORDER|WS_VISIBLE, 0, 0, 0, 0, NULL, NULL, NULL, NULL); - assert(handle); - return handle; } @@ -45,6 +43,11 @@ static void test_get_set_text(void) INT r; hwnd = create_ipaddress_control(); + if (!hwnd) + { + win_skip("IPAddress control not implemented\n"); + return; + } /* check text just after creation */ r = GetWindowText(hwnd, ip, sizeof(ip)/sizeof(CHAR)); diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index d3e4ee86509..217c2eec276 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -185,6 +185,17 @@ static const struct message single_getdispinfo_parent_seq[] = { { 0 } }; +static const struct message getitemposition_seq1[] = { + { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID }, + { 0 } +}; + +static const struct message getitemposition_seq2[] = { + { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID }, + { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID }, + { 0 } +}; + struct subclass_info { WNDPROC oldproc; @@ -1734,7 +1745,7 @@ todo_wine item.stateMask = LVIS_SELECTED; r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item); expect(TRUE, r); - ListView_SetSelectionMark(hwnd, -1); + SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1); item.stateMask = LVIS_SELECTED; item.state = LVIS_SELECTED; @@ -1816,6 +1827,35 @@ todo_wine todo_wine expect(3, rect.top); + /* item LVS_REPORT padding isn't applied to subitems */ + insert_item(hwnd, 0); + + rect.left = LVIR_BOUNDS; + rect.top = 1; + rect.right = rect.bottom = 0; + r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect); + ok(r != 0, "Expected not-null LRESULT\n"); + expect(100, rect.left); + expect(250, rect.right); + + rect.left = LVIR_ICON; + rect.top = 1; + rect.right = rect.bottom = 0; + r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect); + ok(r != 0, "Expected not-null LRESULT\n"); + /* no icon attached - zero width rectangle, with no left padding */ + expect(100, rect.left); + expect(100, rect.right); + + rect.left = LVIR_LABEL; + rect.top = 1; + rect.right = rect.bottom = 0; + r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect); + ok(r != 0, "Expected not-null LRESULT\n"); + /* same as full LVIR_BOUNDS */ + expect(100, rect.left); + expect(250, rect.right); + DestroyWindow(hwnd); /* try it for non LVS_REPORT style */ @@ -2389,13 +2429,17 @@ static void test_hittest(void) y = pos.y + (bounds.bottom - bounds.top) / 2; test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__); test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, TRUE, TRUE, TRUE, __LINE__); - /* try with icons */ + /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */ himl = ImageList_Create(16, 16, 0, 4, 4); ok(himl != NULL, "failed to create imagelist\n"); hbmp = CreateBitmap(16, 16, 1, 1, NULL); ok(hbmp != NULL, "failed to create bitmap\n"); r = ImageList_Add(himl, hbmp, 0); ok(r == 0, "should be zero\n"); + hbmp = CreateBitmap(16, 16, 1, 1, NULL); + ok(hbmp != NULL, "failed to create bitmap\n"); + r = ImageList_Add(himl, hbmp, 0); + ok(r == 1, "should be one\n"); r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl); ok(r == 0, "should return zero\n"); @@ -2407,10 +2451,24 @@ static void test_hittest(void) r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item); expect(TRUE, r); /* on state icon */ - x = pos.x + 8; /* outside column */ + x = pos.x + 8; y = pos.y + (bounds.bottom - bounds.top) / 2; - test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, TRUE, __LINE__); - test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, TRUE, __LINE__); + test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, __LINE__); + test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__); + + /* state icons indices are 1 based, check with valid index */ + item.mask = LVIF_STATE; + item.state = INDEXTOSTATEIMAGEMASK(1); + item.stateMask = LVIS_STATEIMAGEMASK; + item.iItem = 0; + item.iSubItem = 0; + r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item); + expect(TRUE, r); + /* on state icon */ + x = pos.x + 8; + y = pos.y + (bounds.bottom - bounds.top) / 2; + test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, __LINE__); + test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__); himl2 = (HIMAGELIST)SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)NULL); ok(himl2 == himl, "should return handle\n"); @@ -2418,7 +2476,7 @@ static void test_hittest(void) r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl); ok(r == 0, "should return zero\n"); /* on item icon */ - x = pos.x + 8; /* outside column */ + x = pos.x + 8; y = pos.y + (bounds.bottom - bounds.top) / 2; test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMICON, FALSE, FALSE, __LINE__); test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMICON, FALSE, FALSE, FALSE, __LINE__); @@ -2426,6 +2484,202 @@ static void test_hittest(void) DestroyWindow(hwnd); } +static void test_getviewrect(void) +{ + HWND hwnd; + DWORD r; + RECT rect; + LVITEMA item; + + hwnd = create_listview_control(0); + ok(hwnd != NULL, "failed to create a listview window\n"); + + /* empty */ + r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + + insert_column(hwnd, 0); + insert_column(hwnd, 1); + + memset(&item, 0, sizeof(item)); + item.iItem = 0; + item.iSubItem = 0; + SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item); + + r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0)); + expect(TRUE, r); + r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(120, 0)); + expect(TRUE, r); + + rect.left = rect.right = rect.top = rect.bottom = -1; + r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + /* left is set to (2e31-1) - XP SP2 */ + expect(0, rect.right); + expect(0, rect.top); + expect(0, rect.bottom); + + /* switch to LVS_ICON */ + SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~LVS_REPORT); + + rect.left = rect.right = rect.top = rect.bottom = -1; + r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + expect(0, rect.left); + expect(0, rect.top); + /* precise value differs for 2k, XP and Vista */ + ok(rect.bottom > 0, "Expected positive bottom value, got %d\n", rect.bottom); + ok(rect.right > 0, "Expected positive right value, got %d\n", rect.right); + + DestroyWindow(hwnd); +} + +static void test_getitemposition(void) +{ + HWND hwnd, header; + DWORD r; + POINT pt; + RECT rect; + + hwnd = create_listview_control(0); + ok(hwnd != NULL, "failed to create a listview window\n"); + header = subclass_header(hwnd); + + /* LVS_REPORT, single item, no columns added */ + insert_item(hwnd, 0); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + + pt.x = pt.y = -1; + r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt); + expect(TRUE, r); + ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq1, "get item position 1", FALSE); + + /* LVS_REPORT, single item, single column */ + insert_column(hwnd, 0); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + + pt.x = pt.y = -1; + r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt); + expect(TRUE, r); + ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq2, "get item position 2", TRUE); + + memset(&rect, 0, sizeof(rect)); + SendMessage(header, HDM_GETITEMRECT, 0, (LPARAM)&rect); + /* some padding? */ + expect(2, pt.x); + /* offset by header height */ + expect(rect.bottom - rect.top, pt.y); + + DestroyWindow(hwnd); +} + +static void test_columnscreation(void) +{ + HWND hwnd, header; + DWORD r; + + hwnd = create_listview_control(0); + ok(hwnd != NULL, "failed to create a listview window\n"); + + insert_item(hwnd, 0); + + /* headers columns aren't created automatically */ + header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0); + ok(IsWindow(header), "Expected header handle\n"); + r = SendMessage(header, HDM_GETITEMCOUNT, 0, 0); + expect(0, r); + + DestroyWindow(hwnd); +} + +static void test_getitemrect(void) +{ + HWND hwnd; + RECT rect; + DWORD r; + LVITEMA item; + LVCOLUMNA col; + INT order[2]; + POINT pt; + + hwnd = create_listview_control(0); + ok(hwnd != NULL, "failed to create a listview window\n"); + + /* empty item */ + memset(&item, 0, sizeof(item)); + item.iItem = 0; + item.iSubItem = 0; + r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item); + expect(0, r); + + rect.left = LVIR_BOUNDS; + rect.right = rect.top = rect.bottom = -1; + r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + + /* zero width rectangle with no padding */ + expect(0, rect.left); + todo_wine expect(0, rect.right); + + insert_column(hwnd, 0); + insert_column(hwnd, 1); + + col.mask = LVCF_WIDTH; + col.cx = 50; + r = SendMessage(hwnd, LVM_SETCOLUMN, 0, (LPARAM)&col); + expect(TRUE, r); + + col.mask = LVCF_WIDTH; + col.cx = 100; + r = SendMessage(hwnd, LVM_SETCOLUMN, 1, (LPARAM)&col); + expect(TRUE, r); + + rect.left = LVIR_BOUNDS; + rect.right = rect.top = rect.bottom = -1; + r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + + /* still no left padding */ + expect(0, rect.left); + expect(150, rect.right); + + rect.left = LVIR_SELECTBOUNDS; + rect.right = rect.top = rect.bottom = -1; + r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + /* padding */ + todo_wine expect(2, rect.left); + + /* change order */ + order[0] = 1; order[1] = 0; + r = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order); + expect(TRUE, r); + pt.x = -1; + r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt); + expect(TRUE, r); + /* 1 indexed column width + padding */ + todo_wine expect(102, pt.x); + /* rect is at zero too */ + rect.left = LVIR_BOUNDS; + rect.right = rect.top = rect.bottom = -1; + r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + expect(0, rect.left); + /* just width sum */ + expect(150, rect.right); + + rect.left = LVIR_SELECTBOUNDS; + rect.right = rect.top = rect.bottom = -1; + r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect); + expect(TRUE, r); + /* column width + padding */ + todo_wine expect(102, rect.left); + + DestroyWindow(hwnd); +} + START_TEST(listview) { HMODULE hComctl32; @@ -2463,6 +2717,7 @@ START_TEST(listview) test_columns(); test_getorigin(); test_multiselect(); + test_getitemrect(); test_subitem_rect(); test_sorting(); test_ownerdata(); @@ -2470,6 +2725,9 @@ START_TEST(listview) test_nosortheader(); test_setredraw(); test_hittest(); + test_getviewrect(); + test_getitemposition(); + test_columnscreation(); DestroyWindow(hwndparent); } diff --git a/dlls/comctl32/tests/mru.c b/dlls/comctl32/tests/mru.c index 8ebec86f148..c4da87b1dd5 100644 --- a/dlls/comctl32/tests/mru.c +++ b/dlls/comctl32/tests/mru.c @@ -69,11 +69,27 @@ static HANDLE (WINAPI *pCreateMRUListA)(LPCREATEMRULISTA); static void (WINAPI *pFreeMRUList)(HANDLE); static INT (WINAPI *pAddMRUStringA)(HANDLE,LPCSTR); static INT (WINAPI *pEnumMRUList)(HANDLE,INT,LPVOID,DWORD); +static INT (WINAPI *pEnumMRUListW)(HANDLE,INT,LPVOID,DWORD); +static HANDLE (WINAPI *pCreateMRUListLazyA)(LPCREATEMRULISTA, DWORD, DWORD, DWORD); +static INT (WINAPI *pFindMRUData)(HANDLE, LPCVOID, DWORD, LPINT); +static INT (WINAPI *pAddMRUData)(HANDLE, LPCVOID, DWORD); /* static INT (WINAPI *pFindMRUStringA)(HANDLE,LPCSTR,LPINT); */ +static void InitPointers(void) +{ + pCreateMRUListA = (void*)GetProcAddress(hComctl32,(LPCSTR)151); + pFreeMRUList = (void*)GetProcAddress(hComctl32,(LPCSTR)152); + pAddMRUStringA = (void*)GetProcAddress(hComctl32,(LPCSTR)153); + pEnumMRUList = (void*)GetProcAddress(hComctl32,(LPCSTR)154); + pCreateMRUListLazyA = (void*)GetProcAddress(hComctl32,(LPCSTR)157); + pAddMRUData = (void*)GetProcAddress(hComctl32,(LPCSTR)167); + pFindMRUData = (void*)GetProcAddress(hComctl32,(LPCSTR)169); + pEnumMRUListW = (void*)GetProcAddress(hComctl32,(LPCSTR)403); +} + /* Based on RegDeleteTreeW from dlls/advapi32/registry.c */ static LSTATUS mru_RegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey) { @@ -227,11 +243,6 @@ static void test_MRUListA(void) HKEY hKey; INT iRet; - pCreateMRUListA = (void*)GetProcAddress(hComctl32,(LPCSTR)151); - pFreeMRUList = (void*)GetProcAddress(hComctl32,(LPCSTR)152); - pAddMRUStringA = (void*)GetProcAddress(hComctl32,(LPCSTR)153); - pEnumMRUList = (void*)GetProcAddress(hComctl32,(LPCSTR)154); - if (!pCreateMRUListA || !pFreeMRUList || !pAddMRUStringA || !pEnumMRUList) { skip("MRU entry points not found\n"); @@ -413,6 +424,91 @@ static void test_MRUListA(void) /* FreeMRUList(NULL) crashes on Win98 OSR0 */ } +static void test_CreateMRUListLazyA(void) +{ + HANDLE hMRU; + HKEY hKey; + CREATEMRULISTA listA = { 0 }; + + if (!pCreateMRUListLazyA || !pFreeMRUList) + { + win_skip("CreateMRUListLazyA or FreeMRUList entry points not found\n"); + return; + } + + /* wrong size */ + listA.cbSize = sizeof(listA) + 1; + hMRU = pCreateMRUListLazyA(&listA, 0, 0, 0); + ok(hMRU == NULL, "Expected NULL handle, got %p\n", hMRU); + listA.cbSize = 4; + hMRU = pCreateMRUListLazyA(&listA, 0, 0, 0); + ok(hMRU == NULL, "Expected NULL handle, got %p\n", hMRU); + /* NULL hKey */ + listA.cbSize = sizeof(listA); + listA.hKey = NULL; + hMRU = pCreateMRUListLazyA(&listA, 0, 0, 0); + ok(hMRU == NULL, "Expected NULL handle, got %p\n", hMRU); + /* NULL subkey */ + ok(!RegCreateKeyA(HKEY_CURRENT_USER, REG_TEST_KEYA, &hKey), + "Couldn't create test key \"%s\"\n", REG_TEST_KEYA); + listA.cbSize = sizeof(listA); + listA.hKey = hKey; + listA.lpszSubKey = NULL; + hMRU = pCreateMRUListLazyA(&listA, 0, 0, 0); + ok(hMRU == NULL || broken(hMRU != NULL), /* Win9x */ + "Expected NULL handle, got %p\n", hMRU); + if (hMRU) pFreeMRUList(hMRU); +} + +static void test_EnumMRUList(void) +{ + if (!pEnumMRUList || !pEnumMRUListW) + { + win_skip("EnumMRUListA/EnumMRUListW entry point not found\n"); + return; + } + + /* NULL handle */ + if (0) + { + INT iRet; + + /* crashes on NT4, passed on Win2k, XP, 2k3, Vista, 2k8 */ + iRet = pEnumMRUList(NULL, 0, NULL, 0); + iRet = pEnumMRUListW(NULL, 0, NULL, 0); + } +} + +static void test_FindMRUData(void) +{ + INT iRet; + + if (!pFindMRUData) + { + win_skip("FindMRUData entry point not found\n"); + return; + } + + /* NULL handle */ + iRet = pFindMRUData(NULL, NULL, 0, NULL); + ok(iRet == -1, "FindMRUData expected -1, got %d\n", iRet); +} + +static void test_AddMRUData(void) +{ + INT iRet; + + if (!pAddMRUData) + { + win_skip("AddMRUData entry point not found\n"); + return; + } + + /* NULL handle */ + iRet = pFindMRUData(NULL, NULL, 0, NULL); + ok(iRet == -1, "AddMRUData expected -1, got %d\n", iRet); +} + START_TEST(mru) { hComctl32 = GetModuleHandleA("comctl32.dll"); @@ -421,7 +517,13 @@ START_TEST(mru) if (!create_reg_entries()) return; + InitPointers(); + test_MRUListA(); + test_CreateMRUListLazyA(); + test_EnumMRUList(); + test_FindMRUData(); + test_AddMRUData(); delete_reg_entries(); } diff --git a/dlls/comctl32/tests/tooltips.c b/dlls/comctl32/tests/tooltips.c index 2b4f43ffd1b..6a927aa28e8 100644 --- a/dlls/comctl32/tests/tooltips.c +++ b/dlls/comctl32/tests/tooltips.c @@ -232,14 +232,63 @@ static void test_customdraw(void) { } +static const CHAR testcallbackA[] = "callback"; + +static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_NOTIFY && lParam) + { + NMTTDISPINFOA *ttnmdi = (NMTTDISPINFOA*)lParam; + + if (ttnmdi->hdr.code == TTN_GETDISPINFOA) + lstrcpy(ttnmdi->lpszText, testcallbackA); + } + + return DefWindowProcA(hwnd, message, wParam, lParam); +} + +static BOOL register_parent_wnd_class(void) +{ + WNDCLASSA cls; + + cls.style = 0; + cls.lpfnWndProc = parent_wnd_proc; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(NULL); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "Tooltips test parent class"; + return RegisterClassA(&cls); +} + +static HWND create_parent_window(void) +{ + if (!register_parent_wnd_class()) + return NULL; + + return CreateWindowEx(0, "Tooltips test parent class", + "Tooltips test parent window", + WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | + WS_MAXIMIZEBOX | WS_VISIBLE, + 0, 0, 100, 100, + GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL); +} + static void test_gettext(void) { - HWND hwnd; + HWND hwnd, notify; TTTOOLINFOA toolinfoA; TTTOOLINFOW toolinfoW; LRESULT r; - char bufA[10] = ""; + CHAR bufA[10] = ""; WCHAR bufW[10] = { 0 }; + static const CHAR testtipA[] = "testtip"; + + notify = create_parent_window(); + ok(notify != NULL, "Expected notification window to be created\n"); /* For bug 14790 - lpszText is NULL */ hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, @@ -266,7 +315,58 @@ static void test_gettext(void) ok(strcmp(toolinfoA.lpszText, "") == 0, "lpszText should be an empty string\n"); } + /* add another tool with text */ + toolinfoA.cbSize = sizeof(TTTOOLINFOA); + toolinfoA.hwnd = NULL; + toolinfoA.hinst = GetModuleHandleA(NULL); + toolinfoA.uFlags = 0; + toolinfoA.uId = 0x1235ABCD; + strcpy(bufA, testtipA); + toolinfoA.lpszText = bufA; + toolinfoA.lParam = 0xdeadbeef; + GetClientRect(hwnd, &toolinfoA.rect); + r = SendMessageA(hwnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfoA); + ok(r, "Adding the tool to the tooltip failed\n"); + if (r) + { + DWORD length; + + length = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0); + ok(length == 0, "Expected 0, got %d\n", length); + + toolinfoA.hwnd = NULL; + toolinfoA.uId = 0x1235ABCD; + toolinfoA.lpszText = bufA; + SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); + ok(strcmp(toolinfoA.lpszText, testtipA) == 0, "lpszText should be an empty string\n"); + + length = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0); + ok(length == 0, "Expected 0, got %d\n", length); + } + + /* add another with callback text */ + toolinfoA.cbSize = sizeof(TTTOOLINFOA); + toolinfoA.hwnd = notify; + toolinfoA.hinst = GetModuleHandleA(NULL); + toolinfoA.uFlags = 0; + toolinfoA.uId = 0x1236ABCD; + toolinfoA.lpszText = LPSTR_TEXTCALLBACKA; + toolinfoA.lParam = 0xdeadbeef; + GetClientRect(hwnd, &toolinfoA.rect); + r = SendMessageA(hwnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfoA); + ok(r, "Adding the tool to the tooltip failed\n"); + if (r) + { + toolinfoA.hwnd = notify; + toolinfoA.uId = 0x1236ABCD; + toolinfoA.lpszText = bufA; + SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA); + ok(strcmp(toolinfoA.lpszText, testcallbackA) == 0, + "lpszText should be an (%s) string\n", testcallbackA); + } + DestroyWindow(hwnd); + DestroyWindow(notify); SetLastError(0xdeadbeef); hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0, diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index 05a52373ac3..73b34e46305 100644 --- a/dlls/comctl32/tests/treeview.c +++ b/dlls/comctl32/tests/treeview.c @@ -276,7 +276,8 @@ static void TestCallback(void) CHAR buf[128]; LRESULT ret; - TreeView_DeleteAllItems(hTree); + ret = TreeView_DeleteAllItems(hTree); + ok(ret == TRUE, "ret\n"); ins.hParent = TVI_ROOT; ins.hInsertAfter = TVI_ROOT; U(ins).item.mask = TVIF_TEXT; @@ -301,7 +302,8 @@ static void TestCallback(void) assert(hItem1); tvi.hItem = hItem1; - TreeView_GetItem(hTree, &tvi); + ret = TreeView_GetItem(hTree, &tvi); + ok(ret == TRUE, "ret\n"); ok(strcmp(tvi.pszText, test_string) == 0, "Item text mismatch %s vs %s\n", tvi.pszText, test_string); @@ -310,7 +312,8 @@ static void TestCallback(void) ret = TreeView_SetItem(hTree, &tvi); ok(ret == 1, "Expected SetItem return 1, got %ld\n", ret); tvi.pszText = buf; - TreeView_GetItem(hTree, &tvi); + ret = TreeView_GetItem(hTree, &tvi); + ok(ret == TRUE, "Expected GetItem return TRUE, got %ld\n", ret); ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n", tvi.pszText, TEST_CALLBACK_TEXT); @@ -319,7 +322,8 @@ static void TestCallback(void) assert(hItem2); tvi.hItem = hItem2; memset(buf, 0, sizeof(buf)); - TreeView_GetItem(hTree, &tvi); + ret = TreeView_GetItem(hTree, &tvi); + ok(ret == TRUE, "Expected GetItem return TRUE, got %ld\n", ret); ok(strcmp(tvi.pszText, TEST_CALLBACK_TEXT) == 0, "Item text mismatch %s vs %s\n", tvi.pszText, TEST_CALLBACK_TEXT); } @@ -755,6 +759,7 @@ static void TestExpandInvisible(void) HTREEITEM node[5]; RECT dummyRect; BOOL nodeVisible; + LRESULT ret; /* The test builds the following tree and expands then node 1, while node 0 is collapsed. * @@ -766,8 +771,8 @@ static void TestExpandInvisible(void) * */ - TreeView_DeleteAllItems(hTree); - + ret = TreeView_DeleteAllItems(hTree); + ok(ret == TRUE, "ret\n"); ins.hParent = TVI_ROOT; ins.hInsertAfter = TVI_ROOT; U(ins).item.mask = TVIF_TEXT; diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 06bf2399fc6..5a0344fc4ff 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -5322,8 +5322,8 @@ TOOLBAR_Destroy (TOOLBAR_INFO *infoPtr) CloseThemeData (GetWindowTheme (infoPtr->hwndSelf)); /* free toolbar info data */ - Free (infoPtr); SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0); + Free (infoPtr); return 0; } diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index fc9052eb4bc..9d7c327502a 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -123,6 +123,7 @@ typedef struct typedef struct { + HWND hwndSelf; WCHAR szTipText[INFOTIPSIZE]; BOOL bActive; BOOL bTrackActive; @@ -241,24 +242,23 @@ TOOLTIPS_notify_customdraw (DWORD dwDrawStage, NMTTCUSTOMDRAW *lpnmttcd) } static void -TOOLTIPS_Refresh (HWND hwnd, HDC hdc) +TOOLTIPS_Refresh (const TOOLTIPS_INFO *infoPtr, HDC hdc) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd); RECT rc; INT oldBkMode; HFONT hOldFont; HBRUSH hBrush; UINT uFlags = DT_EXTERNALLEADING; HRGN hRgn = NULL; - DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE); + DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); NMTTCUSTOMDRAW nmttcd; DWORD cdmode; if (infoPtr->nMaxTipWidth > -1) uFlags |= DT_WORDBREAK; - if (GetWindowLongW (hwnd, GWL_STYLE) & TTS_NOPREFIX) + if (GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX; - GetClientRect (hwnd, &rc); + GetClientRect (infoPtr->hwndSelf, &rc); hBrush = CreateSolidBrush(infoPtr->clrBk); @@ -268,7 +268,7 @@ TOOLTIPS_Refresh (HWND hwnd, HDC hdc) /* Custom draw - Call PrePaint once initial properties set up */ /* Note: Contrary to MSDN, CDRF_SKIPDEFAULT still draws a tooltip */ - TOOLTIPS_customdraw_fill(&nmttcd, hwnd, hdc, &rc, uFlags); + TOOLTIPS_customdraw_fill(&nmttcd, infoPtr->hwndSelf, hdc, &rc, uFlags); cdmode = TOOLTIPS_notify_customdraw(CDDS_PREPAINT, &nmttcd); uFlags = nmttcd.uDrawFlags; @@ -277,7 +277,7 @@ TOOLTIPS_Refresh (HWND hwnd, HDC hdc) /* create a region to store result into */ hRgn = CreateRectRgn(0, 0, 0, 0); - GetWindowRgn(hwnd, hRgn); + GetWindowRgn(infoPtr->hwndSelf, hRgn); /* fill the background */ FillRgn(hdc, hRgn, hBrush); @@ -359,13 +359,13 @@ TOOLTIPS_Refresh (HWND hwnd, HDC hdc) DeleteObject(hRgn); } -static void TOOLTIPS_GetDispInfoA(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO *toolPtr) +static void TOOLTIPS_GetDispInfoA(const TOOLTIPS_INFO *infoPtr, TTTOOL_INFO *toolPtr, WCHAR *buffer) { NMTTDISPINFOA ttnmdi; /* fill NMHDR struct */ ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA)); - ttnmdi.hdr.hwndFrom = hwnd; + ttnmdi.hdr.hwndFrom = infoPtr->hwndSelf; ttnmdi.hdr.idFrom = toolPtr->uId; ttnmdi.hdr.code = TTN_GETDISPINFOA; /* == TTN_NEEDTEXTA */ ttnmdi.lpszText = ttnmdi.szText; @@ -377,51 +377,51 @@ static void TOOLTIPS_GetDispInfoA(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO if (IS_INTRESOURCE(ttnmdi.lpszText)) { LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText), - infoPtr->szTipText, INFOTIPSIZE); + buffer, INFOTIPSIZE); if (ttnmdi.uFlags & TTF_DI_SETITEM) { toolPtr->hinst = ttnmdi.hinst; toolPtr->lpszText = (LPWSTR)ttnmdi.lpszText; } } else if (ttnmdi.lpszText == 0) { - infoPtr->szTipText[0] = '\0'; + buffer[0] = '\0'; } else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) { - Str_GetPtrAtoW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE); + Str_GetPtrAtoW(ttnmdi.lpszText, buffer, INFOTIPSIZE); if (ttnmdi.uFlags & TTF_DI_SETITEM) { toolPtr->hinst = 0; toolPtr->lpszText = NULL; - Str_SetPtrW(&toolPtr->lpszText, infoPtr->szTipText); + Str_SetPtrW(&toolPtr->lpszText, buffer); } } else { ERR("recursive text callback!\n"); - infoPtr->szTipText[0] = '\0'; + buffer[0] = '\0'; } /* no text available - try calling parent instead as per native */ /* FIXME: Unsure if SETITEM should save the value or not */ - if (infoPtr->szTipText[0] == 0x00) { + if (buffer[0] == 0x00) { SendMessageW(GetParent(toolPtr->hwnd), WM_NOTIFY, toolPtr->uId, (LPARAM)&ttnmdi); if (IS_INTRESOURCE(ttnmdi.lpszText)) { LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText), - infoPtr->szTipText, INFOTIPSIZE); + buffer, INFOTIPSIZE); } else if (ttnmdi.lpszText && ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) { - Str_GetPtrAtoW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE); + Str_GetPtrAtoW(ttnmdi.lpszText, buffer, INFOTIPSIZE); } } } -static void TOOLTIPS_GetDispInfoW(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO *toolPtr) +static void TOOLTIPS_GetDispInfoW(const TOOLTIPS_INFO *infoPtr, TTTOOL_INFO *toolPtr, WCHAR *buffer) { NMTTDISPINFOW ttnmdi; /* fill NMHDR struct */ ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOW)); - ttnmdi.hdr.hwndFrom = hwnd; + ttnmdi.hdr.hwndFrom = infoPtr->hwndSelf; ttnmdi.hdr.idFrom = toolPtr->uId; ttnmdi.hdr.code = TTN_GETDISPINFOW; /* == TTN_NEEDTEXTW */ ttnmdi.lpszText = ttnmdi.szText; @@ -433,47 +433,47 @@ static void TOOLTIPS_GetDispInfoW(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO if (IS_INTRESOURCE(ttnmdi.lpszText)) { LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText), - infoPtr->szTipText, INFOTIPSIZE); + buffer, INFOTIPSIZE); if (ttnmdi.uFlags & TTF_DI_SETITEM) { toolPtr->hinst = ttnmdi.hinst; toolPtr->lpszText = ttnmdi.lpszText; } } else if (ttnmdi.lpszText == 0) { - infoPtr->szTipText[0] = '\0'; + buffer[0] = '\0'; } else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) { - Str_GetPtrW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE); + Str_GetPtrW(ttnmdi.lpszText, buffer, INFOTIPSIZE); if (ttnmdi.uFlags & TTF_DI_SETITEM) { toolPtr->hinst = 0; toolPtr->lpszText = NULL; - Str_SetPtrW(&toolPtr->lpszText, infoPtr->szTipText); + Str_SetPtrW(&toolPtr->lpszText, buffer); } } else { ERR("recursive text callback!\n"); - infoPtr->szTipText[0] = '\0'; + buffer[0] = '\0'; } /* no text available - try calling parent instead as per native */ /* FIXME: Unsure if SETITEM should save the value or not */ - if (infoPtr->szTipText[0] == 0x00) { + if (buffer[0] == 0x00) { SendMessageW(GetParent(toolPtr->hwnd), WM_NOTIFY, toolPtr->uId, (LPARAM)&ttnmdi); if (IS_INTRESOURCE(ttnmdi.lpszText)) { LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText), - infoPtr->szTipText, INFOTIPSIZE); + buffer, INFOTIPSIZE); } else if (ttnmdi.lpszText && ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) { - Str_GetPtrW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE); + Str_GetPtrW(ttnmdi.lpszText, buffer, INFOTIPSIZE); } } } static void -TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool) +TOOLTIPS_GetTipText (const TOOLTIPS_INFO *infoPtr, INT nTool, WCHAR *buffer) { TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool]; @@ -482,35 +482,35 @@ TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool) TRACE("load res string %p %x\n", toolPtr->hinst, LOWORD(toolPtr->lpszText)); LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText), - infoPtr->szTipText, INFOTIPSIZE); + buffer, INFOTIPSIZE); } else if (toolPtr->lpszText) { if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) { if (toolPtr->bNotifyUnicode) - TOOLTIPS_GetDispInfoW(hwnd, infoPtr, toolPtr); + TOOLTIPS_GetDispInfoW(infoPtr, toolPtr, buffer); else - TOOLTIPS_GetDispInfoA(hwnd, infoPtr, toolPtr); + TOOLTIPS_GetDispInfoA(infoPtr, toolPtr, buffer); } else { /* the item is a usual (unicode) text */ - lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE); + lstrcpynW (buffer, toolPtr->lpszText, INFOTIPSIZE); } } else { /* no text available */ - infoPtr->szTipText[0] = '\0'; + buffer[0] = '\0'; } - TRACE("%s\n", debugstr_w(infoPtr->szTipText)); + TRACE("%s\n", debugstr_w(buffer)); } static void -TOOLTIPS_CalcTipSize (HWND hwnd, const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize) +TOOLTIPS_CalcTipSize (const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize) { HDC hdc; HFONT hOldFont; - DWORD style = GetWindowLongW(hwnd, GWL_STYLE); + DWORD style = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT; RECT rc = {0, 0, 0, 0}; SIZE title = {0, 0}; @@ -523,7 +523,7 @@ TOOLTIPS_CalcTipSize (HWND hwnd, const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize) uFlags |= DT_NOPREFIX; TRACE("%s\n", debugstr_w(infoPtr->szTipText)); - hdc = GetDC (hwnd); + hdc = GetDC (infoPtr->hwndSelf); if (infoPtr->pszTitle) { RECT rcTitle = {0, 0, 0, 0}; @@ -543,7 +543,7 @@ TOOLTIPS_CalcTipSize (HWND hwnd, const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize) hOldFont = SelectObject (hdc, infoPtr->hFont); DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags); SelectObject (hdc, hOldFont); - ReleaseDC (hwnd, hdc); + ReleaseDC (infoPtr->hwndSelf, hdc); if ((style & TTS_BALLOON) || infoPtr->pszTitle) { @@ -564,7 +564,7 @@ TOOLTIPS_CalcTipSize (HWND hwnd, const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize) static void -TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate) +TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) { TTTOOL_INFO *toolPtr; HMONITOR monitor; @@ -573,7 +573,7 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate) SIZE size; NMHDR hdr; int ptfx = 0; - DWORD style = GetWindowLongW(hwnd, GWL_STYLE); + DWORD style = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); INT nTool; if (track_activate) @@ -595,9 +595,9 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate) nTool = infoPtr->nTool; } - TRACE("Show tooltip pre %d! (%p)\n", nTool, hwnd); + TRACE("Show tooltip pre %d! (%p)\n", nTool, infoPtr->hwndSelf); - TOOLTIPS_GetTipText (hwnd, infoPtr, nTool); + TOOLTIPS_GetTipText (infoPtr, nTool, infoPtr->szTipText); if (infoPtr->szTipText[0] == '\0') return; @@ -609,14 +609,14 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate) TRACE("Show tooltip %d!\n", nTool); - hdr.hwndFrom = hwnd; + hdr.hwndFrom = infoPtr->hwndSelf; hdr.idFrom = toolPtr->uId; hdr.code = TTN_SHOW; SendMessageW (toolPtr->hwnd, WM_NOTIFY, toolPtr->uId, (LPARAM)&hdr); TRACE("%s\n", debugstr_w(infoPtr->szTipText)); - TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size); + TOOLTIPS_CalcTipSize (infoPtr, &size); TRACE("size %d x %d\n", size.cx, size.cy); if (track_activate) @@ -749,8 +749,8 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate) rect.top = rect.bottom - size.cy; } - AdjustWindowRectEx (&rect, GetWindowLongW (hwnd, GWL_STYLE), - FALSE, GetWindowLongW (hwnd, GWL_EXSTYLE)); + AdjustWindowRectEx (&rect, GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE), + FALSE, GetWindowLongW (infoPtr->hwndSelf, GWL_EXSTYLE)); if (style & TTS_BALLOON) { @@ -800,64 +800,64 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate) CombineRgn(hRgn, hRgn, hrStem, RGN_OR); DeleteObject(hrStem); - SetWindowRgn(hwnd, hRgn, FALSE); + SetWindowRgn(infoPtr->hwndSelf, hRgn, FALSE); /* we don't free the region handle as the system deletes it when * it is no longer needed */ } - SetWindowPos (hwnd, HWND_TOPMOST, rect.left, rect.top, + SetWindowPos (infoPtr->hwndSelf, HWND_TOPMOST, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_SHOWWINDOW | SWP_NOACTIVATE); /* repaint the tooltip */ - InvalidateRect(hwnd, NULL, TRUE); - UpdateWindow(hwnd); + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); + UpdateWindow(infoPtr->hwndSelf); if (!track_activate) { - SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); + SetTimer (infoPtr->hwndSelf, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); TRACE("timer 2 started!\n"); - SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0); + SetTimer (infoPtr->hwndSelf, ID_TIMERLEAVE, infoPtr->nReshowTime, 0); TRACE("timer 3 started!\n"); } } static void -TOOLTIPS_Hide (HWND hwnd, TOOLTIPS_INFO *infoPtr) +TOOLTIPS_Hide (TOOLTIPS_INFO *infoPtr) { TTTOOL_INFO *toolPtr; NMHDR hdr; - TRACE("Hide tooltip %d! (%p)\n", infoPtr->nCurrentTool, hwnd); + TRACE("Hide tooltip %d! (%p)\n", infoPtr->nCurrentTool, infoPtr->hwndSelf); if (infoPtr->nCurrentTool == -1) return; toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; - KillTimer (hwnd, ID_TIMERPOP); + KillTimer (infoPtr->hwndSelf, ID_TIMERPOP); - hdr.hwndFrom = hwnd; + hdr.hwndFrom = infoPtr->hwndSelf; hdr.idFrom = toolPtr->uId; hdr.code = TTN_POP; SendMessageW (toolPtr->hwnd, WM_NOTIFY, toolPtr->uId, (LPARAM)&hdr); infoPtr->nCurrentTool = -1; - SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, + SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); } static void -TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr) +TOOLTIPS_TrackShow (TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_Show(hwnd, infoPtr, TRUE); + TOOLTIPS_Show(infoPtr, TRUE); } static void -TOOLTIPS_TrackHide (HWND hwnd, const TOOLTIPS_INFO *infoPtr) +TOOLTIPS_TrackHide (const TOOLTIPS_INFO *infoPtr) { TTTOOL_INFO *toolPtr; NMHDR hdr; @@ -869,12 +869,12 @@ TOOLTIPS_TrackHide (HWND hwnd, const TOOLTIPS_INFO *infoPtr) toolPtr = &infoPtr->tools[infoPtr->nTrackTool]; - hdr.hwndFrom = hwnd; + hdr.hwndFrom = infoPtr->hwndSelf; hdr.idFrom = toolPtr->uId; hdr.code = TTN_POP; SendMessageW (toolPtr->hwnd, WM_NOTIFY, toolPtr->uId, (LPARAM)&hdr); - SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, + SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); } @@ -977,15 +977,14 @@ TOOLTIPS_IsWindowActive (HWND hwnd) static INT -TOOLTIPS_CheckTool (HWND hwnd, BOOL bShowTest) +TOOLTIPS_CheckTool (const TOOLTIPS_INFO *infoPtr, BOOL bShowTest) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); POINT pt; HWND hwndTool; INT nTool; GetCursorPos (&pt); - hwndTool = (HWND)SendMessageW (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt); + hwndTool = (HWND)SendMessageW (infoPtr->hwndSelf, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt); if (hwndTool == 0) return -1; @@ -994,8 +993,8 @@ TOOLTIPS_CheckTool (HWND hwnd, BOOL bShowTest) if (nTool == -1) return -1; - if (!(GetWindowLongW (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) { - if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER))) + if (!(GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) { + if (!TOOLTIPS_IsWindowActive (GetWindow (infoPtr->hwndSelf, GW_OWNER))) return -1; } @@ -1006,27 +1005,23 @@ TOOLTIPS_CheckTool (HWND hwnd, BOOL bShowTest) static LRESULT -TOOLTIPS_Activate (HWND hwnd, WPARAM wParam) +TOOLTIPS_Activate (TOOLTIPS_INFO *infoPtr, BOOL activate) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - - infoPtr->bActive = (BOOL)wParam; + infoPtr->bActive = activate; if (infoPtr->bActive) TRACE("activate!\n"); if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1)) - TOOLTIPS_Hide (hwnd, infoPtr); + TOOLTIPS_Hide (infoPtr); return 0; } static LRESULT -TOOLTIPS_AddToolA (HWND hwnd, LPARAM lParam) +TOOLTIPS_AddToolA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; TTTOOL_INFO *toolPtr; INT nResult; @@ -1036,7 +1031,7 @@ TOOLTIPS_AddToolA (HWND hwnd, LPARAM lParam) return FALSE; TRACE("add tool (%p) %p %ld%s!\n", - hwnd, lpToolInfo->hwnd, lpToolInfo->uId, + infoPtr->hwndSelf, lpToolInfo->hwnd, lpToolInfo->uId, (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : ""); if (infoPtr->uNumTools == 0) { @@ -1088,17 +1083,17 @@ TOOLTIPS_AddToolA (HWND hwnd, LPARAM lParam) if (toolPtr->uFlags & TTF_SUBCLASS) { if (toolPtr->uFlags & TTF_IDISHWND) { SetWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1, - (DWORD_PTR)hwnd); + (DWORD_PTR)infoPtr->hwndSelf); } else { SetWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1, - (DWORD_PTR)hwnd); + (DWORD_PTR)infoPtr->hwndSelf); } TRACE("subclassing installed!\n"); } nResult = (INT) SendMessageW (toolPtr->hwnd, WM_NOTIFYFORMAT, - (WPARAM)hwnd, (LPARAM)NF_QUERY); + (WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY); if (nResult == NFR_ANSI) { toolPtr->bNotifyUnicode = FALSE; TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n"); @@ -1114,10 +1109,8 @@ TOOLTIPS_AddToolA (HWND hwnd, LPARAM lParam) static LRESULT -TOOLTIPS_AddToolW (HWND hwnd, LPARAM lParam) +TOOLTIPS_AddToolW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; TTTOOL_INFO *toolPtr; INT nResult; @@ -1127,7 +1120,7 @@ TOOLTIPS_AddToolW (HWND hwnd, LPARAM lParam) return FALSE; TRACE("add tool (%p) %p %ld%s!\n", - hwnd, lpToolInfo->hwnd, lpToolInfo->uId, + infoPtr->hwndSelf, lpToolInfo->hwnd, lpToolInfo->uId, (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : ""); if (infoPtr->uNumTools == 0) { @@ -1178,17 +1171,17 @@ TOOLTIPS_AddToolW (HWND hwnd, LPARAM lParam) if (toolPtr->uFlags & TTF_SUBCLASS) { if (toolPtr->uFlags & TTF_IDISHWND) { SetWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1, - (DWORD_PTR)hwnd); + (DWORD_PTR)infoPtr->hwndSelf); } else { SetWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1, - (DWORD_PTR)hwnd); + (DWORD_PTR)infoPtr->hwndSelf); } TRACE("subclassing installed!\n"); } nResult = (INT) SendMessageW (toolPtr->hwnd, WM_NOTIFYFORMAT, - (WPARAM)hwnd, (LPARAM)NF_QUERY); + (WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY); if (nResult == NFR_ANSI) { toolPtr->bNotifyUnicode = FALSE; TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n"); @@ -1204,7 +1197,7 @@ TOOLTIPS_AddToolW (HWND hwnd, LPARAM lParam) static void -TOOLTIPS_DelToolCommon (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool) +TOOLTIPS_DelToolCommon (TOOLTIPS_INFO *infoPtr, INT nTool) { TTTOOL_INFO *toolPtr; @@ -1214,7 +1207,7 @@ TOOLTIPS_DelToolCommon (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool) return; /* make sure the tooltip has disappeared before deleting it */ - TOOLTIPS_Hide(hwnd, infoPtr); + TOOLTIPS_Hide(infoPtr); /* delete text string */ toolPtr = &infoPtr->tools[nTool]; @@ -1280,10 +1273,8 @@ TOOLTIPS_DelToolCommon (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool) } static LRESULT -TOOLTIPS_DelToolA (HWND hwnd, LPARAM lParam) +TOOLTIPS_DelToolA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; INT nTool; if (lpToolInfo == NULL) @@ -1295,17 +1286,15 @@ TOOLTIPS_DelToolA (HWND hwnd, LPARAM lParam) nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); - TOOLTIPS_DelToolCommon (hwnd, infoPtr, nTool); + TOOLTIPS_DelToolCommon (infoPtr, nTool); return 0; } static LRESULT -TOOLTIPS_DelToolW (HWND hwnd, LPARAM lParam) +TOOLTIPS_DelToolW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; INT nTool; if (lpToolInfo == NULL) @@ -1317,18 +1306,15 @@ TOOLTIPS_DelToolW (HWND hwnd, LPARAM lParam) nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); - TOOLTIPS_DelToolCommon (hwnd, infoPtr, nTool); + TOOLTIPS_DelToolCommon (infoPtr, nTool); return 0; } static LRESULT -TOOLTIPS_EnumToolsA (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_EnumToolsA (const TOOLTIPS_INFO *infoPtr, UINT uIndex, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - UINT uIndex = (UINT)wParam; - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; TTTOOL_INFO *toolPtr; if (lpToolInfo == NULL) @@ -1359,11 +1345,8 @@ TOOLTIPS_EnumToolsA (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_EnumToolsW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_EnumToolsW (const TOOLTIPS_INFO *infoPtr, UINT uIndex, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - UINT uIndex = (UINT)wParam; - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; TTTOOL_INFO *toolPtr; if (lpToolInfo == NULL) @@ -1393,10 +1376,8 @@ TOOLTIPS_EnumToolsW (HWND hwnd, WPARAM wParam, LPARAM lParam) } static LRESULT -TOOLTIPS_GetBubbleSize (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetBubbleSize (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; INT nTool; SIZE size; @@ -1410,17 +1391,15 @@ TOOLTIPS_GetBubbleSize (HWND hwnd, WPARAM wParam, LPARAM lParam) TRACE("tool %d\n", nTool); - TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size); + TOOLTIPS_CalcTipSize (infoPtr, &size); TRACE("size %d x %d\n", size.cx, size.cy); return MAKELRESULT(size.cx, size.cy); } static LRESULT -TOOLTIPS_GetCurrentToolA (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetCurrentToolA (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; TTTOOL_INFO *toolPtr; if (lpToolInfo) { @@ -1451,10 +1430,8 @@ TOOLTIPS_GetCurrentToolA (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_GetCurrentToolW (HWND hwnd, LPARAM lParam) +TOOLTIPS_GetCurrentToolW (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; TTTOOL_INFO *toolPtr; if (lpToolInfo) { @@ -1485,11 +1462,9 @@ TOOLTIPS_GetCurrentToolW (HWND hwnd, LPARAM lParam) static LRESULT -TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam) +TOOLTIPS_GetDelayTime (const TOOLTIPS_INFO *infoPtr, DWORD duration) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - - switch (wParam) { + switch (duration) { case TTDT_RESHOW: return infoPtr->nReshowTime; @@ -1501,7 +1476,7 @@ TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam) return infoPtr->nInitialTime; default: - WARN("Invalid wParam %lx\n", wParam); + WARN("Invalid duration flag %x\n", duration); break; } @@ -1510,11 +1485,8 @@ TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam) static LRESULT -TOOLTIPS_GetMargin (HWND hwnd, LPARAM lParam) +TOOLTIPS_GetMargin (const TOOLTIPS_INFO *infoPtr, LPRECT lpRect) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPRECT lpRect = (LPRECT)lParam; - lpRect->left = infoPtr->rcMargin.left; lpRect->right = infoPtr->rcMargin.right; lpRect->bottom = infoPtr->rcMargin.bottom; @@ -1525,19 +1497,16 @@ TOOLTIPS_GetMargin (HWND hwnd, LPARAM lParam) static inline LRESULT -TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetMaxTipWidth (const TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - return infoPtr->nMaxTipWidth; } static LRESULT -TOOLTIPS_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetTextA (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; + WCHAR buffer[INFOTIPSIZE]; INT nTool; if (lpToolInfo == NULL) @@ -1552,18 +1521,18 @@ TOOLTIPS_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) what size buffer it requires nor a way to specify how long the one it supplies is. We'll assume it's up to INFOTIPSIZE */ - WideCharToMultiByte(CP_ACP, 0, infoPtr->tools[nTool].lpszText, -1, - lpToolInfo->lpszText, INFOTIPSIZE, NULL, NULL); + buffer[0] = '\0'; + TOOLTIPS_GetTipText(infoPtr, nTool, buffer); + WideCharToMultiByte(CP_ACP, 0, buffer, -1, lpToolInfo->lpszText, + INFOTIPSIZE, NULL, NULL); return 0; } static LRESULT -TOOLTIPS_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetTextW (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; INT nTool; if (lpToolInfo == NULL) @@ -1577,41 +1546,37 @@ TOOLTIPS_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (infoPtr->tools[nTool].lpszText == NULL) return 0; - strcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText); + lpToolInfo->lpszText[0] = '\0'; + TOOLTIPS_GetTipText(infoPtr, nTool, lpToolInfo->lpszText); return 0; } static inline LRESULT -TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetTipBkColor (const TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); return infoPtr->clrBk; } static inline LRESULT -TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetTipTextColor (const TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); return infoPtr->clrText; } static inline LRESULT -TOOLTIPS_GetToolCount (HWND hwnd) +TOOLTIPS_GetToolCount (const TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); return infoPtr->uNumTools; } static LRESULT -TOOLTIPS_GetToolInfoA (HWND hwnd, LPARAM lParam) +TOOLTIPS_GetToolInfoA (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -1645,10 +1610,8 @@ TOOLTIPS_GetToolInfoA (HWND hwnd, LPARAM lParam) static LRESULT -TOOLTIPS_GetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_GetToolInfoW (const TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -1682,10 +1645,8 @@ TOOLTIPS_GetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_HitTestA (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_HitTestA (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOA lptthit) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTHITTESTINFOA lptthit = (LPTTHITTESTINFOA)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -1717,10 +1678,8 @@ TOOLTIPS_HitTestA (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_HitTestW (HWND hwnd, LPARAM lParam) +TOOLTIPS_HitTestW (const TOOLTIPS_INFO *infoPtr, LPTTHITTESTINFOW lptthit) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTHITTESTINFOW lptthit = (LPTTHITTESTINFOW)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -1752,10 +1711,8 @@ TOOLTIPS_HitTestW (HWND hwnd, LPARAM lParam) static LRESULT -TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_NewToolRectA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpti) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpti = (LPTTTOOLINFOA)lParam; INT nTool; if (lpti == NULL) @@ -1776,10 +1733,8 @@ TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_NewToolRectW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpti) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpti = (LPTTTOOLINFOW)lParam; INT nTool; if (lpti == NULL) @@ -1800,24 +1755,21 @@ TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam) static inline LRESULT -TOOLTIPS_Pop (HWND hwnd) +TOOLTIPS_Pop (TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - TOOLTIPS_Hide (hwnd, infoPtr); + TOOLTIPS_Hide (infoPtr); return 0; } static LRESULT -TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_RelayEvent (TOOLTIPS_INFO *infoPtr, LPMSG lpMsg) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPMSG lpMsg = (LPMSG)lParam; POINT pt; INT nOldTool; - if (lParam == 0) { + if (!lpMsg) { ERR("lpMsg == NULL!\n"); return 0; } @@ -1829,7 +1781,7 @@ TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam) case WM_MBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: - TOOLTIPS_Hide (hwnd, infoPtr); + TOOLTIPS_Hide (infoPtr); break; case WM_MOUSEMOVE: @@ -1838,34 +1790,34 @@ TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam) nOldTool = infoPtr->nTool; infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr, lpMsg->hwnd, &pt); - TRACE("tool (%p) %d %d %d\n", hwnd, nOldTool, + TRACE("tool (%p) %d %d %d\n", infoPtr->hwndSelf, nOldTool, infoPtr->nTool, infoPtr->nCurrentTool); - TRACE("WM_MOUSEMOVE (%p %d %d)\n", hwnd, pt.x, pt.y); + TRACE("WM_MOUSEMOVE (%p %d %d)\n", infoPtr->hwndSelf, pt.x, pt.y); if (infoPtr->nTool != nOldTool) { if(infoPtr->nTool == -1) { /* Moved out of all tools */ - TOOLTIPS_Hide(hwnd, infoPtr); - KillTimer(hwnd, ID_TIMERLEAVE); + TOOLTIPS_Hide(infoPtr); + KillTimer(infoPtr->hwndSelf, ID_TIMERLEAVE); } else if (nOldTool == -1) { /* Moved from outside */ if(infoPtr->bActive) { - SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0); + SetTimer(infoPtr->hwndSelf, ID_TIMERSHOW, infoPtr->nInitialTime, 0); TRACE("timer 1 started!\n"); } } else { /* Moved from one to another */ - TOOLTIPS_Hide (hwnd, infoPtr); - KillTimer(hwnd, ID_TIMERLEAVE); + TOOLTIPS_Hide (infoPtr); + KillTimer(infoPtr->hwndSelf, ID_TIMERLEAVE); if(infoPtr->bActive) { - SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0); + SetTimer (infoPtr->hwndSelf, ID_TIMERSHOW, infoPtr->nReshowTime, 0); TRACE("timer 1 started!\n"); } } } else if(infoPtr->nCurrentTool != -1) { /* restart autopop */ - KillTimer(hwnd, ID_TIMERPOP); - SetTimer(hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); + KillTimer(infoPtr->hwndSelf, ID_TIMERPOP); + SetTimer(infoPtr->hwndSelf, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); TRACE("timer 2 restarted\n"); } else if(infoPtr->nTool != -1 && infoPtr->bActive) { /* previous show attempt didn't result in tooltip so try again */ - SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0); + SetTimer(infoPtr->hwndSelf, ID_TIMERSHOW, infoPtr->nInitialTime, 0); TRACE("timer 1 started!\n"); } break; @@ -1876,12 +1828,9 @@ TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_SetDelayTime (TOOLTIPS_INFO *infoPtr, DWORD duration, INT nTime) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - INT nTime = (INT)LOWORD(lParam); - - switch (wParam) { + switch (duration) { case TTDT_AUTOMATIC: if (nTime <= 0) nTime = GetDoubleClickTime(); @@ -1909,7 +1858,7 @@ TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam) break; default: - WARN("Invalid wParam %lx\n", wParam); + WARN("Invalid duration flag %x\n", duration); break; } @@ -1918,11 +1867,8 @@ TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_SetMargin (HWND hwnd, LPARAM lParam) +TOOLTIPS_SetMargin (TOOLTIPS_INFO *infoPtr, LPRECT lpRect) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPRECT lpRect = (LPRECT)lParam; - infoPtr->rcMargin.left = lpRect->left; infoPtr->rcMargin.right = lpRect->right; infoPtr->rcMargin.bottom = lpRect->bottom; @@ -1933,48 +1879,40 @@ TOOLTIPS_SetMargin (HWND hwnd, LPARAM lParam) static inline LRESULT -TOOLTIPS_SetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_SetMaxTipWidth (TOOLTIPS_INFO *infoPtr, INT MaxWidth) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); INT nTemp = infoPtr->nMaxTipWidth; - infoPtr->nMaxTipWidth = (INT)lParam; + infoPtr->nMaxTipWidth = MaxWidth; return nTemp; } static inline LRESULT -TOOLTIPS_SetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_SetTipBkColor (TOOLTIPS_INFO *infoPtr, COLORREF clrBk) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - - infoPtr->clrBk = (COLORREF)wParam; + infoPtr->clrBk = clrBk; return 0; } static inline LRESULT -TOOLTIPS_SetTipTextColor (HWND hwnd, WPARAM wParam) +TOOLTIPS_SetTipTextColor (TOOLTIPS_INFO *infoPtr, COLORREF clrText) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - - infoPtr->clrText = (COLORREF)wParam; + infoPtr->clrText = clrText; return 0; } static LRESULT -TOOLTIPS_SetTitleA (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_SetTitleA (TOOLTIPS_INFO *infoPtr, UINT_PTR uTitleIcon, LPCSTR pszTitle) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPCSTR pszTitle = (LPCSTR)lParam; - UINT_PTR uTitleIcon = wParam; UINT size; - TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_a(pszTitle), + TRACE("hwnd = %p, title = %s, icon = %p\n", infoPtr->hwndSelf, debugstr_a(pszTitle), (void*)uTitleIcon); Free(infoPtr->pszTitle); @@ -1993,21 +1931,18 @@ TOOLTIPS_SetTitleA (HWND hwnd, WPARAM wParam, LPARAM lParam) if (uTitleIcon <= TTI_ERROR) infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon]; else - infoPtr->hTitleIcon = CopyIcon((HICON)wParam); + infoPtr->hTitleIcon = CopyIcon((HICON)uTitleIcon); return TRUE; } static LRESULT -TOOLTIPS_SetTitleW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_SetTitleW (TOOLTIPS_INFO *infoPtr, UINT_PTR uTitleIcon, LPCWSTR pszTitle) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPCWSTR pszTitle = (LPCWSTR)lParam; - UINT_PTR uTitleIcon = wParam; UINT size; - TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle), + TRACE("hwnd = %p, title = %s, icon = %p\n", infoPtr->hwndSelf, debugstr_w(pszTitle), (void*)uTitleIcon); Free(infoPtr->pszTitle); @@ -2026,7 +1961,7 @@ TOOLTIPS_SetTitleW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (uTitleIcon <= TTI_ERROR) infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon]; else - infoPtr->hTitleIcon = CopyIcon((HICON)wParam); + infoPtr->hTitleIcon = CopyIcon((HICON)uTitleIcon); TRACE("icon = %p\n", infoPtr->hTitleIcon); @@ -2035,10 +1970,8 @@ TOOLTIPS_SetTitleW (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_SetToolInfoA (HWND hwnd, LPARAM lParam) +TOOLTIPS_SetToolInfoA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -2093,10 +2026,8 @@ TOOLTIPS_SetToolInfoA (HWND hwnd, LPARAM lParam) static LRESULT -TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_SetToolInfoW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -2146,12 +2077,12 @@ TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (infoPtr->nCurrentTool == nTool) { - TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool); + TOOLTIPS_GetTipText (infoPtr, infoPtr->nCurrentTool, infoPtr->szTipText); if (infoPtr->szTipText[0] == 0) - TOOLTIPS_Hide(hwnd, infoPtr); + TOOLTIPS_Hide(infoPtr); else - TOOLTIPS_Show (hwnd, infoPtr, FALSE); + TOOLTIPS_Show (infoPtr, FALSE); } return 0; @@ -2159,12 +2090,9 @@ TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_TrackActivate (TOOLTIPS_INFO *infoPtr, BOOL track_activate, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - - if ((BOOL)wParam) { - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; + if (track_activate) { if (lpToolInfo == NULL) return 0; @@ -2176,12 +2104,12 @@ TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam) if (infoPtr->nTrackTool != -1) { TRACE("activated!\n"); infoPtr->bTrackActive = TRUE; - TOOLTIPS_TrackShow (hwnd, infoPtr); + TOOLTIPS_TrackShow (infoPtr); } } else { /* deactivate */ - TOOLTIPS_TrackHide (hwnd, infoPtr); + TOOLTIPS_TrackHide (infoPtr); infoPtr->bTrackActive = FALSE; infoPtr->nTrackTool = -1; @@ -2194,18 +2122,16 @@ TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_TrackPosition (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_TrackPosition (TOOLTIPS_INFO *infoPtr, LPARAM coord) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - - infoPtr->xTrackPos = (INT)LOWORD(lParam); - infoPtr->yTrackPos = (INT)HIWORD(lParam); + infoPtr->xTrackPos = (INT)LOWORD(coord); + infoPtr->yTrackPos = (INT)HIWORD(coord); if (infoPtr->bTrackActive) { TRACE("[%d %d]\n", infoPtr->xTrackPos, infoPtr->yTrackPos); - TOOLTIPS_TrackShow (hwnd, infoPtr); + TOOLTIPS_TrackShow (infoPtr); } return 0; @@ -2213,22 +2139,18 @@ TOOLTIPS_TrackPosition (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_Update (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_Update (TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - if (infoPtr->nCurrentTool != -1) - UpdateWindow (hwnd); + UpdateWindow (infoPtr->hwndSelf); return 0; } static LRESULT -TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_UpdateTipTextA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -2273,19 +2195,17 @@ TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) if(infoPtr->nCurrentTool == -1) return 0; /* force repaint */ if (infoPtr->bActive) - TOOLTIPS_Show (hwnd, infoPtr, FALSE); + TOOLTIPS_Show (infoPtr, FALSE); else if (infoPtr->bTrackActive) - TOOLTIPS_TrackShow (hwnd, infoPtr); + TOOLTIPS_TrackShow (infoPtr); return 0; } static LRESULT -TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_UpdateTipTextW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; TTTOOL_INFO *toolPtr; INT nTool; @@ -2329,9 +2249,9 @@ TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) if(infoPtr->nCurrentTool == -1) return 0; /* force repaint */ if (infoPtr->bActive) - TOOLTIPS_Show (hwnd, infoPtr, FALSE); + TOOLTIPS_Show (infoPtr, FALSE); else if (infoPtr->bTrackActive) - TOOLTIPS_Show (hwnd, infoPtr, TRUE); + TOOLTIPS_Show (infoPtr, TRUE); return 0; } @@ -2362,11 +2282,12 @@ TOOLTIPS_Create (HWND hwnd, const CREATESTRUCTW *lpcs) infoPtr->nTool = -1; infoPtr->nCurrentTool = -1; infoPtr->nTrackTool = -1; + infoPtr->hwndSelf = hwnd; /* initialize colours and fonts */ TOOLTIPS_InitSystemSettings(infoPtr); - TOOLTIPS_SetDelayTime(hwnd, TTDT_AUTOMATIC, 0L); + TOOLTIPS_SetDelayTime(infoPtr, TTDT_AUTOMATIC, 0); SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); @@ -2375,9 +2296,8 @@ TOOLTIPS_Create (HWND hwnd, const CREATESTRUCTW *lpcs) static LRESULT -TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_Destroy (TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); TTTOOL_INFO *toolPtr; UINT i; @@ -2418,34 +2338,31 @@ TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) DeleteObject (infoPtr->hTitleFont); /* free tool tips info data */ + SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0); Free (infoPtr); - SetWindowLongPtrW(hwnd, 0, 0); + return 0; } -static LRESULT -TOOLTIPS_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TOOLTIPS_GetFont (const TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - return (LRESULT)infoPtr->hFont; } static LRESULT -TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +TOOLTIPS_MouseMessage (TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - - TOOLTIPS_Hide (hwnd, infoPtr); + TOOLTIPS_Hide (infoPtr); return 0; } static LRESULT -TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_NCCreate (HWND hwnd, const CREATESTRUCTW *lpcs) { DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE); @@ -2467,9 +2384,8 @@ TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_NCHitTest (const TOOLTIPS_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); INT nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool; TRACE(" nTool=%d\n", nTool); @@ -2481,40 +2397,39 @@ TOOLTIPS_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam) } } - return DefWindowProcW (hwnd, WM_NCHITTEST, wParam, lParam); + return DefWindowProcW (infoPtr->hwndSelf, WM_NCHITTEST, wParam, lParam); } static LRESULT -TOOLTIPS_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_NotifyFormat (TOOLTIPS_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - FIXME ("hwnd=%p wParam=%lx lParam=%lx\n", hwnd, wParam, lParam); + FIXME ("hwnd=%p wParam=%lx lParam=%lx\n", infoPtr->hwndSelf, wParam, lParam); return 0; } static LRESULT -TOOLTIPS_Paint (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_Paint (const TOOLTIPS_INFO *infoPtr, HDC hDC) { HDC hdc; PAINTSTRUCT ps; - hdc = (wParam == 0) ? BeginPaint (hwnd, &ps) : (HDC)wParam; - TOOLTIPS_Refresh (hwnd, hdc); - if (!wParam) - EndPaint (hwnd, &ps); + hdc = (hDC == NULL) ? BeginPaint (infoPtr->hwndSelf, &ps) : hDC; + TOOLTIPS_Refresh (infoPtr, hdc); + if (!hDC) + EndPaint (infoPtr->hwndSelf, &ps); return 0; } static LRESULT -TOOLTIPS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_SetFont (TOOLTIPS_INFO *infoPtr, HFONT hFont, BOOL redraw) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); LOGFONTW lf; - if(!GetObjectW((HFONT)wParam, sizeof(lf), &lf)) + if(!GetObjectW(hFont, sizeof(lf), &lf)) return 0; DeleteObject (infoPtr->hFont); @@ -2524,7 +2439,7 @@ TOOLTIPS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) lf.lfWeight = FW_BOLD; infoPtr->hTitleFont = CreateFontIndirectW(&lf); - if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1)) { + if (redraw & (infoPtr->nCurrentTool != -1)) { FIXME("full redraw needed!\n"); } @@ -2536,15 +2451,12 @@ TOOLTIPS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) * * This function is called when the tooltip receive a * WM_GETTEXTLENGTH message. - * wParam : not used - * lParam : not used * * returns the length, in characters, of the tip text */ -static LRESULT -TOOLTIPS_GetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam) +static inline LRESULT +TOOLTIPS_GetTextLength(const TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); return strlenW(infoPtr->szTipText); } @@ -2560,57 +2472,54 @@ TOOLTIPS_GetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam) * returns the number of characters copied */ static LRESULT -TOOLTIPS_OnWMGetText (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_OnWMGetText (const TOOLTIPS_INFO *infoPtr, WPARAM size, LPWSTR pszText) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); LRESULT res; - LPWSTR pszText = (LPWSTR)lParam; - if(!infoPtr->szTipText || !wParam) + if(!infoPtr->szTipText || !size) return 0; - res = min(strlenW(infoPtr->szTipText)+1, wParam); + res = min(strlenW(infoPtr->szTipText)+1, size); memcpy(pszText, infoPtr->szTipText, res*sizeof(WCHAR)); pszText[res-1] = '\0'; return res-1; } static LRESULT -TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_Timer (TOOLTIPS_INFO *infoPtr, INT iTimer) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); INT nOldTool; - TRACE("timer %ld (%p) expired!\n", wParam, hwnd); + TRACE("timer %d (%p) expired!\n", iTimer, infoPtr->hwndSelf); - switch (wParam) { + switch (iTimer) { case ID_TIMERSHOW: - KillTimer (hwnd, ID_TIMERSHOW); + KillTimer (infoPtr->hwndSelf, ID_TIMERSHOW); nOldTool = infoPtr->nTool; - if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool) - TOOLTIPS_Show (hwnd, infoPtr, FALSE); + if ((infoPtr->nTool = TOOLTIPS_CheckTool (infoPtr, TRUE)) == nOldTool) + TOOLTIPS_Show (infoPtr, FALSE); break; case ID_TIMERPOP: - TOOLTIPS_Hide (hwnd, infoPtr); + TOOLTIPS_Hide (infoPtr); break; case ID_TIMERLEAVE: nOldTool = infoPtr->nTool; - infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, FALSE); - TRACE("tool (%p) %d %d %d\n", hwnd, nOldTool, + infoPtr->nTool = TOOLTIPS_CheckTool (infoPtr, FALSE); + TRACE("tool (%p) %d %d %d\n", infoPtr->hwndSelf, nOldTool, infoPtr->nTool, infoPtr->nCurrentTool); if (infoPtr->nTool != nOldTool) { if(infoPtr->nTool == -1) { /* Moved out of all tools */ - TOOLTIPS_Hide(hwnd, infoPtr); - KillTimer(hwnd, ID_TIMERLEAVE); + TOOLTIPS_Hide(infoPtr); + KillTimer(infoPtr->hwndSelf, ID_TIMERLEAVE); } else if (nOldTool == -1) { /* Moved from outside */ ERR("How did this happen?\n"); } else { /* Moved from one to another */ - TOOLTIPS_Hide (hwnd, infoPtr); - KillTimer(hwnd, ID_TIMERLEAVE); + TOOLTIPS_Hide (infoPtr); + KillTimer(infoPtr->hwndSelf, ID_TIMERLEAVE); if(infoPtr->bActive) { - SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0); + SetTimer (infoPtr->hwndSelf, ID_TIMERSHOW, infoPtr->nReshowTime, 0); TRACE("timer 1 started!\n"); } } @@ -2618,7 +2527,7 @@ TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam) break; default: - ERR("Unknown timer id %ld\n", wParam); + ERR("Unknown timer id %d\n", iTimer); break; } return 0; @@ -2626,10 +2535,8 @@ TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -TOOLTIPS_WinIniChange (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLTIPS_WinIniChange (TOOLTIPS_INFO *infoPtr) { - TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); - TOOLTIPS_InitSystemSettings (infoPtr); return 0; @@ -2639,6 +2546,7 @@ TOOLTIPS_WinIniChange (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT CALLBACK TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uID, DWORD_PTR dwRef) { + TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr ((HWND)dwRef); MSG msg; switch(uMsg) { @@ -2653,7 +2561,7 @@ TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_ msg.message = uMsg; msg.wParam = wParam; msg.lParam = lParam; - TOOLTIPS_RelayEvent((HWND)dwRef, 0, (LPARAM)&msg); + TOOLTIPS_RelayEvent(infoPtr, &msg); break; default: @@ -2666,130 +2574,132 @@ TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_ static LRESULT CALLBACK TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); + TRACE("hwnd=%p msg=%x wparam=%lx lParam=%lx\n", hwnd, uMsg, wParam, lParam); - if (!TOOLTIPS_GetInfoPtr(hwnd) && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE)) + if (!infoPtr && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE)) return DefWindowProcW (hwnd, uMsg, wParam, lParam); switch (uMsg) { case TTM_ACTIVATE: - return TOOLTIPS_Activate (hwnd, wParam); + return TOOLTIPS_Activate (infoPtr, (BOOL)wParam); case TTM_ADDTOOLA: - return TOOLTIPS_AddToolA (hwnd, lParam); + return TOOLTIPS_AddToolA (infoPtr, (LPTTTOOLINFOA)lParam); case TTM_ADDTOOLW: - return TOOLTIPS_AddToolW (hwnd, lParam); + return TOOLTIPS_AddToolW (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_DELTOOLA: - return TOOLTIPS_DelToolA (hwnd, lParam); + return TOOLTIPS_DelToolA (infoPtr, (LPTOOLINFOA)lParam); case TTM_DELTOOLW: - return TOOLTIPS_DelToolW (hwnd, lParam); + return TOOLTIPS_DelToolW (infoPtr, (LPTOOLINFOW)lParam); case TTM_ENUMTOOLSA: - return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam); + return TOOLTIPS_EnumToolsA (infoPtr, (UINT)wParam, (LPTTTOOLINFOA)lParam); case TTM_ENUMTOOLSW: - return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam); + return TOOLTIPS_EnumToolsW (infoPtr, (UINT)wParam, (LPTTTOOLINFOW)lParam); case TTM_GETBUBBLESIZE: - return TOOLTIPS_GetBubbleSize (hwnd, wParam, lParam); + return TOOLTIPS_GetBubbleSize (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_GETCURRENTTOOLA: - return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam); + return TOOLTIPS_GetCurrentToolA (infoPtr, (LPTTTOOLINFOA)lParam); case TTM_GETCURRENTTOOLW: - return TOOLTIPS_GetCurrentToolW (hwnd, lParam); + return TOOLTIPS_GetCurrentToolW (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_GETDELAYTIME: - return TOOLTIPS_GetDelayTime (hwnd, wParam); + return TOOLTIPS_GetDelayTime (infoPtr, (DWORD)wParam); case TTM_GETMARGIN: - return TOOLTIPS_GetMargin (hwnd, lParam); + return TOOLTIPS_GetMargin (infoPtr, (LPRECT)lParam); case TTM_GETMAXTIPWIDTH: - return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam); + return TOOLTIPS_GetMaxTipWidth (infoPtr); case TTM_GETTEXTA: - return TOOLTIPS_GetTextA (hwnd, wParam, lParam); + return TOOLTIPS_GetTextA (infoPtr, (LPTTTOOLINFOA)lParam); case TTM_GETTEXTW: - return TOOLTIPS_GetTextW (hwnd, wParam, lParam); + return TOOLTIPS_GetTextW (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_GETTIPBKCOLOR: - return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam); + return TOOLTIPS_GetTipBkColor (infoPtr); case TTM_GETTIPTEXTCOLOR: - return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam); + return TOOLTIPS_GetTipTextColor (infoPtr); case TTM_GETTOOLCOUNT: - return TOOLTIPS_GetToolCount (hwnd); + return TOOLTIPS_GetToolCount (infoPtr); case TTM_GETTOOLINFOA: - return TOOLTIPS_GetToolInfoA (hwnd, lParam); + return TOOLTIPS_GetToolInfoA (infoPtr, (LPTTTOOLINFOA)lParam); case TTM_GETTOOLINFOW: - return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam); + return TOOLTIPS_GetToolInfoW (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_HITTESTA: - return TOOLTIPS_HitTestA (hwnd, wParam, lParam); + return TOOLTIPS_HitTestA (infoPtr, (LPTTHITTESTINFOA)lParam); case TTM_HITTESTW: - return TOOLTIPS_HitTestW (hwnd, lParam); + return TOOLTIPS_HitTestW (infoPtr, (LPTTHITTESTINFOW)lParam); case TTM_NEWTOOLRECTA: - return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam); + return TOOLTIPS_NewToolRectA (infoPtr, (LPTTTOOLINFOA)lParam); case TTM_NEWTOOLRECTW: - return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam); + return TOOLTIPS_NewToolRectW (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_POP: - return TOOLTIPS_Pop (hwnd); + return TOOLTIPS_Pop (infoPtr); case TTM_RELAYEVENT: - return TOOLTIPS_RelayEvent (hwnd, wParam, lParam); + return TOOLTIPS_RelayEvent (infoPtr, (LPMSG)lParam); case TTM_SETDELAYTIME: - return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam); + return TOOLTIPS_SetDelayTime (infoPtr, (DWORD)wParam, (INT)LOWORD(lParam)); case TTM_SETMARGIN: - return TOOLTIPS_SetMargin (hwnd, lParam); + return TOOLTIPS_SetMargin (infoPtr, (LPRECT)lParam); case TTM_SETMAXTIPWIDTH: - return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam); + return TOOLTIPS_SetMaxTipWidth (infoPtr, (INT)lParam); case TTM_SETTIPBKCOLOR: - return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam); + return TOOLTIPS_SetTipBkColor (infoPtr, (COLORREF)wParam); case TTM_SETTIPTEXTCOLOR: - return TOOLTIPS_SetTipTextColor (hwnd, wParam); + return TOOLTIPS_SetTipTextColor (infoPtr, (COLORREF)wParam); case TTM_SETTITLEA: - return TOOLTIPS_SetTitleA (hwnd, wParam, lParam); + return TOOLTIPS_SetTitleA (infoPtr, (UINT_PTR)wParam, (LPCSTR)lParam); case TTM_SETTITLEW: - return TOOLTIPS_SetTitleW (hwnd, wParam, lParam); + return TOOLTIPS_SetTitleW (infoPtr, (UINT_PTR)wParam, (LPCWSTR)lParam); case TTM_SETTOOLINFOA: - return TOOLTIPS_SetToolInfoA (hwnd, lParam); + return TOOLTIPS_SetToolInfoA (infoPtr, (LPTTTOOLINFOA)lParam); case TTM_SETTOOLINFOW: - return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam); + return TOOLTIPS_SetToolInfoW (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_TRACKACTIVATE: - return TOOLTIPS_TrackActivate (hwnd, wParam, lParam); + return TOOLTIPS_TrackActivate (infoPtr, (BOOL)wParam, (LPTTTOOLINFOA)lParam); case TTM_TRACKPOSITION: - return TOOLTIPS_TrackPosition (hwnd, wParam, lParam); + return TOOLTIPS_TrackPosition (infoPtr, lParam); case TTM_UPDATE: - return TOOLTIPS_Update (hwnd, wParam, lParam); + return TOOLTIPS_Update (infoPtr); case TTM_UPDATETIPTEXTA: - return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam); + return TOOLTIPS_UpdateTipTextA (infoPtr, (LPTTTOOLINFOA)lParam); case TTM_UPDATETIPTEXTW: - return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam); + return TOOLTIPS_UpdateTipTextW (infoPtr, (LPTTTOOLINFOW)lParam); case TTM_WINDOWFROMPOINT: return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam); @@ -2799,20 +2709,20 @@ TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TOOLTIPS_Create (hwnd, (LPCREATESTRUCTW)lParam); case WM_DESTROY: - return TOOLTIPS_Destroy (hwnd, wParam, lParam); + return TOOLTIPS_Destroy (infoPtr); case WM_ERASEBKGND: /* we draw the background in WM_PAINT */ return 0; case WM_GETFONT: - return TOOLTIPS_GetFont (hwnd, wParam, lParam); + return TOOLTIPS_GetFont (infoPtr); case WM_GETTEXT: - return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam); + return TOOLTIPS_OnWMGetText (infoPtr, wParam, (LPWSTR)lParam); case WM_GETTEXTLENGTH: - return TOOLTIPS_GetTextLength (hwnd, wParam, lParam); + return TOOLTIPS_GetTextLength (infoPtr); case WM_LBUTTONDOWN: case WM_LBUTTONUP: @@ -2821,33 +2731,33 @@ TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MOUSEMOVE: - return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam); + return TOOLTIPS_MouseMessage (infoPtr); case WM_NCCREATE: - return TOOLTIPS_NCCreate (hwnd, wParam, lParam); + return TOOLTIPS_NCCreate (hwnd, (LPCREATESTRUCTW)lParam); case WM_NCHITTEST: - return TOOLTIPS_NCHitTest (hwnd, wParam, lParam); + return TOOLTIPS_NCHitTest (infoPtr, wParam, lParam); case WM_NOTIFYFORMAT: - return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); + return TOOLTIPS_NotifyFormat (infoPtr, wParam, lParam); case WM_PRINTCLIENT: case WM_PAINT: - return TOOLTIPS_Paint (hwnd, wParam, lParam); + return TOOLTIPS_Paint (infoPtr, (HDC)wParam); case WM_SETFONT: - return TOOLTIPS_SetFont (hwnd, wParam, lParam); + return TOOLTIPS_SetFont (infoPtr, (HFONT)wParam, LOWORD(lParam)); case WM_SYSCOLORCHANGE: COMCTL32_RefreshSysColors(); return 0; case WM_TIMER: - return TOOLTIPS_Timer (hwnd, wParam, lParam); + return TOOLTIPS_Timer (infoPtr, (INT)wParam); case WM_WININICHANGE: - return TOOLTIPS_WinIniChange (hwnd, wParam, lParam); + return TOOLTIPS_WinIniChange (infoPtr); default: if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg)) diff --git a/dlls/comdlg32/cdlg_De.rc b/dlls/comdlg32/cdlg_De.rc index 46c42913dc2..8e6432e83c4 100644 --- a/dlls/comdlg32/cdlg_De.rc +++ b/dlls/comdlg32/cdlg_De.rc @@ -212,40 +212,40 @@ FONT 8, "MS Shell Dlg" } -FINDDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 236, 62 +FINDDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 30, 73, 241, 63 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Suchen" FONT 8, "MS Shell Dlg" { - LTEXT "S&uchen nach:", -1, 4, 8, 42, 8 - EDITTEXT 1152, 47, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP - CHECKBOX "Nur ganze &Worte", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP - CHECKBOX "Beachte Groß/Kleinschreibung", 1041, 4, 42, 64, 12, BS_AUTOCHECKBOX | WS_TABSTOP - GROUPBOX "Richtung", 1072, 107, 26, 68, 28 - CONTROL "H&och", rad1, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 111, 38, 20, 12 - CONTROL "&Runter", rad2, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12 - DEFPUSHBUTTON "&Nächsten finden", IDOK, 182, 5, 50, 14, WS_GROUP | WS_TABSTOP - PUSHBUTTON "Abbrechen", IDCANCEL, 182, 23, 50, 14, WS_GROUP | WS_TABSTOP - PUSHBUTTON "&Hilfe", pshHelp, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP + LTEXT "S&uchen nach:", -1, 4, 8, 45, 8 + EDITTEXT 1152, 53, 7, 128, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + CHECKBOX "Nu&r ganzes Wort suchen", 1040, 4, 26, 100, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + CHECKBOX "Groß-/Klein&schreibung", 1041, 4, 42, 84, 12, BS_AUTOCHECKBOX | WS_TABSTOP + GROUPBOX "Suchrichtung", 1072, 113, 23, 68, 37 + CONTROL "Nach &oben", rad1, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 117, 34, 50, 10 + CONTROL "Nach &unten", rad2, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 117, 47, 50, 10 + DEFPUSHBUTTON "&Weitersuchen", IDOK, 187, 5, 50, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "Abbrechen", IDCANCEL, 187, 23, 50, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "&Hilfe", pshHelp, 187, 45, 50, 14, WS_GROUP | WS_TABSTOP } -REPLACEDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 230, 94 +REPLACEDLGORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 44, 240, 94 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Ersetzen" FONT 8, "MS Shell Dlg" { - LTEXT "S&uchen nach:", -1, 4, 9, 48, 8 - EDITTEXT 1152, 54, 7, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP - LTEXT "Ersetzen &durch:", -1, 4, 26, 48, 8 - EDITTEXT 1153, 54, 24, 114, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP - CHECKBOX "Nur ganze &Worte", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP - CHECKBOX "Beachte Groß/Kleinschreibung", 1041, 5, 62, 59, 12, BS_AUTOCHECKBOX | WS_TABSTOP - DEFPUSHBUTTON "&Nächsten finden", IDOK, 174, 4, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP - PUSHBUTTON "&Ersetzen", psh1, 174, 21, 50, 14, WS_GROUP | WS_TABSTOP - PUSHBUTTON "&Alle ersetzen", psh2, 174, 38, 50, 14, WS_GROUP | WS_TABSTOP - PUSHBUTTON "Abbrechen", IDCANCEL, 174, 55, 50, 14, WS_GROUP | WS_TABSTOP - PUSHBUTTON "&Hilfe", pshHelp, 174, 75, 50, 14, WS_GROUP | WS_TABSTOP + LTEXT "&Suchen nach:", -1, 4, 9, 48, 8 + EDITTEXT 1152, 56, 7, 112, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + LTEXT "Ersetzen &durch:", -1, 4, 26, 52, 8 + EDITTEXT 1153, 56, 24, 112, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP + CHECKBOX "Nu&r ganzes Wort", 1040, 5, 46, 104, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP + CHECKBOX "Groß-/Kleins&chreibung", 1041, 5, 62, 86, 12, BS_AUTOCHECKBOX | WS_TABSTOP + DEFPUSHBUTTON "&Weitersuchen", IDOK, 175, 6, 60, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + PUSHBUTTON "&Ersetzen", psh1, 175, 23, 60, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "A&lles ersetzen", psh2, 175, 40, 60, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "Abbrechen", IDCANCEL, 175, 57, 60, 14, WS_GROUP | WS_TABSTOP + PUSHBUTTON "&Hilfe", pshHelp, 175, 74, 60, 14, WS_GROUP | WS_TABSTOP } NEWFILEOPENORD DIALOG LOADONCALL MOVEABLE DISCARDABLE 0, 0, 280, 164 diff --git a/dlls/comdlg32/tests/printdlg.c b/dlls/comdlg32/tests/printdlg.c index ec63da9a6c7..4e189eed7e7 100644 --- a/dlls/comdlg32/tests/printdlg.c +++ b/dlls/comdlg32/tests/printdlg.c @@ -246,6 +246,11 @@ static void test_PrintDlgExW(void) PrintDlg(NULL); SetLastError(0xdeadbeef); res = pPrintDlgExW(NULL); + if(res == E_NOTIMPL) + { + win_skip("PrintDlgExW returns not implemented\n"); + return; + } ok( (res == E_INVALIDARG), "got 0x%x with %u and %u (expected 'E_INVALIDARG')\n", res, GetLastError(), CommDlgExtendedError()); diff --git a/dlls/cryptui/cryptui.rc b/dlls/cryptui/cryptui.rc index d425db91095..4b170e3f4bf 100644 --- a/dlls/cryptui/cryptui.rc +++ b/dlls/cryptui/cryptui.rc @@ -48,3 +48,4 @@ IDB_CERT_HEADER BITMAP LOADONCALL DISCARDABLE certheader.bmp #include "cryptui_En.rc" #include "cryptui_Ko.rc" +#include "cryptui_Nl.rc" diff --git a/dlls/cryptui/cryptui_Nl.rc b/dlls/cryptui/cryptui_Nl.rc new file mode 100644 index 00000000000..d046d376b8a --- /dev/null +++ b/dlls/cryptui/cryptui_Nl.rc @@ -0,0 +1,461 @@ +/* + * cryptui dll dutch resources + * + * Copyright 2009 Frans Kool + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + IDS_CERTIFICATE "Certificaat" + IDS_CERTIFICATEINFORMATION "Certificaat informatie" + IDS_CERT_INFO_BAD_SIG "Dit certificaat heeft een foutieve handtekening. Het certificaat kan gewijzigd of corrupt zijn." + IDS_CERT_INFO_UNTRUSTED_CA "Dit basis certificaat wordt niet vertrouwd. Om het te vertrouwen, voeg het toe aan uw systeem's vertrouwde basis certificatenopslag." + IDS_CERT_INFO_UNTRUSTED_ROOT "Dit certificaat kon niet worden getraceerd naar een vertrouwd basis certificaat." + IDS_CERT_INFO_PARTIAL_CHAIN "De uitgever van dit certificaat kon niet gevonden worden." + IDS_CERT_INFO_BAD_PURPOSES "De doeleinden voor dit certificaat konden niet geverifieerd worden." + IDS_CERT_INFO_PURPOSES "Dit certificaat is bedoeld voor de volgende doeleinden:" + IDS_SUBJECT_HEADING "Verstrekt aan: " + IDS_ISSUER_HEADING "Uitgegeven door: " + IDS_VALID_FROM "geldig vanaf " + IDS_VALID_TO " tot " + IDS_CERTIFICATE_BAD_SIGNATURE "Dit certificaat heeft een foutieve handtekening." + IDS_CERTIFICATE_BAD_TIME "Dit certificaat is verlopen of is nog niet geldig." + IDS_CERTIFICATE_BAD_TIMENEST "De geldigheidsperiode van dit certificaat is groter dan die van zijn uitgever." + IDS_CERTIFICATE_REVOKED "Dit certificaat was teruggeroepen door de uitgever." + IDS_CERTIFICATE_VALID "Dit certificaat is OK." + IDS_FIELD "Veld" + IDS_VALUE "Waarde" + IDS_FIELDS_ALL "" + IDS_FIELDS_V1 "Alleen versie 1 velden" + IDS_FIELDS_EXTENSIONS "Alleen extensies" + IDS_FIELDS_CRITICAL_EXTENSIONS "Alleen kritieke extensies" + IDS_FIELDS_PROPERTIES "Alleen eigenschappen" + IDS_FIELD_VERSION "Versie" + IDS_FIELD_SERIAL_NUMBER "Serienummer" + IDS_FIELD_ISSUER "Uitgever" + IDS_FIELD_VALID_FROM "Geldig vanaf" + IDS_FIELD_VALID_TO "Geldig tot" + IDS_FIELD_SUBJECT "Onderwerp" + IDS_FIELD_PUBLIC_KEY "Publieke sleutel" + IDS_FIELD_PUBLIC_KEY_FORMAT "%s (%d bits)" + IDS_PROP_HASH "SHA1 hash" + IDS_PROP_ENHKEY_USAGE "Uitgebreid sleutel gebruik (eigenschap)" + IDS_PROP_FRIENDLY_NAME "Naam alias" + IDS_PROP_DESCRIPTION "Beschrijving" + IDS_CERTIFICATE_PROPERTIES "Certificaat eigenschappen" + IDS_CERTIFICATE_PURPOSE_ERROR "Geef aub. een OID in in de vorm van 1.2.3.4" + IDS_CERTIFICATE_PURPOSE_EXISTS "De ingegeven OID bestaat reeds." + IDS_SELECT_STORE_TITLE "Selecteer certificatenopslag" + IDS_SELECT_STORE "Selecteer aub. een certificatenopslag." + IDS_IMPORT_WIZARD "Certificaat importeerhulp" + IDS_IMPORT_TYPE_MISMATCH "Het bestand bevat objecten die niet voldoen aan de opgegeven criteria. Selecteer aub. een ander bestand." + IDS_IMPORT_FILE_TITLE "Bestand om te importeren" + IDS_IMPORT_FILE_SUBTITLE "Specificeer het bestand dat u wilt importeren." + IDS_IMPORT_STORE_TITLE "Certificatenopslag" + IDS_IMPORT_STORE_SUBTITLE "Certificatenopslagen zijn verzamelingen van certificaten, certificaat terugroeplijsten en certificaat vertrouwenslijsten." + IDS_IMPORT_FILTER_CERT "X.509 Certificaat (*.cer; *.crt)" + IDS_IMPORT_FILTER_PFX "Persoonlijke informatie uitwisseling (*.pfx; *.p12)" + IDS_IMPORT_FILTER_CRL "Certificaat terugroeplijst (*.crl)" + IDS_IMPORT_FILTER_CTL "Certificaat vertrouwenslijst (*.stl)" + IDS_IMPORT_FILTER_SERIALIZED_STORE "Microsoft seriële certificatenopslag (*.sst)" + IDS_IMPORT_FILTER_CMS "CMS/PKCS #7 berichten (*.spc; *.p7b)" + IDS_IMPORT_FILTER_ALL "Alle bestanden (*.*)" + IDS_IMPORT_EMPTY_FILE "Selecteer een bestand." + IDS_IMPORT_BAD_FORMAT "Het bestandsformaat wordt niet herkend. Selecteer aub. een ander bestand." + IDS_IMPORT_OPEN_FAILED "Openen mislukt voor " + IDS_IMPORT_DEST_DETERMINED "Bepaald door het programma" + IDS_IMPORT_SELECT_STORE "Selecteer een opslag" + IDS_IMPORT_STORE_SELECTION "Geselecteerde certificatenopslag" + IDS_IMPORT_DEST_AUTOMATIC "Automatisch bepaald door het programma" + IDS_IMPORT_FILE "Bestand" + IDS_IMPORT_CONTENT "Inhoud" + IDS_IMPORT_CONTENT_CERT "Certificaat" + IDS_IMPORT_CONTENT_CRL "Certificaat terugroeplijst" + IDS_IMPORT_CONTENT_CTL "Certificaat vertrouwenslijst" + IDS_IMPORT_CONTENT_CMS "CMS/PKCS #7 bericht" + IDS_IMPORT_CONTENT_PFX "Persoonlijke informatie uitwisseling" + IDS_IMPORT_CONTENT_STORE "Certificatenopslag" + IDS_IMPORT_SUCCEEDED "Het importeren was succesvol." + IDS_IMPORT_FAILED "Het importeren is mislukt." + IDS_WIZARD_TITLE_FONT "Arial" + IDS_PURPOSE_ALL "" + IDS_PURPOSE_ADVANCED "" + IDS_SUBJECT_COLUMN "Verstrekt aan" + IDS_ISSUER_COLUMN "Uitgegeven door" + IDS_EXPIRATION_COLUMN "Verloop datum" + IDS_FRIENDLY_NAME_COLUMN "Naam alias" + IDS_ALLOWED_PURPOSE_ALL "" + IDS_ALLOWED_PURPOSE_NONE "" + IDS_WARN_REMOVE_MY "U kunt niet langer berichten ontcijferen of ondertekenen met dit certificaat.\nWeet u zeker dat u dit certificaat wilt verwijderen?" + IDS_WARN_REMOVE_PLURAL_MY "U kunt niet langer berichten ontcijferen of ondertekenen met deze certificaten.\nWeet u zeker dat u deze certificaten wilt verwijderen?" + IDS_WARN_REMOVE_ADDRESSBOOK "U kunt niet langer berichten coderen of verifiëren met dit certificaat.\nWeet u zeker dat u dit certificaat wilt verwijderen?" + IDS_WARN_REMOVE_PLURAL_ADDRESSBOOK "U kunt niet langer berichten coderen of verifiëren met deze certificaten.\nWeet u zeker dat u deze certificaten wilt verwijderen?" + IDS_WARN_REMOVE_CA "Certificaten uitgegeven door deze certificaten autoriteit zullen niet meer vertrouwd worden.\nWeet u zeker dat u dit certificaat wilt verwijderen?" + IDS_WARN_REMOVE_PLURAL_CA "Certificaten uitgegeven door deze certificaten autoriteiten zullen niet meer vertrouwd worden.\nWeet u zeker dat u deze certificaten wilt verwijderen?" + IDS_WARN_REMOVE_ROOT "Certificaten uitgegeven door deze basic certificaten autoriteit, alsmede enige certificatie autoriteit die hij verstrekt, zullen niet meer vertrouwd worden.\nWeet u zeker dat u dit vertrouwde basic certificaat wilt verwijderen?" + IDS_WARN_REMOVE_PLURAL_ROOT "Certificaten uitgegeven door deze basic certificaten autoriteiten, alsmede enige certificatie autoriteit die zij verstrekken, zullen niet meer vertrouwd worden.\nWeet u zeker dat u deze vertrouwde basic certificaten wilt verwijderen?" + IDS_WARN_REMOVE_TRUSTEDPUBLISHER "Software ondertekend door deze uitgever zal niet meer vertrouwd worden.\nWeet u zeker dat u dit certificaat wilt verwijderen?" + IDS_WARN_REMOVE_PLURAL_TRUSTEDPUBLISHER "Software ondertekend door deze uitgevers zal niet meer vertrouwd worden.\nWeet u zeker dat u deze certificaten wilt verwijderen?" + IDS_WARN_REMOVE_DEFAULT "Weet u zeker dat u dit certificaat wilt verwijderen?" + IDS_WARN_REMOVE_PLURAL_DEFAULT "Weet u zeker dat u deze certificaten wilt verwijderen?" + IDS_CERT_MGR "Certificaten" + IDS_PURPOSE_SERVER_AUTH "Bewijst de identiteit van een remote computer" + IDS_PURPOSE_CLIENT_AUTH "Bewijst uw identiteit aan een remote computer" + IDS_PURPOSE_CODE_SIGNING "Bewijst dat de software kwam van de software uitgever\nBeschermt software tegen wijzigingen na publicatie" + IDS_PURPOSE_EMAIL_PROTECTION "Beschermt e-mail berichten" + IDS_PURPOSE_IPSEC "Staat beveiligde communicatie over het Internet toe" + IDS_PURPOSE_TIMESTAMP_SIGNING "Laat data ondertekend worden met de huidige tijd" + IDS_PURPOSE_CTL_USAGE_SIGNING "Laat u een certificaat vertrouwenslijst digitaal ondertekenen" + IDS_PURPOSE_EFS "Laat data op de disk gecodeerd worden" + IDS_PURPOSE_EFS_RECOVERY "Bestandsherstel" + IDS_PURPOSE_WHQL "Windows Hardware Driver Verificatie" + IDS_PURPOSE_NT5 "Windows System Component Verificatie" + IDS_PURPOSE_OEM_WHQL "OEM Windows Systeem Component Verificatie" + IDS_PURPOSE_EMBEDDED_NT "Ingebed Windows Systeem Component Verificatie" + IDS_PURPOSE_ROOT_LIST_SIGNER "Basislijst Ondertekenaar" + IDS_PURPOSE_QUALIFIED_SUBORDINATION "Gekwalificeerde ondergeschiktheid" + IDS_PURPOSE_KEY_RECOVERY "Sleutel herstellen" + IDS_PURPOSE_DOCUMENT_SIGNING "Document ondertekening" + IDS_PURPOSE_LIFETIME_SIGNING "Levenslang ondertekenen" + IDS_PURPOSE_DRM "Digitale rechten" + IDS_PURPOSE_LICENSES "Sleutelbos licenties" + IDS_PURPOSE_LICENSE_SERVER "Licentieserver verificatie" + IDS_PURPOSE_ENROLLMENT_AGENT "Certificaatverzoek agent" + IDS_PURPOSE_SMARTCARD_LOGON "Smartcard aanloggen" + IDS_PURPOSE_CA_EXCHANGE "Persoonlijke sleutel archiefbescheiden" + IDS_PURPOSE_KEY_RECOVERY_AGENT "Sleutel herstel agent" + IDS_PURPOSE_DS_EMAIL_REPLICATION "Directory service email replicatie" + IDS_EXPORT_WIZARD "Certificaat Exporteerhulp" + IDS_EXPORT_FORMAT_TITLE "Export formaat" + IDS_EXPORT_FORMAT_SUBTITLE "Selecteer het formaat waarin de inhoud zal worden opgeslagen." + IDS_EXPORT_FILE_TITLE "Exporteer bestandsnaam" + IDS_EXPORT_FILE_SUBTITLE "Geef de naam van het bestand waarin de inhoud zal worden opgeslagen." + IDS_EXPORT_FILE_EXISTS "Het gekozen bestand bestaat reeds. Wilt u het overschrijven?" + IDS_EXPORT_FILTER_CERT "DER-Encoded Binary X.509 (*.cer)" + IDS_EXPORT_FILTER_BASE64_CERT "Base64-geëncodeerd X.509 (*.cer)" + IDS_EXPORT_FILTER_CRL "Certificaat terugroeplijst (*.crl)" + IDS_EXPORT_FILTER_CTL "Certificaat vertrouwenslijst (*.stl)" + IDS_EXPORT_FILTER_CMS "CMS/PKCS #7 berichten (*.p7b)" + IDS_EXPORT_FILTER_PFX "Persoonlijke informatie uitwisseling (*.pfx)" + IDS_EXPORT_FILTER_SERIALIZED_CERT_STORE "Seriële certificatenopslag (*.sst)" + IDS_EXPORT_FORMAT "Bestandsformaat" + IDS_EXPORT_INCLUDE_CHAIN "Neem alle certificaten in het certificatiepad op" + IDS_EXPORT_KEYS "Exporteer sleutels" + IDS_YES "Ja" + IDS_NO "Nee" + IDS_EXPORT_SUCCEEDED "Het exporteren is gelukt." + IDS_EXPORT_FAILED "Het exporteren is mislukt." + IDS_EXPORT_PRIVATE_KEY_TITLE "Exporteer persoonlijke sleutel" + IDS_EXPORT_PRIVATE_KEY_SUBTITLE "Het certificaat bevat een persoonlijke sleutel die mee kan worden geëxporteerd met het certificaat." + IDS_EXPORT_PASSWORD_TITLE "Voer wachtwoord in" + IDS_EXPORT_PASSWORD_SUBTITLE "U kunt een persoonlijke sleutel beveiligen met een wachtwoord." + IDS_EXPORT_PASSWORD_MISMATCH "De wachtwoorden zijn niet gelijk." + IDS_EXPORT_PRIVATE_KEY_UNAVAILABLE "NB: De persoonlijke sleutel voor dit certificaat kon niet geopend worden." + IDS_EXPORT_PRIVATE_KEY_NON_EXPORTABLE "Note: De persoonlijke sleutel voor dit certificaat kan niet geëxporteerd worden." +} + +IDD_GENERAL DIALOG DISCARDABLE 0, 0, 255, 236 +CAPTION "Algemeen" +STYLE WS_VISIBLE +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", -1, "Static", WS_BORDER|SS_WHITERECT, 6,10,241,200 + CONTROL "", IDC_CERTIFICATE_ICON,"RichEdit20W", + ES_READONLY|WS_DISABLED,8,11,26,26 + CONTROL "", IDC_CERTIFICATE_INFO,"RichEdit20W", + ES_READONLY|WS_DISABLED,34,11,212,26 + CONTROL "", -1, "Static", SS_BLACKFRAME, 16,37,222,1 + CONTROL "", IDC_CERTIFICATE_STATUS,"RichEdit20W", + ES_READONLY|ES_MULTILINE,8,38,238,78 + CONTROL "", -1, "Static", SS_BLACKFRAME, 16,116,222,1 + CONTROL "", IDC_CERTIFICATE_NAMES,"RichEdit20W", + ES_READONLY|ES_MULTILINE|WS_DISABLED,8,118,238,90 + PUSHBUTTON "&Installeer certificaat...", IDC_ADDTOSTORE,103,216,70,14 + PUSHBUTTON "Uitgevers &verklaring", IDC_ISSUERSTATEMENT,177,216,70,14 +END + +IDD_DETAIL DIALOG DISCARDABLE 0, 0, 255, 236 +CAPTION "Details" +STYLE WS_VISIBLE +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Toon:", -1, 6,12,40,14 + COMBOBOX IDC_DETAIL_SELECT, 28,10,100,14, + CBS_DROPDOWNLIST|WS_BORDER|WS_VSCROLL|WS_TABSTOP + CONTROL "", IDC_DETAIL_LIST, "SysListView32", + LVS_REPORT|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, + 6,28,241,100 + CONTROL "", IDC_DETAIL_VALUE, "RichEdit20W", + ES_READONLY|ES_MULTILINE|WS_TABSTOP, 6,136,241,70 + PUSHBUTTON "&Wijzig eigenschappen...", IDC_EDITPROPERTIES,103,216,70,14 + PUSHBUTTON "&Kopieer naar bestand...", IDC_EXPORT,177,216,70,14 +END + +IDD_HIERARCHY DIALOG DISCARDABLE 0, 0, 255, 236 +CAPTION "Certificatie pad" +STYLE WS_VISIBLE +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Certification &pad", -1,6,10,245,165, BS_GROUPBOX + CONTROL "",IDC_CERTPATH, "SysTreeView32", TVS_HASLINES|WS_BORDER, + 13,22,231,130 + PUSHBUTTON "&Bekijk certificaat", IDC_VIEWCERTIFICATE,175,156,70,14 + LTEXT "Certificaat &status:", IDC_CERTIFICATESTATUS,6,183,70,14 + CONTROL "", IDC_CERTIFICATESTATUSTEXT,"RichEdit20W", + WS_BORDER|ES_READONLY|ES_MULTILINE|WS_DISABLED,6,195,245,36 +END + +IDD_USERNOTICE DIALOG DISCARDABLE 0, 0, 255, 256 +CAPTION "Disclaimer" +STYLE WS_VISIBLE +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "", IDC_USERNOTICE,"RichEdit20W", + WS_BORDER|ES_READONLY|ES_MULTILINE|WS_DISABLED,6,10,241,200 + PUSHBUTTON "&Sluiten", IDOK,103,216,70,14 + PUSHBUTTON "Meer &informatie", IDC_CPS,177,216,70,14 +END + +IDD_CERT_PROPERTIES_GENERAL DIALOG DISCARDABLE 0, 0, 255, 236 +CAPTION "Algemeen" +STYLE WS_VISIBLE +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Naam alias:", -1, 6,14,60,14 + EDITTEXT IDC_FRIENDLY_NAME, 60,12,191,14, ES_AUTOHSCROLL|WS_TABSTOP + LTEXT "&Beschrijving:", -1, 6,32,60,14 + EDITTEXT IDC_DESCRIPTION, 60,30,191,14, ES_AUTOVSCROLL|ES_MULTILINE|WS_TABSTOP|WS_VSCROLL + GROUPBOX "Certificaat doeleinden", -1,6,48,245,165, BS_GROUPBOX + AUTORADIOBUTTON "Schakel alle doeleinden voor dit certificaat &in", + IDC_ENABLE_ALL_PURPOSES, 12,58,180,14, BS_AUTORADIOBUTTON|WS_TABSTOP + AUTORADIOBUTTON "Schakel alle doeleinden voor dit certificaat &uit", + IDC_DISABLE_ALL_PURPOSES, 12,70,180,14, BS_AUTORADIOBUTTON + AUTORADIOBUTTON "Schakel &alleen de volgende doeleinden voor dit certificaat in:", + IDC_ENABLE_SELECTED_PURPOSES, 12,82,180,14, BS_AUTORADIOBUTTON + CONTROL "", IDC_CERTIFICATE_USAGES,"SysListView32", + LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, + 24,100,220,90 + PUSHBUTTON "Voeg &doeleinde toe...", IDC_ADD_PURPOSE,184,194,60,14 +END + +IDD_ADD_CERT_PURPOSE DIALOG DISCARDABLE 0,0,200,68 +CAPTION "Voeg doeleinde toe" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Voer het object id. (OID) in voor het toe te voegen certificaat doeleinde:", + -1, 6,6,190,28 + EDITTEXT IDC_NEW_PURPOSE, 6,28,190,14, ES_AUTOVSCROLL|ES_MULTILINE|WS_TABSTOP|WS_VSCROLL + PUSHBUTTON "OK", IDOK, 33,48,60,14 + PUSHBUTTON "Annuleren", IDCANCEL, 100,48,60,14 +END + +IDD_SELECT_STORE DIALOG DISCARDABLE 0,0,200,136 +CAPTION "Selecteer certificatenopslag" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Selecteer de certificatenopslag die u wilt gebruiken:", IDC_STORE_TEXT, 6,6,190,28 + CONTROL "",IDC_STORE_LIST, "SysTreeView32", TVS_HASLINES|WS_BORDER|WS_TABSTOP, + 6,28,188,70 + CHECKBOX "&Toon fysieke opslagen", IDC_SHOW_PHYSICAL_STORES, 6,102,90,14, + BS_AUTOCHECKBOX|WS_TABSTOP + PUSHBUTTON "OK", IDOK, 90,118,50,14, BS_DEFPUSHBUTTON + PUSHBUTTON "Annuleren", IDCANCEL, 144,118,50,14 +END + +IDD_IMPORT_WELCOME DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat importeerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Welkom bij de certificaat importeerhulp", IDC_IMPORT_TITLE, + 115,1,195,40 + LTEXT "Deze hulp helps u met het importeren van certificaten, certificaat terugroeplijsten en certificaat vertrouwenslijsten uit een bestand naar een certificatenopslag.", + -1, 115,33,195,16 + LTEXT "Een certificaat kan gebruikt worden om u of de computer waarmee u werkt te identificeren. Het kan ook gebruikt worden voor authenticatie en om berichten te ondertekenen. Certificatenopslagen zijn verzamelingen van certificaten, certificaat terugroeplijsten en certificaat vertrouwenslijsten.", + -1, 115,56,195,40 + LTEXT "Om verder te gaan, click op Volgende.", + -1, 115,103,195,8 +END + +IDD_IMPORT_FILE DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat importeerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Bestands&naam:", -1, 21,1,195,10 + EDITTEXT IDC_IMPORT_FILENAME, 21,11,208,14, ES_AUTOHSCROLL|WS_TABSTOP + PUSHBUTTON "B&laderen...", IDC_IMPORT_BROWSE_FILE, 236,11,60,14 + LTEXT "NB: De volgende bestandsformaten kunnen meer dan één certificaat, certificaat terugroeplijst of certificaat vertrouwenslijst bevatten:", + -1, 21,26,265,16 + LTEXT "Cryptographisch berichtsyntaxis standaard/PKCS #7 berichten (.p7b)", + -1, 31,49,265,10 + LTEXT "Persoonlijke informatie uitwisseling/PKCS #12 (.pfx, .p12)", + -1, 31,64,265,10 + LTEXT "Microsoft seriële certificatenopslag (.sst)", + -1, 31,79,265,10 +END + +IDD_IMPORT_STORE DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat importeerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Wine kan automatisch de certificatenopslag selecteren, of u kunt een locatie opgeven voor de certificaten.", + -1, 21,1,195,20 + AUTORADIOBUTTON "&Automatisch certificatenopslag selecteren", + IDC_IMPORT_AUTO_STORE, 31,18,180,12, BS_AUTORADIOBUTTON|WS_TABSTOP + AUTORADIOBUTTON "&Plaats alle certificaten in de volgende opslag:", + IDC_IMPORT_SPECIFY_STORE, 31,30,180,12, BS_AUTORADIOBUTTON + EDITTEXT IDC_IMPORT_STORE, 44,49,185,14, ES_READONLY + PUSHBUTTON "B&laderen...", IDC_IMPORT_BROWSE_STORE, 236,49,60,14 +END + +IDD_IMPORT_FINISH DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat importeerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Afronden van de certificaat importeerhulp", IDC_IMPORT_TITLE, + 115,1,195,40 + LTEXT "U heeft de certificaat importeerhulp succesvol afgerond.", + -1, 115,33,195,24 + LTEXT "U heeft de volgende instellingen ingegeven:", + -1, 115,57,195,12 + CONTROL "", IDC_IMPORT_SETTINGS, "SysListView32", + LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, + 115,67,174,100 +END + +IDD_CERT_MGR DIALOG DISCARDABLE 0,0,335,270 +CAPTION "Certificaten" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Doeleinden:", -1, 7,9,100,12 + COMBOBOX IDC_MGR_PURPOSE_SELECTION, 83,7,245,14, + CBS_DROPDOWNLIST|WS_BORDER|WS_VSCROLL|WS_TABSTOP + CONTROL "", IDC_MGR_STORES, "SysTabControl32", + WS_CLIPSIBLINGS|WS_TABSTOP, 7,25,321,140 + CONTROL "", IDC_MGR_CERTS, "SysListView32", + LVS_REPORT|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, 15,46,305,111 + PUSHBUTTON "&Importeer...", IDC_MGR_IMPORT, 7,172,51,14 + PUSHBUTTON "&Exporteer...", IDC_MGR_EXPORT, 62,172,51,14, WS_DISABLED + PUSHBUTTON "&Verwijder", IDC_MGR_REMOVE, 117,172,51,14, WS_DISABLED + PUSHBUTTON "Ge&avanceerd...", IDC_MGR_ADVANCED, 277,172,51,14 + GROUPBOX "Certificaat doeleinden", -1,7,194,321,47, BS_GROUPBOX + LTEXT "", IDC_MGR_PURPOSES, 13,208,252,30 + PUSHBUTTON "&Bekijken...", IDC_MGR_VIEW, 269,218,51,14, WS_DISABLED + PUSHBUTTON "&Sluiten", IDCANCEL, 277,249,51,14, BS_DEFPUSHBUTTON +END + +IDD_CERT_MGR_ADVANCED DIALOG DISCARDABLE 0,0,248,176 +CAPTION "Geavanceerde opties" +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Certificaat doeleinde", -1, 7,7,234,141, BS_GROUPBOX + LTEXT "Selecteer een of meerdere doelen om te tonen als Geavanceerde doeleinden wordt geselecteerd.", + -1, 14,18,220,16 + LTEXT "&Certificaat doeleinden:", -1, 14,41,90,12, WS_TABSTOP + CONTROL "", IDC_CERTIFICATE_USAGES,"SysListView32", + LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, + 14,51,220,90 + PUSHBUTTON "OK", IDOK, 132,155,51,14, BS_DEFPUSHBUTTON + PUSHBUTTON "Annuleren", IDCANCEL, 190,155,51,14 +END + +IDD_EXPORT_WELCOME DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat exporteerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Welkom bij de Certificaat exporteerhulp", IDC_EXPORT_TITLE, + 115,1,195,40 + LTEXT "Deze hulp assisteerd u bij het exporteren van certificaten, certificaat terugroeplijsten en certificaat vertrouwenslijsten vanuit een certificatenopslag naar een bestand.", + -1, 115,33,195,16 + LTEXT "Een certificaat kan gebruikt worden om u of de computer waarmee u werkt te identificeren. Het kan ook gebruikt worden voor authenticatie en om berichten te ondertekenen. Certificatenopslagen zijn verzamelingen van certificaten, certificaat terugroeplijsten en certificaat vertrouwenslijsten.", + -1, 115,56,195,40 + LTEXT "Om verder te gaan, click op Volgende.", + -1, 115,103,195,8 +END + +IDD_EXPORT_PRIVATE_KEY DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat exporteerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Als u de persoonlijke sleutel wilt exporteren zult u later verzocht worden een wachtwoord in te geven om de sleutel te beveiligen.", -1, 21,1,195,23 + LTEXT "Wilt u de persoonlijke sleutel exporteren?", -1, 21,24,195,15 + AUTORADIOBUTTON "&Ja, exporteer de persoonlijke sleutel", + IDC_EXPORT_PRIVATE_KEY_YES, 31,36,200,12, BS_AUTORADIOBUTTON|WS_TABSTOP + AUTORADIOBUTTON "&Nee, exporteer de persoonlijke sleutel niet", + IDC_EXPORT_PRIVATE_KEY_NO, 31,48,200,12, BS_AUTORADIOBUTTON + LTEXT "", IDC_EXPORT_PRIVATE_KEY_UNAVAILABLE, 21,60,200,24 +END + +IDD_EXPORT_PASSWORD DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat exporteerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Wachtwoord:", -1, 21,1,195,10 + EDITTEXT IDC_EXPORT_PASSWORD, 21,11,208,14, ES_AUTOHSCROLL|WS_TABSTOP + LTEXT "&Bevestig wachtwoord:", -1, 21,35,195,10 + EDITTEXT IDC_EXPORT_PASSWORD_CONFIRM, 21,45,208,14, ES_AUTOHSCROLL|WS_TABSTOP +END + +IDD_EXPORT_FORMAT DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat exporteerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Selecteer het formaat dat u wilt gebruiken:", -1, 21,1,195,10 + AUTORADIOBUTTON "&DER-encoded X.509 (.cer)", + IDC_EXPORT_FORMAT_DER, 31,18,200,12, BS_AUTORADIOBUTTON|WS_TABSTOP + AUTORADIOBUTTON "Ba&se64-encoded X.509 (.cer):", + IDC_EXPORT_FORMAT_BASE64, 31,30,200,12, BS_AUTORADIOBUTTON + AUTORADIOBUTTON "&Cryptographisch berichtsyntaxis standaard/PKCS #7 berichten (.p7b)", + IDC_EXPORT_FORMAT_CMS, 31,42,200,12, BS_AUTORADIOBUTTON + CHECKBOX "Neem &alle certificaten in het certificatiepad op indien mogelijk", + IDC_EXPORT_CMS_INCLUDE_CHAIN, 44,57,200,8, BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED + AUTORADIOBUTTON "&Persoonlijke informatie uitwisseling/PKCS #12 (.pfx)", + IDC_EXPORT_FORMAT_PFX, 31,72,200,12, BS_AUTORADIOBUTTON|WS_DISABLED + CHECKBOX "Nee&m alle certificaten in het certificatiepad op indien mogelijk", + IDC_EXPORT_PFX_INCLUDE_CHAIN, 44,87,200,8, BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED + CHECKBOX "&Gebruikt sterke encryptie", + IDC_EXPORT_PFX_STRONG_ENCRYPTION, 44,102,200,8, + BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED + CHECKBOX "Verwijder de persoonlijke s&leutel als de export succesvol is", + IDC_EXPORT_PFX_DELETE_PRIVATE_KEY, 44,117,200,8, + BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED +END + +IDD_EXPORT_FILE DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat exporteerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Bestands&naam:", -1, 21,1,195,10 + EDITTEXT IDC_EXPORT_FILENAME, 21,11,208,14, ES_AUTOHSCROLL|WS_TABSTOP + PUSHBUTTON "&Bladeren...", IDC_EXPORT_BROWSE_FILE, 236,11,60,14 +END + +IDD_EXPORT_FINISH DIALOG DISCARDABLE 0,0,317,143 +CAPTION "Certificaat exporteerhulp" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Afronden van de Certificaat exporteerhulp", IDC_EXPORT_TITLE, + 115,1,195,40 + LTEXT "U heeft de Certificaat exporteerhulp succesvol afgerond.", + -1, 115,33,195,24 + LTEXT "U heeft de volgende instellingen gespecificeerd:", + -1, 115,57,195,12 + CONTROL "", IDC_EXPORT_SETTINGS, "SysListView32", + LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, + 115,67,174,100 +END diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index 7600e232cc0..4828ab692b5 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -141,6 +141,9 @@ struct d3d10_vertex_shader { const struct ID3D10VertexShaderVtbl *vtbl; LONG refcount; + + IWineD3DVertexShader *wined3d_shader; + struct wined3d_shader_signature output_signature; }; /* ID3D10GeometryShader */ diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index bbc527b0b46..20e7c4632a6 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -141,7 +141,12 @@ static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device *iface, static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device *iface, ID3D10VertexShader *shader) { - FIXME("iface %p, shader %p stub!\n", iface, shader); + struct d3d10_device *This = (struct d3d10_device *)iface; + struct d3d10_vertex_shader *vs = (struct d3d10_vertex_shader *)shader; + + TRACE("iface %p, shader %p\n", iface, shader); + + IWineD3DDevice_SetVertexShader(This->wined3d_device, vs ? vs->wined3d_shader : NULL); } static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device *iface, @@ -231,7 +236,8 @@ static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device *if static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device *iface, ID3D10GeometryShader *shader) { - FIXME("iface %p, shader %p stub!\n", iface, shader); + if (shader) FIXME("iface %p, shader %p stub!\n", iface, shader); + else WARN("iface %p, shader %p stub!\n", iface, shader); } static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device *iface, D3D10_PRIMITIVE_TOPOLOGY topology) @@ -970,9 +976,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateInputLayout(ID3D10Device *if static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *iface, const void *byte_code, SIZE_T byte_code_length, ID3D10VertexShader **shader) { + struct d3d10_device *This = (struct d3d10_device *)iface; struct d3d10_vertex_shader *object; + struct d3d10_shader_info shader_info; + HRESULT hr; - FIXME("iface %p, byte_code %p, byte_code_length %lu, shader %p stub!\n", + TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n", iface, byte_code, byte_code_length, shader); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); @@ -985,6 +994,26 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateVertexShader(ID3D10Device *i object->vtbl = &d3d10_vertex_shader_vtbl; object->refcount = 1; + shader_info.output_signature = &object->output_signature; + hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info); + if (FAILED(hr)) + { + ERR("Failed to extract shader, hr %#x\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + hr = IWineD3DDevice_CreateVertexShader(This->wined3d_device, + shader_info.shader_code, &object->output_signature, + &object->wined3d_shader, (IUnknown *)object); + if (FAILED(hr)) + { + ERR("CreateVertexShader failed, hr %#x\n", hr); + shader_free_signature(&object->output_signature); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + *shader = (ID3D10VertexShader *)object; return S_OK; diff --git a/dlls/d3d10core/shader.c b/dlls/d3d10core/shader.c index 41b5a1a55d6..582d2a88010 100644 --- a/dlls/d3d10core/shader.c +++ b/dlls/d3d10core/shader.c @@ -176,6 +176,8 @@ static ULONG STDMETHODCALLTYPE d3d10_vertex_shader_Release(ID3D10VertexShader *i if (!refcount) { + IWineD3DVertexShader_Release(This->wined3d_shader); + shader_free_signature(&This->output_signature); HeapFree(GetProcessHeap(), 0, This); } diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 206697d99d4..6af8d1e7738 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1726,7 +1726,6 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; HRESULT hrc = D3D_OK; IDirect3DVertexShader8Impl *object; - IWineD3DVertexDeclaration *wined3d_vertex_declaration; const DWORD *token = pDeclaration; DWORD handle; @@ -1783,13 +1782,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 *ppShader = ((IDirect3DVertexDeclaration8Impl *)object->vertex_declaration)->shader_handle = shader_handle; } - wined3d_vertex_declaration = ((IDirect3DVertexDeclaration8Impl *)object->vertex_declaration)->wined3d_vertex_declaration; - if (pFunction) { /* Usage is missing ... Use SetRenderState to set the sw vp render state in SetVertexShader */ - hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, wined3d_vertex_declaration, - pFunction, &object->wineD3DVertexShader, (IUnknown *)object); + hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction, + NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object); if (FAILED(hrc)) { diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index e5ca4c4afd0..9508ff5c693 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -851,8 +851,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - HRESULT hr = D3D_OK; IWineD3DSurface *pRenderTarget; + HRESULT hr; TRACE("(%p) Relay\n" , This); @@ -863,13 +863,20 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX EnterCriticalSection(&d3d9_cs); hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget); - if (hr == D3D_OK && pRenderTarget != NULL) { - IWineD3DSurface_GetParent(pRenderTarget,(IUnknown**)ppRenderTarget); - IWineD3DSurface_Release(pRenderTarget); - } else { - FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n"); + if (FAILED(hr)) + { + FIXME("Call to IWineD3DDevice_GetRenderTarget failed, hr %#x\n", hr); + } + else if (!pRenderTarget) + { *ppRenderTarget = NULL; } + else + { + IWineD3DSurface_GetParent(pRenderTarget, (IUnknown **)ppRenderTarget); + IWineD3DSurface_Release(pRenderTarget); + } + LeaveCriticalSection(&d3d9_cs); return hr; diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index e4ab5929493..f1d3595b4b5 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -136,6 +136,56 @@ static void test_mipmap_levels(void) DestroyWindow( hwnd ); } +static void test_checkdevicemultisampletype(void) +{ + + HRESULT hr; + HWND hwnd = NULL; + + IDirect3D9 *pD3d = NULL; + IDirect3DDevice9 *pDevice = NULL; + D3DPRESENT_PARAMETERS d3dpp; + D3DDISPLAYMODE d3ddm; + DWORD qualityLevels; + + pD3d = pDirect3DCreate9( D3D_SDK_VERSION ); + ok(pD3d != NULL, "Failed to create IDirect3D9 object\n"); + hwnd = CreateWindow( "static", "d3d9_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL ); + ok(hwnd != NULL, "Failed to create window\n"); + if (!pD3d || !hwnd) goto cleanup; + + IDirect3D9_GetAdapterDisplayMode( pD3d, D3DADAPTER_DEFAULT, &d3ddm ); + ZeroMemory( &d3dpp, sizeof(d3dpp) ); + d3dpp.Windowed = TRUE; + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.BackBufferFormat = d3ddm.Format; + + hr = IDirect3D9_CreateDevice( pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF, hwnd, + D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice ); + ok(SUCCEEDED(hr) || hr == D3DERR_NOTAVAILABLE, "Failed to create IDirect3D9Device (%08x)\n", hr); + if (FAILED(hr)) { + skip("failed to create a d3d device\n"); + goto cleanup; + } + + qualityLevels = 0; + + hr = IDirect3D9_CheckDeviceMultiSampleType(pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, TRUE, + D3DMULTISAMPLE_NONE, &qualityLevels); + ok(SUCCEEDED(hr), "CheckDeviceMultiSampleType failed with (%08x)\n", hr); + ok(qualityLevels == 1,"qualitylevel is not 1 but %d\n",qualityLevels); + + hr = IDirect3D9_CheckDeviceMultiSampleType(pD3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, FALSE, + D3DMULTISAMPLE_NONE, &qualityLevels); + ok(SUCCEEDED(hr), "CheckDeviceMultiSampleType failed with (%08x)\n", hr); + ok(qualityLevels == 1,"qualitylevel is not 1 but %d\n",qualityLevels); + +cleanup: + if (pD3d) IUnknown_Release( pD3d ); + if (pDevice) IUnknown_Release( pDevice ); + DestroyWindow( hwnd ); +} + static void test_swapchain(void) { HRESULT hr; @@ -2230,6 +2280,7 @@ START_TEST(device) test_swapchain(); test_refcount(); test_mipmap_levels(); + test_checkdevicemultisampletype(); test_cursor(); test_reset(); test_scene(); diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index b6f2147987e..07a3531d3df 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -10111,6 +10111,82 @@ static void alphatest_test(IDirect3DDevice9 *device) { ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed with 0x%08x\n", hr); } +static void sincos_test(IDirect3DDevice9 *device) { + const DWORD sin_shader_code[] = { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x05000051, 0xa00f0002, 0x40490fdb, 0x3f800000, 0x00000000, 0x3f59999a, /* def c2, 3.14159, 1, 0, 0.85 */ + 0x03000005, 0x80010001, 0x90000000, 0xa0000002, /* mul r1.x, v0.x, c2.x */ + 0x04000025, 0x80020000, 0x80000001, 0xa0e40000, 0xa0e40001, /* sincos r0.y, r1.x, c0, c1 */ + 0x02000001, 0xc00d0000, 0x90e40000, /* mov oPos.xzw, v0 */ + 0x03000005, 0xc0020000, 0x80550000, 0xa0ff0002, /* mul oPos.y, r0.y, c2.w */ + 0x02000001, 0xd00f0000, 0xa0a60002, /* mov oD0, c2.zyzz */ + 0x0000ffff /* end */ + }; + const DWORD cos_shader_code[] = { + 0xfffe0200, /* vs_2_0 */ + 0x0200001f, 0x80000000, 0x900f0000, /* dcl_position v0 */ + 0x05000051, 0xa00f0002, 0x40490fdb, 0x3f800000, 0x00000000, 0x3f59999a, /* def c2, 3.14159, 1, 0, 0.85 */ + 0x03000005, 0x80010001, 0x90000000, 0xa0000002, /* mul r1.x, v0.x, c2.x */ + 0x04000025, 0x80010000, 0x80000001, 0xa0e40000, 0xa0e40001, /* sincos r0.x, r1.x, c0, c1 */ + 0x02000001, 0xc00d0000, 0x90e40000, /* mov oPos.xzw, v0 */ + 0x03000005, 0xc0020000, 0x80000000, 0xa0ff0002, /* mul oPos.y, r0.x, c2.w */ + 0x02000001, 0xd00f0000, 0xa0a90002, /* mov oD0, c2.yzzz */ + 0x0000ffff /* end */ + }; + IDirect3DVertexShader9 *sin_shader, *cos_shader; + HRESULT hr; + struct { + float x, y, z; + } data[1280]; + unsigned int i; + float sincosc1[4] = {D3DSINCOSCONST1}; + float sincosc2[4] = {D3DSINCOSCONST2}; + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr); + + hr = IDirect3DDevice9_CreateVertexShader(device, sin_shader_code, &sin_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_CreateVertexShader(device, cos_shader_code, &cos_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); + ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, sincosc1, 1); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, sincosc2, 1); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShaderConstantF failed with 0x%08x\n", hr); + + /* Generate a point from -1 to 1 every 0.5 pixels */ + for(i = 0; i < 1280; i++) { + data[i].x = (-640.0 + i) / 640.0; + data[i].y = 0.0; + data[i].z = 0.1; + } + + hr = IDirect3DDevice9_BeginScene(device); + if(SUCCEEDED(hr)) { + hr = IDirect3DDevice9_SetVertexShader(device, sin_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1280, data, sizeof(*data)); + ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed with 0x%08x\n", hr); + + hr = IDirect3DDevice9_SetVertexShader(device, cos_shader); + ok(hr == D3D_OK, "IDirect3DDevice9_SetVertexShader failed with 0x%08x\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_POINTLIST, 1280, data, sizeof(*data)); + ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed with 0x%08x\n", hr); + + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with 0x%08x\n", hr); + } + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + /* TODO: Find a way to properly validate the lines. Precicion issues make this a kinda nasty task */ + + IDirect3DDevice9_SetVertexShader(device, NULL); + IDirect3DVertexShader9_Release(sin_shader); + IDirect3DVertexShader9_Release(cos_shader); +} + START_TEST(visual) { IDirect3DDevice9 *device_ptr; @@ -10220,6 +10296,7 @@ START_TEST(visual) if (caps.VertexShaderVersion >= D3DVS_VERSION(2, 0)) { test_mova(device_ptr); + sincos_test(device_ptr); if (caps.VertexShaderVersion >= D3DVS_VERSION(3, 0)) { test_vshader_input(device_ptr); test_vshader_float16(device_ptr); diff --git a/dlls/d3d9/vertexshader.c b/dlls/d3d9/vertexshader.c index fd2837d53be..d7b680e8011 100644 --- a/dlls/d3d9/vertexshader.c +++ b/dlls/d3d9/vertexshader.c @@ -126,7 +126,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface object->ref = 1; object->lpVtbl = &Direct3DVertexShader9_Vtbl; EnterCriticalSection(&d3d9_cs); - hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, NULL /* declaration */, pFunction, &object->wineD3DVertexShader, (IUnknown *)object); + hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction, + NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object); LeaveCriticalSection(&d3d9_cs); if (FAILED(hrc)) { diff --git a/dlls/d3dx9_36/Makefile.in b/dlls/d3dx9_36/Makefile.in index 7cd5c3c6108..16fd41cd0ff 100644 --- a/dlls/d3dx9_36/Makefile.in +++ b/dlls/d3dx9_36/Makefile.in @@ -12,7 +12,8 @@ C_SRCS = \ math.c \ mesh.c \ shader.c \ - sprite.c + sprite.c \ + surface.c RC_SRCS = version.rc diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec index 8a5082d8324..1c8eecbf77c 100644 --- a/dlls/d3dx9_36/d3dx9_36.spec +++ b/dlls/d3dx9_36/d3dx9_36.spec @@ -151,11 +151,11 @@ @ stub D3DXGetDeclVertexSize @ stdcall D3DXGetDriverLevel(ptr) @ stdcall D3DXGetFVFVertexSize(long) -@ stdcall D3DXGetImageInfoFromFileA(ptr ptr) d3dx8.D3DXGetImageInfoFromFileA -@ stdcall D3DXGetImageInfoFromFileInMemory(ptr long ptr) d3dx8.D3DXGetImageInfoFromFileInMemory -@ stdcall D3DXGetImageInfoFromFileW(ptr ptr) d3dx8.D3DXGetImageInfoFromFileW -@ stdcall D3DXGetImageInfoFromResourceA(long ptr ptr) d3dx8.D3DXGetImageInfoFromResourceA -@ stdcall D3DXGetImageInfoFromResourceW(long ptr ptr) d3dx8.D3DXGetImageInfoFromResourceW +@ stdcall D3DXGetImageInfoFromFileA(str ptr) +@ stdcall D3DXGetImageInfoFromFileInMemory(ptr long ptr) +@ stdcall D3DXGetImageInfoFromFileW(wstr ptr) +@ stdcall D3DXGetImageInfoFromResourceA(long str ptr) +@ stdcall D3DXGetImageInfoFromResourceW(long wstr ptr) @ stdcall D3DXGetPixelShaderProfile(ptr) @ stub D3DXGetShaderConstantTable @ stub D3DXGetShaderConstantTableEx diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c new file mode 100644 index 00000000000..968e3efdd9a --- /dev/null +++ b/dlls/d3dx9_36/surface.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Tony Wasserka + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#include "wine/debug.h" +#include "d3dx9_36_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dx); + + +/************************************************************ + * D3DXGetImageInfoFromFileInMemory + * + * Fills a D3DXIMAGE_INFO structure with info about an image + * + * PARAMS + * data [I] pointer to the image file data + * datasize [I] size of the passed data + * info [O] pointer to the destination structure + * + * RETURNS + * Success: D3D_OK + * Failure: D3DERR_INVALIDCALL + * + */ +HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(LPCVOID data, UINT datasize, D3DXIMAGE_INFO *info) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT WINAPI D3DXGetImageInfoFromFileA(LPCSTR file, D3DXIMAGE_INFO *info) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT WINAPI D3DXGetImageInfoFromFileW(LPCWSTR file, D3DXIMAGE_INFO *info) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT WINAPI D3DXGetImageInfoFromResourceA(HMODULE module, LPCSTR resource, D3DXIMAGE_INFO *info) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} + +HRESULT WINAPI D3DXGetImageInfoFromResourceW(HMODULE module, LPCWSTR resource, D3DXIMAGE_INFO *info) +{ + FIXME("stub\n"); + return E_NOTIMPL; +} diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 44e2cadef0f..82e836f2963 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -1334,6 +1334,8 @@ static void dwarf2_parse_variable(dwarf2_subprogram_t* subpgm, switch (loc.kind) { + case loc_error: + break; case loc_absolute: /* it's a global variable */ /* FIXME: we don't handle its scope yet */ diff --git a/dlls/dplayx/dplayx_global.c b/dlls/dplayx/dplayx_global.c index 9035902f826..d7f3ccac35e 100644 --- a/dlls/dplayx/dplayx_global.c +++ b/dlls/dplayx/dplayx_global.c @@ -995,49 +995,6 @@ HRESULT DPLAYX_SetConnectionSettingsW return DP_OK; } - - -/* Copy an ANSI session desc structure to the given buffer */ -static BOOL DPLAYX_CopyIntoSessionDesc2A( LPDPSESSIONDESC2 lpSessionDest, - LPCDPSESSIONDESC2 lpSessionSrc ) -{ - CopyMemory( lpSessionDest, lpSessionSrc, sizeof( *lpSessionSrc ) ); - - if( lpSessionSrc->u1.lpszSessionNameA ) - { - if ((lpSessionDest->u1.lpszSessionNameA = HeapAlloc( GetProcessHeap(), 0, - strlen(lpSessionSrc->u1.lpszSessionNameA)+1 ))) - strcpy( lpSessionDest->u1.lpszSessionNameA, lpSessionSrc->u1.lpszSessionNameA ); - } - if( lpSessionSrc->u2.lpszPasswordA ) - { - if ((lpSessionDest->u2.lpszPasswordA = HeapAlloc( GetProcessHeap(), 0, - strlen(lpSessionSrc->u2.lpszPasswordA)+1 ))) - strcpy( lpSessionDest->u2.lpszPasswordA, lpSessionSrc->u2.lpszPasswordA ); - } - - return TRUE; -} - -void DPLAYX_SetLocalSession( LPCDPSESSIONDESC2 lpsd ) -{ - UINT i; - - /* FIXME: Is this an error if it exists already? */ - - /* Crude/wrong implementation for now. Just always add to first empty spot */ - for( i=0; i < numSupportedSessions; i++ ) - { - /* Is this one empty? */ - if( sessionData[i].dwSize == 0 ) - { - DPLAYX_CopyIntoSessionDesc2A( &sessionData[i], lpsd ); - break; - } - } - -} - BOOL DPLAYX_WaitForConnectionSettings( BOOL bWait ) { LPDPLAYX_LOBBYDATA lpLobbyData; diff --git a/dlls/dplayx/dplayx_global.h b/dlls/dplayx/dplayx_global.h index b9d48f42b30..5650348efd3 100644 --- a/dlls/dplayx/dplayx_global.h +++ b/dlls/dplayx/dplayx_global.h @@ -51,8 +51,6 @@ BOOL DPLAYX_AnyLobbiesWaitingForConnSettings(void); BOOL DPLAYX_SetLobbyHandles( DWORD dwAppID, HANDLE hStart, HANDLE hDeath, HANDLE hConnRead ); -void DPLAYX_SetLocalSession( LPCDPSESSIONDESC2 lpsd ); - BOOL DPLAYX_SetLobbyMsgThreadId( DWORD dwAppId, DWORD dwThreadId ); diff --git a/dlls/dplayx/name_server.c b/dlls/dplayx/name_server.c index 58402cc12de..65d36ef0cd6 100644 --- a/dlls/dplayx/name_server.c +++ b/dlls/dplayx/name_server.c @@ -74,10 +74,6 @@ static DPQ_DECL_DELETECB( cbDeleteNSNodeFromHeap, lpNSCacheData ); */ void NS_SetLocalComputerAsNameServer( LPCDPSESSIONDESC2 lpsd, LPVOID lpNSInfo ) { -#if 0 - /* FIXME: Remove this method? */ - DPLAYX_SetLocalSession( lpsd ); -#endif lpNSCache lpCache = (lpNSCache)lpNSInfo; lpCache->bNsIsLocal = TRUE; diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c index 2a8252f9c0f..312c90f92cd 100644 --- a/dlls/dsound/capture.c +++ b/dlls/dsound/capture.c @@ -428,7 +428,7 @@ DSOUND_capture_callback(HWAVEIN hwi, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, if (This->state == STATE_STARTING) This->state = STATE_CAPTURING; capture_CheckNotify(Moi, (DWORD_PTR)This->pwave[index].lpData - (DWORD_PTR)This->buffer, This->pwave[index].dwBufferLength); - This->index = (++This->index) % This->nrofpwaves; + This->index = (This->index + 1) % This->nrofpwaves; if ( (This->index == 0) && !(This->capture_buffer->flags & DSCBSTART_LOOPING) ) { TRACE("end of buffer\n"); This->state = STATE_STOPPED; diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec index 34c897a6dd0..dff3cf35b30 100644 --- a/dlls/gdiplus/gdiplus.spec +++ b/dlls/gdiplus/gdiplus.spec @@ -94,7 +94,7 @@ @ stdcall GdipCreateFromHWND(long ptr) @ stdcall GdipCreateFromHWNDICM(long ptr) @ stdcall GdipCreateHBITMAPFromBitmap(ptr ptr long) -@ stub GdipCreateHICONFromBitmap +@ stdcall GdipCreateHICONFromBitmap(ptr ptr) @ stdcall GdipCreateHalftonePalette() @ stdcall GdipCreateHatchBrush(long long long ptr) @ stdcall GdipCreateImageAttributes(ptr) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 9902f0f69ab..29eb00026b8 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -655,6 +655,13 @@ GpStatus WINGDIPAPI GdipCreateCachedBitmap(GpBitmap *bitmap, GpGraphics *graphic return Ok; } +GpStatus WINGDIPAPI GdipCreateHICONFromBitmap(GpBitmap *bitmap, HICON *hicon) +{ + FIXME("(%p, %p)\n", bitmap, hicon); + + return NotImplemented; +} + GpStatus WINGDIPAPI GdipDeleteCachedBitmap(GpCachedBitmap *cachedbmp) { TRACE("%p\n", cachedbmp); diff --git a/dlls/gphoto2.ds/ds_image.c b/dlls/gphoto2.ds/ds_image.c index ae6e11523de..ec29efffe03 100644 --- a/dlls/gphoto2.ds/ds_image.c +++ b/dlls/gphoto2.ds/ds_image.c @@ -460,7 +460,7 @@ TW_UINT16 GPHOTO2_ImageNativeXferGet (pTW_IDENTITY pOrigin, gp_file_unref (activeDS.file); activeDS.file = NULL; ReleaseDC (activeDS.hwndOwner, dc); - *pHandle = (TW_UINT32)hDIB; + *pHandle = (UINT_PTR)hDIB; activeDS.twCC = TWCC_SUCCESS; activeDS.currentState = 7; return TWRC_XFERDONE; diff --git a/dlls/gphoto2.ds/gphoto2_main.c b/dlls/gphoto2.ds/gphoto2_main.c index ab4f392d2e4..5d80d4c4edc 100644 --- a/dlls/gphoto2.ds/gphoto2_main.c +++ b/dlls/gphoto2.ds/gphoto2_main.c @@ -37,12 +37,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(twain); +#ifdef HAVE_GPHOTO2 static char* GPHOTO2_StrDup(const char* str) { char* dst = HeapAlloc(GetProcessHeap(), 0, strlen(str)+1); strcpy(dst, str); return dst; } +#endif static void load_filesystem(const char *folder) { diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index c7d170c03a7..cb97ecd7f27 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -528,7 +528,7 @@ BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags) } else if (dwFlags == IACE_IGNORENOCONTEXT) { - if (GetPropW(hWnd,szwWineIMCProperty) > 0) + if (GetPropW(hWnd,szwWineIMCProperty)) ImmAssociateContext(hWnd,hIMC); return TRUE; } diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index 68bfef82a84..c0663973493 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -17,6 +17,7 @@ */ #include +#include #include "jscript.h" #include "activscp.h" @@ -374,13 +375,19 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li { double d, tmp = 1.0; - if(ctx->ptr == ctx->end || !isdigitW(*ctx->ptr)) { - ERR("No digit after point\n"); + if(ctx->ptr == ctx->end || (!isdigitW(*ctx->ptr) && + *ctx->ptr!='.' && *ctx->ptr!='e' && *ctx->ptr!='E')) { + ERR("Illegal character\n"); return 0; } d = int_part; while(ctx->ptr < ctx->end && isdigitW(*ctx->ptr)) + d = d*10 + *(ctx->ptr++) - '0'; + + if(*ctx->ptr == '.') ctx->ptr++; + + while(ctx->ptr < ctx->end && isdigitW(*ctx->ptr)) d += (tmp /= 10.0)*(*ctx->ptr++ - '0'); if(ctx->ptr < ctx->end && (*ctx->ptr == 'e' || *ctx->ptr == 'E')) { @@ -458,13 +465,20 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal) } while(ctx->ptr < ctx->end && isdigitW(*ctx->ptr)) - l = l*10 + *(ctx->ptr++)-'0'; + { + d = l*10 + *(ctx->ptr)-'0'; + + /* Check for integer overflow */ + if (l > INT_MAX/10 || d < 0) + return parse_double_literal(ctx, l, literal); + + l = d; + ctx->ptr++; + } if(ctx->ptr < ctx->end) { - if(*ctx->ptr == '.') { - ctx->ptr++; + if(*ctx->ptr == '.' || *ctx->ptr == 'e' || *ctx->ptr == 'E') return parse_double_literal(ctx, l, literal); - } if(is_identifier_char(*ctx->ptr)) { WARN("unexpected identifier char\n"); diff --git a/dlls/jscript/math.c b/dlls/jscript/math.c index ac487d133b9..9d609e5d8c0 100644 --- a/dlls/jscript/math.c +++ b/dlls/jscript/math.c @@ -105,8 +105,8 @@ static HRESULT Math_LN2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d static HRESULT Math_LN10(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("\n"); + return math_constant(M_LN10, flags, retv); } /* ECMA-262 3rd Edition 15.8.1.6 */ @@ -120,15 +120,15 @@ static HRESULT Math_PI(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp static HRESULT Math_SQRT2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("\n"); + return math_constant(M_SQRT2, flags, retv); } static HRESULT Math_SQRT1_2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("\n"); + return math_constant(M_SQRT1_2, flags, retv); } /* ECMA-262 3rd Edition 15.8.2.12 */ @@ -160,29 +160,89 @@ static HRESULT Math_abs(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d static HRESULT Math_acos(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, acos(num_val(&v))); + return S_OK; } static HRESULT Math_asin(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, asin(num_val(&v))); + return S_OK; } static HRESULT Math_atan(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, atan(num_val(&v))); + return S_OK; } static HRESULT Math_atan2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v1, v2; + HRESULT hres; + + TRACE("\n"); + + if(arg_cnt(dp)<2) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v1); + if(FAILED(hres)) + return hres; + + hres = to_number(dispex->ctx, get_arg(dp, 1), ei, &v2); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, atan2(num_val(&v1), num_val(&v2))); + return S_OK; } /* ECMA-262 3rd Edition 15.8.2.6 */ @@ -233,8 +293,22 @@ static HRESULT Math_cos(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d static HRESULT Math_exp(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, exp(num_val(&v))); + return S_OK; } static HRESULT Math_floor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, @@ -263,8 +337,24 @@ static HRESULT Math_floor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS static HRESULT Math_log(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) + num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) + num_set_val(retv, log(num_val(&v))); + return S_OK; } /* ECMA-262 3rd Edition 15.8.2.11 */ @@ -351,8 +441,8 @@ static HRESULT Math_pow(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d TRACE("\n"); if(arg_cnt(dp) < 2) { - FIXME("unimplemented arg_cnt %d\n", arg_cnt(dp)); - return E_NOTIMPL; + if(retv) num_set_nan(retv); + return S_OK; } hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &x); @@ -411,22 +501,64 @@ static HRESULT Math_round(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS static HRESULT Math_sin(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, sin(num_val(&v))); + return S_OK; } static HRESULT Math_sqrt(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, sqrt(num_val(&v))); + return S_OK; } static HRESULT Math_tan(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) num_set_nan(retv); + return S_OK; + } + + hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &v); + if(FAILED(hres)) + return hres; + + if(retv) num_set_val(retv, tan(num_val(&v))); + return S_OK; } static const builtin_prop_t Math_props[] = { diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index e79fee45aab..fe552b10778 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -3396,7 +3396,7 @@ HRESULT regexp_match(DispatchEx *dispex, const WCHAR *str, DWORD len, BOOL gflag } if(FAILED(hres)) - return hres; + break; if(ret_size == i) { if(ret) diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 30f201738e7..a17b0670877 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -618,6 +618,12 @@ ok(tmp === 2, "Math.pow(2, 2) = " + tmp); tmp = Math.pow(2, 2, 3); ok(tmp === 4, "Math.pow(2, 2, 3) = " + tmp); +tmp = Math.pow(2); +ok(isNaN(tmp), "Math.pow(2) is not NaN"); + +tmp = Math.pow(); +ok(isNaN(tmp), "Math.pow() is not NaN"); + tmp = Math.random(); ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp)); ok(0 <= tmp && tmp <= 1, "Math.random() = " + tmp); @@ -626,6 +632,285 @@ tmp = Math.random(100); ok(typeof(tmp) == "number", "typeof(tmp) = " + typeof(tmp)); ok(0 <= tmp && tmp <= 1, "Math.random(100) = " + tmp); +tmp = Math.acos(0); +ok(Math.floor(tmp*100) === 157, "Math.acos(0) = " + tmp); + +tmp = Math.acos(1); +ok(Math.floor(tmp*100) === 0, "Math.acos(1) = " + tmp); + +tmp = Math.acos(-1); +ok(Math.floor(tmp*100) === 314, "Math.acos(-1) = " + tmp); + +tmp = Math.acos(Math.PI/4, 2); +ok(Math.floor(tmp*100) === 66, "Math.acos(Math.PI/4, 2) = " + tmp); + +tmp = Math.acos(true); +ok(Math.floor(tmp*100) === 0, "Math.acos(true) = " + tmp); + +tmp = Math.acos(false); +ok(Math.floor(tmp*100) === 157, "Math.acos(false) = " + tmp); + +tmp = Math.acos(1.1); +ok(isNaN(tmp), "Math.acos(1.1) is not NaN"); + +tmp = Math.acos(); +ok(isNaN(tmp), "Math.acos() is not NaN"); + +tmp = Math.acos(NaN); +ok(isNaN(tmp), "Math.acos(NaN) is not NaN"); + +tmp = Math.acos(Infinity); +ok(isNaN(tmp), "Math.acos(Infinity) is not NaN"); + +tmp = Math.acos(-Infinity); +ok(isNaN(tmp), "Math.acos(-Infinity) is not NaN"); + +tmp = Math.asin(0); +ok(Math.floor(tmp*100) === 0, "Math.asin(0) = " + tmp); + +tmp = Math.asin(1); +ok(Math.floor(tmp*100) === 157, "Math.asin(1) = " + tmp); + +tmp = Math.asin(-1); +ok(Math.floor(tmp*100) === -158, "Math.asin(-1) = " + tmp); + +tmp = Math.asin(Math.PI/4, 2); +ok(Math.floor(tmp*100) === 90, "Math.asin(Math.PI/4, 2) = " + tmp); + +tmp = Math.asin(true); +ok(Math.floor(tmp*100) === 157, "Math.asin(true) = " + tmp); + +tmp = Math.asin(false); +ok(Math.floor(tmp*100) === 0, "Math.asin(false) = " + tmp); + +tmp = Math.asin(1.1); +ok(isNaN(tmp), "Math.asin(1.1) is not NaN"); + +tmp = Math.asin(); +ok(isNaN(tmp), "Math.asin() is not NaN"); + +tmp = Math.asin(NaN); +ok(isNaN(tmp), "Math.asin(NaN) is not NaN"); + +tmp = Math.asin(Infinity); +ok(isNaN(tmp), "Math.asin(Infinity) is not NaN"); + +tmp = Math.asin(-Infinity); +ok(isNaN(tmp), "Math.asin(-Infinity) is not NaN"); + +tmp = Math.atan(0); +ok(Math.floor(tmp*100) === 0, "Math.atan(0) = " + tmp); + +tmp = Math.atan(1); +ok(Math.floor(tmp*100) === 78, "Math.atan(1) = " + tmp); + +tmp = Math.atan(-1); +ok(Math.floor(tmp*100) === -79, "Math.atan(-1) = " + tmp); + +tmp = Math.atan(true); +ok(Math.floor(tmp*100) === 78, "Math.atan(true) = " + tmp); + +tmp = Math.atan(false); +ok(Math.floor(tmp*100) === 0, "Math.atan(false) = " + tmp); + +tmp = Math.atan(); +ok(isNaN(tmp), "Math.atan() is not NaN"); + +tmp = Math.atan(NaN); +ok(isNaN(tmp), "Math.atan(NaN) is not NaN"); + +tmp = Math.atan(Infinity); +ok(Math.floor(tmp*100) === 157, "Math.atan(Infinity) = " + tmp); + +tmp = Math.atan(-Infinity); +ok(Math.floor(tmp*100) === -158, "Math.atan(Infinity) = " + tmp); + +tmp = Math.atan2(0, 0); +ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 0) = " + tmp); + +tmp = Math.atan2(0, 1); +ok(Math.floor(tmp*100) === 0, "Math.atan2(0, 1) = " + tmp); + +tmp = Math.atan2(0, Infinity); +ok(Math.floor(tmp*100) === 0, "Math.atan2(0, Infinity) = " + tmp); + +tmp = Math.atan2(0, -1); +ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -1) = " + tmp); + +tmp = Math.atan2(0, -Infinity); +ok(Math.floor(tmp*100) === 314, "Math.atan2(0, -Infinity) = " + tmp); + +tmp = Math.atan2(1, 0); +ok(Math.floor(tmp*100) === 157, "Math.atan2(1, 0) = " + tmp); + +tmp = Math.atan2(Infinity, 0); +ok(Math.floor(tmp*100) === 157, "Math.atan2(Infinity, 0) = " + tmp); + +tmp = Math.atan2(-1, 0); +ok(Math.floor(tmp*100) === -158, "Math.atan2(-1, 0) = " + tmp); + +tmp = Math.atan2(-Infinity, 0); +ok(Math.floor(tmp*100) === -158, "Math.atan2(-Infinity, 0) = " + tmp); + +tmp = Math.atan2(1, 1); +ok(Math.floor(tmp*100) === 78, "Math.atan2(1, 1) = " + tmp); + +tmp = Math.atan2(-1, -1); +ok(Math.floor(tmp*100) === -236, "Math.atan2(-1, -1) = " + tmp); + +tmp = Math.atan2(-1, 1); +ok(Math.floor(tmp*100) === -79, "Math.atan2(-1, 1) = " + tmp); + +tmp = Math.atan2(Infinity, Infinity); +ok(Math.floor(tmp*100) === 78, "Math.atan2(Infinity, Infinity) = " + tmp); + +tmp = Math.atan2(Infinity, -Infinity, 1); +ok(Math.floor(tmp*100) === 235, "Math.atan2(Infinity, -Infinity, 1) = " + tmp); + +tmp = Math.atan2(); +ok(isNaN(tmp), "Math.atan2() is not NaN"); + +tmp = Math.atan2(1); +ok(isNaN(tmp), "Math.atan2(1) is not NaN"); + +tmp = Math.exp(0); +ok(tmp === 1, "Math.exp(0) = " + tmp); + +tmp = Math.exp(1); +ok(Math.floor(tmp*100) === 271, "Math.exp(1) = " + tmp); + +tmp = Math.exp(-1); +ok(Math.floor(tmp*100) === 36, "Math.exp(-1) = " + tmp); + +tmp = Math.exp(true); +ok(Math.floor(tmp*100) === 271, "Math.exp(true) = " + tmp); + +tmp = Math.exp(1, 1); +ok(Math.floor(tmp*100) === 271, "Math.exp(1, 1) = " + tmp); + +tmp = Math.exp(); +ok(isNaN(tmp), "Math.exp() is not NaN"); + +tmp = Math.exp(NaN); +ok(isNaN(tmp), "Math.exp(NaN) is not NaN"); + +tmp = Math.exp(Infinity); +ok(tmp === Infinity, "Math.exp(Infinity) = " + tmp); + +tmp = Math.exp(-Infinity); +ok(tmp === 0, "Math.exp(-Infinity) = " + tmp); + +tmp = Math.log(1); +ok(Math.floor(tmp*100) === 0, "Math.log(1) = " + tmp); + +tmp = Math.log(-1); +ok(isNaN(tmp), "Math.log(-1) is not NaN"); + +tmp = Math.log(true); +ok(Math.floor(tmp*100) === 0, "Math.log(true) = " + tmp); + +tmp = Math.log(1, 1); +ok(Math.floor(tmp*100) === 0, "Math.log(1, 1) = " + tmp); + +tmp = Math.log(); +ok(isNaN(tmp), "Math.log() is not NaN"); + +tmp = Math.log(NaN); +ok(isNaN(tmp), "Math.log(NaN) is not NaN"); + +tmp = Math.log(Infinity); +ok(tmp === Infinity, "Math.log(Infinity) = " + tmp); + +tmp = Math.log(-Infinity); +ok(isNaN(tmp), "Math.log(-Infinity) is not NaN"); + +tmp = Math.sin(0); +ok(tmp === 0, "Math.sin(0) = " + tmp); + +tmp = Math.sin(Math.PI/2); +ok(tmp === 1, "Math.sin(Math.PI/2) = " + tmp); + +tmp = Math.sin(-Math.PI/2); +ok(tmp === -1, "Math.sin(-Math.PI/2) = " + tmp); + +tmp = Math.sin(Math.PI/3, 2); +ok(Math.floor(tmp*100) === 86, "Math.sin(Math.PI/3, 2) = " + tmp); + +tmp = Math.sin(true); +ok(Math.floor(tmp*100) === 84, "Math.sin(true) = " + tmp); + +tmp = Math.sin(false); +ok(tmp === 0, "Math.sin(false) = " + tmp); + +tmp = Math.sin(); +ok(isNaN(tmp), "Math.sin() is not NaN"); + +tmp = Math.sin(NaN); +ok(isNaN(tmp), "Math.sin(NaN) is not NaN"); + +tmp = Math.sin(Infinity); +ok(isNaN(tmp), "Math.sin(Infinity) is not NaN"); + +tmp = Math.sin(-Infinity); +ok(isNaN(tmp), "Math.sin(-Infinity) is not NaN"); + +tmp = Math.sqrt(0); +ok(tmp === 0, "Math.sqrt(0) = " + tmp); + +tmp = Math.sqrt(4); +ok(tmp === 2, "Math.sqrt(4) = " + tmp); + +tmp = Math.sqrt(-1); +ok(isNaN(tmp), "Math.sqrt(-1) is not NaN"); + +tmp = Math.sqrt(2, 2); +ok(Math.floor(tmp*100) === 141, "Math.sqrt(2, 2) = " + tmp); + +tmp = Math.sqrt(true); +ok(tmp === 1, "Math.sqrt(true) = " + tmp); + +tmp = Math.sqrt(false); +ok(tmp === 0, "Math.sqrt(false) = " + tmp); + +tmp = Math.sqrt(); +ok(isNaN(tmp), "Math.sqrt() is not NaN"); + +tmp = Math.sqrt(NaN); +ok(isNaN(tmp), "Math.sqrt(NaN) is not NaN"); + +tmp = Math.sqrt(Infinity); +ok(tmp === Infinity, "Math.sqrt(Infinity) = " + tmp); + +tmp = Math.sqrt(-Infinity); +ok(isNaN(tmp), "Math.sqrt(-Infinity) is not NaN"); + +tmp = Math.tan(0); +ok(tmp === 0, "Math.tan(0) = " + tmp); + +tmp = Math.tan(Math.PI); +ok(Math.floor(tmp*100) === -1, "Math.tan(Math.PI) = " + tmp); + +tmp = Math.tan(2, 2); +ok(Math.floor(tmp*100) === -219, "Math.tan(2, 2) = " + tmp); + +tmp = Math.tan(true); +ok(Math.floor(tmp*100) === 155, "Math.tan(true) = " + tmp); + +tmp = Math.tan(false); +ok(tmp === 0, "Math.tan(false) = " + tmp); + +tmp = Math.tan(); +ok(isNaN(tmp), "Math.tan() is not NaN"); + +tmp = Math.tan(NaN); +ok(isNaN(tmp), "Math.tan(NaN) is not NaN"); + +tmp = Math.tan(Infinity); +ok(isNaN(tmp), "Math.tan(Infinity) is not NaN"); + +tmp = Math.tan(-Infinity); +ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN"); + var func = function (a) { var a = 1; if(a) return; @@ -675,4 +960,19 @@ ok(Math.floor(Math.LN2*100) === 69, "Math.LN2 = " + Math.LN2); Math.LN2 = "test"; ok(Math.floor(Math.LN2*100) === 69, "modified Math.LN2 = " + Math.LN2); +ok(typeof(Math.LN10) === "number", "typeof(Math.LN10) = " + typeof(Math.LN10)); +ok(Math.floor(Math.LN10*100) === 230, "Math.LN10 = " + Math.LN10); +Math.LN10 = "test"; +ok(Math.floor(Math.LN10*100) === 230, "modified Math.LN10 = " + Math.LN10); + +ok(typeof(Math.SQRT2) === "number", "typeof(Math.SQRT2) = " + typeof(Math.SQRT2)); +ok(Math.floor(Math.SQRT2*100) === 141, "Math.SQRT2 = " + Math.SQRT2); +Math.SQRT2 = "test"; +ok(Math.floor(Math.SQRT2*100) === 141, "modified Math.SQRT2 = " + Math.SQRT2); + +ok(typeof(Math.SQRT1_2) === "number", "typeof(Math.SQRT1_2) = " + typeof(Math.SQRT1_2)); +ok(Math.floor(Math.SQRT1_2*100) === 70, "Math.SQRT1_2 = " + Math.SQRT1_2); +Math.SQRT1_2 = "test"; +ok(Math.floor(Math.SQRT1_2*100) === 70, "modified Math.SQRT1_2 = " + Math.SQRT1_2); + reportSuccess(); diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index 0d68f377724..c4f0194160f 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -33,6 +33,8 @@ ok(true === true, "true === true is false"); ok(null === null, "null === null is false"); ok(undefined === undefined, "undefined === undefined is false"); ok(!(undefined === null), "!(undefined === null) is false"); +ok(1E0 === 1, "1E0 === 1 is false"); +ok(1000000*1000000 === 1000000000000, "1000000*1000000 === 1000000000000 is false"); ok(1 !== 2, "1 !== 2 is false"); ok(null !== undefined, "null !== undefined is false"); diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c index c08fb5112ac..c78c7628f5c 100644 --- a/dlls/kernel32/heap.c +++ b/dlls/kernel32/heap.c @@ -375,6 +375,9 @@ HGLOBAL WINAPI GlobalAlloc( pintern = HeapAlloc(GetProcessHeap(), 0, sizeof(GLOBAL32_INTERN)); if (pintern) { + /* Mask out obsolete flags */ + flags &= ~(GMEM_LOWER | GMEM_NOCOMPACT | GMEM_NOT_BANKED | GMEM_NOTIFY); + pintern->Magic = MAGIC_GLOBAL_USED; pintern->Flags = flags >> 8; pintern->LockCount = 0; diff --git a/dlls/kernel32/kernel.rc b/dlls/kernel32/kernel.rc index 29df6949fa5..30d1dcaa8cd 100644 --- a/dlls/kernel32/kernel.rc +++ b/dlls/kernel32/kernel.rc @@ -24,5 +24,6 @@ #include "nls/winerr_kor.mc.rc" #include "nls/winerr_nld.mc.rc" #include "nls/winerr_nor.mc.rc" +#include "nls/winerr_plk.mc.rc" #include "version.rc" diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c index 1b259e57d2a..86675b64d66 100644 --- a/dlls/kernel32/module.c +++ b/dlls/kernel32/module.c @@ -922,12 +922,6 @@ HMODULE WINAPI LoadLibraryExW(LPCWSTR libnameW, HANDLE hfile, DWORD flags) UNICODE_STRING wstr; HMODULE res; - if (hfile) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - if (!libnameW) { SetLastError(ERROR_INVALID_PARAMETER); diff --git a/dlls/kernel32/nls/dea.nls b/dlls/kernel32/nls/dea.nls index 39d6b80c96e..777961dd3f7 100644 --- a/dlls/kernel32/nls/dea.nls +++ b/dlls/kernel32/nls/dea.nls @@ -136,21 +136,21 @@ STRINGTABLE LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN LOCALE_STIMEFORMAT "HH:mm:ss" LOCALE_SYEARMONTH "MMMM yyyy" - LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Western Europe and United States" - LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Central Europe" - LGRPID_BALTIC+LGRPID_RES_BASE "Baltic" - LGRPID_GREEK+LGRPID_RES_BASE "Greek" - LGRPID_CYRILLIC+LGRPID_RES_BASE "Cyrillic" - LGRPID_TURKISH+LGRPID_RES_BASE "Turkic" - LGRPID_JAPANESE+LGRPID_RES_BASE "Japanese" - LGRPID_KOREAN+LGRPID_RES_BASE "Korean" - LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Traditional Chinese" - LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Simplified Chinese" + LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Westeuropa und Vereinigte Staaten" + LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Mitteleuropa" + LGRPID_BALTIC+LGRPID_RES_BASE "Baltisch" + LGRPID_GREEK+LGRPID_RES_BASE "Griechisch" + LGRPID_CYRILLIC+LGRPID_RES_BASE "Kyrillisch" + LGRPID_TURKISH+LGRPID_RES_BASE "Türkisch" + LGRPID_JAPANESE+LGRPID_RES_BASE "Japanisch" + LGRPID_KOREAN+LGRPID_RES_BASE "Koreanisch" + LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Chinesisch (Traditionell)" + LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Chinesisch (Vereinfacht)" LGRPID_THAI+LGRPID_RES_BASE "Thai" - LGRPID_HEBREW+LGRPID_RES_BASE "Hebrew" - LGRPID_ARABIC+LGRPID_RES_BASE "Arabic" - LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamese" - LGRPID_INDIC+LGRPID_RES_BASE "Indic" - LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgian" - LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenian" + LGRPID_HEBREW+LGRPID_RES_BASE "Hebräisch" + LGRPID_ARABIC+LGRPID_RES_BASE "Arabisch" + LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamesisch" + LGRPID_INDIC+LGRPID_RES_BASE "Indisch" + LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgisch" + LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenisch" } diff --git a/dlls/kernel32/nls/dec.nls b/dlls/kernel32/nls/dec.nls index 0badeeb9536..a77cac021f8 100644 --- a/dlls/kernel32/nls/dec.nls +++ b/dlls/kernel32/nls/dec.nls @@ -136,21 +136,21 @@ STRINGTABLE LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_LIECHTENSTEIN LOCALE_STIMEFORMAT "HH:mm:ss" LOCALE_SYEARMONTH "MMMM yyyy" - LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Western Europe and United States" - LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Central Europe" - LGRPID_BALTIC+LGRPID_RES_BASE "Baltic" - LGRPID_GREEK+LGRPID_RES_BASE "Greek" - LGRPID_CYRILLIC+LGRPID_RES_BASE "Cyrillic" - LGRPID_TURKISH+LGRPID_RES_BASE "Turkic" - LGRPID_JAPANESE+LGRPID_RES_BASE "Japanese" - LGRPID_KOREAN+LGRPID_RES_BASE "Korean" - LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Traditional Chinese" - LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Simplified Chinese" + LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Westeuropa und Vereinigte Staaten" + LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Mitteleuropa" + LGRPID_BALTIC+LGRPID_RES_BASE "Baltisch" + LGRPID_GREEK+LGRPID_RES_BASE "Griechisch" + LGRPID_CYRILLIC+LGRPID_RES_BASE "Kyrillisch" + LGRPID_TURKISH+LGRPID_RES_BASE "Türkisch" + LGRPID_JAPANESE+LGRPID_RES_BASE "Japanisch" + LGRPID_KOREAN+LGRPID_RES_BASE "Koreanisch" + LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Chinesisch (Traditionell)" + LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Chinesisch (Vereinfacht)" LGRPID_THAI+LGRPID_RES_BASE "Thai" - LGRPID_HEBREW+LGRPID_RES_BASE "Hebrew" - LGRPID_ARABIC+LGRPID_RES_BASE "Arabic" - LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamese" - LGRPID_INDIC+LGRPID_RES_BASE "Indic" - LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgian" - LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenian" + LGRPID_HEBREW+LGRPID_RES_BASE "Hebräisch" + LGRPID_ARABIC+LGRPID_RES_BASE "Arabisch" + LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamesisch" + LGRPID_INDIC+LGRPID_RES_BASE "Indisch" + LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgisch" + LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenisch" } diff --git a/dlls/kernel32/nls/del.nls b/dlls/kernel32/nls/del.nls index a848e0c2737..396be9f85ec 100644 --- a/dlls/kernel32/nls/del.nls +++ b/dlls/kernel32/nls/del.nls @@ -136,21 +136,21 @@ STRINGTABLE LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_LUXEMBOURG LOCALE_STIMEFORMAT "HH:mm:ss" LOCALE_SYEARMONTH "MMMM yyyy" - LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Western Europe and United States" - LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Central Europe" - LGRPID_BALTIC+LGRPID_RES_BASE "Baltic" - LGRPID_GREEK+LGRPID_RES_BASE "Greek" - LGRPID_CYRILLIC+LGRPID_RES_BASE "Cyrillic" - LGRPID_TURKISH+LGRPID_RES_BASE "Turkic" - LGRPID_JAPANESE+LGRPID_RES_BASE "Japanese" - LGRPID_KOREAN+LGRPID_RES_BASE "Korean" - LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Traditional Chinese" - LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Simplified Chinese" + LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Westeuropa und Vereinigte Staaten" + LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Mitteleuropa" + LGRPID_BALTIC+LGRPID_RES_BASE "Baltisch" + LGRPID_GREEK+LGRPID_RES_BASE "Griechisch" + LGRPID_CYRILLIC+LGRPID_RES_BASE "Kyrillisch" + LGRPID_TURKISH+LGRPID_RES_BASE "Türkisch" + LGRPID_JAPANESE+LGRPID_RES_BASE "Japanisch" + LGRPID_KOREAN+LGRPID_RES_BASE "Koreanisch" + LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Chinesisch (Traditionell)" + LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Chinesisch (Vereinfacht)" LGRPID_THAI+LGRPID_RES_BASE "Thai" - LGRPID_HEBREW+LGRPID_RES_BASE "Hebrew" - LGRPID_ARABIC+LGRPID_RES_BASE "Arabic" - LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamese" - LGRPID_INDIC+LGRPID_RES_BASE "Indic" - LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgian" - LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenian" + LGRPID_HEBREW+LGRPID_RES_BASE "Hebräisch" + LGRPID_ARABIC+LGRPID_RES_BASE "Arabisch" + LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamesisch" + LGRPID_INDIC+LGRPID_RES_BASE "Indisch" + LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgisch" + LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenisch" } diff --git a/dlls/kernel32/nls/des.nls b/dlls/kernel32/nls/des.nls index bdee8763e64..acc470ae081 100644 --- a/dlls/kernel32/nls/des.nls +++ b/dlls/kernel32/nls/des.nls @@ -136,21 +136,21 @@ STRINGTABLE LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS LOCALE_STIMEFORMAT "HH:mm:ss" LOCALE_SYEARMONTH "MMMM yyyy" - LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Western Europe and United States" - LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Central Europe" - LGRPID_BALTIC+LGRPID_RES_BASE "Baltic" - LGRPID_GREEK+LGRPID_RES_BASE "Greek" - LGRPID_CYRILLIC+LGRPID_RES_BASE "Cyrillic" - LGRPID_TURKISH+LGRPID_RES_BASE "Turkic" - LGRPID_JAPANESE+LGRPID_RES_BASE "Japanese" - LGRPID_KOREAN+LGRPID_RES_BASE "Korean" - LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Traditional Chinese" - LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Simplified Chinese" + LGRPID_WESTERN_EUROPE+LGRPID_RES_BASE "Westeuropa und Vereinigte Staaten" + LGRPID_CENTRAL_EUROPE+LGRPID_RES_BASE "Mitteleuropa" + LGRPID_BALTIC+LGRPID_RES_BASE "Baltisch" + LGRPID_GREEK+LGRPID_RES_BASE "Griechisch" + LGRPID_CYRILLIC+LGRPID_RES_BASE "Kyrillisch" + LGRPID_TURKISH+LGRPID_RES_BASE "Türkisch" + LGRPID_JAPANESE+LGRPID_RES_BASE "Japanisch" + LGRPID_KOREAN+LGRPID_RES_BASE "Koreanisch" + LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Chinesisch (Traditionell)" + LGRPID_SIMPLIFIED_CHINESE+LGRPID_RES_BASE "Chinesisch (Vereinfacht)" LGRPID_THAI+LGRPID_RES_BASE "Thai" - LGRPID_HEBREW+LGRPID_RES_BASE "Hebrew" - LGRPID_ARABIC+LGRPID_RES_BASE "Arabic" - LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamese" - LGRPID_INDIC+LGRPID_RES_BASE "Indic" - LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgian" - LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenian" + LGRPID_HEBREW+LGRPID_RES_BASE "Hebräisch" + LGRPID_ARABIC+LGRPID_RES_BASE "Arabisch" + LGRPID_VIETNAMESE+LGRPID_RES_BASE "Vietnamesisch" + LGRPID_INDIC+LGRPID_RES_BASE "Indisch" + LGRPID_GEORGIAN+LGRPID_RES_BASE "Georgisch" + LGRPID_ARMENIAN+LGRPID_RES_BASE "Armenisch" } diff --git a/dlls/kernel32/nls/deu.nls b/dlls/kernel32/nls/deu.nls index 4e392334a83..a4d39b472e5 100644 --- a/dlls/kernel32/nls/deu.nls +++ b/dlls/kernel32/nls/deu.nls @@ -141,7 +141,7 @@ STRINGTABLE LANGUAGE LANG_GERMAN, SUBLANG_GERMAN LGRPID_BALTIC+LGRPID_RES_BASE "Baltisch" LGRPID_GREEK+LGRPID_RES_BASE "Griechisch" LGRPID_CYRILLIC+LGRPID_RES_BASE "Kyrillisch" - LGRPID_TURKISH+LGRPID_RES_BASE "Turkisch" + LGRPID_TURKISH+LGRPID_RES_BASE "Türkisch" LGRPID_JAPANESE+LGRPID_RES_BASE "Japanisch" LGRPID_KOREAN+LGRPID_RES_BASE "Koreanisch" LGRPID_TRADITIONAL_CHINESE+LGRPID_RES_BASE "Chinesisch (Traditionell)" diff --git a/dlls/kernel32/powermgnt.c b/dlls/kernel32/powermgnt.c index 9236d8f1281..8d410446de1 100644 --- a/dlls/kernel32/powermgnt.c +++ b/dlls/kernel32/powermgnt.c @@ -37,10 +37,21 @@ BOOL WINAPI GetDevicePowerState(HANDLE hDevice, BOOL* pfOn) /*********************************************************************** * GetSystemPowerStatus (KERNEL32.@) */ -BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr) +BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS ps) { - WARN("(): stub, harmless.\n"); - return FALSE; /* no power management support */ + WARN("(%p): stub, harmless.\n", ps); + + if (ps) + { + ps->ACLineStatus = 255; + ps->BatteryFlag = 255; + ps->BatteryLifePercent = 255; + ps->Reserved1 = 0; + ps->BatteryLifeTime = ~0u; + ps->BatteryFullLifeTime = ~0u; + return TRUE; + } + return FALSE; } /*********************************************************************** diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index 86ad4e55a40..2328d37dba3 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -1376,7 +1376,12 @@ static void test_FindFirstFileA(void) /* try FindFirstFileA on "C:\foo\" */ SetLastError( 0xdeadbeaf ); - GetTempFileNameA( buffer, "foo", 0, nonexistent ); + if (!GetTempFileNameA( buffer, "foo", 0, nonexistent ) && GetLastError() == ERROR_ACCESS_DENIED) + { + char tmp[MAX_PATH]; + GetTempPathA( sizeof(tmp), tmp ); + GetTempFileNameA( tmp, "foo", 0, nonexistent ); + } DeleteFileA( nonexistent ); strcpy(buffer2, nonexistent); strcat(buffer2, "\\"); diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index 39517ccb0ec..19b410678e5 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -362,9 +362,58 @@ static void test_heap(void) GlobalFree(gbl); } +static void test_obsolete_flags(void) +{ + static struct { + UINT flags; + UINT globalflags; + } test_global_flags[] = { + {GMEM_FIXED | GMEM_NOTIFY, 0}, + {GMEM_FIXED | GMEM_DISCARDABLE, 0}, + {GMEM_MOVEABLE | GMEM_NOTIFY, 0}, + {GMEM_MOVEABLE | GMEM_DDESHARE, GMEM_DDESHARE}, + {GMEM_MOVEABLE | GMEM_NOT_BANKED, 0}, + {GMEM_MOVEABLE | GMEM_NODISCARD, 0}, + {GMEM_MOVEABLE | GMEM_DISCARDABLE, GMEM_DISCARDABLE}, + {GMEM_MOVEABLE | GMEM_DDESHARE | GMEM_DISCARDABLE | GMEM_LOWER | GMEM_NOCOMPACT | GMEM_NODISCARD | + GMEM_NOT_BANKED | GMEM_NOTIFY, GMEM_DDESHARE | GMEM_DISCARDABLE}, + }; + + unsigned int i; + HGLOBAL gbl; + UINT resultflags; + + UINT (WINAPI *pGlobalFlags)(HGLOBAL); + + pGlobalFlags = (void *) GetProcAddress(GetModuleHandleA("kernel32"), "GlobalFlags"); + + if (!pGlobalFlags) + { + win_skip("GlobalFlags is not available\n"); + return; + } + + for (i = 0; i < sizeof(test_global_flags)/sizeof(test_global_flags[0]); i++) + { + gbl = GlobalAlloc(test_global_flags[i].flags, 4); + ok(gbl != NULL, "GlobalAlloc failed\n"); + + SetLastError(MAGIC_DEAD); + resultflags = pGlobalFlags(gbl); + + ok( resultflags == test_global_flags[i].globalflags || + broken(resultflags == (test_global_flags[i].globalflags & ~GMEM_DDESHARE)), /* win9x */ + "%u: expected 0x%08x, but returned 0x%08x with %d\n", + i, test_global_flags[i].globalflags, resultflags, GetLastError() ); + + GlobalFree(gbl); + } +} + START_TEST(heap) { test_heap(); + test_obsolete_flags(); /* Test both short and very long blocks */ test_sized_HeapAlloc(1); diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c index 73d7946cdd6..374a18eea5a 100644 --- a/dlls/kernel32/tests/module.c +++ b/dlls/kernel32/tests/module.c @@ -249,10 +249,24 @@ static void testLoadLibraryEx(void) SetLastError(0xdeadbeef); hmodule = LoadLibraryExA("testfile.dll", hfile, 0); ok(hmodule == 0, "Expected 0, got %p\n", hmodule); - ok(GetLastError() == ERROR_SHARING_VIOLATION || - GetLastError() == ERROR_INVALID_PARAMETER || /* win2k3 */ - GetLastError() == ERROR_FILE_NOT_FOUND, /* win9x */ - "Unexpected last error, got %d\n", GetLastError()); + todo_wine + { + ok(GetLastError() == ERROR_SHARING_VIOLATION || + GetLastError() == ERROR_INVALID_PARAMETER || /* win2k3 */ + GetLastError() == ERROR_FILE_NOT_FOUND, /* win9x */ + "Unexpected last error, got %d\n", GetLastError()); + } + + SetLastError(0xdeadbeef); + hmodule = LoadLibraryExA("testfile.dll", (HANDLE)0xdeadbeef, 0); + ok(hmodule == 0, "Expected 0, got %p\n", hmodule); + todo_wine + { + ok(GetLastError() == ERROR_SHARING_VIOLATION || + GetLastError() == ERROR_INVALID_PARAMETER || /* win2k3 */ + GetLastError() == ERROR_FILE_NOT_FOUND, /* win9x */ + "Unexpected last error, got %d\n", GetLastError()); + } /* try to open a file that is locked */ SetLastError(0xdeadbeef); @@ -304,6 +318,12 @@ static void testLoadLibraryEx(void) GetLastError() == ERROR_SUCCESS, /* win9x */ "Expected 0xdeadbeef or ERROR_SUCCESS, got %d\n", GetLastError()); + /* try invalid file handle */ + SetLastError(0xdeadbeef); + hmodule = LoadLibraryExA(path, (HANDLE)0xdeadbeef, 0); + if (!hmodule) /* succeeds on xp and older */ + ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError()); + CloseHandle(hmodule); /* load kernel32.dll with no path */ diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c index 645473143ae..2c25465175f 100644 --- a/dlls/kernel32/tests/volume.c +++ b/dlls/kernel32/tests/volume.c @@ -67,7 +67,7 @@ static void test_query_dos_deviceA(void) } for (;drivestr[0] <= 'z'; drivestr[0]++) { - /* Older W2K fails with ERROR_INSUFFICIENT_BUFFER when buflen is > 32767 big */ + /* Older W2K fails with ERROR_INSUFFICIENT_BUFFER when buflen is > 32767 */ ret = QueryDosDeviceA( drivestr, buffer, buflen - 1); if(ret) { for (p = buffer; *p; p++) *p = toupper(*p); @@ -130,6 +130,9 @@ static void test_GetVolumeNameForVolumeMountPointA(void) ret = pGetVolumeNameForVolumeMountPointA(path, volume, 0); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n"); + ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE || + GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */ + "wrong error, last=%d\n", GetLastError()); if (0) { /* these crash on XP */ ret = pGetVolumeNameForVolumeMountPointA(path, NULL, len); @@ -147,14 +150,12 @@ static void test_GetVolumeNameForVolumeMountPointA(void) /* test with too small buffer */ ret = pGetVolumeNameForVolumeMountPointA(path, volume, 10); -todo_wine ok(ret == FALSE && GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %d, should be ERROR_FILENAME_EXCED_RANGE\n", GetLastError()); /* Try on a arbitrary directory */ ret = pGetVolumeNameForVolumeMountPointA(temp_path, volume, len); -todo_wine ok(ret == FALSE && GetLastError() == ERROR_NOT_A_REPARSE_POINT, "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n", temp_path, GetLastError()); @@ -169,7 +170,6 @@ todo_wine { path[2] = '\\'; ret = pGetVolumeNameForVolumeMountPointA(path, volume, len); -todo_wine ok(ret == FALSE && GetLastError() == ERROR_FILE_NOT_FOUND, "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n", path, GetLastError()); @@ -177,7 +177,6 @@ todo_wine /* Try without trailing \ and on a non-existent dos drive */ path[2] = 0; ret = pGetVolumeNameForVolumeMountPointA(path, volume, len); -todo_wine ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME, "GetVolumeNameForVolumeMountPointA failed on %s, last=%d\n", path, GetLastError()); @@ -198,6 +197,9 @@ static void test_GetVolumeNameForVolumeMountPointW(void) ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0); ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n"); + ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE || + GetLastError() == ERROR_INVALID_PARAMETER, /* Vista */ + "wrong error, last=%d\n", GetLastError()); if (0) { /* these crash on XP */ ret = pGetVolumeNameForVolumeMountPointW(path, NULL, len); @@ -387,7 +389,6 @@ static void test_enum_vols(void) /* get the unique volume name for the windows drive */ ret = pGetVolumeNameForVolumeMountPointA( path, Volume_1, MAX_PATH ); ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n"); -todo_wine ok(strlen(Volume_1) == 49, "GetVolumeNameForVolumeMountPointA returned wrong length name %s\n", Volume_1); /* get first unique volume name of list */ @@ -405,7 +406,6 @@ todo_wine break; } } while (pFindNextVolumeA( hFind, Volume_2, MAX_PATH )); -todo_wine ok(found, "volume name %s not found by Find[First/Next]Volume\n", Volume_1); pFindVolumeClose( hFind ); } diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c index 1b44aced0bb..0f4161c6ec3 100644 --- a/dlls/kernel32/volume.c +++ b/dlls/kernel32/volume.c @@ -788,20 +788,132 @@ BOOL WINAPI GetVolumeNameForVolumeMountPointA( LPCSTR path, LPSTR volume, DWORD */ BOOL WINAPI GetVolumeNameForVolumeMountPointW( LPCWSTR path, LPWSTR volume, DWORD size ) { + static const WCHAR prefixW[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0}; + static const WCHAR volumeW[] = {'\\','?','?','\\','V','o','l','u','m','e','{',0}; + static const WCHAR trailingW[] = {'\\',0}; + + MOUNTMGR_MOUNT_POINT *input = NULL, *o1; + MOUNTMGR_MOUNT_POINTS *output = NULL; + WCHAR *p; + char *r; + DWORD i, i_size = 1024, o_size = 1024; + WCHAR nonpersist_name[200]; + WCHAR symlink_name[MAX_PATH]; + NTSTATUS status; + HANDLE mgr = INVALID_HANDLE_VALUE; BOOL ret = FALSE; - static const WCHAR fmt[] = - { '\\','\\','?','\\','V','o','l','u','m','e','{','%','0','2','x','}','\\',0 }; TRACE("(%s, %p, %x)\n", debugstr_w(path), volume, size); + if (path[lstrlenW(path)-1] != '\\') + { + SetLastError( ERROR_INVALID_NAME ); + return FALSE; + } + + if (size < 50) + { + SetLastError( ERROR_FILENAME_EXCED_RANGE ); + return FALSE; + } + /* if length of input is > 3 then it must be a mounted folder */ + if (lstrlenW(path) > 3) + { + FIXME("Mounted Folders are not yet supported\n"); + SetLastError( ERROR_NOT_A_REPARSE_POINT ); + return FALSE; + } + + mgr = CreateFileW( MOUNTMGR_DOS_DEVICE_NAME, 0, FILE_SHARE_READ, + NULL, OPEN_EXISTING, 0, 0 ); + if (mgr == INVALID_HANDLE_VALUE) return FALSE; + + if (!(input = HeapAlloc( GetProcessHeap(), 0, i_size ))) + { + SetLastError( ERROR_NOT_ENOUGH_MEMORY ); + goto err_ret; + } + + if (!(output = HeapAlloc( GetProcessHeap(), 0, o_size ))) + { + SetLastError( ERROR_NOT_ENOUGH_MEMORY ); + goto err_ret; + } + + /* construct the symlink name as "\DosDevices\C:" */ + lstrcpyW( symlink_name, prefixW ); + lstrcatW( symlink_name, path ); + symlink_name[lstrlenW(symlink_name)-1] = 0; + + /* Take the mount point and get the "nonpersistent name" */ + /* We will then take that and get the volume name */ + status = read_nt_symlink( symlink_name, nonpersist_name, + sizeof(nonpersist_name)/sizeof(WCHAR) ); + TRACE("read_nt_symlink got stat=%x, for %s, got <%s>\n", status, + debugstr_w(symlink_name), debugstr_w(nonpersist_name)); + if (status != STATUS_SUCCESS) + { + SetLastError( ERROR_FILE_NOT_FOUND ); + goto err_ret; + } + + /* Now take the "nonpersistent name" and ask the mountmgr */ + /* to give us all the mount points. One of them will be */ + /* the volume name (format of \??\Volume{). */ + memset( input, 0, sizeof(*input) ); /* clear all input parameters */ + input->DeviceNameOffset = sizeof(*input); + input->DeviceNameLength = lstrlenW( nonpersist_name) * sizeof(WCHAR); + memcpy( input + 1, nonpersist_name, input->DeviceNameLength ); + + output->Size = o_size; + + /* now get the true volume name from the mountmgr */ + if (!DeviceIoControl( mgr, IOCTL_MOUNTMGR_QUERY_POINTS, input, i_size, + output, o_size, NULL, NULL )) + goto err_ret; - if (!path || !path[0]) return FALSE; + /* Verify and return the data, note string is not null terminated */ + TRACE("found %d matching mount points\n", output->NumberOfMountPoints); + if (output->NumberOfMountPoints < 1) + { + SetLastError( ERROR_NO_VOLUME_ID ); + goto err_ret; + } + o1 = &output->MountPoints[0]; - if (size >= sizeof(fmt) / sizeof(WCHAR)) + /* look for the volume name in returned values */ + for(i=0;iNumberOfMountPoints;i++) { - /* FIXME: will break when we support volume mounts */ - sprintfW( volume, fmt, tolowerW( path[0] ) - 'a' ); - ret = TRUE; + p = (WCHAR*)((char *)output + o1->SymbolicLinkNameOffset); + r = (char *)output + o1->UniqueIdOffset; + TRACE("found symlink=%s, unique=%s, devname=%s\n", + debugstr_wn(p, o1->SymbolicLinkNameLength/sizeof(WCHAR)), + debugstr_an(r, o1->UniqueIdLength), + debugstr_wn((WCHAR*)((char *)output + o1->DeviceNameOffset), + o1->DeviceNameLength/sizeof(WCHAR))); + + if (!strncmpW( p, volumeW, (sizeof(volumeW)-1)/sizeof(WCHAR) )) + { + /* is there space in the return variable ?? */ + if ((o1->SymbolicLinkNameLength/sizeof(WCHAR))+2 > size) + { + SetLastError( ERROR_FILENAME_EXCED_RANGE ); + goto err_ret; + } + memcpy( volume, p, o1->SymbolicLinkNameLength ); + volume[o1->SymbolicLinkNameLength / sizeof(WCHAR)] = 0; + lstrcatW( volume, trailingW ); + /* change second char from '?' to '\' */ + volume[1] = '\\'; + ret = TRUE; + break; + } + o1++; } + +err_ret: + HeapFree( GetProcessHeap(), 0, input ); + HeapFree( GetProcessHeap(), 0, output ); + CloseHandle( mgr ); return ret; } diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c index 5deb87b3881..9cd9a8726f7 100644 --- a/dlls/mlang/mlang.c +++ b/dlls/mlang/mlang.c @@ -1197,7 +1197,7 @@ static HRESULT lcid_from_rfc1766(IEnumRfc1766 *iface, LCID *lcid, LPCWSTR rfc176 while (IEnumRfc1766_Next(iface, 1, &info, &num) == S_OK) { - if (!strcmpW(info.wszRfc1766, rfc1766)) + if (!strcmpiW(info.wszRfc1766, rfc1766)) { *lcid = info.lcid; return S_OK; @@ -1222,8 +1222,6 @@ HRESULT WINAPI Rfc1766ToLcidW(LCID *pLocale, LPCWSTR pszRfc1766) if (!pLocale || !pszRfc1766) return E_INVALIDARG; - *pLocale = 0; - hr = EnumRfc1766_create(0, &enumrfc1766); if (FAILED(hr)) return hr; @@ -1238,6 +1236,9 @@ HRESULT WINAPI Rfc1766ToLcidA(LCID *lcid, LPCSTR rfc1766A) { WCHAR rfc1766W[MAX_RFC1766_NAME + 1]; + if (!rfc1766A) + return E_INVALIDARG; + MultiByteToWideChar(CP_ACP, 0, rfc1766A, -1, rfc1766W, MAX_RFC1766_NAME); rfc1766W[MAX_RFC1766_NAME] = 0; diff --git a/dlls/mlang/tests/Makefile.in b/dlls/mlang/tests/Makefile.in index 1a5aceb161c..ed8d9b7a8da 100644 --- a/dlls/mlang/tests/Makefile.in +++ b/dlls/mlang/tests/Makefile.in @@ -3,7 +3,7 @@ TOPOBJDIR = ../../.. SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = mlang.dll -IMPORTS = oleaut32 ole32 gdi32 kernel32 +IMPORTS = mlang oleaut32 ole32 gdi32 kernel32 CTESTS = \ mlang.c diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c index 0f51df0a4d6..2ae7c742abb 100644 --- a/dlls/mlang/tests/mlang.c +++ b/dlls/mlang/tests/mlang.c @@ -48,6 +48,27 @@ static HRESULT (WINAPI *pConvertINetMultiByteToUnicode)(LPDWORD, DWORD, LPCSTR, LPINT, LPWSTR, LPINT); static HRESULT (WINAPI *pConvertINetUnicodeToMultiByte)(LPDWORD, DWORD, LPCWSTR, LPINT, LPSTR, LPINT); +typedef struct lcid_tag_table { + LPCSTR rfc1766; + LCID lcid; + HRESULT hr; +} lcid_table_entry; + +static const lcid_table_entry lcid_table[] = { + {"e", -1, E_FAIL}, + {"", -1, E_FAIL}, + {"-", -1, E_FAIL}, + {"e-", -1, E_FAIL}, + + {"en", 9, S_OK}, /* only en is special (using PRIMARYLANGID) */ + {"en-gb", 0x809, S_OK}, + {"en-GB", 0x809, S_OK}, + {"EN-GB", 0x809, S_OK}, + {"en-US", 0x409, S_OK}, + {"en-us", 0x409, S_OK} + +}; + static BOOL init_function_ptrs(void) { @@ -382,7 +403,8 @@ static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags) if (TranslateCharsetInfo((DWORD *)(INT_PTR)cpinfo[i].uiFamilyCodePage, &csi, TCI_SRCCODEPAGE)) ok(cpinfo[i].bGDICharset == csi.ciCharset, "%d != %d\n", cpinfo[i].bGDICharset, csi.ciCharset); else - trace("TranslateCharsetInfo failed for cp %u\n", cpinfo[i].uiFamilyCodePage); + if (winetest_debug > 1) + trace("TranslateCharsetInfo failed for cp %u\n", cpinfo[i].uiFamilyCodePage); #ifdef DUMP_CP_INFO trace("%u: codepage %u family %u\n", i, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage); @@ -410,7 +432,8 @@ static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags) } } else - trace("IsValidCodePage failed for cp %u\n", cpinfo[i].uiCodePage); + if (winetest_debug > 1) + trace("IsValidCodePage failed for cp %u\n", cpinfo[i].uiCodePage); if (memcmp(cpinfo[i].wszWebCharset,feffW,sizeof(WCHAR)*11)==0) skip("Legacy windows bug returning invalid charset of unicodeFEFF\n"); @@ -832,36 +855,34 @@ static void test_rfc1766(IMultiLanguage2 *iML2) static void test_GetLcidFromRfc1766(IMultiLanguage2 *iML2) { + WCHAR rfc1766W[MAX_RFC1766_NAME + 1]; LCID lcid; HRESULT ret; + DWORD i; - static WCHAR e[] = { 'e',0 }; static WCHAR en[] = { 'e','n',0 }; - static WCHAR empty[] = { 0 }; - static WCHAR dash[] = { '-',0 }; - static WCHAR e_dash[] = { 'e','-',0 }; - static WCHAR en_gb[] = { 'e','n','-','g','b',0 }; - static WCHAR en_us[] = { 'e','n','-','u','s',0 }; static WCHAR en_them[] = { 'e','n','-','t','h','e','m',0 }; static WCHAR english[] = { 'e','n','g','l','i','s','h',0 }; - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, NULL, en); - ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08x\n", ret); - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, NULL); - ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08x\n", ret); + for(i = 0; i < sizeof(lcid_table) / sizeof(lcid_table[0]); i++) { + lcid = -1; + MultiByteToWideChar(CP_ACP, 0, lcid_table[i].rfc1766, -1, rfc1766W, MAX_RFC1766_NAME); + ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, rfc1766W); - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, e); - ok(ret == E_FAIL, "GetLcidFromRfc1766 returned: %08x\n", ret); + ok(ret == lcid_table[i].hr, + "#%02d: HRESULT 0x%x (expected 0x%x)\n", i, ret, lcid_table[i].hr); - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, empty); - ok(ret == E_FAIL, "GetLcidFromRfc1766 returned: %08x\n", ret); + ok(lcid == lcid_table[i].lcid, + "#%02d: got LCID 0x%x (expected 0x%x)\n", i, lcid, lcid_table[i].lcid); + } - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, dash); - ok(ret == E_FAIL, "GetLcidFromRfc1766 returned: %08x\n", ret); - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, e_dash); - ok(ret == E_FAIL, "GetLcidFromRfc1766 returned: %08x\n", ret); + ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, NULL, en); + ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08x\n", ret); + + ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, NULL); + ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08x\n", ret); ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, en_them); ok((ret == E_FAIL || ret == S_FALSE), "GetLcidFromRfc1766 returned: %08x\n", ret); @@ -887,21 +908,36 @@ static void test_GetLcidFromRfc1766(IMultiLanguage2 *iML2) ok_w2("Expected \"%s\", got \"%s\"n", en, rfcstr); } - lcid = 0; +} + +static void test_Rfc1766ToLcid(void) +{ + LCID lcid; + HRESULT ret; + DWORD i; + + for(i = 0; i < sizeof(lcid_table) / sizeof(lcid_table[0]); i++) { + lcid = -1; + ret = Rfc1766ToLcidA(&lcid, lcid_table[i].rfc1766); - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, en); - ok(ret == S_OK, "GetLcidFromRfc1766 returned: %08x\n", ret); - ok(lcid == 9, "got wrong lcid: %04x\n", lcid); + ok(ret == lcid_table[i].hr, + "#%02d: HRESULT 0x%x (expected 0x%x)\n", i, ret, lcid_table[i].hr); - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, en_gb); - ok(ret == S_OK, "GetLcidFromRfc1766 returned: %08x\n", ret); - ok(lcid == 0x809, "got wrong lcid: %04x\n", lcid); - ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, en_us); - ok(ret == S_OK, "GetLcidFromRfc1766 returned: %08x\n", ret); - ok(lcid == 0x409, "got wrong lcid: %04x\n", lcid); + ok(lcid == lcid_table[i].lcid, + "#%02d: got LCID 0x%x (expected 0x%x)\n", i, lcid, lcid_table[i].lcid); + + } + + ret = Rfc1766ToLcidA(&lcid, NULL); + ok(ret == E_INVALIDARG, "got 0x%08x (expected E_INVALIDARG)\n", ret); + + ret = Rfc1766ToLcidA(NULL, "en"); + ok(ret == E_INVALIDARG, "got 0x%08x (expected E_INVALIDARG)\n", ret); + } + static void test_GetRfc1766FromLcid(IMultiLanguage2 *iML2) { HRESULT hr; @@ -1488,6 +1524,8 @@ START_TEST(mlang) return; CoInitialize(NULL); + test_Rfc1766ToLcid(); + ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER, &IID_IMultiLanguage2, (void **)&iML2); if (ret != S_OK || !iML2) return; diff --git a/dlls/msacm32/format.c b/dlls/msacm32/format.c index 1b20ce025ac..a6f7fbdd6a0 100644 --- a/dlls/msacm32/format.c +++ b/dlls/msacm32/format.c @@ -475,7 +475,7 @@ static BOOL MSACM_FormatEnumHelper(PWINE_ACMDRIVERID padid, HACMDRIVER had, continue; hdrvr = OpenDriver(padid->pszFileName,0,0); - SendDriverMessage(hdrvr,ACMDM_FORMAT_SUGGEST,(DWORD)&adfs,(fdwEnum & 0x000000FFL)); + SendDriverMessage(hdrvr,ACMDM_FORMAT_SUGGEST,(LPARAM)&adfs,(fdwEnum & 0x000000FFL)); if (acmFormatDetailsW(had, pafd, ACM_FORMATDETAILSF_FORMAT) != MMSYSERR_NOERROR) continue; diff --git a/dlls/msctf/context.c b/dlls/msctf/context.c index 8e14a722552..9a0c8feeca6 100644 --- a/dlls/msctf/context.c +++ b/dlls/msctf/context.c @@ -61,7 +61,7 @@ typedef struct tagContext { /* const ITfContextCompositionVtbl *ContextCompositionVtbl; */ /* const ITfContextOwnerCompositionServicesVtbl *ContextOwnerCompositionServicesVtbl; */ /* const ITfContextOwnerServicesVtbl *ContextOwnerServicesVtbl; */ - /* const ITfInsertAtSelectionVtbl *InsertAtSelectionVtbl; */ + const ITfInsertAtSelectionVtbl *InsertAtSelectionVtbl; /* const ITfMouseTrackerVtbl *MouseTrackerVtbl; */ /* const ITfQueryEmbeddedVtbl *QueryEmbeddedVtbl; */ /* const ITfSourceSingleVtbl *SourceSingleVtbl; */ @@ -70,6 +70,7 @@ typedef struct tagContext { TfClientId tidOwner; TfEditCookie defaultCookie; + TS_STATUS documentStatus; ITextStoreACP *pITextStoreACP; ITfContextOwnerCompositionSink *pITfContextOwnerCompositionSink; @@ -107,6 +108,11 @@ static inline Context *impl_from_ITfSourceVtbl(ITfSource *iface) return (Context *)((char *)iface - FIELD_OFFSET(Context,SourceVtbl)); } +static inline Context *impl_from_ITfInsertAtSelectionVtbl(ITfInsertAtSelection*iface) +{ + return (Context *)((char *)iface - FIELD_OFFSET(Context,InsertAtSelectionVtbl)); +} + static void free_sink(ContextSink *sink) { IUnknown_Release(sink->interfaces.pIUnknown); @@ -185,6 +191,10 @@ static HRESULT WINAPI Context_QueryInterface(ITfContext *iface, REFIID iid, LPVO { *ppvOut = &This->SourceVtbl; } + else if (IsEqualIID(iid, &IID_ITfInsertAtSelection)) + { + *ppvOut = &This->InsertAtSelectionVtbl; + } if (*ppvOut) { @@ -223,7 +233,6 @@ static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface, HRESULT hr; Context *This = (Context *)iface; DWORD dwLockFlags = 0x0; - TS_STATUS status; TRACE("(%p) %i %p %x %p\n",This, tid, pes, dwFlags, phrSession); @@ -248,10 +257,10 @@ static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface, else if (dwFlags & TF_ES_READ) dwLockFlags |= TS_LF_READ; - /* TODO: cache this */ - ITextStoreACP_GetStatus(This->pITextStoreACP, &status); + if (!This->documentStatus.dwDynamicFlags) + ITextStoreACP_GetStatus(This->pITextStoreACP, &This->documentStatus); - if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (status.dwDynamicFlags & TS_SD_READONLY)) + if (((dwFlags & TF_ES_READWRITE) == TF_ES_READWRITE) && (This->documentStatus.dwDynamicFlags & TS_SD_READONLY)) { *phrSession = TS_E_READONLY; return S_OK; @@ -263,7 +272,6 @@ static HRESULT WINAPI Context_RequestEditSession (ITfContext *iface, return E_INVALIDARG; } - hr = ITextStoreACP_RequestLock(This->pITextStoreACP, dwLockFlags, phrSession); return hr; @@ -579,6 +587,55 @@ static const ITfSourceVtbl Context_SourceVtbl = ContextSource_UnadviseSink, }; +/***************************************************** + * ITfInsertAtSelection functions + *****************************************************/ +static HRESULT WINAPI InsertAtSelection_QueryInterface(ITfInsertAtSelection *iface, REFIID iid, LPVOID *ppvOut) +{ + Context *This = impl_from_ITfInsertAtSelectionVtbl(iface); + return Context_QueryInterface((ITfContext *)This, iid, *ppvOut); +} + +static ULONG WINAPI InsertAtSelection_AddRef(ITfInsertAtSelection *iface) +{ + Context *This = impl_from_ITfInsertAtSelectionVtbl(iface); + return Context_AddRef((ITfContext *)This); +} + +static ULONG WINAPI InsertAtSelection_Release(ITfInsertAtSelection *iface) +{ + Context *This = impl_from_ITfInsertAtSelectionVtbl(iface); + return Context_Release((ITfContext *)This); +} + +static WINAPI HRESULT InsertAtSelection_InsertTextAtSelection( + ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags, + const WCHAR *pchText, LONG cch, ITfRange **ppRange) +{ + Context *This = impl_from_ITfInsertAtSelectionVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static WINAPI HRESULT InsertAtSelection_InsertEmbeddedAtSelection( + ITfInsertAtSelection *iface, TfEditCookie ec, DWORD dwFlags, + IDataObject *pDataObject, ITfRange **ppRange) +{ + Context *This = impl_from_ITfInsertAtSelectionVtbl(iface); + FIXME("STUB:(%p)\n",This); + return E_NOTIMPL; +} + +static const ITfInsertAtSelectionVtbl Context_InsertAtSelectionVtbl = +{ + InsertAtSelection_QueryInterface, + InsertAtSelection_AddRef, + InsertAtSelection_Release, + + InsertAtSelection_InsertTextAtSelection, + InsertAtSelection_InsertEmbeddedAtSelection, +}; + HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **ppOut, TfEditCookie *pecTextStore) { Context *This; @@ -599,6 +656,7 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp This->ContextVtbl= &Context_ContextVtbl; This->SourceVtbl = &Context_SourceVtbl; + This->InsertAtSelectionVtbl = &Context_InsertAtSelectionVtbl; This->refCount = 1; This->tidOwner = tidOwner; This->connected = FALSE; @@ -739,8 +797,28 @@ static HRESULT WINAPI TextStoreACPSink_OnStatusChange(ITextStoreACPSink *iface, DWORD dwFlags) { TextStoreACPSink *This = (TextStoreACPSink *)iface; - FIXME("STUB:(%p)\n",This); - return E_NOTIMPL; + HRESULT hr, hrSession; + + TRACE("(%p) %x\n",This, dwFlags); + + if (!This->pContext) + { + ERR("No context?\n"); + return E_FAIL; + } + + if (!This->pContext->pITextStoreACP) + { + FIXME("Context does not have a ITextStoreACP\n"); + return E_NOTIMPL; + } + + hr = ITextStoreACP_RequestLock(This->pContext->pITextStoreACP, TS_LF_READ, &hrSession); + + if(SUCCEEDED(hr) && SUCCEEDED(hrSession)) + This->pContext->documentStatus.dwDynamicFlags = dwFlags; + + return S_OK; } static HRESULT WINAPI TextStoreACPSink_OnAttrsChange(ITextStoreACPSink *iface, @@ -761,12 +839,18 @@ static HRESULT WINAPI TextStoreACPSink_OnLockGranted(ITextStoreACPSink *iface, TRACE("(%p) %x\n",This, dwLockFlags); - if (!This->pContext || !This->pContext->currentEditSession) + if (!This->pContext) { - ERR("OnLockGranted called on a context without a current edit session\n"); + ERR("OnLockGranted called without a context\n"); return E_FAIL; } + if (!This->pContext->currentEditSession) + { + FIXME("OnLockGranted called for something other than an EditSession\n"); + return S_OK; + } + cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie)); if (!cookie) return E_OUTOFMEMORY; diff --git a/dlls/msctf/range.c b/dlls/msctf/range.c index 63181afdff2..dd92551181d 100644 --- a/dlls/msctf/range.c +++ b/dlls/msctf/range.c @@ -201,8 +201,21 @@ static HRESULT WINAPI Range_Collapse(ITfRange *iface, TfEditCookie ec, TfAnchor aPos) { Range *This = (Range *)iface; - FIXME("STUB:(%p)\n",This); - return E_NOTIMPL; + TRACE("(%p) %i %i\n",This,ec,aPos); + + switch (aPos) + { + case TF_ANCHOR_START: + This->anchorEnd = This->anchorStart; + break; + case TF_ANCHOR_END: + This->anchorStart = This->anchorEnd; + break; + default: + return E_INVALIDARG; + } + + return S_OK; } static HRESULT WINAPI Range_IsEqualStart(ITfRange *iface, TfEditCookie ec, diff --git a/dlls/msctf/tests/inputprocessor.c b/dlls/msctf/tests/inputprocessor.c index 5884a30b728..bdb9a623e0e 100644 --- a/dlls/msctf/tests/inputprocessor.c +++ b/dlls/msctf/tests/inputprocessor.c @@ -38,6 +38,8 @@ static ITfDocumentMgr *g_dm = NULL; static TfClientId cid = 0; static TfClientId tid = 0; +static ITextStoreACPSink *ACPSink; + #define SINK_UNEXPECTED 0 #define SINK_EXPECTED 1 #define SINK_FIRED 2 @@ -47,6 +49,7 @@ static BOOL test_ShouldDeactivate = FALSE; static DWORD tmSinkCookie; static DWORD tmSinkRefCount; +static DWORD documentStatus; static ITfDocumentMgr *test_CurrentFocus = NULL; static ITfDocumentMgr *test_PrevFocus = NULL; static INT test_OnSetFocus = SINK_UNEXPECTED; @@ -70,7 +73,6 @@ typedef struct tagTextStoreACP const ITextStoreACPVtbl *TextStoreACPVtbl; LONG refCount; - ITextStoreACPSink *sink; } TextStoreACP; static void TextStoreACP_Destructor(TextStoreACP *This) @@ -117,13 +119,12 @@ static ULONG WINAPI TextStoreACP_Release(ITextStoreACP *iface) static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface, REFIID riid, IUnknown *punk, DWORD dwMask) { - TextStoreACP *This = (TextStoreACP *)iface; HRESULT hr; ok(test_ACP_AdviseSink == SINK_EXPECTED, "Unexpected TextStoreACP_AdviseSink sink\n"); test_ACP_AdviseSink = SINK_FIRED; - hr = IUnknown_QueryInterface(punk, &IID_ITextStoreACPSink,(LPVOID*)(&This->sink)); + hr = IUnknown_QueryInterface(punk, &IID_ITextStoreACPSink,(LPVOID*)(&ACPSink)); ok(SUCCEEDED(hr),"Unable to QueryInterface on sink\n"); return S_OK; } @@ -138,28 +139,17 @@ static HRESULT WINAPI TextStoreACP_UnadviseSink(ITextStoreACP *iface, static HRESULT WINAPI TextStoreACP_RequestLock(ITextStoreACP *iface, DWORD dwLockFlags, HRESULT *phrSession) { - TextStoreACP *This = (TextStoreACP *)iface; - ok(test_ACP_RequestLock == SINK_EXPECTED,"Unexpected TextStoreACP_RequestLock\n"); test_ACP_RequestLock = SINK_FIRED; - test_DoEditSession = SINK_EXPECTED; - *phrSession = ITextStoreACPSink_OnLockGranted(This->sink, TS_LF_READWRITE); - ok(test_DoEditSession = SINK_FIRED,"expected DoEditSession not fired\n"); - ok(*phrSession == 0xdeadcafe,"Unexpected return from ITextStoreACPSink_OnLockGranted\n"); + *phrSession = ITextStoreACPSink_OnLockGranted(ACPSink, dwLockFlags); return S_OK; } static HRESULT WINAPI TextStoreACP_GetStatus(ITextStoreACP *iface, TS_STATUS *pdcs) { - static UINT count = 0; - count ++; - - if (count == 1) - ok(test_ACP_GetStatus == SINK_EXPECTED, "Unexpected TextStoreACP_GetStatus\n"); - else - todo_wine ok(count == 1,"GetStatus called too many times\n"); + ok(test_ACP_GetStatus == SINK_EXPECTED, "Unexpected TextStoreACP_GetStatus\n"); test_ACP_GetStatus = SINK_FIRED; - pdcs->dwDynamicFlags = TS_SD_READONLY; + pdcs->dwDynamicFlags = documentStatus; return S_OK; } static HRESULT WINAPI TextStoreACP_QueryInsert(ITextStoreACP *iface, @@ -1483,6 +1473,7 @@ static void test_TStoApplicationText(void) ok(hr == E_INVALIDARG,"RequestEditSession should have failed with %x not %x\n",E_INVALIDARG,hr); ok(hrSession == E_FAIL,"hrSession should be %x not %x\n",E_FAIL,hrSession); + documentStatus = TS_SD_READONLY; hrSession = 0xfeedface; test_ACP_GetStatus = SINK_EXPECTED; hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &hrSession); @@ -1490,13 +1481,21 @@ static void test_TStoApplicationText(void) ok(hrSession == TS_E_READONLY,"Unexpected hrSession (%x)\n",hrSession); ok(test_ACP_GetStatus == SINK_FIRED," expected GetStatus not fired\n"); - test_ACP_GetStatus = SINK_UNEXPECTED; + /* signal a change to allow readwrite sessions */ + documentStatus = 0; test_ACP_RequestLock = SINK_EXPECTED; + ITextStoreACPSink_OnStatusChange(ACPSink,documentStatus); + ok(test_ACP_RequestLock == SINK_FIRED," expected RequestLock not fired\n"); + + test_ACP_GetStatus = SINK_EXPECTED; + test_ACP_RequestLock = SINK_EXPECTED; + test_DoEditSession = SINK_EXPECTED; hrSession = 0xfeedface; - hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READ, &hrSession); + hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &hrSession); ok(SUCCEEDED(hr),"ITfContext_RequestEditSession failed\n"); ok(test_ACP_RequestLock == SINK_FIRED," expected RequestLock not fired\n"); ok(test_DoEditSession == SINK_FIRED," expected DoEditSession not fired\n"); + ok(test_ACP_GetStatus == SINK_FIRED," expected GetStatus not fired\n"); ok(hrSession == 0xdeadcafe,"Unexpected hrSession (%x)\n",hrSession); ITfContext_Release(cxt); diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index 32b08019ec1..720bbfef4be 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -157,6 +157,11 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection TRACE("(%p)->(%d %p)\n", This, index, ppItem); + if (ppItem) + *ppItem = NULL; + else + return E_POINTER; + nsIDOMNodeList_GetLength(This->nslist, &length); if(index < 0 || index >= length) return E_INVALIDARG; diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c index aed4d76b34d..305727629b3 100644 --- a/dlls/mshtml/main.c +++ b/dlls/mshtml/main.c @@ -44,7 +44,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); HINSTANCE hInst; -DWORD mshtml_tls = 0; +DWORD mshtml_tls = TLS_OUT_OF_INDEXES; static HINSTANCE shdoclc = NULL; @@ -69,7 +69,7 @@ static void process_detach(void) if(shdoclc) FreeLibrary(shdoclc); - if(mshtml_tls) + if(mshtml_tls != TLS_OUT_OF_INDEXES) TlsFree(mshtml_tls); } diff --git a/dlls/mshtml/task.c b/dlls/mshtml/task.c index ffef5434ab0..496b96f6bd4 100644 --- a/dlls/mshtml/task.c +++ b/dlls/mshtml/task.c @@ -478,11 +478,19 @@ thread_data_t *get_thread_data(BOOL create) { thread_data_t *thread_data; - if(!mshtml_tls) { - if(create) - mshtml_tls = TlsAlloc(); - else + if(mshtml_tls == TLS_OUT_OF_INDEXES) { + DWORD tls; + + if(!create) + return NULL; + + tls = TlsAlloc(); + if(tls == TLS_OUT_OF_INDEXES) return NULL; + + tls = InterlockedCompareExchange((LONG*)&mshtml_tls, tls, TLS_OUT_OF_INDEXES); + if(tls != mshtml_tls) + TlsFree(tls); } thread_data = TlsGetValue(mshtml_tls); diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 249968d4250..497fc0ac668 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -2927,7 +2927,9 @@ static void test_default_style(IHTMLStyle *style) hres = IHTMLStyle_get_posWidth(style, &f); ok(hres == S_OK, "get_posWidth failed: %08x\n", hres); - ok(f == 2.0f, "f = %f\n", f); + ok(f == 2.0f || + f == 2.2f, /* IE8 */ + "f = %f\n", f); V_VT(&v) = VT_BSTR; V_BSTR(&v) = a2bstr("auto"); @@ -2992,14 +2994,18 @@ static void test_default_style(IHTMLStyle *style) hres = IHTMLStyle_get_posLeft(style, &f); ok(hres == S_OK, "get_posLeft failed: %08x\n", hres); - ok(f == 4.0, "expected 4.0 got %f\n", f); + ok(f == 4.0 || + f == 4.9f, /* IE8 */ + "expected 4.0 or 4.9 (IE8) got %f\n", f); /* Ensure left is updated correctly. */ V_VT(&v) = VT_EMPTY; hres = IHTMLStyle_get_left(style, &v); ok(hres == S_OK, "get_left failed: %08x\n", hres); ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v)); - ok(!strcmp_wa(V_BSTR(&v), "4px"), "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v))); + ok(!strcmp_wa(V_BSTR(&v), "4px") || + !strcmp_wa(V_BSTR(&v), "4.9px"), /* IE8 */ + "V_BSTR(v) = %s\n", dbgstr_w(V_BSTR(&v))); VariantClear(&v); /* Test left */ @@ -3052,7 +3058,9 @@ static void test_default_style(IHTMLStyle *style) hres = IHTMLStyle_get_posTop(style, &f); ok(hres == S_OK, "get_posTop failed: %08x\n", hres); - ok(f == 4.0, "expected 4.0 got %f\n", f); + ok(f == 4.0 || + f == 4.9f, /* IE8 */ + "expected 4.0 or 4.9 (IE8) got %f\n", f); V_VT(&v) = VT_BSTR; V_BSTR(&v) = a2bstr("3px"); @@ -3103,7 +3111,9 @@ static void test_default_style(IHTMLStyle *style) hres = IHTMLStyle_get_posHeight(style, &f); ok(hres == S_OK, "get_posHeight failed: %08x\n", hres); - ok(f == 4.0, "expected 4.0 got %f\n", f); + ok(f == 4.0 || + f == 4.9f, /* IE8 */ + "expected 4.0 or 4.9 (IE8) got %f\n", f); V_VT(&v) = VT_BSTR; V_BSTR(&v) = a2bstr("64px"); @@ -4446,15 +4456,17 @@ static void test_elems(IHTMLDocument2 *doc) IHTMLDOMNode_Release(node); } - disp = (void*)0xdeadbeef; + hres = IHTMLDOMChildrenCollection_item(child_col, length - 1, NULL); + ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres); + + hres = IHTMLDOMChildrenCollection_item(child_col, length, NULL); + ok(hres == E_POINTER, "item failed: %08x, expected E_POINTER\n", hres); + hres = IHTMLDOMChildrenCollection_item(child_col, 6000, &disp); ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres); - ok(disp == (void*)0xdeadbeef, "disp=%p\n", disp); - disp = (void*)0xdeadbeef; hres = IHTMLDOMChildrenCollection_item(child_col, length, &disp); ok(hres == E_INVALIDARG, "item failed: %08x, expected E_INVALIDARG\n", hres); - ok(disp == (void*)0xdeadbeef, "disp=%p\n", disp); test_child_col_disp(child_col); diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 948cf4a6ba9..c8249045943 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -6076,7 +6076,7 @@ static UINT load_assembly(MSIRECORD *rec, LPVOID param) /* FIXME: we should probably check the manifest file here */ if (!MsiGetFileVersionW(assembly->file->TargetPath, version, &size, NULL, NULL) && - strcmpW(version, assembly->file->Version) >= 0) + (!assembly->file->Version || strcmpW(version, assembly->file->Version) >= 0)) { assembly->installed = TRUE; } diff --git a/dlls/msi/alter.c b/dlls/msi/alter.c index c31aae1fdcf..0f750d0166e 100644 --- a/dlls/msi/alter.c +++ b/dlls/msi/alter.c @@ -257,8 +257,11 @@ UINT ALTER_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR name, column_inf return ERROR_FUNCTION_FAILED; r = TABLE_CreateView( db, name, &av->table ); - if (r != ERROR_SUCCESS || !av->table) + if (r != ERROR_SUCCESS) + { + msi_free( av ); return r; + } if (colinfo) colinfo->table = name; diff --git a/dlls/msi/create.c b/dlls/msi/create.c index 05c40cf2318..63cd373dbdc 100644 --- a/dlls/msi/create.c +++ b/dlls/msi/create.c @@ -42,7 +42,7 @@ typedef struct tagMSICREATEVIEW { MSIVIEW view; MSIDATABASE *db; - LPWSTR name; + LPCWSTR name; BOOL bIsTemp; BOOL hold; column_info *col_info; @@ -145,9 +145,9 @@ static const MSIVIEWOPS create_ops = NULL, }; -static UINT check_columns( column_info *col_info ) +static UINT check_columns( const column_info *col_info ) { - column_info *c1, *c2; + const column_info *c1, *c2; /* check for two columns with the same name */ for( c1 = col_info; c1; c1 = c1->next ) @@ -158,7 +158,7 @@ static UINT check_columns( column_info *col_info ) return ERROR_SUCCESS; } -UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, +UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, column_info *col_info, BOOL hold ) { MSICREATEVIEW *cv = NULL; @@ -180,7 +180,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, for( col = col_info; col; col = col->next ) { if (!col->table) - col->table = strdupW(table); + col->table = table; if( !col->temporary ) temp = FALSE; diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 70bcd90b49e..80a2c5d05be 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -377,6 +377,7 @@ static LPWSTR msi_build_createsql_columns(LPWSTR *columns_data, LPWSTR *types, D static const WCHAR type_char[] = {'C','H','A','R',0}; static const WCHAR type_int[] = {'I','N','T',0}; static const WCHAR type_long[] = {'L','O','N','G',0}; + static const WCHAR type_object[] = {'O','B','J','E','C','T',0}; static const WCHAR type_notnull[] = {' ','N','O','T',' ','N','U','L','L',0}; static const WCHAR localizable[] = {' ','L','O','C','A','L','I','Z','A','B','L','E',0}; @@ -421,6 +422,11 @@ static LPWSTR msi_build_createsql_columns(LPWSTR *columns_data, LPWSTR *types, D else type = type_long; break; + case 'v': + lstrcpyW(extra, type_notnull); + case 'V': + type = type_object; + break; default: ERR("Unknown type: %c\n", types[i][0]); msi_free(columns); @@ -522,8 +528,32 @@ static UINT msi_add_table_to_db(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types, return r; } +static LPWSTR msi_import_stream_filename(LPCWSTR path, LPCWSTR name) +{ + DWORD len; + LPWSTR fullname, ptr; + + len = lstrlenW(path) + lstrlenW(name) + 1; + fullname = msi_alloc(len*sizeof(WCHAR)); + if (!fullname) + return NULL; + + lstrcpyW( fullname, path ); + + /* chop off extension from path */ + ptr = strrchrW(fullname, '.'); + if (!ptr) + { + msi_free (fullname); + return NULL; + } + *ptr++ = '\\'; + lstrcpyW( ptr, name ); + return fullname; +} + static UINT construct_record(DWORD num_columns, LPWSTR *types, - LPWSTR *data, MSIRECORD **rec) + LPWSTR *data, LPWSTR path, MSIRECORD **rec) { UINT i; @@ -542,6 +572,20 @@ static UINT construct_record(DWORD num_columns, LPWSTR *types, if (*data[i]) MSI_RecordSetInteger(*rec, i + 1, atoiW(data[i])); break; + case 'V': case 'v': + if (*data[i]) + { + UINT r; + LPWSTR file = msi_import_stream_filename(path, data[i]); + if (!file) + return ERROR_FUNCTION_FAILED; + + r = MSI_RecordSetStreamFromFileW(*rec, i + 1, file); + msi_free (file); + if (r != ERROR_SUCCESS) + return ERROR_FUNCTION_FAILED; + } + break; default: ERR("Unhandled column type: %c\n", types[i][0]); msiobj_release(&(*rec)->hdr); @@ -554,7 +598,8 @@ static UINT construct_record(DWORD num_columns, LPWSTR *types, static UINT msi_add_records_to_table(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types, LPWSTR *labels, LPWSTR **records, - int num_columns, int num_records) + int num_columns, int num_records, + LPWSTR path) { UINT r; int i; @@ -579,7 +624,7 @@ static UINT msi_add_records_to_table(MSIDATABASE *db, LPWSTR *columns, LPWSTR *t for (i = 0; i < num_records; i++) { - r = construct_record(num_columns, types, records[i], &rec); + r = construct_record(num_columns, types, records[i], path, &rec); if (r != ERROR_SUCCESS) goto done; @@ -683,7 +728,7 @@ static UINT MSI_DatabaseImport(MSIDATABASE *db, LPCWSTR folder, LPCWSTR file) } } - r = msi_add_records_to_table( db, columns, types, labels, records, num_columns, num_records ); + r = msi_add_records_to_table( db, columns, types, labels, records, num_columns, num_records, path ); } done: @@ -1011,6 +1056,12 @@ typedef struct _tagMERGETABLE struct list rows; LPWSTR name; DWORD numconflicts; + LPWSTR *columns; + DWORD numcolumns; + LPWSTR *types; + DWORD numtypes; + LPWSTR *labels; + DWORD numlabels; } MERGETABLE; typedef struct _tagMERGEROW @@ -1129,8 +1180,8 @@ done: static LPWSTR get_key_value(MSIQUERY *view, LPCWSTR key, MSIRECORD *rec) { MSIRECORD *colnames; - LPWSTR str; - UINT r, i = 0; + LPWSTR str, val; + UINT r, i = 0, sz = 0; int cmp; r = MSI_ViewGetColumnInfo(view, MSICOLINFO_NAMES, &colnames); @@ -1145,7 +1196,43 @@ static LPWSTR get_key_value(MSIQUERY *view, LPCWSTR key, MSIRECORD *rec) } while (cmp); msiobj_release(&colnames->hdr); - return msi_dup_record_field(rec, i); + + r = MSI_RecordGetStringW(rec, i, NULL, &sz); + if (r != ERROR_SUCCESS) + return NULL; + sz++; + + if (MSI_RecordGetString(rec, i)) /* check record field is a string */ + { + /* quote string record fields */ + const WCHAR szQuote[] = {'\'', 0}; + sz += 2; + val = msi_alloc(sz*sizeof(WCHAR)); + if (!val) + return NULL; + + lstrcpyW(val, szQuote); + r = MSI_RecordGetStringW(rec, i, val+1, &sz); + lstrcpyW(val+1+sz, szQuote); + } + else + { + /* do not quote integer record fields */ + val = msi_alloc(sz*sizeof(WCHAR)); + if (!val) + return NULL; + + r = MSI_RecordGetStringW(rec, i, val, &sz); + } + + if (r != ERROR_SUCCESS) + { + ERR("failed to get string!\n"); + msi_free(val); + return NULL; + } + + return val; } static LPWSTR create_diff_row_query(MSIDATABASE *merge, MSIQUERY *view, @@ -1219,31 +1306,34 @@ static UINT merge_diff_row(MSIRECORD *rec, LPVOID param) MERGEDATA *data = param; MERGETABLE *table = data->curtable; MERGEROW *mergerow; - MSIQUERY *dbview; + MSIQUERY *dbview = NULL; MSIRECORD *row = NULL; - LPWSTR query; - UINT r; + LPWSTR query = NULL; + UINT r = ERROR_SUCCESS; - query = create_diff_row_query(data->merge, data->curview, table->name, rec); - if (!query) - return ERROR_OUTOFMEMORY; + if (TABLE_Exists(data->db, table->name)) + { + query = create_diff_row_query(data->merge, data->curview, table->name, rec); + if (!query) + return ERROR_OUTOFMEMORY; - r = MSI_DatabaseOpenViewW(data->db, query, &dbview); - if (r != ERROR_SUCCESS) - goto done; + r = MSI_DatabaseOpenViewW(data->db, query, &dbview); + if (r != ERROR_SUCCESS) + goto done; - r = MSI_ViewExecute(dbview, NULL); - if (r != ERROR_SUCCESS) - goto done; + r = MSI_ViewExecute(dbview, NULL); + if (r != ERROR_SUCCESS) + goto done; - r = MSI_ViewFetch(dbview, &row); - if (r == ERROR_SUCCESS && !MSI_RecordsAreEqual(rec, row)) - { - table->numconflicts++; - goto done; + r = MSI_ViewFetch(dbview, &row); + if (r == ERROR_SUCCESS && !MSI_RecordsAreEqual(rec, row)) + { + table->numconflicts++; + goto done; + } + else if (r != ERROR_NO_MORE_ITEMS) + goto done; } - else if (r != ERROR_NO_MORE_ITEMS) - goto done; mergerow = msi_alloc(sizeof(MERGEROW)); if (!mergerow) @@ -1269,11 +1359,188 @@ done: return r; } +static UINT msi_get_table_labels(MSIDATABASE *db, LPCWSTR table, LPWSTR **labels, DWORD *numlabels) +{ + UINT r, i, count; + MSIRECORD *prec = NULL; + + r = MSI_DatabaseGetPrimaryKeys(db, table, &prec); + if (r != ERROR_SUCCESS) + return r; + + count = MSI_RecordGetFieldCount(prec); + *numlabels = count + 1; + *labels = msi_alloc((*numlabels)*sizeof(LPWSTR)); + if (!labels) + { + r = ERROR_OUTOFMEMORY; + goto end; + } + + (*labels)[0] = strdupW(table); + for (i=1; i<=count; i++ ) + { + (*labels)[i] = strdupW(MSI_RecordGetString(prec, i)); + } + +end: + msiobj_release( &prec->hdr ); + return r; +} + +static UINT msi_get_query_columns(MSIQUERY *query, LPWSTR **columns, DWORD *numcolumns) +{ + UINT r, i, count; + MSIRECORD *prec = NULL; + + r = MSI_ViewGetColumnInfo(query, MSICOLINFO_NAMES, &prec); + if (r != ERROR_SUCCESS) + return r; + + count = MSI_RecordGetFieldCount(prec); + *columns = msi_alloc(count*sizeof(LPWSTR)); + if (!columns) + { + r = ERROR_OUTOFMEMORY; + goto end; + } + + for (i=1; i<=count; i++ ) + { + (*columns)[i-1] = strdupW(MSI_RecordGetString(prec, i)); + } + + *numcolumns = count; + +end: + msiobj_release( &prec->hdr ); + return r; +} + +static UINT msi_get_query_types(MSIQUERY *query, LPWSTR **types, DWORD *numtypes) +{ + UINT r, i, count; + MSIRECORD *prec = NULL; + + r = MSI_ViewGetColumnInfo(query, MSICOLINFO_TYPES, &prec); + if (r != ERROR_SUCCESS) + return r; + + count = MSI_RecordGetFieldCount(prec); + *types = msi_alloc(count*sizeof(LPWSTR)); + if (!types) + { + r = ERROR_OUTOFMEMORY; + goto end; + } + + for (i=1; i<=count; i++ ) + { + (*types)[i-1] = strdupW(MSI_RecordGetString(prec, i)); + } + +end: + msiobj_release( &prec->hdr ); + return r; +} + +static void merge_free_rows(MERGETABLE *table) +{ + struct list *item, *cursor; + + LIST_FOR_EACH_SAFE(item, cursor, &table->rows) + { + MERGEROW *row = LIST_ENTRY(item, MERGEROW, entry); + + list_remove(&row->entry); + msiobj_release(&row->data->hdr); + msi_free(row); + } +} + +static void free_merge_table(MERGETABLE *table) +{ + UINT i; + + if (table->labels != NULL) + { + for (i = 0; i < table->numlabels; i++) + msi_free(table->labels[i]); + msi_free(table->labels); + } + + if (table->columns != NULL) + { + for (i = 0; i < table->numcolumns; i++) + msi_free(table->columns[i]); + msi_free(table->columns); + } + + if (table->types != NULL) + { + for (i = 0; i < table->numtypes; i++) + msi_free(table->types[i]); + msi_free(table->types); + } + msi_free(table->name); + merge_free_rows(table); + + msi_free(table); +} + +static UINT msi_get_merge_table (MSIDATABASE *db, LPCWSTR name, MERGETABLE **ptable) +{ + UINT r; + MERGETABLE *table; + MSIQUERY *mergeview = NULL; + + static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ', + 'F','R','O','M',' ','`','%','s','`',0}; + + table = msi_alloc_zero(sizeof(MERGETABLE)); + if (!table) + { + *ptable = NULL; + return ERROR_OUTOFMEMORY; + } + + r = msi_get_table_labels(db, name, &table->labels, &table->numlabels); + if (r != ERROR_SUCCESS) + goto err; + + r = MSI_OpenQuery(db, &mergeview, query, name); + if (r != ERROR_SUCCESS) + goto err; + + r = msi_get_query_columns(mergeview, &table->columns, &table->numcolumns); + if (r != ERROR_SUCCESS) + goto err; + + r = msi_get_query_types(mergeview, &table->types, &table->numtypes); + if (r != ERROR_SUCCESS) + goto err; + + list_init(&table->rows); + + table->name = strdupW(name); + table->numconflicts = 0; + + msiobj_release(&mergeview->hdr); + *ptable = table; + return ERROR_SUCCESS; + +err: + msiobj_release(&mergeview->hdr); + free_merge_table(table); + *ptable = NULL; + return r; +} + static UINT merge_diff_tables(MSIRECORD *rec, LPVOID param) { MERGEDATA *data = param; MERGETABLE *table; - MSIQUERY *dbview; + MSIQUERY *dbview = NULL; MSIQUERY *mergeview = NULL; LPCWSTR name; UINT r; @@ -1283,40 +1550,35 @@ static UINT merge_diff_tables(MSIRECORD *rec, LPVOID param) name = MSI_RecordGetString(rec, 1); - r = MSI_OpenQuery(data->db, &dbview, query, name); - if (r != ERROR_SUCCESS) - return r; - r = MSI_OpenQuery(data->merge, &mergeview, query, name); if (r != ERROR_SUCCESS) goto done; - r = merge_verify_colnames(dbview, mergeview); - if (r != ERROR_SUCCESS) - goto done; + if (TABLE_Exists(data->db, name)) + { + r = MSI_OpenQuery(data->db, &dbview, query, name); + if (r != ERROR_SUCCESS) + goto done; - r = merge_verify_primary_keys(data->db, data->merge, name); - if (r != ERROR_SUCCESS) - goto done; + r = merge_verify_colnames(dbview, mergeview); + if (r != ERROR_SUCCESS) + goto done; - table = msi_alloc(sizeof(MERGETABLE)); - if (!table) - { - r = ERROR_OUTOFMEMORY; - goto done; + r = merge_verify_primary_keys(data->db, data->merge, name); + if (r != ERROR_SUCCESS) + goto done; } - list_init(&table->rows); - table->name = strdupW(name); - table->numconflicts = 0; + r = msi_get_merge_table(data->merge, name, &table); + if (r != ERROR_SUCCESS) + goto done; + data->curtable = table; data->curview = mergeview; - r = MSI_IterateRecords(mergeview, NULL, merge_diff_row, data); if (r != ERROR_SUCCESS) { - msi_free(table->name); - msi_free(table); + free_merge_table(table); goto done; } @@ -1357,6 +1619,14 @@ static UINT merge_table(MSIDATABASE *db, MERGETABLE *table) MERGEROW *row; MSIVIEW *tv; + if (!TABLE_Exists(db, table->name)) + { + r = msi_add_table_to_db(db, table->columns, table->types, + table->labels, table->numlabels, table->numcolumns); + if (r != ERROR_SUCCESS) + return ERROR_FUNCTION_FAILED; + } + LIST_FOR_EACH_ENTRY(row, &table->rows, MERGEROW, entry) { r = TABLE_CreateView(db, table->name, &tv); @@ -1415,21 +1685,6 @@ static UINT update_merge_errors(MSIDATABASE *db, LPCWSTR error, return r; } -static void merge_free_rows(MERGETABLE *table) -{ - struct list *item, *cursor; - - LIST_FOR_EACH_SAFE(item, cursor, &table->rows) - { - MERGEROW *row = LIST_ENTRY(item, MERGEROW, entry); - - list_remove(&row->entry); - merge_free_rows(table); - msiobj_release(&row->data->hdr); - msi_free(row); - } -} - UINT WINAPI MsiDatabaseMergeW(MSIHANDLE hDatabase, MSIHANDLE hDatabaseMerge, LPCWSTR szTableName) { @@ -1483,9 +1738,7 @@ UINT WINAPI MsiDatabaseMergeW(MSIHANDLE hDatabase, MSIHANDLE hDatabaseMerge, MERGETABLE *table = LIST_ENTRY(item, MERGETABLE, entry); list_remove(&table->entry); - merge_free_rows(table); - msi_free(table->name); - msi_free(table); + free_merge_table(table); } if (conflicts) diff --git a/dlls/msi/drop.c b/dlls/msi/drop.c index 20ab4417b52..a385633d442 100644 --- a/dlls/msi/drop.c +++ b/dlls/msi/drop.c @@ -113,8 +113,11 @@ UINT DROP_CreateView(MSIDATABASE *db, MSIVIEW **view, LPCWSTR name) return ERROR_FUNCTION_FAILED; r = TABLE_CreateView(db, name, &dv->table); - if (r != ERROR_SUCCESS || !dv->table) + if (r != ERROR_SUCCESS) + { + msi_free( dv ); return r; + } dv->view.ops = &drop_ops; dv->db = db; diff --git a/dlls/msi/join.c b/dlls/msi/join.c index 572e84bb0f2..35db2fef160 100644 --- a/dlls/msi/join.c +++ b/dlls/msi/join.c @@ -338,7 +338,10 @@ UINT JOIN_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR tables ) table = msi_alloc(sizeof(JOINTABLE)); if (!table) - return ERROR_OUTOFMEMORY; + { + r = ERROR_OUTOFMEMORY; + goto end; + } r = TABLE_CreateView( db, tables, &table->view ); if( r != ERROR_SUCCESS ) diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index ccfd6e3d5a8..8c4bd3a4515 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -701,8 +701,10 @@ extern UINT MSI_RecordGetStringW( MSIRECORD * , UINT, LPWSTR, LPDWORD); extern UINT MSI_RecordGetStringA( MSIRECORD *, UINT, LPSTR, LPDWORD); extern int MSI_RecordGetInteger( MSIRECORD *, UINT ); extern UINT MSI_RecordReadStream( MSIRECORD *, UINT, char *, LPDWORD); +extern UINT MSI_RecordSetStream(MSIRECORD *, UINT, IStream *); extern UINT MSI_RecordGetFieldCount( const MSIRECORD *rec ); extern UINT MSI_RecordStreamToFile( MSIRECORD *, UINT, LPCWSTR ); +extern UINT MSI_RecordSetStreamFromFileW( MSIRECORD *, UINT, LPCWSTR ); extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT ); extern MSIRECORD *MSI_CloneRecord( MSIRECORD * ); extern BOOL MSI_RecordsAreEqual( MSIRECORD *, MSIRECORD * ); diff --git a/dlls/msi/query.h b/dlls/msi/query.h index 93b13fd6a7b..eb11a1c0321 100644 --- a/dlls/msi/query.h +++ b/dlls/msi/query.h @@ -98,7 +98,7 @@ UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, struct expr *cond ); -UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, +UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, column_info *col_info, BOOL hold ); UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, diff --git a/dlls/msi/record.c b/dlls/msi/record.c index db54cdc3e0b..68eab694370 100644 --- a/dlls/msi/record.c +++ b/dlls/msi/record.c @@ -661,7 +661,7 @@ static UINT RECORD_StreamFromFile(LPCWSTR szFile, IStream **pstm) return ERROR_SUCCESS; } -static UINT MSI_RecordSetStream(MSIRECORD *rec, UINT iField, IStream *stream) +UINT MSI_RecordSetStream(MSIRECORD *rec, UINT iField, IStream *stream) { if ( (iField == 0) || (iField > rec->count) ) return ERROR_INVALID_PARAMETER; @@ -673,7 +673,7 @@ static UINT MSI_RecordSetStream(MSIRECORD *rec, UINT iField, IStream *stream) return ERROR_SUCCESS; } -static UINT MSI_RecordSetStreamFromFileW(MSIRECORD *rec, UINT iField, LPCWSTR szFilename) +UINT MSI_RecordSetStreamFromFileW(MSIRECORD *rec, UINT iField, LPCWSTR szFilename) { IStream *stm = NULL; HRESULT r; @@ -930,6 +930,7 @@ MSIRECORD *MSI_CloneRecord(MSIRECORD *rec) msiobj_release(&clone->hdr); return NULL; } + clone->fields[i].type = MSIFIELD_STREAM; } else { diff --git a/dlls/msi/sql.y b/dlls/msi/sql.y index 8f241b155d2..969c92cc817 100644 --- a/dlls/msi/sql.y +++ b/dlls/msi/sql.y @@ -32,6 +32,7 @@ #include "query.h" #include "wine/list.h" #include "wine/debug.h" +#include "wine/unicode.h" #define YYLEX_PARAM info #define YYPARSE_PARAM info @@ -54,7 +55,7 @@ static UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *st static INT SQL_getint( void *info ); static int sql_lex( void *SQL_lval, SQL_input *info ); -static LPWSTR parser_add_table( LPWSTR list, LPWSTR table ); +static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table ); static void *parser_alloc( void *info, unsigned int sz ); static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column ); @@ -492,7 +493,6 @@ fromtable: UINT r; r = JOIN_CreateView( sql->db, &$$, $2 ); - msi_free( $2 ); if( r != ERROR_SUCCESS ) YYABORT; } @@ -501,12 +501,12 @@ fromtable: tablelist: table { - $$ = strdupW($1); + $$ = $1; } | table TK_COMMA tablelist { - $$ = parser_add_table($3, $1); + $$ = parser_add_table( info, $3, $1 ); if (!$$) YYABORT; } @@ -696,17 +696,20 @@ number: %% -static LPWSTR parser_add_table(LPWSTR list, LPWSTR table) +static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table ) { - DWORD size = lstrlenW(list) + lstrlenW(table) + 2; static const WCHAR space[] = {' ',0}; + DWORD len = strlenW( list ) + strlenW( table ) + 2; + LPWSTR ret; - list = msi_realloc(list, size * sizeof(WCHAR)); - if (!list) return NULL; - - lstrcatW(list, space); - lstrcatW(list, table); - return list; + ret = parser_alloc( info, len * sizeof(WCHAR) ); + if( ret ) + { + strcpyW( ret, list ); + strcatW( ret, space ); + strcatW( ret, table ); + } + return ret; } static void *parser_alloc( void *info, unsigned int sz ) diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c index 3a548226040..16b323c872e 100644 --- a/dlls/msi/storages.c +++ b/dlls/msi/storages.c @@ -559,8 +559,10 @@ UINT STORAGES_CreateView(MSIDATABASE *db, MSIVIEW **view) rows = add_storages_to_table(sv); if (rows < 0) + { + msi_free( sv ); return ERROR_FUNCTION_FAILED; - + } sv->num_rows = rows; *view = (MSIVIEW *)sv; diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index 065f8ed1f66..2d869cc0d29 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -523,7 +523,10 @@ UINT STREAMS_CreateView(MSIDATABASE *db, MSIVIEW **view) sv->db = db; rows = add_streams_to_table(sv); if (rows < 0) + { + msi_free( sv ); return ERROR_FUNCTION_FAILED; + } sv->num_rows = rows; *view = (MSIVIEW *)sv; diff --git a/dlls/msi/table.c b/dlls/msi/table.c index e7e2e68c38f..885c0ddf796 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1158,6 +1158,93 @@ static UINT TABLE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT * return ERROR_SUCCESS; } +static UINT msi_stream_name( const MSITABLEVIEW *tv, UINT row, LPWSTR *pstname ) +{ + LPWSTR p, stname = NULL; + UINT i, r, type, ival; + DWORD len; + LPCWSTR sval; + MSIVIEW *view = (MSIVIEW *) tv; + + TRACE("%p %d\n", tv, row); + + len = lstrlenW( tv->name ) + 1; + stname = msi_alloc( len*sizeof(WCHAR) ); + if ( !stname ) + { + r = ERROR_OUTOFMEMORY; + goto err; + } + + lstrcpyW( stname, tv->name ); + + for ( i = 0; i < tv->num_cols; i++ ) + { + type = tv->columns[i].type; + if ( type & MSITYPE_KEY ) + { + static const WCHAR szDot[] = { '.', 0 }; + + r = TABLE_fetch_int( view, row, i+1, &ival ); + if ( r != ERROR_SUCCESS ) + goto err; + + if ( tv->columns[i].type & MSITYPE_STRING ) + { + sval = msi_string_lookup_id( tv->db->strings, ival ); + if ( !sval ) + { + r = ERROR_INVALID_PARAMETER; + goto err; + } + } + else + { + static const WCHAR fmt[] = { '%','d',0 }; + WCHAR number[0x20]; + UINT n = bytes_per_column( tv->db, &tv->columns[i] ); + + switch( n ) + { + case 2: + sprintfW( number, fmt, ival^0x8000 ); + break; + case 4: + sprintfW( number, fmt, ival^0x80000000 ); + break; + default: + ERR( "oops - unknown column width %d\n", n ); + r = ERROR_FUNCTION_FAILED; + goto err; + } + sval = number; + } + + len += lstrlenW( szDot ) + lstrlenW( sval ); + p = msi_realloc ( stname, len*sizeof(WCHAR) ); + if ( !p ) + { + r = ERROR_OUTOFMEMORY; + goto err; + } + stname = p; + + lstrcatW( stname, szDot ); + lstrcatW( stname, sval ); + } + else + continue; + } + + *pstname = stname; + return ERROR_SUCCESS; + +err: + msi_free( stname ); + *pstname = NULL; + return r; +} + /* * We need a special case for streams, as we need to reference column with * the name of the stream in the same table, and the table name @@ -1166,58 +1253,19 @@ static UINT TABLE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT * static UINT TABLE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm ) { MSITABLEVIEW *tv = (MSITABLEVIEW*)view; - UINT ival = 0, refcol = 0, r; - LPCWSTR sval; - LPWSTR full_name; - DWORD len; - static const WCHAR szDot[] = { '.', 0 }; - WCHAR number[0x20]; + UINT r; + LPWSTR full_name = NULL; if( !view->ops->fetch_int ) return ERROR_INVALID_PARAMETER; - /* - * The column marked with the type stream data seems to have a single number - * which references the column containing the name of the stream data - * - * Fetch the column to reference first. - */ - r = view->ops->fetch_int( view, row, col, &ival ); - if( r != ERROR_SUCCESS ) - return r; - - /* check the column value is in range */ - if (ival > tv->num_cols || ival == col) - { - ERR("bad column ref (%u) for stream\n", ival); - return ERROR_FUNCTION_FAILED; - } - - if ( tv->columns[ival - 1].type & MSITYPE_STRING ) - { - /* now get the column with the name of the stream */ - r = view->ops->fetch_int( view, row, ival, &refcol ); - if ( r != ERROR_SUCCESS ) - return r; - - /* lookup the string value from the string table */ - sval = msi_string_lookup_id( tv->db->strings, refcol ); - if ( !sval ) - return ERROR_INVALID_PARAMETER; - } - else + r = msi_stream_name( tv, row, &full_name ); + if ( r != ERROR_SUCCESS ) { - static const WCHAR fmt[] = { '%','d',0 }; - sprintfW( number, fmt, ival ); - sval = number; + ERR("fetching stream, error = %d\n", r); + return r; } - len = lstrlenW( tv->name ) + 2 + lstrlenW( sval ); - full_name = msi_alloc( len*sizeof(WCHAR) ); - lstrcpyW( full_name, tv->name ); - lstrcatW( full_name, szDot ); - lstrcatW( full_name, sval ); - r = db_get_raw_stream( tv->db, full_name, stm ); if( r ) ERR("fetching stream %s, error = %d\n",debugstr_w(full_name), r); @@ -1285,6 +1333,46 @@ static UINT TABLE_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec ) return msi_view_get_row(tv->db, view, row, rec); } +static UINT msi_addstreamW( MSIDATABASE *db, LPCWSTR name, IStream *data ) +{ + UINT r; + MSIQUERY *query = NULL; + MSIRECORD *rec = NULL; + + static const WCHAR insert[] = { + 'I','N','S','E','R','T',' ','I','N','T','O',' ', + '`','_','S','t','r','e','a','m','s','`',' ', + '(','`','N','a','m','e','`',',', + '`','D','a','t','a','`',')',' ', + 'V','A','L','U','E','S',' ','(','?',',','?',')',0}; + + TRACE("%p %s %p\n", db, debugstr_w(name), data); + + rec = MSI_CreateRecord( 2 ); + if ( !rec ) + return ERROR_OUTOFMEMORY; + + r = MSI_RecordSetStringW( rec, 1, name ); + if ( r != ERROR_SUCCESS ) + goto err; + + r = MSI_RecordSetIStream( rec, 2, data ); + if ( r != ERROR_SUCCESS ) + goto err; + + r = MSI_DatabaseOpenViewW( db, insert, &query ); + if ( r != ERROR_SUCCESS ) + goto err; + + r = MSI_ViewExecute( query, rec ); + +err: + msiobj_release( &query->hdr ); + msiobj_release( &rec->hdr ); + + return r; +} + static UINT TABLE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask ) { MSITABLEVIEW *tv = (MSITABLEVIEW*)view; @@ -1315,6 +1403,27 @@ static UINT TABLE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UI { if ( MSITYPE_IS_BINARY(tv->columns[ i ].type) ) { + IStream *stm; + LPWSTR stname; + + r = MSI_RecordGetIStream( rec, i + 1, &stm ); + if ( r != ERROR_SUCCESS ) + return r; + + r = msi_stream_name( tv, row, &stname ); + if ( r != ERROR_SUCCESS ) + { + IStream_Release( stm ); + return r; + } + + r = msi_addstreamW( tv->db, stname, stm ); + IStream_Release( stm ); + msi_free ( stname ); + + if ( r != ERROR_SUCCESS ) + return r; + val = 1; /* refers to the first key column */ } else if ( tv->columns[i].type & MSITYPE_STRING ) @@ -2264,7 +2373,67 @@ static UINT read_raw_int(const BYTE *data, UINT col, UINT bytes) return ret; } +static UINT msi_record_encoded_stream_name( const MSITABLEVIEW *tv, MSIRECORD *rec, LPWSTR *pstname ) +{ + static const WCHAR szDot[] = { '.', 0 }; + LPWSTR stname = NULL, sval, p; + DWORD len; + UINT i, r; + + TRACE("%p %p\n", tv, rec); + + len = lstrlenW( tv->name ) + 1; + stname = msi_alloc( len*sizeof(WCHAR) ); + if ( !stname ) + { + r = ERROR_OUTOFMEMORY; + goto err; + } + + lstrcpyW( stname, tv->name ); + + for ( i = 0; i < tv->num_cols; i++ ) + { + if ( tv->columns[i].type & MSITYPE_KEY ) + { + sval = msi_dup_record_field( rec, i + 1 ); + if ( !sval ) + { + r = ERROR_OUTOFMEMORY; + goto err; + } + + len += lstrlenW( szDot ) + lstrlenW ( sval ); + p = msi_realloc ( stname, len*sizeof(WCHAR) ); + if ( !p ) + { + r = ERROR_OUTOFMEMORY; + goto err; + } + stname = p; + + lstrcatW( stname, szDot ); + lstrcatW( stname, sval ); + + msi_free( sval ); + } + else + continue; + } + + *pstname = encode_streamname( FALSE, stname ); + msi_free( stname ); + + return ERROR_SUCCESS; + +err: + msi_free ( stname ); + *pstname = NULL; + return r; +} + static MSIRECORD *msi_get_transform_record( const MSITABLEVIEW *tv, const string_table *st, + IStorage *stg, const BYTE *rawdata, UINT bytes_per_strref ) { UINT i, val, ofs = 0; @@ -2288,8 +2457,28 @@ static MSIRECORD *msi_get_transform_record( const MSITABLEVIEW *tv, const string if ( (~mask&1) && (~columns[i].type & MSITYPE_KEY) && ((1<columns[i].type) ) + if( MSITYPE_IS_BINARY(tv->columns[i].type) ) + { + LPWSTR encname; + IStream *stm = NULL; + UINT r; + + ofs += bytes_per_column( tv->db, &columns[i] ); + + r = msi_record_encoded_stream_name( tv, rec, &encname ); + if ( r != ERROR_SUCCESS ) + return NULL; + + r = IStorage_OpenStream( stg, encname, NULL, + STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm ); + msi_free( encname ); + if ( r != ERROR_SUCCESS ) + return NULL; + + MSI_RecordSetStream( rec, i+1, stm ); + TRACE(" field %d [%s]\n", i+1, debugstr_w(encname)); + } + else if( columns[i].type & MSITYPE_STRING ) { LPCWSTR sval; @@ -2550,7 +2739,7 @@ static UINT msi_table_load_transform( MSIDATABASE *db, IStorage *stg, break; } - rec = msi_get_transform_record( tv, st, &rawdata[n], bytes_per_strref ); + rec = msi_get_transform_record( tv, st, stg, &rawdata[n], bytes_per_strref ); if (rec) { if ( mask & 1 ) diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 41f65f18498..a48bcabfa85 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -1482,6 +1482,89 @@ static void test_streamtable(void) DeleteFile(msifile); } +static void test_binary(void) +{ + MSIHANDLE hdb = 0, rec; + char file[MAX_PATH]; + char buf[MAX_PATH]; + DWORD size; + LPCSTR query; + UINT r; + + /* insert a file into the Binary table */ + r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb ); + ok( r == ERROR_SUCCESS , "Failed to open database\n" ); + + query = "CREATE TABLE `Binary` ( `Name` CHAR(72) NOT NULL, `ID` INT NOT NULL, `Data` OBJECT PRIMARY KEY `Name`, `ID`)"; + r = run_query( hdb, 0, query ); + ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r ); + + create_file( "test.txt" ); + rec = MsiCreateRecord( 1 ); + r = MsiRecordSetStream( rec, 1, "test.txt" ); + ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r); + DeleteFile( "test.txt" ); + + query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'filename1', 1, ? )"; + r = run_query( hdb, rec, query ); + ok( r == ERROR_SUCCESS, "Insert into Binary table failed: %d\n", r ); + + r = MsiCloseHandle( rec ); + ok( r == ERROR_SUCCESS , "Failed to close record handle\n" ); + + r = MsiDatabaseCommit( hdb ); + ok( r == ERROR_SUCCESS , "Failed to commit database\n" ); + + r = MsiCloseHandle( hdb ); + ok( r == ERROR_SUCCESS , "Failed to close database\n" ); + + /* read file from the Stream table */ + r = MsiOpenDatabase( msifile, MSIDBOPEN_READONLY, &hdb ); + ok( r == ERROR_SUCCESS , "Failed to open database\n" ); + + query = "SELECT * FROM `_Streams`"; + r = do_query( hdb, query, &rec ); + ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r ); + + size = MAX_PATH; + r = MsiRecordGetString( rec, 1, file, &size ); + ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r ); + ok( !lstrcmp(file, "Binary.filename1.1"), "Expected 'Binary.filename1.1', got %s\n", file ); + + size = MAX_PATH; + memset( buf, 0, MAX_PATH ); + r = MsiRecordReadStream( rec, 2, buf, &size ); + ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r ); + ok( !lstrcmp(buf, "test.txt\n"), "Expected 'test.txt\\n', got %s\n", buf ); + + r = MsiCloseHandle( rec ); + ok( r == ERROR_SUCCESS , "Failed to close record handle\n" ); + + /* read file from the Binary table */ + query = "SELECT * FROM `Binary`"; + r = do_query( hdb, query, &rec ); + ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r ); + + size = MAX_PATH; + r = MsiRecordGetString( rec, 1, file, &size ); + ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r ); + ok( !lstrcmp(file, "filename1"), "Expected 'filename1', got %s\n", file ); + + size = MAX_PATH; + memset( buf, 0, MAX_PATH ); + r = MsiRecordReadStream( rec, 3, buf, &size ); + ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r ); + ok( !lstrcmp(buf, "test.txt\n"), "Expected 'test.txt\\n', got %s\n", buf ); + + r = MsiCloseHandle( rec ); + ok( r == ERROR_SUCCESS , "Failed to close record handle\n" ); + + r = MsiCloseHandle( hdb ); + ok( r == ERROR_SUCCESS , "Failed to close database\n" ); + + DeleteFile( msifile ); +} + static void test_where(void) { MSIHANDLE hdb = 0, rec, view; @@ -1856,6 +1939,63 @@ static void test_msiimport(void) DeleteFileA(msifile); } +static const CHAR bin_import_dat[] = "Name\tData\r\n" + "s72\tV0\r\n" + "Binary\tName\r\n" + "filename1\tfilename1.ibd\r\n"; + +static void test_binary_import(void) +{ + MSIHANDLE hdb = 0, rec; + char file[MAX_PATH]; + char buf[MAX_PATH]; + char path[MAX_PATH]; + DWORD size; + LPCSTR query; + UINT r; + + /* create files to import */ + write_file("bin_import.idt", bin_import_dat, + (sizeof(bin_import_dat) - 1) * sizeof(char)); + CreateDirectory("bin_import", NULL); + create_file_data("bin_import/filename1.ibd", "just some words", 15); + + /* import files into database */ + r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb); + ok( r == ERROR_SUCCESS , "Failed to open database\n"); + + GetCurrentDirectory(MAX_PATH, path); + r = MsiDatabaseImport(hdb, path, "bin_import.idt"); + ok(r == ERROR_SUCCESS , "Failed to import Binary table\n"); + + /* read file from the Binary table */ + query = "SELECT * FROM `Binary`"; + r = do_query(hdb, query, &rec); + ok(r == ERROR_SUCCESS, "SELECT query failed: %d\n", r); + + size = MAX_PATH; + r = MsiRecordGetString(rec, 1, file, &size); + ok(r == ERROR_SUCCESS, "Failed to get string: %d\n", r); + ok(!lstrcmp(file, "filename1"), "Expected 'filename1', got %s\n", file); + + size = MAX_PATH; + memset(buf, 0, MAX_PATH); + r = MsiRecordReadStream(rec, 2, buf, &size); + ok(r == ERROR_SUCCESS, "Failed to get stream: %d\n", r); + ok(!lstrcmp(buf, "just some words"), + "Expected 'just some words', got %s\n", buf); + + r = MsiCloseHandle(rec); + ok(r == ERROR_SUCCESS , "Failed to close record handle\n"); + + r = MsiCloseHandle(hdb); + ok(r == ERROR_SUCCESS , "Failed to close database\n"); + + DeleteFile("bin_import/filename1.ibd"); + RemoveDirectory("bin_import"); + DeleteFile("bin_import.idt"); +} + static void test_markers(void) { MSIHANDLE hdb, rec; @@ -6804,6 +6944,92 @@ static void test_dbmerge(void) r = run_query(hdb, 0, query); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + query = "DROP TABLE `One`"; + r = run_query(hdb, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "DROP TABLE `One`"; + r = run_query(href, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "CREATE TABLE `One` ( `A` INT, `B` CHAR(72) PRIMARY KEY `A` )"; + r = run_query(href, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 'hi' )"; + r = run_query(href, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + /* table from merged database is not in target database */ + r = MsiDatabaseMergeA(hdb, href, "MergeErrors"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "SELECT * FROM `One`"; + r = do_query(hdb, query, &hrec); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + r = MsiRecordGetInteger(hrec, 1); + ok(r == 1, "Expected 1, got %d\n", r); + + size = MAX_PATH; + r = MsiRecordGetStringA(hrec, 2, buf, &size); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(!lstrcmpA(buf, "hi"), "Expected \"hi\", got \"%s\"\n", buf); + + MsiCloseHandle(hrec); + + /* nothing in MergeErrors */ + query = "SELECT * FROM `MergeErrors`"; + r = do_query(hdb, query, &hrec); + ok(r == ERROR_BAD_QUERY_SYNTAX, + "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r); + + query = "DROP TABLE `One`"; + r = run_query(hdb, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "DROP TABLE `One`"; + r = run_query(href, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "CREATE TABLE `One` ( " + "`A` CHAR(72), `B` INT PRIMARY KEY `A` )"; + r = run_query(hdb, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "CREATE TABLE `One` ( " + "`A` CHAR(72), `B` INT PRIMARY KEY `A` )"; + r = run_query(href, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 'hi', 1 )"; + r = run_query(href, 0, query); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + /* primary key is string */ + r = MsiDatabaseMergeA(hdb, href, "MergeErrors"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + query = "SELECT * FROM `One`"; + r = do_query(hdb, query, &hrec); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + + size = MAX_PATH; + r = MsiRecordGetStringA(hrec, 1, buf, &size); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(!lstrcmpA(buf, "hi"), "Expected \"hi\", got \"%s\"\n", buf); + + r = MsiRecordGetInteger(hrec, 2); + ok(r == 1, "Expected 1, got %d\n", r); + + MsiCloseHandle(hrec); + + /* nothing in MergeErrors */ + query = "SELECT * FROM `MergeErrors`"; + r = do_query(hdb, query, &hrec); + ok(r == ERROR_BAD_QUERY_SYNTAX, + "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r); + create_file_data("codepage.idt", "\r\n\r\n850\t_ForceCodepage\r\n", 0); GetCurrentDirectoryA(MAX_PATH, buf); @@ -6899,12 +7125,9 @@ static void test_dbmerge(void) size = MAX_PATH; ZeroMemory(buf, MAX_PATH); r = MsiRecordReadStream(hrec, 2, buf, &size); - todo_wine - { - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - ok(!lstrcmpA(buf, "binary.dat\n"), - "Expected \"binary.dat\\n\", got \"%s\"\n", buf); - } + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(!lstrcmpA(buf, "binary.dat\n"), + "Expected \"binary.dat\\n\", got \"%s\"\n", buf); MsiCloseHandle(hrec); @@ -7528,8 +7751,10 @@ START_TEST(db) test_msiexport(); test_longstrings(); test_streamtable(); + test_binary(); test_where(); test_msiimport(); + test_binary_import(); test_markers(); test_handle_limit(); test_try_transform(); diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index 933a145823c..a554e346c7e 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -40,6 +40,8 @@ static UINT (WINAPI *pMsiSourceListEnumSourcesA) static UINT (WINAPI *pMsiSourceListGetInfoA) (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, LPCSTR, LPSTR, LPDWORD); +static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); + static HMODULE hsrclient = 0; static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD); static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*); @@ -1316,6 +1318,7 @@ static int CDECL fci_delete(char *pszFile, int *err, void *pv) static void init_functionpointers(void) { HMODULE hmsi = GetModuleHandleA("msi.dll"); + HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll"); #define GET_PROC(mod, func) \ p ## func = (void*)GetProcAddress(mod, #func); \ @@ -1326,6 +1329,8 @@ static void init_functionpointers(void) GET_PROC(hmsi, MsiSourceListEnumSourcesA); GET_PROC(hmsi, MsiSourceListGetInfoA); + GET_PROC(hadvapi32, ConvertSidToStringSidA); + hsrclient = LoadLibraryA("srclient.dll"); GET_PROC(hsrclient, SRRemoveRestorePoint); GET_PROC(hsrclient, SRSetRestorePointA); @@ -1346,26 +1351,28 @@ static BOOL check_win9x(void) return FALSE; } -static void get_user_sid(LPSTR *usersid) +static LPSTR get_user_sid(LPSTR *usersid) { HANDLE token; BYTE buf[1024]; DWORD size; PTOKEN_USER user; - HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll"); - static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); - *usersid = NULL; - pConvertSidToStringSidA = (void *)GetProcAddress(hadvapi32, "ConvertSidToStringSidA"); if (!pConvertSidToStringSidA) - return; + { + win_skip("ConvertSidToStringSidA is not available\n"); + return NULL; + } + *usersid = NULL; OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token); size = sizeof(buf); GetTokenInformation(token, TokenUser, buf, size, &size); user = (PTOKEN_USER)buf; pConvertSidToStringSidA(user->User.Sid, usersid); + ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError()); CloseHandle(token); + return *usersid; } static BOOL check_record(MSIHANDLE rec, UINT field, LPCSTR val) @@ -2511,12 +2518,8 @@ static void test_publish_registerproduct(void) static const CHAR userugkey[] = "Software\\Microsoft\\Installer\\UpgradeCodes" "\\51AAE0C44620A5E4788506E91F249BD2"; - get_user_sid(&usersid); - if (!usersid) - { - skip("ConvertSidToStringSidA is not available\n"); + if (!get_user_sid(&usersid)) return; - } get_date_str(date); GetTempPath(MAX_PATH, temp); @@ -2756,12 +2759,8 @@ static void test_publish_publishproduct(void) static const CHAR machprod[] = "Installer\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB"; static const CHAR machup[] = "Installer\\UpgradeCodes\\51AAE0C44620A5E4788506E91F249BD2"; - get_user_sid(&usersid); - if (!usersid) - { - skip("ConvertSidToStringSidA is not available\n"); + if (!get_user_sid(&usersid)) return; - } GetTempPath(MAX_PATH, temp); @@ -2952,12 +2951,8 @@ static void test_publish_publishfeatures(void) static const CHAR classfeat[] = "Software\\Classes\\Installer\\Features" "\\84A88FD7F6998CE40A22FB59F6B9C2BB"; - get_user_sid(&usersid); - if (!usersid) - { - skip("ConvertSidToStringSidA is not available\n"); + if (!get_user_sid(&usersid)) return; - } CreateDirectoryA("msitest", NULL); create_file("msitest\\maximus", 500); @@ -3114,12 +3109,8 @@ static void test_publish_registeruser(void) "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\" "UserData\\%s\\Products\\84A88FD7F6998CE40A22FB59F6B9C2BB\\InstallProperties"; - get_user_sid(&usersid); - if (!usersid) - { - skip("ConvertSidToStringSidA is not available\n"); + if (!get_user_sid(&usersid)) return; - } get_owner_company(&owner, &company); @@ -3197,12 +3188,8 @@ static void test_publish_processcomponents(void) static const CHAR compkey[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\Components"; - get_user_sid(&usersid); - if (!usersid) - { - skip("ConvertSidToStringSidA is not available\n"); + if (!get_user_sid(&usersid)) return; - } CreateDirectoryA("msitest", NULL); create_file("msitest\\maximus", 500); diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 308a9ccd142..a9eef76e9c0 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -34,26 +34,46 @@ char CURR_DIR[MAX_PATH]; static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR); -static void get_user_sid(LPSTR *usersid) +static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); + +static void init_functionpointers(void) +{ + HMODULE hmsi = GetModuleHandleA("msi.dll"); + HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll"); + +#define GET_PROC(mod, func) \ + p ## func = (void*)GetProcAddress(mod, #func); + + GET_PROC(hmsi, MsiApplyMultiplePatchesA); + + GET_PROC(hadvapi32, ConvertSidToStringSidA); + +#undef GET_PROC +} + + +static LPSTR get_user_sid(LPSTR *usersid) { HANDLE token; BYTE buf[1024]; DWORD size; PTOKEN_USER user; - HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll"); - static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*); - *usersid = NULL; - pConvertSidToStringSidA = (void *)GetProcAddress(hadvapi32, "ConvertSidToStringSidA"); if (!pConvertSidToStringSidA) - return; + { + win_skip("ConvertSidToStringSidA is not available\n"); + return NULL; + } + *usersid = NULL; OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token); size = sizeof(buf); GetTokenInformation(token, TokenUser, buf, size, &size); user = (PTOKEN_USER)buf; pConvertSidToStringSidA(user->User.Sid, usersid); + ok(*usersid != NULL, "pConvertSidToStringSidA failed lre=%d\n", GetLastError()); CloseHandle(token); + return *usersid; } /* RegDeleteTreeW from dlls/advapi32/registry.c */ @@ -7336,12 +7356,8 @@ static void test_appsearch_complocator(void) DWORD size; UINT r; - get_user_sid(&usersid); - if (!usersid) - { - skip("ConvertSidToStringSidA is not available\n"); + if (!get_user_sid(&usersid)) return; - } create_test_file("FileName1"); create_test_file("FileName4"); @@ -11208,7 +11224,6 @@ static void test_MsiGetProductProperty(void) CHAR prodcode[MAX_PATH]; CHAR prod_squashed[MAX_PATH]; HKEY prodkey, userkey, props; - LPSTR usersid; DWORD size; LONG res; UINT r; @@ -11226,7 +11241,6 @@ static void test_MsiGetProductProperty(void) lstrcatA(path, "\\"); create_test_guid(prodcode, prod_squashed); - get_user_sid(&usersid); r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); @@ -11617,9 +11631,7 @@ static void test_MsiApplyPatch(void) START_TEST(package) { - HMODULE hmsi = GetModuleHandleA("msi.dll"); - - pMsiApplyMultiplePatchesA = (void *)GetProcAddress(hmsi, "MsiApplyMultiplePatchesA"); + init_functionpointers(); GetCurrentDirectoryA(MAX_PATH, CURR_DIR); diff --git a/dlls/msi/update.c b/dlls/msi/update.c index 31e5e252a8a..56d2391a731 100644 --- a/dlls/msi/update.c +++ b/dlls/msi/update.c @@ -261,7 +261,10 @@ UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, uv = msi_alloc_zero( sizeof *uv ); if( !uv ) + { + wv->ops->delete( wv ); return ERROR_FUNCTION_FAILED; + } /* fill the structure */ uv->view.ops = &update_ops; diff --git a/dlls/msvcrt/cpp.c b/dlls/msvcrt/cpp.c index 6bc6d3d4cc9..0ed28dd9910 100644 --- a/dlls/msvcrt/cpp.c +++ b/dlls/msvcrt/cpp.c @@ -136,7 +136,7 @@ static void EXCEPTION_ctor(exception *_this, const char** name) _this->vtable = &MSVCRT_exception_vtable; if (*name) { - size_t name_len = strlen(*name) + 1; + unsigned int name_len = strlen(*name) + 1; _this->name = MSVCRT_malloc(name_len); memcpy(_this->name, *name, name_len); _this->do_free = TRUE; diff --git a/dlls/msvcrt/data.c b/dlls/msvcrt/data.c index a031f16e9bb..1e4eafcc24b 100644 --- a/dlls/msvcrt/data.c +++ b/dlls/msvcrt/data.c @@ -231,7 +231,7 @@ MSVCRT_wchar_t*** CDECL __p___winitenv(void) { return &MSVCRT___winitenv; } /* INTERNAL: Create a wide string from an ascii string */ MSVCRT_wchar_t *msvcrt_wstrdupa(const char *str) { - const size_t len = strlen(str) + 1 ; + const unsigned int len = strlen(str) + 1 ; MSVCRT_wchar_t *wstr = MSVCRT_malloc(len* sizeof (MSVCRT_wchar_t)); if (!wstr) return NULL; diff --git a/dlls/msvcrt/errno.c b/dlls/msvcrt/errno.c index e52c49dc51b..6ed6086877f 100644 --- a/dlls/msvcrt/errno.c +++ b/dlls/msvcrt/errno.c @@ -122,7 +122,7 @@ unsigned int MSVCRT__sys_nerr = sizeof(MSVCRT__sys_errlist)/sizeof(MSVCRT__sys_e void msvcrt_set_errno(int err) { int *errno = MSVCRT__errno(); - unsigned long *doserrno = MSVCRT___doserrno(); + MSVCRT_ulong *doserrno = MSVCRT___doserrno(); *doserrno = err; @@ -189,7 +189,7 @@ int* CDECL MSVCRT__errno(void) /********************************************************************* * __doserrno (MSVCRT.@) */ -unsigned long* CDECL MSVCRT___doserrno(void) +MSVCRT_ulong* CDECL MSVCRT___doserrno(void) { return &msvcrt_get_thread_data()->thread_doserrno; } diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 7e1210c1d5e..6671f2fc0e6 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -141,6 +141,16 @@ static void msvcrt_stat64_to_stati64(const struct MSVCRT__stat64 *buf64, struct buf->st_ctime = buf64->st_ctime; } +static void time_to_filetime( MSVCRT___time64_t time, FILETIME *ft ) +{ + /* 1601 to 1970 is 369 years plus 89 leap days */ + static const __int64 secs_1601_to_1970 = ((369 * 365 + 89) * (__int64)86400); + + __int64 ticks = (time + secs_1601_to_1970) * 10000000; + ft->dwHighDateTime = ticks >> 32; + ft->dwLowDateTime = ticks; +} + static inline BOOL msvcrt_is_valid_fd(int fd) { return fd >= 0 && fd < MSVCRT_fdend && (MSVCRT_fdesc[fd].wxflag & WX_OPEN); @@ -914,7 +924,7 @@ int CDECL MSVCRT__locking(int fd, int mode, LONG nbytes) /********************************************************************* * fseek (MSVCRT.@) */ -int CDECL MSVCRT_fseek(MSVCRT_FILE* file, long offset, int whence) +int CDECL MSVCRT_fseek(MSVCRT_FILE* file, MSVCRT_long offset, int whence) { /* Flush output if needed */ if(file->_flag & MSVCRT__IOWRT) @@ -946,13 +956,13 @@ int CDECL MSVCRT_fseek(MSVCRT_FILE* file, long offset, int whence) /********************************************************************* * _chsize (MSVCRT.@) */ -int CDECL _chsize(int fd, long size) +int CDECL _chsize(int fd, MSVCRT_long size) { LONG cur, pos; HANDLE handle; BOOL ret = FALSE; - TRACE("(fd=%d, size=%ld)\n", fd, size); + TRACE("(fd=%d, size=%d)\n", fd, size); LOCK_FILES(); @@ -1213,27 +1223,22 @@ int CDECL MSVCRT__fstat(int fd, struct MSVCRT__stat* buf) } /********************************************************************* - * _futime (MSVCRT.@) + * _futime64 (MSVCRT.@) */ -int CDECL _futime(int fd, struct MSVCRT__utimbuf *t) +int CDECL _futime64(int fd, struct MSVCRT___utimbuf64 *t) { HANDLE hand = msvcrt_fdtoh(fd); FILETIME at, wt; if (!t) { - MSVCRT_time_t currTime; - MSVCRT_time(&currTime); - RtlSecondsSince1970ToTime(currTime, (LARGE_INTEGER *)&at); - wt = at; + time_to_filetime( MSVCRT__time64(NULL), &at ); + wt = at; } else { - RtlSecondsSince1970ToTime(t->actime, (LARGE_INTEGER *)&at); - if (t->actime == t->modtime) - wt = at; - else - RtlSecondsSince1970ToTime(t->modtime, (LARGE_INTEGER *)&wt); + time_to_filetime( t->actime, &at ); + time_to_filetime( t->modtime, &wt ); } if (!SetFileTime(hand, NULL, &at, &wt)) @@ -1245,6 +1250,32 @@ int CDECL _futime(int fd, struct MSVCRT__utimbuf *t) } /********************************************************************* + * _futime32 (MSVCRT.@) + */ +int CDECL _futime32(int fd, struct MSVCRT___utimbuf32 *t) +{ + struct MSVCRT___utimbuf64 t64; + t64.actime = t->actime; + t64.modtime = t->modtime; + return _futime64( fd, &t64 ); +} + +/********************************************************************* + * _futime (MSVCRT.@) + */ +#ifdef _WIN64 +int CDECL _futime(int fd, struct MSVCRT___utimbuf64 *t) +{ + return _futime64( fd, t ); +} +#else +int CDECL _futime(int fd, struct MSVCRT___utimbuf32 *t) +{ + return _futime32( fd, t ); +} +#endif + +/********************************************************************* * _get_osfhandle (MSVCRT.@) */ MSVCRT_intptr_t CDECL _get_osfhandle(int fd) @@ -1807,7 +1838,7 @@ int CDECL _setmode(int fd,int mode) /********************************************************************* * _stat64 (MSVCRT.@) */ -int CDECL MSVCRT__stat64(const char* path, struct MSVCRT__stat64 * buf) +int CDECL MSVCRT_stat64(const char* path, struct MSVCRT__stat64 * buf) { DWORD dw; WIN32_FILE_ATTRIBUTE_DATA hfi; @@ -1864,21 +1895,21 @@ int CDECL MSVCRT__stat64(const char* path, struct MSVCRT__stat64 * buf) buf->st_atime = dw; RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw); buf->st_mtime = buf->st_ctime = dw; - TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink, - (long)(buf->st_size >> 32),(long)buf->st_size, - (long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime); + TRACE("%d %d 0x%08x%08x %d %d %d\n", buf->st_mode,buf->st_nlink, + (int)(buf->st_size >> 32),(int)buf->st_size, + (int)buf->st_atime,(int)buf->st_mtime,(int)buf->st_ctime); return 0; } /********************************************************************* * _stati64 (MSVCRT.@) */ -int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf) +int CDECL MSVCRT_stati64(const char* path, struct MSVCRT__stati64 * buf) { int ret; struct MSVCRT__stat64 buf64; - ret = MSVCRT__stat64(path, &buf64); + ret = MSVCRT_stat64(path, &buf64); if (!ret) msvcrt_stat64_to_stati64(&buf64, buf); return ret; @@ -1887,11 +1918,11 @@ int CDECL MSVCRT__stati64(const char* path, struct MSVCRT__stati64 * buf) /********************************************************************* * _stat (MSVCRT.@) */ -int CDECL MSVCRT__stat(const char* path, struct MSVCRT__stat * buf) +int CDECL MSVCRT_stat(const char* path, struct MSVCRT__stat * buf) { int ret; struct MSVCRT__stat64 buf64; - ret = MSVCRT__stat64( path, &buf64); + ret = MSVCRT_stat64( path, &buf64); if (!ret) msvcrt_stat64_to_stat(&buf64, buf); return ret; @@ -1953,9 +1984,9 @@ int CDECL MSVCRT__wstat64(const MSVCRT_wchar_t* path, struct MSVCRT__stat64 * bu buf->st_atime = dw; RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw); buf->st_mtime = buf->st_ctime = dw; - TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink, - (long)(buf->st_size >> 32),(long)buf->st_size, - (long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime); + TRACE("%d %d 0x%08x%08x %d %d %d\n", buf->st_mode,buf->st_nlink, + (int)(buf->st_size >> 32),(int)buf->st_size, + (int)buf->st_atime,(int)buf->st_mtime,(int)buf->st_ctime); return 0; } @@ -1989,7 +2020,7 @@ int CDECL MSVCRT__wstat(const MSVCRT_wchar_t* path, struct MSVCRT__stat * buf) /********************************************************************* * _tell (MSVCRT.@) */ -long CDECL _tell(int fd) +MSVCRT_long CDECL _tell(int fd) { return MSVCRT__lseek(fd, 0, SEEK_CUR); } @@ -2053,15 +2084,15 @@ int CDECL MSVCRT__umask(int umask) } /********************************************************************* - * _utime (MSVCRT.@) + * _utime64 (MSVCRT.@) */ -int CDECL _utime(const char* path, struct MSVCRT__utimbuf *t) +int CDECL _utime64(const char* path, struct MSVCRT___utimbuf64 *t) { int fd = MSVCRT__open(path, MSVCRT__O_WRONLY | MSVCRT__O_BINARY); if (fd > 0) { - int retVal = _futime(fd, t); + int retVal = _futime64(fd, t); MSVCRT__close(fd); return retVal; } @@ -2069,15 +2100,41 @@ int CDECL _utime(const char* path, struct MSVCRT__utimbuf *t) } /********************************************************************* - * _wutime (MSVCRT.@) + * _utime32 (MSVCRT.@) + */ +int CDECL _utime32(const char* path, struct MSVCRT___utimbuf32 *t) +{ + struct MSVCRT___utimbuf64 t64; + t64.actime = t->actime; + t64.modtime = t->modtime; + return _utime64( path, &t64 ); +} + +/********************************************************************* + * _utime (MSVCRT.@) */ -int CDECL _wutime(const MSVCRT_wchar_t* path, struct MSVCRT__utimbuf *t) +#ifdef _WIN64 +int CDECL _utime(const char* path, struct MSVCRT___utimbuf64 *t) +{ + return _utime64( path, t ); +} +#else +int CDECL _utime(const char* path, struct MSVCRT___utimbuf32 *t) +{ + return _utime32( path, t ); +} +#endif + +/********************************************************************* + * _wutime64 (MSVCRT.@) + */ +int CDECL _wutime64(const MSVCRT_wchar_t* path, struct MSVCRT___utimbuf64 *t) { int fd = _wopen(path, MSVCRT__O_WRONLY | MSVCRT__O_BINARY); if (fd > 0) { - int retVal = _futime(fd, t); + int retVal = _futime64(fd, t); MSVCRT__close(fd); return retVal; } @@ -2085,6 +2142,32 @@ int CDECL _wutime(const MSVCRT_wchar_t* path, struct MSVCRT__utimbuf *t) } /********************************************************************* + * _wutime32 (MSVCRT.@) + */ +int CDECL _wutime32(const MSVCRT_wchar_t* path, struct MSVCRT___utimbuf32 *t) +{ + struct MSVCRT___utimbuf64 t64; + t64.actime = t->actime; + t64.modtime = t->modtime; + return _wutime64( path, &t64 ); +} + +/********************************************************************* + * _wutime (MSVCRT.@) + */ +#ifdef _WIN64 +int CDECL _wutime(const MSVCRT_wchar_t* path, struct MSVCRT___utimbuf64 *t) +{ + return _wutime64( path, t ); +} +#else +int CDECL _wutime(const MSVCRT_wchar_t* path, struct MSVCRT___utimbuf32 *t) +{ + return _wutime32( path, t ); +} +#endif + +/********************************************************************* * _write (MSVCRT.@) */ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count) @@ -2789,7 +2872,7 @@ LONG CDECL MSVCRT_ftell(MSVCRT_FILE* file) { /* TODO: just call fgetpos and return lower half of result */ int off=0; - long pos; + MSVCRT_long pos; pos = _tell(file->_file); if(pos == -1) return -1; if(file->_bufsiz) { @@ -2842,7 +2925,7 @@ int CDECL MSVCRT_fgetpos(MSVCRT_FILE* file, MSVCRT_fpos_t *pos) */ int CDECL MSVCRT_fputs(const char *s, MSVCRT_FILE* file) { - size_t i, len = strlen(s); + MSVCRT_size_t i, len = strlen(s); if (!(MSVCRT_fdesc[file->_file].wxflag & WX_TEXT)) return MSVCRT_fwrite(s,sizeof(*s),len,file) == len ? 0 : MSVCRT_EOF; for (i=0; i_file].wxflag & WX_TEXT)) return MSVCRT_fwrite(s,sizeof(*s),len,file) == len ? 0 : MSVCRT_EOF; for (i=0; i> (32-shift)); @@ -445,7 +445,7 @@ unsigned long CDECL _lrotl(unsigned long num, int shift) /********************************************************************* * _lrotr (MSVCRT.@) */ -unsigned long CDECL _lrotr(unsigned long num, int shift) +MSVCRT_ulong CDECL _lrotr(MSVCRT_ulong num, int shift) { shift &= 0x1f; return (num >> shift) | (num << (32-shift)); @@ -463,7 +463,7 @@ unsigned int CDECL _rotr(unsigned int num, int shift) /********************************************************************* * _scalb (MSVCRT.@) */ -double CDECL _scalb(double num, long power) +double CDECL _scalb(double num, MSVCRT_long power) { /* Note - Can't forward directly as libc expects y as double */ double dblpower = (double)power; @@ -592,7 +592,7 @@ int * CDECL __fpecode(void) /********************************************************************* * ldexp (MSVCRT.@) */ -double CDECL MSVCRT_ldexp(double num, long exp) +double CDECL MSVCRT_ldexp(double num, MSVCRT_long exp) { double z = ldexp(num,exp); @@ -1007,10 +1007,10 @@ MSVCRT_div_t CDECL MSVCRT_div(int num, int denom) * [i386] Windows binary compatible - returns the struct in eax/edx. */ #ifdef __i386__ -unsigned __int64 CDECL MSVCRT_ldiv(long num, long denom) +unsigned __int64 CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom) { ldiv_t ldt = ldiv(num,denom); - return ((unsigned __int64)ldt.rem << 32) | (unsigned long)ldt.quot; + return ((unsigned __int64)ldt.rem << 32) | (MSVCRT_ulong)ldt.quot; } #else /********************************************************************* @@ -1018,7 +1018,7 @@ unsigned __int64 CDECL MSVCRT_ldiv(long num, long denom) * VERSION * [!i386] Non-x86 can't run win32 apps so we don't need binary compatibility */ -MSVCRT_ldiv_t CDECL MSVCRT_ldiv(long num, long denom) +MSVCRT_ldiv_t CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom) { ldiv_t result = ldiv(num,denom); diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index a6e0ccac2e6..f738bcfe510 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -74,12 +74,12 @@ static MSVCRT_wchar_t msvcrt_mbc_to_wc(unsigned int ch) return chW; } -static inline size_t u_strlen( const unsigned char *str ) +static inline MSVCRT_size_t u_strlen( const unsigned char *str ) { return strlen( (const char*) str ); } -static inline unsigned char* u_strncat( unsigned char* dst, const unsigned char* src, size_t len ) +static inline unsigned char* u_strncat( unsigned char* dst, const unsigned char* src, MSVCRT_size_t len ) { return (unsigned char*)strncat( (char*)dst, (const char*)src, len); } @@ -94,12 +94,12 @@ static inline int u_strcasecmp( const unsigned char *s1, const unsigned char *s2 return strcasecmp( (const char*)s1, (const char*)s2 ); } -static inline int u_strncmp( const unsigned char *s1, const unsigned char *s2, size_t len ) +static inline int u_strncmp( const unsigned char *s1, const unsigned char *s2, MSVCRT_size_t len ) { return strncmp( (const char*)s1, (const char*)s2, len ); } -static inline int u_strncasecmp( const unsigned char *s1, const unsigned char *s2, size_t len ) +static inline int u_strncasecmp( const unsigned char *s1, const unsigned char *s2, MSVCRT_size_t len ) { return strncasecmp( (const char*)s1, (const char*)s2, len ); } @@ -124,12 +124,12 @@ static inline unsigned char *u__strset( unsigned char *s, unsigned char c ) return (unsigned char*) _strset( (char*)s, c); } -static inline unsigned char *u__strnset( unsigned char *s, unsigned char c, size_t len ) +static inline unsigned char *u__strnset( unsigned char *s, unsigned char c, MSVCRT_size_t len ) { return (unsigned char*) _strnset( (char*)s, c, len ); } -static inline size_t u_strcspn( const unsigned char *s, const unsigned char *rej ) +static inline MSVCRT_size_t u_strcspn( const unsigned char *s, const unsigned char *rej ) { return strcspn( (const char *)s, (const char*)rej ); } diff --git a/dlls/msvcrt/misc.c b/dlls/msvcrt/misc.c index cba6aa8ea0f..3d3c03b9de5 100644 --- a/dlls/msvcrt/misc.c +++ b/dlls/msvcrt/misc.c @@ -63,9 +63,9 @@ int CDECL MSVCRT_rand(void) /********************************************************************* * _sleep (MSVCRT.@) */ -void CDECL MSVCRT__sleep(unsigned long timeout) +void CDECL MSVCRT__sleep(MSVCRT_ulong timeout) { - TRACE("_sleep for %ld milliseconds\n",timeout); + TRACE("_sleep for %d milliseconds\n",timeout); Sleep((timeout)?timeout:1); } diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 8ed8fd953ce..7edcd6d427c 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -45,22 +45,22 @@ typedef unsigned short MSVCRT_wchar_t; typedef unsigned short MSVCRT_wint_t; typedef unsigned short MSVCRT_wctype_t; typedef unsigned short MSVCRT__ino_t; -typedef unsigned long MSVCRT__fsize_t; +typedef unsigned int MSVCRT__fsize_t; +typedef int MSVCRT_long; +typedef unsigned int MSVCRT_ulong; #ifdef _WIN64 typedef unsigned __int64 MSVCRT_size_t; typedef __int64 MSVCRT_intptr_t; typedef unsigned __int64 MSVCRT_uintptr_t; -typedef __int64 MSVCRT_time_t; #else typedef unsigned long MSVCRT_size_t; typedef long MSVCRT_intptr_t; typedef unsigned long MSVCRT_uintptr_t; -typedef long MSVCRT_time_t; #endif typedef unsigned int MSVCRT__dev_t; -typedef int MSVCRT__off_t; -typedef long MSVCRT_clock_t; -typedef long MSVCRT___time32_t; +typedef int MSVCRT__off_t; +typedef int MSVCRT_clock_t; +typedef int MSVCRT___time32_t; typedef __int64 MSVCRT___time64_t; typedef __int64 MSVCRT_fpos_t; @@ -93,7 +93,7 @@ extern DWORD msvcrt_tls_index; struct __thread_data { int thread_errno; - unsigned long thread_doserrno; + MSVCRT_ulong thread_doserrno; unsigned int random_seed; /* seed for rand() */ char *strtok_next; /* next ptr for strtok() */ unsigned char *mbstok_next; /* next ptr for mbstok() */ @@ -198,8 +198,15 @@ extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**); #define _RT_CRNL 252 #define _RT_BANNER 255 -struct MSVCRT__timeb { - MSVCRT_time_t time; +struct MSVCRT___timeb32 { + MSVCRT___time32_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; + +struct MSVCRT___timeb64 { + MSVCRT___time64_t time; unsigned short millitm; short timezone; short dstflag; @@ -258,8 +265,8 @@ typedef struct MSVCRT__div_t { } MSVCRT_div_t; typedef struct MSVCRT__ldiv_t { - long quot; /* quotient */ - long rem; /* remainder */ + MSVCRT_long quot; /* quotient */ + MSVCRT_long rem; /* remainder */ } MSVCRT_ldiv_t; struct MSVCRT__heapinfo { @@ -292,46 +299,88 @@ struct MSVCRT__diskfree_t { unsigned int bytes_per_sector; }; -struct MSVCRT__finddata_t { - unsigned attrib; - MSVCRT_time_t time_create; - MSVCRT_time_t time_access; - MSVCRT_time_t time_write; - MSVCRT__fsize_t size; - char name[260]; +struct MSVCRT__finddata32_t { + unsigned int attrib; + MSVCRT___time32_t time_create; + MSVCRT___time32_t time_access; + MSVCRT___time32_t time_write; + MSVCRT__fsize_t size; + char name[260]; +}; + +struct MSVCRT__finddata32i64_t { + unsigned int attrib; + MSVCRT___time32_t time_create; + MSVCRT___time32_t time_access; + MSVCRT___time32_t time_write; + __int64 size; + char name[260]; +}; + +struct MSVCRT__finddata64i32_t { + unsigned int attrib; + MSVCRT___time64_t time_create; + MSVCRT___time64_t time_access; + MSVCRT___time64_t time_write; + MSVCRT__fsize_t size; + char name[260]; }; -struct MSVCRT__finddatai64_t { - unsigned attrib; - MSVCRT_time_t time_create; - MSVCRT_time_t time_access; - MSVCRT_time_t time_write; - __int64 size; - char name[260]; +struct MSVCRT__finddata64_t { + unsigned int attrib; + MSVCRT___time64_t time_create; + MSVCRT___time64_t time_access; + MSVCRT___time64_t time_write; + __int64 size; + char name[260]; }; -struct MSVCRT__wfinddata_t { - unsigned attrib; - MSVCRT_time_t time_create; - MSVCRT_time_t time_access; - MSVCRT_time_t time_write; - MSVCRT__fsize_t size; - MSVCRT_wchar_t name[260]; +struct MSVCRT__wfinddata32_t { + unsigned int attrib; + MSVCRT___time32_t time_create; + MSVCRT___time32_t time_access; + MSVCRT___time32_t time_write; + MSVCRT__fsize_t size; + MSVCRT_wchar_t name[260]; }; -struct MSVCRT__wfinddatai64_t { - unsigned attrib; - MSVCRT_time_t time_create; - MSVCRT_time_t time_access; - MSVCRT_time_t time_write; - __int64 size; - MSVCRT_wchar_t name[260]; +struct MSVCRT__wfinddata32i64_t { + unsigned int attrib; + MSVCRT___time32_t time_create; + MSVCRT___time32_t time_access; + MSVCRT___time32_t time_write; + __int64 size; + MSVCRT_wchar_t name[260]; }; -struct MSVCRT__utimbuf +struct MSVCRT__wfinddata64i32_t { + unsigned int attrib; + MSVCRT___time64_t time_create; + MSVCRT___time64_t time_access; + MSVCRT___time64_t time_write; + MSVCRT__fsize_t size; + MSVCRT_wchar_t name[260]; +}; + +struct MSVCRT__wfinddata64_t { + unsigned int attrib; + MSVCRT___time64_t time_create; + MSVCRT___time64_t time_access; + MSVCRT___time64_t time_write; + __int64 size; + MSVCRT_wchar_t name[260]; +}; + +struct MSVCRT___utimbuf32 +{ + MSVCRT___time32_t actime; + MSVCRT___time32_t modtime; +}; + +struct MSVCRT___utimbuf64 { - MSVCRT_time_t actime; - MSVCRT_time_t modtime; + MSVCRT___time64_t actime; + MSVCRT___time64_t modtime; }; /* for FreeBSD */ @@ -339,46 +388,46 @@ struct MSVCRT__utimbuf #undef st_ctime #undef st_mtime -struct MSVCRT__stat { - MSVCRT__dev_t st_dev; - MSVCRT__ino_t st_ino; - unsigned short st_mode; - short st_nlink; - short st_uid; - short st_gid; - MSVCRT__dev_t st_rdev; - MSVCRT__off_t st_size; - MSVCRT_time_t st_atime; - MSVCRT_time_t st_mtime; - MSVCRT_time_t st_ctime; +struct MSVCRT__stat32 { + MSVCRT__dev_t st_dev; + MSVCRT__ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + MSVCRT__dev_t st_rdev; + MSVCRT__off_t st_size; + MSVCRT___time32_t st_atime; + MSVCRT___time32_t st_mtime; + MSVCRT___time32_t st_ctime; }; -struct MSVCRT_stat { - MSVCRT__dev_t st_dev; - MSVCRT__ino_t st_ino; - unsigned short st_mode; - short st_nlink; - short st_uid; - short st_gid; - MSVCRT__dev_t st_rdev; - MSVCRT__off_t st_size; - MSVCRT_time_t st_atime; - MSVCRT_time_t st_mtime; - MSVCRT_time_t st_ctime; +struct MSVCRT__stat32i64 { + MSVCRT__dev_t st_dev; + MSVCRT__ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + MSVCRT__dev_t st_rdev; + __int64 DECLSPEC_ALIGN(8) st_size; + MSVCRT___time32_t st_atime; + MSVCRT___time32_t st_mtime; + MSVCRT___time32_t st_ctime; }; -struct MSVCRT__stati64 { - MSVCRT__dev_t st_dev; - MSVCRT__ino_t st_ino; - unsigned short st_mode; - short st_nlink; - short st_uid; - short st_gid; - MSVCRT__dev_t st_rdev; - __int64 DECLSPEC_ALIGN(8) st_size; - MSVCRT_time_t st_atime; - MSVCRT_time_t st_mtime; - MSVCRT_time_t st_ctime; +struct MSVCRT__stat64i32 { + MSVCRT__dev_t st_dev; + MSVCRT__ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + MSVCRT__dev_t st_rdev; + MSVCRT__off_t st_size; + MSVCRT___time64_t st_atime; + MSVCRT___time64_t st_mtime; + MSVCRT___time64_t st_ctime; }; struct MSVCRT__stat64 { @@ -395,6 +444,22 @@ struct MSVCRT__stat64 { MSVCRT___time64_t st_ctime; }; +#ifdef _WIN64 +#define MSVCRT__finddata_t MSVCRT__finddata64i32_t +#define MSVCRT__finddatai64_t MSVCRT__finddata64_t +#define MSVCRT__wfinddata_t MSVCRT__wfinddata64i32_t +#define MSVCRT__wfinddatai64_t MSVCRT__wfinddata64_t +#define MSVCRT__stat MSVCRT__stat64i32 +#define MSVCRT__stati64 MSVCRT__stat64 +#else +#define MSVCRT__finddata_t MSVCRT__finddata32_t +#define MSVCRT__finddatai64_t MSVCRT__finddata32i64_t +#define MSVCRT__wfinddata_t MSVCRT__wfinddata32_t +#define MSVCRT__wfinddatai64_t MSVCRT__wfinddata32i64_t +#define MSVCRT__stat MSVCRT__stat32 +#define MSVCRT__stati64 MSVCRT__stat32i64 +#endif + #define MSVCRT_WEOF (MSVCRT_wint_t)(0xFFFF) #define MSVCRT_EOF (-1) #define MSVCRT_TMP_MAX 0x7fff @@ -652,19 +717,16 @@ MSVCRT_wint_t __cdecl MSVCRT_fgetwc(MSVCRT_FILE*); MSVCRT_wint_t __cdecl MSVCRT_ungetwc(MSVCRT_wint_t,MSVCRT_FILE*); void __cdecl MSVCRT__exit(int); void __cdecl MSVCRT_abort(void); -unsigned long* __cdecl MSVCRT___doserrno(void); +MSVCRT_ulong* __cdecl MSVCRT___doserrno(void); int* __cdecl MSVCRT__errno(void); char* __cdecl MSVCRT_getenv(const char*); char* __cdecl MSVCRT_setlocale(int,const char*); int __cdecl MSVCRT_fclose(MSVCRT_FILE*); void __cdecl MSVCRT_terminate(void); MSVCRT_FILE* __cdecl MSVCRT__iob_func(void); -MSVCRT_time_t __cdecl MSVCRT_mktime(struct MSVCRT_tm *t); -struct MSVCRT_tm* __cdecl MSVCRT_localtime(const MSVCRT_time_t* secs); -struct MSVCRT_tm* __cdecl MSVCRT_gmtime(const MSVCRT_time_t* secs); MSVCRT_clock_t __cdecl MSVCRT_clock(void); -double __cdecl MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2); -MSVCRT_time_t __cdecl MSVCRT_time(MSVCRT_time_t*); +MSVCRT___time32_t __cdecl MSVCRT__time32(MSVCRT___time32_t*); +MSVCRT___time64_t __cdecl MSVCRT__time64(MSVCRT___time64_t*); MSVCRT_FILE* __cdecl MSVCRT__fdopen(int, const char *); MSVCRT_FILE* __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *); int __cdecl MSVCRT_vsnprintf(char *str, unsigned int len, const char *format, __ms_va_list valist); @@ -697,7 +759,6 @@ MSVCRT_wchar_t*** __cdecl __p__wenviron(void); char* __cdecl _strdate(char* date); char* __cdecl _strtime(char* date); int __cdecl _setmbcp(int); -void __cdecl MSVCRT__ftime(struct MSVCRT__timeb *buf); int __cdecl MSVCRT__close(int); int __cdecl MSVCRT__dup(int); int __cdecl MSVCRT__dup2(int, int); diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index e67251dff7a..8cfcd3dceed 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -210,9 +210,13 @@ @ cdecl _cputs(str) @ cdecl _creat(str long) MSVCRT__creat @ varargs _cscanf(str) +@ cdecl _ctime32(ptr) MSVCRT__ctime32 +@ cdecl _ctime64(ptr) MSVCRT__ctime64 @ extern _ctype MSVCRT__ctype @ cdecl _cwait(ptr long long) @ extern _daylight MSVCRT___daylight +@ cdecl _difftime32(long long) MSVCRT__difftime32 +@ cdecl _difftime64(long long) MSVCRT__difftime64 @ extern _dstbias MSVCRT__dstbias @ cdecl _dup (long) MSVCRT__dup @ cdecl _dup2 (long long) MSVCRT__dup2 @@ -263,9 +267,13 @@ @ cdecl _fstat64(long ptr) MSVCRT__fstat64 @ cdecl _fstati64(long ptr) MSVCRT__fstati64 @ cdecl _ftime(ptr) MSVCRT__ftime +@ cdecl _ftime32(ptr) MSVCRT__ftime32 +@ cdecl _ftime64(ptr) MSVCRT__ftime64 @ cdecl -ret64 _ftol() ntdll._ftol @ cdecl _fullpath(ptr str long) @ cdecl _futime(long ptr) +@ cdecl _futime32(long ptr) +@ cdecl _futime64(long ptr) @ cdecl _gcvt(double long str) @ cdecl _get_osfhandle(long) @ cdecl _get_sbh_threshold() @@ -286,6 +294,8 @@ @ cdecl _getw(ptr) MSVCRT__getw @ cdecl _getws(ptr) MSVCRT__getws @ cdecl _global_unwind2(ptr) +@ cdecl _gmtime32(ptr) MSVCRT__gmtime32 +@ cdecl _gmtime64(ptr) MSVCRT__gmtime64 @ cdecl _heapadd (ptr long) @ cdecl _heapchk() @ cdecl _heapmin() @@ -341,6 +351,8 @@ @ cdecl _lfind(ptr ptr ptr long ptr) @ cdecl _loaddll(str) @ cdecl -i386 _local_unwind2(ptr long) +@ cdecl _localtime32(ptr) MSVCRT__localtime32 +@ cdecl _localtime64(ptr) MSVCRT__localtime64 @ cdecl _lock(long) @ cdecl _locking(long long long) MSVCRT__locking @ cdecl _logb( double ) @@ -414,6 +426,8 @@ @ cdecl _memicmp(str str long) ntdll._memicmp @ cdecl _mkdir(str) MSVCRT__mkdir @ cdecl _mktemp(str) +@ cdecl _mktime32(ptr) MSVCRT__mktime32 +@ cdecl _mktime64(ptr) MSVCRT__mktime64 @ cdecl _msize(ptr) @ cdecl _nextafter(double double) @ cdecl _onexit(ptr) MSVCRT__onexit @@ -468,9 +482,9 @@ @ cdecl _spawnvp(long str ptr) @ cdecl _spawnvpe(long str ptr ptr) @ cdecl _splitpath(str ptr ptr ptr ptr) ntdll._splitpath -@ cdecl _stat(str ptr) MSVCRT__stat -@ cdecl _stat64(str ptr) MSVCRT__stat64 -@ cdecl _stati64(str ptr) MSVCRT__stati64 +@ cdecl _stat(str ptr) MSVCRT_stat +@ cdecl _stat64(str ptr) MSVCRT_stat64 +@ cdecl _stati64(str ptr) MSVCRT_stati64 @ cdecl _statusfp() @ cdecl _strcmpi(str str) ntdll._strcmpi @ cdecl _strdate(ptr) @@ -493,6 +507,8 @@ @ cdecl _tell(long) @ cdecl -ret64 _telli64(long) @ cdecl _tempnam(str str) +@ cdecl _time32(ptr) MSVCRT__time32 +@ cdecl _time64(ptr) MSVCRT__time64 @ extern _timezone MSVCRT___timezone @ cdecl _tolower(long) MSVCRT__tolower @ cdecl _toupper(long) MSVCRT__toupper @@ -507,6 +523,8 @@ @ cdecl _unlink(str) MSVCRT__unlink @ cdecl _unloaddll(long) @ cdecl _unlock(long) +@ cdecl _utime32(str ptr) +@ cdecl _utime64(str ptr) @ cdecl _utime(str ptr) @ cdecl _vscprintf(str ptr) @ cdecl _vscwprintf(wstr ptr) @@ -530,6 +548,8 @@ @ cdecl _wcsset(wstr long) @ cdecl _wcsupr(wstr) ntdll._wcsupr @ cdecl _wctime(ptr) MSVCRT__wctime +@ cdecl _wctime32(ptr) MSVCRT__wctime32 +@ cdecl _wctime64(ptr) MSVCRT__wctime64 @ extern _wenviron @ varargs _wexecl(wstr wstr) @ varargs _wexecle(wstr wstr) @@ -592,6 +612,8 @@ @ cdecl _wtol(wstr) ntdll._wtol @ cdecl _wunlink(wstr) @ cdecl _wutime(wstr ptr) +@ cdecl _wutime32(wstr ptr) +@ cdecl _wutime64(wstr ptr) @ cdecl _y0(double) @ cdecl _y1(double) @ cdecl _yn(long double ) diff --git a/dlls/msvcrt/process.c b/dlls/msvcrt/process.c index 33661489ab5..0b1eb01d272 100644 --- a/dlls/msvcrt/process.c +++ b/dlls/msvcrt/process.c @@ -185,7 +185,7 @@ static MSVCRT_intptr_t msvcrt_spawn(int flags, const MSVCRT_wchar_t* exe, MSVCRT static MSVCRT_wchar_t* msvcrt_argvtos(const MSVCRT_wchar_t* const* arg, MSVCRT_wchar_t delim) { const MSVCRT_wchar_t* const* a; - long size; + int size; MSVCRT_wchar_t* p; MSVCRT_wchar_t* ret; @@ -230,7 +230,7 @@ static MSVCRT_wchar_t* msvcrt_argvtos(const MSVCRT_wchar_t* const* arg, MSVCRT_w static MSVCRT_wchar_t *msvcrt_argvtos_aw(const char * const *arg, MSVCRT_wchar_t delim) { const char * const *a; - unsigned long len; + unsigned int len; MSVCRT_wchar_t *p, *ret; if (!arg) diff --git a/dlls/msvcrt/tests/cpp.c b/dlls/msvcrt/tests/cpp.c index 9c9158df9e2..d640d674e3e 100644 --- a/dlls/msvcrt/tests/cpp.c +++ b/dlls/msvcrt/tests/cpp.c @@ -55,10 +55,10 @@ typedef struct __type_info /* Function pointers. We need to use these to call these funcs as __thiscall */ static HMODULE hMsvcrt; -static void* (*poperator_new)(unsigned int); -static void (*poperator_delete)(void*); -static void* (*pmalloc)(unsigned int); -static void (*pfree)(void*); +static void* (__cdecl *poperator_new)(unsigned int); +static void (__cdecl *poperator_delete)(void*); +static void* (__cdecl *pmalloc)(unsigned int); +static void (__cdecl *pfree)(void*); /* exception */ static void (WINAPI *pexception_ctor)(exception*,LPCSTR*); @@ -113,12 +113,12 @@ static int (WINAPI *ptype_info_opequals_equals)(type_info*,type_info*); static int (WINAPI *ptype_info_opnot_equals)(type_info*,type_info*); /* RTTI */ -static type_info* (*p__RTtypeid)(void*); -static void* (*p__RTCastToVoid)(void*); -static void* (*p__RTDynamicCast)(void*,int,void*,void*,int); +static type_info* (__cdecl *p__RTtypeid)(void*); +static void* (__cdecl *p__RTCastToVoid)(void*); +static void* (__cdecl *p__RTDynamicCast)(void*,int,void*,void*,int); /*Demangle*/ -static char* (*p__unDName)(char*,const char*,int,void*,void*,unsigned short int); +static char* (__cdecl *p__unDName)(char*,const char*,int,void*,void*,unsigned short int); /* _very_ early native versions have serious RTTI bugs, so we check */ diff --git a/dlls/msvcrt/tests/data.c b/dlls/msvcrt/tests/data.c index 01704ac5131..a27ca27f3a6 100644 --- a/dlls/msvcrt/tests/data.c +++ b/dlls/msvcrt/tests/data.c @@ -31,12 +31,12 @@ #include #include -typedef void (*_INITTERMFUN)(void); -static void (*p_initterm)(_INITTERMFUN *start, _INITTERMFUN *end); +typedef void (__cdecl *_INITTERMFUN)(void); +static void (__cdecl *p_initterm)(_INITTERMFUN *start, _INITTERMFUN *end); static int callbacked; -static void initcallback(void) +static void __cdecl initcallback(void) { callbacked++; } diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index edc0799e6b3..d4056563c62 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -179,7 +179,7 @@ static void test_readmode( BOOL ascii_mode ) const int *ip; int i, j, m, ao, pl; unsigned int fp; - long l; + LONG l; fd = open ("fdopen.tst", O_WRONLY | O_CREAT | O_BINARY, _S_IREAD |_S_IWRITE); /* an internal buffer of BUFSIZ is maintained, so make a file big @@ -212,7 +212,7 @@ static void test_readmode( BOOL ascii_mode ) ok(fgets(buffer,2*BUFSIZ+256,file) !=0,"padding line fgets failed unexpected in %s\n", IOMODE); l = ftell(file); pl = 2*BUFSIZ-2; - ok(l == pl,"padding line ftell got %ld should be %d in %s\n", l, pl, IOMODE); + ok(l == pl,"padding line ftell got %d should be %d in %s\n", l, pl, IOMODE); ok(lstrlenA(buffer) == pl+ao,"padding line fgets got size %d should be %d in %s\n", lstrlenA(buffer), pl+ao, IOMODE); for (fp=0; fp #include "wine/test.h" -static void (*p_aligned_free)(void*) = NULL; -static void * (*p_aligned_malloc)(size_t,size_t) = NULL; -static void * (*p_aligned_offset_malloc)(size_t,size_t,size_t) = NULL; -static void * (*p_aligned_realloc)(void*,size_t,size_t) = NULL; -static void * (*p_aligned_offset_realloc)(void*,size_t,size_t,size_t) = NULL; +static void (__cdecl *p_aligned_free)(void*) = NULL; +static void * (__cdecl *p_aligned_malloc)(size_t,size_t) = NULL; +static void * (__cdecl *p_aligned_offset_malloc)(size_t,size_t,size_t) = NULL; +static void * (__cdecl *p_aligned_realloc)(void*,size_t,size_t) = NULL; +static void * (__cdecl *p_aligned_offset_realloc)(void*,size_t,size_t,size_t) = NULL; static void test_aligned_malloc(unsigned int size, unsigned int alignment) { diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c index 66bab153f6b..cea4db309cb 100644 --- a/dlls/msvcrt/tests/printf.c +++ b/dlls/msvcrt/tests/printf.c @@ -782,7 +782,7 @@ static void test_xcvt(void) } } -static int _vsnwprintf_wrapper(wchar_t *str, size_t len, const wchar_t *format, ...) +static int __cdecl _vsnwprintf_wrapper(wchar_t *str, size_t len, const wchar_t *format, ...) { int ret; __ms_va_list valist; @@ -810,8 +810,8 @@ static void test_vsnwprintf(void) ok( !strcmp(buf, "onetwothree"), "got %s expected 'onetwothree'\n", buf ); } -static int (*p__vscprintf)(const char *format, __ms_va_list valist); -static int (*p__vscwprintf)(const wchar_t *format, __ms_va_list valist); +static int (__cdecl *p__vscprintf)(const char *format, __ms_va_list valist); +static int (__cdecl *p__vscwprintf)(const wchar_t *format, __ms_va_list valist); static int __cdecl _vscprintf_wrapper(const char *format, ...) { diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 3286e91bc71..96bcb7fa926 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -45,12 +45,12 @@ static char *buf_to_string(const unsigned char *bin, int len, int nr) #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); } #define expect_bin(buf, value, len) { ok(memcmp((buf), value, len) == 0, "Binary buffer mismatch - expected %s, got %s\n", buf_to_string((unsigned char *)value, len, 1), buf_to_string((buf), len, 0)); } -static void* (*pmemcpy)(void *, const void *, size_t n); -static int* (*pmemcmp)(void *, const void *, size_t n); -static int (*pstrcpy_s)(char *dst, size_t len, const char *src); -static int (*pstrcat_s)(char *dst, size_t len, const char *src); -static int (*p_mbsnbcpy_s)(unsigned char * dst, size_t size, const unsigned char * src, size_t count); -static int (*p_wcscpy_s)(wchar_t *wcDest, size_t size, const wchar_t *wcSrc); +static void* (__cdecl *pmemcpy)(void *, const void *, size_t n); +static int* (__cdecl *pmemcmp)(void *, const void *, size_t n); +static int (__cdecl *pstrcpy_s)(char *dst, size_t len, const char *src); +static int (__cdecl *pstrcat_s)(char *dst, size_t len, const char *src); +static int (__cdecl *p_mbsnbcpy_s)(unsigned char * dst, size_t size, const unsigned char * src, size_t count); +static int (__cdecl *p_wcscpy_s)(wchar_t *wcDest, size_t size, const wchar_t *wcSrc); static int *p__mb_cur_max; static unsigned char *p_mbctype; diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index a929120e1de..3b7bb71abb5 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -85,9 +85,9 @@ static inline void unix_tm_to_msvcrt( struct MSVCRT_tm *dest, const struct tm *s #define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC) /********************************************************************** - * mktime (MSVCRT.@) + * _mktime64 (MSVCRT.@) */ -MSVCRT_time_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) +MSVCRT___time64_t CDECL MSVCRT__mktime64(struct MSVCRT_tm *mstm) { time_t secs; struct tm tm; @@ -99,10 +99,33 @@ MSVCRT_time_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) return secs < 0 ? -1 : secs; } +/********************************************************************** + * _mktime32 (MSVCRT.@) + */ +MSVCRT___time32_t CDECL MSVCRT__mktime32(struct MSVCRT_tm *mstm) +{ + return MSVCRT__mktime64( mstm ); +} + +/********************************************************************** + * mktime (MSVCRT.@) + */ +#ifdef _WIN64 +MSVCRT___time64_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) +{ + return MSVCRT__mktime64( mstm ); +} +#else +MSVCRT___time32_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) +{ + return MSVCRT__mktime32( mstm ); +} +#endif + /********************************************************************* - * localtime (MSVCRT.@) + * _localtime64 (MSVCRT.@) */ -struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT_time_t* secs) +struct MSVCRT_tm* CDECL MSVCRT__localtime64(const MSVCRT___time64_t* secs) { struct tm tm; thread_data_t *data; @@ -119,9 +142,33 @@ struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT_time_t* secs) } /********************************************************************* - * gmtime (MSVCRT.@) + * _localtime32 (MSVCRT.@) */ -struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT_time_t* secs) +struct MSVCRT_tm* CDECL MSVCRT__localtime32(const MSVCRT___time32_t* secs) +{ + MSVCRT___time64_t secs64 = *secs; + return MSVCRT__localtime64( &secs64 ); +} + +/********************************************************************* + * localtime (MSVCRT.@) + */ +#ifdef _WIN64 +struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT___time64_t* secs) +{ + return MSVCRT__localtime64( secs ); +} +#else +struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT___time32_t* secs) +{ + return MSVCRT__localtime32( secs ); +} +#endif + +/********************************************************************* + * _gmtime64 (MSVCRT.@) + */ +struct MSVCRT_tm* CDECL MSVCRT__gmtime64(const MSVCRT___time64_t* secs) { thread_data_t * const data = msvcrt_get_thread_data(); int i; @@ -154,6 +201,30 @@ struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT_time_t* secs) return &data->time_buffer; } +/********************************************************************* + * _gmtime32 (MSVCRT.@) + */ +struct MSVCRT_tm* CDECL MSVCRT__gmtime32(const MSVCRT___time32_t* secs) +{ + MSVCRT___time64_t secs64 = *secs; + return MSVCRT__gmtime64( &secs64 ); +} + +/********************************************************************* + * gmtime (MSVCRT.@) + */ +#ifdef _WIN64 +struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT___time64_t* secs) +{ + return MSVCRT__gmtime64( secs ); +} +#else +struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT___time32_t* secs) +{ + return MSVCRT__gmtime32( secs ); +} +#endif + /********************************************************************** * _strdate (MSVCRT.@) */ @@ -223,17 +294,40 @@ MSVCRT_clock_t CDECL MSVCRT_clock(void) } /********************************************************************* - * difftime (MSVCRT.@) + * _difftime64 (MSVCRT.@) */ -double CDECL MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2) +double CDECL MSVCRT__difftime64(MSVCRT___time64_t time1, MSVCRT___time64_t time2) { return (double)(time1 - time2); } /********************************************************************* - * _ftime (MSVCRT.@) + * _difftime32 (MSVCRT.@) */ -void CDECL MSVCRT__ftime(struct MSVCRT__timeb *buf) +double CDECL MSVCRT__difftime32(MSVCRT___time32_t time1, MSVCRT___time32_t time2) +{ + return (double)(time1 - time2); +} + +/********************************************************************* + * difftime (MSVCRT.@) + */ +#ifdef _WIN64 +double CDECL MSVCRT_difftime(MSVCRT___time64_t time1, MSVCRT___time64_t time2) +{ + return MSVCRT__difftime64( time1, time2 ); +} +#else +double CDECL MSVCRT_difftime(MSVCRT___time32_t time1, MSVCRT___time32_t time2) +{ + return MSVCRT__difftime32( time1, time2 ); +} +#endif + +/********************************************************************* + * _ftime64 (MSVCRT.@) + */ +void CDECL MSVCRT__ftime64(struct MSVCRT___timeb64 *buf) { TIME_ZONE_INFORMATION tzinfo; FILETIME ft; @@ -253,18 +347,76 @@ void CDECL MSVCRT__ftime(struct MSVCRT__timeb *buf) } /********************************************************************* - * time (MSVCRT.@) + * _ftime32 (MSVCRT.@) */ -MSVCRT_time_t CDECL MSVCRT_time(MSVCRT_time_t* buf) +void CDECL MSVCRT__ftime32(struct MSVCRT___timeb32 *buf) { - MSVCRT_time_t curtime; - struct MSVCRT__timeb tb; + struct MSVCRT___timeb64 buf64; - MSVCRT__ftime(&tb); + MSVCRT__ftime64( &buf64 ); + buf->time = buf64.time; + buf->millitm = buf64.millitm; + buf->timezone = buf64.timezone; + buf->dstflag = buf64.dstflag; +} - curtime = tb.time; - return buf ? *buf = curtime : curtime; +/********************************************************************* + * _ftime (MSVCRT.@) + */ +#ifdef _WIN64 +void CDECL MSVCRT__ftime(struct MSVCRT___timeb64 *buf) +{ + return MSVCRT__ftime64( buf ); } +#else +void CDECL MSVCRT__ftime(struct MSVCRT___timeb32 *buf) +{ + return MSVCRT__ftime32( buf ); +} +#endif + +/********************************************************************* + * _time64 (MSVCRT.@) + */ +MSVCRT___time64_t CDECL MSVCRT__time64(MSVCRT___time64_t *buf) +{ + MSVCRT___time64_t curtime; + struct MSVCRT___timeb64 tb; + + MSVCRT__ftime64(&tb); + + curtime = tb.time; + return buf ? *buf = curtime : curtime; +} + +/********************************************************************* + * _time32 (MSVCRT.@) + */ +MSVCRT___time32_t CDECL MSVCRT__time32(MSVCRT___time32_t *buf) +{ + MSVCRT___time32_t curtime; + struct MSVCRT___timeb64 tb; + + MSVCRT__ftime64(&tb); + + curtime = tb.time; + return buf ? *buf = curtime : curtime; +} + +/********************************************************************* + * time (MSVCRT.@) + */ +#ifdef _WIN64 +MSVCRT___time64_t CDECL MSVCRT_time(MSVCRT___time64_t* buf) +{ + return MSVCRT__time64( buf ); +} +#else +MSVCRT___time32_t CDECL MSVCRT_time(MSVCRT___time32_t* buf) +{ + return MSVCRT__time32( buf ); +} +#endif /********************************************************************* * _daylight (MSVCRT.@) @@ -295,12 +447,12 @@ int * CDECL __p__dstbias(void) /********************************************************************* * _timezone (MSVCRT.@) */ -long MSVCRT___timezone = 0; +MSVCRT_long MSVCRT___timezone = 0; /********************************************************************* * __p_timezone (MSVCRT.@) */ -long * CDECL MSVCRT___p__timezone(void) +MSVCRT_long * CDECL MSVCRT___p__timezone(void) { return &MSVCRT___timezone; } @@ -338,7 +490,7 @@ void CDECL MSVCRT__tzset(void) static const time_t seconds_in_year = (365 * 24 + 6) * 3600; time_t t; struct tm *tmp; - long zone_january, zone_july; + int zone_january, zone_july; t = (time(NULL) / seconds_in_year) * seconds_in_year; tmp = localtime(&t); @@ -443,20 +595,69 @@ MSVCRT_wchar_t * CDECL MSVCRT__wasctime(const struct MSVCRT_tm *mstm) } /********************************************************************* - * ctime (MSVCRT.@) + * _ctime64 (MSVCRT.@) + */ +char * CDECL MSVCRT__ctime64(const MSVCRT___time64_t *time) +{ + struct MSVCRT_tm *t; + t = MSVCRT__localtime64( time ); + if (!t) return NULL; + return MSVCRT_asctime( t ); +} + +/********************************************************************* + * _ctime32 (MSVCRT.@) */ -char * CDECL MSVCRT_ctime(const MSVCRT_time_t *time) +char * CDECL MSVCRT__ctime32(const MSVCRT___time32_t *time) { struct MSVCRT_tm *t; - t = MSVCRT_localtime( time ); + t = MSVCRT__localtime32( time ); if (!t) return NULL; return MSVCRT_asctime( t ); } /********************************************************************* + * ctime (MSVCRT.@) + */ +#ifdef _WIN64 +char * CDECL MSVCRT_ctime(const MSVCRT___time64_t *time) +{ + return MSVCRT__ctime64( time ); +} +#else +char * CDECL MSVCRT_ctime(const MSVCRT___time32_t *time) +{ + return MSVCRT__ctime32( time ); +} +#endif + +/********************************************************************* + * _wctime64 (MSVCRT.@) + */ +MSVCRT_wchar_t * CDECL MSVCRT__wctime64(const MSVCRT___time64_t *time) +{ + return MSVCRT__wasctime( MSVCRT__localtime64(time) ); +} + +/********************************************************************* + * _wctime32 (MSVCRT.@) + */ +MSVCRT_wchar_t * CDECL MSVCRT__wctime32(const MSVCRT___time32_t *time) +{ + return MSVCRT__wasctime( MSVCRT__localtime32(time) ); +} + +/********************************************************************* * _wctime (MSVCRT.@) */ -MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT_time_t *time) +#ifdef _WIN64 +MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT___time64_t *time) { - return MSVCRT__wasctime( MSVCRT_localtime(time) ); + return MSVCRT__wctime64( time ); } +#else +MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT___time32_t *time) +{ + return MSVCRT__wctime32( time ); +} +#endif diff --git a/dlls/msvcrt/undname.c b/dlls/msvcrt/undname.c index 317d7d33c64..d825cfc7f72 100644 --- a/dlls/msvcrt/undname.c +++ b/dlls/msvcrt/undname.c @@ -113,7 +113,7 @@ struct datatype_t * where we use a poor-man allocator. It's fast, and since all * allocation is pool, memory management is easy (esp. freeing). */ -static void* und_alloc(struct parsed_symbol* sym, size_t len) +static void* und_alloc(struct parsed_symbol* sym, unsigned int len) { void* ptr; @@ -233,11 +233,11 @@ static char* str_array_get_ref(struct array* cref, unsigned idx) */ static char* str_printf(struct parsed_symbol* sym, const char* format, ...) { - va_list args; - size_t len = 1, i, sz; - char* tmp; - char* p; - char* t; + va_list args; + unsigned int len = 1, i, sz; + char* tmp; + char* p; + char* t; va_start(args, format); for (i = 0; format[i]; i++) @@ -319,7 +319,7 @@ static const char* get_number(struct parsed_symbol* sym) } else if (*sym->current >= 'A' && *sym->current <= 'P') { - long ret = 0; + int ret = 0; while (*sym->current >= 'A' && *sym->current <= 'P') { @@ -329,7 +329,7 @@ static const char* get_number(struct parsed_symbol* sym) if (*sym->current != '@') return NULL; ptr = und_alloc(sym, 17); - sprintf(ptr, "%s%ld", sgn ? "-" : "", ret); + sprintf(ptr, "%s%d", sgn ? "-" : "", ret); sym->current++; } else return NULL; @@ -587,9 +587,9 @@ static BOOL get_class(struct parsed_symbol* sym) */ static char* get_class_string(struct parsed_symbol* sym, int start) { - int i; - size_t len, sz; - char* ret; + int i; + unsigned int len, sz; + char* ret; struct array *a = &sym->stack; for (len = 0, i = start; i < a->num; i++) diff --git a/dlls/msvcrtd/debug.c b/dlls/msvcrtd/debug.c index 04720588374..7e2fa0daf0f 100644 --- a/dlls/msvcrtd/debug.c +++ b/dlls/msvcrtd/debug.c @@ -31,16 +31,19 @@ int _crtAssertBusy = -1; int _crtBreakAlloc = -1; int _crtDbgFlag = 0; -extern int _callnewh(unsigned long); +#ifdef _WIN64 +typedef unsigned __int64 MSVCRT_size_t; +#else +typedef unsigned long MSVCRT_size_t; +#endif + +extern int _callnewh(MSVCRT_size_t); /********************************************************************* * ??2@YAPAXIHPBDH@Z (MSVCRTD.@) */ -void * CDECL MSVCRTD_operator_new_dbg( - unsigned long nSize, - int nBlockUse, - const char *szFileName, - int nLine) +void * CDECL MSVCRTD_operator_new_dbg(MSVCRT_size_t nSize, int nBlockUse, + const char *szFileName, int nLine) { void *retval = NULL; diff --git a/dlls/msvcrtd/tests/debug.c b/dlls/msvcrtd/tests/debug.c index fbfcdc5ea4d..a7f7db1d82b 100644 --- a/dlls/msvcrtd/tests/debug.c +++ b/dlls/msvcrtd/tests/debug.c @@ -30,7 +30,7 @@ /**********************************************************************/ -static void * (*pMSVCRTD_operator_new_dbg)(unsigned long, int, const char *, int) = NULL; +static void * (*pMSVCRTD_operator_new_dbg)(size_t, int, const char *, int) = NULL; /* Some exports are only available in later versions */ #define SETNOFAIL(x,y) x = (void*)GetProcAddress(hModule,y) diff --git a/dlls/msvfw32/drawdib.c b/dlls/msvfw32/drawdib.c index 902f0ca0664..9877e628bc7 100644 --- a/dlls/msvfw32/drawdib.c +++ b/dlls/msvfw32/drawdib.c @@ -72,7 +72,7 @@ static WINE_HDD* MSVIDEO_GetHddPtr(HDRAWDIB hd) return hdd; } -static DWORD HDD_HandleRef = 1; +static UINT_PTR HDD_HandleRef = 1; /*********************************************************************** * DrawDibOpen [MSVFW32.@] diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 0475bd90697..33918ca5d4b 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1004,7 +1004,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz status = map_view( &view, base, total_size, mask, FALSE, VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY | VPROT_IMAGE ); - if (status == STATUS_CONFLICTING_ADDRESSES) + if (status != STATUS_SUCCESS) status = map_view( &view, NULL, total_size, mask, FALSE, VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY | VPROT_IMAGE ); diff --git a/dlls/ole32/tests/clipboard.c b/dlls/ole32/tests/clipboard.c index f06a4823ac0..a6229a18fc2 100644 --- a/dlls/ole32/tests/clipboard.c +++ b/dlls/ole32/tests/clipboard.c @@ -735,7 +735,7 @@ static void test_cf_dataobject(IDataObject *data) DVTARGETDEVICE *target; ok(fmt_ptr->fmt.ptd != NULL, "target device offset zero\n"); - target = (DVTARGETDEVICE*)((char*)priv + (DWORD)fmt_ptr->fmt.ptd); + target = (DVTARGETDEVICE*)((char*)priv + (DWORD_PTR)fmt_ptr->fmt.ptd); ok(!memcmp(target, fmt.ptd, fmt.ptd->tdSize), "target devices differ\n"); CoTaskMemFree(fmt.ptd); } diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index 7363f30f735..d9d684d52b9 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -253,6 +253,13 @@ static void test_CoCreateInstance(void) OleInitialize(NULL); hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk); + if(hr == REGDB_E_CLASSNOTREG) + { + skip("IE not installed so can't test CoCreateInstance\n"); + OleUninitialize(); + return; + } + ok_ole_success(hr, "CoCreateInstance"); if(pUnk) IUnknown_Release(pUnk); OleUninitialize(); @@ -325,8 +332,13 @@ static void test_CoGetClassObject(void) pUnk = (IUnknown *)0xdeadbeef; hr = CoGetClassObject(rclsid, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk); - ok(hr == S_OK, "CoGetClassObject should have returned S_OK instead of 0x%08x\n", hr); - if (pUnk) IUnknown_Release(pUnk); + if(hr == REGDB_E_CLASSNOTREG) + skip("IE not installed so can't test CoGetClassObject\n"); + else + { + ok(hr == S_OK, "CoGetClassObject should have returned S_OK instead of 0x%08x\n", hr); + if (pUnk) IUnknown_Release(pUnk); + } SetEvent(info.stop); WaitForSingleObject(thread, INFINITE); @@ -1030,7 +1042,7 @@ static void test_CoFreeUnusedLibraries(void) hr = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void **)&pUnk); if (hr == REGDB_E_CLASSNOTREG) { - trace("IE not installed so can't run CoFreeUnusedLibraries test\n"); + skip("IE not installed so can't run CoFreeUnusedLibraries test\n"); CoUninitialize(); return; } diff --git a/dlls/ole32/tests/usrmarshal.c b/dlls/ole32/tests/usrmarshal.c index 2b7103cf972..fde0034ab5b 100644 --- a/dlls/ole32/tests/usrmarshal.c +++ b/dlls/ole32/tests/usrmarshal.c @@ -145,7 +145,7 @@ static void test_marshal_HWND(void) HWND_UserMarshal(&umcb.Flags, buffer, &hwnd); wirehwnd = (wireHWND)buffer; ok(wirehwnd->fContext == WDT_INPROC_CALL, "Context should be WDT_INPROC_CALL instead of 0x%08x\n", wirehwnd->fContext); - ok(wirehwnd->u.hInproc == (LONG_PTR)hwnd, "Marshaled value should be %p instead of %p\n", hwnd, (HANDLE)wirehwnd->u.hRemote); + ok(wirehwnd->u.hInproc == (LONG_PTR)hwnd, "Marshaled value should be %p instead of %x\n", hwnd, wirehwnd->u.hRemote); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); HWND_UserUnmarshal(&umcb.Flags, buffer, &hwnd2); diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c index 46fba8b9213..f180f42f8ca 100644 --- a/dlls/ole32/usrmarshal.c +++ b/dlls/ole32/usrmarshal.c @@ -307,7 +307,7 @@ static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffe RemotableHandle *remhandle = (RemotableHandle *)pBuffer; if (remhandle->fContext != WDT_INPROC_CALL) RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); - *handle = (HANDLE)remhandle->u.hInproc; + *handle = (HANDLE)(LONG_PTR)remhandle->u.hInproc; return pBuffer + sizeof(RemotableHandle); } diff --git a/dlls/oleaut32/Makefile.in b/dlls/oleaut32/Makefile.in index cbc1ca12403..5d41598b179 100644 --- a/dlls/oleaut32/Makefile.in +++ b/dlls/oleaut32/Makefile.in @@ -8,6 +8,7 @@ IMPORTS = uuid ole32 rpcrt4 user32 gdi32 advapi32 kernel32 ntdll DELAYIMPORTS = comctl32 urlmon EXTRADEFS = -D_OLEAUT32_ -DCOM_NO_WINDOWS_H \ -DENTRY_PREFIX=OLEAUTPS_ -DPROXY_CLSID=CLSID_PSDispatch -DPROXY_DELEGATION -DREGISTER_PROXY_DLL +EXTRAINCL = @PNGINCL@ C_SRCS = \ connpt.c \ diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 1c1cfef6b2e..6a07a49caaf 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -1326,7 +1326,9 @@ static void test_dump_typelib(const char *name) expect_int(desc->callconv, fn_info->callconv); expect_int(desc->cParams, fn_info->cParams); expect_int(desc->cParamsOpt, fn_info->cParamsOpt); - expect_int(desc->oVft, fn_info->vtbl_index * sizeof(void*)); + ok( desc->oVft == fn_info->vtbl_index * sizeof(void*) || + broken(desc->oVft == fn_info->vtbl_index * 4), /* xp64 */ + "desc->oVft got %u\n", desc->oVft ); expect_int(desc->cScodes, fn_info->cScodes); expect_int(desc->wFuncFlags, fn_info->wFuncFlags); ole_check(ITypeInfo_GetNames(typeinfo, desc->memid, namesTab, 256, &cNames)); diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index f0a6deb7326..662c0a04058 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -5468,7 +5468,7 @@ static void test_VarCat(void) hres = VarCat(&left,&right,&result); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, - "VarCat: NUMBER concat with NUMBER returned inncorrect result\n"); + "VarCat: NUMBER concat with NUMBER returned incorrect result\n"); VariantClear(&left); VariantClear(&right); @@ -5482,7 +5482,7 @@ static void test_VarCat(void) hres = VarCat(&left,&right,&result); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, - "VarCat: NUMBER concat with VT_BSTR, inncorrect result\n"); + "VarCat: NUMBER concat with VT_BSTR, incorrect result\n"); VariantClear(&left); VariantClear(&right); @@ -5495,7 +5495,7 @@ static void test_VarCat(void) hres = VarCat(&left,&right,&result); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, - "VarCat: VT_BSTR concat with NUMBER, inncorrect result\n"); + "VarCat: VT_BSTR concat with NUMBER, incorrect result\n"); VariantClear(&left); VariantClear(&right); @@ -5512,7 +5512,7 @@ static void test_VarCat(void) hres = VarCat(&left,&right,&result); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, - "VarCat: VT_BSTR concat with VT_DATE returned inncorrect result\n"); + "VarCat: VT_BSTR concat with VT_DATE returned incorrect result\n"); VariantClear(&left); VariantClear(&right); @@ -5528,7 +5528,7 @@ static void test_VarCat(void) hres = VarCat(&left,&right,&result); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); ok(VarCmp(&result,&expected,lcid,0) == VARCMP_EQ, - "VarCat: VT_DATE concat with VT_BSTR returned inncorrect result\n"); + "VarCat: VT_DATE concat with VT_BSTR returned incorrect result\n"); VariantClear(&left); VariantClear(&right); diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 909cf8a830c..37965f8ed53 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -3009,7 +3009,7 @@ HRESULT WINAPI VarAnd(LPVARIANT left, LPVARIANT right, LPVARIANT result) { /* * Special cases for when left variant is VT_NULL - * (NULL & 0 = NULL, NULL & value = value) + * (VT_NULL & 0 = VT_NULL, VT_NULL & value = value) */ if (leftvt == VT_NULL) { diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 7235b280885..752ac871e5b 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -88,17 +88,24 @@ my %cat_1_0 = ( "display-list" => 1, "pixel-op" => 1, "pixel-rw" => 1, "state-req" => 1, - "xform" => 1 ); + "xform" => 1, + "VERSION_1_0" => 1, + "VERSION_1_0_DEPRECATED" => 1 ); my %cat_1_1 = ( %cat_1_0, - "1_1" => 1 ); + "VERSION_1_1" => 1, + "VERSION_1_1_DEPRECATED" => 1 ); my %cat_1_2 = ( %cat_1_1, - "VERSION_1_2" => 1 ); + "VERSION_1_2" => 1, + "VERSION_1_2_DEPRECATED" => 1 ); my %cat_1_3 = ( %cat_1_2, - "VERSION_1_3" => 1 ); + "VERSION_1_3" => 1, + "VERSION_1_3_DEPRECATED" => 1 ); my %cat_1_4 = ( %cat_1_3, - "VERSION_1_4" => 1 ); + "VERSION_1_4" => 1, + "VERSION_1_4_DEPRECATED" => 1 ); my %cat_1_5 = ( %cat_1_4, - "VERSION_1_5" => 1 ); + "VERSION_1_5" => 1, + "VERSION_1_5_DEPRECATED" => 1 ); my %norm_categories = (); @@ -130,7 +137,9 @@ my %debug_conv = "GLhandleARB" => "%d", "GLcharARB" => "%c", "GLvoid" => "(void)", - "_GLfuncptr" => "%p"); + "_GLfuncptr" => "%p", + "UINT64" => "%s,wine_dbgstr_longlong(%s)" + ); # # This hash table gives the conversion between OpenGL types and what @@ -215,6 +224,7 @@ sub GenerateThunk($$$$$) my ($func_ref, $comment, $prefix, $thread_safe, $local_var) = @_; my $ret = ""; my $call_arg = ""; + my $trace_call_arg = ""; my $trace_arg = ""; return "" if $func_ref->[0] eq "glGetString"; @@ -235,20 +245,32 @@ sub GenerateThunk($$$$$) ## print $func_ref->[2]->[$i]->[1] . "\n"; my $type = $func_ref->[2]->[$i]->[0]; my $name = ConvertVarName($func_ref->[2]->[$i]->[1]); - $ret = $ret . ConvertType($type) . " $name"; - $call_arg = "$call_arg$name"; + $ret .= ConvertType($type) . " $name"; + $call_arg .= $name; if ($type =~ /\*/) { - $trace_arg = "$trace_arg\%p"; + $trace_arg .= "%p"; + $trace_call_arg .= $name; } else { - $trace_arg = "$trace_arg$debug_conv{$type}"; + if ($debug_conv{$type} =~ /(.*),(.*)/) + { + $trace_arg .= $1; + $trace_call_arg .= sprintf $2, $name; + } + else + { + $trace_arg .= $debug_conv{$type}; + $trace_call_arg .= $name; + } } if ($i+1 < @{$func_ref->[2]}) { - $ret = "$ret, "; - $call_arg = "$call_arg, "; - $trace_arg = "$trace_arg, "; + $ret .= ", "; + $call_arg .= ", "; + $trace_call_arg .= ", "; + $trace_arg .= ", "; } else { - $ret = "$ret "; - $call_arg = "$call_arg "; + $ret .= " "; + $call_arg .= " "; + $trace_call_arg .= " "; } } $ret .= 'void ' if (!@{$func_ref->[2]}); @@ -260,7 +282,7 @@ sub GenerateThunk($$$$$) if ($gen_traces) { $ret = "$ret TRACE(\"($trace_arg)\\n\""; if ($trace_arg ne "") { - $ret = "$ret, $call_arg"; + $ret .= ", $trace_call_arg"; } $ret = "$ret);\n"; } diff --git a/dlls/opengl32/opengl_ext.c b/dlls/opengl32/opengl_ext.c index ae12241aa7a..81cc1d2969b 100644 --- a/dlls/opengl32/opengl_ext.c +++ b/dlls/opengl32/opengl_ext.c @@ -8730,7 +8730,7 @@ static void WINAPI wine_glPolygonOffsetEXT( GLfloat factor, GLfloat bias ) { static void WINAPI wine_glPresentFrameDualFillNV( GLuint video_slot, UINT64 minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3 ) { void (*func_glPresentFrameDualFillNV)( GLuint, UINT64, GLuint, GLuint, GLenum, GLenum, GLuint, GLenum, GLuint, GLenum, GLuint, GLenum, GLuint ) = extension_funcs[EXT_glPresentFrameDualFillNV]; - TRACE("(%d, %lld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\n", video_slot, minPresentTime, beginPresentTimeId, presentDurationId, type, target0, fill0, target1, fill1, target2, fill2, target3, fill3 ); + TRACE("(%d, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\n", video_slot, wine_dbgstr_longlong(minPresentTime), beginPresentTimeId, presentDurationId, type, target0, fill0, target1, fill1, target2, fill2, target3, fill3 ); ENTER_GL(); func_glPresentFrameDualFillNV( video_slot, minPresentTime, beginPresentTimeId, presentDurationId, type, target0, fill0, target1, fill1, target2, fill2, target3, fill3 ); LEAVE_GL(); @@ -8738,7 +8738,7 @@ static void WINAPI wine_glPresentFrameDualFillNV( GLuint video_slot, UINT64 minP static void WINAPI wine_glPresentFrameKeyedNV( GLuint video_slot, UINT64 minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1 ) { void (*func_glPresentFrameKeyedNV)( GLuint, UINT64, GLuint, GLuint, GLenum, GLenum, GLuint, GLuint, GLenum, GLuint, GLuint ) = extension_funcs[EXT_glPresentFrameKeyedNV]; - TRACE("(%d, %lld, %d, %d, %d, %d, %d, %d, %d, %d, %d)\n", video_slot, minPresentTime, beginPresentTimeId, presentDurationId, type, target0, fill0, key0, target1, fill1, key1 ); + TRACE("(%d, %s, %d, %d, %d, %d, %d, %d, %d, %d, %d)\n", video_slot, wine_dbgstr_longlong(minPresentTime), beginPresentTimeId, presentDurationId, type, target0, fill0, key0, target1, fill1, key1 ); ENTER_GL(); func_glPresentFrameKeyedNV( video_slot, minPresentTime, beginPresentTimeId, presentDurationId, type, target0, fill0, key0, target1, fill1, key1 ); LEAVE_GL(); diff --git a/dlls/quartz/control.c b/dlls/quartz/control.c index d14e2219b43..9a50737ae91 100644 --- a/dlls/quartz/control.c +++ b/dlls/quartz/control.c @@ -278,6 +278,8 @@ static HRESULT ForwardCmdSeek( PCRITICAL_SECTION crit_sect, IBaseFilter* from, S IPin_Release( pin ); } } + IEnumPins_Release( enumpins ); + if (foundend && allnotimpl) hr = E_NOTIMPL; else diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 2151e435e35..1cb44bcdbcd 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -168,7 +168,7 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to) } -void +static void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor, int *x, int *y, int *height) { diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 00fc38e21ca..278b9aaa843 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2901,7 +2901,7 @@ get_msg_name(UINT msg) return ""; } -void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam) +static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam) { int x,y; ME_DisplayItem *para, *run; @@ -4616,14 +4616,14 @@ static BOOL ME_RegisterEditorClass(HINSTANCE hInstance) return TRUE; } -LRESULT WINAPI REComboWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { +static LRESULT WINAPI REComboWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { /* FIXME: Not implemented */ TRACE("hWnd %p msg %04x (%s) %08lx %08lx\n", hWnd, msg, get_msg_name(msg), wParam, lParam); return DefWindowProcW(hWnd, msg, wParam, lParam); } -LRESULT WINAPI REListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { +static LRESULT WINAPI REListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { /* FIXME: Not implemented */ TRACE("hWnd %p msg %04x (%s) %08lx %08lx\n", hWnd, msg, get_msg_name(msg), wParam, lParam); diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 8568420dedd..0929e828497 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -171,9 +171,6 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor); BOOL ME_ArrowKey(ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl); -void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para); -void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor, - int *x, int *y, int *height); int ME_GetCursorOfs(ME_TextEditor *editor, int nCursor); void ME_GetSelection(ME_TextEditor *editor, int *from, int *to); int ME_CountParagraphsBetween(ME_TextEditor *editor, int from, int to); diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c index fa1ef79c9f0..b6a6f44f255 100644 --- a/dlls/riched20/reader.c +++ b/dlls/riched20/reader.c @@ -226,10 +226,6 @@ void RTFInit(RTF_Info *info) info->rtfTextBuf[0] = info->pushedTextBuf[0] = '\0'; } - heap_free (info->inputName); - heap_free (info->outputName); - info->inputName = info->outputName = NULL; - for (i = 0; i < rtfMaxClass; i++) RTFSetClassCallback (info, i, NULL); for (i = 0; i < rtfMaxDestination; i++) @@ -278,39 +274,6 @@ void RTFInit(RTF_Info *info) } /* - * Set or get the input or output file name. These are never guaranteed - * to be accurate, only insofar as the calling program makes them so. - */ - -void RTFSetInputName(RTF_Info *info, const char *name) -{ - info->inputName = RTFStrSave (name); - if (info->inputName == NULL) - ERR ("RTFSetInputName: out of memory\n"); -} - - -char *RTFGetInputName(const RTF_Info *info) -{ - return (info->inputName); -} - - -void RTFSetOutputName(RTF_Info *info, const char *name) -{ - info->outputName = RTFStrSave (name); - if (info->outputName == NULL) - ERR ("RTFSetOutputName: out of memory\n"); -} - - -char *RTFGetOutputName(const RTF_Info *info) -{ - return (info->outputName); -} - - -/* * Install or return a writer callback for a destination type */ @@ -483,14 +446,6 @@ static void RTFUngetToken(RTF_Info *info) } -int RTFPeekToken(RTF_Info *info) -{ - _RTFGetToken (info); - RTFUngetToken (info); - return (info->rtfClass); -} - - static void _RTFGetToken(RTF_Info *info) { if (info->rtfFormat == SF_TEXT) @@ -795,29 +750,6 @@ static int GetChar(RTF_Info *info) } -/* - * Synthesize a token by setting the global variables to the - * values supplied. Typically this is followed with a call - * to RTFRouteToken(). - * - * If a param value other than rtfNoParam is passed, it becomes - * part of the token text. - */ - -static void RTFSetToken(RTF_Info *info, int class, int major, int minor, int param, const char *text) -{ - info->rtfClass = class; - info->rtfMajor = major; - info->rtfMinor = minor; - info->rtfParam = param; - if (param == rtfNoParam) - lstrcpyA(info->rtfTextBuf, text); - else - sprintf (info->rtfTextBuf, "%s%d", text, param); - info->rtfTextLen = lstrlenA (info->rtfTextBuf); -} - - /* ---------------------------------------------------------------------- */ /* @@ -1281,22 +1213,6 @@ static void ReadObjGroup(RTF_Info *info) * References to style 0 are mapped onto the Normal style. */ - -static RTFStyle *RTFGetStyle(const RTF_Info *info, int num) -{ - RTFStyle *s; - - if (num == -1) - return (info->styleList); - for (s = info->styleList; s != NULL; s = s->rtfNextStyle) - { - if (s->rtfSNum == num) - break; - } - return (s); /* NULL if not found */ -} - - RTFFont *RTFGetFont(const RTF_Info *info, int num) { RTFFont *f; @@ -1329,59 +1245,6 @@ RTFColor *RTFGetColor(const RTF_Info *info, int num) /* ---------------------------------------------------------------------- */ - -/* - * Expand style n, if there is such a style. - */ - -void RTFExpandStyle(RTF_Info *info, int n) -{ - RTFStyle *s; - RTFStyleElt *se; - - if (n == -1) - return; - s = RTFGetStyle (info, n); - if (s == NULL) - return; - if (s->rtfExpanding != 0) - ERR ("Style expansion loop, style %d\n", n); - s->rtfExpanding = 1; /* set expansion flag for loop detection */ - /* - * Expand "based-on" style (unless it's the same as the current - * style -- Normal style usually gives itself as its own based-on - * style). Based-on style expansion is done by synthesizing - * the token that the writer needs to see in order to trigger - * another style expansion, and feeding to token back through - * the router so the writer sees it. - */ - if (n != s->rtfSBasedOn) - { - RTFSetToken (info, rtfControl, rtfParAttr, rtfStyleNum, - s->rtfSBasedOn, "\\s"); - RTFRouteToken (info); - } - /* - * Now route the tokens unique to this style. RTFSetToken() - * isn't used because it would add the param value to the end - * of the token text, which already has it in. - */ - for (se = s->rtfSSEList; se != NULL; se = se->rtfNextSE) - { - info->rtfClass = se->rtfSEClass; - info->rtfMajor = se->rtfSEMajor; - info->rtfMinor = se->rtfSEMinor; - info->rtfParam = se->rtfSEParam; - lstrcpyA (info->rtfTextBuf, se->rtfSEText); - info->rtfTextLen = lstrlenA (info->rtfTextBuf); - RTFRouteToken (info); - } - s->rtfExpanding = 0; /* done - clear expansion flag */ -} - - -/* ---------------------------------------------------------------------- */ - /* * Control symbol lookup routines */ @@ -2434,14 +2297,6 @@ int RTFCharToHex(char c) } -int RTFHexToChar(int i) -{ - if (i < 10) - return (i + '0'); - return (i - 10 + 'a'); -} - - /* ---------------------------------------------------------------------- */ /* diff --git a/dlls/riched20/rtf.h b/dlls/riched20/rtf.h index 6de440fe547..3277301b3a2 100644 --- a/dlls/riched20/rtf.h +++ b/dlls/riched20/rtf.h @@ -1152,9 +1152,6 @@ struct _RTF_Info { int unicodeLength; /* The length of ANSI representation of Unicode characters */ int codePage; /* Current codepage for text conversion */ - char *inputName; - char *outputName; - ME_InStream *stream; ME_TextEditor *editor; @@ -1191,26 +1188,19 @@ struct _RTF_Info { void RTFInit (RTF_Info *); void RTFDestroy(RTF_Info *info); -void RTFSetInputName (RTF_Info *, const char *); -char *RTFGetInputName (const RTF_Info *); -void RTFSetOutputName (RTF_Info *, const char *); -char *RTFGetOutputName (const RTF_Info *); void RTFSetDestinationCallback (RTF_Info *, int, RTFFuncPtr); void RTFRead (RTF_Info *); int RTFGetToken (RTF_Info *); /* writer should rarely need this */ -int RTFPeekToken (RTF_Info *); void RTFSetReadHook (RTF_Info *, RTFFuncPtr); void RTFRouteToken (RTF_Info *); void RTFSkipGroup (RTF_Info *); void RTFReadGroup (RTF_Info *); -void RTFExpandStyle (RTF_Info *, int); int RTFCheckCM (const RTF_Info *, int, int); int RTFCheckCMM (const RTF_Info *, int, int, int); int RTFCheckMM (const RTF_Info *, int, int); RTFFont *RTFGetFont (const RTF_Info *, int); RTFColor *RTFGetColor (const RTF_Info *, int); int RTFCharToHex ( char); -int RTFHexToChar ( int ); void RTFFlushOutputBuffer( RTF_Info *info ); void RTFSetEditStream(RTF_Info *info, ME_InStream *stream); diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index 9778ea95baf..cf6c1fcb10f 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -725,18 +725,6 @@ void ME_CalcRunExtent(ME_Context *c, const ME_Paragraph *para, int startx, ME_Ru } /****************************************************************************** - * ME_MustBeWrapped - * - * This should ensure that the given paragraph is wrapped so that its screen - * row structure may be used. But it doesn't, yet. - */ -void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para) -{ - assert(para->type == diParagraph); - /* FIXME */ -} - -/****************************************************************************** * ME_SetSelectionCharFormat * * Applies a style change, either to a current selection, or to insert cursor diff --git a/dlls/rpcrt4/cproxy.c b/dlls/rpcrt4/cproxy.c index 6c26d181978..f5fb6f383ec 100644 --- a/dlls/rpcrt4/cproxy.c +++ b/dlls/rpcrt4/cproxy.c @@ -112,13 +112,13 @@ struct StublessThunk { int dummy; }; #endif /* __i386__ */ -HRESULT WINAPI StdProxy_Construct(REFIID riid, - LPUNKNOWN pUnkOuter, - const ProxyFileInfo *ProxyInfo, - int Index, - LPPSFACTORYBUFFER pPSFactory, - LPRPCPROXYBUFFER *ppProxy, - LPVOID *ppvObj) +HRESULT StdProxy_Construct(REFIID riid, + LPUNKNOWN pUnkOuter, + const ProxyFileInfo *ProxyInfo, + int Index, + LPPSFACTORYBUFFER pPSFactory, + LPRPCPROXYBUFFER *ppProxy, + LPVOID *ppvObj) { StdProxyImpl *This; const MIDL_STUBLESS_PROXY_INFO *stubless = NULL; @@ -147,11 +147,11 @@ HRESULT WINAPI StdProxy_Construct(REFIID riid, if (stubless) { CInterfaceStubVtbl *svtbl = ProxyInfo->pStubVtblList[Index]; - unsigned long i, count = svtbl->header.DispatchTableCount; + ULONG i, count = svtbl->header.DispatchTableCount; /* Maybe the original vtbl is just modified directly to point at * ObjectStublessClientXXX thunks in real Windows, but I don't like it */ - TRACE("stubless thunks: count=%ld\n", count); + TRACE("stubless thunks: count=%d\n", count); This->thunks = HeapAlloc(GetProcessHeap(),0,sizeof(struct StublessThunk)*count); This->PVtbl = HeapAlloc(GetProcessHeap(),0,sizeof(LPVOID)*count); for (i=0; iVtbl[i] == (LPVOID)-1) { PFORMAT_STRING fs = stubless->ProcFormatString + stubless->FormatStringOffset[i]; unsigned bytes = *(const WORD*)(fs+8) - STACK_ADJUST; - TRACE("method %ld: stacksize=%d\n", i, bytes); + TRACE("method %d: stacksize=%d\n", i, bytes); FILL_STUBLESS(thunk, i, bytes) This->PVtbl[i] = thunk; } @@ -172,6 +172,7 @@ HRESULT WINAPI StdProxy_Construct(REFIID riid, else This->PVtbl = vtbl->Vtbl; + if (!pUnkOuter) pUnkOuter = (IUnknown *)This; This->lpVtbl = &StdProxy_Vtbl; /* one reference for the proxy */ This->RefCount = 1; @@ -183,11 +184,7 @@ HRESULT WINAPI StdProxy_Construct(REFIID riid, This->pChannel = NULL; *ppProxy = (LPRPCPROXYBUFFER)&This->lpVtbl; *ppvObj = &This->PVtbl; - /* if there is no outer unknown then the caller will control the lifetime - * of the proxy object through the proxy buffer, so no need to increment the - * ref count of the proxy object */ - if (pUnkOuter) - IUnknown_AddRef((IUnknown *)*ppvObj); + IUnknown_AddRef((IUnknown *)*ppvObj); IPSFactoryBuffer_AddRef(pPSFactory); return S_OK; diff --git a/dlls/rpcrt4/cpsf.h b/dlls/rpcrt4/cpsf.h index d8867d40e60..9b401b8d806 100644 --- a/dlls/rpcrt4/cpsf.h +++ b/dlls/rpcrt4/cpsf.h @@ -21,28 +21,17 @@ #ifndef __WINE_CPSF_H #define __WINE_CPSF_H -HRESULT WINAPI StdProxy_Construct(REFIID riid, - LPUNKNOWN pUnkOuter, - const ProxyFileInfo *ProxyInfo, - int Index, - LPPSFACTORYBUFFER pPSFactory, - LPRPCPROXYBUFFER *ppProxy, - LPVOID *ppvObj); - -HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid, - LPUNKNOWN pUnkServer, - PCInterfaceName name, - CInterfaceStubVtbl *vtbl, - LPPSFACTORYBUFFER pPSFactory, - LPRPCSTUBBUFFER *ppStub); - -HRESULT WINAPI CStdStubBuffer_Delegating_Construct(REFIID riid, - LPUNKNOWN pUnkServer, - PCInterfaceName name, - CInterfaceStubVtbl *vtbl, - REFIID delegating_iid, - LPPSFACTORYBUFFER pPSFactory, - LPRPCSTUBBUFFER *ppStub); +HRESULT StdProxy_Construct(REFIID riid, LPUNKNOWN pUnkOuter, const ProxyFileInfo *ProxyInfo, + int Index, LPPSFACTORYBUFFER pPSFactory, LPRPCPROXYBUFFER *ppProxy, + LPVOID *ppvObj); + +HRESULT CStdStubBuffer_Construct(REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name, + CInterfaceStubVtbl *vtbl, LPPSFACTORYBUFFER pPSFactory, + LPRPCSTUBBUFFER *ppStub); + +HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name, + CInterfaceStubVtbl *vtbl, REFIID delegating_iid, + LPPSFACTORYBUFFER pPSFactory, LPRPCSTUBBUFFER *ppStub); const MIDL_SERVER_INFO *CStdStubBuffer_GetServerInfo(IRpcStubBuffer *iface); diff --git a/dlls/rpcrt4/cstub.c b/dlls/rpcrt4/cstub.c index 9708d188175..aed14329c65 100644 --- a/dlls/rpcrt4/cstub.c +++ b/dlls/rpcrt4/cstub.c @@ -61,12 +61,12 @@ static inline cstdstubbuffer_delegating_t *impl_from_delegating( IRpcStubBuffer return (cstdstubbuffer_delegating_t*)((char *)iface - FIELD_OFFSET(cstdstubbuffer_delegating_t, stub_buffer)); } -HRESULT WINAPI CStdStubBuffer_Construct(REFIID riid, - LPUNKNOWN pUnkServer, - PCInterfaceName name, - CInterfaceStubVtbl *vtbl, - LPPSFACTORYBUFFER pPSFactory, - LPRPCSTUBBUFFER *ppStub) +HRESULT CStdStubBuffer_Construct(REFIID riid, + LPUNKNOWN pUnkServer, + PCInterfaceName name, + CInterfaceStubVtbl *vtbl, + LPPSFACTORYBUFFER pPSFactory, + LPRPCSTUBBUFFER *ppStub) { CStdStubBuffer *This; IUnknown *pvServer; @@ -262,13 +262,13 @@ static void release_delegating_vtbl(IUnknownVtbl *vtbl) LeaveCriticalSection(&delegating_vtbl_section); } -HRESULT WINAPI CStdStubBuffer_Delegating_Construct(REFIID riid, - LPUNKNOWN pUnkServer, - PCInterfaceName name, - CInterfaceStubVtbl *vtbl, - REFIID delegating_iid, - LPPSFACTORYBUFFER pPSFactory, - LPRPCSTUBBUFFER *ppStub) +HRESULT CStdStubBuffer_Delegating_Construct(REFIID riid, + LPUNKNOWN pUnkServer, + PCInterfaceName name, + CInterfaceStubVtbl *vtbl, + REFIID delegating_iid, + LPPSFACTORYBUFFER pPSFactory, + LPRPCSTUBBUFFER *ppStub) { cstdstubbuffer_delegating_t *This; IUnknown *pvServer; diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index 1dfb661cc7d..0d12843d750 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -102,9 +102,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); } while(0) #define STD_OVERFLOW_CHECK(_Msg) do { \ - TRACE("buffer=%d/%d\n", _Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer, _Msg->BufferLength); \ + TRACE("buffer=%d/%d\n", (ULONG)(_Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer), _Msg->BufferLength); \ if (_Msg->Buffer > (unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength) \ - ERR("buffer overflow %d bytes\n", _Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength)); \ + ERR("buffer overflow %d bytes\n", (ULONG)(_Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength))); \ } while (0) #define NDR_POINTER_ID_BASE 0x20000 @@ -1042,6 +1042,8 @@ static ULONG PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, } if (attr & RPC_FC_P_DEREF) { + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void*)); + pStubMsg->MemorySize += sizeof(void*); TRACE("deref\n"); } @@ -1554,10 +1556,14 @@ void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, ULONG WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat) { - /* unsigned size = *(LPWORD)(pFormat+2); */ - FIXME("(%p,%p): stub\n", pStubMsg, pFormat); - PointerMemorySize(pStubMsg, pStubMsg->Buffer, pFormat); - return 0; + unsigned char *Buffer = pStubMsg->Buffer; + if (*pFormat != RPC_FC_RP) + { + ALIGN_POINTER(pStubMsg->Buffer, 4); + safe_buffer_increment(pStubMsg, 4); + } + ALIGN_LENGTH(pStubMsg->MemorySize, 4); + return PointerMemorySize(pStubMsg, Buffer, pFormat); } /*********************************************************************** @@ -3283,7 +3289,7 @@ unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, /* save it for use by embedded pointer code later */ pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength; - TRACE("difference = 0x%x\n", pStubMsg->PointerBufferMark - pStubMsg->Buffer); + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - pStubMsg->Buffer)); pointer_buffer_mark_set = 1; /* restore the original buffer length */ @@ -3369,7 +3375,7 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, /* save it for use by embedded pointer code later */ pStubMsg->PointerBufferMark = pStubMsg->Buffer; - TRACE("difference = 0x%x\n", pStubMsg->PointerBufferMark - saved_buffer); + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - saved_buffer)); pointer_buffer_mark_set = 1; /* restore the original buffer */ @@ -3845,7 +3851,7 @@ unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, /* save it for use by embedded pointer code later */ pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength; - TRACE("difference = 0x%x\n", pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer); + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer)); pointer_buffer_mark_set = 1; /* restore fields */ @@ -3923,7 +3929,7 @@ unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, size = pStubMsg->MemorySize; pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded; - TRACE("difference = 0x%x\n", pStubMsg->Buffer - saved_buffer); + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - saved_buffer)); if (!pStubMsg->PointerBufferMark) { /* save it for use by embedded pointer code later */ @@ -6561,36 +6567,51 @@ static ULONG WINAPI NdrBaseTypeMemorySize( case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); safe_buffer_increment(pStubMsg, sizeof(USHORT)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(USHORT)); pStubMsg->MemorySize += sizeof(USHORT); return sizeof(USHORT); case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG)); safe_buffer_increment(pStubMsg, sizeof(ULONG)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(ULONG)); pStubMsg->MemorySize += sizeof(ULONG); return sizeof(ULONG); case RPC_FC_FLOAT: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(float)); safe_buffer_increment(pStubMsg, sizeof(float)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(float)); pStubMsg->MemorySize += sizeof(float); return sizeof(float); case RPC_FC_DOUBLE: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(double)); safe_buffer_increment(pStubMsg, sizeof(double)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(double)); pStubMsg->MemorySize += sizeof(double); return sizeof(double); case RPC_FC_HYPER: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONGLONG)); safe_buffer_increment(pStubMsg, sizeof(ULONGLONG)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(ULONGLONG)); pStubMsg->MemorySize += sizeof(ULONGLONG); return sizeof(ULONGLONG); case RPC_FC_ERROR_STATUS_T: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(error_status_t)); safe_buffer_increment(pStubMsg, sizeof(error_status_t)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(error_status_t)); pStubMsg->MemorySize += sizeof(error_status_t); return sizeof(error_status_t); case RPC_FC_ENUM16: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); safe_buffer_increment(pStubMsg, sizeof(USHORT)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(UINT)); pStubMsg->MemorySize += sizeof(UINT); return sizeof(UINT); case RPC_FC_IGNORE: + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void *)); pStubMsg->MemorySize += sizeof(void *); return sizeof(void *); default: diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c index d078d69067b..8e8ce169aca 100644 --- a/dlls/rpcrt4/rpc_transport.c +++ b/dlls/rpcrt4/rpc_transport.c @@ -2568,7 +2568,7 @@ static int rpcrt4_ncacn_http_write(RpcConnection *Connection, DWORD bytes_written; BOOL ret; - httpc->last_sent_time = ~0UL; /* disable idle packet sending */ + httpc->last_sent_time = ~0U; /* disable idle packet sending */ ret = InternetWriteFile(httpc->in_request, buffer, count, &bytes_written); httpc->last_sent_time = GetTickCount(); TRACE("%p %p %u -> %s\n", httpc->in_request, buffer, count, ret ? "TRUE" : "FALSE"); diff --git a/dlls/rpcrt4/tests/cstub.c b/dlls/rpcrt4/tests/cstub.c index 69d5ea70e2e..4ef70c28890 100644 --- a/dlls/rpcrt4/tests/cstub.c +++ b/dlls/rpcrt4/tests/cstub.c @@ -613,6 +613,74 @@ static IUnknownVtbl create_stub_test_fail_vtbl = NULL }; +struct dummy_unknown +{ + const IUnknownVtbl *vtbl; + LONG ref; +}; + +static HRESULT WINAPI dummy_QueryInterface(IUnknown *This, REFIID iid, void **ppv) +{ + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI dummy_AddRef(LPUNKNOWN iface) +{ + struct dummy_unknown *this = (struct dummy_unknown *)iface; + return InterlockedIncrement( &this->ref ); +} + +ULONG WINAPI dummy_Release(LPUNKNOWN iface) +{ + struct dummy_unknown *this = (struct dummy_unknown *)iface; + return InterlockedDecrement( &this->ref ); +} + +static IUnknownVtbl dummy_unknown_vtbl = +{ + dummy_QueryInterface, + dummy_AddRef, + dummy_Release +}; +static struct dummy_unknown dummy_unknown = { &dummy_unknown_vtbl, 0 }; + +static void create_proxy_test( IPSFactoryBuffer *ppsf, REFIID iid, const void *expected_vtbl ) +{ + IRpcProxyBuffer *proxy = NULL; + IUnknown *iface = NULL; + HRESULT r; + ULONG count; + + r = IPSFactoryBuffer_CreateProxy(ppsf, NULL, iid, &proxy, (void **)&iface); + ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r ); + ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl ); + count = IUnknown_Release( iface ); + ok( count == 1, "wrong refcount %u\n", count ); + count = IRpcProxyBuffer_Release( proxy ); + ok( count == 0, "wrong refcount %u\n", count ); + + dummy_unknown.ref = 4; + r = IPSFactoryBuffer_CreateProxy(ppsf, (IUnknown *)&dummy_unknown, iid, &proxy, (void **)&iface); + ok( r == S_OK, "IPSFactoryBuffer_CreateProxy failed %x\n", r ); + ok( dummy_unknown.ref == 5, "wrong refcount %u\n", dummy_unknown.ref ); + ok( *(void **)iface == expected_vtbl, "wrong iface pointer %p/%p\n", *(void **)iface, expected_vtbl ); + count = IUnknown_Release( iface ); + ok( count == 4, "wrong refcount %u\n", count ); + ok( dummy_unknown.ref == 4, "wrong refcount %u\n", dummy_unknown.ref ); + count = IRpcProxyBuffer_Release( proxy ); + ok( count == 0, "wrong refcount %u\n", count ); + ok( dummy_unknown.ref == 4, "wrong refcount %u\n", dummy_unknown.ref ); +} + +static void test_CreateProxy( IPSFactoryBuffer *ppsf ) +{ + create_proxy_test( ppsf, &IID_if1, if1_proxy_vtbl.Vtbl ); + create_proxy_test( ppsf, &IID_if2, if2_proxy_vtbl.Vtbl ); + create_proxy_test( ppsf, &IID_if3, if3_proxy_vtbl.Vtbl ); + create_proxy_test( ppsf, &IID_if4, if4_proxy_vtbl.Vtbl ); +} + static void test_CreateStub(IPSFactoryBuffer *ppsf) { IUnknownVtbl *vtbl = &create_stub_test_vtbl; @@ -951,6 +1019,7 @@ START_TEST( cstub ) ppsf = test_NdrDllGetClassObject(); test_NdrStubForwardingFunction(); + test_CreateProxy(ppsf); test_CreateStub(ppsf); test_Connect(ppsf); test_Disconnect(ppsf); diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c index efbec2b438e..a4f8bb4985b 100644 --- a/dlls/rpcrt4/tests/ndr_marshall.c +++ b/dlls/rpcrt4/tests/ndr_marshall.c @@ -127,7 +127,7 @@ static void determine_pointer_marshalling_style(void) NdrPointerMarshall(&StubMsg, (unsigned char*)&ch, fmtstr_up_char); ok(StubMsg.Buffer == StubMsg.BufferStart + 5, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); - use_pointer_ids = (*(unsigned int *)StubMsg.BufferStart != (unsigned int)&ch); + use_pointer_ids = (*(unsigned int *)StubMsg.BufferStart != (UINT_PTR)&ch); trace("Pointer marshalling using %s\n", use_pointer_ids ? "pointer ids" : "pointer value"); HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); @@ -138,7 +138,7 @@ static void test_ndr_simple_type(void) RPC_MESSAGE RpcMessage; MIDL_STUB_MESSAGE StubMsg; MIDL_STUB_DESC StubDesc; - long l, l2 = 0; + LONG l, l2 = 0; StubDesc = Object_StubDesc; StubDesc.pFormatTypes = NULL; @@ -154,28 +154,27 @@ static void test_ndr_simple_type(void) l = 0xcafebabe; NdrSimpleTypeMarshall(&StubMsg, (unsigned char*)&l, 8 /* FC_LONG */); ok(StubMsg.Buffer == StubMsg.BufferStart + 4, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); - ok(*(long*)StubMsg.BufferStart == l, "%ld\n", *(long*)StubMsg.BufferStart); + ok(*(LONG*)StubMsg.BufferStart == l, "%d\n", *(LONG*)StubMsg.BufferStart); StubMsg.Buffer = StubMsg.BufferStart + 1; NdrSimpleTypeMarshall(&StubMsg, (unsigned char*)&l, 8 /* FC_LONG */); ok(StubMsg.Buffer == StubMsg.BufferStart + 8, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); - ok(*(long*)(StubMsg.BufferStart + 4) == l, "%ld\n", *(long*)StubMsg.BufferStart); + ok(*(LONG*)(StubMsg.BufferStart + 4) == l, "%d\n", *(LONG*)StubMsg.BufferStart); StubMsg.Buffer = StubMsg.BufferStart + 1; NdrSimpleTypeUnmarshall(&StubMsg, (unsigned char*)&l2, 8 /* FC_LONG */); ok(StubMsg.Buffer == StubMsg.BufferStart + 8, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart); - ok(l2 == l, "%ld\n", l2); + ok(l2 == l, "%d\n", l2); HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart); } static void test_pointer_marshal(const unsigned char *formattypes, - void *memsrc, - long srcsize, + void *memsrc, DWORD srcsize, const void *wiredata, ULONG wiredatalen, int(*cmp)(const void*,const void*,size_t), - long num_additional_allocs, + int num_additional_allocs, const char *msgpfx) { RPC_MESSAGE RpcMessage; @@ -218,9 +217,6 @@ static void test_pointer_marshal(const unsigned char *formattypes, StubMsg.Buffer = StubMsg.BufferStart; StubMsg.MemorySize = 0; - if (0) - { - /* NdrPointerMemorySize crashes under Wine */ size = NdrPointerMemorySize( &StubMsg, formattypes ); ok(size == StubMsg.MemorySize, "%s: mem size %u size %u\n", msgpfx, StubMsg.MemorySize, size); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); @@ -248,7 +244,6 @@ static void test_pointer_marshal(const unsigned char *formattypes, ok(size == srcsize + 4 + (srcsize == 8 ? 8 : 4), "%s: mem size %u\n", msgpfx, size); else ok(size == srcsize + (srcsize == 8 ? 8 : 4), "%s: mem size %u\n", msgpfx, size); - } size = srcsize; if(formattypes[1] & 0x10) size += 4; @@ -302,21 +297,24 @@ todo_wine { NdrPointerFree(&StubMsg, mem, formattypes); /* again pass address of NULL ptr, but pretend we're a server */ - mem = NULL; - StubMsg.Buffer = StubMsg.BufferStart; - StubMsg.IsClient = 0; - ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 ); - ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); - if (formattypes[2] == 0xd /* FC_ENUM16 */) - ok(mem != StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem points to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); - else - ok(mem == StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem doesn't point to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); - ok(!cmp(mem, memsrc, size), "%s: incorrectly unmarshaled\n", msgpfx); - ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); - ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); - if (formattypes[2] != 0xd /* FC_ENUM16 */) { - ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); - my_alloc_called = 0; + if (0) /* crashes on Win9x and NT4 */ + { + mem = NULL; + StubMsg.Buffer = StubMsg.BufferStart; + StubMsg.IsClient = 0; + ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 ); + ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); + if (formattypes[2] == 0xd /* FC_ENUM16 */) + ok(mem != StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem points to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); + else + ok(mem == StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem doesn't point to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart); + ok(!cmp(mem, memsrc, size), "%s: incorrectly unmarshaled\n", msgpfx); + ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %d\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen); + ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize); + if (formattypes[2] != 0xd /* FC_ENUM16 */) { + ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); + my_alloc_called = 0; + } } } HeapFree(GetProcessHeap(), 0, mem_orig); @@ -336,7 +334,7 @@ static void test_simple_types(void) unsigned char *ch_ptr; unsigned short s; unsigned int i; - unsigned long l; + ULONG l; ULONGLONG ll; float f; double d; @@ -461,7 +459,7 @@ static void test_simple_types(void) if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)ch_ptr; + *(unsigned int *)wiredata = (UINT_PTR)ch_ptr; wiredata[4] = ch; test_pointer_marshal(fmtstr_up_char, ch_ptr, 1, wiredata, 5, NULL, 0, "up_char"); @@ -478,7 +476,7 @@ static void test_simple_types(void) if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)&s; + *(unsigned int *)wiredata = (UINT_PTR)&s; *(unsigned short*)(wiredata + 4) = s; test_pointer_marshal(fmtstr_up_wchar, &s, 2, wiredata, 6, NULL, 0, "up_wchar"); @@ -489,16 +487,16 @@ static void test_simple_types(void) if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)&i; + *(unsigned int *)wiredata = (UINT_PTR)&i; *(unsigned short*)(wiredata + 4) = i; - test_pointer_marshal(fmtstr_up_enum16, &i, 2, wiredata, 6, NULL, 0, "up_enum16"); + test_pointer_marshal(fmtstr_up_enum16, &i, 4, wiredata, 6, NULL, 0, "up_enum16"); l = 0xcafebabe; if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)&l; - *(unsigned long*)(wiredata + 4) = l; + *(unsigned int *)wiredata = (UINT_PTR)&l; + *(ULONG*)(wiredata + 4) = l; test_pointer_marshal(fmtstr_up_long, &l, 4, wiredata, 8, NULL, 0, "up_long"); test_pointer_marshal(fmtstr_up_ulong, &l, 4, wiredata, 8, NULL, 0, "up_ulong"); @@ -509,8 +507,8 @@ static void test_simple_types(void) if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)≪ - *(unsigned int **)(wiredata + 4) = 0; + *(unsigned int *)wiredata = (UINT_PTR)≪ + *(unsigned int *)(wiredata + 4) = 0; *(ULONGLONG*)(wiredata + 8) = ll; test_pointer_marshal(fmtstr_up_longlong, &ll, 8, wiredata, 16, NULL, 0, "up_longlong"); @@ -518,7 +516,7 @@ static void test_simple_types(void) if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)&f; + *(unsigned int *)wiredata = (UINT_PTR)&f; *(float*)(wiredata + 4) = f; test_pointer_marshal(fmtstr_up_float, &f, 4, wiredata, 8, NULL, 0, "up_float"); @@ -526,7 +524,7 @@ static void test_simple_types(void) if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)&d; + *(unsigned int *)wiredata = (UINT_PTR)&d; *(unsigned int *)(wiredata + 4) = 0; *(double*)(wiredata + 8) = d; test_pointer_marshal(fmtstr_up_double, &d, 8, wiredata, 16, NULL, 0, "up_double"); @@ -690,12 +688,11 @@ static void test_nontrivial_pointer_types(void) } static void test_simple_struct_marshal(const unsigned char *formattypes, - void *memsrc, - long srcsize, + void *memsrc, DWORD srcsize, const void *wiredata, ULONG wiredatalen, int(*cmp)(const void*,const void*,size_t), - long num_additional_allocs, + int num_additional_allocs, const char *msgpfx) { RPC_MESSAGE RpcMessage; @@ -724,9 +721,6 @@ static void test_simple_struct_marshal(const unsigned char *formattypes, ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart); ok(!memcmp(StubMsg.BufferStart, wiredata, wiredatalen), "%s: incorrectly marshaled %08x %08x %08x\n", msgpfx, *(DWORD*)StubMsg.BufferStart,*((DWORD*)StubMsg.BufferStart+1),*((DWORD*)StubMsg.BufferStart+2)); - if (0) - { - /* FIXME: Causes Wine to crash */ StubMsg.Buffer = StubMsg.BufferStart; StubMsg.MemorySize = 0; size = NdrSimpleStructMemorySize( &StubMsg, formattypes ); @@ -736,12 +730,9 @@ static void test_simple_struct_marshal(const unsigned char *formattypes, StubMsg.Buffer = StubMsg.BufferStart; size = NdrSimpleStructMemorySize( &StubMsg, formattypes ); -todo_wine { ok(size == StubMsg.MemorySize, "%s: size != MemorySize\n", msgpfx); -} ok(StubMsg.MemorySize == ((srcsize + 3) & ~3) + srcsize, "%s: mem size %u\n", msgpfx, size); ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart); - } size = srcsize; /*** Unmarshalling first with must_alloc false ***/ @@ -772,16 +763,19 @@ todo_wine { Passing a NULL ptr while we're a client && !must_alloc crashes on Windows, so we won't do that. */ - mem = NULL; - StubMsg.IsClient = 0; - StubMsg.Buffer = StubMsg.BufferStart; - ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 0 ); - ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); - ok(mem == StubMsg.BufferStart, "%s: mem not equal buffer\n", msgpfx); - ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); - ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); - my_alloc_called = 0; - ok(StubMsg.MemorySize == 0, "%s: memorysize touched in unmarshal\n", msgpfx); + if (0) /* crashes on Win9x and NT4 */ + { + mem = NULL; + StubMsg.IsClient = 0; + StubMsg.Buffer = StubMsg.BufferStart; + ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, FALSE ); + ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr); + ok(mem == StubMsg.BufferStart, "%s: mem not equal buffer\n", msgpfx); + ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx); + ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called); + my_alloc_called = 0; + ok(StubMsg.MemorySize == 0, "%s: memorysize touched in unmarshal\n", msgpfx); + } /*** now must_alloc is true ***/ @@ -839,8 +833,8 @@ todo_wine { typedef struct { - long l1; - long *pl1; + LONG l1; + LONG *pl1; char *pc1; } ps1_t; @@ -876,8 +870,8 @@ static int ps1_cmp(const void *s1, const void *s2, size_t num) static void test_simple_struct(void) { unsigned char wiredata[28]; - unsigned long wiredatalen; - long l; + ULONG wiredatalen; + LONG l; char c; ps1_t ps1; @@ -899,7 +893,7 @@ static void test_simple_struct(void) struct { short s; char c; - long l1, l2; + LONG l1, l2; LONGLONG ll; } s1; @@ -951,13 +945,9 @@ static void test_simple_struct(void) if (use_pointer_ids) *(unsigned int *)wiredata = 0x20000; else - *(unsigned int *)wiredata = (unsigned int)&s1; + *(unsigned int *)wiredata = (UINT_PTR)&s1; memcpy(wiredata + 4, &s1, wiredatalen); - if (0) - { - /* one of the unmarshallings crashes Wine */ test_pointer_marshal(fmtstr_simple_struct, &s1, 24, wiredata, 28, NULL, 0, "struct"); - } /* zero the entire structure, including the hole */ memset(&ps1, 0, sizeof(ps1)); @@ -976,22 +966,22 @@ static void test_simple_struct(void) } else { - *(unsigned int *)(wiredata + 8) = (unsigned int)&l; - *(unsigned int *)(wiredata + 12) = (unsigned int)&c; + *(unsigned int *)(wiredata + 8) = (UINT_PTR)&l; + *(unsigned int *)(wiredata + 12) = (UINT_PTR)&c; } memcpy(wiredata + 16, &l, 4); memcpy(wiredata + 20, &c, 1); test_simple_struct_marshal(fmtstr_pointer_struct + 4, &ps1, 17, wiredata + 4, 17, ps1_cmp, 2, "pointer_struct"); if (use_pointer_ids) + { *(unsigned int *)wiredata = 0x20000; + *(unsigned int *)(wiredata + 8) = 0x20004; + *(unsigned int *)(wiredata + 12) = 0x20008; + } else - *(unsigned int *)wiredata = (unsigned int)&ps1; - if (0) - { - /* one of the unmarshallings crashes Wine */ + *(unsigned int *)wiredata = (UINT_PTR)&ps1; test_pointer_marshal(fmtstr_pointer_struct, &ps1, 17, wiredata, 21, ps1_cmp, 2, "pointer_struct"); - } } static void test_fullpointer_xlat(void) @@ -1120,95 +1110,84 @@ static void test_fullpointer_xlat(void) NdrFullPointerXlatFree(pXlatTables); } -static void test_client_init(void) +/* verify stub data that is identical between client and server */ +static void test_common_stub_data( const char *prefix, const MIDL_STUB_MESSAGE *stubMsg ) { - MIDL_STUB_MESSAGE stubMsg; - RPC_MESSAGE rpcMsg; + void *unset_ptr; - memset(&rpcMsg, 0xcc, sizeof(rpcMsg)); - memset(&stubMsg, 0xcc, sizeof(stubMsg)); - - NdrClientInitializeNew(&rpcMsg, &stubMsg, &Object_StubDesc, 1); + memset(&unset_ptr, 0xcc, sizeof(unset_ptr)); -#define TEST_POINTER_UNSET(field) ok(rpcMsg.field == (void *)0xcccccccc, #field " should have been unset instead of %p\n", rpcMsg.field) +#define TEST_ZERO(field, fmt) ok(stubMsg->field == 0, "%s: " #field " should have been set to zero instead of " fmt "\n", prefix, stubMsg->field) +#define TEST_POINTER_UNSET(field) ok(stubMsg->field == unset_ptr, "%s: " #field " should have been unset instead of %p\n", prefix, stubMsg->field) +#define TEST_ULONG_UNSET(field) ok(stubMsg->field == 0xcccccccc, "%s: " #field " should have been unset instead of 0x%x\n", prefix, stubMsg->field) +#define TEST_ULONG_PTR_UNSET(field) ok(stubMsg->field == (ULONG_PTR)unset_ptr, "%s: " #field " should have been unset instead of 0x%lx\n", prefix, stubMsg->field) - ok(rpcMsg.Handle == NULL, "rpcMsg.Handle should have been NULL instead of %p\n", rpcMsg.Handle); - TEST_POINTER_UNSET(Buffer); - ok(rpcMsg.BufferLength == 0xcccccccc, "rpcMsg.BufferLength should have been unset instead of %d\n", rpcMsg.BufferLength); - ok(rpcMsg.ProcNum == 0x8001, "rpcMsg.ProcNum should have been 0x8001 instead of 0x%x\n", rpcMsg.ProcNum); - TEST_POINTER_UNSET(TransferSyntax); - ok(rpcMsg.RpcInterfaceInformation == Object_StubDesc.RpcInterfaceInformation, - "rpcMsg.RpcInterfaceInformation should have been %p instead of %p\n", - Object_StubDesc.RpcInterfaceInformation, rpcMsg.RpcInterfaceInformation); - /* Note: ReservedForRuntime not tested */ - TEST_POINTER_UNSET(ManagerEpv); - TEST_POINTER_UNSET(ImportContext); - ok(rpcMsg.RpcFlags == 0, "rpcMsg.RpcFlags should have been 0 instead of 0x%x\n", rpcMsg.RpcFlags); -#undef TEST_POINTER_UNSET - -#define TEST_ZERO(field, fmt) ok(stubMsg.field == 0, #field " should have been set to zero instead of " fmt "\n", stubMsg.field) -#define TEST_POINTER_UNSET(field) ok(stubMsg.field == (void *)0xcccccccc, #field " should have been unset instead of %p\n", stubMsg.field) -#define TEST_ULONG_UNSET(field) ok(stubMsg.field == 0xcccccccc, #field " should have been unset instead of 0x%x\n", stubMsg.field) -#define TEST_ULONG_PTR_UNSET(field) ok(stubMsg.field == 0xcccccccc, #field " should have been unset instead of 0x%lx\n", stubMsg.field) - - ok(stubMsg.RpcMsg == &rpcMsg, "stubMsg.RpcMsg should have been %p instead of %p\n", &rpcMsg, stubMsg.RpcMsg); - TEST_POINTER_UNSET(Buffer); - TEST_ZERO(BufferStart, "%p"); - TEST_ZERO(BufferEnd, "%p"); TEST_POINTER_UNSET(BufferMark); - TEST_ZERO(BufferLength, "%d"); TEST_ULONG_UNSET(MemorySize); TEST_POINTER_UNSET(Memory); - ok(stubMsg.IsClient == 1, "stubMsg.IsClient should have been 1 instead of %u\n", stubMsg.IsClient); - TEST_ZERO(ReuseBuffer, "%d"); TEST_ZERO(pAllocAllNodesContext, "%p"); - ok(stubMsg.pPointerQueueState == 0 || - broken(stubMsg.pPointerQueueState == (void *)0xcccccccc), /* win2k */ - "stubMsg.pPointerQueueState should have been unset instead of %p\n", stubMsg.pPointerQueueState); + ok(stubMsg->pPointerQueueState == 0 || + broken(stubMsg->pPointerQueueState == unset_ptr), /* win2k */ + "%s: pPointerQueueState should have been unset instead of %p\n", + prefix, stubMsg->pPointerQueueState); TEST_ZERO(IgnoreEmbeddedPointers, "%d"); TEST_ZERO(PointerBufferMark, "%p"); - TEST_ZERO(CorrDespIncrement, "%d"); - TEST_ZERO(uFlags, "%d"); + ok( stubMsg->uFlags == 0 || + broken(stubMsg->uFlags == 0xcc), /* win9x */ + "%s: uFlags should have been set to zero instead of 0x%x\n", prefix, stubMsg->uFlags ); /* FIXME: UniquePtrCount */ TEST_ULONG_PTR_UNSET(MaxCount); TEST_ULONG_UNSET(Offset); TEST_ULONG_UNSET(ActualCount); - ok(stubMsg.pfnAllocate == my_alloc, "stubMsg.pfnAllocate should have been %p instead of %p\n", my_alloc, stubMsg.pfnAllocate); - ok(stubMsg.pfnFree == my_free, "stubMsg.pfnFree should have been %p instead of %p\n", my_free, stubMsg.pfnFree); + ok(stubMsg->pfnAllocate == my_alloc, "%s: pfnAllocate should have been %p instead of %p\n", + prefix, my_alloc, stubMsg->pfnAllocate); + ok(stubMsg->pfnFree == my_free, "%s: pfnFree should have been %p instead of %p\n", + prefix, my_free, stubMsg->pfnFree); TEST_ZERO(StackTop, "%p"); TEST_POINTER_UNSET(pPresentedType); TEST_POINTER_UNSET(pTransmitType); TEST_POINTER_UNSET(SavedHandle); - ok(stubMsg.StubDesc == &Object_StubDesc, "stubMsg.StubDesc should have been %p instead of %p\n", &Object_StubDesc, stubMsg.StubDesc); - TEST_POINTER_UNSET(FullPtrXlatTables); + ok(stubMsg->StubDesc == &Object_StubDesc, "%s: StubDesc should have been %p instead of %p\n", + prefix, &Object_StubDesc, stubMsg->StubDesc); TEST_ZERO(FullPtrRefId, "%d"); - TEST_ZERO(PointerLength, "%d"); + ok( stubMsg->PointerLength == 0 || + broken(stubMsg->PointerLength == 1), /* win9x, nt4 */ + "%s: pAsyncMsg should have been set to zero instead of %d\n", prefix, stubMsg->PointerLength ); TEST_ZERO(fInDontFree, "%d"); TEST_ZERO(fDontCallFreeInst, "%d"); - ok(stubMsg.fInOnlyParam == 0 || - stubMsg.fInOnlyParam == -1, /* Vista */ - "fInOnlyParam should have been set to 0 or -1 instead of %d\n", stubMsg.fInOnlyParam); - TEST_ZERO(fHasReturn, "%d"); + ok(stubMsg->fInOnlyParam == 0 || + stubMsg->fInOnlyParam == -1, /* Vista */ + "%s: fInOnlyParam should have been set to 0 or -1 instead of %d\n", prefix, stubMsg->fInOnlyParam); + ok( stubMsg->fHasReturn == 0 || + broken(stubMsg->fHasReturn == -1), /* win9x, nt4 */ + "%s: fHasReturn should have been set to zero instead of %d\n", prefix, stubMsg->fHasReturn ); TEST_ZERO(fHasExtensions, "%d"); TEST_ZERO(fHasNewCorrDesc, "%d"); - TEST_ZERO(fIsIn, "%d"); - ok(stubMsg.fIsOut == 0 || - stubMsg.fIsOut == -1, /* XP-SP3 */ - "fIsOut should have been set to 0 or -1 instead of %d\n", stubMsg.fIsOut); + ok(stubMsg->fIsIn == 0 || + broken(stubMsg->fIsIn == -1), /* win9x, nt4 */ + "%s: fIsIn should have been set to 0 instead of %d\n", prefix, stubMsg->fIsIn); + ok(stubMsg->fIsOut == 0 || + stubMsg->fIsOut == -1, /* XP-SP3 */ + "%s: fIsOut should have been set to 0 or -1 instead of %d\n", prefix, stubMsg->fIsOut); TEST_ZERO(fIsOicf, "%d"); - trace("NdrClientInitializeNew: fBufferValid = %d\n", stubMsg.fBufferValid); - ok(stubMsg.fHasMemoryValidateCallback == 0 || - stubMsg.fHasMemoryValidateCallback == -1, /* XP-SP3 */ - "fHasMemoryValidateCallback should have been set to 0 or -1 instead of %d\n", stubMsg.fHasMemoryValidateCallback); - ok(stubMsg.fInFree == 0 || - stubMsg.fInFree == -1, /* XP-SP3 */ - "fInFree should have been set to 0 or -1 instead of %d\n", stubMsg.fInFree); + ok(stubMsg->fBufferValid == 0, + "%s: fBufferValid should have been set to 0 instead of %d\n", prefix, stubMsg->fBufferValid); + ok(stubMsg->fHasMemoryValidateCallback == 0 || + stubMsg->fHasMemoryValidateCallback == -1, /* XP-SP3 */ + "%s: fHasMemoryValidateCallback should have been set to 0 or -1 instead of %d\n", + prefix, stubMsg->fHasMemoryValidateCallback); + ok(stubMsg->fInFree == 0 || + stubMsg->fInFree == -1, /* XP-SP3 */ + "%s: fInFree should have been set to 0 or -1 instead of %d\n", prefix, stubMsg->fInFree); TEST_ZERO(fNeedMCCP, "%d"); - ok(stubMsg.fUnused == 0 || - stubMsg.fUnused == -2, /* Vista */ - "fUnused should have been set to 0 or -2 instead of %d\n", stubMsg.fUnused); - ok(stubMsg.fUnused2 == 0xffffcccc, "stubMsg.fUnused2 should have been 0xffffcccc instead of 0x%x\n", stubMsg.fUnused2); - ok(stubMsg.dwDestContext == MSHCTX_DIFFERENTMACHINE, "stubMsg.dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %d\n", stubMsg.dwDestContext); + ok(stubMsg->fUnused == 0 || + stubMsg->fUnused == -2, /* Vista */ + "%s: fUnused should have been set to 0 or -2 instead of %d\n", prefix, stubMsg->fUnused); + ok(stubMsg->fUnused2 == 0xffffcccc, "%s: fUnused2 should have been 0xffffcccc instead of 0x%x\n", + prefix, stubMsg->fUnused2); + ok(stubMsg->dwDestContext == MSHCTX_DIFFERENTMACHINE, + "%s: dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %d\n", + prefix, stubMsg->dwDestContext); TEST_ZERO(pvDestContext, "%p"); TEST_POINTER_UNSET(SavedContextHandles); TEST_ULONG_UNSET(ParamNumber); @@ -1220,25 +1199,77 @@ static void test_client_init(void) TEST_POINTER_UNSET(pArgQueue); TEST_ZERO(dwStubPhase, "%d"); /* FIXME: where does this value come from? */ - trace("LowStackMark is %p\n", stubMsg.LowStackMark); - TEST_ZERO(pAsyncMsg, "%p"); - TEST_ZERO(pCorrInfo, "%p"); - TEST_ZERO(pCorrMemory, "%p"); - TEST_ZERO(pMemoryList, "%p"); + trace("%s: LowStackMark is %p\n", prefix, stubMsg->LowStackMark); + ok( stubMsg->pAsyncMsg == 0 || broken(stubMsg->pAsyncMsg == unset_ptr), /* win9x, nt4 */ + "%s: pAsyncMsg should have been set to zero instead of %p\n", prefix, stubMsg->pAsyncMsg ); + ok( stubMsg->pCorrInfo == 0 || broken(stubMsg->pCorrInfo == unset_ptr), /* win9x, nt4 */ + "%s: pCorrInfo should have been set to zero instead of %p\n", prefix, stubMsg->pCorrInfo ); + ok( stubMsg->pCorrMemory == 0 || broken(stubMsg->pCorrMemory == unset_ptr), /* win9x, nt4 */ + "%s: pCorrMemory should have been set to zero instead of %p\n", prefix, stubMsg->pCorrMemory ); + ok( stubMsg->pMemoryList == 0 || broken(stubMsg->pMemoryList == unset_ptr), /* win9x, nt4 */ + "%s: pMemoryList should have been set to zero instead of %p\n", prefix, stubMsg->pMemoryList ); TEST_POINTER_UNSET(pCSInfo); TEST_POINTER_UNSET(ConformanceMark); TEST_POINTER_UNSET(VarianceMark); - ok(stubMsg.Unused == 0xcccccccc, "Unused should have be unset instead of 0x%lx\n", stubMsg.Unused); + ok(stubMsg->Unused == (ULONG_PTR)unset_ptr, "%s: Unused should have be unset instead of 0x%lx\n", + prefix, stubMsg->Unused); TEST_POINTER_UNSET(pContext); TEST_POINTER_UNSET(ContextHandleHash); TEST_POINTER_UNSET(pUserMarshalList); TEST_ULONG_PTR_UNSET(Reserved51_3); TEST_ULONG_PTR_UNSET(Reserved51_4); TEST_ULONG_PTR_UNSET(Reserved51_5); + +#undef TEST_ULONG_PTR_UNSET #undef TEST_ULONG_UNSET #undef TEST_POINTER_UNSET #undef TEST_ZERO +} + +static void test_client_init(void) +{ + MIDL_STUB_MESSAGE stubMsg; + RPC_MESSAGE rpcMsg; + void *unset_ptr; + + memset(&rpcMsg, 0xcc, sizeof(rpcMsg)); + memset(&stubMsg, 0xcc, sizeof(stubMsg)); + memset(&unset_ptr, 0xcc, sizeof(unset_ptr)); + + NdrClientInitializeNew(&rpcMsg, &stubMsg, &Object_StubDesc, 1); + + test_common_stub_data( "NdrClientInitializeNew", &stubMsg ); + ok(stubMsg.RpcMsg == &rpcMsg, "stubMsg.RpcMsg should have been %p instead of %p\n", &rpcMsg, stubMsg.RpcMsg); + ok(rpcMsg.Handle == NULL, "rpcMsg.Handle should have been NULL instead of %p\n", rpcMsg.Handle); + ok(rpcMsg.Buffer == unset_ptr, "rpcMsg.Buffer should have been unset instead of %p\n", + rpcMsg.Buffer); + ok(rpcMsg.BufferLength == 0xcccccccc, "rpcMsg.BufferLength should have been unset instead of %d\n", rpcMsg.BufferLength); + ok(rpcMsg.ProcNum == 0x8001, "rpcMsg.ProcNum should have been 0x8001 instead of 0x%x\n", rpcMsg.ProcNum); + ok(rpcMsg.TransferSyntax == unset_ptr, "rpcMsg.TransferSyntax should have been unset instead of %p\n", rpcMsg.TransferSyntax); + ok(rpcMsg.RpcInterfaceInformation == Object_StubDesc.RpcInterfaceInformation, + "rpcMsg.RpcInterfaceInformation should have been %p instead of %p\n", + Object_StubDesc.RpcInterfaceInformation, rpcMsg.RpcInterfaceInformation); + /* Note: ReservedForRuntime not tested */ + ok(rpcMsg.ManagerEpv == unset_ptr, "rpcMsg.ManagerEpv should have been unset instead of %p\n", rpcMsg.ManagerEpv); + ok(rpcMsg.ImportContext == unset_ptr, "rpcMsg.ImportContext should have been unset instead of %p\n", rpcMsg.ImportContext); + ok(rpcMsg.RpcFlags == 0, "rpcMsg.RpcFlags should have been 0 instead of 0x%x\n", rpcMsg.RpcFlags); + + ok(stubMsg.Buffer == unset_ptr, "stubMsg.Buffer should have been unset instead of %p\n", + stubMsg.Buffer); + ok(stubMsg.BufferStart == NULL, "stubMsg.BufferStart should have been NULL instead of %p\n", + stubMsg.BufferStart); + ok(stubMsg.BufferEnd == NULL, "stubMsg.BufferEnd should have been NULL instead of %p\n", + stubMsg.BufferEnd); + ok(stubMsg.BufferLength == 0, "stubMsg.BufferLength should have been 0 instead of %u\n", + stubMsg.BufferLength); + ok(stubMsg.IsClient == 1, "stubMsg.IsClient should have been 1 instead of %u\n", stubMsg.IsClient); + ok(stubMsg.ReuseBuffer == 0, "stubMsg.ReuseBuffer should have been 0 instead of %d\n", + stubMsg.ReuseBuffer); + ok(stubMsg.CorrDespIncrement == 0, "stubMsg.CorrDespIncrement should have been 0 instead of %d\n", + stubMsg.CorrDespIncrement); + ok(stubMsg.FullPtrXlatTables == unset_ptr, "stubMsg.FullPtrXlatTables should have been unset instead of %p\n", + stubMsg.FullPtrXlatTables); } static void test_server_init(void) @@ -1258,104 +1289,22 @@ static void test_server_init(void) ret = NdrServerInitializeNew(&rpcMsg, &stubMsg, &Object_StubDesc); ok(ret == NULL, "NdrServerInitializeNew should have returned NULL instead of %p\n", ret); -#define TEST_ZERO(field, fmt) ok(stubMsg.field == 0, #field " should have been set to zero instead of " fmt "\n", stubMsg.field) -#define TEST_POINTER_UNSET(field) ok(stubMsg.field == (void *)0xcccccccc, #field " should have been unset instead of %p\n", stubMsg.field) -#define TEST_ULONG_UNSET(field) ok(stubMsg.field == 0xcccccccc, #field " should have been unset instead of 0x%x\n", stubMsg.field) -#define TEST_ULONG_PTR_UNSET(field) ok(stubMsg.field == 0xcccccccc, #field " should have been unset instead of 0x%lx\n", stubMsg.field) + test_common_stub_data( "NdrServerInitializeNew", &stubMsg ); ok(stubMsg.RpcMsg == &rpcMsg, "stubMsg.RpcMsg should have been %p instead of %p\n", &rpcMsg, stubMsg.RpcMsg); ok(stubMsg.Buffer == buffer, "stubMsg.Buffer should have been %p instead of %p\n", buffer, stubMsg.Buffer); ok(stubMsg.BufferStart == buffer, "stubMsg.BufferStart should have been %p instead of %p\n", buffer, stubMsg.BufferStart); ok(stubMsg.BufferEnd == buffer + sizeof(buffer), "stubMsg.BufferEnd should have been %p instead of %p\n", buffer + sizeof(buffer), stubMsg.BufferEnd); - TEST_POINTER_UNSET(BufferMark); todo_wine - TEST_ZERO(BufferLength, "%d"); - TEST_ULONG_UNSET(MemorySize); - TEST_POINTER_UNSET(Memory); + ok(stubMsg.BufferLength == 0, "stubMsg.BufferLength should have been 0 instead of %u\n", stubMsg.BufferLength); ok(stubMsg.IsClient == 0, "stubMsg.IsClient should have been 0 instead of %u\n", stubMsg.IsClient); ok(stubMsg.ReuseBuffer == 0 || broken(stubMsg.ReuseBuffer == 1), /* win2k */ "stubMsg.ReuseBuffer should have been set to zero instead of %d\n", stubMsg.ReuseBuffer); - TEST_ZERO(pAllocAllNodesContext, "%p"); - ok(stubMsg.pPointerQueueState == 0 || - broken(stubMsg.pPointerQueueState == (void *)0xcccccccc), /* win2k */ - "stubMsg.pPointerQueueState should have been unset instead of %p\n", stubMsg.pPointerQueueState); - TEST_ZERO(IgnoreEmbeddedPointers, "%d"); - TEST_ZERO(PointerBufferMark, "%p"); ok(stubMsg.CorrDespIncrement == 0xcc || stubMsg.CorrDespIncrement == 0, "CorrDespIncrement should have been unset instead of 0x%x\n", stubMsg.CorrDespIncrement); - TEST_ZERO(uFlags, "%d"); - /* FIXME: UniquePtrCount */ - TEST_ULONG_PTR_UNSET(MaxCount); - TEST_ULONG_UNSET(Offset); - TEST_ULONG_UNSET(ActualCount); - ok(stubMsg.pfnAllocate == my_alloc, "stubMsg.pfnAllocate should have been %p instead of %p\n", my_alloc, stubMsg.pfnAllocate); - ok(stubMsg.pfnFree == my_free, "stubMsg.pfnFree should have been %p instead of %p\n", my_free, stubMsg.pfnFree); - TEST_ZERO(StackTop, "%p"); - TEST_POINTER_UNSET(pPresentedType); - TEST_POINTER_UNSET(pTransmitType); - TEST_POINTER_UNSET(SavedHandle); - ok(stubMsg.StubDesc == &Object_StubDesc, "stubMsg.StubDesc should have been %p instead of %p\n", &Object_StubDesc, stubMsg.StubDesc); - TEST_ZERO(FullPtrXlatTables, "%p"); - TEST_ZERO(FullPtrRefId, "%d"); - TEST_ZERO(PointerLength, "%d"); - TEST_ZERO(fInDontFree, "%d"); - TEST_ZERO(fDontCallFreeInst, "%d"); - ok(stubMsg.fInOnlyParam == 0 || - stubMsg.fInOnlyParam == -1, /* Vista */ - "fInOnlyParam should have been set to 0 or -1 instead of %d\n", stubMsg.fInOnlyParam); - TEST_ZERO(fHasReturn, "%d"); - TEST_ZERO(fHasExtensions, "%d"); - TEST_ZERO(fHasNewCorrDesc, "%d"); - TEST_ZERO(fIsIn, "%d"); - ok(stubMsg.fIsOut == 0 || - stubMsg.fIsOut == -1, /* XP-SP3 */ - "fIsOut should have been set to 0 or -1 instead of %d\n", stubMsg.fIsOut); - TEST_ZERO(fIsOicf, "%d"); - trace("NdrServerInitializeNew: fBufferValid = %d\n", stubMsg.fBufferValid); - ok(stubMsg.fHasMemoryValidateCallback == 0 || - stubMsg.fHasMemoryValidateCallback == -1, /* XP-SP3 */ - "fHasMemoryValidateCallback should have been set to 0 or -1 instead of %d\n", stubMsg.fHasMemoryValidateCallback); - ok(stubMsg.fInFree == 0 || - stubMsg.fInFree == -1, /* XP-SP3 */ - "fInFree should have been set to 0 or -1 instead of %d\n", stubMsg.fInFree); - TEST_ZERO(fNeedMCCP, "%d"); - ok(stubMsg.fUnused == 0 || - stubMsg.fUnused == -2, /* Vista */ - "fUnused should have been set to 0 or -2 instead of %d\n", stubMsg.fUnused); - ok(stubMsg.fUnused2 == 0xffffcccc, "stubMsg.fUnused2 should have been 0xffffcccc instead of 0x%x\n", stubMsg.fUnused2); - ok(stubMsg.dwDestContext == MSHCTX_DIFFERENTMACHINE, "stubMsg.dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %d\n", stubMsg.dwDestContext); - TEST_ZERO(pvDestContext, "%p"); - TEST_POINTER_UNSET(SavedContextHandles); - TEST_ULONG_UNSET(ParamNumber); - TEST_ZERO(pRpcChannelBuffer, "%p"); - TEST_ZERO(pArrayInfo, "%p"); - TEST_POINTER_UNSET(SizePtrCountArray); - TEST_POINTER_UNSET(SizePtrOffsetArray); - TEST_POINTER_UNSET(SizePtrLengthArray); - TEST_POINTER_UNSET(pArgQueue); - TEST_ZERO(dwStubPhase, "%d"); - /* FIXME: where does this value come from? */ - trace("LowStackMark is %p\n", stubMsg.LowStackMark); - TEST_ZERO(pAsyncMsg, "%p"); - TEST_ZERO(pCorrInfo, "%p"); - TEST_ZERO(pCorrMemory, "%p"); - TEST_ZERO(pMemoryList, "%p"); - TEST_POINTER_UNSET(pCSInfo); - TEST_POINTER_UNSET(ConformanceMark); - TEST_POINTER_UNSET(VarianceMark); - ok(stubMsg.Unused == 0xcccccccc, "Unused should have be unset instead of 0x%lx\n", stubMsg.Unused); - TEST_POINTER_UNSET(pContext); - TEST_POINTER_UNSET(ContextHandleHash); - TEST_POINTER_UNSET(pUserMarshalList); - TEST_ULONG_PTR_UNSET(Reserved51_3); - TEST_ULONG_PTR_UNSET(Reserved51_4); - TEST_ULONG_PTR_UNSET(Reserved51_5); -#undef TEST_ULONG_UNSET -#undef TEST_POINTER_UNSET -#undef TEST_ZERO - + ok(stubMsg.FullPtrXlatTables == 0, "stubMsg.BufferLength should have been 0 instead of %p\n", stubMsg.FullPtrXlatTables); } static void test_ndr_allocate(void) @@ -1364,12 +1313,6 @@ static void test_ndr_allocate(void) MIDL_STUB_MESSAGE StubMsg; MIDL_STUB_DESC StubDesc; void *p1, *p2; - struct tag_mem_list_v1_t - { - DWORD magic; - void *ptr; - struct tag_mem_list_v1_t *next; - } *mem_list_v1; struct tag_mem_list_v2_t { DWORD magic; @@ -1382,7 +1325,6 @@ static void test_ndr_allocate(void) StubDesc = Object_StubDesc; NdrClientInitializeNew(&RpcMessage, &StubMsg, &StubDesc, 0); - ok(StubMsg.pMemoryList == NULL, "memlist %p\n", StubMsg.pMemoryList); my_alloc_called = my_free_called = 0; p1 = NdrAllocate(&StubMsg, 10); p2 = NdrAllocate(&StubMsg, 24); @@ -1409,21 +1351,7 @@ static void test_ndr_allocate(void) ok(mem_list_v2->next == NULL, "next %p\n", mem_list_v2->next); } } - else - { - trace("v1 mem list format\n"); - mem_list_v1 = StubMsg.pMemoryList; - ok(mem_list_v1->magic == magic_MEML, "magic %08x\n", mem_list_v1->magic); - ok(mem_list_v1->ptr == p2, "ptr != p2\n"); - ok(mem_list_v1->next != NULL, "next NULL\n"); - mem_list_v1 = mem_list_v1->next; - if(mem_list_v1) - { - ok(mem_list_v1->magic == magic_MEML, "magic %08x\n", mem_list_v1->magic); - ok(mem_list_v1->ptr == p1, "ptr != p1\n"); - ok(mem_list_v1->next == NULL, "next %p\n", mem_list_v1->next); - } - } + else win_skip("v1 mem list format\n"); } /* NdrFree isn't exported so we can't test free'ing */ } diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index 18cfa5942aa..0d41a6278fc 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -33,6 +33,7 @@ #define INT_CODE 4198 static const char *progname; +static BOOL old_windows_version; static HANDLE stop_event; @@ -48,6 +49,8 @@ static void InitFunctionPointers(void) pNDRSContextMarshall2 = (void *)GetProcAddress(hrpcrt4, "NDRSContextMarshall2"); pNDRSContextUnmarshall2 = (void *)GetProcAddress(hrpcrt4, "NDRSContextUnmarshall2"); pRpcServerRegisterIfEx = (void *)GetProcAddress(hrpcrt4, "RpcServerRegisterIfEx"); + + if (!pNDRSContextMarshall2) old_windows_version = TRUE; } void __RPC_FAR *__RPC_USER @@ -616,13 +619,13 @@ s_context_handle_test(void) ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf); ok(!UuidIsNil((UUID *)&buf[4], &status), "uuid should not have been nil\n"); + /* raises ERROR_INVALID_HANDLE exception on Vista upwards */ + if (0) + { h = pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, NULL, 0); ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n"); ok(h->userContext == (void *)0xdeadbeef, "userContext of interface didn't unmarshal properly: %p\n", h->userContext); - /* raises ERROR_INVALID_HANDLE exception on Vista upwards */ - if (0) - { /* marshal a context handle with an interface specified */ h = pNDRSContextUnmarshall2(binding, NULL, NDR_LOCAL_DATA_REPRESENTATION, &server_if.InterfaceId, 0); ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n"); @@ -1096,12 +1099,15 @@ pointer_tests(void) free_list(list); - name.size = 10; - name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size); - get_name(&name); - ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer); - ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name); - HeapFree(GetProcessHeap(), 0, name.name); + if (!old_windows_version) + { + name.size = 10; + name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size); + get_name(&name); + ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer); + ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name); + HeapFree(GetProcessHeap(), 0, name.name); + } pa2 = a; ok(sum_pcarr2(4, &pa2) == 10, "RPC sum_pcarr2\n"); @@ -1134,7 +1140,6 @@ free_pyramid_doub_carr(doub_carr_t *dc) static void array_tests(void) { - const char str1[25] = "Hello"; int m[2][3][4] = { {{1, 2, 3, 4}, {-1, -3, -5, -7}, {0, 2, 4, 6}}, @@ -1153,7 +1158,11 @@ array_tests(void) pints_t api[5]; numbers_struct_t *ns; - ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n"); + if (!old_windows_version) + { + const char str1[25] = "Hello"; + ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n"); + } ok(sum_fixed_int_3d(m) == 4116, "RPC sum_fixed_int_3d\n"); @@ -1240,15 +1249,17 @@ array_tests(void) ok(api[0].pi == pi, "RPC conformant varying array [out] pointer changed from %p to %p\n", pi, api[0].pi); ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *api[0].pi); - ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5])); - ns->length = 5; - ns->size = 5; - ns->numbers[0].pi = pi; - get_numbers_struct(&ns); - ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi); - ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi); - - HeapFree(GetProcessHeap(), 0, ns); + if (!old_windows_version) + { + ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5])); + ns->length = 5; + ns->size = 5; + ns->numbers[0].pi = pi; + get_numbers_struct(&ns); + ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi); + ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi); + HeapFree(GetProcessHeap(), 0, ns); + } HeapFree(GetProcessHeap(), 0, pi); } diff --git a/dlls/rsaenh/mpi.c b/dlls/rsaenh/mpi.c index 0c58e39e96b..b1b1c9e1fc9 100644 --- a/dlls/rsaenh/mpi.c +++ b/dlls/rsaenh/mpi.c @@ -42,6 +42,53 @@ static const int KARATSUBA_MUL_CUTOFF = 88, /* Min. number of digits before Karatsuba multiplication is used. */ KARATSUBA_SQR_CUTOFF = 128; /* Min. number of digits before Karatsuba squaring is used. */ + +/* trim unused digits */ +static void mp_clamp(mp_int *a); + +/* compare |a| to |b| */ +static int mp_cmp_mag(const mp_int *a, const mp_int *b); + +/* Counts the number of lsbs which are zero before the first zero bit */ +static int mp_cnt_lsb(const mp_int *a); + +/* computes a = B**n mod b without division or multiplication useful for + * normalizing numbers in a Montgomery system. + */ +static int mp_montgomery_calc_normalization(mp_int *a, const mp_int *b); + +/* computes x/R == x (mod N) via Montgomery Reduction */ +static int mp_montgomery_reduce(mp_int *a, const mp_int *m, mp_digit mp); + +/* setups the montgomery reduction */ +static int mp_montgomery_setup(const mp_int *a, mp_digit *mp); + +/* Barrett Reduction, computes a (mod b) with a precomputed value c + * + * Assumes that 0 < a <= b*b, note if 0 > a > -(b*b) then you can merely + * compute the reduction as -1 * mp_reduce(mp_abs(a)) [pseudo code]. + */ +static int mp_reduce(mp_int *a, const mp_int *b, const mp_int *c); + +/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */ +static int mp_reduce_2k(mp_int *a, const mp_int *n, mp_digit d); + +/* determines k value for 2k reduction */ +static int mp_reduce_2k_setup(const mp_int *a, mp_digit *d); + +/* used to setup the Barrett reduction for a given modulus b */ +static int mp_reduce_setup(mp_int *a, const mp_int *b); + +/* set to a digit */ +static void mp_set(mp_int *a, mp_digit b); + +/* b = a*a */ +static int mp_sqr(const mp_int *a, mp_int *b); + +/* c = a * a (mod b) */ +static int mp_sqrmod(const mp_int *a, mp_int *b, mp_int *c); + + static void bn_reverse(unsigned char *s, int len); static int s_mp_add(mp_int *a, mp_int *b, mp_int *c); static int s_mp_exptmod (const mp_int * G, const mp_int * X, mp_int * P, mp_int * Y); @@ -3589,7 +3636,7 @@ ERR: } /* determines the setup value */ -int +static int mp_reduce_2k_setup(const mp_int *a, mp_digit *d) { int res, p; @@ -3677,12 +3724,6 @@ int mp_shrink (mp_int * a) return MP_OKAY; } -/* get the size for an signed equivalent */ -int mp_signed_bin_size (const mp_int * a) -{ - return 1 + mp_unsigned_bin_size (a); -} - /* computes b = a*a */ int mp_sqr (const mp_int * a, mp_int * b) diff --git a/dlls/rsaenh/tomcrypt.h b/dlls/rsaenh/tomcrypt.h index aaaac98af26..49fb352729c 100644 --- a/dlls/rsaenh/tomcrypt.h +++ b/dlls/rsaenh/tomcrypt.h @@ -249,9 +249,6 @@ int mp_shrink(mp_int *a); #define mp_iseven(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO) #define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO) -/* set to a digit */ -void mp_set(mp_int *a, mp_digit b); - /* set a 32-bit const */ int mp_set_int(mp_int *a, unsigned long b); @@ -270,14 +267,8 @@ int mp_copy(const mp_int *a, mp_int *b); /* inits and copies, a = b */ int mp_init_copy(mp_int *a, const mp_int *b); -/* trim unused digits */ -void mp_clamp(mp_int *a); - /* ---> digit manipulation <--- */ -/* Counts the number of lsbs which are zero before the first zero bit */ -int mp_cnt_lsb(const mp_int *a); - /* I Love Earth! */ /* makes a pseudo-random int of a given size */ @@ -301,9 +292,6 @@ int mp_neg(mp_int *a, mp_int *b); /* compare a to b */ int mp_cmp(const mp_int *a, const mp_int *b); -/* compare |a| to |b| */ -int mp_cmp_mag(const mp_int *a, const mp_int *b); - /* c = a + b */ int mp_add(mp_int *a, mp_int *b, mp_int *c); @@ -313,9 +301,6 @@ int mp_sub(mp_int *a, mp_int *b, mp_int *c); /* c = a * b */ int mp_mul(const mp_int *a, const mp_int *b, mp_int *c); -/* b = a*a */ -int mp_sqr(const mp_int *a, mp_int *b); - /* c = a mod b, 0 <= c < b */ int mp_mod(const mp_int *a, mp_int *b, mp_int *c); @@ -344,9 +329,6 @@ int mp_submod(mp_int *a, mp_int *b, mp_int *c, mp_int *d); /* d = a * b (mod c) */ int mp_mulmod(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d); -/* c = a * a (mod b) */ -int mp_sqrmod(const mp_int *a, mp_int *b, mp_int *c); - /* c = 1/a (mod b) */ int mp_invmod(const mp_int *a, mp_int *b, mp_int *c); @@ -374,39 +356,12 @@ int mp_is_square(mp_int *arg, int *ret); /* computes the jacobi c = (a | n) (or Legendre if b is prime) */ int mp_jacobi(mp_int *a, mp_int *n, int *c); -/* used to setup the Barrett reduction for a given modulus b */ -int mp_reduce_setup(mp_int *a, const mp_int *b); - -/* Barrett Reduction, computes a (mod b) with a precomputed value c - * - * Assumes that 0 < a <= b*b, note if 0 > a > -(b*b) then you can merely - * compute the reduction as -1 * mp_reduce(mp_abs(a)) [pseudo code]. - */ -int mp_reduce(mp_int *a, const mp_int *b, const mp_int *c); - -/* setups the montgomery reduction */ -int mp_montgomery_setup(const mp_int *a, mp_digit *mp); - -/* computes a = B**n mod b without division or multiplication useful for - * normalizing numbers in a Montgomery system. - */ -int mp_montgomery_calc_normalization(mp_int *a, const mp_int *b); - -/* computes x/R == x (mod N) via Montgomery Reduction */ -int mp_montgomery_reduce(mp_int *a, const mp_int *m, mp_digit mp); - /* returns 1 if a is a valid DR modulus */ int mp_dr_is_modulus(mp_int *a); /* returns true if a can be reduced with mp_reduce_2k */ int mp_reduce_is_2k(mp_int *a); -/* determines k value for 2k reduction */ -int mp_reduce_2k_setup(const mp_int *a, mp_digit *d); - -/* reduces a modulo b where b is of the form 2**p - k [0 <= a] */ -int mp_reduce_2k(mp_int *a, const mp_int *n, mp_digit d); - /* d = a**b (mod c) */ int mp_exptmod(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d); @@ -466,7 +421,6 @@ int mp_unsigned_bin_size(const mp_int *a); int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c); int mp_to_unsigned_bin(const mp_int *a, unsigned char *b); -int mp_signed_bin_size(const mp_int *a); int mp_read_signed_bin(mp_int *a, unsigned char *b, int c); int mp_to_signed_bin(mp_int *a, unsigned char *b); diff --git a/dlls/sane.ds/ds_image.c b/dlls/sane.ds/ds_image.c index 47770402512..4945e55bcbd 100644 --- a/dlls/sane.ds/ds_image.c +++ b/dlls/sane.ds/ds_image.c @@ -563,7 +563,7 @@ TW_UINT16 SANE_ImageNativeXferGet (pTW_IDENTITY pOrigin, psane_cancel (activeDS.deviceHandle); activeDS.sane_started = FALSE; - *pHandle = (TW_UINT32)hDIB; + *pHandle = (UINT_PTR)hDIB; twRC = TWRC_XFERDONE; activeDS.twCC = TWCC_SUCCESS; activeDS.currentState = 7; diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c index fbf2a62169f..8f127e621b1 100644 --- a/dlls/secur32/schannel.c +++ b/dlls/secur32/schannel.c @@ -619,7 +619,11 @@ static int schan_init_sec_ctx_get_next_buffer(const struct schan_transport *t, s idx = schan_find_sec_buffer_idx(s->desc, 0, SECBUFFER_EMPTY); if (idx != -1) s->desc->pBuffers[idx].BufferType = SECBUFFER_TOKEN; } - if (idx != -1 && !s->desc->pBuffers[idx].pvBuffer) s->allow_buffer_resize = TRUE; + if (idx != -1 && !s->desc->pBuffers[idx].pvBuffer) + { + s->desc->pBuffers[idx].cbBuffer = 0; + s->allow_buffer_resize = TRUE; + } } return idx; } diff --git a/dlls/shell32/shell32_Ko.rc b/dlls/shell32/shell32_Ko.rc index bf7b091451c..16ad3b1c83e 100644 --- a/dlls/shell32/shell32_Ko.rc +++ b/dlls/shell32/shell32_Ko.rc @@ -233,8 +233,8 @@ IDS_DELETESELECTED_TEXT " IDS_TRASHITEM_TEXT "´ç½ÅÀº '%1' À»(¸¦) ÈÞÁöÅëÀ¸·Î º¸³»±â¸¦ ¹Ù¶ø´Ï±î?" IDS_TRASHFOLDER_TEXT "´ç½ÅÀº '%1' °ú ±× ¾ÈÀÇ ³»¿ëÀ» ÈÞÁöÅëÀ¸·Î º¸³»±â¸¦ ¹Ù¶ø´Ï±î?" IDS_TRASHMULTIPLE_TEXT "´ç½ÅÀº '%1' µéÀ»(¸¦) ÈÞÁöÅëÀ¸·Î º¸³»±â¸¦ ¹Ù¶ø´Ï±î?" -IDS_CANTTRASH_TEXT "The item '%1' can't be sent to Trash. Do you want to delete it instead?" -IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?" +IDS_CANTTRASH_TEXT "ÀÌ ¾ÆÀÌÅÛ'%1'À» ÈÞÁöÅëÀ¸·Î º¸³¾ ¼ö ¾ø½À´Ï´Ù. ´ë½Å Áö¿ì°Ú½À´Ï±î?" +IDS_OVERWRITEFILE_TEXT "ÀÌ Æú´õ´Â ÀÌ¹Ì '%1' ÆÄÀÏÀ» °¡Áö°í ÀÖ½À´Ï´Ù.\n\n¹Ù²Ù°Ú½À´Ï±î?" IDS_OVERWRITEFILE_CAPTION "ÆÄÀÏ µ¤¾î¾²±â È®ÀÎ" IDS_OVERWRITEFOLDER_TEXT " ÀÌ Æú´õ´Â ÀÌ¹Ì '%1'À̶õ À̸§À» °¡Áø Æú´õ¸¦ Æ÷ÇÔÇÏ°í ÀÖ½À´Ï´Ù.\n\n"\ "¸¸¾à ´ç½ÅÀÌ °°Àº À̸§À¸·Î ´ë»ó Æú´õ¸¦ ÁöÁ¤ÇÑ´Ù¸é ¼±ÅÃµÈ Æú´õ´Â ´ëüµÉ °ÍÀÔ´Ï´Ù\n"\ @@ -287,6 +287,8 @@ IDS_NEWFOLDER " IDS_CPANEL_TITLE "Wine Á¦¾îÆÇ" IDS_CPANEL_NAME "À̸§" IDS_CPANEL_DESCRIPTION "¼³¸í" +IDS_SHLEXEC_NOASSOC "ÀÌ Çü½ÄÀÇ ÆÄÀÏÀ» µµ·Ï ±¸¼ºµÈ À©µµ¿ì ÇÁ·Î±×·¥ÀÌ ¾ø½À´Ï´Ù." + } STRINGTABLE diff --git a/dlls/urlmon/urlmon_main.c b/dlls/urlmon/urlmon_main.c index 3203753f923..6e51db56b98 100644 --- a/dlls/urlmon/urlmon_main.c +++ b/dlls/urlmon/urlmon_main.c @@ -36,7 +36,7 @@ LONG URLMON_refCount = 0; HINSTANCE URLMON_hInstance = 0; static HMODULE hCabinet = NULL; -static DWORD urlmon_tls; +static DWORD urlmon_tls = TLS_OUT_OF_INDEXES; static void init_session(BOOL); @@ -56,9 +56,12 @@ tls_data_t *get_tls_data(void) { tls_data_t *data; - if(!urlmon_tls) { + if(urlmon_tls == TLS_OUT_OF_INDEXES) { DWORD tls = TlsAlloc(); - tls = InterlockedCompareExchange((LONG*)&urlmon_tls, tls, 0); + if(tls == TLS_OUT_OF_INDEXES) + return NULL; + + tls = InterlockedCompareExchange((LONG*)&urlmon_tls, tls, TLS_OUT_OF_INDEXES); if(tls != urlmon_tls) TlsFree(tls); } @@ -83,7 +86,7 @@ static void free_tls_list(void) { tls_data_t *data; - if(!urlmon_tls) + if(urlmon_tls == TLS_OUT_OF_INDEXES) return; while(!list_empty(&tls_list)) { @@ -99,7 +102,7 @@ static void detach_thread(void) { tls_data_t *data; - if(!urlmon_tls) + if(urlmon_tls == TLS_OUT_OF_INDEXES) return; data = TlsGetValue(urlmon_tls); diff --git a/dlls/user32/hook.c b/dlls/user32/hook.c index 0b0d7c4203d..b6dc8e8f2f1 100644 --- a/dlls/user32/hook.c +++ b/dlls/user32/hook.c @@ -891,6 +891,7 @@ void WINAPI NotifyWinEvent(DWORD event, HWND hwnd, LONG object_id, LONG child_id */ BOOL WINAPI IsWinEventHookInstalled(DWORD dwEvent) { - FIXME("(%d)-stub!\n", dwEvent); + /* FIXME: Needed by Office 2007 installer */ + WARN("(%d)-stub!\n", dwEvent); return TRUE; } diff --git a/dlls/user32/misc.c b/dlls/user32/misc.c index 9de9b910bb1..8e7f48ff269 100644 --- a/dlls/user32/misc.c +++ b/dlls/user32/misc.c @@ -706,3 +706,14 @@ LRESULT WINAPI SendIMEMessageExW(HWND p1, LPARAM p2) SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return 0; } + +/********************************************************************** + * DisableProcessWindowsGhosting [USER32.@] + * + */ +VOID WINAPI DisableProcessWindowsGhosting(VOID) +{ + FIXME(": stub\n"); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return; +} diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 2ad3eae7d10..00d344b2c15 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1276,7 +1276,7 @@ static void test_ToUnicode(void) state[VK_LCONTROL] |= HIGHEST_BIT; ret = ToUnicode(VK_TAB, SC_TAB, state, wStr, 2, 0); - todo_wine ok(ret == 0, "ToUnicode for CTRL + Tab didn't return 0 (was %i)\n", ret); + ok(ret == 0, "ToUnicode for CTRL + Tab didn't return 0 (was %i)\n", ret); ret = ToUnicode(VK_RETURN, SC_RETURN, state, wStr, 2, 0); ok(ret == 1, "ToUnicode for CTRL + Return didn't return 1 (was %i)\n", ret); diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c index 75059ea9068..0948f69b0e7 100644 --- a/dlls/user32/tests/menu.c +++ b/dlls/user32/tests/menu.c @@ -571,7 +571,7 @@ static void test_mbs_help( int ispop, int hassub, int mnuopt, 4 + (mnuopt != 1 ? GetSystemMetrics(SM_CXMENUCHECK) : 0) : 0) + arrowwidth + MOD_avec + (hbmp ? - ((int)hbmp<0||(int)hbmp>12 ? bmpsize.cx + 2 : GetSystemMetrics( SM_CXMENUSIZE) + 2) + ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ? bmpsize.cx + 2 : GetSystemMetrics( SM_CXMENUSIZE) + 2) : 0) + (text && hastab ? /* TAB space */ MOD_avec + ( hastab==2 ? sc_size.cx : 0) : 0) + @@ -588,7 +588,7 @@ static void test_mbs_help( int ispop, int hassub, int mnuopt, expect = max( ( !(text || hbmp) ? GetSystemMetrics( SM_CYMENUSIZE)/2 : 0), max( (text ? max( 2 + size.cy, MOD_hic + 4) : 0), (hbmp ? - ((int)hbmp<0||(int)hbmp>12 ? + ((INT_PTR)hbmp<0||(INT_PTR)hbmp>12 ? bmpsize.cy + 2 : GetSystemMetrics( SM_CYMENUSIZE) + 2) : 0))); diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c index 47f52743562..080e5dd59f5 100644 --- a/dlls/user32/tests/text.c +++ b/dlls/user32/tests/text.c @@ -27,8 +27,7 @@ #include "winuser.h" #include "winerror.h" -#define MODIFIED(rect) (rect.left = 10 && rect.right != 100 && rect.top == 10 && rect.bottom != 100) -#define SAME(rect) (rect.left = 10 && rect.right == 100 && rect.top == 10 && rect.bottom == 100) +#define MODIFIED(rect) (rect.left == 10 && rect.right != 100 && rect.top == 10 && rect.bottom != 100) #define EMPTY(rect) (rect.left == rect.right && rect.bottom == rect.top) static void test_DrawTextCalcRect(void) diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 8efdf0aec0f..cae0beda498 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -163,7 +163,7 @@ @ stdcall DialogBoxIndirectParamW(long ptr long ptr long) @ stdcall DialogBoxParamA(long str long ptr long) @ stdcall DialogBoxParamW(long wstr long ptr long) -# @ stub DisableProcessWindowsGhosting +@ stdcall DisableProcessWindowsGhosting() @ stdcall DispatchMessageA(ptr) @ stdcall DispatchMessageW(ptr) # @ stub DisplayExitWindowsWarnings diff --git a/dlls/uuid/uuid.c b/dlls/uuid/uuid.c index 35d4ae8303d..840a34684a8 100644 --- a/dlls/uuid/uuid.c +++ b/dlls/uuid/uuid.c @@ -118,3 +118,12 @@ DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e DEFINE_GUID(GUID_TFCAT_TIP_SPEECH, 0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14); DEFINE_GUID(GUID_TFCAT_TIP_HANDWRITING, 0x246ecb87,0xc2f2,0x4abe,0x90,0x5b,0xc8,0xb3,0x8a,0xdd,0x2c,0x43); DEFINE_GUID (GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, 0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B); +DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_DISABLED, 0x71a5b253,0x1951,0x466b,0x9f,0xbc,0x9c,0x88,0x08,0xfa,0x84,0xf2); +DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE, 0x58273aad,0x01bb,0x4164,0x95,0xc6,0x75,0x5b,0xa0,0xb5,0x16,0x2d); +DEFINE_GUID(GUID_COMPARTMENT_HANDWRITING_OPENCLOSE, 0xf9ae2c6b,0x1866,0x4361,0xaf,0x72,0x7a,0xa3,0x09,0x48,0x89,0x0e); +DEFINE_GUID(GUID_COMPARTMENT_SPEECH_DISABLED, 0x56c5c607,0x0703,0x4e59,0x8e,0x52,0xcb,0xc8,0x4e,0x8b,0xbe,0x35); +DEFINE_GUID(GUID_COMPARTMENT_SPEECH_OPENCLOSE, 0x544d6a63,0xe2e8,0x4752,0xbb,0xd1,0x00,0x09,0x60,0xbc,0xa0,0x83); +DEFINE_GUID(GUID_COMPARTMENT_SPEECH_GLOBALSTATE, 0x2a54fe8e,0x0d08,0x460c,0xa7,0x5d,0x87,0x03,0x5f,0xf4,0x36,0xc5); +DEFINE_GUID(GUID_COMPARTMENT_PERSISTMENUENABLED, 0x575f3783,0x70c8,0x47c8,0xae,0x5d,0x91,0xa0,0x1a,0x1f,0x75,0x92); +DEFINE_GUID(GUID_COMPARTMENT_EMPTYCONTEXT, 0xd7487dbf,0x804e,0x41c5,0x89,0x4d,0xad,0x96,0xfd,0x4e,0xea,0x13); +DEFINE_GUID(GUID_COMPARTMENT_TIPUISTATUS, 0x148ca3ec,0x0366,0x401c,0x8d,0x75,0xed,0x97,0x8d,0x85,0xfb,0xc9); diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 7e3abdf4c61..918f676214b 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -83,6 +83,12 @@ struct shader_arb_priv { struct hash_table_t *fragment_shaders; }; +struct if_frame { + struct list entry; + BOOL ifc; + BOOL muting; +}; + struct shader_arb_ctx_priv { char addr_reg[20]; enum { @@ -93,6 +99,41 @@ struct shader_arb_ctx_priv { /* GL_NV_vertex_program3 or GL_NV_fragment_program2 */ NV3 } target_version; + + const struct arb_vs_compile_args *cur_vs_args; + const struct arb_ps_compile_args *cur_ps_args; + struct list if_frames; + BOOL muted; +}; + +struct arb_ps_compile_args { + struct ps_compile_args super; + DWORD bools; /* WORD is enough, use DWORD for alignment */ +}; + +struct arb_ps_compiled_shader { + struct arb_ps_compile_args args; + GLuint prgId; +}; + +struct arb_pshader_private { + struct arb_ps_compiled_shader *gl_shaders; + UINT num_gl_shaders, shader_array_size; +}; + +struct arb_vs_compile_args { + struct vs_compile_args super; + DWORD bools; /* WORD is enough, use DWORD for alignment */ +}; + +struct arb_vs_compiled_shader { + struct arb_vs_compile_args args; + GLuint prgId; +}; + +struct arb_vshader_private { + struct arb_vs_compiled_shader *gl_shaders; + UINT num_gl_shaders, shader_array_size; }; /******************************************************** @@ -311,7 +352,7 @@ static DWORD *local_const_mapping(IWineD3DBaseShaderImpl *This) if(This->baseShader.load_local_constsF || list_empty(&This->baseShader.constantsF)) return NULL; - ret = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * This->baseShader.limits.temporary); + ret = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * This->baseShader.limits.constant_float); if(!ret) { ERR("Out of memory\n"); return NULL; @@ -328,7 +369,6 @@ static void shader_generate_arb_declarations(IWineD3DBaseShader *iface, const sh SHADER_BUFFER *buffer, const WineD3D_GL_Info *gl_info, DWORD *lconst_map) { IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; - IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; DWORD i, cur, next_local = 0; char pshader = shader_is_pshader_version(reg_maps->shader_version.type); unsigned max_constantsF; @@ -352,8 +392,6 @@ static void shader_generate_arb_declarations(IWineD3DBaseShader *iface, const sh } else { max_constantsF = GL_LIMITS(vshader_constantsF) - 1; } - /* Temporary Output register */ - shader_addline(buffer, "TEMP TMP_OUT;\n"); } for(i = 0; i < This->baseShader.limits.temporary; i++) { @@ -373,13 +411,6 @@ static void shader_generate_arb_declarations(IWineD3DBaseShader *iface, const sh } } - if(device->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE] && pshader) { - shader_addline(buffer, "PARAM srgb_consts1 = {%f, %f, %f, %f};\n", - srgb_mul_low, srgb_cmp, srgb_pow, srgb_mul_high); - shader_addline(buffer, "PARAM srgb_consts2 = {%f, %f, %f, %f};\n", - srgb_sub_high, 0.0, 0.0, 0.0); - } - /* Load local constants using the program-local space, * this avoids reloading them each time the shader is used */ @@ -553,7 +584,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction } else { - if (((IWineD3DVertexShaderImpl *)This)->cur_args->swizzle_map & (1 << reg->idx)) *is_color = TRUE; + if (ctx->cur_vs_args->super.swizzle_map & (1 << reg->idx)) *is_color = TRUE; sprintf(register_name, "vertex.attrib[%u]", reg->idx); } break; @@ -616,7 +647,7 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction case WINED3DSPR_COLOROUT: if (reg->idx == 0) { - if(((IWineD3DPixelShaderImpl *)This)->cur_args->srgb_correction) + if(ctx->cur_ps_args->super.srgb_correction) { strcpy(register_name, "TMP_COLOR"); } @@ -749,6 +780,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD const char *tex_type; IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; + struct shader_arb_ctx_priv *priv = ins->ctx->backend_data; switch(sampler_type) { case WINED3DSTT_1D: @@ -764,10 +796,10 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD } if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type)) { - const IWineD3DPixelShaderImpl* const ps = (const IWineD3DPixelShaderImpl*)This; - if(ps->cur_args->np2_fixup & (1 << sampler_idx)) { - FIXME("NP2 texcoord fixup is currently not implemented in ARB mode (use GLSL instead).\n"); - } + if(priv->cur_ps_args->super.np2_fixup & (1 << sampler_idx)) + { + FIXME("NP2 texcoord fixup is currently not implemented in ARB mode (use GLSL instead).\n"); + } } break; @@ -797,9 +829,8 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type)) { - IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)ins->ctx->shader; gen_color_correction(buffer, dst_str, ins->dst[0].write_mask, - "one", "coefmul.x", ps->cur_args->color_fixup[sampler_idx]); + "one", "coefmul.x", priv->cur_ps_args->super.color_fixup[sampler_idx]); } } @@ -989,19 +1020,51 @@ static void pshader_hw_dp2add(const struct wined3d_shader_instruction *ins) SHADER_BUFFER *buffer = ins->ctx->buffer; char dst_name[50]; char src_name[3][50]; + struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data; shader_arb_get_dst_param(ins, dst, dst_name); shader_arb_get_src_param(ins, &ins->src[0], 0, src_name[0]); - shader_arb_get_src_param(ins, &ins->src[1], 1, src_name[1]); shader_arb_get_src_param(ins, &ins->src[2], 2, src_name[2]); - /* Emulate a DP2 with a DP3 and 0.0. Don't use the dest as temp register, it could be src[1] or src[2] - * src_name[0] can be TA, but TA is a private temp for modifiers, so it is save to overwrite - */ - shader_addline(buffer, "MOV TA, %s;\n", src_name[0]); - shader_addline(buffer, "MOV TA.z, 0.0;\n"); - shader_addline(buffer, "DP3 TA, TA, %s;\n", src_name[1]); - shader_addline(buffer, "ADD%s %s, TA, %s;\n", shader_arb_get_modifier(ins), dst_name, src_name[2]); + if(ctx->target_version >= NV3) + { + /* GL_NV_fragment_program2 has a 1:1 matching instruction */ + shader_arb_get_src_param(ins, &ins->src[1], 1, src_name[1]); + shader_addline(buffer, "DP2A%s %s, %s, %s, %s;\n", shader_arb_get_modifier(ins), + dst_name, src_name[0], src_name[1], src_name[2]); + } + else if(ctx->target_version >= NV2) + { + /* dst.x = src2.?, src0.x, src1.x + src0.y * src1.y + * dst.y = src2.?, src0.x, src1.z + src0.y * src1.w + * dst.z = src2.?, src0.x, src1.x + src0.y * src1.y + * dst.z = src2.?, src0.x, src1.z + src0.y * src1.w + * + * Make sure that src1.zw = src1.xy, then we get a classic dp2add + * + * .xyxy and other swizzles that we could get with this are not valid in + * plain ARBfp, but luckily the NV extension grammar lifts this limitation. + */ + struct wined3d_shader_src_param tmp_param = ins->src[1]; + DWORD swizzle = tmp_param.swizzle & 0xf; /* Selects .xy */ + tmp_param.swizzle = swizzle | (swizzle << 4); /* Creates .xyxy */ + + shader_arb_get_src_param(ins, &tmp_param, 1, src_name[1]); + + shader_addline(buffer, "X2D%s %s, %s, %s, %s;\n", shader_arb_get_modifier(ins), + dst_name, src_name[2], src_name[0], src_name[1]); + } + else + { + shader_arb_get_src_param(ins, &ins->src[1], 1, src_name[1]); + /* Emulate a DP2 with a DP3 and 0.0. Don't use the dest as temp register, it could be src[1] or src[2] + * src_name[0] can be TA, but TA is a private temp for modifiers, so it is save to overwrite + */ + shader_addline(buffer, "MOV TA, %s;\n", src_name[0]); + shader_addline(buffer, "MOV TA.z, 0.0;\n"); + shader_addline(buffer, "DP3 TA, TA, %s;\n", src_name[1]); + shader_addline(buffer, "ADD%s %s, TA, %s;\n", shader_arb_get_modifier(ins), dst_name, src_name[2]); + } } /* Map the opcode 1-to-1 to the GL code */ @@ -1039,6 +1102,7 @@ static void shader_hw_map2gl(const struct wined3d_shader_instruction *ins) case WINED3DSIH_SUB: instruction = "SUB"; break; case WINED3DSIH_MOVA:instruction = "ARR"; break; case WINED3DSIH_SGN: instruction = "SSG"; break; + case WINED3DSIH_DSX: instruction = "DDX"; break; default: instruction = ""; FIXME("Unhandled opcode %#x\n", ins->handler_idx); break; @@ -1066,12 +1130,13 @@ static void shader_hw_nop(const struct wined3d_shader_instruction *ins) static void shader_hw_mov(const struct wined3d_shader_instruction *ins) { IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + BOOL pshader = shader_is_pshader_version(shader->baseShader.reg_maps.shader_version.type); + struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data; SHADER_BUFFER *buffer = ins->ctx->buffer; char src0_param[256]; if(ins->handler_idx == WINED3DSIH_MOVA) { - struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data; struct wined3d_shader_src_param tmp_src = ins->src[0]; char write_mask[6]; @@ -1124,6 +1189,16 @@ static void shader_hw_mov(const struct wined3d_shader_instruction *ins) shader_addline(buffer, "ARL A0.x, %s;\n", src0_param); } } + else if(ins->dst[0].reg.type == WINED3DSPR_COLOROUT && ins->dst[0].reg.idx == 0 && pshader) + { + IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) shader; + if(ctx->cur_ps_args->super.srgb_correction && ps->color0_mov) + { + shader_addline(buffer, "#mov handled in srgb write code\n"); + return; + } + shader_hw_map2gl(ins); + } else { shader_hw_map2gl(ins); @@ -1240,18 +1315,20 @@ static void pshader_hw_texcoord(const struct wined3d_shader_instruction *ins) SHADER_BUFFER *buffer = ins->ctx->buffer; DWORD shader_version = WINED3D_SHADER_VERSION(ins->ctx->reg_maps->shader_version.major, ins->ctx->reg_maps->shader_version.minor); + char dst_str[50]; - char tmp[20]; - shader_arb_get_write_mask(ins, dst, tmp); - if (shader_version != WINED3D_SHADER_VERSION(1,4)) + if (shader_version < WINED3D_SHADER_VERSION(1,4)) { DWORD reg = dst->reg.idx; - shader_addline(buffer, "MOV_SAT T%u%s, fragment.texcoord[%u];\n", reg, tmp, reg); + + shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); + shader_addline(buffer, "MOV_SAT %s, fragment.texcoord[%u];\n", dst_str, reg); } else { char reg_src[40]; shader_arb_get_src_param(ins, &ins->src[0], 0, reg_src); - shader_addline(buffer, "MOV R%u%s, %s;\n", dst->reg.idx, tmp, reg_src); + shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); + shader_addline(buffer, "MOV %s, %s;\n", dst_str, reg_src); } } @@ -1308,9 +1385,8 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) { IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; const struct wined3d_shader_dst_param *dst = &ins->dst[0]; - DWORD src = ins->src[0].reg.idx; SHADER_BUFFER *buffer = ins->ctx->buffer; - char reg_coord[40], dst_reg[50]; + char reg_coord[40], dst_reg[50], src_reg[50]; DWORD reg_dest_code; /* All versions have a destination register. The Tx where the texture coordinates come @@ -1318,15 +1394,16 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) */ reg_dest_code = dst->reg.idx; shader_arb_get_dst_param(ins, &ins->dst[0], dst_reg); + shader_arb_get_src_param(ins, &ins->src[0], 0, src_reg); sprintf(reg_coord, "fragment.texcoord[%u]", reg_dest_code); /* Sampling the perturbation map in Tsrc was done already, including the signedness correction if needed * The Tx in which the perturbation map is stored is the tempreg incarnation of the texture register */ shader_addline(buffer, "SWZ TB, bumpenvmat%d, x, z, 0, 0;\n", reg_dest_code); - shader_addline(buffer, "DP3 TA.x, TB, T%u;\n", src); + shader_addline(buffer, "DP3 TA.x, TB, %s;\n", src_reg); shader_addline(buffer, "SWZ TB, bumpenvmat%d, y, w, 0, 0;\n", reg_dest_code); - shader_addline(buffer, "DP3 TA.y, TB, T%u;\n", src); + shader_addline(buffer, "DP3 TA.y, TB, %s;\n", src_reg); /* with projective textures, texbem only divides the static texture coord, not the displacement, * so we can't let the GL handle this. @@ -1344,8 +1421,9 @@ static void pshader_hw_texbem(const struct wined3d_shader_instruction *ins) if (ins->handler_idx == WINED3DSIH_TEXBEML) { - shader_addline(buffer, "MAD TA, T%u.z, luminance%d.x, luminance%d.y;\n", - src, reg_dest_code, reg_dest_code); + /* No src swizzles are allowed, so this is ok */ + shader_addline(buffer, "MAD TA, %s.z, luminance%d.x, luminance%d.y;\n", + src_reg, reg_dest_code, reg_dest_code); shader_addline(buffer, "MUL %s, %s, TA;\n", dst_reg, dst_reg); } } @@ -1354,13 +1432,17 @@ static void pshader_hw_texm3x2pad(const struct wined3d_shader_instruction *ins) { DWORD reg = ins->dst[0].reg.idx; SHADER_BUFFER *buffer = ins->ctx->buffer; - char src0_name[50]; + char src0_name[50], dst_name[50]; + BOOL is_color; + struct wined3d_shader_register tmp_reg = ins->dst[0].reg; shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name); /* The next instruction will be a texm3x2tex or texm3x2depth that writes to the uninitialized * T register. Use this register to store the calculated vector */ - shader_addline(buffer, "DP3 T%u.x, fragment.texcoord[%u], %s;\n", reg + 1, reg, src0_name); + tmp_reg.idx = reg + 1; + shader_arb_get_register_name(ins, &tmp_reg, dst_name, &is_color); + shader_addline(buffer, "DP3 %s.x, fragment.texcoord[%u], %s;\n", dst_name, reg, src0_name); } static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) @@ -1373,9 +1455,10 @@ static void pshader_hw_texm3x2tex(const struct wined3d_shader_instruction *ins) char dst_str[50]; char src0_name[50]; char dst_reg[50]; + BOOL is_color; /* We know that we're writing to the uninitialized T register, so use it for temporary storage */ - sprintf(dst_reg, "T%u", reg); + shader_arb_get_register_name(ins, &ins->dst[0].reg, dst_reg, &is_color); shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name); @@ -1390,17 +1473,20 @@ static void pshader_hw_texm3x3pad(const struct wined3d_shader_instruction *ins) DWORD reg = ins->dst[0].reg.idx; SHADER_BUFFER *buffer = ins->ctx->buffer; SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; - char src0_name[50]; - unsigned int dst; + char src0_name[50], dst_name[50]; + struct wined3d_shader_register tmp_reg = ins->dst[0].reg; + BOOL is_color; /* There are always 2 texm3x3pad instructions followed by one texm3x3[tex,vspec, ...] instruction, with * incrementing ins->dst[0].register_idx numbers. So the pad instruction already knows the final destination * register, and this register is uninitialized(otherwise the assembler complains that it is 'redeclared') */ - dst = reg + 2 - current_state->current_row; + tmp_reg.idx = reg + 2 - current_state->current_row; + shader_arb_get_register_name(ins, &tmp_reg, dst_name, &is_color); shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name); - shader_addline(buffer, "DP3 T%u.%c, fragment.texcoord[%u], %s;\n", dst, 'x' + current_state->current_row, reg, src0_name); + shader_addline(buffer, "DP3 %s%u.%c, fragment.texcoord[%u], %s;\n", + dst_name, tmp_reg.idx, 'x' + current_state->current_row, reg, src0_name); current_state->texcoord_w[current_state->current_row++] = reg; } @@ -1413,17 +1499,17 @@ static void pshader_hw_texm3x3tex(const struct wined3d_shader_instruction *ins) SHADER_BUFFER *buffer = ins->ctx->buffer; SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state; char dst_str[50]; - char dst_reg[8]; - char src0_name[50]; + char src0_name[50], dst_name[50]; + BOOL is_color; - sprintf(dst_reg, "T%u", reg); + shader_arb_get_register_name(ins, &ins->dst[0].reg, dst_name, &is_color); shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name); - shader_addline(buffer, "DP3 %s.z, fragment.texcoord[%u], %s;\n", dst_reg, reg, src0_name); + shader_addline(buffer, "DP3 %s.z, fragment.texcoord[%u], %s;\n", dst_name, reg, src0_name); /* Sample the texture using the calculated coordinates */ shader_arb_get_dst_param(ins, &ins->dst[0], dst_str); flags = reg < MAX_TEXTURES ? deviceImpl->stateBlock->textureState[reg][WINED3DTSS_TEXTURETRANSFORMFLAGS] : 0; - shader_hw_sample(ins, reg, dst_str, dst_reg, flags & WINED3DTTFF_PROJECTED, FALSE); + shader_hw_sample(ins, reg, dst_str, dst_name, flags & WINED3DTTFF_PROJECTED, FALSE); current_state->current_row = 0; } @@ -1438,11 +1524,12 @@ static void pshader_hw_texm3x3vspec(const struct wined3d_shader_instruction *ins char dst_str[50]; char src0_name[50]; char dst_reg[8]; + BOOL is_color; /* Get the dst reg without writemask strings. We know this register is uninitialized, so we can use all * components for temporary data storage */ - sprintf(dst_reg, "T%u", reg); + shader_arb_get_register_name(ins, &ins->dst[0].reg, dst_reg, &is_color); shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name); shader_addline(buffer, "DP3 %s.z, fragment.texcoord[%u], %s;\n", dst_reg, reg, src0_name); @@ -1480,18 +1567,19 @@ static void pshader_hw_texm3x3spec(const struct wined3d_shader_instruction *ins) char src0_name[50]; char src1_name[50]; char dst_reg[8]; + BOOL is_color; shader_arb_get_src_param(ins, &ins->src[0], 0, src0_name); shader_arb_get_src_param(ins, &ins->src[0], 1, src1_name); - /* Note: TMP.xy is input here, generated by two texm3x3pad instructions */ - sprintf(dst_reg, "T%u", reg); + shader_arb_get_register_name(ins, &ins->dst[0].reg, dst_reg, &is_color); + /* Note: dst_reg.xy is input here, generated by two texm3x3pad instructions */ shader_addline(buffer, "DP3 %s.z, fragment.texcoord[%u], %s;\n", dst_reg, reg, src0_name); /* Calculate reflection vector. * - * dot(N, E) - * TMP.xyz = 2 * --------- * N - E - * dot(N, N) + * dot(N, E) + * dst_reg.xyz = 2 * --------- * N - E + * dot(N, N) * * Which normalizes the normal vector */ @@ -1576,13 +1664,15 @@ static void pshader_hw_texm3x3(const struct wined3d_shader_instruction *ins) { const struct wined3d_shader_dst_param *dst = &ins->dst[0]; SHADER_BUFFER *buffer = ins->ctx->buffer; - char dst_str[50]; + char dst_str[50], dst_name[50]; char src0[50]; + BOOL is_color; shader_arb_get_dst_param(ins, dst, dst_str); shader_arb_get_src_param(ins, &ins->src[0], 0, src0); - shader_addline(buffer, "DP3 T%u.z, fragment.texcoord[%u], %s;\n", dst->reg.idx, dst->reg.idx, src0); - shader_addline(buffer, "MOV %s, T%u;\n", dst_str, dst->reg.idx); + shader_arb_get_register_name(ins, &ins->dst[0].reg, dst_name, &is_color); + shader_addline(buffer, "DP3 %s.z, fragment.texcoord[%u], %s;\n", dst_name, dst->reg.idx, src0); + shader_addline(buffer, "MOV %s, %s;\n", dst_str, dst_name); } /** Process the WINED3DSIO_TEXM3X2DEPTH instruction in ARB: @@ -1593,20 +1683,22 @@ static void pshader_hw_texm3x3(const struct wined3d_shader_instruction *ins) static void pshader_hw_texm3x2depth(const struct wined3d_shader_instruction *ins) { SHADER_BUFFER *buffer = ins->ctx->buffer; - DWORD dst_reg = ins->dst[0].reg.idx; - char src0[50]; + const struct wined3d_shader_dst_param *dst = &ins->dst[0]; + char src0[50], dst_name[50]; + BOOL is_color; shader_arb_get_src_param(ins, &ins->src[0], 0, src0); - shader_addline(buffer, "DP3 T%u.y, fragment.texcoord[%u], %s;\n", dst_reg, dst_reg, src0); + shader_arb_get_register_name(ins, &ins->dst[0].reg, dst_name, &is_color); + shader_addline(buffer, "DP3 %s.y, fragment.texcoord[%u], %s;\n", dst_name, dst->reg.idx, src0); /* How to deal with the special case dst_name.g == 0? if r != 0, then * the r * (1 / 0) will give infinity, which is clamped to 1.0, the correct * result. But if r = 0.0, then 0 * inf = 0, which is incorrect. */ - shader_addline(buffer, "RCP T%u.y, T%u.y;\n", dst_reg, dst_reg); - shader_addline(buffer, "MUL T%u.x, T%u.x, T%u.y;\n", dst_reg, dst_reg, dst_reg); - shader_addline(buffer, "MIN T%u.x, T%u.x, one.x;\n", dst_reg, dst_reg); - shader_addline(buffer, "MAX result.depth, T%u.x, 0.0;\n", dst_reg); + shader_addline(buffer, "RCP %s.y, %s.y;\n", dst_name, dst_name); + shader_addline(buffer, "MUL %s.x, %s.x, %s.y;\n", dst_name, dst_name, dst_name); + shader_addline(buffer, "MIN %s.x, %s.x, one.x;\n", dst_name, dst_name); + shader_addline(buffer, "MAX result.depth, %s.x, 0.0;\n", dst_name); } /** Handles transforming all WINED3DSIO_M?x? opcodes for @@ -1700,14 +1792,24 @@ static void shader_hw_nrm(const struct wined3d_shader_instruction *ins) SHADER_BUFFER *buffer = ins->ctx->buffer; char dst_name[50]; char src_name[50]; + struct shader_arb_ctx_priv *priv = ins->ctx->backend_data; + BOOL pshader = shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type); shader_arb_get_dst_param(ins, &ins->dst[0], dst_name); shader_arb_get_src_param(ins, &ins->src[0], 1 /* Use TB */, src_name); - shader_addline(buffer, "DP3 TA, %s, %s;\n", src_name, src_name); - shader_addline(buffer, "RSQ TA, TA.x;\n"); - /* dst.w = src[0].w * 1 / (src.x^2 + src.y^2 + src.z^2)^(1/2) according to msdn*/ - shader_addline(buffer, "MUL%s %s, %s, TA;\n", shader_arb_get_modifier(ins), dst_name, - src_name); + + if(pshader && priv->target_version >= NV3) + { + shader_addline(buffer, "NRM%s %s, %s;\n", shader_arb_get_modifier(ins), dst_name, src_name); + } + else + { + shader_addline(buffer, "DP3 TA, %s, %s;\n", src_name, src_name); + shader_addline(buffer, "RSQ TA, TA.x;\n"); + /* dst.w = src[0].w * 1 / (src.x^2 + src.y^2 + src.z^2)^(1/2) according to msdn*/ + shader_addline(buffer, "MUL%s %s, %s, TA;\n", shader_arb_get_modifier(ins), dst_name, + src_name); + } } static void shader_hw_sincos(const struct wined3d_shader_instruction *ins) @@ -1717,13 +1819,98 @@ static void shader_hw_sincos(const struct wined3d_shader_instruction *ins) * can't use map2gl */ SHADER_BUFFER *buffer = ins->ctx->buffer; + struct shader_arb_ctx_priv *priv = ins->ctx->backend_data; + const struct wined3d_shader_dst_param *dst = &ins->dst[0]; char dst_name[50]; - char src_name[50]; + char src_name0[50], src_name1[50], src_name2[50]; + BOOL is_color; - shader_arb_get_dst_param(ins, &ins->dst[0], dst_name); - shader_arb_get_src_param(ins, &ins->src[0], 0, src_name); - shader_addline(buffer, "SCS%s %s, %s;\n", shader_arb_get_modifier(ins), dst_name, - src_name); + shader_arb_get_src_param(ins, &ins->src[0], 0, src_name0); + if(shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type)) { + shader_arb_get_dst_param(ins, &ins->dst[0], dst_name); + shader_addline(buffer, "SCS%s %s, %s;\n", shader_arb_get_modifier(ins), dst_name, + src_name0); + } else if(priv->target_version >= NV2) { + shader_arb_get_register_name(ins, &dst->reg, dst_name, &is_color); + + /* Sincos writemask must be .x, .y or .xy */ + if(dst->write_mask & WINED3DSP_WRITEMASK_0) + shader_addline(buffer, "COS%s %s.x, %s;\n", shader_arb_get_modifier(ins), dst_name, src_name0); + if(dst->write_mask & WINED3DSP_WRITEMASK_1) + shader_addline(buffer, "SIN%s %s.y, %s;\n", shader_arb_get_modifier(ins), dst_name, src_name0); + } else { + /* Approximate sine and cosine with a taylor series, as per math textbook. The application passes 8 + * helper constants(D3DSINCOSCONST1 and D3DSINCOSCONST2) in src1 and src2. + * + * sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... + * cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ... + * + * The constants we get are: + * + * +1 +1, -1 -1 +1 +1 -1 -1 + * ---- , ---- , ---- , ----- , ----- , ----- , ------ + * 1!*2 2!*4 3!*8 4!*16 5!*32 6!*64 7!*128 + * + * If used with x^2, x^3, x^4 etc they calculate sin(x/2) and cos(x/2): + * + * (x/2)^2 = x^2 / 4 + * (x/2)^3 = x^3 / 8 + * (x/2)^4 = x^4 / 16 + * (x/2)^5 = x^5 / 32 + * etc + * + * To get the final result: + * sin(x) = 2 * sin(x/2) * cos(x/2) + * cos(x) = cos(x/2)^2 - sin(x/2)^2 + * (from sin(x+y) and cos(x+y) rules) + * + * As per MSDN, dst.z is undefined after the operation, and so is + * dst.x and dst.y if they're masked out by the writemask. Ie + * sincos dst.y, src1, c0, c1 + * returns the sine in dst.y. dst.x and dst.z are undefined, dst.w is not touched. The assembler + * vsa.exe also stops with an error if the dest register is the same register as the source + * register. This means we can use dest.xyz as temporary storage. The assembler vsa.exe output also + * indicates that sincos consumes 8 instruction slots in vs_2_0(and, strangely, in vs_3_0). + */ + shader_arb_get_src_param(ins, &ins->src[1], 1, src_name1); + shader_arb_get_src_param(ins, &ins->src[2], 2, src_name2); + shader_arb_get_register_name(ins, &dst->reg, dst_name, &is_color); + + shader_addline(buffer, "MUL %s.x, %s, %s;\n", dst_name, src_name0, src_name0); /* x ^ 2 */ + shader_addline(buffer, "MUL TA.y, %s.x, %s;\n", dst_name, src_name0); /* x ^ 3 */ + shader_addline(buffer, "MUL %s.y, TA.y, %s;\n", dst_name, src_name0); /* x ^ 4 */ + shader_addline(buffer, "MUL TA.z, %s.y, %s;\n", dst_name, src_name0); /* x ^ 5 */ + shader_addline(buffer, "MUL %s.z, TA.z, %s;\n", dst_name, src_name0); /* x ^ 6 */ + shader_addline(buffer, "MUL TA.w, %s.z, %s;\n", dst_name, src_name0); /* x ^ 7 */ + + /* sin(x/2) + * + * Unfortunately we don't get the constants in a DP4-capable form. Is there a way to + * properly merge that with MULs in the code above? + * The swizzles .yz and xw however fit into the .yzxw swizzle added to ps_2_0. Maybe + * we can merge the sine and cosine MAD rows to calculate them together. + */ + shader_addline(buffer, "MUL TA.x, %s, %s.w;\n", src_name0, src_name2); /* x^1, +1/(1!*2) */ + shader_addline(buffer, "MAD TA.x, TA.y, %s.x, TA.x;\n", src_name2); /* -1/(3!*8) */ + shader_addline(buffer, "MAD TA.x, TA.z, %s.w, TA.x;\n", src_name1); /* +1/(5!*32) */ + shader_addline(buffer, "MAD TA.x, TA.w, %s.x, TA.x;\n", src_name1); /* -1/(7!*128) */ + + /* cos(x/2) */ + shader_addline(buffer, "MAD TA.y, %s.x, %s.y, %s.z;\n", dst_name, src_name2, src_name2); /* -1/(2!*4), +1.0 */ + shader_addline(buffer, "MAD TA.y, %s.y, %s.z, TA.y;\n", dst_name, src_name1); /* +1/(4!*16) */ + shader_addline(buffer, "MAD TA.y, %s.z, %s.y, TA.y;\n", dst_name, src_name1); /* -1/(6!*64) */ + + if(dst->write_mask & WINED3DSP_WRITEMASK_0) { + /* cos x */ + shader_addline(buffer, "MUL TA.z, TA.y, TA.y;\n"); + shader_addline(buffer, "MAD %s.x, -TA.x, TA.x, TA.z;\n", dst_name); + } + if(dst->write_mask & WINED3DSP_WRITEMASK_1) { + /* sin x */ + shader_addline(buffer, "MUL %s.y, TA.x, TA.y;\n", dst_name); + shader_addline(buffer, "ADD %s.y, %s.y, %s.y;\n", dst_name, dst_name, dst_name); + } + } } /* GL locking is done by the caller */ @@ -1830,178 +2017,6 @@ static GLuint create_arb_blt_fragment_program(const WineD3D_GL_Info *gl_info, en return program_id; } -/* GL locking is done by the caller */ -static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - struct shader_arb_priv *priv = This->shader_priv; - const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; - - if (useVS) { - struct vs_compile_args compile_args; - - TRACE("Using vertex shader\n"); - find_vs_compile_args((IWineD3DVertexShaderImpl *) This->stateBlock->vertexShader, This->stateBlock, &compile_args); - priv->current_vprogram_id = find_gl_vshader((IWineD3DVertexShaderImpl *) This->stateBlock->vertexShader, &compile_args); - - /* Bind the vertex program */ - GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id)); - checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id);"); - - /* Enable OpenGL vertex programs */ - glEnable(GL_VERTEX_PROGRAM_ARB); - checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);"); - TRACE("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", This, priv->current_vprogram_id); - } else if(GL_SUPPORT(ARB_VERTEX_PROGRAM)) { - priv->current_vprogram_id = 0; - glDisable(GL_VERTEX_PROGRAM_ARB); - checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)"); - } - - if (usePS) { - struct ps_compile_args compile_args; - TRACE("Using pixel shader\n"); - find_ps_compile_args((IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader, This->stateBlock, &compile_args); - priv->current_fprogram_id = find_gl_pshader((IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader, - &compile_args); - - /* Bind the fragment program */ - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id)); - checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id);"); - - if(!priv->use_arbfp_fixed_func) { - /* Enable OpenGL fragment programs */ - glEnable(GL_FRAGMENT_PROGRAM_ARB); - checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);"); - } - TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, priv->current_fprogram_id); - - shader_arb_ps_local_constants(This); - } else if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && !priv->use_arbfp_fixed_func) { - /* Disable only if we're not using arbfp fixed function fragment processing. If this is used, - * keep GL_FRAGMENT_PROGRAM_ARB enabled, and the fixed function pipeline will bind the fixed function - * replacement shader - */ - glDisable(GL_FRAGMENT_PROGRAM_ARB); - checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)"); - priv->current_fprogram_id = 0; - } -} - -/* GL locking is done by the caller */ -static void shader_arb_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - struct shader_arb_priv *priv = This->shader_priv; - GLuint *blt_fprogram = &priv->depth_blt_fprogram_id[tex_type]; - const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; - - if (!priv->depth_blt_vprogram_id) priv->depth_blt_vprogram_id = create_arb_blt_vertex_program(gl_info); - GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->depth_blt_vprogram_id)); - glEnable(GL_VERTEX_PROGRAM_ARB); - - if (!*blt_fprogram) *blt_fprogram = create_arb_blt_fragment_program(gl_info, tex_type); - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, *blt_fprogram)); - glEnable(GL_FRAGMENT_PROGRAM_ARB); -} - -/* GL locking is done by the caller */ -static void shader_arb_deselect_depth_blt(IWineD3DDevice *iface) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - struct shader_arb_priv *priv = This->shader_priv; - const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; - - if (priv->current_vprogram_id) { - GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id)); - checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertexShader->prgId);"); - - glEnable(GL_VERTEX_PROGRAM_ARB); - checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);"); - - TRACE("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", This, priv->current_vprogram_id); - } else { - glDisable(GL_VERTEX_PROGRAM_ARB); - checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)"); - } - - if (priv->current_fprogram_id) { - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id)); - checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixelShader->prgId);"); - - glEnable(GL_FRAGMENT_PROGRAM_ARB); - checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);"); - - TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, priv->current_fprogram_id); - } else { - glDisable(GL_FRAGMENT_PROGRAM_ARB); - checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)"); - } -} - -static void shader_arb_destroy(IWineD3DBaseShader *iface) { - IWineD3DBaseShaderImpl *baseShader = (IWineD3DBaseShaderImpl *) iface; - const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)baseShader->baseShader.device)->adapter->gl_info; - - if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type)) - { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface; - UINT i; - - ENTER_GL(); - for(i = 0; i < This->num_gl_shaders; i++) { - GL_EXTCALL(glDeleteProgramsARB(1, &This->gl_shaders[i].prgId)); - checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &This->gl_shaders[i].prgId))"); - } - LEAVE_GL(); - HeapFree(GetProcessHeap(), 0, This->gl_shaders); - This->gl_shaders = NULL; - This->num_gl_shaders = 0; - This->shader_array_size = 0; - } else { - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface; - UINT i; - - ENTER_GL(); - for(i = 0; i < This->num_gl_shaders; i++) { - GL_EXTCALL(glDeleteProgramsARB(1, &This->gl_shaders[i].prgId)); - checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &This->gl_shaders[i].prgId))"); - } - LEAVE_GL(); - HeapFree(GetProcessHeap(), 0, This->gl_shaders); - This->gl_shaders = NULL; - This->num_gl_shaders = 0; - This->shader_array_size = 0; - } -} - -static HRESULT shader_arb_alloc(IWineD3DDevice *iface) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - This->shader_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_arb_priv)); - return WINED3D_OK; -} - -static void shader_arb_free(IWineD3DDevice *iface) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; - struct shader_arb_priv *priv = This->shader_priv; - int i; - - ENTER_GL(); - if(priv->depth_blt_vprogram_id) { - GL_EXTCALL(glDeleteProgramsARB(1, &priv->depth_blt_vprogram_id)); - } - for (i = 0; i < tex_type_count; ++i) { - if (priv->depth_blt_fprogram_id[i]) { - GL_EXTCALL(glDeleteProgramsARB(1, &priv->depth_blt_fprogram_id[i])); - } - } - LEAVE_GL(); - - HeapFree(GetProcessHeap(), 0, This->shader_priv); -} - -static BOOL shader_arb_dirty_const(IWineD3DDevice *iface) { - return TRUE; -} - static void arbfp_add_sRGB_correction(SHADER_BUFFER *buffer, const char *fragcolor, const char *tmp1, const char *tmp2, const char *tmp3) { /* Perform sRGB write correction. See GLX_EXT_framebuffer_sRGB */ @@ -2020,23 +2035,28 @@ static void arbfp_add_sRGB_correction(SHADER_BUFFER *buffer, const char *fragcol } /* GL locking is done by the caller */ -static GLuint shader_arb_generate_pshader(IWineD3DPixelShader *iface, - SHADER_BUFFER *buffer, const struct ps_compile_args *args) +static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, + SHADER_BUFFER *buffer, const struct arb_ps_compile_args *args) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; const shader_reg_maps* reg_maps = &This->baseShader.reg_maps; CONST DWORD *function = This->baseShader.function; const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info; const local_constant *lconst; GLuint retval; - const char *fragcolor; + char fragcolor[16]; DWORD *lconst_map = local_const_mapping((IWineD3DBaseShaderImpl *) This); struct shader_arb_ctx_priv priv_ctx; /* Create the hw ARB shader */ memset(&priv_ctx, 0, sizeof(priv_ctx)); + priv_ctx.cur_ps_args = args; + list_init(&priv_ctx.if_frames); + shader_addline(buffer, "!!ARBfp1.0\n"); - if(GL_SUPPORT(NV_FRAGMENT_PROGRAM_OPTION)) { + if(GL_SUPPORT(NV_FRAGMENT_PROGRAM2)) { + shader_addline(buffer, "OPTION NV_fragment_program2;\n"); + priv_ctx.target_version = NV3; + } else if(GL_SUPPORT(NV_FRAGMENT_PROGRAM_OPTION)) { shader_addline(buffer, "OPTION NV_fragment_program;\n"); priv_ctx.target_version = NV2; } else { @@ -2045,7 +2065,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShader *iface, if (reg_maps->shader_version.major < 3) { - switch(args->fog) { + switch(args->super.fog) { case FOG_OFF: break; case FOG_LINEAR: @@ -2069,23 +2089,34 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShader *iface, if (reg_maps->shader_version.major < 2) { - fragcolor = "R0"; + strcpy(fragcolor, "R0"); } else { - if(args->srgb_correction) { - shader_addline(buffer, "TEMP TMP_COLOR;\n"); - fragcolor = "TMP_COLOR"; + if(args->super.srgb_correction) { + if(This->color0_mov) { + sprintf(fragcolor, "R%u", This->color0_reg); + } else { + shader_addline(buffer, "TEMP TMP_COLOR;\n"); + strcpy(fragcolor, "TMP_COLOR"); + } } else { - fragcolor = "result.color"; + strcpy(fragcolor, "result.color"); } } + if(args->super.srgb_correction) { + shader_addline(buffer, "PARAM srgb_consts1 = {%f, %f, %f, %f};\n", + srgb_mul_low, srgb_cmp, srgb_pow, srgb_mul_high); + shader_addline(buffer, "PARAM srgb_consts2 = {%f, %f, %f, %f};\n", + srgb_sub_high, 0.0, 0.0, 0.0); + } + /* Base Declarations */ shader_generate_arb_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION, lconst_map); /* Base Shader Body */ shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, &priv_ctx); - if(args->srgb_correction) { + if(args->super.srgb_correction) { arbfp_add_sRGB_correction(buffer, fragcolor, "TA", "TB", "TC"); shader_addline(buffer, "MOV result.color.a, %s;\n", fragcolor); } else if(reg_maps->shader_version.major < 2) { @@ -2126,10 +2157,9 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShader *iface, } /* GL locking is done by the caller */ -static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface, - SHADER_BUFFER *buffer, const struct vs_compile_args *args) +static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, + SHADER_BUFFER *buffer, const struct arb_vs_compile_args *args) { - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; const shader_reg_maps *reg_maps = &This->baseShader.reg_maps; CONST DWORD *function = This->baseShader.function; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device; @@ -2140,6 +2170,9 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface, struct shader_arb_ctx_priv priv_ctx; memset(&priv_ctx, 0, sizeof(priv_ctx)); + priv_ctx.cur_vs_args = args; + list_init(&priv_ctx.if_frames); + /* Create the hw ARB shader */ shader_addline(buffer, "!!ARBvp1.0\n"); @@ -2150,19 +2183,15 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface, priv_ctx.target_version = ARB; } + shader_addline(buffer, "TEMP TMP_OUT;\n"); if(need_helper_const(gl_info)) { shader_addline(buffer, "PARAM helper_const = { 2.0, -1.0, %d.0, 0.0 };\n", This->rel_offset); } - if(need_mova_const((IWineD3DBaseShader *) iface, gl_info)) { + if(need_mova_const((IWineD3DBaseShader *) This, gl_info)) { shader_addline(buffer, "PARAM mova_const = { 0.5, 0.0, 2.0, 1.0 };\n"); shader_addline(buffer, "TEMP A0_SHADOW;\n"); } - /* Mesa supports only 95 constants */ - if (GL_VEND(MESA) || GL_VEND(WINE)) - This->baseShader.limits.constant_float = - min(95, This->baseShader.limits.constant_float); - shader_addline(buffer, "TEMP TA;\n"); /* Base Declarations */ @@ -2204,7 +2233,7 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface, * the fog frag coord is thrown away. If the fog frag coord is used, but not written by * the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0) */ - if(args->fog_src == VS_FOG_Z) { + if(args->super.fog_src == VS_FOG_Z) { shader_addline(buffer, "MOV result.fogcoord, TMP_OUT.z;\n"); } else if (!reg_maps->fog) { /* posFixup.x is always 1.0, so we can savely use it */ @@ -2267,6 +2296,337 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShader *iface, return ret; } +/* GL locking is done by the caller */ +static GLuint find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb_ps_compile_args *args) +{ + UINT i; + DWORD new_size; + struct arb_ps_compiled_shader *new_array; + SHADER_BUFFER buffer; + struct arb_pshader_private *shader_data; + GLuint ret; + + if(!shader->backend_priv) { + shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data)); + } + shader_data = shader->backend_priv; + + /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2), + * so a linear search is more performant than a hashmap or a binary search + * (cache coherency etc) + */ + for(i = 0; i < shader_data->num_gl_shaders; i++) { + if(memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) { + return shader_data->gl_shaders[i].prgId; + } + } + + TRACE("No matching GL shader found, compiling a new shader\n"); + if(shader_data->shader_array_size == shader_data->num_gl_shaders) { + if (shader_data->num_gl_shaders) + { + new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2); + new_array = HeapReAlloc(GetProcessHeap(), 0, shader_data->gl_shaders, + new_size * sizeof(*shader_data->gl_shaders)); + } else { + new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader_data->gl_shaders)); + new_size = 1; + } + + if(!new_array) { + ERR("Out of memory\n"); + return 0; + } + shader_data->gl_shaders = new_array; + shader_data->shader_array_size = new_size; + } + + shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args; + + pixelshader_update_samplers(&shader->baseShader.reg_maps, + ((IWineD3DDeviceImpl *)shader->baseShader.device)->stateBlock->textures); + + shader_buffer_init(&buffer); + ret = shader_arb_generate_pshader(shader, &buffer, args); + shader_buffer_free(&buffer); + shader_data->gl_shaders[shader_data->num_gl_shaders++].prgId = ret; + + return ret; +} + +static inline BOOL vs_args_equal(const struct arb_vs_compile_args *stored, const struct arb_vs_compile_args *new, + const DWORD use_map) { + if((stored->super.swizzle_map & use_map) != new->super.swizzle_map) return FALSE; + if(stored->super.fog_src != new->super.fog_src) return FALSE; + return stored->bools == new->bools; +} + +static GLuint find_arb_vshader(IWineD3DVertexShaderImpl *shader, const struct arb_vs_compile_args *args) +{ + UINT i; + DWORD new_size; + struct arb_vs_compiled_shader *new_array; + DWORD use_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.use_map; + SHADER_BUFFER buffer; + struct arb_vshader_private *shader_data; + GLuint ret; + + if(!shader->backend_priv) { + shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data)); + } + shader_data = shader->backend_priv; + + /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2), + * so a linear search is more performant than a hashmap or a binary search + * (cache coherency etc) + */ + for(i = 0; i < shader_data->num_gl_shaders; i++) { + if(vs_args_equal(&shader_data->gl_shaders[i].args, args, use_map)) { + return shader_data->gl_shaders[i].prgId; + } + } + + TRACE("No matching GL shader found, compiling a new shader\n"); + + if(shader_data->shader_array_size == shader_data->num_gl_shaders) { + if (shader_data->num_gl_shaders) + { + new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2); + new_array = HeapReAlloc(GetProcessHeap(), 0, shader_data->gl_shaders, + new_size * sizeof(*shader_data->gl_shaders)); + } else { + new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader_data->gl_shaders)); + new_size = 1; + } + + if(!new_array) { + ERR("Out of memory\n"); + return 0; + } + shader_data->gl_shaders = new_array; + shader_data->shader_array_size = new_size; + } + + shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args; + + shader_buffer_init(&buffer); + ret = shader_arb_generate_vshader(shader, &buffer, args); + shader_buffer_free(&buffer); + shader_data->gl_shaders[shader_data->num_gl_shaders++].prgId = ret; + + return ret; +} + +static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, + struct arb_ps_compile_args *args) +{ + int i; + find_ps_compile_args(shader, stateblock, &args->super); + + /* This forces all local boolean constants to 1 to make them stateblock independent */ + args->bools = shader->baseShader.reg_maps.local_bool_consts; + + for(i = 0; i < MAX_CONST_B; i++) + { + if(stateblock->pixelShaderConstantB[i]) args->bools |= ( 1 << i); + } + +} + +static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, + struct arb_vs_compile_args *args) +{ + int i; + find_vs_compile_args(shader, stateblock, &args->super); + + /* This forces all local boolean constants to 1 to make them stateblock independent */ + args->bools = shader->baseShader.reg_maps.local_bool_consts; + + /* TODO: Figure out if it would be better to store bool constants as bitmasks in the stateblock */ + for(i = 0; i < MAX_CONST_B; i++) + { + if(stateblock->vertexShaderConstantB[i]) args->bools |= ( 1 << i); + } + +} + +/* GL locking is done by the caller */ +static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + struct shader_arb_priv *priv = This->shader_priv; + const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; + + if (useVS) { + struct arb_vs_compile_args compile_args; + + TRACE("Using vertex shader\n"); + find_arb_vs_compile_args((IWineD3DVertexShaderImpl *) This->stateBlock->vertexShader, This->stateBlock, &compile_args); + priv->current_vprogram_id = find_arb_vshader((IWineD3DVertexShaderImpl *) This->stateBlock->vertexShader, &compile_args); + + /* Bind the vertex program */ + GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id)); + checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id);"); + + /* Enable OpenGL vertex programs */ + glEnable(GL_VERTEX_PROGRAM_ARB); + checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);"); + TRACE("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", This, priv->current_vprogram_id); + } else if(GL_SUPPORT(ARB_VERTEX_PROGRAM)) { + priv->current_vprogram_id = 0; + glDisable(GL_VERTEX_PROGRAM_ARB); + checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)"); + } + + if (usePS) { + struct arb_ps_compile_args compile_args; + TRACE("Using pixel shader\n"); + find_arb_ps_compile_args((IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader, This->stateBlock, &compile_args); + priv->current_fprogram_id = find_arb_pshader((IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader, + &compile_args); + + /* Bind the fragment program */ + GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id)); + checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id);"); + + if(!priv->use_arbfp_fixed_func) { + /* Enable OpenGL fragment programs */ + glEnable(GL_FRAGMENT_PROGRAM_ARB); + checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);"); + } + TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, priv->current_fprogram_id); + + shader_arb_ps_local_constants(This); + } else if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && !priv->use_arbfp_fixed_func) { + /* Disable only if we're not using arbfp fixed function fragment processing. If this is used, + * keep GL_FRAGMENT_PROGRAM_ARB enabled, and the fixed function pipeline will bind the fixed function + * replacement shader + */ + glDisable(GL_FRAGMENT_PROGRAM_ARB); + checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)"); + priv->current_fprogram_id = 0; + } +} + +/* GL locking is done by the caller */ +static void shader_arb_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + struct shader_arb_priv *priv = This->shader_priv; + GLuint *blt_fprogram = &priv->depth_blt_fprogram_id[tex_type]; + const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; + + if (!priv->depth_blt_vprogram_id) priv->depth_blt_vprogram_id = create_arb_blt_vertex_program(gl_info); + GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->depth_blt_vprogram_id)); + glEnable(GL_VERTEX_PROGRAM_ARB); + + if (!*blt_fprogram) *blt_fprogram = create_arb_blt_fragment_program(gl_info, tex_type); + GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, *blt_fprogram)); + glEnable(GL_FRAGMENT_PROGRAM_ARB); +} + +/* GL locking is done by the caller */ +static void shader_arb_deselect_depth_blt(IWineD3DDevice *iface) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + struct shader_arb_priv *priv = This->shader_priv; + const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; + + if (priv->current_vprogram_id) { + GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id)); + checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertexShader->prgId);"); + + glEnable(GL_VERTEX_PROGRAM_ARB); + checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);"); + + TRACE("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", This, priv->current_vprogram_id); + } else { + glDisable(GL_VERTEX_PROGRAM_ARB); + checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)"); + } + + if (priv->current_fprogram_id) { + GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id)); + checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixelShader->prgId);"); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);"); + + TRACE("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, priv->current_fprogram_id); + } else { + glDisable(GL_FRAGMENT_PROGRAM_ARB); + checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)"); + } +} + +static void shader_arb_destroy(IWineD3DBaseShader *iface) { + IWineD3DBaseShaderImpl *baseShader = (IWineD3DBaseShaderImpl *) iface; + IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)baseShader->baseShader.device; + const WineD3D_GL_Info *gl_info = &device->adapter->gl_info; + + ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); + + if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type)) + { + IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface; + struct arb_pshader_private *shader_data = This->backend_priv; + UINT i; + + if(!shader_data) return; /* This can happen if a shader was never compiled */ + ENTER_GL(); + for(i = 0; i < shader_data->num_gl_shaders; i++) { + GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId)); + checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))"); + } + LEAVE_GL(); + HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); + HeapFree(GetProcessHeap(), 0, shader_data); + This->backend_priv = NULL; + } else { + IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface; + struct arb_vshader_private *shader_data = This->backend_priv; + UINT i; + + if(!shader_data) return; /* This can happen if a shader was never compiled */ + ENTER_GL(); + for(i = 0; i < shader_data->num_gl_shaders; i++) { + GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId)); + checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))"); + } + LEAVE_GL(); + HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); + HeapFree(GetProcessHeap(), 0, shader_data); + This->backend_priv = NULL; + } +} + +static HRESULT shader_arb_alloc(IWineD3DDevice *iface) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + This->shader_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_arb_priv)); + return WINED3D_OK; +} + +static void shader_arb_free(IWineD3DDevice *iface) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; + struct shader_arb_priv *priv = This->shader_priv; + int i; + + ENTER_GL(); + if(priv->depth_blt_vprogram_id) { + GL_EXTCALL(glDeleteProgramsARB(1, &priv->depth_blt_vprogram_id)); + } + for (i = 0; i < tex_type_count; ++i) { + if (priv->depth_blt_fprogram_id[i]) { + GL_EXTCALL(glDeleteProgramsARB(1, &priv->depth_blt_fprogram_id[i])); + } + } + LEAVE_GL(); + + HeapFree(GetProcessHeap(), 0, This->shader_priv); +} + +static BOOL shader_arb_dirty_const(IWineD3DDevice *iface) { + return TRUE; +} + static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) { /* We don't have an ARB fixed function pipeline yet, so let the none backend set its caps, @@ -2354,7 +2714,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_DP3 */ shader_hw_map2gl, /* WINED3DSIH_DP4 */ shader_hw_map2gl, /* WINED3DSIH_DST */ shader_hw_map2gl, - /* WINED3DSIH_DSX */ NULL, + /* WINED3DSIH_DSX */ shader_hw_map2gl, /* WINED3DSIH_DSY */ NULL, /* WINED3DSIH_ELSE */ NULL, /* WINED3DSIH_ENDIF */ NULL, @@ -2420,8 +2780,122 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_TEXREG2RGB */ pshader_hw_texreg2rgb, }; +static inline BOOL get_bool_const(const struct wined3d_shader_instruction *ins, IWineD3DBaseShaderImpl *This, DWORD idx) +{ + BOOL vshader = shader_is_vshader_version(This->baseShader.reg_maps.shader_version.type); + WORD bools = 0; + WORD flag = (1 << idx); + const local_constant *constant; + struct shader_arb_ctx_priv *priv = ins->ctx->backend_data; + + if(This->baseShader.reg_maps.local_bool_consts & flag) + { + /* What good is a if(bool) with a hardcoded local constant? I don't know, but handle it */ + LIST_FOR_EACH_ENTRY(constant, &This->baseShader.constantsB, local_constant, entry) + { + if (constant->idx == idx) + { + return constant->value[0]; + } + } + ERR("Local constant not found\n"); + return FALSE; + } + else + { + if(vshader) bools = priv->cur_vs_args->bools; + else bools = priv->cur_ps_args->bools; + return bools & flag; + } +} + +static void shader_arb_handle_instruction(const struct wined3d_shader_instruction *ins) { + SHADER_HANDLER hw_fct; + struct shader_arb_ctx_priv *priv = ins->ctx->backend_data; + IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader; + struct if_frame *if_frame; + SHADER_BUFFER *buffer = ins->ctx->buffer; + + /* boolean if */ + if(ins->handler_idx == WINED3DSIH_IF) + { + if_frame = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*if_frame)); + list_add_head(&priv->if_frames, &if_frame->entry); + + if(!priv->muted && get_bool_const(ins, This, ins->src[0].reg.idx) == FALSE) + { + shader_addline(buffer, "#if(FALSE){\n"); + priv->muted = TRUE; + if_frame->muting = TRUE; + } + else shader_addline(buffer, "#if(TRUE) {\n"); + + return; /* Instruction is handled */ + } + else if(ins->handler_idx == WINED3DSIH_IFC) + { + /* IF(bool) and if_cond(a, b) use the same ELSE and ENDIF tokens */ + if_frame = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*if_frame)); + if_frame->ifc = TRUE; + list_add_head(&priv->if_frames, &if_frame->entry); + } + else if(ins->handler_idx == WINED3DSIH_ELSE) + { + struct list *e = list_head(&priv->if_frames); + if_frame = LIST_ENTRY(e, struct if_frame, entry); + + if(if_frame->ifc == FALSE) + { + shader_addline(buffer, "#} else {\n"); + if(!priv->muted && !if_frame->muting) + { + priv->muted = TRUE; + if_frame->muting = TRUE; + } + else if(if_frame->muting) priv->muted = FALSE; + return; /* Instruction is handled. */ + } + /* In case of an ifc, generate a HW shader instruction */ + } + else if(ins->handler_idx == WINED3DSIH_ENDIF) + { + struct list *e = list_head(&priv->if_frames); + if_frame = LIST_ENTRY(e, struct if_frame, entry); + + if(!if_frame->ifc) + { + shader_addline(buffer, "#} endif\n"); + if(if_frame->muting) priv->muted = FALSE; + list_remove(&if_frame->entry); + HeapFree(GetProcessHeap(), 0, if_frame); + return; /* Instruction is handled */ + } + else + { + list_remove(&if_frame->entry); + HeapFree(GetProcessHeap(), 0, if_frame); + /* ifc - generate a hw endif */ + } + } + + if(priv->muted) return; + + /* Select handler */ + hw_fct = shader_arb_instruction_handler_table[ins->handler_idx]; + + /* Unhandled opcode */ + if (!hw_fct) + { + FIXME("Backend can't handle opcode %#x\n", ins->handler_idx); + return; + } + hw_fct(ins); + + shader_arb_add_instruction_modifiers(ins); +} + const shader_backend_t arb_program_shader_backend = { - shader_arb_instruction_handler_table, + shader_arb_handle_instruction, shader_arb_select, shader_arb_select_depth_blt, shader_arb_deselect_depth_blt, @@ -2433,11 +2907,8 @@ const shader_backend_t arb_program_shader_backend = { shader_arb_alloc, shader_arb_free, shader_arb_dirty_const, - shader_arb_generate_pshader, - shader_arb_generate_vshader, shader_arb_get_caps, shader_arb_color_fixup_supported, - shader_arb_add_instruction_modifiers, }; /* ARB_fragment_program fixed function pipeline replacement definitions */ diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c index 2fd79ff738c..9dcdbe6f332 100644 --- a/dlls/wined3d/baseshader.c +++ b/dlls/wined3d/baseshader.c @@ -260,7 +260,7 @@ static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct sh break; case WINED3DSPR_INPUT: - if (!pshader) reg_maps->attributes[reg->idx] = 1; + if (!pshader) reg_maps->input_registers |= 1 << reg->idx; else { if (reg->rel_addr) @@ -341,12 +341,58 @@ static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HAN } } +static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage) +{ + static const char *semantic_names[] = + { + /* WINED3DDECLUSAGE_POSITION */ "SV_POSITION", + /* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT", + /* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES", + /* WINED3DDECLUSAGE_NORMAL */ "NORMAL", + /* WINED3DDECLUSAGE_PSIZE */ "PSIZE", + /* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD", + /* WINED3DDECLUSAGE_TANGENT */ "TANGENT", + /* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL", + /* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR", + /* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT", + /* WINED3DDECLUSAGE_COLOR */ "COLOR", + /* WINED3DDECLUSAGE_FOG */ "FOG", + /* WINED3DDECLUSAGE_DEPTH */ "DEPTH", + /* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE", + }; + + if (usage >= sizeof(semantic_names) / sizeof(*semantic_names)) + { + FIXME("Unrecognized usage %#x\n", usage); + return "UNRECOGNIZED"; + } + + return semantic_names[usage]; +} + +BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) +{ + return !strcmp(semantic_name, shader_semantic_name_from_usage(usage)); +} + +static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e, + const struct wined3d_shader_semantic *s) +{ + e->semantic_name = shader_semantic_name_from_usage(s->usage); + e->semantic_idx = s->usage_idx; + e->sysval_semantic = 0; + e->component_type = 0; + e->register_idx = s->reg.reg.idx; + e->mask = s->reg.write_mask; +} + /* Note that this does not count the loop register * as an address register. */ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, - struct shader_reg_maps *reg_maps, struct wined3d_shader_semantic *semantics_in, - struct wined3d_shader_semantic *semantics_out, const DWORD *byte_code, DWORD constf_size) + struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes, + struct wined3d_shader_signature_element *input_signature, + struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size) { IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; void *fe_data = This->baseShader.frontend_data; @@ -410,15 +456,22 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 /* Vshader: mark attributes used * Pshader: mark 3.0 input registers used, save token */ case WINED3DSPR_INPUT: - if (!pshader) reg_maps->attributes[semantic.reg.reg.idx] = 1; - else reg_maps->packed_input[semantic.reg.reg.idx] = 1; - semantics_in[semantic.reg.reg.idx] = semantic; + reg_maps->input_registers |= 1 << semantic.reg.reg.idx; + if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX) + { + attributes[semantic.reg.reg.idx].usage = semantic.usage; + attributes[semantic.reg.reg.idx].usage_idx = semantic.usage_idx; + } + else + { + shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic); + } break; /* Vshader: mark 3.0 output registers used, save token */ case WINED3DSPR_OUTPUT: - reg_maps->packed_output[semantic.reg.reg.idx] = 1; - semantics_out[semantic.reg.reg.idx] = semantic; + reg_maps->output_registers |= 1 << semantic.reg.reg.idx; + shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic); if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1; break; @@ -493,6 +546,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ++pToken; list_add_head(&This->baseShader.constantsB, &lconst->entry); + reg_maps->local_bool_consts |= (1 << dst.reg.idx); } /* If there's a loop in the shader */ else if (ins.handler_idx == WINED3DSIH_LOOP @@ -534,6 +588,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 else { int i, limit; + BOOL color0_mov = FALSE; /* This will loop over all the registers and try to * make a bitmask of the ones we're interested in. @@ -558,6 +613,11 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 } else { + if(pshader && dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0) + { + IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This; + ps->color0_mov = FALSE; + } shader_record_register_usage(This, reg_maps, &dst_param.reg, pshader); } @@ -597,6 +657,22 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 { reg_maps->bumpmat[dst_param.reg.idx] = TRUE; } + else if(pshader && ins.handler_idx == WINED3DSIH_MOV) + { + /* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to + * COLOROUT 0. If we know this in advance, the ARB shader backend can skip + * the mov and perform the sRGB write correction from the source register. + * + * However, if the mov is only partial, we can't do this, and if the write + * comes from an instruction other than MOV it is hard to do as well. If + * COLOROUT 0 is overwritten partially later, the marker is dropped again + */ + if(dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0) + { + /* Used later when the source register is read */ + color0_mov = TRUE; + } + } } if (ins.handler_idx == WINED3DSIH_NRM) @@ -632,6 +708,17 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 shader_record_register_usage(This, reg_maps, &src_param.reg, pshader); --count; } + + if(color0_mov) + { + IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This; + if(src_param.reg.type == WINED3DSPR_TEMP && + src_param.swizzle == WINED3DSP_NOSWIZZLE) + { + ps->color0_mov = TRUE; + ps->color0_reg = src_param.reg.idx; + } + } } } } @@ -933,7 +1020,6 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, { IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */ - const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table; const struct wined3d_shader_frontend *fe = This->baseShader.frontend; void *fe_data = This->baseShader.frontend_data; struct wined3d_shader_src_param src_rel_addr[4]; @@ -944,7 +1030,6 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, struct wined3d_shader_instruction ins; struct wined3d_shader_context ctx; const DWORD *pToken = pFunction; - SHADER_HANDLER hw_fct; DWORD i; /* Initialize current parsing state */ @@ -993,17 +1078,6 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, continue; } - /* Select handler */ - hw_fct = handler_table[ins.handler_idx]; - - /* Unhandled opcode */ - if (!hw_fct) - { - FIXME("Backend can't handle opcode %#x\n", ins.handler_idx); - pToken += param_size; - continue; - } - /* Destination token */ if (ins.dst_count) fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr); @@ -1017,10 +1091,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, } /* Call appropriate function for output target */ - hw_fct(&ins); - - /* Process instruction modifiers for GLSL apps ( _sat, etc. ) */ - device->shader_backend->shader_add_instruction_modifiers(&ins); + device->shader_backend->shader_handle_instruction(&ins); } } @@ -1218,7 +1289,7 @@ void shader_cleanup(IWineD3DBaseShader *iface) } } -static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0}; +static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {} static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {} static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {} static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {} @@ -1230,19 +1301,6 @@ static void shader_none_destroy(IWineD3DBaseShader *iface) {} static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;} static void shader_none_free(IWineD3DDevice *iface) {} static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;} -static GLuint shader_none_generate_pshader(IWineD3DPixelShader *iface, - SHADER_BUFFER *buffer, const struct ps_compile_args *args) -{ - FIXME("NONE shader backend asked to generate a pixel shader\n"); - return 0; -} -static GLuint shader_none_generate_vshader(IWineD3DVertexShader *iface, - SHADER_BUFFER *buffer, const struct vs_compile_args *args) -{ - FIXME("NONE shader backend asked to generate a vertex shader\n"); - return 0; -} -static void shader_none_add_instruction_modifiers(const struct wined3d_shader_instruction *ins) {} #define GLINFO_LOCATION (*gl_info) static void shader_none_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) @@ -1273,7 +1331,7 @@ static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) } const shader_backend_t none_shader_backend = { - shader_none_instruction_handler_table, + shader_none_handle_instruction, shader_none_select, shader_none_select_depth_blt, shader_none_deselect_depth_blt, @@ -1285,9 +1343,6 @@ const shader_backend_t none_shader_backend = { shader_none_alloc, shader_none_free, shader_none_dirty_const, - shader_none_generate_pshader, - shader_none_generate_vshader, shader_none_get_caps, shader_none_color_fixup_supported, - shader_none_add_instruction_modifiers, }; diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 02215c8af83..ba1e100bb5b 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -259,13 +259,14 @@ static void context_reuse_fbo_entry(IWineD3DDevice *iface, struct fbo_entry *ent } /* GL locking is done by the caller */ -static void context_destroy_fbo_entry(IWineD3DDeviceImpl *This, struct fbo_entry *entry) +static void context_destroy_fbo_entry(IWineD3DDeviceImpl *This, WineD3DContext *context, struct fbo_entry *entry) { if (entry->id) { TRACE("Destroy FBO %d\n", entry->id); context_destroy_fbo(This, &entry->id); } + --context->fbo_entry_count; list_remove(&entry->entry); HeapFree(GetProcessHeap(), 0, entry->render_targets); HeapFree(GetProcessHeap(), 0, entry); @@ -381,11 +382,12 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource { for (i = 0; i < This->numContexts; ++i) { + WineD3DContext *context = This->contexts[i]; struct fbo_entry *entry, *entry2; ENTER_GL(); - LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->contexts[i]->fbo_list, struct fbo_entry, entry) + LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry) { BOOL destroyed = FALSE; UINT j; @@ -394,13 +396,13 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource { if (entry->render_targets[j] == (IWineD3DSurface *)resource) { - context_destroy_fbo_entry(This, entry); + context_destroy_fbo_entry(This, context, entry); destroyed = TRUE; } } if (!destroyed && entry->depth_stencil == (IWineD3DSurface *)resource) - context_destroy_fbo_entry(This, entry); + context_destroy_fbo_entry(This, context, entry); } LEAVE_GL(); @@ -944,6 +946,24 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...\n"); } } + if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { + /* MacOS(radeon X1600 at least, but most likely others too) refuses to draw if GLSL and ARBFP are + * enabled, but the currently bound arbfp program is 0. Enabling ARBFP with prog 0 is invalid, but + * GLSL should bypass this. This causes problems in programs that never use the fixed function pipeline, + * because the ARBFP extension is enabled by the ARBFP pipeline at context creation, but no program + * is ever assigned. + * + * So make sure a program is assigned to each context. The first real ARBFP use will set a different + * program and the dummy program is destroyed when the context is destroyed. + */ + const char *dummy_program = + "!!ARBfp1.0\n" + "MOV result.color, fragment.color.primary;\n" + "END\n"; + GL_EXTCALL(glGenProgramsARB(1, &ret->dummy_arbfp_prog)); + GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ret->dummy_arbfp_prog)); + GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(dummy_program), dummy_program)); + } for(s = 0; s < GL_LIMITS(point_sprite_units); s++) { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + s)); @@ -1053,7 +1073,7 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) { ENTER_GL(); LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &context->fbo_list, struct fbo_entry, entry) { - context_destroy_fbo_entry(This, entry); + context_destroy_fbo_entry(This, context, entry); } if (context->src_fbo) { TRACE("Destroy src FBO %d\n", context->src_fbo); @@ -1063,6 +1083,9 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) { TRACE("Destroy dst FBO %d\n", context->dst_fbo); context_destroy_fbo(This, &context->dst_fbo); } + if(context->dummy_arbfp_prog) { + GL_EXTCALL(glDeleteProgramsARB(1, &context->dummy_arbfp_prog)); + } LEAVE_GL(); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 83af654876f..bb8b9759cb4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -51,9 +51,6 @@ const WINED3DLIGHT WINED3D_default_light = { 0.0 /* Phi */ }; -/* static function declarations */ -static void IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource); - /********************************************************** * Global variable / Constants follow **********************************************************/ @@ -440,6 +437,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, struct wined3d_buffer_desc *desc, const void *data, IUnknown *parent, IWineD3DBuffer **buffer) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info); struct wined3d_buffer *object; HRESULT hr; @@ -457,8 +455,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, FIXME("Ignoring access flags (pool)\n"); - hr = resource_init(&object->resource, WINED3DRTYPE_BUFFER, This, desc->byte_width, - desc->usage, WINED3DFMT_UNKNOWN, WINED3DPOOL_MANAGED, parent); + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, desc->byte_width, + desc->usage, format_desc, WINED3DPOOL_MANAGED, parent); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x\n", hr); @@ -469,8 +467,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, TRACE("Created resource %p\n", object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - TRACE("size %#x, usage=%#x, format %s, memory @ %p, iface @ %p\n", object->resource.size, object->resource.usage, debug_d3dformat(object->resource.format_desc->format), object->resource.allocatedMemory, object); @@ -535,7 +531,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac } object->vtbl = &wined3d_buffer_vtbl; - hr = resource_init(&object->resource, WINED3DRTYPE_BUFFER, This, Size, Usage, format_desc, Pool, parent); + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, Size, Usage, format_desc, Pool, parent); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x\n", hr); @@ -547,8 +543,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac TRACE("(%p) : Created resource %p\n", This, object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - TRACE("(%p) : Size=%d, Usage=0x%08x, FVF=%x, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->resource.allocatedMemory, object); *ppVertexBuffer = (IWineD3DBuffer *)object; @@ -602,7 +596,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface } object->vtbl = &wined3d_buffer_vtbl; - hr = resource_init(&object->resource, WINED3DRTYPE_BUFFER, This, Length, Usage, format_desc, Pool, parent); + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, Length, Usage, format_desc, Pool, parent); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x\n", hr); @@ -614,8 +608,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface TRACE("(%p) : Created resource %p\n", This, object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - if(Pool != WINED3DPOOL_SYSTEMMEM && !(Usage & WINED3DUSAGE_DYNAMIC) && GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) { object->flags |= WINED3D_BUFFER_CREATEBO; } @@ -978,7 +970,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, return WINED3DERR_INVALIDCALL; } - hr = resource_init(&object->resource, WINED3DRTYPE_SURFACE, This, Size, Usage, glDesc, Pool, parent); + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_SURFACE, This, Size, Usage, glDesc, Pool, parent); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x\n", hr); @@ -989,8 +981,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, TRACE("(%p) : Created resource %p\n", This, object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - *ppSurface = (IWineD3DSurface *)object; /* "Standalone" surface */ @@ -1169,7 +1159,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, } object->lpVtbl = &IWineD3DTexture_Vtbl; - hr = resource_init(&object->resource, WINED3DRTYPE_TEXTURE, This, 0, Usage, format_desc, Pool, parent); + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_TEXTURE, This, 0, Usage, format_desc, Pool, parent); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x\n", hr); @@ -1180,8 +1170,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, TRACE("(%p) : Created resource %p\n", This, object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - *ppTexture = (IWineD3DTexture *)object; basetexture_init(&object->baseTexture, Levels, Usage); @@ -1328,7 +1316,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa } object->lpVtbl = &IWineD3DVolumeTexture_Vtbl; - hr = resource_init(&object->resource, WINED3DRTYPE_VOLUMETEXTURE, This, 0, Usage, format_desc, Pool, parent); + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_VOLUMETEXTURE, + This, 0, Usage, format_desc, Pool, parent); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x\n", hr); @@ -1339,8 +1328,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa TRACE("(%p) : Created resource %p\n", This, object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - basetexture_init(&object->baseTexture, Levels, Usage); TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height, @@ -1417,7 +1404,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface, } object->lpVtbl = &IWineD3DVolume_Vtbl; - hr = resource_init(&object->resource, WINED3DRTYPE_VOLUME, This, + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_VOLUME, This, Width * Height * Depth * format_desc->byte_count, Usage, format_desc, Pool, parent); if (FAILED(hr)) { @@ -1429,8 +1416,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface, TRACE("(%p) : Created resource %p\n", This, object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - *ppVolume = (IWineD3DVolume *)object; TRACE("(%p) : W(%d) H(%d) D(%d), Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height, @@ -1507,7 +1492,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface } object->lpVtbl = &IWineD3DCubeTexture_Vtbl; - hr = resource_init(&object->resource, WINED3DRTYPE_CUBETEXTURE, This, 0, Usage, format_desc, Pool, parent); + hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_CUBETEXTURE, This, 0, Usage, format_desc, Pool, parent); if (FAILED(hr)) { WARN("Failed to initialize resource, returning %#x\n", hr); @@ -1518,8 +1503,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface TRACE("(%p) : Created resource %p\n", This, object); - IWineD3DDeviceImpl_AddResource(iface, (IWineD3DResource *)object); - basetexture_init(&object->baseTexture, Levels, Usage); TRACE("(%p) Create Cube Texture\n", This); @@ -2327,7 +2310,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3D return WINED3D_OK; } -static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *iface, IWineD3DVertexDeclaration *vertex_declaration, CONST DWORD *pFunction, IWineD3DVertexShader **ppVertexShader, IUnknown *parent) { +static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *iface, + const DWORD *pFunction, const struct wined3d_shader_signature *output_signature, + IWineD3DVertexShader **ppVertexShader, IUnknown *parent) +{ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DVertexShaderImpl *object; /* NOTE: impl usage is ok, this is a create */ HRESULT hr = WINED3D_OK; @@ -2350,11 +2336,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *ifac TRACE("(%p) : Created vertex shader %p\n", This, *ppVertexShader); - if (vertex_declaration) { - IWineD3DVertexShader_FakeSemantics(*ppVertexShader, vertex_declaration); - } - - hr = IWineD3DVertexShader_SetFunction(*ppVertexShader, pFunction, NULL); + hr = IWineD3DVertexShader_SetFunction(*ppVertexShader, pFunction, output_signature); if (FAILED(hr)) { WARN("(%p) : Failed to set function, returning %#x\n", iface, hr); @@ -7779,30 +7761,28 @@ static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT i * any handles to other resource held by the caller must be closed * (e.g. a texture should release all held surfaces because telling the device that it's been released.) *****************************************************/ -static void IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource){ - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; +void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) +{ + TRACE("(%p) : Adding resource %p\n", This, resource); - TRACE("(%p) : Adding Resource %p\n", This, resource); list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry); } -static void IWineD3DDeviceImpl_RemoveResource(IWineD3DDevice *iface, IWineD3DResource *resource){ - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - +static void device_resource_remove(IWineD3DDeviceImpl *This, IWineD3DResource *resource) +{ TRACE("(%p) : Removing resource %p\n", This, resource); list_remove(&((IWineD3DResourceImpl *) resource)->resource.resource_list_entry); } - -static void WINAPI IWineD3DDeviceImpl_ResourceReleased(IWineD3DDevice *iface, IWineD3DResource *resource){ - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; +void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) +{ WINED3DRESOURCETYPE type = IWineD3DResource_GetType(resource); int counter; TRACE("(%p) : resource %p\n", This, resource); - context_resource_released(iface, resource, type); + context_resource_released((IWineD3DDevice *)This, resource, type); switch (type) { /* TODO: check front and back buffers, rendertargets etc.. possibly swapchains? */ @@ -7917,7 +7897,7 @@ static void WINAPI IWineD3DDeviceImpl_ResourceReleased(IWineD3DDevice *iface, IW /* Remove the resource from the resourceStore */ - IWineD3DDeviceImpl_RemoveResource(iface, resource); + device_resource_remove(This, resource); TRACE("Resource released\n"); @@ -8089,7 +8069,6 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_UpdateSurface, IWineD3DDeviceImpl_GetFrontBufferData, /*** object tracking ***/ - IWineD3DDeviceImpl_ResourceReleased, IWineD3DDeviceImpl_EnumResources }; diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 46c1556653d..eb78782daf5 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -901,7 +901,7 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { * So this is just a check to check that our assumption holds true. If not, write a warning * and reduce the number of vertex samplers or probably disable vertex texture fetch. */ - if(gl_info->max_vertex_samplers && + if(gl_info->max_vertex_samplers && gl_info->max_combined_samplers < 12 && MAX_TEXTURES + gl_info->max_vertex_samplers > gl_info->max_combined_samplers) { FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers\n", gl_info->max_vertex_samplers, gl_info->max_combined_samplers); @@ -1737,7 +1737,7 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Ad strcpy(pIdentifier->Description, This->adapters[Adapter].description); /* Note dx8 doesn't supply a DeviceName */ - if (NULL != pIdentifier->DeviceName) strcpy(pIdentifier->DeviceName, "\\\\.\\DISPLAY"); /* FIXME: May depend on desktop? */ + if (NULL != pIdentifier->DeviceName) strcpy(pIdentifier->DeviceName, "\\\\.\\DISPLAY1"); /* FIXME: May depend on desktop? */ pIdentifier->DriverVersion->u.HighPart = This->adapters[Adapter].gl_info.driver_version_hipart; pIdentifier->DriverVersion->u.LowPart = This->adapters[Adapter].gl_info.driver_version; *(pIdentifier->VendorId) = This->adapters[Adapter].gl_info.gl_vendor; @@ -1915,7 +1915,10 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U /* TODO: handle Windowed, add more quality levels */ - if (WINED3DMULTISAMPLE_NONE == MultiSampleType) return WINED3D_OK; + if (WINED3DMULTISAMPLE_NONE == MultiSampleType) { + if(pQualityLevels) *pQualityLevels = 1; + return WINED3D_OK; + } /* By default multisampling is disabled right now as it causes issues * on some Nvidia driver versions and it doesn't work well in combination diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index e655b1ca625..c92659faf8c 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -925,13 +925,11 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, if(i == -1) { LEAVE_GL(); ERR("Feedback failed. Expected %d elements back\n", buffer_size); - Sleep(10000); HeapFree(GetProcessHeap(), 0, feedbuffer); return WINED3DERR_DRIVERINTERNALERROR; } else if(i != buffer_size) { LEAVE_GL(); ERR("Unexpected amount of elements returned. Expected %d, got %d\n", buffer_size, i); - Sleep(10000); HeapFree(GetProcessHeap(), 0, feedbuffer); return WINED3DERR_DRIVERINTERNALERROR; } else { diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index c978e5b0c5a..2385dbc8efd 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -122,6 +122,53 @@ typedef struct { struct vs_compile_args vs_args; } glsl_program_key_t; +struct shader_glsl_ctx_priv { + const struct vs_compile_args *cur_vs_args; + const struct ps_compile_args *cur_ps_args; +}; + +struct glsl_ps_compiled_shader +{ + struct ps_compile_args args; + GLhandleARB prgId; +}; + +struct glsl_pshader_private +{ + struct glsl_ps_compiled_shader *gl_shaders; + UINT num_gl_shaders, shader_array_size; +}; + +struct glsl_vs_compiled_shader +{ + struct vs_compile_args args; + GLhandleARB prgId; +}; + +struct glsl_vshader_private +{ + struct glsl_vs_compiled_shader *gl_shaders; + UINT num_gl_shaders, shader_array_size; +}; + +/* Extract a line from the info log. + * Note that this modifies the source string. */ +static char *get_info_log_line(char **ptr) +{ + char *p, *q; + + p = *ptr; + if (!(q = strstr(p, "\n"))) + { + if (!*p) return NULL; + *ptr += strlen(p); + return p; + } + *q = '\0'; + *ptr = q + 1; + + return p; +} /** Prints the GLSL info log which will contain error messages if they exist */ /* GL locking is done by the caller */ @@ -157,6 +204,8 @@ static void print_glsl_info_log(const WineD3D_GL_Info *gl_info, GLhandleARB obj) * that if there are errors. */ if (infologLength > 1) { + char *ptr, *line; + /* Fglrx doesn't terminate the string properly, but it tells us the proper length. * So use HEAP_ZERO_MEMORY to avoid uninitialized bytes */ @@ -170,10 +219,17 @@ static void print_glsl_info_log(const WineD3D_GL_Info *gl_info, GLhandleARB obj) break; } } - if(is_spam) { - TRACE("Spam received from GLSL shader #%u: %s\n", obj, debugstr_a(infoLog)); - } else { - FIXME("Error received from GLSL shader #%u: %s\n", obj, debugstr_a(infoLog)); + + ptr = infoLog; + if (is_spam) + { + TRACE("Spam received from GLSL shader #%u:\n", obj); + while ((line = get_info_log_line(&ptr))) TRACE(" %s\n", line); + } + else + { + FIXME("Error received from GLSL shader #%u:\n", obj); + while ((line = get_info_log_line(&ptr))) FIXME(" %s\n", line); } HeapFree(GetProcessHeap(), 0, infoLog); } @@ -937,9 +993,16 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s } /* Declare attributes */ - for (i = 0; i < This->baseShader.limits.attributes; i++) { - if (reg_maps->attributes[i]) + if (reg_maps->shader_version.type == WINED3D_SHADER_TYPE_VERTEX) + { + WORD map = reg_maps->input_registers; + + for (i = 0; map; map >>= 1, ++i) + { + if (!(map & 1)) continue; + shader_addline(buffer, "attribute vec4 attrib%i;\n", i); + } } /* Declare loop registers aLx */ @@ -1089,7 +1152,8 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * /* vertex shaders */ if (!pshader) { - if (((IWineD3DVertexShaderImpl *)This)->cur_args->swizzle_map & (1 << reg->idx)) *is_color = TRUE; + struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; + if (priv->cur_vs_args->swizzle_map & (1 << reg->idx)) *is_color = TRUE; sprintf(register_name, "attrib%u", reg->idx); break; } @@ -1623,11 +1687,11 @@ static void PRINTF_ATTR(8, 9) shader_glsl_gen_sample_code(const struct wined3d_s if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type)) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader; - fixup = This->cur_args->color_fixup[sampler]; + struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; + fixup = priv->cur_ps_args->color_fixup[sampler]; sampler_base = "Psampler"; - if(This->cur_args->np2_fixup & (1 << sampler)) { + if(priv->cur_ps_args->np2_fixup & (1 << sampler)) { if(bias) { FIXME("Biased sampling from NP2 textures is unsupported\n"); } else { @@ -3143,51 +3207,51 @@ static void pshader_glsl_dp2add(const struct wined3d_shader_instruction *ins) } static void pshader_glsl_input_pack(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer, - const struct wined3d_shader_semantic *semantics_in, const struct shader_reg_maps *reg_maps, + const struct wined3d_shader_signature_element *input_signature, const struct shader_reg_maps *reg_maps, enum vertexprocessing_mode vertexprocessing) { unsigned int i; IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; + WORD map = reg_maps->input_registers; - for (i = 0; i < MAX_REG_INPUT; ++i) + for (i = 0; map; map >>= 1, ++i) { - DWORD usage, usage_idx; + const char *semantic_name; + UINT semantic_idx; char reg_mask[6]; /* Unused */ - if (!reg_maps->packed_input[i]) continue; + if (!(map & 1)) continue; - usage = semantics_in[i].usage; - usage_idx = semantics_in[i].usage_idx; - shader_glsl_get_write_mask(&semantics_in[i].reg, reg_mask); + semantic_name = input_signature[i].semantic_name; + semantic_idx = input_signature[i].semantic_idx; + shader_glsl_write_mask_to_str(input_signature[i].mask, reg_mask); - switch (usage) + if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_TEXCOORD)) { - case WINED3DDECLUSAGE_TEXCOORD: - if (usage_idx < 8 && vertexprocessing == pretransformed) - shader_addline(buffer, "IN[%u]%s = gl_TexCoord[%u]%s;\n", - This->input_reg_map[i], reg_mask, usage_idx, reg_mask); - else - shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", - This->input_reg_map[i], reg_mask, reg_mask); - break; - - case WINED3DDECLUSAGE_COLOR: - if (usage_idx == 0) - shader_addline(buffer, "IN[%u]%s = vec4(gl_Color)%s;\n", - This->input_reg_map[i], reg_mask, reg_mask); - else if (usage_idx == 1) - shader_addline(buffer, "IN[%u]%s = vec4(gl_SecondaryColor)%s;\n", - This->input_reg_map[i], reg_mask, reg_mask); - else - shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", - This->input_reg_map[i], reg_mask, reg_mask); - break; - - default: + if (semantic_idx < 8 && vertexprocessing == pretransformed) + shader_addline(buffer, "IN[%u]%s = gl_TexCoord[%u]%s;\n", + This->input_reg_map[i], reg_mask, semantic_idx, reg_mask); + else + shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", + This->input_reg_map[i], reg_mask, reg_mask); + } + else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR)) + { + if (semantic_idx == 0) + shader_addline(buffer, "IN[%u]%s = vec4(gl_Color)%s;\n", + This->input_reg_map[i], reg_mask, reg_mask); + else if (semantic_idx == 1) + shader_addline(buffer, "IN[%u]%s = vec4(gl_SecondaryColor)%s;\n", + This->input_reg_map[i], reg_mask, reg_mask); + else shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", This->input_reg_map[i], reg_mask, reg_mask); - break; + } + else + { + shader_addline(buffer, "IN[%u]%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", + This->input_reg_map[i], reg_mask, reg_mask); } } } @@ -3243,27 +3307,32 @@ static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const WineD } static void handle_ps3_input(SHADER_BUFFER *buffer, const WineD3D_GL_Info *gl_info, const DWORD *map, - const struct wined3d_shader_semantic *semantics_in, const struct shader_reg_maps *reg_maps_in, - const struct wined3d_shader_semantic *semantics_out, const struct shader_reg_maps *reg_maps_out) + const struct wined3d_shader_signature_element *input_signature, const struct shader_reg_maps *reg_maps_in, + const struct wined3d_shader_signature_element *output_signature, const struct shader_reg_maps *reg_maps_out) { unsigned int i, j; - DWORD usage, usage_idx, usage_out, usage_idx_out; + const char *semantic_name_in, *semantic_name_out; + UINT semantic_idx_in, semantic_idx_out; DWORD *set; DWORD in_idx; DWORD in_count = vec4_varyings(3, gl_info); char reg_mask[6], reg_mask_out[6]; char destination[50]; + WORD input_map, output_map; set = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*set) * (in_count + 2)); - if (!semantics_out) { + if (!output_signature) + { /* Save gl_FrontColor & gl_FrontSecondaryColor before overwriting them. */ shader_addline(buffer, "vec4 front_color = gl_FrontColor;\n"); shader_addline(buffer, "vec4 front_secondary_color = gl_FrontSecondaryColor;\n"); } - for(i = 0; i < MAX_REG_INPUT; i++) { - if (!reg_maps_in->packed_input[i]) continue; + input_map = reg_maps_in->input_registers; + for (i = 0; input_map; input_map >>= 1, ++i) + { + if (!(input_map & 1)) continue; in_idx = map[i]; if (in_idx >= (in_count + 2)) { @@ -3284,56 +3353,65 @@ static void handle_ps3_input(SHADER_BUFFER *buffer, const WineD3D_GL_Info *gl_in sprintf(destination, "IN[%u]", in_idx); } - usage = semantics_in[i].usage; - usage_idx = semantics_in[i].usage_idx; - set[map[i]] = shader_glsl_get_write_mask(&semantics_in[i].reg, reg_mask); - - if(!semantics_out) { - switch(usage) { - case WINED3DDECLUSAGE_COLOR: - if (usage_idx == 0) - shader_addline(buffer, "%s%s = front_color%s;\n", - destination, reg_mask, reg_mask); - else if (usage_idx == 1) - shader_addline(buffer, "%s%s = front_secondary_color%s;\n", - destination, reg_mask, reg_mask); - else - shader_addline(buffer, "%s%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", - destination, reg_mask, reg_mask); - break; - - case WINED3DDECLUSAGE_TEXCOORD: - if (usage_idx < 8) { - shader_addline(buffer, "%s%s = gl_TexCoord[%u]%s;\n", - destination, reg_mask, usage_idx, reg_mask); - } else { - shader_addline(buffer, "%s%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", - destination, reg_mask, reg_mask); - } - break; - - case WINED3DDECLUSAGE_FOG: - shader_addline(buffer, "%s%s = vec4(gl_FogFragCoord, 0.0, 0.0, 0.0)%s;\n", - destination, reg_mask, reg_mask); - break; + semantic_name_in = input_signature[i].semantic_name; + semantic_idx_in = input_signature[i].semantic_idx; + set[map[i]] = input_signature[i].mask; + shader_glsl_write_mask_to_str(input_signature[i].mask, reg_mask); - default: + if (!output_signature) + { + if (shader_match_semantic(semantic_name_in, WINED3DDECLUSAGE_COLOR)) + { + if (semantic_idx_in == 0) + shader_addline(buffer, "%s%s = front_color%s;\n", + destination, reg_mask, reg_mask); + else if (semantic_idx_in == 1) + shader_addline(buffer, "%s%s = front_secondary_color%s;\n", + destination, reg_mask, reg_mask); + else + shader_addline(buffer, "%s%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", + destination, reg_mask, reg_mask); + } + else if (shader_match_semantic(semantic_name_in, WINED3DDECLUSAGE_TEXCOORD)) + { + if (semantic_idx_in < 8) + { + shader_addline(buffer, "%s%s = gl_TexCoord[%u]%s;\n", + destination, reg_mask, semantic_idx_in, reg_mask); + } + else + { shader_addline(buffer, "%s%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", - destination, reg_mask, reg_mask); + destination, reg_mask, reg_mask); + } + } + else if (shader_match_semantic(semantic_name_in, WINED3DDECLUSAGE_FOG)) + { + shader_addline(buffer, "%s%s = vec4(gl_FogFragCoord, 0.0, 0.0, 0.0)%s;\n", + destination, reg_mask, reg_mask); + } + else + { + shader_addline(buffer, "%s%s = vec4(0.0, 0.0, 0.0, 0.0)%s;\n", + destination, reg_mask, reg_mask); } } else { BOOL found = FALSE; - for(j = 0; j < MAX_REG_OUTPUT; j++) { - if (!reg_maps_out->packed_output[j]) continue; - usage_out = semantics_out[j].usage; - usage_idx_out = semantics_out[j].usage_idx; - shader_glsl_get_write_mask(&semantics_out[j].reg, reg_mask_out); + output_map = reg_maps_out->output_registers; + for (j = 0; output_map; output_map >>= 1, ++j) + { + if (!(output_map & 1)) continue; + + semantic_name_out = output_signature[j].semantic_name; + semantic_idx_out = output_signature[j].semantic_idx; + shader_glsl_write_mask_to_str(output_signature[j].mask, reg_mask_out); - if(usage == usage_out && - usage_idx == usage_idx_out) { + if (semantic_idx_in == semantic_idx_out + && !strcmp(semantic_name_in, semantic_name_out)) + { shader_addline(buffer, "%s%s = OUT[%u]%s;\n", - destination, reg_mask, j, reg_mask); + destination, reg_mask, j, reg_mask_out); found = TRUE; } } @@ -3400,9 +3478,10 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs DWORD ps_major = ps ? ps->baseShader.reg_maps.shader_version.major : 0; unsigned int i; SHADER_BUFFER buffer; - DWORD usage, usage_idx, writemask; + const char *semantic_name; + UINT semantic_idx; char reg_mask[6]; - const struct wined3d_shader_semantic *semantics_out; + const struct wined3d_shader_signature_element *output_signature; shader_buffer_init(&buffer); @@ -3427,87 +3506,87 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs shader_addline(&buffer, "void order_ps_input() { /* do nothing */ }\n"); } } else if(ps_major < 3 && vs_major >= 3) { + WORD map = vs->baseShader.reg_maps.output_registers; + /* The vertex shader writes to its own varyings, the pixel shader needs them in the builtin ones */ - semantics_out = vs->semantics_out; + output_signature = vs->output_signature; shader_addline(&buffer, "void order_ps_input(in vec4 OUT[%u]) {\n", MAX_REG_OUTPUT); - for(i = 0; i < MAX_REG_OUTPUT; i++) { - if (!vs->baseShader.reg_maps.packed_output[i]) continue; - - usage = semantics_out[i].usage; - usage_idx = semantics_out[i].usage_idx; - writemask = shader_glsl_get_write_mask(&semantics_out[i].reg, reg_mask); - - switch(usage) { - case WINED3DDECLUSAGE_COLOR: - if (usage_idx == 0) - shader_addline(&buffer, "gl_FrontColor%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); - else if (usage_idx == 1) - shader_addline(&buffer, "gl_FrontSecondaryColor%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); - break; - - case WINED3DDECLUSAGE_POSITION: - shader_addline(&buffer, "gl_Position%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); - break; - - case WINED3DDECLUSAGE_TEXCOORD: - if (usage_idx < 8) { - if(!(GLINFO_LOCATION).set_texcoord_w || ps_major > 0) writemask |= WINED3DSP_WRITEMASK_3; + for (i = 0; map; map >>= 1, ++i) + { + DWORD write_mask; - shader_addline(&buffer, "gl_TexCoord[%u]%s = OUT[%u]%s;\n", - usage_idx, reg_mask, i, reg_mask); - if(!(writemask & WINED3DSP_WRITEMASK_3)) { - shader_addline(&buffer, "gl_TexCoord[%u].w = 1.0;\n", usage_idx); - } - } - break; + if (!(map & 1)) continue; - case WINED3DDECLUSAGE_PSIZE: - shader_addline(&buffer, "gl_PointSize = OUT[%u].x;\n", i); - break; + semantic_name = output_signature[i].semantic_name; + semantic_idx = output_signature[i].semantic_idx; + write_mask = output_signature[i].mask; + shader_glsl_write_mask_to_str(write_mask, reg_mask); - case WINED3DDECLUSAGE_FOG: - shader_addline(&buffer, "gl_FogFragCoord = OUT[%u].%c;\n", i, reg_mask[1]); - break; + if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_COLOR)) + { + if (semantic_idx == 0) + shader_addline(&buffer, "gl_FrontColor%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); + else if (semantic_idx == 1) + shader_addline(&buffer, "gl_FrontSecondaryColor%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); + } + else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)) + { + shader_addline(&buffer, "gl_Position%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); + } + else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_TEXCOORD)) + { + if (semantic_idx < 8) + { + if (!(GLINFO_LOCATION).set_texcoord_w || ps_major > 0) write_mask |= WINED3DSP_WRITEMASK_3; - default: - break; + shader_addline(&buffer, "gl_TexCoord[%u]%s = OUT[%u]%s;\n", + semantic_idx, reg_mask, i, reg_mask); + if (!(write_mask & WINED3DSP_WRITEMASK_3)) + shader_addline(&buffer, "gl_TexCoord[%u].w = 1.0;\n", semantic_idx); + } + } + else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)) + { + shader_addline(&buffer, "gl_PointSize = OUT[%u].x;\n", i); + } + else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_FOG)) + { + shader_addline(&buffer, "gl_FogFragCoord = OUT[%u].%c;\n", i, reg_mask[1]); } } shader_addline(&buffer, "}\n"); } else if(ps_major >= 3 && vs_major >= 3) { - semantics_out = vs->semantics_out; + WORD map = vs->baseShader.reg_maps.output_registers; + + output_signature = vs->output_signature; /* This one is tricky: a 3.0 pixel shader reads from a 3.0 vertex shader */ shader_addline(&buffer, "varying vec4 IN[%u];\n", vec4_varyings(3, gl_info)); shader_addline(&buffer, "void order_ps_input(in vec4 OUT[%u]) {\n", MAX_REG_OUTPUT); /* First, sort out position and point size. Those are not passed to the pixel shader */ - for(i = 0; i < MAX_REG_OUTPUT; i++) { - if (!vs->baseShader.reg_maps.packed_output[i]) continue; - - usage = semantics_out[i].usage; - usage_idx = semantics_out[i].usage_idx; - shader_glsl_get_write_mask(&semantics_out[i].reg, reg_mask); - - switch(usage) { - case WINED3DDECLUSAGE_POSITION: - shader_addline(&buffer, "gl_Position%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); - break; + for (i = 0; map; map >>= 1, ++i) + { + if (!(map & 1)) continue; - case WINED3DDECLUSAGE_PSIZE: - shader_addline(&buffer, "gl_PointSize = OUT[%u].x;\n", i); - break; + semantic_name = output_signature[i].semantic_name; + shader_glsl_write_mask_to_str(output_signature[i].mask, reg_mask); - default: - break; + if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_POSITION)) + { + shader_addline(&buffer, "gl_Position%s = OUT[%u]%s;\n", reg_mask, i, reg_mask); + } + else if (shader_match_semantic(semantic_name, WINED3DDECLUSAGE_PSIZE)) + { + shader_addline(&buffer, "gl_PointSize = OUT[%u].x;\n", i); } } /* Then, fix the pixel shader input */ - handle_ps3_input(&buffer, gl_info, ps->input_reg_map, - ps->semantics_in, &ps->baseShader.reg_maps, semantics_out, &vs->baseShader.reg_maps); + handle_ps3_input(&buffer, gl_info, ps->input_reg_map, ps->input_signature, + &ps->baseShader.reg_maps, output_signature, &vs->baseShader.reg_maps); shader_addline(&buffer, "}\n"); } else if(ps_major >= 3 && vs_major < 3) { @@ -3517,7 +3596,8 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs * point size, but we depend on the optimizers kindness to find out that the pixel shader doesn't * read gl_TexCoord and gl_ColorX, otherwise we'll run out of varyings */ - handle_ps3_input(&buffer, gl_info, ps->input_reg_map, ps->semantics_in, &ps->baseShader.reg_maps, NULL, NULL); + handle_ps3_input(&buffer, gl_info, ps->input_reg_map, ps->input_signature, + &ps->baseShader.reg_maps, NULL, NULL); shader_addline(&buffer, "}\n"); } else { ERR("Unexpected vertex and pixel shader version condition: vs: %d, ps: %d\n", vs_major, ps_major); @@ -3552,133 +3632,430 @@ static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, const WineD checkGLcall("Hardcoding local constants\n"); } -/** Sets the GLSL program ID for the given pixel and vertex shader combination. - * It sets the programId on the current StateBlock (because it should be called - * inside of the DrawPrimitive() part of the render loop). - * - * If a program for the given combination does not exist, create one, and store - * the program in the hash table. If it creates a program, it will link the - * given objects, too. - */ - /* GL locking is done by the caller */ -static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) { - IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - struct shader_glsl_priv *priv = This->shader_priv; - const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; - IWineD3DPixelShader *pshader = This->stateBlock->pixelShader; - IWineD3DVertexShader *vshader = This->stateBlock->vertexShader; - struct glsl_shader_prog_link *entry = NULL; - GLhandleARB programId = 0; - GLhandleARB reorder_shader_id = 0; - unsigned int i; - char glsl_name[8]; - GLhandleARB vshader_id, pshader_id; - struct ps_compile_args ps_compile_args; - struct vs_compile_args vs_compile_args; - - if(use_vs) { - find_vs_compile_args((IWineD3DVertexShaderImpl*)This->stateBlock->vertexShader, This->stateBlock, &vs_compile_args); - } else { - /* FIXME: Do we really have to spend CPU cycles to generate a few zeroed bytes? */ - memset(&vs_compile_args, 0, sizeof(vs_compile_args)); - } - if(use_ps) { - find_ps_compile_args((IWineD3DPixelShaderImpl*)This->stateBlock->pixelShader, This->stateBlock, &ps_compile_args); - } else { - /* FIXME: Do we really have to spend CPU cycles to generate a few zeroed bytes? */ - memset(&ps_compile_args, 0, sizeof(ps_compile_args)); - } - entry = get_glsl_program_entry(priv, vshader, pshader, &vs_compile_args, &ps_compile_args); - if (entry) { - priv->glsl_program = entry; - return; - } +static GLuint shader_glsl_generate_pshader(IWineD3DPixelShaderImpl *This, + SHADER_BUFFER *buffer, const struct ps_compile_args *args) +{ + const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps; + CONST DWORD *function = This->baseShader.function; + const char *fragcolor; + const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info; + struct shader_glsl_ctx_priv priv_ctx; - /* If we get to this point, then no matching program exists, so we create one */ - programId = GL_EXTCALL(glCreateProgramObjectARB()); - TRACE("Created new GLSL shader program %u\n", programId); + /* Create the hw GLSL shader object and assign it as the shader->prgId */ + GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB)); - /* Create the entry */ - entry = HeapAlloc(GetProcessHeap(), 0, sizeof(struct glsl_shader_prog_link)); - entry->programId = programId; - entry->vshader = vshader; - entry->pshader = pshader; - entry->vs_args = vs_compile_args; - entry->ps_args = ps_compile_args; - entry->constant_version = 0; - /* Add the hash table entry */ - add_glsl_program_entry(priv, entry); + memset(&priv_ctx, 0, sizeof(priv_ctx)); + priv_ctx.cur_ps_args = args; - /* Set the current program */ - priv->glsl_program = entry; + shader_addline(buffer, "#version 120\n"); - if(use_vs) { - vshader_id = find_gl_vshader((IWineD3DVertexShaderImpl *) vshader, &vs_compile_args); - } else { - vshader_id = 0; + if (GL_SUPPORT(ARB_DRAW_BUFFERS)) { + shader_addline(buffer, "#extension GL_ARB_draw_buffers : enable\n"); } - - /* Attach GLSL vshader */ - if (vshader_id) { - const unsigned int max_attribs = 16; /* TODO: Will this always be the case? It is at the moment... */ - char tmp_name[10]; - - reorder_shader_id = generate_param_reorder_function(vshader, pshader, gl_info); - TRACE("Attaching GLSL shader object %u to program %u\n", reorder_shader_id, programId); - GL_EXTCALL(glAttachObjectARB(programId, reorder_shader_id)); - checkGLcall("glAttachObjectARB"); - /* Flag the reorder function for deletion, then it will be freed automatically when the program - * is destroyed + if(GL_SUPPORT(ARB_SHADER_TEXTURE_LOD) && reg_maps->usestexldd) { + shader_addline(buffer, "#extension GL_ARB_shader_texture_lod : enable\n"); + } + if (GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + /* The spec says that it doesn't have to be explicitly enabled, but the nvidia + * drivers write a warning if we don't do so */ - GL_EXTCALL(glDeleteObjectARB(reorder_shader_id)); - - TRACE("Attaching GLSL shader object %u to program %u\n", vshader_id, programId); - GL_EXTCALL(glAttachObjectARB(programId, vshader_id)); - checkGLcall("glAttachObjectARB"); - - /* Bind vertex attributes to a corresponding index number to match - * the same index numbers as ARB_vertex_programs (makes loading - * vertex attributes simpler). With this method, we can use the - * exact same code to load the attributes later for both ARB and - * GLSL shaders. - * - * We have to do this here because we need to know the Program ID - * in order to make the bindings work, and it has to be done prior - * to linking the GLSL program. */ - for (i = 0; i < max_attribs; ++i) { - if (((IWineD3DBaseShaderImpl*)vshader)->baseShader.reg_maps.attributes[i]) { - snprintf(tmp_name, sizeof(tmp_name), "attrib%i", i); - GL_EXTCALL(glBindAttribLocationARB(programId, i, tmp_name)); - } - } - checkGLcall("glBindAttribLocationARB"); - - list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry); + shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n"); } - if(use_ps) { - pshader_id = find_gl_pshader((IWineD3DPixelShaderImpl *) pshader, &ps_compile_args); - } else { - pshader_id = 0; + /* Base Declarations */ + shader_generate_glsl_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION, args); + + /* Pack 3.0 inputs */ + if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader) + { + pshader_glsl_input_pack((IWineD3DPixelShader *) This, buffer, This->input_signature, reg_maps, args->vp_mode); } - /* Attach GLSL pshader */ - if (pshader_id) { - TRACE("Attaching GLSL shader object %u to program %u\n", pshader_id, programId); - GL_EXTCALL(glAttachObjectARB(programId, pshader_id)); - checkGLcall("glAttachObjectARB"); + /* Base Shader Body */ + shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, &priv_ctx); - list_add_head(&((IWineD3DBaseShaderImpl *)pshader)->baseShader.linked_programs, &entry->pshader_entry); + /* Pixel shaders < 2.0 place the resulting color in R0 implicitly */ + if (reg_maps->shader_version.major < 2) + { + /* Some older cards like GeforceFX ones don't support multiple buffers, so also not gl_FragData */ + if(GL_SUPPORT(ARB_DRAW_BUFFERS)) + shader_addline(buffer, "gl_FragData[0] = R0;\n"); + else + shader_addline(buffer, "gl_FragColor = R0;\n"); } - /* Link the program */ - TRACE("Linking GLSL shader program %u\n", programId); - GL_EXTCALL(glLinkProgramARB(programId)); - print_glsl_info_log(&GLINFO_LOCATION, programId); - - entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * GL_LIMITS(vshader_constantsF)); - for (i = 0; i < GL_LIMITS(vshader_constantsF); ++i) { + if(GL_SUPPORT(ARB_DRAW_BUFFERS)) { + fragcolor = "gl_FragData[0]"; + } else { + fragcolor = "gl_FragColor"; + } + if(args->srgb_correction) { + shader_addline(buffer, "tmp0.xyz = pow(%s.xyz, vec3(%f, %f, %f)) * vec3(%f, %f, %f) - vec3(%f, %f, %f);\n", + fragcolor, srgb_pow, srgb_pow, srgb_pow, srgb_mul_high, srgb_mul_high, srgb_mul_high, + srgb_sub_high, srgb_sub_high, srgb_sub_high); + shader_addline(buffer, "tmp1.xyz = %s.xyz * srgb_mul_low.xyz;\n", fragcolor); + shader_addline(buffer, "%s.x = %s.x < srgb_comparison.x ? tmp1.x : tmp0.x;\n", fragcolor, fragcolor); + shader_addline(buffer, "%s.y = %s.y < srgb_comparison.y ? tmp1.y : tmp0.y;\n", fragcolor, fragcolor); + shader_addline(buffer, "%s.z = %s.z < srgb_comparison.z ? tmp1.z : tmp0.z;\n", fragcolor, fragcolor); + shader_addline(buffer, "%s = clamp(%s, 0.0, 1.0);\n", fragcolor, fragcolor); + } + /* Pixel shader < 3.0 do not replace the fog stage. + * This implements linear fog computation and blending. + * TODO: non linear fog + * NOTE: gl_Fog.start and gl_Fog.end don't hold fog start s and end e but + * -1/(e-s) and e/(e-s) respectively. + */ + if (reg_maps->shader_version.major < 3) + { + switch(args->fog) { + case FOG_OFF: break; + case FOG_LINEAR: + shader_addline(buffer, "float fogstart = -1.0 / (gl_Fog.end - gl_Fog.start);\n"); + shader_addline(buffer, "float fogend = gl_Fog.end * -fogstart;\n"); + shader_addline(buffer, "float Fog = clamp(gl_FogFragCoord * fogstart + fogend, 0.0, 1.0);\n"); + shader_addline(buffer, "%s.xyz = mix(gl_Fog.color.xyz, %s.xyz, Fog);\n", fragcolor, fragcolor); + break; + case FOG_EXP: + /* Fog = e^(-gl_Fog.density * gl_FogFragCoord) */ + shader_addline(buffer, "float Fog = exp(-gl_Fog.density * gl_FogFragCoord);\n"); + shader_addline(buffer, "Fog = clamp(Fog, 0.0, 1.0);\n"); + shader_addline(buffer, "%s.xyz = mix(gl_Fog.color.xyz, %s.xyz, Fog);\n", fragcolor, fragcolor); + break; + case FOG_EXP2: + /* Fog = e^(-(gl_Fog.density * gl_FogFragCoord)^2) */ + shader_addline(buffer, "float Fog = exp(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord);\n"); + shader_addline(buffer, "Fog = clamp(Fog, 0.0, 1.0);\n"); + shader_addline(buffer, "%s.xyz = mix(gl_Fog.color.xyz, %s.xyz, Fog);\n", fragcolor, fragcolor); + break; + } + } + + shader_addline(buffer, "}\n"); + + TRACE("Compiling shader object %u\n", shader_obj); + GL_EXTCALL(glShaderSourceARB(shader_obj, 1, (const char**)&buffer->buffer, NULL)); + GL_EXTCALL(glCompileShaderARB(shader_obj)); + print_glsl_info_log(&GLINFO_LOCATION, shader_obj); + + /* Store the shader object */ + return shader_obj; +} + +/* GL locking is done by the caller */ +static GLuint shader_glsl_generate_vshader(IWineD3DVertexShaderImpl *This, + SHADER_BUFFER *buffer, const struct vs_compile_args *args) +{ + const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps; + CONST DWORD *function = This->baseShader.function; + const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info; + struct shader_glsl_ctx_priv priv_ctx; + + /* Create the hw GLSL shader program and assign it as the shader->prgId */ + GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB)); + + shader_addline(buffer, "#version 120\n"); + + memset(&priv_ctx, 0, sizeof(priv_ctx)); + priv_ctx.cur_vs_args = args; + + /* Base Declarations */ + shader_generate_glsl_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION, NULL); + + /* Base Shader Body */ + shader_generate_main((IWineD3DBaseShader*)This, buffer, reg_maps, function, &priv_ctx); + + /* Unpack 3.0 outputs */ + if (reg_maps->shader_version.major >= 3) shader_addline(buffer, "order_ps_input(OUT);\n"); + else shader_addline(buffer, "order_ps_input();\n"); + + /* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used + * or if the fragment depth is used. If the fragment depth is used(FOGTABLEMODE != NONE), + * the fog frag coord is thrown away. If the fog frag coord is used, but not written by + * the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0) + */ + if(args->fog_src == VS_FOG_Z) { + shader_addline(buffer, "gl_FogFragCoord = gl_Position.z;\n"); + } else if (!reg_maps->fog) { + shader_addline(buffer, "gl_FogFragCoord = 0.0;\n"); + } + + /* Write the final position. + * + * OpenGL coordinates specify the center of the pixel while d3d coords specify + * the corner. The offsets are stored in z and w in posFixup. posFixup.y contains + * 1.0 or -1.0 to turn the rendering upside down for offscreen rendering. PosFixup.x + * contains 1.0 to allow a mad. + */ + shader_addline(buffer, "gl_Position.y = gl_Position.y * posFixup.y;\n"); + shader_addline(buffer, "gl_Position.xy += posFixup.zw * gl_Position.ww;\n"); + shader_addline(buffer, "gl_ClipVertex = gl_Position;\n"); + + /* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c + * + * Basically we want (in homogeneous coordinates) z = z * 2 - 1. However, shaders are run + * before the homogeneous divide, so we have to take the w into account: z = ((z / w) * 2 - 1) * w, + * which is the same as z = z * 2 - w. + */ + shader_addline(buffer, "gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;\n"); + + shader_addline(buffer, "}\n"); + + TRACE("Compiling shader object %u\n", shader_obj); + GL_EXTCALL(glShaderSourceARB(shader_obj, 1, (const char**)&buffer->buffer, NULL)); + GL_EXTCALL(glCompileShaderARB(shader_obj)); + print_glsl_info_log(&GLINFO_LOCATION, shader_obj); + + return shader_obj; +} + +static GLhandleARB find_glsl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args) +{ + UINT i; + DWORD new_size; + struct glsl_ps_compiled_shader *new_array; + SHADER_BUFFER buffer; + struct glsl_pshader_private *shader_data; + GLhandleARB ret; + + if(!shader->backend_priv) { + shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data)); + } + shader_data = shader->backend_priv; + + /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2), + * so a linear search is more performant than a hashmap or a binary search + * (cache coherency etc) + */ + for(i = 0; i < shader_data->num_gl_shaders; i++) { + if(memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) { + return shader_data->gl_shaders[i].prgId; + } + } + + TRACE("No matching GL shader found, compiling a new shader\n"); + if(shader_data->shader_array_size == shader_data->num_gl_shaders) { + if (shader_data->num_gl_shaders) + { + new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2); + new_array = HeapReAlloc(GetProcessHeap(), 0, shader_data->gl_shaders, + new_size * sizeof(*shader_data->gl_shaders)); + } else { + new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader_data->gl_shaders)); + new_size = 1; + } + + if(!new_array) { + ERR("Out of memory\n"); + return 0; + } + shader_data->gl_shaders = new_array; + shader_data->shader_array_size = new_size; + } + + shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args; + + pixelshader_update_samplers(&shader->baseShader.reg_maps, + ((IWineD3DDeviceImpl *)shader->baseShader.device)->stateBlock->textures); + + shader_buffer_init(&buffer); + ret = shader_glsl_generate_pshader(shader, &buffer, args); + shader_buffer_free(&buffer); + shader_data->gl_shaders[shader_data->num_gl_shaders++].prgId = ret; + + return ret; +} + +static inline BOOL vs_args_equal(const struct vs_compile_args *stored, const struct vs_compile_args *new, + const DWORD use_map) { + if((stored->swizzle_map & use_map) != new->swizzle_map) return FALSE; + return stored->fog_src == new->fog_src; +} + +static GLhandleARB find_glsl_vshader(IWineD3DVertexShaderImpl *shader, const struct vs_compile_args *args) +{ + UINT i; + DWORD new_size; + struct glsl_vs_compiled_shader *new_array; + DWORD use_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.use_map; + SHADER_BUFFER buffer; + struct glsl_vshader_private *shader_data; + GLhandleARB ret; + + if(!shader->backend_priv) { + shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data)); + } + shader_data = shader->backend_priv; + + /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2), + * so a linear search is more performant than a hashmap or a binary search + * (cache coherency etc) + */ + for(i = 0; i < shader_data->num_gl_shaders; i++) { + if(vs_args_equal(&shader_data->gl_shaders[i].args, args, use_map)) { + return shader_data->gl_shaders[i].prgId; + } + } + + TRACE("No matching GL shader found, compiling a new shader\n"); + + if(shader_data->shader_array_size == shader_data->num_gl_shaders) { + if (shader_data->num_gl_shaders) + { + new_size = shader_data->shader_array_size + max(1, shader_data->shader_array_size / 2); + new_array = HeapReAlloc(GetProcessHeap(), 0, shader_data->gl_shaders, + new_size * sizeof(*shader_data->gl_shaders)); + } else { + new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader_data->gl_shaders)); + new_size = 1; + } + + if(!new_array) { + ERR("Out of memory\n"); + return 0; + } + shader_data->gl_shaders = new_array; + shader_data->shader_array_size = new_size; + } + + shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args; + + shader_buffer_init(&buffer); + ret = shader_glsl_generate_vshader(shader, &buffer, args); + shader_buffer_free(&buffer); + shader_data->gl_shaders[shader_data->num_gl_shaders++].prgId = ret; + + return ret; +} + +/** Sets the GLSL program ID for the given pixel and vertex shader combination. + * It sets the programId on the current StateBlock (because it should be called + * inside of the DrawPrimitive() part of the render loop). + * + * If a program for the given combination does not exist, create one, and store + * the program in the hash table. If it creates a program, it will link the + * given objects, too. + */ + +/* GL locking is done by the caller */ +static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + struct shader_glsl_priv *priv = This->shader_priv; + const WineD3D_GL_Info *gl_info = &This->adapter->gl_info; + IWineD3DPixelShader *pshader = This->stateBlock->pixelShader; + IWineD3DVertexShader *vshader = This->stateBlock->vertexShader; + struct glsl_shader_prog_link *entry = NULL; + GLhandleARB programId = 0; + GLhandleARB reorder_shader_id = 0; + unsigned int i; + char glsl_name[8]; + GLhandleARB vshader_id, pshader_id; + struct ps_compile_args ps_compile_args; + struct vs_compile_args vs_compile_args; + + if(use_vs) { + find_vs_compile_args((IWineD3DVertexShaderImpl*)This->stateBlock->vertexShader, This->stateBlock, &vs_compile_args); + } else { + /* FIXME: Do we really have to spend CPU cycles to generate a few zeroed bytes? */ + memset(&vs_compile_args, 0, sizeof(vs_compile_args)); + } + if(use_ps) { + find_ps_compile_args((IWineD3DPixelShaderImpl*)This->stateBlock->pixelShader, This->stateBlock, &ps_compile_args); + } else { + /* FIXME: Do we really have to spend CPU cycles to generate a few zeroed bytes? */ + memset(&ps_compile_args, 0, sizeof(ps_compile_args)); + } + entry = get_glsl_program_entry(priv, vshader, pshader, &vs_compile_args, &ps_compile_args); + if (entry) { + priv->glsl_program = entry; + return; + } + + /* If we get to this point, then no matching program exists, so we create one */ + programId = GL_EXTCALL(glCreateProgramObjectARB()); + TRACE("Created new GLSL shader program %u\n", programId); + + /* Create the entry */ + entry = HeapAlloc(GetProcessHeap(), 0, sizeof(struct glsl_shader_prog_link)); + entry->programId = programId; + entry->vshader = vshader; + entry->pshader = pshader; + entry->vs_args = vs_compile_args; + entry->ps_args = ps_compile_args; + entry->constant_version = 0; + /* Add the hash table entry */ + add_glsl_program_entry(priv, entry); + + /* Set the current program */ + priv->glsl_program = entry; + + if(use_vs) { + vshader_id = find_glsl_vshader((IWineD3DVertexShaderImpl *) vshader, &vs_compile_args); + } else { + vshader_id = 0; + } + + /* Attach GLSL vshader */ + if (vshader_id) { + WORD map = ((IWineD3DBaseShaderImpl *)vshader)->baseShader.reg_maps.input_registers; + char tmp_name[10]; + + reorder_shader_id = generate_param_reorder_function(vshader, pshader, gl_info); + TRACE("Attaching GLSL shader object %u to program %u\n", reorder_shader_id, programId); + GL_EXTCALL(glAttachObjectARB(programId, reorder_shader_id)); + checkGLcall("glAttachObjectARB"); + /* Flag the reorder function for deletion, then it will be freed automatically when the program + * is destroyed + */ + GL_EXTCALL(glDeleteObjectARB(reorder_shader_id)); + + TRACE("Attaching GLSL shader object %u to program %u\n", vshader_id, programId); + GL_EXTCALL(glAttachObjectARB(programId, vshader_id)); + checkGLcall("glAttachObjectARB"); + + /* Bind vertex attributes to a corresponding index number to match + * the same index numbers as ARB_vertex_programs (makes loading + * vertex attributes simpler). With this method, we can use the + * exact same code to load the attributes later for both ARB and + * GLSL shaders. + * + * We have to do this here because we need to know the Program ID + * in order to make the bindings work, and it has to be done prior + * to linking the GLSL program. */ + for (i = 0; map; map >>= 1, ++i) + { + if (!(map & 1)) continue; + + snprintf(tmp_name, sizeof(tmp_name), "attrib%u", i); + GL_EXTCALL(glBindAttribLocationARB(programId, i, tmp_name)); + } + checkGLcall("glBindAttribLocationARB"); + + list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry); + } + + if(use_ps) { + pshader_id = find_glsl_pshader((IWineD3DPixelShaderImpl *) pshader, &ps_compile_args); + } else { + pshader_id = 0; + } + + /* Attach GLSL pshader */ + if (pshader_id) { + TRACE("Attaching GLSL shader object %u to program %u\n", pshader_id, programId); + GL_EXTCALL(glAttachObjectARB(programId, pshader_id)); + checkGLcall("glAttachObjectARB"); + + list_add_head(&((IWineD3DBaseShaderImpl *)pshader)->baseShader.linked_programs, &entry->pshader_entry); + } + + /* Link the program */ + TRACE("Linking GLSL shader program %u\n", programId); + GL_EXTCALL(glLinkProgramARB(programId)); + print_glsl_info_log(&GLINFO_LOCATION, programId); + + entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * GL_LIMITS(vshader_constantsF)); + for (i = 0; i < GL_LIMITS(vshader_constantsF); ++i) { snprintf(glsl_name, sizeof(glsl_name), "VC[%i]", i); entry->vuniformF_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name)); } @@ -3918,9 +4295,19 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { */ char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type); + ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); + if(pshader) { + struct glsl_pshader_private *shader_data; ps = (IWineD3DPixelShaderImpl *) This; - if(ps->num_gl_shaders == 0) return; + shader_data = ps->backend_priv; + if(!shader_data || shader_data->num_gl_shaders == 0) + { + HeapFree(GetProcessHeap(), 0, shader_data); + ps->backend_priv = NULL; + return; + } + if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->pshader == iface) { ENTER_GL(); @@ -3928,8 +4315,16 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { LEAVE_GL(); } } else { + struct glsl_vshader_private *shader_data; vs = (IWineD3DVertexShaderImpl *) This; - if(vs->num_gl_shaders == 0) return; + shader_data = vs->backend_priv; + if(!shader_data || shader_data->num_gl_shaders == 0) + { + HeapFree(GetProcessHeap(), 0, shader_data); + vs->backend_priv = NULL; + return; + } + if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->vshader == iface) { ENTER_GL(); @@ -3959,32 +4354,32 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) { if(pshader) { UINT i; + struct glsl_pshader_private *shader_data = ps->backend_priv; ENTER_GL(); - for(i = 0; i < ps->num_gl_shaders; i++) { - TRACE("deleting pshader %u\n", ps->gl_shaders[i].prgId); - GL_EXTCALL(glDeleteObjectARB(ps->gl_shaders[i].prgId)); + for(i = 0; i < shader_data->num_gl_shaders; i++) { + TRACE("deleting pshader %u\n", shader_data->gl_shaders[i].prgId); + GL_EXTCALL(glDeleteObjectARB(shader_data->gl_shaders[i].prgId)); checkGLcall("glDeleteObjectARB"); } LEAVE_GL(); - HeapFree(GetProcessHeap(), 0, ps->gl_shaders); - ps->gl_shaders = NULL; - ps->num_gl_shaders = 0; - ps->shader_array_size = 0; + HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); + HeapFree(GetProcessHeap(), 0, shader_data); + ps->backend_priv = NULL; } else { UINT i; + struct glsl_vshader_private *shader_data = vs->backend_priv; ENTER_GL(); - for(i = 0; i < vs->num_gl_shaders; i++) { - TRACE("deleting vshader %u\n", vs->gl_shaders[i].prgId); - GL_EXTCALL(glDeleteObjectARB(vs->gl_shaders[i].prgId)); + for(i = 0; i < shader_data->num_gl_shaders; i++) { + TRACE("deleting vshader %u\n", shader_data->gl_shaders[i].prgId); + GL_EXTCALL(glDeleteObjectARB(shader_data->gl_shaders[i].prgId)); checkGLcall("glDeleteObjectARB"); } LEAVE_GL(); - HeapFree(GetProcessHeap(), 0, vs->gl_shaders); - vs->gl_shaders = NULL; - vs->num_gl_shaders = 0; - vs->shader_array_size = 0; + HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders); + HeapFree(GetProcessHeap(), 0, shader_data); + vs->backend_priv = NULL; } } @@ -4104,177 +4499,6 @@ static BOOL shader_glsl_dirty_const(IWineD3DDevice *iface) { return FALSE; } -/* GL locking is done by the caller */ -static GLuint shader_glsl_generate_pshader(IWineD3DPixelShader *iface, - SHADER_BUFFER *buffer, const struct ps_compile_args *args) -{ - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; - const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps; - CONST DWORD *function = This->baseShader.function; - const char *fragcolor; - const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info; - - /* Create the hw GLSL shader object and assign it as the shader->prgId */ - GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB)); - - shader_addline(buffer, "#version 120\n"); - - if (GL_SUPPORT(ARB_DRAW_BUFFERS)) { - shader_addline(buffer, "#extension GL_ARB_draw_buffers : enable\n"); - } - if(GL_SUPPORT(ARB_SHADER_TEXTURE_LOD) && reg_maps->usestexldd) { - shader_addline(buffer, "#extension GL_ARB_shader_texture_lod : enable\n"); - } - if (GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { - /* The spec says that it doesn't have to be explicitly enabled, but the nvidia - * drivers write a warning if we don't do so - */ - shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n"); - } - - /* Base Declarations */ - shader_generate_glsl_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION, args); - - /* Pack 3.0 inputs */ - if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader) - { - pshader_glsl_input_pack(iface, buffer, This->semantics_in, reg_maps, args->vp_mode); - } - - /* Base Shader Body */ - shader_generate_main((IWineD3DBaseShader *)This, buffer, reg_maps, function, NULL); - - /* Pixel shaders < 2.0 place the resulting color in R0 implicitly */ - if (reg_maps->shader_version.major < 2) - { - /* Some older cards like GeforceFX ones don't support multiple buffers, so also not gl_FragData */ - if(GL_SUPPORT(ARB_DRAW_BUFFERS)) - shader_addline(buffer, "gl_FragData[0] = R0;\n"); - else - shader_addline(buffer, "gl_FragColor = R0;\n"); - } - - if(GL_SUPPORT(ARB_DRAW_BUFFERS)) { - fragcolor = "gl_FragData[0]"; - } else { - fragcolor = "gl_FragColor"; - } - if(args->srgb_correction) { - shader_addline(buffer, "tmp0.xyz = pow(%s.xyz, vec3(%f, %f, %f)) * vec3(%f, %f, %f) - vec3(%f, %f, %f);\n", - fragcolor, srgb_pow, srgb_pow, srgb_pow, srgb_mul_high, srgb_mul_high, srgb_mul_high, - srgb_sub_high, srgb_sub_high, srgb_sub_high); - shader_addline(buffer, "tmp1.xyz = %s.xyz * srgb_mul_low.xyz;\n", fragcolor); - shader_addline(buffer, "%s.x = %s.x < srgb_comparison.x ? tmp1.x : tmp0.x;\n", fragcolor, fragcolor); - shader_addline(buffer, "%s.y = %s.y < srgb_comparison.y ? tmp1.y : tmp0.y;\n", fragcolor, fragcolor); - shader_addline(buffer, "%s.z = %s.z < srgb_comparison.z ? tmp1.z : tmp0.z;\n", fragcolor, fragcolor); - shader_addline(buffer, "%s = clamp(%s, 0.0, 1.0);\n", fragcolor, fragcolor); - } - /* Pixel shader < 3.0 do not replace the fog stage. - * This implements linear fog computation and blending. - * TODO: non linear fog - * NOTE: gl_Fog.start and gl_Fog.end don't hold fog start s and end e but - * -1/(e-s) and e/(e-s) respectively. - */ - if (reg_maps->shader_version.major < 3) - { - switch(args->fog) { - case FOG_OFF: break; - case FOG_LINEAR: - shader_addline(buffer, "float fogstart = -1.0 / (gl_Fog.end - gl_Fog.start);\n"); - shader_addline(buffer, "float fogend = gl_Fog.end * -fogstart;\n"); - shader_addline(buffer, "float Fog = clamp(gl_FogFragCoord * fogstart + fogend, 0.0, 1.0);\n"); - shader_addline(buffer, "%s.xyz = mix(gl_Fog.color.xyz, %s.xyz, Fog);\n", fragcolor, fragcolor); - break; - case FOG_EXP: - /* Fog = e^(-gl_Fog.density * gl_FogFragCoord) */ - shader_addline(buffer, "float Fog = exp(-gl_Fog.density * gl_FogFragCoord);\n"); - shader_addline(buffer, "Fog = clamp(Fog, 0.0, 1.0);\n"); - shader_addline(buffer, "%s.xyz = mix(gl_Fog.color.xyz, %s.xyz, Fog);\n", fragcolor, fragcolor); - break; - case FOG_EXP2: - /* Fog = e^(-(gl_Fog.density * gl_FogFragCoord)^2) */ - shader_addline(buffer, "float Fog = exp(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord);\n"); - shader_addline(buffer, "Fog = clamp(Fog, 0.0, 1.0);\n"); - shader_addline(buffer, "%s.xyz = mix(gl_Fog.color.xyz, %s.xyz, Fog);\n", fragcolor, fragcolor); - break; - } - } - - shader_addline(buffer, "}\n"); - - TRACE("Compiling shader object %u\n", shader_obj); - GL_EXTCALL(glShaderSourceARB(shader_obj, 1, (const char**)&buffer->buffer, NULL)); - GL_EXTCALL(glCompileShaderARB(shader_obj)); - print_glsl_info_log(&GLINFO_LOCATION, shader_obj); - - /* Store the shader object */ - return shader_obj; -} - -/* GL locking is done by the caller */ -static GLuint shader_glsl_generate_vshader(IWineD3DVertexShader *iface, - SHADER_BUFFER *buffer, const struct vs_compile_args *args) -{ - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; - const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps; - CONST DWORD *function = This->baseShader.function; - const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info; - - /* Create the hw GLSL shader program and assign it as the shader->prgId */ - GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB)); - - shader_addline(buffer, "#version 120\n"); - - /* Base Declarations */ - shader_generate_glsl_declarations( (IWineD3DBaseShader*) This, reg_maps, buffer, &GLINFO_LOCATION, NULL); - - /* Base Shader Body */ - shader_generate_main((IWineD3DBaseShader*)This, buffer, reg_maps, function, NULL); - - /* Unpack 3.0 outputs */ - if (reg_maps->shader_version.major >= 3) shader_addline(buffer, "order_ps_input(OUT);\n"); - else shader_addline(buffer, "order_ps_input();\n"); - - /* The D3DRS_FOGTABLEMODE render state defines if the shader-generated fog coord is used - * or if the fragment depth is used. If the fragment depth is used(FOGTABLEMODE != NONE), - * the fog frag coord is thrown away. If the fog frag coord is used, but not written by - * the shader, it is set to 0.0(fully fogged, since start = 1.0, end = 0.0) - */ - if(args->fog_src == VS_FOG_Z) { - shader_addline(buffer, "gl_FogFragCoord = gl_Position.z;\n"); - } else if (!reg_maps->fog) { - shader_addline(buffer, "gl_FogFragCoord = 0.0;\n"); - } - - /* Write the final position. - * - * OpenGL coordinates specify the center of the pixel while d3d coords specify - * the corner. The offsets are stored in z and w in posFixup. posFixup.y contains - * 1.0 or -1.0 to turn the rendering upside down for offscreen rendering. PosFixup.x - * contains 1.0 to allow a mad. - */ - shader_addline(buffer, "gl_Position.y = gl_Position.y * posFixup.y;\n"); - shader_addline(buffer, "gl_Position.xy += posFixup.zw * gl_Position.ww;\n"); - shader_addline(buffer, "gl_ClipVertex = gl_Position;\n"); - - /* Z coord [0;1]->[-1;1] mapping, see comment in transform_projection in state.c - * - * Basically we want (in homogeneous coordinates) z = z * 2 - 1. However, shaders are run - * before the homogeneous divide, so we have to take the w into account: z = ((z / w) * 2 - 1) * w, - * which is the same as z = z * 2 - w. - */ - shader_addline(buffer, "gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;\n"); - - shader_addline(buffer, "}\n"); - - TRACE("Compiling shader object %u\n", shader_obj); - GL_EXTCALL(glShaderSourceARB(shader_obj, 1, (const char**)&buffer->buffer, NULL)); - GL_EXTCALL(glCompileShaderARB(shader_obj)); - print_glsl_info_log(&GLINFO_LOCATION, shader_obj); - - return shader_obj; -} - static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) { /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati @@ -4434,8 +4658,25 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_TEXREG2RGB */ pshader_glsl_texreg2rgb, }; +static void shader_glsl_handle_instruction(const struct wined3d_shader_instruction *ins) { + SHADER_HANDLER hw_fct; + + /* Select handler */ + hw_fct = shader_glsl_instruction_handler_table[ins->handler_idx]; + + /* Unhandled opcode */ + if (!hw_fct) + { + FIXME("Backend can't handle opcode %#x\n", ins->handler_idx); + return; + } + hw_fct(ins); + + shader_glsl_add_instruction_modifiers(ins); +} + const shader_backend_t glsl_shader_backend = { - shader_glsl_instruction_handler_table, + shader_glsl_handle_instruction, shader_glsl_select, shader_glsl_select_depth_blt, shader_glsl_deselect_depth_blt, @@ -4447,9 +4688,6 @@ const shader_backend_t glsl_shader_backend = { shader_glsl_alloc, shader_glsl_free, shader_glsl_dirty_const, - shader_glsl_generate_pshader, - shader_glsl_generate_vshader, shader_glsl_get_caps, shader_glsl_color_fixup_supported, - shader_glsl_add_instruction_modifiers, }; diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c index 6045085a367..6ac145c1ae2 100644 --- a/dlls/wined3d/pixelshader.c +++ b/dlls/wined3d/pixelshader.c @@ -178,6 +178,10 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This) This->baseShader.limits.label = 16; break; + case WINED3D_SHADER_VERSION(4,0): + FIXME("Using 3.0 limits for 4.0 shader\n"); + /* Fall through */ + case WINED3D_SHADER_VERSION(3,0): This->baseShader.limits.temporary = 32; This->baseShader.limits.constant_float = 224; @@ -238,8 +242,9 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i list_init(&This->baseShader.constantsI); /* Second pass: figure out which registers are used, what the semantics are, etc.. */ - hr = shader_get_registers_used((IWineD3DBaseShader *)This, fe, reg_maps, This->semantics_in, NULL, pFunction, - GL_LIMITS(pshader_constantsF)); + hr = shader_get_registers_used((IWineD3DBaseShader *)This, fe, + reg_maps, NULL, This->input_signature, NULL, + pFunction, GL_LIMITS(pshader_constantsF)); if (FAILED(hr)) return hr; pshader_set_limits(This); @@ -294,7 +299,7 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i return WINED3D_OK; } -static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures) +void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures) { WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = reg_maps->sampler_type; unsigned int i; @@ -338,30 +343,6 @@ static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD } } -/* GL locking is done by the caller */ -static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps_compile_args *args) -{ - CONST DWORD *function = This->baseShader.function; - GLuint retval; - SHADER_BUFFER buffer; - IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; - - TRACE("(%p) : function %p\n", This, function); - - pixelshader_update_samplers(&This->baseShader.reg_maps, - ((IWineD3DDeviceImpl *)This->baseShader.device)->stateBlock->textures); - - /* Generate the HW shader */ - TRACE("(%p) : Generating hardware program\n", This); - This->cur_args = args; - shader_buffer_init(&buffer); - retval = device->shader_backend->shader_generate_pshader((IWineD3DPixelShader *)This, &buffer, args); - shader_buffer_free(&buffer); - This->cur_args = NULL; - - return retval; -} - const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl = { /*** IUnknown methods ***/ @@ -440,45 +421,3 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp } } } - -/* GL locking is done by the caller */ -GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args) -{ - UINT i; - DWORD new_size; - struct ps_compiled_shader *new_array; - - /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2), - * so a linear search is more performant than a hashmap or a binary search - * (cache coherency etc) - */ - for(i = 0; i < shader->num_gl_shaders; i++) { - if(memcmp(&shader->gl_shaders[i].args, args, sizeof(*args)) == 0) { - return shader->gl_shaders[i].prgId; - } - } - - TRACE("No matching GL shader found, compiling a new shader\n"); - if(shader->shader_array_size == shader->num_gl_shaders) { - if (shader->num_gl_shaders) - { - new_size = shader->shader_array_size + max(1, shader->shader_array_size / 2); - new_array = HeapReAlloc(GetProcessHeap(), 0, shader->gl_shaders, - new_size * sizeof(*shader->gl_shaders)); - } else { - new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader->gl_shaders)); - new_size = 1; - } - - if(!new_array) { - ERR("Out of memory\n"); - return 0; - } - shader->gl_shaders = new_array; - shader->shader_array_size = new_size; - } - - shader->gl_shaders[shader->num_gl_shaders].args = *args; - shader->gl_shaders[shader->num_gl_shaders].prgId = pixelshader_compile(shader, args); - return shader->gl_shaders[shader->num_gl_shaders++].prgId; -} diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 807240bb333..89ea7f3794d 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -26,10 +26,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); -HRESULT resource_init(struct IWineD3DResourceClass *resource, WINED3DRESOURCETYPE resource_type, +HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type, IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc, WINED3DPOOL pool, IUnknown *parent) { + struct IWineD3DResourceClass *resource = &((IWineD3DResourceImpl *)iface)->resource; + resource->wineD3DDevice = device; resource->parent = parent; resource->resourceType = resource_type; @@ -68,6 +70,8 @@ HRESULT resource_init(struct IWineD3DResourceClass *resource, WINED3DRESOURCETYP WineD3DAdapterChangeGLRam(device, size); } + device_resource_add(device, iface); + return WINED3D_OK; } @@ -96,10 +100,7 @@ void resource_cleanup(IWineD3DResource *iface) This->resource.allocatedMemory = 0; This->resource.heapMemory = 0; - if (This->resource.wineD3DDevice != NULL) { - IWineD3DDevice_ResourceReleased((IWineD3DDevice *)This->resource.wineD3DDevice, iface); - }/* NOTE: this is not really an error for system memory resources */ - return; + if (This->resource.wineD3DDevice) device_resource_released(This->resource.wineD3DDevice, iface); } HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice** ppDevice) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 8fc0d285533..d65105dfb69 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -34,10 +34,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface); WINE_DECLARE_DEBUG_CHANNEL(d3d); #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info -static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey); -static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert); -static void surface_remove_pbo(IWineD3DSurfaceImpl *This); - static void surface_force_reload(IWineD3DSurface *iface) { IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; @@ -1819,6 +1815,86 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ return WINED3D_OK; } +static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey) +{ + IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + IWineD3DPaletteImpl *pal = This->palette; + BOOL index_in_alpha = FALSE; + unsigned int i; + + /* Old games like StarCraft, C&C, Red Alert and others use P8 render targets. + * Reading back the RGB output each lockrect (each frame as they lock the whole screen) + * is slow. Further RGB->P8 conversion is not possible because palettes can have + * duplicate entries. Store the color key in the unused alpha component to speed the + * download up and to make conversion unneeded. */ + index_in_alpha = primary_render_target_is_p8(device); + + if (!pal) + { + UINT dxVersion = ((IWineD3DImpl *)device->wineD3D)->dxVersion; + + /* In DirectDraw the palette is a property of the surface, there are no such things as device palettes. */ + if (dxVersion <= 7) + { + ERR("This code should never get entered for DirectDraw!, expect problems\n"); + if (index_in_alpha) + { + /* Guarantees that memory representation remains correct after sysmem<->texture transfers even if + * there's no palette at this time. */ + for (i = 0; i < 256; i++) table[i][3] = i; + } + } + else + { + /* Direct3D >= 8 palette usage style: P8 textures use device palettes, palette entry format is A8R8G8B8, + * alpha is stored in peFlags and may be used by the app if D3DPTEXTURECAPS_ALPHAPALETTE device + * capability flag is present (wine does advertise this capability) */ + for (i = 0; i < 256; ++i) + { + table[i][0] = device->palettes[device->currentPalette][i].peRed; + table[i][1] = device->palettes[device->currentPalette][i].peGreen; + table[i][2] = device->palettes[device->currentPalette][i].peBlue; + table[i][3] = device->palettes[device->currentPalette][i].peFlags; + } + } + } + else + { + TRACE("Using surface palette %p\n", pal); + /* Get the surface's palette */ + for (i = 0; i < 256; ++i) + { + table[i][0] = pal->palents[i].peRed; + table[i][1] = pal->palents[i].peGreen; + table[i][2] = pal->palents[i].peBlue; + + /* When index_in_alpha is set the palette index is stored in the + * alpha component. In case of a readback we can then read + * GL_ALPHA. Color keying is handled in BltOverride using a + * GL_ALPHA_TEST using GL_NOT_EQUAL. In case of index_in_alpha the + * color key itself is passed to glAlphaFunc in other cases the + * alpha component of pixels that should be masked away is set to 0. */ + if (index_in_alpha) + { + table[i][3] = i; + } + else if (colorkey && (i >= This->SrcBltCKey.dwColorSpaceLowValue) + && (i <= This->SrcBltCKey.dwColorSpaceHighValue)) + { + table[i][3] = 0x00; + } + else if(pal->Flags & WINEDDPCAPS_ALPHA) + { + table[i][3] = pal->palents[i].peFlags; + } + else + { + table[i][3] = 0xFF; + } + } + } +} + static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This) { @@ -2190,65 +2266,6 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI return WINED3D_OK; } -static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey) { - IWineD3DPaletteImpl* pal = This->palette; - IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; - BOOL index_in_alpha = FALSE; - int dxVersion = ( (IWineD3DImpl *) device->wineD3D)->dxVersion; - unsigned int i; - - /* Old games like StarCraft, C&C, Red Alert and others use P8 render targets. - * Reading back the RGB output each lockrect (each frame as they lock the whole screen) - * is slow. Further RGB->P8 conversion is not possible because palettes can have - * duplicate entries. Store the color key in the unused alpha component to speed the - * download up and to make conversion unneeded. */ - index_in_alpha = primary_render_target_is_p8(device); - - if (pal == NULL) { - /* In DirectDraw the palette is a property of the surface, there are no such things as device palettes. */ - if(dxVersion <= 7) { - ERR("This code should never get entered for DirectDraw!, expect problems\n"); - if(index_in_alpha) { - /* Guarantees that memory representation remains correct after sysmem<->texture transfers even if - there's no palette at this time. */ - for (i = 0; i < 256; i++) table[i][3] = i; - } - } else { - /* Direct3D >= 8 palette usage style: P8 textures use device palettes, palette entry format is A8R8G8B8, - alpha is stored in peFlags and may be used by the app if D3DPTEXTURECAPS_ALPHAPALETTE device - capability flag is present (wine does advertise this capability) */ - for (i = 0; i < 256; i++) { - table[i][0] = device->palettes[device->currentPalette][i].peRed; - table[i][1] = device->palettes[device->currentPalette][i].peGreen; - table[i][2] = device->palettes[device->currentPalette][i].peBlue; - table[i][3] = device->palettes[device->currentPalette][i].peFlags; - } - } - } else { - TRACE("Using surface palette %p\n", pal); - /* Get the surface's palette */ - for (i = 0; i < 256; i++) { - table[i][0] = pal->palents[i].peRed; - table[i][1] = pal->palents[i].peGreen; - table[i][2] = pal->palents[i].peBlue; - - /* When index_in_alpha is the palette index is stored in the alpha component. In case of a readback - we can then read GL_ALPHA. Color keying is handled in BltOverride using a GL_ALPHA_TEST using GL_NOT_EQUAL. - In case of index_in_alpha the color key itself is passed to glAlphaFunc in other cases the alpha component - of pixels that should be masked away is set to 0. */ - if(index_in_alpha) { - table[i][3] = i; - } else if(colorkey && (i >= This->SrcBltCKey.dwColorSpaceLowValue) && (i <= This->SrcBltCKey.dwColorSpaceHighValue)) { - table[i][3] = 0x00; - } else if(pal->Flags & WINEDDPCAPS_ALPHA) { - table[i][3] = pal->palents[i].peFlags; - } else { - table[i][3] = 0xFF; - } - } - } -} - /* This function is used in case of 8bit paletted textures to upload the palette. It supports GL_EXT_paletted_texture and GL_ARB_fragment_program, support for other extensions like ATI_fragment_shaders is possible. diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 09f76fd84fd..cce49209df0 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -911,9 +911,12 @@ const char* debug_d3ddevicetype(WINED3DDEVTYPE devtype) { } } -const char* debug_d3dusage(DWORD usage) { - switch (usage & WINED3DUSAGE_MASK) { -#define WINED3DUSAGE_TO_STR(u) case u: return #u +const char *debug_d3dusage(DWORD usage) +{ + char buf[284]; + + buf[0] = '\0'; +#define WINED3DUSAGE_TO_STR(u) if (usage & u) { strcat(buf, " | "#u); usage &= ~u; } WINED3DUSAGE_TO_STR(WINED3DUSAGE_RENDERTARGET); WINED3DUSAGE_TO_STR(WINED3DUSAGE_DEPTHSTENCIL); WINED3DUSAGE_TO_STR(WINED3DUSAGE_WRITEONLY); @@ -926,16 +929,17 @@ const char* debug_d3dusage(DWORD usage) { WINED3DUSAGE_TO_STR(WINED3DUSAGE_AUTOGENMIPMAP); WINED3DUSAGE_TO_STR(WINED3DUSAGE_DMAP); #undef WINED3DUSAGE_TO_STR - case 0: return "none"; - default: - FIXME("Unrecognized %u Usage!\n", usage); - return "unrecognized"; - } + if (usage) FIXME("Unrecognized usage flag(s) %#x\n", usage); + + return buf[0] ? wine_dbg_sprintf("%s", &buf[3]) : "0"; } -const char* debug_d3dusagequery(DWORD usagequery) { - switch (usagequery & WINED3DUSAGE_QUERY_MASK) { -#define WINED3DUSAGEQUERY_TO_STR(u) case u: return #u +const char *debug_d3dusagequery(DWORD usagequery) +{ + char buf[238]; + + buf[0] = '\0'; +#define WINED3DUSAGEQUERY_TO_STR(u) if (usagequery & u) { strcat(buf, " | "#u); usagequery &= ~u; } WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_FILTER); WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_LEGACYBUMPMAP); WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING); @@ -944,11 +948,9 @@ const char* debug_d3dusagequery(DWORD usagequery) { WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_VERTEXTEXTURE); WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_WRAPANDMIP); #undef WINED3DUSAGEQUERY_TO_STR - case 0: return "none"; - default: - FIXME("Unrecognized %u Usage Query!\n", usagequery); - return "unrecognized"; - } + if (usagequery) FIXME("Unrecognized usage query flag(s) %#x\n", usagequery); + + return buf[0] ? wine_dbg_sprintf("%s", &buf[3]) : "0"; } const char* debug_d3ddeclmethod(WINED3DDECLMETHOD method) { diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c index f7766a1fa8b..6c1440d4c25 100644 --- a/dlls/wined3d/vertexshader.c +++ b/dlls/wined3d/vertexshader.c @@ -71,6 +71,10 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); break; + case WINED3D_SHADER_VERSION(4,0): + FIXME("Using 3.0 limits for 4.0 shader\n"); + /* Fall through */ + case WINED3D_SHADER_VERSION(3,0): This->baseShader.limits.temporary = 32; This->baseShader.limits.constant_bool = 32; @@ -101,26 +105,6 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) } } -/* This is an internal function, - * used to create fake semantics for shaders - * that don't have them - d3d8 shaders where the declaration - * stores the register for each input - */ -static void vshader_set_input( - IWineD3DVertexShaderImpl* This, - unsigned int regnum, - BYTE usage, BYTE usage_idx) { - - This->semantics_in[regnum].usage = usage; - This->semantics_in[regnum].usage_idx = usage_idx; - This->semantics_in[regnum].reg.reg.type = WINED3DSPR_INPUT; - This->semantics_in[regnum].reg.reg.idx = regnum; - This->semantics_in[regnum].reg.write_mask = WINED3DSP_WRITEMASK_ALL; - This->semantics_in[regnum].reg.modifiers = 0; - This->semantics_in[regnum].reg.shift = 0; - This->semantics_in[regnum].reg.reg.rel_addr = NULL; -} - static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_idx2) { if (usage_idx1 != usage_idx2) return FALSE; if (usage1 == usage2) return TRUE; @@ -130,19 +114,18 @@ static BOOL match_usage(BYTE usage1, BYTE usage_idx1, BYTE usage2, BYTE usage_id return FALSE; } -BOOL vshader_get_input( - IWineD3DVertexShader* iface, - BYTE usage_req, BYTE usage_idx_req, - unsigned int* regnum) { - - IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface; - int i; +BOOL vshader_get_input(IWineD3DVertexShader* iface, BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) +{ + IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; + WORD map = This->baseShader.reg_maps.input_registers; + unsigned int i; - for (i = 0; i < MAX_ATTRIBS; i++) { - if (!This->baseShader.reg_maps.attributes[i]) continue; + for (i = 0; map; map >>= 1, ++i) + { + if (!(map & 1)) continue; - if (match_usage(This->semantics_in[i].usage, - This->semantics_in[i].usage_idx, usage_req, usage_idx_req)) + if (match_usage(This->attributes[i].usage, + This->attributes[i].usage_idx, usage_req, usage_idx_req)) { *regnum = i; return TRUE; @@ -249,6 +232,7 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader IWineD3DVertexShaderImpl *This =(IWineD3DVertexShaderImpl *)iface; IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device; const struct wined3d_shader_frontend *fe; + unsigned int i; HRESULT hr; shader_reg_maps *reg_maps = &This->baseShader.reg_maps; @@ -280,10 +264,20 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader This->min_rel_offset = GL_LIMITS(vshader_constantsF); This->max_rel_offset = 0; hr = shader_get_registers_used((IWineD3DBaseShader*) This, fe, - reg_maps, This->semantics_in, This->semantics_out, pFunction, - GL_LIMITS(vshader_constantsF)); + reg_maps, This->attributes, NULL, This->output_signature, + pFunction, GL_LIMITS(vshader_constantsF)); if (hr != WINED3D_OK) return hr; + if (output_signature) + { + for (i = 0; i < output_signature->element_count; ++i) + { + struct wined3d_shader_signature_element *e = &output_signature->elements[i]; + reg_maps->output_registers |= 1 << e->register_idx; + This->output_signature[e->register_idx] = *e; + } + } + vshader_set_limits(This); if(deviceImpl->vs_selected_mode == SHADER_ARB && @@ -312,19 +306,6 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader return WINED3D_OK; } -/* Preload semantics for d3d8 shaders */ -static void WINAPI IWineD3DVertexShaderImpl_FakeSemantics(IWineD3DVertexShader *iface, IWineD3DVertexDeclaration *vertex_declaration) { - IWineD3DVertexShaderImpl *This =(IWineD3DVertexShaderImpl *)iface; - IWineD3DVertexDeclarationImpl* vdecl = (IWineD3DVertexDeclarationImpl*)vertex_declaration; - - unsigned int i; - for (i = 0; i < vdecl->element_count; ++i) - { - const struct wined3d_vertex_declaration_element *e = &vdecl->elements[i]; - vshader_set_input(This, e->output_slot, e->usage, e->usage_idx); - } -} - /* Set local constants for d3d8 shaders */ static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertexShader *iface, UINT start_idx, const float *src_data, UINT count) { @@ -351,23 +332,6 @@ static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertex return WINED3D_OK; } -/* GL locking is done by the caller */ -static GLuint vertexshader_compile(IWineD3DVertexShaderImpl *This, const struct vs_compile_args *args) { - IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device; - SHADER_BUFFER buffer; - GLuint ret; - - /* Generate the HW shader */ - TRACE("(%p) : Generating hardware program\n", This); - shader_buffer_init(&buffer); - This->cur_args = args; - ret = deviceImpl->shader_backend->shader_generate_vshader((IWineD3DVertexShader *)This, &buffer, args); - This->cur_args = NULL; - shader_buffer_free(&buffer); - - return ret; -} - const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl = { /*** IUnknown methods ***/ @@ -381,7 +345,6 @@ const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl = /*** IWineD3DVertexShader methods ***/ IWineD3DVertexShaderImpl_GetDevice, IWineD3DVertexShaderImpl_GetFunction, - IWineD3DVertexShaderImpl_FakeSemantics, IWIneD3DVertexShaderImpl_SetLocalConstantsF }; @@ -389,53 +352,3 @@ void find_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockIm args->fog_src = stateblock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE ? VS_FOG_COORD : VS_FOG_Z; args->swizzle_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.swizzle_map; } - -static inline BOOL vs_args_equal(const struct vs_compile_args *stored, const struct vs_compile_args *new, - const DWORD use_map) { - if((stored->swizzle_map & use_map) != new->swizzle_map) return FALSE; - return stored->fog_src == new->fog_src; -} - -/* GL locking is done by the caller */ -GLuint find_gl_vshader(IWineD3DVertexShaderImpl *shader, const struct vs_compile_args *args) -{ - UINT i; - DWORD new_size = shader->shader_array_size; - struct vs_compiled_shader *new_array; - DWORD use_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.use_map; - - /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2), - * so a linear search is more performant than a hashmap or a binary search - * (cache coherency etc) - */ - for(i = 0; i < shader->num_gl_shaders; i++) { - if(vs_args_equal(&shader->gl_shaders[i].args, args, use_map)) { - return shader->gl_shaders[i].prgId; - } - } - - TRACE("No matching GL shader found, compiling a new shader\n"); - - if(shader->shader_array_size == shader->num_gl_shaders) { - if (shader->num_gl_shaders) - { - new_size = shader->shader_array_size + max(1, shader->shader_array_size / 2); - new_array = HeapReAlloc(GetProcessHeap(), 0, shader->gl_shaders, - new_size * sizeof(*shader->gl_shaders)); - } else { - new_array = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader->gl_shaders)); - new_size = 1; - } - - if(!new_array) { - ERR("Out of memory\n"); - return 0; - } - shader->gl_shaders = new_array; - shader->shader_array_size = new_size; - } - - shader->gl_shaders[shader->num_gl_shaders].args = *args; - shader->gl_shaders[shader->num_gl_shaders].prgId = vertexshader_compile(shader, args); - return shader->gl_shaders[shader->num_gl_shaders++].prgId; -} diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 79ac60b2dab..8b7bff8d781 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -621,14 +621,14 @@ typedef struct shader_reg_maps char texcoord[MAX_REG_TEXCRD]; /* pixel < 3.0 */ char temporary[MAX_REG_TEMP]; /* pixel, vertex */ char address[MAX_REG_ADDR]; /* vertex */ - char packed_input[MAX_REG_INPUT]; /* pshader >= 3.0 */ - char packed_output[MAX_REG_OUTPUT]; /* vertex >= 3.0 */ - char attributes[MAX_ATTRIBS]; /* vertex */ char labels[MAX_LABELS]; /* pixel, vertex */ DWORD *constf; /* pixel, vertex */ DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */ + WORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 16 */ + WORD output_registers; /* MAX_REG_OUTPUT, 12 */ WORD integer_constants; /* MAX_CONST_I, 16 */ WORD boolean_constants; /* MAX_CONST_B, 16 */ + WORD local_bool_consts; /* MAX_CONST_B, 16 */ WINED3DSAMPLER_TEXTURE_TYPE sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)]; BOOL bumpmat[MAX_TEXTURES], luminanceparams[MAX_TEXTURES]; @@ -696,6 +696,12 @@ struct wined3d_shader_semantic struct wined3d_shader_dst_param reg; }; +struct wined3d_shader_attribute +{ + WINED3DDECLUSAGE usage; + UINT usage_idx; +}; + struct wined3d_shader_frontend { void *(*shader_init)(const DWORD *ptr, const struct wined3d_shader_signature *output_signature); @@ -792,7 +798,7 @@ struct vs_compile_args { }; typedef struct { - const SHADER_HANDLER *shader_instruction_handler_table; + void (*shader_handle_instruction)(const struct wined3d_shader_instruction *); void (*shader_select)(IWineD3DDevice *iface, BOOL usePS, BOOL useVS); void (*shader_select_depth_blt)(IWineD3DDevice *iface, enum tex_types tex_type); void (*shader_deselect_depth_blt)(IWineD3DDevice *iface); @@ -804,10 +810,6 @@ typedef struct { HRESULT (*shader_alloc_private)(IWineD3DDevice *iface); void (*shader_free_private)(IWineD3DDevice *iface); BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface); - GLuint (*shader_generate_pshader)(IWineD3DPixelShader *iface, - SHADER_BUFFER *buffer, const struct ps_compile_args *args); - GLuint (*shader_generate_vshader)(IWineD3DVertexShader *iface, - SHADER_BUFFER *buffer, const struct vs_compile_args *args); void (*shader_get_caps)(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *caps); BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup); void (*shader_add_instruction_modifiers)(const struct wined3d_shader_instruction *ins); @@ -1229,6 +1231,7 @@ struct WineD3DContext { GLint gl_fog_source; GLfloat fog_coord_value; GLfloat color[4], fogstart, fogend, fogcolor[4]; + GLuint dummy_arbfp_prog; }; typedef enum ContextUsage { @@ -1575,6 +1578,8 @@ struct IWineD3DDeviceImpl extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl; +void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource); +void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource); void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup); void device_stream_info_from_strided(IWineD3DDeviceImpl *This, @@ -1645,7 +1650,7 @@ HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **parent); DWORD resource_get_priority(IWineD3DResource *iface); HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid, void *data, DWORD *data_size); -HRESULT resource_init(struct IWineD3DResourceClass *resource, WINED3DRESOURCETYPE resource_type, +HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type, IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc, WINED3DPOOL pool, IUnknown *parent); WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface); @@ -2578,9 +2583,11 @@ void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx); HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, - struct shader_reg_maps *reg_maps, struct wined3d_shader_semantic *semantics_in, - struct wined3d_shader_semantic *semantics_out, const DWORD *byte_code, DWORD constf_size); + struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes, + struct wined3d_shader_signature_element *input_signature, + struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size); void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDevice *device); +BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage); const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token); void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction); @@ -2649,12 +2656,6 @@ static inline BOOL shader_constant_is_local(IWineD3DBaseShaderImpl* This, DWORD /***************************************************************************** * IDirect3DVertexShader implementation structures */ - -struct vs_compiled_shader { - struct vs_compile_args args; - GLuint prgId; -}; - typedef struct IWineD3DVertexShaderImpl { /* IUnknown parts*/ const IWineD3DVertexShaderVtbl *lpVtbl; @@ -2668,33 +2669,24 @@ typedef struct IWineD3DVertexShaderImpl { DWORD usage; /* The GL shader */ - struct vs_compiled_shader *gl_shaders; - UINT num_gl_shaders, shader_array_size; + void *backend_priv; /* Vertex shader input and output semantics */ - struct wined3d_shader_semantic semantics_in[MAX_ATTRIBS]; - struct wined3d_shader_semantic semantics_out[MAX_REG_OUTPUT]; + struct wined3d_shader_attribute attributes[MAX_ATTRIBS]; + struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT]; UINT min_rel_offset, max_rel_offset; UINT rel_offset; UINT recompile_count; - - const struct vs_compile_args *cur_args; } IWineD3DVertexShaderImpl; extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl; void find_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct vs_compile_args *args); -GLuint find_gl_vshader(IWineD3DVertexShaderImpl *shader, const struct vs_compile_args *args); /***************************************************************************** * IDirect3DPixelShader implementation structure */ -struct ps_compiled_shader { - struct ps_compile_args args; - GLuint prgId; -}; - typedef struct IWineD3DPixelShaderImpl { /* IUnknown parts */ const IWineD3DPixelShaderVtbl *lpVtbl; @@ -2706,14 +2698,13 @@ typedef struct IWineD3DPixelShaderImpl { IUnknown *parent; /* Pixel shader input semantics */ - struct wined3d_shader_semantic semantics_in[MAX_REG_INPUT]; + struct wined3d_shader_signature_element input_signature[MAX_REG_INPUT]; DWORD input_reg_map[MAX_REG_INPUT]; BOOL input_reg_used[MAX_REG_INPUT]; int declared_in_count; /* The GL shader */ - struct ps_compiled_shader *gl_shaders; - UINT num_gl_shaders, shader_array_size; + void *backend_priv; /* Some information about the shader behavior */ struct stb_const_desc bumpenvmatconst[MAX_TEXTURES]; @@ -2721,11 +2712,13 @@ typedef struct IWineD3DPixelShaderImpl { struct stb_const_desc luminanceconst[MAX_TEXTURES]; char vpos_uniform; - const struct ps_compile_args *cur_args; + BOOL color0_mov; + DWORD color0_reg; + } IWineD3DPixelShaderImpl; extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl; -GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args); +void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures); void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args); /* sRGB correction constants */ diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index d6b2888b85a..a2bc00486d7 100644 --- a/dlls/winex11.drv/desktop.c +++ b/dlls/winex11.drv/desktop.c @@ -42,6 +42,9 @@ static const unsigned int widths[] = {320, 400, 512, 640, 800, 1024, 1152, 1280 static const unsigned int heights[] = {200, 300, 384, 480, 600, 768, 864, 1024, 1050, 1200}; #define NUM_DESKTOP_MODES (sizeof(widths) / sizeof(widths[0])) +#define _NET_WM_STATE_REMOVE 0 +#define _NET_WM_STATE_ADD 1 + /* create the mode structures */ static void make_modes(void) { @@ -134,6 +137,8 @@ Window CDECL X11DRV_create_desktop( UINT width, UINT height ) Window win; Display *display = thread_init_display(); + TRACE( "%u x %u\n", width, height ); + wine_tsx11_lock(); /* Create window */ @@ -150,6 +155,13 @@ Window CDECL X11DRV_create_desktop( UINT width, UINT height ) win = XCreateWindow( display, DefaultRootWindow(display), 0, 0, width, height, 0, screen_depth, InputOutput, visual, CWEventMask | CWCursor | CWColormap, &win_attr ); + if (win != None && width == screen_width && height == screen_height) + { + TRACE("setting desktop to fullscreen\n"); + XChangeProperty( display, win, x11drv_atom(_NET_WM_STATE), XA_ATOM, 32, + PropModeReplace, (unsigned char*)&x11drv_atom(_NET_WM_STATE_FULLSCREEN), + 1); + } XFlush( display ); wine_tsx11_unlock(); if (win != None) X11DRV_init_desktop( win, width, height ); @@ -191,6 +203,35 @@ static BOOL CALLBACK update_windows_on_desktop_resize( HWND hwnd, LPARAM lparam return TRUE; } +static void update_desktop_fullscreen( unsigned int width, unsigned int height) +{ + Display *display = thread_display(); + XEvent xev; + + if (!display || root_window != DefaultRootWindow( display )) return; + + xev.xclient.type = ClientMessage; + xev.xclient.window = root_window; + xev.xclient.message_type = x11drv_atom(_NET_WM_STATE); + xev.xclient.serial = 0; + xev.xclient.display = display; + xev.xclient.send_event = True; + xev.xclient.format = 32; + if (width == max_width && height == max_height) + xev.xclient.data.l[0] = _NET_WM_STATE_ADD; + else + xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; + xev.xclient.data.l[1] = x11drv_atom(_NET_WM_STATE_FULLSCREEN); + xev.xclient.data.l[2] = 0; + xev.xclient.data.l[3] = 1; + + TRACE("action=%li\n", xev.xclient.data.l[0]); + + wine_tsx11_lock(); + XSendEvent( display, DefaultRootWindow(display), False, + SubstructureRedirectMask | SubstructureNotifyMask, &xev ); + wine_tsx11_unlock(); +} /*********************************************************************** * X11DRV_resize_desktop @@ -212,6 +253,7 @@ void X11DRV_resize_desktop( unsigned int width, unsigned int height ) else { TRACE( "desktop %p change to (%dx%d)\n", hwnd, width, height ); + update_desktop_fullscreen( width, height ); SetWindowPos( hwnd, 0, virtual_screen_rect.left, virtual_screen_rect.top, virtual_screen_rect.right - virtual_screen_rect.left, virtual_screen_rect.bottom - virtual_screen_rect.top, diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 2f345e38d00..07139e900ec 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -2684,7 +2684,8 @@ INT CDECL X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState if (e.state & ControlMask) { if (((keysym>=33) && (keysym < 'A')) || - ((keysym > 'Z') && (keysym < 'a'))) + ((keysym > 'Z') && (keysym < 'a')) || + (keysym == XK_Tab)) { lpChar[0] = 0; ret = 0; diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index b15b4e255d8..f207a3217c5 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -76,7 +76,7 @@ typedef struct wine_glextension { struct WineGLInfo { const char *glVersion; - const char *glExtensions; + char *glExtensions; int glxVersion[2]; @@ -274,12 +274,13 @@ MAKE_FUNCPTR(glFinish) MAKE_FUNCPTR(glFlush) #undef MAKE_FUNCPTR +static BOOL infoInitialized = FALSE; static BOOL X11DRV_WineGL_InitOpenglInfo(void) { - static BOOL infoInitialized = FALSE; int screen = DefaultScreen(gdi_display); Window win = RootWindow(gdi_display, screen); + const char* str; Visual *visual; XVisualInfo template; XVisualInfo *vis; @@ -318,7 +319,9 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) } WineGLInfo.glVersion = (const char *) pglGetString(GL_VERSION); - WineGLInfo.glExtensions = strdup((const char *) pglGetString(GL_EXTENSIONS)); + str = (const char *) pglGetString(GL_EXTENSIONS); + WineGLInfo.glExtensions = HeapAlloc(GetProcessHeap(), 0, strlen(str)+1); + strcpy(WineGLInfo.glExtensions, str); /* Get the common GLX version supported by GLX client and server ( major/minor) */ pglXQueryVersion(gdi_display, &WineGLInfo.glxVersion[0], &WineGLInfo.glxVersion[1]); @@ -352,6 +355,12 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) return TRUE; } +void X11DRV_OpenGL_Cleanup(void) +{ + HeapFree(GetProcessHeap(), 0, WineGLInfo.glExtensions); + infoInitialized = FALSE; +} + static BOOL has_opengl(void) { static int init_done; @@ -3626,6 +3635,10 @@ XVisualInfo *visual_from_fbconfig_id( XID fbconfig_id ) #else /* no OpenGL includes */ +void X11DRV_OpenGL_Cleanup(void) +{ +} + static inline void opengl_error(void) { static int warned; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 7d0b2ba0438..b11e6a18b87 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -226,6 +226,7 @@ extern int CDECL X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev, PIXELFORMATDESCRIPTOR *ppfd); extern int CDECL X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev); extern BOOL CDECL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev); +extern void X11DRV_OpenGL_Cleanup(void); /* X11 driver internal functions */ diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 020d6b52876..41c866c3a37 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -587,6 +587,7 @@ static void process_detach(void) /* cleanup GDI */ X11DRV_GDI_Finalize(); + X11DRV_OpenGL_Cleanup(); IME_UnregisterClasses(); DeleteCriticalSection( &X11DRV_CritSection ); diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 904939a2c3b..e9ef0f1cab4 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -1376,6 +1376,7 @@ static void HTTPREQ_Destroy(WININETHANDLEHEADER *hdr) HeapFree(GetProcessHeap(), 0, lpwhr->lpszCacheFile); } + DeleteCriticalSection( &lpwhr->read_section ); WININET_Release(&lpwhr->lpHttpSession->hdr); if (lpwhr->pAuthInfo) @@ -1615,7 +1616,7 @@ static DWORD HTTPREQ_SetOption(WININETHANDLEHEADER *hdr, DWORD option, void *buf return ERROR_INTERNET_INVALID_OPTION; } -/* read some more data into the read buffer */ +/* read some more data into the read buffer (the read section must be held) */ static BOOL read_more_data( WININETHTTPREQW *req, int maxlen ) { int len; @@ -1634,7 +1635,7 @@ static BOOL read_more_data( WININETHTTPREQW *req, int maxlen ) return TRUE; } -/* remove some amount of data from the read buffer */ +/* remove some amount of data from the read buffer (the read section must be held) */ static void remove_data( WININETHTTPREQW *req, int count ) { if (!(req->read_size -= count)) req->read_pos = 0; @@ -1645,6 +1646,7 @@ static BOOL read_line( WININETHTTPREQW *req, LPSTR buffer, DWORD *len ) { int count, bytes_read, pos = 0; + EnterCriticalSection( &req->read_section ); for (;;) { char *eol = memchr( req->read_buf + req->read_pos, '\n', req->read_size ); @@ -1662,14 +1664,15 @@ static BOOL read_line( WININETHTTPREQW *req, LPSTR buffer, DWORD *len ) remove_data( req, bytes_read ); if (eol) break; - if (!read_more_data( req, -1 )) return FALSE; - if (!req->read_size) + if (!read_more_data( req, -1 ) || !req->read_size) { *len = 0; TRACE( "returning empty string\n" ); + LeaveCriticalSection( &req->read_section ); return FALSE; } } + LeaveCriticalSection( &req->read_section ); if (pos < *len) { @@ -1681,7 +1684,7 @@ static BOOL read_line( WININETHTTPREQW *req, LPSTR buffer, DWORD *len ) return TRUE; } -/* discard data contents until we reach end of line */ +/* discard data contents until we reach end of line (the read section must be held) */ static BOOL discard_eol( WININETHTTPREQW *req ) { do @@ -1698,7 +1701,7 @@ static BOOL discard_eol( WININETHTTPREQW *req ) return TRUE; } -/* read the size of the next chunk */ +/* read the size of the next chunk (the read section must be held) */ static BOOL start_next_chunk( WININETHTTPREQW *req ) { DWORD chunk_size = 0; @@ -1738,7 +1741,7 @@ static BOOL start_next_chunk( WININETHTTPREQW *req ) } } -/* return the size of data available to be read immediately */ +/* return the size of data available to be read immediately (the read section must be held) */ static DWORD get_avail_data( WININETHTTPREQW *req ) { if (req->read_chunked && (req->dwContentLength == ~0u || req->dwContentLength == req->dwContentRead)) @@ -1746,7 +1749,7 @@ static DWORD get_avail_data( WININETHTTPREQW *req ) return min( req->read_size, req->dwContentLength - req->dwContentRead ); } -/* check if we have reached the end of the data to read */ +/* check if we have reached the end of the data to read (the read section must be held) */ static BOOL end_of_read_data( WININETHTTPREQW *req ) { if (req->read_chunked) return (req->dwContentLength == 0); @@ -1754,6 +1757,7 @@ static BOOL end_of_read_data( WININETHTTPREQW *req ) return (req->dwContentLength == req->dwContentRead); } +/* fetch some more data into the read buffer (the read section must be held) */ static BOOL refill_buffer( WININETHTTPREQW *req ) { int len = sizeof(req->read_buf); @@ -1777,6 +1781,7 @@ static void HTTP_ReceiveRequestData(WININETHTTPREQW *req, BOOL first_notif) TRACE("%p\n", req); + EnterCriticalSection( &req->read_section ); if (refill_buffer( req )) { iar.dwResult = (DWORD_PTR)req->hdr.hInternet; iar.dwError = first_notif ? 0 : get_avail_data(req); @@ -1784,15 +1789,18 @@ static void HTTP_ReceiveRequestData(WININETHTTPREQW *req, BOOL first_notif) iar.dwResult = 0; iar.dwError = INTERNET_GetLastError(); } + LeaveCriticalSection( &req->read_section ); INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, &iar, sizeof(INTERNET_ASYNC_RESULT)); } +/* read data from the http connection (the read section must be held) */ static DWORD HTTPREQ_Read(WININETHTTPREQW *req, void *buffer, DWORD size, DWORD *read, BOOL sync) { int len, bytes_read = 0; + EnterCriticalSection( &req->read_section ); if (req->read_chunked && (req->dwContentLength == ~0u || req->dwContentLength == req->dwContentRead)) { if (!start_next_chunk( req )) goto done; @@ -1818,6 +1826,8 @@ done: *read = bytes_read; TRACE( "retrieved %u bytes (%u/%u)\n", bytes_read, req->dwContentRead, req->dwContentLength ); + LeaveCriticalSection( &req->read_section ); + if(req->lpszCacheFile) { BOOL res; DWORD dwBytesWritten; @@ -1879,6 +1889,18 @@ static DWORD HTTPREQ_ReadFileExA(WININETHANDLEHEADER *hdr, INTERNET_BUFFERSA *bu { WORKREQUEST workRequest; + if (TryEnterCriticalSection( &req->read_section )) + { + if (get_avail_data(req)) + { + res = HTTPREQ_Read(req, buffers->lpvBuffer, buffers->dwBufferLength, + &buffers->dwBufferLength, FALSE); + LeaveCriticalSection( &req->read_section ); + goto done; + } + LeaveCriticalSection( &req->read_section ); + } + workRequest.asyncproc = HTTPREQ_AsyncReadFileExAProc; workRequest.hdr = WININET_AddRef(&req->hdr); workRequest.u.InternetReadFileExA.lpBuffersOut = buffers; @@ -1891,6 +1913,7 @@ static DWORD HTTPREQ_ReadFileExA(WININETHANDLEHEADER *hdr, INTERNET_BUFFERSA *bu res = HTTPREQ_Read(req, buffers->lpvBuffer, buffers->dwBufferLength, &buffers->dwBufferLength, !(flags & IRF_NO_WAIT)); +done: if (res == ERROR_SUCCESS) { DWORD size = buffers->dwBufferLength; INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, @@ -1935,10 +1958,22 @@ static DWORD HTTPREQ_ReadFileExW(WININETHANDLEHEADER *hdr, INTERNET_BUFFERSW *bu INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); - if ((hdr->dwFlags & INTERNET_FLAG_ASYNC) && !get_avail_data(req)) + if (hdr->dwFlags & INTERNET_FLAG_ASYNC) { WORKREQUEST workRequest; + if (TryEnterCriticalSection( &req->read_section )) + { + if (get_avail_data(req)) + { + res = HTTPREQ_Read(req, buffers->lpvBuffer, buffers->dwBufferLength, + &buffers->dwBufferLength, FALSE); + LeaveCriticalSection( &req->read_section ); + goto done; + } + LeaveCriticalSection( &req->read_section ); + } + workRequest.asyncproc = HTTPREQ_AsyncReadFileExWProc; workRequest.hdr = WININET_AddRef(&req->hdr); workRequest.u.InternetReadFileExW.lpBuffersOut = buffers; @@ -1951,6 +1986,7 @@ static DWORD HTTPREQ_ReadFileExW(WININETHANDLEHEADER *hdr, INTERNET_BUFFERSW *bu res = HTTPREQ_Read(req, buffers->lpvBuffer, buffers->dwBufferLength, &buffers->dwBufferLength, !(flags & IRF_NO_WAIT)); +done: if (res == ERROR_SUCCESS) { DWORD size = buffers->dwBufferLength; INTERNET_SendCallback(&req->hdr, req->hdr.dwContext, INTERNET_STATUS_RESPONSE_RECEIVED, @@ -1988,34 +2024,42 @@ static DWORD HTTPREQ_QueryDataAvailable(WININETHANDLEHEADER *hdr, DWORD *availab TRACE("(%p %p %x %lx)\n", req, available, flags, ctx); - if (!(*available = get_avail_data( req ))) + if (req->lpHttpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) { - if (end_of_read_data( req )) return ERROR_SUCCESS; + WORKREQUEST workRequest; - if (req->lpHttpSession->lpAppInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC) + /* never wait, if we can't enter the section we queue an async request right away */ + if (TryEnterCriticalSection( &req->read_section )) { - WORKREQUEST workRequest; + if ((*available = get_avail_data( req ))) goto done; + if (end_of_read_data( req )) goto done; + LeaveCriticalSection( &req->read_section ); + } - workRequest.asyncproc = HTTPREQ_AsyncQueryDataAvailableProc; - workRequest.hdr = WININET_AddRef( &req->hdr ); + workRequest.asyncproc = HTTPREQ_AsyncQueryDataAvailableProc; + workRequest.hdr = WININET_AddRef( &req->hdr ); - INTERNET_AsyncCall(&workRequest); + INTERNET_AsyncCall(&workRequest); - return ERROR_IO_PENDING; - } - else - { - refill_buffer( req ); - *available = get_avail_data( req ); - } + return ERROR_IO_PENDING; } + EnterCriticalSection( &req->read_section ); + + if (!(*available = get_avail_data( req )) && !end_of_read_data( req )) + { + refill_buffer( req ); + *available = get_avail_data( req ); + } + +done: if (*available == sizeof(req->read_buf)) /* check if we have even more pending in the socket */ { DWORD extra; if (NETCON_query_data_available(&req->netConnection, &extra)) *available = min( *available + extra, req->dwContentLength - req->dwContentRead ); } + LeaveCriticalSection( &req->read_section ); TRACE( "returning %u\n", *available ); return ERROR_SUCCESS; @@ -2075,6 +2119,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, lpwhr->hdr.lpfnStatusCB = lpwhs->hdr.lpfnStatusCB; lpwhr->hdr.dwInternalFlags = lpwhs->hdr.dwInternalFlags & INET_CALLBACKW; lpwhr->dwContentLength = ~0u; + InitializeCriticalSection( &lpwhr->read_section ); WININET_AddRef( &lpwhs->hdr ); lpwhr->lpHttpSession = lpwhs; diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 48271d650ec..c2cb80b906c 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -193,8 +193,6 @@ typedef struct WININET_NETCONNECTION netConnection; LPWSTR lpszVersion; LPWSTR lpszStatusText; - DWORD dwContentLength; /* total number of bytes to be read */ - DWORD dwContentRead; /* bytes of the content read so far */ DWORD dwBytesToWrite; DWORD dwBytesWritten; HTTPHEADERW *pCustHeaders; @@ -203,6 +201,10 @@ typedef struct LPWSTR lpszCacheFile; struct HttpAuthInfo *pAuthInfo; struct HttpAuthInfo *pProxyAuthInfo; + + CRITICAL_SECTION read_section; /* section to protect the following fields */ + DWORD dwContentLength; /* total number of bytes to be read */ + DWORD dwContentRead; /* bytes of the content read so far */ BOOL read_chunked; /* are we reading in chunked mode? */ DWORD read_pos; /* current read position in read_buf */ DWORD read_size; /* valid data size in read_buf */ diff --git a/dlls/winmm/tests/wave.c b/dlls/winmm/tests/wave.c index 3a656acdea6..6430667a873 100644 --- a/dlls/winmm/tests/wave.c +++ b/dlls/winmm/tests/wave.c @@ -799,7 +799,7 @@ static void wave_out_test_deviceOut(int device, double duration, "The sound played for %u ms instead of %g ms\n", actual,1000*(duration+paused)); for (i = 0; i < headers; i++) { - ok(frags[i].dwFlags=(WHDR_DONE|WHDR_PREPARED), + ok(frags[i].dwFlags==(WHDR_DONE|WHDR_PREPARED), "WHDR_DONE WHDR_PREPARED expected, got %s\n", wave_header_flags(frags[i].dwFlags)); } diff --git a/include/commctrl.h b/include/commctrl.h index 9428d99d389..e39f4a2391f 100644 --- a/include/commctrl.h +++ b/include/commctrl.h @@ -3724,6 +3724,11 @@ typedef struct NMLVSCROLL SNDMSG(hwnd, LVM_SETITEMSTATE, (WPARAM)(UINT)i, (LPARAM) (LPLVITEM)&_LVi);} #define ListView_GetItemState(hwnd,i,mask) \ (UINT)SNDMSG((hwnd),LVM_GETITEMSTATE,(WPARAM)(UINT)(i),(LPARAM)(UINT)(mask)) +#define ListView_SetCheckState(hwndLV, i, bCheck) \ + { LVITEM _LVi; _LVi.state = INDEXTOSTATEIMAGEMASK((bCheck)?2:1); _LVi.stateMask = LVIS_STATEIMAGEMASK; \ + SNDMSG(hwndLV, LVM_SETITEMSTATE, (WPARAM)(UINT)(i), (LPARAM)(LPLVITEM)&_LVi);} +#define ListView_GetCheckState(hwndLV, i) \ + (((UINT)SNDMSG((hwndLV), LVM_GETITEMSTATE, (i), LVIS_STATEIMAGEMASK) >> 12) - 1) #define ListView_GetCountPerPage(hwnd) \ (BOOL)SNDMSG((hwnd),LVM_GETCOUNTPERPAGE,0,0L) #define ListView_GetImageList(hwnd,iImageList) \ diff --git a/include/msctf.idl b/include/msctf.idl index 93f70c177b9..0a441a68aa1 100644 --- a/include/msctf.idl +++ b/include/msctf.idl @@ -33,6 +33,17 @@ cpp_quote("EXTERN_C const CLSID CLSID_TF_ThreadMgr;") cpp_quote("EXTERN_C const CLSID CLSID_TF_InputProcessorProfiles;") cpp_quote("EXTERN_C const CLSID CLSID_TF_CategoryMgr;") +/* GUIDs for Compartments */ +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_KEYBOARD_DISABLED;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_KEYBOARD_OPENCLOSE;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_HANDWRITING_OPENCLOSE;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_SPEECH_DISABLED;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_SPEECH_OPENCLOSE;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_SPEECH_GLOBALSTATE;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_PERSISTMENUENABLED;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_EMPTYCONTEXT;") +cpp_quote("EXTERN_C const GUID GUID_COMPARTMENT_TIPUISTATUS;") + /* GUIDs for Categories */ cpp_quote("EXTERN_C const GUID GUID_TFCAT_TIP_KEYBOARD;") cpp_quote("EXTERN_C const GUID GUID_TFCAT_TIP_SPEECH;") @@ -868,3 +879,28 @@ interface ITfRange : IUnknown HRESULT GetContext( [out] ITfContext **ppContext); }; + +[ + object, + uuid(55ce16ba-3014-41c1-9ceb-fade1446ac6c), + pointer_default(unique) +] +interface ITfInsertAtSelection : IUnknown +{ + const DWORD TF_IAS_NOQUERY = 0x1; + const DWORD TF_IAS_QUERYONLY = 0x2; + const DWORD TF_IAS_NO_DEFAULT_COMPOSITION = 0x80000000; + + HRESULT InsertTextAtSelection( + [in] TfEditCookie ec, + [in] DWORD dwFlags, + [in, size_is(cch)] const WCHAR *pchText, + [in] LONG cch, + [out] ITfRange **ppRange); + + HRESULT InsertEmbeddedAtSelection( + [in] TfEditCookie ec, + [in] DWORD dwFlags, + [in] IDataObject *pDataObject, + [out] ITfRange **ppRange); +}; diff --git a/include/msvcrt/conio.h b/include/msvcrt/conio.h index 7d4797b41ea..18f3d24b730 100644 --- a/include/msvcrt/conio.h +++ b/include/msvcrt/conio.h @@ -26,10 +26,10 @@ int __cdecl _ungetch(int); #ifdef _M_IX86 int __cdecl _inp(unsigned short); -unsigned long __cdecl _inpd(unsigned short); +__msvcrt_ulong __cdecl _inpd(unsigned short); unsigned short __cdecl _inpw(unsigned short); int __cdecl _outp(unsigned short, int); -unsigned long __cdecl _outpd(unsigned short, unsigned long); +__msvcrt_ulong __cdecl _outpd(unsigned short, __msvcrt_ulong); unsigned short __cdecl _outpw(unsigned short, unsigned short); #endif diff --git a/include/msvcrt/crtdbg.h b/include/msvcrt/crtdbg.h index 83cd85e4cc3..f8e3db89b47 100644 --- a/include/msvcrt/crtdbg.h +++ b/include/msvcrt/crtdbg.h @@ -44,10 +44,10 @@ typedef struct _CrtMemState { struct _CrtMemBlockHeader* pBlockHeader; - unsigned long lCounts[_MAX_BLOCKS]; - unsigned long lSizes[_MAX_BLOCKS]; - unsigned long lHighWaterCount; - unsigned long lTotalCount; + __msvcrt_ulong lCounts[_MAX_BLOCKS]; + __msvcrt_ulong lSizes[_MAX_BLOCKS]; + __msvcrt_ulong lHighWaterCount; + __msvcrt_ulong lTotalCount; } _CrtMemState; @@ -60,7 +60,7 @@ typedef struct _CrtMemState #define _CrtCheckMemory() ((int)1) #define _CrtDbgReport(...) ((int)0) #define _CrtDumpMemoryLeaks() ((int)0) -#define _CrtSetBreakAlloc(a) ((long)0) +#define _CrtSetBreakAlloc(a) ((__msvcrt_long)0) #define _CrtSetDbgFlag(f) ((int)0) #define _CrtSetDumpClient(f) ((void)0) #define _CrtSetReportMode(t,m) ((int)0) diff --git a/include/msvcrt/crtdefs.h b/include/msvcrt/crtdefs.h index 9eac870ea75..2a101a92b2b 100644 --- a/include/msvcrt/crtdefs.h +++ b/include/msvcrt/crtdefs.h @@ -80,6 +80,13 @@ # endif #endif +#ifndef _MSVCRT_LONG_DEFINED +#define _MSVCRT_LONG_DEFINED +/* we need 32-bit longs even on 64-bit */ +typedef int __msvcrt_long; +typedef unsigned int __msvcrt_ulong; +#endif + #ifndef _INTPTR_T_DEFINED #ifdef _WIN64 typedef __int64 intptr_t; @@ -117,7 +124,7 @@ typedef unsigned int size_t; #endif #ifndef _TIME32_T_DEFINED -typedef long __time32_t; +typedef __msvcrt_long __time32_t; #define _TIME32_T_DEFINED #endif @@ -126,11 +133,19 @@ typedef __int64 __time64_t; #define _TIME64_T_DEFINED #endif +#ifdef _USE_32BIT_TIME_T +# ifdef _WIN64 +# error You cannot use 32-bit time_t in Win64 +# endif +#elif !defined(_WIN64) +# define _USE_32BIT_TIME_T +#endif + #ifndef _TIME_T_DEFINED -#ifdef _WIN64 -typedef __time64_t time_t; -#else +#ifdef _USE_32BIT_TIME_T typedef __time32_t time_t; +#else +typedef __time64_t time_t; #endif #define _TIME_T_DEFINED #endif diff --git a/include/msvcrt/direct.h b/include/msvcrt/direct.h index dd5f4215454..45db8e2f2b1 100644 --- a/include/msvcrt/direct.h +++ b/include/msvcrt/direct.h @@ -31,7 +31,7 @@ int __cdecl _chdrive(int); char* __cdecl _getcwd(char*,int); char* __cdecl _getdcwd(int,char*,int); int __cdecl _getdrive(void); -unsigned long __cdecl _getdrives(void); +__msvcrt_ulong __cdecl _getdrives(void); int __cdecl _mkdir(const char*); int __cdecl _rmdir(const char*); diff --git a/include/msvcrt/float.h b/include/msvcrt/float.h index b656e0960a2..a238d13cc54 100644 --- a/include/msvcrt/float.h +++ b/include/msvcrt/float.h @@ -128,7 +128,7 @@ extern "C" { double __cdecl _copysign (double, double); double __cdecl _chgsign (double); -double __cdecl _scalb(double, long); +double __cdecl _scalb(double, __msvcrt_long); double __cdecl _logb(double); double __cdecl _nextafter(double, double); int __cdecl _finite(double); diff --git a/include/msvcrt/io.h b/include/msvcrt/io.h index e9a970e3d27..e15dff1ac8d 100644 --- a/include/msvcrt/io.h +++ b/include/msvcrt/io.h @@ -22,7 +22,7 @@ #define _A_ARCH 0x00000020 #ifndef _FSIZE_T_DEFINED -typedef unsigned long _fsize_t; +typedef __msvcrt_ulong _fsize_t; #define _FSIZE_T_DEFINED #endif @@ -76,7 +76,7 @@ extern "C" { int __cdecl _access(const char*,int); int __cdecl _chmod(const char*,int); -int __cdecl _chsize(int,long); +int __cdecl _chsize(int,__msvcrt_ulong); int __cdecl _close(int); int __cdecl _commit(int); int __cdecl _creat(const char*,int); @@ -84,7 +84,7 @@ int __cdecl _dup(int); int __cdecl _dup2(int,int); int __cdecl _eof(int); __int64 __cdecl _filelengthi64(int); -long __cdecl _filelength(int); +__msvcrt_long __cdecl _filelength(int); int __cdecl _findclose(intptr_t); intptr_t __cdecl _findfirst(const char*,struct _finddata_t*); intptr_t __cdecl _findfirsti64(const char*, struct _finddatai64_t*); @@ -92,8 +92,8 @@ int __cdecl _findnext(intptr_t,struct _finddata_t*); int __cdecl _findnexti64(intptr_t, struct _finddatai64_t*); intptr_t __cdecl _get_osfhandle(int); int __cdecl _isatty(int); -int __cdecl _locking(int,int,long); -long __cdecl _lseek(int,long,int); +int __cdecl _locking(int,int,__msvcrt_long); +__msvcrt_long __cdecl _lseek(int,__msvcrt_long,int); __int64 __cdecl _lseeki64(int,__int64,int); char* __cdecl _mktemp(char*); int __cdecl _open(const char*,int,...); @@ -102,7 +102,7 @@ int __cdecl _pipe(int*,unsigned int,int); int __cdecl _read(int,void*,unsigned int); int __cdecl _setmode(int,int); int __cdecl _sopen(const char*,int,int,...); -long __cdecl _tell(int); +__msvcrt_long __cdecl _tell(int); __int64 __cdecl _telli64(int); int __cdecl _umask(int); int __cdecl _unlink(const char*); @@ -134,20 +134,20 @@ int __cdecl _wunlink(const wchar_t*); static inline int access(const char* path, int mode) { return _access(path, mode); } static inline int chmod(const char* path, int mode) { return _chmod(path, mode); } -static inline int chsize(int fd, long size) { return _chsize(fd, size); } +static inline int chsize(int fd, __msvcrt_long size) { return _chsize(fd, size); } static inline int close(int fd) { return _close(fd); } static inline int creat(const char* path, int mode) { return _creat(path, mode); } static inline int dup(int od) { return _dup(od); } static inline int dup2(int od, int nd) { return _dup2(od, nd); } static inline int eof(int fd) { return _eof(fd); } -static inline long filelength(int fd) { return _filelength(fd); } +static inline __msvcrt_long filelength(int fd) { return _filelength(fd); } static inline int isatty(int fd) { return _isatty(fd); } -static inline int locking(int fd, int mode, long size) { return _locking(fd, mode, size); } -static inline long lseek(int fd, long off, int where) { return _lseek(fd, off, where); } +static inline int locking(int fd, int mode, __msvcrt_long size) { return _locking(fd, mode, size); } +static inline __msvcrt_long lseek(int fd, __msvcrt_long off, int where) { return _lseek(fd, off, where); } static inline char* mktemp(char* pat) { return _mktemp(pat); } static inline int read(int fd, void* buf, unsigned int size) { return _read(fd, buf, size); } static inline int setmode(int fd, int mode) { return _setmode(fd, mode); } -static inline long tell(int fd) { return _tell(fd); } +static inline __msvcrt_long tell(int fd) { return _tell(fd); } #ifndef _UMASK_DEFINED static inline int umask(int fd) { return _umask(fd); } #define _UMASK_DEFINED diff --git a/include/msvcrt/stddef.h b/include/msvcrt/stddef.h index 7a0288e8c29..4f353517f9d 100644 --- a/include/msvcrt/stddef.h +++ b/include/msvcrt/stddef.h @@ -41,8 +41,8 @@ extern "C" { #endif -unsigned long __cdecl __threadid(void); -unsigned long __cdecl __threadhandle(void); +__msvcrt_ulong __cdecl __threadid(void); +__msvcrt_ulong __cdecl __threadhandle(void); #define _threadid (__threadid()) #ifdef __cplusplus diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h index f2398b59309..1b3872cc372 100644 --- a/include/msvcrt/stdio.h +++ b/include/msvcrt/stdio.h @@ -133,9 +133,9 @@ int __cdecl fputs(const char*,FILE*); size_t __cdecl fread(void*,size_t,size_t,FILE*); FILE* __cdecl freopen(const char*,const char*,FILE*); int __cdecl fscanf(FILE*,const char*,...); -int __cdecl fseek(FILE*,long,int); +int __cdecl fseek(FILE*,__msvcrt_long,int); int __cdecl fsetpos(FILE*,fpos_t*); -long __cdecl ftell(FILE*); +__msvcrt_long __cdecl ftell(FILE*); size_t __cdecl fwrite(const void*,size_t,size_t,FILE*); int __cdecl getc(FILE*); int __cdecl getchar(void); diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h index eae4d53593b..2531f73b5f6 100644 --- a/include/msvcrt/stdlib.h +++ b/include/msvcrt/stdlib.h @@ -54,8 +54,8 @@ typedef struct _div_t { } div_t; typedef struct _ldiv_t { - long quot; - long rem; + __msvcrt_long quot; + __msvcrt_long rem; } ldiv_t; #define __max(a,b) (((a) > (b)) ? (a) : (b)) @@ -116,7 +116,7 @@ extern unsigned int _fmode; extern int* __cdecl ___mb_cur_max_func(void); #define __mb_cur_max (*___mb_cur_max_func()) -extern unsigned long* __cdecl __doserrno(void); +extern __msvcrt_ulong* __cdecl __doserrno(void); #define _doserrno (*__doserrno()) extern int* __cdecl _errno(void); #define errno (*_errno()) @@ -142,9 +142,9 @@ char* __cdecl _fullpath(char*,const char*,size_t); char* __cdecl _gcvt(double,int,char*); char* __cdecl _i64toa(__int64,char*,int); char* __cdecl _itoa(int,char*,int); -char* __cdecl _ltoa(long,char*,int); -unsigned long __cdecl _lrotl(unsigned long,int); -unsigned long __cdecl _lrotr(unsigned long,int); +char* __cdecl _ltoa(__msvcrt_long,char*,int); +__msvcrt_ulong __cdecl _lrotl(__msvcrt_ulong,int); +__msvcrt_ulong __cdecl _lrotr(__msvcrt_ulong,int); void __cdecl _makepath(char*,const char*,const char*,const char*,const char*); size_t __cdecl _mbstrlen(const char*); _onexit_t __cdecl _onexit(_onexit_t); @@ -154,12 +154,12 @@ unsigned int __cdecl _rotr(unsigned int,int); void __cdecl _searchenv(const char*,const char*,char*); int __cdecl _set_error_mode(int); void __cdecl _seterrormode(int); -void __cdecl _sleep(unsigned long); +void __cdecl _sleep(__msvcrt_ulong); void __cdecl _splitpath(const char*,char*,char*,char*,char*); long double __cdecl _strtold(const char*,char**); void __cdecl _swab(char*,char*,int); char* __cdecl _ui64toa(unsigned __int64,char*,int); -char* __cdecl _ultoa(unsigned long,char*,int); +char* __cdecl _ultoa(__msvcrt_ulong,char*,int); void __cdecl _exit(int); void __cdecl abort(void); @@ -167,16 +167,16 @@ int __cdecl abs(int); int __cdecl atexit(void (*)(void)); double __cdecl atof(const char*); int __cdecl atoi(const char*); -long __cdecl atol(const char*); +__msvcrt_long __cdecl atol(const char*); void* __cdecl calloc(size_t,size_t); #ifndef __i386__ div_t __cdecl div(int,int); -ldiv_t __cdecl ldiv(long,long); +ldiv_t __cdecl ldiv(__msvcrt_long,__msvcrt_long); #endif void __cdecl exit(int); void __cdecl free(void*); char* __cdecl getenv(const char*); -long __cdecl labs(long); +__msvcrt_long __cdecl labs(__msvcrt_long); void* __cdecl malloc(size_t); int __cdecl mblen(const char*,size_t); void __cdecl perror(const char*); @@ -184,8 +184,8 @@ int __cdecl rand(void); void* __cdecl realloc(void*,size_t); void __cdecl srand(unsigned int); double __cdecl strtod(const char*,char**); -long __cdecl strtol(const char*,char**,int); -unsigned long __cdecl strtoul(const char*,char**,int); +__msvcrt_long __cdecl strtol(const char*,char**,int); +__msvcrt_ulong __cdecl strtoul(const char*,char**,int); int __cdecl system(const char*); void* __cdecl bsearch(const void*,const void*,size_t,size_t,int (*)(const void*,const void*)); void __cdecl qsort(void*,size_t,size_t,int (*)(const void*,const void*)); @@ -194,9 +194,9 @@ void __cdecl qsort(void*,size_t,size_t,int (*)(const void*,const void*) #define _WSTDLIB_DEFINED wchar_t* __cdecl _itow(int,wchar_t*,int); wchar_t* __cdecl _i64tow(__int64,wchar_t*,int); -wchar_t* __cdecl _ltow(long,wchar_t*,int); +wchar_t* __cdecl _ltow(__msvcrt_long,wchar_t*,int); wchar_t* __cdecl _ui64tow(unsigned __int64,wchar_t*,int); -wchar_t* __cdecl _ultow(unsigned long,wchar_t*,int); +wchar_t* __cdecl _ultow(__msvcrt_ulong,wchar_t*,int); wchar_t* __cdecl _wfullpath(wchar_t*,const wchar_t*,size_t); wchar_t* __cdecl _wgetenv(const wchar_t*); void __cdecl _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*); @@ -207,14 +207,14 @@ void __cdecl _wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wcha int __cdecl _wsystem(const wchar_t*); int __cdecl _wtoi(const wchar_t*); __int64 __cdecl _wtoi64(const wchar_t*); -long __cdecl _wtol(const wchar_t*); +__msvcrt_long __cdecl _wtol(const wchar_t*); size_t __cdecl mbstowcs(wchar_t*,const char*,size_t); int __cdecl mbtowc(wchar_t*,const char*,size_t); double __cdecl wcstod(const wchar_t*,wchar_t**); -long __cdecl wcstol(const wchar_t*,wchar_t**,int); +__msvcrt_long __cdecl wcstol(const wchar_t*,wchar_t**,int); size_t __cdecl wcstombs(char*,const wchar_t*,size_t); -unsigned long __cdecl wcstoul(const wchar_t*,wchar_t**,int); +__msvcrt_ulong __cdecl wcstoul(const wchar_t*,wchar_t**,int); int __cdecl wctomb(char*,wchar_t); #endif /* _WSTDLIB_DEFINED */ @@ -230,11 +230,11 @@ static inline char* ecvt(double value, int ndigit, int* decpt, int* sign) { retu static inline char* fcvt(double value, int ndigit, int* decpt, int* sign) { return _fcvt(value, ndigit, decpt, sign); } static inline char* gcvt(double value, int ndigit, char* buf) { return _gcvt(value, ndigit, buf); } static inline char* itoa(int value, char* str, int radix) { return _itoa(value, str, radix); } -static inline char* ltoa(long value, char* str, int radix) { return _ltoa(value, str, radix); } +static inline char* ltoa(__msvcrt_long value, char* str, int radix) { return _ltoa(value, str, radix); } static inline _onexit_t onexit(_onexit_t func) { return _onexit(func); } static inline int putenv(const char* str) { return _putenv(str); } static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); } -static inline char* ultoa(unsigned long value, char* str, int radix) { return _ultoa(value, str, radix); } +static inline char* ultoa(__msvcrt_ulong value, char* str, int radix) { return _ultoa(value, str, radix); } #ifdef __i386__ static inline div_t __wine_msvcrt_div(int num, int denom) @@ -246,13 +246,13 @@ static inline div_t __wine_msvcrt_div(int num, int denom) ret.rem = (int)(res >> 32); return ret; } -static inline ldiv_t __wine_msvcrt_ldiv(long num, long denom) +static inline ldiv_t __wine_msvcrt_ldiv(__msvcrt_long num, __msvcrt_long denom) { - extern unsigned __int64 ldiv(long,long); + extern unsigned __int64 ldiv(__msvcrt_long,__msvcrt_long); ldiv_t ret; unsigned __int64 res = ldiv(num,denom); - ret.quot = (long)res; - ret.rem = (long)(res >> 32); + ret.quot = (__msvcrt_long)res; + ret.rem = (__msvcrt_long)(res >> 32); return ret; } #define div(num,denom) __wine_msvcrt_div(num,denom) diff --git a/include/msvcrt/sys/timeb.h b/include/msvcrt/sys/timeb.h index a3259130a60..783ccbccbc1 100644 --- a/include/msvcrt/sys/timeb.h +++ b/include/msvcrt/sys/timeb.h @@ -33,6 +33,20 @@ struct _timeb short timezone; short dstflag; }; +struct __timeb32 +{ + __time32_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; +struct __timeb64 +{ + __time64_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; #endif /* _TIMEB_DEFINED */ @@ -40,12 +54,18 @@ struct _timeb extern "C" { #endif -void __cdecl _ftime(struct _timeb*); +void __cdecl _ftime32(struct __timeb32*); +void __cdecl _ftime64(struct __timeb64*); #ifdef __cplusplus } #endif +#ifdef _USE_32BIT_TIME_T +static inline void __cdecl _ftime(struct _timeb *tb) { return _ftime32((struct __timeb32*)tb); } +#else +static inline void __cdecl _ftime(struct _timeb *tb) { return _ftime64((struct __timeb64*)tb); } +#endif #define timeb _timeb diff --git a/include/msvcrt/sys/types.h b/include/msvcrt/sys/types.h index a52e00d19bd..fa60bf4aa60 100644 --- a/include/msvcrt/sys/types.h +++ b/include/msvcrt/sys/types.h @@ -46,7 +46,7 @@ typedef int _off_t; typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; -typedef unsigned long u_long; +typedef __msvcrt_ulong u_long; #define _BSDTYPES_DEFINED #endif diff --git a/include/msvcrt/sys/utime.h b/include/msvcrt/sys/utime.h index 95b1f9bc5f9..014351bd0f1 100644 --- a/include/msvcrt/sys/utime.h +++ b/include/msvcrt/sys/utime.h @@ -31,15 +31,38 @@ struct _utimbuf time_t actime; time_t modtime; }; +struct __utimbuf32 +{ + __time32_t actime; + __time32_t modtime; +}; +struct __utimbuf64 +{ + __time64_t actime; + __time64_t modtime; +}; #endif /* _UTIMBUF_DEFINED */ #ifdef __cplusplus extern "C" { #endif -int __cdecl _futime(int,struct _utimbuf*); -int __cdecl _utime(const char*,struct _utimbuf*); -int __cdecl _wutime(const wchar_t*,struct _utimbuf*); +int __cdecl _futime32(int,struct __utimbuf32*); +int __cdecl _futime64(int,struct __utimbuf64*); +int __cdecl _utime32(const char*,struct __utimbuf32*); +int __cdecl _utime64(const char*,struct __utimbuf64*); +int __cdecl _wutime32(const wchar_t*,struct __utimbuf32*); +int __cdecl _wutime64(const wchar_t*,struct __utimbuf64*); + +#ifdef _USE_32BIT_TIME_T +static inline int _futime(int fd, struct _utimbuf *buf) { return _futime32(fd, (struct __utimbuf32*)buf); } +static inline int _utime(const char *s, struct _utimbuf *buf) { return _utime32(s, (struct __utimbuf32*)buf); } +static inline int _wutime(const wchar_t *s, struct _utimbuf *buf) { return _wutime32(s, (struct __utimbuf32*)buf); } +#else +static inline int _futime(int fd, struct _utimbuf *buf) { return _futime64(fd, (struct __utimbuf64*)buf); } +static inline int _utime(const char *s, struct _utimbuf *buf) { return _utime64(s, (struct __utimbuf64*)buf); } +static inline int _wutime(const wchar_t *s, struct _utimbuf *buf) { return _wutime64(s, (struct __utimbuf64*)buf); } +#endif #ifdef __cplusplus } diff --git a/include/msvcrt/time.h b/include/msvcrt/time.h index 7b0eb4c8b13..4c44c7b8270 100644 --- a/include/msvcrt/time.h +++ b/include/msvcrt/time.h @@ -25,7 +25,7 @@ #include #ifndef _CLOCK_T_DEFINED -typedef long clock_t; +typedef __msvcrt_long clock_t; #define _CLOCK_T_DEFINED #endif @@ -67,16 +67,25 @@ extern "C" { #define _tzname (__p__tzname()) int * __cdecl __p__daylight(void); -long * __cdecl __p__dstbias(void); -long * __cdecl __p__timezone(void); +__msvcrt_long * __cdecl __p__dstbias(void); +__msvcrt_long * __cdecl __p__timezone(void); char ** __cdecl __p__tzname(void); #else extern int _daylight; -extern long _dstbias; -extern long _timezone; +extern __msvcrt_long _dstbias; +extern __msvcrt_long _timezone; extern char *_tzname; #endif +#ifdef _USE_32BIT_TIME_T +#define _ctime32 ctime +#define _difftime32 difftime +#define _gmtime32 gmtime +#define _localtime32 localtime +#define _mktime32 mktime +#define _time32 time +#endif + unsigned __cdecl _getsystime(struct tm*); unsigned __cdecl _setsystime(struct tm*,unsigned); char* __cdecl _strdate(char*); @@ -85,21 +94,47 @@ void __cdecl _tzset(void); char* __cdecl asctime(const struct tm*); clock_t __cdecl clock(void); -char* __cdecl ctime(const time_t*); -double __cdecl difftime(time_t,time_t); -struct tm* __cdecl gmtime(const time_t*); -struct tm* __cdecl localtime(const time_t*); -time_t __cdecl mktime(struct tm*); +char* __cdecl _ctime32(const __time32_t*); +char* __cdecl _ctime64(const __time64_t*); +double __cdecl _difftime32(__time32_t,__time32_t); +double __cdecl _difftime64(__time64_t,__time64_t); +struct tm* __cdecl _gmtime32(const __time32_t*); +struct tm* __cdecl _gmtime64(const __time64_t*); +struct tm* __cdecl _localtime32(const __time32_t*); +struct tm* __cdecl _localtime64(const __time64_t*); +__time32_t __cdecl _mktime32(struct tm*); +__time64_t __cdecl _mktime64(struct tm*); size_t __cdecl strftime(char*,size_t,const char*,const struct tm*); -time_t __cdecl time(time_t*); +__time32_t __cdecl _time32(__time32_t*); +__time64_t __cdecl _time64(__time64_t*); + +#ifndef _USE_32BIT_TIME_T +static inline char* ctime(const time_t *t) { return _ctime64(t); } +static inline double difftime(time_t t1, time_t t2) { return _difftime64(t1, t2); } +static inline struct tm* gmtime(const time_t *t) { return _gmtime64(t); } +static inline struct tm* localtime(const time_t *t) { return _localtime64(t); } +static inline time_t mktime(struct tm *tm) { return _mktime64(tm); } +static inline time_t time(time_t *t) { return _time64(t); } +#endif #ifndef _WTIME_DEFINED #define _WTIME_DEFINED + +#ifdef _USE_32BIT_TIME_T +#define _wctime32 _wctime +#endif + wchar_t* __cdecl _wasctime(const struct tm*); size_t __cdecl wcsftime(wchar_t*,size_t,const wchar_t*,const struct tm*); -wchar_t* __cdecl _wctime(const time_t*); +wchar_t* __cdecl _wctime32(const __time32_t*); +wchar_t* __cdecl _wctime64(const __time64_t*); wchar_t* __cdecl _wstrdate(wchar_t*); wchar_t* __cdecl _wstrtime(wchar_t*); + +#ifndef _USE_32BIT_TIME_T +static inline wchar_t* _wctime(const time_t *t) { return _wctime64(t); } +#endif + #endif /* _WTIME_DEFINED */ #ifdef __cplusplus diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h index 03d6107edeb..fe761667bad 100644 --- a/include/msvcrt/wchar.h +++ b/include/msvcrt/wchar.h @@ -45,7 +45,7 @@ typedef int mbstate_t; #endif #ifndef _FSIZE_T_DEFINED -typedef unsigned long _fsize_t; +typedef __msvcrt_ulong _fsize_t; #define _FSIZE_T_DEFINED #endif @@ -224,10 +224,10 @@ int __cdecl _wrmdir(const wchar_t*); int __cdecl _waccess(const wchar_t*,int); int __cdecl _wchmod(const wchar_t*,int); int __cdecl _wcreat(const wchar_t*,int); -long __cdecl _wfindfirst(const wchar_t*,struct _wfinddata_t*); -long __cdecl _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*); -int __cdecl _wfindnext(long,struct _wfinddata_t*); -int __cdecl _wfindnexti64(long, struct _wfinddatai64_t*); +__msvcrt_long __cdecl _wfindfirst(const wchar_t*,struct _wfinddata_t*); +__msvcrt_long __cdecl _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*); +int __cdecl _wfindnext(__msvcrt_long,struct _wfinddata_t*); +int __cdecl _wfindnexti64(__msvcrt_long, struct _wfinddatai64_t*); wchar_t* __cdecl _wmktemp(wchar_t*); int __cdecl _wopen(const wchar_t*,int,...); int __cdecl _wrename(const wchar_t*,const wchar_t*); @@ -314,9 +314,9 @@ int __cdecl wscanf(const wchar_t*,...); #define _WSTDLIB_DEFINED wchar_t* __cdecl _itow(int,wchar_t*,int); wchar_t* __cdecl _i64tow(__int64,wchar_t*,int); -wchar_t* __cdecl _ltow(long,wchar_t*,int); +wchar_t* __cdecl _ltow(__msvcrt_long,wchar_t*,int); wchar_t* __cdecl _ui64tow(unsigned __int64,wchar_t*,int); -wchar_t* __cdecl _ultow(unsigned long,wchar_t*,int); +wchar_t* __cdecl _ultow(__msvcrt_ulong,wchar_t*,int); wchar_t* __cdecl _wfullpath(wchar_t*,const wchar_t*,size_t); wchar_t* __cdecl _wgetenv(const wchar_t*); void __cdecl _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*); @@ -327,14 +327,14 @@ void __cdecl _wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wchar_t*) int __cdecl _wsystem(const wchar_t*); int __cdecl _wtoi(const wchar_t*); __int64 __cdecl _wtoi64(const wchar_t*); -long __cdecl _wtol(const wchar_t*); +__msvcrt_long __cdecl _wtol(const wchar_t*); size_t __cdecl mbstowcs(wchar_t*,const char*,size_t); int __cdecl mbtowc(wchar_t*,const char*,size_t); double __cdecl wcstod(const wchar_t*,wchar_t**); -long __cdecl wcstol(const wchar_t*,wchar_t**,int); +__msvcrt_long __cdecl wcstol(const wchar_t*,wchar_t**,int); size_t __cdecl wcstombs(char*,const wchar_t*,size_t); -unsigned long __cdecl wcstoul(const wchar_t*,wchar_t**,int); +__msvcrt_ulong __cdecl wcstoul(const wchar_t*,wchar_t**,int); int __cdecl wctomb(char*,wchar_t); #endif /* _WSTDLIB_DEFINED */ @@ -370,11 +370,22 @@ size_t __cdecl wcsxfrm(wchar_t*,const wchar_t*,size_t); #ifndef _WTIME_DEFINED #define _WTIME_DEFINED + +#ifdef _USE_32BIT_TIME_T +#define _wctime32 _wctime +#endif + wchar_t* __cdecl _wasctime(const struct tm*); size_t __cdecl wcsftime(wchar_t*,size_t,const wchar_t*,const struct tm*); -wchar_t* __cdecl _wctime(const time_t*); +wchar_t* __cdecl _wctime32(const __time32_t*); +wchar_t* __cdecl _wctime64(const __time64_t*); wchar_t* __cdecl _wstrdate(wchar_t*); wchar_t* __cdecl _wstrtime(wchar_t*); + +#ifndef _USE_32BIT_TIME_T +static inline wchar_t* _wctime(const time_t *t) { return _wctime64(t); } +#endif + #endif /* _WTIME_DEFINED */ wchar_t __cdecl btowc(int); diff --git a/include/rpcndr.h b/include/rpcndr.h index 10aac4c9f0a..78c9a477a47 100644 --- a/include/rpcndr.h +++ b/include/rpcndr.h @@ -170,7 +170,6 @@ typedef struct _NDR_PIPE_MESSAGE *PNDR_PIPE_MESSAGE; typedef struct _NDR_ASYNC_MESSAGE *PNDR_ASYNC_MESSAGE; typedef struct _NDR_CORRELATION_INFO *PNDR_CORRELATION_INFO; -#include typedef struct _MIDL_STUB_MESSAGE { PRPC_MESSAGE RpcMsg; @@ -247,7 +246,6 @@ typedef struct _MIDL_STUB_MESSAGE INT_PTR Reserved51_4; INT_PTR Reserved51_5; } MIDL_STUB_MESSAGE, *PMIDL_STUB_MESSAGE; -#include typedef void * (__RPC_API * GENERIC_BINDING_ROUTINE)(void *); typedef void (__RPC_API * GENERIC_UNBIND_ROUTINE)(void *, unsigned char *); diff --git a/include/schannel.h b/include/schannel.h index 1e7dfcca876..d522edfce83 100644 --- a/include/schannel.h +++ b/include/schannel.h @@ -163,9 +163,9 @@ typedef struct _SCHANNEL_CRED DWORD grbitEnabledProtocols; DWORD dwMinimumCipherStrength; DWORD dwMaximumCipherStrength; - DWORD dwSessionLength; + DWORD dwSessionLifespan; DWORD dwFlags; - DWORD reserved; + DWORD dwCredFormat; } SCHANNEL_CRED, *PSCHANNEL_CRED; typedef struct _SecPkgCred_SupportedAlgs diff --git a/include/wincrypt.h b/include/wincrypt.h index 75017fee939..067dd7c1e8f 100644 --- a/include/wincrypt.h +++ b/include/wincrypt.h @@ -1041,6 +1041,7 @@ typedef struct _CERT_CHAIN_PARA { DWORD dwUrlRetrievalTimeout; BOOL fCheckRevocationFreshnessTime; DWORD dwRevocationFreshnessTime; + LPFILETIME pftCacheResync; #endif } CERT_CHAIN_PARA, *PCERT_CHAIN_PARA; diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index 7a476e858e1..51d886c85c6 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -2868,9 +2868,6 @@ interface IWineD3DVertexShader : IWineD3DBaseShader [out] void *data, [in, out] UINT *data_size ); - void FakeSemantics( - [in] IWineD3DVertexDeclaration *vertex_declaration - ); HRESULT SetLocalConstantsF( [in] UINT start_idx, [in] const float *src_data, @@ -3011,8 +3008,8 @@ interface IWineD3DDevice : IWineD3DBase [in] DWORD fvf ); HRESULT CreateVertexShader( - [in] IWineD3DVertexDeclaration *declaration, [in] const DWORD *function, + [in] const struct wined3d_shader_signature *output_signature, [out] IWineD3DVertexShader **shader, [in] IUnknown *parent ); @@ -3471,9 +3468,6 @@ interface IWineD3DDevice : IWineD3DBase [in] UINT swapchain_idx, [in] IWineD3DSurface *dst_surface ); - void ResourceReleased( - [in] IWineD3DResource *resource - ); HRESULT EnumResources( [in] D3DCB_ENUMRESOURCES callback, [in] void *data diff --git a/include/wininet.h b/include/wininet.h index 6ce8ae03868..e37700af23c 100644 --- a/include/wininet.h +++ b/include/wininet.h @@ -1464,7 +1464,10 @@ INTERNETAPI DWORD WINAPI PrivacyGetZonePreferenceW(DWORD,DWORD,LPDWORD,LPWSTR,LP #define ERROR_INTERNET_SEC_CERT_REVOKED (INTERNET_ERROR_BASE + 170) #define ERROR_INTERNET_FAILED_DUETOSECURITYCHECK (INTERNET_ERROR_BASE + 171) #define ERROR_INTERNET_NOT_INITIALIZED (INTERNET_ERROR_BASE + 172) -#define INTERNET_ERROR_LAST ERROR_INTERNET_NOT_INITIALIZED +#define ERROR_INTERNET_NEED_MSN_SSPI_PKG (INTERNET_ERROR_BASE + 173) +#define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174) +#define ERROR_INTERNET_DECODING_FAILED (INTERNET_ERROR_BASE + 175) +#define INTERNET_ERROR_LAST ERROR_INTERNET_DECODING_FAILED #define NORMAL_CACHE_ENTRY 0x00000001 diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c index 4e56d8ede16..d7354e71521 100644 --- a/programs/notepad/dialog.c +++ b/programs/notepad/dialog.c @@ -45,7 +45,7 @@ VOID ShowLastError(void) LPWSTR lpMsgBuf; WCHAR szTitle[MAX_STRING_LEN]; - LoadStringW(Globals.hInstance, STRING_ERROR, szTitle, SIZEOF(szTitle)); + LoadStringW(Globals.hInstance, STRING_ERROR, szTitle, ARRAY_SIZE(szTitle)); FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, (LPWSTR)&lpMsgBuf, 0, NULL); @@ -68,9 +68,9 @@ static void UpdateWindowCaption(void) if (Globals.szFileTitle[0] != '\0') lstrcpyW(szCaption, Globals.szFileTitle); else - LoadStringW(Globals.hInstance, STRING_UNTITLED, szCaption, SIZEOF(szCaption)); + LoadStringW(Globals.hInstance, STRING_UNTITLED, szCaption, ARRAY_SIZE(szCaption)); - LoadStringW(Globals.hInstance, STRING_NOTEPAD, szNotepad, SIZEOF(szNotepad)); + LoadStringW(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad)); lstrcatW(szCaption, hyphenW); lstrcatW(szCaption, szNotepad); @@ -83,14 +83,14 @@ int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCWSTR szString, DWORD dwFl WCHAR szResource[MAX_STRING_LEN]; /* Load and format szMessage */ - LoadStringW(Globals.hInstance, formatId, szResource, SIZEOF(szResource)); - wnsprintfW(szMessage, SIZEOF(szMessage), szResource, szString); + LoadStringW(Globals.hInstance, formatId, szResource, ARRAY_SIZE(szResource)); + wnsprintfW(szMessage, ARRAY_SIZE(szMessage), szResource, szString); /* Load szCaption */ if ((dwFlags & MB_ICONMASK) == MB_ICONEXCLAMATION) - LoadStringW(Globals.hInstance, STRING_ERROR, szResource, SIZEOF(szResource)); + LoadStringW(Globals.hInstance, STRING_ERROR, szResource, ARRAY_SIZE(szResource)); else - LoadStringW(Globals.hInstance, STRING_NOTEPAD, szResource, SIZEOF(szResource)); + LoadStringW(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource)); /* Display Modal Dialog */ if (hParent == NULL) @@ -107,7 +107,7 @@ static int AlertFileNotSaved(LPCWSTR szFileName) { WCHAR szUntitled[MAX_STRING_LEN]; - LoadStringW(Globals.hInstance, STRING_UNTITLED, szUntitled, SIZEOF(szUntitled)); + LoadStringW(Globals.hInstance, STRING_UNTITLED, szUntitled, ARRAY_SIZE(szUntitled)); return DIALOG_StringMsgBox(NULL, STRING_NOTSAVED, szFileName[0] ? szFileName : szUntitled, MB_ICONQUESTION|MB_YESNOCANCEL); } @@ -257,7 +257,7 @@ void DoOpenFile(LPCWSTR szFileName) SetFocus(Globals.hEdit); /* If the file starts with .LOG, add a time/date at the end and set cursor after */ - if (GetWindowTextW(Globals.hEdit, log, sizeof(log)/sizeof(log[0])) && !lstrcmpW(log, dotlog)) + if (GetWindowTextW(Globals.hEdit, log, ARRAY_SIZE(log)) && !lstrcmpW(log, dotlog)) { static const WCHAR lfW[] = { '\r','\n',0 }; SendMessageW(Globals.hEdit, EM_SETSEL, GetWindowTextLengthW(Globals.hEdit), -1); @@ -292,7 +292,7 @@ VOID DIALOG_FileOpen(VOID) ZeroMemory(&openfilename, sizeof(openfilename)); - GetCurrentDirectoryW(SIZEOF(szDir), szDir); + GetCurrentDirectoryW(ARRAY_SIZE(szDir), szDir); lstrcpyW(szPath, txt_files); openfilename.lStructSize = sizeof(openfilename); @@ -300,7 +300,7 @@ VOID DIALOG_FileOpen(VOID) openfilename.hInstance = Globals.hInstance; openfilename.lpstrFilter = Globals.szFilter; openfilename.lpstrFile = szPath; - openfilename.nMaxFile = SIZEOF(szPath); + openfilename.nMaxFile = ARRAY_SIZE(szPath); openfilename.lpstrInitialDir = szDir; openfilename.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING; @@ -331,7 +331,7 @@ BOOL DIALOG_FileSaveAs(VOID) ZeroMemory(&saveas, sizeof(saveas)); - GetCurrentDirectoryW(SIZEOF(szDir), szDir); + GetCurrentDirectoryW(ARRAY_SIZE(szDir), szDir); lstrcpyW(szPath, txt_files); saveas.lStructSize = sizeof(OPENFILENAMEW); @@ -339,7 +339,7 @@ BOOL DIALOG_FileSaveAs(VOID) saveas.hInstance = Globals.hInstance; saveas.lpstrFilter = Globals.szFilter; saveas.lpstrFile = szPath; - saveas.nMaxFile = SIZEOF(szPath); + saveas.nMaxFile = ARRAY_SIZE(szPath); saveas.lpstrInitialDir = szDir; saveas.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING; @@ -733,7 +733,7 @@ VOID DIALOG_Search(VOID) Globals.find.hwndOwner = Globals.hMainWnd; Globals.find.hInstance = Globals.hInstance; Globals.find.lpstrFindWhat = Globals.szFindText; - Globals.find.wFindWhatLen = SIZEOF(Globals.szFindText); + Globals.find.wFindWhatLen = ARRAY_SIZE(Globals.szFindText); Globals.find.Flags = FR_DOWN|FR_HIDEWHOLEWORD; /* We only need to create the modal FindReplace dialog which will */ @@ -765,9 +765,9 @@ VOID DIALOG_Replace(VOID) Globals.find.hwndOwner = Globals.hMainWnd; Globals.find.hInstance = Globals.hInstance; Globals.find.lpstrFindWhat = Globals.szFindText; - Globals.find.wFindWhatLen = SIZEOF(Globals.szFindText); + Globals.find.wFindWhatLen = ARRAY_SIZE(Globals.szFindText); Globals.find.lpstrReplaceWith = Globals.szReplaceText; - Globals.find.wReplaceWithLen = SIZEOF(Globals.szReplaceText); + Globals.find.wReplaceWithLen = ARRAY_SIZE(Globals.szReplaceText); Globals.find.Flags = FR_DOWN|FR_HIDEWHOLEWORD; /* We only need to create the modal FindReplace dialog which will */ @@ -799,7 +799,7 @@ VOID DIALOG_HelpAboutNotepad(VOID) HICON icon = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_NOTEPAD), IMAGE_ICON, 48, 48, LR_SHARED); - LoadStringW(Globals.hInstance, STRING_NOTEPAD, szNotepad, SIZEOF(szNotepad)); + LoadStringW(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad)); ShellAboutW(Globals.hMainWnd, szNotepad, notepadW, icon); } @@ -830,8 +830,8 @@ static INT_PTR WINAPI DIALOG_PAGESETUP_DlgProc(HWND hDlg, UINT msg, WPARAM wPara { case IDOK: /* save user input and close dialog */ - GetDlgItemTextW(hDlg, IDC_PAGESETUP_HEADERVALUE, Globals.szHeader, SIZEOF(Globals.szHeader)); - GetDlgItemTextW(hDlg, IDC_PAGESETUP_FOOTERVALUE, Globals.szFooter, SIZEOF(Globals.szFooter)); + GetDlgItemTextW(hDlg, IDC_PAGESETUP_HEADERVALUE, Globals.szHeader, ARRAY_SIZE(Globals.szHeader)); + GetDlgItemTextW(hDlg, IDC_PAGESETUP_FOOTERVALUE, Globals.szFooter, ARRAY_SIZE(Globals.szFooter)); Globals.iMarginTop = GetDlgItemInt(hDlg, IDC_PAGESETUP_TOPVALUE, NULL, FALSE) * 100; Globals.iMarginBottom = GetDlgItemInt(hDlg, IDC_PAGESETUP_BOTTOMVALUE, NULL, FALSE) * 100; diff --git a/programs/notepad/main.c b/programs/notepad/main.c index b3c54110c95..c195668f4a3 100644 --- a/programs/notepad/main.c +++ b/programs/notepad/main.c @@ -203,10 +203,10 @@ static VOID NOTEPAD_LoadSettingFromRegistry(void) Globals.lfFont.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE; lstrcpyW(Globals.lfFont.lfFaceName, systemW); - LoadStringW(Globals.hInstance, STRING_PAGESETUP_HEADERVALUE, Globals.szHeader, - sizeof(Globals.szHeader) / sizeof(Globals.szHeader[0])); - LoadStringW(Globals.hInstance, STRING_PAGESETUP_FOOTERVALUE, Globals.szFooter, - sizeof(Globals.szFooter) / sizeof(Globals.szFooter[0])); + LoadStringW(Globals.hInstance, STRING_PAGESETUP_HEADERVALUE, + Globals.szHeader, ARRAY_SIZE(Globals.szHeader)); + LoadStringW(Globals.hInstance, STRING_PAGESETUP_FOOTERVALUE, + Globals.szFooter, ARRAY_SIZE(Globals.szFooter)); if(RegOpenKeyW(HKEY_CURRENT_USER, notepad_reg_key, &hkey) == ERROR_SUCCESS) { @@ -576,7 +576,7 @@ static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, WCHAR szFileName[MAX_PATH]; HANDLE hDrop = (HANDLE) wParam; - DragQueryFileW(hDrop, 0, szFileName, SIZEOF(szFileName)); + DragQueryFileW(hDrop, 0, szFileName, ARRAY_SIZE(szFileName)); DragFinish(hDrop); DoOpenFile(szFileName); break; @@ -598,10 +598,10 @@ static int AlertFileDoesNotExist(LPCWSTR szFileName) WCHAR szMessage[MAX_STRING_LEN]; WCHAR szResource[MAX_STRING_LEN]; - LoadStringW(Globals.hInstance, STRING_DOESNOTEXIST, szResource, SIZEOF(szResource)); + LoadStringW(Globals.hInstance, STRING_DOESNOTEXIST, szResource, ARRAY_SIZE(szResource)); wsprintfW(szMessage, szResource, szFileName); - LoadStringW(Globals.hInstance, STRING_ERROR, szResource, SIZEOF(szResource)); + LoadStringW(Globals.hInstance, STRING_ERROR, szResource, ARRAY_SIZE(szResource)); nResult = MessageBoxW(Globals.hMainWnd, szMessage, szResource, MB_ICONEXCLAMATION | MB_YESNO); diff --git a/programs/notepad/main.h b/programs/notepad/main.h index 69c31af0e5d..f81c437eeb1 100644 --- a/programs/notepad/main.h +++ b/programs/notepad/main.h @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define SIZEOF(a) sizeof(a)/sizeof((a)[0]) +#define ARRAY_SIZE(a) sizeof(a)/sizeof((a)[0]) #include "notepad_res.h" diff --git a/programs/reg/Ko.rc b/programs/reg/Ko.rc index 0871ec33a7d..e9ebbeebfc6 100644 --- a/programs/reg/Ko.rc +++ b/programs/reg/Ko.rc @@ -3,6 +3,7 @@ * Korean language support * * Copyright 2008 Andrew Riedi + * Copyright 2008 YunSong Hwang * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +26,11 @@ STRINGTABLE { STRING_USAGE, "¸í·É¾î Çü½Ä:\n\nREG [ ADD | DELETE | QUERY ]\nREG ¸í·É¾î /?\n" STRING_ADD_USAGE, "REG ADD °ª [/v °ª | /ve] [/t Çü½Ä] [/s ºÐ¸®±âÈ£] [/d µ¥ÀÌŸ] [/f]\n" - STRING_DELETE_USAGE, "REG DELETE °ª [/v °ª | /ve | /va] [/f]\n" - STRING_QUERY_USAGE, "REG QUERY °ª [/v °ª| /ve] [/s]\n" + STRING_DELETE_USAGE, "REG DELETE Å° À̸§ [/v °ª | /ve | /va] [/f]\n" + STRING_QUERY_USAGE, "REG QUERY Å° À̸§ [/v °ª| /ve] [/s]\n" + STRING_SUCCESS, "ÀÛ¾÷ÀÌ ¼º°øÀûÀ¸·Î ³¡³µ½À´Ï´Ù\n" + STRING_INVALID_KEY, "¿¡·¯: ¿Ã¹Ù¸£Áö ¾ÊÀº Å° À̸§\n" + STRING_INVALID_CMDLINE, "¿¡·¯:¿Ã¹Ù¸£Áö ¾ÊÀº ¸í·É¶óÀÎ ¸Å°³º¯¼ö\n" + STRING_NO_REMOTE, "¿¡·¯: ¿ø°Ý ¸Ó½Å¿¡ Å°¸¦ ´õÇÏ´Â °ÍÀº °¡´ÉÇÏÁö ¾Ê½À´Ï´Ù\n" + STRING_CANNOT_FIND, "¿¡·¯: ÀÌ ½Ã½ºÅÛ¿¡¼­ ÁöÁ¤µÈ ·¹Áö½ºÆ®¸® Å°³ª °ªÀ» ãÀ»¼ö ¾ø½À´Ï´Ù\n" } diff --git a/programs/regedit/Ko.rc b/programs/regedit/Ko.rc index 7955aa2a200..17905d71c99 100644 --- a/programs/regedit/Ko.rc +++ b/programs/regedit/Ko.rc @@ -285,6 +285,7 @@ BEGIN ID_EDIT_COPYKEYNAME "¼±ÅÃµÈ Å°ÀÇ À̸§À» Ŭ¸³º¸µå¿¡ º¹»ç" ID_EDIT_FIND "Å°,°ªÀ̳ª µ¥ÀÌŸ¿¡¼­ ÅؽºÆ® ¹®ÀÚ¿­ ã±â" ID_EDIT_FINDNEXT "ÀÌÀü ã±â¿¡¼­ ÁöÁ¤µÈ ¹®ÀÚ¿­·Î ´Ù½Ã ã±â" + ID_EDIT_EXPORT "·¹Áö½ºÆ®¸®ÀÇ ¼±ÅÃµÈ ºÎºÐÀ» ÅؽºÆ® ÆÄÀÏ·Î ³»º¸³»±â" END STRINGTABLE DISCARDABLE @@ -296,7 +297,7 @@ BEGIN IDS_TOO_BIG_VALUE "°ªÀÌ ³Ê¹« Å®´Ï´Ù (%u)" IDS_DELETE_BOX_TITLE "°ª Áö¿ì±â È®ÀÎ" IDS_DELETE_BOX_TEXT "´ç½ÅÀº ÀÌ °ª '%s'À» Á¤¸»·Î Áö¿ì°Ú½À´Ï±î?" - IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" + IDS_DELETE_BOX_TEXT_MULTIPLE "ÀÌ °ªµéÀ» Á¤¸»·Î Áö¿ì°Ú½À´Ï±î?" IDS_NEWKEY "»õ Å° #%d" IDS_NEWVALUE "»õ °ª #%d" IDS_NOTFOUND "'%s'À» ãÀ» ¼ö ¾ø½À´Ï´Ù" diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 0aec488b3e2..85e2897a0f8 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -668,18 +668,22 @@ static void update_wineprefix( int force ) const char *config_dir = wine_get_config_dir(); char *inf_path = get_wine_inf_path(); + int fd; struct stat st; if (!inf_path) { - WINE_WARN( "cannot find path to wine.inf file\n" ); + WINE_MESSAGE( "wine: failed to update %s, wine.inf not found\n", config_dir ); return; } - if (stat( inf_path, &st ) == -1) + if ((fd = open( inf_path, O_RDONLY )) == -1) { - WINE_WARN( "cannot stat wine.inf file: %s\n", strerror(errno) ); + WINE_MESSAGE( "wine: failed to update %s with %s: %s\n", + config_dir, inf_path, strerror(errno) ); goto done; } + fstat( fd, &st ); + close( fd ); if (update_timestamp( config_dir, st.st_mtime ) || force) { diff --git a/programs/winedbg/rsrc.rc b/programs/winedbg/rsrc.rc index fbc07d75ddc..9963bbfbbe7 100644 --- a/programs/winedbg/rsrc.rc +++ b/programs/winedbg/rsrc.rc @@ -26,3 +26,4 @@ #include "rsrc_En.rc" #include "rsrc_Ko.rc" #include "rsrc_Nl.rc" +#include "rsrc_Ru.rc" diff --git a/programs/winedbg/rsrc_Ru.rc b/programs/winedbg/rsrc_Ru.rc new file mode 100644 index 00000000000..7fc05bb9cac --- /dev/null +++ b/programs/winedbg/rsrc_Ru.rc @@ -0,0 +1,53 @@ +/* + * Russian Language Support + * + * Copyright 2009 Vladimir Pankratov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +IDM_DEBUG_POPUP MENU +BEGIN + POPUP "" + BEGIN + MENUITEM "&Îòëàäêà", ID_DEBUG + END +END + +IDD_CRASH_DLG DIALOGEX 100, 100, 273, 175 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Îøèáêà ïðîãðàììû" +FONT 8, "Tahoma" +BEGIN + LTEXT "",IDC_STATIC_BG,0,0,273,52,WS_BORDER,0 + LTEXT " ïðîãðàììå %s îáíàðóæåíà ñåðü¸çíàÿ îøèáêà è îíà äîëæíà áûòü \ + çàêðûòà. Ïðèíîñèì èçâèíåíèÿ çà íåóäîáñòâî.", + IDC_STATIC_TXT1,27,10,224,30 + LTEXT "Îøèáêà ìîãëà áûòü âûçâàíà ïðîáëåìîé â ïðîãðàììå èëè íåäîðàáîòêîé â Wine. \ + Âû ìîæåòå ïîñåòèòü http://appdb.winehq.org è ïîèñêàòü ñîâåòû î çàïóñêå \ + ýòîé ïðîãðàììû.\n\n\ + Åñëè ýòà ïðîáëåìà íå ïðèñóòñòâóåò ïîä Windows è åù¸ íå áûëà çàðåãèñòðèðîâàíà, \ + âû ìîæåòå ñîîáùèòü î íåé íà http://bugs.winehq.org.",IDC_STATIC_TXT2,27,60,224,100 + DEFPUSHBUTTON "Çàêðûòü", IDOK, 205, 151, 60, 16, WS_TABSTOP +END + +STRINGTABLE +BEGIN + IDS_AUTO_CAPTION "Îøèáêà Wine" + IDS_INVALID_PARAMS "Âíóòðåííèå îøèáêè - ïîëó÷åíû íåâåðíûå ïàðàìåòðû" + IDS_UNIDENTIFIED "(íåîïðåäåëåíî)" +END diff --git a/programs/winemenubuilder/Makefile.in b/programs/winemenubuilder/Makefile.in index 050b3b3eabf..092405ea35c 100644 --- a/programs/winemenubuilder/Makefile.in +++ b/programs/winemenubuilder/Makefile.in @@ -5,7 +5,8 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = winemenubuilder.exe APPMODE = -mwindows -IMPORTS = uuid shell32 ole32 user32 advapi32 kernel32 +IMPORTS = uuid shell32 shlwapi ole32 user32 advapi32 kernel32 +EXTRAINCL = @PNGINCL@ C_SRCS = \ winemenubuilder.c diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 58e84c6acba..2e87ca5b65e 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -64,6 +64,7 @@ #endif #include #include +#include #define COBJMACROS @@ -74,6 +75,7 @@ #include #include #include +#include #include "wine/unicode.h" #include "wine/debug.h" @@ -1251,6 +1253,38 @@ static HRESULT get_cmdline( IShellLinkW *sl, LPWSTR szPath, DWORD pathSize, return hr; } +static WCHAR* assoc_query(ASSOCSTR assocStr, LPCWSTR name, LPCWSTR extra) +{ + HRESULT hr; + WCHAR *value = NULL; + DWORD size = 0; + hr = AssocQueryStringW(0, assocStr, name, extra, NULL, &size); + if (SUCCEEDED(hr)) + { + value = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); + if (value) + { + hr = AssocQueryStringW(0, assocStr, name, extra, value, &size); + if (FAILED(hr)) + { + HeapFree(GetProcessHeap(), 0, value); + value = NULL; + } + } + } + return value; +} + +static char* wchars_to_utf8_chars(LPCWSTR string) +{ + char *ret; + INT size = WideCharToMultiByte(CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL); + ret = HeapAlloc(GetProcessHeap(), 0, size); + if (ret) + WideCharToMultiByte(CP_UTF8, 0, string, -1, ret, size, NULL, NULL); + return ret; +} + static BOOL next_line(FILE *file, char **line, int *size) { int pos = 0; @@ -1316,9 +1350,17 @@ static BOOL add_mimes(const char *xdg_data_dir, struct list *mime_types) if (mime_type_entry) { *pos = 0; - mime_type_entry->mimeType = line; - mime_type_entry->glob = pos + 1; - list_add_tail(mime_types, &mime_type_entry->entry); + mime_type_entry->mimeType = heap_printf("%s", line); + mime_type_entry->glob = heap_printf("%s", pos + 1); + if (mime_type_entry->mimeType && mime_type_entry->glob) + list_add_tail(mime_types, &mime_type_entry->entry); + else + { + HeapFree(GetProcessHeap(), 0, mime_type_entry->mimeType); + HeapFree(GetProcessHeap(), 0, mime_type_entry->glob); + HeapFree(GetProcessHeap(), 0, mime_type_entry); + ret = FALSE; + } } else ret = FALSE; @@ -1341,6 +1383,7 @@ static void free_native_mime_types(struct list *native_mime_types) LIST_FOR_EACH_ENTRY_SAFE(mime_type_entry, mime_type_entry2, native_mime_types, struct xdg_mime_type, entry) { list_remove(&mime_type_entry->entry); + HeapFree(GetProcessHeap(), 0, mime_type_entry->glob); HeapFree(GetProcessHeap(), 0, mime_type_entry->mimeType); HeapFree(GetProcessHeap(), 0, mime_type_entry); } @@ -1398,16 +1441,211 @@ static BOOL build_native_mime_types(const char *xdg_data_home, struct list **mim return ret; } +static BOOL match_glob(struct list *native_mime_types, const char *extension, + char **match) +{ + struct xdg_mime_type *mime_type_entry; + int matchLength = 0; + + *match = NULL; + + LIST_FOR_EACH_ENTRY(mime_type_entry, native_mime_types, struct xdg_mime_type, entry) + { + if (fnmatch(mime_type_entry->glob, extension, 0) == 0) + { + if (*match == NULL || matchLength < strlen(mime_type_entry->glob)) + { + *match = mime_type_entry->mimeType; + matchLength = strlen(mime_type_entry->glob); + } + } + } + + if (*match != NULL) + { + *match = heap_printf("%s", *match); + if (*match == NULL) + return FALSE; + } + return TRUE; +} + +static BOOL freedesktop_mime_type_for_extension(struct list *native_mime_types, + const char *extensionA, + LPCWSTR extensionW, + char **mime_type) +{ + WCHAR *lower_extensionW; + INT len; + BOOL ret = match_glob(native_mime_types, extensionA, mime_type); + if (ret == FALSE || *mime_type != NULL) + return ret; + len = strlenW(extensionW); + lower_extensionW = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR)); + if (lower_extensionW) + { + char *lower_extensionA; + memcpy(lower_extensionW, extensionW, (len + 1)*sizeof(WCHAR)); + strlwrW(lower_extensionW); + lower_extensionA = wchars_to_utf8_chars(lower_extensionW); + if (lower_extensionA) + { + ret = match_glob(native_mime_types, lower_extensionA, mime_type); + HeapFree(GetProcessHeap(), 0, lower_extensionA); + } + else + { + ret = FALSE; + WINE_FIXME("out of memory\n"); + } + HeapFree(GetProcessHeap(), 0, lower_extensionW); + } + else + { + ret = FALSE; + WINE_FIXME("out of memory\n"); + } + return ret; +} + +static BOOL write_freedesktop_mime_type_entry(const char *packages_dir, const char *dot_extension, + const char *mime_type, const char *comment) +{ + BOOL ret = FALSE; + char *filename; + + WINE_TRACE("writing MIME type %s, extension=%s, comment=%s\n", wine_dbgstr_a(mime_type), + wine_dbgstr_a(dot_extension), wine_dbgstr_a(comment)); + + filename = heap_printf("%s/x-wine-extension-%s.xml", packages_dir, &dot_extension[1]); + if (filename) + { + FILE *packageFile = fopen(filename, "w"); + if (packageFile) + { + fprintf(packageFile, "\n"); + fprintf(packageFile, "\n"); + fprintf(packageFile, " \n", mime_type); + fprintf(packageFile, " \n", dot_extension); + if (comment) + fprintf(packageFile, " %s\n", comment); + fprintf(packageFile, " \n"); + fprintf(packageFile, "\n"); + ret = TRUE; + fclose(packageFile); + } + else + WINE_ERR("error writing file %s\n", filename); + HeapFree(GetProcessHeap(), 0, filename); + } + else + WINE_ERR("out of memory\n"); + return ret; +} + static BOOL generate_associations(const char *xdg_data_home, const char *packages_dir, const char *applications_dir) { struct list *nativeMimeTypes = NULL; + LSTATUS ret = 0; + int i; + BOOL hasChanged = FALSE; if (!build_native_mime_types(xdg_data_home, &nativeMimeTypes)) { WINE_ERR("could not build native MIME types\n"); return FALSE; } - return TRUE; + + for (i = 0; ; i++) + { + WCHAR *extensionW = NULL; + DWORD size = 1024; + + do + { + HeapFree(GetProcessHeap(), 0, extensionW); + extensionW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); + if (extensionW == NULL) + { + WINE_ERR("out of memory\n"); + ret = ERROR_OUTOFMEMORY; + break; + } + ret = RegEnumKeyExW(HKEY_CLASSES_ROOT, i, extensionW, &size, NULL, NULL, NULL, NULL); + size *= 2; + } while (ret == ERROR_MORE_DATA); + + if (ret == ERROR_SUCCESS && extensionW[0] == '.') + { + char *extensionA = NULL; + WCHAR *commandW = NULL; + WCHAR *friendlyDocNameW = NULL; + char *friendlyDocNameA = NULL; + WCHAR *contentTypeW = NULL; + char *mimeTypeA = NULL; + + extensionA = wchars_to_utf8_chars(extensionW); + if (extensionA == NULL) + { + WINE_ERR("out of memory\n"); + goto end; + } + + commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, NULL); + if (commandW == NULL) + /* no command -> unusable extension */ + goto end; + + friendlyDocNameW = assoc_query(ASSOCSTR_FRIENDLYDOCNAME, extensionW, NULL); + if (friendlyDocNameW) + { + friendlyDocNameA = wchars_to_utf8_chars(friendlyDocNameW); + if (friendlyDocNameA == NULL) + { + WINE_ERR("out of memory\n"); + goto end; + } + } + + contentTypeW = assoc_query(ASSOCSTR_CONTENTTYPE, extensionW, NULL); + + if (!freedesktop_mime_type_for_extension(nativeMimeTypes, extensionA, extensionW, &mimeTypeA)) + goto end; + + if (mimeTypeA == NULL) + { + if (contentTypeW != NULL) + mimeTypeA = wchars_to_utf8_chars(contentTypeW); + else + mimeTypeA = heap_printf("application/x-wine-extension-%s", &extensionA[1]); + + if (mimeTypeA != NULL) + { + write_freedesktop_mime_type_entry(packages_dir, extensionA, mimeTypeA, friendlyDocNameA); + hasChanged = TRUE; + } + else + { + WINE_FIXME("out of memory\n"); + goto end; + } + } + + end: + HeapFree(GetProcessHeap(), 0, extensionA); + HeapFree(GetProcessHeap(), 0, commandW); + HeapFree(GetProcessHeap(), 0, friendlyDocNameW); + HeapFree(GetProcessHeap(), 0, friendlyDocNameA); + HeapFree(GetProcessHeap(), 0, contentTypeW); + HeapFree(GetProcessHeap(), 0, mimeTypeA); + } + HeapFree(GetProcessHeap(), 0, extensionW); + if (ret != ERROR_SUCCESS) + break; + } + + free_native_mime_types(nativeMimeTypes); + return hasChanged; } static BOOL InvokeShellLinker( IShellLinkW *sl, LPCWSTR link, BOOL bWait ) @@ -1841,6 +2079,7 @@ static void RefreshFileTypeAssociations(void) char *mime_dir = NULL; char *packages_dir = NULL; char *applications_dir = NULL; + BOOL hasChanged; hSem = CreateSemaphoreA( NULL, 1, 1, "winemenubuilder_semaphore"); if( WAIT_OBJECT_0 != MsgWaitForMultipleObjects( 1, &hSem, FALSE, INFINITE, QS_ALLINPUT ) ) @@ -1875,7 +2114,21 @@ static void RefreshFileTypeAssociations(void) } create_directories(applications_dir); - generate_associations(xdg_data_dir, packages_dir, applications_dir); + hasChanged = generate_associations(xdg_data_dir, packages_dir, applications_dir); + if (hasChanged) + { + char *command = heap_printf("update-mime-database %s", mime_dir); + if (command) + { + system(command); + HeapFree(GetProcessHeap(), 0, command); + } + else + { + WINE_ERR("out of memory\n"); + goto end; + } + } end: if (hSem) diff --git a/programs/winetest/send.c b/programs/winetest/send.c index 9eae079c4bf..2b4073a7a38 100644 --- a/programs/winetest/send.c +++ b/programs/winetest/send.c @@ -19,11 +19,26 @@ */ #include +#include #include #include #include "winetest.h" +#define USER_AGENT "Winetest Shell" +#define SERVER_NAME "test.winehq.org" +#define URL_PATH "/submit" +#define SEP "--8<--cut-here--8<--" +#define CONTENT_HEADERS "Content-Type: multipart/form-data; boundary=\"" SEP "\"\r\n" \ + "Content-Length: %u\r\n\r\n" +static const char body1[] = "--" SEP "\r\n" + "Content-Disposition: form-data; name=\"reportfile\"; filename=\"%s\"\r\n" + "Content-Type: application/octet-stream\r\n\r\n"; +static const char body2[] = "\r\n--" SEP "\r\n" + "Content-Disposition: form-data; name=\"submit\"\r\n\r\n" + "Upload File\r\n" + "--" SEP "--\r\n"; + static SOCKET open_http (const char *server) { @@ -101,8 +116,8 @@ send_str (SOCKET s, ...) return ret; } -int -send_file (const char *name) +static int +send_file_direct (const char *name) { SOCKET s; HANDLE file; @@ -114,21 +129,13 @@ send_file (const char *name) int ret; /* RFC 2616 */ -#define SEP "--8<--cut-here--8<--" - static const char head[] = "POST /submit HTTP/1.0\r\n" - "Host: test.winehq.org\r\n" - "User-Agent: Winetest Shell\r\n" - "Content-Type: multipart/form-data; boundary=\"" SEP "\"\r\n" - "Content-Length: %u\r\n\r\n"; - static const char body1[] = "--" SEP "\r\n" - "Content-Disposition: form-data; name=\"reportfile\"; filename=\"%s\"\r\n" - "Content-Type: application/octet-stream\r\n\r\n"; - static const char body2[] = "\r\n--" SEP "\r\n" - "Content-Disposition: form-data; name=\"submit\"\r\n\r\n" - "Upload File\r\n" - "--" SEP "--\r\n"; - - s = open_http ("test.winehq.org"); + static const char head[] = "POST " URL_PATH " HTTP/1.0\r\n" + "Host: " SERVER_NAME "\r\n" + "User-Agent: " USER_AGENT "\r\n" + CONTENT_HEADERS + "\r\n"; + + s = open_http (SERVER_NAME); if (s == INVALID_SOCKET) return 1; file = CreateFileA( name, GENERIC_READ, @@ -152,7 +159,7 @@ send_file (const char *name) report (R_WARNING, "File too big (%.1f MB > 1.5 MB); submitting partial report.", filesize/1024.0/1024); - filesize = 1.5*1024*1024; + filesize = (DWORD) 1.5*1024*1024; } report (R_STATUS, "Sending header"); @@ -210,7 +217,7 @@ send_file (const char *name) str = strmake (&count, "Received %s (%d bytes).\n", name, filesize); - ret = memcmp (str, buffer + total - count, count); + ret = total < count || memcmp (str, buffer + total - count, count) != 0; heap_free (str); if (ret) { buffer[total] = 0; @@ -228,3 +235,180 @@ send_file (const char *name) close_http (s); return 1; } + +static int +send_file_wininet (const char *name) +{ + int ret = 0; + HMODULE wininet_mod = NULL; + HINTERNET (WINAPI *pInternetOpen)(LPCSTR agent, DWORD access_type, LPCSTR proxy_name, LPCSTR proxy_bypass, DWORD flags); + HINTERNET (WINAPI *pInternetConnect)(HINTERNET session, LPCSTR server_name, INTERNET_PORT server_port, LPCSTR username, LPCSTR password, DWORD service, DWORD flags, DWORD_PTR *context); + HINTERNET (WINAPI *pHttpOpenRequest)(HINTERNET connection, LPCSTR verb, LPCSTR object_name, LPCSTR version, LPCSTR referer, LPCSTR *accept_types, DWORD flags, DWORD_PTR context); + BOOL (WINAPI *pHttpSendRequestEx)(HINTERNET request, LPINTERNET_BUFFERSA buffers_in, LPINTERNET_BUFFERSA buffers_out, DWORD flags, DWORD_PTR context); + BOOL (WINAPI *pInternetWriteFile)(HINTERNET file, LPCVOID buffer, DWORD number_of_bytes_to_write, LPDWORD number_of_bytes_written); + BOOL (WINAPI *pHttpEndRequest)(HINTERNET request, LPINTERNET_BUFFERSA buffers_out, DWORD flags, DWORD_PTR context); + BOOL (WINAPI *pInternetReadFile)(HINTERNET file, LPCVOID buffer, DWORD number_of_bytes_to_read, LPDWORD number_of_bytes_read); + BOOL (WINAPI *pInternetCloseHandle)(HINTERNET Handle) = NULL; + HANDLE file = INVALID_HANDLE_VALUE; + DWORD filesize, bytes_read, bytes_written; + size_t total, count; + char *str = NULL; + HINTERNET session = NULL; + HINTERNET connection = NULL; + HINTERNET request = NULL; + INTERNET_BUFFERSA buffers_in = { 0 }; + char buffer[BUFLEN+1]; + + static const char extra_headers[] = + CONTENT_HEADERS; + + wininet_mod = LoadLibrary ("wininet.dll"); + if (wininet_mod == NULL) + goto done; + pInternetOpen = (void *)GetProcAddress(wininet_mod, "InternetOpenA"); + pInternetConnect = (void *)GetProcAddress(wininet_mod, "InternetConnectA"); + pHttpOpenRequest = (void *)GetProcAddress(wininet_mod, "HttpOpenRequestA"); + pHttpSendRequestEx = (void *)GetProcAddress(wininet_mod, "HttpSendRequestExA"); + pInternetWriteFile = (void *)GetProcAddress(wininet_mod, "InternetWriteFile"); + pHttpEndRequest = (void *)GetProcAddress(wininet_mod, "HttpEndRequestA"); + pInternetReadFile = (void *)GetProcAddress(wininet_mod, "InternetReadFile"); + pInternetCloseHandle = (void *)GetProcAddress(wininet_mod, "InternetCloseHandle"); + if (pInternetOpen == NULL || pInternetConnect == NULL || pHttpOpenRequest == NULL || pHttpSendRequestEx == NULL || pHttpEndRequest == NULL || + pInternetWriteFile == NULL || pInternetReadFile == NULL || pInternetCloseHandle == NULL) { + goto done; + } + + ret = 1; + + file = CreateFileA( name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, OPEN_EXISTING, 0, NULL ); + + if ((file == INVALID_HANDLE_VALUE) && + (GetLastError() == ERROR_INVALID_PARAMETER)) { + /* FILE_SHARE_DELETE not supported on win9x */ + file = CreateFileA( name, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, NULL ); + } + if (file == INVALID_HANDLE_VALUE) { + report (R_WARNING, "Can't open file '%s': %u", name, GetLastError()); + goto done; + } + + filesize = GetFileSize( file, NULL ); + if (filesize > 1.5*1024*1024) { + report (R_WARNING, + "File too big (%.1f MB > 1.5 MB); submitting partial report.", + filesize/1024.0/1024); + filesize = (DWORD) 1.5*1024*1024; + } + + report (R_STATUS, "Opening HTTP connection to " SERVER_NAME); + session = pInternetOpen (USER_AGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); + if (session == NULL) { + report (R_WARNING, "Unable to open connection, error %u", GetLastError()); + goto done; + } + connection = pInternetConnect (session, SERVER_NAME, INTERNET_DEFAULT_HTTP_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0); + if (connection == NULL) { + report (R_WARNING, "Unable to connect, error %u", GetLastError()); + goto done; + } + request = pHttpOpenRequest (connection, "POST", URL_PATH, NULL, NULL, NULL, + INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | + INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0); + if (request == NULL) { + report (R_WARNING, "Unable to open request, error %u", GetLastError()); + goto done; + } + + report (R_STATUS, "Sending request"); + str = strmake (&total, body1, name); + memset(&buffers_in, 0, sizeof(INTERNET_BUFFERSA)); + buffers_in.dwStructSize = sizeof(INTERNET_BUFFERSA); + buffers_in.dwBufferTotal = filesize + total + sizeof body2 - 1; + buffers_in.lpcszHeader = strmake (&count, extra_headers, buffers_in.dwBufferTotal); + buffers_in.dwHeadersLength = count; + if (! pHttpSendRequestEx(request, &buffers_in, NULL, 0, 0)) { + report (R_WARNING, "Unable to send request, error %u", GetLastError()); + goto done; + } + + if (! pInternetWriteFile(request, str, total, &bytes_written) || bytes_written != total) { + report (R_WARNING, "Unable to write body data, error %u", GetLastError()); + goto done; + } + + report (R_STATUS, "Sending %u bytes of data", filesize); + report (R_PROGRESS, 2, filesize); + total = 0; + while (total < filesize && ReadFile( file, buffer, BUFLEN/2, &bytes_read, NULL )) { + if (!bytes_read) break; + total += bytes_read; + if (total > filesize) bytes_read -= total - filesize; + if (! pInternetWriteFile (request, buffer, bytes_read, &bytes_written) || bytes_written != bytes_read) { + report (R_WARNING, "Error sending body: %u", GetLastError ()); + goto done; + } + report (R_DELTA, bytes_read, "Network transfer: In progress"); + } + + if (! pInternetWriteFile(request, body2, sizeof body2 - 1, &bytes_written) || bytes_written != sizeof body2 - 1) { + report (R_WARNING, "Unable to write final body data, error %u", GetLastError()); + goto done; + } + if (! pHttpEndRequest(request, NULL, 0, 0)) { + report (R_WARNING, "Unable to end request, error %u", GetLastError()); + goto done; + } + report (R_DELTA, 0, "Network transfer: Done"); + + total = 0; + do + { + if (! pInternetReadFile(request, buffer+total, BUFLEN-total, &bytes_read)) { + report (R_WARNING, "Error receiving reply: %u", GetLastError ()); + goto done; + } + total += bytes_read; + if (total == BUFLEN) { + report (R_WARNING, "Buffer overflow"); + goto done; + } + } + while (bytes_read != 0); + + heap_free (str); + str = strmake (&count, "Received %s (%d bytes).\n", + name, filesize); + if (total < count || memcmp (str, buffer + total - count, count) != 0) { + buffer[total] = 0; + report (R_ERROR, "Can't submit logfile '%s'. " + "Server response: %s", name, buffer); + } + + done: + if (buffers_in.lpcszHeader != NULL) + heap_free((void *) buffers_in.lpcszHeader); + if (str != NULL) + heap_free (str); + if (pInternetCloseHandle != NULL && request != NULL) + pInternetCloseHandle (request); + if (pInternetCloseHandle != NULL && connection != NULL) + pInternetCloseHandle (connection); + if (pInternetCloseHandle != NULL && session != NULL) + pInternetCloseHandle (session); + if (file != INVALID_HANDLE_VALUE) + CloseHandle (file); + if (wininet_mod != NULL) + FreeLibrary (wininet_mod); + + return ret; +} + +int +send_file (const char *name) +{ + return send_file_wininet( name ) || send_file_direct( name ); +} diff --git a/tools/config.guess b/tools/config.guess index 951383e3554..da833146088 100755 --- a/tools/config.guess +++ b/tools/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, -# Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. -timestamp='2007-05-17' +timestamp='2009-04-27' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -56,8 +56,8 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -324,14 +324,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; - i86pc:SunOS:5.*:* | ix86xen:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize @@ -532,7 +548,7 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[45]) + *:AIX:*:[456]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -793,12 +809,15 @@ EOF exit ;; *:Interix*:[3456]*) case ${UNAME_MACHINE} in - x86) + x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T | authenticamd) + EM64T | authenticamd | genuineintel) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks @@ -833,7 +852,14 @@ EOF echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -925,6 +951,9 @@ EOF if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in @@ -954,8 +983,8 @@ EOF x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; - xtensa:Linux:*:*) - echo xtensa-unknown-linux-gnu + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so @@ -975,9 +1004,6 @@ EOF a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. @@ -1092,8 +1118,11 @@ EOF pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 @@ -1131,6 +1160,16 @@ EOF 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; @@ -1206,6 +1245,9 @@ EOF BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1314,6 +1356,9 @@ EOF i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1474,9 +1519,9 @@ This script, last modified $timestamp, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from - http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD and - http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD If the version you run ($0) is already up to date, please send the following data and any information you think might be diff --git a/tools/config.sub b/tools/config.sub index c060f448339..a39437d0158 100755 --- a/tools/config.sub +++ b/tools/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, -# Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. -timestamp='2007-04-29' +timestamp='2009-04-17' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -72,8 +72,8 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 -Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -122,6 +122,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -249,13 +250,16 @@ case $basic_machine in | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep \ + | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ - | mips64vr | mips64vrel \ + | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ @@ -268,6 +272,7 @@ case $basic_machine in | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | moxie \ | mt \ | msp430 \ | nios | nios2 \ @@ -277,7 +282,7 @@ case $basic_machine in | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | score \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -286,7 +291,7 @@ case $basic_machine in | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) + | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) @@ -329,14 +334,17 @@ case $basic_machine in | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ + | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ @@ -358,20 +366,24 @@ case $basic_machine in | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ + | xstormy16-* | xtensa*-* \ | ymp-* \ - | z8k-*) + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -435,6 +447,10 @@ case $basic_machine in basic_machine=m68k-apollo os=-bsd ;; + aros) + basic_machine=i386-pc + os=-aros + ;; aux) basic_machine=m68k-apple os=-aux @@ -443,10 +459,22 @@ case $basic_machine in basic_machine=ns32k-sequent os=-dynix ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; c90) basic_machine=c90-cray os=-unicos ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -475,8 +503,8 @@ case $basic_machine in basic_machine=craynv-cray os=-unicosmp ;; - cr16c) - basic_machine=cr16c-unknown + cr16) + basic_machine=cr16-unknown os=-elf ;; crds | unos) @@ -514,6 +542,10 @@ case $basic_machine in basic_machine=m88k-motorola os=-sysv3 ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp @@ -668,6 +700,14 @@ case $basic_machine in basic_machine=m68k-isi os=-sysv ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; m88k-omron*) basic_machine=m88k-omron ;; @@ -813,6 +853,14 @@ case $basic_machine in basic_machine=i860-intel os=-osf ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; pbd) basic_machine=sparc-tti ;; @@ -1021,6 +1069,10 @@ case $basic_machine in basic_machine=tic6x-unknown os=-coff ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu + ;; tx39) basic_machine=mipstx39-unknown ;; @@ -1096,6 +1148,10 @@ case $basic_machine in basic_machine=z8k-unknown os=-sim ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; none) basic_machine=none-none os=-none @@ -1134,7 +1190,7 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) @@ -1206,8 +1262,9 @@ case $os in -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ @@ -1216,7 +1273,7 @@ case $os in | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ + | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ @@ -1356,6 +1413,9 @@ case $os in -zvmoe) os=-zvmoe ;; + -dicos*) + os=-dicos + ;; -none) ;; *) diff --git a/tools/make_requests b/tools/make_requests index b53af11787f..e7a1ffbb586 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -1,7 +1,7 @@ #! /usr/bin/perl -w # # Build the server/trace.c and server/request.h files -# from the contents of include/wine/server.h. +# from the contents of server/protocol.def. # # Copyright (C) 1998 Alexandre Julliard # diff --git a/tools/winapi/winapi_cleanup b/tools/winapi/winapi_cleanup deleted file mode 100755 index 29f94a66bbb..00000000000 --- a/tools/winapi/winapi_cleanup +++ /dev/null @@ -1,231 +0,0 @@ -#! /usr/bin/perl -w - -# Copyright 2002 Patrik Stridvall -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -use strict; - -BEGIN { - $0 =~ m%^(.*?/?tools)/winapi/winapi_cleanup$%; - require "$1/winapi/setup.pm"; -} - -use config qw($current_dir $wine_dir file_absolutize file_directory); -use output qw($output); -use winapi_cleanup_options qw($options); - -use nativeapi qw($nativeapi); -use util qw(edit_file); - -if($options->progress) { - $output->enable_progress; -} else { - $output->disable_progress; -} - -######################################################################## -# cleanup_file - -sub cleanup_file($$$) { - local *IN = shift; - local *OUT = shift; - - my $file = shift; - my $dir = do { - my $file2 = file_absolutize($file); - my $dir = file_directory($file2); - "$wine_dir/$dir"; - }; - - my $indent; - my @comments = (); - my $format_comments = sub { - local $_ = ""; - if ($#comments == 0) { - my $comment = $comments[0]; - - $_ = "$indent/*$comment */"; - } elsif ($#comments > 0) { - $_ = "$indent/*\n"; - foreach my $comment (@comments) { - $_ .= "$indent *$comment\n"; - } - $_ .= "$indent */"; - } - $indent = ""; - @comments = (); - - return $_; - }; - - my $in_comment = 0; - my $modified = 0; - while () { - chomp; - - if ($options->trailing_whitespace) { - s/(.*?)\s+$/$1/ && do { $modified = 1; }; - } else { - s/(.*?)\r$/$1/ && do { $modified = 1; }; - } - - if ($options->cpp_comments) { - if ($in_comment) { - if(/^.*?\*\//) { - $in_comment = 0; - } - } elsif (/^([^\"\/]*?(?:\"[^\"]*?\"[^\"]*?)*?)\/\*(.*?)$/) { - my $indent2 = $1; - my $comment = $2; - if($comment !~ /^.*?\*\//) { - $in_comment = 1; - } - } elsif (/^([^\"\/]*?(?:\"[^\"]*?\"[^\"]*?)*?)\/\/(.*?)\s*$/) { - my $indent2 = $1; - my $comment = $2; - - if ($indent2 =~ /^\s*$/) { - if (!$indent || $indent eq $indent2) { - $indent = $indent2; - push @comments, $comment; - next; - } else { - $_ .= "$indent2/*$comment */"; - } - } else { - my $comments = &$format_comments(); - if ($comments) { - $_ = "$comments\n$indent2/*$comment */"; - } else { - $_ = "$indent2/*$comment */"; - } - - $modified = 1; - } - } else { - my $comments = &$format_comments(); - if ($comments) { - $_ = "$comments\n$_"; - $modified = 1; - } - } - } - - if ($options->include_quotes) { - my $module = ""; - if ($dir =~ m%^$wine_dir/dlls/(.*?)/.*?$%) { - $module = $1; - } - - if (/^(\s*\#\s*include\s+)(?:<(.*?)>|\"(.*?)\")(.*?)\s*$/) { - my $prefix = $1; - my $header = $2 || $3; - my $local = !defined($2) && defined($3); - my $suffix = $4; - - my $exists_system = 0; { - my @system_paths = qw(/usr/include /usr/local/include /usr/X11R6/include); - foreach my $path (@system_paths) { - $exists_system ||= (-e "$path/$header" || 0); - } - $exists_system ||= $nativeapi->is_conditional_header($header); - } - - my $exists_windows = 0; { - if ($header !~ m%^wine/% && $header ne "config.h") { - $exists_windows ||= (-e "$wine_dir/include/$header" || 0); - } - } - - my $exists_wine = 0; { - $exists_wine ||= ($header eq "config.h"); - - if ($header =~ m%^wine/%) { - $exists_wine ||= (-e "$wine_dir/include/$header" || 0); - } - } - - my $exists_local = 0; { - $exists_local ||= ($header eq "y.tab.h"); - - my @local_paths = (); - push @local_paths, "$dir" if $dir !~ m%^$wine_dir/include%; - push @local_paths, "$wine_dir/dlls/$module" if $module; - foreach my $path (@local_paths) { - $exists_local ||= (-e "$path/$header" || 0); - } - } - - if (!$exists_system && !$exists_windows && !$exists_wine && !$exists_local) { - $output->write("warning: header '$header': doesn't exist\n"); - } elsif (($exists_system + $exists_windows + $exists_wine + $exists_local) > 1) { - if ($header !~ /^(?:async\.h|comcat\.h|sql(?:ext|types)?\.h|thread\.h|user\.h)$/) { - $output->write("warning: header '$header': more than one possibillity\n"); - } - } - - if (!$local && $exists_local) { - $_ = "$prefix\"$header\"$suffix"; - $modified = 1; - } elsif ($local && !$exists_local && ($exists_system || $exists_windows || $exists_wine)) { - $_ = "$prefix<$header>$suffix"; - $modified = 1; - } - } - } - - print OUT "$_\n"; - } - - my $comments = &$format_comments(); - if ($comments) { - print OUT "$comments\n"; - $modified = 1; - } - - return $modified; -} - -######################################################################## -# main - -my @h_files = $options->h_files; -my @c_files = $options->c_files; - -my $progress_output; -my $progress_current = 0; -my $progress_max = scalar(@h_files) + scalar(@c_files); - -foreach my $file (@h_files) { - $progress_current++; - $output->progress("$file (file $progress_current of $progress_max)"); - $output->prefix("$file: "); - - if (edit_file($file, \&cleanup_file, @_, $file)) { - $output->write("$file: modified\n"); - } -} - -foreach my $file (@c_files) { - $progress_current++; - $output->progress("$file (file $progress_current of $progress_max)"); - $output->prefix("$file: "); - - if (edit_file($file, \&cleanup_file, $file)) { - $output->write("$file: modified\n"); - } -} diff --git a/tools/winapi/winapi_cleanup_options.pm b/tools/winapi/winapi_cleanup_options.pm deleted file mode 100644 index f6019daee6e..00000000000 --- a/tools/winapi/winapi_cleanup_options.pm +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright 2002 Patrik Stridvall -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -package winapi_cleanup_options; -use base qw(options); - -use strict; - -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); -require Exporter; - -@ISA = qw(Exporter); -@EXPORT = qw(); -@EXPORT_OK = qw($options); - -use options qw($options); - -my %options_long = ( - "debug" => { default => 0, description => "debug mode" }, - "help" => { default => 0, description => "help mode" }, - "verbose" => { default => 0, description => "verbose mode" }, - - "progress" => { default => 1, description => "show progress" }, - - "cpp-comments" => { default => 1, description => "convert C++ comments to C comments" }, - "include-quotes" => { default => 0, description => "convert #include \"\" to <> or the reverse where appropriate" }, - "trailing-whitespace" => { default => 0, description => "remove trailing whitespace" }, -); - -my %options_short = ( - "d" => "debug", - "?" => "help", - "v" => "verbose" -); - -my $options_usage = "usage: winapi_cleanup [--help] []\n"; - -$options = '_options'->new(\%options_long, \%options_short, $options_usage); - -1; diff --git a/tools/winapi/winapi_fixup b/tools/winapi/winapi_fixup deleted file mode 100755 index 334aa52a5d9..00000000000 --- a/tools/winapi/winapi_fixup +++ /dev/null @@ -1,232 +0,0 @@ -#!/usr/bin/perl -w - -# Copyright 2001 Patrik Stridvall -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -use strict; - -BEGIN { - $0 =~ m%^(.*?/?tools)/winapi/winapi_fixup$%; - require "$1/winapi/setup.pm"; -} - -use config qw( - files_filter files_skip - $current_dir $wine_dir $winapi_dir -); -use output qw($output); -use winapi_fixup_options qw($options); - -if($options->progress) { - $output->enable_progress; -} else { - $output->disable_progress; -} - -use winapi_c_parser; -use c_parser; -use type; - -use winapi_fixup_documentation qw(fixup_documentation); -use winapi_fixup_editor; -use winapi_fixup_statements qw(fixup_statements); - -my @c_files = $options->c_files; -@c_files = files_skip(@c_files); -@c_files = files_filter("winelib", @c_files); - -my $progress_output; -my $progress_current = 0; -my $progress_max = scalar(@c_files); - -foreach my $file (@c_files) { - my $editor = new winapi_fixup_editor($file); - - $progress_current++; - $output->progress("$file (file $progress_current of $progress_max)"); - $output->prefix("$file:"); - - { - open(IN, "< $file") || die "Error: Can't open $file: $!\n"; - local $/ = undef; - $_ = ; - close(IN); - } - - my $max_line = 0; - { - local $_ = $_; - while(s/^.*?\n//) { $max_line++; } - if($_) { $max_line++; } - } - - my $parser; - if (1) { - $parser = new c_parser($file); - } else { - $parser = new winapi_c_parser($file); - } - - my $function; - my $line; - - my $update_output = sub { - my $progress = ""; - my $prefix = ""; - - $progress .= "$file (file $progress_current of $progress_max)"; - $prefix .= "$file:"; - - if(defined($function)) { - my $name = $function->name; - my $begin_line = $function->begin_line; - my $begin_column = $function->begin_column; - - $progress .= ": function $name"; - $prefix .= "$begin_line.$begin_column: function $name: "; - } - - if(defined($line)) { - $progress .= ": line $line of $max_line"; - } - - $output->progress($progress); - $output->prefix($prefix); - }; - - my $found_preprocessor = sub { - my $begin_line = shift; - my $begin_column = shift; - my $preprocessor = shift; - - # $output->write("$begin_line.$begin_column: preprocessor: $preprocessor\n"); - - return 1; - }; - - $parser->set_found_preprocessor_callback($found_preprocessor); - - my $found_comment = sub { - my $begin_line = shift; - my $begin_column = shift; - my $comment = shift; - - # $output->write("$begin_line.$begin_column: comment: $comment\n"); - - return 1; - }; - - $parser->set_found_comment_callback($found_comment); - - my $found_line = sub { - $line = shift; - # local $_ = shift; - - &$update_output; - - # $output->progress("$file: line $line of ?"); - }; - - $parser->set_found_line_callback($found_line); - - my $found_declaration = sub { - my $begin_line = shift; - my $begin_column = shift; - my $end_line = shift; - my $end_column = shift; - my $declaration = shift; - - # $output->write("$begin_line.$begin_column-$end_line.$end_column: declaration: \\\n$declaration\n"); - - return 1; - }; - - $parser->set_found_declaration_callback($found_declaration); - - my $found_function = sub { - $function = shift; - - &$update_output; - - my $name = $function->name; - my $begin_line = $function->begin_line; - my $begin_column = $function->begin_column; - my $end_line = $function->end_line; - my $end_column = $function->end_column; - - if($options->documentation) { - # fixup_documentation($function, $editor); - } - - if($options->statements) { - fixup_statements($function, $editor); - } - - my $statements = $function->statements; - if(!defined($statements)) { - $function = undef; - $output->prefix("$file: "); - } else { - # $output->write("$begin_line.$begin_column-$end_line.$end_column: function $name\n"); - } - - return 0; - }; - - $parser->set_found_function_callback($found_function); - - my $found_variable = sub { - my $begin_line = shift; - my $begin_column = shift; - my $linkage = shift; - my $type = shift; - my $name = shift; - - # $output->write("$begin_line.$begin_column: $linkage $type $name = /* ... */\n"); - - return 1; - }; - - $parser->set_found_variable_callback($found_variable); - - my $found_function_call = sub { - my $begin_line = shift; - my $begin_column = shift; - my $end_line = shift; - my $end_column = shift; - my $name = shift; - my $arguments = shift; - - $output->write("$begin_line.$begin_column-$end_line.$end_column: $name(" . join(", ", @$arguments) . ")\n"); - - return 1; - }; - - $parser->set_found_function_call_callback($found_function_call); - - { - my $line = 1; - my $column = 0; - if(!$parser->parse_c_file(\$_, \$line, \$column)) { - $output->write("can't parse file\n"); - } - } - - $output->prefix(""); - - $editor->flush; -} diff --git a/tools/winapi/winapi_fixup_documentation.pm b/tools/winapi/winapi_fixup_documentation.pm deleted file mode 100644 index 21ef75f2b9d..00000000000 --- a/tools/winapi/winapi_fixup_documentation.pm +++ /dev/null @@ -1,402 +0,0 @@ -# -# Copyright 1999, 2000, 2001 Patrik Stridvall -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -package winapi_fixup_documentation; - -use strict; - -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); -require Exporter; - -@ISA = qw(Exporter); -@EXPORT = qw(); -@EXPORT_OK = qw(fixup_documentation); - -use config qw($current_dir $wine_dir); -use modules qw($modules); -use options qw($options); -use output qw($output); -use winapi qw($win16api $win32api @winapis); - -my %documentation_line_used; - -sub fixup_documentation($$) { - my $function = shift; - my $editor = shift; - - my $file = $function->file; - my $documentation_line = $function->documentation_line; - my $documentation = $function->documentation; - my $function_line = $function->function_line; - my $linkage = $function->linkage; - my $return_type = $function->return_type; - my $calling_convention = $function->calling_convention; - my $internal_name = $function->internal_name; - my $statements = $function->statements; - - if($linkage eq "static" || - ($linkage eq "extern" && !defined($statements)) || - ($linkage eq "" && !defined($statements))) - { - return; - } - - my @external_names = $function->external_names; - if($#external_names < 0) { - return; - } - - if($documentation_line_used{$file}{documentation_line}) { - $documentation = undef; - } - $documentation_line_used{$file}{$documentation_line}++; - - my @module_ordinal_entries = (); - foreach my $entry2 ($function->get_all_module_ordinal) { - (my $external_name2, my $module2, my $ordinal2) = @$entry2; - if(($external_name2 eq "@" || - ($win16api->is_module($module2) && !$win16api->is_function_stub_in_module($module2, $external_name2)) || - ($win32api->is_module($module2) && !$win32api->is_function_stub_in_module($module2, $external_name2))) && - $modules->is_allowed_module_in_file($module2, "$current_dir/$file")) - { - push @module_ordinal_entries, $entry2; - } - } - - my $spec_modified = 0; - - if($options->stub && defined($documentation)) { - my $calling_convention16 = $function->calling_convention16; - my $calling_convention32 = $function->calling_convention32; - - foreach my $winapi (@winapis) { - my @entries = (); - my $module = $winapi->function_internal_module($internal_name); - my $ordinal = $winapi->function_internal_ordinal($internal_name); - - if($winapi->is_function_stub_in_module($module, $internal_name)) { - my $external_name = $internal_name; - if($winapi->name eq "win16") { - $external_name =~ s/(?:_)?16([AW]?)$//; - if(defined($1)) { - $external_name .= $1; - } - } - push @entries, [$external_name, $module, $ordinal]; - } - - foreach (split(/\n/, $documentation)) { - if(/^\s*\*\s*(\S+)\s*[\(\[]\s*(\w+)\s*\.\s*([^\s\)\]]*)\s*[\)\]].*?$/) { - my $external_name = $1; - my $module = lc($2); - my $ordinal = $3; - - if($external_name ne "@" && - $winapi->is_module($module) && - $winapi->is_function_stub_in_module($module, $external_name) && - $internal_name !~ /^\U$module\E_\Q$external_name\E$/) - { - push @entries, [$external_name, $module, $ordinal]; - } - } - } - - foreach my $entry (@entries) { - (my $external_name, my $module, my $ordinal) = @$entry; - - my $refargument_types = $function->argument_types; - - if(!defined($refargument_types)) { - next; - } - - my $abort = 0; - my $n; - my @argument_kinds = map { - my $type = $_; - my $kind; - if($type ne "..." && !defined($kind = $winapi->translate_argument($type))) { - $output->write("no win*.api translation defined: " . $type . "\n"); - } - - # FIXME: Kludge - if(defined($kind) && $kind eq "longlong") { - $n += 2; - ("long", "long"); - } elsif(defined($kind)) { - $n++; - $kind; - } elsif($type eq "...") { - if($winapi->name eq "win16") { - $calling_convention16 = "pascal"; # FIXME: Is this correct? - } else { - $calling_convention32 = "varargs"; - } - (); - } else { - $abort = 1; - $n++; - "undef"; - } - } @$refargument_types; - - my $search = "^\\s*$ordinal\\s+stub\\s+$external_name\\s*(?:#.*?)?\$"; - my $replace; - if($winapi->name eq "win16") { - $replace = "$ordinal $calling_convention16 $external_name(@argument_kinds) $internal_name"; - } else { - $replace = "$ordinal $calling_convention32 $external_name(@argument_kinds) $internal_name"; - } - - if(!$abort) { - $spec_modified = 1; - $editor->replace_spec_file($module, $search, $replace); - } - } - } - } - - my %found_external_names; - foreach my $external_name (@external_names) { - $found_external_names{$external_name} = {}; - } - - my $documentation_modified = 0; - - if(!$spec_modified && - (defined($documentation) && !$documentation_modified) && - ($options->documentation_name || $options->documentation_ordinal || - $options->documentation_missing)) - { - local $_; - - my $line3; - my $search; - my $replace; - - my $count = 0; - my $line2 = $documentation_line - 1; - foreach (split(/\n/, $documentation)) { - $line2++; - if(/^(\s*\*\s*(\S+)\s*)((?:\s*[\(\[]\s*\w+(?:\s*\.\s*[^\s\)\]]*\s*)?[\)\]])+)(.*?)$/) { - my $part1 = $1; - my $external_name = $2; - my $part3 = $3; - my $part4 = $4; - - $part4 =~ s/\s*$//; - - my @entries = (); - while($part3 =~ s/^\s*([\(\[]\s*(\w+)(?:\s*\.\s*([^\s\)\]]*)\s*)?[\)\]])//) { - push @entries, [$1, $2, $3]; - } - - my $found = 0; - foreach my $external_name2 (@external_names) { - if($external_name eq $external_name2) { - foreach my $entry (@entries) { - (undef, my $module, undef) = @$entry; - $found_external_names{$external_name2}{$module} = 1; - } - $found = 1; - last; - } - } - - my $replaced = 0; - my $replace2 = ""; - foreach my $entry (@entries) { - my $part12 = $part1; - (my $part32, my $module, my $ordinal) = @$entry; - - foreach my $entry2 (@module_ordinal_entries) { - (my $external_name2, my $module2, my $ordinal2) = @$entry2; - - if($options->documentation_name && lc($module) eq $module2 && - $external_name ne $external_name2) - { - if(!$found && $part12 =~ s/\b\Q$external_name\E\b/$external_name2/) { - $external_name = $external_name2; - $replaced++; - } - } - - if($options->documentation_ordinal && - $external_name eq $external_name2 && - lc($module) eq $module2 && - ($#entries > 0 || !defined($ordinal) || ($ordinal ne $ordinal2))) - { - if(defined($ordinal)) { - if($part32 =~ s/\Q$module\E\s*.\s*\Q$ordinal\E/\U$module2\E.$ordinal2/ || $#entries > 0) { - $replaced++; - } - } else { - if($part32 =~ s/\Q$module\E/\U$module2\E.$ordinal2/ || $#entries > 0) { - $replaced++; - } - } - } - } - if($replace2) { $replace2 .= "\n"; } - $replace2 .= "$part12$part32$part4"; - } - - if($replaced > 0) { - $line3 = $line2; - $search = "^\Q$_\E\$"; - $replace = $replace2; - } - $count++; - } elsif(/^(\s*\*\s*)([^\s\(]+)(?:\(\))?\s*$/) { - my $part1 = $1; - my $external_name = $2; - - if($internal_name =~ /^(?:\S+_)?\Q$external_name\E(?:16)?$/) { - foreach my $entry (@module_ordinal_entries) { - (my $external_name2, my $module, my $ordinal) = @$entry; - - $line3 = $line2; - $search = "^\Q$_\E\$"; - $replace = "$part1$external_name2 (\U$module\E.$ordinal)"; - } - $count++; - } - } - } - - if(defined($line3) && defined($search) && defined($replace)) { - if($count > 1 || $#external_names >= 1) { - $output->write("multiple entries (fixup not supported)\n"); - # $output->write("s/$search/$replace/\n"); - # $output->write("@external_names\n"); - } else { - $documentation_modified = 1; - $editor->substitute_line($line3, $search, $replace); - } - } - } - - if(!$spec_modified && !$documentation_modified && - $options->documentation_missing && defined($documentation)) - { - my $part1; - my $part2; - my $part3; - my $part4; - my $line3 = 0; - - my $line2 = $documentation_line - 1; - foreach (split(/\n/, $documentation)) { - $line2++; - if(/^(\s*\*\s*)(\S+\s*)([\(\[])\s*\w+\s*\.\s*[^\s\)\]]*\s*([\)\]]).*?$/) { - $part1 = $1; - $part2 = $2; - $part3 = $3; - $part4 = $4; - - $part2 =~ s/\S/ /g; - - $line3 = $line2 + 1; - } - } - - foreach my $entry2 (@module_ordinal_entries) { - (my $external_name2, my $module2, my $ordinal2) = @$entry2; - - my $found = 0; - foreach my $external_name (keys(%found_external_names)) { - foreach my $module3 (keys(%{$found_external_names{$external_name}})) { - if($external_name eq $external_name2 && uc($module2) eq $module3) { - $found = 1; - } - } - } - # FIXME: Not 100% correct - if(!$found && - !$win16api->is_function_stub_in_module($module2, $internal_name) && - !$win32api->is_function_stub_in_module($module2, $internal_name)) - { - if($line3 > 0) { - $documentation_modified = 1; - $part2 = $external_name2 . " " x (length($part2) - length($external_name2)); - $editor->insert_line($line3, "$part1$part2$part3\U$module2\E.$ordinal2$part4\n"); - } else { - $output->write("$external_name2 (\U$module2\E.$ordinal2) missing (fixup not supported)\n"); - } - } - } - } - - if(!$documentation_modified && - defined($documentation) && - $options->documentation_wrong) - { - my $line2 = $documentation_line - 1; - foreach (split(/\n/, $documentation)) { - $line2++; - if(/^\s*\*\s*(\S+)\s*[\(\[]\s*(\w+)\s*\.\s*([^\s\)\]]*)\s*[\)\]].*?$/) { - my $external_name = $1; - my $module = $2; - my $ordinal = $3; - - my $found = 0; - foreach my $entry2 (@module_ordinal_entries) { - (my $external_name2, my $module2, my $ordinal2) = @$entry2; - - if($external_name eq $external_name2 && - lc($module) eq $module2 && - $ordinal eq $ordinal2) - { - $found = 1; - } - } - if(!$found) { - if(1) { - $documentation_modified = 1; - - $editor->delete_line($line2, "^\Q$_\E\$"); - } else { - $output->write("$external_name (\U$module\E.$ordinal) wrong (fixup not supported)\n"); - }; - } - } - } - } - - if(!$spec_modified && !$documentation_modified && !defined($documentation)) - { - my $insert = ""; - foreach my $winapi (@winapis) { - my $external_name = $winapi->function_external_name($internal_name); - my $module = $winapi->function_internal_module($internal_name); - my $ordinal = $winapi->function_internal_ordinal($internal_name); - - if(defined($external_name) && defined($module) && defined($ordinal)) { - $insert .= " *\t\t$external_name (\U$module\E.$ordinal)\n"; - } - } - if($insert) { - $editor->insert_line($function_line, - "/" . "*" x 71 . "\n" . - "$insert" . - " */\n"); - } - } -} - -1; diff --git a/tools/winapi/winapi_fixup_editor.pm b/tools/winapi/winapi_fixup_editor.pm deleted file mode 100644 index 1548e3c626e..00000000000 --- a/tools/winapi/winapi_fixup_editor.pm +++ /dev/null @@ -1,407 +0,0 @@ -# -# Copyright 1999, 2000, 2001 Patrik Stridvall -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -package winapi_fixup_editor; - -use strict; - -use options qw($options); -use output qw($output); -use winapi qw($win16api $win32api @winapis); - -use util; - -sub new($$) { - my $proto = shift; - my $class = ref($proto) || $proto; - my $self = {}; - bless ($self, $class); - - my $file = \${$self->{FILE}}; - - $$file = shift; - - return $self; -} - -sub add_trigger($$$) { - my $self = shift; - - my $triggers = \%{$self->{TRIGGERS}}; - - my $line = shift; - my $action = shift; - - if(!defined($$triggers{$line})) { - $$triggers{$line} = []; - } - - push @{$$triggers{$line}}, $action; -} - -sub replace($$$$$$) { - my $self = shift; - - my $begin_line = shift; - my $begin_column = shift; - my $end_line = shift; - my $end_column = shift; - my $replace = shift; - - my $file = \${$self->{FILE}}; - - my $line = $begin_line; - my $action = {}; - - $self->add_trigger($begin_line, { - type => "replace", - begin_line => $begin_line, - begin_column => $begin_column, - end_line => $end_line, - end_column => $end_column, - replace => $replace - }); -} - -sub flush($) { - my $self = shift; - - my $file = \${$self->{FILE}}; - my $triggers = \%{$self->{TRIGGERS}}; - - my $editor = sub { - local *IN = shift; - local *OUT = shift; - - my $modified = 0; - - my $again = 0; - my $lookahead = 0; - my $lookahead_count = 0; - LINE: while($again || defined(my $current = )) { - if(!$again) { - chomp $current; - - if($lookahead) { - $lookahead = 0; - $_ .= "\n" . $current; - $lookahead_count++; - } else { - $_ = $current; - $lookahead_count = 0; - } - } else { - $lookahead_count = 0; - $again = 0; - } - - my $line = $. - $lookahead_count; - foreach my $action (@{$$triggers{$line}}) { - if($. < $action->{end_line}) { - $lookahead = 1; - next LINE; - } - - my $type = $action->{type}; - my $begin_line = $action->{begin_line}; - my $begin_column = $action->{begin_column}; - my $end_line = $action->{end_line}; - my $end_column = $action->{end_column}; - - if($type eq "replace") { - my $replace = $action->{replace}; - - my @lines = split(/\n/, $_); - if($#lines < 0) { - @lines = ($_); - } - - my $begin = ""; - my $column = 0; - $_ = $lines[0]; - while($column < $begin_column - 1 && s/^.//) { - $begin .= $&; - if($& eq "\t") { - $column = $column + 8 - $column % 8; - } else { - $column++; - } - } - - my $column2 = 0; - $_ = $lines[$#lines]; - while($column2 < $end_column && s/^.//) { - if($& eq "\t") { - $column2 = $column2 + 8 - $column2 % 8; - } else { - $column2++; - } - } - my $end = $_; - - $_ = "$begin$replace$end"; - if($options->modify) { - $modified = 1; - } else { - $output->write("$$file:$begin_line.$begin_column-$end_line.$end_column: $replace\n"); - } - } - } - - print OUT "$_\n"; - } - - return $modified; - }; - - my $modified = 0; - if(1) { - $modified = edit_file($$file, $editor); - } - - if(!$modified) { - $self->flush_old; - } -} - -######################################################################## -# Hack for backward compabillity -# - -my %insert_line; -my %substitute_line; -my %delete_line; - -my %spec_file; - -sub flush_old($) { - my $self = shift; - - my $file = ${$self->{FILE}}; - - my $editor = sub { - local *IN = shift; - local *OUT = shift; - - my $modified = 0; - while() { - chomp; - - my $line; - - $line = $insert_line{$.}; - if(defined($line)) { - if($options->modify) { - $_ = "$line$_"; - $modified = 1; - } else { - my $line2 = $line; chomp($line2); - my @line2 = split(/\n/, $line2); - if($#line2 > 0) { - $output->write("$file: $.: insert: \\\n"); - foreach my $line2 (@line2) { - $output->write("'$line2'\n"); - } - } else { - $output->write("$file: $.: insert: '$line2'\n"); - } - } - } - - my $search = $substitute_line{$.}{search}; - my $replace = $substitute_line{$.}{replace}; - - if(defined($search) && defined($replace)) { - my $modified2 = 0; - if(s/$search/$replace/) { - if($options->modify) { - $modified = 1; - } - $modified2 = 1; - } - - if(!$options->modify || !$modified2) { - my $search2; - my $replace2; - if(!$modified2) { - $search2 = "unmatched search"; - $replace2 = "unmatched replace"; - } else { - $search2 = "search"; - $replace2 = "replace"; - } - $output->write("$file: $.: $search2 : '$search'\n"); - - my @replace2 = split(/\n/, $replace); - if($#replace2 > 0) { - $output->write("$file: $.: $replace2: \\\n"); - foreach my $replace2 (@replace2) { - $output->write("'$replace2'\n"); - } - } else { - $output->write("$file: $.: $replace2: '$replace'\n"); - } - } - } - - $line = $delete_line{$.}; - if(defined($line)) { - if(/$line/) { - if($options->modify) { - $modified = 1; - next; - } else { - $output->write("$file: $.: delete: '$line'\n"); - } - } else { - $output->write("$file: $.: unmatched delete: '$line'\n"); - } - } - - print OUT "$_\n"; - } - - return $modified; - }; - - my $n = 0; - while(defined(each %insert_line)) { $n++; } - while(defined(each %substitute_line)) { $n++; } - while(defined(each %delete_line)) { $n++; } - if($n > 0) { - edit_file($file, $editor); - } - - foreach my $module (sort(keys(%spec_file))) { - my $file; - foreach my $winapi (@winapis) { - $file = ($winapi->module_file($module) || $file); - } - - if(defined($file)) { - $file = file_normalize($file); - } - - my @substitutes = @{$spec_file{$module}}; - - my $editor = sub { - local *IN = shift; - local *OUT = shift; - - my $modified = 0; - while() { - chomp; - - my @substitutes2 = (); - foreach my $substitute (@substitutes) { - my $search = $substitute->{search}; - my $replace = $substitute->{replace}; - - if(s/$search/$replace/) { - if($options->modify) { - $modified = 1; - } else { - $output->write("$file: search : '$search'\n"); - $output->write("$file: replace: '$replace'\n"); - } - next; - } else { - push @substitutes2, $substitute; - } - } - @substitutes = @substitutes2; - - print OUT "$_\n"; - } - - return $modified; - }; - - if(defined($file)) { - edit_file($file, $editor); - } else { - $output->write("$module: doesn't have any spec file\n"); - } - - if($#substitutes >= 0) { - foreach my $substitute (@substitutes) { - my $search = $substitute->{search}; - my $replace = $substitute->{replace}; - - $output->write("$file: unmatched search : '$search'\n"); - $output->write("$file: unmatched replace: '$replace'\n"); - } - } - - } - - %insert_line = (); - %substitute_line = (); - %delete_line = (); - - %spec_file = (); -} - -sub delete_line($$$) { - my $self = shift; - - my $line = shift; - my $pattern = shift; - - $delete_line{$line} = $pattern; -} - -sub insert_line($$$) { - my $self = shift; - - my $line = shift; - my $insert = shift; - - $insert_line{$line} = $insert; -} - -sub substitute_line($$$$) { - my $self = shift; - - my $line = shift; - my $search = shift; - my $replace = shift; - - $substitute_line{$line}{search} = $search; - $substitute_line{$line}{replace} = $replace; -} - -sub replace_spec_file($$$$) { - my $self = shift; - - my $module = shift; - my $search = shift; - my $replace = shift; - - my $substitute = {}; - $substitute->{search} = $search; - $substitute->{replace} = $replace; - - if(!defined($spec_file{$module})) { - $spec_file{$module} = []; - } - - push @{$spec_file{$module}}, $substitute; -} - -1; diff --git a/tools/winapi/winapi_fixup_options.pm b/tools/winapi/winapi_fixup_options.pm deleted file mode 100644 index ee0d9e68d21..00000000000 --- a/tools/winapi/winapi_fixup_options.pm +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright 1999, 2000, 2001 Patrik Stridvall -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -package winapi_fixup_options; -use base qw(options); - -use strict; - -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); -require Exporter; - -@ISA = qw(Exporter); -@EXPORT = qw(); -@EXPORT_OK = qw($options); - -use options qw($options); - -my %options_long = ( - "debug" => { default => 0, description => "debug mode" }, - "help" => { default => 0, description => "help mode" }, - "verbose" => { default => 0, description => "verbose mode" }, - - "progress" => { default => 1, description => "show progress" }, - - "win16" => { default => 1, description => "Win16 fixup" }, - "win32" => { default => 1, description => "Win32 fixup" }, - - "local" => { default => 1, description => "local fixup" }, - "documentation" => { default => 1, parent => "local", description => "documentation fixup" }, - "documentation-missing" => { default => 1, parent => "documentation", description => "documentation missing fixup" }, - "documentation-name" => { default => 1, parent => "documentation", description => "documentation name fixup" }, - "documentation-ordinal" => { default => 1, parent => "documentation", description => "documentation ordinal fixup" }, - "documentation-wrong" => { default => 1, parent => "documentation", description => "documentation wrong fixup" }, - "statements" => { default => 1, parent => "local", description => "statements fixup" }, - "statements-windowsx" => { default => 0, parent => "local", description => "statements windowsx fixup" }, - "stub" => { default => 0, parent => "local", description => "stub fixup" }, - - "global" => { default => 1, description => "global fixup" }, - - "modify" => { default => 0, description => "actually perform the fixups" }, -); - -my %options_short = ( - "d" => "debug", - "?" => "help", - "v" => "verbose" -); - -my $options_usage = "usage: winapi_fixup [--help] []\n"; - -$options = '_options'->new(\%options_long, \%options_short, $options_usage); - -1; diff --git a/tools/winapi/winapi_fixup_statements.pm b/tools/winapi/winapi_fixup_statements.pm deleted file mode 100644 index df1d81198b1..00000000000 --- a/tools/winapi/winapi_fixup_statements.pm +++ /dev/null @@ -1,337 +0,0 @@ -# -# Copyright 1999, 2000, 2001 Patrik Stridvall -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -# - -package winapi_fixup_statements; - -use strict; - -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); -require Exporter; - -@ISA = qw(Exporter); -@EXPORT = qw(); -@EXPORT_OK = qw(fixup_statements); - -use config qw($wine_dir); -use options qw($options); -use output qw($output); - -use c_parser; -use winapi_module_user qw( - get_message_result_kind - get_message_wparam_kind - get_message_lparam_kind -); - -######################################################################## -# fixup_function_call - -sub fixup_function_call($$) { - my $name = shift; - my @arguments = @{(shift)};; - - return "$name(" . join(", ", @arguments) . ")"; -} - -######################################################################## -# _parse_makelong - -sub _parse_makelong($) { - local $_ = shift; - - my $low; - my $high; - - my $name; - my @arguments; - my @argument_lines; - my @argument_columns; - - my $parser = new c_parser; - - my $line = 1; - my $column = 0; - if($parser->parse_c_function_call(\$_, \$line, \$column, \$name, \@arguments, \@argument_lines, \@argument_columns) && - $name =~ /^MAKE(?:LONG|LPARAM|LRESULT|WPARAM)$/) - { - $low = $arguments[0]; - $high = $arguments[1]; - } elsif(/^(?:\(\w+\)\s*)?0L?$/) { - $low = "0"; - $high = "0"; - } else { - $low = "($_) & 0xffff"; - $high = "($_) << 16"; - } - - $low =~ s/^\s*(.*?)\s*$/$1/; - $high =~ s/^\s*(.*?)\s*$/$1/; - - return ($low, $high); -} - -######################################################################## -# fixup_function_call_2_windowsx - -sub fixup_user_message_2_windowsx($$) { - my $name = shift; - (my $hwnd, my $msg, my $wparam, my $lparam) = @{(shift)}; - - if($msg !~ /^WM_/) { - return undef; - } elsif($msg =~ /^(?:WM_BEGINDRAG|WM_ENTERMENULOOP|WM_EXITMENULOOP|WM_HELP| - WM_ISACTIVEICON|WM_LBTRACKPOINT|WM_NEXTMENU)$/x) - { - return undef; - } elsif($msg =~ /^WM_(?:GET|SET)TEXT$/) { - return undef; - } - - my $suffix; - $name =~ /([AW])?$/; - if(defined($1)) { - $suffix = $1; - } else { - $suffix = ""; - } - - $wparam =~ s/^\(WPARAM\)\s*//; - $lparam =~ s/^\(LPARAM\)\s*//; - - my @arguments; - if($msg =~ /^WM_COMMAND$/) { - (my $id, my $code_notify) = _parse_makelong($wparam); - my $hwndctl = $lparam; - @arguments = ($id, $hwndctl, $code_notify); - } elsif($msg =~ /^WM_(?:COPY|CUT|PASTE)$/) { - @arguments = (); - } elsif($msg =~ /^WM_(?:CHARTO|VKEYTO)ITEM$/) { - (my $key, my $caret) = _parse_makelong($wparam); - my $hwndctl = $lparam; - @arguments = ($key, $hwndctl, $caret); - } elsif($msg =~ /^WM_(?:COMPARE|DELETE|DRAW|MEASURE)ITEM$/) { - @arguments = ($lparam); - } elsif($msg =~ s/^WM_GETTEXT$/$&$suffix/) { - @arguments = ($wparam, $lparam); - } elsif($msg =~ /^WM_INITMENU$/) { - my $hmenu = $wparam; - @arguments = ($hmenu); - } elsif($msg =~ /^WM_INITMENUPOPUP$/) { - my $hmenu = $wparam; - (my $item, my $system_menu) = _parse_makelong($lparam); - @arguments = ($hmenu, $item, $system_menu); - } elsif($msg =~ /^WM_MENUCHAR$/) { - (my $ch, my $flags) = _parse_makelong($wparam); - my $hmenu = $lparam; - @arguments = ($ch, $flags, $hmenu); - } elsif($msg =~ /^WM_MENUSELECT$/) { - (my $item, my $flags) = _parse_makelong($wparam); - my $hmenu = $lparam; - my $hmenu_popup = "NULL"; # FIXME: Is this really correct? - @arguments = ($hmenu, $item, $hmenu_popup, $flags); - } elsif($msg =~ s/^WM_(NC)?LBUTTONDBLCLK$/WM_$1LBUTTONDOWN/) { - my $double_click = "TRUE"; - my $key_flags = $wparam; - (my $x, my $y) = _parse_makelong($lparam); - @arguments = ($double_click, $x, $y, $key_flags); - } elsif($msg =~ /^WM_(NC)?LBUTTONDOWN$/) { - my $double_click = "FALSE"; - my $key_flags = $wparam; - (my $x, my $y) = _parse_makelong($lparam); - @arguments = ($double_click, $x, $y, $key_flags); - } elsif($msg =~ /^WM_LBUTTONUP$/) { - my $key_flags = $wparam; - (my $x, my $y) = _parse_makelong($lparam); - @arguments = ($x, $y, $key_flags); - } elsif($msg =~ /^WM_SETCURSOR$/) { - my $hwnd_cursor = $wparam; - (my $code_hit_test, my $msg2) = _parse_makelong($lparam); - @arguments = ($hwnd_cursor, $code_hit_test, $msg2); - } elsif($msg =~ s/^WM_SETTEXT$/$&$suffix/) { - my $text = $lparam; - @arguments = ($text); - } elsif($msg =~ /^WM_(?:SYS)?KEYDOWN$/) { - my $vk = $wparam; - (my $repeat, my $flags) = _parse_makelong($lparam); - @arguments = ($vk, $repeat, $flags); - } else { - @arguments = ($wparam, $lparam); - } - unshift @arguments, $hwnd; - - return "FORWARD_" . $msg . "(" . join(", ", @arguments) . ", $name)"; -} - -######################################################################## -# _get_messages - -sub _get_messages($) { - local $_ = shift; - - if(/^(?:BM|CB|EM|LB|STM|WM)_\w+(.*?)$/) { - if(!$1) { - return ($_); - } else { - return (); - } - } elsif(/^(.*?)\s*\?\s*((?:BM|CB|EM|LB|STM|WM)_\w+)\s*:\s*((?:BM|CB|EM|LB|STM|WM)_\w+)$/) { - return ($2, $3); - } elsif(/^\w+$/) { - return (); - } elsif(/^RegisterWindowMessage[AW]\s*\(.*?\)$/) { - return (); - } else { - $output->write("warning: _get_messages: '$_'\n"); - return (); - } -} - -######################################################################## -# _fixup_user_message - -sub _fixup_user_message($$) { - my $name = shift; - (my $hwnd, my $msg, my $wparam, my $lparam) = @{(shift)}; - - my $modified = 0; - - my $wkind; - my $lkind; - foreach my $msg (_get_messages($msg)) { - my $new_wkind = get_message_wparam_kind($msg); - if(defined($wkind) && $new_wkind ne $wkind) { - $output->write("messsages used together do not have the same type\n"); - } else { - $wkind = $new_wkind; - } - - my $new_lkind = get_message_lparam_kind($msg); - if(defined($lkind) && $new_lkind ne $lkind) { - $output->write("messsages used together do not have the same type\n"); - } else { - $lkind = $new_lkind; - } - } - - my @entries = ( - [ \$wparam, $wkind, "W", "w" ], - [ \$lparam, $lkind, "L", "l" ] - ); - foreach my $entry (@entries) { - (my $refparam, my $kind, my $upper, my $lower) = @$entry; - - if(!defined($kind)) { - if($msg =~ /^WM_/) { - $output->write("messsage $msg not properly defined\n"); - $modified = 0; - last; - } - } elsif($kind eq "ptr") { - if($$refparam =~ /^(\(${upper}PARAM\))?\s*($lower[pP]aram)$/) { - if(defined($1)) { - $$refparam = $2; - $modified = 1; - } - } elsif($$refparam =~ /^(\(${upper}PARAM\))?\s*0$/) { - $$refparam = "(${upper}PARAM) NULL"; - $modified = 1; - } elsif($$refparam !~ /^\(${upper}PARAM\)\s*/) { - $$refparam = "(${upper}PARAM) $$refparam"; - $modified = 1; - } - } elsif($kind eq "long") { - if($$refparam =~ s/^\(${upper}PARAM\)\s*//) { - $modified = 1; - } - } - } - - if($modified) { - my @arguments = ($hwnd, $msg, $wparam, $lparam); - return "$name(" . join(", ", @arguments) . ")"; - } else { - return undef; - } -} - -######################################################################## -# fixup_statements - -sub fixup_statements($$) { - my $function = shift; - my $editor = shift; - - my $file = $function->file; - my $linkage = $function->linkage; - my $name = $function->name; - my $statements_line = $function->statements_line; - my $statements_column = $function->statements_column; - my $statements = $function->statements; - - if(!defined($statements)) { - return; - } - - my $parser = new c_parser($file); - - my $found_function_call = sub { - my $begin_line = shift; - my $begin_column = shift; - my $end_line = shift; - my $end_column = shift; - my $name = shift; - my $arguments = shift; - - foreach my $argument (@$arguments) { - $argument =~ s/^\s*(.*?)\s*$/$1/; - } - - my $fixup_function_call; - if($name =~ /^(?:DefWindowProc|SendMessage)[AW]$/) - { - if($options->statements_windowsx) { - $fixup_function_call = \&fixup_user_message_2_windowsx; - } else { - $fixup_function_call = \&_fixup_user_message; - } - } - - if(defined($fixup_function_call)) { - my $replace = &$fixup_function_call($name, $arguments); - - if(defined($replace)) { - $editor->replace($begin_line, $begin_column, $end_line, $end_column, $replace); - } - } elsif($options->debug) { - $output->write("$begin_line.$begin_column-$end_line.$end_column: " . - "$name(" . join(", ", @$arguments) . ")\n"); - } - - return 0; - }; - - $parser->set_found_function_call_callback($found_function_call); - - my $line = $statements_line; - my $column = 0; - if(!$parser->parse_c_statements(\$statements, \$line, \$column)) { - $output->write("error: can't parse statements\n"); - } -} - -1; diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c index bbe4d563d7f..5ff8a164559 100644 --- a/tools/winedump/pe.c +++ b/tools/winedump/pe.c @@ -669,7 +669,7 @@ static void dump_x86_64_unwind_info( const struct runtime_function *function ) } if (info->flags & (UNW_FLAG_EHANDLER | UNW_FLAG_UHANDLER)) printf( " handler %08x data at %08x\n", handler_data->handler, - function->UnwindData + (char *)(&handler_data->handler + 1) - (char *)info ); + (ULONG)(function->UnwindData + (char *)(&handler_data->handler + 1) - (char *)info )); } static void dump_dir_exceptions(void) -- 2.11.4.GIT