+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "stdafx.h"
-#define _WIN32_DCOM
-#include <windows.h>
-#include <iostream>
-#include <algorithm>
-#include <hash_map>
-#include <stdio.h>
-#include "winerror.h"
-#include "WMIAccessor.h"
-#include "XService.h"
-#include "comutil.h"
-
-//#include "xs_private.h"
-#include <wbemidl.h>
-
-#include <version.h>
-
-#define WIDEN2(x) L ## x
-#define WIDEN(x) WIDEN2(x)
-
-#define OBJECT_NAME_A(_Name) OBJECT_PREFIX_STR "XenStore" #_Name
-#define OBJECT_NAME_W(_Name) WIDEN(OBJECT_PREFIX_STR) L"XenStore" WIDEN(#_Name)
-
-#pragma comment(lib, "wbemuuid.lib")
-#pragma comment(lib, "uuid.lib")
-#pragma comment(lib, "comsuppw.lib")
-
-BSTR mkBstr(const char *string, size_t len) {
- BSTR res = NULL;
- size_t returned;
- wchar_t* wstring = new wchar_t[len+1];
- if (wstring == NULL) {
- goto malloc_wstring;
- }
- mbstowcs_s(&returned, wstring, len+1, string, len);
- res = SysAllocString(wstring);
- delete wstring;
-malloc_wstring:
- return res;
-}
-
-char * formatCharStrInt(const char *fmt, va_list l) {
- char *buf = NULL;
- int cnt = _vscprintf(fmt, l);
- buf = (char *)XsAlloc(cnt+1);
- if (buf == NULL) {
- goto malloc_buf;
- }
- _vsnprintf(buf, cnt+1, fmt, l);
-malloc_buf:
- return buf;
-}
-
-char * formatCharStr(const char *fmt, ... ) {
- char *buf =NULL;
- va_list l;
- va_start(l, fmt);
- buf = formatCharStrInt(fmt, l);
- va_end(l);
- return buf;
-}
-
-BSTR formatBstr(const char *fmt, ...)
-{
- char *buf;
- va_list l;
- BSTR res = NULL;
- va_start(l, fmt);
- buf = formatCharStrInt(fmt, l);
- va_end(l);
- res = mkBstr(buf, strlen(buf));
- XsFree(buf);
- return res;
-}
-
-int setVariantString(VARIANT* var, const char *data, size_t len) {
- int err=-1;
- VariantInit(var);
- var->vt=VT_BSTR;
- var->bstrVal = mkBstr(data, len);
- if (var->bstrVal == NULL) {
- goto sysalloc;
- }
- err=0;
-sysalloc:
- return err;
-}
-
-
-int setVariantString(VARIANT* var, const char *string) {
- return setVariantString(var, string, strlen(string));
-}
-
-
-class WatchSink : public IWbemObjectSink
-{
- LONG m_lRef;
- bool bDone;
- HANDLE triggerevent;
- HANDLE triggererror;
-public:
- char *path;
- WatchSink(HANDLE event, HANDLE errorevent, const char *path) {
- m_lRef = 1;
- triggerevent = event;
- triggererror = errorevent;
- this->path = NULL;
- if (path) {
- this->path=(char *)XsAlloc(strlen(path)+1);
- strcpy(this->path, path);
- }
- }
- ~WatchSink() { bDone = TRUE; }
-
- virtual ULONG STDMETHODCALLTYPE AddRef();
- virtual ULONG STDMETHODCALLTYPE Release();
- virtual HRESULT STDMETHODCALLTYPE
- QueryInterface(REFIID riid, void** ppv);
-
- virtual HRESULT STDMETHODCALLTYPE Indicate(
- /* [in] */
- LONG lObjectCount,
- /* [size_is][in] */
- IWbemClassObject __RPC_FAR *__RPC_FAR *apObjArray
- );
-
- virtual HRESULT STDMETHODCALLTYPE SetStatus(
- /* [in] */ LONG lFlags,
- /* [in] */ HRESULT hResult,
- /* [in] */ BSTR strParam,
- /* [in] */ IWbemClassObject __RPC_FAR *pObjParam
- );
-};
-
-
-ULONG WatchSink::AddRef()
-{
- return InterlockedIncrement(&m_lRef);
-}
-
-ULONG WatchSink::Release()
-{
- LONG lRef = InterlockedDecrement(&m_lRef);
- if(lRef == 0)
- delete this;
- return lRef;
-}
-
-HRESULT WatchSink::QueryInterface(REFIID riid, void** ppv)
-{
- if (riid == IID_IUnknown || riid == IID_IWbemObjectSink)
- {
- *ppv = (IWbemObjectSink *) this;
- AddRef();
- return WBEM_S_NO_ERROR;
- }
- else return E_NOINTERFACE;
-}
-
-
-HRESULT WatchSink::Indicate(long lObjCount, IWbemClassObject **pArray)
-{
- for (long i = 0; i < lObjCount; i++)
- {
- IWbemClassObject *pObj = pArray[i];
- SetEvent(this->triggerevent);
- // ... use the object.
-
- // AddRef() is only required if the object will be held after
- // the return to the caller.
- }
-
- return WBEM_S_NO_ERROR;
-}
-
-HRESULT WatchSink::SetStatus(
- /* [in] */ LONG lFlags,
- /* [in] */ HRESULT hResult,
- /* [in] */ BSTR strParam,
- /* [in] */ IWbemClassObject __RPC_FAR *pObjParam
- )
-{
- if (FAILED(hResult)) {
- XsLog("WMI Asyc watch failed %p\n", this);
- SetEvent(this->triggererror);
- }
- return WBEM_S_NO_ERROR;
-}
-
-
-
-struct WMIAccessor
-{
- IWbemServices *mpSvc;
- IWbemServices *mpXSSvc;
-
- HANDLE owning_thread;
-};
-
-struct WMIAccessor *wmi = NULL;
-
-static string wstring2string(const wstring& wstr)
-{
- int len;
-
- len = WideCharToMultiByte(CP_UTF8,
- 0,
- wstr.c_str(),
- -1,
- NULL,
- 0,
- NULL,
- NULL);
-
- string str(len, 0);
-
- len = WideCharToMultiByte(CP_UTF8,
- 0,
- wstr.c_str(),
- -1,
- &str[0],
- (int)str.length(),
- NULL,
- NULL);
-
- return str;
-}
-
-static string bstr2string(const BSTR& bstr)
-{
- wstring wstr(bstr);
-
- return wstring2string(wstr);
-}
-
-IWbemClassObject *getClass(WMIAccessor **wmi, BSTR path) {
- if (*wmi == NULL)
- return NULL;
-
- if ((*wmi)->mpXSSvc == NULL)
- return NULL;
-
- IWbemClassObject *returnedObject;
- HRESULT hres = (*wmi)->mpXSSvc->GetObject(path,WBEM_FLAG_RETURN_WBEM_COMPLETE,
- NULL, &returnedObject, NULL);
- if (FAILED(hres)) {
- returnedObject =NULL;
- }
- return returnedObject;
-}
-
-IWbemClassObject *getObject(WMIAccessor **wmi, BSTR path) {
- IEnumWbemClassObject *returnedEnum;
- IWbemClassObject *returnedObject;
- if (*wmi == NULL)
- return NULL;
- ASSERT((*wmi)->mpXSSvc != NULL);
- HRESULT hres = (*wmi)->mpXSSvc->CreateInstanceEnum(path, WBEM_FLAG_FORWARD_ONLY,
- NULL,
- &returnedEnum);
- if (FAILED(hres)) {
- OutputDebugString("GetEnum failed\n");
- returnedObject =NULL;
- return returnedObject;
- }
- ULONG objects;
-
- hres = returnedEnum->Next(WBEM_INFINITE, 1, &returnedObject, &objects);
-
-
- if (FAILED(hres) || objects < 1) {
- OutputDebugString("GetFromEnum failed\n");
- returnedObject =NULL;
- }
-
- return returnedObject;
-}
-
-HRESULT methodExec(WMIAccessor** wmi, IWbemClassObject* instance, const wchar_t *methodname, IWbemClassObject *inMethodInst, IWbemClassObject **outMethodInst)
-{
- HRESULT hres=E_FAIL ;
-
- IWbemClassObject *outstore=NULL;
- BSTR bpathname = SysAllocString(L"__PATH");
- if (bpathname == NULL){
- goto allocpathname;
- }
-
-
- VARIANT instancepath;
- VariantInit(&instancepath);
- hres = instance->Get(bpathname, 0, &instancepath, NULL, NULL);
- if (FAILED(hres)) {
- goto getclassname;
- }
-
-
- BSTR bmethodname = SysAllocString(methodname);
- if (bmethodname == NULL){
- goto allocmethodname;
- }
-
- hres = (*wmi)->mpXSSvc->ExecMethod(instancepath.bstrVal, bmethodname, 0, NULL,inMethodInst, &outstore, NULL);
- if (outMethodInst != NULL) {
- *outMethodInst = NULL;
- if (!FAILED(hres)){
- *outMethodInst = outstore;
- }
- }
-
- SysFreeString(bmethodname);
-allocmethodname:
-
-getclassname:
- VariantClear(&instancepath);
- SysFreeString(bpathname);
-allocpathname:
- return hres;
-}
-static IEnumWbemClassObject* runXSQuery(WMIAccessor **wmi, BSTR query)
-{
- if (wmi == NULL)
- return NULL;
-
- ASSERT((*wmi)->mpXSSvc != NULL);
-
- // Use the IWbemServices pointer to make requests of WMI.
- // Make requests here:
- IEnumWbemClassObject* pEnumerator = NULL;
- HRESULT hres = (*wmi)->mpXSSvc->ExecQuery(L"WQL",
- query,
- WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
- NULL,
- &pEnumerator);
- if (FAILED(hres))
- {
- DBGPRINT(("ExecQuery failed\n"));
- pEnumerator = NULL;
- }
- return pEnumerator;
-}
-static IEnumWbemClassObject* runQuery(WMIAccessor *wmi, BSTR query)
-{
- if (wmi == NULL)
- return NULL;
-
- ASSERT(wmi->mpSvc != NULL);
-
- // Use the IWbemServices pointer to make requests of WMI.
- // Make requests here:
- IEnumWbemClassObject* pEnumerator = NULL;
- HRESULT hres = wmi->mpSvc->ExecQuery(L"WQL",
- query,
- WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
- NULL,
- &pEnumerator);
- if (FAILED(hres))
- {
- DBGPRINT(("ExecQuery failed\n"));
- pEnumerator = NULL;
- }
- return pEnumerator;
-}
-
-LONG wmicount = 0;
-static BOOLEAN com_initialized = false;
-static IWbemLocator *locator = 0;
-BOOL InitCom(void) {
- HRESULT hres;
- XsLog("Init COM");
- hres = CoInitializeEx(0, COINIT_MULTITHREADED);
- if (FAILED(hres)) {
- goto err_out;
- }
- com_initialized = TRUE;
- //wmi->owning_thread = GetCurrentThread();
- //XsLog("Wmi connect thread %p", GetCurrentThread());
- // Initialize COM security. Most of this is irrelevant to us.
- XsLog("Init security");
- hres = CoInitializeSecurity(
- NULL, /* Security descriptor. Only relevant to servers */
- -1, /* Nr. of auth services. Only relevant to servers */
- NULL, /* List of auth services. Only relevant to servers */
- NULL, /* Reserved */
- RPC_C_AUTHN_LEVEL_DEFAULT, /* Default authentication. The
- details don't really matter when
- you're localhost. */
- RPC_C_IMP_LEVEL_IMPERSONATE, /* WMI needs to be able to
- impersonate us. */
- NULL, /* Authentication info */
- EOAC_NONE, /* Additional capabilities */
- NULL /* Reserved */
- );
- if (FAILED(hres)) {
- goto err_out;
- }
- OutputDebugString("CreateInstance\n");
- hres = CoCreateInstance(
- CLSID_WbemLocator,
- 0,
- CLSCTX_INPROC_SERVER,
- IID_IWbemLocator,
- (LPVOID *) &locator);
- OutputDebugString("Check hres\n");
- if (FAILED(hres)) {
- goto err_out;
- }
- if (locator == NULL) {
- OutputDebugString("Null locator");
- goto err_out;
- }
- return true;
-err_out:
- return false;
-}
-
-BOOL ConnectToWMI(void)
-{
- InitCom();
- HRESULT hres;
- OutputDebugString("Connect to WMI");
- wmicount++;
-
- wmi = (struct WMIAccessor *)XsAlloc(sizeof(*wmi));
- if (wmi == NULL) {
- return false;
- }
- memset(wmi, 0, sizeof(*wmi));
-
-
- OutputDebugString("Connect Server\n");
- try {
- hres = locator->ConnectServer(
- L"root\\CIMV2", // WMI namespace
- NULL, // User name
- NULL, // User password
- NULL, // Locale
- 0, // Security flags
- NULL, // Authority
- NULL, // Context object
- &(wmi->mpSvc) // IWbemServices proxy
- );
- }
- catch(...) {
- OutputDebugString("Exception connecting to server\n");
- goto err_out;
- }
-
- OutputDebugString("Check result\n");
- if (FAILED(hres)) {
- goto err_out;
- }
- /* WMI needs to impersonate us, because it normally runs as an
- unprivileged user and needs our authority in order to access
- device files and so forth. Turn impersonation on. */
- OutputDebugString("Proxy blanket\n");
- hres = CoSetProxyBlanket(
- wmi->mpSvc, // the proxy to set
- RPC_C_AUTHN_WINNT, /* LAN manager authentication,
- although it doesn't really
- matter on localhost. */
- RPC_C_AUTHZ_NONE, // LANMAN can't do much authorization.
- NULL, // Server principal name
- RPC_C_AUTHN_LEVEL_CALL, // Do authentication on every call
- RPC_C_IMP_LEVEL_IMPERSONATE, // Allow full impersonation.
- NULL, // Use current client identity
- EOAC_NONE // No extended proxy capabilities
- );
- if (FAILED(hres)) {
- goto err_out;
- }
- OutputDebugString("WMI Server\n");
- hres = locator->ConnectServer(
- L"root\\WMI", // WMI namespace
- NULL, // User name
- NULL, // User password
- NULL, // Locale
- 0, // Security flags
- NULL, // Authority
- NULL, // Context object
- &wmi->mpXSSvc // IWbemServices proxy
- );
-
- if (FAILED(hres)) {
- goto err_out;
- }
- OutputDebugString("Impersonation\n");
- /* WMI needs to impersonate us, because it normally runs as an
- unprivileged user and needs our authority in order to access
- device files and so forth. Turn impersonation on. */
- hres = CoSetProxyBlanket(
- wmi->mpXSSvc, // the proxy to set
- RPC_C_AUTHN_WINNT, /* LAN manager authentication,
- although it doesn't really
- matter on localhost. */
- RPC_C_AUTHZ_NONE, // LANMAN can't do much authorization.
- NULL, // Server principal name
- RPC_C_AUTHN_LEVEL_CALL, // Do authentication on every call
- RPC_C_IMP_LEVEL_IMPERSONATE, // Allow full impersonation.
- NULL, // Use current client identity
- EOAC_NONE // No extended proxy capabilities
- );
- if (FAILED(hres)) {
- goto err_out;
- }
-
-
- OutputDebugString("Wmi connected\n");
- /* All done. */
- return true;
-
-err_out:
- OutputDebugString("WMI connection failed\n");
- ReleaseWMIAccessor(&wmi);
- return false;
-}
-
-
-void ReleaseCom(void) {
-
- if (com_initialized) {
- OutputDebugString("Release locator\n");
- locator->Release();
- //XsLog("Wmi disconnect thread %p", GetCurrentThread());
- //ASSERT((*wmi)->owning_thread == GetCurrentThread());
- com_initialized = 0;
- OutputDebugString("Uninitialize com\n");
- CoUninitialize();
-
- }
-}
-
-/* Careful: WMI accessors must be released on the same thread that
- allocated them. */
-void ReleaseWMIAccessor(struct WMIAccessor **wmi)
-{
- OutputDebugString("Should I release wmi?\n");
- if (*wmi == NULL)
- return;
- OutputDebugString("Get rid of WMI servers\n");
- if ((*wmi)->mpXSSvc != NULL)
- (*wmi)->mpXSSvc->Release();
- if ((*wmi)->mpSvc != NULL)
- (*wmi)->mpSvc->Release();
- OutputDebugString("Clear WmI\n");
- /* Poison wmi to make use-after-free()s a bit more obvious. */
- memset((*wmi), 0xab, sizeof(**wmi));
- XsFree(*wmi);
- *wmi = NULL;
- ReleaseCom();
- OutputDebugString("Released WMI\n");
-}
-
-/* The fact that something is documented as being a uint64_t field
- doesn't imply that it will be returned as a VT_UI8 field in a
- variant structure. Work around this with a handy conversion
- function. */
-static uint64_t
-GetVariantUint64(VARIANT *vtData)
-{
- switch (vtData->vt) {
- case VT_I2:
- return vtData->iVal;
- case VT_I4:
- return vtData->lVal;
- case VT_I8:
- return vtData->llVal;
- case VT_UI2:
- return vtData->uiVal;
- case VT_UI4:
- return vtData->ulVal;
- case VT_UI8:
- return vtData->ullVal;
- case VT_BSTR:
- /* Yes, I really do mean BSTR: XP returns 64 bit values as
- strings, and we then have to do atoill on it. */
- return _wtoi64(vtData->bstrVal);
- default:
- DBGPRINT(("Bad uint64_t variant %d.\n",vtData->vt));
- return -1;
- }
-}
-
-static HRESULT
-QueryVariant(WMIAccessor *wmi, PWCHAR field, PWCHAR table, VARIANT *vt)
-{
- IEnumWbemClassObject *pEnum;
- BSTR query;
- size_t query_len;
- IWbemClassObject *pclsObj;
- HRESULT hr;
- ULONG uReturn;
-
- query_len = strlen("SELECT FROM ") + wcslen(field) + wcslen(table) + 1;
- query = SysAllocStringLen(NULL, (UINT)query_len);
- if (query == NULL) {
- hr = E_OUTOFMEMORY;
- goto err;
- }
- swprintf_s(query, query_len, L"SELECT %s FROM %s", field, table);
- pEnum = runQuery(wmi, query);
- SysFreeString(query);
-
- if (pEnum == NULL) {
- hr = E_OUTOFMEMORY;
- goto err;
- }
-
- hr = pEnum->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
- pEnum->Release();
- if (FAILED(hr))
- goto err;
- if (uReturn == 0) {
- hr = E_FAIL;
- goto err;
- }
-
- hr = pclsObj->Get(field, 0, vt, NULL, NULL);
- pclsObj->Release();
-
- return hr;
-
-err:
- return hr;
-}
-
-static uint64_t
-QueryUint64(WMIAccessor *wmi, PWCHAR field, PWCHAR table)
-{
- HRESULT hr;
- uint64_t res;
- VARIANT vt;
-
- memset(&vt, 0, sizeof(vt));
-
- hr = QueryVariant(wmi, field, table, &vt);
- if (FAILED(hr))
- return 0;
-
- res = GetVariantUint64(&vt);
- VariantClear(&vt);
- return res;
-}
-
-static BSTR
-QueryBstr(WMIAccessor *wmi, PWCHAR field, PWCHAR table)
-{
- HRESULT hr;
- VARIANT vt;
-
- memset(&vt, 0, sizeof(vt));
-
- hr = QueryVariant(wmi, field, table, &vt);
- if (FAILED(hr))
- return NULL;
- if (vt.vt != VT_BSTR) {
- VariantClear(&vt);
- return NULL;
- }
- return vt.bstrVal;
-}
-
-
-
-/* hash comparator for strings which strips off trailing .exe
- * suffix */
-class string_eq_exe {
-private:
- static size_t len_without_suffix(const char *x)
- {
- size_t l;
- l = strlen(x);
- if (l > 4 && !strcmp(x + l - 4, ".exe"))
- l -= 4;
- return l;
- }
-
-public:
- enum {bucket_size = 4, min_buckets = 8};
- bool operator()(const string &a, const string &b) const
- {
- const char *a_c, *b_c;
- size_t a_l, b_l;
- a_c = a.c_str();
- b_c = b.c_str();
- a_l = len_without_suffix(a_c);
- b_l = len_without_suffix(b_c);
-
- if (a_l != b_l)
- return 1;
- if (memcmp(a_c, b_c, a_l))
- return 1;
- else
- return 0;
- }
-
- size_t operator()(const string &a) const
- {
- size_t acc = 0;
- const char *c_str = a.c_str();
- size_t len = len_without_suffix(c_str);
- unsigned x;
- for (x = 0; x < len; x++)
- acc = (acc * 17 + c_str[x]) % 257;
- return acc;
- }
-};
-
-
-IWbemClassObject *getBase(WMIAccessor** wmi)
-{
- IWbemClassObject* base = getObject(wmi, OBJECT_NAME_W(Base));
- if (base == NULL) {
- *wmi = NULL;
- return NULL;
- }
- return base;
-}
-
-IWbemClassObject *getBaseClass(WMIAccessor** wmi)
-{
- IWbemClassObject* baseclass = getClass(wmi, OBJECT_NAME_W(Base));
- if (baseclass == NULL) {
- *wmi = NULL;
- return NULL;
- }
- return baseclass;
-}
-
-ULONGLONG get64BitUnsigned(VARIANT *var) {
- ULONGLONG res = 0;
- switch (var->vt) {
- case VT_BSTR: {
- VARIANT outvar;
- VariantInit(&outvar);
- VariantChangeType(&outvar, var, 0, VT_UI8);
- res = outvar.ullVal;
- VariantClear(&outvar);
- }
- break;
- case VT_UI8: {
- res = var->ullVal;
- }
- break;
- }
- return res;
-}
-
-FILETIME WmiGetXenTime(WMIAccessor **wmi) {
- FILETIME out;
-
- IWbemClassObject *base = getBase(wmi);
- if (base == NULL) {
- DBGPRINT(("Unable to find base WMI session\n"));
- goto getbasefailed;
- }
-
- VARIANT timevar;
- BSTR timename = mkBstr("XenTime", 7);
- if (timename == NULL)
- goto buildtimenamefailed;
-
-
-
- if (FAILED(base->Get(timename, 0, &timevar, NULL, NULL)))
- goto gettimefailed;
-
- ULONGLONG time =get64BitUnsigned(&timevar);;
-
- out.dwLowDateTime = (DWORD)time;
- out.dwHighDateTime = (DWORD)(time>>32);
- return out;
-
-gettimefailed:
-buildtimenamefailed:
-getbasefailed:
- out.dwLowDateTime = 0;
- out.dwHighDateTime = 0;
- return out ;
-}
-
-IWbemClassObject *openSession(WMIAccessor** wmi, const char *sessionname)
-{
- HRESULT hres;
-
- BSTR query = formatBstr("SELECT * FROM " OBJECT_NAME_A(Session) " WHERE Id=\"" OBJECT_PREFIX_STR " Xen Win32 Service : %s\"", sessionname);
- if (query == NULL)
- goto formatsessionbstrfailed;
-
- IEnumWbemClassObject * sessions = runXSQuery(wmi, query);
- SysFreeString(query);
-
- if (sessions) {
- IWbemClassObject *returnedObject;
- ULONG count;
- hres = sessions->Next(WBEM_INFINITE, 1, &returnedObject, &count);
- sessions->Release();
-
- if (count>0) {
- if (sessionname !=NULL ) {
- if (!WmiSessionEnd(wmi, returnedObject)) {
- return NULL;
- }
- }
- else {
- return returnedObject;
- }
- }
- }
-
- IWbemClassObject *base = getBase(wmi);
- if (base==NULL) {
- DBGPRINT(("Unable to find base WMI session\n"));
- goto getbasefailed;
- }
-
- IWbemClassObject *baseclass = getBaseClass(wmi);
-
- if (baseclass == NULL)
- goto getbaseclassfailed;
-
- IWbemClassObject *inMethod;
-
- IWbemClassObject *inMethodInst;
- IWbemClassObject *outMethodInst;
- if (FAILED(baseclass->GetMethod(L"AddSession",0,&inMethod, NULL)))
- goto getmethodaddsessionfailed;
-
- if (FAILED(inMethod->SpawnInstance(0, &inMethodInst)))
- goto inmethodspawnfailed;
-
- VARIANT var;
- var.vt = VT_BSTR;
- var.bstrVal=formatBstr(VENDOR_NAME_STR " " PRODUCT_NAME_STR " Win32 Service : %s", sessionname);
-
- if (var.bstrVal == NULL)
- goto formatnamebstrfailed;
-
- if (FAILED(inMethodInst->Put(L"Id", 0, &var, 0)))
- goto methodputfailed;
-
- if (FAILED(methodExec(wmi, base, L"AddSession", inMethodInst, &outMethodInst)))
- goto methodexecaddsessionfailed;
-
- if (FAILED(outMethodInst->Get(L"SessionId", 0, &var, NULL, NULL)))
- goto outmethodgetfailed;
-
- size_t query_len;
- query_len = strlen("SELECT * FROM " OBJECT_NAME_A(Session) " WHERE SessionId=")+10;
- query = SysAllocStringLen(NULL, (UINT)query_len);
-
- if (query == NULL)
- goto allocqueryfailed;
-
- swprintf_s(query,query_len, L"SELECT * FROM " OBJECT_NAME_W(Session) L" WHERE SessionId=%d", var.uintVal);
-
- sessions = runXSQuery(wmi, query );
- SysFreeString(query);
-
- if (sessions) {
- IWbemClassObject *returnedObject;
- ULONG count;
- hres = sessions->Next(WBEM_INFINITE, 1, &returnedObject, &count);
- sessions->Release();
- if (count>0) {
- return returnedObject;
- }
-
- }
-
- outMethodInst->Release();
- VariantClear(&var);
- inMethodInst->Release();
- inMethod->Release();
- base->Release();
- baseclass->Release();
- return NULL;
-
-allocqueryfailed:
-outmethodgetfailed:
- outMethodInst->Release();
-
-methodexecaddsessionfailed:
-methodputfailed:
- VariantClear(&var);
-
-formatnamebstrfailed:
- inMethodInst->Release();
-inmethodspawnfailed:
- inMethod->Release();
-
-
-getmethodaddsessionfailed:
- baseclass->Release();
-
-getbaseclassfailed:
- base->Release();
-
-getbasefailed:
-
-
-formatsessionbstrfailed:
- return NULL;
-}
-
-IWbemClassObject* sessionMethodStart(WMIAccessor**wmi,
- const wchar_t *methodname)
-{
- IWbemClassObject *inMethod;
- IWbemClassObject *inMethodInst = NULL;
- IWbemClassObject *sessionClass;
- HRESULT hr;
-
- ASSERT(wmi != NULL);
-
- sessionClass = getClass(wmi, OBJECT_NAME_W(Session));
- if (sessionClass == NULL)
- goto getclassfailed;
-
- hr = sessionClass->GetMethod(methodname,0,&inMethod, NULL);
- if (FAILED(hr))
- goto getmethodfailed;
-
- hr = inMethod->SpawnInstance(0, &inMethodInst);
- if (FAILED(hr))
- goto spawninstancefailed;
-
- inMethod->Release();
-
- sessionClass->Release();
- return inMethodInst;
-
-
-spawninstancefailed:
- inMethod->Release();
-
-getmethodfailed:
- sessionClass->Release();
-
-getclassfailed:
- return NULL;
-}
-
-
-char * bstrToChar(BSTR bst, size_t *len) {
- *len = wcslen(bst);
- char *space = (char *)XsAlloc(*len+1);
- if (space)
- wcstombs_s(len, space, *len+1, bst, _TRUNCATE);
- return space;
-}
-
-void WmiSessionLog(WMIAccessor** wmi, void **sessionhandle,const char *fmt, va_list args) {
- IWbemClassObject **session = (IWbemClassObject **)sessionhandle;
-
- char* message = formatCharStrInt(fmt,args);
-
- OutputDebugString(message);
- if (((*wmi)==NULL) || ((*sessionhandle)==NULL) ) {
- goto nowmi;
- }
- VARIANT vmessage;
- if (setVariantString(&vmessage, message))
- goto setvmessage;
-
- IWbemClassObject *inMethodInst = sessionMethodStart( wmi, L"Log");
- if (!inMethodInst)
- goto sessionstart;
-
- if (FAILED(inMethodInst->Put(L"Message",0,&vmessage,0)))
- goto methodputfailed;
-
- if (FAILED(methodExec(wmi,*session, L"Log", inMethodInst, NULL)))
- goto methodexecfailed;
-
-methodexecfailed:
-methodputfailed:
- inMethodInst->Release();
-
-sessionstart:
- VariantClear(&vmessage);
-
-setvmessage:
-nowmi:
- return;
-}
-
-char* WmiSessionGetEntry(WMIAccessor** wmi, void **sessionhandle,
- const char * path, size_t* len)
-{
- *len = 0;
- IWbemClassObject **session = (IWbemClassObject **)sessionhandle;
-
- VARIANT vpath;
- if (setVariantString(&vpath, path))
- goto setvpath;
-
- IWbemClassObject *outMethodInst = NULL;
-
- IWbemClassObject *inMethodInst = sessionMethodStart( wmi, L"GetValue");
- if (inMethodInst == NULL)
- goto sessionmethodstartfailed;
-
- if (FAILED(inMethodInst->Put(L"PathName",0,&vpath,0)))
- goto methodexecfailed;
-
- methodExec(wmi,*session, L"GetValue", inMethodInst, &outMethodInst);
- if (outMethodInst==NULL)
- goto sessionExec;
-
- VARIANT outval;
- VariantInit(&outval);
-
- if (FAILED(outMethodInst->Get(L"value", 0, &outval, NULL, NULL)))
- goto methodgetfailed;
-
- char *space = NULL;
-
- if (V_VT(&outval) == VT_BSTR)
- {
- space = bstrToChar(outval.bstrVal, len);
- }
-
- outMethodInst->Release();
- inMethodInst->Release();
- VariantClear(&vpath);
- VariantClear(&outval);
- return space;
-
-methodgetfailed:
- outMethodInst->Release();
-
-methodexecfailed:
-sessionExec:
- inMethodInst->Release();
-
-sessionmethodstartfailed:
- VariantClear(&vpath);
-
-setvpath:
- return NULL;
-}
-
-int WmiSessionSetEntry(WMIAccessor** wmi, void **sessionhandle,
- const char*path, const char * value, size_t len)
-{
- int err = -1;
- IWbemClassObject **session = (IWbemClassObject **)sessionhandle;
-
- VARIANT vpath;
- if (setVariantString(&vpath, path))
- goto setvpath;
-
- VARIANT vvalue;
- if (setVariantString(&vvalue, value))
- goto setvvalue;
-
- IWbemClassObject *outMethodInst;
-
- IWbemClassObject *inMethodInst = sessionMethodStart( wmi, L"SetValue");
- if (!inMethodInst)
- goto sessionstart;
-
- inMethodInst->Put(L"PathName",0,&vpath,0);
- inMethodInst->Put(L"value",0,&vvalue,0);
-
- if (FAILED(methodExec(wmi,*session, L"SetValue", inMethodInst, &outMethodInst)))
- goto methodexecfailed;
-
- if (outMethodInst!=NULL)
- outMethodInst->Release();
-
- inMethodInst->Release();
- SysFreeString(vvalue.bstrVal);
- SysFreeString(vpath.bstrVal);
-
- return 0;
-
-methodexecfailed:
- XsLog("WmiSessionSetEntry:MethodExec Failed");
- inMethodInst->Release();
-
-sessionstart:
- XsLog("WmiSessionSetEntry:SessionStart Failed");
- SysFreeString(vvalue.bstrVal);
-
-setvvalue:
- XsLog("WmiSessionSetEntry:SetVValue Failed");
- SysFreeString(vpath.bstrVal);
-
-setvpath:
- XsLog("WmiSessionSetEntry:SetVPath Failed ");
- return err;
-}
-
-int WmiSessionSetEntry(WMIAccessor** wmi, void **sessionhandle,
- const char*path, const char * value) {
- return WmiSessionSetEntry(wmi, sessionhandle, path, value, strlen(value));
-}
-
-int WmiSessionRemoveEntry(WMIAccessor** wmi, void **sessionhandle,
- const char*path){
-
- int err = -1;
- IWbemClassObject **session = (IWbemClassObject **)sessionhandle;
-
- VARIANT vpath;
- if (setVariantString(&vpath, path))
- goto setvpath;
-
- IWbemClassObject *inMethodInst = sessionMethodStart( wmi, L"RemoveValue");
- if (!inMethodInst)
- goto sessionstart;
-
- if (FAILED(inMethodInst->Put(L"PathName",0,&vpath,0)))
- goto methodputfailed;
-
- IWbemClassObject* outMethodInst;
-
- if (FAILED(methodExec(wmi,*session, L"RemoveValue", inMethodInst, &outMethodInst)))
- goto methodexecfailed;
-
- if (outMethodInst != NULL)
- outMethodInst->Release();
-
- err=0;
- inMethodInst->Release();
- VariantClear(&vpath);
- return err;
-methodexecfailed:
- OutputDebugString(__FUNCTION__ " MethodExecFailed");
-methodputfailed:
- OutputDebugString(__FUNCTION__ " MethodPutFailed");
- inMethodInst->Release();
-
-sessionstart:
- OutputDebugString(__FUNCTION__ " SessionStartFailed");
- VariantClear(&vpath);
-
- OutputDebugString(__FUNCTION__ " SessionExecFailed");
-setvpath:
- OutputDebugString(__FUNCTION__ " SetVpathFailed");
- return err;
-}
-
-
-BOOL WmiSessionUnwatch(WMIAccessor** wmi, void **sessionhandle,
- void *watchhandle) {
- IWbemClassObject **session = (IWbemClassObject **)sessionhandle;
- XsLog("Unwatch %p",watchhandle);
- WatchSink * sink = (WatchSink *)watchhandle;
-
- VARIANT vpath;
- if (setVariantString(&vpath, sink->path))
- goto setvpath;
-
- IWbemClassObject *outMethodInst;
- IWbemClassObject *inMethodInst = sessionMethodStart( wmi, L"RemoveWatch");
- if (!inMethodInst)
- goto sessionstart;
-
- inMethodInst->Put(L"PathName",0,&vpath,0);
- if FAILED(methodExec(wmi,*session, L"RemoveWatch", inMethodInst, &outMethodInst))
- goto methodexecfailed;
- if (outMethodInst==NULL)
- goto sessionexecfailed;
-
- outMethodInst->Release();
-
-methodexecfailed:
-sessionexecfailed:
- inMethodInst->Release();
-
-sessionstart:
-setvpath:
- sink->Release();
- return true;
-}
-
-BOOL WmiSessionStart(WMIAccessor** wmi, void **sessionhandle, const char* sessionname)
-{
- IWbemClassObject **session = (IWbemClassObject **)sessionhandle;
- if ((*session = openSession(wmi, sessionname)) == NULL) {
- return false;
- }
- return true;
-}
-
-
-BOOL WmiSessionEnd(WMIAccessor** wmi, void *sessionhandle)
-{
- HRESULT hr;
- ASSERT(*wmi != NULL);
-
- IWbemClassObject *session = (IWbemClassObject *)sessionhandle;
- if (session==NULL) {
- return false;
- }
- hr = methodExec(wmi, session, L"EndSession", NULL,NULL);
- if FAILED(hr)
- goto execmethodfailed;
- session->Release();
- return true;
-
-execmethodfailed:
- return false;
-
-}
-
-void *WmiSessionWatch(WMIAccessor** wmi, void **sessionhandle,
- const char *path, HANDLE event, HANDLE errorevent) {
-
- HRESULT hr;
-
- IWbemClassObject **session = (IWbemClassObject **)sessionhandle;
-
- ASSERT((*wmi) != NULL);
- ASSERT((*sessionhandle) != NULL);
-
- WatchSink * sink = new WatchSink(event, errorevent, path);
- BSTR query=formatBstr("SELECT * from " OBJECT_NAME_A(WatchEvent) " WHERE EventId=\"%s\"", path);
- if (query == NULL) {
- goto formatstringfailed;
- }
-
- hr = (*wmi)->mpXSSvc->ExecNotificationQueryAsync(L"WQL", query,0,NULL, sink);
- if (FAILED(hr)){
- *wmi = NULL;
- goto wmifailed;
- }
-
- VARIANT vpath;
- if (setVariantString(&vpath, path)){
- goto setvpath;
- }
-
-
- IWbemClassObject *inMethodInst = sessionMethodStart( wmi, L"SetWatch");
- if (!inMethodInst)
- goto sessionstart;
-
- hr = inMethodInst->Put(L"PathName",0,&vpath,0);
- if (FAILED(hr))
- goto methodputfailed;
-
- hr = methodExec(wmi,*session, L"SetWatch", inMethodInst, NULL);
- if (FAILED(hr))
- goto methodexecfailed;
-
- VariantClear(&vpath);
-
- SysFreeString(query);
-
- return sink;
-
-
-methodexecfailed:
- OutputDebugString(__FUNCTION__ " : methodexecfailed\n");
-methodputfailed:
- OutputDebugString(__FUNCTION__ " : methodputfailed\n");
- inMethodInst->Release();
-sessionstart:
- OutputDebugString(__FUNCTION__ " : sessionstart\n");
- VariantClear(&vpath);
-setvpath:
- OutputDebugString(__FUNCTION__ " : setvpath\n");
-wmifailed:
- SysFreeString(query);
-formatstringfailed:
- OutputDebugString(__FUNCTION__ " : formatstringfailed\n");
- delete sink;
- return NULL;
-}
-
-void *WmiUnsuspendedEventWatch(WMIAccessor **wmi, HANDLE event, HANDLE errorevent)
-{
- HRESULT hr;
-
- ASSERT(*wmi != NULL);
-
- WatchSink * sink = new WatchSink(event, errorevent, NULL);
- BSTR query=formatBstr("SELECT * from " OBJECT_NAME_A(UnsuspendedEvent));
- if (query==NULL) {
- goto formatstringfailed;
- }
-
- hr = (*wmi)->mpXSSvc->ExecNotificationQueryAsync(L"WQL", query,0,NULL, sink);
- if FAILED(hr)
- goto asyncqueryfailed;
-
- SysFreeString(query);
- return sink;
-
-asyncqueryfailed:
- SysFreeString(query);
-formatstringfailed:
- delete sink;
- return NULL;
-}
-
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _WMIACCESSOR_H
-#define _WMIACCESSOR_H
-
-#include <Wbemidl.h>
-#include <list>
-#include <vector>
-#include <map>
-#include <string>
-
-#include "XSAccessor.h"
-
-using namespace std;
-
-typedef unsigned __int64 uint64_t;
-
-struct WMIAccessor;
-
-extern struct WMIAccessor *wmi;
-
-extern LONG wmicount;
-BOOL InitCom(void);
-void ReleaseCom(void);
-BOOL ConnectToWMI(void);
-void ReleaseWMIAccessor(struct WMIAccessor **);
-
-void UpdateProcessListInStore(WMIAccessor **wmi);
-
-int WmiSessionSetEntry(WMIAccessor** wmi, void **sessionhandle,
- const char*path, const char * value);
-
-int WmiSessionSetEntry(WMIAccessor** wmi, void **sessionhandle,
- const char*path, const char * value, size_t len);
-char* WmiSessionGetEntry(WMIAccessor** wmi, void **sessionhandle,
- const char * path, size_t* len) ;
-
-void *WmiSessionWatch(WMIAccessor** wmi, void **sessionhandle,
- const char *path, HANDLE event, HANDLE errorevent);
-BOOL WmiSessionUnwatch(WMIAccessor** wmi, void **sessionhandle,
- void *watchhandle);
-
-int WmiSessionRemoveEntry(WMIAccessor** wmi, void **sessionhandle,
- const char*path);
-
-char **WmiSessionGetChildren(WMIAccessor** wmi, void **sessionhandle,
- const char * path, unsigned *numentries);
-
-
-void *WmiUnsuspendedEventWatch(WMIAccessor **wmi, HANDLE event, HANDLE errorevent);
-
-int WmiSessionTransactionAbort(WMIAccessor** wmi, void **sessionhandle);
-int WmiSessionTransactionCommit(WMIAccessor** wmi, void **sessionhandle);
-int WmiSessionTransactionStart(WMIAccessor** wmi, void **sessionhandle);
-BOOL WmiSessionStart(WMIAccessor** wmi, void **sessionhandle, const char *sessionname);
-BOOL WmiSessionEnd(WMIAccessor** wmi, void *sessionhandle);
-FILETIME WmiGetXenTime(WMIAccessor **wmi);
-void WmiSessionLog(WMIAccessor** wmi, void **sessionhandle,const char *fmt, va_list args);
-#endif
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <windows.h>
-#include "stdafx.h"
-#include "XSAccessor.h"
-#include "WMIAccessor.h"
-
-static __declspec(thread) void *WmiSessionHandle = NULL;
-
-static LONG volatile threadcount = 0;
-static __declspec(thread) LONG localthreadcount = 0;
-static __declspec(thread) LONG localwmicount = 0;
-
-static long update_cnt=0xF0000000;
-#define XENSTORE_MAGIC 0x7e6ec123
-
-void *XsAlloc(size_t size) {
- void *buf;
-
- buf = malloc(size + 8);
- if (!buf) {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
- memset(buf, 0, size + 8);
- *(unsigned *)buf = XENSTORE_MAGIC;
- return (void *)((ULONG_PTR)buf + 8);
-}
-
-void XsFree(const void *buf) {
- void *orig_buf;
-
- if (!buf)
- return;
- orig_buf = (void *)((ULONG_PTR)buf - 8);
- if (*(unsigned *)orig_buf != XENSTORE_MAGIC) {
- OutputDebugString("XsFree() invoked on bad pointer\n");
- DebugBreak();
- }
- free(orig_buf);
-}
-
-void GetXenTime(FILETIME *now)
-{
- *now = WmiGetXenTime(&wmi);
-}
-
-
-int ListenSuspend(HANDLE event, HANDLE errorevent)
-{
- if (!WmiUnsuspendedEventWatch(&wmi, event, errorevent))
- return -1;
- else
- return 0;
-}
-
-BOOL InitXSAccessor()
-{
- OutputDebugString("XSAccessor\n");
- if (wmicount != localwmicount) {
-
- if (localthreadcount == 0) {
- localthreadcount = InterlockedIncrement(&threadcount);
- }
- char wminame[12];
- _snprintf(wminame, 12, "XS%x", localthreadcount);
- if (WmiSessionStart(&wmi, &WmiSessionHandle, wminame)) {
- localwmicount = wmicount;
- return true;
- }
- OutputDebugString("XSAccessor Failed\n");
- return false;
- }
- return true;
-}
-
-void XsLog(const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- WmiSessionLog(&wmi, &WmiSessionHandle, fmt, args);
- va_end(args);
-}
-
-
-BOOL ShutdownXSAccessor(void)
-{
- if (wmi == NULL) {
- return false;
- }
- if (WmiSessionHandle == NULL) {
- return false;
- }
- return WmiSessionEnd(&wmi, WmiSessionHandle);
-
-}
-
-int XenstorePrintf(const char *path, const char *fmt, ...)
-{
- va_list l;
- char buf[4096];
- int cnt;
-
- va_start(l, fmt);
- cnt = _vsnprintf(buf, sizeof(buf), fmt, l);
- va_end(l);
- if (cnt < 0) {
- DBGPRINT (("Cannot format data for XenstorePrintf!"));
- return -1;
- }
- OutputDebugString(buf);
- /* Now have the thing we're trying to write. */
- return WmiSessionSetEntry(&wmi, &WmiSessionHandle, path, buf);
-}
-
-BOOL XenstoreKickXapi()
-{
- /* New protocol */
- if (XenstorePrintf("data/update_cnt", "%I64d", update_cnt)){
- XsLog("New kick failed ");
- return false;
- }
- /* Old protocol */
- if (WmiSessionSetEntry(&wmi, &WmiSessionHandle, "data/updated", "1")){
- XsLog("Old kick failed");
- return false;
- }
- update_cnt++;
- return true;
-}
-
-
-int
-XenstoreRemove(const char *path)
-{
- if (wmi == NULL)
- return -1;
-
- if (WmiSessionHandle == NULL)
- return -1;
-
- if (WmiSessionRemoveEntry(&wmi, &WmiSessionHandle, path))
- return -1;
- else
- return 0;
-}
-
-ssize_t
-XenstoreRead(const char* path, char** value)
-{
- size_t len;
- *value =WmiSessionGetEntry(&wmi, &WmiSessionHandle, path, &len);
- if (*value)
- return (ssize_t)len;
- else
- return -1;
-}
-
-
-bool XenstoreReadDword(const char *path, DWORD *value) {
- char* buffer;
- ssize_t len;
- len = XenstoreRead(path, &buffer);
- if (len <= 0) {
- return false;
- }
- *value = atoi(buffer);
-
- XsFree(buffer);
-
- return true;
-}
-
-void *
-XenstoreWatch(const char *path, HANDLE event, HANDLE errorevent)
-{
-
- if (wmi == NULL) {
- OutputDebugString("WMI is null\n");
- return NULL;
- }
- if (WmiSessionHandle == NULL) {
- OutputDebugString("Session is null\n");
- return NULL;
- }
- return WmiSessionWatch(&wmi, &WmiSessionHandle, path, event, errorevent);
-}
-
-BOOL
-XenstoreUnwatch(void *watch)
-{
- return WmiSessionUnwatch(&wmi, &WmiSessionHandle, watch);
-}
-
-void
-XenstoreFree(void *tofree)
-{
- return XsFree(tofree);
-}
-
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-#ifndef _XSACCESSOR_H
-#define _XSACCESSOR_H
-
-#include <string>
-#include "windows.h"
-
-
-using namespace std;
-
-#define MAX_XENBUS_PATH 256
-
-#ifdef AMD64
-typedef long long ssize_t;
-#else
-typedef long ssize_t;
-#endif
-
-BOOL InitXSAccessor();
-BOOL ShutdownXSAccessor();
-ssize_t XenstoreRead(const char *path, char **value);
-int XenstoreRemove(const char *path);
-int XenstorePrintf(const char *path, const char *fmt, ...);
-int XenstoreWrite(const char *path, const void *data, size_t len);
-BOOL XenstoreKickXapi(void);
-void *XenstoreWatch(const char *path, HANDLE event, HANDLE errorevent);
-BOOL XenstoreUnwatch(void *watch);
-int ListenSuspend(HANDLE evt, HANDLE errorevent);
-void GetXenTime(FILETIME *res);
-void XsLog(const char *fmt, ...);
-void XenstoreFree(void *tofree);
-void *XsAlloc(size_t size);
-void XsFree(const void *buf);
-bool XenstoreReadDword(const char * path, DWORD *value);
-
-#if DBG
-
-#include <stdarg.h> // va_list
-#include <stdio.h> // vsprintf
-#include <malloc.h>
-
-#include <assert.h>
-#include <tchar.h>
-
-__inline void DebugPrint( IN LPCTSTR msg, IN ... )
-{
- TCHAR buffer[256];
- int res;
- va_list args;
-
- va_start( args, msg );
-#pragma prefast(suppress: 28719, "Yes, we all know _vsnprintf is banned in drivers, this is user level");
- res = _vsntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), msg, args);
- if (res >= 0)
- {
- OutputDebugString( buffer );
- }
- else
- {
- TCHAR *p;
- int count;
-
- count = 512;
- for (;;) {
- p = (TCHAR *)malloc(count * sizeof (TCHAR));
- if (!p) {
- OutputDebugString(_T("Out of memory for debug message!\n"));
- break;
- }
- res = _vsntprintf(p, count, msg, args);
- if (res >= 0)
- break;
-
- free(p);
- count += 256;
- }
- if (p) {
- OutputDebugString( p );
- free(p);
- }
- }
- va_end(args);
-}
-
-#define DBGPRINT(_x_) DebugPrint _x_
-#define ASSERT assert
-
-#else
-
-#define DBGPRINT(_x_)
-#define ASSERT
-
-#endif // DBG
-
-#endif
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <windows.h>
-#include <shlobj.h>
-#include <process.h>
-#include "powrprof.h"
-#include <winuser.h>
-#include "stdafx.h"
-#include "XSAccessor.h"
-#include "WMIAccessor.h"
-#include "XService.h"
-
-#include "messages.h"
-
-#include <setupapi.h>
-#include <cfgmgr32.h>
-#include <initguid.h>
-#include <devguid.h>
-#include <wintrust.h>
-#include <shellapi.h>
-
-#ifdef _WIN64
-#define XENTOOLS_INSTALL_REG_KEY "SOFTWARE\\Wow6432Node\\Citrix\\XenTools"
-#define XENTOOLS_INSTALL_REG_KEY64 "SOFTWARE\\Citrix\\XenTools"
-#else
-#define XENTOOLS_INSTALL_REG_KEY "SOFTWARE\\Citrix\\XenTools"
-#endif
-
-SERVICE_STATUS ServiceStatus;
-SERVICE_STATUS_HANDLE hStatus;
-
-static HANDLE hServiceExitEvent;
-static ULONG WindowsVersion;
-static BOOL LegacyHal = FALSE;
-static HINSTANCE local_hinstance;
-
-HANDLE eventLog;
-#define SIZECHARS(x) (sizeof((x))/sizeof(TCHAR))
-
-// Internal routines
-static DWORD WINAPI ServiceControlHandler(DWORD request, DWORD evtType,
- LPVOID, LPVOID);
-static void ServiceControlManagerUpdate(DWORD dwExitCode, DWORD dwState);
-static void WINAPI ServiceMain(int argc, char** argv);
-static void GetWindowsVersion();
-
-void PrintError(const char *func, DWORD err)
-{
- LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL);
- OutputDebugString((LPTSTR)lpMsgBuf);
- XsLog("%s failed: %s (%x)", func, lpMsgBuf, err);
- XenstorePrintf("control/error", "%s failed: %s (%x)", func, lpMsgBuf, err);
- LocalFree(lpMsgBuf);
-}
-
-void PrintError(const char *func)
-{
- PrintError(func, GetLastError());
-}
-
-void PrintUsage()
-{
- printf("Usage: xenservice [-u]\n");
-
- printf("\t -u: uninstall service\n");
-}
-
-
-
-struct watch_event {
- HANDLE event;
- void *watch;
-};
-
-static void
-ReleaseWatch(struct watch_event *we)
-{
- if (we == NULL)
- return;
- if (we->event != INVALID_HANDLE_VALUE)
- CloseHandle(we->event);
- if (we->watch)
- XenstoreUnwatch(we->watch);
- free(we);
-}
-
-static char * InitString(const char * inputstring)
-{
- char *outputstring = (char *)calloc((strlen(inputstring)+1),sizeof(char));
- if (outputstring == NULL)
- goto failalloc;
- strcpy(outputstring, inputstring);
- return outputstring;
-
-failalloc:
- XsLog(__FUNCTION__ " : Fail malloc");
- return NULL;
-}
-
-static void FreeString(const char *string)
-{
- free((void *)string);
-}
-
-static char* PrintfString(const char *fmt, ...){
- va_list l;
- va_start(l, fmt);
- int numchars = _vscprintf(fmt, l);
- char *outputstring = (char *)calloc(numchars + 1, sizeof(char));
-
- if (outputstring == NULL)
- return NULL;
-
- _vsnprintf(outputstring, numchars, fmt, l);
- return outputstring;
-}
-
-static struct watch_event *
-EstablishWatch(const char *path, HANDLE errorevent)
-{
- struct watch_event *we;
- DWORD err;
- XsLog("Establish watch %s",path);
- we = (struct watch_event *)malloc(sizeof(*we));
- if (!we) {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
- memset(we, 0, sizeof(*we));
- we->watch = NULL;
- we->event = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (we->event != INVALID_HANDLE_VALUE)
- we->watch = XenstoreWatch(path, we->event, errorevent);
- if (we->watch == NULL) {
- OutputDebugString("Watch is null\n");
- err = GetLastError();
- ReleaseWatch(we);
- SetLastError(err);
- return NULL;
- }
- return we;
-}
-
-struct watch_feature {
- struct watch_event *watch;
- const char *feature_flag;
- const char *name;
- BOOL (*handler)(void *);
- void *ctx;
-};
-
-#define MAX_FEATURES 10
-struct watch_feature_set {
- struct watch_feature features[MAX_FEATURES];
- unsigned nr_features;
-};
-
-static BOOL
-AddFeature(struct watch_feature_set *wfs, const char *path,
- const char *flag, const char *name,
- BOOL (*handler)(void *), void *ctx, HANDLE errorevent)
-{
- unsigned n;
- if (wfs->nr_features == MAX_FEATURES)
- goto failfeatures;
-
- n = wfs->nr_features;
-
- wfs->features[n].watch = EstablishWatch(path, errorevent);
- if (wfs->features[n].watch == NULL)
- goto failwatch;
-
- wfs->features[n].feature_flag = flag;
- wfs->features[n].handler = handler;
- wfs->features[n].ctx = ctx;
- wfs->features[n].name = InitString(name);
- if (wfs->features[n].name == NULL)
- goto failname;
- wfs->nr_features++;
- return true;
-
-failname:
- PrintError("Failed to allocate string");
-failwatch:
- PrintError("EstablishWatch() for AddFeature()");
-failfeatures:
- XsLog("Too many features");
- PrintError("Too many features!", ERROR_INVALID_FUNCTION);
- return false;
-}
-
-static void RemoveFeatures(struct watch_feature_set *wfs) {
- unsigned x;
- for (x = 0; x < wfs->nr_features; x++) {
- ReleaseWatch(wfs->features[x].watch);
- wfs->features[x].watch = NULL;
- FreeString(wfs->features[x].name);
- XenstoreRemove(wfs->features[x].feature_flag);
- }
- wfs->nr_features = 0;
-}
-
-static BOOL
-AdvertiseFeatures(struct watch_feature_set *wfs)
-{
- unsigned x;
- for (x = 0; x < wfs->nr_features; x++) {
- if (wfs->features[x].feature_flag != NULL)
- if (XenstorePrintf(wfs->features[x].feature_flag, "1")){
- XsLog("Failed to advertise %s",wfs->features[x].name);
- }
- }
- return true;
-}
-
-
-void ServiceUninstall()
-{
- SC_HANDLE hSvc;
- SC_HANDLE hMgr;
-
- hMgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
-
- if ( hMgr )
- {
- hSvc = OpenService(hMgr, SVC_NAME, SERVICE_ALL_ACCESS);
-
- if (hSvc)
- {
- // try to stop the service
- if ( ControlService( hSvc, SERVICE_CONTROL_STOP, &ServiceStatus ) )
- {
- printf("Stopping %s.", SVC_DISPLAYNAME);
- Sleep( 1000 );
-
- while ( QueryServiceStatus( hSvc, &ServiceStatus ) )
- {
- if ( ServiceStatus.dwCurrentState == SERVICE_STOP_PENDING )
- {
- printf(".");
- Sleep( 1000 );
- }
- else
- break;
- }
-
- if ( ServiceStatus.dwCurrentState == SERVICE_STOPPED )
- printf("\n%s stopped.\n", SVC_DISPLAYNAME );
- else
- printf("\n%s failed to stop.\n", SVC_DISPLAYNAME );
- }
-
- // now remove the service
- if ( DeleteService(hSvc) )
- printf("%s uninstalled.\n", SVC_DISPLAYNAME );
- else
- printf("Unable to uninstall - %d\n", GetLastError());
-
- CloseServiceHandle(hSvc);
-
- }
- else
- printf("Unable to open service - %d\n", GetLastError());
-
- CloseServiceHandle(hMgr);
- }
- else
- printf("Unable to open scm - %d\n", GetLastError());
-
-}
-
-
-int __stdcall
-WinMain(HINSTANCE hInstance, HINSTANCE ignore,
- LPSTR lpCmdLine, int nCmdShow)
-{
- local_hinstance = hInstance;
-
- if (strlen(lpCmdLine) == 0) {
- SERVICE_TABLE_ENTRY ServiceTable[2];
- ServiceTable[0].lpServiceName = SVC_NAME;
- ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
-
- ServiceTable[1].lpServiceName = NULL;
- ServiceTable[1].lpServiceProc = NULL;
-
- DBGPRINT(("XenSvc: starting ctrl dispatcher "));
-
- // Start the control dispatcher thread for our service
- if (!StartServiceCtrlDispatcher(ServiceTable))
- {
- int err = GetLastError();
- if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
- {
- DBGPRINT(("XenSvc: unable to start ctrl dispatcher - %d", GetLastError()));
- }
- }
- else
- {
- // We get here when the service is shut down.
- }
- } else if (!strcmp(lpCmdLine, "-u") || !strcmp(lpCmdLine, "\"-u\"")) {
- ServiceUninstall();
- } else {
- PrintUsage();
- }
-
- return 0;
-}
-
-void AcquireSystemPrivilege(LPCTSTR name)
-{
- HANDLE token;
- TOKEN_PRIVILEGES tkp;
- DWORD err;
-
- LookupPrivilegeValue(NULL, name, &tkp.Privileges[0].Luid);
- tkp.PrivilegeCount = 1;
- tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- if (!OpenProcessToken(GetCurrentProcess(),
- TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,
- &token)) {
- DBGPRINT(("Failed to open local token.\n"));
- } else {
- AdjustTokenPrivileges(token, FALSE, &tkp,
- NULL, 0, NULL);
- err = GetLastError();
- if (err != ERROR_SUCCESS) {
- PrintError("AdjustTokenPrivileges", err);
- }
- }
-}
-
-static void AcquireSystemShutdownPrivilege(void)
-{
- AcquireSystemPrivilege(SE_SHUTDOWN_NAME);
-}
-
-enum XShutdownType {
- XShutdownPoweroff,
- XShutdownReboot,
- XShutdownSuspend,
- XShutdownS3
-};
-
-static BOOL maybeReboot(void *ctx)
-{
- char *shutdown_type;
- BOOL res;
- enum XShutdownType type;
- int cntr = 0;
-
- XsLog("Check if we need to shutdown");
-
- if (XenstoreRead("control/shutdown", &shutdown_type) < 0) {
- XsLog("No need to shutdown");
- return true;
- }
- XsLog("Shutdown type %s\n", shutdown_type);
- if (strcmp(shutdown_type, "poweroff") == 0 ||
- strcmp(shutdown_type, "halt") == 0) {
- type = XShutdownPoweroff;
- } else if (strcmp(shutdown_type, "reboot") == 0) {
- type = XShutdownReboot;
- } else if (strcmp(shutdown_type, "hibernate") == 0) {
- type = XShutdownSuspend;
- } else if (strcmp(shutdown_type, "s3") == 0) {
- type = XShutdownS3;
- } else {
- DBGPRINT(("Bad shutdown type %s\n", shutdown_type));
- goto out;
- }
-
- XsLog("Report Shutdown Event");
- /* We try to shutdown even if this fails, since it might work
- and it can't do any harm. */
- AcquireSystemShutdownPrivilege();
-
- if (eventLog) {
- DWORD eventId;
-
- switch (type) {
- case XShutdownPoweroff:
- eventId = EVENT_XENUSER_POWEROFF;
- break;
- case XShutdownReboot:
- eventId = EVENT_XENUSER_REBOOT;
- break;
- case XShutdownSuspend:
- eventId = EVENT_XENUSER_HIBERNATE;
- break;
- case XShutdownS3:
- eventId = EVENT_XENUSER_S3;
- break;
- }
- }
-
- XsLog("Do the shutdown");
-
- /* do the shutdown */
- switch (type) {
- case XShutdownPoweroff:
- case XShutdownReboot:
- if (WindowsVersion >= 0x500 && WindowsVersion < 0x600)
- {
- /* Windows 2000 InitiateSystemShutdownEx is funny in
- various ways (e.g. sometimes fails to power off after
- shutdown, especially if the local terminal is locked,
- not doing anything if there's nobody logged on, etc.).
- ExitWindowsEx seems to be more reliable, so use it
- instead. */
- /* XXX I don't really understand why
- InitiateSystemShutdownEx behaves so badly. */
- /* If this is a legacy hal then use EWX_SHUTDOWN when shutting
- down instead of EWX_POWEROFF. */
- /* Similar problem on XP. Shutdown/Reboot will hang until the Welcome
- screen screensaver is dismissed by the guest */
-#pragma warning (disable : 28159)
- res = ExitWindowsEx((type == XShutdownReboot ?
- EWX_REBOOT :
- (LegacyHal ?
- EWX_SHUTDOWN :
- EWX_POWEROFF))|
- EWX_FORCE,
- SHTDN_REASON_MAJOR_OTHER|
- SHTDN_REASON_MINOR_ENVIRONMENT |
- SHTDN_REASON_FLAG_PLANNED);
-#pragma warning (default: 28159)
- if (!res) {
- PrintError("ExitWindowsEx");
- return false;
- }
- else
- {
- if (XenstoreRemove("control/shutdown"))
- return false;
- }
- } else {
-#pragma warning (disable : 28159)
- res = InitiateSystemShutdownEx(
- NULL,
- NULL,
- 0,
- TRUE,
- type == XShutdownReboot,
- SHTDN_REASON_MAJOR_OTHER |
- SHTDN_REASON_MINOR_ENVIRONMENT |
- SHTDN_REASON_FLAG_PLANNED);
-#pragma warning (default: 28159)
- if (!res) {
- PrintError("InitiateSystemShutdownEx");
- return false;
- } else {
- if (XenstoreRemove("control/shutdown"))
- return false;
- }
- }
- break;
- case XShutdownSuspend:
- if (XenstorePrintf ("control/hibernation-state", "started"))
- return false;
- /* Even if we think hibernation is disabled, try it anyway.
- It's not like it can do any harm. */
- res = SetSystemPowerState(FALSE, FALSE);
- if (XenstoreRemove ("control/shutdown"))
- {
- return false;
- }
- if (!res) {
- /* Tell the tools that we've failed. */
- PrintError("SetSystemPowerState");
- if (XenstorePrintf ("control/hibernation-state", "failed"))
- return false;
- }
- break;
- case XShutdownS3:
- if (XenstorePrintf ("control/s3-state", "started"))
- return false;
- res = SetSuspendState(FALSE, TRUE, FALSE);
- XenstoreRemove ("control/shutdown");
- if (!res) {
- PrintError("SetSuspendState");
- if (XenstorePrintf ("control/s3-state", "failed"))
- return false;
- }
- break;
- }
-
-out:
- XenstoreFree(shutdown_type);
- return true;
-}
-
-static bool registryMatchString(HKEY hKey,
- LPCTSTR lpValueName,
- LPCTSTR comparestring,
- bool matchcase)
-{
- bool result = false;
- LONG buffersize = sizeof(TCHAR)*256;
- TCHAR *outstring = NULL;
- DWORD outstringsize;
- LONG status;
- do {
- outstringsize = buffersize;
- outstring = (TCHAR *)realloc(outstring, outstringsize);
-
- status = RegQueryValueEx(hKey,
- lpValueName,
- NULL,
- NULL,
- (LPBYTE) outstring,
- &outstringsize);
- buffersize *= 2;
- } while (status == ERROR_MORE_DATA);
-
- if (status == ERROR_FILE_NOT_FOUND)
- goto done;
-
- if (matchcase) {
- if (_tcsncmp(comparestring, outstring, outstringsize))
- goto done;
- }
- else {
- if (_tcsnicoll(comparestring, outstring, outstringsize))
- goto done;
- }
-
- result = true;
-
-done:
- free(outstring);
-
- return result;
-}
-
-static bool
-adjustXenTimeToUTC(FILETIME *now)
-{
- DWORD dwtimeoffset;
- long timeoffset;
- char *vm;
- char *rtckey;
- LARGE_INTEGER longoffset;
- ULARGE_INTEGER longnow;
- size_t vmlen;
-
- // XenTime is assumed to be in UTC, so we need to remove any
- // offsets that are applied to it
-
- __try {
- vmlen = XenstoreRead("vm", &vm);
- if (vmlen <= 0)
- goto fail_readvm;
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- goto fail_readvm;
- }
-
- rtckey = PrintfString("%s/rtc/timeoffset", vm);
- if (rtckey == NULL)
- goto fail_rtckey;
-
- _try {
- BOOL rtcreadworked;
- __try {
- rtcreadworked = XenstoreReadDword(rtckey, &dwtimeoffset);
- }
- __except(EXCEPTION_EXECUTE_HANDLER) {
- rtcreadworked = false;
- }
- if (!rtcreadworked) {
- if (!XenstoreReadDword("platform/timeoffset", &dwtimeoffset))
- goto fail_platformtimeoffset;
- }
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- goto fail_platformtimeoffset;
- }
- timeoffset = (long)dwtimeoffset;
-
- //Convert offset from seconds to nanoseconds
- longoffset.QuadPart = (LONGLONG)timeoffset;
- longoffset.QuadPart = longoffset.QuadPart * 10000000;
-
- // Subtract nanosecond timeoffset from now
- longnow.LowPart = now->dwLowDateTime;
- longnow.HighPart = now->dwHighDateTime;
- longnow.QuadPart -= longoffset.QuadPart;
- now->dwLowDateTime = longnow.LowPart;
- now->dwHighDateTime = longnow.HighPart;
-
- FreeString(rtckey);
- XsFree(vm);
- return true;
-
-fail_platformtimeoffset:
- XsLog("%s: Read platform time offset", __FUNCTION__);
- FreeString(rtckey);
-
-fail_rtckey:
- XsLog("%s: Read RTC Key", __FUNCTION__);
- XsFree(vm);
-
-fail_readvm:
- XsLog("%s: Read VM Key", __FUNCTION__);
- return false;
-}
-
-static bool hosttimeIsUTC()
-{
- HKEY InstallRegKey;
- bool utc = false;
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- XENTOOLS_INSTALL_REG_KEY,
- 0,
- KEY_ALL_ACCESS,
- &InstallRegKey) != ERROR_SUCCESS)
- goto fail_registrykey;
-
-#ifdef _WIN64
-
- if (registryMatchString(InstallRegKey, "HostTime", "UTC", false))
- {
- utc = true;
- goto done;
- }
-
- RegCloseKey(InstallRegKey);
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- XENTOOLS_INSTALL_REG_KEY64,
- 0,
- KEY_ALL_ACCESS,
- &InstallRegKey) != ERROR_SUCCESS)
- goto fail_registrykey;
-
-#endif
-
- if (registryMatchString(InstallRegKey, "HostTime", "UTC", false))
- {
- utc=true;
- }
-
-#ifdef _WIN64
-done:
-#endif
- RegCloseKey(InstallRegKey);
- return utc;
-
-fail_registrykey:
- XsLog("%s: Open Registry Key", __FUNCTION__);
-
- return false;
-}
-
-static void
-setTimeToXenTime(void)
-{
- FILETIME now = {0};
- SYSTEMTIME sys_time;
- SYSTEMTIME current_time;
- bool utc=false;
- XsLog("Set time to XenTime");
-
- GetXenTime(&now);
- if ((now.dwLowDateTime == 0) && (now.dwHighDateTime == 0)) {
- XsLog("Cannot set system time to xentime, unable to contact WMI");
- goto fail_readtime;
- }
-
- utc = hosttimeIsUTC();
-
- if (utc) {
- XsLog("Try UTC");
- if (!adjustXenTimeToUTC(&now))
- goto fail_adjusttime;
- }
-
- if (!FileTimeToSystemTime(&now, &sys_time)) {
- XsLog("Gould not convert file time to system time");
- PrintError("FileTimeToSystemTime()");
- DBGPRINT(("FileTimeToSystemTime(%x.%x)\n",
- now.dwLowDateTime, now.dwHighDateTime));
- } else {
- GetLocalTime(¤t_time);
- XsLog("Time is now %d.%d.%d %d:%d:%d.%d",
- current_time.wYear, current_time.wMonth, current_time.wDay,
- current_time.wHour, current_time.wMinute, current_time.wSecond,
- current_time.wMilliseconds);
- XsLog("Set time to %d.%d.%d %d:%d:%d.%d",
- sys_time.wYear, sys_time.wMonth, sys_time.wDay,
- sys_time.wHour, sys_time.wMinute, sys_time.wSecond,
- sys_time.wMilliseconds);
- if (utc) {
- if (!SetSystemTime(&sys_time))
- PrintError("SetSystemTime()");
- }
- else {
- if (!SetLocalTime(&sys_time))
- PrintError("SetLocalTime()");
- }
- }
-
- return;
-
-fail_adjusttime:
- XsLog("%s: Adjust time", __FUNCTION__);
-
-fail_readtime:
- XsLog("%s: ReadTime", __FUNCTION__);
-}
-
-/* We need to resync the clock when we recover from suspend/resume. */
-static void
-finishSuspend(void)
-{
- DBGPRINT(("Coming back from suspend.\n"));
- setTimeToXenTime();
-}
-
-
-
-//
-// Main loop
-//
-BOOL Run()
-{
- bool exit=false;
- PCHAR pPVAddonsInstalled = NULL;
-
- HANDLE suspendEvent;
-
- int cntr = 0;
- struct watch_feature_set features;
- BOOL snap = FALSE;
-
- OutputDebugString("Trying to connect to WMI\n");
- while (!ConnectToWMI()) {
- OutputDebugString("Unable to connect to WMI, sleeping\n");
- if (WaitForSingleObject(hServiceExitEvent, 1000*10) == WAIT_OBJECT_0) {
- exit = true;
- return exit;
- }
- }
- while (InitXSAccessor()==false) {
- OutputDebugString("Unable to initialise WMI session, sleeping\n");
- if (WaitForSingleObject(hServiceExitEvent, 1000*10) == WAIT_OBJECT_0) {
- exit = true;
- return exit;
- }
- }
- XsLog("Guest agent lite main loop starting");
-
- if (eventLog == NULL)
- XsLog("Event log was not initialised");
-
- setTimeToXenTime();
-
- memset(&features, 0, sizeof(features));
-
- HANDLE wmierrorEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (!wmierrorEvent) {
- PrintError("CreateEvent() wmierrorEvent");
- return exit;
- }
-
-
- XsLog("About to add feature shutdown");
- if (!AddFeature(&features, "control/shutdown", "control/feature-shutdown",
- "shutdown", maybeReboot, NULL, wmierrorEvent)) {
- return exit;
- }
-
- suspendEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (!suspendEvent) {
- PrintError("CreateEvent() suspendEvent");
- return exit;
- }
-
- if (ListenSuspend(suspendEvent, wmierrorEvent) < 0) {
- PrintError("ListenSuspend()");
- CloseHandle(suspendEvent);
- suspendEvent = NULL;
- return exit;
- }
-
-
- XsLog("About to advertise features");
- AdvertiseFeatures(&features);
-
- XsLog("About to kick xapi ");
- XenstoreKickXapi();
-
- while (1)
- {
- DWORD status;
- int nr_handles = 1;
- HANDLE handles[3 + MAX_FEATURES];
- unsigned x;
-
- handles[0] = hServiceExitEvent;
- if (wmierrorEvent)
- handles[nr_handles++] = wmierrorEvent;
- if (suspendEvent)
- handles[nr_handles++] = suspendEvent;
- for (x = 0; x < features.nr_features; x++)
- handles[nr_handles++] = features.features[x].watch->event;
-
- XsLog("win agent going to sleep");
- status = WaitForMultipleObjects(nr_handles, handles, FALSE, INFINITE);
- XsLog("win agent woke up for %d", status);
-
- /* WAIT_OBJECT_0 happens to be 0, so the compiler gets shirty
- about status >= WAIT_OBJECT_0 (since status is unsigned).
- This is more obviously correct than the compiler-friendly
- version, though, so just disable the warning. */
-
-#pragma warning (disable: 4296)
- if (status >= WAIT_OBJECT_0 &&
- status < WAIT_OBJECT_0 + nr_handles)
-#pragma warning (default: 4296)
- {
- HANDLE event = handles[status - WAIT_OBJECT_0];
- if (event == hServiceExitEvent)
- {
- XsLog("service exit event");
- exit = true;
- break;
- }
- else if (event == suspendEvent)
- {
- if (!ReportEvent(eventLog, EVENTLOG_SUCCESS, 0, EVENT_XENUSER_UNSUSPENDED, NULL, 0, 0,
- NULL, NULL)) {
- XsLog("Cannot send to event log %x",GetLastError());
- }
- XsLog("Suspend event");
- finishSuspend();
- AdvertiseFeatures(&features);
- XenstoreKickXapi();
- XsLog("Handled suspend event");
- }
- else if (event == wmierrorEvent)
- {
- ReportEvent(eventLog, EVENTLOG_SUCCESS, 0, EVENT_XENUSER_WMI, NULL, 0, 0,
- NULL, NULL);
- break;
- }
- else
- {
- BOOL fail = false;
- for (x = 0; x < features.nr_features; x++) {
- if (features.features[x].watch->event == event) {
- XsLog("Fire %p",features.features[x].name);
- XsLog("fire feature %s", features.features[x].name);
- OutputDebugString("Event triggered\n");
- if (!(features.features[x].handler(features.features[x].ctx)))
- {
- XsLog("Firing feature failed");
- PrintError("Feature failed");
- fail = true;
- }
- XsLog("fired feature %s",
- features.features[x].name);
- }
- }
- if (fail) {
- XsLog("Resetting");
- ReportEvent(eventLog, EVENTLOG_SUCCESS, 0, EVENT_XENUSER_UNEXPECTED, NULL, 0, 0,
- NULL, NULL);
- break;
- }
- }
- }
- else
- {
- PrintError("WaitForMultipleObjects()");
- break;
- }
- }
- OutputDebugString("WMI Watch loop terminated\n");
- RemoveFeatures(&features);
- XenstoreKickXapi();
-
- XsLog("Guest agent lite loop finishing");
- ReleaseWMIAccessor(&wmi);
-
-
-
-
- XsLog("Guest agent lite loop finished %d", exit);
- return exit;
-}
-
-
-// Service initialization
-bool ServiceInit()
-{
- ServiceStatus.dwServiceType = SERVICE_WIN32;
- ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
- ServiceStatus.dwControlsAccepted =
- SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN |
- SERVICE_ACCEPT_SESSIONCHANGE;
- ServiceStatus.dwWin32ExitCode = 0;
- ServiceStatus.dwServiceSpecificExitCode = 0;
- ServiceStatus.dwCheckPoint = 0;
- ServiceStatus.dwWaitHint = 0;
-
- hStatus = RegisterServiceCtrlHandlerEx(
- "XenService",
- ServiceControlHandler,
- NULL);
- if (hStatus == (SERVICE_STATUS_HANDLE)0)
- {
- // Registering Control Handler failed
- DBGPRINT(("XenSvc: Registering service control handler failed - %d\n", GetLastError()));
- return false;
- }
-
- ServiceStatus.dwCurrentState = SERVICE_RUNNING;
- SetServiceStatus (hStatus, &ServiceStatus);
-
- return true;
-}
-
-void WINAPI ServiceMain(int argc, char** argv)
-{
- // Perform common initialization
- eventLog = RegisterEventSource(NULL, "xensvc");
- hServiceExitEvent = CreateEvent(NULL, false, false, NULL);
- if (hServiceExitEvent == NULL)
- {
- DBGPRINT(("XenSvc: Unable to create the event obj - %d\n", GetLastError()));
- return;
- }
-
- if (!ServiceInit())
- {
- DBGPRINT(("XenSvc: Unable to init xenservice\n"));
- return;
- }
- BOOL stopping;
-
- do {
-
- __try
- {
- stopping = Run();
-
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- __try {
- XsLog("Exception hit %x", GetExceptionCode());
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- }
- stopping = false;
- }
- } while (!stopping);
-
- XsLog("Guest agent service stopped");
- ShutdownXSAccessor();
- DeregisterEventSource(eventLog);
- ServiceControlManagerUpdate(0, SERVICE_STOPPED);
- return;
-}
-
-void ServiceControlManagerUpdate(DWORD dwExitCode, DWORD dwState)
-{
- ServiceStatus.dwWin32ExitCode = dwExitCode;
- ServiceStatus.dwCurrentState = dwState;
- SetServiceStatus (hStatus, &ServiceStatus);
-}
-
-// Service control handler function
-static DWORD WINAPI ServiceControlHandler(DWORD request, DWORD evtType,
- LPVOID eventData, LPVOID ctxt)
-{
- UNREFERENCED_PARAMETER(ctxt);
- UNREFERENCED_PARAMETER(eventData);
-
- switch(request)
- {
- case SERVICE_CONTROL_STOP:
- DBGPRINT(("XenSvc: xenservice stopped.\n"));
- ServiceControlManagerUpdate(0, SERVICE_STOP_PENDING);
- SetEvent(hServiceExitEvent);
- return NO_ERROR;
-
- case SERVICE_CONTROL_SHUTDOWN:
- DBGPRINT(("XenSvc: xenservice shutdown.\n"));
- ServiceControlManagerUpdate(0, SERVICE_STOP_PENDING);
- SetEvent(hServiceExitEvent);
- return NO_ERROR;
-
- default:
- DBGPRINT(("XenSvc: unknown request."));
- break;
- }
-
- ServiceControlManagerUpdate(0, SERVICE_RUNNING);
- return ERROR_CALL_NOT_IMPLEMENTED;
-}
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _XSERVICE_H
-#define _XSERVICE_H
-
-#include <version.h>
-
-#define SVC_NAME "xensvc"
-#define SVC_DISPLAYNAME PRODUCT_NAME_STR ## "Interface Service"
-#define SVC_DESC "Monitors and provides various metrics to XenStore"
-
-void PrintError(const char *func);
-void PrintError(const char *func, DWORD err);
-void StartClipboardSync(void);
-void FinishClipboardSync(void);
-void ClipboardConsoleChanged(void);
-
-void XsDumpLogThisThread(void);
-void XsInitPerThreadLogging(void);
-void XsLogMsg(const char *fmt, ...);
-void DoVolumeDump(void);
-
-void AcquireSystemPrivilege(LPCTSTR name);
-
-#endif
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* Black-box data recorder. This records stuff which is happening
- while the agent runs, and tries to push it out to dom0 syslog if we
- crash. */
-#include "stdafx.h"
-#include <windows.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "XService.h"
-#include "XSAccessor.h"
-
-
-#define RING_SIZE 8192
-
-struct message_ring {
- HANDLE handle;
- unsigned prod_idx;
- unsigned cons_idx;
- unsigned char payload[RING_SIZE];
-};
-
-static __declspec(thread) struct message_ring message_ring;
-
-static char *
-Xsvasprintf(const char *fmt, va_list args)
-{
- char *work;
- int work_size;
- int r;
-
- work_size = 32;
- while (1) {
- work = (char *)malloc(work_size);
- if (!work)
- return work;
- r = _vsnprintf(work, work_size, fmt, args);
- if (r == 0) {
- free(work);
- return NULL;
- }
- if (r != -1 && r < work_size) {
- return work;
- }
- free(work);
- work_size *= 2;
- }
-}
-
-static char *
-Xsasprintf(const char *fmt, ...)
-{
- va_list args;
- char *res;
-
- va_start(args, fmt);
- res = Xsvasprintf(fmt, args);
- va_end(args);
- return res;
-}
-
-void
-XsLogMsg(const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- XsLog(fmt, args);
- va_end(args);
-}
-
-
+++ /dev/null
-SeverityNames=(Informational=0x1)
-FacilityNames=(XenUser=0xd60)
-
-MessageId=0x0001
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_POWEROFF
-Language=English
-The tools requested that the local VM shut itself down.
-.
-
-MessageId=0x0002
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_REBOOT
-Language=English
-The tools requested that the local VM reboot.
-.
-
-MessageId=0x0003
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_HIBERNATE
-Language=English
-The tools requested that the local VM hibernate itself.
-.
-
-MessageId=0x0004
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_S3
-Language=English
-The tools requested that the local VM enter power state S3.
-.
-
-MessageId=0x0005
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_WMI
-Language=English
-The tools noticed that WMI became non-functional.
-.
-
-MessageId=0x0006
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_STARTED
-Language=English
-The tools initiated.
-.
-
-MessageId=0x0007
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_UNSUSPENDED
-Language=English
-The tools returned from suspend.
-.
-
-MessageId=0x0008
-Facility=XenUser
-Severity=Informational
-SymbolicName=EVENT_XENUSER_UNEXPECTED
-Language=English
-The tools experienced an unexpected error.
-.
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-// stdafx.cpp : source file that includes just the standard includes
-// XenService.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-
-#include <iostream>
-#include <tchar.h>
-
-// TODO: reference additional headers your program requires here
+++ /dev/null
-/* Copyright (c) Citrix Systems Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms,
- * with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-#include <windows.h>
-#include <ntverp.h>
-
-#undef VER_COMPANYNAME_STR
-#undef VER_PRODUCTNAME_STR
-#undef VER_PRODUCTVERSION
-#undef VER_PRODUCTVERSION_STR
-
-#include <version.h>
-
-#define VER_COMPANYNAME_STR VENDOR_NAME_STR
-#define VER_LEGALCOPYRIGHT_STR "Copyright (c) Citrix Systems Inc."
-
-#define VER_PRODUCTNAME_STR "XENIFACE"
-#define VER_PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,BUILD_NUMBER
-#define VER_PRODUCTVERSION_STR MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR
-
-#define VER_INTERNALNAME_STR "w32xagent.exe"
-#define VER_FILEVERSION_STR "1.0"
-#define VER_FILEDESCRIPTION_STR "w32agent"
-#define VER_ORIGINALFILENAME_STR "w32xagent.exe"
-#define VER_FILETYPE VFT_APP
-#define VER_FILESUBTYPE 0
-
-xen_icon ICON "xen.ico"
-
-#include "common.ver"
-#include "messages.rc"
\ No newline at end of file
--- /dev/null
+SeverityNames=(Informational=0x1)
+FacilityNames=(XenUser=0xd60)
+
+MessageId=0x0001
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_POWEROFF
+Language=English
+The tools requested that the local VM shut itself down.
+.
+
+MessageId=0x0002
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_REBOOT
+Language=English
+The tools requested that the local VM reboot.
+.
+
+MessageId=0x0003
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_HIBERNATE
+Language=English
+The tools requested that the local VM hibernate itself.
+.
+
+MessageId=0x0004
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_S3
+Language=English
+The tools requested that the local VM enter power state S3.
+.
+
+MessageId=0x0005
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_WMI
+Language=English
+The tools noticed that WMI became non-functional.
+.
+
+MessageId=0x0006
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_STARTED
+Language=English
+The tools initiated.
+.
+
+MessageId=0x0007
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_UNSUSPENDED
+Language=English
+The tools returned from suspend.
+.
+
+MessageId=0x0008
+Facility=XenUser
+Severity=Informational
+SymbolicName=EVENT_XENUSER_UNEXPECTED
+Language=English
+The tools experienced an unexpected error.
+.
--- /dev/null
+/* Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define INITGUID
+#include <windows.h>
+#include <stdio.h>
+
+#include <xeniface_ioctls.h>
+
+#include "service.h"
+#include "messages.h"
+
+int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE ignore, LPSTR lpCmdLine, int nCmdShow)
+{
+ if (strlen(lpCmdLine) != 0) {
+ if (!strcmp(lpCmdLine, "-i") || !strcmp(lpCmdLine, "\"-i\""))
+ return CXenAgent::ServiceInstall();
+ if (!strcmp(lpCmdLine, "-u") || !strcmp(lpCmdLine, "\"-u\""))
+ return CXenAgent::ServiceUninstall();
+ }
+ return CXenAgent::ServiceEntry();
+}
+
+static CXenAgent s_service;
+
+/*static*/ void CXenAgent::Log(const char* fmt, ...)
+{
+ char message[XENIFACE_LOG_MAX_LENGTH];
+ va_list args;
+
+ va_start(args, fmt);
+ vsnprintf_s(message, sizeof(message), sizeof(message)/sizeof(message[0]) - 1, fmt, args);
+ va_end(args);
+
+ OutputDebugString(message);
+}
+
+/*static*/ int CXenAgent::ServiceInstall()
+{
+ SC_HANDLE svc, mgr;
+ char path[MAX_PATH+1];
+
+ mgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (mgr == NULL)
+ return -1;
+
+ if (GetModuleFileNameA(NULL, path, MAX_PATH) == 0) {
+ CloseServiceHandle(mgr);
+ return GetLastError();
+ }
+ path[MAX_PATH] = 0;
+
+ svc = CreateServiceA(mgr, SVC_NAME, SVC_DISPLAYNAME, SERVICE_ALL_ACCESS,
+ SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
+ SERVICE_ERROR_NORMAL, path,
+ NULL, NULL, NULL, NULL, NULL);
+ if (svc == NULL) {
+ CloseServiceHandle(mgr);
+ return -2;
+ }
+
+ CloseServiceHandle(svc);
+ CloseServiceHandle(mgr);
+ return 0;
+}
+
+/*static*/ int CXenAgent::ServiceUninstall()
+{
+ SC_HANDLE svc, mgr;
+
+ mgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (mgr == NULL)
+ return -1;
+
+ svc = OpenService(mgr, SVC_NAME, SERVICE_ALL_ACCESS);
+ if (svc == NULL) {
+ CloseServiceHandle(mgr);
+ return -2;
+ }
+
+ // try to stop the service
+ if (ControlService(svc, SERVICE_CONTROL_STOP, &s_service.m_status))
+ {
+ Sleep( 1000 );
+
+ while (QueryServiceStatus(svc, &s_service.m_status))
+ {
+ if (s_service.m_status.dwCurrentState != SERVICE_STOP_PENDING)
+ break;
+ Sleep(1000);
+ }
+ }
+
+ // now remove the service
+ DeleteService(svc);
+ CloseServiceHandle(svc);
+ CloseServiceHandle(mgr);
+ return 0;
+}
+
+/*static*/ int CXenAgent::ServiceEntry()
+{
+ SERVICE_TABLE_ENTRY ServiceTable[2] =
+ {
+ { SVC_NAME, (LPSERVICE_MAIN_FUNCTION)ServiceMain },
+ { NULL, NULL }
+ };
+
+ if (!StartServiceCtrlDispatcher(ServiceTable)) {
+ CXenAgent::Log("Failed to start dispatcher\n");
+ return GetLastError();
+ }
+ return 0;
+}
+
+/*static*/ void WINAPI CXenAgent::ServiceMain(int argc, char** argv)
+{
+ s_service.__ServiceMain(argc, argv);
+}
+
+/*static*/ DWORD WINAPI CXenAgent::ServiceControlHandlerEx(DWORD req, DWORD evt, LPVOID data, LPVOID ctxt)
+{
+ return s_service.__ServiceControlHandlerEx(req, evt, data, ctxt);
+}
+
+CXenAgent::CXenAgent() : m_handle(NULL), m_evtlog(NULL)
+{
+ m_status.dwServiceType = SERVICE_WIN32;
+ m_status.dwCurrentState = SERVICE_START_PENDING;
+ m_status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
+ m_status.dwWin32ExitCode = 0;
+ m_status.dwServiceSpecificExitCode = 0;
+ m_status.dwCheckPoint = 0;
+ m_status.dwWaitHint = 0;
+
+ m_svc_stop = CreateEvent(FALSE, NULL, NULL, FALSE);
+}
+
+CXenAgent::~CXenAgent()
+{
+ CloseHandle(m_svc_stop);
+}
+
+void CXenAgent::OnServiceStart()
+{
+ CXenAgent::Log("OnServiceStart()\n");
+}
+
+void CXenAgent::OnServiceStop()
+{
+ CXenAgent::Log("OnServiceStop()\n");
+}
+
+void CXenAgent::OnDeviceEvent(DWORD evt, LPVOID data)
+{
+}
+
+bool CXenAgent::ServiceMainLoop()
+{
+ WaitForSingleObject(m_svc_stop, INFINITE);
+ return false;
+}
+
+void CXenAgent::SetServiceStatus(DWORD state, DWORD exit /*= 0*/, DWORD hint /*= 0*/)
+{
+ m_status.dwCurrentState = state;
+ m_status.dwWin32ExitCode = exit;
+ m_status.dwWaitHint = hint;
+ ::SetServiceStatus(m_handle, &m_status);
+}
+
+void WINAPI CXenAgent::__ServiceMain(int argc, char** argv)
+{
+ m_handle = RegisterServiceCtrlHandlerEx(SVC_NAME, ServiceControlHandlerEx, NULL);
+ if (m_handle == NULL)
+ return;
+
+ m_evtlog = RegisterEventSource(NULL, SVC_NAME);
+ SetServiceStatus(SERVICE_RUNNING);
+
+ OnServiceStart();
+ while (ServiceMainLoop()) ;
+ OnServiceStop();
+
+ if (m_evtlog)
+ DeregisterEventSource(m_evtlog);
+ m_evtlog = NULL;
+ SetServiceStatus(SERVICE_STOPPED);
+}
+
+DWORD WINAPI CXenAgent::__ServiceControlHandlerEx(DWORD req, DWORD evt, LPVOID data, LPVOID ctxt)
+{
+ switch (req)
+ {
+ case SERVICE_CONTROL_STOP:
+ SetServiceStatus(SERVICE_STOP_PENDING);
+ SetEvent(m_svc_stop);
+ return NO_ERROR;
+
+ case SERVICE_CONTROL_SHUTDOWN:
+ SetServiceStatus(SERVICE_STOP_PENDING);
+ SetEvent(m_svc_stop);
+ return NO_ERROR;
+
+ case SERVICE_CONTROL_DEVICEEVENT:
+ SetServiceStatus(SERVICE_RUNNING);
+ OnDeviceEvent(evt, data);
+ return NO_ERROR;
+
+ case SERVICE_CONTROL_INTERROGATE:
+ SetServiceStatus(SERVICE_RUNNING);
+ return NO_ERROR;
+
+ default:
+ break;
+ }
+
+ SetServiceStatus(SERVICE_RUNNING);
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
--- /dev/null
+/* Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __XENAGENT_SERVICE_H__
+#define __XENAGENT_SERVICE_H__
+
+#include <version.h>
+
+#define SVC_NAME "xensvc"
+#define SVC_DISPLAYNAME PRODUCT_NAME_STR ## "Interface Service"
+#define SVC_DESC "Monitors and provides various metrics to XenStore"
+
+class CXenAgent
+{
+public: // statics
+ static void Log(const char* fmt, ...);
+
+ static int ServiceInstall();
+ static int ServiceUninstall();
+ static int ServiceEntry();
+
+ static void WINAPI ServiceMain(int argc, char** argv);
+ static DWORD WINAPI ServiceControlHandlerEx(DWORD, DWORD, LPVOID, LPVOID);
+
+public: // ctor/dtor
+ CXenAgent();
+ ~CXenAgent();
+
+private: // service events
+ void OnServiceStart();
+ void OnServiceStop();
+ void OnDeviceEvent(DWORD, LPVOID);
+ bool ServiceMainLoop();
+
+private: // service support
+ void SetServiceStatus(DWORD state, DWORD exit = 0, DWORD hint = 0);
+ void WINAPI __ServiceMain(int argc, char** argv);
+ DWORD WINAPI __ServiceControlHandlerEx(DWORD, DWORD, LPVOID, LPVOID);
+
+ SERVICE_STATUS m_status;
+ SERVICE_STATUS_HANDLE m_handle;
+ HANDLE m_evtlog;
+ HANDLE m_svc_stop;
+};
+
+#endif
--- /dev/null
+/* Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <windows.h>
+#include <ntverp.h>
+
+#undef VER_COMPANYNAME_STR
+#undef VER_PRODUCTNAME_STR
+#undef VER_PRODUCTVERSION
+#undef VER_PRODUCTVERSION_STR
+
+#include <version.h>
+
+#define VER_COMPANYNAME_STR VENDOR_NAME_STR
+#define VER_LEGALCOPYRIGHT_STR "Copyright (c) Citrix Systems Inc."
+
+#define VER_PRODUCTNAME_STR "XENIFACE"
+#define VER_PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,BUILD_NUMBER
+#define VER_PRODUCTVERSION_STR MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR
+
+#define VER_INTERNALNAME_STR "xenagent.exe"
+#define VER_FILEVERSION_STR "1.0"
+#define VER_FILEDESCRIPTION_STR "xenagent"
+#define VER_ORIGINALFILENAME_STR "xenagent.exe"
+#define VER_FILETYPE VFT_APP
+#define VER_FILESUBTYPE 0
+
+xen_icon ICON "xen.ico"
+
+#include "common.ver"
+#include "messages.rc"
\ No newline at end of file
xeniface_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xeniface_coinst.dll
[ServiceDestDir.NT.Copy]
-liteagent.exe
+xenagent.exe
[Xeniface_Device.NT$ARCH$.Services]
AddService = xeniface, %SPSVCINST_ASSOCSERVICE%, xeniface_Service_Inst
-AddService = xenlite, %LITESVC_FLAGS%, xenlite_Service_Inst
+AddService = xenagent, %XENAGENT_FLAGS%, xenagent_Service_Inst
[xeniface_Service_Inst]
DisplayName = %XenIfaceDevice.DeviceDesc%
[CoInst_AddReg]
HKR,,CoInstallers32,0x00010000,"xeniface_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,Entry"
-[xenlite_Service_Inst]
-DisplayName = %xenlite.SVCDESC%
+[xenagent_Service_Inst]
+DisplayName = %xenagent.SVCDESC%
ServiceType = 16 ; SERVICE_WIN32_OWN_PROCESS
StartType = 2 ; SERVICE_AUTO_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
-ServiceBinary = %11%\liteagent.exe
+ServiceBinary = %11%\xenagent.exe
[SourceDisksNames]
1 = %DiskId1%,,,""
[SourceDisksFiles]
xeniface.sys = 1,,
-liteagent.exe = 1,,
+xenagent.exe = 1,,
xeniface_coinst.dll=1,,
[Strings]
Vendor= "@VENDOR_NAME@"
DiskId1 = "@PRODUCT_NAME@ Interface Package"
XenIfaceDevice.DeviceDesc = "@PRODUCT_NAME@ Interface"
-LITESVC_FLAGS= 0x00000800
-xenlite.SVCDESC= "@PRODUCT_NAME@ Interface Service"
+XENAGENT_FLAGS= 0x00000800
+xenagent.SVCDESC= "@PRODUCT_NAME@ Interface Service"
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>StubAgent</RootNamespace>
- <ProjectName>LiteAgent</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v110</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v110</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v110</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v110</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
-
- <PropertyGroup>
- <IncludePath>..\..\include;$(IncludePath)</IncludePath>
- </PropertyGroup>
-
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- </CustomBuildStep>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- </CustomBuildStep>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <BrowseInformation>true</BrowseInformation>
- <PreprocessToFile>false</PreprocessToFile>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>Create</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <BrowseInformation>true</BrowseInformation>
- <PreprocessToFile>false</PreprocessToFile>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\win32stubagent\errors.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\stdafx.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\WmiAccessor.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\XSAccessor.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\XService.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\src\win32stubagent\stdafx.h" />
- <ClInclude Include="..\..\src\win32stubagent\WmiAccessor.h" />
- <ClInclude Include="..\..\src\win32stubagent\XSAccessor.h" />
- <ClInclude Include="..\..\src\win32stubagent\XService.h" />
- </ItemGroup>
- <ItemGroup>
- <CustomBuild Include="..\..\src\win32stubagent\messages.mc">
- <FileType>Document</FileType>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mc %(FullPath)</Command>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mc %(FullPath)</Command>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).rc;%(Filename).h</Outputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).rc;%(Filename).h</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc %(FullPath)</Command>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mc %(FullPath)</Command>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).rc;%(Filename).h</Outputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).rc;%(Filename).h</Outputs>
- </CustomBuild>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="..\..\src\win32stubagent\w32xagent.rc" />
- </ItemGroup>
- <ItemGroup>
- <Image Include="..\..\src\win32stubagent\xen.ico" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup />
-</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>xenagent</RootNamespace>
+ <ProjectName>xenagent</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <IncludePath>..\..\include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ </CustomBuildStep>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ </CustomBuildStep>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
+ <PreprocessToFile>false</PreprocessToFile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
+ <PreprocessToFile>false</PreprocessToFile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\xenagent\service.cpp"/>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\src\xenagent\service.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\src\xenagent\messages.mc">
+ <FileType>Document</FileType>
+ <Command>mc %(FullPath)</Command>
+ <Outputs>%(Filename).rc;%(Filename).h</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\src\xenagent\xenagent.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="..\..\src\xenagent\xen.ico" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup />
+</Project>
\ No newline at end of file
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xeniface", "xeniface\xeniface.vcxproj", "{22166290-65D8-49D2-BB88-33201797C7D8}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LiteAgent", "liteagent\LiteAgent.vcxproj", "{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xenagent", "xenagent\xenagent.vcxproj", "{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package", "package\package.vcxproj", "{9B071A35-897C-477A-AEB7-95F77618A21D}"
ProjectSection(ProjectDependencies) = postProject
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>StubAgent</RootNamespace>
- <ProjectName>LiteAgent</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>MultiByte</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <OutDir>$(SolutionDir)$(Platform)\$(ConfigurationName)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)$(Platform)\$(ConfigurationName)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup>
- <IncludePath>..\..\include;$(IncludePath)</IncludePath>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <PrecompiledHeaderFile />
- <PrecompiledHeaderOutputFile />
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- </CustomBuildStep>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- <PrecompiledHeaderFile />
- <PrecompiledHeaderOutputFile />
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- </CustomBuildStep>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <BrowseInformation>true</BrowseInformation>
- <PreprocessToFile>false</PreprocessToFile>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\liteagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <BrowseInformation>true</BrowseInformation>
- <PreprocessToFile>false</PreprocessToFile>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- <CustomBuildStep>
- <Message>Copying output files</Message>
- <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
- xcopy /y $(TargetDir)LiteAgent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
- <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
- <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
- </CustomBuildStep>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\src\win32stubagent\errors.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\stdafx.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\WmiAccessor.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\XSAccessor.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="..\..\src\win32stubagent\XService.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
- <PreprocessToFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</PreprocessToFile>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\..\src\win32stubagent\stdafx.h" />
- <ClInclude Include="..\..\src\win32stubagent\WmiAccessor.h" />
- <ClInclude Include="..\..\src\win32stubagent\XSAccessor.h" />
- <ClInclude Include="..\..\src\win32stubagent\XService.h" />
- </ItemGroup>
- <ItemGroup>
- <CustomBuild Include="..\..\src\win32stubagent\messages.mc">
- <FileType>Document</FileType>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mc %(FullPath)</Command>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mc %(FullPath)</Command>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Filename).rc;%(Filename).h</Outputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(Filename).rc;%(Filename).h</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">mc %(FullPath)</Command>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">mc %(FullPath)</Command>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Filename).rc;%(Filename).h</Outputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(Filename).rc;%(Filename).h</Outputs>
- </CustomBuild>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="..\..\src\win32stubagent\w32xagent.rc" />
- </ItemGroup>
- <ItemGroup>
- <Image Include="..\..\src\win32stubagent\xen.ico" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup />
-</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>xenagent</RootNamespace>
+ <ProjectName>xenagent</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>WindowsApplicationForDrivers8.1</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>$(SolutionDir)$(Platform)\$(ConfigurationName)\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>$(SolutionDir)$(Platform)\$(ConfigurationName)\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup>
+ <IncludePath>..\..\include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeaderFile />
+ <PrecompiledHeaderOutputFile />
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ </CustomBuildStep>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeaderFile />
+ <PrecompiledHeaderOutputFile />
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ </CustomBuildStep>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
+ <PreprocessToFile>false</PreprocessToFile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>..\..\include;$(SolutionDir)\xenagent;$(SDK_INC_PATH);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
+ <PreprocessToFile>false</PreprocessToFile>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>Powrprof.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <CustomBuildStep>
+ <Message>Copying output files</Message>
+ <Command>xcopy /y $(TargetPath) $(SolutionDir)\..\xeniface\$(PlatformTarget)\
+ xcopy /y $(TargetDir)xenagent.pdb $(SolutionDir)\..\xeniface\$(PlatformTarget)\</Command>
+ <Outputs>$(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetFileName);(SolutionDir)\..\xeniface\$(PlatformTarget)$(TargetName).pdb;%(Outputs)</Outputs>
+ <Inputs>$(TargetPath);$(TargetDir)$(TargetName).pdb</Inputs>
+ </CustomBuildStep>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\xenagent\service.cpp"/>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\src\xenagent\service.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\src\xenagent\messages.mc">
+ <FileType>Document</FileType>
+ <Command>mc %(FullPath)</Command>
+ <Outputs>%(Filename).rc;%(Filename).h</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\src\xenagent\xenagent.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="..\..\src\xenagent\xen.ico" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup />
+</Project>
\ No newline at end of file
{85C731AD-2EA2-4049-A542-D2D38EDE938C} = {85C731AD-2EA2-4049-A542-D2D38EDE938C}
EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LiteAgent", "liteagent\LiteAgent.vcxproj", "{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xenagent", "xenagent\xenagent.vcxproj", "{2E61D2CC-865E-442C-8C83-B8DAFD7BBD3B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "package", "package\package.vcxproj", "{9B071A35-897C-477A-AEB7-95F77618A21D}"
ProjectSection(ProjectDependencies) = postProject