Beispiel #1
0
void IFSEXPORT
FS_EXIT(
   unsigned short uid,
   unsigned short pid,
   unsigned short pdb
   )
{
   if (pidDaemon && (pid == pidDaemon))
      daemonStopped();
}
QmlBackend::QmlBackend(ControlClient *controlClient, QObject *parent) :
    QObject(parent), _controlClient(controlClient), _daemonActive(false), _daemonRunning(false)
{
    connect(_controlClient, SIGNAL(activeChanged(bool)), this, SLOT(daemonActiveChanged(bool)));
    connect(_controlClient, SIGNAL(started()), this, SLOT(daemonStarted()));
    connect(_controlClient, SIGNAL(stopped()), this, SLOT(daemonStopped()));
    connect(_controlClient, SIGNAL(matchPhraseChanged(const QString &)), this, SLOT(matchPhraseChanged(const QString &)));

    _initDaemonState();
}
Beispiel #3
0
int IFSEXPORT
FS_FSCTL(
   union argdat far * pArgDat,
   unsigned short iArgType,
   unsigned short usFunc,
   char far * pParm,
   unsigned short cbMaxParm,
   unsigned short far * pcbParm,
   char far * pData,
   unsigned short cbMaxData,
   unsigned short far * pcbData
   )
{
   int rc;
   struct fsctl far * p = &pRequest->data.fsctl;

   /* Validate iArgType. */
   if ((iArgType != FSCTL_ARG_FILEINSTANCE) &&
       (iArgType != FSCTL_ARG_CURDIR) &&
       (iArgType != FSCTL_ARG_NULL))
      return ERROR_NOT_SUPPORTED;

   /* Validate the parameter buffer. */
   if (cbMaxParm) {
      rc = FSH_PROBEBUF(PB_OPREAD, (char far *) pcbParm,
         sizeof(USHORT));
      if (rc) return ERROR_INVALID_PARAMETER;
      if (*pcbParm > cbMaxParm) return ERROR_INVALID_PARAMETER;
      if (*pcbParm) {
         rc = FSH_PROBEBUF(PB_OPREAD, pParm, *pcbParm);
         if (rc) return ERROR_INVALID_PARAMETER;
      }
   }

   switch (usFunc) {

      case FSCTL_STUBFSD_DAEMON_STARTED: /* daemon started */
      
         if (pidDaemon) return ERROR_STUBFSD_DAEMON_RUNNING;

         if (*pcbParm != sizeof(SETXCHGBUFFERS))
            return ERROR_INVALID_PARAMETER;

         return daemonStarted((PSETXCHGBUFFERS) pParm);

      case FSCTL_STUBFSD_DAEMON_STOPPED: /* daemon stopped */
      
         if (!pidDaemon)
            return ERROR_STUBFSD_DAEMON_NOT_RUN;

         if (queryCurrentPid() != pidDaemon)
            return ERROR_STUBFSD_NOT_DAEMON;

         return daemonStopped();

      case FSCTL_STUBFSD_RESET: /* forcibly detach daemon */
      
         return daemonStopped();

      case FSCTL_STUBFSD_GET_REQUEST: /* wait for next request */

         if (queryCurrentPid() != pidDaemon)
            return ERROR_STUBFSD_NOT_DAEMON;

         rc = FSH_SEMWAIT(&semRqAvail, TO_INFINITE);
         if (rc) return rc;
         
         rc = FSH_SEMSET(&semRqAvail);
         if (rc) return rc;

         return NO_ERROR;

      case FSCTL_STUBFSD_DONE_REQUEST: /* signal request done */
      
         if (queryCurrentPid() != pidDaemon)
            return ERROR_STUBFSD_NOT_DAEMON;

         rc = FSH_SEMCLEAR(&semRqDone);
         if (rc) return rc;

         return NO_ERROR;

      default: /* unknown FSCTL, send to daemon */

         if (rc = requestExchangeXS()) return rc;

         pRequest->rq = FSRQ_FSCTL;

         p->iArgType = iArgType;
         p->usFunc = usFunc;
         p->cbParm = cbMaxParm ? *pcbParm : 0;
         p->cbMaxData = cbMaxData;
         p->cbData = 0;

         if (cbMaxParm) memcpy(pFSData, pParm, *pcbParm);

         if (rc = signalDaemonAndWait()) RELEASE_AND_EXIT(rc);

         if (p->cbData) {
            rc = FSH_PROBEBUF(PB_OPWRITE, (char far *) pcbData,
               sizeof(USHORT));
            if (rc) RELEASE_AND_EXIT(ERROR_INVALID_PARAMETER);
            *pcbData = p->cbData;
            if (!pRequest->rc) {
               if (*pcbData > cbMaxData)
                  RELEASE_AND_EXIT(ERROR_INVALID_PARAMETER);
               if (*pcbData) {
                  rc = FSH_PROBEBUF(PB_OPWRITE, pData, *pcbData);
                  if (rc) RELEASE_AND_EXIT(ERROR_INVALID_PARAMETER);
                  memcpy(pData, pFSData, *pcbData);
               }
            }
         }
         
         RELEASE_AND_EXIT(pRequest->rc);
   }

}