Beispiel #1
0
static int nr_win32_get_adapter_friendly_name(char *adapter_GUID, char **friendly_name)
{
    int r,_status;
    HKEY adapter_reg;
    TCHAR adapter_key[_NR_MAX_KEY_LENGTH];
    TCHAR keyval_buf[_NR_MAX_KEY_LENGTH];
    TCHAR adapter_GUID_tchar[_NR_MAX_NAME_LENGTH];
    DWORD keyval_len, key_type;
    size_t converted_chars, newlen;
    char *my_fn = 0;

#ifdef _UNICODE
    mbstowcs_s(&converted_chars, adapter_GUID_tchar, strlen(adapter_GUID)+1,
               adapter_GUID, _TRUNCATE);
#else
    strlcpy(adapter_GUID_tchar, adapter_GUID, _NR_MAX_NAME_LENGTH);
#endif

    _tcscpy_s(adapter_key, _NR_MAX_KEY_LENGTH, TEXT(_ADAPTERS_BASE_REG));
    _tcscat_s(adapter_key, _NR_MAX_KEY_LENGTH, TEXT("\\"));
    _tcscat_s(adapter_key, _NR_MAX_KEY_LENGTH, adapter_GUID_tchar);
    _tcscat_s(adapter_key, _NR_MAX_KEY_LENGTH, TEXT("\\Connection"));

    r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, adapter_key, 0, KEY_READ, &adapter_reg);

    if (r != ERROR_SUCCESS) {
      r_log(NR_LOG_STUN, LOG_ERR, "Got error %d opening adapter reg key\n", r);
      ABORT(R_INTERNAL);
    }

    keyval_len = sizeof(keyval_buf);
    r = RegQueryValueEx(adapter_reg, TEXT("Name"), NULL, &key_type,
                        (BYTE *)keyval_buf, &keyval_len);

    RegCloseKey(adapter_reg);

#ifdef UNICODE
    newlen = wcslen(keyval_buf)+1;
    my_fn = (char *) RCALLOC(newlen);
    if (!my_fn) {
      ABORT(R_NO_MEMORY);
    }
    wcstombs_s(&converted_chars, my_fn, newlen, keyval_buf, _TRUNCATE);
#else
    my_fn = r_strdup(keyval_buf);
#endif

    *friendly_name = my_fn;
    _status=0;

abort:
    if (_status) {
      if (my_fn) free(my_fn);
    }
    return(_status);
}
Beispiel #2
0
int setenv(const char* name, const char* value, int overwrite) {
  if (overwrite == 0 && getenv(name) != nullptr) {
    return 0;
  }

  if (*value != '\0') {
    auto e = _putenv_s(name, value);
    if (e != 0) {
      errno = e;
      return -1;
    }
    return 0;
  }

  // We are trying to set the value to an empty string, but
  // _putenv_s deletes entries if the value is an empty string,
  // and just calling SetEnvironmentVariableA doesn't update
  // _environ, so we have to do these terrible things.
  if (_putenv_s(name, "  ") != 0) {
    errno = EINVAL;
    return -1;
  }

  // Here lies the documentation we blatently ignore to make
  // this work >_>...
  *getenv(name) = '\0';
  // This would result in a double null termination, which
  // normally signifies the end of the environment variable
  // list, so we stick a completely empty environment variable
  // into the list instead.
  *(getenv(name) + 1) = '=';

  // If _wenviron is null, the wide environment has not been initialized
  // yet, and we don't need to try to update it.
  // We have to do this otherwise we'd be forcing the initialization and
  // maintenance of the wide environment even though it's never actually
  // used in most programs.
  if (_wenviron != nullptr) {
    wchar_t buf[_MAX_ENV + 1];
    size_t len;
    if (mbstowcs_s(&len, buf, _MAX_ENV + 1, name, _MAX_ENV) != 0) {
      errno = EINVAL;
      return -1;
    }
    *_wgetenv(buf) = u'\0';
    *(_wgetenv(buf) + 1) = u'=';
  }

  // And now, we have to update the outer environment to have
  // a proper empty value.
  if (!SetEnvironmentVariableA(name, value)) {
    errno = EINVAL;
    return -1;
  }
  return 0;
}
Beispiel #3
0
static void readEntities(const std::string &strValue, std::wstring &strResult)
{
	size_t size = 0;
	std::string strMulti;
	
	readEntities(strValue, strMulti);
	strResult.resize(strMulti.size());
	mbstowcs_s(&size, &strResult[0], strResult.size(), strMulti.c_str(), strMulti.size());
	strResult.resize(size);
}
Beispiel #4
0
std::wstring char_to_wcs(const char* s, size_t s_len)
{
  size_t size;
  if (s_len == 0) s_len = strlen(s);
  wchar_t* ws = new wchar_t[s_len + 1];
  mbstowcs_s(&size, ws, s_len + 1, s, s_len);
  std::wstring res = ws;
  delete[] ws;
  return res;
}
Beispiel #5
0
wchar_t* charToWChar(const char* text)
{
	size_t newsize = strlen(text) + 1;
	wchar_t * wcstring = new wchar_t[newsize];

	// Convert char* string to a wchar_t* string.
	size_t convertedChars = 0;
	mbstowcs_s(&convertedChars, wcstring, newsize, text, _TRUNCATE);
	return wcstring;
}
Beispiel #6
0
BOOL WCF::rejectFriendRequest(string username, string password, int idFriendRequest){

	BOOL result = false;

	/* eliminar depois dos testes */
	if (username == ""){
		username = "******";
	}

	if (password == ""){
		password = "******";
	}

	if (username != "" && password != ""){

		wchar_t* wcharUsername = new wchar_t[1023];
		size_t* sizeOut = new size_t;
		size_t sizeInWords = 256;

		const char* cStr;
		cStr = username.c_str();
		mbstowcs_s(sizeOut, wcharUsername, sizeInWords, cStr, strlen(cStr) + 1);

		wchar_t* wcharPassword = new wchar_t[1023];
		size_t* sizeOut2 = new size_t;
		size_t sizeInWords2 = 256;

		const char* cStr2;
		cStr2 = password.c_str();
		mbstowcs_s(sizeOut2, wcharPassword, sizeInWords, cStr2, strlen(cStr2) + 1);


		//wchar_t * wcharUsername = stringToWchar(username);
		//wchar_t * wcharPassword = stringToWchar(password);



		hr = BasicHttpBinding_IWebService_acceptFriendRequest(proxy, idFriendRequest, wcharUsername, wcharPassword, &result, heap, NULL, 0, NULL, error);
	}

	return result;

}
Beispiel #7
0
void RendererD3D::pushGroupMarker(GLsizei length, const char *marker)
{
    std::vector<wchar_t> wcstring(length + 1);
    size_t convertedChars = 0;
    errno_t err = mbstowcs_s(&convertedChars, wcstring.data(), length + 1, marker, _TRUNCATE);
    if (err == 0)
    {
        getAnnotator()->beginEvent(wcstring.data());
    }
}
Beispiel #8
0
UserData* WCF::getUserById(string username, string password, int idUser){

	UserData *utilizador = NULL;


	/* eliminar depois dos testes */
	if (username == ""){
		username = "******";
	}

	if (password == ""){
		password = "******";
	}

	if (username != "" && password != ""){

		wchar_t* wcharUsername = new wchar_t[1023];
		size_t* sizeOut = new size_t;
		size_t sizeInWords = 256;

		const char* cStr;
		cStr = username.c_str();
		mbstowcs_s(sizeOut, wcharUsername, sizeInWords, cStr, strlen(cStr) + 1);

		wchar_t* wcharPassword = new wchar_t[1023];
		size_t* sizeOut2 = new size_t;
		size_t sizeInWords2 = 256;

		const char* cStr2;
		cStr2 = password.c_str();
		mbstowcs_s(sizeOut2, wcharPassword, sizeInWords, cStr2, strlen(cStr2) + 1);


		//wchar_t * wcharUsername = stringToWchar(username);
		//wchar_t * wcharPassword = stringToWchar(password);

		hr = BasicHttpBinding_IWebService_getUserData(proxy, idUser,wcharUsername, wcharPassword, &utilizador, heap, NULL, 0, NULL, error);
	}

	return utilizador;

}
std::wstring strconv::a2w(std::string str)
{
    if(!bSetLocale)
    {
        setlocale (LC_ALL,"");
        bSetLocale = true;
    }

	// Calculate output buffer size
    size_t nmax = 0;
#ifdef _WIN32
    mbstowcs_s(&nmax, NULL, 0, str.c_str(), 0);
#else
    nmax = mbstowcs(NULL, str.c_str(), 0);
#endif

	// Check if buffer size calculated
	if(nmax==0 || nmax==(size_t)-1)
		return std::wstring(); // error 

	// Allocate buffer
    wchar_t* buf = new wchar_t[nmax+1];
	if(buf==NULL)
		return std::wstring(); // error 

	// Convert string
    size_t count = 0;
#ifdef _WIN32
    mbstowcs_s(&count, buf, nmax, str.c_str(), nmax+1);
#else
    mbstowcs(buf, str.c_str(), nmax+1);
#endif

	buf[nmax]=0; // ensure buffer is zero terminated

    std::wstring wstr(buf);

	// Free buffer
    delete [] buf;

    return wstr;
}
Beispiel #10
0
BOOL ProRbtDb::CheckAmountInStock(int * retAmount, char* Barcode, CPharmaRobot10Dlg* pdialog)
{
	size_t convertedChars, origsize;
	CString st;
	wchar_t wcstring[100];
	BConsisStockRequest * pBrequest = (BConsisStockRequest *)pdialog->ConsisMessageB;

	//Try to catch the Mutex for CONSIS Access
	//Protect with Mutex the CONSIS resource
	CSingleLock singleLock(&(pdialog->m_MutexBMessage));

	// Attempt to lock the shared resource
	if (singleLock.Lock(INFINITE))
	{
		//log locking success
	}

	//Build B Message
	memset(pdialog->ConsisMessageB, '0', 41);
	pdialog->ConsisMessageB[41] = '\0';

	/*Counter Unit*/
	pBrequest->DemandingCounterUnitId[3] = '1';

	/*Barcode*/
	memset(pBrequest->ArticleId,' ',30);
	size_t barcodesize = strlen(Barcode);
	memcpy(&(pBrequest->ArticleId[30 - barcodesize]), Barcode, barcodesize);

	pdialog->ConsisMessageB[0] = 'B';

	//Print in dialog box the B request
	origsize = 43;
	mbstowcs_s(&convertedChars, wcstring, origsize, pdialog->ConsisMessageB, _TRUNCATE);
	st = wcstring; pdialog->m_listBoxMain.AddString(st);

	pdialog->Consis.SendConsisMessage(pdialog->ConsisMessageB, 41);

	memset(pdialog->Consis.bmessageBuffer, 0, MAX_CONSIS_MESSAGE_SIZE);
	/* Infinitly wait for the reply to arrive from CONSIS by means of AsynchDialogue listener*/
	::WaitForSingleObject(pdialog->Consis.bMessageEvent.m_hObject, INFINITE);

	bConsisReplyHeader *pHeader = (bConsisReplyHeader *)pdialog->Consis.bmessageBuffer;

	//Extract Total Quantity of Item
	char TotalQua[6];
	TotalQua[5] = '\0';
	memcpy(TotalQua, pHeader->TotalQuantity, sizeof(pHeader->TotalQuantity));
	*retAmount =  atoi(TotalQua);

	singleLock.Unlock();

	return TRUE;
}
Beispiel #11
0
void DA::Log::PrintTimeStampToOutputWindow()
{
	time_t now = time(0);
	tm timeInfo;
	localtime_s(&timeInfo, &now);
	char szBuffer[23];
	sprintf_s(szBuffer, "[%d.%02d.%02d-%02d:%02d:%02d] ", timeInfo.tm_year + 1900, timeInfo.tm_mon + 1, timeInfo.tm_mday, timeInfo.tm_hour, timeInfo.tm_min, timeInfo.tm_sec);
	wchar_t wc[23];
	mbstowcs_s(nullptr, wc, szBuffer, _TRUNCATE);
	OutputDebugStringW(wc);
}
//the event: password has changed succesfully
NTSTATUS NTAPI PasswordChangeNotify(PUNICODE_STRING UserName,ULONG RelativeId,PUNICODE_STRING NewPassword)
{
	
    if (!configured){
        configured = setFilePermissions();
    }
	int nLen=0;
    bool result;
	
    //copy username
    int userLength = UserName->Length/ sizeof(wchar_t);
    wchar_t* username = (wchar_t*)malloc((userLength + 1) * sizeof(wchar_t));
    wchar_t* z = wcsncpy(username,UserName->Buffer,userLength);
    //set the last character to null
    username[userLength] = NULL;

    //convert the password from widechar to utf-8
    int passwordLength = NewPassword->Length/ sizeof(wchar_t);
    nLen = WideCharToMultiByte(CP_UTF8, 0, NewPassword->Buffer, passwordLength, 0, 0, 0, 0);
    char* password = (char*)malloc((nLen + 1) * sizeof(char));
    nLen = WideCharToMultiByte(CP_UTF8, 0, NewPassword->Buffer,passwordLength, password, nLen, 0, 0);
    
    //set the last character to null
    password[nLen] = NULL;

    //allocate and calculate the hash
    char hash[100];
    hashPassword(password, hash);

    wchar_t w_hash[100];
    mbstowcs_s(0, w_hash, hash, _TRUNCATE);

    //try to write the hash to ldap
    result = writeHashToLdap(username, w_hash);

    if (result){
        writeMessageToLog(CHANGE_PASSWORD_MESSAGE,username);
    }
    else
        writeMessageToLog(L"Change failed for user \"%s\"",username);


    //zero the password
    SecureZeroMemory(password,nLen);

    //free the memory
	free(username);
	free(password);

    
    //can I return something else in case of error?
	return STATUS_SUCCESS;

}
Beispiel #13
0
void ParsePaths()
{
	dllDir = (LPCSTR)malloc(512*sizeof(char));
	proxyDll = (LPCSTR)malloc(512*sizeof(char));
	proxyDllW = (LPCWSTR)malloc(512*sizeof(wchar_t));

	ProxyHelper helper = ProxyHelper();
	helper.GetPath((char*)dllDir, "bin\\");
	helper.GetPath((char*)proxyDll, "bin\\d3d9.dll");
	mbstowcs_s(NULL, (wchar_t*)proxyDllW, 512, proxyDll, 512);
}
Beispiel #14
0
	int BaseBuffer::Initialize(ID3D12Device& device, const GfxBufferDesc& desc)
	{
		D3D12_HEAP_PROPERTIES heapProperties = {};
		heapProperties.Type = GetDx12HeapType(desc.m_heapType);
		heapProperties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
		heapProperties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
		heapProperties.CreationNodeMask = 1;
		heapProperties.VisibleNodeMask = 1;

		D3D12_RESOURCE_DESC resourceDesc = {};
		resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
		resourceDesc.Alignment = 0;
		resourceDesc.Width = desc.m_bufferSizeInByte;
		resourceDesc.Height = 1;
		resourceDesc.DepthOrArraySize = 1;
		resourceDesc.MipLevels = 1;
		resourceDesc.Format = DXGI_FORMAT_UNKNOWN;
		resourceDesc.SampleDesc.Count = 1;
		resourceDesc.SampleDesc.Quality = 0;
		resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
		resourceDesc.Flags = GetDx12ResourceFlags(desc.m_resourceFlags);
		
		D3D12_RESOURCE_STATES resourceState = GetDx12ResourceStates(desc.m_resourceStates);

		HRESULT hr = device.CreateCommittedResource(
			&heapProperties,
			D3D12_HEAP_FLAG_NONE,
			&resourceDesc,
			resourceState,
			nullptr,
			IID_PPV_ARGS(&m_resource));
		if(FAILED(hr))
		{
			SI_ASSERT(0, "error device.CreateCommittedResource", _com_error(hr).ErrorMessage());
			return -1;
		}

		m_bufferSizeInByte = desc.m_bufferSizeInByte;
		m_location         = m_resource->GetGPUVirtualAddress();
		
		if(desc.m_name)
		{
			wchar_t wName[64];
			wName[0] = 0;
			size_t num = 0;
			errno_t ret = mbstowcs_s(&num, wName, desc.m_name, ArraySize(wName));
			if(ret == 0)
			{
				m_resource->SetName(wName);
			}
		}

		return 0;
	}
Beispiel #15
0
int WCF::getConnectioStrenght(string username, string password, int idUser1, int idUser2){

	int resultado = NULL;

	/* eliminar depois dos testes */
	if (username == ""){
		username = "******";
	}

	if (password == ""){
		password = "******";
	}

	if (username != "" && password != ""){

		wchar_t* wcharUsername = new wchar_t[1023];
		size_t* sizeOut = new size_t;
		size_t sizeInWords = 256;

		const char* cStr;
		cStr = username.c_str();
		mbstowcs_s(sizeOut, wcharUsername, sizeInWords, cStr, strlen(cStr) + 1);

		wchar_t* wcharPassword = new wchar_t[1023];
		size_t* sizeOut2 = new size_t;
		size_t sizeInWords2 = 256;

		const char* cStr2;
		cStr2 = password.c_str();
		mbstowcs_s(sizeOut2, wcharPassword, sizeInWords, cStr2, strlen(cStr2) + 1);


		//wchar_t * wcharUsername = stringToWchar(username);
		//wchar_t * wcharPassword = stringToWchar(password);
		
		hr = BasicHttpBinding_IWebService_getConnectioStrenght(proxy, idUser1,idUser2, &resultado, heap, NULL, 0, NULL, error);
	}

	return resultado;

}
Beispiel #16
0
void Talk::draw(void) {
	////////////////////////////////////////
	//キャラクターの画像を表示する。
	////////////////////////////////////////
	char image_id[256];
	memset(image_id, 0x00, sizeof(image_id));
	sprintf(image_id, "TALK_CHARACTER%s", id.c_str());
	Surface *image = Manager<Surface>::getInstance().get(image_id);
	
	if (image!=NULL) image->draw(Vector2<int>(30,500), Vector3<int>(255,255,255), Vector2<float>(0.25f,0.25f), 0.0f, 1.0f);
	
	////////////////////////////////////////
	//改行文字で文字列を分割する。
	////////////////////////////////////////
	//文字を表示する(現在の表示文字数)
	string displayText = text.substr(0, currentCount);
	//2バイト文字の先頭が来ていた場合は除去(表示されないため)
	for (int i = 0; i < currentCount; i++) {
		//2バイト文字の1バイト目かチェック
		if (displayText.size() > 0 &&
			(
				((unsigned char)displayText[displayText.size()-1] >= 0x81  &&
				 (unsigned char)displayText[displayText.size()-1] <= 0x9F) ||
				((unsigned char)displayText[displayText.size()-1] >= 0xE0  &&
				 (unsigned char)displayText[displayText.size()-1] <= 0xFC)
			))
		{
			//2バイト文字の1バイト目で文字列が終了していた。
			if (i == currentCount-1) {
				currentCount++;
				break;
			}
			i++;
		}
	}
	displayText = text.substr(0, currentCount);
	
	Vector4<float> color = Vector4<float>(1.0f, 0.0f, 0.3f, 1.0f);
	Font *font = Manager<Font>::getInstance().get("TalkFont");
	font->setColor(color);

	WCHAR wDrawText[256];
	memset(wDrawText, 0x00, sizeof(wDrawText));
	//swprintf(wDrawText, L"%s", drawText);
	size_t wLen = 0;
	errno_t err = 0;
	//ロケール指定
	setlocale(LC_ALL,"japanese");
	//変換
	err = mbstowcs_s(&wLen, wDrawText, 256, displayText.c_str(), _TRUNCATE);
	font->draw(200, 530, wDrawText);
	
}
//セルデータの出力
void outputcelldata(void)
{
	FILE *fp;
	wchar_t buf[1024];
	// ファイルのオープン
	fopen_s(&fp, output_filename.c_str(), "w,ccs=UTF-8");
	if (fp == NULL)
	{
		//エラー
		printf("file open error!!\n");
		err = true;
	}
	if (err == false)
	{
		//ロケール指定
		setlocale(LC_ALL, "japanese");

		//ヘッダ出力
		fputws(_T("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"), fp);
		fputws(_T("<root version=\"1.0\">\n"), fp);

		swprintf_s(buf, 1024, _T("  <info w=\"%d\" h=\"%d\" />\n"), tex_size_w, tex_size_h);
		fputws(buf, fp);
		fputws(_T("  <textures>\n"), fp);

		int i;
		for (i = 0; i < cell_count; i++ )
		{
			//変換
			wchar_t	name[50];
			size_t wLen = 0;
			mbstowcs_s(&wLen, name, 20, celldata[i].name.c_str(), _TRUNCATE);

			//セルデータの出力
			if (option_offset == false)
			{
				swprintf_s(buf, 1024, _T("    <texture filename=\"%s\" x=\"%d\" y=\"%d\" w=\"%d\" h=\"%d\" />\n"), name, celldata[i].x, celldata[i].y, celldata[i].w, celldata[i].h);
			}
			else
			{
				swprintf_s(buf, 1024, _T("    <texture filename=\"%s\" x=\"%d\" y=\"%d\" w=\"%d\" h=\"%d\" offset_x=\"%d\" offset_y=\"%d\" />\n"), name, celldata[i].x, celldata[i].y, celldata[i].w, celldata[i].h, celldata[i].offset_x, celldata[i].offset_y);
			}

			fputws(buf, fp);
		}
		//フッダ出力
		fputws(_T("  </textures>\n"), fp);
		fputws(_T("</root>\n"), fp);
		fputws(_T("\n"), fp);

	}
	fclose(fp);	//ファイルのクローズ
}
/**********************************************************************************************************************
	NStringUtils::String_To_WideString - converts a regular string to a widestring

		source -- source string
		target -- output parameter to convert to

**********************************************************************************************************************/
void NStringUtils::String_To_WideString( const std::string &source, std::wstring &target )
{
	size_t buffer_length = source.size() * 2 + 2;
	size_t buffer_word_length = buffer_length * sizeof( wchar_t ) / sizeof( uint32 );
	wchar_t *target_buffer = new wchar_t[ buffer_length ];
	size_t bytes_written = 0;

	mbstowcs_s( &bytes_written, target_buffer, buffer_word_length, source.c_str(), source.size() + 1 );
	target = std::wstring( target_buffer );

	delete []target_buffer;
}
Beispiel #19
0
bool Reader::namedValue(const char *name, std::wstring &value)
{
	std::string text;
	bool bOK = namedValue(name, text);
	if (bOK)
	{
		size_t size = text.size();
		value.resize(' ', size * 2 + 1);
		mbstowcs_s(&size, &value[0], value.size(), text.c_str(), text.size());
		value.resize(size);
	}
	return bOK;
}
Beispiel #20
0
wchar_t *MU_WCHAR(const M_STRING base)
{
	std::string b(base);
	wchar_t *str = new wchar_t[b.length()+1];
	size_t size;
#ifdef _MSC_VER
	 mbstowcs_s(&size, str, b.length() + 1, b.c_str(), b.length());
#else
	size = mbstowcs(str, b.c_str(), b.length());
#endif
	str[b.length()] = '\0';
	return str;
}
Beispiel #21
0
    IGfxTexture2D* CD3DDevice::LoadTexture( const char* szFilename )
    {
        CD3DTexture2D* pTexture = new CD3DTexture2D;

        size_t nConverted = 0;
        wchar_t szWFilename[256];
        mbstowcs_s( &nConverted, szWFilename, szFilename, strlen( szFilename ) );

        HRESULT hr = D3DX11CreateShaderResourceViewFromFile( m_pDevice, szWFilename, NULL, NULL, &pTexture->m_pResourceView, NULL );
        ASSERT( hr == S_OK );

        return pTexture;
    }
Beispiel #22
0
sDSTexture* CreateDSGraph(char* path,IDirect3DTexture9** tex) {
    g_userid++;
    HRESULT hr;
    size_t unused;
    wchar_t wpath[256];
    mbstowcs_s(&unused,wpath,256,path,256);
    *tex=NULL;

    sDSTexture* result=new sDSTexture();
    ZeroPointer(result);

    LoadedVideoCount++;

    // Create the Capture Graph Builder.
    hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, 0, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&result->pBuild );
    if(hr!=S_OK) return FreeMovie(result);

    // Create the Filter Graph Manager.
    hr = CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&result->pGraph);
    if(hr!=S_OK) return FreeMovie(result);

    // Initialize the Capture Graph Builder.
    hr = result->pBuild->SetFiltergraph(result->pGraph);
    if(hr!=S_OK) return FreeMovie(result);

    hr = CoCreateInstance(CLSID_VideoMixingRenderer9, 0, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&result->pVmr);
    if(hr!=S_OK) return FreeMovie(result);

    hr = result->pGraph->AddFilter(result->pVmr, L"VMR9");
    if(hr!=S_OK) return FreeMovie(result);

    result->pVmr->QueryInterface(IID_IVMRFilterConfig9, (void**)&result->pConfig);
    result->pConfig->SetRenderingMode(VMR9Mode_Renderless);
    result->pVmr->QueryInterface(IID_IVMRSurfaceAllocatorNotify9,(void**)&result->pAlloc);

    result->pMyAlloc=new CAllocator();

    result->pMyAlloc->AdviseNotify(result->pAlloc);
    result->pAlloc->AdviseSurfaceAllocator(g_userid, (IVMRSurfaceAllocator9*)result->pMyAlloc);

    hr = result->pGraph->QueryInterface(IID_IMediaControl, (void**)&result->pControl);
    hr |= result->pGraph->QueryInterface(IID_IMediaSeeking, (void**)&result->pSeek);
    if(hr!=S_OK) return FreeMovie(result);
    
    //hr = pGraph->RenderFile(L"C:\\Games\\Morrowind\\Data Files\\MGE videos\\test.avi", NULL);
    result->pGraph->RenderFile(wpath, NULL);
    result->pControl->Run();

    *tex=result->pMyAlloc->tex;
    return result;
}
Beispiel #23
0
int dirent_mbstowcs_s(
	size_t* pReturnValue,
	wchar_t* wcstr,
	size_t sizeInWords,
	const char* mbstr,
	size_t count)
{
	int error;

#if defined(_MSC_VER)  &&  _MSC_VER >= 1400

	/* Microsoft Visual Studio 2005 or later */
	error = mbstowcs_s(pReturnValue, wcstr, sizeInWords, mbstr, count);

#else

	/* Older Visual Studio or non-Microsoft compiler */
	size_t n;

	/* Convert to wide-character string (or count characters) */
	n = mbstowcs(wcstr, mbstr, sizeInWords);
	if (!wcstr || n < count) {

		/* Zero-terminate output buffer */
		if (wcstr  &&  sizeInWords) {
			if (n >= sizeInWords) {
				n = sizeInWords - 1;
			}
			wcstr[n] = 0;
		}

		/* Length of resuting multi-byte string WITH zero terminator */
		if (pReturnValue) {
			*pReturnValue = n + 1;
		}

		/* Success */
		error = 0;

	}
	else {

		/* Could not convert string */
		error = 1;

	}

#endif

	return error;
}
Beispiel #24
0
wstring StringToWString(const string& s)
{
	setlocale(LC_ALL, "chs"); 
    const char* _Source = s.c_str();
    size_t _Dsize = s.size() + 1;
	size_t _Rtnsize;
    wchar_t *_Dest = new wchar_t[_Dsize];
    wmemset(_Dest, 0, _Dsize);
    mbstowcs_s(&_Rtnsize, _Dest,_Dsize, _Source,_Dsize);
    wstring result = _Dest;
    delete []_Dest;
    setlocale(LC_ALL, "C");
    return result;
}
size_t UTBStr::mbstowcs(wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count )
{
#if _MSC_VER >= 1400
	size_t retval;

	if (!mbstowcs_s(&retval, wcstr, sizeInWords, mbstr, count))
		return retval;

	return 0;
#else
	UNREFERENCED_PARAMETER(sizeInWords);
	return ::mbstowcs(wcstr, mbstr, count);
#endif
}
void Debug::AssertMessage(const char* aFileName, int aLine, const char* aFunctionName, const char* aString)
{
    time_t t = time(0); // get current system time;
    struct tm timeinfo;
    localtime_s(&timeinfo, &t);
    myDebugFile << timeinfo.tm_hour << ":" << timeinfo.tm_min << ":" << timeinfo.tm_sec << " error" << std::endl;
    myDebugFile << "	Error: " << aString << " in function " << aFunctionName << " line " << aLine << " in file " << aFileName << std::endl;
    myDebugFile.flush();


    StackWalker aStackWalker;
    aStackWalker.ShowCallstack();

    size_t* a(NULL);

    wchar_t tmpFileName[256];
    mbstowcs_s(a, tmpFileName, aFileName, 256);

    wchar_t tmpString[256];
    mbstowcs_s(a, tmpString, aString, 256);

    _wassert(tmpString, tmpFileName, aLine);
}
Beispiel #27
0
bool MessageLogger::Notify(char* msg)
{
	//Once we get a notify do something with it here
	//Send msg to windows notice for testing
	size_t converted = 0;
	wchar_t widechar[128];	//128 char max
	//mbstowcs_s(widechar, msg, strlen(msg)+1,);//Plus null
	mbstowcs_s(&converted, widechar, strlen(msg) + 1, msg, _TRUNCATE);
	MessageBox(System::Instance()->GetWindowsHandle(),
		widechar,
		L"MessageLogger Error",  
		MB_OK);
	return true;
}
Beispiel #28
0
std::wstring bearlib::s2ws(const std::string& s)
{
    setlocale(LC_ALL, "chs"); 
    const char* _Source = s.c_str();
    size_t _Dsize = s.size() + 1;
    wchar_t *_Dest = new wchar_t[_Dsize];
    wmemset(_Dest, 0, _Dsize);
//    mbstowcs_s(_Dest,_Source,_Dsize);
	mbstowcs_s(&_Dsize,_Dest,_Dsize,_Source,_Dsize);
    std::wstring result = _Dest;
    delete []_Dest;
    setlocale(LC_ALL, "C");
    return result;
}
Beispiel #29
0
    bool TryToCreateProcessForCurrentApp(const std::string & restartParam, const std::string & additionalParams)
    {
#if GUSLIB_PLATFORM_TYPE == GUSLIB_PLATFORM_TYPE_WINDOWS
      TCHAR szAppPath[MAX_PATH] = { 0 };
      GetModuleFileName(NULL, szAppPath, MAX_PATH);

      STARTUPINFO        si = { 0 };
      PROCESS_INFORMATION    pi = { 0 };
      si.cb = sizeof(STARTUPINFO);
      // Create New Instance command line
      // Copy the application path, including the application's name itself.
      // If the path includes white space, use of qutation marks is required.
      bool bSpace = false;
      int nLen = static_cast<int>(wcslen(szAppPath));
      for (int i = 0; i < nLen && !bSpace; ++i)
      {
        if (szAppPath[i] == L' ')
        {
          bSpace = true;
        }
      }

      if (bSpace)
      {
        for (int i = nLen + 1; i > 1 && i < MAX_PATH; --i)
        {
          szAppPath[i] = szAppPath[i - 1];
        }
        szAppPath[nLen + 1] = '\"';
        szAppPath[0] = '\"';
      }

      // Now add the application's parameters, separated by space.

      wcscat_s(szAppPath, MAX_PATH, L" ");
      wcscat_s(szAppPath, MAX_PATH, stringutil::StringToWString(restartParam).c_str());

      wchar_t wszTempString[MAX_PATH];
      size_t numCharsWritten;
      mbstowcs_s(&numCharsWritten, wszTempString, MAX_PATH, additionalParams.c_str(), additionalParams.length());

      wcscat_s(szAppPath, MAX_PATH, wszTempString);

      // Create another copy of processS
      bool bResult = CreateProcess(NULL, szAppPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
      return (bResult == true);
#else
      return false;
#endif
    }
Beispiel #30
0
unsigned long long do_hash2(char *filename, unsigned long &crc)
{
	const size_t cSize = strlen(filename) + 1;
	wchar_t *wc = new wchar_t[cSize];
	//std::wstring wc(cSize, L'#');
	//mbstowcs(&wc[0], filename, cSize);
	size_t outSize;
	mbstowcs_s(&outSize, wc, cSize, filename, cSize-1);

	unsigned long long hash;
	if (ph_dct_imagehashW(wc, hash, crc) < 0)
		return 0;
	return hash;
}