Пример #1
0
	bool InputManager::injectKeyPress(KeyCode _key)
	{
		// проверка на переключение языков
		detectLangShift(_key, true);
		// запоминаем клавишу
		storeKey(_key);

		bool wasFocusKey = isFocusKey();

		//Pass keystrokes to the current active text widget
		if (isFocusKey()) {
			Char ch;
			/*if (mUseOISKeyLayout) {
				ch = _arg.text;
				if (std::find (mCurrentLanguage->second.begin(), mCurrentLanguage->second.end(), ch) == mCurrentLanguage->second.end())
					ch = 0;
			}
			else {*/
				ch = getKeyChar(_key);
			//}
			mWidgetKeyFocus->_onKeyButtonPressed(_key, ch);
		}

		return wasFocusKey;
	}
Пример #2
0
VOID WINAPI ServiceStop()
{
    debug(D_NOTICE, "ServiceStop");
    bStop=TRUE;
    disconnect_pipe();
    unmount();
    ReportStatusToSCMgr(SERVICE_STOPPED, NO_ERROR, 0);
    storeKey(KEY_DELETE, "");
}
Пример #3
0
	bool InputManager::injectKeyPress(KeyCode _key, Char _text)
	{
		// проверка на переключение языков
		firstEncoding(_key, true);

		// запоминаем клавишу
		storeKey(_key, _text);

		bool wasFocusKey = isFocusKey();

		//Pass keystrokes to the current active text widget
		if (isFocusKey())
		{
			mWidgetKeyFocus->_riseKeyButtonPressed(_key, _text);
		}

		return wasFocusKey;
	}
Пример #4
0
static void getDataFromRegistry(const char* key, char data[MAX_PATH])
{
    HRESULT hr;
    char buffer[MAX_PATH];
    DWORD cbDataSize = sizeof(buffer);
    HKEY hKey;
    hr = RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGISTRY_KEY_PCLOUD, 0, KEY_READ, &hKey);
    if (hr)
    {
        storeKey(key, "");
        hr = RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGISTRY_KEY_PCLOUD, 0, KEY_READ, &hKey);
    }
    if (!hr)
    {
        hr = RegQueryValueExA(hKey, key, NULL, NULL, (LPBYTE)data, &cbDataSize);
        RegCloseKey(hKey);
    }
}
Пример #5
0
VOID WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
{
    debug(D_NOTICE, "Called service main %d .", bStop);

    if (bStop) return;

    sshStatusHandle = RegisterServiceCtrlHandler(SZSERVICENAME, service_ctrl);
    if (sshStatusHandle)
    {
        ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
        ssStatus.dwServiceSpecificExitCode = 0;

        if (ReportStatusToSCMgr(SERVICE_START_PENDING, NO_ERROR, 3000))
            ServiceStart(NULL);

        ReportStatusToSCMgr(SERVICE_STOPPED, dwErr, 0);
        storeKey(KEY_DELETE, "");
    }
}
Пример #6
0
VOID WINAPI service_ctrl(DWORD dwCtrlCode)
{
    switch(dwCtrlCode)
    {
        case SERVICE_CONTROL_STOP:
            storeKey(KEY_DELETE, "+");
            debug(D_NOTICE, "SERVICE_CONTROL_STOP");
            ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 0);
            ServiceStop();
            return;
        case SERVICE_CONTROL_SHUTDOWN:
            debug(D_NOTICE, "SERVICE_CONTROL_SHUTDOWN");
            ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 2000);
            ServiceStop();
            return;
        default:
            break;
    }
    ReportStatusToSCMgr(ssStatus.dwCurrentState, NO_ERROR, 0);
}
Пример #7
0
VOID WINAPI ServiceStart(const wchar_t * config_file)
{
    PSID pEveryoneSID = NULL;
    PACL pACL = NULL;
    PSECURITY_DESCRIPTOR pSD = NULL;
    EXPLICIT_ACCESS ea[1];
    SID_IDENTIFIER_AUTHORITY SIDAuthWorld = {SECURITY_WORLD_SID_AUTHORITY};
    SECURITY_ATTRIBUTES sa;

    if(!AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID))
    {
        goto cleanup;
    }

    ZeroMemory(&ea, sizeof(EXPLICIT_ACCESS));
    ea[0].grfAccessPermissions = SPECIFIC_RIGHTS_ALL | STANDARD_RIGHTS_ALL;
    ea[0].grfAccessMode = SET_ACCESS;
    ea[0].grfInheritance= NO_INHERITANCE;
    ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
    ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
    ea[0].Trustee.ptstrName  = (LPTSTR) pEveryoneSID;

    if (SetEntriesInAcl(1, ea, NULL, &pACL))
    {
        goto cleanup;
    }

    pSD = (PSECURITY_DESCRIPTOR) malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
    if(!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
    {
        goto cleanup;
    }
    if (!SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE))
    {
        goto cleanup;
    }
    sa.nLength = sizeof (SECURITY_ATTRIBUTES);
    sa.lpSecurityDescriptor = pSD;
    sa.bInheritHandle = FALSE;

    hPipe = CreateNamedPipe(PIPE_NAME, PIPE_ACCESS_INBOUND,
                            PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
                            1, 0, sizeof(mount_params), 0, &sa);
    mount_params params;
    ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0);
    while (!bStop)
    {
        DWORD read = 0, total;
        if (hPipe != INVALID_HANDLE_VALUE)
        {
            debug(D_NOTICE, "Service main - Connecting pipe...");
            if (!ConnectNamedPipe(hPipe, NULL))
            {
                Sleep(500);
                debug(D_ERROR, "Service main - failed to connect pipe %lu ...", GetLastError());
                continue;
            }
            debug(D_NOTICE, "Service main - Connected pipe...");
        }
        else
        {
            debug(D_ERROR, "Service main - Braking because of broken pipe.");
            break;
        }

        debug(D_NOTICE, "Service main - received command");

        if (ReadFile(hPipe, &params, sizeof(mount_params), &read, NULL))
        {
            total = read;
            while (read && total < sizeof(mount_params))
            {
                if (!ReadFile(hPipe, ((char*)&params+total), sizeof(mount_params)-total, &read, NULL))
                {
                    read = 0;
                    debug(D_ERROR, "Service main - error inner read data from pipe");
                }
                total += read;
            }

            if (total == sizeof(mount_params))
            {
                if ((params.options & OPT_MASK_COMMAND) == OPT_COMMAND_MOUNT)
                {
                    debug(D_NOTICE, "Service main - mounting, %s", params.auth);
                    mount(&params);
                    Sleep(200); // wait thread to start
                }
                else
                {
                    debug(D_NOTICE, "Service main - unmounting");
                    DisconnectNamedPipe(hPipe);
                    unmount();
                }
            }
        }
        else
        {
            debug(D_ERROR, "Service main - error read data from pipe");
        }
        DisconnectNamedPipe(hPipe);
    }

cleanup:
    if (pEveryoneSID) FreeSid(pEveryoneSID);
    if (pACL) free(pACL);
    if (pSD) free(pSD);

    ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 0);

    disconnect_pipe();
    unmount();

    ReportStatusToSCMgr(SERVICE_STOPPED, NO_ERROR, 0);
    storeKey(KEY_DELETE, "");

    debug(D_NOTICE, "Service main - exit");
}