🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #154

HELP! Trouble accessing Data Segment in Interrupt Routine

#154
From: Marni Allison Fylling
Date: Sat, 01 Aug 1992 10:54
63 lines
2819 bytes
Help me.
 
I am writing a device driver (as a DLL).  Part of the device driver is an
Interrupt routine that needs to access the DLL's Data Segment.
 
I have been having trouble using FreeSelector in my device driver.  I
have to play with Selectors because I use self-modifying code to
allow my interrupt routine to access its Data segment.
 
Is this the best way to get an Interrupt Routine to access a Data
Segment?
 
What I do is the following:
 
In an initialization routine (see below), I modify the interrupt routine by
writing the Data Segment Selector in.  In order to write data to
a Code segment (a no-no in protected mode), I first called
(AllocCStoDSAlias) to allocate a Data Selector for the Code Segment,
used it to modify the code, then called FreeSelector() to dispose of it.
 
*******
 
In the initialization routine: 
  (DS points to library's data seg, and this code is in the same
  segment as the interrupt code)
 
    push    ds                          ; save Viper Data Selector
 
    Arg     <cs>                        ; get IntCode Code Selector
    cCall   AllocCStoDSAlias            ; create Data Selector copy in ax
                                        
    mov     ds,ax                       ; ds now has Data Selector to IntCode
    pop     ax                          ; get Viper Data Selector
    mov     ds:[WORD PTR ViperStoreDS], ax ; modify code
 
    Arg     <ds>
    cCall   FreeSelector                ; free allocated selector
 
    mov     ds,ax                       ; restore Viper Data Selector
 
*******
 
At the beginning of my interrupt routine I have:
 
    mov     ax,0000h           ; !!! this part of code gets modified !!!
ViperStoreDS EQU  $-2          ; label to part of code to modify
    mov     ds,ax              ; load ds with Data Seg Selector
 
*******
 
The problem with FreeSelector() is that is causes a GP fault!?! (at
FreeSelector+0061).
 
Has anyone else had this experience?  What am I overlooking?
 
Thanks,
   Marni
-- 
       /|   |\ jmufdiwolu ,^.__,^\        o__     ,^\   Ron Goodman at 
 |\  |' |   | fconservet  |  `\   '\     _.>/ _  /   \    UC Santa Cruz
 |   | ()  () pmkeqica__,/     `\   `\  (_) \(_)' goodman@saturn.ucsc.edu
()  ()       xbigh_,-'_/' ,,,,,,,`\/\,\_/``````        \________________/
Technical Details
Message-ID: <15dqhjINN4ju@darkstar.UCSC.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!hal.com!darkstar.UCSC.EDU!cats.ucsc.edu!marni

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!hal.com!darkstar.UCSC.EDU!cats.ucsc.edu!marni
From: marni@cats.ucsc.edu (Marni Allison Fylling)
Newsgroups: comp.windows.ms.programmer
Subject: HELP!  Trouble accessing Data Segment in Interrupt Routine
Keywords: Device Driver, Interrupts, Selectors, Data Segment
Message-ID: <15dqhjINN4ju@darkstar.UCSC.EDU>
Date: 1 Aug 92 10:54:43 GMT
Organization: University of California; Santa Cruz
Lines: 63
NNTP-Posting-Host: si.ucsc.edu