Did you ever sit in front of IDA thinking "Wow, I think this function would make more sense if all the lines were randomly shuffled". That's not a problem anymore with rublib 0.02!
foo = file[0].map{|l| l.line}.sort_by{rand}
foo.length.times{|i| file[0][i].manual_line = foo[i]}
And you have the lines of the first function shuffled in random order!
OK, this might be a bit useless. But it shows one of the many improvements of rublib 0.02 over yesterday's version. In the new version it's possible to modify values too. In the old version only read access to the IDB database was possible. There are many other improvements in the new version. It's now significantly longer (88 methods according to rdoc), it contains better code, I've added quite a few bug fixes, there's an actual documentation for it, and I've written unit tests to make sure I don't accidentally break things.
Let's see some more one-liners.
Here's what you do to get all function comments:
p file.map{|f| f.comment}.compact
Or if you want to get all comments from inside a function:
p file[0].map{|l| l.comment}.compact
Or if you want to add some TODO reminder to all functions you named but don't yet have a function comment:
file.select{|f| f[0].user_name? && f[0].auto_name? == false && f.comment == nil}.each{|f| f.comment = "TODO: Add comment"}
There are a few things that are on my list of things to do next.
First, I need a better name for rublib. I should stop naming my stuff after what it does. Many moons ago there was something on Slashdot that commercial products have names that appeal to the general population while open-source products have names for nerds (Exhibit A: Photoshop vs GIMP). Although I doubt that rublib is something for the general population I'd like to move away from GIMP and towards Photoshop.
Second, besides the goal of allowing people to write IDA scripts in as few lines as possible I want to add something that the IDA SDK is missing: Consistency and decent names. Sometimes the IDA SDK names use camelCase and sometimes they_use_underscores, sometimes they use neither. Furthermore names like get_func_qty are not easy to remember compared to number_of_functions. Adding consistent names is relatively easy. Adding consistent behaviour is tricky because no two situations are 100% the same. Sometimes it makes more sense to throw an exception and sometimes it makes more sense to return nil. There's another example. Negative indexes are OK for functions (file[-1] returns the last function in the file) whereas negative indexes are not OK for strings in the string list (file.string_list[-1] throws a RuntimeError).
Third, there are a few design issues. One of them is the question whether it would make sense to create a class hierarchy containing all string classes (ansi, unicode, pascal...)? It probably would.
Oh well,
here's rublib 0.02. Enjoy.