Extension (Mac OS)

From Wikipedia, the free encyclopedia

On the Apple Macintosh operating system prior to Mac OS X, extensions were small pieces of code that extended the system's functionality. They were run initially at start-up time, and operated by a variety of mechanisms, including trap patching and other code modifying techniques. Extensions generally filled the same role as DOS's terminate and stay resident programs, or Unix's daemons, although they did have additional functionality to modify existing OS behaviour the other two did not.

[edit] The INIT mechanism

The concept of extensions was not present in the original Macintosh system software, but the system nevertheless had a private patching mechanism that developers soon learned to take advantage of - the INIT loader. This code would search for system resources of type 'INIT', and load and run them at boot time. The code resources had to be stored directly in the Mac System file's resource fork, meaning it was only really available to "power users" who would be comfortable using ResEdit or other resource editor.

Since taking advantage of this mechanism was an unsupported hack, Apple responded by providing a more managed solution. Initially this itself was in the form of an 'INIT' resource placed in the System file, 'INIT 31' that would search for further files of type 'INIT' in the System Folder, and load and run INIT resources inside them. (This is why some veteran Mac programmers still refer to the extensions loading mechanism as the "INIT 31 trick" [1]). INITs could now be installed simply by placing a file in the System Folder, well within the abilities of the average Mac user.

Extensions retained the resource type of 'INIT' throughout their lifetime, and the loader was gradually enhanced to search for these resources in numerous places, including in the resource forks of control panels in a variety of formats and the Chooser.

[edit] Extensions

INITs evolved into system extensions, gaining additional ad hoc protocols along the way, such as supplying an icon to be displayed at boot time. The 'parade of icons' across the screen as each init loaded became familiar to all Mac users. Apple themselves eventually released major (but optional) pieces of the operating system as extensions, such as QuickTime, QuickDraw 3D and many others.

System extensions were a common source of instability on the Macintosh, as third-party code was of variable quality and would often patch the system in ways that did not always work correctly. In addition different extensions might try to patch the same part of the system, which could lead to extension conflicts and other instability. Tracking down these sources of trouble was another task most Mac users encountered at some point.

Later versions of the system attempted to make the process easier by creating a separate folder which contained the extensions, and later still by adding the Extensions Manager, which allowed the user to quickly enable or disable particular extensions, and also to define sets of them that would work correctly together.

The loading order of extensions was always based on the alphabetical sorting of their filenames, which was an amusing quirk. Thus the simple expedient of renaming an extension was one method by which conflicts that depended on loading order could be resolved.

[edit] Viral vectors

INITs and System extensions were the way by which some of the earliest known computer viruses were transmitted - the fact that the system blindly loaded and executed an INIT's code was an obvious security risk, but in the days of limited networking and no Internet connectivity, the globally widespread viruses of today were unknown.