;Version 2.3.3 #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include "Include\WinRT.au3" #include "Include\WinRT_MetaDataImport.au3" #include Global $hGUIMain, $hFilter, $hSearch, $hTypeDefs, $hAbout, $pDispenser Global $aTypeDefs[0], $bUpdating Global $sDefaultMetadataPath = "C:\WINDOWS\system32\WinMetadata" Global $sMetadataPath = ".\Metadata" Global Const $SB_LINEUP = 0 Global Const $SB_LINELEFT = 0 Global Const $SB_LINEDOWN = 1 Global Const $SB_LINERIGHT = 1 Global Const $SB_PAGEUP = 2 Global Const $SB_PAGELEFT = 2 Global Const $SB_PAGEDOWN = 3 Global Const $SB_PAGERIGHT = 3 Global Const $SB_THUMBPOSITION = 4 Global Const $SB_THUMBTRACK = 5 Global Const $SB_TOP = 6 Global Const $SB_LEFT = 6 Global Const $SB_BOTTOM = 7 Global Const $SB_RIGHT = 7 Global Const $SB_ENDSCROLL = 8 Init() Main() Cleanup() Func Init() $hGUIMain = GUICreate("WinRT Class Explorer", 800, 800) GUICtrlCreateLabel("Filter:", 8, 8, 40, 25, $SS_CENTERIMAGE) $hFilter = GUICtrlCreateInput("", 44, 8, 200, 25) $hSearch = GUICtrlCreateButton("Search", 250, 8, 80, 25, $BS_DEFPUSHBUTTON) GUICtrlCreateLabel("TypeDefs:", 8, 40, 80, 25, $SS_CENTERIMAGE) $hTypeDefs = GUICtrlCreateListView("Name", 8, 65, 800 - 16, 350, BitOR($LVS_NOCOLUMNHEADER, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $WS_BORDER), BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg($hTypeDefs, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE_USEHEADER) GUICtrlCreateLabel("About:", 8, 415, 40, 25, $SS_CENTERIMAGE) $hAbout = GUICtrlCreateEdit("", 8, 440, 800 - 16, 350, BitOR($ES_WANTRETURN, $WS_BORDER, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetFont(-1, -1, -1, -1, "Consolas") _WinRT_Startup() $pDispenser = _MetaData_GetDispenser() GetTypeDefs() DisplayTypeDefs() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() EndFunc ;==>Init Func Main() Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hSearch DisplayTypeDefs() EndSwitch WEnd EndFunc ;==>Main Func Cleanup() GUIDelete($hGUIMain) _WinRT_DeleteObject($pDispenser) _WinRT_Shutdown() EndFunc ;==>Cleanup Func GetTypeDefs() Local $hFileSrch, $sFile, $pScope, $iCount Local $pTypeDefEnum, $aTDProps, $aTypeDefsTkns Local $sLocalMetadataPath = $sMetadataPath $hFileSrch = FileFindFirstFile($sLocalMetadataPath & "\*.winmd") While 1 $sFile = FileFindNextFile($hFileSrch) If @error Then FileClose($hSearch) If $sLocalMetadataPath = $sDefaultMetadataPath Then ExitLoop $sLocalMetadataPath = $sDefaultMetadataPath $hFileSrch = FileFindFirstFile($sLocalMetadataPath & "\*.winmd") EndIf $pScope = _MetaData_OpenScope($pDispenser, $sLocalMetadataPath & "\" & $sFile) $aTypeDefsTkns = _MetaData_EnumTypeDefs($pScope, $pTypeDefEnum, -1) ReDim $aTypeDefs[UBound($aTypeDefs) + UBound($aTypeDefsTkns)] For $i = 0 To UBound($aTypeDefsTkns) - 1 $aTDProps = _MetaData_GetTypeDefProps($pScope, $aTypeDefsTkns[$i]) $aTypeDefs[$iCount] = $aTDProps[0] $iCount += 1 Next _MetaData_CloseEnum($pScope, $pTypeDefEnum) _WinRT_DeleteObject($pScope) WEnd EndFunc ;==>GetTypeDefs Func DisplayTypeDefs() Local $tItem, $tName, $iItem = 0, $pItem, $sFilter $bUpdating = True $tItem = DllStructCreate($tagLVITEM) $tName = DllStructCreate("wchar Text[260]") $tItem.Text = DllStructGetPtr($tName) $tItem.TextMax = 260 $tItem.Mask = $LVIF_TEXT $tItem.Item = 0 $pItem = DllStructGetPtr($tItem) GUICtrlSendMsg($hTypeDefs, $LVM_GETITEMTEXTW, $iItem, $pItem) $sFilter = StringStripWS(GUICtrlRead($hFilter), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) If Not $sFilter Then $sFilter = "." GUICtrlSendMsg($hTypeDefs, $WM_SETREDRAW, 0, 0) For $i = 0 To UBound($aTypeDefs) - 1 ;~ DisplayItem($aTypeDefs[$i]) If StringInStr($aTypeDefs[$i], $sFilter) Then If $aTypeDefs[$i] <> $tName.Text Then $tName.Text = $aTypeDefs[$i] $tItem.Item = $iItem GUICtrlSendMsg($hTypeDefs, $LVM_INSERTITEMW, 0, $pItem) ;~ GUICtrlSetColor(-1, 0xFF0000) EndIf $iItem += 1 $tItem.Item = $iItem GUICtrlSendMsg($hTypeDefs, $LVM_GETITEMTEXTW, $iItem, $pItem) Else ;Not In List If $aTypeDefs[$i] = $tName.Text Then GUICtrlSendMsg($hTypeDefs, $LVM_DELETEITEM, $iItem, 0) GUICtrlSendMsg($hTypeDefs, $LVM_GETITEMTEXTW, $iItem, $pItem) EndIf EndIf Next GUICtrlSendMsg($hTypeDefs, $WM_SETREDRAW, 1, 0) $bUpdating = False EndFunc ;==>DisplayTypeDefs Func WM_NOTIFY($hWnd, $iNotif, $wParam, $lParam) #forceref $hWnd, $iNotif, $wParam, $lParam Local $tNMHDR, $tNMLISTVIEW, $tNMLVCUSTOMDRAW Local $tItem, $tName $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch $tNMHDR.IDFrom Case $hTypeDefs Switch $tNMHDR.Code Case $LVN_ITEMCHANGED If Not $bUpdating Then $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) If BitAND($tNMLISTVIEW.NewState, $LVIS_FOCUSED) Then $tItem = DllStructCreate($tagLVITEM) $tName = DllStructCreate("wchar Text[260]") $tItem.Text = DllStructGetPtr($tName) $tItem.TextMax = 260 GUICtrlSendMsg($hTypeDefs, $LVM_GETITEMTEXTW, $tNMLISTVIEW.Item, DllStructGetPtr($tItem)) DisplayItem($tName.Text) EndIf EndIf Case $NM_CUSTOMDRAW $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) If BitAND($tNMLVCUSTOMDRAW.dwDrawStage, $CDDS_ITEM) Then $tNMLVCUSTOMDRAW.clrText = GetItemColour($tNMLVCUSTOMDRAW.dwItemSpec) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func DisplayItem($sTDName) GUICtrlSendMsg($hAbout, $WM_SETREDRAW, 0, 0) GUICtrlSendMsg($hAbout, $EM_SETSEL, -1, -1) Local $sFile, $pScope, $pEnum Local $iTypeDef, $aProps, $aAttrib, $aIfaces, $aProperties, $aMethods, $aFields, $aParams Local $dBlob, $sData, $aParamProps, $aSigParams, $bHasRetVal, $aParamDefs[0] Local $tLine = DllStructCreate("wchar Text[512]"), $pLine = DllStructGetPtr($tLine) GUICtrlSendMsg($hAbout, $EM_SETSEL, 0, -1) GUICtrlSendMsg($hAbout, $EM_REPLACESEL, 0, $pLine) AppendText($sTDName, "TypeDef") $sFile = GetMetaDataFile($sTDName) $pScope = _MetaData_OpenScope($pDispenser, $sFile) $iTypeDef = _MetaData_FindTypeDef($pScope, $sTDName) $aProps = _MetaData_GetTypeDefProps($pScope, $iTypeDef) AppendText(_MetaData_GetTokenName($pScope, $aProps[2]), "Extends") AppendText(_MetaData_GetGUIDAttrib($pScope, $iTypeDef), "GUID") AppendText(_MetaData_GetExcusiveToAttrib($pScope, $iTypeDef), "Exclusive To") AppendText(_MetaData_GetComposableAttibuteType($pScope, $iTypeDef), "Composable") $aAttrib = _MetaData_GetStaticAttribNames($pScope, $iTypeDef) For $i = 0 To UBound($aAttrib) - 1 AppendText($aAttrib[$i], "Statics") Next $aAttrib = _MetaData_GetActivatableAttrib($pScope, $iTypeDef) If Not @error Then AppendText($aAttrib[0], "Activatable") $aIfaces = _MetaData_EnumInterfaceImpls($pScope, $pEnum, $iTypeDef, -1) If Not @error Then _MetaData_CloseEnum($pScope, $pEnum) For $i = 0 To UBound($aIfaces) - 1 $aProps = _MetaData_GetInterfaceImplsProps($pScope, $aIfaces[$i]) If BitAND(0xFF000000, $aProps[1]) = $MDT_TypeRef Then AppendText(_MetaData_GetTokenName($pScope, $aProps[1]), "Interface") ElseIf BitAND(0xFF000000, $aProps[1]) = $MDT_TypeSpec Then $dBlob = _MetaData_GetTypeSpecFromToken($pScope, $aProps[1]) AppendText(_MetaData_DecodeTypeSpec($pScope, $dBlob), "Interface") EndIf Next $aProperties = _MetaData_EnumProperties($pScope, $pEnum, $iTypeDef, -1) If Not @error Then _MetaData_CloseEnum($pScope, $pEnum) For $i = 0 To UBound($aProperties) - 1 AppendText(_MetaData_GetTokenName($pScope, $aProperties[$i]), "Property") Next $aMethods = _MetaData_EnumMethods($pScope, $pEnum, $iTypeDef, -1) If Not @error Then _MetaData_CloseEnum($pScope, $pEnum) For $i = 0 To UBound($aMethods) - 1 $aProps = _MetaData_GetMethodProps($pScope, $aMethods[$i]) AppendText($aProps[1], "Method") $aParams = _MetaData_EnumParams($pScope, $pEnum, $aMethods[$i], -1) If Not @error Then _MetaData_CloseEnum($pScope, $pEnum) $aSigParams = _MetaData_DecodeMethodDefSig($pScope, $aProps[3]) ReDim $aParamDefs[UBound($aSigParams)][2] $bHasRetVal = (UBound($aParams) = UBound($aSigParams)) $sData = $aProps[1] & "(" $aParamDefs[0][0] = "Ret" If $bHasRetVal Then $aParamProps = _MetaData_GetParamProps($pScope, $aParams[0]) $sData = StringFormat("%s = %s", $aParamProps[2], $sData) $aParamDefs[0][1] = $aParamProps[2] EndIf For $j = (($bHasRetVal) ? 1 : 0) To UBound($aParams) - 1 $aParamProps = _MetaData_GetParamProps($pScope, $aParams[$j]) If BitAND($aParamProps[3], 1) Then $aParamDefs[$aParamProps[1]][0] = "In" $sData &= "In " EndIf If BitAND($aParamProps[3], 2) Then $aParamDefs[$aParamProps[1]][0] &= "Out" $sData &= "Out " EndIf $aParamDefs[$aParamProps[1]][1] = $aParamProps[2] $sData &= $aParamProps[2] & ", " Next If StringRight($sData, 2) = ", " Then $sData = StringTrimRight($sData, 2) $sData &= ")" AppendText($sData, "Fn") For $j = 0 To UBound($aParamDefs) - 1 AppendText(StringFormat("%-20s type: %s ", $aParamDefs[$j][1], $aSigParams[$j][1]), "P" & $j) Next Next $aFields = _MetaData_EnumFields($pScope, $pEnum, $iTypeDef, -1) If Not @error Then _MetaData_CloseEnum($pScope, $pEnum) For $i = 0 To UBound($aFields) - 1 $aProps = _MetaData_GetFieldProps($pScope, $aFields[$i]) $aSigParams = _MetaData_DecodeFieldSig($pScope, $aProps[3]) If $aProps[4] = 1 Then AppendText(StringFormat("%15s (%s)", $aProps[1], $aSigParams[0][1]), "Field") Else AppendText(StringFormat("%15s = %4s (%s)", $aProps[1], $aProps[5], $aSigParams[0][1]), "Field") EndIf Next _WinRT_DeleteObject($pScope) GUICtrlSendMsg($hAbout, $WM_VSCROLL, $SB_TOP, 0) GUICtrlSendMsg($hAbout, $WM_HSCROLL, $SB_LEFT, 0) GUICtrlSendMsg($hAbout, $WM_SETREDRAW, 1, 0) EndFunc ;==>DisplayItem Func AppendText($sData, $sTitle = "", $sDelim = ":") Local Static $tLine = DllStructCreate("wchar Text[512]"), $pLine = DllStructGetPtr($tLine) If Not $sData Then Return If $sTitle Then $tLine.Text = StringFormat("%15s %s %s\r\n", $sTitle, $sDelim, $sData) Else $tLine.Text = $sData EndIf GUICtrlSendMsg($hAbout, $EM_SETSEL, -1, -1) If $sData Then GUICtrlSendMsg($hAbout, $EM_REPLACESEL, 0, $pLine) EndFunc ;==>AppendText Func GetItemColour($iItem) Local $tItem, $tName Local $sFile, $pScope, $iTypeDef, $aProps, $iCol $tItem = DllStructCreate($tagLVITEM) $tName = DllStructCreate("wchar Text[260]") $tItem.Text = DllStructGetPtr($tName) $tItem.TextMax = 260 GUICtrlSendMsg($hTypeDefs, $LVM_GETITEMTEXTW, $iItem, DllStructGetPtr($tItem)) $sFile = GetMetaDataFile($tName.Text) $pScope = _MetaData_OpenScope($pDispenser, $sFile) $iTypeDef = _MetaData_FindTypeDef($pScope, $tName.Text) $aProps = _MetaData_GetTypeDefProps($pScope, $iTypeDef) If BitAND($aProps[1], 0x20) Then $iCol = 0xAA0000 Else Switch _MetaData_GetTokenName($pScope, $aProps[2]) Case "System.Object" $iCol = 0x0000AA Case "System.Enum" $iCol = 0x0080AA Case "System.ValueType" $iCol = 0xAAAA00 Case "System.MulticastDelegate" $iCol = 0x008000 Case "System.Attribute" $iCol = 0x800080 Case Else ;~ ConsoleWrite( _MetaData_GetTokenName($pScope, $aProps[2]) & @CRLF) EndSwitch EndIf _WinRT_DeleteObject($pScope) Return $iCol EndFunc ;==>GetItemColour Func GetMetaDataFile($sTDName) Local $sFile, $aScopeBuild $sFile = _MetaData_GetMetaDataFile($sTDName) If @error Then $aScopeBuild = StringRegExp($sTDName, "(.*?\.)", 3) For $i = 0 To UBound($aScopeBuild) - 1 $sFile &= $aScopeBuild[$i] Next For $i = UBound($aScopeBuild) - 1 To 1 Step -1 If FileExists($sMetadataPath & "\" & $sFile & "winmd") Then ExitLoop $sFile = StringTrimRight($sFile, StringLen($aScopeBuild[$i])) Next $sFile = ( $i < 1 ) ? "" : $sMetadataPath & "\" & $sFile & "winmd" EndIf Return SetError($sFile = "", 0, $sFile) EndFunc