From b696a07a38865f608fad8b25e45fcc313bde1530 Mon Sep 17 00:00:00 2001 From: Jan Zerebecki Date: Wed, 7 Jan 2009 22:11:50 +0100 Subject: [PATCH] push 9d6e510d5bb9560a6aa2e6ec402cb2d2444b5081 --- configure | 18 + configure.ac | 2 + dlls/advapi32/tests/cred.c | 12 +- dlls/crypt32/crypt32.spec | 4 +- dlls/crypt32/msg.c | 116 +++++- dlls/d3d8/device.c | 126 +++---- dlls/d3d9/device.c | 41 +- dlls/d3d9/tests/texture.c | 1 - dlls/d3dxof/parsing.c | 83 ++--- dlls/ddraw/device.c | 254 ++++++------- dlls/dnsapi/ns_name.c | 204 ++-------- dlls/gdi32/dispdib.c | 93 ----- dlls/gphoto2.ds/capability.c | 6 +- dlls/gphoto2.ds/gphoto2_main.c | 6 +- dlls/imm32/imm.c | 96 ++--- dlls/inkobj/inkobj.c | 2 +- dlls/inkobj/inkobj_internal.h | 1 - dlls/iphlpapi/icmp.c | 2 +- dlls/iphlpapi/iphlpapi_main.c | 4 +- dlls/jscript/dispex.c | 2 +- dlls/kernel32/debugger.c | 19 - dlls/kernel32/instr.c | 4 + dlls/kernel32/kernel16.c | 19 + dlls/kernel32/kernel32.spec | 48 +-- dlls/kernel32/kernel_private.h | 10 +- dlls/kernel32/relay16.c | 25 +- dlls/kernel32/thunk.c | 306 ++++++++++++--- dlls/kernel32/utthunk.c | 4 + dlls/kernel32/vxd.c | 2 +- dlls/kernel32/wowthunk.c | 243 ------------ dlls/loadperf/Makefile.in | 13 + dlls/loadperf/loadperf.spec | 14 + dlls/loadperf/loadperf_main.c | 92 +++++ dlls/mapi32/mapi32_main.c | 4 +- dlls/mapi32/sendmail.c | 2 +- dlls/mshtml/dispex.c | 1 + dlls/mshtml/htmllocation.c | 19 +- dlls/mshtml/mshtml_private.h | 2 + dlls/mshtml/omnavigator.c | 8 +- dlls/mshtml/tests/dom.c | 1 + dlls/msvcrt/except.c | 8 +- dlls/ntdll/exception.c | 41 +- dlls/ntdll/ntdll_misc.h | 20 +- dlls/ntdll/relay.c | 92 ++++- dlls/ntdll/rtlbitmap.c | 9 +- dlls/ntdll/serial.c | 6 +- dlls/ntdll/signal_i386.c | 8 +- dlls/ntdll/signal_powerpc.c | 7 +- dlls/ntdll/signal_sparc.c | 7 +- dlls/ntdll/signal_x86_64.c | 9 +- dlls/ntdll/thread.c | 2 +- dlls/ntoskrnl.exe/ntoskrnl.c | 10 +- dlls/ole32/defaulthandler.c | 2 +- dlls/ole32/tests/ole2.c | 1 - dlls/oleaut32/olepicture.c | 14 + dlls/oleaut32/tests/olepicture.c | 58 +++ dlls/qmgr/job.c | 18 +- dlls/quartz/pin.c | 413 +++++++++++---------- dlls/quartz/pin.h | 13 - dlls/riched20/editor.c | 22 +- dlls/riched20/paint.c | 41 +- dlls/rpcrt4/rpc_binding.c | 4 +- dlls/rpcrt4/rpc_message.c | 2 +- dlls/sane.ds/sane_main.c | 2 +- dlls/schannel/tests/main.c | 8 +- dlls/secur32/ntlm.c | 2 +- dlls/secur32/schannel.c | 6 +- dlls/secur32/tests/ntlm.c | 14 +- dlls/secur32/tests/schannel.c | 2 +- dlls/secur32/tests/secur32.c | 4 +- dlls/setupapi/parser.c | 69 ++++ dlls/setupapi/setupapi.spec | 2 + dlls/setupapi/stringtable.c | 50 +-- dlls/setupapi/tests/install.c | 12 + dlls/setupapi/tests/parser.c | 51 ++- dlls/setupapi/tests/stringtable.c | 192 +++++++++- dlls/sfc/sfc.spec | 12 + dlls/sfc/sfc_main.c | 6 + dlls/shell32/tests/shlfileop.c | 327 ++++++++++------ dlls/twain_32/twain32_main.c | 6 +- dlls/updspapi/Makefile.in | 10 + dlls/updspapi/updspapi.spec | 70 ++++ dlls/urlmon/tests/url.c | 157 ++++---- dlls/usp10/tests/usp10.c | 83 +++++ dlls/usp10/usp10.c | 43 ++- dlls/w32skrnl/w32skernel.c | 10 - dlls/wined3d/arb_program_shader.c | 4 +- dlls/wined3d/ati_fragment_shader.c | 2 +- dlls/wined3d/device.c | 47 ++- dlls/wined3d/drawprim.c | 42 +-- dlls/wined3d/nvidia_texture_shader.c | 4 +- dlls/wined3d/query.c | 106 ++++-- dlls/wined3d/state.c | 12 +- dlls/wined3d/stateblock.c | 13 +- dlls/wined3d/utils.c | 3 - dlls/wined3d/wined3d_private.h | 22 +- dlls/winedos/devices.c | 134 ------- dlls/winedos/dosexe.h | 7 - dlls/winedos/vga.c | 20 - dlls/winedos/vga.h | 2 - dlls/winex11.drv/window.c | 62 ++++ dlls/winex11.drv/x11drv.h | 2 + dlls/winex11.drv/x11drv_main.c | 2 + dlls/wintab32/context.c | 18 + dlls/xinput1_3/tests/xinput.c | 27 ++ dlls/xinput1_3/xinput1_3.spec | 2 +- dlls/xinput1_3/xinput1_3_main.c | 12 + documentation/README.de | 16 +- include/Makefile.in | 1 + include/ipexport.h | 10 +- .../inkobj/inkobj_internal.h => include/loadperf.h | 30 +- include/mapi.h | 6 +- include/mapix.h | 2 +- include/msvcrt/crtdefs.h | 12 + include/msvcrt/stdio.h | 18 +- include/msvcrt/wchar.h | 8 +- include/setupapi.h | 4 +- include/sspi.h | 132 +++---- include/twain.h | 4 +- include/wine/wined3d.idl | 36 +- include/winnt.h | 160 ++++---- programs/cmd/builtins.c | 107 +++--- programs/cmd/directory.c | 8 +- programs/cmd/wcmd.h | 5 - programs/cmd/wcmdmain.c | 27 +- programs/explorer/appbar.c | 2 - programs/oleview/details.c | 2 +- programs/oleview/interface.c | 2 +- programs/oleview/oleview.c | 6 +- programs/oleview/pane.c | 2 +- programs/oleview/tree.c | 2 +- programs/oleview/typelib.c | 8 +- programs/regedit/Bg.rc | 4 +- programs/regedit/Cs.rc | 4 +- programs/regedit/Da.rc | 4 +- programs/regedit/De.rc | 4 +- programs/regedit/En.rc | 4 +- programs/regedit/Es.rc | 4 +- programs/regedit/Fr.rc | 4 +- programs/regedit/Hu.rc | 4 +- programs/regedit/It.rc | 4 +- programs/regedit/Ja.rc | 4 +- programs/regedit/Ko.rc | 4 +- programs/regedit/Nl.rc | 4 +- programs/regedit/No.rc | 4 +- programs/regedit/Pl.rc | 4 +- programs/regedit/Pt.rc | 8 +- programs/regedit/Ru.rc | 4 +- programs/regedit/Si.rc | 4 +- programs/regedit/Tr.rc | 4 +- programs/regedit/Zh.rc | 8 +- programs/regedit/edit.c | 22 +- programs/regedit/framewnd.c | 4 +- programs/view/view.c | 161 ++++---- programs/winefile/winefile.c | 96 ++--- programs/winefile/winefile.h | 2 - programs/winemenubuilder/winemenubuilder.c | 2 +- programs/winemine/main.c | 46 +-- tools/widl/client.c | 80 ++-- tools/widl/expr.c | 4 +- tools/widl/header.c | 250 +++++++------ tools/widl/header.h | 16 +- tools/widl/parser.h | 3 - tools/widl/parser.y | 263 ++++++------- tools/widl/proxy.c | 217 ++++++----- tools/widl/server.c | 45 ++- tools/widl/typegen.c | 410 +++++++++++--------- tools/widl/typegen.h | 16 +- tools/widl/typelib.c | 45 +-- tools/widl/typetree.c | 92 ++++- tools/widl/typetree.h | 88 +++++ tools/widl/utils.c | 8 +- tools/widl/widltypes.h | 56 ++- tools/widl/write_msft.c | 143 ++++--- tools/wine.desktop | 1 + tools/winebuild/relay.c | 234 ++++++++++-- tools/winebuild/spec32.c | 3 +- tools/winedump/pe.c | 93 +++-- 178 files changed, 4318 insertions(+), 3173 deletions(-) create mode 100644 dlls/loadperf/Makefile.in create mode 100644 dlls/loadperf/loadperf.spec create mode 100644 dlls/loadperf/loadperf_main.c create mode 100644 dlls/updspapi/Makefile.in create mode 100644 dlls/updspapi/updspapi.spec copy dlls/inkobj/inkobj_internal.h => include/loadperf.h (65%) diff --git a/configure b/configure index 36ec8a1b2bb..0e8fdf30129 100755 --- a/configure +++ b/configure @@ -23736,6 +23736,14 @@ dlls/kernel32/tests/Makefile: dlls/kernel32/tests/Makefile.in dlls/Maketest.rule ac_config_files="$ac_config_files dlls/kernel32/tests/Makefile" ALL_MAKEFILES="$ALL_MAKEFILES \\ + dlls/loadperf/Makefile" +test "x$enable_loadperf" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\ + loadperf" +ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS +dlls/loadperf/Makefile: dlls/loadperf/Makefile.in dlls/Makedll.rules" +ac_config_files="$ac_config_files dlls/loadperf/Makefile" + +ALL_MAKEFILES="$ALL_MAKEFILES \\ dlls/localspl/Makefile" test "x$enable_localspl" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\ localspl" @@ -24976,6 +24984,14 @@ dlls/unicows/Makefile: dlls/unicows/Makefile.in dlls/Makedll.rules" ac_config_files="$ac_config_files dlls/unicows/Makefile" ALL_MAKEFILES="$ALL_MAKEFILES \\ + dlls/updspapi/Makefile" +test "x$enable_updspapi" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\ + updspapi" +ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS +dlls/updspapi/Makefile: dlls/updspapi/Makefile.in dlls/Makedll.rules" +ac_config_files="$ac_config_files dlls/updspapi/Makefile" + +ALL_MAKEFILES="$ALL_MAKEFILES \\ dlls/url/Makefile" test "x$enable_url" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\ url" @@ -26792,6 +26808,7 @@ do "dlls/jscript/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/jscript/tests/Makefile" ;; "dlls/kernel32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/kernel32/Makefile" ;; "dlls/kernel32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/kernel32/tests/Makefile" ;; + "dlls/loadperf/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/loadperf/Makefile" ;; "dlls/localspl/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/localspl/Makefile" ;; "dlls/localspl/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/localspl/tests/Makefile" ;; "dlls/localui/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/localui/Makefile" ;; @@ -26947,6 +26964,7 @@ do "dlls/tapi32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/tapi32/Makefile" ;; "dlls/twain_32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/twain_32/Makefile" ;; "dlls/unicows/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/unicows/Makefile" ;; + "dlls/updspapi/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/updspapi/Makefile" ;; "dlls/url/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/url/Makefile" ;; "dlls/urlmon/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/urlmon/Makefile" ;; "dlls/urlmon/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/urlmon/tests/Makefile" ;; diff --git a/configure.ac b/configure.ac index 8392bd80ec0..bb5325b03ab 100644 --- a/configure.ac +++ b/configure.ac @@ -1924,6 +1924,7 @@ WINE_CONFIG_MAKEFILE([dlls/jscript/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DL WINE_CONFIG_MAKEFILE([dlls/jscript/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests]) WINE_CONFIG_MAKEFILE([dlls/kernel32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/kernel32/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests]) +WINE_CONFIG_MAKEFILE([dlls/loadperf/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/localspl/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/localspl/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests]) WINE_CONFIG_MAKEFILE([dlls/localui/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) @@ -2079,6 +2080,7 @@ WINE_CONFIG_MAKEFILE([dlls/sxs/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DI WINE_CONFIG_MAKEFILE([dlls/tapi32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/twain_32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/unicows/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) +WINE_CONFIG_MAKEFILE([dlls/updspapi/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/url/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/urlmon/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS]) WINE_CONFIG_MAKEFILE([dlls/urlmon/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests]) diff --git a/dlls/advapi32/tests/cred.c b/dlls/advapi32/tests/cred.c index e23f8721c09..58103c63166 100644 --- a/dlls/advapi32/tests/cred.c +++ b/dlls/advapi32/tests/cred.c @@ -180,16 +180,20 @@ static void test_CredReadDomainCredentialsA(void) SetLastError(0xdeadbeef); ret = pCredReadDomainCredentialsA(&info, 0, &count, &creds); - ok(!ret && GetLastError() == ERROR_NOT_FOUND, - "CredReadDomainCredentialsA should have failed with ERROR_NOT_FOUND instead of %d\n", + ok(!ret, "CredReadDomainCredentialsA should have failed\n"); + ok(GetLastError() == ERROR_NOT_FOUND || + GetLastError() == ERROR_INVALID_PARAMETER, /* Vista, W2K8 */ + "Expected ERROR_NOT_FOUND or ERROR_INVALID_PARAMETER instead of %d\n", GetLastError()); info.DnsServerName = NULL; SetLastError(0xdeadbeef); ret = pCredReadDomainCredentialsA(&info, 0, &count, &creds); - ok(!ret && GetLastError() == ERROR_NOT_FOUND, - "CredReadDomainCredentialsA should have failed with ERROR_NOT_FOUND instead of %d\n", + ok(!ret, "CredReadDomainCredentialsA should have failed\n"); + ok(GetLastError() == ERROR_NOT_FOUND || + GetLastError() == ERROR_INVALID_PARAMETER, /* Vista, W2K8 */ + "Expected ERROR_NOT_FOUND or ERROR_INVALID_PARAMETER instead of %d\n", GetLastError()); } diff --git a/dlls/crypt32/crypt32.spec b/dlls/crypt32/crypt32.spec index c06bca1debc..3f9ac98e99c 100644 --- a/dlls/crypt32/crypt32.spec +++ b/dlls/crypt32/crypt32.spec @@ -148,12 +148,12 @@ @ stub CryptMsgCountersign @ stub CryptMsgCountersignEncoded @ stdcall CryptMsgDuplicate(ptr) -@ stub CryptMsgEncodeAndSignCTL +@ stdcall CryptMsgEncodeAndSignCTL(long ptr ptr long ptr ptr) @ stdcall CryptMsgGetAndVerifySigner(ptr long ptr long ptr ptr) @ stdcall CryptMsgGetParam(ptr long long ptr ptr) @ stdcall CryptMsgOpenToDecode(long long long long ptr ptr) @ stdcall CryptMsgOpenToEncode(long long long ptr str ptr) -@ stub CryptMsgSignCTL +@ stdcall CryptMsgSignCTL(long ptr long ptr long ptr ptr) @ stdcall CryptMsgUpdate(ptr ptr long long) @ stub CryptMsgVerifyCountersignatureEncoded @ stdcall CryptMsgVerifyCountersignatureEncodedEx(ptr long ptr long ptr long long ptr long ptr) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 7c90d75dd2d..b04af9e630f 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -1169,6 +1169,7 @@ static BOOL CSignedMsgData_Update(CSignedMsgData *msg_data, typedef struct _CSignedEncodeMsg { CryptMsgBase base; + LPSTR innerOID; CRYPT_DATA_BLOB data; CSignedMsgData msg_data; } CSignedEncodeMsg; @@ -1178,6 +1179,7 @@ static void CSignedEncodeMsg_Close(HCRYPTMSG hCryptMsg) CSignedEncodeMsg *msg = (CSignedEncodeMsg *)hCryptMsg; DWORD i; + CryptMemFree(msg->innerOID); CryptMemFree(msg->data.pbData); CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCertEncoded); CRYPT_FreeBlobArray((BlobArray *)&msg->msg_data.info->cCrlEncoded); @@ -1227,32 +1229,46 @@ static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, case CMSG_BARE_CONTENT_PARAM: { CRYPT_SIGNED_INFO info; - char oid_rsa_data[] = szOID_RSA_data; + BOOL freeContent = FALSE; info = *msg->msg_data.info; - /* Quirk: OID is only encoded messages if an update has happened */ - if (msg->base.state != MsgStateInit) - info.content.pszObjId = oid_rsa_data; - else - info.content.pszObjId = NULL; - if (msg->data.cbData) + if (!msg->innerOID || !strcmp(msg->innerOID, szOID_RSA_data)) { - CRYPT_DATA_BLOB blob = { msg->data.cbData, msg->data.pbData }; + char oid_rsa_data[] = szOID_RSA_data; + + /* Quirk: OID is only encoded messages if an update has happened */ + if (msg->base.state != MsgStateInit) + info.content.pszObjId = oid_rsa_data; + else + info.content.pszObjId = NULL; + if (msg->data.cbData) + { + CRYPT_DATA_BLOB blob = { msg->data.cbData, msg->data.pbData }; - ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, - &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, - &info.content.Content.pbData, &info.content.Content.cbData); + ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_OCTET_STRING, + &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, + &info.content.Content.pbData, &info.content.Content.cbData); + freeContent = TRUE; + } + else + { + info.content.Content.cbData = 0; + info.content.Content.pbData = NULL; + ret = TRUE; + } } else { - info.content.Content.cbData = 0; - info.content.Content.pbData = NULL; + info.content.pszObjId = msg->innerOID; + info.content.Content.cbData = msg->data.cbData; + info.content.Content.pbData = msg->data.pbData; ret = TRUE; } if (ret) { ret = CRYPT_AsnEncodeCMSSignedInfo(&info, pvData, pcbData); - LocalFree(info.content.Content.pbData); + if (freeContent) + LocalFree(info.content.Content.pbData); } break; } @@ -1357,9 +1373,22 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, CryptMsgBase_Init((CryptMsgBase *)msg, dwFlags, pStreamInfo, CSignedEncodeMsg_Close, CSignedEncodeMsg_GetParam, CSignedEncodeMsg_Update, CRYPT_DefaultMsgControl); + if (pszInnerContentObjID) + { + msg->innerOID = CryptMemAlloc(strlen(pszInnerContentObjID) + 1); + if (msg->innerOID) + strcpy(msg->innerOID, pszInnerContentObjID); + else + ret = FALSE; + } + else + msg->innerOID = NULL; msg->data.cbData = 0; msg->data.pbData = NULL; - msg->msg_data.info = CryptMemAlloc(sizeof(CRYPT_SIGNED_INFO)); + if (ret) + msg->msg_data.info = CryptMemAlloc(sizeof(CRYPT_SIGNED_INFO)); + else + msg->msg_data.info = NULL; if (msg->msg_data.info) { memset(msg->msg_data.info, 0, sizeof(CRYPT_SIGNED_INFO)); @@ -2896,3 +2925,60 @@ BOOL WINAPI CryptMsgVerifyCountersignatureEncodedEx(HCRYPTPROV_LEGACY hCryptProv cbSignerInfoCountersignature, dwSignerType, pvSigner, dwFlags, pvReserved); return FALSE; } + +BOOL WINAPI CryptMsgEncodeAndSignCTL(DWORD dwMsgEncodingType, + PCTL_INFO pCtlInfo, PCMSG_SIGNED_ENCODE_INFO pSignInfo, DWORD dwFlags, + BYTE *pbEncoded, DWORD *pcbEncoded) +{ + BOOL ret; + BYTE *pbCtlContent; + DWORD cbCtlContent; + + TRACE("(%08x, %p, %p, %08x, %p, %p)\n", dwMsgEncodingType, pCtlInfo, + pSignInfo, dwFlags, pbEncoded, pcbEncoded); + + if (dwFlags) + { + FIXME("unimplemented for flags %08x\n", dwFlags); + return FALSE; + } + if ((ret = CryptEncodeObjectEx(dwMsgEncodingType, PKCS_CTL, pCtlInfo, + CRYPT_ENCODE_ALLOC_FLAG, NULL, &pbCtlContent, &cbCtlContent))) + { + ret = CryptMsgSignCTL(dwMsgEncodingType, pbCtlContent, cbCtlContent, + pSignInfo, dwFlags, pbEncoded, pcbEncoded); + LocalFree(pbCtlContent); + } + return ret; +} + +BOOL WINAPI CryptMsgSignCTL(DWORD dwMsgEncodingType, BYTE *pbCtlContent, + DWORD cbCtlContent, PCMSG_SIGNED_ENCODE_INFO pSignInfo, DWORD dwFlags, + BYTE *pbEncoded, DWORD *pcbEncoded) +{ + static char oid_ctl[] = szOID_CTL; + BOOL ret; + HCRYPTMSG msg; + + TRACE("(%08x, %p, %d, %p, %08x, %p, %p)\n", dwMsgEncodingType, + pbCtlContent, cbCtlContent, pSignInfo, dwFlags, pbEncoded, pcbEncoded); + + if (dwFlags) + { + FIXME("unimplemented for flags %08x\n", dwFlags); + return FALSE; + } + msg = CryptMsgOpenToEncode(dwMsgEncodingType, 0, CMSG_SIGNED, pSignInfo, + oid_ctl, NULL); + if (msg) + { + ret = CryptMsgUpdate(msg, pbCtlContent, cbCtlContent, TRUE); + if (ret) + ret = CryptMsgGetParam(msg, CMSG_CONTENT_PARAM, 0, pbEncoded, + pcbEncoded); + CryptMsgClose(msg); + } + else + ret = FALSE; + return ret; +} diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 96ce450c1a7..ae62f071967 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1266,100 +1266,70 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, D return hr; } +static const struct tss_lookup +{ + BOOL sampler_state; + DWORD state; +} +tss_lookup[] = +{ + {FALSE, WINED3DTSS_FORCE_DWORD}, /* 0, unused */ + {FALSE, WINED3DTSS_COLOROP}, /* 1, D3DTSS_COLOROP */ + {FALSE, WINED3DTSS_COLORARG1}, /* 2, D3DTSS_COLORARG1 */ + {FALSE, WINED3DTSS_COLORARG2}, /* 3, D3DTSS_COLORARG2 */ + {FALSE, WINED3DTSS_ALPHAOP}, /* 4, D3DTSS_ALPHAOP */ + {FALSE, WINED3DTSS_ALPHAARG1}, /* 5, D3DTSS_ALPHAARG1 */ + {FALSE, WINED3DTSS_ALPHAARG2}, /* 6, D3DTSS_ALPHAARG2 */ + {FALSE, WINED3DTSS_BUMPENVMAT00}, /* 7, D3DTSS_BUMPENVMAT00 */ + {FALSE, WINED3DTSS_BUMPENVMAT01}, /* 8, D3DTSS_BUMPENVMAT01 */ + {FALSE, WINED3DTSS_BUMPENVMAT10}, /* 9, D3DTSS_BUMPENVMAT10 */ + {FALSE, WINED3DTSS_BUMPENVMAT11}, /* 10, D3DTSS_BUMPENVMAT11 */ + {FALSE, WINED3DTSS_TEXCOORDINDEX}, /* 11, D3DTSS_TEXCOORDINDEX */ + {FALSE, WINED3DTSS_FORCE_DWORD}, /* 12, unused */ + {TRUE, WINED3DSAMP_ADDRESSU}, /* 13, D3DTSS_ADDRESSU */ + {TRUE, WINED3DSAMP_ADDRESSV}, /* 14, D3DTSS_ADDRESSV */ + {TRUE, WINED3DSAMP_BORDERCOLOR}, /* 15, D3DTSS_BORDERCOLOR */ + {TRUE, WINED3DSAMP_MAGFILTER}, /* 16, D3DTSS_MAGFILTER */ + {TRUE, WINED3DSAMP_MINFILTER}, /* 17, D3DTSS_MINFILTER */ + {TRUE, WINED3DSAMP_MIPFILTER}, /* 18, D3DTSS_MIPFILTER */ + {TRUE, WINED3DSAMP_MIPMAPLODBIAS}, /* 19, D3DTSS_MIPMAPLODBIAS */ + {TRUE, WINED3DSAMP_MAXMIPLEVEL}, /* 20, D3DTSS_MAXMIPLEVEL */ + {TRUE, WINED3DSAMP_MAXANISOTROPY}, /* 21, D3DTSS_MAXANISOTROPY */ + {FALSE, WINED3DTSS_BUMPENVLSCALE}, /* 22, D3DTSS_BUMPENVLSCALE */ + {FALSE, WINED3DTSS_BUMPENVLOFFSET}, /* 23, D3DTSS_BUMPENVLOFFSET */ + {FALSE, WINED3DTSS_TEXTURETRANSFORMFLAGS}, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */ + {TRUE, WINED3DSAMP_ADDRESSW}, /* 25, D3DTSS_ADDRESSW */ + {FALSE, WINED3DTSS_COLORARG0}, /* 26, D3DTSS_COLORARG0 */ + {FALSE, WINED3DTSS_ALPHAARG0}, /* 27, D3DTSS_ALPHAARG0 */ + {FALSE, WINED3DTSS_RESULTARG}, /* 28, D3DTSS_RESULTARG */ +}; + static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; + const struct tss_lookup *l = &tss_lookup[Type]; HRESULT hr; TRACE("(%p) Relay\n" , This); - switch(Type) { - case D3DTSS_ADDRESSU: - Type = WINED3DSAMP_ADDRESSU; - break; - case D3DTSS_ADDRESSV: - Type = WINED3DSAMP_ADDRESSV; - break; - case D3DTSS_ADDRESSW: - Type = WINED3DSAMP_ADDRESSW; - break; - case D3DTSS_BORDERCOLOR: - Type = WINED3DSAMP_BORDERCOLOR; - break; - case D3DTSS_MAGFILTER: - Type = WINED3DSAMP_MAGFILTER; - break; - case D3DTSS_MAXANISOTROPY: - Type = WINED3DSAMP_MAXANISOTROPY; - break; - case D3DTSS_MAXMIPLEVEL: - Type = WINED3DSAMP_MAXMIPLEVEL; - break; - case D3DTSS_MINFILTER: - Type = WINED3DSAMP_MINFILTER; - break; - case D3DTSS_MIPFILTER: - Type = WINED3DSAMP_MIPFILTER; - break; - case D3DTSS_MIPMAPLODBIAS: - Type = WINED3DSAMP_MIPMAPLODBIAS; - break; - default: - EnterCriticalSection(&d3d8_cs); - hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue); - LeaveCriticalSection(&d3d8_cs); - return hr; - } - EnterCriticalSection(&d3d8_cs); - hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, Type, pValue); + + if (l->sampler_state) hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, l->state, pValue); + else hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, l->state, pValue); + LeaveCriticalSection(&d3d8_cs); return hr; } static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; + const struct tss_lookup *l = &tss_lookup[Type]; HRESULT hr; TRACE("(%p) Relay\n" , This); - switch(Type) { - case D3DTSS_ADDRESSU: - Type = WINED3DSAMP_ADDRESSU; - break; - case D3DTSS_ADDRESSV: - Type = WINED3DSAMP_ADDRESSV; - break; - case D3DTSS_ADDRESSW: - Type = WINED3DSAMP_ADDRESSW; - break; - case D3DTSS_BORDERCOLOR: - Type = WINED3DSAMP_BORDERCOLOR; - break; - case D3DTSS_MAGFILTER: - Type = WINED3DSAMP_MAGFILTER; - break; - case D3DTSS_MAXANISOTROPY: - Type = WINED3DSAMP_MAXANISOTROPY; - break; - case D3DTSS_MAXMIPLEVEL: - Type = WINED3DSAMP_MAXMIPLEVEL; - break; - case D3DTSS_MINFILTER: - Type = WINED3DSAMP_MINFILTER; - break; - case D3DTSS_MIPFILTER: - Type = WINED3DSAMP_MIPFILTER; - break; - case D3DTSS_MIPMAPLODBIAS: - Type = WINED3DSAMP_MIPMAPLODBIAS; - break; - default: - EnterCriticalSection(&d3d8_cs); - hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value); - LeaveCriticalSection(&d3d8_cs); - return hr; - } - EnterCriticalSection(&d3d8_cs); - hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, Type, Value); + + if (l->sampler_state) hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, l->state, Value); + else hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, l->state, Value); + LeaveCriticalSection(&d3d8_cs); return hr; } diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 9133fad47ae..9eac67b9268 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1008,13 +1008,50 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX ifac return hr; } +static const WINED3DTEXTURESTAGESTATETYPE tss_lookup[] = +{ + WINED3DTSS_FORCE_DWORD, /* 0, unused */ + WINED3DTSS_COLOROP, /* 1, D3DTSS_COLOROP */ + WINED3DTSS_COLORARG1, /* 2, D3DTSS_COLORARG1 */ + WINED3DTSS_COLORARG2, /* 3, D3DTSS_COLORARG2 */ + WINED3DTSS_ALPHAOP, /* 4, D3DTSS_ALPHAOP */ + WINED3DTSS_ALPHAARG1, /* 5, D3DTSS_ALPHAARG1 */ + WINED3DTSS_ALPHAARG2, /* 6, D3DTSS_ALPHAARG2 */ + WINED3DTSS_BUMPENVMAT00, /* 7, D3DTSS_BUMPENVMAT00 */ + WINED3DTSS_BUMPENVMAT01, /* 8, D3DTSS_BUMPENVMAT01 */ + WINED3DTSS_BUMPENVMAT10, /* 9, D3DTSS_BUMPENVMAT10 */ + WINED3DTSS_BUMPENVMAT11, /* 10, D3DTSS_BUMPENVMAT11 */ + WINED3DTSS_TEXCOORDINDEX, /* 11, D3DTSS_TEXCOORDINDEX */ + WINED3DTSS_FORCE_DWORD, /* 12, unused */ + WINED3DTSS_FORCE_DWORD, /* 13, unused */ + WINED3DTSS_FORCE_DWORD, /* 14, unused */ + WINED3DTSS_FORCE_DWORD, /* 15, unused */ + WINED3DTSS_FORCE_DWORD, /* 16, unused */ + WINED3DTSS_FORCE_DWORD, /* 17, unused */ + WINED3DTSS_FORCE_DWORD, /* 18, unused */ + WINED3DTSS_FORCE_DWORD, /* 19, unused */ + WINED3DTSS_FORCE_DWORD, /* 20, unused */ + WINED3DTSS_FORCE_DWORD, /* 21, unused */ + WINED3DTSS_BUMPENVLSCALE, /* 22, D3DTSS_BUMPENVLSCALE */ + WINED3DTSS_BUMPENVLOFFSET, /* 23, D3DTSS_BUMPENVLOFFSET */ + WINED3DTSS_TEXTURETRANSFORMFLAGS, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */ + WINED3DTSS_FORCE_DWORD, /* 25, unused */ + WINED3DTSS_COLORARG0, /* 26, D3DTSS_COLORARG0 */ + WINED3DTSS_ALPHAARG0, /* 27, D3DTSS_ALPHAARG0 */ + WINED3DTSS_RESULTARG, /* 28, D3DTSS_RESULTARG */ + WINED3DTSS_FORCE_DWORD, /* 29, unused */ + WINED3DTSS_FORCE_DWORD, /* 30, unused */ + WINED3DTSS_FORCE_DWORD, /* 31, unused */ + WINED3DTSS_CONSTANT, /* 32, D3DTSS_CONSTANT */ +}; + static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; HRESULT hr; TRACE("(%p) Relay\n" , This); EnterCriticalSection(&d3d9_cs); - hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue); + hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], pValue); LeaveCriticalSection(&d3d9_cs); return hr; } @@ -1025,7 +1062,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVI TRACE("(%p) Relay\n" , This); EnterCriticalSection(&d3d9_cs); - hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value); + hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], Value); LeaveCriticalSection(&d3d9_cs); return hr; } diff --git a/dlls/d3d9/tests/texture.c b/dlls/d3d9/tests/texture.c index 86132b70d51..4d433b13e5e 100644 --- a/dlls/d3d9/tests/texture.c +++ b/dlls/d3d9/tests/texture.c @@ -99,7 +99,6 @@ static void test_texture_stage_states(IDirect3DDevice9 *device_ptr, int num_stag test_texture_stage_state(device_ptr, i, D3DTSS_ALPHAARG0, D3DTA_CURRENT); test_texture_stage_state(device_ptr, i, D3DTSS_RESULTARG, D3DTA_CURRENT); test_texture_stage_state(device_ptr, i, D3DTSS_CONSTANT, 0); - test_texture_stage_state(device_ptr, i, D3DTSS_FORCE_DWORD, 0); } } diff --git a/dlls/d3dxof/parsing.c b/dlls/d3dxof/parsing.c index 06a1385bf06..d4c71d17bcc 100644 --- a/dlls/d3dxof/parsing.c +++ b/dlls/d3dxof/parsing.c @@ -36,10 +36,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dxof); -static const char* get_primitive_string(WORD token); -static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional); -static WORD check_TOKEN(parse_buffer * buf); - #define TOKEN_NAME 1 #define TOKEN_STRING 2 #define TOKEN_INTEGER 3 @@ -74,6 +70,40 @@ static WORD check_TOKEN(parse_buffer * buf); #define CLSIDFMT "<%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X>" +static const char* get_primitive_string(WORD token) +{ + switch(token) + { + case TOKEN_WORD: + return "WORD"; + case TOKEN_DWORD: + return "DWORD"; + case TOKEN_FLOAT: + return "FLOAT"; + case TOKEN_DOUBLE: + return "DOUBLE"; + case TOKEN_CHAR: + return "CHAR"; + case TOKEN_UCHAR: + return "UCHAR"; + case TOKEN_SWORD: + return "SWORD"; + case TOKEN_SDWORD: + return "SDWORD"; + case TOKEN_VOID: + return "VOID"; + case TOKEN_LPSTR: + return "STRING"; + case TOKEN_UNICODE: + return "UNICODE"; + case TOKEN_CSTRING: + return "CSTRING "; + default: + break; + } + return NULL; +} + void dump_template(xtemplate* templates_array, xtemplate* ptemplate) { int j, k; @@ -115,11 +145,6 @@ void dump_template(xtemplate* templates_array, xtemplate* ptemplate) DPRINTF("}\n"); } -BOOL is_template_available(parse_buffer * buf) -{ - return check_TOKEN(buf) == TOKEN_TEMPLATE; -} - BOOL read_bytes(parse_buffer * buf, LPVOID data, DWORD size) { if (buf->rem_bytes < size) @@ -683,40 +708,6 @@ static WORD parse_TOKEN(parse_buffer * buf) return token; } -static const char* get_primitive_string(WORD token) -{ - switch(token) - { - case TOKEN_WORD: - return "WORD"; - case TOKEN_DWORD: - return "DWORD"; - case TOKEN_FLOAT: - return "FLOAT"; - case TOKEN_DOUBLE: - return "DOUBLE"; - case TOKEN_CHAR: - return "CHAR"; - case TOKEN_UCHAR: - return "UCHAR"; - case TOKEN_SWORD: - return "SWORD"; - case TOKEN_SDWORD: - return "SDWORD"; - case TOKEN_VOID: - return "VOID"; - case TOKEN_LPSTR: - return "STRING"; - case TOKEN_UNICODE: - return "UNICODE"; - case TOKEN_CSTRING: - return "CSTRING "; - default: - break; - } - return NULL; -} - static WORD get_TOKEN(parse_buffer * buf) { if (buf->token_present) @@ -741,6 +732,11 @@ static WORD check_TOKEN(parse_buffer * buf) return buf->current_token; } +BOOL is_template_available(parse_buffer * buf) +{ + return check_TOKEN(buf) == TOKEN_TEMPLATE; +} + static inline BOOL is_primitive_type(WORD token) { BOOL ret; @@ -984,6 +980,7 @@ BOOL parse_template(parse_buffer * buf) return TRUE; } +static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional); static BOOL parse_object_members_list(parse_buffer * buf) { DWORD token; diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 7efc66f5261..ab6623a4098 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -4997,6 +4997,40 @@ IDirect3DDeviceImpl_3_SetTexture(IDirect3DDevice3 *iface, return hr; } +static const struct tss_lookup +{ + BOOL sampler_state; + DWORD state; +} +tss_lookup[] = +{ + {FALSE, WINED3DTSS_FORCE_DWORD}, /* 0, unused */ + {FALSE, WINED3DTSS_COLOROP}, /* 1, D3DTSS_COLOROP */ + {FALSE, WINED3DTSS_COLORARG1}, /* 2, D3DTSS_COLORARG1 */ + {FALSE, WINED3DTSS_COLORARG2}, /* 3, D3DTSS_COLORARG2 */ + {FALSE, WINED3DTSS_ALPHAOP}, /* 4, D3DTSS_ALPHAOP */ + {FALSE, WINED3DTSS_ALPHAARG1}, /* 5, D3DTSS_ALPHAARG1 */ + {FALSE, WINED3DTSS_ALPHAARG2}, /* 6, D3DTSS_ALPHAARG2 */ + {FALSE, WINED3DTSS_BUMPENVMAT00}, /* 7, D3DTSS_BUMPENVMAT00 */ + {FALSE, WINED3DTSS_BUMPENVMAT01}, /* 8, D3DTSS_BUMPENVMAT01 */ + {FALSE, WINED3DTSS_BUMPENVMAT10}, /* 9, D3DTSS_BUMPENVMAT10 */ + {FALSE, WINED3DTSS_BUMPENVMAT11}, /* 10, D3DTSS_BUMPENVMAT11 */ + {FALSE, WINED3DTSS_TEXCOORDINDEX}, /* 11, D3DTSS_TEXCOORDINDEX */ + {TRUE, WINED3DSAMP_ADDRESSU}, /* 12, D3DTSS_ADDRESS */ + {TRUE, WINED3DSAMP_ADDRESSU}, /* 13, D3DTSS_ADDRESSU */ + {TRUE, WINED3DSAMP_ADDRESSV}, /* 14, D3DTSS_ADDRESSV */ + {TRUE, WINED3DSAMP_BORDERCOLOR}, /* 15, D3DTSS_BORDERCOLOR */ + {TRUE, WINED3DSAMP_MAGFILTER}, /* 16, D3DTSS_MAGFILTER */ + {TRUE, WINED3DSAMP_MINFILTER}, /* 17, D3DTSS_MINFILTER */ + {TRUE, WINED3DSAMP_MIPFILTER}, /* 18, D3DTSS_MIPFILTER */ + {TRUE, WINED3DSAMP_MIPMAPLODBIAS}, /* 19, D3DTSS_MIPMAPLODBIAS */ + {TRUE, WINED3DSAMP_MAXMIPLEVEL}, /* 20, D3DTSS_MAXMIPLEVEL */ + {TRUE, WINED3DSAMP_MAXANISOTROPY}, /* 21, D3DTSS_MAXANISOTROPY */ + {FALSE, WINED3DTSS_BUMPENVLSCALE}, /* 22, D3DTSS_BUMPENVLSCALE */ + {FALSE, WINED3DTSS_BUMPENVLOFFSET}, /* 23, D3DTSS_BUMPENVLOFFSET */ + {FALSE, WINED3DTSS_TEXTURETRANSFORMFLAGS}, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */ +}; + /***************************************************************************** * IDirect3DDevice7::GetTextureStageState * @@ -5023,85 +5057,63 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface, { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); HRESULT hr; + const struct tss_lookup *l = &tss_lookup[TexStageStateType]; TRACE("(%p)->(%08x,%08x,%p): Relay!\n", This, Stage, TexStageStateType, State); if(!State) return DDERR_INVALIDPARAMS; EnterCriticalSection(&ddraw_cs); - switch(TexStageStateType) + + if (l->sampler_state) { - /* Mipfilter is a sampler state with different values */ - case D3DTSS_MIPFILTER: - { - WINED3DTEXTUREFILTERTYPE value; + hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, Stage, l->state, State); - hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_MIPFILTER, - &value); - switch(value) + switch(TexStageStateType) + { + /* Mipfilter is a sampler state with different values */ + case D3DTSS_MIPFILTER: { - case WINED3DTEXF_NONE: *State = D3DTFP_NONE; break; - case WINED3DTEXF_POINT: *State = D3DTFP_POINT; break; - case WINED3DTEXF_LINEAR: *State = D3DTFP_LINEAR; break; - default: - ERR("Unexpected mipfilter value %d\n", value); - *State = D3DTFP_NONE; + switch(*State) + { + case WINED3DTEXF_NONE: *State = D3DTFP_NONE; break; + case WINED3DTEXF_POINT: *State = D3DTFP_POINT; break; + case WINED3DTEXF_LINEAR: *State = D3DTFP_LINEAR; break; + default: + ERR("Unexpected mipfilter value %#x\n", *State); + *State = D3DTFP_NONE; + break; + } + break; } - break; - } - /* Minfilter is a sampler state too, equal values */ - case D3DTSS_MINFILTER: - hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_MINFILTER, - State); - break; - - /* Magfilter has slightly different values */ - case D3DTSS_MAGFILTER: - { - WINED3DTEXTUREFILTERTYPE wined3dfilter; - hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_MAGFILTER, - &wined3dfilter); - switch(wined3dfilter) + /* Magfilter has slightly different values */ + case D3DTSS_MAGFILTER: { - case WINED3DTEXF_POINT: *State = D3DTFG_POINT; break; - case WINED3DTEXF_LINEAR: *State = D3DTFG_LINEAR; break; - case WINED3DTEXF_ANISOTROPIC: *State = D3DTFG_ANISOTROPIC; break; - case WINED3DTEXF_FLATCUBIC: *State = D3DTFG_FLATCUBIC; break; - case WINED3DTEXF_GAUSSIANCUBIC: *State = D3DTFG_GAUSSIANCUBIC; break; - default: - ERR("Unexpected wined3d mag filter value %d\n", wined3dfilter); - *State = D3DTFG_POINT; + switch(*State) + { + case WINED3DTEXF_POINT: *State = D3DTFG_POINT; break; + case WINED3DTEXF_LINEAR: *State = D3DTFG_LINEAR; break; + case WINED3DTEXF_ANISOTROPIC: *State = D3DTFG_ANISOTROPIC; break; + case WINED3DTEXF_FLATCUBIC: *State = D3DTFG_FLATCUBIC; break; + case WINED3DTEXF_GAUSSIANCUBIC: *State = D3DTFG_GAUSSIANCUBIC; break; + default: + ERR("Unexpected wined3d mag filter value %#x\n", *State); + *State = D3DTFG_POINT; + break; + } + break; } - break; - } - case D3DTSS_ADDRESS: - case D3DTSS_ADDRESSU: - hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_ADDRESSU, - State); - break; - case D3DTSS_ADDRESSV: - hr = IWineD3DDevice_GetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_ADDRESSV, - State); - break; - default: - hr = IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, - Stage, - TexStageStateType, - State); - break; + default: + break; + } } + else + { + hr = IWineD3DDevice_GetTextureStageState(This->wineD3DDevice, Stage, l->state, State); + } + LeaveCriticalSection(&ddraw_cs); return hr; } @@ -5170,90 +5182,66 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface, DWORD State) { ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface); + const struct tss_lookup *l = &tss_lookup[TexStageStateType]; HRESULT hr; TRACE("(%p)->(%08x,%08x,%08x): Relay!\n", This, Stage, TexStageStateType, State); EnterCriticalSection(&ddraw_cs); - switch(TexStageStateType) + + if (l->sampler_state) { - /* Mipfilter is a sampler state with different values */ - case D3DTSS_MIPFILTER: + switch(TexStageStateType) { - WINED3DTEXTUREFILTERTYPE value; - switch(State) + /* Mipfilter is a sampler state with different values */ + case D3DTSS_MIPFILTER: { - case D3DTFP_NONE: value = WINED3DTEXF_NONE; break; - case D3DTFP_POINT: value = WINED3DTEXF_POINT; break; - case 0: /* Unchecked */ - case D3DTFP_LINEAR: value = WINED3DTEXF_LINEAR; break; - default: - ERR("Unexpected mipfilter value %d\n", State); - value = WINED3DTEXF_NONE; + switch(State) + { + case D3DTFP_NONE: State = WINED3DTEXF_NONE; break; + case D3DTFP_POINT: State = WINED3DTEXF_POINT; break; + case 0: /* Unchecked */ + case D3DTFP_LINEAR: State = WINED3DTEXF_LINEAR; break; + default: + ERR("Unexpected mipfilter value %d\n", State); + State = WINED3DTEXF_NONE; + break; + } + break; } - hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_MIPFILTER, - value); - break; - } - /* Minfilter is a sampler state too, equal values */ - case D3DTSS_MINFILTER: - hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_MINFILTER, - State); - break; - - /* Magfilter has slightly different values */ - case D3DTSS_MAGFILTER: - { - WINED3DTEXTUREFILTERTYPE wined3dfilter; - switch((D3DTEXTUREMAGFILTER) State) + /* Magfilter has slightly different values */ + case D3DTSS_MAGFILTER: { - case D3DTFG_POINT: wined3dfilter = WINED3DTEXF_POINT; break; - case D3DTFG_LINEAR: wined3dfilter = WINED3DTEXF_LINEAR; break; - case D3DTFG_FLATCUBIC: wined3dfilter = WINED3DTEXF_FLATCUBIC; break; - case D3DTFG_GAUSSIANCUBIC: wined3dfilter = WINED3DTEXF_GAUSSIANCUBIC; break; - case D3DTFG_ANISOTROPIC: wined3dfilter = WINED3DTEXF_ANISOTROPIC; break; - default: - ERR("Unexpected d3d7 mag filter type %d\n", State); - wined3dfilter = WINED3DTEXF_POINT; + switch(State) + { + case D3DTFG_POINT: State = WINED3DTEXF_POINT; break; + case D3DTFG_LINEAR: State = WINED3DTEXF_LINEAR; break; + case D3DTFG_FLATCUBIC: State = WINED3DTEXF_FLATCUBIC; break; + case D3DTFG_GAUSSIANCUBIC: State = WINED3DTEXF_GAUSSIANCUBIC; break; + case D3DTFG_ANISOTROPIC: State = WINED3DTEXF_ANISOTROPIC; break; + default: + ERR("Unexpected d3d7 mag filter type %d\n", State); + State = WINED3DTEXF_POINT; + break; + } + break; } - hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_MAGFILTER, - wined3dfilter); - break; - } - case D3DTSS_ADDRESS: - IWineD3DDevice_SetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_ADDRESSV, - State); - /* Drop through */ - case D3DTSS_ADDRESSU: - hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_ADDRESSU, - State); - break; + case D3DTSS_ADDRESS: + IWineD3DDevice_SetSamplerState(This->wineD3DDevice, Stage, WINED3DSAMP_ADDRESSV, State); + break; - case D3DTSS_ADDRESSV: - hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, - Stage, - WINED3DSAMP_ADDRESSV, - State); - break; + default: + break; + } - default: - hr = IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, - Stage, - TexStageStateType, - State); - break; + hr = IWineD3DDevice_SetSamplerState(This->wineD3DDevice, Stage, l->state, State); } + else + { + hr = IWineD3DDevice_SetTextureStageState(This->wineD3DDevice, Stage, l->state, State); + } + LeaveCriticalSection(&ddraw_cs); return hr; } diff --git a/dlls/dnsapi/ns_name.c b/dlls/dnsapi/ns_name.c index 98225789fe1..994aef94459 100644 --- a/dlls/dnsapi/ns_name.c +++ b/dlls/dnsapi/ns_name.c @@ -39,10 +39,42 @@ static const char digits[] = "0123456789"; -/* Forward. */ +/* Private. */ -static int special(int); -static int printable(int); +/* + * special(ch) + * Thinking in noninternationalized USASCII (per the DNS spec), + * is this character special ("in need of quoting") ? + * return: + * boolean. + */ +static int +special(int ch) { + switch (ch) { + case 0x22: /* '"' */ + case 0x2E: /* '.' */ + case 0x3B: /* ';' */ + case 0x5C: /* '\\' */ + /* Special modifiers in zone files. */ + case 0x40: /* '@' */ + case 0x24: /* '$' */ + return (1); + default: + return (0); + } +} + +/* + * printable(ch) + * Thinking in noninternationalized USASCII (per the DNS spec), + * is this character visible and not a space when printed ? + * return: + * boolean. + */ +static int +printable(int ch) { + return (ch > 0x20 && ch < 0x7f); +} /* Public. */ @@ -140,135 +172,6 @@ dns_ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) { return (dn - dst); } -/* - * dns_ns_name_pton(src, dst, dstsiz) - * Convert a ascii string into an encoded domain name as per RFC1035. - * return: - * -1 if it fails - * 1 if string was fully qualified - * 0 is string was not fully qualified - * notes: - * Enforces label and domain length limits. - */ - -int -dns_ns_name_pton(const char *src, u_char *dst, size_t dstsiz) { - u_char *label, *bp, *eom; - int c, n, escaped; - char *cp; - - escaped = 0; - bp = dst; - eom = dst + dstsiz; - label = bp++; - - while ((c = *src++) != 0) { - if (escaped) { - if ((cp = strchr(digits, c)) != NULL) { - n = (cp - digits) * 100; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - return (-1); - } - n += (cp - digits) * 10; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - return (-1); - } - n += (cp - digits); - if (n > 255) { - return (-1); - } - c = n; - } else if (c == '[' && label == bp - 1 && *src == 'x') { - /* Theoretically we would have to handle \[o - as well but we do not since we do not need - it internally. */ - *label = 0x41; - label = bp++; - ++src; - while (isxdigit (*src)) { - n = *src > '9' ? *src - 'a' + 10 : *src - '0'; - ++src; - if (! isxdigit(*src)) { - return (-1); - } - n <<= 4; - n += *src > '9' ? *src - 'a' + 10 : *src - '0'; - if (bp + 1 >= eom) { - return (-1); - } - *bp++ = n; - ++src; - } - *label = (bp - label - 1) * 8; - if (*src++ != ']' || *src++ != '.') { - return (-1); - } - escaped = 0; - label = bp++; - if (bp >= eom) { - return (-1); - } - continue; - } - escaped = 0; - } else if (c == '\\') { - escaped = 1; - continue; - } else if (c == '.') { - c = (bp - label - 1); - if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */ - return (-1); - } - if (label >= eom) { - return (-1); - } - *label = c; - /* Fully qualified ? */ - if (*src == '\0') { - if (c != 0) { - if (bp >= eom) { - return (-1); - } - *bp++ = '\0'; - } - if ((bp - dst) > NS_MAXCDNAME) { - return (-1); - } - return (1); - } - if (c == 0 || *src == '.') { - return (-1); - } - label = bp++; - continue; - } - if (bp >= eom) { - return (-1); - } - *bp++ = (u_char)c; - } - c = (bp - label - 1); - if ((c & NS_CMPRSFLGS) != 0) { /* Label too big. */ - return (-1); - } - if (label >= eom) { - return (-1); - } - *label = c; - if (c != 0) { - if (bp >= eom) { - return (-1); - } - *bp++ = 0; - } - if ((bp - dst) > NS_MAXCDNAME) { /* src too big */ - return (-1); - } - return (0); -} - /* * dns_ns_name_unpack(msg, eom, src, dst, dstsiz) @@ -407,41 +310,4 @@ dns_ns_name_skip(const u_char **ptrptr, const u_char *eom) { return (0); } -/* Private. */ - -/* - * special(ch) - * Thinking in noninternationalized USASCII (per the DNS spec), - * is this character special ("in need of quoting") ? - * return: - * boolean. - */ -static int -special(int ch) { - switch (ch) { - case 0x22: /* '"' */ - case 0x2E: /* '.' */ - case 0x3B: /* ';' */ - case 0x5C: /* '\\' */ - /* Special modifiers in zone files. */ - case 0x40: /* '@' */ - case 0x24: /* '$' */ - return (1); - default: - return (0); - } -} - -/* - * printable(ch) - * Thinking in noninternationalized USASCII (per the DNS spec), - * is this character visible and not a space when printed ? - * return: - * boolean. - */ -static int -printable(int ch) { - return (ch > 0x20 && ch < 0x7f); -} - #endif /* HAVE_RESOLV */ diff --git a/dlls/gdi32/dispdib.c b/dlls/gdi32/dispdib.c index 0d46f65bfb7..cc28547a4b6 100644 --- a/dlls/gdi32/dispdib.c +++ b/dlls/gdi32/dispdib.c @@ -29,74 +29,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); -#if 0 - -static int dispdib_multi = 0; - -static WORD DISPDIB_Begin(WORD wFlags) -{ - unsigned Xres,Yres,Depth; - - switch(wFlags&DISPLAYDIB_MODE) { - case DISPLAYDIB_MODE_DEFAULT: - /* FIXME: is this supposed to autodetect? */ - case DISPLAYDIB_MODE_320x200x8: - Xres=320; Yres=200; Depth=8; break; - case DISPLAYDIB_MODE_320x240x8: - Xres=320; Yres=240; Depth=8; break; - default: - return DISPLAYDIB_NOTSUPPORTED; - } - /* more or less dummy calls to Death/Resurrection, for completeness */ - /* FIXME: what arguments should they get? */ - Death16(0); - if (VGA_SetMode(Xres,Yres,Depth)) { - Resurrection16(0,0,0,0,0,0,0); - return DISPLAYDIB_NOTSUPPORTED; - } - return DISPLAYDIB_NOERROR; -} - -static void DISPDIB_End(void) -{ - Resurrection16(0,0,0,0,0,0,0); /* FIXME: arguments */ - VGA_Exit(); -} - -static void DISPDIB_Palette(LPBITMAPINFO lpbi) -{ - VGA_SetQuadPalette(lpbi->bmiColors,0,256); -} - -static void DISPDIB_Show(LPBITMAPINFOHEADER lpbi,LPSTR lpBits,WORD uFlags) -{ - int Xofs,Yofs,Width=lpbi->biWidth,Height=lpbi->biHeight,Delta; - int Pitch = (Width + 3) & ~3; - unsigned int sPitch,sWidth,sHeight; - LPSTR surf = DOSMEM_MapDosToLinear(0xa0000); - - if (VGA_GetMode(&sHeight,&sWidth,NULL)) return; - sPitch=320; - - Delta=(Height<0)*2-1; - Height*=-Delta; Pitch*=Delta; - - if (uFlags&DISPLAYDIB_NOCENTER) { - Xofs=0; Yofs=0; - } else { - Xofs=(sWidth-Width)/2; - Yofs=(sHeight-Height)/2; - } - surf += (Yofs*sPitch)+Xofs; - if (Pitch<0) lpBits-=Pitch*(Height-1); - for (; Height; Height--,lpBits+=Pitch,surf+=sPitch) { - memcpy(surf,lpBits,Width); - } - - VGA_Poll(0); -} -#endif - /********************************************************************* * DisplayDib (DISPDIB.1) @@ -132,31 +64,6 @@ WORD WINAPI DisplayDib( WORD wFlags /* [in] */ ) { -#if 0 - WORD ret; - - if (wFlags&DISPLAYDIB_END) { - if (dispdib_multi) DISPDIB_End(); - dispdib_multi = 0; - return DISPLAYDIB_NOERROR; - } - if (!dispdib_multi) { - ret=DISPDIB_Begin(wFlags); - if (ret) return ret; - } - if (wFlags&DISPLAYDIB_BEGIN) dispdib_multi = 1; - if (!(wFlags&DISPLAYDIB_NOPALETTE)) { - DISPDIB_Palette(lpbi); - } - /* FIXME: not sure if it's valid to draw images in DISPLAYDIB_BEGIN, so... */ - if (lpBits) { - DISPDIB_Show(&(lpbi->bmiHeader),lpBits,wFlags); - } - if (!(wFlags&DISPLAYDIB_NOWAIT)) { - FIXME("wait not implemented\n"); - } - if (!dispdib_multi) DISPDIB_End(); -#endif FIXME( "broken, should be rewritten using ddraw\n" ); return DISPLAYDIB_NOERROR; } diff --git a/dlls/gphoto2.ds/capability.c b/dlls/gphoto2.ds/capability.c index 754e58dd6a8..378ef2a0358 100644 --- a/dlls/gphoto2.ds/capability.c +++ b/dlls/gphoto2.ds/capability.c @@ -195,7 +195,7 @@ static TW_BOOL GPHOTO2_OneValueSet32 (pTW_CAPABILITY pCapability, TW_UINT32 valu { pCapability->hContainer = GlobalAlloc (0, sizeof(TW_ONEVALUE)); - TRACE("-> %ld\n", value); + TRACE("-> %d\n", value); if (pCapability->hContainer) { @@ -258,7 +258,7 @@ static TW_BOOL GPHOTO2_EnumGet16 (pTW_CAPABILITY pCapability, int *nrofvalues, T *nrofvalues = pVal->NumItems; *values = HeapAlloc( GetProcessHeap(), 0, sizeof(TW_UINT16)*pVal->NumItems); memcpy (*values, pVal->ItemList, sizeof(TW_UINT16)*(*nrofvalues)); - FIXME("Current Index %ld, Default Index %ld\n", pVal->CurrentIndex, pVal->DefaultIndex); + FIXME("Current Index %d, Default Index %d\n", pVal->CurrentIndex, pVal->DefaultIndex); GlobalUnlock (pCapability->hContainer); return TRUE; } @@ -310,7 +310,7 @@ static TW_UINT16 GPHOTO2_ICAPXferMech (pTW_CAPABILITY pCapability, TW_UINT16 act if (!GPHOTO2_OneValueGet32 (pCapability, &xfermechtemp)) return TWCC_LOWMEMORY; activeDS.capXferMech = xfermechtemp; - TRACE("xfermech is %ld\n", xfermechtemp); + TRACE("xfermech is %d\n", xfermechtemp); return TWCC_SUCCESS; } else if (pCapability->ConType == TWON_ENUMERATION) diff --git a/dlls/gphoto2.ds/gphoto2_main.c b/dlls/gphoto2.ds/gphoto2_main.c index 8cf1f9dadf6..311abb84a15 100644 --- a/dlls/gphoto2.ds/gphoto2_main.c +++ b/dlls/gphoto2.ds/gphoto2_main.c @@ -343,7 +343,7 @@ static TW_UINT16 GPHOTO2_PendingXfersEndXfer (pTW_IDENTITY pOrigin, if (file->download) count++; } - TRACE("count = %ld\n", count); + TRACE("count = %d\n", count); pPendingXfers->Count = count; if (pPendingXfers->Count != 0) { activeDS.currentState = 6; @@ -379,7 +379,7 @@ static TW_UINT16 GPHOTO2_PendingXfersGet (pTW_IDENTITY pOrigin, if (file->download) count++; } - TRACE("count = %ld\n", count); + TRACE("count = %d\n", count); pPendingXfers->Count = count; activeDS.twCC = TWCC_SUCCESS; return TWRC_SUCCESS; @@ -1002,7 +1002,7 @@ DS_Entry ( pTW_IDENTITY pOrigin, { TW_UINT16 twRC = TWRC_SUCCESS; /* Return Code */ - TRACE("(DG=%ld DAT=%d MSG=%d)\n", DG, DAT, MSG); + TRACE("(DG=%d DAT=%d MSG=%d)\n", DG, DAT, MSG); switch (DG) { diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index b1ee40f36c8..74d71d9c3e5 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -220,7 +220,7 @@ static DWORD convert_candidatelist_AtoW( static IMMThreadData* IMM_GetThreadData(void) { - return (IMMThreadData*)TlsGetValue(tlsIndex); + return TlsGetValue(tlsIndex); } static void IMM_InitThreadData(void) @@ -436,7 +436,7 @@ static HIMCC ImmCreateBlankCompStr(void) HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) { HIMC old = NULL; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p):\n", hWnd, hIMC); @@ -468,7 +468,7 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC) if (old) { - InputContextData *old_data = (InputContextData*)old; + InputContextData *old_data = old; if (old_data->IMC.hWnd == hWnd) old_data->IMC.hWnd = NULL; } @@ -562,7 +562,7 @@ BOOL WINAPI ImmConfigureIMEA( else { REGISTERWORDW rww; - REGISTERWORDA *rwa = (REGISTERWORDA*)lpData; + REGISTERWORDA *rwa = lpData; BOOL rc; rww.lpReading = strdupAtoW(rwa->lpReading); @@ -596,7 +596,7 @@ BOOL WINAPI ImmConfigureIMEW( return immHkl->pImeConfigure(hKL,hWnd,dwMode,lpData); else { - REGISTERWORDW *rww = (REGISTERWORDW*)lpData; + REGISTERWORDW *rww = lpData; REGISTERWORDA rwa; BOOL rc; @@ -665,7 +665,7 @@ HIMC WINAPI ImmCreateContext(void) static BOOL IMM_DestroyContext(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("Destroying %p\n",hIMC); @@ -808,13 +808,13 @@ LRESULT WINAPI ImmEscapeA( LRESULT rc; if (uEscape == IME_ESC_SET_EUDC_DICTIONARY) { - MultiByteToWideChar(CP_ACP,0,(LPSTR)lpData,-1,buffer,81); + MultiByteToWideChar(CP_ACP,0,lpData,-1,buffer,81); rc = immHkl->pImeEscape(hIMC,uEscape,buffer); } else { rc = immHkl->pImeEscape(hIMC,uEscape,buffer); - WideCharToMultiByte(CP_ACP,0,buffer,-1,(LPSTR)lpData,80, NULL, NULL); + WideCharToMultiByte(CP_ACP,0,buffer,-1,lpData,80, NULL, NULL); } return rc; } @@ -843,13 +843,13 @@ LRESULT WINAPI ImmEscapeW( LRESULT rc; if (uEscape == IME_ESC_SET_EUDC_DICTIONARY) { - WideCharToMultiByte(CP_ACP,0,(LPWSTR)lpData,-1,buffer,81, NULL, NULL); + WideCharToMultiByte(CP_ACP,0,lpData,-1,buffer,81, NULL, NULL); rc = immHkl->pImeEscape(hIMC,uEscape,buffer); } else { rc = immHkl->pImeEscape(hIMC,uEscape,buffer); - MultiByteToWideChar(CP_ACP,0,buffer,-1,(LPWSTR)lpData,80); + MultiByteToWideChar(CP_ACP,0,buffer,-1,lpData,80); } return rc; } @@ -865,7 +865,7 @@ DWORD WINAPI ImmGetCandidateListA( HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen) { - InputContextData *data = (InputContextData *)hIMC; + InputContextData *data = hIMC; LPCANDIDATEINFO candinfo; LPCANDIDATELIST candlist; DWORD ret = 0; @@ -904,7 +904,7 @@ done: DWORD WINAPI ImmGetCandidateListCountA( HIMC hIMC, LPDWORD lpdwListCount) { - InputContextData *data = (InputContextData *)hIMC; + InputContextData *data = hIMC; LPCANDIDATEINFO candinfo; DWORD ret, count; @@ -936,7 +936,7 @@ DWORD WINAPI ImmGetCandidateListCountA( DWORD WINAPI ImmGetCandidateListCountW( HIMC hIMC, LPDWORD lpdwListCount) { - InputContextData *data = (InputContextData *)hIMC; + InputContextData *data = hIMC; LPCANDIDATEINFO candinfo; DWORD ret, count; @@ -969,7 +969,7 @@ DWORD WINAPI ImmGetCandidateListW( HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen) { - InputContextData *data = (InputContextData *)hIMC; + InputContextData *data = hIMC; LPCANDIDATEINFO candinfo; LPCANDIDATELIST candlist; DWORD ret = 0; @@ -1008,7 +1008,7 @@ done: BOOL WINAPI ImmGetCandidateWindow( HIMC hIMC, DWORD dwIndex, LPCANDIDATEFORM lpCandidate) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p, %d, %p\n", hIMC, dwIndex, lpCandidate); @@ -1048,7 +1048,7 @@ BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) */ BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p):\n", hIMC, lplf); @@ -1227,7 +1227,7 @@ static LONG ImmGetCompositionStringT( HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen, BOOL unicode) { LONG rc = 0; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; LPCOMPOSITIONSTRING compstr; LPBYTE compdata; @@ -1339,7 +1339,7 @@ LONG WINAPI ImmGetCompositionStringW( */ BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpCompForm); @@ -1370,7 +1370,7 @@ HIMC WINAPI ImmGetContext(HWND hWnd) if (rc) { - InputContextData *data = (InputContextData*)rc; + InputContextData *data = rc; data->IMC.hWnd = hWnd; } TRACE("returning %p\n", rc); @@ -1460,7 +1460,7 @@ DWORD WINAPI ImmGetConversionListW( BOOL WINAPI ImmGetConversionStatus( HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p %p %p\n", hIMC, lpfdwConversion, lpfdwSentence); @@ -1638,7 +1638,7 @@ UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen) */ BOOL WINAPI ImmGetOpenStatus(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; if (!data) return FALSE; @@ -1736,7 +1736,7 @@ UINT WINAPI ImmGetRegisterWordStyleW( */ BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpptPos); @@ -1754,7 +1754,7 @@ BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) UINT WINAPI ImmGetVirtualKey(HWND hWnd) { OSVERSIONINFOA version; - InputContextData *data = (InputContextData *)ImmGetContext( hWnd ); + InputContextData *data = ImmGetContext( hWnd ); TRACE("%p\n", hWnd); if ( data ) @@ -1923,7 +1923,7 @@ BOOL WINAPI ImmIsUIMessageW( BOOL WINAPI ImmNotifyIME( HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %d, %d, %d)\n", hIMC, dwAction, dwIndex, dwValue); @@ -2013,7 +2013,7 @@ BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC) */ LRESULT WINAPI ImmRequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p %ld %ld\n", hIMC, wParam, wParam); @@ -2028,7 +2028,7 @@ LRESULT WINAPI ImmRequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam) */ LRESULT WINAPI ImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p %ld %ld\n", hIMC, wParam, wParam); @@ -2044,7 +2044,7 @@ LRESULT WINAPI ImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam) BOOL WINAPI ImmSetCandidateWindow( HIMC hIMC, LPCANDIDATEFORM lpCandidate) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpCandidate); @@ -2072,7 +2072,7 @@ BOOL WINAPI ImmSetCandidateWindow( */ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lplf); if (!data || !lplf) @@ -2092,7 +2092,7 @@ BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf) */ BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lplf); if (!data || !lplf) @@ -2118,7 +2118,7 @@ BOOL WINAPI ImmSetCompositionStringA( WCHAR *CompBuffer = NULL; WCHAR *ReadBuffer = NULL; BOOL rc; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); @@ -2166,7 +2166,7 @@ BOOL WINAPI ImmSetCompositionStringW( CHAR *CompBuffer = NULL; CHAR *ReadBuffer = NULL; BOOL rc; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen); @@ -2212,7 +2212,7 @@ BOOL WINAPI ImmSetCompositionWindow( HIMC hIMC, LPCOMPOSITIONFORM lpCompForm) { BOOL reshow = FALSE; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpCompForm); TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm->dwStyle, @@ -2246,7 +2246,7 @@ BOOL WINAPI ImmSetConversionStatus( HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence) { DWORD oldConversion, oldSentence; - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p %d %d\n", hIMC, fdwConversion, fdwSentence); @@ -2276,7 +2276,7 @@ BOOL WINAPI ImmSetConversionStatus( */ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%p %d\n", hIMC, fOpen); @@ -2308,7 +2308,7 @@ BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen) */ BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %p)\n", hIMC, lpptPos); @@ -2431,7 +2431,7 @@ DWORD WINAPI ImmGetImeMenuItemsA( HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu, DWORD dwSize) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize); if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) @@ -2495,7 +2495,7 @@ DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize); if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems) @@ -2555,7 +2555,7 @@ DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType, */ LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; if (!data) return NULL; @@ -2568,7 +2568,7 @@ LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC) */ BOOL WINAPI ImmUnlockIMC(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; data->dwLock--; return (data->dwLock!=0); } @@ -2578,7 +2578,7 @@ BOOL WINAPI ImmUnlockIMC(HIMC hIMC) */ DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; return data->dwLock; } @@ -2613,7 +2613,7 @@ HIMCC WINAPI ImmDestroyIMCC(HIMCC block) LPVOID WINAPI ImmLockIMCC(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; internal->dwLock ++; return internal + 1; @@ -2625,7 +2625,7 @@ LPVOID WINAPI ImmLockIMCC(HIMCC imcc) BOOL WINAPI ImmUnlockIMCC(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; internal->dwLock --; return (internal->dwLock!=0); @@ -2637,7 +2637,7 @@ BOOL WINAPI ImmUnlockIMCC(HIMCC imcc) DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; return internal->dwLock; } @@ -2650,7 +2650,7 @@ HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size) IMCCInternal *internal,*newone; int real_size = size + sizeof(IMCCInternal); - internal = (IMCCInternal*) imcc; + internal = imcc; newone = HeapReAlloc(GetProcessHeap(), 0, internal, real_size); newone->dwSize = size; @@ -2664,7 +2664,7 @@ HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size) DWORD WINAPI ImmGetIMCCSize(HIMCC imcc) { IMCCInternal *internal; - internal = (IMCCInternal*) imcc; + internal = imcc; return internal->dwSize; } @@ -2674,7 +2674,7 @@ DWORD WINAPI ImmGetIMCCSize(HIMCC imcc) */ BOOL WINAPI ImmGenerateMessage(HIMC hIMC) { - InputContextData *data = (InputContextData*)hIMC; + InputContextData *data = hIMC; TRACE("%i messages queued\n",data->IMC.dwNumMsgBuf); if (data->IMC.dwNumMsgBuf > 0) @@ -2712,7 +2712,7 @@ BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lKeyD TRACE("%p %x %x %x\n",hwnd, msg, (UINT)wParam, (UINT)lKeyData); if (imc) - data = (InputContextData*)imc; + data = imc; else return FALSE; @@ -2771,7 +2771,7 @@ BOOL WINAPI ImmProcessKey(HWND hwnd, HKL hKL, UINT vKey, LPARAM lKeyData, DWORD TRACE("%p %p %x %x %x\n",hwnd, hKL, vKey, (UINT)lKeyData, unknown); if (imc) - data = (InputContextData*)imc; + data = imc; else return FALSE; diff --git a/dlls/inkobj/inkobj.c b/dlls/inkobj/inkobj.c index 8cddeb729cd..6191d7eb76d 100644 --- a/dlls/inkobj/inkobj.c +++ b/dlls/inkobj/inkobj.c @@ -19,7 +19,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(inkobj); -LONG INKOBJ_refCount = 0; +static LONG INKOBJ_refCount; HINSTANCE INKOBJ_hInstance; /***************************************************** diff --git a/dlls/inkobj/inkobj_internal.h b/dlls/inkobj/inkobj_internal.h index cfd9b5b5638..3a6d8c80351 100644 --- a/dlls/inkobj/inkobj_internal.h +++ b/dlls/inkobj/inkobj_internal.h @@ -30,7 +30,6 @@ #include "wine/debug.h" -extern LONG INKOBJ_refCount; extern HINSTANCE INKOBJ_hInstance; #endif /* INKOBJ_INTERNAL_H */ diff --git a/dlls/iphlpapi/icmp.c b/dlls/iphlpapi/icmp.c index b868603111f..ca965fb0a5b 100644 --- a/dlls/iphlpapi/icmp.c +++ b/dlls/iphlpapi/icmp.c @@ -492,7 +492,7 @@ DWORD WINAPI IcmpSendEcho2( DWORD Timeout ) { - TRACE("(%p, %p, %p, %p, %08lx, %p, %d, %p, %p, %d, %d): stub\n", IcmpHandle, + TRACE("(%p, %p, %p, %p, %08x, %p, %d, %p, %p, %d, %d): stub\n", IcmpHandle, Event, ApcRoutine, ApcContext, DestinationAddress, RequestData, RequestSize, RequestOptions, ReplyBuffer, ReplySize, Timeout); diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index c7a4a3f8eca..f580ca8fcee 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -1550,7 +1550,7 @@ DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterIn */ BOOL WINAPI GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT) { - FIXME("(DestIpAddress 0x%08lx, HopCount %p, MaxHops %d, RTT %p): stub\n", + FIXME("(DestIpAddress 0x%08x, HopCount %p, MaxHops %d, RTT %p): stub\n", DestIpAddress, HopCount, MaxHops, RTT); return FALSE; } @@ -1880,7 +1880,7 @@ DWORD WINAPI NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped) */ DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen) { - FIXME("(DestIP 0x%08lx, SrcIP 0x%08lx, pMacAddr %p, PhyAddrLen %p): stub\n", + FIXME("(DestIP 0x%08x, SrcIP 0x%08x, pMacAddr %p, PhyAddrLen %p): stub\n", DestIP, SrcIP, pMacAddr, PhyAddrLen); return ERROR_NOT_SUPPORTED; } diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 31f47965ce2..86410af4ec7 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -828,7 +828,7 @@ HRESULT jsdisp_call_value(DispatchEx *disp, LCID lcid, WORD flags, DISPPARAMS *d return disp->builtin_info->value_prop.invoke(disp, lcid, flags, dp, retv, ei, caller); } -HRESULT jsdisp_call(DispatchEx *disp, DISPID id, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, +static HRESULT jsdisp_call(DispatchEx *disp, DISPID id, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { dispex_prop_t *prop; diff --git a/dlls/kernel32/debugger.c b/dlls/kernel32/debugger.c index 6e7b4b1a4db..b83647caf06 100644 --- a/dlls/kernel32/debugger.c +++ b/dlls/kernel32/debugger.c @@ -25,7 +25,6 @@ #include "wine/winbase16.h" #include "wine/server.h" #include "kernel_private.h" -#include "kernel16_private.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(debugstr); @@ -409,24 +408,6 @@ BOOL WINAPI CheckRemoteDebuggerPresent(HANDLE process, PBOOL DebuggerPresent) } /*********************************************************************** - * _DebugOutput (KERNEL.328) - */ -void WINAPIV _DebugOutput( WORD flags, LPCSTR spec, VA_LIST16 valist ) -{ - char caller[101]; - - /* Decode caller address */ - if (!GetModuleName16( GetExePtr(CURRENT_STACK16->cs), caller, sizeof(caller) )) - sprintf( caller, "%04X:%04X", CURRENT_STACK16->cs, CURRENT_STACK16->ip ); - - /* FIXME: cannot use wvsnprintf16 from kernel */ - /* wvsnprintf16( temp, sizeof(temp), spec, valist ); */ - - /* Output */ - FIXME("%s %04x %s\n", caller, flags, debugstr_a(spec) ); -} - -/*********************************************************************** * DebugSetProcessKillOnExit (KERNEL32.@) * * Let a debugger decide whether a debuggee will be killed upon debugger diff --git a/dlls/kernel32/instr.c b/dlls/kernel32/instr.c index 73edf7b756d..7fdc4cd6cab 100644 --- a/dlls/kernel32/instr.c +++ b/dlls/kernel32/instr.c @@ -23,6 +23,8 @@ #include "config.h" #include "wine/port.h" +#ifdef __i386__ + #include #include "windef.h" @@ -928,3 +930,5 @@ FARPROC16 WINAPI GetSetKernelDOSProc16( FARPROC16 DosProc ) FIXME("(DosProc=%p): stub\n", DosProc); return NULL; } + +#endif /* __i386__ */ diff --git a/dlls/kernel32/kernel16.c b/dlls/kernel32/kernel16.c index 7ae378d9e4d..b90405797ca 100644 --- a/dlls/kernel32/kernel16.c +++ b/dlls/kernel32/kernel16.c @@ -19,6 +19,7 @@ */ #include +#include #include "windef.h" #include "winbase.h" @@ -264,3 +265,21 @@ void WINAPI WINHELP_EntryPoint( CONTEXT86 *context ) HeapFree( GetProcessHeap(), 0, cmdline ); ExitThread( exit_code ); } + +/*********************************************************************** + * _DebugOutput (KERNEL.328) + */ +void WINAPIV _DebugOutput( WORD flags, LPCSTR spec, VA_LIST16 valist ) +{ + char caller[101]; + + /* Decode caller address */ + if (!GetModuleName16( GetExePtr(CURRENT_STACK16->cs), caller, sizeof(caller) )) + sprintf( caller, "%04X:%04X", CURRENT_STACK16->cs, CURRENT_STACK16->ip ); + + /* FIXME: cannot use wvsnprintf16 from kernel */ + /* wvsnprintf16( temp, sizeof(temp), spec, valist ); */ + + /* Output */ + FIXME("%s %04x %s\n", caller, flags, debugstr_a(spec) ); +} diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 32e352361c5..d02f6e3b753 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -40,27 +40,27 @@ 30 stdcall -noname GlobalUnWire16(long) 31 stdcall -noname GlobalFree16(long) 32 stdcall -noname GlobalSize16(long) - 33 stdcall -noname HouseCleanLogicallyDeadHandles() - 34 stdcall -noname GetWin16DOSEnv() + 33 stdcall -noname -i386 HouseCleanLogicallyDeadHandles() + 34 stdcall -noname -i386 GetWin16DOSEnv() 35 stdcall -noname LoadLibrary16(str) 36 stdcall -noname FreeLibrary16(long) 37 stdcall -noname GetProcAddress16(long str) WIN32_GetProcAddress16 38 stdcall -noname -i386 -register AllocMappedBuffer() 39 stdcall -noname -i386 -register FreeMappedBuffer() 40 stdcall -noname -i386 -register OT_32ThkLSF() - 41 stdcall -noname ThunkInitLSF(long str long str str) + 41 stdcall -noname -i386 ThunkInitLSF(long str long str str) 42 stdcall -noname -i386 -register LogApiThkLSF(str) - 43 stdcall -noname ThunkInitLS(long str long str str) + 43 stdcall -noname -i386 ThunkInitLS(long str long str str) 44 stdcall -noname -i386 -register LogApiThkSL(str) 45 stdcall -noname -i386 -register Common32ThkLS() - 46 stdcall -noname ThunkInitSL(long str long str str) + 46 stdcall -noname -i386 ThunkInitSL(long str long str str) 47 stdcall -noname -i386 -register LogCBThkSL(str) 48 stdcall -noname ReleaseThunkLock(ptr) 49 stdcall -noname RestoreThunkLock(long) 51 stdcall -noname -i386 -register W32S_BackTo32() - 52 stdcall -noname GetThunkBuff() - 53 stdcall -noname GetThunkStuff(str str) + 52 stdcall -noname -i386 GetThunkBuff() + 53 stdcall -noname -i386 GetThunkStuff(str str) 54 stdcall -noname K32WOWCallback16(long long) 55 stdcall -noname K32WOWCallback16Ex(ptr long long ptr ptr) 56 stdcall -noname K32WOWGetVDMPointer(long long long) @@ -94,20 +94,20 @@ 84 stdcall -noname -ret64 K32RtlConvertLongToLargeInteger(long) ntdll.RtlConvertLongToLargeInteger 85 stdcall -noname -ret64 K32RtlConvertUlongToLargeInteger(long) ntdll.RtlConvertUlongToLargeInteger 86 stdcall @(ptr) _KERNEL32_86 - 87 stdcall -noname SSOnBigStack() - 88 varargs -noname SSCall(long long ptr) + 87 stdcall -noname -i386 SSOnBigStack() + 88 varargs -noname -i386 SSCall(long long ptr) 89 stdcall -noname -i386 -register FT_PrologPrime() 90 stdcall -noname -i386 -register QT_ThunkPrime() - 91 stdcall -noname PK16FNF(ptr) - 92 stdcall -noname GetPK16SysVar() + 91 stdcall -noname -i386 PK16FNF(ptr) + 92 stdcall -noname -i386 GetPK16SysVar() 93 stdcall -noname GetpWin16Lock(ptr) 94 stdcall -noname _CheckNotSysLevel(ptr) 95 stdcall -noname _ConfirmSysLevel(ptr) 96 stdcall -noname _ConfirmWin16Lock() 97 stdcall -noname _EnterSysLevel(ptr) 98 stdcall -noname _LeaveSysLevel(ptr) - 99 stdcall @(long) _KERNEL32_99 -100 stdcall @(long long long) _KERNEL32_100 + 99 stdcall -i386 @(long) _KERNEL32_99 +100 stdcall -i386 @(long long long) _KERNEL32_100 101 stub @ 102 stub @ 103 stub @ @@ -143,8 +143,8 @@ @ stdcall AddRefActCtx(ptr) @ stdcall AddVectoredExceptionHandler(long ptr) ntdll.RtlAddVectoredExceptionHandler @ stdcall AllocConsole() -@ stub AllocLSCallback -@ stdcall AllocSLCallback(ptr ptr) +@ stub -i386 AllocLSCallback +@ stdcall -i386 AllocSLCallback(ptr ptr) @ stub AllocateUserPhysicalPages @ stdcall AreFileApisANSI() @ stdcall AssignProcessToJobObject(ptr ptr) @@ -415,11 +415,11 @@ @ stdcall FreeLibrary(long) @ stdcall FreeLibraryAndExitThread(long long) @ stdcall FreeResource(long) -@ stdcall FreeSLCallback(long) +@ stdcall -i386 FreeSLCallback(long) @ stub FreeUserPhysicalPages @ stub FreeVirtualBuffer @ stdcall GenerateConsoleCtrlEvent(long long) -@ stdcall Get16DLLAddress(long str) +@ stdcall -i386 Get16DLLAddress(long str) @ stdcall GetACP() @ stdcall GetAtomNameA(long ptr long) @ stdcall GetAtomNameW(long ptr long) @@ -1082,7 +1082,7 @@ @ stdcall TermsrvAppInstallMode() @ stdcall Thread32First(long ptr) @ stdcall Thread32Next(long ptr) -@ stdcall ThunkConnect32(ptr str str str ptr ptr) +@ stdcall -i386 ThunkConnect32(ptr str str str ptr ptr) @ stdcall TlsAlloc() @ stub TlsAllocInternal @ stdcall TlsFree(long) @@ -1095,8 +1095,8 @@ @ stub TrimVirtualBuffer @ stdcall TryEnterCriticalSection(ptr) ntdll.RtlTryEnterCriticalSection @ stdcall TzSpecificLocalTimeToSystemTime(ptr ptr ptr) -@ stdcall UTRegister(long str str str ptr ptr ptr) -@ stdcall UTUnRegister(long) +@ stdcall -i386 UTRegister(long str str str ptr ptr ptr) +@ stdcall -i386 UTUnRegister(long) @ stdcall UnMapLS(long) @ stdcall -i386 -norelay UnMapSLFixArray(long long) @ stdcall UnhandledExceptionFilter(ptr) @@ -1251,10 +1251,10 @@ # or 'wine_' (for user-visible functions) to avoid namespace conflicts. # 16-bit relays -@ cdecl __wine_dll_register_16(ptr str) -@ cdecl __wine_dll_unregister_16(ptr) -@ varargs -private __wine_call_from_16_regs() -@ cdecl __wine_emulate_instruction(ptr ptr) +@ cdecl -i386 __wine_dll_register_16(ptr str) +@ cdecl -i386 __wine_dll_unregister_16(ptr) +@ varargs -i386 -private __wine_call_from_16_regs() +@ cdecl -i386 __wine_emulate_instruction(ptr ptr) # Unix files @ cdecl wine_get_unix_file_name(wstr) diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h index 18d71b59ee6..b23aedfc13f 100644 --- a/dlls/kernel32/kernel_private.h +++ b/dlls/kernel32/kernel_private.h @@ -146,12 +146,12 @@ extern HANDLE get_BaseNamedObjects_handle(void); /* Register functions */ #ifdef __i386__ -#define DEFINE_REGS_ENTRYPOINT( name, args, pop_args ) \ +#define DEFINE_REGS_ENTRYPOINT( name, args ) \ __ASM_GLOBAL_FUNC( name, \ - "pushl %eax\n\t" \ - "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \ - ".long " __ASM_NAME("__regs_") #name "-.\n\t" \ - ".byte " #args "," #pop_args ) + ".byte 0x68\n\t" /* pushl $__regs_func */ \ + ".long " __ASM_NAME("__regs_") #name "-.-11\n\t" \ + ".byte 0x6a," #args "\n\t" /* pushl $args */ \ + "call " __ASM_NAME("__wine_call_from_32_regs")) #endif #endif diff --git a/dlls/kernel32/relay16.c b/dlls/kernel32/relay16.c index e34eb367679..a2a550cc23f 100644 --- a/dlls/kernel32/relay16.c +++ b/dlls/kernel32/relay16.c @@ -20,6 +20,8 @@ #include "config.h" #include "wine/port.h" +#ifdef __i386__ + #include #include #include @@ -38,8 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(relay); -#ifdef __i386__ - static const WCHAR **debug_relay_excludelist; static const WCHAR **debug_relay_includelist; static const WCHAR **debug_snoop_excludelist; @@ -569,25 +569,4 @@ int relay_call_from_16( void *entry_point, unsigned char *args16, CONTEXT86 *con return ret_val; } -#else /* __i386__ */ - -/* - * Stubs for the CallTo16/CallFrom16 routines on non-Intel architectures - * (these will never be called but need to be present to satisfy the linker ...) - */ - -/*********************************************************************** - * __wine_call_from_16_regs (KERNEL32.@) - */ -void __wine_call_from_16_regs(void) -{ - assert( FALSE ); -} - -DWORD WINAPI CALL32_CBClient( FARPROC proc, LPWORD args, DWORD *esi ) -{ assert( FALSE ); } - -DWORD WINAPI CALL32_CBClientEx( FARPROC proc, LPWORD args, DWORD *esi, INT *nArgs ) -{ assert( FALSE ); } - #endif /* __i386__ */ diff --git a/dlls/kernel32/thunk.c b/dlls/kernel32/thunk.c index 29093dec307..1f946979349 100644 --- a/dlls/kernel32/thunk.c +++ b/dlls/kernel32/thunk.c @@ -31,6 +31,8 @@ # include #endif +#ifdef __i386__ + #include "windef.h" #include "winbase.h" #include "winerror.h" @@ -147,11 +149,7 @@ struct SLApiDB SEGPTR CALL32_CBClient_RetAddr = 0; SEGPTR CALL32_CBClientEx_RetAddr = 0; -#ifdef __i386__ extern void __wine_call_from_16_thunk(); -#else -static void __wine_call_from_16_thunk() { } -#endif /* Push a DWORD on the 32-bit stack */ static inline void stack32_push( CONTEXT86 *context, DWORD val ) @@ -191,9 +189,7 @@ void WINAPI __regs_LogApiThkLSF( LPSTR func, CONTEXT86 *context ) { TRACE( "%s\n", debugstr_a(func) ); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( LogApiThkLSF, 4, 4 ) -#endif +DEFINE_REGS_ENTRYPOINT( LogApiThkLSF, 1 ) /*********************************************************************** * LogApiThkSL (KERNEL32.44) @@ -204,9 +200,7 @@ void WINAPI __regs_LogApiThkSL( LPSTR func, CONTEXT86 *context ) { TRACE( "%s\n", debugstr_a(func) ); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( LogApiThkSL, 4, 4 ) -#endif +DEFINE_REGS_ENTRYPOINT( LogApiThkSL, 1 ) /*********************************************************************** * LogCBThkSL (KERNEL32.47) @@ -217,9 +211,7 @@ void WINAPI __regs_LogCBThkSL( LPSTR func, CONTEXT86 *context ) { TRACE( "%s\n", debugstr_a(func) ); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( LogCBThkSL, 4, 4 ) -#endif +DEFINE_REGS_ENTRYPOINT( LogCBThkSL, 1 ) /*********************************************************************** * Generates a FT_Prolog call. @@ -486,9 +478,7 @@ void WINAPI __regs_QT_Thunk( CONTEXT86 *context ) context->Esp += LOWORD(context16.Esp) - ( OFFSETOF(NtCurrentTeb()->WOW32Reserved) - argsize ); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( QT_Thunk, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( QT_Thunk, 0 ) /********************************************************************** @@ -554,9 +544,7 @@ void WINAPI __regs_FT_Prolog( CONTEXT86 *context ) *(DWORD *)(context->Ebp - 48) = context->Eax; *(DWORD *)(context->Ebp - 52) = context->Edx; } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( FT_Prolog, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( FT_Prolog, 0 ) /********************************************************************** * FT_Thunk (KERNEL32.@) @@ -622,11 +610,7 @@ void WINAPI __regs_FT_Thunk( CONTEXT86 *context ) /* Copy modified buffers back to 32-bit stack */ memcpy( oldstack, newstack, argsize ); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( FT_Thunk, 0, 0 ) -#endif - -#ifdef __i386__ +DEFINE_REGS_ENTRYPOINT( FT_Thunk, 0 ) /*********************************************************************** * FT_Exit0 (KERNEL32.@) @@ -679,8 +663,6 @@ DEFINE_FT_Exit(48) DEFINE_FT_Exit(52) DEFINE_FT_Exit(56) -#endif /* __i386__ */ - /*********************************************************************** * ThunkInitLS (KERNEL32.43) @@ -778,9 +760,7 @@ void WINAPI __regs_Common32ThkLS( CONTEXT86 *context ) /* Clean up caller's stack frame */ context->Esp += LOBYTE(context16.Ebx); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( Common32ThkLS, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( Common32ThkLS, 0 ) /*********************************************************************** * OT_32ThkLSF (KERNEL32.40) @@ -835,9 +815,7 @@ void WINAPI __regs_OT_32ThkLSF( CONTEXT86 *context ) context->Esp += LOWORD(context16.Esp) - ( OFFSETOF(NtCurrentTeb()->WOW32Reserved) - argsize ); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( OT_32ThkLSF, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( OT_32ThkLSF, 0 ) /*********************************************************************** * ThunkInitLSF (KERNEL32.41) @@ -937,9 +915,7 @@ void WINAPI __regs_FT_PrologPrime( CONTEXT86 *context ) /* Jump to the call stub just created */ context->Eip = (DWORD)relayCode; } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( FT_PrologPrime, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( FT_PrologPrime, 0 ) /*********************************************************************** * QT_ThunkPrime (KERNEL32.90) @@ -969,9 +945,7 @@ void WINAPI __regs_QT_ThunkPrime( CONTEXT86 *context ) /* Jump to the call stub just created */ context->Eip = (DWORD)relayCode; } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( QT_ThunkPrime, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( QT_ThunkPrime, 0 ) /*********************************************************************** * ThunkInitSL (KERNEL32.46) @@ -1112,9 +1086,7 @@ void WINAPI __regs_W32S_BackTo32( CONTEXT86 *context ) context->Eip = stack32_pop(context); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( W32S_BackTo32, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( W32S_BackTo32, 0 ) /********************************************************************** * AllocSLCallback (KERNEL32.@) @@ -1229,9 +1201,7 @@ void WINAPI __regs_AllocMappedBuffer( context->Edi = (DWORD)(buffer + 2); } } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( AllocMappedBuffer, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( AllocMappedBuffer, 0 ) /********************************************************************** * FreeMappedBuffer (KERNEL32.39) @@ -1254,9 +1224,7 @@ void WINAPI __regs_FreeMappedBuffer( GlobalFree((HGLOBAL)buffer[0]); } } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( FreeMappedBuffer, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( FreeMappedBuffer, 0 ) /********************************************************************** * GetTEBSelectorFS (KERNEL.475) @@ -1362,9 +1330,7 @@ void WINAPI __regs_K32Thk1632Prolog( CONTEXT86 *context ) been called. Thus we re-use it to hold the Win16Lock count */ ReleaseThunkLock(&CURRENT_STACK16->entry_point); } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( K32Thk1632Prolog, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( K32Thk1632Prolog, 0 ) /*********************************************************************** * K32Thk1632Epilog (KERNEL32.@) @@ -1399,9 +1365,7 @@ void WINAPI __regs_K32Thk1632Epilog( CONTEXT86 *context ) context->Ebp, context->Esp, NtCurrentTeb()->WOW32Reserved); } } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( K32Thk1632Epilog, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( K32Thk1632Epilog, 0 ) /********************************************************************* * PK16FNF [KERNEL32.91] @@ -2211,9 +2175,7 @@ void WINAPI __regs_CommonUnimpStub( CONTEXT86 *context ) context->Esp += (context->Ecx & 0x0f) * 4; } -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( CommonUnimpStub, 0, 0 ) -#endif +DEFINE_REGS_ENTRYPOINT( CommonUnimpStub, 0 ) /********************************************************************** * HouseCleanLogicallyDeadHandles (KERNEL32.33) @@ -2326,3 +2288,235 @@ void WINAPI Throw16( LPCATCHBUF lpbuf, INT16 retval, CONTEXT86 *context ) if (lpbuf[8] != context->SegSs) ERR("Switching stack segment with Throw() not supported; expect crash now\n" ); } + + +/* + * 16-bit WOW routines (in KERNEL) + */ + +/********************************************************************** + * GetVDMPointer32W (KERNEL.516) + */ +DWORD WINAPI GetVDMPointer32W16( SEGPTR vp, UINT16 fMode ) +{ + GlobalPageLock16(GlobalHandle16(SELECTOROF(vp))); + return (DWORD)K32WOWGetVDMPointer( vp, 0, (DWORD)fMode ); +} + +/*********************************************************************** + * LoadLibraryEx32W (KERNEL.513) + */ +DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags ) +{ + HMODULE hModule; + DWORD mutex_count; + OFSTRUCT ofs; + const char *p; + + if (!lpszLibFile) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + /* if the file cannot be found, call LoadLibraryExA anyway, since it might be + a builtin module. This case is handled in MODULE_LoadLibraryExA */ + + if ((p = strrchr( lpszLibFile, '.' )) && !strchr( p, '\\' )) /* got an extension */ + { + if (OpenFile16( lpszLibFile, &ofs, OF_EXIST ) != HFILE_ERROR16) + lpszLibFile = ofs.szPathName; + } + else + { + char buffer[MAX_PATH+4]; + strcpy( buffer, lpszLibFile ); + strcat( buffer, ".dll" ); + if (OpenFile16( buffer, &ofs, OF_EXIST ) != HFILE_ERROR16) + lpszLibFile = ofs.szPathName; + } + + ReleaseThunkLock( &mutex_count ); + hModule = LoadLibraryExA( lpszLibFile, (HANDLE)hFile, dwFlags ); + RestoreThunkLock( mutex_count ); + + return (DWORD)hModule; +} + +/*********************************************************************** + * GetProcAddress32W (KERNEL.515) + */ +DWORD WINAPI GetProcAddress32W16( DWORD hModule, LPCSTR lpszProc ) +{ + return (DWORD)GetProcAddress( (HMODULE)hModule, lpszProc ); +} + +/*********************************************************************** + * FreeLibrary32W (KERNEL.514) + */ +DWORD WINAPI FreeLibrary32W16( DWORD hLibModule ) +{ + BOOL retv; + DWORD mutex_count; + + ReleaseThunkLock( &mutex_count ); + retv = FreeLibrary( (HMODULE)hLibModule ); + RestoreThunkLock( mutex_count ); + return (DWORD)retv; +} + + +#define CPEX_DEST_STDCALL 0x00000000 +#define CPEX_DEST_CDECL 0x80000000 + +/********************************************************************** + * WOW_CallProc32W + */ +static DWORD WOW_CallProc32W16( FARPROC proc32, DWORD nrofargs, DWORD *args ) +{ + DWORD ret; + DWORD mutex_count; + + ReleaseThunkLock( &mutex_count ); + + /* + * FIXME: If ( nrofargs & CPEX_DEST_CDECL ) != 0, we should call a + * 32-bit CDECL routine ... + */ + + if (!proc32) ret = 0; + else switch (nrofargs) + { + case 0: ret = proc32(); + break; + case 1: ret = proc32(args[0]); + break; + case 2: ret = proc32(args[0],args[1]); + break; + case 3: ret = proc32(args[0],args[1],args[2]); + break; + case 4: ret = proc32(args[0],args[1],args[2],args[3]); + break; + case 5: ret = proc32(args[0],args[1],args[2],args[3],args[4]); + break; + case 6: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5]); + break; + case 7: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6]); + break; + case 8: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]); + break; + case 9: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]); + break; + case 10:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]); + break; + case 11:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]); + break; + case 12:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11]); + break; + case 13:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]); + break; + case 14:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13]); + break; + case 15:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13],args[14]); + break; + default: + /* FIXME: should go up to 32 arguments */ + ERR("Unsupported number of arguments %d, please report.\n",nrofargs); + ret = 0; + break; + } + + RestoreThunkLock( mutex_count ); + + TRACE("returns %08x\n",ret); + return ret; +} + +/********************************************************************** + * CallProc32W (KERNEL.517) + */ +DWORD WINAPIV CallProc32W16( DWORD nrofargs, DWORD argconvmask, FARPROC proc32, VA_LIST16 valist ) +{ + DWORD args[32]; + unsigned int i; + + TRACE("(%d,%d,%p args[",nrofargs,argconvmask,proc32); + + for (i=0;i #include "wine/winbase16.h" @@ -323,3 +325,5 @@ WORD WINAPI UTInit16( DWORD x1, DWORD x2, DWORD x3, DWORD x4 ) FIXME("(%08x, %08x, %08x, %08x): stub\n", x1, x2, x3, x4 ); return 0; } + +#endif /* __i386__ */ diff --git a/dlls/kernel32/vxd.c b/dlls/kernel32/vxd.c index 1ce1060a762..92ad24238de 100644 --- a/dlls/kernel32/vxd.c +++ b/dlls/kernel32/vxd.c @@ -297,7 +297,7 @@ void WINAPI __regs_VxDCall( DWORD service, CONTEXT86 *context ) } } #ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( VxDCall, 4, 4 ) +DEFINE_REGS_ENTRYPOINT( VxDCall, 1 ) #endif diff --git a/dlls/kernel32/wowthunk.c b/dlls/kernel32/wowthunk.c index e7560ecc87f..75351b6e5d4 100644 --- a/dlls/kernel32/wowthunk.c +++ b/dlls/kernel32/wowthunk.c @@ -39,22 +39,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(thunk); -/* - * These are the 16-bit side WOW routines. They reside in wownt16.h - * in the SDK; since we don't support Win16 source code anyway, I've - * placed them here for compilation with Wine ... - */ - -DWORD WINAPI GetVDMPointer32W16(SEGPTR,UINT16); - -DWORD WINAPI LoadLibraryEx32W16(LPCSTR,DWORD,DWORD); -DWORD WINAPI GetProcAddress32W16(DWORD,LPCSTR); -DWORD WINAPI FreeLibrary32W16(DWORD); - -#define CPEX_DEST_STDCALL 0x00000000L -#define CPEX_DEST_CDECL 0x80000000L - - #ifdef __i386__ WINE_DECLARE_DEBUG_CHANNEL(relay); @@ -711,230 +695,3 @@ DWORD WINAPI K32WOWCallback16( DWORD vpfn16, DWORD dwParam ) return ret; } - - -/* - * 16-bit WOW routines (in KERNEL) - */ - -/********************************************************************** - * GetVDMPointer32W (KERNEL.516) - */ -DWORD WINAPI GetVDMPointer32W16( SEGPTR vp, UINT16 fMode ) -{ - GlobalPageLock16(GlobalHandle16(SELECTOROF(vp))); - return (DWORD)K32WOWGetVDMPointer( vp, 0, (DWORD)fMode ); -} - -/*********************************************************************** - * LoadLibraryEx32W (KERNEL.513) - */ -DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags ) -{ - HMODULE hModule; - DWORD mutex_count; - OFSTRUCT ofs; - const char *p; - - if (!lpszLibFile) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - /* if the file cannot be found, call LoadLibraryExA anyway, since it might be - a builtin module. This case is handled in MODULE_LoadLibraryExA */ - - if ((p = strrchr( lpszLibFile, '.' )) && !strchr( p, '\\' )) /* got an extension */ - { - if (OpenFile16( lpszLibFile, &ofs, OF_EXIST ) != HFILE_ERROR16) - lpszLibFile = ofs.szPathName; - } - else - { - char buffer[MAX_PATH+4]; - strcpy( buffer, lpszLibFile ); - strcat( buffer, ".dll" ); - if (OpenFile16( buffer, &ofs, OF_EXIST ) != HFILE_ERROR16) - lpszLibFile = ofs.szPathName; - } - - ReleaseThunkLock( &mutex_count ); - hModule = LoadLibraryExA( lpszLibFile, (HANDLE)hFile, dwFlags ); - RestoreThunkLock( mutex_count ); - - return (DWORD)hModule; -} - -/*********************************************************************** - * GetProcAddress32W (KERNEL.515) - */ -DWORD WINAPI GetProcAddress32W16( DWORD hModule, LPCSTR lpszProc ) -{ - return (DWORD)GetProcAddress( (HMODULE)hModule, lpszProc ); -} - -/*********************************************************************** - * FreeLibrary32W (KERNEL.514) - */ -DWORD WINAPI FreeLibrary32W16( DWORD hLibModule ) -{ - BOOL retv; - DWORD mutex_count; - - ReleaseThunkLock( &mutex_count ); - retv = FreeLibrary( (HMODULE)hLibModule ); - RestoreThunkLock( mutex_count ); - return (DWORD)retv; -} - - -/********************************************************************** - * WOW_CallProc32W - */ -static DWORD WOW_CallProc32W16( FARPROC proc32, DWORD nrofargs, DWORD *args ) -{ - DWORD ret; - DWORD mutex_count; - - ReleaseThunkLock( &mutex_count ); - - /* - * FIXME: If ( nrofargs & CPEX_DEST_CDECL ) != 0, we should call a - * 32-bit CDECL routine ... - */ - - if (!proc32) ret = 0; - else switch (nrofargs) - { - case 0: ret = proc32(); - break; - case 1: ret = proc32(args[0]); - break; - case 2: ret = proc32(args[0],args[1]); - break; - case 3: ret = proc32(args[0],args[1],args[2]); - break; - case 4: ret = proc32(args[0],args[1],args[2],args[3]); - break; - case 5: ret = proc32(args[0],args[1],args[2],args[3],args[4]); - break; - case 6: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5]); - break; - case 7: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6]); - break; - case 8: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]); - break; - case 9: ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]); - break; - case 10:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]); - break; - case 11:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]); - break; - case 12:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11]); - break; - case 13:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]); - break; - case 14:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13]); - break; - case 15:ret = proc32(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13],args[14]); - break; - default: - /* FIXME: should go up to 32 arguments */ - ERR("Unsupported number of arguments %d, please report.\n",nrofargs); - ret = 0; - break; - } - - RestoreThunkLock( mutex_count ); - - TRACE("returns %08x\n",ret); - return ret; -} - -/********************************************************************** - * CallProc32W (KERNEL.517) - */ -DWORD WINAPIV CallProc32W16( DWORD nrofargs, DWORD argconvmask, FARPROC proc32, VA_LIST16 valist ) -{ - DWORD args[32]; - unsigned int i; - - TRACE("(%d,%d,%p args[",nrofargs,argconvmask,proc32); - - for (i=0;i + +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "winnls.h" +#include "wine/debug.h" + +#include "loadperf.h" + +WINE_DEFAULT_DEBUG_CHANNEL(loadperf); + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + TRACE("(0x%p, %d, %p)\n",hinstDLL,fdwReason,lpvReserved); + + switch(fdwReason) + { + case DLL_WINE_PREATTACH: + return FALSE; /* prefer native version */ + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + break; + case DLL_PROCESS_DETACH: + break; + } + + return TRUE; +} + +/************************************************************* + * UnloadPerfCounterTextStringsA (loadperf.@) + * + * NOTES + * See UnloadPerfCounterTextStringsW + */ +DWORD WINAPI UnloadPerfCounterTextStringsA(LPCSTR cmdline, BOOL verbose) +{ + DWORD ret; + LPWSTR cmdlineW = NULL; + + if (cmdline) + { + INT len = MultiByteToWideChar(CP_ACP, 0, cmdline, -1, NULL, 0); + cmdlineW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (!cmdlineW) return ERROR_NOT_ENOUGH_MEMORY; + MultiByteToWideChar(CP_ACP, 0, cmdline, -1, cmdlineW, len); + } + + ret = UnloadPerfCounterTextStringsW(cmdlineW, verbose); + + HeapFree(GetProcessHeap(), 0, cmdlineW); + + return ret; +} + +/************************************************************* + * UnloadPerfCounterTextStringsW (loadperf.@) + * + * PARAMS + * cmdline [in] Last argument in command line - application counters to be removed + * verbose [in] TRUE - the function may write to stdout + * + */ +DWORD WINAPI UnloadPerfCounterTextStringsW(LPCWSTR cmdline, BOOL verbose) +{ + FIXME("(%s, %d): stub\n", debugstr_w(cmdline), verbose); + + return ERROR_SUCCESS; +} diff --git a/dlls/mapi32/mapi32_main.c b/dlls/mapi32/mapi32_main.c index 936d4352132..b9d5888bead 100644 --- a/dlls/mapi32/mapi32_main.c +++ b/dlls/mapi32/mapi32_main.c @@ -89,7 +89,7 @@ HRESULT WINAPI MAPIInitialize(LPVOID init) ULONG WINAPI MAPILogon(ULONG_PTR uiparam, LPSTR profile, LPSTR password, FLAGS flags, ULONG reserved, LPLHANDLE session) { - FIXME("(0x%08lx %s %p 0x%08lx 0x%08x %p) Stub\n", uiparam, + FIXME("(0x%08lx %s %p 0x%08x 0x%08x %p) Stub\n", uiparam, debugstr_a(profile), password, flags, reserved, session); if (session) *session = 1; @@ -99,7 +99,7 @@ ULONG WINAPI MAPILogon(ULONG_PTR uiparam, LPSTR profile, LPSTR password, ULONG WINAPI MAPILogoff(LHANDLE session, ULONG_PTR uiparam, FLAGS flags, ULONG reserved ) { - FIXME("(0x%08lx 0x%08lx 0x%08lx 0x%08x) Stub\n", session, + FIXME("(0x%08lx 0x%08lx 0x%08x 0x%08x) Stub\n", session, uiparam, flags, reserved); return SUCCESS_SUCCESS; } diff --git a/dlls/mapi32/sendmail.c b/dlls/mapi32/sendmail.c index 4103117d800..7b8de6676d5 100644 --- a/dlls/mapi32/sendmail.c +++ b/dlls/mapi32/sendmail.c @@ -71,7 +71,7 @@ ULONG WINAPI MAPISendMail( LHANDLE session, ULONG_PTR uiparam, HRESULT res; DWORD size; - TRACE( "(0x%08lx 0x%08lx %p 0x%08lx 0x%08x)\n", session, uiparam, + TRACE( "(0x%08x 0x%08lx %p 0x%08x 0x%08x)\n", session, uiparam, message, flags, reserved ); if (!message) return MAPI_E_FAILURE; diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 526fdea952b..a3a9595cdad 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -106,6 +106,7 @@ static REFIID tid_ids[] = { &IID_IHTMLGenericElement, &IID_IHTMLImgElement, &IID_IHTMLInputElement, + &IID_IHTMLLocation, &IID_IHTMLOptionElement, &IID_IHTMLSelectElement, &IID_IHTMLStyle, diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index 0881023c87e..5f0d7fbe51e 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -43,12 +43,11 @@ static HRESULT WINAPI HTMLLocation_QueryInterface(IHTMLLocation *iface, REFIID r if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); *ppv = HTMLLOCATION(This); - }else if(IsEqualGUID(&IID_IDispatch, riid)) { - TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); - *ppv = HTMLLOCATION(This); }else if(IsEqualGUID(&IID_IHTMLLocation, riid)) { TRACE("(%p)->(IID_IHTMLLocation %p)\n", This, ppv); *ppv = HTMLLOCATION(This); + }else if(dispex_query_interface(&This->dispex, riid, ppv)) { + return *ppv ? S_OK : E_NOINTERFACE; } if(*ppv) { @@ -293,6 +292,18 @@ static const IHTMLLocationVtbl HTMLLocationVtbl = { HTMLLocation_toString }; +static const tid_t HTMLLocation_iface_tids[] = { + IHTMLLocation_tid, + 0 +}; +static dispex_static_data_t HTMLLocation_dispex = { + NULL, + IHTMLLocation_tid, + NULL, + HTMLLocation_iface_tids +}; + + HTMLLocation *HTMLLocation_Create(HTMLDocument *doc) { HTMLLocation *ret = heap_alloc(sizeof(*ret)); @@ -301,5 +312,7 @@ HTMLLocation *HTMLLocation_Create(HTMLDocument *doc) ret->ref = 1; ret->doc = doc; + init_dispex(&ret->dispex, (IUnknown*)HTMLLOCATION(ret), &HTMLLocation_dispex); + return ret; } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 58f662a75c8..a7e364e27a2 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -102,6 +102,7 @@ typedef enum { IHTMLGenericElement_tid, IHTMLImgElement_tid, IHTMLInputElement_tid, + IHTMLLocation_tid, IHTMLOptionElement_tid, IHTMLSelectElement_tid, IHTMLStyle_tid, @@ -199,6 +200,7 @@ struct ConnectionPoint { }; typedef struct { + DispatchEx dispex; const IHTMLLocationVtbl *lpHTMLLocationVtbl; LONG ref; diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index 9ea6df83dfb..5bb7a8dfcee 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -251,11 +251,15 @@ static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p) { OmNavigator *This = OMNAVIGATOR_THIS(iface); - static const WCHAR win32W[] = {'W','i','n','3','2',0}; +#ifdef _WIN64 + static const WCHAR platformW[] = {'W','i','n','6','4',0}; +#else + static const WCHAR platformW[] = {'W','i','n','3','2',0}; +#endif TRACE("(%p)->(%p)\n", This, p); - *p = SysAllocString(win32W); + *p = SysAllocString(platformW); return S_OK; } diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index ee2a5cafdc3..be54998a6da 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -2207,6 +2207,7 @@ static void test_location(IHTMLDocument2 *doc) IHTMLLocation_Release(location2); test_ifaces((IUnknown*)location, location_iids); + test_disp((IUnknown*)location, &IID_IHTMLLocation); ref = IHTMLLocation_Release(location); ok(!ref, "location chould be destroyed here\n"); diff --git a/dlls/msvcrt/except.c b/dlls/msvcrt/except.c index 6a6fed35f6d..7c4ee473748 100644 --- a/dlls/msvcrt/except.c +++ b/dlls/msvcrt/except.c @@ -219,10 +219,10 @@ int CDECL _except_handler3(PEXCEPTION_RECORD rec, while (trylevel != TRYLEVEL_END) { + TRACE( "level %d prev %d filter %p\n", trylevel, pScopeTable[trylevel].previousTryLevel, + pScopeTable[trylevel].lpfnFilter ); if (pScopeTable[trylevel].lpfnFilter) { - TRACE("filter = %p\n", pScopeTable[trylevel].lpfnFilter); - retval = call_filter( pScopeTable[trylevel].lpfnFilter, &exceptPtrs, &frame->_ebp ); TRACE("filter returned %s\n", retval == EXCEPTION_CONTINUE_EXECUTION ? @@ -241,13 +241,13 @@ int CDECL _except_handler3(PEXCEPTION_RECORD rec, /* Set our trylevel to the enclosing block, and call the __finally * code, which won't return */ - frame->trylevel = pScopeTable->previousTryLevel; + frame->trylevel = pScopeTable[trylevel].previousTryLevel; TRACE("__finally block %p\n",pScopeTable[trylevel].lpfnHandler); call_finally_block(pScopeTable[trylevel].lpfnHandler, &frame->_ebp); ERR("Returned from __finally block - expect crash!\n"); } } - trylevel = pScopeTable->previousTryLevel; + trylevel = pScopeTable[trylevel].previousTryLevel; } } #else diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index c1c53c37be6..607d0e22f39 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -320,8 +320,9 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f { DWORD c; - TRACE( "code=%x flags=%x addr=%p\n", - rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress ); + TRACE( "code=%x flags=%x addr=%p ip=%p tid=%04x\n", + rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress, + GET_IP(context), GetCurrentThreadId() ); for (c = 0; c < rec->NumberParameters; c++) TRACE( " info[%d]=%08lx\n", c, rec->ExceptionInformation[c] ); if (rec->ExceptionCode == EXCEPTION_WINE_STUB) @@ -335,17 +336,26 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f rec->ExceptionAddress, (char*)rec->ExceptionInformation[0], rec->ExceptionInformation[1] ); } -#ifdef __i386__ else { +#ifdef __i386__ TRACE(" eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n", context->Eax, context->Ebx, context->Ecx, context->Edx, context->Esi, context->Edi ); TRACE(" ebp=%08x esp=%08x cs=%04x ds=%04x es=%04x fs=%04x gs=%04x flags=%08x\n", context->Ebp, context->Esp, context->SegCs, context->SegDs, context->SegEs, context->SegFs, context->SegGs, context->EFlags ); - } +#elif defined(__x86_64__) + TRACE(" rax=%016lx rbx=%016lx rcx=%016lx rdx=%016lx\n", + context->Rax, context->Rbx, context->Rcx, context->Rdx ); + TRACE(" rsi=%016lx rdi=%016lx rbp=%016lx rsp=%016lx\n", + context->Rsi, context->Rdi, context->Rbp, context->Rsp ); + TRACE(" r8=%016lx r9=%016lx r10=%016lx r11=%016lx\n", + context->R8, context->R9, context->R10, context->R11 ); + TRACE(" r12=%016lx r13=%016lx r14=%016lx r15=%016lx\n", + context->R12, context->R13, context->R14, context->R15 ); #endif + } status = send_debug_event( rec, TRUE, context ); if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED) return STATUS_SUCCESS; @@ -390,25 +400,6 @@ NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL return status; } -/*********************************************************************** - * RtlCaptureContext (NTDLL.@) - */ -void WINAPI __regs_RtlCaptureContext( CONTEXT *context_out, CONTEXT *context_in ) -{ - *context_out = *context_in; -} - -/**********************************************************************/ - -#ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( RtlCaptureContext, 4, 4 ) -#else -void WINAPI RtlCaptureContext( CONTEXT *context_out ) -{ - memset( context_out, 0, sizeof(*context_out) ); -} -#endif - /*********************************************************************** * RtlRaiseException (NTDLL.@) @@ -430,7 +421,7 @@ void WINAPI __regs_RtlRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context ) /**********************************************************************/ #ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( RtlRaiseException, 4, 4 ) +DEFINE_REGS_ENTRYPOINT( RtlRaiseException, 1 ) #else void WINAPI RtlRaiseException( EXCEPTION_RECORD *rec ) { @@ -522,7 +513,7 @@ void WINAPI __regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD* pEndFrame, PVOID un /**********************************************************************/ #ifdef DEFINE_REGS_ENTRYPOINT -DEFINE_REGS_ENTRYPOINT( RtlUnwind, 16, 16 ) +DEFINE_REGS_ENTRYPOINT( RtlUnwind, 4 ) #else void WINAPI RtlUnwind( PVOID pEndFrame, PVOID unusedEip, PEXCEPTION_RECORD pRecord, PVOID returnEax ) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index ced68d9bd51..dc121f57068 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -41,7 +41,6 @@ struct drive_info /* exceptions */ extern void wait_suspend( CONTEXT *context ); extern void WINAPI __regs_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT ); -extern void get_cpu_context( CONTEXT *context ); extern void set_cpu_context( const CONTEXT *context ); /* debug helper */ @@ -217,13 +216,20 @@ static inline struct ntdll_thread_regs *ntdll_get_thread_regs(void) /* Register functions */ #ifdef __i386__ -#define DEFINE_REGS_ENTRYPOINT( name, args, pop_args ) \ +#define DEFINE_REGS_ENTRYPOINT( name, args ) \ __ASM_GLOBAL_FUNC( name, \ - "pushl %eax\n\t" \ - "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \ - ".long " __ASM_NAME("__regs_") #name "-.\n\t" \ - ".byte " #args "," #pop_args ) -/* FIXME: add support for other CPUs */ + ".byte 0x68\n\t" /* pushl $__regs_func */ \ + ".long " __ASM_NAME("__regs_") #name "-.-11\n\t" \ + ".byte 0x6a," #args "\n\t" /* pushl $args */ \ + "call " __ASM_NAME("__wine_call_from_32_regs")) +#elif defined(__x86_64__) +#define DEFINE_REGS_ENTRYPOINT( name, args ) \ + __ASM_GLOBAL_FUNC( name, \ + "movq %rcx,8(%rsp)\n\t" \ + "movq %rdx,16(%rsp)\n\t" \ + "movq $" #args ",%rcx\n\t" \ + "leaq " __ASM_NAME("__regs_") #name "(%rip),%rdx\n\t" \ + "call " __ASM_NAME("__wine_call_from_regs")) #endif #endif diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c index 6dec576f444..6eeb4534780 100644 --- a/dlls/ntdll/relay.c +++ b/dlls/ntdll/relay.c @@ -421,7 +421,6 @@ void WINAPI __regs_relay_call_regs( struct relay_descr *descr, unsigned int idx, { WORD ordinal = LOWORD(idx); BYTE nb_args = LOBYTE(HIWORD(idx)); - BYTE flags = HIBYTE(HIWORD(idx)); struct relay_private_data *data = descr->private; struct relay_entry_point *entry_point = data->entry_points + ordinal; BYTE *orig_func = entry_point->orig_func; @@ -431,8 +430,7 @@ void WINAPI __regs_relay_call_regs( struct relay_descr *descr, unsigned int idx, /* restore the context to what it was before the relay thunk */ context->Eax = orig_eax; context->Eip = ret_addr; - if (flags & 2) /* stdcall */ - context->Esp += nb_args * sizeof(int); + context->Esp += nb_args * sizeof(int); if (TRACE_ON(relay)) { @@ -449,16 +447,17 @@ void WINAPI __regs_relay_call_regs( struct relay_descr *descr, unsigned int idx, context->Edx, context->Esi, context->Edi, context->Ebp, context->Esp, context->SegDs, context->SegEs, context->SegFs, context->SegGs, context->EFlags ); - assert( orig_func[0] == 0x50 /* pushl %eax */ ); - assert( orig_func[1] == 0xe8 /* call */ ); + assert( orig_func[0] == 0x68 /* pushl func */ ); + assert( orig_func[5] == 0x6a /* pushl args */ ); + assert( orig_func[7] == 0xe8 /* call */ ); } /* now call the real function */ memcpy( args_copy, args, nb_args * sizeof(args[0]) ); - args_copy[nb_args++] = (int)context; /* append context argument */ + args_copy[nb_args++] = (INT_PTR)context; /* append context argument */ - call_entry_point( orig_func + 6 + *(int *)(orig_func + 6), nb_args, args_copy ); + call_entry_point( orig_func + 12 + *(int *)(orig_func + 1), nb_args, args_copy ); if (TRACE_ON(relay)) @@ -479,8 +478,77 @@ void WINAPI __regs_relay_call_regs( struct relay_descr *descr, unsigned int idx, } } extern void WINAPI relay_call_regs(void); -DEFINE_REGS_ENTRYPOINT( relay_call_regs, 16, 16 ) -#endif +DEFINE_REGS_ENTRYPOINT( relay_call_regs, 4 ) + +#else /* __i386__ */ + +void WINAPI __regs_relay_call_regs( struct relay_descr *descr, INT_PTR idx, + INT_PTR *stack, CONTEXT *context ) +{ + WORD ordinal = LOWORD(idx); + BYTE nb_args = LOBYTE(HIWORD(idx)); + struct relay_private_data *data = descr->private; + struct relay_entry_point *entry_point = data->entry_points + ordinal; + BYTE *orig_func = entry_point->orig_func; + INT_PTR *args = stack + 1; + INT_PTR args_copy[32]; + + /* restore the context to what it was before the relay thunk */ + context->Rip = stack[0]; + context->Rsp = (INT_PTR)args; + + if (TRACE_ON(relay)) + { + if (entry_point->name) + DPRINTF( "%04x:Call %s.%s(", GetCurrentThreadId(), data->dllname, entry_point->name ); + else + DPRINTF( "%04x:Call %s.%u(", GetCurrentThreadId(), data->dllname, data->base + ordinal ); + RELAY_PrintArgs( args, nb_args, descr->arg_types[ordinal] ); + DPRINTF( ") ret=%08lx\n", context->Rip ); + + DPRINTF( "%04x: rax=%016lx rbx=%016lx rcx=%016lx rdx=%016lx rsi=%016lx rdi=%016lx rbp=%016lx rsp=%016lx\n", + GetCurrentThreadId(), context->Rax, context->Rbx, context->Rcx, context->Rdx, + context->Rsi, context->Rdi, context->Rbp, context->Rsp ); + DPRINTF( "%04x: r8=%016lx r9=%016lx r10=%016lx r11=%016lx r12=%016lx r13=%016lx r14=%016lx r15=%016lx\n", + GetCurrentThreadId(), context->R8, context->R9, context->R10, context->R11, + context->R12, context->R13, context->R14, context->R15 ); + + assert( orig_func[17] == 0x48 /* leaq */ ); + assert( orig_func[18] == 0x8d ); + assert( orig_func[19] == 0x15 ); + assert( orig_func[24] == 0xe8 /* call */ ); + } + + /* now call the real function */ + + memcpy( args_copy, args, nb_args * sizeof(args[0]) ); + args_copy[nb_args++] = (INT_PTR)context; /* append context argument */ + + call_entry_point( orig_func + 24 + *(int *)(orig_func + 20), nb_args, args_copy ); + + + if (TRACE_ON(relay)) + { + if (entry_point->name) + DPRINTF( "%04x:Ret %s.%s() retval=%08lx ret=%08lx\n", + GetCurrentThreadId(), data->dllname, entry_point->name, + context->Rax, context->Rip ); + else + DPRINTF( "%04x:Ret %s.%u() retval=%08lx ret=%08lx\n", + GetCurrentThreadId(), data->dllname, data->base + ordinal, + context->Rax, context->Rip ); + DPRINTF( "%04x: rax=%016lx rbx=%016lx rcx=%016lx rdx=%016lx rsi=%016lx rdi=%016lx rbp=%016lx rsp=%016lx\n", + GetCurrentThreadId(), context->Rax, context->Rbx, context->Rcx, context->Rdx, + context->Rsi, context->Rdi, context->Rbp, context->Rsp ); + DPRINTF( "%04x: r8=%016lx r9=%016lx r10=%016lx r11=%016lx r12=%016lx r13=%016lx r14=%016lx r15=%016lx\n", + GetCurrentThreadId(), context->R8, context->R9, context->R10, context->R11, + context->R12, context->R13, context->R14, context->R15 ); + } +} +extern void WINAPI relay_call_regs(void); +DEFINE_REGS_ENTRYPOINT( relay_call_regs, 3 ) + +#endif /* __i386__ */ /*********************************************************************** @@ -530,9 +598,7 @@ void RELAY_SetupDLL( HMODULE module ) return; descr->relay_call = relay_call; -#ifdef __i386__ descr->relay_call_regs = relay_call_regs; -#endif descr->private = data; data->module = module; @@ -973,8 +1039,8 @@ void WINAPI __regs_SNOOP_Return( CONTEXT86 *context ) } /* assembly wrappers that save the context */ -DEFINE_REGS_ENTRYPOINT( SNOOP_Entry, 0, 0 ) -DEFINE_REGS_ENTRYPOINT( SNOOP_Return, 0, 0 ) +DEFINE_REGS_ENTRYPOINT( SNOOP_Entry, 0 ) +DEFINE_REGS_ENTRYPOINT( SNOOP_Return, 0 ) #else /* __i386__ */ diff --git a/dlls/ntdll/rtlbitmap.c b/dlls/ntdll/rtlbitmap.c index ef033b22848..806e0e80da5 100644 --- a/dlls/ntdll/rtlbitmap.c +++ b/dlls/ntdll/rtlbitmap.c @@ -555,9 +555,12 @@ ULONG WINAPI RtlNumberOfSetBits(PCRTL_BITMAP lpBits) lpOut++; } - bMasked = *lpOut & NTDLL_maskBits[ulRemainder]; - ulSet += NTDLL_nibbleBitCount[bMasked >> 4]; - ulSet += NTDLL_nibbleBitCount[bMasked & 0xf]; + if (ulRemainder) + { + bMasked = *lpOut & NTDLL_maskBits[ulRemainder]; + ulSet += NTDLL_nibbleBitCount[bMasked >> 4]; + ulSet += NTDLL_nibbleBitCount[bMasked & 0xf]; + } } return ulSet; } diff --git a/dlls/ntdll/serial.c b/dlls/ntdll/serial.c index 40262a42640..c8d3b29a891 100644 --- a/dlls/ntdll/serial.c +++ b/dlls/ntdll/serial.c @@ -651,7 +651,11 @@ static NTSTATUS set_line_control(int fd, const SERIAL_LINE_CONTROL* slc) port.c_cflag &= ~(HUPCL); port.c_cflag |= CLOCAL | CREAD; - port.c_lflag &= ~(ICANON|ECHO|ISIG); + /* + * on FreeBSD, turning off ICANON does not disable IEXTEN, + * so we must turn it off explicitly. No harm done on Linux. + */ + port.c_lflag &= ~(ICANON|ECHO|ISIG|IEXTEN); port.c_lflag |= NOFLSH; bytesize = slc->WordLength; diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 47788e6331f..154366436f8 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -886,17 +886,15 @@ static inline void restore_context( const CONTEXT *context, SIGCONTEXT *sigconte /*********************************************************************** - * get_cpu_context - * - * Register function to get the context of the current thread. + * RtlCaptureContext (NTDLL.@) */ -void WINAPI __regs_get_cpu_context( CONTEXT *context, CONTEXT *regs ) +void WINAPI __regs_RtlCaptureContext( CONTEXT *context, CONTEXT *regs ) { *context = *regs; if (fpux_support) save_fpux( context ); else save_fpu( context ); } -DEFINE_REGS_ENTRYPOINT( get_cpu_context, 4, 4 ) +DEFINE_REGS_ENTRYPOINT( RtlCaptureContext, 1 ) /*********************************************************************** diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c index 4fa44e76c34..c790f845cf7 100644 --- a/dlls/ntdll/signal_powerpc.c +++ b/dlls/ntdll/signal_powerpc.c @@ -268,13 +268,12 @@ static inline void restore_fpu( CONTEXT *context, const SIGCONTEXT *sigcontext ) /*********************************************************************** - * get_cpu_context - * - * Get the context of the current thread. + * RtlCaptureContext (NTDLL.@) */ -void get_cpu_context( CONTEXT *context ) +void WINAPI RtlCaptureContext( CONTEXT *context ) { FIXME("not implemented\n"); + memset( context, 0, sizeof(*context) ); } diff --git a/dlls/ntdll/signal_sparc.c b/dlls/ntdll/signal_sparc.c index 4c1463399f5..54165eefbce 100644 --- a/dlls/ntdll/signal_sparc.c +++ b/dlls/ntdll/signal_sparc.c @@ -149,13 +149,12 @@ static void restore_fpu( CONTEXT *context, ucontext_t *ucontext ) /*********************************************************************** - * get_cpu_context - * - * Get the context of the current thread. + * RtlCaptureContext (NTDLL.@) */ -void get_cpu_context( CONTEXT *context ) +void WINAPI RtlCaptureContext( CONTEXT *context ) { FIXME("not implemented\n"); + memset( context, 0, sizeof(*context) ); } diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 35c9f1b6e81..8e9dd7c1e23 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -199,14 +199,13 @@ static void restore_context( const CONTEXT *context, SIGCONTEXT *sigcontext ) /*********************************************************************** - * get_cpu_context - * - * Get the context of the current thread. + * RtlCaptureContext (NTDLL.@) */ -void get_cpu_context( CONTEXT *context ) +void WINAPI __regs_RtlCaptureContext( CONTEXT *context, CONTEXT *regs ) { - FIXME("not implemented\n"); + *context = *regs; } +DEFINE_REGS_ENTRYPOINT( RtlCaptureContext, 1 ) /*********************************************************************** diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 51b190a121f..7d4675acd89 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -1134,7 +1134,7 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context ) { if (needed_flags) { - get_cpu_context( &ctx ); + RtlCaptureContext( &ctx ); copy_context( context, &ctx, ctx.ContextFlags & needed_flags ); } #ifdef __i386__ diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index f6d7d1e7011..d27014f7d79 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -117,16 +117,20 @@ static HANDLE get_device_manager(void) /* exception handler for emulation of privileged instructions */ static LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs ) { - extern DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT86 *context ); - EXCEPTION_RECORD *record = ptrs->ExceptionRecord; - CONTEXT86 *context = ptrs->ContextRecord; + CONTEXT *context = ptrs->ContextRecord; if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION || record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION) { +#ifdef __i386__ + extern DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT *context ); + if (__wine_emulate_instruction( record, context ) == ExceptionContinueExecution) return EXCEPTION_CONTINUE_EXECUTION; +#else + FIXME( "Privileged instruction emulation not implemented on this CPU\n" ); +#endif } return EXCEPTION_CONTINUE_SEARCH; } diff --git a/dlls/ole32/defaulthandler.c b/dlls/ole32/defaulthandler.c index 5c6f9b2d72f..2384cec3b03 100644 --- a/dlls/ole32/defaulthandler.c +++ b/dlls/ole32/defaulthandler.c @@ -909,7 +909,7 @@ static HRESULT WINAPI DefaultHandler_GetMiscStatus( if (FAILED(hres)) *pdwStatus = 0; - return S_OK; + return hres; } /************************************************************************ diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c index 99b8acb0503..9d0644e035b 100644 --- a/dlls/ole32/tests/ole2.c +++ b/dlls/ole32/tests/ole2.c @@ -1384,7 +1384,6 @@ static void test_default_handler(void) hr); hr = IOleObject_GetMiscStatus(pObject, DVASPECT_CONTENT, &dwStatus); - todo_wine ok(hr == REGDB_E_CLASSNOTREG, "IOleObject_GetMiscStatus should have returned REGDB_E_CLASSNOTREG instead of 0x%08x\n", hr); hr = IOleObject_GetUserClassID(pObject, &clsid); diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index bdce729639f..a0f18558784 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -519,6 +519,10 @@ static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface, { OLEPictureImpl *This = (OLEPictureImpl *)iface; TRACE("(%p)->(%p)\n", This, phandle); + + if(!phandle) + return E_POINTER; + switch(This->desc.picType) { case PICTYPE_NONE: case PICTYPE_UNINITIALIZED: @@ -591,6 +595,10 @@ static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface, { OLEPictureImpl *This = (OLEPictureImpl *)iface; TRACE("(%p)->(%p): type is %d\n", This, ptype, This->desc.picType); + + if(!ptype) + return E_POINTER; + *ptype = This->desc.picType; return S_OK; } @@ -842,8 +850,14 @@ static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface, { OLEPictureImpl *This = (OLEPictureImpl *)iface; TRACE("(%p)->(%p).\n", This, pdwAttr); + + if(!pdwAttr) + return E_POINTER; + *pdwAttr = 0; switch (This->desc.picType) { + case PICTYPE_UNINITIALIZED: + case PICTYPE_NONE: break; case PICTYPE_BITMAP: if (This->hbmMask) *pdwAttr = PICTURE_TRANSPARENT; break; /* not 'truly' scalable, see MSDN. */ case PICTYPE_ICON: *pdwAttr = PICTURE_TRANSPARENT;break; case PICTYPE_ENHMETAFILE: /* fall through */ diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c index 2b5b8bb86eb..ee13227b23d 100644 --- a/dlls/oleaut32/tests/olepicture.c +++ b/dlls/oleaut32/tests/olepicture.c @@ -324,6 +324,7 @@ static void test_empty_image(void) { ULARGE_INTEGER newpos1; LARGE_INTEGER seekto; short type; + DWORD attr; /* Empty image. Happens occasionally in VB programs. */ hglob = GlobalAlloc (0, 8); @@ -347,6 +348,11 @@ static void test_empty_image(void) { ok (hres == S_OK,"empty picture get type failed with hres 0x%08x\n", hres); ok (type == PICTYPE_NONE,"type is %d, but should be PICTYPE_NONE(0)\n", type); + attr = 0xdeadbeef; + hres = IPicture_get_Attributes (pic, &attr); + ok (hres == S_OK,"empty picture get attributes failed with hres 0x%08x\n", hres); + ok (attr == 0,"attr is %d, but should be 0\n", attr); + hres = IPicture_get_Handle (pic, &handle); ok (hres == S_OK,"empty picture get handle failed with hres 0x%08x\n", hres); ok (handle == 0, "empty picture get handle did not return 0, but 0x%08x\n", handle); @@ -645,6 +651,55 @@ static void test_Render(void) ReleaseDC(NULL, hdc); } +static void test_get_Attributes(void) +{ + IPicture *pic; + HRESULT hres; + short type; + DWORD attr; + + OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic); + hres = IPicture_get_Type(pic, &type); + ok(hres == S_OK, "IPicture_get_Type does not return S_OK, but 0x%08x\n", hres); + ok(type == PICTYPE_UNINITIALIZED, "Expected type = PICTYPE_UNINITIALIZED, got = %d\n", type); + + hres = IPicture_get_Attributes(pic, NULL); + ole_expect(hres, E_POINTER); + + attr = 0xdeadbeef; + hres = IPicture_get_Attributes(pic, &attr); + ole_expect(hres, S_OK); + ok(attr == 0, "IPicture_get_Attributes does not reset attr to zero, got %d\n", attr); + + IPicture_Release(pic); +} + +static void test_get_Handle(void) +{ + IPicture *pic; + HRESULT hres; + + OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic); + + hres = IPicture_get_Handle(pic, NULL); + ole_expect(hres, E_POINTER); + + IPicture_Release(pic); +} + +static void test_get_Type(void) +{ + IPicture *pic; + HRESULT hres; + + OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic); + + hres = IPicture_get_Type(pic, NULL); + ole_expect(hres, E_POINTER); + + IPicture_Release(pic); +} + START_TEST(olepicture) { hOleaut32 = GetModuleHandleA("oleaut32.dll"); @@ -672,6 +727,9 @@ START_TEST(olepicture) test_Invoke(); test_OleCreatePictureIndirect(); test_Render(); + test_get_Attributes(); + test_get_Handle(); + test_get_Type(); } diff --git a/dlls/qmgr/job.c b/dlls/qmgr/job.c index 871f14c6c3b..a82b39fe966 100644 --- a/dlls/qmgr/job.c +++ b/dlls/qmgr/job.c @@ -382,32 +382,34 @@ static HRESULT WINAPI BITS_IBackgroundCopyJob_SetMinimumRetryDelay( IBackgroundCopyJob2 *iface, ULONG Seconds) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + FIXME("%u\n", Seconds); + return S_OK; } static HRESULT WINAPI BITS_IBackgroundCopyJob_GetMinimumRetryDelay( IBackgroundCopyJob2 *iface, ULONG *Seconds) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + FIXME("%p\n", Seconds); + *Seconds = 30; + return S_OK; } static HRESULT WINAPI BITS_IBackgroundCopyJob_SetNoProgressTimeout( IBackgroundCopyJob2 *iface, ULONG Seconds) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + FIXME("%u\n", Seconds); + return S_OK; } static HRESULT WINAPI BITS_IBackgroundCopyJob_GetNoProgressTimeout( IBackgroundCopyJob2 *iface, ULONG *Seconds) { - FIXME("Not implemented\n"); - return E_NOTIMPL; + FIXME("%p\n", Seconds); + *Seconds = 900; + return S_OK; } static HRESULT WINAPI BITS_IBackgroundCopyJob_GetErrorCount( diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c index 2d63064860f..00165e535c1 100644 --- a/dlls/quartz/pin.c +++ b/dlls/quartz/pin.c @@ -142,11 +142,6 @@ out: return hr; } -static inline InputPin *impl_from_IMemInputPin( IMemInputPin *iface ) -{ - return (InputPin *)((char*)iface - FIELD_OFFSET(InputPin, lpVtblMemInput)); -} - static void Copy_PinInfo(PIN_INFO * pDest, const PIN_INFO * pSrc) { @@ -159,205 +154,6 @@ static void Copy_PinInfo(PIN_INFO * pDest, const PIN_INFO * pSrc) pDest->pFilter = pSrc->pFilter; } -/* Function called as a helper to IPin_Connect */ -/* specific AM_MEDIA_TYPE - it cannot be NULL */ -/* NOTE: not part of standard interface */ -static HRESULT OutputPin_ConnectSpecific(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt) -{ - OutputPin *This = (OutputPin *)iface; - HRESULT hr; - IMemAllocator * pMemAlloc = NULL; - ALLOCATOR_PROPERTIES actual; /* FIXME: should we put the actual props back in to This? */ - - TRACE("(%p, %p)\n", pReceivePin, pmt); - dump_AM_MEDIA_TYPE(pmt); - - /* FIXME: call queryacceptproc */ - - This->pin.pConnectedTo = pReceivePin; - IPin_AddRef(pReceivePin); - CopyMediaType(&This->pin.mtCurrent, pmt); - - hr = IPin_ReceiveConnection(pReceivePin, iface, pmt); - - /* get the IMemInputPin interface we will use to deliver samples to the - * connected pin */ - if (SUCCEEDED(hr)) - { - This->pMemInputPin = NULL; - hr = IPin_QueryInterface(pReceivePin, &IID_IMemInputPin, (LPVOID)&This->pMemInputPin); - - if (SUCCEEDED(hr) && !This->custom_allocator) - { - hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pMemAlloc); - - if (hr == VFW_E_NO_ALLOCATOR) - /* Input pin provides no allocator, use standard memory allocator */ - hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, &IID_IMemAllocator, (LPVOID*)&pMemAlloc); - - if (SUCCEEDED(hr)) - hr = IMemAllocator_SetProperties(pMemAlloc, &This->allocProps, &actual); - - if (SUCCEEDED(hr)) - hr = IMemInputPin_NotifyAllocator(This->pMemInputPin, pMemAlloc, This->readonly); - - if (pMemAlloc) - IMemAllocator_Release(pMemAlloc); - } - else if (SUCCEEDED(hr)) - { - if (This->alloc) - { - hr = IMemInputPin_NotifyAllocator(This->pMemInputPin, This->alloc, This->readonly); - } - else - hr = VFW_E_NO_ALLOCATOR; - } - - /* break connection if we couldn't get the allocator */ - if (FAILED(hr)) - { - if (This->pMemInputPin) - IMemInputPin_Release(This->pMemInputPin); - This->pMemInputPin = NULL; - - IPin_Disconnect(pReceivePin); - } - } - - if (FAILED(hr)) - { - IPin_Release(This->pin.pConnectedTo); - This->pin.pConnectedTo = NULL; - FreeMediaType(&This->pin.mtCurrent); - } - - TRACE(" -- %x\n", hr); - return hr; -} - -static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, - QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, InputPin * pPinImpl) -{ - TRACE("\n"); - - /* Common attributes */ - pPinImpl->pin.refCount = 1; - pPinImpl->pin.pConnectedTo = NULL; - pPinImpl->pin.fnQueryAccept = pQueryAccept; - pPinImpl->pin.pUserData = pUserData; - pPinImpl->pin.pCritSec = pCritSec; - Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo); - ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE)); - - /* Input pin attributes */ - pPinImpl->fnSampleProc = pSampleProc; - pPinImpl->fnCleanProc = pCleanUp; - pPinImpl->pAllocator = pPinImpl->preferred_allocator = allocator; - if (pPinImpl->preferred_allocator) - IMemAllocator_AddRef(pPinImpl->preferred_allocator); - pPinImpl->tStart = 0; - pPinImpl->tStop = 0; - pPinImpl->dRate = 1.0; - pPinImpl->pin.lpVtbl = InputPin_Vtbl; - pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl; - pPinImpl->flushing = pPinImpl->end_of_stream = 0; - - return S_OK; -} - -static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * pPinInfo, const ALLOCATOR_PROPERTIES * props, LPVOID pUserData, - QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, OutputPin * pPinImpl) -{ - TRACE("\n"); - - /* Common attributes */ - pPinImpl->pin.lpVtbl = OutputPin_Vtbl; - pPinImpl->pin.refCount = 1; - pPinImpl->pin.pConnectedTo = NULL; - pPinImpl->pin.fnQueryAccept = pQueryAccept; - pPinImpl->pin.pUserData = pUserData; - pPinImpl->pin.pCritSec = pCritSec; - Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo); - ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE)); - - /* Output pin attributes */ - pPinImpl->pMemInputPin = NULL; - pPinImpl->pConnectSpecific = OutputPin_ConnectSpecific; - /* If custom_allocator is set, you will need to specify an allocator - * in the alloc member of the struct before an output pin can connect - */ - pPinImpl->custom_allocator = 0; - pPinImpl->alloc = NULL; - pPinImpl->readonly = FALSE; - if (props) - { - pPinImpl->allocProps = *props; - if (pPinImpl->allocProps.cbAlign == 0) - pPinImpl->allocProps.cbAlign = 1; - } - else - ZeroMemory(&pPinImpl->allocProps, sizeof(pPinImpl->allocProps)); - - return S_OK; -} - -HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, IPin ** ppPin) -{ - InputPin * pPinImpl; - - *ppPin = NULL; - - if (pPinInfo->dir != PINDIR_INPUT) - { - ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir); - return E_INVALIDARG; - } - - pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl)); - - if (!pPinImpl) - return E_OUTOFMEMORY; - - if (SUCCEEDED(InputPin_Init(InputPin_Vtbl, pPinInfo, pSampleProc, pUserData, pQueryAccept, pCleanUp, pCritSec, allocator, pPinImpl))) - { - *ppPin = (IPin *)pPinImpl; - return S_OK; - } - - CoTaskMemFree(pPinImpl); - return E_FAIL; -} - -HRESULT OutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, long outputpin_size, const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES *props, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin) -{ - OutputPin * pPinImpl; - - *ppPin = NULL; - - if (pPinInfo->dir != PINDIR_OUTPUT) - { - ERR("Pin direction(%x) != PINDIR_OUTPUT\n", pPinInfo->dir); - return E_INVALIDARG; - } - - assert(outputpin_size >= sizeof(OutputPin)); - - pPinImpl = CoTaskMemAlloc(outputpin_size); - - if (!pPinImpl) - return E_OUTOFMEMORY; - - if (SUCCEEDED(OutputPin_Init(OutputPin_Vtbl, pPinInfo, props, pUserData, pQueryAccept, pCritSec, pPinImpl))) - { - *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); - return S_OK; - } - - CoTaskMemFree(pPinImpl); - return E_FAIL; -} - /*** Common pin functions ***/ ULONG WINAPI IPinImpl_AddRef(IPin * iface) @@ -735,6 +531,11 @@ static const IPinVtbl InputPin_Vtbl = /*** IMemInputPin implementation ***/ +static inline InputPin *impl_from_IMemInputPin( IMemInputPin *iface ) +{ + return (InputPin *)((char*)iface - FIELD_OFFSET(InputPin, lpVtblMemInput)); +} + HRESULT WINAPI MemInputPin_QueryInterface(IMemInputPin * iface, REFIID riid, LPVOID * ppv) { InputPin *This = impl_from_IMemInputPin(iface); @@ -858,6 +659,8 @@ static const IMemInputPinVtbl MemInputPin_Vtbl = MemInputPin_ReceiveCanBlock }; +/*** OutputPin implementation ***/ + HRESULT WINAPI OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv) { OutputPin *This = (OutputPin *)iface; @@ -1260,6 +1063,7 @@ HRESULT OutputPin_DeliverDisconnect(OutputPin * This) return hr; } +/*** PullPin implementation ***/ static HRESULT PullPin_Init(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone, LPCRITICAL_SECTION pCritSec, PullPin * pPinImpl) @@ -1876,3 +1680,204 @@ static const IPinVtbl PullPin_Vtbl = PullPin_EndFlush, PullPin_NewSegment }; + +/*** The Construct functions ***/ + +/* Function called as a helper to IPin_Connect */ +/* specific AM_MEDIA_TYPE - it cannot be NULL */ +/* NOTE: not part of standard interface */ +static HRESULT OutputPin_ConnectSpecific(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt) +{ + OutputPin *This = (OutputPin *)iface; + HRESULT hr; + IMemAllocator * pMemAlloc = NULL; + ALLOCATOR_PROPERTIES actual; /* FIXME: should we put the actual props back in to This? */ + + TRACE("(%p, %p)\n", pReceivePin, pmt); + dump_AM_MEDIA_TYPE(pmt); + + /* FIXME: call queryacceptproc */ + + This->pin.pConnectedTo = pReceivePin; + IPin_AddRef(pReceivePin); + CopyMediaType(&This->pin.mtCurrent, pmt); + + hr = IPin_ReceiveConnection(pReceivePin, iface, pmt); + + /* get the IMemInputPin interface we will use to deliver samples to the + * connected pin */ + if (SUCCEEDED(hr)) + { + This->pMemInputPin = NULL; + hr = IPin_QueryInterface(pReceivePin, &IID_IMemInputPin, (LPVOID)&This->pMemInputPin); + + if (SUCCEEDED(hr) && !This->custom_allocator) + { + hr = IMemInputPin_GetAllocator(This->pMemInputPin, &pMemAlloc); + + if (hr == VFW_E_NO_ALLOCATOR) + /* Input pin provides no allocator, use standard memory allocator */ + hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, &IID_IMemAllocator, (LPVOID*)&pMemAlloc); + + if (SUCCEEDED(hr)) + hr = IMemAllocator_SetProperties(pMemAlloc, &This->allocProps, &actual); + + if (SUCCEEDED(hr)) + hr = IMemInputPin_NotifyAllocator(This->pMemInputPin, pMemAlloc, This->readonly); + + if (pMemAlloc) + IMemAllocator_Release(pMemAlloc); + } + else if (SUCCEEDED(hr)) + { + if (This->alloc) + { + hr = IMemInputPin_NotifyAllocator(This->pMemInputPin, This->alloc, This->readonly); + } + else + hr = VFW_E_NO_ALLOCATOR; + } + + /* break connection if we couldn't get the allocator */ + if (FAILED(hr)) + { + if (This->pMemInputPin) + IMemInputPin_Release(This->pMemInputPin); + This->pMemInputPin = NULL; + + IPin_Disconnect(pReceivePin); + } + } + + if (FAILED(hr)) + { + IPin_Release(This->pin.pConnectedTo); + This->pin.pConnectedTo = NULL; + FreeMediaType(&This->pin.mtCurrent); + } + + TRACE(" -- %x\n", hr); + return hr; +} + +static HRESULT InputPin_Init(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, + QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, InputPin * pPinImpl) +{ + TRACE("\n"); + + /* Common attributes */ + pPinImpl->pin.refCount = 1; + pPinImpl->pin.pConnectedTo = NULL; + pPinImpl->pin.fnQueryAccept = pQueryAccept; + pPinImpl->pin.pUserData = pUserData; + pPinImpl->pin.pCritSec = pCritSec; + Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo); + ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE)); + + /* Input pin attributes */ + pPinImpl->fnSampleProc = pSampleProc; + pPinImpl->fnCleanProc = pCleanUp; + pPinImpl->pAllocator = pPinImpl->preferred_allocator = allocator; + if (pPinImpl->preferred_allocator) + IMemAllocator_AddRef(pPinImpl->preferred_allocator); + pPinImpl->tStart = 0; + pPinImpl->tStop = 0; + pPinImpl->dRate = 1.0; + pPinImpl->pin.lpVtbl = InputPin_Vtbl; + pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl; + pPinImpl->flushing = pPinImpl->end_of_stream = 0; + + return S_OK; +} + +static HRESULT OutputPin_Init(const IPinVtbl *OutputPin_Vtbl, const PIN_INFO * pPinInfo, const ALLOCATOR_PROPERTIES * props, LPVOID pUserData, + QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, OutputPin * pPinImpl) +{ + TRACE("\n"); + + /* Common attributes */ + pPinImpl->pin.lpVtbl = OutputPin_Vtbl; + pPinImpl->pin.refCount = 1; + pPinImpl->pin.pConnectedTo = NULL; + pPinImpl->pin.fnQueryAccept = pQueryAccept; + pPinImpl->pin.pUserData = pUserData; + pPinImpl->pin.pCritSec = pCritSec; + Copy_PinInfo(&pPinImpl->pin.pinInfo, pPinInfo); + ZeroMemory(&pPinImpl->pin.mtCurrent, sizeof(AM_MEDIA_TYPE)); + + /* Output pin attributes */ + pPinImpl->pMemInputPin = NULL; + pPinImpl->pConnectSpecific = OutputPin_ConnectSpecific; + /* If custom_allocator is set, you will need to specify an allocator + * in the alloc member of the struct before an output pin can connect + */ + pPinImpl->custom_allocator = 0; + pPinImpl->alloc = NULL; + pPinImpl->readonly = FALSE; + if (props) + { + pPinImpl->allocProps = *props; + if (pPinImpl->allocProps.cbAlign == 0) + pPinImpl->allocProps.cbAlign = 1; + } + else + ZeroMemory(&pPinImpl->allocProps, sizeof(pPinImpl->allocProps)); + + return S_OK; +} + +HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *allocator, IPin ** ppPin) +{ + InputPin * pPinImpl; + + *ppPin = NULL; + + if (pPinInfo->dir != PINDIR_INPUT) + { + ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir); + return E_INVALIDARG; + } + + pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl)); + + if (!pPinImpl) + return E_OUTOFMEMORY; + + if (SUCCEEDED(InputPin_Init(InputPin_Vtbl, pPinInfo, pSampleProc, pUserData, pQueryAccept, pCleanUp, pCritSec, allocator, pPinImpl))) + { + *ppPin = (IPin *)pPinImpl; + return S_OK; + } + + CoTaskMemFree(pPinImpl); + return E_FAIL; +} + +HRESULT OutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, long outputpin_size, const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES *props, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin) +{ + OutputPin * pPinImpl; + + *ppPin = NULL; + + if (pPinInfo->dir != PINDIR_OUTPUT) + { + ERR("Pin direction(%x) != PINDIR_OUTPUT\n", pPinInfo->dir); + return E_INVALIDARG; + } + + assert(outputpin_size >= sizeof(OutputPin)); + + pPinImpl = CoTaskMemAlloc(outputpin_size); + + if (!pPinImpl) + return E_OUTOFMEMORY; + + if (SUCCEEDED(OutputPin_Init(OutputPin_Vtbl, pPinInfo, props, pUserData, pQueryAccept, pCritSec, pPinImpl))) + { + *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); + return S_OK; + } + + CoTaskMemFree(pPinImpl); + return E_FAIL; +} diff --git a/dlls/quartz/pin.h b/dlls/quartz/pin.h index 3a9719cd224..df0f4fdd5b2 100644 --- a/dlls/quartz/pin.h +++ b/dlls/quartz/pin.h @@ -189,19 +189,6 @@ HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample); HRESULT OutputPin_DeliverDisconnect(OutputPin * This); HRESULT OutputPin_DeliverNewSegment(OutputPin * This, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); -/**********************************/ -/*** MemInputPin Implementation ***/ - -HRESULT WINAPI MemInputPin_QueryInterface(IMemInputPin * iface, REFIID riid, LPVOID * ppv); -ULONG WINAPI MemInputPin_AddRef(IMemInputPin * iface); -ULONG WINAPI MemInputPin_Release(IMemInputPin * iface); -HRESULT WINAPI MemInputPin_GetAllocator(IMemInputPin * iface, IMemAllocator ** ppAllocator); -HRESULT WINAPI MemInputPin_NotifyAllocator(IMemInputPin * iface, IMemAllocator * pAllocator, BOOL bReadOnly); -HRESULT WINAPI MemInputPin_GetAllocatorRequirements(IMemInputPin * iface, ALLOCATOR_PROPERTIES * pProps); -HRESULT WINAPI MemInputPin_Receive(IMemInputPin * iface, IMediaSample * pSample); -HRESULT WINAPI MemInputPin_ReceiveMultiple(IMemInputPin * iface, IMediaSample ** pSamples, long nSamples, long *nSamplesProcessed); -HRESULT WINAPI MemInputPin_ReceiveCanBlock(IMemInputPin * iface); - /* Pull Pin */ HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt); HRESULT WINAPI PullPin_Disconnect(IPin * iface); diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index abb90786668..107dcea60e6 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -3263,7 +3263,11 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, } ME_CommitUndo(editor); if (bRepaint) - ME_RewrapRepaint(editor); + { + ME_WrapMarkedParagraphs(editor); + ME_UpdateScrollBar(editor); + ME_Repaint(editor); + } return 1; } case EM_GETCHARFORMAT: @@ -3285,7 +3289,9 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, case EM_SETPARAFORMAT: { BOOL result = ME_SetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam); - ME_RewrapRepaint(editor); + ME_WrapMarkedParagraphs(editor); + ME_UpdateScrollBar(editor); + ME_Repaint(editor); ME_CommitUndo(editor); return result; } @@ -4004,8 +4010,18 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, break; case SB_THUMBTRACK: case SB_THUMBPOSITION: - ME_ScrollAbs(editor,HIWORD(wParam)); + { + SCROLLINFO sbi; + sbi.cbSize = sizeof(sbi); + sbi.fMask = SIF_TRACKPOS; + /* Try to get 32-bit track position value. */ + if (!GetScrollInfo(editor->hWnd, SB_VERT, &sbi)) + /* GetScrollInfo failed, settle for 16-bit value in wParam. */ + sbi.nTrackPos = HIWORD(wParam); + + ME_ScrollAbs(editor, sbi.nTrackPos); break; + } } if (msg == EM_SCROLL) return 0x00010000 | (((ME_GetYScrollPos(editor) - origNPos)/lineHeight) & 0xffff); diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 94a1f87d9cf..f0acf4a9449 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -1083,7 +1083,15 @@ void ME_UpdateScrollBar(ME_TextEditor *editor) si.cbSize = sizeof(si); bScrollBarWasVisible = ME_GetYScrollVisible(editor); bScrollBarWillBeVisible = editor->nTotalLength > editor->sizeWindow.cy; - + + if (editor->vert_si.nPos && !bScrollBarWillBeVisible) + { + ME_ScrollAbs(editor, 0); + /* ME_ScrollAbs will call this function, + * so nothing else needs to be done here. */ + return; + } + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; if (GetWindowLongW(hWnd, GWL_STYLE) & ES_DISABLENOSCROLL) { @@ -1091,38 +1099,25 @@ void ME_UpdateScrollBar(ME_TextEditor *editor) bScrollBarWillBeVisible = TRUE; } - if (bScrollBarWasVisible != bScrollBarWillBeVisible) - { - ShowScrollBar(hWnd, SB_VERT, bScrollBarWillBeVisible); - ME_MarkAllForWrapping(editor); - ME_WrapMarkedParagraphs(editor); - } - - si.nMin = 0; + si.nMin = 0; si.nMax = editor->nTotalLength; si.nPos = editor->vert_si.nPos; si.nPage = editor->sizeWindow.cy; - - if (!(si.nMin == editor->vert_si.nMin && si.nMax == editor->vert_si.nMax && si.nPage == editor->vert_si.nPage)) + + if (!(si.nMin == editor->vert_si.nMin && + si.nMax == editor->vert_si.nMax && + si.nPage == editor->vert_si.nPage)) { TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage); editor->vert_si.nMin = si.nMin; editor->vert_si.nMax = si.nMax; editor->vert_si.nPage = si.nPage; - if (bScrollBarWillBeVisible) - { + if (bScrollBarWillBeVisible || bScrollBarWasVisible) SetScrollInfo(hWnd, SB_VERT, &si, TRUE); - } - else - { - if (bScrollBarWasVisible && !(si.fMask & SIF_DISABLENOSCROLL)) - { - SetScrollInfo(hWnd, SB_VERT, &si, TRUE); - ShowScrollBar(hWnd, SB_VERT, FALSE); - ME_ScrollAbs(editor, 0); - } - } } + + if (bScrollBarWasVisible != bScrollBarWillBeVisible) + ShowScrollBar(hWnd, SB_VERT, bScrollBarWillBeVisible); } int ME_GetYScrollPos(ME_TextEditor *editor) diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c index e69f0f61add..696887cb7b3 100644 --- a/dlls/rpcrt4/rpc_binding.c +++ b/dlls/rpcrt4/rpc_binding.c @@ -1517,7 +1517,7 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName, { RPC_STATUS status; - TRACE("SecurityQos { Version=%d, Capabilties=0x%x, IdentityTracking=%d, ImpersonationLevel=%d", + TRACE("SecurityQos { Version=%d, Capabilities=0x%x, IdentityTracking=%d, ImpersonationLevel=%d", SecurityQos->Version, SecurityQos->Capabilities, SecurityQos->IdentityTracking, SecurityQos->ImpersonationType); if (SecurityQos->Version >= 2) { @@ -1647,7 +1647,7 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, { RPC_STATUS status; - TRACE("SecurityQos { Version=%d, Capabilties=0x%x, IdentityTracking=%d, ImpersonationLevel=%d", + TRACE("SecurityQos { Version=%d, Capabilities=0x%x, IdentityTracking=%d, ImpersonationLevel=%d", SecurityQos->Version, SecurityQos->Capabilities, SecurityQos->IdentityTracking, SecurityQos->ImpersonationType); if (SecurityQos->Version >= 2) { diff --git a/dlls/rpcrt4/rpc_message.c b/dlls/rpcrt4/rpc_message.c index 72f73b95f29..155d7ec04f4 100644 --- a/dlls/rpcrt4/rpc_message.c +++ b/dlls/rpcrt4/rpc_message.c @@ -606,7 +606,7 @@ static RPC_STATUS RPCRT4_ClientAuthorize(RpcConnection *conn, SecBuffer *in, } } - TRACE("cbBuffer = %ld\n", out->cbBuffer); + TRACE("cbBuffer = %d\n", out->cbBuffer); if (!continue_needed) { diff --git a/dlls/sane.ds/sane_main.c b/dlls/sane.ds/sane_main.c index ea1af0ea15e..468df3b55fd 100644 --- a/dlls/sane.ds/sane_main.c +++ b/dlls/sane.ds/sane_main.c @@ -543,7 +543,7 @@ DS_Entry ( pTW_IDENTITY pOrigin, { TW_UINT16 twRC = TWRC_SUCCESS; /* Return Code */ - TRACE("(DG=%ld DAT=%d MSG=%d)\n", DG, DAT, MSG); + TRACE("(DG=%d DAT=%d MSG=%d)\n", DG, DAT, MSG); switch (DG) { diff --git a/dlls/schannel/tests/main.c b/dlls/schannel/tests/main.c index 5575cc15b1d..9492a97760c 100644 --- a/dlls/schannel/tests/main.c +++ b/dlls/schannel/tests/main.c @@ -144,13 +144,13 @@ static void testGetInfo(void) /* First package: Unified */ status = pTables->GetInfo(&PackageInfo); ok(status == STATUS_SUCCESS, "status: 0x%x\n", status); - ok(PackageInfo.fCapabilities == 0x107b3, "fCapabilities: 0x%lx\n", + ok(PackageInfo.fCapabilities == 0x107b3, "fCapabilities: 0x%x\n", PackageInfo.fCapabilities); ok(PackageInfo.wVersion == 1, "wVersion: %d\n", PackageInfo.wVersion); ok(PackageInfo.wRPCID == 14, "wRPCID: %d\n", PackageInfo.wRPCID); ok(PackageInfo.cbMaxToken == 0x4000 || PackageInfo.cbMaxToken == 0x6000, /* Vista */ - "cbMaxToken: 0x%lx\n", + "cbMaxToken: 0x%x\n", PackageInfo.cbMaxToken); /* Second package: SChannel */ @@ -164,11 +164,11 @@ static void testGetInfo(void) if (status == STATUS_SUCCESS) { - ok(PackageInfo.fCapabilities == 0x107b3, "fCapabilities: 0x%lx\n", + ok(PackageInfo.fCapabilities == 0x107b3, "fCapabilities: 0x%x\n", PackageInfo.fCapabilities); ok(PackageInfo.wVersion == 1, "wVersion: %d\n", PackageInfo.wVersion); ok(PackageInfo.wRPCID == 14, "wRPCID: %d\n", PackageInfo.wRPCID); - ok(PackageInfo.cbMaxToken == 0x4000, "cbMaxToken: 0x%lx\n", + ok(PackageInfo.cbMaxToken == 0x4000, "cbMaxToken: 0x%x\n", PackageInfo.cbMaxToken); } } diff --git a/dlls/secur32/ntlm.c b/dlls/secur32/ntlm.c index f2b8b2a644f..bc44a454a5d 100644 --- a/dlls/secur32/ntlm.c +++ b/dlls/secur32/ntlm.c @@ -768,7 +768,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW( if(pInput->pBuffers[input_token_idx].cbBuffer > max_len) { - TRACE("pInput->pBuffers[%d].cbBuffer is: %ld\n", + TRACE("pInput->pBuffers[%d].cbBuffer is: %d\n", input_token_idx, pInput->pBuffers[input_token_idx].cbBuffer); ret = SEC_E_INVALID_TOKEN; diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c index ff60f540430..9b102fbb492 100644 --- a/dlls/secur32/schannel.c +++ b/dlls/secur32/schannel.c @@ -507,7 +507,7 @@ static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T mi if (!new_data) { - TRACE("Failed to resize %p from %ld to %ld\n", b->pvBuffer, b->cbBuffer, new_size); + TRACE("Failed to resize %p from %d to %ld\n", b->pvBuffer, b->cbBuffer, new_size); return; } @@ -539,7 +539,7 @@ static char *schan_get_buffer(const struct schan_transport *t, struct schan_buff } buffer = &s->desc->pBuffers[s->current_buffer_idx]; - TRACE("Using buffer %d: cbBuffer %ld, BufferType %#lx, pvBuffer %p\n", s->current_buffer_idx, buffer->cbBuffer, buffer->BufferType, buffer->pvBuffer); + TRACE("Using buffer %d: cbBuffer %d, BufferType %#x, pvBuffer %p\n", s->current_buffer_idx, buffer->cbBuffer, buffer->BufferType, buffer->pvBuffer); schan_resize_current_buffer(s, s->offset + *count); max_count = buffer->cbBuffer - s->offset; @@ -636,7 +636,7 @@ static void dump_buffer_desc(SecBufferDesc *desc) for (i = 0; i < desc->cBuffers; ++i) { SecBuffer *b = &desc->pBuffers[i]; - TRACE("\tbuffer %u: cbBuffer %ld, BufferType %#lx pvBuffer %p\n", i, b->cbBuffer, b->BufferType, b->pvBuffer); + TRACE("\tbuffer %u: cbBuffer %d, BufferType %#x pvBuffer %p\n", i, b->cbBuffer, b->BufferType, b->pvBuffer); } } diff --git a/dlls/secur32/tests/ntlm.c b/dlls/secur32/tests/ntlm.c index 4667ef0a2c6..370a7140588 100644 --- a/dlls/secur32/tests/ntlm.c +++ b/dlls/secur32/tests/ntlm.c @@ -447,7 +447,7 @@ static SECURITY_STATUS runClient(SspiData *sspi_data, BOOL first, ULONG data_rep ok(ret == SEC_E_BUFFER_TOO_SMALL, "expected SEC_E_BUFFER_TOO_SMALL, got %s\n", getSecError(ret)); ok(out_buf->pBuffers[0].cbBuffer == 0, - "InitializeSecurityContext set buffer size to %lu\n", out_buf->pBuffers[0].cbBuffer); + "InitializeSecurityContext set buffer size to %u\n", out_buf->pBuffers[0].cbBuffer); out_buf->pBuffers[0].cbBuffer = sspi_data->max_token; out_buf->pBuffers[0].BufferType = SECBUFFER_DATA; @@ -476,9 +476,9 @@ static SECURITY_STATUS runClient(SspiData *sspi_data, BOOL first, ULONG data_rep } ok(out_buf->pBuffers[0].BufferType == SECBUFFER_TOKEN, - "buffer type was changed from SECBUFFER_TOKEN to %ld\n", out_buf->pBuffers[0].BufferType); + "buffer type was changed from SECBUFFER_TOKEN to %d\n", out_buf->pBuffers[0].BufferType); ok(out_buf->pBuffers[0].cbBuffer < sspi_data->max_token, - "InitializeSecurityContext set buffer size to %lu\n", out_buf->pBuffers[0].cbBuffer); + "InitializeSecurityContext set buffer size to %u\n", out_buf->pBuffers[0].cbBuffer); return ret; } @@ -870,16 +870,16 @@ static void testAuth(ULONG data_rep, BOOL fake) "pQueryContextAttributesA(SECPKG_ATTR_SIZES) returned %s\n", getSecError(sec_status)); ok((ctxt_sizes.cbMaxToken == 1904) || (ctxt_sizes.cbMaxToken == 2888), - "cbMaxToken should be 1904 or 2888 but is %lu\n", + "cbMaxToken should be 1904 or 2888 but is %u\n", ctxt_sizes.cbMaxToken); ok(ctxt_sizes.cbMaxSignature == 16, - "cbMaxSignature should be 16 but is %lu\n", + "cbMaxSignature should be 16 but is %u\n", ctxt_sizes.cbMaxSignature); ok(ctxt_sizes.cbSecurityTrailer == 16, - "cbSecurityTrailer should be 16 but is %lu\n", + "cbSecurityTrailer should be 16 but is %u\n", ctxt_sizes.cbSecurityTrailer); ok(ctxt_sizes.cbBlockSize == 0, - "cbBlockSize should be 0 but is %lu\n", + "cbBlockSize should be 0 but is %u\n", ctxt_sizes.cbBlockSize); tAuthend: diff --git a/dlls/secur32/tests/schannel.c b/dlls/secur32/tests/schannel.c index a6032be8ff9..154ba971a52 100644 --- a/dlls/secur32/tests/schannel.c +++ b/dlls/secur32/tests/schannel.c @@ -249,7 +249,7 @@ static void testAcquireSecurityContext(void) NULL, NULL, NULL, NULL, &cred, &exp); ok(st == SEC_E_OK, "AcquireCredentialsHandleA failed: %08x\n", st); /* expriy is indeterminate in win2k3 */ - trace("expiry: %08lx%08lx\n", exp.HighPart, exp.LowPart); + trace("expiry: %08x%08x\n", exp.HighPart, exp.LowPart); pFreeCredentialsHandle(&cred); /* Bad version in SCHANNEL_CRED */ diff --git a/dlls/secur32/tests/secur32.c b/dlls/secur32/tests/secur32.c index 5bdb914e04c..39edeeab3fe 100644 --- a/dlls/secur32/tests/secur32.c +++ b/dlls/secur32/tests/secur32.c @@ -101,7 +101,7 @@ static void test_InitSecurityInterface(void) sftA = pInitSecurityInterfaceA(); ok(sftA != NULL, "pInitSecurityInterfaceA failed\n"); - ok(sftA->dwVersion == SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION, "wrong dwVersion %ld in security function table\n", sftA->dwVersion); + ok(sftA->dwVersion == SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION, "wrong dwVersion %d in security function table\n", sftA->dwVersion); ok(!sftA->Reserved2, "Reserved2 should be NULL instead of %p in security function table\n", sftA->Reserved2); ok(sftA->Reserved3 == sftA->EncryptMessage, "Reserved3 should be equal to EncryptMessage in the security function table\n"); ok(sftA->Reserved4 == sftA->DecryptMessage, "Reserved4 should be equal to DecryptMessage in the security function table\n"); @@ -114,7 +114,7 @@ static void test_InitSecurityInterface(void) sftW = pInitSecurityInterfaceW(); ok(sftW != NULL, "pInitSecurityInterfaceW failed\n"); - ok(sftW->dwVersion == SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION, "wrong dwVersion %ld in security function table\n", sftW->dwVersion); + ok(sftW->dwVersion == SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION, "wrong dwVersion %d in security function table\n", sftW->dwVersion); ok(!sftW->Reserved2, "Reserved2 should be NULL instead of %p in security function table\n", sftW->Reserved2); ok(sftW->Reserved3 == sftW->EncryptMessage, "Reserved3 should be equal to EncryptMessage in the security function table\n"); ok(sftW->Reserved4 == sftW->DecryptMessage, "Reserved4 should be equal to DecryptMessage in the security function table\n"); diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c index 656fb7898ec..00d3373bf87 100644 --- a/dlls/setupapi/parser.c +++ b/dlls/setupapi/parser.c @@ -1245,6 +1245,75 @@ void WINAPI SetupCloseInfFile( HINF hinf ) /*********************************************************************** + * SetupEnumInfSectionsA (SETUPAPI.@) + */ +BOOL WINAPI SetupEnumInfSectionsA( HINF hinf, UINT index, PSTR buffer, DWORD size, DWORD *need ) +{ + struct inf_file *file = hinf; + + for (file = hinf; file; file = file->next) + { + if (index < file->nb_sections) + { + DWORD len = WideCharToMultiByte( CP_ACP, 0, file->sections[index]->name, -1, + NULL, 0, NULL, NULL ); + if (*need) *need = len; + if (!buffer) + { + if (!size) return TRUE; + SetLastError( ERROR_INVALID_USER_BUFFER ); + return FALSE; + } + if (len > size) + { + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return FALSE; + } + WideCharToMultiByte( CP_ACP, 0, file->sections[index]->name, -1, buffer, size, NULL, NULL ); + return TRUE; + } + index -= file->nb_sections; + } + SetLastError( ERROR_NO_MORE_ITEMS ); + return FALSE; +} + + +/*********************************************************************** + * SetupEnumInfSectionsW (SETUPAPI.@) + */ +BOOL WINAPI SetupEnumInfSectionsW( HINF hinf, UINT index, PWSTR buffer, DWORD size, DWORD *need ) +{ + struct inf_file *file = hinf; + + for (file = hinf; file; file = file->next) + { + if (index < file->nb_sections) + { + DWORD len = strlenW( file->sections[index]->name ) + 1; + if (*need) *need = len; + if (!buffer) + { + if (!size) return TRUE; + SetLastError( ERROR_INVALID_USER_BUFFER ); + return FALSE; + } + if (len > size) + { + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return FALSE; + } + memcpy( buffer, file->sections[index]->name, len * sizeof(WCHAR) ); + return TRUE; + } + index -= file->nb_sections; + } + SetLastError( ERROR_NO_MORE_ITEMS ); + return FALSE; +} + + +/*********************************************************************** * SetupGetLineCountA (SETUPAPI.@) */ LONG WINAPI SetupGetLineCountA( HINF hinf, PCSTR name ) diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec index 2996803415d..03435bc2e90 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -389,6 +389,8 @@ @ stub SetupDiUnremoveDevice @ stub SetupDuplicateDiskSpaceListA @ stub SetupDuplicateDiskSpaceListW +@ stdcall SetupEnumInfSectionsA(long long ptr long ptr) +@ stdcall SetupEnumInfSectionsW(long long ptr long ptr) @ stdcall SetupFindFirstLineA(long str str ptr) @ stdcall SetupFindFirstLineW(long wstr wstr ptr) @ stdcall SetupFindNextLine(ptr ptr) diff --git a/dlls/setupapi/stringtable.c b/dlls/setupapi/stringtable.c index 2f43c5c1924..fe319b8733d 100644 --- a/dlls/setupapi/stringtable.c +++ b/dlls/setupapi/stringtable.c @@ -273,6 +273,7 @@ StringTableAddStringEx(HSTRING_TABLE hStringTable, LPWSTR lpString, return ~0u; } memcpy(pStringTable->pSlots[i].pData, lpExtraData, dwExtraDataSize); + pStringTable->pSlots[i].dwSize = dwExtraDataSize; pStringTable->dwUsedSlots++; return i + 1; } @@ -446,35 +447,40 @@ StringTableGetExtraData(HSTRING_TABLE hStringTable, /************************************************************************** - * StringTableLookUpString [SETUPAPI.@] + * StringTableLookUpStringEx [SETUPAPI.@] * - * Searches a string table for a given string. + * Searches a string table and extra data for a given string. * * PARAMS * hStringTable [I] Handle to the string table * lpString [I] String to be searched for * dwFlags [I] Flags * 1: case sensitive compare + * lpExtraData [O] Pointer to the buffer that receives the extra data + * lpReserved [I/O] Unused * * RETURNS * Success: String ID * Failure: -1 */ DWORD WINAPI -StringTableLookUpString(HSTRING_TABLE hStringTable, - LPWSTR lpString, - DWORD dwFlags) +StringTableLookUpStringEx(HSTRING_TABLE hStringTable, + LPWSTR lpString, + DWORD dwFlags, + LPVOID lpExtraData, + LPDWORD lpReserved) { PSTRING_TABLE pStringTable; DWORD i; - TRACE("%p %s %x\n", hStringTable, debugstr_w(lpString), dwFlags); + TRACE("%p %s %x %p, %p\n", hStringTable, debugstr_w(lpString), dwFlags, + lpExtraData, lpReserved); pStringTable = (PSTRING_TABLE)hStringTable; if (pStringTable == NULL) { ERR("Invalid hStringTable!\n"); - return (DWORD)-1; + return ~0u; } /* Search for existing string in the string table */ @@ -485,46 +491,48 @@ StringTableLookUpString(HSTRING_TABLE hStringTable, if (dwFlags & 1) { if (!lstrcmpW(pStringTable->pSlots[i].pString, lpString)) + { + if (lpExtraData) + memcpy(lpExtraData, pStringTable->pSlots[i].pData, (DWORD)lpReserved); return i + 1; + } } else { if (!lstrcmpiW(pStringTable->pSlots[i].pString, lpString)) + { + if (lpExtraData) + memcpy(lpExtraData, pStringTable->pSlots[i].pData, (DWORD)lpReserved); return i + 1; + } } } } - - return (DWORD)-1; + return ~0u; } /************************************************************************** - * StringTableLookUpStringEx [SETUPAPI.@] + * StringTableLookUpString [SETUPAPI.@] * - * Searches a string table and extra data for a given string. + * Searches a string table for a given string. * * PARAMS * hStringTable [I] Handle to the string table * lpString [I] String to be searched for * dwFlags [I] Flags * 1: case sensitive compare - * lpExtraData [O] Pointer to the buffer that receives the extra data - * lpReserved [I/O] Unused * * RETURNS * Success: String ID - * Failure: -1 + * Failure: ~0u */ DWORD WINAPI -StringTableLookUpStringEx(HSTRING_TABLE hStringTable, - LPWSTR lpString, - DWORD dwFlags, - LPVOID lpExtraData, - LPDWORD lpReserved) +StringTableLookUpString(HSTRING_TABLE hStringTable, + LPWSTR lpString, + DWORD dwFlags) { - FIXME("\n"); - return (DWORD)-1; + return StringTableLookUpStringEx(hStringTable, lpString, dwFlags, NULL, NULL); } diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c index 981dce38d0e..4936923531e 100644 --- a/dlls/setupapi/tests/install.c +++ b/dlls/setupapi/tests/install.c @@ -288,6 +288,13 @@ static void test_install_svc_from(void) infhandle = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL); SetLastError(0xdeadbeef); ret = SetupInstallServicesFromInfSectionA(infhandle, "Winetest.Services", 0); + if (!ret && GetLastError() == ERROR_ACCESS_DENIED) + { + skip("Not enough rights to install the service\n"); + SetupCloseInfFile(infhandle); + DeleteFile(inffile); + return; + } ok(ret, "Expected success\n"); ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %08x\n", GetLastError()); @@ -344,6 +351,11 @@ static void test_driver_install(void) skip("OpenSCManagerA is not implemented, we are most likely on win9x\n"); return; } + else if (!scm_handle && (GetLastError() == ERROR_ACCESS_DENIED)) + { + skip("Not enough rights to install the service\n"); + return; + } CloseServiceHandle(scm_handle); /* Place where we expect the driver to be installed */ diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c index 8869ca11d48..ddfd0f29a81 100644 --- a/dlls/setupapi/tests/parser.c +++ b/dlls/setupapi/tests/parser.c @@ -33,12 +33,14 @@ /* function pointers */ static HMODULE hSetupAPI; static LPCWSTR (WINAPI *pSetupGetField)(PINFCONTEXT,DWORD); +static BOOL (WINAPI *pSetupEnumInfSectionsA)( HINF hinf, UINT index, PSTR buffer, DWORD size, UINT *need ); static void init_function_pointers(void) { hSetupAPI = GetModuleHandleA("setupapi.dll"); - pSetupGetField = (void *)GetProcAddress(hSetupAPI, "pSetupGetField"); + pSetupGetField = (void *)GetProcAddress(hSetupAPI, "pSetupGetField"); + pSetupEnumInfSectionsA = (void *)GetProcAddress(hSetupAPI, "SetupEnumInfSectionsA" ); } static const char tmpfilename[] = ".\\tmp.inf"; @@ -246,6 +248,52 @@ static void test_section_names(void) } } +static void test_enum_sections(void) +{ + static const char *contents = STD_HEADER "[s1]\nfoo=bar\n[s2]\nbar=foo\n[s3]\n[strings]\na=b\n"; + + BOOL ret; + DWORD len; + HINF hinf; + UINT err, index; + char buffer[256]; + + if (!pSetupEnumInfSectionsA) + { + win_skip( "SetupEnumInfSectionsA not available\n" ); + return; + } + + hinf = test_file_contents( contents, &err ); + ok( hinf != NULL, "Expected valid INF file\n" ); + + for (index = 0; ; index++) + { + SetLastError( 0xdeadbeef ); + ret = pSetupEnumInfSectionsA( hinf, index, NULL, 0, &len ); + err = GetLastError(); + if (!ret && GetLastError() == ERROR_NO_MORE_ITEMS) break; + ok( ret, "SetupEnumInfSectionsA failed\n" ); + ok( len == 3 || len == 8, "wrong len %u\n", len ); + + SetLastError( 0xdeadbeef ); + ret = pSetupEnumInfSectionsA( hinf, index, NULL, sizeof(buffer), &len ); + err = GetLastError(); + ok( !ret, "SetupEnumInfSectionsA succeeded\n" ); + ok( err == ERROR_INVALID_USER_BUFFER, "wrong error %u\n", err ); + ok( len == 3 || len == 8, "wrong len %u\n", len ); + + SetLastError( 0xdeadbeef ); + ret = pSetupEnumInfSectionsA( hinf, index, buffer, sizeof(buffer), &len ); + ok( ret, "SetupEnumInfSectionsA failed err %u\n", GetLastError() ); + ok( len == 3 || len == 8, "wrong len %u\n", len ); + ok( !lstrcmpi( buffer, "version" ) || !lstrcmpi( buffer, "s1" ) || + !lstrcmpi( buffer, "s2" ) || !lstrcmpi( buffer, "s3" ) || !lstrcmpi( buffer, "strings" ), + "bad section '%s'\n", buffer ); + } + SetupCloseInfFile( hinf ); +} + /* Test various key and value names */ @@ -672,6 +720,7 @@ START_TEST(parser) init_function_pointers(); test_invalid_files(); test_section_names(); + test_enum_sections(); test_key_names(); test_close_inf_file(); test_pSetupGetField(); diff --git a/dlls/setupapi/tests/stringtable.c b/dlls/setupapi/tests/stringtable.c index 6a07b18a98f..a209f23f056 100644 --- a/dlls/setupapi/tests/stringtable.c +++ b/dlls/setupapi/tests/stringtable.c @@ -40,10 +40,13 @@ DECLARE_HANDLE(HSTRING_TABLE); #define ST_CASE_SENSITIVE_COMPARE 0x00000001 static DWORD (WINAPI *pStringTableAddString)(HSTRING_TABLE, LPWSTR, DWORD); +static DWORD (WINAPI *pStringTableAddStringEx)(HSTRING_TABLE, LPWSTR, DWORD, LPVOID, DWORD); static VOID (WINAPI *pStringTableDestroy)(HSTRING_TABLE); static HSTRING_TABLE (WINAPI *pStringTableDuplicate)(HSTRING_TABLE hStringTable); static HSTRING_TABLE (WINAPI *pStringTableInitialize)(VOID); +static HSTRING_TABLE (WINAPI *pStringTableInitializeEx)(DWORD, DWORD); static DWORD (WINAPI *pStringTableLookUpString)(HSTRING_TABLE, LPWSTR, DWORD); +static DWORD (WINAPI *pStringTableLookUpStringEx)(HSTRING_TABLE, LPWSTR, DWORD, LPVOID, LPDWORD); static LPWSTR (WINAPI *pStringTableStringFromId)(HSTRING_TABLE, DWORD); #if 0 static BOOL (WINAPI *pStringTableStringFromIdEx)(HSTRING_TABLE, DWORD, LPWSTR, LPDWORD); @@ -54,8 +57,6 @@ HMODULE hdll; static WCHAR string[] = {'s','t','r','i','n','g',0}; static WCHAR String[] = {'S','t','r','i','n','g',0}; static WCHAR foo[] = {'f','o','o',0}; -DWORD hstring, hString, hfoo; /* Handles pointing to our strings */ -HANDLE table, table2; /* Handles pointing to our tables */ static void load_it_up(void) { @@ -65,10 +66,18 @@ static void load_it_up(void) if (!pStringTableInitialize) pStringTableInitialize = (void*)GetProcAddress(hdll, "pSetupStringTableInitialize"); + pStringTableInitializeEx = (void*)GetProcAddress(hdll, "StringTableInitializeEx"); + if (!pStringTableInitializeEx) + pStringTableInitializeEx = (void*)GetProcAddress(hdll, "pSetupStringTableInitializeEx"); + pStringTableAddString = (void*)GetProcAddress(hdll, "StringTableAddString"); if (!pStringTableAddString) pStringTableAddString = (void*)GetProcAddress(hdll, "pSetupStringTableAddString"); + pStringTableAddStringEx = (void*)GetProcAddress(hdll, "StringTableAddStringEx"); + if (!pStringTableAddStringEx) + pStringTableAddStringEx = (void*)GetProcAddress(hdll, "pSetupStringTableAddStringEx"); + pStringTableDuplicate = (void*)GetProcAddress(hdll, "StringTableDuplicate"); if (!pStringTableDuplicate) pStringTableDuplicate = (void*)GetProcAddress(hdll, "pSetupStringTableDuplicate"); @@ -81,20 +90,22 @@ static void load_it_up(void) if (!pStringTableLookUpString) pStringTableLookUpString = (void*)GetProcAddress(hdll, "pSetupStringTableLookUpString"); + pStringTableLookUpStringEx = (void*)GetProcAddress(hdll, "StringTableLookUpStringEx"); + if (!pStringTableLookUpStringEx) + pStringTableLookUpStringEx = (void*)GetProcAddress(hdll, "pSetupStringTableLookUpStringEx"); + pStringTableStringFromId = (void*)GetProcAddress(hdll, "StringTableStringFromId"); if (!pStringTableStringFromId) pStringTableStringFromId = (void*)GetProcAddress(hdll, "pSetupStringTableStringFromId"); } -static void test_StringTableInitialize(void) -{ - table=pStringTableInitialize(); - ok(table!=NULL,"Failed to Initialize String Table\n"); -} - static void test_StringTableAddString(void) { - DWORD retval; + DWORD retval, hstring, hString, hfoo; + HANDLE table; + + table = pStringTableInitialize(); + ok(table != NULL, "failed to initialize string table\n"); /* case insensitive */ hstring=pStringTableAddString(table,string,0); @@ -111,18 +122,71 @@ static void test_StringTableAddString(void) /* case sensitive */ hString=pStringTableAddString(table,String,ST_CASE_SENSITIVE_COMPARE); ok(hstring!=hString,"String handle and string share same ID %x in Table\n", hstring); + + pStringTableDestroy(table); +} + +static void test_StringTableAddStringEx(void) +{ + DWORD retval, hstring, hString, hfoo; + HANDLE table; + + table = pStringTableInitialize(); + ok(table != NULL,"Failed to Initialize String Table\n"); + + /* case insensitive */ + hstring = pStringTableAddStringEx(table, string, 0, NULL, 0); + ok(hstring != ~0u, "Failed to add string to String Table\n"); + + retval = pStringTableAddStringEx(table, String, 0, NULL, 0); + ok(retval != ~0u, "Failed to add String to String Table\n"); + ok(hstring == retval, "string handle %x != String handle %x in String Table\n", hstring, retval); + + hfoo = pStringTableAddStringEx(table, foo, 0, NULL, 0); + ok(hfoo != ~0u, "Failed to add foo to String Table\n"); + ok(hfoo != hstring, "foo and string share the same ID %x in String Table\n", hfoo); + + /* case sensitive */ + hString = pStringTableAddStringEx(table, String, ST_CASE_SENSITIVE_COMPARE, NULL, 0); + ok(hstring != hString, "String handle and string share same ID %x in Table\n", hstring); + + pStringTableDestroy(table); } static void test_StringTableDuplicate(void) { + HANDLE table, table2; + + table = pStringTableInitialize(); + ok(table != NULL,"Failed to Initialize String Table\n"); + table2=pStringTableDuplicate(table); ok(table2!=NULL,"Failed to duplicate String Table\n"); + + pStringTableDestroy(table); + pStringTableDestroy(table2); } static void test_StringTableLookUpString(void) { - DWORD retval, retval2; - + DWORD retval, retval2, hstring, hString, hfoo; + HANDLE table, table2; + + table = pStringTableInitialize(); + ok(table != NULL,"failed to initialize string table\n"); + + hstring = pStringTableAddString(table, string, 0); + ok(hstring != ~0u, "failed to add 'string' to string table\n"); + + hString = pStringTableAddString(table, String, 0); + ok(hString != ~0u,"failed to add 'String' to string table\n"); + + hfoo = pStringTableAddString(table, foo, 0); + ok(hfoo != ~0u, "failed to add 'foo' to string table\n"); + + table2 = pStringTableDuplicate(table); + ok(table2 != NULL, "Failed to duplicate String Table\n"); + /* case insensitive */ retval=pStringTableLookUpString(table,string,0); ok(retval!=-1,"Failed find string in String Table 1\n"); @@ -152,35 +216,127 @@ static void test_StringTableLookUpString(void) retval=pStringTableLookUpString(table,string,ST_CASE_SENSITIVE_COMPARE); retval2=pStringTableLookUpString(table,String,ST_CASE_SENSITIVE_COMPARE); ok(retval!=retval2,"Lookup of string equals String in Table 1\n"); - ok(retval2==hString, + ok(retval==hString, + "Lookup for String (%x) does not match previous handle (%x) in String Table 1\n", + retval, hString); + + pStringTableDestroy(table); + pStringTableDestroy(table2); +} + +static void test_StringTableLookUpStringEx(void) +{ + static WCHAR uilevel[] = {'U','I','L','E','V','E','L',0}; + DWORD retval, retval2, hstring, hString, hfoo, data; + HANDLE table, table2; + char buffer[4]; + + table = pStringTableInitialize(); + ok(table != NULL,"Failed to Initialize String Table\n"); + + hstring = pStringTableAddString(table, string, 0); + ok(hstring != ~0u, "failed to add 'string' to string table\n"); + + hString = pStringTableAddString(table, String, 0); + ok(hString != ~0u,"failed to add 'String' to string table\n"); + + hfoo = pStringTableAddString(table, foo, 0); + ok(hfoo != ~0u, "failed to add 'foo' to string table\n"); + + table2 = pStringTableDuplicate(table); + ok(table2 != NULL, "Failed to duplicate String Table\n"); + + /* case insensitive */ + retval = pStringTableLookUpStringEx(table, string, 0, NULL, NULL); + ok(retval != ~0u, "Failed find string in String Table 1\n"); + ok(retval == hstring, + "Lookup for string (%x) does not match previous handle (%x) in String Table 1\n", + retval, hstring); + + retval = pStringTableLookUpStringEx(table2, string, 0, NULL, NULL); + ok(retval != ~0u, "Failed find string in String Table 2\n"); + + retval = pStringTableLookUpStringEx(table, String, 0, NULL, NULL); + ok(retval != ~0u, "Failed find String in String Table 1\n"); + + retval = pStringTableLookUpStringEx(table2, String, 0, NULL, NULL); + ok(retval != ~0u, "Failed find String in String Table 2\n"); + + retval=pStringTableLookUpStringEx(table, foo, 0, NULL, NULL); + ok(retval != ~0u, "Failed find foo in String Table 1\n"); + ok(retval == hfoo, + "Lookup for foo (%x) does not match previous handle (%x) in String Table 1\n", + retval, hfoo); + + retval = pStringTableLookUpStringEx(table2, foo, 0, NULL, NULL); + ok(retval != ~0u, "Failed find foo in String Table 2\n"); + + /* case sensitive */ + retval = pStringTableLookUpStringEx(table, string,ST_CASE_SENSITIVE_COMPARE, NULL, NULL); + retval2 = pStringTableLookUpStringEx(table, String, ST_CASE_SENSITIVE_COMPARE, NULL, NULL); + ok(retval != retval2, "Lookup of string equals String in Table 1\n"); + ok(retval == hString, "Lookup for String (%x) does not match previous handle (%x) in String Table 1\n", - retval, hString); + retval, hString); + + pStringTableDestroy(table); + + table = pStringTableInitializeEx(0x1000, 0); + ok(table != NULL, "failed to initialize string table\n"); + + data = 0xaaaaaaaa; + retval = pStringTableAddStringEx(table, uilevel, 0x5, &data, sizeof(data)); + ok(retval != ~0u, "failed to add 'UILEVEL' to string table\n"); + + memset(buffer, 0x55, sizeof(buffer)); + retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, (LPDWORD)0); + ok(retval != ~0u, "failed find 'UILEVEL' in string table\n"); + ok(memcmp(buffer, &data, 4), "unexpected data\n"); + + memset(buffer, 0x55, sizeof(buffer)); + retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, (LPDWORD)2); + ok(retval != ~0u, "failed find 'UILEVEL' in string table\n"); + ok(!memcmp(buffer, &data, 2), "unexpected data\n"); + + memset(buffer, 0x55, sizeof(buffer)); + retval = pStringTableLookUpStringEx(table, uilevel, ST_CASE_SENSITIVE_COMPARE, buffer, (LPDWORD)sizeof(buffer)); + ok(retval != ~0u, "failed find 'UILEVEL' in string table\n"); + ok(!memcmp(buffer, &data, 4), "unexpected data\n"); + + pStringTableDestroy(table); } static void test_StringTableStringFromId(void) { + HANDLE table; + DWORD hstring; WCHAR *string2; int result; + table = pStringTableInitialize(); + ok(table != NULL,"Failed to Initialize String Table\n"); + + hstring = pStringTableAddString(table, string, 0); + ok(hstring != ~0u,"failed to add 'string' to string table\n"); + /* correct */ string2=pStringTableStringFromId(table,pStringTableLookUpString(table,string,0)); ok(string2!=NULL,"Failed to look up string by ID from String Table\n"); result=lstrcmpiW(string, string2); ok(result==0,"StringID %p does not match requested StringID %p\n",string,string2); + + pStringTableDestroy(table); } START_TEST(stringtable) { load_it_up(); - test_StringTableInitialize(); test_StringTableAddString(); + test_StringTableAddStringEx(); test_StringTableDuplicate(); test_StringTableLookUpString(); + test_StringTableLookUpStringEx(); test_StringTableStringFromId(); - - /* assume we can always destroy */ - pStringTableDestroy(table); - pStringTableDestroy(table2); } diff --git a/dlls/sfc/sfc.spec b/dlls/sfc/sfc.spec index 8afb51502fc..04307d2da57 100644 --- a/dlls/sfc/sfc.spec +++ b/dlls/sfc/sfc.spec @@ -1,3 +1,15 @@ +1 stub @ +2 stub @ +3 stdcall @(long) SFC_3 +4 stub @ +5 stub @ +6 stub @ +7 stub @ +8 stub @ +9 stub @ @ stub SfcGetNextProtectedFile @ stdcall SfcIsFileProtected(ptr wstr) sfc_os.SfcIsFileProtected @ stdcall SfcIsKeyProtected(long wstr long) sfc_os.SfcIsKeyProtected +@ stub SfcWLEventLogoff +@ stub SfcWLEventLogon +@ stub SfpVerifyFile diff --git a/dlls/sfc/sfc_main.c b/dlls/sfc/sfc_main.c index 58957c89371..c715867883d 100644 --- a/dlls/sfc/sfc_main.c +++ b/dlls/sfc/sfc_main.c @@ -52,3 +52,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) } return TRUE; } + +DWORD WINAPI SFC_3(DWORD unknown) +{ + FIXME("%x\n", unknown); + return 0; +} diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index 262e7a60a94..6adced60deb 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -33,7 +33,12 @@ #endif /* Error codes could be pre-Win32 */ -#define DE_OPCANCELLED 0x75 +#define DE_SAMEFILE 0x71 +#define DE_MANYSRC1DEST 0x72 +#define DE_OPCANCELLED 0x75 +#define DE_DESTSUBTREE 0x76 +#define DE_INVALIDFILES 0x7C +#define DE_DESTSAMETREE 0x7D #define expect_retval(ret, ret_prewin32)\ ok(retval == ret ||\ broken(retval == ret_prewin32),\ @@ -664,8 +669,9 @@ static void test_rename(void) shfo.pTo = "a.txt\0"; retval = SHFileOperationA(&shfo); ok(retval == ERROR_GEN_FAILURE || + retval == DE_MANYSRC1DEST || /* Vista */ broken(!retval), /* Win9x */ - "Expected ERROR_GEN_FAILURE, got %d\n", retval); + "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST, got %d\n", retval); ok(file_exists("test1.txt"), "Expected test1.txt to exist\n"); ok(file_exists("test2.txt"), "Expected test2.txt to exist\n"); ok(!file_exists("a.txt"), "Expected a.txt to not exist\n"); @@ -674,7 +680,9 @@ static void test_rename(void) shfo.pFrom = "idontexist\0"; shfo.pTo = "newfile\0"; retval = SHFileOperationA(&shfo); - ok(retval == 1026, "Expected 1026, got %d\n", retval); + ok(retval == 1026 || + retval == ERROR_FILE_NOT_FOUND, /* Vista */ + "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", retval); ok(!file_exists("newfile"), "Expected newfile to not exist\n"); /* pTo already exist */ @@ -693,7 +701,9 @@ static void test_rename(void) /* pFrom is empty */ shfo.pFrom = "\0"; retval = SHFileOperationA(&shfo); - ok(retval == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", retval); + ok(retval == ERROR_ACCESS_DENIED || + retval == ERROR_INVALID_TARGET_HANDLE, /* Vista */ + "Expected ERROR_ACCESS_DENIED or ERROR_INVALID_TARGET_HANDLE, got %d\n", retval); /* pFrom is NULL, commented out because it crashes on nt 4.0 */ #if 0 @@ -712,6 +722,7 @@ static void test_copy(void) FILEOP_FLAGS tmp_flags; DWORD retval; LPSTR ptr; + BOOL on_nt4 = FALSE; shfo.hwnd = NULL; shfo.wFunc = FO_COPY; @@ -724,19 +735,19 @@ static void test_copy(void) set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); retval = SHFileOperationA(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("test6.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ - ok(file_exists("test6.txt\\test1.txt"), "The file is not copied - many files " + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not copied - many files " "are specified as a target\n"); - DeleteFileA("test6.txt\\test1.txt"); DeleteFileA("test6.txt\\test2.txt"); RemoveDirectoryA("test6.txt\\test4.txt"); RemoveDirectoryA("test6.txt"); } else { - ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval); + expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); ok(!file_exists("test6.txt"), "The file is copied - many files are " "specified as a target\n"); } @@ -757,21 +768,20 @@ static void test_copy(void) set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0"); retval = SHFileOperationA(&shfo2); - if (retval == ERROR_NO_VOLUME_LABEL) + if (dir_exists("test6.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ - ok(file_exists("test6.txt\\test1.txt"), "The file is not copied - many files " + ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval); + ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not copied - many files " "are specified as a target\n"); - ok(file_exists("test7.txt\\test2.txt"), "The file is not copied - many files " - "are specified as a target\n"); - DeleteFileA("test6.txt\\test1.txt"); - DeleteFileA("test7.txt\\test2.txt"); RemoveDirectoryA("test6.txt"); + ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not copied - many files " + "are specified as a target\n"); RemoveDirectoryA("test7.txt"); } else { - ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval); + expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); ok(!file_exists("test6.txt"), "The file is copied - many files are " "specified as a target\n"); } @@ -882,9 +892,10 @@ static void test_copy(void) shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0"; shfo.fFlags |= FOF_NOERRORUI | FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("testdir2\\a.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFile("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n"); RemoveDirectory("testdir2\\a.txt"); ok(DeleteFile("testdir2\\b.txt\\test2.txt"), "Expected testdir2\\b.txt\\test2.txt to exist\n"); @@ -896,7 +907,9 @@ static void test_copy(void) else { expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); - ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); + ok(shfo.fAnyOperationsAborted || + broken(!shfo.fAnyOperationsAborted), /* NT4 */ + "Expected aborted operations\n"); ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n"); } @@ -905,9 +918,10 @@ static void test_copy(void) shfo.pTo = "e.txt\0f.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); - if (retval == ERROR_NO_MORE_SEARCH_HANDLES) + if (dir_exists("e.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == DE_SAMEFILE, "Expected DE_SAMEFILE, got %d\n", retval); ok(DeleteFile("e.txt\\test1.txt"), "Expected e.txt\\test1.txt to exist\n"); RemoveDirectory("e.txt"); ok(DeleteFile("f.txt\\test2.txt"), "Expected f.txt\\test2.txt to exist\n"); @@ -916,7 +930,9 @@ static void test_copy(void) else { expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); - ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); + ok(shfo.fAnyOperationsAborted || + broken(!shfo.fAnyOperationsAborted), /* NT4 */ + "Expected aborted operations\n"); ok(!file_exists("e.txt"), "Expected e.txt to not exist\n"); } @@ -936,9 +952,10 @@ static void test_copy(void) shfo.fAnyOperationsAborted = FALSE; shfo.fFlags &= ~FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("a.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFile("a.txt\\test1.txt"), "Expected a.txt\\test1.txt to exist\n"); ok(DeleteFile("a.txt\\test2.txt"), "Expected a.txt\\test2.txt to exist\n"); ok(DeleteFile("a.txt\\test3.txt"), "Expected a.txt\\test3.txt to exist\n"); @@ -966,7 +983,7 @@ static void test_copy(void) retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n"); - ok(!file_exists("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to not exist\n"); + ok(!dir_exists("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to not exist\n"); /* try a glob with FOF_MULTIDESTFILES and the same number * of dest files that we would expect @@ -977,9 +994,10 @@ static void test_copy(void) shfo.fFlags &= ~FOF_FILESONLY; shfo.fFlags |= FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("testdir2\\a.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFile("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n"); ok(DeleteFile("testdir2\\a.txt\\test2.txt"), "Expected testdir2\\a.txt\\test2.txt to exist\n"); ok(DeleteFile("testdir2\\a.txt\\test3.txt"), "Expected testdir2\\a.txt\\test3.txt to exist\n"); @@ -989,7 +1007,9 @@ static void test_copy(void) else { expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); - ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); + ok(shfo.fAnyOperationsAborted || + broken(!shfo.fAnyOperationsAborted), /* NT4 */ + "Expected aborted operations\n"); ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n"); } ok(!RemoveDirectory("b.txt"), "b.txt should not exist\n"); @@ -1001,17 +1021,29 @@ static void test_copy(void) shfo.pTo = "b.txt\0c.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); - ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't copy any files */ + ok(!file_exists("b.txt"), "Expected b.txt to not exist\n"); + /* Needed to skip some tests */ + win_skip("Skipping some tests on NT4\n"); + on_nt4 = TRUE; + } + else + { + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); + } ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n"); /* copy two file to three others, all fail */ shfo.pFrom = "test1.txt\0test2.txt\0"; shfo.pTo = "b.txt\0c.txt\0d.txt\0"; retval = SHFileOperation(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("b.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFile("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n"); RemoveDirectory("b.txt"); ok(DeleteFile("c.txt\\test2.txt"), "Expected c.txt\\test2.txt to exist\n"); @@ -1020,7 +1052,9 @@ static void test_copy(void) else { expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); - ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); + ok(shfo.fAnyOperationsAborted || + broken(!shfo.fAnyOperationsAborted), /* NT4 */ + "Expected aborted operations\n"); ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n"); } @@ -1029,9 +1063,10 @@ static void test_copy(void) shfo.pTo = "b.txt\0c.txt\0d.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("b.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFile("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n"); RemoveDirectory("b.txt"); ok(RemoveDirectory("c.txt\\test4.txt"), "Expected c.txt\\test4.txt to exist\n"); @@ -1040,7 +1075,9 @@ static void test_copy(void) else { expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); - ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); + ok(shfo.fAnyOperationsAborted || + broken(!shfo.fAnyOperationsAborted), /* NT4 */ + "Expected aborted operations\n"); ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n"); ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n"); } @@ -1053,7 +1090,7 @@ static void test_copy(void) shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); - ok(DeleteFile("testdir2\\test1.txt"), "Expected newdir\\test1.txt to exist\n"); + ok(DeleteFile("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n"); ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n"); ok(RemoveDirectory("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to exist\n"); @@ -1069,9 +1106,10 @@ static void test_copy(void) shfo.pFrom = "test4.txt\\a.txt\0test4.txt\0"; shfo.pTo = "nonexistent\0"; retval = SHFileOperation(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("nonexistent")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFile("nonexistent\\test4.txt\\a.txt"), "Expected nonexistent\\test4.txt\\a.txt to exist\n"); RemoveDirectory("nonexistent\\test4.txt"); ok(DeleteFile("nonexistent\\a.txt"), "Expected nonexistent\\a.txt to exist\n"); @@ -1080,7 +1118,9 @@ static void test_copy(void) else { expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); - ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); + ok(shfo.fAnyOperationsAborted || + broken(!shfo.fAnyOperationsAborted), /* NT4 */ + "Expected aborted operations\n"); ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n"); } DeleteFile("test4.txt\\a.txt"); @@ -1091,10 +1131,17 @@ static void test_copy(void) shfo.fAnyOperationsAborted = FALSE; shfo.fFlags = FOF_NOERRORUI | FOF_MULTIDESTFILES; retval = SHFileOperation(&shfo); - ok(retval == ERROR_NO_MORE_SEARCH_HANDLES, - "Expected ERROR_NO_MORE_SEARCH_HANDLES, got %d\n", retval); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't copy any files */ + ok(!file_exists("b.txt"), "Expected b.txt to not exist\n"); + } + else + { + ok(retval == DE_SAMEFILE, "Expected DE_SAMEFILE, got %d\n", retval); + ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); + } ok(!shfo.fAnyOperationsAborted, "Expected no operations to be aborted\n"); - ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); ok(!file_exists("c.txt"), "Expected c.txt to not exist\n"); /* destination is same as source directory */ @@ -1102,10 +1149,18 @@ static void test_copy(void) shfo.pTo = "b.txt\0test4.txt\0c.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); - ok(retval == ERROR_SUCCESS || - retval == ERROR_NO_VOLUME_LABEL, /* Vista */ - "Expected ERROR_SUCCESS or ERROR_NO_VOLUME_LABEL, got %d\n", retval); - ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't copy any files */ + ok(!file_exists("b.txt"), "Expected b.txt to not exist\n"); + } + else + { + ok(retval == ERROR_SUCCESS || + retval == DE_DESTSAMETREE, /* Vista */ + "Expected ERROR_SUCCESS or DE_DESTSAMETREE, got %d\n", retval); + ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); + } ok(!file_exists("c.txt"), "Expected c.txt to not exist\n"); /* copy a directory into itself, error displayed in UI */ @@ -1115,8 +1170,8 @@ static void test_copy(void) shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS || - retval == ERROR_INVALID_VERIFY_SWITCH, /* Vista */ - "Expected ERROR_SUCCESS or ERROR_INVALID_VERIFY_SWITCH, got %d\n", retval); + retval == DE_DESTSUBTREE, /* Vista */ + "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval); ok(!RemoveDirectory("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n"); /* copy a directory to itself, error displayed in UI */ @@ -1125,8 +1180,8 @@ static void test_copy(void) shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS || - retval == ERROR_INVALID_VERIFY_SWITCH, /* Vista */ - "Expected ERROR_SUCCESS or ERROR_INVALID_VERIFY_SWITCH, got %d\n", retval); + retval == DE_DESTSUBTREE, /* Vista */ + "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval); /* copy a file into a directory, and the directory into itself */ shfo.pFrom = "test1.txt\0test4.txt\0"; @@ -1135,8 +1190,8 @@ static void test_copy(void) shfo.fFlags |= FOF_NOCONFIRMATION; retval = SHFileOperation(&shfo); ok(retval == ERROR_SUCCESS || - retval == ERROR_INVALID_VERIFY_SWITCH, /* Vista */ - "Expected ERROR_SUCCESS or ERROR_INVALID_VERIFY_SWITCH, got %d\n", retval); + retval == DE_DESTSUBTREE, /* Vista */ + "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval); ok(DeleteFile("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n"); /* copy a file to a file, and the directory into itself */ @@ -1144,9 +1199,10 @@ static void test_copy(void) shfo.pTo = "test4.txt\\a.txt\0"; shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); - if (retval == ERROR_INVALID_VERIFY_SWITCH) + if (dir_exists("test4.txt\\a.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == DE_DESTSUBTREE, "Expected DE_DESTSUBTREE, got %d\n", retval); ok(DeleteFile("test4.txt\\a.txt\\test1.txt"), "Expected test4.txt\\a.txt\\test1.txt to exist\n"); RemoveDirectory("test4.txt\\a.txt"); } @@ -1162,7 +1218,8 @@ static void test_copy(void) shfo.fAnyOperationsAborted = FALSE; retval = SHFileOperation(&shfo); ok(retval == 1026 || - retval == ERROR_FILE_NOT_FOUND, /* Vista */ + retval == ERROR_FILE_NOT_FOUND || /* Vista */ + broken(retval == ERROR_SUCCESS), /* NT4 */ "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", retval); ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n"); ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n"); @@ -1170,30 +1227,36 @@ static void test_copy(void) /* Overwrite tests */ clean_after_shfo_tests(); init_shfo_tests(); - shfo.fFlags = FOF_NOCONFIRMATION; - shfo.pFrom = "test1.txt\0"; - shfo.pTo = "test2.txt\0"; - shfo.fAnyOperationsAborted = FALSE; - /* without FOF_NOCONFIRMATION the confirmation is Yes/No */ - retval = SHFileOperation(&shfo); - ok(retval == 0, "Expected 0, got %d\n", retval); - ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n"); + if (!on_nt4) + { + /* NT4 would throw up some dialog boxes and doesn't copy files that are needed + * in subsequent tests. + */ + shfo.fFlags = FOF_NOCONFIRMATION; + shfo.pFrom = "test1.txt\0"; + shfo.pTo = "test2.txt\0"; + shfo.fAnyOperationsAborted = FALSE; + /* without FOF_NOCONFIRMATION the confirmation is Yes/No */ + retval = SHFileOperation(&shfo); + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n"); - shfo.pFrom = "test3.txt\0test1.txt\0"; - shfo.pTo = "test2.txt\0one.txt\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_MULTIDESTFILES; - /* without FOF_NOCONFIRMATION the confirmation is Yes/Yes to All/No/Cancel */ - retval = SHFileOperation(&shfo); - ok(retval == 0, "Expected 0, got %d\n", retval); - ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n"); + shfo.pFrom = "test3.txt\0test1.txt\0"; + shfo.pTo = "test2.txt\0one.txt\0"; + shfo.fFlags = FOF_NOCONFIRMATION | FOF_MULTIDESTFILES; + /* without FOF_NOCONFIRMATION the confirmation is Yes/Yes to All/No/Cancel */ + retval = SHFileOperation(&shfo); + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n"); - shfo.pFrom = "one.txt\0"; - shfo.pTo = "testdir2\0"; - shfo.fFlags = FOF_NOCONFIRMATION; - /* without FOF_NOCONFIRMATION the confirmation is Yes/No */ - retval = SHFileOperation(&shfo); - ok(retval == 0, "Expected 0, got %d\n", retval); - ok(file_has_content("testdir2\\one.txt", "test1.txt\n"), "The file was not copied\n"); + shfo.pFrom = "one.txt\0"; + shfo.pTo = "testdir2\0"; + shfo.fFlags = FOF_NOCONFIRMATION; + /* without FOF_NOCONFIRMATION the confirmation is Yes/No */ + retval = SHFileOperation(&shfo); + ok(retval == 0, "Expected 0, got %d\n", retval); + ok(file_has_content("testdir2\\one.txt", "test1.txt\n"), "The file was not copied\n"); + } createTestFile("test4.txt\\test1.txt"); shfo.pFrom = "test4.txt\0"; @@ -1217,10 +1280,11 @@ static void test_copy(void) shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; retval = SHFileOperation(&shfo); ok(retval == 1148 || retval == 1026 || - retval == ERROR_ACCESS_DENIED, /* win2k */ - "Expected 1148, 1026 or ERROR_ACCESS_DENIED, got %d\n", retval); + retval == ERROR_ACCESS_DENIED || /* win2k */ + retval == DE_INVALIDFILES, /* Vista */ + "Unexpected return value, got %d\n", retval); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); - if (file_exists("two.txt")) + if (dir_exists("two.txt")) /* Vista and W2K8 (broken or new behavior ?) */ ok(RemoveDirectory("two.txt"), "Expected two.txt to exist\n"); else @@ -1236,9 +1300,17 @@ static void test_copy(void) shfo.pTo = to; shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; retval = SHFileOperation(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't copy any files */ + ok(!file_exists("two.txt"), "Expected two.txt to not exist\n"); + } + else + { + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(DeleteFileA("two.txt"), "Expected file to exist\n"); + } ok(DeleteFileA("one.txt"), "Expected file to exist\n"); - ok(DeleteFileA("two.txt"), "Expected file to exist\n"); createTestFile("one.txt"); @@ -1247,9 +1319,17 @@ static void test_copy(void) shfo.pTo = "two.txt\0three.txt\0"; shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; retval = SHFileOperation(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't copy any files */ + ok(!file_exists("two.txt"), "Expected two.txt to not exist\n"); + } + else + { + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(DeleteFileA("two.txt"), "Expected file to exist\n"); + } ok(DeleteFileA("one.txt"), "Expected file to exist\n"); - ok(DeleteFileA("two.txt"), "Expected file to exist\n"); createTestFile("one.txt"); @@ -1265,10 +1345,11 @@ static void test_copy(void) shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; retval = SHFileOperation(&shfo); ok(retval == 1148 || retval == 1026 || - retval == ERROR_ACCESS_DENIED, /* win2k */ - "Expected 1148, 1026 or ERROR_ACCESS_DENIED, got %d\n", retval); + retval == ERROR_ACCESS_DENIED || /* win2k */ + retval == DE_INVALIDFILES, /* Vista */ + "Unexpected return value, got %d\n", retval); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); - if (file_exists("two.txt")) + if (dir_exists("two.txt")) /* Vista and W2K8 (broken or new behavior ?) */ ok(RemoveDirectory("two.txt"), "Expected two.txt to exist\n"); else @@ -1285,9 +1366,17 @@ static void test_copy(void) shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; retval = SHFileOperation(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't copy any files */ + ok(!file_exists("two.txt"), "Expected two.txt to not exist\n"); + } + else + { + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(DeleteFileA("two.txt"), "Expected file to exist\n"); + } ok(DeleteFileA("one.txt"), "Expected file to exist\n"); - ok(DeleteFileA("two.txt"), "Expected file to exist\n"); createTestFile("one.txt"); createTestFile("two.txt"); @@ -1303,9 +1392,10 @@ static void test_copy(void) shfo.pTo = to; shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; retval = SHFileOperation(&shfo); - if (retval == ERROR_SUCCESS) + if (dir_exists("threedir")) { /* Vista and W2K8 (broken or new behavior ?) */ + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n"); ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n"); ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n"); @@ -1397,7 +1487,7 @@ static void test_copy(void) ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n"); - if (file_exists("fourdir")) + if (dir_exists("fourdir")) { /* Vista and W2K8 (broken or new behavior ?) */ ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n"); @@ -1426,13 +1516,18 @@ static void test_copy(void) FOF_SILENT | FOF_NOERRORUI; retval = SHFileOperation(&shfo); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); + if (file_exists("threedir\\threedir")) + { + /* NT4 */ + ok(DeleteFileA("threedir\\threedir"), "Expected file to exist\n"); + } ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n"); ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n"); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n"); ok(!DeleteFileA("fourdir"), "Expected file to not exist\n"); - ok(!RemoveDirectoryA("fourdir"), "Expected dit to not exist\n"); + ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n"); createTestFile("one.txt"); createTestFile("two.txt"); @@ -1451,7 +1546,7 @@ static void test_copy(void) ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n"); - if (file_exists("fourdir")) + if (dir_exists("fourdir")) { /* Vista and W2K8 (broken or new behavior ?) */ ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n"); @@ -1529,11 +1624,10 @@ static void test_move(void) set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); ok(!SHFileOperationA(&shfo2), "Move many files\n"); - ok(file_exists("test6.txt"), "The file is moved - many files are " + ok(DeleteFileA("test6.txt"), "The file is not moved - many files are " "specified as a target\n"); - DeleteFileA("test6.txt"); - DeleteFileA("test7.txt"); - RemoveDirectoryA("test8.txt"); + ok(DeleteFileA("test7.txt"), "The file is not moved\n"); + ok(RemoveDirectoryA("test8.txt"), "The directory is not moved\n"); init_shfo_tests(); @@ -1544,7 +1638,7 @@ static void test_move(void) if (dir_exists("test6.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ - ok(retval == ERROR_NO_VOLUME_LABEL, "Expected ERROR_NO_VOLUME_LABEL, got %d\n", retval); + ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval); ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n"); RemoveDirectoryA("test6.txt"); ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n"); @@ -1552,7 +1646,7 @@ static void test_move(void) } else { - ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval); + expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); ok(!file_exists("test6.txt"), "The file is not moved - many files are " "specified as a target\n"); } @@ -1580,7 +1674,7 @@ static void test_move(void) } else { - ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval); + expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); ok(file_exists("test1.txt"), "The file is moved. Many files are specified\n"); ok(dir_exists("test4.txt"), "The directory is moved. Many files are specified\n"); } @@ -1608,9 +1702,18 @@ static void test_move(void) shfo.pFrom = "test1.txt\0"; shfo.pTo = "a.txt\0b.txt\0"; retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); - ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n"); - ok(DeleteFile("a.txt"), "Expected a.txt to exist\n"); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't move any files */ + ok(!file_exists("a.txt"), "Expected a.txt to not exist\n"); + DeleteFileA("test1.txt"); + } + else + { + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n"); + ok(DeleteFile("a.txt"), "Expected a.txt to exist\n"); + } ok(!file_exists("b.txt"), "Expected b.txt to not exist\n"); /* move two files to one other */ @@ -1640,8 +1743,8 @@ static void test_move(void) shfo.pTo = "test4.txt\\b.txt\0"; retval = SHFileOperationA(&shfo); ok(retval == ERROR_SUCCESS || - retval == ERROR_INVALID_VERIFY_SWITCH, /* Vista */ - "Expected ERROR_SUCCESS, got %d\n", retval); + retval == DE_DESTSUBTREE, /* Vista */ + "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval); ok(!RemoveDirectory("test4.txt\\b.txt"), "Expected test4.txt\\b.txt to not exist\n"); ok(dir_exists("test4.txt"), "Expected test4.txt to exist\n"); @@ -1673,8 +1776,8 @@ static void test_move(void) if (dir_exists("d.txt")) { /* Vista and W2K8 (broken or new behavior ?) */ - ok(retval == ERROR_NO_MORE_SEARCH_HANDLES, - "Expected ERROR_NO_MORE_SEARCH_HANDLES, got %d\n", retval); + ok(retval == DE_SAMEFILE, + "Expected DE_SAMEFILE, got %d\n", retval); ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n"); ok(!file_exists("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to not exist\n"); RemoveDirectoryA("d.txt"); @@ -1707,9 +1810,17 @@ static void test_move(void) /* try to overwrite an existing file */ shfo.pTo = "test3.txt\0"; retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); - ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n"); - ok(file_exists("test3.txt"), "Expected test3.txt to exist\n"); + if (retval == DE_OPCANCELLED) + { + /* NT4 fails and doesn't move any files */ + ok(file_exists("test2.txt"), "Expected test2.txt to exist\n"); + } + else + { + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n"); + ok(file_exists("test3.txt"), "Expected test3.txt to exist\n"); + } } static void test_sh_create_dir(void) @@ -1771,16 +1882,22 @@ static void test_sh_path_prepare(void) /* file exists, SHPPFW_NONE */ set_curr_dir_path(path, "test1.txt\0"); res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE); - ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res); + ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY) || + res == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), /* Vista */ + "Unexpected result : 0x%08x\n", res); /* file exists, SHPPFW_DIRCREATE */ res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE); - ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res); + ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY) || + res == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), /* Vista */ + "Unexpected result : 0x%08x\n", res); /* file exists, SHPPFW_NONE, trailing \ */ set_curr_dir_path(path, "test1.txt\\\0"); res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE); - ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res); + ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY) || + res == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), /* Vista */ + "Unexpected result : 0x%08x\n", res); /* relative path exists, SHPPFW_DIRCREATE */ res = pSHPathPrepareForWriteA(0, 0, ".\\testdir2", SHPPFW_DIRCREATE); diff --git a/dlls/twain_32/twain32_main.c b/dlls/twain_32/twain32_main.c index 3239ec57e68..9eb27547f14 100644 --- a/dlls/twain_32/twain32_main.c +++ b/dlls/twain_32/twain32_main.c @@ -159,7 +159,7 @@ DSM_Entry (pTW_IDENTITY pOrigin, { TW_UINT16 twRC = TWRC_SUCCESS; /* Return Code */ - TRACE("(DG=%ld DAT=%d MSG=%d)\n", DG, DAT, MSG); + TRACE("(DG=%d DAT=%d MSG=%d)\n", DG, DAT, MSG); if (pDest) { @@ -172,7 +172,7 @@ DSM_Entry (pTW_IDENTITY pOrigin, return TWRC_FAILURE; } DSM_twCC = TWCC_SUCCESS; - TRACE("Forwarding %ld/%d/%d/%p to DS.\n", DG, DAT, MSG, pData); + TRACE("Forwarding %d/%d/%d/%p to DS.\n", DG, DAT, MSG, pData); twRC = pSource->dsEntry(pOrigin, DG, DAT, MSG, pData); TRACE("return value is %d\n", twRC); return twRC; @@ -183,7 +183,7 @@ DSM_Entry (pTW_IDENTITY pOrigin, twRC = TWAIN_SourceManagerHandler (pOrigin, DAT, MSG, pData); break; default: - FIXME("The DSM does not handle DG %ld\n", DG); + FIXME("The DSM does not handle DG %d\n", DG); DSM_twCC = TWCC_BADPROTOCOL; twRC = TWRC_FAILURE; } diff --git a/dlls/updspapi/Makefile.in b/dlls/updspapi/Makefile.in new file mode 100644 index 00000000000..8917f492e4d --- /dev/null +++ b/dlls/updspapi/Makefile.in @@ -0,0 +1,10 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +MODULE = updspapi.dll +IMPORTS = setupapi kernel32 + +@MAKE_DLL_RULES@ + +@DEPENDENCIES@ # everything below this line is overwritten by make depend diff --git a/dlls/updspapi/updspapi.spec b/dlls/updspapi/updspapi.spec new file mode 100644 index 00000000000..eb47bc42d2b --- /dev/null +++ b/dlls/updspapi/updspapi.spec @@ -0,0 +1,70 @@ +@ stdcall UpdSpCloseFileQueue(ptr) setupapi.SetupCloseFileQueue +@ stdcall UpdSpCloseInfFile(long) setupapi.SetupCloseInfFile +@ stdcall UpdSpCommitFileQueueA(long long ptr ptr) setupapi.SetupCommitFileQueueA +@ stdcall UpdSpCommitFileQueueW(long long ptr ptr) setupapi.SetupCommitFileQueueW +@ stdcall UpdSpCopyErrorA(long str str str str str long long str long ptr) setupapi.SetupCopyErrorA +@ stdcall UpdSpCopyErrorW(long wstr wstr wstr wstr wstr long long wstr long ptr) setupapi.SetupCopyErrorW +@ stdcall UpdSpDecompressOrCopyFileA(str str ptr) setupapi.SetupDecompressOrCopyFileA +@ stdcall UpdSpDecompressOrCopyFileW(wstr wstr ptr) setupapi.SetupDecompressOrCopyFileW +@ stdcall UpdSpDefaultQueueCallbackA(ptr long long long) setupapi.SetupDefaultQueueCallbackA +@ stdcall UpdSpDefaultQueueCallbackW(ptr long long long) setupapi.SetupDefaultQueueCallbackW +@ stdcall UpdSpDeleteErrorA(long str str long long) setupapi.SetupDeleteErrorA +@ stdcall UpdSpDeleteErrorW(long wstr wstr long long) setupapi.SetupDeleteErrorW +@ stdcall UpdSpEnumInfSectionsA(long long ptr long ptr) setupapi.SetupEnumInfSectionsA +@ stdcall UpdSpEnumInfSectionsW(long long ptr long ptr) setupapi.SetupEnumInfSectionsW +@ stdcall UpdSpFindFirstLineA(long str str ptr) setupapi.SetupFindFirstLineA +@ stdcall UpdSpFindFirstLineW(long wstr wstr ptr) setupapi.SetupFindFirstLineW +@ stdcall UpdSpFindNextLine(ptr ptr) setupapi.SetupFindNextLine +@ stdcall UpdSpFindNextMatchLineA(ptr str ptr) setupapi.SetupFindNextMatchLineA +@ stdcall UpdSpFindNextMatchLineW(ptr wstr ptr) setupapi.SetupFindNextMatchLineW +@ stdcall UpdSpGetBinaryField(ptr long ptr long ptr) setupapi.SetupGetBinaryField +@ stdcall UpdSpGetFieldCount(ptr) setupapi.SetupGetFieldCount +@ stdcall UpdSpGetIntField(ptr long ptr) setupapi.SetupGetIntField +@ stdcall UpdSpGetLineByIndexA(long str long ptr) setupapi.SetupGetLineByIndexA +@ stdcall UpdSpGetLineByIndexW(long wstr long ptr) setupapi.SetupGetLineByIndexW +@ stdcall UpdSpGetLineCountA(long str) setupapi.SetupGetLineCountA +@ stdcall UpdSpGetLineCountW(long wstr) setupapi.SetupGetLineCountW +@ stdcall UpdSpGetLineTextA(ptr long str str ptr long ptr) setupapi.SetupGetLineTextA +@ stdcall UpdSpGetLineTextW(ptr long wstr wstr ptr long ptr) setupapi.SetupGetLineTextW +@ stdcall UpdSpGetMultiSzFieldA(ptr long ptr long ptr) setupapi.SetupGetMultiSzFieldA +@ stdcall UpdSpGetMultiSzFieldW(ptr long ptr long ptr) setupapi.SetupGetMultiSzFieldW +@ stdcall UpdSpGetSourceFileLocationA(ptr ptr str ptr ptr long ptr) setupapi.SetupGetSourceFileLocationA +@ stdcall UpdSpGetSourceFileLocationW(ptr ptr wstr ptr ptr long ptr) setupapi.SetupGetSourceFileLocationW +@ stdcall UpdSpGetSourceInfoA(ptr long long ptr long ptr) setupapi.SetupGetSourceInfoA +@ stdcall UpdSpGetSourceInfoW(ptr long long ptr long ptr) setupapi.SetupGetSourceInfoW +@ stdcall UpdSpGetStringFieldA(ptr long ptr long ptr) setupapi.SetupGetStringFieldA +@ stdcall UpdSpGetStringFieldW(ptr long ptr long ptr) setupapi.SetupGetStringFieldW +@ stdcall UpdSpGetTargetPathA(ptr ptr str ptr long ptr) setupapi.SetupGetTargetPathA +@ stdcall UpdSpGetTargetPathW(ptr ptr wstr ptr long ptr) setupapi.SetupGetTargetPathW +@ stdcall UpdSpInitDefaultQueueCallback(long) setupapi.SetupInitDefaultQueueCallback +@ stdcall UpdSpInitDefaultQueueCallbackEx(long long long long ptr) setupapi.SetupInitDefaultQueueCallbackEx +@ stdcall UpdSpInstallFilesFromInfSectionA(long long long str str long) setupapi.SetupInstallFilesFromInfSectionA +@ stdcall UpdSpInstallFilesFromInfSectionW(long long long wstr wstr long) setupapi.SetupInstallFilesFromInfSectionW +@ stdcall UpdSpInstallFromInfSectionA(long long str long long str long ptr ptr long ptr) setupapi.SetupInstallFromInfSectionA +@ stdcall UpdSpInstallFromInfSectionW(long long wstr long long wstr long ptr ptr long ptr) setupapi.SetupInstallFromInfSectionW +@ stdcall UpdSpIterateCabinetA(str long ptr ptr) setupapi.SetupIterateCabinetA +@ stdcall UpdSpIterateCabinetW(wstr long ptr ptr) setupapi.SetupIterateCabinetW +@ stdcall UpdSpOpenAppendInfFileA(str long ptr) setupapi.SetupOpenAppendInfFileA +@ stdcall UpdSpOpenAppendInfFileW(wstr long ptr) setupapi.SetupOpenAppendInfFileW +@ stdcall UpdSpOpenFileQueue() setupapi.SetupOpenFileQueue +@ stdcall UpdSpOpenInfFileA(str str long ptr) setupapi.SetupOpenInfFileA +@ stdcall UpdSpOpenInfFileW(wstr wstr long ptr) setupapi.SetupOpenInfFileW +@ stdcall UpdSpPromptForDiskA(ptr str str str str str long ptr long ptr) setupapi.SetupPromptForDiskA +@ stdcall UpdSpPromptForDiskW(ptr wstr wstr wstr wstr wstr long ptr long ptr) setupapi.SetupPromptForDiskW +@ stdcall UpdSpQueueCopyA(long str str str str str str str long) setupapi.SetupQueueCopyA +@ stdcall UpdSpQueueCopySectionA(long str long long str long) setupapi.SetupQueueCopySectionA +@ stdcall UpdSpQueueCopySectionW(long wstr long long wstr long) setupapi.SetupQueueCopySectionW +@ stdcall UpdSpQueueCopyW(long wstr wstr wstr wstr wstr wstr wstr long) setupapi.SetupQueueCopyW +@ stdcall UpdSpQueueDeleteA(long str str) setupapi.SetupQueueDeleteA +@ stdcall UpdSpQueueDeleteSectionA(long long long str) setupapi.SetupQueueDeleteSectionA +@ stdcall UpdSpQueueDeleteSectionW(long long long wstr) setupapi.SetupQueueDeleteSectionW +@ stdcall UpdSpQueueDeleteW(long wstr wstr) setupapi.SetupQueueDeleteW +@ stdcall UpdSpScanFileQueueA(long long long ptr ptr ptr) setupapi.SetupScanFileQueueA +@ stdcall UpdSpScanFileQueueW(long long long ptr ptr ptr) setupapi.SetupScanFileQueueW +@ stdcall UpdSpSetDirectoryIdA(long long str) setupapi.SetupSetDirectoryIdA +@ stdcall UpdSpSetDirectoryIdW(long long wstr) setupapi.SetupSetDirectoryIdW +@ stub UpdSpSetDynamicStringA +@ stub UpdSpSetDynamicStringExA +@ stub UpdSpSetDynamicStringExW +@ stub UpdSpSetDynamicStringW +@ stdcall UpdSpTermDefaultQueueCallback(ptr) setupapi.SetupTermDefaultQueueCallback diff --git a/dlls/urlmon/tests/url.c b/dlls/urlmon/tests/url.c index 830ef1a1f49..2428dc03396 100644 --- a/dlls/urlmon/tests/url.c +++ b/dlls/urlmon/tests/url.c @@ -1248,6 +1248,9 @@ static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallback *iface, ULONG ulP ok(0, "unexpected call\n"); ok(szStatusText == NULL, "Expected szStatusText to be NULL\n"); break; + case BINDSTATUS_PROXYDETECTING: + trace("BINDSTATUS_PROXYDETECTING\n"); + break; default: ok(0, "unexpected code %d\n", ulStatusCode); }; @@ -1768,7 +1771,7 @@ static void test_CreateAsyncBindCtxEx(void) IBindCtx_Release(bctx2); } -static void test_bscholder(IBindStatusCallback *holder) +static BOOL test_bscholder(IBindStatusCallback *holder) { IServiceProvider *serv_prov; IHttpNegotiate *http_negotiate, *http_negotiate_serv; @@ -1776,6 +1779,7 @@ static void test_bscholder(IBindStatusCallback *holder) IAuthenticate *authenticate, *authenticate_serv; IInternetProtocol *protocol; BINDINFO bindinfo = {sizeof(bindinfo)}; + BOOL ret = TRUE; LPWSTR wstr; DWORD dw; HRESULT hres; @@ -1847,6 +1851,7 @@ static void test_bscholder(IBindStatusCallback *holder) IHttpNegotiate_Release(http_negotiate2); }else { skip("Could not get IHttpNegotiate2\n"); + ret = FALSE; } SET_EXPECT(OnProgress_FINDINGRESOURCE); @@ -1897,12 +1902,14 @@ static void test_bscholder(IBindStatusCallback *holder) CHECK_CALLED(QueryService_IInternetProtocol); IServiceProvider_Release(serv_prov); + return ret; } -static void test_RegisterBindStatusCallback(void) +static BOOL test_RegisterBindStatusCallback(void) { IBindStatusCallback *prevbsc, *clb; IBindCtx *bindctx; + BOOL ret = TRUE; IUnknown *unk; HRESULT hres; @@ -1933,7 +1940,8 @@ static void test_RegisterBindStatusCallback(void) ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres); ok(clb != &bsc, "bsc == clb\n"); - test_bscholder(clb); + if(!test_bscholder(clb)) + ret = FALSE; IBindStatusCallback_Release(clb); @@ -1958,6 +1966,7 @@ static void test_RegisterBindStatusCallback(void) ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres); IBindCtx_Release(bindctx); + return ret; } #define BINDTEST_EMULATE 1 @@ -2570,110 +2579,112 @@ START_TEST(url) test_create(); test_CreateAsyncBindCtx(); test_CreateAsyncBindCtxEx(); - test_RegisterBindStatusCallback(); - test_BindToStorage_fail(); - trace("synchronous http test (COM not initialised)...\n"); - test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); + if(!test_RegisterBindStatusCallback()) { + test_BindToStorage_fail(); + + trace("synchronous http test (COM not initialised)...\n"); + test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); - CoInitialize(NULL); + CoInitialize(NULL); - trace("synchronous http test...\n"); - test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); + trace("synchronous http test...\n"); + test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); - trace("synchronous http test (to object)...\n"); - test_BindToObject(HTTP_TEST, FALSE); + trace("synchronous http test (to object)...\n"); + test_BindToObject(HTTP_TEST, FALSE); - trace("synchronous file test...\n"); - test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM); + trace("synchronous file test...\n"); + test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM); - trace("synchronous file test (to object)...\n"); - test_BindToObject(FILE_TEST, FALSE); + trace("synchronous file test (to object)...\n"); + test_BindToObject(FILE_TEST, FALSE); - bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; + bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; - trace("http test...\n"); - test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); + trace("http test...\n"); + test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); - trace("http test (to file)...\n"); - test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE); + trace("http test (to file)...\n"); + test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE); - trace("http test (to object)...\n"); - test_BindToObject(HTTP_TEST, FALSE); + trace("http test (to object)...\n"); + test_BindToObject(HTTP_TEST, FALSE); - trace("http test (short response)...\n"); - http_is_first = TRUE; - urls[HTTP_TEST] = SHORT_RESPONSE_URL; - test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); + trace("http test (short response)...\n"); + http_is_first = TRUE; + urls[HTTP_TEST] = SHORT_RESPONSE_URL; + test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM); - trace("http test (short response, to object)...\n"); - test_BindToObject(HTTP_TEST, FALSE); + trace("http test (short response, to object)...\n"); + test_BindToObject(HTTP_TEST, FALSE); - trace("emulated http test...\n"); - test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM); + trace("emulated http test...\n"); + test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM); - trace("emulated http test (to object)...\n"); - test_BindToObject(HTTP_TEST, TRUE); + trace("emulated http test (to object)...\n"); + test_BindToObject(HTTP_TEST, TRUE); - trace("emulated http test (to file)...\n"); - test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE); + trace("emulated http test (to file)...\n"); + test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE); - trace("about test...\n"); - test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM); + trace("about test...\n"); + test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM); - trace("about test (to file)...\n"); - test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE); + trace("about test (to file)...\n"); + test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE); - trace("about test (to object)...\n"); - test_BindToObject(ABOUT_TEST, FALSE); + trace("about test (to object)...\n"); + test_BindToObject(ABOUT_TEST, FALSE); - trace("emulated about test...\n"); - test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM); + trace("emulated about test...\n"); + test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM); - trace("emulated about test (to file)...\n"); - test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE); + trace("emulated about test (to file)...\n"); + test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE); - trace("emulated about test (to object)...\n"); - test_BindToObject(ABOUT_TEST, TRUE); + trace("emulated about test (to object)...\n"); + test_BindToObject(ABOUT_TEST, TRUE); - trace("file test...\n"); - test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM); + trace("file test...\n"); + test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM); - trace("file test (to file)...\n"); - test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE); + trace("file test (to file)...\n"); + test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE); - trace("file test (to object)...\n"); - test_BindToObject(FILE_TEST, FALSE); + trace("file test (to object)...\n"); + test_BindToObject(FILE_TEST, FALSE); - trace("emulated file test...\n"); - test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM); + trace("emulated file test...\n"); + test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM); - trace("emulated file test (to file)...\n"); - test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE); + trace("emulated file test (to file)...\n"); + test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE); - trace("emulated file test (to object)...\n"); - test_BindToObject(FILE_TEST, TRUE); + trace("emulated file test (to object)...\n"); + test_BindToObject(FILE_TEST, TRUE); - trace("emulated its test...\n"); - test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM); + trace("emulated its test...\n"); + test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM); - trace("emulated its test (to file)...\n"); - test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE); + trace("emulated its test (to file)...\n"); + test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE); - trace("emulated mk test...\n"); - test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM); + trace("emulated mk test...\n"); + test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM); - trace("test URLDownloadToFile for file protocol...\n"); - test_URLDownloadToFile(FILE_TEST, FALSE); + trace("test URLDownloadToFile for file protocol...\n"); + test_URLDownloadToFile(FILE_TEST, FALSE); - trace("test URLDownloadToFile for emulated file protocol...\n"); - test_URLDownloadToFile(FILE_TEST, TRUE); + trace("test URLDownloadToFile for emulated file protocol...\n"); + test_URLDownloadToFile(FILE_TEST, TRUE); - trace("test URLDownloadToFile for http protocol...\n"); - test_URLDownloadToFile(HTTP_TEST, FALSE); + trace("test URLDownloadToFile for http protocol...\n"); + test_URLDownloadToFile(HTTP_TEST, FALSE); - trace("test failures...\n"); - test_BindToStorage_fail(); + trace("test failures...\n"); + test_BindToStorage_fail(); + } DeleteFileA(wszIndexHtmlA); CloseHandle(complete_event); diff --git a/dlls/usp10/tests/usp10.c b/dlls/usp10/tests/usp10.c index c63c6c8a70c..1dba6829ac7 100644 --- a/dlls/usp10/tests/usp10.c +++ b/dlls/usp10/tests/usp10.c @@ -1382,6 +1382,87 @@ static void test_ScriptGetProperties(void) ok(hr == S_OK, "ScriptGetProperties failed: 0x%08x\n", hr); } +static void test_ScriptBreak(void) +{ + static const WCHAR test[] = {' ','\r','\n',0}; + SCRIPT_ITEM items[4]; + SCRIPT_LOGATTR la; + HRESULT hr; + + hr = ScriptItemize(test, 3, 4, NULL, NULL, items, NULL); + ok(!hr, "ScriptItemize should return S_OK not %08x\n", hr); + + memset(&la, 0, sizeof(la)); + hr = ScriptBreak(test, 1, &items[0].a, &la); + ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr); + + ok(!la.fSoftBreak, "fSoftBreak set\n"); + ok(la.fWhiteSpace, "fWhiteSpace not set\n"); + ok(la.fCharStop, "fCharStop not set\n"); + ok(!la.fWordStop, "fWordStop set\n"); + ok(!la.fInvalid, "fInvalid set\n"); + ok(!la.fReserved, "fReserved set\n"); + + memset(&la, 0, sizeof(la)); + hr = ScriptBreak(test + 1, 1, &items[1].a, &la); + ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr); + + ok(!la.fSoftBreak, "fSoftBreak set\n"); + ok(!la.fWhiteSpace, "fWhiteSpace set\n"); + ok(la.fCharStop, "fCharStop not set\n"); + ok(!la.fWordStop, "fWordStop set\n"); + ok(!la.fInvalid, "fInvalid set\n"); + ok(!la.fReserved, "fReserved set\n"); + + memset(&la, 0, sizeof(la)); + hr = ScriptBreak(test + 2, 1, &items[2].a, &la); + ok(!hr, "ScriptBreak should return S_OK not %08x\n", hr); + + ok(!la.fSoftBreak, "fSoftBreak set\n"); + ok(!la.fWhiteSpace, "fWhiteSpace set\n"); + ok(la.fCharStop, "fCharStop not set\n"); + ok(!la.fWordStop, "fWordStop set\n"); + ok(!la.fInvalid, "fInvalid set\n"); + ok(!la.fReserved, "fReserved set\n"); +} + +static void test_newlines(void) +{ + static const WCHAR test1[] = {'t','e','x','t','\r','t','e','x','t',0}; + static const WCHAR test2[] = {'t','e','x','t','\n','t','e','x','t',0}; + static const WCHAR test3[] = {'t','e','x','t','\r','\n','t','e','x','t',0}; + static const WCHAR test4[] = {'t','e','x','t','\n','\r','t','e','x','t',0}; + static const WCHAR test5[] = {'1','2','3','4','\n','\r','1','2','3','4',0}; + SCRIPT_ITEM items[5]; + HRESULT hr; + int count; + + count = 0; + hr = ScriptItemize(test1, lstrlenW(test1), 5, NULL, NULL, items, &count); + ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr); + ok(count == 3, "got %d expected 3\n", count); + + count = 0; + hr = ScriptItemize(test2, lstrlenW(test2), 5, NULL, NULL, items, &count); + ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr); + ok(count == 3, "got %d expected 3\n", count); + + count = 0; + hr = ScriptItemize(test3, lstrlenW(test3), 5, NULL, NULL, items, &count); + ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr); + ok(count == 4, "got %d expected 4\n", count); + + count = 0; + hr = ScriptItemize(test4, lstrlenW(test4), 5, NULL, NULL, items, &count); + ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr); + ok(count == 4, "got %d expected 4\n", count); + + count = 0; + hr = ScriptItemize(test5, lstrlenW(test5), 5, NULL, NULL, items, &count); + ok(hr == S_OK, "ScriptItemize failed: 0x%08x\n", hr); + ok(count == 4, "got %d expected 4\n", count); +} + START_TEST(usp10) { HWND hwnd; @@ -1426,6 +1507,8 @@ START_TEST(usp10) test_ScriptLayout(); test_digit_substitution(); test_ScriptGetProperties(); + test_ScriptBreak(); + test_newlines(); ReleaseDC(hwnd, hdc); DestroyWindow(hwnd); diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index 4af14aecc86..fc2f8e9bb4e 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -519,6 +519,8 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem #define Script_Arabic 6 #define Script_Latin 1 #define Script_Numeric 5 +#define Script_CR 22 +#define Script_LF 23 int cnt = 0, index = 0; int New_Script = SCRIPT_UNDEFINED; @@ -532,6 +534,12 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem pItems[index].iCharPos = 0; memset(&pItems[index].a, 0, sizeof(SCRIPT_ANALYSIS)); + if (pwcInChars[cnt] == '\r') + pItems[index].a.eScript = Script_CR; + else + if (pwcInChars[cnt] == '\n') + pItems[index].a.eScript = Script_LF; + else if (pwcInChars[cnt] >= Numeric_start && pwcInChars[cnt] <= Numeric_stop) pItems[index].a.eScript = Script_Numeric; else @@ -546,10 +554,16 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem TRACE("New_Script=%d, eScript=%d index=%d cnt=%d iCharPos=%d\n", New_Script, pItems[index].a.eScript, index, cnt, - pItems[index].iCharPos = cnt); + pItems[index].iCharPos); - for (cnt=0; cnt < cInChars; cnt++) + for (cnt=1; cnt < cInChars; cnt++) { + if (pwcInChars[cnt] == '\r') + New_Script = Script_CR; + else + if (pwcInChars[cnt] == '\n') + New_Script = Script_LF; + else if ((pwcInChars[cnt] >= Numeric_start && pwcInChars[cnt] <= Numeric_stop) || (New_Script == Script_Numeric && pwcInChars[cnt] == Numeric_space)) New_Script = Script_Numeric; @@ -558,7 +572,8 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem || (New_Script == Script_Arabic && pwcInChars[cnt] == Numeric_space)) New_Script = Script_Arabic; else - if ((WCHAR) pwcInChars[cnt] >= Latin_start && (WCHAR) pwcInChars[cnt] <= Latin_stop) + if ((pwcInChars[cnt] >= Latin_start && pwcInChars[cnt] <= Latin_stop) + || (New_Script == Script_Latin && pwcInChars[cnt] == Numeric_space)) New_Script = Script_Latin; else New_Script = SCRIPT_UNDEFINED; @@ -580,7 +595,7 @@ HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItem if (New_Script == Script_Arabic) pItems[index].a.s.uBidiLevel = 1; - TRACE("index=%d cnt=%d iCharPos=%d\n", index, cnt, pItems[index].iCharPos = cnt); + TRACE("index=%d cnt=%d iCharPos=%d\n", index, cnt, pItems[index].iCharPos); } } @@ -1041,8 +1056,14 @@ HRESULT WINAPI ScriptBreak(const WCHAR *chars, int count, const SCRIPT_ANALYSIS memset(&la[i], 0, sizeof(SCRIPT_LOGATTR)); /* FIXME: set the other flags */ - la[i].fWhiteSpace = isspaceW(chars[i]); + la[i].fWhiteSpace = (chars[i] == ' '); la[i].fCharStop = 1; + + if (i > 0 && la[i - 1].fWhiteSpace) + { + la[i].fSoftBreak = 1; + la[i].fWordStop = 1; + } } return S_OK; } @@ -1266,7 +1287,9 @@ HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars, HRESULT hr; unsigned int i; - TRACE("(%p, %p, %p, %d, %d, %p)\n", hdc, psc, pwcChars, cChars, cMaxGlyphs, psa); + TRACE("(%p, %p, %s, %d, %d, %p, %p, %p, %p, %p)\n", hdc, psc, debugstr_wn(pwcChars, cChars), + cChars, cMaxGlyphs, psa, pwOutGlyphs, pwLogClust, psva, pcGlyphs); + if (psa) TRACE("psa values: %d, %d, %d, %d, %d, %d, %d\n", psa->eScript, psa->fRTL, psa->fLayoutRTL, psa->fLinkBefore, psa->fLinkAfter, psa->fLogicalOrder, psa->fNoGlyphIndex); @@ -1301,10 +1324,12 @@ HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars, for (i = 0; i < cChars; i++) { /* FIXME: set to better values */ - psva[i].uJustification = 2; + psva[i].uJustification = (pwcChars[i] == ' ') ? SCRIPT_JUSTIFY_BLANK : SCRIPT_JUSTIFY_CHARACTER; psva[i].fClusterStart = 1; psva[i].fDiacritic = 0; psva[i].fZeroWidth = 0; + psva[i].fReserved = 0; + psva[i].fShapeReserved = 0; if (pwLogClust) pwLogClust[i] = i; } @@ -1339,8 +1364,8 @@ HRESULT WINAPI ScriptPlace(HDC hdc, SCRIPT_CACHE *psc, const WORD *pwGlyphs, HRESULT hr; int i; - TRACE("(%p, %p, %p, %s, %d, %p, %p, %p)\n", hdc, psc, pwGlyphs, - debugstr_wn(pwGlyphs, cGlyphs), cGlyphs, psva, psa, piAdvance); + TRACE("(%p, %p, %p, %d, %p, %p, %p, %p, %p)\n", hdc, psc, pwGlyphs, cGlyphs, psva, psa, + piAdvance, pGoffset, pABC); if (!psva) return E_INVALIDARG; if ((hr = init_script_cache(hdc, psc)) != S_OK) return hr; diff --git a/dlls/w32skrnl/w32skernel.c b/dlls/w32skrnl/w32skernel.c index 988a47ea63e..761d3539652 100644 --- a/dlls/w32skrnl/w32skernel.c +++ b/dlls/w32skrnl/w32skernel.c @@ -41,16 +41,6 @@ LPSTR WINAPI GetWin32sDirectory(void) } /*********************************************************************** - * _GetThunkBuff - * FIXME: ??? - */ -SEGPTR WINAPI _GetThunkBuff(void) -{ - return 0; -} - - -/*********************************************************************** * GetCurrentTask32 (W32SKRNL.3) */ HTASK16 WINAPI GetCurrentTask32(void) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 3a5493dec28..efb3cb8007e 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -2421,7 +2421,7 @@ static void state_arb_specularenable(DWORD state, IWineD3DStateBlockImpl *stateb } static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); IWineD3DDeviceImpl *device = stateblock->wineD3DDevice; float mat[2][2]; @@ -2456,7 +2456,7 @@ static void set_bumpmat_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, W } static void tex_bumpenvlum_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); IWineD3DDeviceImpl *device = stateblock->wineD3DDevice; float param[4]; diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index aaecafff993..8b20f9bd17a 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -853,7 +853,7 @@ static void state_texfactor_atifs(DWORD state, IWineD3DStateBlockImpl *statebloc } static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); float mat[2][2]; mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index b5f2b3ecb9e..688b2f28c83 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -416,7 +416,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, } object->num_contained_ps_consts_b = MAX_CONST_B; for(i = 0; i < MAX_TEXTURES; i++) { - for(j = 1; j <= WINED3D_HIGHEST_TEXTURE_STATE; j++) { + for (j = 0; j <= WINED3D_HIGHEST_TEXTURE_STATE; ++j) + { object->contained_tss_states[object->num_contained_tss_states].stage = i; object->contained_tss_states[object->num_contained_tss_states].state = j; object->num_contained_tss_states++; @@ -477,9 +478,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, object->num_contained_render_states = NUM_SAVEDPIXELSTATES_R; for (j = 0; j < MAX_TEXTURES; j++) { for (i = 0; i < NUM_SAVEDPIXELSTATES_T; i++) { - object->changed.textureState[j][SavedPixelStates_T[i]] = TRUE; + DWORD state = SavedPixelStates_T[i]; + object->changed.textureState[j] |= 1 << state; object->contained_tss_states[object->num_contained_tss_states].stage = j; - object->contained_tss_states[object->num_contained_tss_states].state = SavedPixelStates_T[i]; + object->contained_tss_states[object->num_contained_tss_states].state = state; object->num_contained_tss_states++; } } @@ -536,9 +538,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface, object->num_contained_render_states = NUM_SAVEDVERTEXSTATES_R; for (j = 0; j < MAX_TEXTURES; j++) { for (i = 0; i < NUM_SAVEDVERTEXSTATES_T; i++) { - object->changed.textureState[j][SavedVertexStates_T[i]] = TRUE; + DWORD state = SavedVertexStates_T[i]; + object->changed.textureState[j] |= 1 << state; object->contained_tss_states[object->num_contained_tss_states].stage = j; - object->contained_tss_states[object->num_contained_tss_states].state = SavedVertexStates_T[i]; + object->contained_tss_states[object->num_contained_tss_states].state = state; object->num_contained_tss_states++; } } @@ -3619,7 +3622,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexShaderConstantF( static inline void markTextureStagesDirty(IWineD3DDeviceImpl *This, DWORD stage) { DWORD i; - for(i = 0; i < WINED3D_HIGHEST_TEXTURE_STATE; i++) { + for(i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i) + { IWineD3DDeviceImpl_MarkStateDirty(This, STATE_TEXTURESTAGE(stage, i)); } } @@ -4446,7 +4450,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if return WINED3D_OK; } - This->updateStateBlock->changed.textureState[Stage][Type] = TRUE; + This->updateStateBlock->changed.textureState[Stage] |= 1 << Type; This->updateStateBlock->textureState[Stage][Type] = Value; if (This->isRecordingState) { @@ -4814,12 +4818,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW } } for(i = 0; i < MAX_TEXTURES; i++) { - for(j = 1; j <= WINED3D_HIGHEST_TEXTURE_STATE; j++) { - if(object->changed.textureState[i][j]) { - object->contained_tss_states[object->num_contained_tss_states].stage = i; - object->contained_tss_states[object->num_contained_tss_states].state = j; - object->num_contained_tss_states++; - } + DWORD map = object->changed.textureState[i]; + + for(j = 0; map; map >>= 1, ++j) + { + if (!(map & 1)) continue; + + object->contained_tss_states[object->num_contained_tss_states].stage = i; + object->contained_tss_states[object->num_contained_tss_states].state = j; + ++object->num_contained_tss_states; } } for(i = 0; i < MAX_COMBINED_SAMPLERS; i++){ @@ -5134,7 +5141,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, WI IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); } /* Account for the loading offset due to index buffers. Instead of reloading all sources correct it with the startvertex parameter */ - drawPrimitive(iface, PrimitiveType, PrimitiveCount, StartVertex, 0/* NumVertices */, -1 /* indxStart */, + drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0/* NumVertices */, StartVertex /* start_idx */, 0 /* indxSize */, NULL /* indxData */, 0 /* minIndex */); return WINED3D_OK; } @@ -5187,7 +5194,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice * IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); } - drawPrimitive(iface, PrimitiveType, primCount, 0, NumVertices, startIndex, + drawPrimitive(iface, PrimitiveType, primCount, NumVertices, startIndex, idxStride, vbo ? NULL : ((IWineD3DIndexBufferImpl *) pIB)->resource.allocatedMemory, minIndex); return WINED3D_OK; @@ -5220,8 +5227,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, /* TODO: Only mark dirty if drawing from a different UP address */ IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC); - drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* start vertex */, 0 /* NumVertices */, - 0 /* indxStart*/, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */); + drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* NumVertices */, + 0 /* start_idx */, 0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */); /* MSDN specifies stream zero settings must be set to NULL */ This->stateBlock->streamStride[0] = 0; @@ -5274,7 +5281,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice * IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VDECL); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER); - drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* vertexStart */, NumVertices, 0 /* indxStart */, idxStride, pIndexData, MinVertexIndex); + drawPrimitive(iface, PrimitiveType, PrimitiveCount, NumVertices, 0 /* start_idx */, idxStride, pIndexData, MinVertexIndex); /* MSDN specifies stream zero settings and index buffer must be set to NULL */ This->stateBlock->streamSource[0] = NULL; @@ -5305,7 +5312,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *if IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER); This->stateBlock->baseVertexIndex = 0; This->up_strided = DrawPrimStrideData; - drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0, 0, 0, 0, NULL, 0); + drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0, 0, 0, NULL, 0); This->up_strided = NULL; return WINED3D_OK; } @@ -5327,7 +5334,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDev This->stateBlock->streamIsUP = TRUE; This->stateBlock->baseVertexIndex = 0; This->up_strided = DrawPrimStrideData; - drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* startvertexidx */, 0 /* numindices */, 0 /* startidx */, idxSize, pIndexData, 0 /* minindex */); + drawPrimitive(iface, PrimitiveType, PrimitiveCount, 0 /* numindices */, 0 /* start_idx */, idxSize, pIndexData, 0 /* minindex */); This->up_strided = NULL; return WINED3D_OK; } diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index fd06d777cee..f7443f21b0d 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -253,8 +253,9 @@ void primitiveDeclarationConvertToStridedData( } } -static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum glPrimitiveType, - const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) { +static void drawStridedFast(IWineD3DDevice *iface, UINT numberOfVertices, GLenum glPrimitiveType, + const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) +{ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; if (idxSize != 0 /* This crashes sometimes!*/) { @@ -273,8 +274,8 @@ static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum #endif } else { - TRACE("(%p) : glDrawArrays(%#x, %d, %d)\n", This, glPrimitiveType, startVertex, numberOfVertices); - glDrawArrays(glPrimitiveType, startVertex, numberOfVertices); + TRACE("(%p) : glDrawArrays(%#x, %d, %d)\n", This, glPrimitiveType, startIdx, numberOfVertices); + glDrawArrays(glPrimitiveType, startIdx, numberOfVertices); checkGLcall("glDrawArrays"); } @@ -287,7 +288,7 @@ static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum */ static void drawStridedSlow(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT NumVertexes, - GLenum glPrimType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) + GLenum glPrimType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { unsigned int textureNo = 0; const WORD *pIdxBufS = NULL; @@ -295,7 +296,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const WineDirect3DVertexStrid ULONG vx_index; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; const UINT *streamOffset = This->stateBlock->streamOffset; - long SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex; + long SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex; BOOL pixelShader = use_ps(This->stateBlock); BOOL specular_fog = FALSE; UINT texture_stages = GL_LIMITS(texture_stages); @@ -597,10 +598,10 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co } static void drawStridedSlowVs(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT numberOfVertices, - GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) + GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; - long SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex; + long SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex; const WORD *pIdxBufS = NULL; const DWORD *pIdxBufL = NULL; ULONG vx_index; @@ -658,7 +659,7 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, const WineDirect3DVertexStr static inline void drawStridedInstanced(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, - ULONG startIdx, ULONG startVertex) + ULONG startIdx) { UINT numInstances = 0, i; int numInstancedAttribs = 0, j; @@ -811,16 +812,9 @@ static inline void remove_vbos(IWineD3DDeviceImpl *This, WineDirect3DVertexStrid } /* Routine common to the draw primitive and draw indexed primitive routines */ -void drawPrimitive(IWineD3DDevice *iface, - int PrimitiveType, - long NumPrimitives, - /* for Indexed: */ - long StartVertexIndex, - UINT numberOfVertices, - long StartIdx, - short idxSize, - const void *idxData, - int minIndex) { +void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives, + UINT numberOfVertices, long StartIdx, short idxSize, const void *idxData, int minIndex) +{ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DSurfaceImpl *target; @@ -908,19 +902,19 @@ void drawPrimitive(IWineD3DDevice *iface, } else { TRACE("Using immediate mode with vertex shaders for half float emulation\n"); } - drawStridedSlowVs(iface, strided, calculatedNumberOfindices, glPrimType, - idxData, idxSize, minIndex, StartIdx, StartVertexIndex); + drawStridedSlowVs(iface, strided, calculatedNumberOfindices, + glPrimType, idxData, idxSize, minIndex, StartIdx); } else { drawStridedSlow(iface, strided, calculatedNumberOfindices, - glPrimType, idxData, idxSize, minIndex, StartIdx, StartVertexIndex); + glPrimType, idxData, idxSize, minIndex, StartIdx); } } else if(This->instancedDraw) { /* Instancing emulation with mixing immediate mode and arrays */ drawStridedInstanced(iface, &This->strided_streams, calculatedNumberOfindices, glPrimType, - idxData, idxSize, minIndex, StartIdx, StartVertexIndex); + idxData, idxSize, minIndex, StartIdx); } else { drawStridedFast(iface, calculatedNumberOfindices, glPrimType, - idxData, idxSize, minIndex, StartIdx, StartVertexIndex); + idxData, idxSize, minIndex, StartIdx); } } diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c index a4677dcbcb9..1da6a0c91da 100644 --- a/dlls/wined3d/nvidia_texture_shader.c +++ b/dlls/wined3d/nvidia_texture_shader.c @@ -451,7 +451,7 @@ void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEX static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage]; BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map & (1 << stage); @@ -556,7 +556,7 @@ static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D } static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage + 1]; float mat[2][2]; diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c index 7826325a374..05e114c1b5a 100644 --- a/dlls/wined3d/query.c +++ b/dlls/wined3d/query.c @@ -63,8 +63,18 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) { ref = InterlockedDecrement(&This->ref); if (ref == 0) { ENTER_GL(); + /* Queries are specific to the GL context that created them. Not + * deleting the query will obviously leak it, but that's still better + * than potentially deleting a different query with the same id in this + * context, and (still) leaking the actual query. */ if(This->type == WINED3DQUERYTYPE_EVENT) { - if(GL_SUPPORT(APPLE_FENCE)) { + if (((WineQueryEventData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext + || This->wineD3DDevice->activeContext->tid != GetCurrentThreadId()) + { + FIXME("Query was created in a different context, skipping deletion\n"); + } + else if(GL_SUPPORT(APPLE_FENCE)) + { GL_EXTCALL(glDeleteFencesAPPLE(1, &((WineQueryEventData *)(This->extendedData))->fenceId)); checkGLcall("glDeleteFencesAPPLE"); } else if(GL_SUPPORT(NV_FENCE)) { @@ -72,8 +82,16 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) { checkGLcall("glDeleteFencesNV"); } } else if(This->type == WINED3DQUERYTYPE_OCCLUSION && GL_SUPPORT(ARB_OCCLUSION_QUERY)) { - GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId)); - checkGLcall("glDeleteQueriesARB"); + if (((WineQueryOcclusionData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext + || This->wineD3DDevice->activeContext->tid != GetCurrentThreadId()) + { + FIXME("Query was created in a different context, skipping deletion\n"); + } + else + { + GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId)); + checkGLcall("glDeleteQueriesARB"); + } } LEAVE_GL(); @@ -268,48 +286,68 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface; + GLuint queryId = ((WineQueryOcclusionData *)This->extendedData)->queryId; DWORD* data = pData; + GLuint available; + GLuint samples; HRESULT res; + TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags); - if(This->state == QUERY_CREATED) { + if (This->state == QUERY_CREATED) + { /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */ TRACE("Query wasn't yet started, returning S_OK\n"); - res = S_OK; if(data) *data = 0; - } else if(This->state == QUERY_BUILDING) { + return S_OK; + } + + if (This->state == QUERY_BUILDING) + { /* Msdn says this returns an error, but our tests show that S_FALSE is returned */ TRACE("Query is building, returning S_FALSE\n"); - res = S_FALSE; - } else if (GL_SUPPORT(ARB_OCCLUSION_QUERY) && - ((WineQueryOcclusionData *)This->extendedData)->ctx == This->wineD3DDevice->activeContext && - This->wineD3DDevice->activeContext->tid == GetCurrentThreadId()) { - GLuint available; - GLuint samples; - GLuint queryId = ((WineQueryOcclusionData *)This->extendedData)->queryId; + return S_FALSE; + } - ENTER_GL(); - GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_AVAILABLE_ARB, &available)); - checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)\n"); - TRACE("(%p) : available %d.\n", This, available); - - if (available) { - if(data) { - GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_ARB, &samples)); - checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)\n"); - TRACE("(%p) : Returning %d samples.\n", This, samples); - *data = samples; - } - res = S_OK; - } else { - res = S_FALSE; - } - LEAVE_GL(); - } else { - WARN("(%p) : Occlusion queries not supported, or wrong context. Returning 1.\n", This); + if (!GL_SUPPORT(ARB_OCCLUSION_QUERY)) + { + WARN("(%p) : Occlusion queries not supported. Returning 1.\n", This); *data = 1; + return S_OK; + } + + if (((WineQueryOcclusionData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext + || This->wineD3DDevice->activeContext->tid != GetCurrentThreadId()) + { + FIXME("%p Wrong context, returning 1.\n", This); + *data = 1; + return S_OK; + } + + ENTER_GL(); + + GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_AVAILABLE_ARB, &available)); + checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)\n"); + TRACE("(%p) : available %d.\n", This, available); + + if (available) + { + if (data) + { + GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_ARB, &samples)); + checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)\n"); + TRACE("(%p) : Returning %d samples.\n", This, samples); + *data = samples; + } res = S_OK; } + else + { + res = S_FALSE; + } + + LEAVE_GL(); + return res; } @@ -324,7 +362,7 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void return S_OK; } if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) { /* See comment in IWineD3DQuery::Issue, event query codeblock */ - WARN("Query context not active, reporting GPU idle\n"); + FIXME("Query context not active, reporting GPU idle\n"); *data = TRUE; } else if(GL_SUPPORT(APPLE_FENCE)) { ENTER_GL(); @@ -460,7 +498,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D WineD3DContext *ctx = ((WineQueryOcclusionData *)This->extendedData)->ctx; if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) { - WARN("Not the owning context, can't start query\n"); + FIXME("Not the owning context, can't start query\n"); } else { ENTER_GL(); /* This is allowed according to msdn and our tests. Reset the query and restart */ diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 54b24530891..777af22d4a3 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -2881,7 +2881,7 @@ static void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTE static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage]; BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map & (1 << stage); @@ -2937,7 +2937,7 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D } void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage]; BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map & (1 << stage); DWORD op, arg1, arg2, arg0; @@ -3036,7 +3036,7 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext } static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD texUnit = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD texUnit = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[texUnit]; BOOL generated; int coordIdx; @@ -3134,7 +3134,7 @@ static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, const WineDirect3D } static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage]; static const GLfloat s_plane[] = { 1.0, 0.0, 0.0, 0.0 }; static const GLfloat t_plane[] = { 0.0, 1.0, 0.0, 0.0 }; @@ -3315,7 +3315,7 @@ static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine } static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); if(stateblock->pixelShader && stage != 0 && ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.luminanceparams[stage]) { @@ -3488,7 +3488,7 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DC } static void shader_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { - DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; + DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); if(stateblock->pixelShader && stage != 0 && ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.bumpmat[stage]) { /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 81614b4e522..e1f1dd8eab3 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -91,7 +91,7 @@ static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES * dest->textures = source->textures; memcpy(dest->transform, source->transform, sizeof(source->transform)); memcpy(dest->renderState, source->renderState, sizeof(source->renderState)); - memcpy(dest->textureState, source->textureState, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)); + memcpy(dest->textureState, source->textureState, sizeof(source->textureState)); memcpy(dest->samplerState, source->samplerState, sizeof(source->samplerState)); dest->clipplane = source->clipplane; dest->pixelShaderConstantsB = source->pixelShaderConstantsB; @@ -138,6 +138,7 @@ void stateblock_savedstates_set( states->textures = 0xfffff; stateblock_set_bits(states->transform, HIGHEST_TRANSFORMSTATE + 1); stateblock_set_bits(states->renderState, WINEHIGHEST_RENDER_STATE + 1); + for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = 0x3ffff; for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3fff; states->clipplane = 0xffffffff; states->pixelShaderConstantsB = 0xffff; @@ -152,6 +153,7 @@ void stateblock_savedstates_set( states->textures = 0; memset(states->transform, 0, sizeof(states->transform)); memset(states->renderState, 0, sizeof(states->renderState)); + memset(states->textureState, 0, sizeof(states->textureState)); memset(states->samplerState, 0, sizeof(states->samplerState)); states->clipplane = 0; states->pixelShaderConstantsB = 0; @@ -159,7 +161,6 @@ void stateblock_savedstates_set( states->vertexShaderConstantsB = 0; states->vertexShaderConstantsI = 0; } - memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)); /* Dynamically sized arrays */ memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF)); @@ -808,7 +809,7 @@ should really perform a delta so that only the changes get updated*/ DWORD stage = This->contained_tss_states[i].stage; DWORD state = This->contained_tss_states[i].state; ((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[stage][state] = This->textureState[stage][state]; - ((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[stage][state] = TRUE; + ((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[stage] |= 1 << state; /* TODO: Record a display list to apply all gl states. For now apply by brute force */ IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(stage, state)); } @@ -998,7 +999,8 @@ should really perform a delta so that only the changes get updated*/ IWineD3DDevice_SetRenderState(pDevice, i, This->renderState[i]); } for(j = 0; j < MAX_TEXTURES; j++) { - for(i = 1; i <= WINED3D_HIGHEST_TEXTURE_STATE; i++) { + for (i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i) + { IWineD3DDevice_SetTextureStageState(pDevice, j, i, This->textureState[j][i]); } } @@ -1023,7 +1025,8 @@ should really perform a delta so that only the changes get updated*/ UINT sampler = j < MAX_FRAGMENT_SAMPLERS ? j : WINED3DVERTEXTEXTURESAMPLER0 + j - MAX_FRAGMENT_SAMPLERS; IWineD3DDevice_SetTexture(pDevice, sampler, This->textures[j]); - for(i = 1; i < WINED3D_HIGHEST_SAMPLER_STATE; i++) { + for (i = 1; i <= WINED3D_HIGHEST_SAMPLER_STATE; ++i) + { IWineD3DDevice_SetSamplerState(pDevice, sampler, i, This->samplerState[j][i]); } } diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 4bfa453d14f..67ab32b7c17 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1025,9 +1025,6 @@ const char* debug_d3dtexturestate(DWORD state) { D3DSTATE_TO_STR(WINED3DTSS_RESULTARG ); D3DSTATE_TO_STR(WINED3DTSS_CONSTANT ); #undef D3DSTATE_TO_STR - case 12: - /* Note WINED3DTSS are not consecutive, so skip these */ - return "unused"; default: FIXME("Unrecognized %u texture state!\n", state); return "unrecognized"; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index a9abe07120e..516cd9f145c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -641,16 +641,8 @@ extern LONG primCounter; */ /* Routine common to the draw primitive and draw indexed primitive routines */ -void drawPrimitive(IWineD3DDevice *iface, - int PrimitiveType, - long NumPrimitives, - /* for Indexed: */ - long StartVertexIndex, - UINT numberOfVertices, - long StartIdx, - short idxBytes, - const void *idxData, - int minIndex); +void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives, + UINT numberOfVertices, long start_idx, short idxBytes, const void *idxData, int minIndex); void primitiveDeclarationConvertToStridedData( IWineD3DDevice *iface, @@ -680,7 +672,7 @@ typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock, #define STATE_RENDER(a) (a) #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE)) -#define STATE_TEXTURESTAGE(stage, num) (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + (stage) * WINED3D_HIGHEST_TEXTURE_STATE + (num)) +#define STATE_TEXTURESTAGE(stage, num) (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num)) #define STATE_IS_TEXTURESTAGE(a) ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE)) /* + 1 because samplers start with 0 */ @@ -1761,10 +1753,10 @@ typedef struct SAVEDSTATES { DWORD transform[(HIGHEST_TRANSFORMSTATE >> 5) + 1]; WORD streamSource; /* MAX_STREAMS, 16 */ WORD streamFreq; /* MAX_STREAMS, 16 */ - DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */ DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1]; - BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1]; - WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14*/ + DWORD textureState[MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */ + WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */ + DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */ DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */ WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */ WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */ @@ -1883,7 +1875,7 @@ struct IWineD3DStateBlockImpl unsigned int num_contained_ps_consts_b; DWORD *contained_ps_consts_f; unsigned int num_contained_ps_consts_f; - struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE)]; + struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)]; unsigned int num_contained_tss_states; struct StageState contained_sampler_states[MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE]; unsigned int num_contained_sampler_states; diff --git a/dlls/winedos/devices.c b/dlls/winedos/devices.c index 0ee6f6c24b9..44bafbe1b6a 100644 --- a/dlls/winedos/devices.c +++ b/dlls/winedos/devices.c @@ -476,140 +476,6 @@ void DOSDEV_InstallDOSDevices(void) dataseg->lol.ptr_CON_dev_hdr = MAKESEGPTR(seg, DOS_DATASEG_OFF(dev[0])); } -DWORD DOSDEV_Console(void) -{ - return DOSMEM_LOL()->ptr_CON_dev_hdr; -} - -DWORD DOSDEV_FindCharDevice(char*name) -{ - SEGPTR cur_ptr = MAKESEGPTR(HIWORD(DOS_LOLSeg), FIELD_OFFSET(DOS_LISTOFLISTS,NUL_dev)); - DOS_DEVICE_HEADER *cur = PTR_REAL_TO_LIN(SELECTOROF(cur_ptr),OFFSETOF(cur_ptr)); - char dname[8]; - int cnt; - - /* get first 8 characters */ - /* if less than 8 characters, pad with spaces */ - for (cnt=0; name[cnt] && cnt<8; cnt++) - dname[cnt]=name[cnt]; - - while(cnt<8) dname[cnt++] = ' '; - - /* search for char devices with the right name */ - while (cur && - ((!(cur->attr & ATTR_CHAR)) || - memcmp(cur->name,dname,8))) { - cur_ptr = cur->next_dev; - if (cur_ptr == NONEXT) cur=NULL; - else cur = PTR_REAL_TO_LIN(SELECTOROF(cur_ptr),OFFSETOF(cur_ptr)); - } - return cur_ptr; -} - -static void DOSDEV_DoReq(void*req, DWORD dev) -{ - REQUEST_HEADER *hdr = (REQUEST_HEADER *)req; - DOS_DEVICE_HEADER *dhdr; - CONTEXT86 ctx; - char *phdr; - - dhdr = PTR_REAL_TO_LIN(SELECTOROF(dev),OFFSETOF(dev)); - phdr = ((char*)DOSMEM_LOL()) + DOS_DATASEG_OFF(req); - - /* copy request to request scratch area */ - memcpy(phdr, req, hdr->size); - - /* prepare to call device driver */ - memset(&ctx, 0, sizeof(ctx)); - ctx.EFlags |= V86_FLAG; - - /* ES:BX points to request for strategy routine */ - ctx.SegEs = HIWORD(DOS_LOLSeg); - ctx.Ebx = DOS_DATASEG_OFF(req); - - /* call strategy routine */ - ctx.SegCs = SELECTOROF(dev); - ctx.Eip = dhdr->strategy; - DPMI_CallRMProc(&ctx, 0, 0, 0); - - /* call interrupt routine */ - ctx.SegCs = SELECTOROF(dev); - ctx.Eip = dhdr->interrupt; - DPMI_CallRMProc(&ctx, 0, 0, 0); - - /* completed, copy request back */ - memcpy(req, phdr, hdr->size); - - if (hdr->status & STAT_ERROR) { - switch (hdr->status & STAT_MASK) { - case 0x0F: /* invalid disk change */ - /* this error seems to fit the bill */ - SetLastError(ERROR_NOT_SAME_DEVICE); - break; - default: - SetLastError((hdr->status & STAT_MASK) + 0x13); - break; - } - } -} - -static int DOSDEV_IO(unsigned cmd, DWORD dev, DWORD buf, int buflen) -{ - REQ_IO req; - - req.hdr.size=sizeof(req); - req.hdr.unit=0; /* not dealing with block devices yet */ - req.hdr.command=cmd; - req.hdr.status=STAT_BUSY; - req.media=0; /* not dealing with block devices yet */ - req.buffer=buf; - req.count=buflen; - req.sector=0; /* block devices */ - req.volume=0; /* block devices */ - - DOSDEV_DoReq(&req, dev); - - return req.count; -} - -int DOSDEV_Peek(DWORD dev, BYTE*data) -{ - REQ_SAFEINPUT req; - - req.hdr.size=sizeof(req); - req.hdr.unit=0; /* not dealing with block devices yet */ - req.hdr.command=CMD_SAFEINPUT; - req.hdr.status=STAT_BUSY; - req.data=0; - - DOSDEV_DoReq(&req, dev); - - if (req.hdr.status & STAT_BUSY) return 0; - - *data = req.data; - return 1; -} - -int DOSDEV_Read(DWORD dev, DWORD buf, int buflen) -{ - return DOSDEV_IO(CMD_INPUT, dev, buf, buflen); -} - -int DOSDEV_Write(DWORD dev, DWORD buf, int buflen, int verify) -{ - return DOSDEV_IO(verify?CMD_SAFEOUTPUT:CMD_OUTPUT, dev, buf, buflen); -} - -int DOSDEV_IoctlRead(DWORD dev, DWORD buf, int buflen) -{ - return DOSDEV_IO(CMD_INIOCTL, dev, buf, buflen); -} - -int DOSDEV_IoctlWrite(DWORD dev, DWORD buf, int buflen) -{ - return DOSDEV_IO(CMD_OUTIOCTL, dev, buf, buflen); -} - void DOSDEV_SetSharingRetry(WORD delay, WORD count) { DOSMEM_LOL()->sharing_retry_delay = delay; diff --git a/dlls/winedos/dosexe.h b/dlls/winedos/dosexe.h index 2a20de754e4..2ba07356631 100644 --- a/dlls/winedos/dosexe.h +++ b/dlls/winedos/dosexe.h @@ -368,13 +368,6 @@ extern UINT WINAPI DOSVM_GetTimer( void ); extern void DOSDEV_InstallDOSDevices(void); extern void DOSDEV_SetupDevice(const WINEDEV * devinfo, WORD seg, WORD off_dev, WORD off_thunk); -extern DWORD DOSDEV_Console(void); -extern DWORD DOSDEV_FindCharDevice(char*name); -extern int DOSDEV_Peek(DWORD dev, BYTE*data); -extern int DOSDEV_Read(DWORD dev, DWORD buf, int buflen); -extern int DOSDEV_Write(DWORD dev, DWORD buf, int buflen, int verify); -extern int DOSDEV_IoctlRead(DWORD dev, DWORD buf, int buflen); -extern int DOSDEV_IoctlWrite(DWORD dev, DWORD buf, int buflen); extern void DOSDEV_SetSharingRetry(WORD delay, WORD count); extern SEGPTR DOSDEV_GetLOL(BOOL v86); diff --git a/dlls/winedos/vga.c b/dlls/winedos/vga.c index 12062deb3a2..6f71cf576ef 100644 --- a/dlls/winedos/vga.c +++ b/dlls/winedos/vga.c @@ -929,21 +929,6 @@ void VGA_Get16Palette(char *Table) memcpy( vga_16_palette, Table, 17 ); /* copy the entries into the table */ } -void VGA_SetQuadPalette(RGBQUAD*color,int start,int len) -{ - PALETTEENTRY pal[256]; - int c; - - if (!lpddraw) return; - for (c=0; c 0) + { + int msglen = srclen; + if (msglen > 20) + msglen = 20; + memset(&xevent.xclient.data.b[0], 0, 20); + memcpy(&xevent.xclient.data.b[0], src, msglen); + src += msglen; + srclen -= msglen; + + XSendEvent( display, DefaultRootWindow( display ), False, PropertyChangeMask, &xevent ); + xevent.xclient.message_type = x11drv_atom(_NET_STARTUP_INFO); + } + wine_tsx11_unlock(); +} + + /*********************************************************************** * is_window_managed * @@ -1099,6 +1159,8 @@ static void map_window( Display *display, struct x11drv_win_data *data, DWORD ne { TRACE( "win %p/%lx\n", data->hwnd, data->whole_window ); + remove_startup_notification( display, data->whole_window ); + wait_for_withdrawn_state( display, data, TRUE ); if (!data->embedded) diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 6b29f2ae3e1..955a08c465e 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -595,6 +595,8 @@ enum x11drv_atoms XATOM_DndSelection, XATOM__ICC_PROFILE, XATOM__MOTIF_WM_HINTS, + XATOM__NET_STARTUP_INFO_BEGIN, + XATOM__NET_STARTUP_INFO, XATOM__NET_SUPPORTED, XATOM__NET_SYSTEM_TRAY_OPCODE, XATOM__NET_SYSTEM_TRAY_S0, diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index fd8a41503e6..020d6b52876 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -132,6 +132,8 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] = "DndSelection", "_ICC_PROFILE", "_MOTIF_WM_HINTS", + "_NET_STARTUP_INFO_BEGIN", + "_NET_STARTUP_INFO", "_NET_SUPPORTED", "_NET_SYSTEM_TRAY_OPCODE", "_NET_SYSTEM_TRAY_S0", diff --git a/dlls/wintab32/context.c b/dlls/wintab32/context.c index f52d8d2c879..6b52c081a15 100644 --- a/dlls/wintab32/context.c +++ b/dlls/wintab32/context.c @@ -685,6 +685,12 @@ BOOL WINAPI WTOverlap(HCTX hCtx, BOOL fToTop) EnterCriticalSection(&csTablet); context = TABLET_FindOpenContext(hCtx); + if (!context) + { + LeaveCriticalSection(&csTablet); + return FALSE; + } + /* if we want to send to top and it's not already there */ if (fToTop && context->context.lcStatus != CXS_ONTOP) { @@ -777,6 +783,12 @@ BOOL WINAPI WTSetA(HCTX hCtx, LPLOGCONTEXTA lpLogCtx) EnterCriticalSection(&csTablet); context = TABLET_FindOpenContext(hCtx); + if (!context) + { + LeaveCriticalSection(&csTablet); + return FALSE; + } + LOGCONTEXTAtoW(lpLogCtx, &context->context); LeaveCriticalSection(&csTablet); @@ -799,6 +811,12 @@ BOOL WINAPI WTSetW(HCTX hCtx, LPLOGCONTEXTW lpLogCtx) EnterCriticalSection(&csTablet); context = TABLET_FindOpenContext(hCtx); + if (!context) + { + LeaveCriticalSection(&csTablet); + return FALSE; + } + memmove(&context->context, lpLogCtx, sizeof(LOGCONTEXTW)); LeaveCriticalSection(&csTablet); diff --git a/dlls/xinput1_3/tests/xinput.c b/dlls/xinput1_3/tests/xinput.c index 4b7f1303138..c137b0c5d5d 100644 --- a/dlls/xinput1_3/tests/xinput.c +++ b/dlls/xinput1_3/tests/xinput.c @@ -27,6 +27,7 @@ static DWORD (WINAPI *pXInputGetState)(DWORD, XINPUT_STATE*); static DWORD (WINAPI *pXInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*); static DWORD (WINAPI *pXInputSetState)(DWORD, XINPUT_VIBRATION*); static void (WINAPI *pXInputEnable)(BOOL); +static DWORD (WINAPI *pXInputGetKeystroke)(DWORD, DWORD, PXINPUT_KEYSTROKE); static void test_set_state(void) { @@ -96,6 +97,30 @@ static void test_get_state(void) ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); } +static void test_get_keystroke(void) +{ + XINPUT_KEYSTROKE keystroke; + DWORD controllerNum; + DWORD result; + + for(controllerNum=0; controllerNum < XUSER_MAX_COUNT; controllerNum++) + { + ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE)); + + result = pXInputGetKeystroke(controllerNum, XINPUT_FLAG_GAMEPAD, &keystroke); + ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputGetKeystroke failed with (%d)\n", result); + + if (ERROR_DEVICE_NOT_CONNECTED == result) + { + skip("Controller %d is not connected\n", controllerNum); + } + } + + ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE)); + result = pXInputGetKeystroke(XUSER_MAX_COUNT+1, XINPUT_FLAG_GAMEPAD, &keystroke); + ok(result == ERROR_BAD_ARGUMENTS, "XInputGetKeystroke returned (%d)\n", result); +} + static void test_get_capabilities(void) { XINPUT_CAPABILITIES capabilities; @@ -134,9 +159,11 @@ START_TEST(xinput) pXInputEnable = (void*)GetProcAddress(hXinput, "XInputEnable"); pXInputSetState = (void*)GetProcAddress(hXinput, "XInputSetState"); pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState"); + pXInputGetKeystroke = (void*)GetProcAddress(hXinput, "XInputGetKeystroke"); pXInputGetCapabilities = (void*)GetProcAddress(hXinput, "XInputGetCapabilities"); test_set_state(); test_get_state(); + test_get_keystroke(); test_get_capabilities(); FreeLibrary(hXinput); } diff --git a/dlls/xinput1_3/xinput1_3.spec b/dlls/xinput1_3/xinput1_3.spec index 7c71bd5ec0f..f2d961c1bcb 100644 --- a/dlls/xinput1_3/xinput1_3.spec +++ b/dlls/xinput1_3/xinput1_3.spec @@ -1,7 +1,7 @@ @ stdcall XInputEnable(long) @ stdcall XInputSetState(long ptr) @ stdcall XInputGetState(long ptr) -@ stub XInputGetKeystroke #(long long ptr) +@ stdcall XInputGetKeystroke(long long ptr) @ stdcall XInputGetCapabilities(long long ptr) @ stub XInputGetDSoundAudioDeviceGuids #(long ptr ptr) @ stub XInputGetBatteryInformation diff --git a/dlls/xinput1_3/xinput1_3_main.c b/dlls/xinput1_3/xinput1_3_main.c index 7f28f3738cd..636dcd1f30d 100644 --- a/dlls/xinput1_3/xinput1_3_main.c +++ b/dlls/xinput1_3/xinput1_3_main.c @@ -79,6 +79,18 @@ DWORD WINAPI XInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState) return ERROR_BAD_ARGUMENTS; } +DWORD WINAPI XInputGetKeystroke(DWORD dwUserIndex, DWORD dwReserve, PXINPUT_KEYSTROKE pKeystroke) +{ + FIXME("(%d %d %p) Stub!\n", dwUserIndex, dwReserve, pKeystroke); + + if (dwUserIndex < XUSER_MAX_COUNT) + { + return ERROR_DEVICE_NOT_CONNECTED; + /* If controller exists then return ERROR_SUCCESS */ + } + return ERROR_BAD_ARGUMENTS; +} + DWORD WINAPI XInputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities) { FIXME("(%d %d %p)\n", dwUserIndex, dwFlags, pCapabilities); diff --git a/documentation/README.de b/documentation/README.de index 6ee1b142531..ee07af0a9d3 100644 --- a/documentation/README.de +++ b/documentation/README.de @@ -32,9 +32,10 @@ Um Wine kompilieren und ausf folgenden Betriebssysteme: Linux version 2.0.36 oder neuer - FreeBSD 4.x oder FreeBSD 5-CURRENT oder neuer - Solaris x86 2.5 oder neuer + FreeBSD 6.3 oder neuer + Solaris x86 9 oder neuer NetBSD-current + Mac OS X 10.4 oder neuer Da Wine Thread-Support auf Kernelebene benötigt, werden nur die oben aufgeführten Betriebssysteme unterstützt. @@ -74,20 +75,11 @@ Unterst Grundsätzliche Voraussetzungen: Sie müssen die Include-Dateien für X11-Entwicklung installiert haben - (Debian nennt diese xlib6g-dev, RedHat XFree86-devel). - -Vorausgesetzte Build-Tools: - Auf x86-Systemen wird der gcc >= 2.7.2 benötigt. - Versionen vor 2.7.2.3 können Probleme damit haben, wenn bestimmte Dateien - mit Optimierungen kompiliert werden, oft im Zusammenhang mit Problemen mit - der Verwaltung von Header-Dateien. pgcc arbeitet derzeit nicht mit Wine. - Die Ursache dieses Problems ist unbekannt. + (Debian nennt diese xlib6g-dev, Red Hat XFree86-devel). Natürlich benötigen Sie auch "make" (höchstwahrscheinlich GNU make). Des Weiteren benötigen Sie flex in der Version 2.5 oder höher und bison. - Wenn Sie RedHat oder Debian benutzen, installieren Sie bitte die flex- - und bison-Pakete. Optionale Support-Bibliotheken: Der ./configure Aufruf zeigt am Ende optionale Bibliotheken an, diff --git a/include/Makefile.in b/include/Makefile.in index 8f004f2547c..8604b8f6721 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -259,6 +259,7 @@ SRCDIR_INCLUDES = \ lmuse.h \ lmuseflg.h \ lmwksta.h \ + loadperf.h \ lzexpand.h \ mapi.h \ mapicode.h \ diff --git a/include/ipexport.h b/include/ipexport.h index 9a02e008fcd..71a44baf19b 100644 --- a/include/ipexport.h +++ b/include/ipexport.h @@ -21,9 +21,9 @@ #ifndef __WINE_IPEXPORT_H #define __WINE_IPEXPORT_H -typedef unsigned long IPAddr; -typedef unsigned long IPMask; -typedef unsigned long IP_STATUS; +typedef ULONG IPAddr; +typedef ULONG IPMask; +typedef ULONG IP_STATUS; struct ip_option_information { @@ -51,8 +51,8 @@ struct ip_option_information struct icmp_echo_reply { IPAddr Address; - unsigned long Status; - unsigned long RoundTripTime; + ULONG Status; + ULONG RoundTripTime; unsigned short DataSize; unsigned short Reserved; void* Data; diff --git a/dlls/inkobj/inkobj_internal.h b/include/loadperf.h similarity index 65% copy from dlls/inkobj/inkobj_internal.h copy to include/loadperf.h index cfd9b5b5638..74472c73d43 100644 --- a/dlls/inkobj/inkobj_internal.h +++ b/include/loadperf.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2007 C John Klehm +/* + * Copyright (C) 2009 Andrey Turkin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,23 +15,20 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef INKOBJ_INTERNAL_H -#define INKOBJ_INTERNAL_H -#include +#ifndef __WINE_LOADPERF_H +#define __WINE_LOADPERF_H -#include "windef.h" -#include "winbase.h" -#include "winerror.h" +#ifdef __cplusplus +extern "C" { +#endif -#define COBJMACROS -#include "winuser.h" -#include "ole2.h" -#include "msinkaut.h" +DWORD WINAPI UnloadPerfCounterTextStringsA(LPCSTR, BOOL); +DWORD WINAPI UnloadPerfCounterTextStringsW(LPCWSTR, BOOL); +#define UnloadPerfCounterTextStrings WINELIB_NAME_AW(UnloadPerfCounterTextStrings) -#include "wine/debug.h" +#ifdef __cplusplus +} +#endif -extern LONG INKOBJ_refCount; -extern HINSTANCE INKOBJ_hInstance; - -#endif /* INKOBJ_INTERNAL_H */ +#endif /* __WINE_LOADPERF_H */ diff --git a/include/mapi.h b/include/mapi.h index f8695f3e702..2d335ea588a 100644 --- a/include/mapi.h +++ b/include/mapi.h @@ -27,15 +27,15 @@ extern "C" { #ifndef __LHANDLE #define __LHANDLE -typedef unsigned long LHANDLE, *LPLHANDLE; +typedef ULONG LHANDLE, *LPLHANDLE; #endif #define lhSessionNull ((LHANDLE)0) #ifndef WINE_FLAGS_DEFINED #define WINE_FLAGS_DEFINED -typedef unsigned long FLAGS; +typedef ULONG FLAGS; #endif -typedef unsigned long* LPULONG; +typedef ULONG *LPULONG; typedef struct { diff --git a/include/mapix.h b/include/mapix.h index 1ca7aaf9a5a..04e7eb147ea 100644 --- a/include/mapix.h +++ b/include/mapix.h @@ -36,7 +36,7 @@ typedef struct IMAPISession *LPMAPISESSION; #ifndef WINE_FLAGS_DEFINED #define WINE_FLAGS_DEFINED -typedef unsigned long FLAGS; +typedef ULONG FLAGS; #endif /* Flags for MAPILogon and MAPILogonEx */ diff --git a/include/msvcrt/crtdefs.h b/include/msvcrt/crtdefs.h index fce448e94c0..9eac870ea75 100644 --- a/include/msvcrt/crtdefs.h +++ b/include/msvcrt/crtdefs.h @@ -68,6 +68,18 @@ # endif #endif /* __cdecl */ +#ifndef __ms_va_list +# if defined(__x86_64__) && defined (__GNUC__) +# define __ms_va_list __builtin_ms_va_list +# define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg) +# define __ms_va_end(list) __builtin_ms_va_end(list) +# else +# define __ms_va_list va_list +# define __ms_va_start(list,arg) va_start(list,arg) +# define __ms_va_end(list) va_end(list) +# endif +#endif + #ifndef _INTPTR_T_DEFINED #ifdef _WIN64 typedef __int64 intptr_t; diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h index 98cc9503e6b..b65a2b17c39 100644 --- a/include/msvcrt/stdio.h +++ b/include/msvcrt/stdio.h @@ -115,7 +115,7 @@ int __cdecl _setmaxstdio(int); int __cdecl _snprintf(char*,size_t,const char*,...); char* __cdecl _tempnam(const char*,const char*); int __cdecl _unlink(const char*); -int __cdecl _vsnprintf(char*,size_t,const char*,va_list); +int __cdecl _vsnprintf(char*,size_t,const char*,__ms_va_list); void __cdecl clearerr(FILE*); int __cdecl fclose(FILE*); @@ -155,9 +155,9 @@ int __cdecl sscanf(const char*,const char*,...); FILE* __cdecl tmpfile(void); char* __cdecl tmpnam(char*); int __cdecl ungetc(int,FILE*); -int __cdecl vfprintf(FILE*,const char*,va_list); -int __cdecl vprintf(const char*,va_list); -int __cdecl vsprintf(char*,const char*,va_list); +int __cdecl vfprintf(FILE*,const char*,__ms_va_list); +int __cdecl vprintf(const char*,__ms_va_list); +int __cdecl vsprintf(char*,const char*,__ms_va_list); #ifndef _WSTDIO_DEFINED #define _WSTDIO_DEFINED @@ -166,7 +166,7 @@ wint_t __cdecl _fputwchar(wint_t); wchar_t* __cdecl _getws(wchar_t*); int __cdecl _putws(const wchar_t*); int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...); -int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,va_list); +int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,__ms_va_list); FILE* __cdecl _wfdopen(int,const wchar_t*); FILE* __cdecl _wfopen(const wchar_t*,const wchar_t*); FILE* __cdecl _wfreopen(const wchar_t*,const wchar_t*,FILE*); @@ -193,9 +193,9 @@ int __cdecl putws(const wchar_t*); int __cdecl swprintf(wchar_t*,const wchar_t*,...); int __cdecl swscanf(const wchar_t*,const wchar_t*,...); wint_t __cdecl ungetwc(wint_t,FILE*); -int __cdecl vfwprintf(FILE*,const wchar_t*,va_list); -int __cdecl vswprintf(wchar_t*,const wchar_t*,va_list); -int __cdecl vwprintf(const wchar_t*,va_list); +int __cdecl vfwprintf(FILE*,const wchar_t*,__ms_va_list); +int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list); +int __cdecl vwprintf(const wchar_t*,__ms_va_list); int __cdecl wprintf(const wchar_t*,...); int __cdecl wscanf(const wchar_t*,...); #endif /* _WSTDIO_DEFINED */ @@ -218,7 +218,7 @@ static inline char* tempnam(const char *dir, const char *prefix) { return _tempn static inline int unlink(const char* path) { return _unlink(path); } #define _UNLINK_DEFINED #endif -static inline int vsnprintf(char *buffer, size_t size, const char *format, va_list args) { return _vsnprintf(buffer,size,format,args); } +static inline int vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args) { return _vsnprintf(buffer,size,format,args); } static inline wint_t fgetwchar(void) { return _fgetwchar(); } static inline wint_t fputwchar(wint_t wc) { return _fputwchar(wc); } diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h index d966caa1095..77bcc10e1d4 100644 --- a/include/msvcrt/wchar.h +++ b/include/msvcrt/wchar.h @@ -275,7 +275,7 @@ wint_t __cdecl _fputwchar(wint_t); wchar_t* __cdecl _getws(wchar_t*); int __cdecl _putws(const wchar_t*); int __cdecl _snwprintf(wchar_t*,size_t,const wchar_t*,...); -int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,va_list); +int __cdecl _vsnwprintf(wchar_t*,size_t,const wchar_t*,__ms_va_list); FILE* __cdecl _wfdopen(int,const wchar_t*); FILE* __cdecl _wfopen(const wchar_t*,const wchar_t*); FILE* __cdecl _wfreopen(const wchar_t*,const wchar_t*,FILE*); @@ -302,9 +302,9 @@ int __cdecl putws(const wchar_t*); int __cdecl swprintf(wchar_t*,const wchar_t*,...); int __cdecl swscanf(const wchar_t*,const wchar_t*,...); wint_t __cdecl ungetwc(wint_t,FILE*); -int __cdecl vfwprintf(FILE*,const wchar_t*,va_list); -int __cdecl vswprintf(wchar_t*,const wchar_t*,va_list); -int __cdecl vwprintf(const wchar_t*,va_list); +int __cdecl vfwprintf(FILE*,const wchar_t*,__ms_va_list); +int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list); +int __cdecl vwprintf(const wchar_t*,__ms_va_list); int __cdecl wprintf(const wchar_t*,...); int __cdecl wscanf(const wchar_t*,...); #endif /* _WSTDIO_DEFINED */ diff --git a/include/setupapi.h b/include/setupapi.h index 0e9cbbbecb5..820c5c4f65a 100644 --- a/include/setupapi.h +++ b/include/setupapi.h @@ -1633,8 +1633,8 @@ BOOL WINAPI SetupDiUnremoveDevice(HDEVINFO, PSP_DEVINFO_DATA); HDSKSPC WINAPI SetupDuplicateDiskSpaceListA(HDSKSPC, PVOID, DWORD, UINT); HDSKSPC WINAPI SetupDuplicateDiskSpaceListW(HDSKSPC, PVOID, DWORD, UINT); #define SetupDuplicateDiskSpaceList WINELIB_NAME_AW(SetupDuplicateDiskSpaceList) -BOOL WINAPI SetupEnumInfSectionsA(HINF, UINT, PSTR, SIZE, UINT *); -BOOL WINAPI SetupEnumInfSectionsW(HINF, UINT, PWSTR, SIZE, UINT *); +BOOL WINAPI SetupEnumInfSectionsA(HINF, UINT, PSTR, DWORD, DWORD *); +BOOL WINAPI SetupEnumInfSectionsW(HINF, UINT, PWSTR, DWORD, DWORD *); #define SetupEnumInfSections WINELIB_NAME_AW(SetupEnumInfSections) BOOL WINAPI SetupFindFirstLineA( HINF hinf, PCSTR section, PCSTR key, INFCONTEXT *context ); BOOL WINAPI SetupFindFirstLineW( HINF hinf, PCWSTR section, PCWSTR key, INFCONTEXT *context ); diff --git a/include/sspi.h b/include/sspi.h index 29eda33a078..f8a71bde35b 100644 --- a/include/sspi.h +++ b/include/sspi.h @@ -71,8 +71,8 @@ typedef PSecHandle PCtxtHandle; typedef struct _SECURITY_INTEGER { - unsigned long LowPart; - long HighPart; + ULONG LowPart; + LONG HighPart; } SECURITY_INTEGER, *PSECURITY_INTEGER; typedef SECURITY_INTEGER TimeStamp, *PTimeStamp; @@ -89,22 +89,22 @@ typedef UNICODE_STRING SECURITY_STRING, *PSECURITY_STRING; typedef struct _SecPkgInfoA { - unsigned long fCapabilities; - unsigned short wVersion; - unsigned short wRPCID; - unsigned long cbMaxToken; - SEC_CHAR *Name; - SEC_CHAR *Comment; + ULONG fCapabilities; + USHORT wVersion; + USHORT wRPCID; + ULONG cbMaxToken; + SEC_CHAR *Name; + SEC_CHAR *Comment; } SecPkgInfoA, *PSecPkgInfoA; typedef struct _SecPkgInfoW { - unsigned long fCapabilities; - unsigned short wVersion; - unsigned short wRPCID; - unsigned long cbMaxToken; - SEC_WCHAR *Name; - SEC_WCHAR *Comment; + ULONG fCapabilities; + USHORT wVersion; + USHORT wRPCID; + ULONG cbMaxToken; + SEC_WCHAR *Name; + SEC_WCHAR *Comment; } SecPkgInfoW, *PSecPkgInfoW; #define SecPkgInfo WINELIB_NAME_AW(SecPkgInfo) @@ -133,9 +133,9 @@ typedef struct _SecPkgInfoW typedef struct _SecBuffer { - unsigned long cbBuffer; - unsigned long BufferType; - void *pvBuffer; + ULONG cbBuffer; + ULONG BufferType; + PVOID pvBuffer; } SecBuffer, *PSecBuffer; /* values for BufferType */ @@ -162,16 +162,16 @@ typedef struct _SecBuffer typedef struct _SecBufferDesc { - unsigned long ulVersion; - unsigned long cBuffers; - PSecBuffer pBuffers; + ULONG ulVersion; + ULONG cBuffers; + PSecBuffer pBuffers; } SecBufferDesc, *PSecBufferDesc; /* values for ulVersion */ #define SECBUFFER_VERSION 0 typedef void (SEC_ENTRY *SEC_GET_KEY_FN)(void *Arg, void *Principal, - unsigned long KeyVer, void **Key, SECURITY_STATUS *Status); + ULONG KeyVer, void **Key, SECURITY_STATUS *Status); SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(PULONG pcPackages, PSecPkgInfoA *ppPackageInfo); @@ -434,19 +434,19 @@ typedef SECURITY_STATUS (SEC_ENTRY *QUERY_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle, typedef struct _SecPkgContext_Sizes { - unsigned long cbMaxToken; - unsigned long cbMaxSignature; - unsigned long cbBlockSize; - unsigned long cbSecurityTrailer; + ULONG cbMaxToken; + ULONG cbMaxSignature; + ULONG cbBlockSize; + ULONG cbSecurityTrailer; } SecPkgContext_Sizes, *PSecPkgContext_Sizes; typedef struct _SecPkgContext_StreamSizes { - unsigned long cbHeader; - unsigned long cbTrailer; - unsigned long cbMaximumMessage; - unsigned long cbBuffers; - unsigned long cbBlockSize; + ULONG cbHeader; + ULONG cbTrailer; + ULONG cbMaximumMessage; + ULONG cbBuffers; + ULONG cbBlockSize; } SecPkgContext_StreamSizes, *PSecPkgContext_StreamSizes; typedef struct _SecPkgContext_NamesA @@ -470,26 +470,26 @@ typedef struct _SecPkgContext_Lifespan typedef struct _SecPkgContext_DceInfo { - unsigned long AuthzSvc; - void *pPac; + ULONG AuthzSvc; + PVOID pPac; } SecPkgContext_DceInfo, *PSecPkgContext_DceInfo; typedef struct _SecPkgContext_KeyInfoA { - SEC_CHAR *sSignatureAlgorithmName; - SEC_CHAR *sEncryptAlgorithmName; - unsigned long KeySize; - unsigned long SignatureAlgorithm; - unsigned long EncryptAlgorithm; + SEC_CHAR *sSignatureAlgorithmName; + SEC_CHAR *sEncryptAlgorithmName; + ULONG KeySize; + ULONG SignatureAlgorithm; + ULONG EncryptAlgorithm; } SecPkgContext_KeyInfoA, *PSecPkgContext_KeyInfoA; typedef struct _SecPkgContext_KeyInfoW { - SEC_WCHAR *sSignatureAlgorithmName; - SEC_WCHAR *sEncryptAlgorithmName; - unsigned long KeySize; - unsigned long SignatureAlgorithm; - unsigned long EncryptAlgorithm; + SEC_WCHAR *sSignatureAlgorithmName; + SEC_WCHAR *sEncryptAlgorithmName; + ULONG KeySize; + ULONG SignatureAlgorithm; + ULONG EncryptAlgorithm; } SecPkgContext_KeyInfoW, *PSecPkgContext_KeyInfoW; #define SecPkgContext_KeyInfo WINELIB_NAME_AW(SecPkgContext_KeyInfo) @@ -510,16 +510,16 @@ typedef struct _SecPkgContext_AuthorityW typedef struct _SecPkgContext_ProtoInfoA { - SEC_CHAR *sProtocolName; - unsigned long majorVersion; - unsigned long minorVersion; + SEC_CHAR *sProtocolName; + ULONG majorVersion; + ULONG minorVersion; } SecPkgContext_ProtoInfoA, *PSecPkgContext_ProtoInfoA; typedef struct _SecPkgContext_ProtoInfoW { - SEC_WCHAR *sProtocolName; - unsigned long majorVersion; - unsigned long minorVersion; + SEC_WCHAR *sProtocolName; + ULONG majorVersion; + ULONG minorVersion; } SecPkgContext_ProtoInfoW, *PSecPkgContext_ProtoInfoW; #define SecPkgContext_ProtoInfo WINELIB_NAME_AW(SecPkgContext_ProtoInfo) @@ -532,7 +532,7 @@ typedef struct _SecPkgContext_PasswordExpiry typedef struct _SecPkgContext_SessionKey { - unsigned long SessionKeyLength; + ULONG SessionKeyLength; unsigned char *SessionKey; } SecPkgContext_SessionKey, *PSecPkgContext_SessionKey; @@ -551,24 +551,24 @@ typedef struct _SecPkgContext_PackageInfoW typedef struct _SecPkgContext_Flags { - unsigned long Flags; + ULONG Flags; } SecPkgContext_Flags, *PSecPkgContext_Flags; typedef struct _SecPkgContext_UserFlags { - unsigned long UserFlags; + ULONG UserFlags; } SecPkgContext_UserFlags, *PSecPkgContext_UserFlags; typedef struct _SecPkgContext_NegotiationInfoA { - PSecPkgInfoA PackageInfo; - unsigned long NegotiationState; + PSecPkgInfoA PackageInfo; + ULONG NegotiationState; } SecPkgContext_NegotiationInfoA, *PSecPkgContext_NegotiationInfoA; typedef struct _SecPkgContext_NegotiationInfoW { - PSecPkgInfoW PackageInfo; - unsigned long NegotiationState; + PSecPkgInfoW PackageInfo; + ULONG NegotiationState; } SecPkgContext_NegotiationInfoW, *PSecPkgContext_NegotiationInfoW; #define SecPkgContext_NegotiationInfo WINELIB_NAME_AW(SecPkgContext_NegotiationInfo) @@ -598,14 +598,14 @@ typedef struct _SecPkgContext_NativeNamesW typedef struct _SecPkgContext_CredentialNameA { - unsigned long CredentialType; - SEC_CHAR *sCredentialName; + ULONG CredentialType; + SEC_CHAR *sCredentialName; } SecPkgContext_CredentialNameA, *PSecPkgContext_CredentialNameA; typedef struct _SecPkgContext_CredentialNameW { - unsigned long CredentialType; - SEC_WCHAR *sCredentialName; + ULONG CredentialType; + SEC_WCHAR *sCredentialName; } SecPkgContext_CredentialNameW, *PSecPkgContext_CredentialNameW; #define SecPkgContext_CredentialName WINELIB_NAME_AW(SecPkgContext_CredentialName) @@ -618,20 +618,20 @@ typedef struct _SecPkgContext_AccessToken typedef struct _SecPkgContext_TargetInformation { - unsigned long MarshalledTargetInfoLength; + ULONG MarshalledTargetInfoLength; unsigned char *MarshalledTargetInfo; } SecPkgContext_TargetInformation, *PSecPkgContext_TargetInformation; typedef struct _SecPkgContext_AuthzID { - unsigned long AuthzIDLength; - char *AuthzID; + ULONG AuthzIDLength; + char *AuthzID; } SecPkgContext_AuthzID, *PSecPkgContext_AuthzID; typedef struct _SecPkgContext_Target { - unsigned long TargetLength; - char *Target; + ULONG TargetLength; + char *Target; } SecPkgContext_Target, *PSecPkgContext_Target; SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext); @@ -742,7 +742,7 @@ typedef SECURITY_STATUS (SEC_ENTRY *SET_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle, typedef struct _SECURITY_FUNCTION_TABLE_A { - unsigned long dwVersion; + ULONG dwVersion; ENUMERATE_SECURITY_PACKAGES_FN_A EnumerateSecurityPackagesA; QUERY_CREDENTIALS_ATTRIBUTES_FN_A QueryCredentialsAttributesA; ACQUIRE_CREDENTIALS_HANDLE_FN_A AcquireCredentialsHandleA; @@ -774,7 +774,7 @@ typedef struct _SECURITY_FUNCTION_TABLE_A typedef struct _SECURITY_FUNCTION_TABLE_W { - unsigned long dwVersion; + ULONG dwVersion; ENUMERATE_SECURITY_PACKAGES_FN_W EnumerateSecurityPackagesW; QUERY_CREDENTIALS_ATTRIBUTES_FN_W QueryCredentialsAttributesW; ACQUIRE_CREDENTIALS_HANDLE_FN_W AcquireCredentialsHandleW; diff --git a/include/twain.h b/include/twain.h index 13bc406b271..a7ff0f092af 100644 --- a/include/twain.h +++ b/include/twain.h @@ -127,10 +127,10 @@ typedef char TW_STR255[256], FAR *pTW_STR255; /* Numeric types. */ typedef char TW_INT8, FAR *pTW_INT8; typedef short TW_INT16, FAR *pTW_INT16; -typedef long TW_INT32, FAR *pTW_INT32; +typedef LONG TW_INT32, FAR *pTW_INT32; typedef unsigned char TW_UINT8, FAR *pTW_UINT8; typedef unsigned short TW_UINT16, FAR *pTW_UINT16; -typedef unsigned long TW_UINT32, FAR *pTW_UINT32; +typedef ULONG TW_UINT32, FAR *pTW_UINT32; typedef unsigned short TW_BOOL, FAR *pTW_BOOL; /* Fixed point structure type. */ diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl index 4c89a4d8718..324f5a2dbcd 100644 --- a/include/wine/wined3d.idl +++ b/include/wine/wined3d.idl @@ -554,24 +554,24 @@ typedef enum _WINED3DMULTISAMPLE_TYPE typedef enum _WINED3DTEXTURESTAGESTATETYPE { - WINED3DTSS_COLOROP = 1, - WINED3DTSS_COLORARG1 = 2, - WINED3DTSS_COLORARG2 = 3, - WINED3DTSS_ALPHAOP = 4, - WINED3DTSS_ALPHAARG1 = 5, - WINED3DTSS_ALPHAARG2 = 6, - WINED3DTSS_BUMPENVMAT00 = 7, - WINED3DTSS_BUMPENVMAT01 = 8, - WINED3DTSS_BUMPENVMAT10 = 9, - WINED3DTSS_BUMPENVMAT11 = 10, - WINED3DTSS_TEXCOORDINDEX = 11, - WINED3DTSS_BUMPENVLSCALE = 22, - WINED3DTSS_BUMPENVLOFFSET = 23, - WINED3DTSS_TEXTURETRANSFORMFLAGS = 24, - WINED3DTSS_COLORARG0 = 26, - WINED3DTSS_ALPHAARG0 = 27, - WINED3DTSS_RESULTARG = 28, - WINED3DTSS_CONSTANT = 32, + WINED3DTSS_COLOROP = 0, + WINED3DTSS_COLORARG1 = 1, + WINED3DTSS_COLORARG2 = 2, + WINED3DTSS_ALPHAOP = 3, + WINED3DTSS_ALPHAARG1 = 4, + WINED3DTSS_ALPHAARG2 = 5, + WINED3DTSS_BUMPENVMAT00 = 6, + WINED3DTSS_BUMPENVMAT01 = 7, + WINED3DTSS_BUMPENVMAT10 = 8, + WINED3DTSS_BUMPENVMAT11 = 9, + WINED3DTSS_TEXCOORDINDEX = 10, + WINED3DTSS_BUMPENVLSCALE = 11, + WINED3DTSS_BUMPENVLOFFSET = 12, + WINED3DTSS_TEXTURETRANSFORMFLAGS = 13, + WINED3DTSS_COLORARG0 = 14, + WINED3DTSS_ALPHAARG0 = 15, + WINED3DTSS_RESULTARG = 16, + WINED3DTSS_CONSTANT = 17, WINED3DTSS_FORCE_DWORD = 0x7fffffff } WINED3DTEXTURESTAGESTATETYPE; const UINT WINED3D_HIGHEST_TEXTURE_STATE = WINED3DTSS_CONSTANT; diff --git a/include/winnt.h b/include/winnt.h index 57f4c5c354b..6dadf9ed819 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -879,109 +879,109 @@ typedef struct DECLSPEC_ALIGN(16) _M128A { } M128A, *PM128A; typedef struct _XMM_SAVE_AREA32 { - WORD ControlWord; - WORD StatusWord; - BYTE TagWord; - BYTE Reserved1; - WORD ErrorOpcode; - DWORD ErrorOffset; - WORD ErrorSelector; - WORD Reserved2; - DWORD DataOffset; - WORD DataSelector; - WORD Reserved3; - DWORD MxCsr; - DWORD MxCsr_Mask; - M128A FloatRegisters[8]; - M128A XmmRegisters[16]; - BYTE Reserved4[96]; + WORD ControlWord; /* 000 */ + WORD StatusWord; /* 002 */ + BYTE TagWord; /* 004 */ + BYTE Reserved1; /* 005 */ + WORD ErrorOpcode; /* 006 */ + DWORD ErrorOffset; /* 008 */ + WORD ErrorSelector; /* 00c */ + WORD Reserved2; /* 00e */ + DWORD DataOffset; /* 010 */ + WORD DataSelector; /* 014 */ + WORD Reserved3; /* 016 */ + DWORD MxCsr; /* 018 */ + DWORD MxCsr_Mask; /* 01c */ + M128A FloatRegisters[8]; /* 020 */ + M128A XmmRegisters[16]; /* 0a0 */ + BYTE Reserved4[96]; /* 1a0 */ } XMM_SAVE_AREA32, *PXMM_SAVE_AREA32; typedef struct DECLSPEC_ALIGN(16) _CONTEXT { - DWORD64 P1Home; - DWORD64 P2Home; - DWORD64 P3Home; - DWORD64 P4Home; - DWORD64 P5Home; - DWORD64 P6Home; + DWORD64 P1Home; /* 000 */ + DWORD64 P2Home; /* 008 */ + DWORD64 P3Home; /* 010 */ + DWORD64 P4Home; /* 018 */ + DWORD64 P5Home; /* 020 */ + DWORD64 P6Home; /* 028 */ /* Control flags */ - DWORD ContextFlags; - DWORD MxCsr; + DWORD ContextFlags; /* 030 */ + DWORD MxCsr; /* 034 */ /* Segment */ - WORD SegCs; - WORD SegDs; - WORD SegEs; - WORD SegFs; - WORD SegGs; - WORD SegSs; - DWORD EFlags; + WORD SegCs; /* 038 */ + WORD SegDs; /* 03a */ + WORD SegEs; /* 03c */ + WORD SegFs; /* 03e */ + WORD SegGs; /* 040 */ + WORD SegSs; /* 042 */ + DWORD EFlags; /* 044 */ /* Debug */ - DWORD64 Dr0; - DWORD64 Dr1; - DWORD64 Dr2; - DWORD64 Dr3; - DWORD64 Dr6; - DWORD64 Dr7; + DWORD64 Dr0; /* 048 */ + DWORD64 Dr1; /* 050 */ + DWORD64 Dr2; /* 058 */ + DWORD64 Dr3; /* 060 */ + DWORD64 Dr6; /* 068 */ + DWORD64 Dr7; /* 070 */ /* Integer */ - DWORD64 Rax; - DWORD64 Rcx; - DWORD64 Rdx; - DWORD64 Rbx; - DWORD64 Rsp; - DWORD64 Rbp; - DWORD64 Rsi; - DWORD64 Rdi; - DWORD64 R8; - DWORD64 R9; - DWORD64 R10; - DWORD64 R11; - DWORD64 R12; - DWORD64 R13; - DWORD64 R14; - DWORD64 R15; + DWORD64 Rax; /* 078 */ + DWORD64 Rcx; /* 080 */ + DWORD64 Rdx; /* 088 */ + DWORD64 Rbx; /* 090 */ + DWORD64 Rsp; /* 098 */ + DWORD64 Rbp; /* 0a0 */ + DWORD64 Rsi; /* 0a8 */ + DWORD64 Rdi; /* 0b0 */ + DWORD64 R8; /* 0b8 */ + DWORD64 R9; /* 0c0 */ + DWORD64 R10; /* 0c8 */ + DWORD64 R11; /* 0d0 */ + DWORD64 R12; /* 0d8 */ + DWORD64 R13; /* 0e0 */ + DWORD64 R14; /* 0e8 */ + DWORD64 R15; /* 0f0 */ /* Counter */ - DWORD64 Rip; + DWORD64 Rip; /* 0f8 */ /* Floating point */ union { - XMM_SAVE_AREA32 FltSave; + XMM_SAVE_AREA32 FltSave; /* 100 */ struct { - M128A Header[2]; - M128A Legacy[8]; - M128A Xmm0; - M128A Xmm1; - M128A Xmm2; - M128A Xmm3; - M128A Xmm4; - M128A Xmm5; - M128A Xmm6; - M128A Xmm7; - M128A Xmm8; - M128A Xmm9; - M128A Xmm10; - M128A Xmm11; - M128A Xmm12; - M128A Xmm13; - M128A Xmm14; - M128A Xmm15; + M128A Header[2]; /* 100 */ + M128A Legacy[8]; /* 120 */ + M128A Xmm0; /* 1a0 */ + M128A Xmm1; /* 1b0 */ + M128A Xmm2; /* 1c0 */ + M128A Xmm3; /* 1d0 */ + M128A Xmm4; /* 1e0 */ + M128A Xmm5; /* 1f0 */ + M128A Xmm6; /* 200 */ + M128A Xmm7; /* 210 */ + M128A Xmm8; /* 220 */ + M128A Xmm9; /* 230 */ + M128A Xmm10; /* 240 */ + M128A Xmm11; /* 250 */ + M128A Xmm12; /* 260 */ + M128A Xmm13; /* 270 */ + M128A Xmm14; /* 280 */ + M128A Xmm15; /* 290 */ } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; /* Vector */ - M128A VectorRegister[26]; - DWORD64 VectorControl; + M128A VectorRegister[26]; /* 300 */ + DWORD64 VectorControl; /* 4a0 */ /* Debug control */ - DWORD64 DebugControl; - DWORD64 LastBranchToRip; - DWORD64 LastBranchFromRip; - DWORD64 LastExceptionToRip; - DWORD64 LastExceptionFromRip; + DWORD64 DebugControl; /* 4a8 */ + DWORD64 LastBranchToRip; /* 4b0 */ + DWORD64 LastBranchFromRip; /* 4b8 */ + DWORD64 LastExceptionToRip; /* 4c0 */ + DWORD64 LastExceptionFromRip; /* 4c8 */ } CONTEXT; typedef struct _RUNTIME_FUNCTION diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index ad186ff91e8..db8b02f52c0 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -66,6 +66,60 @@ static const WCHAR parmY[] = {'/','Y','\0'}; static const WCHAR parmNoY[] = {'/','-','Y','\0'}; static const WCHAR nullW[] = {'\0'}; +/************************************************************************** + * WCMD_ask_confirm + * + * Issue a message and ask 'Are you sure (Y/N)', waiting on a valid + * answer. + * + * Returns True if Y (or A) answer is selected + * If optionAll contains a pointer, ALL is allowed, and if answered + * set to TRUE + * + */ +static BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll) { + + WCHAR msgbuffer[MAXSTRING]; + WCHAR Ybuffer[MAXSTRING]; + WCHAR Nbuffer[MAXSTRING]; + WCHAR Abuffer[MAXSTRING]; + WCHAR answer[MAX_PATH] = {'\0'}; + DWORD count = 0; + + /* Load the translated 'Are you sure', plus valid answers */ + LoadString (hinst, WCMD_CONFIRM, msgbuffer, sizeof(msgbuffer)/sizeof(WCHAR)); + LoadString (hinst, WCMD_YES, Ybuffer, sizeof(Ybuffer)/sizeof(WCHAR)); + LoadString (hinst, WCMD_NO, Nbuffer, sizeof(Nbuffer)/sizeof(WCHAR)); + LoadString (hinst, WCMD_ALL, Abuffer, sizeof(Abuffer)/sizeof(WCHAR)); + + /* Loop waiting on a Y or N */ + while (answer[0] != Ybuffer[0] && answer[0] != Nbuffer[0]) { + static const WCHAR startBkt[] = {' ','(','\0'}; + static const WCHAR endBkt[] = {')','?','\0'}; + + WCMD_output_asis (message); + if (showSureText) { + WCMD_output_asis (msgbuffer); + } + WCMD_output_asis (startBkt); + WCMD_output_asis (Ybuffer); + WCMD_output_asis (fslashW); + WCMD_output_asis (Nbuffer); + if (optionAll) { + WCMD_output_asis (fslashW); + WCMD_output_asis (Abuffer); + } + WCMD_output_asis (endBkt); + WCMD_ReadFile (GetStdHandle(STD_INPUT_HANDLE), answer, + sizeof(answer)/sizeof(WCHAR), &count, NULL); + answer[0] = toupperW(answer[0]); + } + + /* Return the answer */ + return ((answer[0] == Ybuffer[0]) || + (optionAll && (answer[0] == Abuffer[0]))); +} + /**************************************************************************** * WCMD_clear_screen * @@ -2482,59 +2536,6 @@ void WCMD_exit (CMD_LIST **cmdList) { } } -/************************************************************************** - * WCMD_ask_confirm - * - * Issue a message and ask 'Are you sure (Y/N)', waiting on a valid - * answer. - * - * Returns True if Y (or A) answer is selected - * If optionAll contains a pointer, ALL is allowed, and if answered - * set to TRUE - * - */ -BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll) { - - WCHAR msgbuffer[MAXSTRING]; - WCHAR Ybuffer[MAXSTRING]; - WCHAR Nbuffer[MAXSTRING]; - WCHAR Abuffer[MAXSTRING]; - WCHAR answer[MAX_PATH] = {'\0'}; - DWORD count = 0; - - /* Load the translated 'Are you sure', plus valid answers */ - LoadString (hinst, WCMD_CONFIRM, msgbuffer, sizeof(msgbuffer)/sizeof(WCHAR)); - LoadString (hinst, WCMD_YES, Ybuffer, sizeof(Ybuffer)/sizeof(WCHAR)); - LoadString (hinst, WCMD_NO, Nbuffer, sizeof(Nbuffer)/sizeof(WCHAR)); - LoadString (hinst, WCMD_ALL, Abuffer, sizeof(Abuffer)/sizeof(WCHAR)); - - /* Loop waiting on a Y or N */ - while (answer[0] != Ybuffer[0] && answer[0] != Nbuffer[0]) { - static const WCHAR startBkt[] = {' ','(','\0'}; - static const WCHAR endBkt[] = {')','?','\0'}; - - WCMD_output_asis (message); - if (showSureText) { - WCMD_output_asis (msgbuffer); - } - WCMD_output_asis (startBkt); - WCMD_output_asis (Ybuffer); - WCMD_output_asis (fslashW); - WCMD_output_asis (Nbuffer); - if (optionAll) { - WCMD_output_asis (fslashW); - WCMD_output_asis (Abuffer); - } - WCMD_output_asis (endBkt); - WCMD_ReadFile (GetStdHandle(STD_INPUT_HANDLE), answer, - sizeof(answer)/sizeof(WCHAR), &count, NULL); - answer[0] = toupperW(answer[0]); - } - - /* Return the answer */ - return ((answer[0] == Ybuffer[0]) || - (optionAll && (answer[0] == Abuffer[0]))); -} /***************************************************************************** * WCMD_assoc diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index cd17d31d719..647f4f158f3 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -74,7 +74,7 @@ static const WCHAR spaceW[] = {' ','\0'}; * * Reverse a WCHARacter string in-place (strrev() is not available under unixen :-( ). */ -WCHAR * WCMD_strrev (WCHAR *buff) { +static WCHAR * WCMD_strrev (WCHAR *buff) { int r, i; WCHAR b; @@ -95,7 +95,7 @@ WCHAR * WCMD_strrev (WCHAR *buff) { * Result is returned in a static string overwritten with each call. * FIXME: There must be a better algorithm! */ -WCHAR * WCMD_filesize64 (ULONGLONG n) { +static WCHAR * WCMD_filesize64 (ULONGLONG n) { ULONGLONG q; unsigned int r, i; @@ -121,7 +121,7 @@ WCHAR * WCMD_filesize64 (ULONGLONG n) { * * Sort based on the /O options supplied on the command line */ -int WCMD_dir_sort (const void *a, const void *b) +static int WCMD_dir_sort (const void *a, const void *b) { WIN32_FIND_DATA *filea = (WIN32_FIND_DATA *)a; WIN32_FIND_DATA *fileb = (WIN32_FIND_DATA *)b; @@ -200,7 +200,7 @@ int WCMD_dir_sort (const void *a, const void *b) * * Reverse a WCHARacter string in-place (strrev() is not available under unixen :-( ). */ -void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) { +static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) { ULONG sizeNeeded = 0; DWORD rc; diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 99515852946..a31b0113475 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -70,7 +70,6 @@ void WCMD_more (WCHAR *); void WCMD_move (void); void WCMD_output (const WCHAR *format, ...); void WCMD_output_asis (const WCHAR *message); -void WCMD_parse (WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2); void WCMD_pause (void); void WCMD_popd (void); void WCMD_print_error (void); @@ -88,7 +87,6 @@ void WCMD_setshow_path (WCHAR *command); void WCMD_setshow_prompt (void); void WCMD_setshow_time (void); void WCMD_shift (WCHAR *command); -void WCMD_show_prompt (void); void WCMD_title (WCHAR *); void WCMD_type (WCHAR *); void WCMD_verify (WCHAR *command); @@ -98,10 +96,7 @@ int WCMD_volume (int mode, WCHAR *command); WCHAR *WCMD_fgets (WCHAR *s, int n, HANDLE stream); WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where); WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string); -void WCMD_strtrim_trailing_spaces (WCHAR *string); -void WCMD_opt_s_strip_quotes(WCHAR *cmd); void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable, WCHAR *forValue, BOOL justFors); -BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll); void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext); WCHAR *WCMD_LoadMessage(UINT id); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index e4f29a1f350..4c513fb30b7 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -309,7 +309,7 @@ void WCMD_print_error (void) { * */ -void WCMD_show_prompt (void) { +static void WCMD_show_prompt (void) { int status; WCHAR out_string[MAX_PATH], curdir[MAX_PATH], prompt_string[MAX_PATH]; @@ -438,28 +438,11 @@ WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string) { } /************************************************************************* - * WCMD_strtrim_trailing_spaces - * - * Remove trailing spaces from a string. This routine modifies the input - * string by placing a null after the last non-space WCHARacter - */ -void WCMD_strtrim_trailing_spaces (WCHAR *string) { - - WCHAR *ptr; - - ptr = string + strlenW (string) - 1; - while ((*ptr == ' ') && (ptr >= string)) { - *ptr = '\0'; - ptr--; - } -} - -/************************************************************************* * WCMD_opt_s_strip_quotes * * Remove first and last quote WCHARacters, preserving all other text */ -void WCMD_opt_s_strip_quotes(WCHAR *cmd) { +static void WCMD_opt_s_strip_quotes(WCHAR *cmd) { WCHAR *src = cmd + 1, *dest = cmd, *lastq = NULL; while((*dest=*src) != '\0') { if (*src=='\"') @@ -778,7 +761,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR *forVar, WCHAR *forVal) { * read in and not again, except for 'for' variable substitution. * eg. As evidence, "echo %1 && shift && echo %1" or "echo %%path%%" */ -void handleExpansion(WCHAR *cmd, BOOL justFors, WCHAR *forVariable, WCHAR *forValue) { +static void handleExpansion(WCHAR *cmd, BOOL justFors, WCHAR *forVariable, WCHAR *forValue) { /* For commands in a context (batch program): */ /* Expand environment variables in a batch file %{0-9} first */ @@ -863,7 +846,7 @@ void handleExpansion(WCHAR *cmd, BOOL justFors, WCHAR *forVariable, WCHAR *forVa * second in p2. Any subsequent non-qualifier strings are lost. * Parameters in quotes are handled. */ -void WCMD_parse (WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2) +static void WCMD_parse (WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2) { int p = 0; @@ -1629,7 +1612,7 @@ static void WCMD_DumpCommands(CMD_LIST *commands) { * * Adds a command to the current command list */ -void WCMD_addCommand(WCHAR *command, int *commandLen, +static void WCMD_addCommand(WCHAR *command, int *commandLen, WCHAR *redirs, int *redirLen, WCHAR **copyTo, int **copyToLen, CMD_DELIMITERS prevDelim, int curDepth, diff --git a/programs/explorer/appbar.c b/programs/explorer/appbar.c index f6e1eb1c9e6..2947ccd3c77 100644 --- a/programs/explorer/appbar.c +++ b/programs/explorer/appbar.c @@ -203,7 +203,6 @@ static UINT_PTR handle_appbarmessage(DWORD msg, PAPPBARDATA abd) abd->uEdge = ABE_BOTTOM; return TRUE; case ABM_ACTIVATE: - WINE_FIXME("SHAppBarMessage(ABM_ACTIVATE, hwnd=%p, lparam=%lx): stub\n", abd->hWnd, abd->lParam); return TRUE; case ABM_GETAUTOHIDEBAR: WINE_FIXME("SHAppBarMessage(ABM_GETAUTOHIDEBAR, hwnd=%p, edge=%x): stub\n", abd->hWnd, abd->uEdge); @@ -212,7 +211,6 @@ static UINT_PTR handle_appbarmessage(DWORD msg, PAPPBARDATA abd) WINE_FIXME("SHAppBarMessage(ABM_SETAUTOHIDEBAR, hwnd=%p, edge=%x, lparam=%lx): stub\n", abd->hWnd, abd->uEdge, abd->lParam); return TRUE; case ABM_WINDOWPOSCHANGED: - WINE_FIXME("SHAppBarMessage(ABM_WINDOWPOSCHANGED, hwnd=%p): stub\n", abd->hWnd); return TRUE; default: WINE_FIXME("SHAppBarMessage(%x) unimplemented\n", msg); diff --git a/programs/oleview/details.c b/programs/oleview/details.c index 3e266cc3d80..da43de9a634 100644 --- a/programs/oleview/details.c +++ b/programs/oleview/details.c @@ -350,7 +350,7 @@ static void CreateTabCtrl(HWND hWnd) 0, 0, 0, 0, details.hTab, NULL, globals.hMainInst, NULL); } -LRESULT CALLBACK DetailsProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK DetailsProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { int sel; diff --git a/programs/oleview/interface.c b/programs/oleview/interface.c index 2459b74bb30..5262187b946 100644 --- a/programs/oleview/interface.c +++ b/programs/oleview/interface.c @@ -63,7 +63,7 @@ static IUnknown *GetInterface(void) return unk; } -INT_PTR CALLBACK InterfaceViewerProc(HWND hDlgWnd, UINT uMsg, +static INT_PTR CALLBACK InterfaceViewerProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { DIALOG_INFO *di; diff --git a/programs/oleview/oleview.c b/programs/oleview/oleview.c index 153b768822e..592fa0b5782 100644 --- a/programs/oleview/oleview.c +++ b/programs/oleview/oleview.c @@ -26,7 +26,7 @@ static WCHAR wszFormat[] = { '<','o','b','j','e','c','t','\n',' ',' ',' ', 'c','l','a','s','s','i','d','=','\"','c','l','s','i','d',':','%','s','\"','\n', '>','\n','<','/','o','b','j','e','c','t','>','\0' }; -INT_PTR CALLBACK SysConfProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK SysConfProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HKEY hKey; WCHAR buffer[MAX_LOAD_STRING]; @@ -98,7 +98,7 @@ INT_PTR CALLBACK SysConfProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lPar return FALSE; } -INT_PTR CALLBACK CreateInstOnProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK CreateInstOnProc(HWND hDlgWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND hEdit; @@ -431,7 +431,7 @@ static void UpdateStatusBar(int itemID) SendMessage(globals.hStatusBar, SB_SETTEXT, 0, (LPARAM)info); } -LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, +static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) diff --git a/programs/oleview/pane.c b/programs/oleview/pane.c index f274be84553..20c2fd63310 100644 --- a/programs/oleview/pane.c +++ b/programs/oleview/pane.c @@ -57,7 +57,7 @@ static void DrawSplitMoving(HWND hWnd, int x) ReleaseDC(hWnd, hdc); } -LRESULT CALLBACK PaneProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK PaneProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { POINT pt; PANE *pane = (PANE*)GetMenu(hWnd); diff --git a/programs/oleview/tree.c b/programs/oleview/tree.c index a6a992ad26f..3c9ee5ab17b 100644 --- a/programs/oleview/tree.c +++ b/programs/oleview/tree.c @@ -646,7 +646,7 @@ void AddTree(void) AddCOMandAll(); } -LRESULT CALLBACK TreeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK TreeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { diff --git a/programs/oleview/typelib.c b/programs/oleview/typelib.c index c794868f427..4861c5044d9 100644 --- a/programs/oleview/typelib.c +++ b/programs/oleview/typelib.c @@ -189,12 +189,12 @@ static void GetSaveIdlAsPath(void) SaveIdl(wszPath); } -void AddToStrW(WCHAR *wszDest, const WCHAR *wszSource) +static void AddToStrW(WCHAR *wszDest, const WCHAR *wszSource) { lstrcpyW(&wszDest[lstrlenW(wszDest)], wszSource); } -void AddToTLDataStrW(TYPELIB_DATA *pTLData, const WCHAR *wszSource) +static void AddToTLDataStrW(TYPELIB_DATA *pTLData, const WCHAR *wszSource) { int SourceLen = lstrlenW(wszSource); @@ -205,7 +205,7 @@ void AddToTLDataStrW(TYPELIB_DATA *pTLData, const WCHAR *wszSource) pTLData->idlLen += SourceLen; } -void AddToTLDataStrWithTabsW(TYPELIB_DATA *pTLData, WCHAR *wszSource) +static void AddToTLDataStrWithTabsW(TYPELIB_DATA *pTLData, WCHAR *wszSource) { int lineLen = lstrlenW(wszSource); int newLinesNo = 0; @@ -1552,7 +1552,7 @@ static void EmptyTLTree(void) } } -LRESULT CALLBACK TypeLibProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK TypeLibProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { diff --git a/programs/regedit/Bg.rc b/programs/regedit/Bg.rc index 0c86d04f602..67a10248407 100644 --- a/programs/regedit/Bg.rc +++ b/programs/regedit/Bg.rc @@ -266,8 +266,8 @@ BEGIN IDS_ERROR "Ãðåøêà" IDS_BAD_KEY "Çàÿâêàòà çà êëþ÷ '%s' íåóñïåøíà" IDS_BAD_VALUE "Çàÿâêàòà çà ñòîéíîñò '%s' íåóñïåøíà" - IDS_UNSUPPORTED_TYPE "Íå ìîæå äà ðåäàêòèðàòå êëþ÷îâå îò òîçè òèï (%ld)" - IDS_TOO_BIG_VALUE "Ñòîéíîñòòà å ïðåêàëåíî ãîëÿìà (%ld)" + IDS_UNSUPPORTED_TYPE "Íå ìîæå äà ðåäàêòèðàòå êëþ÷îâå îò òîçè òèï (%u)" + 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?" diff --git a/programs/regedit/Cs.rc b/programs/regedit/Cs.rc index 3816e3c1640..250f7e40a88 100644 --- a/programs/regedit/Cs.rc +++ b/programs/regedit/Cs.rc @@ -217,8 +217,8 @@ BEGIN IDS_ERROR "Chyba" IDS_BAD_KEY "Nelze najít klíè '%s'" IDS_BAD_VALUE "Nelze najít položku '%s'" - IDS_UNSUPPORTED_TYPE "Nemohu upravit klíèe tohoto typu (%ld)" - IDS_TOO_BIG_VALUE "Hodnota je pøíliš velká (%ld)" + IDS_UNSUPPORTED_TYPE "Nemohu upravit klíèe tohoto typu (%u)" + IDS_TOO_BIG_VALUE "Hodnota je pøíliš velká (%u)" IDS_DELETE_BOX_TITLE "Potvrïte smazání položky" IDS_DELETE_BOX_TEXT "Opravdu chcete smazat položku '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/Da.rc b/programs/regedit/Da.rc index 8e5eb3a39f1..eb2a7cb8f44 100644 --- a/programs/regedit/Da.rc +++ b/programs/regedit/Da.rc @@ -288,8 +288,8 @@ BEGIN IDS_ERROR "Fejl" IDS_BAD_KEY "Kunne ikke tilgå nøgleen '%s'" IDS_BAD_VALUE "Kunne ikke tilgå værdien '%s'" - IDS_UNSUPPORTED_TYPE "Kunne ikke redigere nøgler af typen '%ld'" - IDS_TOO_BIG_VALUE "Værdien er for stor (%ld)" + IDS_UNSUPPORTED_TYPE "Kunne ikke redigere nøgler af typen '%u'" + IDS_TOO_BIG_VALUE "Værdien er for stor (%u)" IDS_DELETE_BOX_TITLE "Bekræft sletning af værdi" IDS_DELETE_BOX_TEXT "Er du sikker på at ville slette værdien '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/De.rc b/programs/regedit/De.rc index 6df36adba43..4ccb63aaa97 100644 --- a/programs/regedit/De.rc +++ b/programs/regedit/De.rc @@ -295,8 +295,8 @@ BEGIN IDS_ERROR "Fehler" IDS_BAD_KEY "Kann den Schlüssel '%s' nicht lesen" IDS_BAD_VALUE "Kann den Wert '%s' nicht lesen" - IDS_UNSUPPORTED_TYPE "Kann Schlüssel von diesem Typ (%ld) nicht ändern" - IDS_TOO_BIG_VALUE "Der Wert ist zu groß (%ld)" + IDS_UNSUPPORTED_TYPE "Kann Schlüssel von diesem Typ (%u) nicht ändern" + IDS_TOO_BIG_VALUE "Der Wert ist zu groß (%u)" IDS_DELETE_BOX_TITLE "Bitte bestätigen" IDS_DELETE_BOX_TEXT "Wollen Sie '%s' wirklich löschen?" IDS_DELETE_BOX_TEXT_MULTIPLE "Wollen Sie diese Werte wirklich löschen?" diff --git a/programs/regedit/En.rc b/programs/regedit/En.rc index 8cc37aa663e..51bb5c384f2 100644 --- a/programs/regedit/En.rc +++ b/programs/regedit/En.rc @@ -367,8 +367,8 @@ BEGIN IDS_ERROR "Error" IDS_BAD_KEY "Can't query key '%s'" IDS_BAD_VALUE "Can't query value '%s'" - IDS_UNSUPPORTED_TYPE "Can't edit keys of this type (%ld)" - IDS_TOO_BIG_VALUE "Value is too big (%ld)" + IDS_UNSUPPORTED_TYPE "Can't edit keys of this type (%u)" + IDS_TOO_BIG_VALUE "Value is too big (%u)" IDS_DELETE_BOX_TITLE "Confirm Value Delete" IDS_DELETE_BOX_TEXT "Are you sure you want to delete value '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/Es.rc b/programs/regedit/Es.rc index 2e64e558b63..b640abec69c 100644 --- a/programs/regedit/Es.rc +++ b/programs/regedit/Es.rc @@ -290,8 +290,8 @@ BEGIN IDS_ERROR "Error" IDS_BAD_KEY "No se puede consultar la clave '%s'" IDS_BAD_VALUE "No se puede consultar el valor '%s'" - IDS_UNSUPPORTED_TYPE "No se pueden editar claves de este tipo (%ld)" - IDS_TOO_BIG_VALUE "El valor es demasiado grande (%ld)" + IDS_UNSUPPORTED_TYPE "No se pueden editar claves de este tipo (%u)" + IDS_TOO_BIG_VALUE "El valor es demasiado grande (%u)" IDS_DELETE_BOX_TITLE "Confirmar eliminación de valor" IDS_DELETE_BOX_TEXT "¿Seguro que desea eliminar el valor '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/Fr.rc b/programs/regedit/Fr.rc index 079457f2733..db21b4b0aa5 100644 --- a/programs/regedit/Fr.rc +++ b/programs/regedit/Fr.rc @@ -290,8 +290,8 @@ BEGIN IDS_ERROR "Erreur" IDS_BAD_KEY "Ne peut pas questionner la clé '%s'" IDS_BAD_VALUE "Ne peut pas questionner la valeur '%s'" - IDS_UNSUPPORTED_TYPE "Ne peut pas éditer des clés de ce type (%ld)" - IDS_TOO_BIG_VALUE "La valeur est trop grande (%ld)" + IDS_UNSUPPORTED_TYPE "Ne peut pas éditer des clés de ce type (%u)" + IDS_TOO_BIG_VALUE "La valeur est trop grande (%u)" IDS_DELETE_BOX_TITLE "Confirmez l'effacement de valeur" IDS_DELETE_BOX_TEXT "Êtes vous sûr vous voulez supprimer la valeur '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Êtes vous sûr vous voulez supprimer cette valeurs?" diff --git a/programs/regedit/Hu.rc b/programs/regedit/Hu.rc index 3ef9eae7e0a..bad44e8acc4 100644 --- a/programs/regedit/Hu.rc +++ b/programs/regedit/Hu.rc @@ -228,8 +228,8 @@ BEGIN IDS_ERROR "Hiba" IDS_BAD_KEY "Nem tudom lekérni a kulcsot: '%s'" IDS_BAD_VALUE "Nem tudom lekérni az értéket: '%s'" - IDS_UNSUPPORTED_TYPE "Nem tudom ezt a típusú kulcsot szerkeszteni: (%ld)" - IDS_TOO_BIG_VALUE "Az érték túl nagy: (%ld)" + IDS_UNSUPPORTED_TYPE "Nem tudom ezt a típusú kulcsot szerkeszteni: (%u)" + IDS_TOO_BIG_VALUE "Az érték túl nagy: (%u)" IDS_DELETE_BOX_TITLE "Értéktörlés jóváhagyása" IDS_DELETE_BOX_TEXT "Biztos hogy törölni szeretné a(z) '%s' kulcsot?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/It.rc b/programs/regedit/It.rc index 3c3064bf4d6..8876057f600 100644 --- a/programs/regedit/It.rc +++ b/programs/regedit/It.rc @@ -264,8 +264,8 @@ BEGIN IDS_ERROR "Errore" IDS_BAD_KEY "Impossibile trovare la chiave '%s'" IDS_BAD_VALUE "Impossibile trovare il valore '%s'" - IDS_UNSUPPORTED_TYPE "Impossibile editare valori di questo tipo (%ld)" - IDS_TOO_BIG_VALUE "Valore troppo grande (%ld)" + IDS_UNSUPPORTED_TYPE "Impossibile editare valori di questo tipo (%u)" + IDS_TOO_BIG_VALUE "Valore troppo grande (%u)" IDS_DELETE_BOX_TITLE "Confermare Cancellazione del Valore" IDS_DELETE_BOX_TEXT "Sei sicuro di voler cancellare il valore '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/Ja.rc b/programs/regedit/Ja.rc index 44ad89bdde4..75afc1bc869 100644 --- a/programs/regedit/Ja.rc +++ b/programs/regedit/Ja.rc @@ -291,8 +291,8 @@ BEGIN IDS_ERROR "エラー" IDS_BAD_KEY "キー '%s'が所得できません" IDS_BAD_VALUE "値 '%s'が所得できません" - IDS_UNSUPPORTED_TYPE "このタイプのキーは編集できません (%ld)" - IDS_TOO_BIG_VALUE "値が大きすぎます (%ld)" + IDS_UNSUPPORTED_TYPE "このタイプのキーは編集できません (%u)" + IDS_TOO_BIG_VALUE "値が大きすぎます (%u)" IDS_DELETE_BOX_TITLE "値の削除確認" IDS_DELETE_BOX_TEXT "本当に '%s'を削除しますか?" IDS_DELETE_BOX_TEXT_MULTIPLE "これらの値を削除しますか?" diff --git a/programs/regedit/Ko.rc b/programs/regedit/Ko.rc index b73aa8da058..67e248403ed 100644 --- a/programs/regedit/Ko.rc +++ b/programs/regedit/Ko.rc @@ -292,8 +292,8 @@ BEGIN IDS_ERROR "¿¡·¯" IDS_BAD_KEY "Å° '%s'¸¦ ÁúÀÇÇÒ ¼ö ¾ø½À´Ï´Ù" IDS_BAD_VALUE "°ª '%s'¸¦ ÁúÀÇÇÒ ¼ö ¾ø½À´Ï´Ù" - IDS_UNSUPPORTED_TYPE "ÀÌ Å¸ÀÔ (%ld)ÀÇ Å°¸¦ °íÄ¥ ¼ö ¾ø½À´Ï´Ù" - IDS_TOO_BIG_VALUE "°ªÀÌ ³Ê¹« Å®´Ï´Ù (%ld)" + IDS_UNSUPPORTED_TYPE "ÀÌ Å¸ÀÔ (%u)ÀÇ Å°¸¦ °íÄ¥ ¼ö ¾ø½À´Ï´Ù" + 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?" diff --git a/programs/regedit/Nl.rc b/programs/regedit/Nl.rc index 69c5858c4fd..3e92021fbef 100644 --- a/programs/regedit/Nl.rc +++ b/programs/regedit/Nl.rc @@ -289,8 +289,8 @@ BEGIN IDS_ERROR "Fout" IDS_BAD_KEY "Kan sleutel '%s' niet opvragen" IDS_BAD_VALUE "Kan waarde '%s' niet opvragen" - IDS_UNSUPPORTED_TYPE "Kan dit type sleutel (%ld) niet bewerken" - IDS_TOO_BIG_VALUE "Waarde te groot (%ld)" + IDS_UNSUPPORTED_TYPE "Kan dit type sleutel (%u) niet bewerken" + IDS_TOO_BIG_VALUE "Waarde te groot (%u)" IDS_DELETE_BOX_TITLE "Waarde verwijderen bevestigen" IDS_DELETE_BOX_TEXT "Weet u zeker dat u de waarde '%s' wilt verwijderen?" IDS_DELETE_BOX_TEXT_MULTIPLE "Weet u zeker dat u deze waarden wilt verwijderen?" diff --git a/programs/regedit/No.rc b/programs/regedit/No.rc index 62b7055bce0..7601e018be4 100644 --- a/programs/regedit/No.rc +++ b/programs/regedit/No.rc @@ -288,8 +288,8 @@ BEGIN IDS_ERROR "Feil" IDS_BAD_KEY "Klarte ikke lese nøkkelen «%s»" IDS_BAD_VALUE "Klarte ikke lese verdien «%s»" - IDS_UNSUPPORTED_TYPE "Kan ikke redigere nøkler av typen «%ld»" - IDS_TOO_BIG_VALUE "Verdien er for stor (%ld)" + IDS_UNSUPPORTED_TYPE "Kan ikke redigere nøkler av typen «%u»" + IDS_TOO_BIG_VALUE "Verdien er for stor (%u)" IDS_DELETE_BOX_TITLE "Bekreft sletting av verdi" IDS_DELETE_BOX_TEXT "Virkelig slette verdien «%s»?" IDS_DELETE_BOX_TEXT_MULTIPLE "Virkelig slette disse verdiene?" diff --git a/programs/regedit/Pl.rc b/programs/regedit/Pl.rc index eadeca0d0aa..7aa4c5e6eb2 100644 --- a/programs/regedit/Pl.rc +++ b/programs/regedit/Pl.rc @@ -288,8 +288,8 @@ BEGIN IDS_ERROR "B³¹d" IDS_BAD_KEY "Nie uda³o sie przeczytaæ klucza '%s'" IDS_BAD_VALUE "Nie uda³o sie przeczytaæ danej '%s'" - IDS_UNSUPPORTED_TYPE "Nie da siê modyfikowaæ kluczy tego typu (%ld)" - IDS_TOO_BIG_VALUE "Wartoœæ jest zbyt du¿a (%ld)" + IDS_UNSUPPORTED_TYPE "Nie da siê modyfikowaæ kluczy tego typu (%u)" + IDS_TOO_BIG_VALUE "Wartoœæ jest zbyt du¿a (%u)" IDS_DELETE_BOX_TITLE "Potwierdzenie kasowania" IDS_DELETE_BOX_TEXT "Jesteœ pewien, ¿e chcesz usun¹æ dan¹ '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/Pt.rc b/programs/regedit/Pt.rc index ee2b8ff5d2a..44c6a2960f4 100644 --- a/programs/regedit/Pt.rc +++ b/programs/regedit/Pt.rc @@ -355,8 +355,8 @@ BEGIN IDS_ERROR "Erro" IDS_BAD_KEY "Não pode consultar a chave '%s'" IDS_BAD_VALUE "Não pode consultar o valor '%s'" - IDS_UNSUPPORTED_TYPE "Não pode editar chaves deste tipo (%ld)" - IDS_TOO_BIG_VALUE "Valor é muito grande (%ld)" + IDS_UNSUPPORTED_TYPE "Não pode editar chaves deste tipo (%u)" + IDS_TOO_BIG_VALUE "Valor é muito grande (%u)" IDS_DELETE_BOX_TITLE "Confirmar exclusão de valor" IDS_DELETE_BOX_TEXT "Tem certeza que deseja excluir o valor '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" @@ -372,8 +372,8 @@ BEGIN IDS_ERROR "Erro" IDS_BAD_KEY "Não pode perguntar a chave '%s'" IDS_BAD_VALUE "Não pode perguntar o valor '%s'" - IDS_UNSUPPORTED_TYPE "Não pode editar chaves deste tipo (%ld)" - IDS_TOO_BIG_VALUE "Valor muito grande (%ld)" + IDS_UNSUPPORTED_TYPE "Não pode editar chaves deste tipo (%u)" + IDS_TOO_BIG_VALUE "Valor muito grande (%u)" IDS_DELETE_BOX_TITLE "Confirmar exclusão de valor" IDS_DELETE_BOX_TEXT "Tem certeza que deseja excluir o valor '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/Ru.rc b/programs/regedit/Ru.rc index 4be900eafef..46f080744f5 100644 --- a/programs/regedit/Ru.rc +++ b/programs/regedit/Ru.rc @@ -288,8 +288,8 @@ BEGIN IDS_ERROR "Îøèáêà" IDS_BAD_KEY "Íåâîçìîæíî çàïðîñèòü êëþ÷ '%s'" IDS_BAD_VALUE "Íåâîçìîæíî çàïðîñèòü çíà÷åíèå '%s'" - IDS_UNSUPPORTED_TYPE "Ðåäàêòèðîâàíèå êëþ÷åé òèïà (%ld) íå ïîääåðæèâàåòñÿ" - IDS_TOO_BIG_VALUE "Çíà÷åíèå ñëèøêîì âåëèêî (%ld)" + IDS_UNSUPPORTED_TYPE "Ðåäàêòèðîâàíèå êëþ÷åé òèïà (%u) íå ïîääåðæèâàåòñÿ" + 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?" diff --git a/programs/regedit/Si.rc b/programs/regedit/Si.rc index d98f9255094..c3cb1c433c6 100644 --- a/programs/regedit/Si.rc +++ b/programs/regedit/Si.rc @@ -290,8 +290,8 @@ BEGIN IDS_ERROR "Napaka" IDS_BAD_KEY "Ne morem pridobiti podatkov o ključu '%s'" IDS_BAD_VALUE "Ne morem pridobiti podatkov o vrednosti '%s'" - IDS_UNSUPPORTED_TYPE "Ključev te vrste (%ld) ni mogoče spreminjati" - IDS_TOO_BIG_VALUE "Vrednost (%ld) je prevelika" + IDS_UNSUPPORTED_TYPE "Ključev te vrste (%u) ni mogoče spreminjati" + IDS_TOO_BIG_VALUE "Vrednost (%u) je prevelika" IDS_DELETE_BOX_TITLE "Potrditev brisanja vrednosti" IDS_DELETE_BOX_TEXT "Ali ste prepričani, da želite izbrisati vrednost '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are ste prepričani, da želite izbrisati izbrane vrednosti?" diff --git a/programs/regedit/Tr.rc b/programs/regedit/Tr.rc index f74cfba733f..9d7be8e9801 100644 --- a/programs/regedit/Tr.rc +++ b/programs/regedit/Tr.rc @@ -263,8 +263,8 @@ BEGIN IDS_ERROR "Hata" IDS_BAD_KEY "'%s' anahtarý sorgulanamadý" IDS_BAD_VALUE "'%s' deðeri sorgulanamadý" - IDS_UNSUPPORTED_TYPE "Bu tür (%ld) anahtarlar deðiþtirilemez" - IDS_TOO_BIG_VALUE "Deðer çok büyük (%ld)" + IDS_UNSUPPORTED_TYPE "Bu tür (%u) anahtarlar deðiþtirilemez" + IDS_TOO_BIG_VALUE "Deðer çok büyük (%u)" IDS_DELETE_BOX_TITLE "Deðer silmeyi onayla" IDS_DELETE_BOX_TEXT "'%s' deðerini silmek istediðinizden emin misiniz?" IDS_DELETE_BOX_TEXT_MULTIPLE "Are you sure you want to delete these values?" diff --git a/programs/regedit/Zh.rc b/programs/regedit/Zh.rc index 3732d83c2bb..4bbdbc11596 100644 --- a/programs/regedit/Zh.rc +++ b/programs/regedit/Zh.rc @@ -284,8 +284,8 @@ BEGIN IDS_ERROR "错误" IDS_BAD_KEY "不能查询关键词'%s'" IDS_BAD_VALUE "不能查询值'%s'" - IDS_UNSUPPORTED_TYPE "不能编辑这类型的关键词 (%ld)" - IDS_TOO_BIG_VALUE "值太大 (%ld)" + IDS_UNSUPPORTED_TYPE "不能编辑这类型的关键词 (%u)" + IDS_TOO_BIG_VALUE "值太大 (%u)" IDS_DELETE_BOX_TITLE "值删除确认" IDS_DELETE_BOX_TEXT "你确认要删除这个值吗 '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "你确认要删除这些值吗?" @@ -600,8 +600,8 @@ BEGIN IDS_ERROR "錯誤" IDS_BAD_KEY "不能查詢關鍵詞'%s'" IDS_BAD_VALUE "不能查詢值'%s'" - IDS_UNSUPPORTED_TYPE "不能編輯這類型的關鍵詞 (%ld)" - IDS_TOO_BIG_VALUE "值太大 (%ld)" + IDS_UNSUPPORTED_TYPE "不能編輯這類型的關鍵詞 (%u)" + IDS_TOO_BIG_VALUE "值太大 (%u)" IDS_DELETE_BOX_TITLE "值刪除確認" IDS_DELETE_BOX_TEXT "你確認要刪除這個值嗎 '%s'?" IDS_DELETE_BOX_TEXT_MULTIPLE "你確認要刪除這些值嗎?" diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c index 5856b641b2f..2c5b23d295a 100644 --- a/programs/regedit/edit.c +++ b/programs/regedit/edit.c @@ -49,19 +49,19 @@ struct edit_params static INT vmessagebox(HWND hwnd, INT buttons, INT titleId, INT resId, va_list ap) { - TCHAR title[256]; - TCHAR errfmt[1024]; - TCHAR errstr[1024]; + static const WCHAR errorW[] = {'E','r','r','o','r',0}; + static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',' ','e','r','r','o','r',' ','s','t','r','i','n','g','!',0}; - if (!LoadString(hInst, titleId, title, COUNT_OF(title))) - lstrcpy(title, "Error"); + WCHAR title[256]; + WCHAR errfmt[1024]; + WCHAR errstr[1024]; - if (!LoadString(hInst, resId, errfmt, COUNT_OF(errfmt))) - lstrcpy(errfmt, "Unknown error string!"); + if (!LoadStringW(hInst, titleId, title, COUNT_OF(title))) lstrcpyW(title, errorW); + if (!LoadStringW(hInst, resId, errfmt, COUNT_OF(errfmt))) lstrcpyW(errfmt, unknownW); - _vsntprintf(errstr, COUNT_OF(errstr), errfmt, ap); + vsnprintfW(errstr, COUNT_OF(errstr), errfmt, ap); - return MessageBox(hwnd, errstr, title, buttons); + return MessageBoxW(hwnd, errstr, title, buttons); } static INT messagebox(HWND hwnd, INT buttons, INT titleId, INT resId, ...) @@ -401,7 +401,6 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath) BOOL result = FALSE; LONG lRet; HKEY hKey; - CHAR* keyPathA = GetMultiByteString(keyPath); lRet = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ|KEY_SET_VALUE, &hKey); if (lRet != ERROR_SUCCESS) { @@ -409,7 +408,7 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath) return FALSE; } - if (messagebox(hwnd, MB_YESNO | MB_ICONEXCLAMATION, IDS_DELETE_BOX_TITLE, IDS_DELETE_BOX_TEXT, keyPathA) != IDYES) + if (messagebox(hwnd, MB_YESNO | MB_ICONEXCLAMATION, IDS_DELETE_BOX_TITLE, IDS_DELETE_BOX_TEXT, keyPath) != IDYES) goto done; lRet = SHDeleteKeyW(hKeyRoot, keyPath); @@ -421,7 +420,6 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath) done: RegCloseKey(hKey); - HeapFree(GetProcessHeap(), 0, keyPathA); return result; } diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index 5b19899b504..79dcf242656 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -757,9 +757,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) SetFocus(g_pChildWnd->hTreeWnd); } } else { - CHAR* searchStringA = GetMultiByteString(searchString); - error(hWnd, IDS_NOTFOUND, searchStringA); - HeapFree(GetProcessHeap(), 0, searchStringA); + error(hWnd, IDS_NOTFOUND, searchString); } } break; diff --git a/programs/view/view.c b/programs/view/view.c index 0a5497dd9c7..e28901d4f39 100644 --- a/programs/view/view.c +++ b/programs/view/view.c @@ -23,9 +23,6 @@ #include "globals.h" #include -BOOL FileIsPlaceable( LPCSTR szFileName ); -HMETAFILE GetPlaceableMetaFile( HWND hwnd, LPCSTR szFileName ); - HMETAFILE hmf; int deltax = 0, deltay = 0; int width = 0, height = 0; @@ -46,6 +43,85 @@ static BOOL FileOpen(HWND hWnd, char *fn, int fnsz) return GetOpenFileName(&ofn); } +static BOOL FileIsPlaceable( LPCSTR szFileName ) +{ + HFILE hInFile; + APMFILEHEADER apmh; + + if( (hInFile = _lopen( szFileName, OF_READ ) ) == HFILE_ERROR ) + return FALSE; + + if( _lread( hInFile, &apmh, sizeof(APMFILEHEADER) ) + != sizeof(APMFILEHEADER) ) + { + _lclose( hInFile ); + return FALSE; + } + _lclose( hInFile ); + + /* Is it placeable? */ + return (apmh.key == APMHEADER_KEY); +} + +static HMETAFILE GetPlaceableMetaFile( HWND hwnd, LPCSTR szFileName ) +{ + LPBYTE lpData; + METAHEADER mfHeader; + APMFILEHEADER APMHeader; + HFILE fh; + HMETAFILE hmf; + WORD checksum, *p; + HDC hdc; + int i; + + if( (fh = _lopen( szFileName, OF_READ ) ) == HFILE_ERROR ) return 0; + _llseek(fh, 0, 0); + if (!_lread(fh, (LPSTR)&APMHeader, sizeof(APMFILEHEADER))) return 0; + _llseek(fh, sizeof(APMFILEHEADER), 0); + checksum = 0; + p = (WORD *) &APMHeader; + + for(i=0; i<10; i++) + checksum ^= *p++; + if (checksum != APMHeader.checksum) { + char msg[128]; + sprintf(msg, "Computed checksum %04x != stored checksum %04x\n", + checksum, APMHeader.checksum); + MessageBox(hwnd, msg, "Checksum failed", MB_OK); + return 0; + } + + if (!_lread(fh, (LPSTR)&mfHeader, sizeof(METAHEADER))) return 0; + + if (!(lpData = GlobalAlloc(GPTR, (mfHeader.mtSize * 2L)))) return 0; + + _llseek(fh, sizeof(APMFILEHEADER), 0); + if (!_lread(fh, lpData, (UINT)(mfHeader.mtSize * 2L))) + { + GlobalFree((HGLOBAL)lpData); + _lclose(fh); + return 0; + } + _lclose(fh); + + if (!(hmf = SetMetaFileBitsEx(mfHeader.mtSize*2, lpData))) + return 0; + + + width = APMHeader.bbox.Right - APMHeader.bbox.Left; + height = APMHeader.bbox.Bottom - APMHeader.bbox.Top; + + /* printf("Ok! width %d height %d inch %d\n", width, height, APMHeader.inch); */ + hdc = GetDC(hwnd); + width = width * GetDeviceCaps(hdc, LOGPIXELSX)/APMHeader.inch; + height = height * GetDeviceCaps(hdc,LOGPIXELSY)/APMHeader.inch; + ReleaseDC(hwnd, hdc); + + deltax = 0; + deltay = 0 ; + return hmf; +} + LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, @@ -137,82 +213,3 @@ LRESULT CALLBACK WndProc(HWND hwnd, } return 0; } - -BOOL FileIsPlaceable( LPCSTR szFileName ) -{ - HFILE hInFile; - APMFILEHEADER apmh; - - if( (hInFile = _lopen( szFileName, OF_READ ) ) == HFILE_ERROR ) - return FALSE; - - if( _lread( hInFile, &apmh, sizeof(APMFILEHEADER) ) - != sizeof(APMFILEHEADER) ) - { - _lclose( hInFile ); - return FALSE; - } - _lclose( hInFile ); - - /* Is it placeable? */ - return (apmh.key == APMHEADER_KEY); -} - -HMETAFILE GetPlaceableMetaFile( HWND hwnd, LPCSTR szFileName ) -{ - LPBYTE lpData; - METAHEADER mfHeader; - APMFILEHEADER APMHeader; - HFILE fh; - HMETAFILE hmf; - WORD checksum, *p; - HDC hdc; - int i; - - if( (fh = _lopen( szFileName, OF_READ ) ) == HFILE_ERROR ) return 0; - _llseek(fh, 0, 0); - if (!_lread(fh, (LPSTR)&APMHeader, sizeof(APMFILEHEADER))) return 0; - _llseek(fh, sizeof(APMFILEHEADER), 0); - checksum = 0; - p = (WORD *) &APMHeader; - - for(i=0; i<10; i++) - checksum ^= *p++; - if (checksum != APMHeader.checksum) { - char msg[128]; - sprintf(msg, "Computed checksum %04x != stored checksum %04x\n", - checksum, APMHeader.checksum); - MessageBox(hwnd, msg, "Checksum failed", MB_OK); - return 0; - } - - if (!_lread(fh, (LPSTR)&mfHeader, sizeof(METAHEADER))) return 0; - - if (!(lpData = GlobalAlloc(GPTR, (mfHeader.mtSize * 2L)))) return 0; - - _llseek(fh, sizeof(APMFILEHEADER), 0); - if (!_lread(fh, lpData, (UINT)(mfHeader.mtSize * 2L))) - { - GlobalFree((HGLOBAL)lpData); - _lclose(fh); - return 0; - } - _lclose(fh); - - if (!(hmf = SetMetaFileBitsEx(mfHeader.mtSize*2, lpData))) - return 0; - - - width = APMHeader.bbox.Right - APMHeader.bbox.Left; - height = APMHeader.bbox.Bottom - APMHeader.bbox.Top; - - /* printf("Ok! width %d height %d inch %d\n", width, height, APMHeader.inch); */ - hdc = GetDC(hwnd); - width = width * GetDeviceCaps(hdc, LOGPIXELSX)/APMHeader.inch; - height = height * GetDeviceCaps(hdc,LOGPIXELSY)/APMHeader.inch; - ReleaseDC(hwnd, hdc); - - deltax = 0; - deltay = 0 ; - return hmf; -} diff --git a/programs/winefile/winefile.c b/programs/winefile/winefile.c index a49c2ab1929..b3e5471fcd4 100644 --- a/programs/winefile/winefile.c +++ b/programs/winefile/winefile.c @@ -33,6 +33,7 @@ #include "winefile.h" #include "resource.h" +#include "wine/unicode.h" #ifdef _NO_EXTENSIONS #undef _LEFT_FILES @@ -196,8 +197,17 @@ static const TCHAR sQMarks[] = {'?','?','?','\0'}; static const TCHAR sWINEFILEFRAME[] = {'W','F','S','_','F','r','a','m','e','\0'}; static const TCHAR sWINEFILETREE[] = {'W','F','S','_','T','r','e','e','\0'}; -static const TCHAR sLongHexFmt[] = {'%','I','6','4','X','\0'}; -static const TCHAR sLongNumFmt[] = {'%','I','6','4','u','\0'}; +static void format_longlong(LPWSTR ret, ULONGLONG val) +{ + WCHAR buffer[65], *p = &buffer[64]; + + *p = 0; + do { + *(--p) = '0' + val % 10; + val /= 10; + } while (val); + lstrcpyW( ret, p ); +} /* load resource string */ @@ -299,52 +309,6 @@ static inline void choose_font(HWND hwnd) ReleaseDC(hwnd, hdc); } -#ifdef __WINE__ - -#ifdef UNICODE - -/* call vswprintf() in msvcrt.dll */ -/*TODO: fix swprintf() in non-msvcrt mode, so that this dynamic linking function can be removed */ -static int msvcrt_swprintf(WCHAR* buffer, const WCHAR* fmt, ...) -{ - static int (__cdecl *pvswprintf)(WCHAR*, const WCHAR*, va_list) = NULL; - va_list ap; - int ret; - - if (!pvswprintf) { - HMODULE hModMsvcrt = LoadLibraryA("msvcrt"); - pvswprintf = (int(__cdecl*)(WCHAR*,const WCHAR*,va_list)) GetProcAddress(hModMsvcrt, "vswprintf"); - } - - va_start(ap, fmt); - ret = (*pvswprintf)(buffer, fmt, ap); - va_end(ap); - - return ret; -} - -static LPCWSTR my_wcsrchr(LPCWSTR str, WCHAR c) -{ - LPCWSTR p = str; - - while(*p) - ++p; - - do { - if (--p < str) - return NULL; - } while(*p != c); - - return p; -} - -#define _tcsrchr my_wcsrchr -#else /* UNICODE */ -#define _tcsrchr strrchr -#endif /* UNICODE */ - -#endif /* __WINE__ */ - /* allocate and initialise a directory entry */ static Entry* alloc_entry(void) @@ -1219,8 +1183,8 @@ static int compareExt(const void* arg1, const void* arg2) name1 = fd1->cFileName; name2 = fd2->cFileName; - ext1 = _tcsrchr(name1, '.'); - ext2 = _tcsrchr(name2, '.'); + ext1 = strrchrW(name1, '.'); + ext2 = strrchrW(name2, '.'); if (ext1) ext1++; @@ -2032,7 +1996,6 @@ static INT_PTR CALLBACK PropertiesDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wpa static const TCHAR sByteFmt[] = {'%','s',' ','B','y','t','e','s','\0'}; TCHAR b1[BUFFER_LEN], b2[BUFFER_LEN]; LPWIN32_FIND_DATA pWFD; - ULONGLONG size; dlg = (struct PropertiesDialog*) lparam; pWFD = (LPWIN32_FIND_DATA) &dlg->entry.data; @@ -2044,8 +2007,7 @@ static INT_PTR CALLBACK PropertiesDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wpa format_date(&pWFD->ftLastWriteTime, b1, COL_DATE|COL_TIME); SetWindowText(GetDlgItem(hwnd, IDC_STATIC_PROP_LASTCHANGE), b1); - size = ((ULONGLONG)pWFD->nFileSizeHigh << 32) | pWFD->nFileSizeLow; - _stprintf(b1, sLongNumFmt, size); + format_longlong( b1, ((ULONGLONG)pWFD->nFileSizeHigh << 32) | pWFD->nFileSizeLow ); wsprintf(b2, sByteFmt, b1); SetWindowText(GetDlgItem(hwnd, IDC_STATIC_PROP_SIZE), b2); @@ -2907,17 +2869,18 @@ static void format_bytes(LPTSTR buffer, LONGLONG bytes) static const TCHAR sFmtGB[] = {'%', '.', '1', 'f', ' ', 'G', 'B', '\0'}; static const TCHAR sFmtMB[] = {'%', '.', '1', 'f', ' ', 'M', 'B', '\0'}; static const TCHAR sFmtkB[] = {'%', '.', '1', 'f', ' ', 'k', 'B', '\0'}; + static const TCHAR sFmtB[] = {'%', 'u', 0}; float fBytes = (float)bytes; if (bytes >= 1073741824) /* 1 GB */ - _stprintf(buffer, sFmtGB, fBytes/1073741824.f+.5f); + sprintfW(buffer, sFmtGB, fBytes/1073741824.f+.5f); else if (bytes >= 1048576) /* 1 MB */ - _stprintf(buffer, sFmtMB, fBytes/1048576.f+.5f); + sprintfW(buffer, sFmtMB, fBytes/1048576.f+.5f); else if (bytes >= 1024) /* 1 kB */ - _stprintf(buffer, sFmtkB, fBytes/1024.f+.5f); + sprintfW(buffer, sFmtkB, fBytes/1024.f+.5f); else - _stprintf(buffer, sLongNumFmt, bytes); + sprintfW(buffer, sFmtB, (DWORD)bytes); } static void set_space_status(void) @@ -3141,7 +3104,7 @@ static BOOL is_registered_type(LPCTSTR ext) static enum FILE_TYPE get_file_type(LPCTSTR filename) { - LPCTSTR ext = _tcsrchr(filename, '.'); + LPCTSTR ext = strrchrW(filename, '.'); if (!ext) ext = sEmpty; @@ -3354,11 +3317,7 @@ static void draw_item(Pane* pane, LPDRAWITEMSTRUCT dis, Entry* entry, int calcWi if (!(attrs&FILE_ATTRIBUTE_DIRECTORY)) #endif { - ULONGLONG size; - - size = ((ULONGLONG)entry->data.nFileSizeHigh << 32) | entry->data.nFileSizeLow; - - _stprintf(buffer, sLongNumFmt, size); + format_longlong( buffer, ((ULONGLONG)entry->data.nFileSizeHigh << 32) | entry->data.nFileSizeLow ); if (calcWidthCol == -1) output_number(pane, dis, col, buffer); @@ -3397,10 +3356,15 @@ static void draw_item(Pane* pane, LPDRAWITEMSTRUCT dis, Entry* entry, int calcWi #ifndef _NO_EXTENSIONS if (entry->bhfi_valid) { - ULONGLONG index = ((ULONGLONG)entry->bhfi.nFileIndexHigh << 32) | entry->bhfi.nFileIndexLow; - if (visible_cols & COL_INDEX) { - _stprintf(buffer, sLongHexFmt, index); + static const TCHAR fmtlow[] = {'%','X',0}; + static const TCHAR fmthigh[] = {'%','X','%','0','8','X',0}; + + if (entry->bhfi.nFileIndexHigh) + wsprintf(buffer, fmthigh, + entry->bhfi.nFileIndexHigh, entry->bhfi.nFileIndexLow ); + else + wsprintf(buffer, fmtlow, entry->bhfi.nFileIndexLow ); if (calcWidthCol == -1) output_text(pane, dis, col, buffer, DT_RIGHT); diff --git a/programs/winefile/winefile.h b/programs/winefile/winefile.h index cba4843144a..7c1f66c6ca2 100644 --- a/programs/winefile/winefile.h +++ b/programs/winefile/winefile.h @@ -150,11 +150,9 @@ extern WINEFILE_GLOBALS Globals; #ifdef UNICODE extern void _wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext); #define _tsplitpath _wsplitpath -#define _stprintf msvcrt_swprintf #else extern void _splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext); #define _tsplitpath _splitpath -#define _stprintf sprintf #endif #else diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 56eac5ada71..f5f7ec00b6a 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -804,7 +804,7 @@ static BOOL write_desktop_entry(const char *location, const char *linkname, cons fprintf(file, "Exec=env WINEPREFIX=\"%s\" wine \"%s\" %s\n", wine_get_config_dir(), path, args); fprintf(file, "Type=Application\n"); - fprintf(file, "StartupWMClass=Wine\n"); + fprintf(file, "StartupNotify=true\n"); if (descr && lstrlenA(descr)) fprintf(file, "Comment=%s\n", descr); if (workdir && lstrlenA(workdir)) diff --git a/programs/winemine/main.c b/programs/winemine/main.c index 3d0998f87c9..c75712979ca 100644 --- a/programs/winemine/main.c +++ b/programs/winemine/main.c @@ -57,7 +57,7 @@ void CheckLevel( BOARD *p_board ) p_board->mines = p_board->cols * p_board->rows - 2; } -void LoadBoard( BOARD *p_board ) +static void LoadBoard( BOARD *p_board ) { DWORD size; DWORD type; @@ -126,7 +126,7 @@ void LoadBoard( BOARD *p_board ) RegCloseKey( hkey ); } -void InitBoard( BOARD *p_board ) +static void InitBoard( BOARD *p_board ) { HMENU hMenu; @@ -146,7 +146,7 @@ void InitBoard( BOARD *p_board ) CheckLevel( p_board ); } -void SaveBoard( BOARD *p_board ) +static void SaveBoard( BOARD *p_board ) { HKEY hkey; unsigned i; @@ -180,14 +180,14 @@ void SaveBoard( BOARD *p_board ) RegCloseKey( hkey ); } -void DestroyBoard( BOARD *p_board ) +static void DestroyBoard( BOARD *p_board ) { DeleteObject( p_board->hFacesBMP ); DeleteObject( p_board->hLedsBMP ); DeleteObject( p_board->hMinesBMP ); } -void SetDifficulty( BOARD *p_board, DIFFICULTY difficulty ) +static void SetDifficulty( BOARD *p_board, DIFFICULTY difficulty ) { HMENU hMenu; @@ -254,7 +254,7 @@ static void MoveOnScreen(RECT* rect) ShiftBetween(&rect->top, &rect->bottom, mi.rcWork.top, mi.rcWork.bottom); } -void CreateBoard( BOARD *p_board ) +static void CreateBoard( BOARD *p_board ) { int left, top, bottom, right; unsigned col, row; @@ -331,7 +331,7 @@ void CreateBoard( BOARD *p_board ) /* Randomly places mines everywhere except the selected box. */ -void PlaceMines ( BOARD *p_board, int selected_col, int selected_row ) +static void PlaceMines ( BOARD *p_board, int selected_col, int selected_row ) { int i, j; unsigned col, row; @@ -372,7 +372,7 @@ void PlaceMines ( BOARD *p_board, int selected_col, int selected_row ) } } -void DrawMine( HDC hdc, HDC hMemDC, BOARD *p_board, unsigned col, unsigned row, BOOL IsPressed ) +static void DrawMine( HDC hdc, HDC hMemDC, BOARD *p_board, unsigned col, unsigned row, BOOL IsPressed ) { MINEBMP_OFFSET offset = BOX_BMP; @@ -449,7 +449,7 @@ void DrawMine( HDC hdc, HDC hMemDC, BOARD *p_board, unsigned col, unsigned row, hMemDC, 0, offset * MINE_HEIGHT, SRCCOPY ); } -void DrawMines ( HDC hdc, HDC hMemDC, BOARD *p_board ) +static void DrawMines ( HDC hdc, HDC hMemDC, BOARD *p_board ) { HGDIOBJ hOldObj; unsigned col, row; @@ -463,7 +463,7 @@ void DrawMines ( HDC hdc, HDC hMemDC, BOARD *p_board ) SelectObject( hMemDC, hOldObj ); } -void DrawLeds( HDC hdc, HDC hMemDC, BOARD *p_board, int number, int x, int y ) +static void DrawLeds( HDC hdc, HDC hMemDC, BOARD *p_board, int number, int x, int y ) { HGDIOBJ hOldObj; unsigned led[3], i; @@ -506,7 +506,7 @@ void DrawLeds( HDC hdc, HDC hMemDC, BOARD *p_board, int number, int x, int y ) } -void DrawFace( HDC hdc, HDC hMemDC, BOARD *p_board ) +static void DrawFace( HDC hdc, HDC hMemDC, BOARD *p_board ) { HGDIOBJ hOldObj; @@ -523,7 +523,7 @@ void DrawFace( HDC hdc, HDC hMemDC, BOARD *p_board ) } -void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board ) +static void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board ) { RECT tmp_rect; @@ -545,7 +545,7 @@ void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board ) } -void AddFlag( BOARD *p_board, unsigned col, unsigned row ) +static void AddFlag( BOARD *p_board, unsigned col, unsigned row ) { if( p_board->box[col][row].FlagType != COMPLETE ) { switch( p_board->box[col][row].FlagType ) { @@ -569,7 +569,7 @@ void AddFlag( BOARD *p_board, unsigned col, unsigned row ) } -void UnpressBox( BOARD *p_board, unsigned col, unsigned row ) +static void UnpressBox( BOARD *p_board, unsigned col, unsigned row ) { HDC hdc; HGDIOBJ hOldObj; @@ -587,7 +587,7 @@ void UnpressBox( BOARD *p_board, unsigned col, unsigned row ) } -void UnpressBoxes( BOARD *p_board, unsigned col, unsigned row ) +static void UnpressBoxes( BOARD *p_board, unsigned col, unsigned row ) { int i, j; @@ -598,7 +598,7 @@ void UnpressBoxes( BOARD *p_board, unsigned col, unsigned row ) } -void PressBox( BOARD *p_board, unsigned col, unsigned row ) +static void PressBox( BOARD *p_board, unsigned col, unsigned row ) { HDC hdc; HGDIOBJ hOldObj; @@ -616,7 +616,7 @@ void PressBox( BOARD *p_board, unsigned col, unsigned row ) } -void PressBoxes( BOARD *p_board, unsigned col, unsigned row ) +static void PressBoxes( BOARD *p_board, unsigned col, unsigned row ) { int i, j; @@ -643,7 +643,7 @@ void PressBoxes( BOARD *p_board, unsigned col, unsigned row ) } -void CompleteBox( BOARD *p_board, unsigned col, unsigned row ) +static void CompleteBox( BOARD *p_board, unsigned col, unsigned row ) { int i, j; @@ -670,7 +670,7 @@ void CompleteBox( BOARD *p_board, unsigned col, unsigned row ) } -void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row ) +static void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row ) { unsigned numFlags = 0; int i, j; @@ -693,7 +693,7 @@ void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row ) } -void TestMines( BOARD *p_board, POINT pt, int msg ) +static void TestMines( BOARD *p_board, POINT pt, int msg ) { BOOL draw = TRUE; int col, row; @@ -758,7 +758,7 @@ void TestMines( BOARD *p_board, POINT pt, int msg ) } -void TestFace( BOARD *p_board, POINT pt, int msg ) +static void TestFace( BOARD *p_board, POINT pt, int msg ) { if( p_board->status == PLAYING || p_board->status == WAITING ) { if( msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN ) @@ -783,7 +783,7 @@ void TestFace( BOARD *p_board, POINT pt, int msg ) } -void TestBoard( HWND hWnd, BOARD *p_board, int x, int y, int msg ) +static void TestBoard( HWND hWnd, BOARD *p_board, int x, int y, int msg ) { POINT pt; unsigned col,row; @@ -834,7 +834,7 @@ void TestBoard( HWND hWnd, BOARD *p_board, int x, int y, int msg ) } -LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +static LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; diff --git a/tools/widl/client.c b/tools/widl/client.c index 673b9188357..a23e298491c 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -50,14 +50,14 @@ static void print_client( const char *format, ... ) } -static void check_pointers(const func_t *func) +static void check_pointers(const var_t *func) { const var_t *var; - if (!func->args) + if (!type_get_function_args(func->type)) return; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) { if (is_var_ptr(var) && cant_be_null(var)) { @@ -73,7 +73,7 @@ static void check_pointers(const func_t *func) static void write_function_stubs(type_t *iface, unsigned int *proc_offset) { - const func_t *func; + const statement_t *stmt; const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); const var_t *var; int method_count = 0; @@ -81,14 +81,15 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) if (!implicit_handle) print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n\n", iface->name); - if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) { - const var_t *def = func->def; + const var_t *func = stmt->u.var; const var_t* explicit_handle_var; const var_t* explicit_generic_handle_var = NULL; const var_t* context_handle_var = NULL; int has_full_pointer = is_full_pointer_function(func); - const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV); + const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); + const var_list_t *args = type_get_function_args(func->type); /* check for a defined binding handle */ explicit_handle_var = get_explicit_handle_var(func); @@ -99,7 +100,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) context_handle_var = get_context_handle_var(func); } - print_client( "struct __frame_%s%s\n{\n", prefix_client, get_name(def) ); + print_client( "struct __frame_%s%s\n{\n", prefix_client, get_name(func) ); indent++; print_client( "__DECL_EXCEPTION_FRAME\n" ); print_client("MIDL_STUB_MESSAGE _StubMsg;\n"); @@ -112,15 +113,16 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("RPC_BINDING_HANDLE _Handle;\n"); } - if (!is_void(get_func_return_type(func)) && decl_indirect(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type)) && + decl_indirect(type_function_get_rettype(func->type))) { print_client("void *_p_%s;\n", "_RetVal" ); } indent--; print_client( "};\n\n" ); - print_client( "static void __finally_%s%s(", prefix_client, get_name(def) ); - print_client( " struct __frame_%s%s *__frame )\n{\n", prefix_client, get_name(def) ); + print_client( "static void __finally_%s%s(", prefix_client, get_name(func) ); + print_client( " struct __frame_%s%s *__frame )\n{\n", prefix_client, get_name(func) ); indent++; /* FIXME: emit client finally code */ @@ -143,14 +145,14 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) indent--; print_client( "}\n\n" ); - write_type_decl_left(client, get_func_return_type(func)); - if (needs_space_after(get_func_return_type(func))) + write_type_decl_left(client, type_function_get_rettype(func->type)); + if (needs_space_after(type_function_get_rettype(func->type))) fprintf(client, " "); if (callconv) fprintf(client, "%s ", callconv); - fprintf(client, "%s%s(\n", prefix_client, get_name(def)); + fprintf(client, "%s%s(\n", prefix_client, get_name(func)); indent++; - if (func->args) - write_args(client, func->args, iface->name, 0, TRUE); + if (args) + write_args(client, args, iface->name, 0, TRUE); else print_client("void"); fprintf(client, ")\n"); @@ -159,13 +161,13 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) /* write the functions body */ fprintf(client, "{\n"); indent++; - print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(def) ); + print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(func) ); /* declare return value '_RetVal' */ - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) { print_client(""); - write_type_decl_left(client, get_func_return_type(func)); + write_type_decl_left(client, type_function_get_rettype(func->type)); fprintf(client, " _RetVal;\n"); } print_client("RPC_MESSAGE _RpcMessage;\n"); @@ -177,14 +179,15 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("__frame->%s = %s;\n", explicit_generic_handle_var->name, explicit_generic_handle_var->name ); } - if (!is_void(get_func_return_type(func)) && decl_indirect(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type)) && + decl_indirect(type_function_get_rettype(func->type))) { print_client("__frame->_p_%s = &%s;\n", "_RetVal", "_RetVal"); } fprintf(client, "\n"); - print_client( "RpcExceptionInit( 0, __finally_%s%s );\n", prefix_client, get_name(def) ); + print_client( "RpcExceptionInit( 0, __finally_%s%s );\n", prefix_client, get_name(func) ); if (has_full_pointer) write_full_pointer_init(client, indent, func, FALSE); @@ -199,12 +202,12 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, &%s_StubDesc, %d);\n", iface->name, method_count); - if (is_attr(def->attrs, ATTR_IDEMPOTENT) || is_attr(def->attrs, ATTR_BROADCAST)) + if (is_attr(func->attrs, ATTR_IDEMPOTENT) || is_attr(func->attrs, ATTR_BROADCAST)) { print_client("_RpcMessage.RpcFlags = ( RPC_NCA_FLAGS_DEFAULT "); - if (is_attr(def->attrs, ATTR_IDEMPOTENT)) + if (is_attr(func->attrs, ATTR_IDEMPOTENT)) fprintf(client, "| RPC_NCA_FLAGS_IDEMPOTENT "); - if (is_attr(def->attrs, ATTR_BROADCAST)) + if (is_attr(func->attrs, ATTR_BROADCAST)) fprintf(client, "| RPC_NCA_FLAGS_BROADCAST "); fprintf(client, ");\n\n"); } @@ -284,23 +287,24 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) write_remoting_arguments(client, indent, func, "", PASS_OUT, PHASE_UNMARSHAL); /* unmarshal return value */ - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) { - if (decl_indirect(get_func_return_type(func))) + if (decl_indirect(type_function_get_rettype(func->type))) print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal"); - else if (is_ptr(get_func_return_type(func)) || is_array(get_func_return_type(func))) + else if (is_ptr(type_function_get_rettype(func->type)) || + is_array(type_function_get_rettype(func->type))) print_client("%s = 0;\n", "_RetVal"); write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL); } /* update proc_offset */ - if (func->args) + if (args) { - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, args, const var_t, entry ) *proc_offset += get_size_procformatstring_type(var->name, var->type, var->attrs); } - if (!is_void(get_func_return_type(func))) - *proc_offset += get_size_procformatstring_type("return value", get_func_return_type(func), NULL); + if (!is_void(type_function_get_rettype(func->type))) + *proc_offset += get_size_procformatstring_type("return value", type_function_get_rettype(func->type), NULL); else *proc_offset += 2; /* FC_END and FC_PAD */ @@ -309,14 +313,14 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_client("RpcFinally\n"); print_client("{\n"); indent++; - print_client( "__finally_%s%s( __frame );\n", prefix_client, get_name(def) ); + print_client( "__finally_%s%s( __frame );\n", prefix_client, get_name(func) ); indent--; print_client("}\n"); print_client("RpcEndFinally\n"); /* emit return code */ - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) { fprintf(client, "\n"); print_client("return _RetVal;\n"); @@ -466,6 +470,8 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou { if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) { + int has_func = 0; + const statement_t *stmt2; type_t *iface = stmt->u.type; if (!need_stub(iface)) return; @@ -475,7 +481,13 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou fprintf(client, " */\n"); fprintf(client, "\n"); - if (iface->funcs) + STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface)) + { + has_func = 1; + break; + } + + if (has_func) { write_implicithandledecl(iface); diff --git a/tools/widl/expr.c b/tools/widl/expr.c index efe1769e7b1..7f0e26d588c 100644 --- a/tools/widl/expr.c +++ b/tools/widl/expr.c @@ -469,7 +469,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc case EXPR_PPTR: result = resolve_expression(expr_loc, cont_type, e->ref); if (result.type && is_ptr(result.type)) - result.type = result.type->ref; + result.type = type_pointer_get_ref(result.type); else error_loc_info(&expr_loc->v->loc_info, "dereference operator applied to non-pointer type in expression%s%s\n", expr_loc->attr ? " for attribute " : "", @@ -549,7 +549,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc if (result.type && is_array(result.type)) { struct expression_type index_result; - result.type = result.type->ref; + result.type = type_array_get_element(result.type); index_result = resolve_expression(expr_loc, cont_type /* FIXME */, e->u.ext); if (!index_result.type || !is_integer_type(index_result.type)) error_loc_info(&expr_loc->v->loc_info, "array subscript not of integral type in expression%s%s\n", diff --git a/tools/widl/header.c b/tools/widl/header.c index b7df77bb171..a3d225078b7 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -62,10 +62,10 @@ int is_ptrchain_attr(const var_t *var, enum attr_type t) { if (is_attr(type->attrs, t)) return 1; - else if (type->kind == TKIND_ALIAS) + else if (type_is_alias(type)) type = type->orig; else if (is_ptr(type)) - type = type->ref; + type = type_pointer_get_ref(type); else return 0; } } @@ -78,7 +78,7 @@ int is_aliaschain_attr(const type_t *type, enum attr_type attr) { if (is_attr(t->attrs, attr)) return 1; - else if (t->kind == TKIND_ALIAS) + else if (type_is_alias(t)) t = t->orig; else return 0; } @@ -116,9 +116,7 @@ int is_void(const type_t *t) int is_conformant_array(const type_t *t) { - return t->type == RPC_FC_CARRAY - || t->type == RPC_FC_CVARRAY - || (t->type == RPC_FC_BOGUS_ARRAY && t->size_is); + return is_array(t) && type_array_has_conformance(t); } void write_guid(FILE *f, const char *guid_prefix, const char *name, const UUID *uuid) @@ -185,8 +183,8 @@ static void write_enums(FILE *h, var_list_t *enums) int needs_space_after(type_t *t) { - return (t->kind == TKIND_ALIAS - || (!is_ptr(t) && (!is_conformant_array(t) || t->declarray))); + return (type_is_alias(t) || + (!is_ptr(t) && (!is_conformant_array(t) || t->declarray || (is_array(t) && t->name)))); } void write_type_left(FILE *h, type_t *t, int declonly) @@ -194,15 +192,19 @@ void write_type_left(FILE *h, type_t *t, int declonly) if (!h) return; if (is_attr(t->attrs, ATTR_CONST) && - (t->kind == TKIND_ALIAS || t->declarray || !is_ptr(t))) + (type_is_alias(t) || t->declarray || !is_ptr(t))) fprintf(h, "const "); - if (t->kind == TKIND_ALIAS) fprintf(h, "%s", t->name); - else if (t->declarray) write_type_left(h, t->ref, declonly); + if (type_is_alias(t)) fprintf(h, "%s", t->name); + else if (t->declarray) write_type_left(h, type_array_get_element(t), declonly); else { if (t->sign > 0) fprintf(h, "signed "); else if (t->sign < 0) fprintf(h, "unsigned "); - switch (t->type) { + + if (is_array(t) && !t->name) { + write_type_left(h, type_array_get_element(t), declonly); + fprintf(h, "%s*", needs_space_after(type_array_get_element(t)) ? " " : ""); + } else switch (t->type) { case RPC_FC_ENUM16: case RPC_FC_ENUM32: if (!declonly && t->defined && !t->written) { @@ -253,12 +255,9 @@ void write_type_left(FILE *h, type_t *t, int declonly) case RPC_FC_UP: case RPC_FC_FP: case RPC_FC_OP: - case RPC_FC_CARRAY: - case RPC_FC_CVARRAY: - case RPC_FC_BOGUS_ARRAY: - write_type_left(h, t->ref, declonly); - fprintf(h, "%s*", needs_space_after(t->ref) ? " " : ""); - if (is_ptr(t) && is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const "); + write_type_left(h, type_pointer_get_ref(t), declonly); + fprintf(h, "%s*", needs_space_after(type_pointer_get_ref(t)) ? " " : ""); + if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const "); break; default: fprintf(h, "%s", t->name); @@ -273,10 +272,10 @@ void write_type_right(FILE *h, type_t *t, int is_field) if (t->declarray) { if (is_conformant_array(t)) { fprintf(h, "[%s]", is_field ? "1" : ""); - t = t->ref; + t = type_array_get_element(t); } - for ( ; t->declarray; t = t->ref) - fprintf(h, "[%lu]", t->dim); + for ( ; t->declarray; t = type_array_get_element(t)) + fprintf(h, "[%lu]", type_array_get_dim(t)); } } @@ -288,7 +287,7 @@ void write_type_v(FILE *h, type_t *t, int is_field, int declonly, if (!h) return; - for (pt = t; is_ptr(pt); pt = pt->ref, ptr_level++) + for (pt = t; is_ptr(pt); pt = type_pointer_get_ref(pt), ptr_level++) ; if (pt->type == RPC_FC_FUNCTION) { @@ -296,7 +295,7 @@ void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV); if (!callconv) callconv = ""; if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline "); - write_type_left(h, pt->ref, declonly); + write_type_left(h, type_function_get_rettype(pt), declonly); fputc(' ', h); if (ptr_level) fputc('(', h); fprintf(h, "%s ", callconv); @@ -375,10 +374,11 @@ void check_for_additional_prototype_types(const var_list_t *list) if (!list) return; LIST_FOR_EACH_ENTRY( v, list, const var_t, entry ) { - type_t *type; - for (type = v->type; type; type = type->kind == TKIND_ALIAS ? type->orig : type->ref) { + type_t *type = v->type; + if (!type) continue; + for (;;) { const char *name = type->name; - if (type->user_types_registered) continue; + if (type->user_types_registered) break; type->user_types_registered = 1; if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) { if (!context_handle_registered(name)) @@ -422,6 +422,15 @@ void check_for_additional_prototype_types(const var_list_t *list) vars = type_union_get_cases(type); check_for_additional_prototype_types(vars); } + + if (type_is_alias(type)) + type = type->orig; + else if (is_ptr(type)) + type = type_pointer_get_ref(type); + else if (is_array(type)) + type = type_array_get_element(type); + else + break; } } } @@ -479,7 +488,7 @@ int is_const_decl(const var_t *var) if (is_attr(t->attrs, ATTR_CONST)) return TRUE; else if (is_ptr(t)) - t = t->ref; + t = type_pointer_get_ref(t); else break; } return FALSE; @@ -521,14 +530,14 @@ static void write_library(FILE *header, const typelib_t *typelib) } -const var_t* get_explicit_handle_var(const func_t* func) +const var_t* get_explicit_handle_var(const var_t *func) { const var_t* var; - if (!func->args) + if (!type_get_function_args(func->type)) return NULL; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) if (var->type->type == RPC_FC_BIND_PRIMITIVE) return var; @@ -538,51 +547,51 @@ const var_t* get_explicit_handle_var(const func_t* func) const type_t* get_explicit_generic_handle_type(const var_t* var) { const type_t *t; - for (t = var->type; is_ptr(t); t = t->ref) + for (t = var->type; is_ptr(t); t = type_pointer_get_ref(t)) if (t->type != RPC_FC_BIND_PRIMITIVE && is_attr(t->attrs, ATTR_HANDLE)) return t; return NULL; } -const var_t* get_explicit_generic_handle_var(const func_t* func) +const var_t* get_explicit_generic_handle_var(const var_t *func) { const var_t* var; - if (!func->args) + if (!type_get_function_args(func->type)) return NULL; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) if (get_explicit_generic_handle_type(var)) return var; return NULL; } -const var_t* get_context_handle_var(const func_t* func) +const var_t* get_context_handle_var(const var_t *func) { const var_t* var; - if (!func->args) + if (!type_get_function_args(func->type)) return NULL; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) if (is_attr(var->attrs, ATTR_IN) && is_context_handle(var->type)) return var; return NULL; } -int has_out_arg_or_return(const func_t *func) +int has_out_arg_or_return(const var_t *func) { const var_t *var; - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) return 1; - if (!func->args) + if (!type_get_function_args(func->type)) return 0; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) if (is_attr(var->attrs, ATTR_OUT)) return 1; @@ -612,28 +621,34 @@ const var_t *is_callas(const attr_list_t *a) static void write_method_macro(FILE *header, const type_t *iface, const char *name) { - const func_t *cur; - - if (iface->ref) write_method_macro(header, iface->ref, name); + const statement_t *stmt; + int first_iface = 1; - if (!iface->funcs) return; + if (type_iface_get_inherit(iface)) + write_method_macro(header, type_iface_get_inherit(iface), name); - fprintf(header, "/*** %s methods ***/\n", iface->name); - LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { - var_t *def = cur->def; - if (!is_callas(def->attrs)) { + const var_t *func = stmt->u.var; + + if (first_iface) + { + fprintf(header, "/*** %s methods ***/\n", iface->name); + first_iface = 0; + } + + if (!is_callas(func->attrs)) { const var_t *arg; - fprintf(header, "#define %s_%s(This", name, get_name(def)); - if (cur->args) - LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry ) + fprintf(header, "#define %s_%s(This", name, get_name(func)); + if (type_get_function_args(func->type)) + LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry ) fprintf(header, ",%s", arg->name); fprintf(header, ") "); - fprintf(header, "(This)->lpVtbl->%s(This", get_name(def)); - if (cur->args) - LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry ) + fprintf(header, "(This)->lpVtbl->%s(This", get_name(func)); + if (type_get_function_args(func->type)) + LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry ) fprintf(header, ",%s", arg->name); fprintf(header, ")\n"); } @@ -671,21 +686,19 @@ void write_args(FILE *h, const var_list_t *args, const char *name, int method, i static void write_cpp_method_def(FILE *header, const type_t *iface) { - const func_t *cur; - - if (!iface->funcs) return; + const statement_t *stmt; - LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { - var_t *def = cur->def; - if (!is_callas(def->attrs)) { - const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV); + const var_t *func = stmt->u.var; + if (!is_callas(func->attrs)) { + const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); if (!callconv) callconv = ""; indent(header, 0); fprintf(header, "virtual "); - write_type_decl_left(header, get_func_return_type(cur)); - fprintf(header, " %s %s(\n", callconv, get_name(def)); - write_args(header, cur->args, iface->name, 2, TRUE); + write_type_decl_left(header, type_function_get_rettype(func->type)); + fprintf(header, " %s %s(\n", callconv, get_name(func)); + write_args(header, type_get_function_args(func->type), iface->name, 2, TRUE); fprintf(header, ") = 0;\n"); fprintf(header, "\n"); } @@ -694,23 +707,27 @@ static void write_cpp_method_def(FILE *header, const type_t *iface) static void do_write_c_method_def(FILE *header, const type_t *iface, const char *name) { - const func_t *cur; + const statement_t *stmt; + int first_iface = 1; - if (iface->ref) do_write_c_method_def(header, iface->ref, name); + if (type_iface_get_inherit(iface)) + do_write_c_method_def(header, type_iface_get_inherit(iface), name); - if (!iface->funcs) return; - indent(header, 0); - fprintf(header, "/*** %s methods ***/\n", iface->name); - LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { - const var_t *def = cur->def; - if (!is_callas(def->attrs)) { - const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV); + const var_t *func = stmt->u.var; + if (first_iface) { + indent(header, 0); + fprintf(header, "/*** %s methods ***/\n", iface->name); + first_iface = 0; + } + if (!is_callas(func->attrs)) { + const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); if (!callconv) callconv = ""; indent(header, 0); - write_type_decl_left(header, get_func_return_type(cur)); - fprintf(header, " (%s *%s)(\n", callconv, get_name(def)); - write_args(header, cur->args, name, 1, TRUE); + write_type_decl_left(header, type_function_get_rettype(func->type)); + fprintf(header, " (%s *%s)(\n", callconv, get_name(func)); + write_args(header, type_get_function_args(func->type), name, 1, TRUE); fprintf(header, ");\n"); fprintf(header, "\n"); } @@ -724,28 +741,27 @@ static void write_c_method_def(FILE *header, const type_t *iface) static void write_c_disp_method_def(FILE *header, const type_t *iface) { - do_write_c_method_def(header, iface->ref, iface->name); + do_write_c_method_def(header, type_iface_get_inherit(iface), iface->name); } static void write_method_proto(FILE *header, const type_t *iface) { - const func_t *cur; + const statement_t *stmt; - if (!iface->funcs) return; - LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { - const var_t *def = cur->def; + const var_t *func = stmt->u.var; - if (!is_local(def->attrs)) { - const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV); + if (!is_local(func->attrs)) { + const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); if (!callconv) callconv = ""; /* proxy prototype */ - write_type_decl_left(header, get_func_return_type(cur)); - fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(def)); - write_args(header, cur->args, iface->name, 1, TRUE); + write_type_decl_left(header, type_function_get_rettype(func->type)); + fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); + write_args(header, type_get_function_args(func->type), iface->name, 1, TRUE); fprintf(header, ");\n"); /* stub prototype */ - fprintf(header, "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(def)); + fprintf(header, "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(func)); fprintf(header, " IRpcStubBuffer* This,\n"); fprintf(header, " IRpcChannelBuffer* pRpcChannelBuffer,\n"); fprintf(header, " PRPC_MESSAGE pRpcMessage,\n"); @@ -758,30 +774,29 @@ static void write_locals(FILE *fp, const type_t *iface, int body) { static const char comment[] = "/* WIDL-generated stub. You must provide an implementation for this. */"; - const func_list_t *funcs = iface->funcs; - const func_t *cur; + const statement_t *stmt; - if (!is_object(iface->attrs) || !funcs) + if (!is_object(iface->attrs)) return; - LIST_FOR_EACH_ENTRY(cur, funcs, const func_t, entry) { - const var_t *def = cur->def; - const var_t *cas = is_callas(def->attrs); + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { + const var_t *func = stmt->u.var; + const var_t *cas = is_callas(func->attrs); if (cas) { - const func_t *m; - LIST_FOR_EACH_ENTRY(m, iface->funcs, const func_t, entry) - if (!strcmp(m->def->name, cas->name)) + const statement_t *stmt2 = NULL; + STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface)) + if (!strcmp(stmt2->u.var->name, cas->name)) break; - if (&m->entry != iface->funcs) { - const var_t *mdef = m->def; + if (&stmt2->entry != type_iface_get_stmts(iface)) { + const var_t *m = stmt2->u.var; /* proxy prototype - use local prototype */ - write_type_decl_left(fp, get_func_return_type(m)); - fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(mdef)); - write_args(fp, m->args, iface->name, 1, TRUE); + write_type_decl_left(fp, type_function_get_rettype(m->type)); + fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(m)); + write_args(fp, type_get_function_args(m->type), iface->name, 1, TRUE); fprintf(fp, ")"); if (body) { - type_t *rt = get_func_return_type(m); + type_t *rt = type_function_get_rettype(m->type); fprintf(fp, "\n{\n"); fprintf(fp, " %s\n", comment); if (rt->name && strcmp(rt->name, "HRESULT") == 0) @@ -798,9 +813,9 @@ static void write_locals(FILE *fp, const type_t *iface, int body) else fprintf(fp, ";\n"); /* stub prototype - use remotable prototype */ - write_type_decl_left(fp, get_func_return_type(cur)); - fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(mdef)); - write_args(fp, cur->args, iface->name, 1, TRUE); + write_type_decl_left(fp, type_function_get_rettype(func->type)); + fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(m)); + write_args(fp, type_get_function_args(func->type), iface->name, 1, TRUE); fprintf(fp, ")"); if (body) /* Remotable methods must all return HRESULTs. */ @@ -809,7 +824,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body) fprintf(fp, ";\n"); } else - error_loc("invalid call_as attribute (%s -> %s)\n", def->name, cas->name); + error_loc("invalid call_as attribute (%s -> %s)\n", func->name, cas->name); } } } @@ -851,12 +866,12 @@ static void write_function_proto(FILE *header, const type_t *iface, const var_t const char *callconv = get_attrp(fun->type->attrs, ATTR_CALLCONV); /* FIXME: do we need to handle call_as? */ - write_type_decl_left(header, fun->type->ref); + write_type_decl_left(header, type_function_get_rettype(fun->type)); fprintf(header, " "); if (callconv) fprintf(header, "%s ", callconv); fprintf(header, "%s%s(\n", prefix, get_name(fun)); - if (fun->type->details.function->args) - write_args(header, fun->type->details.function->args, iface->name, 0, TRUE); + if (type_get_function_args(fun->type)) + write_args(header, type_get_function_args(fun->type), iface->name, 0, TRUE); else fprintf(header, " void"); fprintf(header, ");\n\n"); @@ -907,9 +922,10 @@ static void write_com_interface_end(FILE *header, type_t *iface) write_iface_guid(header, iface); /* C++ interface */ fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n"); - if (iface->ref) + if (type_iface_get_inherit(iface)) { - fprintf(header, "interface %s : public %s\n", iface->name, iface->ref->name); + fprintf(header, "interface %s : public %s\n", iface->name, + type_iface_get_inherit(iface)->name); fprintf(header, "{\n"); } else @@ -927,7 +943,7 @@ static void write_com_interface_end(FILE *header, type_t *iface) write_cpp_method_def(header, iface); indentation--; } - if (!iface->ref) + if (!type_iface_get_inherit(iface)) fprintf(header, " END_INTERFACE\n"); fprintf(header, "};\n"); fprintf(header, "#else\n"); @@ -950,7 +966,7 @@ static void write_com_interface_end(FILE *header, type_t *iface) fprintf(header, "#ifdef COBJMACROS\n"); /* dispinterfaces don't have real functions, so don't write macros for them, * only for the interface this interface inherits from, i.e. IDispatch */ - write_method_macro(header, dispinterface ? iface->ref : iface, iface->name); + write_method_macro(header, dispinterface ? type_iface_get_inherit(iface) : iface, iface->name); fprintf(header, "#endif\n"); fprintf(header, "\n"); fprintf(header, "#endif\n"); @@ -1042,7 +1058,7 @@ static void write_imports(FILE *header, const statement_list_t *stmts) { case STMT_TYPE: if (stmt->u.type->type == RPC_FC_IP) - write_imports(header, stmt->u.type->stmts); + write_imports(header, type_iface_get_stmts(stmt->u.type)); break; case STMT_TYPEREF: case STMT_IMPORTLIB: @@ -1112,13 +1128,13 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type->attrs)) { write_com_interface_start(header, iface); - write_header_stmts(header, iface->stmts, stmt->u.type, TRUE); + write_header_stmts(header, type_iface_get_stmts(iface), stmt->u.type, TRUE); write_com_interface_end(header, iface); } else { write_rpc_interface_start(header, iface); - write_header_stmts(header, iface->stmts, iface, FALSE); + write_header_stmts(header, type_iface_get_stmts(iface), iface, FALSE); write_rpc_interface_end(header, iface); } } diff --git a/tools/widl/header.h b/tools/widl/header.h index 23561ce37e6..6ac7cb0ae65 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -21,7 +21,7 @@ #ifndef __WIDL_HEADER_H #define __WIDL_HEADER_H -#include "widltypes.h" +#include "typetree.h" extern int is_ptrchain_attr(const var_t *var, enum attr_type t); extern int is_aliaschain_attr(const type_t *var, enum attr_type t); @@ -47,23 +47,23 @@ extern int need_proxy_file(const statement_list_t *stmts); extern const var_t *is_callas(const attr_list_t *list); extern void write_args(FILE *h, const var_list_t *arg, const char *name, int obj, int do_indent); extern void write_array(FILE *h, array_dims_t *v, int field); -extern const var_t* get_explicit_handle_var(const func_t* func); +extern const var_t* get_explicit_handle_var(const var_t *func); extern const type_t* get_explicit_generic_handle_type(const var_t* var); -extern const var_t* get_explicit_generic_handle_var(const func_t* func); -extern const var_t* get_context_handle_var(const func_t* func); -extern int has_out_arg_or_return(const func_t *func); +extern const var_t* get_explicit_generic_handle_var(const var_t *func); +extern const var_t* get_context_handle_var(const var_t *func); +extern int has_out_arg_or_return(const var_t *func); extern void write_guid(FILE *f, const char *guid_prefix, const char *name, const UUID *uuid); extern int is_const_decl(const var_t *var); static inline int last_ptr(const type_t *type) { - return is_ptr(type) && !is_declptr(type->ref); + return is_ptr(type) && !is_declptr(type_pointer_get_ref(type)); } static inline int last_array(const type_t *type) { - return is_array(type) && !is_array(type->ref); + return is_array(type) && !is_array(type_array_get_element(type)); } static inline int is_string_type(const attr_list_t *attrs, const type_t *type) @@ -75,7 +75,7 @@ static inline int is_string_type(const attr_list_t *attrs, const type_t *type) static inline int is_context_handle(const type_t *type) { const type_t *t; - for (t = type; is_ptr(t); t = t->ref) + for (t = type; is_ptr(t); t = type_pointer_get_ref(t)) if (is_attr(t->attrs, ATTR_CONTEXTHANDLE)) return 1; return 0; diff --git a/tools/widl/parser.h b/tools/widl/parser.h index 85171f74b9f..71f08dc994a 100644 --- a/tools/widl/parser.h +++ b/tools/widl/parser.h @@ -45,7 +45,4 @@ void pop_import(void); int is_type(const char *name); -void check_functions(const type_t *iface); -func_list_t *gen_function_list(const statement_list_t *stmts); - #endif diff --git a/tools/widl/parser.y b/tools/widl/parser.y index d9b5c3cbfdf..084b5b3d2a0 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -70,8 +70,6 @@ unsigned char pointer_default = RPC_FC_UP; static int is_object_interface = FALSE; -/* are we inside a library block? */ -static int is_inside_library = FALSE; typedef struct list typelist_t; struct typenode { @@ -140,6 +138,7 @@ static var_t *reg_const(var_t *var); static char *gen_name(void); static void check_arg(var_t *arg); +static void check_statements(const statement_list_t *stmts, int is_inside_library); static void check_all_user_types(const statement_list_t *stmts); static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs); @@ -153,7 +152,7 @@ static attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_module_attrs(const char *name, attr_list_t *attrs); static attr_list_t *check_coclass_attrs(const char *name, attr_list_t *attrs); const char *get_attr_display_name(enum attr_type type); -static void add_explicit_handle_if_necessary(func_t *func); +static void add_explicit_handle_if_necessary(var_t *func); static void check_def(const type_t *t); static statement_t *make_statement(enum statement_type type); @@ -346,6 +345,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s %% input: gbl_statements { fix_incomplete(); + check_statements($1, FALSE); check_all_user_types($1); write_header($1); write_id_data($1); @@ -433,14 +433,12 @@ libraryhdr: tLIBRARY aIDENTIFIER { $$ = $2; } ; library_start: attributes libraryhdr '{' { $$ = make_library($2, check_library_attrs($2, $1)); if (!parse_only) start_typelib($$); - is_inside_library = TRUE; } ; librarydef: library_start imp_statements '}' semicolon_opt { $$ = $1; $$->stmts = $2; if (!parse_only) end_typelib(); - is_inside_library = FALSE; } ; @@ -787,7 +785,7 @@ base_type: tBYTE { $$ = make_builtin($1); } case RPC_FC_HYPER: if ($$->name[0] == 'h') /* hyper, as opposed to __int64 */ { - $$ = alias($$, "MIDL_uhyper"); + $$ = type_new_alias($$, "MIDL_uhyper"); $$->sign = 0; } break; @@ -818,7 +816,7 @@ int_std: tINT { $$ = make_builtin($1); } coclass: tCOCLASS aIDENTIFIER { $$ = make_class($2); } | tCOCLASS aKNOWNTYPE { $$ = find_type($2, 0); - if ($$->kind != TKIND_COCLASS) + if ($$->type != RPC_FC_COCLASS) error_loc("%s was not declared a coclass at %s:%d\n", $2, $$->loc_info.input_name, $$->loc_info.line_number); @@ -832,10 +830,7 @@ coclasshdr: attributes coclass { $$ = $2; ; coclassdef: coclasshdr '{' coclass_ints '}' semicolon_opt - { $$ = $1; - $$->ifaces = $3; - $$->defined = TRUE; - } + { $$ = type_coclass_define($1, $3); } ; coclass_ints: { $$ = NULL; } @@ -846,8 +841,8 @@ coclass_int: m_attributes interfacedec { $$ = make_ifref($2); $$->attrs = $1; } ; -dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_DISPATCH; } - | tDISPINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_DISPATCH; } +dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); } + | tDISPINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); } ; dispinterfacehdr: attributes dispinterface { attr_t *attrs; @@ -884,8 +879,8 @@ inherit: { $$ = NULL; } | ':' aKNOWNTYPE { $$ = find_type_or_error2($2, 0); } ; -interface: tINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_INTERFACE; } - | tINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_INTERFACE; } +interface: tINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); } + | tINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); } ; interfacehdr: attributes interface { $$.interface = $2; @@ -920,8 +915,8 @@ interfacedec: | dispinterface ';' { $$ = $1; } ; -module: tMODULE aIDENTIFIER { $$ = make_type(0, NULL); $$->name = $2; $$->kind = TKIND_MODULE; } - | tMODULE aKNOWNTYPE { $$ = make_type(0, NULL); $$->name = $2; $$->kind = TKIND_MODULE; } +module: tMODULE aIDENTIFIER { $$ = type_new_module($2); } + | tMODULE aKNOWNTYPE { $$ = type_new_module($2); } ; modulehdr: attributes module { $$ = $2; @@ -931,8 +926,7 @@ modulehdr: attributes module { $$ = $2; moduledef: modulehdr '{' int_statements '}' semicolon_opt { $$ = $1; - $$->stmts = $3; - $$->funcs = gen_function_list($3); + type_module_define($$, $3); } ; @@ -1296,17 +1290,11 @@ type_t *make_type(unsigned char type, type_t *ref) { type_t *t = alloc_type(); t->name = NULL; - t->kind = TKIND_PRIMITIVE; t->type = type; t->ref = ref; t->attrs = NULL; t->orig = NULL; - t->funcs = NULL; memset(&t->details, 0, sizeof(t->details)); - t->ifaces = NULL; - t->dim = 0; - t->size_is = NULL; - t->length_is = NULL; t->typestring_offset = 0; t->ptrdesc = 0; t->declarray = FALSE; @@ -1317,6 +1305,7 @@ type_t *make_type(unsigned char type, type_t *ref) t->user_types_registered = FALSE; t->tfswrite = FALSE; t->checked = FALSE; + t->is_alias = FALSE; t->typelib_idx = -1; init_loc_info(&t->loc_info); return t; @@ -1325,7 +1314,6 @@ type_t *make_type(unsigned char type, type_t *ref) static type_t *type_new_enum(char *name, var_list_t *enums) { type_t *t = get_type(RPC_FC_ENUM16, name, tsENUM); - t->kind = TKIND_ENUM; if (enums) { t->details.enumeration = xmalloc(sizeof(*t->details.enumeration)); @@ -1342,7 +1330,6 @@ static type_t *type_new_struct(char *name, int defined, var_list_t *fields) type_t *tag_type = name ? find_type(name, tsSTRUCT) : NULL; type_t *t = make_type(RPC_FC_STRUCT, NULL); t->name = name; - t->kind = TKIND_RECORD; if (defined || (tag_type && tag_type->details.structure)) { if (tag_type && tag_type->details.structure) @@ -1370,7 +1357,6 @@ static type_t *type_new_struct(char *name, int defined, var_list_t *fields) static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields) { type_t *t = get_type(RPC_FC_NON_ENCAPSULATED_UNION, name, tsUNION); - t->kind = TKIND_UNION; t->details.structure = xmalloc(sizeof(*t->details.structure)); t->details.structure->fields = fields; t->defined = TRUE; @@ -1380,10 +1366,8 @@ static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields) static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases) { type_t *t = get_type(RPC_FC_ENCAPSULATED_UNION, name, tsUNION); - t->kind = TKIND_UNION; if (!union_field) union_field = make_var( xstrdup("tagged_union") ); union_field->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL); - union_field->type->kind = TKIND_UNION; union_field->type->details.structure = xmalloc(sizeof(*union_field->type->details.structure)); union_field->type->details.structure->fields = cases; union_field->type->defined = TRUE; @@ -1394,15 +1378,14 @@ static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_ return t; } -static void function_add_head_arg(func_t *func, var_t *arg) +static void type_function_add_head_arg(type_t *type, var_t *arg) { - if (!func->def->type->details.function->args) + if (!type->details.function->args) { - func->def->type->details.function->args = xmalloc( sizeof(*func->def->type->details.function->args) ); - list_init( func->def->type->details.function->args ); + type->details.function->args = xmalloc( sizeof(*type->details.function->args) ); + list_init( type->details.function->args ); } - list_add_head( func->def->type->details.function->args, &arg->entry ); - func->args = func->def->type->details.function->args; + list_add_head( type->details.function->args, &arg->entry ); } static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type) @@ -1421,9 +1404,9 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, { expr_list_t *sizes = get_attrp(v->attrs, ATTR_SIZEIS); expr_list_t *lengs = get_attrp(v->attrs, ATTR_LENGTHIS); - int sizeless, has_varconf; + int sizeless; expr_t *dim; - type_t *atype, **ptype; + type_t **ptype; array_dims_t *arr = decl ? decl->array : NULL; type_t *func_type = decl ? decl->func_type : NULL; type_t *type = decl_spec->type; @@ -1436,7 +1419,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, { type_t *t; /* move inline attribute from return type node to function node */ - for (t = func_type; is_ptr(t); t = t->ref) + for (t = func_type; is_ptr(t); t = type_pointer_get_ref(t)) ; t->attrs = move_attr(t->attrs, type->attrs, ATTR_INLINE); } @@ -1459,7 +1442,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, for (ptr = *pt; ptr && !ptr_attr; ) { ptr_attr = get_attrv(ptr->attrs, ATTR_POINTERTYPE); - if (!ptr_attr && ptr->kind == TKIND_ALIAS) + if (!ptr_attr && type_is_alias(ptr)) ptr = ptr->orig; else break; @@ -1486,6 +1469,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, error_loc("'%s': [v1_enum] attribute applied to non-enum type\n", v->name); } + ptype = &v->type; sizeless = FALSE; if (arr) LIST_FOR_EACH_ENTRY_REV(dim, arr, expr_t, entry) { @@ -1494,35 +1478,46 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, if (dim->is_const) { - v->type = make_type(RPC_FC_LGFARRAY, v->type); + if (dim->cval <= 0) + error_loc("%s: array dimension must be positive\n", v->name); + + /* FIXME: should use a type_memsize that allows us to pass in a pointer size */ + if (0) + { + unsigned int align = 0; + size_t size = type_memsize(v->type, &align); + + if (0xffffffffuL / size < (unsigned long) dim->cval) + error_loc("%s: total array size is too large\n", v->name); + } } else - { sizeless = TRUE; - v->type = make_type(RPC_FC_CARRAY, v->type); - } - v->type->declarray = TRUE; - v->type->dim = dim->cval; + *ptype = type_new_array(NULL, *ptype, TRUE, + dim->is_const ? dim->cval : 0, + dim->is_const ? NULL : dim, NULL); } ptype = &v->type; - has_varconf = FALSE; if (sizes) LIST_FOR_EACH_ENTRY(dim, sizes, expr_t, entry) { if (dim->type != EXPR_VOID) { - has_varconf = TRUE; - atype = *ptype = duptype(*ptype, 0); - - if (atype->type == RPC_FC_SMFARRAY || atype->type == RPC_FC_LGFARRAY) - error_loc("%s: cannot specify size_is for a fixed sized array\n", v->name); - - if (atype->type != RPC_FC_CARRAY && !is_ptr(atype)) + if (is_array(*ptype)) + { + if (type_array_get_conformance(*ptype)->is_const) + error_loc("%s: cannot specify size_is for a fixed sized array\n", v->name); + else + *ptype = type_new_array((*ptype)->name, + type_array_get_element(*ptype), TRUE, + 0, dim, NULL); + } + else if (is_ptr(*ptype)) + *ptype = type_new_array((*ptype)->name, type_pointer_get_ref(*ptype), FALSE, + 0, dim, NULL); + else error_loc("%s: size_is attribute applied to illegal type\n", v->name); - - atype->type = RPC_FC_CARRAY; - atype->size_is = dim; } ptype = &(*ptype)->ref; @@ -1535,19 +1530,17 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, { if (dim->type != EXPR_VOID) { - has_varconf = TRUE; - atype = *ptype = duptype(*ptype, 0); - - if (atype->type == RPC_FC_SMFARRAY) - atype->type = RPC_FC_SMVARRAY; - else if (atype->type == RPC_FC_LGFARRAY) - atype->type = RPC_FC_LGVARRAY; - else if (atype->type == RPC_FC_CARRAY) - atype->type = RPC_FC_CVARRAY; + if (is_array(*ptype)) + { + *ptype = type_new_array((*ptype)->name, + type_array_get_element(*ptype), + (*ptype)->declarray, + type_array_get_dim(*ptype), + type_array_get_conformance(*ptype), + dim); + } else error_loc("%s: length_is attribute applied to illegal type\n", v->name); - - atype->length_is = dim; } ptype = &(*ptype)->ref; @@ -1555,16 +1548,6 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, error_loc("%s: too many expressions in length_is attribute\n", v->name); } - if (has_varconf && !last_array(v->type)) - { - ptype = &v->type; - for (ptype = &v->type; is_array(*ptype); ptype = &(*ptype)->ref) - { - *ptype = duptype(*ptype, 0); - (*ptype)->type = RPC_FC_BOGUS_ARRAY; - } - } - /* v->type is currently pointing to the type on the left-side of the * declaration, so we need to fix this up so that it is the return type of the * function and make v->type point to the function side of the declaration */ @@ -1573,13 +1556,13 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, type_t *ft, *t; type_t *return_type = v->type; v->type = func_type; - for (ft = v->type; is_ptr(ft); ft = ft->ref) + for (ft = v->type; is_ptr(ft); ft = type_pointer_get_ref(ft)) ; assert(ft->type == RPC_FC_FUNCTION); ft->ref = return_type; /* move calling convention attribute, if present, from pointer nodes to * function node */ - for (t = v->type; is_ptr(t); t = t->ref) + for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t)) ft->attrs = move_attr(ft->attrs, t->attrs, ATTR_CALLCONV); if (is_object_interface && !is_attr(ft->attrs, ATTR_CALLCONV)) { @@ -1591,7 +1574,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, else { type_t *t; - for (t = v->type; is_ptr(t); t = t->ref) + for (t = v->type; is_ptr(t); t = type_pointer_get_ref(t)) if (is_attr(t->attrs, ATTR_CALLCONV)) error_loc("calling convention applied to non-function-pointer type\n"); } @@ -1707,8 +1690,6 @@ static func_t *make_func(var_t *def) { func_t *f = xmalloc(sizeof(func_t)); f->def = def; - f->args = def->type->details.function->args; - f->idx = -1; return f; } @@ -1716,7 +1697,6 @@ static type_t *make_class(char *name) { type_t *c = make_type(RPC_FC_COCLASS, NULL); c->name = name; - c->kind = TKIND_COCLASS; return c; } @@ -1796,7 +1776,7 @@ static void add_incomplete(type_t *t) static void fix_type(type_t *t) { - if (t->kind == TKIND_ALIAS && is_incomplete(t)) { + if (type_is_alias(t) && is_incomplete(t)) { type_t *ot = t->orig; fix_type(ot); if (is_struct(ot->type) || is_union(ot->type)) @@ -1846,7 +1826,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at unsigned char c; while (is_ptr(t)) - t = t->ref; + t = type_pointer_get_ref(t); c = t->type; if (c != RPC_FC_CHAR && c != RPC_FC_BYTE && c != RPC_FC_WCHAR) @@ -1860,8 +1840,9 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at /* We must generate names for tagless enum, struct or union. Typedef-ing a tagless enum, struct or union means we want the typedef to be included in a library hence the public attribute. */ - if ((type->kind == TKIND_ENUM || type->kind == TKIND_RECORD - || type->kind == TKIND_UNION) && ! type->name && ! parse_only) + if ((type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32 || + is_struct(type->type) || is_union(type->type)) && + !type->name && !parse_only) { if (! is_attr(attrs, ATTR_PUBLIC)) attrs = append_attr( attrs, make_attr(ATTR_PUBLIC) ); @@ -1886,7 +1867,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at /* set the attributes to allow set_type to do some checks on them */ name->attrs = attrs; set_type(name, decl_spec, decl, 0); - cur = alias(name->type, name->name); + cur = type_new_alias(name->type, name->name); cur->attrs = attrs; if (is_incomplete(cur)) @@ -1982,25 +1963,6 @@ var_t *find_const(const char *name, int f) return cur->var; } -func_list_t *gen_function_list(const statement_list_t *stmts) -{ - func_list_t *func_list = NULL; - const statement_t *stmt; - if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) - { - if (stmt->type == STMT_DECLARATION) - { - var_t *var = stmt->u.var; - if (var->stgclass == STG_NONE && var->type->type == RPC_FC_FUNCTION) - { - check_function_attrs(var->name, var->type->attrs); - func_list = append_func(func_list, make_func(var)); - } - } - } - return func_list; -} - static char *gen_name(void) { static const char format[] = "__WIDL_%s_generated_name_%08lX"; @@ -2313,19 +2275,13 @@ static int is_allowed_conf_type(const type_t *type) static int is_ptr_guid_type(const type_t *type) { unsigned int align = 0; - for (;;) - { - if (type->kind == TKIND_ALIAS) - type = type->orig; - else if (is_ptr(type)) - { - type = type->ref; - break; - } - else - return FALSE; - } - return (type_memsize(type, &align) == 16); + + /* first, make sure it is a pointer to something */ + if (!is_ptr(type)) return FALSE; + + /* second, make sure it is a pointer to something of size sizeof(GUID), + * i.e. 16 bytes */ + return (type_memsize(type_pointer_get_ref(type), &align) == 16); } static void check_conformance_expr_list(const char *attr_name, const var_t *arg, const type_t *container_type, expr_list_t *expr_list) @@ -2423,10 +2379,12 @@ static void check_field_common(const type_t *container_type, is_context_handle = 1; break; } - if (type->kind == TKIND_ALIAS) + if (type_is_alias(type)) type = type->orig; - else if (is_ptr(type) || is_array(type)) + else if (is_ptr(type)) type = type->ref; + else if (is_array(type)) + type = type_array_get_element(type); else break; } @@ -2444,9 +2402,7 @@ static void check_remoting_fields(const var_t *var, type_t *type) const var_t *field; const var_list_t *fields = NULL; - /* find the real type */ - while (type->kind == TKIND_ALIAS) - type = type->orig; + type = type_get_real_type(type); if (type->checked) return; @@ -2468,12 +2424,12 @@ static void check_remoting_fields(const var_t *var, type_t *type) } /* checks that arguments for a function make sense for marshalling and unmarshalling */ -static void check_remoting_args(const func_t *func) +static void check_remoting_args(const var_t *func) { - const char *funcname = func->def->name; + const char *funcname = func->name; const var_t *arg; - if (func->args) LIST_FOR_EACH_ENTRY( arg, func->args, const var_t, entry ) + if (func->type->details.function->args) LIST_FOR_EACH_ENTRY( arg, func->type->details.function->args, const var_t, entry ) { int ptr_level = 0; const type_t *type = arg->type; @@ -2485,12 +2441,12 @@ static void check_remoting_args(const func_t *func) break; if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) break; - if (type->kind == TKIND_ALIAS) + if (type_is_alias(type)) type = type->orig; else if (is_ptr(type)) { ptr_level++; - type = type->ref; + type = type_pointer_get_ref(type); } else break; @@ -2508,11 +2464,11 @@ static void check_remoting_args(const func_t *func) } } - check_field_common(func->def->type, funcname, arg); + check_field_common(func->type, funcname, arg); } } -static void add_explicit_handle_if_necessary(func_t *func) +static void add_explicit_handle_if_necessary(var_t *func) { const var_t* explicit_handle_var; const var_t* explicit_generic_handle_var = NULL; @@ -2534,31 +2490,47 @@ static void add_explicit_handle_if_necessary(func_t *func) var_t *idl_handle = make_var(xstrdup("IDL_handle")); idl_handle->attrs = append_attr(NULL, make_attr(ATTR_IN)); idl_handle->type = find_type_or_error("handle_t", 0); - function_add_head_arg(func, idl_handle); + type_function_add_head_arg(func->type, idl_handle); } } } } -void check_functions(const type_t *iface) +static void check_functions(const type_t *iface, int is_inside_library) { - if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE) && iface->funcs) + const statement_t *stmt; + if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE)) { - func_t *func; - LIST_FOR_EACH_ENTRY( func, iface->funcs, func_t, entry ) + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) + { + var_t *func = stmt->u.var; add_explicit_handle_if_necessary(func); + } } if (!is_inside_library && !is_attr(iface->attrs, ATTR_LOCAL)) { - const func_t *func; - if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) { - if (!is_attr(func->def->attrs, ATTR_LOCAL)) + const var_t *func = stmt->u.var; + if (!is_attr(func->attrs, ATTR_LOCAL)) check_remoting_args(func); } } } +static void check_statements(const statement_list_t *stmts, int is_inside_library) +{ + const statement_t *stmt; + + if (stmts) LIST_FOR_EACH_ENTRY(stmt, stmts, const statement_t, entry) + { + if (stmt->type == STMT_LIBRARY) + check_statements(stmt->u.lib->stmts, TRUE); + else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) + check_functions(stmt->u.type, is_inside_library); + } +} + static void check_all_user_types(const statement_list_t *stmts) { const statement_t *stmt; @@ -2570,10 +2542,11 @@ static void check_all_user_types(const statement_list_t *stmts) else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP && !is_local(stmt->u.type->attrs)) { - const func_t *f; - const func_list_t *fs = stmt->u.type->funcs; - if (fs) LIST_FOR_EACH_ENTRY(f, fs, const func_t, entry) - check_for_additional_prototype_types(f->args); + const statement_t *stmt_func; + STATEMENTS_FOR_EACH_FUNC(stmt_func, type_iface_get_stmts(stmt->u.type)) { + const var_t *func = stmt_func->u.var; + check_for_additional_prototype_types(func->type->details.function->args); + } } } } diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c index 9585d2c6130..878e820ce69 100644 --- a/tools/widl/proxy.c +++ b/tools/widl/proxy.c @@ -164,10 +164,10 @@ int cant_be_null(const var_t *v) if (is_user_type(type)) return 0; - if (! attrs && type) + if (!attrs && is_ptr(type)) { attrs = type->attrs; - type = type->ref; + type = type_pointer_get_ref(type); } while (attrs) @@ -180,10 +180,10 @@ int cant_be_null(const var_t *v) if (t == RPC_FC_RP) return 1; - if (type) + if (is_ptr(type)) { attrs = type->attrs; - type = type->ref; + type = type_pointer_get_ref(type); } else attrs = NULL; @@ -194,17 +194,19 @@ int cant_be_null(const var_t *v) static int need_delegation(const type_t *iface) { - return iface->ref && iface->ref->ref && iface->ref->ignore; + return type_iface_get_inherit(iface) && + type_iface_get_inherit(type_iface_get_inherit(iface)) && + type_iface_get_inherit(iface)->ignore; } static int get_delegation_indirect(const type_t *iface, const type_t ** delegate_to) { const type_t * cur_iface; - for (cur_iface = iface; cur_iface != NULL; cur_iface = cur_iface->ref) + for (cur_iface = iface; cur_iface != NULL; cur_iface = type_iface_get_inherit(cur_iface)) if (need_delegation(cur_iface)) { if(delegate_to) - *delegate_to = cur_iface->ref; + *delegate_to = type_iface_get_inherit(cur_iface); return 1; } return 0; @@ -295,29 +297,28 @@ static void proxy_free_variables( var_list_t *args, const char *local_var_prefix } } -static void gen_proxy(type_t *iface, const func_t *cur, int idx, +static void gen_proxy(type_t *iface, const var_t *func, int idx, unsigned int proc_offset) { - var_t *def = cur->def; - int has_ret = !is_void(get_func_return_type(cur)); - int has_full_pointer = is_full_pointer_function(cur); - const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV); + int has_ret = !is_void(type_function_get_rettype(func->type)); + int has_full_pointer = is_full_pointer_function(func); + const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV); if (!callconv) callconv = ""; indent = 0; print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n", - iface->name, get_name(def) ); + iface->name, get_name(func) ); print_proxy( "{\n"); indent++; - if (has_full_pointer) write_full_pointer_free(proxy, indent, cur); + if (has_full_pointer) write_full_pointer_free(proxy, indent, func); print_proxy( "NdrProxyFreeBuffer( __frame->This, &__frame->_StubMsg );\n" ); indent--; print_proxy( "}\n"); print_proxy( "\n"); - write_type_decl_left(proxy, get_func_return_type(cur)); - print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(def)); - write_args(proxy, cur->args, iface->name, 1, TRUE); + write_type_decl_left(proxy, type_function_get_rettype(func->type)); + print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); + write_args(proxy, type_get_function_args(func->type), iface->name, 1, TRUE); print_proxy( ")\n"); print_proxy( "{\n"); indent ++; @@ -325,41 +326,41 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, /* local variables */ if (has_ret) { print_proxy( "" ); - write_type_decl_left(proxy, get_func_return_type(cur)); + write_type_decl_left(proxy, type_function_get_rettype(func->type)); print_proxy( " _RetVal;\n"); } print_proxy( "RPC_MESSAGE _RpcMessage;\n" ); if (has_ret) { - if (decl_indirect(get_func_return_type(cur))) + if (decl_indirect(type_function_get_rettype(func->type))) print_proxy("void *_p_%s = &%s;\n", "_RetVal", "_RetVal"); } print_proxy( "\n"); - print_proxy( "RpcExceptionInit( __proxy_filter, __finally_%s_%s_Proxy );\n", iface->name, get_name(def) ); + print_proxy( "RpcExceptionInit( __proxy_filter, __finally_%s_%s_Proxy );\n", iface->name, get_name(func) ); print_proxy( "__frame->This = This;\n" ); if (has_full_pointer) - write_full_pointer_init(proxy, indent, cur, FALSE); + write_full_pointer_init(proxy, indent, func, FALSE); /* FIXME: trace */ - clear_output_vars( cur->args ); + clear_output_vars( type_get_function_args(func->type) ); print_proxy( "RpcTryExcept\n" ); print_proxy( "{\n" ); indent++; print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &__frame->_StubMsg, &Object_StubDesc, %d);\n", idx); - proxy_check_pointers( cur->args ); + proxy_check_pointers( type_get_function_args(func->type) ); print_proxy( "RpcTryFinally\n" ); print_proxy( "{\n" ); indent++; - write_remoting_arguments(proxy, indent, cur, "", PASS_IN, PHASE_BUFFERSIZE); + write_remoting_arguments(proxy, indent, func, "", PASS_IN, PHASE_BUFFERSIZE); print_proxy( "NdrProxyGetBuffer(This, &__frame->_StubMsg);\n" ); - write_remoting_arguments(proxy, indent, cur, "", PASS_IN, PHASE_MARSHAL); + write_remoting_arguments(proxy, indent, func, "", PASS_IN, PHASE_MARSHAL); print_proxy( "NdrProxySendReceive(This, &__frame->_StubMsg);\n" ); fprintf(proxy, "\n"); @@ -372,15 +373,16 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, indent--; fprintf(proxy, "\n"); - write_remoting_arguments(proxy, indent, cur, "", PASS_OUT, PHASE_UNMARSHAL); + write_remoting_arguments(proxy, indent, func, "", PASS_OUT, PHASE_UNMARSHAL); if (has_ret) { - if (decl_indirect(get_func_return_type(cur))) + if (decl_indirect(type_function_get_rettype(func->type))) print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal"); - else if (is_ptr(get_func_return_type(cur)) || is_array(get_func_return_type(cur))) + else if (is_ptr(type_function_get_rettype(func->type)) || + is_array(type_function_get_rettype(func->type))) print_proxy("%s = 0;\n", "_RetVal"); - write_remoting_arguments(proxy, indent, cur, "", PASS_RETURN, PHASE_UNMARSHAL); + write_remoting_arguments(proxy, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL); } indent--; @@ -388,7 +390,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, print_proxy( "RpcFinally\n" ); print_proxy( "{\n" ); indent++; - print_proxy( "__finally_%s_%s_Proxy( __frame );\n", iface->name, get_name(def) ); + print_proxy( "__finally_%s_%s_Proxy( __frame );\n", iface->name, get_name(func) ); indent--; print_proxy( "}\n"); print_proxy( "RpcEndFinally\n" ); @@ -398,7 +400,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, print_proxy( "{\n" ); if (has_ret) { indent++; - proxy_free_variables( cur->args, "" ); + proxy_free_variables( type_get_function_args(func->type), "" ); print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" ); indent--; } @@ -413,34 +415,33 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, print_proxy( "\n"); } -static void gen_stub(type_t *iface, const func_t *cur, const char *cas, +static void gen_stub(type_t *iface, const var_t *func, const char *cas, unsigned int proc_offset) { - var_t *def = cur->def; const var_t *arg; - int has_ret = !is_void(get_func_return_type(cur)); - int has_full_pointer = is_full_pointer_function(cur); + int has_ret = !is_void(type_function_get_rettype(func->type)); + int has_full_pointer = is_full_pointer_function(func); indent = 0; - print_proxy( "struct __frame_%s_%s_Stub\n{\n", iface->name, get_name(def)); + print_proxy( "struct __frame_%s_%s_Stub\n{\n", iface->name, get_name(func)); indent++; print_proxy( "__DECL_EXCEPTION_FRAME\n" ); print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n"); print_proxy( "%s * _This;\n", iface->name ); - declare_stub_args( proxy, indent, cur ); + declare_stub_args( proxy, indent, func ); indent--; print_proxy( "};\n\n" ); - print_proxy( "static void __finally_%s_%s_Stub(", iface->name, get_name(def) ); - print_proxy( " struct __frame_%s_%s_Stub *__frame )\n{\n", iface->name, get_name(def) ); + print_proxy( "static void __finally_%s_%s_Stub(", iface->name, get_name(func) ); + print_proxy( " struct __frame_%s_%s_Stub *__frame )\n{\n", iface->name, get_name(func) ); indent++; - write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_OUT, PHASE_FREE); + write_remoting_arguments(proxy, indent, func, "__frame->", PASS_OUT, PHASE_FREE); if (has_full_pointer) - write_full_pointer_free(proxy, indent, cur); + write_full_pointer_free(proxy, indent, func); indent--; print_proxy( "}\n\n" ); - print_proxy( "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(def)); + print_proxy( "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(func)); indent++; print_proxy( "IRpcStubBuffer* This,\n"); print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n"); @@ -450,7 +451,7 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas, print_proxy( "{\n"); indent++; print_proxy( "struct __frame_%s_%s_Stub __f, * const __frame = &__f;\n\n", - iface->name, get_name(def) ); + iface->name, get_name(func) ); print_proxy("__frame->_This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n\n", iface->name); @@ -458,37 +459,37 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas, print_proxy("NdrStubInitialize(_pRpcMessage, &__frame->_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n"); fprintf(proxy, "\n"); - print_proxy( "RpcExceptionInit( 0, __finally_%s_%s_Stub );\n", iface->name, get_name(def) ); + print_proxy( "RpcExceptionInit( 0, __finally_%s_%s_Stub );\n", iface->name, get_name(func) ); - write_parameters_init(proxy, indent, cur, "__frame->"); + write_parameters_init(proxy, indent, func, "__frame->"); print_proxy("RpcTryFinally\n"); print_proxy("{\n"); indent++; if (has_full_pointer) - write_full_pointer_init(proxy, indent, cur, TRUE); + write_full_pointer_init(proxy, indent, func, TRUE); print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset ); indent--; fprintf(proxy, "\n"); - write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_IN, PHASE_UNMARSHAL); + write_remoting_arguments(proxy, indent, func, "__frame->", PASS_IN, PHASE_UNMARSHAL); fprintf(proxy, "\n"); - assign_stub_out_args( proxy, indent, cur, "__frame->" ); + assign_stub_out_args( proxy, indent, func, "__frame->" ); print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n"); fprintf(proxy, "\n"); print_proxy(""); if (has_ret) fprintf(proxy, "__frame->_RetVal = "); if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas); - else fprintf(proxy, "__frame->_This->lpVtbl->%s", get_name(def)); + else fprintf(proxy, "__frame->_This->lpVtbl->%s", get_name(func)); fprintf(proxy, "(__frame->_This"); - if (cur->args) + if (type_get_function_args(func->type)) { - LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), const var_t, entry ) fprintf(proxy, ", %s__frame->%s", arg->type->declarray ? "*" : "", arg->name); } fprintf(proxy, ");\n"); @@ -496,26 +497,26 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas, print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n"); fprintf(proxy, "\n"); - write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_OUT, PHASE_BUFFERSIZE); + write_remoting_arguments(proxy, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE); - if (!is_void(get_func_return_type(cur))) - write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE); + if (!is_void(type_function_get_rettype(func->type))) + write_remoting_arguments(proxy, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE); print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &__frame->_StubMsg);\n"); - write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_OUT, PHASE_MARSHAL); + write_remoting_arguments(proxy, indent, func, "__frame->", PASS_OUT, PHASE_MARSHAL); fprintf(proxy, "\n"); /* marshall the return value */ - if (!is_void(get_func_return_type(cur))) - write_remoting_arguments(proxy, indent, cur, "__frame->", PASS_RETURN, PHASE_MARSHAL); + if (!is_void(type_function_get_rettype(func->type))) + write_remoting_arguments(proxy, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL); indent--; print_proxy("}\n"); print_proxy("RpcFinally\n"); print_proxy("{\n"); indent++; - print_proxy( "__finally_%s_%s_Stub( __frame );\n", iface->name, get_name(def) ); + print_proxy( "__finally_%s_%s_Stub( __frame );\n", iface->name, get_name(func) ); indent--; print_proxy("}\n"); print_proxy("RpcEndFinally\n"); @@ -529,28 +530,33 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas, static int count_methods(type_t *iface) { - const func_t *cur; + const statement_t *stmt; int count = 0; - if (iface->ref) count = count_methods(iface->ref); - if (iface->funcs) - LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) - if (!is_callas(cur->def->attrs)) count++; + if (type_iface_get_inherit(iface)) + count = count_methods(type_iface_get_inherit(iface)); + + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { + const var_t *func = stmt->u.var; + if (!is_callas(func->attrs)) count++; + } return count; } static int write_proxy_methods(type_t *iface, int skip) { - const func_t *cur; + const statement_t *stmt; int i = 0; - if (iface->ref) i = write_proxy_methods(iface->ref, need_delegation(iface)); - if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) { - var_t *def = cur->def; - if (!is_callas(def->attrs)) { + if (type_iface_get_inherit(iface)) + i = write_proxy_methods(type_iface_get_inherit(iface), + need_delegation(iface)); + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { + const var_t *func = stmt->u.var; + if (!is_callas(func->attrs)) { if (i) fprintf(proxy, ",\n"); - if (skip) print_proxy( "0 /* %s_%s_Proxy */", iface->name, get_name(def)); - else print_proxy( "%s_%s_Proxy", iface->name, get_name(def)); + if (skip) print_proxy( "0 /* %s_%s_Proxy */", iface->name, get_name(func)); + else print_proxy( "%s_%s_Proxy", iface->name, get_name(func)); i++; } } @@ -559,18 +565,20 @@ static int write_proxy_methods(type_t *iface, int skip) static int write_stub_methods(type_t *iface, int skip) { - const func_t *cur; + const statement_t *stmt; int i = 0; - if (iface->ref) i = write_stub_methods(iface->ref, need_delegation(iface)); - else return i; /* skip IUnknown */ + if (type_iface_get_inherit(iface)) + i = write_stub_methods(type_iface_get_inherit(iface), need_delegation(iface)); + else + return i; /* skip IUnknown */ - if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) { - var_t *def = cur->def; - if (!is_local(def->attrs)) { + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { + const var_t *func = stmt->u.var; + if (!is_local(func->attrs)) { if (i) fprintf(proxy,",\n"); if (skip) print_proxy("STUB_FORWARDING_FUNCTION"); - else print_proxy( "%s_%s_Stub", iface->name, get_name(def)); + else print_proxy( "%s_%s_Stub", iface->name, get_name(func)); i++; } } @@ -580,38 +588,57 @@ static int write_stub_methods(type_t *iface, int skip) static void write_proxy(type_t *iface, unsigned int *proc_offset) { int midx = -1, count; - const func_t *cur; + const statement_t *stmt; + int first_func = 1; /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */ - fprintf(proxy, "/*****************************************************************************\n"); - fprintf(proxy, " * %s interface\n", iface->name); - fprintf(proxy, " */\n"); - if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) - { - const var_t *def = cur->def; - if (!is_local(def->attrs)) { - const var_t *cas = is_callas(def->attrs); + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) { + const var_t *func = stmt->u.var; + if (first_func) { + fprintf(proxy, "/*****************************************************************************\n"); + fprintf(proxy, " * %s interface\n", iface->name); + fprintf(proxy, " */\n"); + first_func = 0; + } + if (!is_local(func->attrs)) { + const var_t *cas = is_callas(func->attrs); const char *cname = cas ? cas->name : NULL; - int idx = cur->idx; + int idx = func->type->details.function->idx; if (cname) { - const func_t *m; - LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry ) - if (!strcmp(m->def->name, cname)) + const statement_t *stmt2; + STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface)) { + const var_t *m = stmt2->u.var; + if (!strcmp(m->name, cname)) { - idx = m->idx; + idx = m->type->details.function->idx; break; } + } } - gen_proxy(iface, cur, idx, *proc_offset); - gen_stub(iface, cur, cname, *proc_offset); - *proc_offset += get_size_procformatstring_func( cur ); + gen_proxy(iface, func, idx, *proc_offset); + gen_stub(iface, func, cname, *proc_offset); + *proc_offset += get_size_procformatstring_func( func ); if (midx == -1) midx = idx; else if (midx != idx) error("method index mismatch in write_proxy\n"); midx++; } } + /* interface didn't have any methods - search in inherited interfaces */ + if (midx == -1) { + const type_t *inherit_iface; + for (inherit_iface = type_iface_get_inherit(iface); + inherit_iface; + inherit_iface = type_iface_get_inherit(inherit_iface)) { + STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(inherit_iface)) { + const var_t *func = stmt->u.var; + int idx = func->type->details.function->idx; + if (idx + 1 > midx) midx = idx + 1; + } + } + } + count = count_methods(iface); if (midx != -1 && midx != count) error("invalid count %u/%u\n", count, midx); @@ -743,7 +770,7 @@ static void build_iface_list( const statement_list_t *stmts, type_t **ifaces[], else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) { type_t *iface = stmt->u.type; - if (iface->ref && need_proxy(iface)) + if (type_iface_get_inherit(iface) && need_proxy(iface)) { *ifaces = xrealloc( *ifaces, (*count + 1) * sizeof(*ifaces) ); (*ifaces)[(*count)++] = iface; diff --git a/tools/widl/server.c b/tools/widl/server.c index 20d0e7e43c7..3b0e2f40f98 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -50,20 +50,19 @@ static void print_server(const char *format, ...) static void write_function_stubs(type_t *iface, unsigned int *proc_offset) { - const func_t *func; + const statement_t *stmt; const var_t *var; const var_t* explicit_handle_var; - if (!iface->funcs) return; - LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) { - const var_t *def = func->def; + const var_t *func = stmt->u.var; int has_full_pointer = is_full_pointer_function(func); /* check for a defined binding handle */ explicit_handle_var = get_explicit_handle_var(func); - print_server("struct __frame_%s_%s\n{\n", iface->name, get_name(def)); + print_server("struct __frame_%s_%s\n{\n", iface->name, get_name(func)); indent++; print_server("__DECL_EXCEPTION_FRAME\n"); print_server("MIDL_STUB_MESSAGE _StubMsg;\n"); @@ -74,8 +73,8 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) indent--; print_server("};\n\n"); - print_server("static void __finally_%s_%s(", iface->name, get_name(def)); - fprintf(server," struct __frame_%s_%s *__frame )\n{\n", iface->name, get_name(def)); + print_server("static void __finally_%s_%s(", iface->name, get_name(func)); + fprintf(server," struct __frame_%s_%s *__frame )\n{\n", iface->name, get_name(func)); indent++; write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_FREE); @@ -86,12 +85,12 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) indent--; print_server("}\n\n"); - print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(def)); + print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(func)); /* write the functions body */ fprintf(server, "{\n"); indent++; - print_server("struct __frame_%s_%s __f, * const __frame = &__f;\n", iface->name, get_name(def)); + print_server("struct __frame_%s_%s __f, * const __frame = &__f;\n", iface->name, get_name(func)); if (has_out_arg_or_return(func)) print_server("RPC_STATUS _Status;\n"); fprintf(server, "\n"); @@ -102,7 +101,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_server("&%s_StubDesc);\n", iface->name); indent--; fprintf(server, "\n"); - print_server( "RpcExceptionInit( __server_filter, __finally_%s_%s );\n", iface->name, get_name(def)); + print_server( "RpcExceptionInit( __server_filter, __finally_%s_%s );\n", iface->name, get_name(func)); write_parameters_init(server, indent, func, "__frame->"); @@ -122,7 +121,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) if (has_full_pointer) write_full_pointer_init(server, indent, func, TRUE); - if (func->args) + if (type_get_function_args(func->type)) { print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n"); indent++; @@ -156,19 +155,19 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) assign_stub_out_args(server, indent, func, "__frame->"); /* Call the real server function */ - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) print_server("__frame->_RetVal = "); else print_server(""); - fprintf(server, "%s%s", prefix_server, get_name(def)); + fprintf(server, "%s%s", prefix_server, get_name(func)); - if (func->args) + if (type_get_function_args(func->type)) { int first_arg = 1; fprintf(server, "(\n"); indent++; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) { if (first_arg) first_arg = 0; @@ -202,7 +201,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) { write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE); - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE); print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.BufferLength;\n"); @@ -221,7 +220,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_MARSHAL); /* marshall the return value */ - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL); indent--; @@ -229,7 +228,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) print_server("RpcFinally\n"); print_server("{\n"); indent++; - print_server("__finally_%s_%s( __frame );\n", iface->name, get_name(def)); + print_server("__finally_%s_%s( __frame );\n", iface->name, get_name(func)); indent--; print_server("}\n"); print_server("RpcEndFinally\n"); @@ -251,16 +250,16 @@ static void write_dispatchtable(type_t *iface) { unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION); unsigned long method_count = 0; - const func_t *func; + const statement_t *stmt; print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name); print_server("{\n"); indent++; - if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) { - var_t *def = func->def; - print_server("%s_%s,\n", iface->name, get_name(def)); + var_t *func = stmt->u.var; + print_server("%s_%s,\n", iface->name, get_name(func)); method_count++; } print_server("0\n"); @@ -417,7 +416,7 @@ static void write_server_stmts(const statement_list_t *stmts, int expr_eval_rout fprintf(server, " */\n"); fprintf(server, "\n"); - if (iface->funcs) + if (statements_has_func(type_iface_get_stmts(iface))) { write_serverinterfacedecl(iface); write_stubdescdecl(iface); diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 7810f80d507..dfcb31e13e7 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -46,7 +46,7 @@ /* value to add on to round size up to a multiple of alignment */ #define ROUNDING(size, alignment) (((alignment) - 1) - (((size) + ((alignment) - 1)) & ((alignment) - 1))) -static const func_t *current_func; +static const var_t *current_func; static const type_t *current_structure; static const type_t *current_iface; @@ -120,6 +120,15 @@ const char *string_of_type(unsigned char type) } } +static unsigned char get_pointer_fc(const type_t *type) +{ + assert(is_ptr(type)); + /* FIXME: see corresponding hack in set_type - we shouldn't be getting + * the pointer type from an alias, rather determining it from the + * position */ + return type->type; +} + static int get_struct_type(const type_t *type) { int has_pointer = 0; @@ -152,20 +161,20 @@ static int get_struct_type(const type_t *type) continue; } - if (is_array(field->type->ref)) + if (is_array(type_array_get_element(field->type))) return RPC_FC_BOGUS_STRUCT; - if (is_conformant_array(field->type)) + if (type_array_has_conformance(field->type)) { has_conformance = 1; if (field->type->declarray && list_next(fields, &field->entry)) error_loc("field '%s' deriving from a conformant array must be the last field in the structure\n", field->name); } - if (field->type->length_is) + if (type_array_has_variance(field->type)) has_variance = 1; - t = field->type->ref; + t = type_array_get_element(field->type); } switch (get_struct_type(t)) @@ -205,11 +214,15 @@ static int get_struct_type(const type_t *type) return RPC_FC_BOGUS_STRUCT; /* pointers to interfaces aren't really pointers and have to be * marshalled specially so they make the structure complex */ - if (t->ref->type == RPC_FC_IP) + if (type_pointer_get_ref(t)->type == RPC_FC_IP) return RPC_FC_BOGUS_STRUCT; has_pointer = 1; break; + case RPC_FC_SMFARRAY: + case RPC_FC_LGFARRAY: + case RPC_FC_SMVARRAY: + case RPC_FC_LGVARRAY: case RPC_FC_CARRAY: case RPC_FC_CVARRAY: case RPC_FC_BOGUS_ARRAY: @@ -281,36 +294,70 @@ static int get_struct_type(const type_t *type) return RPC_FC_STRUCT; } -static int get_array_type(const type_t *type) +static unsigned char get_array_type(const type_t *type) { - if (is_array(type)) + unsigned char fc; + const expr_t *size_is; + const type_t *elem_type; + + if (!is_array(type)) + return type->type; + + elem_type = type_array_get_element(type); + size_is = type_array_get_conformance(type); + + if (!size_is) { - const type_t *rt = type->ref; - if (is_user_type(rt)) - return RPC_FC_BOGUS_ARRAY; - switch (get_struct_type(rt)) + unsigned int align = 0; + size_t size = type_memsize(elem_type, &align); + if (size * type_array_get_dim(type) > 0xffffuL) + fc = RPC_FC_LGFARRAY; + else + fc = RPC_FC_SMFARRAY; + } + else + fc = RPC_FC_CARRAY; + + if (type_array_has_variance(type)) + { + if (fc == RPC_FC_SMFARRAY) + fc = RPC_FC_SMVARRAY; + else if (fc == RPC_FC_LGFARRAY) + fc = RPC_FC_LGVARRAY; + else if (fc == RPC_FC_CARRAY) + fc = RPC_FC_CVARRAY; + } + + if (is_user_type(elem_type)) + fc = RPC_FC_BOGUS_ARRAY; + else if (is_struct(elem_type->type)) + { + switch (get_struct_type(elem_type)) { case RPC_FC_BOGUS_STRUCT: - case RPC_FC_NON_ENCAPSULATED_UNION: - case RPC_FC_ENCAPSULATED_UNION: - case RPC_FC_ENUM16: - return RPC_FC_BOGUS_ARRAY; - /* FC_RP should be above, but widl overuses these, and will break things. */ - case RPC_FC_UP: - case RPC_FC_RP: - if (rt->ref->type == RPC_FC_IP) return RPC_FC_BOGUS_ARRAY; + fc = RPC_FC_BOGUS_ARRAY; break; } - - if (type->type == RPC_FC_LGFARRAY || type->type == RPC_FC_LGVARRAY) - { - unsigned int align = 0; - size_t size = type_memsize(type, &align); - if (size * type->dim <= 0xffff) - return (type->type == RPC_FC_LGFARRAY) ? RPC_FC_SMFARRAY : RPC_FC_SMVARRAY; - } } - return type->type; + else if (elem_type->type == RPC_FC_ENUM16) + { + /* is 16-bit enum - if so, wire size differs from mem size and so + * the array cannot be block copied, which means the array is complex */ + fc = RPC_FC_BOGUS_ARRAY; + } + else if (is_union(elem_type->type)) + fc = RPC_FC_BOGUS_ARRAY; + else if (is_ptr(elem_type)) + { + /* ref pointers cannot just be block copied. unique pointers to + * interfaces need special treatment. either case means the array is + * complex */ + if (get_pointer_fc(elem_type) == RPC_FC_RP || + type_pointer_get_ref(elem_type)->type == RPC_FC_IP) + fc = RPC_FC_BOGUS_ARRAY; + } + + return fc; } int is_struct(unsigned char type) @@ -363,7 +410,7 @@ static int type_has_pointers(const type_t *type) else if (is_ptr(type)) return TRUE; else if (is_array(type)) - return type_has_pointers(type->ref); + return type_has_pointers(type_array_get_element(type)); else if (is_struct(type->type)) { var_list_t *fields = type_struct_get_fields(type); @@ -398,7 +445,7 @@ static int type_has_full_pointer(const type_t *type) else if (is_ptr(type)) return FALSE; else if (is_array(type)) - return type_has_full_pointer(type->ref); + return type_has_full_pointer(type_array_get_element(type)); else if (is_struct(type->type)) { var_list_t *fields = type_struct_get_fields(type); @@ -467,7 +514,7 @@ static type_t *get_user_type(const type_t *t, const char **pname) return ut; } - if (t->kind == TKIND_ALIAS) + if (type_is_alias(t)) t = t->orig; else return 0; @@ -483,13 +530,13 @@ static int is_embedded_complex(const type_t *type) { unsigned char tc = type->type; return is_struct(tc) || is_union(tc) || is_array(type) || is_user_type(type) - || (is_ptr(type) && type->ref->type == RPC_FC_IP); + || (is_ptr(type) && type_pointer_get_ref(type)->type == RPC_FC_IP); } static const char *get_context_handle_type_name(const type_t *type) { const type_t *t; - for (t = type; is_ptr(t); t = t->ref) + for (t = type; is_ptr(t); t = type_pointer_get_ref(t)) if (is_attr(t->attrs, ATTR_CONTEXTHANDLE)) return t->name; assert(0); @@ -536,17 +583,17 @@ static void write_var_init(FILE *file, int indent, const type_t *t, const char * print_file(file, indent, "%s%s = 0;\n", local_var_prefix, n); } -void write_parameters_init(FILE *file, int indent, const func_t *func, const char *local_var_prefix) +void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix) { const var_t *var; - if (!is_void(get_func_return_type(func))) - write_var_init(file, indent, get_func_return_type(func), "_RetVal", local_var_prefix); + if (!is_void(type_function_get_rettype(func->type))) + write_var_init(file, indent, type_function_get_rettype(func->type), "_RetVal", local_var_prefix); - if (!func->args) + if (!type_get_function_args(func->type)) return; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) write_var_init(file, indent, var->type, var->name, local_var_prefix); fprintf(file, "\n"); @@ -678,28 +725,29 @@ static void write_procformatstring_stmts(FILE *file, int indent, const statement { if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP) { - const func_t *func; + const statement_t *stmt_func; if (!pred(stmt->u.type)) continue; - if (stmt->u.type->funcs) LIST_FOR_EACH_ENTRY( func, stmt->u.type->funcs, const func_t, entry ) + STATEMENTS_FOR_EACH_FUNC(stmt_func, type_iface_get_stmts(stmt->u.type)) { - if (is_local(func->def->attrs)) continue; + const var_t *func = stmt_func->u.var; + if (is_local(func->attrs)) continue; /* emit argument data */ - if (func->args) + if (type_get_function_args(func->type)) { const var_t *var; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) write_procformatstring_type(file, indent, var->name, var->type, var->attrs, FALSE); } /* emit return value data */ - if (is_void(get_func_return_type(func))) + if (is_void(type_function_get_rettype(func->type))) { print_file(file, indent, "0x5b, /* FC_END */\n"); print_file(file, indent, "0x5c, /* FC_PAD */\n"); } else - write_procformatstring_type(file, indent, "return value", get_func_return_type(func), NULL, TRUE); + write_procformatstring_type(file, indent, "return value", type_function_get_rettype(func->type), NULL, TRUE); } } else if (stmt->type == STMT_LIBRARY) @@ -1004,11 +1052,11 @@ size_t type_memsize(const type_t *t, unsigned int *align) { size_t size = 0; - if (t->kind == TKIND_ALIAS) + if (type_is_alias(t)) size = type_memsize(t->orig, align); else if (t->declarray && is_conformant_array(t)) { - type_memsize(t->ref, align); + type_memsize(type_array_get_element(t), align); size = 0; } else if (is_ptr(t) || is_conformant_array(t)) @@ -1065,37 +1113,37 @@ size_t type_memsize(const type_t *t, unsigned int *align) case RPC_FC_SMVARRAY: case RPC_FC_LGVARRAY: case RPC_FC_BOGUS_ARRAY: - size = t->dim * type_memsize(t->ref, align); + size = type_array_get_dim(t) * type_memsize(type_array_get_element(t), align); break; default: - error("type_memsize: Unknown type %d\n", t->type); + error("type_memsize: Unknown type 0x%x\n", t->type); size = 0; } return size; } -int is_full_pointer_function(const func_t *func) +int is_full_pointer_function(const var_t *func) { const var_t *var; - if (type_has_full_pointer(get_func_return_type(func))) + if (type_has_full_pointer(type_function_get_rettype(func->type))) return TRUE; - if (!func->args) + if (!type_get_function_args(func->type)) return FALSE; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) if (type_has_full_pointer( var->type )) return TRUE; return FALSE; } -void write_full_pointer_init(FILE *file, int indent, const func_t *func, int is_server) +void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server) { print_file(file, indent, "__frame->_StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,%s);\n", is_server ? "XLAT_SERVER" : "XLAT_CLIENT"); fprintf(file, "\n"); } -void write_full_pointer_free(FILE *file, int indent, const func_t *func) +void write_full_pointer_free(FILE *file, int indent, const var_t *func) { print_file(file, indent, "NdrFullPointerXlatFree(__frame->_StubMsg.FullPtrXlatTables);\n"); fprintf(file, "\n"); @@ -1103,9 +1151,9 @@ void write_full_pointer_free(FILE *file, int indent, const func_t *func) static unsigned int write_nonsimple_pointer(FILE *file, const type_t *type, size_t offset) { - short absoff = type->ref->typestring_offset; + short absoff = type_pointer_get_ref(type)->typestring_offset; short reloff = absoff - (offset + 2); - int ptr_attr = is_ptr(type->ref) ? 0x10 : 0x0; + int ptr_attr = is_ptr(type_pointer_get_ref(type)) ? 0x10 : 0x0; print_file(file, 2, "0x%02x, 0x%x,\t/* %s */\n", type->type, ptr_attr, string_of_type(type->type)); @@ -1116,7 +1164,7 @@ static unsigned int write_nonsimple_pointer(FILE *file, const type_t *type, size static unsigned int write_simple_pointer(FILE *file, const type_t *type) { - unsigned char fc = type->ref->type; + unsigned char fc = type_pointer_get_ref(type)->type; /* for historical reasons, write_simple_pointer also handled string types, * but no longer does. catch bad uses of the function with this check */ if (is_string_type(type->attrs, type)) @@ -1142,9 +1190,9 @@ static size_t write_pointer_tfs(FILE *file, type_t *type, unsigned int *typestri print_start_tfs_comment(file, type, offset); update_tfsoff(type, offset, file); - if (type->ref->typestring_offset) + if (type_pointer_get_ref(type)->typestring_offset) *typestring_offset += write_nonsimple_pointer(file, type, offset); - else if (is_base_type(type->ref->type)) + else if (is_base_type(type_pointer_get_ref(type)->type)) *typestring_offset += write_simple_pointer(file, type); return offset; @@ -1391,7 +1439,7 @@ static int write_pointer_description_offsets( int written = 0; unsigned int align; - if (is_ptr(type) && type->ref->type != RPC_FC_IP) + if (is_ptr(type) && type_pointer_get_ref(type)->type != RPC_FC_IP) { if (offset_in_memory && offset_in_buffer) { @@ -1413,7 +1461,8 @@ static int write_pointer_description_offsets( if (is_string_type(attrs, type)) write_string_tfs(file, NULL, type, NULL, typestring_offset); - else if (processed(type->ref) || is_base_type(type->ref->type)) + else if (processed(type_pointer_get_ref(type)) || + is_base_type(type_pointer_get_ref(type)->type)) write_pointer_tfs(file, type, typestring_offset); else error("write_pointer_description_offsets: type format string unknown\n"); @@ -1424,8 +1473,8 @@ static int write_pointer_description_offsets( if (is_array(type)) { return write_pointer_description_offsets( - file, attrs, type->ref, offset_in_memory, offset_in_buffer, - typestring_offset); + file, attrs, type_array_get_element(type), offset_in_memory, + offset_in_buffer, typestring_offset); } else if (is_non_complex_struct(type)) { @@ -1481,7 +1530,7 @@ static int write_fixed_array_pointer_descriptions( /* unfortunately, this needs to be done in two passes to avoid * writing out redundant FC_FIXED_REPEAT descriptions */ pointer_count = write_pointer_description_offsets( - NULL, attrs, type->ref, NULL, NULL, &temp); + NULL, attrs, type_array_get_element(type), NULL, NULL, &temp); if (pointer_count > 0) { unsigned int increment_size; @@ -1489,11 +1538,11 @@ static int write_fixed_array_pointer_descriptions( size_t offset_of_array_pointer_buf = 0; align = 0; - increment_size = type_memsize(type->ref, &align); + increment_size = type_memsize(type_array_get_element(type), &align); print_file(file, 2, "0x%02x, /* FC_FIXED_REPEAT */\n", RPC_FC_FIXED_REPEAT); print_file(file, 2, "0x%02x, /* FC_PAD */\n", RPC_FC_PAD); - print_file(file, 2, "NdrFcShort(0x%x), /* Iterations = %d */\n", type->dim, type->dim); + print_file(file, 2, "NdrFcShort(0x%x), /* Iterations = %d */\n", type_array_get_dim(type), type_array_get_dim(type)); print_file(file, 2, "NdrFcShort(0x%x), /* Increment = %d */\n", increment_size, increment_size); print_file(file, 2, "NdrFcShort(0x%x), /* Offset to array = %d */\n", *offset_in_memory, *offset_in_memory); print_file(file, 2, "NdrFcShort(0x%x), /* Number of pointers = %d */\n", pointer_count, pointer_count); @@ -1549,13 +1598,13 @@ static int write_conformant_array_pointer_descriptions( unsigned int align; int pointer_count = 0; - if (is_conformant_array(type) && !type->length_is) + if (is_conformant_array(type) && !type_array_has_variance(type)) { unsigned int temp = 0; /* unfortunately, this needs to be done in two passes to avoid * writing out redundant FC_VARIABLE_REPEAT descriptions */ pointer_count = write_pointer_description_offsets( - NULL, attrs, type->ref, NULL, NULL, &temp); + NULL, attrs, type_array_get_element(type), NULL, NULL, &temp); if (pointer_count > 0) { unsigned int increment_size; @@ -1563,7 +1612,7 @@ static int write_conformant_array_pointer_descriptions( size_t offset_of_array_pointer_buf = offset_in_memory; align = 0; - increment_size = type_memsize(type->ref, &align); + increment_size = type_memsize(type_array_get_element(type), &align); if (increment_size > USHRT_MAX) error("array size of %u bytes is too large\n", increment_size); @@ -1576,8 +1625,9 @@ static int write_conformant_array_pointer_descriptions( *typestring_offset += 8; pointer_count = write_pointer_description_offsets( - file, attrs, type->ref, &offset_of_array_pointer_mem, - &offset_of_array_pointer_buf, typestring_offset); + file, attrs, type_array_get_element(type), + &offset_of_array_pointer_mem, &offset_of_array_pointer_buf, + typestring_offset); } } @@ -1594,19 +1644,19 @@ static int write_varying_array_pointer_descriptions( unsigned int align; int pointer_count = 0; - if (is_array(type) && type->length_is) + if (is_array(type) && type_array_has_variance(type)) { unsigned int temp = 0; /* unfortunately, this needs to be done in two passes to avoid * writing out redundant FC_VARIABLE_REPEAT descriptions */ pointer_count = write_pointer_description_offsets( - NULL, attrs, type->ref, NULL, NULL, &temp); + NULL, attrs, type_array_get_element(type), NULL, NULL, &temp); if (pointer_count > 0) { unsigned int increment_size; align = 0; - increment_size = type_memsize(type->ref, &align); + increment_size = type_memsize(type_array_get_element(type), &align); if (increment_size > USHRT_MAX) error("array size of %u bytes is too large\n", increment_size); @@ -1632,7 +1682,7 @@ static int write_varying_array_pointer_descriptions( { size_t padding; - if (is_array(v->type) && v->type->length_is) + if (is_array(v->type) && type_array_has_variance(v->type)) { *offset_in_buffer = ROUND_SIZE(*offset_in_buffer, 4); /* skip over variance and offset in buffer */ @@ -1747,7 +1797,10 @@ static size_t write_string_tfs(FILE *file, const attr_list_t *attrs, start_offset = *typestring_offset; update_tfsoff(type, start_offset, file); - rtype = type->ref->type; + if (is_array(type)) + rtype = type_array_get_element(type)->type; + else + rtype = type_pointer_get_ref(type)->type; if ((rtype != RPC_FC_BYTE) && (rtype != RPC_FC_CHAR) && (rtype != RPC_FC_WCHAR)) { @@ -1757,10 +1810,12 @@ static size_t write_string_tfs(FILE *file, const attr_list_t *attrs, if (type->declarray && !is_conformant_array(type)) { + unsigned long dim = type_array_get_dim(type); + /* FIXME: multi-dimensional array */ - if (0xffffuL < type->dim) + if (0xffffuL < dim) error("array size for parameter %s exceeds %u bytes by %lu bytes\n", - name, 0xffffu, type->dim - 0xffffu); + name, 0xffffu, dim - 0xffffu); if (rtype == RPC_FC_CHAR) WRITE_FCTYPE(file, FC_CSTRING, *typestring_offset); @@ -1769,12 +1824,12 @@ static size_t write_string_tfs(FILE *file, const attr_list_t *attrs, print_file(file, 2, "0x%x, /* FC_PAD */\n", RPC_FC_PAD); *typestring_offset += 2; - print_file(file, 2, "NdrFcShort(0x%x), /* %d */\n", type->dim, type->dim); + print_file(file, 2, "NdrFcShort(0x%x), /* %d */\n", dim, dim); *typestring_offset += 2; return start_offset; } - else if (type->size_is) + else if (is_conformant_array(type)) { unsigned int align = 0; @@ -1790,7 +1845,7 @@ static size_t write_string_tfs(FILE *file, const attr_list_t *attrs, (type->declarray && current_structure ? type_memsize(current_structure, &align) : 0), - type, type->size_is); + type, type_array_get_conformance(type)); return start_offset; } @@ -1810,8 +1865,8 @@ static size_t write_string_tfs(FILE *file, const attr_list_t *attrs, static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type, const char *name, unsigned int *typestring_offset) { - const expr_t *length_is = type->length_is; - const expr_t *size_is = type->size_is; + const expr_t *length_is = type_array_get_variance(type); + const expr_t *size_is = type_array_get_conformance(type); unsigned int align = 0; size_t size; size_t start_offset; @@ -1826,13 +1881,13 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type if (!pointer_type) pointer_type = RPC_FC_RP; - if (write_embedded_types(file, attrs, type->ref, name, FALSE, typestring_offset)) + if (write_embedded_types(file, attrs, type_array_get_element(type), name, FALSE, typestring_offset)) has_pointer = TRUE; else - has_pointer = type_has_pointers(type->ref); + has_pointer = type_has_pointers(type_array_get_element(type)); align = 0; - size = type_memsize((is_conformant_array(type) ? type->ref : type), &align); + size = type_memsize((is_conformant_array(type) ? type_array_get_element(type) : type), &align); real_type = get_array_type( type ); start_offset = *typestring_offset; @@ -1864,16 +1919,17 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type if (real_type == RPC_FC_SMVARRAY || real_type == RPC_FC_LGVARRAY) { unsigned int elalign = 0; - size_t elsize = type_memsize(type->ref, &elalign); + size_t elsize = type_memsize(type_array_get_element(type), &elalign); + unsigned long dim = type_array_get_dim(type); if (real_type == RPC_FC_LGVARRAY) { - print_file(file, 2, "NdrFcLong(0x%x),\t/* %lu */\n", type->dim, type->dim); + print_file(file, 2, "NdrFcLong(0x%x),\t/* %lu */\n", dim, dim); *typestring_offset += 4; } else { - print_file(file, 2, "NdrFcShort(0x%x),\t/* %lu */\n", type->dim, type->dim); + print_file(file, 2, "NdrFcShort(0x%x),\t/* %lu */\n", dim, dim); *typestring_offset += 2; } @@ -1896,12 +1952,12 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type *typestring_offset += 1; } - write_member_type(file, type, NULL, type->ref, NULL, typestring_offset); + write_member_type(file, type, NULL, type_array_get_element(type), NULL, typestring_offset); write_end(file, typestring_offset); } else { - unsigned int dim = size_is ? 0 : type->dim; + unsigned int dim = size_is ? 0 : type_array_get_dim(type); print_file(file, 2, "NdrFcShort(0x%x),\t/* %u */\n", dim, dim); *typestring_offset += 2; *typestring_offset @@ -1910,7 +1966,7 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type *typestring_offset += write_conf_or_var_desc(file, current_structure, baseoff, type, length_is); - write_member_type(file, type, NULL, type->ref, NULL, typestring_offset); + write_member_type(file, type, NULL, type_array_get_element(type), NULL, typestring_offset); write_end(file, typestring_offset); } @@ -2319,7 +2375,7 @@ static size_t write_ip_tfs(FILE *file, const attr_list_t *attrs, type_t *type, } else { - const type_t *base = is_ptr(type) ? type->ref : type; + const type_t *base = is_ptr(type) ? type_pointer_get_ref(type) : type; const UUID *uuid = get_attrp(base->attrs, ATTR_UUID); if (! uuid) @@ -2391,7 +2447,7 @@ static size_t write_contexthandle_tfs(FILE *file, const type_t *type, return start_offset; } -static size_t write_typeformatstring_var(FILE *file, int indent, const func_t *func, +static size_t write_typeformatstring_var(FILE *file, int indent, const var_t *func, type_t *type, const var_t *var, unsigned int *typeformat_offset) { @@ -2471,7 +2527,7 @@ static size_t write_typeformatstring_var(FILE *file, int indent, const func_t *f size_t start_offset = *typeformat_offset; int in_attr = is_attr(var->attrs, ATTR_IN); int out_attr = is_attr(var->attrs, ATTR_OUT); - const type_t *base = type->ref; + const type_t *base = type_pointer_get_ref(type); if (base->type == RPC_FC_IP || (base->type == 0 @@ -2496,7 +2552,9 @@ static size_t write_typeformatstring_var(FILE *file, int indent, const func_t *f assert(is_ptr(type)); - offset = write_typeformatstring_var(file, indent, func, type->ref, var, typeformat_offset); + offset = write_typeformatstring_var(file, indent, func, + type_pointer_get_ref(type), var, + typeformat_offset); if (file) fprintf(file, "/* %2u */\n", *typeformat_offset); return write_pointer_only_tfs(file, var->attrs, type->type, @@ -2519,7 +2577,7 @@ static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *ty } else if (is_ptr(type)) { - type_t *ref = type->ref; + type_t *ref = type_pointer_get_ref(type); if (ref->type == RPC_FC_IP || (ref->type == 0 @@ -2572,6 +2630,8 @@ static size_t process_tfs_stmts(FILE *file, const statement_list_t *stmts, if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) { const type_t *iface; + const statement_t *stmt_func; + if (stmt->type == STMT_LIBRARY) { process_tfs_stmts(file, stmt->u.lib->stmts, pred, typeformat_offset); @@ -2584,35 +2644,33 @@ static size_t process_tfs_stmts(FILE *file, const statement_list_t *stmts, if (!pred(iface)) continue; - if (iface->funcs) + current_iface = iface; + STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(iface) ) { - const func_t *func; - current_iface = iface; - LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) - { - if (is_local(func->def->attrs)) continue; + const var_t *func = stmt_func->u.var; + if (is_local(func->attrs)) continue; - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) { - var_t v = *func->def; - v.type = get_func_return_type(func); - update_tfsoff(get_func_return_type(func), + var_t v = *func; + v.type = type_function_get_rettype(func->type); + update_tfsoff(type_function_get_rettype(func->type), write_typeformatstring_var( - file, 2, NULL, get_func_return_type(func), + file, 2, NULL, + type_function_get_rettype(func->type), &v, typeformat_offset), file); } current_func = func; - if (func->args) - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + if (type_get_function_args(func->type)) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) update_tfsoff( var->type, write_typeformatstring_var( file, 2, func, var->type, var, typeformat_offset), file); - } } } @@ -2701,14 +2759,15 @@ static unsigned int get_required_buffer_size_type( return fields_memsize(type_struct_get_fields(type), alignment); case RPC_FC_RP: - return - is_base_type( type->ref->type ) || get_struct_type(type->ref) == RPC_FC_STRUCT - ? get_required_buffer_size_type( type->ref, name, alignment ) - : 0; + { + const type_t *ref = type_pointer_get_ref(type); + return is_base_type( ref->type ) || get_struct_type(ref) == RPC_FC_STRUCT ? + get_required_buffer_size_type( ref, name, alignment ) : 0; + } case RPC_FC_SMFARRAY: case RPC_FC_LGFARRAY: - return type->dim * get_required_buffer_size_type(type->ref, name, alignment); + return type_array_get_dim(type) * get_required_buffer_size_type(type_array_get_element(type), name, alignment); default: return 0; @@ -2742,24 +2801,24 @@ static unsigned int get_required_buffer_size(const var_t *var, unsigned int *ali return 0; } -static unsigned int get_function_buffer_size( const func_t *func, enum pass pass ) +static unsigned int get_function_buffer_size( const var_t *func, enum pass pass ) { const var_t *var; unsigned int total_size = 0, alignment; - if (func->args) + if (type_get_function_args(func->type)) { - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) { total_size += get_required_buffer_size(var, &alignment, pass); total_size += alignment; } } - if (pass == PASS_OUT && !is_void(get_func_return_type(func))) + if (pass == PASS_OUT && !is_void(type_function_get_rettype(func->type))) { - var_t v = *func->def; - v.type = get_func_return_type(func); + var_t v = *func; + v.type = type_function_get_rettype(func->type); total_size += get_required_buffer_size(&v, &alignment, PASS_RETURN); total_size += alignment; } @@ -2819,7 +2878,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL) return; - rtype = is_ptr(type) ? type->ref->type : type->type; + rtype = is_ptr(type) ? type_pointer_get_ref(type)->type : type->type; switch (rtype) { @@ -2872,7 +2931,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, if (phase == PHASE_MARSHAL) { print_file(file, indent, "*("); - write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); if (is_ptr(type)) fprintf(file, " *)__frame->_StubMsg.Buffer = *"); else @@ -2883,7 +2942,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, else if (phase == PHASE_UNMARSHAL) { print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof("); - write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n"); print_file(file, indent, "{\n"); print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); @@ -2897,12 +2956,12 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, fprintf(file, " = ("); else fprintf(file, " = *("); - write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); fprintf(file, " *)__frame->_StubMsg.Buffer;\n"); } print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof("); - write_type_decl(file, is_ptr(type) ? type->ref : type, NULL); + write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL); fprintf(file, ");\n"); } @@ -2917,11 +2976,11 @@ expr_t *get_size_is_expr(const type_t *t, const char *name) { expr_t *x = NULL; - for ( ; is_ptr(t) || is_array(t); t = t->ref) - if (t->size_is) + for ( ; is_array(t); t = type_array_get_element(t)) + if (type_array_has_conformance(t)) { if (!x) - x = t->size_is; + x = type_array_get_conformance(t); else error("%s: multidimensional conformant" " arrays not supported at the top level\n", @@ -2944,19 +3003,19 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char break; else if (is_array(type) || is_string_type(var->attrs, type)) { - if (is_conformance_needed_for_phase(phase)) + if (is_conformance_needed_for_phase(phase) && is_array(type)) { - if (type->size_is) + if (type_array_has_conformance(type)) { print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)"); - write_expr(file, type->size_is, 1, 1, NULL, NULL, local_var_prefix); + write_expr(file, type_array_get_conformance(type), 1, 1, NULL, NULL, local_var_prefix); fprintf(file, ";\n\n"); } - if (type->length_is) + if (type_array_has_variance(type)) { print_file(file, indent, "__frame->_StubMsg.Offset = 0;\n"); /* FIXME */ print_file(file, indent, "__frame->_StubMsg.ActualCount = (ULONG_PTR)"); - write_expr(file, type->length_is, 1, 1, NULL, NULL, local_var_prefix); + write_expr(file, type_array_get_variance(type), 1, 1, NULL, NULL, local_var_prefix); fprintf(file, ";\n\n"); } } @@ -2985,13 +3044,13 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char break; } else if (is_ptr(type)) - type = type->ref; + type = type_pointer_get_ref(type); else break; } } -static void write_remoting_arg(FILE *file, int indent, const func_t *func, const char *local_var_prefix, +static void write_remoting_arg(FILE *file, int indent, const var_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase, const var_t *var) { int in_attr, out_attr, pointer_type; @@ -3080,7 +3139,7 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, const { if (phase == PHASE_FREE || pass == PASS_RETURN || pointer_type == RPC_FC_UP) print_phase_function(file, indent, "Pointer", local_var_prefix, phase, var, - start_offset - (type->size_is ? 4 : 2)); + start_offset - (is_conformant_array(type) ? 4 : 2)); else print_phase_function(file, indent, "ConformantString", local_var_prefix, phase, var, start_offset); @@ -3158,7 +3217,7 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, const } else { - const type_t *ref = type->ref; + const type_t *ref = type_pointer_get_ref(type); if (type->type == RPC_FC_RP && is_base_type(ref->type)) { if (phase != PHASE_FREE) @@ -3183,7 +3242,7 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, const fprintf(file, "\n"); } -void write_remoting_arguments(FILE *file, int indent, const func_t *func, const char *local_var_prefix, +void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase) { if (phase == PHASE_BUFFERSIZE && pass != PASS_RETURN) @@ -3195,8 +3254,8 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func, const if (pass == PASS_RETURN) { var_t var; - var = *func->def; - var.type = get_func_return_type(func); + var = *func; + var.type = type_function_get_rettype(func->type); var.name = xstrdup( "_RetVal" ); write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, &var ); free( var.name ); @@ -3204,9 +3263,9 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func, const else { const var_t *var; - if (!func->args) + if (!type_get_function_args(func->type)) return; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) write_remoting_arg( file, indent, func, local_var_prefix, pass, phase, var ); } } @@ -3218,21 +3277,21 @@ size_t get_size_procformatstring_type(const char *name, const type_t *type, cons } -size_t get_size_procformatstring_func(const func_t *func) +size_t get_size_procformatstring_func(const var_t *func) { const var_t *var; size_t size = 0; /* argument list size */ - if (func->args) - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + if (type_get_function_args(func->type)) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) size += get_size_procformatstring_type(var->name, var->type, var->attrs); /* return value size */ - if (is_void(get_func_return_type(func))) + if (is_void(type_function_get_rettype(func->type))) size += 2; /* FC_END and FC_PAD */ else - size += get_size_procformatstring_type("return value", get_func_return_type(func), NULL); + size += get_size_procformatstring_type("return value", type_function_get_rettype(func->type), NULL); return size; } @@ -3241,11 +3300,12 @@ size_t get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred { const statement_t *stmt; size_t size = 1; - const func_t *func; if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry ) { const type_t *iface; + const statement_t *stmt_func; + if (stmt->type == STMT_LIBRARY) { size += get_size_procformatstring(stmt->u.lib->stmts, pred) - 1; @@ -3258,10 +3318,12 @@ size_t get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred if (!pred(iface)) continue; - if (iface->funcs) - LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry ) - if (!is_local(func->def->attrs)) - size += get_size_procformatstring_func( func ); + STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(iface) ) + { + const var_t *func = stmt_func->u.var; + if (!is_local(func->attrs)) + size += get_size_procformatstring_func( func ); + } } return size; } @@ -3272,24 +3334,24 @@ size_t get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred return process_tfs(NULL, stmts, pred); } -void declare_stub_args( FILE *file, int indent, const func_t *func ) +void declare_stub_args( FILE *file, int indent, const var_t *func ) { int in_attr, out_attr; int i = 0; const var_t *var; /* declare return value '_RetVal' */ - if (!is_void(get_func_return_type(func))) + if (!is_void(type_function_get_rettype(func->type))) { print_file(file, indent, ""); - write_type_decl_left(file, get_func_return_type(func)); + write_type_decl_left(file, type_function_get_rettype(func->type)); fprintf(file, " _RetVal;\n"); } - if (!func->args) + if (!type_get_function_args(func->type)) return; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) { int is_string = is_string_type(var->attrs, var->type); @@ -3302,11 +3364,15 @@ void declare_stub_args( FILE *file, int indent, const func_t *func ) print_file(file, indent, "NDR_SCONTEXT %s;\n", var->name); else { - if (!in_attr && !var->type->size_is && !is_string) + if (!in_attr && !is_conformant_array(var->type) && !is_string) { + type_t *type_to_print; print_file(file, indent, ""); - write_type_decl(file, var->type->declarray ? var->type : var->type->ref, - "_W%u", i++); + if (var->type->declarray) + type_to_print = var->type; + else + type_to_print = type_pointer_get_ref(var->type); + write_type_decl(file, type_to_print, "_W%u", i++); fprintf(file, ";\n"); } @@ -3327,16 +3393,16 @@ void declare_stub_args( FILE *file, int indent, const func_t *func ) } -void assign_stub_out_args( FILE *file, int indent, const func_t *func, const char *local_var_prefix ) +void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char *local_var_prefix ) { int in_attr, out_attr; int i = 0, sep = 0; const var_t *var; - if (!func->args) + if (!type_get_function_args(func->type)) return; - LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) { int is_string = is_string_type(var->attrs, var->type); in_attr = is_attr(var->attrs, ATTR_IN); @@ -3355,15 +3421,19 @@ void assign_stub_out_args( FILE *file, int indent, const func_t *func, const cha print_file(file, indent + 1, "(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%d]);\n", var->type->typestring_offset); } - else if (var->type->size_is) + else if (is_array(var->type) && + type_array_has_conformance(var->type)) { unsigned int size, align = 0; type_t *type = var->type; fprintf(file, " = NdrAllocate(&__frame->_StubMsg, "); - for ( ; type->size_is ; type = type->ref) + for ( ; + is_array(type) && type_array_has_conformance(type); + type = type_array_get_element(type)) { - write_expr(file, type->size_is, TRUE, TRUE, NULL, NULL, local_var_prefix); + write_expr(file, type_array_get_conformance(type), TRUE, + TRUE, NULL, NULL, local_var_prefix); fprintf(file, " * "); } size = type_memsize(type, &align); diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h index 0276b7fa433..b2c48df1993 100644 --- a/tools/widl/typegen.h +++ b/tools/widl/typegen.h @@ -43,14 +43,14 @@ void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred); void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname); -void write_remoting_arguments(FILE *file, int indent, const func_t *func, const char *local_var_prefix, +void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix, enum pass pass, enum remoting_phase phase); size_t get_size_procformatstring_type(const char *name, const type_t *type, const attr_list_t *attrs); -size_t get_size_procformatstring_func(const func_t *func); +size_t get_size_procformatstring_func(const var_t *func); size_t get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred); size_t get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred); -void assign_stub_out_args( FILE *file, int indent, const func_t *func, const char *local_var_prefix ); -void declare_stub_args( FILE *file, int indent, const func_t *func ); +void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char *local_var_prefix ); +void declare_stub_args( FILE *file, int indent, const var_t *func ); int write_expr_eval_routines(FILE *file, const char *iface); void write_expr_eval_routine_list(FILE *file, const char *iface); void write_user_quad_list(FILE *file); @@ -58,11 +58,11 @@ void write_endpoints( FILE *f, const char *prefix, const str_list_t *list ); void write_exceptions( FILE *file ); size_t type_memsize(const type_t *t, unsigned int *align); int decl_indirect(const type_t *t); -void write_parameters_init(FILE *file, int indent, const func_t *func, const char *local_var_prefix); +void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix); void print(FILE *file, int indent, const char *format, va_list ap); int get_padding(const var_list_t *fields); int is_user_type(const type_t *t); expr_t *get_size_is_expr(const type_t *t, const char *name); -int is_full_pointer_function(const func_t *func); -void write_full_pointer_init(FILE *file, int indent, const func_t *func, int is_server); -void write_full_pointer_free(FILE *file, int indent, const func_t *func); +int is_full_pointer_function(const var_t *func); +void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server); +void write_full_pointer_free(FILE *file, int indent, const var_t *func); diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c index 446f9a5ae98..55a2e22c4fa 100644 --- a/tools/widl/typelib.c +++ b/tools/widl/typelib.c @@ -45,34 +45,10 @@ #include "typelib.h" #include "widltypes.h" #include "typelib_struct.h" +#include "typetree.h" static typelib_t *typelib; -type_t *duptype(type_t *t, int dupname) -{ - type_t *d = alloc_type(); - - *d = *t; - if (dupname && t->name) - d->name = xstrdup(t->name); - - d->orig = t; - return d; -} - -type_t *alias(type_t *t, const char *name) -{ - type_t *a = duptype(t, 0); - - a->name = xstrdup(name); - a->kind = TKIND_ALIAS; - a->attrs = NULL; - a->declarray = FALSE; - init_loc_info(&a->loc_info); - - return a; -} - int is_ptr(const type_t *t) { unsigned char c = t->type; @@ -148,12 +124,19 @@ static unsigned short builtin_vt(const type_t *t) return kwp->vt; } if (is_string_type (t->attrs, t)) - switch (t->ref->type) + { + unsigned char fc; + if (is_array(t)) + fc = type_array_get_element(t)->type; + else + fc = type_pointer_get_ref(t)->type; + switch (fc) { case RPC_FC_CHAR: return VT_LPSTR; case RPC_FC_WCHAR: return VT_LPWSTR; default: break; } + } return 0; } @@ -173,7 +156,7 @@ unsigned short get_type_vt(type_t *t) if (vt) return vt; } - if (t->kind == TKIND_ALIAS && is_attr(t->attrs, ATTR_PUBLIC)) + if (type_is_alias(t) && is_attr(t->attrs, ATTR_PUBLIC)) return VT_USERDEFINED; switch (t->type) { @@ -207,8 +190,13 @@ unsigned short get_type_vt(type_t *t) case RPC_FC_UP: case RPC_FC_OP: case RPC_FC_FP: + case RPC_FC_SMFARRAY: + case RPC_FC_LGFARRAY: + case RPC_FC_SMVARRAY: + case RPC_FC_LGVARRAY: case RPC_FC_CARRAY: case RPC_FC_CVARRAY: + case RPC_FC_BOGUS_ARRAY: if(t->ref) { if (match(t->ref->name, "SAFEARRAY")) @@ -233,9 +221,10 @@ unsigned short get_type_vt(type_t *t) case RPC_FC_CVSTRUCT: case RPC_FC_BOGUS_STRUCT: case RPC_FC_COCLASS: + case RPC_FC_MODULE: return VT_USERDEFINED; case 0: - return t->kind == TKIND_PRIMITIVE ? VT_VOID : VT_USERDEFINED; + return VT_VOID; default: error("get_type_vt: unknown type: 0x%02x\n", t->type); } diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 2b56bb8e6ff..5591ce6de21 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -29,11 +29,23 @@ #include "typetree.h" #include "header.h" +type_t *duptype(type_t *t, int dupname) +{ + type_t *d = alloc_type(); + + *d = *t; + if (dupname && t->name) + d->name = xstrdup(t->name); + + return d; +} + type_t *type_new_function(var_list_t *args) { type_t *t = make_type(RPC_FC_FUNCTION, NULL); t->details.function = xmalloc(sizeof(*t->details.function)); t->details.function->args = args; + t->details.function->idx = -1; return t; } @@ -44,22 +56,61 @@ type_t *type_new_pointer(type_t *ref, attr_list_t *attrs) return t; } +type_t *type_new_alias(type_t *t, const char *name) +{ + type_t *a = duptype(t, 0); + + a->name = xstrdup(name); + a->attrs = NULL; + a->declarray = FALSE; + a->orig = t; + a->is_alias = TRUE; + init_loc_info(&a->loc_info); + + return a; +} + +type_t *type_new_module(char *name) +{ + type_t *type = make_type(RPC_FC_MODULE, NULL); + type->name = name; + /* FIXME: register type to detect multiple definitions */ + return type; +} + +type_t *type_new_array(const char *name, type_t *element, int declarray, + unsigned long dim, expr_t *size_is, expr_t *length_is) +{ + type_t *t = make_type(RPC_FC_LGFARRAY, element); + if (name) t->name = xstrdup(name); + t->declarray = declarray; + t->details.array.length_is = length_is; + if (size_is) + t->details.array.size_is = size_is; + else + t->details.array.dim = dim; + return t; +} + static int compute_method_indexes(type_t *iface) { int idx; - func_t *f; + statement_t *stmt; + + if (!iface->details.iface) + return 0; - if (iface->ref) - idx = compute_method_indexes(iface->ref); + if (type_iface_get_inherit(iface)) + idx = compute_method_indexes(type_iface_get_inherit(iface)); else idx = 0; - if (!iface->funcs) - return idx; - - LIST_FOR_EACH_ENTRY( f, iface->funcs, func_t, entry ) - if (! is_callas(f->def->attrs)) - f->idx = idx++; + STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) ) + { + var_t *func = stmt->u.var; + if (!is_callas(func->attrs)) + func->type->details.function->idx = idx++; + } return idx; } @@ -68,12 +119,10 @@ void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stm { iface->ref = inherit; iface->details.iface = xmalloc(sizeof(*iface->details.iface)); - iface->funcs = gen_function_list(stmts); iface->details.iface->disp_props = NULL; iface->details.iface->disp_methods = NULL; - iface->stmts = stmts; + iface->details.iface->stmts = stmts; iface->defined = TRUE; - check_functions(iface); compute_method_indexes(iface); } @@ -82,12 +131,10 @@ void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *me iface->ref = find_type("IDispatch", 0); if (!iface->ref) error_loc("IDispatch is undefined\n"); iface->details.iface = xmalloc(sizeof(*iface->details.iface)); - iface->funcs = NULL; iface->details.iface->disp_props = props; iface->details.iface->disp_methods = methods; - iface->stmts = NULL; + iface->details.iface->stmts = NULL; iface->defined = TRUE; - check_functions(iface); compute_method_indexes(iface); } @@ -96,3 +143,18 @@ void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface) type_dispinterface_define(dispiface, iface->details.iface->disp_props, iface->details.iface->disp_methods); } + +void type_module_define(type_t *module, statement_list_t *stmts) +{ + if (module->details.module) error_loc("multiple definition error\n"); + module->details.module = xmalloc(sizeof(*module->details.module)); + module->details.module->stmts = stmts; + module->defined = TRUE; +} + +type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces) +{ + coclass->details.coclass.ifaces = ifaces; + coclass->defined = TRUE; + return coclass; +} diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 99c0d2f911d..8efc62bd996 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -26,9 +26,18 @@ type_t *type_new_function(var_list_t *args); type_t *type_new_pointer(type_t *ref, attr_list_t *attrs); +type_t *type_new_alias(type_t *t, const char *name); +type_t *type_new_module(char *name); +type_t *type_new_array(const char *name, type_t *element, int declarray, + unsigned long dim, expr_t *size_is, expr_t *length_is); void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts); void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods); void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface); +void type_module_define(type_t *module, statement_list_t *stmts); +type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces); + +/* FIXME: shouldn't need to export this */ +type_t *duptype(type_t *t, int dupname); static inline var_list_t *type_struct_get_fields(const type_t *type) { @@ -42,6 +51,12 @@ static inline var_list_t *type_function_get_args(const type_t *type) return type->details.function->args; } +static inline type_t *type_function_get_rettype(const type_t *type) +{ + assert(type->type == RPC_FC_FUNCTION); + return type->ref; +} + static inline var_list_t *type_enum_get_values(const type_t *type) { assert(type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32); @@ -73,6 +88,18 @@ static inline var_list_t *type_union_get_cases(const type_t *type) return type->details.structure->fields; } +static inline statement_list_t *type_iface_get_stmts(const type_t *type) +{ + assert(type->type == RPC_FC_IP); + return type->details.iface->stmts; +} + +static inline type_t *type_iface_get_inherit(const type_t *type) +{ + assert(type->type == RPC_FC_IP); + return type->ref; +} + static inline var_list_t *type_dispiface_get_props(const type_t *type) { assert(type->type == RPC_FC_IP); @@ -104,4 +131,65 @@ static inline int type_is_complete(const type_t *type) return TRUE; } +static inline int type_array_has_conformance(const type_t *type) +{ + assert(is_array(type)); + return (type->details.array.size_is != NULL); +} + +static inline int type_array_has_variance(const type_t *type) +{ + assert(is_array(type)); + return (type->details.array.length_is != NULL); +} + +static inline unsigned long type_array_get_dim(const type_t *type) +{ + assert(is_array(type)); + return type->details.array.dim; +} + +static inline expr_t *type_array_get_conformance(const type_t *type) +{ + assert(is_array(type)); + return type->details.array.size_is; +} + +static inline expr_t *type_array_get_variance(const type_t *type) +{ + assert(is_array(type)); + return type->details.array.length_is; +} + +static inline type_t *type_array_get_element(const type_t *type) +{ + assert(is_array(type)); + return type->ref; +} + +static inline type_t *type_get_real_type(const type_t *type) +{ + if (type->is_alias) + return type_get_real_type(type->orig); + else + return (type_t *)type; +} + +static inline int type_is_alias(const type_t *type) +{ + return type->is_alias; +} + +static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type) +{ + assert(type->type == RPC_FC_COCLASS); + return type->details.coclass.ifaces; +} + +static inline type_t *type_pointer_get_ref(const type_t *type) +{ + assert(is_ptr(type)); + return type->ref; +} + #endif /* WIDL_TYPE_TREE_H */ diff --git a/tools/widl/utils.c b/tools/widl/utils.c index 2e05addeb7a..65477742acf 100644 --- a/tools/widl/utils.c +++ b/tools/widl/utils.c @@ -71,7 +71,7 @@ void error_loc(const char *s, ...) loc_info_t cur_loc = CURRENT_LOCATION; va_list ap; va_start(ap, s); - generic_msg(&cur_loc, s, "Error", ap); + generic_msg(&cur_loc, s, "error", ap); va_end(ap); exit(1); } @@ -86,7 +86,7 @@ void error_loc_info(const loc_info_t *loc_info, const char *s, ...) { va_list ap; va_start(ap, s); - generic_msg(loc_info, s, "Error", ap); + generic_msg(loc_info, s, "error", ap); va_end(ap); exit(1); } @@ -96,7 +96,7 @@ int parser_warning(const char *s, ...) loc_info_t cur_loc = CURRENT_LOCATION; va_list ap; va_start(ap, s); - generic_msg(&cur_loc, s, "Warning", ap); + generic_msg(&cur_loc, s, "warning", ap); va_end(ap); return 0; } @@ -124,7 +124,7 @@ void warning_loc_info(const loc_info_t *loc_info, const char *s, ...) { va_list ap; va_start(ap, s); - generic_msg(loc_info, s, "Warning", ap); + generic_msg(loc_info, s, "warning", ap); va_end(ap); } diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 2ae856c827e..fe8c25045bc 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -35,6 +35,7 @@ typedef GUID UUID; #define TRUE 1 #define FALSE 0 +#define RPC_FC_MODULE 0xfc #define RPC_FC_COCLASS 0xfd #define RPC_FC_FUNCTION 0xfe @@ -273,17 +274,35 @@ struct enumeration_details struct func_details { var_list_t *args; + int idx; }; struct iface_details { + statement_list_t *stmts; func_list_t *disp_methods; var_list_t *disp_props; }; +struct module_details +{ + statement_list_t *stmts; + func_list_t *funcs; +}; + +struct array_details +{ + unsigned long dim; + expr_t *size_is, *length_is; +}; + +struct coclass_details +{ + ifref_list_t *ifaces; +}; + struct _type_t { const char *name; - enum type_kind kind; unsigned char type; struct _type_t *ref; attr_list_t *attrs; @@ -293,12 +312,10 @@ struct _type_t { struct enumeration_details *enumeration; struct func_details *function; struct iface_details *iface; + struct module_details *module; + struct array_details array; + struct coclass_details coclass; } details; - func_list_t *funcs; /* interfaces and modules */ - statement_list_t *stmts; /* interfaces and modules */ - ifref_list_t *ifaces; /* coclasses */ - unsigned long dim; /* array dimension */ - expr_t *size_is, *length_is; type_t *orig; /* dup'd types */ unsigned int typestring_offset; unsigned int ptrdesc; /* used for complex structs */ @@ -311,6 +328,7 @@ struct _type_t { unsigned int user_types_registered : 1; unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */ unsigned int checked : 1; + unsigned int is_alias : 1; /* is the type an alias? */ int sign : 2; }; @@ -339,8 +357,6 @@ struct _declarator_t { struct _func_t { var_t *def; - var_list_t *args; - int idx; /* parser-internal */ struct list entry; @@ -426,9 +442,6 @@ type_t *alloc_type(void); void set_all_tfswrite(int val); void clear_all_offsets(void); -type_t *duptype(type_t *t, int dupname); -type_t *alias(type_t *t, const char *name); - int is_ptr(const type_t *t); int is_array(const type_t *t); int is_var_ptr(const var_t *v); @@ -442,9 +455,26 @@ type_t *make_type(unsigned char type, type_t *ref); void init_loc_info(loc_info_t *); -static inline type_t *get_func_return_type(const func_t *func) +static inline var_list_t *type_get_function_args(const type_t *func_type) { - return func->def->type->ref; + return func_type->details.function->args; +} + +#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \ + if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \ + if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \ + stmt->u.var->type->type == RPC_FC_FUNCTION) + +static inline int statements_has_func(const statement_list_t *stmts) +{ + const statement_t *stmt; + int has_func = 0; + STATEMENTS_FOR_EACH_FUNC(stmt, stmts) + { + has_func = 1; + break; + } + return has_func; } #endif diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index fd237dcfc17..04195ff4a08 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -876,8 +876,8 @@ static int encode_type( case VT_PTR: { int next_vt; - for(next_vt = 0; type->ref; type = type->ref) { - next_vt = get_type_vt(type->ref); + for(next_vt = 0; is_ptr(type); type = type_pointer_get_ref(type)) { + next_vt = get_type_vt(type_pointer_get_ref(type)); if (next_vt != 0) break; } @@ -885,7 +885,8 @@ static int encode_type( if (next_vt == 0) next_vt = VT_VOID; - encode_type(typelib, next_vt, type->ref, &target_type, NULL, NULL, &child_size); + encode_type(typelib, next_vt, type_pointer_get_ref(type), + &target_type, NULL, NULL, &child_size); /* these types already have an implicit pointer, so we don't need to * add another */ if(next_vt == VT_DISPATCH || next_vt == VT_UNKNOWN) { @@ -979,7 +980,7 @@ static int encode_type( int typeinfo_offset; /* typedef'd types without public attribute aren't included in the typelib */ - while (type->typelib_idx < 0 && type->kind == TKIND_ALIAS && !is_attr(type->attrs, ATTR_PUBLIC)) + while (type->typelib_idx < 0 && type_is_alias(type) && !is_attr(type->attrs, ATTR_PUBLIC)) type = type->orig; chat("encode_type: VT_USERDEFINED - type %p name = %s type->type %d idx %d\n", type, @@ -1080,7 +1081,7 @@ static int encode_var( int *arraydata; num_dims = 0; - for (atype = type; atype->declarray; atype = atype->ref) + for (atype = type; atype->declarray; atype = type_array_get_element(atype)) ++num_dims; chat("array with %d dimensions\n", num_dims); @@ -1093,12 +1094,12 @@ static int encode_var( arraydata[1] |= ((num_dims * 2 * sizeof(long)) << 16); arraydata += 2; - for (atype = type; atype->declarray; atype = atype->ref) + for (atype = type; atype->declarray; atype = type_array_get_element(atype)) { - arraydata[0] = atype->dim; + arraydata[0] = type_array_get_dim(atype); arraydata[1] = 0; arraydata += 2; - elements *= atype->dim; + elements *= type_array_get_dim(atype); } typeoffset = ctl2_alloc_segment(typelib, MSFT_SEG_TYPEDESC, 8, 0); @@ -1115,7 +1116,10 @@ static int encode_var( vt = get_type_vt(type); if (vt == VT_PTR) { - int skip_ptr = encode_var(typelib, type->ref, var, &target_type, NULL, NULL, &child_size); + type_t *ref = is_ptr(type) ? + type_pointer_get_ref(type) : type_array_get_element(type); + int skip_ptr = encode_var(typelib, ref, var, + &target_type, NULL, NULL, &child_size); if(skip_ptr == 2) { chat("encode_var: skipping ptr\n"); @@ -1261,7 +1265,7 @@ static HRESULT set_custdata(msft_typelib_t *typelib, REFGUID guid, return S_OK; } -static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int index) +static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index) { int offset, name_offset; int *typedata, typedata_size; @@ -1292,13 +1296,13 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int break; } - if (is_local( func->def->attrs )) { + if (is_local( func->attrs )) { chat("add_func_desc: skipping local function\n"); return S_FALSE; } - if (func->args) - LIST_FOR_EACH_ENTRY( arg, func->args, var_t, entry ) + if (type_get_function_args(func->type)) + LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), var_t, entry ) { num_params++; if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) { @@ -1311,9 +1315,9 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int chat("add_func_desc: num of params %d\n", num_params); - name_offset = ctl2_alloc_name(typeinfo->typelib, func->def->name); + name_offset = ctl2_alloc_name(typeinfo->typelib, func->name); - if (func->def->attrs) LIST_FOR_EACH_ENTRY( attr, func->def->attrs, const attr_t, entry ) { + if (func->attrs) LIST_FOR_EACH_ENTRY( attr, func->attrs, const attr_t, entry ) { expr_t *expr = attr->u.pval; switch(attr->type) { case ATTR_BINDABLE: @@ -1434,7 +1438,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int /* fill out the basic type information */ typedata[0] = typedata_size | (index << 16); - encode_var(typeinfo->typelib, get_func_return_type(func), func->def, &typedata[1], NULL, NULL, &decoded_size); + encode_var(typeinfo->typelib, type_function_get_rettype(func->type), func, &typedata[1], NULL, NULL, &decoded_size); typedata[2] = funcflags; typedata[3] = ((52 /*sizeof(FUNCDESC)*/ + decoded_size) << 16) | typeinfo->typeinfo->cbSizeVft; typedata[4] = (next_idx << 16) | (callconv << 8) | (invokekind << 3) | funckind; @@ -1460,10 +1464,10 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int warning("unknown number of optional attrs\n"); } - if (func->args) + if (type_get_function_args(func->type)) { i = 0; - LIST_FOR_EACH_ENTRY( arg, func->args, var_t, entry ) + LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), var_t, entry ) { int paramflags = 0; int *paramdata = typedata + 6 + extra_attr + (num_defaults ? num_params : 0) + i * 3; @@ -1567,10 +1571,10 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int if(typeinfo->typekind == TKIND_MODULE) namedata[9] |= 0x20; - if (func->args) + if (type_get_function_args(func->type)) { i = 0; - LIST_FOR_EACH_ENTRY( arg, func->args, var_t, entry ) + LIST_FOR_EACH_ENTRY( arg, type_get_function_args(func->type), var_t, entry ) { /* don't give the last arg of a [propput*] func a name */ if(i != num_params - 1 || (invokekind != 0x4 /* INVOKE_PROPERTYPUT */ && invokekind != 0x8 /* INVOKE_PROPERTYPUTREF */)) @@ -1965,9 +1969,10 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte add_dispatch(typelib); msft_typeinfo->typeinfo->cImplTypes = 1; - /* count the no of funcs, as the variable indices come after the funcs */ - if (dispinterface->funcs) - LIST_FOR_EACH_ENTRY( func, dispinterface->funcs, const func_t, entry ) idx++; + /* count the no of methods, as the variable indices come after the funcs */ + if (dispinterface->details.iface->disp_methods) + LIST_FOR_EACH_ENTRY( func, dispinterface->details.iface->disp_methods, const func_t, entry ) + idx++; if (type_dispiface_get_props(dispinterface)) LIST_FOR_EACH_ENTRY( var, type_dispiface_get_props(dispinterface), var_t, entry ) @@ -1977,7 +1982,7 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte { idx = 0; LIST_FOR_EACH_ENTRY( func, type_dispiface_get_methods(dispinterface), const func_t, entry ) - if(add_func_desc(msft_typeinfo, func, idx) == S_OK) + if(add_func_desc(msft_typeinfo, func->def, idx) == S_OK) idx++; } } @@ -1985,11 +1990,12 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) { int idx = 0; - const func_t *func; + const statement_t *stmt_func; type_t *ref; msft_typeinfo_t *msft_typeinfo; importinfo_t *ref_importinfo = NULL; int num_parents = 0, num_funcs = 0; + type_t *inherit; const type_t *derived; if (-1 < interface->typelib_idx) @@ -2001,11 +2007,14 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) /* midl adds the parent interface first, unless the parent itself has no parent (i.e. it stops before IUnknown). */ - if(interface->ref) { - ref_importinfo = find_importinfo(typelib, interface->ref->name); + inherit = type_iface_get_inherit(interface); + + if(inherit) { + ref_importinfo = find_importinfo(typelib, inherit->name); - if(!ref_importinfo && interface->ref->ref && interface->ref->typelib_idx == -1) - add_interface_typeinfo(typelib, interface->ref); + if(!ref_importinfo && type_iface_get_inherit(inherit) && + inherit->typelib_idx == -1) + add_interface_typeinfo(typelib, inherit); } interface->typelib_idx = typelib->typelib_header.nrtypeinfos; @@ -2013,7 +2022,7 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) msft_typeinfo->typeinfo->size = 4; msft_typeinfo->typeinfo->typekind |= 0x2200; - for (derived = interface->ref; derived; derived = derived->ref) + for (derived = inherit; derived; derived = type_iface_get_inherit(derived)) if (derived->name && !strcmp(derived->name, "IDispatch")) msft_typeinfo->typeinfo->flags |= 0x1000; /* TYPEFLAG_FDISPATCHABLE */ @@ -2021,23 +2030,26 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) if (!(msft_typeinfo->typeinfo->flags & 0x1000)) /* TYPEFLAG_FDISPATCHABLE */ msft_typeinfo->typeinfo->flags &= ~0x40; /* TYPEFLAG_FDUAL */ - if(interface->ref) - add_impl_type(msft_typeinfo, interface->ref, ref_importinfo); + if(type_iface_get_inherit(interface)) + add_impl_type(msft_typeinfo, type_iface_get_inherit(interface), + ref_importinfo); /* count the number of inherited interfaces and non-local functions */ - for(ref = interface->ref; ref; ref = ref->ref) { + for(ref = inherit; ref; ref = type_iface_get_inherit(ref)) { num_parents++; - if (ref->funcs) - LIST_FOR_EACH_ENTRY( func, ref->funcs, const func_t, entry ) - if (!is_local(func->def->attrs)) num_funcs++; + STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(ref) ) { + var_t *func = stmt_func->u.var; + if (!is_local(func->attrs)) num_funcs++; + } } msft_typeinfo->typeinfo->datatype2 = num_funcs << 16 | num_parents; msft_typeinfo->typeinfo->cbSizeVft = num_funcs * 4; - if (interface->funcs) - LIST_FOR_EACH_ENTRY( func, interface->funcs, const func_t, entry ) - if(add_func_desc(msft_typeinfo, func, idx) == S_OK) - idx++; + STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(interface) ) { + var_t *func = stmt_func->u.var; + if(add_func_desc(msft_typeinfo, func, idx) == S_OK) + idx++; + } } static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure) @@ -2096,6 +2108,7 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls) MSFT_RefRecord *ref, *first = NULL, *first_source = NULL; int have_default = 0, have_default_source = 0; const attr_t *attr; + ifref_list_t *ifaces; if (-1 < cls->typelib_idx) return; @@ -2103,13 +2116,14 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls) cls->typelib_idx = typelib->typelib_header.nrtypeinfos; msft_typeinfo = create_msft_typeinfo(typelib, TKIND_COCLASS, cls->name, cls->attrs); - if (cls->ifaces) LIST_FOR_EACH_ENTRY( iref, cls->ifaces, ifref_t, entry ) num_ifaces++; + ifaces = type_coclass_get_ifaces(cls); + if (ifaces) LIST_FOR_EACH_ENTRY( iref, ifaces, ifref_t, entry ) num_ifaces++; offset = msft_typeinfo->typeinfo->datatype1 = ctl2_alloc_segment(typelib, MSFT_SEG_REFERENCES, num_ifaces * sizeof(*ref), 0); i = 0; - if (cls->ifaces) LIST_FOR_EACH_ENTRY( iref, cls->ifaces, ifref_t, entry ) { + if (ifaces) LIST_FOR_EACH_ENTRY( iref, ifaces, ifref_t, entry ) { if(iref->iface->typelib_idx == -1) add_interface_typeinfo(typelib, iref->iface); ref = (MSFT_RefRecord*) (typelib->typelib_segment_data[MSFT_SEG_REFERENCES] + offset + i * sizeof(*ref)); @@ -2173,7 +2187,7 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls) static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module) { int idx = 0; - const func_t *func; + const statement_t *stmt; msft_typeinfo_t *msft_typeinfo; if (-1 < module->typelib_idx) @@ -2183,34 +2197,53 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module) msft_typeinfo = create_msft_typeinfo(typelib, TKIND_MODULE, module->name, module->attrs); msft_typeinfo->typeinfo->typekind |= 0x0a00; - if (module->funcs) - LIST_FOR_EACH_ENTRY( func, module->funcs, const func_t, entry ) - if(add_func_desc(msft_typeinfo, func, idx) == S_OK) - idx++; + STATEMENTS_FOR_EACH_FUNC( stmt, module->details.module->stmts ) { + var_t *func = stmt->u.var; + if(add_func_desc(msft_typeinfo, func, idx) == S_OK) + idx++; + } msft_typeinfo->typeinfo->size = idx; } static void add_type_typeinfo(msft_typelib_t *typelib, type_t *type) { - switch (type->kind) { - case TKIND_INTERFACE: - case TKIND_DISPATCH: + switch (type->type) { + case RPC_FC_IP: add_interface_typeinfo(typelib, type); break; - case TKIND_RECORD: + case RPC_FC_STRUCT: add_structure_typeinfo(typelib, type); break; - case TKIND_ENUM: + case RPC_FC_ENUM16: + case RPC_FC_ENUM32: add_enum_typeinfo(typelib, type); break; - case TKIND_COCLASS: + case RPC_FC_COCLASS: add_coclass_typeinfo(typelib, type); break; - case TKIND_PRIMITIVE: + case RPC_FC_BYTE: + case RPC_FC_CHAR: + case RPC_FC_USMALL: + case RPC_FC_SMALL: + case RPC_FC_WCHAR: + case RPC_FC_USHORT: + case RPC_FC_SHORT: + case RPC_FC_ULONG: + case RPC_FC_LONG: + case RPC_FC_HYPER: + case RPC_FC_IGNORE: + case RPC_FC_FLOAT: + case RPC_FC_DOUBLE: + case RPC_FC_ERROR_STATUS_T: + case RPC_FC_BIND_PRIMITIVE: + case RPC_FC_RP: + case RPC_FC_UP: + case RPC_FC_OP: + case RPC_FC_FP: break; default: - error("add_entry: unhandled type %d for %s\n", type->kind, type->name); + error("add_entry: unhandled type 0x%x for %s\n", type->type, type->name); break; } } diff --git a/tools/wine.desktop b/tools/wine.desktop index fe8f1e30851..0d69cc81755 100644 --- a/tools/wine.desktop +++ b/tools/wine.desktop @@ -18,3 +18,4 @@ Name[nn]=Wine Programlaster for Windowsapplikasjoner Exec=wine start /unix %f MimeType=application/x-ms-dos-executable;application/x-msdos-program;application/x-msdownload;application/exe;application/x-exe;application/dos-exe;vms/exe;application/x-winexe;application/msdos-windows;application/x-zip-compressed;application/x-executable;application/x-msi; NoDisplay=true +StartupNotify=true diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c index a1c7970520f..8b08cde8bea 100644 --- a/tools/winebuild/relay.c +++ b/tools/winebuild/relay.c @@ -741,9 +741,10 @@ static void BuildCallTo32CBClient( BOOL isEx ) * * Stack layout: * ... - * (ebp+16) first arg - * (ebp+12) ret addr to user code - * (ebp+8) eax saved by relay code + * (ebp+20) first arg + * (ebp+16) ret addr to user code + * (ebp+12) func to call (relative to relay code ret addr) + * (ebp+8) number of args * (ebp+4) ret addr to relay code * (ebp+0) saved ebp * (ebp-128) buffer area to allow stack frame manipulation @@ -770,17 +771,16 @@ static void BuildCallFrom32Regs(void) output( "\tpushl %%ebp\n" ); output( "\tmovl %%esp,%%ebp\n "); - output( "\tleal -%d(%%esp), %%esp\n", STACK_SPACE + 4 /* for context arg */); + output( "\tleal -%d(%%esp),%%esp\n", STACK_SPACE ); /* Build the context structure */ + output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Eax) - STACK_SPACE ); output( "\tpushfl\n" ); output( "\tpopl %%eax\n" ); output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(EFlags) - STACK_SPACE ); output( "\tmovl 0(%%ebp),%%eax\n" ); output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Ebp) - STACK_SPACE ); - output( "\tmovl 8(%%ebp),%%eax\n" ); - output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Eax) - STACK_SPACE ); output( "\tmovl %%ebx,%d(%%ebp)\n", CONTEXTOFFSET(Ebx) - STACK_SPACE ); output( "\tmovl %%ecx,%d(%%ebp)\n", CONTEXTOFFSET(Ecx) - STACK_SPACE ); output( "\tmovl %%edx,%d(%%ebp)\n", CONTEXTOFFSET(Edx) - STACK_SPACE ); @@ -805,31 +805,30 @@ static void BuildCallFrom32Regs(void) output( "\tmovl $0x%x,%%eax\n", CONTEXT86_FULL ); output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(ContextFlags) - STACK_SPACE ); - output( "\tmovl 12(%%ebp),%%eax\n" ); /* Get %eip at time of call */ + output( "\tmovl 16(%%ebp),%%eax\n" ); /* Get %eip at time of call */ output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Eip) - STACK_SPACE ); /* Transfer the arguments */ - output( "\tmovl 4(%%ebp),%%ebx\n" ); /* get relay code addr */ - output( "\tmovzbl 4(%%ebx),%%ecx\n" ); /* fetch number of args to copy */ - output( "\tsubl %%ecx,%%esp\n" ); + output( "\tmovl 8(%%ebp),%%ecx\n" ); /* fetch number of args to copy */ + output( "\tleal 4(,%%ecx,4),%%edx\n" ); /* add 4 for context arg */ + output( "\tsubl %%edx,%%esp\n" ); output( "\tandl $~15,%%esp\n" ); - output( "\tleal 16(%%ebp),%%esi\n" ); /* get %esp at time of call */ + output( "\tleal 20(%%ebp),%%esi\n" ); /* get %esp at time of call */ output( "\tmovl %%esp,%%edi\n" ); - output( "\tshrl $2,%%ecx\n" ); + output( "\ttest %%ecx,%%ecx\n" ); output( "\tjz 1f\n" ); output( "\tcld\n" ); output( "\trep\n\tmovsl\n" ); /* copy args */ output( "1:\tleal %d(%%ebp),%%eax\n", -STACK_SPACE ); /* get addr of context struct */ output( "\tmovl %%eax,(%%edi)\n" ); /* and pass it as extra arg */ - output( "\tmovzbl 5(%%ebx),%%eax\n" ); /* fetch number of args to remove */ - output( "\tleal 16(%%ebp,%%eax),%%eax\n" ); - output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Esp) - STACK_SPACE ); + output( "\tmovl %%esi,%d(%%ebp)\n", CONTEXTOFFSET(Esp) - STACK_SPACE ); /* Call the entry point */ - output( "\taddl (%%ebx),%%ebx\n" ); - output( "\tcall *%%ebx\n" ); + output( "\tmovl 4(%%ebp),%%eax\n" ); /* get relay code addr */ + output( "\taddl 12(%%ebp),%%eax\n" ); + output( "\tcall *%%eax\n" ); output( "\tleal -%d(%%ebp),%%ecx\n", STACK_SPACE ); /* Restore the context structure */ @@ -984,6 +983,173 @@ void BuildRelays16(void) output_gnu_stack_note(); } + +/******************************************************************* + * build_call_from_regs_x86_64 + * + * Build the register saving code for a 'register' entry point. + * + * Stack layout: + * ... + * (rsp+16) first arg + * (rsp+8) ret addr to user code + * (rsp) ret addr to relay code + * (rsp-128) buffer area to allow stack frame manipulation + * + * Parameters: + * %rcx number of args + * %rdx entry point + */ +static void build_call_from_regs_x86_64(void) +{ + static const int STACK_SPACE = 128 + 0x4d0; /* size of x86_64 context */ + + /* Function header */ + + function_header( "__wine_call_from_regs" ); + + output( "\tsubq $%u,%%rsp\n", STACK_SPACE ); + + /* save registers into the context */ + + output( "\tmovq %%rax,0x78(%%rsp)\n" ); + output( "\tmovq %u(%%rsp),%%rax\n", STACK_SPACE + 16 ); /* saved %rcx on stack */ + output( "\tmovq %%rax,0x80(%%rsp)\n" ); + output( "\tmovq %u(%%rsp),%%rax\n", STACK_SPACE + 24 ); /* saved %rdx on stack */ + output( "\tmovq %%rax,0x88(%%rsp)\n" ); + output( "\tmovq %%rbx,0x90(%%rsp)\n" ); + output( "\tleaq %u(%%rsp),%%rax\n", STACK_SPACE + 16 ); + output( "\tmovq %%rax,0x98(%%rsp)\n" ); + output( "\tmovq %%rbp,0xa0(%%rsp)\n" ); + output( "\tmovq %%rsi,0xa8(%%rsp)\n" ); + output( "\tmovq %%rdi,0xb0(%%rsp)\n" ); + output( "\tmovq %%r8,0xb8(%%rsp)\n" ); + output( "\tmovq %%r9,0xc0(%%rsp)\n" ); + output( "\tmovq %%r10,0xc8(%%rsp)\n" ); + output( "\tmovq %%r11,0xd0(%%rsp)\n" ); + output( "\tmovq %%r12,0xd8(%%rsp)\n" ); + output( "\tmovq %%r13,0xe0(%%rsp)\n" ); + output( "\tmovq %%r14,0xe8(%%rsp)\n" ); + output( "\tmovq %%r15,0xf0(%%rsp)\n" ); + output( "\tmovq %u(%%rsp),%%rax\n", STACK_SPACE + 8 ); + output( "\tmovq %%rax,0xf8(%%rsp)\n" ); + + output( "\tstmxcsr 0x34(%%rsp)\n" ); + output( "\tfxsave 0x100(%%rsp)\n" ); + output( "\tmovdqa %%xmm0,0x1a0(%%rsp)\n" ); + output( "\tmovdqa %%xmm1,0x1b0(%%rsp)\n" ); + output( "\tmovdqa %%xmm2,0x1c0(%%rsp)\n" ); + output( "\tmovdqa %%xmm3,0x1d0(%%rsp)\n" ); + output( "\tmovdqa %%xmm4,0x1e0(%%rsp)\n" ); + output( "\tmovdqa %%xmm5,0x1f0(%%rsp)\n" ); + output( "\tmovdqa %%xmm6,0x200(%%rsp)\n" ); + output( "\tmovdqa %%xmm7,0x210(%%rsp)\n" ); + output( "\tmovdqa %%xmm8,0x220(%%rsp)\n" ); + output( "\tmovdqa %%xmm9,0x230(%%rsp)\n" ); + output( "\tmovdqa %%xmm10,0x240(%%rsp)\n" ); + output( "\tmovdqa %%xmm11,0x250(%%rsp)\n" ); + output( "\tmovdqa %%xmm12,0x260(%%rsp)\n" ); + output( "\tmovdqa %%xmm13,0x270(%%rsp)\n" ); + output( "\tmovdqa %%xmm14,0x280(%%rsp)\n" ); + output( "\tmovdqa %%xmm15,0x290(%%rsp)\n" ); + + output( "\tmovw %%cs,0x38(%%rsp)\n" ); + output( "\tmovw %%ds,0x3a(%%rsp)\n" ); + output( "\tmovw %%es,0x3c(%%rsp)\n" ); + output( "\tmovw %%fs,0x3e(%%rsp)\n" ); + output( "\tmovw %%gs,0x40(%%rsp)\n" ); + output( "\tmovw %%ss,0x42(%%rsp)\n" ); + output( "\tpushfq\n" ); + output( "\tpopq %%rax\n" ); + output( "\tmovl %%eax,0x44(%%rsp)\n" ); + + output( "\tmovl $0x%x,0x30(%%rsp)\n", 0x0010000f ); + + /* transfer the arguments */ + + output( "\tmovq %%r8,%u(%%rsp)\n", STACK_SPACE + 32 ); + output( "\tmovq %%r9,%u(%%rsp)\n", STACK_SPACE + 40 ); + output( "\tmovq $4,%%rax\n" ); + output( "\tleaq %u(%%rsp),%%rsi\n", STACK_SPACE + 16 ); + output( "\tcmpq %%rax,%%rcx\n" ); + output( "\tcmovgq %%rcx,%%rax\n" ); + output( "\tmovq %%rsp,%%rbx\n" ); + output( "\tleaq 16(,%%rax,8),%%rax\n" ); /* add 8 for context arg and 8 for rounding */ + output( "\tandq $~15,%%rax\n" ); + output( "\tsubq %%rax,%%rsp\n" ); + output( "\tmovq %%rsp,%%rdi\n" ); + output( "\tjrcxz 1f\n" ); + output( "\tcld\n" ); + output( "\trep\n\tmovsq\n" ); + output( "1:\tmovq %%rbx,0(%%rdi)\n" ); /* context arg */ + + /* call the entry point */ + + output( "\tmovq %%rdx,%%rax\n" ); + output( "\tmovq 0(%%rsp),%%rcx\n" ); + output( "\tmovq 8(%%rsp),%%rdx\n" ); + output( "\tmovq 16(%%rsp),%%r8\n" ); + output( "\tmovq 24(%%rsp),%%r9\n" ); + output( "\tcallq *%%rax\n" ); + + /* restore the context structure */ + + output( "1:\tmovq 0x80(%%rbx),%%rcx\n" ); + output( "\tmovq 0x88(%%rbx),%%rdx\n" ); + output( "\tmovq 0xa0(%%rbx),%%rbp\n" ); + output( "\tmovq 0xa8(%%rbx),%%rsi\n" ); + output( "\tmovq 0xb0(%%rbx),%%rdi\n" ); + output( "\tmovq 0xb8(%%rbx),%%r8\n" ); + output( "\tmovq 0xc0(%%rbx),%%r9\n" ); + output( "\tmovq 0xc8(%%rbx),%%r10\n" ); + output( "\tmovq 0xd0(%%rbx),%%r11\n" ); + output( "\tmovq 0xd8(%%rbx),%%r12\n" ); + output( "\tmovq 0xe0(%%rbx),%%r13\n" ); + output( "\tmovq 0xe8(%%rbx),%%r14\n" ); + output( "\tmovq 0xf0(%%rbx),%%r15\n" ); + + output( "\tmovdqa 0x1a0(%%rbx),%%xmm0\n" ); + output( "\tmovdqa 0x1b0(%%rbx),%%xmm1\n" ); + output( "\tmovdqa 0x1c0(%%rbx),%%xmm2\n" ); + output( "\tmovdqa 0x1d0(%%rbx),%%xmm3\n" ); + output( "\tmovdqa 0x1e0(%%rbx),%%xmm4\n" ); + output( "\tmovdqa 0x1f0(%%rbx),%%xmm5\n" ); + output( "\tmovdqa 0x200(%%rbx),%%xmm6\n" ); + output( "\tmovdqa 0x210(%%rbx),%%xmm7\n" ); + output( "\tmovdqa 0x220(%%rbx),%%xmm8\n" ); + output( "\tmovdqa 0x230(%%rbx),%%xmm9\n" ); + output( "\tmovdqa 0x240(%%rbx),%%xmm10\n" ); + output( "\tmovdqa 0x250(%%rbx),%%xmm11\n" ); + output( "\tmovdqa 0x260(%%rbx),%%xmm12\n" ); + output( "\tmovdqa 0x270(%%rbx),%%xmm13\n" ); + output( "\tmovdqa 0x280(%%rbx),%%xmm14\n" ); + output( "\tmovdqa 0x290(%%rbx),%%xmm15\n" ); + output( "\tfxrstor 0x100(%%rbx)\n" ); + output( "\tldmxcsr 0x34(%%rbx)\n" ); + + output( "\tmovl 0x44(%%rbx),%%eax\n" ); + output( "\tpushq %%rax\n" ); + output( "\tpopfq\n" ); + + output( "\tmovq 0x98(%%rbx),%%rax\n" ); /* stack pointer */ + output( "\tpushq 0xf8(%%rbx)\n" ); /* return address */ + output( "\tpopq -8(%%rax)\n" ); + output( "\tpushq 0x78(%%rbx)\n" ); /* rax */ + output( "\tpopq -16(%%rax)\n" ); + output( "\tmovq 0x90(%%rbx),%%rbx\n" ); + output( "\tleaq -16(%%rax),%%rsp\n" ); + output( "\tpopq %%rax\n" ); + output( "\tret\n" ); + + output_function_size( "__wine_call_from_regs" ); + + function_header( "__wine_restore_regs" ); + output( "\tmovq %%rcx,%%rbx\n" ); + output( "\tjmp 1b\n" ); + output_function_size( "__wine_restore_regs" ); +} + + /******************************************************************* * BuildRelays32 * @@ -991,21 +1157,29 @@ void BuildRelays16(void) */ void BuildRelays32(void) { - if (target_cpu != CPU_x86) + switch (target_cpu) { + case CPU_x86: + output( "/* File generated automatically. Do not edit! */\n\n" ); + output( "\t.text\n" ); + output( "%s:\n\n", asm_name("__wine_spec_thunk_text_32") ); + + /* 32-bit register entry point */ + BuildCallFrom32Regs(); + + output_function_size( "__wine_spec_thunk_text_32" ); + output_gnu_stack_note(); + break; + + case CPU_x86_64: + output( "/* File generated automatically. Do not edit! */\n\n" ); + output( "\t.text\n" ); + build_call_from_regs_x86_64(); + output_gnu_stack_note(); + break; + + default: output( "/* File not used with this architecture. Do not edit! */\n\n" ); return; } - - /* File header */ - - output( "/* File generated automatically. Do not edit! */\n\n" ); - output( "\t.text\n" ); - output( "%s:\n\n", asm_name("__wine_spec_thunk_text_32") ); - - /* 32-bit register entry point */ - BuildCallFrom32Regs(); - - output_function_size( "__wine_spec_thunk_text_32" ); - output_gnu_stack_note(); } diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 9cf60c3f15c..583c422c566 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -137,7 +137,6 @@ static void output_relay_debug( DLLSPEC *spec ) output( "\tpushl %%esp\n" ); if (odp->flags & FLAG_RET64) flags |= 1; - if (odp->type == TYPE_STDCALL) flags |= 2; output( "\tpushl $%u\n", (flags << 24) | (args << 16) | (i - spec->base) ); if (UsePIC) @@ -171,7 +170,7 @@ static void output_relay_debug( DLLSPEC *spec ) output( "\tmovq $%u,%%rdx\n", (flags << 24) | (args << 16) | (i - spec->base) ); output( "\tleaq .L__wine_spec_relay_descr(%%rip),%%rcx\n" ); output( "\tsubq $40,%%rsp\n" ); - output( "\tcallq *8(%%rcx)\n" ); + output( "\tcallq *%u(%%rcx)\n", (odp->flags & FLAG_REGISTER) ? 16 : 8 ); output( "\taddq $40,%%rsp\n" ); output( "\tret\n" ); break; diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c index 31a744e7734..491228fcd9e 100644 --- a/tools/winedump/pe.c +++ b/tools/winedump/pe.c @@ -469,7 +469,7 @@ static void dump_dir_exported_functions(void) const DWORD* pFunc; const DWORD* pName; const WORD* pOrdl; - DWORD* map; + DWORD* funcs; if (!exportDir) return; @@ -496,37 +496,27 @@ static void dump_dir_exported_functions(void) pOrdl = RVA(exportDir->AddressOfNameOrdinals, exportDir->NumberOfNames * sizeof(WORD)); if (!pOrdl) {printf("Can't grab functions' ordinal table\n"); return;} - /* bit map of used funcs */ - map = calloc(((exportDir->NumberOfFunctions + 31) & ~31) / 32, sizeof(DWORD)); - if (!map) fatal("no memory"); + funcs = calloc( exportDir->NumberOfFunctions, sizeof(*funcs) ); + if (!funcs) fatal("no memory"); - for (i = 0; i < exportDir->NumberOfNames; i++, pName++, pOrdl++) - { - map[*pOrdl / 32] |= 1 << (*pOrdl % 32); + for (i = 0; i < exportDir->NumberOfNames; i++) funcs[pOrdl[i]] = pName[i]; - printf(" %08X %4u %s", pFunc[*pOrdl], exportDir->Base + *pOrdl, - get_symbol_str((const char*)RVA(*pName, sizeof(DWORD)))); - /* check for forwarded function */ - if ((const char *)RVA(pFunc[*pOrdl],sizeof(void*)) >= (const char *)exportDir && - (const char *)RVA(pFunc[*pOrdl],sizeof(void*)) < (const char *)exportDir + size) - printf( " (-> %s)", (const char *)RVA(pFunc[*pOrdl],1)); - printf("\n"); - } - pFunc = RVA(exportDir->AddressOfFunctions, exportDir->NumberOfFunctions * sizeof(DWORD)); - if (!pFunc) - { - printf("Can't grab functions' address table\n"); - free(map); - return; - } for (i = 0; i < exportDir->NumberOfFunctions; i++) { - if (pFunc[i] && !(map[i / 32] & (1 << (i % 32)))) - { - printf(" %08X %4u \n", pFunc[i], exportDir->Base + i); - } + if (!pFunc[i]) continue; + printf(" %08X %5u ", pFunc[i], exportDir->Base + i); + if (funcs[i]) + { + printf("%s", get_symbol_str((const char*)RVA(funcs[i], sizeof(DWORD)))); + /* check for forwarded function */ + if ((const char *)RVA(pFunc[i],1) >= (const char *)exportDir && + (const char *)RVA(pFunc[i],1) < (const char *)exportDir + size) + printf(" (-> %s)", (const char *)RVA(pFunc[i],1)); + printf("\n"); + } + else printf("\n"); } - free(map); + free(funcs); printf("\n"); } @@ -813,6 +803,52 @@ static void dump_dir_clr_header(void) printf("\n"); } +static void dump_dir_reloc(void) +{ + unsigned int i, size = 0; + const USHORT *relocs; + const IMAGE_BASE_RELOCATION *rel = get_dir_and_size(IMAGE_DIRECTORY_ENTRY_BASERELOC, &size); + const IMAGE_BASE_RELOCATION *end = (IMAGE_BASE_RELOCATION *)((char *)rel + size); + static const char * const names[] = + { + "BASED_ABSOLUTE", + "BASED_HIGH", + "BASED_LOW", + "BASED_HIGHLOW", + "BASED_HIGHADJ", + "BASED_MIPS_JMPADDR", + "BASED_SECTION", + "BASED_REL", + "unknown 8", + "BASED_IA64_IMM64", + "BASED_DIR64", + "BASED_HIGH3ADJ", + "unknown 12", + "unknown 13", + "unknown 14", + "unknown 15" + }; + + if (!rel) return; + + printf( "Relocations\n" ); + while (rel < end - 1 && rel->SizeOfBlock) + { + printf( " Page %x\n", rel->VirtualAddress ); + relocs = (const USHORT *)(rel + 1); + i = (rel->SizeOfBlock - sizeof(*rel)) / sizeof(USHORT); + while (i--) + { + USHORT offset = *relocs & 0xfff; + int type = *relocs >> 12; + printf( " off %04x type %s\n", offset, names[type] ); + relocs++; + } + rel = (const IMAGE_BASE_RELOCATION *)relocs; + } + printf("\n"); +} + static void dump_dir_tls(void) { IMAGE_TLS_DIRECTORY64 dir; @@ -1257,11 +1293,8 @@ void pe_dump(void) dump_dir_tls(); if (all || !strcmp(globals.dumpsect, "clr")) dump_dir_clr_header(); -#if 0 - /* FIXME: not implemented yet */ if (all || !strcmp(globals.dumpsect, "reloc")) dump_dir_reloc(); -#endif } if (globals.do_debug) dump_debug(); -- 2.11.4.GIT