Example #1
0
//
// 卸载LSP
//
BOOL RemoveProvider()
{
	LPWSAPROTOCOL_INFOW pProtoInfo;
	int nProtocols;
	DWORD dwLayeredCatalogId;
	
	// 根据Guid取得分层协议的目录ID号
	pProtoInfo = GetProvider(&nProtocols);
	int nError;
	for(int i=0; i<nProtocols; i++)
	{
		if(memcmp(&ProviderGuid, &pProtoInfo[i].ProviderId, sizeof(ProviderGuid)) == 0)
		{
			dwLayeredCatalogId = pProtoInfo[i].dwCatalogEntryId;
			break;
		}
	}
	
	if(i < nProtocols)
	{
		// 移除协议链
		for(i=0; i<nProtocols; i++)
		{
			if((pProtoInfo[i].ProtocolChain.ChainLen > 1) && (pProtoInfo[i].ProtocolChain.ChainEntries[0] == dwLayeredCatalogId))
			{
				::WSCDeinstallProvider(&pProtoInfo[i].ProviderId, &nError);
			}
		}
		// 移除分层协议
		::WSCDeinstallProvider(&ProviderGuid, &nError);
	}
	
	return TRUE;
}
Example #2
0
CFX_Matrix CPWL_Wnd::GetWindowMatrix() const {
  CFX_Matrix mt = GetChildToRoot();

  if (IPWL_Provider* pProvider = GetProvider()) {
    mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
    return mt;
  }

  return mt;
}
Example #3
0
/* FMIFS.7 */
VOID
NTAPI
FormatEx(
    IN PWCHAR DriveRoot,
    IN FMIFS_MEDIA_FLAG MediaFlag,
    IN PWCHAR Format,
    IN PWCHAR Label,
    IN BOOLEAN QuickFormat,
    IN ULONG ClusterSize,
    IN PFMIFSCALLBACK Callback)
{
    PIFS_PROVIDER Provider;
    UNICODE_STRING usDriveRoot;
    UNICODE_STRING usLabel;
    BOOLEAN Argument = FALSE;
    WCHAR VolumeName[MAX_PATH];
    //CURDIR CurDir;

    Provider = GetProvider(Format);
    if (!Provider)
    {
        /* Unknown file system */
        Callback(DONE, 0, &Argument);
        return;
    }

#if 1
    DPRINT1("Warning: use GetVolumeNameForVolumeMountPointW() instead!\n");
    swprintf(VolumeName, L"\\??\\%c:", towupper(DriveRoot[0]));
    RtlCreateUnicodeString(&usDriveRoot, VolumeName);
    /* Code disabled as long as our storage stack doesn't understand IOCTL_MOUNTDEV_QUERY_DEVICE_NAME */
#else
    if (!GetVolumeNameForVolumeMountPointW(DriveRoot, VolumeName, MAX_PATH) ||
        !RtlDosPathNameToNtPathName_U(VolumeName, &usDriveRoot, NULL, &CurDir))
    {
        /* Report an error. */
        Callback(DONE, 0, &Argument);
        return;
    }
#endif

    RtlInitUnicodeString(&usLabel, Label);

    DPRINT("FormatEx - %S\n", Format);
    Provider->FormatEx(&usDriveRoot,
                       MediaFlag,
                       &usLabel,
                       QuickFormat,
                       ClusterSize,
                       Callback);

    RtlFreeUnicodeString(&usDriveRoot);
}
Example #4
0
HRESULT
CTraceSession::DeleteTraceProvider(_In_ GUID &ProviderGuid)
{
    // Find the guid in the list
    CTraceProvider *Provider;
    HRESULT hr = GetProvider(ProviderGuid, true, &Provider);
    if (FAILED(hr))
    {
        delete Provider;
    }
    return hr;
}
Example #5
0
void FSourceControlModule::QueueStatusUpdate(const FString& InFilename)
{
	if(IsEnabled())
	{
		TSharedPtr<ISourceControlState, ESPMode::ThreadSafe> SourceControlState = GetProvider().GetState(InFilename, EStateCacheUsage::Use);
		if(SourceControlState.IsValid())
		{
			FTimespan TimeSinceLastUpdate = FDateTime::Now() - SourceControlState->GetTimeStamp();
			if(TimeSinceLastUpdate > SourceControlConstants::StateRefreshInterval)
			{
				PendingStatusUpdateFiles.AddUnique(InFilename);
			}
		}
	}
}
void main()
{
	LPWSAPROTOCOL_INFOW pProtoInfo;
	int nProtocols;
	pProtoInfo = GetProvider(&nProtocols);

	for(int i=0; i<nProtocols; i++)
	{
		
		printf(" Protocol: %ws \n", pProtoInfo[i].szProtocol);
		printf(" CatalogEntryId: %d		ChainLen: %d \n\n", 
			pProtoInfo[i].dwCatalogEntryId, pProtoInfo[i].ProtocolChain.ChainLen);
		
	}
}
Example #7
0
/// @brief Open stream 
///
void DirectSoundPlayer::OpenStream() {
	// Get provider
	AudioProvider *provider = GetProvider();

	// Initialize the DirectSound object
	HRESULT res;
	res = DirectSoundCreate8(&DSDEVID_DefaultPlayback,&directSound,NULL); // TODO: support selecting audio device
	if (FAILED(res)) throw _T("Failed initializing DirectSound");

	// Set DirectSound parameters
	AegisubApp *app = (AegisubApp*) wxTheApp;
	directSound->SetCooperativeLevel((HWND)app->frame->GetHandle(),DSSCL_PRIORITY);

	// Create the wave format structure
	WAVEFORMATEX waveFormat;
	waveFormat.wFormatTag = WAVE_FORMAT_PCM;
	waveFormat.nSamplesPerSec = provider->GetSampleRate();
	waveFormat.nChannels = provider->GetChannels();
	waveFormat.wBitsPerSample = provider->GetBytesPerSample() * 8;
	waveFormat.nBlockAlign = waveFormat.nChannels * waveFormat.wBitsPerSample / 8;
	waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
	waveFormat.cbSize = sizeof(waveFormat);

	// Create the buffer initializer
	int aim = waveFormat.nAvgBytesPerSec * 15/100; // 150 ms buffer
	int min = DSBSIZE_MIN;
	int max = DSBSIZE_MAX;
	bufSize = std::min(std::max(min,aim),max);
	DSBUFFERDESC desc;
	desc.dwSize = sizeof(DSBUFFERDESC);
	desc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS;
	desc.dwBufferBytes = bufSize;
	desc.dwReserved = 0;
	desc.lpwfxFormat = &waveFormat;
	desc.guid3DAlgorithm = GUID_NULL;

	// Create the buffer
	IDirectSoundBuffer *buf;
	res = directSound->CreateSoundBuffer(&desc,&buf,NULL);
	if (res != DS_OK) throw _T("Failed creating DirectSound buffer");

	// Copy interface to buffer
	res = buf->QueryInterface(IID_IDirectSoundBuffer8,(LPVOID*) &buffer);
	if (res != S_OK) throw _T("Failed casting interface to IDirectSoundBuffer8");

	// Set data
	offset = 0;
}
void main()
{
	int nTotalProtocols;
	LPWSAPROTOCOL_INFO pProtoInfo = GetProvider(&nTotalProtocols);
	if(pProtoInfo != NULL)
	{
		// 打印出各个提供者的协议信息
		for(int i=0; i<nTotalProtocols; i++)
		{
			printf(" Protocol: %s \n", pProtoInfo[i].szProtocol);
			printf(" CatalogEntryId: %d		ChainLen: %d \n\n", 
				pProtoInfo[i].dwCatalogEntryId, pProtoInfo[i].ProtocolChain.ChainLen);
		}
		FreeProvider(pProtoInfo);
	}
}
Example #9
0
void FSourceControlModule::ShutdownModule()
{
	// close the current provider
	GetProvider().Close();

#if WITH_UNREAL_DEVELOPER_TOOLS
	// unregister message log
	if(FModuleManager::Get().IsModuleLoaded("MessageLog"))
	{
		FMessageLogModule& MessageLogModule = FModuleManager::LoadModuleChecked<FMessageLogModule>("MessageLog");
		MessageLogModule.UnregisterLogListing("SourceControl");
	}
#endif

	// unbind default provider from editor
	IModularFeatures::Get().UnregisterModularFeature( SourceControlFeatureName, &DefaultSourceControlProvider );

	// we don't care about modular features any more
	IModularFeatures::Get().OnModularFeatureRegistered().RemoveAll(this);
	IModularFeatures::Get().OnModularFeatureUnregistered().RemoveAll(this);
}
Example #10
0
void FSourceControlModule::Tick()
{	
	if( CurrentSourceControlProvider != nullptr )
	{
		ISourceControlProvider& Provider = GetProvider();

		// tick the provider, so any operation results can be read back
		Provider.Tick();

		// don't allow background status updates when temporarily disabled for login
		if(!bTemporarilyDisabled)
		{
			// check for any pending dispatches
			if(PendingStatusUpdateFiles.Num() > 0)
			{
				// grab a batch of files
				TArray<FString> FilesToDispatch;
				for(auto Iter(PendingStatusUpdateFiles.CreateConstIterator()); Iter; Iter++)
				{
					if(FilesToDispatch.Num() >= SourceControlConstants::MaxStatusDispatchesPerTick)
					{
						break;
					}
					FilesToDispatch.Add(*Iter);
				}

				if(FilesToDispatch.Num() > 0)
				{
					// remove the files we are dispatching so we don't try again
					PendingStatusUpdateFiles.RemoveAt(0, FilesToDispatch.Num());

					// dispatch update
					Provider.Execute(ISourceControlOperation::Create<FUpdateStatus>(), FilesToDispatch, EConcurrency::Asynchronous);
				}
			}
		}
	}
}
Example #11
0
bool FSourceControlModule::IsEnabled() const
{
	return !bTemporarilyDisabled && GetProvider().IsEnabled();
}
Example #12
0
int WSPAPI WSPStartup(
					  WORD wVersionRequested,
					  LPWSPDATA lpWSPData,
					  LPWSAPROTOCOL_INFO lpProtocolInfo,
					  WSPUPCALLTABLE UpcallTable,
					  LPWSPPROC_TABLE lpProcTable
					  )
{
	int i;
	ODS1(L"WSPStartup... %s \n", g_szCurrentApp);

	if(lpProtocolInfo->ProtocolChain.ChainLen <= 1)
	{
		return WSAEPROVIDERFAILEDINIT;
	}
	g_pUpCallTable = UpcallTable;
	WSAPROTOCOL_INFOW NextProtocolInfo;
	int nTotalProtos;
	LPWSAPROTOCOL_INFOW pProtoInfo = GetProvider(&nTotalProtos);
	
	DWORD dwBaseEntryId = lpProtocolInfo->ProtocolChain.ChainEntries[1];
	for(i=0; i<nTotalProtos; i++)
	{
		if(pProtoInfo[i].dwCatalogEntryId == dwBaseEntryId)
		{
			memcpy(&NextProtocolInfo, &pProtoInfo[i], sizeof(NextProtocolInfo));
			break;
		}
	}
	if(i >= nTotalProtos)
	{
		ODS(L" WSPStartup: Can not find underlying protocol \n");
		return WSAEPROVIDERFAILEDINIT;
	}


	int nError;
	TCHAR szBaseProviderDll[MAX_PATH];
	int nLen = MAX_PATH;

	if(::WSCGetProviderPath(&NextProtocolInfo.ProviderId, szBaseProviderDll, &nLen, &nError) == SOCKET_ERROR)
	{
		ODS1(L" WSPStartup: WSCGetProviderPath() failed %d \n", nError);
		return WSAEPROVIDERFAILEDINIT;
	}
	if(!::ExpandEnvironmentStrings(szBaseProviderDll, szBaseProviderDll, MAX_PATH))
	{
		ODS1(L" WSPStartup: ExpandEnvironmentStrings() failed %d \n", ::GetLastError());
		return WSAEPROVIDERFAILEDINIT;
	}

	HMODULE hModule = ::LoadLibrary(szBaseProviderDll);
	if(hModule == NULL)
	{
		ODS1(L" WSPStartup: LoadLibrary() failed %d \n", ::GetLastError());
		return WSAEPROVIDERFAILEDINIT;
	}


	LPWSPSTARTUP pfnWSPStartup = NULL;
	pfnWSPStartup = (LPWSPSTARTUP)::GetProcAddress(hModule, "WSPStartup");
	if(pfnWSPStartup == NULL)
	{
		ODS1(L" WSPStartup: GetProcAddress() failed %d \n", ::GetLastError());
		return WSAEPROVIDERFAILEDINIT;
	}

	LPWSAPROTOCOL_INFOW pInfo = lpProtocolInfo;
	if(NextProtocolInfo.ProtocolChain.ChainLen == BASE_PROTOCOL)
		pInfo = &NextProtocolInfo;
	int nRet = pfnWSPStartup(wVersionRequested, lpWSPData, pInfo, UpcallTable, lpProcTable);
	if(nRet != ERROR_SUCCESS)
	{
		ODS1(L" WSPStartup: underlying provider's WSPStartup() failed %d \n", nRet);
		return nRet;
	}
	g_NextProcTable = *lpProcTable;
	lpProcTable->lpWSPSocket = WSPSocket;
	lpProcTable->lpWSPCloseSocket = WSPCloseSocket;
	lpProcTable->lpWSPConnect = WSPConnect;
	lpProcTable->lpWSPAccept = WSPAccept;
	lpProcTable->lpWSPSend = WSPSend;
	lpProcTable->lpWSPSendTo = WSPSendTo;
	lpProcTable->lpWSPRecv = WSPRecv;
	lpProcTable->lpWSPRecvFrom = WSPRecvFrom;
	lpProcTable->lpWSPAddressToString = WSPAddressToString;
	lpProcTable->lpWSPAsyncSelect = WSPAsyncSelect;
	lpProcTable->lpWSPBind = WSPBind;
	lpProcTable->lpWSPCancelBlockingCall = WSPCancelBlockingCall;
	lpProcTable->lpWSPCleanup = WSPCleanup;
	lpProcTable->lpWSPDuplicateSocket = WSPDuplicateSocket;
	lpProcTable->lpWSPEnumNetworkEvents = WSPEnumNetworkEvents;
	lpProcTable->lpWSPEventSelect = WSPEventSelect;
	lpProcTable->lpWSPGetOverlappedResult = WSPGetOverlappedResult;
	lpProcTable->lpWSPGetPeerName = WSPGetPeerName;
	lpProcTable->lpWSPGetQOSByName = WSPGetQOSByName;
	lpProcTable->lpWSPGetSockName = WSPGetSockName;
	lpProcTable->lpWSPGetSockOpt = WSPGetSockOpt;
	lpProcTable->lpWSPIoctl = WSPIoctl;
	lpProcTable->lpWSPJoinLeaf = WSPJoinLeaf;
	lpProcTable->lpWSPListen = WSPListen;
	lpProcTable->lpWSPRecvDisconnect = WSPRecvDisconnect;
	lpProcTable->lpWSPSelect = WSPSelect;
	lpProcTable->lpWSPSendDisconnect = WSPSendDisconnect;
	lpProcTable->lpWSPSetSockOpt = WSPSetSockOpt;
	lpProcTable->lpWSPShutdown = WSPShutdown;
	lpProcTable->lpWSPStringToAddress = WSPStringToAddress;
	FreeProvider(pProtoInfo);
	return nRet;
}
Example #13
0
/// @brief Fill buffer 
/// @param fill 
/// @return 
///
bool DirectSoundPlayer::FillBuffer(bool fill) {
	if (playPos >= endPos) return false;

	// Variables
	HRESULT res;
	void *ptr1, *ptr2;
	unsigned long int size1, size2;
	AudioProvider *provider = GetProvider();
	int bytesps = provider->GetBytesPerSample();

	// To write length
	int toWrite = 0;
	if (fill) {
		toWrite = bufSize;
	}
	else {
		DWORD bufplay;
		res = buffer->GetCurrentPosition(&bufplay, NULL);
		if (FAILED(res)) return false;
		toWrite = (int)bufplay - (int)offset;
		if (toWrite < 0) toWrite += bufSize;
	}
	if (toWrite == 0) return true;

	// Make sure we only get as many samples as are available
	if (playPos + toWrite/bytesps > endPos) {
		toWrite = (endPos - playPos) * bytesps;
	}

	// If we're going to fill the entire buffer (ie. at start of playback) start by zeroing it out
	// If it's not zeroed out we might have a playback selection shorter than the buffer
	// and then everything after the playback selection will be junk, which we don't want played.
	if (fill) {
RetryClear:
		res = buffer->Lock(0, bufSize, &ptr1, &size1, &ptr2, &size2, 0);
		if (res == DSERR_BUFFERLOST) {
			buffer->Restore();
			goto RetryClear;
		}
		memset(ptr1, 0, size1);
		memset(ptr2, 0, size2);
		buffer->Unlock(ptr1, size1, ptr2, size2);
	}

	// Lock buffer
RetryLock:
	if (fill) {
		res = buffer->Lock(offset, toWrite, &ptr1, &size1, &ptr2, &size2, 0);
	}
	else {
		res = buffer->Lock(offset, toWrite, &ptr1, &size1, &ptr2, &size2, 0);//DSBLOCK_FROMWRITECURSOR);
	}

	// Buffer lost?
	if (res == DSERR_BUFFERLOST) {
		LOG_D("audio/player/dsound1") << "lost dsound buffer";
		buffer->Restore();
		goto RetryLock;
	}

	// Error
	if (FAILED(res)) return false;

	// Convert size to number of samples
	unsigned long int count1 = size1 / bytesps;
	unsigned long int count2 = size2 / bytesps;

	LOG_D_IF(count1, "audio/player/dsound1") << "DS fill: " << (unsigned long)playPos << " -> " << (unsigned long)playPos+count1;
	LOG_D_IF(count2, "audio/player/dsound1") << "DS fill: " << (unsigned long)playPos+count1 << " -> " << (unsigned long)playPos+count1+count2;
	LOG_D_IF(!count1 && !count2, "audio/player/dsound1") << "DS fill: nothing";

	// Get source wave
	if (count1) provider->GetAudioWithVolume(ptr1, playPos, count1, volume);
	if (count2) provider->GetAudioWithVolume(ptr2, playPos+count1, count2, volume);
	playPos += count1+count2;

	// Unlock
	buffer->Unlock(ptr1,count1*bytesps,ptr2,count2*bytesps);

	// Update offset
	offset = (offset + count1*bytesps + count2*bytesps) % bufSize;

	return playPos < endPos;
}
Example #14
0
FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
  if (m_bMouseDown)
    return FALSE;

  CPWL_Wnd::OnRButtonUp(point, nFlag);

  if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point))
    return TRUE;

  IFX_SystemHandler* pSH = GetSystemHandler();
  if (!pSH)
    return FALSE;

  SetFocus();

  CPVT_WordRange wrLatin = GetLatinWordsRange(point);
  CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);

  FX_HMENU hPopup = pSH->CreatePopupMenu();
  if (!hPopup)
    return FALSE;

  CFX_ByteStringArray sSuggestWords;
  CPDF_Point ptPopup = point;

  if (!IsReadOnly()) {
    if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) {
      if (m_pSpellCheck) {
        CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin);

        if (!m_pSpellCheck->CheckWord(sLatin)) {
          m_pSpellCheck->SuggestWords(sLatin, sSuggestWords);

          int32_t nSuggest = sSuggestWords.GetSize();

          for (int32_t nWord = 0; nWord < nSuggest; nWord++) {
            pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord,
                                sSuggestWords[nWord].UTF8Decode());
          }

          if (nSuggest > 0)
            pSH->AppendMenuItem(hPopup, 0, L"");

          ptPopup = GetWordRightBottomPoint(wrLatin.EndPos);
        }
      }
    }
  }

  IPWL_Provider* pProvider = GetProvider();

  if (HasFlag(PES_UNDO)) {
    pSH->AppendMenuItem(
        hPopup, WM_PWLEDIT_UNDO,
        pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
    pSH->AppendMenuItem(
        hPopup, WM_PWLEDIT_REDO,
        pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
    pSH->AppendMenuItem(hPopup, 0, L"");

    if (!m_pEdit->CanUndo())
      pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE);
    if (!m_pEdit->CanRedo())
      pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
  }

  pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
                      pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
  pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
                      pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
  pSH->AppendMenuItem(
      hPopup, WM_PWLEDIT_PASTE,
      pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
  pSH->AppendMenuItem(
      hPopup, WM_PWLEDIT_DELETE,
      pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");

  CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd());
  if (swText.IsEmpty())
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);

  if (!m_pEdit->IsSelected()) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
  }

  if (IsReadOnly()) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
  }

  if (HasFlag(PES_PASSWORD)) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
  }

  if (HasFlag(PES_NOREAD)) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
  }

  pSH->AppendMenuItem(hPopup, 0, L"");
  pSH->AppendMenuItem(
      hPopup, WM_PWLEDIT_SELECTALL,
      pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All");

  if (m_pEdit->GetTotalWords() == 0) {
    pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
  }

  int32_t x, y;
  PWLtoWnd(ptPopup, x, y);
  pSH->ClientToScreen(GetAttachedHWnd(), x, y);
  pSH->SetCursor(FXCT_ARROW);
  int32_t nCmd = pSH->TrackPopupMenu(hPopup, x, y, GetAttachedHWnd());

  switch (nCmd) {
    case WM_PWLEDIT_UNDO:
      Undo();
      break;
    case WM_PWLEDIT_REDO:
      Redo();
      break;
    case WM_PWLEDIT_CUT:
      CutText();
      break;
    case WM_PWLEDIT_COPY:
      CopyText();
      break;
    case WM_PWLEDIT_PASTE:
      PasteText();
      break;
    case WM_PWLEDIT_DELETE:
      Clear();
      break;
    case WM_PWLEDIT_SELECTALL:
      SelectAll();
      break;
    case WM_PWLEDIT_SUGGEST + 0:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[0].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 1:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[1].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 2:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[2].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 3:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[3].UTF8Decode().c_str());
      break;
    case WM_PWLEDIT_SUGGEST + 4:
      SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
             m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
      ReplaceSel(sSuggestWords[4].UTF8Decode().c_str());
      break;
    default:
      break;
  }

  pSH->DestroyMenu(hPopup);

  return TRUE;
}
Example #15
0
BOOL InstallProvider(WCHAR *pwszPathName)
{
	WCHAR wszLSPName[] = L"PhoenixLSP";
	LPWSAPROTOCOL_INFOW pProtoInfo;
	int nProtocols;
	WSAPROTOCOL_INFOW OriginalProtocolInfo[3];
	DWORD			 dwOrigCatalogId[3];
	int nArrayCount = 0;

	DWORD dwLayeredCatalogId;		// 我们分层协议的目录ID号

	int nError;
	
		// 找到我们的下层协议,将信息放入数组中
	// 枚举所有服务程序提供者
	pProtoInfo = GetProvider(&nProtocols);
	BOOL bFindUdp = FALSE;
	BOOL bFindTcp = FALSE;
	BOOL bFindRaw = FALSE;
	int i=0;
	for(i; i<nProtocols; i++)
	{
		if(pProtoInfo[i].iAddressFamily == AF_INET)
		{
		if(!bFindUdp && pProtoInfo[i].iProtocol == IPPROTO_UDP)
			{
				memcpy(&OriginalProtocolInfo[nArrayCount], &pProtoInfo[i], sizeof(WSAPROTOCOL_INFOW));
				OriginalProtocolInfo[nArrayCount].dwServiceFlags1 = 
					OriginalProtocolInfo[nArrayCount].dwServiceFlags1 & (~XP1_IFS_HANDLES); 
				
				dwOrigCatalogId[nArrayCount++] = pProtoInfo[i].dwCatalogEntryId;

				bFindUdp = TRUE;
			}

		if(!bFindTcp && pProtoInfo[i].iProtocol == IPPROTO_TCP)
			{
				memcpy(&OriginalProtocolInfo[nArrayCount], &pProtoInfo[i], sizeof(WSAPROTOCOL_INFOW));
				OriginalProtocolInfo[nArrayCount].dwServiceFlags1 = 
					OriginalProtocolInfo[nArrayCount].dwServiceFlags1 & (~XP1_IFS_HANDLES); 
				
				dwOrigCatalogId[nArrayCount++] = pProtoInfo[i].dwCatalogEntryId;

				bFindTcp = TRUE;
			} 
		if(!bFindRaw && pProtoInfo[i].iProtocol == IPPROTO_IP)
			{
				memcpy(&OriginalProtocolInfo[nArrayCount], &pProtoInfo[i], sizeof(WSAPROTOCOL_INFOW));
				OriginalProtocolInfo[nArrayCount].dwServiceFlags1 = 
					OriginalProtocolInfo[nArrayCount].dwServiceFlags1 & (~XP1_IFS_HANDLES); 
				
				dwOrigCatalogId[nArrayCount++] = pProtoInfo[i].dwCatalogEntryId;

				bFindRaw = TRUE;
			}
		}
	}  

		// 安装我们的分层协议,获取一个dwLayeredCatalogId
	// 随便找一个下层协议的结构复制过来即可
	WSAPROTOCOL_INFOW LayeredProtocolInfo;
	memcpy(&LayeredProtocolInfo, &OriginalProtocolInfo[0], sizeof(WSAPROTOCOL_INFOW));
	// 修改协议名称,类型,设置PFL_HIDDEN标志
	wcscpy(LayeredProtocolInfo.szProtocol, wszLSPName);
	LayeredProtocolInfo.ProtocolChain.ChainLen = LAYERED_PROTOCOL; // 0;
	LayeredProtocolInfo.dwProviderFlags |= PFL_HIDDEN;
	// 安装
	if(::WSCInstallProvider(&ProviderGuid, 
					pwszPathName, &LayeredProtocolInfo, 1, &nError) == SOCKET_ERROR)
	{
		return FALSE;
	}
	// 重新枚举协议,获取分层协议的目录ID号
	FreeProvider(pProtoInfo);
	pProtoInfo = GetProvider(&nProtocols);
	for(i=0; i<nProtocols; i++)
	{
		if(memcmp(&pProtoInfo[i].ProviderId, &ProviderGuid, sizeof(ProviderGuid)) == 0)
		{
			dwLayeredCatalogId = pProtoInfo[i].dwCatalogEntryId;
			break;
		}
	}

			// 安装协议链
	// 修改协议名称,类型
	WCHAR wszChainName[WSAPROTOCOL_LEN + 1];
	for(i=0; i<nArrayCount; i++)
	{
		swprintf(wszChainName, L"%ws over %ws", wszLSPName, OriginalProtocolInfo[i].szProtocol);
		wcscpy(OriginalProtocolInfo[i].szProtocol, wszChainName);
		if(OriginalProtocolInfo[i].ProtocolChain.ChainLen == 1)
		{
			OriginalProtocolInfo[i].ProtocolChain.ChainEntries[1] = dwOrigCatalogId[i];
		}
		else
		{
			for(int j = OriginalProtocolInfo[i].ProtocolChain.ChainLen; j>0; j--)
			{
				OriginalProtocolInfo[i].ProtocolChain.ChainEntries[j] 
									= OriginalProtocolInfo[i].ProtocolChain.ChainEntries[j-1];
			}
		}
		OriginalProtocolInfo[i].ProtocolChain.ChainLen ++;
		OriginalProtocolInfo[i].ProtocolChain.ChainEntries[0] = dwLayeredCatalogId;	
	}
	// 获取一个Guid,安装之
	GUID ProviderChainGuid;
	if(::UuidCreate(&ProviderChainGuid) == RPC_S_OK)
	{
		if(::WSCInstallProvider(&ProviderChainGuid, 
					pwszPathName, OriginalProtocolInfo, nArrayCount, &nError) == SOCKET_ERROR)
		{
			return FALSE;	
		}
	}
	else
		return FALSE;

			// 重新排序Winsock目录,将我们的协议链提前
	// 重新枚举安装的协议
	FreeProvider(pProtoInfo);
	pProtoInfo = GetProvider(&nProtocols);

	DWORD dwIds[20];
	int nIndex = 0;
	// 添加我们的协议链
	for(i=0; i<nProtocols; i++)
	{
		if((pProtoInfo[i].ProtocolChain.ChainLen > 1) &&
					(pProtoInfo[i].ProtocolChain.ChainEntries[0] == dwLayeredCatalogId))
			dwIds[nIndex++] = pProtoInfo[i].dwCatalogEntryId;
	}
	// 添加其它协议
	for(i=0; i<nProtocols; i++)
	{
		if((pProtoInfo[i].ProtocolChain.ChainLen <= 1) ||
				(pProtoInfo[i].ProtocolChain.ChainEntries[0] != dwLayeredCatalogId))
			dwIds[nIndex++] = pProtoInfo[i].dwCatalogEntryId;
	}
	// 重新排序Winsock目录
	if((nError = ::WSCWriteProviderOrder(dwIds, nIndex)) != ERROR_SUCCESS)
	{
		return FALSE;
	}
	FreeProvider(pProtoInfo);

	return TRUE;
}
Example #16
0
void FSourceControlModule::ShowLoginDialog(const FSourceControlLoginClosed& InOnSourceControlLoginClosed, ELoginWindowMode::Type InLoginWindowMode, EOnLoginWindowStartup::Type InOnLoginWindowStartup)
{
#if SOURCE_CONTROL_WITH_SLATE
	// Get Active Provider Name
	ActiveProviderName = GetProvider().GetName().ToString();

	// if we are showing a modal version of the dialog & a modeless version already exists, we must destroy the modeless dialog first
	if(InLoginWindowMode == ELoginWindowMode::Modal && SourceControlLoginPtr.IsValid())
	{
		// unhook the delegate so it doesn't fire in this case
		SourceControlLoginWindowPtr->SetOnWindowClosed(FOnWindowClosed());
		SourceControlLoginWindowPtr->RequestDestroyWindow();
		SourceControlLoginWindowPtr = NULL;
		SourceControlLoginPtr = NULL;
	}

	if(SourceControlLoginWindowPtr.IsValid())
	{
		SourceControlLoginWindowPtr->BringToFront();
	}
	else
	{
		// set provider to 'none'.
		// When we open the window, we turn off the fact that source control is available, this solves issues that are present with
		// being a three state modeless system (Accepted settings, disabled, and not yet decided).
		if(InOnLoginWindowStartup == EOnLoginWindowStartup::ResetProviderToNone)
		{
			SetProvider("None");
		}

		// temporarily disable access to source control features
		bTemporarilyDisabled = true;

		// Create the window
		SourceControlLoginWindowPtr = SNew(SWindow)
			.Title( LOCTEXT("SourceControlLoginTitle", "Source Control Login") )
			.HasCloseButton(false)
			.SupportsMaximize(false) 
			.SupportsMinimize(false)
			.SizingRule( ESizingRule::Autosized );

		// Set the closed callback
		SourceControlLoginWindowPtr->SetOnWindowClosed(FOnWindowClosed::CreateRaw(this, &FSourceControlModule::OnSourceControlDialogClosed));

		// Setup the content for the created login window.
		SourceControlLoginWindowPtr->SetContent(
			SNew(SBox)
			.WidthOverride(700.0f)
			[
				SAssignNew(SourceControlLoginPtr, SSourceControlLogin)
				.ParentWindow(SourceControlLoginWindowPtr)
				.OnSourceControlLoginClosed(InOnSourceControlLoginClosed)
			]
			);

		TSharedPtr<SWindow> RootWindow = FGlobalTabmanager::Get()->GetRootWindow();
		if(RootWindow.IsValid())
		{
			if(InLoginWindowMode == ELoginWindowMode::Modal)
			{
				FSlateApplication::Get().AddModalWindow(SourceControlLoginWindowPtr.ToSharedRef(), RootWindow);
			}
			else
			{
				FSlateApplication::Get().AddWindowAsNativeChild(SourceControlLoginWindowPtr.ToSharedRef(), RootWindow.ToSharedRef());
			}
		}
		else
		{
			if(InLoginWindowMode == ELoginWindowMode::Modal)
			{
				FSlateApplication::Get().AddModalWindow(SourceControlLoginWindowPtr.ToSharedRef(), RootWindow);
			}
			else
			{
				FSlateApplication::Get().AddWindow(SourceControlLoginWindowPtr.ToSharedRef());
			}
		}
	}
#else
	STUBBED("FSourceControlModule::ShowLoginDialog - no Slate");
#endif // SOURCE_CONTROL_WITH_SLATE
}
Example #17
0
BOOL RSAKey::GenKey(DWORD dwFlags)
{
    DWORD dwBitLen;
    DWORD dwByteLen1;
    DWORD dwByteLen2;
    DWORD dwBufferSize1;
    DWORD dwBufferSize2;
    BYTE *pb;

    dwBitLen = dwFlags >> 16;

    // use the default if not specified
    if (dwBitLen == 0)
        dwBitLen = 1024;

    if ((dwBitLen % 16 != 0) || 
        (dwBitLen > 16384))
    {
        SetLastError(NTE_BAD_FLAGS);
        return FALSE;
    }
    m_dwBitLen = dwBitLen;

    dwByteLen1 = dwBitLen / 8;
    dwByteLen2 = dwByteLen1 / 2;

    dwBufferSize1 = BigNum::GetBufferSize(dwByteLen1);
    dwBufferSize2 = BigNum::GetBufferSize(dwByteLen2);

    m_dwSize = BigNum::GetBufferSize(sizeof(DWORD)) + 
            (2 * dwBufferSize1 + 5 * dwBufferSize2);
    pb = (BYTE*)malloc(m_dwSize);
    if (pb == NULL)
    {
        SetLastError(ERROR_OUTOFMEMORY);
        return FALSE;
    }
    m_pBlob = pb;

    m_pExponent = (BigNum*)pb;
    pb += BigNum::GetBufferSize(sizeof(DWORD));

static const BYTE c_DefaultExponent[4] = { 1, 0, 1, 0 };
    BigNum::SetBytes(m_pExponent, c_DefaultExponent, sizeof(DWORD));

#define HELPER(m_pMember, size) \
    m_pMember = (BigNum*)pb; \
    pb += dwBufferSize##size;

    HELPER(m_pModulus, 1);

    HELPER(m_pPrime1, 2);
    HELPER(m_pPrime2, 2);
    HELPER(m_pExponent1, 2);
    HELPER(m_pExponent2, 2);
    HELPER(m_pCoefficient, 2);
    HELPER(m_pPrivateExponent, 1);
#undef HELPER

    if (!GenerateKey())
    {
        ClearStack();
        return FALSE;
    }

    if (!CheckKey())
    {                       
        SetLastError(E_UNEXPECTED);
        _ASSERTE(false);

        ClearStack();
        return FALSE;
    }        

    GetProvider()->SetSignatureKey(this);
    return TRUE;
}
Example #18
0
BOOL RSAKey::ImportKey(DWORD dwFlags, CONST BYTE *pbData, DWORD dwDataLen)
{            
    BOOL bPrivate;
    DWORD dwBitLen;
    DWORD dwByteLen1;
    DWORD dwByteLen2;
    DWORD dwBufferSize1;
    DWORD dwBufferSize2;
    BYTE *pb;
    BLOBHEADER *pBlobHeader;
    RSAPUBKEY* pRSAPubKey;

    _ASSERTE(dwDataLen >= sizeof(BLOBHEADER));
    pBlobHeader = (BLOBHEADER*)pbData;

    pbData += sizeof(BLOBHEADER);
    dwDataLen -= sizeof(BLOBHEADER);

    switch (pBlobHeader->bType)
    {
    case PUBLICKEYBLOB:
        bPrivate = FALSE;
        break;
    case PRIVATEKEYBLOB:
        bPrivate = TRUE;
        break;
    default:
        goto BadKey;
    }

    if (dwDataLen < sizeof(RSAPUBKEY))
    {
        goto BadKey;
    }
    pRSAPubKey = (RSAPUBKEY*)pbData;

    pbData += sizeof(RSAPUBKEY);
    dwDataLen -= sizeof(RSAPUBKEY);

    if (GET_UNALIGNED_VAL32(&pRSAPubKey->magic) != 
        (bPrivate ? 0x32415352U : 0x31415352U)) // 'RSA2' : 'RSA1'
    {
        goto BadKey;
    }

    dwBitLen = GET_UNALIGNED_VAL32(&pRSAPubKey->bitlen);

    if ((dwBitLen == 0) ||
        (dwBitLen % 16 != 0) ||
        (dwBitLen > 16384))
    {
        goto BadKey;
    }
    m_dwBitLen = dwBitLen;

    dwByteLen1 = dwBitLen / 8;
    dwByteLen2 = dwByteLen1 / 2;

    if (dwDataLen != (bPrivate ? (9 * dwByteLen2) : dwByteLen1))
    {
        goto BadKey;
    }

    dwBufferSize1 = BigNum::GetBufferSize(dwByteLen1);
    dwBufferSize2 = BigNum::GetBufferSize(dwByteLen2);

    m_dwSize = BigNum::GetBufferSize(sizeof(DWORD)) + 
            (bPrivate ? (2 * dwBufferSize1 + 5 * dwBufferSize2) : dwBufferSize1);
    pb = (BYTE*)malloc(m_dwSize);
    if (pb == NULL)
    {
        SetLastError(ERROR_OUTOFMEMORY);
        return FALSE;
    }
    m_pBlob = pb;

    m_pExponent = (BigNum*)pb;
    pb += BigNum::GetBufferSize(sizeof(DWORD));
    BigNum::SetBytes(m_pExponent, (BYTE*)&pRSAPubKey->pubexp, sizeof(DWORD));

#define HELPER(m_pMember, size) \
    m_pMember = (BigNum*)pb; \
    pb += dwBufferSize##size; \
    BigNum::SetBytes(m_pMember, pbData, dwByteLen##size); \
    pbData += dwByteLen##size;

    HELPER(m_pModulus, 1);

    if (!bPrivate)
        return TRUE;

    HELPER(m_pPrime1, 2);
    HELPER(m_pPrime2, 2);
    HELPER(m_pExponent1, 2);
    HELPER(m_pExponent2, 2);
    HELPER(m_pCoefficient, 2);
    HELPER(m_pPrivateExponent, 1);
#undef HELPER

    if (!CheckKey())
    {
        ClearStack();
        goto BadKey;
    }

    ClearStack();

    GetProvider()->SetSignatureKey(this);
    return TRUE;

BadKey:
    SetLastError(NTE_BAD_KEY);
    return FALSE;
}
Example #19
0
void FrameMain::OnSubtitlesOpen() {
	UpdateTitle();
	auto vc = context->videoController;

	/// @todo figure out how to move this to the relevant controllers without
	///       prompting for each file loaded/unloaded

	// Load stuff from the new script
	auto video     = config::path->MakeAbsolute(context->ass->GetScriptInfo("Video File"), "?script");
	auto vfr       = config::path->MakeAbsolute(context->ass->GetScriptInfo("VFR File"), "?script");
	auto keyframes = config::path->MakeAbsolute(context->ass->GetScriptInfo("Keyframes File"), "?script");
	auto audio     = config::path->MakeAbsolute(context->ass->GetScriptInfo("Audio URI"), "?script");

	bool videoChanged     = !blockVideoLoad && video != vc->GetVideoName();
	bool timecodesChanged = vfr != vc->GetTimecodesName();
	bool keyframesChanged = keyframes != vc->GetKeyFramesName();
	bool audioChanged     = !blockAudioLoad && audio != context->audioController->GetAudioURL();

	// Check if there is anything to change
	int autoLoadMode = OPT_GET("App/Auto/Load Linked Files")->GetInt();
	if (autoLoadMode == 0 || (!videoChanged && !timecodesChanged && !keyframesChanged && !audioChanged)) {
		SetDisplayMode(1, 1);
		return;
	}

	if (autoLoadMode == 2) {
		if (wxMessageBox(_("Do you want to load/unload the associated files?"), _("(Un)Load files?"), wxYES_NO | wxCENTRE, this) != wxYES) {
			SetDisplayMode(1, 1);
			if (vc->IsLoaded() && vc->GetProvider()->GetColorSpace() != context->ass->GetScriptInfo("YCbCr Matrix"))
				vc->Reload();
			return;
		}
	}

	if (audioChanged)
		blockAudioLoad = true;

	// Video
	if (videoChanged) {
		vc->SetVideo(video);
		if (vc->IsLoaded()) {
			vc->JumpToFrame(context->ass->GetUIStateAsInt("Video Position"));

			std::string arString = context->ass->GetUIState("Video Aspect Ratio");
			if (boost::starts_with(arString, "c")) {
				double ar = 0.;
				agi::util::try_parse(arString.substr(1), &ar);
				vc->SetAspectRatio(ar);
			}
			else {
				int ar = 0;
				if (agi::util::try_parse(arString, &ar) && ar >= 0 && ar < 4)
					vc->SetAspectRatio((AspectRatio)ar);
			}

			double videoZoom = 0.;
			if (agi::util::try_parse(context->ass->GetUIState("Video Zoom Percent"), &videoZoom))
				context->videoDisplay->SetZoom(videoZoom);
		}
	}
	else if (vc->IsLoaded() && vc->GetProvider()->GetColorSpace() != context->ass->GetScriptInfo("YCbCr Matrix"))
		vc->Reload();

	vc->LoadTimecodes(vfr);
	vc->LoadKeyframes(keyframes);

	// Audio
	if (audioChanged) {
		blockAudioLoad = false;
		try {
			if (audio.empty())
				context->audioController->CloseAudio();
			else
				context->audioController->OpenAudio(audio);
		}
		catch (agi::UserCancelException const&) { }
		catch (agi::fs::FileSystemError const& err) {
			wxMessageBox(to_wx(err.GetMessage()), "Error opening audio", wxOK | wxICON_ERROR | wxCENTER, this);
		}
	}

	SetDisplayMode(1, 1);
}