Juil 202014
 

In a previous article, I have shared a delphi unit for libewf.

Now lets code a proxy for ImDisk using that external libyal library to mount an EWF file.

I initially used this template from reboot.pro and came with the below basic delphi unit.

Once I had done that, it was pretty easy to fill in the missing parts to mount and EWF reusing my previous libewf delphi unit.
See code attached.proxy_EWF

library proxy;

uses
  SysUtils,
  Classes,windows;

{$R *.res}

type
  dllread_proc = function (handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;
  dllwrite_proc = function (handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;
  dllclose_proc = function (handle:thandle): integer; cdecl;

var
file_handle:thandle;

function SetFilePointerEx (hFile: THandle; lDistanceToMove: int64; lpNewFilePointer: Pointer; dwMoveMethod: DWORD): BOOL; stdcall; external 'kernel32.dll';
function GetFileSizeEx(hFile: THandle; var lpFileSize: Int64): BOOL; stdcall; external 'kernel32.dll' name 'GetFileSizeEx';

function my_read_proc(handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;
var
bytes_read:cardinal;
begin
	writeln('Read request - size:'+inttostr(size)+' offset:'+inttostr(offset));
	SetFilePointerEx(handle, offset, nil, FILE_BEGIN);
	ReadFile(handle, buf^, size, bytes_read, nil);
	result:=bytes_read;
end;

function my_write_proc(handle:thandle; buf:pointer; size:cardinal; offset:int64): integer; cdecl;
var
bytes_written:cardinal;
begin
	writeln('Write request - size:'+inttostr(size)+' offset:'+inttostr(offset));
	SetFilePointerEx(handle, offset, nil, FILE_BEGIN);
	WriteFile(handle, buf^, size, bytes_written, nil);
	result:=bytes_written;
end;

function my_close_proc(handle:thandle): integer; cdecl;
begin
	writeln('Close request');
	CloseHandle(handle);
	result:=0;
end;

function dllopen(filename:pchar; read_only:integer; var dllread:dllread_proc; var dllwrite:dllwrite_proc; var dllclose:dllclose_proc; var size:int64):thandle;cdecl;
begin
	writeln('File to open: '+filename);

	dllread := my_read_proc;
	dllwrite := my_write_proc;
	dllclose := my_close_proc;

	file_handle := CreateFile(filename, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
	GetFileSizeEx(file_handle, size);

	result:=file_handle;
end;

exports
  dllopen index 1;

begin
end.

The command lines for the proxy and ImDisk are below :

devio --dll=proxy.dll;dllopen shm:test_proxy c:\test.vmdk
imdisk -a -t proxy -o shm -o ro -f test_proxy -m Z:

Devio in action :
imdisk_ewf

Juil 142014
 

Changes since last changelog.

Discuss it here. Download it here.

changed : using IOCTL_DISK_GET_LENGTH_INFO in main screen rather than disk geometry to retrieve (correct) disk size
added : user confirmation on disk online/offline/rw/ro
added : display disk serial number (in disk properties)
added : display disk cache information (in disk properties)
added : display disk attributes (in disk properties)
changed : update int13 unit with IOCTL_DISK_GET_DRIVE_GEOMETRY_EX instead of IOCTL_DISK_GET_DRIVE_GEOMETRY
changed : moved most disk management (GET) functions to a separate unit (http://msdn.microsoft.com/en-us/library/windows/desktop/aa363979(v=vs.85).aspx)
changed : renamed clone_disk method to clone
fixed : _GetDiskLength
added : _GetPartLength
added : backup_ewf & restore_ewf
added : zero out unused (ntfs) clusters
added : CompactVirtualDisk
added : backup to fixed vhd (raw image+footer)

 Posted by at 22 h 22 min
Juil 072014
 

A small break away from coding and electronic…

I wanted to offer something special to my special geek girl so here it is : a jewel (earings) made of resistors 🙂

Two times 5 * 1.8Kohm : yes, I am not cheap, not counting !

IMG_4423

 Posted by at 21 h 42 min
Juil 062014
 

In a previous article, we had used a 74HC595 to control a ULN2803.
This enabled us to deal with 8 LED’s.

Lets now cascade two 74HC595 to deal with 16 LED’s.
To do this, we will use the serial output of 74HC595 #1 to the serial input of 74HC595 #2.

Here below the schema.

uln2803a_4_bb

Here below the arduino sketch.
Note that we use two arrays, and that we go up and down in each array.

//the pins we are using
int latchPin = 2;
int clockPin = 3;
int dataPin = 4;


byte dataArrayA[9];
byte dataArrayB[9];
 
void setup() {
  //set all the pins used to talk to the chip
  //as output pins so we can write to them
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  
  dataArrayA[0] = 0xFF; //11111111
  dataArrayA[1] = 0xFE; //11111110
  dataArrayA[2] = 0xFC; //11111100
  dataArrayA[3] = 0xF8; //11111000
  dataArrayA[4] = 0xF0; //11110000
  dataArrayA[5] = 0xE0; //11100000
  dataArrayA[6] = 0xC0; //11000000
  dataArrayA[7] = 0x80; //10000000
  dataArrayA[8] = 0x00; //00000000
  
  dataArrayB[8] = 0xFF; //11111111
  dataArrayB[7] = 0xFE; //11111110
  dataArrayB[6] = 0xFC; //11111100
  dataArrayB[5] = 0xF8; //11111000
  dataArrayB[4] = 0xF0; //11110000
  dataArrayB[3] = 0xE0; //11100000
  dataArrayB[2] = 0xC0; //11000000
  dataArrayB[1] = 0x80; //10000000
  dataArrayB[0] = 0x00; //00000000

}
 
void loop() {
  for (int i = 0; i < 9; i++) {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, dataArrayA[i]);  
    shiftOut(dataPin, clockPin, MSBFIRST, dataArrayB[i]);
    digitalWrite(latchPin, HIGH);
    delay(100);
  }

  for (int i = 8; i >= 0; i--) {
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, dataArrayA[i]);
  shiftOut(dataPin, clockPin, MSBFIRST, dataArrayB[i]);  
  digitalWrite(latchPin, HIGH);
  delay(100);
  }
  
}
 Posted by at 19 h 39 min
Juil 052014
 

I discussed WinFE some weeks ago here.

It got updated with the following significant features (amongst others) : SysWOW64 and UEFI support. See here.

 Posted by at 14 h 59 min
Juin 082014
 

Here below a video illustrating the previous article.

On the proto board, you’ll notice a 74HC595 controlling a ULN2803 plugged to 8 leds.

I use the below array of byte to have the up and down effect

  dataArray[0] = 0xFF; //11111111
  dataArray[1] = 0xFE; //11111110
  dataArray[2] = 0xFC; //11111100
  dataArray[3] = 0xF8; //11111000
  dataArray[4] = 0xF0; //11110000
  dataArray[5] = 0xE0; //11100000
  dataArray[6] = 0xC0; //11000000
  dataArray[7] = 0x80; //10000000
  dataArray[8] = 0x00; //00000000

Juin 072014
 

Still on my journey to a wordclock…

In the previous article, we have seen how to use a shift register to control up to 8 digital outputs (or more if you cascade IC’s).

One drawback in the previous setup is that we had to use one transistor per digital output (to control a device powered by another source).
That is 8 extra transistors, 8*3 extra wires, etc : not very practical and especially if we intend to control several shift registers IC’s. (i plan on using 3 in my wordclock project)

So this is where the ULN2803 comes in : 8 NPN transistors and one common ground in one integrated circuit.

uln2803

See below a refreshed schema (compared to the previous article). Note that I have decided to power my IC’s with my (regulated) Arduino 5v but I could as well have used my battery pack power.
Our 74HC595 will control our ULN2803 (by sending HIGH or LOW on the input) which in turn will drive the current thru each output/led.

uln2803a_bb

the Arduino sketch :

//the pins we are using
int latchPin = 2;
int clockPin = 3;
int dataPin = 4;
 
void setup() {
  //set all the pins used to talk to the chip
  //as output pins so we can write to them
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}
 
void loop() {
  for (int i = 0; i < 8; i++) {
 
    //take the latchPin low so the LEDs don't change while we are writing data
    digitalWrite(latchPin, LOW);
 
    //shift out the bits
    shiftOut(dataPin, clockPin, MSBFIRST, i);  
 
    //take the latch pin high so the pins reflect
    //the data we have sent
    digitalWrite(latchPin, HIGH);

    // pause before next value:
    delay(1000);
  }
}