예제 #1
0
int main(int argc, char* argv[])
#endif
{
    if (GetVersion() & 0x80000000)
    {
		_tprintf(_T("This application only runs on Windows NT/2000 or later"));
		return 0;
    }

	if (!ParseCommandLine(argc, argv))
		return 0;

	if (g_eat != ExamineAccessTokenNo)
	{
		CAccessToken at;
		if (!at.GetProcessToken(TOKEN_READ | TOKEN_QUERY_SOURCE))
			Log(_T("Could not open process token"));
		else
		{
			Log(_T("Process Access Token:"));
			DumpAccessToken(at);
		}
	}

	for (size_t i=0; i<g_aObjects.GetCount(); i++)
	{
		Log(_T("Security Descriptor for object %s:"), (LPCTSTR)g_aObjects[i]);
		switch (g_eot)
		{
		case ExamineObjectTypeDefault:
		case ExamineObjectTypeFile:
			DumpSecurityDescriptor(g_aObjects[i], SE_FILE_OBJECT, mapFileAccess);
			break;
		case ExamineObjectTypeRegkey:
			DumpSecurityDescriptor(g_aObjects[i], SE_REGISTRY_KEY, mapRegkeyAccess);
			break;
		case ExamineObjectTypeService:
			DumpSecurityDescriptor(g_aObjects[i], SE_SERVICE, mapServiceAccess);
			break;
		case ExamineObjectTypeKernel:
			DumpSecurityDescriptor(g_aObjects[i], SE_KERNEL_OBJECT, mapKernelAccess);
			break;
		case ExamineObjectTypePrinter:
			DumpSecurityDescriptor(g_aObjects[i], SE_PRINTER, mapPrinterAccess);
			break;
		default:
			ATLASSERT(FALSE);
		}
	}

	return 0;
}
예제 #2
0
// run until parent process exit
bool CSessionHost::ThreadLoop()
{
	if(m_hParent == 0) 
	{
		return false;
	}
	CoInitializeEx(0,COINIT_MULTITHREADED);
	{
		CComQIPtr<IWinRobotService>pService;
		HRESULT hr = pService.CoCreateInstance(__uuidof(ServiceHost));
		if ( FAILED(hr) )
		{
			DebugOutF(filelog::log_error,"CoCreateInstance Service failed with 0x%x",hr);
			return false;
		}
		CComPtr<IWinRobotSession>pSession;
		hr = pSession.CoCreateInstance(__uuidof(WinRobotSession));
		if ( FAILED(hr) )
		{
			DebugOutF(filelog::log_error,"CoCreateInstance WinRobotSession failed with 0x%x",hr);
			return false;
		}
		CAccessToken token;
		if(!token.GetProcessToken(TOKEN_ALL_ACCESS))
		{
			DebugOutF(filelog::log_error,"GetProcessToken failed with %d",GetLastError());
			return false;
		}
		DWORD sid = 0;
		if(!token.GetTerminalServicesSessionId(&sid))
		{
			DebugOutF(filelog::log_error,"GetTerminalServicesSessionId failed with %d",GetLastError());
			return false;
		}

		pService->RegSession(sid,GetCurrentProcessId(),pSession);

		WaitForSingleObject(m_hParent,-1);
	}
	//CoUninitialize();
	return false;
}