void Property::Read(ModuleReader &reader, const MemberHeader &header) { // Get the module. Module *module = GetModule(); // Read the member attributes. ReadAttributes(reader, header.memberAttributes); // Read the type, and the number of indices. uint8_t numindices; uint32_t typeId; reader >> typeId >> numindices; // Read the indices for(size_t i = 0; i < numindices; ++i) { uint32_t indexTypeId; reader >> indexTypeId; indices.push_back(module->GetType(indexTypeId)); } // Read the get and set accessor. uint32_t getId, setId; reader >> getId >> setId; // Get the type, getter and setter. type = module->GetType(typeId); if(getId != 0) getAccessor = module->GetFunction(getId); if(setId != 0) setAccessor = module->GetFunction(setId); }
//************************************************************************* // Method: getManagedDefinition // Description: Uses reflection to get information about a managed method // // Parameters: // fInfo - structure which contains query data // // Return Value: (InterceptedFunction) the function definition //************************************************************************* InterceptedFunction * AddCustIntWizPg2::getManagedDefinition (functionInformation * fInfo) { InterceptedFunction * iFunc = new InterceptedFunction(); //Set the function name iFunc->Name = fInfo->functionName; //Set the library location name iFunc->OriginalDll = Path::GetFileName(fInfo->libraryName); //LOAD THE ASSEMBLY TO GET MORE INFORMATION Assembly * asmLibrary = Assembly::LoadFrom (fInfo->libraryName); //Get the module Module * asmModule = asmLibrary->GetModule (fInfo->moduleName); //Get the type Type * moduleType = asmModule->GetType (fInfo->typeName); //Get the method if (!fInfo->isConstructor) { MethodInfo * mi = NULL; try { mi = moduleType->GetMethod (getBaseName(fInfo->functionName), fInfo->bindingFlags, NULL, fInfo->paramTypeArray, NULL); } catch(...) { // in case of an exception, just return NULL return NULL; } if (!mi) return NULL; //Get Parameter Info ParameterInfo * paramInfo[] = mi->GetParameters(); //Set the modifiers if (mi->IsPrivate) iFunc->AddTypeModifier ("private"); if (mi->IsPublic) iFunc->AddTypeModifier ("public"); if (mi->IsVirtual) iFunc->AddTypeModifier ("virtual"); if (mi->IsAbstract) iFunc->AddTypeModifier ("abstract"); if (mi->IsStatic) iFunc->AddTypeModifier ("static"); //Set return type iFunc->ReturnType = mi->ReturnType->ToString(); //Set Parameter Info for (int parCount = 0; parCount < paramInfo->Count; parCount++) { ParameterInfo * pInfo = paramInfo[parCount]; InterceptedFunctionParameter * ifParam = new InterceptedFunctionParameter (); ifParam->ID = pInfo->Position; ifParam->Name = pInfo->Name; ifParam->Type = pInfo->ParameterType->FullName; ifParam->Access = ""; if (pInfo->IsIn) ifParam->Access = "IN "; if (pInfo->IsOut) ifParam->Access = String::Concat(ifParam->Access, "OUT"); if (ifParam->Access->Length == 0) ifParam->Access = "NONE"; iFunc->AddParameter (ifParam); } } else { ConstructorInfo * ci = moduleType->GetConstructor (fInfo->bindingFlags, NULL, fInfo->paramTypeArray, NULL); if (!ci) return NULL; //Get Parameter Info ParameterInfo * paramInfo[] = ci->GetParameters(); //Set the modifiers if (ci->IsPrivate) iFunc->AddTypeModifier ("private"); if (ci->IsPublic) iFunc->AddTypeModifier ("public"); if (ci->IsVirtual) iFunc->AddTypeModifier ("virtual"); if (ci->IsAbstract) iFunc->AddTypeModifier ("abstract"); if (ci->IsStatic) iFunc->AddTypeModifier ("static"); //Set return type iFunc->ReturnType = S"System.Void"; //Set Parameter Info for (int parCount = 0; parCount < paramInfo->Count; parCount++) { ParameterInfo * pInfo = paramInfo[parCount]; InterceptedFunctionParameter * ifParam = new InterceptedFunctionParameter (); ifParam->ID = pInfo->Position; ifParam->Name = pInfo->Name; ifParam->Type = pInfo->ParameterType->FullName; ifParam->Access = ""; if (pInfo->IsIn) ifParam->Access = "IN "; if (pInfo->IsOut) ifParam->Access = String::Concat(ifParam->Access, "OUT"); if (ifParam->Access->Length == 0) ifParam->Access = "NONE"; iFunc->AddParameter (ifParam); } } return iFunc; }