How the Tool Works

Let's examine the detail of how the tool works in an example. We'll load the following HTML file. Remember that a Scriptlet is basically an HTML file, and that the main differences between Scriptlets and ordinary Web pages are all in the script section, which is completely unaffected by this.

<html>
<head>
<title>A Demo Page</title>
</head>

<body>
<script language="VBscript" for="window" event="onload">
  Toolbar1.AddItem "Back", "Prev_N.bmp", "Prev_H.bmp", "Prev_D.bmp", "Prev_G.bmp"
  Toolbar1.AddItem "Forward", "Next_N.bmp", "Next_H.bmp", "Next_D.bmp", "Next_G.bmp"
  Toolbar1.AddItem "Play", "Play_N.bmp", "Play_H.bmp", "Play_D.bmp", "Play_G.bmp"
  Toolbar1.AddItem "Stop", "Stop_N.bmp", "Stop_H.bmp", "Stop_D.bmp", "Stop_G.bmp"
  Toolbar1.Cursor = "hand"
  Toolbar1.SetButtons
</script>

This is a reference to <a href="testflex.htm">a new HTML file</a>.
<object id="Toolbar1" data="Toolbar.htm" align="baseline" border="0"
        width="300" height="60" type="text/x-scriptlet">
</object> 

<img src="Hot.gif" width="100" height="100">

<object classid="clsid:8E27C92B-1264-101C-8A2F-040224009C02"
        border="0" width="288" height="192">
</object>

</body>
</html>

The page shown above is the same one we've already seen rendered in some previous screenshots. It contains:

Running the tool, we observe that the first procedure that gets called is EnumerateImages. This causes the file hot.gif to be added to the result listbox. Next, it's the turn of EnumerateObjects. The demo page has two objects: a Scriptlet and an ActiveX control. The first one our search meets is the Scriptlet toolbar.htm. It is added to the list, and it loads in the hidden WebBrowser too. However, this Scriptlet has no other explicit link to other files. So the recursion ends very soon and without producing visible effects.

As you may remember from a previous chapter, the Toolbar has a completely empty body—the images, in fact, are all inserted at run-time. We'll have more to say on this later.

The third entry is the CLSID of the ActiveX control. From this we go up to the file mscal.ocx. It's reasonable to suppose that this file too has a dependency-list. However, we need specialized tools and specific algorithms to walk through the export section of a Win32 executable. (See Further Reading for suggestions.)

Finally, we call the EnumerateLinks procedure. The demo page we're considering includes a single link. To be precise, it is

<a href="testflex.htm">a new HTML file</a>.

The referenced document is an HTML page containing a Scriptlet we designed and built in an earlier chapter. To help remember, it is the expandable textbox given by a line of text, a picture, and a nested Scriptlet. See Chapter 9 for more information about its structure and internal details.

The search procedure adds the file testflex.htm to the result listbox. Then the file loads in the WebBrowser control and gets recursively analyzed. This page just includes the FlexText.htm Scriptlet. The second examination extracts all the files that form the Scriptlet. They are:

The last two files arepart of the Scriptlet, so the recursion applies twice.

© 1997 by Wrox Press. All rights reserved.