From 24a16c0037fd7c0f0d15c6980e4cc77ea642e89e Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Mon, 9 Sep 2019 14:57:45 +0800 Subject: [PATCH] localspl: Fix MONITOR2.cbSize calculation when converting from MONITOREX. Signed-off-by: Dmitry Timoshkov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/localspl/localmon.c | 2 +- dlls/localspl/provider.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/localspl/localmon.c b/dlls/localspl/localmon.c index 6937e050cdb..e634a332536 100644 --- a/dlls/localspl/localmon.c +++ b/dlls/localspl/localmon.c @@ -777,7 +777,7 @@ LPMONITOREX WINAPI InitializePrintMonitor(LPWSTR regroot) { static MONITOREX mymonitorex = { - sizeof(MONITOREX) - sizeof(DWORD), + sizeof(MONITOR), { localmon_EnumPortsW, localmon_OpenPortW, diff --git a/dlls/localspl/provider.c b/dlls/localspl/provider.c index 4627284f129..7a12751f17f 100644 --- a/dlls/localspl/provider.c +++ b/dlls/localspl/provider.c @@ -504,7 +504,9 @@ static monitor_t * monitor_load(LPCWSTR name, LPWSTR dllname) if (pmonitorEx) { /* Layout of MONITOREX and MONITOR2 mostly matches */ - memcpy(&pm->monitor, pmonitorEx, min(pmonitorEx->dwMonitorSize + sizeof(DWORD), sizeof(pm->monitor))); + memcpy(&pm->monitor, pmonitorEx, min(pmonitorEx->dwMonitorSize + sizeof(void *), sizeof(pm->monitor))); + /* MONITOREX.dwMonitorSize doesn't include the size field, while MONITOR2.cbSize does */ + pm->monitor.cbSize += sizeof(void *); pm->old_XcvOpenPort = pmonitorEx->Monitor.pfnXcvOpenPort; pm->monitor.pfnXcvOpenPort = NULL; }