Пример #1
0
/*
* DesktopListCompareFunc
*
* Purpose:
*
* Desktop page listview comparer function.
*
*/
INT CALLBACK DesktopListCompareFunc(
	_In_ LPARAM lParam1,
	_In_ LPARAM lParam2,
	_In_ LPARAM lParamSort
	)
{
	LPWSTR lpItem1, lpItem2;
	INT nResult;

	lpItem1 = supGetItemText(DesktopList, (INT)lParam1, (INT)lParamSort, NULL);
	if (lpItem1 == NULL)
		return 0;

	lpItem2 = supGetItemText(DesktopList, (INT)lParam2, (INT)lParamSort, NULL);
	if (lpItem2 == NULL)
		return 0;

	if (bDesktopListSortInverse)
		nResult = _strcmpi(lpItem2, lpItem1);
	else
		nResult = _strcmpi(lpItem1, lpItem2);

	HeapFree(GetProcessHeap(), 0, lpItem1);
	HeapFree(GetProcessHeap(), 0, lpItem2);
	return nResult;
}
Пример #2
0
/*
* SdtSaveListToFile
*
* Purpose:
*
* Dump table to the selected file
*
*/
VOID SdtSaveListToFile(
	_In_ HWND hwndDlg
	)
{
	
	WCHAR ch;
	INT BufferSize = 0;
	INT	numitems;
	INT	row, subitem;
	SIZE_T sz, k;
	LPWSTR pItem = NULL;
	HCURSOR hSaveCursor;
	HCURSOR hHourGlass;
	WCHAR szTempBuffer[MAX_PATH + 1];

	RtlSecureZeroMemory(szTempBuffer, sizeof(szTempBuffer));

	_strcpy(szTempBuffer, TEXT("list.txt"));
	if (supSaveDialogExecute(hwndDlg, (LPWSTR)&szTempBuffer, TEXT("Text files\0*.txt\0\0"))) {

		hHourGlass = LoadCursorW(NULL, IDC_WAIT);

		ch = (WCHAR)0xFEFF;
		supWriteBufferToFile(szTempBuffer, &ch, sizeof(WCHAR), FALSE, FALSE);

		SetCapture(hwndDlg);
		hSaveCursor = SetCursor(hHourGlass);

		numitems = ListView_GetItemCount(SdtDlgContext.ListView);
		for (row = 0; row < numitems; row++) {

			output[0] = 0;
			for (subitem = 0; subitem < SdtDlgContext.lvColumnCount; subitem++) {

				sz = 0;
				pItem = supGetItemText(SdtDlgContext.ListView, row, subitem, &sz);
				if (pItem) {
					_strcat(output, pItem);
					HeapFree(GetProcessHeap(), 0, pItem);
				}
				if (subitem == 1) {
					for (k = 54; k > sz / sizeof(WCHAR); k--) {
						_strcat(output, TEXT(" "));
					}
				}
				else {
					_strcat(output, TEXT("\t"));
				}
			}
			_strcat(output, L"\r\n");
			BufferSize = (INT)_strlen(output);
			supWriteBufferToFile(szTempBuffer, output, BufferSize * sizeof(WCHAR), FALSE, TRUE);
		}

		SetCursor(hSaveCursor);
		ReleaseCapture();
	}
}
Пример #3
0
/*
* PipeDlgCompareFunc
*
* Purpose:
*
* Pipe Dialog listview comparer function.
*
*/
INT CALLBACK PipeDlgCompareFunc(
    _In_ LPARAM lParam1,
    _In_ LPARAM lParam2,
    _In_ LPARAM lParamSort
)
{
    LPWSTR lpItem1, lpItem2;
    INT    nResult = 0;

    lpItem1 = supGetItemText(PipeDlgContext.ListView, (INT)lParam1, (INT)lParamSort, NULL);
    lpItem2 = supGetItemText(PipeDlgContext.ListView, (INT)lParam2, (INT)lParamSort, NULL);

    if ((lpItem1 == NULL) && (lpItem2 == NULL)) {
        nResult = 0;
        goto Done;
    }

    if ((lpItem1 == NULL) && (lpItem2 != NULL)) {
        nResult = (PipeDlgContext.bInverseSort) ? 1 : -1;
        goto Done;
    }
    if ((lpItem2 == NULL) && (lpItem1 != NULL)) {
        nResult = (PipeDlgContext.bInverseSort) ? -1 : 1;
        goto Done;
    }

    if (PipeDlgContext.bInverseSort)
        nResult = _strcmpi(lpItem2, lpItem1);
    else
        nResult = _strcmpi(lpItem1, lpItem2);

Done:
    if (lpItem1) {
        HeapFree(GetProcessHeap(), 0, lpItem1);
    }
    if (lpItem2) {
        HeapFree(GetProcessHeap(), 0, lpItem2);
    }
    return nResult;
}
Пример #4
0
/*
* FindDlgHandleNotify
*
* Purpose:
*
* WM_NOTIFY processing for FindDlg listview.
*
*/
VOID FindDlgHandleNotify(
    LPNMLISTVIEW	nhdr
)
{
    INT      c, k;
    LPWSTR   lpItemText;
    LVCOLUMN col;

    if (nhdr == NULL)
        return;

    if (nhdr->hdr.idFrom != ID_SEARCH_LIST)
        return;

    switch (nhdr->hdr.code) {

    case LVN_ITEMCHANGED:
        if (!(nhdr->uNewState & LVIS_SELECTED))
            break;

        lpItemText = supGetItemText(nhdr->hdr.hwndFrom, nhdr->iItem, 0, NULL);
        if (lpItemText) {
            ListToObject(lpItemText);
            HeapFree(GetProcessHeap(), 0, lpItemText);
        }
        break;

    case LVN_COLUMNCLICK:
        bFindDlgSortInverse = !bFindDlgSortInverse;
        FindDlgSortColumn = ((NMLISTVIEW *)nhdr)->iSubItem;
        ListView_SortItemsEx(FindDlgList, &FindDlgCompareFunc, FindDlgSortColumn);

        RtlSecureZeroMemory(&col, sizeof(col));
        col.mask = LVCF_IMAGE;
        col.iImage = -1;

        for (c = 0; c < 2; c++)
            ListView_SetColumn(FindDlgList, c, &col);

        k = ImageList_GetImageCount(ListViewImages);
        if (bFindDlgSortInverse)
            col.iImage = k - 2;
        else
            col.iImage = k - 1;

        ListView_SetColumn(FindDlgList, ((NMLISTVIEW *)nhdr)->iSubItem, &col);
        break;

    default:
        break;
    }
}
Пример #5
0
/*
* MainWindowObjectListCompareFunc
*
* Purpose:
*
* Main window listview comparer function.
*
*/
INT CALLBACK MainWindowObjectListCompareFunc(
	_In_ LPARAM lParam1,
	_In_ LPARAM lParam2,
	_In_ LPARAM lParamSort
	)
{
	LPWSTR lpItem1, lpItem2;
	INT nResult = 0;
	
	lpItem1 = supGetItemText(ObjectList, (INT)lParam1, (INT)lParamSort, NULL);
	lpItem2 = supGetItemText(ObjectList, (INT)lParam2, (INT)lParamSort, NULL);

	if ((lpItem1 == NULL) && (lpItem2 == NULL)) {
		nResult = 0;
		goto Done;
	}
	if ((lpItem1 == NULL) && (lpItem2 != NULL)) {
		nResult = (bSortInverse) ? 1 : -1;
		goto Done;
	}
	if ((lpItem2 == NULL) && (lpItem1 != NULL)) {
		nResult = (bSortInverse) ? -1 : 1;
		goto Done;
	}

	if (bSortInverse)
		nResult = _strcmpi(lpItem2, lpItem1);
	else
		nResult = _strcmpi(lpItem1, lpItem2);

Done:
	if (lpItem1) {
		HeapFree(GetProcessHeap(), 0, lpItem1);
	}
	if (lpItem2) {
		HeapFree(GetProcessHeap(), 0, lpItem2);
	}
	return nResult;
}
Пример #6
0
/*
* MainWindowHandleObjectListProp
*
* Purpose:
*
* Object List properties per selected item.
*
*/
VOID MainWindowHandleObjectListProp(
    _In_ HWND hwnd
)
{
    INT     nSelected;
    LPWSTR  lpItemText, lpType, lpDesc = NULL;

    if (g_PropWindow != NULL)
        return;

    //nothing selected, go away
    if (ListView_GetSelectedCount(g_hwndObjectList) == 0) {
        return;
    }

    nSelected = ListView_GetSelectionMark(g_hwndObjectList);
    if (nSelected == -1) {
        return;
    }

    lpItemText = supGetItemText(g_hwndObjectList, nSelected, 0, NULL);
    if (lpItemText) {
        lpType = supGetItemText(g_hwndObjectList, nSelected, 1, NULL);
        if (lpType) {

            //lpDesc is not important, we can work if it NULL
            lpDesc = supGetItemText(g_hwndObjectList, nSelected, 2, NULL);

            propCreateDialog(hwnd, lpItemText, lpType, lpDesc);

            if (lpDesc) {
                supHeapFree(lpDesc);
            }
            supHeapFree(lpType);
        }
        supHeapFree(lpItemText);
    }
}
Пример #7
0
/*
* MainWindowObjectListCompareFunc
*
* Purpose:
*
* Main window listview comparer function.
*
*/
INT CALLBACK MainWindowObjectListCompareFunc(
    _In_ LPARAM lParam1,
    _In_ LPARAM lParam2,
    _In_ LPARAM lParamSort
)
{
    INT    nResult = 0;
    LPWSTR lpItem1 = NULL, lpItem2 = NULL;

    lpItem1 = supGetItemText(g_hwndObjectList, (INT)lParam1, (INT)lParamSort, NULL);
    lpItem2 = supGetItemText(g_hwndObjectList, (INT)lParam2, (INT)lParamSort, NULL);

    if ((lpItem1 == NULL) && (lpItem2 == NULL)) {
        nResult = 0;
        goto Done;
    }
    if ((lpItem1 == NULL) && (lpItem2 != NULL)) {
        nResult = (bMainWndSortInverse) ? 1 : -1;
        goto Done;
    }
    if ((lpItem2 == NULL) && (lpItem1 != NULL)) {
        nResult = (bMainWndSortInverse) ? -1 : 1;
        goto Done;
    }

    if (bMainWndSortInverse)
        nResult = _strcmpi(lpItem2, lpItem1);
    else
        nResult = _strcmpi(lpItem1, lpItem2);

Done:
    if (lpItem1) supHeapFree(lpItem1);
    if (lpItem2) supHeapFree(lpItem2);

    return nResult;
}
Пример #8
0
/*
* DesktopListHandleNotify
*
* Purpose:
*
* WM_NOTIFY processing for Desktop page listview.
*
*/
VOID DesktopListHandleNotify(
	HWND			hwndDlg,
	LPNMLISTVIEW	nhdr
	)
{
	LVCOLUMNW	col;
	INT			c;
	SIZE_T		sz, i, l;
	LPWSTR		lpItemText, lpName;

	if (nhdr == NULL) {
		return;
	}

	if (nhdr->hdr.idFrom != ID_DESKTOPSLIST) {
		return;
	}

	switch (nhdr->hdr.code) {

	case LVN_COLUMNCLICK:
		bDesktopListSortInverse = !bDesktopListSortInverse;
		DesktopListSortColumn = ((NMLISTVIEW *)nhdr)->iSubItem;
		ListView_SortItemsEx(DesktopList, &DesktopListCompareFunc, DesktopListSortColumn);

		RtlSecureZeroMemory(&col, sizeof(col));
		col.mask = LVCF_IMAGE;
		col.iImage = -1;

		for (c = 0; c < 3; c++) {
			ListView_SetColumn(DesktopList, c, &col);
		}

		if (bDesktopListSortInverse)
			col.iImage = 1;
		else
			col.iImage = 2;

		ListView_SetColumn(DesktopList, ((NMLISTVIEW *)nhdr)->iSubItem, &col);
		break;

	case NM_DBLCLK:
		/*
		* A very basic support for this type
		* desktop described by win32k PDESKTOP structure which is totally undocumented
		*/
		sz = 0;
		lpItemText = supGetItemText(DesktopList, ListView_GetSelectionMark(DesktopList), 0, &sz);
		if (lpItemText) {
			l = 0;
			for (i = 0; i<sz; i++)
				if (lpItemText[i] == L'\\')
					l = i + 1;
			lpName = &lpItemText[l];
			//hwndDlg set to mainwindow on purpose
			propCreateDialog(hwndDlg, lpName, T_ObjectNames[TYPE_DESKTOP], NULL);
			HeapFree(GetProcessHeap(), 0, lpItemText);
		}
		break;

	default:
		break;
	}
}
Пример #9
0
/*
* SdtDlgCompareFunc
*
* Purpose:
*
* KiServiceTable Dialog listview comparer function.
*
*/
INT CALLBACK SdtDlgCompareFunc(
	_In_ LPARAM lParam1,
	_In_ LPARAM lParam2,
	_In_ LPARAM lParamSort
	)
{
	INT       nResult = 0;
	LPWSTR    lpItem1, lpItem2;
	ULONG     id1, id2;
	ULONG_PTR ad1, ad2;

	lpItem1 = supGetItemText(SdtDlgContext.ListView, (INT)lParam1, (INT)lParamSort, NULL);
	lpItem2 = supGetItemText(SdtDlgContext.ListView, (INT)lParam2, (INT)lParamSort, NULL);

	if ((lpItem1 == NULL) && (lpItem2 == NULL)) {
		nResult = 0;
		goto Done;
	}

	if ((lpItem1 == NULL) && (lpItem2 != NULL)) {
		nResult = (SdtDlgContext.bInverseSort) ? 1 : -1;
		goto Done;
	}
	if ((lpItem2 == NULL) && (lpItem1 != NULL)) {
		nResult = (SdtDlgContext.bInverseSort) ? -1 : 1;
		goto Done;
	}

	switch (lParamSort) {

	//sort Index
	case 0:
		id1 = strtoul(lpItem1);
		id2 = strtoul(lpItem2);

		if (SdtDlgContext.bInverseSort)
			nResult = id1 < id2;
		else
			nResult = id1 > id2;

		break;

	//sort Address
	case 2:
		
		ad1 = hextou64(&lpItem1[2]);
		ad2 = hextou64(&lpItem2[2]);

		if (SdtDlgContext.bInverseSort)
			nResult = ad1 < ad2;
		else
			nResult = ad1 > ad2;

		break;

	//sort Name, Module
	case 1:
	case 3:
	default:
		if (SdtDlgContext.bInverseSort)
			nResult = _strcmpi(lpItem2, lpItem1);
		else
			nResult = _strcmpi(lpItem1, lpItem2);
		break;
	}

Done:
	if (lpItem1) {
		HeapFree(GetProcessHeap(), 0, lpItem1);
	}
	if (lpItem2) {
		HeapFree(GetProcessHeap(), 0, lpItem2);
	}
	return nResult;
}
Пример #10
0
/*
* MainWindowHandleWMCommand
*
* Purpose:
*
* Main window WM_COMMAND handler.
*
*/
LRESULT MainWindowHandleWMCommand(
    _In_ HWND hwnd,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam
)
{
    LPWSTR  lpItemText;
    HWND    hwndFocus;

    UNREFERENCED_PARAMETER(lParam);

    switch (LOWORD(wParam)) {

    case ID_FILE_RUNASADMIN:
        supRunAsAdmin();
        break;

    case ID_FILE_EXIT:
        PostQuitMessage(0);
        break;

    case ID_OBJECT_PROPERTIES:
        hwndFocus = GetFocus();
        if (hwndFocus == g_hwndObjectList) {
            MainWindowHandleObjectListProp(hwnd);
        }
        if (hwndFocus == g_hwndObjectTree) {
            MainWindowHandleObjectTreeProp(hwnd);
        }
        break;

    case ID_OBJECT_GOTOLINKTARGET:
        lpItemText = supGetItemText(g_hwndObjectList, ListView_GetSelectionMark(g_hwndObjectList), 2, NULL);
        if (lpItemText) {
            if (_strcmpi(lpItemText, L"\\??") == 0) {
                ListToObject(L"\\GLOBAL??");
            }
            else {
                ListToObject(lpItemText);
            }
            supHeapFree(lpItemText);
        }
        else {
            lpItemText = supGetItemText(g_hwndObjectList, ListView_GetSelectionMark(g_hwndObjectList), 0, NULL);
            if (lpItemText) {
                if ((_strcmpi(lpItemText, L"GLOBALROOT") == 0) &&
                    (_strcmpi(g_WinObj.CurrentObjectPath, L"\\GLOBAL??") == 0))
                {
                    ListToObject(L"\\");
                }
                supHeapFree(lpItemText);
            }
        }
        break;

    case ID_FIND_FINDOBJECT:
        FindDlgCreate(hwnd);
        break;

    case ID_VIEW_REFRESH:
        MainWindowOnRefresh(hwnd);
        break;

        //Extras -> Pipes
    case ID_EXTRAS_PIPES:
        extrasShowPipeDialog(hwnd);
        break;

        //Extras -> Mailslots
    case ID_EXTRAS_MAILSLOTS:
        extrasShowMailslotsDialog(hwnd);
        break;

        //Extras -> UserSharedData
    case ID_EXTRAS_USERSHAREDDATA:
        extrasShowUserSharedDataDialog(hwnd);
        break;

        //Extras -> Private Namespaces
    case ID_EXTRAS_PRIVATENAMESPACES:
        if (g_WinObj.osver.dwBuildNumber <= 10240) {

            //feature require driver usage
            if (g_kdctx.hDevice != NULL) {
                extrasShowPrivateNamespacesDialog(hwnd);
            }
        }
        break;

        //Extras -> KiServiceTable
    case ID_EXTRAS_SSDT:

        //feature require driver usage
#ifndef _DEBUG
        if (g_kdctx.hDevice != NULL) {
#endif
            extrasShowSSDTDialog(hwnd);
#ifndef _DEBUG
        }
#endif
        break;

        //Extras -> Drivers
    case ID_EXTRAS_DRIVERS:
        extrasShowDriversDialog(hwnd);
        break;

    case ID_HELP_ABOUT:
        DialogBoxParam(g_WinObj.hInstance, MAKEINTRESOURCE(IDD_DIALOG_ABOUT),
            hwnd, (DLGPROC)&AboutDialogProc, 0);
        break;

    case ID_HELP_HELP:
        supShowHelp();
        break;

    default:
        break;
    }
    return FALSE;
}
Пример #11
0
/*
* MainWindowHandleWMCommand
*
* Purpose:
*
* Main window WM_COMMAND handler.
*
*/
LRESULT MainWindowHandleWMCommand(
	_In_ HWND hwnd,
	_In_ WPARAM wParam,
	_In_ LPARAM lParam
	)
{
	LPWSTR		lpItemText;
	HWND		hwndFocus;


	UNREFERENCED_PARAMETER(lParam);

	switch (LOWORD(wParam)) {

	case ID_FILE_RUNASADMIN:
		supRunAsAdmin();
		break;

	case ID_FILE_EXIT:
		PostQuitMessage(0);
		break;

	case ID_OBJECT_PROPERTIES:
		hwndFocus = GetFocus();
		if (hwndFocus == ObjectList) {
			MainWindowHandleObjectListProp(hwnd);
		}
		if (hwndFocus == ObjectTree) {
			MainWindowHandleObjectTreeProp(hwnd);
		}
		break;

	case ID_OBJECT_GOTOLINKTARGET:
		lpItemText = supGetItemText(ObjectList, ListView_GetSelectionMark(ObjectList), 2, NULL);
		if (lpItemText) {
			if (_strcmpi(lpItemText, L"\\??") == 0) {
				ListToObject(L"\\GLOBAL??");
			}
			else {
				ListToObject(lpItemText);
			}
			HeapFree(GetProcessHeap(), 0, lpItemText);
		}
		else {
			lpItemText = supGetItemText(ObjectList, ListView_GetSelectionMark(ObjectList), 0, NULL);
			if (lpItemText) {
				if (
					(_strcmpi(lpItemText, L"GLOBALROOT") == 0) && 
					(_strcmpi(CurrentObjectPath, L"\\GLOBAL??") == 0)
					) 
				{
					ListToObject(L"\\");
				}
				HeapFree(GetProcessHeap(), 0, lpItemText);
			}
		}
		break;

	case ID_FIND_FINDOBJECT:
		FindDlgCreate(hwnd);
		break;

	case ID_VIEW_REFRESH:
		MainWindowOnRefresh(hwnd);
		break;

	case ID_EXTRAS_PIPES:
		extrasShowPipeDialog(hwnd);
		break;

	case ID_EXTRAS_USERSHAREDDATA:
		extrasShowUserSharedDataDialog(hwnd);
		break;

	case ID_EXTRAS_PRIVATENAMESPACES:
		extrasShowPrivateNamespacesDialog(hwnd);
		break;

	case ID_HELP_ABOUT:
		DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_ABOUT), 
			hwnd, (DLGPROC)&AboutDialogProc, 0);
		break;

	case ID_HELP_HELP:
		supShowHelp();
		break;

	default:
		break;
	}
	return FALSE;
}
Пример #12
0
/*
* PipeDlgShowProperties
*
* Purpose:
*
* Show properties dialog for selected pipe.
* Because of Pipe special case we cannot use propCreateDialog.
*
*/
VOID PipeDlgShowProperties(
    _In_ INT iItem
)
{
    INT                 nPages = 0;
    PROP_OBJECT_INFO   *Context;
    HPROPSHEETPAGE      SecurityPage = NULL;
    PROPSHEETPAGE       Page;
    PROPSHEETHEADER     PropHeader;
    WCHAR               szCaption[MAX_PATH];

    Context = propContextCreate(NULL, NULL, NULL, NULL);
    if (Context == NULL) {
        return;
    }

    Context->lpObjectName = supGetItemText(PipeDlgContext.ListView, iItem, 0, NULL);
    Context->lpCurrentObjectPath = PipeCreateFullName(Context->lpObjectName);

    //
    //Create Pipe Page
    //
    RtlSecureZeroMemory(&Page, sizeof(Page));
    Page.dwSize = sizeof(PROPSHEETPAGE);
    Page.dwFlags = PSP_DEFAULT | PSP_USETITLE;
    Page.hInstance = g_hInstance;
    Page.pszTemplate = MAKEINTRESOURCE(IDD_PROP_PIPE);
    Page.pfnDlgProc = PipeTypeDialogProc;
    Page.pszTitle = TEXT("Pipe");
    Page.lParam = (LPARAM)Context;
    epsp[nPages++] = CreatePropertySheetPage(&Page);

    //
    //Create Security Dialog if available
    //
    SecurityPage = propSecurityCreatePage(
        Context,
        (POPENOBJECTMETHOD)&PipeOpenObjectMethod,
        NULL, //use default close method
        SI_EDIT_AUDITS | SI_EDIT_OWNER | SI_EDIT_PERMS |
        SI_ADVANCED | SI_NO_ACL_PROTECT | SI_NO_TREE_APPLY |
        SI_PAGE_TITLE
    );
    if (SecurityPage != NULL) {
        epsp[nPages++] = SecurityPage;
    }

    //
    //Create property sheet
    //
    _strcpy(szCaption, TEXT("Pipe Properties"));
    RtlSecureZeroMemory(&PropHeader, sizeof(PropHeader));
    PropHeader.dwSize = sizeof(PropHeader);
    PropHeader.phpage = epsp;
    PropHeader.nPages = nPages;
    PropHeader.dwFlags = PSH_DEFAULT | PSH_NOCONTEXTHELP;
    PropHeader.nStartPage = 0;
    PropHeader.hwndParent = PipeDlgContext.hwndDlg;
    PropHeader.hInstance = g_hInstance;
    PropHeader.pszCaption = szCaption;

    PropertySheet(&PropHeader);
    propContextDestroy(Context);
}