Important alert: (current site time 7/15/2013 5:50:02 PM EDT)
 

VB icon

^!A dos based Turbo "C" program (TSR) to Lock / Unlock Floppy Drivers....(with full source code)

Email
Submitted on: 4/26/2002 3:21:36 AM
By: my name is Nitin Jindal (from Panchkula,Haryana)  
Level: Advanced
User Rating: By 2 Users
Compatibility: C, C++ (general)
Views: 24511
(About the author)
 
     Dos based TSR program to Disable/Enable floppy drives.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: ^!A dos based Turbo"C" program (TSR) to Lock / Unlock Floppy Drivers....(with full source code)
// Description:Dos based TSR program to Disable/Enable floppy drives.
// By: my nameis Nitin Jindal (from Panchkula,Haryana)
//
// Side Effects:Not compatible under windows
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=3805&lngWId=3//for details.//**************************************

/*
nofloppy.c written in "Turbo C" for Advance User
TSR program to disable floppy Drives A: & B:
Developed by Nitin Jindal
email:	 computer_bazzar@rediffmail.com
(don't send me email for any query,except Bug)
if possible send me a updated or advance version of this program. use can use,modify or redistribute this program freely
PLEASE VOTE FOR ME !!!!
REMEMBER:
(1)Never change the extension of this program to .cpp. 
(2) This program in meant for DOS (not for windows)
(3) This program will never compile in TC window. You have to use TCC compiler at dos prompt. This tcc.exe file will be present in TC folder. You don't need to copy this file 	from hell
	c:\tc> tcc nofloppy.c
(4)all the ".h" ".obj" files must be present in the current directory
(5)tasm.exe, tlink.exe files must be present in the current directory
(6)you will have to change <> to "" in ur program
for example insted of using <dos.h> u have to use "dos.h" also u have to change this <> to "" in ur dos.h or all calling .h files,simply open dos.h in any text editior and change all <> sign that call other .h files. You have to repeat this method with all ur calling .h files.
(7)it is better to copy all files in current directory c:\tc> copy bin (this will copy all files from c:\tc\bin)c:\tc> copy inlcude (this will copy all files from c:\tc\include)	c:\tc> copy lib (this will copy all files from c:\tc\lib)
*///////////////////////////////////////////////////////////////////
#pragma inline /* dodn't remove this line */
#include "dos.h"
#include "stdio.h"
#include "conio.h"
#define SUCCESS 0XC0FF
#define FAILURE 0XC000
union REGS i,o;
void interrupt (*old)();
struct INTERRUPT
{
	unsigned bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,fl;
};
void interrupt disk (struct INTERRUPT);
int tsrc;
unsigned our_psp;
void interrupt our_1c();
void interrupt (*prev_1c)();
void interrupt our_2f(struct INTERRUPT);
void interrupt (*prev_2f)();
main(int argc,char *argv[])
{
int far *ebptr;
strupr(argv[1]);
tsrc=strcmp(argv[1],"UNLOAD");
if(tsrc!=0)
		{
i.x.ax=0xc000;
int86(0x2f,&i,&o);
if(o.x.ax!=SUCCESS)
			{
our_psp=getpsp();
res();
ebptr=MK_FP(our_psp,0x2c);
freemem(*ebptr);
printf("\Nofloppy v(1.0) Installed Successfully....\n");
keep(0,2500);
/* if u want to use automatic memory allocation use next line*/
/*keep(0,(_SS+(_SP/16)-_psp));*/
			}
printf("\nfor unloading nofloppy use -> nofloppy unload \n");
printf("\n Nofloppy v(1.0) already Loaded.....");
}
else
		{
i.x.ax=0xc000;
int86(0x2f,&i,&o);
if(o.x.ax==SUCCESS)
{
i.x.ax=0xc001;
int86(0x2f,&i,&o);
if(o.x.ax==FAILURE)
printf("\nCannot uninstall Nofloppy v(1.0),another program on top\n");
else
printf("\nNofloppy ver(1.0) Uninstalled");
}
else
printf("\nNofloppy ver(1.0) NOT IN MEMORY");
}
return 0;
}
res()
{
prev_1c=getvect(0x1c);
setvect(0x1c,our_1c);
prev_2f=getvect(0x2f);
setvect(0x2f,our_2f);
old=getvect(0x13);
setvect(0x13,disk);
return 0;
}
void interrupt disk(struct INTERRUPT r)
{
	if (_DL==0 || _DL==1)
	{
	asm clc;
	asm pushf
	asm pop r.fl
	return;
	}
_ES=r.es;
_DX=r.dx;
_CX=r.cx;
_BX=r.bx;
_AX=r.ax;
(*old)();
asm pushf
asm pop r.fl;
r.ax=_AX;
r.bx=_BX;
r.cx=_CX;
r.dx=_DX;
r.es=_ES;
}
void interrupt our_1c()
{
(*prev_1c)();
}
void interrupt our_2f(struct INTERRUPT r)
{
if(r.ax==0xc000)
{
r.ax=SUCCESS;
return;
}
if(r.ax==0xc001)
{
r.ax=uninstall();
return;
}
asm pop bp
asm pop di
asm pop si
asm pop ds
asm pop es
asm pop dx
asm pop cx
asm pop bx
asm pop ax
asm jmp cs:_prev_2f;
}
int uninstall()
{
if(our_1c==getvect(0x1c) && our_2f==getvect(0x2f)&&disk==getvect(0x13))
{
setvect(0x1c,prev_1c);
setvect(0x2f,prev_2f);
setvect(0x13,old);
freemem(our_psp);
return(SUCCESS);
}
else
return(FAILURE);
}
/**************************************************/


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
1/18/2003 9:54:12 AM

AOA
Thnks for providing us such useful code.
sir, if you know how to programed a parallel port through c++ programming, please, send me any useful material. i will be very thankful to u. my email is
mr_aboubakar@yahoo.com
if you need further detail about it then feedback. i will be glade to see some help from u.
thankyou
your little brother
(If this comment was disrespectful, please report it.)

 
1/18/2003 10:06:18 AM

thnks sir for this code.
i think you are a nice person and would like to help to your juniors. sir, i have a problem about parallel port programing. i want to make a peer to peer connection between two computers through c/c++. if u have any useful material in this respect, please send me, i shall be very thnkful to you
(If this comment was disrespectful, please report it.)

 
2/22/2008 10:10:11 AMsivaprasad

Congrats ur achivement is amazing
Now floppy drives are rare will u change it with CD drive.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.