Playing with Node.js and jQuery

I’ve been experimenting at work. Using Node.js to make a very simple web back-end and using jQuery/javascript on the client side. For work it’s to test out idea’s for “web based product configurations” stuff.

But I’ve been re-purposing the code/lessons at night:

Asm webview

 

I’ve made those two parts as panels and you can scroll (arrow keys) up/down though the assembly lines (plan to link highlighting when there are more views) and the function details is auto populating and dynamic, and it’s ajax’ed back to the node.js server, and persisted to disk.

Small starts, but I’ve found a “framework” in which to explore some idea’s I’ve struggled how to UI for years, so am over the moon with how this is progressing.

The bonus: the resulting tooling is web based so collaboration is baked in…

 

SVN Update Conflict finder

I just discovered a feature I’d never seen before in the Tortoise SVN Client, I did a update from my work repository, knowing there were a large number of project file changes that would conflict.

Normally I would scroll through list of changes and just visually locate the red lines.

Tortise SVN Next Conflict

But lo and behold, there is a button that takes you to the next conflict, magic!

-1.#IND00

Debugging a recent issue, where our _matherr handler was logging a call to sqrt with -1.#IND00 as input, and in this same scenario the system was crashing (the actual problem needing to be solved).

So to findout what input was going into the sqrt, as I suspected there was rubish being passed in, I wanted to know what -1.#IND00 was in binnary.

I knew that passing -1.0 to sqrt would result in -1.#IND00 in the result, so I altered the code:

int main ()
{
	double d = sqrt(-1.0);
}

int __cdecl _matherr(struct _exception *e)
{
	informf( "\nMath Error: %s, Parameters: %lf %lf, Return: %lf\n",
		e->name, e->arg1, e->arg2, e->retval ) ;

	union ccc
	{
		double d;
		struct {
			long a;
			long b;
		} ll;
	};

	ccc aa;

	aa.d = e->retval;

<break point here, and inspect aa in debugger>
	if( _isnan( e->retval ) ) {
		e->retval = 0 ;
	}
	return 1 ;
}

results in the values:

aa.ll.a = 0;
aa.ll.b = 0xFFF80000;

And I posted this because Googling for -1.#IND00 got me no results.

IDA Script: Fixing 16bit pushed data segment references

A good friend has started reversing an old 16bit Borland C++ (3.1?) program, and had lots of stack push data segment offsets that were not correctly cross referencing.

After telling him the shortcuts for manually fixing the issue (press O for the data segment, or Alt-R for any segment offset), he wrote an IDC script to do it en mass.

Thus (made up example code)


push ds;

mov ax, 0x1234;

push ax

should look like:


push ds;

mov ax, ds:dword_1234;

push ax

Here’s his script:

#include <idc.idc>

static main()
{
    auto seg, loc;
    auto movloc, movtarget;
    auto xref;
    auto dsegbase;

    dsegbase = SegByName("dseg") * 16;
    Message("dsegbase=%x\n", dsegbase);

    Message("========================================\n");
    seg = FirstSeg();

    while(seg != BADADDR )
    {
        Message("----------------------------------------\n");

        loc = SegStart(seg);

        if( Byte(loc) != 0xCD || Byte(loc+1) != 0x3F)
        {
            Message("Fixing indirect push [ds:xx] refs from %s\n", SegName(seg));

            while(loc != BADADDR && loc < SegEnd(seg))
            {
                if (GetMnem(loc) != "push" || GetOpnd(loc, 0) != "ds")
                {
                    loc = NextHead(loc, BADADDR);
                    continue;
                }
                loc = NextHead(loc, BADADDR);

                if (GetMnem(loc) != "mov" || GetOpType(loc, 1) != o_imm)
                {
                    loc = NextHead(loc, BADADDR);
                    continue;
                }
                movloc = loc;
                movtarget = GetOpnd(movloc, 0);
                loc = NextHead(loc, BADADDR);

                if (GetMnem(loc) != "push" || GetOpnd(loc, 0) != movtarget)
                {
                    continue;
                }

                // At this point, we know we're pushing a [ds:x] combo.
                //Message("%x: mov %s, %s\n", movloc, movtarget, GetOpnd(movloc, 1));

                // Abort if there already exists a Dxref
                xref = Dfirst(movloc);
                if (xref != BADADDR)
                {
                    continue;
                }

                Message("  Updating %s:%04x\n", SegName(seg), (movloc - seg) & 0xffff);
                OpOff(movloc, 1, dsegbase);
            }
        }

        seg = NextSeg(seg);
    }
}