delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/10/06/05:46:36

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <cone.1128591471.368325.13774.0@digisoft>
X-Mailer: http://www.courier-mta.org/cone/
From: Jose Miguel =?ISO-8859-1?B?UOlyZXo=?= <NOSPAM_josemiguel_ AT _NOSPAM_perezruiz DOT com_NOSPAM>
Newsgroups: comp.os.msdos.djgpp
Subject: Need to hook INT 21h from a DJGPP TSR
Mime-Version: 1.0
Lines: 58
X-Complaints-To: abuse AT easynews DOT com
Organization: EasyNews, UseNet made Easy!
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Thu, 06 Oct 2005 09:37:54 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi All!

I'm developing a DJGPP TSR which will be a installable FS to access Ext2 
partitions from DOS. I have in place all the code to keep the TSR, hook some 
interrupts and such. However, I'm stuck with INT 21h.

I want to hook INT 21h, to provide LFN support and some more functions. The 
following is a sample of the actual code I'm using to hook INT 2F, 
but it does not work with INT 21h.

Please note before replying: This is a protected mode TSR, which returns to 
DOS. The problem is similar to calling system() with INT 21h hooked.


//-------------------------------------------------------------------------
// All memory is LOCKED. No virtual memory.
int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;

//-------------------------------------------------------------------------
void my_handler(_go32_dpmi_registers *r)
{
    if (r->h.ah == OUR_FUNCTION) {
        // Do work
        return;
    }

    r->x.cs = oldInt2F.rm_segment;
    r->x.ip = oldInt2F.rm_offset;
    r->x.ss = r->x.sp = 0;
    _go32_dpmi_simulate_fcall_iret(r);
}

//-------------------------------------------------------------------------
void install_handler()
{
    _go32_dpmi_get_real_mode_interrupt_vector(0x2F, &oldInt2F);
    info.pm_offset = (unsigned long)my_handler;
    _go32_dpmi_allocate_real_mode_callback_iret(&info, &regs);
    _go32_dpmi_set_real_mode_interrupt_vector(0x2F, &info);
}


I'm aware of the reentrance problem, however, I don't know how to handle it. 
It will be very useful to see some sample code which already solves this.

I will not call any INT 21h functions inside my handler, at least I'm not 
planning to, so reentrancy should not be a problem for me besides DJGPP 
itself calling INT 21h.

Please, I'm in a hurry, since the entire project is stopped until I can 
solve this. It will be very useful if you have some links to source code 
that already does this or some documentation I can read. I'm not very good 
at assembly code, but if you know of a solution in assembly it will be 
welcome.

Cheers,
Jose Miguel.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019