예제 #1
0
FCIMPLEND

void QCALLTYPE SystemNative::_GetCommandLine(QCall::StringHandleOnStack retString)
{
    QCALL_CONTRACT;

    BEGIN_QCALL;

    LPCWSTR commandLine;

    if (g_pCachedCommandLine != NULL)
    {
        // Use the cached command line if available
        commandLine = g_pCachedCommandLine;
    }
    else
    {
        commandLine = WszGetCommandLine();
        if (commandLine==NULL)
            COMPlusThrowOM();
    }
    
    retString.Set(commandLine);

    END_QCALL;
}
예제 #2
0
void QCALLTYPE TypeNameBuilder::_ToString(TypeNameBuilder * pTnb, QCall::StringHandleOnStack retString)
{
    QCALL_CONTRACT;

    BEGIN_QCALL;
    retString.Set(*pTnb->GetString());
    END_QCALL;
} 
예제 #3
0
FCIMPLEND

void QCALLTYPE SystemNative::_GetCommandLine(QCall::StringHandleOnStack retString)
{
    QCALL_CONTRACT;

    BEGIN_QCALL;

    LPCWSTR commandLine;

    commandLine = WszGetCommandLine();
    if (commandLine==NULL)
        COMPlusThrowOM();

    retString.Set(commandLine);

    END_QCALL;
}
예제 #4
0
파일: console.cpp 프로젝트: 0xMF/coreclr
// A buffer of size ConsoleNative::MaxConsoleTitleLength is quite big.
// First, we try allocating a smaller buffer because most often, the console title is short.
// If it turns out that the short buffer size is insufficient, we try again using a larger buffer.
INT32 QCALLTYPE ConsoleNative::GetTitle(QCall::StringHandleOnStack outTitle, INT32& outTitleLen) {

    QCALL_CONTRACT;
    
    INT32 result = 0;
    
    BEGIN_QCALL;

    // Reserve buffer:   
    InlineSBuffer< ADJUST_NUM_CHARS(BUFF_SIZE(ShortConsoleTitleLength)) > titleBuff;
        
    // Hold last error:
    DWORD lastError;

    // Read console title, get length of the title:    
    
    BYTE *buffPtr = titleBuff.OpenRawBuffer( ADJUST_NUM_CHARS(BUFF_SIZE(ShortConsoleTitleLength)) );
    
    SetLastError(0);
    DWORD len = GetConsoleTitle((TCHAR *) buffPtr, ADJUST_NUM_CHARS(ShortConsoleTitleLength + 1));
    lastError = GetLastError();

    titleBuff.CloseRawBuffer();
    
    // If the title length is larger than supported maximum, do not bother reading it, just return the length:
    if (len > MaxConsoleTitleLength) {
    
        outTitleLen = len;
        outTitle.Set(W(""));    
        result = 0;  
    
    // If title length is within valid range:
    } else {
    
        // If the title is longer than the short buffer, but can fit in the max supported length,
        // read it again with the long buffer:
        if (len > ShortConsoleTitleLength) {
        
            COUNT_T buffSize = ADJUST_NUM_CHARS(BUFF_SIZE(len));
            titleBuff.SetSize(buffSize);
            
            BYTE *buffPtr = titleBuff.OpenRawBuffer(buffSize);
            
            SetLastError(0);
            len = GetConsoleTitle((TCHAR *) buffPtr, ADJUST_NUM_CHARS(len + 1));
            lastError = GetLastError();

            titleBuff.CloseRawBuffer();
        }
        
        // Zero may indicate error or empty title. Check for error:
        result = (INT32) (0 == len ? lastError : 0);
        
        // If no error, set title and length:
        if (0 == result) {
            const BYTE *cBuffPtr = (const BYTE *) titleBuff;
            outTitle.Set((TCHAR *) cBuffPtr);
            outTitleLen = (INT32) len;
            
        // If error, set to empty:
        } else {            
            outTitleLen = (INT32) -1;
            // No need to set the title string if we have an error anyway.
        }
    }  // if title length is within valid range.
        
    END_QCALL;

    return result;
}