예제 #1
0
VOID
CNdasService::ServiceMain(DWORD dwArgc, LPTSTR* lpArgs)
{
	m_bDebugMode = FALSE;

	BOOL fSuccess = this->ximeta::CTask::Initialize();
	if (!fSuccess) {
		// TODO: Return appropriate error code for stopped
		// TODO: Event Log
		ReportStatusToSCMgr(SERVICE_STOPPED, 0, ::GetLastError());
		return;
	}

	fSuccess = this->Run();
	
	if (!fSuccess) {
		// TODO: Return appropriate error code for stopped
		// TODO: Event Log
		ReportStatusToSCMgr(SERVICE_STOPPED, 0, ::GetLastError());
		return;
	}

	DBGPRT_INFO(_FT("NDAS Service is running...\n"));

	ReportStatusToSCMgr(SERVICE_RUNNING);

	return;
}
예제 #2
0
HANDLE
CNdasEventSubscriber::
WaitServer(BOOL& bStopThread)
{
	OVERLAPPED ov = {0};
	ov.hEvent = m_hDataEvent;

	HANDLE hPipe = CreatePipeConnection(&ov);

	if (INVALID_HANDLE_VALUE == hPipe) {
		NDAS_EVENT_INFO ei = {0};
		ei.EventType = NDAS_EVENT_TYPE_CONNECTION_FAILED;
		CallEventProc(::GetLastError(), NULL);
	}

	//
	// Wait for 5 seconds and try again
	//

	while (INVALID_HANDLE_VALUE == hPipe) {
		
		{
			NDAS_EVENT_INFO ei = {0};
			ei.EventType = NDAS_EVENT_TYPE_CONNECTION_FAILED;
			CallEventProc(::GetLastError(), &ei);
		}

		DWORD dwWaitResult = ::WaitForSingleObject(
			m_hThreadStopEvent, 
			5 * 1000);

		if (WAIT_OBJECT_0 == dwWaitResult) {

			bStopThread = TRUE;
			return INVALID_HANDLE_VALUE;

		} else if (WAIT_TIMEOUT == dwWaitResult) {

			{
				NDAS_EVENT_INFO ei = {0};
				ei.EventType = NDAS_EVENT_TYPE_RETRYING_CONNECTION;
				CallEventProc(::GetLastError(), &ei);
			}

			hPipe = CreatePipeConnection(&ov);

		} else {
			DPErrorEx(_FT("Wait failed: \n"));
			return INVALID_HANDLE_VALUE;
		}
	}

	{
		NDAS_EVENT_INFO ei = {0};
		ei.EventType = NDAS_EVENT_TYPE_CONNECTED;
		CallEventProc(0, &ei);
	}

	return hPipe;
}
예제 #3
0
BOOL GetLocalLpxAddressList(
	IN SOCKET s,
	IN DWORD cbBuffer,
	OUT LPSOCKET_ADDRESS_LIST lpBuffer,
	OUT LPDWORD pcbBytesReturned)
{
	_ASSERTE(INVALID_SOCKET != s);
	_ASSERTE(!IsBadWritePtr(lpBuffer, cbBuffer));

	INT iError = WSAIoctl(
		s,
		SIO_ADDRESS_LIST_QUERY,
		NULL, 
		0,
		lpBuffer,
		cbBuffer,
		pcbBytesReturned,
		NULL,
		NULL);

	if (iError != 0) {
		DPErrorEx(_FT("SIO_ADDRESS_LIST_QUERY failed: "));
		return FALSE;
	}

	return TRUE;
}
예제 #4
0
VOID
CNdasLogicalDevice::OnUnmounted()
{
	ximeta::CAutoLock autolock(this);

	DBGPRT_INFO(_FT("%s: Unmount Completed%s.\n"), ToString(),
		m_fDisconnected ? _T(" (by disconnection)") : _T(""));

	SetStatus(NDAS_LOGICALDEVICE_STATUS_UNMOUNTED);

	m_dwMountTick = 0;

	if (!m_fDisconnected)
	{
		// clears the mount flag only on unmount by user's request
		SetLastMountAccess(0); 
	}

	// clears the risky mount flag
	SetRiskyMountFlag(FALSE);

	// Detach from the event monitor
	pGetNdasEventMonitor()->Detach(this);

	// Check the status of parent devices of unit devices
	for (DWORD i = 0; i < m_logicalDeviceGroup.nUnitDevices; ++i)
	{
		CheckUnitDeviceOnUnmount(m_pUnitDevices[i]);
	}
}
예제 #5
0
BOOL
CNdasEventPublisher::SendVersionInfo(HANDLE hPipe, LPOVERLAPPED lpOverlapped)
{
	const DWORD cbMessage = sizeof(NDAS_EVENT_MESSAGE);
	NDAS_EVENT_MESSAGE msgVersion = {0};

	msgVersion.MessageSize = cbMessage;
	msgVersion.EventType = NDAS_EVENT_TYPE_VERSION_INFO;
	msgVersion.VersionInfo.MajorVersion = NDAS_EVENT_VERSION_MAJOR;
	msgVersion.VersionInfo.MinorVersion = NDAS_EVENT_VERSION_MINOR;

	DWORD cbWritten(0);
	
	BOOL fSuccess = ::WriteFile(
		hPipe, 
		&msgVersion,
		cbMessage,
		&cbWritten,
		lpOverlapped);

	if (!fSuccess && ERROR_IO_PENDING != ::GetLastError()) {
		DBGPRT_ERR_EX(_FT("Writing an initial version event failed: "));
		return FALSE;
	}

	return TRUE;
}
예제 #6
0
BOOL
CNdasDeviceComm::GetDiskInfoBlock(PNDAS_DIB pDiskInfoBlock)
{
	_ASSERTE(m_bInitialized && "CNdasDeviceComm is not initialized");
	_ASSERTE(pDiskInfoBlock != NULL);

	//
	// Read Last Sector for NDAS_UNITDISK_INFORMATION_BLOCK
	//
	unsigned _int8 ui8IdeResponse;

	PTARGET_DATA pTargetData = &m_lspath.PerTarget[m_dwUnitNo];
	UINT64 ui64DiskBlock = pTargetData->SectorCount - 1;

	INT iResult = IdeCommand(
		&m_lspath, m_dwUnitNo, 0, 
		WIN_READ, 
		ui64DiskBlock, 1, 0,
		(PCHAR) pDiskInfoBlock, &ui8IdeResponse);

	if (0 != iResult) {
		DPError(_FT("IdeCommand failed with error %d, ide response %d.\n"), iResult, ui8IdeResponse);
		return FALSE;
	}

	return TRUE;
}
예제 #7
0
BOOL
CNdasDevice::UpdateDeviceInfo()
{
	ximeta::CAutoLock autolock(this);

	if (NDAS_DEVICE_STATUS_CONNECTED != m_status) {
		return FALSE;
	}

	BOOL fSuccess = GetDeviceInfo(
		m_localLpxAddress, 
		m_remoteLpxAddress, 
		GetHWType(), 
		GetHWVersion());

	if (!fSuccess) 
	{
		BOOL fDisconnectable = DestroyAllUnitDevices();
		if (fDisconnectable)
		{
			DBGPRT_INFO(_FT("%s: Changing to DISCONNECTED.\n"), ToString());
			ChangeStatus(NDAS_DEVICE_STATUS_DISCONNECTED);
		} 
		else 
		{
			DBGPRT_INFO(_T("%s: Some unit devices are mounted!\n"), ToString());
		}

		return FALSE;
	}

	return TRUE;
}
예제 #8
0
BOOL
CNdasAutoRegister::ProcessRegister(
	CONST NDAS_DEVICE_ID& deviceId, 
	ACCESS_MASK autoRegAccess)
{
	CNdasDeviceRegistrar* pRegistrar = pGetNdasDeviceRegistrar();
	CRefObjPtr<CNdasDevice> pExistingDevice = pRegistrar->Find(deviceId);
	if (NULL != pExistingDevice.p) {
		return TRUE;
	}

	CRefObjPtr<CNdasDevice> pDevice = pRegistrar->Register(deviceId, TRUE, TRUE);
	if (NULL == pDevice.p) {
		return FALSE;
	}

	pDevice->SetGrantedAccess(autoRegAccess);

	BOOL fSuccess = pDevice->Enable(TRUE);
	if (!fSuccess) {
		DBGPRT_ERR(_FT("Enable failed: "));
	}

	TCHAR szName[MAX_NDAS_DEVICE_NAME_LEN + 1];
	HRESULT hr = ::StringCchPrintf(szName, MAX_NDAS_DEVICE_NAME_LEN + 1,
		_T("NDAS Device A%04d"), pDevice->GetSlotNo());
	_ASSERTE(SUCCEEDED(hr));

	pDevice->SetName(szName);

	return TRUE;
}
예제 #9
0
CNdasDevice::CNdasDevice(
	DWORD dwSlotNo, 
	CONST NDAS_DEVICE_ID& deviceId) :
	m_status(NDAS_DEVICE_STATUS_DISABLED),
	m_lastError(NDAS_DEVICE_ERROR_NONE),
	m_dwSlotNo(dwSlotNo),
	m_deviceId(deviceId),
	m_grantedAccess(0x00000000L),
	m_dwLastHeartbeatTick(0),
	m_dwCommFailureCount(0),
	m_fAutoRegistered(FALSE)
{
	m_szDeviceName[0] = TEXT('\0');

	::ZeroMemory(
		&m_hwInfo, 
		sizeof(HARDWARE_INFO));

	::ZeroMemory(
		m_pUnitDevices, 
		sizeof(CNdasUnitDevice*) * MAX_NDAS_UNITDEVICE_COUNT);

	HRESULT hr = ::StringCchPrintf(
		m_szCfgContainer, 
		30, 
		TEXT("Devices\\%04d"), 
		dwSlotNo);

	_ASSERT(SUCCEEDED(hr));

	DBGPRT_TRACE(_FT("ctor: %s\n"), ToString());
}
예제 #10
0
VOID
CNdasDevice::SetGrantedAccess(ACCESS_MASK access)
{
	ximeta::CAutoLock autolock(this);

	// only GENERIC_READ and GENERIC_WRITE are acceptable
	m_grantedAccess = (access & (GENERIC_READ | GENERIC_WRITE));

	const DWORD cbData = sizeof(m_grantedAccess) + sizeof(m_deviceId);
	BYTE lpbData[cbData] = {0};

	::CopyMemory(lpbData, &m_grantedAccess, sizeof(m_grantedAccess));
	::CopyMemory(lpbData + sizeof(m_grantedAccess), &m_deviceId, sizeof(m_deviceId));

	BOOL fSuccess = _NdasSystemCfg.SetSecureValueEx(
		m_szCfgContainer, 
		TEXT("GrantedAccess"), 
		lpbData,
		cbData);

	if (!fSuccess) 
	{
		DBGPRT_WARN_EX(_FT("Writing device access to the registry failed at %s.\n"), 
			m_szCfgContainer);
	}

	(VOID) pGetNdasEventPublisher()->DevicePropertyChanged(m_dwSlotNo);
}
예제 #11
0
VOID
CNdasDevice::SetName(LPCTSTR szName)
{
	ximeta::CAutoLock autolock(this);

	HRESULT hr = ::StringCchCopy(
		m_szDeviceName, 
		MAX_NDAS_DEVICE_NAME_LEN, 
		szName);

	_ASSERTE(SUCCEEDED(hr));

	BOOL fSuccess = _NdasSystemCfg.SetValueEx(
		m_szCfgContainer, 
		TEXT("DeviceName"), 
		szName);

	if (!fSuccess) {
		DBGPRT_WARN_EX(
			_FT("Writing device name entry to the registry failed at %s.\n"), 
			m_szCfgContainer);
	}

	CNdasEventPublisher* pEventPublisher = pGetNdasEventPublisher();
	(VOID) pEventPublisher->DevicePropertyChanged(m_dwSlotNo);
}
예제 #12
0
CNdasEventMonitor::~CNdasEventMonitor()
{
	if (INVALID_HANDLE_VALUE != m_hHeartbeatMonitorTimer) {
		BOOL fSuccess = ::CloseHandle(m_hHeartbeatMonitorTimer);
		if (!fSuccess) {
			DBGPRT_WARN_EX(_FT("Failed to close Heartbeat Monitor Timer Handle: "));
		}
	}

	if (NULL != m_hLogDeviceSetChangeEvent) {
		BOOL fSuccess = ::CloseHandle(m_hLogDeviceSetChangeEvent);
		if (!fSuccess) {
			DBGPRT_WARN_EX(_FT("Failed to close Logical device set change event: "));
		}
	}
}
예제 #13
0
BOOL DisableDiskWriteCache(HANDLE hDisk)
{
	BOOL fSuccess = FALSE;
	DWORD cbReturned = 0;
	DISK_CACHE_INFORMATION diskCacheInfo = {0};

	fSuccess = ::DeviceIoControl(
		hDisk,
		IOCTL_DISK_GET_CACHE_INFORMATION,
		NULL,
		0,
		&diskCacheInfo,
		sizeof(DISK_CACHE_INFORMATION),
		&cbReturned,
		NULL);

	if (!fSuccess) {
		DPErrorEx(_FT("DeviceIoControl(IOCTL_DISK_GET_CACHE_INFORMATION) failed: "));
		return FALSE;
	}

	DPInfo(_FT("Disk Write Cache Enabled: %d.\n"), diskCacheInfo.WriteCacheEnabled);
	if (!diskCacheInfo.WriteCacheEnabled) {
		DPInfo(_FT("Disk Write Cache Already Disabled. Ignoring.\n"));
		return TRUE;
	}

	diskCacheInfo.WriteCacheEnabled = FALSE;
	fSuccess = ::DeviceIoControl(
		hDisk,
		IOCTL_DISK_SET_CACHE_INFORMATION,
		&diskCacheInfo,
		sizeof(DISK_CACHE_INFORMATION),
		&diskCacheInfo,
		sizeof(DISK_CACHE_INFORMATION),
		&cbReturned,
		NULL);

	if (!fSuccess) {
		DPErrorEx(_FT("DeviceIoControl(IOCTL_DISK_SET_CACHE_INFORMATION) failed: "));
		return FALSE;
	}

	DPInfo(_FT("Disable Write Cache (%p) completed successfully.\n"), hDisk);
	return TRUE;

}
예제 #14
0
BOOL
CNdasDevice::Enable(BOOL bEnable)
{
	ximeta::CAutoLock autolock(this);

	if (bEnable) 
	{
		//
		// To enable this device
		//
		if (NDAS_DEVICE_STATUS_DISABLED != m_status) 
		{
			return TRUE;
		} 

		//
		// DISABLED -> DISCONNECTED
		//
		ChangeStatus(NDAS_DEVICE_STATUS_DISCONNECTED);
	} 
	else 
	{
		//
		// To disable this device
		//
		if (NDAS_DEVICE_STATUS_DISABLED == m_status) 
		{
			return TRUE;
		} 

		//
		// You cannot disable this device when a unit device is mounted
		//
		if (IsAnyUnitDevicesMounted())
		{
			::SetLastError(NDASHLPSVC_ERROR_CANNOT_DISABLE_MOUNTED_DEVICE);
			return FALSE;
		}

		//
		// DISCONNECTED/CONNECTED -> DISABLED
		//
		ChangeStatus(NDAS_DEVICE_STATUS_DISABLED);
	}

	BOOL fSuccess = _NdasSystemCfg.SetValueEx(
		m_szCfgContainer, 
		TEXT("Enabled"), 
		bEnable);

	if (!fSuccess) 
	{
		DBGPRT_WARN_EX(
			_FT("%s: Writing device enable status to the registry failed at %s:"), 
			ToString(), m_szCfgContainer);
	}

	return TRUE;
}
예제 #15
0
BOOL 
APIENTRY 
DllMain(
	HANDLE hModule, 
	DWORD  dwReason, 
	LPVOID lpReserved)
{
	switch (dwReason)
	{
	case DLL_PROCESS_ATTACH:

		InitProcessData();

		XDbgInit(_T("NDASUSER"));
		XDbgLoadSettingsFromRegistry(
			_T("Software\\NDAS\\NDASUSER"),
			HKEY_CURRENT_USER);

		DBGPRT_INFO(_FT("NDASUSER.DLL Process Attach\n"));

		_pEventSubscriber = new CNdasEventSubscriber();

		break;

	case DLL_THREAD_ATTACH:
		DBGPRT_INFO(_FT("NDASUSER.DLL Thread Attach\n"));
		break;
	case DLL_THREAD_DETACH:
		DBGPRT_INFO(_FT("NDASUSER.DLL Thread Detach\n"));
		break;
	case DLL_PROCESS_DETACH:

		if (NULL != _pxdbgSystemDebugOutput) {
			delete _pxdbgSystemDebugOutput;
		}

		XDbgCleanup();
		CleanupProcessData();
		DBGPRT_INFO(_FT("NDASUSER.DLL Process Detach\n"));

		delete _pEventSubscriber;

		break;
	}
    return TRUE;
}
예제 #16
0
ULONG
CNdasLogicalDevice::AddRef()
{
	ximeta::CAutoLock autolock(this);
	ULONG ulCount = ximeta::CExtensibleObject::AddRef();
	DBGPRT_INFO(_FT("%s: %u\n"), ToString(), ulCount);
	return ulCount;
}
예제 #17
0
ULONG
CNdasUnitDevice::Release()
{
	ximeta::CAutoLock autolock(this);
	ULONG ulCount = ximeta::CExtensibleObject::Release();
	DBGPRT_INFO(_FT("AddRef Reference: %u\n"), ulCount);
	return ulCount;
}
예제 #18
0
BOOL
CNdasLogicalDevice::Initialize()
{
	ximeta::CAutoLock autolock(this);

	if (NDAS_LOGICALDEVICE_STATUS_NOT_INITIALIZED != m_status) {
		// Already initialized
		return TRUE;
	}

	if (NULL == m_hDisconnectedEvent) {
		m_hDisconnectedEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
		if (NULL == m_hDisconnectedEvent) {
			DBGPRT_ERR_EX(_FT("Disconnect event creation failed: "));
			return FALSE;
		}
	}

	if (NULL == m_hAlarmEvent) {
		m_hAlarmEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
		if (NULL == m_hAlarmEvent) {
			DBGPRT_ERR_EX(_FT("Alarm event creation failed: "));
			::CloseHandle(m_hDisconnectedEvent);
			return FALSE;
		}
	}

	ACCESS_MASK lastMountAccess = GetLastMountAccess();

	BOOL fRiskyMountFlag = GetRiskyMountFlag();

	if (fRiskyMountFlag) {
		m_fRiskyMount = fRiskyMountFlag;
	}

	if ((lastMountAccess > 0) && !IsRiskyMount()) {
		SetMountOnReady(lastMountAccess, FALSE);
	}

	SetStatus(NDAS_LOGICALDEVICE_STATUS_UNMOUNTED);

	DBGPRT_INFO(_FT("Logical Device %d initialized successfully.\n"), m_logicalDeviceId);

	return TRUE;
}
예제 #19
0
BOOL
CNdasDevice::InvalidateUnitDevice(DWORD dwUnitNo)
{
	ximeta::CAutoLock autoLock(this);

	DBGPRT_INFO(_FT("%s: Invalidating Unit Device %d\n"), ToString(), dwUnitNo);

	if (dwUnitNo >= MAX_NDAS_UNITDEVICE_COUNT) 
	{
		DBGPRT_INFO(_T("%s: Invalid Unit No: %d\n"), ToString(), dwUnitNo);
		::SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	if (NDAS_DEVICE_STATUS_CONNECTED != GetStatus()) 
	{
		DBGPRT_INFO(_T("%s: Non-connected device ignored\n"), ToString());
		return FALSE;
	}

	BOOL fSuccess = UpdateDeviceInfo();
	if (!fSuccess)
	{
		DBGPRT_ERR_EX(_T("%s: Device is not available.\n"), ToString());
		return FALSE;
	}

	fSuccess = DestroyUnitDevice(dwUnitNo);
	if (!fSuccess) 
	{
		DBGPRT_ERR_EX(_FT("%s: Destroying unit device (%d) failed: "), ToString(), dwUnitNo);
		return FALSE;
	}

	fSuccess = CreateUnitDevice(dwUnitNo);
	if (!fSuccess) 
	{
		DBGPRT_ERR_EX(_FT("%s: Creating unit device (%d) failed: "), ToString(), dwUnitNo);
		return FALSE;
	}

	DBGPRT_INFO(_FT("%s: Unit Device (%d) recreated\n"), ToString(), dwUnitNo);

	return TRUE;
}
예제 #20
0
파일: jdher_bi.c 프로젝트: palao/tmLQCD
void Proj_A_psi_bi(bispinor * const y, bispinor * const x){
  double mtheta = -p_theta;
  int i;
  /* y = A*x */

  p_A_psi_bi(y, x); 

  /* y = -theta*x+y*/
  _FT(daxpy)(&p_n2, &mtheta, (double*) x, &ONE, (double*) y, &ONE);
  /* p_work_bi = Q^dagger*y */ 
  for(i = 0; i < p_k; i++) {
    p_work_bi[i] = scalar_prod_bi((bispinor*) (p_Q_bi+i*p_lda), (bispinor*) y, 
				  p_n*sizeof(complex)/sizeof(bispinor));
  }
  /* y = y - Q*p_work_bi */ 
  _FT(zgemv)(fupl_n, &p_n, &p_k, &CMONE, p_Q_bi, &p_lda, (complex*) p_work_bi, 
	     &ONE, &CONE, (complex*) y, &ONE, 1);
}
예제 #21
0
CNdasDevice::~CNdasDevice()
{
	ximeta::CAutoLock autolock(this);

	BOOL fSuccess = DestroyAllUnitDevices();
	_ASSERTE(fSuccess);

	DBGPRT_TRACE(_FT("dtor: %s\n"), ToString());
}
예제 #22
0
BOOL
CNdasDeviceRegistrar::Unregister(DWORD dwSlotNo)
{
	ximeta::CAutoLock autolock(this);

	DeviceSlotMap::iterator itrSlot = 
		m_deviceSlotMap.find(dwSlotNo);

	if (m_deviceSlotMap.end() == itrSlot) {
		// TODO: Make more specific error code
		::SetLastError(NDASHLPSVC_ERROR_DEVICE_ENTRY_NOT_FOUND);
		return FALSE;
	}

	PCNdasDevice pDevice = itrSlot->second;

	if (pDevice->GetStatus() != NDAS_DEVICE_STATUS_DISABLED) {
		// TODO: ::SetLastError(NDAS_ERROR_CANNOT_UNREGISTER_ENABLED_DEVICE);
		// TODO: Make more specific error code
		::SetLastError(NDASHLPSVC_ERROR_CANNOT_UNREGISTER_ENABLED_DEVICE);
		return FALSE;
	}

	DeviceIdMap::iterator itrId = 
		m_deviceIdMap.find(pDevice->GetDeviceId());

	_ASSERTE(m_deviceIdMap.end() != itrId);

	m_deviceIdMap.erase(itrId);
	m_deviceSlotMap.erase(itrSlot);
	m_pbSlotOccupied[dwSlotNo] = FALSE;

	pDevice->Release();

	TCHAR szContainer[30];
	HRESULT hr = ::StringCchPrintf(szContainer, 30, TEXT("Devices\\%04d"), dwSlotNo);
	_ASSERT(SUCCEEDED(hr));

	BOOL fSuccess = _NdasSystemCfg.DeleteContainer(szContainer, FALSE);
	
	if (!fSuccess) {
		DPWarningEx(
			_FT("Deleting registration entry from the registry failed at %s.\n"), 
			szContainer);
	}

	CNdasInstanceManager* pInstMan = CNdasInstanceManager::Instance();
	_ASSERTE(NULL != pInstMan);

	CNdasEventPublisher* pEventPublisher = pInstMan->GetEventPublisher();
	_ASSERTE(NULL != pEventPublisher);

	(void) pEventPublisher->DeviceEntryChanged();

	return TRUE;

}
예제 #23
0
BOOL 
CNdasEventPublisher::AddEvent(
	const NDAS_EVENT_MESSAGE& eventMessage)
{
	m_queueLock.Lock();
	m_EventMessageQueue.push(eventMessage);
	m_queueLock.Unlock();
	BOOL fSuccess = ::ReleaseSemaphore(m_hSemQueue, 1, NULL);
	if (!fSuccess) {
		// Queue Full
		DBGPRT_ERR_EX(_FT("Event Message Queue Full, Discarded %s :"), 
			NdasEventTypeString(eventMessage.EventType));
		return FALSE;
	}
	DBGPRT_INFO(_FT("Event Message Queued: %s\n"), 
		NdasEventTypeString(eventMessage.EventType));
	return TRUE;
}
예제 #24
0
VOID
CNdasDevice::ChangeStatus(NDAS_DEVICE_STATUS newStatus)
{
	ximeta::CAutoLock autolock(this);

	if (m_status == newStatus) {
		return;
	}

	NDAS_DEVICE_STATUS oldStatus = m_status;

	//
	// clear failure count for every status change
	//
	m_dwCommFailureCount = 0;

	switch (newStatus) {
	case NDAS_DEVICE_STATUS_DISABLED:
		{
			pGetNdasDeviceHeartbeatListner()->Detach(this);
			pGetNdasEventMonitor()->Detach(this);
			DestroyAllUnitDevices();
		}
		break;
	case NDAS_DEVICE_STATUS_CONNECTED:
		{
			pGetNdasEventMonitor()->Attach(this);
		}
		break;
	case NDAS_DEVICE_STATUS_DISCONNECTED:
		{
			//
			// Detaching from the Monitor will be done at OnStatusCheck
			// by returning TRUE to detach this device from the monitor
			//
			pGetNdasDeviceHeartbeatListner()->Attach(this);
			DestroyAllUnitDevices();
		}
		break;
	default:
		_ASSERTE(FALSE);
	}

	DBGPRT_INFO(_FT("%s status changed %s to %s\n"),
		ToString(),
		NdasDeviceStatusString(m_status),
		NdasDeviceStatusString(newStatus));

	m_status = newStatus;

	(VOID) pGetNdasEventPublisher()->
		DeviceStatusChanged(m_dwSlotNo, oldStatus, newStatus);

	return;
}
예제 #25
0
BOOL
CNdasLogicalDevice::IsPSWriteShareCapable()
{
	BOOL fNoPSWriteShare = FALSE;

	// global option
	BOOL fSuccess = _NdasSystemCfg.GetValueEx(
		_T("ndassvc"),
		_T("NoPSWriteShare"),
		&fNoPSWriteShare);
	if (fSuccess && fNoPSWriteShare)
	{
		DBGPRT_INFO(_FT("NoPSWriteShare is set as global.\n"));
		return FALSE;
	}

	// logical device specific option
	fSuccess = _NdasSystemCfg.GetValueEx(
		m_szRegContainer,
		_T("NoPSWriteShare"),
		&fNoPSWriteShare);
	if (fSuccess && fNoPSWriteShare)
	{
		DBGPRT_INFO(_FT("NoPSWriteShare is set at %s.\n"), ToString());
		return FALSE;
	}

	// even though NoPSWriteShare is not set, if there is no active
	// LFS filter, then PSWriteShare is denied.
	WORD wNDFSMajor, wNDFSMinor;
	fSuccess = ::LfsFiltCtlGetVersion(
		NULL, NULL, NULL, NULL, 
		&wNDFSMajor, &wNDFSMinor);
	if (!fSuccess)
	{
		// no LFS exists or it is not working NoPSWriteShare
		DBGPRT_INFO(_FT("LFSFilter does not exist. NoPSWriteShare.\n"));
		return FALSE;
	}

	return TRUE;
}
예제 #26
0
BOOL 
CNdasEventPublisher::ServiceTerminating()
{
	NDAS_EVENT_MESSAGE msg = {0};
	msg.MessageSize = sizeof(NDAS_EVENT_MESSAGE);
	msg.EventType = NDAS_EVENT_TYPE_TERMINATING;

	DPInfo(_FT("Service Termination Event.\n"));

	return AddEvent(&msg);
}
예제 #27
0
BOOL  
CNdasEventPublisher::LogicalDeviceEntryChanged()
{
	NDAS_EVENT_MESSAGE msg = {0};
	msg.MessageSize = sizeof(NDAS_EVENT_MESSAGE);
	msg.EventType = NDAS_EVENT_TYPE_LOGICALDEVICE_ENTRY_CHANGED;

	DPInfo(_FT("Logical Device Entry Changed\n"));

	return AddEvent(&msg);
}
예제 #28
0
BOOL
CNdasEventPublisher::SuspendRejected()
{
	NDAS_EVENT_MESSAGE msg = {0};
	msg.MessageSize = sizeof(NDAS_EVENT_MESSAGE);
	msg.EventType = NDAS_EVENT_TYPE_SUSPEND_REJECTED;

	DBGPRT_INFO(_FT("Suspend Rejected Event.\n"));

	return AddEvent(msg);
}
예제 #29
0
BOOL 
CNdasEventPublisher::DeviceEntryChanged()
{
	NDAS_EVENT_MESSAGE msg = {0};
	msg.MessageSize = sizeof(NDAS_EVENT_MESSAGE);
	msg.EventType = NDAS_EVENT_TYPE_DEVICE_ENTRY_CHANGED;

	DBGPRT_INFO(_FT("Device Entry Changed\n"));

	return AddEvent(msg);
}
예제 #30
0
NDASDI_API 
BOOL 
WINAPI 
NdasDiDeleteService(
	IN LPCTSTR	ServiceName)
{
	AutoSCHandle schSCManager = OpenSCManager(
		NULL, 
		NULL, 
		SC_MANAGER_ALL_ACCESS );

	DPInfo(_FT("Deleting Service %s.\n"), ServiceName);

	if (NULL == (SC_HANDLE) schSCManager) {
		DPErrorEx(_FT("Opening SC Manager failed: "));
		return FALSE;
	}

	return NdasDiDeleteServiceSCH(schSCManager, ServiceName);
}