From bb803c1aadd0dfb3fbaec99f3c12b571ad866b76 Mon Sep 17 00:00:00 2001 From: Ethan Rodensky Date: Sun, 22 Oct 2023 13:46:43 -0400 Subject: [PATCH 01/33] Accuracy improvements --- dll/cpl/desk/theme.c | 3 ++ dll/win32/uxtheme/nonclient.c | 76 ++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/dll/cpl/desk/theme.c b/dll/cpl/desk/theme.c index 788c16c16e1..8c9f9faa8e4 100644 --- a/dll/cpl/desk/theme.c +++ b/dll/cpl/desk/theme.c @@ -997,6 +997,9 @@ DrawThemePreview(IN HDC hdcMem, IN PCOLOR_SCHEME scheme, IN PTHEME_SELECTION pSe FillRect(hdcMem, prcWindow, hbrBack); DeleteObject(hbrBack); + InflateRect(prcWindow, -8, -8); + prcWindow->bottom -= 12; + hres = DrawNCPreview(hdcMem, DNCP_DRAW_ALL, prcWindow, diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c index c39b7778b4b..897276b4888 100644 --- a/dll/win32/uxtheme/nonclient.c +++ b/dll/win32/uxtheme/nonclient.c @@ -1096,9 +1096,9 @@ DrawWindowForNCPreview( return; DWORD dwStyle = pcontext->wi.dwStyle; - + DWORD dwExStyle = pcontext->wi.dwExStyle; pcontext->CaptionHeight = GetThemeSysSize(pcontext->theme, - pcontext->wi.dwExStyle & WS_EX_TOOLWINDOW + dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMSIZE : SM_CYSIZE ) + pcontext->wi.cyWindowBorders @@ -1200,8 +1200,11 @@ DrawWindowForNCPreview( SelectObject(hDC, pen); OffsetRect(&rcClientNew, -pcontext->wi.rcWindow.left, -pcontext->wi.rcWindow.top); - rcClientNew.right++; - rcClientNew.bottom++; + if (!(dwExStyle & WS_EX_DLGMODALFRAME)) + { + rcClientNew.right++; + rcClientNew.bottom++; + } pcontext->wi.rcClient = rcClientNew; if (drawClientAreaColor) Rectangle(hDC, rcClientNew.left, rcClientNew.top, rcClientNew.right, rcClientNew.bottom); @@ -1269,15 +1272,18 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, context.wi.dwStyle |= WS_VISIBLE; context.hRgn = CreateRectRgnIndirect(&context.wi.rcWindow); + RECT rcAdjPreview = { prcPreview->left, prcPreview->top, prcPreview->right, prcPreview->bottom }; + INT previewWidth = rcAdjPreview.right - rcAdjPreview.left; + INT previewHeight = rcAdjPreview.bottom - rcAdjPreview.top; /* Draw inactive preview window */ context.Active = FALSE; SetWindowTextW(hwndDummy, L"Inactive Window"); DrawWindowForNCPreview(hDC, &context - , prcPreview->left + 8 - , prcPreview->top + 8 - , prcPreview->right - 25 - , prcPreview->bottom - 40 + , rcAdjPreview.left + , rcAdjPreview.top + , rcAdjPreview.right - 17 + , rcAdjPreview.bottom - 20 , TRUE , NULL ); @@ -1289,10 +1295,10 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, DWORD textDrawFlags = DT_NOPREFIX | DT_SINGLELINE | DT_WORDBREAK; RECT rcWindowClient; DrawWindowForNCPreview(hDC, &context - , prcPreview->left + 18 - , prcPreview->top + 30 - , prcPreview->right - 8 - , prcPreview->bottom - 20 + , rcAdjPreview.left + 10 + , rcAdjPreview.top + 22 + , rcAdjPreview.right + , rcAdjPreview.bottom , TRUE , &rcWindowClient ); @@ -1309,30 +1315,42 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, /* Draw preview dialog window */ SetWindowTextW(hwndDummy, L"Message Box"); - context.wi.dwStyle &= ~(WS_VSCROLL | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME); - context.wi.dwExStyle = WS_EX_DLGMODALFRAME; + DWORD dwStyleNew = WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_DLGFRAME; + SetWindowLongPtr(hwndDummy, GWL_STYLE, dwStyleNew); + DWORD dwExStyleNew = WS_EX_DLGMODALFRAME; + SetWindowLongPtr(hwndDummy, GWL_EXSTYLE, dwExStyleNew); + + if (GetWindowInfo(hwndDummy, &context.wi)) + { + context.wi.dwStyle = dwStyleNew; + context.wi.dwExStyle = dwExStyleNew; + } + else + return E_FAIL; + - INT msgBoxHeight = prcPreview->bottom - prcPreview->top; + INT msgBoxHalfWidth = 75; + INT msgBoxHCenter = rcAdjPreview.left + (previewWidth / 2); + INT msgBoxVCenter = rcAdjPreview.top + (previewHeight / 2); + if (previewHeight % 2 != 0) + msgBoxVCenter++; DrawWindowForNCPreview(hDC, &context - , prcPreview->left + 98 - , prcPreview->top + ((msgBoxHeight / 5) * 3) - 53 - , prcPreview->right - 99 - , prcPreview->bottom - 27 + , msgBoxHCenter - msgBoxHalfWidth + , msgBoxVCenter - 29 + , msgBoxHCenter + msgBoxHalfWidth + , msgBoxVCenter + 71 , FALSE , &rcWindowClient ); DrawThemeBackground(context.theme, hDC, WP_DIALOG, 0, &rcWindowClient, NULL); - INT msgBoxWidth = rcWindowClient.right - rcWindowClient.left; - msgBoxHeight = rcWindowClient.bottom - rcWindowClient.top; - /* Draw preview dialog button */ HTHEME hBtnTheme = OpenThemeDataFromFile(hThemeFile, hwndDummy, L"BUTTON", OTD_NONCLIENT); if (hBtnTheme) { - INT btnCenterH = rcWindowClient.left + (msgBoxWidth / 2); - INT btnCenterV = rcWindowClient.top + (msgBoxHeight / 2); + INT btnCenterH = rcWindowClient.left + ((rcWindowClient.right - rcWindowClient.left) / 2); + INT btnCenterV = rcWindowClient.top + ((rcWindowClient.bottom - rcWindowClient.top) / 2); RECT rcBtn = { btnCenterH - 40 @@ -1340,9 +1358,11 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, , btnCenterH + 40 , btnCenterV + 15 }; - DrawThemeBackground(hBtnTheme, hDC, BP_PUSHBUTTON, PBS_NORMAL, &rcBtn, NULL); + int btnPart = BP_PUSHBUTTON; + int btnState = PBS_DEFAULTED; + DrawThemeBackground(hBtnTheme, hDC, btnPart, btnState, &rcBtn, NULL); MARGINS btnContentMargins; - if (GetThemeMargins(hBtnTheme, hDC, BP_PUSHBUTTON, PBS_NORMAL, TMT_CONTENTMARGINS, NULL, &btnContentMargins) == S_OK) + if (GetThemeMargins(hBtnTheme, hDC, btnPart, btnState, TMT_CONTENTMARGINS, NULL, &btnContentMargins) == S_OK) { rcBtn.left += btnContentMargins.cxLeftWidth; rcBtn.top += btnContentMargins.cyTopHeight; @@ -1352,10 +1372,10 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, LPCWSTR btnText = L"OK"; LOGFONTW lfBtn; - if ((GetThemeFont(hBtnTheme, hDC, BP_PUSHBUTTON, PBS_NORMAL, TMT_FONT, &lfBtn) != S_OK) && textFont) + if ((GetThemeFont(hBtnTheme, hDC, btnPart, btnState, TMT_FONT, &lfBtn) != S_OK) && textFont) SelectFont(hDC, textFont); - DrawThemeText(hBtnTheme, hDC, BP_PUSHBUTTON, PBS_NORMAL, btnText, -1, DT_CENTER | DT_VCENTER | textDrawFlags, 0, &rcBtn); + DrawThemeText(hBtnTheme, hDC, btnPart, btnState, btnText, -1, DT_CENTER | DT_VCENTER | textDrawFlags, 0, &rcBtn); CloseThemeData(hBtnTheme); } From c57d4be3c7139e93acd4ad9c0321ee2e0c11685b Mon Sep 17 00:00:00 2001 From: Ethan Rodensky Date: Sun, 22 Oct 2023 14:01:25 -0400 Subject: [PATCH 02/33] Address code style feedback --- dll/win32/uxtheme/ncscrollbar.c | 7 ++- dll/win32/uxtheme/nonclient.c | 81 ++++++--------------------------- 2 files changed, 19 insertions(+), 69 deletions(-) diff --git a/dll/win32/uxtheme/ncscrollbar.c b/dll/win32/uxtheme/ncscrollbar.c index 6132f0c7471..0adb4826cfa 100644 --- a/dll/win32/uxtheme/ncscrollbar.c +++ b/dll/win32/uxtheme/ncscrollbar.c @@ -317,11 +317,14 @@ ThemeDrawScrollBarEx(PDRAW_CONTEXT pcontext, INT nBar, PSCROLLBARINFO psbi, POIN void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT nBar, POINT* pt) { + SCROLLBARINFO sbi; if (((nBar == SB_VERT) && !(pcontext->wi.dwStyle & WS_VSCROLL)) || - ((nBar == SB_HORZ) && !(pcontext->wi.dwStyle & WS_HSCROLL))) return; + ((nBar == SB_HORZ) && !(pcontext->wi.dwStyle & WS_HSCROLL))) + { + return; + } - SCROLLBARINFO sbi; sbi.cbSize = sizeof(sbi); GetScrollBarInfo(pcontext->hWnd, SCROLL_getObjectId(nBar), &sbi); ThemeDrawScrollBarEx(pcontext, nBar, &sbi, pt); diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c index 897276b4888..b5da9f5a258 100644 --- a/dll/win32/uxtheme/nonclient.c +++ b/dll/win32/uxtheme/nonclient.c @@ -264,10 +264,11 @@ static void ThemeCalculateCaptionButtonsPosEx(WINDOWINFO wi, HWND hWnd, HTHEME h void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme) { + INT btnHeight; WINDOWINFO wi = {sizeof(wi)}; if(!GetWindowInfo(hWnd, &wi)) return; - INT btnHeight = GetSystemMetrics(wi.dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMSIZE : SM_CYSIZE); + btnHeight = GetSystemMetrics(wi.dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMSIZE : SM_CYSIZE); ThemeCalculateCaptionButtonsPosEx(wi, hWnd, htheme, btnHeight); } @@ -1087,8 +1088,10 @@ DrawWindowForNCPreview( _In_ INT right, _In_ INT bottom, _In_ BOOL drawClientAreaColor, - _Out_ OPTIONAL LPRECT prcClient) + _Out_opt_ LPRECT prcClient) { + SCROLLINFO dummyScrollInfo; + if (!hDC) return; @@ -1097,15 +1100,9 @@ DrawWindowForNCPreview( DWORD dwStyle = pcontext->wi.dwStyle; DWORD dwExStyle = pcontext->wi.dwExStyle; - pcontext->CaptionHeight = GetThemeSysSize(pcontext->theme, - dwExStyle & WS_EX_TOOLWINDOW - ? SM_CYSMSIZE - : SM_CYSIZE - ) + pcontext->wi.cyWindowBorders - ; + pcontext->CaptionHeight = pcontext->wi.cyWindowBorders + GetThemeSysSize(pcontext->theme, dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMSIZE : SM_CYSIZE); /* FIXME: still need to use ncmetrics from parameters for window border width */ - SCROLLINFO dummyScrollInfo; dummyScrollInfo.fMask = SIF_DISABLENOSCROLL; BOOL hasVScrollBar = dwStyle & WS_VSCROLL; @@ -1115,30 +1112,12 @@ DrawWindowForNCPreview( SetScrollInfo(pcontext->hWnd, SB_VERT, &dummyScrollInfo, TRUE); } - RECT rcWindowPrev = - { - pcontext->wi.rcWindow.left, - pcontext->wi.rcWindow.top, - pcontext->wi.rcWindow.right, - pcontext->wi.rcWindow.bottom - }; + RECT rcWindowPrev = { pcontext->wi.rcWindow.left, pcontext->wi.rcWindow.top, pcontext->wi.rcWindow.right, pcontext->wi.rcWindow.bottom }; UNREFERENCED_PARAMETER(rcWindowPrev); - RECT rcClientPrev = - { - pcontext->wi.rcClient.left, - pcontext->wi.rcClient.top, - pcontext->wi.rcClient.right, - pcontext->wi.rcClient.bottom - }; + RECT rcClientPrev = { pcontext->wi.rcClient.left, pcontext->wi.rcClient.top, pcontext->wi.rcClient.right, pcontext->wi.rcClient.bottom }; UNREFERENCED_PARAMETER(rcClientPrev); SetWindowPos(pcontext->hWnd, NULL, left, top, right - left, bottom - top, SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME | SWP_NOCOPYBITS); - RECT rcWindowNew = - { - left, - top, - right, - bottom - }; + RECT rcWindowNew = { left, top, right, bottom }; pcontext->wi.rcWindow = rcWindowNew; SetViewportOrgEx(hDC, rcWindowNew.left, rcWindowNew.top, NULL); @@ -1146,12 +1125,7 @@ DrawWindowForNCPreview( INT offsetX = -rcWindowNew.left; INT offsetY = -rcWindowNew.top; OffsetRect(&rcWindowNew, offsetX, offsetY); - ThemeCalculateCaptionButtonsPosEx( - pcontext->wi - , pcontext->hWnd - , pcontext->theme - , pcontext->CaptionHeight - pcontext->wi.cyWindowBorders - ); + ThemeCalculateCaptionButtonsPosEx(pcontext->wi, pcontext->hWnd, pcontext->theme, pcontext->CaptionHeight - pcontext->wi.cyWindowBorders); INT leftBorderInset = pcontext->wi.cxWindowBorders; @@ -1279,14 +1253,7 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, /* Draw inactive preview window */ context.Active = FALSE; SetWindowTextW(hwndDummy, L"Inactive Window"); - DrawWindowForNCPreview(hDC, &context - , rcAdjPreview.left - , rcAdjPreview.top - , rcAdjPreview.right - 17 - , rcAdjPreview.bottom - 20 - , TRUE - , NULL - ); + DrawWindowForNCPreview(hDC, &context, rcAdjPreview.left, rcAdjPreview.top, rcAdjPreview.right - 17, rcAdjPreview.bottom - 20, TRUE, NULL); /* Draw active preview window */ context.Active = TRUE; @@ -1294,14 +1261,7 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, DWORD textDrawFlags = DT_NOPREFIX | DT_SINGLELINE | DT_WORDBREAK; RECT rcWindowClient; - DrawWindowForNCPreview(hDC, &context - , rcAdjPreview.left + 10 - , rcAdjPreview.top + 22 - , rcAdjPreview.right - , rcAdjPreview.bottom - , TRUE - , &rcWindowClient - ); + DrawWindowForNCPreview(hDC, &context, rcAdjPreview.left + 10, rcAdjPreview.top + 22, rcAdjPreview.right, rcAdjPreview.bottom, TRUE, &rcWindowClient); SetTextColor(hDC, GetThemeSysColor(context.theme, COLOR_WINDOWTEXT)); LOGFONTW lfText; HFONT textFont = NULL; @@ -1335,14 +1295,7 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, if (previewHeight % 2 != 0) msgBoxVCenter++; - DrawWindowForNCPreview(hDC, &context - , msgBoxHCenter - msgBoxHalfWidth - , msgBoxVCenter - 29 - , msgBoxHCenter + msgBoxHalfWidth - , msgBoxVCenter + 71 - , FALSE - , &rcWindowClient - ); + DrawWindowForNCPreview(hDC, &context, msgBoxHCenter - msgBoxHalfWidth, msgBoxVCenter - 29, msgBoxHCenter + msgBoxHalfWidth, msgBoxVCenter + 71, FALSE, &rcWindowClient); DrawThemeBackground(context.theme, hDC, WP_DIALOG, 0, &rcWindowClient, NULL); /* Draw preview dialog button */ @@ -1351,13 +1304,7 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, { INT btnCenterH = rcWindowClient.left + ((rcWindowClient.right - rcWindowClient.left) / 2); INT btnCenterV = rcWindowClient.top + ((rcWindowClient.bottom - rcWindowClient.top) / 2); - RECT rcBtn = - { - btnCenterH - 40 - , btnCenterV - 15 - , btnCenterH + 40 - , btnCenterV + 15 - }; + RECT rcBtn = { btnCenterH - 40, btnCenterV - 15, btnCenterH + 40, btnCenterV + 15}; int btnPart = BP_PUSHBUTTON; int btnState = PBS_DEFAULTED; DrawThemeBackground(hBtnTheme, hDC, btnPart, btnState, &rcBtn, NULL); From 6ddaca72db99243993ab2c4cfd8d051e938fdc45 Mon Sep 17 00:00:00 2001 From: Ethan Rodensky Date: Sun, 22 Oct 2023 14:08:59 -0400 Subject: [PATCH 03/33] Remove unneeded SetThemeAppProperties call --- dll/win32/uxtheme/nonclient.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c index b5da9f5a258..a001a1e42c9 100644 --- a/dll/win32/uxtheme/nonclient.c +++ b/dll/win32/uxtheme/nonclient.c @@ -1225,7 +1225,6 @@ HRESULT WINAPI DrawNCPreview(HDC hDC, hwndDummy = CreateWindowExW(0, L"DummyPreviewWindowClass", L"Active window", WS_OVERLAPPEDWINDOW | WS_VSCROLL, 30, 30, 300, 150, 0, 0, hDllInst, NULL); if (!hwndDummy) return E_FAIL; - SetThemeAppProperties(GetThemeAppProperties() | STAP_ALLOW_CONTROLS); hres = OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, &hThemeFile,0); if (FAILED(hres)) From 7f5c59a0b3e3b731f118c7654972c88b2418fa82 Mon Sep 17 00:00:00 2001 From: Thamatip Chitpong Date: Mon, 23 Oct 2023 18:53:08 +0700 Subject: [PATCH 04/33] [HOTPLUG] Add device properties dialog support (#5812) Clicking at "Properties" button or right-click menu now opens properties dialog for the selected device. --- dll/cpl/hotplug/hotplug.c | 75 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/dll/cpl/hotplug/hotplug.c b/dll/cpl/hotplug/hotplug.c index 7f2930f26cc..15dea9c7583 100644 --- a/dll/cpl/hotplug/hotplug.c +++ b/dll/cpl/hotplug/hotplug.c @@ -157,13 +157,13 @@ InsertDeviceTreeItem( tvItem.hParent = hParent; tvItem.hInsertAfter = TVI_LAST; - tvItem.item.mask = TVIF_STATE | TVIF_TEXT /*| TVIF_PARAM*/ | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvItem.item.state = TVIS_EXPANDED; tvItem.item.stateMask = TVIS_EXPANDED; tvItem.item.pszText = szDisplayName; tvItem.item.iImage = nClassImage; tvItem.item.iSelectedImage = nClassImage; - tvItem.item.lParam = (LPARAM)NULL; + tvItem.item.lParam = (LPARAM)DevInst; return TreeView_InsertItem(hwndDeviceTree, &tvItem); } @@ -344,6 +344,69 @@ ShowContextMenu( } +static +DEVINST +GetSelectedDeviceInst( + _In_ HWND hwndDeviceTree) +{ + HTREEITEM hTreeItem; + TVITEMW item; + + hTreeItem = TreeView_GetSelection(hwndDeviceTree); + if (hTreeItem == NULL) + return 0; + + ZeroMemory(&item, sizeof(item)); + item.mask = TVIF_PARAM; + item.hItem = hTreeItem; + + TreeView_GetItem(hwndDeviceTree, &item); + + return item.lParam; +} + +static +VOID +ShowDeviceProperties( + _In_ HWND hwndParent, + _In_ DEVINST DevInst) +{ + ULONG ulSize; + CONFIGRET cr; + LPWSTR pszDevId; + + cr = CM_Get_Device_ID_Size(&ulSize, DevInst, 0); + if (cr != CR_SUCCESS || ulSize == 0) + return; + + /* Take the terminating NULL into account */ + ulSize++; + + pszDevId = HeapAlloc(GetProcessHeap(), 0, ulSize * sizeof(WCHAR)); + if (pszDevId == NULL) + return; + + cr = CM_Get_Device_IDW(DevInst, pszDevId, ulSize, 0); + if (cr == CR_SUCCESS) + { + typedef int (WINAPI *PFDEVICEPROPERTIESW)(HWND, LPCWSTR, LPCWSTR, BOOL); + HMODULE hDevMgrDll; + PFDEVICEPROPERTIESW pDevicePropertiesW; + + hDevMgrDll = LoadLibraryW(L"devmgr.dll"); + if (hDevMgrDll != NULL) + { + pDevicePropertiesW = (PFDEVICEPROPERTIESW)GetProcAddress(hDevMgrDll, "DevicePropertiesW"); + if (pDevicePropertiesW != NULL) + pDevicePropertiesW(hwndParent, NULL, pszDevId, FALSE); + + FreeLibrary(hDevMgrDll); + } + } + + HeapFree(GetProcessHeap(), 0, pszDevId); +} + INT_PTR CALLBACK SafeRemovalDlgProc( @@ -434,6 +497,14 @@ SafeRemovalDlgProc( } } break; + + case IDC_SAFE_REMOVE_PROPERTIES: + case IDM_PROPERTIES: + { + HWND hwndDevTree = GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE); + ShowDeviceProperties(hwndDlg, GetSelectedDeviceInst(hwndDevTree)); + break; + } } break; From 5b54477d47f943561bed08df8e6feee2d5d0e839 Mon Sep 17 00:00:00 2001 From: Serge Gautherie <32623169+SergeGautherie@users.noreply.github.com> Date: Mon, 23 Oct 2023 18:16:59 +0200 Subject: [PATCH 05/33] [BDASUP][PORTCLS][SYSAUDIO][USB] Use ExAllocatePoolZero() and ExFreePoolWithTag() (#5811) --- drivers/multimedia/bdasup/bdasup.c | 20 ++++---------------- drivers/usb/usbccgp/misc.c | 14 ++------------ drivers/usb/usbstor/misc.c | 10 +--------- drivers/usb/usbstor_new/misc.c | 22 ++-------------------- drivers/wdm/audio/backpln/portcls/pool.cpp | 9 +-------- drivers/wdm/audio/sysaudio/main.c | 14 ++++---------- 6 files changed, 14 insertions(+), 75 deletions(-) diff --git a/drivers/multimedia/bdasup/bdasup.c b/drivers/multimedia/bdasup/bdasup.c index df3de2a13d9..b300d88d828 100644 --- a/drivers/multimedia/bdasup/bdasup.c +++ b/drivers/multimedia/bdasup/bdasup.c @@ -1,6 +1,8 @@ #include "precomp.h" +#define TAG_BDASUP 'SadB' + const GUID KSPROPSETID_BdaPinControl = {0xded49d5, 0xa8b7, 0x4d5d, {0x97, 0xa1, 0x12, 0xb0, 0xc1, 0x95, 0x87, 0x4d}}; const GUID KSMETHODSETID_BdaDeviceConfiguration = {0x71985f45, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; const GUID KSPROPSETID_BdaTopology = {0xa14ee835, 0x0a23, 0x11d3, {0x9c, 0xc7, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}}; @@ -24,7 +26,6 @@ KSPROPERTY_ITEM FilterPropertyItem[] = DEFINE_KSPROPERTY_ITEM_BDA_NODE_DESCRIPTORS(BdaPropertyNodeDescriptors, NULL) }; - KSPROPERTY_SET FilterPropertySet = { &KSPROPSETID_BdaTopology, @@ -90,28 +91,21 @@ KSAUTOMATION_TABLE PinAutomationTable = NULL }; - PVOID AllocateItem( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes) { - PVOID Item = ExAllocatePool(PoolType, NumberOfBytes); - if (!Item) - return Item; - - RtlZeroMemory(Item, NumberOfBytes); - return Item; + return ExAllocatePoolZero(PoolType, NumberOfBytes, TAG_BDASUP); } VOID FreeItem( IN PVOID Item) { - ExFreePool(Item); + ExFreePoolWithTag(Item, TAG_BDASUP); } - PBDA_FILTER_INSTANCE_ENTRY GetFilterInstanceEntry( IN PKSFILTERFACTORY FilterFactory) @@ -141,7 +135,6 @@ GetFilterInstanceEntry( InstanceEntry = NULL; } - /* release spin lock */ KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel); @@ -245,7 +238,6 @@ FreeFilterInstance( KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel); } - /* @implemented */ @@ -339,7 +331,6 @@ BdaCreateFilterFactoryEx( /* release spin lock */ KeReleaseSpinLock(&g_Settings.FilterFactoryInstanceListLock, OldLevel); - if (ppKSFilterFactory) { /* store result */ @@ -450,7 +441,6 @@ BdaCreatePin( } } - DPRINT("BdaCreatePin Result %x PinId %u\n", Status, PinId); return Status; } @@ -543,8 +533,6 @@ BdaInitFilter( return Status; } - - /* @implemented */ diff --git a/drivers/usb/usbccgp/misc.c b/drivers/usb/usbccgp/misc.c index 5edd293838f..9242fcf0a31 100644 --- a/drivers/usb/usbccgp/misc.c +++ b/drivers/usb/usbccgp/misc.c @@ -95,17 +95,8 @@ AllocateItem( IN POOL_TYPE PoolType, IN ULONG ItemSize) { - /* Allocate item */ - PVOID Item = ExAllocatePoolWithTag(PoolType, ItemSize, USBCCPG_TAG); - - if (Item) - { - /* Zero item */ - RtlZeroMemory(Item, ItemSize); - } - - /* Return element */ - return Item; + /* Allocate, zero and return item */ + return ExAllocatePoolZero(PoolType, ItemSize, USBCCPG_TAG); } VOID @@ -123,7 +114,6 @@ DumpFunctionDescriptor( { ULONG Index, SubIndex; - DPRINT("FunctionCount %lu\n", FunctionDescriptorCount); for (Index = 0; Index < FunctionDescriptorCount; Index++) { diff --git a/drivers/usb/usbstor/misc.c b/drivers/usb/usbstor/misc.c index 71af4c1fd61..7165cc1d433 100644 --- a/drivers/usb/usbstor/misc.c +++ b/drivers/usb/usbstor/misc.c @@ -12,7 +12,6 @@ #define NDEBUG #include - IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine; NTSTATUS @@ -126,14 +125,7 @@ AllocateItem( IN POOL_TYPE PoolType, IN ULONG ItemSize) { - PVOID Item = ExAllocatePoolWithTag(PoolType, ItemSize, USB_STOR_TAG); - - if (Item) - { - RtlZeroMemory(Item, ItemSize); - } - - return Item; + return ExAllocatePoolZero(PoolType, ItemSize, USB_STOR_TAG); } VOID diff --git a/drivers/usb/usbstor_new/misc.c b/drivers/usb/usbstor_new/misc.c index 6b60cf828e7..861acb11cd7 100644 --- a/drivers/usb/usbstor_new/misc.c +++ b/drivers/usb/usbstor_new/misc.c @@ -55,7 +55,6 @@ USBSTOR_SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp) // IoSetCompletionRoutine(Irp, USBSTOR_SyncForwardIrpCompletionRoutine, &Event, TRUE, TRUE, TRUE); - // // call driver // @@ -101,13 +100,11 @@ USBSTOR_GetBusInterface( ASSERT(DeviceObject); ASSERT(BusInterface); - // // initialize event // KeInitializeEvent(&Event, NotificationEvent, FALSE); - // // create irp // @@ -194,7 +191,6 @@ USBSTOR_SyncUrbRequest( // KeInitializeEvent(&Event, NotificationEvent, FALSE); - // // get next stack location // @@ -252,22 +248,9 @@ AllocateItem( IN ULONG ItemSize) { // - // allocate item + // allocate, zero and return item // - PVOID Item = ExAllocatePoolWithTag(PoolType, ItemSize, USB_STOR_TAG); - - if (Item) - { - // - // zero item - // - RtlZeroMemory(Item, ItemSize); - } - - // - // return element - // - return Item; + return ExAllocatePoolZero(PoolType, ItemSize, USB_STOR_TAG); } VOID @@ -333,7 +316,6 @@ USBSTOR_ClassRequest( return Status; } - NTSTATUS USBSTOR_GetMaxLUN( IN PDEVICE_OBJECT DeviceObject, diff --git a/drivers/wdm/audio/backpln/portcls/pool.cpp b/drivers/wdm/audio/backpln/portcls/pool.cpp index cd39f61c3fb..63ee67edcdd 100644 --- a/drivers/wdm/audio/backpln/portcls/pool.cpp +++ b/drivers/wdm/audio/backpln/portcls/pool.cpp @@ -11,7 +11,6 @@ #ifndef YDEBUG #define NDEBUG #endif - #include PVOID @@ -20,12 +19,7 @@ AllocateItem( IN SIZE_T NumberOfBytes, IN ULONG Tag) { - PVOID Item = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag); - if (!Item) - return Item; - - RtlZeroMemory(Item, NumberOfBytes); - return Item; + return ExAllocatePoolZero(PoolType, NumberOfBytes, Tag); } VOID @@ -33,6 +27,5 @@ FreeItem( IN PVOID Item, IN ULONG Tag) { - ExFreePoolWithTag(Item, Tag); } diff --git a/drivers/wdm/audio/sysaudio/main.c b/drivers/wdm/audio/sysaudio/main.c index ee7946146f3..12e5b2aacfc 100644 --- a/drivers/wdm/audio/sysaudio/main.c +++ b/drivers/wdm/audio/sysaudio/main.c @@ -14,6 +14,8 @@ #define NDEBUG #include +#define TAG_SYSAUDIO 'AsyS' + const GUID KSCATEGORY_SYSAUDIO = {0xA7C7A5B1L, 0x5AF3, 0x11D1, {0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07}}; const GUID KSCATEGORY_AUDIO_DEVICE = {0xFBF6F530L, 0x07B9, 0x11D2, {0xA7, 0x1E, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}}; const GUID KSCATEGORY_PREFERRED_WAVEOUT_DEVICE = {0xD6C5066EL, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}}; @@ -25,22 +27,16 @@ AllocateItem( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes) { - PVOID Item = ExAllocatePool(PoolType, NumberOfBytes); - if (!Item) - return Item; - - RtlZeroMemory(Item, NumberOfBytes); - return Item; + return ExAllocatePoolZero(PoolType, NumberOfBytes, TAG_SYSAUDIO); } VOID FreeItem( IN PVOID Item) { - ExFreePool(Item); + ExFreePoolWithTag(Item, TAG_SYSAUDIO); } - VOID NTAPI SysAudio_Unload(IN PDRIVER_OBJECT DriverObject) @@ -88,7 +84,6 @@ SysAudio_Shutdown( return STATUS_SUCCESS; } - NTSTATUS NTAPI SysAudio_Pnp( @@ -222,7 +217,6 @@ SysAudio_AddDevice( /* register shutdown notification */ IoRegisterShutdownNotification(DeviceObject); - /* Done */ return STATUS_SUCCESS; From 501c2bdd63c4d4b97c4bc3b54241abe53e0fabdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 22 Oct 2023 21:57:59 +0200 Subject: [PATCH 06/33] [NTOS:LPC] Fix input parameter for ProbeAndCaptureUnicodeString (#5815) Addendum to commit b3c55b9e6 (PR #4399). Passing &CapturedObjectName as pointer to be probed and captured would fail if e.g. PreviousMode == UserMode, since that pointer is always in kernel space. Instead, pass the original user-mode pointer. Bug caught by Timo Kreuzer ;) --- ntoskrnl/lpc/create.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/lpc/create.c b/ntoskrnl/lpc/create.c index 7c017b6b7e1..2f4d5b9622a 100644 --- a/ntoskrnl/lpc/create.c +++ b/ntoskrnl/lpc/create.c @@ -83,8 +83,9 @@ LpcpCreatePort(OUT PHANDLE PortHandle, } else { - if (ObjectAttributes->ObjectName) - CapturedObjectName = *(ObjectAttributes->ObjectName); + ObjectName = ObjectAttributes->ObjectName; + if (ObjectName) + CapturedObjectName = *ObjectName; } /* Normalize the buffer pointer in case we don't have @@ -96,7 +97,7 @@ LpcpCreatePort(OUT PHANDLE PortHandle, /* Capture the port name for DPRINT only - ObCreateObject does its * own capture. As it is used only for debugging, ignore any failure; * the string is zeroed out in such case. */ - ProbeAndCaptureUnicodeString(&CapturedPortName, PreviousMode, &CapturedObjectName); + ProbeAndCaptureUnicodeString(&CapturedPortName, PreviousMode, ObjectName); LPCTRACE(LPC_CREATE_DEBUG, "Name: %wZ\n", &CapturedPortName); ReleaseCapturedUnicodeString(&CapturedPortName, PreviousMode); #endif From 3b1cbb357833fc4cbf78747cab6e6132b148aded Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Thu, 13 Oct 2022 19:56:10 +0200 Subject: [PATCH 07/33] [BDASUP][KMIXER][MMIXER][STREAM] Replace meaningless YDEBUG bdasup: Addendum to 40c15ec (r46632). kmixer: Addendum to 3e489bf (r42143). mmixer: Addendum to c42d9f2 (r44872). stream: Addendum to 4a0debf (r41662). --- drivers/multimedia/bdasup/precomp.h | 2 +- drivers/wdm/audio/filters/kmixer/filter.c | 3 +-- drivers/wdm/audio/filters/kmixer/kmixer.c | 4 +--- drivers/wdm/audio/legacy/stream/stream.h | 3 ++- sdk/lib/drivers/sound/mmixer/controls.c | 9 +-------- sdk/lib/drivers/sound/mmixer/filter.c | 2 +- sdk/lib/drivers/sound/mmixer/midi.c | 2 +- sdk/lib/drivers/sound/mmixer/mixer.c | 4 +--- sdk/lib/drivers/sound/mmixer/sup.c | 5 +---- sdk/lib/drivers/sound/mmixer/topology.c | 10 +--------- sdk/lib/drivers/sound/mmixer/wave.c | 8 +------- 11 files changed, 12 insertions(+), 40 deletions(-) diff --git a/drivers/multimedia/bdasup/precomp.h b/drivers/multimedia/bdasup/precomp.h index 45a603ddecd..be258b38783 100644 --- a/drivers/multimedia/bdasup/precomp.h +++ b/drivers/multimedia/bdasup/precomp.h @@ -10,7 +10,7 @@ #include #include -#define YDEBUG +// #define NDEBUG #include diff --git a/drivers/wdm/audio/filters/kmixer/filter.c b/drivers/wdm/audio/filters/kmixer/filter.c index 5d84eb2c2d0..f2112b758b1 100644 --- a/drivers/wdm/audio/filters/kmixer/filter.c +++ b/drivers/wdm/audio/filters/kmixer/filter.c @@ -10,7 +10,7 @@ #include -#define YDEBUG +// #define NDEBUG #include NTSTATUS @@ -199,4 +199,3 @@ KMixAllocateDeviceHeader( CreateItem); return Status; } - diff --git a/drivers/wdm/audio/filters/kmixer/kmixer.c b/drivers/wdm/audio/filters/kmixer/kmixer.c index 978e46565cd..b9ae6e68af9 100644 --- a/drivers/wdm/audio/filters/kmixer/kmixer.c +++ b/drivers/wdm/audio/filters/kmixer/kmixer.c @@ -8,7 +8,7 @@ #include "kmixer.h" -#define YDEBUG +// #define NDEBUG #include NTSTATUS @@ -72,7 +72,6 @@ KMix_AddDevice( /* initialize device extension */ RtlZeroMemory(DeviceExtension, sizeof(KMIXER_DEVICE_EXT)); - Status = KMixAllocateDeviceHeader(DeviceExtension); if (!NT_SUCCESS(Status)) { @@ -98,7 +97,6 @@ KMix_AddDevice( return Status; } - NTSTATUS NTAPI DriverEntry( diff --git a/drivers/wdm/audio/legacy/stream/stream.h b/drivers/wdm/audio/legacy/stream/stream.h index 5994d91be56..09054368ea0 100644 --- a/drivers/wdm/audio/legacy/stream/stream.h +++ b/drivers/wdm/audio/legacy/stream/stream.h @@ -1,7 +1,8 @@ #pragma once #include -#define YDEBUG + +// #define NDEBUG #include #define STREAMDEBUG_LEVEL DebugLevelMaximum diff --git a/sdk/lib/drivers/sound/mmixer/controls.c b/sdk/lib/drivers/sound/mmixer/controls.c index 3b5a8036b25..a7521bf4dd3 100644 --- a/sdk/lib/drivers/sound/mmixer/controls.c +++ b/sdk/lib/drivers/sound/mmixer/controls.c @@ -8,7 +8,7 @@ #include "precomp.h" -#define YDEBUG +// #define NDEBUG #include const GUID KSNODETYPE_DESKTOP_MICROPHONE = {0xDFF21BE2, 0xF70F, 0x11D0, {0xB9, 0x17, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}; @@ -56,7 +56,6 @@ MMixerAddMixerControl( return MM_STATUS_NO_MEMORY; } - /* initialize mixer control */ MixerControl->hDevice = hMixer; MixerControl->NodeID = NodeIndex; @@ -263,7 +262,6 @@ MMixerCreateDestinationLine( DestinationLine->Line.dwUser = 0; DestinationLine->Line.fdwLine = MIXERLINE_LINEF_ACTIVE; - if (LineName) { MixerContext->Copy(DestinationLine->Line.szShortName, LineName, (min(MIXER_SHORT_NAME_CHARS, wcslen(LineName)+1)) * sizeof(WCHAR)); @@ -564,7 +562,6 @@ MMixerGetChannelCountEnhanced( Request.Property.Flags = KSPROPERTY_TYPE_BASICSUPPORT | KSPROPERTY_TYPE_TOPOLOGY; Request.Property.Id = KSPROPERTY_AUDIO_VOLUMELEVEL; - /* get description */ Status = MixerContext->Control(hMixer, IOCTL_KS_PROPERTY, (PVOID)&Request, sizeof(KSP_NODE), (PVOID)&Description, sizeof(KSPROPERTY_DESCRIPTION), &BytesReturned); if (Status == MM_STATUS_SUCCESS) @@ -772,7 +769,6 @@ MMixerGetComponentAndTargetType( Request.Property.Set = KSPROPSETID_Pin; Request.Property.Id = KSPROPERTY_PIN_CATEGORY; - /* get pin category */ Status = MixerContext->Control(hMixer, IOCTL_KS_PROPERTY, (PVOID)&Request, sizeof(KSP_PIN), &Guid, sizeof(GUID), &BytesReturned); if (Status != MM_STATUS_SUCCESS) @@ -1163,7 +1159,6 @@ MMixerAddMixerSourceLines( return MM_STATUS_SUCCESS; } - MIXER_STATUS MMixerAddMixerControlsToDestinationLine( IN PMIXER_CONTEXT MixerContext, @@ -1623,7 +1618,6 @@ MMixerInitializeFilter( } } - /* now get the bridge pin which is at the end of node path * For sink pins (wave out) search down stream * For source pins (wave in) search up stream @@ -1829,7 +1823,6 @@ MMixerSetupFilter( return Status; } - MIXER_STATUS MMixerAddEvent( IN PMIXER_CONTEXT MixerContext, diff --git a/sdk/lib/drivers/sound/mmixer/filter.c b/sdk/lib/drivers/sound/mmixer/filter.c index a41bcee7bb7..19033c831ad 100644 --- a/sdk/lib/drivers/sound/mmixer/filter.c +++ b/sdk/lib/drivers/sound/mmixer/filter.c @@ -8,7 +8,7 @@ #include "precomp.h" -#define YDEBUG +// #define NDEBUG #include ULONG diff --git a/sdk/lib/drivers/sound/mmixer/midi.c b/sdk/lib/drivers/sound/mmixer/midi.c index 969f252773a..acca89ca5ad 100644 --- a/sdk/lib/drivers/sound/mmixer/midi.c +++ b/sdk/lib/drivers/sound/mmixer/midi.c @@ -8,7 +8,7 @@ #include "precomp.h" -#define YDEBUG +// #define NDEBUG #include MIXER_STATUS diff --git a/sdk/lib/drivers/sound/mmixer/mixer.c b/sdk/lib/drivers/sound/mmixer/mixer.c index 3b8d900bef6..4b98ed53ae3 100644 --- a/sdk/lib/drivers/sound/mmixer/mixer.c +++ b/sdk/lib/drivers/sound/mmixer/mixer.c @@ -8,7 +8,7 @@ #include "precomp.h" -#define YDEBUG +// #define NDEBUG #include ULONG @@ -106,7 +106,6 @@ MMixerOpen( /* add the event */ Status = MMixerAddEvent(MixerContext, MixerInfo, MixerEventContext, MixerEventRoutine); - /* store result */ *MixerHandle = (HANDLE)MixerInfo; return MM_STATUS_SUCCESS; @@ -687,7 +686,6 @@ MMixerPrintMixers( DPRINT1("WaveOutCount %lu\n", MixerList->WaveOutListCount); DPRINT1("MixerCount %p\n", MixerList->MixerListCount); - for(Index = 0; Index < MixerList->MixerListCount; Index++) { /* get mixer info */ diff --git a/sdk/lib/drivers/sound/mmixer/sup.c b/sdk/lib/drivers/sound/mmixer/sup.c index 4fa8c080309..cfd5ab8b0b1 100644 --- a/sdk/lib/drivers/sound/mmixer/sup.c +++ b/sdk/lib/drivers/sound/mmixer/sup.c @@ -8,7 +8,7 @@ #include "precomp.h" -#define YDEBUG +// #define NDEBUG #include const GUID KSNODETYPE_SUM = {0xDA441A60L, 0xC556, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}}; @@ -36,7 +36,6 @@ const GUID KSDATAFORMAT_TYPE_MUSIC = {0xE725D360L, 0x62CC, 0x11CF, {0xA5, 0xD6, const GUID KSDATAFORMAT_SUBTYPE_MIDI = {0x1D262760L, 0xE957, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; const GUID KSDATAFORMAT_SPECIFIER_NONE = {0x0F6417D6L, 0xC318, 0x11D0, {0xA4, 0x3F, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}; - MIXER_STATUS MMixerVerifyContext( IN PMIXER_CONTEXT MixerContext) @@ -125,7 +124,6 @@ MMixerFreeMixerInfo( MixerContext->Free((PVOID)MixerInfo); } - LPMIXER_DATA MMixerGetMixerDataByDeviceHandle( IN PMIXER_CONTEXT MixerContext, @@ -156,7 +154,6 @@ MMixerGetMixerDataByDeviceHandle( return NULL; } - LPMIXER_INFO MMixerGetMixerInfoByIndex( IN PMIXER_CONTEXT MixerContext, diff --git a/sdk/lib/drivers/sound/mmixer/topology.c b/sdk/lib/drivers/sound/mmixer/topology.c index 136dc61dee1..29b1237436b 100644 --- a/sdk/lib/drivers/sound/mmixer/topology.c +++ b/sdk/lib/drivers/sound/mmixer/topology.c @@ -8,7 +8,7 @@ #include "precomp.h" -#define YDEBUG +// #define NDEBUG #include VOID @@ -37,11 +37,8 @@ MMixerPrintTopology( Topology->TopologyNodes[Index].NodeConnectedFromCount, Topology->TopologyNodes[Index].NodeConnectedToCount, Topology->TopologyNodes[Index].Visited, Topology->TopologyNodes[Index].PinConnectedFromCount, Topology->TopologyNodes[Index].PinConnectedToCount); } - - } - MIXER_STATUS MMixerAllocateTopology( IN PMIXER_CONTEXT MixerContext, @@ -708,7 +705,6 @@ MMixerGetNodeIndexFromGuid( return MAXULONG; } - VOID MMixerGetAllUpOrDownstreamPinsFromNodeIndex( IN PMIXER_CONTEXT MixerContext, @@ -848,7 +844,6 @@ MMixerGetAllUpOrDownstreamPinsFromPinIndex( TopologyPinsCount = Pin->PinConnectedToCount; } - /* reset visited status */ MMixerResetTopologyVisitStatus(Topology); @@ -906,7 +901,6 @@ MMixerGetAllUpOrDownstreamNodesFromPinIndex( TopologyNodesCount = Pin->NodesConnectedToCount; } - /* reset visited status */ MMixerResetTopologyVisitStatus(Topology); @@ -924,7 +918,6 @@ MMixerGetAllUpOrDownstreamNodesFromPinIndex( } } - VOID MMixerGetNextNodesFromPinIndex( IN PMIXER_CONTEXT MixerContext, @@ -1248,7 +1241,6 @@ MMixerIsTopologyNodeReserved( *bReserved = Topology->TopologyNodes[NodeIndex].Reserved; } - MIXER_STATUS MMixerCreateTopology( IN PMIXER_CONTEXT MixerContext, diff --git a/sdk/lib/drivers/sound/mmixer/wave.c b/sdk/lib/drivers/sound/mmixer/wave.c index 6326e3227d7..e049ca485bd 100644 --- a/sdk/lib/drivers/sound/mmixer/wave.c +++ b/sdk/lib/drivers/sound/mmixer/wave.c @@ -8,7 +8,7 @@ #include "precomp.h" -#define YDEBUG +// #define NDEBUG #include const GUID KSPROPSETID_Connection = {0x1D58C920L, 0xAC9B, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}; @@ -111,9 +111,6 @@ MMixerGetWaveInfoByIndexAndType( return MM_STATUS_INVALID_PARAMETER; } - - - VOID MMixerInitializeDataFormat( IN PKSDATAFORMAT_WAVEFORMATEX DataFormat, @@ -137,7 +134,6 @@ MMixerInitializeDataFormat( DataFormat->DataFormat.SampleSize = 4; } - MIXER_STATUS MMixerGetAudioPinDataRanges( IN PMIXER_CONTEXT MixerContext, @@ -307,7 +303,6 @@ MMixerCheckFormat( /* check if pin supports the sample rate in 16-Bit Mono */ Result |= TestRange[Index].Bit16Mono; - if (DataRangeAudio->MaximumChannels > 1) { /* check if pin supports the sample rate in 16-Bit Stereo */ @@ -317,7 +312,6 @@ MMixerCheckFormat( } } - if (bInput) WaveInfo->u.InCaps.dwFormats = Result; else From 96430d2520282889fa83b5453bd93371fd2d9b43 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Tue, 24 Oct 2023 00:34:50 +0200 Subject: [PATCH 08/33] IEnumIDList::Next must handle pceltFetched and memory errors correctly --- dll/shellext/fontext/CEnumFonts.cpp | 21 +++++++++++++++----- dll/shellext/netshell/enumlist.cpp | 8 ++++++++ dll/shellext/zipfldr/CEnumZipContents.cpp | 24 +++++++++++------------ dll/win32/shell32/CEnumIDListBase.cpp | 6 ++++++ 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/dll/shellext/fontext/CEnumFonts.cpp b/dll/shellext/fontext/CEnumFonts.cpp index 3897a73debd..957e816d322 100644 --- a/dll/shellext/fontext/CEnumFonts.cpp +++ b/dll/shellext/fontext/CEnumFonts.cpp @@ -36,9 +36,10 @@ class CEnumFonts : // *** IEnumIDList methods *** STDMETHODIMP Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched) { - if (!pceltFetched || !rgelt) + if (!rgelt || (!pceltFetched && celt != 1)) return E_POINTER; + HRESULT hr = S_OK; ULONG Fetched = 0; while (celt) @@ -48,15 +49,25 @@ class CEnumFonts : if (m_Index < g_FontCache->Size()) { CStringW Name = g_FontCache->Name(m_Index); - rgelt[Fetched] = _ILCreate(Name, m_Index); - + LPITEMIDLIST item = _ILCreate(Name, m_Index); + if (!item) + { + hr = Fetched ? S_FALSE : E_OUTOFMEMORY; + break; + } + rgelt[Fetched] = item; m_Index++; Fetched++; } + else + { + hr = S_FALSE; + } } - *pceltFetched = Fetched; - return Fetched ? S_OK : S_FALSE; + if (pceltFetched) + *pceltFetched = Fetched; + return hr; } STDMETHODIMP Skip(ULONG celt) { diff --git a/dll/shellext/netshell/enumlist.cpp b/dll/shellext/netshell/enumlist.cpp index a95eab776d8..9369663f708 100644 --- a/dll/shellext/netshell/enumlist.cpp +++ b/dll/shellext/netshell/enumlist.cpp @@ -277,9 +277,17 @@ CEnumIDList::Next( for (i = 0; i < celt; i++) { if (!m_pCurrent) + { + hr = S_FALSE; break; + } temp = ILClone(m_pCurrent->pidl); + if (!temp) + { + hr = i ? S_FALSE : E_OUTOFMEMORY; + break; + } rgelt[i] = temp; m_pCurrent = m_pCurrent->pNext; } diff --git a/dll/shellext/zipfldr/CEnumZipContents.cpp b/dll/shellext/zipfldr/CEnumZipContents.cpp index 372e21ba772..a3f5bcbf79c 100644 --- a/dll/shellext/zipfldr/CEnumZipContents.cpp +++ b/dll/shellext/zipfldr/CEnumZipContents.cpp @@ -34,25 +34,25 @@ class CEnumZipContents : // *** IEnumIDList methods *** STDMETHODIMP Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched) { - if (!pceltFetched || !rgelt) + if (!rgelt || (!pceltFetched && celt != 1)) return E_POINTER; - *pceltFetched = 0; - - if (celt != 1) - return E_FAIL; - + LPITEMIDLIST item; CStringW name; bool dir; unz_file_info64 info; - if (mEnumerator.next_unique(m_Prefix, name, dir, info)) + for (ULONG i = 0; i < celt; ++i) { - *pceltFetched = 1; - *rgelt = _ILCreate(dir ? ZIP_PIDL_DIRECTORY : ZIP_PIDL_FILE, name, info); - return S_OK; + if (pceltFetched) + *pceltFetched = i; + if (!mEnumerator.next_unique(m_Prefix, name, dir, info)) + return S_FALSE; + item = _ILCreate(dir ? ZIP_PIDL_DIRECTORY : ZIP_PIDL_FILE, name, info); + if (!item) + return i ? S_FALSE : E_OUTOFMEMORY; + rgelt[i] = item; } - - return S_FALSE; + return S_OK; } STDMETHODIMP Skip(ULONG celt) { diff --git a/dll/win32/shell32/CEnumIDListBase.cpp b/dll/win32/shell32/CEnumIDListBase.cpp index 59633418c3d..47adf6e2ea8 100644 --- a/dll/win32/shell32/CEnumIDListBase.cpp +++ b/dll/win32/shell32/CEnumIDListBase.cpp @@ -172,9 +172,15 @@ HRESULT WINAPI CEnumIDListBase::Next( for(i = 0; i < celt; i++) { if(!mpCurrent) + { hr = S_FALSE; break; + } temp = ILClone(mpCurrent->pidl); + if (!temp) + { hr = i ? S_FALSE : E_OUTOFMEMORY; + break; + } rgelt[i] = temp; mpCurrent = mpCurrent->pNext; } From 139300759a59bdf41f050acede52ff455d43314b Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Tue, 24 Oct 2023 02:04:02 +0200 Subject: [PATCH 09/33] Handle ADN_DEL_IF_EMPTY in DelNodeW and DelNodeRunDLL32 --- dll/win32/advpack/files.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dll/win32/advpack/files.c b/dll/win32/advpack/files.c index 3e4cb366007..f759e2f091a 100644 --- a/dll/win32/advpack/files.c +++ b/dll/win32/advpack/files.c @@ -341,9 +341,15 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags) HANDLE hFindFile; WIN32_FIND_DATAW w32fd; BOOL done = TRUE; - int fname_len = lstrlenW(fname); + int fname_len; + + if (flags & ADN_DEL_IF_EMPTY) + { + goto deleteinitialdirectory; + } /* Generate a path with wildcard suitable for iterating */ + fname_len = lstrlenW(fname); if (fname_len && fname[fname_len-1] != '\\') fname[fname_len++] = '\\'; lstrcpyW(fname + fname_len, asterisk); @@ -371,8 +377,10 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags) if (done) { +deleteinitialdirectory: TRACE("%s: directory\n", debugstr_w(fname)); - if (SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL) && RemoveDirectoryW(fname)) + SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL); + if (RemoveDirectoryW(fname)) { ret = S_OK; } @@ -381,7 +389,8 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags) else { TRACE("%s: file\n", debugstr_w(fname)); - if (SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL) && DeleteFileW(fname)) + SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL); + if (DeleteFileW(fname)) { ret = S_OK; } @@ -436,8 +445,8 @@ HRESULT WINAPI DelNodeW(LPCWSTR pszFileOrDirName, DWORD dwFlags) TRACE("(%s, %d)\n", debugstr_w(pszFileOrDirName), dwFlags); - if (dwFlags) - FIXME("Flags ignored!\n"); + if (dwFlags & ~ADN_DEL_IF_EMPTY) + FIXME("Flags %#x ignored!\n", dwFlags); if (pszFileOrDirName && *pszFileOrDirName) { From 23d2f4208476cea5a73180ff9c289cc7ad91ac0a Mon Sep 17 00:00:00 2001 From: Egor Ananyin Date: Tue, 24 Oct 2023 15:34:14 +0300 Subject: [PATCH 10/33] [NTUSER] Fix system menu mouse handing Add a check for the system menu opened from the app icon. Fixes CORE-19258 --- win32ss/user/ntuser/menu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/win32ss/user/ntuser/menu.c b/win32ss/user/ntuser/menu.c index 6b2f242cc25..919aae48d60 100644 --- a/win32ss/user/ntuser/menu.c +++ b/win32ss/user/ntuser/menu.c @@ -3555,7 +3555,9 @@ static BOOL FASTCALL MENU_ButtonDown(MTRACKER* pmt, PMENU PtMenu, UINT Flags) { UINT id = 0; PITEM item; - if (IS_SYSTEM_MENU(PtMenu)) + + // Special check for the icon system menu + if (IS_SYSTEM_MENU(PtMenu) && !(PtMenu->fFlags & MNF_POPUP)) { item = PtMenu->rgItems; } @@ -3599,7 +3601,8 @@ static INT FASTCALL MENU_ButtonUp(MTRACKER *pmt, PMENU PtMenu, UINT Flags) UINT Id = 0; ITEM *item; - if ( IS_SYSTEM_MENU(PtMenu) ) + // Special check for the icon system menu + if (IS_SYSTEM_MENU(PtMenu) && !(PtMenu->fFlags & MNF_POPUP)) { item = PtMenu->rgItems; } From d14fc85565aea59f019d0fe56cd3048974e8b6b3 Mon Sep 17 00:00:00 2001 From: Julen Urizar Compains Date: Tue, 24 Oct 2023 15:08:31 +0200 Subject: [PATCH 11/33] Add BaseAdress_gcc_x64.cmake and use it in the CMakeLists --- CMakeLists.txt | 7 +- GCC8x64-2.patch | 120 +++++++++ GCC8x64-2new.patch | 106 ++++++++ sdk/cmake/baseaddress_gcc_x64.cmake | 384 ++++++++++++++++++++++++++++ 4 files changed, 615 insertions(+), 2 deletions(-) create mode 100644 GCC8x64-2.patch create mode 100644 GCC8x64-2new.patch create mode 100644 sdk/cmake/baseaddress_gcc_x64.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 12dd07e5085..025b44dc9a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,8 +345,11 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to include(sdk/cmake/baseaddress_msvc.cmake) endif() else() - include(sdk/cmake/baseaddress.cmake) - endif() + if (ARCH STREQUAL "amd64") + include(sdk/cmake/baseaddress_gcc_x64.cmake) + else() + include(sdk/cmake/baseaddress.cmake) + endif() # For MSVC builds, this puts all debug symbols file in the same directory. if(MSVC) diff --git a/GCC8x64-2.patch b/GCC8x64-2.patch new file mode 100644 index 00000000000..2d13a7a3438 --- /dev/null +++ b/GCC8x64-2.patch @@ -0,0 +1,120 @@ +diff --git a/dll/win32/advapi32/service/eventlog.c b/dll/win32/advapi32/service/eventlog.c +index 028e5d234ce..3ba4bee8e97 100644 +--- a/dll/win32/advapi32/service/eventlog.c ++++ b/dll/win32/advapi32/service/eventlog.c +@@ -94,6 +94,9 @@ EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName, + handle_t __RPC_USER + EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName) + { ++ #ifdef _M_AMD64 ++ return NULL; ++ #endif + handle_t hBinding = NULL; + RPC_WSTR pszStringBinding; + RPC_STATUS status; +diff --git a/dll/win32/kernel32/client/debugger.c b/dll/win32/kernel32/client/debugger.c +index a466296f451..9d5529f4dc8 100644 +--- a/dll/win32/kernel32/client/debugger.c ++++ b/dll/win32/kernel32/client/debugger.c +@@ -692,6 +692,7 @@ VOID + WINAPI + OutputDebugStringA(IN LPCSTR _OutputString) + { ++ #ifndef _M_AMD64 + _SEH2_TRY + { + ULONG_PTR a_nArgs[2]; +@@ -703,6 +704,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) ++ #endif + { + /* no user-mode debugger: try the systemwide debug message monitor, or the + kernel debugger as a last resort */ +@@ -740,6 +742,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + + _SEH2_TRY + { ++ DPRINT1("SIMONE 1\n"); + volatile PCHAR a_cBuffer = NULL; + + /* opening the mutex failed */ +@@ -790,6 +793,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + + _SEH2_TRY + { ++ DPRINT1("SIMONE 1\n"); + /* size of the current output block */ + volatile SIZE_T nRoundLen; + +@@ -885,6 +889,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + } + _SEH2_FINALLY + { ++ DPRINT1("SIMONE 2\n"); + /* close all the still open resources */ + if (hDBMonBufferReady) CloseHandle(hDBMonBufferReady); + if (pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer); +@@ -897,7 +902,9 @@ OutputDebugStringA(IN LPCSTR _OutputString) + } + _SEH2_END; + } ++ #ifndef _M_AMD64 + _SEH2_END; ++ #endif + } + + /* +diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h +index c7bf663d1c8..95d5256f2c8 100644 +--- a/ntoskrnl/include/internal/mm.h ++++ b/ntoskrnl/include/internal/mm.h +@@ -868,7 +868,8 @@ MmDeleteKernelStack(PVOID Stack, + + /* balance.c / pagefile.c******************************************************/ + +-inline VOID UpdateTotalCommittedPages(LONG Delta) ++FORCEINLINE ++VOID UpdateTotalCommittedPages(LONG Delta) + { + /* + * Add up all the used "Committed" memory + pagefile. +diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake +index 1bef231351f..10ca85a37ec 100644 +--- a/ntoskrnl/ntos.cmake ++++ b/ntoskrnl/ntos.cmake +@@ -1,3 +1,4 @@ ++add_compile_options(-O0) + + include_directories( + ${REACTOS_SOURCE_DIR} +diff --git a/sdk/cmake/baseaddress.cmake b/sdk/cmake/baseaddress.cmake +index 02ad613b9b9..fa58958bbb2 100644 +--- a/sdk/cmake/baseaddress.cmake ++++ b/sdk/cmake/baseaddress.cmake +@@ -1,8 +1,8 @@ + # Generated from output-MinGW-i386/ + # Generated by sdk/tools/gen_baseaddress.py + +-set(baseaddress_ntdll 0x7c920000) # should be above 0x7c920000 +-set(baseaddress_kernel32 0x7c620000) ++set(baseaddress_ntdll 0x7c800000) # should be above 0x7c920000 ++set(baseaddress_kernel32 0x77e40000) + set(baseaddress_msvcrt 0x7c530000) + set(baseaddress_advapi32 0x7c470000) + set(baseaddress_gdi32 0x7c210000) +diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c +index dec55f7d3a5..a3413b3c56d 100644 +--- a/sdk/lib/rtl/amd64/unwind.c ++++ b/sdk/lib/rtl/amd64/unwind.c +@@ -847,6 +847,9 @@ RtlpUnwindInternal( + + /* We have successfully unwound a frame. Copy the unwind context back. */ + *ContextRecord = UnwindContext; ++ #ifdef _M_AMD64 ++ return TRUE; ++ #endif + } + + if (ExceptionRecord->ExceptionCode != STATUS_UNWIND_CONSOLIDATE) diff --git a/GCC8x64-2new.patch b/GCC8x64-2new.patch new file mode 100644 index 00000000000..2a35878aae9 --- /dev/null +++ b/GCC8x64-2new.patch @@ -0,0 +1,106 @@ +diff --git a/dll/win32/advapi32/service/eventlog.c b/dll/win32/advapi32/service/eventlog.c +index 028e5d234ce..3ba4bee8e97 100644 +--- a/dll/win32/advapi32/service/eventlog.c ++++ b/dll/win32/advapi32/service/eventlog.c +@@ -94,6 +94,9 @@ EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName, + handle_t __RPC_USER + EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName) + { ++ #ifdef _M_AMD64 ++ return NULL; ++ #endif + handle_t hBinding = NULL; + RPC_WSTR pszStringBinding; + RPC_STATUS status; +diff --git a/dll/win32/kernel32/client/debugger.c b/dll/win32/kernel32/client/debugger.c +index a466296f451..9d5529f4dc8 100644 +--- a/dll/win32/kernel32/client/debugger.c ++++ b/dll/win32/kernel32/client/debugger.c +@@ -692,6 +692,7 @@ VOID + WINAPI + OutputDebugStringA(IN LPCSTR _OutputString) + { ++ #ifndef _M_AMD64 + _SEH2_TRY + { + ULONG_PTR a_nArgs[2]; +@@ -703,6 +704,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) ++ #endif + { + /* no user-mode debugger: try the systemwide debug message monitor, or the + kernel debugger as a last resort */ +@@ -740,6 +742,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + + _SEH2_TRY + { ++ DPRINT1("SIMONE 1\n"); + volatile PCHAR a_cBuffer = NULL; + + /* opening the mutex failed */ +@@ -790,6 +793,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + + _SEH2_TRY + { ++ DPRINT1("SIMONE 1\n"); + /* size of the current output block */ + volatile SIZE_T nRoundLen; + +@@ -885,6 +889,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) + } + _SEH2_FINALLY + { ++ DPRINT1("SIMONE 2\n"); + /* close all the still open resources */ + if (hDBMonBufferReady) CloseHandle(hDBMonBufferReady); + if (pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer); +@@ -897,7 +902,9 @@ OutputDebugStringA(IN LPCSTR _OutputString) + } + _SEH2_END; + } ++ #ifndef _M_AMD64 + _SEH2_END; ++ #endif + } + + /* +diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake +index 1bef231351f..10ca85a37ec 100644 +--- a/ntoskrnl/ntos.cmake ++++ b/ntoskrnl/ntos.cmake +@@ -1,3 +1,4 @@ ++add_compile_options(-O0) + + include_directories( + ${REACTOS_SOURCE_DIR} +diff --git a/sdk/cmake/baseaddress.cmake b/sdk/cmake/baseaddress.cmake +index 02ad613b9b9..fa58958bbb2 100644 +--- a/sdk/cmake/baseaddress.cmake ++++ b/sdk/cmake/baseaddress.cmake +@@ -1,8 +1,8 @@ + # Generated from output-MinGW-i386/ + # Generated by sdk/tools/gen_baseaddress.py + +-set(baseaddress_ntdll 0x7c920000) # should be above 0x7c920000 +-set(baseaddress_kernel32 0x7c620000) ++set(baseaddress_ntdll 0x7c800000) # should be above 0x7c920000 ++set(baseaddress_kernel32 0x77e40000) + set(baseaddress_msvcrt 0x7c530000) + set(baseaddress_advapi32 0x7c470000) + set(baseaddress_gdi32 0x7c210000) +diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c +index dec55f7d3a5..a3413b3c56d 100644 +--- a/sdk/lib/rtl/amd64/unwind.c ++++ b/sdk/lib/rtl/amd64/unwind.c +@@ -847,6 +847,9 @@ RtlpUnwindInternal( + + /* We have successfully unwound a frame. Copy the unwind context back. */ + *ContextRecord = UnwindContext; ++ #ifdef _M_AMD64 ++ return TRUE; ++ #endif + } + + if (ExceptionRecord->ExceptionCode != STATUS_UNWIND_CONSOLIDATE) diff --git a/sdk/cmake/baseaddress_gcc_x64.cmake b/sdk/cmake/baseaddress_gcc_x64.cmake new file mode 100644 index 00000000000..14b957fdee2 --- /dev/null +++ b/sdk/cmake/baseaddress_gcc_x64.cmake @@ -0,0 +1,384 @@ +# Generated from /reactos/output-MinGW-amd64 +# Generated by sdk/tools/gen_baseaddress.py + +set(baseaddress_ntdll 0x7c920000) # should be above 0x7c920000 +set(baseaddress_kernel32 0x7c500000) +set(baseaddress_msvcrt 0x7c280000) +set(baseaddress_advapi32 0x7c100000) +set(baseaddress_gdi32 0x7bf60000) +set(baseaddress_user32 0x77a20000) # reserved +set(baseaddress_dhcpcsvc 0x7bee0000) +set(baseaddress_dnsapi 0x7be10000) +set(baseaddress_icmp 0x7bdd0000) +set(baseaddress_iphlpapi 0x7bd40000) +set(baseaddress_ws2_32 0x7bc90000) +set(baseaddress_ws2help 0x7bc50000) +set(baseaddress_shlwapi 0x7ba60000) +set(baseaddress_rpcrt4 0x7b890000) +set(baseaddress_comctl32 0x7b540000) +set(baseaddress_ole32 0x7b120000) +set(baseaddress_winspool 0x7b020000) +set(baseaddress_winmm 0x7af20000) +set(baseaddress_comdlg32 0x7ad80000) +set(baseaddress_shell32 0x79ba0000) +set(baseaddress_lz32 0x79b80000) +set(baseaddress_version 0x79b30000) +set(baseaddress_oleaut32 0x797f0000) +set(baseaddress_setupapi 0x79540000) +set(baseaddress_mpr 0x794d0000) +set(baseaddress_crypt32 0x792c0000) +set(baseaddress_wininet 0x79110000) +set(baseaddress_urlmon 0x78ed0000) +set(baseaddress_psapi 0x78e90000) +set(baseaddress_imm32 0x78df0000) +set(baseaddress_msvfw32 0x78d80000) +set(baseaddress_dbghelp 0x78c00000) +set(baseaddress_devmgr 0x78a30000) +set(baseaddress_msacm32 0x789c0000) +set(baseaddress_netapi32 0x78890000) +set(baseaddress_powrprof 0x78840000) +set(baseaddress_secur32 0x787a0000) +set(baseaddress_wintrust 0x78700000) +set(baseaddress_avicap32 0x786c0000) +set(baseaddress_cabinet 0x78630000) +set(baseaddress_dsound 0x78520000) +set(baseaddress_glu32 0x78320000) +set(baseaddress_opengl32 0x780e0000) +set(baseaddress_riched20 0x77f50000) +set(baseaddress_userenv 0x77eb0000) +set(baseaddress_uxtheme 0x77e00000) +set(baseaddress_cryptui 0x77d10000) +set(baseaddress_csrsrv 0x779d0000) +set(baseaddress_basesrv 0x77990000) +set(baseaddress_winsrv 0x77840000) +set(baseaddress_dplayx 0x77750000) +set(baseaddress_gdiplus 0x77520000) +set(baseaddress_msimg32 0x774e0000) +set(baseaddress_mswsock 0x77490000) +set(baseaddress_oledlg 0x77420000) +set(baseaddress_rasapi32 0x773c0000) +set(baseaddress_rsaenh 0x77310000) +set(baseaddress_samlib 0x772b0000) +set(baseaddress_sensapi 0x77270000) +set(baseaddress_sfc_os 0x77230000) +set(baseaddress_snmpapi 0x771e0000) +set(baseaddress_spoolss 0x77170000) +set(baseaddress_usp10 0x77090000) +set(baseaddress_access 0x76ff0000) +set(baseaddress_acgenral 0x76fc0000) +set(baseaddress_aclayers 0x76f70000) +set(baseaddress_acledit 0x76f30000) +set(baseaddress_aclui 0x76ec0000) +set(baseaddress_acppage 0x76df0000) +set(baseaddress_activeds 0x76da0000) +set(baseaddress_actxprxy 0x76a40000) +set(baseaddress_advapi32_vista 0x76a10000) +set(baseaddress_advpack 0x769a0000) +set(baseaddress_amstream 0x768c0000) +set(baseaddress_apphelp 0x76840000) +set(baseaddress_appwiz 0x76780000) +set(baseaddress_atl 0x766f0000) +set(baseaddress_atl100 0x76660000) +set(baseaddress_atl80 0x765d0000) +set(baseaddress_authz 0x76590000) +set(baseaddress_avifil32 0x764a0000) +set(baseaddress_batt 0x76460000) +set(baseaddress_bcrypt 0x76410000) +set(baseaddress_beepmidi 0x763d0000) +set(baseaddress_browser 0x76380000) +set(baseaddress_browseui 0x75df0000) +set(baseaddress_bthci 0x75db0000) +set(baseaddress_cards 0x75ce0000) +set(baseaddress_cfgmgr32 0x75ca0000) +set(baseaddress_clb 0x75c60000) +set(baseaddress_clusapi 0x75c10000) +set(baseaddress_cmicpl 0x75bc0000) +set(baseaddress_comcat 0x75b80000) +set(baseaddress_compstui 0x75b40000) +set(baseaddress_console 0x75ac0000) +set(baseaddress_credui 0x75a60000) +set(baseaddress_cryptdlg 0x75a10000) +set(baseaddress_cryptdll 0x759d0000) +set(baseaddress_cryptext 0x75990000) +set(baseaddress_cryptnet 0x75940000) +set(baseaddress_d3d8 0x75870000) +set(baseaddress_d3d8thk 0x75850000) +set(baseaddress_d3d9 0x75750000) +set(baseaddress_d3dcompiler_43 0x75600000) +set(baseaddress_d3drm 0x75480000) +set(baseaddress_d3dwine 0x75050000) +set(baseaddress_d3dx9_24 0x74db0000) +set(baseaddress_d3dx9_25 0x74b10000) +set(baseaddress_d3dx9_26 0x74860000) +set(baseaddress_d3dx9_27 0x745b0000) +set(baseaddress_d3dx9_28 0x74300000) +set(baseaddress_d3dx9_29 0x74050000) +set(baseaddress_d3dx9_30 0x73da0000) +set(baseaddress_d3dx9_31 0x73af0000) +set(baseaddress_d3dx9_32 0x73840000) +set(baseaddress_d3dx9_33 0x73590000) +set(baseaddress_d3dx9_34 0x732e0000) +set(baseaddress_d3dx9_35 0x73030000) +set(baseaddress_d3dx9_36 0x72d80000) +set(baseaddress_d3dx9_37 0x72ad0000) +set(baseaddress_d3dx9_38 0x72820000) +set(baseaddress_d3dx9_39 0x72570000) +set(baseaddress_d3dx9_40 0x722c0000) +set(baseaddress_d3dx9_41 0x72010000) +set(baseaddress_d3dx9_42 0x71d60000) +set(baseaddress_d3dx9_43 0x71ab0000) +set(baseaddress_d3dxof 0x71a30000) +set(baseaddress_dbgeng 0x71990000) +set(baseaddress_dciman32 0x71950000) +set(baseaddress_dcomlaunch 0x71910000) +set(baseaddress_ddraw 0x71770000) +set(baseaddress_desk 0x715f0000) +set(baseaddress_deskadp 0x71590000) +set(baseaddress_deskmon 0x71530000) +set(baseaddress_devcpux 0x714f0000) +set(baseaddress_devenum 0x71460000) +set(baseaddress_dinput 0x71390000) +set(baseaddress_dinput8 0x712c0000) +set(baseaddress_dmusic 0x71210000) +set(baseaddress_dnsrslvr 0x711d0000) +set(baseaddress_dplay 0x71190000) +set(baseaddress_dpnhpast 0x71150000) +set(baseaddress_dxdiagn 0x710c0000) +set(baseaddress_dxtn 0x71090000) +set(baseaddress_esent 0x71040000) +set(baseaddress_faultrep 0x71000000) +set(baseaddress_fltlib 0x70fc0000) +set(baseaddress_fmifs 0x70f90000) +set(baseaddress_fontext 0x70e80000) +set(baseaddress_fontsub 0x70e40000) +set(baseaddress_framedyn 0x70df0000) +set(baseaddress_gdi32_vista 0x70dc0000) +set(baseaddress_getuname 0x70c10000) +set(baseaddress_halmp 0x709a0000) +set(baseaddress_hdwwiz 0x70910000) +set(baseaddress_hhctrl 0x70850000) +set(baseaddress_hid 0x707f0000) +set(baseaddress_hlink 0x70770000) +set(baseaddress_hnetcfg 0x706d0000) +set(baseaddress_hotplug 0x70690000) +set(baseaddress_httpapi 0x70650000) +set(baseaddress_iccvid 0x70600000) +set(baseaddress_ieframe 0x703e0000) +set(baseaddress_iernonce 0x70350000) +set(baseaddress_imaadp32.acm 0x70300000) +set(baseaddress_imagehlp 0x702b0000) +set(baseaddress_inetcomm 0x701b0000) +set(baseaddress_inetcpl 0x70120000) +set(baseaddress_inetmib1 0x700d0000) +set(baseaddress_initpki 0x70090000) +set(baseaddress_input 0x6fff0000) +set(baseaddress_inseng 0x6ff70000) +set(baseaddress_intl 0x6fed0000) +set(baseaddress_iologmsg 0x6feb0000) +set(baseaddress_itircl 0x6fe70000) +set(baseaddress_itss 0x6fdf0000) +set(baseaddress_joy 0x6fd90000) +set(baseaddress_jscript 0x6f9e0000) +set(baseaddress_jsproxy 0x6f990000) +set(baseaddress_kbsdll 0x6f950000) +set(baseaddress_kernel32_vista 0x6f920000) +set(baseaddress_ksuser 0x6f8e0000) +set(baseaddress_libjpeg 0x6f7c0000) +set(baseaddress_libpng 0x6f690000) +set(baseaddress_libtiff 0x6f4c0000) +set(baseaddress_libtirpc 0x6f340000) +set(baseaddress_libxslt 0x6ee10000) +set(baseaddress_loadperf 0x6edd0000) +set(baseaddress_localmon 0x6ed80000) +set(baseaddress_localspl 0x6ecc0000) +set(baseaddress_localui 0x6ec70000) +set(baseaddress_lpk 0x6ec30000) +set(baseaddress_lsasrv 0x6eb50000) +set(baseaddress_main 0x6ea30000) +set(baseaddress_mapi32 0x6e9a0000) +set(baseaddress_mbedtls 0x6e850000) +set(baseaddress_mciavi32 0x6e7e0000) +set(baseaddress_mcicda 0x6e790000) +set(baseaddress_mciqtz32 0x6e720000) +set(baseaddress_mciseq 0x6e6d0000) +set(baseaddress_mciwave 0x6e680000) +set(baseaddress_mgmtapi 0x6e640000) +set(baseaddress_midimap 0x6e600000) +set(baseaddress_mlang 0x6e580000) +set(baseaddress_mmdrv 0x6e540000) +set(baseaddress_mmsys 0x6e430000) +set(baseaddress_modemui 0x6e3a0000) +set(baseaddress_mprapi 0x6e350000) +set(baseaddress_msacm32.drv 0x6e300000) +set(baseaddress_msadp32.acm 0x6e2c0000) +set(baseaddress_msafd 0x6e250000) +set(baseaddress_mscat32 0x6e210000) +set(baseaddress_mscms 0x6e1b0000) +set(baseaddress_mscoree 0x6e0f0000) +set(baseaddress_msctf 0x6e000000) +set(baseaddress_msdmo 0x6dfb0000) +set(baseaddress_msftedit 0x6df70000) +set(baseaddress_msg711.acm 0x6df30000) +set(baseaddress_msgina 0x6de10000) +set(baseaddress_msgsm32.acm 0x6ddd0000) +set(baseaddress_mshtml 0x6d4d0000) +set(baseaddress_msi 0x6d0c0000) +set(baseaddress_msimtf 0x6d060000) +set(baseaddress_msisip 0x6d020000) +set(baseaddress_msisys 0x6cfe0000) +set(baseaddress_mspatcha 0x6cf90000) +set(baseaddress_msports 0x6cf30000) +set(baseaddress_msrle32 0x6cee0000) +set(baseaddress_mssign32 0x6cea0000) +set(baseaddress_mssip32 0x6ce60000) +set(baseaddress_mstask 0x6cdf0000) +set(baseaddress_msv1_0 0x6cda0000) +set(baseaddress_msvcrt20 0x6cb20000) +set(baseaddress_msvcrt40 0x6c8a0000) +set(baseaddress_msvidc32 0x6c850000) +set(baseaddress_msxml 0x6c800000) +set(baseaddress_msxml2 0x6c7b0000) +set(baseaddress_msxml3 0x6bff0000) +set(baseaddress_msxml3r 0x6bfd0000) +set(baseaddress_msxml4 0x6bf70000) +set(baseaddress_msxml6 0x6bf10000) +set(baseaddress_mycomput 0x6bef0000) +set(baseaddress_mydocs 0x6be50000) +set(baseaddress_ncpa 0x6be10000) +set(baseaddress_nddeapi 0x6bdc0000) +set(baseaddress_netcfgx 0x6bcc0000) +set(baseaddress_netevent 0x6bc90000) +set(baseaddress_netid 0x6bc20000) +set(baseaddress_netlogon 0x6bbd0000) +set(baseaddress_netmsg 0x6ba50000) +set(baseaddress_netplwiz 0x6ba10000) +set(baseaddress_netshell 0x6b890000) +set(baseaddress_newdev 0x6b810000) +set(baseaddress_nfs41_np 0x6b7c0000) +set(baseaddress_normaliz 0x6b790000) +set(baseaddress_npptools 0x6b750000) +set(baseaddress_ntdll_vista 0x6b710000) +set(baseaddress_ntdsapi 0x6b6c0000) +set(baseaddress_ntlanman 0x6b680000) +set(baseaddress_ntmarta 0x6b640000) +set(baseaddress_ntobjshex 0x6b500000) +set(baseaddress_ntprint 0x6b4b0000) +set(baseaddress_objsel 0x6b450000) +set(baseaddress_odbc32 0x6b3d0000) +set(baseaddress_odbccp32 0x6b370000) +set(baseaddress_odbccp32i 0x6b330000) +set(baseaddress_oleacc 0x6b270000) +set(baseaddress_olecli32 0x6b220000) +set(baseaddress_olepro32 0x6b1e0000) +set(baseaddress_olesvr32 0x6b1a0000) +set(baseaddress_olethk32 0x6b160000) +set(baseaddress_openglcfg 0x6b120000) +set(baseaddress_pdh 0x6b0c0000) +set(baseaddress_pidgen 0x6b080000) +set(baseaddress_pifmgr 0x6b010000) +set(baseaddress_powercfg 0x6af60000) +set(baseaddress_printui 0x6af20000) +set(baseaddress_profmap 0x6aee0000) +set(baseaddress_propsys 0x6ae60000) +set(baseaddress_pstorec 0x6ae10000) +set(baseaddress_qcap 0x6acd0000) +set(baseaddress_qedit 0x6ac10000) +set(baseaddress_qmgr 0x6ab90000) +set(baseaddress_qmgrprxy 0x6aaf0000) +set(baseaddress_quartz 0x6a720000) +set(baseaddress_query 0x6a6d0000) +set(baseaddress_rasadhlp 0x6a690000) +set(baseaddress_rasdlg 0x6a490000) +set(baseaddress_rasman 0x6a440000) +set(baseaddress_regapi 0x6a3f0000) +set(baseaddress_resutils 0x6a3a0000) +set(baseaddress_riched32 0x6a360000) +set(baseaddress_rsabase 0x6a340000) +set(baseaddress_samsrv 0x6a270000) +set(baseaddress_sccbase 0x6a230000) +set(baseaddress_schannel 0x6a1c0000) +set(baseaddress_schedsvc 0x6a170000) +set(baseaddress_scrrun 0x6a0c0000) +set(baseaddress_seclogon 0x6a070000) +set(baseaddress_security 0x6a050000) +set(baseaddress_sendmail 0x69fb0000) +set(baseaddress_serialui 0x69f70000) +set(baseaddress_sfc 0x69f30000) +set(baseaddress_sfcfiles 0x69ef0000) +set(baseaddress_shdoclc 0x69eb0000) +set(baseaddress_shdocvw 0x69e00000) +set(baseaddress_shellbtrfs 0x699c0000) +set(baseaddress_shfolder 0x699a0000) +set(baseaddress_shimgvw 0x69930000) +set(baseaddress_shsvcs 0x698e0000) +set(baseaddress_slbcsp 0x698a0000) +set(baseaddress_sndblst 0x69840000) +set(baseaddress_softpub 0x69820000) +set(baseaddress_srclient 0x697e0000) +set(baseaddress_srvsvc 0x69790000) +set(baseaddress_sti 0x69720000) +set(baseaddress_stobject 0x695f0000) +set(baseaddress_storprop 0x695b0000) +set(baseaddress_streamci 0x69570000) +set(baseaddress_sxs 0x69510000) +set(baseaddress_sysdm 0x69390000) +set(baseaddress_syssetup 0x691f0000) +set(baseaddress_t2embed 0x691b0000) +set(baseaddress_tapi32 0x69140000) +set(baseaddress_tapiui 0x690b0000) +set(baseaddress_telephon 0x69070000) +set(baseaddress_themeui 0x69050000) +set(baseaddress_timedate 0x68fb0000) +set(baseaddress_traffic 0x68f70000) +set(baseaddress_twain_32 0x68f20000) +set(baseaddress_ubtrfs 0x68ed0000) +set(baseaddress_ucdfs 0x68ea0000) +set(baseaddress_uext2 0x68e50000) +set(baseaddress_ufat 0x68df0000) +set(baseaddress_ufatx 0x68dc0000) +set(baseaddress_umandlg 0x68d70000) +set(baseaddress_umpnpmgr 0x68d00000) +set(baseaddress_untfs 0x68cd0000) +set(baseaddress_updspapi 0x68c90000) +set(baseaddress_url 0x68c50000) +set(baseaddress_usrmgr 0x68bd0000) +set(baseaddress_vbscript 0x68a80000) +set(baseaddress_vdmdbg 0x68a40000) +set(baseaddress_verifier 0x68a10000) +set(baseaddress_vssapi 0x689c0000) +set(baseaddress_w32time 0x68980000) +set(baseaddress_wbemdisp 0x688f0000) +set(baseaddress_wbemprox 0x687f0000) +set(baseaddress_wdmaud.drv 0x685c0000) +set(baseaddress_windowscodecs 0x682b0000) +set(baseaddress_windowscodecsext 0x68260000) +set(baseaddress_wined3dcfg 0x68220000) +set(baseaddress_winemp3.acm 0x68120000) +set(baseaddress_winfax 0x680e0000) +set(baseaddress_wing32 0x680a0000) +set(baseaddress_winhttp 0x67fd0000) +set(baseaddress_winprint 0x67f90000) +set(baseaddress_winscard 0x67f40000) +set(baseaddress_winsta 0x67ef0000) +set(baseaddress_wkssvc 0x67ea0000) +set(baseaddress_wlanapi 0x67e50000) +set(baseaddress_wldap32 0x67de0000) +set(baseaddress_wlnotify 0x67d90000) +set(baseaddress_wmi 0x67d70000) +set(baseaddress_wmisvc 0x67d30000) +set(baseaddress_wmiutils 0x67cd0000) +set(baseaddress_wmvcore 0x67c40000) +set(baseaddress_wshirda 0x67c00000) +set(baseaddress_wshom 0x67b80000) +set(baseaddress_wshtcpip 0x67b40000) +set(baseaddress_wsock32 0x67b00000) +set(baseaddress_wtsapi32 0x67ab0000) +set(baseaddress_wuapi 0x67a30000) +set(baseaddress_wuauserv 0x679f0000) +set(baseaddress_xinput1_1 0x679b0000) +set(baseaddress_xinput1_2 0x67970000) +set(baseaddress_xinput1_3 0x67930000) +set(baseaddress_xinput9_1_0 0x678f0000) +set(baseaddress_xmllite 0x67860000) +set(baseaddress_xolehlp 0x67810000) +set(baseaddress_zipfldr 0x67550000) From 398045f98ec79237cff965311dcd50502711bf62 Mon Sep 17 00:00:00 2001 From: Julen Urizar Compains Date: Tue, 24 Oct 2023 15:14:35 +0200 Subject: [PATCH 12/33] Add BaseAdress_gcc_x64.cmake and use it in the CMakeLists fixed --- CMakeLists.txt | 1 + GCC8x64-2.patch | 120 --------------------------------------------- GCC8x64-2new.patch | 106 --------------------------------------- 3 files changed, 1 insertion(+), 226 deletions(-) delete mode 100644 GCC8x64-2.patch delete mode 100644 GCC8x64-2new.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 025b44dc9a9..e63bf96fded 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -350,6 +350,7 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to else() include(sdk/cmake/baseaddress.cmake) endif() + endif() # For MSVC builds, this puts all debug symbols file in the same directory. if(MSVC) diff --git a/GCC8x64-2.patch b/GCC8x64-2.patch deleted file mode 100644 index 2d13a7a3438..00000000000 --- a/GCC8x64-2.patch +++ /dev/null @@ -1,120 +0,0 @@ -diff --git a/dll/win32/advapi32/service/eventlog.c b/dll/win32/advapi32/service/eventlog.c -index 028e5d234ce..3ba4bee8e97 100644 ---- a/dll/win32/advapi32/service/eventlog.c -+++ b/dll/win32/advapi32/service/eventlog.c -@@ -94,6 +94,9 @@ EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName, - handle_t __RPC_USER - EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName) - { -+ #ifdef _M_AMD64 -+ return NULL; -+ #endif - handle_t hBinding = NULL; - RPC_WSTR pszStringBinding; - RPC_STATUS status; -diff --git a/dll/win32/kernel32/client/debugger.c b/dll/win32/kernel32/client/debugger.c -index a466296f451..9d5529f4dc8 100644 ---- a/dll/win32/kernel32/client/debugger.c -+++ b/dll/win32/kernel32/client/debugger.c -@@ -692,6 +692,7 @@ VOID - WINAPI - OutputDebugStringA(IN LPCSTR _OutputString) - { -+ #ifndef _M_AMD64 - _SEH2_TRY - { - ULONG_PTR a_nArgs[2]; -@@ -703,6 +704,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) -+ #endif - { - /* no user-mode debugger: try the systemwide debug message monitor, or the - kernel debugger as a last resort */ -@@ -740,6 +742,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - - _SEH2_TRY - { -+ DPRINT1("SIMONE 1\n"); - volatile PCHAR a_cBuffer = NULL; - - /* opening the mutex failed */ -@@ -790,6 +793,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - - _SEH2_TRY - { -+ DPRINT1("SIMONE 1\n"); - /* size of the current output block */ - volatile SIZE_T nRoundLen; - -@@ -885,6 +889,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - } - _SEH2_FINALLY - { -+ DPRINT1("SIMONE 2\n"); - /* close all the still open resources */ - if (hDBMonBufferReady) CloseHandle(hDBMonBufferReady); - if (pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer); -@@ -897,7 +902,9 @@ OutputDebugStringA(IN LPCSTR _OutputString) - } - _SEH2_END; - } -+ #ifndef _M_AMD64 - _SEH2_END; -+ #endif - } - - /* -diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h -index c7bf663d1c8..95d5256f2c8 100644 ---- a/ntoskrnl/include/internal/mm.h -+++ b/ntoskrnl/include/internal/mm.h -@@ -868,7 +868,8 @@ MmDeleteKernelStack(PVOID Stack, - - /* balance.c / pagefile.c******************************************************/ - --inline VOID UpdateTotalCommittedPages(LONG Delta) -+FORCEINLINE -+VOID UpdateTotalCommittedPages(LONG Delta) - { - /* - * Add up all the used "Committed" memory + pagefile. -diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake -index 1bef231351f..10ca85a37ec 100644 ---- a/ntoskrnl/ntos.cmake -+++ b/ntoskrnl/ntos.cmake -@@ -1,3 +1,4 @@ -+add_compile_options(-O0) - - include_directories( - ${REACTOS_SOURCE_DIR} -diff --git a/sdk/cmake/baseaddress.cmake b/sdk/cmake/baseaddress.cmake -index 02ad613b9b9..fa58958bbb2 100644 ---- a/sdk/cmake/baseaddress.cmake -+++ b/sdk/cmake/baseaddress.cmake -@@ -1,8 +1,8 @@ - # Generated from output-MinGW-i386/ - # Generated by sdk/tools/gen_baseaddress.py - --set(baseaddress_ntdll 0x7c920000) # should be above 0x7c920000 --set(baseaddress_kernel32 0x7c620000) -+set(baseaddress_ntdll 0x7c800000) # should be above 0x7c920000 -+set(baseaddress_kernel32 0x77e40000) - set(baseaddress_msvcrt 0x7c530000) - set(baseaddress_advapi32 0x7c470000) - set(baseaddress_gdi32 0x7c210000) -diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c -index dec55f7d3a5..a3413b3c56d 100644 ---- a/sdk/lib/rtl/amd64/unwind.c -+++ b/sdk/lib/rtl/amd64/unwind.c -@@ -847,6 +847,9 @@ RtlpUnwindInternal( - - /* We have successfully unwound a frame. Copy the unwind context back. */ - *ContextRecord = UnwindContext; -+ #ifdef _M_AMD64 -+ return TRUE; -+ #endif - } - - if (ExceptionRecord->ExceptionCode != STATUS_UNWIND_CONSOLIDATE) diff --git a/GCC8x64-2new.patch b/GCC8x64-2new.patch deleted file mode 100644 index 2a35878aae9..00000000000 --- a/GCC8x64-2new.patch +++ /dev/null @@ -1,106 +0,0 @@ -diff --git a/dll/win32/advapi32/service/eventlog.c b/dll/win32/advapi32/service/eventlog.c -index 028e5d234ce..3ba4bee8e97 100644 ---- a/dll/win32/advapi32/service/eventlog.c -+++ b/dll/win32/advapi32/service/eventlog.c -@@ -94,6 +94,9 @@ EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName, - handle_t __RPC_USER - EVENTLOG_HANDLE_W_bind(EVENTLOG_HANDLE_W UNCServerName) - { -+ #ifdef _M_AMD64 -+ return NULL; -+ #endif - handle_t hBinding = NULL; - RPC_WSTR pszStringBinding; - RPC_STATUS status; -diff --git a/dll/win32/kernel32/client/debugger.c b/dll/win32/kernel32/client/debugger.c -index a466296f451..9d5529f4dc8 100644 ---- a/dll/win32/kernel32/client/debugger.c -+++ b/dll/win32/kernel32/client/debugger.c -@@ -692,6 +692,7 @@ VOID - WINAPI - OutputDebugStringA(IN LPCSTR _OutputString) - { -+ #ifndef _M_AMD64 - _SEH2_TRY - { - ULONG_PTR a_nArgs[2]; -@@ -703,6 +704,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - RaiseException(DBG_PRINTEXCEPTION_C, 0, 2, a_nArgs); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) -+ #endif - { - /* no user-mode debugger: try the systemwide debug message monitor, or the - kernel debugger as a last resort */ -@@ -740,6 +742,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - - _SEH2_TRY - { -+ DPRINT1("SIMONE 1\n"); - volatile PCHAR a_cBuffer = NULL; - - /* opening the mutex failed */ -@@ -790,6 +793,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - - _SEH2_TRY - { -+ DPRINT1("SIMONE 1\n"); - /* size of the current output block */ - volatile SIZE_T nRoundLen; - -@@ -885,6 +889,7 @@ OutputDebugStringA(IN LPCSTR _OutputString) - } - _SEH2_FINALLY - { -+ DPRINT1("SIMONE 2\n"); - /* close all the still open resources */ - if (hDBMonBufferReady) CloseHandle(hDBMonBufferReady); - if (pDBMonBuffer) UnmapViewOfFile(pDBMonBuffer); -@@ -897,7 +902,9 @@ OutputDebugStringA(IN LPCSTR _OutputString) - } - _SEH2_END; - } -+ #ifndef _M_AMD64 - _SEH2_END; -+ #endif - } - - /* -diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake -index 1bef231351f..10ca85a37ec 100644 ---- a/ntoskrnl/ntos.cmake -+++ b/ntoskrnl/ntos.cmake -@@ -1,3 +1,4 @@ -+add_compile_options(-O0) - - include_directories( - ${REACTOS_SOURCE_DIR} -diff --git a/sdk/cmake/baseaddress.cmake b/sdk/cmake/baseaddress.cmake -index 02ad613b9b9..fa58958bbb2 100644 ---- a/sdk/cmake/baseaddress.cmake -+++ b/sdk/cmake/baseaddress.cmake -@@ -1,8 +1,8 @@ - # Generated from output-MinGW-i386/ - # Generated by sdk/tools/gen_baseaddress.py - --set(baseaddress_ntdll 0x7c920000) # should be above 0x7c920000 --set(baseaddress_kernel32 0x7c620000) -+set(baseaddress_ntdll 0x7c800000) # should be above 0x7c920000 -+set(baseaddress_kernel32 0x77e40000) - set(baseaddress_msvcrt 0x7c530000) - set(baseaddress_advapi32 0x7c470000) - set(baseaddress_gdi32 0x7c210000) -diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c -index dec55f7d3a5..a3413b3c56d 100644 ---- a/sdk/lib/rtl/amd64/unwind.c -+++ b/sdk/lib/rtl/amd64/unwind.c -@@ -847,6 +847,9 @@ RtlpUnwindInternal( - - /* We have successfully unwound a frame. Copy the unwind context back. */ - *ContextRecord = UnwindContext; -+ #ifdef _M_AMD64 -+ return TRUE; -+ #endif - } - - if (ExceptionRecord->ExceptionCode != STATUS_UNWIND_CONSOLIDATE) From ab199cc147afab56d975d100ebbc5816e5993aed Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 02:35:49 +0900 Subject: [PATCH 13/33] [MSPAINT] Show out-of-memory message (#5817) - Improve ImageModel::PushImageForUndo. - Use FormatMessage in newly added ShowOutOfMemory function. - Call ShowOutOfMemory() when out of memory. CORE-19227, CORE-19094 --- base/applications/mspaint/common.h | 1 + base/applications/mspaint/dib.cpp | 3 +++ base/applications/mspaint/history.cpp | 31 +++++++++++++++++++++------ base/applications/mspaint/history.h | 3 ++- base/applications/mspaint/main.cpp | 12 +++++++++++ 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/base/applications/mspaint/common.h b/base/applications/mspaint/common.h index 3dda6703441..125a9cb53a6 100644 --- a/base/applications/mspaint/common.h +++ b/base/applications/mspaint/common.h @@ -43,6 +43,7 @@ enum HITTEST // hit /* FUNCTIONS ********************************************************/ +void ShowOutOfMemory(void); BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1); BOOL OpenMailer(HWND hWnd, LPCWSTR pszPathName); diff --git a/base/applications/mspaint/dib.cpp b/base/applications/mspaint/dib.cpp index eede3325c55..2c13cc2f785 100644 --- a/base/applications/mspaint/dib.cpp +++ b/base/applications/mspaint/dib.cpp @@ -228,7 +228,10 @@ HBITMAP InitializeImage(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile) COLORREF white = RGB(255, 255, 255); HBITMAP hBitmap = CreateColorDIB(registrySettings.BMPWidth, registrySettings.BMPHeight, white); if (hBitmap == NULL) + { + ShowOutOfMemory(); return NULL; + } HDC hScreenDC = ::GetDC(NULL); g_xDpi = (float)::GetDeviceCaps(hScreenDC, LOGPIXELSX); diff --git a/base/applications/mspaint/history.cpp b/base/applications/mspaint/history.cpp index 2d28cb5def2..003d0ab5877 100644 --- a/base/applications/mspaint/history.cpp +++ b/base/applications/mspaint/history.cpp @@ -116,13 +116,31 @@ void ImageModel::ClearHistory() m_redoSteps = 0; } +void ImageModel::PushImageForUndo() +{ + HBITMAP hbm = CopyBitmap(); + if (hbm) + { + ShowOutOfMemory(); + return; + } + + PushImageForUndo(hbm); +} + void ImageModel::PushImageForUndo(HBITMAP hbm) { ATLTRACE("%s: %d\n", __FUNCTION__, m_currInd); + if (hbm == NULL) + { + ShowOutOfMemory(); + return; + } + // Go to the next item with an HBITMAP or current item ::DeleteObject(m_hBms[(m_currInd + 1) % HISTORYSIZE]); - m_hBms[(m_currInd + 1) % HISTORYSIZE] = (hbm ? hbm : CopyDIBImage(m_hBms[m_currInd])); + m_hBms[(m_currInd + 1) % HISTORYSIZE] = hbm; m_currInd = (m_currInd + 1) % HISTORYSIZE; ::SelectObject(m_hDrawingDC, m_hBms[m_currInd]); @@ -145,7 +163,10 @@ void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY) // Create an HBITMAP HBITMAP hbmCropped = CreateDIBWithProperties(nWidth, nHeight); if (!hbmCropped) + { + ShowOutOfMemory(); return; + } // Select the HBITMAP by memory DC HDC hdcMem = ::CreateCompatibleDC(m_hDrawingDC); @@ -251,8 +272,7 @@ void ImageModel::RotateNTimes90Degrees(int iN) case 3: { HBITMAP hbm = Rotate90DegreeBlt(m_hDrawingDC, GetWidth(), GetHeight(), iN == 1, FALSE); - if (hbm) - PushImageForUndo(hbm); + PushImageForUndo(hbm); break; } case 2: @@ -294,8 +314,7 @@ void ImageModel::PushBlackAndWhite() HBITMAP hNewBitmap = ConvertToBlackAndWhite(hBitmap); UnlockBitmap(hBitmap); - if (hNewBitmap) - PushImageForUndo(hNewBitmap); + PushImageForUndo(hNewBitmap); } HBITMAP ImageModel::LockBitmap() @@ -319,7 +338,7 @@ void ImageModel::SelectionClone(BOOL bUndoable) return; if (bUndoable) - PushImageForUndo(CopyBitmap()); + PushImageForUndo(); selectionModel.DrawSelection(m_hDrawingDC, paletteModel.GetBgColor(), toolsModel.IsBackgroundTransparent()); diff --git a/base/applications/mspaint/history.h b/base/applications/mspaint/history.h index 24f1e09cd13..093dd1c34dd 100644 --- a/base/applications/mspaint/history.h +++ b/base/applications/mspaint/history.h @@ -19,7 +19,8 @@ class ImageModel HDC GetDC(); BOOL CanUndo() const { return m_undoSteps > 0; } BOOL CanRedo() const { return m_redoSteps > 0; } - void PushImageForUndo(HBITMAP hbm = NULL); + void PushImageForUndo(); + void PushImageForUndo(HBITMAP hbm); void ResetToPrevious(void); void Undo(BOOL bClearRedo = FALSE); void Redo(void); diff --git a/base/applications/mspaint/main.cpp b/base/applications/mspaint/main.cpp index ac1a037ddae..63db53f02de 100644 --- a/base/applications/mspaint/main.cpp +++ b/base/applications/mspaint/main.cpp @@ -22,6 +22,18 @@ CMainWindow mainWindow; /* FUNCTIONS ********************************************************/ +void ShowOutOfMemory(void) +{ + WCHAR szText[256]; + ::FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + ERROR_OUTOFMEMORY, + 0, + szText, _countof(szText), + NULL); + mainWindow.MessageBox(szText, NULL, MB_ICONERROR); +} + // get file name extension from filter string static BOOL FileExtFromFilter(LPTSTR pExt, OPENFILENAME *pOFN) From 6d701b4b05c465e1e01abd911949c9645e193f0f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 9 Oct 2023 21:39:35 +0300 Subject: [PATCH 14/33] [NTOS:MM] Add ASSERTS to MmLockAddressSpace to guarantee lock ordering --- ntoskrnl/include/internal/mm.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index f637014794a..d1dad7a25c1 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -1690,6 +1690,12 @@ FORCEINLINE VOID MmLockAddressSpace(PMMSUPPORT AddressSpace) { + ASSERT(!PsGetCurrentThread()->OwnsProcessWorkingSetExclusive); + ASSERT(!PsGetCurrentThread()->OwnsProcessWorkingSetShared); + ASSERT(!PsGetCurrentThread()->OwnsSystemWorkingSetExclusive); + ASSERT(!PsGetCurrentThread()->OwnsSystemWorkingSetShared); + ASSERT(!PsGetCurrentThread()->OwnsSessionWorkingSetExclusive); + ASSERT(!PsGetCurrentThread()->OwnsSessionWorkingSetShared); KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock); } From a8b57f0a6ba6061ce810290b7d8e64ac5b73e7f3 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 9 Oct 2023 22:01:56 +0300 Subject: [PATCH 15/33] [NTOS:MM] Fix address space locking in MiProtectVirtualMemory --- ntoskrnl/mm/ARM3/virtual.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ntoskrnl/mm/ARM3/virtual.c b/ntoskrnl/mm/ARM3/virtual.c index e0804520435..ec081c8110d 100644 --- a/ntoskrnl/mm/ARM3/virtual.c +++ b/ntoskrnl/mm/ARM3/virtual.c @@ -2213,6 +2213,9 @@ MiProtectVirtualMemory(IN PEPROCESS Process, PETHREAD Thread = PsGetCurrentThread(); TABLE_SEARCH_RESULT Result; + /* We must be attached */ + ASSERT(Process == PsGetCurrentProcess()); + /* Calculate base address for the VAD */ StartingAddress = (ULONG_PTR)PAGE_ALIGN((*BaseAddress)); EndingAddress = (((ULONG_PTR)*BaseAddress + *NumberOfBytesToProtect - 1) | (PAGE_SIZE - 1)); @@ -2225,11 +2228,22 @@ MiProtectVirtualMemory(IN PEPROCESS Process, return STATUS_INVALID_PAGE_PROTECTION; } + /* Lock the address space and make sure the process isn't already dead */ + AddressSpace = MmGetCurrentAddressSpace(); + MmLockAddressSpace(AddressSpace); + if (Process->VmDeleted) + { + DPRINT1("Process is dying\n"); + Status = STATUS_PROCESS_IS_TERMINATING; + goto FailPath; + } + /* Check for ROS specific memory area */ MemoryArea = MmLocateMemoryAreaByAddress(&Process->Vm, *BaseAddress); if ((MemoryArea) && (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3)) { /* Evil hack */ + MmUnlockAddressSpace(AddressSpace); return MiRosProtectVirtualMemory(Process, BaseAddress, NumberOfBytesToProtect, @@ -2237,16 +2251,6 @@ MiProtectVirtualMemory(IN PEPROCESS Process, OldAccessProtection); } - /* Lock the address space and make sure the process isn't already dead */ - AddressSpace = MmGetCurrentAddressSpace(); - MmLockAddressSpace(AddressSpace); - if (Process->VmDeleted) - { - DPRINT1("Process is dying\n"); - Status = STATUS_PROCESS_IS_TERMINATING; - goto FailPath; - } - /* Get the VAD for this address range, and make sure it exists */ Result = MiCheckForConflictingNode(StartingAddress >> PAGE_SHIFT, EndingAddress >> PAGE_SHIFT, From 84d0586ca40c21ae4d2b3a68137bc3e88423d463 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 10 Oct 2023 22:37:21 +0300 Subject: [PATCH 16/33] [NTOS:MM] Handle page table faults in MmArmAccessFault MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These faults are handled by ARM³ and we don't need to check for a memory area. They can be recursive faults (e.g. from MiDeleteSystemPageableVm), so we might be holding the WS lock already. Passing it straight to ARM³ allows to acquire the WS lock below to look up the memory area. --- ntoskrnl/mm/mmfault.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/mm/mmfault.c b/ntoskrnl/mm/mmfault.c index 7937f7b5e5b..68e31ba1281 100644 --- a/ntoskrnl/mm/mmfault.c +++ b/ntoskrnl/mm/mmfault.c @@ -227,11 +227,12 @@ MmAccessFault(IN ULONG FaultCode, #endif } - /* Handle shared user page, which doesn't have a VAD / MemoryArea */ - if (PAGE_ALIGN(Address) == (PVOID)MM_SHARED_USER_DATA_VA) + /* Handle shared user page / page table, which don't have a VAD / MemoryArea */ + if ((PAGE_ALIGN(Address) == (PVOID)MM_SHARED_USER_DATA_VA) || + MI_IS_PAGE_TABLE_ADDRESS(Address)) { /* This is an ARM3 fault */ - DPRINT("ARM3 fault %p\n", MemoryArea); + DPRINT("ARM3 fault %p\n", Address); return MmArmAccessFault(FaultCode, Address, Mode, TrapInformation); } From a662bedab8310ac4c15e1337e584e5f5835d14f5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 10 Oct 2023 02:10:52 +0300 Subject: [PATCH 17/33] [NTOS:MM] Fix bugs in MmAccessFault - Acquire the appropriate working set lock when calling MmLocateMemoryAreaByAddress - Do not access MemoryArea without holding the lock (otherwise it can be pulled away under our feet) - Fix range check for paged pool --- ntoskrnl/mm/mmfault.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/mm/mmfault.c b/ntoskrnl/mm/mmfault.c index 68e31ba1281..cfd6d756d15 100644 --- a/ntoskrnl/mm/mmfault.c +++ b/ntoskrnl/mm/mmfault.c @@ -213,6 +213,7 @@ MmAccessFault(IN ULONG FaultCode, { PMEMORY_AREA MemoryArea = NULL; NTSTATUS Status; + BOOLEAN IsArm3Fault = FALSE; /* Cute little hack for ROS */ if ((ULONG_PTR)Address >= (ULONG_PTR)MmSystemRangeStart) @@ -239,19 +240,40 @@ MmAccessFault(IN ULONG FaultCode, /* Is there a ReactOS address space yet? */ if (MmGetKernelAddressSpace()) { - /* Check if this is an ARM3 memory area */ - MemoryArea = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(), Address); - if (!(MemoryArea) && (Address <= MM_HIGHEST_USER_ADDRESS)) + if (Address > MM_HIGHEST_USER_ADDRESS) + { + /* Check if this is an ARM3 memory area */ + MiLockWorkingSetShared(PsGetCurrentThread(), &MmSystemCacheWs); + MemoryArea = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(), Address); + + if ((MemoryArea != NULL) && (MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3)) + { + IsArm3Fault = TRUE; + } + + MiUnlockWorkingSetShared(PsGetCurrentThread(), &MmSystemCacheWs); + } + else { /* Could this be a VAD fault from user-mode? */ + MiLockProcessWorkingSetShared(PsGetCurrentProcess(), PsGetCurrentThread()); MemoryArea = MmLocateMemoryAreaByAddress(MmGetCurrentAddressSpace(), Address); + + if ((MemoryArea != NULL) && (MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3)) + { + IsArm3Fault = TRUE; + } + + MiUnlockProcessWorkingSetShared(PsGetCurrentProcess(), PsGetCurrentThread()); } } /* Is this an ARM3 memory area, or is there no address space yet? */ - if (((MemoryArea) && (MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3)) || - (!(MemoryArea) && ((ULONG_PTR)Address >= (ULONG_PTR)MmPagedPoolStart)) || - (!MmGetKernelAddressSpace())) + if (IsArm3Fault || + ((MemoryArea == NULL) && + ((ULONG_PTR)Address >= (ULONG_PTR)MmPagedPoolStart) && + ((ULONG_PTR)Address < (ULONG_PTR)MmPagedPoolEnd)) || + (!MmGetKernelAddressSpace())) { /* This is an ARM3 fault */ DPRINT("ARM3 fault %p\n", MemoryArea); From de3958dc2b626626d017be102c04eb75b3cce56d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 10 Oct 2023 02:42:11 +0300 Subject: [PATCH 18/33] Revert "[NTOS:MM/x64] Temporarily release AddressCreationLock in MmCreateVirtualMappingUnsafeEx" This reverts commit e685b25e35c9d6dfbe2139ac71f7378b1f9e6d0f. --- ntoskrnl/mm/i386/page.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c index eeccef94346..df13cb013e2 100644 --- a/ntoskrnl/mm/i386/page.c +++ b/ntoskrnl/mm/i386/page.c @@ -637,9 +637,6 @@ MmCreateVirtualMappingUnsafeEx( PMMPTE PointerPte; MMPTE TempPte; ULONG_PTR Pte; -#ifdef _M_AMD64 - BOOLEAN LockReleased = FALSE; -#endif DPRINT("MmCreateVirtualMappingUnsafe(%p, %p, %lu, %x)\n", Process, Address, flProtect, Page); @@ -668,15 +665,6 @@ MmCreateVirtualMappingUnsafeEx( if (!MiSynchronizeSystemPde(MiAddressToPde(Address))) MiFillSystemPageDirectory(Address, PAGE_SIZE); #endif - -#ifdef _M_AMD64 - /* This is a temporary hack, because we can incur a recursive page fault when accessing the PDE */ - if (PsIdleProcess->AddressCreationLock.Owner == KeGetCurrentThread()) - { - MmUnlockAddressSpace(MmGetKernelAddressSpace()); - LockReleased = TRUE; - } -#endif } else { @@ -727,15 +715,6 @@ MmCreateVirtualMappingUnsafeEx( MiIncrementPageTableReferences(Address); MiUnlockProcessWorkingSetUnsafe(Process, PsGetCurrentThread()); } -#ifdef _M_AMD64 - else - { - if (LockReleased) - { - MmLockAddressSpace(MmGetKernelAddressSpace()); - } - } -#endif return(STATUS_SUCCESS); } From 601bb49c0d276447fd6435a8f70cc0f190db681a Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 9 Oct 2023 22:24:01 +0300 Subject: [PATCH 19/33] [NTOS:MM] Fix MmFreeMemoryArea - Stay attached while deleting the VAD node - Acquire the appropriate working set lock when deleting a VAD node - Both are needed for locking correctness --- ntoskrnl/mm/marea.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c index ab8bff4a18e..281226c4afc 100644 --- a/ntoskrnl/mm/marea.c +++ b/ntoskrnl/mm/marea.c @@ -300,8 +300,7 @@ MmFreeMemoryArea( PEPROCESS CurrentProcess = PsGetCurrentProcess(); PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace); - if (Process != NULL && - Process != CurrentProcess) + if ((Process != NULL) && (Process != CurrentProcess)) { KeAttachProcess(&Process->Pcb); } @@ -337,12 +336,6 @@ MmFreeMemoryArea( } } - if (Process != NULL && - Process != CurrentProcess) - { - KeDetachProcess(); - } - //if (MemoryArea->VadNode.StartingVpn < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT if (MemoryArea->Vad) { @@ -357,14 +350,23 @@ MmFreeMemoryArea( ASSERT(MemoryArea->VadNode.u.VadFlags.Spare != 0); if (((PMMVAD)MemoryArea->Vad)->u.VadFlags.Spare == 1) { + MiLockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread()); MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &Process->VadRoot); + MiUnlockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread()); } MemoryArea->Vad = NULL; } else { + MiLockWorkingSet(PsGetCurrentThread(), &MmSystemCacheWs); MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &MiRosKernelVadRoot); + MiUnlockWorkingSet(PsGetCurrentThread(), &MmSystemCacheWs); + } + + if ((Process != NULL) && (Process != CurrentProcess)) + { + KeDetachProcess(); } } From 07ad8c4c11d72f9603cef8ad667664a7ce9a44f6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 9 Oct 2023 21:45:01 +0300 Subject: [PATCH 20/33] [NTOS:MM] Attach to the target process in MmMapViewOfSection This is required to satisfy VAD locking rules. --- ntoskrnl/mm/section.c | 49 +++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 35c36d45cfa..ff77ef77077 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -4008,6 +4008,8 @@ MmMapViewOfSection(IN PVOID SectionObject, PMMSUPPORT AddressSpace; NTSTATUS Status = STATUS_SUCCESS; BOOLEAN NotAtBase = FALSE; + BOOLEAN IsAttached = FALSE; + KAPC_STATE ApcState; if (MiIsRosSectionObject(SectionObject) == FALSE) { @@ -4031,6 +4033,12 @@ MmMapViewOfSection(IN PVOID SectionObject, return STATUS_INVALID_PAGE_PROTECTION; } + if (PsGetCurrentProcess() != Process) + { + KeStackAttachProcess(&Process->Pcb, &ApcState); + IsAttached = TRUE; + } + /* FIXME: We should keep this, but it would break code checking equality */ Protect &= ~PAGE_NOCACHE; @@ -4097,15 +4105,15 @@ MmMapViewOfSection(IN PVOID SectionObject, /* Fail if the user requested a fixed base address. */ if ((*BaseAddress) != NULL) { - MmUnlockAddressSpace(AddressSpace); - return STATUS_CONFLICTING_ADDRESSES; + Status = STATUS_CONFLICTING_ADDRESSES; + goto Exit; } /* Otherwise find a gap to map the image. */ ImageBase = (ULONG_PTR)MmFindGap(AddressSpace, PAGE_ROUND_UP(ImageSize), MM_VIRTMEM_GRANULARITY, FALSE); if (ImageBase == 0) { - MmUnlockAddressSpace(AddressSpace); - return STATUS_CONFLICTING_ADDRESSES; + Status = STATUS_CONFLICTING_ADDRESSES; + goto Exit; } /* Remember that we loaded image at a different base address */ NotAtBase = TRUE; @@ -4136,8 +4144,7 @@ MmMapViewOfSection(IN PVOID SectionObject, MmUnlockSectionSegment(&SectionSegments[i]); } - MmUnlockAddressSpace(AddressSpace); - return Status; + goto Exit; } } @@ -4160,22 +4167,22 @@ MmMapViewOfSection(IN PVOID SectionObject, if ((Protect & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE)) && !(Section->InitialPageProtection & (PAGE_READWRITE|PAGE_EXECUTE_READWRITE))) { - MmUnlockAddressSpace(AddressSpace); - return STATUS_SECTION_PROTECTION; + Status = STATUS_SECTION_PROTECTION; + goto Exit; } /* check for read access */ if ((Protect & (PAGE_READONLY|PAGE_WRITECOPY|PAGE_EXECUTE_READ|PAGE_EXECUTE_WRITECOPY)) && !(Section->InitialPageProtection & (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY))) { - MmUnlockAddressSpace(AddressSpace); - return STATUS_SECTION_PROTECTION; + Status = STATUS_SECTION_PROTECTION; + goto Exit; } /* check for execute access */ if ((Protect & (PAGE_EXECUTE|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY)) && !(Section->InitialPageProtection & (PAGE_EXECUTE|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY))) { - MmUnlockAddressSpace(AddressSpace); - return STATUS_SECTION_PROTECTION; + Status = STATUS_SECTION_PROTECTION; + goto Exit; } if (SectionOffset == NULL) @@ -4189,8 +4196,8 @@ MmMapViewOfSection(IN PVOID SectionObject, if ((ViewOffset % PAGE_SIZE) != 0) { - MmUnlockAddressSpace(AddressSpace); - return STATUS_MAPPED_ALIGNMENT; + Status = STATUS_MAPPED_ALIGNMENT; + goto Exit; } if ((*ViewSize) == 0) @@ -4219,18 +4226,24 @@ MmMapViewOfSection(IN PVOID SectionObject, MmUnlockSectionSegment(Segment); if (!NT_SUCCESS(Status)) { - MmUnlockAddressSpace(AddressSpace); - return Status; + goto Exit; } } - MmUnlockAddressSpace(AddressSpace); - if (NotAtBase) Status = STATUS_IMAGE_NOT_AT_BASE; else Status = STATUS_SUCCESS; +Exit: + + MmUnlockAddressSpace(AddressSpace); + + if (IsAttached) + { + KeUnstackDetachProcess(&ApcState); + } + return Status; } From 23589e9bf14afe5763a1fede921b1f67ef949246 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 10 Oct 2023 02:33:53 +0300 Subject: [PATCH 21/33] [NTOS:MM] Lock kernel address space in MiInitSystemMemoryAreas This is required to satisfy VAD locking rules. --- ntoskrnl/mm/mminit.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/mm/mminit.c b/ntoskrnl/mm/mminit.c index 3e58ad9bbc8..009383992b7 100644 --- a/ntoskrnl/mm/mminit.c +++ b/ntoskrnl/mm/mminit.c @@ -1,4 +1,4 @@ -/* +/* * PROJECT: ReactOS Kernel * LICENSE: GPL - See COPYING in the top level directory * FILE: ntoskrnl/mm/mminit.c @@ -68,6 +68,8 @@ MiInitSystemMemoryAreas(VOID) // Create all the static memory areas. // + MmLockAddressSpace(MmGetKernelAddressSpace()); + #ifdef _M_AMD64 // Reserved range FFFF800000000000 - FFFFF68000000000 MiCreateArm3StaticMemoryArea((PVOID)MI_REAL_SYSTEM_RANGE_START, PTE_BASE - MI_REAL_SYSTEM_RANGE_START, FALSE); @@ -118,6 +120,8 @@ MiInitSystemMemoryAreas(VOID) // KUSER_SHARED_DATA MiCreateArm3StaticMemoryArea((PVOID)KI_USER_SHARED_DATA, PAGE_SIZE, FALSE); #endif /* _X86_ */ + + MmUnlockAddressSpace(MmGetKernelAddressSpace()); } CODE_SEG("INIT") From d831bc4fab38300e36765cf591059c8fd5752926 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 10 Oct 2023 02:41:19 +0300 Subject: [PATCH 22/33] [NTOS:MM] Add ASSERTs for VAD table locking --- ntoskrnl/mm/ARM3/vadnode.c | 88 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/ntoskrnl/mm/ARM3/vadnode.c b/ntoskrnl/mm/ARM3/vadnode.c index 050e1c92235..53b8fa83dbd 100644 --- a/ntoskrnl/mm/ARM3/vadnode.c +++ b/ntoskrnl/mm/ARM3/vadnode.c @@ -43,6 +43,74 @@ CHAR MmReadWrite[32] = /* FUNCTIONS ******************************************************************/ +extern MM_AVL_TABLE MiRosKernelVadRoot; + +#if DBG + +static +VOID +MiDbgAssertIsLockedForRead(_In_ PMM_AVL_TABLE Table) +{ + if (Table == &MmSectionBasedRoot) + { + /* Need to hold MmSectionBasedMutex */ + ASSERT(MmSectionBasedMutex.Owner == KeGetCurrentThread()); + } + else if (Table == &MiRosKernelVadRoot) + { + /* Need to hold either the system working-set lock or + the idle process' AddressCreationLock */ + ASSERT(PsGetCurrentThread()->OwnsSystemWorkingSetExclusive || + PsGetCurrentThread()->OwnsSystemWorkingSetShared || + (PsIdleProcess->AddressCreationLock.Owner == KeGetCurrentThread())); + } + else + { + /* Need to hold either the process working-set lock or + the current process' AddressCreationLock */ + PEPROCESS Process = CONTAINING_RECORD(Table, EPROCESS, VadRoot); + ASSERT(MI_WS_OWNER(Process) || + (Process->AddressCreationLock.Owner == KeGetCurrentThread())); + } +} + +static +VOID +MiDbgAssertIsLockedForWrite(_In_ PMM_AVL_TABLE Table) +{ + if (Table == &MmSectionBasedRoot) + { + /* Need to hold MmSectionBasedMutex */ + ASSERT(MmSectionBasedMutex.Owner == KeGetCurrentThread()); + } + else if (Table == &MiRosKernelVadRoot) + { + /* Need to hold both the system working-set lock exclusive and + the idle process' AddressCreationLock */ + ASSERT(PsGetCurrentThread()->OwnsSystemWorkingSetExclusive); + ASSERT(PsIdleProcess->AddressCreationLock.Owner == KeGetCurrentThread()); + } + else + { + /* Need to hold both the process working-set lock exclusive and + the current process' AddressCreationLock */ + PEPROCESS Process = CONTAINING_RECORD(Table, EPROCESS, VadRoot); + ASSERT(Process == PsGetCurrentProcess()); + ASSERT(PsGetCurrentThread()->OwnsProcessWorkingSetExclusive); + ASSERT(Process->AddressCreationLock.Owner == KeGetCurrentThread()); + } +} + +#define ASSERT_LOCKED_FOR_READ(Table) MiDbgAssertIsLockedForRead(Table) +#define ASSERT_LOCKED_FOR_WRITE(Table) MiDbgAssertIsLockedForWrite(Table) + +#else // DBG + +#define ASSERT_LOCKED_FOR_READ(Table) +#define ASSERT_LOCKED_FOR_WRITE(Table) + +#endif // DBG + PMMVAD NTAPI MiLocateAddress(IN PVOID VirtualAddress) @@ -52,6 +120,8 @@ MiLocateAddress(IN PVOID VirtualAddress) PMM_AVL_TABLE Table = &PsGetCurrentProcess()->VadRoot; TABLE_SEARCH_RESULT SearchResult; + ASSERT_LOCKED_FOR_READ(Table); + /* Start with the the hint */ FoundVad = (PMMVAD)Table->NodeHint; if (!FoundVad) return NULL; @@ -69,6 +139,8 @@ MiLocateAddress(IN PVOID VirtualAddress) /* We found it, update the hint */ ASSERT(FoundVad != NULL); ASSERT((Vpn >= FoundVad->StartingVpn) && (Vpn <= FoundVad->EndingVpn)); + + /* We allow this (atomic) update without exclusive lock, because it's a hint only */ Table->NodeHint = FoundVad; return FoundVad; } @@ -82,6 +154,8 @@ MiCheckForConflictingNode(IN ULONG_PTR StartVpn, { PMMADDRESS_NODE ParentNode, CurrentNode; + ASSERT_LOCKED_FOR_READ(Table); + /* If the tree is empty, there is no conflict */ if (Table->NumberGenericTableElements == 0) return TableEmptyTree; @@ -132,6 +206,8 @@ MiInsertNode(IN PMM_AVL_TABLE Table, { PMMVAD_LONG Vad; + ASSERT_LOCKED_FOR_WRITE(Table); + /* Insert it into the tree */ RtlpInsertAvlTreeNode(Table, NewNode, Parent, Result); @@ -186,6 +262,8 @@ MiInsertVad(IN PMMVAD Vad, TABLE_SEARCH_RESULT Result; PMMADDRESS_NODE Parent = NULL; + ASSERT_LOCKED_FOR_WRITE(VadRoot); + /* Validate the VAD and set it as the current hint */ ASSERT(Vad->EndingVpn >= Vad->StartingVpn); VadRoot->NodeHint = Vad; @@ -348,6 +426,8 @@ MiInsertBasedSection(IN PSECTION Section) PMMADDRESS_NODE Parent = NULL; ASSERT(Section->Address.EndingVpn >= Section->Address.StartingVpn); + ASSERT_LOCKED_FOR_WRITE(&MmSectionBasedRoot); + /* Find the parent VAD and where this child should be inserted */ Result = RtlpFindAvlTableNodeOrParent(&MmSectionBasedRoot, (PVOID)Section->Address.StartingVpn, &Parent); ASSERT(Result != TableFoundNode); @@ -362,6 +442,8 @@ MiRemoveNode(IN PMMADDRESS_NODE Node, { PMMVAD_LONG Vad; + ASSERT_LOCKED_FOR_WRITE(Table); + /* Call the AVL code */ RtlpDeleteAvlTreeNode(Table, Node); @@ -509,6 +591,8 @@ MiFindEmptyAddressRangeInTree(IN SIZE_T Length, ULONG_PTR PageCount, AlignmentVpn, LowVpn, HighestVpn; ASSERT(Length != 0); + ASSERT_LOCKED_FOR_READ(Table); + /* Calculate page numbers for the length, alignment, and starting address */ PageCount = BYTES_TO_PAGES(Length); AlignmentVpn = Alignment >> PAGE_SHIFT; @@ -605,6 +689,8 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, ULONG_PTR LowVpn, HighVpn, AlignmentVpn; PFN_NUMBER PageCount; + ASSERT_LOCKED_FOR_READ(Table); + /* Sanity checks */ ASSERT(BoundaryAddress); ASSERT(BoundaryAddress <= ((ULONG_PTR)MM_HIGHEST_VAD_ADDRESS)); @@ -719,6 +805,8 @@ MiFindEmptyAddressRangeDownBasedTree(IN SIZE_T Length, PMMADDRESS_NODE Node, LowestNode; ULONG_PTR LowVpn, BestVpn; + ASSERT_LOCKED_FOR_READ(Table); + /* Sanity checks */ ASSERT(Table == &MmSectionBasedRoot); ASSERT(BoundaryAddress); From 9360423cc22d1b5a8f064895ba2390edc6dea045 Mon Sep 17 00:00:00 2001 From: Joachim Henze Date: Tue, 24 Oct 2023 22:59:28 +0200 Subject: [PATCH 23/33] [SYSSETUP] syssetup.rc improve URLs (#5810) Reformat those URLs in a way that allows new lines to be added, or existing lines to be removed or changed, without the need to touch any neighbor line. This will also allow git blame to work much better in the future. Fix outdated URLs: http://www.icu-project.org -> http://icu.unicode.org https://fedorahosted.org/liberation-fonts -> http://pagure.io/liberation-fonts I checked: all of the URLs do still work as good as before. * Update ext2fsd links in syssetup.rc and media/doc --- dll/win32/syssetup/syssetup.rc | 17 ++++++++++++++++- media/doc/3rd Party Files.txt | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dll/win32/syssetup/syssetup.rc b/dll/win32/syssetup/syssetup.rc index 77cec6efc3b..206e9a0c206 100644 --- a/dll/win32/syssetup/syssetup.rc +++ b/dll/win32/syssetup/syssetup.rc @@ -33,7 +33,22 @@ IDI_ICON5 ICON "resources/5.ico" STRINGTABLE BEGIN - IDS_ACKPROJECTS "Wine - http://www.winehq.org\nFreeType - http://www.freetype.org\nSYSLINUX - http://syslinux.zytor.com\nMinGW - http://www.mingw.org\nBochs - http://bochs.sourceforge.net\nMesa3D - http://www.mesa3d.org\nadns - http://www.gnu.org/software/adns\nICU - http://www.icu-project.org/\nGraphApp - http://enchantia.com/software/graphapp/\nExt2 - http://www.ext2fsd.com/\nGNU FreeFont - http://savannah.gnu.org/projects/freefont/\nDejaVu Fonts - http://dejavu.sourceforge.net\nLiberation(tm) Fonts - https://fedorahosted.org/liberation-fonts/\nBtrfs - https://github.com/maharmstone/btrfs\nTango Desktop Project - http://tango.freedesktop.org/Tango_Desktop_Project" + IDS_ACKPROJECTS "Wine - http://winehq.org\ +\nFreeType - http://freetype.org\ +\nSYSLINUX - http://syslinux.zytor.com\ +\nMinGW - http://mingw.org\ +\nBochs - http://bochs.sourceforge.net\ +\nMesa3D - http://mesa3d.org\ +\nadns - http://gnu.org/software/adns\ +\nICU - http://icu.unicode.org\ +\nGraphApp - http://enchantia.com/software/graphapp\ +\nExt2 - http://sourceforge.net/projects/ext2fsd\ +\nGNU FreeFont - http://savannah.gnu.org/projects/freefont\ +\nDejaVu Fonts - http://dejavu.sourceforge.net\ +\nLiberation(tm) Fonts - http://pagure.io/liberation-fonts\ +\nBtrfs - https://github.com/maharmstone/btrfs\ +\nTango Desktop Project - http://tango.freedesktop.org/Tango_Desktop_Project\ +" END IDR_GPL RT_TEXT "COPYING" diff --git a/media/doc/3rd Party Files.txt b/media/doc/3rd Party Files.txt index f1633295bfa..b39199a5cd6 100644 --- a/media/doc/3rd Party Files.txt +++ b/media/doc/3rd Party Files.txt @@ -93,7 +93,8 @@ Path: drivers/filesystems/ext2 Path: sdk/lib/fslib/ext2lib Used Version: 0.69 License: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later.html) -URL: http://www.ext2fsd.com +URL: https://web.archive.org/web/20210516213924/http://www.ext2fsd.com +URL: https://sourceforge.net/projects/ext2fsd Title: NFSv4.1 Client for Windows Path: base/services/nfsd From 149b27cc9afc9c8d5de43734db1fd67e944454d5 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Mon, 23 Oct 2023 08:02:06 +0900 Subject: [PATCH 24/33] [SHELL32] Fix CDefView::InvokeContextMenuCommand for copyto/moveto --- dll/win32/shell32/CDefView.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 9f12fd09549..82fc6152389 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -1519,7 +1519,12 @@ HRESULT CDefView::InvokeContextMenuCommand(CComPtr &pCM, UINT uCom ZeroMemory(&cmi, sizeof(cmi)); cmi.cbSize = sizeof(cmi); - cmi.lpVerb = MAKEINTRESOURCEA(uCommand); + if (uCommand == FCIDM_SHVIEW_COPYTO) + cmi.lpVerb = "copyto"; + if (uCommand == FCIDM_SHVIEW_MOVETO) + cmi.lpVerb = "moveto"; + else + cmi.lpVerb = MAKEINTRESOURCEA(uCommand); cmi.hwnd = m_hWnd; if (GetKeyState(VK_SHIFT) & 0x8000) From 876acb8dbe60d8577ad2f0772d000c7b3535069e Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Mon, 23 Oct 2023 08:05:51 +0900 Subject: [PATCH 25/33] fix --- dll/win32/shell32/CDefView.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 82fc6152389..a941c65c7cd 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -1519,13 +1519,14 @@ HRESULT CDefView::InvokeContextMenuCommand(CComPtr &pCM, UINT uCom ZeroMemory(&cmi, sizeof(cmi)); cmi.cbSize = sizeof(cmi); + cmi.hwnd = m_hWnd; + if (uCommand == FCIDM_SHVIEW_COPYTO) cmi.lpVerb = "copyto"; - if (uCommand == FCIDM_SHVIEW_MOVETO) + else if (uCommand == FCIDM_SHVIEW_MOVETO) cmi.lpVerb = "moveto"; else cmi.lpVerb = MAKEINTRESOURCEA(uCommand); - cmi.hwnd = m_hWnd; if (GetKeyState(VK_SHIFT) & 0x8000) cmi.fMask |= CMIC_MASK_SHIFT_DOWN; From e491bdff8c578931270882428ff6030b6048e9af Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 09:31:02 +0900 Subject: [PATCH 26/33] big fix --- dll/win32/shell32/CDefView.cpp | 53 ++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index a941c65c7cd..740f8dcb857 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -163,6 +163,7 @@ class CDefView : INT _FindInsertableIndexFromPoint(POINT pt); void _HandleStatusBarResize(int width); void _ForceStatusBarResize(); + void _DoCopyToMoveToFolder(BOOL bCopy); public: CDefView(); @@ -197,7 +198,7 @@ class CDefView : void OnDeactivate(); void DoActivate(UINT uState); HRESULT drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - HRESULT InvokeContextMenuCommand(CComPtr &pCM, UINT uCommand, POINT* pt); + HRESULT InvokeContextMenuCommand(CComPtr &pCM, LPCSTR lpVerb, POINT* pt = NULL); LRESULT OnExplorerCommand(UINT uCommand, BOOL bUseSelection); // *** IOleWindow methods *** @@ -1513,20 +1514,14 @@ UINT CDefView::GetSelections() return m_cidl; } -HRESULT CDefView::InvokeContextMenuCommand(CComPtr &pCM, UINT uCommand, POINT* pt) +HRESULT CDefView::InvokeContextMenuCommand(CComPtr &pCM, LPCSTR lpVerb, POINT* pt) { CMINVOKECOMMANDINFOEX cmi; ZeroMemory(&cmi, sizeof(cmi)); cmi.cbSize = sizeof(cmi); cmi.hwnd = m_hWnd; - - if (uCommand == FCIDM_SHVIEW_COPYTO) - cmi.lpVerb = "copyto"; - else if (uCommand == FCIDM_SHVIEW_MOVETO) - cmi.lpVerb = "moveto"; - else - cmi.lpVerb = MAKEINTRESOURCEA(uCommand); + cmi.lpVerb = lpVerb; if (GetKeyState(VK_SHIFT) & 0x8000) cmi.fMask |= CMIC_MASK_SHIFT_DOWN; @@ -1589,7 +1584,7 @@ HRESULT CDefView::OpenSelectedItems() return E_FAIL; } - InvokeContextMenuCommand(pCM, uCommand, NULL); + InvokeContextMenuCommand(pCM, MAKEINTRESOURCEA(uCommand), NULL); return hResult; } @@ -1688,7 +1683,7 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b if (uCommand == FCIDM_SHVIEW_OPEN && OnDefaultCommand() == S_OK) return 0; - InvokeContextMenuCommand(m_pCM, uCommand - CONTEXT_MENU_BASE_ID, &pt); + InvokeContextMenuCommand(m_pCM, MAKEINTRESOURCEA(uCommand - CONTEXT_MENU_BASE_ID), &pt); return 0; } @@ -1737,7 +1732,7 @@ LRESULT CDefView::OnExplorerCommand(UINT uCommand, BOOL bUseSelection) } // FIXME: We should probably use the objects position? - InvokeContextMenuCommand(pCM, uCommand, NULL); + InvokeContextMenuCommand(pCM, MAKEINTRESOURCEA(uCommand), NULL); return 0; } @@ -1824,6 +1819,29 @@ void CDefView::DoActivate(UINT uState) TRACE("--\n"); } +void CDefView::_DoCopyToMoveToFolder(BOOL bCopy) +{ + if (!GetSelections()) + return; + + SFGAOF rfg = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_FILESYSTEM; + HRESULT hr = m_pSFParent->GetAttributesOf(m_cidl, m_apidl, &rfg); + if (FAILED_UNEXPECTEDLY(hr)) + return; + + if (!bCopy && !(rfg & SFGAO_CANMOVE)) + return; + if (bCopy && !(rfg & SFGAO_CANCOPY)) + return; + + CComPtr pCM; + hr = m_pSFParent->GetUIObjectOf(m_hWnd, m_cidl, m_apidl, IID_IContextMenu, 0, (void **)&pCM); + if (FAILED_UNEXPECTEDLY(hr)) + return; + + InvokeContextMenuCommand(pCM, (bCopy ? "copyto" : "moveto"), NULL); +} + /********************************************************** * ShellView_OnActivate() */ @@ -1960,26 +1978,31 @@ LRESULT CDefView::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHand case FCIDM_SHVIEW_COPY: case FCIDM_SHVIEW_RENAME: case FCIDM_SHVIEW_PROPERTIES: - case FCIDM_SHVIEW_COPYTO: - case FCIDM_SHVIEW_MOVETO: if (SHRestricted(REST_NOVIEWCONTEXTMENU)) return 0; return OnExplorerCommand(dwCmdID, TRUE); + case FCIDM_SHVIEW_COPYTO: + case FCIDM_SHVIEW_MOVETO: + _DoCopyToMoveToFolder(dwCmdID == FCIDM_SHVIEW_COPYTO); + return 0; + case FCIDM_SHVIEW_INSERT: case FCIDM_SHVIEW_UNDO: case FCIDM_SHVIEW_INSERTLINK: case FCIDM_SHVIEW_NEWFOLDER: return OnExplorerCommand(dwCmdID, FALSE); default: + { /* WM_COMMAND messages from the file menu are routed to the CDefView so as to let m_pFileMenu handle the command */ if (m_pFileMenu && dwCmd == 0) { HMENU Dummy = NULL; MenuCleanup _(m_pFileMenu, Dummy); - InvokeContextMenuCommand(m_pFileMenu, dwCmdID, NULL); + InvokeContextMenuCommand(m_pFileMenu, MAKEINTRESOURCEA(dwCmdID), NULL); } + } } return 0; From 9ba32d51a7e70c536605126510b522db0ca1eb6e Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 09:37:04 +0900 Subject: [PATCH 27/33] small fix --- dll/win32/shell32/CDefView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp index 740f8dcb857..a06feb085b4 100644 --- a/dll/win32/shell32/CDefView.cpp +++ b/dll/win32/shell32/CDefView.cpp @@ -198,7 +198,7 @@ class CDefView : void OnDeactivate(); void DoActivate(UINT uState); HRESULT drag_notify_subitem(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - HRESULT InvokeContextMenuCommand(CComPtr &pCM, LPCSTR lpVerb, POINT* pt = NULL); + HRESULT InvokeContextMenuCommand(CComPtr& pCM, LPCSTR lpVerb, POINT* pt = NULL); LRESULT OnExplorerCommand(UINT uCommand, BOOL bUseSelection); // *** IOleWindow methods *** @@ -1514,7 +1514,7 @@ UINT CDefView::GetSelections() return m_cidl; } -HRESULT CDefView::InvokeContextMenuCommand(CComPtr &pCM, LPCSTR lpVerb, POINT* pt) +HRESULT CDefView::InvokeContextMenuCommand(CComPtr& pCM, LPCSTR lpVerb, POINT* pt) { CMINVOKECOMMANDINFOEX cmi; From 50b799ff396b83f53f4209a315a28f47b1e8f59e Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 11:35:52 +0900 Subject: [PATCH 28/33] [SDK] Add header to psdk --- sdk/include/psdk/pathcch.h | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 sdk/include/psdk/pathcch.h diff --git a/sdk/include/psdk/pathcch.h b/sdk/include/psdk/pathcch.h new file mode 100644 index 00000000000..0c2dc63c41b --- /dev/null +++ b/sdk/include/psdk/pathcch.h @@ -0,0 +1,50 @@ +/* + * Copyright 2017 Michael Müller + * + * 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 + */ + +#define PATHCCH_NONE 0x00 +#define PATHCCH_ALLOW_LONG_PATHS 0x01 +#define PATHCCH_FORCE_ENABLE_LONG_NAME_PROCESS 0x02 +#define PATHCCH_FORCE_DISABLE_LONG_NAME_PROCESS 0x04 +#define PATHCCH_DO_NOT_NORMALIZE_SEGMENTS 0x08 +#define PATHCCH_ENSURE_IS_EXTENDED_LENGTH_PATH 0x10 +#define PATHCCH_ENSURE_TRAILING_SLASH 0x20 + +#define PATHCCH_MAX_CCH 0x8000 + +HRESULT WINAPI PathAllocCanonicalize(const WCHAR *path_in, DWORD flags, WCHAR **path_out); +HRESULT WINAPI PathAllocCombine(const WCHAR *path1, const WCHAR *path2, DWORD flags, WCHAR **out); +HRESULT WINAPI PathCchAddBackslash(WCHAR *path, SIZE_T size); +HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **end, SIZE_T *remaining); +HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extension); +HRESULT WINAPI PathCchAppend(WCHAR *path1, SIZE_T size, const WCHAR *path2); +HRESULT WINAPI PathCchAppendEx(WCHAR *path1, SIZE_T size, const WCHAR *path2, DWORD flags); +HRESULT WINAPI PathCchCanonicalize(WCHAR *out, SIZE_T size, const WCHAR *in); +HRESULT WINAPI PathCchCanonicalizeEx(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags); +HRESULT WINAPI PathCchCombine(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2); +HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags); +HRESULT WINAPI PathCchFindExtension(const WCHAR *path, SIZE_T size, const WCHAR **extension); +BOOL WINAPI PathCchIsRoot(const WCHAR *path); +HRESULT WINAPI PathCchRemoveBackslash(WCHAR *path, SIZE_T path_size); +HRESULT WINAPI PathCchRemoveBackslashEx(WCHAR *path, SIZE_T path_size, WCHAR **path_end, SIZE_T *free_size); +HRESULT WINAPI PathCchRemoveExtension(WCHAR *path, SIZE_T size); +HRESULT WINAPI PathCchRemoveFileSpec(WCHAR *path, SIZE_T size); +HRESULT WINAPI PathCchRenameExtension(WCHAR *path, SIZE_T size, const WCHAR *extension); +HRESULT WINAPI PathCchSkipRoot(const WCHAR *path, const WCHAR **root_end); +HRESULT WINAPI PathCchStripPrefix(WCHAR *path, SIZE_T size); +HRESULT WINAPI PathCchStripToRoot(WCHAR *path, SIZE_T size); +BOOL WINAPI PathIsUNCEx(const WCHAR *path, const WCHAR **server); From 3992cb4e6223416b981413f28ebc697e1f99fadf Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 11:56:23 +0900 Subject: [PATCH 29/33] add pathcch.h sync --- sdk/tools/winesync/wininet.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/tools/winesync/wininet.cfg b/sdk/tools/winesync/wininet.cfg index b6f5a87e7f7..74aac7181ad 100644 --- a/sdk/tools/winesync/wininet.cfg +++ b/sdk/tools/winesync/wininet.cfg @@ -2,6 +2,7 @@ directories: dlls/wininet: dll/win32/wininet dlls/wininet/tests: modules/rostests/winetests/wininet files: + include/pathcch.h: sdk/include/psdk/pathcch.h include/wininet.h: sdk/include/psdk/wininet.h include/winineti.h: sdk/include/psdk/winineti.h tags: From d00e93c76625cd38abdb1b87737abfdb81228c93 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 11:58:43 +0900 Subject: [PATCH 30/33] add pathcch.h sync 2 --- sdk/tools/winesync/pathcch.cfg | 4 ++++ sdk/tools/winesync/wininet.cfg | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 sdk/tools/winesync/pathcch.cfg diff --git a/sdk/tools/winesync/pathcch.cfg b/sdk/tools/winesync/pathcch.cfg new file mode 100644 index 00000000000..9b1b01b6430 --- /dev/null +++ b/sdk/tools/winesync/pathcch.cfg @@ -0,0 +1,4 @@ +files: + include/pathcch.h: sdk/include/psdk/pathcch.h +tags: + wine: wine-8.18 diff --git a/sdk/tools/winesync/wininet.cfg b/sdk/tools/winesync/wininet.cfg index 74aac7181ad..b6f5a87e7f7 100644 --- a/sdk/tools/winesync/wininet.cfg +++ b/sdk/tools/winesync/wininet.cfg @@ -2,7 +2,6 @@ directories: dlls/wininet: dll/win32/wininet dlls/wininet/tests: modules/rostests/winetests/wininet files: - include/pathcch.h: sdk/include/psdk/pathcch.h include/wininet.h: sdk/include/psdk/wininet.h include/winineti.h: sdk/include/psdk/winineti.h tags: From 9f4a24f7eb318a5d902332cfcd007a0e47f8a6a8 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 12:01:35 +0900 Subject: [PATCH 31/33] add pathcch.h sync 3 --- sdk/tools/winesync/pathcch.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/tools/winesync/pathcch.cfg b/sdk/tools/winesync/pathcch.cfg index 9b1b01b6430..ec7445a8162 100644 --- a/sdk/tools/winesync/pathcch.cfg +++ b/sdk/tools/winesync/pathcch.cfg @@ -1,3 +1,4 @@ +directories: files: include/pathcch.h: sdk/include/psdk/pathcch.h tags: From 09100e7cbde39415a51df1601936c56734f62db8 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 16:44:24 +0900 Subject: [PATCH 32/33] [REGEDIT] Use functions strictly --- base/applications/regedit/childwnd.c | 9 +++++---- base/applications/regedit/edit.c | 26 ++++++++++++++------------ base/applications/regedit/find.c | 21 ++++++++++----------- base/applications/regedit/framewnd.c | 8 +++++--- base/applications/regedit/security.c | 3 +-- base/applications/regedit/txtproc.c | 5 +++-- 6 files changed, 38 insertions(+), 34 deletions(-) diff --git a/base/applications/regedit/childwnd.c b/base/applications/regedit/childwnd.c index 67a88bc90a5..d77ed1899b3 100644 --- a/base/applications/regedit/childwnd.c +++ b/base/applications/regedit/childwnd.c @@ -177,7 +177,7 @@ static void SuggestKeys(HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions RegCloseKey(hOtherKey); bFound = TRUE; - wcscpy(szLastFound, szBuffer); + StringCbCopyW(szLastFound, sizeof(szLastFound), szBuffer); pszKeyPath = szLastFound; } } @@ -258,10 +258,11 @@ UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath, BOOL bSelectNone) if (fullPath) { /* set (correct) the address bar text */ - if (keyPath[0] != L'\0') - swprintf(fullPath, L"%s%s%s", rootName, keyPath[0]==L'\\'?L"":L"\\", keyPath); + if (keyPath[0] != UNICODE_NULL) + StringCbPrintfW(fullPath, cbFullPath, L"%s%s%s", rootName, + ((keyPath[0] == L'\\') ? L"" : L"\\"), keyPath); else - fullPath = wcscpy(fullPath, rootName); + StringCbCopyW(fullPath, cbFullPath, rootName); SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath); SendMessageW(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath); diff --git a/base/applications/regedit/edit.c b/base/applications/regedit/edit.c index d84361c7a0a..8805ccb35e7 100644 --- a/base/applications/regedit/edit.c +++ b/base/applications/regedit/edit.c @@ -50,10 +50,10 @@ void error(HWND hwnd, INT resId, ...) hInstance = GetModuleHandle(0); if (!LoadStringW(hInstance, IDS_ERROR, title, ARRAY_SIZE(title))) - wcscpy(title, L"Error"); + StringCbCopyW(title, sizeof(title), L"Error"); if (!LoadStringW(hInstance, resId, errfmt, ARRAY_SIZE(errfmt))) - wcscpy(errfmt, L"Unknown error string!"); + StringCbCopyW(errfmt, sizeof(errfmt), L"Unknown error string!"); va_start(ap, resId); _vsnwprintf(errstr, ARRAY_SIZE(errstr), errfmt, ap); @@ -66,7 +66,7 @@ static void error_code_messagebox(HWND hwnd, DWORD error_code) { WCHAR title[256]; if (!LoadStringW(hInst, IDS_ERROR, title, ARRAY_SIZE(title))) - wcscpy(title, L"Error"); + StringCbCopyW(title, sizeof(title), L"Error"); ErrorMessageBox(hwnd, title, error_code); } @@ -81,13 +81,13 @@ void warning(HWND hwnd, INT resId, ...) hInstance = GetModuleHandle(0); if (!LoadStringW(hInstance, IDS_WARNING, title, ARRAY_SIZE(title))) - wcscpy(title, L"Warning"); + StringCbCopyW(title, sizeof(title), L"Warning"); if (!LoadStringW(hInstance, resId, errfmt, ARRAY_SIZE(errfmt))) - wcscpy(errfmt, L"Unknown error string!"); + StringCbCopyW(errfmt, sizeof(errfmt), L"Unknown error string!"); va_start(ap, resId); - _vsnwprintf(errstr, ARRAY_SIZE(errstr), errfmt, ap); + StringCbVPrintfW(errstr, sizeof(errstr), errfmt, ap); va_end(ap); MessageBoxW(hwnd, errstr, title, MB_OK | MB_ICONSTOP); @@ -304,7 +304,7 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP SetDlgItemTextW(hwndDlg, IDC_VALUE_NAME, buffer); } CheckRadioButton (hwndDlg, IDC_FORMAT_HEX, IDC_FORMAT_DEC, IDC_FORMAT_HEX); - swprintf(ValueString, L"%lx", dwordValueData); + StringCbPrintfW(ValueString, sizeof(ValueString), L"%lx", dwordValueData); SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, ValueString); SendMessage(GetDlgItem(hwndDlg, IDC_VALUE_DATA), EM_SETSEL, 0, -1); SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA)); @@ -327,7 +327,7 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP } } } - swprintf(ValueString, L"%lx", Value); + StringCbPrintfW(ValueString, sizeof(ValueString), L"%lx", Value); SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, ValueString); return TRUE; } @@ -347,7 +347,7 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP } } } - swprintf(ValueString, L"%lu", Value); + StringCbPrintfW(ValueString, sizeof(ValueString), L"%lu", Value); SetDlgItemTextW(hwndDlg, IDC_VALUE_DATA, ValueString); return TRUE; } @@ -1491,6 +1491,7 @@ LONG RenameKey(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpNewName) LPCWSTR s; LPWSTR lpNewSubKey = NULL; LONG Ret = 0; + SIZE_T cbNewSubKey; if (!lpSubKey) return Ret; @@ -1499,11 +1500,12 @@ LONG RenameKey(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpNewName) if (s) { s++; - lpNewSubKey = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (s - lpSubKey + wcslen(lpNewName) + 1) * sizeof(WCHAR)); + cbNewSubKey = (s - lpSubKey + wcslen(lpNewName) + 1) * sizeof(WCHAR); + lpNewSubKey = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, cbNewSubKey); if (lpNewSubKey != NULL) { - memcpy(lpNewSubKey, lpSubKey, (s - lpSubKey) * sizeof(WCHAR)); - wcscpy(lpNewSubKey + (s - lpSubKey), lpNewName); + StringCbCopyNW(lpNewSubKey, cbNewSubKey, lpSubKey, (s - lpSubKey) * sizeof(WCHAR)); + StringCbCatW(lpNewSubKey, cbNewSubKey, lpNewName); lpNewName = lpNewSubKey; } else diff --git a/base/applications/regedit/find.c b/base/applications/regedit/find.c index 444f4a25952..9405271a916 100644 --- a/base/applications/regedit/find.c +++ b/base/applications/regedit/find.c @@ -144,7 +144,7 @@ BOOL RegFindRecurse( if(wcslen(pszSubKey) >= _countof(szSubKey)) return FALSE; - wcscpy(szSubKey, pszSubKey); + StringCbCopyW(szSubKey, sizeof(szSubKey), pszSubKey); hSubKey = NULL; lResult = RegOpenKeyExW(hKey, szSubKey, 0, KEY_ALL_ACCESS, &hSubKey); @@ -304,14 +304,14 @@ BOOL RegFindRecurse( ppszFoundValueName)) { LPWSTR psz = *ppszFoundSubKey; - *ppszFoundSubKey = malloc( - (wcslen(szSubKey) + wcslen(psz) + 2) * sizeof(WCHAR)); + SIZE_T cbFoundSubKey = (wcslen(szSubKey) + wcslen(psz) + 2) * sizeof(WCHAR); + *ppszFoundSubKey = malloc(cbFoundSubKey); if (*ppszFoundSubKey == NULL) goto err; if (szSubKey[0]) { - wcscpy(*ppszFoundSubKey, szSubKey); - wcscat(*ppszFoundSubKey, s_backslash); + StringCbCopyW(*ppszFoundSubKey, cbFoundSubKey, szSubKey); + StringCbCatW(*ppszFoundSubKey, cbFoundSubKey, s_backslash); } else **ppszFoundSubKey = 0; @@ -368,7 +368,7 @@ BOOL RegFindWalk( ppszFoundValueName)) return TRUE; - wcscpy(szSubKey, pszSubKey); + StringCbCopyW(szSubKey, sizeof(szSubKey), pszSubKey); while(szSubKey[0] != 0) { if (DoEvents()) @@ -460,15 +460,14 @@ BOOL RegFindWalk( ppszFoundSubKey, ppszFoundValueName)) { LPWSTR psz = *ppszFoundSubKey; - *ppszFoundSubKey = malloc( - (wcslen(szSubKey) + wcslen(psz) + 2) * - sizeof(WCHAR)); + SIZE_T cbFoundSubKey = (wcslen(szSubKey) + wcslen(psz) + 2) * sizeof(WCHAR); + *ppszFoundSubKey = malloc(cbFoundSubKey); if (*ppszFoundSubKey == NULL) goto err; if (szSubKey[0]) { - wcscpy(*ppszFoundSubKey, szSubKey); - wcscat(*ppszFoundSubKey, s_backslash); + StringCbCopyW(*ppszFoundSubKey, cbFoundSubKey, szSubKey); + StringCbCatW(*ppszFoundSubKey, cbFoundSubKey, s_backslash); } else **ppszFoundSubKey = 0; diff --git a/base/applications/regedit/framewnd.c b/base/applications/regedit/framewnd.c index 6b5b1c28cfb..6f382a072cd 100644 --- a/base/applications/regedit/framewnd.c +++ b/base/applications/regedit/framewnd.c @@ -138,7 +138,7 @@ static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) { WCHAR str[100]; - wcscpy(str, L""); + str[0] = UNICODE_NULL; if (nFlags & MF_POPUP) { if (hSysMenu != GetMenu(hWnd)) @@ -814,6 +814,7 @@ BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName) WCHAR szBuffer[512]; HGLOBAL hGlobal; LPWSTR s; + SIZE_T cbGlobal; if (!OpenClipboard(hWnd)) goto done; @@ -825,12 +826,13 @@ BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName) if (!GetKeyName(szBuffer, ARRAY_SIZE(szBuffer), hRootKey, keyName)) goto done; - hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + cbGlobal = (wcslen(szBuffer) + 1) * sizeof(WCHAR); + hGlobal = GlobalAlloc(GMEM_MOVEABLE, cbGlobal); if (!hGlobal) goto done; s = GlobalLock(hGlobal); - wcscpy(s, szBuffer); + StringCbCopyW(s, cbGlobal, szBuffer); GlobalUnlock(hGlobal); SetClipboardData(CF_UNICODETEXT, hGlobal); diff --git a/base/applications/regedit/security.c b/base/applications/regedit/security.c index 71251583e9c..0ea90092d91 100644 --- a/base/applications/regedit/security.c +++ b/base/applications/regedit/security.c @@ -782,8 +782,7 @@ CRegKeySecurity_fnConstructor(LPWSTR lpRegKey, obj->ObjectInfo = *ObjectInfo; obj->Btn = Btn; obj->hRootKey = hRootKey; - wcscpy(obj->szRegKey, - lpRegKey); + StringCbCopyW(obj->szRegKey, sizeof(obj->szRegKey), lpRegKey); } else SetLastError(ERROR_NOT_ENOUGH_MEMORY); diff --git a/base/applications/regedit/txtproc.c b/base/applications/regedit/txtproc.c index f5e3ea041c2..092930e6f7a 100644 --- a/base/applications/regedit/txtproc.c +++ b/base/applications/regedit/txtproc.c @@ -194,8 +194,9 @@ static WCHAR * txt_build_subkey_path(LPCWSTR path, DWORD path_len, LPCWSTR subkey_name, DWORD subkey_len) { WCHAR *subkey_path; - subkey_path = malloc((path_len + subkey_len + 2) * sizeof(WCHAR)); - swprintf(subkey_path, L"%s\\%s", path, subkey_name); + SIZE_T cb_subkey_path = (path_len + subkey_len + 2) * sizeof(WCHAR); + subkey_path = malloc(cb_subkey_path); + StringCbPrintfW(subkey_path, cb_subkey_path, L"%s\\%s", path, subkey_name); return subkey_path; } From a5619d99bda82e23323d6dc885cdbecf26df3434 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 25 Oct 2023 16:59:13 +0900 Subject: [PATCH 33/33] [SHELL32] Remove 'Create Link' context menu item from drives --- dll/win32/shell32/folders/CDrivesFolder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp b/dll/win32/shell32/folders/CDrivesFolder.cpp index 2293884e9ea..b33d4105dfa 100644 --- a/dll/win32/shell32/folders/CDrivesFolder.cpp +++ b/dll/win32/shell32/folders/CDrivesFolder.cpp @@ -590,7 +590,7 @@ static const DWORD dwControlPanelAttributes = SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_CANLINK; static const DWORD dwDriveAttributes = SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | - SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME | SFGAO_CANLINK; + SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME; CDrivesFolder::CDrivesFolder() {