• 0

any kind person to convert 1995 C into a modern .NET language?


Question

hey, there's a program that us router hackers use to fix bricked routers which ppl accidently brick when trying to install DD-WRT open source router firmware. It uses the parallel port to erase the memory on the router. The program that needs re-writing in a modern language enables the JTAG cable to communicate with the router via a parallel (aka lptp) port but if you are using a pci card with a parallel port on then it wont work as the IRQ addresses are incorrect to the default ones for this app which are the ones which onboard parallel ports use. If someone can re-write this app in a modern language we might be able to get 1 of the dd-wrt programmers to change the code to auto-detect the irq addresses, we would need the new sourcecode of course.

source code: http://www.sendspace.com/file/tmdq77 (25kb)

for more info about this app and what needs to be changed after written in a modern language see here: http://www.dd-wrt.com/phpBB2/viewtopic.php...asc&start=0

we would be very thankful indeed!

here is a photo of the cable that its for to connect PC to a router:

1zfnek4.jpg

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

First, these "modern" toy languages like .NET are totally unsuitable for low-level hardware access; this is the kind of stuff for which you need C. Second, all you posted was some bootstrap code to install a driver; reread the thread.

Link to comment
Share on other sites

  • 0

yes, the code is to load the driver, then install it but if you dont have default irq values that you have with onboard parallel ports then it wont install which wont let you use the wrt54g.exe application which this app is to be used with which erases the memory on the router, this app is to load a driver that will allow the wrt54g.exe app to fix the router.

Link to comment
Share on other sites

  • 0

Well, there is nothing in that application which does that, so presumably you'd need the source code for the driver itself. This is essentially just a GUI someone put together in about five minutes that simply passes the file name of the driver to a Windows API.

Link to comment
Share on other sites

  • 0

The program and source code you attached are for a generic driver loader, which is typically used by programmers (in most cases) to load drivers they're coding/testing. Recoding this in .NET would be rather pointless, as this should function on any 32-bit version of Windows and furthermore, I'm not sure there's even a .NET interface for the service control manager, so you'd be forced to import the same APIs used by this program; making the port to C#/.NET trivial.

This tool itself means nothing to your specific case. The driver you attached with it I'm assuming somehow holds some significance though (if it doesn't, you're an idiot who shouldn't put random sh*t in archives). I was in a bored mood and had 10 minutes to waste, so I decided to reverse it and recode the driver itself (despite the fact no source was included). Here it is: (there might be a few typos, but I only did this quickly in notepad)

#include <ntddk.h>

UNICODE_STRING  szDeviceName, szSymbolicLinkName;
DEVICE_OBJECT   DeviceObject = NULL;
KSPIN_LOCK	  SpinLock;

VOID DriverUnload(__in const PDRIVER_OBJECT pDriverObject)
{
  if (DeviceObject != NULL)
  {
	IoDeleteSymbolicLink(szSymbolicLinkName);
	IoDeleteDevice(&DeviceObject);
  }
}

NTSTATUS DriverDispatch(__in const PDRIVER_OBJECT pDriverObject, __in PIRP pIRP)
{
  KIRQL OldIRQL;

  pIRP->IoStatus.Information  = 0;
  pIRP->IoStatus.Status	   = STATUS_SUCCESS;

  // this is some real hacky **** this coder wanted to do
  if (*(BYTE*)Tail.Overlay.CurrentStackLocation == 14)
  {
	if (*(DWORD*)(Tail.Overlay.CurrentStackLocation + 3) == 0x830020C0)
	{
	  if (*(DWORD*)(Tail.Overlay.CurrentStackLocation + 1) > 4)
	  {
		// coder should have just gone with an interlocked exchange
		KeAcquireSpinLock(&SpinLock, &OldIRQL);
		pIRP->AssociatedIrp.MasterIrp->MdlAddress = (PMDL)13; // prepare for a BSOD
		KeReleaseSpinLock(&SpinLock, &OldIRQL);
		pIRP->IoStatus.Information  = 4;
	  }
	}
	else
	  pIRP->IoStatus.Status = STATUS_INVALID_PARAMETER;
  }

  IoCompleteRequest(pIRP, 0);
  return pIRP->IoStatus.Status;
}

EXTERN_C NTSTATUS DriverEntry(__inout PDRIVER_OBJECT pDriverObject, __in_z PUNICODE_STRING pszRegistryPath)
{
  UNREFERENCED_PARAMETER(pszRegistryPath);

  RtlInitUnicodeString(&szDeviceName, L"\\Device\\WDDJ_NT");
  // NOTE: the usage of 0x8300 is bizarre, drivers must used the predefined FILE_DEVICE_* constants,
  //	   yet this driver uses one reserved by microsoft itself.
  //	   if it doesn't work, just try changing it to FILE_DEVICE_UNKNOWN.
  if (NT_SUCCESS(IoCreateDevice(pDriverObject, 4, &szDeviceName, 0x8300, FILE_DEVICE_SECURE_OPEN, TRUE, &DeviceObject)))
  {
	RtlInitUnicodeString(&szSymbolicLinkName, L"\\DosDevices\\WDDJ_NT");
	if (NT_SUCCESS(IoCreateSymbolicLink(&szSymbolicLinkName, szDeviceName)))
	{
	  KeInitializeSpinLock(&SpinLock);
	  pDriverObject->MajorFunction[IRP_MJ_CREATE] = DriverDispatch;
	  pDriverObject->MajorFunction[IRP_MJ_CLOSE]  = DriverDispatch;
	  pDriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = DriverDispatch; // got no ****in' clue why it does this
	  pDriverObject->DriverUnload = DriverUnload;
	  return STATUS_SUCCESS;
	}
	else
	  IoDeleteDevice(DeviceObject);
  }
  return STATUS_UNSUCCESSFUL;
}

Link to comment
Share on other sites

  • 0

the driver that needs to be loaded using this loaddrv.exe is iogive.sys which is in this .rar: http://www.sendspace.com/file/1tgh78

the wrt54g.exe application that actually does the erasing of the memory of the router is also in the rar along with sourcecode for it. Not sure if the author of the wrt54g.exe app is able to integrate the code from the loading app into it, would be much nicer to have it all in 1 app rather than 2 applications.

the WDDJ_NT.SYS that was left in the first .rar file i linked was in the original archive the author of loaddrv.exe made so i'm not sure what that does but the driver we need to load is iogive.sys.

so to summarise:

loaddrv.exe is used to load iogive.sys, in the app you press the "install" button then "start", this allows you to connect with a router via a parallel port using a JTAG cable. Then you use the wrt54g.exe app to erase the memory of the router which then fixes the bricked router and you can use other software to re-install DD-WRT open source router software. BUT the drive iogive.sys ONLY works with default IRQ values for parallel ports on motherboards and wont work with parallel ports on pci cards as most new motherboards dont have parallel ports so i bought a pci parallel port.

Edited by torrentthief
Link to comment
Share on other sites

  • 0

You really need to read these posts more carefully. All that x0r did was reverse-engineer the sample driver that was included in the rar you posted; basically, he just posted a sample driver from Dr. Dobb's Journal to demonstrate his ability to read x86.

Edit: looks like you edited your post. :)

Edit2: If you really want someone to look at this, why not at least post a link to the source and article associated with the giveio driver that was provided in the original thread instead of expecting someone to disassemble it?

Link to comment
Share on other sites

  • 0

sorry didnt realise you posted when i started editing my post.

I didnt realise at first that the giveio.sys file was the problem which is why i didnt post it, i thought it was the loaddrv.exe problem which is why i thought someone could re-write it in a modern language with a similar gui and the person could put a banner to their programming/software house as free advertisement for helping but from your feedback it seems that the giveio.sys file is the problem, after alot of googling i've found the sourcecode for giveio.sys: http://www.ddj.com/architect/184409876?pgno=3

Edited by torrentthief
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.