示例#1
0
//===============================================================================================
// Attaches an unmanaged symwriter to a newly created dynamic module.
//===============================================================================================
FCIMPL2(LPVOID, COMModule::nCreateISymWriterForDynamicModule, ReflectModuleBaseObject* reflectionModuleUNSAFE, StringObject* filenameUNSAFE)
{
    FCALL_CONTRACT;

    REFLECTMODULEBASEREF refModule = (REFLECTMODULEBASEREF)ObjectToOBJECTREF(reflectionModuleUNSAFE);

    ReflectionModule *mod = (ReflectionModule*)refModule->GetModule();
    STRINGREF filename = (STRINGREF)filenameUNSAFE;

    LPVOID pInternalSymWriter = NULL;
    
    HELPER_METHOD_FRAME_BEGIN_RET_2(filename, refModule);

    SString name;
    if (filename != NULL)
    {
        filename->GetSString(name);
    }

    GCX_PREEMP();
    pInternalSymWriter = CreateISymWriterForDynamicModule(mod, name.GetUnicode());

    HELPER_METHOD_FRAME_END();

    return pInternalSymWriter;

} // COMModule::nCreateISymWriterForDynamicModule
示例#2
0
FCIMPLEND

// Note: Arguments checked in IL.
FCIMPL1(Object*, SystemNative::_GetEnvironmentVariable, StringObject* strVarUNSAFE)
{
    FCALL_CONTRACT;

    STRINGREF refRetVal;
    STRINGREF strVar;

    refRetVal   = NULL;
    strVar      = ObjectToSTRINGREF(strVarUNSAFE);

    HELPER_METHOD_FRAME_BEGIN_RET_2(refRetVal, strVar);

    int len;

    // Get the length of the environment variable.
    PathString envPath;    // prefix complains if pass a null ptr in, so rely on the final length parm instead
    len = WszGetEnvironmentVariable(strVar->GetBuffer(), envPath);

    if (len != 0)
    {
        // Allocate the string.
        refRetVal = StringObject::NewString(len);
 
        wcscpy_s(refRetVal->GetBuffer(), len + 1, envPath);
        
    }

    HELPER_METHOD_FRAME_END();

    return OBJECTREFToObject(refRetVal);
}
示例#3
0
FCIMPLEND

// Note: Arguments checked in IL.
FCIMPL1(Object*, SystemNative::_GetEnvironmentVariable, StringObject* strVarUNSAFE)
{
    FCALL_CONTRACT;

    STRINGREF refRetVal;
    STRINGREF strVar;

    refRetVal   = NULL;
    strVar      = ObjectToSTRINGREF(strVarUNSAFE);

    HELPER_METHOD_FRAME_BEGIN_RET_2(refRetVal, strVar);

    // We loop round getting the length of the env var and then trying to copy
    // the value into a managed string. Usually we'll go through this loop
    // precisely once, but the caution is ncessary in case the variable mutates
    // beneath us.
    int len, newLen;

    // Get the length of the environment variable.
    WCHAR dummy;    // prefix complains if pass a null ptr in, so rely on the final length parm instead
    len = WszGetEnvironmentVariable(strVar->GetBuffer(), &dummy, 0);

    while (len != 0)
    {
        // Allocate the string.
        refRetVal = StringObject::NewString(len);

        // Get the value.
        newLen = WszGetEnvironmentVariable(strVar->GetBuffer(), refRetVal->GetBuffer(), len);
        if (newLen != (len - 1))
        {
            // The envvar changed, need to do this again. Let GC collect the
            // string we just allocated.
            refRetVal = NULL;

            // Go back and try again.
            len = newLen;
        }
        else
            break;
    }

    HELPER_METHOD_FRAME_END();

    return OBJECTREFToObject(refRetVal);
}