コード例 #1
0
ファイル: twowaypipe.cpp プロジェクト: Afshintm/coreclr
// Disconnect server or client side of the pipe.
// true - success, false - failure (use GetLastError() for more details)
bool TwoWayPipe::Disconnect()
{
    if (m_state == ServerConnected)
    {
        DisconnectNamedPipe(m_outboundPipe);
        DisconnectNamedPipe(m_inboundPipe);
        CloseHandle(m_outboundPipe);
        m_outboundPipe = INVALID_HANDLE_VALUE;
        CloseHandle(m_inboundPipe);
        m_inboundPipe = INVALID_HANDLE_VALUE;
        m_state = NotInitialized;
        return true;
    }
    else if (m_state == ClientConnected)
    {
        CloseHandle(m_outboundPipe);
        m_outboundPipe = INVALID_HANDLE_VALUE;
        CloseHandle(m_inboundPipe);
        m_inboundPipe = INVALID_HANDLE_VALUE;
        m_state = NotInitialized;
        return true;
    } 
    else 
    {
        // nothign to do
        return true;
    }
}
コード例 #2
0
ファイル: win32_support.c プロジェクト: Distrotech/mpg123
/* function should be able to tell if bytes are
   available and return immediately on overlapped
   asynchrounous pipes, like unix select() */
DWORD win32_fifo_read_peek(struct timeval *tv)
{
	DWORD ret = 0;
	DWORD err, timer;

	timer = (tv) ? tv -> tv_sec * 1000 : INFINITE;

	debug1("Peeking on pipe handle %p", fifohandle);

	SetLastError(0);
	if(!fifohandle) return 0;
		PeekNamedPipe(fifohandle, NULL, 0, NULL, &ret, NULL);
	err =  GetLastError();
	debug1("Waiting %ld msec for pipe to be ready", timer);
	debug1("GetLastError was %ld", err);
	if(err == ERROR_BROKEN_PIPE)
	{
		debug("Broken pipe, disconnecting");
		DisconnectNamedPipe(fifohandle);
		ConnectNamedPipe(fifohandle,&ov1);
		WaitForSingleObjectEx(fifohandle,timer,TRUE);
	}
	else if(err == ERROR_BAD_PIPE)
	{
		debug("Bad pipe, Waiting for connect");
		DisconnectNamedPipe(fifohandle);
		ConnectNamedPipe(fifohandle,&ov1);
		WaitForSingleObjectEx(fifohandle,timer,TRUE);
	}
	debug2("peek %ld bytes, error %ld",ret, err);
	return ret;
}
コード例 #3
0
ファイル: fifo_server.cpp プロジェクト: VladutZzZ/Labs
int main() {
	HANDLE f1, f2;
	char s[128];
	DWORD x;
	
	printf("I am the server \n");

	// creating pipes
	f1=CreateNamedPipe(TEXT("\\\\.\\PIPE\\fifo1"), PIPE_ACCESS_INBOUND,PIPE_TYPE_BYTE|PIPE_WAIT, 3, 0, 0, 0, NULL);
	f2=CreateNamedPipe(TEXT("\\\\.\\PIPE\\fifo2"), PIPE_ACCESS_OUTBOUND,PIPE_TYPE_BYTE|PIPE_WAIT, 3, 0, 0, 0, NULL);
	ConnectNamedPipe(f1, NULL);
	ConnectNamedPipe(f2, NULL);
	
	// reading from pipe
	x = 0;
	if (ReadFile(f1, s, sizeof(s), &x, NULL)==0) {
		printf("reading error.. %d\n", x);
	}
	printf("read from pipe: %s\n", s);

	// writing to pipe
	strcpy(s, "Howdy!\n");
	if (WriteFile(f2, s, strlen(s)+1, &x, NULL)==0) {
		printf("writing error..%d\n", x);
	}
	
	// close pipes
	DisconnectNamedPipe(f1);
	DisconnectNamedPipe(f2);
	CloseHandle(f1);
	CloseHandle(f2);

}
コード例 #4
0
ファイル: pplpipe.c プロジェクト: gozfree/src
PPL_DECLARE (int) ppl_pipe_close (ppl_pipe_t * apipe)
{
  if (apipe == NULL)
    return -1;
  DisconnectNamedPipe (apipe->pipes[0]);
  DisconnectNamedPipe (apipe->pipes[1]);
  CloseHandle(apipe->pipes[0]);
  CloseHandle(apipe->pipes[1]);
  osip_free (apipe);
  return 0;
}
コード例 #5
0
ファイル: Watcher.cpp プロジェクト: Avalonxy/malware-1
void __stdcall Watcher::pipeThread(Watcher *w)
{
	for (;;) {
		HANDLE pipe = w->pipe;
		WORD rv, myv = Base::instance()->getNVersion();
		DWORD rd;
		WORD cmd;
		if (!ConnectNamedPipe(pipe, NULL)) {
			Sleep(1000);
			continue;
		}

		ReadFile(pipe, &cmd, sizeof(cmd), &rd, NULL);
		WriteFile(pipe, &myv, sizeof(myv), &rd, NULL);
		if (!cmd) {
			ReadFile(pipe, &rv, sizeof(rv), &rd, NULL);
			if (HIBYTE(rv) > HIBYTE(myv) || (HIBYTE(rv) == HIBYTE(myv) && LOBYTE(rv) > LOBYTE(myv))) {
				w->terminate();
				return;
			}
		} else {
			char file[MAX_PATH + 1];
			ReadFile(pipe, file, sizeof(file), &rd, NULL);
			file[MAX_PATH] = 0;
			log(LL_DIAG, L_NEW L_DEL L_COMMAND "%s", file);
			Sleep(6000);
			Base::instance()->forceDeleteFile(std::string(file));
		}
		
		DisconnectNamedPipe(pipe);
	}
}
コード例 #6
0
ファイル: Channel.cpp プロジェクト: feifeigd/decoda
void Channel::Destroy()
{
    if (m_creator)
    {
        FlushFileBuffers(m_pipe);
        DisconnectNamedPipe(m_pipe);
        m_creator = false;
    }

    if (m_doneEvent != INVALID_HANDLE_VALUE)
    {
        
        // Signal the done event so that if we're currently blocked reading,
        // we'll stop.

        SetEvent(m_doneEvent);

        CloseHandle(m_doneEvent);
        m_doneEvent = INVALID_HANDLE_VALUE;

    }

    if (m_readEvent != INVALID_HANDLE_VALUE)
    {
        CloseHandle(m_readEvent);
        m_readEvent = INVALID_HANDLE_VALUE;
    }

    if (m_pipe != INVALID_HANDLE_VALUE)
    {
        CloseHandle(m_pipe);
        m_pipe = INVALID_HANDLE_VALUE;
    }

}
コード例 #7
0
void QLocalSocketPrivate::destroyPipeHandles()
{
    if (handle != INVALID_HANDLE_VALUE) {
        DisconnectNamedPipe(handle);
        CloseHandle(handle);
    }
}
コード例 #8
0
ファイル: winptty.c プロジェクト: Archlogic/libretro-mame
file_error win_close_ptty(osd_file *file)
{
	FlushFileBuffers(file->handle);
	DisconnectNamedPipe(file->handle);
	CloseHandle(file->handle);
	return FILERR_NONE;
}
コード例 #9
0
ファイル: VmIPC.cpp プロジェクト: Nukem9/VMWareClient
DWORD WINAPI PipeThreadMonitor(LPVOID Arg)
{
	IPCPacket packet;

	for (;;)
	{
		// Wait for the client to connect
		if (!ConnectNamedPipe(g_Pipe, nullptr))
		{
			printf("An error occurred while waiting for a client connection\n");
			return 1;
		}

		for (bool runloop = true; runloop;)
		{
			// Wait for a client message to be sent
			if (!ReadFromPipe(&packet))
			{
				printf("Failed to read from client connection\n");
				
				runloop = false;
				break;
			}

			// Handle the message here
			switch (packet.MessageType)
			{
			case VM_CLIENT_READMEM_CMD:
				VmHandleReadMem(&packet);
				break;

			case VM_CLIENT_WRITEMEM_CMD:
				VmHandleWriteMem(&packet);
				break;

			case VM_CLIENT_SHUTDOWN_CMD:
				printf("GOT A SHUTDOWN MESSAGE TYPE\n");

				// Exit the loop
				runloop = false;
				break;

			default:
				printf("GOT AN UNKNOWN MESSAGE TYPE\n");

				packet.Status = 0;
				break;
			}

			// Send the resulting packet
			if (!WriteToPipe(&packet))
				return 1;
		}

		// Disconnect the client
		DisconnectNamedPipe(g_Pipe);
	}

	return 0;
}
コード例 #10
0
ファイル: ChildProcess.cpp プロジェクト: saluber/UIforETW
DWORD ChildProcess::ListenerThread()
{
	// wait for someone to connect to the pipe
	if (ConnectNamedPipe(hPipe_, NULL) || GetLastError() == ERROR_PIPE_CONNECTED)
	{
		// Acquire the lock while writing to processOutput_
		char buffer[1024];
		DWORD dwRead;
		while (ReadFile(hPipe_, buffer, sizeof(buffer) - 1, &dwRead, NULL) != FALSE)
		{
			if (dwRead > 0)
			{
				CSingleLock locker(&outputLock_);
				buffer[dwRead] = 0;
				OutputDebugStringA(buffer);
				processOutput_ += AnsiToUnicode(buffer);
			}
			SetEvent(hOutputAvailable_);
		}
	}
	else
	{
		OutputDebugString(L"Connect failed.\n");
	}

	DisconnectNamedPipe(hPipe_);

	return 0;
}
コード例 #11
0
ファイル: efl_net_socket_windows.c プロジェクト: tasn/efl
static void
_efl_net_socket_windows_handle_close(HANDLE h)
{
   if (!FlushFileBuffers(h))
     {
        DWORD win32err = GetLastError();
        if (win32err != ERROR_PIPE_NOT_CONNECTED)
          {
             char *msg = _efl_net_windows_error_msg_get(GetLastError());
             WRN("HANDLE=%p could not flush buffers: %s", h, msg);
             free(msg);
          }
     }
   if (!DisconnectNamedPipe(h))
     {
        DWORD win32err = GetLastError();
        if ((win32err != ERROR_NOT_SUPPORTED) && /* dialer socket don't support it */
            (win32err != ERROR_PIPE_NOT_CONNECTED))
          {
             char *msg = _efl_net_windows_error_msg_get(win32err);
             WRN("HANDLE=%p could not disconnect: %s", h, msg);
             free(msg);
          }
     }
   CloseHandle(h);
   DBG("HANDLE=%p closed", h);
}
コード例 #12
0
ファイル: fastcgi.c プロジェクト: hsomesun/dezend
static inline void fcgi_close(fcgi_request *req, int force, int destroy)
{
    if (destroy) {
        zend_hash_destroy(&req->env);
    }

#ifdef _WIN32
    if (is_impersonate) {
        RevertToSelf();
    }
#endif

    if ((force || !req->keep) && req->fd >= 0) {
#ifdef _WIN32
        HANDLE pipe = (HANDLE)_get_osfhandle(req->fd);

        if (!force) {
            FlushFileBuffers(pipe);
        }
        DisconnectNamedPipe(pipe);
#else
        if (!force) {
            char buf[8];

            shutdown(req->fd, 1);
            while (recv(req->fd, buf, sizeof(buf), 0) > 0) {}
        }
        close(req->fd);
#endif
        req->fd = -1;
    }
}
コード例 #13
0
ファイル: PipeBase.cpp プロジェクト: MakotoTaniguchi/ProxyCmd
void CPipeBase::ClosePipe()
{
    if (m_hPipeClient != INVALID_HANDLE_VALUE)
    {
		DisconnectNamedPipe( m_hPipeClient );
        CloseHandle(m_hPipeClient);
        m_hPipeClient = INVALID_HANDLE_VALUE;
    }

	if (m_hPipeServer != INVALID_HANDLE_VALUE)
    {
		DisconnectNamedPipe( m_hPipeServer );
        CloseHandle(m_hPipeServer);
        m_hPipeServer = INVALID_HANDLE_VALUE;
    }
}
コード例 #14
0
bool MWinNamedPipeServer::Connect(void)
	{
	if(mClientConnected==true)
		{
		DisconnectNamedPipe(mhPipe);
		}

	if(ConnectNamedPipe(mhPipe,NULL)==FALSE)
		{
		// It is possible that a client connects before the ConnectNamedPipe is invoked after CreateNamed Pipe.
		// Connections is still good! 
		//  Ref: https://msdn.microsoft.com/query/dev15.query?appId=Dev15IDEF1&l=EN-US&k=k(NAMEDPIPEAPI%2FConnectNamedPipe);k(ConnectNamedPipe);k(DevLang-C%2B%2B);k(TargetOS-Windows)&rd=true
		DWORD error=GetLastError();
		if(error==ERROR_PIPE_CONNECTED)
			{
			mClientConnected=true;
			return true;
			}

		mClientConnected=false;
		return false;
		}

	mClientConnected=true;
	return true;
	}
コード例 #15
0
ファイル: rpc_transport.c プロジェクト: WASSUM/longene_travel
static RPC_STATUS rpcrt4_conn_listen_pipe(RpcConnection_np *npc)
{
  if (npc->listening)
    return RPC_S_OK;

  npc->listening = TRUE;
  for (;;)
  {
      if (ConnectNamedPipe(npc->pipe, &npc->ovl))
          return RPC_S_OK;

      switch(GetLastError())
      {
      case ERROR_PIPE_CONNECTED:
          SetEvent(npc->ovl.hEvent);
          return RPC_S_OK;
      case ERROR_IO_PENDING:
          /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */
          return RPC_S_OK;
      case ERROR_NO_DATA_DETECTED:
          /* client has disconnected, retry */
          DisconnectNamedPipe( npc->pipe );
          break;
      default:
          npc->listening = FALSE;
          WARN("Couldn't ConnectNamedPipe (error was %d)\n", GetLastError());
          return RPC_S_OUT_OF_RESOURCES;
      }
  }
}
static void close_client_connection(NVQRConnection c)
{
#if defined (_WIN32)
    DisconnectNamedPipe(c.client_handle);
#else
#endif
}
コード例 #17
0
void NamedPipeConnection::_close()
{
    if( isClosed( ))
        return;

    LBASSERT( _fd > 0 );

    if( isListening( ))
    {
        _exitAIOAccept();

        if( _fd != INVALID_HANDLE_VALUE && !DisconnectNamedPipe( _fd ))
            LBERROR << "Could not disconnect named pipe: " << lunchbox::sysError
                    << std::endl;
    }
    else
    {
        _exitAIORead();
        if( _fd != INVALID_HANDLE_VALUE && !CloseHandle( _fd ))
            LBERROR << "Could not close named pipe: " << lunchbox::sysError
                    << std::endl;
    }

    _fd = INVALID_HANDLE_VALUE;
    _setState( STATE_CLOSED );
}
コード例 #18
0
ファイル: pipedebug.hpp プロジェクト: 1ee7/hosts
	void DisconnectAndClose(LPPIPEINST lpPipeInst){
		if (! DisconnectNamedPipe(lpPipeInst->hPipeInst))
			printf("DisconnectNamedPipe failed with %ld.\n", GetLastError());
		CloseHandle(lpPipeInst->hPipeInst);
		if (lpPipeInst != NULL)
			HeapFree(GetProcessHeap(),0, lpPipeInst);
	}
コード例 #19
0
ファイル: Server.cpp プロジェクト: Andreyko/NamedPipes
    VOID Server::Stop_Helper(VOID)
    {        
        printf("Stop_Helper: Server\n");

        eState_ = STATE::stopping;

        StopMainThread();

        for (DWORD counter = 0; counter < S_PIPES_INSTANCES; counter++ ) 
        {
            DisconnectNamedPipe(Pipe_[counter].hPipeInst);

            CLOSE_HANDLE(Pipe_[counter].hPipeInst);
        }

        for (DWORD counter = 0; counter < S_PIPES_EVENTS; counter++ )
        {
            CLOSE_HANDLE(hPipes_Events_[counter]);
        }

        for (DWORD counter = 0; counter < S_EVENTS_; counter++ )
        {
            CLOSE_HANDLE(hS_Events_[counter]); 
        }

        CLOSE_HANDLE(hServerIsUp_Mutex);

        DeleteCriticalSection(&csReadPipe_);
        for (DWORD counter = 0; counter < S_PIPES_INSTANCES; counter++)
        {        
            DeleteCriticalSection(&Pipe_[counter].csWritePipe);
        }  

        eState_ = STATE::stopped;
    }
コード例 #20
0
ファイル: pipe.cpp プロジェクト: gatgui/gcore
void gcore::Pipe::close() {
  if (isNamed() && isOwned()) {
#ifndef _WIN32
    gcore::String path = "/tmp/" + mName;
    closeRead();
    closeWrite();
    unlink(path.c_str());
#else
    if (mConnected) {
      FlushFileBuffers(mDesc[1]);
      DisconnectNamedPipe(mDesc[0]);
    }
    closeRead();
    closeWrite();
#endif
  } else {
    closeRead();
    closeWrite();
  }
  mName = "";
  mOwn = false;
#ifdef _WIN32
  mConnected = false;
#endif
}
コード例 #21
0
void ExtCommandsHandler::run()
{
    while (1) {
        QStringList args;
        if (!readRequest(&args)) {
            qWarning ("failed to read request from shell extension: %s",
                      formatErrorMessage().c_str());
            break;
        }

        QString cmd = args.takeAt(0);
        QString resp;
        if (cmd == "list-repos") {
            resp = handleListRepos(args);
        } else if (cmd == "get-share-link") {
            handleGenShareLink(args);
        } else if (cmd == "get-file-status") {
            resp = handleGetFileStatus(args);
        } else {
            qWarning ("[ext] unknown request command: %s", cmd.toUtf8().data());
        }

        if (!sendResponse(resp)) {
            qWarning ("failed to write response to shell extension: %s",
                      formatErrorMessage().c_str());
            break;
        }
    }

    qWarning ("An extension client is disconnected: GLE=%lu\n",
              GetLastError());
    DisconnectNamedPipe(pipe_);
    CloseHandle(pipe_);
}
コード例 #22
0
ファイル: spk.c プロジェクト: Kartofelna/brltty
static void
exitSpeechInput (void *data) {
  if (speechInputPath) {
#if defined(__MINGW32__)
#elif defined(S_ISFIFO)
    unlink(speechInputPath);
#endif /* cleanup speech input */

    free(speechInputPath);
    speechInputPath = NULL;
  }

#if defined(__MINGW32__)
  if (speechInputHandle != INVALID_HANDLE_VALUE) {
    if (speechInputConnected) {
      DisconnectNamedPipe(speechInputHandle);
      speechInputConnected = 0;
    }

    CloseHandle(speechInputHandle);
    speechInputHandle = INVALID_HANDLE_VALUE;
  }
#elif defined(S_ISFIFO)
  if (speechInputDescriptor != -1) {
    close(speechInputDescriptor);
    speechInputDescriptor = -1;
  }
#endif /* disable speech input */
}
コード例 #23
0
ファイル: os_win32.c プロジェクト: BlueBrain/FastCGI
/*
 *--------------------------------------------------------------
 *
 * OS_LibShutdown --
 *
 *	Shutdown the OS library.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Memory freed, handles closed.
 *
 *--------------------------------------------------------------
 */
void OS_LibShutdown()
{

    if (hIoCompPort != INVALID_HANDLE_VALUE) 
    {
        CloseHandle(hIoCompPort);
        hIoCompPort = INVALID_HANDLE_VALUE;
    }

    if (hStdinCompPort != INVALID_HANDLE_VALUE) 
    {
        CloseHandle(hStdinCompPort);
        hStdinCompPort = INVALID_HANDLE_VALUE;
    }

    if (acceptMutex != INVALID_HANDLE_VALUE) 
    {
        ReleaseMutex(acceptMutex);
    }

    DisconnectNamedPipe(hListen);

    CancelIo(hListen);


    WSACleanup();
}
コード例 #24
0
ファイル: spk.c プロジェクト: Kartofelna/brltty
void
processSpeechInput (SpeechSynthesizer *spk) {
#if defined(__MINGW32__)
  if (speechInputHandle != INVALID_HANDLE_VALUE) {
    if (speechInputConnected ||
        (speechInputConnected = ConnectNamedPipe(speechInputHandle, NULL)) ||
        (speechInputConnected = (GetLastError() == ERROR_PIPE_CONNECTED))) {
      char buffer[0X1000];
      DWORD count;

      if (ReadFile(speechInputHandle, buffer, sizeof(buffer), &count, NULL)) {
        if (count) sayCharacters(spk, buffer, count, 0);
      } else {
        DWORD error = GetLastError();

        if (error != ERROR_NO_DATA) {
          speechInputConnected = 0;
          DisconnectNamedPipe(speechInputHandle);

          if (error != ERROR_BROKEN_PIPE)
            logWindowsSystemError("speech input FIFO read");
        }
      }
    }
  }
#elif defined(S_ISFIFO)
  if (speechInputDescriptor != -1) {
    char buffer[0X1000];
    int count = read(speechInputDescriptor, buffer, sizeof(buffer));
    if (count > 0) sayCharacters(spk, buffer, count, 0);
  }
#endif /* process speech input */
}
コード例 #25
0
ファイル: Filter.Pipe.cpp プロジェクト: slavanap/ssifSource
		AVSValue __cdecl DestroyPipe(AVSValue args, void* user_data, IScriptEnvironment* env) {
			HANDLE hPipe = (HANDLE)args[0].AsInt();
			DisconnectNamedPipe(hPipe);
			FlushFileBuffers(hPipe);
			CloseHandle(hPipe);
			return AVSValue();
		}
コード例 #26
0
void QLocalSocket::close()
{
    Q_D(QLocalSocket);
    if (state() == UnconnectedState)
        return;

    QIODevice::close();
    d->state = ClosingState;
    emit stateChanged(d->state);
    if (!d->pipeClosed)
        emit readChannelFinished();
    d->serverName = QString();
    d->fullServerName = QString();

    if (state() != UnconnectedState && bytesToWrite() > 0) {
        disconnectFromServer();
        return;
    }
    d->readSequenceStarted = false;
    d->pendingReadyRead = false;
    d->pipeClosed = false;
    DisconnectNamedPipe(d->handle);
    CloseHandle(d->handle);
    d->handle = INVALID_HANDLE_VALUE;
    ResetEvent(d->overlapped.hEvent);
    d->state = UnconnectedState;
    emit stateChanged(d->state);
    emit disconnected();
    if (d->pipeWriter) {
        delete d->pipeWriter;
        d->pipeWriter = 0;
    }
}
コード例 #27
0
WinConnection::~WinConnection()
{
    if (!DisconnectNamedPipe(_pipe)) {
        DBG(0, "DisconnectNamedPipe failed %d", GetLastError());
    }
    CloseHandle(_pipe);
}
コード例 #28
0
ファイル: npserver.c プロジェクト: GYGit/reactos
VOID InstanceThread (LPVOID lpvParam)
{
   CHAR chRequest[BUFSIZE];
   CHAR chReply[BUFSIZE];
   DWORD cbBytesRead, cbReplyBytes, cbWritten;
   BOOL fSuccess;
   HANDLE hPipe;

   hPipe = (HANDLE)lpvParam;
   while (1)
     {
	fSuccess = ReadFile(hPipe,
			    chRequest,
			    BUFSIZE,
			    &cbBytesRead,
			    NULL);
	if (!fSuccess || cbBytesRead == 0)
	  break;

	GetAnswerToRequest(chRequest, chReply, &cbReplyBytes);

	fSuccess = WriteFile(hPipe,
			     chReply,
			     cbReplyBytes,
			     &cbWritten,
			     NULL);
	if (!fSuccess || cbReplyBytes != cbWritten)
	  break;
    }

   FlushFileBuffers(hPipe);
   DisconnectNamedPipe(hPipe);
   CloseHandle(hPipe);
}
コード例 #29
0
ファイル: signal.c プロジェクト: Epictetus/postgres
/* Signal dispatching thread */
static DWORD WINAPI
pg_signal_dispatch_thread(LPVOID param)
{
	HANDLE		pipe = (HANDLE) param;
	BYTE		sigNum;
	DWORD		bytes;

	if (!ReadFile(pipe, &sigNum, 1, &bytes, NULL))
	{
		/* Client died before sending */
		CloseHandle(pipe);
		return 0;
	}
	if (bytes != 1)
	{
		/* Received <bytes> bytes over signal pipe (should be 1) */
		CloseHandle(pipe);
		return 0;
	}
	WriteFile(pipe, &sigNum, 1, &bytes, NULL);	/* Don't care if it works or
												 * not.. */
	FlushFileBuffers(pipe);
	DisconnectNamedPipe(pipe);
	CloseHandle(pipe);

	pg_queue_signal(sigNum);
	return 0;
}
コード例 #30
0
ファイル: Watcher.cpp プロジェクト: Avalonxy/malware-1
bool Watcher::install()
{
	//return(true);


	DWORD rd;
	char msg[MAX_PATH + 2];
	std::string current;

	Base *b = Base::instance();
	if (b->isInstalled())
		return(true);
	if (!b->install())
		return(false);

	DisconnectNamedPipe(pipe);
	CloseHandle(pipe);
	pipe = NULL;

	*(WORD *)msg = 1;
	b->getCurrentPath(current);
	strcpy(msg + 2, current.c_str());
	Sleep(10000);
	//MessageBoxA(NULL, msg + 2, "send dcmd", MB_OK);
	WaitNamedPipe(pipename.c_str(), 10000);
	CallNamedPipe(pipename.c_str(), msg, sizeof(msg), NULL, 0, &rd, 0);
	terminate();
	return(true);
}