TealPoint Logo


    The Palm Foleo - Thoughts for the Future
    Living with NVFS (updated)
    Crashes, Errors and PalmOS
    PalmSource Post Report
    What's That I Hear?
    Palms, ARMs, and Handhelds
    The Future of PalmOS
    Movies on the Move
  Hacks on your Handheld
    PalmOS Version-o-Rama
    Memory and the Modern Palm
    New PalmOS handhelds hit market
      Am I Compatible?
      How to Purchase
      How to Install
      Get Support
      Tech Articles
      Contact Us
      Site Map

Our Company...

      About Us
      Online Store

      Ad Banners
      PalmOS Links


PalmOS Tech Articles > #4, November 2001

Hacks on your Handheld
All About Hacks

What are Hacks?
Hacks. No, we're not referring to pale, pimple-faced teenagers trying to break into Pentagon computers. Hacks are the common name for a class of programs which extend the functionality of Palm OS. While the terms "hacks", "hackers" and "hacking" are often associated with legendary stories about phone phreaking, Captain Crunch, and calls to President about the Pentagon running out of toilet paper, the term "hacks" in the context of Palm OS handhelds is entirely benign.

In programming lingo, "hack" is roughly equivalent to the term "jury-rig" ("bodge" for you Brits out there. Who says you can't learn anything from watching Junkyard Wars? ) The word has no nefarious implication, but simply refers to program code which accomplishes tasks in an unorthodox, often ingenious, way. Accordingly, "Hackmaster" was the name Edward Keyes chose for his original system extensions manager back in 1996. Seeing a growing need, Keyes developed Hackmaster and the Hack standard as a way for different developers to extend the operating system in a consistent, compatible way.

What Hacks Can Do
We all know how ordinary applications run on a Palm handheld. When you want to start, say, a spreadsheet app, you find its icon in the system launcher screen and tap on it. Later, if you want to go into your word processor, you go back to the launcher screen, and this automatically stops the spreadsheet from running. When you're in the word processor, the spreadsheet is no longer performing calculations; the two applications cannot run at the same time. Hacks, however, are different. They can run when you're still inside another application, leading to functionality and numerous uses achievable no other way.

Today, hundreds of useful hacks are available from different developers. At TealPoint, six of our own products are hacks, including TealEcho, TealLaunch, and TealGlance. TealEcho draws a digital ink trail when you write, reducing recognition errors and increasing speed. TealLaunch, on the other hand, quickens application launching with a pop-up launcher window and button mapping ability. Lastly, TealGlance previews your day in an instant by popping up a reminder window on power up with the date, time, upcoming calendar events and to-do items.

Other developers have released popular hacks too. FindHack, an enhanced replacement for the system "Find" command, is always a popular download. Another is Afterburner, a program which accelerates a handheld by turning up the system clock. PrintHack, a recent release, brings up a pop-up window to print the text of a current text field or clipboard through printing systems like TealPrint. Hundreds of others are also available.

What Hacks Can't Do
The possible uses for hacks are limitless, though there are some things they cannot do. Hacks tend to perform functions which are system-wide only. For instance, a hack can automatically select a word when you double-tap a text field in any program. It's much more difficult to, say, write a hack which only capitalizes text on a single screen of one specific app. Also, hacks can only act on information that that Palm OS knows about. So, one might make a spell checking hack which works on system text fields, but that same hack would not work with a word processor that stores its text internally and uses its own text-handling routines.

How to use Hacks
In order to use hacks, one must first install a system extensions manager. This is a normal application (not a hack itself) which coordinates the activation and configuration of hack programs. The original Hackmaster, although known to have a few bugs and hasn't been updated since 1997, it is still the defacto standard and is commonly in use. Alternatives include X-Master, and our own program TealMaster, which is the newest and arguably most powerful of extensions managers available. While any of these will work, NEVER run more than one extensions manager at a time, as doing so can lead to stunningly stability-free operating conditions (a crash). Also, never delete or upgrade a hack that is currently in use for the same reason.

When running hacks, the extensions manager is the only program which appears in the system launcher. The hacks show themselves and are turned on and off only from inside the extensions manager. Configuration of the hacks is done there as well. Advanced managers such as TealMaster also allow deleting and renaming of hacks and offer other diagnostic and configuration tools.

How Hacks Work
Last issue, we discussed how operating systems like Palm OS allow programs to run. Palm OS provides shared code routines, allowing different apps to peacefully coexist and have similar functionality. It's no coincidence that even apps from different companies tend to display the same fonts, use similar buttons and menus, and allocate memory in a way that doesn't overwrite other programs or their databases. They're able to because they use shared Palm OS routines to perform these tasks, saving their developers from needing to write the routines from scratch.

Palm OS provides a rich set of some 1000 routines for handling memory, graphics, sounds, ports, text, categories, and user input. The "WinDrawChars" routine is an example. Apps run "WinDrawChars" to draw text onto the screen. This routine needs four pieces of information--called parameters--before it can draw. These include the text to draw, the total number of letters to draw, and where on screen to draw the text, expressed as horizontal and vertical coordinates. The screen's coordinates start with (0,0) in the upper left hand corner. Thus, an app can print "Hello" (which has 5 letters) in the upper left hand corner by running the "WinDrawChars" routine, giving it the four parameters ( "Hello", 5, 0, 0 ).

Hacks work by replacing one or more system routines with their own code. Any apps trying to use a replaced system routine end up using the hack's code instead. The hack gets the parameters the original routine would have gotten. It also gets the location of the original routine, so it can run that routine if it needs to (called "passing-through"), sometimes after first modifying the parameters. For instance, one could write a relatively useless hack to reverse text drawn to the screen by replacing the WinDrawChars routine. In the previous example, the hack would get the parameters ( "Hello", 5, 0, 0 ), but would reverse the text in the first parameter to ( "olleH", 5, 0, 0 ) before calling the original system routine to do the actual drawing.

Types of Hacks
Hacks replace system functions for different reasons. They can be categorized into three basic categories.

'Replacement' Hacks
"Replacement" hacks duplicate a system routine's functionality entirely, and do not pass-through to the original routine. FindHack is one example. When one taps on the silkscreened "find" button, FindHack, if active, brings up its own window to let the user perform an enhanced search operation. It does not call the system routine afterwards, as doing so would also bring up the original system window asking to perform the same search that was just completed.

'Enhancement' Hacks
Unlike replacement hacks, "enhancement" hacks do call the original system routine. When doing so, they either modify the passed parameters before passing them on, or use them to perform a related function. TealEcho is an enhancement hack. It hooks into a system routine used to save pen strokes for the graffiti system. TealEcho still passes through the pen strokes to the original routine, but also uses this information to draw the strokes onto the screen as you write.

'Parasitic' Hacks
Parasitic hacks are perhaps the most common. They resemble enhancement hacks, but function in ways not directly related to the routines they hook into. Instead, they use the system routines simply as a way to trigger their activation. Pop-up programs like printHack and TealLaunch fit into this category. Most of these hacks hook into the system routines "SysHandleEvent" or "EvtGetEvent". These are two routines that programs regularly call in response to screen taps, button presses, and other system messages. Parasitic programs tend to hook into one or the other, passing through to the original routines. They watch for one or more specific pen strokes or button presses, and activate only when a certain combination is seen.

Advanced Hack Usage
Some of you astute folks might have noticed a potential issue when running hacks. What happens if two hacks try to hook into the same system routine? Actually, it's exactly this situation which makes extensions managers necessary. When multiple hacks try to hook into the same routine, the manager chains them together like a bucket brigade, with each hack passing on parameters to the next one in the chain. This keeps the hacks in harmony, with only the last one calling the original system routine directly.

While usually a nifty solution, this can sometimes cause problems if the order of the hacks in the chain is significant. For instance, if one of the hacks is a replacement hack, it must be the last one in the chain because it won't call any hacks following it in the queue. This happens when trying to run FindHack with TealMagnify, the software magnifying glass. Both hook into the system "Find" command. TealMagnify brings up a magnifying window when you tap on the silkscreened "find" button. It also has another "find" button inside its window to allow "passing through" for an actual search operation. In normal use, this allows the silkscreened button to be used for two purposes: to start the magnifying glass, or perform a search operation. When using FindHack and TealMagnify together, TealMagnify must be first in the list because FindHack does not have a "pass-through" button. It wouldn't make sense for it to have one, as you'd normally never want to perform a standard system search if FindHack's enhanced search is available.

Conflicts between hacks or between a hack and an application can also occur. Sometimes, this is due to limited resources shared between the two parties. Other times, a conflict arises because two hacks are trying to accomplish tasks which are mutually exclusive. In either case, fixing the problem, if it is even possible, often requires modification of the programs. Fortunately, TealMaster has exclusive tools to avoid both problems. For hack-order problems, its priority setting allows the order of hacks to be specified explicitly. For conflicts, its application profile mapping feature allows hacks to be automatically turned on and off depending on the current application. By turning off hacks that are not needed, chances of encountering a conflict are minimized.

The major cause of hack conflicts, however, is exhaustion of stack memory. As converted in Issue #2, stack memory is a special section of all available memory reserved by Palm OS. All hacks must share this "stack" with each other and the current application. When the available stack runs out, the result is typically a spectacular system crash. The program TealMemBrain can be used to prevent such problems. A hack itself, TealMemBrain can be set to allocate more memory to the stack, increasing stability and preventing stack-based problems.

Where to Find Hacks
Hacks can be found on all Palm OS software download web sites. Handango and PalmGear H.Q. list some 300 of these system extensions. Some of the programs mentioned in this article were:

TealMaster ($9.95, www.tealpoint.com/softmstr.htm)
TealEcho ($11.95, www.tealpoint.com/softecho.htm)
TealLaunch ($11.95, www.tealpoint.com/softlnch.htm)
TealGlance ($11.95, www.tealpoint.com/softglnc.htm)
TealMagnify ($11.95, www.tealpoint.com/softlens.htm)
TealMemBrain ($11.95, www.tealpoint.com/softmemb.htm)
FindHack ($10, www.perso.wandoo.fr/fpillet/)
Afterburner (freeware, www.gavini.com)
printHack (prerelease, www.paulcomputing.com)

<<previous articlenext article >>

Home  |  Software  |  Add-Ins  |  Guides  |  Community  |  Press  |  Support  |  Site Map

This site is best viewed at 800x600 with Internet Explorer 4.0 or Netscape 4.0 or higher.
(c)1997-2008 TealPoint Software All rights reserved.