From fceec90e24a0fde9a20ce2f0d24feef63a3269f9 Mon Sep 17 00:00:00 2001 From: Jan Zerebecki Date: Sat, 24 Nov 2007 16:52:51 +0100 Subject: [PATCH] push 97f44e0adb27fff75ba63d8fb97c65db9edfbe82 --- configure | 6 +- configure.ac | 6 +- dlls/advapi32/service.c | 3 - dlls/atl/atl_ax.c | 1 - dlls/comctl32/comboex.c | 40 +- dlls/comctl32/tooltips.c | 281 ++--- dlls/comdlg32/filedlg.c | 3 +- dlls/comdlg32/tests/printdlg.c | 1 - dlls/credui/Makefile.in | 2 +- dlls/credui/credui_De.rc | 2 +- dlls/credui/credui_En.rc | 6 +- dlls/credui/credui_Fr.rc | 4 + dlls/credui/credui_Ko.rc | 2 +- dlls/credui/credui_No.rc | 2 +- dlls/credui/credui_Pl.rc | 2 +- dlls/credui/credui_Sv.rc | 2 +- dlls/credui/credui_main.c | 494 ++++++-- dlls/credui/credui_resources.h | 4 + dlls/crypt32/tests/cert.c | 109 +- dlls/crypt32/tests/chain.c | 111 +- dlls/crypt32/tests/crl.c | 50 +- dlls/crypt32/tests/encode.c | 520 ++++---- dlls/crypt32/tests/oid.c | 19 +- dlls/crypt32/tests/protectdata.c | 38 +- dlls/crypt32/tests/store.c | 258 ++-- dlls/d3d8/device.c | 1 + dlls/d3d8/tests/visual.c | 7 +- dlls/d3d9/device.c | 1 + dlls/d3dx8/d3dx8.spec | 20 +- dlls/d3dx8/math.c | 118 ++ dlls/d3dx8/tests/math.c | 88 +- dlls/dinput/joystick_linux.c | 1 - dlls/dnsapi/ns_name.c | 1 - dlls/hlink/Makefile.in | 1 + dlls/hlink/browse_ctx.c | 23 +- dlls/hlink/extserv.c | 185 +++ dlls/hlink/hlink.spec | 2 +- dlls/hlink/hlink_main.c | 35 +- dlls/hlink/hlink_private.h | 78 ++ dlls/hlink/link.c | 90 +- dlls/hlink/tests/hlink.c | 57 +- dlls/iphlpapi/iphlpapi_main.c | 12 +- dlls/kernel32/kernel32.spec | 4 +- dlls/kernel32/kernel_main.c | 1 - dlls/kernel32/tests/thread.c | 25 +- dlls/kernel32/tests/toolhelp.c | 6 +- dlls/kernel32/volume.c | 20 + dlls/localspl/tests/localmon.c | 4 +- dlls/mshtml/editor.c | 4 +- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/navigate.c | 4 +- dlls/mshtml/nsio.c | 4 +- dlls/mshtml/olecmd.c | 43 +- dlls/mshtml/tests/htmldoc.c | 169 ++- dlls/mshtml/view.c | 24 +- dlls/msi/automation.c | 28 +- dlls/msi/files.c | 7 +- dlls/msi/script.c | 2 - dlls/msi/tests/automation.c | 5 + dlls/msi/tests/install.c | 3 + dlls/msvcrt/tests/heap.c | 3 +- dlls/msxml3/domdoc.c | 25 +- dlls/msxml3/node.c | 5 +- dlls/msxml3/tests/domdoc.c | 14 + dlls/netapi32/access.c | 6 +- dlls/ntdll/heap.c | 1 - dlls/ntdll/loader.c | 9 +- dlls/ntdll/process.c | 22 +- dlls/ntdll/serial.c | 3 - dlls/ntdll/server.c | 1 - dlls/ntdll/signal_powerpc.c | 1 - dlls/ntdll/tests/file.c | 2 +- dlls/ntdll/tests/info.c | 36 + dlls/olecli32/olecli_main.c | 2 +- dlls/qcap/vfwcapture.c | 2 + dlls/quartz/avidec.c | 1 - dlls/quartz/dsoundrender.c | 4 +- dlls/quartz/filesource.c | 2 + dlls/quartz/parser.c | 8 +- dlls/quartz/pin.c | 12 +- dlls/quartz/transform.c | 4 + dlls/quartz/videorenderer.c | 4 +- dlls/rpcrt4/ndr_marshall.c | 10 +- dlls/rpcrt4/rpcrt4_main.c | 4 +- dlls/rsaenh/Makefile.in | 1 + dlls/rsaenh/aes.c | 1333 ++++++++++++++++++++ dlls/rsaenh/implglue.c | 29 + dlls/rsaenh/implglue.h | 1 + dlls/rsaenh/rsaenh.c | 94 +- dlls/rsaenh/tests/rsaenh.c | 121 +- dlls/rsaenh/tomcrypt.h | 9 + dlls/setupapi/setupcab.c | 1 - dlls/setupapi/setupx_main.c | 1 - dlls/shdocvw/factory.c | 6 +- dlls/shdocvw/shdocvw.inf | 24 +- dlls/shdocvw/tests/webbrowser.c | 18 + dlls/shdocvw/webbrowser.c | 18 +- dlls/shell32/changenotify.c | 2 +- dlls/shell32/classes.c | 10 +- dlls/shell32/shell32.spec | 2 + dlls/shell32/shellord.c | 18 + dlls/shell32/shfldr_mycomp.c | 1 + dlls/shell32/shfldr_unixfs.c | 74 +- dlls/shell32/shlexec.c | 364 ++++-- dlls/urlmon/bindctx.c | 4 +- dlls/user32/edit.c | 38 +- dlls/user32/listbox.c | 24 +- dlls/user32/resources/display.rc | 10 +- dlls/user32/sysparams.c | 23 +- dlls/user32/tests/listbox.c | 2 +- dlls/user32/winpos.c | 1 - dlls/uuid/uuid.c | 2 +- dlls/wined3d/arb_program_shader.c | 6 +- dlls/wined3d/baseshader.c | 50 +- dlls/wined3d/device.c | 60 +- dlls/wined3d/directx.c | 3 +- dlls/wined3d/glsl_shader.c | 40 +- dlls/wined3d/palette.c | 10 +- dlls/wined3d/pixelshader.c | 59 +- dlls/wined3d/resource.c | 9 +- dlls/wined3d/vertexdeclaration.c | 29 +- dlls/wined3d/vertexshader.c | 219 +++- dlls/wined3d/wined3d_private.h | 41 +- dlls/winex11.drv/settings.c | 39 +- dlls/winex11.drv/winpos.c | 6 + dlls/wininet/cookie.c | 2 +- dlls/winmm/mci.c | 1 - dlls/wsock32/Makefile.in | 2 +- dlls/wsock32/wsock32.spec | 4 +- include/Makefile.in | 1 + include/d3dx8math.h | 11 + .../credui/credui_resources.h => include/isguids.h | 19 +- include/wine/server_protocol.h | 3 +- include/winuser.h | 7 + libs/port/spawn.c | 6 +- programs/cmd/Fr.rc | 2 +- programs/explorer/Makefile.in | 2 +- programs/explorer/desktop.c | 20 + programs/explorer/systray.c | 4 + programs/winecfg/No.rc | 22 +- programs/winefile/Es.rc | 85 +- programs/wordpad/De.rc | 2 +- programs/wordpad/En.rc | 2 +- programs/wordpad/Fr.rc | 2 +- programs/wordpad/Hu.rc | 2 +- programs/wordpad/Ko.rc | 3 +- programs/wordpad/Makefile.in | 1 + programs/wordpad/Nl.rc | 2 +- programs/wordpad/No.rc | 2 +- programs/wordpad/Pl.rc | 2 +- programs/wordpad/Ru.rc | 2 +- programs/wordpad/Tr.rc | 2 +- programs/wordpad/print.c | 602 +++++++++ programs/wordpad/rsrc.rc | 2 +- programs/wordpad/wordpad.c | 612 +-------- programs/wordpad/{resource.h => wordpad.h} | 18 +- server/file.c | 53 +- server/process.c | 15 +- server/protocol.def | 1 + server/trace.c | 1 + tools/widl/server.c | 1 - tools/widl/typegen.c | 1 - tools/widl/utils.c | 1 - tools/wrc/utils.c | 1 - 164 files changed, 5480 insertions(+), 2064 deletions(-) create mode 100644 dlls/hlink/extserv.c create mode 100644 dlls/hlink/hlink_private.h create mode 100644 dlls/rsaenh/aes.c copy dlls/credui/credui_resources.h => include/isguids.h (60%) create mode 100644 programs/wordpad/print.c rename programs/wordpad/{resource.h => wordpad.h} (90%) diff --git a/configure b/configure index 03b81933de1..de3508e84e2 100755 --- a/configure +++ b/configure @@ -10503,7 +10503,7 @@ echo "${ECHO_T}not found" >&6; } This probably prevents linking to OpenGL. Try deleting the file and restarting configure." else wine_warnings="$wine_warnings|No OpenGL library found on this system. -Wine will be build without OpenGL or Direct3D support." +Wine will be built without OpenGL or Direct3D support." fi else { echo "$as_me:$LINENO: result: $ac_cv_lib_soname_GL" >&5 @@ -10592,11 +10592,11 @@ fi else wine_warnings="$wine_warnings|Old Mesa headers detected. Consider upgrading your Mesa libraries (http://www.mesa3d.org/). -Wine will be build without OpenGL or Direct3D support." +Wine will be built without OpenGL or Direct3D support." fi else wine_warnings="$wine_warnings|OpenGL development headers not found. -Wine will be build without OpenGL or Direct3D support." +Wine will be built without OpenGL or Direct3D support." fi fi diff --git a/configure.ac b/configure.ac index 021ecc78630..f84720916a3 100644 --- a/configure.ac +++ b/configure.ac @@ -667,7 +667,7 @@ Wine will be built without XComposite support. (winex11.drv)]) This probably prevents linking to OpenGL. Try deleting the file and restarting configure.]) else WINE_WARNING([No OpenGL library found on this system. -Wine will be build without OpenGL or Direct3D support.]) +Wine will be built without OpenGL or Direct3D support.]) fi], $X_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS) @@ -679,11 +679,11 @@ Wine will be build without OpenGL or Direct3D support.]) $OPENGL_LIBS $X_LIBS $X_PRE_LIBS -lXext -lX11 -lm $X_EXTRA_LIBS) else WINE_WARNING([Old Mesa headers detected. Consider upgrading your Mesa libraries (http://www.mesa3d.org/). -Wine will be build without OpenGL or Direct3D support.]) +Wine will be built without OpenGL or Direct3D support.]) fi else WINE_WARNING([OpenGL development headers not found. -Wine will be build without OpenGL or Direct3D support.]) +Wine will be built without OpenGL or Direct3D support.]) fi fi diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index 63fd076959e..3acab45ed2f 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -2107,9 +2107,6 @@ QueryServiceConfigW( SC_HANDLE hService, n -= sizeof(WCHAR); } - if( n < 0 ) - ERR("Buffer overflow!\n"); - TRACE("Image path = %s\n", debugstr_w(lpServiceConfig->lpBinaryPathName) ); TRACE("Group = %s\n", debugstr_w(lpServiceConfig->lpLoadOrderGroup) ); TRACE("Dependencies = %s\n", debugstr_w(lpServiceConfig->lpDependencies) ); diff --git a/dlls/atl/atl_ax.c b/dlls/atl/atl_ax.c index 8201d099b0a..64b338bf6a2 100644 --- a/dlls/atl/atl_ax.c +++ b/dlls/atl/atl_ax.c @@ -25,7 +25,6 @@ #include "windef.h" #include "winbase.h" -#include "winuser.h" #include "winerror.h" #include "winuser.h" #include "wine/debug.h" diff --git a/dlls/comctl32/comboex.c b/dlls/comctl32/comboex.c index 299a997e14c..55e530866e2 100644 --- a/dlls/comctl32/comboex.c +++ b/dlls/comctl32/comboex.c @@ -1578,6 +1578,27 @@ static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT const *di } +static void COMBOEX_ResetContent (COMBOEX_INFO *infoPtr) +{ + if (infoPtr->items) + { + CBE_ITEMDATA *item, *next; + + item = infoPtr->items; + while (item) { + next = item->next; + COMBOEX_FreeText (item); + Free (item); + item = next; + } + infoPtr->items = 0; + } + + infoPtr->selected = -1; + infoPtr->nb_items = 0; +} + + static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) { if (infoPtr->hwndCombo) @@ -1586,18 +1607,7 @@ static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) Free (infoPtr->edit); infoPtr->edit = 0; - if (infoPtr->items) { - CBE_ITEMDATA *item, *next; - - item = infoPtr->items; - while (item) { - next = item->next; - COMBOEX_FreeText (item); - Free (item); - item = next; - } - infoPtr->items = 0; - } + COMBOEX_ResetContent (infoPtr); if (infoPtr->defaultFont) DeleteObject (infoPtr->defaultFont); @@ -2226,6 +2236,7 @@ COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_SETTEXT: case WM_GETTEXT: + case WM_GETTEXTLENGTH: return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam); case CB_GETLBTEXT: @@ -2234,12 +2245,15 @@ COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case CB_GETLBTEXTLEN: return COMBOEX_GetListboxText(infoPtr, wParam, NULL); + case CB_RESETCONTENT: + COMBOEX_ResetContent(infoPtr); + /* fall through */ + /* Combo messages we are not sure if we need to process or just forward */ case CB_GETDROPPEDCONTROLRECT: case CB_GETITEMHEIGHT: case CB_GETEXTENDEDUI: case CB_LIMITTEXT: - case CB_RESETCONTENT: case CB_SELECTSTRING: /* Combo messages OK to just forward to the regular COMBO */ diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 39401eb4f61..8740b63f8f5 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -515,7 +515,7 @@ TOOLTIPS_CalcTipSize (HWND hwnd, const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize) static void -TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr) +TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate) { TTTOOL_INFO *toolPtr; HMONITOR monitor; @@ -525,25 +525,40 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr) NMHDR hdr; int ptfx = 0; DWORD style = GetWindowLongW(hwnd, GWL_STYLE); + INT nTool; - if (infoPtr->nTool == -1) { - TRACE("invalid tool (-1)!\n"); - return; + if (track_activate) + { + if (infoPtr->nTrackTool == -1) + { + TRACE("invalid tracking tool (-1)!\n"); + return; + } + nTool = infoPtr->nTrackTool; + } + else + { + if (infoPtr->nTool == -1) + { + TRACE("invalid tool (-1)!\n"); + return; + } + nTool = infoPtr->nTool; } - infoPtr->nCurrentTool = infoPtr->nTool; + TRACE("Show tooltip pre %d! (%p)\n", nTool, hwnd); - TRACE("Show tooltip pre %d! (%p)\n", infoPtr->nTool, hwnd); + TOOLTIPS_GetTipText (hwnd, infoPtr, nTool); - TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool); + if (infoPtr->szTipText[0] == '\0') + return; - if (infoPtr->szTipText[0] == '\0') { - infoPtr->nCurrentTool = -1; - return; - } + toolPtr = &infoPtr->tools[nTool]; - TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool); - toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; + if (!track_activate) + infoPtr->nCurrentTool = infoPtr->nTool; + + TRACE("Show tooltip %d!\n", nTool); hdr.hwndFrom = hwnd; hdr.idFrom = toolPtr->uId; @@ -556,61 +571,103 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr) TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size); TRACE("size %d x %d\n", size.cx, size.cy); - if (toolPtr->uFlags & TTF_CENTERTIP) { - RECT rc; + if (track_activate) + { + rect.left = infoPtr->xTrackPos; + rect.top = infoPtr->yTrackPos; + ptfx = rect.left; - if (toolPtr->uFlags & TTF_IDISHWND) - GetWindowRect ((HWND)toolPtr->uId, &rc); - else { - rc = toolPtr->rect; - MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rc, 2); - } - rect.left = (rc.left + rc.right - size.cx) / 2; - if (style & TTS_BALLOON) - { - ptfx = rc.left + ((rc.right - rc.left) / 2); - - /* CENTERTIP ballon tooltips default to below the field - if they fit on the screen */ - if(rc.bottom + size.cy > GetSystemMetrics(SM_CYSCREEN)) - { - rect.top = rc.top - size.cy; - infoPtr->bToolBelow = FALSE; - } - else - { - infoPtr->bToolBelow = TRUE; - rect.top = rc.bottom; - } - rect.left = max(0, rect.left - BALLOON_STEMINDENT); + if (toolPtr->uFlags & TTF_CENTERTIP) + { + rect.left -= (size.cx / 2); + if (!(style & TTS_BALLOON)) + rect.top -= (size.cy / 2); } - else + infoPtr->bToolBelow = TRUE; + + if (!(toolPtr->uFlags & TTF_ABSOLUTE)) { - rect.top = rc.bottom + 2; - infoPtr->bToolBelow = TRUE; + if (style & TTS_BALLOON) + rect.left -= BALLOON_STEMINDENT; + else + { + RECT rcTool; + + if (toolPtr->uFlags & TTF_IDISHWND) + GetWindowRect ((HWND)toolPtr->uId, &rcTool); + else + { + rcTool = toolPtr->rect; + MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rcTool, 2); + } + + /* smart placement */ + if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) && + (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom)) + rect.left = rcTool.right; + } } } - else { - GetCursorPos ((LPPOINT)&rect); - if (style & TTS_BALLOON) - { - ptfx = rect.left; - if(rect.top - size.cy >= 0) + else + { + if (toolPtr->uFlags & TTF_CENTERTIP) + { + RECT rc; + + if (toolPtr->uFlags & TTF_IDISHWND) + GetWindowRect ((HWND)toolPtr->uId, &rc); + else { + rc = toolPtr->rect; + MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rc, 2); + } + rect.left = (rc.left + rc.right - size.cx) / 2; + if (style & TTS_BALLOON) { - rect.top -= size.cy; - infoPtr->bToolBelow = FALSE; + ptfx = rc.left + ((rc.right - rc.left) / 2); + + /* CENTERTIP ballon tooltips default to below the field + * if they fit on the screen */ + if (rc.bottom + size.cy > GetSystemMetrics(SM_CYSCREEN)) + { + rect.top = rc.top - size.cy; + infoPtr->bToolBelow = FALSE; + } + else + { + infoPtr->bToolBelow = TRUE; + rect.top = rc.bottom; + } + rect.left = max(0, rect.left - BALLOON_STEMINDENT); } else { - infoPtr->bToolBelow = TRUE; - rect.top += 20; + rect.top = rc.bottom + 2; + infoPtr->bToolBelow = TRUE; } - rect.left = max(0, rect.left - BALLOON_STEMINDENT); } else { - rect.top += 20; - infoPtr->bToolBelow = TRUE; + GetCursorPos ((LPPOINT)&rect); + if (style & TTS_BALLOON) + { + ptfx = rect.left; + if(rect.top - size.cy >= 0) + { + rect.top -= size.cy; + infoPtr->bToolBelow = FALSE; + } + else + { + infoPtr->bToolBelow = TRUE; + rect.top += 20; + } + rect.left = max(0, rect.left - BALLOON_STEMINDENT); + } + else + { + rect.top += 20; + infoPtr->bToolBelow = TRUE; + } } } @@ -708,10 +765,13 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr) InvalidateRect(hwnd, NULL, TRUE); UpdateWindow(hwnd); - SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); - TRACE("timer 2 started!\n"); - SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0); - TRACE("timer 3 started!\n"); + if (!track_activate) + { + SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); + TRACE("timer 2 started!\n"); + SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0); + TRACE("timer 3 started!\n"); + } } @@ -745,98 +805,7 @@ TOOLTIPS_Hide (HWND hwnd, TOOLTIPS_INFO *infoPtr) static void TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr) { - TTTOOL_INFO *toolPtr; - RECT rect; - SIZE size; - NMHDR hdr; - - if (infoPtr->nTrackTool == -1) { - TRACE("invalid tracking tool (-1)!\n"); - return; - } - - TRACE("show tracking tooltip pre %d!\n", infoPtr->nTrackTool); - - TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nTrackTool); - - if (infoPtr->szTipText[0] == '\0') { - infoPtr->nTrackTool = -1; - return; - } - - TRACE("show tracking tooltip %d!\n", infoPtr->nTrackTool); - toolPtr = &infoPtr->tools[infoPtr->nTrackTool]; - - hdr.hwndFrom = hwnd; - hdr.idFrom = toolPtr->uId; - hdr.code = TTN_SHOW; - SendMessageW (toolPtr->hwnd, WM_NOTIFY, - (WPARAM)toolPtr->uId, (LPARAM)&hdr); - - TRACE("%s\n", debugstr_w(infoPtr->szTipText)); - - TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size); - TRACE("size %d x %d\n", size.cx, size.cy); - - if (toolPtr->uFlags & TTF_ABSOLUTE) { - rect.left = infoPtr->xTrackPos; - rect.top = infoPtr->yTrackPos; - - if (toolPtr->uFlags & TTF_CENTERTIP) { - rect.left -= (size.cx / 2); - rect.top -= (size.cy / 2); - } - } - else { - RECT rcTool; - - if (toolPtr->uFlags & TTF_IDISHWND) - GetWindowRect ((HWND)toolPtr->uId, &rcTool); - else { - rcTool = toolPtr->rect; - MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rcTool, 2); - } - - GetCursorPos ((LPPOINT)&rect); - rect.top += 20; - - if (toolPtr->uFlags & TTF_CENTERTIP) { - rect.left -= (size.cx / 2); - rect.top -= (size.cy / 2); - } - - /* smart placement */ - if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) && - (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom)) - rect.left = rcTool.right; - } - - TRACE("pos %d - %d\n", rect.left, rect.top); - - rect.right = rect.left + size.cx; - rect.bottom = rect.top + size.cy; - - AdjustWindowRectEx (&rect, GetWindowLongW (hwnd, GWL_STYLE), - FALSE, GetWindowLongW (hwnd, GWL_EXSTYLE)); - - if (GetWindowLongW(hwnd, GWL_STYLE) & TTS_BALLOON) - { - HRGN hRgn; - - /* FIXME: need to add pointy bit using CreatePolyRgn & CombinRgn */ - hRgn = CreateRoundRectRgn(0, 0, rect.right - rect.left, rect.bottom - rect.top, BALLOON_ROUNDEDNESS, BALLOON_ROUNDEDNESS); - - SetWindowRgn(hwnd, hRgn, FALSE); - /* we don't free the region handle as the system deletes it when - * it is no longer needed */ - } - - SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - SWP_SHOWWINDOW | SWP_NOACTIVATE ); - - InvalidateRect(hwnd, NULL, TRUE); - UpdateWindow(hwnd); + TOOLTIPS_Show(hwnd, infoPtr, TRUE); } @@ -2133,7 +2102,7 @@ TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (infoPtr->szTipText[0] == 0) TOOLTIPS_Hide(hwnd, infoPtr); else - TOOLTIPS_Show (hwnd, infoPtr); + TOOLTIPS_Show (hwnd, infoPtr, FALSE); } return 0; @@ -2255,7 +2224,7 @@ TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) if(infoPtr->nCurrentTool == -1) return 0; /* force repaint */ if (infoPtr->bActive) - TOOLTIPS_Show (hwnd, infoPtr); + TOOLTIPS_Show (hwnd, infoPtr, FALSE); else if (infoPtr->bTrackActive) TOOLTIPS_TrackShow (hwnd, infoPtr); @@ -2311,9 +2280,9 @@ TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) if(infoPtr->nCurrentTool == -1) return 0; /* force repaint */ if (infoPtr->bActive) - TOOLTIPS_Show (hwnd, infoPtr); + TOOLTIPS_Show (hwnd, infoPtr, FALSE); else if (infoPtr->bTrackActive) - TOOLTIPS_TrackShow (hwnd, infoPtr); + TOOLTIPS_Show (hwnd, infoPtr, TRUE); return 0; } @@ -2570,7 +2539,7 @@ TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam) KillTimer (hwnd, ID_TIMERSHOW); nOldTool = infoPtr->nTool; if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool) - TOOLTIPS_Show (hwnd, infoPtr); + TOOLTIPS_Show (hwnd, infoPtr, FALSE); break; case ID_TIMERPOP: diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index cd2ad51ac22..67fefd1d141 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -61,12 +61,11 @@ #include "windef.h" #include "winbase.h" -#include "winreg.h" #include "winternl.h" #include "winnls.h" #include "wingdi.h" -#include "winuser.h" #include "winreg.h" +#include "winuser.h" #include "commdlg.h" #include "dlgs.h" #include "cdlg.h" diff --git a/dlls/comdlg32/tests/printdlg.c b/dlls/comdlg32/tests/printdlg.c index 9842b17599a..783773f1adc 100644 --- a/dlls/comdlg32/tests/printdlg.c +++ b/dlls/comdlg32/tests/printdlg.c @@ -25,7 +25,6 @@ #include "winbase.h" #include "winerror.h" #include "wingdi.h" -#include "wingdi.h" #include "winuser.h" #include "cderr.h" diff --git a/dlls/credui/Makefile.in b/dlls/credui/Makefile.in index b4e1197e461..3e75b17f280 100644 --- a/dlls/credui/Makefile.in +++ b/dlls/credui/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = credui.dll IMPORTLIB = libcredui.$(IMPLIBEXT) -IMPORTS = comctl32 user32 kernel32 +IMPORTS = comctl32 user32 advapi32 kernel32 C_SRCS = \ credui_main.c diff --git a/dlls/credui/credui_De.rc b/dlls/credui/credui_De.rc index 52227ec5fc4..3c9fcd214a6 100644 --- a/dlls/credui/credui_De.rc +++ b/dlls/credui/credui_De.rc @@ -30,7 +30,7 @@ BEGIN LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP LTEXT "&Benutzername:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | - CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12 + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 LTEXT "&Passwort:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL CONTROL "&Remember my password",IDC_SAVE,"Button", diff --git a/dlls/credui/credui_En.rc b/dlls/credui/credui_En.rc index cdbe98e7aed..02f6f354a15 100644 --- a/dlls/credui/credui_En.rc +++ b/dlls/credui/credui_En.rc @@ -30,7 +30,7 @@ BEGIN LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP LTEXT "&User name:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | - CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12 + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 LTEXT "&Password:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL CONTROL "&Remember my password",IDC_SAVE,"Button", @@ -43,4 +43,8 @@ STRINGTABLE DISCARDABLE { IDS_TITLEFORMAT "Connect to %s" IDS_MESSAGEFORMAT "Connecting to %s" + IDS_INCORRECTPASSWORDTITLE "Logon unsuccessful" + IDS_INCORRECTPASSWORD "Make sure that your user name\nand password are correct." + IDS_CAPSLOCKONTITLE "Caps Lock is On" + IDS_CAPSLOCKON "Having Caps Lock on may cause you to enter your password incorrectly.\n\nPress the Caps Lock key on your keyboard to turn off Caps Lock before\nentering your password." } diff --git a/dlls/credui/credui_Fr.rc b/dlls/credui/credui_Fr.rc index 8faad276d64..c1d71d4b5e4 100644 --- a/dlls/credui/credui_Fr.rc +++ b/dlls/credui/credui_Fr.rc @@ -43,4 +43,8 @@ STRINGTABLE DISCARDABLE { IDS_TITLEFORMAT "Se connecter à %s" IDS_MESSAGEFORMAT "Connexion à %s" + IDS_INCORRECTPASSWORDTITLE "Échec lors de la connexion" + IDS_INCORRECTPASSWORD "Assurez-vous que votre nom d'utilisateur\net votre mot de passe sont corrects." + IDS_CAPSLOCKONTITLE "VERR.MAJ est activé" + IDS_CAPSLOCKON "Le verrouillage majuscule étant activé, cela pourrait provoquer une erreur lors de la saisie de votre mot de passe.\n\nAppuyez sur la touche VERR.MAJ de votre clavier afin de désactiver le verrouilage majuscule avant\nde saisir votre mot de passe." } diff --git a/dlls/credui/credui_Ko.rc b/dlls/credui/credui_Ko.rc index 3208af113ed..0e944690f8f 100644 --- a/dlls/credui/credui_Ko.rc +++ b/dlls/credui/credui_Ko.rc @@ -31,7 +31,7 @@ BEGIN LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP LTEXT "»ç¿ëÀÚ À̸§(&U):",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | - CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12 + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 LTEXT "¾ÏÈ£(&P):",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL CONTROL "³» ¾ÏÈ£ ±â¾ï(&R)",IDC_SAVE,"Button", diff --git a/dlls/credui/credui_No.rc b/dlls/credui/credui_No.rc index 4f1ddb71269..8e7be892ad8 100644 --- a/dlls/credui/credui_No.rc +++ b/dlls/credui/credui_No.rc @@ -30,7 +30,7 @@ BEGIN LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP LTEXT "Br&ukernavn:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | - CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12 + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 LTEXT "&Passord:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL CONTROL "&Remember my password",IDC_SAVE,"Button", diff --git a/dlls/credui/credui_Pl.rc b/dlls/credui/credui_Pl.rc index 0063e527937..87d2d1adb3f 100644 --- a/dlls/credui/credui_Pl.rc +++ b/dlls/credui/credui_Pl.rc @@ -31,7 +31,7 @@ BEGIN LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP LTEXT "&U¿ytkownik:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | - CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12 + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 LTEXT "&Has³o:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL CONTROL "&Remember my password",IDC_SAVE,"Button", diff --git a/dlls/credui/credui_Sv.rc b/dlls/credui/credui_Sv.rc index 7c57306d47a..a3c850ba9dc 100644 --- a/dlls/credui/credui_Sv.rc +++ b/dlls/credui/credui_Sv.rc @@ -30,7 +30,7 @@ BEGIN LTEXT "IDS_MESSAGEFORMAT",IDC_MESSAGE,8,48,199,8,NOT WS_GROUP LTEXT "A&nvändarnamn:",IDC_STATIC,8,62,72,12,SS_CENTERIMAGE CONTROL "",IDC_USERNAME,"ComboBoxEx32",CBS_DROPDOWN | - CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,12 + CBS_NOINTEGRALHEIGHT | WS_TABSTOP,80,62,126,87 LTEXT "&Lösenord:",IDC_STATIC,8,80,72,12,SS_CENTERIMAGE EDITTEXT IDC_PASSWORD,80,80,126,12,ES_PASSWORD | ES_AUTOHSCROLL CONTROL "&Remember my password",IDC_SAVE,"Button", diff --git a/dlls/credui/credui_main.c b/dlls/credui/credui_main.c index f9e24eb5eaf..43ab2d644e1 100644 --- a/dlls/credui/credui_main.c +++ b/dlls/credui/credui_main.c @@ -35,12 +35,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(credui); +#define TOOLID_INCORRECTPASSWORD 1 +#define TOOLID_CAPSLOCKON 2 + +#define ID_CAPSLOCKPOP 1 + struct pending_credentials { struct list entry; PWSTR pszTargetName; PWSTR pszUsername; PWSTR pszPassword; + BOOL generic; }; static HINSTANCE hinstCredUI; @@ -78,6 +84,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) HeapFree(GetProcessHeap(), 0, entry->pszTargetName); HeapFree(GetProcessHeap(), 0, entry->pszUsername); + ZeroMemory(entry->pszPassword, (strlenW(entry->pszPassword) + 1) * sizeof(WCHAR)); HeapFree(GetProcessHeap(), 0, entry->pszPassword); HeapFree(GetProcessHeap(), 0, entry); } @@ -87,10 +94,32 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) } static DWORD save_credentials(PCWSTR pszTargetName, PCWSTR pszUsername, - PCWSTR pszPassword) + PCWSTR pszPassword, BOOL generic) { - FIXME("save servername %s with username %s\n", debugstr_w(pszTargetName), debugstr_w(pszUsername)); - return ERROR_SUCCESS; + CREDENTIALW cred; + + TRACE("saving servername %s with username %s\n", debugstr_w(pszTargetName), debugstr_w(pszUsername)); + + cred.Flags = 0; + cred.Type = generic ? CRED_TYPE_GENERIC : CRED_TYPE_DOMAIN_PASSWORD; + cred.TargetName = (LPWSTR)pszTargetName; + cred.Comment = NULL; + cred.CredentialBlobSize = strlenW(pszPassword) * sizeof(WCHAR); + cred.CredentialBlob = (LPBYTE)pszPassword; + cred.Persist = CRED_PERSIST_ENTERPRISE; + cred.AttributeCount = 0; + cred.Attributes = NULL; + cred.TargetAlias = NULL; + cred.UserName = (LPWSTR)pszUsername; + + if (CredWriteW(&cred, 0)) + return ERROR_SUCCESS; + else + { + DWORD ret = GetLastError(); + ERR("CredWriteW failed with error %d\n", ret); + return ret; + } } struct cred_dialog_params @@ -105,53 +134,347 @@ struct cred_dialog_params ULONG ulPasswordMaxChars; BOOL fSave; DWORD dwFlags; + HWND hwndBalloonTip; + BOOL fBalloonTipActive; }; -static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, - LPARAM lParam) +static void CredDialogFillUsernameCombo(HWND hwndUsername, struct cred_dialog_params *params) { - switch (uMsg) + DWORD count; + DWORD i; + PCREDENTIALW *credentials; + + if (!CredEnumerateW(NULL, 0, &count, &credentials)) + return; + + for (i = 0; i < count; i++) { - case WM_INITDIALOG: + COMBOBOXEXITEMW comboitem; + DWORD j; + BOOL duplicate = FALSE; + + if (params->dwFlags & CREDUI_FLAGS_GENERIC_CREDENTIALS) { - struct cred_dialog_params *params = (struct cred_dialog_params *)lParam; + if ((credentials[i]->Type != CRED_TYPE_GENERIC) || !credentials[i]->UserName) + continue; + } + else + { + if (credentials[i]->Type == CRED_TYPE_GENERIC) + continue; + } - SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)params); - if (params->pszMessageText) - SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText); - else + /* don't add another item with the same name if we've already added it */ + for (j = 0; j < i; j++) + if (!strcmpW(credentials[i]->UserName, credentials[j]->UserName)) { - WCHAR format[256]; - WCHAR message[256]; - LoadStringW(hinstCredUI, IDS_MESSAGEFORMAT, format, sizeof(format)/sizeof(format[0])); - snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->pszTargetName); - SetDlgItemTextW(hwndDlg, IDC_MESSAGE, message); + duplicate = TRUE; + break; } - SetDlgItemTextW(hwndDlg, IDC_USERNAME, params->pszUsername); - SetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword); - if (params->pszUsername[0]) - SetFocus(GetDlgItem(hwndDlg, IDC_PASSWORD)); - else - SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME)); + if (duplicate) + continue; + + comboitem.mask = CBEIF_TEXT; + comboitem.iItem = -1; + comboitem.pszText = credentials[i]->UserName; + SendMessageW(hwndUsername, CBEM_INSERTITEMW, 0, (LPARAM)&comboitem); + } + + CredFree(credentials); +} + +static void CredDialogCreateBalloonTip(HWND hwndDlg, struct cred_dialog_params *params) +{ + TTTOOLINFOW toolinfo; + WCHAR wszText[256]; + + if (params->hwndBalloonTip) + return; + + params->hwndBalloonTip = CreateWindowExW(WS_EX_TOOLWINDOW, TOOLTIPS_CLASSW, + NULL, WS_POPUP | TTS_NOPREFIX | TTS_BALLOON, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndDlg, NULL, + hinstCredUI, NULL); + SetWindowPos(params->hwndBalloonTip, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + + if (!LoadStringW(hinstCredUI, IDS_INCORRECTPASSWORD, wszText, sizeof(wszText)/sizeof(wszText[0]))) + { + ERR("failed to load IDS_INCORRECTPASSWORD\n"); + return; + } + + toolinfo.cbSize = sizeof(toolinfo); + toolinfo.uFlags = TTF_TRACK; + toolinfo.hwnd = hwndDlg; + toolinfo.uId = TOOLID_INCORRECTPASSWORD; + memset(&toolinfo.rect, 0, sizeof(toolinfo.rect)); + toolinfo.hinst = NULL; + toolinfo.lpszText = wszText; + toolinfo.lParam = 0; + toolinfo.lpReserved = NULL; + SendMessageW(params->hwndBalloonTip, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo); + + if (!LoadStringW(hinstCredUI, IDS_CAPSLOCKON, wszText, sizeof(wszText)/sizeof(wszText[0]))) + { + ERR("failed to load IDS_CAPSLOCKON\n"); + return; + } + + toolinfo.uId = TOOLID_CAPSLOCKON; + SendMessageW(params->hwndBalloonTip, TTM_ADDTOOLW, 0, (LPARAM)&toolinfo); +} + +static void CredDialogShowIncorrectPasswordBalloon(HWND hwndDlg, struct cred_dialog_params *params) +{ + TTTOOLINFOW toolinfo; + RECT rcPassword; + INT x; + INT y; + WCHAR wszTitle[256]; + + /* user name likely wrong so balloon would be confusing. focus is also + * not set to the password edit box, so more notification would need to be + * handled */ + if (!params->pszUsername[0]) + return; + + /* don't show two balloon tips at once */ + if (params->fBalloonTipActive) + return; + + if (!LoadStringW(hinstCredUI, IDS_INCORRECTPASSWORDTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]))) + { + ERR("failed to load IDS_INCORRECTPASSWORDTITLE\n"); + return; + } + + CredDialogCreateBalloonTip(hwndDlg, params); + + memset(&toolinfo, 0, sizeof(toolinfo)); + toolinfo.cbSize = sizeof(toolinfo); + toolinfo.hwnd = hwndDlg; + toolinfo.uId = TOOLID_INCORRECTPASSWORD; + + SendMessageW(params->hwndBalloonTip, TTM_SETTITLEW, TTI_ERROR, (LPARAM)wszTitle); + + GetWindowRect(GetDlgItem(hwndDlg, IDC_PASSWORD), &rcPassword); + /* centred vertically and in the right side of the password edit control */ + x = rcPassword.right - 12; + y = (rcPassword.top + rcPassword.bottom) / 2; + SendMessageW(params->hwndBalloonTip, TTM_TRACKPOSITION, 0, MAKELONG(x, y)); + + SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolinfo); + + params->fBalloonTipActive = TRUE; +} + +static void CredDialogShowCapsLockBalloon(HWND hwndDlg, struct cred_dialog_params *params) +{ + TTTOOLINFOW toolinfo; + RECT rcPassword; + INT x; + INT y; + WCHAR wszTitle[256]; + + /* don't show two balloon tips at once */ + if (params->fBalloonTipActive) + return; + + if (!LoadStringW(hinstCredUI, IDS_CAPSLOCKONTITLE, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]))) + { + ERR("failed to load IDS_IDSCAPSLOCKONTITLE\n"); + return; + } + + CredDialogCreateBalloonTip(hwndDlg, params); + + memset(&toolinfo, 0, sizeof(toolinfo)); + toolinfo.cbSize = sizeof(toolinfo); + toolinfo.hwnd = hwndDlg; + toolinfo.uId = TOOLID_CAPSLOCKON; + + SendMessageW(params->hwndBalloonTip, TTM_SETTITLEW, TTI_WARNING, (LPARAM)wszTitle); + + GetWindowRect(GetDlgItem(hwndDlg, IDC_PASSWORD), &rcPassword); + /* just inside the left side of the password edit control */ + x = rcPassword.left + 12; + y = rcPassword.bottom - 3; + SendMessageW(params->hwndBalloonTip, TTM_TRACKPOSITION, 0, MAKELONG(x, y)); + + SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolinfo); - if (params->pszCaptionText) - SetWindowTextW(hwndDlg, params->pszCaptionText); + SetTimer(hwndDlg, ID_CAPSLOCKPOP, + SendMessageW(params->hwndBalloonTip, TTM_GETDELAYTIME, TTDT_AUTOPOP, 0), + NULL); + + params->fBalloonTipActive = TRUE; +} + +static void CredDialogHideBalloonTip(HWND hwndDlg, struct cred_dialog_params *params) +{ + TTTOOLINFOW toolinfo; + + if (!params->hwndBalloonTip) + return; + + memset(&toolinfo, 0, sizeof(toolinfo)); + + toolinfo.cbSize = sizeof(toolinfo); + toolinfo.hwnd = hwndDlg; + toolinfo.uId = 0; + SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)&toolinfo); + toolinfo.uId = 1; + SendMessageW(params->hwndBalloonTip, TTM_TRACKACTIVATE, FALSE, (LPARAM)&toolinfo); + + params->fBalloonTipActive = FALSE; +} + +static inline BOOL CredDialogCapsLockOn(void) +{ + return GetKeyState(VK_CAPITAL) & 0x1 ? TRUE : FALSE; +} + +static LRESULT CALLBACK CredDialogPasswordSubclassProc(HWND hwnd, UINT uMsg, + WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) +{ + struct cred_dialog_params *params = (struct cred_dialog_params *)dwRefData; + switch (uMsg) + { + case WM_KEYDOWN: + if (wParam == VK_CAPITAL) + { + HWND hwndDlg = GetParent(hwnd); + if (CredDialogCapsLockOn()) + CredDialogShowCapsLockBalloon(hwndDlg, params); else - { - WCHAR format[256]; - WCHAR title[256]; - LoadStringW(hinstCredUI, IDS_TITLEFORMAT, format, sizeof(format)/sizeof(format[0])); - snprintfW(title, sizeof(title)/sizeof(title[0]), format, params->pszTargetName); - SetWindowTextW(hwndDlg, title); - } + CredDialogHideBalloonTip(hwndDlg, params); + } + break; + case WM_DESTROY: + RemoveWindowSubclass(hwnd, CredDialogPasswordSubclassProc, uIdSubclass); + break; + } + return DefSubclassProc(hwnd, uMsg, wParam, lParam); +} - if (params->dwFlags & (CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_PERSIST)) - ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE); - else if (params->fSave) - CheckDlgButton(hwndDlg, IDC_SAVE, BST_CHECKED); +static BOOL CredDialogInit(HWND hwndDlg, struct cred_dialog_params *params) +{ + HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME); + HWND hwndPassword = GetDlgItem(hwndDlg, IDC_PASSWORD); - return FALSE; + SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)params); + + if (params->hbmBanner) + SendMessageW(GetDlgItem(hwndDlg, IDB_BANNER), STM_SETIMAGE, + IMAGE_BITMAP, (LPARAM)params->hbmBanner); + + if (params->pszMessageText) + SetDlgItemTextW(hwndDlg, IDC_MESSAGE, params->pszMessageText); + else + { + WCHAR format[256]; + WCHAR message[256]; + LoadStringW(hinstCredUI, IDS_MESSAGEFORMAT, format, sizeof(format)/sizeof(format[0])); + snprintfW(message, sizeof(message)/sizeof(message[0]), format, params->pszTargetName); + SetDlgItemTextW(hwndDlg, IDC_MESSAGE, message); + } + SetWindowTextW(hwndUsername, params->pszUsername); + SetWindowTextW(hwndPassword, params->pszPassword); + + CredDialogFillUsernameCombo(hwndUsername, params); + + if (params->pszUsername[0]) + { + /* prevent showing a balloon tip here */ + params->fBalloonTipActive = TRUE; + SetFocus(hwndPassword); + params->fBalloonTipActive = FALSE; + } + else + SetFocus(hwndUsername); + + if (params->pszCaptionText) + SetWindowTextW(hwndDlg, params->pszCaptionText); + else + { + WCHAR format[256]; + WCHAR title[256]; + LoadStringW(hinstCredUI, IDS_TITLEFORMAT, format, sizeof(format)/sizeof(format[0])); + snprintfW(title, sizeof(title)/sizeof(title[0]), format, params->pszTargetName); + SetWindowTextW(hwndDlg, title); + } + + if (params->dwFlags & (CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_PERSIST)) + ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE); + else if (params->fSave) + CheckDlgButton(hwndDlg, IDC_SAVE, BST_CHECKED); + + /* setup subclassing for Caps Lock detection */ + SetWindowSubclass(hwndPassword, CredDialogPasswordSubclassProc, 1, (DWORD_PTR)params); + + if (params->dwFlags & CREDUI_FLAGS_INCORRECT_PASSWORD) + CredDialogShowIncorrectPasswordBalloon(hwndDlg, params); + else if ((GetFocus() == hwndPassword) && CredDialogCapsLockOn()) + CredDialogShowCapsLockBalloon(hwndDlg, params); + + return FALSE; +} + +static void CredDialogCommandOk(HWND hwndDlg, struct cred_dialog_params *params) +{ + HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME); + LPWSTR user; + INT len; + INT len2; + + len = GetWindowTextLengthW(hwndUsername); + user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); + GetWindowTextW(hwndUsername, user, len + 1); + + if (!user[0]) + { + HeapFree(GetProcessHeap(), 0, user); + return; + } + + if (!strchrW(user, '\\') && !strchrW(user, '@')) + { + INT len_target = strlenW(params->pszTargetName); + memcpy(params->pszUsername, params->pszTargetName, + min(len_target, params->ulUsernameMaxChars) * sizeof(WCHAR)); + if (len_target + 1 < params->ulUsernameMaxChars) + params->pszUsername[len_target] = '\\'; + if (len_target + 2 < params->ulUsernameMaxChars) + params->pszUsername[len_target + 1] = '\0'; + } + else if (params->ulUsernameMaxChars > 0) + params->pszUsername[0] = '\0'; + + len2 = strlenW(params->pszUsername); + memcpy(params->pszUsername + len2, user, min(len, params->ulUsernameMaxChars - len2) * sizeof(WCHAR)); + if (params->ulUsernameMaxChars) + params->pszUsername[len2 + min(len, params->ulUsernameMaxChars - len2 - 1)] = '\0'; + + HeapFree(GetProcessHeap(), 0, user); + + GetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword, + params->ulPasswordMaxChars); + + EndDialog(hwndDlg, IDOK); +} + +static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, + LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + struct cred_dialog_params *params = (struct cred_dialog_params *)lParam; + + return CredDialogInit(hwndDlg, params); } case WM_COMMAND: switch (wParam) @@ -160,52 +483,58 @@ static INT_PTR CALLBACK CredDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, { struct cred_dialog_params *params = (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); - HWND hwndUsername = GetDlgItem(hwndDlg, IDC_USERNAME); - LPWSTR user; - INT len; - INT len2; - - len = GetWindowTextLengthW(hwndUsername); - user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); - GetWindowTextW(hwndUsername, user, len + 1); - - if (!user[0]) - { - HeapFree(GetProcessHeap(), 0, user); - return TRUE; - } - - if (!strchrW(user, '\\') && !strchrW(user, '@')) - { - INT len_target = strlenW(params->pszTargetName); - memcpy(params->pszUsername, params->pszTargetName, - min(len_target, params->ulUsernameMaxChars) * sizeof(WCHAR)); - if (len_target + 1 < params->ulUsernameMaxChars) - params->pszUsername[len_target] = '\\'; - if (len_target + 2 < params->ulUsernameMaxChars) - params->pszUsername[len_target + 1] = '\0'; - } - else if (params->ulUsernameMaxChars > 0) - params->pszUsername[0] = '\0'; - - len2 = strlenW(params->pszUsername); - memcpy(params->pszUsername + len2, user, min(len, params->ulUsernameMaxChars - len2) * sizeof(WCHAR)); - if (params->ulUsernameMaxChars) - params->pszUsername[len2 + min(len, params->ulUsernameMaxChars - len2 - 1)] = '\0'; - - HeapFree(GetProcessHeap(), 0, user); - - GetDlgItemTextW(hwndDlg, IDC_PASSWORD, params->pszPassword, - params->ulPasswordMaxChars); - - EndDialog(hwndDlg, IDOK); + CredDialogCommandOk(hwndDlg, params); return TRUE; } case MAKELONG(IDCANCEL, BN_CLICKED): EndDialog(hwndDlg, IDCANCEL); return TRUE; + case MAKELONG(IDC_PASSWORD, EN_SETFOCUS): + if (CredDialogCapsLockOn()) + { + struct cred_dialog_params *params = + (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); + CredDialogShowCapsLockBalloon(hwndDlg, params); + } + /* don't allow another window to steal focus while the + * user is typing their password */ + LockSetForegroundWindow(LSFW_LOCK); + return TRUE; + case MAKELONG(IDC_PASSWORD, EN_KILLFOCUS): + { + struct cred_dialog_params *params = + (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); + /* the user is no longer typing their password, so allow + * other windows to become foreground ones */ + LockSetForegroundWindow(LSFW_UNLOCK); + CredDialogHideBalloonTip(hwndDlg, params); + return TRUE; + } + case MAKELONG(IDC_PASSWORD, EN_CHANGE): + { + struct cred_dialog_params *params = + (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); + CredDialogHideBalloonTip(hwndDlg, params); + return TRUE; + } } - /* fall through */ + return FALSE; + case WM_TIMER: + if (wParam == ID_CAPSLOCKPOP) + { + struct cred_dialog_params *params = + (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); + CredDialogHideBalloonTip(hwndDlg, params); + return TRUE; + } + return FALSE; + case WM_DESTROY: + { + struct cred_dialog_params *params = + (struct cred_dialog_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); + if (params->hwndBalloonTip) DestroyWindow(params->hwndBalloonTip); + return TRUE; + } default: return FALSE; } @@ -260,6 +589,8 @@ DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW pUIInfo, params.ulPasswordMaxChars = ulPasswordMaxChars; params.fSave = pfSave ? *pfSave : FALSE; params.dwFlags = dwFlags; + params.hwndBalloonTip = NULL; + params.fBalloonTipActive = FALSE; ret = DialogBoxParamW(hinstCredUI, MAKEINTRESOURCEW(IDD_CREDDIALOG), pUIInfo ? pUIInfo->hwndParent : NULL, @@ -293,6 +624,7 @@ DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW pUIInfo, { found = TRUE; HeapFree(GetProcessHeap(), 0, entry->pszUsername); + ZeroMemory(entry->pszPassword, (strlenW(entry->pszPassword) + 1) * sizeof(WCHAR)); HeapFree(GetProcessHeap(), 0, entry->pszPassword); } @@ -312,11 +644,13 @@ DWORD WINAPI CredUIPromptForCredentialsW(PCREDUI_INFOW pUIInfo, len = strlenW(params.pszPassword); entry->pszPassword = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR)); memcpy(entry->pszPassword, params.pszPassword, (len + 1)*sizeof(WCHAR)); + entry->generic = dwFlags & CREDUI_FLAGS_GENERIC_CREDENTIALS ? TRUE : FALSE; LeaveCriticalSection(&csPendingCredentials); } else - result = save_credentials(pszTargetName, pszUsername, pszPassword); + result = save_credentials(pszTargetName, pszUsername, pszPassword, + dwFlags & CREDUI_FLAGS_GENERIC_CREDENTIALS ? TRUE : FALSE); } return result; @@ -342,7 +676,8 @@ DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR pszTargetName, BOOL bConfirm) if (!strcmpW(pszTargetName, entry->pszTargetName)) { if (bConfirm) - result = save_credentials(entry->pszTargetName, entry->pszUsername, entry->pszPassword); + result = save_credentials(entry->pszTargetName, entry->pszUsername, + entry->pszPassword, entry->generic); else result = ERROR_SUCCESS; @@ -350,6 +685,7 @@ DWORD WINAPI CredUIConfirmCredentialsW(PCWSTR pszTargetName, BOOL bConfirm) HeapFree(GetProcessHeap(), 0, entry->pszTargetName); HeapFree(GetProcessHeap(), 0, entry->pszUsername); + ZeroMemory(entry->pszPassword, (strlenW(entry->pszPassword) + 1) * sizeof(WCHAR)); HeapFree(GetProcessHeap(), 0, entry->pszPassword); HeapFree(GetProcessHeap(), 0, entry); diff --git a/dlls/credui/credui_resources.h b/dlls/credui/credui_resources.h index d7acae50779..4f6e427939b 100644 --- a/dlls/credui/credui_resources.h +++ b/dlls/credui/credui_resources.h @@ -27,3 +27,7 @@ #define IDS_TITLEFORMAT 300 #define IDS_MESSAGEFORMAT 301 +#define IDS_INCORRECTPASSWORDTITLE 302 +#define IDS_INCORRECTPASSWORD 303 +#define IDS_CAPSLOCKON 304 +#define IDS_CAPSLOCKONTITLE 305 diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index 8e4bc5d892e..cb3de1cc145 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -29,6 +29,11 @@ #include "wine/test.h" +static BOOL (WINAPI *pCertAddStoreToCollection)(HCERTSTORE,HCERTSTORE,DWORD,DWORD); +static PCCERT_CONTEXT (WINAPI *pCertCreateSelfSignCertificate)(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE,PCERT_NAME_BLOB,DWORD,PCRYPT_KEY_PROV_INFO,PCRYPT_ALGORITHM_IDENTIFIER,PSYSTEMTIME,PSYSTEMTIME,PCERT_EXTENSIONS); +static BOOL (WINAPI *pCertGetValidUsages)(DWORD,PCCERT_CONTEXT*,int*,LPSTR*,DWORD*); +static BOOL (WINAPI *pCryptAcquireCertificatePrivateKey)(PCCERT_CONTEXT,DWORD,void*,HCRYPTPROV_OR_NCRYPT_KEY_HANDLE*,DWORD*,BOOL*); +static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); static BOOL (WINAPI * pCryptVerifyCertificateSignatureEx) (HCRYPTPROV, DWORD, DWORD, void *, DWORD, void *, DWORD, void *); @@ -45,6 +50,11 @@ static void init_function_pointers(void) if(!p ## func) \ trace("GetProcAddress(%s) failed\n", #func); + GET_PROC(hCrypt32, CertAddStoreToCollection) + GET_PROC(hCrypt32, CertCreateSelfSignCertificate) + GET_PROC(hCrypt32, CertGetValidUsages) + GET_PROC(hCrypt32, CryptAcquireCertificatePrivateKey) + GET_PROC(hCrypt32, CryptEncodeObjectEx) GET_PROC(hCrypt32, CryptVerifyCertificateSignatureEx) GET_PROC(hAdvapi32, CryptAcquireContextW) @@ -256,10 +266,10 @@ static void testAddCert(void) collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); ok(collection != NULL, "CertOpenStore failed: %08x\n", GetLastError()); - if (collection) + if (collection && pCertAddStoreToCollection) { /* Add store to the collection, but disable updates */ - CertAddStoreToCollection(collection, store, 0, 0); + pCertAddStoreToCollection(collection, store, 0, 0); context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert2, sizeof(bigCert2)); @@ -1587,6 +1597,11 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, skip("no CryptVerifyCertificateSignatureEx support\n"); return; } + if (!pCryptEncodeObjectEx) + { + skip("no CryptEncodeObjectEx support\n"); + return; + } ret = pCryptVerifyCertificateSignatureEx(0, 0, 0, NULL, 0, NULL, 0, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); @@ -1608,7 +1623,7 @@ static void testVerifyCertSig(HCRYPTPROV csp, const CRYPT_DATA_BLOB *toBeSigned, info.Signature.cbData = sigLen; info.Signature.pbData = (BYTE *)sig; info.Signature.cUnusedBits = 0; - ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, + ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&cert, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (cert) @@ -1791,13 +1806,19 @@ static void testCreateSelfSignCert(void) HCRYPTKEY key; CRYPT_KEY_PROV_INFO info; + if (!pCertCreateSelfSignCertificate) + { + skip("CertCreateSelfSignCertificate() is not available\n"); + return; + } + /* This crashes: - context = CertCreateSelfSignCertificate(0, NULL, 0, NULL, NULL, NULL, NULL, + context = pCertCreateSelfSignCertificate(0, NULL, 0, NULL, NULL, NULL, NULL, NULL); * Calling this with no first parameter creates a new key container, which * lasts beyond the test, so I don't test that. Nb: the generated key * name is a GUID. - context = CertCreateSelfSignCertificate(0, &name, 0, NULL, NULL, NULL, NULL, + context = pCertCreateSelfSignCertificate(0, &name, 0, NULL, NULL, NULL, NULL, NULL); */ @@ -1808,7 +1829,7 @@ static void testCreateSelfSignCert(void) CRYPT_NEWKEYSET); ok(ret, "CryptAcquireContext failed: %08x\n", GetLastError()); - context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); ok(!context && GetLastError() == NTE_NO_KEY, "Expected NTE_NO_KEY, got %08x\n", GetLastError()); @@ -1816,7 +1837,7 @@ static void testCreateSelfSignCert(void) ok(ret, "CryptGenKey failed: %08x\n", GetLastError()); if (ret) { - context = CertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, + context = pCertCreateSelfSignCertificate(csp, &name, 0, NULL, NULL, NULL, NULL, NULL); ok(context != NULL, "CertCreateSelfSignCertificate failed: %08x\n", GetLastError()); @@ -1868,7 +1889,7 @@ static void testCreateSelfSignCert(void) info.dwKeySpec = AT_KEYEXCHANGE; info.pwszProvName = (LPWSTR) MS_DEF_PROV_W; info.pwszContainerName = cspNameW; - context = CertCreateSelfSignCertificate(0, &name, 0, &info, NULL, NULL, + context = pCertCreateSelfSignCertificate(0, &name, 0, &info, NULL, NULL, NULL, NULL); ok(context != NULL, "CertCreateSelfSignCertificate failed: %08x\n", GetLastError()); @@ -2220,14 +2241,20 @@ static void testGetValidUsages(void) LPSTR *oids = NULL; PCCERT_CONTEXT contexts[3]; + if (!pCertGetValidUsages) + { + skip("CertGetValidUsages() is not available\n"); + return; + } + /* Crash - ret = CertGetValidUsages(0, NULL, NULL, NULL, NULL); - ret = CertGetValidUsages(0, NULL, NULL, NULL, &size); + ret = pCertGetValidUsages(0, NULL, NULL, NULL, NULL); + ret = pCertGetValidUsages(0, NULL, NULL, NULL, &size); */ contexts[0] = NULL; numOIDs = size = 0xdeadbeef; SetLastError(0xdeadbeef); - ret = CertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size); + ret = pCertGetValidUsages(1, &contexts[0], &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %d\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); ok(size == 0, "Expected size 0, got %d\n", size); @@ -2238,16 +2265,16 @@ static void testGetValidUsages(void) contexts[2] = CertCreateCertificateContext(X509_ASN_ENCODING, cert2WithUsage, sizeof(cert2WithUsage)); numOIDs = size = 0xdeadbeef; - ret = CertGetValidUsages(0, NULL, &numOIDs, NULL, &size); + ret = pCertGetValidUsages(0, NULL, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); ok(size == 0, "Expected size 0, got %d\n", size); numOIDs = size = 0xdeadbeef; - ret = CertGetValidUsages(1, contexts, &numOIDs, NULL, &size); + ret = pCertGetValidUsages(1, contexts, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); ok(numOIDs == -1, "Expected -1, got %d\n", numOIDs); ok(size == 0, "Expected size 0, got %d\n", size); - ret = CertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size); + ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2258,10 +2285,10 @@ static void testGetValidUsages(void) DWORD smallSize = 1; SetLastError(0xdeadbeef); - ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize); + ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &smallSize); ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", GetLastError()); - ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); + ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n", @@ -2270,11 +2297,11 @@ static void testGetValidUsages(void) } numOIDs = size = 0xdeadbeef; /* Oddly enough, this crashes when the number of contexts is not 1: - ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size); + ret = pCertGetValidUsages(2, contexts, &numOIDs, NULL, &size); * but setting size to 0 allows it to succeed: */ size = 0; - ret = CertGetValidUsages(2, contexts, &numOIDs, NULL, &size); + ret = pCertGetValidUsages(2, contexts, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); ok(numOIDs == 3, "Expected 3, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2283,7 +2310,7 @@ static void testGetValidUsages(void) { int i; - ret = CertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); + ret = pCertGetValidUsages(1, &contexts[1], &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs[i]), "unexpected OID %s\n", @@ -2292,7 +2319,7 @@ static void testGetValidUsages(void) } numOIDs = 0xdeadbeef; size = 0; - ret = CertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size); + ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2301,7 +2328,7 @@ static void testGetValidUsages(void) { int i; - ret = CertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size); + ret = pCertGetValidUsages(1, &contexts[2], &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n", @@ -2310,7 +2337,7 @@ static void testGetValidUsages(void) } numOIDs = 0xdeadbeef; size = 0; - ret = CertGetValidUsages(3, contexts, &numOIDs, NULL, &size); + ret = pCertGetValidUsages(3, contexts, &numOIDs, NULL, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); ok(numOIDs == 2, "Expected 2, got %d\n", numOIDs); ok(size, "Expected non-zero size\n"); @@ -2319,7 +2346,7 @@ static void testGetValidUsages(void) { int i; - ret = CertGetValidUsages(3, contexts, &numOIDs, oids, &size); + ret = pCertGetValidUsages(3, contexts, &numOIDs, oids, &size); ok(ret, "CertGetValidUsages failed: %08x\n", GetLastError()); for (i = 0; i < numOIDs; i++) ok(!lstrcmpA(oids[i], expectedOIDs2[i]), "unexpected OID %s\n", @@ -2679,6 +2706,12 @@ static void testAcquireCertPrivateKey(void) HCRYPTKEY key; WCHAR ms_def_prov_w[MAX_PATH]; + if (!pCryptAcquireCertificatePrivateKey) + { + skip("CryptAcquireCertificatePrivateKey() is not available\n"); + return; + } + lstrcpyW(ms_def_prov_w, MS_DEF_PROV_W); keyProvInfo.pwszContainerName = cspNameW; @@ -2696,28 +2729,28 @@ static void testAcquireCertPrivateKey(void) sizeof(selfSignedCert)); /* Crash - ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, NULL); - ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, + ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, NULL); + ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, NULL, &callerFree); - ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, &keySpec, + ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, NULL, &keySpec, NULL); - ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, NULL, NULL); - ret = CryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, &keySpec, + ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, NULL, NULL); + ret = pCryptAcquireCertificatePrivateKey(NULL, 0, NULL, &csp, &keySpec, &callerFree); - ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, NULL, NULL, NULL); + ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, NULL, NULL, NULL); */ /* Missing private key */ - ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, NULL, NULL); + ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, NULL, NULL); ok(!ret && GetLastError() == CRYPT_E_NO_KEY_PROPERTY, "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError()); - ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, + ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, &callerFree); ok(!ret && GetLastError() == CRYPT_E_NO_KEY_PROPERTY, "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError()); CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo); - ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, + ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &csp, &keySpec, &callerFree); ok(!ret && GetLastError() == CRYPT_E_NO_KEY_PROPERTY, "Expected CRYPT_E_NO_KEY_PROPERTY, got %08x\n", GetLastError()); @@ -2733,20 +2766,20 @@ static void testAcquireCertPrivateKey(void) CERT_KEY_CONTEXT keyContext; /* Don't cache provider */ - ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, + ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, &keySpec, &callerFree); ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); ok(callerFree, "Expected callerFree to be TRUE\n"); CryptReleaseContext(certCSP, 0); - ret = CryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, + ret = pCryptAcquireCertificatePrivateKey(cert, 0, NULL, &certCSP, NULL, NULL); ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); CryptReleaseContext(certCSP, 0); /* Use the key prov info's caching (there shouldn't be any) */ - ret = CryptAcquireCertificatePrivateKey(cert, + ret = pCryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", @@ -2755,7 +2788,7 @@ static void testAcquireCertPrivateKey(void) CryptReleaseContext(certCSP, 0); /* Cache it (and check that it's cached) */ - ret = CryptAcquireCertificatePrivateKey(cert, + ret = pCryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_CACHE_FLAG, NULL, &certCSP, &keySpec, &callerFree); ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", GetLastError()); @@ -2775,7 +2808,7 @@ static void testAcquireCertPrivateKey(void) CertSetCertificateContextProperty(cert, CERT_KEY_PROV_INFO_PROP_ID, 0, &keyProvInfo); /* Now use the key prov info's caching */ - ret = CryptAcquireCertificatePrivateKey(cert, + ret = pCryptAcquireCertificatePrivateKey(cert, CRYPT_ACQUIRE_USE_PROV_INFO_FLAG, NULL, &certCSP, &keySpec, &callerFree); ok(ret, "CryptAcquireCertificatePrivateKey failed: %08x\n", @@ -2808,7 +2841,7 @@ static void testAcquireCertPrivateKey(void) ok(size == sizeof(exportedPublicKeyBlob), "Unexpected size %d\n", size); ok(!memcmp(buf, exportedPublicKeyBlob, size), "Unexpected value\n"); - ret = CryptEncodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, RSA_CSP_PUBLICKEYBLOB, buf, CRYPT_ENCODE_ALLOC_FLAG, NULL, &encodedKey, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) diff --git a/dlls/crypt32/tests/chain.c b/dlls/crypt32/tests/chain.c index 0257c3ed1c9..91cae474429 100644 --- a/dlls/crypt32/tests/chain.c +++ b/dlls/crypt32/tests/chain.c @@ -52,6 +52,13 @@ static const BYTE selfSignedCert[] = { 0x0a, 0x8c, 0xb4, 0x5c, 0x34, 0x78, 0xe0, 0x3c, 0x9c, 0xe9, 0xf3, 0x30, 0x9f, 0xa8, 0x76, 0x57, 0x92, 0x36 }; +static BOOL (WINAPI *pCertCreateCertificateChainEngine)(PCERT_CHAIN_ENGINE_CONFIG,HCERTCHAINENGINE*); +static BOOL (WINAPI *pCertGetCertificateChain)(HCERTCHAINENGINE,PCCERT_CONTEXT,LPFILETIME,HCERTSTORE,PCERT_CHAIN_PARA,DWORD,LPVOID,PCCERT_CHAIN_CONTEXT*); +static VOID (WINAPI *pCertFreeCertificateChain)(PCCERT_CHAIN_CONTEXT); +static VOID (WINAPI *pCertFreeCertificateChainEngine)(HCERTCHAINENGINE); +static BOOL (WINAPI *pCertVerifyCertificateChainPolicy)(LPCSTR,PCCERT_CHAIN_CONTEXT,PCERT_CHAIN_POLICY_PARA,PCERT_CHAIN_POLICY_STATUS); + + static void testCreateCertChainEngine(void) { BOOL ret; @@ -59,43 +66,49 @@ static void testCreateCertChainEngine(void) HCERTCHAINENGINE engine; HCERTSTORE store; + if (!pCertCreateCertificateChainEngine || !pCertFreeCertificateChainEngine) + { + skip("Cert*CertificateChainEngine() functions are not available\n"); + return; + } + /* Crash - ret = CertCreateCertificateChainEngine(NULL, NULL); - ret = CertCreateCertificateChainEngine(NULL, &engine); + ret = pCertCreateCertificateChainEngine(NULL, NULL); + ret = pCertCreateCertificateChainEngine(NULL, &engine); */ - ret = CertCreateCertificateChainEngine(&config, NULL); + ret = pCertCreateCertificateChainEngine(&config, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); - ret = CertCreateCertificateChainEngine(&config, &engine); + ret = pCertCreateCertificateChainEngine(&config, &engine); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* Crashes config.cbSize = sizeof(config); - ret = CertCreateCertificateChainEngine(&config, NULL); + ret = pCertCreateCertificateChainEngine(&config, NULL); */ config.cbSize = sizeof(config); - ret = CertCreateCertificateChainEngine(&config, &engine); + ret = pCertCreateCertificateChainEngine(&config, &engine); ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError()); - CertFreeCertificateChainEngine(engine); + pCertFreeCertificateChainEngine(engine); config.dwFlags = 0xff000000; - ret = CertCreateCertificateChainEngine(&config, &engine); + ret = pCertCreateCertificateChainEngine(&config, &engine); ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError()); - CertFreeCertificateChainEngine(engine); + pCertFreeCertificateChainEngine(engine); /* Creating a cert with no root certs at all is allowed.. */ store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); config.hRestrictedRoot = store; - ret = CertCreateCertificateChainEngine(&config, &engine); + ret = pCertCreateCertificateChainEngine(&config, &engine); ok(ret, "CertCreateCertificateChainEngine failed: %08x\n", GetLastError()); - CertFreeCertificateChainEngine(engine); + pCertFreeCertificateChainEngine(engine); /* but creating one with a restricted root with a cert that isn't a member * of the Root store isn't allowed. */ CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert), CERT_STORE_ADD_ALWAYS, NULL); - ret = CertCreateCertificateChainEngine(&config, &engine); + ret = pCertCreateCertificateChainEngine(&config, &engine); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); @@ -1129,7 +1142,7 @@ static PCCERT_CHAIN_CONTEXT getChain(const CONST_BLOB_ARRAY *certArray, FILETIME fileTime; SystemTimeToFileTime(checkTime, &fileTime); - ret = CertGetCertificateChain(NULL, endCert, &fileTime, + ret = pCertGetCertificateChain(NULL, endCert, &fileTime, includeStore ? store : NULL, &chainPara, flags, NULL, &chain); if (todo & TODO_CHAIN) todo_wine ok(ret, "Chain %d: CertGetCertificateChain failed: %08x\n", @@ -1566,36 +1579,36 @@ static void testGetCertChain(void) DWORD i; /* Basic parameter checks */ - ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); + ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); - ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, + ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, NULL, 0, NULL, &chain); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* Crash - ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, NULL); - ret = CertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, + ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, NULL); + ret = pCertGetCertificateChain(NULL, NULL, NULL, NULL, ¶, 0, NULL, &chain); */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); - ret = CertGetCertificateChain(NULL, cert, NULL, NULL, NULL, 0, NULL, NULL); + ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, NULL, 0, NULL, NULL); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* Crash - ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, NULL); + ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, NULL); */ /* Tests with an invalid cert (one whose signature is bad) */ SetLastError(0xdeadbeef); - ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret && GetLastError() == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got %d\n", GetLastError()); para.cbSize = sizeof(para); SetLastError(0xdeadbeef); - ret = CertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, + ret = pCertGetCertificateChain(NULL, cert, NULL, NULL, ¶, 0, NULL, &chain); ok(!ret && GetLastError() == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got %d\n", GetLastError()); @@ -1609,7 +1622,7 @@ static void testGetCertChain(void) { checkChainStatus(chain, &chainCheck[i].status, chainCheck[i].todo, i); - CertFreeCertificateChain(chain); + pCertFreeCertificateChain(chain); } } for (i = 0; i < sizeof(chainCheckNoStore) / sizeof(chainCheckNoStore[0]); @@ -1621,7 +1634,7 @@ static void testGetCertChain(void) { checkChainStatus(chain, &chainCheckNoStore[i].status, chainCheckNoStore[i].todo, i); - CertFreeCertificateChain(chain); + pCertFreeCertificateChain(chain); } } } @@ -1737,7 +1750,7 @@ static void checkChainPolicyStatus(LPCSTR policy, ChainPolicyCheck *check, if (chain) { CERT_CHAIN_POLICY_STATUS policyStatus = { 0 }; - BOOL ret = CertVerifyCertificateChainPolicy(policy, chain, NULL, + BOOL ret = pCertVerifyCertificateChainPolicy(policy, chain, NULL, &policyStatus); if (check->todo & TODO_POLICY) @@ -1775,7 +1788,7 @@ static void checkChainPolicyStatus(LPCSTR policy, ChainPolicyCheck *check, "%d: expected %d, got %d\n", testIndex, check->status.lElementIndex, policyStatus.lElementIndex); } - CertFreeCertificateChain(chain); + pCertFreeCertificateChain(chain); } } @@ -1789,34 +1802,40 @@ static void testVerifyCertChainPolicy(void) CERT_CHAIN_POLICY_PARA policyPara = { 0 }; DWORD i; + if (!pCertVerifyCertificateChainPolicy) + { + skip("CertVerifyCertificateChainPolicy() is not available\n"); + return; + } + /* Crash - ret = CertVerifyCertificateChainPolicy(NULL, NULL, NULL, NULL); - ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, + ret = pCertVerifyCertificateChainPolicy(NULL, NULL, NULL, NULL); + ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, NULL); - ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, + ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, &chainPara, NULL); */ SetLastError(0xdeadbeef); - ret = CertVerifyCertificateChainPolicy(NULL, NULL, NULL, &policyStatus); + ret = pCertVerifyCertificateChainPolicy(NULL, NULL, NULL, &policyStatus); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); /* Crashes - ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, + ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, NULL, NULL, &policyStatus); */ cert = CertCreateCertificateContext(X509_ASN_ENCODING, selfSignedCert, sizeof(selfSignedCert)); - CertGetCertificateChain(NULL, cert, NULL, NULL, &chainPara, 0, NULL, + pCertGetCertificateChain(NULL, cert, NULL, NULL, &chainPara, 0, NULL, &chain); /* Crash - ret = CertVerifyCertificateChainPolicy(NULL, chain, NULL, NULL); - ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, + ret = pCertVerifyCertificateChainPolicy(NULL, chain, NULL, NULL); + ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, NULL); - ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, + ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, &chainPara, NULL); */ /* Size of policy status is apparently ignored, as is pChainPolicyPara */ - ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, + ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, NULL, &policyStatus); ok(ret, "CertVerifyCertificateChainPolicy failed: %08x\n", GetLastError()); ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT, @@ -1824,7 +1843,7 @@ static void testVerifyCertChainPolicy(void) ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0, "Expected both indexes 0, got %d, %d\n", policyStatus.lChainIndex, policyStatus.lElementIndex); - ret = CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, + ret = pCertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_BASE, chain, &policyPara, &policyStatus); ok(ret, "CertVerifyCertificateChainPolicy failed: %08x\n", GetLastError()); ok(policyStatus.dwError == CERT_E_UNTRUSTEDROOT, @@ -1832,7 +1851,7 @@ static void testVerifyCertChainPolicy(void) ok(policyStatus.lChainIndex == 0 && policyStatus.lElementIndex == 0, "Expected both indexes 0, got %d, %d\n", policyStatus.lChainIndex, policyStatus.lElementIndex); - CertFreeCertificateChain(chain); + pCertFreeCertificateChain(chain); CertFreeCertificateContext(cert); for (i = 0; @@ -1855,7 +1874,21 @@ static void testVerifyCertChainPolicy(void) START_TEST(chain) { + HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); + pCertCreateCertificateChainEngine = (void*)GetProcAddress(hCrypt32, "CertCreateCertificateChainEngine"); + pCertGetCertificateChain = (void*)GetProcAddress(hCrypt32, "CertGetCertificateChain"); + pCertFreeCertificateChain = (void*)GetProcAddress(hCrypt32, "CertFreeCertificateChain"); + pCertFreeCertificateChainEngine = (void*)GetProcAddress(hCrypt32, "CertFreeCertificateChainEngine"); + pCertVerifyCertificateChainPolicy = (void*)GetProcAddress(hCrypt32, "CertVerifyCertificateChainPolicy"); + testCreateCertChainEngine(); - testVerifyCertChainPolicy(); - testGetCertChain(); + if (!pCertGetCertificateChain) + { + skip("CertGetCertificateChain() is not available\n"); + } + else + { + testVerifyCertChainPolicy(); + testGetCertChain(); + } } diff --git a/dlls/crypt32/tests/crl.c b/dlls/crypt32/tests/crl.c index 7ecf6d4f1ae..3a65c7dc7d6 100644 --- a/dlls/crypt32/tests/crl.c +++ b/dlls/crypt32/tests/crl.c @@ -29,6 +29,7 @@ #include "wine/test.h" + static const BYTE bigCert[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x00, 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x4a, 0x75, 0x61, 0x6e, 0x20, 0x4c, 0x61, 0x6e, 0x67, 0x00, 0x30, 0x22, @@ -76,11 +77,15 @@ static const BYTE signedCRL[] = { 0x30, 0x45, 0x30, 0x2c, 0x30, 0x02, 0x06, 0x30, 0x5a, 0x30, 0x02, 0x06, 0x00, 0x03, 0x11, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }; +static BOOL (WINAPI *pCertFindCertificateInCRL)(PCCERT_CONTEXT,PCCRL_CONTEXT,DWORD,void*,PCRL_ENTRY*); +static PCCRL_CONTEXT (WINAPI *pCertFindCRLInStore)(HCERTSTORE,DWORD,DWORD,DWORD,const void*,PCCRL_CONTEXT); static BOOL (WINAPI *pCertIsValidCRLForCertificate)(PCCERT_CONTEXT, PCCRL_CONTEXT, DWORD, void*); static void init_function_pointers(void) { HMODULE hdll = GetModuleHandleA("crypt32.dll"); + pCertFindCertificateInCRL = (void*)GetProcAddress(hdll, "CertFindCertificateInCRL"); + pCertFindCRLInStore = (void*)GetProcAddress(hdll, "CertFindCRLInStore"); pCertIsValidCRLForCertificate = (void*)GetProcAddress(hdll, "CertIsValidCRLForCertificate"); } @@ -205,33 +210,38 @@ static void testFindCRL(void) BOOL ret; if (!store) return; + if (!pCertFindCRLInStore) + { + skip("CertFindCRLInStore() is not available\n"); + return; + } ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL, sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError()); /* Crashes - context = CertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL); + context = pCertFindCRLInStore(NULL, 0, 0, 0, NULL, NULL); */ /* Find any context */ - context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL); + context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* Bogus flags are ignored */ - context = CertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL); + context = pCertFindCRLInStore(store, 0, 1234, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* CRL encoding type is ignored too */ - context = CertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL); + context = pCertFindCRLInStore(store, 1234, 0, CRL_FIND_ANY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); /* This appears to match any cert */ - context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL); + context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, NULL, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); @@ -241,7 +251,7 @@ static void testFindCRL(void) sizeof(bigCert2)); ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", GetLastError()); - context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); + context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); ok(context == NULL, "Expected no matching context\n"); CertFreeCertificateContext(cert); @@ -250,7 +260,7 @@ static void testFindCRL(void) sizeof(bigCert)); ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", GetLastError()); - context = CertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); + context = pCertFindCRLInStore(store, 0, 0, CRL_FIND_ISSUED_BY, cert, NULL); ok(context != NULL, "Expected a context\n"); if (context) CertFreeCRLContext(context); @@ -600,31 +610,37 @@ static void testFindCertInCRL(void) PCCRL_CONTEXT crl; PCRL_ENTRY entry; + if (!pCertFindCertificateInCRL) + { + skip("CertFindCertificateInCRL() is not available\n"); + return; + } + cert = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert)); ok(cert != NULL, "CertCreateCertificateContext failed: %08x\n", GetLastError()); /* Crash - ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL); - ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, NULL); - ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, NULL); - ret = CertFindCertificateInCRL(cert, crl, 0, NULL, NULL); - ret = CertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry); - ret = CertFindCertificateInCRL(NULL, crl, 0, NULL, &entry); - ret = CertFindCertificateInCRL(cert, NULL, 0, NULL, &entry); + ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, NULL); + ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, NULL); + ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, NULL); + ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, NULL); + ret = pCertFindCertificateInCRL(NULL, NULL, 0, NULL, &entry); + ret = pCertFindCertificateInCRL(NULL, crl, 0, NULL, &entry); + ret = pCertFindCertificateInCRL(cert, NULL, 0, NULL, &entry); */ crl = CertCreateCRLContext(X509_ASN_ENCODING, verisignCRL, sizeof(verisignCRL)); - ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError()); ok(entry == NULL, "Expected not to find an entry in CRL\n"); CertFreeCRLContext(crl); crl = CertCreateCRLContext(X509_ASN_ENCODING, v1CRLWithIssuerAndEntry, sizeof(v1CRLWithIssuerAndEntry)); - ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError()); ok(entry != NULL, "Expected to find an entry in CRL\n"); CertFreeCRLContext(crl); @@ -632,7 +648,7 @@ static void testFindCertInCRL(void) /* Entry found even though CRL issuer doesn't match cert issuer */ crl = CertCreateCRLContext(X509_ASN_ENCODING, crlWithDifferentIssuer, sizeof(crlWithDifferentIssuer)); - ret = CertFindCertificateInCRL(cert, crl, 0, NULL, &entry); + ret = pCertFindCertificateInCRL(cert, crl, 0, NULL, &entry); ok(ret, "CertFindCertificateInCRL failed: %08x\n", GetLastError()); ok(entry != NULL, "Expected to find an entry in CRL\n"); CertFreeCRLContext(crl); diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c index a06531c3293..7616ec5e644 100644 --- a/dlls/crypt32/tests/encode.c +++ b/dlls/crypt32/tests/encode.c @@ -26,6 +26,10 @@ #include "wine/test.h" + +static BOOL (WINAPI *pCryptDecodeObjectEx)(DWORD,LPCSTR,const BYTE*,DWORD,DWORD,PCRYPT_DECODE_PARA,void*,DWORD*); +static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); + struct encodedInt { int val; @@ -90,28 +94,28 @@ static void test_encodeInt(DWORD dwEncoding) BYTE *buf = NULL; /* CryptEncodeObjectEx with NULL bufSize crashes.. - ret = CryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + ret = pCryptEncodeObjectEx(3, X509_INTEGER, &ints[0].val, 0, NULL, NULL, NULL); */ /* check bogus encoding */ - ret = CryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL, + ret = pCryptEncodeObjectEx(0, X509_INTEGER, &ints[0].val, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); /* check with NULL integer buffer. Windows XP incorrectly returns an * NTSTATUS. */ - ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) { /* encode as normal integer */ - ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, + ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %d\n", GetLastError()); - ret = CryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, + ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); if (buf) @@ -127,10 +131,10 @@ static void test_encodeInt(DWORD dwEncoding) /* encode as multibyte integer */ blob.cbData = sizeof(ints[i].val); blob.pbData = (BYTE *)&ints[i].val; - ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %d\n", GetLastError()); - ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); if (buf) @@ -151,10 +155,10 @@ static void test_encodeInt(DWORD dwEncoding) { blob.cbData = strlen((const char*)bigInts[i].val); blob.pbData = (BYTE *)bigInts[i].val; - ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %d\n", GetLastError()); - ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); if (buf) @@ -174,10 +178,10 @@ static void test_encodeInt(DWORD dwEncoding) { blob.cbData = strlen((const char*)bigUInts[i].val); blob.pbData = (BYTE*)bigUInts[i].val; - ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, 0, NULL, NULL, &bufSize); ok(ret, "Expected success, got %d\n", GetLastError()); - ret = CryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); if (buf) @@ -207,26 +211,26 @@ static void test_decodeInt(DWORD dwEncoding) BOOL ret; /* CryptDecodeObjectEx with NULL bufSize crashes.. - ret = CryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded, + ret = pCryptDecodeObjectEx(3, X509_INTEGER, &ints[0].encoded, ints[0].encoded[1] + 2, 0, NULL, NULL, NULL); */ /* check bogus encoding */ - ret = CryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded, + ret = pCryptDecodeObjectEx(3, X509_INTEGER, (BYTE *)&ints[0].encoded, ints[0].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); /* check with NULL integer buffer */ - ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL, + ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, NULL, 0, 0, NULL, NULL, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); /* check with a valid, but too large, integer */ - ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, bigInt, bigInt[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, "Expected CRYPT_E_ASN1_LARGE, got %d\n", GetLastError()); /* check with a DER-encoded string */ - ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, testStr, testStr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %d\n", GetLastError()); @@ -234,12 +238,12 @@ static void test_decodeInt(DWORD dwEncoding) { /* When the output buffer is NULL, this always succeeds */ SetLastError(0xdeadbeef); - ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, + ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, ints[i].encoded, ints[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, "Expected success and NOERROR, got %d\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, + ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, ints[i].encoded, ints[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError()); @@ -254,12 +258,12 @@ static void test_decodeInt(DWORD dwEncoding) } for (i = 0; i < sizeof(bigInts) / sizeof(bigInts[0]); i++) { - ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, "Expected success and NOERROR, got %d\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, + ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigInts[i].encoded, bigInts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError()); @@ -279,12 +283,12 @@ static void test_decodeInt(DWORD dwEncoding) } for (i = 0; i < sizeof(bigUInts) / sizeof(bigUInts[0]); i++) { - ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL, &bufSize); ok(ret && GetLastError() == NOERROR, "Expected success and NOERROR, got %d\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, + ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %d\n", GetLastError()); @@ -303,7 +307,7 @@ static void test_decodeInt(DWORD dwEncoding) } } /* Decode the value 1 with long-form length */ - ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm, + ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, longForm, sizeof(longForm), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -312,7 +316,7 @@ static void test_decodeInt(DWORD dwEncoding) LocalFree(buf); } /* check with extra bytes at the end */ - ret = CryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes, + ret = pCryptDecodeObjectEx(dwEncoding, X509_INTEGER, extraBytes, sizeof(extraBytes), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -326,7 +330,7 @@ static void test_decodeInt(DWORD dwEncoding) * Under XP it fails with CRYPT_E_ASN1_LARGE, which means there's a limit * on the size decoded, but in ME it fails with CRYPT_E_ASN1_EOD or crashes. * So this test unfortunately isn't useful. - ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig, + ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, tooBig, 0x7fffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_LARGE, "Expected CRYPT_E_ASN1_LARGE, got %08x\n", GetLastError()); @@ -337,7 +341,7 @@ static void test_decodeInt(DWORD dwEncoding) if (0) { /* a large buffer isn't guaranteed to crash, it depends on memory allocation order */ - ret = CryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus, + ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigBogus, 0x01ffffff, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); @@ -373,7 +377,7 @@ static void test_encodeEnumerated(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = CryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], + ret = pCryptEncodeObjectEx(dwEncoding, enumeratedTypes[i], &enums[j].val, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); @@ -406,7 +410,7 @@ static void test_decodeEnumerated(DWORD dwEncoding) DWORD bufSize = sizeof(int); int val; - ret = CryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], + ret = pCryptDecodeObjectEx(dwEncoding, enumeratedTypes[i], enums[j].encoded, enums[j].encoded[1] + 2, 0, NULL, (BYTE *)&val, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -434,7 +438,7 @@ static void testTimeEncoding(DWORD dwEncoding, LPCSTR structType, ret = SystemTimeToFileTime(&time->sysTime, &ft); ok(ret, "SystemTimeToFileTime failed: %d\n", GetLastError()); - ret = CryptEncodeObjectEx(dwEncoding, structType, &ft, + ret = pCryptEncodeObjectEx(dwEncoding, structType, &ft, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); /* years other than 1950-2050 are not allowed for encodings other than * X509_CHOICE_OF_TIME. @@ -505,7 +509,7 @@ static void testTimeDecoding(DWORD dwEncoding, LPCSTR structType, DWORD size = sizeof(ft); BOOL ret; - ret = CryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, + ret = pCryptDecodeObjectEx(dwEncoding, structType, time->encodedTime, time->encodedTime[1] + 2, 0, NULL, &ft, &size); /* years other than 1950-2050 are not allowed for encodings other than * X509_CHOICE_OF_TIME. @@ -616,7 +620,7 @@ static void test_decodeFiletime(DWORD dwEncoding) ret = SystemTimeToFileTime(×[0].sysTime, &ft1); ok(ret, "SystemTimeToFileTime failed: %d\n", GetLastError()); size = 1; - ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, times[0].encodedTime, times[0].encodedTime[1] + 2, 0, NULL, &ft2, &size); ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", GetLastError()); @@ -636,7 +640,7 @@ static void test_decodeFiletime(DWORD dwEncoding) for (i = 0; i < sizeof(bogusTimes) / sizeof(bogusTimes[0]); i++) { size = sizeof(ft1); - ret = CryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, bogusTimes[i], bogusTimes[i][1] + 2, 0, NULL, &ft1, &size); ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); @@ -726,14 +730,14 @@ static void test_encodeName(DWORD dwEncoding) BOOL ret; /* Test with NULL pvStructInfo */ - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); /* Test with empty CERT_NAME_INFO */ info.cRDN = 0; info.rgRDN = NULL; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -744,7 +748,7 @@ static void test_encodeName(DWORD dwEncoding) } /* Test with bogus CERT_RDN */ info.cRDN = 1; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); @@ -753,7 +757,7 @@ static void test_encodeName(DWORD dwEncoding) rdn.rgRDNAttr = NULL; info.cRDN = 1; info.rgRDN = &rdn; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -765,7 +769,7 @@ static void test_encodeName(DWORD dwEncoding) /* Test with bogus attr array */ rdn.cRDNAttr = 1; rdn.rgRDNAttr = NULL; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); @@ -776,7 +780,7 @@ static void test_encodeName(DWORD dwEncoding) attrs[0].Value.pbData = (BYTE *)commonName; rdn.cRDNAttr = 1; rdn.rgRDNAttr = attrs; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret, "Expected failure, got success\n"); */ @@ -793,7 +797,7 @@ static void test_encodeName(DWORD dwEncoding) attrs[1].Value.pbData = (BYTE *)surName; rdn.cRDNAttr = 2; rdn.rgRDNAttr = attrs; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -807,7 +811,7 @@ static void test_encodeName(DWORD dwEncoding) attrs[0].Value.pbData = (LPBYTE)twoRDNs; attrs[0].Value.cbData = sizeof(twoRDNs); rdn.cRDNAttr = 1; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -820,7 +824,7 @@ static void test_encodeName(DWORD dwEncoding) /* CERT_RDN_ANY_TYPE is too vague for X509_NAMEs, check the return */ rdn.cRDNAttr = 1; attrs[0].dwValueType = CERT_RDN_ANY_TYPE; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); @@ -831,7 +835,7 @@ static void test_encodeName(DWORD dwEncoding) info.rgRDN = &rdn; buf = NULL; size = 0; - ret = CryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info, + ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, X509_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -867,14 +871,14 @@ static void test_encodeUnicodeName(DWORD dwEncoding) BOOL ret; /* Test with NULL pvStructInfo */ - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); /* Test with empty CERT_NAME_INFO */ info.cRDN = 0; info.rgRDN = NULL; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -894,7 +898,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) rdn.rgRDNAttr = attrs; info.cRDN = 1; info.rgRDN = &rdn; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_PRINTABLE_STRING, "Expected CRYPT_E_INVALID_PRINTABLE_STRING, got %08x\n", GetLastError()); @@ -914,7 +918,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) rdn.rgRDNAttr = attrs; info.cRDN = 1; info.rgRDN = &rdn; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -928,7 +932,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) attrs[0].Value.pbData = (LPBYTE)twoRDNs; attrs[0].Value.cbData = sizeof(twoRDNs); rdn.cRDNAttr = 1; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -941,7 +945,7 @@ static void test_encodeUnicodeName(DWORD dwEncoding) /* Unicode names infer the type for CERT_RDN_ANY_TYPE */ rdn.cRDNAttr = 1; attrs[0].dwValueType = CERT_RDN_ANY_TYPE; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); todo_wine ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -1028,7 +1032,7 @@ static void test_decodeName(DWORD dwEncoding) /* test empty name */ bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptySequence, + ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, (BYTE *)&buf, &bufSize); @@ -1045,7 +1049,7 @@ static void test_decodeName(DWORD dwEncoding) LocalFree(buf); } /* test empty name with indefinite-length encoding */ - ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyIndefiniteSequence, + ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptyIndefiniteSequence, sizeof(emptyIndefiniteSequence), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1059,7 +1063,7 @@ static void test_decodeName(DWORD dwEncoding) } /* test empty RDN */ bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, emptyRDNs, + ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, emptyRDNs, emptyRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, (BYTE *)&buf, &bufSize); @@ -1075,7 +1079,7 @@ static void test_decodeName(DWORD dwEncoding) } /* test two RDN attrs */ bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNs, + ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNs, twoRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, (BYTE *)&buf, &bufSize); @@ -1099,13 +1103,13 @@ static void test_decodeName(DWORD dwEncoding) } /* test that two RDN attrs with extra bytes succeeds */ bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNsExtraBytes, + ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME, twoRDNsExtraBytes, sizeof(twoRDNsExtraBytes), 0, NULL, NULL, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); /* And, a slightly more complicated name */ buf = NULL; bufSize = 0; - ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs, + ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME, encodedRDNAttrs, sizeof(encodedRDNAttrs), CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -1127,7 +1131,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding) /* test empty name */ bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptySequence, + ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, (BYTE *)&buf, &bufSize); @@ -1143,7 +1147,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding) } /* test empty RDN */ bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptyRDNs, + ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, emptyRDNs, emptyRDNs[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, (BYTE *)&buf, &bufSize); @@ -1159,7 +1163,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding) } /* test two RDN attrs */ bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, twoRDNsNoNull, + ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME, twoRDNsNoNull, sizeof(twoRDNsNoNull), CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, (BYTE *)&buf, &bufSize); @@ -1265,7 +1269,7 @@ static void test_encodeNameValue(DWORD dwEncoding) value.dwValueType = CERT_RDN_ENCODED_BLOB; value.Value.pbData = printableCommonNameValue; value.Value.cbData = sizeof(printableCommonNameValue); - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -1278,7 +1282,7 @@ static void test_encodeNameValue(DWORD dwEncoding) } for (i = 0; i < sizeof(nameValues) / sizeof(nameValues[0]); i++) { - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &nameValues[i].value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "Type %d: CryptEncodeObjectEx failed: %08x\n", @@ -1303,7 +1307,7 @@ static void test_decodeNameValue(DWORD dwEncoding) for (i = 0; i < sizeof(nameValues) / sizeof(nameValues[0]); i++) { - ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, + ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, nameValues[i].encoded, nameValues[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_SHARE_OID_STRING_FLAG, NULL, (BYTE *)&buf, &bufSize); @@ -1350,7 +1354,7 @@ static void test_encodeAltName(DWORD dwEncoding) char oid[] = "1.2.3"; /* Test with empty info */ - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -1361,13 +1365,13 @@ static void test_encodeAltName(DWORD dwEncoding) /* Test with an empty entry */ info.cAltEntry = 1; info.rgAltEntry = &entry; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* Test with an empty pointer */ entry.dwAltNameChoice = CERT_ALT_NAME_URL; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -1377,7 +1381,7 @@ static void test_encodeAltName(DWORD dwEncoding) } /* Test with a real URL */ U(entry).pwszURL = (LPWSTR)url; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -1387,7 +1391,7 @@ static void test_encodeAltName(DWORD dwEncoding) } /* Now with the URL containing an invalid IA5 char */ U(entry).pwszURL = (LPWSTR)nihongoURL; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING, "Expected CRYPT_E_INVALID_IA5_STRING, got %08x\n", GetLastError()); @@ -1397,7 +1401,7 @@ static void test_encodeAltName(DWORD dwEncoding) GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size)); /* Now with the URL missing a scheme */ U(entry).pwszURL = (LPWSTR)dnsName; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -1407,7 +1411,7 @@ static void test_encodeAltName(DWORD dwEncoding) } /* Now with a DNS name */ entry.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -1420,7 +1424,7 @@ static void test_encodeAltName(DWORD dwEncoding) entry.dwAltNameChoice = CERT_ALT_NAME_IP_ADDRESS; U(entry).IPAddress.cbData = sizeof(localhost); U(entry).IPAddress.pbData = (LPBYTE)localhost; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -1431,7 +1435,7 @@ static void test_encodeAltName(DWORD dwEncoding) /* Test with OID */ entry.dwAltNameChoice = CERT_ALT_NAME_REGISTERED_ID; U(entry).pszRegisteredID = oid; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -1443,7 +1447,7 @@ static void test_encodeAltName(DWORD dwEncoding) entry.dwAltNameChoice = CERT_ALT_NAME_DIRECTORY_NAME; U(entry).DirectoryName.cbData = sizeof(encodedCommonName); U(entry).DirectoryName.pbData = (LPBYTE)encodedCommonName; - ret = CryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -1465,18 +1469,18 @@ static void test_decodeAltName(DWORD dwEncoding) CERT_ALT_NAME_INFO *info; /* Test some bogus ones first */ - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, unimplementedType, sizeof(unimplementedType), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_BADTAG, "Expected CRYPT_E_ASN1_BADTAG, got %08x\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, bogusType, sizeof(bogusType), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); /* Now expected cases */ - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1488,7 +1492,7 @@ static void test_decodeAltName(DWORD dwEncoding) info->cAltEntry); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURL, emptyURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1505,10 +1509,10 @@ static void test_decodeAltName(DWORD dwEncoding) "Expected empty URL\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, emptyURLExtraBytes, sizeof(emptyURLExtraBytes), 0, NULL, NULL, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedURL, encodedURL[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1524,7 +1528,7 @@ static void test_decodeAltName(DWORD dwEncoding) ok(!lstrcmpW(U(info->rgAltEntry[0]).pwszURL, url), "Unexpected URL\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDnsName, encodedDnsName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1541,7 +1545,7 @@ static void test_decodeAltName(DWORD dwEncoding) "Unexpected DNS name\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedIPAddr, encodedIPAddr[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1561,7 +1565,7 @@ static void test_decodeAltName(DWORD dwEncoding) sizeof(localhost)), "Unexpected IP address value\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedOidName, sizeof(encodedOidName), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1578,7 +1582,7 @@ static void test_decodeAltName(DWORD dwEncoding) "Expected OID 1.2.3, got %s\n", U(info->rgAltEntry[0]).pszRegisteredID); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ALTERNATE_NAME, encodedDirectoryName, sizeof(encodedDirectoryName), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1677,7 +1681,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) BOOL ret; CERT_NAME_VALUE value; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); @@ -1685,23 +1689,23 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) value.dwValueType = 0; /* aka CERT_RDN_ANY_TYPE */ value.Value.pbData = NULL; value.Value.cbData = 0; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); value.dwValueType = CERT_RDN_ENCODED_BLOB; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); value.dwValueType = CERT_RDN_ANY_TYPE; value.Value.pbData = (LPBYTE)oneW; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); value.Value.cbData = sizeof(oneW); - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); @@ -1709,7 +1713,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) value.dwValueType = CERT_RDN_ENCODED_BLOB; value.Value.pbData = oneUniversal; value.Value.cbData = sizeof(oneUniversal); - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_CHAR_STRING, "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); @@ -1719,7 +1723,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeErrors[i].str; value.dwValueType = unicodeErrors[i].valueType; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == unicodeErrors[i].error, "Value type %d: expected %08x, got %08x\n", value.dwValueType, @@ -1734,7 +1738,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeResults[i].str; value.dwValueType = unicodeResults[i].valueType; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -1755,7 +1759,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) { value.Value.pbData = (LPBYTE)unicodeWeirdness[i].str; value.dwValueType = unicodeWeirdness[i].valueType; - ret = CryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, + ret = pCryptEncodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, &value, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -1787,7 +1791,7 @@ static void test_decodeUnicodeNameValue(DWORD dwEncoding) BOOL ret; DWORD size = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, + ret = pCryptDecodeObjectEx(dwEncoding, X509_UNICODE_NAME_VALUE, unicodeResults[i].encoded.pbData, unicodeResults[i].encoded.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1841,7 +1845,7 @@ static void test_encodeOctets(DWORD dwEncoding) blob.cbData = strlen((const char*)octets[i].val); blob.pbData = (BYTE*)octets[i].val; - ret = CryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_OCTET_STRING, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %d\n", GetLastError()); if (buf) @@ -1867,7 +1871,7 @@ static void test_decodeOctets(DWORD dwEncoding) BOOL ret; DWORD bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, + ret = pCryptDecodeObjectEx(dwEncoding, X509_OCTET_STRING, (BYTE *)octets[i].encoded, octets[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1929,7 +1933,7 @@ static void test_encodeBits(DWORD dwEncoding) blob.cbData = sizeof(bytesToEncode); blob.pbData = (BYTE *)bytesToEncode; blob.cUnusedBits = bits[i].cUnusedBits; - ret = CryptEncodeObjectEx(dwEncoding, X509_BITS, &blob, + ret = pCryptEncodeObjectEx(dwEncoding, X509_BITS, &blob, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -1956,7 +1960,7 @@ static void test_decodeBits(DWORD dwEncoding) /* normal cases */ for (i = 0; i < sizeof(bits) / sizeof(bits[0]); i++) { - ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -1979,7 +1983,7 @@ static void test_decodeBits(DWORD dwEncoding) /* special case: check that something that's valid in BER but not in DER * decodes successfully */ - ret = CryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, ber, ber[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2043,7 +2047,7 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) /* First test with the simpler info2 */ for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++) { - ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, &constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); @@ -2061,7 +2065,7 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) info.SubjectType.cbData = 0; info.fPathLenConstraint = FALSE; info.cSubtreesConstraint = 0; - ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2076,7 +2080,7 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) */ info.cSubtreesConstraint = 1; info.rgSubtreesConstraint = &nameBlob; - ret = CryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2104,7 +2108,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) /* First test with simpler info2 */ for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++) { - ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, constraints2[i].encoded, constraints2[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed for item %d: %08x\n", i, @@ -2121,17 +2125,17 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) } /* Check with the order of encoded elements inverted */ buf = (PBYTE)1; - ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, inverted, inverted[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); ok(!buf, "Expected buf to be set to NULL\n"); /* Check with a non-DER bool */ - ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, badBool.encoded, badBool.encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "pCryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) { CERT_BASIC_CONSTRAINTS2_INFO *info = @@ -2141,13 +2145,13 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) LocalFree(buf); } /* Check with a non-basic constraints value */ - ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, (LPBYTE)encodedCommonName, encodedCommonName[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); /* Now check with the more complex CERT_BASIC_CONSTRAINTS_INFO */ - ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, emptyConstraint, sizeof(emptyConstraint), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -2160,7 +2164,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) ok(info->cSubtreesConstraint == 0, "Expected no subtree constraints\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS, constraintWithDomainName, sizeof(constraintWithDomainName), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -2228,7 +2232,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), modulus1, sizeof(modulus1)); - ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == E_INVALIDARG, @@ -2236,7 +2240,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) /* Now with a bogus reserved field */ hdr->bType = PUBLICKEYBLOB; hdr->reserved = 1; - ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); if (buf) @@ -2249,7 +2253,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) /* Now with a bogus blob version */ hdr->reserved = 0; hdr->bVersion = 0; - ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); if (buf) @@ -2262,7 +2266,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) /* And with a bogus alg ID */ hdr->bVersion = CUR_BLOB_VERSION; hdr->aiKeyAlg = CALG_DES; - ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); if (buf) @@ -2274,11 +2278,11 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) } /* Check a couple of RSA-related OIDs */ hdr->aiKeyAlg = CALG_RSA_KEYX; - ret = CryptEncodeObjectEx(dwEncoding, szOID_RSA_RSA, + ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_RSA, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - ret = CryptEncodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, + ret = pCryptEncodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); @@ -2288,7 +2292,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) { memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen); - ret = CryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptEncodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, toEncode, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2311,18 +2315,18 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) BOOL ret; /* Try with a bad length */ - ret = CryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1], CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08x\n", CRYPT_E_ASN1_EOD); /* Try with a couple of RSA-related OIDs */ - ret = CryptDecodeObjectEx(dwEncoding, szOID_RSA_RSA, + ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_RSA, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, + ret = pCryptDecodeObjectEx(dwEncoding, szOID_RSA_SHA1RSA, rsaPubKeys[0].encoded, rsaPubKeys[0].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, @@ -2331,7 +2335,7 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) for (i = 0; i < sizeof(rsaPubKeys) / sizeof(rsaPubKeys[0]); i++) { bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, + ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, rsaPubKeys[i].encoded, rsaPubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -2394,7 +2398,7 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding) seq.cValue = sizeof(ints) / sizeof(ints[0]); seq.rgValue = blobs; - ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2408,7 +2412,7 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding) */ blobs[0].cbData = times[0].encodedTime[1] + 2; blobs[0].pbData = (BYTE *)times[0].encodedTime; - ret = CryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, + ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2426,7 +2430,7 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence, + ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, intSequence, intSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2446,7 +2450,7 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding) } LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence, + ret = pCryptDecodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, mixedSequence, mixedSequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -2502,7 +2506,7 @@ static void test_encodeExtensions(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = CryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts, + ret = pCryptEncodeObjectEx(dwEncoding, X509_EXTENSIONS, &exts[i].exts, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2526,7 +2530,7 @@ static void test_decodeExtensions(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -2629,7 +2633,7 @@ static void test_encodePublicKeyInfo(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = CryptEncodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = pCryptEncodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, &pubKeys[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); @@ -2686,7 +2690,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) for (i = 0; i < sizeof(pubKeys) / sizeof(pubKeys[0]); i++) { /* The NULL form decodes to the decoded member */ - ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, pubKeys[i].encoded, pubKeys[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -2697,7 +2701,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) LocalFree(buf); } /* The non-NULL form decodes to the original */ - ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, pubKeys[i].encodedNoNull, pubKeys[i].encodedNoNull[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -2708,7 +2712,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) } } /* Test with bogus (not valid DER) parameters */ - ret = CryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, bogusPubKeyInfo, bogusPubKeyInfo[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, @@ -2801,12 +2805,12 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) CERT_EXTENSION ext; /* Test with NULL pvStructInfo */ - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); /* Test with a V1 cert */ - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2818,7 +2822,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) } /* Test v2 cert */ info.dwVersion = CERT_V2; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2829,7 +2833,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) } /* Test v3 cert */ info.dwVersion = CERT_V3; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2844,7 +2848,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.dwVersion = CERT_V1; info.cExtension = 1; info.rgExtension = &criticalExt; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2856,7 +2860,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) /* test v1 cert with a serial number */ info.SerialNumber.cbData = sizeof(serialNum); info.SerialNumber.pbData = (BYTE *)serialNum; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -2869,7 +2873,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.Issuer.pbData = (BYTE *)encodedCommonName; info.Subject.cbData = sizeof(encodedCommonName); info.Subject.pbData = (BYTE *)encodedCommonName; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -2881,7 +2885,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) info.SubjectPublicKeyInfo.Algorithm.pszObjId = oid_rsa_rsa; info.SubjectPublicKeyInfo.PublicKey.cbData = sizeof(aKey); info.SubjectPublicKeyInfo.PublicKey.pbData = (LPBYTE)aKey; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -2904,7 +2908,7 @@ static void test_encodeCertToBeSigned(DWORD dwEncoding) ext.Value.pbData = (BYTE *)octetCommonNameValue; info.cExtension = 1; info.rgExtension = &ext; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -2923,11 +2927,11 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) DWORD size = 0, i; /* Test with NULL pbEncoded */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 0, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 0, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_ASN1_EOD, "Expected CRYPT_E_ASN1_EOD, got %08x\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, NULL, 1, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); @@ -2937,13 +2941,13 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) */ for (i = 0; i < sizeof(corruptCerts) / sizeof(corruptCerts[0]); i++) { - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, corruptCerts[i], corruptCerts[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret, "Expected failure\n"); } /* Now check with serial number, subject and issuer specified */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, bigCert, sizeof(bigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -2967,7 +2971,7 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* Check again with pub key specified */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, v1CertWithPubKey, sizeof(v1CertWithPubKey), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -3029,7 +3033,7 @@ static void test_encodeCert(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &bufSize); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3046,7 +3050,7 @@ static void test_decodeCert(DWORD dwEncoding) BYTE *buf = NULL; DWORD size = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT, signedBigCert, sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3064,7 +3068,7 @@ static void test_decodeCert(DWORD dwEncoding) LocalFree(buf); } /* A signed cert decodes as a CERT_INFO too */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, signedBigCert, sizeof(signedBigCert), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3116,14 +3120,14 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) DWORD size = 0; /* Test with an empty info */ - ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* Test with one empty dist point */ info.cDistPoint = 1; info.rgDistPoint = &point; - ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -3137,7 +3141,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) U(entry).pwszURL = (LPWSTR)nihongoURL; U(point.DistPointName).FullName.cAltEntry = 1; U(point.DistPointName).FullName.rgAltEntry = &entry; - ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_INVALID_IA5_STRING, "Expected CRYPT_E_INVALID_IA5_STRING, got %08x\n", GetLastError()); @@ -3147,7 +3151,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) GET_CERT_ALT_NAME_VALUE_ERR_INDEX(size)); /* A dist point with (just) a valid name */ U(entry).pwszURL = (LPWSTR)url; - ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -3159,7 +3163,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_NO_NAME; point.ReasonFlags.cbData = sizeof(crlReason); point.ReasonFlags.pbData = (LPBYTE)&crlReason; - ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -3171,7 +3175,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) point.ReasonFlags.cbData = 0; point.CRLIssuer.cAltEntry = 1; point.CRLIssuer.rgAltEntry = &entry; - ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -3181,7 +3185,7 @@ static void test_encodeCRLDistPoints(DWORD dwEncoding) } /* A dist point with both a name and an issuer */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; - ret = CryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -3201,7 +3205,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) PCRL_DIST_POINT point; PCERT_ALT_NAME_ENTRY entry; - ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, emptyDistPoint, emptyDistPoint[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (ret) @@ -3219,7 +3223,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrl, distPointWithUrl[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (ret) @@ -3245,7 +3249,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithReason, distPointWithReason[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (ret) @@ -3267,7 +3271,7 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ok(point->CRLIssuer.cAltEntry == 0, "Expected no issuer\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (ret) @@ -3314,7 +3318,7 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) CRL_ISSUING_DIST_POINT point = { { 0 } }; CERT_ALT_NAME_ENTRY entry; - ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) { @@ -3323,7 +3327,7 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) } ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); - ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3335,7 +3339,7 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) /* nonsensical flags */ point.fOnlyContainsUserCerts = TRUE; point.fOnlyContainsCACerts = TRUE; - ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3347,14 +3351,14 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) /* unimplemented name type */ point.fOnlyContainsCACerts = point.fOnlyContainsUserCerts = FALSE; point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_ISSUER_RDN_NAME; - ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* empty name */ point.DistPointName.dwDistPointNameChoice = CRL_DIST_POINT_FULL_NAME; U(point.DistPointName).FullName.cAltEntry = 0; - ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3368,7 +3372,7 @@ static void test_encodeCRLIssuingDistPoint(DWORD dwEncoding) U(entry).pwszURL = (LPWSTR)url; U(point.DistPointName).FullName.cAltEntry = 1; U(point.DistPointName).FullName.rgAltEntry = &entry; - ret = CryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, &point, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3453,7 +3457,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) DWORD size = 0; CRL_ISSUING_DIST_POINT point = { { 0 } }; - ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, emptySequence, emptySequence[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!ret && GetLastError() == ERROR_FILE_NOT_FOUND) @@ -3467,7 +3471,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, badFlagsIDP, badFlagsIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -3477,7 +3481,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, emptyNameIDP, emptyNameIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -3489,7 +3493,7 @@ static void test_decodeCRLIssuingDistPoint(DWORD dwEncoding) compareCRLIssuingDistPoints(&point, (PCRL_ISSUING_DIST_POINT)buf); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ISSUING_DIST_POINT, urlIDP, urlIDP[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -3568,7 +3572,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) CERT_EXTENSION ext; /* Test with a V1 CRL */ - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3579,7 +3583,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) } /* Test v2 CRL */ info.dwVersion = CRL_V2; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3593,7 +3597,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) info.dwVersion = CRL_V1; info.Issuer.cbData = sizeof(encodedCommonName); info.Issuer.pbData = (BYTE *)encodedCommonName; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3604,13 +3608,13 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) } /* v1 CRL with a name and a NULL entry pointer */ info.cCRLEntry = 1; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); /* now set an empty entry */ info.rgCRLEntry = &entry; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -3623,7 +3627,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* an entry with a serial number */ entry.SerialNumber.cbData = sizeof(serialNum); entry.SerialNumber.pbData = (BYTE *)serialNum; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -3636,9 +3640,9 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* an entry with an extension */ entry.cExtension = 1; entry.rgExtension = &criticalExt; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "pCryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) { ok(size == sizeof(v1CRLWithEntryExt), "Wrong size %d\n", size); @@ -3649,7 +3653,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) entry.cExtension = 0; info.cExtension = 1; info.rgExtension = &criticalExt; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3661,7 +3665,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) /* a v2 CRL with an extension, this time non-critical */ info.dwVersion = CRL_V2; info.rgExtension = &nonCriticalExt; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -3676,7 +3680,7 @@ static void test_encodeCRLToBeSigned(DWORD dwEncoding) ext.Value.cbData = sizeof(urlIDP); ext.Value.pbData = (LPBYTE)urlIDP; entry.rgExtension = &ext; - ret = CryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4241,14 +4245,14 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) for (i = 0; i < sizeof(corruptCRLs) / sizeof(corruptCRLs[0]); i++) { - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, corruptCRLs[i], corruptCRLs[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && (GetLastError() == CRYPT_E_ASN1_CORRUPT), "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); } /* at a minimum, a CRL must contain an issuer: */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuer, v1CRLWithIssuer[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4266,13 +4270,13 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* check decoding with an empty CRL entry */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuerAndEmptyEntry, v1CRLWithIssuerAndEmptyEntry[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, "Expected CRYPT_E_ASN1_CORRUPT, got %08x\n", GetLastError()); /* with a real CRL entry */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithIssuerAndEntry, v1CRLWithIssuerAndEntry[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4299,7 +4303,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* a real CRL from verisign that has extensions */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, verisignCRL, sizeof(verisignCRL), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4318,7 +4322,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* another real CRL from verisign that has lots of entries */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, verisignCRLWithLotsOfEntries, sizeof(verisignCRLWithLotsOfEntries), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4334,7 +4338,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* and finally, with an extension */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v1CRLWithExt, sizeof(v1CRLWithExt), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4362,7 +4366,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) info->cExtension); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v2CRLWithExt, sizeof(v2CRLWithExt), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4375,7 +4379,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) LocalFree(buf); } /* And again, with an issuing dist point */ - ret = CryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, + ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, v2CRLWithIssuingDistPoint, sizeof(v2CRLWithIssuingDistPoint), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4405,7 +4409,7 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding) /* Test with empty usage */ usage.cUsageIdentifier = 0; - ret = CryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4417,7 +4421,7 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding) /* Test with a few usages */ usage.cUsageIdentifier = sizeof(keyUsages) / sizeof(keyUsages[0]); usage.rgpszUsageIdentifier = (LPSTR *)keyUsages; - ret = CryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, + ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4434,7 +4438,7 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4448,7 +4452,7 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) usage->cUsageIdentifier); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, + ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4485,7 +4489,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) DWORD size = 0; /* Test with empty id */ - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4497,7 +4501,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) /* With just a key id */ info.KeyId.cbData = sizeof(keyId); info.KeyId.pbData = keyId; - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4510,7 +4514,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) info.KeyId.cbData = 0; info.CertIssuer.cbData = sizeof(encodedCommonName); info.CertIssuer.pbData = (BYTE *)encodedCommonName; - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4524,7 +4528,7 @@ static void test_encodeAuthorityKeyId(DWORD dwEncoding) info.CertIssuer.cbData = 0; info.CertSerialNumber.cbData = sizeof(serialNum); info.CertSerialNumber.pbData = (BYTE *)serialNum; - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4542,7 +4546,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4557,7 +4561,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithId, sizeof(authorityKeyIdWithId), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4574,7 +4578,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithIssuer, sizeof(authorityKeyIdWithIssuer), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4592,7 +4596,7 @@ static void test_decodeAuthorityKeyId(DWORD dwEncoding) ok(info->CertSerialNumber.cbData == 0, "Expected no serial number\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID, authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4625,7 +4629,7 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) DWORD size = 0; /* Test with empty id */ - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4637,7 +4641,7 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) /* With just a key id */ info.KeyId.cbData = sizeof(keyId); info.KeyId.pbData = keyId; - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4651,16 +4655,16 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) info.KeyId.cbData = 0; info.AuthorityCertIssuer.cAltEntry = 1; info.AuthorityCertIssuer.rgAltEntry = &entry; - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* With an issuer name */ entry.dwAltNameChoice = CERT_ALT_NAME_URL; U(entry).pwszURL = (LPWSTR)url; - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); - ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "pCryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) { ok(size == sizeof(authorityKeyIdWithIssuerUrl), "Unexpected size %d\n", @@ -4673,7 +4677,7 @@ static void test_encodeAuthorityKeyId2(DWORD dwEncoding) info.AuthorityCertIssuer.cAltEntry = 0; info.AuthorityCertSerialNumber.cbData = sizeof(serialNum); info.AuthorityCertSerialNumber.pbData = (BYTE *)serialNum; - ret = CryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, + ret = pCryptEncodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (buf) @@ -4691,7 +4695,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) LPBYTE buf = NULL; DWORD size = 0; - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4708,7 +4712,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithId, sizeof(authorityKeyIdWithId), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4727,7 +4731,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithIssuerUrl, sizeof(authorityKeyIdWithIssuerUrl), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4750,7 +4754,7 @@ static void test_decodeAuthorityKeyId2(DWORD dwEncoding) "Expected no serial number\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, + ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_KEY_ID2, authorityKeyIdWithSerial, sizeof(authorityKeyIdWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); @@ -4789,17 +4793,17 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding) char oid1[] = "1.2.3"; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); info.pszObjId = oid1; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); if (buf) @@ -4810,7 +4814,7 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding) } info.Content.pbData = bogusDER; info.Content.cbData = sizeof(bogusDER); - ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed; %x\n", GetLastError()); if (buf) @@ -4821,7 +4825,7 @@ static void test_encodePKCSContentInfo(DWORD dwEncoding) } info.Content.pbData = (BYTE *)ints[0].encoded; info.Content.cbData = ints[0].encoded[1] + 2; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -4868,7 +4872,7 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) DWORD size = 0; CRYPT_CONTENT_INFO *info; - ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, emptyPKCSContentInfo, sizeof(emptyPKCSContentInfo), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -4882,12 +4886,12 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) info->Content.cbData); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, emptyPKCSContentInfoExtraBytes, sizeof(emptyPKCSContentInfoExtraBytes), 0, NULL, NULL, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); SetLastError(0xdeadbeef); - ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, bogusPKCSContentInfo, sizeof(bogusPKCSContentInfo), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as @@ -4897,7 +4901,7 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) GetLastError() == CRYPT_E_ASN1_CORRUPT), "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %x\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, intPKCSContentInfo, sizeof(intPKCSContentInfo), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -4913,7 +4917,7 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) info->Content.cbData), "Unexpected value\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, indefiniteSignedPKCSContent, sizeof(indefiniteSignedPKCSContent), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -4946,17 +4950,17 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) char oid[] = "1.2.3"; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, NULL, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, NULL, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError()); SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); attr.pszObjId = oid; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); if (buf) @@ -4969,7 +4973,7 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) blob.pbData = bogusDER; attr.cValue = 1; attr.rgValue = &blob; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); if (buf) @@ -4980,7 +4984,7 @@ static void test_encodePKCSAttribute(DWORD dwEncoding) } blob.pbData = (BYTE *)ints[0].encoded; blob.cbData = ints[0].encoded[1] + 2; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, &attr, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -4997,7 +5001,7 @@ static void test_decodePKCSAttribute(DWORD dwEncoding) DWORD size = 0; CRYPT_ATTRIBUTE *attr; - ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, emptyPKCSAttr, sizeof(emptyPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -5011,7 +5015,7 @@ static void test_decodePKCSAttribute(DWORD dwEncoding) LocalFree(buf); } SetLastError(0xdeadbeef); - ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, bogusPKCSAttr, sizeof(bogusPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); /* Native fails with CRYPT_E_ASN1_EOD, accept also CRYPT_E_ASN1_CORRUPT as @@ -5021,7 +5025,7 @@ static void test_decodePKCSAttribute(DWORD dwEncoding) GetLastError() == CRYPT_E_ASN1_CORRUPT), "Expected CRYPT_E_ASN1_EOD or CRYPT_E_ASN1_CORRUPT, got %x\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTE, intPKCSAttr, sizeof(intPKCSAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -5056,7 +5060,7 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) DWORD size = 0; char oid1[] = "1.2.3", oid2[] = "1.5.6"; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); if (buf) @@ -5068,12 +5072,12 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) attributes.cAttr = 1; attributes.rgAttr = attr; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", GetLastError()); attr[0].pszObjId = oid1; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) { @@ -5087,7 +5091,7 @@ static void test_encodePKCSAttributes(DWORD dwEncoding) blob.pbData = (BYTE *)ints[0].encoded; blob.cbData = ints[0].encoded[1] + 2; attributes.cAttr = 2; - ret = CryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, &attributes, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %x\n", GetLastError()); if (buf) @@ -5105,7 +5109,7 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) DWORD size = 0; CRYPT_ATTRIBUTES *attributes; - ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, emptyPKCSAttributes, sizeof(emptyPKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -5116,7 +5120,7 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) attributes->cAttr); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, singlePKCSAttributes, sizeof(singlePKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -5131,7 +5135,7 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) "Expected no attributes, got %d\n", attributes->rgAttr[0].cValue); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -5206,7 +5210,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) CRYPT_ATTRIBUTE attr = { oid_common_name, 1, &commonName }; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); @@ -5217,7 +5221,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.Issuer.cbData = sizeof(encodedCommonNameNoNull); info.Issuer.pbData = encodedCommonNameNoNull; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -5238,7 +5242,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.SerialNumber.cbData = sizeof(serialNum); info.SerialNumber.pbData = (BYTE *)serialNum; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -5260,7 +5264,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) } info.HashAlgorithm.pszObjId = oid1; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -5282,7 +5286,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) } info.HashEncryptionAlgorithm.pszObjId = oid2; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -5305,7 +5309,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.EncryptedHash.cbData = sizeof(hash); info.EncryptedHash.pbData = (BYTE *)hash; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -5328,7 +5332,7 @@ static void test_encodePKCSSignerInfo(DWORD dwEncoding) info.AuthAttrs.cAttr = 1; info.AuthAttrs.rgAttr = &attr; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, + ret = pCryptEncodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (!(dwEncoding & PKCS_7_ASN_ENCODING)) ok(!ret && GetLastError() == E_INVALIDARG, @@ -5359,12 +5363,12 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) /* A PKCS signer can't be decoded without a serial number. */ SetLastError(0xdeadbeef); - ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, minimalPKCSSigner, sizeof(minimalPKCSSigner), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == CRYPT_E_ASN1_CORRUPT, "Expected CRYPT_E_ASN1_CORRUPT, got %x\n", GetLastError()); - ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithSerial, sizeof(PKCSSignerWithSerial), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); @@ -5383,7 +5387,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Unexpected value\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHashAlgo, sizeof(PKCSSignerWithHashAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) @@ -5403,7 +5407,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Expected 1.2.3, got %s\n", info->HashAlgorithm.pszObjId); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHashAndEncryptionAlgo, sizeof(PKCSSignerWithHashAndEncryptionAlgo), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); @@ -5426,7 +5430,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Expected 1.5.6, got %s\n", info->HashEncryptionAlgorithm.pszObjId); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithHash, sizeof(PKCSSignerWithHash), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) @@ -5452,7 +5456,7 @@ static void test_decodePKCSSignerInfo(DWORD dwEncoding) "Unexpected value\n"); LocalFree(buf); } - ret = CryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, + ret = pCryptDecodeObjectEx(dwEncoding, PKCS7_SIGNER_INFO, PKCSSignerWithAuthAttr, sizeof(PKCSSignerWithAuthAttr), CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); if (buf) @@ -5503,7 +5507,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LPBYTE buf; DWORD size; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -5515,12 +5519,12 @@ static void test_encodeNameConstraints(DWORD dwEncoding) constraints.cPermittedSubtree = 1; constraints.rgPermittedSubtree = &permitted; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); permitted.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -5534,7 +5538,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) constraints.cExcludedSubtree = 1; constraints.rgExcludedSubtree = &excluded; excluded.Base.dwAltNameChoice = CERT_ALT_NAME_DNS_NAME; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -5545,7 +5549,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LocalFree(buf); } U(excluded.Base).pwszURL = (LPWSTR)url; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -5559,7 +5563,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) U(permitted.Base).IPAddress.cbData = sizeof(encodedIPAddr); U(permitted.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; constraints.cPermittedSubtree = 1; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -5571,7 +5575,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) LocalFree(buf); } permitted.dwMinimum = 5; - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -5585,7 +5589,7 @@ static void test_encodeNameConstraints(DWORD dwEncoding) permitted.fMaximum = TRUE; permitted.dwMaximum = 3; SetLastError(0xdeadbeef); - ret = CryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, + ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, &constraints, CRYPT_ENCODE_ALLOC_FLAG, NULL, (BYTE *)&buf, &size); ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError()); if (ret) @@ -5652,7 +5656,7 @@ static void test_decodeNameConstraints(DWORD dwEncoding) { DWORD size; - ret = CryptDecodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, + ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_CONSTRAINTS, encodedNameConstraints[i].encoded.pbData, encodedNameConstraints[i].encoded.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &constraints, &size); @@ -5852,8 +5856,18 @@ START_TEST(encode) { static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING }; + HMODULE hCrypt32; DWORD i; + hCrypt32 = GetModuleHandleA("crypt32.dll"); + pCryptDecodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptDecodeObjectEx"); + pCryptEncodeObjectEx = (void*)GetProcAddress(hCrypt32, "CryptEncodeObjectEx"); + if (!pCryptDecodeObjectEx || !pCryptEncodeObjectEx) + { + skip("CryptDecodeObjectEx() is not available\n"); + return; + } + for (i = 0; i < sizeof(encodings) / sizeof(encodings[0]); i++) { test_encodeInt(encodings[i]); diff --git a/dlls/crypt32/tests/oid.c b/dlls/crypt32/tests/oid.c index f4f11f08ebc..b4950fcda2e 100644 --- a/dlls/crypt32/tests/oid.c +++ b/dlls/crypt32/tests/oid.c @@ -27,6 +27,10 @@ #include "wine/test.h" + +static BOOL (WINAPI *pCryptEnumOIDInfo)(DWORD,DWORD,void*,PFN_CRYPT_ENUM_OID_INFO); + + struct OIDToAlgID { LPCSTR oid; @@ -471,14 +475,20 @@ static void test_enumOIDInfo(void) BOOL ret; DWORD count = 0; + if (!pCryptEnumOIDInfo) + { + skip("CryptEnumOIDInfo() is not available\n"); + return; + } + /* This crashes - ret = CryptEnumOIDInfo(7, 0, NULL, NULL); + ret = pCryptEnumOIDInfo(7, 0, NULL, NULL); */ /* Silly tests, check that more than one thing is enumerated */ - ret = CryptEnumOIDInfo(0, 0, &count, countOidInfo); + ret = pCryptEnumOIDInfo(0, 0, &count, countOidInfo); ok(ret && count > 0, "Expected more than item enumerated\n"); - ret = CryptEnumOIDInfo(0, 0, NULL, noOidInfo); + ret = pCryptEnumOIDInfo(0, 0, NULL, noOidInfo); ok(!ret, "Expected FALSE\n"); } @@ -532,6 +542,9 @@ static void test_findOIDInfo(void) START_TEST(oid) { + HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); + pCryptEnumOIDInfo = (void*)GetProcAddress(hCrypt32, "CryptEnumOIDInfo"); + testOIDToAlgID(); testAlgIDToOID(); test_enumOIDInfo(); diff --git a/dlls/crypt32/tests/protectdata.c b/dlls/crypt32/tests/protectdata.c index 64ffa68cedf..0dfad9aaf30 100644 --- a/dlls/crypt32/tests/protectdata.c +++ b/dlls/crypt32/tests/protectdata.c @@ -27,6 +27,9 @@ #include "wine/test.h" +static BOOL (WINAPI *pCryptProtectData)(DATA_BLOB*,LPCWSTR,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); +static BOOL (WINAPI *pCryptUnprotectData)(DATA_BLOB*,LPWSTR*,DATA_BLOB*,PVOID,CRYPTPROTECT_PROMPTSTRUCT*,DWORD,DATA_BLOB*); + static char secret[] = "I am a super secret string that no one can see!"; static char secret2[] = "I am a super secret string indescribable string"; static char key[] = "Wibble wibble wibble"; @@ -49,13 +52,13 @@ static void test_cryptprotectdata(void) entropy.cbData=strlen(key)+1; SetLastError(0xDEADBEEF); - protected = CryptProtectData(NULL,desc,NULL,NULL,NULL,0,&cipher); + protected = pCryptProtectData(NULL,desc,NULL,NULL,NULL,0,&cipher); ok(!protected, "Encrypting without plain data source.\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); SetLastError(0xDEADBEEF); - protected = CryptProtectData(&plain,desc,NULL,NULL,NULL,0,NULL); + protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,NULL); ok(!protected, "Encrypting without cipher destination.\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); @@ -65,7 +68,7 @@ static void test_cryptprotectdata(void) /* without entropy */ SetLastError(0xDEADBEEF); - protected = CryptProtectData(&plain,desc,NULL,NULL,NULL,0,&cipher); + protected = pCryptProtectData(&plain,desc,NULL,NULL,NULL,0,&cipher); ok(protected, "Encrypting without entropy.\n"); r = GetLastError(); ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r); @@ -75,7 +78,7 @@ static void test_cryptprotectdata(void) /* with entropy */ SetLastError(0xDEADBEEF); - protected = CryptProtectData(&plain,desc,&entropy,NULL,NULL,0,&cipher_entropy); + protected = pCryptProtectData(&plain,desc,&entropy,NULL,NULL,0,&cipher_entropy); ok(protected, "Encrypting with entropy.\n"); r = GetLastError(); ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r); @@ -87,7 +90,7 @@ static void test_cryptprotectdata(void) plain.pbData=(void*)secret2; plain.cbData=strlen(secret2)+1; SetLastError(0xDEADBEEF); - protected = CryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc); + protected = pCryptProtectData(&plain,NULL,&entropy,NULL,NULL,0,&cipher_no_desc); ok(protected, "Encrypting with entropy and no description.\n"); r = GetLastError(); ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r); @@ -111,13 +114,13 @@ static void test_cryptunprotectdata(void) plain.cbData=0; SetLastError(0xDEADBEEF); - okay = CryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL); + okay = pCryptUnprotectData(&cipher,NULL,NULL,NULL,NULL,0,NULL); ok(!okay,"Decrypting without destination\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); SetLastError(0xDEADBEEF); - okay = CryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain); + okay = pCryptUnprotectData(NULL,NULL,NULL,NULL,NULL,0,&plain); ok(!okay,"Decrypting without source\n"); r = GetLastError(); ok(r == ERROR_INVALID_PARAMETER, "Wrong (%u) GetLastError seen\n",r); @@ -126,7 +129,7 @@ static void test_cryptunprotectdata(void) plain.cbData=0; SetLastError(0xDEADBEEF); - okay = CryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain); + okay = pCryptUnprotectData(&cipher_entropy,NULL,NULL,NULL,NULL,0,&plain); ok(!okay,"Decrypting without needed entropy\n"); r = GetLastError(); ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n", r); @@ -137,7 +140,7 @@ static void test_cryptunprotectdata(void) /* without entropy */ SetLastError(0xDEADBEEF); - okay = CryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain); + okay = pCryptUnprotectData(&cipher,&data_desc,NULL,NULL,NULL,0,&plain); ok(okay,"Decrypting without entropy\n"); r = GetLastError(); ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r); @@ -157,14 +160,14 @@ static void test_cryptunprotectdata(void) /* with wrong entropy */ SetLastError(0xDEADBEEF); - okay = CryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain); + okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&cipher_entropy,NULL,NULL,0,&plain); ok(!okay,"Decrypting with wrong entropy\n"); r = GetLastError(); ok(r == ERROR_INVALID_DATA, "Wrong (%u) GetLastError seen\n",r); /* with entropy */ SetLastError(0xDEADBEEF); - okay = CryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain); + okay = pCryptUnprotectData(&cipher_entropy,&data_desc,&entropy,NULL,NULL,0,&plain); ok(okay,"Decrypting with entropy\n"); r = GetLastError(); ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r); @@ -184,7 +187,7 @@ static void test_cryptunprotectdata(void) /* with entropy but no description */ SetLastError(0xDEADBEEF); - okay = CryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain); + okay = pCryptUnprotectData(&cipher_no_desc,&data_desc,&entropy,NULL,NULL,0,&plain); ok(okay,"Decrypting with entropy and no description\n"); r = GetLastError(); ok(r == ERROR_SUCCESS, "Wrong (%u) GetLastError seen\n",r); @@ -204,8 +207,17 @@ static void test_cryptunprotectdata(void) START_TEST(protectdata) { - protected=FALSE; + HMODULE hCrypt32 = GetModuleHandleA("crypt32.dll"); + hCrypt32 = GetModuleHandleA("crypt32.dll"); + pCryptProtectData = (void*)GetProcAddress(hCrypt32, "CryptProtectData"); + pCryptUnprotectData = (void*)GetProcAddress(hCrypt32, "CryptUnprotectData"); + if (!pCryptProtectData || !pCryptUnprotectData) + { + skip("Crypt(Un)ProtectData() is not available\n"); + return; + } + protected=FALSE; test_cryptprotectdata(); test_cryptunprotectdata(); diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c index 05ea5e069e7..95c8054d0a2 100644 --- a/dlls/crypt32/tests/store.c +++ b/dlls/crypt32/tests/store.c @@ -94,6 +94,15 @@ static const BYTE bigCert2[] = { 0x30, 0x7a, 0x02, 0x01, 0x01, 0x30, 0x02, 0x06, 0x00, 0xa3, 0x16, 0x30, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01 }; + +static BOOL (WINAPI *pCertAddStoreToCollection)(HCERTSTORE,HCERTSTORE,DWORD,DWORD); +static BOOL (WINAPI *pCertControlStore)(HCERTSTORE,DWORD,DWORD,void const*); +static PCCRL_CONTEXT (WINAPI *pCertEnumCRLsInStore)(HCERTSTORE,PCCRL_CONTEXT); +static BOOL (WINAPI *pCertEnumSystemStore)(DWORD,void*,void*,PFN_CERT_ENUM_SYSTEM_STORE); +static BOOL (WINAPI *pCertGetStoreProperty)(HCERTSTORE,DWORD,void*,DWORD*); +static void (WINAPI *pCertRemoveStoreFromCollection)(HCERTSTORE,HCERTSTORE); +static BOOL (WINAPI *pCertSetStoreProperty)(HCERTSTORE,DWORD,DWORD,const void*); + static void testMemStore(void) { HCERTSTORE store1, store2; @@ -274,6 +283,12 @@ static void testCollectionStore(void) PCCERT_CONTEXT context; BOOL ret; + if (!pCertAddStoreToCollection) + { + skip("CertAddStoreToCollection() is not available\n"); + return; + } + collection = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); @@ -290,7 +305,7 @@ static void testCollectionStore(void) bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); /* Add the memory store to the collection, without allowing adding */ - ret = CertAddStoreToCollection(collection, store1, 0, 0); + ret = pCertAddStoreToCollection(collection, store1, 0, 0); ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); /* Verify the cert is in the collection */ context = CertEnumCertificatesInStore(collection, NULL); @@ -310,26 +325,26 @@ static void testCollectionStore(void) store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); /* Try adding a store to a non-collection store */ - ret = CertAddStoreToCollection(store1, store2, + ret = pCertAddStoreToCollection(store1, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* Try adding some bogus stores */ /* This crashes in Windows - ret = CertAddStoreToCollection(0, store2, + ret = pCertAddStoreToCollection(0, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); */ /* This "succeeds"... */ - ret = CertAddStoreToCollection(collection, 0, + ret = pCertAddStoreToCollection(collection, 0, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); /* while this crashes. - ret = CertAddStoreToCollection(collection, 1, + ret = pCertAddStoreToCollection(collection, 1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); */ /* Add it to the collection, this time allowing adding */ - ret = CertAddStoreToCollection(collection, store2, + ret = pCertAddStoreToCollection(collection, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); /* Check that adding to the collection is allowed */ @@ -397,7 +412,7 @@ static void testCollectionStore(void) /* Adding a collection to a collection is legal */ collection2 = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - ret = CertAddStoreToCollection(collection2, collection, + ret = pCertAddStoreToCollection(collection2, collection, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); /* check the contents of collection2 */ @@ -457,10 +472,10 @@ static void testCollectionStore(void) CERT_STORE_CREATE_NEW_FLAG, NULL); ok(collection != 0, "CertOpenStore failed: %08x\n", GetLastError()); - ret = CertAddStoreToCollection(collection, store1, + ret = pCertAddStoreToCollection(collection, store1, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); - ret = CertAddStoreToCollection(collection, store2, + ret = pCertAddStoreToCollection(collection, store2, CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); @@ -528,25 +543,32 @@ static void testCollectionStore(void) ok(context == NULL, "Unexpected cert\n"); } - /* Finally, test removing stores from the collection. No return value, so - * it's a bit funny to test. - */ - /* This crashes - CertRemoveStoreFromCollection(NULL, NULL); - */ - /* This "succeeds," no crash, no last error set */ - SetLastError(0xdeadbeef); - CertRemoveStoreFromCollection(store2, collection); - ok(GetLastError() == 0xdeadbeef, - "Didn't expect an error to be set: %08x\n", GetLastError()); - - /* After removing store2, the collection should be empty */ - SetLastError(0xdeadbeef); - CertRemoveStoreFromCollection(collection, store2); - ok(GetLastError() == 0xdeadbeef, - "Didn't expect an error to be set: %08x\n", GetLastError()); - context = CertEnumCertificatesInStore(collection, NULL); - ok(!context, "Unexpected cert\n"); + if (!pCertRemoveStoreFromCollection) + { + skip("CertRemoveStoreFromCollection() is not available\n"); + } + else + { + /* Finally, test removing stores from the collection. No return + * value, so it's a bit funny to test. + */ + /* This crashes + * pCertRemoveStoreFromCollection(NULL, NULL); + */ + /* This "succeeds," no crash, no last error set */ + SetLastError(0xdeadbeef); + pCertRemoveStoreFromCollection(store2, collection); + ok(GetLastError() == 0xdeadbeef, + "Didn't expect an error to be set: %08x\n", GetLastError()); + + /* After removing store2, the collection should be empty */ + SetLastError(0xdeadbeef); + pCertRemoveStoreFromCollection(collection, store2); + ok(GetLastError() == 0xdeadbeef, + "Didn't expect an error to be set: %08x\n", GetLastError()); + context = CertEnumCertificatesInStore(collection, NULL); + ok(!context, "Unexpected cert\n"); + } CertCloseStore(collection, 0); CertCloseStore(store2, 0); @@ -614,6 +636,13 @@ static void testRegStore(void) todo_wine ok(store != 0, "CertOpenStore failed: %08x\n", GetLastError()); CertCloseStore(store, 0); + /* It looks like the remainder pretty much needs CertControlStore() */ + if (!pCertControlStore) + { + skip("CertControlStore() is not available\n"); + return; + } + rc = RegCreateKeyExA(HKEY_CURRENT_USER, tempKey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL); ok(!rc, "RegCreateKeyExA failed: %d\n", rc); @@ -637,7 +666,7 @@ static void testRegStore(void) ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); /* so flush the cache to force a commit.. */ - ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* and check that the expected subkey was written. */ size = sizeof(hash); @@ -696,7 +725,7 @@ static void testRegStore(void) ok(context != NULL, "Expected a cert context\n"); if (context) CertDeleteCertificateFromStore(context); - ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* Add a serialized cert with a bogus hash directly to the registry */ @@ -733,7 +762,7 @@ static void testRegStore(void) sizeof(buf)); ok(!rc, "RegSetValueExA failed: %d\n", rc); - ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* Make sure the bogus hash cert gets loaded. */ @@ -790,7 +819,7 @@ static void testRegStore(void) sizeof(buf)); ok(!rc, "RegSetValueExA failed: %d\n", rc); - ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* and make sure just one cert still gets loaded. */ @@ -811,7 +840,7 @@ static void testRegStore(void) sizeof(buf)); ok(!rc, "RegSetValueExA failed: %d\n", rc); - ret = CertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_RESYNC, NULL); ok(ret, "CertControlStore failed: %08x\n", GetLastError()); /* and make sure two certs get loaded. */ @@ -893,10 +922,12 @@ static void testSystemRegStore(void) CERT_STORE_CREATE_NEW_FLAG, NULL); if (memStore) { - BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0); - - ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + if (pCertAddStoreToCollection) + { + BOOL ret = pCertAddStoreToCollection(store, memStore, 0, 0); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08x\n", GetLastError()); + } CertCloseStore(memStore, 0); } CertCloseStore(store, 0); @@ -984,10 +1015,12 @@ static void testSystemStore(void) /* Check that it's a collection store */ if (memStore) { - BOOL ret = CertAddStoreToCollection(store, memStore, 0, 0); - - /* FIXME: this'll fail on NT4, but what error will it give? */ - ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + if (pCertAddStoreToCollection) + { + BOOL ret = pCertAddStoreToCollection(store, memStore, 0, 0); + /* FIXME: this'll fail on NT4, but what error will it give? */ + ok(ret, "CertAddStoreToCollection failed: %08x\n", GetLastError()); + } CertCloseStore(memStore, 0); } CertCloseStore(store, 0); @@ -1073,7 +1106,13 @@ static void testFileStore(void) BOOL ret; PCCERT_CONTEXT cert; HANDLE file; - + + if (!pCertControlStore) + { + skip("CertControlStore() is not available\n"); + return; + } + store = CertOpenStore(CERT_STORE_PROV_FILE, 0, 0, 0, NULL); ok(!store && GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %08x\n", GetLastError()); @@ -1109,7 +1148,7 @@ static void testFileStore(void) /* apparently allows adding certificates.. */ ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); /* but not commits.. */ - ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); /* It still has certs in memory.. */ @@ -1133,7 +1172,7 @@ static void testFileStore(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); - ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); CertCloseStore(store, 0); @@ -1148,7 +1187,7 @@ static void testFileStore(void) ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); ok(ret, "CertAddEncodedCertificateToStore failed: %d\n", ret); - ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "Expected ERROR_CALL_NOT_IMPLEMENTED, got %08x\n", GetLastError()); CertCloseStore(store, 0); @@ -1164,7 +1203,7 @@ static void testFileStore(void) ok(ret, "CertAddEncodedCertificateToStore failed: %08x\n", GetLastError()); /* with commits enabled, commit is allowed */ - ret = CertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); + ret = pCertControlStore(store, 0, CERT_STORE_CTRL_COMMIT, NULL); ok(ret, "CertControlStore failed: %d\n", ret); compareFile(filename, serializedStoreWithCert, sizeof(serializedStoreWithCert)); @@ -1248,8 +1287,11 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - crl = CertEnumCRLsInStore(store, NULL); - ok(!crl, "Expected no CRLs\n"); + if (pCertEnumCRLsInStore) + { + crl = pCertEnumCRLsInStore(store, NULL); + ok(!crl, "Expected no CRLs\n"); + } CertCloseStore(store, 0); DeleteFileW(filename); @@ -1269,8 +1311,11 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - crl = CertEnumCRLsInStore(store, NULL); - ok(!crl, "Expected no CRLs\n"); + if (pCertEnumCRLsInStore) + { + crl = pCertEnumCRLsInStore(store, NULL); + ok(!crl, "Expected no CRLs\n"); + } CertCloseStore(store, 0); DeleteFileW(filename); @@ -1290,10 +1335,13 @@ static void testFileNameStore(void) GetLastError()); cert = CertEnumCertificatesInStore(store, cert); ok(!cert, "Expected only one cert\n"); - crl = CertEnumCRLsInStore(store, NULL); - ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError()); - crl = CertEnumCRLsInStore(store, crl); - ok(!crl, "Expected only one CRL\n"); + if (pCertEnumCRLsInStore) + { + crl = pCertEnumCRLsInStore(store, NULL); + ok(crl != NULL, "CertEnumCRLsInStore failed: %08x\n", GetLastError()); + crl = pCertEnumCRLsInStore(store, crl); + ok(!crl, "Expected only one CRL\n"); + } CertCloseStore(store, 0); /* Don't delete it this time, the next test uses it */ @@ -1416,13 +1464,16 @@ static void testMessageStore(void) } while (cert); ok(count == 0, "Expected 0 certificates, got %d\n", count); - count = 0; - do { - crl = CertEnumCRLsInStore(store, crl); - if (crl) - count++; - } while (crl); - ok(count == 0, "Expected 0 CRLs, got %d\n", count); + if (pCertEnumCRLsInStore) + { + count = 0; + do { + crl = pCertEnumCRLsInStore(store, crl); + if (crl) + count++; + } while (crl); + ok(count == 0, "Expected 0 CRLs, got %d\n", count); + } /* Can add certs to a message store */ ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, @@ -1464,13 +1515,16 @@ static void testMessageStore(void) } while (cert); ok(count == 1, "Expected 1 certificate, got %d\n", count); - count = 0; - do { - crl = CertEnumCRLsInStore(store, crl); - if (crl) - count++; - } while (crl); - ok(count == 1, "Expected 1 CRL, got %d\n", count); + if (pCertEnumCRLsInStore) + { + count = 0; + do { + crl = pCertEnumCRLsInStore(store, crl); + if (crl) + count++; + } while (crl); + ok(count == 1, "Expected 1 CRL, got %d\n", count); + } CertCloseStore(store, 0); } /* Encoding appears to be ignored */ @@ -1534,17 +1588,23 @@ static void testCertEnumSystemStore(void) BOOL ret; struct EnumSystemStoreInfo info = { FALSE, 0 }; + if (!pCertEnumSystemStore) + { + skip("CertEnumSystemStore() is not available\n"); + return; + } + SetLastError(0xdeadbeef); - ret = CertEnumSystemStore(0, NULL, NULL, NULL); + ret = pCertEnumSystemStore(0, NULL, NULL, NULL); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); /* Crashes - ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL, + ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, NULL, NULL); */ SetLastError(0xdeadbeef); - ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, + ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, enumSystemStoreCB); /* Callback returning FALSE stops enumeration */ ok(!ret, "Expected CertEnumSystemStore to stop\n"); @@ -1553,7 +1613,7 @@ static void testCertEnumSystemStore(void) info.goOn = TRUE; info.storeCount = 0; - ret = CertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, + ret = pCertEnumSystemStore(CERT_SYSTEM_STORE_LOCAL_MACHINE, NULL, &info, enumSystemStoreCB); ok(ret, "CertEnumSystemStore failed: %08x\n", GetLastError()); /* There should always be at least My, Root, and CA stores */ @@ -1568,52 +1628,58 @@ static void testStoreProperty(void) DWORD propID, size = 0, state; CRYPT_DATA_BLOB blob; + if (!pCertGetStoreProperty || !pCertSetStoreProperty) + { + skip("CertGet/SetStoreProperty() is not available\n"); + return; + } + /* Crash - ret = CertGetStoreProperty(NULL, 0, NULL, NULL); - ret = CertGetStoreProperty(NULL, 0, NULL, &size); - ret = CertGetStoreProperty(store, 0, NULL, NULL); + ret = pCertGetStoreProperty(NULL, 0, NULL, NULL); + ret = pCertGetStoreProperty(NULL, 0, NULL, &size); + ret = pCertGetStoreProperty(store, 0, NULL, NULL); */ store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); /* Check a missing prop ID */ SetLastError(0xdeadbeef); - ret = CertGetStoreProperty(store, 0, NULL, &size); + ret = pCertGetStoreProperty(store, 0, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); /* Contrary to MSDN, CERT_ACCESS_STATE_PROP_ID is supported for stores.. */ size = sizeof(state); - ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); + ret = pCertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n", GetLastError()); ok(!state, "Expected a non-persisted store\n"); /* and CERT_STORE_LOCALIZED_NAME_PROP_ID isn't supported by default. */ size = 0; - ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, + ret = pCertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); /* Delete an arbitrary property on a store */ - ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); + ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); /* Set an arbitrary property on a store */ blob.pbData = (LPBYTE)&state; blob.cbData = sizeof(state); - ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob); + ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, &blob); ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); /* Get an arbitrary property that's been set */ - ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); + ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError()); ok(size == sizeof(state), "Unexpected data size %d\n", size); - ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size); + ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, &propID, &size); ok(ret, "CertGetStoreProperty failed: %08x\n", GetLastError()); ok(propID == state, "CertGetStoreProperty got the wrong value\n"); /* Delete it again */ - ret = CertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); + ret = pCertSetStoreProperty(store, CERT_FIRST_USER_PROP_ID, 0, NULL); ok(ret, "CertSetStoreProperty failed: %08x\n", GetLastError()); /* And check that it's missing */ SetLastError(0xdeadbeef); - ret = CertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); + ret = pCertGetStoreProperty(store, CERT_FIRST_USER_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); CertCloseStore(store, 0); @@ -1621,13 +1687,13 @@ static void testStoreProperty(void) /* Recheck on the My store.. */ store = CertOpenSystemStoreW(0, MyW); size = sizeof(state); - ret = CertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); + ret = pCertGetStoreProperty(store, CERT_ACCESS_STATE_PROP_ID, &state, &size); ok(ret, "CertGetStoreProperty failed for CERT_ACCESS_STATE_PROP_ID: %08x\n", GetLastError()); ok(state, "Expected a persisted store\n"); SetLastError(0xdeadbeef); size = 0; - ret = CertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, + ret = pCertGetStoreProperty(store, CERT_STORE_LOCALIZED_NAME_PROP_ID, NULL, &size); ok(!ret && GetLastError() == CRYPT_E_NOT_FOUND, "Expected CRYPT_E_NOT_FOUND, got %08x\n", GetLastError()); @@ -1807,7 +1873,7 @@ static DWORD countCRLsInStore(HCERTSTORE store) DWORD crls = 0; do { - crl = CertEnumCRLsInStore(store, crl); + crl = pCertEnumCRLsInStore(store, crl); if (crl) crls++; } while (crl); @@ -1869,8 +1935,11 @@ static void test_I_UpdateStore(void) ok(ret, "I_CertUpdateStore failed: %08x\n", GetLastError()); certs = countCertsInStore(store1); ok(certs == 1, "Expected 1 cert, got %d\n", certs); - certs = countCRLsInStore(store1); - ok(certs == 1, "Expected 1 CRL, got %d\n", certs); + if (pCertEnumCRLsInStore) + { + certs = countCRLsInStore(store1); + ok(certs == 1, "Expected 1 CRL, got %d\n", certs); + } CertDeleteCertificateFromStore(cert); /* If a context is deleted from store2, I_CertUpdateStore delets it @@ -1888,6 +1957,17 @@ static void test_I_UpdateStore(void) START_TEST(store) { + HMODULE hdll; + + hdll = GetModuleHandleA("Crypt32.dll"); + pCertAddStoreToCollection = (void*)GetProcAddress(hdll, "CertAddStoreToCollection"); + pCertControlStore = (void*)GetProcAddress(hdll, "CertControlStore"); + pCertEnumCRLsInStore = (void*)GetProcAddress(hdll, "CertEnumCRLsInStore"); + pCertEnumSystemStore = (void*)GetProcAddress(hdll, "CertEnumSystemStore"); + pCertGetStoreProperty = (void*)GetProcAddress(hdll, "CertGetStoreProperty"); + pCertRemoveStoreFromCollection = (void*)GetProcAddress(hdll, "CertRemoveStoreFromCollection"); + pCertSetStoreProperty = (void*)GetProcAddress(hdll, "CertSetStoreProperty"); + /* various combinations of CertOpenStore */ testMemStore(); testCollectionStore(); diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 205120e46c7..55ebe83f4bb 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -106,6 +106,7 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) { for(i = 0; i < This->numConvertedDecls; i++) { IWineD3DVertexDeclaration_Release(This->decls[i].decl); } + HeapFree(GetProcessHeap(), 0, This->decls); IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroyDepthStencilSurface, D3D8CB_DestroySwapChain); IWineD3DDevice_Release(This->WineD3DDevice); diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index 744e623e2d7..d1e21923710 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -800,5 +800,10 @@ START_TEST(visual) } cleanup: - if(device_ptr) IDirect3DDevice8_Release(device_ptr); + if(device_ptr) { + D3DDEVICE_CREATION_PARAMETERS creation_parameters; + IDirect3DDevice8_GetCreationParameters(device_ptr, &creation_parameters); + IDirect3DDevice8_Release(device_ptr); + DestroyWindow(creation_parameters.hFocusWindow); + } } diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 261a3ffc8b2..f4024a21325 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1128,6 +1128,7 @@ IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD if (hr != S_OK) return NULL; hr = IDirect3DDevice9Impl_CreateVertexDeclaration((IDirect3DDevice9 *) This, elements, &pDecl); + HeapFree(GetProcessHeap(), 0, elements); /* CreateVertexDeclaration makes a copy */ if (hr != S_OK) return NULL; if(This->declArraySize == This->numConvertedDecls) { diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec index 9dca39bc0aa..af78fb26d8b 100644 --- a/dlls/d3dx8/d3dx8.spec +++ b/dlls/d3dx8/d3dx8.spec @@ -53,21 +53,21 @@ @ stub D3DXQuaternionRotationMatrix @ stub D3DXQuaternionRotationAxis @ stub D3DXQuaternionRotationYawPitchRoll -@ stub D3DXQuaternionMultiply +@ stdcall D3DXQuaternionMultiply(ptr ptr ptr) @ stdcall D3DXQuaternionNormalize(ptr ptr) -@ stub D3DXQuaternionInverse +@ stdcall D3DXQuaternionInverse(ptr ptr) @ stub D3DXQuaternionLn @ stub D3DXQuaternionExp -@ stub D3DXQuaternionSlerp -@ stub D3DXQuaternionSquad -@ stub D3DXQuaternionBaryCentric +@ stdcall D3DXQuaternionSlerp(ptr ptr ptr long) +@ stdcall D3DXQuaternionSquad(ptr ptr ptr ptr ptr long) +@ stdcall D3DXQuaternionBaryCentric(ptr ptr ptr ptr long long) @ stdcall D3DXPlaneNormalize(ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) -@ stub D3DXPlaneFromPointNormal -@ stub D3DXPlaneFromPoints -@ stub D3DXPlaneTransform -@ stub D3DXColorAdjustSaturation -@ stub D3DXColorAdjustContrast +@ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) +@ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) +@ stdcall D3DXPlaneTransform(ptr ptr ptr) +@ stdcall D3DXColorAdjustSaturation(ptr ptr long) +@ stdcall D3DXColorAdjustContrast(ptr ptr long) @ stub D3DXCreateMatrixStack @ stdcall D3DXCreateFont(ptr ptr ptr) @ stub D3DXCreateFontIndirect diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c index cb6789a0aa6..e907be14022 100644 --- a/dlls/d3dx8/math.c +++ b/dlls/d3dx8/math.c @@ -32,6 +32,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx8); +/*_________________D3DXColor____________________*/ + +D3DXCOLOR* WINAPI D3DXColorAdjustContrast(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, FLOAT s) +{ + pout->r = 0.5f + s * (pc->r - 0.5f); + pout->g = 0.5f + s * (pc->g - 0.5f); + pout->b = 0.5f + s * (pc->b - 0.5f); + pout->a = pc->a; + return pout; +} + +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, FLOAT s) +{ + FLOAT grey; + + grey = pc->r * 0.2125f + pc->g * 0.7154f + pc->b * 0.0721f; + pout->r = grey + s * (pc->r - grey); + pout->g = grey + s * (pc->g - grey); + pout->b = grey + s * (pc->b - grey); + pout->a = pc->a; + return pout; +} + /*_________________D3DXMatrix____________________*/ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *pout, float scaling, D3DXVECTOR3 *rotationcenter, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation) @@ -482,6 +505,29 @@ D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm) /*_________________D3DXPLANE________________*/ +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal(D3DXPLANE *pout, CONST D3DXVECTOR3 *pvpoint, CONST D3DXVECTOR3 *pvnormal) +{ + pout->a = pvnormal->x; + pout->b = pvnormal->y; + pout->c = pvnormal->z; + pout->d = -D3DXVec3Dot(pvpoint, pvnormal); + return pout; +} + +D3DXPLANE* WINAPI D3DXPlaneFromPoints(D3DXPLANE *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3) +{ + D3DXVECTOR3 edge1, edge2, normal, Nnormal; + + edge1.x = 0.0f; edge1.y = 0.0f; edge1.z = 0.0f; + edge2.x = 0.0f; edge2.y = 0.0f; edge2.z = 0.0f; + D3DXVec3Subtract(&edge1, pv2, pv1); + D3DXVec3Subtract(&edge2, pv3, pv1); + D3DXVec3Cross(&normal, &edge1, &edge2); + D3DXVec3Normalize(&Nnormal, &normal); + D3DXPlaneFromPointNormal(pout, pv1, &Nnormal); + return pout; +} + D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine(D3DXVECTOR3 *pout, CONST D3DXPLANE *pp, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2) { D3DXVECTOR3 direction, normal; @@ -524,8 +570,57 @@ D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp) return pout; } +D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *pplane, CONST D3DXMATRIX *pm) +{ + pout->a = pm->u.m[0][0] * pplane->a + pm->u.m[1][0] * pplane->b + pm->u.m[2][0] * pplane->c + pm->u.m[3][0] * pplane->d; + pout->b = pm->u.m[0][1] * pplane->a + pm->u.m[1][1] * pplane->b + pm->u.m[2][1] * pplane->c + pm->u.m[3][1] * pplane->d; + pout->c = pm->u.m[0][2] * pplane->a + pm->u.m[1][2] * pplane->b + pm->u.m[2][2] * pplane->c + pm->u.m[3][2] * pplane->d; + pout->d = pm->u.m[0][3] * pplane->a + pm->u.m[1][3] * pplane->b + pm->u.m[2][3] * pplane->c + pm->u.m[3][3] * pplane->d; + return pout; +} + /*_________________D3DXQUATERNION________________*/ +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, FLOAT f, FLOAT g) +{ + D3DXQUATERNION temp1, temp2; + D3DXQuaternionSlerp(pout, D3DXQuaternionSlerp(&temp1, pq1, pq2, f + g), D3DXQuaternionSlerp(&temp2, pq1, pq3, f+g), g / (f + g)); + return pout; +} + +D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) +{ + D3DXQUATERNION temp; + FLOAT norm; + + norm = D3DXQuaternionLengthSq(pq); + if ( !norm ) + { + pout->x = 0.0f; + pout->y = 0.0f; + pout->z = 0.0f; + pout->w = 0.0f; + } + else + { + D3DXQuaternionConjugate(&temp, pq); + pout->x = temp.x / norm; + pout->y = temp.y / norm; + pout->z = temp.z / norm; + pout->w = temp.w / norm; + } + return pout; +} + +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2) +{ + pout->x = pq2->w * pq1->x + pq2->x * pq1->w + pq2->y * pq1->z - pq2->z * pq1->y; + pout->y = pq2->w * pq1->y - pq2->x * pq1->z + pq2->y * pq1->w + pq2->z * pq1->x; + pout->z = pq2->w * pq1->z + pq2->x * pq1->y - pq2->y * pq1->x + pq2->z * pq1->w; + pout->w = pq2->w * pq1->w - pq2->x * pq1->x - pq2->y * pq1->y - pq2->z * pq1->z; + return pout; +} + D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq) { FLOAT norm; @@ -547,6 +642,29 @@ D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQ } return pout; } + +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t) +{ + FLOAT dot, epsilon; + + epsilon = 1.0f; + dot = D3DXQuaternionDot(pq1, pq2); + if ( dot < 0.0f) epsilon = -1.0f; + pout->x = (1.0f - t) * pq1->x + epsilon * t * pq2->x; + pout->y = (1.0f - t) * pq1->y + epsilon * t * pq2->y; + pout->z = (1.0f - t) * pq1->z + epsilon * t * pq2->z; + pout->w = (1.0f - t) * pq1->w + epsilon * t * pq2->w; + return pout; +} + +D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, CONST D3DXQUATERNION *pq4, FLOAT t) +{ + D3DXQUATERNION temp1, temp2; + + D3DXQuaternionSlerp(pout, D3DXQuaternionSlerp(&temp1, pq1, pq4, t), D3DXQuaternionSlerp(&temp2, pq2, pq3, t), 2.0f * t * (1.0f - t)); + return pout; +} + /*_________________D3DXVec2_____________________*/ D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g) diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index 05a72e91ee2..229d0b7dc61 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -67,6 +67,7 @@ static void D3DXColorTest(void) color.r = 0.2f; color.g = 0.75f; color.b = 0.41f; color.a = 0.93f; color1.r = 0.6f; color1.g = 0.55f; color1.b = 0.23f; color1.a = 0.82f; color2.r = 0.3f; color2.g = 0.5f; color2.b = 0.76f; color2.a = 0.11f; + scale = 0.3f; /*_______________D3DXColorAdd________________*/ @@ -81,6 +82,16 @@ static void D3DXColorTest(void) funcpointer = D3DXColorAdd(NULL,NULL,NULL); ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); +/*_______________D3DXColorAdjustContrast______*/ + expected.r = 0.41f; expected.g = 0.575f; expected.b = 0.473f, expected.a = 0.93f; + D3DXColorAdjustContrast(&got,&color,scale); + expect_color(expected,got); + +/*_______________D3DXColorAdjustSaturation______*/ + expected.r = 0.486028f; expected.g = 0.651028f; expected.b = 0.549028f, expected.a = 0.93f; + D3DXColorAdjustSaturation(&got,&color,scale); + expect_color(expected,got); + /*_______________D3DXColorLerp________________*/ expected.r = 0.32f; expected.g = 0.69f; expected.b = 0.356f; expected.a = 0.897f; D3DXColorLerp(&got,&color,&color1,scale); @@ -436,13 +447,22 @@ static void D3DXMatrixTest(void) static void D3DXPlaneTest(void) { + D3DXMATRIX mat; D3DXPLANE expectedplane, gotplane, nulplane, plane; - D3DXVECTOR3 expectedvec, gotvec, vec1, vec2; + D3DXVECTOR3 expectedvec, gotvec, vec1, vec2, vec3; LPD3DXVECTOR3 funcpointer; D3DXVECTOR4 vec; FLOAT expected, got; + U(mat).m[0][1] = 5.0f; U(mat).m[0][2] = 7.0f; U(mat).m[0][3] = 8.0f; + U(mat).m[1][0] = 11.0f; U(mat).m[1][2] = 16.0f; U(mat).m[1][3] = 33.0f; + U(mat).m[2][0] = 19.0f; U(mat).m[2][1] = -21.0f; U(mat).m[2][3] = 43.0f; + U(mat).m[3][0] = 2.0f; U(mat).m[3][1] = 3.0f; U(mat).m[3][2] = -4.0f; + U(mat).m[0][0] = 10.0f; U(mat).m[1][1] = 20.0f; U(mat).m[2][2] = 30.0f; + U(mat).m[3][3] = -40.0f; + plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f; + vec.x = 2.0f; vec.y = 5.0f; vec.z = -6.0f; vec.w = 11.0f; /*_______________D3DXPlaneDot________________*/ @@ -478,6 +498,26 @@ static void D3DXPlaneTest(void) got = D3DXPlaneDotNormal(NULL,NULL), ok( expected == got, "Expected : %f, Got : %f\n",expected, got); +/*_______________D3DXPlaneFromPointNormal_______*/ + vec1.x = 11.0f; vec1.y = 13.0f; vec1.z = 15.0f; + vec2.x = 17.0f; vec2.y = 31.0f; vec2.z = 24.0f; + expectedplane.a = 17.0f; expectedplane.b = 31.0f; expectedplane.c = 24.0f; expectedplane.d = -950.0f; + D3DXPlaneFromPointNormal(&gotplane,&vec1,&vec2); + expect_plane(expectedplane, gotplane); + +/*_______________D3DXPlaneFromPoints_______*/ + vec1.x = 1.0f; vec1.y = 2.0f; vec1.z = 3.0f; + vec2.x = 1.0f; vec2.y = -6.0f; vec2.z = -5.0f; + vec3.x = 83.0f; vec3.y = 74.0f; vec3.z = 65.0f; + expectedplane.a = 0.085914f; expectedplane.b = -0.704492f; expectedplane.c = 0.704492f; expectedplane.d = -0.790406f; + D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3); + expect_plane(expectedplane, gotplane); + /* Test if 2 vectors are parallels */ + vec3.x = 1.0f; vec3.y = 1.0f; vec3.z = 2.0f; + expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f; + D3DXPlaneFromPoints(&gotplane,&vec1,&vec2,&vec3); + expect_plane(expectedplane, gotplane); + /*_______________D3DXPlaneIntersectLine___________*/ vec1.x = 9.0f; vec1.y = 6.0f; vec1.z = 3.0f; vec2.x = 2.0f; vec2.y = 5.0f; vec2.z = 8.0f; @@ -503,18 +543,33 @@ static void D3DXPlaneTest(void) expectedplane.a = 0.0f; expectedplane.b = 0.0f; expectedplane.c = 0.0f; expectedplane.d = 0.0f; D3DXPlaneNormalize(&gotplane, &nulplane); expect_plane(expectedplane, gotplane); + +/*_______________D3DXPlaneTransform____________*/ + expectedplane.a = 49.0f; expectedplane.b = -98.0f; expectedplane.c = 55.0f; expectedplane.d = -165.0f; + D3DXPlaneTransform(&gotplane,&plane,&mat); + expect_plane(expectedplane, gotplane); } static void D3X8QuaternionTest(void) { - D3DXQUATERNION expectedquat, gotquat, nul, q, r, s; + D3DXQUATERNION expectedquat, gotquat, nul, q, r, s, t, u; LPD3DXQUATERNION funcpointer; - FLOAT expected, got; + FLOAT expected, got, scale, scale2; BOOL expectedbool, gotbool; nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f; nul.w = 0.0f; q.x = 1.0f, q.y = 2.0f; q.z = 4.0f; q.w = 10.0f; r.x = -3.0f; r.y = 4.0f; r.z = -5.0f; r.w = 7.0; + t.x = -1111.0f, t.y= 111.0f; t.z = -11.0f; t.w = 1.0f; + u.x = 91.0f; u.y = - 82.0f; u.z = 7.3f; u.w = -6.4f; + + scale = 0.3f; + scale2 = 0.78f; + +/*_______________D3DXQuaternionBaryCentric________________________*/ + expectedquat.x = -867.444458; expectedquat.y = 87.851111f; expectedquat.z = -9.937778f; expectedquat.w = 3.235555f; + D3DXQuaternionBaryCentric(&gotquat,&q,&r,&t,scale,scale2); + expect_vec4(expectedquat,gotquat); /*_______________D3DXQuaternionConjugate________________*/ expectedquat.x = -1.0f; expectedquat.y = -2.0f; expectedquat.z = -4.0f; expectedquat.w = 10.0f; @@ -546,6 +601,15 @@ static void D3X8QuaternionTest(void) funcpointer = D3DXQuaternionIdentity(NULL); ok(funcpointer == NULL, "Expected: %p, Got: %p\n", NULL, funcpointer); +/*_______________D3DXQuaternionInverse________________________*/ + expectedquat.x = -1.0f/121.0f; expectedquat.y = -2.0f/121.0f; expectedquat.z = -4.0f/121.0f; expectedquat.w = 10.0f/121.0f; + D3DXQuaternionInverse(&gotquat,&q); + expect_vec4(expectedquat,gotquat); + /* test the null quaternion */ + expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f; + D3DXQuaternionInverse(&gotquat,&nul); + expect_vec4(expectedquat,gotquat); + /*_______________D3DXQuaternionIsIdentity________________*/ s.x = 0.0f; s.y = 0.0f; s.z = 0.0f; s.w = 1.0f; expectedbool = TRUE; @@ -577,6 +641,11 @@ static void D3X8QuaternionTest(void) got = D3DXQuaternionLengthSq(NULL); ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got); +/*_______________D3DXQuaternionMultiply________________________*/ + expectedquat.x = 3.0f; expectedquat.y = 61.0f; expectedquat.z = -32.0f; expectedquat.w = 85.0f; + D3DXQuaternionMultiply(&gotquat,&q,&r); + expect_vec4(expectedquat,gotquat); + /*_______________D3DXQuaternionNormalize________________________*/ expectedquat.x = 1.0f/11.0f; expectedquat.y = 2.0f/11.0f; expectedquat.z = 4.0f/11.0f; expectedquat.w = 10.0f/11.0f; D3DXQuaternionNormalize(&gotquat,&q); @@ -585,6 +654,19 @@ static void D3X8QuaternionTest(void) expectedquat.x = 0.0f; expectedquat.y = 0.0f; expectedquat.z = 0.0f; expectedquat.w = 0.0f; D3DXQuaternionNormalize(&gotquat,&nul); expect_vec4(expectedquat,gotquat); + +/*_______________D3DXQuaternionSlerp________________________*/ + expectedquat.x = -0.2f; expectedquat.y = 2.6f; expectedquat.z = 1.3f; expectedquat.w = 9.1f; + D3DXQuaternionSlerp(&gotquat,&q,&r,scale); + expect_vec4(expectedquat,gotquat); + expectedquat.x = 334.0f; expectedquat.y = -31.9f; expectedquat.z = 6.1f; expectedquat.w = 6.7f; + D3DXQuaternionSlerp(&gotquat,&q,&t,scale); + expect_vec4(expectedquat,gotquat); + +/*_______________D3DXQuaternionSquad________________________*/ + expectedquat.x = -156.296f; expectedquat.y = 30.242f; expectedquat.z = -2.5022f; expectedquat.w = 7.3576f; + D3DXQuaternionSquad(&gotquat,&q,&r,&t,&u,scale); + expect_vec4(expectedquat,gotquat); } static void D3X8Vector2Test(void) diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 000837df83d..bb967b9463b 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -32,7 +32,6 @@ #include #include #include -#include #ifdef HAVE_UNISTD_H # include #endif diff --git a/dlls/dnsapi/ns_name.c b/dlls/dnsapi/ns_name.c index de5fbdb14f6..c33c7d6639e 100644 --- a/dlls/dnsapi/ns_name.c +++ b/dlls/dnsapi/ns_name.c @@ -32,7 +32,6 @@ # include #endif #include -#include /* Data. */ diff --git a/dlls/hlink/Makefile.in b/dlls/hlink/Makefile.in index d7ceff2f83d..3d0262ce608 100644 --- a/dlls/hlink/Makefile.in +++ b/dlls/hlink/Makefile.in @@ -10,6 +10,7 @@ EXTRALIBS = -luuid C_SRCS = \ browse_ctx.c \ + extserv.c \ hlink_main.c \ link.c diff --git a/dlls/hlink/browse_ctx.c b/dlls/hlink/browse_ctx.c index f36fd2fbe15..3b2f4b4b1a5 100644 --- a/dlls/hlink/browse_ctx.c +++ b/dlls/hlink/browse_ctx.c @@ -18,20 +18,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#define COBJMACROS - -#include "winerror.h" -#include "windef.h" -#include "winbase.h" -#include "winuser.h" -#include "ole2.h" -#include "unknwn.h" -#include "objidl.h" +#include "hlink_private.h" #include "wine/debug.h" -#include "hlink.h" WINE_DEFAULT_DEBUG_CHANNEL(hlink); @@ -57,7 +46,7 @@ HRESULT WINAPI HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, if (pUnkOuter) return CLASS_E_NOAGGREGATION; - hl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HlinkBCImpl)); + hl = hlink_alloc_zero(sizeof(HlinkBCImpl)); if (!hl) return E_OUTOFMEMORY; @@ -106,10 +95,10 @@ static ULONG WINAPI IHlinkBC_fnRelease (IHlinkBrowseContext* iface) return refCount; TRACE("-- destroying IHlinkBrowseContext (%p)\n", This); - HeapFree(GetProcessHeap(), 0, This->BrowseWindowInfo); + hlink_free(This->BrowseWindowInfo); if (This->CurrentPage) IHlink_Release(This->CurrentPage); - HeapFree(GetProcessHeap(), 0, This); + hlink_free(This); return 0; } @@ -166,8 +155,8 @@ static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface, HlinkBCImpl *This = (HlinkBCImpl*)iface; TRACE("(%p)->(%p)\n", This, phlbwi); - HeapFree(GetProcessHeap(), 0, This->BrowseWindowInfo); - This->BrowseWindowInfo = HeapAlloc(GetProcessHeap(), 0, phlbwi->cbSize); + hlink_free(This->BrowseWindowInfo); + This->BrowseWindowInfo = hlink_alloc(phlbwi->cbSize); memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize); return S_OK; diff --git a/dlls/hlink/extserv.c b/dlls/hlink/extserv.c new file mode 100644 index 00000000000..d2abf2e872a --- /dev/null +++ b/dlls/hlink/extserv.c @@ -0,0 +1,185 @@ +/* + * Copyright 2007 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "hlink_private.h" + +#include "wine/debug.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL(hlink); + +#define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl))) + +typedef struct { + const IUnknownVtbl *lpIUnknownVtbl; + const IAuthenticateVtbl *lpIAuthenticateVtbl; + + LONG ref; + IUnknown *outer; + + HWND hwnd; + LPWSTR username; + LPWSTR password; +} ExtensionService; + +#define EXTSERVUNK(x) ((IUnknown*) &(x)->lpIUnknownVtbl) +#define AUTHENTICATE(x) ((IAuthenticate*) &(x)->lpIAuthenticateVtbl) + +#define EXTSERVUNK_THIS(iface) DEFINE_THIS(ExtensionService, IUnknown, iface) + +static HRESULT WINAPI ExtServUnk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) +{ + ExtensionService *This = EXTSERVUNK_THIS(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = EXTSERVUNK(This); + }else if(IsEqualGUID(&IID_IAuthenticate, riid)) { + TRACE("(%p)->(IID_IAuthenticate %p)\n", This, ppv); + *ppv = AUTHENTICATE(This); + } + + if(*ppv) { + IUnknown_AddRef(EXTSERVUNK(This)); + return S_OK; + } + + FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + return E_NOINTERFACE; +} + +static ULONG WINAPI ExtServUnk_AddRef(IUnknown *iface) +{ + ExtensionService *This = EXTSERVUNK_THIS(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI ExtServUnk_Release(IUnknown *iface) +{ + ExtensionService *This = EXTSERVUNK_THIS(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) { + hlink_free(This->username); + hlink_free(This->password); + hlink_free(This); + } + + return ref; +} + +#undef EXTSERVUNK_THIS + +static const IUnknownVtbl ExtServUnkVtbl = { + ExtServUnk_QueryInterface, + ExtServUnk_AddRef, + ExtServUnk_Release +}; + +#define AUTHENTICATE_THIS(iface) DEFINE_THIS(ExtensionService, IAuthenticate, iface) + +static HRESULT WINAPI Authenticate_QueryInterface(IAuthenticate *iface, REFIID riid, void **ppv) +{ + ExtensionService *This = AUTHENTICATE_THIS(iface); + return IUnknown_QueryInterface(This->outer, riid, ppv); +} + +static ULONG WINAPI Authenticate_AddRef(IAuthenticate *iface) +{ + ExtensionService *This = AUTHENTICATE_THIS(iface); + return IUnknown_AddRef(This->outer); +} + +static ULONG WINAPI Authenticate_Release(IAuthenticate *iface) +{ + ExtensionService *This = AUTHENTICATE_THIS(iface); + return IUnknown_Release(This->outer); +} + +static HRESULT WINAPI Authenticate_Authenticate(IAuthenticate *iface, + HWND *phwnd, LPWSTR *pszUsername, LPWSTR *pszPassword) +{ + ExtensionService *This = AUTHENTICATE_THIS(iface); + + TRACE("(%p)->(%p %p %p)\n", This, phwnd, pszUsername, pszPassword); + + if(!phwnd || !pszUsername || !pszPassword) + return E_INVALIDARG; + + *phwnd = This->hwnd; + *pszUsername = hlink_co_strdupW(This->username); + *pszPassword = hlink_co_strdupW(This->password); + + return S_OK; +} + +#undef AUTHENTICATE_THIS + +static const IAuthenticateVtbl AuthenticateVtbl = { + Authenticate_QueryInterface, + Authenticate_AddRef, + Authenticate_Release, + Authenticate_Authenticate +}; + +HRESULT WINAPI HlinkCreateExtensionServices(LPCWSTR pwzAdditionalHeaders, + HWND phwnd, LPCWSTR pszUsername, LPCWSTR pszPassword, + IUnknown *punkOuter, REFIID riid, void** ppv) +{ + ExtensionService *ret; + HRESULT hres = S_OK; + + TRACE("%s %p %s %s %p %s %p\n",debugstr_w(pwzAdditionalHeaders), + phwnd, debugstr_w(pszUsername), debugstr_w(pszPassword), + punkOuter, debugstr_guid(riid), ppv); + + if(pwzAdditionalHeaders) + FIXME("Unsupported pwzAdditionalHeaders\n"); + + ret = hlink_alloc(sizeof(*ret)); + + ret->lpIUnknownVtbl = &ExtServUnkVtbl; + ret->lpIAuthenticateVtbl = &AuthenticateVtbl; + ret->ref = 1; + ret->hwnd = phwnd; + ret->username = hlink_strdupW(pszUsername); + ret->password = hlink_strdupW(pszPassword); + + + if(!punkOuter) { + ret->outer = EXTSERVUNK(ret); + hres = IUnknown_QueryInterface(EXTSERVUNK(ret), riid, ppv); + IUnknown_Release(EXTSERVUNK(ret)); + }else if(IsEqualGUID(&IID_IUnknown, riid)) { + ret->outer = punkOuter; + *ppv = EXTSERVUNK(ret); + }else { + IUnknown_Release(EXTSERVUNK(ret)); + hres = E_INVALIDARG; + } + + return hres; +} diff --git a/dlls/hlink/hlink.spec b/dlls/hlink/hlink.spec index e5ab631a954..280d21b4707 100644 --- a/dlls/hlink/hlink.spec +++ b/dlls/hlink/hlink.spec @@ -6,7 +6,7 @@ 8 stdcall HlinkNavigateToStringReference(wstr wstr ptr long ptr long ptr ptr ptr) 9 stdcall HlinkOnNavigate(ptr ptr long ptr wstr wstr ptr) 10 stdcall HlinkNavigate(ptr ptr long ptr ptr ptr) -11 stub HlinkUpdateStackItem +11 stdcall HlinkUpdateStackItem(ptr ptr long wstr wstr) 12 stub HlinkOnRenameDocument 14 stub HlinkResolveMonikerForData 15 stub HlinkResolveStringForData diff --git a/dlls/hlink/hlink_main.c b/dlls/hlink/hlink_main.c index a786b6233e0..4e321899c39 100644 --- a/dlls/hlink/hlink_main.c +++ b/dlls/hlink/hlink_main.c @@ -18,28 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include "hlink_private.h" -#define COBJMACROS - -#include "winerror.h" -#include "windef.h" -#include "winbase.h" -#include "winuser.h" #include "winreg.h" -#include "ole2.h" -#include "unknwn.h" +#include "hlguids.h" #include "wine/debug.h" -#include "wine/unicode.h" -#include "hlink.h" -#include "hlguids.h" WINE_DEFAULT_DEBUG_CHANNEL(hlink); -extern HRESULT WINAPI HLink_Constructor(IUnknown *, REFIID, LPVOID*); -extern HRESULT WINAPI HLinkBrowseContext_Constructor(IUnknown *, REFIID, LPVOID*); - typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown*, REFIID, LPVOID*); typedef struct @@ -228,16 +215,6 @@ HRESULT WINAPI HlinkQueryCreateFromData(IDataObject* piDataObj) return E_NOTIMPL; } -HRESULT WINAPI HlinkCreateExtensionServices(LPCWSTR pwzAdditionalHeaders, - HWND phwnd, LPCWSTR pszUsername, LPCWSTR pszPassword, - IUnknown *punkOuter, REFIID riid, void** ppvObj) -{ - FIXME("%s %p %s %s %p %s %p\n",debugstr_w(pwzAdditionalHeaders), - phwnd, debugstr_w(pszUsername), debugstr_w(pszPassword), - punkOuter, debugstr_guid(riid), ppvObj); - return E_NOTIMPL; -} - HRESULT WINAPI HlinkNavigateToStringReference( LPCWSTR pwzTarget, LPCWSTR pwzLocation, IHlinkSite *pihlsite, DWORD dwSiteData, IHlinkFrame *pihlframe, DWORD grfHLNF, LPBC pibc, @@ -337,6 +314,14 @@ HRESULT WINAPI HlinkTranslateURL(LPCWSTR pwzURL, DWORD grfFlags, LPWSTR *ppwzTra return E_NOTIMPL; } +HRESULT WINAPI HlinkUpdateStackItem(IHlinkFrame *pihlframe, IHlinkBrowseContext *pihlbc, + ULONG uHLID, IMoniker *pimkTrgt, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName) +{ + FIXME("(%p %p %u %p %s %s)\n", pihlframe, pihlbc, uHLID, pimkTrgt, debugstr_w(pwzLocation), + debugstr_w(pwzFriendlyName)); + return E_NOTIMPL; +} + static HRESULT WINAPI HLinkCF_fnQueryInterface ( LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj) { diff --git a/dlls/hlink/hlink_private.h b/dlls/hlink/hlink_private.h new file mode 100644 index 00000000000..ef381bd1121 --- /dev/null +++ b/dlls/hlink/hlink_private.h @@ -0,0 +1,78 @@ +/* + * Copyright 2007 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define COBJMACROS + +#include "winerror.h" +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" +#include "hlink.h" + +#include "wine/unicode.h" + +extern HRESULT WINAPI HLink_Constructor(IUnknown*,REFIID,void**); +extern HRESULT WINAPI HLinkBrowseContext_Constructor(IUnknown*,REFIID,void**); + +static inline void *hlink_alloc(size_t len) +{ + return HeapAlloc(GetProcessHeap(), 0, len); +} + +static inline void *hlink_alloc_zero(size_t len) +{ + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); +} + +static inline BOOL hlink_free(void *mem) +{ + return HeapFree(GetProcessHeap(), 0, mem); +} + +static inline LPWSTR hlink_strdupW(LPCWSTR str) +{ + LPWSTR ret = NULL; + + if(str) { + DWORD size; + + size = (strlenW(str)+1)*sizeof(WCHAR); + ret = hlink_alloc(size); + memcpy(ret, str, size); + } + + return ret; +} + +static inline LPWSTR hlink_co_strdupW(LPCWSTR str) +{ + LPWSTR ret = NULL; + + if(str) { + DWORD size; + + size = (strlenW(str)+1)*sizeof(WCHAR); + ret = CoTaskMemAlloc(size); + memcpy(ret, str, size); + } + + return ret; +} diff --git a/dlls/hlink/link.c b/dlls/hlink/link.c index c450951ea8a..179a1791e20 100644 --- a/dlls/hlink/link.c +++ b/dlls/hlink/link.c @@ -18,24 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include "hlink_private.h" -#define COBJMACROS - -#include "winerror.h" -#include "windef.h" -#include "winbase.h" -#include "winuser.h" -#include "ole2.h" -#include "unknwn.h" -#include "objidl.h" #include "shellapi.h" +#include "hlguids.h" #include "wine/debug.h" -#include "wine/unicode.h" - -#include "hlink.h" -#include "hlguids.h" WINE_DEFAULT_DEBUG_CHANNEL(hlink); @@ -82,34 +70,6 @@ static inline HlinkImpl* HlinkImpl_from_IDataObject( IDataObject* iface) return (HlinkImpl*) ((CHAR*)iface - FIELD_OFFSET(HlinkImpl, lpDOVtbl)); } -static inline LPWSTR strdupW( LPCWSTR str ) -{ - LPWSTR r; - UINT len; - - if (!str) - return NULL; - len = (lstrlenW(str)+1) * sizeof (WCHAR); - r = HeapAlloc(GetProcessHeap(), 0, len); - if (r) - memcpy(r, str, len); - return r; -} - -static inline LPWSTR co_strdupW( LPCWSTR str ) -{ - LPWSTR r; - UINT len; - - if (!str) - return NULL; - len = (lstrlenW(str)+1) * sizeof (WCHAR); - r = CoTaskMemAlloc(len); - if (r) - memcpy(r, str, len); - return r; -} - static inline void __GetMoniker(HlinkImpl* This, IMoniker** moniker) { *moniker = NULL; @@ -138,7 +98,7 @@ HRESULT WINAPI HLink_Constructor(IUnknown *pUnkOuter, REFIID riid, if (pUnkOuter) return CLASS_E_NOAGGREGATION; - hl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HlinkImpl)); + hl = hlink_alloc_zero(sizeof(HlinkImpl)); if (!hl) return E_OUTOFMEMORY; @@ -195,15 +155,15 @@ static ULONG WINAPI IHlink_fnRelease (IHlink* iface) return refCount; TRACE("-- destroying IHlink (%p)\n", This); - HeapFree(GetProcessHeap(), 0, This->FriendlyName); - HeapFree(GetProcessHeap(), 0, This->Target); - HeapFree(GetProcessHeap(), 0, This->TargetFrameName); - HeapFree(GetProcessHeap(), 0, This->Location); + hlink_free(This->FriendlyName); + hlink_free(This->Target); + hlink_free(This->TargetFrameName); + hlink_free(This->Location); if (This->Moniker) IMoniker_Release(This->Moniker); if (This->Site) IHlinkSite_Release(This->Site); - HeapFree(GetProcessHeap(), 0, This); + hlink_free(This); return 0; } @@ -263,8 +223,8 @@ static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface, CoTaskMemFree(display_name); } - HeapFree(GetProcessHeap(), 0, This->Location); - This->Location = strdupW( pwzLocation ); + hlink_free(This->Location); + This->Location = hlink_strdupW( pwzLocation ); return S_OK; } @@ -279,13 +239,13 @@ static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface, if (grfHLSETF & HLINKSETF_TARGET) { - HeapFree(GetProcessHeap(), 0, This->Target); - This->Target = strdupW( pwzTarget ); + hlink_free(This->Target); + This->Target = hlink_strdupW( pwzTarget ); } if (grfHLSETF & HLINKSETF_LOCATION) { - HeapFree(GetProcessHeap(), 0, This->Location); - This->Location = strdupW( pwzLocation ); + hlink_free(This->Location); + This->Location = hlink_strdupW( pwzLocation ); } return S_OK; @@ -317,7 +277,7 @@ static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface, if (ppwzTarget) { - *ppwzTarget = co_strdupW( This->Target ); + *ppwzTarget = hlink_co_strdupW( This->Target ); if (!This->Target) { @@ -337,7 +297,7 @@ static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface, } } if (ppwzLocation) - *ppwzLocation = co_strdupW( This->Location ); + *ppwzLocation = hlink_co_strdupW( This->Location ); TRACE("(Target: %s Location: %s)\n", (ppwzTarget)?debugstr_w(*ppwzTarget):"", @@ -353,8 +313,8 @@ static HRESULT WINAPI IHlink_fnSetFriendlyName (IHlink *iface, TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName)); - HeapFree(GetProcessHeap(), 0, This->FriendlyName); - This->FriendlyName = strdupW( pwzFriendlyName ); + hlink_free(This->FriendlyName); + This->FriendlyName = hlink_strdupW( pwzFriendlyName ); return S_OK; } @@ -369,7 +329,7 @@ static HRESULT WINAPI IHlink_fnGetFriendlyName (IHlink* iface, /* FIXME: Only using explicitly set and cached friendly names */ if (This->FriendlyName) - *ppwzFriendlyName = co_strdupW( This->FriendlyName ); + *ppwzFriendlyName = hlink_co_strdupW( This->FriendlyName ); else { IMoniker *moniker; @@ -396,8 +356,8 @@ static HRESULT WINAPI IHlink_fnSetTargetFrameName(IHlink* iface, HlinkImpl *This = (HlinkImpl*)iface; TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename)); - HeapFree(GetProcessHeap(), 0, This->TargetFrameName); - This->TargetFrameName = strdupW( pwzTargetFramename ); + hlink_free(This->TargetFrameName); + This->TargetFrameName = hlink_strdupW( pwzTargetFramename ); return S_OK; } @@ -408,7 +368,7 @@ static HRESULT WINAPI IHlink_fnGetTargetFrameName(IHlink* iface, HlinkImpl *This = (HlinkImpl*)iface; TRACE("(%p)->(%p)\n", This, ppwzTargetFrameName); - *ppwzTargetFrameName = co_strdupW( This->TargetFrameName ); + *ppwzTargetFrameName = hlink_co_strdupW( This->TargetFrameName ); return S_OK; } @@ -688,18 +648,18 @@ static HRESULT read_hlink_string(IStream *pStm, LPWSTR *out_str) TRACE("read len %d\n", len); - str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + str = hlink_alloc(len * sizeof(WCHAR)); if (!str) return E_OUTOFMEMORY; hr = IStream_Read(pStm, str, len * sizeof(WCHAR), &read); if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, str); + hlink_free(str); return hr; } if (read != len * sizeof(WCHAR)) { - HeapFree(GetProcessHeap(), 0, str); + hlink_free(str); return STG_E_READFAULT; } TRACE("read string %s\n", debugstr_w(str)); diff --git a/dlls/hlink/tests/hlink.c b/dlls/hlink/tests/hlink.c index 4d3a3e2e4da..4a59f63f322 100644 --- a/dlls/hlink/tests/hlink.c +++ b/dlls/hlink/tests/hlink.c @@ -2,6 +2,7 @@ * Implementation of hyperlinking (hlink.dll) * * Copyright 2006 Mike McCormack + * Copyright 2007 Jacek Caban for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -322,16 +323,12 @@ static void test_special_reference(void) HRESULT hres; hres = HlinkGetSpecialReference(HLSR_HOME, &ref); - todo_wine ok(hres == S_OK, "HlinkGetSpecialReference(HLSR_HOME) failed: %08x\n", hres); - todo_wine ok(ref != NULL, "ref == NULL\n"); CoTaskMemFree(ref); hres = HlinkGetSpecialReference(HLSR_SEARCHPAGE, &ref); - todo_wine ok(hres == S_OK, "HlinkGetSpecialReference(HLSR_SEARCHPAGE) failed: %08x\n", hres); - todo_wine ok(ref != NULL, "ref == NULL\n"); CoTaskMemFree(ref); @@ -346,6 +343,57 @@ static void test_special_reference(void) ok(ref == NULL, "ref=%p\n", ref); } +static void test_HlinkCreateExtensionServices(void) +{ + IAuthenticate *authenticate; + LPWSTR password, username; + HWND hwnd; + HRESULT hres; + + static const WCHAR usernameW[] = {'u','s','e','r',0}; + static const WCHAR passwordW[] = {'p','a','s','s',0}; + + hres = HlinkCreateExtensionServices(NULL, NULL, NULL, NULL, + NULL, &IID_IAuthenticate, (void**)&authenticate); + ok(hres == S_OK, "HlinkCreateExtensionServices failed: %08x\n", hres); + ok(authenticate != NULL, "HlinkCreateExtensionServices returned NULL\n"); + + password = username = (void*)0xdeadbeef; + hwnd = (void*)0xdeadbeef; + hres = IAuthenticate_Authenticate(authenticate, &hwnd, &username, &password); + ok(hres == S_OK, "Authenticate failed: %08x\n", hres); + ok(!hwnd, "hwnd != NULL\n"); + ok(!username, "username != NULL\n"); + ok(!password, "password != NULL\n"); + + IAuthenticate_Release(authenticate); + + + hres = HlinkCreateExtensionServices(NULL, (HWND)0xfefefefe, usernameW, passwordW, + NULL, &IID_IAuthenticate, (void**)&authenticate); + ok(hres == S_OK, "HlinkCreateExtensionServices failed: %08x\n", hres); + ok(authenticate != NULL, "HlinkCreateExtensionServices returned NULL\n"); + + password = username = NULL; + hwnd = NULL; + hres = IAuthenticate_Authenticate(authenticate, &hwnd, &username, &password); + ok(hres == S_OK, "Authenticate failed: %08x\n", hres); + ok(hwnd == (HWND)0xfefefefe, "hwnd=%p\n", hwnd); + ok(!lstrcmpW(username, usernameW), "unexpected username\n"); + ok(!lstrcmpW(password, passwordW), "unexpected password\n"); + CoTaskMemFree(username); + CoTaskMemFree(password); + + password = username = (void*)0xdeadbeef; + hwnd = (void*)0xdeadbeef; + hres = IAuthenticate_Authenticate(authenticate, &hwnd, NULL, &password); + ok(hres == E_INVALIDARG, "Authenticate failed: %08x\n", hres); + ok(password == (void*)0xdeadbeef, "password = %p\n", password); + ok(hwnd == (void*)0xdeadbeef, "hwnd = %p\n", hwnd); + + IAuthenticate_Release(authenticate); +} + START_TEST(hlink) { CoInitialize(NULL); @@ -354,6 +402,7 @@ START_TEST(hlink) test_reference(); test_persist(); test_special_reference(); + test_HlinkCreateExtensionServices(); CoUninitialize(); } diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 0de885852f7..14a6fa4d457 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -1600,14 +1600,14 @@ DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder) ret = getTcpTable(&pTcpTable, numEntries, 0, 0); if (!ret) { size = sizeof(MIB_TCPTABLE); - if (numEntries > 1) - size += (numEntries - 1) * sizeof(MIB_TCPROW); + if (pTcpTable->dwNumEntries > 1) + size += (pTcpTable->dwNumEntries - 1) * sizeof(MIB_TCPROW); *pdwSize = size; - if (bOrder) - qsort(pTcpTable->table, pTcpTable->dwNumEntries, - sizeof(MIB_TCPROW), TcpTableSorter); - ret = NO_ERROR; + if (bOrder) + qsort(pTcpTable->table, pTcpTable->dwNumEntries, + sizeof(MIB_TCPROW), TcpTableSorter); + ret = NO_ERROR; } } } diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index c9912fa3858..bc3ba3aa106 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -371,10 +371,10 @@ @ stdcall FindFirstFileExA(str long ptr long ptr long) @ stdcall FindFirstFileExW(wstr long ptr long ptr long) @ stdcall FindFirstFileW(wstr ptr) -@ stub FindFirstVolumeA +@ stdcall FindFirstVolumeA(ptr long) @ stdcall FindFirstVolumeMountPointA(str ptr long) @ stdcall FindFirstVolumeMountPointW(wstr ptr long) -@ stub FindFirstVolumeW +@ stdcall FindFirstVolumeW(ptr long) @ stdcall FindNextChangeNotification(long) @ stdcall FindNextFileA(long ptr) @ stdcall FindNextFileW(long ptr) diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c index 846f7872a7d..504e6f06b41 100644 --- a/dlls/kernel32/kernel_main.c +++ b/dlls/kernel32/kernel_main.c @@ -35,7 +35,6 @@ #include "wine/winbase16.h" #include "wine/library.h" -#include "wincon.h" #include "toolhelp.h" #include "kernel_private.h" #include "kernel16_private.h" diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c index 38692d4fedc..6b90ad1cc6b 100644 --- a/dlls/kernel32/tests/thread.c +++ b/dlls/kernel32/tests/thread.c @@ -795,6 +795,7 @@ static void test_SetThreadContext(void) HANDLE thread; DWORD threadid; DWORD prevcount; + BOOL ret; SetLastError(0xdeadbeef); event = CreateEvent( NULL, TRUE, FALSE, NULL ); @@ -811,16 +812,20 @@ static void test_SetThreadContext(void) ctx.ContextFlags = CONTEXT_FULL; SetLastError(0xdeadbeef); - ok( GetThreadContext( thread, &ctx ), "GetThreadContext failed : (%d)\n", GetLastError() ); - - /* simulate a call to set_test_val(10) */ - stack = (int *)ctx.Esp; - stack[-1] = 10; - stack[-2] = ctx.Eip; - ctx.Esp -= 2 * sizeof(int *); - ctx.Eip = (DWORD)set_test_val; - SetLastError(0xdeadbeef); - ok( SetThreadContext( thread, &ctx ), "SetThreadContext failed : (%d)\n", GetLastError() ); + ret = GetThreadContext( thread, &ctx ); + ok( ret, "GetThreadContext failed : (%u)\n", GetLastError() ); + + if (ret) + { + /* simulate a call to set_test_val(10) */ + stack = (int *)ctx.Esp; + stack[-1] = 10; + stack[-2] = ctx.Eip; + ctx.Esp -= 2 * sizeof(int *); + ctx.Eip = (DWORD)set_test_val; + SetLastError(0xdeadbeef); + ok( SetThreadContext( thread, &ctx ), "SetThreadContext failed : (%d)\n", GetLastError() ); + } SetLastError(0xdeadbeef); prevcount = ResumeThread( thread ); diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c index ca9c06cf4d9..3ae7540f096 100644 --- a/dlls/kernel32/tests/toolhelp.c +++ b/dlls/kernel32/tests/toolhelp.c @@ -21,13 +21,11 @@ #include #include #include -#include -#include -#include "tlhelp32.h" -#include "wine/test.h" #include "windef.h" #include "winbase.h" +#include "tlhelp32.h" +#include "wine/test.h" #include "winuser.h" static char selfname[MAX_PATH]; diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c index 8d3251e9915..5ebe91f64d5 100644 --- a/dlls/kernel32/volume.c +++ b/dlls/kernel32/volume.c @@ -1388,6 +1388,26 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu } /*********************************************************************** + * FindFirstVolumeA (KERNEL32.@) + */ +HANDLE WINAPI FindFirstVolumeA(LPSTR volume, DWORD len) +{ + FIXME("(%p, %d), stub!\n", volume, len); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return INVALID_HANDLE_VALUE; +} + +/*********************************************************************** + * FindFirstVolumeW (KERNEL32.@) + */ +HANDLE WINAPI FindFirstVolumeW(LPWSTR volume, DWORD len) +{ + FIXME("(%p, %d), stub!\n", volume, len); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return INVALID_HANDLE_VALUE; +} + +/*********************************************************************** * FindFirstVolumeMountPointA (KERNEL32.@) */ HANDLE WINAPI FindFirstVolumeMountPointA(LPCSTR root, LPSTR mount_point, DWORD len) diff --git a/dlls/localspl/tests/localmon.c b/dlls/localspl/tests/localmon.c index 31267313dc1..4d75a4cff2b 100644 --- a/dlls/localspl/tests/localmon.c +++ b/dlls/localspl/tests/localmon.c @@ -339,7 +339,7 @@ static void test_AddPortEx(void) /* ########################### */ -static void test_ClosePort() +static void test_ClosePort(void) { HANDLE hPort; HANDLE hPort2; @@ -629,7 +629,7 @@ static void test_InitializePrintMonitor(void) /* ########################### */ -static void test_OpenPort() +static void test_OpenPort(void) { HANDLE hPort; HANDLE hPort2; diff --git a/dlls/mshtml/editor.c b/dlls/mshtml/editor.c index 827fa072855..53938e94116 100644 --- a/dlls/mshtml/editor.c +++ b/dlls/mshtml/editor.c @@ -586,6 +586,9 @@ static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, DWORD len; nsresult nsres; + V_VT(out) = VT_BSTR; + V_BSTR(out) = NULL; + nsparam = create_nscommand_params(); nsres = get_ns_command_state(This->nscontainer, NSCMD_FONTFACE, nsparam); @@ -600,7 +603,6 @@ static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, MultiByteToWideChar(CP_ACP, 0, stra, -1, strw, -1); nsfree(stra); - V_VT(out) = VT_BSTR; V_BSTR(out) = SysAllocString(strw); mshtml_free(strw); } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index a35347e5886..2bf926b3e25 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -398,6 +398,7 @@ BOOL install_wine_gecko(BOOL); void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD); void call_property_onchanged(ConnectionPoint*,DISPID); +HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*); void *nsalloc(size_t); void nsfree(void*); diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index 5e05a647105..96369cbd3f4 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -647,8 +647,8 @@ static HRESULT WINAPI BSCServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv) { BSCallback *This = SERVPROV_THIS(iface); - FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv); - return E_NOTIMPL; + TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv); + return E_NOINTERFACE; } #undef SERVPROV_THIS diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index 16ada42bc57..22b30e5fe11 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -761,7 +761,9 @@ static nsresult NSAPI nsChannel_AsyncOpen(nsIHttpChannel *iface, nsIStreamListen nsIWineURI_GetNSContainer(This->uri, &container); if(!container) { TRACE("container = NULL\n"); - return nsIChannel_AsyncOpen(This->channel, aListener, aContext); + return This->channel + ? nsIChannel_AsyncOpen(This->channel, aListener, aContext) + : NS_ERROR_UNEXPECTED; } nsIWineURI_GetIsDocumentURI(This->uri, &is_doc_uri); diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c index b76ea31cdb1..326b0b00cd1 100644 --- a/dlls/mshtml/olecmd.c +++ b/dlls/mshtml/olecmd.c @@ -534,8 +534,6 @@ static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, IMoniker *mon; HRESULT hres; - static const WCHAR wszAboutBlank[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; - TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); if(in || out) @@ -546,9 +544,20 @@ static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, This->usermode = EDITMODE; + if(This->mon) { + CLSID clsid = IID_NULL; + hres = IMoniker_GetClassID(This->mon, &clsid); + if(SUCCEEDED(hres)) { + /* We should use IMoniker::Save here */ + FIXME("Use CLSID %s\n", debugstr_guid(&clsid)); + } + } + if(This->frame) IOleInPlaceFrame_SetStatusText(This->frame, NULL); + This->readystate = READYSTATE_UNINITIALIZED; + if(This->client) { IOleCommandTarget *cmdtrg; @@ -581,25 +590,34 @@ static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, if(This->nscontainer) set_ns_editmode(This->nscontainer); - hres = CreateURLMoniker(NULL, wszAboutBlank, &mon); - if(FAILED(hres)) { - FIXME("CreateURLMoniker failed: %08x\n", hres); - return hres; - } - update_doc(This, UPDATE_UI); + if(This->mon) { + /* FIXME: We should find nicer way to do this */ + remove_doc_tasks(This); + + mon = This->mon; + IMoniker_AddRef(mon); + }else { + static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; + + hres = CreateURLMoniker(NULL, about_blankW, &mon); + if(FAILED(hres)) { + FIXME("CreateURLMoniker failed: %08x\n", hres); + return hres; + } + } + hres = IPersistMoniker_Load(PERSISTMON(This), TRUE, mon, NULL, 0); IMoniker_Release(mon); if(FAILED(hres)) return hres; if(This->ui_active) { - OLECHAR wszHTMLDocument[30]; RECT rcBorderWidths; if(This->ip_window) - IOleInPlaceUIWindow_SetActiveObject(This->ip_window, NULL, NULL); + call_set_active_object(This->ip_window, NULL); if(This->hostui) IDocHostUIHandler_HideUI(This->hostui); @@ -607,11 +625,8 @@ static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, IDocHostUIHandler_ShowUI(This->hostui, DOCHOSTUITYPE_AUTHOR, ACTOBJ(This), CMDTARGET(This), This->frame, This->ip_window); - LoadStringW(hInst, IDS_HTMLDOCUMENT, wszHTMLDocument, - sizeof(wszHTMLDocument)/sizeof(WCHAR)); - if(This->ip_window) - IOleInPlaceUIWindow_SetActiveObject(This->ip_window, ACTOBJ(This), wszHTMLDocument); + call_set_active_object(This->ip_window, ACTOBJ(This)); memset(&rcBorderWidths, 0, sizeof(rcBorderWidths)); IOleInPlaceFrame_SetBorderSpace(This->frame, &rcBorderWidths); diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c index 3e335b78b04..fe0d09d5d67 100644 --- a/dlls/mshtml/tests/htmldoc.c +++ b/dlls/mshtml/tests/htmldoc.c @@ -71,6 +71,7 @@ static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL; DEFINE_EXPECT(LockContainer); DEFINE_EXPECT(SetActiveObject); +DEFINE_EXPECT(SetActiveObject_null); DEFINE_EXPECT(GetWindow); DEFINE_EXPECT(CanInPlaceActivate); DEFINE_EXPECT(OnInPlaceActivate); @@ -118,6 +119,7 @@ DEFINE_EXPECT(GetDisplayName); DEFINE_EXPECT(BindToStorage); DEFINE_EXPECT(IsSystemMoniker); DEFINE_EXPECT(GetBindResult); +DEFINE_EXPECT(GetClassID); DEFINE_EXPECT(Abort); DEFINE_EXPECT(Read); DEFINE_EXPECT(CreateInstance); @@ -135,7 +137,7 @@ DEFINE_EXPECT(GetExternal); static IUnknown *doc_unk; static BOOL expect_LockContainer_fLock; -static BOOL expect_SetActiveObject_active, expect_InPlaceUIWindow_SetActiveObject_active = TRUE; +static BOOL expect_InPlaceUIWindow_SetActiveObject_active = TRUE; static BOOL ipsex; static BOOL set_clientsite = FALSE, container_locked = FALSE; static BOOL readystate_set_loading = FALSE, load_from_stream; @@ -163,10 +165,12 @@ static const WCHAR doc_url[] = {'w','i','n','e','t','e','s','t',':','d','o','c', static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; static HRESULT QueryInterface(REFIID riid, void **ppv); -static void test_readyState(IUnknown*); static void test_MSHTML_QueryStatus(IUnknown*,DWORD); static BOOL nogecko = FALSE; +#define test_readyState(u) _test_readyState(__LINE__,u) +static void _test_readyState(unsigned,IUnknown*); + static void test_GetCurMoniker(IUnknown*,IMoniker*,LPCWSTR); static const WCHAR wszTimesNewRoman[] = @@ -186,6 +190,17 @@ static const char *debugstr_guid(REFIID riid) return buf; } +static const char *debugstr_w(LPCWSTR str) +{ + static char buf[1024]; + + if(!str) + return "(null)"; + + WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL); + return buf; +} + #define EXPECT_UPDATEUI 1 #define EXPECT_SETTITLE 2 @@ -850,6 +865,7 @@ static const IBindingVtbl BindingVtbl = { static IBinding Binding = { &BindingVtbl }; DEFINE_GUID(IID_IMoniker_unk,0xA158A630,0xED6F,0x45FB,0xB9,0x87,0xF6,0x86,0x76,0xF5,0x77,0x52); +DEFINE_GUID(IID_IMoniker_unk2, 0x79EAC9D3,0xBAF9,0x11CE,0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B); static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv) { @@ -857,6 +873,8 @@ static HRESULT WINAPI Moniker_QueryInterface(IMoniker *iface, REFIID riid, void if(IsEqualGUID(&IID_IMoniker_unk, riid)) return E_NOINTERFACE; /* TODO */ + if(IsEqualGUID(&IID_IMoniker_unk2, riid)) + return E_NOINTERFACE; /* TODO */ ok(0, "unexpected riid: %s\n", debugstr_guid(riid)); return E_NOINTERFACE; @@ -874,8 +892,9 @@ static ULONG WINAPI Moniker_Release(IMoniker *iface) static HRESULT WINAPI Moniker_GetClassID(IMoniker *iface, CLSID *pClassID) { - ok(0, "unexpected call\n"); - return E_NOTIMPL; + CHECK_EXPECT(GetClassID); + ok(IsEqualGUID(pClassID, &IID_NULL), "pClassID = %s\n", debugstr_guid(pClassID)); + return E_FAIL; } static HRESULT WINAPI Moniker_IsDirty(IMoniker *iface) @@ -924,6 +943,8 @@ static HRESULT WINAPI Moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMon CHECK_EXPECT(BindToStorage); + load_state = LD_LOADING; + ok(pbc != NULL, "pbc == NULL\n"); ok(pmkToLeft == NULL, "pmkToLeft=%p\n", pmkToLeft); ok(IsEqualGUID(&IID_IStream, riid), "unexpected riid\n"); @@ -1233,13 +1254,14 @@ static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface, static const WCHAR wszHTML_Document[] = {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0}; - CHECK_EXPECT2(SetActiveObject); + if(pActiveObject) { + CHECK_EXPECT2(SetActiveObject); - if(expect_SetActiveObject_active) { - ok(pActiveObject != NULL, "pActiveObject = NULL\n"); if(pActiveObject && PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_ENGLISH) ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n"); }else { + CHECK_EXPECT(SetActiveObject_null); + ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject); ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName); } @@ -1634,13 +1656,12 @@ static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocum SET_EXPECT(OnUIActivate); SET_EXPECT(SetActiveObject); SET_EXPECT(ShowUI); - expect_SetActiveObject_active = TRUE; expect_status_text = NULL; hres = IOleDocumentView_UIActivate(view, TRUE); if(FAILED(hres)) { - trace("UIActivate failed: %08x\n", hres); + skip("UIActivate failed: %08x\n", hres); return hres; } ok(hres == S_OK, "UIActivate failed: %08x\n", hres); @@ -2368,7 +2389,7 @@ static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam return DefWindowProc(hwnd, msg, wParam, lParam); } -static void test_readyState(IUnknown *unk) +static void _test_readyState(unsigned line, IUnknown *unk) { IHTMLDocument2 *htmldoc; BSTR state; @@ -2400,7 +2421,9 @@ static void test_readyState(IUnknown *unk) hres = IHTMLDocument2_get_readyState(htmldoc, &state); ok(hres == S_OK, "get_ReadyState failed: %08x\n", hres); - ok(!lstrcmpW(state, expected_state[load_state]), "unexpected state, expected %d\n", load_state); + ok_(__FILE__, line) + (!lstrcmpW(state, expected_state[load_state]), "unexpected state \"%s\", expected %d\n", + debugstr_w(state), load_state); IHTMLDocument_Release(htmldoc); } @@ -2562,11 +2585,13 @@ static void test_Load(IPersistMoniker *persist) SET_EXPECT(OnChanged_READYSTATE); SET_EXPECT(Exec_ShellDocView_84); SET_EXPECT(BindToStorage); + SET_EXPECT(SetActiveObject); if(set_clientsite) { SET_EXPECT(Invoke_AMBIENT_SILENT); SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); SET_EXPECT(Exec_ShellDocView_37); } + load_state = LD_DOLOAD; expect_LockContainer_fLock = TRUE; readystate_set_loading = TRUE; @@ -2598,6 +2623,7 @@ static void test_Load(IPersistMoniker *persist) CHECK_CALLED(OnChanged_READYSTATE); SET_CALLED(Exec_ShellDocView_84); CHECK_CALLED(BindToStorage); + SET_CALLED(SetActiveObject); /* FIXME */ if(set_clientsite) { CHECK_CALLED(Invoke_AMBIENT_SILENT); CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); @@ -2779,14 +2805,15 @@ static const OLECMDF expect_cmds[OLECMDID_GETPRINTTEMPLATE+1] = { OLECMDF_SUPPORTED /* OLECMDID_GETPRINTTEMPLATE */ }; -static void test_QueryStatus(IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf) +#define test_QueryStatus(u,cgid,cmdid,cmdf) _test_QueryStatus(__LINE__,u,cgid,cmdid,cmdf) +static void _test_QueryStatus(unsigned line, IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf) { IOleCommandTarget *cmdtrg; OLECMD olecmd = {cmdid, 0}; HRESULT hres; hres = IUnknown_QueryInterface(unk, &IID_IOleCommandTarget, (void**)&cmdtrg); - ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres); + ok_(__FILE__,line) (hres == S_OK, "QueryInterface(IID_IOleCommandTarget failed: %08x\n", hres); if(FAILED(hres)) return; @@ -2795,8 +2822,8 @@ static void test_QueryStatus(IUnknown *unk, REFIID cgid, ULONG cmdid, DWORD cmdf IOleCommandTarget_Release(cmdtrg); - ok(olecmd.cmdID == cmdid, "cmdID changed\n"); - ok(olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf); + ok_(__FILE__,line) (olecmd.cmdID == cmdid, "cmdID changed\n"); + ok_(__FILE__,line) (olecmd.cmdf == cmdf, "(%u) cmdf=%08x, expected %08x\n", cmdid, olecmd.cmdf, cmdf); } static void test_MSHTML_QueryStatus(IUnknown *unk, DWORD cmdf) @@ -2937,7 +2964,7 @@ static void test_exec_onunload(IUnknown *unk) IOleCommandTarget_Release(cmdtrg); } -static void test_exec_editmode(IUnknown *unk) +static void test_exec_editmode(IUnknown *unk, BOOL loaded) { IOleCommandTarget *cmdtrg; HRESULT hres; @@ -2949,13 +2976,22 @@ static void test_exec_editmode(IUnknown *unk) editmode = TRUE; + if(loaded) + load_state = LD_DOLOAD; + + if(loaded) + SET_EXPECT(GetClassID); SET_EXPECT(SetStatusText); SET_EXPECT(Exec_ShellDocView_37); SET_EXPECT(GetHostInfo); + if(loaded) + SET_EXPECT(GetDisplayName); SET_EXPECT(Invoke_AMBIENT_SILENT); SET_EXPECT(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); SET_EXPECT(OnChanged_READYSTATE); SET_EXPECT(Exec_ShellDocView_84); + if(loaded) + SET_EXPECT(BindToStorage); SET_EXPECT(InPlaceUIWindow_SetActiveObject); SET_EXPECT(HideUI); SET_EXPECT(ShowUI); @@ -2968,13 +3004,19 @@ static void test_exec_editmode(IUnknown *unk) OLECMDEXECOPT_DODEFAULT, NULL, NULL); ok(hres == S_OK, "Exec failed: %08x\n", hres); + if(loaded) + CHECK_CALLED(GetClassID); CHECK_CALLED(SetStatusText); CHECK_CALLED(Exec_ShellDocView_37); CHECK_CALLED(GetHostInfo); + if(loaded) + CHECK_CALLED(GetDisplayName); CHECK_CALLED(Invoke_AMBIENT_SILENT); CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED); CHECK_CALLED(OnChanged_READYSTATE); SET_CALLED(Exec_ShellDocView_84); + if(loaded) + CHECK_CALLED(BindToStorage); CHECK_CALLED(InPlaceUIWindow_SetActiveObject); CHECK_CALLED(HideUI); CHECK_CALLED(ShowUI); @@ -3021,8 +3063,13 @@ static void test_exec_fontname(IUnknown *unk, LPCWSTR name, LPCWSTR exname) if(out && !nogecko) { ok(V_VT(out) == VT_BSTR, "V_VT(out) = %x\n", V_VT(out)); - if(V_VT(out) == VT_BSTR) - ok(!lstrcmpW(V_BSTR(out), name ? name : exname), "unexpected fontname\n"); + if(V_VT(out) == VT_BSTR) { + if(exname) + ok(!lstrcmpW(V_BSTR(out), name ? name : exname), + "unexpected fontname \"%s\"\n", debugstr_w(name)); + else + ok(V_BSTR(out) == NULL, "V_BSTR(out) != NULL\n"); + } VariantClear(out); } @@ -3404,7 +3451,6 @@ static HRESULT test_Activate(IUnknown *unk, DWORD flags) SET_EXPECT(ShowUI); SET_EXPECT(InPlaceUIWindow_SetActiveObject); SET_EXPECT(InPlaceFrame_SetBorderSpace); - expect_SetActiveObject_active = TRUE; expect_status_text = NULL; hres = IOleDocumentView_UIActivate(docview, TRUE); @@ -3480,17 +3526,16 @@ static void test_UIDeactivate(void) SET_EXPECT(InPlaceUIWindow_SetActiveObject); } if(call_UIActivate != CallUIActivate_None) { - SET_EXPECT(SetActiveObject); + SET_EXPECT(SetActiveObject_null); SET_EXPECT(HideUI); SET_EXPECT(OnUIDeactivate); } - expect_SetActiveObject_active = FALSE; hres = IOleDocumentView_UIActivate(view, FALSE); ok(hres == S_OK, "UIActivate failed: %08x\n", hres); if(call_UIActivate != CallUIActivate_None) { - CHECK_CALLED(SetActiveObject); + CHECK_CALLED(SetActiveObject_null); CHECK_CALLED(HideUI); CHECK_CALLED(OnUIDeactivate); } @@ -3630,15 +3675,15 @@ static void init_test(enum load_state_t ls) { ipsex = FALSE; } -static void test_HTMLDocument(enum load_state_t ls) +static void test_HTMLDocument(BOOL do_load) { IUnknown *unk; HRESULT hres; ULONG ref; - trace("Testing HTMLDocument (%s)...\n", (ls == LD_DOLOAD ? " load" : "no load")); + trace("Testing HTMLDocument (%s)...\n", (do_load ? "load" : "no load")); - init_test(ls); + init_test(do_load ? LD_DOLOAD : LD_NO); hres = create_document(&unk); if(FAILED(hres)) @@ -3652,7 +3697,7 @@ static void test_HTMLDocument(enum load_state_t ls) test_ConnectionPointContainer(unk); test_GetCurMoniker(unk, NULL, NULL); test_Persist(unk); - if(load_state == LD_NO) + if(!do_load) test_OnAmbientPropertyChange2(unk); hres = test_Activate(unk, CLIENTSITE_EXPECTPATH); @@ -3661,7 +3706,7 @@ static void test_HTMLDocument(enum load_state_t ls) return; } - if(load_state == LD_LOADING) { + if(do_load) { test_download(FALSE, TRUE, TRUE); test_GetCurMoniker(unk, &Moniker, NULL); } @@ -3706,9 +3751,9 @@ static void test_HTMLDocument(enum load_state_t ls) test_CloseView(); test_Close(unk, TRUE); test_OnAmbientPropertyChange2(unk); - test_GetCurMoniker(unk, load_state == LD_NO ? NULL : &Moniker, NULL); + test_GetCurMoniker(unk, do_load ? &Moniker : NULL, NULL); - if(ls != LD_DOLOAD) { + if(!do_load) { /* Activate HTMLDocument again, calling UIActivate after showing the window */ call_UIActivate = CallUIActivate_AfterShow; test_Activate(unk, 0); @@ -3835,7 +3880,6 @@ static void test_edit_uiactivate(IOleObject *oleobj) SET_EXPECT(ShowUI); SET_EXPECT(InPlaceUIWindow_SetActiveObject); SET_EXPECT(InPlaceFrame_SetBorderSpace); - expect_SetActiveObject_active = TRUE; expect_status_text = NULL; hres = IOleDocumentView_UIActivate(docview, TRUE); @@ -3850,16 +3894,16 @@ static void test_edit_uiactivate(IOleObject *oleobj) IOleDocumentView_Release(docview); } -static void test_editing_mode(void) +static void test_editing_mode(BOOL do_load) { IUnknown *unk; IOleObject *oleobj; HRESULT hres; ULONG ref; - trace("Testing HTMLDocument (edit)...\n"); + trace("Testing HTMLDocument (edit%s)...\n", do_load ? " load" : ""); - init_test(LD_DOLOAD); + init_test(do_load ? LD_DOLOAD : LD_NO); call_UIActivate = CallUIActivate_AfterShow; hres = create_document(&unk); @@ -3877,40 +3921,44 @@ static void test_editing_mode(void) test_edit_uiactivate(oleobj); test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); - - test_exec_editmode(unk); + if(do_load) + test_Persist(unk); + stream_read = protocol_read = 0; + test_exec_editmode(unk, do_load); test_UIDeactivate(); call_UIActivate = CallUIActivate_None; IOleObject_Release(oleobj); test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED); - test_download(TRUE, FALSE, FALSE); + test_download(TRUE, do_load, do_load); test_timer(EXPECT_UPDATEUI); test_MSHTML_QueryStatus(unk, OLECMDF_SUPPORTED|OLECMDF_ENABLED); - test_exec_fontname(unk, NULL, wszTimesNewRoman); - test_exec_fontname(unk, wszArial, wszTimesNewRoman); - test_timer(EXPECT_UPDATEUI); - test_exec_fontname(unk, NULL, wszArial); + if(!do_load) { + test_exec_fontname(unk, NULL, wszTimesNewRoman); + test_exec_fontname(unk, wszArial, wszTimesNewRoman); + test_timer(EXPECT_UPDATEUI); + test_exec_fontname(unk, NULL, wszArial); - test_exec_noargs(unk, IDM_JUSTIFYRIGHT); - test_timer(EXPECT_UPDATEUI); - if(!nogecko) - test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, - OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED); - - test_exec_noargs(unk, IDM_JUSTIFYCENTER); - test_timer(EXPECT_UPDATEUI); - test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, - OLECMDF_SUPPORTED|OLECMDF_ENABLED); - if(!nogecko) - test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, - OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED); + test_exec_noargs(unk, IDM_JUSTIFYRIGHT); + test_timer(EXPECT_UPDATEUI); + if(!nogecko) + test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, + OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED); - test_exec_noargs(unk, IDM_HORIZONTALLINE); - test_timer(EXPECT_UPDATEUI); - test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, - OLECMDF_SUPPORTED|OLECMDF_ENABLED); + test_exec_noargs(unk, IDM_JUSTIFYCENTER); + test_timer(EXPECT_UPDATEUI); + test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYRIGHT, + OLECMDF_SUPPORTED|OLECMDF_ENABLED); + if(!nogecko) + test_QueryStatus(unk, &CGID_MSHTML, IDM_JUSTIFYCENTER, + OLECMDF_SUPPORTED|OLECMDF_ENABLED|OLECMDF_LATCHED); + + test_exec_noargs(unk, IDM_HORIZONTALLINE); + test_timer(EXPECT_UPDATEUI); + test_QueryStatus(unk, &CGID_MSHTML, IDM_HORIZONTALLINE, + OLECMDF_SUPPORTED|OLECMDF_ENABLED); + } test_UIDeactivate(); test_InPlaceDeactivate(unk, TRUE); @@ -3980,11 +4028,12 @@ START_TEST(htmldoc) container_hwnd = create_container_window(); register_protocol(); - test_HTMLDocument(LD_NO); - test_HTMLDocument(LD_DOLOAD); + test_HTMLDocument(FALSE); + test_HTMLDocument(TRUE); test_HTMLDocument_hlink(); test_HTMLDocument_StreamLoad(); - test_editing_mode(); + test_editing_mode(FALSE); + test_editing_mode(TRUE); DestroyWindow(container_hwnd); CoUninitialize(); diff --git a/dlls/mshtml/view.c b/dlls/mshtml/view.c index e1f13dc4248..5872091784e 100644 --- a/dlls/mshtml/view.c +++ b/dlls/mshtml/view.c @@ -415,6 +415,18 @@ void hide_tooltip(HTMLDocument *This) SendMessageW(This->tooltips_hwnd, TTM_ACTIVATE, FALSE, 0); } +HRESULT call_set_active_object(IOleInPlaceUIWindow *window, IOleInPlaceActiveObject *act_obj) +{ + static WCHAR html_documentW[30]; + + if(act_obj && !html_documentW[0]) { + LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW, + sizeof(html_documentW)/sizeof(WCHAR)); + } + + return IOleInPlaceFrame_SetActiveObject(window, act_obj, act_obj ? html_documentW : NULL); +} + /********************************************************** * IOleDocumentView implementation */ @@ -564,7 +576,6 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f } if(fUIActivate) { - OLECHAR wszHTMLDocument[30]; RECT rcBorderWidths; if(This->ui_active) @@ -583,12 +594,9 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f update_doc(This, UPDATE_UI); - LoadStringW(hInst, IDS_HTMLDOCUMENT, wszHTMLDocument, - sizeof(wszHTMLDocument)/sizeof(WCHAR)); - hres = IOleInPlaceSite_OnUIActivate(This->ipsite); if(SUCCEEDED(hres)) { - IOleInPlaceFrame_SetActiveObject(This->frame, ACTOBJ(This), wszHTMLDocument); + call_set_active_object((IOleInPlaceUIWindow*)This->frame, ACTOBJ(This)); }else { FIXME("OnUIActivate failed: %08x\n", hres); IOleInPlaceFrame_Release(This->frame); @@ -604,7 +612,7 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f IDocHostUIHandler_HideUI(This->hostui); if(This->ip_window) - IOleInPlaceUIWindow_SetActiveObject(This->ip_window, ACTOBJ(This), wszHTMLDocument); + call_set_active_object(This->ip_window, ACTOBJ(This)); memset(&rcBorderWidths, 0, sizeof(rcBorderWidths)); IOleInPlaceFrame_SetBorderSpace(This->frame, &rcBorderWidths); @@ -614,9 +622,9 @@ static HRESULT WINAPI OleDocumentView_UIActivate(IOleDocumentView *iface, BOOL f if(This->ui_active) { This->ui_active = FALSE; if(This->ip_window) - IOleInPlaceUIWindow_SetActiveObject(This->ip_window, NULL, NULL); + call_set_active_object(This->ip_window, NULL); if(This->frame) - IOleInPlaceFrame_SetActiveObject(This->frame, NULL, NULL); + call_set_active_object((IOleInPlaceUIWindow*)This->frame, NULL); if(This->hostui) IDocHostUIHandler_HideUI(This->hostui); if(This->ipsite) diff --git a/dlls/msi/automation.c b/dlls/msi/automation.c index fb8d4f578c0..0b631acad6b 100644 --- a/dlls/msi/automation.c +++ b/dlls/msi/automation.c @@ -282,6 +282,7 @@ static ULONG WINAPI AutomationObject_Release(IDispatch* iface) if (!ref) { if (This->funcFree) This->funcFree(This); + ITypeInfo_Release(This->iTypeInfo); MsiCloseHandle(This->msiHandle); HeapFree(GetProcessHeap(), 0, This); } @@ -682,7 +683,6 @@ static HRESULT WINAPI ListEnumerator_Clone(IEnumVARIANT* iface, IEnumVARIANT **p return hr; } - IUnknown_AddRef(*ppEnum); return S_OK; } @@ -997,10 +997,7 @@ static HRESULT WINAPI ListImpl_Invoke( if (wFlags & DISPATCH_METHOD) { V_VT(pVarResult) = VT_UNKNOWN; if (SUCCEEDED(hr = create_list_enumerator(NULL, (LPVOID *)&pUnk, This, 0))) - { - IUnknown_AddRef(pUnk); V_UNKNOWN(pVarResult) = pUnk; - } else ERR("Failed to create IEnumVARIANT object, hresult 0x%08x\n", hr); } @@ -1086,10 +1083,7 @@ static HRESULT WINAPI ViewImpl_Invoke( if ((ret = MsiViewFetch(This->msiHandle, &msiHandle)) == ERROR_SUCCESS) { if (SUCCEEDED(hr = create_automation_object(msiHandle, NULL, (LPVOID*)&pDispatch, &DIID_Record, RecordImpl_Invoke, NULL, 0))) - { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; - } else ERR("Failed to create Record object, hresult 0x%08x\n", hr); } @@ -1174,10 +1168,7 @@ static HRESULT WINAPI DatabaseImpl_Invoke( { hr = create_automation_object(msiHandle, NULL, (LPVOID *)&pDispatch, &DIID_SummaryInfo, SummaryInfoImpl_Invoke, NULL, 0); if (SUCCEEDED(hr)) - { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; - } else ERR("Failed to create SummaryInfo object: 0x%08x\n", hr); } @@ -1199,10 +1190,7 @@ static HRESULT WINAPI DatabaseImpl_Invoke( if ((ret = MsiDatabaseOpenViewW(This->msiHandle, V_BSTR(&varg0), &msiHandle)) == ERROR_SUCCESS) { if (SUCCEEDED(hr = create_automation_object(msiHandle, NULL, (LPVOID*)&pDispatch, &DIID_View, ViewImpl_Invoke, NULL, 0))) - { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; - } else ERR("Failed to create View object, hresult 0x%08x\n", hr); } @@ -1332,10 +1320,7 @@ static HRESULT WINAPI SessionImpl_Invoke( if ((msiHandle = MsiGetActiveDatabase(This->msiHandle))) { if (SUCCEEDED(hr = create_automation_object(msiHandle, NULL, (LPVOID*)&pDispatch, &DIID_Database, DatabaseImpl_Invoke, NULL, 0))) - { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; - } else ERR("Failed to create Database object, hresult 0x%08x\n", hr); } @@ -1565,10 +1550,7 @@ static HRESULT WINAPI InstallerImpl_Invoke( if ((msiHandle = MsiCreateRecord(V_I4(&varg0)))) { if (SUCCEEDED(hr = create_automation_object(msiHandle, NULL, (LPVOID*)&pDispatch, &DIID_Record, RecordImpl_Invoke, NULL, 0))) - { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; - } else ERR("Failed to create Record object, hresult 0x%08x\n", hr); } @@ -1596,10 +1578,7 @@ static HRESULT WINAPI InstallerImpl_Invoke( if ((ret = MsiOpenPackageExW(V_BSTR(&varg0), V_I4(&varg1), &msiHandle)) == ERROR_SUCCESS) { if (SUCCEEDED(hr = create_session(msiHandle, (IDispatch *)This, &pDispatch))) - { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; - } else ERR("Failed to create Session object, hresult 0x%08x\n", hr); } @@ -1632,10 +1611,7 @@ static HRESULT WINAPI InstallerImpl_Invoke( hr = create_automation_object(msiHandle, NULL, (LPVOID *)&pDispatch, &DIID_Database, DatabaseImpl_Invoke, NULL, 0); if (SUCCEEDED(hr)) - { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; - } else ERR("Failed to create Database object: 0x%08x\n", hr); } @@ -1820,7 +1796,6 @@ static HRESULT WINAPI InstallerImpl_Invoke( V_VT(pVarResult) = VT_DISPATCH; if (SUCCEEDED(hr = create_automation_object(0, NULL, (LPVOID*)&pDispatch, &DIID_StringList, ListImpl_Invoke, ListImpl_Free, sizeof(ListData)))) { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; /* Save product strings */ @@ -1867,7 +1842,6 @@ static HRESULT WINAPI InstallerImpl_Invoke( V_VT(pVarResult) = VT_DISPATCH; if (SUCCEEDED(hr = create_automation_object(0, NULL, (LPVOID*)&pDispatch, &DIID_StringList, ListImpl_Invoke, ListImpl_Free, sizeof(ListData)))) { - IDispatch_AddRef(pDispatch); V_DISPATCH(pVarResult) = pDispatch; /* Save product strings */ diff --git a/dlls/msi/files.c b/dlls/msi/files.c index 8dbc765424d..c50e4200a4b 100644 --- a/dlls/msi/files.c +++ b/dlls/msi/files.c @@ -637,10 +637,11 @@ static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *m } } - if (file->IsCompressed && mi->cabinet && - GetFileAttributesW(mi->cabinet) == INVALID_FILE_ATTRIBUTES) + if (file->IsCompressed && + mi->cabinet && mi->cabinet[0] != '#' && + GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES) { - ERR("Cabinet not found: %s\n", debugstr_w(mi->cabinet)); + ERR("Cabinet not found: %s\n", debugstr_w(mi->source)); return ERROR_INSTALL_FAILURE; } diff --git a/dlls/msi/script.c b/dlls/msi/script.c index 2f2a17e9aa2..014ba6b7346 100644 --- a/dlls/msi/script.c +++ b/dlls/msi/script.c @@ -102,12 +102,10 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function /* Create an installer object */ hr = create_msiserver(NULL, (LPVOID *)&pActiveScriptSite->pInstaller); if (hr != S_OK) goto done; - IUnknown_AddRef((IUnknown *)pActiveScriptSite->pInstaller); /* Create a session object */ hr = create_session(hPackage, pActiveScriptSite->pInstaller, &pActiveScriptSite->pSession); if (hr != S_OK) goto done; - IUnknown_AddRef((IUnknown *)pActiveScriptSite->pSession); /* Create the scripting engine */ if ((type & 7) == msidbCustomActionTypeJScript) diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c index d074d348058..269d17c3502 100644 --- a/dlls/msi/tests/automation.c +++ b/dlls/msi/tests/automation.c @@ -387,6 +387,9 @@ static void check_service_is_installed(void) res = DeleteService(service); ok(res, "Failed to delete TestService\n"); + + CloseServiceHandle(service); + CloseServiceHandle(scm); } /* @@ -1365,6 +1368,8 @@ static void test_SummaryInfo(IDispatch *pSummaryInfo, const msi_summary_info *in } else skip("SummaryInfo_Property (pid %d) unhandled result type %d\n", entry->property, vt); + + VariantClear(&varresult); } /* SummaryInfo::Property, get; invalid arguments */ diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index 3e482332eb2..b8817d9ab34 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -1265,6 +1265,9 @@ static void check_service_is_installed(void) res = DeleteService(service); ok(res, "Failed to delete TestService\n"); + + CloseServiceHandle(service); + CloseServiceHandle(scm); } static void test_MsiInstallProduct(void) diff --git a/dlls/msvcrt/tests/heap.c b/dlls/msvcrt/tests/heap.c index e2e9a4a9eb2..afea53fc23f 100644 --- a/dlls/msvcrt/tests/heap.c +++ b/dlls/msvcrt/tests/heap.c @@ -355,8 +355,7 @@ START_TEST(heap) mem = realloc(NULL, 0); ok(mem != NULL, "memory not (re)allocated for size 0\n"); - if (mem) - free(mem); + free(mem); test_aligned(); } diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index 9a1dba74bf7..b4b89624f64 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -744,8 +744,29 @@ static HRESULT WINAPI domdoc_createTextNode( BSTR data, IXMLDOMText** text ) { - FIXME("\n"); - return E_NOTIMPL; + domdoc *This = impl_from_IXMLDOMDocument2( iface ); + xmlNodePtr xmlnode; + xmlChar *xml_content; + + TRACE("%p->(%s %p)\n", iface, debugstr_w(data), text); + + if(!text) + return E_INVALIDARG; + + *text = NULL; + + xml_content = xmlChar_from_wchar((WCHAR*)data); + xmlnode = xmlNewText(xml_content); + HeapFree(GetProcessHeap(), 0, xml_content); + + if(!xmlnode) + return E_FAIL; + + xmlnode->doc = get_doc( This ); + + *text = (IXMLDOMText*)create_text(xmlnode); + + return S_OK; } diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 298deff9816..e52718e4272 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -564,7 +564,10 @@ static HRESULT WINAPI xmlnode_get_text( default: FIXME("Unhandled node type %d\n", This->node->type); } - + + /* Always return a string. */ + if (!str) str = SysAllocStringLen( NULL, 0 ); + TRACE("%p %s\n", This, debugstr_w(str) ); *text = str; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index 60d7acfeffc..937e2fd698c 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -333,6 +333,7 @@ static void test_domdoc( void ) IXMLDOMParseError *error; IXMLDOMElement *element = NULL; IXMLDOMNode *node; + IXMLDOMText *nodetext = NULL; VARIANT_BOOL b; VARIANT var; BSTR str; @@ -488,6 +489,15 @@ static void test_domdoc( void ) ok( code == 0, "code %ld\n", code ); IXMLDOMParseError_Release( error ); + /* test createTextNode */ + str = SysAllocString( szOpen ); + r = IXMLDOMDocument_createTextNode(doc, str, NULL); + ok( r == E_INVALIDARG, "returns %08x\n", r ); + r = IXMLDOMDocument_createTextNode(doc, str, &nodetext); + ok( r == S_OK, "returns %08x\n", r ); + IXMLDOMText_Release( nodetext ); + SysFreeString( str ); + r = IXMLDOMDocument_Release( doc ); ok( r == 0, "document ref count incorrect\n"); @@ -1206,6 +1216,10 @@ static void test_get_text(void) ok( r == S_OK, "ret %08x\n", r ); IXMLDOMNodeList_Release( node_list ); + /* Invalid output parameter*/ + r = IXMLDOMNode_get_text( node, NULL ); + ok( r == E_INVALIDARG, "ret %08x\n", r ); + r = IXMLDOMNode_get_text( node, &str ); ok( r == S_OK, "ret %08x\n", r ); todo_wine { diff --git a/dlls/netapi32/access.c b/dlls/netapi32/access.c index 15cd84cd034..dc9498bfd09 100644 --- a/dlls/netapi32/access.c +++ b/dlls/netapi32/access.c @@ -178,10 +178,8 @@ NET_API_STATUS WINAPI NetUserAdd(LPCWSTR servername, break; } - if(su) - { - HeapFree(GetProcessHeap(), 0, su); - } + HeapFree(GetProcessHeap(), 0, su); + return status; } diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 1e559573601..a68acf3105e 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -35,7 +35,6 @@ #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" -#include "winternl.h" #include "winnt.h" #include "winternl.h" #include "wine/list.h" diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 8769b09d034..ca1ebdd3608 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -36,6 +36,7 @@ #include "wine/exception.h" #include "wine/library.h" +#include "wine/pthread.h" #include "wine/unicode.h" #include "wine/debug.h" #include "wine/server.h" @@ -52,6 +53,8 @@ WINE_DECLARE_DEBUG_CHANNEL(imports); #define RT_MANIFEST ((ULONG_PTR)24) #define ISOLATIONAWARE_MANIFEST_RESOURCE_ID ((ULONG_PTR)2) +extern struct wine_pthread_functions pthread_functions; + typedef DWORD (CALLBACK *DLLENTRYPROC)(HMODULE,DWORD,LPVOID); static int process_detaching = 0; /* set on process detach to avoid deadlocks with thread detach */ @@ -2296,6 +2299,7 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3, exit(1); } + peb->LoaderLock = &loader_section; peb->ProcessParameters->ImagePathName = wm->ldr.FullDllName; version_init( wm->ldr.FullDllName.Buffer ); @@ -2313,6 +2317,9 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3, if ((status = fixup_imports( wm, load_path )) != STATUS_SUCCESS) goto error; if ((status = alloc_process_tls()) != STATUS_SUCCESS) goto error; if ((status = alloc_thread_tls()) != STATUS_SUCCESS) goto error; + + pthread_functions.sigprocmask( SIG_UNBLOCK, &server_block_set, NULL ); + if ((status = process_attach( wm, (LPVOID)1 )) != STATUS_SUCCESS) { if (last_failed_modref) @@ -2329,7 +2336,7 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3, error: ERR( "Main exe initialization for %s failed, status %x\n", debugstr_w(peb->ProcessParameters->ImagePathName.Buffer), status ); - exit(1); + NtTerminateProcess( GetCurrentProcess(), status ); } diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index b059c94b9c5..b5e6a643887 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -137,7 +137,6 @@ NTSTATUS WINAPI NtQueryInformationProcess( UNIMPLEMENTED_INFO_CLASS(ProcessDeviceMap); UNIMPLEMENTED_INFO_CLASS(ProcessSessionInformation); UNIMPLEMENTED_INFO_CLASS(ProcessForegroundInformation); - UNIMPLEMENTED_INFO_CLASS(ProcessImageFileName); UNIMPLEMENTED_INFO_CLASS(ProcessLUIDDeviceMapsEnabled); UNIMPLEMENTED_INFO_CLASS(ProcessBreakOnTermination); UNIMPLEMENTED_INFO_CLASS(ProcessDebugObjectHandle); @@ -309,6 +308,27 @@ NTSTATUS WINAPI NtQueryInformationProcess( } else ret = STATUS_INFO_LENGTH_MISMATCH; break; + case ProcessImageFileName: + SERVER_START_REQ(get_dll_info) + { + UNICODE_STRING *image_file_name_str = ProcessInformation; + + req->handle = ProcessHandle; + req->base_address = NULL; /* main module */ + wine_server_set_reply( req, image_file_name_str ? image_file_name_str + 1 : NULL, + ProcessInformationLength > sizeof(UNICODE_STRING) ? ProcessInformationLength - sizeof(UNICODE_STRING) : 0 ); + ret = wine_server_call( req ); + if (ret == STATUS_BUFFER_TOO_SMALL) ret = STATUS_INFO_LENGTH_MISMATCH; + + len = sizeof(UNICODE_STRING) + reply->filename_len; + if (ret == STATUS_SUCCESS) + { + image_file_name_str->MaximumLength = image_file_name_str->Length = reply->filename_len; + image_file_name_str->Buffer = (PWSTR)(image_file_name_str + 1); + } + } + SERVER_END_REQ; + break; default: FIXME("(%p,info_class=%d,%p,0x%08x,%p) Unknown information class\n", ProcessHandle,ProcessInformationClass, diff --git a/dlls/ntdll/serial.c b/dlls/ntdll/serial.c index be398a57b6d..1b05b6e1744 100644 --- a/dlls/ntdll/serial.c +++ b/dlls/ntdll/serial.c @@ -39,9 +39,6 @@ #ifdef HAVE_UNISTD_H # include #endif -#ifdef HAVE_TERMIOS_H -#include -#endif #include #ifdef HAVE_SYS_STAT_H # include diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index 33f81dc4d78..1eebef136da 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c @@ -1072,7 +1072,6 @@ NTSTATUS server_init_process_done(void) } SERVER_END_REQ; - pthread_functions.sigprocmask( SIG_UNBLOCK, &server_block_set, NULL ); return status; } diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c index 9b73510333a..9f1b52a2aa4 100644 --- a/dlls/ntdll/signal_powerpc.c +++ b/dlls/ntdll/signal_powerpc.c @@ -103,7 +103,6 @@ typedef struct ucontext SIGCONTEXT; # include # include -# include typedef siginfo_t siginfo; typedef struct ucontext SIGCONTEXT; diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 8ea454c4d11..846448e7ab5 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -512,7 +512,7 @@ static void test_iocp_fileio(HANDLE h) NTSTATUS res = pNtSetInformationFile( hPipeSrv, &iosb, &fci, sizeof(fci), FileCompletionInformation ); ok( res == STATUS_SUCCESS, "NtSetInformationFile failed: %x\n", res ); - ok( iosb.Status == STATUS_SUCCESS, "iosb.Status invalid: %x\n", iosb.Status ); + ok( U(iosb).Status == STATUS_SUCCESS, "iosb.Status invalid: %x\n", U(iosb).Status ); count = get_pending_msgs(h); ok( !count, "Unexpected msg count: %ld\n", count ); diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 526c62e20cc..08ab1928677 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -19,6 +19,7 @@ */ #include "ntdll_test.h" +#include static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG); static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG); @@ -754,6 +755,37 @@ static void test_query_process_handlecount(void) } } +static void test_query_process_image_file_name(void) +{ + DWORD status; + ULONG ReturnLength; + UNICODE_STRING image_file_name; + void *buffer; + char *file_nameA; + INT len; + + status = pNtQueryInformationProcess(NULL, ProcessImageFileName, &image_file_name, sizeof(image_file_name), NULL); + ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status); + + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, 2, &ReturnLength); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); + + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, sizeof(image_file_name), &ReturnLength); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); + + buffer = HeapAlloc(GetProcessHeap(), 0, ReturnLength); + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, buffer, ReturnLength, &ReturnLength); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + memcpy(&image_file_name, buffer, sizeof(image_file_name)); + len = WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), NULL, 0, NULL, NULL); + file_nameA = HeapAlloc(GetProcessHeap(), 0, len + 1); + WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), file_nameA, len, NULL, NULL); + file_nameA[len] = '\0'; + HeapFree(GetProcessHeap(), 0, buffer); + trace("process image file name: %s\n", file_nameA); + HeapFree(GetProcessHeap(), 0, file_nameA); +} + static void test_readvirtualmemory(void) { @@ -886,6 +918,10 @@ START_TEST(info) trace("Starting test_query_process_handlecount()\n"); test_query_process_handlecount(); + /* 27 ProcessImageFileName */ + trace("Starting test_query_process_image_file_name()\n"); + test_query_process_image_file_name(); + /* belongs into it's own file */ trace("Starting test_readvirtualmemory()\n"); test_readvirtualmemory(); diff --git a/dlls/olecli32/olecli_main.c b/dlls/olecli32/olecli_main.c index d751522b1f4..a36cb72a3e1 100644 --- a/dlls/olecli32/olecli_main.c +++ b/dlls/olecli32/olecli_main.c @@ -146,7 +146,7 @@ typedef LPCSTR LPCOLESTR16; struct _OLESTREAM; typedef struct _OLEOBJECTVTBL { - void CALLBACK *(*QueryProtocol)(_LPOLEOBJECT,LPCOLESTR16); + void * (CALLBACK *QueryProtocol)(_LPOLEOBJECT,LPCOLESTR16); OLESTATUS (CALLBACK *Release)(_LPOLEOBJECT); OLESTATUS (CALLBACK *Show)(_LPOLEOBJECT,BOOL16); OLESTATUS (CALLBACK *DoVerb)(_LPOLEOBJECT,UINT16,BOOL16,BOOL16); diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c index b461054fcd9..5e46335c5f1 100644 --- a/dlls/qcap/vfwcapture.c +++ b/dlls/qcap/vfwcapture.c @@ -767,6 +767,8 @@ VfwPin_Construct( IBaseFilter * pBaseFilter, LPCRITICAL_SECTION pCritSec, *ppPin = (IPin *)(&pPinImpl->pin.pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } diff --git a/dlls/quartz/avidec.c b/dlls/quartz/avidec.c index 9e033c12f56..16dfe69d5a6 100644 --- a/dlls/quartz/avidec.c +++ b/dlls/quartz/avidec.c @@ -24,7 +24,6 @@ #include "pin.h" #include "uuids.h" -#include "vfwmsgs.h" #include "amvideo.h" #include "windef.h" #include "winbase.h" diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c index a7ebd9f9c93..947bb986da5 100644 --- a/dlls/quartz/dsoundrender.c +++ b/dlls/quartz/dsoundrender.c @@ -97,10 +97,12 @@ static HRESULT DSoundRender_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLE { pPinImpl->pin.lpVtbl = &DSoundRender_InputPin_Vtbl; pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl; - + *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 726776bfbef..73c92b2f481 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -880,6 +880,8 @@ static HRESULT FileAsyncReader_Construct(HANDLE hFile, IBaseFilter * pBaseFilter *ppPin = (IPin *)(&pPinImpl->pin.pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } diff --git a/dlls/quartz/parser.c b/dlls/quartz/parser.c index 39ea58b339c..94eb614842d 100644 --- a/dlls/quartz/parser.c +++ b/dlls/quartz/parser.c @@ -128,10 +128,12 @@ static HRESULT Parser_OutputPin_Construct(const PIN_INFO * pPinInfo, ALLOCATOR_P if (SUCCEEDED(Parser_OutputPin_Init(pPinInfo, props, pUserData, pQueryAccept, pmt, fSamplesPerSec, pCritSec, pPinImpl))) { pPinImpl->pin.pin.lpVtbl = &Parser_OutputPin_Vtbl; - + *ppPin = (IPin *)pPinImpl; return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } @@ -723,10 +725,12 @@ static HRESULT Parser_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC p if (SUCCEEDED(PullPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl))) { pPinImpl->pin.lpVtbl = &Parser_InputPin_Vtbl; - + *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c index 9960dffe82d..08ddcefcd6d 100644 --- a/dlls/quartz/pin.c +++ b/dlls/quartz/pin.c @@ -147,10 +147,12 @@ HRESULT InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LP { pPinImpl->pin.lpVtbl = &InputPin_Vtbl; pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl; - + *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } @@ -228,10 +230,12 @@ HRESULT OutputPin_Construct(const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES *pro if (SUCCEEDED(OutputPin_Init(pPinInfo, props, pUserData, pQueryAccept, pCritSec, pPinImpl))) { pPinImpl->pin.lpVtbl = &OutputPin_Vtbl; - + *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } @@ -1021,10 +1025,12 @@ HRESULT PullPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPV if (SUCCEEDED(PullPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl))) { pPinImpl->pin.lpVtbl = &PullPin_Vtbl; - + *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } diff --git a/dlls/quartz/transform.c b/dlls/quartz/transform.c index b63cacde02e..0570a90607a 100644 --- a/dlls/quartz/transform.c +++ b/dlls/quartz/transform.c @@ -107,6 +107,8 @@ static HRESULT TransformFilter_InputPin_Construct(const PIN_INFO * pPinInfo, SAM *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } @@ -136,6 +138,8 @@ static HRESULT TransformFilter_OutputPin_Construct(const PIN_INFO * pPinInfo, co *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 9e76fd136da..67e601ebb42 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -277,10 +277,12 @@ static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPL { pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl; pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl; - + *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl); return S_OK; } + + CoTaskMemFree(pPinImpl); return E_FAIL; } diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index 05902033b3d..57a442c06c3 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -871,10 +871,11 @@ static void PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, switch (type) { case RPC_FC_RP: /* ref pointer (always non-null) */ -#if 0 /* this causes problems for InstallShield so is disabled - we need more tests */ if (!Pointer) + { + ERR("NULL ref pointer is not allowed\n"); RpcRaiseException(RPC_X_NULL_REF_POINTER); -#endif + } pointer_needs_marshaling = 1; break; case RPC_FC_UP: /* unique pointer */ @@ -1016,6 +1017,11 @@ static void PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, switch (type) { case RPC_FC_RP: /* ref pointer (always non-null) */ + if (!Pointer) + { + ERR("NULL ref pointer is not allowed\n"); + RpcRaiseException(RPC_X_NULL_REF_POINTER); + } break; case RPC_FC_OP: case RPC_FC_UP: diff --git a/dlls/rpcrt4/rpcrt4_main.c b/dlls/rpcrt4/rpcrt4_main.c index ac69d5b8374..d5576643934 100644 --- a/dlls/rpcrt4/rpcrt4_main.c +++ b/dlls/rpcrt4/rpcrt4_main.c @@ -926,7 +926,9 @@ RPC_STATUS RPC_ENTRY RpcCancelThread(void* ThreadHandle) LIST_FOR_EACH_ENTRY(tdata, &threaddata_list, struct threaddata, entry) if (tdata->thread_id == target_tid) { - rpcrt4_conn_cancel_call(tdata->connection); + EnterCriticalSection(&tdata->cs); + if (tdata->connection) rpcrt4_conn_cancel_call(tdata->connection); + LeaveCriticalSection(&tdata->cs); break; } LeaveCriticalSection(&threaddata_cs); diff --git a/dlls/rsaenh/Makefile.in b/dlls/rsaenh/Makefile.in index e6b94706ba5..7c5a0546cd3 100644 --- a/dlls/rsaenh/Makefile.in +++ b/dlls/rsaenh/Makefile.in @@ -8,6 +8,7 @@ IMPORTLIB = librsaenh.$(IMPLIBEXT) IMPORTS = crypt32 advapi32 kernel32 C_SRCS = \ + aes.c \ des.c \ handle.c \ implglue.c \ diff --git a/dlls/rsaenh/aes.c b/dlls/rsaenh/aes.c new file mode 100644 index 00000000000..c0beb14639f --- /dev/null +++ b/dlls/rsaenh/aes.c @@ -0,0 +1,1333 @@ +/* + * AES functions + * + * Copyright 2007 Vijay Kiran Kamuju + * Based on public domain code by Tom St Denis (tomstdenis@iahu.ca) + * and Dobes Vandermeer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* + * This file contains code from the LibTomCrypt cryptographic + * library written by Tom St Denis (tomstdenis@iahu.ca). LibTomCrypt + * is in the public domain. The code in this file is tailored to + * special requirements. Take a look at http://libtom.org for the + * original version. + */ + +#include "tomcrypt.h" + +static const ulong32 TE0[256] = { + 0xc66363a5UL, 0xf87c7c84UL, 0xee777799UL, 0xf67b7b8dUL, + 0xfff2f20dUL, 0xd66b6bbdUL, 0xde6f6fb1UL, 0x91c5c554UL, + 0x60303050UL, 0x02010103UL, 0xce6767a9UL, 0x562b2b7dUL, + 0xe7fefe19UL, 0xb5d7d762UL, 0x4dababe6UL, 0xec76769aUL, + 0x8fcaca45UL, 0x1f82829dUL, 0x89c9c940UL, 0xfa7d7d87UL, + 0xeffafa15UL, 0xb25959ebUL, 0x8e4747c9UL, 0xfbf0f00bUL, + 0x41adadecUL, 0xb3d4d467UL, 0x5fa2a2fdUL, 0x45afafeaUL, + 0x239c9cbfUL, 0x53a4a4f7UL, 0xe4727296UL, 0x9bc0c05bUL, + 0x75b7b7c2UL, 0xe1fdfd1cUL, 0x3d9393aeUL, 0x4c26266aUL, + 0x6c36365aUL, 0x7e3f3f41UL, 0xf5f7f702UL, 0x83cccc4fUL, + 0x6834345cUL, 0x51a5a5f4UL, 0xd1e5e534UL, 0xf9f1f108UL, + 0xe2717193UL, 0xabd8d873UL, 0x62313153UL, 0x2a15153fUL, + 0x0804040cUL, 0x95c7c752UL, 0x46232365UL, 0x9dc3c35eUL, + 0x30181828UL, 0x379696a1UL, 0x0a05050fUL, 0x2f9a9ab5UL, + 0x0e070709UL, 0x24121236UL, 0x1b80809bUL, 0xdfe2e23dUL, + 0xcdebeb26UL, 0x4e272769UL, 0x7fb2b2cdUL, 0xea75759fUL, + 0x1209091bUL, 0x1d83839eUL, 0x582c2c74UL, 0x341a1a2eUL, + 0x361b1b2dUL, 0xdc6e6eb2UL, 0xb45a5aeeUL, 0x5ba0a0fbUL, + 0xa45252f6UL, 0x763b3b4dUL, 0xb7d6d661UL, 0x7db3b3ceUL, + 0x5229297bUL, 0xdde3e33eUL, 0x5e2f2f71UL, 0x13848497UL, + 0xa65353f5UL, 0xb9d1d168UL, 0x00000000UL, 0xc1eded2cUL, + 0x40202060UL, 0xe3fcfc1fUL, 0x79b1b1c8UL, 0xb65b5bedUL, + 0xd46a6abeUL, 0x8dcbcb46UL, 0x67bebed9UL, 0x7239394bUL, + 0x944a4adeUL, 0x984c4cd4UL, 0xb05858e8UL, 0x85cfcf4aUL, + 0xbbd0d06bUL, 0xc5efef2aUL, 0x4faaaae5UL, 0xedfbfb16UL, + 0x864343c5UL, 0x9a4d4dd7UL, 0x66333355UL, 0x11858594UL, + 0x8a4545cfUL, 0xe9f9f910UL, 0x04020206UL, 0xfe7f7f81UL, + 0xa05050f0UL, 0x783c3c44UL, 0x259f9fbaUL, 0x4ba8a8e3UL, + 0xa25151f3UL, 0x5da3a3feUL, 0x804040c0UL, 0x058f8f8aUL, + 0x3f9292adUL, 0x219d9dbcUL, 0x70383848UL, 0xf1f5f504UL, + 0x63bcbcdfUL, 0x77b6b6c1UL, 0xafdada75UL, 0x42212163UL, + 0x20101030UL, 0xe5ffff1aUL, 0xfdf3f30eUL, 0xbfd2d26dUL, + 0x81cdcd4cUL, 0x180c0c14UL, 0x26131335UL, 0xc3ecec2fUL, + 0xbe5f5fe1UL, 0x359797a2UL, 0x884444ccUL, 0x2e171739UL, + 0x93c4c457UL, 0x55a7a7f2UL, 0xfc7e7e82UL, 0x7a3d3d47UL, + 0xc86464acUL, 0xba5d5de7UL, 0x3219192bUL, 0xe6737395UL, + 0xc06060a0UL, 0x19818198UL, 0x9e4f4fd1UL, 0xa3dcdc7fUL, + 0x44222266UL, 0x542a2a7eUL, 0x3b9090abUL, 0x0b888883UL, + 0x8c4646caUL, 0xc7eeee29UL, 0x6bb8b8d3UL, 0x2814143cUL, + 0xa7dede79UL, 0xbc5e5ee2UL, 0x160b0b1dUL, 0xaddbdb76UL, + 0xdbe0e03bUL, 0x64323256UL, 0x743a3a4eUL, 0x140a0a1eUL, + 0x924949dbUL, 0x0c06060aUL, 0x4824246cUL, 0xb85c5ce4UL, + 0x9fc2c25dUL, 0xbdd3d36eUL, 0x43acacefUL, 0xc46262a6UL, + 0x399191a8UL, 0x319595a4UL, 0xd3e4e437UL, 0xf279798bUL, + 0xd5e7e732UL, 0x8bc8c843UL, 0x6e373759UL, 0xda6d6db7UL, + 0x018d8d8cUL, 0xb1d5d564UL, 0x9c4e4ed2UL, 0x49a9a9e0UL, + 0xd86c6cb4UL, 0xac5656faUL, 0xf3f4f407UL, 0xcfeaea25UL, + 0xca6565afUL, 0xf47a7a8eUL, 0x47aeaee9UL, 0x10080818UL, + 0x6fbabad5UL, 0xf0787888UL, 0x4a25256fUL, 0x5c2e2e72UL, + 0x381c1c24UL, 0x57a6a6f1UL, 0x73b4b4c7UL, 0x97c6c651UL, + 0xcbe8e823UL, 0xa1dddd7cUL, 0xe874749cUL, 0x3e1f1f21UL, + 0x964b4bddUL, 0x61bdbddcUL, 0x0d8b8b86UL, 0x0f8a8a85UL, + 0xe0707090UL, 0x7c3e3e42UL, 0x71b5b5c4UL, 0xcc6666aaUL, + 0x904848d8UL, 0x06030305UL, 0xf7f6f601UL, 0x1c0e0e12UL, + 0xc26161a3UL, 0x6a35355fUL, 0xae5757f9UL, 0x69b9b9d0UL, + 0x17868691UL, 0x99c1c158UL, 0x3a1d1d27UL, 0x279e9eb9UL, + 0xd9e1e138UL, 0xebf8f813UL, 0x2b9898b3UL, 0x22111133UL, + 0xd26969bbUL, 0xa9d9d970UL, 0x078e8e89UL, 0x339494a7UL, + 0x2d9b9bb6UL, 0x3c1e1e22UL, 0x15878792UL, 0xc9e9e920UL, + 0x87cece49UL, 0xaa5555ffUL, 0x50282878UL, 0xa5dfdf7aUL, + 0x038c8c8fUL, 0x59a1a1f8UL, 0x09898980UL, 0x1a0d0d17UL, + 0x65bfbfdaUL, 0xd7e6e631UL, 0x844242c6UL, 0xd06868b8UL, + 0x824141c3UL, 0x299999b0UL, 0x5a2d2d77UL, 0x1e0f0f11UL, + 0x7bb0b0cbUL, 0xa85454fcUL, 0x6dbbbbd6UL, 0x2c16163aUL, +}; + +static const ulong32 Te4[256] = { + 0x63636363UL, 0x7c7c7c7cUL, 0x77777777UL, 0x7b7b7b7bUL, + 0xf2f2f2f2UL, 0x6b6b6b6bUL, 0x6f6f6f6fUL, 0xc5c5c5c5UL, + 0x30303030UL, 0x01010101UL, 0x67676767UL, 0x2b2b2b2bUL, + 0xfefefefeUL, 0xd7d7d7d7UL, 0xababababUL, 0x76767676UL, + 0xcacacacaUL, 0x82828282UL, 0xc9c9c9c9UL, 0x7d7d7d7dUL, + 0xfafafafaUL, 0x59595959UL, 0x47474747UL, 0xf0f0f0f0UL, + 0xadadadadUL, 0xd4d4d4d4UL, 0xa2a2a2a2UL, 0xafafafafUL, + 0x9c9c9c9cUL, 0xa4a4a4a4UL, 0x72727272UL, 0xc0c0c0c0UL, + 0xb7b7b7b7UL, 0xfdfdfdfdUL, 0x93939393UL, 0x26262626UL, + 0x36363636UL, 0x3f3f3f3fUL, 0xf7f7f7f7UL, 0xccccccccUL, + 0x34343434UL, 0xa5a5a5a5UL, 0xe5e5e5e5UL, 0xf1f1f1f1UL, + 0x71717171UL, 0xd8d8d8d8UL, 0x31313131UL, 0x15151515UL, + 0x04040404UL, 0xc7c7c7c7UL, 0x23232323UL, 0xc3c3c3c3UL, + 0x18181818UL, 0x96969696UL, 0x05050505UL, 0x9a9a9a9aUL, + 0x07070707UL, 0x12121212UL, 0x80808080UL, 0xe2e2e2e2UL, + 0xebebebebUL, 0x27272727UL, 0xb2b2b2b2UL, 0x75757575UL, + 0x09090909UL, 0x83838383UL, 0x2c2c2c2cUL, 0x1a1a1a1aUL, + 0x1b1b1b1bUL, 0x6e6e6e6eUL, 0x5a5a5a5aUL, 0xa0a0a0a0UL, + 0x52525252UL, 0x3b3b3b3bUL, 0xd6d6d6d6UL, 0xb3b3b3b3UL, + 0x29292929UL, 0xe3e3e3e3UL, 0x2f2f2f2fUL, 0x84848484UL, + 0x53535353UL, 0xd1d1d1d1UL, 0x00000000UL, 0xededededUL, + 0x20202020UL, 0xfcfcfcfcUL, 0xb1b1b1b1UL, 0x5b5b5b5bUL, + 0x6a6a6a6aUL, 0xcbcbcbcbUL, 0xbebebebeUL, 0x39393939UL, + 0x4a4a4a4aUL, 0x4c4c4c4cUL, 0x58585858UL, 0xcfcfcfcfUL, + 0xd0d0d0d0UL, 0xefefefefUL, 0xaaaaaaaaUL, 0xfbfbfbfbUL, + 0x43434343UL, 0x4d4d4d4dUL, 0x33333333UL, 0x85858585UL, + 0x45454545UL, 0xf9f9f9f9UL, 0x02020202UL, 0x7f7f7f7fUL, + 0x50505050UL, 0x3c3c3c3cUL, 0x9f9f9f9fUL, 0xa8a8a8a8UL, + 0x51515151UL, 0xa3a3a3a3UL, 0x40404040UL, 0x8f8f8f8fUL, + 0x92929292UL, 0x9d9d9d9dUL, 0x38383838UL, 0xf5f5f5f5UL, + 0xbcbcbcbcUL, 0xb6b6b6b6UL, 0xdadadadaUL, 0x21212121UL, + 0x10101010UL, 0xffffffffUL, 0xf3f3f3f3UL, 0xd2d2d2d2UL, + 0xcdcdcdcdUL, 0x0c0c0c0cUL, 0x13131313UL, 0xececececUL, + 0x5f5f5f5fUL, 0x97979797UL, 0x44444444UL, 0x17171717UL, + 0xc4c4c4c4UL, 0xa7a7a7a7UL, 0x7e7e7e7eUL, 0x3d3d3d3dUL, + 0x64646464UL, 0x5d5d5d5dUL, 0x19191919UL, 0x73737373UL, + 0x60606060UL, 0x81818181UL, 0x4f4f4f4fUL, 0xdcdcdcdcUL, + 0x22222222UL, 0x2a2a2a2aUL, 0x90909090UL, 0x88888888UL, + 0x46464646UL, 0xeeeeeeeeUL, 0xb8b8b8b8UL, 0x14141414UL, + 0xdedededeUL, 0x5e5e5e5eUL, 0x0b0b0b0bUL, 0xdbdbdbdbUL, + 0xe0e0e0e0UL, 0x32323232UL, 0x3a3a3a3aUL, 0x0a0a0a0aUL, + 0x49494949UL, 0x06060606UL, 0x24242424UL, 0x5c5c5c5cUL, + 0xc2c2c2c2UL, 0xd3d3d3d3UL, 0xacacacacUL, 0x62626262UL, + 0x91919191UL, 0x95959595UL, 0xe4e4e4e4UL, 0x79797979UL, + 0xe7e7e7e7UL, 0xc8c8c8c8UL, 0x37373737UL, 0x6d6d6d6dUL, + 0x8d8d8d8dUL, 0xd5d5d5d5UL, 0x4e4e4e4eUL, 0xa9a9a9a9UL, + 0x6c6c6c6cUL, 0x56565656UL, 0xf4f4f4f4UL, 0xeaeaeaeaUL, + 0x65656565UL, 0x7a7a7a7aUL, 0xaeaeaeaeUL, 0x08080808UL, + 0xbabababaUL, 0x78787878UL, 0x25252525UL, 0x2e2e2e2eUL, + 0x1c1c1c1cUL, 0xa6a6a6a6UL, 0xb4b4b4b4UL, 0xc6c6c6c6UL, + 0xe8e8e8e8UL, 0xddddddddUL, 0x74747474UL, 0x1f1f1f1fUL, + 0x4b4b4b4bUL, 0xbdbdbdbdUL, 0x8b8b8b8bUL, 0x8a8a8a8aUL, + 0x70707070UL, 0x3e3e3e3eUL, 0xb5b5b5b5UL, 0x66666666UL, + 0x48484848UL, 0x03030303UL, 0xf6f6f6f6UL, 0x0e0e0e0eUL, + 0x61616161UL, 0x35353535UL, 0x57575757UL, 0xb9b9b9b9UL, + 0x86868686UL, 0xc1c1c1c1UL, 0x1d1d1d1dUL, 0x9e9e9e9eUL, + 0xe1e1e1e1UL, 0xf8f8f8f8UL, 0x98989898UL, 0x11111111UL, + 0x69696969UL, 0xd9d9d9d9UL, 0x8e8e8e8eUL, 0x94949494UL, + 0x9b9b9b9bUL, 0x1e1e1e1eUL, 0x87878787UL, 0xe9e9e9e9UL, + 0xcecececeUL, 0x55555555UL, 0x28282828UL, 0xdfdfdfdfUL, + 0x8c8c8c8cUL, 0xa1a1a1a1UL, 0x89898989UL, 0x0d0d0d0dUL, + 0xbfbfbfbfUL, 0xe6e6e6e6UL, 0x42424242UL, 0x68686868UL, + 0x41414141UL, 0x99999999UL, 0x2d2d2d2dUL, 0x0f0f0f0fUL, + 0xb0b0b0b0UL, 0x54545454UL, 0xbbbbbbbbUL, 0x16161616UL, +}; + +static const ulong32 TD0[256] = { + 0x51f4a750UL, 0x7e416553UL, 0x1a17a4c3UL, 0x3a275e96UL, + 0x3bab6bcbUL, 0x1f9d45f1UL, 0xacfa58abUL, 0x4be30393UL, + 0x2030fa55UL, 0xad766df6UL, 0x88cc7691UL, 0xf5024c25UL, + 0x4fe5d7fcUL, 0xc52acbd7UL, 0x26354480UL, 0xb562a38fUL, + 0xdeb15a49UL, 0x25ba1b67UL, 0x45ea0e98UL, 0x5dfec0e1UL, + 0xc32f7502UL, 0x814cf012UL, 0x8d4697a3UL, 0x6bd3f9c6UL, + 0x038f5fe7UL, 0x15929c95UL, 0xbf6d7aebUL, 0x955259daUL, + 0xd4be832dUL, 0x587421d3UL, 0x49e06929UL, 0x8ec9c844UL, + 0x75c2896aUL, 0xf48e7978UL, 0x99583e6bUL, 0x27b971ddUL, + 0xbee14fb6UL, 0xf088ad17UL, 0xc920ac66UL, 0x7dce3ab4UL, + 0x63df4a18UL, 0xe51a3182UL, 0x97513360UL, 0x62537f45UL, + 0xb16477e0UL, 0xbb6bae84UL, 0xfe81a01cUL, 0xf9082b94UL, + 0x70486858UL, 0x8f45fd19UL, 0x94de6c87UL, 0x527bf8b7UL, + 0xab73d323UL, 0x724b02e2UL, 0xe31f8f57UL, 0x6655ab2aUL, + 0xb2eb2807UL, 0x2fb5c203UL, 0x86c57b9aUL, 0xd33708a5UL, + 0x302887f2UL, 0x23bfa5b2UL, 0x02036abaUL, 0xed16825cUL, + 0x8acf1c2bUL, 0xa779b492UL, 0xf307f2f0UL, 0x4e69e2a1UL, + 0x65daf4cdUL, 0x0605bed5UL, 0xd134621fUL, 0xc4a6fe8aUL, + 0x342e539dUL, 0xa2f355a0UL, 0x058ae132UL, 0xa4f6eb75UL, + 0x0b83ec39UL, 0x4060efaaUL, 0x5e719f06UL, 0xbd6e1051UL, + 0x3e218af9UL, 0x96dd063dUL, 0xdd3e05aeUL, 0x4de6bd46UL, + 0x91548db5UL, 0x71c45d05UL, 0x0406d46fUL, 0x605015ffUL, + 0x1998fb24UL, 0xd6bde997UL, 0x894043ccUL, 0x67d99e77UL, + 0xb0e842bdUL, 0x07898b88UL, 0xe7195b38UL, 0x79c8eedbUL, + 0xa17c0a47UL, 0x7c420fe9UL, 0xf8841ec9UL, 0x00000000UL, + 0x09808683UL, 0x322bed48UL, 0x1e1170acUL, 0x6c5a724eUL, + 0xfd0efffbUL, 0x0f853856UL, 0x3daed51eUL, 0x362d3927UL, + 0x0a0fd964UL, 0x685ca621UL, 0x9b5b54d1UL, 0x24362e3aUL, + 0x0c0a67b1UL, 0x9357e70fUL, 0xb4ee96d2UL, 0x1b9b919eUL, + 0x80c0c54fUL, 0x61dc20a2UL, 0x5a774b69UL, 0x1c121a16UL, + 0xe293ba0aUL, 0xc0a02ae5UL, 0x3c22e043UL, 0x121b171dUL, + 0x0e090d0bUL, 0xf28bc7adUL, 0x2db6a8b9UL, 0x141ea9c8UL, + 0x57f11985UL, 0xaf75074cUL, 0xee99ddbbUL, 0xa37f60fdUL, + 0xf701269fUL, 0x5c72f5bcUL, 0x44663bc5UL, 0x5bfb7e34UL, + 0x8b432976UL, 0xcb23c6dcUL, 0xb6edfc68UL, 0xb8e4f163UL, + 0xd731dccaUL, 0x42638510UL, 0x13972240UL, 0x84c61120UL, + 0x854a247dUL, 0xd2bb3df8UL, 0xaef93211UL, 0xc729a16dUL, + 0x1d9e2f4bUL, 0xdcb230f3UL, 0x0d8652ecUL, 0x77c1e3d0UL, + 0x2bb3166cUL, 0xa970b999UL, 0x119448faUL, 0x47e96422UL, + 0xa8fc8cc4UL, 0xa0f03f1aUL, 0x567d2cd8UL, 0x223390efUL, + 0x87494ec7UL, 0xd938d1c1UL, 0x8ccaa2feUL, 0x98d40b36UL, + 0xa6f581cfUL, 0xa57ade28UL, 0xdab78e26UL, 0x3fadbfa4UL, + 0x2c3a9de4UL, 0x5078920dUL, 0x6a5fcc9bUL, 0x547e4662UL, + 0xf68d13c2UL, 0x90d8b8e8UL, 0x2e39f75eUL, 0x82c3aff5UL, + 0x9f5d80beUL, 0x69d0937cUL, 0x6fd52da9UL, 0xcf2512b3UL, + 0xc8ac993bUL, 0x10187da7UL, 0xe89c636eUL, 0xdb3bbb7bUL, + 0xcd267809UL, 0x6e5918f4UL, 0xec9ab701UL, 0x834f9aa8UL, + 0xe6956e65UL, 0xaaffe67eUL, 0x21bccf08UL, 0xef15e8e6UL, + 0xbae79bd9UL, 0x4a6f36ceUL, 0xea9f09d4UL, 0x29b07cd6UL, + 0x31a4b2afUL, 0x2a3f2331UL, 0xc6a59430UL, 0x35a266c0UL, + 0x744ebc37UL, 0xfc82caa6UL, 0xe090d0b0UL, 0x33a7d815UL, + 0xf104984aUL, 0x41ecdaf7UL, 0x7fcd500eUL, 0x1791f62fUL, + 0x764dd68dUL, 0x43efb04dUL, 0xccaa4d54UL, 0xe49604dfUL, + 0x9ed1b5e3UL, 0x4c6a881bUL, 0xc12c1fb8UL, 0x4665517fUL, + 0x9d5eea04UL, 0x018c355dUL, 0xfa877473UL, 0xfb0b412eUL, + 0xb3671d5aUL, 0x92dbd252UL, 0xe9105633UL, 0x6dd64713UL, + 0x9ad7618cUL, 0x37a10c7aUL, 0x59f8148eUL, 0xeb133c89UL, + 0xcea927eeUL, 0xb761c935UL, 0xe11ce5edUL, 0x7a47b13cUL, + 0x9cd2df59UL, 0x55f2733fUL, 0x1814ce79UL, 0x73c737bfUL, + 0x53f7cdeaUL, 0x5ffdaa5bUL, 0xdf3d6f14UL, 0x7844db86UL, + 0xcaaff381UL, 0xb968c43eUL, 0x3824342cUL, 0xc2a3405fUL, + 0x161dc372UL, 0xbce2250cUL, 0x283c498bUL, 0xff0d9541UL, + 0x39a80171UL, 0x080cb3deUL, 0xd8b4e49cUL, 0x6456c190UL, + 0x7bcb8461UL, 0xd532b670UL, 0x486c5c74UL, 0xd0b85742UL, +}; + +static const ulong32 Td4[256] = { + 0x52525252UL, 0x09090909UL, 0x6a6a6a6aUL, 0xd5d5d5d5UL, + 0x30303030UL, 0x36363636UL, 0xa5a5a5a5UL, 0x38383838UL, + 0xbfbfbfbfUL, 0x40404040UL, 0xa3a3a3a3UL, 0x9e9e9e9eUL, + 0x81818181UL, 0xf3f3f3f3UL, 0xd7d7d7d7UL, 0xfbfbfbfbUL, + 0x7c7c7c7cUL, 0xe3e3e3e3UL, 0x39393939UL, 0x82828282UL, + 0x9b9b9b9bUL, 0x2f2f2f2fUL, 0xffffffffUL, 0x87878787UL, + 0x34343434UL, 0x8e8e8e8eUL, 0x43434343UL, 0x44444444UL, + 0xc4c4c4c4UL, 0xdedededeUL, 0xe9e9e9e9UL, 0xcbcbcbcbUL, + 0x54545454UL, 0x7b7b7b7bUL, 0x94949494UL, 0x32323232UL, + 0xa6a6a6a6UL, 0xc2c2c2c2UL, 0x23232323UL, 0x3d3d3d3dUL, + 0xeeeeeeeeUL, 0x4c4c4c4cUL, 0x95959595UL, 0x0b0b0b0bUL, + 0x42424242UL, 0xfafafafaUL, 0xc3c3c3c3UL, 0x4e4e4e4eUL, + 0x08080808UL, 0x2e2e2e2eUL, 0xa1a1a1a1UL, 0x66666666UL, + 0x28282828UL, 0xd9d9d9d9UL, 0x24242424UL, 0xb2b2b2b2UL, + 0x76767676UL, 0x5b5b5b5bUL, 0xa2a2a2a2UL, 0x49494949UL, + 0x6d6d6d6dUL, 0x8b8b8b8bUL, 0xd1d1d1d1UL, 0x25252525UL, + 0x72727272UL, 0xf8f8f8f8UL, 0xf6f6f6f6UL, 0x64646464UL, + 0x86868686UL, 0x68686868UL, 0x98989898UL, 0x16161616UL, + 0xd4d4d4d4UL, 0xa4a4a4a4UL, 0x5c5c5c5cUL, 0xccccccccUL, + 0x5d5d5d5dUL, 0x65656565UL, 0xb6b6b6b6UL, 0x92929292UL, + 0x6c6c6c6cUL, 0x70707070UL, 0x48484848UL, 0x50505050UL, + 0xfdfdfdfdUL, 0xededededUL, 0xb9b9b9b9UL, 0xdadadadaUL, + 0x5e5e5e5eUL, 0x15151515UL, 0x46464646UL, 0x57575757UL, + 0xa7a7a7a7UL, 0x8d8d8d8dUL, 0x9d9d9d9dUL, 0x84848484UL, + 0x90909090UL, 0xd8d8d8d8UL, 0xababababUL, 0x00000000UL, + 0x8c8c8c8cUL, 0xbcbcbcbcUL, 0xd3d3d3d3UL, 0x0a0a0a0aUL, + 0xf7f7f7f7UL, 0xe4e4e4e4UL, 0x58585858UL, 0x05050505UL, + 0xb8b8b8b8UL, 0xb3b3b3b3UL, 0x45454545UL, 0x06060606UL, + 0xd0d0d0d0UL, 0x2c2c2c2cUL, 0x1e1e1e1eUL, 0x8f8f8f8fUL, + 0xcacacacaUL, 0x3f3f3f3fUL, 0x0f0f0f0fUL, 0x02020202UL, + 0xc1c1c1c1UL, 0xafafafafUL, 0xbdbdbdbdUL, 0x03030303UL, + 0x01010101UL, 0x13131313UL, 0x8a8a8a8aUL, 0x6b6b6b6bUL, + 0x3a3a3a3aUL, 0x91919191UL, 0x11111111UL, 0x41414141UL, + 0x4f4f4f4fUL, 0x67676767UL, 0xdcdcdcdcUL, 0xeaeaeaeaUL, + 0x97979797UL, 0xf2f2f2f2UL, 0xcfcfcfcfUL, 0xcecececeUL, + 0xf0f0f0f0UL, 0xb4b4b4b4UL, 0xe6e6e6e6UL, 0x73737373UL, + 0x96969696UL, 0xacacacacUL, 0x74747474UL, 0x22222222UL, + 0xe7e7e7e7UL, 0xadadadadUL, 0x35353535UL, 0x85858585UL, + 0xe2e2e2e2UL, 0xf9f9f9f9UL, 0x37373737UL, 0xe8e8e8e8UL, + 0x1c1c1c1cUL, 0x75757575UL, 0xdfdfdfdfUL, 0x6e6e6e6eUL, + 0x47474747UL, 0xf1f1f1f1UL, 0x1a1a1a1aUL, 0x71717171UL, + 0x1d1d1d1dUL, 0x29292929UL, 0xc5c5c5c5UL, 0x89898989UL, + 0x6f6f6f6fUL, 0xb7b7b7b7UL, 0x62626262UL, 0x0e0e0e0eUL, + 0xaaaaaaaaUL, 0x18181818UL, 0xbebebebeUL, 0x1b1b1b1bUL, + 0xfcfcfcfcUL, 0x56565656UL, 0x3e3e3e3eUL, 0x4b4b4b4bUL, + 0xc6c6c6c6UL, 0xd2d2d2d2UL, 0x79797979UL, 0x20202020UL, + 0x9a9a9a9aUL, 0xdbdbdbdbUL, 0xc0c0c0c0UL, 0xfefefefeUL, + 0x78787878UL, 0xcdcdcdcdUL, 0x5a5a5a5aUL, 0xf4f4f4f4UL, + 0x1f1f1f1fUL, 0xddddddddUL, 0xa8a8a8a8UL, 0x33333333UL, + 0x88888888UL, 0x07070707UL, 0xc7c7c7c7UL, 0x31313131UL, + 0xb1b1b1b1UL, 0x12121212UL, 0x10101010UL, 0x59595959UL, + 0x27272727UL, 0x80808080UL, 0xececececUL, 0x5f5f5f5fUL, + 0x60606060UL, 0x51515151UL, 0x7f7f7f7fUL, 0xa9a9a9a9UL, + 0x19191919UL, 0xb5b5b5b5UL, 0x4a4a4a4aUL, 0x0d0d0d0dUL, + 0x2d2d2d2dUL, 0xe5e5e5e5UL, 0x7a7a7a7aUL, 0x9f9f9f9fUL, + 0x93939393UL, 0xc9c9c9c9UL, 0x9c9c9c9cUL, 0xefefefefUL, + 0xa0a0a0a0UL, 0xe0e0e0e0UL, 0x3b3b3b3bUL, 0x4d4d4d4dUL, + 0xaeaeaeaeUL, 0x2a2a2a2aUL, 0xf5f5f5f5UL, 0xb0b0b0b0UL, + 0xc8c8c8c8UL, 0xebebebebUL, 0xbbbbbbbbUL, 0x3c3c3c3cUL, + 0x83838383UL, 0x53535353UL, 0x99999999UL, 0x61616161UL, + 0x17171717UL, 0x2b2b2b2bUL, 0x04040404UL, 0x7e7e7e7eUL, + 0xbabababaUL, 0x77777777UL, 0xd6d6d6d6UL, 0x26262626UL, + 0xe1e1e1e1UL, 0x69696969UL, 0x14141414UL, 0x63636363UL, + 0x55555555UL, 0x21212121UL, 0x0c0c0c0cUL, 0x7d7d7d7dUL, +}; + +#define Te0(x) TE0[x] +#define Te1(x) TE1[x] +#define Te2(x) TE2[x] +#define Te3(x) TE3[x] + +#define Td0(x) TD0[x] +#define Td1(x) TD1[x] +#define Td2(x) TD2[x] +#define Td3(x) TD3[x] + +static const ulong32 TE1[256] = { + 0xa5c66363UL, 0x84f87c7cUL, 0x99ee7777UL, 0x8df67b7bUL, + 0x0dfff2f2UL, 0xbdd66b6bUL, 0xb1de6f6fUL, 0x5491c5c5UL, + 0x50603030UL, 0x03020101UL, 0xa9ce6767UL, 0x7d562b2bUL, + 0x19e7fefeUL, 0x62b5d7d7UL, 0xe64dababUL, 0x9aec7676UL, + 0x458fcacaUL, 0x9d1f8282UL, 0x4089c9c9UL, 0x87fa7d7dUL, + 0x15effafaUL, 0xebb25959UL, 0xc98e4747UL, 0x0bfbf0f0UL, + 0xec41adadUL, 0x67b3d4d4UL, 0xfd5fa2a2UL, 0xea45afafUL, + 0xbf239c9cUL, 0xf753a4a4UL, 0x96e47272UL, 0x5b9bc0c0UL, + 0xc275b7b7UL, 0x1ce1fdfdUL, 0xae3d9393UL, 0x6a4c2626UL, + 0x5a6c3636UL, 0x417e3f3fUL, 0x02f5f7f7UL, 0x4f83ccccUL, + 0x5c683434UL, 0xf451a5a5UL, 0x34d1e5e5UL, 0x08f9f1f1UL, + 0x93e27171UL, 0x73abd8d8UL, 0x53623131UL, 0x3f2a1515UL, + 0x0c080404UL, 0x5295c7c7UL, 0x65462323UL, 0x5e9dc3c3UL, + 0x28301818UL, 0xa1379696UL, 0x0f0a0505UL, 0xb52f9a9aUL, + 0x090e0707UL, 0x36241212UL, 0x9b1b8080UL, 0x3ddfe2e2UL, + 0x26cdebebUL, 0x694e2727UL, 0xcd7fb2b2UL, 0x9fea7575UL, + 0x1b120909UL, 0x9e1d8383UL, 0x74582c2cUL, 0x2e341a1aUL, + 0x2d361b1bUL, 0xb2dc6e6eUL, 0xeeb45a5aUL, 0xfb5ba0a0UL, + 0xf6a45252UL, 0x4d763b3bUL, 0x61b7d6d6UL, 0xce7db3b3UL, + 0x7b522929UL, 0x3edde3e3UL, 0x715e2f2fUL, 0x97138484UL, + 0xf5a65353UL, 0x68b9d1d1UL, 0x00000000UL, 0x2cc1ededUL, + 0x60402020UL, 0x1fe3fcfcUL, 0xc879b1b1UL, 0xedb65b5bUL, + 0xbed46a6aUL, 0x468dcbcbUL, 0xd967bebeUL, 0x4b723939UL, + 0xde944a4aUL, 0xd4984c4cUL, 0xe8b05858UL, 0x4a85cfcfUL, + 0x6bbbd0d0UL, 0x2ac5efefUL, 0xe54faaaaUL, 0x16edfbfbUL, + 0xc5864343UL, 0xd79a4d4dUL, 0x55663333UL, 0x94118585UL, + 0xcf8a4545UL, 0x10e9f9f9UL, 0x06040202UL, 0x81fe7f7fUL, + 0xf0a05050UL, 0x44783c3cUL, 0xba259f9fUL, 0xe34ba8a8UL, + 0xf3a25151UL, 0xfe5da3a3UL, 0xc0804040UL, 0x8a058f8fUL, + 0xad3f9292UL, 0xbc219d9dUL, 0x48703838UL, 0x04f1f5f5UL, + 0xdf63bcbcUL, 0xc177b6b6UL, 0x75afdadaUL, 0x63422121UL, + 0x30201010UL, 0x1ae5ffffUL, 0x0efdf3f3UL, 0x6dbfd2d2UL, + 0x4c81cdcdUL, 0x14180c0cUL, 0x35261313UL, 0x2fc3ececUL, + 0xe1be5f5fUL, 0xa2359797UL, 0xcc884444UL, 0x392e1717UL, + 0x5793c4c4UL, 0xf255a7a7UL, 0x82fc7e7eUL, 0x477a3d3dUL, + 0xacc86464UL, 0xe7ba5d5dUL, 0x2b321919UL, 0x95e67373UL, + 0xa0c06060UL, 0x98198181UL, 0xd19e4f4fUL, 0x7fa3dcdcUL, + 0x66442222UL, 0x7e542a2aUL, 0xab3b9090UL, 0x830b8888UL, + 0xca8c4646UL, 0x29c7eeeeUL, 0xd36bb8b8UL, 0x3c281414UL, + 0x79a7dedeUL, 0xe2bc5e5eUL, 0x1d160b0bUL, 0x76addbdbUL, + 0x3bdbe0e0UL, 0x56643232UL, 0x4e743a3aUL, 0x1e140a0aUL, + 0xdb924949UL, 0x0a0c0606UL, 0x6c482424UL, 0xe4b85c5cUL, + 0x5d9fc2c2UL, 0x6ebdd3d3UL, 0xef43acacUL, 0xa6c46262UL, + 0xa8399191UL, 0xa4319595UL, 0x37d3e4e4UL, 0x8bf27979UL, + 0x32d5e7e7UL, 0x438bc8c8UL, 0x596e3737UL, 0xb7da6d6dUL, + 0x8c018d8dUL, 0x64b1d5d5UL, 0xd29c4e4eUL, 0xe049a9a9UL, + 0xb4d86c6cUL, 0xfaac5656UL, 0x07f3f4f4UL, 0x25cfeaeaUL, + 0xafca6565UL, 0x8ef47a7aUL, 0xe947aeaeUL, 0x18100808UL, + 0xd56fbabaUL, 0x88f07878UL, 0x6f4a2525UL, 0x725c2e2eUL, + 0x24381c1cUL, 0xf157a6a6UL, 0xc773b4b4UL, 0x5197c6c6UL, + 0x23cbe8e8UL, 0x7ca1ddddUL, 0x9ce87474UL, 0x213e1f1fUL, + 0xdd964b4bUL, 0xdc61bdbdUL, 0x860d8b8bUL, 0x850f8a8aUL, + 0x90e07070UL, 0x427c3e3eUL, 0xc471b5b5UL, 0xaacc6666UL, + 0xd8904848UL, 0x05060303UL, 0x01f7f6f6UL, 0x121c0e0eUL, + 0xa3c26161UL, 0x5f6a3535UL, 0xf9ae5757UL, 0xd069b9b9UL, + 0x91178686UL, 0x5899c1c1UL, 0x273a1d1dUL, 0xb9279e9eUL, + 0x38d9e1e1UL, 0x13ebf8f8UL, 0xb32b9898UL, 0x33221111UL, + 0xbbd26969UL, 0x70a9d9d9UL, 0x89078e8eUL, 0xa7339494UL, + 0xb62d9b9bUL, 0x223c1e1eUL, 0x92158787UL, 0x20c9e9e9UL, + 0x4987ceceUL, 0xffaa5555UL, 0x78502828UL, 0x7aa5dfdfUL, + 0x8f038c8cUL, 0xf859a1a1UL, 0x80098989UL, 0x171a0d0dUL, + 0xda65bfbfUL, 0x31d7e6e6UL, 0xc6844242UL, 0xb8d06868UL, + 0xc3824141UL, 0xb0299999UL, 0x775a2d2dUL, 0x111e0f0fUL, + 0xcb7bb0b0UL, 0xfca85454UL, 0xd66dbbbbUL, 0x3a2c1616UL, +}; +static const ulong32 TE2[256] = { + 0x63a5c663UL, 0x7c84f87cUL, 0x7799ee77UL, 0x7b8df67bUL, + 0xf20dfff2UL, 0x6bbdd66bUL, 0x6fb1de6fUL, 0xc55491c5UL, + 0x30506030UL, 0x01030201UL, 0x67a9ce67UL, 0x2b7d562bUL, + 0xfe19e7feUL, 0xd762b5d7UL, 0xabe64dabUL, 0x769aec76UL, + 0xca458fcaUL, 0x829d1f82UL, 0xc94089c9UL, 0x7d87fa7dUL, + 0xfa15effaUL, 0x59ebb259UL, 0x47c98e47UL, 0xf00bfbf0UL, + 0xadec41adUL, 0xd467b3d4UL, 0xa2fd5fa2UL, 0xafea45afUL, + 0x9cbf239cUL, 0xa4f753a4UL, 0x7296e472UL, 0xc05b9bc0UL, + 0xb7c275b7UL, 0xfd1ce1fdUL, 0x93ae3d93UL, 0x266a4c26UL, + 0x365a6c36UL, 0x3f417e3fUL, 0xf702f5f7UL, 0xcc4f83ccUL, + 0x345c6834UL, 0xa5f451a5UL, 0xe534d1e5UL, 0xf108f9f1UL, + 0x7193e271UL, 0xd873abd8UL, 0x31536231UL, 0x153f2a15UL, + 0x040c0804UL, 0xc75295c7UL, 0x23654623UL, 0xc35e9dc3UL, + 0x18283018UL, 0x96a13796UL, 0x050f0a05UL, 0x9ab52f9aUL, + 0x07090e07UL, 0x12362412UL, 0x809b1b80UL, 0xe23ddfe2UL, + 0xeb26cdebUL, 0x27694e27UL, 0xb2cd7fb2UL, 0x759fea75UL, + 0x091b1209UL, 0x839e1d83UL, 0x2c74582cUL, 0x1a2e341aUL, + 0x1b2d361bUL, 0x6eb2dc6eUL, 0x5aeeb45aUL, 0xa0fb5ba0UL, + 0x52f6a452UL, 0x3b4d763bUL, 0xd661b7d6UL, 0xb3ce7db3UL, + 0x297b5229UL, 0xe33edde3UL, 0x2f715e2fUL, 0x84971384UL, + 0x53f5a653UL, 0xd168b9d1UL, 0x00000000UL, 0xed2cc1edUL, + 0x20604020UL, 0xfc1fe3fcUL, 0xb1c879b1UL, 0x5bedb65bUL, + 0x6abed46aUL, 0xcb468dcbUL, 0xbed967beUL, 0x394b7239UL, + 0x4ade944aUL, 0x4cd4984cUL, 0x58e8b058UL, 0xcf4a85cfUL, + 0xd06bbbd0UL, 0xef2ac5efUL, 0xaae54faaUL, 0xfb16edfbUL, + 0x43c58643UL, 0x4dd79a4dUL, 0x33556633UL, 0x85941185UL, + 0x45cf8a45UL, 0xf910e9f9UL, 0x02060402UL, 0x7f81fe7fUL, + 0x50f0a050UL, 0x3c44783cUL, 0x9fba259fUL, 0xa8e34ba8UL, + 0x51f3a251UL, 0xa3fe5da3UL, 0x40c08040UL, 0x8f8a058fUL, + 0x92ad3f92UL, 0x9dbc219dUL, 0x38487038UL, 0xf504f1f5UL, + 0xbcdf63bcUL, 0xb6c177b6UL, 0xda75afdaUL, 0x21634221UL, + 0x10302010UL, 0xff1ae5ffUL, 0xf30efdf3UL, 0xd26dbfd2UL, + 0xcd4c81cdUL, 0x0c14180cUL, 0x13352613UL, 0xec2fc3ecUL, + 0x5fe1be5fUL, 0x97a23597UL, 0x44cc8844UL, 0x17392e17UL, + 0xc45793c4UL, 0xa7f255a7UL, 0x7e82fc7eUL, 0x3d477a3dUL, + 0x64acc864UL, 0x5de7ba5dUL, 0x192b3219UL, 0x7395e673UL, + 0x60a0c060UL, 0x81981981UL, 0x4fd19e4fUL, 0xdc7fa3dcUL, + 0x22664422UL, 0x2a7e542aUL, 0x90ab3b90UL, 0x88830b88UL, + 0x46ca8c46UL, 0xee29c7eeUL, 0xb8d36bb8UL, 0x143c2814UL, + 0xde79a7deUL, 0x5ee2bc5eUL, 0x0b1d160bUL, 0xdb76addbUL, + 0xe03bdbe0UL, 0x32566432UL, 0x3a4e743aUL, 0x0a1e140aUL, + 0x49db9249UL, 0x060a0c06UL, 0x246c4824UL, 0x5ce4b85cUL, + 0xc25d9fc2UL, 0xd36ebdd3UL, 0xacef43acUL, 0x62a6c462UL, + 0x91a83991UL, 0x95a43195UL, 0xe437d3e4UL, 0x798bf279UL, + 0xe732d5e7UL, 0xc8438bc8UL, 0x37596e37UL, 0x6db7da6dUL, + 0x8d8c018dUL, 0xd564b1d5UL, 0x4ed29c4eUL, 0xa9e049a9UL, + 0x6cb4d86cUL, 0x56faac56UL, 0xf407f3f4UL, 0xea25cfeaUL, + 0x65afca65UL, 0x7a8ef47aUL, 0xaee947aeUL, 0x08181008UL, + 0xbad56fbaUL, 0x7888f078UL, 0x256f4a25UL, 0x2e725c2eUL, + 0x1c24381cUL, 0xa6f157a6UL, 0xb4c773b4UL, 0xc65197c6UL, + 0xe823cbe8UL, 0xdd7ca1ddUL, 0x749ce874UL, 0x1f213e1fUL, + 0x4bdd964bUL, 0xbddc61bdUL, 0x8b860d8bUL, 0x8a850f8aUL, + 0x7090e070UL, 0x3e427c3eUL, 0xb5c471b5UL, 0x66aacc66UL, + 0x48d89048UL, 0x03050603UL, 0xf601f7f6UL, 0x0e121c0eUL, + 0x61a3c261UL, 0x355f6a35UL, 0x57f9ae57UL, 0xb9d069b9UL, + 0x86911786UL, 0xc15899c1UL, 0x1d273a1dUL, 0x9eb9279eUL, + 0xe138d9e1UL, 0xf813ebf8UL, 0x98b32b98UL, 0x11332211UL, + 0x69bbd269UL, 0xd970a9d9UL, 0x8e89078eUL, 0x94a73394UL, + 0x9bb62d9bUL, 0x1e223c1eUL, 0x87921587UL, 0xe920c9e9UL, + 0xce4987ceUL, 0x55ffaa55UL, 0x28785028UL, 0xdf7aa5dfUL, + 0x8c8f038cUL, 0xa1f859a1UL, 0x89800989UL, 0x0d171a0dUL, + 0xbfda65bfUL, 0xe631d7e6UL, 0x42c68442UL, 0x68b8d068UL, + 0x41c38241UL, 0x99b02999UL, 0x2d775a2dUL, 0x0f111e0fUL, + 0xb0cb7bb0UL, 0x54fca854UL, 0xbbd66dbbUL, 0x163a2c16UL, +}; +static const ulong32 TE3[256] = { + + 0x6363a5c6UL, 0x7c7c84f8UL, 0x777799eeUL, 0x7b7b8df6UL, + 0xf2f20dffUL, 0x6b6bbdd6UL, 0x6f6fb1deUL, 0xc5c55491UL, + 0x30305060UL, 0x01010302UL, 0x6767a9ceUL, 0x2b2b7d56UL, + 0xfefe19e7UL, 0xd7d762b5UL, 0xababe64dUL, 0x76769aecUL, + 0xcaca458fUL, 0x82829d1fUL, 0xc9c94089UL, 0x7d7d87faUL, + 0xfafa15efUL, 0x5959ebb2UL, 0x4747c98eUL, 0xf0f00bfbUL, + 0xadadec41UL, 0xd4d467b3UL, 0xa2a2fd5fUL, 0xafafea45UL, + 0x9c9cbf23UL, 0xa4a4f753UL, 0x727296e4UL, 0xc0c05b9bUL, + 0xb7b7c275UL, 0xfdfd1ce1UL, 0x9393ae3dUL, 0x26266a4cUL, + 0x36365a6cUL, 0x3f3f417eUL, 0xf7f702f5UL, 0xcccc4f83UL, + 0x34345c68UL, 0xa5a5f451UL, 0xe5e534d1UL, 0xf1f108f9UL, + 0x717193e2UL, 0xd8d873abUL, 0x31315362UL, 0x15153f2aUL, + 0x04040c08UL, 0xc7c75295UL, 0x23236546UL, 0xc3c35e9dUL, + 0x18182830UL, 0x9696a137UL, 0x05050f0aUL, 0x9a9ab52fUL, + 0x0707090eUL, 0x12123624UL, 0x80809b1bUL, 0xe2e23ddfUL, + 0xebeb26cdUL, 0x2727694eUL, 0xb2b2cd7fUL, 0x75759feaUL, + 0x09091b12UL, 0x83839e1dUL, 0x2c2c7458UL, 0x1a1a2e34UL, + 0x1b1b2d36UL, 0x6e6eb2dcUL, 0x5a5aeeb4UL, 0xa0a0fb5bUL, + 0x5252f6a4UL, 0x3b3b4d76UL, 0xd6d661b7UL, 0xb3b3ce7dUL, + 0x29297b52UL, 0xe3e33eddUL, 0x2f2f715eUL, 0x84849713UL, + 0x5353f5a6UL, 0xd1d168b9UL, 0x00000000UL, 0xeded2cc1UL, + 0x20206040UL, 0xfcfc1fe3UL, 0xb1b1c879UL, 0x5b5bedb6UL, + 0x6a6abed4UL, 0xcbcb468dUL, 0xbebed967UL, 0x39394b72UL, + 0x4a4ade94UL, 0x4c4cd498UL, 0x5858e8b0UL, 0xcfcf4a85UL, + 0xd0d06bbbUL, 0xefef2ac5UL, 0xaaaae54fUL, 0xfbfb16edUL, + 0x4343c586UL, 0x4d4dd79aUL, 0x33335566UL, 0x85859411UL, + 0x4545cf8aUL, 0xf9f910e9UL, 0x02020604UL, 0x7f7f81feUL, + 0x5050f0a0UL, 0x3c3c4478UL, 0x9f9fba25UL, 0xa8a8e34bUL, + 0x5151f3a2UL, 0xa3a3fe5dUL, 0x4040c080UL, 0x8f8f8a05UL, + 0x9292ad3fUL, 0x9d9dbc21UL, 0x38384870UL, 0xf5f504f1UL, + 0xbcbcdf63UL, 0xb6b6c177UL, 0xdada75afUL, 0x21216342UL, + 0x10103020UL, 0xffff1ae5UL, 0xf3f30efdUL, 0xd2d26dbfUL, + 0xcdcd4c81UL, 0x0c0c1418UL, 0x13133526UL, 0xecec2fc3UL, + 0x5f5fe1beUL, 0x9797a235UL, 0x4444cc88UL, 0x1717392eUL, + 0xc4c45793UL, 0xa7a7f255UL, 0x7e7e82fcUL, 0x3d3d477aUL, + 0x6464acc8UL, 0x5d5de7baUL, 0x19192b32UL, 0x737395e6UL, + 0x6060a0c0UL, 0x81819819UL, 0x4f4fd19eUL, 0xdcdc7fa3UL, + 0x22226644UL, 0x2a2a7e54UL, 0x9090ab3bUL, 0x8888830bUL, + 0x4646ca8cUL, 0xeeee29c7UL, 0xb8b8d36bUL, 0x14143c28UL, + 0xdede79a7UL, 0x5e5ee2bcUL, 0x0b0b1d16UL, 0xdbdb76adUL, + 0xe0e03bdbUL, 0x32325664UL, 0x3a3a4e74UL, 0x0a0a1e14UL, + 0x4949db92UL, 0x06060a0cUL, 0x24246c48UL, 0x5c5ce4b8UL, + 0xc2c25d9fUL, 0xd3d36ebdUL, 0xacacef43UL, 0x6262a6c4UL, + 0x9191a839UL, 0x9595a431UL, 0xe4e437d3UL, 0x79798bf2UL, + 0xe7e732d5UL, 0xc8c8438bUL, 0x3737596eUL, 0x6d6db7daUL, + 0x8d8d8c01UL, 0xd5d564b1UL, 0x4e4ed29cUL, 0xa9a9e049UL, + 0x6c6cb4d8UL, 0x5656faacUL, 0xf4f407f3UL, 0xeaea25cfUL, + 0x6565afcaUL, 0x7a7a8ef4UL, 0xaeaee947UL, 0x08081810UL, + 0xbabad56fUL, 0x787888f0UL, 0x25256f4aUL, 0x2e2e725cUL, + 0x1c1c2438UL, 0xa6a6f157UL, 0xb4b4c773UL, 0xc6c65197UL, + 0xe8e823cbUL, 0xdddd7ca1UL, 0x74749ce8UL, 0x1f1f213eUL, + 0x4b4bdd96UL, 0xbdbddc61UL, 0x8b8b860dUL, 0x8a8a850fUL, + 0x707090e0UL, 0x3e3e427cUL, 0xb5b5c471UL, 0x6666aaccUL, + 0x4848d890UL, 0x03030506UL, 0xf6f601f7UL, 0x0e0e121cUL, + 0x6161a3c2UL, 0x35355f6aUL, 0x5757f9aeUL, 0xb9b9d069UL, + 0x86869117UL, 0xc1c15899UL, 0x1d1d273aUL, 0x9e9eb927UL, + 0xe1e138d9UL, 0xf8f813ebUL, 0x9898b32bUL, 0x11113322UL, + 0x6969bbd2UL, 0xd9d970a9UL, 0x8e8e8907UL, 0x9494a733UL, + 0x9b9bb62dUL, 0x1e1e223cUL, 0x87879215UL, 0xe9e920c9UL, + 0xcece4987UL, 0x5555ffaaUL, 0x28287850UL, 0xdfdf7aa5UL, + 0x8c8c8f03UL, 0xa1a1f859UL, 0x89898009UL, 0x0d0d171aUL, + 0xbfbfda65UL, 0xe6e631d7UL, 0x4242c684UL, 0x6868b8d0UL, + 0x4141c382UL, 0x9999b029UL, 0x2d2d775aUL, 0x0f0f111eUL, + 0xb0b0cb7bUL, 0x5454fca8UL, 0xbbbbd66dUL, 0x16163a2cUL, +}; + +static const ulong32 Te4_0[] = { +0x00000063UL, 0x0000007cUL, 0x00000077UL, 0x0000007bUL, 0x000000f2UL, 0x0000006bUL, 0x0000006fUL, 0x000000c5UL, +0x00000030UL, 0x00000001UL, 0x00000067UL, 0x0000002bUL, 0x000000feUL, 0x000000d7UL, 0x000000abUL, 0x00000076UL, +0x000000caUL, 0x00000082UL, 0x000000c9UL, 0x0000007dUL, 0x000000faUL, 0x00000059UL, 0x00000047UL, 0x000000f0UL, +0x000000adUL, 0x000000d4UL, 0x000000a2UL, 0x000000afUL, 0x0000009cUL, 0x000000a4UL, 0x00000072UL, 0x000000c0UL, +0x000000b7UL, 0x000000fdUL, 0x00000093UL, 0x00000026UL, 0x00000036UL, 0x0000003fUL, 0x000000f7UL, 0x000000ccUL, +0x00000034UL, 0x000000a5UL, 0x000000e5UL, 0x000000f1UL, 0x00000071UL, 0x000000d8UL, 0x00000031UL, 0x00000015UL, +0x00000004UL, 0x000000c7UL, 0x00000023UL, 0x000000c3UL, 0x00000018UL, 0x00000096UL, 0x00000005UL, 0x0000009aUL, +0x00000007UL, 0x00000012UL, 0x00000080UL, 0x000000e2UL, 0x000000ebUL, 0x00000027UL, 0x000000b2UL, 0x00000075UL, +0x00000009UL, 0x00000083UL, 0x0000002cUL, 0x0000001aUL, 0x0000001bUL, 0x0000006eUL, 0x0000005aUL, 0x000000a0UL, +0x00000052UL, 0x0000003bUL, 0x000000d6UL, 0x000000b3UL, 0x00000029UL, 0x000000e3UL, 0x0000002fUL, 0x00000084UL, +0x00000053UL, 0x000000d1UL, 0x00000000UL, 0x000000edUL, 0x00000020UL, 0x000000fcUL, 0x000000b1UL, 0x0000005bUL, +0x0000006aUL, 0x000000cbUL, 0x000000beUL, 0x00000039UL, 0x0000004aUL, 0x0000004cUL, 0x00000058UL, 0x000000cfUL, +0x000000d0UL, 0x000000efUL, 0x000000aaUL, 0x000000fbUL, 0x00000043UL, 0x0000004dUL, 0x00000033UL, 0x00000085UL, +0x00000045UL, 0x000000f9UL, 0x00000002UL, 0x0000007fUL, 0x00000050UL, 0x0000003cUL, 0x0000009fUL, 0x000000a8UL, +0x00000051UL, 0x000000a3UL, 0x00000040UL, 0x0000008fUL, 0x00000092UL, 0x0000009dUL, 0x00000038UL, 0x000000f5UL, +0x000000bcUL, 0x000000b6UL, 0x000000daUL, 0x00000021UL, 0x00000010UL, 0x000000ffUL, 0x000000f3UL, 0x000000d2UL, +0x000000cdUL, 0x0000000cUL, 0x00000013UL, 0x000000ecUL, 0x0000005fUL, 0x00000097UL, 0x00000044UL, 0x00000017UL, +0x000000c4UL, 0x000000a7UL, 0x0000007eUL, 0x0000003dUL, 0x00000064UL, 0x0000005dUL, 0x00000019UL, 0x00000073UL, +0x00000060UL, 0x00000081UL, 0x0000004fUL, 0x000000dcUL, 0x00000022UL, 0x0000002aUL, 0x00000090UL, 0x00000088UL, +0x00000046UL, 0x000000eeUL, 0x000000b8UL, 0x00000014UL, 0x000000deUL, 0x0000005eUL, 0x0000000bUL, 0x000000dbUL, +0x000000e0UL, 0x00000032UL, 0x0000003aUL, 0x0000000aUL, 0x00000049UL, 0x00000006UL, 0x00000024UL, 0x0000005cUL, +0x000000c2UL, 0x000000d3UL, 0x000000acUL, 0x00000062UL, 0x00000091UL, 0x00000095UL, 0x000000e4UL, 0x00000079UL, +0x000000e7UL, 0x000000c8UL, 0x00000037UL, 0x0000006dUL, 0x0000008dUL, 0x000000d5UL, 0x0000004eUL, 0x000000a9UL, +0x0000006cUL, 0x00000056UL, 0x000000f4UL, 0x000000eaUL, 0x00000065UL, 0x0000007aUL, 0x000000aeUL, 0x00000008UL, +0x000000baUL, 0x00000078UL, 0x00000025UL, 0x0000002eUL, 0x0000001cUL, 0x000000a6UL, 0x000000b4UL, 0x000000c6UL, +0x000000e8UL, 0x000000ddUL, 0x00000074UL, 0x0000001fUL, 0x0000004bUL, 0x000000bdUL, 0x0000008bUL, 0x0000008aUL, +0x00000070UL, 0x0000003eUL, 0x000000b5UL, 0x00000066UL, 0x00000048UL, 0x00000003UL, 0x000000f6UL, 0x0000000eUL, +0x00000061UL, 0x00000035UL, 0x00000057UL, 0x000000b9UL, 0x00000086UL, 0x000000c1UL, 0x0000001dUL, 0x0000009eUL, +0x000000e1UL, 0x000000f8UL, 0x00000098UL, 0x00000011UL, 0x00000069UL, 0x000000d9UL, 0x0000008eUL, 0x00000094UL, +0x0000009bUL, 0x0000001eUL, 0x00000087UL, 0x000000e9UL, 0x000000ceUL, 0x00000055UL, 0x00000028UL, 0x000000dfUL, +0x0000008cUL, 0x000000a1UL, 0x00000089UL, 0x0000000dUL, 0x000000bfUL, 0x000000e6UL, 0x00000042UL, 0x00000068UL, +0x00000041UL, 0x00000099UL, 0x0000002dUL, 0x0000000fUL, 0x000000b0UL, 0x00000054UL, 0x000000bbUL, 0x00000016UL +}; + +static const ulong32 Te4_1[] = { +0x00006300UL, 0x00007c00UL, 0x00007700UL, 0x00007b00UL, 0x0000f200UL, 0x00006b00UL, 0x00006f00UL, 0x0000c500UL, +0x00003000UL, 0x00000100UL, 0x00006700UL, 0x00002b00UL, 0x0000fe00UL, 0x0000d700UL, 0x0000ab00UL, 0x00007600UL, +0x0000ca00UL, 0x00008200UL, 0x0000c900UL, 0x00007d00UL, 0x0000fa00UL, 0x00005900UL, 0x00004700UL, 0x0000f000UL, +0x0000ad00UL, 0x0000d400UL, 0x0000a200UL, 0x0000af00UL, 0x00009c00UL, 0x0000a400UL, 0x00007200UL, 0x0000c000UL, +0x0000b700UL, 0x0000fd00UL, 0x00009300UL, 0x00002600UL, 0x00003600UL, 0x00003f00UL, 0x0000f700UL, 0x0000cc00UL, +0x00003400UL, 0x0000a500UL, 0x0000e500UL, 0x0000f100UL, 0x00007100UL, 0x0000d800UL, 0x00003100UL, 0x00001500UL, +0x00000400UL, 0x0000c700UL, 0x00002300UL, 0x0000c300UL, 0x00001800UL, 0x00009600UL, 0x00000500UL, 0x00009a00UL, +0x00000700UL, 0x00001200UL, 0x00008000UL, 0x0000e200UL, 0x0000eb00UL, 0x00002700UL, 0x0000b200UL, 0x00007500UL, +0x00000900UL, 0x00008300UL, 0x00002c00UL, 0x00001a00UL, 0x00001b00UL, 0x00006e00UL, 0x00005a00UL, 0x0000a000UL, +0x00005200UL, 0x00003b00UL, 0x0000d600UL, 0x0000b300UL, 0x00002900UL, 0x0000e300UL, 0x00002f00UL, 0x00008400UL, +0x00005300UL, 0x0000d100UL, 0x00000000UL, 0x0000ed00UL, 0x00002000UL, 0x0000fc00UL, 0x0000b100UL, 0x00005b00UL, +0x00006a00UL, 0x0000cb00UL, 0x0000be00UL, 0x00003900UL, 0x00004a00UL, 0x00004c00UL, 0x00005800UL, 0x0000cf00UL, +0x0000d000UL, 0x0000ef00UL, 0x0000aa00UL, 0x0000fb00UL, 0x00004300UL, 0x00004d00UL, 0x00003300UL, 0x00008500UL, +0x00004500UL, 0x0000f900UL, 0x00000200UL, 0x00007f00UL, 0x00005000UL, 0x00003c00UL, 0x00009f00UL, 0x0000a800UL, +0x00005100UL, 0x0000a300UL, 0x00004000UL, 0x00008f00UL, 0x00009200UL, 0x00009d00UL, 0x00003800UL, 0x0000f500UL, +0x0000bc00UL, 0x0000b600UL, 0x0000da00UL, 0x00002100UL, 0x00001000UL, 0x0000ff00UL, 0x0000f300UL, 0x0000d200UL, +0x0000cd00UL, 0x00000c00UL, 0x00001300UL, 0x0000ec00UL, 0x00005f00UL, 0x00009700UL, 0x00004400UL, 0x00001700UL, +0x0000c400UL, 0x0000a700UL, 0x00007e00UL, 0x00003d00UL, 0x00006400UL, 0x00005d00UL, 0x00001900UL, 0x00007300UL, +0x00006000UL, 0x00008100UL, 0x00004f00UL, 0x0000dc00UL, 0x00002200UL, 0x00002a00UL, 0x00009000UL, 0x00008800UL, +0x00004600UL, 0x0000ee00UL, 0x0000b800UL, 0x00001400UL, 0x0000de00UL, 0x00005e00UL, 0x00000b00UL, 0x0000db00UL, +0x0000e000UL, 0x00003200UL, 0x00003a00UL, 0x00000a00UL, 0x00004900UL, 0x00000600UL, 0x00002400UL, 0x00005c00UL, +0x0000c200UL, 0x0000d300UL, 0x0000ac00UL, 0x00006200UL, 0x00009100UL, 0x00009500UL, 0x0000e400UL, 0x00007900UL, +0x0000e700UL, 0x0000c800UL, 0x00003700UL, 0x00006d00UL, 0x00008d00UL, 0x0000d500UL, 0x00004e00UL, 0x0000a900UL, +0x00006c00UL, 0x00005600UL, 0x0000f400UL, 0x0000ea00UL, 0x00006500UL, 0x00007a00UL, 0x0000ae00UL, 0x00000800UL, +0x0000ba00UL, 0x00007800UL, 0x00002500UL, 0x00002e00UL, 0x00001c00UL, 0x0000a600UL, 0x0000b400UL, 0x0000c600UL, +0x0000e800UL, 0x0000dd00UL, 0x00007400UL, 0x00001f00UL, 0x00004b00UL, 0x0000bd00UL, 0x00008b00UL, 0x00008a00UL, +0x00007000UL, 0x00003e00UL, 0x0000b500UL, 0x00006600UL, 0x00004800UL, 0x00000300UL, 0x0000f600UL, 0x00000e00UL, +0x00006100UL, 0x00003500UL, 0x00005700UL, 0x0000b900UL, 0x00008600UL, 0x0000c100UL, 0x00001d00UL, 0x00009e00UL, +0x0000e100UL, 0x0000f800UL, 0x00009800UL, 0x00001100UL, 0x00006900UL, 0x0000d900UL, 0x00008e00UL, 0x00009400UL, +0x00009b00UL, 0x00001e00UL, 0x00008700UL, 0x0000e900UL, 0x0000ce00UL, 0x00005500UL, 0x00002800UL, 0x0000df00UL, +0x00008c00UL, 0x0000a100UL, 0x00008900UL, 0x00000d00UL, 0x0000bf00UL, 0x0000e600UL, 0x00004200UL, 0x00006800UL, +0x00004100UL, 0x00009900UL, 0x00002d00UL, 0x00000f00UL, 0x0000b000UL, 0x00005400UL, 0x0000bb00UL, 0x00001600UL +}; + +static const ulong32 Te4_2[] = { +0x00630000UL, 0x007c0000UL, 0x00770000UL, 0x007b0000UL, 0x00f20000UL, 0x006b0000UL, 0x006f0000UL, 0x00c50000UL, +0x00300000UL, 0x00010000UL, 0x00670000UL, 0x002b0000UL, 0x00fe0000UL, 0x00d70000UL, 0x00ab0000UL, 0x00760000UL, +0x00ca0000UL, 0x00820000UL, 0x00c90000UL, 0x007d0000UL, 0x00fa0000UL, 0x00590000UL, 0x00470000UL, 0x00f00000UL, +0x00ad0000UL, 0x00d40000UL, 0x00a20000UL, 0x00af0000UL, 0x009c0000UL, 0x00a40000UL, 0x00720000UL, 0x00c00000UL, +0x00b70000UL, 0x00fd0000UL, 0x00930000UL, 0x00260000UL, 0x00360000UL, 0x003f0000UL, 0x00f70000UL, 0x00cc0000UL, +0x00340000UL, 0x00a50000UL, 0x00e50000UL, 0x00f10000UL, 0x00710000UL, 0x00d80000UL, 0x00310000UL, 0x00150000UL, +0x00040000UL, 0x00c70000UL, 0x00230000UL, 0x00c30000UL, 0x00180000UL, 0x00960000UL, 0x00050000UL, 0x009a0000UL, +0x00070000UL, 0x00120000UL, 0x00800000UL, 0x00e20000UL, 0x00eb0000UL, 0x00270000UL, 0x00b20000UL, 0x00750000UL, +0x00090000UL, 0x00830000UL, 0x002c0000UL, 0x001a0000UL, 0x001b0000UL, 0x006e0000UL, 0x005a0000UL, 0x00a00000UL, +0x00520000UL, 0x003b0000UL, 0x00d60000UL, 0x00b30000UL, 0x00290000UL, 0x00e30000UL, 0x002f0000UL, 0x00840000UL, +0x00530000UL, 0x00d10000UL, 0x00000000UL, 0x00ed0000UL, 0x00200000UL, 0x00fc0000UL, 0x00b10000UL, 0x005b0000UL, +0x006a0000UL, 0x00cb0000UL, 0x00be0000UL, 0x00390000UL, 0x004a0000UL, 0x004c0000UL, 0x00580000UL, 0x00cf0000UL, +0x00d00000UL, 0x00ef0000UL, 0x00aa0000UL, 0x00fb0000UL, 0x00430000UL, 0x004d0000UL, 0x00330000UL, 0x00850000UL, +0x00450000UL, 0x00f90000UL, 0x00020000UL, 0x007f0000UL, 0x00500000UL, 0x003c0000UL, 0x009f0000UL, 0x00a80000UL, +0x00510000UL, 0x00a30000UL, 0x00400000UL, 0x008f0000UL, 0x00920000UL, 0x009d0000UL, 0x00380000UL, 0x00f50000UL, +0x00bc0000UL, 0x00b60000UL, 0x00da0000UL, 0x00210000UL, 0x00100000UL, 0x00ff0000UL, 0x00f30000UL, 0x00d20000UL, +0x00cd0000UL, 0x000c0000UL, 0x00130000UL, 0x00ec0000UL, 0x005f0000UL, 0x00970000UL, 0x00440000UL, 0x00170000UL, +0x00c40000UL, 0x00a70000UL, 0x007e0000UL, 0x003d0000UL, 0x00640000UL, 0x005d0000UL, 0x00190000UL, 0x00730000UL, +0x00600000UL, 0x00810000UL, 0x004f0000UL, 0x00dc0000UL, 0x00220000UL, 0x002a0000UL, 0x00900000UL, 0x00880000UL, +0x00460000UL, 0x00ee0000UL, 0x00b80000UL, 0x00140000UL, 0x00de0000UL, 0x005e0000UL, 0x000b0000UL, 0x00db0000UL, +0x00e00000UL, 0x00320000UL, 0x003a0000UL, 0x000a0000UL, 0x00490000UL, 0x00060000UL, 0x00240000UL, 0x005c0000UL, +0x00c20000UL, 0x00d30000UL, 0x00ac0000UL, 0x00620000UL, 0x00910000UL, 0x00950000UL, 0x00e40000UL, 0x00790000UL, +0x00e70000UL, 0x00c80000UL, 0x00370000UL, 0x006d0000UL, 0x008d0000UL, 0x00d50000UL, 0x004e0000UL, 0x00a90000UL, +0x006c0000UL, 0x00560000UL, 0x00f40000UL, 0x00ea0000UL, 0x00650000UL, 0x007a0000UL, 0x00ae0000UL, 0x00080000UL, +0x00ba0000UL, 0x00780000UL, 0x00250000UL, 0x002e0000UL, 0x001c0000UL, 0x00a60000UL, 0x00b40000UL, 0x00c60000UL, +0x00e80000UL, 0x00dd0000UL, 0x00740000UL, 0x001f0000UL, 0x004b0000UL, 0x00bd0000UL, 0x008b0000UL, 0x008a0000UL, +0x00700000UL, 0x003e0000UL, 0x00b50000UL, 0x00660000UL, 0x00480000UL, 0x00030000UL, 0x00f60000UL, 0x000e0000UL, +0x00610000UL, 0x00350000UL, 0x00570000UL, 0x00b90000UL, 0x00860000UL, 0x00c10000UL, 0x001d0000UL, 0x009e0000UL, +0x00e10000UL, 0x00f80000UL, 0x00980000UL, 0x00110000UL, 0x00690000UL, 0x00d90000UL, 0x008e0000UL, 0x00940000UL, +0x009b0000UL, 0x001e0000UL, 0x00870000UL, 0x00e90000UL, 0x00ce0000UL, 0x00550000UL, 0x00280000UL, 0x00df0000UL, +0x008c0000UL, 0x00a10000UL, 0x00890000UL, 0x000d0000UL, 0x00bf0000UL, 0x00e60000UL, 0x00420000UL, 0x00680000UL, +0x00410000UL, 0x00990000UL, 0x002d0000UL, 0x000f0000UL, 0x00b00000UL, 0x00540000UL, 0x00bb0000UL, 0x00160000UL +}; + +static const ulong32 Te4_3[] = { +0x63000000UL, 0x7c000000UL, 0x77000000UL, 0x7b000000UL, 0xf2000000UL, 0x6b000000UL, 0x6f000000UL, 0xc5000000UL, +0x30000000UL, 0x01000000UL, 0x67000000UL, 0x2b000000UL, 0xfe000000UL, 0xd7000000UL, 0xab000000UL, 0x76000000UL, +0xca000000UL, 0x82000000UL, 0xc9000000UL, 0x7d000000UL, 0xfa000000UL, 0x59000000UL, 0x47000000UL, 0xf0000000UL, +0xad000000UL, 0xd4000000UL, 0xa2000000UL, 0xaf000000UL, 0x9c000000UL, 0xa4000000UL, 0x72000000UL, 0xc0000000UL, +0xb7000000UL, 0xfd000000UL, 0x93000000UL, 0x26000000UL, 0x36000000UL, 0x3f000000UL, 0xf7000000UL, 0xcc000000UL, +0x34000000UL, 0xa5000000UL, 0xe5000000UL, 0xf1000000UL, 0x71000000UL, 0xd8000000UL, 0x31000000UL, 0x15000000UL, +0x04000000UL, 0xc7000000UL, 0x23000000UL, 0xc3000000UL, 0x18000000UL, 0x96000000UL, 0x05000000UL, 0x9a000000UL, +0x07000000UL, 0x12000000UL, 0x80000000UL, 0xe2000000UL, 0xeb000000UL, 0x27000000UL, 0xb2000000UL, 0x75000000UL, +0x09000000UL, 0x83000000UL, 0x2c000000UL, 0x1a000000UL, 0x1b000000UL, 0x6e000000UL, 0x5a000000UL, 0xa0000000UL, +0x52000000UL, 0x3b000000UL, 0xd6000000UL, 0xb3000000UL, 0x29000000UL, 0xe3000000UL, 0x2f000000UL, 0x84000000UL, +0x53000000UL, 0xd1000000UL, 0x00000000UL, 0xed000000UL, 0x20000000UL, 0xfc000000UL, 0xb1000000UL, 0x5b000000UL, +0x6a000000UL, 0xcb000000UL, 0xbe000000UL, 0x39000000UL, 0x4a000000UL, 0x4c000000UL, 0x58000000UL, 0xcf000000UL, +0xd0000000UL, 0xef000000UL, 0xaa000000UL, 0xfb000000UL, 0x43000000UL, 0x4d000000UL, 0x33000000UL, 0x85000000UL, +0x45000000UL, 0xf9000000UL, 0x02000000UL, 0x7f000000UL, 0x50000000UL, 0x3c000000UL, 0x9f000000UL, 0xa8000000UL, +0x51000000UL, 0xa3000000UL, 0x40000000UL, 0x8f000000UL, 0x92000000UL, 0x9d000000UL, 0x38000000UL, 0xf5000000UL, +0xbc000000UL, 0xb6000000UL, 0xda000000UL, 0x21000000UL, 0x10000000UL, 0xff000000UL, 0xf3000000UL, 0xd2000000UL, +0xcd000000UL, 0x0c000000UL, 0x13000000UL, 0xec000000UL, 0x5f000000UL, 0x97000000UL, 0x44000000UL, 0x17000000UL, +0xc4000000UL, 0xa7000000UL, 0x7e000000UL, 0x3d000000UL, 0x64000000UL, 0x5d000000UL, 0x19000000UL, 0x73000000UL, +0x60000000UL, 0x81000000UL, 0x4f000000UL, 0xdc000000UL, 0x22000000UL, 0x2a000000UL, 0x90000000UL, 0x88000000UL, +0x46000000UL, 0xee000000UL, 0xb8000000UL, 0x14000000UL, 0xde000000UL, 0x5e000000UL, 0x0b000000UL, 0xdb000000UL, +0xe0000000UL, 0x32000000UL, 0x3a000000UL, 0x0a000000UL, 0x49000000UL, 0x06000000UL, 0x24000000UL, 0x5c000000UL, +0xc2000000UL, 0xd3000000UL, 0xac000000UL, 0x62000000UL, 0x91000000UL, 0x95000000UL, 0xe4000000UL, 0x79000000UL, +0xe7000000UL, 0xc8000000UL, 0x37000000UL, 0x6d000000UL, 0x8d000000UL, 0xd5000000UL, 0x4e000000UL, 0xa9000000UL, +0x6c000000UL, 0x56000000UL, 0xf4000000UL, 0xea000000UL, 0x65000000UL, 0x7a000000UL, 0xae000000UL, 0x08000000UL, +0xba000000UL, 0x78000000UL, 0x25000000UL, 0x2e000000UL, 0x1c000000UL, 0xa6000000UL, 0xb4000000UL, 0xc6000000UL, +0xe8000000UL, 0xdd000000UL, 0x74000000UL, 0x1f000000UL, 0x4b000000UL, 0xbd000000UL, 0x8b000000UL, 0x8a000000UL, +0x70000000UL, 0x3e000000UL, 0xb5000000UL, 0x66000000UL, 0x48000000UL, 0x03000000UL, 0xf6000000UL, 0x0e000000UL, +0x61000000UL, 0x35000000UL, 0x57000000UL, 0xb9000000UL, 0x86000000UL, 0xc1000000UL, 0x1d000000UL, 0x9e000000UL, +0xe1000000UL, 0xf8000000UL, 0x98000000UL, 0x11000000UL, 0x69000000UL, 0xd9000000UL, 0x8e000000UL, 0x94000000UL, +0x9b000000UL, 0x1e000000UL, 0x87000000UL, 0xe9000000UL, 0xce000000UL, 0x55000000UL, 0x28000000UL, 0xdf000000UL, +0x8c000000UL, 0xa1000000UL, 0x89000000UL, 0x0d000000UL, 0xbf000000UL, 0xe6000000UL, 0x42000000UL, 0x68000000UL, +0x41000000UL, 0x99000000UL, 0x2d000000UL, 0x0f000000UL, 0xb0000000UL, 0x54000000UL, 0xbb000000UL, 0x16000000UL +}; + +static const ulong32 TD1[256] = { + 0x5051f4a7UL, 0x537e4165UL, 0xc31a17a4UL, 0x963a275eUL, + 0xcb3bab6bUL, 0xf11f9d45UL, 0xabacfa58UL, 0x934be303UL, + 0x552030faUL, 0xf6ad766dUL, 0x9188cc76UL, 0x25f5024cUL, + 0xfc4fe5d7UL, 0xd7c52acbUL, 0x80263544UL, 0x8fb562a3UL, + 0x49deb15aUL, 0x6725ba1bUL, 0x9845ea0eUL, 0xe15dfec0UL, + 0x02c32f75UL, 0x12814cf0UL, 0xa38d4697UL, 0xc66bd3f9UL, + 0xe7038f5fUL, 0x9515929cUL, 0xebbf6d7aUL, 0xda955259UL, + 0x2dd4be83UL, 0xd3587421UL, 0x2949e069UL, 0x448ec9c8UL, + 0x6a75c289UL, 0x78f48e79UL, 0x6b99583eUL, 0xdd27b971UL, + 0xb6bee14fUL, 0x17f088adUL, 0x66c920acUL, 0xb47dce3aUL, + 0x1863df4aUL, 0x82e51a31UL, 0x60975133UL, 0x4562537fUL, + 0xe0b16477UL, 0x84bb6baeUL, 0x1cfe81a0UL, 0x94f9082bUL, + 0x58704868UL, 0x198f45fdUL, 0x8794de6cUL, 0xb7527bf8UL, + 0x23ab73d3UL, 0xe2724b02UL, 0x57e31f8fUL, 0x2a6655abUL, + 0x07b2eb28UL, 0x032fb5c2UL, 0x9a86c57bUL, 0xa5d33708UL, + 0xf2302887UL, 0xb223bfa5UL, 0xba02036aUL, 0x5ced1682UL, + 0x2b8acf1cUL, 0x92a779b4UL, 0xf0f307f2UL, 0xa14e69e2UL, + 0xcd65daf4UL, 0xd50605beUL, 0x1fd13462UL, 0x8ac4a6feUL, + 0x9d342e53UL, 0xa0a2f355UL, 0x32058ae1UL, 0x75a4f6ebUL, + 0x390b83ecUL, 0xaa4060efUL, 0x065e719fUL, 0x51bd6e10UL, + 0xf93e218aUL, 0x3d96dd06UL, 0xaedd3e05UL, 0x464de6bdUL, + 0xb591548dUL, 0x0571c45dUL, 0x6f0406d4UL, 0xff605015UL, + 0x241998fbUL, 0x97d6bde9UL, 0xcc894043UL, 0x7767d99eUL, + 0xbdb0e842UL, 0x8807898bUL, 0x38e7195bUL, 0xdb79c8eeUL, + 0x47a17c0aUL, 0xe97c420fUL, 0xc9f8841eUL, 0x00000000UL, + 0x83098086UL, 0x48322bedUL, 0xac1e1170UL, 0x4e6c5a72UL, + 0xfbfd0effUL, 0x560f8538UL, 0x1e3daed5UL, 0x27362d39UL, + 0x640a0fd9UL, 0x21685ca6UL, 0xd19b5b54UL, 0x3a24362eUL, + 0xb10c0a67UL, 0x0f9357e7UL, 0xd2b4ee96UL, 0x9e1b9b91UL, + 0x4f80c0c5UL, 0xa261dc20UL, 0x695a774bUL, 0x161c121aUL, + 0x0ae293baUL, 0xe5c0a02aUL, 0x433c22e0UL, 0x1d121b17UL, + 0x0b0e090dUL, 0xadf28bc7UL, 0xb92db6a8UL, 0xc8141ea9UL, + 0x8557f119UL, 0x4caf7507UL, 0xbbee99ddUL, 0xfda37f60UL, + 0x9ff70126UL, 0xbc5c72f5UL, 0xc544663bUL, 0x345bfb7eUL, + 0x768b4329UL, 0xdccb23c6UL, 0x68b6edfcUL, 0x63b8e4f1UL, + 0xcad731dcUL, 0x10426385UL, 0x40139722UL, 0x2084c611UL, + 0x7d854a24UL, 0xf8d2bb3dUL, 0x11aef932UL, 0x6dc729a1UL, + 0x4b1d9e2fUL, 0xf3dcb230UL, 0xec0d8652UL, 0xd077c1e3UL, + 0x6c2bb316UL, 0x99a970b9UL, 0xfa119448UL, 0x2247e964UL, + 0xc4a8fc8cUL, 0x1aa0f03fUL, 0xd8567d2cUL, 0xef223390UL, + 0xc787494eUL, 0xc1d938d1UL, 0xfe8ccaa2UL, 0x3698d40bUL, + 0xcfa6f581UL, 0x28a57adeUL, 0x26dab78eUL, 0xa43fadbfUL, + 0xe42c3a9dUL, 0x0d507892UL, 0x9b6a5fccUL, 0x62547e46UL, + 0xc2f68d13UL, 0xe890d8b8UL, 0x5e2e39f7UL, 0xf582c3afUL, + 0xbe9f5d80UL, 0x7c69d093UL, 0xa96fd52dUL, 0xb3cf2512UL, + 0x3bc8ac99UL, 0xa710187dUL, 0x6ee89c63UL, 0x7bdb3bbbUL, + 0x09cd2678UL, 0xf46e5918UL, 0x01ec9ab7UL, 0xa8834f9aUL, + 0x65e6956eUL, 0x7eaaffe6UL, 0x0821bccfUL, 0xe6ef15e8UL, + 0xd9bae79bUL, 0xce4a6f36UL, 0xd4ea9f09UL, 0xd629b07cUL, + 0xaf31a4b2UL, 0x312a3f23UL, 0x30c6a594UL, 0xc035a266UL, + 0x37744ebcUL, 0xa6fc82caUL, 0xb0e090d0UL, 0x1533a7d8UL, + 0x4af10498UL, 0xf741ecdaUL, 0x0e7fcd50UL, 0x2f1791f6UL, + 0x8d764dd6UL, 0x4d43efb0UL, 0x54ccaa4dUL, 0xdfe49604UL, + 0xe39ed1b5UL, 0x1b4c6a88UL, 0xb8c12c1fUL, 0x7f466551UL, + 0x049d5eeaUL, 0x5d018c35UL, 0x73fa8774UL, 0x2efb0b41UL, + 0x5ab3671dUL, 0x5292dbd2UL, 0x33e91056UL, 0x136dd647UL, + 0x8c9ad761UL, 0x7a37a10cUL, 0x8e59f814UL, 0x89eb133cUL, + 0xeecea927UL, 0x35b761c9UL, 0xede11ce5UL, 0x3c7a47b1UL, + 0x599cd2dfUL, 0x3f55f273UL, 0x791814ceUL, 0xbf73c737UL, + 0xea53f7cdUL, 0x5b5ffdaaUL, 0x14df3d6fUL, 0x867844dbUL, + 0x81caaff3UL, 0x3eb968c4UL, 0x2c382434UL, 0x5fc2a340UL, + 0x72161dc3UL, 0x0cbce225UL, 0x8b283c49UL, 0x41ff0d95UL, + 0x7139a801UL, 0xde080cb3UL, 0x9cd8b4e4UL, 0x906456c1UL, + 0x617bcb84UL, 0x70d532b6UL, 0x74486c5cUL, 0x42d0b857UL, +}; +static const ulong32 TD2[256] = { + 0xa75051f4UL, 0x65537e41UL, 0xa4c31a17UL, 0x5e963a27UL, + 0x6bcb3babUL, 0x45f11f9dUL, 0x58abacfaUL, 0x03934be3UL, + 0xfa552030UL, 0x6df6ad76UL, 0x769188ccUL, 0x4c25f502UL, + 0xd7fc4fe5UL, 0xcbd7c52aUL, 0x44802635UL, 0xa38fb562UL, + 0x5a49deb1UL, 0x1b6725baUL, 0x0e9845eaUL, 0xc0e15dfeUL, + 0x7502c32fUL, 0xf012814cUL, 0x97a38d46UL, 0xf9c66bd3UL, + 0x5fe7038fUL, 0x9c951592UL, 0x7aebbf6dUL, 0x59da9552UL, + 0x832dd4beUL, 0x21d35874UL, 0x692949e0UL, 0xc8448ec9UL, + 0x896a75c2UL, 0x7978f48eUL, 0x3e6b9958UL, 0x71dd27b9UL, + 0x4fb6bee1UL, 0xad17f088UL, 0xac66c920UL, 0x3ab47dceUL, + 0x4a1863dfUL, 0x3182e51aUL, 0x33609751UL, 0x7f456253UL, + 0x77e0b164UL, 0xae84bb6bUL, 0xa01cfe81UL, 0x2b94f908UL, + 0x68587048UL, 0xfd198f45UL, 0x6c8794deUL, 0xf8b7527bUL, + 0xd323ab73UL, 0x02e2724bUL, 0x8f57e31fUL, 0xab2a6655UL, + 0x2807b2ebUL, 0xc2032fb5UL, 0x7b9a86c5UL, 0x08a5d337UL, + 0x87f23028UL, 0xa5b223bfUL, 0x6aba0203UL, 0x825ced16UL, + 0x1c2b8acfUL, 0xb492a779UL, 0xf2f0f307UL, 0xe2a14e69UL, + 0xf4cd65daUL, 0xbed50605UL, 0x621fd134UL, 0xfe8ac4a6UL, + 0x539d342eUL, 0x55a0a2f3UL, 0xe132058aUL, 0xeb75a4f6UL, + 0xec390b83UL, 0xefaa4060UL, 0x9f065e71UL, 0x1051bd6eUL, + 0x8af93e21UL, 0x063d96ddUL, 0x05aedd3eUL, 0xbd464de6UL, + 0x8db59154UL, 0x5d0571c4UL, 0xd46f0406UL, 0x15ff6050UL, + 0xfb241998UL, 0xe997d6bdUL, 0x43cc8940UL, 0x9e7767d9UL, + 0x42bdb0e8UL, 0x8b880789UL, 0x5b38e719UL, 0xeedb79c8UL, + 0x0a47a17cUL, 0x0fe97c42UL, 0x1ec9f884UL, 0x00000000UL, + 0x86830980UL, 0xed48322bUL, 0x70ac1e11UL, 0x724e6c5aUL, + 0xfffbfd0eUL, 0x38560f85UL, 0xd51e3daeUL, 0x3927362dUL, + 0xd9640a0fUL, 0xa621685cUL, 0x54d19b5bUL, 0x2e3a2436UL, + 0x67b10c0aUL, 0xe70f9357UL, 0x96d2b4eeUL, 0x919e1b9bUL, + 0xc54f80c0UL, 0x20a261dcUL, 0x4b695a77UL, 0x1a161c12UL, + 0xba0ae293UL, 0x2ae5c0a0UL, 0xe0433c22UL, 0x171d121bUL, + 0x0d0b0e09UL, 0xc7adf28bUL, 0xa8b92db6UL, 0xa9c8141eUL, + 0x198557f1UL, 0x074caf75UL, 0xddbbee99UL, 0x60fda37fUL, + 0x269ff701UL, 0xf5bc5c72UL, 0x3bc54466UL, 0x7e345bfbUL, + 0x29768b43UL, 0xc6dccb23UL, 0xfc68b6edUL, 0xf163b8e4UL, + 0xdccad731UL, 0x85104263UL, 0x22401397UL, 0x112084c6UL, + 0x247d854aUL, 0x3df8d2bbUL, 0x3211aef9UL, 0xa16dc729UL, + 0x2f4b1d9eUL, 0x30f3dcb2UL, 0x52ec0d86UL, 0xe3d077c1UL, + 0x166c2bb3UL, 0xb999a970UL, 0x48fa1194UL, 0x642247e9UL, + 0x8cc4a8fcUL, 0x3f1aa0f0UL, 0x2cd8567dUL, 0x90ef2233UL, + 0x4ec78749UL, 0xd1c1d938UL, 0xa2fe8ccaUL, 0x0b3698d4UL, + 0x81cfa6f5UL, 0xde28a57aUL, 0x8e26dab7UL, 0xbfa43fadUL, + 0x9de42c3aUL, 0x920d5078UL, 0xcc9b6a5fUL, 0x4662547eUL, + 0x13c2f68dUL, 0xb8e890d8UL, 0xf75e2e39UL, 0xaff582c3UL, + 0x80be9f5dUL, 0x937c69d0UL, 0x2da96fd5UL, 0x12b3cf25UL, + 0x993bc8acUL, 0x7da71018UL, 0x636ee89cUL, 0xbb7bdb3bUL, + 0x7809cd26UL, 0x18f46e59UL, 0xb701ec9aUL, 0x9aa8834fUL, + 0x6e65e695UL, 0xe67eaaffUL, 0xcf0821bcUL, 0xe8e6ef15UL, + 0x9bd9bae7UL, 0x36ce4a6fUL, 0x09d4ea9fUL, 0x7cd629b0UL, + 0xb2af31a4UL, 0x23312a3fUL, 0x9430c6a5UL, 0x66c035a2UL, + 0xbc37744eUL, 0xcaa6fc82UL, 0xd0b0e090UL, 0xd81533a7UL, + 0x984af104UL, 0xdaf741ecUL, 0x500e7fcdUL, 0xf62f1791UL, + 0xd68d764dUL, 0xb04d43efUL, 0x4d54ccaaUL, 0x04dfe496UL, + 0xb5e39ed1UL, 0x881b4c6aUL, 0x1fb8c12cUL, 0x517f4665UL, + 0xea049d5eUL, 0x355d018cUL, 0x7473fa87UL, 0x412efb0bUL, + 0x1d5ab367UL, 0xd25292dbUL, 0x5633e910UL, 0x47136dd6UL, + 0x618c9ad7UL, 0x0c7a37a1UL, 0x148e59f8UL, 0x3c89eb13UL, + 0x27eecea9UL, 0xc935b761UL, 0xe5ede11cUL, 0xb13c7a47UL, + 0xdf599cd2UL, 0x733f55f2UL, 0xce791814UL, 0x37bf73c7UL, + 0xcdea53f7UL, 0xaa5b5ffdUL, 0x6f14df3dUL, 0xdb867844UL, + 0xf381caafUL, 0xc43eb968UL, 0x342c3824UL, 0x405fc2a3UL, + 0xc372161dUL, 0x250cbce2UL, 0x498b283cUL, 0x9541ff0dUL, + 0x017139a8UL, 0xb3de080cUL, 0xe49cd8b4UL, 0xc1906456UL, + 0x84617bcbUL, 0xb670d532UL, 0x5c74486cUL, 0x5742d0b8UL, +}; +static const ulong32 TD3[256] = { + 0xf4a75051UL, 0x4165537eUL, 0x17a4c31aUL, 0x275e963aUL, + 0xab6bcb3bUL, 0x9d45f11fUL, 0xfa58abacUL, 0xe303934bUL, + 0x30fa5520UL, 0x766df6adUL, 0xcc769188UL, 0x024c25f5UL, + 0xe5d7fc4fUL, 0x2acbd7c5UL, 0x35448026UL, 0x62a38fb5UL, + 0xb15a49deUL, 0xba1b6725UL, 0xea0e9845UL, 0xfec0e15dUL, + 0x2f7502c3UL, 0x4cf01281UL, 0x4697a38dUL, 0xd3f9c66bUL, + 0x8f5fe703UL, 0x929c9515UL, 0x6d7aebbfUL, 0x5259da95UL, + 0xbe832dd4UL, 0x7421d358UL, 0xe0692949UL, 0xc9c8448eUL, + 0xc2896a75UL, 0x8e7978f4UL, 0x583e6b99UL, 0xb971dd27UL, + 0xe14fb6beUL, 0x88ad17f0UL, 0x20ac66c9UL, 0xce3ab47dUL, + 0xdf4a1863UL, 0x1a3182e5UL, 0x51336097UL, 0x537f4562UL, + 0x6477e0b1UL, 0x6bae84bbUL, 0x81a01cfeUL, 0x082b94f9UL, + 0x48685870UL, 0x45fd198fUL, 0xde6c8794UL, 0x7bf8b752UL, + 0x73d323abUL, 0x4b02e272UL, 0x1f8f57e3UL, 0x55ab2a66UL, + 0xeb2807b2UL, 0xb5c2032fUL, 0xc57b9a86UL, 0x3708a5d3UL, + 0x2887f230UL, 0xbfa5b223UL, 0x036aba02UL, 0x16825cedUL, + 0xcf1c2b8aUL, 0x79b492a7UL, 0x07f2f0f3UL, 0x69e2a14eUL, + 0xdaf4cd65UL, 0x05bed506UL, 0x34621fd1UL, 0xa6fe8ac4UL, + 0x2e539d34UL, 0xf355a0a2UL, 0x8ae13205UL, 0xf6eb75a4UL, + 0x83ec390bUL, 0x60efaa40UL, 0x719f065eUL, 0x6e1051bdUL, + 0x218af93eUL, 0xdd063d96UL, 0x3e05aeddUL, 0xe6bd464dUL, + 0x548db591UL, 0xc45d0571UL, 0x06d46f04UL, 0x5015ff60UL, + 0x98fb2419UL, 0xbde997d6UL, 0x4043cc89UL, 0xd99e7767UL, + 0xe842bdb0UL, 0x898b8807UL, 0x195b38e7UL, 0xc8eedb79UL, + 0x7c0a47a1UL, 0x420fe97cUL, 0x841ec9f8UL, 0x00000000UL, + 0x80868309UL, 0x2bed4832UL, 0x1170ac1eUL, 0x5a724e6cUL, + 0x0efffbfdUL, 0x8538560fUL, 0xaed51e3dUL, 0x2d392736UL, + 0x0fd9640aUL, 0x5ca62168UL, 0x5b54d19bUL, 0x362e3a24UL, + 0x0a67b10cUL, 0x57e70f93UL, 0xee96d2b4UL, 0x9b919e1bUL, + 0xc0c54f80UL, 0xdc20a261UL, 0x774b695aUL, 0x121a161cUL, + 0x93ba0ae2UL, 0xa02ae5c0UL, 0x22e0433cUL, 0x1b171d12UL, + 0x090d0b0eUL, 0x8bc7adf2UL, 0xb6a8b92dUL, 0x1ea9c814UL, + 0xf1198557UL, 0x75074cafUL, 0x99ddbbeeUL, 0x7f60fda3UL, + 0x01269ff7UL, 0x72f5bc5cUL, 0x663bc544UL, 0xfb7e345bUL, + 0x4329768bUL, 0x23c6dccbUL, 0xedfc68b6UL, 0xe4f163b8UL, + 0x31dccad7UL, 0x63851042UL, 0x97224013UL, 0xc6112084UL, + 0x4a247d85UL, 0xbb3df8d2UL, 0xf93211aeUL, 0x29a16dc7UL, + 0x9e2f4b1dUL, 0xb230f3dcUL, 0x8652ec0dUL, 0xc1e3d077UL, + 0xb3166c2bUL, 0x70b999a9UL, 0x9448fa11UL, 0xe9642247UL, + 0xfc8cc4a8UL, 0xf03f1aa0UL, 0x7d2cd856UL, 0x3390ef22UL, + 0x494ec787UL, 0x38d1c1d9UL, 0xcaa2fe8cUL, 0xd40b3698UL, + 0xf581cfa6UL, 0x7ade28a5UL, 0xb78e26daUL, 0xadbfa43fUL, + 0x3a9de42cUL, 0x78920d50UL, 0x5fcc9b6aUL, 0x7e466254UL, + 0x8d13c2f6UL, 0xd8b8e890UL, 0x39f75e2eUL, 0xc3aff582UL, + 0x5d80be9fUL, 0xd0937c69UL, 0xd52da96fUL, 0x2512b3cfUL, + 0xac993bc8UL, 0x187da710UL, 0x9c636ee8UL, 0x3bbb7bdbUL, + 0x267809cdUL, 0x5918f46eUL, 0x9ab701ecUL, 0x4f9aa883UL, + 0x956e65e6UL, 0xffe67eaaUL, 0xbccf0821UL, 0x15e8e6efUL, + 0xe79bd9baUL, 0x6f36ce4aUL, 0x9f09d4eaUL, 0xb07cd629UL, + 0xa4b2af31UL, 0x3f23312aUL, 0xa59430c6UL, 0xa266c035UL, + 0x4ebc3774UL, 0x82caa6fcUL, 0x90d0b0e0UL, 0xa7d81533UL, + 0x04984af1UL, 0xecdaf741UL, 0xcd500e7fUL, 0x91f62f17UL, + 0x4dd68d76UL, 0xefb04d43UL, 0xaa4d54ccUL, 0x9604dfe4UL, + 0xd1b5e39eUL, 0x6a881b4cUL, 0x2c1fb8c1UL, 0x65517f46UL, + 0x5eea049dUL, 0x8c355d01UL, 0x877473faUL, 0x0b412efbUL, + 0x671d5ab3UL, 0xdbd25292UL, 0x105633e9UL, 0xd647136dUL, + 0xd7618c9aUL, 0xa10c7a37UL, 0xf8148e59UL, 0x133c89ebUL, + 0xa927eeceUL, 0x61c935b7UL, 0x1ce5ede1UL, 0x47b13c7aUL, + 0xd2df599cUL, 0xf2733f55UL, 0x14ce7918UL, 0xc737bf73UL, + 0xf7cdea53UL, 0xfdaa5b5fUL, 0x3d6f14dfUL, 0x44db8678UL, + 0xaff381caUL, 0x68c43eb9UL, 0x24342c38UL, 0xa3405fc2UL, + 0x1dc37216UL, 0xe2250cbcUL, 0x3c498b28UL, 0x0d9541ffUL, + 0xa8017139UL, 0x0cb3de08UL, 0xb4e49cd8UL, 0x56c19064UL, + 0xcb84617bUL, 0x32b670d5UL, 0x6c5c7448UL, 0xb85742d0UL, +}; + +static const ulong32 Tks0[] = { +0x00000000UL, 0x0e090d0bUL, 0x1c121a16UL, 0x121b171dUL, 0x3824342cUL, 0x362d3927UL, 0x24362e3aUL, 0x2a3f2331UL, +0x70486858UL, 0x7e416553UL, 0x6c5a724eUL, 0x62537f45UL, 0x486c5c74UL, 0x4665517fUL, 0x547e4662UL, 0x5a774b69UL, +0xe090d0b0UL, 0xee99ddbbUL, 0xfc82caa6UL, 0xf28bc7adUL, 0xd8b4e49cUL, 0xd6bde997UL, 0xc4a6fe8aUL, 0xcaaff381UL, +0x90d8b8e8UL, 0x9ed1b5e3UL, 0x8ccaa2feUL, 0x82c3aff5UL, 0xa8fc8cc4UL, 0xa6f581cfUL, 0xb4ee96d2UL, 0xbae79bd9UL, +0xdb3bbb7bUL, 0xd532b670UL, 0xc729a16dUL, 0xc920ac66UL, 0xe31f8f57UL, 0xed16825cUL, 0xff0d9541UL, 0xf104984aUL, +0xab73d323UL, 0xa57ade28UL, 0xb761c935UL, 0xb968c43eUL, 0x9357e70fUL, 0x9d5eea04UL, 0x8f45fd19UL, 0x814cf012UL, +0x3bab6bcbUL, 0x35a266c0UL, 0x27b971ddUL, 0x29b07cd6UL, 0x038f5fe7UL, 0x0d8652ecUL, 0x1f9d45f1UL, 0x119448faUL, +0x4be30393UL, 0x45ea0e98UL, 0x57f11985UL, 0x59f8148eUL, 0x73c737bfUL, 0x7dce3ab4UL, 0x6fd52da9UL, 0x61dc20a2UL, +0xad766df6UL, 0xa37f60fdUL, 0xb16477e0UL, 0xbf6d7aebUL, 0x955259daUL, 0x9b5b54d1UL, 0x894043ccUL, 0x87494ec7UL, +0xdd3e05aeUL, 0xd33708a5UL, 0xc12c1fb8UL, 0xcf2512b3UL, 0xe51a3182UL, 0xeb133c89UL, 0xf9082b94UL, 0xf701269fUL, +0x4de6bd46UL, 0x43efb04dUL, 0x51f4a750UL, 0x5ffdaa5bUL, 0x75c2896aUL, 0x7bcb8461UL, 0x69d0937cUL, 0x67d99e77UL, +0x3daed51eUL, 0x33a7d815UL, 0x21bccf08UL, 0x2fb5c203UL, 0x058ae132UL, 0x0b83ec39UL, 0x1998fb24UL, 0x1791f62fUL, +0x764dd68dUL, 0x7844db86UL, 0x6a5fcc9bUL, 0x6456c190UL, 0x4e69e2a1UL, 0x4060efaaUL, 0x527bf8b7UL, 0x5c72f5bcUL, +0x0605bed5UL, 0x080cb3deUL, 0x1a17a4c3UL, 0x141ea9c8UL, 0x3e218af9UL, 0x302887f2UL, 0x223390efUL, 0x2c3a9de4UL, +0x96dd063dUL, 0x98d40b36UL, 0x8acf1c2bUL, 0x84c61120UL, 0xaef93211UL, 0xa0f03f1aUL, 0xb2eb2807UL, 0xbce2250cUL, +0xe6956e65UL, 0xe89c636eUL, 0xfa877473UL, 0xf48e7978UL, 0xdeb15a49UL, 0xd0b85742UL, 0xc2a3405fUL, 0xccaa4d54UL, +0x41ecdaf7UL, 0x4fe5d7fcUL, 0x5dfec0e1UL, 0x53f7cdeaUL, 0x79c8eedbUL, 0x77c1e3d0UL, 0x65daf4cdUL, 0x6bd3f9c6UL, +0x31a4b2afUL, 0x3fadbfa4UL, 0x2db6a8b9UL, 0x23bfa5b2UL, 0x09808683UL, 0x07898b88UL, 0x15929c95UL, 0x1b9b919eUL, +0xa17c0a47UL, 0xaf75074cUL, 0xbd6e1051UL, 0xb3671d5aUL, 0x99583e6bUL, 0x97513360UL, 0x854a247dUL, 0x8b432976UL, +0xd134621fUL, 0xdf3d6f14UL, 0xcd267809UL, 0xc32f7502UL, 0xe9105633UL, 0xe7195b38UL, 0xf5024c25UL, 0xfb0b412eUL, +0x9ad7618cUL, 0x94de6c87UL, 0x86c57b9aUL, 0x88cc7691UL, 0xa2f355a0UL, 0xacfa58abUL, 0xbee14fb6UL, 0xb0e842bdUL, +0xea9f09d4UL, 0xe49604dfUL, 0xf68d13c2UL, 0xf8841ec9UL, 0xd2bb3df8UL, 0xdcb230f3UL, 0xcea927eeUL, 0xc0a02ae5UL, +0x7a47b13cUL, 0x744ebc37UL, 0x6655ab2aUL, 0x685ca621UL, 0x42638510UL, 0x4c6a881bUL, 0x5e719f06UL, 0x5078920dUL, +0x0a0fd964UL, 0x0406d46fUL, 0x161dc372UL, 0x1814ce79UL, 0x322bed48UL, 0x3c22e043UL, 0x2e39f75eUL, 0x2030fa55UL, +0xec9ab701UL, 0xe293ba0aUL, 0xf088ad17UL, 0xfe81a01cUL, 0xd4be832dUL, 0xdab78e26UL, 0xc8ac993bUL, 0xc6a59430UL, +0x9cd2df59UL, 0x92dbd252UL, 0x80c0c54fUL, 0x8ec9c844UL, 0xa4f6eb75UL, 0xaaffe67eUL, 0xb8e4f163UL, 0xb6edfc68UL, +0x0c0a67b1UL, 0x02036abaUL, 0x10187da7UL, 0x1e1170acUL, 0x342e539dUL, 0x3a275e96UL, 0x283c498bUL, 0x26354480UL, +0x7c420fe9UL, 0x724b02e2UL, 0x605015ffUL, 0x6e5918f4UL, 0x44663bc5UL, 0x4a6f36ceUL, 0x587421d3UL, 0x567d2cd8UL, +0x37a10c7aUL, 0x39a80171UL, 0x2bb3166cUL, 0x25ba1b67UL, 0x0f853856UL, 0x018c355dUL, 0x13972240UL, 0x1d9e2f4bUL, +0x47e96422UL, 0x49e06929UL, 0x5bfb7e34UL, 0x55f2733fUL, 0x7fcd500eUL, 0x71c45d05UL, 0x63df4a18UL, 0x6dd64713UL, +0xd731dccaUL, 0xd938d1c1UL, 0xcb23c6dcUL, 0xc52acbd7UL, 0xef15e8e6UL, 0xe11ce5edUL, 0xf307f2f0UL, 0xfd0efffbUL, +0xa779b492UL, 0xa970b999UL, 0xbb6bae84UL, 0xb562a38fUL, 0x9f5d80beUL, 0x91548db5UL, 0x834f9aa8UL, 0x8d4697a3UL +}; + +static const ulong32 Tks1[] = { +0x00000000UL, 0x0b0e090dUL, 0x161c121aUL, 0x1d121b17UL, 0x2c382434UL, 0x27362d39UL, 0x3a24362eUL, 0x312a3f23UL, +0x58704868UL, 0x537e4165UL, 0x4e6c5a72UL, 0x4562537fUL, 0x74486c5cUL, 0x7f466551UL, 0x62547e46UL, 0x695a774bUL, +0xb0e090d0UL, 0xbbee99ddUL, 0xa6fc82caUL, 0xadf28bc7UL, 0x9cd8b4e4UL, 0x97d6bde9UL, 0x8ac4a6feUL, 0x81caaff3UL, +0xe890d8b8UL, 0xe39ed1b5UL, 0xfe8ccaa2UL, 0xf582c3afUL, 0xc4a8fc8cUL, 0xcfa6f581UL, 0xd2b4ee96UL, 0xd9bae79bUL, +0x7bdb3bbbUL, 0x70d532b6UL, 0x6dc729a1UL, 0x66c920acUL, 0x57e31f8fUL, 0x5ced1682UL, 0x41ff0d95UL, 0x4af10498UL, +0x23ab73d3UL, 0x28a57adeUL, 0x35b761c9UL, 0x3eb968c4UL, 0x0f9357e7UL, 0x049d5eeaUL, 0x198f45fdUL, 0x12814cf0UL, +0xcb3bab6bUL, 0xc035a266UL, 0xdd27b971UL, 0xd629b07cUL, 0xe7038f5fUL, 0xec0d8652UL, 0xf11f9d45UL, 0xfa119448UL, +0x934be303UL, 0x9845ea0eUL, 0x8557f119UL, 0x8e59f814UL, 0xbf73c737UL, 0xb47dce3aUL, 0xa96fd52dUL, 0xa261dc20UL, +0xf6ad766dUL, 0xfda37f60UL, 0xe0b16477UL, 0xebbf6d7aUL, 0xda955259UL, 0xd19b5b54UL, 0xcc894043UL, 0xc787494eUL, +0xaedd3e05UL, 0xa5d33708UL, 0xb8c12c1fUL, 0xb3cf2512UL, 0x82e51a31UL, 0x89eb133cUL, 0x94f9082bUL, 0x9ff70126UL, +0x464de6bdUL, 0x4d43efb0UL, 0x5051f4a7UL, 0x5b5ffdaaUL, 0x6a75c289UL, 0x617bcb84UL, 0x7c69d093UL, 0x7767d99eUL, +0x1e3daed5UL, 0x1533a7d8UL, 0x0821bccfUL, 0x032fb5c2UL, 0x32058ae1UL, 0x390b83ecUL, 0x241998fbUL, 0x2f1791f6UL, +0x8d764dd6UL, 0x867844dbUL, 0x9b6a5fccUL, 0x906456c1UL, 0xa14e69e2UL, 0xaa4060efUL, 0xb7527bf8UL, 0xbc5c72f5UL, +0xd50605beUL, 0xde080cb3UL, 0xc31a17a4UL, 0xc8141ea9UL, 0xf93e218aUL, 0xf2302887UL, 0xef223390UL, 0xe42c3a9dUL, +0x3d96dd06UL, 0x3698d40bUL, 0x2b8acf1cUL, 0x2084c611UL, 0x11aef932UL, 0x1aa0f03fUL, 0x07b2eb28UL, 0x0cbce225UL, +0x65e6956eUL, 0x6ee89c63UL, 0x73fa8774UL, 0x78f48e79UL, 0x49deb15aUL, 0x42d0b857UL, 0x5fc2a340UL, 0x54ccaa4dUL, +0xf741ecdaUL, 0xfc4fe5d7UL, 0xe15dfec0UL, 0xea53f7cdUL, 0xdb79c8eeUL, 0xd077c1e3UL, 0xcd65daf4UL, 0xc66bd3f9UL, +0xaf31a4b2UL, 0xa43fadbfUL, 0xb92db6a8UL, 0xb223bfa5UL, 0x83098086UL, 0x8807898bUL, 0x9515929cUL, 0x9e1b9b91UL, +0x47a17c0aUL, 0x4caf7507UL, 0x51bd6e10UL, 0x5ab3671dUL, 0x6b99583eUL, 0x60975133UL, 0x7d854a24UL, 0x768b4329UL, +0x1fd13462UL, 0x14df3d6fUL, 0x09cd2678UL, 0x02c32f75UL, 0x33e91056UL, 0x38e7195bUL, 0x25f5024cUL, 0x2efb0b41UL, +0x8c9ad761UL, 0x8794de6cUL, 0x9a86c57bUL, 0x9188cc76UL, 0xa0a2f355UL, 0xabacfa58UL, 0xb6bee14fUL, 0xbdb0e842UL, +0xd4ea9f09UL, 0xdfe49604UL, 0xc2f68d13UL, 0xc9f8841eUL, 0xf8d2bb3dUL, 0xf3dcb230UL, 0xeecea927UL, 0xe5c0a02aUL, +0x3c7a47b1UL, 0x37744ebcUL, 0x2a6655abUL, 0x21685ca6UL, 0x10426385UL, 0x1b4c6a88UL, 0x065e719fUL, 0x0d507892UL, +0x640a0fd9UL, 0x6f0406d4UL, 0x72161dc3UL, 0x791814ceUL, 0x48322bedUL, 0x433c22e0UL, 0x5e2e39f7UL, 0x552030faUL, +0x01ec9ab7UL, 0x0ae293baUL, 0x17f088adUL, 0x1cfe81a0UL, 0x2dd4be83UL, 0x26dab78eUL, 0x3bc8ac99UL, 0x30c6a594UL, +0x599cd2dfUL, 0x5292dbd2UL, 0x4f80c0c5UL, 0x448ec9c8UL, 0x75a4f6ebUL, 0x7eaaffe6UL, 0x63b8e4f1UL, 0x68b6edfcUL, +0xb10c0a67UL, 0xba02036aUL, 0xa710187dUL, 0xac1e1170UL, 0x9d342e53UL, 0x963a275eUL, 0x8b283c49UL, 0x80263544UL, +0xe97c420fUL, 0xe2724b02UL, 0xff605015UL, 0xf46e5918UL, 0xc544663bUL, 0xce4a6f36UL, 0xd3587421UL, 0xd8567d2cUL, +0x7a37a10cUL, 0x7139a801UL, 0x6c2bb316UL, 0x6725ba1bUL, 0x560f8538UL, 0x5d018c35UL, 0x40139722UL, 0x4b1d9e2fUL, +0x2247e964UL, 0x2949e069UL, 0x345bfb7eUL, 0x3f55f273UL, 0x0e7fcd50UL, 0x0571c45dUL, 0x1863df4aUL, 0x136dd647UL, +0xcad731dcUL, 0xc1d938d1UL, 0xdccb23c6UL, 0xd7c52acbUL, 0xe6ef15e8UL, 0xede11ce5UL, 0xf0f307f2UL, 0xfbfd0effUL, +0x92a779b4UL, 0x99a970b9UL, 0x84bb6baeUL, 0x8fb562a3UL, 0xbe9f5d80UL, 0xb591548dUL, 0xa8834f9aUL, 0xa38d4697UL +}; + +static const ulong32 Tks2[] = { +0x00000000UL, 0x0d0b0e09UL, 0x1a161c12UL, 0x171d121bUL, 0x342c3824UL, 0x3927362dUL, 0x2e3a2436UL, 0x23312a3fUL, +0x68587048UL, 0x65537e41UL, 0x724e6c5aUL, 0x7f456253UL, 0x5c74486cUL, 0x517f4665UL, 0x4662547eUL, 0x4b695a77UL, +0xd0b0e090UL, 0xddbbee99UL, 0xcaa6fc82UL, 0xc7adf28bUL, 0xe49cd8b4UL, 0xe997d6bdUL, 0xfe8ac4a6UL, 0xf381caafUL, +0xb8e890d8UL, 0xb5e39ed1UL, 0xa2fe8ccaUL, 0xaff582c3UL, 0x8cc4a8fcUL, 0x81cfa6f5UL, 0x96d2b4eeUL, 0x9bd9bae7UL, +0xbb7bdb3bUL, 0xb670d532UL, 0xa16dc729UL, 0xac66c920UL, 0x8f57e31fUL, 0x825ced16UL, 0x9541ff0dUL, 0x984af104UL, +0xd323ab73UL, 0xde28a57aUL, 0xc935b761UL, 0xc43eb968UL, 0xe70f9357UL, 0xea049d5eUL, 0xfd198f45UL, 0xf012814cUL, +0x6bcb3babUL, 0x66c035a2UL, 0x71dd27b9UL, 0x7cd629b0UL, 0x5fe7038fUL, 0x52ec0d86UL, 0x45f11f9dUL, 0x48fa1194UL, +0x03934be3UL, 0x0e9845eaUL, 0x198557f1UL, 0x148e59f8UL, 0x37bf73c7UL, 0x3ab47dceUL, 0x2da96fd5UL, 0x20a261dcUL, +0x6df6ad76UL, 0x60fda37fUL, 0x77e0b164UL, 0x7aebbf6dUL, 0x59da9552UL, 0x54d19b5bUL, 0x43cc8940UL, 0x4ec78749UL, +0x05aedd3eUL, 0x08a5d337UL, 0x1fb8c12cUL, 0x12b3cf25UL, 0x3182e51aUL, 0x3c89eb13UL, 0x2b94f908UL, 0x269ff701UL, +0xbd464de6UL, 0xb04d43efUL, 0xa75051f4UL, 0xaa5b5ffdUL, 0x896a75c2UL, 0x84617bcbUL, 0x937c69d0UL, 0x9e7767d9UL, +0xd51e3daeUL, 0xd81533a7UL, 0xcf0821bcUL, 0xc2032fb5UL, 0xe132058aUL, 0xec390b83UL, 0xfb241998UL, 0xf62f1791UL, +0xd68d764dUL, 0xdb867844UL, 0xcc9b6a5fUL, 0xc1906456UL, 0xe2a14e69UL, 0xefaa4060UL, 0xf8b7527bUL, 0xf5bc5c72UL, +0xbed50605UL, 0xb3de080cUL, 0xa4c31a17UL, 0xa9c8141eUL, 0x8af93e21UL, 0x87f23028UL, 0x90ef2233UL, 0x9de42c3aUL, +0x063d96ddUL, 0x0b3698d4UL, 0x1c2b8acfUL, 0x112084c6UL, 0x3211aef9UL, 0x3f1aa0f0UL, 0x2807b2ebUL, 0x250cbce2UL, +0x6e65e695UL, 0x636ee89cUL, 0x7473fa87UL, 0x7978f48eUL, 0x5a49deb1UL, 0x5742d0b8UL, 0x405fc2a3UL, 0x4d54ccaaUL, +0xdaf741ecUL, 0xd7fc4fe5UL, 0xc0e15dfeUL, 0xcdea53f7UL, 0xeedb79c8UL, 0xe3d077c1UL, 0xf4cd65daUL, 0xf9c66bd3UL, +0xb2af31a4UL, 0xbfa43fadUL, 0xa8b92db6UL, 0xa5b223bfUL, 0x86830980UL, 0x8b880789UL, 0x9c951592UL, 0x919e1b9bUL, +0x0a47a17cUL, 0x074caf75UL, 0x1051bd6eUL, 0x1d5ab367UL, 0x3e6b9958UL, 0x33609751UL, 0x247d854aUL, 0x29768b43UL, +0x621fd134UL, 0x6f14df3dUL, 0x7809cd26UL, 0x7502c32fUL, 0x5633e910UL, 0x5b38e719UL, 0x4c25f502UL, 0x412efb0bUL, +0x618c9ad7UL, 0x6c8794deUL, 0x7b9a86c5UL, 0x769188ccUL, 0x55a0a2f3UL, 0x58abacfaUL, 0x4fb6bee1UL, 0x42bdb0e8UL, +0x09d4ea9fUL, 0x04dfe496UL, 0x13c2f68dUL, 0x1ec9f884UL, 0x3df8d2bbUL, 0x30f3dcb2UL, 0x27eecea9UL, 0x2ae5c0a0UL, +0xb13c7a47UL, 0xbc37744eUL, 0xab2a6655UL, 0xa621685cUL, 0x85104263UL, 0x881b4c6aUL, 0x9f065e71UL, 0x920d5078UL, +0xd9640a0fUL, 0xd46f0406UL, 0xc372161dUL, 0xce791814UL, 0xed48322bUL, 0xe0433c22UL, 0xf75e2e39UL, 0xfa552030UL, +0xb701ec9aUL, 0xba0ae293UL, 0xad17f088UL, 0xa01cfe81UL, 0x832dd4beUL, 0x8e26dab7UL, 0x993bc8acUL, 0x9430c6a5UL, +0xdf599cd2UL, 0xd25292dbUL, 0xc54f80c0UL, 0xc8448ec9UL, 0xeb75a4f6UL, 0xe67eaaffUL, 0xf163b8e4UL, 0xfc68b6edUL, +0x67b10c0aUL, 0x6aba0203UL, 0x7da71018UL, 0x70ac1e11UL, 0x539d342eUL, 0x5e963a27UL, 0x498b283cUL, 0x44802635UL, +0x0fe97c42UL, 0x02e2724bUL, 0x15ff6050UL, 0x18f46e59UL, 0x3bc54466UL, 0x36ce4a6fUL, 0x21d35874UL, 0x2cd8567dUL, +0x0c7a37a1UL, 0x017139a8UL, 0x166c2bb3UL, 0x1b6725baUL, 0x38560f85UL, 0x355d018cUL, 0x22401397UL, 0x2f4b1d9eUL, +0x642247e9UL, 0x692949e0UL, 0x7e345bfbUL, 0x733f55f2UL, 0x500e7fcdUL, 0x5d0571c4UL, 0x4a1863dfUL, 0x47136dd6UL, +0xdccad731UL, 0xd1c1d938UL, 0xc6dccb23UL, 0xcbd7c52aUL, 0xe8e6ef15UL, 0xe5ede11cUL, 0xf2f0f307UL, 0xfffbfd0eUL, +0xb492a779UL, 0xb999a970UL, 0xae84bb6bUL, 0xa38fb562UL, 0x80be9f5dUL, 0x8db59154UL, 0x9aa8834fUL, 0x97a38d46UL +}; + +static const ulong32 Tks3[] = { +0x00000000UL, 0x090d0b0eUL, 0x121a161cUL, 0x1b171d12UL, 0x24342c38UL, 0x2d392736UL, 0x362e3a24UL, 0x3f23312aUL, +0x48685870UL, 0x4165537eUL, 0x5a724e6cUL, 0x537f4562UL, 0x6c5c7448UL, 0x65517f46UL, 0x7e466254UL, 0x774b695aUL, +0x90d0b0e0UL, 0x99ddbbeeUL, 0x82caa6fcUL, 0x8bc7adf2UL, 0xb4e49cd8UL, 0xbde997d6UL, 0xa6fe8ac4UL, 0xaff381caUL, +0xd8b8e890UL, 0xd1b5e39eUL, 0xcaa2fe8cUL, 0xc3aff582UL, 0xfc8cc4a8UL, 0xf581cfa6UL, 0xee96d2b4UL, 0xe79bd9baUL, +0x3bbb7bdbUL, 0x32b670d5UL, 0x29a16dc7UL, 0x20ac66c9UL, 0x1f8f57e3UL, 0x16825cedUL, 0x0d9541ffUL, 0x04984af1UL, +0x73d323abUL, 0x7ade28a5UL, 0x61c935b7UL, 0x68c43eb9UL, 0x57e70f93UL, 0x5eea049dUL, 0x45fd198fUL, 0x4cf01281UL, +0xab6bcb3bUL, 0xa266c035UL, 0xb971dd27UL, 0xb07cd629UL, 0x8f5fe703UL, 0x8652ec0dUL, 0x9d45f11fUL, 0x9448fa11UL, +0xe303934bUL, 0xea0e9845UL, 0xf1198557UL, 0xf8148e59UL, 0xc737bf73UL, 0xce3ab47dUL, 0xd52da96fUL, 0xdc20a261UL, +0x766df6adUL, 0x7f60fda3UL, 0x6477e0b1UL, 0x6d7aebbfUL, 0x5259da95UL, 0x5b54d19bUL, 0x4043cc89UL, 0x494ec787UL, +0x3e05aeddUL, 0x3708a5d3UL, 0x2c1fb8c1UL, 0x2512b3cfUL, 0x1a3182e5UL, 0x133c89ebUL, 0x082b94f9UL, 0x01269ff7UL, +0xe6bd464dUL, 0xefb04d43UL, 0xf4a75051UL, 0xfdaa5b5fUL, 0xc2896a75UL, 0xcb84617bUL, 0xd0937c69UL, 0xd99e7767UL, +0xaed51e3dUL, 0xa7d81533UL, 0xbccf0821UL, 0xb5c2032fUL, 0x8ae13205UL, 0x83ec390bUL, 0x98fb2419UL, 0x91f62f17UL, +0x4dd68d76UL, 0x44db8678UL, 0x5fcc9b6aUL, 0x56c19064UL, 0x69e2a14eUL, 0x60efaa40UL, 0x7bf8b752UL, 0x72f5bc5cUL, +0x05bed506UL, 0x0cb3de08UL, 0x17a4c31aUL, 0x1ea9c814UL, 0x218af93eUL, 0x2887f230UL, 0x3390ef22UL, 0x3a9de42cUL, +0xdd063d96UL, 0xd40b3698UL, 0xcf1c2b8aUL, 0xc6112084UL, 0xf93211aeUL, 0xf03f1aa0UL, 0xeb2807b2UL, 0xe2250cbcUL, +0x956e65e6UL, 0x9c636ee8UL, 0x877473faUL, 0x8e7978f4UL, 0xb15a49deUL, 0xb85742d0UL, 0xa3405fc2UL, 0xaa4d54ccUL, +0xecdaf741UL, 0xe5d7fc4fUL, 0xfec0e15dUL, 0xf7cdea53UL, 0xc8eedb79UL, 0xc1e3d077UL, 0xdaf4cd65UL, 0xd3f9c66bUL, +0xa4b2af31UL, 0xadbfa43fUL, 0xb6a8b92dUL, 0xbfa5b223UL, 0x80868309UL, 0x898b8807UL, 0x929c9515UL, 0x9b919e1bUL, +0x7c0a47a1UL, 0x75074cafUL, 0x6e1051bdUL, 0x671d5ab3UL, 0x583e6b99UL, 0x51336097UL, 0x4a247d85UL, 0x4329768bUL, +0x34621fd1UL, 0x3d6f14dfUL, 0x267809cdUL, 0x2f7502c3UL, 0x105633e9UL, 0x195b38e7UL, 0x024c25f5UL, 0x0b412efbUL, +0xd7618c9aUL, 0xde6c8794UL, 0xc57b9a86UL, 0xcc769188UL, 0xf355a0a2UL, 0xfa58abacUL, 0xe14fb6beUL, 0xe842bdb0UL, +0x9f09d4eaUL, 0x9604dfe4UL, 0x8d13c2f6UL, 0x841ec9f8UL, 0xbb3df8d2UL, 0xb230f3dcUL, 0xa927eeceUL, 0xa02ae5c0UL, +0x47b13c7aUL, 0x4ebc3774UL, 0x55ab2a66UL, 0x5ca62168UL, 0x63851042UL, 0x6a881b4cUL, 0x719f065eUL, 0x78920d50UL, +0x0fd9640aUL, 0x06d46f04UL, 0x1dc37216UL, 0x14ce7918UL, 0x2bed4832UL, 0x22e0433cUL, 0x39f75e2eUL, 0x30fa5520UL, +0x9ab701ecUL, 0x93ba0ae2UL, 0x88ad17f0UL, 0x81a01cfeUL, 0xbe832dd4UL, 0xb78e26daUL, 0xac993bc8UL, 0xa59430c6UL, +0xd2df599cUL, 0xdbd25292UL, 0xc0c54f80UL, 0xc9c8448eUL, 0xf6eb75a4UL, 0xffe67eaaUL, 0xe4f163b8UL, 0xedfc68b6UL, +0x0a67b10cUL, 0x036aba02UL, 0x187da710UL, 0x1170ac1eUL, 0x2e539d34UL, 0x275e963aUL, 0x3c498b28UL, 0x35448026UL, +0x420fe97cUL, 0x4b02e272UL, 0x5015ff60UL, 0x5918f46eUL, 0x663bc544UL, 0x6f36ce4aUL, 0x7421d358UL, 0x7d2cd856UL, +0xa10c7a37UL, 0xa8017139UL, 0xb3166c2bUL, 0xba1b6725UL, 0x8538560fUL, 0x8c355d01UL, 0x97224013UL, 0x9e2f4b1dUL, +0xe9642247UL, 0xe0692949UL, 0xfb7e345bUL, 0xf2733f55UL, 0xcd500e7fUL, 0xc45d0571UL, 0xdf4a1863UL, 0xd647136dUL, +0x31dccad7UL, 0x38d1c1d9UL, 0x23c6dccbUL, 0x2acbd7c5UL, 0x15e8e6efUL, 0x1ce5ede1UL, 0x07f2f0f3UL, 0x0efffbfdUL, +0x79b492a7UL, 0x70b999a9UL, 0x6bae84bbUL, 0x62a38fb5UL, 0x5d80be9fUL, 0x548db591UL, 0x4f9aa883UL, 0x4697a38dUL +}; + +static const ulong32 rcon[] = { + 0x01000000UL, 0x02000000UL, 0x04000000UL, 0x08000000UL, + 0x10000000UL, 0x20000000UL, 0x40000000UL, 0x80000000UL, + 0x1B000000UL, 0x36000000UL +}; + +static ulong32 setup_mix(ulong32 temp) +{ + return (Te4_3[byte(temp, 2)]) ^ + (Te4_2[byte(temp, 1)]) ^ + (Te4_1[byte(temp, 0)]) ^ + (Te4_0[byte(temp, 3)]); +} + +int aes_setup(const unsigned char *key, int keylen, int rounds, aes_key *skey) +{ + int i, j; + ulong32 temp, *rk; + ulong32 *rrk; + + if (keylen != 16 && keylen != 24 && keylen != 32) { + return CRYPT_INVALID_KEYSIZE; + } + + if (rounds != 0 && rounds != (10 + ((keylen/8)-2)*2)) { + return CRYPT_INVALID_ROUNDS; + } + + skey->Nr = 10 + ((keylen/8)-2)*2; + + /* setup the forward key */ + i = 0; + rk = skey->eK; + LOAD32H(rk[0], key ); + LOAD32H(rk[1], key + 4); + LOAD32H(rk[2], key + 8); + LOAD32H(rk[3], key + 12); + if (keylen == 16) { + j = 44; + for (;;) { + temp = rk[3]; + rk[4] = rk[0] ^ setup_mix(temp) ^ rcon[i]; + rk[5] = rk[1] ^ rk[4]; + rk[6] = rk[2] ^ rk[5]; + rk[7] = rk[3] ^ rk[6]; + if (++i == 10) { + break; + } + rk += 4; + } + } else if (keylen == 24) { + j = 52; + LOAD32H(rk[4], key + 16); + LOAD32H(rk[5], key + 20); + for (;;) { + temp = rk[5]; + rk[ 6] = rk[ 0] ^ setup_mix(temp) ^ rcon[i]; + rk[ 7] = rk[ 1] ^ rk[ 6]; + rk[ 8] = rk[ 2] ^ rk[ 7]; + rk[ 9] = rk[ 3] ^ rk[ 8]; + if (++i == 8) { + break; + } + rk[10] = rk[ 4] ^ rk[ 9]; + rk[11] = rk[ 5] ^ rk[10]; + rk += 6; + } + } else if (keylen == 32) { + j = 60; + LOAD32H(rk[4], key + 16); + LOAD32H(rk[5], key + 20); + LOAD32H(rk[6], key + 24); + LOAD32H(rk[7], key + 28); + for (;;) { + temp = rk[7]; + rk[ 8] = rk[ 0] ^ setup_mix(temp) ^ rcon[i]; + rk[ 9] = rk[ 1] ^ rk[ 8]; + rk[10] = rk[ 2] ^ rk[ 9]; + rk[11] = rk[ 3] ^ rk[10]; + if (++i == 7) { + break; + } + temp = rk[11]; + rk[12] = rk[ 4] ^ setup_mix(ROR(temp, 8)); + rk[13] = rk[ 5] ^ rk[12]; + rk[14] = rk[ 6] ^ rk[13]; + rk[15] = rk[ 7] ^ rk[14]; + rk += 8; + } + } else { + j = 4; + } + + rk = skey->dK; + rrk = skey->eK + j - 4; + + *rk++ = *rrk++; + *rk++ = *rrk++; + *rk++ = *rrk++; + *rk = *rrk; + rk -= 3; rrk -= 3; + + for (i = 1; i < skey->Nr; i++) { + rrk -= 4; + rk += 4; + temp = rrk[0]; + rk[0] = + Tks0[byte(temp, 3)] ^ + Tks1[byte(temp, 2)] ^ + Tks2[byte(temp, 1)] ^ + Tks3[byte(temp, 0)]; + temp = rrk[1]; + rk[1] = + Tks0[byte(temp, 3)] ^ + Tks1[byte(temp, 2)] ^ + Tks2[byte(temp, 1)] ^ + Tks3[byte(temp, 0)]; + temp = rrk[2]; + rk[2] = + Tks0[byte(temp, 3)] ^ + Tks1[byte(temp, 2)] ^ + Tks2[byte(temp, 1)] ^ + Tks3[byte(temp, 0)]; + temp = rrk[3]; + rk[3] = + Tks0[byte(temp, 3)] ^ + Tks1[byte(temp, 2)] ^ + Tks2[byte(temp, 1)] ^ + Tks3[byte(temp, 0)]; + } + + rrk -= 4; + rk += 4; + *rk++ = *rrk++; + *rk++ = *rrk++; + *rk++ = *rrk++; + *rk = *rrk; + + return CRYPT_OK; +} + +void aes_ecb_encrypt(const unsigned char *pt, unsigned char *ct, aes_key *skey) +{ + ulong32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; + int Nr, r; + + Nr = skey->Nr; + rk = skey->eK; + + LOAD32H(s0, pt ); s0 ^= rk[0]; + LOAD32H(s1, pt + 4); s1 ^= rk[1]; + LOAD32H(s2, pt + 8); s2 ^= rk[2]; + LOAD32H(s3, pt + 12); s3 ^= rk[3]; + + r = Nr >> 1; + for (;;) { + t0 = + Te0(byte(s0, 3)) ^ + Te1(byte(s1, 2)) ^ + Te2(byte(s2, 1)) ^ + Te3(byte(s3, 0)) ^ + rk[4]; + t1 = + Te0(byte(s1, 3)) ^ + Te1(byte(s2, 2)) ^ + Te2(byte(s3, 1)) ^ + Te3(byte(s0, 0)) ^ + rk[5]; + t2 = + Te0(byte(s2, 3)) ^ + Te1(byte(s3, 2)) ^ + Te2(byte(s0, 1)) ^ + Te3(byte(s1, 0)) ^ + rk[6]; + t3 = + Te0(byte(s3, 3)) ^ + Te1(byte(s0, 2)) ^ + Te2(byte(s1, 1)) ^ + Te3(byte(s2, 0)) ^ + rk[7]; + + rk += 8; + if (--r == 0) { + break; + } + + s0 = + Te0(byte(t0, 3)) ^ + Te1(byte(t1, 2)) ^ + Te2(byte(t2, 1)) ^ + Te3(byte(t3, 0)) ^ + rk[0]; + s1 = + Te0(byte(t1, 3)) ^ + Te1(byte(t2, 2)) ^ + Te2(byte(t3, 1)) ^ + Te3(byte(t0, 0)) ^ + rk[1]; + s2 = + Te0(byte(t2, 3)) ^ + Te1(byte(t3, 2)) ^ + Te2(byte(t0, 1)) ^ + Te3(byte(t1, 0)) ^ + rk[2]; + s3 = + Te0(byte(t3, 3)) ^ + Te1(byte(t0, 2)) ^ + Te2(byte(t1, 1)) ^ + Te3(byte(t2, 0)) ^ + rk[3]; + } + + s0 = + (Te4_3[byte(t0, 3)]) ^ + (Te4_2[byte(t1, 2)]) ^ + (Te4_1[byte(t2, 1)]) ^ + (Te4_0[byte(t3, 0)]) ^ + rk[0]; + STORE32H(s0, ct); + s1 = + (Te4_3[byte(t1, 3)]) ^ + (Te4_2[byte(t2, 2)]) ^ + (Te4_1[byte(t3, 1)]) ^ + (Te4_0[byte(t0, 0)]) ^ + rk[1]; + STORE32H(s1, ct+4); + s2 = + (Te4_3[byte(t2, 3)]) ^ + (Te4_2[byte(t3, 2)]) ^ + (Te4_1[byte(t0, 1)]) ^ + (Te4_0[byte(t1, 0)]) ^ + rk[2]; + STORE32H(s2, ct+8); + s3 = + (Te4_3[byte(t3, 3)]) ^ + (Te4_2[byte(t0, 2)]) ^ + (Te4_1[byte(t1, 1)]) ^ + (Te4_0[byte(t2, 0)]) ^ + rk[3]; + STORE32H(s3, ct+12); +} + +void aes_ecb_decrypt(const unsigned char *ct, unsigned char *pt, aes_key *skey) +{ + ulong32 s0, s1, s2, s3, t0, t1, t2, t3, *rk; + int Nr, r; + + Nr = skey->Nr; + rk = skey->dK; + + LOAD32H(s0, ct ); s0 ^= rk[0]; + LOAD32H(s1, ct + 4); s1 ^= rk[1]; + LOAD32H(s2, ct + 8); s2 ^= rk[2]; + LOAD32H(s3, ct + 12); s3 ^= rk[3]; + + r = Nr >> 1; + for (;;) { + + t0 = + Td0(byte(s0, 3)) ^ + Td1(byte(s3, 2)) ^ + Td2(byte(s2, 1)) ^ + Td3(byte(s1, 0)) ^ + rk[4]; + t1 = + Td0(byte(s1, 3)) ^ + Td1(byte(s0, 2)) ^ + Td2(byte(s3, 1)) ^ + Td3(byte(s2, 0)) ^ + rk[5]; + t2 = + Td0(byte(s2, 3)) ^ + Td1(byte(s1, 2)) ^ + Td2(byte(s0, 1)) ^ + Td3(byte(s3, 0)) ^ + rk[6]; + t3 = + Td0(byte(s3, 3)) ^ + Td1(byte(s2, 2)) ^ + Td2(byte(s1, 1)) ^ + Td3(byte(s0, 0)) ^ + rk[7]; + + rk += 8; + if (--r == 0) { + break; + } + + + s0 = + Td0(byte(t0, 3)) ^ + Td1(byte(t3, 2)) ^ + Td2(byte(t2, 1)) ^ + Td3(byte(t1, 0)) ^ + rk[0]; + s1 = + Td0(byte(t1, 3)) ^ + Td1(byte(t0, 2)) ^ + Td2(byte(t3, 1)) ^ + Td3(byte(t2, 0)) ^ + rk[1]; + s2 = + Td0(byte(t2, 3)) ^ + Td1(byte(t1, 2)) ^ + Td2(byte(t0, 1)) ^ + Td3(byte(t3, 0)) ^ + rk[2]; + s3 = + Td0(byte(t3, 3)) ^ + Td1(byte(t2, 2)) ^ + Td2(byte(t1, 1)) ^ + Td3(byte(t0, 0)) ^ + rk[3]; + } + + s0 = + (Td4[byte(t0, 3)] & 0xff000000) ^ + (Td4[byte(t3, 2)] & 0x00ff0000) ^ + (Td4[byte(t2, 1)] & 0x0000ff00) ^ + (Td4[byte(t1, 0)] & 0x000000ff) ^ + rk[0]; + STORE32H(s0, pt); + s1 = + (Td4[byte(t1, 3)] & 0xff000000) ^ + (Td4[byte(t0, 2)] & 0x00ff0000) ^ + (Td4[byte(t3, 1)] & 0x0000ff00) ^ + (Td4[byte(t2, 0)] & 0x000000ff) ^ + rk[1]; + STORE32H(s1, pt+4); + s2 = + (Td4[byte(t2, 3)] & 0xff000000) ^ + (Td4[byte(t1, 2)] & 0x00ff0000) ^ + (Td4[byte(t0, 1)] & 0x0000ff00) ^ + (Td4[byte(t3, 0)] & 0x000000ff) ^ + rk[2]; + STORE32H(s2, pt+8); + s3 = + (Td4[byte(t3, 3)] & 0xff000000) ^ + (Td4[byte(t2, 2)] & 0x00ff0000) ^ + (Td4[byte(t1, 1)] & 0x0000ff00) ^ + (Td4[byte(t0, 0)] & 0x000000ff) ^ + rk[3]; + STORE32H(s3, pt+12); +} diff --git a/dlls/rsaenh/implglue.c b/dlls/rsaenh/implglue.c index d31f615eff0..bb39a7b8c45 100644 --- a/dlls/rsaenh/implglue.c +++ b/dlls/rsaenh/implglue.c @@ -3,6 +3,7 @@ * Glueing the RSAENH specific code to the crypto library * * Copyright (c) 2004, 2005 Michael Jung + * Copyright (c) 2007 Vijay Kiran Kamuju * * based on code by Mike McCormack and David Hammerton * @@ -194,6 +195,19 @@ BOOL setup_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, case CALG_DES: des_setup(abKeyValue, 8, 0, &pKeyContext->des); break; + + case CALG_AES: + case CALG_AES_128: + aes_setup(abKeyValue, 16, 0, &pKeyContext->aes); + break; + + case CALG_AES_192: + aes_setup(abKeyValue, 24, 0, &pKeyContext->aes); + break; + + case CALG_AES_256: + aes_setup(abKeyValue, 32, 0, &pKeyContext->aes); + break; } return TRUE; @@ -209,6 +223,10 @@ BOOL duplicate_key_impl(ALG_ID aiAlgid, CONST KEY_CONTEXT *pSrcKeyContext, case CALG_3DES: case CALG_3DES_112: case CALG_DES: + case CALG_AES: + case CALG_AES_128: + case CALG_AES_192: + case CALG_AES_256: memcpy(pDestKeyContext, pSrcKeyContext, sizeof(KEY_CONTEXT)); break; case CALG_RSA_KEYX: @@ -275,6 +293,17 @@ BOOL encrypt_block_impl(ALG_ID aiAlgid, DWORD dwKeySpec, KEY_CONTEXT *pKeyContex } break; + case CALG_AES: + case CALG_AES_128: + case CALG_AES_192: + case CALG_AES_256: + if (enc) { + aes_ecb_encrypt(in, out, &pKeyContext->aes); + } else { + aes_ecb_decrypt(in, out, &pKeyContext->aes); + } + break; + case CALG_RSA_KEYX: case CALG_RSA_SIGN: outlen = inlen = (mp_count_bits(&pKeyContext->rsa.N)+7)/8; diff --git a/dlls/rsaenh/implglue.h b/dlls/rsaenh/implglue.h index d421c3d9ac8..5deaf53e58a 100644 --- a/dlls/rsaenh/implglue.h +++ b/dlls/rsaenh/implglue.h @@ -63,6 +63,7 @@ typedef union tagKEY_CONTEXT { rc2_key rc2; des_key des; des3_key des3; + aes_key aes; prng_state rc4; rsa_key rsa; } KEY_CONTEXT; diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c index 7dc1cf2c3e3..fcf3dcf6861 100644 --- a/dlls/rsaenh/rsaenh.c +++ b/dlls/rsaenh/rsaenh.c @@ -5,6 +5,7 @@ * Copyright 2002 TransGaming Technologies (David Hammerton) * Copyright 2004 Mike McCormack for CodeWeavers * Copyright 2004, 2005 Michael Jung + * Copyright 2007 Vijay Kiran Kamuju * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -111,6 +112,7 @@ typedef struct tagCRYPTKEY #define RSAENH_PERSONALITY_STRONG 1u #define RSAENH_PERSONALITY_ENHANCED 2u #define RSAENH_PERSONALITY_SCHANNEL 3u +#define RSAENH_PERSONALITY_AES 4u #define RSAENH_MAGIC_CONTAINER 0x26384993u typedef struct tagKEYCONTAINER @@ -153,9 +155,9 @@ typedef struct tagKEYCONTAINER /****************************************************************************** * aProvEnumAlgsEx - Defines the capabilities of the CSP personalities. */ -#define RSAENH_MAX_ENUMALGS 20 +#define RSAENH_MAX_ENUMALGS 24 #define RSAENH_PCT1_SSL2_SSL3_TLS1 (CRYPT_FLAG_PCT1|CRYPT_FLAG_SSL2|CRYPT_FLAG_SSL3|CRYPT_FLAG_TLS1) -static const PROV_ENUMALGS_EX aProvEnumAlgsEx[4][RSAENH_MAX_ENUMALGS+1] = +static const PROV_ENUMALGS_EX aProvEnumAlgsEx[5][RSAENH_MAX_ENUMALGS+1] = { { {CALG_RC2, 40, 40, 56,0, 4,"RC2", 24,"RSA Data Security's RC2"}, @@ -228,6 +230,27 @@ static const PROV_ENUMALGS_EX aProvEnumAlgsEx[4][RSAENH_MAX_ENUMALGS+1] = {CALG_SCHANNEL_ENC_KEY,0,0,-1,0, 12,"SCH ENC KEY",24,"SChannel Encryption Key"}, {CALG_TLS1PRF, 0, 0, -1,0, 9,"TLS1 PRF", 28,"TLS1 Pseudo Random Function"}, {0, 0, 0, 0,0, 1,"", 1,""} + }, + { + {CALG_RC2, 128, 40, 128,0, 4,"RC2", 24,"RSA Data Security's RC2"}, + {CALG_RC4, 128, 40, 128,0, 4,"RC4", 24,"RSA Data Security's RC4"}, + {CALG_DES, 56, 56, 56,0, 4,"DES", 31,"Data Encryption Standard (DES)"}, + {CALG_3DES_112, 112,112, 112,0, 13,"3DES TWO KEY",19,"Two Key Triple DES"}, + {CALG_3DES, 168,168, 168,0, 5,"3DES", 21,"Three Key Triple DES"}, + {CALG_AES, 128,128, 128,0, 4,"AES", 35,"Advanced Encryption Standard (AES)"}, + {CALG_AES_128, 128,128, 128,0, 8,"AES-128", 39,"Advanced Encryption Standard (AES-128)"}, + {CALG_AES_192, 192,192, 192,0, 8,"AES-192", 39,"Advanced Encryption Standard (AES-192)"}, + {CALG_AES_256, 256,256, 256,0, 8,"AES-256", 39,"Advanced Encryption Standard (AES-256)"}, + {CALG_SHA, 160,160, 160,CRYPT_FLAG_SIGNING, 6,"SHA-1", 30,"Secure Hash Algorithm (SHA-1)"}, + {CALG_MD2, 128,128, 128,CRYPT_FLAG_SIGNING, 4,"MD2", 23,"Message Digest 2 (MD2)"}, + {CALG_MD4, 128,128, 128,CRYPT_FLAG_SIGNING, 4,"MD4", 23,"Message Digest 4 (MD4)"}, + {CALG_MD5, 128,128, 128,CRYPT_FLAG_SIGNING, 4,"MD5", 23,"Message Digest 5 (MD5)"}, + {CALG_SSL3_SHAMD5,288,288,288,0, 12,"SSL3 SHAMD5",12,"SSL3 SHAMD5"}, + {CALG_MAC, 0, 0, 0,0, 4,"MAC", 28,"Message Authentication Code"}, + {CALG_RSA_SIGN,1024,384,16384,CRYPT_FLAG_SIGNING|CRYPT_FLAG_IPSEC,9,"RSA_SIGN",14,"RSA Signature"}, + {CALG_RSA_KEYX,1024,384,16384,CRYPT_FLAG_SIGNING|CRYPT_FLAG_IPSEC,9,"RSA_KEYX",17,"RSA Key Exchange"}, + {CALG_HMAC, 0, 0, 0,0, 5,"HMAC", 18,"Hugo's MAC (HMAC)"}, + {0, 0, 0, 0,0, 1,"", 1,""} } }; @@ -844,6 +867,14 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK pCryptKey->dwMode = CRYPT_MODE_CBC; break; + case CALG_AES: + case CALG_AES_128: + case CALG_AES_192: + case CALG_AES_256: + pCryptKey->dwBlockLen = 16; + pCryptKey->dwMode = CRYPT_MODE_ECB; + break; + case CALG_RSA_KEYX: case CALG_RSA_SIGN: pCryptKey->dwBlockLen = dwKeyLen >> 3; @@ -1081,6 +1112,8 @@ static HCRYPTPROV new_key_container(PCCH pszContainerName, DWORD dwFlags, const pKeyContainer->dwPersonality = RSAENH_PERSONALITY_ENHANCED; } else if (!strcmp(pVTable->pszProvName, MS_DEF_RSA_SCHANNEL_PROV_A)) { pKeyContainer->dwPersonality = RSAENH_PERSONALITY_SCHANNEL; + } else if (!strcmp(pVTable->pszProvName, MS_ENH_RSA_AES_PROV_A)) { + pKeyContainer->dwPersonality = RSAENH_PERSONALITY_AES; } else { pKeyContainer->dwPersonality = RSAENH_PERSONALITY_STRONG; } @@ -2562,6 +2595,10 @@ BOOL WINAPI RSAENH_CPGenKey(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYP case CALG_DES: case CALG_3DES_112: case CALG_3DES: + case CALG_AES: + case CALG_AES_128: + case CALG_AES_192: + case CALG_AES_256: case CALG_PCT1_MASTER: case CALG_SSL2_MASTER: case CALG_SSL3_MASTER: @@ -3757,7 +3794,7 @@ cleanup: return res; } -static const WCHAR szProviderKeys[4][97] = { +static const WCHAR szProviderKeys[5][104] = { { 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\','C','r','y','p','t','o','g','r', 'a','p','h','y','\\','D','e','f','a','u','l','t','s','\\','P','r','o','v', @@ -3781,9 +3818,14 @@ static const WCHAR szProviderKeys[4][97] = { 'C','r','y','p','t','o','g','r','a','p','h','y','\\','D','e','f','a','u','l','t','s','\\', 'P','r','o','v','i','d','e','r','\\','M','i','c','r','o','s','o','f','t',' ', 'R','S','A',' ','S','C','h','a','n','n','e','l',' ', + 'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 }, + { 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\', + 'C','r','y','p','t','o','g','r','a','p','h','y','\\','D','e','f','a','u','l','t','s','\\', + 'P','r','o','v','i','d','e','r','\\','M','i','c','r','o','s','o','f','t',' ', + 'E','n','h','a','n','c','e','d',' ','R','S','A',' ','a','n','d',' ','A','E','S',' ', 'C','r','y','p','t','o','g','r','a','p','h','i','c',' ','P','r','o','v','i','d','e','r',0 } }; -static const WCHAR szDefaultKeys[2][65] = { +static const WCHAR szDefaultKeys[3][65] = { { 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\','C','r','y','p','t','o','g','r', 'a','p','h','y','\\','D','e','f','a','u','l','t','s','\\','P','r','o','v', @@ -3791,7 +3833,11 @@ static const WCHAR szDefaultKeys[2][65] = { { 'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\','C','r','y','p','t','o','g','r', 'a','p','h','y','\\','D','e','f','a','u','l','t','s','\\','P','r','o','v', - 'i','d','e','r',' ','T','y','p','e','s','\\','T','y','p','e',' ','0','1','2',0 } + 'i','d','e','r',' ','T','y','p','e','s','\\','T','y','p','e',' ','0','1','2',0 }, + { 'S','o','f','t','w','a','r','e','\\', + 'M','i','c','r','o','s','o','f','t','\\','C','r','y','p','t','o','g','r', + 'a','p','h','y','\\','D','e','f','a','u','l','t','s','\\','P','r','o','v', + 'i','d','e','r',' ','T','y','p','e','s','\\','T','y','p','e',' ','0','2','4',0 } }; @@ -3823,7 +3869,7 @@ HRESULT WINAPI DllRegisterServer(void) long apiRet; int i; - for (i=0; i<4; i++) { + for (i=0; i<5; i++) { apiRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, szProviderKeys[i], 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, &dp); @@ -3835,8 +3881,21 @@ HRESULT WINAPI DllRegisterServer(void) static const WCHAR szRSABase[] = { 'r','s','a','e','n','h','.','d','l','l',0 }; static const WCHAR szType[] = { 'T','y','p','e',0 }; static const WCHAR szSignature[] = { 'S','i','g','n','a','t','u','r','e',0 }; - DWORD type = (i == 3) ? PROV_RSA_SCHANNEL : PROV_RSA_FULL; - DWORD sign = 0xdeadbeef; + DWORD type, sign; + + switch(i) + { + case 3: + type=PROV_RSA_SCHANNEL; + break; + case 4: + type=PROV_RSA_AES; + break; + default: + type=PROV_RSA_FULL; + break; + } + sign = 0xdeadbeef; RegSetValueExW(key, szImagePath, 0, REG_SZ, (const BYTE *)szRSABase, (lstrlenW(szRSABase) + 1) * sizeof(WCHAR)); RegSetValueExW(key, szType, 0, REG_DWORD, (LPBYTE)&type, sizeof(type)); @@ -3846,30 +3905,35 @@ HRESULT WINAPI DllRegisterServer(void) } } - for (i=0; i<2; i++) { - apiRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, szDefaultKeys[i], 0, NULL, + for (i=0; i<3; i++) { + apiRet = RegCreateKeyExW(HKEY_LOCAL_MACHINE, szDefaultKeys[i], 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, &dp); if (apiRet == ERROR_SUCCESS) { if (dp == REG_CREATED_NEW_KEY) { static const WCHAR szName[] = { 'N','a','m','e',0 }; - static const WCHAR szRSAName[2][46] = { + static const WCHAR szRSAName[3][54] = { { 'M','i','c','r','o','s','o','f','t',' ', 'B','a','s','e',' ', 'C','r','y','p','t','o','g','r','a','p','h','i','c',' ', 'P','r','o','v','i','d','e','r',' ','v','1','.','0',0 }, { 'M','i','c','r','o','s','o','f','t',' ','R','S','A',' ', 'S','C','h','a','n','n','e','l',' ', 'C','r','y','p','t','o','g','r','a','p','h','i','c',' ', + 'P','r','o','v','i','d','e','r',0 }, + { 'M','i','c','r','o','s','o','f','t',' ','E','n','h','a','n','c','e','d',' ', + 'R','S','A',' ','a','n','d',' ','A','E','S',' ', + 'C','r','y','p','t','o','g','r','a','p','h','i','c',' ', 'P','r','o','v','i','d','e','r',0 } }; static const WCHAR szTypeName[] = { 'T','y','p','e','N','a','m','e',0 }; - static const WCHAR szRSATypeName[2][38] = { + static const WCHAR szRSATypeName[3][38] = { { 'R','S','A',' ','F','u','l','l',' ', '(','S','i','g','n','a','t','u','r','e',' ','a','n','d',' ', 'K','e','y',' ','E','x','c','h','a','n','g','e',')',0 }, - { 'R','S','A',' ','S','C','h','a','n','n','e','l',0 } }; + { 'R','S','A',' ','S','C','h','a','n','n','e','l',0 }, + { 'R','S','A',' ','F','u','l','l',' ','a','n','d',' ','A','E','S',0 } }; - RegSetValueExW(key, szName, 0, REG_SZ, + RegSetValueExW(key, szName, 0, REG_SZ, (const BYTE *)szRSAName[i], lstrlenW(szRSAName[i])*sizeof(WCHAR)+sizeof(WCHAR)); RegSetValueExW(key, szTypeName, 0, REG_SZ, (const BYTE *)szRSATypeName[i], lstrlenW(szRSATypeName[i])*sizeof(WCHAR)+sizeof(WCHAR)); @@ -3900,7 +3964,9 @@ HRESULT WINAPI DllUnregisterServer(void) RegDeleteKeyW(HKEY_LOCAL_MACHINE, szProviderKeys[1]); RegDeleteKeyW(HKEY_LOCAL_MACHINE, szProviderKeys[2]); RegDeleteKeyW(HKEY_LOCAL_MACHINE, szProviderKeys[3]); + RegDeleteKeyW(HKEY_LOCAL_MACHINE, szProviderKeys[4]); RegDeleteKeyW(HKEY_LOCAL_MACHINE, szDefaultKeys[0]); RegDeleteKeyW(HKEY_LOCAL_MACHINE, szDefaultKeys[1]); + RegDeleteKeyW(HKEY_LOCAL_MACHINE, szDefaultKeys[2]); return S_OK; } diff --git a/dlls/rsaenh/tests/rsaenh.c b/dlls/rsaenh/tests/rsaenh.c index d2216475e1e..b44398d25e6 100644 --- a/dlls/rsaenh/tests/rsaenh.c +++ b/dlls/rsaenh/tests/rsaenh.c @@ -2,6 +2,8 @@ * Unit tests for rsaenh functions * * Copyright (c) 2004 Michael Jung + * Copyright (c) 2006 Juan Lang + * Copyright (c) 2007 Vijay Kiran Kamuju * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -54,7 +56,7 @@ static const cryptdata cTestData[4] = { 12,12,16} }; -static void printBytes(const char *heading, BYTE *pb, size_t cb) +static void printBytes(const char *heading, const BYTE *pb, size_t cb) { size_t i; printf("%s: ",heading); @@ -83,7 +85,7 @@ static void trace_hex(BYTE *pbData, DWORD dwLen) { } */ -static int init_environment(void) +static int init_base_environment(void) { HCRYPTKEY hKey; BOOL result; @@ -100,7 +102,7 @@ static int init_environment(void) ok(GetLastError()==NTE_BAD_KEYSET, "%08x\n", GetLastError()); if (GetLastError()!=NTE_BAD_KEYSET) return 0; result = CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, - CRYPT_NEWKEYSET); + CRYPT_NEWKEYSET); ok(result, "%08x\n", GetLastError()); if (!result) return 0; result = CryptGenKey(hProv, AT_KEYEXCHANGE, 0, &hKey); @@ -113,7 +115,7 @@ static int init_environment(void) return 1; } -static void clean_up_environment(void) +static void clean_up_base_environment(void) { BOOL result; @@ -123,6 +125,51 @@ static void clean_up_environment(void) CryptAcquireContext(&hProv, szContainer, szProvider, PROV_RSA_FULL, CRYPT_DELETEKEYSET); } +static int init_aes_environment(void) +{ + HCRYPTKEY hKey; + BOOL result; + + pCryptDuplicateHash = (void *)GetProcAddress(GetModuleHandleA("advapi32.dll"), "CryptDuplicateHash"); + + hProv = (HCRYPTPROV)INVALID_HANDLE_VALUE; + + /* we are using NULL as provider name for RSA_AES provider as the provider + * names are different in Windows XP and Vista. Its different as to what + * its defined in the SDK on Windows XP. + * This provider is available on Windows XP, Windows 2003 and Vista. */ + + result = CryptAcquireContext(&hProv, szContainer, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT); + ok(!result && GetLastError()==NTE_BAD_FLAGS, "%d, %08x\n", result, GetLastError()); + + if (!CryptAcquireContext(&hProv, szContainer, NULL, PROV_RSA_AES, 0)) + { + ok(GetLastError()==NTE_BAD_KEYSET, "%08x\n", GetLastError()); + if (GetLastError()!=NTE_BAD_KEYSET) return 0; + result = CryptAcquireContext(&hProv, szContainer, NULL, PROV_RSA_AES, + CRYPT_NEWKEYSET); + ok(result, "%08x\n", GetLastError()); + if (!result) return 0; + result = CryptGenKey(hProv, AT_KEYEXCHANGE, 0, &hKey); + ok(result, "%08x\n", GetLastError()); + if (result) CryptDestroyKey(hKey); + result = CryptGenKey(hProv, AT_SIGNATURE, 0, &hKey); + ok(result, "%08x\n", GetLastError()); + if (result) CryptDestroyKey(hKey); + } + return 1; +} + +static void clean_up_aes_environment(void) +{ + BOOL result; + + result = CryptReleaseContext(hProv, 1); + ok(!result && GetLastError()==NTE_BAD_FLAGS, "%08x\n", GetLastError()); + + CryptAcquireContext(&hProv, szContainer, NULL, PROV_RSA_AES, CRYPT_DELETEKEYSET); +} + static void test_prov(void) { BOOL result; @@ -586,6 +633,62 @@ static void test_3des(void) ok(result, "%08x\n", GetLastError()); } +static void test_aes(int keylen) +{ + HCRYPTKEY hKey; + BOOL result; + DWORD dwLen; + unsigned char pbData[16]; + int i; + + switch (keylen) + { + case 256: + result = derive_key(CALG_AES_256, &hKey, 0); + break; + case 192: + result = derive_key(CALG_AES_192, &hKey, 0); + break; + default: + case 128: + result = derive_key(CALG_AES_128, &hKey, 0); + break; + } + if (!result) return; + + for (i=0; i #include -#include "wine/debug.h" #include "windef.h" #include "winbase.h" #include "wingdi.h" diff --git a/dlls/setupapi/setupx_main.c b/dlls/setupapi/setupx_main.c index fcf89c063e3..9b12ff79b86 100644 --- a/dlls/setupapi/setupx_main.c +++ b/dlls/setupapi/setupx_main.c @@ -69,7 +69,6 @@ #include "setupapi.h" #include "setupx16.h" #include "setupapi_private.h" -#include "winerror.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(setupapi); diff --git a/dlls/shdocvw/factory.c b/dlls/shdocvw/factory.c index e13f2acdceb..c8bb51190bc 100644 --- a/dlls/shdocvw/factory.c +++ b/dlls/shdocvw/factory.c @@ -24,6 +24,7 @@ #include "shdocvw.h" #include "winreg.h" #include "advpub.h" +#include "isguids.h" #include "wine/debug.h" @@ -206,14 +207,15 @@ static const GUID CLSID_MruLongList = static HRESULT register_server(BOOL doregister) { STRTABLEA strtable; - STRENTRYA pse[13]; - static CLSID const *clsids[13]; + STRENTRYA pse[14]; + static CLSID const *clsids[14]; int i = 0; HRESULT hres; INF_SET_CLSID(CUrlHistory); INF_SET_CLSID(Internet); INF_SET_CLSID(InternetExplorer); + INF_SET_CLSID(InternetShortcut); INF_SET_CLSID(MicrosoftBrowserArchitecture); INF_SET_CLSID(MruLongList); INF_SET_CLSID(SearchAssistantOC); diff --git a/dlls/shdocvw/shdocvw.inf b/dlls/shdocvw/shdocvw.inf index 91de9ee14be..9c38a55888c 100644 --- a/dlls/shdocvw/shdocvw.inf +++ b/dlls/shdocvw/shdocvw.inf @@ -3,11 +3,11 @@ Signature="$CHICAGO$" [RegisterDll] -AddReg=Classes.Reg +AddReg=Classes.Reg, Settings.Reg [UnregisterDll] -DelReg=Classes.Reg +DelReg=Classes.Reg, Settings.Reg [RegisterIE] @@ -108,6 +108,26 @@ HKCR,"CLSID\%CLSID_WebBrowser_V1%\VersionIndependentProgID",,,"Shell.Explorer" HKCR,"Shell.Explorer.1",,,"" HKCR,"Shell.Explorer.1\CLSID",,,"%CLSID_WebBrowser_V1%" +HKCR,"CLSID\%CLSID_InternetShortcut%",,,"Internet Shortcut" +HKCR,"CLSID\%CLSID_InternetShortcut%\InProcServer32",,,"%MODULE%" +HKCR,"CLSID\%CLSID_InternetShortcut%\InProcServer32","ThreadingModel",,"Apartment" +HKCR,"CLSID\%CLSID_InternetShortcut%\ProgID",,,"InternetShortcut" +HKCR,"CLSID\%CLSID_InternetShortcut%\shellex\MayChangeDefaultMenu",,, +HKCR,"InternetShortcut",,,"Internet Shortcut" +HKCR,"InternetShortcut","EditFlags",2,"2" +HKCR,"InternetShortcut","IsShortcut",, +HKCR,"InternetShortcut","NeverShowExt",, +HKCR,"InternetShortcut\CLSID",,,"%CLSID_InteretShortcut%" +HKCR,"InternetShortcut\DefaultIcon",,,"url.dll,0" +HKCR,"InternetShortcut\shell\open\command",,,"rundll32.exe shdocvw.dll,OpenURL %l" +HKCR,"InternetShortcut\shell\print\command",,,"rundll32.exe mshtml.dll,PrintHTML \"%1\"" +HKCR,"InternetShortcut\shell\printto\command",,,"rundll32.exe mshtml.dll,PrintHTML \"%1\" \"%2\" \"%3\" \"%4\"" + + +[Settings.Reg] +HKCU,"Software\Microsoft\Internet Explorer\Main","Start Page",,"http://www.winehq.org" +HKCU,"Software\Microsoft\Internet Explorer\Main","Search Page",,"http://www.google.com" + [IE.Reg] HKLM,"Software\Microsoft\Internet Explorer","Version",,"6.0.2900.2180" diff --git a/dlls/shdocvw/tests/webbrowser.c b/dlls/shdocvw/tests/webbrowser.c index 796c47c1e61..2659bc4456b 100644 --- a/dlls/shdocvw/tests/webbrowser.c +++ b/dlls/shdocvw/tests/webbrowser.c @@ -984,6 +984,7 @@ static void test_ClassInfo(IUnknown *unk) static void test_ie_funcs(IUnknown *unk) { IWebBrowser2 *wb; + IDispatch *disp; VARIANT_BOOL b; int i; long hwnd; @@ -1134,6 +1135,23 @@ static void test_ie_funcs(IUnknown *unk) ok(hres == E_NOTIMPL, "get_Resizable failed: %08x\n", hres); ok(b == 0x100, "b=%x\n", b); + /* Application */ + + disp = NULL; + hres = IWebBrowser2_get_Application(wb, &disp); + ok(hres == S_OK, "get_Application failed: %08x\n", hres); + ok(disp == (void*)wb, "disp=%p, expected %p\n", disp, wb); + if(disp) + IDispatch_Release(disp); + + hres = IWebBrowser2_get_Application(wb, NULL); + ok(hres == E_POINTER, "get_Application failed: %08x, expected E_POINTER\n", hres); + + /* Quit */ + + hres = IWebBrowser2_Quit(wb); + ok(hres == E_FAIL, "Quit failed: %08x, expected E_FAIL\n", hres); + IWebBrowser2_Release(wb); } diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c index 49914f7184a..79ae4a1f8f2 100644 --- a/dlls/shdocvw/webbrowser.c +++ b/dlls/shdocvw/webbrowser.c @@ -260,8 +260,15 @@ static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface) static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)->(%p)\n", This, ppDisp); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, ppDisp); + + if(!ppDisp) + return E_POINTER; + + *ppDisp = (IDispatch*)WEBBROWSER2(This); + IDispatch_AddRef(*ppDisp); + return S_OK; } static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp) @@ -450,8 +457,11 @@ static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBo static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface) { WebBrowser *This = WEBBROWSER_THIS(iface); - FIXME("(%p)\n", This); - return E_NOTIMPL; + + TRACE("(%p)\n", This); + + /* It's a InternetExplorer specific method, we have nothing to do here. */ + return E_FAIL; } static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy) diff --git a/dlls/shell32/changenotify.c b/dlls/shell32/changenotify.c index c88ca1f2a7e..4cd17e9a406 100644 --- a/dlls/shell32/changenotify.c +++ b/dlls/shell32/changenotify.c @@ -267,7 +267,7 @@ static BOOL should_notify( LPCITEMIDLIST changed, LPCITEMIDLIST watched, BOOL su return FALSE; if (ILIsEqual( watched, changed ) ) return TRUE; - if( sub && ILIsParent( watched, changed, FALSE ) ) + if( sub && ILIsParent( watched, changed, TRUE ) ) return TRUE; return FALSE; } diff --git a/dlls/shell32/classes.c b/dlls/shell32/classes.c index db4ce80126e..d17a31cb989 100644 --- a/dlls/shell32/classes.c +++ b/dlls/shell32/classes.c @@ -65,7 +65,7 @@ BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL lstrcpynW(szTemp + (bPrependDot?1:0), szExtension, MAX_EXTENSION_LENGTH); - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szTemp, 0, 0x02000000, &hkey)) + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey)) { return FALSE; } @@ -99,7 +99,7 @@ BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bP lstrcpynA(szTemp + (bPrependDot?1:0), szExtension, MAX_EXTENSION_LENGTH); - if (RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, 0x02000000, &hkey)) + if (RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey)) { return FALSE; } @@ -182,7 +182,7 @@ BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LP TRACE("%p %s %s %p\n", hkeyClass, debugstr_w(szClass), debugstr_w(szVerb), szDest); if (szClass) - RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, 0x02000000, &hkeyClass); + RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, KEY_READ, &hkeyClass); if (!hkeyClass) return FALSE; ret = FALSE; @@ -280,7 +280,7 @@ BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_i lstrcpynW(sTemp, szClass, MAX_PATH); lstrcatW(sTemp, swDefaultIcon); - if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, 0x02000000, &hkey)) + if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hkey)) { ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx); RegCloseKey(hkey); @@ -304,7 +304,7 @@ BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx sprintf(sTemp, "%s\\DefaultIcon",szClass); - if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, 0x02000000, &hkey)) + if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hkey)) { ret = HCR_RegGetDefaultIconA(hkey, szDest, len, picon_idx); RegCloseKey(hkey); diff --git a/dlls/shell32/shell32.spec b/dlls/shell32/shell32.spec index 6928538bcfa..044f4430f1f 100644 --- a/dlls/shell32/shell32.spec +++ b/dlls/shell32/shell32.spec @@ -210,6 +210,8 @@ 250 stdcall -noname PathRemoveExtension(ptr) PathRemoveExtensionAW 251 stdcall -noname PathRemoveArgs(ptr) PathRemoveArgsAW 256 stdcall @(ptr ptr) SHELL32_256 + 258 stdcall -noname LinkWindow_RegisterClass() + 259 stdcall -noname LinkWindow_UnregisterClass() #299 stub Shl1632_ThunkData32 #300 stub Shl3216_ThunkData32 diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c index 57d6b821065..ed326eab0be 100644 --- a/dlls/shell32/shellord.c +++ b/dlls/shell32/shellord.c @@ -1957,3 +1957,21 @@ HRESULT WINAPI SHSetLocalizedName(LPWSTR pszPath, LPCWSTR pszResModule, int idsR return S_OK; } + +/************************************************************************* + * LinkWindow_RegisterClass (SHELL32.258) + */ +BOOL WINAPI LinkWindow_RegisterClass(void) +{ + FIXME("()\n"); + return TRUE; +} + +/************************************************************************* + * LinkWindow_UnregisterClass (SHELL32.259) + */ +BOOL WINAPI LinkWindow_UnregisterClass(void) +{ + FIXME("()\n"); + return TRUE; +} diff --git a/dlls/shell32/shfldr_mycomp.c b/dlls/shell32/shfldr_mycomp.c index ec0132b0faf..87530a58163 100644 --- a/dlls/shell32/shfldr_mycomp.c +++ b/dlls/shell32/shfldr_mycomp.c @@ -684,6 +684,7 @@ static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface, { /* Neither a shell namespace extension nor a drive letter. */ ERR("Wrong pidl type\n"); + CoTaskMemFree(pszPath); return E_INVALIDARG; } } diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c index c18da270acd..6c190012b85 100644 --- a/dlls/shell32/shfldr_unixfs.c +++ b/dlls/shell32/shfldr_unixfs.c @@ -140,7 +140,6 @@ # include #endif #include -#include #define COBJMACROS #define NONAMELESSUNION @@ -743,6 +742,61 @@ static HRESULT UNIXFS_initialize_target_folder(UnixFolder *This, const char *szB } /****************************************************************************** + * UNIXFS_copy [Internal] + * + * Copy pwszDosSrc to pwszDosDst. + * + * PARAMS + * pwszDosSrc [I] absolute path of the source + * pwszDosDst [I] absolute path of the destination + * + * RETURNS + * Success: S_OK, + * Failure: E_FAIL + */ +static HRESULT UNIXFS_copy(LPCWSTR pwszDosSrc, LPCWSTR pwszDosDst) +{ + SHFILEOPSTRUCTW op; + LPWSTR pwszSrc, pwszDst; + HRESULT res = E_OUTOFMEMORY; + UINT iSrcLen, iDstLen; + + if (!pwszDosSrc || !pwszDosDst) + return E_FAIL; + + iSrcLen = lstrlenW(pwszDosSrc); + iDstLen = lstrlenW(pwszDosDst); + pwszSrc = HeapAlloc(GetProcessHeap(), 0, (iSrcLen + 2) * sizeof(WCHAR)); + pwszDst = HeapAlloc(GetProcessHeap(), 0, (iDstLen + 2) * sizeof(WCHAR)); + + if (pwszSrc && pwszDst) { + lstrcpyW(pwszSrc, pwszDosSrc); + lstrcpyW(pwszDst, pwszDosDst); + /* double null termination */ + pwszSrc[iSrcLen + 1] = 0; + pwszDst[iDstLen + 1] = 0; + + ZeroMemory(&op, sizeof(op)); + op.hwnd = GetActiveWindow(); + op.wFunc = FO_COPY; + op.pFrom = pwszSrc; + op.pTo = pwszDst; + op.fFlags = FOF_ALLOWUNDO; + if (!SHFileOperationW(&op)) + { + WARN("SHFileOperationW failed\n"); + res = E_FAIL; + } + else + res = S_OK; + } + + HeapFree(GetProcessHeap(), 0, pwszSrc); + HeapFree(GetProcessHeap(), 0, pwszDst); + return res; +} + +/****************************************************************************** * UnixFolder * * Class whose heap based instances represent unix filesystem directories. @@ -1865,7 +1919,7 @@ static HRESULT WINAPI UnixFolder_ISFHelper_CopyItems(ISFHelper* iface, IShellFol HRESULT hr; char szAbsoluteDst[FILENAME_MAX], *pszRelativeDst; - TRACE("(iface=%p, psfFrom=%p, cidl=%d, apidl=%p): semi-stub\n", iface, psfFrom, cidl, apidl); + TRACE("(iface=%p, psfFrom=%p, cidl=%d, apidl=%p)\n", iface, psfFrom, cidl, apidl); if (!psfFrom || !cidl || !apidl) return E_INVALIDARG; @@ -1883,6 +1937,8 @@ static HRESULT WINAPI UnixFolder_ISFHelper_CopyItems(ISFHelper* iface, IShellFol WCHAR wszSrc[MAX_PATH]; char szSrc[FILENAME_MAX]; STRRET strret; + HRESULT res; + WCHAR *pwszDosSrc, *pwszDosDst; /* Build the unix path of the current source item. */ if (FAILED(IShellFolder_GetDisplayNameOf(psfFrom, apidl[i], SHGDN_FORPARSING, &strret))) @@ -1895,7 +1951,19 @@ static HRESULT WINAPI UnixFolder_ISFHelper_CopyItems(ISFHelper* iface, IShellFol /* Build the unix path of the current destination item */ UNIXFS_filename_from_shitemid(apidl[i], pszRelativeDst); - FIXME("Would copy %s to %s. Not yet implemented.\n", szSrc, szAbsoluteDst); + pwszDosSrc = wine_get_dos_file_name(szSrc); + pwszDosDst = wine_get_dos_file_name(szAbsoluteDst); + + if (pwszDosSrc && pwszDosDst) + res = UNIXFS_copy(pwszDosSrc, pwszDosDst); + else + res = E_OUTOFMEMORY; + + HeapFree(GetProcessHeap(), 0, pwszDosSrc); + HeapFree(GetProcessHeap(), 0, pwszDosDst); + + if (res != S_OK) + return res; } return S_OK; } diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 9800043cafa..a6a71387814 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -632,11 +632,7 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation, * attached */ TRACE("found %s\n", debugstr_w(lpResult)); return 33; - - /* Greater than 32 to indicate success FIXME According to the - * docs, I should be returning a handle for the - * executable. Does this mean I'm supposed to open the - * executable file or something? More RTFM, I guess... */ + /* Greater than 32 to indicate success */ } tok = p; } @@ -749,14 +745,15 @@ static HDDEDATA CALLBACK dde_cb(UINT uType, UINT uFmt, HCONV hConv, * launching an application and trying (#2) to connect to it * */ -static unsigned dde_connect(WCHAR* key, const WCHAR* start, WCHAR* ddeexec, +static unsigned dde_connect(const WCHAR* key, const WCHAR* start, WCHAR* ddeexec, const WCHAR* lpFile, WCHAR *env, LPCWSTR szCommandline, LPITEMIDLIST pidl, SHELL_ExecuteW32 execfunc, const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out) { static const WCHAR wApplication[] = {'\\','a','p','p','l','i','c','a','t','i','o','n',0}; static const WCHAR wTopic[] = {'\\','t','o','p','i','c',0}; - WCHAR * endkey = key + strlenW(key); + WCHAR regkey[256]; + WCHAR * endkey = regkey + strlenW(key); WCHAR app[256], topic[256], ifexec[256], res[256]; LONG applen, topiclen, ifexeclen; WCHAR * exec; @@ -769,9 +766,10 @@ static unsigned dde_connect(WCHAR* key, const WCHAR* start, WCHAR* ddeexec, unsigned ret = SE_ERR_NOASSOC; BOOL unicode = !(GetVersion() & 0x80000000); + strcpyW(regkey, key); strcpyW(endkey, wApplication); applen = sizeof(app); - if (RegQueryValueW(HKEY_CLASSES_ROOT, key, app, &applen) != ERROR_SUCCESS) + if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, app, &applen) != ERROR_SUCCESS) { WCHAR command[1024], fullpath[MAX_PATH]; static const WCHAR wSo[] = { '.','s','o',0 }; @@ -822,7 +820,7 @@ static unsigned dde_connect(WCHAR* key, const WCHAR* start, WCHAR* ddeexec, strcpyW(endkey, wTopic); topiclen = sizeof(topic); - if (RegQueryValueW(HKEY_CLASSES_ROOT, key, topic, &topiclen) != ERROR_SUCCESS) + if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, topic, &topiclen) != ERROR_SUCCESS) { static const WCHAR wSystem[] = {'S','y','s','t','e','m',0}; strcpyW(topic, wSystem); @@ -864,7 +862,7 @@ static unsigned dde_connect(WCHAR* key, const WCHAR* start, WCHAR* ddeexec, } strcpyW(endkey, wIfexec); ifexeclen = sizeof(ifexec); - if (RegQueryValueW(HKEY_CLASSES_ROOT, key, ifexec, &ifexeclen) == ERROR_SUCCESS) + if (RegQueryValueW(HKEY_CLASSES_ROOT, regkey, ifexec, &ifexeclen) == ERROR_SUCCESS) { exec = ifexec; } @@ -907,7 +905,7 @@ static unsigned dde_connect(WCHAR* key, const WCHAR* start, WCHAR* ddeexec, /************************************************************************* * execute_from_key [Internal] */ -static UINT_PTR execute_from_key(LPWSTR key, LPCWSTR lpFile, WCHAR *env, LPCWSTR szCommandline, +static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env, LPCWSTR szCommandline, LPCWSTR executable_name, SHELL_ExecuteW32 execfunc, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out) @@ -1289,24 +1287,181 @@ static LONG ShellExecute_FromContextMenu( LPSHELLEXECUTEINFOW sei ) return r; } +static UINT_PTR SHELL_execute_class( LPCWSTR wszApplicationName, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc ) +{ + static const WCHAR wSpace[] = {' ',0}; + WCHAR execCmd[1024], wcmd[1024]; + /* launch a document by fileclass like 'WordPad.Document.1' */ + /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */ + /* FIXME: wcmd should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */ + ULONG cmask=(psei->fMask & SEE_MASK_CLASSALL); + DWORD resultLen; + BOOL done; + + HCR_GetExecuteCommandW((cmask == SEE_MASK_CLASSKEY) ? psei->hkeyClass : NULL, + (cmask == SEE_MASK_CLASSNAME) ? psei->lpClass: NULL, + psei->lpVerb, + execCmd, sizeof(execCmd)); + + /* FIXME: get the extension of lpFile, check if it fits to the lpClass */ + TRACE("SEE_MASK_CLASSNAME->%s, doc->%s\n", debugstr_w(execCmd), debugstr_w(wszApplicationName)); + + wcmd[0] = '\0'; + done = SHELL_ArgifyW(wcmd, sizeof(wcmd)/sizeof(WCHAR), execCmd, wszApplicationName, psei->lpIDList, NULL, &resultLen); + if (!done && wszApplicationName[0]) + { + strcatW(wcmd, wSpace); + strcatW(wcmd, wszApplicationName); + } + if (resultLen > sizeof(wcmd)/sizeof(WCHAR)) + ERR("Argify buffer not large enough... truncating\n"); + return execfunc(wcmd, NULL, FALSE, psei, psei_out); +} + +static BOOL SHELL_translate_idlist( LPSHELLEXECUTEINFOW sei, LPWSTR wszParameters, DWORD parametersLen, LPWSTR wszApplicationName, DWORD dwApplicationNameLen ) +{ + static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0}; + WCHAR buffer[MAX_PATH]; + BOOL appKnownSingular = FALSE; + + /* last chance to translate IDList: now also allow CLSID paths */ + if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW(sei->lpIDList, buffer, sizeof(buffer)))) { + if (buffer[0]==':' && buffer[1]==':') { + /* open shell folder for the specified class GUID */ + if (lstrlenW(buffer) + 1 > parametersLen) + ERR("parameters len exceeds buffer size (%i > %i), truncating\n", + lstrlenW(buffer) + 1, parametersLen); + lstrcpynW(wszParameters, buffer, parametersLen); + if (lstrlenW(wExplorer) > dwApplicationNameLen) + ERR("application len exceeds buffer size (%i > %i), truncating\n", + lstrlenW(wExplorer) + 1, dwApplicationNameLen); + lstrcpynW(wszApplicationName, wExplorer, dwApplicationNameLen); + appKnownSingular = TRUE; + + sei->fMask &= ~SEE_MASK_INVOKEIDLIST; + } else { + WCHAR target[MAX_PATH]; + DWORD attribs; + DWORD resultLen; + /* Check if we're executing a directory and if so use the + handler for the Folder class */ + strcpyW(target, buffer); + attribs = GetFileAttributesW(buffer); + if (attribs != INVALID_FILE_ATTRIBUTES && + (attribs & FILE_ATTRIBUTE_DIRECTORY) && + HCR_GetExecuteCommandW(0, wszFolder, + sei->lpVerb, + buffer, sizeof(buffer))) { + SHELL_ArgifyW(wszApplicationName, dwApplicationNameLen, + buffer, target, sei->lpIDList, NULL, &resultLen); + if (resultLen > dwApplicationNameLen) + ERR("Argify buffer not large enough... truncating\n"); + appKnownSingular = FALSE; + } + sei->fMask &= ~SEE_MASK_INVOKEIDLIST; + } + } + return appKnownSingular; +} + +static UINT_PTR SHELL_quote_and_execute( LPCWSTR wcmd, LPCWSTR wszParameters, LPCWSTR lpstrProtocol, LPCWSTR wszApplicationName, LPWSTR env, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc ) +{ + static const WCHAR wQuote[] = {'"',0}; + static const WCHAR wSpace[] = {' ',0}; + UINT_PTR retval; + DWORD len; + WCHAR *wszQuotedCmd; + + /* Length of quotes plus length of command plus NULL terminator */ + len = 2 + lstrlenW(wcmd) + 1; + if (wszParameters[0]) + { + /* Length of space plus length of parameters */ + len += 1 + lstrlenW(wszParameters); + } + wszQuotedCmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + /* Must quote to handle case where cmd contains spaces, + * else security hole if malicious user creates executable file "C:\\Program" + */ + strcpyW(wszQuotedCmd, wQuote); + strcatW(wszQuotedCmd, wcmd); + strcatW(wszQuotedCmd, wQuote); + if (wszParameters[0]) { + strcatW(wszQuotedCmd, wSpace); + strcatW(wszQuotedCmd, wszParameters); + } + TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName), debugstr_w(psei->lpVerb), debugstr_w(wszQuotedCmd), debugstr_w(lpstrProtocol)); + if (*lpstrProtocol) + retval = execute_from_key(lpstrProtocol, wszApplicationName, env, psei->lpParameters, wcmd, execfunc, psei, psei_out); + else + retval = execfunc(wszQuotedCmd, env, FALSE, psei, psei_out); + HeapFree(GetProcessHeap(), 0, wszQuotedCmd); + return retval; +} + +static UINT_PTR SHELL_execute_url( LPCWSTR lpFile, LPCWSTR wFile, LPCWSTR wcmd, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out, SHELL_ExecuteW32 execfunc ) +{ + static const WCHAR wShell[] = {'\\','s','h','e','l','l','\\',0}; + static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0}; + UINT_PTR retval; + WCHAR *lpstrProtocol; + LPCWSTR lpstrRes; + INT iSize; + DWORD len; + + lpstrRes = strchrW(lpFile, ':'); + if (lpstrRes) + iSize = lpstrRes - lpFile; + else + iSize = strlenW(lpFile); + + TRACE("Got URL: %s\n", debugstr_w(lpFile)); + /* Looking for ...protocol\shell\lpOperation\command */ + len = iSize + lstrlenW(wShell) + lstrlenW(wCommand) + 1; + if (psei->lpVerb) + len += lstrlenW(psei->lpVerb); + else + len += lstrlenW(wszOpen); + lpstrProtocol = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR)); + lpstrProtocol[iSize] = '\0'; + strcatW(lpstrProtocol, wShell); + strcatW(lpstrProtocol, psei->lpVerb? psei->lpVerb: wszOpen); + strcatW(lpstrProtocol, wCommand); + + /* Remove File Protocol from lpFile */ + /* In the case file://path/file */ + if (!strncmpiW(lpFile, wFile, iSize)) + { + lpFile += iSize; + while (*lpFile == ':') lpFile++; + } + retval = execute_from_key(lpstrProtocol, lpFile, NULL, psei->lpParameters, + wcmd, execfunc, psei, psei_out); + HeapFree(GetProcessHeap(), 0, lpstrProtocol); + return retval; +} + /************************************************************************* * SHELL_execute [Internal] */ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) { - static const WCHAR wQuote[] = {'"',0}; static const WCHAR wSpace[] = {' ',0}; static const WCHAR wWww[] = {'w','w','w',0}; static const WCHAR wFile[] = {'f','i','l','e',0}; static const WCHAR wHttp[] = {'h','t','t','p',':','/','/',0}; - static const WCHAR wExplorer[] = {'e','x','p','l','o','r','e','r','.','e','x','e',0}; static const DWORD unsupportedFlags = SEE_MASK_INVOKEIDLIST | SEE_MASK_ICON | SEE_MASK_HOTKEY | SEE_MASK_CONNECTNETDRV | SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI | SEE_MASK_UNICODE | SEE_MASK_ASYNCOK | SEE_MASK_HMONITOR; - WCHAR *wszApplicationName, wszParameters[1024], wszDir[MAX_PATH]; + WCHAR parametersBuffer[1024], dirBuffer[MAX_PATH], wcmdBuffer[1024]; + WCHAR *wszApplicationName, *wszParameters, *wszDir, *wcmd; DWORD dwApplicationNameLen = MAX_PATH+2; + DWORD parametersLen = sizeof(parametersBuffer) / sizeof(WCHAR); + DWORD dirLen = sizeof(dirBuffer) / sizeof(WCHAR); + DWORD wcmdLen = sizeof(wcmdBuffer) / sizeof(WCHAR); DWORD len; SHELLEXECUTEINFOW sei_tmp; /* modifiable copy of SHELLEXECUTEINFO struct */ WCHAR wfileName[MAX_PATH]; @@ -1314,9 +1469,6 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) WCHAR lpstrProtocol[256]; LPCWSTR lpFile; UINT_PTR retval = SE_ERR_NOASSOC; - WCHAR wcmd[1024]; - WCHAR buffer[MAX_PATH]; - BOOL done; BOOL appKnownSingular = FALSE; /* make a local copy of the LPSHELLEXECUTEINFO structure and work with this from now on */ @@ -1354,13 +1506,31 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) memcpy(wszApplicationName, sei_tmp.lpFile, l*sizeof(WCHAR)); } + wszParameters = parametersBuffer; if (sei_tmp.lpParameters) + { + len = lstrlenW(sei_tmp.lpParameters) + 1; + if (len > parametersLen) + { + wszParameters = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + parametersLen = len; + } strcpyW(wszParameters, sei_tmp.lpParameters); + } else *wszParameters = '\0'; + wszDir = dirBuffer; if (sei_tmp.lpDirectory) + { + len = lstrlenW(sei_tmp.lpDirectory) + 1; + if (len > dirLen) + { + wszDir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + dirLen = len; + } strcpyW(wszDir, sei_tmp.lpDirectory); + } else *wszDir = '\0'; @@ -1389,6 +1559,10 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) if (hr == S_OK) { HeapFree(GetProcessHeap(), 0, wszApplicationName); + if (wszParameters != parametersBuffer) + HeapFree(GetProcessHeap(), 0, wszParameters); + if (wszDir != dirBuffer) + HeapFree(GetProcessHeap(), 0, wszDir); return TRUE; } } @@ -1402,73 +1576,32 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) { sei->hInstApp = (HINSTANCE) 33; HeapFree(GetProcessHeap(), 0, wszApplicationName); + if (wszParameters != parametersBuffer) + HeapFree(GetProcessHeap(), 0, wszParameters); + if (wszDir != dirBuffer) + HeapFree(GetProcessHeap(), 0, wszDir); return TRUE; } if (sei_tmp.fMask & SEE_MASK_CLASSALL) { - /* launch a document by fileclass like 'WordPad.Document.1' */ - /* the Commandline contains 'c:\Path\wordpad.exe "%1"' */ - /* FIXME: szCommandline should not be of a fixed size. Fixed to 1024, MAX_PATH is way too short! */ - ULONG cmask=(sei_tmp.fMask & SEE_MASK_CLASSALL); - DWORD resultLen; - HCR_GetExecuteCommandW((cmask == SEE_MASK_CLASSKEY) ? sei_tmp.hkeyClass : NULL, - (cmask == SEE_MASK_CLASSNAME) ? sei_tmp.lpClass: NULL, - sei_tmp.lpVerb, - wszParameters, sizeof(wszParameters)/sizeof(WCHAR)); - - /* FIXME: get the extension of lpFile, check if it fits to the lpClass */ - TRACE("SEE_MASK_CLASSNAME->%s, doc->%s\n", debugstr_w(wszParameters), debugstr_w(wszApplicationName)); - - wcmd[0] = '\0'; - done = SHELL_ArgifyW(wcmd, sizeof(wcmd)/sizeof(WCHAR), wszParameters, wszApplicationName, sei_tmp.lpIDList, NULL, &resultLen); - if (!done && wszApplicationName[0]) - { - strcatW(wcmd, wSpace); - strcatW(wcmd, wszApplicationName); - } - if (resultLen > sizeof(wcmd)/sizeof(WCHAR)) - ERR("Argify buffer not large enough... truncating\n"); - retval = execfunc(wcmd, NULL, FALSE, &sei_tmp, sei); - + retval = SHELL_execute_class( wszApplicationName, &sei_tmp, sei, + execfunc ); HeapFree(GetProcessHeap(), 0, wszApplicationName); + if (wszParameters != parametersBuffer) + HeapFree(GetProcessHeap(), 0, wszParameters); + if (wszDir != dirBuffer) + HeapFree(GetProcessHeap(), 0, wszDir); return retval > 32; } /* Has the IDList not yet been translated? */ if (sei_tmp.fMask & SEE_MASK_IDLIST) { - /* last chance to translate IDList: now also allow CLSID paths */ - if (SUCCEEDED(SHELL_GetPathFromIDListForExecuteW(sei_tmp.lpIDList, buffer, sizeof(buffer)))) { - if (buffer[0]==':' && buffer[1]==':') { - /* open shell folder for the specified class GUID */ - strcpyW(wszParameters, buffer); - strcpyW(wszApplicationName, wExplorer); - appKnownSingular = TRUE; - - sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST; - } else { - WCHAR target[MAX_PATH]; - DWORD attribs; - DWORD resultLen; - /* Check if we're executing a directory and if so use the - handler for the Folder class */ - strcpyW(target, buffer); - attribs = GetFileAttributesW(buffer); - if (attribs != INVALID_FILE_ATTRIBUTES && - (attribs & FILE_ATTRIBUTE_DIRECTORY) && - HCR_GetExecuteCommandW(0, wszFolder, - sei_tmp.lpVerb, - buffer, sizeof(buffer))) { - SHELL_ArgifyW(wszApplicationName, dwApplicationNameLen, - buffer, target, sei_tmp.lpIDList, NULL, &resultLen); - if (resultLen > dwApplicationNameLen) - ERR("Argify buffer not large enough... truncating\n"); - appKnownSingular = FALSE; - } - sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST; - } - } + appKnownSingular = SHELL_translate_idlist( &sei_tmp, wszParameters, + parametersLen, + wszApplicationName, + dwApplicationNameLen ); } /* expand environment strings */ @@ -1496,10 +1629,11 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) len++; buf = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); ExpandEnvironmentStringsW(sei_tmp.lpParameters, buf, len); - if (len > 1024) - ERR("Parameters exceeds buffer size (%i > 1024)\n",len); - lstrcpynW(wszParameters, buf, min(1024,len)); - HeapFree(GetProcessHeap(),0,buf); + if (wszParameters != parametersBuffer) + HeapFree(GetProcessHeap(), 0, wszParameters); + wszParameters = buf; + parametersLen = len; + sei_tmp.lpParameters = wszParameters; } } @@ -1512,10 +1646,10 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) len++; buf = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); ExpandEnvironmentStringsW(sei_tmp.lpDirectory, buf, len); - if (len > 1024) - ERR("Directory exceeds buffer size (%i > 1024)\n",len); - lstrcpynW(wszDir, buf, min(1024,len)); - HeapFree(GetProcessHeap(),0,buf); + if (wszDir != dirBuffer) + HeapFree(GetProcessHeap(), 0, wszDir); + wszDir = buf; + sei_tmp.lpDirectory = wszDir; } } @@ -1586,6 +1720,15 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) lpFile = wfileName; + wcmd = wcmdBuffer; + len = lstrlenW(wszApplicationName) + 1; + if (sei_tmp.lpParameters[0]) + len += 1 + lstrlenW(wszParameters); + if (len > wcmdLen) + { + wcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + wcmdLen = len; + } strcpyW(wcmd, wszApplicationName); if (sei_tmp.lpParameters[0]) { strcatW(wcmd, wSpace); @@ -1595,61 +1738,28 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) retval = execfunc(wcmd, NULL, FALSE, &sei_tmp, sei); if (retval > 32) { HeapFree(GetProcessHeap(), 0, wszApplicationName); + if (wszParameters != parametersBuffer) + HeapFree(GetProcessHeap(), 0, wszParameters); + if (wszDir != dirBuffer) + HeapFree(GetProcessHeap(), 0, wszDir); + if (wcmd != wcmdBuffer) + HeapFree(GetProcessHeap(), 0, wcmd); return TRUE; } /* Else, try to find the executable */ wcmd[0] = '\0'; - retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, 1024, lpstrProtocol, &env, sei_tmp.lpIDList, sei_tmp.lpParameters); + retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, wcmdLen, lpstrProtocol, &env, sei_tmp.lpIDList, sei_tmp.lpParameters); if (retval > 32) /* Found */ { - WCHAR wszQuotedCmd[MAX_PATH+2]; - /* Must quote to handle case where cmd contains spaces, - * else security hole if malicious user creates executable file "C:\\Program" - */ - strcpyW(wszQuotedCmd, wQuote); - strcatW(wszQuotedCmd, wcmd); - strcatW(wszQuotedCmd, wQuote); - if (wszParameters[0]) { - strcatW(wszQuotedCmd, wSpace); - strcatW(wszQuotedCmd, wszParameters); - } - TRACE("%s/%s => %s/%s\n", debugstr_w(wszApplicationName), debugstr_w(sei_tmp.lpVerb), debugstr_w(wszQuotedCmd), debugstr_w(lpstrProtocol)); - if (*lpstrProtocol) - retval = execute_from_key(lpstrProtocol, wszApplicationName, env, sei_tmp.lpParameters, wcmd, execfunc, &sei_tmp, sei); - else - retval = execfunc(wszQuotedCmd, env, FALSE, &sei_tmp, sei); + retval = SHELL_quote_and_execute( wcmd, wszParameters, lpstrProtocol, + wszApplicationName, env, &sei_tmp, + sei, execfunc ); HeapFree( GetProcessHeap(), 0, env ); } else if (PathIsURLW(lpFile)) /* File not found, check for URL */ { - static const WCHAR wShell[] = {'\\','s','h','e','l','l','\\',0}; - static const WCHAR wCommand[] = {'\\','c','o','m','m','a','n','d',0}; - LPWSTR lpstrRes; - INT iSize; - - lpstrRes = strchrW(lpFile, ':'); - if (lpstrRes) - iSize = lpstrRes - lpFile; - else - iSize = strlenW(lpFile); - - TRACE("Got URL: %s\n", debugstr_w(lpFile)); - /* Looking for ...protocol\shell\lpOperation\command */ - memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR)); - lpstrProtocol[iSize] = '\0'; - strcatW(lpstrProtocol, wShell); - strcatW(lpstrProtocol, sei_tmp.lpVerb? sei_tmp.lpVerb: wszOpen); - strcatW(lpstrProtocol, wCommand); - - /* Remove File Protocol from lpFile */ - /* In the case file://path/file */ - if (!strncmpiW(lpFile, wFile, iSize)) - { - lpFile += iSize; - while (*lpFile == ':') lpFile++; - } - retval = execute_from_key(lpstrProtocol, lpFile, NULL, sei_tmp.lpParameters, wcmd, execfunc, &sei_tmp, sei); + retval = SHELL_execute_url( lpFile, wFile, wcmd, &sei_tmp, sei, execfunc ); } /* Check if file specified is in the form www.??????.*** */ else if (!strncmpiW(lpFile, wWww, 3)) @@ -1664,6 +1774,12 @@ BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) TRACE("retval %lu\n", retval); HeapFree(GetProcessHeap(), 0, wszApplicationName); + if (wszParameters != parametersBuffer) + HeapFree(GetProcessHeap(), 0, wszParameters); + if (wszDir != dirBuffer) + HeapFree(GetProcessHeap(), 0, wszDir); + if (wcmd != wcmdBuffer) + HeapFree(GetProcessHeap(), 0, wcmd); sei->hInstApp = (HINSTANCE)(retval > 32 ? 33 : retval); return retval > 32; diff --git a/dlls/urlmon/bindctx.c b/dlls/urlmon/bindctx.c index 9d24707d2a6..13dd9876ea5 100644 --- a/dlls/urlmon/bindctx.c +++ b/dlls/urlmon/bindctx.c @@ -520,7 +520,9 @@ HRESULT WINAPI RegisterBindStatusCallback(IBindCtx *pbc, IBindStatusCallback *pb IBindCtx_RevokeObjectParam(pbc, BSCBHolder); } - hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)create_bsc(pbsc)); + bsc = create_bsc(pbsc); + hres = IBindCtx_RegisterObjectParam(pbc, BSCBHolder, (IUnknown*)bsc); + IBindStatusCallback_Release(bsc); if(FAILED(hres)) { IBindStatusCallback_Release(prev); return hres; diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 958f4fee390..d7c649982ec 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -184,7 +184,7 @@ typedef struct * We still like to call them internally * "static inline" makes them more like macro's */ -static inline BOOL EDIT_EM_CanUndo(EDITSTATE *es); +static inline BOOL EDIT_EM_CanUndo(const EDITSTATE *es); static inline void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es); static inline void EDIT_WM_Clear(EDITSTATE *es); static inline void EDIT_WM_Cut(EDITSTATE *es); @@ -204,7 +204,7 @@ static void EDIT_MoveUp_ML(EDITSTATE *es, BOOL extend); */ static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count, INT action); static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap); -static void EDIT_ConfinePoint(EDITSTATE *es, LPINT x, LPINT y); +static void EDIT_ConfinePoint(const EDITSTATE *es, LPINT x, LPINT y); static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc); static void EDIT_InvalidateText(EDITSTATE *es, INT start, INT end); static void EDIT_LockBuffer(EDITSTATE *es); @@ -220,7 +220,7 @@ static void EDIT_PaintLine(EDITSTATE *es, HDC hdc, INT line, BOOL rev); static INT EDIT_PaintText(EDITSTATE *es, HDC hdc, INT x, INT y, INT line, INT col, INT count, BOOL rev); static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap); static void EDIT_AdjustFormatRect(EDITSTATE *es); -static void EDIT_SetRectNP(EDITSTATE *es, LPRECT lprc); +static void EDIT_SetRectNP(EDITSTATE *es, const RECT *lprc); static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force); static void EDIT_UpdateScrollInfo(EDITSTATE *es); static INT CALLBACK EDIT_WordBreakProc(LPWSTR s, INT index, INT count, INT action); @@ -232,10 +232,10 @@ static BOOL EDIT_EM_FmtLines(EDITSTATE *es, BOOL add_eol); static HLOCAL EDIT_EM_GetHandle(EDITSTATE *es); static HLOCAL16 EDIT_EM_GetHandle16(EDITSTATE *es); static INT EDIT_EM_GetLine(EDITSTATE *es, INT line, LPWSTR dst, BOOL unicode); -static LRESULT EDIT_EM_GetSel(EDITSTATE *es, PUINT start, PUINT end); +static LRESULT EDIT_EM_GetSel(const EDITSTATE *es, PUINT start, PUINT end); static LRESULT EDIT_EM_GetThumb(EDITSTATE *es); static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index); -static INT EDIT_EM_LineIndex(EDITSTATE *es, INT line); +static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line); static INT EDIT_EM_LineLength(EDITSTATE *es, INT index); static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy); static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy); @@ -249,8 +249,8 @@ static void EDIT_EM_SetLimitText(EDITSTATE *es, UINT limit); static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, WORD left, WORD right, BOOL repaint); static void EDIT_EM_SetPasswordChar(EDITSTATE *es, WCHAR c); static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap); -static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs); -static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, LPINT16 tabs); +static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs); +static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, const INT16 *tabs); static void EDIT_EM_SetWordBreakProc(EDITSTATE *es, void *wbp); static void EDIT_EM_SetWordBreakProc16(EDITSTATE *es, EDITWORDBREAKPROC16 wbp); static BOOL EDIT_EM_Undo(EDITSTATE *es); @@ -264,7 +264,7 @@ static void EDIT_WM_Copy(EDITSTATE *es); static LRESULT EDIT_WM_Create(EDITSTATE *es, LPCWSTR name); static LRESULT EDIT_WM_Destroy(EDITSTATE *es); static LRESULT EDIT_WM_EraseBkGnd(EDITSTATE *es, HDC dc); -static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPWSTR dst, BOOL unicode); +static INT EDIT_WM_GetText(const EDITSTATE *es, INT count, LPWSTR dst, BOOL unicode); static LRESULT EDIT_WM_HScroll(EDITSTATE *es, INT action, INT pos); static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key); static LRESULT EDIT_WM_KillFocus(EDITSTATE *es); @@ -284,7 +284,7 @@ static LRESULT EDIT_WM_StyleChanged(EDITSTATE *es, WPARAM which, const STYLESTR static LRESULT EDIT_WM_SysKeyDown(EDITSTATE *es, INT key, DWORD key_data); static void EDIT_WM_Timer(EDITSTATE *es); static LRESULT EDIT_WM_VScroll(EDITSTATE *es, INT action, INT pos); -static void EDIT_UpdateText(EDITSTATE *es, LPRECT rc, BOOL bErase); +static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase); static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase); static void EDIT_ImeComposition(HWND hwnd, LPARAM CompFlag, EDITSTATE *es); @@ -312,7 +312,7 @@ const struct builtin_class_descr EDIT_builtin_class = * EM_CANUNDO * */ -static inline BOOL EDIT_EM_CanUndo(EDITSTATE *es) +static inline BOOL EDIT_EM_CanUndo(const EDITSTATE *es) { return (es->undo_insert_count || strlenW(es->undo_text)); } @@ -1622,7 +1622,7 @@ static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap) * (so CharFromPos returns the nearest _visible_ character) * */ -static void EDIT_ConfinePoint(EDITSTATE *es, LPINT x, LPINT y) +static void EDIT_ConfinePoint(const EDITSTATE *es, LPINT x, LPINT y) { *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1); *y = min(max(*y, es->format_rect.top), es->format_rect.bottom - 1); @@ -2390,7 +2390,7 @@ static void EDIT_AdjustFormatRect(EDITSTATE *es) * it is also used to set the rect of a single line control * */ -static void EDIT_SetRectNP(EDITSTATE *es, LPRECT rc) +static void EDIT_SetRectNP(EDITSTATE *es, const RECT *rc) { LONG_PTR ExStyle; INT bw, bh; @@ -2855,7 +2855,7 @@ static INT EDIT_EM_GetLine(EDITSTATE *es, INT line, LPWSTR dst, BOOL unicode) * EM_GETSEL * */ -static LRESULT EDIT_EM_GetSel(EDITSTATE *es, PUINT start, PUINT end) +static LRESULT EDIT_EM_GetSel(const EDITSTATE *es, PUINT start, PUINT end) { UINT s = es->selection_start; UINT e = es->selection_end; @@ -2920,10 +2920,10 @@ static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index) * EM_LINEINDEX * */ -static INT EDIT_EM_LineIndex(EDITSTATE *es, INT line) +static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line) { INT line_index; - LINEDEF *line_def; + const LINEDEF *line_def; if (!(es->style & ES_MULTILINE)) return 0; @@ -3851,7 +3851,7 @@ static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap) * EM_SETTABSTOPS * */ -static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs) +static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs) { if (!(es->style & ES_MULTILINE)) return FALSE; @@ -3872,7 +3872,7 @@ static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs) * EM_SETTABSTOPS16 * */ -static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, LPINT16 tabs) +static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, const INT16 *tabs) { if (!(es->style & ES_MULTILINE)) return FALSE; @@ -4275,7 +4275,7 @@ static LRESULT EDIT_WM_EraseBkGnd(EDITSTATE *es, HDC dc) * WM_GETTEXT * */ -static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPWSTR dst, BOOL unicode) +static INT EDIT_WM_GetText(const EDITSTATE *es, INT count, LPWSTR dst, BOOL unicode) { if(!count) return 0; @@ -5344,7 +5344,7 @@ static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase) * EDIT_UpdateText * */ -static void EDIT_UpdateText(EDITSTATE *es, LPRECT rc, BOOL bErase) +static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase) { if (es->flags & EF_UPDATE) { es->flags &= ~EF_UPDATE; diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 5d99670895f..d819684c2cb 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -131,7 +131,7 @@ static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE; static LRESULT WINAPI ListBoxWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); static LRESULT WINAPI ListBoxWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); -static LRESULT LISTBOX_GetItemRect( LB_DESCR *descr, INT index, RECT *rect ); +static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT *rect ); /********************************************************************* * listbox class descriptor @@ -177,7 +177,7 @@ static inline BOOL is_old_app( LB_DESCR *descr ) * * Return the current page size */ -static INT LISTBOX_GetCurrentPageSize( LB_DESCR *descr ) +static INT LISTBOX_GetCurrentPageSize( const LB_DESCR *descr ) { INT i, height; if (!(descr->style & LBS_OWNERDRAWVARIABLE)) return descr->page_size; @@ -195,7 +195,7 @@ static INT LISTBOX_GetCurrentPageSize( LB_DESCR *descr ) * * Return the maximum possible index for the top of the listbox. */ -static INT LISTBOX_GetMaxTopIndex( LB_DESCR *descr ) +static INT LISTBOX_GetMaxTopIndex( const LB_DESCR *descr ) { INT max, page; @@ -432,7 +432,7 @@ static void LISTBOX_UpdateSize( LB_DESCR *descr ) * Get the rectangle enclosing an item, in listbox client coordinates. * Return 1 if the rectangle is (partially) visible, 0 if hidden, -1 on error. */ -static LRESULT LISTBOX_GetItemRect( LB_DESCR *descr, INT index, RECT *rect ) +static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT *rect ) { /* Index <= 0 is legal even on empty listboxes */ if (index && (index >= descr->nb_items)) @@ -490,7 +490,7 @@ static LRESULT LISTBOX_GetItemRect( LB_DESCR *descr, INT index, RECT *rect ) * * Return the item nearest from point (x,y) (in client coordinates). */ -static INT LISTBOX_GetItemFromPoint( LB_DESCR *descr, INT x, INT y ) +static INT LISTBOX_GetItemFromPoint( const LB_DESCR *descr, INT x, INT y ) { INT index = descr->top_item; @@ -999,10 +999,10 @@ static INT LISTBOX_FindString( LB_DESCR *descr, INT start, LPCWSTR str, BOOL exa /*********************************************************************** * LISTBOX_GetSelCount */ -static LRESULT LISTBOX_GetSelCount( LB_DESCR *descr ) +static LRESULT LISTBOX_GetSelCount( const LB_DESCR *descr ) { INT i, count; - LB_ITEMDATA *item = descr->items; + const LB_ITEMDATA *item = descr->items; if (!(descr->style & LBS_MULTIPLESEL) || (descr->style & LBS_NOSEL)) @@ -1016,10 +1016,10 @@ static LRESULT LISTBOX_GetSelCount( LB_DESCR *descr ) /*********************************************************************** * LISTBOX_GetSelItems16 */ -static LRESULT LISTBOX_GetSelItems16( LB_DESCR *descr, INT16 max, LPINT16 array ) +static LRESULT LISTBOX_GetSelItems16( const LB_DESCR *descr, INT16 max, LPINT16 array ) { INT i, count; - LB_ITEMDATA *item = descr->items; + const LB_ITEMDATA *item = descr->items; if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR; for (i = count = 0; (i < descr->nb_items) && (count < max); i++, item++) @@ -1031,10 +1031,10 @@ static LRESULT LISTBOX_GetSelItems16( LB_DESCR *descr, INT16 max, LPINT16 array /*********************************************************************** * LISTBOX_GetSelItems */ -static LRESULT LISTBOX_GetSelItems( LB_DESCR *descr, INT max, LPINT array ) +static LRESULT LISTBOX_GetSelItems( const LB_DESCR *descr, INT max, LPINT array ) { INT i, count; - LB_ITEMDATA *item = descr->items; + const LB_ITEMDATA *item = descr->items; if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR; for (i = count = 0; (i < descr->nb_items) && (count < max); i++, item++) @@ -1200,7 +1200,7 @@ static void LISTBOX_InvalidateItemRect( LB_DESCR *descr, INT index ) /*********************************************************************** * LISTBOX_GetItemHeight */ -static LRESULT LISTBOX_GetItemHeight( LB_DESCR *descr, INT index ) +static LRESULT LISTBOX_GetItemHeight( const LB_DESCR *descr, INT index ) { if (descr->style & LBS_OWNERDRAWVARIABLE && descr->nb_items > 0) { diff --git a/dlls/user32/resources/display.rc b/dlls/user32/resources/display.rc index 647bf0027ac..243bf2d7380 100644 --- a/dlls/user32/resources/display.rc +++ b/dlls/user32/resources/display.rc @@ -31,8 +31,8 @@ 0x01, /* horizontal-line width */ /* default system color values */ - 0x00c0c0c0L, /* scrollbar */ - 0x00c0c0c0L, /* desktop */ + 0x00d4d0c8L, /* scrollbar */ + 0x00d4d0c8L, /* desktop */ 0x00800000L, /* active caption */ 0x00ffffffL, /* inactive caption */ 0x00ffffffL, /* menu */ @@ -41,12 +41,12 @@ 0x00000000L, /* menu text */ 0x00000000L, /* window text */ 0x00ffffffL, /* caption text */ - 0x00c0c0c0L, /* active border */ - 0x00c0c0c0L, /* inactive border */ + 0x00d4d0c8L, /* active border */ + 0x00d4d0c8L, /* inactive border */ 0x00ffffffL, /* app workspace */ 0x00800000L, /* hilite bk */ 0x00ffffffL, /* hilite text */ - 0x00c0c0c0L, /* btn face */ + 0x00d4d0c8L, /* btn face */ 0x00808080L, /* btn shadow */ 0x00c0c0c0L, /* gray text */ 0x00000000L, /* btn text */ diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index f5be96c945a..d5acd0bda92 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -87,29 +87,29 @@ enum spi_index static const char * const DefSysColors[] = { - "Scrollbar", "192 192 192", /* COLOR_SCROLLBAR */ - "Background", "0 128 128", /* COLOR_BACKGROUND */ + "Scrollbar", "212 208 200", /* COLOR_SCROLLBAR */ + "Background", "58 110 165", /* COLOR_BACKGROUND */ "ActiveTitle", "0 0 128", /* COLOR_ACTIVECAPTION */ "InactiveTitle", "128 128 128", /* COLOR_INACTIVECAPTION */ - "Menu", "192 192 192", /* COLOR_MENU */ + "Menu", "212 208 200", /* COLOR_MENU */ "Window", "255 255 255", /* COLOR_WINDOW */ "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */ "MenuText", "0 0 0", /* COLOR_MENUTEXT */ "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */ "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */ - "ActiveBorder", "192 192 192", /* COLOR_ACTIVEBORDER */ - "InactiveBorder", "192 192 192", /* COLOR_INACTIVEBORDER */ + "ActiveBorder", "212 208 200", /* COLOR_ACTIVEBORDER */ + "InactiveBorder", "212 208 200", /* COLOR_INACTIVEBORDER */ "AppWorkSpace", "128 128 128", /* COLOR_APPWORKSPACE */ "Hilight", "0 0 128", /* COLOR_HIGHLIGHT */ "HilightText", "255 255 255", /* COLOR_HIGHLIGHTTEXT */ - "ButtonFace", "192 192 192", /* COLOR_BTNFACE */ + "ButtonFace", "212 208 200", /* COLOR_BTNFACE */ "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */ "GrayText", "128 128 128", /* COLOR_GRAYTEXT */ "ButtonText", "0 0 0", /* COLOR_BTNTEXT */ - "InactiveTitleText", "192 192 192", /* COLOR_INACTIVECAPTIONTEXT */ + "InactiveTitleText", "212 208 200", /* COLOR_INACTIVECAPTIONTEXT */ "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */ - "ButtonDkShadow", "0 0 0", /* COLOR_3DDKSHADOW */ - "ButtonLight", "224 224 224", /* COLOR_3DLIGHT */ + "ButtonDkShadow", "64 64 64", /* COLOR_3DDKSHADOW */ + "ButtonLight", "212 208 200", /* COLOR_3DLIGHT */ "InfoText", "0 0 0", /* COLOR_INFOTEXT */ "InfoWindow", "255 255 225", /* COLOR_INFOBK */ "ButtonAlternateFace", "180 180 180", /* COLOR_ALTERNATEBTNFACE */ @@ -117,7 +117,7 @@ static const char * const DefSysColors[] = "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */ "GradientInactiveTitle", "181 181 181", /* COLOR_GRADIENTINACTIVECAPTION */ "MenuHilight", "0 0 0", /* COLOR_MENUHILIGHT */ - "MenuBar", "192 192 192" /* COLOR_MENUBAR */ + "MenuBar", "212 208 200" /* COLOR_MENUBAR */ }; /** @@ -261,8 +261,7 @@ static const WCHAR MessageFontSize[]= {'M','e','s','s','a static const WCHAR System[]= {'S','y','s','t','e','m',0}; static const WCHAR IconTitleSize[]= {'I','c','o','n','T','i','t','l','e','S','i','z','e',0}; static const WCHAR IconTitleFaceName[]= {'I','c','o','n','T','i','t','l','e','F','a','c','e','N','a','m','e',0}; -static const WCHAR defPattern[]= {'1','7','0',' ','8','5',' ','1','7','0',' ','8','5',' ','1','7','0',' ','8','5', - ' ','1','7','0',' ','8','5',0}; +static const WCHAR defPattern[]= {'0',' ','0',' ','0',' ','0',' ','0',' ','0',' ','0',' ','0',0}; static const WCHAR CSu[]= {'%','u',0}; static const WCHAR CSd[]= {'%','d',0}; diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c index 90f3e2cbe4b..529e2c001e1 100644 --- a/dlls/user32/tests/listbox.c +++ b/dlls/user32/tests/listbox.c @@ -1010,7 +1010,7 @@ static void test_listbox_dlgdir(void) /* Loaded path should have overwritten the label text */ SendMessage(g_label, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)pathBuffer); trace("Static control after DlgDirList: %s\n", pathBuffer); - ok (strcmp("default contents", pathBuffer), "DlgDirList() did not modify static control!"); + ok (strcmp("default contents", pathBuffer), "DlgDirList() did not modify static control!\n"); /* There should be some content in the listbox */ itemCount = SendMessage(g_listBox, LB_GETCOUNT, 0, 0); diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 21c1089d758..94a95d27017 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -26,7 +26,6 @@ #include #include "ntstatus.h" #define WIN32_NO_STATUS -#include "winerror.h" #include "windef.h" #include "winbase.h" #include "wingdi.h" diff --git a/dlls/uuid/uuid.c b/dlls/uuid/uuid.c index e1aeaf4f1f6..28cdec46dbf 100644 --- a/dlls/uuid/uuid.c +++ b/dlls/uuid/uuid.c @@ -28,7 +28,6 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); -#include "windef.h" #include "winbase.h" #include "wingdi.h" #include "winuser.h" @@ -69,6 +68,7 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); #include "urlhist.h" #include "hlguids.h" #include "dimm.h" +#include "isguids.h" /* FIXME: cguids declares GUIDs but does not define their values */ diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index d6ca4a87739..4a08f7013c3 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -1723,10 +1723,14 @@ static void shader_arb_cleanup(IWineD3DDevice *iface) { if (GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) glDisable(GL_FRAGMENT_PROGRAM_ARB); } +static void shader_arb_destroy(IWineD3DBaseShader *iface) { +} + const shader_backend_t arb_program_shader_backend = { &shader_arb_select, &shader_arb_select_depth_blt, &shader_arb_load_constants, &shader_arb_cleanup, - &shader_arb_color_correction + &shader_arb_color_correction, + &shader_arb_destroy }; diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c index 7f699270313..638db902f08 100644 --- a/dlls/wined3d/baseshader.c +++ b/dlls/wined3d/baseshader.c @@ -1062,7 +1062,7 @@ void shader_trace_init( } } -void shader_delete_constant_list( +static void shader_delete_constant_list( struct list* clist) { struct list *ptr; @@ -1080,10 +1080,56 @@ static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {} static void shader_none_select_depth_blt(IWineD3DDevice *iface) {} static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {} static void shader_none_cleanup(IWineD3DDevice *iface) {} +static void shader_none_color_correction(SHADER_OPCODE_ARG* arg) {} +static void shader_none_destroy(IWineD3DBaseShader *iface) {} const shader_backend_t none_shader_backend = { &shader_none_select, &shader_none_select_depth_blt, &shader_none_load_constants, - &shader_none_cleanup + &shader_none_cleanup, + &shader_none_color_correction, + &shader_none_destroy }; + +/* ******************************************* + IWineD3DPixelShader IUnknown parts follow + ******************************************* */ +HRESULT WINAPI IWineD3DBaseShaderImpl_QueryInterface(IWineD3DBaseShader *iface, REFIID riid, LPVOID *ppobj) +{ + IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface; + TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj); + if (IsEqualGUID(riid, &IID_IUnknown) + || IsEqualGUID(riid, &IID_IWineD3DBase) + || IsEqualGUID(riid, &IID_IWineD3DBaseShader) + || IsEqualGUID(riid, &IID_IWineD3DPixelShader)) { + IUnknown_AddRef(iface); + *ppobj = This; + return S_OK; + } + *ppobj = NULL; + return E_NOINTERFACE; +} + +ULONG WINAPI IWineD3DBaseShaderImpl_AddRef(IWineD3DBaseShader *iface) { + IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; + TRACE("(%p) : AddRef increasing from %d\n", This, This->baseShader.ref); + return InterlockedIncrement(&This->baseShader.ref); +} + +ULONG WINAPI IWineD3DBaseShaderImpl_Release(IWineD3DBaseShader *iface) { + IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device; + ULONG ref; + TRACE("(%p) : Releasing from %d\n", This, This->baseShader.ref); + ref = InterlockedDecrement(&This->baseShader.ref); + if (ref == 0) { + deviceImpl->shader_backend->shader_destroy(iface); + HeapFree(GetProcessHeap(), 0, This->baseShader.function); + shader_delete_constant_list(&This->baseShader.constantsF); + shader_delete_constant_list(&This->baseShader.constantsB); + shader_delete_constant_list(&This->baseShader.constantsI); + HeapFree(GetProcessHeap(), 0, This); + } + return ref; +} diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 441aa3f0566..659b8bf8d69 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -71,8 +71,8 @@ static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3 object=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3D##type##Impl)); \ D3DMEMCHECK(object, pp##type); \ object->lpVtbl = &IWineD3D##type##_Vtbl; \ - object->parent = parent; \ - object->ref = 1; \ + object->parent = parent; \ + object->baseShader.ref = 1; \ object->baseShader.device = (IWineD3DDevice*) This; \ list_init(&object->baseShader.linked_programs); \ *pp##type = (IWineD3D##type *) object; \ @@ -179,9 +179,9 @@ static ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) { /* NOTE: You must release the parent if the object was created via a callback ** ***************************/ - if (This->resources != NULL ) { + if (!list_empty(&This->resources)) { FIXME("(%p) Device released with resources still bound, acceptable but unexpected\n", This); - dumpResources(This->resources); + dumpResources(&This->resources); } if(This->contexts) ERR("Context array not freed!\n"); @@ -6622,18 +6622,18 @@ static BOOL WINAPI IWineD3DDeviceImpl_ShowCursor(IWineD3DDevice* iface, BOO static HRESULT WINAPI IWineD3DDeviceImpl_TestCooperativeLevel(IWineD3DDevice* iface) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; + IWineD3DResourceImpl *resource; TRACE("(%p) : state (%u)\n", This, This->state); + /* TODO: Implement wrapping of the WndProc so that mimimize and maxamise can be monitored and the states adjusted. */ switch (This->state) { case WINED3D_OK: return WINED3D_OK; case WINED3DERR_DEVICELOST: { - ResourceList *resourceList = This->resources; - while (NULL != resourceList) { - if (((IWineD3DResourceImpl *)resourceList->resource)->resource.pool == WINED3DPOOL_DEFAULT /* TODO: IWineD3DResource_GetPool(resourceList->resource)*/) - return WINED3DERR_DEVICENOTRESET; - resourceList = resourceList->next; + LIST_FOR_EACH_ENTRY(resource, &This->resources, IWineD3DResourceImpl, resource.resource_list_entry) { + if (resource->resource.pool == WINED3DPOOL_DEFAULT) + return WINED3DERR_DEVICENOTRESET; } return WINED3DERR_DEVICELOST; } @@ -6881,51 +6881,17 @@ static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT i *****************************************************/ static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource){ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - ResourceList* resourceList; - - TRACE("(%p) : resource %p\n", This, resource); - /* add a new texture to the frot of the linked list */ - resourceList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ResourceList)); - resourceList->resource = resource; - /* Get the old head */ - resourceList->next = This->resources; - - This->resources = resourceList; - TRACE("Added resource %p with element %p pointing to %p\n", resource, resourceList, resourceList->next); - - return; + TRACE("(%p) : Adding Resource %p\n", This, resource); + list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry); } static void WINAPI IWineD3DDeviceImpl_RemoveResource(IWineD3DDevice *iface, IWineD3DResource *resource){ IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - ResourceList* resourceList = NULL; - ResourceList* previousResourceList = NULL; - - TRACE("(%p) : resource %p\n", This, resource); - resourceList = This->resources; + TRACE("(%p) : Removing resource %p\n", This, resource); - while (resourceList != NULL) { - if(resourceList->resource == resource) break; - previousResourceList = resourceList; - resourceList = resourceList->next; - } - - if (resourceList == NULL) { - FIXME("Attempted to remove resource %p that hasn't been stored\n", resource); - return; - } else { - TRACE("Found resource %p with element %p pointing to %p (previous %p)\n", resourceList->resource, resourceList, resourceList->next, previousResourceList); - } - /* make sure we don't leave a hole in the list */ - if (previousResourceList != NULL) { - previousResourceList->next = resourceList->next; - } else { - This->resources = resourceList->next; - } - - return; + list_remove(&((IWineD3DResourceImpl *) resource)->resource.resource_list_entry); } diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 8ed2d9246f1..36d7ebcfe8b 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -758,7 +758,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) { GLint tmp; glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &tmp); - gl_info->max_fragment_samplers = min(8, tmp); + gl_info->max_fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, tmp); } else { gl_info->max_fragment_samplers = max(gl_info->max_fragment_samplers, gl_max); } @@ -2695,6 +2695,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, object->adapter = numAdapters ? &Adapters[Adapter] : NULL; IWineD3D_AddRef(object->wineD3D); object->parent = parent; + list_init(&object->resources); if(This->dxVersion == 7) { object->surface_alignment = 8; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 5d988e40b4b..d9e525bb5aa 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -293,7 +293,7 @@ static void shader_glsl_load_constantsB( for (i=0; ibaseShader.device)->adapter->gl_info; + + /* Note: Do not use QueryInterface here to find out which shader type this is because this code + * can be called from IWineD3DBaseShader::Release + */ + char pshader = shader_is_pshader_version(This->baseShader.hex_version); + + if(This->baseShader.prgId == 0) return; + linked_programs = &This->baseShader.linked_programs; + + TRACE("Deleting linked programs\n"); + if (linked_programs->next) { + struct glsl_shader_prog_link *entry, *entry2; + + if(pshader) { + LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, pshader_entry) { + delete_glsl_program_entry(This->baseShader.device, entry); + } + } else { + LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, vshader_entry) { + delete_glsl_program_entry(This->baseShader.device, entry); + } + } + } + + TRACE("Deleting shader object %u\n", This->baseShader.prgId); + GL_EXTCALL(glDeleteObjectARB(This->baseShader.prgId)); + checkGLcall("glDeleteObjectARB"); +} + const shader_backend_t glsl_shader_backend = { &shader_glsl_select, &shader_glsl_select_depth_blt, &shader_glsl_load_constants, &shader_glsl_cleanup, - &shader_glsl_color_correction + &shader_glsl_color_correction, + &shader_glsl_destroy }; diff --git a/dlls/wined3d/palette.c b/dlls/wined3d/palette.c index a1dcc9f95f7..506b4fe0630 100644 --- a/dlls/wined3d/palette.c +++ b/dlls/wined3d/palette.c @@ -107,7 +107,7 @@ static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt) { IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface; - ResourceList *res; + IWineD3DResourceImpl *res; TRACE("(%p)->(%08x,%d,%d,%p)\n",This,Flags,Start,Count,PalEnt); @@ -134,11 +134,11 @@ static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DW /* If the palette is attached to the render target, update all render targets */ - for(res = This->wineD3DDevice->resources; res != NULL; res=res->next) { - if(IWineD3DResource_GetType(res->resource) == WINED3DRTYPE_SURFACE) { - IWineD3DSurfaceImpl *impl = (IWineD3DSurfaceImpl *) res->resource; + LIST_FOR_EACH_ENTRY(res, &This->wineD3DDevice->resources, IWineD3DResourceImpl, resource.resource_list_entry) { + if(IWineD3DResource_GetType((IWineD3DResource *) res) == WINED3DRTYPE_SURFACE) { + IWineD3DSurfaceImpl *impl = (IWineD3DSurfaceImpl *) res; if(impl->palette == This) - IWineD3DSurface_RealizePalette( (IWineD3DSurface *) res->resource); + IWineD3DSurface_RealizePalette((IWineD3DSurface *) res); } } diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c index 2c8424d8d25..b9fbd75482d 100644 --- a/dlls/wined3d/pixelshader.c +++ b/dlls/wined3d/pixelshader.c @@ -42,62 +42,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); #endif #define GLNAME_REQUIRE_GLSL ((const char *)1) -/* ******************************************* - IWineD3DPixelShader IUnknown parts follow - ******************************************* */ -static HRESULT WINAPI IWineD3DPixelShaderImpl_QueryInterface(IWineD3DPixelShader *iface, REFIID riid, LPVOID *ppobj) -{ - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; - TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj); - if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IWineD3DBase) - || IsEqualGUID(riid, &IID_IWineD3DBaseShader) - || IsEqualGUID(riid, &IID_IWineD3DPixelShader)) { - IUnknown_AddRef(iface); - *ppobj = This; - return S_OK; - } - *ppobj = NULL; - return E_NOINTERFACE; -} -static ULONG WINAPI IWineD3DPixelShaderImpl_AddRef(IWineD3DPixelShader *iface) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; - TRACE("(%p) : AddRef increasing from %d\n", This, This->ref); - return InterlockedIncrement(&This->ref); +static HRESULT WINAPI IWineD3DPixelShaderImpl_QueryInterface(IWineD3DPixelShader *iface, REFIID riid, LPVOID *ppobj) { + return IWineD3DBaseShaderImpl_QueryInterface((IWineD3DBaseShader *) iface, riid, ppobj); } -static void destroy_glsl_pshader(IWineD3DPixelShaderImpl *This) { - struct list *linked_programs = &This->baseShader.linked_programs; - - TRACE("Deleting linked programs\n"); - if (linked_programs->next) { - struct glsl_shader_prog_link *entry, *entry2; - LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, pshader_entry) { - delete_glsl_program_entry(This->baseShader.device, entry); - } - } - - TRACE("Deleting shader object %u\n", This->baseShader.prgId); - GL_EXTCALL(glDeleteObjectARB(This->baseShader.prgId)); - checkGLcall("glDeleteObjectARB"); +static ULONG WINAPI IWineD3DPixelShaderImpl_AddRef(IWineD3DPixelShader *iface) { + return IWineD3DBaseShaderImpl_AddRef((IWineD3DBaseShader *) iface); } static ULONG WINAPI IWineD3DPixelShaderImpl_Release(IWineD3DPixelShader *iface) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; - ULONG ref; - TRACE("(%p) : Releasing from %d\n", This, This->ref); - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - if (This->baseShader.shader_mode == SHADER_GLSL && This->baseShader.prgId != 0) { - destroy_glsl_pshader(This); - } - shader_delete_constant_list(&This->baseShader.constantsF); - shader_delete_constant_list(&This->baseShader.constantsB); - shader_delete_constant_list(&This->baseShader.constantsI); - HeapFree(GetProcessHeap(), 0, This); - } - return ref; + return IWineD3DBaseShaderImpl_Release((IWineD3DBaseShader *) iface); } /* ******************************************* @@ -676,9 +631,7 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_CompileShader(IWineD3DPixelShader This->baseShader.recompile_count++; } - if (This->baseShader.shader_mode == SHADER_GLSL && This->baseShader.prgId != 0) { - destroy_glsl_pshader(This); - } + deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface); } /* We don't need to compile */ diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 9faaea575b8..151af2c2838 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -248,12 +248,11 @@ HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown return WINED3D_OK; } -void dumpResources(ResourceList *resources) { - ResourceList *iterator = resources; +void dumpResources(struct list *list) { + IWineD3DResourceImpl *resource; - while(iterator) { - FIXME("Leftover resource %p with type %d,%s\n", iterator->resource, IWineD3DResource_GetType(iterator->resource), debug_d3dresourcetype(IWineD3DResource_GetType(iterator->resource))); - iterator = iterator->next; + LIST_FOR_EACH_ENTRY(resource, list, IWineD3DResourceImpl, resource.resource_list_entry) { + FIXME("Leftover resource %p with type %d,%s\n", resource, IWineD3DResource_GetType((IWineD3DResource *) resource), debug_d3dresourcetype(IWineD3DResource_GetType((IWineD3DResource *) resource))); } } diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index bc22d899135..924db6a1c4f 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -120,7 +120,7 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte const WINED3DVERTEXELEMENT *elements, size_t element_count) { IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface; HRESULT hr = WINED3D_OK; - int i; + int i, j; char isPreLoaded[MAX_STREAMS]; TRACE("(%p) : d3d version %d\n", This, ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion); @@ -162,8 +162,35 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte This->num_streams++; isPreLoaded[This->pDeclarationWine[i].Stream] = 1; } + + /* Create a sorted array containing the attribute declarations that are of type + * D3DCOLOR. D3DCOLOR requires swizzling of the r and b component, and if the + * declaration of one attribute changes the vertex shader needs recompilation. + * Having a sorted array of the attributes allows efficient comparison of the + * declaration against a shader + */ + if(This->pDeclarationWine[i].Type == WINED3DDECLTYPE_D3DCOLOR) { + for(j = 0; j < This->num_swizzled_attribs; j++) { + if(This->swizzled_attribs[j].usage > This->pDeclarationWine[i].Usage || + (This->swizzled_attribs[j].usage == This->pDeclarationWine[i].Usage && + This->swizzled_attribs[j].idx > This->pDeclarationWine[i].UsageIndex)) { + memmove(&This->swizzled_attribs[j + 1], &This->swizzled_attribs[j], + sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j - 1))); + break; + } + } + + This->swizzled_attribs[j].usage = This->pDeclarationWine[i].Usage; + This->swizzled_attribs[j].idx = This->pDeclarationWine[i].UsageIndex; + This->num_swizzled_attribs++; + } } + TRACE("Swizzled attributes found:\n"); + for(i = 0; i < This->num_swizzled_attribs; i++) { + TRACE("%u: %s%d\n", i, + debug_d3ddeclusage(This->swizzled_attribs[i].usage), This->swizzled_attribs[i].idx); + } TRACE("Returning\n"); return hr; } diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c index 5baf00d989b..bd4c2c11aa0 100644 --- a/dlls/wined3d/vertexshader.c +++ b/dlls/wined3d/vertexshader.c @@ -263,29 +263,95 @@ BOOL vshader_input_is_color( unsigned int regnum) { IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface; - IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; - IWineD3DVertexDeclarationImpl *vertexDeclaration = (IWineD3DVertexDeclarationImpl *)deviceImpl->stateBlock->vertexDecl; DWORD usage_token = This->semantics_in[regnum].usage; DWORD usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT; DWORD usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT; - if (vertexDeclaration) { - int i; - /* Find the declaration element that matches our register, then check - * if it has D3DCOLOR as it's type. This works for both d3d8 and d3d9. */ - for (i = 0; i < vertexDeclaration->declarationWNumElements-1; ++i) { - WINED3DVERTEXELEMENT *element = vertexDeclaration->pDeclarationWine + i; - if (match_usage(element->Usage, element->UsageIndex, usage, usage_idx)) { - return element->Type == WINED3DDECLTYPE_D3DCOLOR; - } + int i; + + for(i = 0; i < This->num_swizzled_attribs; i++) { + if(This->swizzled_attribs[i].usage == usage && + This->swizzled_attribs[i].idx == usage_idx) { + return TRUE; } } - - ERR("Either no vertexdeclaration present, or register not matched. This should never happen.\n"); return FALSE; } +static inline void find_swizzled_attribs(IWineD3DVertexDeclaration *declaration, IWineD3DVertexShaderImpl *This) { + UINT num = 0, i, j; + UINT numoldswizzles = This->num_swizzled_attribs; + IWineD3DVertexDeclarationImpl *decl = (IWineD3DVertexDeclarationImpl *) declaration; + + DWORD usage_token, usage, usage_idx; + BOOL found; + + attrib_declaration oldswizzles[sizeof(This->swizzled_attribs) / sizeof(This->swizzled_attribs[0])]; + + /* Back up the old swizzles to keep attributes that are undefined in the current declaration */ + memcpy(oldswizzles, This->swizzled_attribs, sizeof(oldswizzles)); + + memset(This->swizzled_attribs, 0, sizeof(This->swizzled_attribs[0]) * MAX_ATTRIBS); + + for(i = 0; i < decl->num_swizzled_attribs; i++) { + for(j = 0; j < MAX_ATTRIBS; j++) { + usage_token = This->semantics_in[j].usage; + usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT; + usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT; + + if(decl->swizzled_attribs[i].usage == usage && + decl->swizzled_attribs[i].idx == usage_idx) { + This->swizzled_attribs[num].usage = usage; + This->swizzled_attribs[num].idx = usage_idx; + num++; + } + } + } + + /* Add previously converted attributes back in if they are not defined in the current declaration */ + for(i = 0; i < numoldswizzles; i++) { + + found = FALSE; + for(j = 0; j < decl->declarationWNumElements; j++) { + if(oldswizzles[i].usage == decl->pDeclarationWine[j].Usage && + oldswizzles[i].idx == decl->pDeclarationWine[j].UsageIndex) { + found = TRUE; + } + } + if(found) { + /* This previously converted attribute is declared in the current declaration. Either it is + * already in the new array, or it should not be there. Skip it + */ + continue; + } + /* We have a previously swizzled attribute that is not defined by the current vertex declaration. + * Insert it into the new conversion array to keep it in the old defined state. Otherwise we end up + * recompiling if the old decl is used again because undefined attributes are reset to no swizzling. + * In the reverse way(attribute was not swizzled and is not declared in new declaration) the attrib + * stays unswizzled as well because it isn't found in the oldswizzles array + */ + for(j = 0; j < num; j++) { + if(oldswizzles[i].usage > This->swizzled_attribs[j].usage || ( + oldswizzles[i].usage == This->swizzled_attribs[j].usage && + oldswizzles[i].idx > This->swizzled_attribs[j].idx)) { + memmove(&This->swizzled_attribs[j + 1], &This->swizzled_attribs[j], + sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j - 1))); + break; + } + } + This->swizzled_attribs[j].usage = oldswizzles[i].usage; + This->swizzled_attribs[j].idx = oldswizzles[i].idx; + num++; + } + + TRACE("New swizzled attributes array\n"); + for(i = 0; i < num; i++) { + TRACE("%d: %s(%d), %d\n", i, debug_d3ddeclusage(This->swizzled_attribs[i].usage), + This->swizzled_attribs[i].usage, This->swizzled_attribs[i].idx); + } + This->num_swizzled_attribs = num; +} /** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB or GLSL and send it to the card */ static VOID IWineD3DVertexShaderImpl_GenerateShader( @@ -294,8 +360,11 @@ static VOID IWineD3DVertexShaderImpl_GenerateShader( CONST DWORD *pFunction) { IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; + IWineD3DVertexDeclaration *decl = ((IWineD3DDeviceImpl *) This->baseShader.device)->stateBlock->vertexDecl; SHADER_BUFFER buffer; + find_swizzled_attribs(decl, This); + #if 0 /* FIXME: Use the buffer that is held by the device, this is ok since fixups will be skipped for software shaders it also requires entering a critical section but cuts down the runtime footprint of wined3d and any memory fragmentation that may occur... */ if (This->device->fixupVertexBufferSize < SHADER_PGMSIZE) { @@ -437,56 +506,16 @@ static VOID IWineD3DVertexShaderImpl_GenerateShader( /* ******************************************* IWineD3DVertexShader IUnknown parts follow ******************************************* */ -static HRESULT WINAPI IWineD3DVertexShaderImpl_QueryInterface(IWineD3DVertexShader *iface, REFIID riid, LPVOID *ppobj) -{ - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; - TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj); - if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_IWineD3DBase) - || IsEqualGUID(riid, &IID_IWineD3DBaseShader) - || IsEqualGUID(riid, &IID_IWineD3DVertexShader)) { - IUnknown_AddRef(iface); - *ppobj = This; - return S_OK; - } - *ppobj = NULL; - return E_NOINTERFACE; +static HRESULT WINAPI IWineD3DVertexShaderImpl_QueryInterface(IWineD3DVertexShader *iface, REFIID riid, LPVOID *ppobj) { + return IWineD3DBaseShaderImpl_QueryInterface((IWineD3DBaseShader *) iface, riid, ppobj); } -static ULONG WINAPI IWineD3DVertexShaderImpl_AddRef(IWineD3DVertexShader *iface) { - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; - TRACE("(%p) : AddRef increasing from %d\n", This, This->ref); - return InterlockedIncrement(&This->ref); +static ULONG WINAPI IWineD3DVertexShaderImpl_AddRef(IWineD3DVertexShader *iface) { + return IWineD3DBaseShaderImpl_AddRef((IWineD3DBaseShader *) iface); } static ULONG WINAPI IWineD3DVertexShaderImpl_Release(IWineD3DVertexShader *iface) { - IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; - ULONG ref; - TRACE("(%p) : Releasing from %d\n", This, This->ref); - ref = InterlockedDecrement(&This->ref); - if (ref == 0) { - if (This->baseShader.shader_mode == SHADER_GLSL && This->baseShader.prgId != 0) { - struct list *linked_programs = &This->baseShader.linked_programs; - - TRACE("Deleting linked programs\n"); - if (linked_programs->next) { - struct glsl_shader_prog_link *entry, *entry2; - LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, linked_programs, struct glsl_shader_prog_link, vshader_entry) { - delete_glsl_program_entry(This->baseShader.device, entry); - } - } - - TRACE("Deleting shader object %u\n", This->baseShader.prgId); - GL_EXTCALL(glDeleteObjectARB(This->baseShader.prgId)); - checkGLcall("glDeleteObjectARB"); - } - shader_delete_constant_list(&This->baseShader.constantsF); - shader_delete_constant_list(&This->baseShader.constantsB); - shader_delete_constant_list(&This->baseShader.constantsI); - HeapFree(GetProcessHeap(), 0, This); - - } - return ref; + return IWineD3DBaseShaderImpl_Release((IWineD3DBaseShader *) iface); } /* ******************************************* @@ -640,14 +669,86 @@ static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertex return WINED3D_OK; } +static inline BOOL swizzled_attribs_differ(IWineD3DVertexShaderImpl *This, IWineD3DVertexDeclarationImpl *vdecl) { + UINT i, j, k; + BOOL found; + + DWORD usage_token; + DWORD usage; + DWORD usage_idx; + + for(i = 0; i < vdecl->declarationWNumElements; i++) { + for(j = 0; j < MAX_ATTRIBS; j++) { + if(!This->baseShader.reg_maps.attributes) continue; + + usage_token = This->semantics_in[j].usage; + usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT; + usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT; + + if(vdecl->pDeclarationWine[i].Usage != usage || + vdecl->pDeclarationWine[i].UsageIndex != usage_idx) { + continue; + } + + found = FALSE; + for(k = 0; k < This->num_swizzled_attribs; k++) { + if(This->swizzled_attribs[k].usage == usage && + This->swizzled_attribs[k].idx == usage_idx) { + found = TRUE; + } + } + if(!found && vdecl->pDeclarationWine[i].Type == WINED3DDECLTYPE_D3DCOLOR) { + TRACE("Attribute %s%d is D3DCOLOR now but wasn't before\n", + debug_d3ddeclusage(usage), usage_idx); + return TRUE; + } + if( found && vdecl->pDeclarationWine[i].Type != WINED3DDECLTYPE_D3DCOLOR) { + TRACE("Attribute %s%d was D3DCOLOR before but is not any more\n", + debug_d3ddeclusage(usage), usage_idx); + return TRUE; + } + } + } + return FALSE; +} + static HRESULT WINAPI IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) { IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; + IWineD3DVertexDeclarationImpl *vdecl; CONST DWORD *function = This->baseShader.function; + IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device; TRACE("(%p) : function %p\n", iface, function); /* We're already compiled. */ - if (This->baseShader.is_compiled) return WINED3D_OK; + if (This->baseShader.is_compiled) { + vdecl = (IWineD3DVertexDeclarationImpl *) deviceImpl->stateBlock->vertexDecl; + + if(This->num_swizzled_attribs != vdecl->num_swizzled_attribs || + memcmp(This->swizzled_attribs, vdecl->swizzled_attribs, sizeof(vdecl->swizzled_attribs[0]) * This->num_swizzled_attribs) != 0) { + + /* The swizzled attributes differ between shader and declaration. This doesn't necessarily mean + * we have to recompile, but we have to take a deeper look at see if the attribs that differ + * are declared in the decl and used in the shader + */ + if(swizzled_attribs_differ(This, vdecl)) { + WARN("Recompiling vertex shader %p due to D3DCOLOR input changes\n", This); + goto recompile; + } + WARN("Swizzled attribute validation required an expensive comparison\n"); + } + + return WINED3D_OK; + + recompile: + if(This->recompile_count < 50) { + This->recompile_count++; + } else { + FIXME("Vertexshader %p recompiled more than 50 times\n", This); + } + + deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface); + } /* We don't need to compile */ if (!function) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 428b8df411e..37908a70f43 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -211,6 +211,7 @@ typedef struct { void (*shader_load_constants)(IWineD3DDevice *iface, char usePS, char useVS); void (*shader_cleanup)(IWineD3DDevice *iface); void (*shader_color_correction)(struct SHADER_OPCODE_ARG *arg); + void (*shader_destroy)(IWineD3DBaseShader *iface); } shader_backend_t; extern const shader_backend_t glsl_shader_backend; @@ -625,13 +626,8 @@ extern BOOL pbuffer_support; /* allocate one pbuffer per surface */ extern BOOL pbuffer_per_surface; -typedef struct ResourceList { - IWineD3DResource *resource; - struct ResourceList *next; -} ResourceList; - /* A helper function that dumps a resource list */ -void dumpResources(ResourceList *resources); +void dumpResources(struct list *list); /***************************************************************************** * IWineD3DDevice implementation structure @@ -681,7 +677,7 @@ struct IWineD3DDeviceImpl IWineD3DSwapChain **swapchains; UINT NumberOfSwapChains; - ResourceList *resources; /* a linked list to track resources created by the device */ + struct list resources; /* a linked list to track resources created by the device */ /* Render Target Support */ IWineD3DSurface **render_targets; @@ -821,6 +817,7 @@ typedef struct IWineD3DResourceClass BYTE *allocatedMemory; /* Pointer to the real data location */ BYTE *heapMemory; /* Pointer to the HeapAlloced block of memory */ struct list privateData; + struct list resource_list_entry; } IWineD3DResourceClass; @@ -1238,6 +1235,13 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ /***************************************************************************** * IWineD3DVertexDeclaration implementation structure */ +typedef struct attrib_declaration { + DWORD usage; + DWORD idx; +} attrib_declaration; + +#define MAX_ATTRIBS 16 + typedef struct IWineD3DVertexDeclarationImpl { /* IUnknown Information */ const IWineD3DVertexDeclarationVtbl *lpVtbl; @@ -1252,6 +1256,10 @@ typedef struct IWineD3DVertexDeclarationImpl { DWORD streams[MAX_STREAMS]; UINT num_streams; BOOL position_transformed; + + /* Ordered array of declaration types that need swizzling in a vshader */ + attrib_declaration swizzled_attribs[MAX_ATTRIBS]; + UINT num_swizzled_attribs; } IWineD3DVertexDeclarationImpl; extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl; @@ -1627,7 +1635,6 @@ typedef struct { #define MAX_REG_TEXCRD 8 #define MAX_REG_INPUT 12 #define MAX_REG_OUTPUT 12 -#define MAX_ATTRIBS 16 #define MAX_CONST_I 16 #define MAX_CONST_B 16 @@ -1748,9 +1755,6 @@ extern const SHADER_OPCODE* shader_get_opcode( IWineD3DBaseShader *iface, const DWORD code); -extern void shader_delete_constant_list( - struct list* clist); - void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_link *entry); /* Vertex shader utility functions */ @@ -1882,11 +1886,12 @@ extern void pshader_glsl_input_pack( */ typedef struct IWineD3DBaseShaderClass { + LONG ref; DWORD hex_version; SHADER_LIMITS limits; SHADER_PARSE_STATE parse_state; CONST SHADER_OPCODE *shader_ins; - CONST DWORD *function; + DWORD *function; UINT functionLength; GLuint prgId; BOOL is_compiled; @@ -1924,12 +1929,15 @@ typedef struct IWineD3DBaseShaderClass typedef struct IWineD3DBaseShaderImpl { /* IUnknown */ const IWineD3DBaseShaderVtbl *lpVtbl; - LONG ref; /* IWineD3DBaseShader */ IWineD3DBaseShaderClass baseShader; } IWineD3DBaseShaderImpl; +HRESULT WINAPI IWineD3DBaseShaderImpl_QueryInterface(IWineD3DBaseShader *iface, REFIID riid, LPVOID *ppobj); +ULONG WINAPI IWineD3DBaseShaderImpl_AddRef(IWineD3DBaseShader *iface); +ULONG WINAPI IWineD3DBaseShaderImpl_Release(IWineD3DBaseShader *iface); + extern HRESULT shader_get_registers_used( IWineD3DBaseShader *iface, shader_reg_maps* reg_maps, @@ -2038,7 +2046,6 @@ static inline BOOL shader_is_scalar(DWORD param) { typedef struct IWineD3DVertexShaderImpl { /* IUnknown parts*/ const IWineD3DVertexShaderVtbl *lpVtbl; - LONG ref; /* Note: Ref counting not required */ /* IWineD3DBaseShader */ IWineD3DBaseShaderClass baseShader; @@ -2052,11 +2059,16 @@ typedef struct IWineD3DVertexShaderImpl { semantic semantics_in [MAX_ATTRIBS]; semantic semantics_out [MAX_REG_OUTPUT]; + /* Ordered array of attributes that are swizzled */ + attrib_declaration swizzled_attribs [MAX_ATTRIBS]; + UINT num_swizzled_attribs; + /* run time datas... */ VSHADERDATA *data; UINT min_rel_offset, max_rel_offset; UINT rel_offset; + UINT recompile_count; #if 0 /* needs reworking */ /* run time datas */ VSHADERINPUTDATA input; @@ -2079,7 +2091,6 @@ enum vertexprocessing_mode { typedef struct IWineD3DPixelShaderImpl { /* IUnknown parts */ const IWineD3DPixelShaderVtbl *lpVtbl; - LONG ref; /* Note: Ref counting not required */ /* IWineD3DBaseShader */ IWineD3DBaseShaderClass baseShader; diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index 2de20ca4ec7..a3fd3d5146c 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -21,6 +21,7 @@ #include "config.h" #include #include +#include #define NONAMELESSUNION #define NONAMELESSSTRUCT @@ -166,17 +167,40 @@ void X11DRV_Settings_Init(void) X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 60); } -/* Our fake driver GUID path */ -static const char wine_X11_reg_key[] = - "System\\CurrentControlSet\\Control\\Video\\{64498428-1122-3344-5566-778899aabbcc}\\0000"; +static BOOL get_display_device_reg_key(char *key, unsigned len) +{ + static const char display_device_guid_prop[] = "__wine_display_device_guid"; + static const char video_path[] = "System\\CurrentControlSet\\Control\\Video\\{"; + static const char display0[] = "}\\0000"; + ATOM guid_atom; + + assert(len >= sizeof(video_path) + sizeof(display0) + 40); + + guid_atom = HandleToULong(GetPropA(GetDesktopWindow(), display_device_guid_prop)); + if (!guid_atom) return FALSE; + + memcpy(key, video_path, sizeof(video_path)); + + if (!GlobalGetAtomNameA(guid_atom, key + strlen(key), 40)) + return FALSE; + + strcat(key, display0); + + TRACE("display device key %s\n", wine_dbgstr_a(key)); + return TRUE; +} static BOOL read_registry_settings(DEVMODEW *dm) { + char wine_x11_reg_key[128]; HKEY hkey; DWORD type, size; BOOL ret = TRUE; - if (RegOpenKeyA(HKEY_CURRENT_CONFIG, wine_X11_reg_key, &hkey)) + if (!get_display_device_reg_key(wine_x11_reg_key, sizeof(wine_x11_reg_key))) + return FALSE; + + if (RegOpenKeyExA(HKEY_CURRENT_CONFIG, wine_x11_reg_key, 0, KEY_READ, &hkey)) return FALSE; #define query_value(name, data) \ @@ -203,10 +227,15 @@ static BOOL read_registry_settings(DEVMODEW *dm) static BOOL write_registry_settings(const DEVMODEW *dm) { + char wine_x11_reg_key[128]; HKEY hkey; BOOL ret = TRUE; - if (RegCreateKeyA(HKEY_CURRENT_CONFIG, wine_X11_reg_key, &hkey)) + if (!get_display_device_reg_key(wine_x11_reg_key, sizeof(wine_x11_reg_key))) + return FALSE; + + if (RegCreateKeyExA(HKEY_CURRENT_CONFIG, wine_x11_reg_key, 0, NULL, + REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey, NULL)) return FALSE; #define set_value(name, data) \ diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c index e4ce6f5c15a..c01f702d51a 100644 --- a/dlls/winex11.drv/winpos.c +++ b/dlls/winex11.drv/winpos.c @@ -1454,7 +1454,13 @@ void X11DRV_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) } } else if (moved && !DragFullWindows) + { draw_moving_frame( hdc, &sizingRect, thickframe ); + /* make sure the moving frame is erased before we move the window */ + wine_tsx11_lock(); + XFlush( gdi_display ); + wine_tsx11_unlock(); + } ReleaseDC( parent, hdc ); diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c index b44c4a68325..2eef2d99748 100644 --- a/dlls/wininet/cookie.c +++ b/dlls/wininet/cookie.c @@ -454,7 +454,7 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, return FALSE; } - hostName[0] = 0; + hostName[0] = path[0] = 0; ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0])); if (!ret || !hostName[0]) return FALSE; diff --git a/dlls/winmm/mci.c b/dlls/winmm/mci.c index 44748d217ca..52d5402872f 100644 --- a/dlls/winmm/mci.c +++ b/dlls/winmm/mci.c @@ -53,7 +53,6 @@ #include "windef.h" #include "winbase.h" #include "wingdi.h" -#include "winreg.h" #include "mmsystem.h" #include "winuser.h" #include "winnls.h" diff --git a/dlls/wsock32/Makefile.in b/dlls/wsock32/Makefile.in index 0fbb83f2996..46af82bc303 100644 --- a/dlls/wsock32/Makefile.in +++ b/dlls/wsock32/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = wsock32.dll IMPORTLIB = libwsock32.$(IMPLIBEXT) -IMPORTS = ws2_32 iphlpapi kernel32 +IMPORTS = mswsock ws2_32 iphlpapi kernel32 C_SRCS = \ protocol.c \ diff --git a/dlls/wsock32/wsock32.spec b/dlls/wsock32/wsock32.spec index 620abb1c6fb..3a4b32a7e13 100644 --- a/dlls/wsock32/wsock32.spec +++ b/dlls/wsock32/wsock32.spec @@ -74,5 +74,5 @@ 1120 stdcall GetServiceW(long ptr ptr long ptr ptr ptr) #1130 stub NPLoadNameSpaces 1140 stub TransmitFile -1141 stub AcceptEx -1142 stub GetAcceptExSockaddrs +1141 stdcall AcceptEx(long long ptr long long long ptr ptr) mswsock.AcceptEx +1142 stdcall GetAcceptExSockaddrs(ptr long long long ptr ptr ptr ptr) mswsock.GetAcceptExSockaddrs diff --git a/include/Makefile.in b/include/Makefile.in index 3b08d73e6e8..e1d53dac5cf 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -204,6 +204,7 @@ SRCDIR_INCLUDES = \ ipifcons.h \ iprtrmib.h \ iptypes.h \ + isguids.h \ ks.h \ ksguid.h \ ksmedia.h \ diff --git a/include/d3dx8math.h b/include/d3dx8math.h index 930c4178c64..3e5581ebebe 100644 --- a/include/d3dx8math.h +++ b/include/d3dx8math.h @@ -263,6 +263,9 @@ typedef struct D3DXCOLOR extern "C" { #endif +D3DXCOLOR* WINAPI D3DXColorAdjustContrast(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, FLOAT s); +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation(D3DXCOLOR *pout, CONST D3DXCOLOR *pc, FLOAT s); + D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *pout, float scaling, D3DXVECTOR3 *rotationcenter, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation); FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm); D3DXMATRIX* WINAPI D3DXMatrixInverse(D3DXMATRIX *pout, FLOAT *pdeterminant, CONST D3DXMATRIX *pm); @@ -293,10 +296,18 @@ D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z); D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm); +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal(D3DXPLANE *pout, CONST D3DXVECTOR3 *pvpoint, CONST D3DXVECTOR3 *pvnormal); +D3DXPLANE* WINAPI D3DXPlaneFromPoints(D3DXPLANE *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3); D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine(D3DXVECTOR3 *pout, CONST D3DXPLANE *pp, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2); D3DXPLANE* WINAPI D3DXPlaneNormalize(D3DXPLANE *pout, CONST D3DXPLANE *pp); +D3DXPLANE* WINAPI D3DXPlaneTransform(D3DXPLANE *pout, CONST D3DXPLANE *pplane, CONST D3DXMATRIX *pm); +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, FLOAT f, FLOAT g); +D3DXQUATERNION* WINAPI D3DXQuaternionInverse(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2); D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq); +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, FLOAT t); +D3DXQUATERNION* WINAPI D3DXQuaternionSquad(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq1, CONST D3DXQUATERNION *pq2, CONST D3DXQUATERNION *pq3, CONST D3DXQUATERNION *pq4, FLOAT t); D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g); D3DXVECTOR2* WINAPI D3DXVec2CatmullRom(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv0, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT s); diff --git a/dlls/credui/credui_resources.h b/include/isguids.h similarity index 60% copy from dlls/credui/credui_resources.h copy to include/isguids.h index d7acae50779..daf56003d67 100644 --- a/dlls/credui/credui_resources.h +++ b/include/isguids.h @@ -1,5 +1,5 @@ /* - * Copyright 2007 Robert Shearman (for CodeWeavers) + * Copyright 2007 Jacek Caban for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -16,14 +16,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define IDD_CREDDIALOG 100 -#define IDC_USERNAME 101 -#define IDC_PASSWORD 102 -#define IDC_MESSAGE 103 -#define IDC_STATIC 104 -#define IDC_SAVE 105 +#ifndef _ISGUIDS_H_ +#define _ISGUIDS_H_ -#define IDB_BANNER 200 +DEFINE_GUID(CLSID_InternetShortcut, 0xfbf23b40,0xe3f0,0x101b,0x84,0x88,0x00,0xaa,0x00,0x3e,0x56,0xf8); -#define IDS_TITLEFORMAT 300 -#define IDS_MESSAGEFORMAT 301 +DEFINE_GUID(IID_IUniformResourceLocatorA, 0xfbf23b80,0xe3f0,0x101b,0x84,0x88,0x00,0xaa,0x00,0x3e,0x56,0xf8); +DEFINE_GUID(IID_IUniformResourceLocatorW, 0xcabb0da0,0xda57,0x11cf,0x99,0x74,0x00,0x20,0xaf,0xd7,0x97,0x62); +#define IID_IUniformResourceLocator WINELIB_NAME_AW(IID_IUniformResourceLocator) + +#endif diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 7d02577c9f6..43a69a61efa 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -672,6 +672,7 @@ struct get_dll_info_reply struct reply_header __header; size_t size; void* entry_point; + data_size_t filename_len; /* VARARG(filename,unicode_str); */ }; @@ -5004,6 +5005,6 @@ union generic_reply struct add_fd_completion_reply add_fd_completion_reply; }; -#define SERVER_PROTOCOL_VERSION 331 +#define SERVER_PROTOCOL_VERSION 332 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/include/winuser.h b/include/winuser.h index f3af607e748..ddd81c5b09a 100644 --- a/include/winuser.h +++ b/include/winuser.h @@ -4220,6 +4220,13 @@ typedef struct #define STATE_SYSTEM_PROTECTED 0x20000000 #define STATE_SYSTEM_VALID 0x3FFFFFFF +/* Lock codes for LockSetForegroundWindow */ +#define LSFW_LOCK 1 +#define LSFW_UNLOCK 2 + +/* Values for AllowSetForegroundWindow */ +#define ASFW_ANY ((DWORD)-1) + #define EnumTaskWindows(handle,proc,lparam) \ EnumThreadWindows(handle,proc,lparam) #define OemToAnsiA OemToCharA diff --git a/libs/port/spawn.c b/libs/port/spawn.c index 832862c3509..490abb30ac8 100644 --- a/libs/port/spawn.c +++ b/libs/port/spawn.c @@ -23,6 +23,7 @@ #include #include +#include #ifdef HAVE_SYS_WAIT_H #include #endif @@ -41,7 +42,8 @@ int spawnvp(int mode, const char *cmdname, const char *const argv[]) if (mode == _P_OVERLAY) { execvp(cmdname, (char **)argv); - return -1; /* if we get here it failed */ + /* if we get here it failed */ + if (errno != ENOTSUP) return -1; /* exec fails on MacOS if the process has multiple threads */ } dfl_act.sa_handler = SIG_DFL; @@ -58,6 +60,8 @@ int spawnvp(int mode, const char *cmdname, const char *const argv[]) _exit(1); } + if (pid != -1 && mode == _P_OVERLAY) exit(0); + if (pid != -1 && mode == _P_WAIT) { while (pid != (wret = waitpid(pid, &status, 0))) diff --git a/programs/cmd/Fr.rc b/programs/cmd/Fr.rc index 59afbabf742..4fecb39cef9 100644 --- a/programs/cmd/Fr.rc +++ b/programs/cmd/Fr.rc @@ -3,7 +3,7 @@ * French Language Support * * Copyright 2003 Sylvain Petreolle - * Copyright 2007 Jonathan Ernst + * Copyright 2007 Jonathan Ernst * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/programs/explorer/Makefile.in b/programs/explorer/Makefile.in index 3ee51f8cd06..9498a0f447d 100644 --- a/programs/explorer/Makefile.in +++ b/programs/explorer/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = explorer.exe APPMODE = -mwindows -IMPORTS = user32 gdi32 advapi32 kernel32 ntdll +IMPORTS = rpcrt4 user32 gdi32 advapi32 kernel32 ntdll DELAYIMPORTS = comctl32 EXTRADEFS = @HALINCL@ EXTRALIBS = @DISKARBITRATIONLIB@ diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index 7f2e23f0dc6..4b1d0416e5c 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -115,6 +115,25 @@ static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height return ret; } +static void initialize_display_settings( HWND desktop ) +{ + static const WCHAR display_device_guid_propW[] = { + '_','_','w','i','n','e','_','d','i','s','p','l','a','y','_', + 'd','e','v','i','c','e','_','g','u','i','d',0 }; + GUID guid; + LPWSTR guid_str; + ATOM guid_atom; + + UuidCreate( &guid ); + UuidToStringW( &guid, &guid_str ); + WINE_TRACE( "display guid %s\n", wine_dbgstr_w(guid_str) ); + + guid_atom = GlobalAddAtomW( guid_str ); + SetPropW( desktop, display_device_guid_propW, ULongToHandle(guid_atom) ); + + RpcStringFreeW( &guid_str ); +} + /* main desktop management function */ void manage_desktop( char *arg ) { @@ -171,6 +190,7 @@ void manage_desktop( char *arg ) SetWindowTextW( hwnd, desktop_nameW ); SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE ); SetDeskWallPaper( (LPSTR)-1 ); + initialize_display_settings( hwnd ); initialize_diskarbitration(); initialize_hal(); initialize_systray(); diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index ca8a34bfd3c..a5535ff38c8 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -212,6 +212,10 @@ static void modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip) { set_tooltip(icon, nid->szTip, modify_tooltip); } + if (nid->uFlags & NIF_INFO && nid->cbSize >= NOTIFYICONDATAA_V2_SIZE) + { + WINE_FIXME("balloon tip title %s, message %s\n", wine_dbgstr_w(nid->szInfoTitle), wine_dbgstr_w(nid->szInfo)); + } } static void add_icon(NOTIFYICONDATAW *nid) diff --git a/programs/winecfg/No.rc b/programs/winecfg/No.rc index bc6be435c5b..b7751bf341b 100644 --- a/programs/winecfg/No.rc +++ b/programs/winecfg/No.rc @@ -2,7 +2,7 @@ * WineCfg resources * Norwegian Bokmål Language Support * - * Copyright 2005-2006 Alexander N. Sørnes + * Copyright 2005-2007 Alexander N. Sørnes * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -46,7 +46,7 @@ STYLE WS_CHILD | WS_DISABLED FONT 8, "MS Shell Dlg" BEGIN GROUPBOX " Programminnstillinger ",IDC_STATIC, 8,4,244,240 - LTEXT "Wine kan herme etter forskjellige Windows-versjoner for hvert program. Denne fanen er koblet med bibliotek- og grafikkfanene, sånn at du kan endre innstillinger for hele systemet eller enkelte program der også.", + LTEXT "Wine kan etterligne forskjellige Windows-versjoner for hvert program. Denne fanen er koblet med bibliotek- og grafikkfanene, sånn at du kan endre innstillinger for hele systemet eller enkelte program der også.", IDC_STATIC,15,20,227,30 CONTROL "Programmer",IDC_APP_LISTVIEW,"SysListView32",WS_BORDER | WS_TABSTOP | LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS, 15,50,230,150 @@ -69,9 +69,9 @@ BEGIN LTEXT "Du kan velge å emulere et Windows-skrivebord, der alle vinduene er bundet i en virtuell skjerm, eller du kan få vinduene til å oppføre seg som andre programmer på skrivebordet.", IDC_STATIC,15,126,228,28 - LTEXT "Skrivebordsstrrelse:",IDC_DESKTOP_SIZE,15,168,44,8,WS_DISABLED + LTEXT "Størrelse:",IDC_DESKTOP_SIZE,15,168,44,8,WS_DISABLED LTEXT "X",IDC_DESKTOP_BY,108,168,8,8,WS_DISABLED - CONTROL "Emuler et virtuelt skrivebord",IDC_ENABLE_DESKTOP,"Button", + CONTROL "Vis et virtuelt skrivebord",IDC_ENABLE_DESKTOP,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,15,153,230,10 EDITTEXT IDC_DESKTOP_WIDTH,64,168,40,12,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED @@ -83,7 +83,7 @@ BEGIN COMBOBOX IDC_D3D_VSHADER_MODE,100,198,150,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Tillat piksel-skyggelegger (hvis maskinvaren støtter det)",IDC_D3D_PSHADER_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,217,230,10 - GROUPBOX " Screen Resolution ",IDC_STATIC,8,242,244,25 + GROUPBOX " Skjermoppløsning (styrer skriftstørrelse) ",IDC_STATIC,8,242,244,25 CONTROL "", IDC_RES_TRACKBAR, "msctls_trackbar32",WS_TABSTOP,12,250,187,15 EDITTEXT IDC_RES_DPIEDIT,204,250,23,13,ES_NUMBER|WS_TABSTOP LTEXT "dpi",IDC_STATIC,235,252,10,8 @@ -99,7 +99,7 @@ BEGIN LTEXT "Ny overstyring for bibliotek:",IDC_STATIC,16,58,100,8 COMBOBOX IDC_DLLCOMBO,16,68,140,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP | CBS_SORT | CBS_LOWERCASE PUSHBUTTON "&Legg til",IDC_DLLS_ADDDLL, 164,68,82,13,BS_DEFPUSHBUTTON - LTEXT "Eksisterende overstyringer:",IDC_STATIC,16,86,100,8 + LTEXT "Gjeldende overstyringer:",IDC_STATIC,16,86,100,8 LISTBOX IDC_DLLS_LIST,16,96,140,140,WS_BORDER | WS_TABSTOP | WS_VSCROLL PUSHBUTTON "R&ediger",IDC_DLLS_EDITDLL,164,96,82,14 PUSHBUTTON "Fje&rn",IDC_DLLS_REMOVEDLL,164,114,82,14 @@ -110,7 +110,7 @@ STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU CAPTION "Rediger overstyring" FONT 8, "MS Shell Dlg" BEGIN - GROUPBOX " Lastingsrekkeflge ",IDC_STATIC,8,4,94,66 + GROUPBOX " Lastingsrekkefølge ",IDC_STATIC,8,4,94,66 CONTROL "Inne&bygget (Wine)",IDC_RAD_BUILTIN,"Button", BS_AUTORADIOBUTTON | WS_GROUP,16,14,75,10 CONTROL "I&nnfødt (Windows)",IDC_RAD_NATIVE,"Button", BS_AUTORADIOBUTTON,16,24,75,10 CONTROL "&Innebygget så innfødt",IDC_RAD_BUILTIN_NATIVE,"Button", BS_AUTORADIOBUTTON,16,34,75,10 @@ -179,7 +179,7 @@ IDD_DESKTOP_INTEGRATION DIALOG DISCARDABLE 0, 0, 260, 250 STYLE WS_CHILD | WS_DISABLED FONT 8, "MS Shell Dlg" BEGIN - GROUPBOX " Appearance ",IDC_STATIC,8,4,244,106 + GROUPBOX " Utseende ",IDC_STATIC,8,4,244,106 LTEXT "Tema:",IDC_STATIC,15,16,130,8 COMBOBOX IDC_THEME_THEMECOMBO,15,24,130,14,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Installer tema . . .",IDC_THEME_INSTALL,152,23,93,14 @@ -289,8 +289,8 @@ END STRINGTABLE DISCARDABLE BEGIN - IDC_SYSPARAMS_BUTTON "Styrer bakgrunnen" - IDC_SYSPARAMS_BUTTON_TEXT "Styrer tekst" + IDC_SYSPARAMS_BUTTON "Kontrollerbakgrunn" + IDC_SYSPARAMS_BUTTON_TEXT "Kontrollertekst" IDC_SYSPARAMS_DESKTOP "Skrivebord" IDC_SYSPARAMS_MENU "Menybakgrunn" IDC_SYSPARAMS_MENU_TEXT "Menytekst" @@ -305,5 +305,5 @@ BEGIN IDC_SYSPARAMS_ACTIVE_TITLE_TEXT "Aktiv titteltekst" IDC_SYSPARAMS_INACTIVE_TITLE "Inaktiv tittellinje" IDC_SYSPARAMS_INACTIVE_TITLE_TEXT "Inaktiv titteltekst" - IDC_SYSPARAMS_MSGBOX_TEXT "Message Box Text" + IDC_SYSPARAMS_MSGBOX_TEXT "Meldingsvindutekst" END diff --git a/programs/winefile/Es.rc b/programs/winefile/Es.rc index 77b93da2646..4ad3e953948 100644 --- a/programs/winefile/Es.rc +++ b/programs/winefile/Es.rc @@ -2,7 +2,7 @@ * WineFile * Spanish Language Support * - * Copyright 2004 José Manuel Ferrer Ortiz + * Copyright 2004, 2007 José Manuel Ferrer Ortiz * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -111,7 +111,7 @@ IDM_WINEFILE MENU FIXED IMPURE #endif MENUITEM SEPARATOR MENUITEM "&Minimizar al ejecutarse", 504 - MENUITEM "&Guardar opciones al salir", 511 + MENUITEM "&Guardar opciones al salir", ID_VIEW_SAVESETTINGS } @@ -173,6 +173,59 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "&Examinar", 254, 158, 43, 47, 14 } +IDD_DIALOG_VIEW_TYPE DIALOG DISCARDABLE 15, 13, 161, 97 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Por tipo de archivo" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "&Nombre:",-1,7,8,22,10 + EDITTEXT IDC_VIEW_PATTERN,31,7,63,12,ES_AUTOHSCROLL + GROUPBOX "Tipo de archivo",-1,7,23,87,56 + CONTROL "&Directorios",IDC_VIEW_TYPE_DIRECTORIES,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,32,70,10 + CONTROL "&Programas",IDC_VIEW_TYPE_PROGRAMS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,43,70,10 + CONTROL "Docu&mentos",IDC_VIEW_TYPE_DOCUMENTS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,54,70,10 + CONTROL "&Otros archivos",IDC_VIEW_TYPE_OTHERS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,65,70,10 + CONTROL "Mostrar archivos de &sistema/ocultos",IDC_VIEW_TYPE_HIDDEN, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,81,130,9 + DEFPUSHBUTTON "Aceptar",IDOK,104,7,50,14 + PUSHBUTTON "Cancelar",IDCANCEL,104,24,50,14 +END + +IDD_DIALOG_PROPERTIES DIALOG DISCARDABLE 0, 0, 248, 215 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Propiedades de %s" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Aceptar",IDOK,191,7,50,14 + PUSHBUTTON "Cancelar",IDCANCEL,191,29,50,14 + LTEXT "Nombre:",-1,7,7,59,9 + EDITTEXT IDC_STATIC_PROP_FILENAME,71,7,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "&Ruta completa:",-1,7,18,59,9 + EDITTEXT IDC_STATIC_PROP_PATH,71,18,120,9, ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Último cambio:",-1,7,29,59,9 + EDITTEXT IDC_STATIC_PROP_LASTCHANGE,71,29,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Versión:",-1,7,40,59,9 + EDITTEXT IDC_STATIC_PROP_VERSION,71,40,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Cop&yright:",-1,7,51,59,9 + EDITTEXT IDC_STATIC_PROP_COPYRIGHT,71,51,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + LTEXT "Tamaño:",-1,7,62,59,9 + EDITTEXT IDC_STATIC_PROP_SIZE,71,62,120,9,ES_READONLY | NOT WS_BORDER | WS_TABSTOP + GROUPBOX "Atributos",-1,7,79,158,46 + CONTROL "Sólo &lectura",IDC_CHECK_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,91,68,9 + CONTROL "&Oculto",IDC_CHECK_HIDDEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,91,68,9 + CONTROL "A&rchivar",IDC_CHECK_ARCHIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,101,68,9 + CONTROL "&Sistema",IDC_CHECK_SYSTEM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,101,68,9 + CONTROL "&Comprimido",IDC_CHECK_COMPRESSED,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,17,111,68,9 + GROUPBOX "Información de &versión",-1,7,129,234,79 + LISTBOX IDC_LIST_PROP_VERSION_TYPES,13,139,107,63,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_LIST_PROP_VERSION_VALUES,123,139,111,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL +END + + STRINGTABLE { IDS_FONT_SEL_DLG_NAME "Aplicando configuración de fuente" @@ -183,7 +236,7 @@ STRINGTABLE { IDS_WINEFILE "Winefile" IDS_ERROR "Error" - IDS_ROOT_FS "sf raíz" + IDS_ROOT_FS "SF raíz" IDS_UNIXFS "unixfs" IDS_DESKTOP "Escritorio" IDS_SHELL "Shell" @@ -204,4 +257,30 @@ STRINGTABLE IDS_COL_LINKS "Enlaces" IDS_COL_ATTR "Atributos" IDS_COL_SEC "Seguridad" + + IDS_FREE_SPACE_FMT "%s de %s libre" +} + +STRINGTABLE +{ +IDS_LICENSE_CAPTION, "LICENCIA" +IDS_LICENSE, +"This library is free software; you can redistribute it and/or \ +modify it under the terms of the GNU Lesser General Public \ +License as published by the Free Software Foundation; either \ +version 2.1 of the License, or (at your option) any later version.\n\ +This library is distributed in the hope that it will be useful, \ +but WITHOUT ANY WARRANTY; without even the implied warranty of \ +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \ +Lesser General Public License for more details.\n\ +You should have received a copy of the GNU Lesser General Public \ +License along with this library; if not, write to the Free Software \ +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA" + +IDS_WARRANTY_CAPTION, "SIN GARANTÍA" +IDS_WARRANTY, +"This library is distributed in the hope that it will be useful, \ +but WITHOUT ANY WARRANTY; without even the implied warranty of \ +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \ +Lesser General Public License for more details." } diff --git a/programs/wordpad/De.rc b/programs/wordpad/De.rc index 7175fa7b3bf..079d63dadfc 100644 --- a/programs/wordpad/De.rc +++ b/programs/wordpad/De.rc @@ -18,7 +18,7 @@ LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Datei" BEGIN diff --git a/programs/wordpad/En.rc b/programs/wordpad/En.rc index a14ec7f6611..a2b26f6cdb2 100644 --- a/programs/wordpad/En.rc +++ b/programs/wordpad/En.rc @@ -18,7 +18,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&File" BEGIN diff --git a/programs/wordpad/Fr.rc b/programs/wordpad/Fr.rc index 1902a0a9b64..46928f6ea23 100644 --- a/programs/wordpad/Fr.rc +++ b/programs/wordpad/Fr.rc @@ -18,7 +18,7 @@ LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Fichier" BEGIN diff --git a/programs/wordpad/Hu.rc b/programs/wordpad/Hu.rc index 7b72a7fe549..0070d867e31 100644 --- a/programs/wordpad/Hu.rc +++ b/programs/wordpad/Hu.rc @@ -18,7 +18,7 @@ LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Fájl" BEGIN diff --git a/programs/wordpad/Ko.rc b/programs/wordpad/Ko.rc index 5e6633eadd3..9ef5d598b8b 100644 --- a/programs/wordpad/Ko.rc +++ b/programs/wordpad/Ko.rc @@ -19,7 +19,8 @@ LANGUAGE LANG_KOREAN, SUBLANG_NEUTRAL -MAINMENU MENU DISCARDABLE + +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "ÆÄÀÏ(&F)" BEGIN diff --git a/programs/wordpad/Makefile.in b/programs/wordpad/Makefile.in index 69f17216b74..2d9d7f8af10 100644 --- a/programs/wordpad/Makefile.in +++ b/programs/wordpad/Makefile.in @@ -10,6 +10,7 @@ EXTRADEFS = -DNO_LIBWINE_PORT MODCFLAGS = @BUILTINFLAG@ C_SRCS = \ + print.c \ wordpad.c RC_SRCS = rsrc.rc diff --git a/programs/wordpad/Nl.rc b/programs/wordpad/Nl.rc index 04042d8aa64..52f826ecaa4 100644 --- a/programs/wordpad/Nl.rc +++ b/programs/wordpad/Nl.rc @@ -18,7 +18,7 @@ LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Bestand" BEGIN diff --git a/programs/wordpad/No.rc b/programs/wordpad/No.rc index 0c203ed63f3..5907e44d895 100644 --- a/programs/wordpad/No.rc +++ b/programs/wordpad/No.rc @@ -18,7 +18,7 @@ LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Fil" BEGIN diff --git a/programs/wordpad/Pl.rc b/programs/wordpad/Pl.rc index 3ed7e81ca51..54384337e3e 100644 --- a/programs/wordpad/Pl.rc +++ b/programs/wordpad/Pl.rc @@ -19,7 +19,7 @@ LANGUAGE LANG_POLISH, SUBLANG_DEFAULT -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Plik" BEGIN diff --git a/programs/wordpad/Ru.rc b/programs/wordpad/Ru.rc index 3eaf4386397..5c813e94442 100644 --- a/programs/wordpad/Ru.rc +++ b/programs/wordpad/Ru.rc @@ -18,7 +18,7 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Ôàéë" BEGIN diff --git a/programs/wordpad/Tr.rc b/programs/wordpad/Tr.rc index b3463f0c0c8..60cf300e742 100644 --- a/programs/wordpad/Tr.rc +++ b/programs/wordpad/Tr.rc @@ -20,7 +20,7 @@ LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT -MAINMENU MENU DISCARDABLE +IDM_MAINMENU MENU DISCARDABLE BEGIN POPUP "&Dosya" BEGIN diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c new file mode 100644 index 00000000000..5888999e937 --- /dev/null +++ b/programs/wordpad/print.c @@ -0,0 +1,602 @@ +/* + * Wordpad implementation - Printing and print preview functions + * + * Copyright 2007 by Alexander N. Sørnes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include + +#include "wordpad.h" + +typedef struct _previewinfo +{ + int page; + int pages; + HDC hdc; + HDC hdcSized; + RECT window; + LPWSTR wszFileName; +} previewinfo, *ppreviewinfo; + +static HGLOBAL devMode; +static HGLOBAL devNames; + +static RECT margins; +static previewinfo preview; + +static const WCHAR var_pagemargin[] = {'P','a','g','e','M','a','r','g','i','n',0}; + +static LPWSTR get_print_file_filter(HWND hMainWnd) +{ + static WCHAR wszPrintFilter[MAX_STRING_LEN*2+6+4+1]; + const WCHAR files_prn[] = {'*','.','P','R','N',0}; + const WCHAR files_all[] = {'*','.','*','\0'}; + LPWSTR p; + HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE); + + p = wszPrintFilter; + LoadStringW(hInstance, STRING_PRINTER_FILES_PRN, p, MAX_STRING_LEN); + p += lstrlenW(p) + 1; + lstrcpyW(p, files_prn); + p += lstrlenW(p) + 1; + LoadStringW(hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN); + p += lstrlenW(p) + 1; + lstrcpyW(p, files_all); + p += lstrlenW(p) + 1; + *p = 0; + + return wszPrintFilter; +} + +void registry_set_pagemargins(HKEY hKey) +{ + RegSetValueExW(hKey, var_pagemargin, 0, REG_BINARY, (LPBYTE)&margins, sizeof(RECT)); +} + +void registry_read_pagemargins(HKEY hKey) +{ + DWORD size = sizeof(RECT); + + if(!hKey || RegQueryValueExW(hKey, var_pagemargin, 0, NULL, (LPBYTE)&margins, + &size) != ERROR_SUCCESS || size != sizeof(RECT)) + { + margins.top = 1417; + margins.bottom = 1417; + margins.left = 1757; + margins.right = 1757; + } +} + +static void AddTextButton(HWND hRebarWnd, int string, int command, int id) +{ + REBARBANDINFOW rb; + HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hRebarWnd, GWLP_HINSTANCE); + WCHAR text[MAX_STRING_LEN]; + HWND hButton; + + LoadStringW(hInstance, string, text, MAX_STRING_LEN); + hButton = CreateWindowW(WC_BUTTONW, text, + WS_VISIBLE | WS_CHILD, 5, 5, 100, 15, + hRebarWnd, (HMENU)command, hInstance, NULL); + + rb.cbSize = sizeof(rb); + rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; + rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; + rb.hwndChild = hButton; + rb.cyChild = rb.cyMinChild = 22; + rb.cx = rb.cxMinChild = 90; + rb.cxIdeal = 100; + rb.wID = id; + + SendMessageW(hRebarWnd, RB_INSERTBAND, -1, (LPARAM)&rb); +} + +static HDC make_dc(void) +{ + if(devNames && devMode) + { + LPDEVNAMES dn = GlobalLock(devNames); + LPDEVMODEW dm = GlobalLock(devMode); + HDC ret; + + ret = CreateDCW((LPWSTR)dn + dn->wDriverOffset, + (LPWSTR)dn + dn->wDeviceOffset, 0, dm); + + GlobalUnlock(dn); + GlobalUnlock(dm); + + return ret; + } else + { + return 0; + } +} + +static LONG twips_to_centmm(int twips) +{ + return MulDiv(twips, 1000, 567); +} + +LONG centmm_to_twips(int mm) +{ + return MulDiv(mm, 567, 1000); +} + +static LONG twips_to_pixels(int twips, int dpi) +{ + float ret = ((float)twips / ((float)567 * 2.54)) * (float)dpi; + return (LONG)ret; +} + +static LONG devunits_to_twips(int units, int dpi) +{ + float ret = ((float)units / (float)dpi) * (float)567 * 2.54; + return (LONG)ret; +} + + +static RECT get_print_rect(HDC hdc) +{ + RECT rc; + int width, height; + + if(hdc) + { + int dpiY = GetDeviceCaps(hdc, LOGPIXELSY); + int dpiX = GetDeviceCaps(hdc, LOGPIXELSX); + width = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALWIDTH), dpiX); + height = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALHEIGHT), dpiY); + } else + { + width = centmm_to_twips(18500); + height = centmm_to_twips(27000); + } + + rc.left = margins.left; + rc.right = width - margins.right; + rc.top = margins.top; + rc.bottom = height - margins.bottom; + + return rc; +} + +void target_device(HWND hMainWnd, DWORD wordWrap) +{ + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + HDC hdc = make_dc(); + int width = 0; + + if(wordWrap == ID_WORDWRAP_MARGIN) + { + RECT rc = get_print_rect(hdc); + width = rc.right; + } + + if(!hdc) + { + HDC hMaindc = GetDC(hMainWnd); + hdc = CreateCompatibleDC(hMaindc); + ReleaseDC(hMainWnd, hMaindc); + } + + SendMessageW(hEditorWnd, EM_SETTARGETDEVICE, (WPARAM)hdc, width); + + DeleteDC(hdc); +} + +static LPWSTR dialog_print_to_file(HWND hMainWnd) +{ + OPENFILENAMEW ofn; + static WCHAR file[MAX_PATH] = {'O','U','T','P','U','T','.','P','R','N',0}; + static const WCHAR defExt[] = {'P','R','N',0}; + static LPWSTR file_filter; + + if(!file_filter) + file_filter = get_print_file_filter(hMainWnd); + + ZeroMemory(&ofn, sizeof(ofn)); + + ofn.lStructSize = sizeof(ofn); + ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + ofn.hwndOwner = hMainWnd; + ofn.lpstrFilter = file_filter; + ofn.lpstrFile = (LPWSTR)file; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = (LPWSTR)defExt; + + if(GetSaveFileNameW(&ofn)) + return (LPWSTR)file; + else + return FALSE; +} + +static int get_num_pages(HWND hEditorWnd, FORMATRANGE fr) +{ + int page = 0; + + do + { + page++; + fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, + (LPARAM)&fr); + } + while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); + + return page; +} + +static void char_from_pagenum(HWND hEditorWnd, FORMATRANGE *fr, int page) +{ + int i; + + for(i = 1; i <= page; i++) + { + if(i == page) + break; + + fr->chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)fr); + } +} + +static void print(LPPRINTDLGW pd, LPWSTR wszFileName) +{ + FORMATRANGE fr; + DOCINFOW di; + HWND hEditorWnd = GetDlgItem(pd->hwndOwner, IDC_EDITOR); + int printedPages = 0; + + fr.hdc = pd->hDC; + fr.hdcTarget = pd->hDC; + + fr.rc = get_print_rect(fr.hdc); + fr.rcPage.left = 0; + fr.rcPage.right = fr.rc.right + margins.right; + fr.rcPage.top = 0; + fr.rcPage.bottom = fr.rc.bottom + margins.bottom; + + ZeroMemory(&di, sizeof(di)); + di.cbSize = sizeof(di); + di.lpszDocName = wszFileName; + + if(pd->Flags & PD_PRINTTOFILE) + { + di.lpszOutput = dialog_print_to_file(pd->hwndOwner); + if(!di.lpszOutput) + return; + } + + if(pd->Flags & PD_SELECTION) + { + SendMessageW(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&fr.chrg); + } else + { + GETTEXTLENGTHEX gt; + gt.flags = GTL_DEFAULT; + gt.codepage = 1200; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + + if(pd->Flags & PD_PAGENUMS) + char_from_pagenum(hEditorWnd, &fr, pd->nToPage); + } + + StartDocW(fr.hdc, &di); + do + { + if(StartPage(fr.hdc) <= 0) + break; + + fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); + + if(EndPage(fr.hdc) <= 0) + break; + + printedPages++; + if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage))) + break; + } + while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); + + EndDoc(fr.hdc); + SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); +} + +void dialog_printsetup(HWND hMainWnd) +{ + PAGESETUPDLGW ps; + + ZeroMemory(&ps, sizeof(ps)); + ps.lStructSize = sizeof(ps); + ps.hwndOwner = hMainWnd; + ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS; + ps.rtMargin.left = twips_to_centmm(margins.left); + ps.rtMargin.right = twips_to_centmm(margins.right); + ps.rtMargin.top = twips_to_centmm(margins.top); + ps.rtMargin.bottom = twips_to_centmm(margins.bottom); + ps.hDevMode = devMode; + ps.hDevNames = devNames; + + if(PageSetupDlgW(&ps)) + { + margins.left = centmm_to_twips(ps.rtMargin.left); + margins.right = centmm_to_twips(ps.rtMargin.right); + margins.top = centmm_to_twips(ps.rtMargin.top); + margins.bottom = centmm_to_twips(ps.rtMargin.bottom); + devMode = ps.hDevMode; + devNames = ps.hDevNames; + } +} + +void get_default_printer_opts(void) +{ + PRINTDLGW pd; + ZeroMemory(&pd, sizeof(pd)); + + ZeroMemory(&pd, sizeof(pd)); + pd.lStructSize = sizeof(pd); + pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT; + pd.hDevMode = devMode; + + PrintDlgW(&pd); + + devMode = pd.hDevMode; + devNames = pd.hDevNames; +} + +void print_quick(LPWSTR wszFileName) +{ + PRINTDLGW pd; + + ZeroMemory(&pd, sizeof(pd)); + pd.hDC = make_dc(); + + print(&pd, wszFileName); +} + +void dialog_print(HWND hMainWnd, LPWSTR wszFileName) +{ + PRINTDLGW pd; + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + int from = 0; + int to = 0; + + ZeroMemory(&pd, sizeof(pd)); + pd.lStructSize = sizeof(pd); + pd.hwndOwner = hMainWnd; + pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; + pd.nMinPage = 1; + pd.nMaxPage = -1; + pd.hDevMode = devMode; + pd.hDevNames = devNames; + + SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); + if(from == to) + pd.Flags |= PD_NOSELECTION; + + if(PrintDlgW(&pd)) + { + devMode = pd.hDevMode; + devNames = pd.hDevNames; + print(&pd, wszFileName); + } +} + +static void preview_bar_show(HWND hMainWnd, BOOL show) +{ + HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); + int i; + + if(show) + { + REBARBANDINFOW rb; + HWND hStatic; + + AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1); + AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2); + AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3); + AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN4); + + hStatic = CreateWindowW(WC_STATICW, NULL, + WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, + hReBar, NULL, NULL, NULL); + + rb.cbSize = sizeof(rb); + rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; + rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; + rb.hwndChild = hStatic; + rb.cyChild = rb.cyMinChild = 22; + rb.cx = rb.cxMinChild = 90; + rb.cxIdeal = 100; + rb.wID = BANDID_PREVIEW_BUFFER; + + SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb); + } else + { + for(i = 0; i <= PREVIEW_BUTTONS; i++) + SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0); + } +} + +void init_preview(HWND hMainWnd, LPWSTR wszFileName) +{ + preview.page = 1; + preview.hdc = 0; + preview.wszFileName = wszFileName; + preview_bar_show(hMainWnd, TRUE); +} + +void close_preview(HWND hMainWnd) +{ + preview.window.right = 0; + preview.window.bottom = 0; + preview.page = 0; + preview.pages = 0; + + preview_bar_show(hMainWnd, FALSE); +} + +BOOL preview_isactive(void) +{ + return preview.page != 0; +} + +LRESULT print_preview(HWND hMainWnd) +{ + FORMATRANGE fr; + GETTEXTLENGTHEX gt; + HDC hdc; + RECT window, background; + HBITMAP hBitmapCapture, hBitmapScaled; + int bmWidth, bmHeight, bmNewWidth, bmNewHeight; + float ratioWidth, ratioHeight, ratio; + int xOffset, yOffset; + int barheight; + HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); + PAINTSTRUCT ps; + + hdc = BeginPaint(hMainWnd, &ps); + GetClientRect(hMainWnd, &window); + + fr.hdcTarget = make_dc(); + fr.rc = get_print_rect(fr.hdcTarget); + fr.rcPage.left = 0; + fr.rcPage.top = 0; + fr.rcPage.bottom = fr.rc.bottom + margins.bottom; + fr.rcPage.right = fr.rc.right + margins.right; + + bmWidth = twips_to_pixels(fr.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX)); + bmHeight = twips_to_pixels(fr.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY)); + + hBitmapCapture = CreateCompatibleBitmap(hdc, bmWidth, bmHeight); + + if(!preview.hdc) + { + RECT paper; + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); + + preview.hdc = CreateCompatibleDC(hdc); + fr.hdc = preview.hdc; + gt.flags = GTL_DEFAULT; + gt.codepage = 1200; + fr.chrg.cpMin = 0; + fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); + + paper.left = 0; + paper.right = bmWidth; + paper.top = 0; + paper.bottom = bmHeight; + + if(!preview.pages) + preview.pages = get_num_pages(hEditorWnd, fr); + + SelectObject(preview.hdc, hBitmapCapture); + + char_from_pagenum(hEditorWnd, &fr, preview.page); + + FillRect(preview.hdc, &paper, GetStockObject(WHITE_BRUSH)); + SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); + SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); + + EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_PREVPAGE), preview.page > 1); + EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), preview.page < preview.pages); + } + + barheight = SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0); + ratioWidth = ((float)window.right - 20.0) / (float)bmHeight; + ratioHeight = ((float)window.bottom - 20.0 - (float)barheight) / (float)bmHeight; + + if(ratioWidth > ratioHeight) + ratio = ratioHeight; + else + ratio = ratioWidth; + + bmNewWidth = (int)((float)bmWidth * ratio); + bmNewHeight = (int)((float)bmHeight * ratio); + hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight); + + xOffset = ((window.right - bmNewWidth) / 2); + yOffset = ((window.bottom - bmNewHeight + barheight) / 2); + + if(window.right != preview.window.right || window.bottom != preview.window.bottom) + { + DeleteDC(preview.hdcSized), + preview.hdcSized = CreateCompatibleDC(hdc); + SelectObject(preview.hdcSized, hBitmapScaled); + + StretchBlt(preview.hdcSized, 0, 0, bmNewWidth, bmNewHeight, preview.hdc, 0, 0, bmWidth, bmHeight, SRCCOPY); + } + + window.top = barheight; + FillRect(hdc, &window, GetStockObject(GRAY_BRUSH)); + + SelectObject(hdc, hBitmapScaled); + + background.left = xOffset - 2; + background.right = xOffset + bmNewWidth + 2; + background.top = yOffset - 2; + background.bottom = yOffset + bmNewHeight + 2; + + FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); + + BitBlt(hdc, xOffset, yOffset, bmNewWidth, bmNewHeight, preview.hdcSized, 0, 0, SRCCOPY); + + DeleteDC(fr.hdcTarget); + preview.window = window; + + EndPaint(hMainWnd, &ps); + + return 0; +} + +LRESULT preview_command(HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + switch(LOWORD(wParam)) + { + case ID_FILE_EXIT: + PostMessageW(hWnd, WM_CLOSE, 0, 0); + break; + + case ID_PREVIEW_NEXTPAGE: + case ID_PREVIEW_PREVPAGE: + { + HWND hReBar = GetDlgItem(hWnd, IDC_REBAR); + RECT rc; + + if(LOWORD(wParam) == ID_PREVIEW_NEXTPAGE) + preview.page++; + else + preview.page--; + + preview.hdc = 0; + preview.window.right = 0; + + GetClientRect(hWnd, &rc); + rc.top += SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0); + InvalidateRect(hWnd, &rc, TRUE); + } + break; + + case ID_PRINT: + dialog_print(hWnd, preview.wszFileName); + SendMessageW(hWnd, WM_CLOSE, 0, 0); + break; + } + + return 0; +} diff --git a/programs/wordpad/rsrc.rc b/programs/wordpad/rsrc.rc index 37ffae76e69..00cfdd51c97 100644 --- a/programs/wordpad/rsrc.rc +++ b/programs/wordpad/rsrc.rc @@ -20,7 +20,7 @@ #include #include -#include "resource.h" +#include "wordpad.h" MAINACCELTABLE ACCELERATORS BEGIN diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index a117a756f5d..ce3e16158ed 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -22,8 +22,6 @@ #define WIN32_LEAN_AND_MEAN #define _WIN32_IE 0x0400 -#define MAX_STRING_LEN 255 - #include #include #include @@ -38,7 +36,7 @@ #include #include -#include "resource.h" +#include "wordpad.h" #ifdef NONAMELESSUNION # define U(x) (x).u @@ -52,7 +50,6 @@ /* use LoadString */ static const WCHAR xszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0}; -static const WCHAR xszMainMenu[] = {'M','A','I','N','M','E','N','U',0}; static const WCHAR wszRichEditClass[] = {'R','I','C','H','E','D','I','T','2','0','W',0}; static const WCHAR wszMainWndClass[] = {'W','O','R','D','P','A','D','T','O','P',0}; @@ -67,7 +64,6 @@ static const WCHAR key_text[] = {'T','e','x','t',0}; static const WCHAR var_file[] = {'F','i','l','e','%','d',0}; static const WCHAR var_framerect[] = {'F','r','a','m','e','R','e','c','t',0}; static const WCHAR var_barstate0[] = {'B','a','r','S','t','a','t','e','0',0}; -static const WCHAR var_pagemargin[] = {'P','a','g','e','M','a','r','g','i','n',0}; static const WCHAR stringFormat[] = {'%','2','d','\0'}; @@ -78,10 +74,13 @@ static HMENU hPopupMenu; static UINT ID_FINDMSGSTRING; +static DWORD wordWrap[2]; +static WPARAM fileFormat = SF_RTF; + +static WCHAR wszFileName[MAX_PATH]; static WCHAR wszFilter[MAX_STRING_LEN*4+6*3+5]; static WCHAR wszDefaultFileName[MAX_STRING_LEN]; static WCHAR wszSaveChanges[MAX_STRING_LEN]; -static WCHAR wszPrintFilter[MAX_STRING_LEN*2+6+4+1]; static WCHAR units_cmW[MAX_STRING_LEN]; static char units_cmA[MAX_STRING_LEN]; @@ -95,7 +94,7 @@ static void DoLoadStrings(void) static const WCHAR files_rtf[] = {'*','.','r','t','f','\0'}; static const WCHAR files_txt[] = {'*','.','t','x','t','\0'}; static const WCHAR files_all[] = {'*','.','*','\0'}; - static const WCHAR files_prn[] = {'*','.','P','R','N',0}; + HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE); LoadStringW(hInstance, STRING_RICHTEXT_FILES_RTF, p, MAX_STRING_LEN); @@ -116,17 +115,6 @@ static void DoLoadStrings(void) p += lstrlenW(p) + 1; *p = '\0'; - p = wszPrintFilter; - LoadStringW(hInstance, STRING_PRINTER_FILES_PRN, p, MAX_STRING_LEN); - p += lstrlenW(p) + 1; - lstrcpyW(p, files_prn); - p += lstrlenW(p) + 1; - LoadStringW(hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN); - p += lstrlenW(p) + 1; - lstrcpyW(p, files_all); - p += lstrlenW(p) + 1; - *p = 0; - p = wszDefaultFileName; LoadStringW(hInstance, STRING_DEFAULT_FILENAME, p, MAX_STRING_LEN); @@ -151,36 +139,6 @@ static void AddButton(HWND hwndToolBar, int nImage, int nCommand) SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button); } -static void AddTextButton(HWND hWnd, int string, int command, int id) -{ - REBARBANDINFOW rb; - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE); - static const WCHAR button[] = {'B','U','T','T','O','N',0}; - WCHAR text[MAX_STRING_LEN]; - HWND hButton; - RECT rc; - - LoadStringW(hInstance, string, text, MAX_STRING_LEN); - hButton = CreateWindowW(button, text, - WS_VISIBLE | WS_CHILD, 5, 5, 100, 15, - hMainWnd, (HMENU)command, hInstance, NULL); - - rb.cbSize = sizeof(rb); - rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; - rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; - rb.hwndChild = hButton; - rb.cyChild = rb.cyMinChild = 22; - rb.cx = rb.cxMinChild = 90; - rb.cxIdeal = 100; - rb.wID = id; - - rc.bottom = 22; - rc.right = 90; - - SendMessageW(hWnd, RB_INSERTBAND, -1, (LPARAM)&rb); - SetWindowPos(hButton, 0, 0, 0, 90, 22, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); -} - static void AddSeparator(HWND hwndToolBar) { TBBUTTON button; @@ -241,9 +199,6 @@ static LPWSTR file_basename(LPWSTR path) return pos; } -static WCHAR wszFileName[MAX_PATH]; -static WPARAM fileFormat = SF_RTF; - static void set_caption(LPCWSTR wszNewFileName) { static const WCHAR wszSeparator[] = {' ','-',' '}; @@ -313,8 +268,6 @@ static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey) return ret; } -static RECT margins; - static void registry_set_options(void) { HKEY hKey; @@ -328,7 +281,7 @@ static void registry_set_options(void) RegSetValueExW(hKey, var_framerect, 0, REG_BINARY, (LPBYTE)&rc, sizeof(RECT)); - RegSetValueExW(hKey, var_pagemargin, 0, REG_BINARY, (LPBYTE)&margins, sizeof(RECT)); + registry_set_pagemargins(hKey); } } @@ -892,7 +845,6 @@ static void update_window(void) } static DWORD barState[2]; -static DWORD wordWrap[2]; static BOOL is_bar_visible(int bandId) { @@ -956,99 +908,21 @@ static void set_bar_states(void) update_window(); } -static HGLOBAL devMode; -static HGLOBAL devNames; - -static HDC make_dc(void) -{ - if(devNames && devMode) - { - LPDEVNAMES dn = GlobalLock(devNames); - LPDEVMODEW dm = GlobalLock(devMode); - HDC ret; - - ret = CreateDCW((LPWSTR)dn + dn->wDriverOffset, - (LPWSTR)dn + dn->wDeviceOffset, 0, dm); - - GlobalUnlock(dn); - GlobalUnlock(dm); - - return ret; - } else - { - return 0; - } -} - -static LONG twips_to_pixels(int twips, int dpi) -{ - float ret = ((float)twips / ((float)567 * 2.54)) * (float)dpi; - return (LONG)ret; -} - -static LONG devunits_to_twips(int units, int dpi) -{ - float ret = ((float)units / (float)dpi) * (float)567 * 2.54; - return (LONG)ret; -} - -static LONG centmm_to_twips(int mm) -{ - return MulDiv(mm, 567, 1000); -} - -static LONG twips_to_centmm(int twips) -{ - return MulDiv(twips, 1000, 567); -} - -static RECT get_print_rect(HDC hdc) -{ - RECT rc; - int width, height; - - if(hdc) - { - int dpiY = GetDeviceCaps(hdc, LOGPIXELSY); - int dpiX = GetDeviceCaps(hdc, LOGPIXELSX); - width = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALWIDTH), dpiX); - height = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALHEIGHT), dpiY); - } else - { - width = centmm_to_twips(18500); - height = centmm_to_twips(27000); - } - - rc.left = margins.left; - rc.right = width - margins.right; - rc.top = margins.top; - rc.bottom = height - margins.bottom; - - return rc; -} - -static void target_device(void) +static void preview_exit(HWND hMainWnd) { - HDC hdc = make_dc(); - int width = 0; - int index = reg_formatindex(fileFormat); + HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE); + HMENU hMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_MAINMENU)); + HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR); - if(wordWrap[index] == ID_WORDWRAP_MARGIN) - { - RECT rc = get_print_rect(hdc); - width = rc.right; - } + set_bar_states(); + ShowWindow(hEditorWnd, TRUE); - if(!hdc) - { - HDC hMaindc = GetDC(hMainWnd); - hdc = CreateCompatibleDC(hMaindc); - ReleaseDC(hMainWnd, hMaindc); - } + close_preview(hMainWnd); - SendMessageW(hEditorWnd, EM_SETTARGETDEVICE, (WPARAM)hdc, width); + SetMenu(hMainWnd, hMenu); + registry_read_filelist(hMainWnd); - DeleteDC(hdc); + update_window(); } static void set_fileformat(WPARAM format) @@ -1066,7 +940,7 @@ static void set_fileformat(WPARAM format) set_bar_states(); set_default_font(); - target_device(); + target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); } static void DoOpenFile(LPCWSTR szOpenFileName) @@ -1290,406 +1164,6 @@ static void DialogOpenFile(void) } } -static LPWSTR dialog_print_to_file(void) -{ - OPENFILENAMEW ofn; - static WCHAR file[MAX_PATH] = {'O','U','T','P','U','T','.','P','R','N',0}; - static const WCHAR defExt[] = {'P','R','N',0}; - - ZeroMemory(&ofn, sizeof(ofn)); - - ofn.lStructSize = sizeof(ofn); - ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - ofn.hwndOwner = hMainWnd; - ofn.lpstrFilter = (LPWSTR)wszPrintFilter; - ofn.lpstrFile = (LPWSTR)file; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = (LPWSTR)defExt; - - if(GetSaveFileNameW(&ofn)) - return (LPWSTR)file; - else - return FALSE; -} - -static int get_num_pages(FORMATRANGE fr) -{ - int page = 0; - - do - { - page++; - fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, - (LPARAM)&fr); - } - while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); - - return page; -} - -static void char_from_pagenum(FORMATRANGE *fr, int page) -{ - int i; - - for(i = 1; i <= page; i++) - { - if(i == page) - break; - - fr->chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)fr); - } -} - -static void print(LPPRINTDLGW pd) -{ - FORMATRANGE fr; - DOCINFOW di; - int printedPages = 0; - - fr.hdc = pd->hDC; - fr.hdcTarget = pd->hDC; - - fr.rc = get_print_rect(fr.hdc); - fr.rcPage.left = 0; - fr.rcPage.right = fr.rc.right + margins.right; - fr.rcPage.top = 0; - fr.rcPage.bottom = fr.rc.bottom + margins.bottom; - - ZeroMemory(&di, sizeof(di)); - di.cbSize = sizeof(di); - di.lpszDocName = (LPWSTR)wszFileName; - - if(pd->Flags & PD_PRINTTOFILE) - { - di.lpszOutput = dialog_print_to_file(); - if(!di.lpszOutput) - return; - } - - if(pd->Flags & PD_SELECTION) - { - SendMessageW(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&fr.chrg); - } else - { - GETTEXTLENGTHEX gt; - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - - if(pd->Flags & PD_PAGENUMS) - char_from_pagenum(&fr, pd->nToPage); - } - - StartDocW(fr.hdc, &di); - do - { - if(StartPage(fr.hdc) <= 0) - break; - - fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); - - if(EndPage(fr.hdc) <= 0) - break; - - printedPages++; - if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage))) - break; - } - while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax); - - EndDoc(fr.hdc); - SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); - target_device(); -} - -static void dialog_printsetup(void) -{ - PAGESETUPDLGW ps; - - ZeroMemory(&ps, sizeof(ps)); - ps.lStructSize = sizeof(ps); - ps.hwndOwner = hMainWnd; - ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS; - ps.rtMargin.left = twips_to_centmm(margins.left); - ps.rtMargin.right = twips_to_centmm(margins.right); - ps.rtMargin.top = twips_to_centmm(margins.top); - ps.rtMargin.bottom = twips_to_centmm(margins.bottom); - ps.hDevMode = devMode; - ps.hDevNames = devNames; - - if(PageSetupDlgW(&ps)) - { - margins.left = centmm_to_twips(ps.rtMargin.left); - margins.right = centmm_to_twips(ps.rtMargin.right); - margins.top = centmm_to_twips(ps.rtMargin.top); - margins.bottom = centmm_to_twips(ps.rtMargin.bottom); - devMode = ps.hDevMode; - devNames = ps.hDevNames; - target_device(); - } -} - -static void get_default_printer_opts(void) -{ - PRINTDLGW pd; - ZeroMemory(&pd, sizeof(pd)); - - ZeroMemory(&pd, sizeof(pd)); - pd.lStructSize = sizeof(pd); - pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT; - pd.hwndOwner = hMainWnd; - pd.hDevMode = devMode; - - PrintDlgW(&pd); - - devMode = pd.hDevMode; - devNames = pd.hDevNames; -} - -static void print_quick(void) -{ - PRINTDLGW pd; - - ZeroMemory(&pd, sizeof(pd)); - pd.hDC = make_dc(); - - print(&pd); -} - -static void dialog_print(void) -{ - PRINTDLGW pd; - int from = 0; - int to = 0; - - ZeroMemory(&pd, sizeof(pd)); - pd.lStructSize = sizeof(pd); - pd.hwndOwner = hMainWnd; - pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE; - pd.nMinPage = 1; - pd.nMaxPage = -1; - pd.hDevMode = devMode; - pd.hDevNames = devNames; - - SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to); - if(from == to) - pd.Flags |= PD_NOSELECTION; - - if(PrintDlgW(&pd)) - { - devMode = pd.hDevMode; - devNames = pd.hDevNames; - print(&pd); - } -} - -typedef struct _previewinfo -{ - int page; - int pages; - HDC hdc; - HDC hdcSized; - RECT window; -} previewinfo, *ppreviewinfo; - -static previewinfo preview; - -static void preview_bar_show(BOOL show) -{ - HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); - int i; - - if(show) - { - REBARBANDINFOW rb; - - AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1); - AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2); - AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3); - AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN4); - - rb.cbSize = sizeof(rb); - rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID; - rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT; - rb.cyChild = rb.cyMinChild = 22; - rb.cx = rb.cxMinChild = 90; - rb.cxIdeal = 100; - rb.wID = BANDID_PREVIEW_BUFFER; - - SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb); - } else - { - for(i = 0; i <= PREVIEW_BUTTONS; i++) - SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0); - } -} - -static void preview_exit(void) -{ - HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE); - HMENU hMenu = LoadMenuW(hInstance, xszMainMenu); - - set_bar_states(); - preview.window.right = 0; - preview.window.bottom = 0; - preview.page = 0; - preview.pages = 0; - ShowWindow(hEditorWnd, TRUE); - - preview_bar_show(FALSE); - - SetMenu(hMainWnd, hMenu); - registry_read_filelist(hMainWnd); - - update_window(); -} - -static LRESULT print_preview(void) -{ - FORMATRANGE fr; - GETTEXTLENGTHEX gt; - HDC hdc; - RECT window, background; - HBITMAP hBitmapCapture, hBitmapScaled; - int bmWidth, bmHeight, bmNewWidth, bmNewHeight; - float ratioWidth, ratioHeight, ratio; - int xOffset, yOffset; - int barheight; - HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); - PAINTSTRUCT ps; - - hdc = BeginPaint(hMainWnd, &ps); - GetClientRect(hMainWnd, &window); - - fr.hdcTarget = make_dc(); - fr.rc = get_print_rect(fr.hdcTarget); - fr.rcPage.left = 0; - fr.rcPage.top = 0; - fr.rcPage.bottom = fr.rc.bottom + margins.bottom; - fr.rcPage.right = fr.rc.right + margins.right; - - bmWidth = twips_to_pixels(fr.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX)); - bmHeight = twips_to_pixels(fr.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY)); - - hBitmapCapture = CreateCompatibleBitmap(hdc, bmWidth, bmHeight); - - if(!preview.hdc) - { - RECT paper; - - preview.hdc = CreateCompatibleDC(hdc); - fr.hdc = preview.hdc; - gt.flags = GTL_DEFAULT; - gt.codepage = 1200; - fr.chrg.cpMin = 0; - fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0); - - paper.left = 0; - paper.right = bmWidth; - paper.top = 0; - paper.bottom = bmHeight; - - if(!preview.pages) - preview.pages = get_num_pages(fr); - - SelectObject(preview.hdc, hBitmapCapture); - - char_from_pagenum(&fr, preview.page); - - FillRect(preview.hdc, &paper, GetStockObject(WHITE_BRUSH)); - SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr); - SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0); - - EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_PREVPAGE), preview.page > 1); - EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), preview.page < preview.pages); - } - - barheight = SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0); - ratioWidth = ((float)window.right - 20.0) / (float)bmHeight; - ratioHeight = ((float)window.bottom - 20.0 - (float)barheight) / (float)bmHeight; - - if(ratioWidth > ratioHeight) - ratio = ratioHeight; - else - ratio = ratioWidth; - - bmNewWidth = (int)((float)bmWidth * ratio); - bmNewHeight = (int)((float)bmHeight * ratio); - hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight); - - xOffset = ((window.right - bmNewWidth) / 2); - yOffset = ((window.bottom - bmNewHeight + barheight) / 2); - - if(window.right != preview.window.right || window.bottom != preview.window.bottom) - { - DeleteDC(preview.hdcSized), - preview.hdcSized = CreateCompatibleDC(hdc); - SelectObject(preview.hdcSized, hBitmapScaled); - - StretchBlt(preview.hdcSized, 0, 0, bmNewWidth, bmNewHeight, preview.hdc, 0, 0, bmWidth, bmHeight, SRCCOPY); - } - - window.top = barheight; - FillRect(hdc, &window, GetStockObject(GRAY_BRUSH)); - - SelectObject(hdc, hBitmapScaled); - - background.left = xOffset - 2; - background.right = xOffset + bmNewWidth + 2; - background.top = yOffset - 2; - background.bottom = yOffset + bmNewHeight + 2; - - FillRect(hdc, &background, GetStockObject(BLACK_BRUSH)); - - BitBlt(hdc, xOffset, yOffset, bmNewWidth, bmNewHeight, preview.hdcSized, 0, 0, SRCCOPY); - - DeleteDC(fr.hdcTarget); - preview.window = window; - - EndPaint(hMainWnd, &ps); - - return 0; -} - -static LRESULT preview_command(HWND hWnd, WPARAM wParam, LPARAM lParam) -{ - switch(LOWORD(wParam)) - { - case ID_FILE_EXIT: - PostMessageW(hMainWnd, WM_CLOSE, 0, 0); - break; - - case ID_PREVIEW_NEXTPAGE: - case ID_PREVIEW_PREVPAGE: - { - HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR); - RECT rc; - - if(LOWORD(wParam) == ID_PREVIEW_NEXTPAGE) - preview.page++; - else - preview.page--; - - preview.hdc = 0; - preview.window.right = 0; - - GetClientRect(hMainWnd, &rc); - rc.top += SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0); - InvalidateRect(hMainWnd, &rc, TRUE); - } - break; - - case ID_PRINT: - dialog_print(); - preview_exit(); - break; - } - - return 0; -} - - static void dialog_about(void) { HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE); @@ -1825,7 +1299,7 @@ static void dialog_viewproperties(void) U2(psh).nStartPage = 0; PropertySheetW(&psh); set_bar_states(); - target_device(); + target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); } static void HandleCommandLine(LPWSTR cmdline) @@ -1994,17 +1468,11 @@ static void dialog_find(LPFINDREPLACEW fr, BOOL replace) static void registry_read_options(void) { HKEY hKey; - DWORD size = sizeof(RECT); - if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS || - RegQueryValueExW(hKey, var_pagemargin, 0, NULL, (LPBYTE)&margins, - &size) != ERROR_SUCCESS || size != sizeof(RECT)) - { - margins.top = 1417; - margins.bottom = 1417; - margins.left = 1757; - margins.right = 1757; - } + if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS) + registry_read_pagemargins(NULL); + else + registry_read_pagemargins(hKey); RegCloseKey(hKey); } @@ -2784,11 +2252,13 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) break; case ID_PRINT: - dialog_print(); + dialog_print(hWnd, wszFileName); + target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); break; case ID_PRINT_QUICK: - print_quick(); + print_quick(wszFileName); + target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); break; case ID_PREVIEW: @@ -2799,17 +2269,17 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) set_bar_states(); barState[index] = tmp; ShowWindow(hEditorWnd, FALSE); - preview_bar_show(TRUE); - preview.page = 1; - preview.hdc = 0; + init_preview(hWnd, wszFileName); + SetMenu(hWnd, NULL); InvalidateRect(0, 0, TRUE); } break; case ID_PRINTSETUP: - dialog_printsetup(); + dialog_printsetup(hWnd); + target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); break; case ID_FORMAT_BOLD: @@ -3178,19 +2648,21 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara return OnNotify( hWnd, wParam, lParam ); case WM_COMMAND: - if(preview.page) + if(preview_isactive()) + { return preview_command( hWnd, wParam, lParam ); - else - return OnCommand( hWnd, wParam, lParam ); + } + + return OnCommand( hWnd, wParam, lParam ); case WM_DESTROY: PostQuitMessage(0); break; case WM_CLOSE: - if(preview.page) + if(preview_isactive()) { - preview_exit(); + preview_exit(hWnd); } else if(prompt_save_changes()) { registry_set_options(); @@ -3227,8 +2699,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara } break; case WM_PAINT: - if(preview.page) - return print_preview(); + if(preview_isactive()) + return print_preview(hWnd); else return DefWindowProcW(hWnd, msg, wParam, lParam); @@ -3261,7 +2733,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar wc.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_WORDPAD)); wc.hCursor = LoadCursor(NULL, IDC_IBEAM); wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW); - wc.lpszMenuName = xszMainMenu; + wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MAINMENU); wc.lpszClassName = wszMainWndClass; RegisterClassW(&wc); @@ -3275,7 +2747,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar set_fileformat(SF_RTF); hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP)); get_default_printer_opts(); - target_device(); + target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]); HandleCommandLine(GetCommandLineW()); diff --git a/programs/wordpad/resource.h b/programs/wordpad/wordpad.h similarity index 90% rename from programs/wordpad/resource.h rename to programs/wordpad/wordpad.h index 130eb94b47c..fd694560617 100644 --- a/programs/wordpad/resource.h +++ b/programs/wordpad/wordpad.h @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#define MAX_STRING_LEN 255 + #define ID_FILE_EXIT 1000 #define ID_FILE_OPEN 1001 #define ID_FILE_SAVE 1002 @@ -138,7 +140,8 @@ #define IDD_TABSTOPS 2103 #define IDD_FORMATOPTS 2104 -#define IDM_POPUP 2200 +#define IDM_MAINMENU 2200 +#define IDM_POPUP 2201 #define IDB_TOOLBAR 100 #define IDB_FORMATBAR 101 @@ -181,3 +184,16 @@ #define STRING_SAVE_LOSEFORMATTING 1704 #define STRING_INVALID_NUMBER 1705 #define STRING_OLE_STORAGE_NOT_SUPPORTED 1706 + +void dialog_printsetup(HWND); +void dialog_print(HWND, LPWSTR); +void target_device(HWND, DWORD); +void print_quick(LPWSTR); +LRESULT preview_command(HWND, WPARAM, LPARAM); +void init_preview(HWND, LPWSTR); +void close_preview(HWND); +BOOL preview_isactive(void); +LRESULT print_preview(HWND); +void get_default_printer_opts(void); +void registry_set_pagemargins(HKEY); +void registry_read_pagemargins(HKEY); diff --git a/server/file.c b/server/file.c index 7f34c02b6ec..ad98d2129bd 100644 --- a/server/file.c +++ b/server/file.c @@ -299,6 +299,7 @@ static struct security_descriptor *file_get_sd( struct object *obj ) const SID *user; const SID *group; size_t dacl_size; + ACE_HEADER *current_ace; ACCESS_ALLOWED_ACE *aaa; ACL *dacl; SID *sid; @@ -328,6 +329,11 @@ static struct security_descriptor *file_get_sd( struct object *obj ) if (st.st_mode & S_IRWXU) dacl_size += FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + FIELD_OFFSET(SID, SubAuthority[user->SubAuthorityCount]); + if ((!(st.st_mode & S_IRUSR) && (st.st_mode & (S_IRGRP|S_IROTH))) || + (!(st.st_mode & S_IWUSR) && (st.st_mode & (S_IWGRP|S_IWOTH))) || + (!(st.st_mode & S_IXUSR) && (st.st_mode & (S_IXGRP|S_IXOTH)))) + dacl_size += FIELD_OFFSET(ACCESS_DENIED_ACE, SidStart) + + FIELD_OFFSET(SID, SubAuthority[user->SubAuthorityCount]); if (st.st_mode & S_IRWXO) dacl_size += FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + FIELD_OFFSET(SID, SubAuthority[world_sid->SubAuthorityCount]); @@ -355,10 +361,15 @@ static struct security_descriptor *file_get_sd( struct object *obj ) dacl->Sbz1 = 0; dacl->AclSize = dacl_size; dacl->AceCount = 1 + (st.st_mode & S_IRWXU ? 1 : 0) + (st.st_mode & S_IRWXO ? 1 : 0); + if ((!(st.st_mode & S_IRUSR) && (st.st_mode & (S_IRGRP|S_IROTH))) || + (!(st.st_mode & S_IWUSR) && (st.st_mode & (S_IWGRP|S_IWOTH))) || + (!(st.st_mode & S_IXUSR) && (st.st_mode & (S_IXGRP|S_IXOTH)))) + dacl->AceCount++; dacl->Sbz2 = 0; /* always give FILE_ALL_ACCESS for Local System */ aaa = (ACCESS_ALLOWED_ACE *)(dacl + 1); + current_ace = &aaa->Header; aaa->Header.AceType = ACCESS_ALLOWED_ACE_TYPE; aaa->Header.AceFlags = 0; aaa->Header.AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + @@ -370,7 +381,8 @@ static struct security_descriptor *file_get_sd( struct object *obj ) if (st.st_mode & S_IRWXU) { /* appropriate access rights for the user */ - aaa = (ACCESS_ALLOWED_ACE *)ace_next( &aaa->Header ); + aaa = (ACCESS_ALLOWED_ACE *)ace_next( current_ace ); + current_ace = &aaa->Header; aaa->Header.AceType = ACCESS_ALLOWED_ACE_TYPE; aaa->Header.AceFlags = 0; aaa->Header.AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + @@ -385,10 +397,33 @@ static struct security_descriptor *file_get_sd( struct object *obj ) sid = (SID *)&aaa->SidStart; memcpy( sid, user, FIELD_OFFSET(SID, SubAuthority[user->SubAuthorityCount]) ); } + if ((!(st.st_mode & S_IRUSR) && (st.st_mode & (S_IRGRP|S_IROTH))) || + (!(st.st_mode & S_IWUSR) && (st.st_mode & (S_IWGRP|S_IWOTH))) || + (!(st.st_mode & S_IXUSR) && (st.st_mode & (S_IXGRP|S_IXOTH)))) + { + /* deny just in case the user is a member of the group */ + ACCESS_DENIED_ACE *ada = (ACCESS_DENIED_ACE *)ace_next( current_ace ); + current_ace = &ada->Header; + ada->Header.AceType = ACCESS_DENIED_ACE_TYPE; + ada->Header.AceFlags = 0; + ada->Header.AceSize = FIELD_OFFSET(ACCESS_DENIED_ACE, SidStart) + + FIELD_OFFSET(SID, SubAuthority[user->SubAuthorityCount]); + ada->Mask = 0; + if (!(st.st_mode & S_IRUSR) && (st.st_mode & (S_IRGRP|S_IROTH))) + ada->Mask |= FILE_GENERIC_READ; + if (!(st.st_mode & S_IWUSR) && (st.st_mode & (S_IWGRP|S_IROTH))) + ada->Mask |= FILE_GENERIC_WRITE | DELETE; + if (!(st.st_mode & S_IXUSR) && (st.st_mode & (S_IXGRP|S_IXOTH))) + ada->Mask |= FILE_GENERIC_EXECUTE; + ada->Mask &= ~STANDARD_RIGHTS_ALL; /* never deny standard rights */ + sid = (SID *)&ada->SidStart; + memcpy( sid, user, FIELD_OFFSET(SID, SubAuthority[user->SubAuthorityCount]) ); + } if (st.st_mode & S_IRWXO) { /* appropriate access rights for Everyone */ - aaa = (ACCESS_ALLOWED_ACE *)ace_next( &aaa->Header ); + aaa = (ACCESS_ALLOWED_ACE *)ace_next( current_ace ); + current_ace = &aaa->Header; aaa->Header.AceType = ACCESS_ALLOWED_ACE_TYPE; aaa->Header.AceFlags = 0; aaa->Header.AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + @@ -421,7 +456,7 @@ static mode_t sd_to_mode( const struct security_descriptor *sd, const SID *owner { const ACE_HEADER *ace = (const ACE_HEADER *)(dacl + 1); ULONG i; - for (i = 0; i < dacl->AceCount; i++, ace_next( ace )) + for (i = 0; i < dacl->AceCount; i++, ace = ace_next( ace )) { const ACCESS_ALLOWED_ACE *aa_ace; const ACCESS_DENIED_ACE *ad_ace; @@ -438,11 +473,11 @@ static mode_t sd_to_mode( const struct security_descriptor *sd, const SID *owner { unsigned int access = generic_file_map_access( ad_ace->Mask ); if (access & FILE_READ_DATA) - denied_mode |= S_IROTH; + denied_mode |= S_IRUSR|S_IRGRP|S_IROTH; if (access & FILE_WRITE_DATA) - denied_mode |= S_IWOTH; + denied_mode |= S_IWUSR|S_IWGRP|S_IWOTH; if (access & FILE_EXECUTE) - denied_mode |= S_IXOTH; + denied_mode |= S_IXUSR|S_IXGRP|S_IXOTH; } else if (security_equal_sid( sid, owner )) { @@ -462,11 +497,11 @@ static mode_t sd_to_mode( const struct security_descriptor *sd, const SID *owner { unsigned int access = generic_file_map_access( aa_ace->Mask ); if (access & FILE_READ_DATA) - new_mode |= S_IROTH; + new_mode |= S_IRUSR|S_IRGRP|S_IROTH; if (access & FILE_WRITE_DATA) - new_mode |= S_IWOTH; + new_mode |= S_IWUSR|S_IWGRP|S_IWOTH; if (access & FILE_EXECUTE) - new_mode |= S_IXOTH; + new_mode |= S_IXUSR|S_IXGRP|S_IXOTH; } else if (security_equal_sid( sid, owner )) { diff --git a/server/process.c b/server/process.c index 4f54da26d00..2350e7b9ec9 100644 --- a/server/process.c +++ b/server/process.c @@ -1130,16 +1130,25 @@ DECL_HANDLER(get_dll_info) if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION ))) { - struct process_dll *dll = find_process_dll( process, req->base_address ); + struct process_dll *dll; + + if (req->base_address) + dll = find_process_dll( process, req->base_address ); + else /* NULL means main module */ + dll = list_head( &process->dlls ) ? + LIST_ENTRY(list_head( &process->dlls ), struct process_dll, entry) : NULL; if (dll) { reply->size = dll->size; reply->entry_point = NULL; /* FIXME */ + reply->filename_len = dll->namelen; if (dll->filename) { - data_size_t len = min( dll->namelen, get_reply_max_size() ); - set_reply_data( dll->filename, len ); + if (dll->namelen <= get_reply_max_size()) + set_reply_data( dll->filename, dll->namelen ); + else + set_error( STATUS_BUFFER_TOO_SMALL ); } } else diff --git a/server/protocol.def b/server/protocol.def index 7e106d4cb9a..7faed3d1e6c 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -620,6 +620,7 @@ typedef union @REPLY size_t size; /* module size */ void* entry_point; + data_size_t filename_len; /* buffer len in bytes required to store filename */ VARARG(filename,unicode_str); /* file name of module */ @END diff --git a/server/trace.c b/server/trace.c index 941da58c542..84be7eac080 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1004,6 +1004,7 @@ static void dump_get_dll_info_reply( const struct get_dll_info_reply *req ) { fprintf( stderr, " size=%lu,", (unsigned long)req->size ); fprintf( stderr, " entry_point=%p,", req->entry_point ); + fprintf( stderr, " filename_len=%u,", req->filename_len ); fprintf( stderr, " filename=" ); dump_varargs_unicode_str( cur_size ); } diff --git a/tools/widl/server.c b/tools/widl/server.c index a52c7297c35..c9156626963 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -37,7 +37,6 @@ #include "header.h" #include "windef.h" -#include "widl.h" #include "typelib.h" #include "typelib_struct.h" #include "typegen.h" diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index bb75a0a62a6..1078ede0dc4 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -40,7 +40,6 @@ #include "windef.h" #include "wine/list.h" -#include "widl.h" #include "typegen.h" static const func_t *current_func; diff --git a/tools/widl/utils.c b/tools/widl/utils.c index 7dafc10635d..e77361ce339 100644 --- a/tools/widl/utils.c +++ b/tools/widl/utils.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "widl.h" diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c index b0109a7f145..35811bb06ee 100644 --- a/tools/wrc/utils.c +++ b/tools/wrc/utils.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "wine/unicode.h" -- 2.11.4.GIT