void CShowActiveDirUsers::GetUserAndDomainNameFromUPN(LPTSTR szUser, 
								LPTSTR szUserName, LPTSTR szDomainName)
{
	ULONG size = 8192;
	TCHAR buffer[8192];

	if ( TranslateName( szUser, NameUserPrincipal, NameSamCompatible, 
										buffer, &size ) )
	{
		// we UPN name
		TCHAR  szSeparators[] = L"\\";
		TCHAR* szToken  = L"";

		szToken = _tcstok( buffer, szSeparators );

		// domain
		_tcsupr(szToken);
		_tcscpy(szDomainName, szToken);

		// user name
		szToken = wcstok( NULL, szSeparators );
		_tcslwr(szToken);
		_tcscpy(szUserName, szToken);

	}
}
Exemplo n.º 2
0
BOOL KImageModule::EnumSymbolsCallback(LPSTR SymbolName, ULONG SymbolAddress, ULONG SymbolSize) 
{ 
	unsigned callid = 0;
	unsigned parano = 0;

	// translate symbol address SymbolAddress to RVA SymbolAddress - mappedBase
	// translate RVA to pointer within the loaded image
	const unsigned char * p;
	
	if ( m_bLoaded )
		p = GetImagePointer(SymbolAddress);
	else
		p = (const unsigned char *) SymbolAddress;

	// Checking for system service call pattern
	if ( ! IsBadReadPtr(p, 14) )
	if ( (p[0]==0xB8) &&												  // mov eax, <callid>
		 (p[5]==0x8D) && (p[6]==0x54) && (p[7]==0x24) && (p[8]==0x04) &&  // lea edx, [esp+4]
		 (p[9]==0xCD) && (p[10]==0x2E) )								  // int 2E
	{
		callid = * (unsigned *) (p+1);
			
		if ( p[11]==0xC2 )												  // ret <parasize>	
		    parano = * (unsigned short *) (p+12) / 4;
	}
	
	if ( callid )
	{
		const IMAGEHLP_SYMBOL * pSymbol = ImageGetSymbol(SymbolName);

		// print out the RVA, and the symbol name passed to us. 
		if ( m_bForPogy )
		{				
			Output( "D %s(", SymbolName);
			for (unsigned i=0; i<parano; i++)
			{
				Output("D");
				if ( i != (parano-1) )
					Output(",");
			}
			Output("), %08X, %x\n", pSymbol->Address, callid);
		}
		else
		{
			Output( "syscall(0x%04x, %2d) %08X %s!%s\n", callid, parano, pSymbol->Address, m_modulename, SymbolName); 
	
			ShowFPO(SymbolAddress);
			TranslateName(SymbolName);
		}
		m_nCount ++;
	}

	return TRUE; 
} 
Exemplo n.º 3
0
USHORT GetEASName(PVOLINFO pVolInfo, ULONG ulDirCluster, PSZ pszFileName, PSZ * pszEASName)
{
    USHORT rc;

    if (strlen(pszFileName) > FAT32MAXPATH - 4)
        return ERROR_FILENAME_EXCED_RANGE;

    *pszEASName = malloc(FAT32MAXPATH);
    if (!(*pszEASName))
        return ERROR_NOT_ENOUGH_MEMORY;

    if (f32Parms.fUseShortNames)
    {
        rc = TranslateName(pVolInfo, ulDirCluster, pszFileName, *pszEASName, TRANSLATE_SHORT_TO_LONG);
        if (rc)
            strcpy(*pszEASName, pszFileName);
    }
    else
        strcpy(*pszEASName, pszFileName);

    strcat(*pszEASName, EA_EXTENTION);
    return 0;
}
Exemplo n.º 4
0
//---------------------------------------------------------------------------
void __fastcall TFormClientRep::ProcHistory(bool All)
{
	AnsiString Title  = "ѕросмотр истории изменени¤";
	AnsiString FldKey = WrkGData->FieldKey;
	AnsiString TableName = GetPiece(FldKey,"_ID",1).UpperCase();
	int ID = WrkGData->WrkDSet->FieldByName(FldKey)->AsInteger;
	AnsiString FieldNames;
	AnsiString TitleNames;
	AnsiString SS;
	TDBGridEh* Grid = WrkGData->WrkGrid;
	TStringList* FieldNamesList = new TStringList();
	TStringList* TitleNamesList = new TStringList();
	AnsiString AllFieldNames;
	if (All) {
		TDBGridColumnsEh* Columns = Grid->Columns;
		int Cnt = Columns->Count;
		AnsiString S;
		bool KeyIncduded = true;
		for (int i = 0; i < Cnt; i++) {
			 TColumnEh* Column = Columns->Items[i];
			 if (Column->Visible) {
				 AnsiString X = ","+TranslateName(Column->FieldName);
				 if (!AllFieldNames.Pos(X)) {
					 AllFieldNames += X;
					 FieldNames += X ;
					 SS = Column->Title->Caption;
					 TitleNames += "," + GetPiece(SS, "|",1);
					 SS = GetPiece(SS, "|",2);
					 if (SS != "")  TitleNames += "-> " + SS;
					 if (FieldNames.Length() > 230 || TitleNames.Length() > 200) {
						 KeyIncduded = KeyIncduded || FieldNames.Pos("," + FldKey);
						 FieldNames  = FieldNames.SubString(2,1000);
						 TitleNames  = TitleNames.SubString(2,1000);
						 FieldNames  = FieldNames.UpperCase();
						 FieldNamesList->Add(FieldNames);
						 TitleNamesList->Add(TitleNames);
						 FieldNames = "";
						 TitleNames = "";
					 }
				 }
			 }
		}
		if (!KeyIncduded) {
			FieldNames = "," +FldKey + FieldNames  + ",STATUS";
			TitleNames = ",N записи"  + TitleNames + ",—осто¤ние";
		}
		else {
			FieldNames = FieldNames + ",STATUS";
			TitleNames = TitleNames + ",—осто¤ние";
		}
		FieldNames  = FieldNames.SubString(2,1000);
		TitleNames  = TitleNames.SubString(2,1000);
		FieldNames = FieldNames.UpperCase();
		FieldNamesList->Add(FieldNames);
		TitleNamesList->Add(TitleNames);
		FieldNames = "";
		TitleNames = "";

		Title = Title + " всех видимых полей";
	}
	else {
		TColumnEh* Column = Grid->Columns->Items[Grid->Col - 1];
		FieldNames = TranslateName(Column->FieldName);
		SS = Column->Title->Caption;
		TitleNames =  GetPiece(SS, "|",1);
		SS = GetPiece(SS, "|",2);
		if (SS != "")  TitleNames += "-> " + SS;
		Title = Title + " пол¤ > "+ TitleNames + " <";
		FieldNames = FieldNames.UpperCase();
		FieldNamesList->Add(FieldNames);
		TitleNamesList->Add(TitleNames);
	}
	RestValue RestData;
	if (SimpleSelHistoryID(this, 0,Title,TableName,ID,FieldNamesList,TitleNamesList,RestData)) {
//		RestoreValue(RestData,!All);
	}
}
/***
*BOOL __get_qualified_locale - return fully qualified locale
*
*Purpose:
*       get default locale, qualify partially complete locales
*
*Entry:
*       lpInStr - input strings to be qualified
*       lpOutId - pointer to numeric LCIDs and codepage output
*       lpOutStr - pointer to string LCIDs and codepage output
*
*Exit:
*       TRUE if success, qualified locale is valid
*       FALSE if failure
*
*Exceptions:
*
*******************************************************************************/
BOOL __cdecl __get_qualified_locale(const LPLC_STRINGS lpInStr, LPLC_ID lpOutId,
                                    LPLC_STRINGS lpOutStr)
{
    int     iCodePage;

    //  initialize pointer to call locale info routine based on operating system

    if (!pfnGetLocaleInfoA)
    {
        pfnGetLocaleInfoA = IsThisWindowsNT() ? GetLocaleInfoA : crtGetLocaleInfoA;
    }

    if (!lpInStr)
    {
        //  if no input defined, just use default LCID
        GetLcidFromDefault();
    }
    else
    {
        //  convert non-NLS language strings to three-letter abbreviations
        pchLanguage = lpInStr->szLanguage;
        if (pchLanguage && *pchLanguage)
            TranslateName(__rg_language,
                          sizeof(__rg_language) / sizeof(LOCALETAB) - 1,
                          &pchLanguage);

        //  convert non-NLS country strings to three-letter abbreviations
        pchCountry = lpInStr->szCountry;
        if (pchCountry && *pchCountry)
            TranslateName(__rg_country,
                          sizeof(__rg_country) / sizeof(LOCALETAB) - 1,
                          &pchCountry);

        iLcidState = 0;

        if (pchLanguage && *pchLanguage)
        {
            if (pchCountry && *pchCountry)
            {
                //  both language and country strings defined
                GetLcidFromLangCountry();
            }
            else
            {
                //  language string defined, but country string undefined
                GetLcidFromLanguage();
            }
        }
        else
        {
            if (pchCountry && *pchCountry)
            {
                //  country string defined, but language string undefined
                GetLcidFromCountry();
            }
            else
            {
                //  both language and country strings undefined
                GetLcidFromDefault();
            }
        }
    }

    //  test for error in LCID processing
    if (!iLcidState)
        return FALSE;

    //  process codepage value
    iCodePage = ProcessCodePage(lpInStr->szCodePage);

    //  verify codepage validity
    if (!iCodePage || !IsValidCodePage((WORD)iCodePage))
        return FALSE;

    //  verify locale is installed
    if (!IsValidLocale(lcidLanguage, LCID_INSTALLED))
        return FALSE;

    //  set numeric LCID and codepage results
    if (lpOutId)
    {
        lpOutId->wLanguage = LANGIDFROMLCID(lcidLanguage);
        lpOutId->wCountry = LANGIDFROMLCID(lcidCountry);
        lpOutId->wCodePage = (WORD)iCodePage;
    }

    //  set string language, country, and codepage results
    if (lpOutStr)
    {
        if ((*pfnGetLocaleInfoA)(lcidLanguage, LOCALE_SENGLANGUAGE,
                                 lpOutStr->szLanguage, MAX_LANG_LEN) == 0)
            return FALSE;
        if ((*pfnGetLocaleInfoA)(lcidCountry, LOCALE_SENGCOUNTRY,
                                 lpOutStr->szCountry, MAX_CTRY_LEN) == 0)
            return FALSE;
        _itoa((int)iCodePage, (char *)lpOutStr->szCodePage, 10);
    }
    return TRUE;
}