VirtualBox

Changeset 96123 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Aug 8, 2022 11:13:44 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152925
Message:

Add/3D/win: Added a VbglR3WriteLog implementation to the VBoxMpLogger.cpp code. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/3D/win/VBoxWddmUmHlp/VBoxMpLogger.cpp

    r95955 r96123  
    22/** @file
    33 * VBox WDDM Display logger implementation
     4 *
     5 * We're unable to use standard r3 vbgl-based backdoor logging API because
     6 * win8 Metro apps can not do CreateFile/Read/Write by default.  This is why
     7 * we use miniport escape functionality to issue backdoor log string to the
     8 * miniport and submit it to host via standard r0 backdoor logging api
     9 * accordingly
    410 */
    511
     
    1622 */
    1723
    18 /* We're unable to use standard r3 vbgl-based backdoor logging API because win8 Metro apps
    19  * can not do CreateFile/Read/Write by default.
    20  * This is why we use miniport escape functionality to issue backdoor log string to the miniport
    21  * and submit it to host via standard r0 backdoor logging api accordingly
    22  */
    23 
    2424#define IPRT_NO_CRT_FOR_3RD_PARTY /* To get malloc and free wrappers in IPRT_NO_CRT mode. Doesn't link with IPRT in non-no-CRT mode. */
    2525#include "UmHlpInternal.h"
     
    3333# include <stdio.h>
    3434#endif
     35#include <VBox/VBoxGuestLib.h>
    3536
    36 DECLCALLBACK(void) VBoxDispMpLoggerLog(const char *pszString)
     37
     38static void VBoxDispMpLoggerLogN(const char *pchString, size_t cchString)
    3739{
    3840    D3DKMTFUNCTIONS const *d3dkmt = D3DKMTFunctions();
     
    4547    if (Status == 0)
    4648    {
    47         uint32_t cbString = (uint32_t)strlen(pszString) + 1;
    48         uint32_t cbCmd = RT_UOFFSETOF_DYN(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cbString]);
     49        uint32_t cchString2 = (uint32_t)RT_MIN(cchString, _64K - 1U);
     50        uint32_t cbCmd = RT_UOFFSETOF_DYN(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cchString2 + 1]);
    4951        PVBOXDISPIFESCAPE_DBGPRINT pCmd = (PVBOXDISPIFESCAPE_DBGPRINT)malloc(cbCmd);
    5052        Assert(pCmd);
     
    5355            pCmd->EscapeHdr.escapeCode = VBOXESC_DBGPRINT;
    5456            pCmd->EscapeHdr.u32CmdSpecific = 0;
    55             memcpy(pCmd->aStringBuf, pszString, cbString);
     57            memcpy(pCmd->aStringBuf, pchString, cchString2);
     58            pCmd->aStringBuf[cchString2] = '\0';
    5659
    5760            D3DKMT_ESCAPE EscapeData;
     
    7679}
    7780
     81
     82DECLCALLBACK(void) VBoxDispMpLoggerLog(const char *pszString)
     83{
     84    VBoxDispMpLoggerLogN(pszString, strlen(pszString));
     85}
     86
     87
    7888DECLCALLBACK(void) VBoxDispMpLoggerLogF(const char *pszFormat, ...)
    7989{
     
    94104    VBoxDispMpLoggerLog(szBuffer);
    95105}
     106
     107
     108/* Interface used for backdoor logging.  In no-CRT mode we will drag in IPRT
     109   logging and it will be used on assertion in the no-CRT and IPRT code. */
     110VBGLR3DECL(int) VbglR3WriteLog(const char *pch, size_t cch)
     111{
     112    VBoxDispMpLoggerLogN(pch, cch);
     113    return VINF_SUCCESS;
     114}
     115
    96116
    97117/**
     
    135155    VBoxDispMpLoggerLog(szBuffer);
    136156}
     157
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette