感受微软外包项目(三)

来源:互联网 发布:unity 图片优化 编辑:程序博客网 时间:2024/05/22 00:11

关于DirectUI

         一旦完成API Hook,那么一个实质性的工作就是Office Communicator的资源文件结构分析。OCUI结构是基于DirectUI技术实现的,因此与标准的Win32软件差异极大,微软内部在很早以前就开始开发DirectUI框架了,至于为什么要实现这样一个框架,原因很复杂,其中一个基本的原因也许是传统的技术每个UI元素大体要匹配一个“窗口”句柄,表面上看,句柄仅仅就是一个32位整数,其实不然,其背后应该是一个很复杂的数据结构,一个进程能够管理的窗口句柄个数应该是有限的,同时窗口句柄过多无疑要给系统增加额外的开销,因此Microsoft的开发者需要简化“窗口句柄”背后的东西,使得其能够响应部分关键的“消息”,因此,他们需要一种窗口对象的替代物,能够正常处理(诸如键盘、鼠标、绘制等)消息,但同时又不是传统的“窗口”,这一点应该是一个很重要的因素,也解释了传统的Spy++实用程序为什么无法直接观察DirectUI内部因素;开发DirectUI的另外一个原因也许是需要基于XML技术描述UI结构,用XML技术描述UI的好处是显而易见的,Windows7Shell体系很大程度都依赖于DirectUI的实现。

         既然DirectUI的关键点之一是“XMLUI描述,那么这些“XML”保存在哪里?如果我们用Visual Studio 2008Shell直接打开Communicator.exe这个文件,我们会发现其资源结构如下:

这里,msgsres.dllMSN的资源文件对应的动态链接库,在OC资源的结构树中我们发现了节点“UIFILE”,打开这个节点对应的子元素,我们即可发现我们感兴趣的东西,例如“940”这个节点:

 

 

<duixml>

  <BuddyListFrame resid="idBuddyListFrame" AccRole="Pane" id="atom(idBuddyListFrame)" Sheet="MainSS" Layout="BorderLayout()">

    <PNG id="atom(idMainUIBackground)" LayoutPos="Client" Layout="BorderLayout()">

      <MyPane id="atom(idMyPane)" AccName="resstr(2520, library(lclang.dll))" LayoutPos="Top" Layout="FillLayout()" Padding="rect(1,2,1,2)">

        <PNG id="atom(idMyPaneBackground)" Layout="BorderLayout()">

          <Element Background="ARGB(0,0,0,0)" layoutPos="Left" Margin="rect(0,0,7,0)" ContentAlign="MiddleLeft" Layout="FillLayout()">

            <PNG id="atom(idMyPaneAccent)" Active="MouseAndKeyboard"/>

            <PNG id="atom(idMyPanePawn)" idres="706"/>

          </Element>

          <Element LayoutPos="Client" Layout="VerticalFlowLayout(0,3,3,0)" Padding="rect(0,1,0,0)" ContentAlign="TopLeft">

            <Element Layout="BorderLayout()" Padding="rect(2,2,2,2)">

              <Element id="atom(idMyPaneName)" LayoutPos="Client"/>

              <PNG id="atom(idMyLocation)" Active="Mouse" LayoutPos="Right" Padding="rect(3,0,0,0)"/>

              <Element id="atom(idMyPaneStatus)" Active="Mouse" LayoutPos="Right" Padding="rect(0,0,0,1)"/>

            </Element>

            <Element Layout="BorderLayout()" Margin="rect(0,3,0,0)" Padding="rect(2,2,0,1)">

              <PNG id="atom(idMyPaneNoteImage)" Flip="False" idres="740" layoutPos="Left" ContentAlign="MiddleLeft"/>

              <Element id="atom(idMyPaneNoteParent)" LayoutPos="Client" Layout="FillLayout()">

                <Button id="atom(idMyPaneNote)" Active="MouseAndKeyboard"/>

                <EditNote id="atom(idMyPaneNoteEdit)" ContentAlign="MiddleLeft" Bottomless="True" MaxTextLength="511" XScrollable="False" YScrollable="False" RichEditStyle="PlainText|MultiLine|DisableDrag" Visible="False" Active="MouseAndKeyboard"/>

              </Element>

            </Element>

          </Element>

          <Element id="atom(idMyPaneInfoPanel)" Layout="FillLayout()" Margin="rect(1,0,0,0)">

            <PNG id="atom(idMyPaneInfoColumn)" Layout="GridLayout(2,1)">

              <CmdButton Layout="FlowLayout(0,3)" id="atom(idMyPaneCallForwarding)" Active="MouseAndKeyboard">

                <PNG Flip="false" IdRes="731" id="atom(idMyPaneCallForwardingImage)"/>

                <PNG IdRes="4006"/>

              </CmdButton>

              <CmdButton Layout="FlowLayout(0,3)" id="atom(idMyPaneNotifications)" Active="MouseAndKeyboard">

                <PNG Flip="false" IdRes="733" id="atom(idMyPaneNotificationsImage)"/>

                <PNG IdRes="4006"/>

              </CmdButton>

            </PNG>

          </Element>

        </PNG>

      </MyPane>

      <Element Padding="rect(1,0,1,3)" LayoutPos="Client" Layout="BorderLayout()">

        <Element ID="atom(idSearchInputPaneHook)" LayoutPos="top" Layout="FillLayout()"/>

        <Element ID="atom(idSearchResultsParent)" Layout="FillLayout()">

          <Element ID="atom(idSearchResultsPaneArea)" Layout="BorderLayout()">

            <Element ID="atom(idSearchGalBeingDownloaded)" Active="Mouse" content="resstr(2404, library(lclang.dll))"/>

            <Element ID="atom(idSearchNoResults)" Active="Mouse" content="resstr(2402, library(lclang.dll))"/>

            <Element ID="atom(idSearchMoreResultsAvailable)" Active="Mouse"/>

            <Element ID="atom(idSearchResultsPaneHook)" LayoutPos="Client" Layout="FillLayout()"/>

          </Element>

        </Element>

        <Constrainer id="atom(idBuddyListConstrainer)" LayoutPos="Client" Layout="FillLayout()" Height="200">

          <Element ID="atom(idVirtualListBorder)" Layout="FillLayout()">

            <VirtualListView ID="atom(idVirtualList)" Layout="FillLayout()"/>

          </Element>

        </Constrainer>

        <Constrainer id="atom(idPluginsConstrainer)" LayoutPos="Bottom" Layout="BorderLayout()" Height="150">

          <Splitter Layout="BorderLayout()" LayoutPos="Top" ContentAlign="middlecenter" Class="Vertical" BeforeID="atom(idBuddyListConstrainer)" AfterID="atom(idPluginsConstrainer)" OrientationStyle="Reverse|Vertical" Padding="rect(1,0,1,0)">

            <PNG id="atom(idSplitter)" LayoutPos="client" Layout="FillLayout()">

              <PNG idres="3531" Layout="BorderLayout()">

                <Element LayoutPos="left" Layout="FillLayout()">

                  <PNG id="atom(idSplitterToggleBackground)"/>

                  <PNG idres="3533" id="atom(idSplitterToggle)" Active="MouseAndKeyboard"/>

                </Element>

              </PNG>

            </PNG>

          </Splitter>

          <Element LayoutPos="Client" Layout="FillLayout()">

            <WebBrowserHost ID="atom(idPlugin)" Visible="False" Enabled="False" height="100"/>

          </Element>

          <Element LayoutPos="Bottom" Layout="FillLayout()">

            <PNG id="atom(idTabsBackground)"/>

            <Element Background="ARGB(0,0,0,0)" Layout="BorderLayout()" Padding="rect(1,0,0,0)">

              <OverflowToolbar ID="atom(idTabList)" LayoutPos="None">

                <CmdButton ID="atom(idTabsMenuButton)" LayoutPos="1" Active="MouseAndKeyboard"/>

              </OverflowToolbar>

            </Element>

          </Element>

        </Constrainer>

      </Element>

    </PNG>

  </BuddyListFrame>

  <Element resid="idTab" id="atom(idTab)" Layout="BorderLayout()" Sheet="MainSS">

    <RadioButton ID="atom(idTabButton)" GroupId="atom(idTabButtonGroup)" LayoutPos="Left" Active="MouseAndKeyboard" Layout="FillLayout()" ContentAlign="BottomCenter">

      <PNG id="atom(idTabImage)"/>

    </RadioButton>

  </Element>

  <StyleSheets>

    <Style resid="MainSS">

      <Element Background="ARGB(0,0,0,0)"/>

      <if id="atom(idSearchResultsPaneArea)">

        <Element Background="ifhc(window, white)" BorderColor="ifhc(windowtext, RGB(77,93,131))" BorderThickness="rect(1,1,1,1)"/>

      </if>

      <if id="atom(idSearchGalBeingDownloaded)">

        <Element Accessible="True" Tooltip="True" AccDesc="resstr(2404,library(lclang.dll))" AccRole="StaticText" LayoutPos="Top" ContentAlign="EndEllipsis" Padding="rect(2,2,2,2)" BorderThickness="rect(0,0,0,1)" BorderColor="ifhc(windowtext,RGB(177,193,231))"/>

      </if>

      <if id="atom(idSearchNoResults)">

        <Element Accessible="True" Tooltip="True" AccDesc="resstr(2402,library(lclang.dll))" AccRole="StaticText" LayoutPos="Top" Padding="rect(2,2,2,2)" Height="40"/>

      </if>

      <if id="atom(idSearchMoreResultsAvailable)">

        <Element Accessible="True" Tooltip="True" AccDesc="resstr(2403,library(lclang.dll))" AccRole="StaticText" LayoutPos="Top" ContentAlign="EndEllipsis" Padding="rect(2,2,2,2)" BorderThickness="rect(0,0,0,1)" BorderColor="ifhc(windowtext,RGB(177,193,231))"/>

      </if>

      <if id="atom(idSearchResultsPaneHook)">

        <Element Accessible="True" AccName="resstr(2401, library(lclang.dll))" AccRole="List"/>

      </if>

      <if id="atom(idSearchResultsParent)">

        <Element LayoutPos="Top"/>

      </if>

      <if id="atom(idVirtualListBorder)">

        <Element BorderColor="ifhc(windowtext,RGB(77,93,131))" BorderThickness="rect(1,1,1,1)"/>

      </if>

      <if id="atom(idPluginsConstrainer)">

        <Constrainer LayoutPos="Bottom"/>

      </if>

      <PNG Background="ARGB(0,0,0,0)"/>

      <if id="atom(idMainUIBackground)">

        <PNG Background="ifhc(window,Gradient(RGB(71,81,88),RGB(66,85,112),RGB(129,145,159),4))"/>

      </if>

      <if id="atom(idMyPaneBackground)">

        <PNG Blendmode="7" IsBackground="True" Idres="ifhc(0,707)" Background="ifhc(window,ARGB(0,0,0,0))" BorderThickness="ifhc(rect(1,1,1,1), rect(2,2,3,3))" Padding="ifhc(rect(6,1,2,2), rect(5,0,0,0))" BorderColor="ifhc(windowtext, ARGB(0,0,0,0))"/>

      </if>

      <if id="atom(idSplitter)">

        <PNG Blendmode="4" IsBackground="True" idres="ifhc(0,3530)" Background="ifhc(window,ARGB(0,0,0,0))"/>

      </if>

      <if id="atom(idSplitterToggleBackground)">

        <PNG Blendmode="0" idres="ifhc(0,3534)" Background="ifhc(window,ARGB(0,0,0,0))"/>

      </if>

      <if id="atom(idSplitterToggle)">

        <PNG Accessible="True" AccRole="PushButton" IdRes="3533" Cursor="Arrow"/>

      </if>

      <if id="atom(idTabsBackground)">

        <PNG Blendmode="7" IsBackground="True" idres="ifhc(0,3501)" Background="ifhc(window,ARGB(0,0,0,0))" BorderThickness="ifhc(rect(1,1,1,1),rect(2,1,2,2))" Padding="ifhc(rect(1,0,1,1), rect(0,0,0,0))" BorderColor="ifhc(windowtext, ARGB(0,0,0,0))"/>

      </if>

      <VirtualListView Accessible="True" AccRole="List" AccName="resstr(2499, library(lclang.dll))" Background="ifhc(window,white)"/>

      <if id="atom(idMyPaneAccent)">

        <PNG Accessible="True" Tooltip="True" AccName="resstr(2523,library(lclang.dll))" AccRole="PushButton" AccDesc="resstr(2529,library(lclang.dll))" AccDefAction="resstr(60047, library(lclang.dll))" IdRes="722"/>

        <if KeyFocused="True">

          <PNG IdRes="723"/>

        </if>

        <if MouseFocused="True">

          <PNG IdRes="723"/>

        </if>

        <if Pressed="True">

          <PNG IdRes="724"/>

        </if>

      </if>

      <if id="atom(idMyPanePawn)">

        <PNG Flip="True" Accessible="True" AccName="resstr(2502,library(lclang.dll))" AccRole="Graphic"/>

      </if>

      <if id="atom(idMyPaneNoteImage)">

        <PNG LayoutPos="left"/>

      </if>

      <if id="atom(idMyPaneNoteParent)">

        <Element LayoutPos="client"/>

      </if>

      <if id="atom(idMyPaneNote)">

        <Button ContentAlign="EndEllipsis" BorderThickness="rect(1,1,1,1)" BorderColor="ARGB(0,0,0,0)" Padding="rect(2,2,0,3)" Accessible="True" AccName="resstr(2524,library(lclang.dll))" AccRole="StaticText" AccDefAction="resstr(60047, library(lclang.dll))" Shortcut="None"/>

        <if class="PromptText">

          <Button FontStyle="Italic" Foreground="ifhc(windowtext, SlateGray)"/>

        </if>

        <if MouseFocused="True">

          <Button BorderColor="ifhc(windowtext,RGB(89,93,119))" Cursor="IBeam"/>

        </if>

        <if KeyFocused="True">

          <Button BorderColor="ifhc(windowtext,RGB(89,93,119))"/>

        </if>

      </if>

      <if id="atom(idMyPaneNoteEdit)">

        <EditNote ContentAlign="EndEllipsis" BorderThickness="rect(1,1,1,1)" BorderColor="ifhc(windowtext, RGB(0,0,0))" Background="ifhc(window,ARGB(180,255,255,255))" Padding="rect(2,2,2,2)" Fontsize="8pt" Accessible="True" AccName="resstr(2524,library(lclang.dll))" AccRole="StaticText"/>

      </if>

      <if id="atom(idMyPaneInfoColumn)">

        <PNG blendmode="7" BorderThickness="rect(2,0,0,0)" IsBackground="True" idres="ifhc(0,716)" BorderColor="ifhc(windowtext,ARGB(0,0,0,0))"/>

      </if>

      <if id="atom(idMyPaneInfoPanel)">

        <Element LayoutPos="Right"/>

      </if>

      <if id="atom(idMyPaneCallForwardingImage)">

        <PNG Margin="rect(0,0,2,0)"/>

      </if>

      <if id="atom(idMyPaneNotificationsImage)">

        <PNG Margin="rect(0,0,2,0)" Padding="rect(0,1,0,0)"/>

      </if>

      <if id="atom(idMyPaneCallForwarding)">

        <CmdButton IsBackground="true" BlendMode="7" IdRes="0" ContentAlign="MiddleCenter" BorderThickness="rect(1,1,1,1)" BorderColor="ARGB(0,0,0,0)" Background="ARGB(0,0,0,0)" Padding="rect(1,1,3,0)" Tooltip="True" Accessible="True" AccName="resstr(2526,library(lclang.dll))" AccRole="ButtonMenu" AccDefAction="resstr(60047, library(lclang.dll))" ButtonStyle="ifhc(CustomBorder | BorderOnSelected| FocusRect3D,0)"/>

        <if KeyFocused="True">

          <CmdButton IdRes="ifhc(0,812)"/>

        </if>

        <if MouseFocused="True">

          <CmdButton IdRes="ifhc(0,810)"/>

        </if>

        <if Pressed="True">

          <CmdButton IdRes="ifhc(0,811)"/>

        </if>

        <if Selected="True">

          <CmdButton IdRes="ifhc(0,813)" Background="ifhc(highlight,ARGB(0,0,0,0))"/>

          <if MouseWithin="True">

            <CmdButton IdRes="ifhc(0,814)"/>

          </if>

        </if>

      </if>

      <if id="atom(idMyPaneNotifications)">

        <CmdButton IsBackground="true" BlendMode="7" ContentAlign="MiddleCenter" BorderThickness="rect(1,1,1,1)" BorderColor="ARGB(0,0,0,0)" Background="ARGB(0,0,0,0)" Padding="rect(1,1,3,0)" Tooltip="True" Accessible="True" AccName="resstr(2527,library(lclang.dll))" AccRole="ButtonMenu" AccDefAction="resstr(60047, library(lclang.dll))" ButtonStyle="ifhc(CustomBorder | BorderOnSelected| FocusRect3D,0)"/>

        <if KeyFocused="True">

          <CmdButton IdRes="ifhc(0,812)"/>

        </if>

        <if MouseFocused="True">

          <CmdButton IdRes="ifhc(0,810)"/>

        </if>

        <if Pressed="True">

          <CmdButton IdRes="ifhc(0,811)"/>

        </if>

        <if Selected="True">

          <CmdButton IdRes="ifhc(0,813)" Background="ifhc(highlight,ARGB(0,0,0,0))"/>

          <if MouseWithin="True">

            <PNG IdRes="ifhc(0,814)"/>

          </if>

        </if>

      </if>

      <if id="atom(idTabsMenuButton)">

        <CmdButton Accessible="True" AccRole="ButtonMenu" Background="ARGB(0,0,0,0)" IdRes="3503"/>

        <if KeyFocused="True">

          <CmdButton tooltip="true"/>

        </if>

        <if MouseFocused="True">

          <CmdButton tooltip="true"/>

        </if>

        <if Pressed="True">

          <CmdButton tooltip="true"/>

        </if>

      </if>

      <RadioButton Accessible="True" AccRole="RadioButton" Background="ARGB(0,0,0,0)"/>

      <if GroupId="atom(idTabButtonGroup)">

        <RadioButton ContentAlign="MiddleCenter" Cursor="Hand" IdRes="0" Tooltip="True" IsBackground="True" Blendmode="7" Padding="rect(8,4,8,4)" Width="32" Height="24"/>

        <if KeyFocused="True">

          <RadioButton IdRes="3520" Margin="rect(0,-1,0,0)" Padding="rect(5,2,5,1)" BorderThickness="rect(3,2,3,3)"/>

        </if>

        <if MouseFocused="True">

          <RadioButton IdRes="3520" Margin="rect(0,-1,0,0)" Padding="rect(5,2,5,1)" BorderThickness="rect(3,2,3,3)"/>

        </if>

        <if Selected="True">

          <RadioButton IdRes="3502" Margin="rect(0,-1,0,0)" Padding="rect(6,3,6,2)" BorderThickness="rect(2,1,2,2)"/>

          <if KeyFocused="True">

            <RadioButton IdRes="3521" Margin="rect(0,-1,0,0)" Padding="rect(5,2,5,1)" BorderThickness="rect(3,2,3,3)"/>

          </if>

        </if>

      </if>

      <if id="atom(idTabImage)">

        <PNG Background="ARGB(0,0,0,0)" Flip="False"/>

      </if>

      <if id="atom(idTabList)">

        <OverflowToolbar Accessible="True" AccRole="Grouping" Background="ARGB(0,0,0,0)"/>

      </if>

      <WebBrowserHost Background="ifhc(window, white)" BorderColor="ifhc(windowtext,RGB(77,93,131))" BorderThickness="rect(1,1,1,0)" WebBrowserStyle="OpenInNewWindow | AllowUNC"/>

      <MyPane Accessible="True" AccName="resstr(2520, library(lclang.dll))" AccRole="PushButton" Background="ARGB(0,0,0,0)" Foreground="ifhc(windowtext, RGB(35,45,80))"/>

      <if id="atom(idMyPaneName)">

        <Element Accessible="True" AccName="resstr(2521, library(lclang.dll))" AccRole="StaticText" ContentAlign="EndEllipsis" FontWeight="ExtraBold" FontSize="10pt"/>

      </if>

      <if id="atom(idMyPaneCallForwardingLine)">

        <Element LayoutPos="Top"/>

      </if>

      <if id="atom(idMyPaneStatus)">

        <Element Tooltip="True" Accessible="True" AccName="resstr(2522, library(lclang.dll))" AccRole="StaticText" ContentAlign="BottomRight|EndEllipsis"/>

      </if>

      <if id="atom(idMyLocation)">

        <PNG IdRes="4042" Tooltip="True" Accessible="True" AccName="resstr(2528, library(lclang.dll))" AccRole="StaticText" ContentAlign="TopCenter"/>

      </if>

    </Style>

  </StyleSheets>

</duixml>

从中我们可以看出许多“线索”,类似的,你可以分析“msgsres.dll”,事实上,类似MSN Shell的关键技术实现就是分析这些DirectUI的文件描述,并在软件运行时的某个时刻适当的修改这些描述以增加新的“元素”。

原创粉丝点击