Win32HandleToDosFileHandle / DosFileHandleToWin32Handle

Derek Fawcus dfawcus at
Fri Jan 27 21:07:34 CST 2006

On Fri, Jan 27, 2006 at 09:24:13PM +0100, Eric Pouech wrote:
> Derek Fawcus wrote:
> > I'm looking to do some changes to the wine vdm - or more accurately
> > to the winedos dll to make the handling for some DOS applications
> > more useful.  This is mainly driven from a desire to run DOS apps
> > without a wineconsole,  so using the unix stdin/stdout/stderr as
> > the DOS file handles.  i.e. ala the BSD doscmd program;  mind it
> > also has similar issues (plus I'd have to port it :)
> > 
> > There are a few things I'll have to alter wrt to the existing console
> > handling (within winedos),  but the main part will be using the JFT
> > within the PSP/PDB and creating SFTs.  
> not sure what you're exactly trying to achieve.
> why do you need this ? do you really have programs peeking inside the 
> JFT/SFT structures ?

It's not the peeking,  it's to make some other emulation more accurate.

I don't anticipate making the SFT look like the DOS SFT,  or even having
it visible to the DOS/win16 program.  It'll be an abstraction within
the VDM which is equivalent to a SFT.

At the moment,  if program 1 opens a file,  execs program 2 and then
program 2 closes the file,  program 1 will no longer have a valid
file handle.  Or at least that's how I read the code,  since there
does not seem to be any increment of a reference count across the
DOS int 21/4b.

I suppose one could do something in the VDM process to mark the file
handles as having multiple references,  and then do proper open / close
handling.  But that would require a valid JFT anyway.

So th JFT gives a way to update a reference count in the SFT.

Another place where I think it'll come in handy is for redirection,
where it'll allow for stashing an equivalent of the device info word.
I think this'll make some of the console handling a bit better.

So at the moment,  I'm thinking of something like:

struct pseudo_SFT {
    WORD    refcnt;
    HANDLE  win32_file_handle;
    WORD    device_info_word;

There are also othe bits of the int21.c code which could be simplified
if the above existed (possibly by adding more fields).


More information about the wine-devel mailing list