Link to home
Start Free TrialLog in
Avatar of yewnix
yewnixFlag for United States of America

asked on

Drive Letter Proxy

I'd like advice on an approach to take to do the following.
What I need is to create a Virtual Drive that acts as a proxy to a different server for the file(s).

ie:
my virtual drive is z:\

You define what paths Z can list.
\\server1\images
\\server2\images

if myimage.gho is on \\server1\images then the user goes there

Is this even somewhat possible ?

Subst won't work because it only seems to take one path.
Avatar of yewnix
yewnix
Flag of United States of America image

ASKER

Would it be possible to hook NtOpenFile / NtCreateFile and instead pass back the handle of the file I specify .. thus opening that file ?
Avatar of Eddie Shipman
You can map a network drive to the UNC path using WNetAddConnection2() and WNetCancelConnection2() to do the job. You can also use the "NET USE" command.

Here's some code to do it, posted on the Borland NG's by John Leavey:

function Connect_Drive( Drive, Path: String ): Boolean;
var
  NR: TNetResource;
  w: DWord;
begin
  WNetCancelConnection2( PChar( Drive ), 0, False );
  with NR do
  begin
    dwType := RESOURCETYPE_ANY;
    lpLocalName := PChar( Drive );
    lpRemoteName := PChar( Path );
    lpProvider := '';
  end;
  try
    w := WNetAddConnection2( NR, nil, nil, 0 );
    Result := w = 0;
  except
    on E: Exception do Result := False;
  end;
end;
Avatar of yewnix

ASKER

EddieShipman,
  Thanks for the reply. However this solution isn't what i'm looking for as it wouldn't do what I need it to. Here is a more detailed explaination of what i'm looking at accomplishing

[computer with virtual drive shared as \\mainserver\images]

3 Servers each containing a part of the image.
\\server1\images\image.gho
\\server2\images\image001.ghs
\\server3\images\image002.ghs

----------------------------------------
A computer with a ghost bootdisk
Boots and maps a network drive letter I to \\mainserver\images
When the computer tries to open mike.gho the [mainserver] finds out what server has the first part, and hands off the handle of the file back to the unit trying to load the image
When the computer goes for the second and third part it would do that same.
----------------------------------------

So as I stated before I was wondering if I hooked the api call NtCreateFile on the [mainserver]
Then it would query a database to find out where that file is located... get the file handle off the associated \\server\image\<image part>
Then hand it back to the unit loading the image

Ofcourse the network shares would use the same username\password for every server so that authentication would be automatic.
I as totally unaware of any way to map one drive to THREE different computers.
Please enlighten me...

In the ghost bootdisk, can you modify the batch file it runs upon startup?
May I ask HOW ghost only took PART of the image in each gho file?
Avatar of yewnix

ASKER

I'm not wanting to "MAP" one drive letter to three computers.
Basically I just want to HOOK the API call and when the computer doing the image download trys to open the file
the server sees it(because of the hook) and then passes back the HANDLE of the file off of a different server.

I'm not modifying anything into bootdisk at all.
It will ALWAYS map to \\mainserver\images

Avatar of yewnix

ASKER

"May I ask HOW ghost only took PART of the image in each gho file?"

Ghost can split an image into mutliple parts.
I believe the standard 2GB.
So if my total image is 6GB then i have three parts, each 2GB large.
Ghost is the only thing that handles putting the parts together. there is no way for you to do it otherwise.
ghost uses it's own compression algorithm and you won't be able to even figure out where the file
lies, much less decompress it.
Avatar of yewnix

ASKER

GHOST is still opening the file and uncompressing it to disk..
Do you still not understand what i'm trying to do ?

When I state HANDLE of the file I mean it programmatically..
Do you understand what I'm saying?
Ghost is the only thing has the capability to locate/open those files.

Since they are compressed using Ghost's compression algorithm you won't be able to
do anything with them even if you ARE successful in locating the parts. There is no way to
"hook" into Ghost to capture the opening because Ghost runs in a DOS virtual machine.

I'd like to know why you are so adamant to do this, anyway.
Avatar of yewnix

ASKER

I'm not hooking GHOST. I'm hooking the main server that ghosts maps its drive letter to.

I would like to make my own DFS(Distrubuted File System)
Window's DFS does not offer me enough functionality
ASKER CERTIFIED SOLUTION
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yewnix

ASKER

You are saying I can't create an application that is ran on the main server that creates a virtual drive(shared as \\mainserver\images)
Then installs a hook on NtCreateFile....

and when a different computer boots ghost off a dos disk... maps to \\mainserver\images
and when it requests a file....
the application that implemented the hook catches this and says.. no here is a different file..
Avatar of yewnix

ASKER

Can anyone give an update on this please ?
Avatar of yewnix

ASKER

No longer an issue.