STDMETHODIMP LogicalItem_Processes_Task::GetDisplayName(bool theFullName, TCHAR * theOutName, int * theSize)
{
	LocalizationManagerPtr aL;

	switch (myType)
	{
	case Reveal:
		return aL->GetStringSafe( KEYOF(IDS_APCHITEMS_ITEMPROC_REVEAL), theOutName, theSize);

	case Quit:
		return aL->GetStringSafe( KEYOF(IDS_APCHITEMS_ITEMPROC_QUIT), theOutName, theSize);

	default:
		return E_INVALIDARG;
	}
}
STDMETHODIMP ItemFactory_Processes::GetItemName( const MenuSetItemData * theItem, TCHAR * theOut, int theBufSize )
{
	if (theOut == 0)
		return E_POINTER;

	if (theItem->Size != sizeof MenuSetItemData)
		return E_INVALIDARG;

	int aSize = theBufSize;

	LocalizationManagerPtr aM;
	return aM->GetStringSafe( KEYOF(IDS_APCHITEMS_ITEMPROC), theOut, &aSize);
}
LogicalItem_Processes_Child::LogicalItem_Processes_Child(DWORD theProcessID, HANDLE theHProcess)
	: myProcessID(theProcessID), myActualLength(0), myProcessShortName(myProcessName), myFlags(0)
{
	IProcessNameRetriever * aN = IProcessNameRetriever::Instance();
	myActualLength = aN->GetProcessName(theHProcess, myProcessName, ProcessNameSize);

	if (myActualLength == 0)
	{
		LocalizationManagerPtr aP;
		myActualLength = ProcessNameSize;
		aP->GetStringSafe( KEYOF(IDS_APCHITEMS_ITEMPROC_SYS), myProcessName, &myActualLength);
	}
	else
	{
		TCHAR * aChar = _tcsrchr( myProcessName, _T('\\') );

		if (aChar != 0)
			myProcessShortName = ++aChar; // because the pointer is pointing to the backslash, advance by one character

		myFlags |= NameValid;
	}


	HANDLE aH = GetCurrentProcess();
	BOOL aRes = DuplicateHandle(aH, theHProcess, aH, &myHProcess, PROCESS_TERMINATE|PROCESS_SET_INFORMATION, FALSE, 0);
	if (aRes)     myFlags |= CanQuit|CanEdit;
	else
	{
		aRes = DuplicateHandle(aH, theHProcess, aH, &myHProcess, PROCESS_TERMINATE, FALSE, 0);
		if (aRes)   myFlags |= CanQuit;
		else
		{
			aRes = DuplicateHandle(aH, theHProcess, aH, &myHProcess, PROCESS_SET_INFORMATION, FALSE, 0);
			if (aRes)  myFlags |= CanEdit;
			else       myHProcess = NULL;
		}
	}
}
Exemple #4
0
/*
 * getkey()
 *
 * Returns a key code (if up/down codes being returned),
 * 	a byte of ASCII (if that's requested)
 * 	NOKEY (if no key has been hit).
 */
int getkey ()
{
	register unsigned char keycode, key, entry;
	unsigned char notrepeating;

    while (1) {
	/* Loop til a value-returning key is pressed or buffer is empty */

	if (!bgetp(gp->g_keybuf)) {
		if (gp->g_keyrkey != IDLEKEY) {
			if (gp->g_nmiclock >= gp->g_keyrtime) {
				gp->g_keyrtime = gp->g_keyrtick + gp->g_nmiclock;
				keycode = gp->g_keyrkey;
				notrepeating = 0;  /* We are repeating */
				goto interpretkeycode;
			}
		}
		return (NOKEY); /* Either no autorepeat or no tick yet. */
	}

	bget(gp->g_keybuf, keycode);
	notrepeating = 1;	/* We are not repeating */

interpretkeycode:

	key = KEYOF(keycode);

	if (gp->g_translation == TR_NONE) 
		return (keycode);
	/* The only other value currently supported is TR_ASCII. */

	/* Translate key number and current shifts to an action byte */
	if (gp->g_shiftmask & SHIFTMASK)
		entry = keytables[0]->k_shifted->keymap[key];
	else
		entry = keytables[0]->k_normal ->keymap[key];

	if (notrepeating) {
		register unsigned char enF0;

		enF0 = entry & 0xF0;
		if ((STATEOF(keycode) == PRESSED) &&
/* We might need to add the RESET/IDLE/ERROR entries here.  FIXME? */
		    (NOSCROLL  != entry) &&
		    (SHIFTKEYS != enF0) &&
		    (BUCKYBITS != enF0) ) {
			gp->g_keyrkey = keycode;
			gp->g_keyrtime = gp->g_nmiclock + gp->g_keyrinit;
		} else {
			if (key == KEYOF(gp->g_keyrkey))
				gp->g_keyrkey = IDLEKEY;
		}
	}

	/* If key is going up and is not a reset or shift key, ignore it. */
	if (STATEOF(keycode) != PRESSED) {
		if (keycode == RESETKEY)	/* Reset has key-up bit on */
			entry = RESET;
		else
		     if ((entry&0xF0) != SHIFTKEYS)
			entry = NOP;
	}

	switch (entry >> 4) {

	case 0:
	case 1:
	case 2:
	case 3:
	case 4:
	case 5:
	case 6:
	case 7:
		/* Map normal ascii depending on ctrl, capslock */
		if (gp->g_shiftmask & CTRLMASK) entry &= 0x1F;
		if ((gp->g_shiftmask & CAPSMASK) &&
			(entry >= 'a' && entry <= 'z'))
				entry += 'A' - 'a';
		return entry;

	case SHIFTKEYS >> 4:
		gp->g_shiftmask ^= 1 << (entry & 0x0F);
		break;

	case FUNNY >> 4:
		switch (entry) {
		case NOP:
			break;

		case NOSCROLL:
			if (gp->g_shiftmask & CTLSMASK)	goto sendcq;
			else				goto sendcs;

		case CTRLS:
		sendcs:
			gp->g_shiftmask |= CTLSMASK;
			return (('S'-0x40) /* | gp->g_buckybits */);

		case CTRLQ:
		sendcq:
			gp->g_shiftmask &= ~CTLSMASK;
			return (('Q'-0x40) /* | gp->g_buckybits */);

		case IDLE:
		case RESET:
		gotreset:
			gp->g_shiftmask &= keytables[0]->k_idleshifts;
			gp->g_keyrkey = IDLEKEY;	/* Don't repeat */
			break;

		case ERROR:
			printf("Keyboard error detected\n");
			goto gotreset;

/* Remember when adding new entries that, if they should NOT auto-repeat,
they should be put into the IF statement just above this switch block.
*/
		default:
			goto badentry;
		}
		break;

	/*
	 * Remember when adding new entries that, if they should NOT
	 * auto-repeat, they should be put into the IF statement just above
	 * this switch block.
	 */
	default:
	badentry:
		break;
	}
    }
}
STDMETHODIMP LogicalItem_Processes_Root::GetDisplayName( bool theFullName, TCHAR * theOutName, int * theSize )
{
	LocalizationManagerPtr aM;
	return aM->GetStringSafe( KEYOF(IDS_APCHITEMS_ITEMPROC), theOutName, theSize);
}