Exemple #1
0
        MDSigPatcher(List <byte> sigBuilder, RemappedTypeTokens remappedTypeTokens, RawModuleBytes moduleData, uint blobOffset, uint sigOffset)
        {
            this.sigBuilder         = sigBuilder;
            this.remappedTypeTokens = remappedTypeTokens;
            currPos = (byte *)moduleData.Pointer + blobOffset + sigOffset;
            uint size = MDPatcherUtils.ReadCompressedUInt32(ref currPos, (byte *)moduleData.Pointer + moduleData.Size);

            startPos         = currPos;
            endPos           = currPos + size;
            usingBuilder     = false;
            recursionCounter = 0;
        }
Exemple #2
0
 public MDEditorPatcher(RawModuleBytes moduleData, MetadataEditor mdEditor, IAssembly tempAssembly, TypeDef nonNestedEditedTypeOrNull, MDEditorPatcherOptions options)
 {
     this.moduleData   = moduleData;
     peFile            = (byte *)moduleData.Pointer;
     this.tempAssembly = tempAssembly;
     this.nonNestedEditedTypeOrNull = nonNestedEditedTypeOrNull;
     remappedTypeTokens             = new RemappedTypeTokens(nonNestedEditedTypeOrNull);
     sigBuilder         = new List <byte>();
     this.mdEditor      = mdEditor;
     this.options       = options;
     tempAssemblyRefRid = 0;
 }
Exemple #3
0
 public static byte[]? PatchTypeSignature(List <byte> sigBuilder, RemappedTypeTokens remappedTypeTokens, RawModuleBytes moduleData, uint blobOffset, uint sigOffset)
 {
     try {
         var patcher = new MDSigPatcher(sigBuilder, remappedTypeTokens, moduleData, blobOffset, sigOffset);
         patcher.PatchTypeSignature();
         return(patcher.GetResult());
     }
     catch (InvalidSignatureException) {
     }
     Debug.Fail("Failed to patch type sig");
     return(null);
 }
Exemple #4
0
        MDSigPatcher(List <byte> sigBuilder, RemappedTypeTokens remappedTypeTokens, RawModuleBytes moduleData, uint blobOffset, uint sigOffset)
        {
            if ((ulong)blobOffset + sigOffset > (ulong)moduleData.Size)
            {
                ThrowInvalidSignatureException();
            }
            this.sigBuilder         = sigBuilder;
            this.remappedTypeTokens = remappedTypeTokens;
            currPos = (byte *)moduleData.Pointer + blobOffset + sigOffset;
            uint size = MDPatcherUtils.ReadCompressedUInt32(ref currPos, (byte *)moduleData.Pointer + moduleData.Size);

            startPos = currPos;
            endPos   = currPos + size;
            if ((ulong)(endPos - (byte *)moduleData.Pointer) > (ulong)moduleData.Size)
            {
                ThrowInvalidSignatureException();
            }
            usingBuilder     = false;
            recursionCounter = 0;
        }