If the program produces the expected output, copy the Turbo C codes into your post and its result. You may do this by pressing Print Screen on your keyboard for the result of your program then, switch to Paint Brush and Paste. Resize the window and copy this to your post.
Answer:
#include
#include
#include
#include
#include
#include
unsigned char buffer[3];
FILE *fd;
int handle;
fail(char *);
void pass(char *);
main(int argc,char *argv[])
{
int n;
if(argc!=3)
{
printf("\nFailpass Utility v1.0 Email: chingpongin@yahoo.co.in");
printf("\nEnable/Disable .EXE or .COM execution");
printf("\nsyntex failpass fail
printf("\n or");
printf("\n failpass pass
exit(2);
}
strupr(argv[1]);
n=strcmp(argv[1],"FAIL");
if(n==0)
{
fail(argv[2]);
exit(2);
}
n=strcmp(argv[1],"PASS");
if(n==0)
{
pass(argv[2]);
exit(2);
}
return 0;
}
fail(char *fname)
{
_chmod(fname,1,FA_ARCH);
fd=fopen(fname,"rb+");
if(fd==NULL)
{
printf("\nCann't open %s\n\n",fname);
exit(2);
}
fseek(fd,0,SEEK_SET);
fread(buffer,2,1,fd);
if(buffer[0]==0xcd)
if(buffer[1]==0x20)
{
fclose(fd);
printf("\n%s already protected...\n\n",fname);
exit(2);
}
fseek(fd,0,SEEK_END);
fwrite(buffer,2,1,fd);
fseek(fd,0,SEEK_SET);
buffer[0]=0xcd; /* don't take any PANGA with this line */
buffer[1]=0x20; /* don't take any PANGA with this line */
fwrite(buffer,2,1,fd);
fclose(fd);
return 0;
}
void pass(char *fname)
{
int xyz;
fd=fopen(fname,"rb+");
if(fd==NULL)
{
fclose(fd);
printf("\nCannot open file %s\n\n",fname);
exit(2);
}
fseek(fd,0,SEEK_SET);
fread(buffer,2,1,fd);
if(buffer[0]!=0xcd)
if(buffer[1]!=0x20)
{
fclose(fd);
printf("\n%s is NOT protected....\n\n",fname);
exit(2);
}
fseek(fd,-2,SEEK_END);
fread(buffer,2,1,fd);
fseek(fd,0,SEEK_SET);
fwrite(buffer,2,1,fd);
fclose(fd);
handle=open(fname,O_RDWR);
chsize(handle,(filelength(handle))-2);
close(handle);
}
Jiacler Y. Tanap