Exemplo n.º 1
0
/*
* supGetObjectNameIndexByTypeIndex
*
* Purpose:
*
* Returns object index of known type.
*
* Known type names listed in sup.c T_ObjectNames, and known object indexes listed in sup.h as TYPE_*
*
*/
UINT supGetObjectNameIndexByTypeIndex(
	_In_ PVOID Object,
	_In_ UCHAR TypeIndex
	)
{
	UINT Index;
	ULONG i;
	BOOL bFound = FALSE;
	POBJECT_TYPE_INFORMATION pObject;
	POBJECT_TYPE_INFORMATION_8 pObject8;

	if (Object == NULL) {
		return TYPE_UNKNOWN;
	}

	Index = ObDecodeTypeIndex(Object, TypeIndex);

	pObject = (POBJECT_TYPE_INFORMATION)&g_pObjectTypesInfo->TypeInformation;
	for (i = 0; i < g_pObjectTypesInfo->NumberOfTypes; i++) {
		
		if (g_kdctx.osver.dwBuildNumber >= 9200) {
			pObject8 = (POBJECT_TYPE_INFORMATION_8)pObject;
			if (pObject8->TypeIndex == Index) {
				bFound = TRUE;
			}
		}
		else {
			if (i + 2 == Index) {
				bFound = TRUE;
			}
		}

		if (bFound) {
			return supGetObjectIndexByTypeName(pObject->TypeName.Buffer);
		}

		pObject = (POBJECT_TYPE_INFORMATION)((PCHAR)(pObject + 1) +
			ALIGN_UP(pObject->TypeName.MaximumLength, sizeof(ULONG_PTR)));
	}

	return TYPE_UNKNOWN;
}
Exemplo n.º 2
0
/*
* FindDlgAddListItem
*
* Purpose:
*
* Add item to listview.
*
*/
VOID FindDlgAddListItem(
    _In_ HWND	hList,
    _In_ LPWSTR	ObjectName,
    _In_ LPWSTR	TypeName
)
{
    INT     index;
    LVITEM  lvitem;

    RtlSecureZeroMemory(&lvitem, sizeof(lvitem));

    lvitem.mask = LVIF_TEXT | LVIF_IMAGE;
    lvitem.iSubItem = 0;
    lvitem.pszText = ObjectName;
    lvitem.iItem = 0;
    lvitem.iImage = supGetObjectIndexByTypeName(TypeName);
    index = ListView_InsertItem(hList, &lvitem);

    lvitem.mask = LVIF_TEXT;
    lvitem.iSubItem = 1;
    lvitem.pszText = TypeName;
    lvitem.iItem = index;
    ListView_SetItem(hList, &lvitem);
}
Exemplo n.º 3
0
/*
* propContextCreate
*
* Purpose:
*
* Initialize property sheet object context
*
*/
PPROP_OBJECT_INFO propContextCreate(
	LPWSTR lpObjectName,
	LPCWSTR lpObjectType,
	LPWSTR lpCurrentObjectPath,
	LPWSTR lpDescription
	)
{
	BOOL bSelectedObject = FALSE, bSelectedDirectory = FALSE;
	PROP_OBJECT_INFO *Context;

	__try {
		//allocate context structure
		Context = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PROP_OBJECT_INFO));
		if (Context == NULL) {
			return Context;
		}

		//copy object name if given
		if (lpObjectName) {
			Context->lpObjectName = HeapAlloc(GetProcessHeap(),
				HEAP_ZERO_MEMORY,
				_strlen(lpObjectName) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
			if (Context->lpObjectName) {
				_strcpy(Context->lpObjectName, lpObjectName);
				bSelectedObject = (_strcmpi(Context->lpObjectName, L"ObjectTypes") == 0);
			}
		}

		//copy object type if given
		if (lpObjectType) {
			Context->lpObjectType = HeapAlloc(GetProcessHeap(),
				HEAP_ZERO_MEMORY,
				_strlen(lpObjectType) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
			if (Context->lpObjectType) {
				_strcpy(Context->lpObjectType, lpObjectType);
			}
			Context->TypeIndex = supGetObjectIndexByTypeName(lpObjectType);
		}

		//copy CurrentObjectPath if given, as it can change because dialog is modeless
		if (lpCurrentObjectPath) {
			Context->lpCurrentObjectPath = HeapAlloc(GetProcessHeap(),
				HEAP_ZERO_MEMORY,
				_strlen(lpCurrentObjectPath) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
			if (Context->lpCurrentObjectPath) {
				_strcpy(Context->lpCurrentObjectPath, lpCurrentObjectPath);
				bSelectedDirectory = (_strcmpi(Context->lpCurrentObjectPath, T_OBJECTTYPES) == 0);
			}
		}

		//copy object description, could be NULL
		if (lpDescription) {
			Context->lpDescription = HeapAlloc(GetProcessHeap(),
				HEAP_ZERO_MEMORY,
				_strlen(lpDescription) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
			if (Context->lpDescription) {
				_strcpy(Context->lpDescription, lpDescription);
			}
		}

		//check if object is Type object
		//Type objects handled differently
		if ((bSelectedObject != TRUE) && (bSelectedDirectory != FALSE)) {
			Context->IsType = TRUE;
			//
			// Query actual type index for case when user will browse Type object info
			//
			if (Context->lpObjectName) {
				Context->RealTypeIndex = supGetObjectIndexByTypeName(Context->lpObjectName);
			}
		}
		else {
			//use the same type index for everything else
			Context->RealTypeIndex = Context->TypeIndex;
		}

	}
	__except (exceptFilter(GetExceptionCode(), GetExceptionInformation())) {
		return NULL;
	}
	return Context;
}