Washi1337 / AsmResolver

A library for creating, reading and editing PE files and .NET modules.
https://docs.washi.dev/asmresolver/
MIT License
826 stars 125 forks source link

Not Work with Tinysharp #541

Closed steve02081504 closed 3 months ago

steve02081504 commented 3 months ago

AsmResolver Version

5.5.1.0

.NET Version

8.0.1

Operating System

Windows

Describe the Bug

An error exe is generated when reading and rewriting a program generated by Tinysharp. Its not a big deal. So okay not to fix it if y want.

How To Reproduce

~ >'"Hello 世界!👾"' | ps12exe
Compiled file written -> 1024 bytes
~ >./a.exe
Hello 世界!👾
~ >Get-ChildItem ~/workstation/pwshProjs/ps12exe/src/bin/AsmResolver | ForEach-Object { Add-Type -LiteralPath $_ }
~ >$file = [AsmResolver.PE.PEImage]::FromFile('.\a.exe')
~ >$Builder = New-Object AsmResolver.PE.DotNet.Builder.ManagedPEFileBuilder
~ >$file = $builder.CreateFile($file)
~ >$file.Write('.\a.exe')
~ >./a.exe
爮汥捯
䀀ȀЀ
~ >

Expected Behavior

Hello 世界!👾

Actual Behavior

爮汥捯 䀀ȀЀ

Additional Context

图片

Washi1337 commented 3 months ago

This is by design. ManagedPEFileBuilder does a full reconstruction of the PE and does not necessarily preserve existing segments unless you explicitly tell it to do as such.

steve02081504 commented 3 months ago

got it! txh for explaning.