Changeset 71406 in vbox for trunk/src/VBox/Main/include
- Timestamp:
- Mar 20, 2018 2:44:24 PM (7 years ago)
- Location:
- trunk/src/VBox/Main/include
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r71314 r71406 686 686 /** The session's friendly name. Optional. */ 687 687 Utf8Str mName; 688 /** The session's unique ID. Used to encode 689 * a context ID. */ 688 /** The session's unique ID. Used to encode a context ID. */ 690 689 uint32_t mID; 691 690 /** Flag indicating if this is an internal session … … 907 906 GuestWaitEventPayload(uint32_t uTypePayload, 908 907 const void *pvPayload, uint32_t cbPayload) 909 { 908 : uType(0), 909 cbData(0), 910 pvData(NULL) 911 { 912 int rc = copyFrom(uTypePayload, pvPayload, cbPayload); 913 if (RT_FAILURE(rc)) 914 throw rc; 915 } 916 917 virtual ~GuestWaitEventPayload(void) 918 { 919 Clear(); 920 } 921 922 GuestWaitEventPayload& operator=(const GuestWaitEventPayload &that) 923 { 924 CopyFromDeep(that); 925 return *this; 926 } 927 928 public: 929 930 void Clear(void) 931 { 932 if (pvData) 933 { 934 Assert(cbData); 935 RTMemFree(pvData); 936 cbData = 0; 937 pvData = NULL; 938 } 939 uType = 0; 940 } 941 942 int CopyFromDeep(const GuestWaitEventPayload &payload) 943 { 944 return copyFrom(payload.uType, payload.pvData, payload.cbData); 945 } 946 947 const void* Raw(void) const { return pvData; } 948 949 size_t Size(void) const { return cbData; } 950 951 uint32_t Type(void) const { return uType; } 952 953 void* MutableRaw(void) { return pvData; } 954 955 Utf8Str ToString(void) 956 { 957 const char *pszStr = (const char *)pvData; 958 size_t cbStr = cbData; 959 960 if (RT_FAILURE(RTStrValidateEncodingEx(pszStr, cbStr, 961 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED | RTSTR_VALIDATE_ENCODING_EXACT_LENGTH))) 962 { 963 AssertFailed(); 964 return ""; 965 } 966 967 return Utf8Str(pszStr, cbStr); 968 } 969 970 protected: 971 972 int copyFrom(uint32_t uTypePayload, const void *pvPayload, uint32_t cbPayload) 973 { 974 if (cbPayload > _64K) /* Paranoia. */ 975 return VERR_TOO_MUCH_DATA; 976 977 Clear(); 978 979 int rc = VINF_SUCCESS; 980 910 981 if (cbPayload) 911 982 { … … 918 989 cbData = cbPayload; 919 990 } 920 else /* Throw IPRT error. */921 throwVERR_NO_MEMORY;991 else 992 rc = VERR_NO_MEMORY; 922 993 } 923 994 else … … 928 999 cbData = 0; 929 1000 } 930 }931 932 virtual ~GuestWaitEventPayload(void)933 {934 Clear();935 }936 937 GuestWaitEventPayload& operator=(const GuestWaitEventPayload &that)938 {939 CopyFromDeep(that);940 return *this;941 }942 943 public:944 945 void Clear(void)946 {947 if (pvData)948 {949 RTMemFree(pvData);950 cbData = 0;951 pvData = NULL;952 }953 uType = 0;954 }955 956 int CopyFromDeep(const GuestWaitEventPayload &payload)957 {958 Clear();959 960 int rc = VINF_SUCCESS;961 if (payload.cbData)962 {963 Assert(payload.cbData);964 pvData = RTMemAlloc(payload.cbData);965 if (pvData)966 {967 memcpy(pvData, payload.pvData, payload.cbData);968 cbData = payload.cbData;969 uType = payload.uType;970 }971 else972 rc = VERR_NO_MEMORY;973 }974 1001 975 1002 return rc; 976 }977 978 const void* Raw(void) const { return pvData; }979 980 size_t Size(void) const { return cbData; }981 982 uint32_t Type(void) const { return uType; }983 984 void* MutableRaw(void) { return pvData; }985 986 Utf8Str ToString(void)987 {988 const char *pszStr = (const char *)pvData;989 size_t cbStr = cbData;990 991 if (!RTStrValidateEncodingEx(pszStr, cbStr,992 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED | RTSTR_VALIDATE_ENCODING_EXACT_LENGTH))993 return "";994 995 return Utf8Str(pszStr, cbStr);996 1003 } 997 1004 … … 1003 1010 uint32_t cbData; 1004 1011 /** Pointer to actual payload data. */ 1005 void *pvData;1012 void *pvData; 1006 1013 }; 1007 1014 … … 1114 1121 int generateContextID(uint32_t uSessionID, uint32_t uObjectID, uint32_t *puContextID); 1115 1122 int registerWaitEvent(uint32_t uSessionID, uint32_t uObjectID, GuestWaitEvent **ppEvent); 1116 int registerWaitEvent (uint32_t uSessionID, uint32_t uObjectID, const GuestEventTypes &lstEvents, GuestWaitEvent **ppEvent);1123 int registerWaitEventEx(uint32_t uSessionID, uint32_t uObjectID, const GuestEventTypes &lstEvents, GuestWaitEvent **ppEvent); 1117 1124 int unregisterWaitEvent(GuestWaitEvent *pEvent); 1118 1125 int waitForEvent(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, VBoxEventType_T *pType, IEvent **ppEvent); -
trunk/src/VBox/Main/include/GuestDirectoryImpl.h
r71250 r71406 37 37 DECLARE_EMPTY_CTOR_DTOR(GuestDirectory) 38 38 39 int init(Console *pConsole, GuestSession *pSession, ULONG uDirID, const GuestDirectoryOpenInfo &openInfo);39 int init(Console *pConsole, GuestSession *pSession, ULONG aObjectID, const GuestDirectoryOpenInfo &openInfo); 40 40 void uninit(void); 41 41 … … 79 79 /** The directory's open info. */ 80 80 GuestDirectoryOpenInfo mOpenInfo; 81 /** The directory's ID. */82 uint32_t mID;83 81 /** The process tool instance to use. */ 84 82 GuestProcessTool mProcessTool; -
trunk/src/VBox/Main/include/GuestFileImpl.h
r69500 r71406 123 123 /** The file's initial size on open. */ 124 124 uint64_t mInitialSize; 125 /** The file's ID. */126 uint32_t mID;127 125 /** The current file status. */ 128 126 FileStatus_T mStatus; -
trunk/src/VBox/Main/include/GuestImpl.h
r69500 r71406 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 202 202 #ifdef VBOX_WITH_GUEST_CONTROL 203 203 GuestSessions mGuestSessions; 204 uint32_t mNextSessionID;205 204 #endif 206 205 } mData; -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r71301 r71406 40 40 DECLARE_EMPTY_CTOR_DTOR(GuestProcess) 41 41 42 int init(Console *aConsole, GuestSession *aSession, ULONG a ProcessID,42 int init(Console *aConsole, GuestSession *aSession, ULONG aObjectID, 43 43 const GuestProcessStartupInfo &aProcInfo, const GuestEnvironment *pBaseEnv); 44 44 void uninit(void); … … 147 147 /** Exit code if process has been terminated. */ 148 148 LONG mExitCode; 149 /** PID reported from the guest. */ 149 /** PID reported from the guest. 150 * Note: This is *not* the internal object ID! */ 150 151 ULONG mPID; 151 152 /** The current process status. */ -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r71345 r71406 30 30 31 31 #include <iprt/isofs.h> /* For UpdateAdditions. */ 32 33 #include <deque> 32 34 33 35 class Guest; … … 493 495 typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses; 494 496 497 /** Guest session object type enumeration. */ 498 enum SESSIONOBJECTTYPE 499 { 500 /** Anonymous object. */ 501 SESSIONOBJECTTYPE_ANONYMOUS = 0, 502 /** Session object. */ 503 SESSIONOBJECTTYPE_SESSION = 1, 504 /** Directory object. */ 505 SESSIONOBJECTTYPE_DIRECTORY = 2, 506 /** File object. */ 507 SESSIONOBJECTTYPE_FILE = 3, 508 /** Process object. */ 509 SESSIONOBJECTTYPE_PROCESS = 4, 510 /** The usual 32-bit hack. */ 511 SESSIONOBJECTTYPE_32BIT_HACK = 0x7fffffff 512 }; 513 514 struct SessionObject 515 { 516 /** Creation timestamp (in ms). */ 517 uint64_t tsCreatedMs; 518 /** The object type. */ 519 SESSIONOBJECTTYPE enmType; 520 }; 521 522 /** Map containing all objects bound to a guest session. 523 * The key specifies the (global) context ID. */ 524 typedef std::map <uint32_t, SessionObject> SessionObjects; 525 /** Queue containing context IDs which are no longer in use. 526 * Useful for quickly retrieving a new, unused context ID. */ 527 typedef std::deque <uint32_t> SessionObjectsFree; 528 495 529 public: 496 530 /** @name Public internal methods. 497 531 * @todo r=bird: Most of these are public for no real reason... 498 532 * @{ */ 499 int i_copyToGuestCreateDir(const com::Utf8Str &aDestination, uint32_t fFlags, int *pGuestRc);500 533 int i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc); 501 534 inline bool i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir); 502 int i_directory RemoveFromList(GuestDirectory *pDirectory);535 int i_directoryUnregister(GuestDirectory *pDirectory); 503 536 int i_directoryRemove(const Utf8Str &strPath, uint32_t uFlags, int *pGuestRc); 504 537 int i_directoryCreate(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc); 505 int i_objectCreateTemp(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory,506 Utf8Str &strName, int *pGuestRc);507 538 int i_directoryOpen(const GuestDirectoryOpenInfo &openInfo, 508 539 ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc); 509 540 int i_directoryQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc); 510 int i_dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);511 int i_dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);512 541 int i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 513 int i_dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);514 542 int i_dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 515 543 inline bool i_fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile); 516 int i_file RemoveFromList(GuestFile *pFile);544 int i_fileUnregister(GuestFile *pFile); 517 545 int i_fileRemove(const Utf8Str &strPath, int *pGuestRc); 518 546 int i_fileOpen(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc); 519 547 int i_fileQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc); 520 548 int i_fileQuerySize(const Utf8Str &strPath, bool fFollowSymlinks, int64_t *pllSize, int *pGuestRc); 549 int i_fsCreateTemp(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory, 550 Utf8Str &strName, int *pGuestRc); 521 551 int i_fsQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc); 522 552 const GuestCredentials &i_getCredentials(void); … … 533 563 Guest *i_getParent(void) { return mParent; } 534 564 uint32_t i_getProtocolVersion(void) { return mData.mProtocolVersion; } 565 int i_objectRegister(SESSIONOBJECTTYPE enmType, uint32_t *puObjectID); 566 int i_objectRegisterEx(SESSIONOBJECTTYPE enmType, uint32_t fFlags, uint32_t *puObjectID); 567 int i_objectUnregister(uint32_t uObjectID); 535 568 int i_pathRename(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *pGuestRc); 536 569 int i_pathUserDocuments(Utf8Str &strPath, int *prcGuest); 537 570 int i_pathUserHome(Utf8Str &strPath, int *prcGuest); 538 int i_process RemoveFromList(GuestProcess *pProcess);571 int i_processUnregister(GuestProcess *pProcess); 539 572 int i_processCreateEx(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress); 540 573 inline bool i_processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess); … … 571 604 /** The session's startup info. */ 572 605 GuestSessionStartupInfo mSession; 606 /** The session's object ID. 607 * Needed for registering wait events which are bound directly to this session. */ 608 uint32_t mObjectID; 573 609 /** The session's current status. */ 574 610 GuestSessionStatus_T mStatus; … … 586 622 /** Process objects bound to this session. */ 587 623 SessionProcesses mProcesses; 624 /** Map of registered session objects (files, directories, ...). */ 625 SessionObjects mObjects; 626 /** Queue of object IDs which are not used anymore (free list). 627 * Acts as a "free list" for the mObjects map. */ 628 SessionObjectsFree mObjectsFree; 588 629 /** Guest control protocol version to be used. 589 630 * Guest Additions < VBox 4.3 have version 1, … … 592 633 /** Session timeout (in ms). */ 593 634 uint32_t mTimeout; 594 /** Total number of session objects (processes,595 * files, ...). */596 uint32_t mNumObjects;597 635 /** The last returned session status 598 636 * returned from the guest side. */ … … 611 649 , mFiles(rThat.mFiles) 612 650 , mProcesses(rThat.mProcesses) 651 , mObjects(rThat.mObjects) 652 , mObjectsFree(rThat.mObjectsFree) 613 653 , mProtocolVersion(rThat.mProtocolVersion) 614 654 , mTimeout(rThat.mTimeout) 615 , mNumObjects(rThat.mNumObjects)616 655 , mRC(rThat.mRC) 617 656 { }
Note:
See TracChangeset
for help on using the changeset viewer.