Beispiel #1
0
bool
JavaJncReader::GetSymbolAndRangeFromAddr(
    gtUInt64  addr,
    string&    symName,
    gtUInt64&  startAddr,
    gtUInt64&  endAddr
)
{
    bool bRet = false;

    // NOTE: This is 1 because the first item in the table is the main
    //       method for the JNC
    //
    for (unsigned int i = 1; i < m_addressRangeTable.size(); i++)
    {
        // Check if address is within the range
        if ((addr >= m_addressRangeTable[i].pc_start)
            && (addr <= m_addressRangeTable[i].pc_end))
        {
            symName   = GetMethodName((jmethodID)m_addressRangeTable[i].id);
            startAddr = (gtUInt64) m_addressRangeTable[i].pc_start,
            endAddr   = (gtUInt64) m_addressRangeTable[i].pc_end,
            bRet      = true;
        }

        // In case there are duplicate range we use the inner most one
        // TODO: Verify this part
        if ((addr < m_addressRangeTable[i].pc_start))
        {
            break;
        }
    }

    return bRet;
}
Beispiel #2
0
void HttpRequest::AppendStartLineToString(std::string* result) const {
    CHECK_NE(m_method, METHOD_UNKNOWN);
    StringAppend(result, GetMethodName(m_method), " ", m_uri);
    HttpVersion version = Version();
    if (!version.IsEmpty()) {
        StringAppend(result, " ", "HTTP/", version.Major(), ".", version.Minor());
    }
}
Beispiel #3
0
void
JavaJncReader::_fillLineNumSrcMap(
    JNCInlineMap&       ilmap,
    int                 numFrames,
    void*               vbcisArray,
    void*               vmethodArray,
    gtUInt64  thisPc,
    gtUInt64  nextPc
)
{
    jint* bcisArray = (jint*) vbcisArray;
    jmethodID* methodArray = (jmethodID*) vmethodArray;

    int xx;
    numFrames -= 2;

    for (xx = numFrames; xx >= 0; xx--)
    {
        LineNumSrc lns;
        addrRanges addrRange;

        bool ret = _getSrcInfoFromBcAndMethodID(bcisArray[xx],
                                                methodArray[xx],
                                                lns.lineNum,
                                                lns.sourceFile);

        if (false == ret)
        {
            continue;
        }

        addrRange.startAddr = thisPc;
        addrRange.stopAddr  = nextPc;
        // lns.startAddr       = thisPc;
        // lns.stopAddr        = nextPc;
        lns.methodId        = methodArray[xx];
        lns.symName         = GetMethodName(methodArray[xx]);

        if ((gtUInt64) - 1 == nextPc)
        {
            for (unsigned int j = 1; j < m_addressRangeTable.size(); j++)
            {
                if ((m_addressRangeTable[j].id == methodArray[xx])
                    && (thisPc >= (gtUInt64) m_addressRangeTable[j].pc_start)
                    && (thisPc <= (gtUInt64) m_addressRangeTable[j].pc_end))
                {
                    addrRange.startAddr = (gtUInt64) m_addressRangeTable[j].pc_start;
                    addrRange.stopAddr  = (gtUInt64) m_addressRangeTable[j].pc_end;
                    break;
                }
            }
        }

        lns.addrs.push_back(addrRange);
        ilmap.insert(JNCInlineMap::value_type(thisPc, lns));
    }
}
ECode Int32PropertyValuesHolder::SetupSetter(
        /* [in] */ IInterface* target)
{
    if (mProperty != NULL) {
        return NOERROR;
    }
    // Check new static hashmap<propName, int> for setter method
    {
        AutoLock lock(mPropertyMapLock);
        AutoPtr<IClassInfo> clInfo = TransformClassInfo(target);
        ClassMethodMapIterator exit = sJNISetterPropertyMap.Find(clInfo);
        AutoPtr<MethodMap> propertyMap = NULL;
        if(exit != sJNISetterPropertyMap.End())
        {
            propertyMap = exit->mSecond;
            if(propertyMap != NULL)
            {
                MethodMapIterator it = propertyMap->Find(mPropertyName);
                if(it != propertyMap->End())
                {
                    AutoPtr<IMethodInfo> mtInfo = it->mSecond;
                    if(mtInfo != NULL)
                    {
                        mJniSetter = mtInfo;
                    }
                }
            }
        }
        if(mJniSetter == NULL)
        {
            String methodName = GetMethodName(String("Set"), mPropertyName);
            clInfo->GetMethodInfo(methodName, (IMethodInfo**)&mJniSetter);
            if(mJniSetter != NULL) {
                if (propertyMap == NULL) {
                    propertyMap = new MethodMap();
                    sJNISetterPropertyMap[clInfo] = propertyMap;
                }
                (*propertyMap)[mPropertyName] = mJniSetter;
            }
        }

    }
    if (mJniSetter == NULL) {
        // Couldn't find method through fast JNI approach - just use reflection
        return PropertyValuesHolder::SetupSetter(target);
    }
    return NOERROR;
}
ECode MultiFloatValuesHolder::SetupSetter(
    /* [in] */ IInterface* targetClass)
{
    if (mJniSetter != NULL) {
        return NOERROR;
    }
    // try {
    AutoLock lock(mPropertyMapLock);
    // mPropertyMapLock.writeLock().lock();
    AutoPtr<IClassInfo> info = TransformClassInfo(targetClass);
    AutoPtr<MethodMap> propertyMap = sJNISetterPropertyMap[info];

    typename ClassMethodMap::Iterator it = sJNISetterPropertyMap.Find(info);
    if ((it != sJNISetterPropertyMap.End()) && (it->mSecond != NULL)) {
        propertyMap = it->mSecond;
        typename MethodMap::Iterator it2 = propertyMap->Find(mPropertyName);
        if ((it2 != propertyMap->End()) && (it2->mSecond != NULL)) {
            mJniSetter = it2->mSecond;
        }
    }

    if (mJniSetter == NULL) {
        String methodName = GetMethodName(String("Set"), mPropertyName);
        CalculateValue(0.f);
        AutoPtr<IArrayList> values;
        GetAnimatedValue((IInterface**)&values);
        Int32 numParams = 0;
        values->GetSize(&numParams);

        try {
            mJniSetter = nGetMultipleFloatMethod(info, methodName, numParams);
        } catch (NoSuchMethodError e) {
            // try without the 'set' prefix
            mJniSetter = nGetMultipleFloatMethod(info, mPropertyName, numParams);
        }
        if (mJniSetter != NULL) {
            if (propertyMap == NULL) {
                propertyMap = new MethodMap();
                sJNISetterPropertyMap[info] = propertyMap;
            }
            (*propertyMap)[mPropertyName] = mJniSetter;
        }
    }
    // } finally {
    //     mPropertyMapLock.writeLock().unlock();
    // }
    return NOERROR;
}
Beispiel #6
0
ECode Int32PropertyValuesHolder::SetupSetter(
    /* [in] */ IClassInfo* target)
{
    if (mProperty != NULL) {
        return NOERROR;
    }
    // Check new static hashmap<propName, int> for setter method
    {
        AutoLock lock(mPropertyMapLock);

        String methodName = GetMethodName(String("Set"), mPropertyName);

        AutoPtr<MethodMap> propertyMap;
        ClassMethodMapIterator it = sNativeGetterSetterPropertyMap.Find(target);
        if (it != sNativeGetterSetterPropertyMap.End()) {
            propertyMap = it->mSecond;
        }
        if (propertyMap != NULL) {
            MethodMapIterator mit = propertyMap->Find(methodName);
            AutoPtr<IMethodInfo> mtInfo;
            if (mit != propertyMap->End()) {
                mtInfo = mit->mSecond;
            }
            if (mtInfo != NULL) {
                mNativeSetter = mit->mSecond;
            }
        }
        if (mNativeSetter == NULL) {
            mNativeSetter = nGetInt32Method(target, methodName);
            if (mNativeSetter != NULL) {
                if (propertyMap == NULL) {
                    propertyMap = new MethodMap();
                    sNativeGetterSetterPropertyMap[target] = propertyMap;
                }
                (*propertyMap)[methodName] = mNativeSetter;
            }
            else {
                String className;
                target->GetName(&className);
                Logger::E("Int32PropertyValuesHolder", "Error: Method [%s] is not found on target class %s",
                    methodName.string(), className.string());
            }
        }
    }
    return NOERROR;
}
/// <summary>Handle <c>ICorProfilerCallback::JITCompilationStarted</c></summary>
/// <remarks>The 'workhorse' </remarks>
HRESULT STDMETHODCALLTYPE CCodeInjection::JITCompilationStarted( 
        /* [in] */ FunctionID functionId, /* [in] */ BOOL fIsSafeToBlock) 
{
    ModuleID moduleId; mdToken funcToken;
    std::wstring methodName = GetMethodName(functionId, 
        moduleId, funcToken);
    ATLTRACE(_T("::JITCompilationStarted(%X -> %s)"), 
        functionId, W2CT(methodName.c_str()));

    if (L"ProfilerTarget.Program.TargetMethod" == methodName && 
        m_targetMethodRef !=0 ) {
        // get method body
        LPCBYTE pMethodHeader = NULL;
        ULONG iMethodSize = 0;
        COM_FAIL_RETURN(m_profilerInfo3->GetILFunctionBody(
            moduleId, funcToken, &pMethodHeader, &iMethodSize), 
            S_OK);

        // parse IL
        Method instMethod((IMAGE_COR_ILMETHOD*)pMethodHeader); // <--

        // insert new IL block
        InstructionList instructions;
        instructions.push_back(new Instruction(CEE_LDARG_0));
        instructions.push_back(new Instruction(CEE_CALL, m_targetMethodRef));

        instMethod.InsertSequenceInstructionsAtOriginalOffset(
            1, instructions);

        instMethod.DumpIL();

        // allocate memory
        CComPtr<IMethodMalloc> methodMalloc;
        COM_FAIL_RETURN(m_profilerInfo3->GetILFunctionBodyAllocator(
            moduleId, &methodMalloc), S_OK);
        void* pNewMethod = methodMalloc->Alloc(instMethod.GetMethodSize());

        // write new method
        instMethod.WriteMethod((IMAGE_COR_ILMETHOD*)pNewMethod);
        COM_FAIL_RETURN(m_profilerInfo3->SetILFunctionBody(moduleId, 
            funcToken, (LPCBYTE) pNewMethod), S_OK);
    }

    return S_OK;
}
Beispiel #8
0
ECode Int32PropertyValuesHolder::SetupGetter(
    /* [in] */ IClassInfo* target)
{
    if (mProperty != NULL) {
        return NOERROR;
    }
    // Check new static hashmap<propName, int> for setter method
    {
        AutoLock lock(mPropertyMapLock);

        String methodName = GetMethodName(String("Get"), mPropertyName);

        AutoPtr<MethodMap> propertyMap;
        ClassMethodMapIterator it = sNativeGetterSetterPropertyMap.Find(target);
        if (it != sNativeGetterSetterPropertyMap.End()) {
            propertyMap = it->mSecond;
        }
        if (propertyMap != NULL) {
            MethodMapIterator mit = propertyMap->Find(methodName);
            AutoPtr<IMethodInfo> mtInfo;
            if (mit != propertyMap->End()) {
                mtInfo = mit->mSecond;
            }
            if (mtInfo != NULL) {
                mGetter = mit->mSecond;
            }
        }
        if (mGetter == NULL) {
            target->GetMethodInfo(methodName, String("(I32*)E"), (IMethodInfo**)&mGetter);
            if (mGetter != NULL) {
                if (propertyMap == NULL) {
                    propertyMap = new MethodMap();
                    sNativeGetterSetterPropertyMap[target] = propertyMap;
                }
                (*propertyMap)[methodName] = mGetter;
            }
        }
    }
    return NOERROR;
}
Beispiel #9
0
void
JavaJncReader::DumpAddressRangeTable(FILE* f)
{
    (void)(f); // unused
#if 0
    fprintf(f, "DumpAddressRangeTable - (size:%u)\n",
            m_addressRangeTable.size());

    for (unsigned int i = 0; i < m_addressRangeTable.size(); i++)
    {
        fprintf(f, "id:%4lu, pc_start:0x%lx, pc_end:0x%lx, name:%s\n",
                m_addressRangeTable[i].id,
                m_addressRangeTable[i].pc_start,
                m_addressRangeTable[i].pc_end,
                GetMethodName((jmethodID)m_addressRangeTable[i].id));
    }

    fprintf(f, "DumpAddressRangeTable: END\n");
#endif //0

    return;
}
Beispiel #10
0
void
JavaJncReader::DumpAddressRangeTable(FILE* f)
{
    if (nullptr == f)
    {
        return;
    }

    fprintf(f, "DumpAddressRangeTable - (size:%u)\n",
            m_addressRangeTable.size());

    for (unsigned int i = 0; i < m_addressRangeTable.size(); i++)
    {
        fprintf(f, "id:%4llu, pc_start:0x%llx, pc_end:0x%llx, name:%s\n",
                m_addressRangeTable[i].id,
                m_addressRangeTable[i].pc_start,
                m_addressRangeTable[i].pc_end,
                GetMethodName(m_addressRangeTable[i].id));
    }

    fprintf(f, "DumpAddressRangeTable: END\n");

    return;
}
Beispiel #11
0
int JsonRpcCoder::EncodeResult(const Result& res, Json::Value& obj) const
{
    Json::Value msgObj;
    if(0 != res.JsonEncode(msgObj))
    {
        LOG_ERROR("serialNo:[%d], jsonencode error, res:[%s]", res.serialNo, res.ToString().c_str());
        return -1;
    }
    
    obj["id"] = ToJsonValue(Json::Int(res.context.peer.msgId));
    obj["errno"] = ToJsonValue(Json::Int(res.error));
    if (res.errMsg.size()>0)
    {
        obj["errmsg"] = ToJsonValue(res.errMsg);
    }
    if( msgObj.type() != Json::nullValue)
    {
        obj["result"] = msgObj;
    }
    std::string msgName = res.GetTypeName();
    const std::string& method = GetMethodName(msgName);
    obj["method"] = ToJsonValue(method);
    return 0;
}
Beispiel #12
0
VectorMap<String, String> Ide::GetMethodVars(const String& method)
{
    VectorMap<String, String> map;
    LoadVarFile(GetMethodName(method), map);
    return map;
}
Beispiel #13
0
std::string Request::method_name() const { return GetMethodName(method()); }
/// <summary>Handle <c>ICorProfilerCallback::JITCompilationStarted</c></summary>
/// <remarks>The 'workhorse' </remarks>
HRESULT STDMETHODCALLTYPE CCodeInjection::JITCompilationStarted( 
        /* [in] */ FunctionID functionId, /* [in] */ BOOL fIsSafeToBlock) 
{
    ModuleID moduleId; mdToken funcToken;
    std::wstring methodName = GetMethodName(functionId, 
        moduleId, funcToken);
    ATLTRACE(_T("::JITCompilationStarted(%X -> %s)"), 
        functionId, W2CT(methodName.c_str()));

    if (L"ProfilerTarget.Program.OnMethodToInstrument" == methodName && 
        m_targetMethodRef !=0 ) {
        // get method body
        LPCBYTE pMethodHeader = NULL;
        ULONG iMethodSize = 0;
        COM_FAIL_RETURN(m_profilerInfo3->GetILFunctionBody(
            moduleId, funcToken, &pMethodHeader, &iMethodSize), 
            S_OK);

        CComPtr<IMetaDataEmit> metaDataEmit;
        COM_FAIL_RETURN(m_profilerInfo3->GetModuleMetaData(moduleId, 
            ofRead | ofWrite, IID_IMetaDataEmit, (IUnknown**)&metaDataEmit), S_OK);

        // parse IL
        Method instMethod((IMAGE_COR_ILMETHOD*)pMethodHeader); // <--
        instMethod.SetMinimumStackSize(3); // should be correct for this sample
        
        // NOTE: build signature (in the knowledge that the method we are instrumenting currently has no local vars)
        static COR_SIGNATURE localSignature[] = 
        {
            IMAGE_CEE_CS_CALLCONV_LOCAL_SIG,   
            0x02,                                   
            ELEMENT_TYPE_ARRAY, ELEMENT_TYPE_OBJECT, 01, 00, 00,  
            ELEMENT_TYPE_ARRAY, ELEMENT_TYPE_OBJECT, 01, 00, 00
        };
        
        mdSignature signature;
        COM_FAIL_RETURN(metaDataEmit->GetTokenFromSig(localSignature, sizeof(localSignature), &signature), S_OK);
        instMethod.m_header.LocalVarSigTok = signature;

        // insert new IL block
        InstructionList instructions; // NOTE: this IL will be different for an instance method or if the local vars signature is different
        instructions.push_back(new Instruction(CEE_NOP));
        instructions.push_back(new Instruction(CEE_LDC_I4_2));
        instructions.push_back(new Instruction(CEE_NEWARR, m_objectTypeRef));
        instructions.push_back(new Instruction(CEE_STLOC_1));
        instructions.push_back(new Instruction(CEE_LDLOC_1));
        instructions.push_back(new Instruction(CEE_LDC_I4_0));
        instructions.push_back(new Instruction(CEE_LDARG_0));
        instructions.push_back(new Instruction(CEE_STELEM_REF));
        instructions.push_back(new Instruction(CEE_LDLOC_1));
        instructions.push_back(new Instruction(CEE_LDC_I4_1));
        instructions.push_back(new Instruction(CEE_LDARG_1));
        instructions.push_back(new Instruction(CEE_STELEM_REF));
        instructions.push_back(new Instruction(CEE_LDLOC_1));
        instructions.push_back(new Instruction(CEE_STLOC_0));
        instructions.push_back(new Instruction(CEE_LDLOC_0));
        instructions.push_back(new Instruction(CEE_CALL, m_targetMethodRef));

        instMethod.InsertSequenceInstructionsAtOriginalOffset(
            0, instructions);

        instMethod.DumpIL();

        // allocate memory
        CComPtr<IMethodMalloc> methodMalloc;
        COM_FAIL_RETURN(m_profilerInfo3->GetILFunctionBodyAllocator(
            moduleId, &methodMalloc), S_OK);
        void* pNewMethod = methodMalloc->Alloc(instMethod.GetMethodSize());

        // write new method
        instMethod.WriteMethod((IMAGE_COR_ILMETHOD*)pNewMethod);
        COM_FAIL_RETURN(m_profilerInfo3->SetILFunctionBody(moduleId, 
            funcToken, (LPCBYTE) pNewMethod), S_OK);

        // update IL maps
        ULONG mapSize = instMethod.GetILMapSize();
        void* pMap = CoTaskMemAlloc(mapSize * sizeof(COR_IL_MAP));
        instMethod.PopulateILMap(mapSize, (COR_IL_MAP*)pMap);

        COM_FAIL_RETURN(m_profilerInfo3->SetILInstrumentedCodeMap(
            functionId, TRUE, mapSize, (COR_IL_MAP*)pMap), S_OK);
        CoTaskMemFree(pMap);
    }

    return S_OK;
}
Beispiel #15
0
void AdminCache::DumpCache(FILE *fp)
{
	int *itable;
	AdminId aid;
	GroupId gid;
	char flagstr[64];
	unsigned int num;
	AdminUser *pAdmin;
	AdminGroup *pGroup;
	char name_buffer[512];

	fprintf(fp, "\"Groups\"\n{\n");
	
	num = 0;
	gid = m_FirstGroup;
	while (gid != INVALID_GROUP_ID
			&& (pGroup = GetGroup(gid)) != NULL)
	{
		num++;
		FillFlagString(pGroup->addflags, flagstr, sizeof(flagstr));

		fprintf(fp, "\t/* num = %d, gid = 0x%X */\n", num, gid);
		fprintf(fp, "\t\"%s\"\n\t{\n", GetString(pGroup->nameidx));
		fprintf(fp, "\t\t\"flags\"\t\t\t\"%s\"\n", flagstr);
		fprintf(fp, "\t\t\"immunity\"\t\t\"%d\"\n", pGroup->immunity_level);
		
		if (pGroup->immune_table != -1
			&& (itable = (int *)m_pMemory->GetAddress(pGroup->immune_table)) != NULL)
		{
			AdminGroup *pAltGroup;
			const char *gname, *mod;

			for (int i = 1; i <= itable[0]; i++)
			{
				if ((pAltGroup = GetGroup(itable[i])) == NULL)
				{
					/* Assume the rest of the table is corrupt */
					break;
				}
				gname = GetString(pAltGroup->nameidx);
				if (atoi(gname) != 0)
				{
					mod = "@";
				}
				else
				{
					mod = "";
				}
				fprintf(fp, "\t\t\"immunity\"\t\t\"%s%s\"\n", mod, gname);
			}
		}

		fprintf(fp, "\n\t\t\"Overrides\"\n\t\t{\n");
		if (pGroup->pCmdGrpTable != NULL)
		{
			sm_trie_bad_iterator(pGroup->pCmdGrpTable, 
				name_buffer,
				sizeof(name_buffer),
				iterator_group_grp_override,
				fp);
		}
		if (pGroup->pCmdTable != NULL)
		{
			sm_trie_bad_iterator(pGroup->pCmdTable, 
				name_buffer,
				sizeof(name_buffer),
				iterator_group_basic_override,
				fp);
		}
		fprintf(fp, "\t\t}\n");

		fprintf(fp, "\t}\n");

		if ((gid = pGroup->next_grp) != INVALID_GROUP_ID)
		{
			fprintf(fp, "\n");
		}
	}

	fprintf(fp, "}\n\n");
	fprintf(fp, "\"Admins\"\n{\n");

	num = 0;
	aid = m_FirstUser;
	while (aid != INVALID_ADMIN_ID
			&& (pAdmin = GetUser(aid)) != NULL)
	{
		num++;
		FillFlagString(pAdmin->flags, flagstr, sizeof(flagstr));

		fprintf(fp, "\t/* num = %d, aid = 0x%X, serialno = 0x%X*/\n", num, aid, pAdmin->serialchange);

		if (pAdmin->nameidx != -1)
		{
			fprintf(fp, "\t\"%s\"\n\t{\n", GetString(pAdmin->nameidx));
		}
		else
		{
			fprintf(fp, "\t\"\"\n\t{\n");
		}

		if (pAdmin->auth.identidx != -1)
		{
			fprintf(fp, "\t\t\"auth\"\t\t\t\"%s\"\n", GetMethodName(pAdmin->auth.index));
			fprintf(fp, "\t\t\"identity\"\t\t\"%s\"\n", GetString(pAdmin->auth.identidx));
		}
		if (pAdmin->password != -1)
		{
			fprintf(fp, "\t\t\"password\"\t\t\"%s\"\n", GetString(pAdmin->password));
		}
		fprintf(fp, "\t\t\"flags\"\t\t\t\"%s\"\n", flagstr);
		fprintf(fp, "\t\t\"immunity\"\t\t\"%d\"\n", pAdmin->immunity_level);

		if (pAdmin->grp_count != 0 
			&& pAdmin->grp_table != -1 
			&& (itable = (int *)m_pMemory->GetAddress(pAdmin->grp_table)) != NULL)
		{
			unsigned int i;

			for (i = 0; i < pAdmin->grp_count; i++)
			{
				if ((pGroup = GetGroup(itable[i])) == NULL)
				{
					/* Assume the rest of the table is corrupt */
					break;
				}
				fprintf(fp, "\t\t\"group\"\t\t\t\"%s\"\n", GetString(pGroup->nameidx));
			}
		}

		fprintf(fp, "\t}\n");

		if ((aid = pAdmin->next_user) != INVALID_ADMIN_ID)
		{
			fprintf(fp, "\n");
		}
	}

	fprintf(fp, "}\n\n");

	fprintf(fp, "\"Overrides\"\n{\n");
	if (m_pCmdGrpOverrides != NULL)
	{
		sm_trie_bad_iterator(m_pCmdGrpOverrides,
			name_buffer,
			sizeof(name_buffer),
			iterator_glob_grp_override,
			fp);
	}
	if (m_pCmdOverrides != NULL)
	{
		sm_trie_bad_iterator(m_pCmdOverrides,
			name_buffer, 
			sizeof(name_buffer), 
			iterator_glob_basic_override, 
			fp);
	}
	fprintf(fp, "}\n");
}
Beispiel #16
0
void CPipeServer::Start(void)
{
	BYTE command;
	while (TRUE)
	{
		CreatePipeandWaitForconnect();

		try
		{
			while (TRUE)
			{
				command=ReadByte();

				switch(command)
				{
					case MONOCMD_INITMONO:
						InitMono();					
						break;	

					case MONOCMD_OBJECT_GETCLASS:
						Object_GetClass();
						break;

					case MONOCMD_ENUMDOMAINS:
						EnumDomains();
						break;

					case MONOCMD_SETCURRENTDOMAIN:
						SetCurrentDomain();
						break;

					case MONOCMD_ENUMASSEMBLIES:
						EnumAssemblies();
						break;

					case MONOCMD_GETIMAGEFROMASSEMBLY:
						GetImageFromAssembly();
						break;

					case MONOCMD_GETIMAGENAME:
						GetImageName();
						break;

					case MONOCMD_ENUMCLASSESINIMAGE:
						EnumClassesInImage();
						break;

					case MONOCMD_ENUMFIELDSINCLASS:
						EnumFieldsInClass();
						break;

					case MONOCMD_ENUMMETHODSINCLASS:
						EnumMethodsInClass();
						break;

					case MONOCMD_COMPILEMETHOD:
						CompileMethod();
						break;

					case MONOCMD_GETMETHODHEADER:
						GetMethodHeader();
						break;

					case MONOCMD_GETMETHODHEADER_CODE:
						GetILCode();
						break;

					case MONOCMD_LOOKUPRVA:
						RvaMap();
						break;

					case MONOCMD_GETJITINFO:
						GetJitInfo();
						break;

					case MONOCMD_FINDCLASS:
						FindClass();
						break;

					case MONOCMD_FINDMETHOD:
						FindMethod();
						break;

					case MONOCMD_GETMETHODNAME:
						GetMethodName();
						break;		

					case MONOCMD_GETMETHODCLASS:
						GetMethodClass();
						break;

					case MONOCMD_GETCLASSNAME:
						GetKlassName();
						break;

					case MONOCMD_GETCLASSNAMESPACE:
						GetClassNamespace();
						break;

					case MONOCMD_FREEMETHOD:
						FreeMethod();
						break;

					case MONOCMD_TERMINATE:												
						return;

					case MONOCMD_DISASSEMBLE:
						DisassembleMethod();
						break;

					case MONOCMD_GETMETHODSIGNATURE:
						GetMethodSignature();
						break;

					case MONOCMD_GETPARENTCLASS:
						GetParentClass();
						break;

					case MONOCMD_GETSTATICFIELDADDRESSFROMCLASS:
						GetStaticFieldAddressFromClass();
						break;
				}
			}			
		}
		catch (char *e)
		{
			//Pipe error, or something else that wasn't caught. Exit the connection and start over	
			OutputDebugStringA("Pipe error:\n");
			OutputDebugStringA(e);

			if (attached)
			{
				mono_thread_detach(mono_selfthread);
				attached=FALSE;
			}
			

		}
		catch (...)
		{
			OutputDebugStringA("Unexpected pipe error\n");
			if (attached)
			{
				mono_thread_detach(mono_selfthread);
				attached=FALSE;
			}	
		}

	}

}