private uint GetNextSectStart(uint rva, uint tide)
{
- if (tide < SectionAlignment) return rva + SectionAlignment;
- return rva + ((tide / SectionAlignment) + 1) * SectionAlignment;
+ uint c = tide / SectionAlignment;
+ if ((tide % SectionAlignment) != 0)
+ c++;
+ return rva + (c * SectionAlignment);
}
private void BuildTextSection()
private static readonly string mscorlibName = "mscorlib";
private Module thisMod;
private ClassDef moduleClass;
- private ArrayList classRefList = new ArrayList();
- private ArrayList classDefList = new ArrayList();
private ArrayList resources = new ArrayList ();
private Assembly thisAssembly;
private static bool isMSCorlib;
return modRef;
}
+ public ClassRef AddExternClass(string ns, string name, TypeAttr attrs, MetaDataElement declRef)
+ {
+ return new ExternClassRef (attrs, ns, name, declRef, metaData);
+ }
+
/// <summary>
/// Add a "global" method to this module
/// </summary>
/// <param name="retType">return type</param>
/// <param name="pars">method parameters</param>
/// <returns>a descriptor for this new "global" method</returns>
+ public MethodDef AddMethod (string name, Param ret_param, Param [] pars)
+ {
+ return moduleClass.AddMethod (name, ret_param, pars);
+ }
+
public MethodDef AddMethod(string name, Type retType, Param[] pars)
{
- return moduleClass.AddMethod(name,retType,pars);
+ return AddMethod (name, new Param (ParamAttr.Default, "", retType), pars);
}
/// <summary>
/// <param name="retType">return type</param>
/// <param name="pars">method parameters</param>
/// <returns>a descriptor for this new "global" method</returns>
+ public MethodDef AddMethod (MethAttr mAtts, ImplAttr iAtts, string name, Param ret_param, Param [] pars)
+ {
+ return moduleClass.AddMethod (mAtts, iAtts, name, ret_param, pars);
+ }
+
public MethodDef AddMethod(MethAttr mAtts, ImplAttr iAtts, string name, Type retType, Param[] pars)
{
- return moduleClass.AddMethod(mAtts,iAtts,name,retType,pars);
+ return AddMethod (mAtts, iAtts, name, new Param (ParamAttr.Default, "", retType), pars);
}
public MethodRef AddMethodToTypeSpec (Type item, string name, Type retType, Type[] pars)
public void AddGenericParam (GenParam param)
{
- param.GetTypeSpec (metaData);
+ metaData.AddToTable (MDTable.TypeSpec, param);
}
public FileRef AddFile(string fName, byte[] hashBytes, bool hasMetaData, bool entryPoint)
public void AddCustomAttribute (Method meth, byte [] data, MetaDataElement element)
{
metaData.AddCustomAttribute (new CustomAttribute (element, meth, data));
+ element.HasCustomAttr = true;
}
public void AddDeclSecurity (SecurityAction sec_action, byte [] data, MetaDataElement element)
metaData.AddDeclSecurity (new DeclSecurity (element, (ushort) sec_action, data));
}
+ public void AddDeclSecurity (SecurityAction sec_action, PEAPI.PermissionSet ps, MetaDataElement element)
+ {
+ metaData.AddDeclSecurity (new DeclSecurity_20 (element, (ushort) sec_action, ps));
+ }
+
/// <summary>
/// Add a managed resource from another assembly.
/// </summary>
/// Write out the PEFile (the "bake" function)
/// </summary>
public void WritePEFile() { /* the "bake" function */
- fileImage.ReserveStrongNameSignatureSpace = thisAssembly.HasPublicKey;
+ if (thisAssembly != null)
+ fileImage.ReserveStrongNameSignatureSpace = thisAssembly.HasPublicKey;
fileImage.MakeFile();
}
/// Error for invalid PE file
/// </summary>
public class PEFileException : System.Exception {
- public PEFileException(string msg) : base("Error in PE File: " + msg) { }
+ public PEFileException(string msg) : base(msg) { }
}
public class NotYetImplementedException : System.Exception {