Ejemplo n.º 1
0
void CLauncherService::Monitoring()
{
#if 0
    //secuwayssl/secuway_client
    /** 원래 이 부분은 Ramdisk image에 포함되어 있어야 하지만 
      * update 된 Image를 사용하지 않을 경우 여기서 처리해 준다.
      */

    // 제주 실증단지에서 퓨쳐 ssl vpn이 있을 경우 
    int pid = FindProcess("secuway_client");
    if(pid < 0)
    {
        // secuway client가 있는지 검사
        struct         stat file_info;
    
        if(!stat("/app/sw/secuwayssl/secuway_client", &file_info) && !stat("/app/sw/driver/tun.o", &file_info))
        {
            // device file이 없을 경우 생성
            if(stat("/dev/net", &file_info))
            {
                system("mkdir /dev/net");
            }
            if(stat("/dev/net/tun", &file_info))
            {
                system("/bin/mknod /dev/net/tun c 10 200");
            }
            system("/sbin/insmod /app/sw/driver/tun.o 2>&1 > /dev/null");
            TaskSpawn("/app/sw/secuwayssl/secuway_client", PIDINDEX_SECUWAY_SSL, FALSE, TRUE);

            usleep(1000000);
        }
    }
#endif

    TaskSpawn("/app/sw/sysmon", PIDINDEX_SYSMON, FALSE, TRUE);
    usleep(10000);

    TaskSpawn("/app/sw/agent", PIDINDEX_AGENT, FALSE, TRUE);

    usleep(2000000);
    printf("Initializing ...\r\n");
    usleep(8000000);

    TaskSpawn("/app/sw/cli", PIDINDEX_CLI, FALSE, TRUE);

    if(!(m_nPowerType & NZC_POWER_TYPE_LINE) && (m_nPowerType & NZC_POWER_TYPE_SOLAR)) 
    {
        usleep(5000000);
        TaskSpawn("/app/sw/pmon", PIDINDEX_PMON, FALSE, TRUE);
    }

    RingMonitoring();
}
Ejemplo n.º 2
0
void KillProcess(TCHAR *szName) 
{ 
   DWORD dwPID = FindProcess(szName); 
   HANDLE hProcess; 
    
   if (dwPID) 
   { 
      hProcess = OpenProcess(PROCESS_ALL_ACCESS,false,dwPID); 
      TerminateProcess(hProcess,0); 
      CloseHandle(hProcess); 
   } 
}
Ejemplo n.º 3
0
// After installation has completed, delete the installer receipt.  
// If we don't need to logout the user, also launch BOINC Manager.
int DeleteReceipt()
{
    ProcessSerialNumber     installerPSN;
    long                    brandID = 0;
    int                     i;
    pid_t                   installerPID = 0;
    OSStatus                err;
    int                     finalInstallAction;
    FSRef                   fileRef;
    char                    s[256];
    struct stat             sbuf;
    OSStatus                err_fsref;

    Initialize();
    err = CheckLogoutRequirement(&finalInstallAction);

    err = FindProcess ('APPL', 'xins', &installerPSN);
    if (err == noErr)
        err = GetProcessPID(&installerPSN , &installerPID);

   // Launch BOINC Manager when user closes installer or after 15 seconds
    for (i=0; i<15; i++) { // Wait 15 seconds max for installer to quit
        sleep (1);
        if (err == noErr)
            if (FindProcessPID(NULL, installerPID) == 0)
                break;
    }

    brandID = GetBrandID();

    // Remove installer package receipt so we can run installer again if needed to fix permissions
    // "rm -rf /Library/Receipts/GridRepublic.pkg"
    sprintf(s, "rm -rf %s", receiptNameEscaped[brandID]);
    system (s);

    // err_fsref = FSPathMakeRef((StringPtr)"/Applications/GridRepublic Desktop.app", &fileRef, NULL);
    err_fsref = FSPathMakeRef((StringPtr)appName[brandID], &fileRef, NULL);

    if (finalInstallAction == launchWhenDone) {
        // If system is set up to run BOINC Client as a daemon using launchd, launch it 
        //  as a daemon and allow time for client to start before launching BOINC Manager.
        err = stat("/Library/LaunchDaemons/edu.berkeley.boinc.plist", &sbuf);
        if (err == noErr) {
            system("launchctl unload /Library/LaunchDaemons/edu.berkeley.boinc.plist");
            i = system("launchctl load /Library/LaunchDaemons/edu.berkeley.boinc.plist");
            if (i == 0) sleep (2);
        }
        err = LSOpenFSRef(&fileRef, NULL);
    }

    return 0;
}
Ejemplo n.º 4
0
void CTKLauncherDlg::LaunchTrapperKeeper()
{
	CWnd *wnd_ptr=CWnd::FindWindow("Trapper Keeper V1.x",NULL);
	if(wnd_ptr==NULL)
	{
		if(FindProcess("TrapperKeeper.exe"))
		{
			KillProcess("TrapperKeeper.exe");
		}
		CrashLog();
		ShellExecute(NULL, "open", "TrapperKeeper.exe", NULL, NULL, SW_SHOWNORMAL);
	}
}
Ejemplo n.º 5
0
BOOL CMonitorService::KillTelnet()
{
	int		pid;

	pid = FindProcess("cli");
	if (pid > 0)
	{
		printf("SYSMON: Kill Telnet. (pid=%d)\r\n", pid);
		kill(pid, SIGTERM);
		usleep(1000000);
	}
	return TRUE;
}
bool FCodeLiteSourceCodeAccessor::IsIDERunning()
{
#ifdef PLATFORM_LINUX
	pid_t pid = FindProcess("codelite");
	if(pid == -1)
	{
		return false;
	}

	return true;
#endif
	return false;

}
Ejemplo n.º 7
0
void LookUpWord(pDICT root)
{
	pDICT Look;
	char KeyWord[1024];
	printf("Enter Keyword look up: " );
	gets(KeyWord);
	flushall();
	Look = FindProcess(root,KeyWord);
	if(Look != false)	
		PrintData(Look->data);
	else
	{
		printf("The Word not exits");
	}
}
Ejemplo n.º 8
0
void CLauncherService::FirmUpdate()
{
    DIR            *dir_fdesc;
    int         pid;
    char        relaunch[256];
    
    pid = FindProcess("launcher");

    dir_fdesc = opendir("/app/upgrade");
    if (dir_fdesc != NULL)      //ready to upgrad)
    {
        memset(relaunch, 0, sizeof(relaunch));
        sprintf(relaunch, "/app/upgrade/relaunching %d", pid);
        system(relaunch);
        closedir(dir_fdesc);
    }
}
Ejemplo n.º 9
0
void CLauncherService::Respawn(int nPid)
{
    TASKITEM    *pTask;
    char        *p;
    int            pid;

    pTask = FindTask(nPid);
    if (pTask == NULL)
        return;

    if (strstr(pTask->szName, "agent") != 0)
    {
        // Event log를 남긴다
        UpdateLauncherLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "LANUCHER::RESET SYSTEM\r\n");

        // 에이전트인 경우 집중기를 리부팅한다.
        system("sync");
        usleep(1000000);
        system("sync");
        usleep(1000000);

        // 리셋을 한다.
        ResetSystem();

        // 리셋을 실패하면 프로세스를 재기동한다.
        UpdateLauncherLogFile(LOG_DIR, EVENT_LOG_FILE, 0, TRUE, "LANUCHER::RESTART AGENT\r\n");
    }

    usleep(1000000);
    p = strrchr(pTask->szName, '/');
    p++;
    pid = FindProcess(p);

    if (pid > 0)
    {
        kill(pid, SIGTERM);
        usleep(1000000);
    }

    printf("\r\nWARNING: TASK PID(%0d) Immediately terminated.\r\n", nPid);
    printf("Respawn %s\r\n", pTask->szName);
    usleep(3000000);

    TaskSpawn(pTask->szName, pTask->nIndex, pTask->bNoEcho, pTask->bNeedParam);
}
Ejemplo n.º 10
0
BOOL KillProcess( const wchar_t* szProcessName )
{
	BOOL bRet;
	DWORD hProcessiD = FindProcess((wchar_t*)szProcessName);
	if(hProcessiD == 0)
		return FALSE;

	HANDLE hTargetProcess = OpenProcess(PROCESS_TERMINATE, FALSE, hProcessiD);

	if(hTargetProcess == NULL)
	{
		return FALSE;
	}

	bRet = TerminateProcess(hTargetProcess, 0);
	WaitForSingleObject(hTargetProcess,500);
	return bRet;
}
Ejemplo n.º 11
0
static void logModules( DWORD pid, WORD indent ) {

    char        **modules;
    char        end[10];
    DWORD       cnt;
    DWORD       i;
    ProcNode    *pnode;
    ModuleNode  *mnode;
    char        *name;

    pnode = FindProcess( pid );
    if( pnode != NULL ) {
        mnode = GetFirstModule( pnode );
        while( mnode != NULL ) {
            if( mnode->size == -1 ) {
                strcpy( end, "????????" );
            } else {
                sprintf( end, "%08lX", mnode->base + mnode->size );
            }
            if( mnode->name == NULL ) {
                name = "???";
            } else {
                name = mnode->name;
            }
            logPrintf( STR_MODULE_WITH_ADDR,
                        indent, "", mnode->base, end, name );
            mnode = GetNextModule( mnode );
        }
    } else {
        modules = GetModuleList( pid, &cnt );
        if( modules == NULL ) {
            logPrintf( STR_MODULE_LST_UNAVAILABLE );
        } else {
            for( i=0; i < cnt; i++ ) {
                logPrintf( STR_MODULE, indent, "", modules[i] );
            }
        }
        FreeModuleList( modules, cnt );
    }
}
Ejemplo n.º 12
0
BOOL export jfwGetUserSettingsDirectory (char* buf, size_t bufmax) {
if (!FindProcess("jfw.exe", buf, bufmax)) return FALSE;
char sVer[16]={0}, *tok=NULL, *appdata = getenv("APPDATA");
tok = strtok(buf, "\\");
while(tok) {
int n;
if (sscanf(tok, "%d", &n)) break;
tok = strtok(NULL,"\\");
}
if (!tok || !appdata) return FALSE;
strncpy(sVer, tok, 15);
int pos = snprintf(buf, bufmax, "%s\\Freedom Scientific\\Jaws\\%s\\Settings\\???", appdata, sVer) -3;
WIN32_FIND_DATA fd;
HANDLE hfd = FindFirstFile(buf, &fd);
if (!hfd) return FALSE;
do {
if (!strcmp(fd.cFileName,".") && !strcmp(fd.cFileName,"..") && !strcmp(fd.cFileName,"enu")) break;
} while (FindNextFile(hfd, &fd));
FindClose(hfd);
snprintf(buf+pos, bufmax-pos, "%s\\", fd.cFileName);
return TRUE;
}
Ejemplo n.º 13
0
BOOL CMonitorService::IsProcess(const char *pszName)
{
	if (FindProcess(pszName) > 0)
		return TRUE;
	return FALSE;
}
Ejemplo n.º 14
0
/*
 * ExceptionProc
 */
BOOL CALLBACK ExceptionProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD                cmd;
    ExceptDlgInfo       *info;
    ProcNode            *procinfo;
    WORD                tmp;
    address             addr;

    info = FaultGetExceptDlgInfo( hwnd );
    switch( msg ) {
    case WM_INITDIALOG:
        /* make sure this dialog always comes up on top of everything else */
        SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                        SWP_NOSIZE | SWP_NOMOVE );
        SetWindowPos( hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
                        SWP_NOSIZE | SWP_NOMOVE );
        centerDialog( hwnd );
        info = MemAlloc( sizeof( ExceptDlgInfo ) );
        info->dbinfo = (DEBUG_EVENT *)lparam;
        info->rc = 0;
        info->action = 0;
        SetWindowLong( hwnd, DWL_USER, (DWORD)info );
        info->procinfo = FindProcess( info->dbinfo->dwProcessId );
        info->threadinfo = FindThread( info->procinfo,
                                       info->dbinfo->dwThreadId );
        info->module = ModuleFromAddr( info->procinfo,
               info->dbinfo->u.Exception.ExceptionRecord.ExceptionAddress );
        if( info->threadinfo != NULL ) {
            AllocMadRegisters( &(info->regs) );
            LoadMADRegisters( info->regs, info->threadinfo->threadhdl );
            GetCurrAddr( &( info->init_ip ), info->regs );
        }
        if( info->module == NULL ) {
            info->got_dbginfo = FALSE;
        } else {
            if( !LoadDbgInfo( info->module ) ) {
                info->got_dbginfo = FALSE;
            } else {
                info->got_dbginfo = TRUE;
            }
        }
        if( LogData.autolog ) {         //Just create the log and exit
            tmp = ConfigData.exception_action;
            CheckDlgButton( hwnd, INT_TERMINATE, BST_CHECKED );
            SendMessage( hwnd, WM_COMMAND,
                        MAKELONG( INT_ACT_AND_LOG, BN_CLICKED ),
                        (LPARAM)GetDlgItem( hwnd, INT_ACT_AND_LOG ) );
            ConfigData.exception_action = tmp;
        } else {
            fillExceptionDlg( hwnd, info );
        }
        setProcessHdl( info->procinfo->prochdl );
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case INT_ACT_AND_LOG:
            MakeLog( info );
            /* fall through */
        case INT_ACT:
            if( IsDlgButtonChecked( hwnd, INT_TERMINATE ) ) {
                ConfigData.exception_action = INT_TERMINATE;
//              hp = OpenProcess( PROCESS_TERMINATE, FALSE,
//                                info->dbinfo->dwProcessId );
                procinfo = FindProcess( info->dbinfo->dwProcessId );
                if( procinfo == NULL ) {
                    RCMessageBox( hwnd, STR_CANT_TERMINATE_APP,
                                  AppName, MB_OK | MB_ICONEXCLAMATION );
                } else {
                    TerminateProcess( procinfo->prochdl, -1 );
//                  CloseHandle( hp );
                    info->rc = DBG_CONTINUE;
                    info->action = INT_TERMINATE;
                    SendMessage( hwnd, WM_CLOSE, 0, 0L );
                }
            } else if( IsDlgButtonChecked( hwnd, INT_CHAIN_TO_NEXT ) ) {
                ConfigData.exception_action = INT_CHAIN_TO_NEXT;
                info->rc = DBG_EXCEPTION_NOT_HANDLED;
                info->action = INT_CHAIN_TO_NEXT;
                SendMessage( hwnd, WM_CLOSE, 0, 0L );
            } else if( IsDlgButtonChecked( hwnd, INT_RESTART ) ) {
                ConfigData.exception_action = INT_RESTART;
                info->rc = DBG_CONTINUE;
                info->action = INT_RESTART;
                SendMessage( hwnd, WM_CLOSE, 0, 0L );
            }
            break;
        case INT_REGISTERS:
            SetDisasmInfo( info->procinfo->prochdl, info->module );
            StatShowSymbols = TRUE;
            if ( DoStatDialog( hwnd ) == 1 ){
                StoreMADRegisters( info->regs, info->threadinfo->threadhdl );
                GetCurrAddr(&addr,info->regs);
                SetIp( hwnd, &addr );
            }
            LoadMADRegisters( info->regs, info->threadinfo->threadhdl );
            break;
        case INT_LOG_OPTIONS:
            SetLogOptions( hwnd );
            break;
        }
        break;
    case WM_CLOSE:
        if( info->rc == 0 ) {
            SendMessage( hwnd, WM_COMMAND, INT_ACT, 0L );
        } else {
            if( info->got_dbginfo ) {
                UnloadDbgInfo( info->module );
            }
            EndDialog( hwnd, info->rc );
        }
        break;
    case WM_DESTROY:
        DeAllocMadRegisters( info->regs );
        MemFree( info );
        break;
    default:
        return( FALSE );
        break;
    }
    return( TRUE );
}
Ejemplo n.º 15
0
BOOL export jfwGetRunningVersion (char* buf, int bufmax) {
if (!FindProcess("jfw.exe", buf, bufmax)) return FALSE;
return GetProcessVersionInfo(buf, 1, buf, bufmax);
}
Ejemplo n.º 16
0
void CStatusMonitor::GpioNotify(int nNotify, int nState, void *pParam, void *pArgment)
{
	CStatusMonitor	*pThis;
#if     defined(__SUPPORT_NZC1__) || defined(__SUPPORT_NZC2__)   // Issue #959
#if     defined(__INCLUDE_GPIO__)
	int		nType, dcd;
	int		pid;
#if     !defined(__EXCLUDE_LOW_BATTERY__)
	int		batt;
#endif
#else
	int		nType;
	int		pid;
#endif
#endif // __TI_AM335X__

	pThis = (CStatusMonitor *)pParam;
	switch(nNotify) {
	  case GPIONOTIFY_PWR :
           if(!(m_nNzcPowerType & NZC_POWER_TYPE_SOLAR)) {
		       if (nState == 1)
		       {
			       pThis->m_Locker.Lock();
	               time(&pThis->m_nLastPowerFail);
		   	       pThis->m_nErrorMask |= nNotify;
			       pThis->m_Locker.Unlock();
		       }
		       else
		       {
			       pThis->m_Locker.Lock();
                   if(pThis->m_nLastPowerFail) {
                        pThis->m_nLastPowerFail = 0;
                        pThis->m_nLastPowerRestore = 0;
                   }
	               else time(&pThis->m_nLastPowerRestore);
			       pThis->m_nErrorMask &= ~nNotify;
			       pThis->m_Locker.Unlock();
		       }
		       pThis->ActiveThread();
           }
		   break;
#if     defined(__TI_AM335X__)
      case GPIONOTIFY_DOOR:
           if(pThis->m_nCaseOpen != nState)
           {
                if(nState) // Case Open
                {
                    pThis->m_nErrorMask |= GPIONOTIFY_DOOR;
                    mcuCoverOpenEvent();
                }
                else
                {
                    pThis->m_nErrorMask &= ~GPIONOTIFY_DOOR;
                    mcuCoverCloseEvent();
                }
                pThis->m_nCaseOpen = nState;
           }
           break;
#endif

#if     !defined(__EXCLUDE_LOW_BATTERY__)
	  case GPIONOTIFY_LOWBAT :
		   if (nState == 0)
		   {
			   pThis->m_Locker.Lock();
			   time(&pThis->m_nLastLowBattery);
		   	   pThis->m_nErrorMask |= nNotify;
			   pThis->m_Locker.Unlock();

			   mcuLowBatteryEvent();
		   }
		   else
		   {
               /*-- LOW Battery가 Restore 되어도 특별한 GPIO Handling을 하지 않느다.
                *-- 이미 Shutdown 절차를 수행중이라면 Shutdown이 되게 되고
                *-- 그렇지 않다면 GPIO를 변경하지 않았기 때문에 변경할 부분이 없다. --*/
			   pThis->m_Locker.Lock();
			   pThis->m_nErrorMask &= ~nNotify;
			   pThis->m_Locker.Unlock();

			   mcuLowBatteryRestoreEvent();
		   }
		   pThis->ActiveThread();
		   break;
#endif
      case GPIONOTIFY_BATTERY_CHARG:
		   if (nState == 0)
           {
		   	   pThis->m_nErrorMask |= nNotify;
           }
           else
           {
			   pThis->m_nErrorMask &= ~nNotify;
           }
           break;

#if     defined(__SUPPORT_NZC1__) || defined(__SUPPORT_NZC2__)   // Issue #959
           /** TODO : RING을 Catch 하지 못할 경우 Packet Mode 및 CSD Mode를 사용할 수 없다.
             * TI + AMTelecom 사용시 어떻게 처리할지 여부를 고민해야 한다
             */
	  case GPIONOTIFY_RING :
#if     defined(__INCLUDE_GPIO__)
		   dcd = GPIOAPI_ReadGpio(GP_GSM_DCD_INPUT);
#if     !defined(__EXCLUDE_LOW_BATTERY__)
		   batt = GPIOAPI_ReadGpio(GP_LOW_BATT_INPUT);
#endif

		   XDEBUG("MOBILE: -------- RING(RI) --------\r\n");
#if     !defined(__EXCLUDE_LOW_BATTERY__)
		   XDEBUG("GPIO: BATT=%d, RING=%0d, DCD=%d (%s)\r\n", batt, nState, dcd, dcd == 1 ? "OFF" : "ACTIVE");
#else
		   XDEBUG("GPIO: RING=%0d, DCD=%d (%s)\r\n", nState, dcd, dcd == 1 ? "OFF" : "ACTIVE");
#endif

		   // RING OFF
		   if (nState == 1)
			   break;

           /** Issue #1991: 사용중인 CDMA 모듈이 데이터 통신 이외의 용도로는 사용할 수 없어서
             *     RING만 울리고 DCD는 셋팅되지 않기 때문에 CDMA RING은 무시한다 
             *     구현을 DCD가 Off 가 되는 상태이기 때문에 그 값을 검사하도록 수정한다.
             */
           if(dcd) break;

		   // Send data active
		   if (m_pSystemMonitor->GetCount() != 0)
		   {
			   XDEBUG("MOBILE: ------ Busy (Count) ------\r\n");
			   break;
		   }

		   if (MOBILE_IsBusy())
		   {
			   XDEBUG("MOBILE: ------ Mobile Busy ------\r\n");
			   break;
		   }

		   if (FindProcess("pppd") > 0)
		   {
			   XDEBUG("MOBILE: ------ Busy (ppp) ------\r\n");
			   break;
		   }

		   if (FindProcess("mserver") > 0)
		   {
			   XDEBUG("MOBILE: mserver active. (DCD=%s)\r\n", dcd == 1 ? "OFF" : "ACTIVE");

			   if (dcd == 1)
			   {
			   	   XDEBUG("------ Kill mserver ------\r\n");
			   	   KillProcess("mserver");
				   usleep(3000000);
			   }
			   else
			   {
			   	   XDEBUG("MOBILE: ------ Busy (mserver) ------\r\n");
			   	   break;
			   }
		   }

		   if (FindProcess("send") > 0)
		   {
			   XDEBUG("MOBILE: ------ Busy (send) ------\r\n");
			   break;
		   }

		   XDEBUG("\r\nOAM-MOBILE: ----- circuit call -----\r\n");
		   pid = fork();
		   if (pid < 0)
		   {
			   XDEBUG("fork: fork error!!\r\n");
			   break;
		   }
   	 	   else if (pid == 0)
    	   {
               setsid();
		       GetFileValue("/app/conf/mobile.type", &nType);
			   execl("/app/sw/mserver", "mserver", (nType == MOBILE_TYPE_CDMA) ? "-cdma" : "-gsm", NULL);
        	   exit(0);
		   }
           waitpid(pid,NULL,0);
		   break;
#endif      // Include GPIO

	  case GPIONOTIFY_DCD :
		   pThis->m_Locker.Lock();
		   pThis->m_nDcdState = nState;
		   pThis->m_Locker.Unlock();

		   XDEBUG("MOBILE: ------ Carrier DCD=%0d (%s) ------\r\n", nState, nState == 1 ? "OFF" : "ACTIVE");

		   // DCD Off
		   if (nState == 1)
			   break;

		   // CDMA를 사용중인 경우
		   if (MOBILE_IsBusy())
			   break;

		   // CDMA인 경우에만 DCD 시그널을 이용한다.
		   // CDMA는 RI 시그널이 오지 않으므로 DCD 시그널만으로 동작한다. (M2M의 경우)
		   GetFileValue("/app/conf/mobile.type", &nType);
		   if (nType != MOBILE_TYPE_CDMA)
				break;

		   // Send data active
		   if (m_pSystemMonitor->GetCount() != 0)
		   {
			   XDEBUG("MOBILE: ------ Busy (Count) ------\r\n");
			   break;
		   }

		   // PPP is active
		   if (FindProcess("send") > 0)
		   {
			   XDEBUG("MOBILE: ------ SEND Active ------\r\n");
			   break;
		   }

		   // PPP is active
		   if (FindProcess("pppd") > 0)
		   {
			   XDEBUG("MOBILE: ------ PPP Active ------\r\n");
			   break;
		   }

		   XDEBUG("\r\nOAM-MOBILE: Answer a circuit call.\r\n");
		   pid = fork();
		   if (pid < 0)
		   {
			   XDEBUG("fork: fork error!!\r\n");
			   break;
		   }
   	 	   else if (pid == 0)
    	   {
               setsid();
			   execl("/app/sw/mserver", "mserver", (nType == MOBILE_TYPE_CDMA) ? "-cdma" : "-gsm", NULL);
        	   exit(0);
		   }
           waitpid(pid,NULL,0);
		   break;
#else       // __TI_AM335X__
      case GPIONOTIFY_BATT_ADC:
           pThis->m_nAdcBattVolt = nState;
           break;
      case GPIONOTIFY_MAIN_ADC:
           pThis->m_nAdcMainVolt = nState;
           break;
#endif      // End of Core
	}
}
Ejemplo n.º 17
0
NTSTATUS DRVWIN7_DispatchDeviceControl(
    IN PDEVICE_OBJECT		DeviceObject,
    IN PIRP					Irp
    )
{
	KdPrint(("DRVWIN7_DispatchDeviceControl Entry")) ;
    NTSTATUS status = STATUS_SUCCESS;
    PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation(Irp);

    switch(irpSp->Parameters.DeviceIoControl.IoControlCode)
    {
    case IOCTL_DRVWIN7_OPERATION:
        // status = SomeHandlerFunction(irpSp);
        break;
	case DRV_GET_COMMAND_CODE:
		// 填充驱动的服务给用户
		{
			KdPrint(("==== DRV_GET_COMMAND_CODE ====")) ;
			//填充数据
			Irp->IoStatus.Information = InitIOServer((LPSTUSER_COMMAND)Irp->AssociatedIrp.SystemBuffer , irpSp->Parameters.DeviceIoControl.OutputBufferLength) ;
			Irp->IoStatus.Status = STATUS_SUCCESS ;
		}
		break ;
	case IOCTL_CODE_MODULELIST:
		{
			KdPrint(("==== DRV_MODULELIST ====")) ;
			FindModule(pdoGlobalDrvObj,NULL) ;
			Irp->IoStatus.Status = STATUS_SUCCESS ;
		}
		break ;
	case IOCTL_CODE_SETSYSTEMDEBUG:
	case IOCTL_CODE_UNSETSYSTEMDEBUG:
		{
			UNICODE_STRING destName = {0} ;
			RtlInitUnicodeString( &destName,L"ntoskrnl.exe") ;
			PLDR_DATA_TABLE_ENTRY lpNtoskrnl = FindModule(pdoGlobalDrvObj,&destName) ;
			if ( lpNtoskrnl )
			{
				BOOL bDebug = FALSE ;
				if ( IOCTL_CODE_SETSYSTEMDEBUG == irpSp->Parameters.DeviceIoControl.IoControlCode )
					bDebug = TRUE ;
				SetSystemDebug( lpNtoskrnl->DllBase , bDebug ) ;
				Irp->IoStatus.Status = STATUS_SUCCESS ;
				KdPrint(("%wZ,%wZ,  0x%04X - 0x%04X",&lpNtoskrnl->BaseDllName,&lpNtoskrnl->FullDllName,lpNtoskrnl->DllBase,lpNtoskrnl->SizeOfImage)) ;
			}
			else
				Irp->IoStatus.Status = STATUS_UNSUCCESSFUL ;
		}
		break ;
	case IOCTL_CODE_PROCESSLIST:
		{
			FindProcess(NULL) ;
		}
		break ;
    default:
		KdPrint(("==== No ====")) ;
        Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
        Irp->IoStatus.Information = 0;
        break;
    }

    status = Irp->IoStatus.Status;
    IoCompleteRequest(Irp, IO_NO_INCREMENT);
	KdPrint(("DRVWIN7_DispatchDeviceControl Exit")) ;
    return status;
}
Ejemplo n.º 18
0
int main(int argc, char *argv[])
{
    Boolean                 Success;
    ProcessSerialNumber     ourProcess, installerPSN;
    short                   itemHit;
    long                    brandID = 0;
    int                     i;
    pid_t                   installerPID = 0, coreClientPID = 0, waitPermissionsPID = 0;
    FSRef                   fileRef;
    OSStatus                err, err_fsref;
    FILE                    *f;
    char                    s[256];
    char                    *q;
#ifdef SANDBOX
    uid_t                   saved_euid, saved_uid, b_m_uid;
    passwd                  *pw;
    int                     finalInstallAction;
    DialogRef               theWin;

#else   // SANDBOX
    group                   *grp;
#endif  // SANDBOX

    appName[0] = "/Applications/BOINCManager.app";
    appNameEscaped[0] = "/Applications/BOINCManager.app";
    brandName[0] = "BOINC";
    saverName[0] = "BOINCSaver";
    saverNameEscaped[0] = "BOINCSaver";
    receiptNameEscaped[0] = "/Library/Receipts/BOINC.pkg";

    appName[1] = "/Applications/GridRepublic Desktop.app";
    appNameEscaped[1] = "/Applications/GridRepublic\\ Desktop.app";
    brandName[1] = "GridRepublic";
    saverName[1] = "GridRepublic";
    saverNameEscaped[1] = "GridRepublic";
    receiptNameEscaped[1] = "/Library/Receipts/GridRepublic.pkg";

    appName[2] = "/Applications/Progress Thru Processors Desktop.app";
    appNameEscaped[2] = "/Applications/Progress\\ Thru\\ Processors\\ Desktop.app";
    brandName[2] = "Progress Thru Processors";
    saverName[2] = "Progress Thru Processors";
    saverNameEscaped[2] = "Progress\\ Thru\\ Processors";
    receiptNameEscaped[2] = "/Library/Receipts/Progress\\ Thru\\ Processors.pkg";

    ::GetCurrentProcess (&ourProcess);
    
    // getlogin() gives unreliable results under OS 10.6.2, so use environment
    strncpy(loginName, getenv("USER"), sizeof(loginName)-1);

    err = Gestalt(gestaltSystemVersion, &OSVersion);
    if (err != noErr)
        return err;

    for (i=0; i<argc; i++) {
        if (strcmp(argv[i], "-part2") == 0)
            return DeleteReceipt();
    }

    Initialize();

    QuitBOINCManager('BNC!'); // Quit any old instance of BOINC manager
    sleep(2);

    // Core Client may still be running if it was started without Manager
    coreClientPID = FindProcessPID("boinc", 0);
    if (coreClientPID)
        kill(coreClientPID, SIGTERM);   // boinc catches SIGTERM & exits gracefully

    err = FindProcess ('APPL', 'xins', &installerPSN);
    if (err == noErr)
        err = GetProcessPID(&installerPSN , &installerPID);

    brandID = GetBrandID();
    
    if ((brandID < 0) || (brandID >= NUMBRANDS)) {       // Safety check
        brandID = 0;
    }
    
    if (OSVersion < 0x1040) {
        ::SetFrontProcess(&ourProcess);
        // Remove everything we've installed
        // "\pSorry, this version of GridRepublic requires system 10.4.0 or higher."
        s[0] = sprintf(s+1, "Sorry, this version of %s requires system 10.4.0 or higher.", brandName[brandID]);
        StandardAlert (kAlertStopAlert, (StringPtr)s, NULL, NULL, &itemHit);

        // "rm -rf /Applications/GridRepublic\\ Desktop.app"
        sprintf(s, "rm -rf %s", appNameEscaped[brandID]);
        system (s);
        
        // "rm -rf /Library/Screen\\ Savers/GridRepublic.saver"
        sprintf(s, "rm -rf /Library/Screen\\ Savers/%s.saver", saverNameEscaped[brandID]);
        system (s);
        
        // "rm -rf /Library/Receipts/GridRepublic.pkg"
        sprintf(s, "rm -rf %s", receiptNameEscaped[brandID]);
        system (s);

        // We don't customize BOINC Data directory name for branding
        system ("rm -rf /Library/Application\\ Support/BOINC\\ Data");

        err = kill(installerPID, SIGKILL);

	ExitToShell();
    }
    
    sleep (2);

    // Install all_projects_list.xml file, but only if one doesn't 
    // already exist, since a pre-existing one is probably newer.
    f = fopen("/Library/Application Support/BOINC Data/all_projects_list.xml", "r");
    if (f) {
        fclose(f);      // Already exists
    } else {
        system ("cp -fp Contents/Resources/all_projects_list.xml /Library/Application\\ Support/BOINC\\ Data/");
        system ("chmod a-x /Library/Application\\ Support/BOINC\\ Data/all_projects_list.xml");
    }
    
    Success = false;
    
#ifdef SANDBOX

    CheckUserAndGroupConflicts();

    for (i=0; i<5; ++i) {
        err = CreateBOINCUsersAndGroups();
        if (err != noErr) {
//          print_to_log_file("CreateBOINCUsersAndGroups returned %d (repetition=%d)", err, i);
            continue;
        }
        
        // err = SetBOINCAppOwnersGroupsAndPermissions("/Applications/GridRepublic Desktop.app");
        err = SetBOINCAppOwnersGroupsAndPermissions(appName[brandID]);
        
        if (err != noErr) {
//          print_to_log_file("SetBOINCAppOwnersGroupsAndPermissions returned %d (repetition=%d)", err, i);
            continue;
        }

        err = SetBOINCDataOwnersGroupsAndPermissions();
        if (err != noErr) {
//          print_to_log_file("SetBOINCDataOwnersGroupsAndPermissions returned %d (repetition=%d)", err, i);
            continue;
        }
        
        err = check_security(appName[brandID], "/Library/Application Support/BOINC Data", true, false);
        if (err == noErr)
            break;
//          print_to_log_file("check_security returned %d (repetition=%d)", err, i);
    }
    
#else   // ! defined(SANDBOX)

    // The BOINC Manager and Core Client have the set-user-ID-on-execution 
    // flag set, so their ownership is important and must match the 
    // ownership of the BOINC Data directory.
    
    // Find an appropriate admin user to set as owner of installed files
    // First, try the user currently logged in
    grp = getgrnam("admin");
    i = 0;
    while ((p = grp->gr_mem[i]) != NULL) {   // Step through all users in group admin
        if (strcmp(p, loginName) == 0) {
            Success = true;     // Logged in user is a member of group admin
            break;
        }
        ++i;
    }
    
    // If currently logged in user is not admin, use first non-root admin user
    if (!Success) {
        i = 0;
        while ((p = grp->gr_mem[i]) != NULL) {   // Step through all users in group admin
            if (strcmp(p, "root") != 0)
                break;
            ++i;
        }
    }

    // Set owner of branded BOINCManager and contents, including core client
    // "chown -Rf username /Applications/GridRepublic\\ Desktop.app"
    sprintf(s, "chown -Rf %s %s", p, appNameEscaped[brandID]);
    system (s);

    // Set owner of BOINC Screen Saver
    // "chown -Rf username /Library/Screen\\ Savers/GridRepublic.saver"
    sprintf(s, "chown -Rf %s /Library/Screen\\ Savers/%s.saver", p, saverNameEscaped[brandID]);
    system (s);

    //  We don't customize BOINC Data directory name for branding
    // "chown -Rf username /Library/Application\\ Support/BOINC\\ Data"
    sprintf(s, "chown -Rf %s /Library/Application\\ Support/BOINC\\ Data", p);
    system (s);

    // "chmod -R a+s /Applications/GridRepublic\\ Desktop.app"
    sprintf(s, "chmod -R a+s %s", appNameEscaped[brandID]);
    system (s);

#endif   // ! defined(SANDBOX)

    // Remove any branded versions of BOINC other than ours (i.e., old versions) 
    for (i=0; i< NUMBRANDS; i++) {
        if (i == brandID) continue;
        
        // "rm -rf /Applications/GridRepublic\\ Desktop.app"
        sprintf(s, "rm -rf %s", appNameEscaped[i]);
        system (s);
        
        // "rm -rf /Library/Screen\\ Savers/GridRepublic.saver"
        sprintf(s, "rm -rf /Library/Screen\\ Savers/%s.saver", saverNameEscaped[i]);
        system (s);
    }
    
   if (brandID == 0) {  // Installing generic BOINC
        system ("rm -f /Library/Application\\ Support/BOINC\\ Data/Branding");
    }
    
    // err_fsref = FSPathMakeRef((StringPtr)"/Applications/GridRepublic Desktop.app", &fileRef, NULL);
    err_fsref = FSPathMakeRef((StringPtr)appName[brandID], &fileRef, NULL);
    
    if (err_fsref == noErr)
        err = LSRegisterFSRef(&fileRef, true);
    
    err = UpdateAllVisibleUsers(brandID);
    if (err != noErr)
        return err;
 
#ifdef SANDBOX
    err = CheckLogoutRequirement(&finalInstallAction);
    
    if (finalInstallAction == launchWhenDone) {
        // Wait for BOINC's RPC socket address to become available to user boinc_master, in
        // case we are upgrading from a version which did not run as user boinc_master.
        saved_uid = getuid();
        saved_euid = geteuid();
        
        pw = getpwnam("boinc_master");
        b_m_uid = pw->pw_uid;
        seteuid(b_m_uid);
        
        for (i=0; i<120; i++) {
            err = TestRPCBind();
            if (err == noErr)
                break;
            
            sleep(1);
        }
        
        seteuid(saved_euid);

        ProcessSerialNumber ourPSN;
        ProcessInfoRec      pInfo;
        FSRef               ourFSRef, theFSRef;
        char                thePath[MAXPATHLEN];
        
        // Get the full path to this PostInstall application's bundle
        err = GetCurrentProcess (&ourPSN);
        if (err)
            return -1000;          // Should never happen
        
        memset(&pInfo, 0, sizeof(pInfo));
        pInfo.processInfoLength = sizeof( ProcessInfoRec );
        err = GetProcessInformation(&ourPSN, &pInfo);
        if (err)
            return -1001;          // Should never happen
        
        err = GetProcessBundleLocation(&ourPSN, &ourFSRef);
        if (err)
            return -1002;          // Should never happen

        err = FSRefMakePath (&ourFSRef, (UInt8*)thePath, sizeof(thePath));
        if (err)
            return -1003;          // Should never happen
        
        q = strrchr(thePath, '/');
        if (q == NULL)
            return -1004;          // Should never happen

        *++q = '\0';
        strlcat(thePath, "WaitPermissions.app", sizeof(thePath));
        err = FSPathMakeRef((StringPtr)thePath, &theFSRef, NULL);
        
        // When we first create the boinc_master group and add the current user to the 
        // new group, there is a delay before the new group membership is recognized.  
        // If we launch the BOINC Manager too soon, it will fail with a -1037 permissions 
        // error, so we wait until the current user can access the switcher application.
        // Apparently, in order to get the changed permissions / group membership, we must 
        // launch a new process belonging to the user.  It may also need to be in a new 
        // process group or new session. Neither system() nor popen() works, even after 
        // setting the uid and euid back to the logged in user, but LSOpenFSRef() does.
        // The WaitPermissions application loops until it can access the switcher 
        // application.
        err = LSOpenFSRef(&theFSRef, NULL);

        waitPermissionsStartTime = time(NULL);
        for (i=0; i<15; i++) {     // Show "Please wait..." alert after 15 seconds
            waitPermissionsPID = FindProcessPID("WaitPermissions", 0);
            if (waitPermissionsPID == 0) {
                return 0;
            }
            sleep(1);
        }
        
        CreateStandardAlert(kAlertNoteAlert, CFSTR("Finishing install.  Please wait ..."), CFSTR("This may take a few more minutes."), NULL, &theWin);
        HideDialogItem(theWin, kStdOkItemIndex);
        RemoveDialogItems(theWin, kStdOkItemIndex, 1, false);
        RunStandardAlert(theWin, &myFilterProc, &itemHit);

    }
#endif   // SANDBOX
    
    return 0;
}
Ejemplo n.º 19
0
/*
 * ThreadCtlProc
 */
BOOL CALLBACK ThreadCtlProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD                cmd;
    ThreadCtlInfo       *info;
    LRESULT             index;
    char                buf[200];
    DWORD               threadid;
    ThreadNode          *thread;
    ProcNode            *process;
    DWORD               susp_cnt;
    DWORD               rc;
    char                *action;

    info = (ThreadCtlInfo *)GET_DLGDATA( hwnd );
    switch( msg ) {
    case WM_INITDIALOG:
        info = MemAlloc( sizeof( ThreadCtlInfo ) );
        if( !GetProcessInfo( lparam, &info->procinfo ) ) {
             RCsprintf( buf, STR_CANT_GET_PROC_INFO, info->procid );
             MessageBox( hwnd, buf, AppName, MB_OK | MB_ICONEXCLAMATION );
             SendMessage( hwnd, WM_CLOSE, 0, 0 );
        }
        info->procid = lparam;
        ThreadDlg = hwnd;
        SET_DLGDATA( hwnd, info );
        fillThreadCtl( hwnd, &info->procinfo, buf );
        RCsprintf( buf, STR_THREAD_4_PROC_X, lparam );
        SetDlgItemText( hwnd, THREAD_PROC_NAME, buf );
        sprintf( buf, "(%s)", info->procinfo.name );
        SetDlgItemText( hwnd, THREAD_PROC_PATH, buf );
        SendDlgItemMessage( hwnd, THREAD_LIST, LB_SETCURSEL, 0, 0L );
        index = SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETCURSEL, 0, 0L );
        if( index != LB_ERR ) {
            enableChoices( hwnd, TRUE );
        }
        fillThreadInfo( hwnd, &info->procinfo );
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        if( cmd == THREAD_SUSPEND || cmd == THREAD_RESUME ||
            cmd == THREAD_KILL || cmd == THREAD_SET_PRIORITY ) {
            index = SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETCURSEL, 0, 0L );
            if( index == LB_ERR ) {
                RCMessageBox( hwnd, STR_NO_SELECTED_THREAD, AppName, MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETTEXT, (WPARAM)index, (LPARAM)(LPSTR)buf );
            threadid = getThreadId( buf );
            process = FindProcess( info->procinfo.pid );
            thread = FindThread( process, threadid );
        }
        switch( cmd ) {
        case IDOK:
            SendMessage( hwnd, WM_CLOSE, 0, 0L );
            break;
        case THREAD_REFRESH:
            RefreshInfo();
            if( GetProcessInfo( info->procid, &info->procinfo ) ) {
                fillThreadCtl( hwnd, &info->procinfo, buf );
                fillThreadInfo( hwnd, &info->procinfo );
            } else {
                action = AllocRCString( STR_REFRESH );
                RCMessageBox( hwnd, STR_CANT_REFRESH_THRD, action,
                              MB_OK | MB_ICONEXCLAMATION );
                FreeRCString( action );
            }
            break;
        case THREAD_SUSPEND:
            action = AllocRCString( STR_THREAD_SUSPEND );
            if( thread == NULL ) {
                RCsprintf( buf, STR_CANT_GET_HDL_4_THD_X, threadid );
                MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION );
            } else {
                susp_cnt = SuspendThread( thread->threadhdl );
                if( susp_cnt == -1 ) {
                    RCsprintf( buf, STR_CANT_SUSPEND_THRD_X, threadid );
                    MessageBox( hwnd, buf, action, MB_ICONQUESTION | MB_OK );
                } else if( susp_cnt > 0 ) {
                    RCsprintf( buf, STR_THREAD_ALREADY_SUSP, threadid, susp_cnt );
                    index = MessageBox( hwnd, buf, action, MB_ICONQUESTION | MB_YESNO );
                    if( index == IDNO ) {
                        ResumeThread( thread->threadhdl );
                    }
                }
                SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L );
            }
            FreeRCString( action );
            break;
        case THREAD_RESUME:
            action = AllocRCString( STR_RESUME );
            if( thread == NULL ) {
                RCsprintf( buf, STR_THREAD_NOT_RESUMED , threadid );
                MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION );
            } else {
                susp_cnt = ResumeThread( thread->threadhdl );
                if( susp_cnt == -1 ) {
                    RCsprintf( buf, STR_CANT_RESUME_THRD_X, threadid );
                    MessageBox( hwnd, buf, action,
                                MB_ICONEXCLAMATION | MB_OK );
                } else if( susp_cnt == 0 ) {
                    RCsprintf( buf, STR_THRD_IS_NOT_SUSP, threadid );
                    MessageBox( hwnd, buf, action,
                                MB_ICONEXCLAMATION | MB_OK );
                } else if( susp_cnt > 1 ) {
                    RCsprintf( buf, STR_SUSP_COUNT_DECREMENTED,
                                threadid, susp_cnt );
                    MessageBox( hwnd, buf, action,
                                MB_ICONEXCLAMATION | MB_OK );
                }
                SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L );
            }
            FreeRCString( action );
            break;
        case THREAD_KILL:
            action = AllocRCString( STR_KILL );
            if( thread == NULL ) {
                RCsprintf( buf, STR_THRD_NOT_TERMINATED, threadid );
                MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION );
            } else if( GetRetCode( hwnd, RETCD_THREAD, thread->threadid, &rc ) ) {
                if( !TerminateThread( thread->threadhdl, rc ) ) {
                    RCsprintf( buf, STR_CANT_KILL_THRD_X, threadid );
                    MessageBox( hwnd, buf, action,
                                MB_OK | MB_ICONEXCLAMATION );
                }
                SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L );
            }
            FreeRCString( action );
            break;
        case THREAD_SET_PRIORITY:
//          {
//              ThreadPriorityInfo      prinfo;
//
//              if( thread == NULL ) {
//                  sprintf( buf, "Unable to get a handle for thread %08X.\n",
//                           threadid );
//                  MessageBox( hwnd, buf, "Set Priority",
//                              MB_OK | MB_ICONEXCLAMATION );
//              } else {
//                  prinfo.procid = info->procid;
//                  prinfo.thread = thread;
//                  prinfo.priority = GetThreadPriority( thread->threadhdl );
//                  prinfo.procinfo = &info->procinfo;
//                  DialogBoxParam( Instance, "THREAD_PRIORITY_DLG", hwnd,
//                                  ThreadPriorityDlgProc, (DWORD)&prinfo );
//                  fillThreadInfo( hwnd, &info->procinfo );
//              }
//          }
//          break;
        case THREAD_LIST:
            if( HIWORD( wparam ) == LBN_SELCHANGE ) {
                fillThreadInfo( hwnd, &info->procinfo );
            }
            break;
        }
        break;
    case DR_TASK_LIST_CHANGE:
        /* make sure this process still exists */
//here  if( FindProcess( info->procid ) == NULL ) {
//here      SendDlgItemMessage( hwnd, THREAD_LIST, LB_RESETCONTENT, 0, 0L );
//here      enableChoices( hwnd, FALSE );
//here      info->proc = NULL;
//here  } else {
//here      fillThreadCtl( hwnd, info->proc, buf );
//here  }
        break;
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        break;
    case WM_DESTROY:
        MemFree( info );
        ThreadDlg = NULL;
        break;
    default:
        return( FALSE );
    }
    return( TRUE );
}
Ejemplo n.º 20
0
//===============================================================================================
//===== Функция IO Control
//===============================================================================================
NTSTATUS IoCtlMyDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
{
	MegaDriverData *pdata;
	NTSTATUS status = STATUS_SUCCESS;
	ULONG BytesCount =0; // Число переданных/полученных байт (пока 0)	
	PIO_STACK_LOCATION IrpStack=IoGetCurrentIrpStackLocation(Irp);
	UCHAR *buff;//for byte

	// Получаем указатель на расширение устройства
	PEXAMPLE_DEVICE_EXTENSION dx = (PEXAMPLE_DEVICE_EXTENSION)DeviceObject->DeviceExtension;

	// Выделяем из IRP значение IOCTL кода (причина вызова)
	ULONG ControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
	//лог
	DbgPrint(" >MegaDriver: IoCtlDriver - we are in");

	//--------------------------------------------------------------------------------------------------------------
	switch(ControlCode)
	{
		//тут нам прислали структурку с двумя строкаме
	case IOCTL_SEND_DATA_STRUCT:
		BytesCount = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
		if(DataSize == BytesCount) 
		{
			//===================================================================================================
			//===== Получаем параметры
			//===================================================================================================
			DbgPrint(" >MegaDriver: IoCtlDriver -> Check BufferIn Size - [ok]");

			//проверяем параметр
			if(((MegaDriverData*)Irp->AssociatedIrp.SystemBuffer)->procToFind == NULL)
			{
				DbgPrint(" >MegaDriver: IoCtlDriver -> Input Params == NULL");
				break;//сваливаем нахер, ибо иначе может быть бсод...
			}
			//copy data
			strcpy(gData.procToFind, ((MegaDriverData*)Irp->AssociatedIrp.SystemBuffer)->procToFind);
			strcpy(gData.procToOpen, ((MegaDriverData*)Irp->AssociatedIrp.SystemBuffer)->procToOpen);
			//show what we have
			DbgPrint(" >MegaDriver: IoCtlDriver -> Input Params:");
			DbgPrint(" >MegaDriver: IoCtlDriver -> procToFind %s", gData.procToFind);
			DbgPrint(" >MegaDriver: IoCtlDriver -> procToOpen %s", gData.procToOpen);
			//if not BSOD =)
			gInited = TRUE;
			//Шикарно... тут мы приняли параметрЫ !!!

			//создаем нотифаер на создание нового процесса в системе
			PsSetCreateProcessNotifyRoutine(NotifyRoutine, FALSE);

			//===================================================================================================
			//===== Чонить отсылаем обратно
			//===================================================================================================
			pdata = (MegaDriverData*)Irp->AssociatedIrp.SystemBuffer;
			strcpy(gData.status, "all data accepted");//нипашет пока 
			strcpy(pdata->procToFind, "11111111111");
			strcpy(pdata->procToOpen, "22222222222");
			if(FindProcess(FindBuffer))
			{
				DbgPrint(" >MegaDriver: +++ PROCESS FOUND +++");
				strcpy(pdata->status, "found");
			}
			else
			{
				strcpy(pdata->status, "not found");
			}
			Irp->IoStatus.Information = sizeof(gData);

			DbgPrint(" >MegaDriver: IoCtlDriver -> Status: %s", pdata->status);


			//осталось всеголишь найти нужный процесс)))


			//IoRequestDpc( //create DPC
			//IoInitializeDpcRequest
			//KeInsertQueueDpc
			//PsCreateSystemThread//IRQL_PASSIVE_LEVEL
			//WriteToFile("First test string from IoCtl \r\n");
			//---------



		}
		else DbgPrint(" >MegaDriver: IoCtlDriver -> Check BufferIn Size - [failed]");
		break;
	case IOCTL_JUST_CHECK_STATUS:
		pdata = (MegaDriverData*)Irp->AssociatedIrp.SystemBuffer;
		strcpy(gData.status, "all data accepted");//нипашет пока 
		strcpy(pdata->procToFind, "11111111111");
		strcpy(pdata->procToOpen, "22222222222");
		if(FindProcess(FindBuffer))
		{
			DbgPrint(" >MegaDriver: +++ PROCESS FOUND +++");
			strcpy(pdata->status, "found");
		}
		else
		{
			strcpy(pdata->status, "not found");
		}
		Irp->IoStatus.Information = sizeof(gData);

		DbgPrint(" >MegaDriver: IoCtlDriver -> Status: %s", pdata->status);
		break;
	default:
		DbgPrint(" >MegaDriver: IoCtlDriver -> UnKnown ControlCode");
	}
	//--------------------------------------------------------------------------------------------------------------



	IoCompleteRequest(Irp, IO_NO_INCREMENT);//завершаем обработку запроса

	return STATUS_SUCCESS;
}