ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
December 2017
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
26 participants
355 discussions
Start a n
N
ew thread
[reactos] 01/01: [SERVMAN]
by Ged Murphy
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e36b89addba874fc9aa89…
commit e36b89addba874fc9aa898a42e894ef37465cd30 Author: Ged Murphy <gedmurphy(a)reactos.org> AuthorDate: Tue Dec 5 22:13:02 2017 +0000 [SERVMAN] - Avoid a potential race whereby the current service selection can change before the propsheet thread starts up - Cleanup the depends data, it doesn't need to be passed around the propsheet --- .../mscutils/servman/dependencies_tv1.c | 29 ++++----- .../mscutils/servman/dependencies_tv2.c | 24 +++---- base/applications/mscutils/servman/precomp.h | 17 +++-- base/applications/mscutils/servman/propsheet.c | 75 +++++++++++----------- .../mscutils/servman/propsheet_depends.c | 54 ++++++++-------- .../mscutils/servman/propsheet_recovery.c | 3 +- 6 files changed, 107 insertions(+), 95 deletions(-) diff --git a/base/applications/mscutils/servman/dependencies_tv1.c b/base/applications/mscutils/servman/dependencies_tv1.c index 5e764e51db..27d376ea54 100644 --- a/base/applications/mscutils/servman/dependencies_tv1.c +++ b/base/applications/mscutils/servman/dependencies_tv1.c @@ -10,8 +10,7 @@ #include "precomp.h" LPWSTR -TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo, - SC_HANDLE hService) +TV1_GetDependants(SC_HANDLE hService) { LPQUERY_SERVICE_CONFIG lpServiceConfig; LPWSTR lpStr = NULL; @@ -80,7 +79,7 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo, } VOID -TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, +TV1_AddDependantsToTree(PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName) { @@ -103,7 +102,7 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, if (hService) { /* Get a list of service dependents */ - lpDependants = TV1_GetDependants(pDlgInfo, hService); + lpDependants = TV1_GetDependants(hService); if (lpDependants) { lpStr = lpDependants; @@ -127,7 +126,7 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, } /* Add it */ - AddItemToTreeView(pDlgInfo->hDependsTreeView1, + AddItemToTreeView(pDependData->hDependsTreeView1, hParent, lpServiceConfig->lpDisplayName, lpStr, @@ -156,7 +155,7 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, /* Load the 'No dependencies' string */ AllocAndLoadString(&lpNoDepends, hInstance, IDS_NO_DEPENDS); - AddItemToTreeView(pDlgInfo->hDependsTreeView1, + AddItemToTreeView(pDependData->hDependsTreeView1, NULL, lpNoDepends, NULL, @@ -166,7 +165,7 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, LocalFree(lpNoDepends); /* Disable the window */ - EnableWindow(pDlgInfo->hDependsTreeView1, FALSE); + EnableWindow(pDependData->hDependsTreeView1, FALSE); } } @@ -178,25 +177,25 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, } BOOL -TV1_Initialize(PSERVICEPROPSHEET pDlgInfo, +TV1_Initialize(PDEPENDDATA pDependData, LPWSTR lpServiceName) { BOOL bRet = FALSE; /* Associate the imagelist with TV1 */ - pDlgInfo->hDependsTreeView1 = GetDlgItem(pDlgInfo->hDependsWnd, IDC_DEPEND_TREE1); - if (!pDlgInfo->hDependsTreeView1) + pDependData->hDependsTreeView1 = GetDlgItem(pDependData->hDependsWnd, IDC_DEPEND_TREE1); + if (!pDependData->hDependsTreeView1) { - ImageList_Destroy(pDlgInfo->hDependsImageList); - pDlgInfo->hDependsImageList = NULL; + ImageList_Destroy(pDependData->hDependsImageList); + pDependData->hDependsImageList = NULL; return FALSE; } - (void)TreeView_SetImageList(pDlgInfo->hDependsTreeView1, - pDlgInfo->hDependsImageList, + (void)TreeView_SetImageList(pDependData->hDependsTreeView1, + pDependData->hDependsImageList, TVSIL_NORMAL); /* Set the first items in the control */ - TV1_AddDependantsToTree(pDlgInfo, NULL, lpServiceName); + TV1_AddDependantsToTree(pDependData, NULL, lpServiceName); return bRet; } diff --git a/base/applications/mscutils/servman/dependencies_tv2.c b/base/applications/mscutils/servman/dependencies_tv2.c index a0f37b07c1..6f23197c0a 100644 --- a/base/applications/mscutils/servman/dependencies_tv2.c +++ b/base/applications/mscutils/servman/dependencies_tv2.c @@ -118,7 +118,7 @@ TV2_GetDependants(LPWSTR lpServiceName, } VOID -TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, +TV2_AddDependantsToTree(PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName) { @@ -138,7 +138,7 @@ TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, bHasChildren = TV2_HasDependantServices(lpServiceStatus[i].lpServiceName); /* Add it */ - AddItemToTreeView(pDlgInfo->hDependsTreeView2, + AddItemToTreeView(pDependData->hDependsTreeView2, hParent, lpServiceStatus[i].lpDisplayName, lpServiceStatus[i].lpServiceName, @@ -158,7 +158,7 @@ TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, /* Load the 'No dependencies' string */ AllocAndLoadString(&lpNoDepends, hInstance, IDS_NO_DEPENDS); - AddItemToTreeView(pDlgInfo->hDependsTreeView2, + AddItemToTreeView(pDependData->hDependsTreeView2, NULL, lpNoDepends, NULL, @@ -168,31 +168,31 @@ TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, LocalFree(lpNoDepends); /* Disable the window */ - EnableWindow(pDlgInfo->hDependsTreeView2, FALSE); + EnableWindow(pDependData->hDependsTreeView2, FALSE); } } } BOOL -TV2_Initialize(PSERVICEPROPSHEET pDlgInfo, +TV2_Initialize(PDEPENDDATA pDependData, LPWSTR lpServiceName) { BOOL bRet = FALSE; /* Associate the imagelist with TV2 */ - pDlgInfo->hDependsTreeView2 = GetDlgItem(pDlgInfo->hDependsWnd, IDC_DEPEND_TREE2); - if (!pDlgInfo->hDependsTreeView2) + pDependData->hDependsTreeView2 = GetDlgItem(pDependData->hDependsWnd, IDC_DEPEND_TREE2); + if (!pDependData->hDependsTreeView2) { - ImageList_Destroy(pDlgInfo->hDependsImageList); - pDlgInfo->hDependsImageList = NULL; + ImageList_Destroy(pDependData->hDependsImageList); + pDependData->hDependsImageList = NULL; return FALSE; } - (void)TreeView_SetImageList(pDlgInfo->hDependsTreeView2, - pDlgInfo->hDependsImageList, + (void)TreeView_SetImageList(pDependData->hDependsTreeView2, + pDependData->hDependsImageList, TVSIL_NORMAL); /* Set the first items in the control */ - TV2_AddDependantsToTree(pDlgInfo, NULL, lpServiceName); + TV2_AddDependantsToTree(pDependData, NULL, lpServiceName); return bRet; } diff --git a/base/applications/mscutils/servman/precomp.h b/base/applications/mscutils/servman/precomp.h index 051634dc95..5ec27109f6 100644 --- a/base/applications/mscutils/servman/precomp.h +++ b/base/applications/mscutils/servman/precomp.h @@ -128,11 +128,18 @@ typedef struct _SERVICEPROPSHEET { PMAIN_WND_INFO Info; ENUM_SERVICE_STATUS_PROCESS *pService; + +} SERVICEPROPSHEET, *PSERVICEPROPSHEET; + +typedef struct _DEPENDDATA +{ + PSERVICEPROPSHEET pDlgInfo; HIMAGELIST hDependsImageList; HWND hDependsWnd; HWND hDependsTreeView1; HWND hDependsTreeView2; -} SERVICEPROPSHEET, *PSERVICEPROPSHEET; + +} DEPENDDATA, *PDEPENDDATA; HTREEITEM AddItemToTreeView(HWND hTreeView, HTREEITEM hRoot, LPWSTR lpDisplayName, LPWSTR lpServiceName, ULONG serviceType, BOOL bHasChildren); @@ -147,12 +154,12 @@ LPWSTR DisplayName, LPWSTR ServiceList); /* tv1_dependencies */ -BOOL TV1_Initialize(PSERVICEPROPSHEET pDlgInfo, LPWSTR lpServiceName); -VOID TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPWSTR lpServiceName); +BOOL TV1_Initialize(PDEPENDDATA pDependData, LPWSTR lpServiceName); +VOID TV1_AddDependantsToTree(PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName); /* tv2_dependencies */ -BOOL TV2_Initialize(PSERVICEPROPSHEET pDlgInfo, LPWSTR lpServiceName); -VOID TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPWSTR lpServiceName); +BOOL TV2_Initialize(PDEPENDDATA pDependData, LPWSTR lpServiceName); +VOID TV2_AddDependantsToTree(PDEPENDDATA pDependData, HTREEITEM hParent, LPWSTR lpServiceName); BOOL TV2_HasDependantServices(LPWSTR lpServiceName); LPENUM_SERVICE_STATUS TV2_GetDependants(LPWSTR lpServiceName, LPDWORD lpdwCount); diff --git a/base/applications/mscutils/servman/propsheet.c b/base/applications/mscutils/servman/propsheet.c index 9557420ebb..bd0ec24510 100644 --- a/base/applications/mscutils/servman/propsheet.c +++ b/base/applications/mscutils/servman/propsheet.c @@ -3,7 +3,7 @@ * LICENSE: GPL - See COPYING in the top level directory * FILE: base/applications/mscutils/servman/propsheet.c * PURPOSE: Property dialog box message handler - * COPYRIGHT: Copyright 2006-2007 Ged Murphy <gedmurphy(a)reactos.org> + * COPYRIGHT: Copyright 2006-2017 Ged Murphy <gedmurphy(a)reactos.org> * */ @@ -29,8 +29,20 @@ InitPropSheetPage(PROPSHEETPAGE *psp, VOID OpenPropSheet(PMAIN_WND_INFO Info) { + PSERVICEPROPSHEET pServicePropSheet; HANDLE hThread; - hThread = (HANDLE)_beginthreadex(NULL, 0, &PropSheetThread, Info, 0, NULL); + + pServicePropSheet = HeapAlloc(ProcessHeap, + 0, + sizeof(*pServicePropSheet)); + if (!pServicePropSheet) return; + + /* Set the current service in this calling thread to avoid + * it being updated before the thread is up */ + pServicePropSheet->pService = Info->pCurrentService; + pServicePropSheet->Info = Info; + + hThread = (HANDLE)_beginthreadex(NULL, 0, &PropSheetThread, pServicePropSheet, 0, NULL); if (hThread) { CloseHandle(hThread); @@ -40,65 +52,54 @@ OpenPropSheet(PMAIN_WND_INFO Info) unsigned int __stdcall PropSheetThread(void* Param) { + PSERVICEPROPSHEET pServicePropSheet; PROPSHEETHEADER psh; PROPSHEETPAGE psp[4]; - PSERVICEPROPSHEET pServicePropSheet; HWND hDlg = NULL; MSG Msg; - PMAIN_WND_INFO Info = (PMAIN_WND_INFO)Param; + pServicePropSheet = (PSERVICEPROPSHEET)Param; ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_MODELESS; - psh.hwndParent = Info->hMainWnd; + psh.hwndParent = pServicePropSheet->Info->hMainWnd; psh.hInstance = hInstance; psh.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SM_ICON)); - psh.pszCaption = Info->pCurrentService->lpDisplayName; + psh.pszCaption = pServicePropSheet->Info->pCurrentService->lpDisplayName; psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE); psh.nStartPage = 0; psh.ppsp = psp; + /* Initialize the tabs */ + InitPropSheetPage(&psp[0], pServicePropSheet, IDD_DLG_GENERAL, GeneralPageProc); + InitPropSheetPage(&psp[1], pServicePropSheet, IDD_LOGON, LogonPageProc); + InitPropSheetPage(&psp[2], pServicePropSheet, IDD_RECOVERY, RecoveryPageProc); + InitPropSheetPage(&psp[3], pServicePropSheet, IDD_DLG_DEPEND, DependenciesPageProc); - pServicePropSheet = HeapAlloc(ProcessHeap, - 0, - sizeof(*pServicePropSheet)); - if (pServicePropSheet) + hDlg = (HWND)PropertySheetW(&psh); + if (hDlg) { - /* Save current service, as it could change while the dialog is open */ - pServicePropSheet->pService = Info->pCurrentService; - pServicePropSheet->Info = Info; - - InitPropSheetPage(&psp[0], pServicePropSheet, IDD_DLG_GENERAL, GeneralPageProc); - InitPropSheetPage(&psp[1], pServicePropSheet, IDD_LOGON, LogonPageProc); - InitPropSheetPage(&psp[2], pServicePropSheet, IDD_RECOVERY, RecoveryPageProc); - InitPropSheetPage(&psp[3], pServicePropSheet, IDD_DLG_DEPEND, DependenciesPageProc); - - hDlg = (HWND)PropertySheetW(&psh); - if (hDlg) + /* Pump the message queue */ + while (GetMessageW(&Msg, NULL, 0, 0)) { - /* Pump the message queue */ - while (GetMessageW(&Msg, NULL, 0, 0)) + if (PropSheet_GetCurrentPageHwnd(hDlg) == NULL) { + /* The user hit the ok / cancel button, pull it down */ + EnableWindow(pServicePropSheet->Info->hMainWnd, TRUE); + DestroyWindow(hDlg); + } - if (PropSheet_GetCurrentPageHwnd(hDlg) == NULL) - { - /* The user hit the ok / cancel button, pull it down */ - EnableWindow(Info->hMainWnd, TRUE); - DestroyWindow(hDlg); - } - - if (PropSheet_IsDialogMessage(hDlg, &Msg) != 0) - { - TranslateMessage(&Msg); - DispatchMessageW(&Msg); - } + if (PropSheet_IsDialogMessage(hDlg, &Msg) != 0) + { + TranslateMessage(&Msg); + DispatchMessageW(&Msg); } } - - HeapFree(GetProcessHeap(), 0, pServicePropSheet); } + HeapFree(GetProcessHeap(), 0, pServicePropSheet); + return (hDlg != NULL); } diff --git a/base/applications/mscutils/servman/propsheet_depends.c b/base/applications/mscutils/servman/propsheet_depends.c index b32111700e..de1d6a5573 100644 --- a/base/applications/mscutils/servman/propsheet_depends.c +++ b/base/applications/mscutils/servman/propsheet_depends.c @@ -159,20 +159,20 @@ TreeView_GetItemText(HWND hTreeView, */ static VOID -InitDependPage(PSERVICEPROPSHEET pDlgInfo) +InitDependPage(PDEPENDDATA pDependData) { /* Initialize the image list */ - pDlgInfo->hDependsImageList = InitImageList(IDI_NODEPENDS, - IDI_DRIVER, - GetSystemMetrics(SM_CXSMICON), - GetSystemMetrics(SM_CXSMICON), - IMAGE_ICON); + pDependData->hDependsImageList = InitImageList(IDI_NODEPENDS, + IDI_DRIVER, + GetSystemMetrics(SM_CXSMICON), + GetSystemMetrics(SM_CXSMICON), + IMAGE_ICON); /* Set the first tree view */ - TV1_Initialize(pDlgInfo, pDlgInfo->pService->lpServiceName); + TV1_Initialize(pDependData, pDependData->pDlgInfo->pService->lpServiceName); /* Set the second tree view */ - TV2_Initialize(pDlgInfo, pDlgInfo->pService->lpServiceName); + TV2_Initialize(pDependData, pDependData->pDlgInfo->pService->lpServiceName); } /* @@ -185,12 +185,13 @@ DependenciesPageProc(HWND hwndDlg, WPARAM wParam, LPARAM lParam) { - PSERVICEPROPSHEET pDlgInfo; + + PDEPENDDATA pDependData; /* Get the window context */ - pDlgInfo = (PSERVICEPROPSHEET)GetWindowLongPtr(hwndDlg, - GWLP_USERDATA); - if (pDlgInfo == NULL && uMsg != WM_INITDIALOG) + pDependData = (PDEPENDDATA)GetWindowLongPtr(hwndDlg, + GWLP_USERDATA); + if (pDependData == NULL && uMsg != WM_INITDIALOG) { return FALSE; } @@ -199,16 +200,17 @@ DependenciesPageProc(HWND hwndDlg, { case WM_INITDIALOG: { - pDlgInfo = (PSERVICEPROPSHEET)(((LPPROPSHEETPAGE)lParam)->lParam); - if (pDlgInfo != NULL) + pDependData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DEPENDDATA)); + if (pDependData != NULL) { SetWindowLongPtr(hwndDlg, GWLP_USERDATA, - (LONG_PTR)pDlgInfo); + (LONG_PTR)pDependData); - pDlgInfo->hDependsWnd = hwndDlg; + pDependData->pDlgInfo = (PSERVICEPROPSHEET)(((LPPROPSHEETPAGE)lParam)->lParam); + pDependData->hDependsWnd = hwndDlg; - InitDependPage(pDlgInfo); + InitDependPage(pDependData); } } break; @@ -226,19 +228,19 @@ DependenciesPageProc(HWND hwndDlg, if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE1) { /* Has this node been expanded before */ - if (!TreeView_GetChild(pDlgInfo->hDependsTreeView1, lpnmtv->itemNew.hItem)) + if (!TreeView_GetChild(pDependData->hDependsTreeView1, lpnmtv->itemNew.hItem)) { /* It's not, add the children */ - TV1_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam); + TV1_AddDependantsToTree(pDependData, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam); } } else if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE2) { /* Has this node been expanded before */ - if (!TreeView_GetChild(pDlgInfo->hDependsTreeView2, lpnmtv->itemNew.hItem)) + if (!TreeView_GetChild(pDependData->hDependsTreeView2, lpnmtv->itemNew.hItem)) { /* It's not, add the children */ - TV2_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam); + TV2_AddDependantsToTree(pDependData, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam); } } } @@ -256,11 +258,13 @@ DependenciesPageProc(HWND hwndDlg, break; case WM_DESTROY: - DestroyTreeView(pDlgInfo->hDependsTreeView1); - DestroyTreeView(pDlgInfo->hDependsTreeView2); + DestroyTreeView(pDependData->hDependsTreeView1); + DestroyTreeView(pDependData->hDependsTreeView2); - if (pDlgInfo->hDependsImageList) - ImageList_Destroy(pDlgInfo->hDependsImageList); + if (pDependData->hDependsImageList) + ImageList_Destroy(pDependData->hDependsImageList); + + HeapFree(GetProcessHeap(), 0, pDependData); } return FALSE; diff --git a/base/applications/mscutils/servman/propsheet_recovery.c b/base/applications/mscutils/servman/propsheet_recovery.c index 8e16122151..59205f24c0 100644 --- a/base/applications/mscutils/servman/propsheet_recovery.c +++ b/base/applications/mscutils/servman/propsheet_recovery.c @@ -170,7 +170,8 @@ ShowFailureActions( { WCHAR szBuffer[256]; PWSTR startPtr, endPtr; - INT i, index, id, length; + INT index, id, length; + DWORD i; for (i = 0; i < min(pRecoveryData->pServiceFailure->cActions, 3); i++) {
7 years
1
0
0
0
[reactos] 01/01: [VCDCLI] Add support for UDF/Joliet hidding. By providing /u or /j switch on mount, the virtual CD-ROM class driver will break the associated signatures on read so that FSDs cannot recognize them any longer.
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4296826c5882a245e103b…
commit 4296826c5882a245e103b28bb4e64371a0b01c97 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Tue Dec 5 21:38:40 2017 +0100 [VCDCLI] Add support for UDF/Joliet hidding. By providing /u or /j switch on mount, the virtual CD-ROM class driver will break the associated signatures on read so that FSDs cannot recognize them any longer. --- .../rosapps/applications/cmdutils/vcdcli/vcdcli.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/rosapps/applications/cmdutils/vcdcli/vcdcli.c b/modules/rosapps/applications/cmdutils/vcdcli/vcdcli.c index 315dc958bc..c3bcf0cc56 100644 --- a/modules/rosapps/applications/cmdutils/vcdcli/vcdcli.c +++ b/modules/rosapps/applications/cmdutils/vcdcli/vcdcli.c @@ -37,9 +37,11 @@ PrintUsage(int type) else if (type == 1) { _ftprintf(stdout, _T("mount usage:\n")); - _ftprintf(stdout, _T("\tmount <drive letter> <path.iso>\n")); + _ftprintf(stdout, _T("\tmount <drive letter> <path.iso> [/u] [/j]\n")); _ftprintf(stdout, _T("\tMount the ISO image given in <path.iso> on the previously created virtual drive <drive letter>\n")); _ftprintf(stdout, _T("\t\tDo not use colon for drive letter\n")); + _ftprintf(stdout, _T("\t\tUse /u to make UDF volumes not appear as such\n")); + _ftprintf(stdout, _T("\t\tUse /j to make Joliet volumes not appear as such\n")); } else if (type == 2) { @@ -331,6 +333,7 @@ _tmain(int argc, const TCHAR *argv[]) } else if (_tcscmp(argv[1], _T("mount")) == 0) { + DWORD i; HANDLE hFile; WCHAR Letter; UNICODE_STRING NtPathName; @@ -377,7 +380,22 @@ _tmain(int argc, const TCHAR *argv[]) /* Copy it in the parameter structure */ _tcsncpy(MountParams.Path, NtPathName.Buffer, 255); MountParams.Length = Min(NtPathName.Length, 255 * sizeof(WCHAR)); - MountParams.Flags = 0; /* FIXME */ + MountParams.Flags = 0; + + /* Do we have to suppress anything? */ + for (i = 4; i < argc; ++i) + { + /* Make UDF uneffective */ + if (_tcscmp(argv[i], _T("/u")) == 0) + { + MountParams.Flags |= MOUNT_FLAG_SUPP_UDF; + } + /* Make Joliet uneffective */ + else if (_tcscmp(argv[i], _T("/j")) == 0) + { + MountParams.Flags |= MOUNT_FLAG_SUPP_JOLIET; + } + } /* No longer needed */ RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathName.Buffer);
7 years
1
0
0
0
[reactos] 01/01: [Servman] Make the property sheets modeless so users can open multiple services at the same time (#166)
by Ged Murphy
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ceb1e0b9ff1a4567923c6…
commit ceb1e0b9ff1a4567923c6a32914296d8721f6332 Author: Ged Murphy <gedmurphy(a)reactos.org> AuthorDate: Tue Dec 5 12:25:14 2017 +0000 [Servman] Make the property sheets modeless so users can open multiple services at the same time (#166) [SERVMAN] - Make the property sheets modeless so users can open multiple services at the same time - Untested in ros. In fact we have no code or tests cases to check that modeless property sheets work, so please raise a bug if you find any issues with the app. - Dedicated to reactosfanboy --- base/applications/mscutils/servman/precomp.h | 3 +- base/applications/mscutils/servman/propsheet.c | 65 ++++++++++++++++++++------ 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/base/applications/mscutils/servman/precomp.h b/base/applications/mscutils/servman/precomp.h index 661772ffb4..051634dc95 100644 --- a/base/applications/mscutils/servman/precomp.h +++ b/base/applications/mscutils/servman/precomp.h @@ -13,6 +13,7 @@ #include <shlobj.h> #include <commdlg.h> #include <strsafe.h> +#include <process.h> #include "resource.h" @@ -155,7 +156,7 @@ VOID TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPWS BOOL TV2_HasDependantServices(LPWSTR lpServiceName); LPENUM_SERVICE_STATUS TV2_GetDependants(LPWSTR lpServiceName, LPDWORD lpdwCount); -LONG APIENTRY OpenPropSheet(PMAIN_WND_INFO Info); +VOID OpenPropSheet(PMAIN_WND_INFO Info); /* propsheet window procs */ INT_PTR CALLBACK DependenciesPageProc(HWND hwndDlg, diff --git a/base/applications/mscutils/servman/propsheet.c b/base/applications/mscutils/servman/propsheet.c index dc978c8dc7..9557420ebb 100644 --- a/base/applications/mscutils/servman/propsheet.c +++ b/base/applications/mscutils/servman/propsheet.c @@ -9,32 +9,48 @@ #include "precomp.h" +unsigned int __stdcall PropSheetThread(void* Param); + static VOID InitPropSheetPage(PROPSHEETPAGE *psp, PSERVICEPROPSHEET dlgInfo, WORD idDlg, DLGPROC DlgProc) { - ZeroMemory(psp, sizeof(PROPSHEETPAGE)); - psp->dwSize = sizeof(PROPSHEETPAGE); - psp->dwFlags = PSP_DEFAULT; - psp->hInstance = hInstance; - psp->pszTemplate = MAKEINTRESOURCE(idDlg); - psp->pfnDlgProc = DlgProc; - psp->lParam = (LPARAM)dlgInfo; + ZeroMemory(psp, sizeof(PROPSHEETPAGE)); + psp->dwSize = sizeof(PROPSHEETPAGE); + psp->dwFlags = PSP_DEFAULT; + psp->hInstance = hInstance; + psp->pszTemplate = MAKEINTRESOURCE(idDlg); + psp->pfnDlgProc = DlgProc; + psp->lParam = (LPARAM)dlgInfo; } -LONG APIENTRY +VOID OpenPropSheet(PMAIN_WND_INFO Info) +{ + HANDLE hThread; + hThread = (HANDLE)_beginthreadex(NULL, 0, &PropSheetThread, Info, 0, NULL); + if (hThread) + { + CloseHandle(hThread); + } +} + + +unsigned int __stdcall PropSheetThread(void* Param) { PROPSHEETHEADER psh; PROPSHEETPAGE psp[4]; PSERVICEPROPSHEET pServicePropSheet; - LONG Ret = 0; + HWND hDlg = NULL; + MSG Msg; + + PMAIN_WND_INFO Info = (PMAIN_WND_INFO)Param; ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USECALLBACK;// | PSH_MODELESS; + psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_MODELESS; psh.hwndParent = Info->hMainWnd; psh.hInstance = hInstance; psh.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SM_ICON)); @@ -58,12 +74,31 @@ OpenPropSheet(PMAIN_WND_INFO Info) InitPropSheetPage(&psp[2], pServicePropSheet, IDD_RECOVERY, RecoveryPageProc); InitPropSheetPage(&psp[3], pServicePropSheet, IDD_DLG_DEPEND, DependenciesPageProc); - Ret = (LONG)(PropertySheet(&psh) != -1); + hDlg = (HWND)PropertySheetW(&psh); + if (hDlg) + { + /* Pump the message queue */ + while (GetMessageW(&Msg, NULL, 0, 0)) + { + + if (PropSheet_GetCurrentPageHwnd(hDlg) == NULL) + { + /* The user hit the ok / cancel button, pull it down */ + EnableWindow(Info->hMainWnd, TRUE); + DestroyWindow(hDlg); + } - HeapFree(ProcessHeap, - 0, - pServicePropSheet); + if (PropSheet_IsDialogMessage(hDlg, &Msg) != 0) + { + TranslateMessage(&Msg); + DispatchMessageW(&Msg); + } + } + } + + HeapFree(GetProcessHeap(), 0, pServicePropSheet); } - return Ret; + return (hDlg != NULL); } +
7 years
1
0
0
0
[reactos] 03/03: [SHELL32_APITEST] SHParseDisplayName: More tests for relative paths
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=df88fcf5ccd5ec43433c1…
commit df88fcf5ccd5ec43433c1bcb7ac0c9f88e0afa79 Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sun Dec 3 18:45:24 2017 +0300 [SHELL32_APITEST] SHParseDisplayName: More tests for relative paths --- modules/rostests/apitests/shell32/SHParseDisplayName.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/rostests/apitests/shell32/SHParseDisplayName.cpp b/modules/rostests/apitests/shell32/SHParseDisplayName.cpp index a1a37c3508..cc495dc811 100644 --- a/modules/rostests/apitests/shell32/SHParseDisplayName.cpp +++ b/modules/rostests/apitests/shell32/SHParseDisplayName.cpp @@ -46,7 +46,11 @@ struct test_data Tests[] = {__LINE__, L" :", NULL, 0, E_INVALIDARG, 0}, {__LINE__, L"/", NULL, 0, E_INVALIDARG, 0}, {__LINE__, L"//", NULL, 0, E_INVALIDARG, 0}, + /* This opens C:\ from Win+R and address bar */ {__LINE__, L"\\", NULL, 0, E_INVALIDARG, 0}, + /* These two opens "C:\Program Files" from Win+R and address bar */ + {__LINE__, L"\\Program Files", NULL, 0, E_INVALIDARG, 0}, + {__LINE__, L"\\Program Files\\", NULL, 0, E_INVALIDARG, 0}, {__LINE__, L"\\\\?", NULL, 0, E_INVALIDARG, 0}, {__LINE__, L"\\\\?\\", NULL, 0, E_INVALIDARG, 0}, /* Tests for the shell: protocol */ @@ -139,6 +143,7 @@ UINT get_host_os_flag() START_TEST(SHParseDisplayName) { HRESULT hr; + WCHAR winDir[MAX_PATH]; UINT os_flag = get_host_os_flag(); ok (os_flag != 0, "Incompatible os version %d!", os_flag); if (os_flag == 0) @@ -148,6 +153,9 @@ START_TEST(SHParseDisplayName) hr = SHGetDesktopFolder(&psfDesktop); ok(hr == S_OK, "hr = %lx\n", hr); + GetWindowsDirectoryW(winDir, _countof(winDir)); + SetCurrentDirectoryW(winDir); + for (UINT i = 0; i < _countof(Tests); i ++) { if (Tests[i].ValidForVersion && !(Tests[i].ValidForVersion & os_flag))
7 years
1
0
0
0
[reactos] 02/03: [BROWSEUI] SHExplorerParseCmdLine: Improve relative path handling
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=53edadb8c0ce1ced5faed…
commit 53edadb8c0ce1ced5faedcd5080b1a65d3f85212 Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sat Dec 2 23:54:35 2017 +0300 [BROWSEUI] SHExplorerParseCmdLine: Improve relative path handling CORE-12882, CORE-13847 --- dll/win32/browseui/parsecmdline.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dll/win32/browseui/parsecmdline.cpp b/dll/win32/browseui/parsecmdline.cpp index d2a0d2f9b3..acf617607f 100644 --- a/dll/win32/browseui/parsecmdline.cpp +++ b/dll/win32/browseui/parsecmdline.cpp @@ -382,6 +382,12 @@ SHExplorerParseCmdLine(ExplorerCommandLineParseResults * pInfo) { // Or just a plain old string. + WCHAR szPath[MAX_PATH]; + DWORD result = GetFullPathNameW(strField, _countof(szPath), szPath, NULL); + + if (result != 0 && result <= _countof(szPath) && PathFileExistsW(szPath)) + StringCchCopyW(strField, _countof(strField), szPath); + LPITEMIDLIST pidlPath = ILCreateFromPathW(strField); pInfo->pidlPath = pidlPath;
7 years
1
0
0
0
[reactos] 01/03: [BROWSEUI_APITEST] Improve tests for relative paths
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5dade730725296c381193…
commit 5dade730725296c3811939f5ba13384e8cfdf242 Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sat Dec 2 23:52:38 2017 +0300 [BROWSEUI_APITEST] Improve tests for relative paths --- .../apitests/browseui/SHExplorerParseCmdLine.c | 80 ++++++++++++++++++++-- 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/modules/rostests/apitests/browseui/SHExplorerParseCmdLine.c b/modules/rostests/apitests/browseui/SHExplorerParseCmdLine.c index 88c086b3a3..bc9023a08e 100644 --- a/modules/rostests/apitests/browseui/SHExplorerParseCmdLine.c +++ b/modules/rostests/apitests/browseui/SHExplorerParseCmdLine.c @@ -45,6 +45,37 @@ UINT (WINAPI *SHExplorerParseCmdLine)(_Out_ PEXPLORER_INFO Info); #define InvalidPointer ((PVOID)0x5555555555555555ULL) +DWORD ReplaceSubstr( +_Out_ PWCHAR OutputStr, +_In_ DWORD OutputLen, +_In_ PCWSTR InputStr, +_In_ PCWSTR ReplaceStr, +_In_ PCWSTR ReplaceWith) +{ + DWORD result = 0; + PCWSTR pos; + PCWSTR pwc; + + if (!OutputLen) + return result; + + OutputStr[0] = 0; + pos = InputStr; + pwc = wcsstr(pos, ReplaceStr); + while (pwc) + { + if (StringCchCatNW(OutputStr, OutputLen, pos, pwc - pos) == STRSAFE_E_INSUFFICIENT_BUFFER) + break; + if (StringCchCatW(OutputStr, OutputLen, ReplaceWith) == STRSAFE_E_INSUFFICIENT_BUFFER) + break; + result++; + pos = pwc + wcslen(ReplaceStr); + pwc = wcsstr(pos, ReplaceStr); + } + StringCchCatW(OutputStr, OutputLen, pos); + return result; +} + static VOID TestCommandLine( @@ -97,6 +128,33 @@ _Out_opt_ PUINT PWriteEnd) if (Info.pidl != NULL && Info.pidl != InvalidPointer) { WCHAR pidlPathName[MAX_PATH] = L""; + WCHAR pidlPathTest[MAX_PATH] = L""; + WCHAR rootDir[MAX_PATH] = L""; + WCHAR curDir[MAX_PATH] = L""; + WCHAR replaceName[MAX_PATH]; + + GetFullPathNameW(L"\\", _countof(rootDir), rootDir, NULL); + + GetCurrentDirectoryW(_countof(curDir), curDir); + if (wcslen(curDir) != 0 && curDir[wcslen(curDir) - 1] != L'\\') + StringCchCatW(curDir, _countof(curDir), L"\\"); + + if (PidlPath) + { + StringCchCopyW(pidlPathTest, _countof(pidlPathTest), PidlPath); + + if (wcsstr(pidlPathTest, L"::ROOT::") != NULL && wcslen(rootDir) > 0) + { + if (ReplaceSubstr(replaceName, _countof(replaceName), pidlPathTest, L"::ROOT::", rootDir)) + StringCchCopyW(pidlPathTest, _countof(pidlPathTest), replaceName); + } + + if (wcsstr(pidlPathTest, L"::CURDIR::") != NULL && wcslen(curDir) > 0) + { + if (ReplaceSubstr(replaceName, _countof(replaceName), pidlPathTest, L"::CURDIR::", curDir)) + StringCchCopyW(pidlPathTest, _countof(pidlPathTest), replaceName); + } + } if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555) { @@ -105,7 +163,7 @@ _Out_opt_ PUINT PWriteEnd) if (ExpectedCsidl == PIDL_PATH_EQUALS_PATH) { - ok(wcsicmp(pidlPathName, PidlPath) == 0, "Path from pidl does not match; pidlPathName=%S\n", pidlPathName); + ok(wcsicmp(pidlPathName, pidlPathTest) == 0, "Path from pidl does not match; pidlPathName=%S\n", pidlPathName); } else if (ExpectedCsidl == PIDL_IS_EMPTY) { @@ -115,12 +173,12 @@ _Out_opt_ PUINT PWriteEnd) { if (ExpectedCsidl == PIDL_IS_PATH) { - ExpectedPidl = SHSimpleIDListFromPath(PidlPath); + ExpectedPidl = SHSimpleIDListFromPath(pidlPathTest); hr = ExpectedPidl == NULL ? E_FAIL : S_OK; - ok(ExpectedPidl != NULL, "SHSimpleIDListFromPath(%S) failed. pidlPathName=%S\n", PidlPath, pidlPathName); + ok(ExpectedPidl != NULL, "SHSimpleIDListFromPath(%S) failed. pidlPathName=%S\n", pidlPathTest, pidlPathName); if (SUCCEEDED(hr)) { - ok(ILIsEqual(Info.pidl, ExpectedPidl), "Unexpected pidl value %p; pidlPathName=%S PidlPath=%S\n", Info.pidl, pidlPathName, PidlPath); + ok(ILIsEqual(Info.pidl, ExpectedPidl), "Unexpected pidl value %p; pidlPathName=%S pidlPathTest=%S\n", Info.pidl, pidlPathName, pidlPathTest); ILFree(ExpectedPidl); } } @@ -209,6 +267,7 @@ START_TEST(SHExplorerParseCmdLine) { __LINE__, L"%wrongdir%", TRUE, PIDL_IS_NULL, 0x02000000, L"%wrongdir%"}, { __LINE__, L"%programfiles#", TRUE, PIDL_IS_NULL, 0x02000000, L"%programfiles#"}, { __LINE__, L",", TRUE, PIDL_IS_EMPTY, 0x00000200}, + { __LINE__, L"\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::ROOT::" }, // disk letter depends on current directory { __LINE__, L"c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, { __LINE__, L"c:", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, { __LINE__, L"c", TRUE, PIDL_IS_NULL, 0x02000000, L"c"}, @@ -216,9 +275,12 @@ START_TEST(SHExplorerParseCmdLine) { __LINE__, L"c:\\Program Files\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, { __LINE__, L"c:\\Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\Program Files/"}, { __LINE__, L"c:/Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:/Program Files/"}, - { __LINE__, L"fonts", TRUE, PIDL_IS_NULL, 0x02000000, L"fonts" }, - { __LINE__, L"winsxs", TRUE, PIDL_IS_NULL, 0x02000000, L"winsxs" }, - { __LINE__, L"system32", TRUE, PIDL_IS_NULL, 0x02000000, L"system32" }, + { __LINE__, L"fonts", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::CURDIR::fonts" }, // this would not fail if we are in Windows directory + { __LINE__, L"winsxs", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::CURDIR::winsxs" }, + { __LINE__, L"system32", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::CURDIR::system32" }, + { __LINE__, L"drivers", TRUE, PIDL_IS_NULL, 0x02000000, L"drivers" }, // this would fail since we are not in system32 directory + { __LINE__, L"spool", TRUE, PIDL_IS_NULL, 0x02000000, L"spool" }, + { __LINE__, L"wbem", TRUE, PIDL_IS_NULL, 0x02000000, L"wbem" }, { __LINE__, TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000200, NULL, TEST_PATHW }, { __LINE__, L"\"c:\\\"\"program files\"", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\\"program files"}, { __LINE__, L"\"c:\\\"program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, @@ -345,6 +407,7 @@ START_TEST(SHExplorerParseCmdLine) int i; UINT maxWrite = 0; FILE * ff; + WCHAR winDir[MAX_PATH]; HMODULE browseui = LoadLibraryA("browseui.dll"); SHExplorerParseCmdLine = (UINT (__stdcall *)(PEXPLORER_INFO))GetProcAddress(browseui, MAKEINTRESOURCEA(107)); @@ -360,6 +423,9 @@ START_TEST(SHExplorerParseCmdLine) ff = fopen(TEST_PATHA, "wb"); fclose(ff); + GetWindowsDirectoryW(winDir, _countof(winDir)); + SetCurrentDirectoryW(winDir); + for (i = 0; i < TestCount; i++) { UINT cWrite;
7 years
1
0
0
0
[reactos] 01/01: [SHELL32] shellpath.c: it is _WIN32_WINNT, not WIN32_WINNT. We even need to use __REACTOS__ instead here. CORE-12580
by Serge Gautherie
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=57aa1f1fc6744733020e8…
commit 57aa1f1fc6744733020e800e45ffa86481337179 Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr> AuthorDate: Fri Nov 17 01:44:31 2017 +0100 [SHELL32] shellpath.c: it is _WIN32_WINNT, not WIN32_WINNT. We even need to use __REACTOS__ instead here. CORE-12580 --- dll/win32/shell32/wine/shellpath.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dll/win32/shell32/wine/shellpath.c b/dll/win32/shell32/wine/shellpath.c index c65ac4ed47..02072e9a85 100644 --- a/dll/win32/shell32/wine/shellpath.c +++ b/dll/win32/shell32/wine/shellpath.c @@ -645,7 +645,8 @@ typedef enum _CSIDL_Type { CSIDL_Type_SystemX86Path, } CSIDL_Type; -#if WIN32_WINNT >= 0x0600 +/* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */ +#ifndef __REACTOS__ #define CSIDL_CONTACTS 0x0043 #define CSIDL_DOWNLOADS 0x0047 #define CSIDL_LINKS 0x004d @@ -1042,7 +1043,8 @@ static const CSIDL_DATA CSIDL_Data[] = NULL, NULL }, -#if WIN32_WINNT >= 0x0600 +/* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */ +#ifndef __REACTOS__ { /* 0x3f */ &FOLDERID_AddNewPrograms, CSIDL_Type_Disallowed, @@ -2271,7 +2273,8 @@ static HRESULT _SHRegisterUserShellFolders(BOOL bDefault) CSIDL_MYPICTURES, CSIDL_FONTS, CSIDL_ADMINTOOLS, -#if WIN32_WINNT >= 0x0600 +/* Cannot use #if _WIN32_WINNT >= 0x0600 because _WIN32_WINNT == 0x0600 here. */ +#ifndef __REACTOS__ CSIDL_CONTACTS, CSIDL_DOWNLOADS, CSIDL_LINKS,
7 years
1
0
0
0
[reactos] 01/01: [AFD] Introduce and use pool tags. Thanks go to Arty for assisting me with this. CORE-14048
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b8309397b57c2a1fffb12…
commit b8309397b57c2a1fffb12e63d9a15becfd2fae57 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Dec 2 00:20:14 2017 +0100 [AFD] Introduce and use pool tags. Thanks go to Arty for assisting me with this. CORE-14048 --- drivers/network/afd/afd/bind.c | 11 +++- drivers/network/afd/afd/connect.c | 68 +++++++++++++++++++------ drivers/network/afd/afd/context.c | 7 +-- drivers/network/afd/afd/event.c | 24 ++++++--- drivers/network/afd/afd/info.c | 14 +++-- drivers/network/afd/afd/listen.c | 25 ++++++--- drivers/network/afd/afd/lock.c | 29 +++++++---- drivers/network/afd/afd/main.c | 104 ++++++++++++++++++++++---------------- drivers/network/afd/afd/read.c | 19 ++++--- drivers/network/afd/afd/select.c | 6 ++- drivers/network/afd/afd/tdi.c | 41 +++++++++------ drivers/network/afd/afd/tdiconn.c | 16 +++--- drivers/network/afd/afd/write.c | 10 ++-- drivers/network/afd/include/afd.h | 18 +++++++ 14 files changed, 269 insertions(+), 123 deletions(-) diff --git a/drivers/network/afd/afd/bind.c b/drivers/network/afd/afd/bind.c index 15767d04d2..1962d226fa 100644 --- a/drivers/network/afd/afd/bind.c +++ b/drivers/network/afd/afd/bind.c @@ -43,7 +43,10 @@ NTSTATUS WarmSocketForBind( PAFD_FCB FCB, ULONG ShareType ) { if (NT_SUCCESS(Status) && !FCB->Recv.Window) { - FCB->Recv.Window = ExAllocatePool(PagedPool, FCB->Recv.Size); + FCB->Recv.Window = ExAllocatePoolWithTag(PagedPool, + FCB->Recv.Size, + TAG_AFD_DATA_BUFFER); + if (!FCB->Recv.Window) Status = STATUS_NO_MEMORY; } @@ -87,7 +90,11 @@ AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 ); - if( FCB->LocalAddress ) ExFreePool( FCB->LocalAddress ); + if (FCB->LocalAddress) + { + ExFreePoolWithTag(FCB->LocalAddress, TAG_AFD_TRANSPORT_ADDRESS); + } + FCB->LocalAddress = TaCopyTransportAddress( &BindReq->Address ); if( FCB->LocalAddress ) diff --git a/drivers/network/afd/afd/connect.c b/drivers/network/afd/afd/connect.c index 0144741a04..1562f5f985 100644 --- a/drivers/network/afd/afd/connect.c +++ b/drivers/network/afd/afd/connect.c @@ -59,13 +59,16 @@ AfdSetConnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->ConnectOptions) { - ExFreePool(FCB->ConnectOptions); + ExFreePoolWithTag(FCB->ConnectOptions, TAG_AFD_CONNECT_OPTIONS); FCB->ConnectOptions = NULL; FCB->ConnectOptionsSize = 0; FCB->FilledConnectOptions = 0; } - FCB->ConnectOptions = ExAllocatePool(PagedPool, ConnectOptionsSize); + FCB->ConnectOptions = ExAllocatePoolWithTag(PagedPool, + ConnectOptionsSize, + TAG_AFD_CONNECT_OPTIONS); + if (!FCB->ConnectOptions) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); @@ -103,12 +106,15 @@ AfdSetConnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->ConnectOptions) { - ExFreePool(FCB->ConnectOptions); + ExFreePoolWithTag(FCB->ConnectOptions, TAG_AFD_CONNECT_OPTIONS); FCB->ConnectOptionsSize = 0; FCB->FilledConnectOptions = 0; } - FCB->ConnectOptions = ExAllocatePool(PagedPool, *ConnectOptionsSize); + FCB->ConnectOptions = ExAllocatePoolWithTag(PagedPool, + *ConnectOptionsSize, + TAG_AFD_CONNECT_OPTIONS); + if (!FCB->ConnectOptions) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); FCB->ConnectOptionsSize = *ConnectOptionsSize; @@ -165,13 +171,16 @@ AfdSetConnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->ConnectData) { - ExFreePool(FCB->ConnectData); + ExFreePoolWithTag(FCB->ConnectData, TAG_AFD_CONNECT_DATA); FCB->ConnectData = NULL; FCB->ConnectDataSize = 0; FCB->FilledConnectData = 0; } - FCB->ConnectData = ExAllocatePool(PagedPool, ConnectDataSize); + FCB->ConnectData = ExAllocatePoolWithTag(PagedPool, + ConnectDataSize, + TAG_AFD_CONNECT_DATA); + if (!FCB->ConnectData) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); RtlCopyMemory(FCB->ConnectData, @@ -208,12 +217,15 @@ AfdSetConnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->ConnectData) { - ExFreePool(FCB->ConnectData); + ExFreePoolWithTag(FCB->ConnectData, TAG_AFD_CONNECT_DATA); FCB->ConnectDataSize = 0; FCB->FilledConnectData = 0; } - FCB->ConnectData = ExAllocatePool(PagedPool, *ConnectDataSize); + FCB->ConnectData = ExAllocatePoolWithTag(PagedPool, + *ConnectDataSize, + TAG_AFD_CONNECT_DATA); + if (!FCB->ConnectData) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); FCB->ConnectDataSize = *ConnectDataSize; @@ -269,13 +281,19 @@ MakeSocketIntoConnection(PAFD_FCB FCB) { /* Allocate the receive area and start receiving */ if (!FCB->Recv.Window) { - FCB->Recv.Window = ExAllocatePool( PagedPool, FCB->Recv.Size ); + FCB->Recv.Window = ExAllocatePoolWithTag(PagedPool, + FCB->Recv.Size, + TAG_AFD_DATA_BUFFER); + if( !FCB->Recv.Window ) return STATUS_NO_MEMORY; } if (!FCB->Send.Window) { - FCB->Send.Window = ExAllocatePool( PagedPool, FCB->Send.Size ); + FCB->Send.Window = ExAllocatePoolWithTag(PagedPool, + FCB->Send.Size, + TAG_AFD_DATA_BUFFER); + if( !FCB->Send.Window ) return STATUS_NO_MEMORY; } @@ -434,7 +452,11 @@ AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS ) { - if( FCB->RemoteAddress ) ExFreePool( FCB->RemoteAddress ); + if (FCB->RemoteAddress) + { + ExFreePoolWithTag(FCB->RemoteAddress, TAG_AFD_TRANSPORT_ADDRESS); + } + FCB->RemoteAddress = TaCopyTransportAddress( &ConnectReq->RemoteAddress ); @@ -455,7 +477,11 @@ AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, return LeaveIrpUntilLater( FCB, Irp, FUNCTION_CONNECT ); case SOCKET_STATE_CREATED: - if( FCB->LocalAddress ) ExFreePool( FCB->LocalAddress ); + if (FCB->LocalAddress) + { + ExFreePoolWithTag(FCB->LocalAddress, TAG_AFD_TRANSPORT_ADDRESS); + } + FCB->LocalAddress = TaBuildNullTransportAddress( ConnectReq->RemoteAddress.Address[0].AddressType ); @@ -473,7 +499,11 @@ AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, /* Drop through to SOCKET_STATE_BOUND */ case SOCKET_STATE_BOUND: - if( FCB->RemoteAddress ) ExFreePool( FCB->RemoteAddress ); + if (FCB->RemoteAddress) + { + ExFreePoolWithTag(FCB->RemoteAddress, TAG_AFD_TRANSPORT_ADDRESS); + } + FCB->RemoteAddress = TaCopyTransportAddress( &ConnectReq->RemoteAddress ); @@ -487,14 +517,22 @@ AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, if( !NT_SUCCESS(Status) ) break; - if (FCB->ConnectReturnInfo) ExFreePool(FCB->ConnectReturnInfo); + if (FCB->ConnectReturnInfo) + { + ExFreePoolWithTag(FCB->ConnectReturnInfo, TAG_AFD_TDI_CONNECTION_INFORMATION); + } + Status = TdiBuildConnectionInfo ( &FCB->ConnectReturnInfo, &ConnectReq->RemoteAddress ); if( NT_SUCCESS(Status) ) { - if (FCB->ConnectCallInfo) ExFreePool(FCB->ConnectCallInfo); + if (FCB->ConnectCallInfo) + { + ExFreePoolWithTag(FCB->ConnectCallInfo, TAG_AFD_TDI_CONNECTION_INFORMATION); + } + Status = TdiBuildConnectionInfo(&FCB->ConnectCallInfo, &ConnectReq->RemoteAddress); } diff --git a/drivers/network/afd/afd/context.c b/drivers/network/afd/afd/context.c index 6bcc17c5db..6a72a1caec 100644 --- a/drivers/network/afd/afd/context.c +++ b/drivers/network/afd/afd/context.c @@ -75,12 +75,13 @@ AfdSetContext( PDEVICE_OBJECT DeviceObject, PIRP Irp, return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); if( FCB->Context ) { - ExFreePool( FCB->Context ); + ExFreePoolWithTag(FCB->Context, TAG_AFD_SOCKET_CONTEXT); FCB->ContextSize = 0; } - FCB->Context = ExAllocatePool( PagedPool, - IrpSp->Parameters.DeviceIoControl.InputBufferLength ); + FCB->Context = ExAllocatePoolWithTag(PagedPool, + IrpSp->Parameters.DeviceIoControl.InputBufferLength, + TAG_AFD_SOCKET_CONTEXT); if( !FCB->Context ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 ); diff --git a/drivers/network/afd/afd/event.c b/drivers/network/afd/afd/event.c index 93f5f3d336..86fa211742 100644 --- a/drivers/network/afd/afd/event.c +++ b/drivers/network/afd/afd/event.c @@ -55,15 +55,21 @@ NTSTATUS AfdEventReceive( AFD_DbgPrint(MID_TRACE, ("Receiving (%d) bytes on socket\n", BytesAvailable)); - ReceiveBuffer = ExAllocatePool(NonPagedPool, BytesAvailable); + ReceiveBuffer = ExAllocatePoolWithTag(NonPagedPool, + BytesAvailable, + TAG_AFD_DATA_BUFFER); + if (!ReceiveBuffer) return STATUS_INSUFFICIENT_RESOURCES; /*Buffer = (PAFD_BUFFER)ExAllocateFromNPagedLookasideList( &BufferLookasideList);*/ - Buffer = (PAFD_BUFFER)ExAllocatePool(NonPagedPool, sizeof(AFD_BUFFER)); + Buffer = (PAFD_BUFFER)ExAllocatePoolWithTag(NonPagedPool, + sizeof(AFD_BUFFER), + TAG_AFD_DATA_BUFFER); + if (!Buffer) { - ExFreePool(ReceiveBuffer); + ExFreePoolWithTag(ReceiveBuffer, TAG_AFD_DATA_BUFFER); return STATUS_INSUFFICIENT_RESOURCES; } @@ -149,15 +155,21 @@ NTSTATUS AfdEventReceiveDatagramHandler( AFD_DbgPrint(MID_TRACE, ("Receiving (%d) bytes from (0x%X).\n", BytesAvailable, *(PULONG)SourceAddress)); - ReceiveBuffer = ExAllocatePool(NonPagedPool, BytesAvailable); + ReceiveBuffer = ExAllocatePoolWithTag(NonPagedPool, + BytesAvailable, + TAG_AFD_DATA_BUFFER); + if (!ReceiveBuffer) return STATUS_INSUFFICIENT_RESOURCES; /*Buffer = (PAFD_BUFFER)ExAllocateFromNPagedLookasideList( &BufferLookasideList);*/ - Buffer = (PAFD_BUFFER)ExAllocatePool(NonPagedPool, sizeof(AFD_BUFFER)); + Buffer = (PAFD_BUFFER)ExAllocatePoolWithTag(NonPagedPool, + sizeof(AFD_BUFFER), + TAG_AFD_DATA_BUFFER); + if (!Buffer) { - ExFreePool(ReceiveBuffer); + ExFreePoolWithTag(ReceiveBuffer, TAG_AFD_DATA_BUFFER); return STATUS_INSUFFICIENT_RESOURCES; } diff --git a/drivers/network/afd/afd/info.c b/drivers/network/afd/afd/info.c index 162f6606d2..1c05842e4e 100644 --- a/drivers/network/afd/afd/info.c +++ b/drivers/network/afd/afd/info.c @@ -124,7 +124,10 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp, FCB->OobInline = InfoReq->Information.Boolean; break; case AFD_INFO_RECEIVE_WINDOW_SIZE: - NewBuffer = ExAllocatePool(PagedPool, InfoReq->Information.Ulong); + NewBuffer = ExAllocatePoolWithTag(PagedPool, + InfoReq->Information.Ulong, + TAG_AFD_DATA_BUFFER); + if (NewBuffer) { if (FCB->Recv.Content > InfoReq->Information.Ulong) @@ -136,7 +139,7 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp, FCB->Recv.Window, FCB->Recv.Content); - ExFreePool(FCB->Recv.Window); + ExFreePoolWithTag(FCB->Recv.Window, TAG_AFD_DATA_BUFFER); } FCB->Recv.Size = InfoReq->Information.Ulong; @@ -150,7 +153,10 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp, } break; case AFD_INFO_SEND_WINDOW_SIZE: - NewBuffer = ExAllocatePool(PagedPool, InfoReq->Information.Ulong); + NewBuffer = ExAllocatePoolWithTag(PagedPool, + InfoReq->Information.Ulong, + TAG_AFD_DATA_BUFFER); + if (NewBuffer) { if (FCB->Send.BytesUsed > InfoReq->Information.Ulong) @@ -162,7 +168,7 @@ AfdSetInfo( PDEVICE_OBJECT DeviceObject, PIRP Irp, FCB->Send.Window, FCB->Send.BytesUsed); - ExFreePool(FCB->Send.Window); + ExFreePoolWithTag(FCB->Send.Window, TAG_AFD_DATA_BUFFER); } FCB->Send.Size = InfoReq->Information.Ulong; diff --git a/drivers/network/afd/afd/listen.c b/drivers/network/afd/afd/listen.c index 120ad11f7f..9a5a50b30a 100644 --- a/drivers/network/afd/afd/listen.c +++ b/drivers/network/afd/afd/listen.c @@ -27,7 +27,11 @@ static NTSTATUS SatisfyAccept( PAFD_DEVICE_EXTENSION DeviceExt, FCB->Connection = Qelt->Object; - if( FCB->RemoteAddress ) ExFreePool( FCB->RemoteAddress ); + if (FCB->RemoteAddress) + { + ExFreePoolWithTag(FCB->RemoteAddress, TAG_AFD_TRANSPORT_ADDRESS); + } + FCB->RemoteAddress = TaCopyTransportAddress( Qelt->ConnInfo->RemoteAddress ); @@ -115,13 +119,17 @@ static NTSTATUS NTAPI ListenComplete( PDEVICE_OBJECT DeviceObject, /* Free ConnectionReturnInfo and ConnectionCallInfo */ if (FCB->ListenIrp.ConnectionReturnInfo) { - ExFreePool(FCB->ListenIrp.ConnectionReturnInfo); + ExFreePoolWithTag(FCB->ListenIrp.ConnectionReturnInfo, + TAG_AFD_TDI_CONNECTION_INFORMATION); + FCB->ListenIrp.ConnectionReturnInfo = NULL; } if (FCB->ListenIrp.ConnectionCallInfo) { - ExFreePool(FCB->ListenIrp.ConnectionCallInfo); + ExFreePoolWithTag(FCB->ListenIrp.ConnectionCallInfo, + TAG_AFD_TDI_CONNECTION_INFORMATION); + FCB->ListenIrp.ConnectionCallInfo = NULL; } @@ -138,7 +146,10 @@ static NTSTATUS NTAPI ListenComplete( PDEVICE_OBJECT DeviceObject, return Irp->IoStatus.Status; } - Qelt = ExAllocatePool( NonPagedPool, sizeof(*Qelt) ); + Qelt = ExAllocatePoolWithTag(NonPagedPool, + sizeof(*Qelt), + TAG_AFD_ACCEPT_QUEUE); + if( !Qelt ) { Status = STATUS_NO_MEMORY; } else { @@ -256,7 +267,9 @@ NTSTATUS AfdListenSocket( PDEVICE_OBJECT DeviceObject, PIRP Irp, if (!NT_SUCCESS(Status)) { - ExFreePool(FCB->ListenIrp.ConnectionCallInfo); + ExFreePoolWithTag(FCB->ListenIrp.ConnectionCallInfo, + TAG_AFD_TDI_CONNECTION_INFORMATION); + FCB->ListenIrp.ConnectionCallInfo = NULL; return UnlockAndMaybeComplete(FCB, Status, Irp, 0); } @@ -372,7 +385,7 @@ NTSTATUS AfdAccept( PDEVICE_OBJECT DeviceObject, PIRP Irp, AFD_DbgPrint(MID_TRACE,("Completed a wait for accept\n")); - ExFreePool( PendingConnObj ); + ExFreePoolWithTag(PendingConnObj, TAG_AFD_ACCEPT_QUEUE); if( !IsListEmpty( &FCB->PendingConnections ) ) { diff --git a/drivers/network/afd/afd/lock.c b/drivers/network/afd/afd/lock.c index 714987d50b..aed7b8120a 100644 --- a/drivers/network/afd/afd/lock.c +++ b/drivers/network/afd/afd/lock.c @@ -69,7 +69,10 @@ PVOID LockRequest( PIRP Irp, } /* The allocated address goes in index 0 */ - Irp->Tail.Overlay.DriverContext[0] = ExAllocatePool(NonPagedPool, MmGetMdlByteCount(Irp->MdlAddress)); + Irp->Tail.Overlay.DriverContext[0] = ExAllocatePoolWithTag(NonPagedPool, + MmGetMdlByteCount(Irp->MdlAddress), + TAG_AFD_DATA_BUFFER); + if (!Irp->Tail.Overlay.DriverContext[0]) { AFD_DbgPrint(MIN_TRACE,("Failed to allocate memory\n")); @@ -126,7 +129,10 @@ PVOID LockRequest( PIRP Irp, } /* We need to create the info struct that AFD expects for all send/recv requests */ - AfdInfo = ExAllocatePool(NonPagedPool, sizeof(AFD_RECV_INFO) + sizeof(AFD_WSABUF)); + AfdInfo = ExAllocatePoolWithTag(NonPagedPool, + sizeof(AFD_RECV_INFO) + sizeof(AFD_WSABUF), + TAG_AFD_DATA_BUFFER); + if (!AfdInfo) { AFD_DbgPrint(MIN_TRACE,("Failed to allocate memory\n")); @@ -186,7 +192,7 @@ VOID UnlockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) MmGetMdlByteCount(Irp->MdlAddress)); } - ExFreePool(Irp->Tail.Overlay.DriverContext[0]); + ExFreePoolWithTag(Irp->Tail.Overlay.DriverContext[0], TAG_AFD_DATA_BUFFER); MmUnlockPages( Irp->MdlAddress ); IoFreeMdl( Irp->MdlAddress ); Irp->MdlAddress = NULL; @@ -204,7 +210,7 @@ PAFD_WSABUF LockBuffers( PAFD_WSABUF Buf, UINT Count, /* Copy the buffer array so we don't lose it */ UINT Lock = LockAddress ? 2 : 0; UINT Size = (sizeof(AFD_WSABUF) + sizeof(AFD_MAPBUF)) * (Count + Lock); - PAFD_WSABUF NewBuf = ExAllocatePool( PagedPool, Size ); + PAFD_WSABUF NewBuf = ExAllocatePoolWithTag(PagedPool, Size, TAG_AFD_WSA_BUFFER); BOOLEAN LockFailed = FALSE; PAFD_MAPBUF MapBuf; @@ -230,7 +236,7 @@ PAFD_WSABUF LockBuffers( PAFD_WSABUF Buf, UINT Count, AFD_DbgPrint(MIN_TRACE,("Access violation copying buffer info " "from userland (%p %p)\n", Buf, AddressLen)); - ExFreePool( NewBuf ); + ExFreePoolWithTag(NewBuf, TAG_AFD_WSA_BUFFER); _SEH2_YIELD(return NULL); } _SEH2_END; @@ -265,11 +271,11 @@ PAFD_WSABUF LockBuffers( PAFD_WSABUF Buf, UINT Count, AFD_DbgPrint(MIN_TRACE,("Failed to lock pages\n")); IoFreeMdl( MapBuf[i].Mdl ); MapBuf[i].Mdl = NULL; - ExFreePool( NewBuf ); + ExFreePoolWithTag(NewBuf, TAG_AFD_WSA_BUFFER); return NULL; } } else { - ExFreePool( NewBuf ); + ExFreePoolWithTag(NewBuf, TAG_AFD_WSA_BUFFER); return NULL; } } @@ -295,7 +301,7 @@ VOID UnlockBuffers( PAFD_WSABUF Buf, UINT Count, BOOL Address ) { } } - ExFreePool( Buf ); + ExFreePoolWithTag(Buf, TAG_AFD_WSA_BUFFER); Buf = NULL; } @@ -305,8 +311,9 @@ PAFD_HANDLE LockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) { UINT i; NTSTATUS Status = STATUS_SUCCESS; - PAFD_HANDLE FileObjects = ExAllocatePool - ( NonPagedPool, HandleCount * sizeof(AFD_HANDLE) ); + PAFD_HANDLE FileObjects = ExAllocatePoolWithTag(NonPagedPool, + HandleCount * sizeof(AFD_HANDLE), + TAG_AFD_POLL_HANDLE); for( i = 0; FileObjects && i < HandleCount; i++ ) { FileObjects[i].Status = 0; @@ -346,7 +353,7 @@ VOID UnlockHandles( PAFD_HANDLE HandleArray, UINT HandleCount ) { ObDereferenceObject( (PVOID)HandleArray[i].Handle ); } - ExFreePool( HandleArray ); + ExFreePoolWithTag(HandleArray, TAG_AFD_POLL_HANDLE); HandleArray = NULL; } diff --git a/drivers/network/afd/afd/main.c b/drivers/network/afd/afd/main.c index c4feb08dbe..df2eccc835 100644 --- a/drivers/network/afd/afd/main.c +++ b/drivers/network/afd/afd/main.c @@ -86,13 +86,16 @@ AfdSetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->DisconnectOptions) { - ExFreePool(FCB->DisconnectOptions); + ExFreePoolWithTag(FCB->DisconnectOptions, TAG_AFD_DISCONNECT_OPTIONS); FCB->DisconnectOptions = NULL; FCB->DisconnectOptionsSize = 0; FCB->FilledDisconnectOptions = 0; } - FCB->DisconnectOptions = ExAllocatePool(PagedPool, DisconnectOptionsSize); + FCB->DisconnectOptions = ExAllocatePoolWithTag(PagedPool, + DisconnectOptionsSize, + TAG_AFD_DISCONNECT_OPTIONS); + if (!FCB->DisconnectOptions) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); @@ -130,12 +133,15 @@ AfdSetDisconnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->DisconnectOptions) { - ExFreePool(FCB->DisconnectOptions); + ExFreePoolWithTag(FCB->DisconnectOptions, TAG_AFD_DISCONNECT_OPTIONS); FCB->DisconnectOptionsSize = 0; FCB->FilledDisconnectOptions = 0; } - FCB->DisconnectOptions = ExAllocatePool(PagedPool, *DisconnectOptionsSize); + FCB->DisconnectOptions = ExAllocatePoolWithTag(PagedPool, + *DisconnectOptionsSize, + TAG_AFD_DISCONNECT_OPTIONS); + if (!FCB->DisconnectOptions) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); FCB->DisconnectOptionsSize = *DisconnectOptionsSize; @@ -192,13 +198,16 @@ AfdSetDisconnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->DisconnectData) { - ExFreePool(FCB->DisconnectData); + ExFreePoolWithTag(FCB->DisconnectData, TAG_AFD_DISCONNECT_DATA); FCB->DisconnectData = NULL; FCB->DisconnectDataSize = 0; FCB->FilledDisconnectData = 0; } - FCB->DisconnectData = ExAllocatePool(PagedPool, DisconnectDataSize); + FCB->DisconnectData = ExAllocatePoolWithTag(PagedPool, + DisconnectDataSize, + TAG_AFD_DISCONNECT_DATA); + if (!FCB->DisconnectData) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); @@ -236,12 +245,15 @@ AfdSetDisconnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->DisconnectData) { - ExFreePool(FCB->DisconnectData); + ExFreePoolWithTag(FCB->DisconnectData, TAG_AFD_DISCONNECT_DATA); FCB->DisconnectDataSize = 0; FCB->FilledDisconnectData = 0; } - FCB->DisconnectData = ExAllocatePool(PagedPool, *DisconnectDataSize); + FCB->DisconnectData = ExAllocatePoolWithTag(PagedPool, + *DisconnectDataSize, + TAG_AFD_DISCONNECT_DATA); + if (!FCB->DisconnectData) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); @@ -319,7 +331,7 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n")); - FCB = ExAllocatePool(NonPagedPool, sizeof(AFD_FCB)); + FCB = ExAllocatePoolWithTag(NonPagedPool, sizeof(AFD_FCB), TAG_AFD_FCB); if( FCB == NULL ) { Irp->IoStatus.Status = STATUS_NO_MEMORY; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -354,11 +366,12 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, if( ConnectInfo ) { FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName; FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length; - FCB->TdiDeviceName.Buffer = - ExAllocatePool( NonPagedPool, FCB->TdiDeviceName.Length ); + FCB->TdiDeviceName.Buffer = ExAllocatePoolWithTag(NonPagedPool, + FCB->TdiDeviceName.Length, + TAG_AFD_TRANSPORT_ADDRESS); if( !FCB->TdiDeviceName.Buffer ) { - ExFreePool(FCB); + ExFreePoolWithTag(FCB, TAG_AFD_FCB); AFD_DbgPrint(MID_TRACE,("Could not copy target string\n")); Irp->IoStatus.Status = STATUS_NO_MEMORY; IoCompleteRequest( Irp, IO_NETWORK_INCREMENT ); @@ -388,8 +401,11 @@ AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, } if( !NT_SUCCESS(Status) ) { - if( FCB->TdiDeviceName.Buffer ) ExFreePool( FCB->TdiDeviceName.Buffer ); - ExFreePool( FCB ); + if (FCB->TdiDeviceName.Buffer) + { + ExFreePoolWithTag(FCB->TdiDeviceName.Buffer, TAG_AFD_TRANSPORT_ADDRESS); + } + ExFreePoolWithTag(FCB, TAG_AFD_FCB); FileObject->FsContext = NULL; } @@ -485,7 +501,7 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, ObDereferenceObject(Qelt->Object.Object); ZwClose(Qelt->Object.Handle); - ExFreePool(Qelt); + ExFreePoolWithTag(Qelt, TAG_AFD_ACCEPT_QUEUE); } SocketStateUnlock( FCB ); @@ -493,41 +509,41 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, if( FCB->EventSelect ) ObDereferenceObject( FCB->EventSelect ); - if( FCB->Context ) - ExFreePool( FCB->Context ); + if (FCB->Context) + ExFreePoolWithTag(FCB->Context, TAG_AFD_SOCKET_CONTEXT); - if( FCB->Recv.Window ) - ExFreePool( FCB->Recv.Window ); + if (FCB->Recv.Window) + ExFreePoolWithTag(FCB->Recv.Window, TAG_AFD_DATA_BUFFER); - if( FCB->Send.Window ) - ExFreePool( FCB->Send.Window ); + if (FCB->Send.Window) + ExFreePoolWithTag(FCB->Send.Window, TAG_AFD_DATA_BUFFER); - if( FCB->AddressFrom ) - ExFreePool( FCB->AddressFrom ); + if (FCB->AddressFrom) + ExFreePoolWithTag(FCB->AddressFrom, TAG_AFD_TDI_CONNECTION_INFORMATION); - if( FCB->ConnectCallInfo ) - ExFreePool( FCB->ConnectCallInfo ); + if (FCB->ConnectCallInfo) + ExFreePoolWithTag(FCB->ConnectCallInfo, TAG_AFD_TDI_CONNECTION_INFORMATION); - if( FCB->ConnectReturnInfo ) - ExFreePool( FCB->ConnectReturnInfo ); + if (FCB->ConnectReturnInfo) + ExFreePoolWithTag(FCB->ConnectReturnInfo, TAG_AFD_TDI_CONNECTION_INFORMATION); - if( FCB->ConnectData ) - ExFreePool( FCB->ConnectData ); + if (FCB->ConnectData) + ExFreePoolWithTag(FCB->ConnectData, TAG_AFD_CONNECT_DATA); - if( FCB->DisconnectData ) - ExFreePool( FCB->DisconnectData ); + if (FCB->DisconnectData) + ExFreePoolWithTag(FCB->DisconnectData, TAG_AFD_DISCONNECT_DATA); - if( FCB->ConnectOptions ) - ExFreePool( FCB->ConnectOptions ); + if (FCB->ConnectOptions) + ExFreePoolWithTag(FCB->ConnectOptions, TAG_AFD_CONNECT_OPTIONS); - if( FCB->DisconnectOptions ) - ExFreePool( FCB->DisconnectOptions ); + if (FCB->DisconnectOptions) + ExFreePoolWithTag(FCB->DisconnectOptions, TAG_AFD_DISCONNECT_OPTIONS); - if( FCB->LocalAddress ) - ExFreePool( FCB->LocalAddress ); + if (FCB->LocalAddress) + ExFreePoolWithTag(FCB->LocalAddress, TAG_AFD_TRANSPORT_ADDRESS); - if( FCB->RemoteAddress ) - ExFreePool( FCB->RemoteAddress ); + if (FCB->RemoteAddress) + ExFreePoolWithTag(FCB->RemoteAddress, TAG_AFD_TRANSPORT_ADDRESS); if( FCB->Connection.Object ) { @@ -554,10 +570,12 @@ AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, } } - if( FCB->TdiDeviceName.Buffer ) - ExFreePool(FCB->TdiDeviceName.Buffer); + if (FCB->TdiDeviceName.Buffer) + { + ExFreePoolWithTag(FCB->TdiDeviceName.Buffer, TAG_AFD_TRANSPORT_ADDRESS); + } - ExFreePool(FCB); + ExFreePoolWithTag(FCB, TAG_AFD_FCB); Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; @@ -817,7 +835,7 @@ AfdDisconnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, return UnlockAndMaybeComplete(FCB, STATUS_INVALID_PARAMETER, Irp, 0); } - ExFreePool(FCB->RemoteAddress); + ExFreePoolWithTag(FCB->RemoteAddress, TAG_AFD_TRANSPORT_ADDRESS); FCB->RemoteAddress = NULL; } diff --git a/drivers/network/afd/afd/read.c b/drivers/network/afd/afd/read.c index fff6797e93..b0ff01add6 100644 --- a/drivers/network/afd/afd/read.c +++ b/drivers/network/afd/afd/read.c @@ -409,8 +409,8 @@ SatisfyPacketRecvRequest( PAFD_FCB FCB, PIRP Irp, if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) { FCB->Recv.Content -= DatagramRecv->Len; - ExFreePool( DatagramRecv->Address ); - ExFreePool( DatagramRecv ); + ExFreePoolWithTag(DatagramRecv->Address, TAG_AFD_TRANSPORT_ADDRESS); + ExFreePoolWithTag(DatagramRecv, TAG_AFD_STORED_DATAGRAM); } AFD_DbgPrint(MID_TRACE,("Done\n")); @@ -584,8 +584,8 @@ PacketSocketRecvComplete( while( !IsListEmpty( &FCB->DatagramList ) ) { DatagramRecvEntry = RemoveHeadList(&FCB->DatagramList); DatagramRecv = CONTAINING_RECORD(DatagramRecvEntry, AFD_STORED_DATAGRAM, ListEntry); - ExFreePool( DatagramRecv->Address ); - ExFreePool( DatagramRecv ); + ExFreePoolWithTag(DatagramRecv->Address, TAG_AFD_TRANSPORT_ADDRESS); + ExFreePoolWithTag(DatagramRecv, TAG_AFD_STORED_DATAGRAM); } SocketStateUnlock( FCB ); @@ -604,7 +604,9 @@ PacketSocketRecvComplete( return STATUS_FILE_CLOSED; } - DatagramRecv = ExAllocatePool( NonPagedPool, DGSize ); + DatagramRecv = ExAllocatePoolWithTag(NonPagedPool, + DGSize, + TAG_AFD_STORED_DATAGRAM); if( DatagramRecv ) { DatagramRecv->Len = Irp->IoStatus.Information; @@ -620,7 +622,12 @@ PacketSocketRecvComplete( } else Status = STATUS_NO_MEMORY; if( !NT_SUCCESS( Status ) ) { - if( DatagramRecv ) ExFreePool( DatagramRecv ); + + if (DatagramRecv) + { + ExFreePoolWithTag(DatagramRecv, TAG_AFD_STORED_DATAGRAM); + } + SocketStateUnlock( FCB ); return Status; } else { diff --git a/drivers/network/afd/afd/select.c b/drivers/network/afd/afd/select.c index 2835f9c2ef..6c8e5a279d 100644 --- a/drivers/network/afd/afd/select.c +++ b/drivers/network/afd/afd/select.c @@ -68,7 +68,7 @@ VOID SignalSocket( { KeCancelTimer( &Poll->Timer ); RemoveEntryList( &Poll->ListEntry ); - ExFreePool( Poll ); + ExFreePoolWithTag(Poll, TAG_AFD_ACTIVE_POLL); } Irp->IoStatus.Status = Status; @@ -228,7 +228,9 @@ AfdSelect( PDEVICE_OBJECT DeviceObject, PIRP Irp, PAFD_ACTIVE_POLL Poll = NULL; - Poll = ExAllocatePool( NonPagedPool, sizeof(AFD_ACTIVE_POLL) ); + Poll = ExAllocatePoolWithTag(NonPagedPool, + sizeof(AFD_ACTIVE_POLL), + TAG_AFD_ACTIVE_POLL); if (Poll){ Poll->Irp = Irp; diff --git a/drivers/network/afd/afd/tdi.c b/drivers/network/afd/afd/tdi.c index b480303e61..75085bcc22 100644 --- a/drivers/network/afd/afd/tdi.c +++ b/drivers/network/afd/afd/tdi.c @@ -196,7 +196,9 @@ NTSTATUS TdiOpenAddressFile( EaLength = sizeof(FILE_FULL_EA_INFORMATION) + TDI_TRANSPORT_ADDRESS_LENGTH + TaLengthOfTransportAddress( Name ) + 1; - EaInfo = (PFILE_FULL_EA_INFORMATION)ExAllocatePool(NonPagedPool, EaLength); + EaInfo = (PFILE_FULL_EA_INFORMATION)ExAllocatePoolWithTag(NonPagedPool, + EaLength, + TAG_AFD_EA_INFO); if (!EaInfo) return STATUS_INSUFFICIENT_RESOURCES; @@ -217,7 +219,7 @@ NTSTATUS TdiOpenAddressFile( ShareType, AddressHandle, AddressObject); - ExFreePool(EaInfo); + ExFreePoolWithTag(EaInfo, TAG_AFD_EA_INFO); return Status; } @@ -229,13 +231,16 @@ NTSTATUS TdiQueryMaxDatagramLength( PTDI_MAX_DATAGRAM_INFO Buffer; NTSTATUS Status = STATUS_SUCCESS; - Buffer = ExAllocatePool(NonPagedPool, sizeof(TDI_MAX_DATAGRAM_INFO)); + Buffer = ExAllocatePoolWithTag(NonPagedPool, + sizeof(TDI_MAX_DATAGRAM_INFO), + TAG_AFD_DATA_BUFFER); + if (!Buffer) return STATUS_NO_MEMORY; Mdl = IoAllocateMdl(Buffer, sizeof(TDI_MAX_DATAGRAM_INFO), FALSE, FALSE, NULL); if (!Mdl) { - ExFreePool(Buffer); + ExFreePoolWithTag(Buffer, TAG_AFD_DATA_BUFFER); return STATUS_NO_MEMORY; } @@ -253,7 +258,7 @@ NTSTATUS TdiQueryMaxDatagramLength( { AFD_DbgPrint(MIN_TRACE,("Failed to lock pages\n")); IoFreeMdl(Mdl); - ExFreePool(Buffer); + ExFreePoolWithTag(Buffer, TAG_AFD_DATA_BUFFER); return Status; } @@ -262,13 +267,13 @@ NTSTATUS TdiQueryMaxDatagramLength( Mdl); if (!NT_SUCCESS(Status)) { - ExFreePool(Buffer); + ExFreePoolWithTag(Buffer, TAG_AFD_DATA_BUFFER); return Status; } *MaxDatagramLength = Buffer->MaxDatagramSize; - ExFreePool(Buffer); + ExFreePoolWithTag(Buffer, TAG_AFD_DATA_BUFFER); return STATUS_SUCCESS; } @@ -299,7 +304,9 @@ NTSTATUS TdiOpenConnectionEndpointFile( TDI_CONNECTION_CONTEXT_LENGTH + sizeof(PVOID) + 1; - EaInfo = (PFILE_FULL_EA_INFORMATION)ExAllocatePool(NonPagedPool, EaLength); + EaInfo = (PFILE_FULL_EA_INFORMATION)ExAllocatePoolWithTag(NonPagedPool, + EaLength, + TAG_AFD_EA_INFO); if (!EaInfo) return STATUS_INSUFFICIENT_RESOURCES; @@ -319,7 +326,7 @@ NTSTATUS TdiOpenConnectionEndpointFile( AFD_SHARE_UNIQUE, ConnectionHandle, ConnectionObject); - ExFreePool(EaInfo); + ExFreePoolWithTag(EaInfo, TAG_AFD_EA_INFO); return Status; } @@ -776,7 +783,9 @@ NTSTATUS TdiQueryAddress( AFD_DbgPrint(MAX_TRACE, ("Called\n")); BufferSize = sizeof(TDIEntityID) * 20; - Entities = (TDIEntityID*)ExAllocatePool(NonPagedPool, BufferSize); + Entities = (TDIEntityID*)ExAllocatePoolWithTag(NonPagedPool, + BufferSize, + TAG_AFD_TRANSPORT_ADDRESS); if (!Entities) { AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n")); return STATUS_INSUFFICIENT_RESOURCES; @@ -794,7 +803,7 @@ NTSTATUS TdiQueryAddress( &BufferSize); /* Output buffer size */ if (!NT_SUCCESS(Status)) { AFD_DbgPrint(MIN_TRACE, ("Unable to get list of supported entities (Status = 0x%X).\n", Status)); - ExFreePool(Entities); + ExFreePoolWithTag(Entities, TAG_AFD_TRANSPORT_ADDRESS); return Status; } @@ -841,7 +850,9 @@ NTSTATUS TdiQueryAddress( if (SnmpInfo.ipsi_numaddr != 0) { BufferSize = SnmpInfo.ipsi_numaddr * sizeof(IPADDR_ENTRY); - IpAddress = (PIPADDR_ENTRY)ExAllocatePool(NonPagedPool, BufferSize); + IpAddress = (PIPADDR_ENTRY)ExAllocatePoolWithTag(NonPagedPool, + BufferSize, + TAG_AFD_SNMP_ADDRESS_INFO); if (!IpAddress) { AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n")); break; @@ -857,7 +868,7 @@ NTSTATUS TdiQueryAddress( &BufferSize); /* Output buffer size */ if (!NT_SUCCESS(Status)) { AFD_DbgPrint(MIN_TRACE, ("Unable to get IP address (Status = 0x%X).\n", Status)); - ExFreePool(IpAddress); + ExFreePoolWithTag(IpAddress, TAG_AFD_SNMP_ADDRESS_INFO); break; } @@ -869,7 +880,7 @@ NTSTATUS TdiQueryAddress( *Address = DN2H(IpAddress->Addr); } - ExFreePool(IpAddress); + ExFreePoolWithTag(IpAddress, TAG_AFD_SNMP_ADDRESS_INFO); } else { Status = STATUS_UNSUCCESSFUL; break; @@ -877,7 +888,7 @@ NTSTATUS TdiQueryAddress( } } - ExFreePool(Entities); + ExFreePoolWithTag(Entities, TAG_AFD_TRANSPORT_ADDRESS); AFD_DbgPrint(MAX_TRACE, ("Leaving\n")); diff --git a/drivers/network/afd/afd/tdiconn.c b/drivers/network/afd/afd/tdiconn.c index 12454b9e94..afa9f0f1d9 100644 --- a/drivers/network/afd/afd/tdiconn.c +++ b/drivers/network/afd/afd/tdiconn.c @@ -85,7 +85,9 @@ PTRANSPORT_ADDRESS TaCopyTransportAddress( PTRANSPORT_ADDRESS OtherAddress ) { if (!AddrLen) return NULL; - A = ExAllocatePool( NonPagedPool, AddrLen ); + A = ExAllocatePoolWithTag(NonPagedPool, + AddrLen, + TAG_AFD_TRANSPORT_ADDRESS); if( A ) TaCopyTransportAddressInPlace( A, OtherAddress ); @@ -117,13 +119,13 @@ PTRANSPORT_ADDRESS TaBuildNullTransportAddress(UINT AddressType) if (!AddrLen) return NULL; - A = ExAllocatePool(NonPagedPool, AddrLen); + A = ExAllocatePoolWithTag(NonPagedPool, AddrLen, TAG_AFD_TRANSPORT_ADDRESS); if (A) { if (TdiBuildNullTransportAddressInPlace(A, AddressType) != STATUS_SUCCESS) { - ExFreePool(A); + ExFreePoolWithTag(A, TAG_AFD_TRANSPORT_ADDRESS); return NULL; } } @@ -190,9 +192,9 @@ NTSTATUS TdiBuildNullConnectionInfo } ConnInfo = (PTDI_CONNECTION_INFORMATION) - ExAllocatePool(NonPagedPool, - sizeof(TDI_CONNECTION_INFORMATION) + - TdiAddressSize); + ExAllocatePoolWithTag(NonPagedPool, + sizeof(TDI_CONNECTION_INFORMATION) + TdiAddressSize, + TAG_AFD_TDI_CONNECTION_INFORMATION); if (!ConnInfo) { *ConnectionInfo = NULL; return STATUS_INSUFFICIENT_RESOURCES; @@ -202,7 +204,7 @@ NTSTATUS TdiBuildNullConnectionInfo if (!NT_SUCCESS(Status)) { - ExFreePool( ConnInfo ); + ExFreePoolWithTag(ConnInfo, TAG_AFD_TDI_CONNECTION_INFORMATION); ConnInfo = NULL; } diff --git a/drivers/network/afd/afd/write.c b/drivers/network/afd/afd/write.c index e1c1fe2a55..605676102a 100644 --- a/drivers/network/afd/afd/write.c +++ b/drivers/network/afd/afd/write.c @@ -398,7 +398,7 @@ AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp, } } - ExFreePool( TargetAddress ); + ExFreePoolWithTag(TargetAddress, TAG_AFD_TDI_CONNECTION_INFORMATION); SocketStateUnlock(FCB); @@ -597,7 +597,11 @@ AfdPacketSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp, if (FCB->State == SOCKET_STATE_CREATED) { - if( FCB->LocalAddress ) ExFreePool( FCB->LocalAddress ); + if (FCB->LocalAddress) + { + ExFreePoolWithTag(FCB->LocalAddress, TAG_AFD_TRANSPORT_ADDRESS); + } + FCB->LocalAddress = TaBuildNullTransportAddress( ((PTRANSPORT_ADDRESS)SendReq->TdiConnection.RemoteAddress)-> Address[0].AddressType ); @@ -660,7 +664,7 @@ AfdPacketSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp, } } - ExFreePool(TargetAddress); + ExFreePoolWithTag(TargetAddress, TAG_AFD_TDI_CONNECTION_INFORMATION); SocketStateUnlock(FCB); diff --git a/drivers/network/afd/include/afd.h b/drivers/network/afd/include/afd.h index f3ae253aff..21aaac5f42 100644 --- a/drivers/network/afd/include/afd.h +++ b/drivers/network/afd/include/afd.h @@ -35,6 +35,24 @@ #define IP_MIB_STATS_ID 1 #define IP_MIB_ADDRTABLE_ENTRY_ID 0x102 +#define TAG_AFD_DATA_BUFFER 'BdfA' +#define TAG_AFD_TRANSPORT_ADDRESS 'tdfA' +#define TAG_AFD_SOCKET_CONTEXT 'XdfA' +#define TAG_AFD_CONNECT_DATA 'cdfA' +#define TAG_AFD_DISCONNECT_DATA 'ddfA' + +#define TAG_AFD_CONNECT_OPTIONS 'ocfA' +#define TAG_AFD_DISCONNECT_OPTIONS 'odfA' +#define TAG_AFD_ACCEPT_QUEUE 'qafA' +#define TAG_AFD_POLL_HANDLE 'hpfA' +#define TAG_AFD_FCB 'cffA' +#define TAG_AFD_ACTIVE_POLL 'pafA' +#define TAG_AFD_EA_INFO 'aefA' +#define TAG_AFD_STORED_DATAGRAM 'gsfA' +#define TAG_AFD_SNMP_ADDRESS_INFO 'asfA' +#define TAG_AFD_TDI_CONNECTION_INFORMATION 'cTfA' +#define TAG_AFD_WSA_BUFFER 'bWfA' + typedef struct IPADDR_ENTRY { ULONG Addr; ULONG Index;
7 years
1
0
0
0
[reactos] 02/02: [IPHLPAPI] Implement interface name resolving functions
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a2cc76af845b2a037a6a4…
commit a2cc76af845b2a037a6a472b740ce437107d9bd7 Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sat Nov 25 23:18:48 2017 +0300 [IPHLPAPI] Implement interface name resolving functions Including: - NhGetInterfaceNameFromDeviceGuid - NhGetInterfaceNameFromGuid CORE-13831, CORE-14033 Reference:
https://github.com/boundary/wireshark/blob/master/capture_win_ifnames.c#L275
--- dll/win32/iphlpapi/iphlpapi.spec | 4 +- dll/win32/iphlpapi/iphlpapi_main.c | 94 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/dll/win32/iphlpapi/iphlpapi.spec b/dll/win32/iphlpapi/iphlpapi.spec index 6fd9462501..76b5fb30d3 100644 --- a/dll/win32/iphlpapi/iphlpapi.spec +++ b/dll/win32/iphlpapi/iphlpapi.spec @@ -108,8 +108,8 @@ @ stub NTPTimeToNTFileTime @ stub NTTimeToNTPTime @ stub NhGetGuidFromInterfaceName -@ stdcall NhGetInterfaceNameFromDeviceGuid(long long long long long) -@ stub NhGetInterfaceNameFromGuid +@ stdcall NhGetInterfaceNameFromDeviceGuid(ptr ptr ptr long long) +@ stdcall NhGetInterfaceNameFromGuid(ptr ptr ptr long long) @ stdcall NhpAllocateAndGetInterfaceInfoFromStack(ptr ptr long ptr long) @ stub NhpGetInterfaceIndexFromStack @ stdcall NotifyAddrChange( ptr ptr ) diff --git a/dll/win32/iphlpapi/iphlpapi_main.c b/dll/win32/iphlpapi/iphlpapi_main.c index a7df4cdcec..af8cbd1805 100644 --- a/dll/win32/iphlpapi/iphlpapi_main.c +++ b/dll/win32/iphlpapi/iphlpapi_main.c @@ -22,6 +22,7 @@ #include <config.h> #include "iphlpapi_private.h" +#include <strsafe.h> WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); @@ -2619,13 +2620,96 @@ SetIpForwardEntryToStack(PMIB_IPFORWARDROW pRoute) return 0L; } +DWORD GetInterfaceNameInternal(_In_ const GUID * pInterfaceGUID, + _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, + _Inout_ PULONG pOutBufLen) +{ + UNICODE_STRING GuidString; + DWORD result, type; + WCHAR szKeyName[2*MAX_PATH]; + HRESULT hr; + HKEY hKey; + + if (pInterfaceGUID == NULL || pOutBufLen == NULL) + return ERROR_INVALID_PARAMETER; + + result = RtlStringFromGUID(pInterfaceGUID, &GuidString); + + if (!NT_SUCCESS(result)) + { + // failed to convert guid to string + return RtlNtStatusToDosError(result); + } + + hr = StringCbPrintfW(szKeyName, sizeof(szKeyName), L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", GuidString.Buffer); + RtlFreeUnicodeString(&GuidString); + + if (FAILED(hr)) + { + // key name is too long + return ERROR_BUFFER_OVERFLOW; + } + + result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKeyName, 0, KEY_READ, &hKey); + + if (result != ERROR_SUCCESS) + { + // failed to find adapter entry + return ERROR_NOT_FOUND; + } + + result = RegQueryValueExW(hKey, L"Name", NULL, &type, (PVOID)pInterfaceName, pOutBufLen); + + RegCloseKey(hKey); + + if (result == ERROR_MORE_DATA) + { + *pOutBufLen = MAX_INTERFACE_NAME_LEN * 2; + return ERROR_INSUFFICIENT_BUFFER; + } + + if (result != ERROR_SUCCESS || type != REG_SZ) + { + // failed to read adapter name + return ERROR_NO_DATA; + } + return ERROR_SUCCESS; +} + +/* + * @implemented + */ DWORD WINAPI -NhGetInterfaceNameFromDeviceGuid(DWORD dwUnknown1, - DWORD dwUnknown2, - DWORD dwUnknown3, +NhGetInterfaceNameFromDeviceGuid(_In_ const GUID * pInterfaceGUID, + _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, + _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5) { - FIXME("NhGetInterfaceNameFromDeviceGuid() stub\n"); - return 0L; + SetLastError(ERROR_SUCCESS); + + if (pInterfaceName == NULL) + return ERROR_INVALID_PARAMETER; + + return GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen); +} + +/* + * @implemented + */ +DWORD WINAPI +NhGetInterfaceNameFromGuid(_In_ const GUID * pInterfaceGUID, + _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, + _Inout_ PULONG pOutBufLen, + DWORD dwUnknown4, + DWORD dwUnknown5) +{ + DWORD result; + + result = GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen); + + if (result == ERROR_NOT_FOUND) + SetLastError(ERROR_PATH_NOT_FOUND); + + return result; }
7 years
1
0
0
0
[reactos] 01/02: [IPHLPAPI_APITEST] Add tests for interface resolving functions
by Stanislav Motylkov
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d6e0c422e1661223d6091…
commit d6e0c422e1661223d60910386164458cc02a9574 Author: Stanislav Motylkov <x86corez(a)gmail.com> AuthorDate: Sat Nov 25 20:06:21 2017 +0300 [IPHLPAPI_APITEST] Add tests for interface resolving functions CORE-13831, CORE-14033 --- modules/rostests/apitests/iphlpapi/CMakeLists.txt | 1 + .../rostests/apitests/iphlpapi/GetInterfaceName.c | 396 +++++++++++++++++++++ modules/rostests/apitests/iphlpapi/testlist.c | 2 + 3 files changed, 399 insertions(+) diff --git a/modules/rostests/apitests/iphlpapi/CMakeLists.txt b/modules/rostests/apitests/iphlpapi/CMakeLists.txt index c5ecc1457b..2a5a3ad754 100644 --- a/modules/rostests/apitests/iphlpapi/CMakeLists.txt +++ b/modules/rostests/apitests/iphlpapi/CMakeLists.txt @@ -1,5 +1,6 @@ list(APPEND SOURCE + GetInterfaceName.c GetNetworkParams.c icmp.c SendARP.c diff --git a/modules/rostests/apitests/iphlpapi/GetInterfaceName.c b/modules/rostests/apitests/iphlpapi/GetInterfaceName.c new file mode 100644 index 0000000000..f6e3321cee --- /dev/null +++ b/modules/rostests/apitests/iphlpapi/GetInterfaceName.c @@ -0,0 +1,396 @@ +/* + * PROJECT: ReactOS API Tests + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) + * PURPOSE: Tests for network interface name resolving functions + * COPYRIGHT: Copyright 2017 Stanislav Motylkov + */ + +#include <apitest.h> + +#define WIN32_NO_STATUS +#include <iphlpapi.h> +#include <ndk/rtlfuncs.h> +#include <initguid.h> + +DEFINE_GUID(MY_TEST_GUID, 0x8D1AB70F, 0xADF0, 0x49FC, 0x9D, 0x07, 0x4E, 0x89, 0x29, 0x2D, 0xC5, 0x2B); +static DWORD (WINAPI * pNhGetInterfaceNameFromGuid)(PVOID, PVOID, PULONG, DWORD, DWORD); +static DWORD (WINAPI * pNhGetInterfaceNameFromDeviceGuid)(PVOID, PVOID, PULONG, DWORD, DWORD); + +/* + * Tests for NhGetInterfaceNameFromGuid + */ +static +VOID +test_NhGetInterfaceNameFromGuid(GUID AdapterGUID, DWORD par1, DWORD par2) +{ + DWORD ApiReturn, Error; + ULONG ulOutBufLen; + WCHAR Name[MAX_INTERFACE_NAME_LEN + 4]; + GUID UniqueGUID = MY_TEST_GUID; + + // Test NULL GUID + SetLastError(0xbeeffeed); + Error = 0xbeeffeed; + ZeroMemory(&Name, sizeof(Name)); + ApiReturn = ERROR_SUCCESS; + ulOutBufLen = sizeof(Name); + StartSeh() + ApiReturn = pNhGetInterfaceNameFromGuid(NULL, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + EndSeh(STATUS_SUCCESS); + + ok(ApiReturn == ERROR_INVALID_PARAMETER, + "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n", + ApiReturn); + ok(Error == 0xbeeffeed, + "GetLastError() returned %ld, expected 0xbeeffeed\n", + Error); + ok(ulOutBufLen == sizeof(Name), + "ulOutBufLen is %ld, expected = sizeof(Name)\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // Test correct GUID, but NULL name + SetLastError(0xbeeffeed); + ZeroMemory(&Name, sizeof(Name)); + ApiReturn = pNhGetInterfaceNameFromGuid(&AdapterGUID, NULL, &ulOutBufLen, par1, par2); + Error = GetLastError(); + + ok(ApiReturn == ERROR_SUCCESS, + "ApiReturn returned %ld, expected ERROR_SUCCESS\n", + ApiReturn); + ok(Error == 0xbeeffeed, + "GetLastError() returned %ld, expected 0xbeeffeed\n", + Error); + ok(ulOutBufLen > 0, + "ulOutBufLen is %ld, expected > 0\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // NhGetInterfaceNameFromGuid will throw exception if pOutBufLen is NULL + SetLastError(0xbeeffeed); + Error = 0xbeeffeed; + ZeroMemory(&Name, sizeof(Name)); + ApiReturn = ERROR_SUCCESS; + StartSeh() + ApiReturn = pNhGetInterfaceNameFromGuid(&AdapterGUID, &Name, NULL, par1, par2); + Error = GetLastError(); + EndSeh(STATUS_SUCCESS); + + ok(ApiReturn == ERROR_INVALID_PARAMETER, + "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n", + ApiReturn); + ok(Error == 0xbeeffeed, + "GetLastError() returned %ld, expected 0xbeeffeed\n", + Error); + ok(ulOutBufLen > 0, + "ulOutBufLen is %ld, expected > 0\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // Test correct values + SetLastError(0xbeeffeed); + ZeroMemory(&Name, sizeof(Name)); + ulOutBufLen = sizeof(Name); + ApiReturn = pNhGetInterfaceNameFromGuid(&AdapterGUID, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + + ok(ApiReturn == ERROR_SUCCESS, + "ApiReturn returned %ld, expected ERROR_SUCCESS\n", + ApiReturn); + ok(Error == 0xbeeffeed, + "GetLastError() returned %ld, expected 0xbeeffeed\n", + Error); + ok(ulOutBufLen > 0, + "ulOutBufLen is %ld, expected > 0\n", + ulOutBufLen); + Error = wcslen(Name); + ok(Error > 0, + "wcslen(Name) is %ld, expected > 0\n", + Error); + if (Error > 0) + trace("Adapter name: \"%S\"\n", Name); + + // Test correct values, but with new unique GUID + SetLastError(0xbeeffeed); + ZeroMemory(&Name, sizeof(Name)); + ulOutBufLen = sizeof(Name); + ApiReturn = pNhGetInterfaceNameFromGuid((PVOID)&UniqueGUID, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + + ok(ApiReturn == ERROR_NOT_FOUND, + "ApiReturn returned %ld, expected ERROR_NOT_FOUND\n", + ApiReturn); + ok(Error == ERROR_PATH_NOT_FOUND, + "GetLastError() returned %ld, expected ERROR_PATH_NOT_FOUND\n", + Error); + ok(ulOutBufLen == sizeof(Name), + "ulOutBufLen is %ld, expected = sizeof(Name)\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // Test correct values, but with small length + SetLastError(0xbeeffeed); + ZeroMemory(&Name, sizeof(Name)); + ulOutBufLen = 0; + ApiReturn = pNhGetInterfaceNameFromGuid(&AdapterGUID, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + + ok(ApiReturn == ERROR_INSUFFICIENT_BUFFER, + "ApiReturn returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", + ApiReturn); + ok(Error == 0xbeeffeed, + "GetLastError() returned %ld, expected 0xbeeffeed\n", + Error); + ok(ulOutBufLen == MAX_INTERFACE_NAME_LEN * 2, + "ulOutBufLen is %ld, expected = MAX_INTERFACE_NAME_LEN * 2\n", + ulOutBufLen); + ok_wstr(L"", Name); +} + +/* + * Tests for NhGetInterfaceNameFromDeviceGuid + */ +static +VOID +test_NhGetInterfaceNameFromDeviceGuid(GUID AdapterGUID, DWORD par1, DWORD par2) +{ + DWORD ApiReturn, Error; + ULONG ulOutBufLen; + WCHAR Name[MAX_INTERFACE_NAME_LEN]; + GUID UniqueGUID = MY_TEST_GUID; + + // Test NULL GUID + // Windows XP: NhGetInterfaceNameFromDeviceGuid throws exception here + SetLastError(0xbeeffeed); + Error = 0xbeeffeed; + ZeroMemory(&Name, sizeof(Name)); + ApiReturn = ERROR_SUCCESS; + ulOutBufLen = sizeof(Name); + StartSeh() + ApiReturn = pNhGetInterfaceNameFromDeviceGuid(NULL, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + EndSeh(STATUS_SUCCESS); + + ok(ApiReturn == ERROR_INVALID_PARAMETER, + "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n", + ApiReturn); + ok(Error == ERROR_SUCCESS, + "GetLastError() returned %ld, expected ERROR_SUCCESS\n", + Error); + ok(ulOutBufLen == sizeof(Name), + "ulOutBufLen is %ld, expected = sizeof(Name)\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // Test correct GUID, but NULL name + SetLastError(0xbeeffeed); + Error = 0xbeeffeed; + ZeroMemory(&Name, sizeof(Name)); + ApiReturn = ERROR_SUCCESS; + StartSeh() + ApiReturn = pNhGetInterfaceNameFromDeviceGuid(&AdapterGUID, NULL, &ulOutBufLen, par1, par2); + Error = GetLastError(); + EndSeh(STATUS_SUCCESS); + + ok(ApiReturn == ERROR_INVALID_PARAMETER, + "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n", + ApiReturn); + ok(Error == ERROR_SUCCESS, + "GetLastError() returned %ld, expected ERROR_SUCCESS\n", + Error); + ok(ulOutBufLen > 0, + "ulOutBufLen is %ld, expected > 0\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // NhGetInterfaceNameFromDeviceGuid will throw exception if pOutBufLen is NULL + SetLastError(0xbeeffeed); + Error = 0xbeeffeed; + ZeroMemory(&Name, sizeof(Name)); + ApiReturn = ERROR_SUCCESS; + StartSeh() + ApiReturn = pNhGetInterfaceNameFromDeviceGuid(&AdapterGUID, &Name, NULL, par1, par2); + Error = GetLastError(); + EndSeh(STATUS_SUCCESS); + + ok(ApiReturn == ERROR_INVALID_PARAMETER, + "ApiReturn returned %ld, expected ERROR_INVALID_PARAMETER\n", + ApiReturn); + ok(Error == ERROR_SUCCESS, + "GetLastError() returned %ld, expected ERROR_SUCCESS\n", + Error); + ok(ulOutBufLen > 0, + "ulOutBufLen is %ld, expected > 0\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // Test correct values + SetLastError(0xbeeffeed); + ZeroMemory(&Name, sizeof(Name)); + ulOutBufLen = sizeof(Name); + ApiReturn = pNhGetInterfaceNameFromDeviceGuid(&AdapterGUID, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + + ok(ApiReturn == ERROR_SUCCESS, + "ApiReturn returned %ld, expected ERROR_SUCCESS\n", + ApiReturn); + ok(Error == ERROR_SUCCESS, + "GetLastError() returned %ld, expected ERROR_SUCCESS\n", + Error); + ok(ulOutBufLen > 0, + "ulOutBufLen is %ld, expected > 0\n", + ulOutBufLen); + Error = wcslen(Name); + ok(Error > 0, + "wcslen(Name) is %ld, expected > 0\n", + Error); + if (Error > 0) + trace("Adapter name: \"%S\"\n", Name); + + // Test correct values, but with new unique GUID + SetLastError(0xbeeffeed); + ZeroMemory(&Name, sizeof(Name)); + ulOutBufLen = sizeof(Name); + ApiReturn = pNhGetInterfaceNameFromDeviceGuid((PVOID)&UniqueGUID, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + + ok(ApiReturn == ERROR_NOT_FOUND, + "ApiReturn returned %ld, expected ERROR_NOT_FOUND\n", + ApiReturn); + ok(Error == ERROR_SUCCESS, + "GetLastError() returned %ld, expected ERROR_SUCCESS\n", + Error); + ok(ulOutBufLen == sizeof(Name), + "ulOutBufLen is %ld, expected = sizeof(Name)\n", + ulOutBufLen); + ok_wstr(L"", Name); + + // Test correct values, but with small length + SetLastError(0xbeeffeed); + ZeroMemory(&Name, sizeof(Name)); + ulOutBufLen = 0; + ApiReturn = pNhGetInterfaceNameFromDeviceGuid(&AdapterGUID, &Name, &ulOutBufLen, par1, par2); + Error = GetLastError(); + + ok(ApiReturn == ERROR_INSUFFICIENT_BUFFER, + "ApiReturn returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", + ApiReturn); + ok(Error == ERROR_SUCCESS, + "GetLastError() returned %ld, expected ERROR_SUCCESS\n", + Error); + ok(ulOutBufLen == MAX_INTERFACE_NAME_LEN * 2, + "ulOutBufLen is %ld, expected = MAX_INTERFACE_NAME_LEN * 2\n", + ulOutBufLen); + ok_wstr(L"", Name); +} + +static +VOID +test_GetInterfaceName(VOID) +{ + PIP_INTERFACE_INFO pInfo = NULL; + ULONG ulOutBufLen = 0; + DWORD ApiReturn; + WCHAR Name[MAX_ADAPTER_NAME]; + UNICODE_STRING GuidString; + GUID AdapterGUID; + HINSTANCE hIpHlpApi; + + ApiReturn = GetInterfaceInfo(pInfo, &ulOutBufLen); + ok(ApiReturn == ERROR_INSUFFICIENT_BUFFER, + "GetInterfaceInfo(pInfo, &ulOutBufLen) returned %ld, expected ERROR_INSUFFICIENT_BUFFER\n", + ApiReturn); + if (ApiReturn != ERROR_INSUFFICIENT_BUFFER) + { + skip("Can't determine size of IP_INTERFACE_INFO. Can't proceed\n"); + return; + } + + pInfo = (IP_INTERFACE_INFO *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulOutBufLen); + if (pInfo == NULL) + { + skip("pInfo is NULL. Can't proceed\n"); + return; + } + + ApiReturn = GetInterfaceInfo(pInfo, &ulOutBufLen); + ok(ApiReturn == NO_ERROR, + "GetInterfaceInfo(pInfo, &ulOutBufLen) returned %ld, expected NO_ERROR\n", + ApiReturn); + if (ApiReturn != NO_ERROR || ulOutBufLen == 0) + { + skip("GetInterfaceInfo failed with error %ld. Can't proceed\n", ApiReturn); + return; + } + + if (pInfo->NumAdapters > 0) + CopyMemory(&Name, &pInfo->Adapter[0].Name, sizeof(Name)); + + if (pInfo->NumAdapters == 0) + { + HeapFree(GetProcessHeap(), 0, pInfo); + skip("pInfo->NumAdapters = 0. Can't proceed\n"); + return; + } + trace("pInfo->NumAdapters: %lu\n", pInfo->NumAdapters); + + HeapFree(GetProcessHeap(), 0, pInfo); + + ApiReturn = wcsncmp(Name, L"\\DEVICE\\TCPIP_", 14); + ok(ApiReturn == 0, + "wcsncmp(Name, L\"\\DEVICE\\TCPIP_\", 14) returned %ld, expected 0\n", + ApiReturn); + if (ApiReturn != 0) + { + if (wcslen(Name) == 0) + { + skip("pInfo->Adapter[0].Name is empty. Can't proceed\n"); + return; + } + else + { + // workaround for ReactOS + trace("pInfo->Adapter[0].Name = \"%ls\" is incorrect.\n", Name); + RtlInitUnicodeString(&GuidString, &Name[0]); + } + } + else + { + RtlInitUnicodeString(&GuidString, &Name[14]); + } + + ApiReturn = RtlGUIDFromString(&GuidString, &AdapterGUID); + RtlFreeUnicodeString(&GuidString); + if (ApiReturn != 0) + { + skip("RtlGUIDFromString failed. Can't proceed\n"); + return; + } + + hIpHlpApi = GetModuleHandleW(L"iphlpapi.dll"); + if (!hIpHlpApi) + { + skip("Failed to load iphlpapi.dll. Can't proceed\n"); + return; + } + + pNhGetInterfaceNameFromGuid = (void *)GetProcAddress(hIpHlpApi, "NhGetInterfaceNameFromGuid"); + + if (!pNhGetInterfaceNameFromGuid) + skip("NhGetInterfaceNameFromGuid not found. Can't proceed\n"); + else + test_NhGetInterfaceNameFromGuid(AdapterGUID, 0, 0); + + pNhGetInterfaceNameFromDeviceGuid = (void *)GetProcAddress(hIpHlpApi, "NhGetInterfaceNameFromDeviceGuid"); + + if (!pNhGetInterfaceNameFromDeviceGuid) + skip("NhGetInterfaceNameFromDeviceGuid not found. Can't proceed\n"); + else + test_NhGetInterfaceNameFromDeviceGuid(AdapterGUID, 1, 0); +} + +START_TEST(GetInterfaceName) +{ + test_GetInterfaceName(); +} diff --git a/modules/rostests/apitests/iphlpapi/testlist.c b/modules/rostests/apitests/iphlpapi/testlist.c index 7eaff2e253..942004df68 100644 --- a/modules/rostests/apitests/iphlpapi/testlist.c +++ b/modules/rostests/apitests/iphlpapi/testlist.c @@ -3,12 +3,14 @@ #define STANDALONE #include <apitest.h> +extern void func_GetInterfaceName(void); extern void func_GetNetworkParams(void); extern void func_icmp(void); extern void func_SendARP(void); const struct test winetest_testlist[] = { + { "GetInterfaceName", func_GetInterfaceName }, { "GetNetworkParams", func_GetNetworkParams }, { "icmp", func_icmp }, { "SendARP", func_SendARP },
7 years
1
0
0
0
← Newer
1
...
31
32
33
34
35
36
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Results per page:
10
25
50
100
200