Archive for September, 2011

container.getElementsByTagName is not a function

I was setting up DokuWiki the other day to play around with. I want to use it as a kind of note pad of sorts to document some of my work and ideas and keep them accessible. As I was tweaking things here and there things started to get a little broken. In particular, the cool editing toolbar over the edit box when editing topics disappeared.

Looking at the DokuWiki faq it seems the most likely cause is broken JavaScript somewhere so I opened up FireBug to see what was happening. This is what I found:

container.getElementsByTagName is not a function
   var collection = container.getElementsByTagName(tagName);

Well, that looks like a valid function for a DOM element so why would it not be defined? This error is occurring on line 2155 of ASCIIMathML.js (2.0.2) in the function called getElementsByClass(). This function takes three parameters, container, tagName, and clsName.

So I set a break point and check some of the parameters. Right away I see that the container parameter is actually being given a string that actually looks like a class name.

Until recently, browsers didn’t supply a native getElementsByClass() function[1] so libraries that needed it provided their own implementation. It seems this implementation is overriding another implementation that does take the class name as a first parameter instead of a DOM element.

ASCIIMathML.js actually only calls this function twice so I opted for the simple solution of find/replace in ASCIIMathML.js and renamed the function to something simple like amGetElementsByClass(). With that change, the error is gone and my toolbar is back.

[1] JavaScript now has a native getElementsByClassName() method supported by Firefox 3 and up, IE9 (not 7 or 8!) Safari, Chrome and Opera.

Tags: , , ,

Monday, September 19th, 2011 JavaScript, Programming No Comments

FWdasm v0.01

FWdasm is a free command line disassembler intended to be used to examine executable files. It is designed to be scriptable and able to quickly pull out specific information about an executable in a format that is easily parsed in an automated fashion. It is also able to dump large amounts of information in nicely formatted tables and cross-referenced assembly for manual analysis. Currently, only Microsoft PE executables are supported but support for other executable formats including ELF and analysis of raw binary streams (e.g. shellcode) will be added in the future.
The following sample output was generated by running FWdasm on itself using the following command line parameters:

C:>fwdasm -vf fwdasm.exe -Ccos all -qlixSabfgTRdvvvv > out.txt

The parameters are described on the download page below. Note that there are multiple ‘v’ parameters passed. This increases the verbosity of the output and is intended for producing human friendly output. If no ‘v’ parameters are specified, output is in a format suitable for text parsing. Tables are output in csv format that can be imported into a spreadsheet application. Assembly is output without cross-reference information. As ‘v’ parameters are added, tabular data is formatted in SQL-like output tables, and the assembly code is more and more annotated with offsets, call and branch target cross-references, string table references and external library calls.

FWdasm is free and can be downloaded here.

Tags: , ,

Sunday, September 11th, 2011 Programming No Comments