www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/09/26/06:40:41

Xref: news-dnh.mv.net comp.os.msdos.djgpp:2188
Path: news-dnh.mv.net!mv!news.sprintlink.net!cs.utexas.edu!swrinde!tank.news.pipex.net!pipex!dispatch.news.demon.net!demon!alphdyn.demon.co.uk
From: Steve Higgins <steve>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Locking handlers code
Date: Tue, 26 Sep 1995 08:30:28 GMT
Lines: 55
References: <DFHJ4D DOT 8tG AT jade DOT mv DOT net>
Nntp-Posting-Host: alphdyn.demon.co.uk
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

Here are the routines that I use to lock and unlock the program memory.

Perhaps someone else could confirm that they will work.


#include <stdio.h>
#include <string.h>
#include <dpmi.h>


__dpmi_meminfo lockRegion;



void LockEverything()
{
    unsigned long addr;

    printf("Locking Program Memory\n");

    __dpmi_get_segment_base_address(_go32_my_cs(),&addr);

    printf("Base Address of Code Selector 0x%lx\n",addr);

    memset(&lockRegion,0,sizeof(lockRegion));

    lockRegion.address = addr + 0x10A8;
    lockRegion.size    = sbrk(0) - 0x10A8;

    if(__dpmi_lock_linear_region(&lockRegion) == -1)
    {
        printf("  Memory Lock Error\n");
        printf("    Could not lock %d K of program memory.\n",
                lockRegion.size/1024+1);
        exit(0);
    }
    else
    {
        printf("  Locked %d K of system memory\n",lockRegion.size/1024+1);
    }
}


void UnlockEverything()
{
    printf("Unlocking Program Memory\n");
    __dpmi_unlock_linear_region(&lockRegion);
}



-- 
Steve Higgins

- Raw text -


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