Exemplo n.º 1
0
BOOL DisplayAllPrivileges(HANDLE hToken)
{
	BOOL bResult = FALSE;
	DWORD dwSize = 0;
	TOKEN_PRIVILEGES* pTokenPrivilegesInfo = NULL;
	pTokenPrivilegesInfo = (TOKEN_PRIVILEGES*)RetrieveTokenInformation(hToken, TokenPrivileges, dwSize);
	ASSERT_NOTNULLRET(pTokenPrivilegesInfo, FALSE);

	CHAR lpwNameBuf[MAX_PATH] = { 0 };
	DWORD bufSize = 0;
	LUID_AND_ATTRIBUTES *pPrivilegeAttr = NULL;
	for (UINT i = 0; i < pTokenPrivilegesInfo->PrivilegeCount; ++i)
	{
		pPrivilegeAttr = &(pTokenPrivilegesInfo->Privileges[i]);
		bufSize = MAX_PATH - 1;
		if (FALSE == LookupPrivilegeNameA("", &(pTokenPrivilegesInfo->Privileges[i].Luid), lpwNameBuf, &bufSize))
		{
			DOLOG("LookupPrivilegeNameW failed ErrorCocde: " + GetLastError());
			bResult = FALSE;
			break;
		}

		DOLOG("Privilege Name:" + lpwNameBuf + " , Enable: " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_ENABLED)
			+ ", Default Enable: " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_ENABLED_BY_DEFAULT) 
			+ ", Remove : " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_REMOVED)
			+ ", Access: " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_USED_FOR_ACCESS));
		bResult = TRUE;
	}
	free(pTokenPrivilegesInfo);

	return bResult ;
}
Exemplo n.º 2
0
BOOL CNameEvent::Init(LPSTR lpEventName, BOOL bIsCreate)
{
	assert(ISNOTNULL(lpEventName));
	if (ISNULL(lpEventName))
	{ 
		DOLOG("length of Event Name Can't be 0 ");
		return FALSE;
	}
	
	if (ISZERO(strlen(lpEventName)))
	{
		DOLOG("length of Event Name Can't be 0 ");
		return FALSE;
	}

	if (ISNOZERO(strcpy_s(m_cbEventName, _countof(m_cbEventName), lpEventName)))
	{
		DOLOG("copy event name failed !");
		return FALSE;
	}

	if (bIsCreate)
	{
		return this->CreateEvent();
	}
	else
	{
		return this->OpenEvent();
	}
}
Exemplo n.º 3
0
BOOL CNameEvent::Wait()
{
	assert(ISNOTNULL(m_hEvent));
	if (ISNULL(m_hEvent))
	{
		DOLOG("can't wait null event handle!");
		return FALSE;
	}
	DWORD retCode = 0;
	retCode = WaitForSingleObject(m_hEvent, BLOCKOUTTIMEMSEC);

	BOOL isOK = FALSE;
	switch (retCode)
	{
	case WAIT_FAILED:
		DOLOG("wait event failed! " + GetLastError());
		isOK = FALSE;
		break;
	case WAIT_OBJECT_0:
		isOK = TRUE;
		break;
	case WAIT_TIMEOUT:
		DOLOG(" waitforSingleObject Timeout !");
		isOK = FALSE;
	default:
		DOLOG("waitforSingleObject unknown conidtion ! " + GetLastError());
		isOK = FALSE;
	};
	return isOK;
}
Exemplo n.º 4
0
void initEM (INFO *info) {
  unsigned int num_clusters = info -> num_clusters;
  unsigned int i;  /*  Index into w1  */
  unsigned int j;  /*  Index into w2  */
  unsigned int k;  /*  Index into clusters  */
  PROBNODE sum;
  time_t start;
  time_t end;

  time (&start);
  PROGRESS_MSG ("Begin initialization...");

  /*  Assign probabilities to probz  */
  sum = 0.0;
  for (k = 0; k < num_clusters; k++) {
    GET_PROBZ_CURR (k) = RANDOM_FLOAT;
    sum += GET_PROBZ_CURR (k);
  }
  for (k = 0; k < num_clusters; k++) {
    GET_PROBZ_CURR (k) = DOLOG (GET_PROBZ_CURR (k) / sum);
  }

  /*  Assign probabilities to probw1_z  */
  for (i = 0; i < (info -> num_clusters * info -> m); i++) {
    info -> probw1_z_curr[i] = RANDOM_FLOAT;
  }
  for (k = 0; k < num_clusters; k++) {
    sum = 0.0;
    for (i = 0; i < info -> m; i++) {
      sum += GET_PROBW1_Z_CURR (k, i);
    }
    for (i = 0; i < info -> m; i++) {
      GET_PROBW1_Z_CURR (k, i) = DOLOG (GET_PROBW1_Z_CURR (k, i) / sum);
    }
  }

  /*  Assign probabilities to probw2_z  */
  for (i = 0; i < (info -> num_clusters * info -> n); i++) {
    info -> probw2_z_curr[i] = RANDOM_FLOAT;
  }
  for (k = 0; k < num_clusters; k++) {
    sum= 0.0;
    for (j = 0; j < info -> n; j++) {
      sum += GET_PROBW2_Z_CURR (k, j);
    }
    for (j = 0; j < info -> n; j++) {
      GET_PROBW2_Z_CURR (k, j) = DOLOG (GET_PROBW2_Z_CURR (k, j) / sum);
    }
  }

  PROGRESS_MSG ("Initialization complete...");

  time (&end);
  info -> initEM_time += difftime (end, start);

  return;
}
Exemplo n.º 5
0
BOOL WINAPI InjectLibrarySafeA(DWORD threadID, const CHAR*pDLL, DWORD dwLen)
{
	CNameShareMemory shareMemInst;
	shareMemInst.Init(HELPERINJECTIONTARGETIDNAMEA, sizeof(DWORD), TRUE);
	char* lpTargetIDBuffer = shareMemInst.GetBuffer();
	memcpy(lpTargetIDBuffer, &threadID, sizeof(DWORD));

    HMODULE hLib = LoadLibraryA(pDLL);
	DOLOG("Target Thread ID: "+threadID);
    char pSWHEXStr[18];
    SWHEXPROC setWindowsHookEx;
    LPVOID proc;
    HHOOK hook;
    HMODULE hU32;

	if (!hLib)
	{
		DOLOG("LoadLibraryA Failed ! " + GetLastError());
        return FALSE;
	}

    memcpy(pSWHEXStr, "SetWindowsHookExA", 18);         //SetWindowsHookEx with each character obfuscated

#ifdef _WIN64
    proc = GetProcAddress(hLib, "DummyDebugProc");
#else
    proc = GetProcAddress(hLib, "_DummyDebugProc@12");
#endif
    if (!proc)
    {
        FreeLibrary(hLib);
        return FALSE;
    }

    hU32 = GetModuleHandle(TEXT("USER32"));
    setWindowsHookEx = (SWHEXPROC)GetProcAddress(hU32, pSWHEXStr);

    /* this is terrible. */
    hook = setWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)proc, hLib, 0);
	if (!hook)
	{
		DOLOG("setWindowsHookExA Failed !" + GetLastError());
		return FALSE;
	}

	/*
    for (int i = 0; i < 20; i++)
        PostThreadMessage(0, WM_USER + 432, 0, (LPARAM)hook);
    Sleep(1000);
    for (int i = 0; i < 20; i++)
        PostThreadMessage(0, WM_USER + 432, 0, (LPARAM)hook);
	*/
    Sleep(2000);
	UnhookWindowsHookEx(hook);
    FreeLibrary(hLib);
    return TRUE;
}
bool CDuplicateOutputDx11::CreateOutputDuplicator()
{
	SAFE_RELEASE(m_pOutputDuplication);

	HRESULT hRes = S_OK;
	IDXGIDevice* pDxgiDevice = nullptr;

	hRes = m_pDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&pDxgiDevice));
	if (!SUCCEEDED(hRes))
	{
		DOLOG("m_pDevice->QueryInterface failed!");
		return false;
	}
	
	IDXGIAdapter* pDxgiAdapter = nullptr;
	hRes = pDxgiDevice->GetParent(__uuidof(IDXGIAdapter), reinterpret_cast<void**>(&pDxgiAdapter));
	SAFE_RELEASE(pDxgiDevice);
	if (!SUCCEEDED(hRes))
	{
		DOLOG("pDxgiDevice->GetParent failed!");
		return false;
	}
	
	DXGI_ADAPTER_DESC descAdapter;
	pDxgiAdapter->GetDesc(&descAdapter);

	// Get output
	IDXGIOutput* pDxgiOutput = nullptr;
	hRes = pDxgiAdapter->EnumOutputs(0, &pDxgiOutput);
	SAFE_RELEASE(pDxgiAdapter);
	if (!SUCCEEDED(hRes))
	{
		DOLOG("pDxgiAdapter->EnumOutputs failed!");
		return false;
	}

	// Get output1
    IDXGIOutput1* pDxgiOutput1 = nullptr;
    hRes = pDxgiOutput->QueryInterface(__uuidof(IDXGIOutput1), reinterpret_cast<void**>(&pDxgiOutput1));
	SAFE_RELEASE(pDxgiOutput);
    if (!SUCCEEDED(hRes))
    {
		DOLOG("pDxgiOutput->QueryInterface failed!");
		return false;
    }
	
	// Get duplicate
	hRes = pDxgiOutput1->DuplicateOutput(m_pDevice, &m_pOutputDuplication);
	SAFE_RELEASE(pDxgiOutput1);
	if (!SUCCEEDED(hRes))
	{
		DOLOG("pDxgiOutput1->DuplicateOutput");
		return false;
	}
		
	return true;
}
Exemplo n.º 7
0
LRESULT CALLBACK TipPureDeskWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	TipPureDeskWindow *pThis = NULL;
	switch (message)
	{
	case WM_TIMER:
		BringWindowToTop(hWnd);
		break;
	case WM_GETMINMAXINFO:
		pThis = (TipPureDeskWindow*)GetWindowLong(hWnd, GWL_USERDATA);
		if (pThis == NULL)
		{
			DOLOG("have not right TipMsgWindow instance£¡");
			break;
		}
		MINMAXINFO* mmi;
		if (lParam == NULL)
		{
			break;
		}
		mmi = (MINMAXINFO*)lParam;
		mmi->ptMinTrackSize.x = 1;
		mmi->ptMinTrackSize.y = 1;
		mmi->ptMaxTrackSize.x = pThis->m_DesktopRect.right - pThis->m_DesktopRect.left;
		mmi->ptMaxTrackSize.y = pThis->m_DesktopRect.bottom - pThis->m_DesktopRect.top;
		break;
	case WM_PAINT:
		pThis = (TipPureDeskWindow*)GetWindowLong(hWnd, GWL_USERDATA);
		if (pThis == NULL)
		{
			DOLOG("have not right TipMsgWindow instance£¡");
			break;
		}
		hdc = BeginPaint(hWnd, &ps);
		HBRUSH hbr;
		hbr = CreateSolidBrush(RGB(111, 0, 0));
		//pThis->m_DesktopRect.top += 200;
		//DPtoLP(,)
		FillRect(hdc, &pThis->m_DesktopRect, hbr);

		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Exemplo n.º 8
0
// Pure desk window ------------------------------------------------------------------------
BOOL TipPureDeskWindow::InitInstance(HINSTANCE hInstance)
{
	HWND hWnd;
	HWND hwndDesktop = GetDesktopWindow();

	GetWindowRect(hwndDesktop, &m_DesktopRect);
		
	hWnd = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, L"ShowTextTip", L"", WS_VISIBLE,
		m_DesktopRect.left, m_DesktopRect.top, m_DesktopRect.right, m_DesktopRect.bottom, NULL, NULL, hInstance, NULL);
	if (!hWnd)
	{
		DOLOG("CreateWindowExW Failed! ErrorCode:" + GetLastError());
		return FALSE;
	}
	SetWindowLong(hWnd, GWL_USERDATA, (LONG)this);
	LONG_PTR Style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
	Style = Style &~WS_CAPTION &~WS_SYSMENU &~WS_SIZEBOX;
	::SetWindowLongPtr(hWnd, GWL_STYLE, Style);
	
	HWND forgroundWnd = GetForegroundWindow();
	SetWindowPos(hWnd, forgroundWnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
	ShowWindow(hWnd, SW_SHOWNORMAL);
	UpdateWindow(hWnd);
	return TRUE;
}
DuplicatorInfo CDuplicateOutputDx11::GetNewFrame(ID3D11Texture2D** p2dTexture)
{
	DXGI_OUTDUPL_FRAME_INFO frameInfo;
	IDXGIResource* pDesktopResource = nullptr;
	HRESULT hr = S_OK;
	hr = m_pOutputDuplication->AcquireNextFrame(15, &frameInfo, &pDesktopResource);
	if (hr == DXGI_ERROR_ACCESS_LOST)
	{
		return DuplicatorInfo_Lost;
	}
	else if (hr == DXGI_ERROR_WAIT_TIMEOUT)
	{
		return DuplicatorInfo_Timeout;
	}
	else if (hr == DXGI_ERROR_INVALID_CALL)
	{
		return DuplicatorInfo_InvalidCall;
	}
	else if (FAILED(hr))
	{
		return DuplicatorInfo_Error;
	}

	if (FAILED(hr = pDesktopResource->QueryInterface(__uuidof(ID3D11Texture2D), reinterpret_cast<void**>(p2dTexture))))
	{
		SAFE_RELEASE(pDesktopResource);
		DOLOG(" pDesktopResource->QueryInterface failed");
		return DuplicatorInfo_Error;
	}
	
	SAFE_RELEASE(pDesktopResource);
	return DuplicatorInfo_Acquired;
}
Exemplo n.º 10
0
bool EnumSpecificProcessModule(DWORD processID, list<string>& rModuleNames)
{
    HANDLE hProcess = NULL;
    // Get a handle to the process.
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
                           PROCESS_VM_READ,
                           FALSE, processID);
    if (hProcess == NULL)
    {
        DOLOG("打开process:" + processID + "失败");
        return false;
    }

    DWORD needSize = 0;
    if (FALSE == EnumProcessModules(hProcess, NULL, 0, &needSize))
    {
        DOLOG("EnumProcessModules " + processID + "失败 ErrCode:" + GetLastError());
        return false;
    }

    HMODULE *hMods = (HMODULE*)malloc(needSize);
    if (hMods == NULL)
    {
        DOLOG(" malloc 错误");
        return false;
    }
    memset(hMods, 0, needSize);

    UINT fGraphicFeature = 0;
    if (EnumProcessModules(hProcess, hMods, needSize, &needSize))
    {
        for (unsigned int i = 0; i < (needSize / sizeof(HMODULE)); i++)
        {
            CHAR szModName[MAX_PATH] = { 0 };
            // Get the full path to the module's file.
            if (GetModuleFileNameExA(hProcess, hMods[i], szModName, (sizeof(szModName) / sizeof(TCHAR))))
            {
                rModuleNames.push_back(szModName);
                DOLOG(szModName);
            }
        }
    }
    SAFE_FREE(hMods);
    return true;
}
Exemplo n.º 11
0
BOOL CNameEvent::Fire()
{
	assert(ISNOTNULL(m_hEvent));
	if (ISNULL(m_hEvent))
	{
		DOLOG("can't Fire null event handle!");
		return FALSE;
	}
	BOOL bResult = TRUE;
	
	bResult = SetEvent(m_hEvent);
	if (ISNOTTRUE(bResult))
	{
		DOLOG("SetEvent Failed!" + GetLastError());
		bResult = FALSE;
	}
	return bResult;
}
Exemplo n.º 12
0
BOOL CDisplayAdapterHelper::AdjustDllfor64bit(CHAR* cbTargetBuf, UINT uSize, LPSTR lpDllPath)
{
	if (ISNULL(cbTargetBuf))
	{
		DOLOG("cbTargetBuf Can't be null");
		return FALSE;
	}
	
	if (ISNULL(lpDllPath))
	{
		DOLOG("lpDllpath Can't be null !");
		return FALSE;
	}
	
	LPSTR lpDotPos = strrchr(lpDllPath, '.');
	UINT uPos = lpDotPos - lpDllPath;

	return InsertStrInStrSpecifyPosA(cbTargetBuf, uSize, lpDllPath, BIT64, uPos);
}
Exemplo n.º 13
0
BOOL CDisplayAdapterHelper::InjectSpecificDllAndProcessByNameInner(LPSTR lpAppName, LPSTR lpDllName, BOOL bInjectSafeMode)
{
	assert(ISNOTNULL(lpAppName));
	if (ISNULL(lpAppName))
	{
		DOLOG("AppName should not to be null !");
		return FALSE;
	}

	DWORD procid = GetSpecificProcIDByNameEx(lpAppName);

	if (ISZERO(procid))
	{
		DOLOG("GetSpecificProcIDByNameEx Failed");
		return FALSE;
	}

	return InjectSpecificDllAndProcessByIdInner(procid,  lpDllName,  bInjectSafeMode);
}
Exemplo n.º 14
0
// [2015/12/17 wupeng]
// test
//char tempbuf[max_path] = { 0 };
//insertstrinstrspecifyposa(tempbuf, max_path, "my.dll", "64", 2);
//dolog(tempbuf);
//insertstrinstrspecifyposa(tempbuf, max_path, "my.dll", "64", 50);
//dolog(tempbuf);
//insertstrinstrspecifyposa(tempbuf, max_path, "my.dll", "64", strlen("my.dll"));
//dolog(tempbuf);
//insertstrinstrspecifyposa(tempbuf, max_path, "my.dll", "64", 0);
//dolog(tempbuf);
BOOL InsertStrInStrSpecifyPosA(LPSTR lpTarBuf, UINT cBufLen, LPSTR lpSrcStr, LPSTR lpInsertStr, UINT iPos)
{
    if (ISNULL(lpTarBuf)) {
        DOLOG("lpTarBuf NULL !");
        return FALSE;
    }

    if (ISNULL(lpSrcStr)) {
        DOLOG("lpSrcStr NULL !");
        return FALSE;
    }

    if (ISNULL(lpInsertStr)) {
        DOLOG("lpInsertStr NULL !");
        return FALSE;
    }

    UINT cInsertStrLen = (UINT)strlen(lpInsertStr);
    UINT cSrcStrLen = (UINT)strlen(lpSrcStr);

    if (iPos > cSrcStrLen)
    {
        DOLOG("iPos stack overflow !");
        return FALSE;
    }
    ZeroMemory(lpTarBuf, cBufLen);
    UINT cTotalNeed = cSrcStrLen + cInsertStrLen  + 1;

    if (cTotalNeed > cBufLen)
    {
        DOLOG("not enough for fill the result string!");
        return FALSE;
    }

    UINT uCurPos = 0;
    memcpy(lpTarBuf, lpSrcStr, iPos);
    uCurPos += iPos;
    memcpy(lpTarBuf + uCurPos, lpInsertStr, cInsertStrLen);
    uCurPos += cInsertStrLen;
    memcpy(lpTarBuf + uCurPos, lpSrcStr + iPos, cSrcStrLen - iPos);

    return TRUE;
}
Exemplo n.º 15
0
// [2015/12/15 wupeng]
BOOL EnableDebugPrivilege(BOOL bEnableDebugPrivilege)
{
    HANDLE hToken;
    TOKEN_PRIVILEGES tp;
    LUID luid;

    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
    {
        DOLOG("OpenProcessToken Failed "+GetLastError());
        return FALSE;
    }

    if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid))
    {
        DOLOG("LookupPrivilegeValue Failed "+ GetLastError());
        CloseHandle(hToken);
        return FALSE;
    }

    tp.PrivilegeCount = 1;
    tp.Privileges[0].Luid = luid;
    if (bEnableDebugPrivilege)
    {
        tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    }
    else
    {
        tp.Privileges[0].Attributes = 0;
    }

    if (!AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL))
    {
        DOLOG("AdjustTokenPrivileges Failed "+ GetLastError());

        CloseHandle(hToken);
        return FALSE;
    }

    CloseHandle(hToken);

    return TRUE;
}
Exemplo n.º 16
0
BOOL CNameEvent::OpenEvent()
{
	assert(ISNULL(m_hEvent));
	if (ISNOTNULL(m_hEvent))
	{
		DOLOG("the Event already opened!");
		return FALSE;
	}
	
	m_hEvent = OpenEventA(EVENT_MODIFY_STATE, FALSE, m_cbEventName);
	
	assert(ISNOTNULL(m_hEvent));
	if (ISNULL(m_hEvent))
	{
		DOLOG("open Event failed! " + GetLastError());
		return FALSE;
	}

	return TRUE;
}
Exemplo n.º 17
0
bool TipPureDeskWindow::ShowDesktopCoveredWindow()
{
	HINSTANCE hInstance = GetModuleHandle(NULL);
	MyRegisterClass(hInstance);
	if (!InitInstance(hInstance))
	{
		DOLOG("InitInstance Failed! ErrorCode:" + GetLastError());
		return false;
	}
	return true;
}
Exemplo n.º 18
0
BOOL CNameEvent::CreateEvent()
{
	assert(ISNULL(m_hEvent));
	if (ISNOTNULL(m_hEvent))
	{
		DOLOG("the Event already created!");
		return FALSE;
	}

	m_hEvent = CreateEventA(NULL,
							TRUE,
							FALSE,
							m_cbEventName);
	assert(ISNOTNULL(m_hEvent));
	if (ISNULL(m_hEvent))
	{
		DOLOG("Create Event Failed " + GetLastError());
		return FALSE;
	}
	return TRUE;
}
Exemplo n.º 19
0
BOOL RegistryOp::RestoreKey(LPWSTR lpFileName)
{
	assert(m_hKey);
	assert(lpFileName);
	long lReturn = RegRestoreKey(m_hKey, lpFileName, REG_WHOLE_HIVE_VOLATILE);
	if (lReturn == ERROR_SUCCESS)
	{
		return TRUE;
	}
	DOLOG("RegRestoreKey ERROR return:" + lReturn);
	return FALSE;
}
Exemplo n.º 20
0
LPVOID RetrieveTokenInformation(HANDLE hToken,
	TOKEN_INFORMATION_CLASS infoClass,
	DWORD& rSize)
{
	assert(hToken);
	LPVOID pInfo = NULL;
	GetTokenInformation(hToken, infoClass, NULL, 0, &rSize);
	if (rSize == 0)
	{
		DOLOG("GetTokenInformation GetSize Failed!");
		return NULL;
	}
	pInfo = malloc(rSize);

	if (TRUE != GetTokenInformation(hToken, infoClass, pInfo, rSize, &rSize))
	{
		DOLOG("GetTokenInformation Failed!");
		return NULL;
	}
	return pInfo;
}
Exemplo n.º 21
0
BOOL RegistryOp::SaveKey(LPWSTR lpFileName)
{
	assert(m_hKey);
	assert(lpFileName);

	long lReturn = RegSaveKeyW(m_hKey, lpFileName, NULL);

	if (lReturn == ERROR_SUCCESS)
		return TRUE;
	DOLOG("RegSaveKeyW ERROR return:" + lReturn);
	return FALSE;
}
Exemplo n.º 22
0
// [2015/12/15 wupeng]
// if failed return 0, success return the Process ID
DWORD GetSpecificProcIDByName(LPWSTR lpName)
{
    DWORD resProcessID = 0;
    if (ISNULL(lpName))
    {
        DOLOG("Process Name can't be null");
        return 0;
    }

    if (ISFALSE(EnableDebugPrivilege(TRUE)))
    {
        DOLOG("EnableDebugPrivilege Failed !");
        return 0;
    }

    PROCESSENTRY32W pe32;
    ZeroMemory(&pe32, sizeof(pe32));

    HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hProcessSnap == INVALID_HANDLE_VALUE)
    {
        DOLOG(" CreateToolhelp32Snapshot Failed ! \n" + GetLastError());
        return 0;
    }

    BOOL bMore = Process32FirstW(hProcessSnap, &pe32);
    while (bMore)
    {
        DOLOGW(L" >>" + pe32.szExeFile + L" : " + pe32.th32ProcessID);
        if (lstrcmpW(pe32.szExeFile, lpName) == 0)
        {
            resProcessID = pe32.th32ProcessID;
        }
        bMore = Process32NextW(hProcessSnap, &pe32);
    }

    // 不要忘记清除掉snapshot对象
    CloseHandle(hProcessSnap);
    return resProcessID;
}
Exemplo n.º 23
0
bool TipMsgWindow::ShowATopMostInfoWindow()
{
	HINSTANCE hInstance = GetModuleHandle(NULL);
	MyRegisterClass(hInstance);

	if (!InitInstance(hInstance))
	{
		DOLOG("InitInstance Failed! ErrorCode:" + GetLastError());
		return false;
	}
	
	return true;
}
Exemplo n.º 24
0
    bool Encode(LPVOID picInPtr, LPVOID nalOut, int *pNalNum)
    {
        x264_picture_t *picIn = (x264_picture_t*)picInPtr;
        x264_picture_t picOut;
		x264_picture_init(&picOut);

        if(x264_encoder_encode(x264, (x264_nal_t**)&nalOut, pNalNum, picIn, &picOut) < 0)
        {
            DOLOG("x264 encode failed");
            return false;
        }
		int countCacheFrame = x264_encoder_delayed_frames(x264);
		DOLOG("当前被缓存的帧数为" + countCacheFrame);
		int res = 0;
		
		if (countCacheFrame>0)
		{
			res = x264_encoder_encode(x264, (x264_nal_t**)&nalOut, pNalNum, NULL, &picOut);
		}

        return true;
    }
Exemplo n.º 25
0
BOOL RegistryOp::Write(LPWSTR lpSubKey, DWORD dwVal)
{
	assert(m_hKey);
	assert(lpSubKey);

	long lReturn = RegSetValueExW(m_hKey, lpSubKey, 0L, REG_DWORD, 
									(const BYTE *)&dwVal, sizeof(DWORD));

	if (lReturn == ERROR_SUCCESS)
		return TRUE;
	DOLOG("RegSetValueExW ERROR return:" + lReturn);
	return FALSE;
}
Exemplo n.º 26
0
LRESULT CALLBACK TipMsgWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	TipMsgWindow *pThis = NULL;

	switch (message)
	{
	case WM_TIMER:
		BringWindowToTop(hWnd);
		break;
	case WM_GETMINMAXINFO:
		MINMAXINFO* mmi;
		mmi = (MINMAXINFO*)lParam;
		mmi->ptMinTrackSize.x = 1;
		mmi->ptMinTrackSize.y = 1;
		mmi->ptMaxTrackSize.x = 200;
		mmi->ptMaxTrackSize.y = 200;
		break;
	case WM_CREATE:
		SetTimer(hWnd,0, 1000, NULL);
		break;
	case WM_PAINT:
		RECT rc;
		pThis = (TipMsgWindow*)GetWindowLong(hWnd, GWL_USERDATA);
		if (pThis == NULL)
		{
			DOLOG("have not right TipMsgWindow instance£¡");
			break;
		}
		
		hdc = BeginPaint(hWnd, &ps);
		//hbr = CreateSolidBrush(RGB(0, 0, 0));
		rc.top = 0;
		rc.left = 0;
		rc.right = pThis->m_size.x;
		rc.bottom = pThis->m_size.y;
		//assert(FillRect(hdc, &rc, hbr));
		SetTextColor(hdc, RGB(255, 0, 0));
		SetBkColor(hdc, RGB(0, 0, 0));
		DrawTextA(hdc, pThis->m_Msg, strlen(pThis->m_Msg), &rc, DT_CENTER | DT_VCENTER);
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Exemplo n.º 27
0
BOOL DisplayGroupInfo(HANDLE hToken)
{
	BOOL bResult = FALSE;
	do{
		TOKEN_GROUPS *pGroupsInfo = NULL;
		DWORD dwSize = 0;
		pGroupsInfo = (TOKEN_GROUPS*)RetrieveTokenInformation(hToken, TokenGroups, dwSize);
		if (!pGroupsInfo)
			break;
		SID_NAME_USE SidType;
		char lpName[MAX_PATH] = { 0 };
		char lpDomain[MAX_PATH] = { 0 };

		for (unsigned int i = 0; i < pGroupsInfo->GroupCount; ++i)
		{
			dwSize = MAX_PATH;
			if (!LookupAccountSidA(NULL, pGroupsInfo->Groups[i].Sid,
				lpName, &dwSize, lpDomain,
				&dwSize, &SidType))
			{
				DWORD dwResult = GetLastError();
				if (dwResult == ERROR_NONE_MAPPED)
					strcpy_s(lpName, dwSize, "NONE_MAPPED");
				else
				{
					DOLOG("LookupAccountSid Error:"+ GetLastError());
					return FALSE;
				}
			}
			DOLOG("gourpName:" + lpDomain + "\\" + lpName + ": \r\n \tenable:" + ((pGroupsInfo->Groups[i].Attributes & SE_GROUP_ENABLED) ? 1 : 0) +
				",  \tdeny_only:" + ((pGroupsInfo->Groups[i].Attributes & SE_GROUP_USE_FOR_DENY_ONLY) ? 1 : 0) + " \r\n");
		}

		free(pGroupsInfo);
		bResult = TRUE;
	} while (false);
	return bResult;
}
Exemplo n.º 28
0
BOOL DisplayUserInfo(HANDLE hToken){
	BOOL bResult = FALSE;
	do{
		TOKEN_USER *pUserInfo = NULL;
		DWORD dwSize = 0;
		LPTSTR pName = NULL;//从令牌获取用户信息
		pUserInfo = (TOKEN_USER *)RetrieveTokenInformation(hToken, TokenUser, dwSize);
		if (!pUserInfo)
			break;

		SID_NAME_USE SidType;
		char lpName[MAX_PATH] = { 0 };
		char lpDomain[MAX_PATH] = { 0 };

		dwSize = MAX_PATH;
		if (!LookupAccountSidA(NULL, pUserInfo->User.Sid,
			lpName, &dwSize, lpDomain,
			&dwSize, &SidType))
		{
			int dwResult = GetLastError();
			if (dwResult == ERROR_NONE_MAPPED)
				strcpy_s(lpName, dwSize, "NONE_MAPPED");
			else
			{
				DOLOG("LookupAccountSid ErrorCode: " + GetLastError());
				free(pUserInfo);
				return FALSE;
			}
		}
		DOLOG("Current user is a member of the \r\n \t\t " + lpDomain + "\\" + lpName + " \r\n");

		free(pUserInfo);
		bResult = TRUE;
	} while (false);
	return bResult;
}
Exemplo n.º 29
0
BOOL RegistryOp::DeleteValue(LPWSTR lpwValueName)
{
	assert(m_hKey);
	assert(lpwValueName);

	long lReturn = RegDeleteValueW(m_hKey, lpwValueName);

	if (lReturn == ERROR_SUCCESS)
	{
		return TRUE;
	}

	DOLOG("RegDeleteValueW ERROR return:" + lReturn);
	return FALSE;
}
Exemplo n.º 30
0
BOOL RegistryOp::DeleteKey(HKEY hKey, LPWSTR lpwSubKey)
{
	assert(hKey);
	assert(lpwSubKey);

	long lReturn = RegDeleteValueW(hKey, lpwSubKey);

	if (lReturn == ERROR_SUCCESS)
	{
		return TRUE;
	}

	DOLOG("RegDeleteValue ERROR return:" + lReturn);
	return FALSE;
}